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--.clang-format5
-rw-r--r--doc/python_api/sphinx_doc_gen.py1
-rw-r--r--extern/draco/dracoenc/cmake/util.cmake1
-rw-r--r--intern/atomic/atomic_ops.h10
-rw-r--r--intern/atomic/intern/atomic_ops_utils.h6
-rw-r--r--intern/audaspace/intern/AUD_PyInit.cpp6
-rw-r--r--intern/clog/clog.c3
-rw-r--r--intern/cycles/blender/addon/properties.py18
-rw-r--r--intern/cycles/blender/addon/ui.py7
-rw-r--r--intern/cycles/blender/addon/version_update.py201
-rw-r--r--intern/cycles/blender/blender_curves.cpp4
-rw-r--r--intern/cycles/blender/blender_mesh.cpp2
-rw-r--r--intern/cycles/blender/blender_session.cpp27
-rw-r--r--intern/cycles/blender/blender_shader.cpp22
-rw-r--r--intern/cycles/blender/blender_sync.cpp2
-rw-r--r--intern/cycles/bvh/bvh8.cpp52
-rw-r--r--intern/cycles/bvh/bvh8.h58
-rw-r--r--intern/cycles/bvh/bvh_embree.cpp22
-rw-r--r--intern/cycles/device/device.cpp3
-rw-r--r--intern/cycles/device/device_cpu.cpp16
-rw-r--r--intern/cycles/device/device_cuda.cpp5
-rw-r--r--intern/cycles/device/device_denoising.cpp12
-rw-r--r--intern/cycles/device/device_opencl.cpp4
-rw-r--r--intern/cycles/device/device_split_kernel.h2
-rw-r--r--intern/cycles/device/device_task.h3
-rw-r--r--intern/cycles/device/opencl/opencl.h4
-rw-r--r--intern/cycles/device/opencl/opencl_split.cpp8
-rw-r--r--intern/cycles/kernel/bvh/bvh.h13
-rw-r--r--intern/cycles/kernel/bvh/bvh_nodes.h310
-rw-r--r--intern/cycles/kernel/bvh/bvh_shadow_all.h10
-rw-r--r--intern/cycles/kernel/bvh/bvh_traversal.h124
-rw-r--r--intern/cycles/kernel/bvh/bvh_types.h1
-rw-r--r--intern/cycles/kernel/bvh/obvh_nodes.h181
-rw-r--r--intern/cycles/kernel/bvh/obvh_shadow_all.h14
-rw-r--r--intern/cycles/kernel/bvh/obvh_traversal.h81
-rw-r--r--intern/cycles/kernel/bvh/qbvh_nodes.h189
-rw-r--r--intern/cycles/kernel/bvh/qbvh_shadow_all.h12
-rw-r--r--intern/cycles/kernel/bvh/qbvh_traversal.h73
-rw-r--r--intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h19
-rw-r--r--intern/cycles/kernel/closure/bsdf_hair.h4
-rw-r--r--intern/cycles/kernel/closure/bsdf_hair_principled.h3
-rw-r--r--intern/cycles/kernel/closure/bsdf_microfacet_multi.h18
-rw-r--r--intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h23
-rw-r--r--intern/cycles/kernel/closure/bsdf_util.h2
-rw-r--r--intern/cycles/kernel/closure/bssrdf.h6
-rw-r--r--intern/cycles/kernel/filter/filter_features.h5
-rw-r--r--intern/cycles/kernel/filter/filter_features_sse.h4
-rw-r--r--intern/cycles/kernel/filter/filter_nlm_cpu.h3
-rw-r--r--intern/cycles/kernel/filter/filter_prefilter.h26
-rw-r--r--intern/cycles/kernel/filter/filter_transform.h8
-rw-r--r--intern/cycles/kernel/filter/filter_transform_gpu.h8
-rw-r--r--intern/cycles/kernel/filter/filter_transform_sse.h8
-rw-r--r--intern/cycles/kernel/geom/geom_curve_intersect.h121
-rw-r--r--intern/cycles/kernel/geom/geom_object.h3
-rw-r--r--intern/cycles/kernel/geom/geom_triangle_intersect.h58
-rw-r--r--intern/cycles/kernel/kernel_bake.h6
-rw-r--r--intern/cycles/kernel/kernel_id_passes.h32
-rw-r--r--intern/cycles/kernel/kernel_light.h3
-rw-r--r--intern/cycles/kernel/kernel_montecarlo.h31
-rw-r--r--intern/cycles/kernel/kernel_path.h32
-rw-r--r--intern/cycles/kernel/kernel_path_branched.h4
-rw-r--r--intern/cycles/kernel/kernel_path_surface.h12
-rw-r--r--intern/cycles/kernel/kernel_shadow.h12
-rw-r--r--intern/cycles/kernel/kernel_types.h4
-rw-r--r--intern/cycles/kernel/kernel_volume.h4
-rw-r--r--intern/cycles/kernel/kernels/cuda/kernel_config.h3
-rw-r--r--intern/cycles/kernel/osl/background.cpp4
-rw-r--r--intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp2
-rw-r--r--intern/cycles/kernel/osl/bsdf_phong_ramp.cpp2
-rw-r--r--intern/cycles/kernel/osl/emissive.cpp2
-rw-r--r--intern/cycles/kernel/osl/osl_bssrdf.cpp2
-rw-r--r--intern/cycles/kernel/osl/osl_closures.cpp71
-rw-r--r--intern/cycles/kernel/osl/osl_closures.h10
-rw-r--r--intern/cycles/kernel/osl/osl_globals.h44
-rw-r--r--intern/cycles/kernel/osl/osl_services.cpp410
-rw-r--r--intern/cycles/kernel/osl/osl_services.h3
-rw-r--r--intern/cycles/kernel/osl/osl_shader.cpp43
-rw-r--r--intern/cycles/kernel/shaders/node_ies_light.osl4
-rw-r--r--intern/cycles/kernel/shaders/stdosl.h18
-rw-r--r--intern/cycles/kernel/split/kernel_buffer_update.h4
-rw-r--r--intern/cycles/kernel/split/kernel_data_init.h8
-rw-r--r--intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h6
-rw-r--r--intern/cycles/kernel/split/kernel_next_iteration_setup.h6
-rw-r--r--intern/cycles/kernel/split/kernel_split_data_types.h11
-rw-r--r--intern/cycles/kernel/svm/svm_ao.h30
-rw-r--r--intern/cycles/kernel/svm/svm_ies.h18
-rw-r--r--intern/cycles/kernel/svm/svm_types.h5
-rw-r--r--intern/cycles/kernel/svm/svm_voronoi.h3
-rw-r--r--intern/cycles/render/CMakeLists.txt2
-rw-r--r--intern/cycles/render/attribute.cpp3
-rw-r--r--intern/cycles/render/camera.cpp6
-rw-r--r--intern/cycles/render/colorspace.cpp374
-rw-r--r--intern/cycles/render/colorspace.h65
-rw-r--r--intern/cycles/render/curves.cpp7
-rw-r--r--intern/cycles/render/curves.h3
-rw-r--r--intern/cycles/render/denoising.cpp12
-rw-r--r--intern/cycles/render/denoising.h15
-rw-r--r--intern/cycles/render/image.cpp139
-rw-r--r--intern/cycles/render/image.h38
-rw-r--r--intern/cycles/render/mesh.cpp5
-rw-r--r--intern/cycles/render/nodes.cpp103
-rw-r--r--intern/cycles/render/nodes.h52
-rw-r--r--intern/cycles/render/osl.cpp68
-rw-r--r--intern/cycles/render/osl.h8
-rw-r--r--intern/cycles/render/shader.cpp6
-rw-r--r--intern/cycles/render/shader.h6
-rw-r--r--intern/cycles/render/svm.cpp6
-rw-r--r--intern/cycles/render/tile.cpp31
-rw-r--r--intern/cycles/subd/subd_split.cpp2
-rw-r--r--intern/cycles/util/util_aligned_malloc.h15
-rw-r--r--intern/cycles/util/util_color.h9
-rw-r--r--intern/cycles/util/util_debug.h3
-rw-r--r--intern/cycles/util/util_half.h3
-rw-r--r--intern/cycles/util/util_ies.cpp28
-rw-r--r--intern/cycles/util/util_image.h1
-rw-r--r--intern/cycles/util/util_map.h7
-rw-r--r--intern/cycles/util/util_math.h19
-rw-r--r--intern/cycles/util/util_math_fast.h12
-rw-r--r--intern/cycles/util/util_math_intersect.h2
-rw-r--r--intern/cycles/util/util_math_matrix.h38
-rw-r--r--intern/cycles/util/util_profiling.cpp3
-rw-r--r--intern/cycles/util/util_progress.h3
-rw-r--r--intern/cycles/util/util_task.cpp2
-rw-r--r--intern/cycles/util/util_types_float8.h52
-rw-r--r--intern/cycles/util/util_types_float8_impl.h52
-rw-r--r--intern/dualcon/intern/MemoryAllocator.h32
-rw-r--r--intern/dualcon/intern/Projections.h14
-rw-r--r--intern/dualcon/intern/octree.cpp178
-rw-r--r--intern/dualcon/intern/octree.h12
-rw-r--r--intern/ffmpeg/ffmpeg_compat.h10
-rw-r--r--intern/ghost/GHOST_C-api.h17
-rw-r--r--intern/ghost/GHOST_ISystem.h22
-rw-r--r--intern/ghost/GHOST_IWindow.h9
-rw-r--r--intern/ghost/GHOST_Rect.h25
-rw-r--r--intern/ghost/GHOST_Types.h13
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp7
-rw-r--r--intern/ghost/intern/GHOST_Context.h12
-rw-r--r--intern/ghost/intern/GHOST_ContextCGL.h1
-rw-r--r--intern/ghost/intern/GHOST_ContextCGL.mm75
-rw-r--r--intern/ghost/intern/GHOST_ContextEGL.cpp37
-rw-r--r--intern/ghost/intern/GHOST_ContextEGL.h1
-rw-r--r--intern/ghost/intern/GHOST_ContextGLX.cpp35
-rw-r--r--intern/ghost/intern/GHOST_ContextGLX.h9
-rw-r--r--intern/ghost/intern/GHOST_ContextNone.h3
-rw-r--r--intern/ghost/intern/GHOST_ContextSDL.cpp19
-rw-r--r--intern/ghost/intern/GHOST_ContextSDL.h1
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.cpp159
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.h12
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerCocoa.h6
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerCocoa.mm14
-rw-r--r--intern/ghost/intern/GHOST_DropTargetWin32.cpp11
-rw-r--r--intern/ghost/intern/GHOST_EventDragnDrop.h37
-rw-r--r--intern/ghost/intern/GHOST_ImeWin32.cpp18
-rw-r--r--intern/ghost/intern/GHOST_ImeWin32.h2
-rw-r--r--intern/ghost/intern/GHOST_System.cpp21
-rw-r--r--intern/ghost/intern/GHOST_System.h6
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.h12
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm180
-rw-r--r--intern/ghost/intern/GHOST_SystemSDL.cpp16
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp80
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.h14
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp52
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.h6
-rw-r--r--intern/ghost/intern/GHOST_Window.cpp13
-rw-r--r--intern/ghost/intern/GHOST_Window.h19
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.h5
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm33
-rw-r--r--intern/ghost/intern/GHOST_WindowManager.cpp4
-rw-r--r--intern/ghost/intern/GHOST_WindowNULL.h5
-rw-r--r--intern/ghost/intern/GHOST_WindowSDL.cpp8
-rw-r--r--intern/ghost/intern/GHOST_WindowSDL.h3
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp17
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.h9
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp155
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.h5
-rw-r--r--intern/ghost/test/gears/GHOST_Test.cpp9
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h82
-rw-r--r--intern/guardedalloc/intern/mallocn_guarded_impl.c4
-rw-r--r--intern/guardedalloc/intern/mmap_win.c2
-rw-r--r--intern/guardedalloc/test/simpletest/memtest.c2
-rw-r--r--intern/iksolver/intern/IK_QJacobianSolver.cpp4
-rw-r--r--intern/iksolver/intern/IK_QSegment.cpp2
-rw-r--r--intern/iksolver/intern/IK_QSegment.h6
-rw-r--r--intern/locale/boost_locale_wrapper.cpp5
-rw-r--r--intern/mikktspace/mikktspace.c59
-rw-r--r--intern/mikktspace/mikktspace.h55
-rw-r--r--intern/opencolorio/ocio_impl.cc8
-rw-r--r--intern/opencolorio/ocio_impl_glsl.cc4
-rw-r--r--intern/rigidbody/RBI_api.h3
-rw-r--r--intern/rigidbody/rb_bullet_api.cpp46
-rw-r--r--intern/string/STR_String.h4
-rw-r--r--intern/string/intern/STR_String.cpp14
-rw-r--r--intern/utfconv/utf_winfunc.h4
-rw-r--r--intern/utfconv/utfconv.c20
-rw-r--r--intern/utfconv/utfconv.h10
-rw-r--r--release/datafiles/userdef/userdef_default_theme.c1
-rw-r--r--release/scripts/presets/gpencil_material/fill_only.py5
-rw-r--r--release/scripts/presets/gpencil_material/stroke_and_fill.py5
-rw-r--r--release/scripts/presets/gpencil_material/stroke_only.py5
-rw-r--r--release/scripts/presets/interface_theme/blender_light.xml1
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/blender_default.py106
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py329
-rw-r--r--release/scripts/startup/bl_operators/object_quick_effects.py4
-rw-r--r--release/scripts/startup/bl_operators/presets.py5
-rw-r--r--release/scripts/startup/bl_operators/view3d.py6
-rw-r--r--release/scripts/startup/bl_operators/wm.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_grease_pencil_common.py20
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py12
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py26
-rw-r--r--release/scripts/startup/bl_ui/properties_view_layer.py1
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py154
-rw-r--r--release/scripts/startup/bl_ui/space_dopesheet.py1
-rw-r--r--release/scripts/startup/bl_ui/space_image.py274
-rw-r--r--release/scripts/startup/bl_ui/space_sequencer.py89
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_common.py32
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_toolbar.py31
-rw-r--r--release/scripts/startup/bl_ui/space_topbar.py14
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py7
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py413
-rw-r--r--source/blender/alembic/intern/abc_exporter.cc3
-rw-r--r--source/blender/alembic/intern/abc_exporter.h4
-rw-r--r--source/blender/alembic/intern/abc_object.cc3
-rw-r--r--source/blender/alembic/intern/abc_util.cc8
-rw-r--r--source/blender/alembic/intern/abc_util.h5
-rw-r--r--source/blender/alembic/intern/alembic_capi.cc12
-rw-r--r--source/blender/avi/AVI_avi.h16
-rw-r--r--source/blender/avi/intern/avi_rgb32.c2
-rw-r--r--source/blender/blenfont/BLF_api.h3
-rw-r--r--source/blender/blenfont/CMakeLists.txt4
-rw-r--r--source/blender/blenfont/intern/blf.c9
-rw-r--r--source/blender/blenfont/intern/blf_thumbs.c4
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h5
-rw-r--r--source/blender/blenkernel/BKE_animsys.h3
-rw-r--r--source/blender/blenkernel/BKE_armature.h3
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/BKE_bvhutils.h5
-rw-r--r--source/blender/blenkernel/BKE_cachefile.h27
-rw-r--r--source/blender/blenkernel/BKE_constraint.h15
-rw-r--r--source/blender/blenkernel/BKE_customdata.h47
-rw-r--r--source/blender/blenkernel/BKE_deform.h3
-rw-r--r--source/blender/blenkernel/BKE_dynamicpaint.h2
-rw-r--r--source/blender/blenkernel/BKE_effect.h10
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h44
-rw-r--r--source/blender/blenkernel/BKE_gpencil_modifier.h4
-rw-r--r--source/blender/blenkernel/BKE_layer.h1
-rw-r--r--source/blender/blenkernel/BKE_library.h43
-rw-r--r--source/blender/blenkernel/BKE_library_query.h7
-rw-r--r--source/blender/blenkernel/BKE_library_remap.h45
-rw-r--r--source/blender/blenkernel/BKE_main.h15
-rw-r--r--source/blender/blenkernel/BKE_material.h2
-rw-r--r--source/blender/blenkernel/BKE_mesh.h11
-rw-r--r--source/blender/blenkernel/BKE_mesh_remap.h17
-rw-r--r--source/blender/blenkernel/BKE_modifier.h4
-rw-r--r--source/blender/blenkernel/BKE_movieclip.h3
-rw-r--r--source/blender/blenkernel/BKE_node.h40
-rw-r--r--source/blender/blenkernel/BKE_object.h2
-rw-r--r--source/blender/blenkernel/BKE_paint.h1
-rw-r--r--source/blender/blenkernel/BKE_particle.h11
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h45
-rw-r--r--source/blender/blenkernel/BKE_pointcache.h7
-rw-r--r--source/blender/blenkernel/BKE_rigidbody.h3
-rw-r--r--source/blender/blenkernel/BKE_scene.h9
-rw-r--r--source/blender/blenkernel/BKE_screen.h6
-rw-r--r--source/blender/blenkernel/BKE_sequencer.h72
-rw-r--r--source/blender/blenkernel/BKE_shrinkwrap.h6
-rw-r--r--source/blender/blenkernel/BKE_softbody.h4
-rw-r--r--source/blender/blenkernel/BKE_sound.h25
-rw-r--r--source/blender/blenkernel/BKE_undo_system.h3
-rw-r--r--source/blender/blenkernel/BKE_unit.h2
-rw-r--r--source/blender/blenkernel/CMakeLists.txt12
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_intern.h5
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c47
-rw-r--r--source/blender/blenkernel/intern/action.c48
-rw-r--r--source/blender/blenkernel/intern/anim.c8
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c210
-rw-r--r--source/blender/blenkernel/intern/appdir.c13
-rw-r--r--source/blender/blenkernel/intern/armature.c607
-rw-r--r--source/blender/blenkernel/intern/armature_update.c38
-rw-r--r--source/blender/blenkernel/intern/blender.c5
-rw-r--r--source/blender/blenkernel/intern/blender_copybuffer.c3
-rw-r--r--source/blender/blenkernel/intern/blendfile.c3
-rw-r--r--source/blender/blenkernel/intern/boids.c42
-rw-r--r--source/blender/blenkernel/intern/brush.c9
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c12
-rw-r--r--source/blender/blenkernel/intern/cachefile.c253
-rw-r--r--source/blender/blenkernel/intern/camera.c6
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c6
-rw-r--r--source/blender/blenkernel/intern/cloth.c12
-rw-r--r--source/blender/blenkernel/intern/collection.c31
-rw-r--r--source/blender/blenkernel/intern/collision.c22
-rw-r--r--source/blender/blenkernel/intern/colorband.c5
-rw-r--r--source/blender/blenkernel/intern/constraint.c104
-rw-r--r--source/blender/blenkernel/intern/curve.c51
-rw-r--r--source/blender/blenkernel/intern/customdata.c67
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c68
-rw-r--r--source/blender/blenkernel/intern/deform.c19
-rw-r--r--source/blender/blenkernel/intern/displist.c9
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c277
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c2
-rw-r--r--source/blender/blenkernel/intern/editmesh.c10
-rw-r--r--source/blender/blenkernel/intern/editmesh_tangent.c16
-rw-r--r--source/blender/blenkernel/intern/effect.c9
-rw-r--r--source/blender/blenkernel/intern/fcurve.c77
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c40
-rw-r--r--source/blender/blenkernel/intern/font.c9
-rw-r--r--source/blender/blenkernel/intern/gpencil.c25
-rw-r--r--source/blender/blenkernel/intern/icons.c13
-rw-r--r--source/blender/blenkernel/intern/idprop.c12
-rw-r--r--source/blender/blenkernel/intern/image.c12
-rw-r--r--source/blender/blenkernel/intern/ipo.c107
-rw-r--r--source/blender/blenkernel/intern/key.c18
-rw-r--r--source/blender/blenkernel/intern/lattice.c72
-rw-r--r--source/blender/blenkernel/intern/layer.c17
-rw-r--r--source/blender/blenkernel/intern/library.c158
-rw-r--r--source/blender/blenkernel/intern/library_idmap.c3
-rw-r--r--source/blender/blenkernel/intern/library_override.c104
-rw-r--r--source/blender/blenkernel/intern/library_query.c65
-rw-r--r--source/blender/blenkernel/intern/library_remap.c156
-rw-r--r--source/blender/blenkernel/intern/light.c6
-rw-r--r--source/blender/blenkernel/intern/lightprobe.c6
-rw-r--r--source/blender/blenkernel/intern/linestyle.c6
-rw-r--r--source/blender/blenkernel/intern/main.c13
-rw-r--r--source/blender/blenkernel/intern/mask.c16
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c51
-rw-r--r--source/blender/blenkernel/intern/material.c6
-rw-r--r--source/blender/blenkernel/intern/mball.c27
-rw-r--r--source/blender/blenkernel/intern/mball_tessellate.c17
-rw-r--r--source/blender/blenkernel/intern/mesh.c41
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c38
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c301
-rw-r--r--source/blender/blenkernel/intern/mesh_iterators.c3
-rw-r--r--source/blender/blenkernel/intern/mesh_mapping.c69
-rw-r--r--source/blender/blenkernel/intern/mesh_merge.c41
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c126
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.c7
-rw-r--r--source/blender/blenkernel/intern/mesh_tangent.c19
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c11
-rw-r--r--source/blender/blenkernel/intern/modifier.c19
-rw-r--r--source/blender/blenkernel/intern/movieclip.c6
-rw-r--r--source/blender/blenkernel/intern/multires.c3
-rw-r--r--source/blender/blenkernel/intern/nla.c88
-rw-r--r--source/blender/blenkernel/intern/node.c122
-rw-r--r--source/blender/blenkernel/intern/object.c91
-rw-r--r--source/blender/blenkernel/intern/object_deform.c11
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c9
-rw-r--r--source/blender/blenkernel/intern/object_update.c8
-rw-r--r--source/blender/blenkernel/intern/ocean.c45
-rw-r--r--source/blender/blenkernel/intern/packedFile.c11
-rw-r--r--source/blender/blenkernel/intern/paint.c93
-rw-r--r--source/blender/blenkernel/intern/paint_toolslots.c1
-rw-r--r--source/blender/blenkernel/intern/particle.c59
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c21
-rw-r--r--source/blender/blenkernel/intern/particle_system.c62
-rw-r--r--source/blender/blenkernel/intern/pbvh.c82
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c3
-rw-r--r--source/blender/blenkernel/intern/pointcache.c9
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c63
-rw-r--r--source/blender/blenkernel/intern/scene.c133
-rw-r--r--source/blender/blenkernel/intern/screen.c3
-rw-r--r--source/blender/blenkernel/intern/seqcache.c614
-rw-r--r--source/blender/blenkernel/intern/sequencer.c414
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c39
-rw-r--r--source/blender/blenkernel/intern/smoke.c22
-rw-r--r--source/blender/blenkernel/intern/softbody.c95
-rw-r--r--source/blender/blenkernel/intern/sound.c466
-rw-r--r--source/blender/blenkernel/intern/speaker.c6
-rw-r--r--source/blender/blenkernel/intern/studiolight.c6
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c31
-rw-r--r--source/blender/blenkernel/intern/suggestions.c2
-rw-r--r--source/blender/blenkernel/intern/text.c17
-rw-r--r--source/blender/blenkernel/intern/texture.c9
-rw-r--r--source/blender/blenkernel/intern/tracking.c9
-rw-r--r--source/blender/blenkernel/intern/tracking_region_tracker.c3
-rw-r--r--source/blender/blenkernel/intern/tracking_stabilize.c4
-rw-r--r--source/blender/blenkernel/intern/undo_system.c12
-rw-r--r--source/blender/blenkernel/intern/unit.c21
-rw-r--r--source/blender/blenkernel/intern/workspace.c16
-rw-r--r--source/blender/blenkernel/intern/world.c6
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c20
-rw-r--r--source/blender/blenkernel/nla_private.h3
-rw-r--r--source/blender/blenlib/BLI_compiler_compat.h6
-rw-r--r--source/blender/blenlib/BLI_listbase.h4
-rw-r--r--source/blender/blenlib/BLI_rect.h2
-rw-r--r--source/blender/blenlib/CMakeLists.txt2
-rw-r--r--source/blender/blenlib/intern/DLRB_tree.c2
-rw-r--r--source/blender/blenlib/intern/expr_pylike_eval.c6
-rw-r--r--source/blender/blenlib/intern/freetypefont.c4
-rw-r--r--source/blender/blenlib/intern/hash_mm2a.c2
-rw-r--r--source/blender/blenlib/intern/math_geom.c2
-rw-r--r--source/blender/blenlib/intern/noise.c4
-rw-r--r--source/blender/blenlib/intern/storage.c13
-rw-r--r--source/blender/blenloader/CMakeLists.txt1
-rw-r--r--source/blender/blenloader/intern/readblenentry.c5
-rw-r--r--source/blender/blenloader/intern/readfile.c304
-rw-r--r--source/blender/blenloader/intern/readfile.h4
-rw-r--r--source/blender/blenloader/intern/versioning_250.c91
-rw-r--r--source/blender/blenloader/intern/versioning_260.c148
-rw-r--r--source/blender/blenloader/intern/versioning_280.c34
-rw-r--r--source/blender/blenloader/intern/versioning_cycles.c332
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c48
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c12
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c22
-rw-r--r--source/blender/blenloader/intern/writefile.c139
-rw-r--r--source/blender/bmesh/CMakeLists.txt2
-rw-r--r--source/blender/bmesh/bmesh.h43
-rw-r--r--source/blender/bmesh/bmesh_class.h24
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c3
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c22
-rw-r--r--source/blender/bmesh/intern/bmesh_edgeloop.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators_inline.h3
-rw-r--r--source/blender/bmesh/intern/bmesh_log.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c3
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c161
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c54
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_validate.c3
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c21
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c15
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon_edgenet.c12
-rw-r--r--source/blender/bmesh/intern/bmesh_query.c20
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c9
-rw-r--r--source/blender/bmesh/operators/bmo_bridge.c7
-rw-r--r--source/blender/bmesh/operators/bmo_connect_pair.c9
-rw-r--r--source/blender/bmesh/operators/bmo_create.c4
-rw-r--r--source/blender/bmesh/operators/bmo_dissolve.c18
-rw-r--r--source/blender/bmesh/operators/bmo_fill_grid.c2
-rw-r--r--source/blender/bmesh/operators/bmo_inset.c17
-rw-r--r--source/blender/bmesh/operators/bmo_join_triangles.c3
-rw-r--r--source/blender/bmesh/operators/bmo_normals.c38
-rw-r--r--source/blender/bmesh/operators/bmo_primitive.c10
-rw-r--r--source/blender/bmesh/operators/bmo_removedoubles.c5
-rw-r--r--source/blender/bmesh/operators/bmo_rotate_edges.c15
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c4
-rw-r--r--source/blender/bmesh/tools/bmesh_beautify.c3
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c314
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_collapse.c5
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_dissolve.c3
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_path_region.c13
-rw-r--r--source/blender/collada/AnimationExporter.cpp37
-rw-r--r--source/blender/collada/AnimationImporter.cpp283
-rw-r--r--source/blender/collada/ArmatureExporter.cpp2
-rw-r--r--source/blender/collada/ArmatureImporter.cpp131
-rw-r--r--source/blender/collada/BCAnimationCurve.cpp5
-rw-r--r--source/blender/collada/CMakeLists.txt2
-rw-r--r--source/blender/collada/ControllerExporter.cpp62
-rw-r--r--source/blender/collada/DocumentExporter.cpp5
-rw-r--r--source/blender/collada/DocumentImporter.cpp169
-rw-r--r--source/blender/collada/DocumentImporter.h3
-rw-r--r--source/blender/collada/EffectExporter.cpp6
-rw-r--r--source/blender/collada/ExtraHandler.cpp13
-rw-r--r--source/blender/collada/ExtraHandler.h3
-rw-r--r--source/blender/collada/GeometryExporter.cpp74
-rw-r--r--source/blender/collada/GeometryExporter.h16
-rw-r--r--source/blender/collada/ImageExporter.cpp37
-rw-r--r--source/blender/collada/MeshImporter.cpp5
-rw-r--r--source/blender/collada/MeshImporter.h28
-rw-r--r--source/blender/collada/SceneExporter.cpp30
-rw-r--r--source/blender/collada/SkinInfo.cpp74
-rw-r--r--source/blender/collada/TransformReader.h2
-rw-r--r--source/blender/collada/TransformWriter.cpp3
-rw-r--r--source/blender/collada/collada_utils.cpp43
-rw-r--r--source/blender/compositor/CMakeLists.txt4
-rw-r--r--source/blender/compositor/COM_compositor.h121
-rw-r--r--source/blender/compositor/COM_defines.h6
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.h3
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.h4
-rw-r--r--source/blender/compositor/intern/COM_Converter.h6
-rw-r--r--source/blender/compositor/intern/COM_Debug.cpp8
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp6
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.h23
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h55
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h3
-rw-r--r--source/blender/compositor/intern/COM_Node.h3
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.cpp3
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h30
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.cpp2
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp3
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.h7
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.cpp3
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.h29
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_DespeckleOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp21
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_MapRangeOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_NormalizeOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_SunBeamsOperation.cpp11
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_WrapOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.cpp2
-rw-r--r--source/blender/depsgraph/CMakeLists.txt3
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_debug.h2
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_query.h34
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.cc97
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.h17
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cache.cc186
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cache.h103
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc81
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.h7
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc5
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc12
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc221
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h12
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc4
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc11
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.cc29
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.h4
-rw-r--r--source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc1
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc8
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_filter.cc243
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc5
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type.h2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc277
-rw-r--r--source/blender/depsgraph/intern/node/deg_node.cc5
-rw-r--r--source/blender/depsgraph/intern/node/deg_node.h2
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_component.cc5
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_component.h1
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_id.cc1
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_id.h3
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.cc5
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.h7
-rw-r--r--source/blender/draw/CMakeLists.txt4
-rw-r--r--source/blender/draw/engines/basic/basic_engine.c4
-rw-r--r--source/blender/draw/engines/eevee/eevee_bloom.c37
-rw-r--r--source/blender/draw/engines/eevee/eevee_depth_of_field.c11
-rw-r--r--source/blender/draw/engines/eevee/eevee_effects.c64
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c20
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightprobes.c3
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c11
-rw-r--r--source/blender/draw/engines/eevee/eevee_lookdev.c158
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c270
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h46
-rw-r--r--source/blender/draw/engines/eevee/eevee_screen_raytrace.c5
-rw-r--r--source/blender/draw/engines/eevee/eevee_temporal_sampling.c17
-rw-r--r--source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl23
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl9
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl7
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl16
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl5
-rw-r--r--source/blender/draw/engines/eevee/shaders/ltc_lib.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl3
-rw-r--r--source/blender/draw/engines/external/external_engine.c118
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c13
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_utils.c44
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c3
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_shader_fx.c9
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl14
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl5
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl14
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl2
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl2
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl16
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl2
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl6
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl3
-rw-r--r--source/blender/draw/engines/workbench/solid_mode.c8
-rw-r--r--source/blender/draw/engines/workbench/transparent_mode.c8
-rw-r--r--source/blender/draw/engines/workbench/workbench_deferred.c36
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_aa.c8
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_dof.c7
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_taa.c28
-rw-r--r--source/blender/draw/engines/workbench/workbench_forward.c133
-rw-r--r--source/blender/draw/engines/workbench/workbench_materials.c3
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h43
-rw-r--r--source/blender/draw/intern/DRW_render.h31
-rw-r--r--source/blender/draw/intern/draw_anim_viz.c5
-rw-r--r--source/blender/draw/intern/draw_armature.c76
-rw-r--r--source/blender/draw/intern/draw_cache.c33
-rw-r--r--source/blender/draw/intern/draw_cache.h1
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h20
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c8
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c379
-rw-r--r--source/blender/draw/intern/draw_cache_impl_metaball.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c15
-rw-r--r--source/blender/draw/intern/draw_common.c8
-rw-r--r--source/blender/draw/intern/draw_common.h1
-rw-r--r--source/blender/draw/intern/draw_hair.c3
-rw-r--r--source/blender/draw/intern/draw_instance_data.c10
-rw-r--r--source/blender/draw/intern/draw_manager.c51
-rw-r--r--source/blender/draw/intern/draw_manager.h6
-rw-r--r--source/blender/draw/intern/draw_manager_data.c211
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c28
-rw-r--r--source/blender/draw/intern/draw_manager_shader.c9
-rw-r--r--source/blender/draw/intern/draw_view.c29
-rw-r--r--source/blender/draw/intern/draw_view.h2
-rw-r--r--source/blender/draw/modes/edit_armature_mode.c1
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c54
-rw-r--r--source/blender/draw/modes/edit_mesh_mode_text.c24
-rw-r--r--source/blender/draw/modes/edit_metaball_mode.c2
-rw-r--r--source/blender/draw/modes/object_mode.c17
-rw-r--r--source/blender/draw/modes/overlay_mode.c5
-rw-r--r--source/blender/draw/modes/paint_texture_mode.c2
-rw-r--r--source/blender/draw/modes/pose_mode.c16
-rw-r--r--source/blender/draw/modes/sculpt_mode.c111
-rw-r--r--source/blender/draw/modes/shaders/common_fxaa_lib.glsl8
-rw-r--r--source/blender/draw/modes/shaders/common_hair_lib.glsl4
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl4
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl14
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl23
-rw-r--r--source/blender/draw/modes/shaders/object_grid_frag.glsl4
-rw-r--r--source/blender/draw/modes/shaders/particle_strand_vert.glsl4
-rw-r--r--source/blender/editors/animation/CMakeLists.txt2
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c15
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c92
-rw-r--r--source/blender/editors/animation/anim_deps.c2
-rw-r--r--source/blender/editors/animation/anim_draw.c2
-rw-r--r--source/blender/editors/animation/anim_filter.c56
-rw-r--r--source/blender/editors/animation/anim_markers.c237
-rw-r--r--source/blender/editors/animation/anim_ops.c6
-rw-r--r--source/blender/editors/animation/drivers.c8
-rw-r--r--source/blender/editors/animation/keyframes_draw.c2
-rw-r--r--source/blender/editors/animation/keyframes_edit.c6
-rw-r--r--source/blender/editors/animation/keyframing.c16
-rw-r--r--source/blender/editors/animation/keyingsets.c10
-rw-r--r--source/blender/editors/armature/CMakeLists.txt2
-rw-r--r--source/blender/editors/armature/armature_intern.h5
-rw-r--r--source/blender/editors/armature/armature_naming.c7
-rw-r--r--source/blender/editors/armature/armature_ops.c6
-rw-r--r--source/blender/editors/armature/armature_relations.c100
-rw-r--r--source/blender/editors/armature/armature_select.c4
-rw-r--r--source/blender/editors/armature/armature_utils.c4
-rw-r--r--source/blender/editors/armature/meshlaplacian.c4
-rw-r--r--source/blender/editors/armature/pose_edit.c34
-rw-r--r--source/blender/editors/armature/pose_lib.c24
-rw-r--r--source/blender/editors/armature/pose_slide.c76
-rw-r--r--source/blender/editors/armature/pose_utils.c21
-rw-r--r--source/blender/editors/curve/CMakeLists.txt2
-rw-r--r--source/blender/editors/curve/curve_ops.c4
-rw-r--r--source/blender/editors/gizmo_library/CMakeLists.txt2
-rw-r--r--source/blender/editors/gpencil/CMakeLists.txt4
-rw-r--r--source/blender/editors/gpencil/annotate_draw.c251
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c40
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c43
-rw-r--r--source/blender/editors/gpencil/gpencil_armature.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c19
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c19
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_ops.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c51
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c20
-rw-r--r--source/blender/editors/gpencil/gpencil_undo.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c17
-rw-r--r--source/blender/editors/include/BIF_glutil.h4
-rw-r--r--source/blender/editors/include/ED_anim_api.h19
-rw-r--r--source/blender/editors/include/ED_image.h3
-rw-r--r--source/blender/editors/include/ED_screen.h7
-rw-r--r--source/blender/editors/include/ED_screen_types.h24
-rw-r--r--source/blender/editors/include/ED_uvedit.h1
-rw-r--r--source/blender/editors/include/ED_view3d.h12
-rw-r--r--source/blender/editors/include/UI_icons.h54
-rw-r--r--source/blender/editors/include/UI_interface.h1
-rw-r--r--source/blender/editors/include/UI_resources.h3
-rw-r--r--source/blender/editors/include/UI_view2d.h132
-rw-r--r--source/blender/editors/interface/CMakeLists.txt3
-rw-r--r--source/blender/editors/interface/interface.c6
-rw-r--r--source/blender/editors/interface/interface_context_menu.c2
-rw-r--r--source/blender/editors/interface/interface_draw.c35
-rw-r--r--source/blender/editors/interface/interface_handlers.c5
-rw-r--r--source/blender/editors/interface/interface_icons.c21
-rw-r--r--source/blender/editors/interface/interface_layout.c17
-rw-r--r--source/blender/editors/interface/interface_panel.c15
-rw-r--r--source/blender/editors/interface/interface_query.c9
-rw-r--r--source/blender/editors/interface/interface_region_popover.c9
-rw-r--r--source/blender/editors/interface/interface_region_popup.c13
-rw-r--r--source/blender/editors/interface/interface_region_search.c2
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c2
-rw-r--r--source/blender/editors/interface/interface_templates.c19
-rw-r--r--source/blender/editors/interface/interface_widgets.c6
-rw-r--r--source/blender/editors/interface/resources.c8
-rw-r--r--source/blender/editors/interface/view2d.c663
-rw-r--r--source/blender/editors/interface/view2d_draw.c546
-rw-r--r--source/blender/editors/interface/view2d_ops.c3
-rw-r--r--source/blender/editors/io/CMakeLists.txt4
-rw-r--r--source/blender/editors/io/io_cache.c14
-rw-r--r--source/blender/editors/io/io_collada.c4
-rw-r--r--source/blender/editors/mask/CMakeLists.txt2
-rw-r--r--source/blender/editors/mask/mask_edit.c2
-rw-r--r--source/blender/editors/mask/mask_ops.c2
-rw-r--r--source/blender/editors/mask/mask_relationships.c2
-rw-r--r--source/blender/editors/mask/mask_select.c10
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt4
-rw-r--r--source/blender/editors/mesh/editface.c2
-rw-r--r--source/blender/editors/mesh/editmesh_add.c4
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c2
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c2
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c3
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c2
-rw-r--r--source/blender/editors/mesh/editmesh_path.c4
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c4
-rw-r--r--source/blender/editors/mesh/editmesh_select.c3
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c26
-rw-r--r--source/blender/editors/mesh/mesh_ops.c28
-rw-r--r--source/blender/editors/metaball/mball_ops.c2
-rw-r--r--source/blender/editors/object/CMakeLists.txt6
-rw-r--r--source/blender/editors/object/object_add.c4
-rw-r--r--source/blender/editors/object/object_bake.c6
-rw-r--r--source/blender/editors/object/object_bake_api.c2
-rw-r--r--source/blender/editors/object/object_collection.c2
-rw-r--r--source/blender/editors/object/object_constraint.c55
-rw-r--r--source/blender/editors/object/object_data_transfer.c8
-rw-r--r--source/blender/editors/object/object_edit.c6
-rw-r--r--source/blender/editors/object/object_hook.c2
-rw-r--r--source/blender/editors/object/object_modifier.c37
-rw-r--r--source/blender/editors/object/object_ops.c4
-rw-r--r--source/blender/editors/object/object_relations.c15
-rw-r--r--source/blender/editors/object/object_select.c6
-rw-r--r--source/blender/editors/object/object_transform.c4
-rw-r--r--source/blender/editors/object/object_utils.c2
-rw-r--r--source/blender/editors/object/object_vgroup.c11
-rw-r--r--source/blender/editors/physics/CMakeLists.txt2
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c39
-rw-r--r--source/blender/editors/physics/particle_edit.c5
-rw-r--r--source/blender/editors/physics/physics_fluid.c3
-rw-r--r--source/blender/editors/render/CMakeLists.txt4
-rw-r--r--source/blender/editors/render/render_internal.c9
-rw-r--r--source/blender/editors/render/render_opengl.c29
-rw-r--r--source/blender/editors/render/render_preview.c37
-rw-r--r--source/blender/editors/render/render_update.c2
-rw-r--r--source/blender/editors/screen/CMakeLists.txt2
-rw-r--r--source/blender/editors/screen/area.c73
-rw-r--r--source/blender/editors/screen/screen_context.c17
-rw-r--r--source/blender/editors/screen/screen_draw.c3
-rw-r--r--source/blender/editors/screen/screen_edit.c38
-rw-r--r--source/blender/editors/screen/screen_geometry.c77
-rw-r--r--source/blender/editors/screen/screen_ops.c30
-rw-r--r--source/blender/editors/screen/workspace_edit.c4
-rw-r--r--source/blender/editors/sculpt_paint/CMakeLists.txt2
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c55
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h3
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c38
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c1
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c124
-rw-r--r--source/blender/editors/sound/CMakeLists.txt1
-rw-r--r--source/blender/editors/sound/sound_ops.c57
-rw-r--r--source/blender/editors/space_action/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_action/action_draw.c137
-rw-r--r--source/blender/editors/space_action/action_edit.c30
-rw-r--r--source/blender/editors/space_action/action_ops.c2
-rw-r--r--source/blender/editors/space_action/action_select.c89
-rw-r--r--source/blender/editors/space_action/space_action.c29
-rw-r--r--source/blender/editors/space_buttons/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c3
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c20
-rw-r--r--source/blender/editors/space_clip/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c8
-rw-r--r--source/blender/editors/space_clip/clip_ops.c2
-rw-r--r--source/blender/editors/space_clip/space_clip.c45
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c2
-rw-r--r--source/blender/editors/space_clip/tracking_ops_detect.c2
-rw-r--r--source/blender/editors/space_clip/tracking_ops_intern.h4
-rw-r--r--source/blender/editors/space_clip/tracking_select.c43
-rw-r--r--source/blender/editors/space_console/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_console/space_console.c9
-rw-r--r--source/blender/editors/space_file/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_file/file_ops.c7
-rw-r--r--source/blender/editors/space_file/fsmenu.c7
-rw-r--r--source/blender/editors/space_file/space_file.c18
-rw-r--r--source/blender/editors/space_graph/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_graph/graph_draw.c75
-rw-r--r--source/blender/editors/space_graph/graph_edit.c16
-rw-r--r--source/blender/editors/space_graph/graph_intern.h2
-rw-r--r--source/blender/editors/space_graph/graph_ops.c4
-rw-r--r--source/blender/editors/space_graph/graph_select.c54
-rw-r--r--source/blender/editors/space_graph/graph_utils.c3
-rw-r--r--source/blender/editors/space_graph/space_graph.c47
-rw-r--r--source/blender/editors/space_image/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_image/image_buttons.c1
-rw-r--r--source/blender/editors/space_image/image_draw.c2
-rw-r--r--source/blender/editors/space_image/image_ops.c11
-rw-r--r--source/blender/editors/space_image/space_image.c56
-rw-r--r--source/blender/editors/space_info/CMakeLists.txt6
-rw-r--r--source/blender/editors/space_info/info_draw.c4
-rw-r--r--source/blender/editors/space_info/info_report.c71
-rw-r--r--source/blender/editors/space_info/space_info.c7
-rw-r--r--source/blender/editors/space_nla/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c2
-rw-r--r--source/blender/editors/space_nla/nla_channels.c16
-rw-r--r--source/blender/editors/space_nla/nla_draw.c96
-rw-r--r--source/blender/editors/space_nla/nla_edit.c20
-rw-r--r--source/blender/editors/space_nla/nla_select.c65
-rw-r--r--source/blender/editors/space_nla/space_nla.c39
-rw-r--r--source/blender/editors/space_node/CMakeLists.txt6
-rw-r--r--source/blender/editors/space_node/node_draw.c7
-rw-r--r--source/blender/editors/space_node/node_group.c12
-rw-r--r--source/blender/editors/space_node/node_select.c33
-rw-r--r--source/blender/editors/space_node/space_node.c2
-rw-r--r--source/blender/editors/space_outliner/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_outliner/outliner_dragdrop.c3
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c144
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c3
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h5
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c28
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c21
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c189
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c8
-rw-r--r--source/blender/editors/space_script/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_script/space_script.c4
-rw-r--r--source/blender/editors/space_sequencer/CMakeLists.txt5
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c28
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c198
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c5
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_preview.c4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c47
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c16
-rw-r--r--source/blender/editors/space_statusbar/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_text/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_text/space_text.c8
-rw-r--r--source/blender/editors/space_text/text_autocomplete.c6
-rw-r--r--source/blender/editors/space_text/text_draw.c2
-rw-r--r--source/blender/editors/space_text/text_ops.c91
-rw-r--r--source/blender/editors/space_topbar/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_view3d/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c24
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_navigate.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c11
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c2
-rw-r--r--source/blender/editors/transform/CMakeLists.txt4
-rw-r--r--source/blender/editors/transform/transform.c46
-rw-r--r--source/blender/editors/transform/transform_conversions.c51
-rw-r--r--source/blender/editors/transform/transform_generics.c61
-rw-r--r--source/blender/editors/transform/transform_ops.c21
-rw-r--r--source/blender/editors/transform/transform_snap.c23
-rw-r--r--source/blender/editors/transform/transform_snap_object.c2
-rw-r--r--source/blender/editors/undo/CMakeLists.txt2
-rw-r--r--source/blender/editors/util/CMakeLists.txt4
-rw-r--r--source/blender/editors/util/ed_util.c14
-rw-r--r--source/blender/editors/uvedit/CMakeLists.txt2
-rw-r--r--source/blender/editors/uvedit/uvedit_buttons.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c6
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c174
-rw-r--r--source/blender/freestyle/intern/application/AppView.h4
-rw-r--r--source/blender/freestyle/intern/application/Controller.cpp6
-rw-r--r--source/blender/freestyle/intern/application/Controller.h20
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp7
-rw-r--r--source/blender/freestyle/intern/geometry/FastGrid.h8
-rw-r--r--source/blender/freestyle/intern/geometry/FitCurve.cpp9
-rw-r--r--source/blender/freestyle/intern/geometry/GeomCleaner.h42
-rw-r--r--source/blender/freestyle/intern/geometry/GeomUtils.cpp34
-rw-r--r--source/blender/freestyle/intern/geometry/GeomUtils.h6
-rw-r--r--source/blender/freestyle/intern/geometry/Grid.cpp23
-rw-r--r--source/blender/freestyle/intern/geometry/Grid.h40
-rw-r--r--source/blender/freestyle/intern/geometry/GridHelpers.cpp13
-rw-r--r--source/blender/freestyle/intern/geometry/GridHelpers.h4
-rw-r--r--source/blender/freestyle/intern/geometry/SweepLine.h4
-rw-r--r--source/blender/freestyle/intern/image/GaussianFilter.h23
-rw-r--r--source/blender/freestyle/intern/image/Image.h13
-rw-r--r--source/blender/freestyle/intern/image/ImagePyramid.cpp2
-rw-r--r--source/blender/freestyle/intern/image/ImagePyramid.h2
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp6
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h3
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h3
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h6
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h6
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h3
-rw-r--r--source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h12
-rw-r--r--source/blender/freestyle/intern/scene_graph/Node.h3
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp3
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h3
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeGroup.cpp10
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeGroup.h3
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeTransform.cpp2
-rw-r--r--source/blender/freestyle/intern/scene_graph/Rep.cpp3
-rw-r--r--source/blender/freestyle/intern/scene_graph/Rep.h7
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h8
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h50
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h12
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp20
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.h50
-rw-r--r--source/blender/freestyle/intern/stroke/Canvas.cpp18
-rw-r--r--source/blender/freestyle/intern/stroke/Canvas.h10
-rw-r--r--source/blender/freestyle/intern/stroke/Chain.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/ChainingIterators.cpp5
-rw-r--r--source/blender/freestyle/intern/stroke/ChainingIterators.h92
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.cpp9
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.h40
-rw-r--r--source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h10
-rw-r--r--source/blender/freestyle/intern/stroke/CurveIterators.h6
-rw-r--r--source/blender/freestyle/intern/stroke/Operators.cpp10
-rw-r--r--source/blender/freestyle/intern/stroke/Operators.h116
-rw-r--r--source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/Predicates0D.h4
-rw-r--r--source/blender/freestyle/intern/stroke/Predicates1D.h13
-rw-r--r--source/blender/freestyle/intern/stroke/QInformationMap.h2
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.cpp21
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.h37
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h6
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeIterators.h23
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRenderer.h5
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.cpp28
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeShader.h15
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeTesselator.cpp2
-rw-r--r--source/blender/freestyle/intern/system/PointerSequence.h26
-rw-r--r--source/blender/freestyle/intern/system/PythonInterpreter.h2
-rw-r--r--source/blender/freestyle/intern/system/RandGen.cpp3
-rw-r--r--source/blender/freestyle/intern/system/StringUtils.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/BoxGrid.h31
-rw-r--r--source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp53
-rw-r--r--source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp15
-rw-r--r--source/blender/freestyle/intern/view_map/FEdgeXDetector.h7
-rw-r--r--source/blender/freestyle/intern/view_map/Functions0D.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/Functions0D.h59
-rw-r--r--source/blender/freestyle/intern/view_map/Functions1D.h28
-rw-r--r--source/blender/freestyle/intern/view_map/GridDensityProvider.h3
-rw-r--r--source/blender/freestyle/intern/view_map/Interface0D.h21
-rw-r--r--source/blender/freestyle/intern/view_map/Interface1D.h42
-rw-r--r--source/blender/freestyle/intern/view_map/Silhouette.cpp6
-rw-r--r--source/blender/freestyle/intern/view_map/Silhouette.h78
-rw-r--r--source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp7
-rw-r--r--source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h4
-rw-r--r--source/blender/freestyle/intern/view_map/SphericalGrid.cpp6
-rw-r--r--source/blender/freestyle/intern/view_map/SphericalGrid.h50
-rw-r--r--source/blender/freestyle/intern/view_map/SteerableViewMap.cpp31
-rw-r--r--source/blender/freestyle/intern/view_map/SteerableViewMap.h26
-rw-r--r--source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp14
-rw-r--r--source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h9
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.cpp22
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.h128
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h18
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp157
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.h34
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapIO.cpp6
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapIterators.h24
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapTesselator.h22
-rw-r--r--source/blender/freestyle/intern/winged_edge/Curvature.cpp73
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.cpp24
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.h61
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.cpp11
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.h72
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp6
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h4
-rw-r--r--source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp16
-rw-r--r--source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h4
-rw-r--r--source/blender/gpencil_modifiers/CMakeLists.txt6
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c19
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c2
-rw-r--r--source/blender/gpu/CMakeLists.txt2
-rw-r--r--source/blender/gpu/GPU_buffers.h5
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c93
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c6
-rw-r--r--source/blender/gpu/intern/gpu_select.c2
-rw-r--r--source/blender/gpu/intern/gpu_select_pick.c11
-rw-r--r--source/blender/gpu/intern/gpu_select_private.h2
-rw-r--r--source/blender/gpu/intern/gpu_shader.c2
-rw-r--r--source/blender/gpu/intern/gpu_texture.c5
-rw-r--r--source/blender/gpu/intern/gpu_uniformbuffer.c19
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl32
-rw-r--r--source/blender/ikplugin/BIK_api.h15
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c6
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp41
-rw-r--r--source/blender/imbuf/IMB_imbuf.h7
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c29
-rw-r--r--source/blender/imbuf/intern/anim_movie.c4
-rw-r--r--source/blender/imbuf/intern/cache.c4
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp28
-rw-r--r--source/blender/imbuf/intern/dds/PixelFormat.h8
-rw-r--r--source/blender/imbuf/intern/moviecache.c47
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp2
-rw-r--r--source/blender/imbuf/intern/radiance_hdr.c8
-rw-r--r--source/blender/makesdna/DNA_ID.h4
-rw-r--r--source/blender/makesdna/DNA_action_types.h4
-rw-r--r--source/blender/makesdna/DNA_anim_types.h7
-rw-r--r--source/blender/makesdna/DNA_boid_types.h12
-rw-r--r--source/blender/makesdna/DNA_brush_types.h13
-rw-r--r--source/blender/makesdna/DNA_cachefile_types.h12
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h5
-rw-r--r--source/blender/makesdna/DNA_dynamicpaint_types.h19
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h2
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h2
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h5
-rw-r--r--source/blender/makesdna/DNA_node_types.h17
-rw-r--r--source/blender/makesdna/DNA_object_types.h3
-rw-r--r--source/blender/makesdna/DNA_rigidbody_types.h2
-rw-r--r--source/blender/makesdna/DNA_scene_types.h89
-rw-r--r--source/blender/makesdna/DNA_screen_types.h42
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h45
-rw-r--r--source/blender/makesdna/DNA_smoke_types.h8
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h11
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h8
-rw-r--r--source/blender/makesdna/DNA_workspace_types.h25
-rw-r--r--source/blender/makesdna/intern/CMakeLists.txt2
-rw-r--r--source/blender/makesrna/RNA_enum_types.h2
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt8
-rw-r--r--source/blender/makesrna/intern/makesrna.c4
-rw-r--r--source/blender/makesrna/intern/rna_access.c2
-rw-r--r--source/blender/makesrna/intern/rna_animation.c12
-rw-r--r--source/blender/makesrna/intern/rna_armature.c2
-rw-r--r--source/blender/makesrna/intern/rna_brush.c16
-rw-r--r--source/blender/makesrna/intern/rna_cachefile.c38
-rw-r--r--source/blender/makesrna/intern/rna_camera.c5
-rw-r--r--source/blender/makesrna/intern/rna_color.c10
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c18
-rw-r--r--source/blender/makesrna/intern/rna_dynamicpaint.c50
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c5
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c16
-rw-r--r--source/blender/makesrna/intern/rna_mask.c2
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c21
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c6
-rw-r--r--source/blender/makesrna/intern/rna_object.c25
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c19
-rw-r--r--source/blender/makesrna/intern/rna_scene.c174
-rw-r--r--source/blender/makesrna/intern/rna_screen.c11
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c6
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c84
-rw-r--r--source/blender/makesrna/intern/rna_space.c9
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c41
-rw-r--r--source/blender/makesrna/intern/rna_wm.c4
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_workspace.c18
-rw-r--r--source/blender/modifiers/CMakeLists.txt6
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c24
-rw-r--r--source/blender/modifiers/intern/MOD_array.c17
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c26
-rw-r--r--source/blender/modifiers/intern/MOD_correctivesmooth.c3
-rw-r--r--source/blender/modifiers/intern/MOD_datatransfer.c4
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c5
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c4
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c6
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c18
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c17
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c28
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c20
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c3
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c10
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c2
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c3
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c6
-rw-r--r--source/blender/modifiers/intern/MOD_triangulate.c2
-rw-r--r--source/blender/modifiers/intern/MOD_util.c6
-rw-r--r--source/blender/modifiers/intern/MOD_weighted_normal.c226
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.c11
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.h16
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c7
-rw-r--r--source/blender/nodes/CMakeLists.txt2
-rw-r--r--source/blender/nodes/NOD_common.h6
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c15
-rw-r--r--source/blender/nodes/composite/node_composite_util.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorbalance.c3
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_common.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_cryptomatte.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c17
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_outputFile.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_scale.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_switchview.c2
-rw-r--r--source/blender/nodes/intern/node_common.c76
-rw-r--r--source/blender/nodes/intern/node_exec.c3
-rw-r--r--source/blender/nodes/intern/node_util.c3
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c11
-rw-r--r--source/blender/nodes/shader/node_shader_util.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_attribute.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_common.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c87
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c2
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c5
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_common.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_proc.c3
-rw-r--r--source/blender/physics/CMakeLists.txt2
-rw-r--r--source/blender/physics/intern/BPH_mass_spring.cpp51
-rw-r--r--source/blender/physics/intern/ConstrainedConjugateGradient.h23
-rw-r--r--source/blender/physics/intern/eigen_utils.h5
-rw-r--r--source/blender/physics/intern/hair_volume.cpp15
-rw-r--r--source/blender/physics/intern/implicit_blender.c15
-rw-r--r--source/blender/physics/intern/implicit_eigen.cpp12
-rw-r--r--source/blender/python/bmesh/CMakeLists.txt2
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c18
-rw-r--r--source/blender/python/generic/CMakeLists.txt2
-rw-r--r--source/blender/python/generic/idprop_py_api.c3
-rw-r--r--source/blender/python/generic/py_capi_utils.c12
-rw-r--r--source/blender/python/generic/python_utildefines.h3
-rw-r--r--source/blender/python/gpu/CMakeLists.txt2
-rw-r--r--source/blender/python/gpu/gpu_py_batch.c3
-rw-r--r--source/blender/python/intern/CMakeLists.txt1
-rw-r--r--source/blender/python/intern/bpy.c3
-rw-r--r--source/blender/python/intern/bpy_app_ocio.c10
-rw-r--r--source/blender/python/intern/bpy_app_translations.c22
-rw-r--r--source/blender/python/intern/bpy_driver.c16
-rw-r--r--source/blender/python/intern/bpy_gizmo_wrap.c5
-rw-r--r--source/blender/python/intern/bpy_interface.c5
-rw-r--r--source/blender/python/intern/bpy_operator.c5
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c8
-rw-r--r--source/blender/python/intern/bpy_props.c5
-rw-r--r--source/blender/python/intern/bpy_rna.c76
-rw-r--r--source/blender/python/intern/bpy_rna.h11
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c8
-rw-r--r--source/blender/python/intern/bpy_rna_array.c8
-rw-r--r--source/blender/python/intern/bpy_rna_id_collection.c15
-rw-r--r--source/blender/python/intern/bpy_utils_units.c12
-rw-r--r--source/blender/python/intern/stubs.c4
-rw-r--r--source/blender/python/mathutils/CMakeLists.txt2
-rw-r--r--source/blender/python/mathutils/mathutils.c18
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c3
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c7
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c8
-rw-r--r--source/blender/render/CMakeLists.txt6
-rw-r--r--source/blender/render/intern/source/imagetexture.c8
-rw-r--r--source/blender/render/intern/source/pipeline.c2
-rw-r--r--source/blender/render/intern/source/render_texture.c8
-rw-r--r--source/blender/shader_fx/CMakeLists.txt6
-rw-r--r--source/blender/windowmanager/CMakeLists.txt2
-rw-r--r--source/blender/windowmanager/WM_api.h11
-rw-r--r--source/blender/windowmanager/WM_keymap.h6
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c10
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c84
-rw-r--r--source/blender/windowmanager/intern/wm_files.c22
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c28
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c221
-rw-r--r--source/blender/windowmanager/intern/wm_keymap_utils.c3
-rw-r--r--source/blender/windowmanager/intern/wm_operator_props.c7
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c6
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c2
-rw-r--r--source/blender/windowmanager/intern/wm_stereo.c2
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c95
-rw-r--r--source/blender/windowmanager/intern/wm_window.c2
-rw-r--r--source/blender/windowmanager/wm_cursors.h2
-rw-r--r--source/blender/windowmanager/wm_event_system.h5
-rw-r--r--source/creator/CMakeLists.txt8
-rw-r--r--tests/gtests/blenlib/BLI_path_util_test.cc131
1190 files changed, 18604 insertions, 14844 deletions
diff --git a/.clang-format b/.clang-format
index 6374b48f2b6..c876affd8b8 100644
--- a/.clang-format
+++ b/.clang-format
@@ -98,9 +98,8 @@ SpaceInEmptyParentheses: false
# Note that this doesn't work for C-style comments.
SpacesBeforeTrailingComments: 2
-# Don't reflow comments, let developers define line breaks.
-# Enabling breaks some ascii art.
-ReflowComments: false
+# Reflow comments, developers must disable formatting as with code to override this.
+ReflowComments: true
# Never use tabs for indentation.
# Note: TabWidth and IndentWidth must be the same, or strange things happen.
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index 0d34392ff32..f8b3f0c962d 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -1054,7 +1054,6 @@ context_type_map = {
"texture_slot": ("MaterialTextureSlot", False),
"texture_user": ("ID", False),
"texture_user_property": ("Property", False),
- "uv_sculpt_object": ("Object", False),
"vertex_paint_object": ("Object", False),
"view_layer": ("ViewLayer", False),
"visible_bases": ("ObjectBase", True),
diff --git a/extern/draco/dracoenc/cmake/util.cmake b/extern/draco/dracoenc/cmake/util.cmake
index 252761fe6fb..d9254c03c03 100644
--- a/extern/draco/dracoenc/cmake/util.cmake
+++ b/extern/draco/dracoenc/cmake/util.cmake
@@ -71,4 +71,3 @@ macro (set_variable_if_unset var_name default_value)
endmacro ()
endif() # DRACO_CMAKE_UTIL_CMAKE_
-
diff --git a/intern/atomic/atomic_ops.h b/intern/atomic/atomic_ops.h
index 9d4ec67ba97..106e19567da 100644
--- a/intern/atomic/atomic_ops.h
+++ b/intern/atomic/atomic_ops.h
@@ -126,15 +126,17 @@ ATOMIC_INLINE void *atomic_cas_ptr(void **v, void *old, void *_new);
ATOMIC_INLINE float atomic_cas_float(float *v, float old, float _new);
-/* WARNING! Float 'atomics' are really faked ones, those are actually closer to some kind of spinlock-sync'ed operation,
- * which means they are only efficient if collisions are highly unlikely (i.e. if probability of two threads
- * working on the same pointer at the same time is very low). */
+/* WARNING! Float 'atomics' are really faked ones, those are actually closer to some kind of
+ * spinlock-sync'ed operation, which means they are only efficient if collisions are highly
+ * unlikely (i.e. if probability of two threads working on the same pointer at the same time is
+ * very low). */
ATOMIC_INLINE float atomic_add_and_fetch_fl(float *p, const float x);
/******************************************************************************/
/* Include system-dependent implementations. */
-/* Note that we are using _unix flavor as fallback here (it will raise precompiler errors as needed). */
+/* Note that we are using _unix flavor as fallback here
+ * (it will raise precompiler errors as needed). */
#if defined(_MSC_VER)
# include "intern/atomic_ops_msvc.h"
#else
diff --git a/intern/atomic/intern/atomic_ops_utils.h b/intern/atomic/intern/atomic_ops_utils.h
index 4010051607c..b54e12eb49d 100644
--- a/intern/atomic/intern/atomic_ops_utils.h
+++ b/intern/atomic/intern/atomic_ops_utils.h
@@ -116,9 +116,9 @@
enum { ATOMIC_ASSERT_CONCAT(static_assert_, __COUNTER__) = 1 / (int)(!!(a)) };
# else /* older gcc, clang... */
/* This can't be used twice on the same line so ensure if using in headers
- * that the headers are not included twice (by wrapping in #ifndef...#endif)
- * Note it doesn't cause an issue when used on same line of separate modules
- * compiled with gcc -combine -fwhole-program. */
+ * that the headers are not included twice (by wrapping in #ifndef...#endif)
+ * Note it doesn't cause an issue when used on same line of separate modules
+ * compiled with gcc -combine -fwhole-program. */
# define ATOMIC_STATIC_ASSERT(a, msg) \
; \
enum { ATOMIC_ASSERT_CONCAT(assert_line_, __LINE__) = 1 / (int)(!!(a)) };
diff --git a/intern/audaspace/intern/AUD_PyInit.cpp b/intern/audaspace/intern/AUD_PyInit.cpp
index b65d2740f32..843fe1e6cf1 100644
--- a/intern/audaspace/intern/AUD_PyInit.cpp
+++ b/intern/audaspace/intern/AUD_PyInit.cpp
@@ -34,11 +34,11 @@ extern void *BKE_sound_get_factory(void *sound);
static PyObject *AUD_getSoundFromPointer(PyObject *self, PyObject *args)
{
- long int lptr;
+ PyObject *lptr = NULL;
- if (PyArg_Parse(args, "l:_sound_from_pointer", &lptr)) {
+ if (PyArg_Parse(args, "O:_sound_from_pointer", &lptr)) {
if (lptr) {
- AUD_Sound *sound = BKE_sound_get_factory((void *)lptr);
+ AUD_Sound *sound = BKE_sound_get_factory(PyLong_AsVoidPtr(lptr));
if (sound) {
Sound *obj = (Sound *)Sound_empty();
diff --git a/intern/clog/clog.c b/intern/clog/clog.c
index ea6f215e8f0..da94acd97b1 100644
--- a/intern/clog/clog.c
+++ b/intern/clog/clog.c
@@ -356,7 +356,8 @@ static void clg_ctx_fatal_action(CLogContext *ctx)
static void clg_ctx_backtrace(CLogContext *ctx)
{
/* Note: we avoid writing fo 'FILE', for backtrace we make an exception,
- * if necessary we could have a version of the callback that writes to file descriptor all at once. */
+ * if necessary we could have a version of the callback that writes to file
+ * descriptor all at once. */
ctx->callbacks.backtrace_fn(ctx->output_file);
fflush(ctx->output_file);
}
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index ae07bcd38fe..6da88a769f5 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -1192,20 +1192,6 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
min=3, max=64,
default=3,
)
- minimum_width: FloatProperty(
- name="Minimal width",
- description="Minimal pixel width for strands (0 - deactivated)",
- min=0.0, max=100.0,
- default=0.0,
- subtype='PIXEL'
- )
- maximum_width: FloatProperty(
- name="Maximal width",
- description="Maximum extension that strand radius can be increased by",
- min=0.0, max=100.0,
- default=0.1,
- subtype='PIXEL'
- )
subdivisions: IntProperty(
name="Subdivisions",
description="Number of subdivisions used in Cardinal curve intersection (power of 2)",
@@ -1504,7 +1490,9 @@ class CyclesPreferences(bpy.types.AddonPreferences):
break
if not found_device:
- box.label(text="No compatible GPUs found", icon='INFO')
+ col = box.column(align=True);
+ col.label(text="No compatible GPUs found for path tracing", icon='INFO')
+ col.label(text="Cycles will render on the CPU", icon='BLANK1')
return
for device in devices:
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 16ad3716d4b..0845f567056 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -358,8 +358,6 @@ class CYCLES_RENDER_PT_hair(CyclesButtonsPanel, Panel):
layout.active = ccscene.use_curves
col = layout.column()
- col.prop(ccscene, "minimum_width", text="Min Pixels")
- col.prop(ccscene, "maximum_width", text="Max Extension")
col.prop(ccscene, "shape", text="Shape")
if not (ccscene.primitive in {'CURVE_SEGMENTS', 'LINE_SEGMENTS'} and ccscene.shape == 'RIBBONS'):
col.prop(ccscene, "cull_backfacing", text="Cull back-faces")
@@ -747,7 +745,6 @@ class CYCLES_RENDER_PT_override(CyclesButtonsPanel, Panel):
class CYCLES_RENDER_PT_passes(CyclesButtonsPanel, Panel):
bl_label = "Passes"
bl_context = "view_layer"
- bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
pass
@@ -2133,13 +2130,13 @@ classes = (
CYCLES_RENDER_PT_performance_acceleration_structure,
CYCLES_RENDER_PT_performance_final_render,
CYCLES_RENDER_PT_performance_viewport,
- CYCLES_RENDER_PT_filter,
- CYCLES_RENDER_PT_override,
CYCLES_RENDER_PT_passes,
CYCLES_RENDER_PT_passes_data,
CYCLES_RENDER_PT_passes_light,
CYCLES_RENDER_PT_passes_crypto,
CYCLES_RENDER_PT_passes_debug,
+ CYCLES_RENDER_PT_filter,
+ CYCLES_RENDER_PT_override,
CYCLES_RENDER_PT_denoising,
CYCLES_PT_post_processing,
CYCLES_CAMERA_PT_dof,
diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py
index 6f005727b95..899245db03e 100644
--- a/intern/cycles/blender/addon/version_update.py
+++ b/intern/cycles/blender/addon/version_update.py
@@ -22,140 +22,6 @@ import math
from bpy.app.handlers import persistent
-def foreach_cycles_nodetree_group(nodetree, traversed):
- for node in nodetree.nodes:
- if node.bl_idname == 'ShaderNodeGroup':
- group = node.node_tree
- if group and group not in traversed:
- traversed.add(group)
- yield group, group.library
- yield from foreach_cycles_nodetree_group(group, traversed)
-
-
-def foreach_cycles_nodetree():
- traversed = set()
-
- for material in bpy.data.materials:
- nodetree = material.node_tree
- if nodetree:
- yield nodetree, material.library
- yield from foreach_cycles_nodetree_group(nodetree, traversed)
-
- for world in bpy.data.worlds:
- nodetree = world.node_tree
- if nodetree:
- yield nodetree, world.library
- foreach_cycles_nodetree_group(nodetree, traversed)
-
- for light in bpy.data.lights:
- nodetree = light.node_tree
- if nodetree:
- yield nodetree, light.library
- foreach_cycles_nodetree_group(nodetree, traversed)
-
-
-def displacement_node_insert(nodetree):
- # Gather links to replace
- displacement_links = []
- for link in nodetree.links:
- if (
- link.to_node.bl_idname == 'ShaderNodeOutputMaterial' and
- link.from_node.bl_idname != 'ShaderNodeDisplacement' and
- link.to_socket.identifier == 'Displacement'
- ):
- displacement_links.append(link)
-
- # Replace links with displacement node
- for link in displacement_links:
- from_node = link.from_node
- from_socket = link.from_socket
- to_node = link.to_node
- to_socket = link.to_socket
-
- nodetree.links.remove(link)
-
- node = nodetree.nodes.new(type='ShaderNodeDisplacement')
- node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0])
- node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1])
- node.inputs['Scale'].default_value = 0.1
- node.inputs['Midlevel'].default_value = 0.0
-
- nodetree.links.new(from_socket, node.inputs['Height'])
- nodetree.links.new(node.outputs['Displacement'], to_socket)
-
-
-def displacement_principled_nodes(node):
- if node.bl_idname == 'ShaderNodeDisplacement':
- if node.space != 'WORLD':
- node.space = 'OBJECT'
- if node.bl_idname == 'ShaderNodeBsdfPrincipled':
- if node.subsurface_method != 'RANDOM_WALK':
- node.subsurface_method = 'BURLEY'
-
-
-def square_roughness_node_insert(nodetree):
- roughness_node_types = {
- 'ShaderNodeBsdfAnisotropic',
- 'ShaderNodeBsdfGlass',
- 'ShaderNodeBsdfGlossy',
- 'ShaderNodeBsdfRefraction'}
-
- # Update default values
- for node in nodetree.nodes:
- if node.bl_idname in roughness_node_types:
- roughness_input = node.inputs['Roughness']
- roughness_input.default_value = math.sqrt(max(roughness_input.default_value, 0.0))
-
- # Gather roughness links to replace
- roughness_links = []
- for link in nodetree.links:
- if link.to_node.bl_idname in roughness_node_types and \
- link.to_socket.identifier == 'Roughness':
- roughness_links.append(link)
-
- # Replace links with sqrt node
- for link in roughness_links:
- from_node = link.from_node
- from_socket = link.from_socket
- to_node = link.to_node
- to_socket = link.to_socket
-
- nodetree.links.remove(link)
-
- node = nodetree.nodes.new(type='ShaderNodeMath')
- node.operation = 'POWER'
- node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0])
- node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1])
-
- nodetree.links.new(from_socket, node.inputs[0])
- node.inputs[1].default_value = 0.5
- nodetree.links.new(node.outputs['Value'], to_socket)
-
-
-def mapping_node_order_flip(node):
- """
- Flip euler order of mapping shader node
- """
- if node.bl_idname == 'ShaderNodeMapping':
- rot = node.rotation.copy()
- rot.order = 'ZYX'
- quat = rot.to_quaternion()
- node.rotation = quat.to_euler('XYZ')
-
-
-def vector_curve_node_remap(node):
- """
- Remap values of vector curve node from normalized to absolute values
- """
- if node.bl_idname == 'ShaderNodeVectorCurve':
- node.mapping.use_clip = False
- for curve in node.mapping.curves:
- for point in curve.points:
- point.location.x = (point.location.x * 2.0) - 1.0
- point.location.y = (point.location.y - 0.5) * 2.0
- node.mapping.update()
-
-
def custom_bake_remap(scene):
"""
Remap bake types into the new types and set the flags accordingly
@@ -213,28 +79,6 @@ def custom_bake_remap(scene):
scene.render.bake.use_pass_indirect = False
-def ambient_occlusion_node_relink(nodetree):
- for node in nodetree.nodes:
- if node.bl_idname == 'ShaderNodeAmbientOcclusion':
- node.samples = 1
- node.only_local = False
- node.inputs['Distance'].default_value = 0.0
-
- # Gather links to replace
- ao_links = []
- for link in nodetree.links:
- if link.from_node.bl_idname == 'ShaderNodeAmbientOcclusion':
- ao_links.append(link)
-
- # Replace links
- for link in ao_links:
- from_node = link.from_node
- to_socket = link.to_socket
-
- nodetree.links.remove(link)
- nodetree.links.new(from_node.outputs['Color'], to_socket)
-
-
@persistent
def do_versions(self):
if bpy.context.preferences.version <= (2, 78, 1):
@@ -411,48 +255,3 @@ def do_versions(self):
cmat = mat.cycles
if not cmat.is_property_set("displacement_method"):
cmat.displacement_method = 'DISPLACEMENT'
-
- # Nodes
- for nodetree, library in foreach_cycles_nodetree():
- if library not in libraries:
- continue
-
- # Euler order was ZYX in previous versions.
- if version <= (2, 73, 4):
- for node in nodetree.nodes:
- mapping_node_order_flip(node)
-
- if version <= (2, 76, 5):
- for node in nodetree.nodes:
- vector_curve_node_remap(node)
-
- if version <= (2, 79, 1) or \
- (version >= (2, 80, 0) and version <= (2, 80, 3)):
- displacement_node_insert(nodetree)
-
- if version <= (2, 79, 2):
- for node in nodetree.nodes:
- displacement_principled_nodes(node)
-
- if version <= (2, 79, 3) or \
- (version >= (2, 80, 0) and version <= (2, 80, 4)):
- # Switch to squared roughness convention
- square_roughness_node_insert(nodetree)
-
- if version <= (2, 79, 4):
- ambient_occlusion_node_relink(nodetree)
-
- # Particles
- for part in bpy.data.particles:
- if part.library not in libraries:
- continue
-
- # Copy cycles hair settings to internal settings
- if version <= (2, 80, 15):
- cpart = part.get("cycles", None)
- if cpart:
- part.shape = cpart.get("shape", 0.0)
- part.root_radius = cpart.get("root_width", 1.0)
- part.tip_radius = cpart.get("tip_width", 0.0)
- part.radius_scale = cpart.get("radius_scale", 0.01)
- part.use_close_tip = cpart.get("use_closetip", True)
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index d0375ceb79c..1a36376f36e 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -766,7 +766,7 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
}
}
else {
- /* Number of keys has changed. Genereate an interpolated version
+ /* Number of keys has changed. Generate an interpolated version
* to preserve motion blur. */
const float step_size = num_center_curve_keys > 1 ? 1.0f / (num_center_curve_keys - 1) :
0.0f;
@@ -897,8 +897,6 @@ void BlenderSync::sync_curve_settings()
CurveSystemManager prev_curve_system_manager = *curve_system_manager;
curve_system_manager->use_curves = get_boolean(csscene, "use_curves");
- curve_system_manager->minimum_width = get_float(csscene, "minimum_width");
- curve_system_manager->maximum_width = get_float(csscene, "maximum_width");
curve_system_manager->primitive = (CurvePrimitiveType)get_enum(
csscene, "primitive", CURVE_NUM_PRIMITIVE_TYPES, CURVE_LINE_SEGMENTS);
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index de594f4fb6c..1b47c4123e3 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include "render/colorspace.h"
#include "render/mesh.h"
#include "render/object.h"
#include "render/scene.h"
@@ -301,6 +302,7 @@ static void create_mesh_volume_attribute(
INTERPOLATION_LINEAR,
EXTENSION_CLIP,
use_alpha,
+ u_colorspace_raw,
metadata);
}
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 29a97bf6546..c50dbb6ba55 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -16,12 +16,13 @@
#include <stdlib.h>
+#include "device/device.h"
#include "render/background.h"
#include "render/buffers.h"
#include "render/camera.h"
-#include "device/device.h"
-#include "render/integrator.h"
+#include "render/colorspace.h"
#include "render/film.h"
+#include "render/integrator.h"
#include "render/light.h"
#include "render/mesh.h"
#include "render/object.h"
@@ -155,8 +156,8 @@ void BlenderSession::create_session()
/* There is no single depsgraph to use for the entire render.
* So we need to handle this differently.
*
- * We could loop over the final render result render layers in pipeline and keep Cycles unaware of multiple layers,
- * or perhaps move syncing further down in the pipeline.
+ * We could loop over the final render result render layers in pipeline and keep Cycles unaware
+ * of multiple layers, or perhaps move syncing further down in the pipeline.
*/
/* create sync */
sync = new BlenderSync(b_engine, b_data, b_scene, scene, !background, session->progress);
@@ -528,14 +529,15 @@ void BlenderSession::render(BL::Depsgraph &b_depsgraph_)
/* Attempt to free all data which is held by Blender side, since at this
* point we knwo that we've got everything to render current view layer.
*/
- /* At the moment we only free if we are not doing multi-view (or if we are rendering the last view).
- * See T58142/D4239 for discussion.
+ /* At the moment we only free if we are not doing multi-view
+ * (or if we are rendering the last view). See T58142/D4239 for discussion.
*/
if (view_index == num_views - 1) {
free_blender_memory_if_possible();
}
- /* Make sure all views have different noise patterns. - hardcoded value just to make it random */
+ /* Make sure all views have different noise patterns. - hardcoded value just to make it random
+ */
if (view_index != 0) {
scene->integrator->seed += hash_int_2d(scene->integrator->seed,
hash_int(view_index * 0xdeadbeef));
@@ -1057,8 +1059,9 @@ void BlenderSession::update_status_progress()
}
double current_time = time_dt();
- /* When rendering in a window, redraw the status at least once per second to keep the elapsed and remaining time up-to-date.
- * For headless rendering, only report when something significant changes to keep the console output readable. */
+ /* When rendering in a window, redraw the status at least once per second to keep the elapsed and
+ * remaining time up-to-date. For headless rendering, only report when something significant
+ * changes to keep the console output readable. */
if (status != last_status || (!headless && (current_time - last_status_time) > 1.0)) {
b_engine.update_stats("", (timestatus + scene_status + status).c_str());
b_engine.update_memory_stats(mem_used, mem_peak);
@@ -1156,6 +1159,12 @@ void BlenderSession::builtin_image_info(const string &builtin_name,
metadata.height = b_image.size()[1];
metadata.depth = 1;
metadata.channels = b_image.channels();
+
+ if (metadata.is_float) {
+ /* Float images are already converted on the Blender side,
+ * no need to do anything in Cycles. */
+ metadata.colorspace = u_colorspace_raw;
+ }
}
else if (b_id.is_a(&RNA_Object)) {
/* smoke volume data */
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index d1f823bc2b8..e6ec8b22d7a 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -15,6 +15,7 @@
*/
#include "render/background.h"
+#include "render/colorspace.h"
#include "render/graph.h"
#include "render/light.h"
#include "render/nodes.h"
@@ -665,7 +666,14 @@ static ShaderNode *add_node(Scene *scene,
}
#endif
}
- image->color_space = (NodeImageColorSpace)b_image_node.color_space();
+ switch (b_image_node.color_space()) {
+ case BL::ShaderNodeTexImage::color_space_NONE:
+ image->colorspace = u_colorspace_raw;
+ break;
+ case BL::ShaderNodeTexImage::color_space_COLOR:
+ image->colorspace = u_colorspace_auto;
+ break;
+ }
image->projection = (NodeImageProjection)b_image_node.projection();
image->interpolation = get_image_interpolation(b_image_node);
image->extension = get_image_extension(b_image_node);
@@ -710,7 +718,14 @@ static ShaderNode *add_node(Scene *scene,
}
#endif
}
- env->color_space = (NodeImageColorSpace)b_env_node.color_space();
+ switch (b_env_node.color_space()) {
+ case BL::ShaderNodeTexEnvironment::color_space_NONE:
+ env->colorspace = u_colorspace_raw;
+ break;
+ case BL::ShaderNodeTexEnvironment::color_space_COLOR:
+ env->colorspace = u_colorspace_auto;
+ break;
+ }
env->interpolation = get_image_interpolation(b_env_node);
env->projection = (NodeEnvironmentProjection)b_env_node.projection();
BL::TexMapping b_texture_mapping(b_env_node.texture_mapping());
@@ -861,7 +876,8 @@ static ShaderNode *add_node(Scene *scene,
point_density->builtin_data,
point_density->interpolation,
EXTENSION_CLIP,
- true);
+ true,
+ u_colorspace_raw);
}
node = point_density;
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index 0ab6d88487e..8d93d517d4e 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -583,7 +583,7 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa
}
/* Cryptomatte stores two ID/weight pairs per RGBA layer.
- * User facing paramter is the number of pairs. */
+ * User facing parameter is the number of pairs. */
int crypto_depth = min(16, get_int(crp, "pass_crypto_depth")) / 2;
scene->film->cryptomatte_depth = crypto_depth;
scene->film->cryptomatte_passes = CRYPT_NONE;
diff --git a/intern/cycles/bvh/bvh8.cpp b/intern/cycles/bvh/bvh8.cpp
index e812d806b94..10fd01dd8d0 100644
--- a/intern/cycles/bvh/bvh8.cpp
+++ b/intern/cycles/bvh/bvh8.cpp
@@ -1,30 +1,30 @@
/*
-* Original code Copyright 2017, Intel Corporation
-* Modifications Copyright 2018, Blender Foundation.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* * Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of Intel Corporation nor the names of its contributors
-* may be used to endorse or promote products derived from this software
-* without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ * Original code Copyright 2017, Intel Corporation
+ * Modifications Copyright 2018, Blender Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#include "bvh/bvh8.h"
diff --git a/intern/cycles/bvh/bvh8.h b/intern/cycles/bvh/bvh8.h
index fc07eadcada..6292353c7d4 100644
--- a/intern/cycles/bvh/bvh8.h
+++ b/intern/cycles/bvh/bvh8.h
@@ -1,30 +1,30 @@
/*
-* Original code Copyright 2017, Intel Corporation
-* Modifications Copyright 2018, Blender Foundation.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* * Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of Intel Corporation nor the names of its contributors
-* may be used to endorse or promote products derived from this software
-* without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ * Original code Copyright 2017, Intel Corporation
+ * Modifications Copyright 2018, Blender Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#ifndef __BVH8_H__
#define __BVH8_H__
@@ -50,9 +50,9 @@ class Progress;
#define BVH_UNALIGNED_ONODE_SIZE 28
/* BVH8
-*
-* Octo BVH, with each node having eight children, to use with SIMD instructions.
-*/
+ *
+ * Octo BVH, with each node having eight children, to use with SIMD instructions.
+ */
class BVH8 : public BVH {
protected:
/* constructor */
diff --git a/intern/cycles/bvh/bvh_embree.cpp b/intern/cycles/bvh/bvh_embree.cpp
index 5ef9622aba2..088ec759331 100644
--- a/intern/cycles/bvh/bvh_embree.cpp
+++ b/intern/cycles/bvh/bvh_embree.cpp
@@ -18,18 +18,19 @@
* It supports triangles, curves, object and deformation blur and instancing.
* Not supported are thick line segments, those have no native equivalent in Embree.
* They could be implemented using Embree's thick curves, at the expense of wasted memory.
- * User defined intersections for Embree could also be an option, but since Embree only uses aligned BVHs
- * for user geometry, this would come with reduced performance and/or higher memory usage.
+ * User defined intersections for Embree could also be an option, but since Embree only uses
+ * aligned BVHs for user geometry, this would come with reduced performance and/or higher memory
+ * usage.
*
- * Since Embree allows object to be either curves or triangles but not both, Cycles object IDs are maapped
- * to Embree IDs by multiplying by two and adding one for curves.
+ * Since Embree allows object to be either curves or triangles but not both, Cycles object IDs are
+ * maapped to Embree IDs by multiplying by two and adding one for curves.
*
- * This implementation shares RTCDevices between Cycles instances. Eventually each instance should get
- * a separate RTCDevice to correctly keep track of memory usage.
+ * This implementation shares RTCDevices between Cycles instances. Eventually each instance should
+ * get a separate RTCDevice to correctly keep track of memory usage.
*
- * Vertex and index buffers are duplicated between Cycles device arrays and Embree. These could be merged,
- * which would requrie changes to intersection refinement, shader setup, mesh light sampling and a few
- * other places in Cycles where direct access to vertex data is required.
+ * Vertex and index buffers are duplicated between Cycles device arrays and Embree. These could be
+ * merged, which would requrie changes to intersection refinement, shader setup, mesh light
+ * sampling and a few other places in Cycles where direct access to vertex data is required.
*/
#ifdef WITH_EMBREE
@@ -40,7 +41,8 @@
# include "bvh/bvh_embree.h"
-/* Kernel includes are necessary so that the filter function for Embree can access the packed BVH. */
+/* Kernel includes are necessary so that the filter function for Embree can access the packed BVH.
+ */
# include "kernel/bvh/bvh_embree.h"
# include "kernel/kernel_compat_cpu.h"
# include "kernel/split/kernel_split_data_types.h"
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index 16a68e8b855..47d111802cd 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -287,7 +287,8 @@ void Device::draw_pixels(device_memory &rgba,
}
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
- /* invalidate old contents - avoids stalling if buffer is still waiting in queue to be rendered */
+ /* invalidate old contents - avoids stalling if buffer is still waiting in queue to be rendered
+ */
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), NULL, GL_STREAM_DRAW);
float *vpointer = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index 837a8186064..5d279ebb965 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -43,6 +43,7 @@
#include "render/buffers.h"
#include "render/coverage.h"
+#include "util/util_aligned_malloc.h"
#include "util/util_debug.h"
#include "util/util_foreach.h"
#include "util/util_function.h"
@@ -165,7 +166,7 @@ class CPUDevice : public Device {
bool need_texture_info;
#ifdef WITH_OSL
- OSLGlobals osl_globals;
+ OSLGlobals *osl_globals;
#endif
bool use_split_kernel;
@@ -282,7 +283,9 @@ class CPUDevice : public Device {
}
#ifdef WITH_OSL
- kernel_globals.osl = &osl_globals;
+ /* Must use aligned malloc due to concurrent hash map. */
+ osl_globals = util_aligned_new<OSLGlobals>();
+ kernel_globals.osl = osl_globals;
#endif
use_split_kernel = DebugFlags().cpu.split_kernel;
if (use_split_kernel) {
@@ -317,6 +320,9 @@ class CPUDevice : public Device {
~CPUDevice()
{
+#ifdef WITH_OSL
+ util_aligned_delete(osl_globals);
+#endif
task_pool.stop();
texture_info.free();
}
@@ -492,7 +498,7 @@ class CPUDevice : public Device {
void *osl_memory()
{
#ifdef WITH_OSL
- return &osl_globals;
+ return osl_globals;
#else
return NULL;
#endif
@@ -981,7 +987,7 @@ class CPUDevice : public Device {
KernelGlobals kg = kernel_globals;
#ifdef WITH_OSL
- OSLShader::thread_init(&kg, &kernel_globals, &osl_globals);
+ OSLShader::thread_init(&kg, &kernel_globals, osl_globals);
#endif
for (int sample = 0; sample < task.num_samples; sample++) {
for (int x = task.shader_x; x < task.shader_x + task.shader_w; x++)
@@ -1053,7 +1059,7 @@ class CPUDevice : public Device {
kg.decoupled_volume_steps_index = 0;
kg.coverage_asset = kg.coverage_object = kg.coverage_material = NULL;
#ifdef WITH_OSL
- OSLShader::thread_init(&kg, &kernel_globals, &osl_globals);
+ OSLShader::thread_init(&kg, &kernel_globals, osl_globals);
#endif
return kg;
}
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 936e1dccfa6..cac1edb188e 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -1019,7 +1019,7 @@ class CUDADevice : public Device {
size_t bytes;
cuda_assert(cuModuleGetGlobal(&mem, &bytes, cuModule, name));
- //assert(bytes == size);
+ // assert(bytes == size);
cuda_assert(cuMemcpyHtoD(mem, host, size));
}
@@ -2127,7 +2127,8 @@ class CUDADevice : public Device {
}
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
- /* invalidate old contents - avoids stalling if buffer is still waiting in queue to be rendered */
+ /* invalidate old contents -
+ * avoids stalling if buffer is still waiting in queue to be rendered */
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), NULL, GL_STREAM_DRAW);
vpointer = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
diff --git a/intern/cycles/device/device_denoising.cpp b/intern/cycles/device/device_denoising.cpp
index 05a7fb8ae4d..55548c98b97 100644
--- a/intern/cycles/device/device_denoising.cpp
+++ b/intern/cycles/device/device_denoising.cpp
@@ -104,7 +104,8 @@ void DenoisingTask::set_render_buffer(RenderTile *rtiles)
void DenoisingTask::setup_denoising_buffer()
{
- /* Expand filter_area by radius pixels and clamp the result to the extent of the neighboring tiles */
+ /* Expand filter_area by radius pixels and clamp the result to the extent of the neighboring
+ * tiles */
rect = rect_from_shape(filter_area.x, filter_area.y, filter_area.z, filter_area.w);
rect = rect_expand(rect, radius);
rect = rect_clip(rect,
@@ -149,16 +150,19 @@ void DenoisingTask::prefilter_shadowing()
device_sub_ptr buffer_var(buffer.mem, 5 * buffer.pass_stride, buffer.pass_stride);
device_sub_ptr filtered_var(buffer.mem, 6 * buffer.pass_stride, buffer.pass_stride);
- /* Get the A/B unfiltered passes, the combined sample variance, the estimated variance of the sample variance and the buffer variance. */
+ /* Get the A/B unfiltered passes, the combined sample variance, the estimated variance of the
+ * sample variance and the buffer variance. */
functions.divide_shadow(*unfiltered_a, *unfiltered_b, *sample_var, *sample_var_var, *buffer_var);
- /* Smooth the (generally pretty noisy) buffer variance using the spatial information from the sample variance. */
+ /* Smooth the (generally pretty noisy) buffer variance using the spatial information from the
+ * sample variance. */
nlm_state.set_parameters(6, 3, 4.0f, 1.0f, false);
functions.non_local_means(*buffer_var, *sample_var, *sample_var_var, *filtered_var);
/* Reuse memory, the previous data isn't needed anymore. */
device_ptr filtered_a = *buffer_var, filtered_b = *sample_var;
- /* Use the smoothed variance to filter the two shadow half images using each other for weight calculation. */
+ /* Use the smoothed variance to filter the two shadow half images using each other for weight
+ * calculation. */
nlm_state.set_parameters(5, 3, 1.0f, 0.25f, false);
functions.non_local_means(*unfiltered_a, *unfiltered_b, *filtered_var, filtered_a);
functions.non_local_means(*unfiltered_b, *unfiltered_a, *filtered_var, filtered_b);
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 99a8d2438d6..b07596c60ff 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -136,8 +136,8 @@ string device_opencl_capabilities()
}
string result = "";
string error_msg = ""; /* Only used by opencl_assert(), but in the future
- * it could also be nicely reported to the console.
- */
+ * it could also be nicely reported to the console.
+ */
cl_uint num_platforms = 0;
opencl_assert(device_opencl_get_num_platforms_safe(&num_platforms));
if (num_platforms == 0) {
diff --git a/intern/cycles/device/device_split_kernel.h b/intern/cycles/device/device_split_kernel.h
index c9fb2ac844f..6ff326bf214 100644
--- a/intern/cycles/device/device_split_kernel.h
+++ b/intern/cycles/device/device_split_kernel.h
@@ -27,7 +27,7 @@ CCL_NAMESPACE_BEGIN
* Since some bytes may be needed for aligning chunks of memory;
* This is the amount of memory that we dedicate for that purpose.
*/
-#define DATA_ALLOCATION_MEM_FACTOR 5000000 //5MB
+#define DATA_ALLOCATION_MEM_FACTOR 5000000 // 5MB
/* Types used for split kernel */
diff --git a/intern/cycles/device/device_task.h b/intern/cycles/device/device_task.h
index 5cc2e5e25db..a04062ed4ef 100644
--- a/intern/cycles/device/device_task.h
+++ b/intern/cycles/device/device_task.h
@@ -40,7 +40,8 @@ class DenoiseParams {
float strength;
/* Preserve more or less detail based on feature passes. */
float feature_strength;
- /* When removing pixels that don't carry information, use a relative threshold instead of an absolute one. */
+ /* When removing pixels that don't carry information,
+ * use a relative threshold instead of an absolute one. */
bool relative_pca;
/* How many frames before and after the current center frame are included. */
int neighbor_frames;
diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h
index e7bafa0b8a8..70773902790 100644
--- a/intern/cycles/device/opencl/opencl.h
+++ b/intern/cycles/device/opencl/opencl.h
@@ -358,8 +358,8 @@ class OpenCLDevice : public Device {
OpenCLSplitPrograms(OpenCLDevice *device);
~OpenCLSplitPrograms();
- /* Load the kernels and put the created kernels in the given `programs`
- * paramter. */
+ /* Load the kernels and put the created kernels in the given
+ * `programs` paramter. */
void load_kernels(vector<OpenCLProgram *> &programs,
const DeviceRequestedFeatures &requested_features,
bool is_preview = false);
diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp
index 70b1a643044..442b92100bb 100644
--- a/intern/cycles/device/opencl/opencl_split.cpp
+++ b/intern/cycles/device/opencl/opencl_split.cpp
@@ -265,7 +265,7 @@ void OpenCLDevice::OpenCLSplitPrograms::load_kernels(
ADD_SPLIT_KERNEL_PROGRAM(shader_eval);
/* Quick kernels bundled in a single program to reduce overhead of starting
- * Blender processes. */
+ * Blender processes. */
program_split = OpenCLDevice::OpenCLProgram(
device,
"split_bundle",
@@ -668,7 +668,8 @@ OpenCLDevice::OpenCLDevice(DeviceInfo &info, Stats &stats, Profiler &profiler, b
return;
}
- /* Allocate this right away so that texture_info is placed at offset 0 in the device memory buffers */
+ /* Allocate this right away so that texture_info
+ * is placed at offset 0 in the device memory buffers. */
texture_info.resize(1);
memory_manager.alloc("texture_info", texture_info);
@@ -1149,7 +1150,8 @@ void OpenCLDevice::tex_alloc(device_memory &mem)
<< string_human_readable_size(mem.memory_size()) << ")";
memory_manager.alloc(mem.name, mem);
- /* Set the pointer to non-null to keep code that inspects its value from thinking its unallocated. */
+ /* Set the pointer to non-null to keep code that inspects its value from thinking its
+ * unallocated. */
mem.device_pointer = 1;
textures[mem.name] = &mem;
textures_need_update = true;
diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h
index 13e72ed299f..7503bad37b0 100644
--- a/intern/cycles/kernel/bvh/bvh.h
+++ b/intern/cycles/kernel/bvh/bvh.h
@@ -57,7 +57,7 @@ CCL_NAMESPACE_BEGIN
#if defined(__HAIR__)
# define BVH_FUNCTION_NAME bvh_intersect_hair
-# define BVH_FUNCTION_FEATURES BVH_INSTANCING | BVH_HAIR | BVH_HAIR_MINIMUM_WIDTH
+# define BVH_FUNCTION_FEATURES BVH_INSTANCING | BVH_HAIR
# include "kernel/bvh/bvh_traversal.h"
#endif
@@ -69,7 +69,7 @@ CCL_NAMESPACE_BEGIN
#if defined(__HAIR__) && defined(__OBJECT_MOTION__)
# define BVH_FUNCTION_NAME bvh_intersect_hair_motion
-# define BVH_FUNCTION_FEATURES BVH_INSTANCING | BVH_HAIR | BVH_HAIR_MINIMUM_WIDTH | BVH_MOTION
+# define BVH_FUNCTION_FEATURES BVH_INSTANCING | BVH_HAIR | BVH_MOTION
# include "kernel/bvh/bvh_traversal.h"
#endif
@@ -181,10 +181,7 @@ ccl_device_inline bool scene_intersect_valid(const Ray *ray)
ccl_device_intersect bool scene_intersect(KernelGlobals *kg,
const Ray ray,
const uint visibility,
- Intersection *isect,
- uint *lcg_state,
- float difl,
- float extmax)
+ Intersection *isect)
{
PROFILING_INIT(kg, PROFILING_INTERSECT);
@@ -211,7 +208,7 @@ ccl_device_intersect bool scene_intersect(KernelGlobals *kg,
if (kernel_data.bvh.have_motion) {
# ifdef __HAIR__
if (kernel_data.bvh.have_curves)
- return bvh_intersect_hair_motion(kg, &ray, isect, visibility, lcg_state, difl, extmax);
+ return bvh_intersect_hair_motion(kg, &ray, isect, visibility);
# endif /* __HAIR__ */
return bvh_intersect_motion(kg, &ray, isect, visibility);
@@ -220,7 +217,7 @@ ccl_device_intersect bool scene_intersect(KernelGlobals *kg,
#ifdef __HAIR__
if (kernel_data.bvh.have_curves)
- return bvh_intersect_hair(kg, &ray, isect, visibility, lcg_state, difl, extmax);
+ return bvh_intersect_hair(kg, &ray, isect, visibility);
#endif /* __HAIR__ */
#ifdef __KERNEL_CPU__
diff --git a/intern/cycles/kernel/bvh/bvh_nodes.h b/intern/cycles/kernel/bvh/bvh_nodes.h
index 042630121c8..a33bc73e25b 100644
--- a/intern/cycles/kernel/bvh/bvh_nodes.h
+++ b/intern/cycles/kernel/bvh/bvh_nodes.h
@@ -75,67 +75,6 @@ ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg,
# endif
}
-ccl_device_forceinline int bvh_aligned_node_intersect_robust(KernelGlobals *kg,
- const float3 P,
- const float3 idir,
- const float t,
- const float difl,
- const float extmax,
- const int node_addr,
- const uint visibility,
- float dist[2])
-{
-
- /* fetch node data */
- float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
- float4 node0 = kernel_tex_fetch(__bvh_nodes, node_addr + 1);
- float4 node1 = kernel_tex_fetch(__bvh_nodes, node_addr + 2);
- float4 node2 = kernel_tex_fetch(__bvh_nodes, node_addr + 3);
-
- /* intersect ray against child nodes */
- float c0lox = (node0.x - P.x) * idir.x;
- float c0hix = (node0.z - P.x) * idir.x;
- float c0loy = (node1.x - P.y) * idir.y;
- float c0hiy = (node1.z - P.y) * idir.y;
- float c0loz = (node2.x - P.z) * idir.z;
- float c0hiz = (node2.z - P.z) * idir.z;
- float c0min = max4(0.0f, min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz));
- float c0max = min4(t, max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz));
-
- float c1lox = (node0.y - P.x) * idir.x;
- float c1hix = (node0.w - P.x) * idir.x;
- float c1loy = (node1.y - P.y) * idir.y;
- float c1hiy = (node1.w - P.y) * idir.y;
- float c1loz = (node2.y - P.z) * idir.z;
- float c1hiz = (node2.w - P.z) * idir.z;
- float c1min = max4(0.0f, min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz));
- float c1max = min4(t, max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz));
-
- if (difl != 0.0f) {
- float hdiff = 1.0f + difl;
- float ldiff = 1.0f - difl;
- if (__float_as_int(cnodes.z) & PATH_RAY_CURVE) {
- c0min = max(ldiff * c0min, c0min - extmax);
- c0max = min(hdiff * c0max, c0max + extmax);
- }
- if (__float_as_int(cnodes.w) & PATH_RAY_CURVE) {
- c1min = max(ldiff * c1min, c1min - extmax);
- c1max = min(hdiff * c1max, c1max + extmax);
- }
- }
-
- dist[0] = c0min;
- dist[1] = c1min;
-
-# ifdef __VISIBILITY_FLAG__
- /* this visibility test gives a 5% performance hit, how to solve? */
- return (((c0max >= c0min) && (__float_as_uint(cnodes.x) & visibility)) ? 1 : 0) |
- (((c1max >= c1min) && (__float_as_uint(cnodes.y) & visibility)) ? 2 : 0);
-# else
- return ((c0max >= c0min) ? 1 : 0) | ((c1max >= c1min) ? 2 : 0);
-# endif
-}
-
ccl_device_forceinline bool bvh_unaligned_node_intersect_child(KernelGlobals *kg,
const float3 P,
const float3 dir,
@@ -162,41 +101,6 @@ ccl_device_forceinline bool bvh_unaligned_node_intersect_child(KernelGlobals *kg
return tnear <= tfar;
}
-ccl_device_forceinline bool bvh_unaligned_node_intersect_child_robust(KernelGlobals *kg,
- const float3 P,
- const float3 dir,
- const float t,
- const float difl,
- int node_addr,
- int child,
- float dist[2])
-{
- Transform space = bvh_unaligned_node_fetch_space(kg, node_addr, child);
- float3 aligned_dir = transform_direction(&space, dir);
- float3 aligned_P = transform_point(&space, P);
- float3 nrdir = -bvh_inverse_direction(aligned_dir);
- float3 tLowerXYZ = aligned_P * nrdir;
- float3 tUpperXYZ = tLowerXYZ - nrdir;
- const float near_x = min(tLowerXYZ.x, tUpperXYZ.x);
- const float near_y = min(tLowerXYZ.y, tUpperXYZ.y);
- const float near_z = min(tLowerXYZ.z, tUpperXYZ.z);
- const float far_x = max(tLowerXYZ.x, tUpperXYZ.x);
- const float far_y = max(tLowerXYZ.y, tUpperXYZ.y);
- const float far_z = max(tLowerXYZ.z, tUpperXYZ.z);
- const float tnear = max4(0.0f, near_x, near_y, near_z);
- const float tfar = min4(t, far_x, far_y, far_z);
- *dist = tnear;
- if (difl != 0.0f) {
- /* TODO(sergey): Same as for QBVH, needs a proper use. */
- const float round_down = 1.0f - difl;
- const float round_up = 1.0f + difl;
- return round_down * tnear <= round_up * tfar;
- }
- else {
- return tnear <= tfar;
- }
-}
-
ccl_device_forceinline int bvh_unaligned_node_intersect(KernelGlobals *kg,
const float3 P,
const float3 dir,
@@ -227,38 +131,6 @@ ccl_device_forceinline int bvh_unaligned_node_intersect(KernelGlobals *kg,
return mask;
}
-ccl_device_forceinline int bvh_unaligned_node_intersect_robust(KernelGlobals *kg,
- const float3 P,
- const float3 dir,
- const float3 idir,
- const float t,
- const float difl,
- const float extmax,
- const int node_addr,
- const uint visibility,
- float dist[2])
-{
- int mask = 0;
- float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
- if (bvh_unaligned_node_intersect_child_robust(kg, P, dir, t, difl, node_addr, 0, &dist[0])) {
-# ifdef __VISIBILITY_FLAG__
- if ((__float_as_uint(cnodes.x) & visibility))
-# endif
- {
- mask |= 1;
- }
- }
- if (bvh_unaligned_node_intersect_child_robust(kg, P, dir, t, difl, node_addr, 1, &dist[1])) {
-# ifdef __VISIBILITY_FLAG__
- if ((__float_as_uint(cnodes.y) & visibility))
-# endif
- {
- mask |= 2;
- }
- }
- return mask;
-}
-
ccl_device_forceinline int bvh_node_intersect(KernelGlobals *kg,
const float3 P,
const float3 dir,
@@ -277,27 +149,6 @@ ccl_device_forceinline int bvh_node_intersect(KernelGlobals *kg,
}
}
-ccl_device_forceinline int bvh_node_intersect_robust(KernelGlobals *kg,
- const float3 P,
- const float3 dir,
- const float3 idir,
- const float t,
- const float difl,
- const float extmax,
- const int node_addr,
- const uint visibility,
- float dist[2])
-{
- float4 node = kernel_tex_fetch(__bvh_nodes, node_addr);
- if (__float_as_uint(node.x) & PATH_RAY_NODE_UNALIGNED) {
- return bvh_unaligned_node_intersect_robust(
- kg, P, dir, idir, t, difl, extmax, node_addr, visibility, dist);
- }
- else {
- return bvh_aligned_node_intersect_robust(
- kg, P, idir, t, difl, extmax, node_addr, visibility, dist);
- }
-}
#else /* !defined(__KERNEL_SSE2__) */
int ccl_device_forceinline bvh_aligned_node_intersect(KernelGlobals *kg,
@@ -343,69 +194,6 @@ int ccl_device_forceinline bvh_aligned_node_intersect(KernelGlobals *kg,
# endif
}
-ccl_device_forceinline int bvh_aligned_node_intersect_robust(KernelGlobals *kg,
- const float3 &P,
- const float3 &dir,
- const ssef &tsplat,
- const ssef Psplat[3],
- const ssef idirsplat[3],
- const shuffle_swap_t shufflexyz[3],
- const float difl,
- const float extmax,
- const int nodeAddr,
- const uint visibility,
- float dist[2])
-{
- /* Intersect two child bounding boxes, SSE3 version adapted from Embree */
- const ssef pn = cast(ssei(0, 0, 0x80000000, 0x80000000));
-
- /* fetch node data */
- const ssef *bvh_nodes = (ssef *)kg->__bvh_nodes.data + nodeAddr;
-
- /* intersect ray against child nodes */
- const ssef tminmaxx = (shuffle_swap(bvh_nodes[1], shufflexyz[0]) - Psplat[0]) * idirsplat[0];
- const ssef tminmaxy = (shuffle_swap(bvh_nodes[2], shufflexyz[1]) - Psplat[1]) * idirsplat[1];
- const ssef tminmaxz = (shuffle_swap(bvh_nodes[3], shufflexyz[2]) - Psplat[2]) * idirsplat[2];
-
- /* calculate { c0min, c1min, -c0max, -c1max} */
- ssef minmax = max(max(tminmaxx, tminmaxy), max(tminmaxz, tsplat));
- const ssef tminmax = minmax ^ pn;
-
- if (difl != 0.0f) {
- float4 cnodes = kernel_tex_fetch(__bvh_nodes, nodeAddr + 0);
- float4 *tminmaxview = (float4 *)&tminmax;
- float &c0min = tminmaxview->x, &c1min = tminmaxview->y;
- float &c0max = tminmaxview->z, &c1max = tminmaxview->w;
- float hdiff = 1.0f + difl;
- float ldiff = 1.0f - difl;
- if (__float_as_int(cnodes.x) & PATH_RAY_CURVE) {
- c0min = max(ldiff * c0min, c0min - extmax);
- c0max = min(hdiff * c0max, c0max + extmax);
- }
- if (__float_as_int(cnodes.y) & PATH_RAY_CURVE) {
- c1min = max(ldiff * c1min, c1min - extmax);
- c1max = min(hdiff * c1max, c1max + extmax);
- }
- }
-
- const sseb lrhit = tminmax <= shuffle<2, 3, 0, 1>(tminmax);
-
- dist[0] = tminmax[0];
- dist[1] = tminmax[1];
-
- int mask = movemask(lrhit);
-
-# ifdef __VISIBILITY_FLAG__
- /* this visibility test gives a 5% performance hit, how to solve? */
- float4 cnodes = kernel_tex_fetch(__bvh_nodes, nodeAddr + 0);
- int cmask = (((mask & 1) && (__float_as_uint(cnodes.x) & visibility)) ? 1 : 0) |
- (((mask & 2) && (__float_as_uint(cnodes.y) & visibility)) ? 2 : 0);
- return cmask;
-# else
- return mask & 3;
-# endif
-}
-
ccl_device_forceinline int bvh_unaligned_node_intersect(KernelGlobals *kg,
const float3 P,
const float3 dir,
@@ -458,68 +246,6 @@ ccl_device_forceinline int bvh_unaligned_node_intersect(KernelGlobals *kg,
# endif
}
-ccl_device_forceinline int bvh_unaligned_node_intersect_robust(KernelGlobals *kg,
- const float3 P,
- const float3 dir,
- const ssef &isect_near,
- const ssef &isect_far,
- const float difl,
- const int node_addr,
- const uint visibility,
- float dist[2])
-{
- Transform space0 = bvh_unaligned_node_fetch_space(kg, node_addr, 0);
- Transform space1 = bvh_unaligned_node_fetch_space(kg, node_addr, 1);
-
- float3 aligned_dir0 = transform_direction(&space0, dir),
- aligned_dir1 = transform_direction(&space1, dir);
- float3 aligned_P0 = transform_point(&space0, P), aligned_P1 = transform_point(&space1, P);
- float3 nrdir0 = -bvh_inverse_direction(aligned_dir0),
- nrdir1 = -bvh_inverse_direction(aligned_dir1);
-
- ssef lower_x = ssef(aligned_P0.x * nrdir0.x, aligned_P1.x * nrdir1.x, 0.0f, 0.0f),
- lower_y = ssef(aligned_P0.y * nrdir0.y, aligned_P1.y * nrdir1.y, 0.0f, 0.0f),
- lower_z = ssef(aligned_P0.z * nrdir0.z, aligned_P1.z * nrdir1.z, 0.0f, 0.0f);
-
- ssef upper_x = lower_x - ssef(nrdir0.x, nrdir1.x, 0.0f, 0.0f),
- upper_y = lower_y - ssef(nrdir0.y, nrdir1.y, 0.0f, 0.0f),
- upper_z = lower_z - ssef(nrdir0.z, nrdir1.z, 0.0f, 0.0f);
-
- ssef tnear_x = min(lower_x, upper_x);
- ssef tnear_y = min(lower_y, upper_y);
- ssef tnear_z = min(lower_z, upper_z);
- ssef tfar_x = max(lower_x, upper_x);
- ssef tfar_y = max(lower_y, upper_y);
- ssef tfar_z = max(lower_z, upper_z);
-
- const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
- const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
- sseb vmask;
- if (difl != 0.0f) {
- const float round_down = 1.0f - difl;
- const float round_up = 1.0f + difl;
- vmask = round_down * tnear <= round_up * tfar;
- }
- else {
- vmask = tnear <= tfar;
- }
-
- dist[0] = tnear.f[0];
- dist[1] = tnear.f[1];
-
- int mask = (int)movemask(vmask);
-
-# ifdef __VISIBILITY_FLAG__
- /* this visibility test gives a 5% performance hit, how to solve? */
- float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
- int cmask = (((mask & 1) && (__float_as_uint(cnodes.x) & visibility)) ? 1 : 0) |
- (((mask & 2) && (__float_as_uint(cnodes.y) & visibility)) ? 2 : 0);
- return cmask;
-# else
- return mask & 3;
-# endif
-}
-
ccl_device_forceinline int bvh_node_intersect(KernelGlobals *kg,
const float3 &P,
const float3 &dir,
@@ -543,40 +269,4 @@ ccl_device_forceinline int bvh_node_intersect(KernelGlobals *kg,
kg, P, dir, tsplat, Psplat, idirsplat, shufflexyz, node_addr, visibility, dist);
}
}
-
-ccl_device_forceinline int bvh_node_intersect_robust(KernelGlobals *kg,
- const float3 &P,
- const float3 &dir,
- const ssef &isect_near,
- const ssef &isect_far,
- const ssef &tsplat,
- const ssef Psplat[3],
- const ssef idirsplat[3],
- const shuffle_swap_t shufflexyz[3],
- const float difl,
- const float extmax,
- const int node_addr,
- const uint visibility,
- float dist[2])
-{
- float4 node = kernel_tex_fetch(__bvh_nodes, node_addr);
- if (__float_as_uint(node.x) & PATH_RAY_NODE_UNALIGNED) {
- return bvh_unaligned_node_intersect_robust(
- kg, P, dir, isect_near, isect_far, difl, node_addr, visibility, dist);
- }
- else {
- return bvh_aligned_node_intersect_robust(kg,
- P,
- dir,
- tsplat,
- Psplat,
- idirsplat,
- shufflexyz,
- difl,
- extmax,
- node_addr,
- visibility,
- dist);
- }
-}
#endif /* !defined(__KERNEL_SSE2__) */
diff --git a/intern/cycles/kernel/bvh/bvh_shadow_all.h b/intern/cycles/kernel/bvh/bvh_shadow_all.h
index b362779549c..268bb149970 100644
--- a/intern/cycles/kernel/bvh/bvh_shadow_all.h
+++ b/intern/cycles/kernel/bvh/bvh_shadow_all.h
@@ -219,10 +219,7 @@ ccl_device_inline
object,
prim_addr,
ray->time,
- curve_type,
- NULL,
- 0,
- 0);
+ curve_type);
}
else {
hit = curve_intersect(kg,
@@ -233,10 +230,7 @@ ccl_device_inline
object,
prim_addr,
ray->time,
- curve_type,
- NULL,
- 0,
- 0);
+ curve_type);
}
break;
}
diff --git a/intern/cycles/kernel/bvh/bvh_traversal.h b/intern/cycles/kernel/bvh/bvh_traversal.h
index 34a06d003bb..18afc6ae4eb 100644
--- a/intern/cycles/kernel/bvh/bvh_traversal.h
+++ b/intern/cycles/kernel/bvh/bvh_traversal.h
@@ -26,10 +26,8 @@
#if BVH_FEATURE(BVH_HAIR)
# define NODE_INTERSECT bvh_node_intersect
-# define NODE_INTERSECT_ROBUST bvh_node_intersect_robust
#else
# define NODE_INTERSECT bvh_aligned_node_intersect
-# define NODE_INTERSECT_ROBUST bvh_aligned_node_intersect_robust
#endif
/* This is a template BVH traversal function, where various features can be
@@ -38,21 +36,13 @@
*
* BVH_INSTANCING: object instancing
* BVH_HAIR: hair curve rendering
- * BVH_HAIR_MINIMUM_WIDTH: hair curve rendering with minimum width
* BVH_MOTION: motion blur rendering
*/
ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
const Ray *ray,
Intersection *isect,
- const uint visibility
-#if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH)
- ,
- uint *lcg_state,
- float difl,
- float extmax
-#endif
-)
+ const uint visibility)
{
/* todo:
* - test if pushing distance on the stack helps (for non shadow rays)
@@ -117,23 +107,6 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
#if !defined(__KERNEL_SSE2__)
-# if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH)
- if (difl != 0.0f) {
- traverse_mask = NODE_INTERSECT_ROBUST(kg,
- P,
-# if BVH_FEATURE(BVH_HAIR)
- dir,
-# endif
- idir,
- isect->t,
- difl,
- extmax,
- node_addr,
- visibility,
- dist);
- }
- else
-# endif
{
traverse_mask = NODE_INTERSECT(kg,
P,
@@ -147,27 +120,6 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
dist);
}
#else // __KERNEL_SSE2__
-# if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH)
- if (difl != 0.0f) {
- traverse_mask = NODE_INTERSECT_ROBUST(kg,
- P,
- dir,
-# if BVH_FEATURE(BVH_HAIR)
- tnear,
- tfar,
-# endif
- tsplat,
- Psplat,
- idirsplat,
- shufflexyz,
- difl,
- extmax,
- node_addr,
- visibility,
- dist);
- }
- else
-# endif
{
traverse_mask = NODE_INTERSECT(kg,
P,
@@ -287,32 +239,12 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL));
bool hit;
if (kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) {
- hit = cardinal_curve_intersect(kg,
- isect,
- P,
- dir,
- visibility,
- object,
- prim_addr,
- ray->time,
- curve_type,
- lcg_state,
- difl,
- extmax);
+ hit = cardinal_curve_intersect(
+ kg, isect, P, dir, visibility, object, prim_addr, ray->time, curve_type);
}
else {
- hit = curve_intersect(kg,
- isect,
- P,
- dir,
- visibility,
- object,
- prim_addr,
- ray->time,
- curve_type,
- lcg_state,
- difl,
- extmax);
+ hit = curve_intersect(
+ kg, isect, P, dir, visibility, object, prim_addr, ray->time, curve_type);
}
if (hit) {
/* shadow ray early termination */
@@ -408,56 +340,19 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
const Ray *ray,
Intersection *isect,
- const uint visibility
-#if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH)
- ,
- uint *lcg_state,
- float difl,
- float extmax
-#endif
-)
+ const uint visibility)
{
switch (kernel_data.bvh.bvh_layout) {
#ifdef __KERNEL_AVX2__
case BVH_LAYOUT_BVH8:
- return BVH_FUNCTION_FULL_NAME(OBVH)(kg,
- ray,
- isect,
- visibility
-# if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH)
- ,
- lcg_state,
- difl,
- extmax
-# endif
- );
+ return BVH_FUNCTION_FULL_NAME(OBVH)(kg, ray, isect, visibility);
#endif
#ifdef __QBVH__
case BVH_LAYOUT_BVH4:
- return BVH_FUNCTION_FULL_NAME(QBVH)(kg,
- ray,
- isect,
- visibility
-# if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH)
- ,
- lcg_state,
- difl,
- extmax
-# endif
- );
+ return BVH_FUNCTION_FULL_NAME(QBVH)(kg, ray, isect, visibility);
#endif /* __QBVH__ */
case BVH_LAYOUT_BVH2:
- return BVH_FUNCTION_FULL_NAME(BVH)(kg,
- ray,
- isect,
- visibility
-#if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH)
- ,
- lcg_state,
- difl,
- extmax
-#endif
- );
+ return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect, visibility);
}
kernel_assert(!"Should not happen");
return false;
@@ -466,4 +361,3 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
#undef BVH_FUNCTION_NAME
#undef BVH_FUNCTION_FEATURES
#undef NODE_INTERSECT
-#undef NODE_INTERSECT_ROBUST
diff --git a/intern/cycles/kernel/bvh/bvh_types.h b/intern/cycles/kernel/bvh/bvh_types.h
index 16f3b03f842..84dc0dbaef5 100644
--- a/intern/cycles/kernel/bvh/bvh_types.h
+++ b/intern/cycles/kernel/bvh/bvh_types.h
@@ -38,7 +38,6 @@ CCL_NAMESPACE_BEGIN
#define BVH_INSTANCING 1
#define BVH_MOTION 2
#define BVH_HAIR 4
-#define BVH_HAIR_MINIMUM_WIDTH 8
#define BVH_NAME_JOIN(x, y) x##_##y
#define BVH_NAME_EVAL(x, y) BVH_NAME_JOIN(x, y)
diff --git a/intern/cycles/kernel/bvh/obvh_nodes.h b/intern/cycles/kernel/bvh/obvh_nodes.h
index 6831562cade..e5c935b75ed 100644
--- a/intern/cycles/kernel/bvh/obvh_nodes.h
+++ b/intern/cycles/kernel/bvh/obvh_nodes.h
@@ -276,53 +276,6 @@ ccl_device_inline int obvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg
#endif
}
-ccl_device_inline int obvh_aligned_node_intersect_robust(KernelGlobals *ccl_restrict kg,
- const avxf &isect_near,
- const avxf &isect_far,
-#ifdef __KERNEL_AVX2__
- const avx3f &P_idir,
-#else
- const avx3f &P,
-#endif
- const avx3f &idir,
- const int near_x,
- const int near_y,
- const int near_z,
- const int far_x,
- const int far_y,
- const int far_z,
- const int node_addr,
- const float difl,
- avxf *ccl_restrict dist)
-{
- const int offset = node_addr + 2;
-#ifdef __KERNEL_AVX2__
- const avxf tnear_x = msub(
- kernel_tex_fetch_avxf(__bvh_nodes, offset + near_x * 2), idir.x, P_idir.x);
- const avxf tfar_x = msub(
- kernel_tex_fetch_avxf(__bvh_nodes, offset + far_x * 2), idir.x, P_idir.x);
- const avxf tnear_y = msub(
- kernel_tex_fetch_avxf(__bvh_nodes, offset + near_y * 2), idir.y, P_idir.y);
- const avxf tfar_y = msub(
- kernel_tex_fetch_avxf(__bvh_nodes, offset + far_y * 2), idir.y, P_idir.y);
- const avxf tnear_z = msub(
- kernel_tex_fetch_avxf(__bvh_nodes, offset + near_z * 2), idir.z, P_idir.z);
- const avxf tfar_z = msub(
- kernel_tex_fetch_avxf(__bvh_nodes, offset + far_z * 2), idir.z, P_idir.z);
-
- const float round_down = 1.0f - difl;
- const float round_up = 1.0f + difl;
- const avxf tnear = max4(tnear_x, tnear_y, tnear_z, isect_near);
- const avxf tfar = min4(tfar_x, tfar_y, tfar_z, isect_far);
- const avxb vmask = round_down * tnear <= round_up * tfar;
- int mask = (int)movemask(vmask);
- *dist = tnear;
- return mask;
-#else
- return 0;
-#endif
-}
-
/* Unaligned nodes intersection */
ccl_device_inline int obvh_unaligned_node_intersect(KernelGlobals *ccl_restrict kg,
@@ -391,77 +344,6 @@ ccl_device_inline int obvh_unaligned_node_intersect(KernelGlobals *ccl_restrict
return movemask(vmask);
}
-ccl_device_inline int obvh_unaligned_node_intersect_robust(KernelGlobals *ccl_restrict kg,
- const avxf &isect_near,
- const avxf &isect_far,
-#ifdef __KERNEL_AVX2__
- const avx3f &P_idir,
-#endif
- const avx3f &P,
- const avx3f &dir,
- const avx3f &idir,
- const int near_x,
- const int near_y,
- const int near_z,
- const int far_x,
- const int far_y,
- const int far_z,
- const int node_addr,
- const float difl,
- avxf *ccl_restrict dist)
-{
- const int offset = node_addr;
- const avxf tfm_x_x = kernel_tex_fetch_avxf(__bvh_nodes, offset + 2);
- const avxf tfm_x_y = kernel_tex_fetch_avxf(__bvh_nodes, offset + 4);
- const avxf tfm_x_z = kernel_tex_fetch_avxf(__bvh_nodes, offset + 6);
-
- const avxf tfm_y_x = kernel_tex_fetch_avxf(__bvh_nodes, offset + 8);
- const avxf tfm_y_y = kernel_tex_fetch_avxf(__bvh_nodes, offset + 10);
- const avxf tfm_y_z = kernel_tex_fetch_avxf(__bvh_nodes, offset + 12);
-
- const avxf tfm_z_x = kernel_tex_fetch_avxf(__bvh_nodes, offset + 14);
- const avxf tfm_z_y = kernel_tex_fetch_avxf(__bvh_nodes, offset + 16);
- const avxf tfm_z_z = kernel_tex_fetch_avxf(__bvh_nodes, offset + 18);
-
- const avxf tfm_t_x = kernel_tex_fetch_avxf(__bvh_nodes, offset + 20);
- const avxf tfm_t_y = kernel_tex_fetch_avxf(__bvh_nodes, offset + 22);
- const avxf tfm_t_z = kernel_tex_fetch_avxf(__bvh_nodes, offset + 24);
-
- const avxf aligned_dir_x = dir.x * tfm_x_x + dir.y * tfm_x_y + dir.z * tfm_x_z,
- aligned_dir_y = dir.x * tfm_y_x + dir.y * tfm_y_y + dir.z * tfm_y_z,
- aligned_dir_z = dir.x * tfm_z_x + dir.y * tfm_z_y + dir.z * tfm_z_z;
-
- const avxf aligned_P_x = P.x * tfm_x_x + P.y * tfm_x_y + P.z * tfm_x_z + tfm_t_x,
- aligned_P_y = P.x * tfm_y_x + P.y * tfm_y_y + P.z * tfm_y_z + tfm_t_y,
- aligned_P_z = P.x * tfm_z_x + P.y * tfm_z_y + P.z * tfm_z_z + tfm_t_z;
-
- const avxf neg_one(-1.0f);
- const avxf nrdir_x = neg_one / aligned_dir_x, nrdir_y = neg_one / aligned_dir_y,
- nrdir_z = neg_one / aligned_dir_z;
-
- const avxf tlower_x = aligned_P_x * nrdir_x, tlower_y = aligned_P_y * nrdir_y,
- tlower_z = aligned_P_z * nrdir_z;
-
- const avxf tupper_x = tlower_x - nrdir_x, tupper_y = tlower_y - nrdir_y,
- tupper_z = tlower_z - nrdir_z;
-
- const float round_down = 1.0f - difl;
- const float round_up = 1.0f + difl;
-
- const avxf tnear_x = min(tlower_x, tupper_x);
- const avxf tnear_y = min(tlower_y, tupper_y);
- const avxf tnear_z = min(tlower_z, tupper_z);
- const avxf tfar_x = max(tlower_x, tupper_x);
- const avxf tfar_y = max(tlower_y, tupper_y);
- const avxf tfar_z = max(tlower_z, tupper_z);
-
- const avxf tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
- const avxf tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
- const avxb vmask = round_down * tnear <= round_up * tfar;
- *dist = tnear;
- return movemask(vmask);
-}
-
/* Intersectors wrappers.
*
* They'll check node type and call appropriate intersection code.
@@ -526,66 +408,3 @@ ccl_device_inline int obvh_node_intersect(KernelGlobals *ccl_restrict kg,
dist);
}
}
-
-ccl_device_inline int obvh_node_intersect_robust(KernelGlobals *ccl_restrict kg,
- const avxf &isect_near,
- const avxf &isect_far,
-#ifdef __KERNEL_AVX2__
- const avx3f &P_idir,
-#endif
- const avx3f &P,
- const avx3f &dir,
- const avx3f &idir,
- const int near_x,
- const int near_y,
- const int near_z,
- const int far_x,
- const int far_y,
- const int far_z,
- const int node_addr,
- const float difl,
- avxf *ccl_restrict dist)
-{
- const int offset = node_addr;
- const float4 node = kernel_tex_fetch(__bvh_nodes, offset);
- if (__float_as_uint(node.x) & PATH_RAY_NODE_UNALIGNED) {
- return obvh_unaligned_node_intersect_robust(kg,
- isect_near,
- isect_far,
-#ifdef __KERNEL_AVX2__
- P_idir,
-#endif
- P,
- dir,
- idir,
- near_x,
- near_y,
- near_z,
- far_x,
- far_y,
- far_z,
- node_addr,
- difl,
- dist);
- }
- else {
- return obvh_aligned_node_intersect_robust(kg,
- isect_near,
- isect_far,
-#ifdef __KERNEL_AVX2__
- P_idir,
-#else
- P,
-#endif
- idir,
- near_x,
- near_y,
- near_z,
- far_x,
- far_y,
- far_z,
- node_addr,
- difl,
- dist);
- }
-}
diff --git a/intern/cycles/kernel/bvh/obvh_shadow_all.h b/intern/cycles/kernel/bvh/obvh_shadow_all.h
index 98efb003788..b7ab75b723c 100644
--- a/intern/cycles/kernel/bvh/obvh_shadow_all.h
+++ b/intern/cycles/kernel/bvh/obvh_shadow_all.h
@@ -431,7 +431,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
}
prim_addr++;
- } //while
+ } // while
}
else {
kernel_assert((kernel_tex_fetch(__prim_type, (prim_addr)) & PRIMITIVE_ALL) ==
@@ -503,10 +503,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
object,
prim_addr,
ray->time,
- curve_type,
- NULL,
- 0,
- 0);
+ curve_type);
}
else {
hit = curve_intersect(kg,
@@ -517,10 +514,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
object,
prim_addr,
ray->time,
- curve_type,
- NULL,
- 0,
- 0);
+ curve_type);
}
break;
}
@@ -574,7 +568,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
}
prim_addr++;
- } //while prim
+ } // while prim
}
}
#if BVH_FEATURE(BVH_INSTANCING)
diff --git a/intern/cycles/kernel/bvh/obvh_traversal.h b/intern/cycles/kernel/bvh/obvh_traversal.h
index 86b1de48aaa..9095233f8b6 100644
--- a/intern/cycles/kernel/bvh/obvh_traversal.h
+++ b/intern/cycles/kernel/bvh/obvh_traversal.h
@@ -20,29 +20,19 @@
*
* BVH_INSTANCING: object instancing
* BVH_HAIR: hair curve rendering
- * BVH_HAIR_MINIMUM_WIDTH: hair curve rendering with minimum width
* BVH_MOTION: motion blur rendering
*/
#if BVH_FEATURE(BVH_HAIR)
# define NODE_INTERSECT obvh_node_intersect
-# define NODE_INTERSECT_ROBUST obvh_node_intersect_robust
#else
# define NODE_INTERSECT obvh_aligned_node_intersect
-# define NODE_INTERSECT_ROBUST obvh_aligned_node_intersect_robust
#endif
ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
const Ray *ray,
Intersection *isect,
- const uint visibility
-#if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH)
- ,
- uint *lcg_state,
- float difl,
- float extmax
-#endif
-)
+ const uint visibility)
{
/* Traversal stack in CUDA thread-local memory. */
OBVHStackItem traversal_stack[BVH_OSTACK_SIZE];
@@ -117,38 +107,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
BVH_DEBUG_NEXT_NODE();
-#if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH)
- if (difl != 0.0f) {
- /* NOTE: We extend all the child BB instead of fetching
- * and checking visibility flags for each of the,
- *
- * Need to test if doing opposite would be any faster.
- */
- child_mask = NODE_INTERSECT_ROBUST(kg,
- tnear,
- tfar,
-# ifdef __KERNEL_AVX2__
- P_idir4,
-# endif
-# if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
- org4,
-# endif
-# if BVH_FEATURE(BVH_HAIR)
- dir4,
-# endif
- idir4,
- near_x,
- near_y,
- near_z,
- far_x,
- far_y,
- far_z,
- node_addr,
- difl,
- &dist);
- }
- else
-#endif /* BVH_HAIR_MINIMUM_WIDTH */
{
child_mask = NODE_INTERSECT(kg,
tnear,
@@ -375,8 +333,8 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
}
/* Eight children are hit, push all onto stack and sort 8
- * stack items, continue with closest child.
- */
+ * stack items, continue with closest child.
+ */
r = __bscf(child_mask);
int c7 = __float_as_int(cnodes[r]);
float d7 = ((float *)&dist)[r];
@@ -451,7 +409,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
return true;
}
}
- } //for
+ } // for
}
else {
kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
@@ -472,7 +430,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
return true;
}
}
- } //prim count
+ } // prim count
break;
}
#if BVH_FEATURE(BVH_MOTION)
@@ -501,32 +459,12 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL));
bool hit;
if (kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) {
- hit = cardinal_curve_intersect(kg,
- isect,
- P,
- dir,
- visibility,
- object,
- prim_addr,
- ray->time,
- curve_type,
- lcg_state,
- difl,
- extmax);
+ hit = cardinal_curve_intersect(
+ kg, isect, P, dir, visibility, object, prim_addr, ray->time, curve_type);
}
else {
- hit = curve_intersect(kg,
- isect,
- P,
- dir,
- visibility,
- object,
- prim_addr,
- ray->time,
- curve_type,
- lcg_state,
- difl,
- extmax);
+ hit = curve_intersect(
+ kg, isect, P, dir, visibility, object, prim_addr, ray->time, curve_type);
}
if (hit) {
tfar = avxf(isect->t);
@@ -617,4 +555,3 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg,
}
#undef NODE_INTERSECT
-#undef NODE_INTERSECT_ROBUST
diff --git a/intern/cycles/kernel/bvh/qbvh_nodes.h b/intern/cycles/kernel/bvh/qbvh_nodes.h
index 7c1d8c8c72e..070406fb18a 100644
--- a/intern/cycles/kernel/bvh/qbvh_nodes.h
+++ b/intern/cycles/kernel/bvh/qbvh_nodes.h
@@ -127,7 +127,7 @@ ccl_device_inline void qbvh_stack_sort(QBVHStackItem *ccl_restrict s1,
/* Axis-aligned nodes intersection */
-//ccl_device_inline int qbvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg,
+// ccl_device_inline int qbvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg,
static int qbvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg,
const ssef &isect_near,
const ssef &isect_far,
@@ -181,51 +181,6 @@ static int qbvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg,
return mask;
}
-ccl_device_inline int qbvh_aligned_node_intersect_robust(KernelGlobals *ccl_restrict kg,
- const ssef &isect_near,
- const ssef &isect_far,
-#ifdef __KERNEL_AVX2__
- const sse3f &P_idir,
-#else
- const sse3f &P,
-#endif
- const sse3f &idir,
- const int near_x,
- const int near_y,
- const int near_z,
- const int far_x,
- const int far_y,
- const int far_z,
- const int node_addr,
- const float difl,
- ssef *ccl_restrict dist)
-{
- const int offset = node_addr + 1;
-#ifdef __KERNEL_AVX2__
- const ssef tnear_x = msub(kernel_tex_fetch_ssef(__bvh_nodes, offset + near_x), idir.x, P_idir.x);
- const ssef tnear_y = msub(kernel_tex_fetch_ssef(__bvh_nodes, offset + near_y), idir.y, P_idir.y);
- const ssef tnear_z = msub(kernel_tex_fetch_ssef(__bvh_nodes, offset + near_z), idir.z, P_idir.z);
- const ssef tfar_x = msub(kernel_tex_fetch_ssef(__bvh_nodes, offset + far_x), idir.x, P_idir.x);
- const ssef tfar_y = msub(kernel_tex_fetch_ssef(__bvh_nodes, offset + far_y), idir.y, P_idir.y);
- const ssef tfar_z = msub(kernel_tex_fetch_ssef(__bvh_nodes, offset + far_z), idir.z, P_idir.z);
-#else
- const ssef tnear_x = (kernel_tex_fetch_ssef(__bvh_nodes, offset + near_x) - P.x) * idir.x;
- const ssef tnear_y = (kernel_tex_fetch_ssef(__bvh_nodes, offset + near_y) - P.y) * idir.y;
- const ssef tnear_z = (kernel_tex_fetch_ssef(__bvh_nodes, offset + near_z) - P.z) * idir.z;
- const ssef tfar_x = (kernel_tex_fetch_ssef(__bvh_nodes, offset + far_x) - P.x) * idir.x;
- const ssef tfar_y = (kernel_tex_fetch_ssef(__bvh_nodes, offset + far_y) - P.y) * idir.y;
- const ssef tfar_z = (kernel_tex_fetch_ssef(__bvh_nodes, offset + far_z) - P.z) * idir.z;
-#endif
-
- const float round_down = 1.0f - difl;
- const float round_up = 1.0f + difl;
- const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
- const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
- const sseb vmask = round_down * tnear <= round_up * tfar;
- *dist = tnear;
- return (int)movemask(vmask);
-}
-
/* Unaligned nodes intersection */
ccl_device_inline int qbvh_unaligned_node_intersect(KernelGlobals *ccl_restrict kg,
@@ -308,85 +263,6 @@ ccl_device_inline int qbvh_unaligned_node_intersect(KernelGlobals *ccl_restrict
#endif
}
-ccl_device_inline int qbvh_unaligned_node_intersect_robust(KernelGlobals *ccl_restrict kg,
- const ssef &isect_near,
- const ssef &isect_far,
-#ifdef __KERNEL_AVX2__
- const sse3f &P_idir,
-#endif
- const sse3f &P,
- const sse3f &dir,
- const sse3f &idir,
- const int near_x,
- const int near_y,
- const int near_z,
- const int far_x,
- const int far_y,
- const int far_z,
- const int node_addr,
- const float difl,
- ssef *ccl_restrict dist)
-{
- const int offset = node_addr;
- const ssef tfm_x_x = kernel_tex_fetch_ssef(__bvh_nodes, offset + 1);
- const ssef tfm_x_y = kernel_tex_fetch_ssef(__bvh_nodes, offset + 2);
- const ssef tfm_x_z = kernel_tex_fetch_ssef(__bvh_nodes, offset + 3);
-
- const ssef tfm_y_x = kernel_tex_fetch_ssef(__bvh_nodes, offset + 4);
- const ssef tfm_y_y = kernel_tex_fetch_ssef(__bvh_nodes, offset + 5);
- const ssef tfm_y_z = kernel_tex_fetch_ssef(__bvh_nodes, offset + 6);
-
- const ssef tfm_z_x = kernel_tex_fetch_ssef(__bvh_nodes, offset + 7);
- const ssef tfm_z_y = kernel_tex_fetch_ssef(__bvh_nodes, offset + 8);
- const ssef tfm_z_z = kernel_tex_fetch_ssef(__bvh_nodes, offset + 9);
-
- const ssef tfm_t_x = kernel_tex_fetch_ssef(__bvh_nodes, offset + 10);
- const ssef tfm_t_y = kernel_tex_fetch_ssef(__bvh_nodes, offset + 11);
- const ssef tfm_t_z = kernel_tex_fetch_ssef(__bvh_nodes, offset + 12);
-
- const ssef aligned_dir_x = dir.x * tfm_x_x + dir.y * tfm_x_y + dir.z * tfm_x_z,
- aligned_dir_y = dir.x * tfm_y_x + dir.y * tfm_y_y + dir.z * tfm_y_z,
- aligned_dir_z = dir.x * tfm_z_x + dir.y * tfm_z_y + dir.z * tfm_z_z;
-
- const ssef aligned_P_x = P.x * tfm_x_x + P.y * tfm_x_y + P.z * tfm_x_z + tfm_t_x,
- aligned_P_y = P.x * tfm_y_x + P.y * tfm_y_y + P.z * tfm_y_z + tfm_t_y,
- aligned_P_z = P.x * tfm_z_x + P.y * tfm_z_y + P.z * tfm_z_z + tfm_t_z;
-
- const ssef neg_one(-1.0f, -1.0f, -1.0f, -1.0f);
- const ssef nrdir_x = neg_one / aligned_dir_x, nrdir_y = neg_one / aligned_dir_y,
- nrdir_z = neg_one / aligned_dir_z;
-
- const ssef tlower_x = aligned_P_x * nrdir_x, tlower_y = aligned_P_y * nrdir_y,
- tlower_z = aligned_P_z * nrdir_z;
-
- const ssef tupper_x = tlower_x - nrdir_x, tupper_y = tlower_y - nrdir_y,
- tupper_z = tlower_z - nrdir_z;
-
- const float round_down = 1.0f - difl;
- const float round_up = 1.0f + difl;
-
-#ifdef __KERNEL_SSE41__
- const ssef tnear_x = mini(tlower_x, tupper_x);
- const ssef tnear_y = mini(tlower_y, tupper_y);
- const ssef tnear_z = mini(tlower_z, tupper_z);
- const ssef tfar_x = maxi(tlower_x, tupper_x);
- const ssef tfar_y = maxi(tlower_y, tupper_y);
- const ssef tfar_z = maxi(tlower_z, tupper_z);
-#else
- const ssef tnear_x = min(tlower_x, tupper_x);
- const ssef tnear_y = min(tlower_y, tupper_y);
- const ssef tnear_z = min(tlower_z, tupper_z);
- const ssef tfar_x = max(tlower_x, tupper_x);
- const ssef tfar_y = max(tlower_y, tupper_y);
- const ssef tfar_z = max(tlower_z, tupper_z);
-#endif
- const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
- const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
- const sseb vmask = round_down * tnear <= round_up * tfar;
- *dist = tnear;
- return movemask(vmask);
-}
-
/* Intersectors wrappers.
*
* They'll check node type and call appropriate intersection code.
@@ -451,66 +327,3 @@ ccl_device_inline int qbvh_node_intersect(KernelGlobals *ccl_restrict kg,
dist);
}
}
-
-ccl_device_inline int qbvh_node_intersect_robust(KernelGlobals *ccl_restrict kg,
- const ssef &isect_near,
- const ssef &isect_far,
-#ifdef __KERNEL_AVX2__
- const sse3f &P_idir,
-#endif
- const sse3f &P,
- const sse3f &dir,
- const sse3f &idir,
- const int near_x,
- const int near_y,
- const int near_z,
- const int far_x,
- const int far_y,
- const int far_z,
- const int node_addr,
- const float difl,
- ssef *ccl_restrict dist)
-{
- const int offset = node_addr;
- const float4 node = kernel_tex_fetch(__bvh_nodes, offset);
- if (__float_as_uint(node.x) & PATH_RAY_NODE_UNALIGNED) {
- return qbvh_unaligned_node_intersect_robust(kg,
- isect_near,
- isect_far,
-#ifdef __KERNEL_AVX2__
- P_idir,
-#endif
- P,
- dir,
- idir,
- near_x,
- near_y,
- near_z,
- far_x,
- far_y,
- far_z,
- node_addr,
- difl,
- dist);
- }
- else {
- return qbvh_aligned_node_intersect_robust(kg,
- isect_near,
- isect_far,
-#ifdef __KERNEL_AVX2__
- P_idir,
-#else
- P,
-#endif
- idir,
- near_x,
- near_y,
- near_z,
- far_x,
- far_y,
- far_z,
- node_addr,
- difl,
- dist);
- }
-}
diff --git a/intern/cycles/kernel/bvh/qbvh_shadow_all.h b/intern/cycles/kernel/bvh/qbvh_shadow_all.h
index 49e607bfbd0..682251bf25b 100644
--- a/intern/cycles/kernel/bvh/qbvh_shadow_all.h
+++ b/intern/cycles/kernel/bvh/qbvh_shadow_all.h
@@ -37,7 +37,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
uint *num_hits)
{
/* TODO(sergey):
- * - Test if pushing distance on the stack helps.
+ * - Test if pushing distance on the stack helps.
* - Likely and unlikely for if() statements.
* - Test restrict attribute for pointers.
*/
@@ -293,10 +293,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
object,
prim_addr,
ray->time,
- curve_type,
- NULL,
- 0,
- 0);
+ curve_type);
}
else {
hit = curve_intersect(kg,
@@ -307,10 +304,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
object,
prim_addr,
ray->time,
- curve_type,
- NULL,
- 0,
- 0);
+ curve_type);
}
break;
}
diff --git a/intern/cycles/kernel/bvh/qbvh_traversal.h b/intern/cycles/kernel/bvh/qbvh_traversal.h
index 9ee0f7b5933..f43e84bf368 100644
--- a/intern/cycles/kernel/bvh/qbvh_traversal.h
+++ b/intern/cycles/kernel/bvh/qbvh_traversal.h
@@ -20,29 +20,19 @@
*
* BVH_INSTANCING: object instancing
* BVH_HAIR: hair curve rendering
- * BVH_HAIR_MINIMUM_WIDTH: hair curve rendering with minimum width
* BVH_MOTION: motion blur rendering
*/
#if BVH_FEATURE(BVH_HAIR)
# define NODE_INTERSECT qbvh_node_intersect
-# define NODE_INTERSECT_ROBUST qbvh_node_intersect_robust
#else
# define NODE_INTERSECT qbvh_aligned_node_intersect
-# define NODE_INTERSECT_ROBUST qbvh_aligned_node_intersect_robust
#endif
ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
const Ray *ray,
Intersection *isect,
- const uint visibility
-#if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH)
- ,
- uint *lcg_state,
- float difl,
- float extmax
-#endif
-)
+ const uint visibility)
{
/* TODO(sergey):
* - Test if pushing distance on the stack helps (for non shadow rays).
@@ -126,38 +116,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
BVH_DEBUG_NEXT_NODE();
-#if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH)
- if (difl != 0.0f) {
- /* NOTE: We extend all the child BB instead of fetching
- * and checking visibility flags for each of the,
- *
- * Need to test if doing opposite would be any faster.
- */
- child_mask = NODE_INTERSECT_ROBUST(kg,
- tnear,
- tfar,
-# ifdef __KERNEL_AVX2__
- P_idir4,
-# endif
-# if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__)
- org4,
-# endif
-# if BVH_FEATURE(BVH_HAIR)
- dir4,
-# endif
- idir4,
- near_x,
- near_y,
- near_z,
- far_x,
- far_y,
- far_z,
- node_addr,
- difl,
- &dist);
- }
- else
-#endif /* BVH_HAIR_MINIMUM_WIDTH */
{
child_mask = NODE_INTERSECT(kg,
tnear,
@@ -364,32 +322,12 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL));
bool hit;
if (kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) {
- hit = cardinal_curve_intersect(kg,
- isect,
- P,
- dir,
- visibility,
- object,
- prim_addr,
- ray->time,
- curve_type,
- lcg_state,
- difl,
- extmax);
+ hit = cardinal_curve_intersect(
+ kg, isect, P, dir, visibility, object, prim_addr, ray->time, curve_type);
}
else {
- hit = curve_intersect(kg,
- isect,
- P,
- dir,
- visibility,
- object,
- prim_addr,
- ray->time,
- curve_type,
- lcg_state,
- difl,
- extmax);
+ hit = curve_intersect(
+ kg, isect, P, dir, visibility, object, prim_addr, ray->time, curve_type);
}
if (hit) {
tfar = ssef(isect->t);
@@ -480,4 +418,3 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
}
#undef NODE_INTERSECT
-#undef NODE_INTERSECT_ROBUST
diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
index b3b1c37748d..6495ae743ab 100644
--- a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
+++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
@@ -85,15 +85,11 @@ ccl_device_forceinline float3 bsdf_ashikhmin_shirley_eval_reflect(const ShaderCl
float HdotI = fmaxf(fabsf(dot(H, I)), 1e-6f);
float HdotN = fmaxf(dot(H, N), 1e-6f);
- float pump =
- 1.0f /
- fmaxf(
- 1e-6f,
- (HdotI *
- fmaxf(
- NdotO,
- NdotI))); /* pump from original paper (first derivative disc., but cancels the HdotI in the pdf nicely) */
- /*float pump = 1.0f / fmaxf(1e-4f, ((NdotO + NdotI) * (NdotO*NdotI))); */ /* pump from d-brdf paper */
+ /* pump from original paper
+ * (first derivative disc., but cancels the HdotI in the pdf nicely) */
+ float pump = 1.0f / fmaxf(1e-6f, (HdotI * fmaxf(NdotO, NdotI)));
+ /* pump from d-brdf paper */
+ /*float pump = 1.0f / fmaxf(1e-4f, ((NdotO + NdotI) * (NdotO*NdotI))); */
float n_x = bsdf_ashikhmin_shirley_roughness_to_exponent(bsdf->alpha_x);
float n_y = bsdf_ashikhmin_shirley_roughness_to_exponent(bsdf->alpha_y);
@@ -105,9 +101,8 @@ ccl_device_forceinline float3 bsdf_ashikhmin_shirley_eval_reflect(const ShaderCl
float norm = (n_x + 1.0f) / (8.0f * M_PI_F);
out = NdotO * norm * lobe * pump;
- *pdf =
- norm * lobe /
- HdotI; /* this is p_h / 4(H.I) (conversion from 'wh measure' to 'wi measure', eq. 8 in paper) */
+ /* this is p_h / 4(H.I) (conversion from 'wh measure' to 'wi measure', eq. 8 in paper). */
+ *pdf = norm * lobe / HdotI;
}
else {
/* anisotropic */
diff --git a/intern/cycles/kernel/closure/bsdf_hair.h b/intern/cycles/kernel/closure/bsdf_hair.h
index 6b2a9a97d30..4b6f5b3b439 100644
--- a/intern/cycles/kernel/closure/bsdf_hair.h
+++ b/intern/cycles/kernel/closure/bsdf_hair.h
@@ -224,7 +224,7 @@ ccl_device int bsdf_hair_reflection_sample(const ShaderClosure *sc,
fast_sincosf(phi, &sinphi, &cosphi);
*omega_in = (cosphi * costheta_i) * locy - (sinphi * costheta_i) * locx + (sintheta_i)*Tg;
- //differentials - TODO: find a better approximation for the reflective bounce
+ // differentials - TODO: find a better approximation for the reflective bounce
#ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = 2 * dot(locy, dIdx) * locy - dIdx;
*domega_in_dy = 2 * dot(locy, dIdy) * locy - dIdy;
@@ -285,7 +285,7 @@ ccl_device int bsdf_hair_transmission_sample(const ShaderClosure *sc,
fast_sincosf(phi, &sinphi, &cosphi);
*omega_in = (cosphi * costheta_i) * locy - (sinphi * costheta_i) * locx + (sintheta_i)*Tg;
- //differentials - TODO: find a better approximation for the transmission bounce
+ // differentials - TODO: find a better approximation for the transmission bounce
#ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = 2 * dot(locy, dIdx) * locy - dIdx;
*domega_in_dy = 2 * dot(locy, dIdy) * locy - dIdy;
diff --git a/intern/cycles/kernel/closure/bsdf_hair_principled.h b/intern/cycles/kernel/closure/bsdf_hair_principled.h
index a4bba2fbf6c..4db5a6cc830 100644
--- a/intern/cycles/kernel/closure/bsdf_hair_principled.h
+++ b/intern/cycles/kernel/closure/bsdf_hair_principled.h
@@ -60,7 +60,8 @@ ccl_device_inline float cos_from_sin(const float s)
return safe_sqrtf(1.0f - s * s);
}
-/* Gives the change in direction in the normal plane for the given angles and p-th-order scattering. */
+/* Gives the change in direction in the normal plane for the given angles and p-th-order
+ * scattering. */
ccl_device_inline float delta_phi(int p, float gamma_o, float gamma_t)
{
return 2.0f * p * gamma_t - 2.0f * gamma_o + p * M_PI_F;
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet_multi.h b/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
index 2cc1a9c5299..07be33ee6b5 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
@@ -16,7 +16,8 @@
CCL_NAMESPACE_BEGIN
-/* Most of the code is based on the supplemental implementations from https://eheitzresearch.wordpress.com/240-2/. */
+/* Most of the code is based on the supplemental implementations from
+ * https://eheitzresearch.wordpress.com/240-2/. */
/* === GGX Microfacet distribution functions === */
@@ -80,7 +81,8 @@ ccl_device_forceinline float2 mf_sampleP22_11(const float cosI,
return make_float2(slopeX, -slopeY);
}
-/* Visible normal sampling for the GGX distribution (based on page 7 of the supplemental implementation). */
+/* Visible normal sampling for the GGX distribution
+ * (based on page 7 of the supplemental implementation). */
ccl_device_forceinline float3 mf_sample_vndf(const float3 wi,
const float2 alpha,
const float randx,
@@ -134,7 +136,8 @@ ccl_device_forceinline float3 mf_eval_phase_glossy(const float3 w,
return make_float3(phase, phase, phase);
}
-/* Phase function for dielectric transmissive materials, including both reflection and refraction according to the dielectric fresnel term. */
+/* Phase function for dielectric transmissive materials, including both reflection and refraction
+ * according to the dielectric fresnel term. */
ccl_device_forceinline float3 mf_sample_phase_glass(
const float3 wi, const float eta, const float3 wm, const float randV, bool *outside)
{
@@ -227,7 +230,8 @@ ccl_device_forceinline float mf_G1(const float3 w, const float C1, const float l
return powf(C1, lambda);
}
-/* Sampling from the visible height distribution (based on page 17 of the supplemental implementation). */
+/* Sampling from the visible height distribution (based on page 17 of the supplemental
+ * implementation). */
ccl_device_forceinline bool mf_sample_height(
const float3 w, float *h, float *C1, float *G1, float *lambda, const float U)
{
@@ -254,7 +258,8 @@ ccl_device_forceinline bool mf_sample_height(
}
/* === PDF approximations for the different phase functions. ===
- * As explained in bsdf_microfacet_multi_impl.h, using approximations with MIS still produces an unbiased result. */
+ * As explained in bsdf_microfacet_multi_impl.h, using approximations with MIS still produces an
+ * unbiased result. */
/* Approximation for the albedo of the single-scattering GGX distribution,
* the missing energy is then approximated as a diffuse reflection for the PDF. */
@@ -342,7 +347,8 @@ ccl_device_forceinline float mf_glass_pdf(const float3 wi,
}
}
-/* === Actual random walk implementations, one version of mf_eval and mf_sample per phase function. === */
+/* === Actual random walk implementations === */
+/* One version of mf_eval and mf_sample per phase function. */
#define MF_NAME_JOIN(x, y) x##_##y
#define MF_NAME_EVAL(x, y) MF_NAME_JOIN(x, y)
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h b/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h
index 79247ee8057..04d9b22d7d2 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h
@@ -16,14 +16,14 @@
/* Evaluate the BSDF from wi to wo.
* Evaluation is split into the analytical single-scattering BSDF and the multi-scattering BSDF,
- * which is evaluated stochastically through a random walk. At each bounce (except for the first one),
- * the amount of reflection from here towards wo is evaluated before bouncing again.
+ * which is evaluated stochastically through a random walk. At each bounce (except for the first
+ * one), the amount of reflection from here towards wo is evaluated before bouncing again.
*
- * Because of the random walk, the evaluation is not deterministic, but its expected value is equal to
- * the correct BSDF, which is enough for Monte-Carlo rendering. The PDF also can't be determined
- * analytically, so the single-scattering PDF plus a diffuse term to account for the multi-scattered
- * energy is used. In combination with MIS, that is enough to produce an unbiased result, although
- * the balance heuristic isn't necessarily optimal anymore.
+ * Because of the random walk, the evaluation is not deterministic, but its expected value is equal
+ * to the correct BSDF, which is enough for Monte-Carlo rendering. The PDF also can't be determined
+ * analytically, so the single-scattering PDF plus a diffuse term to account for the
+ * multi-scattered energy is used. In combination with MIS, that is enough to produce an unbiased
+ * result, although the balance heuristic isn't necessarily optimal anymore.
*/
ccl_device_forceinline float3 MF_FUNCTION_FULL_NAME(mf_eval)(float3 wi,
float3 wo,
@@ -36,7 +36,8 @@ ccl_device_forceinline float3 MF_FUNCTION_FULL_NAME(mf_eval)(float3 wi,
bool use_fresnel,
const float3 cspec0)
{
- /* Evaluating for a shallower incoming direction produces less noise, and the properties of the BSDF guarantee reciprocity. */
+ /* Evaluating for a shallower incoming direction produces less noise, and the properties of the
+ * BSDF guarantee reciprocity. */
bool swapped = false;
#ifdef MF_MULTI_GLASS
if (wi.z * wo.z < 0.0f) {
@@ -180,9 +181,9 @@ ccl_device_forceinline float3 MF_FUNCTION_FULL_NAME(mf_eval)(float3 wi,
return eval;
}
-/* Perform a random walk on the microsurface starting from wi, returning the direction in which the walk
- * escaped the surface in wo. The function returns the throughput between wi and wo.
- * Without reflection losses due to coloring or fresnel absorption in conductors, the sampling is optimal.
+/* Perform a random walk on the microsurface starting from wi, returning the direction in which the
+ * walk escaped the surface in wo. The function returns the throughput between wi and wo. Without
+ * reflection losses due to coloring or fresnel absorption in conductors, the sampling is optimal.
*/
ccl_device_forceinline float3 MF_FUNCTION_FULL_NAME(mf_sample)(float3 wi,
float3 *wo,
diff --git a/intern/cycles/kernel/closure/bsdf_util.h b/intern/cycles/kernel/closure/bsdf_util.h
index a9a27edd7de..3bce47caedb 100644
--- a/intern/cycles/kernel/closure/bsdf_util.h
+++ b/intern/cycles/kernel/closure/bsdf_util.h
@@ -155,7 +155,7 @@ interpolate_fresnel_color(float3 L, float3 H, float ior, float F0, float3 cspec0
/* Calculate the fresnel interpolation factor
* The value from fresnel_dielectric_cos(...) has to be normalized because
* the cspec0 keeps the F0 color
- */
+ */
float F0_norm = 1.0f / (1.0f - F0);
float FH = (fresnel_dielectric_cos(dot(L, H), ior) - F0) * F0_norm;
diff --git a/intern/cycles/kernel/closure/bssrdf.h b/intern/cycles/kernel/closure/bssrdf.h
index 57804eca269..a7d9f90b443 100644
--- a/intern/cycles/kernel/closure/bssrdf.h
+++ b/intern/cycles/kernel/closure/bssrdf.h
@@ -450,7 +450,8 @@ ccl_device void bssrdf_sample(const ShaderClosure *sc, float xi, float *r, float
else if (bssrdf->type == CLOSURE_BSSRDF_GAUSSIAN_ID) {
bssrdf_gaussian_sample(radius, xi, r, h);
}
- else { /*if(bssrdf->type == CLOSURE_BSSRDF_BURLEY_ID || bssrdf->type == CLOSURE_BSSRDF_PRINCIPLED_ID)*/
+ else { /* if (bssrdf->type == CLOSURE_BSSRDF_BURLEY_ID ||
+ * bssrdf->type == CLOSURE_BSSRDF_PRINCIPLED_ID) */
bssrdf_burley_sample(radius, xi, r, h);
}
}
@@ -466,7 +467,8 @@ ccl_device float bssrdf_channel_pdf(const Bssrdf *bssrdf, float radius, float r)
else if (bssrdf->type == CLOSURE_BSSRDF_GAUSSIAN_ID) {
return bssrdf_gaussian_pdf(radius, r);
}
- else { /*if(bssrdf->type == CLOSURE_BSSRDF_BURLEY_ID || bssrdf->type == CLOSURE_BSSRDF_PRINCIPLED_ID)*/
+ else { /* if (bssrdf->type == CLOSURE_BSSRDF_BURLEY_ID ||
+ * bssrdf->type == CLOSURE_BSSRDF_PRINCIPLED_ID)*/
return bssrdf_burley_pdf(radius, r);
}
}
diff --git a/intern/cycles/kernel/filter/filter_features.h b/intern/cycles/kernel/filter/filter_features.h
index 809ccfe8be6..8a2af957146 100644
--- a/intern/cycles/kernel/filter/filter_features.h
+++ b/intern/cycles/kernel/filter/filter_features.h
@@ -18,8 +18,9 @@ CCL_NAMESPACE_BEGIN
#define ccl_get_feature(buffer, pass) (buffer)[(pass)*pass_stride]
-/* Loop over the pixels in the range [low.x, high.x) x [low.y, high.y).+ * pixel_buffer always points to the current pixel in the first pass.
- * Repeat the loop for every secondary frame if there are any. */
+/* Loop over the pixels in the range [low.x, high.x) x [low.y, high.y).+ * pixel_buffer always
+ * points to the current pixel in the first pass. Repeat the loop for every secondary frame if
+ * there are any. */
#define FOR_PIXEL_WINDOW \
for (int frame = 0; frame < tile_info->num_frames; frame++) { \
pixel.z = tile_info->frames[frame]; \
diff --git a/intern/cycles/kernel/filter/filter_features_sse.h b/intern/cycles/kernel/filter/filter_features_sse.h
index 1e0d6e93453..7bbd17066fd 100644
--- a/intern/cycles/kernel/filter/filter_features_sse.h
+++ b/intern/cycles/kernel/filter/filter_features_sse.h
@@ -20,8 +20,8 @@ CCL_NAMESPACE_BEGIN
/* Loop over the pixels in the range [low.x, high.x) x [low.y, high.y), 4 at a time.
* pixel_buffer always points to the first of the 4 current pixel in the first pass.
- * x4 and y4 contain the coordinates of the four pixels, active_pixels contains a mask that's set for all pixels within the window.
- * Repeat the loop for every secondary frame if there are any. */
+ * x4 and y4 contain the coordinates of the four pixels, active_pixels contains a mask that's set
+ * for all pixels within the window. Repeat the loop for every secondary frame if there are any. */
#define FOR_PIXEL_WINDOW_SSE \
for (int frame = 0; frame < tile_info->num_frames; frame++) { \
pixel.z = tile_info->frames[frame]; \
diff --git a/intern/cycles/kernel/filter/filter_nlm_cpu.h b/intern/cycles/kernel/filter/filter_nlm_cpu.h
index a94266a8786..24200c29203 100644
--- a/intern/cycles/kernel/filter/filter_nlm_cpu.h
+++ b/intern/cycles/kernel/filter/filter_nlm_cpu.h
@@ -197,7 +197,8 @@ ccl_device_inline void kernel_filter_nlm_construct_gramian(int dx,
bool use_time)
{
int4 clip_area = rect_clip(rect, filter_window);
- /* fy and fy are in filter-window-relative coordinates, while x and y are in feature-window-relative coordinates. */
+ /* fy and fy are in filter-window-relative coordinates,
+ * while x and y are in feature-window-relative coordinates. */
for (int y = clip_area.y; y < clip_area.w; y++) {
for (int x = clip_area.x; x < clip_area.z; x++) {
const int low = max(rect.x, x - f);
diff --git a/intern/cycles/kernel/filter/filter_prefilter.h b/intern/cycles/kernel/filter/filter_prefilter.h
index 8211311313d..b48a3f3f68b 100644
--- a/intern/cycles/kernel/filter/filter_prefilter.h
+++ b/intern/cycles/kernel/filter/filter_prefilter.h
@@ -16,14 +16,19 @@
CCL_NAMESPACE_BEGIN
-/* First step of the shadow prefiltering, performs the shadow division and stores all data
+/**
+ * First step of the shadow prefiltering, performs the shadow division and stores all data
* in a nice and easy rectangular array that can be passed to the NLM filter.
*
* Calculates:
- * unfiltered: Contains the two half images of the shadow feature pass
- * sampleVariance: The sample-based variance calculated in the kernel. Note: This calculation is biased in general, and especially here since the variance of the ratio can only be approximated.
- * sampleVarianceV: Variance of the sample variance estimation, quite noisy (since it's essentially the buffer variance of the two variance halves)
- * bufferVariance: The buffer-based variance of the shadow feature. Unbiased, but quite noisy.
+ * \param unfiltered: Contains the two half images of the shadow feature pass
+ * \param sampleVariance: The sample-based variance calculated in the kernel.
+ * Note: This calculation is biased in general,
+ * and especially here since the variance of the ratio can only be approximated.
+ * \param sampleVarianceV: Variance of the sample variance estimation, quite noisy
+ * (since it's essentially the buffer variance of the two variance halves)
+ * \param bufferVariance: The buffer-based variance of the shadow feature.
+ * Unbiased, but quite noisy.
*/
ccl_device void kernel_filter_divide_shadow(int sample,
CCL_FILTER_TILE_INFO,
@@ -204,10 +209,10 @@ ccl_device void kernel_filter_detect_outliers(int x,
if (L > ref) {
/* The pixel appears to be an outlier.
- * However, it may just be a legitimate highlight. Therefore, it is checked how likely it is that the pixel
- * should actually be at the reference value:
- * If the reference is within the 3-sigma interval, the pixel is assumed to be a statistical outlier.
- * Otherwise, it is very unlikely that the pixel should be darker, which indicates a legitimate highlight.
+ * However, it may just be a legitimate highlight. Therefore, it is checked how likely it is
+ * that the pixel should actually be at the reference value: If the reference is within the
+ * 3-sigma interval, the pixel is assumed to be a statistical outlier. Otherwise, it is very
+ * unlikely that the pixel should be darker, which indicates a legitimate highlight.
*/
if (pixel_variance < 0.0f || pixel_variance > 9.0f * max_variance) {
@@ -219,7 +224,8 @@ ccl_device void kernel_filter_detect_outliers(int x,
float stddev = sqrtf(pixel_variance);
if (L - 3 * stddev < ref) {
/* The pixel is an outlier, so negate the depth value to mark it as one.
- * Also, scale its brightness down to the outlier threshold to avoid trouble with the NLM weights. */
+ * Also, scale its brightness down to the outlier threshold to avoid trouble with the NLM
+ * weights. */
depth[idx] = -depth[idx];
float fac = ref / L;
color *= fac;
diff --git a/intern/cycles/kernel/filter/filter_transform.h b/intern/cycles/kernel/filter/filter_transform.h
index 69e3c7c458d..585c4b33787 100644
--- a/intern/cycles/kernel/filter/filter_transform.h
+++ b/intern/cycles/kernel/filter/filter_transform.h
@@ -55,7 +55,8 @@ ccl_device void kernel_filter_construct_transform(const float *ccl_restrict buff
math_vector_scale(feature_means, 1.0f / num_pixels, num_features);
- /* === Scale the shifted feature passes to a range of [-1; 1], will be baked into the transform later. === */
+ /* === Scale the shifted feature passes to a range of [-1; 1] ===
+ * Will be baked into the transform later. */
float feature_scale[DENOISE_FEATURES];
math_vector_zero(feature_scale, num_features);
@@ -69,8 +70,9 @@ ccl_device void kernel_filter_construct_transform(const float *ccl_restrict buff
filter_calculate_scale(feature_scale, use_time);
/* === Generate the feature transformation. ===
- * This transformation maps the num_features-dimentional feature space to a reduced feature (r-feature) space
- * which generally has fewer dimensions. This mainly helps to prevent overfitting. */
+ * This transformation maps the num_features-dimentional feature space to a reduced feature
+ * (r-feature) space which generally has fewer dimensions. This mainly helps to prevent
+ * overfitting. */
float feature_matrix[DENOISE_FEATURES * DENOISE_FEATURES];
math_matrix_zero(feature_matrix, num_features);
FOR_PIXEL_WINDOW
diff --git a/intern/cycles/kernel/filter/filter_transform_gpu.h b/intern/cycles/kernel/filter/filter_transform_gpu.h
index 89cddfd927f..41bbadb621d 100644
--- a/intern/cycles/kernel/filter/filter_transform_gpu.h
+++ b/intern/cycles/kernel/filter/filter_transform_gpu.h
@@ -61,7 +61,8 @@ ccl_device void kernel_filter_construct_transform(const ccl_global float *ccl_re
math_vector_scale(feature_means, 1.0f / num_pixels, num_features);
- /* === Scale the shifted feature passes to a range of [-1; 1], will be baked into the transform later. === */
+ /* === Scale the shifted feature passes to a range of [-1; 1] ===
+ * Will be baked into the transform later. */
float feature_scale[DENOISE_FEATURES];
math_vector_zero(feature_scale, num_features);
@@ -75,8 +76,9 @@ ccl_device void kernel_filter_construct_transform(const ccl_global float *ccl_re
filter_calculate_scale(feature_scale, use_time);
/* === Generate the feature transformation. ===
- * This transformation maps the num_features-dimentional feature space to a reduced feature (r-feature) space
- * which generally has fewer dimensions. This mainly helps to prevent overfitting. */
+ * This transformation maps the num_features-dimentional feature space to a reduced feature
+ * (r-feature) space which generally has fewer dimensions. This mainly helps to prevent
+ * overfitting. */
float feature_matrix[DENOISE_FEATURES * DENOISE_FEATURES];
math_matrix_zero(feature_matrix, num_features);
FOR_PIXEL_WINDOW
diff --git a/intern/cycles/kernel/filter/filter_transform_sse.h b/intern/cycles/kernel/filter/filter_transform_sse.h
index 22397b292db..830444645d7 100644
--- a/intern/cycles/kernel/filter/filter_transform_sse.h
+++ b/intern/cycles/kernel/filter/filter_transform_sse.h
@@ -58,7 +58,8 @@ ccl_device void kernel_filter_construct_transform(const float *ccl_restrict buff
feature_means[i] = reduce_add(feature_means[i]) * pixel_scale;
}
- /* === Scale the shifted feature passes to a range of [-1; 1], will be baked into the transform later. === */
+ /* === Scale the shifted feature passes to a range of [-1; 1] ===
+ * Will be baked into the transform later. */
float4 feature_scale[DENOISE_FEATURES];
math_vector_zero_sse(feature_scale, num_features);
FOR_PIXEL_WINDOW_SSE
@@ -72,8 +73,9 @@ ccl_device void kernel_filter_construct_transform(const float *ccl_restrict buff
filter_calculate_scale_sse(feature_scale, use_time);
/* === Generate the feature transformation. ===
- * This transformation maps the num_features-dimentional feature space to a reduced feature (r-feature) space
- * which generally has fewer dimensions. This mainly helps to prevent overfitting. */
+ * This transformation maps the num_features-dimentional feature space to a reduced feature
+ * (r-feature) space which generally has fewer dimensions. This mainly helps to prevent
+ * overfitting. */
float4 feature_matrix_sse[DENOISE_FEATURES * DENOISE_FEATURES];
math_matrix_zero_sse(feature_matrix_sse, num_features);
FOR_PIXEL_WINDOW_SSE
diff --git a/intern/cycles/kernel/geom/geom_curve_intersect.h b/intern/cycles/kernel/geom/geom_curve_intersect.h
index 5fd277c2f99..0327ebf8890 100644
--- a/intern/cycles/kernel/geom/geom_curve_intersect.h
+++ b/intern/cycles/kernel/geom/geom_curve_intersect.h
@@ -34,10 +34,7 @@ ccl_device_forceinline bool cardinal_curve_intersect(KernelGlobals *kg,
int object,
int curveAddr,
float time,
- int type,
- uint *lcg_state,
- float difl,
- float extmax)
+ int type)
{
const bool is_curve_primitive = (type & PRIMITIVE_CURVE);
@@ -239,9 +236,6 @@ ccl_device_forceinline bool cardinal_curve_intersect(KernelGlobals *kg,
return false;
/* minimum width extension */
- float mw_extension = min(difl * fabsf(upper), extmax);
- float r_ext = mw_extension + r_curr;
-
float xextrem[4];
curvebounds(&lower,
&upper,
@@ -253,7 +247,7 @@ ccl_device_forceinline bool cardinal_curve_intersect(KernelGlobals *kg,
curve_coef[1].x,
curve_coef[2].x,
curve_coef[3].x);
- if (lower > r_ext || upper < -r_ext)
+ if (lower > r_curr || upper < -r_curr)
return false;
float yextrem[4];
@@ -267,7 +261,7 @@ ccl_device_forceinline bool cardinal_curve_intersect(KernelGlobals *kg,
curve_coef[1].y,
curve_coef[2].y,
curve_coef[3].y);
- if (lower > r_ext || upper < -r_ext)
+ if (lower > r_curr || upper < -r_curr)
return false;
/* setup recurrent loop */
@@ -340,12 +334,8 @@ ccl_device_forceinline bool cardinal_curve_intersect(KernelGlobals *kg,
float r2 = r_st + (r_en - r_st) * i_en;
r_curr = max(r1, r2);
- mw_extension = min(difl * fabsf(bmaxz), extmax);
- float r_ext = mw_extension + r_curr;
- float coverage = 1.0f;
-
- if (bminz - r_curr > isect->t || bmaxz + r_curr < epsilon || bminx > r_ext || bmaxx < -r_ext ||
- bminy > r_ext || bmaxy < -r_ext) {
+ if (bminz - r_curr > isect->t || bmaxz + r_curr < epsilon || bminx > r_curr ||
+ bmaxx < -r_curr || bminy > r_curr || bmaxy < -r_curr) {
/* the bounding box does not overlap the square centered at O */
tree += level;
level = tree & -tree;
@@ -404,31 +394,7 @@ ccl_device_forceinline bool cardinal_curve_intersect(KernelGlobals *kg,
continue;
}
- /* compute coverage */
- float r_ext = r_curr;
- coverage = 1.0f;
- if (difl != 0.0f) {
- mw_extension = min(difl * fabsf(bmaxz), extmax);
- r_ext = mw_extension + r_curr;
-# ifdef __KERNEL_SSE__
- const float3 p_curr_sq = p_curr * p_curr;
- const float3 dxxx(_mm_sqrt_ss(_mm_hadd_ps(p_curr_sq.m128, p_curr_sq.m128)));
- float d = dxxx.x;
-# else
- float d = sqrtf(p_curr.x * p_curr.x + p_curr.y * p_curr.y);
-# endif
- float d0 = d - r_curr;
- float d1 = d + r_curr;
- float inv_mw_extension = 1.0f / mw_extension;
- if (d0 >= 0)
- coverage = (min(d1 * inv_mw_extension, 1.0f) - min(d0 * inv_mw_extension, 1.0f)) *
- 0.5f;
- else // inside
- coverage = (min(d1 * inv_mw_extension, 1.0f) + min(-d0 * inv_mw_extension, 1.0f)) *
- 0.5f;
- }
-
- if (p_curr.x * p_curr.x + p_curr.y * p_curr.y >= r_ext * r_ext || p_curr.z <= epsilon ||
+ if (p_curr.x * p_curr.x + p_curr.y * p_curr.y >= r_curr * r_curr || p_curr.z <= epsilon ||
isect->t < p_curr.z) {
tree++;
level = tree & -tree;
@@ -436,41 +402,23 @@ ccl_device_forceinline bool cardinal_curve_intersect(KernelGlobals *kg,
}
t = p_curr.z;
-
- /* stochastic fade from minimum width */
- if (difl != 0.0f && lcg_state) {
- if (coverage != 1.0f && (lcg_step_float(lcg_state) > coverage))
- return hit;
- }
}
else {
float l = len(p_en - p_st);
- /* minimum width extension */
- float or1 = r1;
- float or2 = r2;
-
- if (difl != 0.0f) {
- mw_extension = min(len(p_st - P) * difl, extmax);
- or1 = r1 < mw_extension ? mw_extension : r1;
- mw_extension = min(len(p_en - P) * difl, extmax);
- or2 = r2 < mw_extension ? mw_extension : r2;
- }
- /* --- */
float invl = 1.0f / l;
float3 tg = (p_en - p_st) * invl;
- gd = (or2 - or1) * invl;
+ gd = (r2 - r1) * invl;
float difz = -dot(p_st, tg);
float cyla = 1.0f - (tg.z * tg.z * (1 + gd * gd));
float invcyla = 1.0f / cyla;
- float halfb = (-p_st.z - tg.z * (difz + gd * (difz * gd + or1)));
+ float halfb = (-p_st.z - tg.z * (difz + gd * (difz * gd + r1)));
float tcentre = -halfb * invcyla;
float zcentre = difz + (tg.z * tcentre);
float3 tdif = -p_st;
tdif.z += tcentre;
float tdifz = dot(tdif, tg);
- float tb = 2 * (tdif.z - tg.z * (tdifz + gd * (tdifz * gd + or1)));
- float tc = dot(tdif, tdif) - tdifz * tdifz * (1 + gd * gd) - or1 * or1 -
- 2 * or1 * tdifz * gd;
+ float tb = 2 * (tdif.z - tg.z * (tdifz + gd * (tdifz * gd + r1)));
+ float tc = dot(tdif, tdif) - tdifz * tdifz * (1 + gd * gd) - r1 * r1 - 2 * r1 * tdifz * gd;
float td = tb * tb - 4 * cyla * tc;
if (td < 0.0f) {
tree++;
@@ -507,16 +455,6 @@ ccl_device_forceinline bool cardinal_curve_intersect(KernelGlobals *kg,
w = saturate(w);
/* compute u on the curve segment */
u = i_st * (1 - w) + i_en * w;
-
- /* stochastic fade from minimum width */
- if (difl != 0.0f && lcg_state) {
- r_curr = r1 + (r2 - r1) * w;
- r_ext = or1 + (or2 - or1) * w;
- coverage = r_curr / r_ext;
-
- if (coverage != 1.0f && (lcg_step_float(lcg_state) > coverage))
- return hit;
- }
}
/* we found a new intersection */
@@ -556,10 +494,7 @@ ccl_device_forceinline bool curve_intersect(KernelGlobals *kg,
int object,
int curveAddr,
float time,
- int type,
- uint *lcg_state,
- float difl,
- float extmax)
+ int type)
{
/* define few macros to minimize code duplication for SSE */
# ifndef __KERNEL_SSE2__
@@ -600,23 +535,14 @@ ccl_device_forceinline bool curve_intersect(KernelGlobals *kg,
motion_curve_keys(kg, fobject, prim, time, k0, k1, P_curve);
}
- float or1 = P_curve[0].w;
- float or2 = P_curve[1].w;
+ float r1 = P_curve[0].w;
+ float r2 = P_curve[1].w;
float3 p1 = float4_to_float3(P_curve[0]);
float3 p2 = float4_to_float3(P_curve[1]);
/* minimum width extension */
- float r1 = or1;
- float r2 = or2;
float3 dif = P - p1;
float3 dif_second = P - p2;
- if (difl != 0.0f) {
- float pixelsize = min(len3(dif) * difl, extmax);
- r1 = or1 < pixelsize ? pixelsize : or1;
- pixelsize = min(len3(dif_second) * difl, extmax);
- r2 = or2 < pixelsize ? pixelsize : or2;
- }
- /* --- */
float3 p21_diff = p2 - p1;
float3 sphere_dif1 = (dif + dif_second) * 0.5f;
@@ -635,20 +561,10 @@ ccl_device_forceinline bool curve_intersect(KernelGlobals *kg,
motion_curve_keys(kg, fobject, prim, time, k0, k1, (float4 *)&P_curve);
}
- const ssef or12 = shuffle<3, 3, 3, 3>(P_curve[0], P_curve[1]);
-
- ssef r12 = or12;
+ ssef r12 = shuffle<3, 3, 3, 3>(P_curve[0], P_curve[1]);
const ssef vP = load4f(P);
const ssef dif = vP - P_curve[0];
const ssef dif_second = vP - P_curve[1];
- if (difl != 0.0f) {
- const ssef len1_sq = len3_squared_splat(dif);
- const ssef len2_sq = len3_squared_splat(dif_second);
- const ssef len12 = mm_sqrt(shuffle<0, 0, 0, 0>(len1_sq, len2_sq));
- const ssef pixelsize12 = min(len12 * difl, ssef(extmax));
- r12 = max(or12, pixelsize12);
- }
- float or1 = extract<0>(or12), or2 = extract<0>(shuffle<2>(or12));
float r1 = extract<0>(r12), r2 = extract<0>(shuffle<2>(r12));
const ssef p21_diff = P_curve[1] - P_curve[0];
@@ -754,15 +670,6 @@ ccl_device_forceinline bool curve_intersect(KernelGlobals *kg,
z = zcentre + (dirz * correction);
}
- /* stochastic fade from minimum width */
- float adjradius = or1 + z * (or2 - or1) * invl;
- adjradius = adjradius / (r1 + z * gd);
- if (lcg_state && adjradius != 1.0f) {
- if (lcg_step_float(lcg_state) > adjradius)
- return false;
- }
- /* --- */
-
if (t > 0.0f && t < isect->t && z >= 0 && z <= l) {
if (flags & CURVE_KN_ENCLOSEFILTER) {
diff --git a/intern/cycles/kernel/geom/geom_object.h b/intern/cycles/kernel/geom/geom_object.h
index 2792fd64c61..f410e6e27e2 100644
--- a/intern/cycles/kernel/geom/geom_object.h
+++ b/intern/cycles/kernel/geom/geom_object.h
@@ -386,7 +386,8 @@ ccl_device float3 particle_angular_velocity(KernelGlobals *kg, int particle)
ccl_device_inline float3 bvh_clamp_direction(float3 dir)
{
- /* clamp absolute values by exp2f(-80.0f) to avoid division by zero when calculating inverse direction */
+ /* clamp absolute values by exp2f(-80.0f) to avoid division by zero when calculating inverse
+ * direction */
#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE2__)
const ssef oopes(8.271806E-25f, 8.271806E-25f, 8.271806E-25f, 0.0f);
const ssef mask = _mm_cmpgt_ps(fabs(dir), oopes);
diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h b/intern/cycles/kernel/geom/geom_triangle_intersect.h
index bcad03102d2..9c6fd498a80 100644
--- a/intern/cycles/kernel/geom/geom_triangle_intersect.h
+++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h
@@ -178,7 +178,7 @@ ccl_device_inline int ray_triangle_intersect8(KernelGlobals *kg,
_mm256_cmpeq_epi32(two256, UVW_256_1));
unsigned char mask_minmaxUVW_pos = _mm256_movemask_ps(_mm256_castsi256_ps(mask_minmaxUVW_256));
- if ((mask_minmaxUVW_pos & prim_num_mask) == prim_num_mask) { //all bits set
+ if ((mask_minmaxUVW_pos & prim_num_mask) == prim_num_mask) { // all bits set
return false;
}
@@ -375,7 +375,7 @@ ccl_device_inline int triangle_intersect8(KernelGlobals *kg,
tri_b[i] = *(__m128 *)&kg->__prim_tri_verts.data[tri_vindex++];
tri_c[i] = *(__m128 *)&kg->__prim_tri_verts.data[tri_vindex++];
}
- //create 9 or 12 placeholders
+ // create 9 or 12 placeholders
tri[0] = _mm256_castps128_ps256(tri_a[0]); //_mm256_zextps128_ps256
tri[1] = _mm256_castps128_ps256(tri_b[0]); //_mm256_zextps128_ps256
tri[2] = _mm256_castps128_ps256(tri_c[0]); //_mm256_zextps128_ps256
@@ -401,40 +401,40 @@ ccl_device_inline int triangle_intersect8(KernelGlobals *kg,
}
//------------------------------------------------
- //0! Xa0 Ya0 Za0 1 Xa4 Ya4 Za4 1
- //1! Xb0 Yb0 Zb0 1 Xb4 Yb4 Zb4 1
- //2! Xc0 Yc0 Zc0 1 Xc4 Yc4 Zc4 1
+ // 0! Xa0 Ya0 Za0 1 Xa4 Ya4 Za4 1
+ // 1! Xb0 Yb0 Zb0 1 Xb4 Yb4 Zb4 1
+ // 2! Xc0 Yc0 Zc0 1 Xc4 Yc4 Zc4 1
- //3! Xa1 Ya1 Za1 1 Xa5 Ya5 Za5 1
- //4! Xb1 Yb1 Zb1 1 Xb5 Yb5 Zb5 1
- //5! Xc1 Yc1 Zc1 1 Xc5 Yc5 Zc5 1
+ // 3! Xa1 Ya1 Za1 1 Xa5 Ya5 Za5 1
+ // 4! Xb1 Yb1 Zb1 1 Xb5 Yb5 Zb5 1
+ // 5! Xc1 Yc1 Zc1 1 Xc5 Yc5 Zc5 1
- //6! Xa2 Ya2 Za2 1 Xa6 Ya6 Za6 1
- //7! Xb2 Yb2 Zb2 1 Xb6 Yb6 Zb6 1
- //8! Xc2 Yc2 Zc2 1 Xc6 Yc6 Zc6 1
+ // 6! Xa2 Ya2 Za2 1 Xa6 Ya6 Za6 1
+ // 7! Xb2 Yb2 Zb2 1 Xb6 Yb6 Zb6 1
+ // 8! Xc2 Yc2 Zc2 1 Xc6 Yc6 Zc6 1
- //9! Xa3 Ya3 Za3 1 Xa7 Ya7 Za7 1
- //10! Xb3 Yb3 Zb3 1 Xb7 Yb7 Zb7 1
- //11! Xc3 Yc3 Zc3 1 Xc7 Yc7 Zc7 1
+ // 9! Xa3 Ya3 Za3 1 Xa7 Ya7 Za7 1
+ // 10! Xb3 Yb3 Zb3 1 Xb7 Yb7 Zb7 1
+ // 11! Xc3 Yc3 Zc3 1 Xc7 Yc7 Zc7 1
//"transpose"
- tritmp[0] = _mm256_unpacklo_ps(tri[0], tri[3]); //0! Xa0 Xa1 Ya0 Ya1 Xa4 Xa5 Ya4 Ya5
- tritmp[1] = _mm256_unpackhi_ps(tri[0], tri[3]); //1! Za0 Za1 1 1 Za4 Za5 1 1
+ tritmp[0] = _mm256_unpacklo_ps(tri[0], tri[3]); // 0! Xa0 Xa1 Ya0 Ya1 Xa4 Xa5 Ya4 Ya5
+ tritmp[1] = _mm256_unpackhi_ps(tri[0], tri[3]); // 1! Za0 Za1 1 1 Za4 Za5 1 1
- tritmp[2] = _mm256_unpacklo_ps(tri[6], tri[9]); //2! Xa2 Xa3 Ya2 Ya3 Xa6 Xa7 Ya6 Ya7
- tritmp[3] = _mm256_unpackhi_ps(tri[6], tri[9]); //3! Za2 Za3 1 1 Za6 Za7 1 1
+ tritmp[2] = _mm256_unpacklo_ps(tri[6], tri[9]); // 2! Xa2 Xa3 Ya2 Ya3 Xa6 Xa7 Ya6 Ya7
+ tritmp[3] = _mm256_unpackhi_ps(tri[6], tri[9]); // 3! Za2 Za3 1 1 Za6 Za7 1 1
- tritmp[4] = _mm256_unpacklo_ps(tri[1], tri[4]); //4! Xb0 Xb1 Yb0 Yb1 Xb4 Xb5 Yb4 Yb5
- tritmp[5] = _mm256_unpackhi_ps(tri[1], tri[4]); //5! Zb0 Zb1 1 1 Zb4 Zb5 1 1
+ tritmp[4] = _mm256_unpacklo_ps(tri[1], tri[4]); // 4! Xb0 Xb1 Yb0 Yb1 Xb4 Xb5 Yb4 Yb5
+ tritmp[5] = _mm256_unpackhi_ps(tri[1], tri[4]); // 5! Zb0 Zb1 1 1 Zb4 Zb5 1 1
- tritmp[6] = _mm256_unpacklo_ps(tri[7], tri[10]); //6! Xb2 Xb3 Yb2 Yb3 Xb6 Xb7 Yb6 Yb7
- tritmp[7] = _mm256_unpackhi_ps(tri[7], tri[10]); //7! Zb2 Zb3 1 1 Zb6 Zb7 1 1
+ tritmp[6] = _mm256_unpacklo_ps(tri[7], tri[10]); // 6! Xb2 Xb3 Yb2 Yb3 Xb6 Xb7 Yb6 Yb7
+ tritmp[7] = _mm256_unpackhi_ps(tri[7], tri[10]); // 7! Zb2 Zb3 1 1 Zb6 Zb7 1 1
- tritmp[8] = _mm256_unpacklo_ps(tri[2], tri[5]); //8! Xc0 Xc1 Yc0 Yc1 Xc4 Xc5 Yc4 Yc5
- tritmp[9] = _mm256_unpackhi_ps(tri[2], tri[5]); //9! Zc0 Zc1 1 1 Zc4 Zc5 1 1
+ tritmp[8] = _mm256_unpacklo_ps(tri[2], tri[5]); // 8! Xc0 Xc1 Yc0 Yc1 Xc4 Xc5 Yc4 Yc5
+ tritmp[9] = _mm256_unpackhi_ps(tri[2], tri[5]); // 9! Zc0 Zc1 1 1 Zc4 Zc5 1 1
- tritmp[10] = _mm256_unpacklo_ps(tri[8], tri[11]); //10! Xc2 Xc3 Yc2 Yc3 Xc6 Xc7 Yc6 Yc7
- tritmp[11] = _mm256_unpackhi_ps(tri[8], tri[11]); //11! Zc2 Zc3 1 1 Zc6 Zc7 1 1
+ tritmp[10] = _mm256_unpacklo_ps(tri[8], tri[11]); // 10! Xc2 Xc3 Yc2 Yc3 Xc6 Xc7 Yc6 Yc7
+ tritmp[11] = _mm256_unpackhi_ps(tri[8], tri[11]); // 11! Zc2 Zc3 1 1 Zc6 Zc7 1 1
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
triA[0] = _mm256_castpd_ps(
@@ -459,13 +459,13 @@ ccl_device_inline int triangle_intersect8(KernelGlobals *kg,
triC[0] = _mm256_castpd_ps(
_mm256_unpacklo_pd(_mm256_castps_pd(tritmp[8]),
- _mm256_castps_pd(tritmp[10]))); //Xc0 Xc1 Xc2 Xc3 Xc4 Xc5 Xc6 Xc7
+ _mm256_castps_pd(tritmp[10]))); // Xc0 Xc1 Xc2 Xc3 Xc4 Xc5 Xc6 Xc7
triC[1] = _mm256_castpd_ps(
_mm256_unpackhi_pd(_mm256_castps_pd(tritmp[8]),
- _mm256_castps_pd(tritmp[10]))); //Yc0 Yc1 Yc2 Yc3 Yc4 Yc5 Yc6 Yc7
+ _mm256_castps_pd(tritmp[10]))); // Yc0 Yc1 Yc2 Yc3 Yc4 Yc5 Yc6 Yc7
triC[2] = _mm256_castpd_ps(
_mm256_unpacklo_pd(_mm256_castps_pd(tritmp[9]),
- _mm256_castps_pd(tritmp[11]))); //Zc0 Zc1 Zc2 Zc3 Zc4 Zc5 Zc6 Zc7
+ _mm256_castps_pd(tritmp[11]))); // Zc0 Zc1 Zc2 Zc3 Zc4 Zc5 Zc6 Zc7
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h
index 10b71bc6bdf..cd1ca5ea7ec 100644
--- a/intern/cycles/kernel/kernel_bake.h
+++ b/intern/cycles/kernel/kernel_bake.h
@@ -72,7 +72,8 @@ ccl_device_inline void compute_light_pass(
# ifdef __SUBSURFACE__
/* sample subsurface scattering */
if ((pass_filter & BAKE_FILTER_SUBSURFACE) && (sd->flag & SD_BSSRDF)) {
- /* when mixing BSSRDF and BSDF closures we should skip BSDF lighting if scattering was successful */
+ /* When mixing BSSRDF and BSDF closures we should skip BSDF lighting
+ * if scattering was successful. */
SubsurfaceIndirectRays ss_indirect;
kernel_path_subsurface_init_indirect(&ss_indirect);
if (kernel_path_subsurface_scatter(
@@ -123,7 +124,8 @@ ccl_device_inline void compute_light_pass(
# ifdef __SUBSURFACE__
/* sample subsurface scattering */
if ((pass_filter & BAKE_FILTER_SUBSURFACE) && (sd->flag & SD_BSSRDF)) {
- /* when mixing BSSRDF and BSDF closures we should skip BSDF lighting if scattering was successful */
+ /* When mixing BSSRDF and BSDF closures we should skip BSDF lighting
+ * if scattering was successful. */
kernel_branched_path_subsurface_scatter(
kg, sd, &indirect_sd, &emission_sd, &L_sample, &state, &ray, throughput);
}
diff --git a/intern/cycles/kernel/kernel_id_passes.h b/intern/cycles/kernel/kernel_id_passes.h
index c1f4e39e5e7..1ca42e933d1 100644
--- a/intern/cycles/kernel/kernel_id_passes.h
+++ b/intern/cycles/kernel/kernel_id_passes.h
@@ -1,18 +1,18 @@
/*
-* Copyright 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.
-*/
+ * Copyright 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.
+ */
CCL_NAMESPACE_BEGIN
@@ -32,7 +32,7 @@ ccl_device_inline void kernel_write_id_slots(ccl_global float *buffer,
/* If the loop reaches an empty slot, the ID isn't in any slot yet - so add it! */
if (id_buffer[slot].x == ID_NONE) {
/* Use an atomic to claim this slot.
- * If a different thread got here first, try again from this slot on. */
+ * If a different thread got here first, try again from this slot on. */
float old_id = atomic_compare_and_swap_float(buffer + slot * 2, ID_NONE, id);
if (old_id != ID_NONE && old_id != id) {
continue;
@@ -54,7 +54,7 @@ ccl_device_inline void kernel_write_id_slots(ccl_global float *buffer,
break;
}
/* If there already is a slot for that ID, add the weight.
- * If no slot was found, add it to the last. */
+ * If no slot was found, add it to the last. */
else if (id_buffer[slot].x == id || slot == num_slots - 1) {
id_buffer[slot].y += weight;
break;
diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index 5e24f8dedaf..9128bfa9d95 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -524,7 +524,8 @@ ccl_device float background_light_pdf(KernelGlobals *kg, float3 P, float3 direct
portal_pdf = background_portal_pdf(kg, P, direction, -1, &is_possible) * portal_sampling_pdf;
if (!is_possible) {
/* Portal sampling is not possible here because all portals point to the wrong side.
- * If map sampling is possible, it would be used instead, otherwise fallback sampling is used. */
+ * If map sampling is possible, it would be used instead,
+ * otherwise fallback sampling is used. */
if (portal_sampling_pdf == 1.0f) {
return kernel_data.integrator.pdf_lights / M_4PI_F;
}
diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h
index a933be970c2..acd5086be3a 100644
--- a/intern/cycles/kernel/kernel_montecarlo.h
+++ b/intern/cycles/kernel/kernel_montecarlo.h
@@ -199,21 +199,27 @@ ccl_device float3 ensure_valid_reflection(float3 Ng, float3 I, float3 N)
float NdotNg = dot(N, Ng);
float3 X = normalize(N - NdotNg * Ng);
+ /* Keep math expressions. */
+ /* clang-format off */
/* Calculate N.z and N.x in the local coordinate system.
*
* The goal of this computation is to find a N' that is rotated towards Ng just enough
* to lift R' above the threshold (here called t), therefore dot(R', Ng) = t.
*
- * According to the standard reflection equation, this means that we want dot(2*dot(N', I)*N' - I, Ng) = t.
+ * According to the standard reflection equation,
+ * this means that we want dot(2*dot(N', I)*N' - I, Ng) = t.
*
- * Since the Z axis of our local coordinate system is Ng, dot(x, Ng) is just x.z, so we get 2*dot(N', I)*N'.z - I.z = t.
+ * Since the Z axis of our local coordinate system is Ng, dot(x, Ng) is just x.z, so we get
+ * 2*dot(N', I)*N'.z - I.z = t.
*
- * The rotation is simple to express in the coordinate system we formed - since N lies in the X-Z-plane, we know that
- * N' will also lie in the X-Z-plane, so N'.y = 0 and therefore dot(N', I) = N'.x*I.x + N'.z*I.z .
+ * The rotation is simple to express in the coordinate system we formed -
+ * since N lies in the X-Z-plane, we know that N' will also lie in the X-Z-plane,
+ * so N'.y = 0 and therefore dot(N', I) = N'.x*I.x + N'.z*I.z .
*
* Furthermore, we want N' to be normalized, so N'.x = sqrt(1 - N'.z^2).
*
- * With these simplifications, we get the final equation 2*(sqrt(1 - N'.z^2)*I.x + N'.z*I.z)*N'.z - I.z = t.
+ * With these simplifications,
+ * we get the final equation 2*(sqrt(1 - N'.z^2)*I.x + N'.z*I.z)*N'.z - I.z = t.
*
* The only unknown here is N'.z, so we can solve for that.
*
@@ -227,8 +233,11 @@ ccl_device float3 ensure_valid_reflection(float3 Ng, float3 I, float3 N)
* c = I.z*t + a
* N'.z = +-sqrt(0.5*(+-b + c)/a)
*
- * Two solutions can immediately be discarded because they're negative so N' would lie in the lower hemisphere.
+ * Two solutions can immediately be discarded because they're negative so N' would lie in the
+ * lower hemisphere.
*/
+ /* clang-format on */
+
float Ix = dot(I, X), Iz = dot(I, Ng);
float Ix2 = sqr(Ix), Iz2 = sqr(Iz);
float a = Ix2 + Iz2;
@@ -237,8 +246,9 @@ ccl_device float3 ensure_valid_reflection(float3 Ng, float3 I, float3 N)
float c = Iz * threshold + a;
/* Evaluate both solutions.
- * In many cases one can be immediately discarded (if N'.z would be imaginary or larger than one), so check for that first.
- * If no option is viable (might happen in extreme cases like N being in the wrong hemisphere), give up and return Ng. */
+ * In many cases one can be immediately discarded (if N'.z would be imaginary or larger than
+ * one), so check for that first. If no option is viable (might happen in extreme cases like N
+ * being in the wrong hemisphere), give up and return Ng. */
float fac = 0.5f / a;
float N1_z2 = fac * (b + c), N2_z2 = fac * (-b + c);
bool valid1 = (N1_z2 > 1e-5f) && (N1_z2 <= (1.0f + 1e-5f));
@@ -256,8 +266,9 @@ ccl_device float3 ensure_valid_reflection(float3 Ng, float3 I, float3 N)
valid1 = (R1 >= 1e-5f);
valid2 = (R2 >= 1e-5f);
if (valid1 && valid2) {
- /* If both solutions are valid, return the one with the shallower reflection since it will be closer to the input
- * (if the original reflection wasn't shallow, we would not be in this part of the function). */
+ /* If both solutions are valid, return the one with the shallower reflection since it will be
+ * closer to the input (if the original reflection wasn't shallow, we would not be in this
+ * part of the function). */
N_new = (R1 < R2) ? N1 : N2;
}
else {
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index 2be1b745632..f3e2a8a234a 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -65,25 +65,7 @@ ccl_device_forceinline bool kernel_path_scene_intersect(KernelGlobals *kg,
ray->t = kernel_data.background.ao_distance;
}
-#ifdef __HAIR__
- float difl = 0.0f, extmax = 0.0f;
- uint lcg_state = 0;
-
- if (kernel_data.bvh.have_curves) {
- if ((kernel_data.cam.resolution == 1) && (state->flag & PATH_RAY_CAMERA)) {
- float3 pixdiff = ray->dD.dx + ray->dD.dy;
- /*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/
- difl = kernel_data.curve.minimum_width * len(pixdiff) * 0.5f;
- }
-
- extmax = kernel_data.curve.maximum_width;
- lcg_state = lcg_state_init_addrspace(state, 0x51633e2d);
- }
-
- bool hit = scene_intersect(kg, *ray, visibility, isect, &lcg_state, difl, extmax);
-#else
- bool hit = scene_intersect(kg, *ray, visibility, isect, NULL, 0.0f, 0.0f);
-#endif /* __HAIR__ */
+ bool hit = scene_intersect(kg, *ray, visibility, isect);
#ifdef __KERNEL_DEBUG__
if (state->flag & PATH_RAY_CAMERA) {
@@ -455,8 +437,8 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
}
/* path termination. this is a strange place to put the termination, it's
- * mainly due to the mixed in MIS that we use. gives too many unneeded
- * shader evaluations, only need emission if we are going to terminate */
+ * mainly due to the mixed in MIS that we use. gives too many unneeded
+ * shader evaluations, only need emission if we are going to terminate */
float probability = path_state_continuation_probability(kg, state, throughput);
if (probability == 0.0f) {
@@ -482,7 +464,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
# ifdef __SUBSURFACE__
/* bssrdf scatter to a different location on the same object, replacing
- * the closures with a diffuse BSDF */
+ * the closures with a diffuse BSDF */
if (sd->flag & SD_BSSRDF) {
if (kernel_path_subsurface_scatter(
kg, sd, emission_sd, L, state, ray, &throughput, &ss_indirect)) {
@@ -593,8 +575,8 @@ ccl_device_forceinline void kernel_path_integrate(KernelGlobals *kg,
}
/* path termination. this is a strange place to put the termination, it's
- * mainly due to the mixed in MIS that we use. gives too many unneeded
- * shader evaluations, only need emission if we are going to terminate */
+ * mainly due to the mixed in MIS that we use. gives too many unneeded
+ * shader evaluations, only need emission if we are going to terminate */
float probability = path_state_continuation_probability(kg, state, throughput);
if (probability == 0.0f) {
@@ -619,7 +601,7 @@ ccl_device_forceinline void kernel_path_integrate(KernelGlobals *kg,
# ifdef __SUBSURFACE__
/* bssrdf scatter to a different location on the same object, replacing
- * the closures with a diffuse BSDF */
+ * the closures with a diffuse BSDF */
if (sd.flag & SD_BSSRDF) {
if (kernel_path_subsurface_scatter(
kg, &sd, emission_sd, L, state, ray, &throughput, &ss_indirect)) {
diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h
index e8ce61024b3..f3a1ea3f4fd 100644
--- a/intern/cycles/kernel/kernel_path_branched.h
+++ b/intern/cycles/kernel/kernel_path_branched.h
@@ -428,8 +428,8 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg,
/* transparency termination */
if (state.flag & PATH_RAY_TRANSPARENT) {
/* path termination. this is a strange place to put the termination, it's
- * mainly due to the mixed in MIS that we use. gives too many unneeded
- * shader evaluations, only need emission if we are going to terminate */
+ * mainly due to the mixed in MIS that we use. gives too many unneeded
+ * shader evaluations, only need emission if we are going to terminate */
float probability = path_state_continuation_probability(kg, &state, throughput);
if (probability == 0.0f) {
diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h
index 6251313c5f8..a1ab4951565 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -18,7 +18,8 @@ CCL_NAMESPACE_BEGIN
#if defined(__BRANCHED_PATH__) || defined(__SUBSURFACE__) || defined(__SHADOW_TRICKS__) || \
defined(__BAKING__)
-/* branched path tracing: connect path directly to position on one or more lights and add it to L */
+/* branched path tracing: connect path directly to position on one or more lights and add it to L
+ */
ccl_device_noinline void kernel_branched_path_surface_connect_light(
KernelGlobals *kg,
ShaderData *sd,
@@ -62,8 +63,10 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(
LightSample ls;
if (lamp_light_sample(kg, i, light_u, light_v, sd->P, &ls)) {
- /* The sampling probability returned by lamp_light_sample assumes that all lights were sampled.
- * However, this code only samples lamps, so if the scene also had mesh lights, the real probability is twice as high. */
+ /* The sampling probability returned by lamp_light_sample assumes that all lights were
+ * sampled.
+ * However, this code only samples lamps, so if the scene also had mesh lights, the real
+ * probability is twice as high. */
if (kernel_data.integrator.pdf_triangles != 0.0f)
ls.pdf *= 2.0f;
@@ -109,7 +112,8 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(
LightSample ls;
if (light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
- /* Same as above, probability needs to be corrected since the sampling was forced to select a mesh light. */
+ /* Same as above, probability needs to be corrected since the sampling was forced to
+ * select a mesh light. */
if (kernel_data.integrator.num_all_lights)
ls.pdf *= 2.0f;
diff --git a/intern/cycles/kernel/kernel_shadow.h b/intern/cycles/kernel/kernel_shadow.h
index 6af1369feab..07201819030 100644
--- a/intern/cycles/kernel/kernel_shadow.h
+++ b/intern/cycles/kernel/kernel_shadow.h
@@ -103,8 +103,7 @@ ccl_device bool shadow_blocked_opaque(KernelGlobals *kg,
Intersection *isect,
float3 *shadow)
{
- const bool blocked = scene_intersect(
- kg, *ray, visibility & PATH_RAY_SHADOW_OPAQUE, isect, NULL, 0.0f, 0.0f);
+ const bool blocked = scene_intersect(kg, *ray, visibility & PATH_RAY_SHADOW_OPAQUE, isect);
#ifdef __VOLUME__
if (!blocked && state->volume_stack[0].shader != SHADER_NONE) {
/* Apply attenuation from current volume shader. */
@@ -319,8 +318,7 @@ ccl_device bool shadow_blocked_transparent_stepped_loop(KernelGlobals *kg,
if (bounce >= kernel_data.integrator.transparent_max_bounce) {
return true;
}
- if (!scene_intersect(
- kg, *ray, visibility & PATH_RAY_SHADOW_TRANSPARENT, isect, NULL, 0.0f, 0.0f)) {
+ if (!scene_intersect(kg, *ray, visibility & PATH_RAY_SHADOW_TRANSPARENT, isect)) {
break;
}
if (!shader_transparent_shadow(kg, isect)) {
@@ -376,8 +374,7 @@ ccl_device bool shadow_blocked_transparent_stepped(KernelGlobals *kg,
Intersection *isect,
float3 *shadow)
{
- bool blocked = scene_intersect(
- kg, *ray, visibility & PATH_RAY_SHADOW_OPAQUE, isect, NULL, 0.0f, 0.0f);
+ bool blocked = scene_intersect(kg, *ray, visibility & PATH_RAY_SHADOW_OPAQUE, isect);
bool is_transparent_isect = blocked ? shader_transparent_shadow(kg, isect) : false;
return shadow_blocked_transparent_stepped_loop(
kg, sd, shadow_sd, state, visibility, ray, isect, blocked, is_transparent_isect, shadow);
@@ -436,8 +433,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg,
* TODO(sergey): Check why using record-all behavior causes slowdown in such
* cases. Could that be caused by a higher spill pressure?
*/
- const bool blocked = scene_intersect(
- kg, *ray, visibility & PATH_RAY_SHADOW_OPAQUE, &isect, NULL, 0.0f, 0.0f);
+ const bool blocked = scene_intersect(kg, *ray, visibility & PATH_RAY_SHADOW_OPAQUE, &isect);
const bool is_transparent_isect = blocked ? shader_transparent_shadow(kg, &isect) : false;
if (!blocked || !is_transparent_isect || max_hits + 1 >= SHADOW_STACK_MAX_HITS) {
return shadow_blocked_transparent_stepped_loop(
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 3f62b726b6a..7d4f655a32e 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -981,7 +981,6 @@ typedef ccl_addr_space struct ShaderData {
differential3 ray_dP;
#ifdef __OSL__
- struct KernelGlobals *osl_globals;
struct PathState *osl_path_state;
#endif
@@ -1372,8 +1371,7 @@ typedef struct KernelCurves {
int curveflags;
int subdivisions;
- float minimum_width;
- float maximum_width;
+ int pad1, pad2;
} KernelCurves;
static_assert_align(KernelCurves, 16);
diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h
index e024003252f..1705f58b87d 100644
--- a/intern/cycles/kernel/kernel_volume.h
+++ b/intern/cycles/kernel/kernel_volume.h
@@ -559,7 +559,7 @@ kernel_volume_integrate_heterogeneous_distance(KernelGlobals *kg,
float dt = new_t - t;
/* use random position inside this segment to sample shader,
- * for last shorter step we remap it to fit within the segment. */
+ * for last shorter step we remap it to fit within the segment. */
if (new_t == ray->t) {
step_offset *= (new_t - t) / step_size;
}
@@ -794,7 +794,7 @@ ccl_device void kernel_volume_decoupled_record(KernelGlobals *kg,
float dt = new_t - t;
/* use random position inside this segment to sample shader,
- * for last shorter step we remap it to fit within the segment. */
+ * for last shorter step we remap it to fit within the segment. */
if (new_t == ray->t) {
step_offset *= (new_t - t) / step_size;
}
diff --git a/intern/cycles/kernel/kernels/cuda/kernel_config.h b/intern/cycles/kernel/kernels/cuda/kernel_config.h
index d9f349837a8..3ec00762e72 100644
--- a/intern/cycles/kernel/kernels/cuda/kernel_config.h
+++ b/intern/cycles/kernel/kernels/cuda/kernel_config.h
@@ -61,7 +61,8 @@
/* 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 */
+/* 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
# define CUDA_KERNEL_MAX_REGISTERS 64
# else
diff --git a/intern/cycles/kernel/osl/background.cpp b/intern/cycles/kernel/osl/background.cpp
index b395227845d..03fa88f40ad 100644
--- a/intern/cycles/kernel/osl/background.cpp
+++ b/intern/cycles/kernel/osl/background.cpp
@@ -52,7 +52,7 @@ using namespace OSL;
///
class GenericBackgroundClosure : public CClosurePrimitive {
public:
- void setup(ShaderData *sd, int /* path_flag */, float3 weight)
+ void setup(const KernelGlobals *, ShaderData *sd, int /* path_flag */, float3 weight)
{
background_setup(sd, weight);
}
@@ -67,7 +67,7 @@ class GenericBackgroundClosure : public CClosurePrimitive {
///
class HoldoutClosure : CClosurePrimitive {
public:
- void setup(ShaderData *sd, int /* path_flag */, float3 weight)
+ void setup(const KernelGlobals *, ShaderData *sd, int /* path_flag */, float3 weight)
{
closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_HOLDOUT_ID, weight);
sd->flag |= SD_HOLDOUT;
diff --git a/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp b/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp
index c5edc7c9be3..419837ab8d6 100644
--- a/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp
+++ b/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp
@@ -51,7 +51,7 @@ class DiffuseRampClosure : public CBSDFClosure {
DiffuseRampBsdf params;
Color3 colors[8];
- void setup(ShaderData *sd, int /* path_flag */, float3 weight)
+ void setup(const KernelGlobals *, ShaderData *sd, int /* path_flag */, float3 weight)
{
DiffuseRampBsdf *bsdf = (DiffuseRampBsdf *)bsdf_alloc_osl(
sd, sizeof(DiffuseRampBsdf), weight, &params);
diff --git a/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp b/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp
index 4b7e59ff932..6bf39934235 100644
--- a/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp
+++ b/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp
@@ -50,7 +50,7 @@ class PhongRampClosure : public CBSDFClosure {
PhongRampBsdf params;
Color3 colors[8];
- void setup(ShaderData *sd, int /* path_flag */, float3 weight)
+ void setup(const KernelGlobals *, ShaderData *sd, int /* path_flag */, float3 weight)
{
PhongRampBsdf *bsdf = (PhongRampBsdf *)bsdf_alloc_osl(
sd, sizeof(PhongRampBsdf), weight, &params);
diff --git a/intern/cycles/kernel/osl/emissive.cpp b/intern/cycles/kernel/osl/emissive.cpp
index c29ddb13e2e..894727a5c7b 100644
--- a/intern/cycles/kernel/osl/emissive.cpp
+++ b/intern/cycles/kernel/osl/emissive.cpp
@@ -54,7 +54,7 @@ using namespace OSL;
///
class GenericEmissiveClosure : public CClosurePrimitive {
public:
- void setup(ShaderData *sd, int /* path_flag */, float3 weight)
+ void setup(const KernelGlobals *, ShaderData *sd, int /* path_flag */, float3 weight)
{
emission_setup(sd, weight);
}
diff --git a/intern/cycles/kernel/osl/osl_bssrdf.cpp b/intern/cycles/kernel/osl/osl_bssrdf.cpp
index dd52c33071c..b487aef09a1 100644
--- a/intern/cycles/kernel/osl/osl_bssrdf.cpp
+++ b/intern/cycles/kernel/osl/osl_bssrdf.cpp
@@ -67,7 +67,7 @@ class CBSSRDFClosure : public CClosurePrimitive {
params.roughness = 0.0f;
}
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *, ShaderData *sd, int path_flag, float3 weight)
{
if (method == u_cubic) {
alloc(sd, path_flag, weight, CLOSURE_BSSRDF_CUBIC_ID);
diff --git a/intern/cycles/kernel/osl/osl_closures.cpp b/intern/cycles/kernel/osl/osl_closures.cpp
index aa7e2727577..7152a56bd70 100644
--- a/intern/cycles/kernel/osl/osl_closures.cpp
+++ b/intern/cycles/kernel/osl/osl_closures.cpp
@@ -227,9 +227,9 @@ CLOSURE_FLOAT3_PARAM(DiffuseClosure, params.N),
return bsdf;
}
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
- if (!skip(sd, path_flag, LABEL_GLOSSY)) {
+ if (!skip(kg, sd, path_flag, LABEL_GLOSSY)) {
PrincipledHairBSDF *bsdf = (PrincipledHairBSDF *)alloc(sd, path_flag, weight);
if (!bsdf) {
return;
@@ -287,7 +287,7 @@ class PrincipledClearcoatClosure : public CBSDFClosure {
return bsdf;
}
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
if (!bsdf) {
@@ -471,12 +471,13 @@ void OSLShader::register_closures(OSLShadingSystem *ss_)
/* BSDF Closure */
-bool CBSDFClosure::skip(const ShaderData *sd, int path_flag, int scattering)
+bool CBSDFClosure::skip(const KernelGlobals *kg,
+ const ShaderData *sd,
+ int path_flag,
+ int scattering)
{
/* caustic options */
if ((scattering & LABEL_GLOSSY) && (path_flag & PATH_RAY_DIFFUSE)) {
- KernelGlobals *kg = sd->osl_globals;
-
if ((!kernel_data.integrator.caustics_reflective && (scattering & LABEL_REFLECT)) ||
(!kernel_data.integrator.caustics_refractive && (scattering & LABEL_TRANSMIT))) {
return true;
@@ -494,12 +495,12 @@ class MicrofacetFresnelClosure : public CBSDFClosure {
float3 color;
float3 cspec0;
- MicrofacetBsdf *alloc(ShaderData *sd, int path_flag, float3 weight)
+ MicrofacetBsdf *alloc(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
/* Technically, the MultiGGX Glass closure may also transmit. However,
- * since this is set statically and only used for caustic flags, this
- * is probably as good as it gets. */
- if (skip(sd, path_flag, LABEL_GLOSSY | LABEL_REFLECT)) {
+ * since this is set statically and only used for caustic flags, this
+ * is probably as good as it gets. */
+ if (skip(kg, sd, path_flag, LABEL_GLOSSY | LABEL_REFLECT)) {
return NULL;
}
@@ -524,9 +525,9 @@ class MicrofacetFresnelClosure : public CBSDFClosure {
class MicrofacetGGXFresnelClosure : public MicrofacetFresnelClosure {
public:
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
- MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ MicrofacetBsdf *bsdf = alloc(kg, sd, path_flag, weight);
if (!bsdf) {
return;
}
@@ -553,9 +554,9 @@ CCLOSURE_PREPARE(closure_bsdf_microfacet_ggx_fresnel_prepare, MicrofacetGGXFresn
class MicrofacetGGXAnisoFresnelClosure : public MicrofacetFresnelClosure {
public:
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
- MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ MicrofacetBsdf *bsdf = alloc(kg, sd, path_flag, weight);
if (!bsdf) {
return;
}
@@ -588,12 +589,12 @@ class MicrofacetMultiClosure : public CBSDFClosure {
MicrofacetBsdf params;
float3 color;
- MicrofacetBsdf *alloc(ShaderData *sd, int path_flag, float3 weight)
+ MicrofacetBsdf *alloc(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
/* Technically, the MultiGGX closure may also transmit. However,
* since this is set statically and only used for caustic flags, this
* is probably as good as it gets. */
- if (skip(sd, path_flag, LABEL_GLOSSY | LABEL_REFLECT)) {
+ if (skip(kg, sd, path_flag, LABEL_GLOSSY | LABEL_REFLECT)) {
return NULL;
}
@@ -618,9 +619,9 @@ class MicrofacetMultiClosure : public CBSDFClosure {
class MicrofacetMultiGGXClosure : public MicrofacetMultiClosure {
public:
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
- MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ MicrofacetBsdf *bsdf = alloc(kg, sd, path_flag, weight);
if (!bsdf) {
return;
}
@@ -646,9 +647,9 @@ CCLOSURE_PREPARE(closure_bsdf_microfacet_multi_ggx_prepare, MicrofacetMultiGGXCl
class MicrofacetMultiGGXAnisoClosure : public MicrofacetMultiClosure {
public:
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
- MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ MicrofacetBsdf *bsdf = alloc(kg, sd, path_flag, weight);
if (!bsdf) {
return;
}
@@ -678,9 +679,9 @@ class MicrofacetMultiGGXGlassClosure : public MicrofacetMultiClosure {
{
}
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
- MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ MicrofacetBsdf *bsdf = alloc(kg, sd, path_flag, weight);
if (!bsdf) {
return;
}
@@ -712,12 +713,12 @@ class MicrofacetMultiFresnelClosure : public CBSDFClosure {
float3 color;
float3 cspec0;
- MicrofacetBsdf *alloc(ShaderData *sd, int path_flag, float3 weight)
+ MicrofacetBsdf *alloc(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
/* Technically, the MultiGGX closure may also transmit. However,
- * since this is set statically and only used for caustic flags, this
- * is probably as good as it gets. */
- if (skip(sd, path_flag, LABEL_GLOSSY | LABEL_REFLECT)) {
+ * since this is set statically and only used for caustic flags, this
+ * is probably as good as it gets. */
+ if (skip(kg, sd, path_flag, LABEL_GLOSSY | LABEL_REFLECT)) {
return NULL;
}
@@ -742,9 +743,9 @@ class MicrofacetMultiFresnelClosure : public CBSDFClosure {
class MicrofacetMultiGGXFresnelClosure : public MicrofacetMultiFresnelClosure {
public:
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
- MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ MicrofacetBsdf *bsdf = alloc(kg, sd, path_flag, weight);
if (!bsdf) {
return;
}
@@ -772,9 +773,9 @@ CCLOSURE_PREPARE(closure_bsdf_microfacet_multi_ggx_fresnel_prepare,
class MicrofacetMultiGGXAnisoFresnelClosure : public MicrofacetMultiFresnelClosure {
public:
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
- MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ MicrofacetBsdf *bsdf = alloc(kg, sd, path_flag, weight);
if (!bsdf) {
return;
}
@@ -806,9 +807,9 @@ class MicrofacetMultiGGXGlassFresnelClosure : public MicrofacetMultiFresnelClosu
{
}
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
- MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ MicrofacetBsdf *bsdf = alloc(kg, sd, path_flag, weight);
if (!bsdf) {
return;
}
@@ -841,7 +842,7 @@ class TransparentClosure : public CBSDFClosure {
ShaderClosure params;
float3 unused;
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
bsdf_transparent_setup(sd, weight, path_flag);
}
@@ -860,7 +861,7 @@ CCLOSURE_PREPARE(closure_bsdf_transparent_prepare, TransparentClosure)
class VolumeAbsorptionClosure : public CBSDFClosure {
public:
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
volume_extinction_setup(sd, weight);
}
@@ -879,7 +880,7 @@ class VolumeHenyeyGreensteinClosure : public CBSDFClosure {
public:
HenyeyGreensteinVolume params;
- void setup(ShaderData *sd, int path_flag, float3 weight)
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight)
{
volume_extinction_setup(sd, weight);
diff --git a/intern/cycles/kernel/osl/osl_closures.h b/intern/cycles/kernel/osl/osl_closures.h
index d3db6b71f5c..9de1e036194 100644
--- a/intern/cycles/kernel/osl/osl_closures.h
+++ b/intern/cycles/kernel/osl/osl_closures.h
@@ -42,6 +42,8 @@
CCL_NAMESPACE_BEGIN
+struct KernelGlobals;
+
OSL::ClosureParam *closure_emission_params();
OSL::ClosureParam *closure_background_params();
OSL::ClosureParam *closure_holdout_params();
@@ -111,7 +113,7 @@ void closure_bsdf_principled_hair_prepare(OSL::RendererServices *, int id, void
class CClosurePrimitive {
public:
- virtual void setup(ShaderData *sd, int path_flag, float3 weight) = 0;
+ virtual void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight) = 0;
OSL::ustring label;
};
@@ -120,7 +122,7 @@ class CClosurePrimitive {
class CBSDFClosure : public CClosurePrimitive {
public:
- bool skip(const ShaderData *sd, int path_flag, int scattering);
+ bool skip(const KernelGlobals *kg, const ShaderData *sd, int path_flag, int scattering);
};
#define BSDF_CLOSURE_CLASS_BEGIN(Upper, lower, structname, TYPE) \
@@ -130,9 +132,9 @@ class CBSDFClosure : public CClosurePrimitive {
structname params; \
float3 unused; \
\
- void setup(ShaderData *sd, int path_flag, float3 weight) \
+ void setup(const KernelGlobals *kg, ShaderData *sd, int path_flag, float3 weight) \
{ \
- if (!skip(sd, path_flag, TYPE)) { \
+ if (!skip(kg, sd, path_flag, TYPE)) { \
structname *bsdf = (structname *)bsdf_alloc_osl(sd, sizeof(structname), weight, &params); \
sd->flag |= (bsdf) ? bsdf_##lower##_setup(bsdf) : 0; \
} \
diff --git a/intern/cycles/kernel/osl/osl_globals.h b/intern/cycles/kernel/osl/osl_globals.h
index 641c9967586..51bc5cf81a9 100644
--- a/intern/cycles/kernel/osl/osl_globals.h
+++ b/intern/cycles/kernel/osl/osl_globals.h
@@ -21,10 +21,14 @@
# include <OSL/oslexec.h>
+# include <OpenImageIO/refcnt.h>
+# include <OpenImageIO/unordered_map_concurrent.h>
+
# include "util/util_map.h"
# include "util/util_param.h"
# include "util/util_thread.h"
# include "util/util_vector.h"
+# include "util/util_unique_ptr.h"
# ifndef WIN32
using std::isfinite;
@@ -33,6 +37,43 @@ using std::isfinite;
CCL_NAMESPACE_BEGIN
class OSLRenderServices;
+class ColorSpaceProcessor;
+
+/* OSL Texture Handle
+ *
+ * OSL texture lookups are string based. If those strings are known at compile
+ * time, the OSL compiler can cache a texture handle to use instead of a string.
+ *
+ * By default it uses TextureSystem::TextureHandle. But since we want to support
+ * different kinds of textures and color space conversions, this is our own handle
+ * with additional data.
+ *
+ * These are stored in a concurrent hash map, because OSL can compile multiple
+ * shaders in parallel. */
+
+struct OSLTextureHandle : public OIIO::RefCnt {
+ enum Type { OIIO, SVM, IES, BEVEL, AO };
+
+ OSLTextureHandle(Type type = OIIO, int svm_slot = -1)
+ : type(type), svm_slot(svm_slot), oiio_handle(NULL), processor(NULL)
+ {
+ }
+
+ Type type;
+ int svm_slot;
+ OSL::TextureSystem::TextureHandle *oiio_handle;
+ ColorSpaceProcessor *processor;
+};
+
+typedef OIIO::intrusive_ptr<OSLTextureHandle> OSLTextureHandleRef;
+typedef OIIO::unordered_map_concurrent<ustring, OSLTextureHandleRef, ustringHash>
+ OSLTextureHandleMap;
+
+/* OSL Globals
+ *
+ * Data needed by OSL render services, that is global to a rendering session.
+ * This includes all OSL shaders, name to attribute mapping and texture handles.
+ * */
struct OSLGlobals {
OSLGlobals()
@@ -70,6 +111,9 @@ struct OSLGlobals {
vector<AttributeMap> attribute_map;
ObjectNameMap object_name_map;
vector<ustring> object_names;
+
+ /* textures */
+ OSLTextureHandleMap textures;
};
/* trace() call result */
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp
index 0257e18c3e8..8215f6522db 100644
--- a/intern/cycles/kernel/osl/osl_services.cpp
+++ b/intern/cycles/kernel/osl/osl_services.cpp
@@ -25,6 +25,7 @@
#include <string.h>
+#include "render/colorspace.h"
#include "render/mesh.h"
#include "render/object.h"
#include "render/scene.h"
@@ -124,12 +125,11 @@ ustring OSLRenderServices::u_I("I");
ustring OSLRenderServices::u_u("u");
ustring OSLRenderServices::u_v("v");
ustring OSLRenderServices::u_empty;
-ustring OSLRenderServices::u_at_bevel("@bevel");
-ustring OSLRenderServices::u_at_ao("@ao");
OSLRenderServices::OSLRenderServices()
{
kernel_globals = NULL;
+ osl_globals = NULL;
osl_ts = NULL;
#ifdef WITH_PTEX
@@ -148,9 +148,12 @@ OSLRenderServices::~OSLRenderServices()
#endif
}
-void OSLRenderServices::thread_init(KernelGlobals *kernel_globals_, OSL::TextureSystem *osl_ts_)
+void OSLRenderServices::thread_init(KernelGlobals *kernel_globals_,
+ OSLGlobals *osl_globals_,
+ OSL::TextureSystem *osl_ts_)
{
kernel_globals = kernel_globals_;
+ osl_globals = osl_globals_;
osl_ts = osl_ts_;
}
@@ -163,7 +166,6 @@ bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg,
* a concept of shader space, so we just use object space for both. */
if (xform) {
const ShaderData *sd = (const ShaderData *)xform;
- KernelGlobals *kg = sd->osl_globals;
int object = sd->object;
if (object != OBJECT_NONE) {
@@ -173,9 +175,9 @@ bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg,
if (time == sd->time)
tfm = sd->ob_tfm;
else
- tfm = object_fetch_transform_motion_test(kg, object, time, NULL);
+ tfm = object_fetch_transform_motion_test(kernel_globals, object, time, NULL);
#else
- Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
+ Transform tfm = object_fetch_transform(kernel_globals, object, OBJECT_TRANSFORM);
#endif
copy_matrix(result, tfm);
@@ -200,7 +202,6 @@ bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg,
* a concept of shader space, so we just use object space for both. */
if (xform) {
const ShaderData *sd = (const ShaderData *)xform;
- KernelGlobals *kg = sd->osl_globals;
int object = sd->object;
if (object != OBJECT_NONE) {
@@ -210,9 +211,9 @@ bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg,
if (time == sd->time)
itfm = sd->ob_itfm;
else
- object_fetch_transform_motion_test(kg, object, time, &itfm);
+ object_fetch_transform_motion_test(kernel_globals, object, time, &itfm);
#else
- Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
+ Transform itfm = object_fetch_transform(kernel_globals, object, OBJECT_INVERSE_TRANSFORM);
#endif
copy_matrix(result, itfm);
@@ -304,8 +305,7 @@ bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg,
#ifdef __OBJECT_MOTION__
Transform tfm = sd->ob_tfm;
#else
- KernelGlobals *kg = sd->osl_globals;
- Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
+ Transform tfm = object_fetch_transform(kernel_globals, object, OBJECT_TRANSFORM);
#endif
copy_matrix(result, tfm);
@@ -335,8 +335,7 @@ bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg,
#ifdef __OBJECT_MOTION__
Transform tfm = sd->ob_itfm;
#else
- KernelGlobals *kg = sd->osl_globals;
- Transform tfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
+ Transform tfm = object_fetch_transform(kernel_globals, object, OBJECT_INVERSE_TRANSFORM);
#endif
copy_matrix(result, tfm);
@@ -892,15 +891,15 @@ bool OSLRenderServices::get_attribute(OSL::ShaderGlobals *sg,
bool OSLRenderServices::get_attribute(
ShaderData *sd, bool derivatives, ustring object_name, TypeDesc type, ustring name, void *val)
{
- KernelGlobals *kg = sd->osl_globals;
+ KernelGlobals *kg = kernel_globals;
int prim_type = 0;
int object;
/* lookup of attribute on another object */
if (object_name != u_empty) {
- OSLGlobals::ObjectNameMap::iterator it = kg->osl->object_name_map.find(object_name);
+ OSLGlobals::ObjectNameMap::iterator it = osl_globals->object_name_map.find(object_name);
- if (it == kg->osl->object_name_map.end())
+ if (it == osl_globals->object_name_map.end())
return false;
object = it->second;
@@ -915,7 +914,7 @@ bool OSLRenderServices::get_attribute(
/* find attribute on object */
object = object * ATTR_PRIM_TYPES + prim_type;
- OSLGlobals::AttributeMap &attribute_map = kg->osl->attribute_map[object];
+ OSLGlobals::AttributeMap &attribute_map = osl_globals->attribute_map[object];
OSLGlobals::AttributeMap::iterator it = attribute_map.find(name);
if (it != attribute_map.end()) {
@@ -956,19 +955,44 @@ bool OSLRenderServices::get_userdata(
TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(ustring filename)
{
- if (filename.length() && filename[0] == '@') {
- /* Dummy, we don't use texture handles for builtin textures but need
- * to tell the OSL runtime optimizer that this is a valid texture. */
+ OSLTextureHandleMap::iterator it = osl_globals->textures.find(filename);
+
+ /* For non-OIIO textures, just return a pointer to our own OSLTextureHandle. */
+ if (it != osl_globals->textures.end()) {
+ if (it->second->type != OSLTextureHandle::OIIO) {
+ return (TextureSystem::TextureHandle *)it->second.get();
+ }
+ }
+
+ /* Get handle from OpenImageIO. */
+ OSL::TextureSystem *ts = osl_ts;
+ TextureSystem::TextureHandle *handle = ts->get_texture_handle(filename);
+ if (handle == NULL) {
return NULL;
}
- else {
- return texturesys()->get_texture_handle(filename);
+
+ /* Insert new OSLTextureHandle if needed. */
+ if (it == osl_globals->textures.end()) {
+ osl_globals->textures.insert(filename, new OSLTextureHandle(OSLTextureHandle::OIIO));
+ it = osl_globals->textures.find(filename);
}
+
+ /* Assign OIIO texture handle and return. */
+ it->second->oiio_handle = handle;
+ return (TextureSystem::TextureHandle *)it->second.get();
}
bool OSLRenderServices::good(TextureSystem::TextureHandle *texture_handle)
{
- return texturesys()->good(texture_handle);
+ OSLTextureHandle *handle = (OSLTextureHandle *)texture_handle;
+
+ if (handle->oiio_handle) {
+ OSL::TextureSystem *ts = osl_ts;
+ return ts->good(handle->oiio_handle);
+ }
+ else {
+ return true;
+ }
}
bool OSLRenderServices::texture(ustring filename,
@@ -988,70 +1012,29 @@ bool OSLRenderServices::texture(ustring filename,
float *dresultdt,
ustring *errormessage)
{
- OSL::TextureSystem *ts = osl_ts;
- ShaderData *sd = (ShaderData *)(sg->renderstate);
- KernelGlobals *kg = sd->osl_globals;
-
- if (texture_thread_info == NULL) {
- OSLThreadData *tdata = kg->osl_tdata;
- texture_thread_info = tdata->oiio_thread_info;
- }
-
-#ifdef WITH_PTEX
- /* todo: this is just a quick hack, only works with particular files and options */
- if (string_endswith(filename.string(), ".ptx")) {
- float2 uv;
- int faceid;
-
- if (!primitive_ptex(kg, sd, &uv, &faceid))
- return false;
-
- float u = uv.x;
- float v = uv.y;
- float dudx = 0.0f;
- float dvdx = 0.0f;
- float dudy = 0.0f;
- float dvdy = 0.0f;
-
- Ptex::String error;
- PtexPtr<PtexTexture> r(ptex_cache->get(filename.c_str(), error));
-
- if (!r) {
- //std::cerr << error.c_str() << std::endl;
- return false;
- }
-
- bool mipmaplerp = false;
- float sharpness = 1.0f;
- PtexFilter::Options opts(PtexFilter::f_bicubic, mipmaplerp, sharpness);
- PtexPtr<PtexFilter> f(PtexFilter::getFilter(r, opts));
-
- f->eval(result, options.firstchannel, nchannels, faceid, u, v, dudx, dvdx, dudy, dvdy);
-
- for (int c = r->numChannels(); c < nchannels; c++)
- result[c] = result[0];
-
- return true;
- }
-#endif
+ OSLTextureHandle *handle = (OSLTextureHandle *)texture_handle;
+ OSLTextureHandle::Type texture_type = (handle) ? handle->type : OSLTextureHandle::OIIO;
bool status = false;
- if (filename.length() && filename[0] == '@') {
- if (filename == u_at_bevel) {
+ switch (texture_type) {
+ case OSLTextureHandle::BEVEL: {
/* Bevel shader hack. */
if (nchannels >= 3) {
+ ShaderData *sd = (ShaderData *)(sg->renderstate);
PathState *state = sd->osl_path_state;
int num_samples = (int)s;
float radius = t;
- float3 N = svm_bevel(kg, sd, state, radius, num_samples);
+ float3 N = svm_bevel(kernel_globals, sd, state, radius, num_samples);
result[0] = N.x;
result[1] = N.y;
result[2] = N.z;
status = true;
}
+ break;
}
- else if (filename == u_at_ao) {
+ case OSLTextureHandle::AO: {
/* AO shader hack. */
+ ShaderData *sd = (ShaderData *)(sg->renderstate);
PathState *state = sd->osl_path_state;
int num_samples = (int)s;
float radius = t;
@@ -1066,19 +1049,13 @@ bool OSLRenderServices::texture(ustring filename,
if ((int)options.tblur) {
flags |= NODE_AO_GLOBAL_RADIUS;
}
- result[0] = svm_ao(kg, sd, N, state, radius, num_samples, flags);
- status = true;
- }
- else if (filename[1] == 'l') {
- /* IES light. */
- int slot = atoi(filename.c_str() + 2);
- result[0] = kernel_ies_interp(kg, slot, s, t);
+ result[0] = svm_ao(kernel_globals, sd, N, state, radius, num_samples, flags);
status = true;
+ break;
}
- else {
+ case OSLTextureHandle::SVM: {
/* Packed texture. */
- int slot = atoi(filename.c_str() + 2);
- float4 rgba = kernel_tex_image_interp(kg, slot, s, 1.0f - t);
+ float4 rgba = kernel_tex_image_interp(kernel_globals, handle->svm_slot, s, 1.0f - t);
result[0] = rgba[0];
if (nchannels > 1)
@@ -1088,37 +1065,62 @@ bool OSLRenderServices::texture(ustring filename,
if (nchannels > 3)
result[3] = rgba[3];
status = true;
+ break;
}
- }
- else {
- if (texture_handle != NULL) {
- status = ts->texture(texture_handle,
- texture_thread_info,
- options,
- s,
- t,
- dsdx,
- dtdx,
- dsdy,
- dtdy,
- nchannels,
- result,
- dresultds,
- dresultdt);
+ case OSLTextureHandle::IES: {
+ /* IES light. */
+ result[0] = kernel_ies_interp(kernel_globals, handle->svm_slot, s, t);
+ status = true;
+ break;
}
- else {
- status = ts->texture(filename,
- options,
- s,
- t,
- dsdx,
- dtdx,
- dsdy,
- dtdy,
- nchannels,
- result,
- dresultds,
- dresultdt);
+ case OSLTextureHandle::OIIO: {
+ /* OpenImageIO texture cache. */
+ OSL::TextureSystem *ts = osl_ts;
+
+ if (handle && handle->oiio_handle) {
+ if (texture_thread_info == NULL) {
+ OSLThreadData *tdata = kernel_globals->osl_tdata;
+ texture_thread_info = tdata->oiio_thread_info;
+ }
+
+ status = ts->texture(handle->oiio_handle,
+ texture_thread_info,
+ options,
+ s,
+ t,
+ dsdx,
+ dtdx,
+ dsdy,
+ dtdy,
+ nchannels,
+ result,
+ dresultds,
+ dresultdt);
+ }
+ else {
+ status = ts->texture(filename,
+ options,
+ s,
+ t,
+ dsdx,
+ dtdx,
+ dsdy,
+ dtdy,
+ nchannels,
+ result,
+ dresultds,
+ dresultdt);
+ }
+
+ if (!status) {
+ /* This might be slow, but prevents error messages leak and
+ * other nasty stuff happening. */
+ ts->geterror();
+ }
+ else if (handle && handle->processor) {
+ ColorSpaceManager::to_scene_linear(handle->processor, result, nchannels);
+ }
+ break;
}
}
@@ -1131,11 +1133,6 @@ bool OSLRenderServices::texture(ustring filename,
if (nchannels == 4)
result[3] = 1.0f;
}
- /* This might be slow, but prevents error messages leak and
- * other nasty stuff happening.
- */
- string err = ts->geterror();
- (void)err;
}
return status;
@@ -1157,56 +1154,79 @@ bool OSLRenderServices::texture3d(ustring filename,
float *dresultdr,
ustring *errormessage)
{
- OSL::TextureSystem *ts = osl_ts;
- ShaderData *sd = (ShaderData *)(sg->renderstate);
- KernelGlobals *kg = sd->osl_globals;
+ OSLTextureHandle *handle = (OSLTextureHandle *)texture_handle;
+ OSLTextureHandle::Type texture_type = (handle) ? handle->type : OSLTextureHandle::OIIO;
+ bool status = false;
- if (texture_thread_info == NULL) {
- OSLThreadData *tdata = kg->osl_tdata;
- texture_thread_info = tdata->oiio_thread_info;
- }
+ switch (texture_type) {
+ case OSLTextureHandle::SVM: {
+ /* Packed texture. */
+ int slot = handle->svm_slot;
+ float4 rgba = kernel_tex_image_interp_3d(
+ kernel_globals, slot, P.x, P.y, P.z, INTERPOLATION_NONE);
- bool status;
- if (filename.length() && filename[0] == '@') {
- int slot = atoi(filename.c_str() + 1);
- float4 rgba = kernel_tex_image_interp_3d(kg, slot, P.x, P.y, P.z, INTERPOLATION_NONE);
+ result[0] = rgba[0];
+ if (nchannels > 1)
+ result[1] = rgba[1];
+ if (nchannels > 2)
+ result[2] = rgba[2];
+ if (nchannels > 3)
+ result[3] = rgba[3];
+ status = true;
+ break;
+ }
+ case OSLTextureHandle::OIIO: {
+ /* OpenImageIO texture cache. */
+ OSL::TextureSystem *ts = osl_ts;
+
+ if (handle && handle->oiio_handle) {
+ if (texture_thread_info == NULL) {
+ OSLThreadData *tdata = kernel_globals->osl_tdata;
+ texture_thread_info = tdata->oiio_thread_info;
+ }
- result[0] = rgba[0];
- if (nchannels > 1)
- result[1] = rgba[1];
- if (nchannels > 2)
- result[2] = rgba[2];
- if (nchannels > 3)
- result[3] = rgba[3];
- status = true;
- }
- else {
- if (texture_handle != NULL) {
- status = ts->texture3d(texture_handle,
- texture_thread_info,
- options,
- P,
- dPdx,
- dPdy,
- dPdz,
- nchannels,
- result,
- dresultds,
- dresultdt,
- dresultdr);
+ status = ts->texture3d(handle->oiio_handle,
+ texture_thread_info,
+ options,
+ P,
+ dPdx,
+ dPdy,
+ dPdz,
+ nchannels,
+ result,
+ dresultds,
+ dresultdt,
+ dresultdr);
+ }
+ else {
+ status = ts->texture3d(filename,
+ options,
+ P,
+ dPdx,
+ dPdy,
+ dPdz,
+ nchannels,
+ result,
+ dresultds,
+ dresultdt,
+ dresultdr);
+ }
+
+ if (!status) {
+ /* This might be slow, but prevents error messages leak and
+ * other nasty stuff happening. */
+ ts->geterror();
+ }
+ else if (handle && handle->processor) {
+ ColorSpaceManager::to_scene_linear(handle->processor, result, nchannels);
+ }
+ break;
}
- else {
- status = ts->texture3d(filename,
- options,
- P,
- dPdx,
- dPdy,
- dPdz,
- nchannels,
- result,
- dresultds,
- dresultdt,
- dresultdr);
+ case OSLTextureHandle::IES:
+ case OSLTextureHandle::AO:
+ case OSLTextureHandle::BEVEL: {
+ status = false;
+ break;
}
}
@@ -1219,18 +1239,13 @@ bool OSLRenderServices::texture3d(ustring filename,
if (nchannels == 4)
result[3] = 1.0f;
}
- /* This might be slow, but prevents error messages leak and
- * other nasty stuff happening.
- */
- string err = ts->geterror();
- (void)err;
}
return status;
}
bool OSLRenderServices::environment(ustring filename,
- TextureHandle *th,
+ TextureHandle *texture_handle,
TexturePerthread *thread_info,
TextureOpt &options,
OSL::ShaderGlobals *sg,
@@ -1243,21 +1258,31 @@ bool OSLRenderServices::environment(ustring filename,
float *dresultdt,
ustring *errormessage)
{
+ OSLTextureHandle *handle = (OSLTextureHandle *)texture_handle;
OSL::TextureSystem *ts = osl_ts;
+ bool status = false;
- if (thread_info == NULL) {
- ShaderData *sd = (ShaderData *)(sg->renderstate);
- KernelGlobals *kg = sd->osl_globals;
- OSLThreadData *tdata = kg->osl_tdata;
- thread_info = tdata->oiio_thread_info;
- }
+ if (handle && handle->oiio_handle) {
+ if (thread_info == NULL) {
+ OSLThreadData *tdata = kernel_globals->osl_tdata;
+ thread_info = tdata->oiio_thread_info;
+ }
- if (th == NULL) {
- th = ts->get_texture_handle(filename, thread_info);
+ status = ts->environment(handle->oiio_handle,
+ thread_info,
+ options,
+ R,
+ dRdx,
+ dRdy,
+ nchannels,
+ result,
+ dresultds,
+ dresultdt);
+ }
+ else {
+ status = ts->environment(
+ filename, options, R, dRdx, dRdy, nchannels, result, dresultds, dresultdt);
}
-
- bool status = ts->environment(
- th, thread_info, options, R, dRdx, dRdy, nchannels, result, dresultds, dresultdt);
if (!status) {
if (nchannels == 3 || nchannels == 4) {
@@ -1269,26 +1294,31 @@ bool OSLRenderServices::environment(ustring filename,
result[3] = 1.0f;
}
}
+ else if (handle && handle->processor) {
+ ColorSpaceManager::to_scene_linear(handle->processor, result, nchannels);
+ }
return status;
}
bool OSLRenderServices::get_texture_info(OSL::ShaderGlobals *sg,
ustring filename,
- TextureHandle *th,
+ TextureHandle *texture_handle,
int subimage,
ustring dataname,
TypeDesc datatype,
void *data)
{
- OSL::TextureSystem *ts = osl_ts;
- if (filename.length() && filename[0] == '@') {
- /* Special builtin textures. */
+ OSLTextureHandle *handle = (OSLTextureHandle *)texture_handle;
+
+ /* No texture info for other texture types. */
+ if (handle && handle->type != OSLTextureHandle::OIIO) {
return false;
}
- else {
- return ts->get_texture_info(filename, subimage, dataname, datatype, data);
- }
+
+ /* Get texture info from OpenImageIO. */
+ OSL::TextureSystem *ts = osl_ts;
+ return ts->get_texture_info(filename, subimage, dataname, datatype, data);
}
int OSLRenderServices::pointcloud_search(OSL::ShaderGlobals *sg,
@@ -1369,11 +1399,10 @@ bool OSLRenderServices::trace(TraceOpt &options,
tracedata->ray = ray;
tracedata->setup = false;
tracedata->init = true;
- tracedata->sd.osl_globals = sd->osl_globals;
/* Raytrace, leaving out shadow opaque to avoid early exit. */
uint visibility = PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE;
- return scene_intersect(sd->osl_globals, ray, visibility, &tracedata->isect, NULL, 0.0f, 0.0f);
+ return scene_intersect(kernel_globals, ray, visibility, &tracedata->isect);
}
bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg,
@@ -1396,11 +1425,10 @@ bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg,
}
else {
ShaderData *sd = &tracedata->sd;
- KernelGlobals *kg = sd->osl_globals;
if (!tracedata->setup) {
/* lazy shader data setup */
- shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray);
+ shader_setup_from_ray(kernel_globals, sd, &tracedata->isect, &tracedata->ray);
tracedata->setup = true;
}
diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h
index 2fad5833fc9..e881e528fc5 100644
--- a/intern/cycles/kernel/osl/osl_services.h
+++ b/intern/cycles/kernel/osl/osl_services.h
@@ -45,7 +45,7 @@ class OSLRenderServices : public OSL::RendererServices {
OSLRenderServices();
~OSLRenderServices();
- void thread_init(KernelGlobals *kernel_globals, OSL::TextureSystem *ts);
+ void thread_init(KernelGlobals *kernel_globals, OSLGlobals *osl_globals, OSL::TextureSystem *ts);
bool get_matrix(OSL::ShaderGlobals *sg,
OSL::Matrix44 &result,
@@ -257,6 +257,7 @@ class OSLRenderServices : public OSL::RendererServices {
private:
KernelGlobals *kernel_globals;
+ OSLGlobals *osl_globals;
OSL::TextureSystem *osl_ts;
#ifdef WITH_PTEX
PtexCache *ptex_cache;
diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp
index 3d9c579c9ff..69599825bc0 100644
--- a/intern/cycles/kernel/osl/osl_shader.cpp
+++ b/intern/cycles/kernel/osl/osl_shader.cpp
@@ -49,7 +49,7 @@ void OSLShader::thread_init(KernelGlobals *kg,
/* per thread kernel data init*/
kg->osl = osl_globals;
- kg->osl->services->thread_init(kernel_globals, osl_globals->ts);
+ kg->osl->services->thread_init(kernel_globals, osl_globals, osl_globals->ts);
OSL::ShadingSystem *ss = kg->osl->ss;
OSLThreadData *tdata = new OSLThreadData();
@@ -129,13 +129,13 @@ static void shaderdata_to_shaderglobals(
tdata->tracedata.init = false;
/* used by renderservices */
- sd->osl_globals = kg;
sd->osl_path_state = state;
}
/* Surface */
-static void flatten_surface_closure_tree(ShaderData *sd,
+static void flatten_surface_closure_tree(KernelGlobals *kg,
+ ShaderData *sd,
int path_flag,
const OSL::ClosureColor *closure,
float3 weight = make_float3(1.0f, 1.0f, 1.0f))
@@ -146,13 +146,14 @@ static void flatten_surface_closure_tree(ShaderData *sd,
switch (closure->id) {
case OSL::ClosureColor::MUL: {
OSL::ClosureMul *mul = (OSL::ClosureMul *)closure;
- flatten_surface_closure_tree(sd, path_flag, mul->closure, TO_FLOAT3(mul->weight) * weight);
+ flatten_surface_closure_tree(
+ kg, sd, path_flag, mul->closure, TO_FLOAT3(mul->weight) * weight);
break;
}
case OSL::ClosureColor::ADD: {
OSL::ClosureAdd *add = (OSL::ClosureAdd *)closure;
- flatten_surface_closure_tree(sd, path_flag, add->closureA, weight);
- flatten_surface_closure_tree(sd, path_flag, add->closureB, weight);
+ flatten_surface_closure_tree(kg, sd, path_flag, add->closureA, weight);
+ flatten_surface_closure_tree(kg, sd, path_flag, add->closureB, weight);
break;
}
default: {
@@ -163,7 +164,7 @@ static void flatten_surface_closure_tree(ShaderData *sd,
#ifdef OSL_SUPPORTS_WEIGHTED_CLOSURE_COMPONENTS
weight = weight * TO_FLOAT3(comp->w);
#endif
- prim->setup(sd, path_flag, weight);
+ prim->setup(kg, sd, path_flag, weight);
}
break;
}
@@ -234,12 +235,13 @@ void OSLShader::eval_surface(KernelGlobals *kg, ShaderData *sd, PathState *state
/* flatten closure tree */
if (globals->Ci)
- flatten_surface_closure_tree(sd, path_flag, globals->Ci);
+ flatten_surface_closure_tree(kg, sd, path_flag, globals->Ci);
}
/* Background */
-static void flatten_background_closure_tree(ShaderData *sd,
+static void flatten_background_closure_tree(KernelGlobals *kg,
+ ShaderData *sd,
const OSL::ClosureColor *closure,
float3 weight = make_float3(1.0f, 1.0f, 1.0f))
{
@@ -250,14 +252,14 @@ static void flatten_background_closure_tree(ShaderData *sd,
switch (closure->id) {
case OSL::ClosureColor::MUL: {
OSL::ClosureMul *mul = (OSL::ClosureMul *)closure;
- flatten_background_closure_tree(sd, mul->closure, weight * TO_FLOAT3(mul->weight));
+ flatten_background_closure_tree(kg, sd, mul->closure, weight * TO_FLOAT3(mul->weight));
break;
}
case OSL::ClosureColor::ADD: {
OSL::ClosureAdd *add = (OSL::ClosureAdd *)closure;
- flatten_background_closure_tree(sd, add->closureA, weight);
- flatten_background_closure_tree(sd, add->closureB, weight);
+ flatten_background_closure_tree(kg, sd, add->closureA, weight);
+ flatten_background_closure_tree(kg, sd, add->closureB, weight);
break;
}
default: {
@@ -268,7 +270,7 @@ static void flatten_background_closure_tree(ShaderData *sd,
#ifdef OSL_SUPPORTS_WEIGHTED_CLOSURE_COMPONENTS
weight = weight * TO_FLOAT3(comp->w);
#endif
- prim->setup(sd, 0, weight);
+ prim->setup(kg, sd, 0, weight);
}
break;
}
@@ -292,12 +294,13 @@ void OSLShader::eval_background(KernelGlobals *kg, ShaderData *sd, PathState *st
/* return background color immediately */
if (globals->Ci)
- flatten_background_closure_tree(sd, globals->Ci);
+ flatten_background_closure_tree(kg, sd, globals->Ci);
}
/* Volume */
-static void flatten_volume_closure_tree(ShaderData *sd,
+static void flatten_volume_closure_tree(KernelGlobals *kg,
+ ShaderData *sd,
const OSL::ClosureColor *closure,
float3 weight = make_float3(1.0f, 1.0f, 1.0f))
{
@@ -307,13 +310,13 @@ static void flatten_volume_closure_tree(ShaderData *sd,
switch (closure->id) {
case OSL::ClosureColor::MUL: {
OSL::ClosureMul *mul = (OSL::ClosureMul *)closure;
- flatten_volume_closure_tree(sd, mul->closure, TO_FLOAT3(mul->weight) * weight);
+ flatten_volume_closure_tree(kg, sd, mul->closure, TO_FLOAT3(mul->weight) * weight);
break;
}
case OSL::ClosureColor::ADD: {
OSL::ClosureAdd *add = (OSL::ClosureAdd *)closure;
- flatten_volume_closure_tree(sd, add->closureA, weight);
- flatten_volume_closure_tree(sd, add->closureB, weight);
+ flatten_volume_closure_tree(kg, sd, add->closureA, weight);
+ flatten_volume_closure_tree(kg, sd, add->closureB, weight);
break;
}
default: {
@@ -324,7 +327,7 @@ static void flatten_volume_closure_tree(ShaderData *sd,
#ifdef OSL_SUPPORTS_WEIGHTED_CLOSURE_COMPONENTS
weight = weight * TO_FLOAT3(comp->w);
#endif
- prim->setup(sd, 0, weight);
+ prim->setup(kg, sd, 0, weight);
}
}
}
@@ -348,7 +351,7 @@ void OSLShader::eval_volume(KernelGlobals *kg, ShaderData *sd, PathState *state,
/* flatten closure tree */
if (globals->Ci)
- flatten_volume_closure_tree(sd, globals->Ci);
+ flatten_volume_closure_tree(kg, sd, globals->Ci);
}
/* Displacement */
diff --git a/intern/cycles/kernel/shaders/node_ies_light.osl b/intern/cycles/kernel/shaders/node_ies_light.osl
index ea8c44e09de..ce0173451da 100644
--- a/intern/cycles/kernel/shaders/node_ies_light.osl
+++ b/intern/cycles/kernel/shaders/node_ies_light.osl
@@ -21,7 +21,7 @@
shader node_ies_light(int use_mapping = 0,
matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- int slot = 0,
+ string filename = "",
float Strength = 1.0,
point Vector = I,
output float Fac = 0.0)
@@ -37,5 +37,5 @@ shader node_ies_light(int use_mapping = 0,
float v_angle = acos(-p[2]);
float h_angle = atan2(p[0], p[1]) + M_PI;
- Fac = Strength * texture(format("@l%d", slot), h_angle, v_angle);
+ Fac = Strength * texture(filename, h_angle, v_angle);
}
diff --git a/intern/cycles/kernel/shaders/stdosl.h b/intern/cycles/kernel/shaders/stdosl.h
index 2762b414ce4..6515d914909 100644
--- a/intern/cycles/kernel/shaders/stdosl.h
+++ b/intern/cycles/kernel/shaders/stdosl.h
@@ -387,14 +387,14 @@ point rotate(point p, float angle, point a, point b)
vector axis = normalize(b - a);
float cosang, sinang;
/* Older OSX has major issues with sincos() function,
- * it's likely a big in OSL or LLVM. For until we've
- * updated to new versions of this libraries we'll
- * use a workaround to prevent possible crashes on all
- * the platforms.
- *
- * Shouldn't be that bad because it's mainly used for
- * anisotropic shader where angle is usually constant.
- */
+ * it's likely a big in OSL or LLVM. For until we've
+ * updated to new versions of this libraries we'll
+ * use a workaround to prevent possible crashes on all
+ * the platforms.
+ *
+ * Shouldn't be that bad because it's mainly used for
+ * anisotropic shader where angle is usually constant.
+ */
#if 0
sincos(angle, sinang, cosang);
#else
@@ -425,7 +425,7 @@ point rotate(point p, float angle, point a, point b)
normal ensure_valid_reflection(normal Ng, vector I, normal N)
{
/* The implementation here mirrors the one in kernel_montecarlo.h,
- * check there for an explanation of the algorithm. */
+ * check there for an explanation of the algorithm. */
float sqr(float x)
{
diff --git a/intern/cycles/kernel/split/kernel_buffer_update.h b/intern/cycles/kernel/split/kernel_buffer_update.h
index e77743350dc..e37be5b405e 100644
--- a/intern/cycles/kernel/split/kernel_buffer_update.h
+++ b/intern/cycles/kernel/split/kernel_buffer_update.h
@@ -132,8 +132,8 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg,
if (ray->t != 0.0f) {
/* Initialize throughput, path radiance, Ray, PathState;
- * These rays proceed with path-iteration.
- */
+ * These rays proceed with path-iteration.
+ */
*throughput = make_float3(1.0f, 1.0f, 1.0f);
path_radiance_init(L, kernel_data.film.use_light_pass);
path_state_init(kg,
diff --git a/intern/cycles/kernel/split/kernel_data_init.h b/intern/cycles/kernel/split/kernel_data_init.h
index 52930843f56..2f83a10316d 100644
--- a/intern/cycles/kernel/split/kernel_data_init.h
+++ b/intern/cycles/kernel/split/kernel_data_init.h
@@ -46,10 +46,10 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)(
int sh,
int offset,
int stride,
- ccl_global int *Queue_index, /* Tracks the number of elements in queues */
- int queuesize, /* size (capacity) of the queue */
- ccl_global char *
- use_queues_flag, /* flag to decide if scene-intersect kernel should use queues to fetch ray index */
+ ccl_global int *Queue_index, /* Tracks the number of elements in queues */
+ int queuesize, /* size (capacity) of the queue */
+ ccl_global char *use_queues_flag, /* flag to decide if scene-intersect kernel should use queues
+ to fetch ray index */
ccl_global unsigned int *work_pools, /* Work pool for each work group */
unsigned int num_samples,
ccl_global float *buffer)
diff --git a/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h b/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h
index 63bc5a8e0ce..5cd4131e2ae 100644
--- a/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h
+++ b/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h
@@ -114,9 +114,9 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(
if (IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
/* Path termination. this is a strange place to put the termination, it's
- * mainly due to the mixed in MIS that we use. gives too many unneeded
- * shader evaluations, only need emission if we are going to terminate.
- */
+ * mainly due to the mixed in MIS that we use. gives too many unneeded
+ * shader evaluations, only need emission if we are going to terminate.
+ */
float probability = path_state_continuation_probability(kg, state, throughput);
if (probability == 0.0f) {
diff --git a/intern/cycles/kernel/split/kernel_next_iteration_setup.h b/intern/cycles/kernel/split/kernel_next_iteration_setup.h
index 781ce869374..3c2f6038035 100644
--- a/intern/cycles/kernel/split/kernel_next_iteration_setup.h
+++ b/intern/cycles/kernel/split/kernel_next_iteration_setup.h
@@ -109,9 +109,9 @@ ccl_device void kernel_next_iteration_setup(KernelGlobals *kg,
if (ccl_global_id(0) == 0 && ccl_global_id(1) == 0) {
/* If we are here, then it means that scene-intersect kernel
- * has already been executed atleast once. From the next time,
- * scene-intersect kernel may operate on queues to fetch ray index
- */
+ * has already been executed atleast once. From the next time,
+ * scene-intersect kernel may operate on queues to fetch ray index
+ */
*kernel_split_params.use_queues_flag = 1;
/* Mark queue indices of QUEUE_SHADOW_RAY_CAST_AO_RAYS and
diff --git a/intern/cycles/kernel/split/kernel_split_data_types.h b/intern/cycles/kernel/split/kernel_split_data_types.h
index 6ff3f5bdb55..ac4a450ca2b 100644
--- a/intern/cycles/kernel/split/kernel_split_data_types.h
+++ b/intern/cycles/kernel/split/kernel_split_data_types.h
@@ -19,7 +19,8 @@
CCL_NAMESPACE_BEGIN
-/* parameters used by the split kernels, we use a single struct to avoid passing these to each kernel */
+/* parameters used by the split kernels, we use a single struct to avoid passing these to each
+ * kernel */
typedef struct SplitParams {
WorkTile tile;
@@ -112,7 +113,8 @@ typedef ccl_global struct SplitBranchedState {
SPLIT_DATA_BRANCHED_ENTRIES \
SPLIT_DATA_ENTRY(ShaderData, _sd, 0)
-/* entries to be copied to inactive rays when sharing branched samples (TODO: which are actually needed?) */
+/* Entries to be copied to inactive rays when sharing branched samples
+ * (TODO: which are actually needed?) */
#define SPLIT_DATA_ENTRIES_BRANCHED_SHARED \
SPLIT_DATA_ENTRY(ccl_global float3, throughput, 1) \
SPLIT_DATA_ENTRY(PathRadiance, path_radiance, 1) \
@@ -134,8 +136,9 @@ typedef struct SplitData {
SPLIT_DATA_ENTRIES
#undef SPLIT_DATA_ENTRY
- /* this is actually in a separate buffer from the rest of the split state data (so it can be read back from
- * the host easily) but is still used the same as the other data so we have it here in this struct as well
+ /* this is actually in a separate buffer from the rest of the split state data (so it can be read
+ * back from the host easily) but is still used the same as the other data so we have it here in
+ * this struct as well
*/
ccl_global char *ray_state;
} SplitData;
diff --git a/intern/cycles/kernel/svm/svm_ao.h b/intern/cycles/kernel/svm/svm_ao.h
index 06076175c40..62413979201 100644
--- a/intern/cycles/kernel/svm/svm_ao.h
+++ b/intern/cycles/kernel/svm/svm_ao.h
@@ -1,18 +1,18 @@
/*
-* 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.
-*/
+ * 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.
+ */
CCL_NAMESPACE_BEGIN
@@ -70,7 +70,7 @@ ccl_device_noinline float svm_ao(KernelGlobals *kg,
}
else {
Intersection isect;
- if (!scene_intersect(kg, ray, PATH_RAY_SHADOW_OPAQUE, &isect, NULL, 0.0f, 0.0f)) {
+ if (!scene_intersect(kg, ray, PATH_RAY_SHADOW_OPAQUE, &isect)) {
unoccluded++;
}
}
diff --git a/intern/cycles/kernel/svm/svm_ies.h b/intern/cycles/kernel/svm/svm_ies.h
index 9434c0c5505..f13527c03db 100644
--- a/intern/cycles/kernel/svm/svm_ies.h
+++ b/intern/cycles/kernel/svm/svm_ies.h
@@ -21,12 +21,12 @@ CCL_NAMESPACE_BEGIN
ccl_device_inline float interpolate_ies_vertical(
KernelGlobals *kg, int ofs, int v, int v_num, float v_frac, int h)
{
- /* Since lookups are performed in spherical coordinates, clamping the coordinates at the low end of v
- * (corresponding to the north pole) would result in artifacts.
- * The proper way of dealing with this would be to lookup the corresponding value on the other side of the pole,
- * but since the horizontal coordinates might be nonuniform, this would require yet another interpolation.
- * Therefore, the assumtion is made that the light is going to be symmetrical, which means that we can just take
- * the corresponding value at the current horizontal coordinate. */
+ /* Since lookups are performed in spherical coordinates, clamping the coordinates at the low end
+ * of v (corresponding to the north pole) would result in artifacts. The proper way of dealing
+ * with this would be to lookup the corresponding value on the other side of the pole, but since
+ * the horizontal coordinates might be nonuniform, this would require yet another interpolation.
+ * Therefore, the assumtion is made that the light is going to be symmetrical, which means that
+ * we can just take the corresponding value at the current horizontal coordinate. */
#define IES_LOOKUP(v) kernel_tex_fetch(__ies, ofs + h * v_num + (v))
/* If v is zero, assume symmetry and read at v=1 instead of v=-1. */
@@ -66,7 +66,8 @@ ccl_device_inline float kernel_ies_interp(KernelGlobals *kg,
/* Lookup the angles to find the table position. */
int h_i, v_i;
- /* TODO(lukas): Consider using bisection. Probably not worth it for the vast majority of IES files. */
+ /* TODO(lukas): Consider using bisection.
+ * Probably not worth it for the vast majority of IES files. */
for (h_i = 0; IES_LOOKUP_ANGLE_H(h_i + 1) < h_angle; h_i++)
;
for (v_i = 0; IES_LOOKUP_ANGLE_V(v_i + 1) < v_angle; v_i++)
@@ -83,7 +84,8 @@ ccl_device_inline float kernel_ies_interp(KernelGlobals *kg,
/* Perform cubic interpolation along the horizontal coordinate to get the intensity value.
* If h_i is zero, just wrap around since the horizontal angles always go over the full circle.
- * However, the last entry (360°) equals the first one, so we need to wrap around to the one before that. */
+ * However, the last entry (360°) equals the first one, so we need to wrap around to the one
+ * before that. */
float a = interpolate_ies_vertical(
kg, ofs, v_i, v_num, v_frac, (h_i == 0) ? h_num - 2 : h_i - 1);
float b = interpolate_ies_vertical(kg, ofs, v_i, v_num, v_frac, h_i);
diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h
index d31e4f93696..2e4d0c81b95 100644
--- a/intern/cycles/kernel/svm/svm_types.h
+++ b/intern/cycles/kernel/svm/svm_types.h
@@ -373,11 +373,6 @@ typedef enum NodeNormalMapSpace {
NODE_NORMAL_MAP_BLENDER_WORLD,
} NodeNormalMapSpace;
-typedef enum NodeImageColorSpace {
- NODE_COLOR_SPACE_NONE = 0,
- NODE_COLOR_SPACE_COLOR = 1,
-} NodeImageColorSpace;
-
typedef enum NodeImageProjection {
NODE_IMAGE_PROJ_FLAT = 0,
NODE_IMAGE_PROJ_BOX = 1,
diff --git a/intern/cycles/kernel/svm/svm_voronoi.h b/intern/cycles/kernel/svm/svm_voronoi.h
index c311aefaf38..3e28a316169 100644
--- a/intern/cycles/kernel/svm/svm_voronoi.h
+++ b/intern/cycles/kernel/svm/svm_voronoi.h
@@ -70,7 +70,8 @@ ccl_device void voronoi_neighbors(
}
}
- /* To keep the shortest four distances and associated points we have to keep them in sorted order. */
+ /* To keep the shortest four distances and associated points we have to keep them in sorted
+ * order. */
if (d < da[0]) {
da[3] = da[2];
da[2] = da[1];
diff --git a/intern/cycles/render/CMakeLists.txt b/intern/cycles/render/CMakeLists.txt
index 378957d21f4..c79e5a23ea1 100644
--- a/intern/cycles/render/CMakeLists.txt
+++ b/intern/cycles/render/CMakeLists.txt
@@ -14,6 +14,7 @@ set(SRC
bake.cpp
buffers.cpp
camera.cpp
+ colorspace.cpp
constant_fold.cpp
coverage.cpp
denoising.cpp
@@ -48,6 +49,7 @@ set(SRC_HEADERS
background.h
buffers.h
camera.h
+ colorspace.h
constant_fold.h
coverage.h
denoising.h
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp
index dad6cb4fe6d..f1341d50b9d 100644
--- a/intern/cycles/render/attribute.cpp
+++ b/intern/cycles/render/attribute.cpp
@@ -251,6 +251,9 @@ void Attribute::add_with_weight(void *dst, void *src, float weight)
else if (same_storage(type, TypeDesc::TypeFloat)) {
*((float *)dst) += *((float *)src) * weight;
}
+ else if (same_storage(type, TypeFloat2)) {
+ *((float2 *)dst) += *((float2 *)src) * weight;
+ }
else if (same_storage(type, TypeDesc::TypeVector)) {
*((float4 *)dst) += *((float4 *)src) * weight;
}
diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp
index a950324d4d4..baa3ce77f84 100644
--- a/intern/cycles/render/camera.cpp
+++ b/intern/cycles/render/camera.cpp
@@ -642,7 +642,8 @@ float Camera::world_to_raster_size(float3 P)
float3 D = normalize(Ddiff);
res = len(dist * dDdx - dot(dist * dDdx, D) * D);
- /* Decent approx distance to frustum (doesn't handle corners correctly, but not that big of a deal) */
+ /* Decent approx distance to frustum
+ * (doesn't handle corners correctly, but not that big of a deal) */
float f_dist = 0.0f;
if (offscreen_dicing_scale > 1.0f) {
@@ -686,7 +687,8 @@ float Camera::world_to_raster_size(float3 P)
f_dist = max(f_dist, *d);
}
else {
- /* Possibly far enough behind the frustum to use distance to origin instead of edge */
+ /* Possibly far enough behind the frustum to use distance to origin instead of edge
+ */
test_o = true;
}
}
diff --git a/intern/cycles/render/colorspace.cpp b/intern/cycles/render/colorspace.cpp
new file mode 100644
index 00000000000..cbfcf774a15
--- /dev/null
+++ b/intern/cycles/render/colorspace.cpp
@@ -0,0 +1,374 @@
+/*
+ * Copyright 2011-2013 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 "render/colorspace.h"
+
+#include "util/util_color.h"
+#include "util/util_image.h"
+#include "util/util_half.h"
+#include "util/util_logging.h"
+#include "util/util_math.h"
+#include "util/util_thread.h"
+#include "util/util_vector.h"
+
+#ifdef WITH_OCIO
+# include <OpenColorIO/OpenColorIO.h>
+namespace OCIO = OCIO_NAMESPACE;
+#endif
+
+CCL_NAMESPACE_BEGIN
+
+/* Builtin colorspaces. */
+ustring u_colorspace_auto;
+ustring u_colorspace_raw("__builtin_raw");
+ustring u_colorspace_srgb("__builtin_srgb");
+
+/* Cached data. */
+#ifdef WITH_OCIO
+static thread_mutex cache_mutex;
+static unordered_map<ustring, ustring, ustringHash> cached_colorspaces;
+static unordered_map<ustring, OCIO::ConstProcessorRcPtr, ustringHash> cached_processors;
+#endif
+
+ColorSpaceProcessor *ColorSpaceManager::get_processor(ustring colorspace)
+{
+#ifdef WITH_OCIO
+ /* Only use this for OpenColorIO color spaces, not the builtin ones. */
+ assert(colorspace != u_colorspace_srgb && colorspace != u_colorspace_auto);
+
+ if (colorspace == u_colorspace_raw) {
+ return NULL;
+ }
+
+ OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
+ if (!config) {
+ return NULL;
+ }
+
+ /* Cache processor until free_memory(), memory overhead is expected to be
+ * small and the processor is likely to be reused. */
+ thread_scoped_lock cache_lock(cache_mutex);
+ if (cached_processors.find(colorspace) == cached_processors.end()) {
+ try {
+ cached_processors[colorspace] = config->getProcessor(colorspace.c_str(), "scene_linear");
+ }
+ catch (OCIO::Exception &exception) {
+ cached_processors[colorspace] = OCIO::ConstProcessorRcPtr();
+ VLOG(1) << "Colorspace " << colorspace.c_str()
+ << " can't be converted to scene_linear: " << exception.what();
+ }
+ }
+
+ const OCIO::Processor *processor = cached_processors[colorspace].get();
+ return (ColorSpaceProcessor *)processor;
+#else
+ /* No OpenColorIO. */
+ (void)colorspace;
+ return NULL;
+#endif
+}
+
+ustring ColorSpaceManager::detect_known_colorspace(ustring colorspace,
+ const char *file_format,
+ bool is_float)
+{
+ if (colorspace == u_colorspace_auto) {
+ /* Auto detect sRGB or raw if none specified. */
+ if (is_float) {
+ bool srgb = (colorspace == "sRGB" || colorspace == "GammaCorrected" ||
+ (colorspace.empty() &&
+ (strcmp(file_format, "png") == 0 || strcmp(file_format, "tiff") == 0 ||
+ strcmp(file_format, "dpx") == 0 || strcmp(file_format, "jpeg2000") == 0)));
+ return srgb ? u_colorspace_srgb : u_colorspace_raw;
+ }
+ else {
+ return u_colorspace_srgb;
+ }
+ }
+ else if (colorspace == u_colorspace_srgb || colorspace == u_colorspace_raw) {
+ /* Builtin colorspaces. */
+ return colorspace;
+ }
+ else {
+ /* Use OpenColorIO. */
+#ifdef WITH_OCIO
+ {
+ thread_scoped_lock cache_lock(cache_mutex);
+ /* Cached lookup. */
+ if (cached_colorspaces.find(colorspace) != cached_colorspaces.end()) {
+ return cached_colorspaces[colorspace];
+ }
+ }
+
+ /* Detect if it matches a simple builtin colorspace. */
+ bool is_no_op, is_srgb;
+ is_builtin_colorspace(colorspace, is_no_op, is_srgb);
+
+ thread_scoped_lock cache_lock(cache_mutex);
+ if (is_no_op) {
+ VLOG(1) << "Colorspace " << colorspace.string() << " is no-op";
+ cached_colorspaces[colorspace] = u_colorspace_raw;
+ return u_colorspace_raw;
+ }
+ else if (is_srgb) {
+ VLOG(1) << "Colorspace " << colorspace.string() << " is sRGB";
+ cached_colorspaces[colorspace] = u_colorspace_srgb;
+ return u_colorspace_srgb;
+ }
+
+ /* Verify if we can convert from the requested color space. */
+ if (!get_processor(colorspace)) {
+ OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
+ if (!config || !config->getColorSpace(colorspace.c_str())) {
+ VLOG(1) << "Colorspace " << colorspace.c_str() << " not found, using raw instead";
+ }
+ else {
+ VLOG(1) << "Colorspace " << colorspace.c_str()
+ << " can't be converted to scene_linear, using raw instead";
+ }
+ cached_colorspaces[colorspace] = u_colorspace_raw;
+ return u_colorspace_raw;
+ }
+
+ /* Convert to/from colorspace with OpenColorIO. */
+ VLOG(1) << "Colorspace " << colorspace.string() << " handled through OpenColorIO";
+ cached_colorspaces[colorspace] = colorspace;
+ return colorspace;
+#else
+ VLOG(1) << "Colorspace " << colorspace.c_str() << " not available, built without OpenColorIO";
+ return u_colorspace_raw;
+#endif
+ }
+}
+
+void ColorSpaceManager::is_builtin_colorspace(ustring colorspace, bool &is_no_op, bool &is_srgb)
+{
+#ifdef WITH_OCIO
+ const OCIO::Processor *processor = (const OCIO::Processor *)get_processor(colorspace);
+ if (!processor) {
+ is_no_op = false;
+ is_srgb = false;
+ return;
+ }
+
+ is_no_op = true;
+ is_srgb = true;
+ for (int i = 0; i < 256; i++) {
+ float v = i / 255.0f;
+
+ float cR[3] = {v, 0, 0};
+ float cG[3] = {0, v, 0};
+ float cB[3] = {0, 0, v};
+ float cW[3] = {v, v, v};
+ processor->applyRGB(cR);
+ processor->applyRGB(cG);
+ processor->applyRGB(cB);
+ processor->applyRGB(cW);
+
+ /* Make sure that there is no channel crosstalk. */
+ if (fabsf(cR[1]) > 1e-5f || fabsf(cR[2]) > 1e-5f || fabsf(cG[0]) > 1e-5f ||
+ fabsf(cG[2]) > 1e-5f || fabsf(cB[0]) > 1e-5f || fabsf(cB[1]) > 1e-5f) {
+ is_no_op = false;
+ is_srgb = false;
+ break;
+ }
+ /* Make sure that the three primaries combine linearly. */
+ if (!compare_floats(cR[0], cW[0], 1e-6f, 64) || !compare_floats(cG[1], cW[1], 1e-6f, 64) ||
+ !compare_floats(cB[2], cW[2], 1e-6f, 64)) {
+ is_no_op = false;
+ is_srgb = false;
+ break;
+ }
+ /* Make sure that the three channels behave identically. */
+ if (!compare_floats(cW[0], cW[1], 1e-6f, 64) || !compare_floats(cW[1], cW[2], 1e-6f, 64)) {
+ is_no_op = false;
+ is_srgb = false;
+ break;
+ }
+
+ float out_v = average(make_float3(cW[0], cW[1], cW[2]));
+ if (!compare_floats(v, out_v, 1e-6f, 64)) {
+ is_no_op = false;
+ }
+ if (!compare_floats(color_srgb_to_linear(v), out_v, 1e-6f, 64)) {
+ is_srgb = false;
+ }
+ }
+#else
+ (void)colorspace;
+ is_no_op = false;
+ is_srgb = false;
+#endif
+}
+
+#ifdef WITH_OCIO
+
+template<typename T> inline float4 cast_to_float4(T *data)
+{
+ return make_float4(util_image_cast_to_float(data[0]),
+ util_image_cast_to_float(data[1]),
+ util_image_cast_to_float(data[2]),
+ util_image_cast_to_float(data[3]));
+}
+
+template<typename T> inline void cast_from_float4(T *data, float4 value)
+{
+ data[0] = util_image_cast_from_float<T>(value.x);
+ data[1] = util_image_cast_from_float<T>(value.y);
+ data[2] = util_image_cast_from_float<T>(value.z);
+ data[3] = util_image_cast_from_float<T>(value.w);
+}
+
+/* Slower versions for other all data types, which needs to convert to float and back. */
+template<typename T, bool compress_as_srgb = false>
+inline void processor_apply_pixels(const OCIO::Processor *processor,
+ T *pixels,
+ size_t width,
+ size_t height)
+{
+ /* Process large images in chunks to keep temporary memory requirement down. */
+ size_t y_chunk_size = max(1, 16 * 1024 * 1024 / (sizeof(float4) * width));
+ vector<float4> float_pixels(y_chunk_size * width);
+
+ for (size_t y0 = 0; y0 < height; y0 += y_chunk_size) {
+ size_t y1 = std::min(y0 + y_chunk_size, height);
+ size_t i = 0;
+
+ for (size_t y = y0; y < y1; y++) {
+ for (size_t x = 0; x < width; x++, i++) {
+ float_pixels[i] = cast_to_float4(pixels + 4 * (y * width + x));
+ }
+ }
+
+ OCIO::PackedImageDesc desc((float *)float_pixels.data(), width, y_chunk_size, 4);
+ processor->apply(desc);
+
+ i = 0;
+ for (size_t y = y0; y < y1; y++) {
+ for (size_t x = 0; x < width; x++, i++) {
+ float4 value = float_pixels[i];
+ if (compress_as_srgb) {
+ value = color_linear_to_srgb_v4(value);
+ }
+ cast_from_float4(pixels + 4 * (y * width + x), value);
+ }
+ }
+ }
+}
+
+/* Fast version for float images, which OpenColorIO can handle natively. */
+template<>
+inline void processor_apply_pixels(const OCIO::Processor *processor,
+ float *pixels,
+ size_t width,
+ size_t height)
+{
+ OCIO::PackedImageDesc desc(pixels, width, height, 4);
+ processor->apply(desc);
+}
+#endif
+
+template<typename T>
+void ColorSpaceManager::to_scene_linear(ustring colorspace,
+ T *pixels,
+ size_t width,
+ size_t height,
+ size_t depth,
+ bool compress_as_srgb)
+{
+#ifdef WITH_OCIO
+ const OCIO::Processor *processor = (const OCIO::Processor *)get_processor(colorspace);
+
+ if (processor) {
+ if (compress_as_srgb) {
+ /* Compress output as sRGB. */
+ for (size_t z = 0; z < depth; z++) {
+ processor_apply_pixels<T, true>(processor, &pixels[z * width * height], width, height);
+ }
+ }
+ else {
+ /* Write output as scene linear directly. */
+ for (size_t z = 0; z < depth; z++) {
+ processor_apply_pixels<T>(processor, &pixels[z * width * height], width, height);
+ }
+ }
+ }
+#else
+ (void)colorspace;
+ (void)pixels;
+ (void)width;
+ (void)height;
+ (void)depth;
+ (void)compress_as_srgb;
+#endif
+}
+
+void ColorSpaceManager::to_scene_linear(ColorSpaceProcessor *processor_,
+ float *pixel,
+ int channels)
+{
+#ifdef WITH_OCIO
+ const OCIO::Processor *processor = (const OCIO::Processor *)processor_;
+
+ if (processor) {
+ if (channels == 3) {
+ processor->applyRGB(pixel);
+ }
+ else if (channels == 4) {
+ if (pixel[3] == 1.0f || pixel[3] == 0.0f) {
+ /* Fast path for RGBA. */
+ processor->applyRGB(pixel);
+ }
+ else {
+ /* Unassociate and associate alpha since color management should not
+ * be affected by transparency. */
+ float alpha = pixel[3];
+ float inv_alpha = 1.0f / alpha;
+
+ pixel[0] *= inv_alpha;
+ pixel[1] *= inv_alpha;
+ pixel[2] *= inv_alpha;
+
+ processor->applyRGB(pixel);
+
+ pixel[0] *= alpha;
+ pixel[1] *= alpha;
+ pixel[2] *= alpha;
+ }
+ }
+ }
+#else
+ (void)processor_;
+ (void)pixel;
+ (void)channels;
+#endif
+}
+
+void ColorSpaceManager::free_memory()
+{
+#ifdef WITH_OCIO
+ map_free_memory(cached_colorspaces);
+ map_free_memory(cached_colorspaces);
+#endif
+}
+
+/* Template instanstations so we don't have to inline functions. */
+template void ColorSpaceManager::to_scene_linear(ustring, uchar *, size_t, size_t, size_t, bool);
+template void ColorSpaceManager::to_scene_linear(ustring, ushort *, size_t, size_t, size_t, bool);
+template void ColorSpaceManager::to_scene_linear(ustring, half *, size_t, size_t, size_t, bool);
+template void ColorSpaceManager::to_scene_linear(ustring, float *, size_t, size_t, size_t, bool);
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/render/colorspace.h b/intern/cycles/render/colorspace.h
new file mode 100644
index 00000000000..e7c7f943c2d
--- /dev/null
+++ b/intern/cycles/render/colorspace.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011-2013 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 __COLORSPACE_H__
+#define __COLORSPACE_H__
+
+#include "util/util_map.h"
+#include "util/util_param.h"
+
+CCL_NAMESPACE_BEGIN
+
+extern ustring u_colorspace_auto;
+extern ustring u_colorspace_raw;
+extern ustring u_colorspace_srgb;
+
+class ColorSpaceProcessor;
+
+class ColorSpaceManager {
+ public:
+ /* Convert used specified colorspace to a colorspace that we are able to
+ * convert to and from. If the colorspace is u_colorspace_auto, we auto
+ * detect a colospace. */
+ static ustring detect_known_colorspace(ustring colorspace,
+ const char *file_format,
+ bool is_float);
+
+ /* Convert pixels in the specified colorspace to scene linear color for
+ * rendering. Must be a colorspace returned from detect_known_colorspace. */
+ template<typename T>
+ static void to_scene_linear(ustring colorspace,
+ T *pixels,
+ size_t width,
+ size_t height,
+ size_t depth,
+ bool compress_as_srgb);
+
+ /* Efficiently convert pixels to scene linear colorspace at render time,
+ * for OSL where the image texture cache contains original pixels. The
+ * handle is valid for the lifetime of the application. */
+ static ColorSpaceProcessor *get_processor(ustring colorspace);
+ static void to_scene_linear(ColorSpaceProcessor *processor, float *pixel, int channels);
+
+ /* Clear memory when the application exits. Invalidates all processors. */
+ static void free_memory();
+
+ private:
+ static void is_builtin_colorspace(ustring colorspace, bool &is_no_op, bool &is_srgb);
+};
+
+CCL_NAMESPACE_END
+
+#endif /* __COLORSPACE_H__ */
diff --git a/intern/cycles/render/curves.cpp b/intern/cycles/render/curves.cpp
index 49ab70541c2..66fbc9eb4a8 100644
--- a/intern/cycles/render/curves.cpp
+++ b/intern/cycles/render/curves.cpp
@@ -88,9 +88,6 @@ CurveSystemManager::CurveSystemManager()
resolution = 3;
subdivisions = 3;
- minimum_width = 0.0f;
- maximum_width = 0.0f;
-
use_curves = true;
use_encasing = true;
use_backfacing = false;
@@ -138,8 +135,6 @@ void CurveSystemManager::device_update(Device *device,
if (use_encasing)
kcurve->curveflags |= CURVE_KN_ENCLOSEFILTER;
- kcurve->minimum_width = minimum_width;
- kcurve->maximum_width = maximum_width;
kcurve->subdivisions = subdivisions;
}
@@ -160,8 +155,6 @@ bool CurveSystemManager::modified(const CurveSystemManager &CurveSystemManager)
line_method == CurveSystemManager.line_method && primitive == CurveSystemManager.primitive &&
use_encasing == CurveSystemManager.use_encasing &&
use_tangent_normal_geometry == CurveSystemManager.use_tangent_normal_geometry &&
- minimum_width == CurveSystemManager.minimum_width &&
- maximum_width == CurveSystemManager.maximum_width &&
use_backfacing == CurveSystemManager.use_backfacing &&
triangle_method == CurveSystemManager.triangle_method &&
resolution == CurveSystemManager.resolution && use_curves == CurveSystemManager.use_curves &&
diff --git a/intern/cycles/render/curves.h b/intern/cycles/render/curves.h
index 81e7b4ac88d..ade289a402e 100644
--- a/intern/cycles/render/curves.h
+++ b/intern/cycles/render/curves.h
@@ -92,9 +92,6 @@ class CurveSystemManager {
int resolution;
int subdivisions;
- float minimum_width;
- float maximum_width;
-
bool use_curves;
bool use_encasing;
bool use_backfacing;
diff --git a/intern/cycles/render/denoising.cpp b/intern/cycles/render/denoising.cpp
index c4f21d9c771..82bbfa5f823 100644
--- a/intern/cycles/render/denoising.cpp
+++ b/intern/cycles/render/denoising.cpp
@@ -69,8 +69,8 @@ static void print_progress(int num, int total, int frame, int num_frames)
fflush(stdout);
}
-/* Splits in at its last dot, setting suffix to the part after the dot and in to the part before it.
- * Returns whether a dot was found. */
+/* Splits in at its last dot, setting suffix to the part after the dot and in to the part before
+ * it. Returns whether a dot was found. */
static bool split_last_dot(string &in, string &suffix)
{
size_t pos = in.rfind(".");
@@ -84,9 +84,8 @@ static bool split_last_dot(string &in, string &suffix)
/* Separate channel names as generated by Blender.
* If views is true:
- * Inputs are expected in the form RenderLayer.Pass.View.Channel, sets renderlayer to "RenderLayer.View"
- * Otherwise:
- * Inputs are expected in the form RenderLayer.Pass.Channel */
+ * Inputs are expected in the form RenderLayer.Pass.View.Channel, sets renderlayer to
+ * "RenderLayer.View" Otherwise: Inputs are expected in the form RenderLayer.Pass.Channel */
static bool parse_channel_name(
string name, string &renderlayer, string &pass, string &channel, bool multiview_channels)
{
@@ -631,7 +630,8 @@ bool DenoiseImage::parse_channels(const ImageSpec &in_spec, string &error)
layer.name = name;
layer.samples = samples;
- /* If the sample value isn't set yet, check if there is a layer-specific one in the input file. */
+ /* If the sample value isn't set yet, check if there is a layer-specific one in the input file.
+ */
if (layer.samples < 1) {
string sample_string = in_spec.get_string_attribute("cycles." + name + ".samples", "");
if (sample_string != "") {
diff --git a/intern/cycles/render/denoising.h b/intern/cycles/render/denoising.h
index dcb842a4603..c234d00eb49 100644
--- a/intern/cycles/render/denoising.h
+++ b/intern/cycles/render/denoising.h
@@ -87,14 +87,17 @@ struct DenoiseImageLayer {
/* input_to_image_channel of the secondary frames, if any are used. */
vector<vector<int>> neighbor_input_to_image_channel;
- /* Write i-th channel of the processing output to output_to_image_channel[i]-th channel of the file. */
+ /* Write i-th channel of the processing output to output_to_image_channel[i]-th channel of the
+ * file. */
vector<int> output_to_image_channel;
- /* Detect whether this layer contains a full set of channels and set up the offsets accordingly. */
+ /* Detect whether this layer contains a full set of channels and set up the offsets accordingly.
+ */
bool detect_denoising_channels();
/* Map the channels of a secondary frame to the channels that are required for processing,
- * fill neighbor_input_to_image_channel if all are present or return false if a channel are missing. */
+ * fill neighbor_input_to_image_channel if all are present or return false if a channel are
+ * missing. */
bool match_channels(int neighbor,
const std::vector<string> &channelnames,
const std::vector<string> &neighbor_channelnames);
@@ -125,7 +128,8 @@ class DenoiseImage {
void free();
- /* Open the input image, parse its channels, open the output image and allocate the output buffer. */
+ /* Open the input image, parse its channels, open the output image and allocate the output
+ * buffer. */
bool load(const string &in_filepath, string &error);
/* Load neighboring frames. */
@@ -139,7 +143,8 @@ class DenoiseImage {
bool save_output(const string &out_filepath, string &error);
protected:
- /* Parse input file channels, separate them into DenoiseImageLayers, detect DenoiseImageLayers with full channel sets,
+ /* Parse input file channels, separate them into DenoiseImageLayers,
+ * detect DenoiseImageLayers with full channel sets,
* fill layers and set up the output channels and passthrough map. */
bool parse_channels(const ImageSpec &in_spec, string &error);
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index ae219e912e0..9f2a5e57d42 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -14,12 +14,14 @@
* limitations under the License.
*/
-#include "device/device.h"
#include "render/image.h"
+#include "device/device.h"
+#include "render/colorspace.h"
#include "render/scene.h"
#include "render/stats.h"
#include "util/util_foreach.h"
+#include "util/util_image_impl.h"
#include "util/util_logging.h"
#include "util/util_path.h"
#include "util/util_progress.h"
@@ -164,11 +166,36 @@ bool ImageManager::get_image_metadata(int flat_slot, ImageMetaData &metadata)
return false;
}
+void ImageManager::metadata_detect_colorspace(ImageMetaData &metadata, const char *file_format)
+{
+ /* Convert used specified color spaces to one we know how to handle. */
+ metadata.colorspace = ColorSpaceManager::detect_known_colorspace(
+ metadata.colorspace, file_format, metadata.is_float || metadata.is_half);
+
+ if (metadata.colorspace == u_colorspace_raw) {
+ /* Nothing to do. */
+ }
+ else if (metadata.colorspace == u_colorspace_srgb) {
+ /* Keep sRGB colorspace stored as sRGB, to save memory and/or loading time
+ * for the common case of 8bit sRGB images like PNG. */
+ metadata.compress_as_srgb = true;
+ }
+ else {
+ /* Always compress non-raw 8bit images as scene linear + sRGB, as a
+ * heuristic to keep memory usage the same without too much data loss
+ * due to quantization in common cases. */
+ metadata.compress_as_srgb = (metadata.type == IMAGE_DATA_TYPE_BYTE ||
+ metadata.type == IMAGE_DATA_TYPE_BYTE4);
+ }
+}
+
bool ImageManager::get_image_metadata(const string &filename,
void *builtin_data,
+ ustring colorspace,
ImageMetaData &metadata)
{
- memset(&metadata, 0, sizeof(metadata));
+ metadata = ImageMetaData();
+ metadata.colorspace = colorspace;
if (builtin_data) {
if (builtin_image_info_cb) {
@@ -179,13 +206,14 @@ bool ImageManager::get_image_metadata(const string &filename,
}
if (metadata.is_float) {
- metadata.is_linear = true;
metadata.type = (metadata.channels > 1) ? IMAGE_DATA_TYPE_FLOAT4 : IMAGE_DATA_TYPE_FLOAT;
}
else {
metadata.type = (metadata.channels > 1) ? IMAGE_DATA_TYPE_BYTE4 : IMAGE_DATA_TYPE_BYTE;
}
+ metadata_detect_colorspace(metadata, "");
+
return true;
}
@@ -213,20 +241,19 @@ bool ImageManager::get_image_metadata(const string &filename,
metadata.width = spec.width;
metadata.height = spec.height;
metadata.depth = spec.depth;
+ metadata.compress_as_srgb = false;
/* Check the main format, and channel formats. */
size_t channel_size = spec.format.basesize();
if (spec.format.is_floating_point()) {
metadata.is_float = true;
- metadata.is_linear = true;
}
for (size_t channel = 0; channel < spec.channelformats.size(); channel++) {
channel_size = max(channel_size, spec.channelformats[channel].basesize());
if (spec.channelformats[channel].is_floating_point()) {
metadata.is_float = true;
- metadata.is_linear = true;
}
}
@@ -235,21 +262,6 @@ bool ImageManager::get_image_metadata(const string &filename,
metadata.is_half = true;
}
- /* basic color space detection, not great but better than nothing
- * before we do OpenColorIO integration */
- if (metadata.is_float) {
- string colorspace = spec.get_string_attribute("oiio:ColorSpace");
-
- metadata.is_linear = !(
- colorspace == "sRGB" || colorspace == "GammaCorrected" ||
- (colorspace == "" &&
- (strcmp(in->format_name(), "png") == 0 || strcmp(in->format_name(), "tiff") == 0 ||
- strcmp(in->format_name(), "dpx") == 0 || strcmp(in->format_name(), "jpeg2000") == 0)));
- }
- else {
- metadata.is_linear = false;
- }
-
/* set type and channels */
metadata.channels = spec.nchannels;
@@ -266,6 +278,8 @@ bool ImageManager::get_image_metadata(const string &filename,
metadata.type = (metadata.channels > 1) ? IMAGE_DATA_TYPE_BYTE4 : IMAGE_DATA_TYPE_BYTE;
}
+ metadata_detect_colorspace(metadata, in->format_name());
+
in->close();
return true;
@@ -276,11 +290,12 @@ static bool image_equals(ImageManager::Image *image,
void *builtin_data,
InterpolationType interpolation,
ExtensionType extension,
- bool use_alpha)
+ bool use_alpha,
+ ustring colorspace)
{
return image->filename == filename && image->builtin_data == builtin_data &&
image->interpolation == interpolation && image->extension == extension &&
- image->use_alpha == use_alpha;
+ image->use_alpha == use_alpha && image->colorspace == colorspace;
}
int ImageManager::add_image(const string &filename,
@@ -290,12 +305,13 @@ int ImageManager::add_image(const string &filename,
InterpolationType interpolation,
ExtensionType extension,
bool use_alpha,
+ ustring colorspace,
ImageMetaData &metadata)
{
Image *img;
size_t slot;
- get_image_metadata(filename, builtin_data, metadata);
+ get_image_metadata(filename, builtin_data, colorspace, metadata);
ImageDataType type = metadata.type;
thread_scoped_lock device_lock(device_mutex);
@@ -313,7 +329,8 @@ int ImageManager::add_image(const string &filename,
/* Fnd existing image. */
for (slot = 0; slot < images[type].size(); slot++) {
img = images[type][slot];
- if (img && image_equals(img, filename, builtin_data, interpolation, extension, use_alpha)) {
+ if (img && image_equals(
+ img, filename, builtin_data, interpolation, extension, use_alpha, colorspace)) {
if (img->frame != frame) {
img->frame = frame;
img->need_load = true;
@@ -322,6 +339,10 @@ int ImageManager::add_image(const string &filename,
img->use_alpha = use_alpha;
img->need_load = true;
}
+ if (img->colorspace != colorspace) {
+ img->colorspace = colorspace;
+ img->need_load = true;
+ }
if (!(img->metadata == metadata)) {
img->metadata = metadata;
img->need_load = true;
@@ -370,6 +391,7 @@ int ImageManager::add_image(const string &filename,
img->extension = extension;
img->users = 1;
img->use_alpha = use_alpha;
+ img->colorspace = colorspace;
img->mem = NULL;
images[type][slot] = img;
@@ -403,15 +425,20 @@ void ImageManager::remove_image(const string &filename,
void *builtin_data,
InterpolationType interpolation,
ExtensionType extension,
- bool use_alpha)
+ bool use_alpha,
+ ustring colorspace)
{
size_t slot;
for (int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
for (slot = 0; slot < images[type].size(); slot++) {
- if (images[type][slot] &&
- image_equals(
- images[type][slot], filename, builtin_data, interpolation, extension, use_alpha)) {
+ if (images[type][slot] && image_equals(images[type][slot],
+ filename,
+ builtin_data,
+ interpolation,
+ extension,
+ use_alpha,
+ colorspace)) {
remove_image(type_index_to_flattened_slot(slot, (ImageDataType)type));
return;
}
@@ -427,13 +454,18 @@ void ImageManager::tag_reload_image(const string &filename,
void *builtin_data,
InterpolationType interpolation,
ExtensionType extension,
- bool use_alpha)
+ bool use_alpha,
+ ustring colorspace)
{
for (size_t type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
for (size_t slot = 0; slot < images[type].size(); slot++) {
- if (images[type][slot] &&
- image_equals(
- images[type][slot], filename, builtin_data, interpolation, extension, use_alpha)) {
+ if (images[type][slot] && image_equals(images[type][slot],
+ filename,
+ builtin_data,
+ interpolation,
+ extension,
+ use_alpha,
+ colorspace)) {
images[type][slot]->need_load = true;
break;
}
@@ -502,14 +534,16 @@ bool ImageManager::file_load_image(Image *img,
int depth = img->metadata.depth;
int components = img->metadata.channels;
- /* Read RGBA pixels. */
+ /* Read pixels. */
vector<StorageType> pixels_storage;
StorageType *pixels;
const size_t max_size = max(max(width, height), depth);
if (max_size == 0) {
- /* Don't bother with invalid images. */
+ /* Don't bother with empty images. */
return false;
}
+
+ /* Allocate memory as needed, may be smaller to resize down. */
if (texture_limit > 0 && max_size > texture_limit) {
pixels_storage.resize(((size_t)width) * height * depth * 4);
pixels = &pixels_storage[0];
@@ -518,19 +552,23 @@ bool ImageManager::file_load_image(Image *img,
thread_scoped_lock device_lock(device_mutex);
pixels = (StorageType *)tex_img.alloc(width, height, depth);
}
+
if (pixels == NULL) {
/* Could be that we've run out of memory. */
return false;
}
+
bool cmyk = false;
const size_t num_pixels = ((size_t)width) * height * depth;
if (in) {
+ /* Read pixels through OpenImageIO. */
StorageType *readpixels = pixels;
vector<StorageType> tmppixels;
if (components > 4) {
tmppixels.resize(((size_t)width) * height * components);
readpixels = &tmppixels[0];
}
+
if (depth <= 1) {
size_t scanlinesize = ((size_t)width) * components * sizeof(StorageType);
in->read_image(FileFormat,
@@ -542,6 +580,7 @@ bool ImageManager::file_load_image(Image *img,
else {
in->read_image(FileFormat, (uchar *)readpixels);
}
+
if (components > 4) {
size_t dimensions = ((size_t)width) * height;
for (size_t i = dimensions - 1, pixel = 0; pixel < dimensions; pixel++, i--) {
@@ -552,10 +591,12 @@ bool ImageManager::file_load_image(Image *img,
}
tmppixels.clear();
}
+
cmyk = strcmp(in->format_name(), "jpeg") == 0 && components == 4;
in->close();
}
else {
+ /* Read pixels through callback. */
if (FileFormat == TypeDesc::FLOAT) {
builtin_image_float_pixels_cb(img->filename,
img->builtin_data,
@@ -574,16 +615,17 @@ bool ImageManager::file_load_image(Image *img,
/* TODO(dingto): Support half for ImBuf. */
}
}
- /* Check if we actually have a float4 slot, in case components == 1,
- * but device doesn't support single channel textures.
- */
+
+ /* The kernel can handle 1 and 4 channel images. Anything that is not a single
+ * channel image is converted to RGBA format. */
bool is_rgba = (type == IMAGE_DATA_TYPE_FLOAT4 || type == IMAGE_DATA_TYPE_HALF4 ||
type == IMAGE_DATA_TYPE_BYTE4 || type == IMAGE_DATA_TYPE_USHORT4);
+
if (is_rgba) {
const StorageType one = util_image_cast_from_float<StorageType>(1.0f);
if (cmyk) {
- /* CMYK */
+ /* CMYK to RGBA. */
for (size_t i = num_pixels - 1, pixel = 0; pixel < num_pixels; pixel++, i--) {
float c = util_image_cast_to_float(pixels[i * 4 + 0]);
float m = util_image_cast_to_float(pixels[i * 4 + 1]);
@@ -596,7 +638,7 @@ bool ImageManager::file_load_image(Image *img,
}
}
else if (components == 2) {
- /* grayscale + alpha */
+ /* Grayscale + alpha to RGBA. */
for (size_t i = num_pixels - 1, pixel = 0; pixel < num_pixels; pixel++, i--) {
pixels[i * 4 + 3] = pixels[i * 2 + 1];
pixels[i * 4 + 2] = pixels[i * 2 + 0];
@@ -605,7 +647,7 @@ bool ImageManager::file_load_image(Image *img,
}
}
else if (components == 3) {
- /* RGB */
+ /* RGB to RGBA. */
for (size_t i = num_pixels - 1, pixel = 0; pixel < num_pixels; pixel++, i--) {
pixels[i * 4 + 3] = one;
pixels[i * 4 + 2] = pixels[i * 3 + 2];
@@ -614,7 +656,7 @@ bool ImageManager::file_load_image(Image *img,
}
}
else if (components == 1) {
- /* grayscale */
+ /* Grayscale to RGBA. */
for (size_t i = num_pixels - 1, pixel = 0; pixel < num_pixels; pixel++, i--) {
pixels[i * 4 + 3] = one;
pixels[i * 4 + 2] = pixels[i];
@@ -622,18 +664,27 @@ bool ImageManager::file_load_image(Image *img,
pixels[i * 4 + 0] = pixels[i];
}
}
+
+ /* Disable alpha if requested by the user. */
if (img->use_alpha == false) {
for (size_t i = num_pixels - 1, pixel = 0; pixel < num_pixels; pixel++, i--) {
pixels[i * 4 + 3] = one;
}
}
+
+ if (img->metadata.colorspace != u_colorspace_raw &&
+ img->metadata.colorspace != u_colorspace_srgb) {
+ /* Convert to scene linear. */
+ ColorSpaceManager::to_scene_linear(
+ img->metadata.colorspace, pixels, width, height, depth, img->metadata.compress_as_srgb);
+ }
}
+
/* Make sure we don't have buggy values. */
if (FileFormat == TypeDesc::FLOAT) {
/* For RGBA buffers we put all channels to 0 if either of them is not
* finite. This way we avoid possible artifacts caused by fully changed
- * hue.
- */
+ * hue. */
if (is_rgba) {
for (size_t i = 0; i < num_pixels; i += 4) {
StorageType *pixel = &pixels[i * 4];
@@ -655,6 +706,7 @@ bool ImageManager::file_load_image(Image *img,
}
}
}
+
/* Scale image down if needed. */
if (pixels_storage.size() > 0) {
float scale_factor = 1.0f;
@@ -684,6 +736,7 @@ bool ImageManager::file_load_image(Image *img,
memcpy(texture_pixels, &scaled_pixels[0], scaled_pixels.size() * sizeof(StorageType));
}
+
return true;
}
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index 34f046692f6..e8ed657ee10 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -20,6 +20,8 @@
#include "device/device.h"
#include "device/device_memory.h"
+#include "render/colorspace.h"
+
#include "util/util_image.h"
#include "util/util_string.h"
#include "util/util_thread.h"
@@ -32,6 +34,7 @@ class Device;
class Progress;
class RenderStats;
class Scene;
+class ColorSpaceProcessor;
class ImageMetaData {
public:
@@ -43,13 +46,29 @@ class ImageMetaData {
/* Automatically set. */
ImageDataType type;
- bool is_linear;
+ ustring colorspace;
+ bool compress_as_srgb;
+
+ ImageMetaData()
+ : is_float(false),
+ is_half(false),
+ channels(0),
+ width(0),
+ height(0),
+ depth(0),
+ builtin_free_cache(false),
+ type((ImageDataType)0),
+ colorspace(u_colorspace_raw),
+ compress_as_srgb(false)
+ {
+ }
bool operator==(const ImageMetaData &other) const
{
return is_float == other.is_float && is_half == other.is_half && channels == other.channels &&
width == other.width && height == other.height && depth == other.depth &&
- type == other.type && is_linear == other.is_linear;
+ type == other.type && colorspace == other.colorspace &&
+ compress_as_srgb == other.compress_as_srgb;
}
};
@@ -65,19 +84,25 @@ class ImageManager {
InterpolationType interpolation,
ExtensionType extension,
bool use_alpha,
+ ustring colorspace,
ImageMetaData &metadata);
void remove_image(int flat_slot);
void remove_image(const string &filename,
void *builtin_data,
InterpolationType interpolation,
ExtensionType extension,
- bool use_alpha);
+ bool use_alpha,
+ ustring colorspace);
void tag_reload_image(const string &filename,
void *builtin_data,
InterpolationType interpolation,
ExtensionType extension,
- bool use_alpha);
- bool get_image_metadata(const string &filename, void *builtin_data, ImageMetaData &metadata);
+ bool use_alpha,
+ ustring colorspace);
+ bool get_image_metadata(const string &filename,
+ void *builtin_data,
+ ustring colorspace,
+ ImageMetaData &metadata);
bool get_image_metadata(int flat_slot, ImageMetaData &metadata);
void device_update(Device *device, Scene *scene, Progress &progress);
@@ -120,6 +145,7 @@ class ImageManager {
void *builtin_data;
ImageMetaData metadata;
+ ustring colorspace;
bool use_alpha;
bool need_load;
bool animated;
@@ -152,6 +178,8 @@ class ImageManager {
int texture_limit,
device_vector<DeviceType> &tex_img);
+ void metadata_detect_colorspace(ImageMetaData &metadata, const char *file_format);
+
void device_load_image(
Device *device, Scene *scene, ImageDataType type, int slot, Progress *progress);
void device_free_image(Device *device, ImageDataType type, int slot);
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 54dacf5d1f4..f1622493455 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -839,8 +839,9 @@ void Mesh::add_undisplaced()
size_t size = attr->buffer_size(
this, (subdivision_type == SUBDIVISION_NONE) ? ATTR_PRIM_TRIANGLE : ATTR_PRIM_SUBD);
- /* Center points for ngons aren't stored in Mesh::verts but are included in size since they will be
- * calculated later, we subtract them from size here so we don't have an overflow while copying.
+ /* Center points for ngons aren't stored in Mesh::verts but are included in size since they will
+ * be calculated later, we subtract them from size here so we don't have an overflow while
+ * copying.
*/
size -= num_ngons * attr->data_sizeof();
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 16416a9a009..6e86643cc2b 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include "render/colorspace.h"
#include "render/film.h"
#include "render/image.h"
#include "render/integrator.h"
@@ -207,11 +208,7 @@ NODE_DEFINE(ImageTextureNode)
TEXTURE_MAPPING_DEFINE(ImageTextureNode);
SOCKET_STRING(filename, "Filename", ustring());
-
- static NodeEnum color_space_enum;
- color_space_enum.insert("none", NODE_COLOR_SPACE_NONE);
- color_space_enum.insert("color", NODE_COLOR_SPACE_COLOR);
- SOCKET_ENUM(color_space, "Color Space", color_space_enum, NODE_COLOR_SPACE_COLOR);
+ SOCKET_STRING(colorspace, "Colorspace", u_colorspace_auto);
SOCKET_BOOLEAN(use_alpha, "Use Alpha", true);
@@ -250,7 +247,8 @@ ImageTextureNode::ImageTextureNode() : ImageSlotTextureNode(node_type)
image_manager = NULL;
slot = -1;
is_float = -1;
- is_linear = false;
+ compress_as_srgb = false;
+ colorspace = u_colorspace_raw;
builtin_data = NULL;
animated = false;
}
@@ -259,7 +257,7 @@ ImageTextureNode::~ImageTextureNode()
{
if (image_manager) {
image_manager->remove_image(
- filename.string(), builtin_data, interpolation, extension, use_alpha);
+ filename.string(), builtin_data, interpolation, extension, use_alpha, colorspace);
}
}
@@ -269,7 +267,8 @@ ShaderNode *ImageTextureNode::clone() const
node->image_manager = NULL;
node->slot = -1;
node->is_float = -1;
- node->is_linear = false;
+ node->compress_as_srgb = false;
+ node->colorspace = u_colorspace_raw;
return node;
}
@@ -304,13 +303,14 @@ void ImageTextureNode::compile(SVMCompiler &compiler)
interpolation,
extension,
use_alpha,
+ colorspace,
metadata);
is_float = metadata.is_float;
- is_linear = metadata.is_linear;
+ compress_as_srgb = metadata.compress_as_srgb;
+ colorspace = metadata.colorspace;
}
if (slot != -1) {
- int srgb = (is_linear || color_space != NODE_COLOR_SPACE_COLOR) ? 0 : 1;
int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
if (projection != NODE_IMAGE_PROJ_BOX) {
@@ -319,7 +319,7 @@ void ImageTextureNode::compile(SVMCompiler &compiler)
compiler.encode_uchar4(vector_offset,
compiler.stack_assign_if_linked(color_out),
compiler.stack_assign_if_linked(alpha_out),
- srgb),
+ compress_as_srgb),
projection);
}
else {
@@ -328,7 +328,7 @@ void ImageTextureNode::compile(SVMCompiler &compiler)
compiler.encode_uchar4(vector_offset,
compiler.stack_assign_if_linked(color_out),
compiler.stack_assign_if_linked(alpha_out),
- srgb),
+ compress_as_srgb),
__float_as_int(projection_blend));
}
@@ -358,7 +358,7 @@ void ImageTextureNode::compile(OSLCompiler &compiler)
if (is_float == -1) {
ImageMetaData metadata;
if (builtin_data == NULL) {
- image_manager->get_image_metadata(filename.string(), NULL, metadata);
+ image_manager->get_image_metadata(filename.string(), NULL, colorspace, metadata);
}
else {
slot = image_manager->add_image(filename.string(),
@@ -368,28 +368,22 @@ void ImageTextureNode::compile(OSLCompiler &compiler)
interpolation,
extension,
use_alpha,
+ colorspace,
metadata);
}
is_float = metadata.is_float;
- is_linear = metadata.is_linear;
+ compress_as_srgb = metadata.compress_as_srgb;
+ colorspace = metadata.colorspace;
}
if (slot == -1) {
- compiler.parameter(this, "filename");
+ compiler.parameter_texture("filename", filename, colorspace);
}
else {
- /* TODO(sergey): It's not so simple to pass custom attribute
- * to the texture() function in order to make builtin images
- * support more clear. So we use special file name which is
- * "@i<slot_number>" and check whether file name matches this
- * mask in the OSLRenderServices::texture().
- */
- compiler.parameter("filename", string_printf("@i%d", slot).c_str());
+ compiler.parameter_texture("filename", slot);
}
- if (is_linear || color_space != NODE_COLOR_SPACE_COLOR)
- compiler.parameter("color_space", "linear");
- else
- compiler.parameter("color_space", "sRGB");
+
+ compiler.parameter("color_space", (compress_as_srgb) ? "sRGB" : "linear");
compiler.parameter(this, "projection");
compiler.parameter(this, "projection_blend");
compiler.parameter("is_float", is_float);
@@ -409,11 +403,7 @@ NODE_DEFINE(EnvironmentTextureNode)
TEXTURE_MAPPING_DEFINE(EnvironmentTextureNode);
SOCKET_STRING(filename, "Filename", ustring());
-
- static NodeEnum color_space_enum;
- color_space_enum.insert("none", NODE_COLOR_SPACE_NONE);
- color_space_enum.insert("color", NODE_COLOR_SPACE_COLOR);
- SOCKET_ENUM(color_space, "Color Space", color_space_enum, NODE_COLOR_SPACE_COLOR);
+ SOCKET_STRING(colorspace, "Colorspace", u_colorspace_auto);
SOCKET_BOOLEAN(use_alpha, "Use Alpha", true);
@@ -442,7 +432,8 @@ EnvironmentTextureNode::EnvironmentTextureNode() : ImageSlotTextureNode(node_typ
image_manager = NULL;
slot = -1;
is_float = -1;
- is_linear = false;
+ compress_as_srgb = false;
+ colorspace = u_colorspace_raw;
builtin_data = NULL;
animated = false;
}
@@ -451,7 +442,7 @@ EnvironmentTextureNode::~EnvironmentTextureNode()
{
if (image_manager) {
image_manager->remove_image(
- filename.string(), builtin_data, interpolation, EXTENSION_REPEAT, use_alpha);
+ filename.string(), builtin_data, interpolation, EXTENSION_REPEAT, use_alpha, colorspace);
}
}
@@ -461,7 +452,8 @@ ShaderNode *EnvironmentTextureNode::clone() const
node->image_manager = NULL;
node->slot = -1;
node->is_float = -1;
- node->is_linear = false;
+ node->compress_as_srgb = false;
+ node->colorspace = u_colorspace_raw;
return node;
}
@@ -494,13 +486,14 @@ void EnvironmentTextureNode::compile(SVMCompiler &compiler)
interpolation,
EXTENSION_REPEAT,
use_alpha,
+ colorspace,
metadata);
is_float = metadata.is_float;
- is_linear = metadata.is_linear;
+ compress_as_srgb = metadata.compress_as_srgb;
+ colorspace = metadata.colorspace;
}
if (slot != -1) {
- int srgb = (is_linear || color_space != NODE_COLOR_SPACE_COLOR) ? 0 : 1;
int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
compiler.add_node(NODE_TEX_ENVIRONMENT,
@@ -508,7 +501,7 @@ void EnvironmentTextureNode::compile(SVMCompiler &compiler)
compiler.encode_uchar4(vector_offset,
compiler.stack_assign_if_linked(color_out),
compiler.stack_assign_if_linked(alpha_out),
- srgb),
+ compress_as_srgb),
projection);
tex_mapping.compile_end(compiler, vector_in, vector_offset);
@@ -540,7 +533,7 @@ void EnvironmentTextureNode::compile(OSLCompiler &compiler)
if (is_float == -1) {
ImageMetaData metadata;
if (builtin_data == NULL) {
- image_manager->get_image_metadata(filename.string(), NULL, metadata);
+ image_manager->get_image_metadata(filename.string(), NULL, colorspace, metadata);
}
else {
slot = image_manager->add_image(filename.string(),
@@ -550,24 +543,23 @@ void EnvironmentTextureNode::compile(OSLCompiler &compiler)
interpolation,
EXTENSION_REPEAT,
use_alpha,
+ colorspace,
metadata);
}
is_float = metadata.is_float;
- is_linear = metadata.is_linear;
+ compress_as_srgb = metadata.compress_as_srgb;
+ colorspace = metadata.colorspace;
}
if (slot == -1) {
- compiler.parameter(this, "filename");
+ compiler.parameter_texture("filename", filename, colorspace);
}
else {
- compiler.parameter("filename", string_printf("@i%d", slot).c_str());
+ compiler.parameter_texture("filename", slot);
}
- compiler.parameter(this, "projection");
- if (is_linear || color_space != NODE_COLOR_SPACE_COLOR)
- compiler.parameter("color_space", "linear");
- else
- compiler.parameter("color_space", "sRGB");
+ compiler.parameter(this, "projection");
+ compiler.parameter("color_space", (compress_as_srgb) ? "sRGB" : "linear");
compiler.parameter(this, "interpolation");
compiler.parameter("is_float", is_float);
compiler.parameter("use_alpha", !alpha_out->links.empty());
@@ -1080,7 +1072,7 @@ void IESLightNode::compile(OSLCompiler &compiler)
tex_mapping.compile(compiler);
- compiler.parameter("slot", slot);
+ compiler.parameter_texture_ies("filename", slot);
compiler.add(this, "node_ies_light");
}
@@ -1483,7 +1475,7 @@ PointDensityTextureNode::~PointDensityTextureNode()
{
if (image_manager) {
image_manager->remove_image(
- filename.string(), builtin_data, interpolation, EXTENSION_CLIP, true);
+ filename.string(), builtin_data, interpolation, EXTENSION_CLIP, true, ustring());
}
}
@@ -1507,8 +1499,15 @@ void PointDensityTextureNode::add_image()
{
if (slot == -1) {
ImageMetaData metadata;
- slot = image_manager->add_image(
- filename.string(), builtin_data, false, 0, interpolation, EXTENSION_CLIP, true, metadata);
+ slot = image_manager->add_image(filename.string(),
+ builtin_data,
+ false,
+ 0,
+ interpolation,
+ EXTENSION_CLIP,
+ true,
+ u_colorspace_raw,
+ metadata);
}
}
@@ -1567,9 +1566,7 @@ void PointDensityTextureNode::compile(OSLCompiler &compiler)
if (use_density || use_color) {
add_image();
- if (slot != -1) {
- compiler.parameter("filename", string_printf("@i%d", slot).c_str());
- }
+ compiler.parameter_texture("filename", slot);
if (space == NODE_TEX_VOXEL_SPACE_WORLD) {
compiler.parameter("mapping", tfm);
compiler.parameter("use_mapping", 1);
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index 7796711115e..88fa728ecd1 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -92,13 +92,18 @@ class ImageTextureNode : public ImageSlotTextureNode {
return true;
}
- ImageManager *image_manager;
- int is_float;
- bool is_linear;
+ virtual bool equals(const ShaderNode &other)
+ {
+ const ImageTextureNode &image_node = (const ImageTextureNode &)other;
+ return ImageSlotTextureNode::equals(other) && builtin_data == image_node.builtin_data &&
+ animated == image_node.animated;
+ }
+
+ /* Parameters. */
bool use_alpha;
ustring filename;
void *builtin_data;
- NodeImageColorSpace color_space;
+ ustring colorspace;
NodeImageProjection projection;
InterpolationType interpolation;
ExtensionType extension;
@@ -106,12 +111,11 @@ class ImageTextureNode : public ImageSlotTextureNode {
bool animated;
float3 vector;
- virtual bool equals(const ShaderNode &other)
- {
- const ImageTextureNode &image_node = (const ImageTextureNode &)other;
- return ImageSlotTextureNode::equals(other) && builtin_data == image_node.builtin_data &&
- animated == image_node.animated;
- }
+ /* Runtime. */
+ ImageManager *image_manager;
+ int is_float;
+ bool compress_as_srgb;
+ ustring known_colorspace;
};
class EnvironmentTextureNode : public ImageSlotTextureNode {
@@ -129,24 +133,28 @@ class EnvironmentTextureNode : public ImageSlotTextureNode {
return NODE_GROUP_LEVEL_2;
}
- ImageManager *image_manager;
- int is_float;
- bool is_linear;
+ virtual bool equals(const ShaderNode &other)
+ {
+ const EnvironmentTextureNode &env_node = (const EnvironmentTextureNode &)other;
+ return ImageSlotTextureNode::equals(other) && builtin_data == env_node.builtin_data &&
+ animated == env_node.animated;
+ }
+
+ /* Parameters. */
bool use_alpha;
ustring filename;
void *builtin_data;
- NodeImageColorSpace color_space;
+ ustring colorspace;
NodeEnvironmentProjection projection;
InterpolationType interpolation;
bool animated;
float3 vector;
- virtual bool equals(const ShaderNode &other)
- {
- const EnvironmentTextureNode &env_node = (const EnvironmentTextureNode &)other;
- return ImageSlotTextureNode::equals(other) && builtin_data == env_node.builtin_data &&
- animated == env_node.animated;
- }
+ /* Runtime. */
+ ImageManager *image_manager;
+ int is_float;
+ bool compress_as_srgb;
+ ustring known_colorspace;
};
class SkyTextureNode : public TextureNode {
@@ -319,15 +327,17 @@ class PointDensityTextureNode : public ShaderNode {
void add_image();
+ /* Parameters. */
ustring filename;
NodeTexVoxelSpace space;
InterpolationType interpolation;
Transform tfm;
float3 vector;
+ void *builtin_data;
+ /* Runtime. */
ImageManager *image_manager;
int slot;
- void *builtin_data;
virtual bool equals(const ShaderNode &other)
{
diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp
index b66a46938be..a65c8e9f338 100644
--- a/intern/cycles/render/osl.cpp
+++ b/intern/cycles/render/osl.cpp
@@ -16,6 +16,7 @@
#include "device/device.h"
+#include "render/colorspace.h"
#include "render/graph.h"
#include "render/light.h"
#include "render/osl.h"
@@ -104,6 +105,11 @@ void OSLShaderManager::device_update(Device *device,
/* create shaders */
OSLGlobals *og = (OSLGlobals *)device->osl_memory();
+ /* Partial thread init of services, the OSL compiler can query data like
+ * constant texture handles. This will be done again right before rendering
+ * with full data available. */
+ services->thread_init(NULL, og, ts);
+
foreach (Shader *shader, scene->shaders) {
assert(shader->graph);
@@ -115,9 +121,9 @@ void OSLShaderManager::device_update(Device *device,
* compile shaders alternating */
thread_scoped_lock lock(ss_mutex);
- OSLCompiler compiler((void *)this, (void *)ss, scene->image_manager, scene->light_manager);
+ OSLCompiler compiler((void *)this, (void *)ss, og, scene->image_manager, scene->light_manager);
compiler.background = (shader == scene->default_background);
- compiler.compile(scene, og, shader);
+ compiler.compile(scene, shader);
if (shader->use_mis && shader->has_surface_emission)
scene->light_manager->need_update = true;
@@ -140,6 +146,10 @@ void OSLShaderManager::device_update(Device *device,
/* set texture system */
scene->image_manager->set_osl_texture_system((void *)ts);
+ /* add special builtin texture types */
+ og->textures.insert(ustring("@ao"), new OSLTextureHandle(OSLTextureHandle::AO));
+ og->textures.insert(ustring("@bevel"), new OSLTextureHandle(OSLTextureHandle::BEVEL));
+
device_update_common(device, dscene, scene, progress);
{
@@ -557,11 +567,13 @@ OSLNode *OSLShaderManager::osl_node(const std::string &filepath,
OSLCompiler::OSLCompiler(void *manager_,
void *shadingsys_,
+ OSLGlobals *osl_globals_,
ImageManager *image_manager_,
LightManager *light_manager_)
{
manager = manager_;
shadingsys = shadingsys_;
+ osl_globals = osl_globals_;
image_manager = image_manager_;
light_manager = light_manager_;
current_type = SHADER_TYPE_SURFACE;
@@ -1123,7 +1135,7 @@ OSL::ShaderGroupRef OSLCompiler::compile_type(Shader *shader, ShaderGraph *graph
return group;
}
-void OSLCompiler::compile(Scene *scene, OSLGlobals *og, Shader *shader)
+void OSLCompiler::compile(Scene *scene, Shader *shader)
{
if (shader->need_update) {
ShaderGraph *graph = shader->graph;
@@ -1188,10 +1200,38 @@ void OSLCompiler::compile(Scene *scene, OSLGlobals *og, Shader *shader)
}
/* push state to array for lookup */
- og->surface_state.push_back(shader->osl_surface_ref);
- og->volume_state.push_back(shader->osl_volume_ref);
- og->displacement_state.push_back(shader->osl_displacement_ref);
- og->bump_state.push_back(shader->osl_surface_bump_ref);
+ osl_globals->surface_state.push_back(shader->osl_surface_ref);
+ osl_globals->volume_state.push_back(shader->osl_volume_ref);
+ osl_globals->displacement_state.push_back(shader->osl_displacement_ref);
+ osl_globals->bump_state.push_back(shader->osl_surface_bump_ref);
+}
+
+void OSLCompiler::parameter_texture(const char *name, ustring filename, ustring colorspace)
+{
+ /* Textured loaded through the OpenImageIO texture cache. For this
+ * case we need to do runtime color space conversion. */
+ OSLTextureHandle *handle = new OSLTextureHandle(OSLTextureHandle::OIIO);
+ handle->processor = ColorSpaceManager::get_processor(colorspace);
+ osl_globals->textures.insert(filename, handle);
+ parameter(name, filename);
+}
+
+void OSLCompiler::parameter_texture(const char *name, int svm_slot)
+{
+ /* Texture loaded through SVM image texture system. We generate a unique
+ * name, which ends up being used in OSLRenderServices::get_texture_handle
+ * to get handle again. */
+ ustring filename(string_printf("@i%d", svm_slot).c_str());
+ osl_globals->textures.insert(filename, new OSLTextureHandle(OSLTextureHandle::SVM, svm_slot));
+ parameter(name, filename);
+}
+
+void OSLCompiler::parameter_texture_ies(const char *name, int svm_slot)
+{
+ /* IES light textures stored in SVM. */
+ ustring filename(string_printf("@l%d", svm_slot).c_str());
+ osl_globals->textures.insert(filename, new OSLTextureHandle(OSLTextureHandle::IES, svm_slot));
+ parameter(name, filename);
}
#else
@@ -1248,6 +1288,20 @@ void OSLCompiler::parameter_color_array(const char * /*name*/, const array<float
{
}
+void OSLCompiler::parameter_texture(const char * /* name */,
+ ustring /* filename */,
+ ustring /* colorspace */)
+{
+}
+
+void OSLCompiler::parameter_texture(const char * /* name */, int /* svm_slot */)
+{
+}
+
+void OSLCompiler::parameter_texture_ies(const char * /* name */, int /* svm_slot */)
+{
+}
+
#endif /* WITH_OSL */
CCL_NAMESPACE_END
diff --git a/intern/cycles/render/osl.h b/intern/cycles/render/osl.h
index aec518a6c2b..ac73f1d3c24 100644
--- a/intern/cycles/render/osl.h
+++ b/intern/cycles/render/osl.h
@@ -129,9 +129,10 @@ class OSLCompiler {
public:
OSLCompiler(void *manager,
void *shadingsys,
+ OSLGlobals *osl_globals,
ImageManager *image_manager,
LightManager *light_manager);
- void compile(Scene *scene, OSLGlobals *og, Shader *shader);
+ void compile(Scene *scene, Shader *shader);
void add(ShaderNode *node, const char *name, bool isfilepath = false);
@@ -152,6 +153,10 @@ class OSLCompiler {
void parameter_attribute(const char *name, ustring s);
+ void parameter_texture(const char *name, ustring filename, ustring colorspace);
+ void parameter_texture(const char *name, int svm_slot);
+ void parameter_texture_ies(const char *name, int svm_slot);
+
ShaderType output_type()
{
return current_type;
@@ -175,6 +180,7 @@ class OSLCompiler {
void *shadingsys;
void *manager;
+ OSLGlobals *osl_globals;
ShaderType current_type;
Shader *current_shader;
};
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index ac3303cbfeb..ec85e516832 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -14,9 +14,11 @@
* limitations under the License.
*/
+#include "device/device.h"
+
#include "render/background.h"
#include "render/camera.h"
-#include "device/device.h"
+#include "render/colorspace.h"
#include "render/graph.h"
#include "render/integrator.h"
#include "render/light.h"
@@ -717,6 +719,8 @@ void ShaderManager::free_memory()
#ifdef WITH_OSL
OSLShaderManager::free_memory();
#endif
+
+ ColorSpaceManager::free_memory();
}
float ShaderManager::linear_rgb_to_gray(float3 c)
diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h
index 600b0cc59d4..f74204df355 100644
--- a/intern/cycles/render/shader.h
+++ b/intern/cycles/render/shader.h
@@ -143,8 +143,10 @@ class Shader : public Node {
Shader();
~Shader();
- /* Checks whether the shader consists of just a emission node with fixed inputs that's connected directly to the output.
- * If yes, it sets the content of emission to the constant value (color * strength), which is then used for speeding up light evaluation. */
+ /* Checks whether the shader consists of just a emission node with fixed inputs that's connected
+ * directly to the output.
+ * If yes, it sets the content of emission to the constant value (color * strength), which is
+ * then used for speeding up light evaluation. */
bool is_constant_emission(float3 *emission);
void set_graph(ShaderGraph *graph);
diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp
index d8e3e24f39e..040aa074f28 100644
--- a/intern/cycles/render/svm.cpp
+++ b/intern/cycles/render/svm.cpp
@@ -773,7 +773,8 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
compile_failed = false;
}
- /* for bump shaders we fall thru to the surface shader, but if this is any other kind of shader it ends here */
+ /* for bump shaders we fall thru to the surface shader, but if this is any other kind of shader
+ * it ends here */
if (type != SHADER_TYPE_BUMP) {
add_node(NODE_END, 0, 0, 0);
}
@@ -828,7 +829,8 @@ void SVMCompiler::compile(
{
scoped_timer timer((summary != NULL) ? &summary->time_generate_surface : NULL);
compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
- /* only set jump offset if there's no bump shader, as the bump shader will fall thru to this one if it exists */
+ /* only set jump offset if there's no bump shader, as the bump shader will fall thru to this
+ * one if it exists */
if (!has_bump) {
svm_nodes[index].y = svm_nodes.size();
}
diff --git a/intern/cycles/render/tile.cpp b/intern/cycles/render/tile.cpp
index 3148b5ef664..9ef0c695667 100644
--- a/intern/cycles/render/tile.cpp
+++ b/intern/cycles/render/tile.cpp
@@ -170,8 +170,9 @@ void TileManager::set_samples(int num_samples_)
}
else {
uint64_t pixel_samples = 0;
- /* While rendering in the viewport, the initial preview resolution is increased to the native resolution
- * before the actual rendering begins. Therefore, additional pixel samples will be rendered. */
+ /* While rendering in the viewport, the initial preview resolution is increased to the native
+ * resolution before the actual rendering begins. Therefore, additional pixel samples will be
+ * rendered. */
int divider = max(get_divider(params.width, params.height, start_resolution) / 2, pixel_size);
while (divider > pixel_size) {
int image_w = max(1, params.width / divider);
@@ -190,8 +191,9 @@ void TileManager::set_samples(int num_samples_)
}
}
-/* If sliced is false, splits image into tiles and assigns equal amount of tiles to every render device.
- * If sliced is true, slice image into as much pieces as how many devices are rendering this image. */
+/* If sliced is false, splits image into tiles and assigns equal amount of tiles to every render
+ * device. If sliced is true, slice image into as much pieces as how many devices are rendering
+ * this image. */
int TileManager::gen_tiles(bool sliced)
{
int resolution = state.resolution_divider;
@@ -255,7 +257,8 @@ int TileManager::gen_tiles(bool sliced)
}
int2 pos = block * block_size + tile * tile_size + offset;
- /* Only add tiles which are in the image (tiles outside of the image can be generated since the spiral is always square). */
+ /* Only add tiles which are in the image (tiles outside of the image can be generated since
+ * the spiral is always square). */
if (pos.x >= 0 && pos.y >= 0 && pos.x < image_w && pos.y < image_h) {
int w = min(tile_size.x, image_w - pos.x);
int h = min(tile_size.y, image_h - pos.y);
@@ -336,7 +339,8 @@ int TileManager::gen_tiles(bool sliced)
cur_tiles++;
if (cur_tiles == tiles_per_device) {
- /* Tiles are already generated in Bottom-to-Top order, so no sort is necessary in that case. */
+ /* Tiles are already generated in Bottom-to-Top order, so no sort is necessary in that
+ * case. */
if (tile_order != TILE_BOTTOM_TO_TOP) {
tile_list->sort(TileComparator(tile_order, center, &state.tiles[0]));
}
@@ -398,7 +402,8 @@ int TileManager::get_neighbor_index(int index, int neighbor)
return ny * state.tile_stride + nx;
}
-/* Checks whether all neighbors of a tile (as well as the tile itself) are at least at state min_state. */
+/* Checks whether all neighbors of a tile (as well as the tile itself) are at least at state
+ * min_state. */
bool TileManager::check_neighbor_state(int index, Tile::State min_state)
{
if (index < 0 || state.tiles[index].state < min_state) {
@@ -415,7 +420,8 @@ bool TileManager::check_neighbor_state(int index, Tile::State min_state)
return true;
}
-/* Returns whether the tile should be written (and freed if no denoising is used) instead of updating. */
+/* Returns whether the tile should be written (and freed if no denoising is used) instead of
+ * updating. */
bool TileManager::finish_tile(int index, bool &delete_tile)
{
delete_tile = false;
@@ -432,7 +438,8 @@ bool TileManager::finish_tile(int index, bool &delete_tile)
return true;
}
state.tiles[index].state = Tile::RENDERED;
- /* For each neighbor and the tile itself, check whether all of its neighbors have been rendered. If yes, it can be denoised. */
+ /* For each neighbor and the tile itself, check whether all of its neighbors have been
+ * rendered. If yes, it can be denoised. */
for (int neighbor = 0; neighbor < 9; neighbor++) {
int nindex = get_neighbor_index(index, neighbor);
if (check_neighbor_state(nindex, Tile::RENDERED)) {
@@ -444,13 +451,15 @@ bool TileManager::finish_tile(int index, bool &delete_tile)
}
case Tile::DENOISE: {
state.tiles[index].state = Tile::DENOISED;
- /* For each neighbor and the tile itself, check whether all of its neighbors have been denoised. If yes, it can be freed. */
+ /* For each neighbor and the tile itself, check whether all of its neighbors have been
+ * denoised. If yes, it can be freed. */
for (int neighbor = 0; neighbor < 9; neighbor++) {
int nindex = get_neighbor_index(index, neighbor);
if (check_neighbor_state(nindex, Tile::DENOISED)) {
state.tiles[nindex].state = Tile::DONE;
/* It can happen that the tile just finished denoising and already can be freed here.
- * However, in that case it still has to be written before deleting, so we can't delete it yet. */
+ * However, in that case it still has to be written before deleting, so we can't delete
+ * it yet. */
if (neighbor == 8) {
delete_tile = true;
}
diff --git a/intern/cycles/subd/subd_split.cpp b/intern/cycles/subd/subd_split.cpp
index 803363bc240..e6603632ba7 100644
--- a/intern/cycles/subd/subd_split.cpp
+++ b/intern/cycles/subd/subd_split.cpp
@@ -141,7 +141,7 @@ void DiagSplit::split(QuadDice::SubPatch &sub, QuadDice::EdgeFactors &ef, int de
bool split_v = (ef.tv0 == DSPLIT_NON_UNIFORM || ef.tv1 == DSPLIT_NON_UNIFORM);
/* Split subpatches such that the ratio of T for opposite edges doesn't
- * exceed 1.5, this reduces over tessellation for some patches
+ * exceed 1.5, this reduces over tessellation for some patches
*/
bool tmp_split_v = split_v;
if (!split_u && min(ef.tu0, ef.tu1) > 8 && min(ef.tu0, ef.tu1) * 1.5f < max(ef.tu0, ef.tu1))
diff --git a/intern/cycles/util/util_aligned_malloc.h b/intern/cycles/util/util_aligned_malloc.h
index 0f006e95f6a..7115e4cb0c6 100644
--- a/intern/cycles/util/util_aligned_malloc.h
+++ b/intern/cycles/util/util_aligned_malloc.h
@@ -30,6 +30,21 @@ void *util_aligned_malloc(size_t size, int alignment);
/* Free memory allocated by util_aligned_malloc. */
void util_aligned_free(void *ptr);
+/* Aligned new operator. */
+template<typename T> T *util_aligned_new()
+{
+ void *mem = util_aligned_malloc(sizeof(T), alignof(T));
+ return new (mem) T();
+}
+
+template<typename T> void util_aligned_delete(T *t)
+{
+ if (t) {
+ t->~T();
+ util_aligned_free(t);
+ }
+}
+
CCL_NAMESPACE_END
#endif /* __UTIL_ALIGNED_MALLOC_H__ */
diff --git a/intern/cycles/util/util_color.h b/intern/cycles/util/util_color.h
index ca4c393f66e..83410db13c6 100644
--- a/intern/cycles/util/util_color.h
+++ b/intern/cycles/util/util_color.h
@@ -167,7 +167,8 @@ ccl_device float3 xyY_to_xyz(float x, float y, float Y)
#ifdef __KERNEL_SSE2__
/*
* Calculate initial guess for arg^exp based on float representation
- * This method gives a constant bias, which can be easily compensated by multiplication with bias_coeff.
+ * This method gives a constant bias,
+ * which can be easily compensated by multiplication with bias_coeff.
* Gives better results for exponents near 1 (e. g. 4/5).
* exp = exponent, encoded as uint32_t
* e2coeff = 2^(127/exponent - 127) * bias_coeff^(1/exponent), encoded as uint32_t
@@ -235,6 +236,12 @@ ccl_device float3 color_linear_to_srgb_v3(float3 c)
color_linear_to_srgb(c.x), color_linear_to_srgb(c.y), color_linear_to_srgb(c.z));
}
+ccl_device float4 color_linear_to_srgb_v4(float4 c)
+{
+ return make_float4(
+ color_linear_to_srgb(c.x), color_linear_to_srgb(c.y), color_linear_to_srgb(c.z), c.w);
+}
+
ccl_device float4 color_srgb_to_linear_v4(float4 c)
{
#ifdef __KERNEL_SSE2__
diff --git a/intern/cycles/util/util_debug.h b/intern/cycles/util/util_debug.h
index d668ddc6d6c..83d9e96ffa5 100644
--- a/intern/cycles/util/util_debug.h
+++ b/intern/cycles/util/util_debug.h
@@ -141,7 +141,8 @@ class DebugFlags {
/* Use debug version of the kernel. */
bool debug;
- /* TODO(mai): Currently this is only for OpenCL, but we should have it implemented for all devices. */
+ /* TODO(mai): Currently this is only for OpenCL, but we should have it implemented for all
+ * devices. */
/* Artificial memory limit in bytes (0 if disabled). */
size_t mem_limit;
};
diff --git a/intern/cycles/util/util_half.h b/intern/cycles/util/util_half.h
index 9c40f5310c2..647e9cf2fd6 100644
--- a/intern/cycles/util/util_half.h
+++ b/intern/cycles/util/util_half.h
@@ -36,7 +36,8 @@ CCL_NAMESPACE_BEGIN
/* CUDA has its own half data type, no need to define then */
# ifndef __KERNEL_CUDA__
-/* Implementing this as a class rather than a typedef so that the compiler can tell it apart from unsigned shorts. */
+/* Implementing this as a class rather than a typedef so that the compiler can tell it apart from
+ * unsigned shorts. */
class half {
public:
half() : v(0)
diff --git a/intern/cycles/util/util_ies.cpp b/intern/cycles/util/util_ies.cpp
index ff5c709b406..7c24a4ec28c 100644
--- a/intern/cycles/util/util_ies.cpp
+++ b/intern/cycles/util/util_ies.cpp
@@ -155,7 +155,8 @@ bool IESFile::parse(ustring ies)
type = (IESType)parser.get_long(); /* Photometric type */
/* TODO(lukas): Test whether the current type B processing can also deal with type A files.
- * In theory the only difference should be orientation which we ignore anyways, but with IES you never know...
+ * In theory the only difference should be orientation which we ignore anyways, but with IES you
+ * never know...
*/
if (type != TYPE_B && type != TYPE_C) {
return false;
@@ -173,12 +174,13 @@ bool IESFile::parse(ustring ies)
* Cycles expects radiometric quantities, though, which requires a conversion.
* However, the Luminous efficacy (ratio of lumens per Watt) depends on the spectral distribution
* of the light source since lumens take human perception into account.
- * Since this spectral distribution is not known from the IES file, a typical one must be assumed.
- * The D65 standard illuminant has a Luminous efficacy of 177.83, which is used here to convert to Watt/sr.
- * A more advanced approach would be to add a Blackbody Temperature input to the node and numerically
- * integrate the Luminous efficacy from the resulting spectral distribution.
- * Also, the Watt/sr value must be multiplied by 4*pi to get the Watt value that Cycles expects
- * for lamp strength. Therefore, the conversion here uses 4*pi/177.83 as a Candela to Watt factor.
+ * Since this spectral distribution is not known from the IES file, a typical one must be
+ * assumed. The D65 standard illuminant has a Luminous efficacy of 177.83, which is used here to
+ * convert to Watt/sr. A more advanced approach would be to add a Blackbody Temperature input to
+ * the node and numerically integrate the Luminous efficacy from the resulting spectral
+ * distribution. Also, the Watt/sr value must be multiplied by 4*pi to get the Watt value that
+ * Cycles expects for lamp strength. Therefore, the conversion here uses 4*pi/177.83 as a Candela
+ * to Watt factor.
*/
factor *= 0.0706650768394;
@@ -294,7 +296,8 @@ bool IESFile::process_type_b()
bool IESFile::process_type_c()
{
if (h_angles[0] == 90.0f) {
- /* Some files are stored from 90° to 270°, so we just rotate them to the regular 0°-180° range here. */
+ /* Some files are stored from 90° to 270°, so we just rotate them to the regular 0°-180° range
+ * here. */
for (int i = 0; i < h_angles.size(); i++) {
h_angles[i] -= 90.0f;
}
@@ -311,8 +314,9 @@ bool IESFile::process_type_c()
if (h_angles[h_angles.size() - 1] == 90.0f) {
/* Only one quadrant is defined, so we need to mirror twice (from one to two, then to four).
- * Since the two->four mirroring step might also be required if we get an input of two quadrants,
- * we only do the first mirror here and later do the second mirror in either case. */
+ * Since the two->four mirroring step might also be required if we get an input of two
+ * quadrants, we only do the first mirror here and later do the second mirror in either case.
+ */
int hnum = h_angles.size();
for (int i = hnum - 2; i >= 0; i--) {
h_angles.push_back(180.0f - h_angles[i]);
@@ -329,8 +333,8 @@ bool IESFile::process_type_c()
}
}
- /* Some files skip the 360° entry (contrary to standard) because it's supposed to be identical to the 0° entry.
- * If the file has a discernible order in its spacing, just fix this. */
+ /* Some files skip the 360° entry (contrary to standard) because it's supposed to be identical to
+ * the 0° entry. If the file has a discernible order in its spacing, just fix this. */
if (h_angles[h_angles.size() - 1] != 360.0f) {
int hnum = h_angles.size();
float last_step = h_angles[hnum - 1] - h_angles[hnum - 2];
diff --git a/intern/cycles/util/util_image.h b/intern/cycles/util/util_image.h
index 8962c09d098..27ec7ffb423 100644
--- a/intern/cycles/util/util_image.h
+++ b/intern/cycles/util/util_image.h
@@ -21,6 +21,7 @@
# include <OpenImageIO/imageio.h>
+# include "util/util_half.h"
# include "util/util_vector.h"
CCL_NAMESPACE_BEGIN
diff --git a/intern/cycles/util/util_map.h b/intern/cycles/util/util_map.h
index 3c9288417cf..8385b08dd5a 100644
--- a/intern/cycles/util/util_map.h
+++ b/intern/cycles/util/util_map.h
@@ -26,6 +26,13 @@ using std::map;
using std::pair;
using std::unordered_map;
+template<typename T> static void map_free_memory(T &data)
+{
+ /* Use swap() trick to actually free all internal memory. */
+ T empty_data;
+ data.swap(empty_data);
+}
+
CCL_NAMESPACE_END
#endif /* __UTIL_MAP_H__ */
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index 92cab29346a..40c5ebbab67 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -651,6 +651,25 @@ ccl_device_inline float2 map_to_sphere(const float3 co)
return make_float2(u, v);
}
+/* Compares two floats.
+ * Returns true if their absolute difference is smaller than abs_diff (for numbers near zero)
+ * or their relative difference is less than ulp_diff ULPs.
+ * Based on https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
+ */
+
+ccl_device_inline float compare_floats(float a, float b, float abs_diff, int ulp_diff)
+{
+ if (fabsf(a - b) < abs_diff) {
+ return true;
+ }
+
+ if ((a < 0.0f) != (b < 0.0f)) {
+ return false;
+ }
+
+ return (abs(__float_as_int(a) - __float_as_int(b)) < ulp_diff);
+}
+
CCL_NAMESPACE_END
#endif /* __UTIL_MATH_H__ */
diff --git a/intern/cycles/util/util_math_fast.h b/intern/cycles/util/util_math_fast.h
index 872271666aa..dbed83ab84d 100644
--- a/intern/cycles/util/util_math_fast.h
+++ b/intern/cycles/util/util_math_fast.h
@@ -282,8 +282,10 @@ ccl_device float fast_acosf(float x)
const float m = (f < 1.0f) ? 1.0f - (1.0f - f) : 1.0f;
/* Based on http://www.pouet.net/topic.php?which=9132&page=2
* 85% accurate (ulp 0)
- * Examined 2130706434 values of acos: 15.2000597 avg ulp diff, 4492 max ulp, 4.51803e-05 max error // without "denormal crush"
- * Examined 2130706434 values of acos: 15.2007108 avg ulp diff, 4492 max ulp, 4.51803e-05 max error // with "denormal crush"
+ * Examined 2130706434 values of acos:
+ * 15.2000597 avg ulp diff, 4492 max ulp, 4.51803e-05 max error // without "denormal crush"
+ * Examined 2130706434 values of acos:
+ * 15.2007108 avg ulp diff, 4492 max ulp, 4.51803e-05 max error // with "denormal crush"
*/
const float a = sqrtf(1.0f - m) *
(1.5707963267f + m * (-0.213300989f + m * (0.077980478f + m * -0.02164095f)));
@@ -312,8 +314,10 @@ ccl_device float fast_atanf(float x)
const float s = 1.0f - (1.0f - k); /* Crush denormals. */
const float t = s * s;
/* http://mathforum.org/library/drmath/view/62672.html
- * Examined 4278190080 values of atan: 2.36864877 avg ulp diff, 302 max ulp, 6.55651e-06 max error // (with denormals)
- * Examined 4278190080 values of atan: 171160502 avg ulp diff, 855638016 max ulp, 6.55651e-06 max error // (crush denormals)
+ * Examined 4278190080 values of atan:
+ * 2.36864877 avg ulp diff, 302 max ulp, 6.55651e-06 max error // (with denormals)
+ * Examined 4278190080 values of atan:
+ * 171160502 avg ulp diff, 855638016 max ulp, 6.55651e-06 max error // (crush denormals)
*/
float r = s * madd(0.43157974f, t, 1.0f) / madd(madd(0.05831938f, t, 0.76443945f), t, 1.0f);
if (a > 1.0f) {
diff --git a/intern/cycles/util/util_math_intersect.h b/intern/cycles/util/util_math_intersect.h
index 95ac231c611..fa3a541eea9 100644
--- a/intern/cycles/util/util_math_intersect.h
+++ b/intern/cycles/util/util_math_intersect.h
@@ -163,7 +163,7 @@ ccl_device_forceinline bool ray_triangle_intersect(float3 ray_P,
/* Calculate geometry normal and denominator. */
const float3 Ng1 = cross(e1, e0);
- //const Vec3vfM Ng1 = stable_triangle_normal(e2,e1,e0);
+ // const Vec3vfM Ng1 = stable_triangle_normal(e2,e1,e0);
const float3 Ng = Ng1 + Ng1;
const float den = dot3(Ng, dir);
/* Avoid division by 0. */
diff --git a/intern/cycles/util/util_math_matrix.h b/intern/cycles/util/util_math_matrix.h
index fe80fab6ebd..e1c7d5d838f 100644
--- a/intern/cycles/util/util_math_matrix.h
+++ b/intern/cycles/util/util_math_matrix.h
@@ -110,7 +110,8 @@ ccl_device_inline void math_vec3_add_strided(
}
/* Elementary matrix operations.
- * Note: TriMatrix refers to a square matrix that is symmetric, and therefore its upper-triangular part isn't stored. */
+ * Note: TriMatrix refers to a square matrix that is symmetric,
+ * and therefore its upper-triangular part isn't stored. */
ccl_device_inline void math_trimatrix_add_diagonal(ccl_global float *A,
int n,
@@ -196,7 +197,8 @@ ccl_device void math_trimatrix_cholesky(ccl_global float *A, int n, int stride)
}
}
-/* Solve A*S=y for S given A and y, where A is symmetrical positive-semidefinite and both inputs are destroyed in the process.
+/* Solve A*S=y for S given A and y,
+ * where A is symmetrical positive-semidefinite and both inputs are destroyed in the process.
*
* We can apply Cholesky decomposition to find a lower triangular L so that L*Lt = A.
* With that we get (L*Lt)*S = L*(Lt*S) = L*b = y, defining b as Lt*S.
@@ -204,15 +206,16 @@ ccl_device void math_trimatrix_cholesky(ccl_global float *A, int n, int stride)
* Then, the remaining problem is Lt*S = b, which again can be solved easily.
*
* This is useful for solving the normal equation S=inv(Xt*W*X)*Xt*W*y, since Xt*W*X is
- * symmetrical positive-semidefinite by construction, so we can just use this function with A=Xt*W*X and y=Xt*W*y. */
+ * symmetrical positive-semidefinite by construction,
+ * so we can just use this function with A=Xt*W*X and y=Xt*W*y. */
ccl_device_inline void math_trimatrix_vec3_solve(ccl_global float *A,
ccl_global float3 *y,
int n,
int stride)
{
/* Since the first entry of the design row is always 1, the upper-left element of XtWX is a good
- * heuristic for the amount of pixels considered (with weighting), therefore the amount of correction
- * is scaled based on it. */
+ * heuristic for the amount of pixels considered (with weighting),
+ * therefore the amount of correction is scaled based on it. */
math_trimatrix_add_diagonal(A, n, 3e-7f * A[0], stride); /* Improve the numerical stability. */
math_trimatrix_cholesky(A, n, stride); /* Replace A with L so that L*Lt = A. */
@@ -234,8 +237,8 @@ ccl_device_inline void math_trimatrix_vec3_solve(ccl_global float *A,
}
/* Perform the Jacobi Eigenvalue Methon on matrix A.
- * A is assumed to be a symmetrical matrix, therefore only the lower-triangular part is ever accessed.
- * The algorithm overwrites the contents of A.
+ * A is assumed to be a symmetrical matrix, therefore only the lower-triangular part is ever
+ * accessed. The algorithm overwrites the contents of A.
*
* After returning, A will be overwritten with D, which is (almost) diagonal,
* and V will contain the eigenvectors of the original A in its rows (!),
@@ -263,7 +266,8 @@ ccl_device void math_matrix_jacobi_eigendecomposition(float *A,
}
if (off_diagonal < 1e-7f) {
/* The matrix has nearly reached diagonal form.
- * Since the eigenvalues are only used to determine truncation, their exact values aren't required - a relative error of a few ULPs won't matter at all. */
+ * Since the eigenvalues are only used to determine truncation, their exact values aren't
+ * required - a relative error of a few ULPs won't matter at all. */
break;
}
@@ -277,7 +281,8 @@ ccl_device void math_matrix_jacobi_eigendecomposition(float *A,
float element = MAT(A, n, row, col);
float abs_element = fabsf(element);
- /* If we're in a later sweep and the element already is very small, just set it to zero and skip the rotation. */
+ /* If we're in a later sweep and the element already is very small,
+ * just set it to zero and skip the rotation. */
if (sweep > 3 && abs_element <= singular_epsilon * fabsf(MAT(A, n, row, row)) &&
abs_element <= singular_epsilon * fabsf(MAT(A, n, col, col))) {
MAT(A, n, row, col) = 0.0f;
@@ -288,13 +293,16 @@ ccl_device void math_matrix_jacobi_eigendecomposition(float *A,
continue;
}
- /* If we're in one of the first sweeps and the element is smaller than the threshold, skip it. */
+ /* If we're in one of the first sweeps and the element is smaller than the threshold,
+ * skip it. */
if (sweep < 3 && (abs_element < threshold)) {
continue;
}
- /* Determine rotation: The rotation is characterized by its angle phi - or, in the actual implementation, sin(phi) and cos(phi).
- * To find those, we first compute their ratio - that might be unstable if the angle approaches 90°, so there's a fallback for that case.
+ /* Determine rotation: The rotation is characterized by its angle phi - or,
+ * in the actual implementation, sin(phi) and cos(phi).
+ * To find those, we first compute their ratio - that might be unstable if the angle
+ * approaches 90°, so there's a fallback for that case.
* Then, we compute sin(phi) and cos(phi) themselves. */
float singular_diff = MAT(A, n, row, row) - MAT(A, n, col, col);
float ratio;
@@ -310,7 +318,8 @@ ccl_device void math_matrix_jacobi_eigendecomposition(float *A,
float c = 1.0f / sqrtf(1.0f + ratio * ratio);
float s = ratio * c;
- /* To improve numerical stability by avoiding cancellation, the update equations are reformulized to use sin(phi) and tan(phi/2) instead. */
+ /* To improve numerical stability by avoiding cancellation, the update equations are
+ * reformulized to use sin(phi) and tan(phi/2) instead. */
float tan_phi_2 = s / (1.0f + c);
/* Update the singular values in the diagonal. */
@@ -330,7 +339,8 @@ ccl_device void math_matrix_jacobi_eigendecomposition(float *A,
MATS(M, n, r2, c2, stride) += s * (M1 - tan_phi_2 * M2); \
}
- /* Split into three parts to ensure correct accesses since we only store the lower-triangular part of A. */
+ /* Split into three parts to ensure correct accesses since we only store the
+ * lower-triangular part of A. */
for (int i = 0; i < col; i++)
ROT(A, col, i, row, i, 1);
for (int i = col + 1; i < row; i++)
diff --git a/intern/cycles/util/util_profiling.cpp b/intern/cycles/util/util_profiling.cpp
index e3edf219435..bbefbadd0fe 100644
--- a/intern/cycles/util/util_profiling.cpp
+++ b/intern/cycles/util/util_profiling.cpp
@@ -47,7 +47,8 @@ void Profiler::run()
}
if (cur_shader >= 0 && cur_shader < shader_samples.size()) {
- /* Only consider the active shader during events whose runtime significantly depends on it. */
+ /* 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))) {
diff --git a/intern/cycles/util/util_progress.h b/intern/cycles/util/util_progress.h
index f05e5b918f3..379beaeeefa 100644
--- a/intern/cycles/util/util_progress.h
+++ b/intern/cycles/util/util_progress.h
@@ -362,7 +362,8 @@ class Progress {
* It's used to display the sample count if only one tile is active. */
int current_tile_sample;
/* Stores the number of tiles that's already finished.
- * Used to determine whether all but the last tile are finished rendering, in which case the current_tile_sample is displayed. */
+ * Used to determine whether all but the last tile are finished rendering,
+ * in which case the current_tile_sample is displayed. */
int rendered_tiles, denoised_tiles;
double start_time, render_start_time;
diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp
index 4b11ce73ea9..2f771e2717e 100644
--- a/intern/cycles/util/util_task.cpp
+++ b/intern/cycles/util/util_task.cpp
@@ -261,7 +261,7 @@ vector<int> distribute_threads_on_nodes(const int num_threads)
const int num_nodes = num_per_node_processors.size();
int thread_index = 0;
/* First pass: fill in all the nodes to their maximum.
- *
+ *
* If there is less threads than the overall nodes capacity, some of the
* nodes or parts of them will idle.
*
diff --git a/intern/cycles/util/util_types_float8.h b/intern/cycles/util/util_types_float8.h
index 7289e3298c3..27da120a4ba 100644
--- a/intern/cycles/util/util_types_float8.h
+++ b/intern/cycles/util/util_types_float8.h
@@ -1,30 +1,30 @@
/*
-* Original code Copyright 2017, Intel Corporation
-* Modifications Copyright 2018, Blender Foundation.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* * Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of Intel Corporation nor the names of its contributors
-* may be used to endorse or promote products derived from this software
-* without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ * Original code Copyright 2017, Intel Corporation
+ * Modifications Copyright 2018, Blender Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#ifndef __UTIL_TYPES_FLOAT8_H__
#define __UTIL_TYPES_FLOAT8_H__
diff --git a/intern/cycles/util/util_types_float8_impl.h b/intern/cycles/util/util_types_float8_impl.h
index 8ce3d81b1bb..4e4ea28c6a4 100644
--- a/intern/cycles/util/util_types_float8_impl.h
+++ b/intern/cycles/util/util_types_float8_impl.h
@@ -1,30 +1,30 @@
/*
-* Original code Copyright 2017, Intel Corporation
-* Modifications Copyright 2018, Blender Foundation.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* * Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of Intel Corporation nor the names of its contributors
-* may be used to endorse or promote products derived from this software
-* without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ * Original code Copyright 2017, Intel Corporation
+ * Modifications Copyright 2018, Blender Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#ifndef __UTIL_TYPES_FLOAT8_IMPL_H__
#define __UTIL_TYPES_FLOAT8_IMPL_H__
diff --git a/intern/dualcon/intern/MemoryAllocator.h b/intern/dualcon/intern/MemoryAllocator.h
index 933b9dea197..f39e8255521 100644
--- a/intern/dualcon/intern/MemoryAllocator.h
+++ b/intern/dualcon/intern/MemoryAllocator.h
@@ -81,8 +81,8 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
int available;
/**
- * Allocate a memory block
- */
+ * Allocate a memory block
+ */
void allocateDataBlock()
{
// Allocate a data block
@@ -98,8 +98,8 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
}
/**
- * Allocate a stack block, to store more deallocated objects
- */
+ * Allocate a stack block, to store more deallocated objects
+ */
void allocateStackBlock()
{
// Allocate a stack block
@@ -111,8 +111,8 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
public:
/**
- * Constructor
- */
+ * Constructor
+ */
MemoryAllocator()
{
HEAP_UNIT = 1 << HEAP_BASE;
@@ -134,8 +134,8 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
}
/**
- * Destructor
- */
+ * Destructor
+ */
void destroy()
{
int i;
@@ -150,8 +150,8 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
}
/**
- * Allocation method
- */
+ * Allocation method
+ */
void *allocate()
{
if (available == 0) {
@@ -164,8 +164,8 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
}
/**
- * De-allocation method
- */
+ * De-allocation method
+ */
void deallocate(void *obj)
{
if (available == stacksize) {
@@ -179,8 +179,8 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
}
/**
- * Print information
- */
+ * Print information
+ */
void printInfo()
{
printf("Bytes: %d Used: %d Allocated: %d Maxfree: %d\n",
@@ -191,8 +191,8 @@ template<int N> class MemoryAllocator : public VirtualMemoryAllocator {
}
/**
- * Query methods
- */
+ * Query methods
+ */
int getAllocated()
{
return HEAP_UNIT * datablocknum - available;
diff --git a/intern/dualcon/intern/Projections.h b/intern/dualcon/intern/Projections.h
index fc650158a0b..dcd5de7dff0 100644
--- a/intern/dualcon/intern/Projections.h
+++ b/intern/dualcon/intern/Projections.h
@@ -32,11 +32,11 @@
#endif
/**
-* Structures and classes for computing projections of triangles onto
-* separating axes during scan conversion
-*
-* @author Tao Ju
-*/
+ * Structures and classes for computing projections of triangles onto
+ * separating axes during scan conversion
+ *
+ * @author Tao Ju
+ */
extern const int vertmap[8][3];
extern const int centmap[3][3][3][2];
@@ -45,9 +45,9 @@ extern const int facemap[6][4];
/* Axes:
* 0, 1, 2: cube face normals
- *
+ *
* 3: triangle normal
- *
+ *
* 4, 5, 6,
* 7, 8, 9,
* 10, 11, 12: cross of each triangle edge vector with each cube
diff --git a/intern/dualcon/intern/octree.cpp b/intern/dualcon/intern/octree.cpp
index 46783176fc1..a6fac6fed33 100644
--- a/intern/dualcon/intern/octree.cpp
+++ b/intern/dualcon/intern/octree.cpp
@@ -531,9 +531,11 @@ Node *Octree::trace(Node *newnode, int *st, int len, int depth, PathList *&paths
findPaths((Node **)nf, lf, df, nstf, depth - 1, cellProcFaceMask[i][2], conn[i]);
- //if(conn[i]) {
- // printPath(conn[i]);
- //}
+#if 0
+ if (conn[i]) {
+ printPath(conn[i]);
+ }
+#endif
}
// Connect paths
@@ -1045,14 +1047,19 @@ Node *Octree::patchSplitSingle(Node *newnode,
PathElement *pre2 = NULL;
int side = findPair(head, st[dir] + len / 2, dir, pre1, pre2);
- /*
- if(pre1 == pre2) {
- int edgelen =(dimen >> maxDepth);
- dc_printf("Location: %d %d %d Direction: %d Reso: %d\n", st[0]/edgelen, st[1]/edgelen, st[2]/edgelen, dir, len/edgelen);
- printPath(head);
- exit(0);
- }
- */
+#if 0
+ if (pre1 == pre2) {
+ int edgelen = (dimen >> maxDepth);
+ dc_printf("Location: %d %d %d Direction: %d Reso: %d\n",
+ st[0] / edgelen,
+ st[1] / edgelen,
+ st[2] / edgelen,
+ dir,
+ len / edgelen);
+ printPath(head);
+ exit(0);
+ }
+#endif
if (side) {
// Entirely on one side
@@ -1247,9 +1254,11 @@ Node *Octree::connectFace(
spt[(dir + walkdir) % 3] += mindimen;
}
- // dc_printf("new x,y: %d %d\n", ori[xdir] / edgelen, ori[ydir] / edgelen);
- // dc_printf("nori: %d %d %d alpha: %f walkdir: %d\n", nori[0], nori[1], nori[2], alpha, walkdir);
- // dc_printf("%f %f %f\n", spt[0], spt[1], spt[2]);
+#if 0
+ dc_printf("new x,y: %d %d\n", ori[xdir] / edgelen, ori[ydir] / edgelen);
+ dc_printf("nori: %d %d %d alpha: %f walkdir: %d\n", nori[0], nori[1], nori[2], alpha, walkdir);
+ dc_printf("%f %f %f\n", spt[0], spt[1], spt[2]);
+#endif
// Locate the current cells on both sides
newnode = locateCell(&newnode->internal, st, len, nori, dir, 1, nodeN, stN, lenN);
@@ -1436,8 +1445,20 @@ Node *Octree::locateCell(InternalNode *node,
}
#ifdef IN_DEBUG_MODE
- // dc_printf("In LOCATECELL index of ori(%d %d %d) with dir %d side %d in st(%d %d %d, %d) is: %d\n",
- // ori[0], ori[1], ori[2], dir, side, st[0], st[1], st[2], len, ind);
+# if 0
+ dc_printf(
+ "In LOCATECELL index of ori(%d %d %d) with dir %d side %d in st(%d %d %d, %d) is: %d\n",
+ ori[0],
+ ori[1],
+ ori[2],
+ dir,
+ side,
+ st[0],
+ st[1],
+ st[2],
+ len,
+ ind);
+# endif
#endif
rst[0] = st[0] + vertmap[ind][0] * len;
@@ -1481,12 +1502,15 @@ Node *Octree::locateCell(InternalNode *node,
void Octree::checkElement(PathElement * /*ele*/)
{
- /*
- if(ele != NULL && locateLeafCheck(ele->pos) != ele->node) {
- dc_printf("Screwed! at pos: %d %d %d\n", ele->pos[0]>>minshift, ele->pos[1]>>minshift, ele->pos[2]>>minshift);
- exit(0);
- }
- */
+#if 0
+ if (ele != NULL && locateLeafCheck(ele->pos) != ele->node) {
+ dc_printf("Screwed! at pos: %d %d %d\n",
+ ele->pos[0] >> minshift,
+ ele->pos[1] >> minshift,
+ ele->pos[2] >> minshift);
+ exit(0);
+ }
+#endif
}
void Octree::checkPath(PathElement *path)
@@ -1564,9 +1588,9 @@ void Octree::getFacePoint(PathElement *leaf, int dir, int &x, int &y, float &p,
avg[1] /= num;
avg[2] /= num;
- //avg[0] =(float) leaf->pos[0];
- //avg[1] =(float) leaf->pos[1];
- //avg[2] =(float) leaf->pos[2];
+ // avg[0] =(float) leaf->pos[0];
+ // avg[1] =(float) leaf->pos[1];
+ // avg[2] =(float) leaf->pos[2];
}
int xdir = (dir + 1) % 3;
@@ -1578,32 +1602,48 @@ void Octree::getFacePoint(PathElement *leaf, int dir, int &x, int &y, float &p,
#ifdef IN_DEBUG_MODE
// Is it outside?
// PathElement* leaf = leaf1->len < leaf2->len ? leaf1 : leaf2;
- /*
- float* m =(leaf == leaf1 ? m1 : m2);
- if(xf < leaf->pos[xdir] ||
- yf < leaf->pos[ydir] ||
- xf > leaf->pos[xdir] + leaf->len ||
- yf > leaf->pos[ydir] + leaf->len) {
- dc_printf("Outside cube(%d %d %d), %d : %d %d %f %f\n", leaf->pos[0], leaf->pos[1], leaf->pos[2], leaf->len,
- pos, dir, xf, yf);
-
- // For now, snap to cell
- xf = m[xdir];
- yf = m[ydir];
- }
- */
+# if 0
+ float *m = (leaf == leaf1 ? m1 : m2);
+ if (xf < leaf->pos[xdir] || yf < leaf->pos[ydir] || xf > leaf->pos[xdir] + leaf->len ||
+ yf > leaf->pos[ydir] + leaf->len) {
+ dc_printf("Outside cube(%d %d %d), %d : %d %d %f %f\n",
+ leaf->pos[0],
+ leaf->pos[1],
+ leaf->pos[2],
+ leaf->len,
+ pos,
+ dir,
+ xf,
+ yf);
- /*
- if(alpha < 0 || alpha > 1 ||
- xf < leaf->pos[xdir] || xf > leaf->pos[xdir] + leaf->len ||
- yf < leaf->pos[ydir] || yf > leaf->pos[ydir] + leaf->len) {
- dc_printf("Alpha: %f Address: %d and %d\n", alpha, leaf1->node, leaf2->node);
- dc_printf("GETFACEPOINT result:(%d %d %d) %d min:(%f %f %f);(%d %d %d) %d min:(%f %f %f).\n",
- leaf1->pos[0], leaf1->pos[1], leaf1->pos[2], leaf1->len, m1[0], m1[1], m1[2],
- leaf2->pos[0], leaf2->pos[1], leaf2->pos[2], leaf2->len, m2[0], m2[1], m2[2]);
- dc_printf("Face point at dir %d pos %d: %f %f\n", dir, pos, xf, yf);
- }
- */
+ // For now, snap to cell
+ xf = m[xdir];
+ yf = m[ydir];
+ }
+# endif
+
+# if 0
+ if (alpha < 0 || alpha > 1 || xf < leaf->pos[xdir] || xf > leaf->pos[xdir] + leaf->len ||
+ yf < leaf->pos[ydir] || yf > leaf->pos[ydir] + leaf->len) {
+ dc_printf("Alpha: %f Address: %d and %d\n", alpha, leaf1->node, leaf2->node);
+ dc_printf("GETFACEPOINT result:(%d %d %d) %d min:(%f %f %f);(%d %d %d) %d min:(%f %f %f).\n",
+ leaf1->pos[0],
+ leaf1->pos[1],
+ leaf1->pos[2],
+ leaf1->len,
+ m1[0],
+ m1[1],
+ m1[2],
+ leaf2->pos[0],
+ leaf2->pos[1],
+ leaf2->pos[2],
+ leaf2->len,
+ m2[0],
+ m2[1],
+ m2[2]);
+ dc_printf("Face point at dir %d pos %d: %f %f\n", dir, pos, xf, yf);
+ }
+# endif
#endif
// Get the integer and float part
@@ -1860,7 +1900,13 @@ int Octree::floodFill(LeafNode *leaf, int st[3], int len, int /*height*/, int th
// Queue processing
int nst[3], dir;
while (queue->popQueue(nst, dir) == 1) {
- // dc_printf("nst: %d %d %d, dir: %d\n", nst[0]/mindimen, nst[1]/mindimen, nst[2]/mindimen, dir);
+#if 0
+ dc_printf("nst: %d %d %d, dir: %d\n",
+ nst[0] / mindimen,
+ nst[1] / mindimen,
+ nst[2] / mindimen,
+ dir);
+#endif
// locations
int stMask[3][3] = {{0, 0 - len, 0 - len}, {0 - len, 0, 0 - len}, {0 - len, 0 - len, 0}};
int cst[2][3];
@@ -1920,7 +1966,13 @@ int Octree::floodFill(LeafNode *leaf, int st[3], int len, int /*height*/, int th
if (isInProcess(cs[cind], edge) == 0) {
setInProcessAll(est, edir);
queue->pushQueue(est, edir);
- // dc_printf("Pushed: est: %d %d %d, edir: %d\n", est[0]/len, est[1]/len, est[2]/len, edir);
+#if 0
+ dc_printf("Pushed: est: %d %d %d, edir: %d\n",
+ est[0] / len,
+ est[1] / len,
+ est[2] / len,
+ edir);
+#endif
total++;
}
}
@@ -1957,7 +2009,13 @@ int Octree::floodFill(LeafNode *leaf, int st[3], int len, int /*height*/, int th
// Queue processing
while (queue->popQueue(nst, dir) == 1) {
- // dc_printf("nst: %d %d %d, dir: %d\n", nst[0]/mindimen, nst[1]/mindimen, nst[2]/mindimen, dir);
+#if 0
+ dc_printf("nst: %d %d %d, dir: %d\n",
+ nst[0] / mindimen,
+ nst[1] / mindimen,
+ nst[2] / mindimen,
+ dir);
+#endif
// locations
int stMask[3][3] = {{0, 0 - len, 0 - len}, {0 - len, 0, 0 - len}, {0 - len, 0 - len, 0}};
int cst[2][3];
@@ -2016,7 +2074,13 @@ int Octree::floodFill(LeafNode *leaf, int st[3], int len, int /*height*/, int th
if (getEdgeParity(cs[cind], edge) == 1) {
flipParityAll(est, edir);
queue->pushQueue(est, edir);
- // dc_printf("Pushed: est: %d %d %d, edir: %d\n", est[0]/len, est[1]/len, est[2]/len, edir);
+#if 0
+ dc_printf("Pushed: est: %d %d %d, edir: %d\n",
+ est[0] / len,
+ est[1] / len,
+ est[2] / len,
+ edir);
+#endif
total++;
}
}
@@ -2283,10 +2347,10 @@ void Octree::generateMinimizer(Node *node, int st[3], int len, int height, int &
computeMinimizer(&node->leaf, st, len, rvalue);
// Update
- //float fnst[3];
+ // float fnst[3];
for (j = 0; j < 3; j++) {
rvalue[j] = rvalue[j] * range / dimen + origin[j];
- //fnst[j] = st[j] * range / dimen + origin[j];
+ // fnst[j] = st[j] * range / dimen + origin[j];
}
int mult = 0, smask = getSignMask(&node->leaf);
@@ -2329,7 +2393,7 @@ void Octree::generateMinimizer(Node *node, int st[3], int len, int height, int &
void Octree::processEdgeWrite(Node *node[4], int /*depth*/[4], int /*maxdep*/, int dir)
{
- //int color = 0;
+ // int color = 0;
int i = 3;
{
diff --git a/intern/dualcon/intern/octree.h b/intern/dualcon/intern/octree.h
index db945e36390..b2d88f0d2b5 100644
--- a/intern/dualcon/intern/octree.h
+++ b/intern/dualcon/intern/octree.h
@@ -987,12 +987,14 @@ class Octree {
const LeafNode *node = locateLeaf(nst);
if (e1) {
- // getEdgeIntersectionByIndex(node, femask[i][0], nstt, 1, pts[fmask[i][0]], norms[fmask[i][0]]);
+ // getEdgeIntersectionByIndex(node, femask[i][0], nstt, 1, pts[fmask[i][0]],
+ // norms[fmask[i][0]]);
getEdgeIntersectionByIndex(
node, femask[i][0], nst, len, pts[fmask[i][0]], norms[fmask[i][0]]);
}
if (e2) {
- // getEdgeIntersectionByIndex(node, femask[i][1], nstt, 1, pts[fmask[i][1]], norms[fmask[i][1]]);
+ // getEdgeIntersectionByIndex(node, femask[i][1], nstt, 1, pts[fmask[i][1]],
+ // norms[fmask[i][1]]);
getEdgeIntersectionByIndex(
node, femask[i][1], nst, len, pts[fmask[i][1]], norms[fmask[i][1]]);
}
@@ -1057,13 +1059,15 @@ class Octree {
int e2 = getStoredEdgesParity(node, femask[i][1]);
if (e1) {
- // getEdgeIntersectionByIndex(node, femask[i][0], nstt, 1, pts[fmask[i][0]], norms[fmask[i][0]]);
+ // getEdgeIntersectionByIndex(node, femask[i][0], nstt, 1, pts[fmask[i][0]],
+ // norms[fmask[i][0]]);
getEdgeIntersectionByIndex(
node, femask[i][0], nst, len, pts[fmask[i][0]], norms[fmask[i][0]]);
parity[fmask[i][0]] = 1;
}
if (e2) {
- // getEdgeIntersectionByIndex(node, femask[i][1], nstt, 1, pts[fmask[i][1]], norms[fmask[i][1]]);
+ // getEdgeIntersectionByIndex(node, femask[i][1], nstt, 1, pts[fmask[i][1]],
+ // norms[fmask[i][1]]);
getEdgeIntersectionByIndex(
node, femask[i][1], nst, len, pts[fmask[i][1]], norms[fmask[i][1]]);
parity[fmask[i][1]] = 1;
diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h
index 1eafd409668..863fbd40bb0 100644
--- a/intern/ffmpeg/ffmpeg_compat.h
+++ b/intern/ffmpeg/ffmpeg_compat.h
@@ -1,7 +1,7 @@
/*
* compatibility macros to make every ffmpeg installation appear
* like the most current installation (wrapping some functionality sometimes)
- * it also includes all ffmpeg header files at once, no need to do it
+ * it also includes all ffmpeg header files at once, no need to do it
* separately.
*
* Copyright (c) 2011 Peter Schlaile
@@ -136,8 +136,8 @@ int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
#endif
-/* XXX TODO Probably fix to correct modern flags in code? Not sure how old FFMPEG we want to support though,
- * so for now this will do. */
+/* XXX TODO Probably fix to correct modern flags in code? Not sure how old FFMPEG we want to
+ * support though, so for now this will do. */
#ifndef FF_MIN_BUFFER_SIZE
# ifdef AV_INPUT_BUFFER_MIN_SIZE
@@ -215,8 +215,8 @@ int av_get_cropped_height_from_codec(AVCodecContext *pCodecCtx)
/* really bad hack to remove this dreadfull black bar at the bottom
with Canon footage and old ffmpeg versions.
(to fix this properly in older ffmpeg versions one has to write a new
- demuxer...)
-
+ demuxer...)
+
see the actual fix here for reference:
http://git.libav.org/?p=libav.git;a=commit;h=30f515091c323da59c0f1b533703dedca2f4b95d
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 8bb6a670754..6c490e51b0d 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -155,7 +155,8 @@ extern void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle,
* The new window is added to the list of windows managed.
* Never explicitly delete the window, use disposeWindow() instead.
* \param systemhandle The handle to the system
- * \param title The name of the window (displayed in the title bar of the window if the OS supports it).
+ * \param title The name of the window
+ * (displayed in the title bar of the window if the OS supports it).
* \param left The coordinate of the left edge of the window.
* \param top The coordinate of the top edge of the window.
* \param width The width the window.
@@ -684,19 +685,14 @@ extern GHOST_TSuccess GHOST_SetSwapInterval(GHOST_WindowHandle windowhandle, int
/**
* Gets the current swap interval for swapBuffers.
- * \param windowhandle The handle to the window
- * \param intervalOut pointer to location to return swap interval (left untouched if there is an error)
+ * \param windowhandle: The handle to the window
+ * \param intervalOut: pointer to location to return swap interval
+ * (left untouched if there is an error)
* \return A boolean success indicator of if swap interval was successfully read.
*/
extern GHOST_TSuccess GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle, int *intervalOut);
/**
- * Gets the current swap interval for swapBuffers.
- * \return Number of AA Samples (0 if there is no multisample buffer)
- */
-extern GHOST_TUns16 GHOST_GetNumOfAASamples(GHOST_WindowHandle windowhandle);
-
-/**
* Activates the drawing context of this window.
* \param windowhandle The handle to the window
* \return A success indicator.
@@ -790,7 +786,8 @@ extern GHOST_TSuccess GHOST_IsEmptyRectangle(GHOST_RectangleHandle rectanglehand
/**
* Returns whether this rectangle is valid.
- * Valid rectangles are rectangles that have m_l <= m_r and m_t <= m_b. Thus, empty rectangles are valid.
+ * Valid rectangles are rectangles that have m_l <= m_r and m_t <= m_b.
+ * Thus, empty rectangles are valid.
* \param rectanglehandle The handle to the rectangle
* \return Success value (true == valid rectangle)
*/
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 66e37a525c0..3c93d21f30f 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -226,17 +226,18 @@ class GHOST_ISystem {
* Create a new window.
* The new window is added to the list of windows managed.
* Never explicitly delete the window, use disposeWindow() instead.
- * \param title The name of the window (displayed in the title bar of the window if the OS supports it).
- * \param left The coordinate of the left edge of the window.
- * \param top The coordinate of the top edge of the window.
- * \param width The width the window.
- * \param height The height the window.
- * \param state The state of the window when opened.
- * \param type The type of drawing context installed in this window.
+ * \param title: The name of the window
+ * (displayed in the title bar of the window if the OS supports it).
+ * \param left: The coordinate of the left edge of the window.
+ * \param top: The coordinate of the top edge of the window.
+ * \param width: The width the window.
+ * \param height: The height the window.
+ * \param state: The state of the window when opened.
+ * \param type: The type of drawing context installed in this window.
* \param glSettings: Misc OpenGL settings.
* \param exclusive: Use to show the window ontop and ignore others (used fullscreen).
- * \param parentWindow Parent (embedder) window
- * \return The new window (or 0 if creation failed).
+ * \param parentWindow: Parent (embedder) window
+ * \return The new window (or 0 if creation failed).
*/
virtual GHOST_IWindow *createWindow(const STR_String &title,
GHOST_TInt32 left,
@@ -287,8 +288,7 @@ class GHOST_ISystem {
virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting &setting,
GHOST_IWindow **window,
const bool stereoVisual,
- const bool alphaBackground = 0,
- const GHOST_TUns16 numOfAASamples = 0) = 0;
+ const bool alphaBackground = 0) = 0;
/**
* Updates the resolution while in fullscreen mode.
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index 0b1b83c36a7..6a9e0b9588a 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -205,18 +205,13 @@ class GHOST_IWindow {
/**
* Gets the current swap interval for swapBuffers.
- * \param intervalOut pointer to location to return swap interval (left untouched if there is an error)
+ * \param intervalOut pointer to location to return swap interval
+ * (left untouched if there is an error)
* \return A boolean success indicator of if swap interval was successfully read.
*/
virtual GHOST_TSuccess getSwapInterval(int &intervalOut) = 0;
/**
- * Gets the current swap interval for swapBuffers.
- * \return Number of AA Samples (0 if there is no multisample buffer)
- */
- virtual GHOST_TUns16 getNumOfAASamples() = 0;
-
- /**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
diff --git a/intern/ghost/GHOST_Rect.h b/intern/ghost/GHOST_Rect.h
index cd4eb936066..d4c05a7b8aa 100644
--- a/intern/ghost/GHOST_Rect.h
+++ b/intern/ghost/GHOST_Rect.h
@@ -77,23 +77,24 @@ class GHOST_Rect {
/**
* Sets all members of the rectangle.
- * \param l requested left coordinate of the rectangle
- * \param t requested top coordinate of the rectangle
- * \param r requested right coordinate of the rectangle
- * \param b requested bottom coordinate of the rectangle
+ * \param l: requested left coordinate of the rectangle.
+ * \param t: requested top coordinate of the rectangle.
+ * \param r: requested right coordinate of the rectangle.
+ * \param b: requested bottom coordinate of the rectangle.
*/
virtual inline void set(GHOST_TInt32 l, GHOST_TInt32 t, GHOST_TInt32 r, GHOST_TInt32 b);
/**
* Returns whether this rectangle is empty.
* Empty rectangles are rectangles that have width==0 and/or height==0.
- * \return boolean value (true==empty rectangle)
+ * \return boolean value (true==empty rectangle)
*/
virtual inline bool isEmpty() const;
/**
* Returns whether this rectangle is valid.
- * Valid rectangles are rectangles that have m_l <= m_r and m_t <= m_b. Thus, empty rectangles are valid.
+ * Valid rectangles are rectangles that have m_l <= m_r and m_t <= m_b.
+ * Thus, empty rectangles are valid.
* \return boolean value (true==valid rectangle)
*/
virtual inline bool isValid() const;
@@ -101,28 +102,28 @@ class GHOST_Rect {
/**
* Grows (or shrinks the rectangle).
* The method avoids negative insets making the rectangle invalid
- * \param i The amount of offset given to each extreme (negative values shrink the rectangle).
+ * \param i: The amount of offset given to each extreme (negative values shrink the rectangle).
*/
virtual void inset(GHOST_TInt32 i);
/**
* Does a union of the rectangle given and this rectangle.
* The result is stored in this rectangle.
- * \param r The rectangle that is input for the union operation.
+ * \param r: The rectangle that is input for the union operation.
*/
virtual inline void unionRect(const GHOST_Rect &r);
/**
* Grows the rectangle to included a point.
- * \param x The x-coordinate of the point.
- * \param y The y-coordinate of the point.
+ * \param x: The x-coordinate of the point.
+ * \param y: The y-coordinate of the point.
*/
virtual inline void unionPoint(GHOST_TInt32 x, GHOST_TInt32 y);
/**
* Grows the rectangle to included a point.
- * \param x The x-coordinate of the point.
- * \param y The y-coordinate of the point.
+ * \param x The x-coordinate of the point.
+ * \param y The y-coordinate of the point.
*/
virtual inline void wrapPoint(GHOST_TInt32 &x, GHOST_TInt32 &y, GHOST_TInt32 ofs);
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index 36678bcc913..faba5bb996a 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -49,7 +49,6 @@ typedef int GHOST_TInt32;
typedef unsigned int GHOST_TUns32;
typedef struct {
- GHOST_TUns16 numOfAASamples;
int flags;
} GHOST_GLSettings;
@@ -368,10 +367,14 @@ typedef enum {
} GHOST_TKey;
typedef enum {
- GHOST_kGrabDisable = 0, /* grab not set */
- GHOST_kGrabNormal, /* no cursor adjustments */
- GHOST_kGrabWrap, /* wrap the mouse location to prevent limiting screen bounds */
- GHOST_kGrabHide, /* hide the mouse while grabbing and restore the original location on release (numbuts) */
+ /** Grab not set. */
+ GHOST_kGrabDisable = 0,
+ /** No cursor adjustments. */
+ GHOST_kGrabNormal,
+ /** Wrap the mouse location to prevent limiting screen bounds. */
+ GHOST_kGrabWrap,
+ /** Hide the mouse while grabbing and restore the original location on release (numbuts). */
+ GHOST_kGrabHide,
} GHOST_TGrabCursorMode;
typedef void *GHOST_TEventDataPtr;
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 8d9570a39f3..3848c723e5b 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -611,13 +611,6 @@ GHOST_TSuccess GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle, int *inter
return window->getSwapInterval(*intervalOut);
}
-GHOST_TUns16 GHOST_GetNumOfAASamples(GHOST_WindowHandle windowhandle)
-{
- GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
-
- return window->getNumOfAASamples();
-}
-
GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
diff --git a/intern/ghost/intern/GHOST_Context.h b/intern/ghost/intern/GHOST_Context.h
index ed7b63aa436..7937fd1f7c7 100644
--- a/intern/ghost/intern/GHOST_Context.h
+++ b/intern/ghost/intern/GHOST_Context.h
@@ -37,10 +37,8 @@ class GHOST_Context : public GHOST_IContext {
/**
* Constructor.
* \param stereoVisual Stereo visual for quad buffered stereo.
- * \param numOfAASamples Number of samples used for AA (zero if no AA)
*/
- GHOST_Context(bool stereoVisual, GHOST_TUns16 numOfAASamples)
- : m_stereoVisual(stereoVisual), m_numOfAASamples(numOfAASamples)
+ GHOST_Context(bool stereoVisual) : m_stereoVisual(stereoVisual)
{
}
@@ -121,19 +119,11 @@ class GHOST_Context : public GHOST_IContext {
return m_stereoVisual;
}
- /** Number of samples used in anti-aliasing, set to 0 if no AA */
- inline GHOST_TUns16 getNumOfAASamples() const
- {
- return m_numOfAASamples;
- }
-
protected:
void initContextGLEW();
bool m_stereoVisual;
- GHOST_TUns16 m_numOfAASamples;
-
static void initClearGL();
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/intern/ghost/intern/GHOST_ContextCGL.h b/intern/ghost/intern/GHOST_ContextCGL.h
index 648af1cc9c7..fd760837d45 100644
--- a/intern/ghost/intern/GHOST_ContextCGL.h
+++ b/intern/ghost/intern/GHOST_ContextCGL.h
@@ -44,7 +44,6 @@ class GHOST_ContextCGL : public GHOST_Context {
* Constructor.
*/
GHOST_ContextCGL(bool stereoVisual,
- GHOST_TUns16 numOfAASamples,
NSWindow *window,
NSOpenGLView *openGLView,
int contextProfileMask,
diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm b/intern/ghost/intern/GHOST_ContextCGL.mm
index 9b4e1864adf..5b8bb643751 100644
--- a/intern/ghost/intern/GHOST_ContextCGL.mm
+++ b/intern/ghost/intern/GHOST_ContextCGL.mm
@@ -40,7 +40,6 @@ NSOpenGLContext *GHOST_ContextCGL::s_sharedOpenGLContext = nil;
int GHOST_ContextCGL::s_sharedCount = 0;
GHOST_ContextCGL::GHOST_ContextCGL(bool stereoVisual,
- GHOST_TUns16 numOfAASamples,
NSWindow *window,
NSOpenGLView *openGLView,
int contextProfileMask,
@@ -48,7 +47,7 @@ GHOST_ContextCGL::GHOST_ContextCGL(bool stereoVisual,
int contextMinorVersion,
int contextFlags,
int contextResetNotificationStrategy)
- : GHOST_Context(stereoVisual, numOfAASamples),
+ : GHOST_Context(stereoVisual),
m_openGLView(openGLView),
m_openGLContext(nil),
m_debug(contextFlags)
@@ -183,9 +182,7 @@ GHOST_TSuccess GHOST_ContextCGL::updateDrawingContext()
static void makeAttribList(std::vector<NSOpenGLPixelFormatAttribute> &attribs,
bool coreProfile,
bool stereoVisual,
- int numOfAASamples,
bool needAlpha,
- bool needStencil,
bool softwareGL)
{
attribs.clear();
@@ -207,9 +204,6 @@ static void makeAttribList(std::vector<NSOpenGLPixelFormatAttribute> &attribs,
attribs.push_back(NSOpenGLPFAAllowOfflineRenderers); // for automatic GPU switching
- attribs.push_back(NSOpenGLPFADepthSize);
- attribs.push_back((NSOpenGLPixelFormatAttribute)32);
-
if (stereoVisual)
attribs.push_back(NSOpenGLPFAStereo);
@@ -218,22 +212,6 @@ static void makeAttribList(std::vector<NSOpenGLPixelFormatAttribute> &attribs,
attribs.push_back((NSOpenGLPixelFormatAttribute)8);
}
- if (needStencil) {
- attribs.push_back(NSOpenGLPFAStencilSize);
- attribs.push_back((NSOpenGLPixelFormatAttribute)8);
- }
-
- if (numOfAASamples > 0) {
- // Multisample anti-aliasing
- attribs.push_back(NSOpenGLPFAMultisample);
-
- attribs.push_back(NSOpenGLPFASampleBuffers);
- attribs.push_back((NSOpenGLPixelFormatAttribute)1);
-
- attribs.push_back(NSOpenGLPFASamples);
- attribs.push_back((NSOpenGLPixelFormatAttribute)numOfAASamples);
- }
-
attribs.push_back((NSOpenGLPixelFormatAttribute)0);
}
@@ -263,57 +241,18 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
static const bool needAlpha = false;
#endif
-#ifdef GHOST_OPENGL_STENCIL
- static const bool needStencil = true;
-#else
- static const bool needStencil = false;
-#endif
-
static bool softwareGL = getenv("BLENDER_SOFTWAREGL"); // command-line argument would be better
GLint major = 0, minor = 0;
NSOpenGLPixelFormat *pixelFormat;
// TODO: keep pixel format for subsequent windows/contexts instead of recreating each time
- makeAttribList(attribs,
- m_coreProfile,
- m_stereoVisual,
- m_numOfAASamples,
- needAlpha,
- needStencil,
- softwareGL);
+ makeAttribList(attribs, m_coreProfile, m_stereoVisual, needAlpha, softwareGL);
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];
- // Fall back to no multisampling if Antialiasing init failed
- if (m_numOfAASamples > 0 && pixelFormat == nil) {
- // XXX jwilkins: Does CGL only succeed when it makes an exact match on the number of samples?
- // Does this need to explicitly try for a lesser match before giving up?
- // (Now that I think about it, does WGL really require the code that it has for finding a lesser match?)
-
- attribs.clear();
- makeAttribList(attribs, m_coreProfile, m_stereoVisual, 0, needAlpha, needStencil, softwareGL);
- pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];
- }
-
if (pixelFormat == nil)
goto error;
- if (m_numOfAASamples > 0) { //Set m_numOfAASamples to the actual value
- GLint actualSamples;
- [pixelFormat getValues:&actualSamples forAttribute:NSOpenGLPFASamples forVirtualScreen:0];
-
- if (m_numOfAASamples != (GHOST_TUns16)actualSamples) {
- fprintf(
- stderr,
- "Warning! Unable to find a multisample pixel format that supports exactly %d samples. "
- "Substituting one that uses %d samples.\n",
- m_numOfAASamples,
- actualSamples);
-
- m_numOfAASamples = (GHOST_TUns16)actualSamples;
- }
- }
-
m_openGLContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat
shareContext:s_sharedOpenGLContext];
[pixelFormat release];
@@ -336,13 +275,7 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
[m_openGLContext release];
// create software GL context
- makeAttribList(attribs,
- m_coreProfile,
- m_stereoVisual,
- m_numOfAASamples,
- needAlpha,
- needStencil,
- softwareGL);
+ makeAttribList(attribs, m_coreProfile, m_stereoVisual, needAlpha, softwareGL);
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];
m_openGLContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat
shareContext:s_sharedOpenGLContext];
@@ -358,7 +291,7 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
}
#ifdef GHOST_MULTITHREADED_OPENGL
- //Switch openGL to multhreaded mode
+ // Switch openGL to multhreaded mode
if (CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine) == kCGLNoError)
if (m_debug)
fprintf(stderr, "\nSwitched OpenGL to multithreaded mode\n");
diff --git a/intern/ghost/intern/GHOST_ContextEGL.cpp b/intern/ghost/intern/GHOST_ContextEGL.cpp
index 34df5f3119d..d4eeda2a9ef 100644
--- a/intern/ghost/intern/GHOST_ContextEGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextEGL.cpp
@@ -200,7 +200,6 @@ template<typename T> T &choose_api(EGLenum api, T &a, T &b, T &c)
}
GHOST_ContextEGL::GHOST_ContextEGL(bool stereoVisual,
- GHOST_TUns16 numOfAASamples,
EGLNativeWindowType nativeWindow,
EGLNativeDisplayType nativeDisplay,
EGLint contextProfileMask,
@@ -209,7 +208,7 @@ GHOST_ContextEGL::GHOST_ContextEGL(bool stereoVisual,
EGLint contextFlags,
EGLint contextResetNotificationStrategy,
EGLenum api)
- : GHOST_Context(stereoVisual, numOfAASamples),
+ : GHOST_Context(stereoVisual),
m_nativeDisplay(nativeDisplay),
m_nativeWindow(nativeWindow),
m_contextProfileMask(contextProfileMask),
@@ -435,22 +434,6 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
attrib_list.push_back(8);
#endif
- attrib_list.push_back(EGL_DEPTH_SIZE);
- attrib_list.push_back(24);
-
-#ifdef GHOST_OPENGL_STENCIL
- attrib_list.push_back(EGL_STENCIL_SIZE);
- attrib_list.push_back(8);
-#endif
-
- if (m_numOfAASamples > 0) {
- attrib_list.push_back(EGL_SAMPLE_BUFFERS);
- attrib_list.push_back(1);
-
- attrib_list.push_back(EGL_SAMPLES);
- attrib_list.push_back(m_numOfAASamples);
- }
-
attrib_list.push_back(EGL_NONE);
EGLConfig config;
@@ -462,24 +445,6 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
if (num_config != 1) // num_config should be exactly 1
goto error;
- if (m_numOfAASamples > 0) {
- EGLint actualSamples;
-
- if (!EGL_CHK(::eglGetConfigAttrib(m_display, config, EGL_SAMPLE_BUFFERS, &actualSamples)))
- goto error;
-
- if (m_numOfAASamples != actualSamples) {
- fprintf(
- stderr,
- "Warning! Unable to find a multisample pixel format that supports exactly %d samples. "
- "Substituting one that uses %d samples.\n",
- m_numOfAASamples,
- actualSamples);
-
- m_numOfAASamples = (GHOST_TUns16)actualSamples;
- }
- }
-
m_surface = ::eglCreateWindowSurface(m_display, config, m_nativeWindow, NULL);
if (!EGL_CHK(m_surface != EGL_NO_SURFACE))
diff --git a/intern/ghost/intern/GHOST_ContextEGL.h b/intern/ghost/intern/GHOST_ContextEGL.h
index 0a759493e4d..cd6b0c959b7 100644
--- a/intern/ghost/intern/GHOST_ContextEGL.h
+++ b/intern/ghost/intern/GHOST_ContextEGL.h
@@ -42,7 +42,6 @@ class GHOST_ContextEGL : public GHOST_Context {
* Constructor.
*/
GHOST_ContextEGL(bool stereoVisual,
- GHOST_TUns16 numOfAASamples,
EGLNativeWindowType nativeWindow,
EGLNativeDisplayType nativeDisplay,
EGLint contextProfileMask,
diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp
index 6a5126d59b8..fac75f299fc 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.cpp
+++ b/intern/ghost/intern/GHOST_ContextGLX.cpp
@@ -44,7 +44,6 @@ GLXContext GHOST_ContextGLX::s_sharedContext = None;
int GHOST_ContextGLX::s_sharedCount = 0;
GHOST_ContextGLX::GHOST_ContextGLX(bool stereoVisual,
- GHOST_TUns16 numOfAASamples,
Window window,
Display *display,
GLXFBConfig fbconfig,
@@ -53,7 +52,7 @@ GHOST_ContextGLX::GHOST_ContextGLX(bool stereoVisual,
int contextMinorVersion,
int contextFlags,
int contextResetNotificationStrategy)
- : GHOST_Context(stereoVisual, numOfAASamples),
+ : GHOST_Context(stereoVisual),
m_display(display),
m_fbconfig(fbconfig),
m_window(window),
@@ -260,7 +259,7 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
int glx_attribs[64];
int fbcount = 0;
- GHOST_X11_GL_GetAttributes(glx_attribs, 64, m_numOfAASamples, m_stereoVisual, false, true);
+ GHOST_X11_GL_GetAttributes(glx_attribs, 64, m_stereoVisual, false, true);
framebuffer_config = glXChooseFBConfig(
m_display, DefaultScreen(m_display), glx_attribs, &fbcount);
@@ -369,21 +368,11 @@ GHOST_TSuccess GHOST_ContextGLX::getSwapInterval(int &intervalOut)
*
* \note Similar to SDL's 'X11_GL_GetAttributes'
*/
-int GHOST_X11_GL_GetAttributes(int *attribs,
- int attribs_max,
- int samples,
- bool is_stereo_visual,
- bool need_alpha,
- bool for_fb_config)
+int GHOST_X11_GL_GetAttributes(
+ int *attribs, int attribs_max, bool is_stereo_visual, bool need_alpha, bool for_fb_config)
{
int i = 0;
-#ifdef GHOST_OPENGL_STENCIL
- const bool need_stencil = true;
-#else
- const bool need_stencil = false;
-#endif
-
if (is_stereo_visual) {
attribs[i++] = GLX_STEREO;
if (for_fb_config) {
@@ -413,27 +402,11 @@ int GHOST_X11_GL_GetAttributes(int *attribs,
attribs[i++] = GLX_GREEN_SIZE;
attribs[i++] = True;
- attribs[i++] = GLX_DEPTH_SIZE;
- attribs[i++] = True;
-
if (need_alpha) {
attribs[i++] = GLX_ALPHA_SIZE;
attribs[i++] = True;
}
- if (need_stencil) {
- attribs[i++] = GLX_STENCIL_SIZE;
- attribs[i++] = True;
- }
-
- if (samples) {
- attribs[i++] = GLX_SAMPLE_BUFFERS_ARB;
- attribs[i++] = True;
-
- attribs[i++] = GLX_SAMPLES_ARB;
- attribs[i++] = samples;
- }
-
attribs[i++] = 0;
GHOST_ASSERT(i <= attribs_max, "attribute size too small");
diff --git a/intern/ghost/intern/GHOST_ContextGLX.h b/intern/ghost/intern/GHOST_ContextGLX.h
index 5b631ea55de..ba8df7dac1b 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.h
+++ b/intern/ghost/intern/GHOST_ContextGLX.h
@@ -43,7 +43,6 @@ class GHOST_ContextGLX : public GHOST_Context {
* Constructor.
*/
GHOST_ContextGLX(bool stereoVisual,
- GHOST_TUns16 numOfAASamples,
Window window,
Display *display,
GLXFBConfig fbconfig,
@@ -124,11 +123,7 @@ class GHOST_ContextGLX : public GHOST_Context {
};
/* used to get GLX info */
-int GHOST_X11_GL_GetAttributes(int *attribs,
- int attribs_max,
- int samples,
- bool is_stereo_visual,
- bool need_alpha,
- bool for_fb_config);
+int GHOST_X11_GL_GetAttributes(
+ int *attribs, int attribs_max, bool is_stereo_visual, bool need_alpha, bool for_fb_config);
#endif // __GHOST_CONTEXTGLX_H__
diff --git a/intern/ghost/intern/GHOST_ContextNone.h b/intern/ghost/intern/GHOST_ContextNone.h
index b7297d2497c..2a3c08701b4 100644
--- a/intern/ghost/intern/GHOST_ContextNone.h
+++ b/intern/ghost/intern/GHOST_ContextNone.h
@@ -30,8 +30,7 @@
class GHOST_ContextNone : public GHOST_Context {
public:
- GHOST_ContextNone(bool stereoVisual, GHOST_TUns16 numOfAASamples)
- : GHOST_Context(stereoVisual, numOfAASamples), m_swapInterval(1)
+ GHOST_ContextNone(bool stereoVisual) : GHOST_Context(stereoVisual), m_swapInterval(1)
{
}
diff --git a/intern/ghost/intern/GHOST_ContextSDL.cpp b/intern/ghost/intern/GHOST_ContextSDL.cpp
index 600cab6f6d5..bf0737e5efa 100644
--- a/intern/ghost/intern/GHOST_ContextSDL.cpp
+++ b/intern/ghost/intern/GHOST_ContextSDL.cpp
@@ -35,14 +35,13 @@ SDL_GLContext GHOST_ContextSDL::s_sharedContext = NULL;
int GHOST_ContextSDL::s_sharedCount = 0;
GHOST_ContextSDL::GHOST_ContextSDL(bool stereoVisual,
- GHOST_TUns16 numOfAASamples,
SDL_Window *window,
int contextProfileMask,
int contextMajorVersion,
int contextMinorVersion,
int contextFlags,
int contextResetNotificationStrategy)
- : GHOST_Context(stereoVisual, numOfAASamples),
+ : GHOST_Context(stereoVisual),
m_window(window),
m_hidden_window(NULL),
m_contextProfileMask(contextProfileMask),
@@ -113,12 +112,6 @@ GHOST_TSuccess GHOST_ContextSDL::initializeDrawingContext()
const bool needAlpha = false;
#endif
-#ifdef GHOST_OPENGL_STENCIL
- const bool needStencil = true;
-#else
- const bool needStencil = false;
-#endif
-
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, m_contextProfileMask);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, m_contextMajorVersion);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, m_contextMinorVersion);
@@ -126,7 +119,6 @@ GHOST_TSuccess GHOST_ContextSDL::initializeDrawingContext()
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
@@ -135,19 +127,10 @@ GHOST_TSuccess GHOST_ContextSDL::initializeDrawingContext()
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
}
- if (needStencil) {
- SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
- }
-
if (m_stereoVisual) {
SDL_GL_SetAttribute(SDL_GL_STEREO, 1);
}
- if (m_numOfAASamples) {
- SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
- SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, m_numOfAASamples);
- }
-
if (m_window == NULL) {
m_hidden_window = SDL_CreateWindow("Offscreen Context Windows",
SDL_WINDOWPOS_UNDEFINED,
diff --git a/intern/ghost/intern/GHOST_ContextSDL.h b/intern/ghost/intern/GHOST_ContextSDL.h
index bbd8dd5ad5e..670d930e1e7 100644
--- a/intern/ghost/intern/GHOST_ContextSDL.h
+++ b/intern/ghost/intern/GHOST_ContextSDL.h
@@ -48,7 +48,6 @@ class GHOST_ContextSDL : public GHOST_Context {
* Constructor.
*/
GHOST_ContextSDL(bool stereoVisual,
- GHOST_TUns16 numOfAASamples,
SDL_Window *window,
int contextProfileMask,
int contextMajorVersion,
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp
index 96d6e0c1600..d4851450ce8 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -42,7 +42,6 @@ static bool is_crappy_intel_card()
GHOST_ContextWGL::GHOST_ContextWGL(bool stereoVisual,
bool alphaBackground,
- GHOST_TUns16 numOfAASamples,
HWND hWnd,
HDC hDC,
int contextProfileMask,
@@ -50,7 +49,7 @@ GHOST_ContextWGL::GHOST_ContextWGL(bool stereoVisual,
int contextMinorVersion,
int contextFlags,
int contextResetNotificationStrategy)
- : GHOST_Context(stereoVisual, numOfAASamples),
+ : GHOST_Context(stereoVisual),
m_hWnd(hWnd),
m_hDC(hDC),
m_contextProfileMask(contextProfileMask),
@@ -154,7 +153,7 @@ static int weight_pixel_format(PIXELFORMATDESCRIPTOR &pfd, PIXELFORMATDESCRIPTOR
/* if no formats can be found, can we determine why it was rejected? */
if (!(pfd.dwFlags & PFD_SUPPORT_OPENGL) || !(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
!(pfd.dwFlags & PFD_DOUBLEBUFFER) || /* Blender _needs_ this */
- !(pfd.iPixelType == PFD_TYPE_RGBA) || (pfd.cDepthBits < 16) ||
+ !(pfd.iPixelType == PFD_TYPE_RGBA) ||
(pfd.cColorBits > 32) || /* 64 bit formats disable aero */
(pfd.dwFlags & PFD_GENERIC_FORMAT)) /* no software renderers */
{
@@ -163,10 +162,6 @@ static int weight_pixel_format(PIXELFORMATDESCRIPTOR &pfd, PIXELFORMATDESCRIPTOR
weight = 1; /* it's usable */
- /* the bigger the depth buffer the better */
- /* give no weight to a 16-bit depth buffer, because those are crap */
- weight += pfd.cDepthBits - 16;
-
weight += pfd.cColorBits - 8;
if (preferredPFD.cAlphaBits > 0 && pfd.cAlphaBits > 0)
@@ -175,10 +170,6 @@ static int weight_pixel_format(PIXELFORMATDESCRIPTOR &pfd, PIXELFORMATDESCRIPTOR
if ((preferredPFD.dwFlags & PFD_SUPPORT_COMPOSITION) && (pfd.dwFlags & PFD_SUPPORT_COMPOSITION))
weight++;
#endif
-#ifdef GHOST_OPENGL_STENCIL
- if (pfd.cStencilBits >= 8)
- weight++;
-#endif
return weight;
}
@@ -235,11 +226,11 @@ static int choose_pixel_format_legacy(HDC hDC, PIXELFORMATDESCRIPTOR &preferredP
return iPixelFormat;
}
-/*
+/**
* Clone a window for the purpose of creating a temporary context to initialize WGL extensions.
- * There is no generic way to clone the lpParam parameter, so the caller is responsible for cloning it themselves.
+ * There is no generic way to clone the lpParam parameter,
+ * so the caller is responsible for cloning it themselves.
*/
-
static HWND clone_window(HWND hWnd, LPVOID lpParam)
{
int count;
@@ -373,12 +364,7 @@ finalize:
}
}
-static void makeAttribList(std::vector<int> &out,
- bool stereoVisual,
- int numOfAASamples,
- bool needAlpha,
- bool needStencil,
- bool sRGB)
+static void makeAttribList(std::vector<int> &out, bool stereoVisual, bool needAlpha)
{
out.clear();
out.reserve(30);
@@ -406,37 +392,15 @@ static void makeAttribList(std::vector<int> &out,
out.push_back(WGL_COLOR_BITS_ARB);
out.push_back(24);
- out.push_back(WGL_DEPTH_BITS_ARB);
- out.push_back(24);
-
if (needAlpha) {
out.push_back(WGL_ALPHA_BITS_ARB);
out.push_back(8);
}
- if (needStencil) {
- out.push_back(WGL_STENCIL_BITS_ARB);
- out.push_back(8);
- }
-
- if (numOfAASamples > 0) {
- out.push_back(WGL_SAMPLES_ARB);
- out.push_back(numOfAASamples);
-
- out.push_back(WGL_SAMPLE_BUFFERS_ARB);
- out.push_back(GL_TRUE);
- }
-
- if (sRGB) {
- out.push_back(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
- out.push_back(GL_TRUE);
- }
-
out.push_back(0);
}
-int GHOST_ContextWGL::_choose_pixel_format_arb_1(
- bool stereoVisual, int numOfAASamples, bool needAlpha, bool needStencil, bool sRGB)
+int GHOST_ContextWGL::_choose_pixel_format_arb_1(bool stereoVisual, bool needAlpha)
{
std::vector<int> iAttributes;
@@ -445,27 +409,17 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_1(
int iPixelFormat = 0;
int iPixelFormats[_MAX_PIXEL_FORMATS];
- int samples;
+ makeAttribList(iAttributes, stereoVisual, needAlpha);
- // guard against some insanely high number of samples
- if (numOfAASamples > 64) {
- fprintf(stderr, "Warning! Clamping number of samples to 64.\n");
- samples = 64;
- }
- else {
- samples = numOfAASamples;
- }
+ UINT nNumFormats;
+ WIN32_CHK(wglChoosePixelFormatARB(
+ m_hDC, &(iAttributes[0]), NULL, _MAX_PIXEL_FORMATS, iPixelFormats, &nNumFormats));
- // request a format with as many samples as possible, but not more than requested
- while (samples >= 0) {
- makeAttribList(iAttributes, stereoVisual, samples, needAlpha, needStencil, sRGB);
-
- UINT nNumFormats;
- WIN32_CHK(wglChoosePixelFormatARB(
- m_hDC, &(iAttributes[0]), NULL, _MAX_PIXEL_FORMATS, iPixelFormats, &nNumFormats));
+ if (nNumFormats > 0) {
+ iPixelFormat = iPixelFormats[0];
#ifdef WIN32_COMPOSITING
- if (needAlpha && nNumFormats) {
+ if (needAlpha) {
// scan through all pixel format to make sure one supports compositing
PIXELFORMATDESCRIPTOR pfd;
int i;
@@ -480,41 +434,16 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_1(
}
if (i == nNumFormats) {
fprintf(stderr, "Warning! Unable to find a pixel format with compositing capability.\n");
- iPixelFormat = iPixelFormats[0];
}
}
- else
#endif
- iPixelFormat = iPixelFormats[0];
- /* total number of formats that match (regardless of size of iPixelFormat array)
- * see: WGL_ARB_pixel_format extension spec */
- if (nNumFormats > 0)
- break;
-
- /* if not reset, then the state of iPixelFormat is undefined after call to wglChoosePixelFormatARB
- * see: WGL_ARB_pixel_format extension spec */
- iPixelFormat = 0;
-
- samples--;
}
- // check how many samples were actually gotten
+ // check pixel format
if (iPixelFormat != 0) {
- int iQuery[] = {WGL_SAMPLES_ARB};
- int actualSamples, alphaBits;
- wglGetPixelFormatAttribivARB(m_hDC, iPixelFormat, 0, 1, iQuery, &actualSamples);
-
- if (actualSamples != numOfAASamples) {
- fprintf(
- stderr,
- "Warning! Unable to find a multisample pixel format that supports exactly %d samples. "
- "Substituting one that uses %d samples.\n",
- numOfAASamples,
- actualSamples);
- }
if (needAlpha) {
- iQuery[0] = WGL_ALPHA_BITS_ARB;
- wglGetPixelFormatAttribivARB(m_hDC, iPixelFormat, 0, 1, iQuery, &alphaBits);
+ int alphaBits, iQuery = WGL_ALPHA_BITS_ARB;
+ wglGetPixelFormatAttribivARB(m_hDC, iPixelFormat, 0, 1, &iQuery, &alphaBits);
if (alphaBits == 0) {
fprintf(stderr, "Warning! Unable to find a frame buffer with alpha channel.\n");
}
@@ -523,18 +452,16 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_1(
return iPixelFormat;
}
-int GHOST_ContextWGL::choose_pixel_format_arb(
- bool stereoVisual, int numOfAASamples, bool needAlpha, bool needStencil, bool sRGB)
+int GHOST_ContextWGL::choose_pixel_format_arb(bool stereoVisual, bool needAlpha)
{
int iPixelFormat;
- iPixelFormat = _choose_pixel_format_arb_1(
- stereoVisual, numOfAASamples, needAlpha, needStencil, sRGB);
+ iPixelFormat = _choose_pixel_format_arb_1(stereoVisual, needAlpha);
if (iPixelFormat == 0 && stereoVisual) {
fprintf(stderr, "Warning! Unable to find a stereo pixel format.\n");
- iPixelFormat = _choose_pixel_format_arb_1(false, numOfAASamples, needAlpha, needStencil, sRGB);
+ iPixelFormat = _choose_pixel_format_arb_1(false, needAlpha);
m_stereoVisual = false; // set context property to actual value
}
@@ -542,8 +469,7 @@ int GHOST_ContextWGL::choose_pixel_format_arb(
return iPixelFormat;
}
-int GHOST_ContextWGL::choose_pixel_format(
- bool stereoVisual, int numOfAASamples, bool needAlpha, bool needStencil, bool sRGB)
+int GHOST_ContextWGL::choose_pixel_format(bool stereoVisual, bool needAlpha)
{
PIXELFORMATDESCRIPTOR preferredPFD = {
sizeof(PIXELFORMATDESCRIPTOR), /* size */
@@ -572,12 +498,12 @@ int GHOST_ContextWGL::choose_pixel_format(
0,
0,
0,
- 0, /* accum bits (ignored) */
- 24, /* depth buffer */
- (BYTE)(needStencil ? 8 : 0), /* stencil buffer */
- 0, /* no auxiliary buffers */
- PFD_MAIN_PLANE, /* main layer */
- 0, /* reserved */
+ 0, /* accum bits (ignored) */
+ 0, /* depth buffer */
+ 0, /* stencil buffer */
+ 0, /* no auxiliary buffers */
+ PFD_MAIN_PLANE, /* main layer */
+ 0, /* reserved */
0,
0,
0 /* layer, visible, and damage masks (ignored) */
@@ -585,21 +511,10 @@ int GHOST_ContextWGL::choose_pixel_format(
initContextWGLEW(preferredPFD);
- if (numOfAASamples > 0 && !WGLEW_ARB_multisample) {
- fprintf(stderr, "Warning! Unable to request a multisample framebuffer.\n");
- numOfAASamples = 0;
- }
-
- if (sRGB && !(WGLEW_ARB_framebuffer_sRGB || WGLEW_EXT_framebuffer_sRGB)) {
- fprintf(stderr, "Warning! Unable to request an sRGB framebuffer.\n");
- sRGB = false;
- }
-
int iPixelFormat = 0;
if (WGLEW_ARB_pixel_format)
- iPixelFormat = choose_pixel_format_arb(
- stereoVisual, numOfAASamples, needAlpha, needStencil, sRGB);
+ iPixelFormat = choose_pixel_format_arb(stereoVisual, needAlpha);
if (iPixelFormat == 0)
iPixelFormat = choose_pixel_format_legacy(m_hDC, preferredPFD);
@@ -629,25 +544,12 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
if (!WGLEW_ARB_create_context || ::GetPixelFormat(m_hDC) == 0) {
const bool needAlpha = m_alphaBackground;
-
-#ifdef GHOST_OPENGL_STENCIL
- const bool needStencil = true;
-#else
- const bool needStencil = false;
-#endif
-
-#ifdef GHOST_OPENGL_SRGB
- const bool sRGB = true;
-#else
- const bool sRGB = false;
-#endif
int iPixelFormat;
int lastPFD;
PIXELFORMATDESCRIPTOR chosenPFD;
- iPixelFormat = choose_pixel_format(
- m_stereoVisual, m_numOfAASamples, needAlpha, needStencil, sRGB);
+ iPixelFormat = choose_pixel_format(m_stereoVisual, needAlpha);
if (iPixelFormat == 0) {
goto error;
@@ -663,9 +565,6 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
if (needAlpha && chosenPFD.cAlphaBits == 0)
fprintf(stderr, "Warning! Unable to find a pixel format with an alpha channel.\n");
- if (needStencil && chosenPFD.cStencilBits == 0)
- fprintf(stderr, "Warning! Unable to find a pixel format with a stencil buffer.\n");
-
if (!WIN32_CHK(::SetPixelFormat(m_hDC, iPixelFormat, &chosenPFD))) {
goto error;
}
diff --git a/intern/ghost/intern/GHOST_ContextWGL.h b/intern/ghost/intern/GHOST_ContextWGL.h
index a3fd9de74a1..a990e42c4ff 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.h
+++ b/intern/ghost/intern/GHOST_ContextWGL.h
@@ -41,7 +41,6 @@ class GHOST_ContextWGL : public GHOST_Context {
*/
GHOST_ContextWGL(bool stereoVisual,
bool alphaBackground,
- GHOST_TUns16 numOfAASamples,
HWND hWnd,
HDC hDC,
int contextProfileMask,
@@ -101,14 +100,9 @@ class GHOST_ContextWGL : public GHOST_Context {
GHOST_TSuccess getSwapInterval(int &intervalOut);
private:
- int choose_pixel_format(
- bool stereoVisual, int numOfAASamples, bool needAlpha, bool needStencil, bool sRGB);
-
- int choose_pixel_format_arb(
- bool stereoVisual, int numOfAASamples, bool needAlpha, bool needStencil, bool sRGB);
-
- int _choose_pixel_format_arb_1(
- bool stereoVisual, int numOfAASamples, bool needAlpha, bool needStencil, bool sRGB);
+ int choose_pixel_format(bool stereoVisual, bool needAlpha);
+ int choose_pixel_format_arb(bool stereoVisual, bool needAlpha);
+ int _choose_pixel_format_arb_1(bool stereoVisual, bool needAlpha);
void initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD);
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCocoa.h b/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
index cfdc7be357e..c99e93279f7 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
+++ b/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
@@ -87,11 +87,11 @@ class GHOST_DisplayManagerCocoa : public GHOST_DisplayManager {
const GHOST_DisplaySetting &setting);
protected:
- //Do not cache values as OS X supports screen hot plug
+ // Do not cache values as OS X supports screen hot plug
/** Cached number of displays. */
- //CGDisplayCount m_numDisplays;
+ // CGDisplayCount m_numDisplays;
/** Cached display id's for each display. */
- //CGDirectDisplayID* m_displayIDs;
+ // CGDirectDisplayID* m_displayIDs;
};
#endif // __GHOST_DISPLAYMANAGERCOCOA_H__
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm
index 7f44a14f49c..f060d45c911 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm
+++ b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm
@@ -42,7 +42,7 @@ GHOST_TSuccess GHOST_DisplayManagerCocoa::getNumDisplays(GHOST_TUns8 &numDisplay
GHOST_TSuccess GHOST_DisplayManagerCocoa::getNumDisplaySettings(GHOST_TUns8 display,
GHOST_TInt32 &numSettings) const
{
- numSettings = (GHOST_TInt32)3; //Width, Height, BitsPerPixel
+ numSettings = (GHOST_TInt32)3; // Width, Height, BitsPerPixel
return GHOST_kSuccess;
}
@@ -55,7 +55,7 @@ GHOST_TSuccess GHOST_DisplayManagerCocoa::getDisplaySetting(GHOST_TUns8 display,
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- if (display == kMainDisplay) //Screen #0 may not be the main one
+ if (display == kMainDisplay) // Screen #0 may not be the main one
askedDisplay = [NSScreen mainScreen];
else
askedDisplay = [[NSScreen screens] objectAtIndex:display];
@@ -71,7 +71,7 @@ GHOST_TSuccess GHOST_DisplayManagerCocoa::getDisplaySetting(GHOST_TUns8 display,
setting.bpp = NSBitsPerPixelFromDepth([askedDisplay depth]);
- setting.frequency = 0; //No more CRT display...
+ setting.frequency = 0; // No more CRT display...
#ifdef GHOST_DEBUG
printf("display mode: width=%d, height=%d, bpp=%d, frequency=%d\n",
@@ -96,7 +96,7 @@ GHOST_TSuccess GHOST_DisplayManagerCocoa::getCurrentDisplaySetting(
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- if (display == kMainDisplay) //Screen #0 may not be the main one
+ if (display == kMainDisplay) // Screen #0 may not be the main one
askedDisplay = [NSScreen mainScreen];
else
askedDisplay = [[NSScreen screens] objectAtIndex:display];
@@ -112,7 +112,7 @@ GHOST_TSuccess GHOST_DisplayManagerCocoa::getCurrentDisplaySetting(
setting.bpp = NSBitsPerPixelFromDepth([askedDisplay depth]);
- setting.frequency = 0; //No more CRT display...
+ setting.frequency = 0; // No more CRT display...
#ifdef GHOST_DEBUG
printf("current display mode: width=%d, height=%d, bpp=%d, frequency=%d\n",
@@ -141,7 +141,7 @@ GHOST_TSuccess GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(
printf(" setting.frequency=%d\n", setting.frequency);
#endif // GHOST_DEBUG
- //Display configuration is no more available in 10.6
+ // Display configuration is no more available in 10.6
/* CFDictionaryRef displayModeValues = ::CGDisplayBestModeForParametersAndRefreshRate(
m_displayIDs[display],
@@ -159,7 +159,7 @@ GHOST_TSuccess GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(
printf(" setting.frequency=%d\n", getValue(displayModeValues, kCGDisplayRefreshRate)); */
#endif // GHOST_DEBUG
- //CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues);
+ // CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues);
return /*err == CGDisplayNoErr ?*/ GHOST_kSuccess /*: GHOST_kFailure*/;
}
diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.cpp b/intern/ghost/intern/GHOST_DropTargetWin32.cpp
index b41a133a069..931aca81fb8 100644
--- a/intern/ghost/intern/GHOST_DropTargetWin32.cpp
+++ b/intern/ghost/intern/GHOST_DropTargetWin32.cpp
@@ -119,7 +119,8 @@ HRESULT __stdcall GHOST_DropTargetWin32::DragOver(DWORD grfKeyState, POINTL pt,
}
else {
*pdwEffect = DROPEFFECT_NONE;
- // *pdwEffect = DROPEFFECT_COPY; // XXX Uncomment to test drop. Drop will not be called if pdwEffect == DROPEFFECT_NONE.
+ // XXX Uncomment to test drop. Drop will not be called if pdwEffect == DROPEFFECT_NONE.
+ // *pdwEffect = DROPEFFECT_COPY;
}
m_system->pushDragDropEvent(
GHOST_kEventDraggingUpdated, m_draggedObjectType, m_window, pt.x, pt.y, NULL);
@@ -205,7 +206,7 @@ void *GHOST_DropTargetWin32::getGhostData(IDataObject *pDataObject)
return getDropDataAsString(pDataObject);
break;
case GHOST_kDragnDropTypeBitmap:
- //return getDropDataAsBitmap(pDataObject);
+ // return getDropDataAsBitmap(pDataObject);
break;
default:
#ifdef GHOST_DEBUG
@@ -322,10 +323,10 @@ void *GHOST_DropTargetWin32::getDropDataAsString(IDataObject *pDataObject)
int GHOST_DropTargetWin32::WideCharToANSI(LPCWSTR in, char *&out)
{
int size;
- out = NULL; //caller should free if != NULL
+ out = NULL; // caller should free if != NULL
// Get the required size.
- size = ::WideCharToMultiByte(CP_ACP, //System Default Codepage
+ size = ::WideCharToMultiByte(CP_ACP, // System Default Codepage
0x00000400, // WC_NO_BEST_FIT_CHARS
in,
-1, //-1 null terminated, makes output null terminated too.
@@ -352,7 +353,7 @@ int GHOST_DropTargetWin32::WideCharToANSI(LPCWSTR in, char *&out)
if (!size) {
#ifdef GHOST_DEBUG
::printLastError();
-#endif //GHOST_DEBUG
+#endif // GHOST_DEBUG
::free(out);
out = NULL;
}
diff --git a/intern/ghost/intern/GHOST_EventDragnDrop.h b/intern/ghost/intern/GHOST_EventDragnDrop.h
index 169b0b5d174..8e2a8d806ee 100644
--- a/intern/ghost/intern/GHOST_EventDragnDrop.h
+++ b/intern/ghost/intern/GHOST_EventDragnDrop.h
@@ -35,28 +35,31 @@ extern "C" {
*
* The dragging sequence is performed in four phases:
*
- * <li> Start sequence (GHOST_kEventDraggingEntered) that tells a drag'n'drop operation has started.
- * Already gives the object data type, and the entering mouse location
+ * - Start sequence (GHOST_kEventDraggingEntered) that tells
+ * a drag'n'drop operation has started.
+ * Already gives the object data type, and the entering mouse location
*
- * <li> Update mouse position (GHOST_kEventDraggingUpdated) sent upon each mouse move until the drag'n'drop operation
- * stops, to give the updated mouse position. Useful to highlight a potential destination, and update the status
- * (through GHOST_setAcceptDragOperation) telling if the object can be dropped at
- * the current cursor position.
+ * - Update mouse position (GHOST_kEventDraggingUpdated) sent upon each mouse move until the
+ * drag'n'drop operation stops, to give the updated mouse position.
+ * Useful to highlight a potential destination, and update the status
+ * (through GHOST_setAcceptDragOperation) telling if the object can be dropped at the current
+ * cursor position.
*
- * <li> Abort drag'n'drop sequence (GHOST_kEventDraggingExited) sent when the user moved the mouse outside the window.
+ * - Abort drag'n'drop sequence (GHOST_kEventDraggingExited)
+ * sent when the user moved the mouse outside the window.
*
- * <li> Send the dropped data (GHOST_kEventDraggingDropDone)
+ * - Send the dropped data (GHOST_kEventDraggingDropDone)
*
- * <li> Outside of the normal sequence, dropped data can be sent (GHOST_kEventDraggingDropOnIcon).
- * This can happen when the user drops an object on the application icon.
- * (Also used in OSX to pass the filename of the document the user doubled-clicked in the finder)
+ * - Outside of the normal sequence, dropped data can be sent (GHOST_kEventDraggingDropOnIcon).
+ * This can happen when the user drops an object on the application icon.
+ * (Also used in OSX to pass the filename of the document the user doubled-clicked in the finder)
*
- * <br><br>Note that the mouse positions are given in Blender coordinates (y=0 at bottom)
+ * Note that the mouse positions are given in Blender coordinates (y=0 at bottom)
*
- * <br>Currently supported object types :
- * <li>UTF-8 string
- * <li>array of strings representing filenames (GHOST_TStringArray)
- * <li>bitmap ImBuf
+ * Currently supported object types:
+ * - UTF-8 string.
+ * - array of strings representing filenames (GHOST_TStringArray).
+ * - bitmap #ImBuf.
*/
class GHOST_EventDragnDrop : public GHOST_Event {
public:
@@ -88,7 +91,7 @@ class GHOST_EventDragnDrop : public GHOST_Event {
~GHOST_EventDragnDrop()
{
- //Free the dropped object data
+ // Free the dropped object data
if (m_dragnDropEventData.data == NULL)
return;
diff --git a/intern/ghost/intern/GHOST_ImeWin32.cpp b/intern/ghost/intern/GHOST_ImeWin32.cpp
index 531dbe4b444..06fab47933a 100644
--- a/intern/ghost/intern/GHOST_ImeWin32.cpp
+++ b/intern/ghost/intern/GHOST_ImeWin32.cpp
@@ -271,11 +271,11 @@ void GHOST_ImeWin32::GetCaret(HIMC imm_context, LPARAM lparam, ImeComposition *c
case LANG_JAPANESE:
/**
- * For Japanese IMEs, the robustest way to retrieve the caret
- * is scanning the attribute of the latest composition string and
- * retrieving the begining and the end of the target clause, i.e.
- * a clause being converted.
- */
+ * For Japanese IMEs, the robustest way to retrieve the caret
+ * is scanning the attribute of the latest composition string and
+ * retrieving the begining and the end of the target clause, i.e.
+ * a clause being converted.
+ */
if (lparam & GCS_COMPATTR) {
int attribute_size = ::ImmGetCompositionStringW(imm_context, GCS_COMPATTR, NULL, 0);
if (attribute_size > 0) {
@@ -292,10 +292,10 @@ void GHOST_ImeWin32::GetCaret(HIMC imm_context, LPARAM lparam, ImeComposition *c
}
if (target_start == attribute_size) {
/**
- * This composition clause does not contain any target clauses,
- * i.e. this clauses is an input clause.
- * We treat whole this clause as a target clause.
- */
+ * This composition clause does not contain any target clauses,
+ * i.e. this clauses is an input clause.
+ * We treat whole this clause as a target clause.
+ */
target_end = target_start;
target_start = 0;
}
diff --git a/intern/ghost/intern/GHOST_ImeWin32.h b/intern/ghost/intern/GHOST_ImeWin32.h
index 61fc93a78af..9c1f2473223 100644
--- a/intern/ghost/intern/GHOST_ImeWin32.h
+++ b/intern/ghost/intern/GHOST_ImeWin32.h
@@ -17,7 +17,7 @@
* All rights reserved.
*
* The Original Code is: some of this file.
-*/
+ */
/** \file
* \ingroup GHOST
diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp
index 1530dddd5f1..a696afeae02 100644
--- a/intern/ghost/intern/GHOST_System.cpp
+++ b/intern/ghost/intern/GHOST_System.cpp
@@ -129,8 +129,7 @@ bool GHOST_System::validWindow(GHOST_IWindow *window)
GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting &setting,
GHOST_IWindow **window,
const bool stereoVisual,
- const bool alphaBackground,
- const GHOST_TUns16 numOfAASamples)
+ const bool alphaBackground)
{
GHOST_TSuccess success = GHOST_kFailure;
GHOST_ASSERT(m_windowManager, "GHOST_System::beginFullScreen(): invalid window manager");
@@ -139,13 +138,13 @@ GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting &setting
m_displayManager->getCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay,
m_preFullScreenSetting);
- //GHOST_PRINT("GHOST_System::beginFullScreen(): activating new display settings\n");
+ // GHOST_PRINT("GHOST_System::beginFullScreen(): activating new display settings\n");
success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay,
setting);
if (success == GHOST_kSuccess) {
- //GHOST_PRINT("GHOST_System::beginFullScreen(): creating full-screen window\n");
+ // GHOST_PRINT("GHOST_System::beginFullScreen(): creating full-screen window\n");
success = createFullScreenWindow(
- (GHOST_Window **)window, setting, stereoVisual, alphaBackground, numOfAASamples);
+ (GHOST_Window **)window, setting, stereoVisual, alphaBackground);
if (success == GHOST_kSuccess) {
m_windowManager->beginFullScreen(*window, stereoVisual);
}
@@ -182,11 +181,11 @@ GHOST_TSuccess GHOST_System::endFullScreen(void)
GHOST_TSuccess success = GHOST_kFailure;
GHOST_ASSERT(m_windowManager, "GHOST_System::endFullScreen(): invalid window manager");
if (m_windowManager->getFullScreen()) {
- //GHOST_IWindow* window = m_windowManager->getFullScreenWindow();
- //GHOST_PRINT("GHOST_System::endFullScreen(): leaving window manager full-screen mode\n");
+ // GHOST_IWindow* window = m_windowManager->getFullScreenWindow();
+ // GHOST_PRINT("GHOST_System::endFullScreen(): leaving window manager full-screen mode\n");
success = m_windowManager->endFullScreen();
GHOST_ASSERT(m_displayManager, "GHOST_System::endFullScreen(): invalid display manager");
- //GHOST_PRINT("GHOST_System::endFullScreen(): leaving full-screen mode\n");
+ // GHOST_PRINT("GHOST_System::endFullScreen(): leaving full-screen mode\n");
success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay,
m_preFullScreenSetting);
}
@@ -353,8 +352,7 @@ GHOST_TSuccess GHOST_System::exit()
GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window,
const GHOST_DisplaySetting &settings,
const bool stereoVisual,
- const bool alphaBackground,
- const GHOST_TUns16 numOfAASamples)
+ const bool alphaBackground)
{
GHOST_GLSettings glSettings = {0};
@@ -362,13 +360,12 @@ GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window,
glSettings.flags |= GHOST_glStereoVisual;
if (alphaBackground)
glSettings.flags |= GHOST_glAlphaBackground;
- glSettings.numOfAASamples = numOfAASamples;
/* note: don't use getCurrentDisplaySetting() because on X11 we may
* be zoomed in and the desktop may be bigger then the viewport. */
GHOST_ASSERT(m_displayManager,
"GHOST_System::createFullScreenWindow(): invalid display manager");
- //GHOST_PRINT("GHOST_System::createFullScreenWindow(): creating full-screen window\n");
+ // GHOST_PRINT("GHOST_System::createFullScreenWindow(): creating full-screen window\n");
*window = (GHOST_Window *)createWindow(STR_String(""),
0,
0,
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 2c7025b6036..a62641c5cf5 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -137,8 +137,7 @@ class GHOST_System : public GHOST_ISystem {
GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting &setting,
GHOST_IWindow **window,
const bool stereoVisual,
- const bool alphaBackground,
- const GHOST_TUns16 numOfAASamples = 0);
+ const bool alphaBackground);
/**
* Updates the resolution while in fullscreen mode.
@@ -350,8 +349,7 @@ class GHOST_System : public GHOST_ISystem {
GHOST_TSuccess createFullScreenWindow(GHOST_Window **window,
const GHOST_DisplaySetting &settings,
const bool stereoVisual,
- const bool alphaBackground = 0,
- const GHOST_TUns16 numOfAASamples = 0);
+ const bool alphaBackground = 0);
/** The display manager (platform dependent). */
GHOST_DisplayManager *m_displayManager;
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h
index 9206ef90ee7..749139fee76 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -87,7 +87,8 @@ class GHOST_SystemCocoa : public GHOST_System {
* Create a new window.
* The new window is added to the list of windows managed.
* Never explicitly delete the window, use disposeWindow() instead.
- * \param title The name of the window (displayed in the title bar of the window if the OS supports it).
+ * \param title The name of the window
+ * (displayed in the title bar of the window if the OS supports it).
* \param left The coordinate of the left edge of the window.
* \param top The coordinate of the top edge of the window.
* \param width The width the window.
@@ -150,7 +151,8 @@ class GHOST_SystemCocoa : public GHOST_System {
/**
* Handles a drag'n'drop destination event. Called by GHOST_WindowCocoa window subclass
* \param eventType The type of drag'n'drop event
- * \param draggedObjectType The type object concerned (currently array of file names, string, TIFF image)
+ * \param draggedObjectType The type object concerned
+ * (currently array of file names, string, TIFF image)
* \param mouseX x mouse coordinate (in cocoa base window coordinates)
* \param mouseY y mouse coordinate
* \param window The window on which the event occurred
@@ -291,10 +293,12 @@ class GHOST_SystemCocoa : public GHOST_System {
/** Start time at initialization. */
GHOST_TUns64 m_start_time;
- /** Event has been processed directly by Cocoa (or NDOF manager) and has sent a ghost event to be dispatched */
+ /** Event has been processed directly by Cocoa (or NDOF manager)
+ * and has sent a ghost event to be dispatched */
bool m_outsideLoopEventProcessed;
- /** Raised window is not yet known by the window manager, so delay application become active event handling */
+ /** Raised window is not yet known by the window manager,
+ * so delay application become active event handling */
bool m_needDelayedApplicationBecomeActiveEventProcessing;
/** State of the modifiers. */
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 903fe4a6e8d..1fd0914eb73 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -86,7 +86,7 @@ static GHOST_TButtonMask convertButton(int button)
*/
static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
{
- //printf("\nrecvchar %c 0x%x",recvChar,recvChar);
+ // printf("\nrecvchar %c 0x%x",recvChar,recvChar);
switch (rawCode) {
/*Physical keycodes not used due to map changes in int'l keyboards
case kVK_ANSI_A: return GHOST_kKeyA;
@@ -341,7 +341,8 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
static bool g_hasFirstFile = false;
static char g_firstFileBuf[512];
-//TODO:Need to investigate this. Function called too early in creator.c to have g_hasFirstFile == true
+// TODO: Need to investigate this.
+// Function called too early in creator.c to have g_hasFirstFile == true
extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
{
if (g_hasFirstFile) {
@@ -423,8 +424,9 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
- //TODO: implement graceful termination through Cocoa mechanism to avoid session log off to be canceled
- //Note that Cmd+Q is already handled by keyhandler
+ /* TODO: implement graceful termination through Cocoa mechanism
+ * to avoid session log off to be canceled. */
+ /* Note that Cmd+Q is already handled by keyhandler. */
if (systemCocoa->handleQuitRequest() == GHOST_kExitNow)
return NSTerminateCancel; //NSTerminateNow;
else
@@ -514,7 +516,7 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
GHOST_ASSERT(m_displayManager, "GHOST_SystemCocoa::GHOST_SystemCocoa(): m_displayManager==0\n");
m_displayManager->initialize();
- //NSEvent timeStamp is given in system uptime, state start date is boot time
+ // NSEvent timeStamp is given in system uptime, state start date is boot time
mib[0] = CTL_KERN;
mib[1] = KERN_BOOTTIME;
len = sizeof(struct timeval);
@@ -522,7 +524,7 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
sysctl(mib, 2, &boottime, &len, NULL, 0);
m_start_time = ((boottime.tv_sec * 1000) + (boottime.tv_usec / 1000));
- //Detect multitouch trackpad
+ // Detect multitouch trackpad
mib[0] = CTL_HW;
mib[1] = HW_MODEL;
sysctl(mib, 2, NULL, &len, NULL, 0);
@@ -550,9 +552,9 @@ GHOST_TSuccess GHOST_SystemCocoa::init()
m_ndofManager = new GHOST_NDOFManagerCocoa(*this);
#endif
- //ProcessSerialNumber psn;
+ // ProcessSerialNumber psn;
- //Carbon stuff to move window & menu to foreground
+ // Carbon stuff to move window & menu to foreground
/*if (!GetCurrentProcess(&psn)) {
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
@@ -567,7 +569,7 @@ GHOST_TSuccess GHOST_SystemCocoa::init()
NSMenu *windowMenu;
NSMenu *appMenu;
- //Create the application menu
+ // Create the application menu
appMenu = [[NSMenu alloc] initWithTitle:@"Blender"];
[appMenu addItemWithTitle:@"About Blender"
@@ -599,10 +601,10 @@ GHOST_TSuccess GHOST_SystemCocoa::init()
[mainMenubar addItem:menuItem];
[menuItem release];
- [NSApp performSelector:@selector(setAppleMenu:) withObject:appMenu]; //Needed for 10.5
+ [NSApp performSelector:@selector(setAppleMenu:) withObject:appMenu]; // Needed for 10.5
[appMenu release];
- //Create the window menu
+ // Create the window menu
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
menuItem = [windowMenu addItemWithTitle:@"Minimize"
@@ -650,19 +652,19 @@ GHOST_TSuccess GHOST_SystemCocoa::init()
GHOST_TUns64 GHOST_SystemCocoa::getMilliSeconds() const
{
- //Cocoa equivalent exists in 10.6 ([[NSProcessInfo processInfo] systemUptime])
+ // Cocoa equivalent exists in 10.6 ([[NSProcessInfo processInfo] systemUptime])
struct timeval currentTime;
gettimeofday(&currentTime, NULL);
- //Return timestamp of system uptime
+ // Return timestamp of system uptime
return ((currentTime.tv_sec * 1000) + (currentTime.tv_usec / 1000) - m_start_time);
}
GHOST_TUns8 GHOST_SystemCocoa::getNumDisplays() const
{
- //Note that OS X supports monitor hot plug
+ // Note that OS X supports monitor hot plug
// We do not support multiple monitors at the moment
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -675,10 +677,10 @@ GHOST_TUns8 GHOST_SystemCocoa::getNumDisplays() const
void GHOST_SystemCocoa::getMainDisplayDimensions(GHOST_TUns32 &width, GHOST_TUns32 &height) const
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- //Get visible frame, that is frame excluding dock and top menu bar
+ // Get visible frame, that is frame excluding dock and top menu bar
NSRect frame = [[NSScreen mainScreen] visibleFrame];
- //Returns max window contents (excluding title bar...)
+ // Returns max window contents (excluding title bar...)
NSRect contentRect = [NSWindow
contentRectForFrameRect:frame
styleMask:(NSTitledWindowMask | NSClosableWindowMask |
@@ -710,7 +712,7 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const STR_String &title,
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
GHOST_IWindow *window = NULL;
- //Get the available rect for including window contents
+ // Get the available rect for including window contents
NSRect frame = [[NSScreen mainScreen] visibleFrame];
NSRect contentRect = [NSWindow
contentRectForFrameRect:frame
@@ -719,7 +721,7 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const STR_String &title,
GHOST_TInt32 bottom = (contentRect.size.height - 1) - height - top;
- //Ensures window top left is inside this available rect
+ // Ensures window top left is inside this available rect
left = left > contentRect.origin.x ? left : contentRect.origin.x;
// Add contentRect.origin.y to respect docksize
bottom = bottom > contentRect.origin.y ? bottom + contentRect.origin.y : contentRect.origin.y;
@@ -733,7 +735,6 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const STR_String &title,
state,
type,
glSettings.flags & GHOST_glStereoVisual,
- glSettings.numOfAASamples,
glSettings.flags & GHOST_glDebugContext);
if (window->getValid()) {
@@ -741,7 +742,8 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const STR_String &title,
GHOST_ASSERT(m_windowManager, "m_windowManager not initialized");
m_windowManager->addWindow(window);
m_windowManager->setActiveWindow(window);
- //Need to tell window manager the new window is the active one (Cocoa does not send the event activate upon window creation)
+ /* Need to tell window manager the new window is the active one
+ * (Cocoa does not send the event activate upon window creation). */
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window));
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
}
@@ -763,7 +765,6 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const STR_String &title,
GHOST_IContext *GHOST_SystemCocoa::createOffscreenContext()
{
GHOST_Context *context = new GHOST_ContextCGL(false,
- 0,
NULL,
NULL,
@@ -821,13 +822,13 @@ GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32
if (!window)
return GHOST_kFailure;
- //Cursor and mouse dissociation placed here not to interfere with continuous grab
+ // Cursor and mouse dissociation placed here not to interfere with continuous grab
// (in cont. grab setMouseCursorPosition is directly called)
CGAssociateMouseAndMouseCursorPosition(false);
setMouseCursorPosition(x, y);
CGAssociateMouseAndMouseCursorPosition(true);
- //Force mouse move event (not pushed by Cocoa)
+ // Force mouse move event (not pushed by Cocoa)
pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, x, y));
m_outsideLoopEventProcessed = true;
@@ -845,11 +846,11 @@ GHOST_TSuccess GHOST_SystemCocoa::setMouseCursorPosition(GHOST_TInt32 x, GHOST_T
NSScreen *windowScreen = window->getScreen();
NSRect screenRect = [windowScreen frame];
- //Set position relative to current screen
+ // Set position relative to current screen
xf -= screenRect.origin.x;
yf -= screenRect.origin.y;
- //Quartz Display Services uses the old coordinates (top left origin)
+ // Quartz Display Services uses the old coordinates (top left origin)
yf = screenRect.size.height - yf;
CGDisplayMoveCursorToPoint((CGDirectDisplayID)[[[windowScreen deviceDescription]
@@ -901,7 +902,7 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent)
NSEvent *event;
// SetMouseCoalescingEnabled(false, NULL);
- //TODO : implement timer ??
+ // TODO : implement timer ??
#if 0
do {
GHOST_TimerManager* timerMgr = getTimerManager();
@@ -981,11 +982,11 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent)
return anyProcessed;
}
-//Note: called from NSApplication delegate
+// Note: called from NSApplication delegate
GHOST_TSuccess GHOST_SystemCocoa::handleApplicationBecomeActiveEvent()
{
- //Update the modifiers key mask, as its status may have changed when the application was not active
- //(that is when update events are sent to another application)
+ // Update the modifiers key mask, as its status may have changed when the application
+ // was not active (that is when update events are sent to another application).
unsigned int modifiers;
GHOST_IWindow *window = m_windowManager->getActiveWindow();
@@ -1038,7 +1039,7 @@ void GHOST_SystemCocoa::notifyExternalEventProcessed()
m_outsideLoopEventProcessed = true;
}
-//Note: called from NSWindow delegate
+// Note: called from NSWindow delegate
GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType,
GHOST_WindowCocoa *window)
{
@@ -1079,13 +1080,15 @@ GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType,
break;
case GHOST_kEventWindowSize:
if (!m_ignoreWindowSizedMessages) {
- //Enforce only one resize message per event loop (coalescing all the live resize messages)
+ // Enforce only one resize message per event loop
+ // (coalescing all the live resize messages)
window->updateDrawingContext();
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
- //Mouse up event is trapped by the resizing event loop, so send it anyway to the window manager
+ // Mouse up event is trapped by the resizing event loop,
+ // so send it anyway to the window manager.
pushEvent(new GHOST_EventButton(
getMilliSeconds(), GHOST_kEventButtonUp, window, GHOST_kButtonMaskLeft));
- //m_ignoreWindowSizedMessages = true;
+ // m_ignoreWindowSizedMessages = true;
}
break;
case GHOST_kEventNativeResolutionChange:
@@ -1104,7 +1107,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType,
return GHOST_kSuccess;
}
-//Note: called from NSWindow subclass
+// Note: called from NSWindow subclass
GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType,
GHOST_TDragnDropTypes draggedObjectType,
GHOST_WindowCocoa *window,
@@ -1240,7 +1243,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
/* As Core Graphics does not support contextes with non premutliplied alpha,
we need to get alpha key values in a separate batch */
- /* First get RGB values w/o Alpha to avoid pre-multiplication, 32bit but last byte is unused */
+ /* First get RGB values w/o Alpha to avoid pre-multiplication,
+ * 32bit but last byte is unused */
blBitmapFormatImageRGB = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:imgSize.width
@@ -1342,11 +1346,11 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest()
{
GHOST_Window *window = (GHOST_Window *)m_windowManager->getActiveWindow();
- //Discard quit event if we are in cursor grab sequence
+ // Discard quit event if we are in cursor grab sequence
if (window && window->getCursorGrabModeIsWarp())
return GHOST_kExitCancel;
- //Check open windows if some changes are not saved
+ // Check open windows if some changes are not saved
if (m_windowManager->getAnyModifiedState()) {
int shouldQuit = NSRunAlertPanel(
@"Exit Blender",
@@ -1359,14 +1363,14 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest()
return GHOST_kExitNow;
}
else {
- //Give back focus to the blender window if user selected cancel quit
+ // Give back focus to the blender window if user selected cancel quit
NSArray *windowsList = [NSApp orderedWindows];
if ([windowsList count]) {
[[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
- //Handle the modifiers keyes changed state issue
- //as recovering from the quit dialog is like application
- //gaining focus back.
- //Main issue fixed is Cmd modifier not being cleared
+ // Handle the modifiers keyes changed state issue
+ // as recovering from the quit dialog is like application
+ // gaining focus back.
+ // Main issue fixed is Cmd modifier not being cleared
handleApplicationBecomeActiveEvent();
}
}
@@ -1393,11 +1397,12 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
return NO;
}
- //Discard event if we are in cursor grab sequence, it'll lead to "stuck cursor" situation if the alert panel is raised
+ /* Discard event if we are in cursor grab sequence,
+ * it'll lead to "stuck cursor" situation if the alert panel is raised */
if (window && window->getCursorGrabModeIsWarp())
return GHOST_kExitCancel;
- //Check open windows if some changes are not saved
+ // Check open windows if some changes are not saved
if (m_windowManager->getAnyModifiedState()) {
confirmOpen = NSRunAlertPanel(
[NSString stringWithFormat:@"Opening %@", [filepath lastPathComponent]],
@@ -1407,7 +1412,7 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
nil);
}
- //Give back focus to the blender window
+ // Give back focus to the blender window
windowsList = [NSApp orderedWindows];
if ([windowsList count]) {
[[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
@@ -1442,7 +1447,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventT
window = m_windowManager->getWindowAssociatedWithOSWindow((void *)[event window]);
if (!window) {
- //printf("\nW failure for event 0x%x",[event type]);
+ // printf("\nW failure for event 0x%x",[event type]);
return GHOST_kFailure;
}
@@ -1466,7 +1471,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventT
ct.Xtilt = 0;
ct.Ytilt = 0;
if ([event isEnteringProximity]) {
- //pointer is entering tablet area proximity
+ // pointer is entering tablet area proximity
switch ([event pointingDeviceType]) {
case NSPenPointingDevice:
ct.Active = GHOST_kTabletModeStylus;
@@ -1507,7 +1512,7 @@ bool GHOST_SystemCocoa::handleTabletEvent(void *eventPtr)
handleTabletEvent(eventPtr, NSTabletProximity);
return true;
default:
- //No tablet event included : do nothing
+ // No tablet event included : do nothing
return false;
}
}
@@ -1526,7 +1531,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
if (!window) {
window = (GHOST_WindowCocoa *)m_windowManager->getActiveWindow();
if (!window) {
- //printf("\nW failure for event 0x%x",[event type]);
+ // printf("\nW failure for event 0x%x",[event type]);
return GHOST_kFailure;
}
}
@@ -1537,43 +1542,43 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
case NSLeftMouseDown:
pushEvent(new GHOST_EventButton(
[event timestamp] * 1000, GHOST_kEventButtonDown, window, GHOST_kButtonMaskLeft));
- handleTabletEvent(event); //Handle tablet events combined with mouse events
+ handleTabletEvent(event); // Handle tablet events combined with mouse events
break;
case NSRightMouseDown:
pushEvent(new GHOST_EventButton(
[event timestamp] * 1000, GHOST_kEventButtonDown, window, GHOST_kButtonMaskRight));
- handleTabletEvent(event); //Handle tablet events combined with mouse events
+ handleTabletEvent(event); // Handle tablet events combined with mouse events
break;
case NSOtherMouseDown:
pushEvent(new GHOST_EventButton([event timestamp] * 1000,
GHOST_kEventButtonDown,
window,
convertButton([event buttonNumber])));
- handleTabletEvent(event); //Handle tablet events combined with mouse events
+ handleTabletEvent(event); // Handle tablet events combined with mouse events
break;
case NSLeftMouseUp:
pushEvent(new GHOST_EventButton(
[event timestamp] * 1000, GHOST_kEventButtonUp, window, GHOST_kButtonMaskLeft));
- handleTabletEvent(event); //Handle tablet events combined with mouse events
+ handleTabletEvent(event); // Handle tablet events combined with mouse events
break;
case NSRightMouseUp:
pushEvent(new GHOST_EventButton(
[event timestamp] * 1000, GHOST_kEventButtonUp, window, GHOST_kButtonMaskRight));
- handleTabletEvent(event); //Handle tablet events combined with mouse events
+ handleTabletEvent(event); // Handle tablet events combined with mouse events
break;
case NSOtherMouseUp:
pushEvent(new GHOST_EventButton([event timestamp] * 1000,
GHOST_kEventButtonUp,
window,
convertButton([event buttonNumber])));
- handleTabletEvent(event); //Handle tablet events combined with mouse events
+ handleTabletEvent(event); // Handle tablet events combined with mouse events
break;
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSOtherMouseDragged:
- //Handle tablet events combined with mouse events
+ // Handle tablet events combined with mouse events
handleTabletEvent(event);
case NSMouseMoved: {
@@ -1587,7 +1592,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
}
switch (grab_mode) {
- case GHOST_kGrabHide: //Cursor hidden grab operation : no cursor move
+ case GHOST_kGrabHide: // Cursor hidden grab operation : no cursor move
{
GHOST_TInt32 x_warp, y_warp, x_accum, y_accum, x, y;
@@ -1597,7 +1602,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
window->getCursorGrabAccum(x_accum, y_accum);
x_accum += [event deltaX];
y_accum += -[event
- deltaY]; //Strange Apple implementation (inverted coordinates for the deltaY) ...
+ deltaY]; // Strange Apple implementation (inverted coordinates for the deltaY) ...
window->setCursorGrabAccum(x_accum, y_accum);
window->clientToScreenIntern(x_warp + x_accum, y_warp + y_accum, x, y);
@@ -1605,7 +1610,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
[event timestamp] * 1000, GHOST_kEventCursorMove, window, x, y));
break;
}
- case GHOST_kGrabWrap: //Wrap cursor at area/window boundaries
+ case GHOST_kGrabWrap: // Wrap cursor at area/window boundaries
{
NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
GHOST_TInt32 x_mouse = mousePos.x;
@@ -1616,23 +1621,24 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
if (window->getCursorGrabBounds(bounds) == GHOST_kFailure)
window->getClientBounds(bounds);
- //Switch back to Cocoa coordinates orientation (y=0 at botton,the same as blender internal btw!), and to client coordinates
+ /* Switch back to Cocoa coordinates orientation
+ * (y=0 at botton,the same as blender internal btw!), and to client coordinates. */
window->getClientBounds(windowBounds);
window->screenToClient(bounds.m_l, bounds.m_b, correctedBounds.m_l, correctedBounds.m_t);
window->screenToClient(bounds.m_r, bounds.m_t, correctedBounds.m_r, correctedBounds.m_b);
correctedBounds.m_b = (windowBounds.m_b - windowBounds.m_t) - correctedBounds.m_b;
correctedBounds.m_t = (windowBounds.m_b - windowBounds.m_t) - correctedBounds.m_t;
- //Get accumulation from previous mouse warps
+ // Get accumulation from previous mouse warps
GHOST_TInt32 x_accum, y_accum;
window->getCursorGrabAccum(x_accum, y_accum);
- //Warp mouse cursor if needed
+ // Warp mouse cursor if needed
GHOST_TInt32 warped_x_mouse = x_mouse;
GHOST_TInt32 warped_y_mouse = y_mouse;
correctedBounds.wrapPoint(warped_x_mouse, warped_y_mouse, 4);
- //Set new cursor position
+ // Set new cursor position
if (x_mouse != warped_x_mouse || y_mouse != warped_y_mouse) {
GHOST_TInt32 warped_x, warped_y;
window->clientToScreenIntern(warped_x_mouse, warped_y_mouse, warped_x, warped_y);
@@ -1641,7 +1647,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
y_accum + (y_mouse - warped_y_mouse));
}
- //Generate event
+ // Generate event
GHOST_TInt32 x, y;
window->clientToScreenIntern(x_mouse + x_accum, y_mouse + y_accum, x, y);
pushEvent(new GHOST_EventCursor(
@@ -1649,7 +1655,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
break;
}
default: {
- //Normal cursor operation: send mouse position in window
+ // Normal cursor operation: send mouse position in window
NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
GHOST_TInt32 x, y;
@@ -1671,9 +1677,9 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
phase = [event phase];
/* when pressing a key while momentum scrolling continues after
- * lifting fingers off the trackpad, the action can unexpectedly
- * change from e.g. scrolling to zooming. this works around the
- * issue by ignoring momentum scroll after a key press */
+ * lifting fingers off the trackpad, the action can unexpectedly
+ * change from e.g. scrolling to zooming. this works around the
+ * issue by ignoring momentum scroll after a key press */
if (momentumPhase) {
if (m_ignoreMomentumScroll)
break;
@@ -1683,14 +1689,15 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
}
/* we assume phases are only set for gestures from trackpad or magic
- * mouse events. note that using tablet at the same time may not work
- * since this is a static variable */
+ * mouse events. note that using tablet at the same time may not work
+ * since this is a static variable */
if (phase == NSEventPhaseBegan)
m_multiTouchScroll = true;
else if (phase == NSEventPhaseEnded)
m_multiTouchScroll = false;
- /* standard scrollwheel case, if no swiping happened, and no momentum (kinetic scroll) works */
+ /* Standard scrollwheel case, if no swiping happened,
+ * and no momentum (kinetic scroll) works. */
if (!m_multiTouchScroll && momentumPhase == NSEventPhaseNone) {
GHOST_TInt32 delta;
@@ -1699,7 +1706,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
if (deltaF == 0.0)
deltaF = [event deltaX]; // make blender decide if it's horizontal scroll
if (deltaF == 0.0)
- break; //discard trackpad delta=0 events
+ break; // discard trackpad delta=0 events
delta = deltaF > 0.0 ? 1 : -1;
pushEvent(new GHOST_EventWheel([event timestamp] * 1000, window, delta));
@@ -1714,7 +1721,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
dx = [event scrollingDeltaX];
dy = [event scrollingDeltaY];
- /* however, wacom tablet (intuos5) needs old deltas, it then has momentum and phase at zero */
+ /* However, wacom tablet (intuos5) needs old deltas,
+ * it then has momentum and phase at zero. */
if (phase == NSEventPhaseNone && momentumPhase == NSEventPhaseNone) {
dx = [event deltaX];
dy = [event deltaY];
@@ -1772,7 +1780,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
window = m_windowManager->getWindowAssociatedWithOSWindow((void *)[event window]);
if (!window) {
- //printf("\nW failure for event 0x%x",[event type]);
+ // printf("\nW failure for event 0x%x",[event type]);
return GHOST_kFailure;
}
@@ -1817,7 +1825,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
utf8_buf[0] = '\0';
if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSCommandKeyMask))
- break; //Cmd-Q is directly handled by Cocoa
+ break; // Cmd-Q is directly handled by Cocoa
/* ascii is a subset of unicode */
if (utf8_buf[0] && !utf8_buf[1]) {
@@ -1827,12 +1835,30 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
if ([event type] == NSKeyDown) {
pushEvent(new GHOST_EventKey(
[event timestamp] * 1000, GHOST_kEventKeyDown, window, keyCode, ascii, utf8_buf));
- //printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
+#if 0
+ printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",
+ [event keyCode],
+ [charsIgnoringModifiers length] > 0 ? [charsIgnoringModifiers characterAtIndex:0] :
+ ' ',
+ keyCode,
+ ascii,
+ ascii,
+ utf8_buf);
+#endif
}
else {
pushEvent(new GHOST_EventKey(
[event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, 0, NULL));
- //printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
+#if 0
+ printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",
+ [event keyCode],
+ [charsIgnoringModifiers length] > 0 ? [charsIgnoringModifiers characterAtIndex:0] :
+ ' ',
+ keyCode,
+ ascii,
+ ascii,
+ utf8_buf);
+#endif
}
m_ignoreMomentumScroll = true;
break;
diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp b/intern/ghost/intern/GHOST_SystemSDL.cpp
index 81f1a4007cb..7b0407c6c4c 100644
--- a/intern/ghost/intern/GHOST_SystemSDL.cpp
+++ b/intern/ghost/intern/GHOST_SystemSDL.cpp
@@ -37,10 +37,7 @@ GHOST_SystemSDL::GHOST_SystemSDL() : GHOST_System()
printf("Error initializing SDL: %s\n", SDL_GetError());
}
- /* SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); */
- /* SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); */
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
@@ -75,8 +72,7 @@ GHOST_IWindow *GHOST_SystemSDL::createWindow(const STR_String &title,
parentWindow,
type,
((glSettings.flags & GHOST_glStereoVisual) != 0),
- exclusive,
- glSettings.numOfAASamples);
+ exclusive);
if (window) {
if (GHOST_kWindowStateFullScreen == state) {
@@ -145,7 +141,6 @@ GHOST_TUns8 GHOST_SystemSDL::getNumDisplays() const
GHOST_IContext *GHOST_SystemSDL::createOffscreenContext()
{
GHOST_Context *context = new GHOST_ContextSDL(0,
- 0,
NULL,
0, // profile bit
3,
@@ -318,7 +313,7 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
SDL_WindowEvent &sdl_sub_evt = sdl_event->window;
GHOST_WindowSDL *window = findGhostWindow(
SDL_GetWindowFromID_fallback(sdl_sub_evt.windowID));
- //assert(window != NULL); // can be NULL on close window.
+ // assert(window != NULL); // can be NULL on close window.
switch (sdl_sub_evt.event) {
case SDL_WINDOWEVENT_EXPOSED:
@@ -458,7 +453,8 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
assert(window != NULL);
GHOST_TKey gkey = convertSDLKey(sdl_sub_evt.keysym.scancode);
- /* note, the sdl_sub_evt.keysym.sym is truncated, for unicode support ghost has to be modified */
+ /* note, the sdl_sub_evt.keysym.sym is truncated,
+ * for unicode support ghost has to be modified */
/* printf("%d\n", sym); */
if (sym > 127) {
switch (sym) {
@@ -636,7 +632,7 @@ bool GHOST_SystemSDL::generateWindowExposeEvents()
(*w_start)->validate();
if (g_event) {
- //printf("Expose events pushed\n");
+ // printf("Expose events pushed\n");
pushEvent(g_event);
anyProcessed = true;
}
@@ -661,7 +657,7 @@ bool GHOST_SystemSDL::processEvents(bool waitForEvent)
if (next == GHOST_kFireTimeNever) {
SDL_WaitEventTimeout(NULL, -1);
- //SleepTillEvent(m_display, -1);
+ // SleepTillEvent(m_display, -1);
}
else {
GHOST_TInt64 maxSleep = next - getMilliSeconds();
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index ab159e91d85..5d882fd6dcb 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -279,7 +279,6 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow(const STR_String &title,
type,
((glSettings.flags & GHOST_glStereoVisual) != 0),
((glSettings.flags & GHOST_glAlphaBackground) != 0),
- glSettings.numOfAASamples,
parentWindow,
((glSettings.flags & GHOST_glDebugContext) != 0));
@@ -327,7 +326,6 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
for (int minor = 5; minor >= 0; --minor) {
context = new GHOST_ContextWGL(false,
true,
- 0,
wnd,
mHDC,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
@@ -346,7 +344,6 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
context = new GHOST_ContextWGL(false,
true,
- 0,
wnd,
mHDC,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
@@ -370,11 +367,11 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
}
#elif defined(WITH_GL_PROFILE_COMPAT)
- // ask for 2.1 context, driver gives any GL version >= 2.1 (hopefully the latest compatibility profile)
+ // ask for 2.1 context, driver gives any GL version >= 2.1
+ // (hopefully the latest compatibility profile)
// 2.1 ignores the profile bit & is incompatible with core profile
context = new GHOST_ContextWGL(false,
true,
- 0,
NULL,
NULL,
0, // no profile bit
@@ -1003,9 +1000,11 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA
int r;
GetKeyboardState((PBYTE)state);
- // don't call ToUnicodeEx on dead keys as it clears the buffer and so won't allow diacritical composition.
+ // Don't call ToUnicodeEx on dead keys as it clears the buffer and so won't allow diacritical
+ // composition.
if (MapVirtualKeyW(vk, 2) != 0) {
- // todo: ToUnicodeEx can respond with up to 4 utf16 chars (only 2 here). Could be up to 24 utf8 bytes.
+ // todo: ToUnicodeEx can respond with up to 4 utf16 chars (only 2 here).
+ // Could be up to 24 utf8 bytes.
if ((r = ToUnicodeEx(
vk, raw.data.keyboard.MakeCode, state, utf16, 2, 0, system->m_keylayout))) {
if ((r > 0 && r < 3)) {
@@ -1195,7 +1194,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
if (wParam == RIM_INPUTSINK) {
if (GetFocus() != hwnd) // WM_INPUT message not for this window
return 0;
- } //else wParam == RIM_INPUT
+ } // else wParam == RIM_INPUT
RAWINPUT raw;
RAWINPUT *raw_ptr = &raw;
@@ -1437,8 +1436,8 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
////////////////////////////////////////////////////////////////////////
case WM_NCMOUSEMOVE:
/* The WM_NCMOUSEMOVE message is posted to a window when the cursor is moved
- * within the nonclient area of the window. This message is posted to the window
- * that contains the cursor. If a window has captured the mouse, this message is not posted.
+ * within the nonclient area of the window. This message is posted to the window that
+ * contains the cursor. If a window has captured the mouse, this message is not posted.
*/
case WM_NCHITTEST:
/* The WM_NCHITTEST message is sent to a window when the cursor moves, or
@@ -1452,16 +1451,17 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
// Window events, processed
////////////////////////////////////////////////////////////////////////
case WM_CLOSE:
- /* The WM_CLOSE message is sent as a signal that a window or an application should terminate. */
+ /* The WM_CLOSE message is sent as a signal that a window
+ * or an application should terminate. */
event = processWindowEvent(GHOST_kEventWindowClose, window);
break;
case WM_ACTIVATE:
- /* The WM_ACTIVATE message is sent to both the window being activated and the window being
- * deactivated. If the windows use the same input queue, the message is sent synchronously,
- * first to the window procedure of the top-level window being deactivated, then to the window
- * procedure of the top-level window being activated. If the windows use different input queues,
- * the message is sent asynchronously, so the window is activated immediately.
- */
+ /* The WM_ACTIVATE message is sent to both the window being activated and the window
+ * being deactivated. If the windows use the same input queue, the message is sent
+ * synchronously, first to the window procedure of the top-level window being
+ * deactivated, then to the window procedure of the top-level window being activated.
+ * If the windows use different input queues, the message is sent asynchronously,
+ * so the window is activated immediately. */
{
GHOST_ModifierKeys modifiers;
modifiers.clear();
@@ -1471,7 +1471,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
GHOST_kEventWindowDeactivate,
window);
/* WARNING: Let DefWindowProc handle WM_ACTIVATE, otherwise WM_MOUSEWHEEL
- * will not be dispatched to OUR active window if we minimize one of OUR windows. */
+ * will not be dispatched to OUR active window if we minimize one of OUR windows. */
if (LOWORD(wParam) == WA_INACTIVE)
window->lostMouseCapture();
window->processWin32TabletActivateEvent(GET_WM_ACTIVATE_STATE(wParam, lParam));
@@ -1523,7 +1523,8 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* to perform any move or size change processing during the WM_WINDOWPOSCHANGED
* message without calling DefWindowProc.
*/
- /* we get first WM_SIZE before we fully init. So, do not dispatch before we continiously resizng */
+ /* we get first WM_SIZE before we fully init.
+ * So, do not dispatch before we continiously resizng */
if (window->m_inLiveResize) {
system->pushEvent(processWindowEvent(GHOST_kEventWindowSize, window));
system->dispatchEvents();
@@ -1557,9 +1558,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
case WM_DPICHANGED:
- /* The WM_DPICHANGED message is sent when the effective dots per inch (dpi) for a window has changed.
- * The DPI is the scale factor for a window. There are multiple events that can cause the DPI to
- * change such as when the window is moved to a monitor with a different DPI.
+ /* The WM_DPICHANGED message is sent when the effective dots per inch (dpi) for a
+ * window has changed. The DPI is the scale factor for a window. There are multiple
+ * events that can cause the DPI tochange such as when the window is moved to a monitor
+ * with a different DPI.
*/
{
// The suggested new size and position of the window.
@@ -1598,31 +1600,33 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* invalidated portion of a window for painting.
*/
case WM_NCPAINT:
- /* An application sends the WM_NCPAINT message to a window when its frame must be painted. */
+ /* An application sends the WM_NCPAINT message to a window
+ * when its frame must be painted. */
case WM_NCACTIVATE:
- /* The WM_NCACTIVATE message is sent to a window when its nonclient area needs to be changed
- * to indicate an active or inactive state.
- */
+ /* The WM_NCACTIVATE message is sent to a window when its nonclient area needs to be
+ * changed to indicate an active or inactive state. */
case WM_DESTROY:
- /* The WM_DESTROY message is sent when a window is being destroyed. It is sent to the window
- * procedure of the window being destroyed after the window is removed from the screen.
- * This message is sent first to the window being destroyed and then to the child windows
- * (if any) as they are destroyed. During the processing of the message, it can be assumed
- * that all child windows still exist.
- */
+ /* The WM_DESTROY message is sent when a window is being destroyed. It is sent to the
+ * window procedure of the window being destroyed after the window is removed from the
+ * screen. This message is sent first to the window being destroyed and then to the child
+ * windows (if any) as they are destroyed. During the processing of the message, it can
+ * be assumed that all child windows still exist. */
case WM_NCDESTROY:
- /* The WM_NCDESTROY message informs a window that its nonclient area is being destroyed. The
- * DestroyWindow function sends the WM_NCDESTROY message to the window following the WM_DESTROY
- * message. WM_DESTROY is used to free the allocated memory object associated with the window.
+ /* The WM_NCDESTROY message informs a window that its nonclient area is being
+ * destroyed. The DestroyWindow function sends the WM_NCDESTROY message to the window
+ * following the WM_DESTROY message. WM_DESTROY is used to free the allocated memory
+ * object associated with the window.
*/
break;
case WM_KILLFOCUS:
- /* The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus.
- * We want to prevent this if a window is still active and it loses focus to nowhere*/
+ /* The WM_KILLFOCUS message is sent to a window immediately before it loses the
+ * keyboard focus. We want to prevent this if a window is still active and it loses
+ * focus to nowhere. */
if (!wParam && hwnd == ::GetActiveWindow())
::SetFocus(hwnd);
case WM_SHOWWINDOW:
- /* The WM_SHOWWINDOW message is sent to a window when the window is about to be hidden or shown. */
+ /* The WM_SHOWWINDOW message is sent to a window when the window is
+ * about to be hidden or shown. */
case WM_WINDOWPOSCHANGING:
/* The WM_WINDOWPOSCHANGING message is sent to a window whose size, position, or place in
* the Z order is about to change as a result of a call to the SetWindowPos function or
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index 0eb91d511b1..98b18d2c00b 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -102,7 +102,8 @@ class GHOST_SystemWin32 : public GHOST_System {
* Create a new window.
* The new window is added to the list of windows managed.
* Never explicitly delete the window, use disposeWindow() instead.
- * \param title The name of the window (displayed in the title bar of the window if the OS supports it).
+ * \param title The name of the window
+ * (displayed in the title bar of the window if the OS supports it).
* \param left The coordinate of the left edge of the window.
* \param top The coordinate of the top edge of the window.
* \param width The width the window.
@@ -205,11 +206,12 @@ class GHOST_SystemWin32 : public GHOST_System {
/**
* Creates a drag'n'drop event and pushes it immediately onto the event queue.
* Called by GHOST_DropTargetWin32 class.
- * \param eventType The type of drag'n'drop event
- * \param draggedObjectType The type object concerned (currently array of file names, string, ?bitmap)
- * \param mouseX x mouse coordinate (in window coordinates)
- * \param mouseY y mouse coordinate
- * \param window The window on which the event occurred
+ * \param eventType: The type of drag'n'drop event
+ * \param draggedObjectType: The type object concerned
+ * (currently array of file names, string, ?bitmap)
+ * \param mouseX: x mouse coordinate (in window coordinates)
+ * \param mouseY: y mouse coordinate
+ * \param window: The window on which the event occurred
* \return Indication whether the event was handled.
*/
static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType,
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index b850619e851..c688d7713b2 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -88,8 +88,8 @@
/* see [#34039] Fix Alt key glitch on Unity desktop */
#define USE_UNITY_WORKAROUND
-/* Fix 'shortcut' part of keyboard reading code only ever using first defined keymap instead of active one.
- * See T47228 and D1746 */
+/* Fix 'shortcut' part of keyboard reading code only ever using first defined keymap
+ * instead of active one. See T47228 and D1746 */
#define USE_NON_LATIN_KB_WORKAROUND
static GHOST_TKey ghost_key_from_keysym(const KeySym key);
@@ -314,7 +314,8 @@ void GHOST_SystemX11::getAllDisplayDimensions(GHOST_TUns32 &width, GHOST_TUns32
* Create a new window.
* The new window is added to the list of windows managed.
* Never explicitly delete the window, use disposeWindow() instead.
- * \param title The name of the window (displayed in the title bar of the window if the OS supports it).
+ * \param title The name of the window
+ * (displayed in the title bar of the window if the OS supports it).
* \param left The coordinate of the left edge of the window.
* \param top The coordinate of the top edge of the window.
* \param width The width the window.
@@ -355,7 +356,6 @@ GHOST_IWindow *GHOST_SystemX11::createWindow(const STR_String &title,
((glSettings.flags & GHOST_glStereoVisual) != 0),
exclusive,
((glSettings.flags & GHOST_glAlphaBackground) != 0),
- glSettings.numOfAASamples,
(glSettings.flags & GHOST_glDebugContext) != 0);
if (window) {
@@ -421,7 +421,6 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext()
for (int minor = 5; minor >= 0; --minor) {
context = new GHOST_ContextGLX(false,
- 0,
(Window)NULL,
m_display,
(GLXFBConfig)NULL,
@@ -439,7 +438,6 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext()
}
context = new GHOST_ContextGLX(false,
- 0,
(Window)NULL,
m_display,
(GLXFBConfig)NULL,
@@ -947,18 +945,19 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
* - Fallback to XLookupString to get a key_sym from active user-defined keymap.
*
* Note that:
- * - This effectively 'lock' main number keys to always output number events (except when using alt-gr).
- * - This enforces users to use an ascii-compatible keymap with Blender - but at least it gives
- * predictable and consistent results.
+ * - This effectively 'lock' main number keys to always output number events
+ * (except when using alt-gr).
+ * - This enforces users to use an ascii-compatible keymap with Blender -
+ * but at least it gives predictable and consistent results.
*
- * Also, note that nothing in XLib sources [1] makes it obvious why those two functions give different
- * key_sym results...
+ * Also, note that nothing in XLib sources [1] makes it obvious why those two functions give
+ * different key_sym results...
*
* [1] http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/KeyBind.c
*/
KeySym key_sym_str;
- /* Mode_switch 'modifier' is AltGr - when this one or Shift are enabled, we do not want to apply
- * that 'forced number' hack. */
+ /* Mode_switch 'modifier' is AltGr - when this one or Shift are enabled,
+ * we do not want to apply that 'forced number' hack. */
const unsigned int mode_switch_mask = XkbKeysymToModifiers(xke->display, XK_Mode_switch);
const unsigned int number_hack_forbidden_kmods_mask = mode_switch_mask | ShiftMask;
if ((xke->keycode >= 10 && xke->keycode < 20) &&
@@ -976,8 +975,8 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
ascii = '\0';
}
- /* Only allow a limited set of keys from XLookupKeysym, all others we take from XLookupString,
- * unless it gives unknown key... */
+ /* Only allow a limited set of keys from XLookupKeysym,
+ * all others we take from XLookupString, unless it gives unknown key... */
gkey = ghost_key_from_keysym_or_keycode(key_sym, m_xkb_descr, xke->keycode);
switch (gkey) {
case GHOST_kKeyRightAlt:
@@ -1184,7 +1183,8 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
XFocusChangeEvent &xfe = xe->xfocus;
/* TODO: make sure this is the correct place for activate/deactivate */
- // printf("X: focus %s for window %d\n", xfe.type == FocusIn ? "in" : "out", (int) xfe.window);
+ // printf("X: focus %s for window %d\n",
+ // xfe.type == FocusIn ? "in" : "out", (int) xfe.window);
/* May have to look at the type of event and filter some out. */
@@ -1236,7 +1236,8 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
}
else {
#ifdef WITH_XDND
- /* try to handle drag event (if there's no such events, GHOST_HandleClientMessage will return zero) */
+ /* try to handle drag event
+ * (if there's no such events, GHOST_HandleClientMessage will return zero) */
if (window->getDropTarget()->GHOST_HandleClientMessage(xe) == false) {
/* Unknown client message, ignore */
}
@@ -1270,7 +1271,8 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
getMilliSeconds(), GHOST_kEventCursorMove, window, xce.x_root, xce.y_root);
}
- // printf("X: %s window %d\n", xce.type == EnterNotify ? "entering" : "leaving", (int) xce.window);
+ // printf("X: %s window %d\n",
+ // xce.type == EnterNotify ? "entering" : "leaving", (int) xce.window);
if (xce.type == EnterNotify)
m_windowManager->setActiveWindow(window);
@@ -1397,9 +1399,10 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
* around tablet surface */
window->GetTabletData()->Active = xtablet.mode;
- /* Note: This event might be generated with incomplete dataset (don't exactly know why, looks like in
- * some cases, if the value does not change, it is not included in subsequent XDeviceMotionEvent
- * events). So we have to check which values this event actually contains!
+ /* Note: This event might be generated with incomplete dataset
+ * (don't exactly know why, looks like in some cases, if the value does not change,
+ * it is not included in subsequent XDeviceMotionEvent events).
+ * So we have to check which values this event actually contains!
*/
# define AXIS_VALUE_GET(axis, val) \
@@ -1414,8 +1417,9 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
* but I got garbage data without it. Found it in the xidump.c source --matt
*
* The '& 0xffff' just truncates the value to its two lowest bytes, this probably means
- * some drivers do not properly set the whole int value? Since we convert to float afterward,
- * I don't think we need to cast to short here, but do not have a device to check this. --mont29
+ * some drivers do not properly set the whole int value? Since we convert to float
+ * afterward, I don't think we need to cast to short here, but do not have a device to
+ * check this. --mont29
*/
if (AXIS_VALUE_GET(3, axis_value)) {
window->GetTabletData()->Xtilt = (short)(axis_value & 0xffff) /
@@ -2280,7 +2284,7 @@ void GHOST_SystemX11::refreshXInputDevices()
NULL;
GHOST_TTabletMode tablet_mode = tablet_mode_from_name(device_info[i].name, device_type);
- // printf("Tablet type:'%s', name:'%s', index:%d\n", device_type, device_info[i].name, i);
+ // printf("Tablet type:'%s', name:'%s', index:%d\n", device_type, device_info[i].name, i);
if (device_type) {
XFree((void *)device_type);
diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h
index d73582b52fa..f7f33185f9b 100644
--- a/intern/ghost/intern/GHOST_SystemX11.h
+++ b/intern/ghost/intern/GHOST_SystemX11.h
@@ -128,7 +128,8 @@ class GHOST_SystemX11 : public GHOST_System {
* Create a new window.
* The new window is added to the list of windows managed.
* Never explicitly delete the window, use disposeWindow() instead.
- * \param title The name of the window (displayed in the title bar of the window if the OS supports it).
+ * \param title The name of the window
+ * (displayed in the title bar of the window if the OS supports it).
* \param left The coordinate of the left edge of the window.
* \param top The coordinate of the top edge of the window.
* \param width The width the window.
@@ -241,7 +242,8 @@ class GHOST_SystemX11 : public GHOST_System {
* Creates a drag'n'drop event and pushes it immediately onto the event queue.
* Called by GHOST_DropTargetX11 class.
* \param eventType The type of drag'n'drop event
- * \param draggedObjectType The type object concerned (currently array of file names, string, ?bitmap)
+ * \param draggedObjectType The type object concerned
+ * (currently array of file names, string, ?bitmap)
* \param mouseX x mouse coordinate (in window coordinates)
* \param mouseY y mouse coordinate
* \param window The window on which the event occurred
diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp
index 06b76aee23d..85283a34d2e 100644
--- a/intern/ghost/intern/GHOST_Window.cpp
+++ b/intern/ghost/intern/GHOST_Window.cpp
@@ -35,15 +35,13 @@ GHOST_Window::GHOST_Window(GHOST_TUns32 width,
GHOST_TUns32 height,
GHOST_TWindowState state,
const bool wantStereoVisual,
- const bool /*exclusive*/,
- const GHOST_TUns16 wantNumOfAASamples)
+ const bool /*exclusive*/)
: m_drawingContextType(GHOST_kDrawingContextTypeNone),
m_cursorVisible(true),
m_cursorGrab(GHOST_kGrabDisable),
m_cursorShape(GHOST_kStandardCursorDefault),
m_wantStereoVisual(wantStereoVisual),
- m_wantNumOfAASamples(wantNumOfAASamples),
- m_context(new GHOST_ContextNone(false, 0))
+ m_context(new GHOST_ContextNone(false))
{
m_isUnsavedChanges = false;
m_canAcceptDragOperation = false;
@@ -85,7 +83,7 @@ GHOST_TSuccess GHOST_Window::setDrawingContextType(GHOST_TDrawingContextType typ
m_drawingContextType = type;
}
else {
- m_context = new GHOST_ContextNone(m_wantStereoVisual, m_wantNumOfAASamples);
+ m_context = new GHOST_ContextNone(m_wantStereoVisual);
m_drawingContextType = GHOST_kDrawingContextTypeNone;
}
@@ -111,11 +109,6 @@ GHOST_TSuccess GHOST_Window::getSwapInterval(int &intervalOut)
return m_context->getSwapInterval(intervalOut);
}
-GHOST_TUns16 GHOST_Window::getNumOfAASamples()
-{
- return m_context->getNumOfAASamples();
-}
-
GHOST_TSuccess GHOST_Window::activateDrawingContext()
{
return m_context->activateDrawingContext();
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 8c01d66bbfd..b5399ec803e 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -50,14 +50,12 @@ class GHOST_Window : public GHOST_IWindow {
* \param stereoVisual Stereo visual for quad buffered stereo.
* \param exclusive Use to show the window ontop and ignore others
* (used fullscreen).
- * \param numOfAASamples Number of samples used for AA (zero if no AA)
*/
GHOST_Window(GHOST_TUns32 width,
GHOST_TUns32 height,
GHOST_TWindowState state,
const bool wantStereoVisual = false,
- const bool exclusive = false,
- const GHOST_TUns16 wantNumOfAASamples = 0);
+ const bool exclusive = false);
/**
* \section Interface inherited from GHOST_IWindow left for derived class
@@ -70,8 +68,10 @@ class GHOST_Window : public GHOST_IWindow {
* virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width) = 0;
* virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height) = 0;
* virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height) = 0;
- * virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
- * virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
+ * virtual void screenToClient(
+ * GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
+ * virtual void clientToScreen(
+ * GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
* virtual GHOST_TWindowState getState() const = 0;
* virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
* virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
@@ -202,12 +202,6 @@ class GHOST_Window : public GHOST_IWindow {
GHOST_TSuccess getSwapInterval(int &intervalOut);
/**
- * Gets the current swap interval for swapBuffers.
- * \return Number of AA Samples (0 if there is no multisample buffer)
- */
- GHOST_TUns16 getNumOfAASamples();
-
- /**
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
*/
void setAcceptDragOperation(bool canAccept);
@@ -400,9 +394,6 @@ class GHOST_Window : public GHOST_IWindow {
/** Whether to attempt to initialize a context with a stereo framebuffer. */
bool m_wantStereoVisual;
- /** Attempt to initialize a context with this many samples. */
- GHOST_TUns16 m_wantNumOfAASamples;
-
/** Full-screen width */
GHOST_TUns32 m_fullScreenWidth;
/** Full-screen height */
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.h b/intern/ghost/intern/GHOST_WindowCocoa.h
index acda109eb7f..41e7191701e 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.h
+++ b/intern/ghost/intern/GHOST_WindowCocoa.h
@@ -54,7 +54,6 @@ class GHOST_WindowCocoa : public GHOST_Window {
* \param state The state the window is initially opened with.
* \param type The type of drawing context installed in this window.
* \param stereoVisual Stereo visual for quad buffered stereo.
- * \param numOfAASamples Number of samples used for AA (zero if no AA)
*/
GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa,
const STR_String &title,
@@ -65,7 +64,6 @@ class GHOST_WindowCocoa : public GHOST_Window {
GHOST_TWindowState state,
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
const bool stereoVisual = false,
- const GHOST_TUns16 numOfAASamples = 0,
bool is_debug = false);
/**
@@ -100,7 +98,8 @@ class GHOST_WindowCocoa : public GHOST_Window {
/**
* Returns the window rectangle dimensions.
- * The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
+ * The dimensions are given in screen coordinates that are
+ * relative to the upper-left corner of the screen.
* \param bounds The bounding rectangle of the window.
*/
void getWindowBounds(GHOST_Rect &bounds) const;
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index a73c818297c..f257399fc9c 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -115,7 +115,8 @@
//Send event only once, at end of resize operation (when user has released mouse button)
systemCocoa->handleWindowEvent(GHOST_kEventWindowSize, associatedWindow);
//}
- /* Live resize, send event, gets handled in wm_window.c. Needed because live resize runs in a modal loop, not letting main loop run */
+ /* Live resize, send event, gets handled in wm_window.c.
+ * Needed because live resize runs in a modal loop, not letting main loop run */
if ([[notification object] inLiveResize]) {
systemCocoa->dispatchEvents();
}
@@ -136,7 +137,8 @@
@end
#pragma mark NSWindow subclass
-//We need to subclass it to tell that even borderless (fullscreen), it can become key (receive user events)
+// We need to subclass it to tell that even borderless (fullscreen),
+// it can become key (receive user events)
@interface CocoaWindow : NSWindow
{
GHOST_SystemCocoa *systemCocoa;
@@ -529,9 +531,8 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
const bool stereoVisual,
- const GHOST_TUns16 numOfAASamples,
bool is_debug)
- : GHOST_Window(width, height, state, stereoVisual, false, numOfAASamples),
+ : GHOST_Window(width, height, state, stereoVisual, false),
m_customCursor(0),
m_debug_context(is_debug)
{
@@ -541,7 +542,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa,
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- //Creates the window
+ // Creates the window
NSRect rect;
NSSize minSize;
@@ -564,12 +565,12 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa,
[m_window setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
- //Forbid to resize the window below the blender defined minimum one
+ // Forbid to resize the window below the blender defined minimum one
minSize.width = 320;
minSize.height = 240;
[m_window setContentMinSize:minSize];
- //Creates the OpenGL View inside the window
+ // Creates the OpenGL View inside the window
m_openGLView = [[CocoaOpenGLView alloc] initWithFrame:rect];
if (m_systemCocoa->m_nativePixel) {
@@ -671,7 +672,7 @@ void GHOST_WindowCocoa::setTitle(const STR_String &title)
NSString *windowTitle = [[NSString alloc] initWithCString:title encoding:NSUTF8StringEncoding];
- //Set associated file if applicable
+ // Set associated file if applicable
if (windowTitle && [windowTitle hasPrefix:@"Blender"]) {
NSRange fileStrRange;
NSString *associatedFileName;
@@ -685,7 +686,7 @@ void GHOST_WindowCocoa::setTitle(const STR_String &title)
associatedFileName = [windowTitle substringWithRange:fileStrRange];
[m_window setTitle:[associatedFileName lastPathComponent]];
- //Blender used file open/save functions converte file names into legal URL ones
+ // Blender used file open/save functions converte file names into legal URL ones
associatedFileName = [associatedFileName
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
@try {
@@ -752,7 +753,7 @@ void GHOST_WindowCocoa::getClientBounds(GHOST_Rect &bounds) const
NSRect screenSize = [[m_window screen] visibleFrame];
- //Max window contents as screen size (excluding title bar...)
+ // Max window contents as screen size (excluding title bar...)
NSRect contentRect = [CocoaWindow
contentRectForFrameRect:screenSize
styleMask:(NSTitledWindowMask | NSClosableWindowMask |
@@ -1000,7 +1001,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setOrder(GHOST_TWindowOrder order)
[m_window orderBack:nil];
- //Check for other blender opened windows and make the frontmost key
+ // Check for other blender opened windows and make the frontmost key
windowsList = [NSApp orderedWindows];
if ([windowsList count]) {
[[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
@@ -1018,7 +1019,6 @@ GHOST_Context *GHOST_WindowCocoa::newDrawingContext(GHOST_TDrawingContextType ty
if (type == GHOST_kDrawingContextTypeOpenGL) {
GHOST_Context *context = new GHOST_ContextCGL(m_wantStereoVisual,
- m_wantNumOfAASamples,
m_window,
m_openGLView,
@@ -1229,7 +1229,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorGrab(GHOST_TGrabCursorMode mode
GHOST_TSuccess err = GHOST_kSuccess;
if (mode != GHOST_kGrabDisable) {
- //No need to perform grab without warp as it is always on in OS X
+ // No need to perform grab without warp as it is always on in OS X
if (mode != GHOST_kGrabNormal) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -1240,7 +1240,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorGrab(GHOST_TGrabCursorMode mode
setWindowCursorVisibility(false);
}
- //Make window key if it wasn't to get the mouse move events
+ // Make window key if it wasn't to get the mouse move events
[m_window makeKeyWindow];
[pool drain];
@@ -1252,7 +1252,8 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorGrab(GHOST_TGrabCursorMode mode
setWindowCursorVisibility(true);
}
- /* Almost works without but important otherwise the mouse GHOST location can be incorrect on exit */
+ /* Almost works without but important otherwise the mouse GHOST location
+ * can be incorrect on exit. */
setCursorGrabAccum(0, 0);
m_cursorGrabBounds.m_l = m_cursorGrabBounds.m_r = -1; /* disable */
}
@@ -1352,7 +1353,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCustomCursorShape(GHOST_TUns8 *bitmap
hotSpotPoint.x = hotX;
hotSpotPoint.y = hotY;
- //foreground and background color parameter is not handled for now (10.6)
+ // foreground and background color parameter is not handled for now (10.6)
m_customCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:hotSpotPoint];
[cursorImageRep release];
diff --git a/intern/ghost/intern/GHOST_WindowManager.cpp b/intern/ghost/intern/GHOST_WindowManager.cpp
index ca557e472f7..52a57edd4e9 100644
--- a/intern/ghost/intern/GHOST_WindowManager.cpp
+++ b/intern/ghost/intern/GHOST_WindowManager.cpp
@@ -121,11 +121,11 @@ GHOST_TSuccess GHOST_WindowManager::endFullScreen(void)
GHOST_TSuccess success = GHOST_kFailure;
if (getFullScreen()) {
if (m_fullScreenWindow != NULL) {
- //GHOST_PRINT("GHOST_WindowManager::endFullScreen(): deleting full-screen window\n");
+ // GHOST_PRINT("GHOST_WindowManager::endFullScreen(): deleting full-screen window\n");
setWindowInactive(m_fullScreenWindow);
m_fullScreenWindow->endFullScreen();
delete m_fullScreenWindow;
- //GHOST_PRINT("GHOST_WindowManager::endFullScreen(): done\n");
+ // GHOST_PRINT("GHOST_WindowManager::endFullScreen(): done\n");
m_fullScreenWindow = NULL;
if (m_activeWindowBeforeFullScreen) {
setActiveWindow(m_activeWindowBeforeFullScreen);
diff --git a/intern/ghost/intern/GHOST_WindowNULL.h b/intern/ghost/intern/GHOST_WindowNULL.h
index 3ac3389291d..0ea33710ef6 100644
--- a/intern/ghost/intern/GHOST_WindowNULL.h
+++ b/intern/ghost/intern/GHOST_WindowNULL.h
@@ -45,9 +45,8 @@ class GHOST_WindowNULL : public GHOST_Window {
GHOST_TWindowState state,
const GHOST_TEmbedderWindowID parentWindow,
GHOST_TDrawingContextType type,
- const bool stereoVisual,
- const GHOST_TUns16 numOfAASamples)
- : GHOST_Window(width, height, state, stereoVisual, false, numOfAASamples), m_system(system)
+ const bool stereoVisual)
+ : GHOST_Window(width, height, state, stereoVisual, false), m_system(system)
{
setTitle(title);
}
diff --git a/intern/ghost/intern/GHOST_WindowSDL.cpp b/intern/ghost/intern/GHOST_WindowSDL.cpp
index 89efdf1a94e..9c9fffdba50 100644
--- a/intern/ghost/intern/GHOST_WindowSDL.cpp
+++ b/intern/ghost/intern/GHOST_WindowSDL.cpp
@@ -36,9 +36,8 @@ GHOST_WindowSDL::GHOST_WindowSDL(GHOST_SystemSDL *system,
const GHOST_TEmbedderWindowID parentWindow,
GHOST_TDrawingContextType type,
const bool stereoVisual,
- const bool exclusive,
- const GHOST_TUns16 numOfAASamples)
- : GHOST_Window(width, height, state, stereoVisual, exclusive, numOfAASamples),
+ const bool exclusive)
+ : GHOST_Window(width, height, state, stereoVisual, exclusive),
m_system(system),
m_valid_setup(false),
m_invalid_window(false),
@@ -81,7 +80,6 @@ GHOST_Context *GHOST_WindowSDL::newDrawingContext(GHOST_TDrawingContextType type
{
if (type == GHOST_kDrawingContextTypeOpenGL) {
GHOST_Context *context = new GHOST_ContextSDL(m_wantStereoVisual,
- m_wantNumOfAASamples,
m_sdl_win,
0, // profile bit
3,
@@ -623,7 +621,7 @@ static void sdl_cursor_init(void)
DEF_CURSOR(bottom_right_corner, GHOST_kStandardCursorBottomRightCorner);
DEF_CURSOR(bottom_left_corner, GHOST_kStandardCursorBottomLeftCorner);
DEF_CURSOR(arrow, GHOST_kStandardCursorCopy);
- //DEF_CURSOR(arrow, GHOST_kStandardCursorCustom);
+ // DEF_CURSOR(arrow, GHOST_kStandardCursorCustom);
DEF_CURSOR(arrow, GHOST_kStandardCursorPencil);
#undef DEF_CURSOR
diff --git a/intern/ghost/intern/GHOST_WindowSDL.h b/intern/ghost/intern/GHOST_WindowSDL.h
index 3a9a1ad7df2..7b3cddc5f17 100644
--- a/intern/ghost/intern/GHOST_WindowSDL.h
+++ b/intern/ghost/intern/GHOST_WindowSDL.h
@@ -63,8 +63,7 @@ class GHOST_WindowSDL : public GHOST_Window {
const GHOST_TEmbedderWindowID parentWindow,
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
const bool stereoVisual = false,
- const bool exclusive = false,
- const GHOST_TUns16 numOfAASamples = 0);
+ const bool exclusive = false);
~GHOST_WindowSDL();
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 2feda927998..def075bd47c 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -66,10 +66,9 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
GHOST_TDrawingContextType type,
bool wantStereoVisual,
bool alphaBackground,
- GHOST_TUns16 wantNumOfAASamples,
GHOST_TEmbedderWindowID parentwindowhwnd,
bool is_debug)
- : GHOST_Window(width, height, state, wantStereoVisual, false, wantNumOfAASamples),
+ : GHOST_Window(width, height, state, wantStereoVisual, false),
m_inLiveResize(false),
m_system(system),
m_hDC(0),
@@ -262,7 +261,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
::UpdateWindow(m_hWnd);
}
else {
- //invalidate the window
+ // invalidate the window
::DestroyWindow(m_hWnd);
m_hWnd = NULL;
}
@@ -657,11 +656,11 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty
#if defined(WITH_GL_PROFILE_CORE)
/* - AMD and Intel give us exactly this version
* - NVIDIA gives at least this version <-- desired behavior
- * So we ask for 4.5, 4.4 ... 3.3 in descending order to get the best version on the user's system. */
+ * So we ask for 4.5, 4.4 ... 3.3 in descending order
+ * to get the best version on the user's system. */
for (int minor = 5; minor >= 0; --minor) {
context = new GHOST_ContextWGL(m_wantStereoVisual,
m_wantAlphaBackground,
- m_wantNumOfAASamples,
m_hWnd,
m_hDC,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
@@ -679,7 +678,6 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty
}
context = new GHOST_ContextWGL(m_wantStereoVisual,
m_wantAlphaBackground,
- m_wantNumOfAASamples,
m_hWnd,
m_hDC,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
@@ -703,11 +701,11 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty
}
#elif defined(WITH_GL_PROFILE_COMPAT)
- // ask for 2.1 context, driver gives any GL version >= 2.1 (hopefully the latest compatibility profile)
+ // ask for 2.1 context, driver gives any GL version >= 2.1
+ // (hopefully the latest compatibility profile)
// 2.1 ignores the profile bit & is incompatible with core profile
context = new GHOST_ContextWGL(m_wantStereoVisual,
m_wantAlphaBackground,
- m_wantNumOfAASamples,
m_hWnd,
m_hDC,
0, // no profile bit
@@ -898,7 +896,8 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCursorGrab(GHOST_TGrabCursorMode mode
m_system->setCursorPosition(pos[0], pos[1]);
}
- /* Almost works without but important otherwise the mouse GHOST location can be incorrect on exit */
+ /* Almost works without but important otherwise the mouse GHOST location
+ * can be incorrect on exit. */
setCursorGrabAccum(0, 0);
m_cursorGrabBounds.m_l = m_cursorGrabBounds.m_r = -1; /* disable */
registerMouseClickEvent(3);
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h
index 73791d3fbbf..2f1f3a53c81 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -166,8 +166,8 @@ typedef struct tagPOINTER_TOUCH_INFO {
} POINTER_TOUCH_INFO;
/*
- * Macros to retrieve information from pointer input message parameters
- */
+ * Macros to retrieve information from pointer input message parameters
+ */
#define GET_POINTERID_WPARAM(wParam) (LOWORD(wParam))
#define IS_POINTER_FLAG_SET_WPARAM(wParam, flag) (((DWORD)HIWORD(wParam) & (flag)) == (flag))
#define IS_POINTER_NEW_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_NEW)
@@ -223,7 +223,6 @@ class GHOST_WindowWin32 : public GHOST_Window {
* \param state The state the window is initially opened with.
* \param type The type of drawing context installed in this window.
* \param wantStereoVisual Stereo visual for quad buffered stereo.
- * \param wantNumOfAASamples Number of samples used for AA (zero if no AA)
* \param parentWindowHwnd
*/
GHOST_WindowWin32(GHOST_SystemWin32 *system,
@@ -236,7 +235,6 @@ class GHOST_WindowWin32 : public GHOST_Window {
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
bool wantStereoVisual = false,
bool alphaBackground = false,
- GHOST_TUns16 wantNumOfAASamples = 0,
GHOST_TEmbedderWindowID parentWindowHwnd = 0,
bool is_debug = false);
@@ -272,7 +270,8 @@ class GHOST_WindowWin32 : public GHOST_Window {
/**
* Returns the window rectangle dimensions.
- * The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
+ * The dimensions are given in screen coordinates that are
+ * relative to the upper-left corner of the screen.
* \param bounds The bounding rectangle of the window.
*/
void getWindowBounds(GHOST_Rect &bounds) const;
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 21e42e01aea..8c69b9eb65e 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -49,7 +49,7 @@
# include <X11/extensions/XInput2.h>
#endif
-//For DPI value
+// For DPI value
#include <X11/Xresource.h>
#include <cstring>
@@ -92,14 +92,10 @@ typedef struct {
static XVisualInfo *x11_visualinfo_from_glx(Display *display,
bool stereoVisual,
- GHOST_TUns16 *r_numOfAASamples,
bool needAlpha,
GLXFBConfig *fbconfig)
{
- XVisualInfo *visual = NULL;
- GHOST_TUns16 numOfAASamples = *r_numOfAASamples;
int glx_major, glx_minor, glx_version; /* GLX version: major.minor */
- GHOST_TUns16 actualSamples;
int glx_attribs[64];
*fbconfig = NULL;
@@ -117,14 +113,9 @@ static XVisualInfo *x11_visualinfo_from_glx(Display *display,
return NULL;
}
glx_version = glx_major * 100 + glx_minor;
-
- if (glx_version >= 104) {
- actualSamples = numOfAASamples;
- }
- else {
- numOfAASamples = 0;
- actualSamples = 0;
- }
+#ifndef WITH_X11_ALPHA
+ (void)glx_version;
+#endif
#ifdef WITH_X11_ALPHA
if (needAlpha && glx_version >= 103 &&
@@ -133,106 +124,63 @@ static XVisualInfo *x11_visualinfo_from_glx(Display *display,
(glXGetVisualFromFBConfig ||
(glXGetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)glXGetProcAddressARB(
(const GLubyte *)"glXGetVisualFromFBConfig")) != NULL)) {
- GLXFBConfig *fbconfigs;
- int nbfbconfig;
- int i;
- for (;;) {
+ GHOST_X11_GL_GetAttributes(glx_attribs, 64, stereoVisual, needAlpha, true);
- GHOST_X11_GL_GetAttributes(glx_attribs, 64, actualSamples, stereoVisual, needAlpha, true);
-
- fbconfigs = glXChooseFBConfig(display, DefaultScreen(display), glx_attribs, &nbfbconfig);
-
- /* Any sample level or even zero, which means oversampling disabled, is good
- * but we need a valid visual to continue */
- if (nbfbconfig > 0) {
- /* take a frame buffer config that has alpha cap */
- for (i = 0; i < nbfbconfig; i++) {
- visual = (XVisualInfo *)glXGetVisualFromFBConfig(display, fbconfigs[i]);
- if (!visual)
+ int nbfbconfig;
+ GLXFBConfig *fbconfigs = glXChooseFBConfig(
+ display, DefaultScreen(display), glx_attribs, &nbfbconfig);
+
+ /* Any sample level or even zero, which means oversampling disabled, is good
+ * but we need a valid visual to continue */
+ if (nbfbconfig > 0) {
+ /* take a frame buffer config that has alpha cap */
+ for (int i = 0; i < nbfbconfig; i++) {
+ XVisualInfo *visual = (XVisualInfo *)glXGetVisualFromFBConfig(display, fbconfigs[i]);
+ if (!visual)
+ continue;
+ /* if we don't need a alpha background, the first config will do, otherwise
+ * test the alphaMask as it won't necessarily be present */
+ if (needAlpha) {
+ XRenderPictFormat *pict_format = XRenderFindVisualFormat(display, visual->visual);
+ if (!pict_format)
+ continue;
+ if (pict_format->direct.alphaMask <= 0)
continue;
- /* if we don't need a alpha background, the first config will do, otherwise
- * test the alphaMask as it won't necessarily be present */
- if (needAlpha) {
- XRenderPictFormat *pict_format = XRenderFindVisualFormat(display, visual->visual);
- if (!pict_format)
- continue;
- if (pict_format->direct.alphaMask <= 0)
- continue;
- }
- *fbconfig = fbconfigs[i];
- break;
- }
- XFree(fbconfigs);
- if (i < nbfbconfig) {
- if (actualSamples < numOfAASamples) {
- fprintf(stderr,
- "Warning! Unable to find a multisample pixel format that supports exactly %d "
- "samples. "
- "Substituting one that uses %d samples.\n",
- numOfAASamples,
- actualSamples);
- }
- break;
}
- visual = NULL;
- }
- if (actualSamples == 0) {
- /* All options exhausted, cannot continue */
- fprintf(stderr,
- "%s:%d: X11 glXChooseVisual() failed, "
- "verify working openGL system!\n",
- __FILE__,
- __LINE__);
+ *fbconfig = fbconfigs[i];
+ XFree(fbconfigs);
- return NULL;
- }
- else {
- --actualSamples;
+ return visual;
}
+
+ XFree(fbconfigs);
}
}
else
#endif
{
/* legacy, don't use extension */
- for (;;) {
- GHOST_X11_GL_GetAttributes(glx_attribs, 64, actualSamples, stereoVisual, needAlpha, false);
-
- visual = glXChooseVisual(display, DefaultScreen(display), glx_attribs);
-
- /* Any sample level or even zero, which means oversampling disabled, is good
- * but we need a valid visual to continue */
- if (visual != NULL) {
- if (actualSamples < numOfAASamples) {
- fprintf(stderr,
- "Warning! Unable to find a multisample pixel format that supports exactly %d "
- "samples. "
- "Substituting one that uses %d samples.\n",
- numOfAASamples,
- actualSamples);
- }
- break;
- }
+ GHOST_X11_GL_GetAttributes(glx_attribs, 64, stereoVisual, needAlpha, false);
- if (actualSamples == 0) {
- /* All options exhausted, cannot continue */
- fprintf(stderr,
- "%s:%d: X11 glXChooseVisual() failed, "
- "verify working openGL system!\n",
- __FILE__,
- __LINE__);
+ XVisualInfo *visual = glXChooseVisual(display, DefaultScreen(display), glx_attribs);
- return NULL;
- }
- else {
- --actualSamples;
- }
+ /* Any sample level or even zero, which means oversampling disabled, is good
+ * but we need a valid visual to continue */
+ if (visual != NULL) {
+ return visual;
}
}
- *r_numOfAASamples = actualSamples;
- return visual;
+
+ /* All options exhausted, cannot continue */
+ fprintf(stderr,
+ "%s:%d: X11 glXChooseVisual() failed, "
+ "verify working openGL system!\n",
+ __FILE__,
+ __LINE__);
+
+ return NULL;
}
GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system,
@@ -248,9 +196,8 @@ GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system,
const bool stereoVisual,
const bool exclusive,
const bool alphaBackground,
- const GHOST_TUns16 numOfAASamples,
const bool is_debug)
- : GHOST_Window(width, height, state, stereoVisual, exclusive, numOfAASamples),
+ : GHOST_Window(width, height, state, stereoVisual, exclusive),
m_display(display),
m_visualInfo(NULL),
m_fbconfig(NULL),
@@ -271,11 +218,8 @@ GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system,
m_is_debug_context(is_debug)
{
if (type == GHOST_kDrawingContextTypeOpenGL) {
- m_visualInfo = x11_visualinfo_from_glx(m_display,
- stereoVisual,
- &m_wantNumOfAASamples,
- alphaBackground,
- (GLXFBConfig *)&m_fbconfig);
+ m_visualInfo = x11_visualinfo_from_glx(
+ m_display, stereoVisual, alphaBackground, (GLXFBConfig *)&m_fbconfig);
}
else {
XVisualInfo tmp = {0};
@@ -1298,7 +1242,6 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
for (int minor = 5; minor >= 0; --minor) {
context = new GHOST_ContextGLX(m_wantStereoVisual,
- m_wantNumOfAASamples,
m_window,
m_display,
(GLXFBConfig)m_fbconfig,
@@ -1316,7 +1259,6 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
}
context = new GHOST_ContextGLX(m_wantStereoVisual,
- m_wantNumOfAASamples,
m_window,
m_display,
(GLXFBConfig)m_fbconfig,
@@ -1507,7 +1449,8 @@ GHOST_TSuccess GHOST_WindowX11::setWindowCursorGrab(GHOST_TGrabCursorMode mode)
setWindowCursorVisibility(true);
}
- /* Almost works without but important otherwise the mouse GHOST location can be incorrect on exit */
+ /* Almost works without but important
+ * otherwise the mouse GHOST location can be incorrect on exit. */
setCursorGrabAccum(0, 0);
m_cursorGrabBounds.m_l = m_cursorGrabBounds.m_r = -1; /* disable */
#ifdef GHOST_X11_GRAB
diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h
index 8378a8b5ef8..a39a186406f 100644
--- a/intern/ghost/intern/GHOST_WindowX11.h
+++ b/intern/ghost/intern/GHOST_WindowX11.h
@@ -46,7 +46,8 @@ class GHOST_DropTargetX11;
/**
* X11 implementation of GHOST_IWindow.
- * Dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
+ * Dimensions are given in screen coordinates that are
+ * relative to the upper-left corner of the screen.
*/
class GHOST_WindowX11 : public GHOST_Window {
@@ -65,7 +66,6 @@ class GHOST_WindowX11 : public GHOST_Window {
* \param type The type of drawing context installed in this window.
* \param stereoVisual Stereo visual for quad buffered stereo.
* \param alphaBackground Enable alpha blending of window with display background
- * \param numOfAASamples Number of samples used for AA (zero if no AA)
*/
GHOST_WindowX11(GHOST_SystemX11 *system,
Display *display,
@@ -80,7 +80,6 @@ class GHOST_WindowX11 : public GHOST_Window {
const bool stereoVisual = false,
const bool exclusive = false,
const bool alphaBackground = false,
- const GHOST_TUns16 numOfAASamples = 0,
const bool is_debug = false);
bool getValid() const;
diff --git a/intern/ghost/test/gears/GHOST_Test.cpp b/intern/ghost/test/gears/GHOST_Test.cpp
index 654177d3f66..47eddbcfb83 100644
--- a/intern/ghost/test/gears/GHOST_Test.cpp
+++ b/intern/ghost/test/gears/GHOST_Test.cpp
@@ -678,11 +678,12 @@ int main(int /*argc*/, char ** /*argv*/)
LONG lresult;
HKEY hkey = 0;
DWORD dwd = 0;
- //unsigned char buffer[128];
+ // unsigned char buffer[128];
CRegKey regkey;
- //DWORD keyValue;
- // lresult = regkey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable");
+ // DWORD keyValue;
+ // lresult = regkey.Open(
+ // HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable");
lresult = regkey.Open(HKEY_LOCAL_MACHINE,
"SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable",
KEY_ALL_ACCESS);
@@ -718,7 +719,7 @@ int main(int /*argc*/, char ** /*argv*/)
// Enter main loop
while (!app.m_exitRequested) {
- //printf("main: loop\n");
+ // printf("main: loop\n");
fSystem->processEvents(true);
fSystem->dispatchEvents();
}
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index b5ac3288a61..b1a0eda0e22 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -60,13 +60,13 @@ extern "C" {
#endif
/** Returns the length of the allocated memory segment pointed at
- * by vmemh. If the pointer was not previously allocated by this
- * module, the result is undefined.*/
+ * by vmemh. If the pointer was not previously allocated by this
+ * module, the result is undefined.*/
extern size_t (*MEM_allocN_len)(const void *vmemh) ATTR_WARN_UNUSED_RESULT;
/**
- * Release memory previously allocated by this module.
- */
+ * Release memory previously allocated by this module.
+ */
extern void (*MEM_freeN)(void *vmemh);
#if 0 /* UNUSED */
@@ -77,23 +77,23 @@ extern short (*MEM_testN)(void *vmemh);
#endif
/**
- * Duplicates a block of memory, and returns a pointer to the
- * newly allocated block. */
+ * Duplicates a block of memory, and returns a pointer to the
+ * newly allocated block. */
extern void *(*MEM_dupallocN)(const void *vmemh) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT;
/**
- * Reallocates a block of memory, and returns pointer to the newly
- * allocated block, the old one is freed. this is not as optimized
- * as a system realloc but just makes a new allocation and copies
- * over from existing memory. */
+ * Reallocates a block of memory, and returns pointer to the newly
+ * allocated block, the old one is freed. this is not as optimized
+ * as a system realloc but just makes a new allocation and copies
+ * over from existing memory. */
extern void *(*MEM_reallocN_id)(void *vmemh,
size_t len,
const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(2);
/**
- * A variant of realloc which zeros new bytes
- */
+ * A variant of realloc which zeros new bytes
+ */
extern void *(*MEM_recallocN_id)(void *vmemh,
size_t len,
const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT
@@ -103,62 +103,62 @@ extern void *(*MEM_recallocN_id)(void *vmemh,
#define MEM_recallocN(vmemh, len) MEM_recallocN_id(vmemh, len, __func__)
/**
- * Allocate a block of memory of size len, with tag name str. The
- * memory is cleared. The name must be static, because only a
- * pointer to it is stored ! */
+ * Allocate a block of memory of size len, with tag name str. The
+ * memory is cleared. The name must be static, because only a
+ * pointer to it is stored ! */
extern void *(*MEM_callocN)(size_t len, const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2);
/**
- * Allocate a block of memory of size (len * size), with tag name
- * str, aborting in case of integer overflows to prevent vulnerabilities.
- * The memory is cleared. The name must be static, because only a
- * pointer to it is stored ! */
+ * Allocate a block of memory of size (len * size), with tag name
+ * str, aborting in case of integer overflows to prevent vulnerabilities.
+ * The memory is cleared. The name must be static, because only a
+ * pointer to it is stored ! */
extern void *(*MEM_calloc_arrayN)(size_t len,
size_t size,
const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(1, 2) ATTR_NONNULL(3);
/**
- * Allocate a block of memory of size len, with tag name str. The
- * name must be a static, because only a pointer to it is stored !
- * */
+ * Allocate a block of memory of size len, with tag name str. The
+ * name must be a static, because only a pointer to it is stored !
+ * */
extern void *(*MEM_mallocN)(size_t len, const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2);
/**
- * Allocate a block of memory of size (len * size), with tag name str,
- * aborting in case of integer overflow to prevent vulnerabilities. The
- * name must be a static, because only a pointer to it is stored !
- * */
+ * Allocate a block of memory of size (len * size), with tag name str,
+ * aborting in case of integer overflow to prevent vulnerabilities. The
+ * name must be a static, because only a pointer to it is stored !
+ * */
extern void *(*MEM_malloc_arrayN)(size_t len,
size_t size,
const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(1, 2) ATTR_NONNULL(3);
/**
- * Allocate an aligned block of memory of size len, with tag name str. The
- * name must be a static, because only a pointer to it is stored !
- * */
+ * Allocate an aligned block of memory of size len, with tag name str. The
+ * name must be a static, because only a pointer to it is stored !
+ * */
extern void *(*MEM_mallocN_aligned)(size_t len,
size_t alignment,
const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(1) ATTR_NONNULL(3);
/**
- * Same as callocN, clears memory and uses mmap (disk cached) if supported.
- * Can be free'd with MEM_freeN as usual.
- * */
+ * Same as callocN, clears memory and uses mmap (disk cached) if supported.
+ * Can be free'd with MEM_freeN as usual.
+ * */
extern void *(*MEM_mapallocN)(size_t len,
const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2);
/** Print a list of the names and sizes of all allocated memory
- * blocks. as a python dict for easy investigation */
+ * blocks. as a python dict for easy investigation */
extern void (*MEM_printmemlist_pydict)(void);
/** Print a list of the names and sizes of all allocated memory
- * blocks. */
+ * blocks. */
extern void (*MEM_printmemlist)(void);
/** calls the function on all allocated memory blocks. */
@@ -171,22 +171,22 @@ extern void (*MEM_printmemlist_stats)(void);
extern void (*MEM_set_error_callback)(void (*func)(const char *));
/**
- * Are the start/end block markers still correct ?
- *
- * @retval true for correct memory, false for corrupted memory. */
+ * Are the start/end block markers still correct ?
+ *
+ * @retval true for correct memory, false for corrupted memory. */
extern bool (*MEM_consistency_check)(void);
/** Set thread locking functions for safe memory allocation from multiple
- * threads, pass NULL pointers to disable thread locking again. */
+ * threads, pass NULL pointers to disable thread locking again. */
extern void (*MEM_set_lock_callback)(void (*lock)(void), void (*unlock)(void));
/** Attempt to enforce OSX (or other OS's) to have malloc and stack nonzero */
extern void (*MEM_set_memory_debug)(void);
/**
- * Memory usage stats
- * - MEM_get_memory_in_use is all memory
- * - MEM_get_mapped_memory_in_use is a subset of all memory */
+ * Memory usage stats
+ * - MEM_get_memory_in_use is all memory
+ * - MEM_get_mapped_memory_in_use is a subset of all memory */
extern size_t (*MEM_get_memory_in_use)(void);
/** Get mapped memory usage. */
extern size_t (*MEM_get_mapped_memory_in_use)(void);
diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c
index 384cba113ff..8ba14b3887b 100644
--- a/intern/guardedalloc/intern/mallocn_guarded_impl.c
+++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c
@@ -106,8 +106,8 @@ typedef struct MemHead {
int tag2;
short mmap; /* if true, memory was mmapped */
short alignment; /* if non-zero aligned alloc was used
- * and alignment is stored here.
- */
+ * and alignment is stored here.
+ */
#ifdef DEBUG_MEMCOUNTER
int _count;
#endif
diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c
index 331d67aa55a..5b0c4b6614a 100644
--- a/intern/guardedalloc/intern/mmap_win.c
+++ b/intern/guardedalloc/intern/mmap_win.c
@@ -32,7 +32,7 @@
# include "mmap_win.h"
# ifndef FILE_MAP_EXECUTE
-//not defined in earlier versions of the Platform SDK (before February 2003)
+// not defined in earlier versions of the Platform SDK (before February 2003)
# define FILE_MAP_EXECUTE 0x0020
# endif
diff --git a/intern/guardedalloc/test/simpletest/memtest.c b/intern/guardedalloc/test/simpletest/memtest.c
index 576e502b72e..8acced088f6 100644
--- a/intern/guardedalloc/test/simpletest/memtest.c
+++ b/intern/guardedalloc/test/simpletest/memtest.c
@@ -23,7 +23,7 @@
*/
/* To compile run:
- * gcc -DWITH_GUARDEDALLOC -I../../ -I../../../atomic/ memtest.c ../../intern/mallocn.c -o simpletest
+ * gcc -DWITH_GUARDEDALLOC -I../../ -I../../../atomic/ memtest.c ../../intern/mallocn.c -o memtest
*/
/* Number of chunks to test with */
diff --git a/intern/iksolver/intern/IK_QJacobianSolver.cpp b/intern/iksolver/intern/IK_QJacobianSolver.cpp
index 90032096d37..6c2c0bacf48 100644
--- a/intern/iksolver/intern/IK_QJacobianSolver.cpp
+++ b/intern/iksolver/intern/IK_QJacobianSolver.cpp
@@ -297,7 +297,7 @@ bool IK_QJacobianSolver::Solve(IK_QSegment *root,
{
float scale = ComputeScale();
bool solved = false;
- //double dt = analyze_time();
+ // double dt = analyze_time();
Scale(scale, tasks);
@@ -359,7 +359,7 @@ bool IK_QJacobianSolver::Solve(IK_QSegment *root,
Scale(1.0f / scale, tasks);
- //analyze_add_run(max_iterations, analyze_time()-dt);
+ // analyze_add_run(max_iterations, analyze_time()-dt);
return solved;
}
diff --git a/intern/iksolver/intern/IK_QSegment.cpp b/intern/iksolver/intern/IK_QSegment.cpp
index 89a1afaafbd..dbbec621acd 100644
--- a/intern/iksolver/intern/IK_QSegment.cpp
+++ b/intern/iksolver/intern/IK_QSegment.cpp
@@ -578,7 +578,7 @@ void IK_QSwingSegment::SetLimit(int axis, double lmin, double lmax)
// put center of ellispe in the middle between min and max
double offset = 0.5 * (lmin + lmax);
- //lmax = lmax - offset;
+ // lmax = lmax - offset;
if (axis == 0) {
m_min[0] = -lmax;
diff --git a/intern/iksolver/intern/IK_QSegment.h b/intern/iksolver/intern/IK_QSegment.h
index 47125db3865..3c8c5033d28 100644
--- a/intern/iksolver/intern/IK_QSegment.h
+++ b/intern/iksolver/intern/IK_QSegment.h
@@ -32,11 +32,11 @@
/**
* An IK_Qsegment encodes information about a segments
* local coordinate system.
- *
+ *
* These segments always point along the y-axis.
- *
+ *
* Here we define the local coordinates of a joint as
- * local_transform =
+ * local_transform =
* translate(tr1) * rotation(A) * rotation(q) * translate(0,length,0)
* You can read this as:
* - first translate by (0,length,0)
diff --git a/intern/locale/boost_locale_wrapper.cpp b/intern/locale/boost_locale_wrapper.cpp
index bb46f48a14f..e03f8500a3d 100644
--- a/intern/locale/boost_locale_wrapper.cpp
+++ b/intern/locale/boost_locale_wrapper.cpp
@@ -84,7 +84,7 @@ void bl_locale_set(const char *locale)
// Specify location of dictionaries.
gen.add_messages_path(messages_path);
gen.add_messages_domain(default_domain);
- //gen.set_default_messages_domain(default_domain);
+ // gen.set_default_messages_domain(default_domain);
try {
if (locale && locale[0]) {
@@ -103,7 +103,8 @@ void bl_locale_set(const char *locale)
bl_locale_global_cache();
- // Generate the locale string (useful to know which locale we are actually using in case of "default" one).
+ // Generate the locale string
+ // (useful to know which locale we are actually using in case of "default" one).
#define LOCALE_INFO std::use_facet<boost::locale::info>(_locale)
locale_str = LOCALE_INFO.language();
diff --git a/intern/mikktspace/mikktspace.c b/intern/mikktspace/mikktspace.c
index 26e12081f80..ab58c8f48e4 100644
--- a/intern/mikktspace/mikktspace.c
+++ b/intern/mikktspace/mikktspace.c
@@ -306,9 +306,9 @@ tbool genTangSpace(const SMikkTSpaceContext *pContext, const float fAngularThres
iNrTSPaces = GenerateInitialVerticesIndexList(pTriInfos, piTriListIn, pContext, iNrTrianglesIn);
// make a welded index list of identical positions and attributes (pos, norm, texc)
- //printf("gen welded index list begin\n");
+ // printf("gen welded index list begin\n");
GenerateSharedVerticesIndexList(piTriListIn, pContext, iNrTrianglesIn);
- //printf("gen welded index list end\n");
+ // printf("gen welded index list end\n");
// Mark all degenerate triangles
iTotTris = iNrTrianglesIn;
@@ -336,9 +336,9 @@ tbool genTangSpace(const SMikkTSpaceContext *pContext, const float fAngularThres
DegenPrologue(pTriInfos, piTriListIn, iNrTrianglesIn, iTotTris);
// evaluate triangle level attributes and neighbor list
- //printf("gen neighbors list begin\n");
+ // printf("gen neighbors list begin\n");
InitTriInfo(pTriInfos, piTriListIn, pContext, iNrTrianglesIn);
- //printf("gen neighbors list end\n");
+ // printf("gen neighbors list end\n");
// based on the 4 rules, identify groups based on connectivity
iNrMaxGroups = iNrTrianglesIn * 3;
@@ -353,10 +353,10 @@ tbool genTangSpace(const SMikkTSpaceContext *pContext, const float fAngularThres
free(pTriInfos);
return TFALSE;
}
- //printf("gen 4rule groups begin\n");
+ // printf("gen 4rule groups begin\n");
iNrActiveGroups = Build4RuleGroups(
pTriInfos, pGroups, piGroupTrianglesBuffer, piTriListIn, iNrTrianglesIn);
- //printf("gen 4rule groups end\n");
+ // printf("gen 4rule groups end\n");
//
@@ -383,10 +383,10 @@ tbool genTangSpace(const SMikkTSpaceContext *pContext, const float fAngularThres
// make tspaces, each group is split up into subgroups if necessary
// based on fAngularThreshold. Finally a tangent space is made for
// every resulting subgroup
- //printf("gen tspaces begin\n");
+ // printf("gen tspaces begin\n");
bRes = GenerateTSpaces(
psTspace, pTriInfos, pGroups, iNrActiveGroups, piTriListIn, fThresCos, pContext);
- //printf("gen tspaces end\n");
+ // printf("gen tspaces end\n");
// clean up
free(pGroups);
@@ -458,7 +458,7 @@ tbool genTangSpace(const SMikkTSpaceContext *pContext, const float fAngularThres
return TTRUE;
}
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct {
float vert[3];
@@ -512,10 +512,10 @@ static void radixsort_pair(uint *comp, int *data, uint *comp2, int *data2, int n
}
/* Merge identical vertices.
- * To find vertices with identical position, normal and texcoord, we calculate a hash of the 9 values.
- * Then, by sorting based on that hash, identical elements (having identical hashes) will be moved next to each other.
- * Since there might be hash collisions, the elements of each block are then compared with each other and duplicates
- * are merged.
+ * To find vertices with identical position, normal and texcoord, we calculate a hash of the 9
+ * values. Then, by sorting based on that hash, identical elements (having identical hashes) will
+ * be moved next to each other. Since there might be hash collisions, the elements of each block
+ * are then compared with each other and duplicates are merged.
*/
static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[],
const SMikkTSpaceContext *pContext,
@@ -803,8 +803,8 @@ MIKK_INLINE SVec3 GetTexCoord(const SMikkTSpaceContext *pContext, const int inde
return res;
}
-/////////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
typedef union {
struct {
@@ -844,7 +844,8 @@ static void InitTriInfo(STriInfo pTriInfos[],
const int iNrTrianglesIn)
{
int f = 0, i = 0, t = 0;
- // pTriInfos[f].iFlag is cleared in GenerateInitialVerticesIndexList() which is called before this function.
+ // pTriInfos[f].iFlag is cleared in GenerateInitialVerticesIndexList()
+ // which is called before this function.
// generate neighbor info list
for (f = 0; f < iNrTrianglesIn; f++)
@@ -883,7 +884,7 @@ static void InitTriInfo(STriInfo pTriInfos[],
const SVec3 d2 = vsub(v3, v1);
const float fSignedAreaSTx2 = t21x * t31y - t21y * t31x;
- //assert(fSignedAreaSTx2!=0);
+ // assert(fSignedAreaSTx2!=0);
SVec3 vOs = vsub(vscale(t31y, d1), vscale(t21y, d2)); // eq 18
SVec3 vOt = vadd(vscale(-t31x, d1), vscale(t21x, d2)); // eq 19
@@ -925,7 +926,7 @@ static void InitTriInfo(STriInfo pTriInfos[],
const tbool bOrientB = (pTriInfos[t + 1].iFlag & ORIENT_PRESERVING) != 0 ? TTRUE : TFALSE;
// if this happens the quad has extremely bad mapping!!
if (bOrientA != bOrientB) {
- //printf("found quad with bad mapping\n");
+ // printf("found quad with bad mapping\n");
tbool bChooseOrientFirstTri = TFALSE;
if ((pTriInfos[t + 1].iFlag & GROUP_WITH_ANY) != 0)
bChooseOrientFirstTri = TTRUE;
@@ -961,8 +962,8 @@ static void InitTriInfo(STriInfo pTriInfos[],
}
}
-/////////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
static tbool AssignRecur(const int piTriListIn[],
STriInfo psTriInfos[],
@@ -1097,8 +1098,8 @@ static tbool AssignRecur(const int piTriListIn[],
return TTRUE;
}
-/////////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
static tbool CompareSubGroups(const SSubGroup *pg1, const SSubGroup *pg2);
static void QuickSort(int *pSortBuffer, int iLeft, int iRight, unsigned int uSeed);
@@ -1219,7 +1220,7 @@ static tbool GenerateTSpaces(STSpace psTspace[],
// assign tangent space index
assert(bFound || l == iUniqueSubGroups);
- //piTempTangIndices[f*3+index] = iUniqueTspaces+l;
+ // piTempTangIndices[f*3+index] = iUniqueTspaces+l;
// if no match was found we allocate a new subgroup
if (!bFound) {
@@ -1458,7 +1459,7 @@ static void BuildNeighborsFast(STriInfo pTriInfos[],
if (pEdges[iCurStartIndex].i0 != pEdges[i].i0) {
const int iL = iCurStartIndex;
const int iR = i - 1;
- //const int iElems = i-iL;
+ // const int iElems = i-iL;
iCurStartIndex = i;
QuickSortEdges(pEdges, iL, iR, 1, uSeed); // sort channel 1 which is i1
}
@@ -1472,7 +1473,7 @@ static void BuildNeighborsFast(STriInfo pTriInfos[],
if (pEdges[iCurStartIndex].i0 != pEdges[i].i0 || pEdges[iCurStartIndex].i1 != pEdges[i].i1) {
const int iL = iCurStartIndex;
const int iR = i - 1;
- //const int iElems = i-iL;
+ // const int iElems = i-iL;
iCurStartIndex = i;
QuickSortEdges(pEdges, iL, iR, 2, uSeed); // sort channel 2 which is f
}
@@ -1510,7 +1511,7 @@ static void BuildNeighborsFast(STriInfo pTriInfos[],
&piTriListIn[t * 3],
pEdges[j].i0,
pEdges[j].i1); // resolve index ordering and edge_num
- //assert(!(i0_A==i1_B && i1_A==i0_B));
+ // assert(!(i0_A==i1_B && i1_A==i0_B));
bUnassigned_B = pTriInfos[t].FaceNeighbors[edgenum_B] == -1 ? TTRUE : TFALSE;
if (i0_A == i0_B && i1_A == i1_B && bUnassigned_B)
bNotFound = TFALSE;
@@ -1521,7 +1522,7 @@ static void BuildNeighborsFast(STriInfo pTriInfos[],
if (!bNotFound) {
int t = pEdges[j].f;
pTriInfos[f].FaceNeighbors[edgenum_A] = t;
- //assert(pTriInfos[t].FaceNeighbors[edgenum_B]==-1);
+ // assert(pTriInfos[t].FaceNeighbors[edgenum_B]==-1);
pTriInfos[t].FaceNeighbors[edgenum_B] = f;
}
}
@@ -1550,7 +1551,7 @@ static void BuildNeighborsSlow(STriInfo pTriInfos[],
// in rev order
const int i1_B = piTriListIn[t * 3 + j];
const int i0_B = piTriListIn[t * 3 + (j < 2 ? (j + 1) : 0)];
- //assert(!(i0_A==i1_B && i1_A==i0_B));
+ // assert(!(i0_A==i1_B && i1_A==i0_B));
if (i0_A == i0_B && i1_A == i1_B)
bFound = TTRUE;
else
@@ -1565,7 +1566,7 @@ static void BuildNeighborsSlow(STriInfo pTriInfos[],
// assign neighbors
if (bFound) {
pTriInfos[f].FaceNeighbors[i] = t;
- //assert(pTriInfos[t].FaceNeighbors[j]==-1);
+ // assert(pTriInfos[t].FaceNeighbors[j]==-1);
pTriInfos[t].FaceNeighbors[j] = f;
}
}
diff --git a/intern/mikktspace/mikktspace.h b/intern/mikktspace/mikktspace.h
index bc5c0d62f4f..cbd541494a7 100644
--- a/intern/mikktspace/mikktspace.h
+++ b/intern/mikktspace/mikktspace.h
@@ -38,8 +38,8 @@ extern "C" {
* and used as is into any tool, program or plugin.
* The code is designed to consistently generate the same
* tangent spaces, for a given mesh, in any tool in which it is used.
- * This is done by performing an internal welding step and subsequently an order-independent evaluation
- * of tangent space for meshes consisting of triangles and quads.
+ * This is done by performing an internal welding step and subsequently an order-independent
+ * evaluation of tangent space for meshes consisting of triangles and quads.
* This means faces can be received in any order and the same is true for
* the order of vertices of each face. The generated result will not be affected
* by such reordering. Additionally, whether degenerate (vertices or texture coordinates)
@@ -88,10 +88,12 @@ typedef struct {
// This function is used to return the tangent and fSign to the application.
// fvTangent is a unit length vector.
- // For normal maps it is sufficient to use the following simplified version of the bitangent which is generated at pixel/vertex level.
+ // For normal maps it is sufficient to use the following simplified version of the bitangent
+ // which is generated at pixel/vertex level.
// bitangent = fSign * cross(vN, tangent);
// Note that the results are returned unindexed. It is possible to generate a new index list
- // But averaging/overwriting tangent spaces by using an already existing index list WILL produce INCRORRECT results.
+ // But averaging/overwriting tangent spaces by using an already existing index list WILL produce
+ // INCRORRECT results.
// DO NOT! use an already existing index list.
void (*m_setTSpaceBasic)(const SMikkTSpaceContext *pContext,
const float fvTangent[],
@@ -104,12 +106,13 @@ typedef struct {
// true magnitudes which can be used for relief mapping effects.
// fvBiTangent is the "real" bitangent and thus may not be perpendicular to fvTangent.
// However, both are perpendicular to the vertex normal.
- // For normal maps it is sufficient to use the following simplified version of the bitangent which is generated at pixel/vertex level.
+ // For normal maps it is sufficient to use the following simplified version of the bitangent
+ // which is generated at pixel/vertex level.
// fSign = bIsOrientationPreserving ? 1.0f : (-1.0f);
// bitangent = fSign * cross(vN, tangent);
// Note that the results are returned unindexed. It is possible to generate a new index list
- // But averaging/overwriting tangent spaces by using an already existing index list WILL produce INCRORRECT results.
- // DO NOT! use an already existing index list.
+ // But averaging/overwriting tangent spaces by using an already existing index list WILL produce
+ // INCRORRECT results. DO NOT! use an already existing index list.
void (*m_setTSpace)(const SMikkTSpaceContext *pContext,
const float fvTangent[],
const float fvBiTangent[],
@@ -121,26 +124,27 @@ typedef struct {
} SMikkTSpaceInterface;
struct SMikkTSpaceContext {
- SMikkTSpaceInterface *m_pInterface; // initialized with callback functions
- void *
- m_pUserData; // pointer to client side mesh data etc. (passed as the first parameter with every interface call)
+ // initialized with callback functions
+ SMikkTSpaceInterface *m_pInterface;
+ // pointer to client side mesh data etc.
+ // (passed as the first parameter with every interface call)
+ void *m_pUserData;
};
// these are both thread safe!
-tbool genTangSpaceDefault(
- const SMikkTSpaceContext *
- pContext); // Default (recommended) fAngularThreshold is 180 degrees (which means threshold disabled)
+// Default (recommended) fAngularThreshold is 180 degrees (which means threshold disabled)
+tbool genTangSpaceDefault(const SMikkTSpaceContext *pContext);
tbool genTangSpace(const SMikkTSpaceContext *pContext, const float fAngularThreshold);
-// To avoid visual errors (distortions/unwanted hard edges in lighting), when using sampled normal maps, the
-// normal map sampler must use the exact inverse of the pixel shader transformation.
-// The most efficient transformation we can possibly do in the pixel shader is
-// achieved by using, directly, the "unnormalized" interpolated tangent, bitangent and vertex normal: vT, vB and vN.
+// To avoid visual errors (distortions/unwanted hard edges in lighting), when using sampled normal
+// maps, the normal map sampler must use the exact inverse of the pixel shader transformation.
+// The most efficient transformation we can possibly do in the pixel shader is achieved by using,
+// directly, the "unnormalized" interpolated tangent, bitangent and vertex normal: vT, vB and vN.
// pixel shader (fast transform out)
// vNout = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN );
// where vNt is the tangent space normal. The normal map sampler must likewise use the
-// interpolated and "unnormalized" tangent, bitangent and vertex normal to be compliant with the pixel shader.
-// sampler does (exact inverse of pixel shader):
+// interpolated and "unnormalized" tangent, bitangent and vertex normal to be compliant with the
+// pixel shader. sampler does (exact inverse of pixel shader):
// float3 row0 = cross(vB, vN);
// float3 row1 = cross(vN, vT);
// float3 row2 = cross(vT, vB);
@@ -149,12 +153,13 @@ tbool genTangSpace(const SMikkTSpaceContext *pContext, const float fAngularThres
// where vNout is the sampled normal in some chosen 3D space.
//
// Should you choose to reconstruct the bitangent in the pixel shader instead
-// of the vertex shader, as explained earlier, then be sure to do this in the normal map sampler also.
-// Finally, beware of quad triangulations. If the normal map sampler doesn't use the same triangulation of
-// quads as your renderer then problems will occur since the interpolated tangent spaces will differ
-// eventhough the vertex level tangent spaces match. This can be solved either by triangulating before
-// sampling/exporting or by using the order-independent choice of diagonal for splitting quads suggested earlier.
-// However, this must be used both by the sampler and your tools/rendering pipeline.
+// of the vertex shader, as explained earlier, then be sure to do this in the normal map sampler
+// also. Finally, beware of quad triangulations. If the normal map sampler doesn't use the same
+// triangulation of quads as your renderer then problems will occur since the interpolated tangent
+// spaces will differ eventhough the vertex level tangent spaces match. This can be solved either
+// by triangulating before sampling/exporting or by using the order-independent choice of diagonal
+// for splitting quads suggested earlier. However, this must be used both by the sampler and your
+// tools/rendering pipeline.
#ifdef __cplusplus
}
diff --git a/intern/opencolorio/ocio_impl.cc b/intern/opencolorio/ocio_impl.cc
index 3917ed234c7..1b2207bfb53 100644
--- a/intern/opencolorio/ocio_impl.cc
+++ b/intern/opencolorio/ocio_impl.cc
@@ -496,9 +496,8 @@ int OCIOImpl::colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs_)
const char *family = (*cs)->getFamily();
if (!strcmp(family, "rrt") || !strcmp(family, "display")) {
- /* assume display and rrt transformations are not invertible
- * in fact some of them could be, but it doesn't make much sense to allow use them as invertible
- */
+ /* assume display and rrt transformations are not invertible in fact some of them could be,
+ * but it doesn't make much sense to allow use them as invertible. */
return false;
}
@@ -508,7 +507,8 @@ int OCIOImpl::colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs_)
}
if ((*cs)->getTransform(COLORSPACE_DIR_TO_REFERENCE)) {
- /* if there's defined transform to reference space, color space could be converted to scene linear */
+ /* if there's defined transform to reference space,
+ * color space could be converted to scene linear. */
return true;
}
diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc
index 4d0908eafd5..99d59c8d989 100644
--- a/intern/opencolorio/ocio_impl_glsl.cc
+++ b/intern/opencolorio/ocio_impl_glsl.cc
@@ -70,8 +70,8 @@ typedef struct OCIO_GLSLShader {
/* LUT */
bool lut3d_texture_allocated; /* boolean flag indicating whether
- * lut texture is allocated
- */
+ * lut texture is allocated
+ */
bool lut3d_texture_valid;
GLuint lut3d_texture; /* OGL texture ID for 3D LUT */
diff --git a/intern/rigidbody/RBI_api.h b/intern/rigidbody/RBI_api.h
index 9a7cbec6879..9546b840419 100644
--- a/intern/rigidbody/RBI_api.h
+++ b/intern/rigidbody/RBI_api.h
@@ -83,7 +83,8 @@ void RB_dworld_set_split_impulse(rbDynamicsWorld *world, int split_impulse);
/* Simulation ----------------------- */
-/* Step the simulation by the desired amount (in seconds) with extra controls on substep sizes and maximum substeps */
+/* Step the simulation by the desired amount (in seconds) with extra controls on substep sizes and
+ * maximum substeps */
void RB_dworld_step_simulation(rbDynamicsWorld *world,
float timeStep,
int maxSubSteps,
diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp
index afeddc4d790..1b22080756d 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -23,26 +23,28 @@
*/
/*
-Bullet Continuous Collision Detection and Physics Library
-Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
-
-This software is provided 'as-is', without any express or implied warranty.
-In no event will the authors be held liable for any damages arising from the use of this software.
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it freely,
-subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
-2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-3. This notice may not be removed or altered from any source distribution.
-*/
+ * Bullet Continuous Collision Detection and Physics Library
+ * Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
+ *
+ * This software is provided 'as-is', without any express or implied warranty. In no event will the
+ * authors be held liable for any damages arising from the use of this software. Permission is
+ * granted to anyone to use this software for any purpose, including commercial applications, and
+ * to alter it and redistribute it freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
+ * original software. If you use this software in a product, an acknowledgment in the product
+ * documentation would be appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
+ * being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
-/* This file defines the "RigidBody interface" for the
+/* This file defines the "RigidBody interface" for the
* Bullet Physics Engine. This API is designed to be used
* from C-code in Blender as part of the Rigid Body simulation
* system.
*
- * It is based on the Bullet C-API, but is heavily modified to
+ * It is based on the Bullet C-API, but is heavily modified to
* give access to more data types and to offer a nicer interface.
*
* -- Joshua Leung, June 2010
@@ -221,7 +223,7 @@ void RB_dworld_step_simulation(rbDynamicsWorld *world,
*/
void RB_dworld_export(rbDynamicsWorld *world, const char *filename)
{
- //create a large enough buffer. There is no method to pre-calculate the buffer size yet.
+ // create a large enough buffer. There is no method to pre-calculate the buffer size yet.
int maxSerializeBufferSize = 1024 * 1024 * 5;
btDefaultSerializer *serializer = new btDefaultSerializer(maxSerializeBufferSize);
@@ -358,7 +360,8 @@ void RB_body_delete(rbRigidBody *object)
/* body itself */
- /* manually remove constraint refs of the rigid body, normally this happens when removing constraints from the world
+ /* manually remove constraint refs of the rigid body, normally this happens when removing
+ * constraints from the world
* but since we delete everything when the world is rebult, we need to do it manually here */
for (int i = body->getNumConstraintRefs() - 1; i >= 0; i--) {
btTypedConstraint *con = body->getConstraintRef(i);
@@ -388,8 +391,8 @@ float RB_body_get_mass(rbRigidBody *object)
{
btRigidBody *body = object->body;
- /* there isn't really a mass setting, but rather 'inverse mass'
- * which we convert back to mass by taking the reciprocal again
+ /* there isn't really a mass setting, but rather 'inverse mass'
+ * which we convert back to mass by taking the reciprocal again
*/
float value = (float)body->getInvMass();
@@ -572,7 +575,7 @@ void RB_body_deactivate(rbRigidBody *object)
/* Simulation ----------------------- */
-/* The transform matrices Blender uses are OpenGL-style matrices,
+/* The transform matrices Blender uses are OpenGL-style matrices,
* while Bullet uses the Right-Handed coordinate system style instead.
*/
@@ -711,7 +714,8 @@ rbCollisionShape *RB_shape_new_convex_hull(
/* Setup (Triangle Mesh) ---------- */
-/* Need to call RB_trimesh_finish() after creating triangle mesh and adding vertices and triangles */
+/* Need to call RB_trimesh_finish() after creating triangle mesh and adding vertices and triangles
+ */
rbMeshData *RB_trimesh_data_new(int num_tris, int num_verts)
{
diff --git a/intern/string/STR_String.h b/intern/string/STR_String.h
index 5516f14bafa..4e6d04c1c64 100644
--- a/intern/string/STR_String.h
+++ b/intern/string/STR_String.h
@@ -312,7 +312,7 @@ class STR_String {
}
// serializing
- //int Serialize(pCStream stream);
+ // int Serialize(pCStream stream);
protected:
// Implementation
@@ -334,7 +334,7 @@ class STR_String {
}
char *m_data; // -> STR_String data
- int m_len; //z Data length
+ int m_len; // z Data length
int m_max; // Space in data buffer
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/intern/string/intern/STR_String.cpp b/intern/string/intern/STR_String.cpp
index bc95e96180a..3a4e703ca26 100644
--- a/intern/string/intern/STR_String.cpp
+++ b/intern/string/intern/STR_String.cpp
@@ -336,7 +336,7 @@ int STR_String::FindOneOf(const char *set, int pos) const
//
void STR_String::Replace(int pos, rcSTR_String str)
{
- //bounds(pos, 0, Length()-1);
+ // bounds(pos, 0, Length()-1);
if (str.Length() < 1) {
// Remove one character from the string
@@ -358,8 +358,8 @@ void STR_String::Replace(int pos, rcSTR_String str)
//
void STR_String::Replace(int pos, int num, rcSTR_String str)
{
- //bounds(pos, 0, Length()-1);
- //bounds(pos+num, 0, Length());
+ // bounds(pos, 0, Length()-1);
+ // bounds(pos+num, 0, Length());
assertd(num >= 1);
if (str.Length() < num) {
@@ -385,7 +385,8 @@ void STR_String::Replace(int pos, int num, rcSTR_String str)
-------------------------------------------------------------------------------------------------*/
//
-// Compare two strings and return the result, <0 if *this<rhs, >0 if *this>rhs or 0 if *this==rhs
+// Compare two strings and return the result,
+// <0 if *this<rhs, >0 if *this>rhs or 0 if *this==rhs
//
int STR_String::Compare(rcSTR_String rhs) const
{
@@ -393,7 +394,8 @@ int STR_String::Compare(rcSTR_String rhs) const
}
//
-// Compare two strings without respecting case and return the result, <0 if *this<rhs, >0 if *this>rhs or 0 if *this==rhs
+// Compare two strings without respecting case and return the result,
+// <0 if *this<rhs, >0 if *this>rhs or 0 if *this==rhs
//
int STR_String::CompareNoCase(rcSTR_String rhs) const
{
@@ -608,7 +610,7 @@ std::vector<STR_String> STR_String::Explode(char c) const
}
}
- //uc. -= STR_String("");
+ // uc. -= STR_String("");
return uc;
}
diff --git a/intern/utfconv/utf_winfunc.h b/intern/utfconv/utf_winfunc.h
index 71fc9835d74..596109cac0e 100644
--- a/intern/utfconv/utf_winfunc.h
+++ b/intern/utfconv/utf_winfunc.h
@@ -2,7 +2,7 @@
* 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.
+ * 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
@@ -15,7 +15,7 @@
*
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
- *
+ *
*/
#ifndef __UTF_WINFUNC_H__
diff --git a/intern/utfconv/utfconv.c b/intern/utfconv/utfconv.c
index 4a098f2595c..10a64448f80 100644
--- a/intern/utfconv/utfconv.c
+++ b/intern/utfconv/utfconv.c
@@ -2,7 +2,7 @@
* 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.
+ * 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
@@ -15,7 +15,7 @@
*
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
- *
+ *
*/
#include "utfconv.h"
@@ -83,22 +83,22 @@ size_t count_utf_16_from_8(const char *string8)
count++;
u32 = 0;
continue;
- } //1 utf-8 char
+ } // 1 utf-8 char
if ((u & 0x07 << 5) == 0xC0) {
type = 1;
u32 = u & 0x1F;
continue;
- } //2 utf-8 char
+ } // 2 utf-8 char
if ((u & 0x0F << 4) == 0xE0) {
type = 2;
u32 = u & 0x0F;
continue;
- } //3 utf-8 char
+ } // 3 utf-8 char
if ((u & 0x1F << 3) == 0xF0) {
type = 3;
u32 = u & 0x07;
continue;
- } //4 utf-8 char
+ } // 4 utf-8 char
continue;
}
else {
@@ -204,22 +204,22 @@ int conv_utf_8_to_16(const char *in8, wchar_t *out16, size_t size16)
out16++;
u32 = 0;
continue;
- } //1 utf-8 char
+ } // 1 utf-8 char
if ((u & 0x07 << 5) == 0xC0) {
type = 1;
u32 = u & 0x1F;
continue;
- } //2 utf-8 char
+ } // 2 utf-8 char
if ((u & 0x0F << 4) == 0xE0) {
type = 2;
u32 = u & 0x0F;
continue;
- } //3 utf-8 char
+ } // 3 utf-8 char
if ((u & 0x1F << 3) == 0xF0) {
type = 3;
u32 = u & 0x07;
continue;
- } //4 utf-8 char
+ } // 4 utf-8 char
err |= UTF_ERROR_ILLCHAR;
continue;
}
diff --git a/intern/utfconv/utfconv.h b/intern/utfconv/utfconv.h
index f13afbc0934..befaeae63de 100644
--- a/intern/utfconv/utfconv.h
+++ b/intern/utfconv/utfconv.h
@@ -2,7 +2,7 @@
* 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.
+ * 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
@@ -15,7 +15,7 @@
*
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
- *
+ *
*/
#ifndef __UTFCONV_H__
@@ -81,12 +81,14 @@ char *alloc_utf_8_from_16(const wchar_t *in16, size_t add);
/**
* Allocates and converts the utf-16 string from utf-8
* @param in8 utf-8 string to convert
- * @param add any additional size which will be allocated for new utf-16 string in wchar_t (two bytes)
+ * @param add any additional size which will be allocated for new utf-16 string
+ * in wchar_t (two bytes)
* @return New allocated and converted utf-16 string or NULL if in8 is 0.
*/
wchar_t *alloc_utf16_from_8(const char *in8, size_t add);
-/* Easy allocation and conversion of new utf-16 string. New string has _16 suffix. Must be deallocated with UTF16_UN_ENCODE in right order*/
+/* Easy allocation and conversion of new utf-16 string. New string has _16 suffix.
+ * Must be deallocated with UTF16_UN_ENCODE in right order. */
#define UTF16_ENCODE(in8str) \
if (1) { \
wchar_t *in8str##_16 = alloc_utf16_from_8((const char *)in8str, 0)
diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c
index 97a2edf7df1..9c763c5b2a1 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -355,6 +355,7 @@ const bTheme U_theme_default = {
.handle_sel_align = RGBA(0xf090a0ff),
.vertex_size = 3,
.outline_width = 1,
+ .obcenter_dia = 6,
.facedot_size = 3,
.editmesh_active = RGBA(0xffffff80),
.clipping_border_3d = RGBA(0x313131ff),
diff --git a/release/scripts/presets/gpencil_material/fill_only.py b/release/scripts/presets/gpencil_material/fill_only.py
index b15f5f28f80..bad9d7b1304 100644
--- a/release/scripts/presets/gpencil_material/fill_only.py
+++ b/release/scripts/presets/gpencil_material/fill_only.py
@@ -8,6 +8,9 @@ gpcolor.color = (0.0, 0.0, 0.0, 0.0)
gpcolor.stroke_image = None
gpcolor.pixel_size = 100.0
gpcolor.use_stroke_pattern = False
+gpcolor.use_stroke_texture_mix = False
+gpcolor.mix_stroke_factor = 0.0
+gpcolor.use_follow_path = True
gpcolor.fill_style = 'SOLID'
gpcolor.fill_color = (0.5, 0.5, 0.5, 1.0)
gpcolor.fill_image = None
@@ -26,7 +29,7 @@ gpcolor.texture_scale = (1.0, 1.0)
gpcolor.texture_angle = 0.0
gpcolor.texture_opacity = 1.0
gpcolor.texture_clamp = False
-gpcolor.texture_mix = False
+gpcolor.use_fill_texture_mix = False
gpcolor.mix_factor = 0.0
gpcolor.show_stroke = False
gpcolor.show_fill = True
diff --git a/release/scripts/presets/gpencil_material/stroke_and_fill.py b/release/scripts/presets/gpencil_material/stroke_and_fill.py
index b9a1e873ea2..1f523949a5d 100644
--- a/release/scripts/presets/gpencil_material/stroke_and_fill.py
+++ b/release/scripts/presets/gpencil_material/stroke_and_fill.py
@@ -8,6 +8,9 @@ gpcolor.color = (0.0, 0.0, 0.0, 1.0)
gpcolor.stroke_image = None
gpcolor.pixel_size = 100.0
gpcolor.use_stroke_pattern = False
+gpcolor.use_stroke_texture_mix = False
+gpcolor.mix_stroke_factor = 0.0
+gpcolor.use_follow_path = True
gpcolor.fill_style = 'SOLID'
gpcolor.fill_color = (0.5, 0.5, 0.5, 1.0)
gpcolor.fill_image = None
@@ -26,7 +29,7 @@ gpcolor.texture_scale = (1.0, 1.0)
gpcolor.texture_angle = 0.0
gpcolor.texture_opacity = 1.0
gpcolor.texture_clamp = False
-gpcolor.texture_mix = False
+gpcolor.use_fill_texture_mix = False
gpcolor.mix_factor = 0.0
gpcolor.show_stroke = True
gpcolor.show_fill = True
diff --git a/release/scripts/presets/gpencil_material/stroke_only.py b/release/scripts/presets/gpencil_material/stroke_only.py
index 96739af59f0..27b579fce0c 100644
--- a/release/scripts/presets/gpencil_material/stroke_only.py
+++ b/release/scripts/presets/gpencil_material/stroke_only.py
@@ -8,6 +8,9 @@ gpcolor.color = (0.0, 0.0, 0.0, 1.0)
gpcolor.stroke_image = None
gpcolor.pixel_size = 100.0
gpcolor.use_stroke_pattern = False
+gpcolor.use_stroke_texture_mix = False
+gpcolor.mix_stroke_factor = 0.0
+gpcolor.use_follow_path = True
gpcolor.fill_style = 'SOLID'
gpcolor.fill_color = (0.5, 0.5, 0.5, 0.0)
gpcolor.fill_image = None
@@ -26,7 +29,7 @@ gpcolor.texture_scale = (1.0, 1.0)
gpcolor.texture_angle = 0.0
gpcolor.texture_opacity = 1.0
gpcolor.texture_clamp = False
-gpcolor.texture_mix = False
+gpcolor.use_fill_texture_mix = False
gpcolor.mix_factor = 0.0
gpcolor.show_stroke = True
gpcolor.show_fill = False
diff --git a/release/scripts/presets/interface_theme/blender_light.xml b/release/scripts/presets/interface_theme/blender_light.xml
index fbdf82f77ab..d1fc068853f 100644
--- a/release/scripts/presets/interface_theme/blender_light.xml
+++ b/release/scripts/presets/interface_theme/blender_light.xml
@@ -408,6 +408,7 @@
paint_curve_handle="#7fff7f7f"
paint_curve_pivot="#ff7f7f7f"
outline_width="1"
+ obcenter_dia="6"
>
<space>
<ThemeSpaceGradient
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 7435f25210d..45c082feee9 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -261,11 +261,11 @@ def _template_items_uv_select_mode(params):
def _template_items_proportional_editing(*, connected=False):
return [
op_menu_pie("VIEW3D_MT_proportional_editing_falloff_pie", {"type": 'O', "value": 'PRESS', "shift": True}),
- ("wm.context_toggle_enum", {"type": 'O', "value": 'PRESS'},
- {"properties": [("data_path", 'tool_settings.proportional_edit'), ("value_1", 'DISABLED'), ("value_2", 'ENABLED')]}),
+ ("wm.context_toggle", {"type": 'O', "value": 'PRESS'},
+ {"properties": [("data_path", 'tool_settings.use_proportional_edit')]}),
*(() if not connected else (
- ("wm.context_toggle_enum", {"type": 'O', "value": 'PRESS', "alt": True},
- {"properties": [("data_path", 'tool_settings.proportional_edit'), ("value_1", 'DISABLED'), ("value_2", 'CONNECTED')]}),
+ ("wm.context_toggle", {"type": 'O', "value": 'PRESS', "alt": True},
+ {"properties": [("data_path", 'tool_settings.use_proportional_connected')]}),
))
]
@@ -326,7 +326,7 @@ def km_window(params):
if params.apple:
# Apple standard shortcuts. Cmd+F for search since F-keys are not easy to use.
items.extend([
- ("wm.read_homefile", {"type": 'N', "value": 'PRESS', "oskey": True}, None),
+ op_menu("TOPBAR_MT_file_new", {"type": 'N', "value": 'PRESS', "oskey": True}),
op_menu("TOPBAR_MT_file_open_recent", {"type": 'O', "value": 'PRESS', "shift": True, "oskey": True}),
("wm.open_mainfile", {"type": 'O', "value": 'PRESS', "oskey": True}, None),
("wm.save_mainfile", {"type": 'S', "value": 'PRESS', "oskey": True}, None),
@@ -356,7 +356,7 @@ def km_window(params):
items.extend([
# File operations
- ("wm.read_homefile", {"type": 'N', "value": 'PRESS', "ctrl": True}, None),
+ op_menu("TOPBAR_MT_file_new", {"type": 'N', "value": 'PRESS', "ctrl": True}),
op_menu("TOPBAR_MT_file_open_recent", {"type": 'O', "value": 'PRESS', "shift": True, "ctrl": True}),
("wm.open_mainfile", {"type": 'O', "value": 'PRESS', "ctrl": True}, None),
("wm.save_mainfile", {"type": 'S', "value": 'PRESS', "ctrl": True}, None),
@@ -713,7 +713,7 @@ def km_outliner(params):
("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None),
("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK'},
- {"properties": [("extend", False), ("recursive", False)]}),
+ {"properties": [("extend", False), ("recursive", False), ("deselect_all", not params.legacy)]}),
("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True},
{"properties": [("extend", True), ("recursive", False)]}),
("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True},
@@ -783,7 +783,7 @@ def km_uv_editor(params):
*_template_items_uv_select_mode(params),
("uv.mark_seam", {"type": 'E', "value": 'PRESS', "ctrl": True}, None),
("uv.select", {"type": params.select_mouse, "value": params.select_mouse_value},
- {"properties": [("extend", False)]}),
+ {"properties": [("extend", False), ("deselect_all", not params.legacy)]}),
("uv.select", {"type": params.select_mouse, "value": params.select_mouse_value, "shift": True},
{"properties": [("extend", True)]}),
("uv.select_loop", {"type": params.select_mouse, "value": params.select_mouse_value, "alt": True},
@@ -863,8 +863,6 @@ def km_uv_editor(params):
("uv.minimize_stretch", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
("uv.pack_islands", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
("uv.average_islands_scale", {"type": 'A', "value": 'PRESS', "ctrl": True}, None),
- ("wm.context_toggle", {"type": 'Q', "value": 'PRESS'},
- {"properties": [("data_path", 'tool_settings.use_uv_sculpt')]}),
])
if params.select_mouse == 'LEFTMOUSE' and not params.legacy:
@@ -877,39 +875,6 @@ def km_uv_editor(params):
return keymap
-def km_uv_sculpt(_params):
- items = []
- keymap = (
- "UV Sculpt",
- {"space_type": 'EMPTY', "region_type": 'WINDOW'},
- {"items": items},
- )
-
- items.extend([
- ("wm.context_toggle", {"type": 'Q', "value": 'PRESS'},
- {"properties": [("data_path", 'tool_settings.use_uv_sculpt')]}),
- ("sculpt.uv_sculpt_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS'},
- {"properties": [("mode", 'NORMAL')]}),
- ("sculpt.uv_sculpt_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
- {"properties": [("mode", 'INVERT')]}),
- ("sculpt.uv_sculpt_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
- {"properties": [("mode", 'RELAX')]}),
- ("brush.scale_size", {"type": 'LEFT_BRACKET', "value": 'PRESS'},
- {"properties": [("scalar", 0.9)]}),
- ("brush.scale_size", {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
- {"properties": [("scalar", 1.0 / 0.9)]}),
- *_template_paint_radial_control("uv_sculpt"),
- ("brush.uv_sculpt_tool_set", {"type": 'S', "value": 'PRESS'},
- {"properties": [("tool", 'RELAX')]}),
- ("brush.uv_sculpt_tool_set", {"type": 'P', "value": 'PRESS'},
- {"properties": [("tool", 'PINCH')]}),
- ("brush.uv_sculpt_tool_set", {"type": 'G', "value": 'PRESS'},
- {"properties": [("tool", 'GRAB')]}),
- ])
-
- return keymap
-
-
# 3D View: all regions.
def km_view3d_generic(_params):
items = []
@@ -1251,7 +1216,8 @@ def km_mask_editing(params):
("mask.delete", {"type": 'X', "value": 'PRESS'}, None),
("mask.delete", {"type": 'DEL', "value": 'PRESS'}, None),
("mask.select", {"type": params.select_mouse, "value": params.select_mouse_value},
- {"properties": [("extend", False), ("deselect", False), ("toggle", False)]}),
+ {"properties": [("extend", False), ("deselect", False), ("toggle", False),
+ ("deselect_all", not params.legacy)]}),
("mask.select", {"type": params.select_mouse, "value": params.select_mouse_value, "shift": True},
{"properties": [("extend", False), ("deselect", False), ("toggle", True)]}),
*_template_items_select_actions(params, "mask.select_all"),
@@ -1380,7 +1346,8 @@ def km_graph_editor(params):
{"properties": [("data_path", 'space_data.show_handles')]}),
("graph.cursor_set", {"type": params.action_mouse, "value": 'PRESS'}, None),
("graph.clickselect", {"type": params.select_mouse, "value": 'PRESS'},
- {"properties": [("extend", False), ("column", False), ("curves", False)]}),
+ {"properties": [("extend", False), ("deselect_all", not params.legacy),
+ ("column", False), ("curves", False)]}),
("graph.clickselect", {"type": params.select_mouse, "value": 'PRESS', "alt": True},
{"properties": [("extend", False), ("column", True), ("curves", False)]}),
("graph.clickselect", {"type": params.select_mouse, "value": 'PRESS', "shift": True},
@@ -1740,7 +1707,11 @@ def km_info(params):
)
items.extend([
- ("info.select_pick", {"type": params.select_mouse, "value": 'PRESS'}, None),
+ ("info.select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK'}, None),
+ ("info.select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True},
+ {"properties": [("extend", True)]}),
+ ("info.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+ {"properties": [("wait_for_input", False)]}),
*_template_items_select_actions(params, "info.select_all"),
("info.select_box", {"type": 'B', "value": 'PRESS'}, None),
("info.report_replay", {"type": 'R', "value": 'PRESS'}, None),
@@ -1915,7 +1886,8 @@ def km_dopesheet(params):
items.extend([
("action.clickselect", {"type": params.select_mouse, "value": 'PRESS'},
- {"properties": [("extend", False), ("column", False), ("channel", False)]}),
+ {"properties": [("extend", False), ("deselect_all", not params.legacy),
+ ("column", False), ("channel", False)]}),
("action.clickselect", {"type": params.select_mouse, "value": 'PRESS', "alt": True},
{"properties": [("extend", False), ("column", True), ("channel", False)]}),
("action.clickselect", {"type": params.select_mouse, "value": 'PRESS', "shift": True},
@@ -2067,7 +2039,7 @@ def km_nla_editor(params):
items.extend([
("nla.click_select", {"type": params.select_mouse, "value": 'PRESS'},
- {"properties": [("extend", False)]}),
+ {"properties": [("extend", False), ("deselect_all", not params.legacy)]}),
("nla.click_select", {"type": params.select_mouse, "value": 'PRESS', "shift": True},
{"properties": [("extend", True)]}),
("nla.select_leftright", {"type": params.select_mouse, "value": 'PRESS', "ctrl": True},
@@ -2414,7 +2386,8 @@ def km_sequencer(params):
)
),
("sequencer.select", {"type": params.select_mouse, "value": 'PRESS'},
- {"properties": [("extend", False), ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False)]}),
+ {"properties": [("extend", False), ("deselect_all", True),
+ ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False)]}),
("sequencer.select", {"type": params.select_mouse, "value": 'PRESS', "shift": True},
{"properties": [("extend", True), ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False)]}),
("sequencer.select", {"type": params.select_mouse, "value": 'PRESS', "alt": True},
@@ -2575,8 +2548,11 @@ def km_clip(_params):
{"properties": [("backwards", True), ("sequence", True)]}),
("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.prefetch", {"type": 'P', "value": 'PRESS'}, None),
+ op_menu_pie("CLIP_MT_tracking_pie", {"type": 'E', "value": 'PRESS'}),
+ op_menu_pie("CLIP_MT_solving_pie", {"type": 'S', "value": 'PRESS', "shift": True}),
+ op_menu_pie("CLIP_MT_marker_pie", {"type": 'E', "value": 'PRESS', "shift": True}),
+ op_menu_pie("CLIP_MT_reconstruction_pie", {"type": 'W', "value": 'PRESS', "shift": True}),
])
return keymap
@@ -2637,7 +2613,7 @@ def km_clip_editor(params):
{"properties": [("position", 'PATHSTART')]}),
("clip.change_frame", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
("clip.select", {"type": params.select_mouse, "value": 'PRESS'},
- {"properties": [("extend", False)]}),
+ {"properties": [("extend", False), ("deselect_all", not params.legacy)]}),
("clip.select", {"type": params.select_mouse, "value": 'PRESS', "shift": True},
{"properties": [("extend", True)]}),
*_template_items_select_actions(params, "clip.select_all"),
@@ -3019,7 +2995,8 @@ def km_grease_pencil_stroke_edit_mode(params):
("gpencil.interpolate", {"type": 'E', "value": 'PRESS', "ctrl": True, "alt": True}, None),
("gpencil.interpolate_sequence", {"type": 'E', "value": 'PRESS', "shift": True, "ctrl": True}, None),
# Normal select
- ("gpencil.select", {"type": params.select_mouse, "value": params.select_mouse_value}, None),
+ ("gpencil.select", {"type": params.select_mouse, "value": params.select_mouse_value},
+ {"properties": [("deselect_all", not params.legacy)]}),
# Selection
*_grease_pencil_selection(params),
# Duplicate and move selected points
@@ -3958,7 +3935,7 @@ def km_mesh(params):
("mesh.rip_move", {"type": 'V', "value": 'PRESS', "alt": True},
{"properties": [("MESH_OT_rip", [("use_fill", True), ],)]}),
("mesh.rip_edge_move", {"type": 'D', "value": 'PRESS', "alt": True}, None),
- ("mesh.merge", {"type": 'M', "value": 'PRESS', "alt": True}, None),
+ op_menu("VIEW3D_MT_edit_mesh_merge", {"type": 'M', "value": 'PRESS', "alt": True}),
("transform.shrink_fatten", {"type": 'S', "value": 'PRESS', "alt": True}, None),
("mesh.edge_face_add", {"type": 'F', "value": 'PRESS'}, None),
("mesh.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
@@ -5265,13 +5242,32 @@ def km_image_editor_tool_uv_select_lasso(params):
)
+def km_image_editor_tool_uv_sculpt_stroke(params):
+ return (
+ "Image Editor Tool: Uv, Sculpt Stroke",
+ {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
+ {"items": [
+ ("sculpt.uv_sculpt_stroke", {"type": params.tool_mouse, "value": 'PRESS'}, None),
+ ("sculpt.uv_sculpt_stroke", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
+ {"properties": [("mode", 'INVERT')]}),
+ ("sculpt.uv_sculpt_stroke", {"type": params.tool_mouse, "value": 'PRESS', "shift": True},
+ {"properties": [("mode", 'RELAX')]}),
+ ("brush.scale_size", {"type": 'LEFT_BRACKET', "value": 'PRESS'},
+ {"properties": [("scalar", 0.9)]}),
+ ("brush.scale_size", {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
+ {"properties": [("scalar", 1.0 / 0.9)]}),
+ *_template_paint_radial_control("uv_sculpt"),
+ ]},
+ )
+
+
def km_node_editor_tool_select(params):
return (
"Node Tool: Select",
{"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'},
{"items": [
("node.select", {"type": params.select_mouse, "value": 'PRESS'},
- {"properties": [("extend", False)]}),
+ {"properties": [("extend", False), ("deselect_all", not params.legacy)]}),
]},
)
@@ -6105,7 +6101,6 @@ def generate_keymaps(params=None):
# Editors.
km_outliner(params),
km_uv_editor(params),
- km_uv_sculpt(params),
km_view3d_generic(params),
km_view3d(params),
km_mask_editing(params),
@@ -6233,6 +6228,7 @@ def generate_keymaps(params=None):
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_sculpt_stroke(params),
km_node_editor_tool_select(params),
km_node_editor_tool_select_box(params),
km_node_editor_tool_select_lasso(params),
diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index a91787298f8..6cb13446435 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -183,10 +183,6 @@ def km_window(params):
)
items.extend([
-
- op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
- ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
-
# File operations
("wm.read_homefile", {"type": 'N', "value": 'PRESS', "ctrl": True}, None),
op_menu("TOPBAR_MT_file_open_recent", {"type": 'O', "value": 'PRESS', "shift": True, "ctrl": True}),
@@ -425,6 +421,7 @@ def km_property_editor(params):
)
items.extend([
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("buttons.context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None),
("screen.space_context_cycle", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True},
{"properties": [("direction", 'PREV'), ], },),
@@ -444,10 +441,12 @@ def km_outliner(params):
)
items.extend([
+ op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None),
("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK'},
- {"properties": [("extend", False), ("recursive", False)]}),
+ {"properties": [("extend", False), ("recursive", False), ("deselect_all", True)]}),
("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True},
{"properties": [("extend", True), ("recursive", False)]}),
("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True},
@@ -509,9 +508,11 @@ def km_uv_editor(params):
)
items.extend([
+ op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
# Selection modes.
("uv.select", {"type": 'LEFTMOUSE', "value": 'PRESS'},
- {"properties": [("extend", False)]}),
+ {"properties": [("extend", False), ("deselect_all", True)]}),
("uv.select_loop", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK', "shift": True},
{"properties": [("extend", True)]}),
("uv.select_loop", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'},
@@ -534,6 +535,8 @@ def km_uv_editor(params):
("transform.rotate", {"type": 'E', "value": 'PRESS'}, None),
("transform.resize", {"type": 'R', "value": 'PRESS'}, None),
op_menu("IMAGE_MT_uvs_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
+ ("wm.context_toggle", {"type": 'B', "value": 'PRESS'},
+ {"properties": [("data_path", 'tool_settings.use_proportional_edit')]}),
# Tools
op_tool("builtin.select_box", {"type": 'Q', "value": 'PRESS'}),
op_tool("builtin.transform", {"type": 'W', "value": 'PRESS'}),
@@ -546,38 +549,6 @@ def km_uv_editor(params):
return keymap
-def km_uv_sculpt(params):
- items = []
- keymap = (
- "UV Sculpt",
- {"space_type": 'EMPTY', "region_type": 'WINDOW'},
- {"items": items},
- )
-
- items.extend([
- ("wm.context_toggle", {"type": 'Q', "value": 'PRESS'},
- {"properties": [("data_path", 'tool_settings.use_uv_sculpt')]}),
- ("sculpt.uv_sculpt_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS'},
- {"properties": [("mode", 'NORMAL')]}),
- ("sculpt.uv_sculpt_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
- {"properties": [("mode", 'INVERT')]}),
- ("sculpt.uv_sculpt_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
- {"properties": [("mode", 'RELAX')]}),
- ("brush.scale_size", {"type": 'LEFT_BRACKET', "value": 'PRESS'},
- {"properties": [("scalar", 0.9)]}),
- ("brush.scale_size", {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
- {"properties": [("scalar", 1.0 / 0.9)]}),
- *_template_paint_radial_control("uv_sculpt"),
- ("brush.uv_sculpt_tool_set", {"type": 'S', "value": 'PRESS'},
- {"properties": [("tool", 'RELAX')]}),
- ("brush.uv_sculpt_tool_set", {"type": 'P', "value": 'PRESS'},
- {"properties": [("tool", 'PINCH')]}),
- ("brush.uv_sculpt_tool_set", {"type": 'G', "value": 'PRESS'},
- {"properties": [("tool", 'GRAB')]}),
- ])
-
- return keymap
-
# 3D View: all regions.
def km_view3d_generic(_params):
items = []
@@ -606,6 +577,8 @@ def km_view3d(params):
)
items.extend([
+ op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
# Visibility.
("view3d.localview", {"type": 'I', "value": 'PRESS', "shift": True}, None),
# Navigation.
@@ -725,14 +698,16 @@ def km_mask_editing(params):
)
items.extend([
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("mask.new", {"type": 'N', "value": 'PRESS', "alt": True}, None),
- op_menu_pie("VIEW3D_MT_proportional_editing_falloff_pie", {"type": 'O', "value": 'PRESS', "shift": True}),
+ ("wm.context_toggle", {"type": 'B', "value": 'PRESS'},
+ {"properties": [("data_path", 'tool_settings.use_proportional_edit_mask')]}),
("mask.add_vertex_slide", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None),
("mask.add_feather_vertex_slide", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None),
("mask.delete", {"type": 'BACK_SPACE', "value": 'PRESS'}, None),
("mask.delete", {"type": 'DEL', "value": 'PRESS'}, None),
("mask.select", {"type": 'LEFTMOUSE', "value": 'PRESS'},
- {"properties": [("extend", False), ("deselect", False), ("toggle", False)]}),
+ {"properties": [("extend", False), ("deselect", False), ("toggle", False), ("deselect_all", True)]}),
("mask.select", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
{"properties": [("extend", False), ("deselect", False), ("toggle", True)]}),
("mask.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'SELECT')]}),
@@ -789,6 +764,7 @@ def km_markers(params):
)
items.extend([
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("anim.change_frame", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
("graph.cursor_set", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
("marker.add", {"type": 'M', "value": 'PRESS'}, None),
@@ -824,6 +800,7 @@ def km_graph_editor_generic(params):
)
items.extend([
+ op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
("graph.hide", {"type": 'H', "value": 'PRESS', "ctrl": True},
{"properties": [("unselected", False)]}),
@@ -844,10 +821,11 @@ def km_graph_editor(params):
)
items.extend([
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
*_template_items_animation(),
("graph.cursor_set", {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True}, None),
("graph.clickselect", {"type": 'LEFTMOUSE', "value": 'PRESS'},
- {"properties": [("extend", False), ("column", False), ("curves", False)]}),
+ {"properties": [("extend", False), ("deselect_all", True), ("column", False), ("curves", False)]}),
("graph.clickselect", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
{"properties": [("extend", False), ("column", True), ("curves", False)]}),
("graph.clickselect", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
@@ -858,8 +836,6 @@ def km_graph_editor(params):
{"properties": [("extend", False), ("column", False), ("curves", True)]}),
("graph.clickselect", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True},
{"properties": [("extend", True), ("column", False), ("curves", True)]}),
- ("graph.select_leftright", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
- {"properties": [("mode", 'CHECK'), ("extend", False)]}),
("graph.select_leftright", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
{"properties": [("mode", 'CHECK'), ("extend", True)]}),
("graph.select_leftright", {"type": 'LEFT_BRACKET', "value": 'PRESS'},
@@ -877,6 +853,12 @@ def km_graph_editor(params):
{"properties": [("axis_range", False), ("include_handles", True)]}),
("graph.select_box", {"type": 'Q', "value": 'PRESS', "ctrl": True, "alt": True},
{"properties": [("axis_range", True), ("include_handles", True)]}),
+ ("graph.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+ {"properties":[("axis_range", False), ("include_handles", False), ("wait_for_input", False), ("mode", 'SET')]}),
+ ("graph.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "shift": True},
+ {"properties":[("axis_range", False), ("include_handles", False), ("wait_for_input", False), ("mode", 'ADD')]}),
+ ("graph.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "ctrl": True},
+ {"properties":[("axis_range", False),("include_handles", False), ("wait_for_input", False), ("mode", 'SUB')]}),
("graph.select_more", {"type": 'UP_ARROW', "value": 'PRESS'}, None),
("graph.select_less", {"type": 'DOWN_ARROW', "value": 'PRESS'}, None),
("graph.select_linked", {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, None),
@@ -894,13 +876,16 @@ def km_graph_editor(params):
("graph.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
("graph.view_selected", {"type": 'F', "value": 'PRESS'}, None),
("graph.view_frame", {"type": 'A', "value": 'PRESS', "shift": True}, None),
- ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("anim.channels_editable_toggle", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
("transform.translate", {"type": 'W', "value": 'PRESS'}, None),
- ("transform.translate", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
+ ("transform.translate", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'EVT_TWEAK_M', "value": 'ANY'}, None),
("transform.transform", {"type": 'Y', "value": 'PRESS'},
{"properties": [("mode", 'TIME_EXTEND')]}),
("transform.rotate", {"type": 'E', "value": 'PRESS'}, None),
("transform.resize", {"type": 'R', "value": 'PRESS'}, None),
+ ("wm.context_toggle", {"type": 'B', "value": 'PRESS'},
+ {"properties": [("data_path", 'tool_settings.use_proportional_fcurve')]}),
("marker.add", {"type": 'M', "value": 'PRESS'}, None),
("marker.rename", {"type": 'RET', "value": 'PRESS'}, None),
])
@@ -917,6 +902,8 @@ def km_image_generic(params):
)
items.extend([
+ op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("image.new", {"type": 'N', "value": 'PRESS', "alt": True}, None),
("image.open", {"type": 'O', "value": 'PRESS', "alt": True}, None),
("image.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None),
@@ -939,8 +926,8 @@ def km_image(params):
items.extend([
("image.view_all", {"type": 'A', "value": 'PRESS'}, None),
("image.view_selected", {"type": 'F', "value": 'PRESS'}, None),
- ("image.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
- ("image.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("image.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "alt": True}, None),
+ ("image.view_pan", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True}, None),
("image.view_pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None),
("image.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
("image.view_ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None),
@@ -948,7 +935,7 @@ def km_image(params):
("image.view_zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None),
("image.view_zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None),
("image.view_zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None),
- ("image.view_zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ("image.view_zoom", {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True}, None),
("image.view_zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None),
("image.view_zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None),
("image.view_zoom_border", {"type": 'Z', "value": 'PRESS'}, None),
@@ -1005,6 +992,8 @@ def km_node_generic(_params):
)
items.extend([
+ op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
+ ("node.add_search", {"type": 'TAB', "value": 'PRESS'}, None),
])
return keymap
@@ -1065,7 +1054,6 @@ def km_node_editor(params):
{"properties": [("replace", False)]}),
("node.link_make", {"type": 'F', "value": 'PRESS', "shift": True},
{"properties": [("replace", True)]}),
- op_menu("NODE_MT_add", {"type": 'A', "value": 'PRESS', "shift": True}),
("node.duplicate_move", {"type": 'D', "value": 'PRESS', "ctrl": True}, None),
("node.parent_set", {"type": 'P', "value": 'PRESS'}, None),
("node.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None),
@@ -1104,7 +1092,7 @@ def km_node_editor(params):
("node.clear_viewer_border", {"type": 'Z', "value": 'PRESS', "alt": True}, None),
("node.translate_attach", {"type": 'W', "value": 'PRESS'}, None),
("node.translate_attach", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
- ("node.translate_attach", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
+ ("node.translate_attach", {"type": 'EVT_TWEAK_M', "value": 'ANY'}, None),
("transform.translate", {"type": 'W', "value": 'PRESS'},
{"properties": [("release_confirm", True)]}),
("transform.translate", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
@@ -1129,10 +1117,19 @@ def km_info(params):
)
items.extend([
+ op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("info.select_pick", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
- ("info.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'SELECT')]}),
- ("info.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True, "shift": True}, None),
- ("info.select_all", {"type": 'I', "value": 'PRESS', "ctrl": True}, None),
+ ("info.select_pick", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties": [("extend", True)]}),
+ ("info.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+ {"properties": [("wait_for_input", False)]}),
+ ("info.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True},
+ {"properties": [("action", 'SELECT')]}),
+ ("info.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True, "shift": True},
+ {"properties": [("action", 'DESELECT')]}),
+ ("info.select_all", {"type": 'I', "value": 'PRESS', "ctrl": True},
+ {"properties": [("action", 'INVERT')]}),
("info.select_box", {"type": 'Q', "value": 'PRESS'}, None),
("info.report_replay", {"type": 'R', "value": 'PRESS'}, None),
("info.report_delete", {"type": 'BACK_SPACE', "value": 'PRESS'}, None),
@@ -1279,10 +1276,10 @@ def km_dopesheet_generic(params):
)
items.extend([
- ("wm.context_toggle", {"type": 'N', "value": 'PRESS'},
+ op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("wm.context_toggle", {"type": 'RIGHT_BRACKET', "value": 'PRESS', "ctrl": True},
{"properties": [("data_path", 'space_data.show_region_ui')]}),
- ("wm.context_set_enum", {"type": 'TAB', "value": 'PRESS', "ctrl": True},
- {"properties": [("data_path", 'area.type'), ("value", 'GRAPH_EDITOR')]})
])
return keymap
@@ -1299,7 +1296,7 @@ def km_dopesheet(params):
items.extend([
*_template_items_animation(),
("action.clickselect", {"type": 'LEFTMOUSE', "value": 'PRESS'},
- {"properties": [("extend", False), ("column", False), ("channel", False)]}),
+ {"properties": [("extend", False), ("deselect_all", True), ("column", False), ("channel", False)]}),
("action.clickselect", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
{"properties": [("extend", False), ("column", True), ("channel", False)]}),
("action.clickselect", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
@@ -1310,8 +1307,6 @@ def km_dopesheet(params):
{"properties": [("extend", False), ("column", False), ("channel", True)]}),
("action.clickselect", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True},
{"properties": [("extend", True), ("column", False), ("channel", True)]}),
- ("action.select_leftright", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
- {"properties": [("mode", 'CHECK'), ("extend", False)]}),
("action.select_leftright", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
{"properties": [("mode", 'CHECK'), ("extend", True)]}),
("action.select_leftright", {"type": 'LEFT_BRACKET', "value": 'PRESS'},
@@ -1325,6 +1320,12 @@ def km_dopesheet(params):
{"properties": [("axis_range", False)]}),
("action.select_box", {"type": 'Q', "value": 'PRESS', "alt": True},
{"properties": [("axis_range", True)]}),
+ ("action.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+ {"properties":[("axis_range", False), ("wait_for_input", False), ("mode", 'SET')]}),
+ ("action.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "shift": True},
+ {"properties":[("axis_range", False), ("wait_for_input", False), ("mode", 'ADD')]}),
+ ("action.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "ctrl": True},
+ {"properties":[("axis_range", False), ("wait_for_input", False), ("mode", 'SUB')]}),
("action.select_column", {"type": 'K', "value": 'PRESS'},
{"properties": [("mode", 'KEYS')]}),
("action.select_column", {"type": 'K', "value": 'PRESS', "ctrl": True},
@@ -1351,19 +1352,22 @@ def km_dopesheet(params):
("action.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
("action.view_selected", {"type": 'F', "value": 'PRESS'}, None),
("action.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None),
- ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("anim.channels_editable_toggle", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
- ("transform.transform", {"type": 'G', "value": 'PRESS'},
+ ("transform.transform", {"type": 'W', "value": 'PRESS'},
{"properties": [("mode", 'TIME_TRANSLATE')]}),
- ("transform.transform", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+ ("transform.transform", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+ {"properties": [("mode", 'TIME_TRANSLATE')]}),
+ ("transform.transform", {"type": 'EVT_TWEAK_M', "value": 'ANY'},
{"properties": [("mode", 'TIME_TRANSLATE')]}),
("transform.transform", {"type": 'E', "value": 'PRESS'},
{"properties": [("mode", 'TIME_EXTEND')]}),
- ("transform.transform", {"type": 'S', "value": 'PRESS'},
+ ("transform.transform", {"type": 'R', "value": 'PRESS'},
{"properties": [("mode", 'TIME_SCALE')]}),
("transform.transform", {"type": 'T', "value": 'PRESS', "shift": True},
{"properties": [("mode", 'TIME_SLIDE')]}),
- op_menu_pie("VIEW3D_MT_proportional_editing_falloff_pie", {"type": 'O', "value": 'PRESS', "shift": True}),
+ ("wm.context_toggle", {"type": 'B', "value": 'PRESS'},
+ {"properties": [("data_path", 'tool_settings.use_proportional_action')]}),
("marker.add", {"type": 'M', "value": 'PRESS'}, None),
("marker.rename", {"type": 'RET', "value": 'PRESS'}, None),
("anim.start_frame_set", {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, None),
@@ -1382,6 +1386,8 @@ def km_nla_generic(params):
)
items.extend([
+ op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
*_template_items_animation(),
("nla.tweakmode_enter", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
("nla.tweakmode_exit", {"type": 'ESC', "value": 'PRESS'}, None),
@@ -1421,11 +1427,9 @@ def km_nla_editor(params):
items.extend([
("nla.click_select", {"type": 'LEFTMOUSE', "value": 'PRESS'},
- {"properties": [("extend", False)]}),
+ {"properties": [("extend", False), ("deselect_all", True)]}),
("nla.click_select", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
{"properties": [("extend", True)]}),
- ("nla.select_leftright", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
- {"properties": [("mode", 'CHECK'), ("extend", False)]}),
("nla.select_leftright", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
{"properties": [("mode", 'CHECK'), ("extend", True)]}),
("nla.select_leftright", {"type": 'LEFT_BRACKET', "value": 'PRESS'},
@@ -1439,6 +1443,12 @@ def km_nla_editor(params):
{"properties": [("axis_range", False)]}),
("nla.select_box", {"type": 'Q', "value": 'PRESS', "alt": True},
{"properties": [("axis_range", True)]}),
+ ("nla.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+ {"properties":[("wait_for_input", False), ("mode", 'SET')]}),
+ ("nla.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "shift": True},
+ {"properties":[("wait_for_input", False), ("mode", 'ADD')]}),
+ ("nla.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "ctrl": True},
+ {"properties":[("wait_for_input", False), ("mode", 'SUB')]}),
("nla.view_all", {"type": 'A', "value": 'PRESS'}, None),
("nla.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
("nla.view_selected", {"type": 'F', "value": 'PRESS'}, None),
@@ -1452,14 +1462,14 @@ def km_nla_editor(params):
("nla.make_single_user", {"type": 'U', "value": 'PRESS'}, None),
("nla.delete", {"type": 'BACK_SPACE', "value": 'PRESS'}, None),
("nla.delete", {"type": 'DEL', "value": 'PRESS'}, None),
- #("nla.split", {"type": 'Y', "value": 'PRESS'}, None),
("nla.mute_toggle", {"type": 'M', "value": 'PRESS'}, None),
- #("nla.swap", {"type": 'F', "value": 'PRESS', "alt": True}, None),
("nla.move_up", {"type": 'PAGE_UP', "value": 'PRESS'}, None),
("nla.move_down", {"type": 'PAGE_DOWN', "value": 'PRESS'}, None),
("transform.transform", {"type": 'W', "value": 'PRESS'},
{"properties": [("mode", 'TRANSLATION')]}),
- ("transform.transform", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+ ("transform.transform", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+ {"properties": [("mode", 'TRANSLATION')]}),
+ ("transform.transform", {"type": 'EVT_TWEAK_M', "value": 'ANY'},
{"properties": [("mode", 'TRANSLATION')]}),
("transform.transform", {"type": 'E', "value": 'PRESS'},
{"properties": [("mode", 'TIME_EXTEND')]}),
@@ -1481,6 +1491,7 @@ def km_text_generic(params):
)
items.extend([
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("text.start_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
("text.jump", {"type": 'J', "value": 'PRESS', "ctrl": True}, None),
("text.find", {"type": 'G', "value": 'PRESS', "ctrl": True}, None),
@@ -1642,11 +1653,9 @@ def km_sequencercommon(_params):
)
items.extend([
- ("wm.context_toggle", {"type": 'N', "value": 'PRESS'},
+ op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
+ ("wm.context_toggle", {"type": 'RIGHT_BRACKET', "value": 'PRESS', "ctrl": True},
{"properties": [("data_path", 'space_data.show_region_ui')]}),
- ("wm.context_toggle", {"type": 'O', "value": 'PRESS', "shift": True},
- {"properties": [("data_path", 'scene.sequence_editor.show_overlay')]}),
- #("sequencer.view_toggle", {"type": 'TAB', "value": 'PRESS', "ctrl": True}, None),
])
return keymap
@@ -1661,6 +1670,7 @@ def km_sequencer(params):
)
items.extend([
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("sequencer.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'SELECT')]}),
("sequencer.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True, "shift": True}, {"properties": [("action", 'DESELECT')]}),
("sequencer.select_all", {"type": 'I', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'INVERT')]}),
@@ -1689,7 +1699,7 @@ def km_sequencer(params):
("sequencer.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
("sequencer.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
("sequencer.images_separate", {"type": 'Y', "value": 'PRESS'}, None),
- ("sequencer.meta_toggle", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("sequencer.meta_toggle", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
("sequencer.meta_make", {"type": 'G', "value": 'PRESS', "ctrl": True}, None),
("sequencer.meta_separate", {"type": 'G', "value": 'PRESS', "ctrl": True, "alt": True}, None),
("sequencer.view_all", {"type": 'A', "value": 'PRESS'}, None),
@@ -1723,7 +1733,7 @@ def km_sequencer(params):
)
),
("sequencer.select", {"type": 'LEFTMOUSE', "value": 'PRESS'},
- {"properties": [("extend", False), ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False)]}),
+ {"properties": [("extend", False), ("deselect_all", True), ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False)]}),
("sequencer.select", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
{"properties": [("extend", True), ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False)]}),
("sequencer.select", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
@@ -1741,13 +1751,20 @@ def km_sequencer(params):
("sequencer.select_linked_pick", {"type": 'L', "value": 'PRESS', "shift": True},
{"properties": [("extend", True)]}),
("sequencer.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
- ("sequencer.select_box", {"type": 'B', "value": 'PRESS'}, None),
+ ("sequencer.select_box", {"type": 'Q', "value": 'PRESS'}, None),
+ ("sequencer.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+ {"properties":[("wait_for_input", False), ("mode", 'SET')]}),
+ ("sequencer.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "shift": True},
+ {"properties":[("wait_for_input", False), ("mode", 'ADD')]}),
+ ("sequencer.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "ctrl": True},
+ {"properties":[("wait_for_input", False), ("mode", 'SUB')]}),
("sequencer.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None),
- ("sequencer.slip", {"type": 'S', "value": 'PRESS'}, None),
+ ("sequencer.slip", {"type": 'R', "value": 'PRESS'}, None),
("wm.context_set_int", {"type": 'O', "value": 'PRESS'},
{"properties": [("data_path", 'scene.sequence_editor.overlay_frame'), ("value", 0)]}),
- ("transform.seq_slide", {"type": 'G', "value": 'PRESS'}, None),
- ("transform.seq_slide", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
+ ("transform.seq_slide", {"type": 'W', "value": 'PRESS'}, None),
+ ("transform.seq_slide", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("transform.seq_slide", {"type": 'EVT_TWEAK_M', "value": 'ANY'}, None),
("transform.transform", {"type": 'E', "value": 'PRESS'},
{"properties": [("mode", 'TIME_EXTEND')]}),
("marker.add", {"type": 'M', "value": 'PRESS'}, None),
@@ -1766,6 +1783,7 @@ def km_sequencerpreview(params):
)
items.extend([
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("sequencer.view_all_preview", {"type": 'A', "value": 'PRESS'}, None),
("sequencer.view_all_preview", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None),
("sequencer.view_ghost_border", {"type": 'O', "value": 'PRESS'}, None),
@@ -1851,6 +1869,8 @@ def km_clip(params):
)
items.extend([
+ op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("clip.open", {"type": 'O', "value": 'PRESS', "alt": True}, None),
("clip.track_markers", {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True},
{"properties": [("backwards", True), ("sequence", False)]}),
@@ -1878,6 +1898,7 @@ def km_clip_editor(params):
)
items.extend([
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("clip.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
("clip.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
("clip.view_pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None),
@@ -1922,7 +1943,7 @@ def km_clip_editor(params):
{"properties": [("position", 'PATHSTART')]}),
("clip.change_frame", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
("clip.select", {"type": 'LEFTMOUSE', "value": 'PRESS'},
- {"properties": [("extend", False)]}),
+ {"properties": [("extend", False), ("deselect_all", True)]}),
("clip.select", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
{"properties": [("extend", True)]}),
("clip.select_box", {"type": 'Q', "value": 'PRESS'}, None),
@@ -1987,6 +2008,8 @@ def km_clip_graph_editor(params):
)
items.extend([
+ op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("clip.graph_select", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("extend", False)]}),
("clip.graph_select", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
@@ -2030,6 +2053,7 @@ def km_clip_dopesheet_editor(_params):
)
items.extend([
+ ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
("clip.dopesheet_select_channel", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("extend", True)]}),
("clip.dopesheet_view_all", {"type": 'HOME', "value": 'PRESS'}, None),
@@ -2224,7 +2248,8 @@ def km_grease_pencil_stroke_edit_mode(params):
("gpencil.interpolate", {"type": 'E', "value": 'PRESS', "ctrl": True, "alt": True}, None),
("gpencil.interpolate_sequence", {"type": 'E', "value": 'PRESS', "shift": True, "ctrl": True}, None),
# Normal select
- ("gpencil.select", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("gpencil.select", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+ {"properties": [("deselect_all", True)]}),
# Selection
*_grease_pencil_selection(params),
# Duplicate and move selected points
@@ -2267,6 +2292,8 @@ def km_grease_pencil_stroke_edit_mode(params):
("gpencil.move_to_layer", {"type": 'G', "value": 'PRESS'}, None),
# Transform tools
("transform.translate", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
+ ("wm.context_toggle", {"type": 'B', "value": 'PRESS'},
+ {"properties": [("data_path", 'tool_settings.use_proportional_edit')]}),
# Vertex group menu
op_menu("GPENCIL_MT_gpencil_vertex_group", {"type": 'G', "value": 'PRESS', "ctrl": True}),
# Select mode
@@ -2589,6 +2616,7 @@ def km_object_mode(params):
items.extend([
*_template_items_animation(),
+ #Selection
("object.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'SELECT')]}),
("object.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True, "shift": True}, {"properties": [("action", 'DESELECT')]}),
("object.select_all", {"type": 'I', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'INVERT')]}),
@@ -2604,6 +2632,9 @@ def km_object_mode(params):
("object.select_hierarchy", {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True},
{"properties": [("direction", 'CHILD'), ("extend", True)]}),
("object.parent_set", {"type": 'P', "value": 'PRESS'}, None),
+
+ ("wm.context_toggle", {"type": 'B', "value": 'PRESS'},
+ {"properties": [("data_path", 'tool_settings.use_proportional_edit_objects')]}),
("object.parent_clear", {"type": 'P', "value": 'PRESS', "shift": True}, None),
("object.location_clear", {"type": 'W', "value": 'PRESS', "alt": True},
{"properties": [("clear_delta", False)]}),
@@ -2698,7 +2729,7 @@ def km_curve(params):
("curve.select_more", {"type": 'UP_ARROW', "value": 'PRESS'}, None),
("curve.select_less", {"type": 'DOWN_ARROW', "value": 'PRESS'}, None),
("curve.select_linked", {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, None),
- ("curve.shortest_path_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True}, None),
+ ("curve.shortest_path_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True, "shift": True}, None),
("curve.duplicate_move", {"type": 'D', "value": 'PRESS', "ctrl": True}, None),
op_menu("VIEW3D_MT_edit_curve_delete", {"type": 'BACK_SPACE', "value": 'PRESS'}),
op_menu("VIEW3D_MT_edit_curve_delete", {"type": 'DEL', "value": 'PRESS'}),
@@ -2711,8 +2742,11 @@ def km_curve(params):
("curve.hide", {"type": 'H', "value": 'PRESS', "shift": True},
{"properties": [("unselected", True)]}),
op_menu("VIEW3D_MT_edit_curve_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
+ ("wm.context_toggle", {"type": 'B', "value": 'PRESS'},
+ {"properties": [("data_path", 'tool_settings.use_proportional_edit')]}),
# Tools
*_template_items_basic_tools(),
+ op_tool("builtin.extrude", {"type": 'E', "value": 'PRESS', "ctrl": True}),
op_tool("builtin.tilt", {"type": 'Y', "value": 'PRESS'}),
op_tool("builtin.radius", {"type": 'U', "value": 'PRESS'}),
@@ -3005,14 +3039,17 @@ def km_mesh(params):
)
items.extend([
-
+ # Selection
("mesh.loop_select", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'},
{"properties": [("extend", False), ("deselect", False), ("toggle", False)]}),
("mesh.loop_select", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK', "shift": True},
{"properties": [("extend", True), ("deselect", False), ("toggle", False)]}),
("mesh.loop_select", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK', "ctrl": True},
{"properties": [("extend", False), ("deselect", True), ("toggle", False)]}),
- # Selection
+
+ ("mesh.shortest_path_pick", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
+ {"properties": [("use_fill", False)]}),
+
("mesh.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'SELECT')]}),
("mesh.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True, "shift": True}, {"properties": [("action", 'DESELECT')]}),
("mesh.select_all", {"type": 'I', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'INVERT')]}),
@@ -3031,11 +3068,13 @@ def km_mesh(params):
op_menu("VIEW3D_MT_edit_mesh_delete", {"type": 'DEL', "value": 'PRESS'}),
("mesh.dissolve_mode", {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True}, None),
("mesh.dissolve_mode", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None),
+ ("wm.context_toggle", {"type": 'B', "value": 'PRESS'},
+ {"properties": [("data_path", 'tool_settings.use_proportional_edit')]}),
# Menus.
op_menu("VIEW3D_MT_edit_mesh_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
#Tools
*_template_items_basic_tools(),
- op_tool("builtin.bevel", {"type": 'B', "value": 'PRESS'}),
+ op_tool("builtin.bevel", {"type": 'B', "value": 'PRESS', "ctrl": True}),
op_tool("builtin.inset_faces", {"type": 'I', "value": 'PRESS'}),
op_tool("builtin.extrude_region", {"type": 'E', "value": 'PRESS', "ctrl": True}),
op_tool("builtin.knife", {"type": 'K', "value": 'PRESS'}),
@@ -3069,6 +3108,7 @@ def km_armature(params):
("armature.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'SELECT')]}),
("armature.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True, "shift": True}, {"properties": [("action", 'DESELECT')]}),
("armature.select_all", {"type": 'I', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'INVERT')]}),
+
("armature.select_hierarchy", {"type": 'LEFT_BRACKET', "value": 'PRESS'},
{"properties": [("direction", 'PARENT'), ("extend", False)]}),
("armature.select_hierarchy", {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True},
@@ -3077,11 +3117,16 @@ def km_armature(params):
{"properties": [("direction", 'CHILD'), ("extend", False)]}),
("armature.select_hierarchy", {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True},
{"properties": [("direction", 'CHILD'), ("extend", True)]}),
+
("armature.select_more", {"type": 'UP_ARROW', "value": 'PRESS'}, None),
("armature.select_less", {"type": 'DOWN_ARROW', "value": 'PRESS'}, None),
+
("armature.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None),
("armature.select_linked", {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
{"properties": [("deselect", False)]}),
+
+ ("armature.shortest_path_pick", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "shift": True}, None),
+
# Editing.
op_menu("VIEW3D_MT_edit_armature_delete", {"type": 'DEL', "value": 'PRESS'}),
op_menu("VIEW3D_MT_edit_armature_delete", {"type": 'BACK_SPACE', "value": 'PRESS'}),
@@ -3124,6 +3169,8 @@ def km_metaball(params):
("mball.select_all", {"type": 'I', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'INVERT')]}),
("mball.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None),
op_menu("VIEW3D_MT_edit_metaball_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
+ ("wm.context_toggle", {"type": 'B', "value": 'PRESS'},
+ {"properties": [("data_path", 'tool_settings.use_proportional_edit')]}),
# Tools
*_template_items_basic_tools(),
])
@@ -3148,7 +3195,8 @@ def km_lattice(params):
("lattice.select_less", {"type": 'DOWN_ARROW', "value": 'PRESS'}, None),
("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
op_menu("VIEW3D_MT_edit_lattice_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
-
+ ("wm.context_toggle", {"type": 'B', "value": 'PRESS'},
+ {"properties": [("data_path", 'tool_settings.use_proportional_edit')]}),
# Tools
op_tool("builtin.select_box", {"type": 'Q', "value": 'PRESS'}),
op_tool("builtin.move", {"type": 'W', "value": 'PRESS'}),
@@ -3194,6 +3242,8 @@ def km_particle(params):
{"properties": [("data_path_primary", 'tool_settings.particle_edit.brush.size')]}),
("wm.radial_control", {"type": 'U', "value": 'PRESS', "shift": True},
{"properties": [("data_path_primary", 'tool_settings.particle_edit.brush.strength')]}),
+ ("wm.context_toggle", {"type": 'B', "value": 'PRESS'},
+ {"properties": [("data_path", 'tool_settings.use_proportional_edit')]}),
op_menu("VIEW3D_MT_particle_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
])
@@ -3350,10 +3400,10 @@ def km_knife_tool_modal_map(_params):
items.extend([
("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None),
("PANNING", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True}, None),
- ("ADD_CUT", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("ADD_CUT", {"type": 'LEFTMOUSE', "value": 'ANY', "any": True}, None),
("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None),
("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None),
- ("CONFIRM", {"type": 'SPACE', "value": 'PRESS', "any": True}, None),
+ ("CONFIRM", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK', "any": True}, None),
("NEW_CUT", {"type": 'E', "value": 'PRESS'}, None),
("SNAP_MIDPOINTS_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None),
("SNAP_MIDPOINTS_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None),
@@ -3468,20 +3518,97 @@ def km_transform_modal_map(_params):
# Tool System Keymaps
-
def km_3d_view_tool_move(params):
return (
"3D View Tool: Move",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [
- ("transform.translate", {"type": params.tool_tweak, "value": 'ANY'},
+ ("transform.translate", {"type": 'MIDDLEMOUSE', "value": 'ANY'},
+ {"properties": [("release_confirm", True)]}),
+ *_template_items_tool_select_actions("view3d.select_box", type=params.tool_tweak, value='ANY'),
+ ]},
+ )
+
+
+def km_3d_view_tool_rotate(params):
+ return (
+ "3D View Tool: Rotate",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items": [
+ ("transform.rotate", {"type": 'MIDDLEMOUSE', "value": 'ANY'},
+ {"properties": [("release_confirm", True)]}),
+ *_template_items_tool_select_actions("view3d.select_box", type=params.tool_tweak, value='ANY'),
+ ]},
+ )
+
+
+def km_3d_view_tool_scale(params):
+ return (
+ "3D View Tool: Scale",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items": [
+ ("transform.resize", {"type": 'MIDDLEMOUSE', "value": 'ANY'},
+ {"properties": [("release_confirm", True)]}),
+ *_template_items_tool_select_actions("view3d.select_box", type=params.tool_tweak, value='ANY'),
+ ]},
+ )
+
+
+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": [
+ ("mesh.extrude_context_move", {"type": 'MIDDLEMOUSE', "value": 'ANY'},
+ {"properties": [("TRANSFORM_OT_translate", [("release_confirm", True)])]}),
+ *_template_items_tool_select_actions("view3d.select_box", type=params.tool_tweak, value='ANY'),
+ ]},
+ )
+
+
+def km_3d_view_tool_edit_mesh_shear(params):
+ return (
+ "3D View Tool: Edit Mesh, Shear",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items": [
+ ("transform.shear", {"type": 'MIDDLEMOUSE', "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ("object.duplicate_move", {"type": params.tool_tweak, "value": 'ANY', "shift": True}, None),
- ("mesh.duplicate_move", {"type": params.tool_tweak, "value": 'ANY', "shift": True}, None),
- ("curve.duplicate_move", {"type": params.tool_tweak, "value": 'ANY', "shift": True}, None),
- ("armature.duplicate_move", {"type": params.tool_tweak, "value": 'ANY', "shift": True}, None),
- ("mball.duplicate_move", {"type": params.tool_tweak, "value": 'ANY', "shift": True}, None),
- ("gpencil.duplicate_move", {"type": 'D', "value": 'PRESS', "ctrl": True}, None),
+ *_template_items_tool_select_actions("view3d.select_box", type=params.tool_tweak, value='ANY'),
+ ]},
+ )
+
+
+def km_3d_view_tool_edit_mesh_spin(params):
+ return (
+ "3D View Tool: Edit Mesh, Spin",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items": [
+ ("mesh.spin", {"type": 'MIDDLEMOUSE', "value": 'ANY'}, None),
+ *_template_items_tool_select_actions("view3d.select_box", type=params.tool_tweak, value='ANY'),
+ ]},
+ )
+
+
+def km_3d_view_tool_edit_mesh_spin_duplicate(params):
+ return (
+ "3D View Tool: Edit Mesh, Spin Duplicates",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items": [
+ ("mesh.spin", {"type": 'MIDDLEMOUSE', "value": 'ANY'},
+ {"properties": [("dupli", True)]}),
+ *_template_items_tool_select_actions("view3d.select_box", type=params.tool_tweak, value='ANY'),
+ ]},
+ )
+
+
+def km_3d_view_tool_edit_curve_extrude(params):
+ return (
+ "3D View Tool: Edit Curve, Extrude",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items": [
+ ("curve.extrude_move", {"type": 'MIDDLEMOUSE', "value": 'ANY'},
+ {"properties": [("TRANSFORM_OT_translate", [("release_confirm", True)])]}),
+ *_template_items_tool_select_actions("view3d.select_box", type=params.tool_tweak, value='ANY'),
]},
)
@@ -3506,7 +3633,6 @@ def generate_keymaps(params=None):
# Editors.
km_outliner(params),
km_uv_editor(params),
- km_uv_sculpt(params),
km_view3d_generic(params),
km_view3d(params),
km_mask_editing(params),
@@ -3577,4 +3703,11 @@ def generate_keymaps(params=None):
# Tool System.
km_3d_view_tool_move(params),
+ km_3d_view_tool_rotate(params),
+ km_3d_view_tool_scale(params),
+ km_3d_view_tool_edit_mesh_extrude_region(params),
+ km_3d_view_tool_edit_mesh_shear(params),
+ km_3d_view_tool_edit_mesh_spin(params),
+ km_3d_view_tool_edit_mesh_spin_duplicate(params),
+ km_3d_view_tool_edit_curve_extrude(params),
]
diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py
index 14b96e1d5c1..798dd0bdd6a 100644
--- a/release/scripts/startup/bl_operators/object_quick_effects.py
+++ b/release/scripts/startup/bl_operators/object_quick_effects.py
@@ -54,6 +54,7 @@ class ObjectModeOperator:
class QuickFur(ObjectModeOperator, Operator):
+ """Add fur setup to the selected objects"""
bl_idname = "object.quick_fur"
bl_label = "Quick Fur"
bl_options = {'REGISTER', 'UNDO'}
@@ -119,6 +120,7 @@ class QuickFur(ObjectModeOperator, Operator):
class QuickExplode(ObjectModeOperator, Operator):
+ """Make selected objects explode"""
bl_idname = "object.quick_explode"
bl_label = "Quick Explode"
bl_options = {'REGISTER', 'UNDO'}
@@ -325,6 +327,7 @@ def grid_location(x, y):
class QuickSmoke(ObjectModeOperator, Operator):
+ """Use selected objects as smoke emitters"""
bl_idname = "object.quick_smoke"
bl_label = "Quick Smoke"
bl_options = {'REGISTER', 'UNDO'}
@@ -429,6 +432,7 @@ class QuickSmoke(ObjectModeOperator, Operator):
class QuickFluid(ObjectModeOperator, Operator):
+ """Use selected objects in a fluid simulation"""
bl_idname = "object.quick_fluid"
bl_label = "Quick Fluid"
bl_options = {'REGISTER', 'UNDO'}
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index baacb0c051e..c7f516f61a1 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -670,6 +670,9 @@ class AddPresetGpencilMaterial(AddPresetBase, Operator):
"gpcolor.stroke_image",
"gpcolor.pixel_size",
"gpcolor.use_stroke_pattern",
+ "gpcolor.use_stroke_texture_mix",
+ "gpcolor.mix_stroke_factor",
+ "gpcolor.use_follow_path",
"gpcolor.fill_style",
"gpcolor.fill_color",
"gpcolor.fill_image",
@@ -688,7 +691,7 @@ class AddPresetGpencilMaterial(AddPresetBase, Operator):
"gpcolor.texture_angle",
"gpcolor.texture_opacity",
"gpcolor.texture_clamp",
- "gpcolor.texture_mix",
+ "gpcolor.use_fill_texture_mix",
"gpcolor.mix_factor",
"gpcolor.show_stroke",
"gpcolor.show_fill",
diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py
index 2216dce2d28..537ad46126f 100644
--- a/release/scripts/startup/bl_operators/view3d.py
+++ b/release/scripts/startup/bl_operators/view3d.py
@@ -24,7 +24,7 @@ from bpy.props import BoolProperty
class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
- """Extrude individual elements and move"""
+ """Extrude each individual face separately along local normals"""
bl_label = "Extrude Individual and Move"
bl_idname = "view3d.edit_mesh_extrude_individual_move"
@@ -65,7 +65,7 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
class VIEW3D_OT_edit_mesh_extrude_move(Operator):
- """Extrude and move along normals"""
+ """Extrude region together along the average normal"""
bl_label = "Extrude and Move on Normals"
bl_idname = "view3d.edit_mesh_extrude_move_normal"
@@ -123,7 +123,7 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator):
- """Extrude and move along individual normals"""
+ """Extrude region together along local normals"""
bl_label = "Extrude and Move on Individual Normals"
bl_idname = "view3d.edit_mesh_extrude_move_shrink_fatten"
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 5976e036fab..1d6aac38b8e 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -1001,7 +1001,7 @@ class WM_OT_doc_view_manual(Operator):
class WM_OT_doc_view(Operator):
- """Load online reference docs"""
+ """Open online reference docs in.a web browser"""
bl_idname = "wm.doc_view"
bl_label = "View Documentation"
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 14c616d14d5..05a8735fc2f 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -386,7 +386,7 @@ class GPENCIL_MT_pie_tool_palette(Menu):
row.operator("transform.resize", text="Scale", icon='MAN_SCALE')
row = col.row(align=True)
row.label(text="Proportional Edit:")
- row.prop(context.tool_settings, "proportional_edit", text="", icon_only=True)
+ row.prop(context.tool_settings, "use_proportional_edit", text="", icon_only=True)
row.prop(context.tool_settings, "proportional_edit_falloff", text="", icon_only=True)
# NW - Select (Non-Modal)
@@ -808,7 +808,7 @@ class GreasePencilToolsPanel:
layout.label(text="Proportional Edit:")
row = layout.row()
- row.prop(context.tool_settings, "proportional_edit", text="")
+ row.prop(context.tool_settings, "use_proportional_edit", text="")
row.prop(context.tool_settings, "proportional_edit_falloff", text="")
layout.separator()
@@ -881,6 +881,22 @@ class GreasePencilMaterialsPanel:
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
+ # stroke color
+ ma = None
+ if is_view3d and brush is not None:
+ gp_settings = brush.gpencil_settings
+ if gp_settings.use_material_pin is False:
+ ma = ob.material_slots[ob.active_material_index].material
+ else:
+ ma = gp_settings.material
+
+ if ma is not None and ma.grease_pencil is not None:
+ gpcolor = ma.grease_pencil
+ if gpcolor.stroke_style == 'SOLID' or \
+ gpcolor.use_stroke_pattern is True or \
+ gpcolor.use_stroke_texture_mix is True:
+ row = layout.row()
+ row.prop(gpcolor, "color", text="Stroke Color")
else:
space = context.space_data
diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
index fec8723ef5e..4eb43695eb5 100644
--- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
@@ -39,15 +39,6 @@ class PHYSICS_UL_dynapaint_surfaces(UIList):
row.label(text="", icon_value=icon)
row.prop(surf, "name", text="", emboss=False, icon_value=sticon)
row = layout.row(align=True)
-
- if surf.use_color_preview:
- row.prop(
- surf,
- "show_preview",
- text="",
- emboss=False,
- icon='RESTRICT_VIEW_OFF' if surf.show_preview else 'RESTRICT_VIEW_ON'
- )
row.prop(surf, "is_active", text="")
elif self.layout_type == 'GRID':
@@ -373,9 +364,6 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
# vertex format outputs.
if surface.surface_format == 'VERTEX':
if surface_type == 'PAINT':
- # toggle active preview.
- layout.prop(surface, "preview_id")
-
# paint-map output.
row = layout.row()
row.prop_search(surface, "output_name_a", ob.data, "vertex_colors", text="Paintmap Layer")
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 193ab6e6462..4c794a80493 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -541,6 +541,27 @@ class RENDER_PT_eevee_hair(RenderButtonsPanel, Panel):
layout.prop(rd, "hair_subdiv")
+class RENDER_PT_opengl_sampling(RenderButtonsPanel, Panel):
+ bl_label = "Sampling"
+ COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
+
+ @classmethod
+ def poll(cls, context):
+ return (context.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+ layout.use_property_decorate = False # No animation.
+
+ scene = context.scene
+ props = scene.display
+
+ col = layout.column()
+ col.prop(props, "render_aa", text="Render")
+ col.prop(props, "viewport_aa", text="Viewport")
+
+
class RENDER_PT_opengl_film(RenderButtonsPanel, Panel):
bl_label = "Film"
bl_options = {'DEFAULT_CLOSED'}
@@ -552,10 +573,6 @@ class RENDER_PT_opengl_film(RenderButtonsPanel, Panel):
layout.use_property_decorate = False # No animation.
rd = context.scene.render
-
- layout.prop(rd, "use_antialiasing")
-
- layout.prop(rd, "antialiasing_samples")
layout.prop(rd, "alpha_mode")
@@ -704,6 +721,7 @@ classes = (
RENDER_PT_eevee_indirect_lighting_display,
RENDER_PT_eevee_film,
RENDER_PT_eevee_film_overscan,
+ RENDER_PT_opengl_sampling,
RENDER_PT_opengl_lighting,
RENDER_PT_opengl_color,
RENDER_PT_opengl_options,
diff --git a/release/scripts/startup/bl_ui/properties_view_layer.py b/release/scripts/startup/bl_ui/properties_view_layer.py
index 639e31c85ad..121b8f2f401 100644
--- a/release/scripts/startup/bl_ui/properties_view_layer.py
+++ b/release/scripts/startup/bl_ui/properties_view_layer.py
@@ -56,7 +56,6 @@ class VIEWLAYER_PT_layer(ViewLayerButtonsPanel, Panel):
class VIEWLAYER_PT_eevee_layer_passes(ViewLayerButtonsPanel, Panel):
bl_label = "Passes"
- bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_EEVEE'}
def draw(self, context):
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index ffc047ed175..b92b12abb86 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -1514,6 +1514,156 @@ class CLIP_MT_pivot_pie(Menu):
pie.prop_enum(context.space_data, "pivot_point", value='MEDIAN_POINT')
+class CLIP_MT_marker_pie(Menu):
+ # Settings for the individual markers
+ bl_label = "Marker Settings"
+
+ @classmethod
+ def poll(cls, context):
+ space = context.space_data
+ return space.mode == 'TRACKING' and space.clip
+
+ def draw(self, context):
+ clip = context.space_data.clip
+ tracks = getattr(getattr(clip, "tracking", None), "tracks", None)
+ track_active = tracks.active if tracks else None
+
+ layout = self.layout
+ pie = layout.menu_pie()
+ # Use Location Tracking
+ prop = pie.operator("wm.context_set_enum", text="Loc")
+ prop.data_path = "space_data.clip.tracking.tracks.active.motion_model"
+ prop.value = "Loc"
+ # Use Affine Tracking
+ prop = pie.operator("wm.context_set_enum", text="Affine")
+ prop.data_path = "space_data.clip.tracking.tracks.active.motion_model"
+ prop.value = "Affine"
+ # Copy Settings From Active To Selected
+ pie.operator("clip.track_settings_to_track", icon='COPYDOWN')
+ # Make Settings Default
+ pie.operator("clip.track_settings_as_default", icon='SETTINGS')
+ if track_active:
+ # Use Normalization
+ pie.prop(track_active, "use_normalization", text="Normalization")
+ # Use Brute Force
+ pie.prop(track_active, "use_brute", text="Use Brute Force")
+ # Match Keyframe
+ prop = pie.operator("wm.context_set_enum", text="Match Previous", icon='KEYFRAME_HLT')
+ prop.data_path = "space_data.clip.tracking.tracks.active.pattern_match"
+ prop.value = 'KEYFRAME'
+ # Match Previous Frame
+ prop = pie.operator("wm.context_set_enum", text="Match Keyframe", icon='KEYFRAME')
+ prop.data_path = "space_data.clip.tracking.tracks.active.pattern_match"
+ prop.value = 'PREV_FRAME'
+
+
+class CLIP_MT_tracking_pie(Menu):
+ # Tracking Operators
+ bl_label = "Tracking"
+
+ @classmethod
+ def poll(cls, context):
+ space = context.space_data
+ return space.mode == 'TRACKING' and space.clip
+
+ def draw(self, context):
+ space = context.space_data
+ clip = space.clip
+ act_track = clip.tracking.tracks.active
+
+ layout = self.layout
+ pie = layout.menu_pie()
+ # Track Backwards
+ prop = pie.operator("clip.track_markers", icon='TRACKING_BACKWARDS')
+ prop.backwards = True
+ prop.sequence = True
+ # Track Forwards
+ prop = pie.operator("clip.track_markers", icon='TRACKING_FORWARDS')
+ prop.backwards = False
+ prop.sequence = True
+ # Disable Marker
+ pie.operator("clip.disable_markers", icon="VISIBLE_IPO_ON").action = 'TOGGLE'
+ # Detect Features
+ pie.operator("clip.detect_features", icon='ZOOM_SELECTED')
+ # Clear Path Backwards
+ pie.operator("clip.clear_track_path", icon='TRACKING_CLEAR_BACKWARDS').action = 'UPTO'
+ # Clear Path Forwards
+ pie.operator("clip.clear_track_path", icon='TRACKING_CLEAR_FORWARDS').action = 'REMAINED'
+ # Refine Backwards
+ pie.operator("clip.refine_markers", icon='TRACKING_REFINE_BACKWARDS').backwards = True
+ # Refine Forwards
+ pie.operator("clip.refine_markers", icon='TRACKING_REFINE_FORWARDS').backwards = False
+
+
+class CLIP_MT_solving_pie(Menu):
+ # Operators to solve the scene
+ bl_label = "Solving"
+
+ @classmethod
+ def poll(cls, context):
+ space = context.space_data
+ return space.mode == 'TRACKING' and space.clip
+
+ def draw(self, context):
+ clip = context.space_data.clip
+ settings = getattr(getattr(clip, "tracking", None), "settings", None)
+
+ layout = self.layout
+ pie = layout.menu_pie()
+ # Clear Solution
+ pie.operator("clip.clear_solution", icon='FILE_REFRESH')
+ # Solve Camera
+ pie.operator("clip.solve_camera", text="Solve Camera", icon='OUTLINER_OB_CAMERA')
+ # Use Tripod Solver
+ if settings:
+ pie.prop(settings, "use_tripod_solver", text="Tripod Solver")
+ # create Plane Track
+ pie.operator("clip.create_plane_track", icon='MATPLANE')
+ # Set Keyframe A
+ pie.operator("clip.set_solver_keyframe", text="Set Keyframe A",
+ icon='KEYFRAME').keyframe = 'KEYFRAME_A'
+ # Set Keyframe B
+ pie.operator("clip.set_solver_keyframe", text="Set Keyframe B",
+ icon='KEYFRAME').keyframe = 'KEYFRAME_B'
+ # Clean Tracks
+ prop = pie.operator("clip.clean_tracks", icon='X')
+ # Filter Tracks
+ pie.operator("clip.filter_tracks", icon='FILTER')
+ prop.frames = 15
+ prop.error = 2
+
+
+class CLIP_MT_reconstruction_pie(Menu):
+ # Scene Reconstruction
+ bl_label = "Reconstruction"
+
+ @classmethod
+ def poll(cls, context):
+ space = context.space_data
+ return space.mode == 'TRACKING' and space.clip
+
+ def draw(self, context):
+ layout = self.layout
+ pie = layout.menu_pie()
+ # Set Active Clip As Viewport Background
+ pie.operator("clip.set_viewport_background", text="Set Viewport Background", icon='FILE_IMAGE')
+ # Setup Tracking Scene
+ pie.operator("clip.setup_tracking_scene", text="Setup Tracking Scene", icon='SCENE_DATA')
+ # Setup Floor
+ pie.operator("clip.set_plane", text="Set Floor", icon='AXIS_TOP')
+ # Set Origin
+ pie.operator("clip.set_origin", text="Set Origin", icon='OBJECT_ORIGIN')
+ # Set X Axis
+ pie.operator("clip.set_axis", text="Set X Axis", icon='AXIS_FRONT').axis = 'X'
+ # Set Y Axis
+ pie.operator("clip.set_axis", text="Set Y Axis", icon='AXIS_SIDE').axis = 'Y'
+ # Set Scale
+ pie.operator("clip.set_scale", text="Set Scale", icon='ARROW_LEFTRIGHT')
+ # Apply Solution Scale
+ pie.operator("clip.apply_solution_scale", icon='ARROW_LEFTRIGHT')
+
+
+
classes = (
CLIP_UL_tracking_objects,
CLIP_HT_header,
@@ -1569,6 +1719,10 @@ classes = (
CLIP_MT_stabilize_2d_context_menu,
CLIP_MT_stabilize_2d_rotation_context_menu,
CLIP_MT_pivot_pie,
+ CLIP_MT_marker_pie,
+ CLIP_MT_tracking_pie,
+ CLIP_MT_reconstruction_pie,
+ CLIP_MT_solving_pie
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index 94f1292a3cc..70d37c971a5 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -589,7 +589,6 @@ class DOPESHEET_MT_context_menu(Menu):
layout.operator_menu_enum("action.handle_type", "type", text="Handle Type")
layout.operator_menu_enum("action.interpolation_type", "type", text="Interpolation Mode")
- layout.operator_menu_enum("action.easing_type", "type", text="Easing Type")
layout.separator()
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 28edc6df3ce..af357a8cc12 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -41,13 +41,13 @@ from bpy.app.translations import pgettext_iface as iface_
class ImagePaintPanel(UnifiedPaintPanel):
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
+ bl_space_type = 'IMAGE_EDITOR'
+ bl_region_type = 'UI'
class BrushButtonsPanel(UnifiedPaintPanel):
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
+ bl_space_type = 'IMAGE_EDITOR'
+ bl_region_type = 'UI'
@classmethod
def poll(cls, context):
@@ -55,6 +55,25 @@ class BrushButtonsPanel(UnifiedPaintPanel):
return tool_settings.brush
+class IMAGE_PT_active_tool(Panel):
+ bl_space_type = 'IMAGE_EDITOR'
+ bl_region_type = 'UI'
+ bl_label = "Active Tool"
+ bl_category = "Tool"
+
+ def draw(self, context):
+ layout = self.layout
+
+ # Panel display of topbar tool settings.
+ # currently displays in tool settings, keep here since the same functionality is used for the topbar.
+
+ layout.use_property_split = True
+ layout.use_property_decorate = False
+
+ from .space_toolsystem_common import ToolSelectPanelHelper
+ ToolSelectPanelHelper.draw_active_tool_header(context, layout, show_tool_name=True)
+
+
class IMAGE_MT_view(Menu):
bl_label = "View"
@@ -160,7 +179,7 @@ class IMAGE_MT_select(Menu):
layout.separator()
layout.operator("uv.select_pinned")
- layout.operator("uv.select_linked").extend = False
+ layout.operator("uv.select_linked")
layout.separator()
@@ -265,20 +284,6 @@ class IMAGE_MT_uvs_showhide(Menu):
layout.operator("uv.hide", text="Hide Unselected").unselected = True
-class IMAGE_MT_uvs_proportional(Menu):
- bl_label = "Proportional Editing"
-
- def draw(self, context):
- layout = self.layout
-
- layout.props_enum(context.tool_settings, "proportional_edit")
-
- layout.separator()
-
- layout.label(text="Falloff:")
- layout.props_enum(context.tool_settings, "proportional_edit_falloff")
-
-
class IMAGE_MT_uvs_transform(Menu):
bl_label = "Transform"
@@ -359,10 +364,6 @@ class IMAGE_MT_uvs(Menu):
layout.separator()
- layout.prop(tool_settings, "use_uv_sculpt")
-
- layout.separator()
-
layout.prop(uv, "use_live_unwrap")
layout.operator("uv.unwrap")
@@ -518,31 +519,10 @@ class IMAGE_HT_tool_header(Header):
self.draw_tool_settings(context)
sima = context.space_data
- show_uvedit = sima.show_uvedit
- show_maskedit = sima.show_maskedit
layout.separator_spacer()
- if show_uvedit or show_maskedit:
- layout.prop(sima, "pivot_point", icon_only=True)
-
- if show_uvedit:
- tool_settings = context.tool_settings
-
- # Snap.
- row = layout.row(align=True)
- row.prop(tool_settings, "use_snap", text="")
- row.prop(tool_settings, "snap_uv_element", icon_only=True)
- if tool_settings.snap_uv_element != 'INCREMENT':
- row.prop(tool_settings, "snap_target", text="")
-
- # Proportional Editing
- row = layout.row(align=True)
- row.prop(tool_settings, "proportional_edit", icon_only=True)
- # if tool_settings.proportional_edit != 'DISABLED':
- sub = row.row(align=True)
- sub.active = tool_settings.proportional_edit != 'DISABLED'
- sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
+ IMAGE_HT_header.draw_xform_template(layout, context)
layout.separator_spacer()
@@ -570,9 +550,10 @@ class IMAGE_HT_tool_header(Header):
if tool_mode == 'PAINT':
if (tool is not None) and tool.has_datablock:
- layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common_2d", category="")
- elif context.uv_sculpt_object is not None:
- layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".uv_sculpt", category="")
+ layout.popover_group(space_type='IMAGE_EDITOR', region_type='UI', context=".paint_common_2d", category="")
+ elif tool_mode == 'UV':
+ if (tool is not None) and tool.has_datablock:
+ layout.popover_group(space_type='IMAGE_EDITOR', region_type='UI', context=".uv_sculpt", category="")
def draw_mode_settings(self, context):
layout = self.layout
@@ -584,15 +565,15 @@ class IMAGE_HT_tool_header(Header):
tool_mode = context.mode if tool is None else tool.mode
if tool_mode == 'PAINT':
- layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".imagepaint_2d", category="")
+ layout.popover_group(space_type='IMAGE_EDITOR', region_type='UI', context=".imagepaint_2d", category="")
class _draw_tool_settings_context_mode:
@staticmethod
- def VIEW(context, layout, _tool):
- tool_settings = context.tool_settings
- if tool_settings.use_uv_sculpt:
+ def UV(context, layout, tool):
+ if tool and tool.has_datablock:
if context.mode == 'EDIT_MESH':
+ tool_settings = context.tool_settings
uv_sculpt = tool_settings.uv_sculpt
brush = uv_sculpt.brush
if brush:
@@ -631,6 +612,32 @@ class _draw_tool_settings_context_mode:
class IMAGE_HT_header(Header):
bl_space_type = 'IMAGE_EDITOR'
+ @staticmethod
+ def draw_xform_template(layout, context):
+ sima = context.space_data
+ show_uvedit = sima.show_uvedit
+ show_maskedit = sima.show_maskedit
+
+ if show_uvedit or show_maskedit:
+ layout.prop(sima, "pivot_point", icon_only=True)
+
+ if show_uvedit:
+ tool_settings = context.tool_settings
+
+ # Snap.
+ row = layout.row(align=True)
+ row.prop(tool_settings, "use_snap", text="")
+ row.prop(tool_settings, "snap_uv_element", icon_only=True)
+ if tool_settings.snap_uv_element != 'INCREMENT':
+ row.prop(tool_settings, "snap_target", text="")
+
+ # Proportional Editing
+ row = layout.row(align=True)
+ row.prop(tool_settings, "use_proportional_edit", icon_only=True)
+ sub = row.row(align=True)
+ sub.active = tool_settings.use_proportional_edit
+ sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
+
def draw(self, context):
layout = self.layout
@@ -638,12 +645,13 @@ class IMAGE_HT_header(Header):
ima = sima.image
iuser = sima.image_user
tool_settings = context.tool_settings
+ show_region_tool_header = sima.show_region_tool_header
show_render = sima.show_render
show_uvedit = sima.show_uvedit
show_maskedit = sima.show_maskedit
- if not sima.show_region_tool_header:
+ if not show_region_tool_header:
layout.template_header()
if sima.mode != 'UV':
@@ -665,6 +673,9 @@ class IMAGE_HT_header(Header):
layout.separator_spacer()
+ if not show_region_tool_header:
+ IMAGE_HT_header.draw_xform_template(layout, context)
+
layout.template_ID(sima, "image", new="image.new", open="image.open")
if show_maskedit:
@@ -682,12 +693,6 @@ class IMAGE_HT_header(Header):
mesh = context.edit_object.data
layout.prop_search(mesh.uv_layers, "active", mesh, "uv_layers", text="")
- row = layout.row()
- row.popover(
- panel="IMAGE_PT_view_display",
- text="Display"
- )
-
if ima:
if ima.is_stereo_3d:
row = layout.row()
@@ -809,8 +814,9 @@ class IMAGE_PT_image_properties(Panel):
class IMAGE_PT_view_display(Panel):
bl_space_type = 'IMAGE_EDITOR'
- bl_region_type = 'HEADER'
+ bl_region_type = 'UI'
bl_label = "Display"
+ bl_category = "View"
@classmethod
def poll(cls, context):
@@ -839,9 +845,10 @@ class IMAGE_PT_view_display(Panel):
class IMAGE_PT_view_display_uv_edit_overlays(Panel):
bl_space_type = 'IMAGE_EDITOR'
- bl_region_type = 'HEADER'
+ bl_region_type = 'UI'
bl_label = "Overlays"
bl_parent_id = 'IMAGE_PT_view_display'
+ bl_category = "View"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
@@ -852,16 +859,15 @@ class IMAGE_PT_view_display_uv_edit_overlays(Panel):
def draw(self, context):
layout = self.layout
layout.use_property_split = True
+ layout.use_property_decorate = False
sima = context.space_data
uvedit = sima.uv_editor
col = layout.column()
- split = col.split(factor=0.6)
- split.prop(uvedit, "show_edges", text="Edges")
- split.prop(uvedit, "edge_display_type", text="")
-
+ col.prop(uvedit, "edge_display_type", text="Display As")
+ col.prop(uvedit, "show_edges", text="Edges")
col.prop(uvedit, "show_faces", text="Faces")
col = layout.column()
@@ -869,11 +875,12 @@ class IMAGE_PT_view_display_uv_edit_overlays(Panel):
col.prop(uvedit, "show_modified_edges", text="Modified")
-class IMAGE_PT_view_display_uv_edit_overlays_advanced(Panel):
+class IMAGE_PT_view_display_uv_edit_overlays_stretch(Panel):
bl_space_type = 'IMAGE_EDITOR'
- bl_region_type = 'HEADER'
- bl_label = "Advanced"
+ bl_region_type = 'UI'
+ bl_label = "Stretching"
bl_parent_id = 'IMAGE_PT_view_display_uv_edit_overlays'
+ bl_category = "View"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
@@ -881,6 +888,11 @@ class IMAGE_PT_view_display_uv_edit_overlays_advanced(Panel):
sima = context.space_data
return (sima and (sima.show_uvedit))
+ def draw_header(self, context):
+ sima = context.space_data
+ uvedit = sima.uv_editor
+ self.layout.prop(uvedit, "show_stretch", text="")
+
def draw(self, context):
layout = self.layout
layout.use_property_split = True
@@ -888,12 +900,8 @@ class IMAGE_PT_view_display_uv_edit_overlays_advanced(Panel):
sima = context.space_data
uvedit = sima.uv_editor
- col = layout.column()
- col.prop(uvedit, "show_stretch", text="Stretch")
-
- sub = col.column()
- sub.active = uvedit.show_stretch
- sub.prop(uvedit, "display_stretch_type", text="Type")
+ layout.active = uvedit.show_stretch
+ layout.prop(uvedit, "display_stretch_type", text="Type")
class IMAGE_UL_render_slots(UIList):
@@ -939,7 +947,7 @@ class IMAGE_PT_render_slots(Panel):
class IMAGE_PT_paint(Panel, ImagePaintPanel):
bl_label = "Brush"
bl_context = ".paint_common_2d"
- bl_category = "Tools"
+ bl_category = "Tool"
def draw(self, context):
layout = self.layout
@@ -958,6 +966,7 @@ class IMAGE_PT_paint(Panel, ImagePaintPanel):
class IMAGE_PT_paint_color(Panel, ImagePaintPanel):
+ bl_category = "Tool"
bl_context = ".paint_common_2d"
bl_parent_id = "IMAGE_PT_paint"
bl_label = "Color Picker"
@@ -981,6 +990,7 @@ class IMAGE_PT_paint_color(Panel, ImagePaintPanel):
class IMAGE_PT_paint_swatches(Panel, ImagePaintPanel):
+ bl_category = "Tool"
bl_context = ".paint_common_2d"
bl_parent_id = "IMAGE_PT_paint"
bl_label = "Color Palette"
@@ -1004,6 +1014,7 @@ class IMAGE_PT_paint_swatches(Panel, ImagePaintPanel):
class IMAGE_PT_paint_gradient(Panel, ImagePaintPanel):
+ bl_category = "Tool"
bl_context = ".paint_common_2d"
bl_parent_id = "IMAGE_PT_paint"
bl_label = "Gradient"
@@ -1035,6 +1046,7 @@ class IMAGE_PT_paint_gradient(Panel, ImagePaintPanel):
class IMAGE_PT_paint_clone(Panel, ImagePaintPanel):
+ bl_category = "Tool"
bl_context = ".paint_common_2d"
bl_parent_id = "IMAGE_PT_paint"
bl_label = "Clone from Image/UV Map"
@@ -1062,6 +1074,7 @@ class IMAGE_PT_paint_clone(Panel, ImagePaintPanel):
class IMAGE_PT_paint_options(Panel, ImagePaintPanel):
+ bl_category = "Tool"
bl_context = ".paint_common_2d"
bl_parent_id = "IMAGE_PT_paint"
bl_label = "Options"
@@ -1090,7 +1103,7 @@ class IMAGE_PT_tools_brush_display(BrushButtonsPanel, Panel):
bl_label = "Display"
bl_context = ".paint_common_2d"
bl_options = {'DEFAULT_CLOSED'}
- bl_category = "Options"
+ bl_category = "Tool"
def draw(self, context):
layout = self.layout
@@ -1144,6 +1157,7 @@ class IMAGE_PT_tools_brush_display_show_brush(BrushButtonsPanel, Panel):
bl_context = ".paint_common_2d" # dot on purpose (access from topbar)
bl_label = "Show Brush"
bl_parent_id = "IMAGE_PT_tools_brush_display"
+ bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
def draw_header(self, context):
@@ -1177,6 +1191,7 @@ class IMAGE_PT_tools_brush_display_custom_icon(BrushButtonsPanel, Panel):
bl_context = ".paint_common_2d" # dot on purpose (access from topbar)
bl_label = "Custom Icon"
bl_parent_id = "IMAGE_PT_tools_brush_display"
+ bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
def draw_header(self, context):
@@ -1202,8 +1217,8 @@ class IMAGE_PT_tools_brush_display_custom_icon(BrushButtonsPanel, Panel):
class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
bl_label = "Texture"
bl_context = ".paint_common_2d"
+ bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
- bl_category = "Tools"
def draw(self, context):
layout = self.layout
@@ -1220,8 +1235,8 @@ class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
bl_label = "Texture Mask"
bl_context = ".paint_common_2d"
+ bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
- bl_category = "Tools"
def draw(self, context):
layout = self.layout
@@ -1238,8 +1253,8 @@ class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
class IMAGE_PT_paint_stroke(BrushButtonsPanel, Panel):
bl_label = "Stroke"
bl_context = ".paint_common_2d"
+ bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
- bl_category = "Tools"
def draw(self, context):
layout = self.layout
@@ -1288,6 +1303,7 @@ class IMAGE_PT_paint_stroke_smooth_stroke(BrushButtonsPanel, Panel):
bl_context = ".paint_common_2d" # dot on purpose (access from topbar)
bl_label = "Smooth Stroke"
bl_parent_id = "IMAGE_PT_paint_stroke"
+ bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
@@ -1320,8 +1336,8 @@ class IMAGE_PT_paint_stroke_smooth_stroke(BrushButtonsPanel, Panel):
class IMAGE_PT_paint_curve(BrushButtonsPanel, Panel):
bl_label = "Falloff"
bl_context = ".paint_common_2d"
+ bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
- bl_category = "Tools"
def draw(self, context):
layout = self.layout
@@ -1342,9 +1358,9 @@ class IMAGE_PT_paint_curve(BrushButtonsPanel, Panel):
class IMAGE_PT_tools_imagepaint_symmetry(BrushButtonsPanel, Panel):
- bl_category = "Tools"
bl_context = ".imagepaint_2d"
bl_label = "Tiling"
+ bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
@@ -1359,53 +1375,33 @@ class IMAGE_PT_tools_imagepaint_symmetry(BrushButtonsPanel, Panel):
row.prop(ipaint, "tile_y", text="Y", toggle=True)
-class IMAGE_PT_uv_sculpt_curve(Panel):
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
+class IMAGE_PT_uv_sculpt_brush(Panel):
+ bl_space_type = 'IMAGE_EDITOR'
+ bl_region_type = 'UI'
bl_context = ".uv_sculpt" # dot on purpose (access from topbar)
- bl_category = "Options"
- bl_label = "UV Sculpt Curve"
- bl_options = {'DEFAULT_CLOSED'}
+ bl_category = "Tool"
+ bl_label = "Brush"
@classmethod
def poll(cls, context):
- return (context.uv_sculpt_object is not None)
+ sima = context.space_data
+ # TODO(campbell): nicer way to check if we're in uv sculpt mode.
+ if sima and sima.show_uvedit:
+ from .space_toolsystem_common import ToolSelectPanelHelper
+ tool = ToolSelectPanelHelper.tool_active_from_context(context)
+ if tool.has_datablock:
+ return True
+ return False
def draw(self, context):
+ from .properties_paint_common import UnifiedPaintPanel
layout = self.layout
tool_settings = context.tool_settings
uvsculpt = tool_settings.uv_sculpt
- brush = uvsculpt.brush
-
- layout.template_curve_mapping(brush, "curve")
-
- row = layout.row(align=True)
- row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
- row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
- row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
- row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
- row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
- row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
-
-class IMAGE_PT_uv_sculpt(Panel):
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = ".uv_sculpt" # dot on purpose (access from topbar)
- bl_category = "Options"
- bl_label = "UV Sculpt"
-
- @classmethod
- def poll(cls, context):
- return (context.uv_sculpt_object is not None)
-
- def draw(self, context):
- from .properties_paint_common import UnifiedPaintPanel
- layout = self.layout
+ layout.template_ID(uvsculpt, "brush")
- tool_settings = context.tool_settings
- uvsculpt = tool_settings.uv_sculpt
brush = uvsculpt.brush
if not self.is_popover:
@@ -1424,13 +1420,43 @@ class IMAGE_PT_uv_sculpt(Panel):
col.prop(tool_settings, "uv_sculpt_lock_borders")
col.prop(tool_settings, "uv_sculpt_all_islands")
- col.prop(tool_settings, "uv_sculpt_tool")
- if tool_settings.uv_sculpt_tool == 'RELAX':
- col.prop(tool_settings, "uv_relax_method")
+ if brush:
+ if brush.uv_sculpt_tool == 'RELAX':
+ col.prop(tool_settings, "uv_relax_method")
col.prop(uvsculpt, "show_brush")
+class IMAGE_PT_uv_sculpt_curve(Panel):
+ bl_space_type = 'IMAGE_EDITOR'
+ bl_region_type = 'UI'
+ bl_context = ".uv_sculpt" # dot on purpose (access from topbar)
+ bl_category = "Tool"
+ bl_label = "Falloff"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ poll = IMAGE_PT_uv_sculpt_brush.poll
+
+ def draw(self, context):
+ layout = self.layout
+
+ tool_settings = context.tool_settings
+ uvsculpt = tool_settings.uv_sculpt
+ brush = uvsculpt.brush
+
+ if brush is not None:
+ layout.template_curve_mapping(brush, "curve")
+
+ row = layout.row(align=True)
+ row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
+ row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
+ row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
+ row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
+ row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
+ row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
+
+
+
class ImageScopesPanel:
@classmethod
def poll(cls, context):
@@ -1548,7 +1574,7 @@ class IMAGE_PT_scope_sample(ImageScopesPanel, Panel):
class IMAGE_PT_uv_cursor(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
- bl_category = "Image"
+ bl_category = "View"
bl_label = "2D Cursor"
@classmethod
@@ -1572,7 +1598,7 @@ class IMAGE_PT_uv_cursor(Panel):
class IMAGE_PT_grease_pencil(AnnotationDataPanel, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
- bl_category = "Image"
+ bl_category = "View"
# NOTE: this is just a wrapper around the generic GP Panel.
@@ -1588,7 +1614,6 @@ classes = (
IMAGE_MT_image_invert,
IMAGE_MT_uvs,
IMAGE_MT_uvs_showhide,
- IMAGE_MT_uvs_proportional,
IMAGE_MT_uvs_transform,
IMAGE_MT_uvs_snap,
IMAGE_MT_uvs_mirror,
@@ -1600,6 +1625,7 @@ classes = (
IMAGE_HT_tool_header,
IMAGE_HT_header,
MASK_MT_editor_menus,
+ IMAGE_PT_active_tool,
IMAGE_PT_mask,
IMAGE_PT_mask_layers,
IMAGE_PT_mask_display,
@@ -1610,7 +1636,7 @@ classes = (
IMAGE_PT_render_slots,
IMAGE_PT_view_display,
IMAGE_PT_view_display_uv_edit_overlays,
- IMAGE_PT_view_display_uv_edit_overlays_advanced,
+ IMAGE_PT_view_display_uv_edit_overlays_stretch,
IMAGE_PT_paint,
IMAGE_PT_paint_color,
IMAGE_PT_paint_swatches,
@@ -1626,7 +1652,7 @@ classes = (
IMAGE_PT_tools_brush_display_show_brush,
IMAGE_PT_tools_brush_display_custom_icon,
IMAGE_PT_tools_imagepaint_symmetry,
- IMAGE_PT_uv_sculpt,
+ IMAGE_PT_uv_sculpt_brush,
IMAGE_PT_uv_sculpt_curve,
IMAGE_PT_view_histogram,
IMAGE_PT_view_waveform,
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 87ebf365a1e..7f54276c7e5 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -125,8 +125,8 @@ class SEQUENCER_HT_header(Header):
# Proportional editing
if gpd and gpd.use_stroke_edit_mode:
row = layout.row(align=True)
- row.prop(tool_settings, "proportional_edit", icon_only=True)
- if tool_settings.proportional_edit != 'DISABLED':
+ row.prop(tool_settings, "use_proportional_edit", icon_only=True)
+ if tool_settings.use_proportional_edit:
row.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
@@ -159,6 +159,25 @@ class SEQUENCER_MT_view_toggle(Menu):
layout.operator("sequencer.view_toggle").type = 'SEQUENCER_PREVIEW'
+class SEQUENCER_MT_view_cache(Menu):
+ bl_label = "Cache"
+
+ def draw(self, context):
+ layout = self.layout
+
+ ed = context.scene.sequence_editor
+ layout.prop(ed, "show_cache")
+ layout.separator()
+
+ col = layout.column()
+ col.enabled = ed.show_cache
+
+ col.prop(ed, "show_cache_final_out")
+ col.prop(ed, "show_cache_raw")
+ col.prop(ed, "show_cache_preprocessed")
+ col.prop(ed, "show_cache_composite")
+
+
class SEQUENCER_MT_view(Menu):
bl_label = "View"
@@ -212,6 +231,7 @@ class SEQUENCER_MT_view(Menu):
layout.prop(st, "show_frame_indicator")
layout.prop(st, "show_strip_offset")
layout.prop(st, "show_marker_lines")
+ layout.menu("SEQUENCER_MT_view_cache")
layout.prop_menu_enum(st, "waveform_display_type")
@@ -1145,9 +1165,29 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel):
layout.prop(strip, "use_float", text="Convert to Float")
+class SEQUENCER_PT_cache_settings(SequencerButtonsPanel, Panel):
+ bl_label = "Cache Settings"
+ bl_category = "Proxy & Cache"
+
+ @classmethod
+ def poll(cls, context):
+ return cls.has_sequencer(context)
+
+ def draw(self, context):
+ layout = self.layout
+ ed = context.scene.sequence_editor
+
+ layout.prop(ed, "use_cache_raw")
+ layout.prop(ed, "use_cache_preprocessed")
+ layout.prop(ed, "use_cache_composite")
+ layout.prop(ed, "use_cache_final")
+ layout.separator()
+ layout.prop(ed, "recycle_max_cost")
+
+
class SEQUENCER_PT_proxy_settings(SequencerButtonsPanel, Panel):
- bl_label = "Proxy settings"
- bl_category = "Proxy"
+ bl_label = "Proxy Settings"
+ bl_category = "Proxy & Cache"
@classmethod
def poll(cls, context):
return cls.has_sequencer(context)
@@ -1168,8 +1208,8 @@ class SEQUENCER_PT_proxy_settings(SequencerButtonsPanel, Panel):
class SEQUENCER_PT_strip_proxy(SequencerButtonsPanel, Panel):
- bl_label = "Strip Proxy/Timecode"
- bl_category = "Proxy"
+ bl_label = "Strip Proxy & Timecode"
+ bl_category = "Proxy & Cache"
@classmethod
def poll(cls, context):
@@ -1225,8 +1265,33 @@ class SEQUENCER_PT_strip_proxy(SequencerButtonsPanel, Panel):
col.prop(proxy, "timecode")
+class SEQUENCER_PT_strip_cache(SequencerButtonsPanel, Panel):
+ bl_label = "Strip Cache"
+ bl_category = "Proxy & Cache"
+
+ @classmethod
+ def poll(cls, context):
+ if not cls.has_sequencer(context):
+ return False
+ if act_strip(context) is not None:
+ return True
+
+ def draw_header(self, context):
+ strip = act_strip(context)
+ self.layout.prop(strip, "override_cache_settings", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ strip = act_strip(context)
+ layout.active = strip.override_cache_settings
+
+ layout.prop(strip, "use_cache_raw")
+ layout.prop(strip, "use_cache_preprocessed")
+ layout.prop(strip, "use_cache_composite")
+
+
class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, Panel):
- bl_label = "Scene Preview/Render"
+ bl_label = "Scene Shading"
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
bl_category = "Strip"
@@ -1239,11 +1304,8 @@ class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, Panel):
col = layout.column()
col.prop(render, "sequencer_gl_preview", text="")
- row = col.row()
- row.active = render.sequencer_gl_preview == 'SOLID'
- row.prop(render, "use_sequencer_gl_textured_solid")
-
- col.prop(render, "use_sequencer_gl_dof")
+ if render.sequencer_gl_preview in ['SOLID', 'WIREFRAME']:
+ col.prop(render, "use_sequencer_override_scene_strip")
class SEQUENCER_PT_view(SequencerButtonsPanel_Output, Panel):
@@ -1411,6 +1473,7 @@ classes = (
SEQUENCER_HT_header,
SEQUENCER_MT_editor_menus,
SEQUENCER_MT_view,
+ SEQUENCER_MT_view_cache,
SEQUENCER_MT_view_toggle,
SEQUENCER_MT_select,
SEQUENCER_MT_marker,
@@ -1430,8 +1493,10 @@ classes = (
SEQUENCER_PT_scene,
SEQUENCER_PT_mask,
SEQUENCER_PT_filter,
+ SEQUENCER_PT_cache_settings,
SEQUENCER_PT_proxy_settings,
SEQUENCER_PT_strip_proxy,
+ SEQUENCER_PT_strip_cache,
SEQUENCER_PT_preview,
SEQUENCER_PT_view,
SEQUENCER_PT_view_safe_areas,
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index aa9e0bf979f..71354f9875d 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -544,23 +544,37 @@ class ToolSelectPanelHelper:
self.draw_cls(self.layout, context)
@staticmethod
+ def _tool_key_from_context(context):
+ space_data = context.space_data
+ space_type = space_data.type
+ if space_type == 'VIEW_3D':
+ return space_type, context.mode
+ elif space_type == 'IMAGE_EDITOR':
+ return space_type, space_data.mode
+ elif space_type == 'NODE_EDITOR':
+ return space_type, None
+ else:
+ return None, None
+
+ @staticmethod
def tool_active_from_context(context):
- # BAD DESIGN WARNING: last used tool
- workspace = context.workspace
- space_type = workspace.tools_space_type
- mode = workspace.tools_mode
- return ToolSelectPanelHelper._tool_active_from_context(context, space_type, mode)
+ space_type = context.space_data.type
+ return ToolSelectPanelHelper._tool_active_from_context(context, space_type)
@staticmethod
def draw_active_tool_header(
context, layout,
*,
show_tool_name=False,
+ tool_key=None,
):
- # BAD DESIGN WARNING: last used tool
- workspace = context.workspace
- space_type = workspace.tools_space_type
- mode = workspace.tools_mode
+ if tool_key is None:
+ space_type, mode = ToolSelectPanelHelper._tool_key_from_context(context)
+ else:
+ space_type, mode = tool_key
+
+ if space_type is None:
+ return None
item, tool, icon_value = ToolSelectPanelHelper._tool_get_active(context, space_type, mode, with_icon=True)
if item is None:
return None
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index edde8f54d6e..35a019b8edf 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1171,12 +1171,33 @@ class _defs_image_uv_sculpt:
@staticmethod
def generate_from_brushes(context):
+ def draw_cursor(context, _tool, xy):
+ from gpu_extras.presets import draw_circle_2d
+ tool_settings = context.tool_settings
+ uv_sculpt = tool_settings.uv_sculpt
+ if not uv_sculpt.show_brush:
+ return
+ ups = tool_settings.unified_paint_settings
+ if ups.use_unified_size:
+ radius = ups.size
+ else:
+ brush = tool_settings.uv_sculpt.brush
+ if brush is None:
+ return
+ radius = brush.size
+ draw_circle_2d(xy, (1.0,) * 4, radius, 32)
+
return generate_from_enum_ex(
context,
idname_prefix="builtin_brush.",
icon_prefix="brush.uv_sculpt.",
- type=bpy.types.ToolSettings,
+ type=bpy.types.Brush,
attr="uv_sculpt_tool",
+ tooldef_keywords=dict(
+ operator="sculpt.uv_sculpt_stroke",
+ keymap="Image Editor Tool: Uv, Sculpt Stroke",
+ draw_cursor=draw_cursor,
+ ),
)
@@ -1664,7 +1685,6 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
_defs_annotate.poly,
_defs_annotate.eraser,
),
- _defs_view3d_generic.ruler,
)
_tools_gpencil_select = (
@@ -1683,6 +1703,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
*_tools_transform,
None,
*_tools_annotate,
+ _defs_view3d_generic.ruler,
)
_tools = {
@@ -1791,6 +1812,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
_defs_view3d_generic.cursor,
None,
*_tools_annotate,
+ _defs_view3d_generic.ruler,
],
'PARTICLE': [
*_tools_select,
@@ -1803,6 +1825,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
None,
_defs_sculpt.hide_border,
_defs_sculpt.mask_border,
+ None,
+ *_tools_annotate,
],
'PAINT_TEXTURE': [
_defs_texture_paint.generate_from_brushes,
@@ -1812,6 +1836,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
if _defs_texture_paint.poll_select_mask(context)
else ()
),
+ *_tools_annotate,
],
'PAINT_VERTEX': [
_defs_vertex_paint.generate_from_brushes,
@@ -1821,6 +1846,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
if _defs_vertex_paint.poll_select_mask(context)
else ()
),
+ *_tools_annotate,
],
'PAINT_WEIGHT': [
_defs_weight_paint.generate_from_brushes,
@@ -1842,6 +1868,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
if _defs_weight_paint.poll_select_mask(context)
else ()
),
+ *_tools_annotate,
],
'PAINT_GPENCIL': [
_defs_view3d_generic.cursor,
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index e75f4d1bb5d..3e7d6d98679 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -262,7 +262,7 @@ class TOPBAR_MT_file_new(Menu):
@staticmethod
def draw_ex(layout, _context, *, use_splash=False, use_more=False):
- layout.operator_context = 'EXEC_DEFAULT'
+ layout.operator_context = 'INVOKE_DEFAULT'
# Limit number of templates in splash screen, spill over into more menu.
paths = TOPBAR_MT_file_new.app_template_paths()
@@ -294,6 +294,8 @@ class TOPBAR_MT_file_new(Menu):
)
props.app_template = d
+ layout.operator_context = 'EXEC_DEFAULT'
+
if show_more:
layout.menu("TOPBAR_MT_templates_more", text="...")
@@ -557,7 +559,7 @@ class TOPBAR_MT_file_context_menu(Menu):
layout = self.layout
layout.operator_context = 'INVOKE_AREA'
- layout.operator("wm.read_homefile", text="New", icon='FILE_NEW')
+ layout.menu("TOPBAR_MT_file_new", text="New", icon='FILE_NEW')
layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
layout.separator()
@@ -609,6 +611,7 @@ class TOPBAR_PT_active_tool(Panel):
def draw(self, context):
layout = self.layout
+ tool_mode = context.mode
# Panel display of topbar tool settings.
# currently displays in tool settings, keep here since the same functionality is used for the topbar.
@@ -617,7 +620,12 @@ class TOPBAR_PT_active_tool(Panel):
layout.use_property_decorate = False
from .space_toolsystem_common import ToolSelectPanelHelper
- ToolSelectPanelHelper.draw_active_tool_header(context, layout, show_tool_name=True)
+ ToolSelectPanelHelper.draw_active_tool_header(
+ context,
+ layout,
+ show_tool_name=True,
+ tool_key=('VIEW_3D', tool_mode),
+ )
# Grease Pencil Object - Primitive curve
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 7cfcbfe133e..cb589feb57f 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -318,6 +318,7 @@ class USERPREF_PT_edit_objects_duplicate_data(PreferencePanel, Panel):
col.prop(edit, "use_duplicate_curve", text="Curve")
# col.prop(edit, "use_duplicate_fcurve", text="F-Curve")
col.prop(edit, "use_duplicate_light", text="Light")
+ col.prop(edit, "use_duplicate_lightprobe", text="Light Probe")
col = flow.column()
col.prop(edit, "use_duplicate_material", text="Material")
col.prop(edit, "use_duplicate_mesh", text="Mesh")
@@ -327,6 +328,7 @@ class USERPREF_PT_edit_objects_duplicate_data(PreferencePanel, Panel):
col.prop(edit, "use_duplicate_surface", text="Surface")
col.prop(edit, "use_duplicate_text", text="Text")
col.prop(edit, "use_duplicate_texture", text="Texture")
+ col.prop(edit, "use_duplicate_grease_pencil", text="Grease Pencil")
class USERPREF_PT_edit_cursor(PreferencePanel, Panel):
@@ -578,9 +580,8 @@ class USERPREF_PT_viewport_display(PreferencePanel, Panel):
flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
col = flow.column()
- col.prop(view, "gizmo_size", text="Gizmo Size")
- col.prop(view, "object_origin_size")
- col.separator()
+ col.prop(view, "gizmo_size")
+ col.prop(view, "lookdev_ball_size")
flow.separator()
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 93527f75f39..5ac9bdb2804 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -33,7 +33,6 @@ from .properties_grease_pencil_common import (
)
from bpy.app.translations import contexts as i18n_contexts
-
class VIEW3D_HT_tool_header(Header):
bl_space_type = 'VIEW_3D'
bl_region_type = "TOOL_HEADER"
@@ -43,145 +42,11 @@ class VIEW3D_HT_tool_header(Header):
layout.row(align=True).template_header()
- # mode_string = context.mode
- obj = context.active_object
- tool_settings = context.tool_settings
-
- object_mode = 'OBJECT' if obj is None else obj.mode
- has_pose_mode = (
- (object_mode == 'POSE') or
- (object_mode == 'WEIGHT_PAINT' and context.pose_object is not None)
- )
-
self.draw_tool_settings(context)
layout.separator_spacer()
- # Mode & Transform Settings
- scene = context.scene
-
- # Orientation
- if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL'} or has_pose_mode:
- orient_slot = scene.transform_orientation_slots[0]
- row = layout.row(align=True)
-
- sub = row.row()
- sub.ui_units_x = 4
- sub.prop_with_popover(
- orient_slot,
- "type",
- text="",
- panel="VIEW3D_PT_transform_orientations",
- )
-
- # Pivot
- if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL', 'SCULPT_GPENCIL'} or has_pose_mode:
- layout.prop_with_popover(
- tool_settings,
- "transform_pivot_point",
- text="",
- icon_only=True,
- panel="VIEW3D_PT_pivot_point",
- )
-
- # Snap
- show_snap = False
- if obj is None:
- show_snap = True
- else:
- if (object_mode not in {
- 'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT',
- 'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'
- }) or has_pose_mode:
- show_snap = True
- else:
-
- from .properties_paint_common import UnifiedPaintPanel
- paint_settings = UnifiedPaintPanel.paint_settings(context)
-
- if paint_settings:
- brush = paint_settings.brush
- if brush and brush.stroke_method == 'CURVE':
- show_snap = True
-
- if show_snap:
- snap_items = bpy.types.ToolSettings.bl_rna.properties["snap_elements"].enum_items
- snap_elements = tool_settings.snap_elements
- if len(snap_elements) == 1:
- text = ""
- for elem in snap_elements:
- icon = snap_items[elem].icon
- break
- else:
- text = "Mix"
- icon = 'NONE'
- del snap_items, snap_elements
-
- row = layout.row(align=True)
- row.prop(tool_settings, "use_snap", text="")
-
- sub = row.row(align=True)
- sub.popover(
- panel="VIEW3D_PT_snapping",
- icon=icon,
- text=text,
- )
-
- # Proportional editing
- gpd = context.gpencil_data
- 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)
- sub.active = tool_settings.proportional_edit != 'DISABLED'
- sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
-
- elif object_mode == 'OBJECT':
- row = layout.row(align=True)
- row.prop(tool_settings, "use_proportional_edit_objects", icon_only=True)
- 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)
-
- # grease pencil
- if object_mode == 'PAINT_GPENCIL':
- layout.prop_with_popover(
- tool_settings,
- "gpencil_stroke_placement_view3d",
- text="",
- panel="VIEW3D_PT_gpencil_origin",
- )
-
- if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL'}:
- layout.prop_with_popover(
- tool_settings.gpencil_sculpt,
- "lock_axis",
- text="",
- panel="VIEW3D_PT_gpencil_lock",
- )
-
- if object_mode == 'PAINT_GPENCIL':
- # FIXME: this is bad practice!
- # Tool options are to be displayed in the topbar.
- if context.workspace.tools.from_space_view3d_mode(object_mode).idname == "builtin_brush.Draw":
- settings = tool_settings.gpencil_sculpt.guide
- row = layout.row(align=True)
- row.prop(settings, "use_guide", text="", icon='GRID')
- sub = row.row(align=True)
- sub.active = settings.use_guide
- sub.popover(
- panel="VIEW3D_PT_gpencil_guide",
- text="Guides",
- )
+ VIEW3D_HT_header.draw_xform_template(layout, context)
layout.separator_spacer()
@@ -189,12 +54,15 @@ class VIEW3D_HT_tool_header(Header):
def draw_tool_settings(self, context):
layout = self.layout
+ tool_mode = context.mode
# Active Tool
# -----------
from .space_toolsystem_common import ToolSelectPanelHelper
- tool = ToolSelectPanelHelper.draw_active_tool_header(context, layout)
- tool_mode = context.mode if tool is None else tool.mode
+ tool = ToolSelectPanelHelper.draw_active_tool_header(
+ context, layout,
+ tool_key=('VIEW_3D', tool_mode),
+ )
# Object Mode Options
# -------------------
@@ -516,6 +384,143 @@ class _draw_tool_settings_context_mode:
class VIEW3D_HT_header(Header):
bl_space_type = 'VIEW_3D'
+ @staticmethod
+ def draw_xform_template(layout, context):
+ obj = context.active_object
+ object_mode = 'OBJECT' if obj is None else obj.mode
+ has_pose_mode = (
+ (object_mode == 'POSE') or
+ (object_mode == 'WEIGHT_PAINT' and context.pose_object is not None)
+ )
+
+ tool_settings = context.tool_settings
+
+ # Mode & Transform Settings
+ scene = context.scene
+
+ # Orientation
+ if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL'} or has_pose_mode:
+ orient_slot = scene.transform_orientation_slots[0]
+ row = layout.row(align=True)
+
+ sub = row.row()
+ sub.ui_units_x = 4
+ sub.prop_with_popover(
+ orient_slot,
+ "type",
+ text="",
+ panel="VIEW3D_PT_transform_orientations",
+ )
+
+ # Pivot
+ if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL', 'SCULPT_GPENCIL'} or has_pose_mode:
+ layout.prop_with_popover(
+ tool_settings,
+ "transform_pivot_point",
+ text="",
+ icon_only=True,
+ panel="VIEW3D_PT_pivot_point",
+ )
+
+ # Snap
+ show_snap = False
+ if obj is None:
+ show_snap = True
+ else:
+ if (object_mode not in {
+ 'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT',
+ 'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'
+ }) or has_pose_mode:
+ show_snap = True
+ else:
+
+ from .properties_paint_common import UnifiedPaintPanel
+ paint_settings = UnifiedPaintPanel.paint_settings(context)
+
+ if paint_settings:
+ brush = paint_settings.brush
+ if brush and brush.stroke_method == 'CURVE':
+ show_snap = True
+
+ if show_snap:
+ snap_items = bpy.types.ToolSettings.bl_rna.properties["snap_elements"].enum_items
+ snap_elements = tool_settings.snap_elements
+ if len(snap_elements) == 1:
+ text = ""
+ for elem in snap_elements:
+ icon = snap_items[elem].icon
+ break
+ else:
+ text = "Mix"
+ icon = 'NONE'
+ del snap_items, snap_elements
+
+ row = layout.row(align=True)
+ row.prop(tool_settings, "use_snap", text="")
+
+ sub = row.row(align=True)
+ sub.popover(
+ panel="VIEW3D_PT_snapping",
+ icon=icon,
+ text=text,
+ )
+
+ # Proportional editing
+ if object_mode in {'EDIT', 'PARTICLE_EDIT', 'SCULPT_GPENCIL', 'EDIT_GPENCIL', 'OBJECT'}:
+ row = layout.row(align=True)
+ kw = {}
+ if object_mode == 'OBJECT':
+ attr = "use_proportional_edit_objects"
+ else:
+ attr = "use_proportional_edit"
+
+ if tool_settings.use_proportional_connected:
+ kw["icon"] = 'PROP_CON'
+ elif tool_settings.use_proportional_projected:
+ kw["icon"] = 'PROP_PROJECTED'
+
+ row.prop(tool_settings, attr, icon_only=True, **kw)
+ sub = row.row(align=True)
+ sub.active = getattr(tool_settings, attr)
+ sub.prop_with_popover(
+ tool_settings,
+ "proportional_edit_falloff",
+ text="",
+ icon_only=True,
+ panel="VIEW3D_PT_proportional_edit",
+ )
+
+ # grease pencil
+ if object_mode == 'PAINT_GPENCIL':
+ layout.prop_with_popover(
+ tool_settings,
+ "gpencil_stroke_placement_view3d",
+ text="",
+ panel="VIEW3D_PT_gpencil_origin",
+ )
+
+ if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL'}:
+ layout.prop_with_popover(
+ tool_settings.gpencil_sculpt,
+ "lock_axis",
+ text="",
+ panel="VIEW3D_PT_gpencil_lock",
+ )
+
+ if object_mode == 'PAINT_GPENCIL':
+ # FIXME: this is bad practice!
+ # Tool options are to be displayed in the topbar.
+ if context.workspace.tools.from_space_view3d_mode(object_mode).idname == "builtin_brush.Draw":
+ settings = tool_settings.gpencil_sculpt.guide
+ row = layout.row(align=True)
+ row.prop(settings, "use_guide", text="", icon='GRID')
+ sub = row.row(align=True)
+ sub.active = settings.use_guide
+ sub.popover(
+ panel="VIEW3D_PT_gpencil_guide",
+ text="Guides",
+ )
+
def draw(self, context):
layout = self.layout
@@ -524,8 +529,9 @@ class VIEW3D_HT_header(Header):
shading = view.shading
# mode_string = context.mode
obj = context.active_object
+ show_region_tool_header = view.show_region_tool_header
- if not view.show_region_tool_header:
+ if not show_region_tool_header:
layout.row(align=True).template_header()
row = layout.row(align=True)
@@ -606,6 +612,11 @@ class VIEW3D_HT_header(Header):
layout.separator_spacer()
+ if not show_region_tool_header:
+ VIEW3D_HT_header.draw_xform_template(layout, context)
+
+ layout.separator_spacer()
+
# Viewport Settings
layout.popover(
panel="VIEW3D_PT_object_type_visibility",
@@ -2640,6 +2651,7 @@ class VIEW3D_MT_brush_paint_modes(Menu):
brush = settings.brush
layout.prop(brush, "use_paint_sculpt", text="Sculpt")
+ layout.prop(brush, "use_paint_uv_sculpt", text="UV Sculpt")
layout.prop(brush, "use_paint_vertex", text="Vertex Paint")
layout.prop(brush, "use_paint_weight", text="Weight Paint")
layout.prop(brush, "use_paint_image", text="Texture Paint")
@@ -3346,8 +3358,9 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
# Removal Operators
if selected_verts_len > 1:
- col.operator("mesh.merge", text="Merge Vertices...")
- col.operator("mesh.remove_doubles", text="Remove Double Vertices")
+ col.menu("VIEW3D_MT_edit_mesh_merge", text="Merge Vertices")
+ col.operator("mesh.split")
+ col.operator_menu_enum("mesh.separate", "type")
col.operator("mesh.dissolve_verts")
col.operator("mesh.delete", text="Delete Vertices").type = 'VERT'
@@ -3413,6 +3426,8 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
# Removal Operators
col.operator("mesh.unsubdivide")
+ col.operator("mesh.split")
+ col.operator_menu_enum("mesh.separate", "type")
col.operator("mesh.dissolve_edges")
col.operator("mesh.delete", text="Delete Edges").type = 'EDGE'
@@ -3457,6 +3472,8 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
# Removal Operators
col.operator("mesh.unsubdivide")
+ col.operator("mesh.split")
+ col.operator_menu_enum("mesh.separate", "type")
col.operator("mesh.dissolve_faces")
col.operator("mesh.delete", text="Delete Faces").type = 'FACE'
@@ -3550,8 +3567,7 @@ class VIEW3D_MT_edit_mesh_vertices(Menu):
layout.separator()
- layout.operator("mesh.merge", text="Merge Vertices")
- layout.operator("mesh.remove_doubles", text="Remove Double Vertices")
+ layout.menu("VIEW3D_MT_edit_mesh_merge", text="Merge Vertices")
layout.separator()
@@ -3740,32 +3756,28 @@ class VIEW3D_MT_edit_mesh_normals(Menu):
layout.separator()
- layout.operator("mesh.flip_normals")
+ layout.operator("mesh.flip_normals", text="Flip")
layout.operator("mesh.set_normals_from_faces", text="Set From Faces")
-
- layout.operator("transform.rotate_normal", text="Rotate Normal")
- layout.operator("mesh.point_normals", text="Point normals to target")
-
+ layout.operator("transform.rotate_normal", text="Rotate")
+ layout.operator("mesh.point_normals", text="Point to Target")
layout.operator("mesh.merge_normals", text="Merge")
layout.operator("mesh.split_normals", text="Split")
+ layout.operator("mesh.average_normals", text="Average")
- layout.operator("mesh.average_normals", text="Average Normals")
-
- layout.label(text="Normal Vector")
-
- layout.operator("mesh.normals_tools", text="Copy").mode = 'COPY'
- layout.operator("mesh.normals_tools", text="Paste").mode = 'PASTE'
+ layout.separator()
- layout.operator("mesh.normals_tools", text="Multiply").mode = 'MULTIPLY'
- layout.operator("mesh.normals_tools", text="Add").mode = 'ADD'
+ layout.operator("mesh.normals_tools", text="Copy Vectors").mode = 'COPY'
+ layout.operator("mesh.normals_tools", text="Paste Vectors").mode = 'PASTE'
+ layout.operator("mesh.normals_tools", text="Add Vectors").mode = 'ADD'
+ layout.operator("mesh.normals_tools", text="Multiply Vectors").mode = 'MULTIPLY'
- layout.operator("mesh.normals_tools", text="Reset").mode = 'RESET'
+ layout.operator("mesh.smoothen_normals", text="Smoothen Vectors")
+ layout.operator("mesh.normals_tools", text="Reset Vectors").mode = 'RESET'
- layout.operator("mesh.smoothen_normals", text="Smoothen")
+ layout.separator()
- layout.label(text="Face Strength")
- layout.operator("mesh.mod_weighted_strength", text="Face Select", icon='FACESEL').set = False
- layout.operator("mesh.mod_weighted_strength", text="Set Strength", icon='ADD').set = True
+ layout.operator("mesh.mod_weighted_strength", text="Get Face Strength").set = False
+ layout.operator("mesh.mod_weighted_strength", text="Set Face Strength").set = True
class VIEW3D_MT_edit_mesh_shading(Menu):
@@ -3845,6 +3857,19 @@ class VIEW3D_MT_edit_mesh_delete(Menu):
layout.operator("mesh.delete_edgeloop", text="Edge Loops")
+class VIEW3D_MT_edit_mesh_merge(Menu):
+ bl_label = "Merge"
+
+ def draw(self, _context):
+ layout = self.layout
+
+ layout.operator_enum("mesh.merge", "type")
+
+ layout.separator()
+
+ layout.operator("mesh.remove_doubles", text="By Distance")
+
+
class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
_operator_name = "mesh"
@@ -4634,6 +4659,26 @@ class VIEW3D_MT_proportional_editing_falloff_pie(Menu):
# ********** Panel **********
+class VIEW3D_PT_active_tool(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'UI'
+ bl_label = "Active Tool"
+ bl_category = "Tool"
+ # bl_context = ".active_tool" # dot on purpose (access from tool settings)
+
+ def draw(self, context):
+ layout = self.layout
+
+ # Panel display of topbar tool settings.
+ # currently displays in tool settings, keep here since the same functionality is used for the topbar.
+
+ layout.use_property_split = True
+ layout.use_property_decorate = False
+
+ from .space_toolsystem_common import ToolSelectPanelHelper
+ ToolSelectPanelHelper.draw_active_tool_header(context, layout, show_tool_name=True)
+
+
class VIEW3D_PT_view3d_properties(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
@@ -4736,7 +4781,7 @@ class VIEW3D_PT_collections(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "View"
- bl_label = "Collections Visibility"
+ bl_label = "Collections"
bl_options = {'DEFAULT_CLOSED'}
def _draw_collection(self, layout, view_layer, collection, index):
@@ -4787,9 +4832,6 @@ class VIEW3D_PT_collections(Panel):
layout = self.layout
layout.use_property_split = False
- layout.label(text="Collections Visibility")
- layout.column()
-
view_layer = context.view_layer
# We pass index 0 here beause the index is increased
# so the first real index is 1
@@ -5731,6 +5773,27 @@ class VIEW3D_PT_snapping(Panel):
row.prop(tool_settings, "use_snap_scale", text="Scale", toggle=True)
+class VIEW3D_PT_proportional_edit(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "Proportional Editing"
+ bl_ui_units_x = 8
+
+ def draw(self, context):
+ layout = self.layout
+ tool_settings = context.tool_settings
+ col = layout.column()
+
+ if context.mode != 'OBJECT':
+ col.prop(tool_settings, "use_proportional_connected")
+ sub = col.column()
+ sub.active = not tool_settings.use_proportional_connected
+ sub.prop(tool_settings, "use_proportional_projected")
+ col.separator()
+
+ col.prop(tool_settings, "proportional_edit_falloff", expand=True)
+
+
class VIEW3D_PT_transform_orientations(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
@@ -5988,7 +6051,7 @@ class VIEW3D_PT_view3d_stereo(Panel):
class VIEW3D_PT_context_properties(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
- bl_category = "View"
+ bl_category = "Item"
bl_label = "Properties"
bl_options = {'DEFAULT_CLOSED'}
@@ -6179,8 +6242,15 @@ class VIEW3D_PT_paint_vertex_context_menu(Panel):
def draw(self, context):
layout = self.layout
-
brush = context.tool_settings.vertex_paint.brush
+ capabilities = brush.vertex_paint_capabilities
+
+ if capabilities.has_color:
+ split = layout.split(factor=0.1)
+ UnifiedPaintPanel.prop_unified_color(split, context, brush, "color", text="")
+ UnifiedPaintPanel.prop_unified_color_picker(split, context, brush, "color", value_slider=True)
+ layout.prop(brush, "blend", text="")
+
UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True)
UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength")
@@ -6196,6 +6266,12 @@ class VIEW3D_PT_paint_texture_context_menu(Panel):
brush = context.tool_settings.image_paint.brush
capabilities = brush.image_paint_capabilities
+ if capabilities.has_color:
+ split = layout.split(factor=0.1)
+ UnifiedPaintPanel.prop_unified_color(split, context, brush, "color", text="")
+ UnifiedPaintPanel.prop_unified_color_picker(split, context, brush, "color", value_slider=True)
+ layout.prop(brush, "blend", text="")
+
if capabilities.has_radius:
UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True)
UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength")
@@ -6374,6 +6450,7 @@ classes = (
VIEW3D_MT_edit_mesh_weights,
VIEW3D_MT_edit_mesh_clean,
VIEW3D_MT_edit_mesh_delete,
+ VIEW3D_MT_edit_mesh_merge,
VIEW3D_MT_edit_mesh_showhide,
VIEW3D_MT_paint_gpencil,
VIEW3D_MT_assign_material,
@@ -6414,6 +6491,7 @@ classes = (
VIEW3D_MT_snap_pie,
VIEW3D_MT_orientations_pie,
VIEW3D_MT_proportional_editing_falloff_pie,
+ VIEW3D_PT_active_tool,
VIEW3D_PT_view3d_properties,
VIEW3D_PT_view3d_lock,
VIEW3D_PT_view3d_cursor,
@@ -6448,6 +6526,7 @@ classes = (
VIEW3D_PT_overlay_sculpt,
VIEW3D_PT_pivot_point,
VIEW3D_PT_snapping,
+ VIEW3D_PT_proportional_edit,
VIEW3D_PT_gpencil_origin,
VIEW3D_PT_gpencil_lock,
VIEW3D_PT_gpencil_guide,
diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc
index 4a7f26d2e18..e39b5686c82 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -158,7 +158,8 @@ static bool export_object(const ExportSettings *const settings,
if (settings->selected_only && !BASE_SELECTED(v3d, base)) {
return false;
}
- // FIXME Sybren: handle these cleanly (maybe just remove code), now using active scene layer instead.
+ // FIXME Sybren: handle these cleanly (maybe just remove code),
+ // now using active scene layer instead.
if (settings->visible_layers_only && !BASE_VISIBLE(v3d, base)) {
return false;
}
diff --git a/source/blender/alembic/intern/abc_exporter.h b/source/blender/alembic/intern/abc_exporter.h
index 6ed6a97f935..e6a7a3fc7f4 100644
--- a/source/blender/alembic/intern/abc_exporter.h
+++ b/source/blender/alembic/intern/abc_exporter.h
@@ -43,8 +43,8 @@ struct ExportSettings {
ExportSettings();
Scene *scene;
- ViewLayer *
- view_layer; // Scene layer to export; all its objects will be exported, unless selected_only=true
+ /** Scene layer to export; all its objects will be exported, unless selected_only=true. */
+ ViewLayer *view_layer;
Depsgraph *depsgraph;
SimpleLogger logger;
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index 36daa50e095..e437273c1be 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -364,9 +364,6 @@ void AbcObjectReader::addCacheModifier()
id_us_plus(&mcmd->cache_file->id);
BLI_strncpy(mcmd->object_path, m_iobject.getFullName().c_str(), FILE_MAX);
-
- mcmd->reader = reinterpret_cast<CacheReader *>(this);
- this->incref();
}
chrono_t AbcObjectReader::minTime() const
diff --git a/source/blender/alembic/intern/abc_util.cc b/source/blender/alembic/intern/abc_util.cc
index 380ceff80cf..2fc340f73ce 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -160,7 +160,8 @@ void create_swapped_rotation_matrix(float rot_x_mat[3][3],
rot_z_mat[1][1] = cos(rz);
}
-/* Convert matrix from Z=up to Y=up or vice versa. Use yup_mat = zup_mat for in-place conversion. */
+/* Convert matrix from Z=up to Y=up or vice versa.
+ * Use yup_mat = zup_mat for in-place conversion. */
void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMode mode)
{
float dst_rot[3][3], src_rot[3][3], dst_scale_mat[4][4];
@@ -378,11 +379,6 @@ ScopeTimer::~ScopeTimer()
/* ********************** */
-bool SimpleLogger::empty()
-{
- return ((size_t)m_stream.tellp()) == 0ul;
-}
-
std::string SimpleLogger::str() const
{
return m_stream.str();
diff --git a/source/blender/alembic/intern/abc_util.h b/source/blender/alembic/intern/abc_util.h
index 44ad4bca2f7..f7f662212fd 100644
--- a/source/blender/alembic/intern/abc_util.h
+++ b/source/blender/alembic/intern/abc_util.h
@@ -210,11 +210,6 @@ class SimpleLogger {
public:
/**
- * Check whether or not the SimpleLogger's stream is empty.
- */
- bool empty();
-
- /**
* Return a copy of the string contained in the SimpleLogger's stream.
*/
std::string str() const;
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index aac7a7f2d82..b502692d0e5 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -290,8 +290,9 @@ static void export_endjob(void *customdata)
BLI_delete(data->filename, false, false);
}
- if (!data->settings.logger.empty()) {
- std::cerr << data->settings.logger;
+ std::string log = data->settings.logger.str();
+ if (!log.empty()) {
+ std::cerr << log;
WM_report(RPT_ERROR, "Errors occurred during the export, look in the console to know more...");
}
@@ -626,6 +627,7 @@ struct ImportJobData {
char filename[1024];
ImportSettings settings;
+ ArchiveReader *archive;
std::vector<AbcObjectReader *> readers;
short *stop;
@@ -671,9 +673,9 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa
cache_file->is_sequence = data->settings.is_sequence;
cache_file->scale = data->settings.scale;
- cache_file->handle = handle_from_archive(archive);
- BLI_strncpy(cache_file->filepath, data->filename, 1024);
+ STRNCPY(cache_file->filepath, data->filename);
+ data->archive = archive;
data->settings.cache_file = cache_file;
*data->do_update = true;
@@ -854,6 +856,7 @@ static void import_endjob(void *user_data)
static void import_freejob(void *user_data)
{
ImportJobData *data = static_cast<ImportJobData *>(user_data);
+ delete data->archive;
delete data;
}
@@ -885,6 +888,7 @@ bool ABC_import(bContext *C,
job->settings.validate_meshes = validate_meshes;
job->error_code = ABC_NO_ERROR;
job->was_cancelled = false;
+ job->archive = NULL;
G.is_break = false;
diff --git a/source/blender/avi/AVI_avi.h b/source/blender/avi/AVI_avi.h
index 7b7f58506da..e14d947f5dd 100644
--- a/source/blender/avi/AVI_avi.h
+++ b/source/blender/avi/AVI_avi.h
@@ -63,12 +63,18 @@ typedef struct _AviMainHeader {
int MaxBytesPerSec; /* MaxBytesPerSec - approx bps system must handle */
int PaddingGranularity;
int Flags;
-#define AVIF_HASINDEX 0x00000010 /* had idx1 chunk */
-#define AVIF_MUSTUSEINDEX 0x00000020 /* must use idx1 chunk to determine order */
-#define AVIF_ISINTERLEAVED 0x00000100 /* AVI file is interleaved */
+
+ /** had idx1 chunk */
+#define AVIF_HASINDEX 0x00000010
+ /** must use idx1 chunk to determine order */
+#define AVIF_MUSTUSEINDEX 0x00000020
+ /** AVI file is interleaved */
+#define AVIF_ISINTERLEAVED 0x00000100
#define AVIF_TRUSTCKTYPE 0x00000800
-#define AVIF_WASCAPTUREFILE 0x00010000 /* specially allocated used for capturing real time video */
-#define AVIF_COPYRIGHTED 0x00020000 /* contains copyrighted data */
+ /** specially allocated used for capturing real time video */
+#define AVIF_WASCAPTUREFILE 0x00010000
+ /** contains copyrighted data */
+#define AVIF_COPYRIGHTED 0x00020000
int TotalFrames;
int InitialFrames; /* InitialFrames - initial frame before interleaving */
diff --git a/source/blender/avi/intern/avi_rgb32.c b/source/blender/avi/intern/avi_rgb32.c
index fae255d65ba..3efa4814c70 100644
--- a/source/blender/avi/intern/avi_rgb32.c
+++ b/source/blender/avi/intern/avi_rgb32.c
@@ -71,7 +71,7 @@ void *avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer,
*size = (size_t)movie->header->Height * (size_t)movie->header->Width * 4;
buf = imb_alloc_pixels(
- movie->header->Height, movie->header->Width, 3, sizeof(unsigned char), "torgb32buf");
+ movie->header->Height, movie->header->Width, 4, sizeof(unsigned char), "torgb32buf");
if (!buf) {
return NULL;
}
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index 60b27ead968..448bb0d621a 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -53,6 +53,9 @@ int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size
void BLF_unload(const char *name) ATTR_NONNULL();
void BLF_unload_id(int fontid);
+/* Check if font supports a particular glyph. */
+bool BLF_has_glyph(int fontid, unsigned int unicode);
+
/* Attach a file with metrics information from memory. */
void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size);
diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt
index e16ff10c76d..ba8697a44b6 100644
--- a/source/blender/blenfont/CMakeLists.txt
+++ b/source/blender/blenfont/CMakeLists.txt
@@ -25,11 +25,11 @@ set(INC
../blentranslation
../editors/include
../gpu
+ ../imbuf
../makesdna
../makesrna
- ../imbuf
- ../../../intern/guardedalloc
../../../intern/glew-mx
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index d16a4d7ed4d..793e9805899 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -188,6 +188,15 @@ int BLF_default(void)
return global_font_default;
}
+bool BLF_has_glyph(int fontid, unsigned int unicode)
+{
+ FontBLF *font = blf_get(fontid);
+ if (font) {
+ return FT_Get_Char_Index(font->face, unicode) != 0;
+ }
+ return false;
+}
+
int BLF_load(const char *name)
{
FontBLF *font;
diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c
index 2b34b1f8324..802f97fc5f5 100644
--- a/source/blender/blenfont/intern/blf_thumbs.c
+++ b/source/blender/blenfont/intern/blf_thumbs.c
@@ -107,8 +107,8 @@ void BLF_thumb_preview(const char *filename,
font->pos[1] -= font->glyph_cache->ascender * 1.1f;
- /* We fallback to default english strings in case not enough chars are available in current font
- * for given translated string (useful in non-latin i18n context, like chinese,
+ /* We fallback to default english strings in case not enough chars are available in current
+ * font for given translated string (useful in non-latin i18n context, like chinese,
* since many fonts will then show nothing but ugly 'missing char' in their preview).
* Does not handle all cases, but much better than nothing.
*/
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 4fc519ecd6d..f835f4332ed 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -134,8 +134,9 @@ struct DerivedMesh {
* \warning Typical access is done via #getLoopTriArray, #getNumLoopTri.
*/
struct {
- /* WARNING! swapping between array (ready-to-be-used data) and array_wip (where data is actually computed)
- * shall always be protected by same lock as one used for looptris computing. */
+ /* WARNING! swapping between array (ready-to-be-used data) and array_wip
+ * (where data is actually computed) shall always be protected by same
+ * lock as one used for looptris computing. */
struct MLoopTri *array, *array_wip;
int num;
int num_alloc;
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index 0503efb1661..583a90b2dee 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -95,7 +95,8 @@ void BKE_animdata_merge_copy(struct Main *bmain,
/* ************************************* */
/* KeyingSets API */
-/* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
+/* Used to create a new 'custom' KeyingSet for the user,
+ * that will be automatically added to the stack */
struct KeyingSet *BKE_keyingset_add(
struct ListBase *list, const char idname[], const char name[], short flag, short keyingflag);
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 267617e154f..b5da30e725d 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -144,8 +144,9 @@ void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph,
float outmat[4][4]);
void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[3][3], bool use_compat);
+void BKE_pchan_rot_to_mat3(const struct bPoseChannel *pchan, float mat[3][3]);
void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[4][4], bool use_comat);
-void BKE_pchan_to_mat4(struct bPoseChannel *pchan, float chan_mat[4][4]);
+void BKE_pchan_to_mat4(const struct bPoseChannel *pchan, float chan_mat[4][4]);
void BKE_pchan_calc_mat(struct bPoseChannel *pchan);
/* Simple helper, computes the offset bone matrix. */
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 2433b856697..e01f6a6b751 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -27,7 +27,7 @@
* \note Use #STRINGIFY() rather than defining with quotes.
*/
#define BLENDER_VERSION 280
-#define BLENDER_SUBVERSION 58
+#define BLENDER_SUBVERSION 60
/** Several breakages with 280, e.g. collections vs layers. */
#define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h
index 1d40ba0bc78..4b64b6fa269 100644
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@ -84,11 +84,12 @@ typedef struct BVHTreeFromMesh {
/**
* Builds a bvh tree where nodes are the relevant elements of the given mesh.
- * Configures BVHTreeFromMesh.
+ * Configures #BVHTreeFromMesh.
*
* The tree is build in mesh space coordinates, this means special care must be made on queries
* so that the coordinates and rays are first translated on the mesh local coordinates.
- * Reason for this is that bvh_from_mesh_* can use a cache in some cases and so it becomes possible to reuse a BVHTree.
+ * Reason for this is that bvh_from_mesh_* can use a cache in some cases and so it
+ * becomes possible to reuse a #BVHTree.
*
* free_bvhtree_from_mesh should be called when the tree is no longer needed.
*/
diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h
index b991ac24284..257975e3c17 100644
--- a/source/blender/blenkernel/BKE_cachefile.h
+++ b/source/blender/blenkernel/BKE_cachefile.h
@@ -29,8 +29,10 @@ extern "C" {
#endif
struct CacheFile;
+struct CacheReader;
struct Depsgraph;
struct Main;
+struct Object;
struct Scene;
void BKE_cachefiles_init(void);
@@ -52,24 +54,27 @@ void BKE_cachefile_make_local(struct Main *bmain,
struct CacheFile *cache_file,
const bool lib_local);
-void BKE_cachefile_reload(const struct Main *bmain, struct CacheFile *cache_file);
+void BKE_cachefile_reload(struct Depsgraph *depsgraph, struct CacheFile *cache_file);
-void BKE_cachefile_ensure_handle(const struct Main *bmain, struct CacheFile *cache_file);
-
-void BKE_cachefile_update_frame(struct Main *bmain,
- struct Depsgraph *depsgraph,
- struct Scene *scene,
- const float ctime,
- const float fps);
+void BKE_cachefile_eval(struct Main *bmain,
+ struct Depsgraph *depsgraph,
+ struct CacheFile *cache_file);
bool BKE_cachefile_filepath_get(const struct Main *bmain,
+ const struct Depsgraph *depsgrah,
const struct CacheFile *cache_file,
- float frame,
char r_filename[1024]);
-float BKE_cachefile_time_offset(struct CacheFile *cache_file, const float time, const float fps);
+float BKE_cachefile_time_offset(const struct CacheFile *cache_file,
+ const float time,
+ const float fps);
-void BKE_cachefile_clean(struct Main *bmain, struct CacheFile *cache_file);
+/* Modifiers and constraints open and free readers through these. */
+void BKE_cachefile_reader_open(struct CacheFile *cache_file,
+ struct CacheReader **reader,
+ struct Object *object,
+ const char *object_path);
+void BKE_cachefile_reader_free(struct CacheFile *cache_file, struct CacheReader **reader);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index 9ad3657284d..8fe3bd77a26 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -101,13 +101,22 @@ typedef struct bConstraintTypeInfo {
void (*id_looper)(struct bConstraint *con, ConstraintIDFunc func, void *userdata);
/** copy any special data that is allocated separately (optional) */
void (*copy_data)(struct bConstraint *con, struct bConstraint *src);
- /** set settings for data that will be used for bConstraint.data (memory already allocated using MEM_callocN) */
+ /**
+ * Set settings for data that will be used for #bConstraint.data
+ * (memory already allocated using #MEM_callocN).
+ */
void (*new_data)(void *cdata);
/* target handling function pointers */
- /** for multi-target constraints: return that list; otherwise make a temporary list (returns number of targets) */
+ /**
+ * For multi-target constraints: return that list;
+ * otherwise make a temporary list (returns number of targets).
+ */
int (*get_constraint_targets)(struct bConstraint *con, struct ListBase *list);
- /** for single-target constraints only: flush data back to source data, and the free memory used */
+ /**
+ * For single-target constraints only:
+ * flush data back to source data, and the free memory used.
+ */
void (*flush_constraint_targets)(struct bConstraint *con, struct ListBase *list, bool no_copy);
/* evaluation */
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index e4dc8ffae02..f354e5e6de3 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -113,7 +113,8 @@ bool CustomData_has_referenced(const struct CustomData *data);
* implemented for mloopuv/mloopcol, for now.*/
void CustomData_data_copy_value(int type, const void *source, void *dest);
-/* Same as above, but doing advanced mixing. Only available for a few types of data (like colors...). */
+/* Same as above, but doing advanced mixing.
+ * Only available for a few types of data (like colors...). */
void CustomData_data_mix_value(
int type, const void *source, void *dest, const int mixmode, const float mixfactor);
@@ -478,8 +479,8 @@ typedef void (*cd_datatransfer_interp)(const struct CustomDataTransferLayerMap *
const float mix_factor);
/**
- * Fake CD_LAYERS (those are actually 'real' data stored directly into elements' structs, or otherwise not (directly)
- * accessible to usual CDLayer system). */
+ * Fake CD_LAYERS (those are actually 'real' data stored directly into elements' structs,
+ * or otherwise not (directly) accessible to usual CDLayer system). */
enum {
CD_FAKE = 1 << 8,
@@ -531,23 +532,29 @@ typedef struct CustomDataTransferLayerMap {
int data_type;
int mix_mode;
float mix_factor;
- const float *
- mix_weights; /* If non-NULL, array of weights, one for each dest item, replaces mix_factor. */
-
- const void *
- data_src; /* Data source array (can be regular CD data, vertices/edges/etc., keyblocks...). */
- void *data_dst; /* Data dest array (same type as dat_src). */
- int data_src_n; /* Index to affect in data_src (used e.g. for vgroups). */
- int data_dst_n; /* Index to affect in data_dst (used e.g. for vgroups). */
- size_t elem_size; /* Size of one element of data_src/data_dst. */
-
- size_t data_size; /* Size of actual data we transfer. */
- size_t
- data_offset; /* Offset of actual data we transfer (in element contained in data_src/dst). */
- uint64_t data_flag; /* For bitflag transfer, flag(s) to affect in transferred data. */
-
- void *
- interp_data; /* Opaque pointer, to be used by specific interp callback (e.g. transformspace for normals). */
+ /** If non-NULL, array of weights, one for each dest item, replaces mix_factor. */
+ const float *mix_weights;
+
+ /** Data source array (can be regular CD data, vertices/edges/etc., keyblocks...). */
+ const void *data_src;
+ /** Data dest array (same type as dat_src). */
+ void *data_dst;
+ /** Index to affect in data_src (used e.g. for vgroups). */
+ int data_src_n;
+ /** Index to affect in data_dst (used e.g. for vgroups). */
+ int data_dst_n;
+ /** Size of one element of data_src/data_dst. */
+ size_t elem_size;
+
+ /** Size of actual data we transfer. */
+ size_t data_size;
+ /** Offset of actual data we transfer (in element contained in data_src/dst). */
+ size_t data_offset;
+ /** For bitflag transfer, flag(s) to affect in transferred data. */
+ uint64_t data_flag;
+
+ /** Opaque pointer, to be used by specific interp callback (e.g. transformspace for normals). */
+ void *interp_data;
cd_datatransfer_interp interp;
} CustomDataTransferLayerMap;
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h
index 510e989a087..fd7fa632999 100644
--- a/source/blender/blenkernel/BKE_deform.h
+++ b/source/blender/blenkernel/BKE_deform.h
@@ -109,7 +109,8 @@ void defvert_normalize_lock_map(struct MDeformVert *dvert,
const bool *lock_flags,
const int defbase_tot);
-/* Utilities to 'extract' a given vgroup into a simple float array, for verts, but also edges/polys/loops. */
+/* Utilities to 'extract' a given vgroup into a simple float array,
+ * for verts, but also edges/polys/loops. */
void BKE_defvert_extract_vgroup_to_vertweights(struct MDeformVert *dvert,
const int defgroup,
const int num_verts,
diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h
index 9f4f2862c95..c4f05d404ce 100644
--- a/source/blender/blenkernel/BKE_dynamicpaint.h
+++ b/source/blender/blenkernel/BKE_dynamicpaint.h
@@ -83,13 +83,11 @@ void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd);
void dynamicPaint_freeSurfaceData(struct DynamicPaintSurface *surface);
void dynamicPaint_cacheUpdateFrames(struct DynamicPaintSurface *surface);
-bool dynamicPaint_surfaceHasColorPreview(struct DynamicPaintSurface *surface);
bool dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface,
struct Object *ob,
int output);
void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface);
void dynamicPaintSurface_setUniqueName(struct DynamicPaintSurface *surface, const char *basename);
-void dynamicPaint_resetPreview(struct DynamicPaintCanvasSettings *canvas);
struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings *canvas);
/* image sequence baking */
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index 15b59993d77..94e8f4304b8 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -154,8 +154,14 @@ int get_effector_data(struct EffectorCache *eff,
int real_velocity);
/* required for particle_system.c */
-//void do_physical_effector(struct EffectorData *eff, struct EffectorPoint *point, float *total_force);
-//float effector_falloff(struct EffectorData *eff, struct EffectorPoint *point, struct EffectorWeights *weights);
+#if 0
+void do_physical_effector(struct EffectorData *eff,
+ struct EffectorPoint *point,
+ float *total_force);
+float effector_falloff(struct EffectorData *eff,
+ struct EffectorPoint *point,
+ struct EffectorWeights *weights);
+#endif
/* EffectedPoint->flag */
#define PE_WIND_AS_SPEED 1
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 5e45faf1d0b..c1232addee3 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -128,29 +128,38 @@ float evaluate_driver(struct PathResolvedRNA *anim_rna,
*/
typedef struct FModifierTypeInfo {
/* admin/ident */
- short type; /* FMODIFIER_TYPE_### */
- short size; /* size in bytes of the struct */
- short acttype; /* eFMI_Action_Types */
- short requires; /* eFMI_Requirement_Flags */
- char name[64]; /* name of modifier in interface */
- char structName[64]; /* name of struct for SDNA */
- uint storage_size; /* size of buffer that can be reused between time and value evaluation */
+ /** #FMODIFIER_TYPE_* */
+ short type;
+ /** size in bytes of the struct. */
+ short size;
+ /** #eFMI_Action_Types. */
+ short acttype;
+ /** #eFMI_Requirement_Flags. */
+ short requires;
+ /** name of modifier in interface. */
+ char name[64];
+ /** name of struct for SDNA. */
+ char structName[64];
+ /** Size of buffer that can be reused between time and value evaluation. */
+ uint storage_size;
/* data management function pointers - special handling */
- /* free any data that is allocated separately (optional) */
+ /** Free any data that is allocated separately (optional). */
void (*free_data)(struct FModifier *fcm);
- /* copy any special data that is allocated separately (optional) */
+ /** Copy any special data that is allocated separately (optional). */
void (*copy_data)(struct FModifier *fcm, const struct FModifier *src);
- /* set settings for data that will be used for FCuModifier.data (memory already allocated using MEM_callocN) */
+ /**
+ * Set settings for data that will be used for FCuModifier.data
+ * (memory already allocated using #MEM_callocN). */
void (*new_data)(void *mdata);
- /* verifies that the modifier settings are valid */
+ /** Verifies that the modifier settings are valid */
void (*verify_data)(struct FModifier *fcm);
/* evaluation */
- /* evaluate time that the modifier requires the F-Curve to be evaluated at */
+ /** Evaluate time that the modifier requires the F-Curve to be evaluated at */
float (*evaluate_modifier_time)(
struct FCurve *fcu, struct FModifier *fcm, float cvalue, float evaltime, void *storage);
- /* evaluate the modifier for the given time and 'accumulated' value */
+ /** Evaluate the modifier for the given time and 'accumulated' value */
void (*evaluate_modifier)(
struct FCurve *fcu, struct FModifier *fcm, float *cvalue, float evaltime, void *storage);
} FModifierTypeInfo;
@@ -223,7 +232,8 @@ int BKE_fcm_envelope_find_index(struct FCM_EnvelopeData *array,
/* ************** F-Curves API ******************** */
-/* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */
+/* threshold for binary-searching keyframes - threshold here should be good enough for now,
+ * but should become userpref */
#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */
/* -------- Data Management -------- */
@@ -243,7 +253,8 @@ struct FCurve *iter_step_fcurve(struct FCurve *fcu_iter, const char rna_path[]);
struct FCurve *id_data_find_fcurve(
ID *id, void *data, struct StructRNA *type, const char *prop_name, int index, bool *r_driven);
-/* Get list of LinkData's containing pointers to the F-Curves which control the types of data indicated
+/* Get list of LinkData's containing pointers to the F-Curves which control the types of data
+ * indicated
* e.g. numMatches = list_find_data_fcurves(matches, &act->curves, "pose.bones[", "MyFancyBone");
*/
int list_find_data_fcurves(ListBase *dst,
@@ -259,7 +270,8 @@ struct FCurve *rna_get_fcurve(struct PointerRNA *ptr,
struct bAction **r_action,
bool *r_driven,
bool *r_special);
-/* Same as above, but takes a context data, temp hack needed for complex paths like texture ones. */
+/* Same as above, but takes a context data,
+ * temp hack needed for complex paths like texture ones. */
struct FCurve *rna_get_fcurve_context_ui(struct bContext *C,
struct PointerRNA *ptr,
struct PropertyRNA *prop,
diff --git a/source/blender/blenkernel/BKE_gpencil_modifier.h b/source/blender/blenkernel/BKE_gpencil_modifier.h
index 128ff39de7a..4655abf6e02 100644
--- a/source/blender/blenkernel/BKE_gpencil_modifier.h
+++ b/source/blender/blenkernel/BKE_gpencil_modifier.h
@@ -38,8 +38,8 @@ struct Object;
struct Scene;
struct ViewLayer;
struct bArmature;
-struct
- bContext; /* NOTE: bakeModifier() - called from UI - needs to create new datablocks, hence the need for this */
+/* NOTE: bakeModifier() called from UI: needs to create new datablocks, hence the need for this. */
+struct bContext;
struct bGPDframe;
struct bGPDlayer;
struct bGPDstroke;
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 98fb59814fa..cc6c43c51f6 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -68,7 +68,6 @@ struct ViewLayer *BKE_view_layer_find_from_collection(const struct Scene *scene,
struct Base *BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob);
void BKE_view_layer_base_deselect_all(struct ViewLayer *view_layer);
-void BKE_view_layer_base_select(struct Base *selbase);
void BKE_view_layer_base_select_and_set_active(struct ViewLayer *view_layer, struct Base *selbase);
void BKE_view_layer_copy_data(struct Scene *scene_dst,
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 82ae832c73e..54b9fdac5b4 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -34,13 +34,13 @@ extern "C" {
* WARNING: description below is ideal goal, current status of naming does not yet
* fully follow it (this is WIP).
*
- * BKE_id_ should be used for rather high-level operations, that involve Main database and
- * relations with other IDs, and can be considered as 'safe' (as in, in themselves, they leave
- * affected IDs/Main in a consistent status).
+ * - BKE_id_ should be used for rather high-level operations, that involve Main database and
+ * relations with other IDs, and can be considered as 'safe'
+ * (as in, in themselves, they leave affected IDs/Main in a consistent status).
*
- * BKE_libblock_ should be used for lower level operations, that perform some parts of BKE_id_ ones,
- * but will generally not ensure caller that affected data is in a consistent state
- * by their own execution alone.
+ * - BKE_libblock_ should be used for lower level operations,
+ * that perform some parts of BKE_id_ ones, but will generally not ensure caller that affected
+ * data is in a consistent state by their own execution alone.
*
* Consequently, external code should not typically use BKE_libblock_ functions,
* except in some specific cases requiring advanced (and potentially dangerous) handling.
@@ -72,44 +72,47 @@ void *BKE_id_new_nomain(const short type, const char *name);
*/
enum {
/* *** Generic options (should be handled by all ID types copying, ID creation, etc.). *** */
- /* Create datablock outside of any main database - similar to 'localize' functions of materials etc. */
+ /** Create datablock outside of any main database -
+ * similar to 'localize' functions of materials etc. */
LIB_ID_CREATE_NO_MAIN = 1 << 0,
- /* Do not affect user refcount of datablocks used by new one (which also gets zero usercount then).
+ /** Do not affect user refcount of datablocks used by new one
+ * (which also gets zero usercount then).
* Implies LIB_ID_CREATE_NO_MAIN. */
LIB_ID_CREATE_NO_USER_REFCOUNT = 1 << 1,
- /* Assume given 'newid' already points to allocated memory for whole datablock (ID + data) - USE WITH CAUTION!
+ /** Assume given 'newid' already points to allocated memory for whole datablock
+ * (ID + data) - USE WITH CAUTION!
* Implies LIB_ID_CREATE_NO_MAIN. */
LIB_ID_CREATE_NO_ALLOCATE = 1 << 2,
- /* Do not tag new ID for update in depsgraph. */
+ /** Do not tag new ID for update in depsgraph. */
LIB_ID_CREATE_NO_DEG_TAG = 1 << 8,
/* *** Specific options to some ID types or usages. *** */
/* *** May be ignored by unrelated ID copying functions. *** */
- /* Object only, needed by make_local code. */
+ /** Object only, needed by make_local code. */
LIB_ID_COPY_NO_PROXY_CLEAR = 1 << 16,
- /* Do not copy preview data, when supported. */
+ /** Do not copy preview data, when supported. */
LIB_ID_COPY_NO_PREVIEW = 1 << 17,
- /* Copy runtime data caches. */
+ /** Copy runtime data caches. */
LIB_ID_COPY_CACHES = 1 << 18,
- /* Don't copy id->adt, used by ID datablock localization routines. */
+ /** Don't copy id->adt, used by ID datablock localization routines. */
LIB_ID_COPY_NO_ANIMDATA = 1 << 19,
- /* Mesh: Reference CD data layers instead of doing real copy - USE WITH CAUTION! */
+ /** Mesh: Reference CD data layers instead of doing real copy - USE WITH CAUTION! */
LIB_ID_COPY_CD_REFERENCE = 1 << 20,
/* *** XXX Hackish/not-so-nice specific behaviors needed for some corner cases. *** */
/* *** Ideally we should not have those, but we need them for now... *** */
- /* EXCEPTION! Deep-copy actions used by animdata of copied ID. */
+ /** EXCEPTION! Deep-copy actions used by animdata of copied ID. */
LIB_ID_COPY_ACTIONS = 1 << 24,
- /* Keep the library pointer when copying datablock outside of bmain. */
+ /** Keep the library pointer when copying datablock outside of bmain. */
LIB_ID_COPY_KEEP_LIB = 1 << 25,
- /* EXCEPTION! Deep-copy shapekeys used by copied obdata ID. */
+ /** EXCEPTION! Deep-copy shapekeys used by copied obdata ID. */
LIB_ID_COPY_SHAPEKEY = 1 << 26,
/* *** Helper 'defines' gathering most common flag sets. *** */
- /* Shapekeys are not real ID's, more like local data to geometry IDs... */
+ /** Shapekeys are not real ID's, more like local data to geometry IDs... */
LIB_ID_COPY_DEFAULT = LIB_ID_COPY_SHAPEKEY,
- /* Generate a local copy, outside of bmain, to work on (used by COW e.g.). */
+ /** Generate a local copy, outside of bmain, to work on (used by COW e.g.). */
LIB_ID_COPY_LOCALIZE = LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW | LIB_ID_COPY_CACHES,
};
diff --git a/source/blender/blenkernel/BKE_library_query.h b/source/blender/blenkernel/BKE_library_query.h
index caa36742f76..94e7830aabe 100644
--- a/source/blender/blenkernel/BKE_library_query.h
+++ b/source/blender/blenkernel/BKE_library_query.h
@@ -38,9 +38,12 @@ enum {
*/
IDWALK_CB_INDIRECT_USAGE = (1 << 2),
- /** That ID is used as mere sub-data by its owner
+ /**
+ * That ID is used as mere sub-data by its owner
* (only case currently: those f***ing nodetrees in materials etc.).
- * This means callback shall not *do* anything, only use this as informative data if it needs it. */
+ * This means callback shall not *do* anything,
+ * only use this as informative data if it needs it.
+ */
IDWALK_CB_PRIVATE = (1 << 3),
/** That ID is not really used by its owner, it's just an internal hint/helper.
diff --git a/source/blender/blenkernel/BKE_library_remap.h b/source/blender/blenkernel/BKE_library_remap.h
index da104c4c205..41ac8c8c8e6 100644
--- a/source/blender/blenkernel/BKE_library_remap.h
+++ b/source/blender/blenkernel/BKE_library_remap.h
@@ -29,29 +29,44 @@ extern "C" {
/* Also IDRemap->flag. */
enum {
- /* Do not remap indirect usages of IDs (that is, when user is some linked data). */
+ /** Do not remap indirect usages of IDs (that is, when user is some linked data). */
ID_REMAP_SKIP_INDIRECT_USAGE = 1 << 0,
- /* This flag should always be set, *except for 'unlink' scenarios* (only relevant when new_id == NULL).
- * Basically, when unset, NEVER_NULL ID usages will keep pointing to old_id, but (if needed) old_id user count
- * will still be decremented. This is mandatory for 'delete ID' case, but in all other situation this would lead
- * to invalid user counts! */
+ /**
+ * This flag should always be set, *except for 'unlink' scenarios*
+ * (only relevant when new_id == NULL).
+ * Basically, when unset, NEVER_NULL ID usages will keep pointing to old_id, but (if needed)
+ * old_id user count will still be decremented.
+ * This is mandatory for 'delete ID' case,
+ * but in all other situation this would lead to invalid user counts!
+ */
ID_REMAP_SKIP_NEVER_NULL_USAGE = 1 << 1,
- /* This tells the callback func to flag with LIB_DOIT all IDs using target one with a 'never NULL' pointer
- * (like e.g. Object->data). */
+ /**
+ * This tells the callback func to flag with #LIB_DOIT all IDs
+ * using target one with a 'never NULL' pointer (like e.g. #Object.data).
+ */
ID_REMAP_FLAG_NEVER_NULL_USAGE = 1 << 2,
- /* This tells the callback func to force setting IDs using target one with a 'never NULL' pointer to NULL.
- * WARNING! Use with extreme care, this will leave database in broken state and can cause crashes very easily! */
+ /**
+ * This tells the callback func to force setting IDs
+ * using target one with a 'never NULL' pointer to NULL.
+ * \warning Use with extreme care, this will leave database in broken state
+ * and can cause crashes very easily!
+ */
ID_REMAP_FORCE_NEVER_NULL_USAGE = 1 << 3,
- /* Do not consider proxy/_group pointers of local objects as indirect usages...
- * Our oh-so-beloved proxies again... Do not consider data used by local proxy object as indirect usage.
- * This is needed e.g. in reload scenario, since we have to ensure remapping of Armature data of local proxy
- * is also performed. Usual nightmare... */
+ /**
+ * Do not consider proxy/_group pointers of local objects as indirect usages...
+ * Our oh-so-beloved proxies again...
+ * Do not consider data used by local proxy object as indirect usage.
+ * This is needed e.g. in reload scenario,
+ * since we have to ensure remapping of Armature data of local proxy
+ * is also performed. Usual nightmare...
+ */
ID_REMAP_NO_INDIRECT_PROXY_DATA_USAGE = 1 << 4,
- /* Do not remap static override pointers. */
+ /** Do not remap static override pointers. */
ID_REMAP_SKIP_STATIC_OVERRIDE = 1 << 5,
};
-/* Note: Requiring new_id to be non-null, this *may* not be the case ultimately, but makes things simpler for now. */
+/* Note: Requiring new_id to be non-null, this *may* not be the case ultimately,
+ * but makes things simpler for now. */
void BKE_libblock_remap_locked(struct Main *bmain,
void *old_idv,
void *new_idv,
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index b8721f61371..1c987d5eb8e 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -57,7 +57,8 @@ typedef struct BlendThumbnail {
/* Structs caching relations between data-blocks in a given Main. */
typedef struct MainIDRelationsEntry {
struct MainIDRelationsEntry *next;
- /* WARNING! for user_to_used, that pointer is really an ID** one, but for used_to_user, it’s only an ID* one! */
+ /* WARNING! for user_to_used,
+ * that pointer is really an ID** one, but for used_to_user, it’s only an ID* one! */
struct ID **id_pointer;
int usage_flag; /* Using IDWALK_ enums, in BKE_library_query.h */
} MainIDRelationsEntry;
@@ -121,9 +122,11 @@ typedef struct Main {
ListBase cachefiles;
ListBase workspaces;
- /* Must be generated, used and freed by same code - never assume this is valid data unless you know
- * when, who and how it was created.
- * Used by code doing a lot of remapping etc. at once to speed things up. */
+ /**
+ * Must be generated, used and freed by same code - never assume this is valid data unless you
+ * know when, who and how it was created.
+ * Used by code doing a lot of remapping etc. at once to speed things up.
+ */
struct MainIDRelations *relations;
struct MainLock *lock;
@@ -165,7 +168,9 @@ struct GSet *BKE_main_gset_create(struct Main *bmain, struct GSet *gset);
} \
((void)0)
-/* DO NOT use break statement with that macro, use FOREACH_MAIN_LISTBASE and FOREACH_MAIN_LISTBASE_ID instead
+/**
+ * DO NOT use break statement with that macro,
+ * use #FOREACH_MAIN_LISTBASE and #FOREACH_MAIN_LISTBASE_ID instead
* if you need that kind of control flow. */
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id) \
{ \
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h
index 37c502b3b0c..9d8b9218a79 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -113,7 +113,7 @@ void free_matcopybuf(void);
void copy_matcopybuf(struct Main *bmain, struct Material *ma);
void paste_matcopybuf(struct Main *bmain, struct Material *ma);
-/* Evaluation. */
+/* Dependency graph evaluation. */
struct Depsgraph;
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index d4ad0e771d3..ecee00b1b3f 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -123,10 +123,12 @@ struct Mesh *BKE_mesh_new_nomain_from_template(const struct Mesh *me_src,
int loops_len,
int polys_len);
-/* Performs copy for use during evaluation, optional referencing original arrays to reduce memory. */
+/* Performs copy for use during evaluation,
+ * optional referencing original arrays to reduce memory. */
struct Mesh *BKE_mesh_copy_for_eval(struct Mesh *source, bool reference);
-/* These functions construct a new Mesh, contrary to BKE_mesh_from_nurbs which modifies ob itself. */
+/* These functions construct a new Mesh,
+ * contrary to BKE_mesh_from_nurbs which modifies ob itself. */
struct Mesh *BKE_mesh_new_nomain_from_curve(struct Object *ob);
struct Mesh *BKE_mesh_new_nomain_from_curve_displist(struct Object *ob, struct ListBase *dispbase);
@@ -214,8 +216,8 @@ struct Mesh *BKE_mesh_new_from_object(struct Depsgraph *depsgraph,
const bool calc_undeformed);
struct Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
struct Scene *scene,
- struct Object *ob,
- struct ModifierData *md,
+ struct Object *ob_eval,
+ struct ModifierData *md_eval,
int build_shapekey_layers);
/* Copies a nomain-Mesh into an existing Mesh. */
@@ -671,6 +673,7 @@ enum {
BKE_MESH_BATCH_DIRTY_ALL = 0,
BKE_MESH_BATCH_DIRTY_MAYBE_ALL,
BKE_MESH_BATCH_DIRTY_SELECT,
+ BKE_MESH_BATCH_DIRTY_SELECT_PAINT,
BKE_MESH_BATCH_DIRTY_SHADING,
BKE_MESH_BATCH_DIRTY_SCULPT_COORDS,
BKE_MESH_BATCH_DIRTY_UVEDIT_ALL,
diff --git a/source/blender/blenkernel/BKE_mesh_remap.h b/source/blender/blenkernel/BKE_mesh_remap.h
index 54f263a8bfb..36cc5bedb79 100644
--- a/source/blender/blenkernel/BKE_mesh_remap.h
+++ b/source/blender/blenkernel/BKE_mesh_remap.h
@@ -54,10 +54,12 @@ void BKE_mesh_remap_item_define_invalid(MeshPairRemap *map, const int index);
/* TODO:
* Add other 'from/to' mapping sources, like e.g. using an UVMap, etc.
- * http://blenderartists.org/forum/showthread.php?346458-Move-Vertices-to-the-location-of-the-Reference-Mesh-based-on-the-UV-Position
+ * https://blenderartists.org/t/619105
+ *
* We could also use similar topology mappings inside a same mesh
* (cf. Campbell's 'select face islands from similar topology' wip work).
- * Also, users will have to check, whether we can get rid of some modes here, not sure all will be useful!
+ * Also, users will have to check, whether we can get rid of some modes here,
+ * not sure all will be useful!
*/
enum {
MREMAP_USE_VERT = 1 << 4,
@@ -104,13 +106,15 @@ enum {
/* Nearest edge of nearest poly (using mid-point). */
MREMAP_MODE_EDGE_POLY_NEAREST = MREMAP_MODE_EDGE | MREMAP_USE_POLY | MREMAP_USE_NEAREST,
- /* Cast a set of rays from along dest edge, interpolating its vertices' normals, and use hit source edges. */
+ /* Cast a set of rays from along dest edge,
+ * interpolating its vertices' normals, and use hit source edges. */
MREMAP_MODE_EDGE_EDGEINTERP_VNORPROJ = MREMAP_MODE_EDGE | MREMAP_USE_VERT | MREMAP_USE_NORPROJ |
MREMAP_USE_INTERP,
/* ***** Target's loops ***** */
- /* Note: when islands are given to loop mapping func, all loops from the same destination face will always be mapped
- * to loops of source faces within a same island, regardless of mapping mode. */
+ /* Note: when islands are given to loop mapping func,
+ * all loops from the same destination face will always be mapped
+ * to loops of source faces within a same island, regardless of mapping mode. */
MREMAP_MODE_LOOP = 1 << 26,
/* Best normal-matching loop from nearest vert. */
@@ -138,7 +142,8 @@ enum {
/* Source poly from best normal-matching dest poly. */
MREMAP_MODE_POLY_NOR = MREMAP_MODE_POLY | MREMAP_USE_POLY | MREMAP_USE_NORMAL,
- /* Project dest poly onto source mesh using its normal, and use interpolation of all intersecting source polys. */
+ /* Project dest poly onto source mesh using its normal,
+ * and use interpolation of all intersecting source polys. */
MREMAP_MODE_POLY_POLYINTERP_PNORPROJ = MREMAP_MODE_POLY | MREMAP_USE_POLY | MREMAP_USE_NORPROJ |
MREMAP_USE_INTERP,
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 5b6f3cf17c4..a34f570ad1f 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -83,8 +83,8 @@ typedef enum {
*/
eModifierTypeFlag_RequiresOriginalData = (1 << 5),
- /* For modifiers that support pointcache, so we can check to see if it has files we need to deal with
- */
+ /* For modifiers that support pointcache,
+ * so we can check to see if it has files we need to deal with. */
eModifierTypeFlag_UsesPointCache = (1 << 6),
/* For physics modifiers, max one per type */
diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h
index 43ee284a201..9425f396bc5 100644
--- a/source/blender/blenkernel/BKE_movieclip.h
+++ b/source/blender/blenkernel/BKE_movieclip.h
@@ -116,7 +116,8 @@ bool BKE_movieclip_put_frame_if_possible(struct MovieClip *clip,
struct MovieClipUser *user,
struct ImBuf *ibuf);
-/* Evaluation. */
+/* Dependency graph evaluation. */
+
void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, struct MovieClip *clip);
void BKE_movieclip_eval_selection_update(struct Depsgraph *depsgraph, struct MovieClip *clip);
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 682d0b981fa..b760be29dae 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -218,7 +218,7 @@ typedef struct bNodeType {
/// Called when the node is updated in the editor.
void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node);
/// Check and update if internal ID data has changed.
- void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
+ void (*group_update_func)(struct bNodeTree *ntree, struct bNode *node);
/// Initialize a new node instance of this type after creation.
void (*initfunc)(struct bNodeTree *ntree, struct bNode *node);
@@ -395,15 +395,14 @@ struct bNode *ntreeFindType(const struct bNodeTree *ntree, int type);
bool ntreeHasType(const struct bNodeTree *ntree, int type);
bool ntreeHasTree(const struct bNodeTree *ntree, const struct bNodeTree *lookup);
void ntreeUpdateTree(struct Main *main, struct bNodeTree *ntree);
-/* XXX Currently each tree update call does call to ntreeVerifyNodes too.
- * Some day this should be replaced by a decent depsgraph automatism!
- */
-void ntreeVerifyNodes(struct Main *main, struct ID *id);
+void ntreeUpdateAllNew(struct Main *main);
+void ntreeUpdateAllUsers(struct Main *main, struct ID *id);
void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, int *totnodes);
-/* XXX old trees handle output flags automatically based on special output node types and last active selection.
- * new tree types have a per-output socket flag to indicate the final output to use explicitly.
+/* XXX old trees handle output flags automatically based on special output
+ * node types and last active selection.
+ * New tree types have a per-output socket flag to indicate the final output to use explicitly.
*/
void ntreeSetOutput(struct bNodeTree *ntree);
@@ -736,10 +735,10 @@ void node_type_label(
struct bNodeType *ntype,
void (*labelfunc)(struct bNodeTree *ntree, struct bNode *, char *label, int maxlen));
void node_type_update(struct bNodeType *ntype,
- void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node),
- void (*verifyfunc)(struct bNodeTree *ntree,
- struct bNode *node,
- struct ID *id));
+ void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node));
+void node_type_group_update(struct bNodeType *ntype,
+ void (*group_update_func)(struct bNodeTree *ntree,
+ struct bNode *node));
void node_type_exec(struct bNodeType *ntype,
NodeInitExecFunction initexecfunc,
@@ -777,16 +776,20 @@ void BKE_node_tree_unlink_id(ID *id, struct bNodeTree *ntree);
/* -------------------------------------------------------------------- */
/** \name Node Tree Iterator
*
- * Utility macro for visiting every node tree in the library data, including local bNodeTree blocks in other IDs.
- * This avoids the need for callback functions and allows executing code in a single inner code block.
+ * Utility macro for visiting every node tree in the library data,
+ * including local bNodeTree blocks in other IDs.
+ * This avoids the need for callback functions and allows executing code
+ * in a single inner code block.
*
* Variables:
*
- * nodetree: The actual bNodeTree data block.
- * Check nodetree->idname or nodetree->typeinfo to use only specific types.
+ * - nodetree:
+ * The actual bNodeTree data block.
+ * Check nodetree->idname or nodetree->typeinfo to use only specific types.
*
- * id: The owner of the bNodeTree data block.
- * Same as nodetree if it's a linkable node tree from the library.
+ * - id:
+ * The owner of the bNodeTree data block.
+ * Same as nodetree if it's a linkable node tree from the library.
*
* Examples:
*
@@ -854,7 +857,8 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree,
/* note: types are needed to restore callbacks, don't change values */
/* range 1 - 100 is reserved for common nodes */
-/* using toolbox, we add node groups by assuming the values below don't exceed NODE_GROUP_MENU for now */
+/* using toolbox, we add node groups by assuming the values below
+ * don't exceed NODE_GROUP_MENU for now. */
//#define SH_NODE_OUTPUT 1
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index ab7ca44368c..49b35bfccc1 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -153,7 +153,7 @@ struct Object *BKE_object_duplicate(struct Main *bmain,
void BKE_object_obdata_size_init(struct Object *ob, const float scale);
void BKE_object_scale_to_mat3(struct Object *ob, float mat[3][3]);
-void BKE_object_rot_to_mat3(struct Object *ob, float mat[3][3], bool use_drot);
+void BKE_object_rot_to_mat3(const struct Object *ob, float mat[3][3], bool use_drot);
void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], bool use_compat);
void BKE_object_to_mat3(struct Object *ob, float mat[3][3]);
void BKE_object_to_mat4(struct Object *ob, float mat[4][4]);
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index b0fbf07d467..56c92b731b7 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -145,6 +145,7 @@ void BKE_paint_runtime_init(const struct ToolSettings *ts, struct Paint *paint);
void BKE_paint_cavity_curve_preset(struct Paint *p, int preset);
eObjectMode BKE_paint_object_mode_from_paintmode(ePaintMode mode);
+bool BKE_paint_ensure_from_paintmode(struct Scene *sce, ePaintMode mode);
struct Paint *BKE_paint_get_active_from_paintmode(struct Scene *sce, ePaintMode mode);
const struct EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode);
const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index feb40d86151..f9bd722f8ba 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -201,21 +201,24 @@ typedef struct ParticleCollisionElement {
short inv_nor, inside;
} ParticleCollisionElement;
-/* container for moving data between deflet_particle and particle_intersect_face */
+/** Container for moving data between deflet_particle and particle_intersect_face. */
typedef struct ParticleCollision {
struct Object *current;
struct Object *hit;
struct Object *skip[PARTICLE_COLLISION_MAX_COLLISIONS + 1];
struct Object *emitter;
- struct CollisionModifierData *md; // collision modifier for current object;
+ /** Collision modifier for current object. */
+ struct CollisionModifierData *md;
- float f; // time factor of previous collision, needed for substracting face velocity
+ /** Time factor of previous collision, needed for substracting face velocity. */
+ float f;
float fac1, fac2;
float cfra, old_cfra;
- float original_ray_length; //original length of co2-co1, needed for collision time evaluation
+ /** Original length of co2-co1, needed for collision time evaluation. */
+ float original_ray_length;
int skip_count;
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 6df6d36aceb..9b15462de6b 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -40,6 +40,7 @@ struct MPoly;
struct MVert;
struct PBVH;
struct PBVHNode;
+struct GPU_PBVH_Buffers;
typedef struct PBVH PBVH;
typedef struct PBVHNode PBVHNode;
@@ -48,6 +49,21 @@ typedef struct {
float (*co)[3];
} PBVHProxyNode;
+typedef enum {
+ PBVH_Leaf = 1,
+
+ PBVH_UpdateNormals = 2,
+ PBVH_UpdateBB = 4,
+ PBVH_UpdateOriginalBB = 8,
+ PBVH_UpdateDrawBuffers = 16,
+ PBVH_UpdateRedraw = 32,
+
+ PBVH_RebuildDrawBuffers = 64,
+ PBVH_FullyHidden = 128,
+
+ PBVH_UpdateTopology = 256,
+} PBVHNodeFlags;
+
/* Callbacks */
/* returns 1 if the search should continue from this node, 0 otherwise */
@@ -151,13 +167,15 @@ bool BKE_pbvh_node_find_nearest_to_ray(PBVH *bvh,
void BKE_pbvh_draw_cb(PBVH *bvh,
float (*planes)[4],
float (*fnors)[3],
- bool fast,
- bool wires,
- bool only_mask,
bool show_vcol,
- void (*draw_fn)(void *user_data, struct GPUBatch *batch),
+ void (*draw_fn)(void *user_data, struct GPU_PBVH_Buffers *buffers),
void *user_data);
+void BKE_pbvh_draw_debug_cb(
+ PBVH *bvh,
+ void (*draw_fn)(void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag),
+ void *user_data);
+
/* PBVH Access */
typedef enum {
PBVH_FACES,
@@ -202,21 +220,6 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *bvh,
/* Node Access */
-typedef enum {
- PBVH_Leaf = 1,
-
- PBVH_UpdateNormals = 2,
- PBVH_UpdateBB = 4,
- PBVH_UpdateOriginalBB = 8,
- PBVH_UpdateDrawBuffers = 16,
- PBVH_UpdateRedraw = 32,
-
- PBVH_RebuildDrawBuffers = 64,
- PBVH_FullyHidden = 128,
-
- PBVH_UpdateTopology = 256,
-} PBVHNodeFlags;
-
void BKE_pbvh_node_mark_update(PBVHNode *node);
void BKE_pbvh_node_mark_rebuild_draw(PBVHNode *node);
void BKE_pbvh_node_mark_redraw(PBVHNode *node);
@@ -400,8 +403,8 @@ void BKE_pbvh_node_get_bm_orco_data(PBVHNode *node,
bool BKE_pbvh_node_vert_update_check_any(PBVH *bvh, PBVHNode *node);
-//void BKE_pbvh_node_BB_reset(PBVHNode *node);
-//void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3]);
+// void BKE_pbvh_node_BB_reset(PBVHNode *node);
+// void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3]);
bool pbvh_has_mask(PBVH *bvh);
void pbvh_show_diffuse_color_set(PBVH *bvh, bool show_diffuse_color);
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index 8a8ae3e2566..6ce60081f5b 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -167,7 +167,8 @@ typedef struct PTCacheID {
void (*interpolate_extra_data)(
void *calldata, struct PTCacheMem *pm, float cfra, float cfra1, float cfra2);
- /* total number of simulated points (the cfra parameter is just for using same function pointer with totwrite) */
+ /* Total number of simulated points
+ * (the cfra parameter is just for using same function pointer with totwrite). */
int (*totpoint)(void *calldata, int cfra);
/* report error if number of points does not match */
void (*error)(void *calldata, const char *message);
@@ -265,8 +266,8 @@ typedef struct PTCacheEdit {
struct ParticleSystemModifierData *psmd;
struct ParticleSystemModifierData *psmd_eval;
struct KDTree_3d *emitter_field;
- float *
- emitter_cosnos; /* localspace face centers and normals (average of its verts), from the derived mesh */
+ /* Localspace face centers and normals (average of its verts), from the derived mesh. */
+ float *emitter_cosnos;
int *mirror_cache;
struct ParticleCacheKey **pathcache; /* path cache (runtime) */
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index 72bc95028da..c940e646d95 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -106,7 +106,8 @@ void BKE_rigidbody_remove_constraint(struct Scene *scene, struct Object *ob);
(rbo->flag & RBO_FLAG_DISABLED))) ? \
(0.0f) : \
(rbo->mass))
-/* get collision margin for Rigid Body Object, triangle mesh and cone shapes cannot embed margin, convex hull always uses custom margin */
+/* Get collision margin for Rigid Body Object, triangle mesh and cone shapes cannot embed margin,
+ * convex hull always uses custom margin. */
#define RBO_GET_MARGIN(rbo) \
((rbo->flag & RBO_FLAG_USE_MARGIN || rbo->shape == RB_SHAPE_CONVEXH || \
rbo->shape == RB_SHAPE_TRIMESH || rbo->shape == RB_SHAPE_CONE) ? \
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 6cd71604561..3b5db883cf3 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -102,7 +102,6 @@ int BKE_scene_base_iter_next(struct Depsgraph *depsgraph,
void BKE_scene_base_flag_to_objects(struct ViewLayer *view_layer);
void BKE_scene_object_base_flag_sync_from_base(struct Base *base);
-void BKE_scene_object_base_flag_sync_from_object(struct Base *base);
void BKE_scene_set_background(struct Main *bmain, struct Scene *sce);
struct Scene *BKE_scene_set_name(struct Main *bmain, const char *name);
@@ -241,6 +240,14 @@ void BKE_scene_cursor_quat_to_rot(struct View3DCursor *cursor,
const float quat[4],
bool use_compat);
+/* Dependency graph evaluation. */
+
+/* Evaluate parts of sequences which needs to be done as a part of a dependency graph evaluation.
+ * This does NOT include actual rendering of the strips, but rather makes them up-to-date for
+ * animation playback and makes them ready for the sequencer's rendering pipeline to render them.
+ */
+void BKE_scene_eval_sequencer_sequences(struct Depsgraph *depsgraph, struct Scene *scene);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 6a9711dd316..93c9c41e482 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -182,7 +182,8 @@ typedef struct ARegionType {
int prefsizex, prefsizey;
/* default keymaps to add */
int keymapflag;
- /* return without drawing. lock is set by region definition, and copied to do_lock by render. can become flag */
+ /* return without drawing.
+ * lock is set by region definition, and copied to do_lock by render. can become flag. */
short do_lock, lock;
/* call cursor function on each move event */
short event_cursor;
@@ -337,7 +338,8 @@ struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
void BKE_area_region_panels_free(struct ListBase *panels);
void BKE_screen_area_free(struct ScrArea *sa);
-/* Gizmo-maps of a region need to be freed with the region. Uses callback to avoid low-level call. */
+/* Gizmo-maps of a region need to be freed with the region.
+ * Uses callback to avoid low-level call. */
void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *));
void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizmoMap *));
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index 820f28fb363..170ab657388 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -100,9 +100,8 @@ typedef struct SeqRenderData {
/* special case for OpenGL render */
struct GPUOffScreen *gpu_offscreen;
- struct GPUFX *gpu_fx;
- int gpu_samples;
- bool gpu_full_samples;
+ // int gpu_samples;
+ // bool gpu_full_samples;
} SeqRenderData;
void BKE_sequencer_new_render_data(struct Main *bmain,
@@ -302,46 +301,33 @@ void BKE_sequencer_proxy_set(struct Sequence *seq, bool value);
* Sequencer memory cache management functions
* ********************************************************************** */
-typedef enum {
- SEQ_STRIPELEM_IBUF,
- SEQ_STRIPELEM_IBUF_COMP,
- SEQ_STRIPELEM_IBUF_STARTSTILL,
- SEQ_STRIPELEM_IBUF_ENDSTILL,
-} eSeqStripElemIBuf;
+#define SEQ_CACHE_COST_MAX 10.0f
-void BKE_sequencer_cache_destruct(void);
-void BKE_sequencer_cache_cleanup(void);
-
-/* returned ImBuf is properly refed and has to be freed */
struct ImBuf *BKE_sequencer_cache_get(const SeqRenderData *context,
struct Sequence *seq,
float cfra,
- eSeqStripElemIBuf type);
-
-/* passed ImBuf is properly refed, so ownership is *not*
- * transferred to the cache.
- * you can pass the same ImBuf multiple times to the cache without problems.
- */
-
+ int type);
void BKE_sequencer_cache_put(const SeqRenderData *context,
struct Sequence *seq,
float cfra,
- eSeqStripElemIBuf type,
- struct ImBuf *nval);
-
-void BKE_sequencer_cache_cleanup_sequence(struct Sequence *seq);
-
-struct ImBuf *BKE_sequencer_preprocessed_cache_get(const SeqRenderData *context,
- struct Sequence *seq,
- float cfra,
- eSeqStripElemIBuf type);
-void BKE_sequencer_preprocessed_cache_put(const SeqRenderData *context,
- struct Sequence *seq,
- float cfra,
- eSeqStripElemIBuf type,
- struct ImBuf *ibuf);
-void BKE_sequencer_preprocessed_cache_cleanup(void);
-void BKE_sequencer_preprocessed_cache_cleanup_sequence(struct Sequence *seq);
+ int type,
+ struct ImBuf *nval,
+ float cost);
+bool BKE_sequencer_cache_put_if_possible(const SeqRenderData *context,
+ struct Sequence *seq,
+ float cfra,
+ int type,
+ struct ImBuf *nval,
+ float cost);
+void BKE_sequencer_cache_free_temp_cache(struct Scene *scene, short id, int cfra);
+void BKE_sequencer_cache_destruct(struct Scene *scene);
+void BKE_sequencer_cache_cleanup_all(struct Main *bmain);
+void BKE_sequencer_cache_cleanup(struct Scene *scene);
+void BKE_sequencer_cache_cleanup_sequence(struct Scene *scene, struct Sequence *seq);
+void BKE_sequencer_cache_iterate(
+ struct Scene *scene,
+ void *userdata,
+ bool callback(void *userdata, struct Sequence *seq, int cfra, int cache_type, float cost));
/* **********************************************************************
* seqeffects.c
@@ -500,19 +486,9 @@ struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C,
ListBase *seqbasep,
struct SeqLoadInfo *seq_load);
-/* view3d draw callback, run when not in background view */
-/* NOTE: Keep in sync with V3D_OFSDRAW_* flags. */
-enum {
- SEQ_OFSDRAW_NONE = (0),
- SEQ_OFSDRAW_USE_BACKGROUND = (1 << 0),
- SEQ_OFSDRAW_USE_FULL_SAMPLE = (1 << 1),
- SEQ_OFSDRAW_USE_GPENCIL = (1 << 2),
- SEQ_OFSDRAW_USE_SOLID_TEX = (1 << 2),
- SEQ_OFSDRAW_USE_CAMERA_DOF = (1 << 3),
-};
-
typedef struct ImBuf *(*SequencerDrawView)(struct Depsgraph *depsgraph,
struct Scene *scene,
+ struct View3DShading *shading_override,
int drawtype,
struct Object *camera,
int width,
@@ -590,6 +566,6 @@ void BKE_sequencer_color_balance_apply(struct StripColorBalance *cb,
bool make_float,
struct ImBuf *mask_input);
-void BKE_sequencer_all_free_anim_ibufs(struct Main *bmain, int cfra);
+void BKE_sequencer_all_free_anim_ibufs(struct Scene *scene, int cfra);
#endif /* __BKE_SEQUENCER_H__ */
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index d97525d4094..8993654254e 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -112,7 +112,8 @@ void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd,
int numVerts);
/*
- * This function casts a ray in the given BVHTree.. but it takes into consideration the space_transform, that is:
+ * This function casts a ray in the given BVHTree.
+ * but it takes into consideration the space_transform, that is:
*
* if transf was configured with "SPACE_TRANSFORM_SETUP( &transf, ob1, ob2 )"
* then the input (vert, dir, BVHTreeRayHit) must be defined in ob1 coordinates space
@@ -129,7 +130,8 @@ bool BKE_shrinkwrap_project_normal(char options,
struct ShrinkwrapTreeData *tree,
BVHTreeRayHit *hit);
-/* Maps the point to the nearest surface, either by simple nearest, or by target normal projection. */
+/* Maps the point to the nearest surface, either by simple nearest,
+ * or by target normal projection. */
void BKE_shrinkwrap_find_nearest_surface(struct ShrinkwrapTreeData *tree,
struct BVHTreeNearest *nearest,
float co[3],
diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h
index 049950f2a03..e0a8b7f9d5d 100644
--- a/source/blender/blenkernel/BKE_softbody.h
+++ b/source/blender/blenkernel/BKE_softbody.h
@@ -37,8 +37,8 @@ typedef struct BodyPoint {
int *springs;
float choke, choke2, frozen;
float colball;
- short loc_flag; //reserved by locale module specific states
- //char octantflag;
+ short loc_flag; // reserved by locale module specific states
+ // char octantflag;
float mass;
float springweight;
} BodyPoint;
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index 91e23d35f0e..f526dd579ce 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -32,6 +32,7 @@
struct Main;
struct Sequence;
struct bSound;
+struct Depsgraph;
typedef struct SoundWaveform {
int length;
@@ -71,10 +72,17 @@ void BKE_sound_cache(struct bSound *sound);
void BKE_sound_delete_cache(struct bSound *sound);
+void BKE_sound_reset_runtime(struct bSound *sound);
void BKE_sound_load(struct Main *main, struct bSound *sound);
+void BKE_sound_ensure_loaded(struct Main *bmain, struct bSound *sound);
void BKE_sound_free(struct bSound *sound);
+/* Is used by sequencer to temporarily load audio to access information about channels and
+ * duration. */
+void BKE_sound_load_audio(struct Main *main, struct bSound *sound);
+void BKE_sound_free_audio(struct bSound *sound);
+
void BKE_sound_copy_data(struct Main *bmain,
struct bSound *sound_dst,
const struct bSound *sound_src,
@@ -86,7 +94,9 @@ void BKE_sound_make_local(struct Main *bmain, struct bSound *sound, const bool l
AUD_Device *BKE_sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume);
#endif
+void BKE_sound_reset_scene_runtime(struct Scene *scene);
void BKE_sound_create_scene(struct Scene *scene);
+void BKE_sound_ensure_scene(struct Scene *scene);
void BKE_sound_destroy_scene(struct Scene *scene);
@@ -134,6 +144,10 @@ void BKE_sound_stop_scene(struct Scene *scene);
void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene);
+/* Use this after original scene's frame has been changed. It will take care of doing all the
+ * updates required for BKE_sound_seek_scene(). */
+void BKE_sound_update_and_seek(struct Main *bmain, struct Depsgraph *depsgraph);
+
float BKE_sound_sync_scene(struct Scene *scene);
int BKE_sound_scene_playing(struct Scene *scene);
@@ -150,4 +164,15 @@ float BKE_sound_get_length(struct bSound *sound);
char **BKE_sound_get_device_names(void);
+typedef void (*SoundJackSyncCallback)(struct Main *bmain, int mode, float time);
+
+void BKE_sound_jack_sync_callback_set(SoundJackSyncCallback callback);
+void BKE_sound_jack_scene_update(struct Scene *scene, int mode, float time);
+
+/* Dependency graph evaluation. */
+
+struct Depsgraph;
+
+void BKE_sound_evaluate(struct Depsgraph *depsgraph, struct Main *bmain, struct bSound *sound);
+
#endif /* __BKE_SOUND_H__ */
diff --git a/source/blender/blenkernel/BKE_undo_system.h b/source/blender/blenkernel/BKE_undo_system.h
index fc6fc6ff336..d4cb9331605 100644
--- a/source/blender/blenkernel/BKE_undo_system.h
+++ b/source/blender/blenkernel/BKE_undo_system.h
@@ -92,7 +92,8 @@ typedef struct UndoType {
/**
* When NULL, we don't consider this undo type for context checks.
* Operators must explicitly set the undo type and handle adding the undo step.
- * This is needed when tools operate on data which isn't the primary mode (eg, paint-curve in sculpt mode).
+ * This is needed when tools operate on data which isn't the primary mode
+ * (eg, paint-curve in sculpt mode).
*/
bool (*poll)(struct bContext *C);
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h
index 17973265390..4f9ff61c9a6 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -63,7 +63,7 @@ double bUnit_BaseScalar(int system, int type);
bool bUnit_IsValid(int system, int type);
/* loop over scales, could add names later */
-//double bUnit_Iter(void **unit, char **name, int system, int type);
+// double bUnit_Iter(void **unit, char **name, int system, int type);
void bUnit_GetSystem(int system, int type, void const **r_usys_pt, int *r_len);
int bUnit_GetBaseUnit(const void *usys_pt);
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index cd612cd9d8c..e564e91749c 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -24,29 +24,29 @@ set(INC
../blenlib
../blenloader
../blentranslation
+ ../bmesh
../depsgraph
../draw
+ ../gpencil_modifiers
../gpu
../ikplugin
../imbuf
../makesdna
../makesrna
- ../bmesh
../modifiers
- ../gpencil_modifiers
- ../shader_fx
../nodes
../physics
+ ../shader_fx
../render/extern/include
../../../intern/ghost
- ../../../intern/guardedalloc
../../../intern/glew-mx
+ ../../../intern/guardedalloc
../../../intern/iksolver/extern
- ../../../intern/memutil
- ../../../intern/mikktspace
../../../intern/atomic
../../../intern/clog
../../../intern/libmv
+ ../../../intern/memutil
+ ../../../intern/mikktspace
../../../intern/opensubdiv
../../../extern/curve_fit_nd
../../../intern/smoke/extern
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_intern.h b/source/blender/blenkernel/intern/CCGSubSurf_intern.h
index f89545e802e..41a34b65381 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_intern.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf_intern.h
@@ -269,7 +269,10 @@ struct CCGSubSurf {
#define EDGE_getNo(e, lvl, x) ccg_edge_getNo(e, lvl, x, vertDataSize, normalDataOffset)
#define FACE_getIFNo(f, lvl, S, x, y) \
ccg_face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset)
-//#define FACE_calcIFNo(f, lvl, S, x, y, no) _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize)
+#if 0
+# define FACE_calcIFNo(f, lvl, S, x, y, no) \
+ _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize)
+#endif
#define FACE_getIENo(f, lvl, S, x) \
ccg_face_getIENo(f, lvl, S, x, subdivLevels, vertDataSize, normalDataOffset)
#define FACE_getIECo(f, lvl, S, x) ccg_face_getIECo(f, lvl, S, x, subdivLevels, vertDataSize)
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index e70fcfe75c1..959435ad486 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -246,8 +246,8 @@ static const MLoopTri *dm_getLoopTriArray(DerivedMesh *dm)
}
else {
BLI_rw_mutex_lock(&loops_cache_lock, THREAD_LOCK_WRITE);
- /* We need to ensure array is still NULL inside mutex-protected code, some other thread might have already
- * recomputed those looptris. */
+ /* We need to ensure array is still NULL inside mutex-protected code,
+ * some other thread might have already recomputed those looptris. */
if (dm->looptris.array == NULL) {
dm->recalcLoopTri(dm);
}
@@ -485,7 +485,8 @@ void DM_ensure_normals(DerivedMesh *dm)
/**
* Ensure the array is large enough
*
- * \note This function must always be thread-protected by caller. It should only be used by internal code.
+ * \note This function must always be thread-protected by caller.
+ * It should only be used by internal code.
*/
void DM_ensure_looptri_data(DerivedMesh *dm)
{
@@ -1039,16 +1040,28 @@ static void mesh_calc_modifier_final_normals(const Mesh *mesh_input,
/* Compute normals. */
const bool do_loop_normals = ((mesh_input->flag & ME_AUTOSMOOTH) != 0 ||
(dataMask->lmask & CD_MASK_NORMAL) != 0);
- /* Some modifiers may need this info from their target (other) object, simpler to generate it here as well.
+ /* Some modifiers may need this info from their target (other) object,
+ * simpler to generate it here as well.
* Note that they will always be generated when no loop normals are comptuted,
* since they are needed by drawing code. */
const bool do_poly_normals = ((dataMask->pmask & CD_MASK_NORMAL) != 0);
if (do_loop_normals) {
- /* In case we also need poly normals, add the layer here, then BKE_mesh_calc_normals_split() will fill it. */
+ /* In case we also need poly normals, add the layer and compute them here
+ * (BKE_mesh_calc_normals_split() assumes that if that data exists, it is always valid). */
if (do_poly_normals) {
if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) {
- CustomData_add_layer(&mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly);
+ float(*polynors)[3] = CustomData_add_layer(
+ &mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly);
+ BKE_mesh_calc_normals_poly(mesh_final->mvert,
+ NULL,
+ mesh_final->totvert,
+ mesh_final->mloop,
+ mesh_final->mpoly,
+ mesh_final->totloop,
+ mesh_final->totpoly,
+ polynors,
+ false);
}
}
/* Compute loop normals (note: will compute poly and vert normals as well, if needed!) */
@@ -1076,8 +1089,9 @@ static void mesh_calc_modifier_final_normals(const Mesh *mesh_input,
}
}
- /* Some modifiers, like datatransfer, may generate those data as temp layer, we do not want to keep them,
- * as they are used by display code when available (i.e. even if autosmooth is disabled). */
+ /* Some modifiers, like data-transfer, may generate those data as temp layer,
+ * we do not want to keep them, as they are used by display code when available
+ * (i.e. even if autosmooth is disabled). */
if (!do_loop_normals && CustomData_has_layer(&mesh_final->ldata, CD_NORMAL)) {
CustomData_free_layers(&mesh_final->ldata, CD_NORMAL, mesh_final->totloop);
}
@@ -1354,7 +1368,8 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
CustomData_add_layer(
&mesh_final->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh_final->totpoly);
- /* Not worth parallelizing this, gives less than 0.1% overall speedup in best of best cases... */
+ /* Not worth parallelizing this,
+ * gives less than 0.1% overall speedup in best of best cases... */
range_vn_i(
CustomData_get_layer(&mesh_final->vdata, CD_ORIGINDEX), mesh_final->totvert, 0);
range_vn_i(
@@ -1574,11 +1589,13 @@ static void editbmesh_calc_modifier_final_normals(const Mesh *mesh_input,
{
const bool do_loop_normals = ((mesh_input->flag & ME_AUTOSMOOTH) != 0 ||
(dataMask->lmask & CD_MASK_NORMAL) != 0);
- /* Some modifiers may need this info from their target (other) object, simpler to generate it here as well. */
+ /* Some modifiers may need this info from their target (other) object,
+ * simpler to generate it here as well. */
const bool do_poly_normals = ((dataMask->pmask & CD_MASK_NORMAL) != 0);
if (do_loop_normals) {
- /* In case we also need poly normals, add the layer here, then BKE_mesh_calc_normals_split() will fill it. */
+ /* In case we also need poly normals, add the layer here,
+ * then BKE_mesh_calc_normals_split() will fill it. */
if (do_poly_normals) {
if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) {
CustomData_add_layer(&mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly);
@@ -2009,7 +2026,10 @@ static void mesh_build_data(struct Depsgraph *depsgraph,
* but this avoids waiting on first stroke) */
/* XXX Disabled for now.
* This can create horrible nasty bugs by generating re-entrant call of mesh_get_eval_final! */
- // BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, false, false);
+#if 0
+ BKE_sculpt_update_mesh_elements(
+ depsgraph, scene, scene->toolsettings->sculpt, ob, false, false);
+#endif
}
mesh_runtime_check_normals_valid(ob->runtime.mesh_eval);
@@ -2433,7 +2453,8 @@ static void mesh_init_origspace(Mesh *mesh)
}
invert_v2(scale);
- /* Finally, transform all vcos_2d into ((0, 0), (1, 1)) square and assign them as origspace. */
+ /* Finally, transform all vcos_2d into ((0, 0), (1, 1))
+ * square and assign them as origspace. */
for (j = 0; j < mp->totloop; j++, lof++) {
add_v2_v2v2(lof->uv, vcos_2d[j], translate);
mul_v2_v2(lof->uv, scale);
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 8e9158b8433..9b321ff4e44 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -115,8 +115,10 @@ void BKE_action_free(bAction *act)
/* .................................. */
/**
- * Only copy internal data of Action ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Action ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -139,8 +141,11 @@ void BKE_action_copy_data(Main *UNUSED(bmain),
for (fcu_src = act_src->curves.first; fcu_src; fcu_src = fcu_src->next) {
/* duplicate F-Curve */
- fcu_dst = copy_fcurve(
- fcu_src); /* XXX TODO pass subdata flag? But surprisingly does not seem to be doing any ID refcounting... */
+
+ /* XXX TODO pass subdata flag?
+ * But surprisingly does not seem to be doing any ID refcounting... */
+ fcu_dst = copy_fcurve(fcu_src);
+
BLI_addtail(&act_dst->curves, fcu_dst);
/* fix group links (kindof bad list-in-list search, but this is the most reliable way) */
@@ -309,12 +314,13 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
/* firstly, link this F-Curve to the group */
agrp->channels.first = agrp->channels.last = fcurve;
- /* step through the groups preceding this one, finding the F-Curve there to attach this one after */
+ /* Step through the groups preceding this one,
+ * finding the F-Curve there to attach this one after. */
for (grp = agrp->prev; grp; grp = grp->prev) {
- /* if this group has F-Curves, we want weave the given one in right after the last channel there,
- * but via the Action's list not this group's list
+ /* if this group has F-Curves, we want weave the given one in right after the last channel
+ * there, but via the Action's list not this group's list
* - this is so that the F-Curve is in the right place in the Action,
- * but won't be included in the previous group
+ * but won't be included in the previous group.
*/
if (grp->channels.last) {
/* once we've added, break here since we don't need to search any further... */
@@ -323,9 +329,9 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
}
}
- /* if grp is NULL, that means we fell through, and this F-Curve should be added as the new first
- * since group is (effectively) the first group. Thus, the existing first F-Curve becomes the
- * second in the chain, etc. etc.
+ /* If grp is NULL, that means we fell through, and this F-Curve should be added as the new
+ * first since group is (effectively) the first group. Thus, the existing first F-Curve becomes
+ * the second in the chain, etc. etc.
*/
if (grp == NULL) {
BLI_insertlinkbefore(&act->curves, act->curves.first, fcurve);
@@ -606,7 +612,8 @@ void BKE_pose_copy_data_ex(bPose **dst,
&listb, &pchan->constraints, flag, true); // BKE_constraints_copy NULLs listb
pchan->constraints = listb;
- /* XXX: This is needed for motionpath drawing to work. Dunno why it was setting to null before... */
+ /* XXX: This is needed for motionpath drawing to work.
+ * Dunno why it was setting to null before... */
pchan->mpath = animviz_copy_motionpath(pchan->mpath);
}
@@ -1287,7 +1294,8 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
const char *bPtr = NULL, *pPtr = NULL;
- /* if enough flags have been found, we can stop checking unless we're also getting the curves */
+ /* If enough flags have been found,
+ * we can stop checking unless we're also getting the curves. */
if ((flags == ACT_TRANS_ALL) && (curves == NULL)) {
break;
}
@@ -1531,14 +1539,12 @@ void what_does_obaction(
}
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
- BLI_strncpy(
- workob->id.name,
- "OB<ConstrWorkOb>",
- sizeof(
- workob->id
- .name)); /* we don't use real object name, otherwise RNA screws with the real thing */
-
- /* if we're given a group to use, it's likely to be more efficient (though a bit more dangerous) */
+
+ /* we don't use real object name, otherwise RNA screws with the real thing */
+ BLI_strncpy(workob->id.name, "OB<ConstrWorkOb>", sizeof(workob->id.name));
+
+ /* If we're given a group to use, it's likely to be more efficient
+ * (though a bit more dangerous). */
if (agrp) {
/* specifically evaluate this group only */
PointerRNA id_ptr;
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index e74af25a4a1..6b8f8e5303e 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -202,7 +202,8 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports,
mpath = *dst;
- /* path is "valid" if length is valid, but must also be of the same length as is being requested */
+ /* Path is "valid" if length is valid,
+ * but must also be of the same length as is being requested. */
if ((mpath->start_frame != mpath->end_frame) && (mpath->length > 0)) {
/* outer check ensures that we have some curve data for this path */
if (mpath->length == expected_length) {
@@ -309,7 +310,8 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
tot = cycl ? bl->nr : bl->nr - 1;
path->len = tot + 1;
- /* exception: vector handle paths and polygon paths should be subdivided at least a factor resolu */
+ /* Exception: vector handle paths and polygon paths should be subdivided
+ * at least a factor resolution. */
if (path->len < nu->resolu * SEGMENTSU(nu)) {
path->len = nu->resolu * SEGMENTSU(nu);
}
@@ -478,7 +480,7 @@ int where_on_path(Object *ob,
* which used to temporary set CU_FOLLOW flag for the curve and no
* longer does it (because of threading issues of such a thing.
*/
- //if (cu->flag & CU_FOLLOW) {
+ // if (cu->flag & CU_FOLLOW) {
key_curve_tangent_weights(1.0f - fac, data, KEY_BSPLINE);
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index e8bcb664c6e..cc5cd3b03ae 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -179,7 +179,8 @@ AnimData *BKE_animdata_add_id(ID *id)
/* Action Setter --------------------------------------- */
-/* Called when user tries to change the active action of an AnimData block (via RNA, Outliner, etc.) */
+/** Called when user tries to change the active action of an AnimData block
+ * (via RNA, Outliner, etc.) */
bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
{
AnimData *adt = BKE_animdata_from_id(id);
@@ -283,7 +284,8 @@ void BKE_animdata_free(ID *id, const bool do_id_user)
/**
* Make a copy of the given AnimData - to be used when copying datablocks.
- * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
+ * \param flag: Control ID pointers management,
+ * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
* \return The copied animdata.
*/
AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag)
@@ -325,7 +327,8 @@ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag)
}
/**
- * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
+ * \param flag: Control ID pointers management,
+ * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
* \return true is succesfully copied.
*/
bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID *id_from, const int flag)
@@ -572,7 +575,8 @@ void BKE_animdata_separate_by_basepath(Main *bmain, ID *srcID, ID *dstID, ListBa
/* active action */
if (srcAdt->action) {
- /* set up an action if necessary, and name it in a similar way so that it can be easily found again */
+ /* Set up an action if necessary,
+ * and name it in a similar way so that it can be easily found again. */
if (dstAdt->action == NULL) {
dstAdt->action = BKE_action_add(bmain, srcAdt->action->id.name + 2);
}
@@ -629,7 +633,8 @@ void BKE_animdata_separate_by_basepath(Main *bmain, ID *srcID, ID *dstID, ListBa
* they will get picked up by the dependency system.
*
* \param C: Context pointer - for getting active data
- * \param[in,out] ptr RNA pointer for property's datablock. May be modified as result of path remapping.
+ * \param[in,out] ptr: RNA pointer for property's datablock.
+ * May be modified as result of path remapping.
* \param prop: RNA definition of property to add for
* \return MEM_alloc'd string representing the path to the property from the given #PointerRNA
*/
@@ -670,7 +675,8 @@ char *BKE_animdata_driver_path_hack(bContext *C,
/* Path Validation -------------------------------------------- */
-/* Check if a given RNA Path is valid, by tracing it from the given ID, and seeing if we can resolve it */
+/* Check if a given RNA Path is valid, by tracing it from the given ID,
+ * and seeing if we can resolve it. */
static bool check_rna_path_is_valid(ID *owner_id, const char *path)
{
PointerRNA id_ptr, ptr;
@@ -766,7 +772,8 @@ static bool fcurves_path_rename_fix(ID *owner_id,
fcu->rna_path = rna_path_rename_fix(
owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths);
/* if path changed and the F-Curve is grouped, check if its group also needs renaming
- * (i.e. F-Curve is first of a bone's F-Curves; hence renaming this should also trigger rename) */
+ * (i.e. F-Curve is first of a bone's F-Curves;
+ * hence renaming this should also trigger rename) */
if (fcu->rna_path != old_path) {
bActionGroup *agrp = fcu->grp;
is_changed = true;
@@ -1456,7 +1463,8 @@ KS_Path *BKE_keyingset_find_path(KeyingSet *ks,
/* Defining Tools --------------------------- */
-/* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
+/* Used to create a new 'custom' KeyingSet for the user,
+ * that will be automatically added to the stack */
KeyingSet *BKE_keyingset_add(
ListBase *list, const char idname[], const char name[], short flag, short keyingflag)
{
@@ -1471,8 +1479,8 @@ KeyingSet *BKE_keyingset_add(
ks->flag = flag;
ks->keyingflag = keyingflag;
- ks->keyingoverride =
- keyingflag; /* NOTE: assume that if one is set one way, the other should be too, so that it'll work */
+ /* NOTE: assume that if one is set one way, the other should be too, so that it'll work */
+ ks->keyingoverride = keyingflag;
/* add KeyingSet to list */
BLI_addtail(list, ks);
@@ -1824,31 +1832,50 @@ bool BKE_animsys_execute_fcurve(PointerRNA *ptr, FCurve *fcu, float curval)
return ok;
}
+static bool animsys_construct_orig_pointer_rna(const PointerRNA *ptr, PointerRNA *ptr_orig)
+{
+ *ptr_orig = *ptr;
+ /* NOTE: nlastrip_evaluate_controls() creates PointerRNA with ID of NULL. Technically, this is
+ * not a valid pointer, but there are exceptions in various places of this file which handles
+ * such pointers.
+ * We do special trickery here as well, to quickly go from evaluated to original NlaStrip. */
+ if (ptr->id.data == NULL) {
+ if (ptr->type != &RNA_NlaStrip) {
+ return false;
+ }
+ NlaStrip *strip = ((NlaStrip *)ptr_orig->data);
+ if (strip->orig_strip == NULL) {
+ return false;
+ }
+ ptr_orig->data = strip->orig_strip;
+ }
+ else {
+ ptr_orig->id.data = ((ID *)ptr_orig->id.data)->orig_id;
+ ptr_orig->data = ptr_orig->id.data;
+ }
+ return true;
+}
+
static void animsys_write_orig_anim_rna(PointerRNA *ptr,
const char *rna_path,
int array_index,
float value)
{
- /* Pointer is expected to be an ID pointer, if it's not -- we are doomed.
- *
- * NOTE: It is possible to have animation data on NLA strip, see T57360.
- * TODO(sergey): Find solution for those cases.
- */
- if (ptr->id.data == NULL) {
+ PointerRNA ptr_orig;
+ if (!animsys_construct_orig_pointer_rna(ptr, &ptr_orig)) {
return;
}
- PointerRNA orig_ptr = *ptr;
- orig_ptr.id.data = ((ID *)orig_ptr.id.data)->orig_id;
- orig_ptr.data = orig_ptr.id.data;
PathResolvedRNA orig_anim_rna;
- /* TODO(sergey): Is there a faster way to get anim_rna of original ID? */
- if (animsys_store_rna_setting(&orig_ptr, rna_path, array_index, &orig_anim_rna)) {
+ /* TODO(sergey): Should be possible to cache resolved path in dependency graph somehow. */
+ if (animsys_store_rna_setting(&ptr_orig, rna_path, array_index, &orig_anim_rna)) {
animsys_write_rna_setting(&orig_anim_rna, value);
}
}
-/* Evaluate all the F-Curves in the given list
- * This performs a set of standard checks. If extra checks are required, separate code should be used
+/**
+ * Evaluate all the F-Curves in the given list
+ * This performs a set of standard checks. If extra checks are required,
+ * separate code should be used.
*/
static void animsys_evaluate_fcurves(Depsgraph *depsgraph,
PointerRNA *ptr,
@@ -1898,9 +1925,8 @@ static void animsys_evaluate_drivers(PointerRNA *ptr, AnimData *adt, float ctime
/* XXX driver recalc flag is not set yet by depsgraph! */
if ((driver) && !(driver->flag & DRIVER_FLAG_INVALID)) {
/* evaluate this using values set already in other places
- * NOTE: for 'layering' option later on, we should check if we should remove old value before adding
- * new to only be done when drivers only changed */
-
+ * NOTE: for 'layering' option later on, we should check if we should remove old value
+ * before adding new to only be done when drivers only changed. */
PathResolvedRNA anim_rna;
if (animsys_store_rna_setting(ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
@@ -1937,7 +1963,8 @@ static void action_idcode_patch_check(ID *id, bAction *act)
/* the actual checks... hopefully not too much of a performance hit in the long run... */
if (act->idroot == 0) {
- /* use the current root if not set already (i.e. newly created actions and actions from 2.50-2.57 builds)
+ /* use the current root if not set already
+ * (i.e. newly created actions and actions from 2.50-2.57 builds).
* - this has problems if there are 2 users, and the first one encountered is the invalid one
* in which case, the user will need to manually fix this (?)
*/
@@ -2067,9 +2094,9 @@ static void nlastrip_evaluate_controls(Depsgraph *depsgraph, NlaStrip *strip, fl
strip->strip_time = nlastrip_get_frame(strip, ctime, NLATIME_CONVERT_EVAL);
}
- /* if user can control the evaluation time (using F-Curves), consider the option which allows this time to be clamped
- * to lie within extents of the action-clip, so that a steady changing rate of progress through several cycles of the clip
- * can be achieved easily
+ /* if user can control the evaluation time (using F-Curves), consider the option which allows
+ * this time to be clamped to lie within extents of the action-clip, so that a steady changing
+ * rate of progress through several cycles of the clip can be achieved easily.
*/
/* NOTE: if we add any more of these special cases, we better group them up nicely... */
if ((strip->flag & NLASTRIP_FLAG_USR_TIME) && (strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC)) {
@@ -2160,7 +2187,8 @@ NlaEvalStrip *nlastrips_ctime_get_strip(
* - skip if no influence (i.e. same effect as muting the strip)
* - negative influence is not supported yet... how would that be defined?
*/
- /* TODO: this sounds a bit hacky having a few isolated F-Curves stuck on some data it operates on... */
+ /* TODO: this sounds a bit hacky having a few isolated F-Curves
+ * stuck on some data it operates on... */
nlastrip_evaluate_controls(depsgraph, estrip, ctime);
if (estrip->influence <= 0.0f) {
return NULL;
@@ -2331,7 +2359,8 @@ static NlaEvalChannelSnapshot *nlaeval_snapshot_find_channel(NlaEvalSnapshot *sn
return &nec->base_snapshot;
}
-/* Retrieve or create the channel value snapshot, copying from the other snapshot (or default values) */
+/* Retrieve or create the channel value snapshot, copying from the other snapshot
+ * (or default values) */
static NlaEvalChannelSnapshot *nlaeval_snapshot_ensure_channel(NlaEvalSnapshot *snapshot,
NlaEvalChannel *nec)
{
@@ -2959,7 +2988,8 @@ static void nlaeval_snapshot_mix_and_free(NlaEvalData *nlaeval,
}
/* ---------------------- */
-/* F-Modifier stack joining/separation utilities - should we generalise these for BLI_listbase.h interface? */
+/* F-Modifier stack joining/separation utilities -
+ * should we generalize these for BLI_listbase.h interface? */
/* Temporarily join two lists of modifiers together, storing the result in a third list */
static void nlaeval_fmodifiers_join_stacks(ListBase *result, ListBase *list1, ListBase *list2)
@@ -2979,8 +3009,9 @@ static void nlaeval_fmodifiers_join_stacks(ListBase *result, ListBase *list1, Li
result->last = list1->last;
}
else {
- /* list1 should be added first, and list2 second, with the endpoints of these being the endpoints for result
- * - the original lists must be left unchanged though, as we need that fact for restoring
+ /* list1 should be added first, and list2 second,
+ * with the endpoints of these being the endpoints for result
+ * - the original lists must be left unchanged though, as we need that fact for restoring.
*/
result->first = list1->first;
result->last = list2->last;
@@ -3058,7 +3089,8 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr,
.influence = strip->influence,
};
- /* evaluate all the F-Curves in the action, saving the relevant pointers to data that will need to be used */
+ /* Evaluate all the F-Curves in the action,
+ * saving the relevant pointers to data that will need to be used. */
for (fcu = strip->act->curves.first; fcu; fcu = fcu->next) {
float value = 0.0f;
@@ -3071,18 +3103,20 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr,
}
/* evaluate the F-Curve's value for the time given in the strip
- * NOTE: we use the modified time here, since strip's F-Curve Modifiers are applied on top of this
+ * NOTE: we use the modified time here, since strip's F-Curve Modifiers
+ * are applied on top of this.
*/
value = evaluate_fcurve(fcu, evaltime);
/* apply strip's F-Curve Modifiers on this value
- * NOTE: we apply the strip's original evaluation time not the modified one (as per standard F-Curve eval)
+ * NOTE: we apply the strip's original evaluation time not the modified one
+ * (as per standard F-Curve eval)
*/
evaluate_value_fmodifiers(&storage, &tmp_modifiers, fcu, &value, strip->strip_time);
- /* get an NLA evaluation channel to work with, and accumulate the evaluated value with the value(s)
- * stored in this channel if it has been used already
- */
+ /* Get an NLA evaluation channel to work with,
+ * and accumulate the evaluated value with the value(s)
+ * stored in this channel if it has been used already. */
NlaEvalChannel *nec = nlaevalchan_verify(ptr, channels, fcu->rna_path);
nlaeval_blend_value(&blend, nec, fcu->array_index, value);
@@ -3208,10 +3242,13 @@ void nlastrip_evaluate(Depsgraph *depsgraph,
{
NlaStrip *strip = nes->strip;
- /* to prevent potential infinite recursion problems (i.e. transition strip, beside meta strip containing a transition
- * several levels deep inside it), we tag the current strip as being evaluated, and clear this when we leave
+ /* To prevent potential infinite recursion problems
+ * (i.e. transition strip, beside meta strip containing a transition
+ * several levels deep inside it),
+ * we tag the current strip as being evaluated, and clear this when we leave.
*/
- /* TODO: be careful with this flag, since some edit tools may be running and have set this while animplayback was running */
+ /* TODO: be careful with this flag, since some edit tools may be running and have
+ * set this while animplayback was running */
if (strip->flag & NLASTRIP_FLAG_EDIT_TOUCHED) {
return;
}
@@ -3365,9 +3402,10 @@ static void animsys_evaluate_nla_domain(PointerRNA *ptr, NlaEvalData *channels,
/**
* NLA Evaluation function - values are calculated and stored in temporary "NlaEvalChannels"
*
- * \param[out] echannels Evaluation channels with calculated values
- * \param[out] r_context If not NULL, data about the currently edited strip is stored here and excluded from value calculation.
- * \return false if NLA evaluation isn't actually applicable
+ * \param[out] echannels: Evaluation channels with calculated values
+ * \param[out] r_context: If not NULL,
+ * data about the currently edited strip is stored here and excluded from value calculation.
+ * \return false if NLA evaluation isn't actually applicable.
*/
static bool animsys_evaluate_nla(Depsgraph *depsgraph,
NlaEvalData *echannels,
@@ -3391,7 +3429,8 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
/* 1. get the stack of strips to evaluate at current time (influence calculated here) */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next, track_index++) {
- /* stop here if tweaking is on and this strip is the tweaking track (it will be the first one that's 'disabled')... */
+ /* stop here if tweaking is on and this strip is the tweaking track
+ * (it will be the first one that's 'disabled')... */
if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED)) {
break;
}
@@ -3452,7 +3491,8 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
/* set settings of dummy NLA strip from AnimData settings */
dummy_strip->act = adt->action;
- /* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */
+ /* action range is calculated taking F-Modifiers into account
+ * (which making new strips doesn't do due to the troublesome nature of that) */
calc_action_range(dummy_strip->act, &dummy_strip->actstart, &dummy_strip->actend, 1);
dummy_strip->start = dummy_strip->actstart;
dummy_strip->end = (IS_EQF(dummy_strip->actstart, dummy_strip->actend)) ?
@@ -3469,14 +3509,16 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
dummy_strip->extendmode = adt->act_extendmode;
}
- /* Unless extendmode is Nothing (might be useful for flattening NLA evaluation), disable range. */
+ /* Unless extendmode is Nothing (might be useful for flattening NLA evaluation),
+ * disable range. */
if (dummy_strip->extendmode != NLASTRIP_EXTEND_NOTHING) {
dummy_strip->flag |= NLASTRIP_FLAG_NO_TIME_MAP;
}
dummy_strip->influence = adt->act_influence;
- /* NOTE: must set this, or else the default setting overrides, and this setting doesn't work */
+ /* NOTE: must set this, or else the default setting overrides,
+ * and this setting doesn't work. */
dummy_strip->flag |= NLASTRIP_FLAG_USR_INFLUENCE;
}
@@ -3486,7 +3528,8 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
}
/* If computing the context for keyframing, store data there instead of the list. */
else {
- /* The extend mode here effectively controls whether it is possible to keyframe beyond the ends. */
+ /* The extend mode here effectively controls
+ * whether it is possible to key-frame beyond the ends. */
dummy_strip->extendmode = is_inplace_tweak ? NLASTRIP_EXTEND_NOTHING :
NLASTRIP_EXTEND_HOLD;
@@ -3513,7 +3556,8 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
return true;
}
- /* 2. for each strip, evaluate then accumulate on top of existing channels, but don't set values yet */
+ /* 2. for each strip, evaluate then accumulate on top of existing channels,
+ * but don't set values yet. */
for (nes = estrips.first; nes; nes = nes->next) {
nlastrip_evaluate(depsgraph, ptr, echannels, NULL, nes, &echannels->eval_snapshot);
}
@@ -3564,9 +3608,10 @@ static void animsys_calculate_nla(Depsgraph *depsgraph,
* Prepare data necessary to compute correct keyframe values for NLA strips
* with non-Replace mode or influence different from 1.
*
- * @param cache List used to cache contexts for reuse when keying multiple channels in one operation.
- * @param ptr RNA pointer to the Object with the animation.
- * @return Keyframing context, or NULL if not necessary.
+ * \param cache List used to cache contexts for reuse when keying
+ * multiple channels in one operation.
+ * \param ptr RNA pointer to the Object with the animation.
+ * \return Keyframing context, or NULL if not necessary.
*/
NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context(struct ListBase *cache,
struct Depsgraph *depsgraph,
@@ -3607,13 +3652,14 @@ NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context(struct ListBase *ca
/**
* Apply correction from the NLA context to the values about to be keyframed.
*
- * @param context Context to use (may be NULL).
- * @param prop_ptr Property about to be keyframed.
- * @param[in,out] values Array of property values to adjust.
- * @param count Number of values in the array.
- * @param index Index of the element about to be updated, or -1.
- * @param[out] r_force_all Set to true if all channels must be inserted. May be NULL.
- * @return False if correction fails due to a division by zero, or null r_force_all when all channels are required.
+ * \param context Context to use (may be NULL).
+ * \param prop_ptr Property about to be keyframed.
+ * \param[in,out] values Array of property values to adjust.
+ * \param count Number of values in the array.
+ * \param index Index of the element about to be updated, or -1.
+ * \param[out] r_force_all Set to true if all channels must be inserted. May be NULL.
+ * \return False if correction fails due to a division by zero,
+ * or null r_force_all when all channels are required.
*/
bool BKE_animsys_nla_remap_keyframe_values(struct NlaKeyframingContext *context,
struct PointerRNA *prop_ptr,
@@ -3757,17 +3803,21 @@ static void animsys_evaluate_overrides(PointerRNA *ptr, AnimData *adt)
* 3) Drivers/expressions are evaluated on top of this, in an order where dependencies are
* resolved nicely.
* Note: it may be necessary to have some tools to handle the cases where some higher-level
- * drivers are added and cause some problematic dependencies that didn't exist in the local levels...
+ * drivers are added and cause some problematic dependencies that
+ * didn't exist in the local levels...
*
* --------------< always executed >------------------
*
* Maintenance of editability of settings (XXX):
- * In order to ensure that settings that are animated can still be manipulated in the UI without requiring
- * that keyframes are added to prevent these values from being overwritten, we use 'overrides'.
+ * - In order to ensure that settings that are animated can still be manipulated in the UI without
+ * requiring that keyframes are added to prevent these values from being overwritten,
+ * we use 'overrides'.
*
* Unresolved things:
- * - Handling of multi-user settings (i.e. time-offset, group-instancing) -> big cache grids or nodal system? but stored where?
- * - Multiple-block dependencies (i.e. drivers for settings are in both local and higher levels) -> split into separate lists?
+ * - Handling of multi-user settings (i.e. time-offset, group-instancing) -> big cache grids
+ * or nodal system? but stored where?
+ * - Multiple-block dependencies
+ * (i.e. drivers for settings are in both local and higher levels) -> split into separate lists?
*
* Current Status:
* - Currently (as of September 2009), overrides we haven't needed to (fully) implement overrides.
@@ -3856,10 +3906,10 @@ void BKE_animsys_evaluate_all_animation(Main *main,
}
/* macros for less typing
- * - only evaluate animation data for id if it has users (and not just fake ones)
- * - whether animdata exists is checked for by the evaluation function, though taking
- * this outside of the function may make things slightly faster?
- */
+ * - only evaluate animation data for id if it has users (and not just fake ones)
+ * - whether animdata exists is checked for by the evaluation function, though taking
+ * this outside of the function may make things slightly faster?
+ */
#define EVAL_ANIM_IDS(first, aflag) \
for (id = first; id; id = id->next) { \
if (ID_REAL_USERS(id) > 0) { \
@@ -3870,11 +3920,11 @@ void BKE_animsys_evaluate_all_animation(Main *main,
(void)0
/* another macro for the "embedded" nodetree cases
- * - this is like EVAL_ANIM_IDS, but this handles the case "embedded nodetrees"
- * (i.e. scene/material/texture->nodetree) which we need a special exception
- * for, otherwise they'd get skipped
- * - ntp = "node tree parent" = datablock where node tree stuff resides
- */
+ * - this is like EVAL_ANIM_IDS, but this handles the case "embedded nodetrees"
+ * (i.e. scene/material/texture->nodetree) which we need a special exception
+ * for, otherwise they'd get skipped
+ * - ntp = "node tree parent" = datablock where node tree stuff resides
+ */
#define EVAL_ANIM_NODETREE_IDS(first, NtId_Type, aflag) \
for (id = first; id; id = id->next) { \
if (ID_REAL_USERS(id) > 0) { \
@@ -4044,9 +4094,9 @@ void BKE_animsys_eval_driver(Depsgraph *depsgraph,
/* XXX driver recalc flag is not set yet by depsgraph! */
if ((driver_orig) && !(driver_orig->flag & DRIVER_FLAG_INVALID)) {
/* evaluate this using values set already in other places
- * NOTE: for 'layering' option later on, we should check if we should remove old value before adding
- * new to only be done when drivers only changed */
- //printf("\told val = %f\n", fcu->curval);
+ * NOTE: for 'layering' option later on, we should check if we should remove old value before
+ * adding new to only be done when drivers only changed */
+ // printf("\told val = %f\n", fcu->curval);
PathResolvedRNA anim_rna;
if (animsys_store_rna_setting(&id_ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 0986596f97c..2b4123c74e2 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -55,8 +55,9 @@
# ifdef WITH_BINRELOC
# include "binreloc.h"
# endif
-# include <unistd.h> /* mkdtemp on OSX (and probably all *BSD?), not worth making specific check for this OS. */
-#endif /* WIN32 */
+/* mkdtemp on OSX (and probably all *BSD?), not worth making specific check for this OS. */
+# include <unistd.h>
+#endif /* WIN32 */
/* local */
static CLG_LogRef LOG = {"bke.appdir"};
@@ -156,7 +157,7 @@ static bool test_path(char *targetpath,
#ifdef PATH_DEBUG
printf("\t%s missing: %s\n", __func__, targetpath);
#endif
- //targetpath[0] = '\0';
+ // targetpath[0] = '\0';
return false;
}
}
@@ -222,9 +223,11 @@ static bool get_path_local(char *targetpath,
relfolder[0] = '\0';
}
- /* try EXECUTABLE_DIR/2.5x/folder_name - new default directory for local blender installed files */
+ /* Try EXECUTABLE_DIR/2.5x/folder_name -
+ * new default directory for local blender installed files. */
#ifdef __APPLE__
- /* due new codesign situation in OSX > 10.9.5 we must move the blender_version dir with contents to Resources */
+ /* Due new codesign situation in OSX > 10.9.5
+ * we must move the blender_version dir with contents to Resources. */
char osx_resourses[FILE_MAX];
BLI_snprintf(osx_resourses, sizeof(osx_resourses), "%s../Resources", bprogdir);
/* Remove the '/../' added above. */
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 531c1795497..60446bf60b6 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -169,9 +169,33 @@ static void copy_bonechildren(Bone *bone_dst,
}
}
+static void copy_bonechildren_custom_handles(Bone *bone_dst, bArmature *arm_dst, GHash **bone_hash)
+{
+ Bone *bone_dst_child;
+
+ /* Lazily create the name -> bone hashtable. */
+ if ((bone_dst->bbone_prev || bone_dst->bbone_next) && *bone_hash == NULL) {
+ *bone_hash = BKE_armature_bone_from_name_map(arm_dst);
+ }
+
+ if (bone_dst->bbone_prev) {
+ bone_dst->bbone_prev = BLI_ghash_lookup(*bone_hash, bone_dst->bbone_prev->name);
+ }
+ if (bone_dst->bbone_next) {
+ bone_dst->bbone_next = BLI_ghash_lookup(*bone_hash, bone_dst->bbone_next->name);
+ }
+
+ for (bone_dst_child = bone_dst->childbase.first; bone_dst_child;
+ bone_dst_child = bone_dst_child->next) {
+ copy_bonechildren_custom_handles(bone_dst_child, arm_dst, bone_hash);
+ }
+}
+
/**
- * Only copy internal data of Armature ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Armature ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -200,6 +224,17 @@ void BKE_armature_copy_data(Main *UNUSED(bmain),
arm_dst->act_bone = bone_dst_act;
+ /* Fix custom handle references. */
+ GHash *bone_hash = NULL; /* lazily created */
+
+ for (bone_dst = arm_dst->bonebase.first; bone_dst; bone_dst = bone_dst->next) {
+ copy_bonechildren_custom_handles(bone_dst, arm_dst, &bone_hash);
+ }
+
+ if (bone_hash) {
+ BLI_ghash_free(bone_hash, NULL, NULL);
+ }
+
arm_dst->edbo = NULL;
arm_dst->act_edbone = NULL;
}
@@ -463,7 +498,8 @@ static void equalize_cubic_bezier(const float control[4][3],
r_t_points[final_segments] = 1.0f;
}
-/* Evaluate bezier position and tangent at a specific parameter value using the De Casteljau algorithm. */
+/* Evaluate bezier position and tangent at a specific parameter value
+ * using the De Casteljau algorithm. */
static void evaluate_cubic_bezier(const float control[4][3],
float t,
float r_pos[3],
@@ -809,9 +845,10 @@ void BKE_pchan_bbone_handles_compute(const BBoneSplineParameters *param,
*r_roll2 += param->roll2;
/* Extra curve x / y */
- /* NOTE: Scale correction factors here are to compensate for some random floating-point glitches
- * when scaling up the bone or it's parent by a factor of approximately 8.15/6, which results
- * in the bone length getting scaled up too (from 1 to 8), causing the curve to flatten out.
+ /* NOTE:
+ * Scale correction factors here are to compensate for some random floating-point glitches
+ * when scaling up the bone or it's parent by a factor of approximately 8.15/6, which results
+ * in the bone length getting scaled up too (from 1 to 8), causing the curve to flatten out.
*/
const float xscale_correction = (param->do_scale) ? param->scale[0] : 1.0f;
const float yscale_correction = (param->do_scale) ? param->scale[2] : 1.0f;
@@ -1059,7 +1096,8 @@ void BKE_pchan_bbone_segments_cache_copy(bPoseChannel *pchan, bPoseChannel *pcha
}
}
-/** Calculate index and blend factor for the two B-Bone segment nodes affecting the point at 0 <= pos <= 1. */
+/** Calculate index and blend factor for the two B-Bone segment nodes
+ * affecting the point at 0 <= pos <= 1. */
void BKE_pchan_bbone_deform_segment_index(const bPoseChannel *pchan,
float pos,
int *r_index,
@@ -1255,6 +1293,211 @@ static void pchan_bone_deform(bPoseChannel *pchan,
(*contrib) += weight;
}
+typedef struct ArmatureUserdata {
+ Object *armOb;
+ Object *target;
+ const Mesh *mesh;
+ float (*vertexCos)[3];
+ float (*defMats)[3][3];
+ float (*prevCos)[3];
+
+ bool use_envelope;
+ bool use_quaternion;
+ bool invert_vgroup;
+ bool use_dverts;
+
+ int armature_def_nr;
+
+ int target_totvert;
+ MDeformVert *dverts;
+
+ int defbase_tot;
+ bPoseChannel **defnrToPC;
+
+ float premat[4][4];
+ float postmat[4][4];
+} ArmatureUserdata;
+
+static void armature_vert_task(void *__restrict userdata,
+ const int i,
+ const ParallelRangeTLS *__restrict UNUSED(tls))
+{
+ const ArmatureUserdata *data = userdata;
+ float(*const vertexCos)[3] = data->vertexCos;
+ float(*const defMats)[3][3] = data->defMats;
+ float(*const prevCos)[3] = data->prevCos;
+ const bool use_envelope = data->use_envelope;
+ const bool use_quaternion = data->use_quaternion;
+ const bool use_dverts = data->use_dverts;
+ const int armature_def_nr = data->armature_def_nr;
+
+ MDeformVert *dvert;
+ DualQuat sumdq, *dq = NULL;
+ bPoseChannel *pchan;
+ float *co, dco[3];
+ float sumvec[3], summat[3][3];
+ float *vec = NULL, (*smat)[3] = NULL;
+ float contrib = 0.0f;
+ float armature_weight = 1.0f; /* default to 1 if no overall def group */
+ float prevco_weight = 1.0f; /* weight for optional cached vertexcos */
+
+ if (use_quaternion) {
+ memset(&sumdq, 0, sizeof(DualQuat));
+ dq = &sumdq;
+ }
+ else {
+ sumvec[0] = sumvec[1] = sumvec[2] = 0.0f;
+ vec = sumvec;
+
+ if (defMats) {
+ zero_m3(summat);
+ smat = summat;
+ }
+ }
+
+ if (use_dverts || armature_def_nr != -1) {
+ if (data->mesh) {
+ BLI_assert(i < data->mesh->totvert);
+ dvert = data->mesh->dvert + i;
+ }
+ else if (data->dverts && i < data->target_totvert) {
+ dvert = data->dverts + i;
+ }
+ else {
+ dvert = NULL;
+ }
+ }
+ else {
+ dvert = NULL;
+ }
+
+ if (armature_def_nr != -1 && dvert) {
+ armature_weight = defvert_find_weight(dvert, armature_def_nr);
+
+ if (data->invert_vgroup) {
+ armature_weight = 1.0f - armature_weight;
+ }
+
+ /* hackish: the blending factor can be used for blending with prevCos too */
+ if (prevCos) {
+ prevco_weight = armature_weight;
+ armature_weight = 1.0f;
+ }
+ }
+
+ /* check if there's any point in calculating for this vert */
+ if (armature_weight == 0.0f) {
+ return;
+ }
+
+ /* get the coord we work on */
+ co = prevCos ? prevCos[i] : vertexCos[i];
+
+ /* Apply the object's matrix */
+ mul_m4_v3(data->premat, co);
+
+ if (use_dverts && dvert && dvert->totweight) { /* use weight groups ? */
+ MDeformWeight *dw = dvert->dw;
+ int deformed = 0;
+ unsigned int j;
+ float acum_weight = 0;
+ for (j = dvert->totweight; j != 0; j--, dw++) {
+ const int index = dw->def_nr;
+ if (index >= 0 && index < data->defbase_tot && (pchan = data->defnrToPC[index])) {
+ float weight = dw->weight;
+ Bone *bone = pchan->bone;
+
+ deformed = 1;
+
+ if (bone && bone->flag & BONE_MULT_VG_ENV) {
+ weight *= distfactor_to_bone(
+ co, bone->arm_head, bone->arm_tail, bone->rad_head, bone->rad_tail, bone->dist);
+ }
+
+ /* check limit of weight */
+ if (data->target->type == OB_GPENCIL) {
+ if (acum_weight + weight >= 1.0f) {
+ weight = 1.0f - acum_weight;
+ }
+ acum_weight += weight;
+ }
+
+ pchan_bone_deform(pchan, weight, vec, dq, smat, co, &contrib);
+
+ /* if acumulated weight limit exceed, exit loop */
+ if ((data->target->type == OB_GPENCIL) && (acum_weight >= 1.0f)) {
+ break;
+ }
+ }
+ }
+ /* if there are vertexgroups but not groups with bones
+ * (like for softbody groups) */
+ if (deformed == 0 && use_envelope) {
+ for (pchan = data->armOb->pose->chanbase.first; pchan; pchan = pchan->next) {
+ if (!(pchan->bone->flag & BONE_NO_DEFORM)) {
+ contrib += dist_bone_deform(pchan, vec, dq, smat, co);
+ }
+ }
+ }
+ }
+ else if (use_envelope) {
+ for (pchan = data->armOb->pose->chanbase.first; pchan; pchan = pchan->next) {
+ if (!(pchan->bone->flag & BONE_NO_DEFORM)) {
+ contrib += dist_bone_deform(pchan, vec, dq, smat, co);
+ }
+ }
+ }
+
+ /* actually should be EPSILON? weight values and contrib can be like 10e-39 small */
+ if (contrib > 0.0001f) {
+ if (use_quaternion) {
+ normalize_dq(dq, contrib);
+
+ if (armature_weight != 1.0f) {
+ copy_v3_v3(dco, co);
+ mul_v3m3_dq(dco, (defMats) ? summat : NULL, dq);
+ sub_v3_v3(dco, co);
+ mul_v3_fl(dco, armature_weight);
+ add_v3_v3(co, dco);
+ }
+ else {
+ mul_v3m3_dq(co, (defMats) ? summat : NULL, dq);
+ }
+
+ smat = summat;
+ }
+ else {
+ mul_v3_fl(vec, armature_weight / contrib);
+ add_v3_v3v3(co, vec, co);
+ }
+
+ if (defMats) {
+ float pre[3][3], post[3][3], tmpmat[3][3];
+
+ copy_m3_m4(pre, data->premat);
+ copy_m3_m4(post, data->postmat);
+ copy_m3_m3(tmpmat, defMats[i]);
+
+ if (!use_quaternion) { /* quaternion already is scale corrected */
+ mul_m3_fl(smat, armature_weight / contrib);
+ }
+
+ mul_m3_series(defMats[i], post, smat, pre, tmpmat);
+ }
+ }
+
+ /* always, check above code */
+ mul_m4_v3(data->postmat, co);
+
+ /* interpolate with previous modifier position using weight group */
+ if (prevCos) {
+ float mw = 1.0f - prevco_weight;
+ vertexCos[i][0] = prevco_weight * vertexCos[i][0] + mw * co[0];
+ vertexCos[i][1] = prevco_weight * vertexCos[i][1] + mw * co[1];
+ vertexCos[i][2] = prevco_weight * vertexCos[i][2] + mw * co[2];
+ }
+}
+
void armature_deform_verts(Object *armOb,
Object *target,
const Mesh *mesh,
@@ -1267,10 +1510,9 @@ void armature_deform_verts(Object *armOb,
bGPDstroke *gps)
{
bArmature *arm = armOb->data;
- bPoseChannel *pchan, **defnrToPC = NULL;
+ bPoseChannel **defnrToPC = NULL;
MDeformVert *dverts = NULL;
bDeformGroup *dg;
- float obinv[4][4], premat[4][4], postmat[4][4];
const bool use_envelope = (deformflag & ARM_DEF_ENVELOPE) != 0;
const bool use_quaternion = (deformflag & ARM_DEF_QUATERNION) != 0;
const bool invert_vgroup = (deformflag & ARM_DEF_INVERT_VGROUP) != 0;
@@ -1291,11 +1533,6 @@ void armature_deform_verts(Object *armOb,
BLI_assert(0);
}
- invert_m4_m4(obinv, target->obmat);
- copy_m4_m4(premat, target->obmat);
- mul_m4_m4m4(postmat, obinv, armOb->obmat);
- invert_m4_m4(premat, postmat);
-
/* get the def_nr for the overall armature vertex group if present */
armature_def_nr = defgroup_name_index(target, defgrp_name);
@@ -1354,172 +1591,32 @@ void armature_deform_verts(Object *armOb,
}
}
- for (i = 0; i < numVerts; i++) {
- MDeformVert *dvert;
- DualQuat sumdq, *dq = NULL;
- float *co, dco[3];
- float sumvec[3], summat[3][3];
- float *vec = NULL, (*smat)[3] = NULL;
- float contrib = 0.0f;
- float armature_weight = 1.0f; /* default to 1 if no overall def group */
- float prevco_weight = 1.0f; /* weight for optional cached vertexcos */
-
- if (use_quaternion) {
- memset(&sumdq, 0, sizeof(DualQuat));
- dq = &sumdq;
- }
- else {
- sumvec[0] = sumvec[1] = sumvec[2] = 0.0f;
- vec = sumvec;
-
- if (defMats) {
- zero_m3(summat);
- smat = summat;
- }
- }
-
- if (use_dverts || armature_def_nr != -1) {
- if (mesh) {
- BLI_assert(i < mesh->totvert);
- dvert = mesh->dvert + i;
- }
- else if (dverts && i < target_totvert) {
- dvert = dverts + i;
- }
- else {
- dvert = NULL;
- }
- }
- else {
- dvert = NULL;
- }
-
- if (armature_def_nr != -1 && dvert) {
- armature_weight = defvert_find_weight(dvert, armature_def_nr);
-
- if (invert_vgroup) {
- armature_weight = 1.0f - armature_weight;
- }
-
- /* hackish: the blending factor can be used for blending with prevCos too */
- if (prevCos) {
- prevco_weight = armature_weight;
- armature_weight = 1.0f;
- }
- }
-
- /* check if there's any point in calculating for this vert */
- if (armature_weight == 0.0f) {
- continue;
- }
-
- /* get the coord we work on */
- co = prevCos ? prevCos[i] : vertexCos[i];
-
- /* Apply the object's matrix */
- mul_m4_v3(premat, co);
-
- if (use_dverts && dvert && dvert->totweight) { /* use weight groups ? */
- MDeformWeight *dw = dvert->dw;
- int deformed = 0;
- unsigned int j;
- float acum_weight = 0;
- for (j = dvert->totweight; j != 0; j--, dw++) {
- const int index = dw->def_nr;
- if (index >= 0 && index < defbase_tot && (pchan = defnrToPC[index])) {
- float weight = dw->weight;
- Bone *bone = pchan->bone;
-
- deformed = 1;
-
- if (bone && bone->flag & BONE_MULT_VG_ENV) {
- weight *= distfactor_to_bone(
- co, bone->arm_head, bone->arm_tail, bone->rad_head, bone->rad_tail, bone->dist);
- }
-
- /* check limit of weight */
- if (target->type == OB_GPENCIL) {
- if (acum_weight + weight >= 1.0f) {
- weight = 1.0f - acum_weight;
- }
- acum_weight += weight;
- }
-
- pchan_bone_deform(pchan, weight, vec, dq, smat, co, &contrib);
-
- /* if acumulated weight limit exceed, exit loop */
- if ((target->type == OB_GPENCIL) && (acum_weight >= 1.0f)) {
- break;
- }
- }
- }
- /* if there are vertexgroups but not groups with bones
- * (like for softbody groups) */
- if (deformed == 0 && use_envelope) {
- for (pchan = armOb->pose->chanbase.first; pchan; pchan = pchan->next) {
- if (!(pchan->bone->flag & BONE_NO_DEFORM)) {
- contrib += dist_bone_deform(pchan, vec, dq, smat, co);
- }
- }
- }
- }
- else if (use_envelope) {
- for (pchan = armOb->pose->chanbase.first; pchan; pchan = pchan->next) {
- if (!(pchan->bone->flag & BONE_NO_DEFORM)) {
- contrib += dist_bone_deform(pchan, vec, dq, smat, co);
- }
- }
- }
-
- /* actually should be EPSILON? weight values and contrib can be like 10e-39 small */
- if (contrib > 0.0001f) {
- if (use_quaternion) {
- normalize_dq(dq, contrib);
-
- if (armature_weight != 1.0f) {
- copy_v3_v3(dco, co);
- mul_v3m3_dq(dco, (defMats) ? summat : NULL, dq);
- sub_v3_v3(dco, co);
- mul_v3_fl(dco, armature_weight);
- add_v3_v3(co, dco);
- }
- else {
- mul_v3m3_dq(co, (defMats) ? summat : NULL, dq);
- }
-
- smat = summat;
- }
- else {
- mul_v3_fl(vec, armature_weight / contrib);
- add_v3_v3v3(co, vec, co);
- }
-
- if (defMats) {
- float pre[3][3], post[3][3], tmpmat[3][3];
-
- copy_m3_m4(pre, premat);
- copy_m3_m4(post, postmat);
- copy_m3_m3(tmpmat, defMats[i]);
-
- if (!use_quaternion) { /* quaternion already is scale corrected */
- mul_m3_fl(smat, armature_weight / contrib);
- }
+ ArmatureUserdata data = {.armOb = armOb,
+ .target = target,
+ .mesh = mesh,
+ .vertexCos = vertexCos,
+ .defMats = defMats,
+ .prevCos = prevCos,
+ .use_envelope = use_envelope,
+ .use_quaternion = use_quaternion,
+ .invert_vgroup = invert_vgroup,
+ .use_dverts = use_dverts,
+ .armature_def_nr = armature_def_nr,
+ .target_totvert = target_totvert,
+ .dverts = dverts,
+ .defbase_tot = defbase_tot,
+ .defnrToPC = defnrToPC};
+
+ float obinv[4][4];
+ invert_m4_m4(obinv, target->obmat);
- mul_m3_series(defMats[i], post, smat, pre, tmpmat);
- }
- }
+ mul_m4_m4m4(data.postmat, obinv, armOb->obmat);
+ invert_m4_m4(data.premat, data.postmat);
- /* always, check above code */
- mul_m4_v3(postmat, co);
-
- /* interpolate with previous modifier position using weight group */
- if (prevCos) {
- float mw = 1.0f - prevco_weight;
- vertexCos[i][0] = prevco_weight * vertexCos[i][0] + mw * co[0];
- vertexCos[i][1] = prevco_weight * vertexCos[i][1] + mw * co[1];
- vertexCos[i][2] = prevco_weight * vertexCos[i][2] + mw * co[2];
- }
- }
+ ParallelRangeSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.min_iter_per_thread = 32;
+ BLI_task_parallel_range(0, numVerts, &data, armature_vert_task, &settings);
if (defnrToPC) {
MEM_freeN(defnrToPC);
@@ -1588,13 +1685,14 @@ void BKE_bone_offset_matrix_get(const Bone *bone, float offs_bone[4][4])
offs_bone[3][1] += bone->parent->length;
}
-/* Construct the matrices (rot/scale and loc) to apply the PoseChannels into the armature (object) space.
+/* Construct the matrices (rot/scale and loc)
+ * to apply the PoseChannels into the armature (object) space.
* I.e. (roughly) the "pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b)" in the
* pose_mat(b)= pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b)
* ...function.
*
- * This allows to get the transformations of a bone in its object space, *before* constraints (and IK)
- * get applied (used by pose evaluation code).
+ * This allows to get the transformations of a bone in its object space,
+ * *before* constraints (and IK) get applied (used by pose evaluation code).
* And reverse: to find pchan transformations needed to place a bone at a given loc/rot/scale
* in object space (used by interactive transform, and snapping code).
*
@@ -1695,7 +1793,8 @@ void BKE_bone_parent_transform_calc_from_matrices(int bone_flag,
else if (bone_flag & (BONE_HINGE | BONE_NO_SCALE)) {
mul_m4_m4m4(r_bpt->loc_mat, parent_pose_mat, offs_bone);
}
- /* Else (i.e. default, usual case), just use the same matrix for rotation/scaling, and location. */
+ /* Else (i.e. default, usual case),
+ * just use the same matrix for rotation/scaling, and location. */
else {
copy_m4_m4(r_bpt->loc_mat, r_bpt->rotscale_mat);
}
@@ -1833,6 +1932,33 @@ void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[3][3], bool use_compat
}
/**
+ * Same as #BKE_object_rot_to_mat3().
+ */
+void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float mat[3][3])
+{
+ /* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
+ if (pchan->rotmode > 0) {
+ /* euler rotations (will cause gimble lock,
+ * but this can be alleviated a bit with rotation orders) */
+ eulO_to_mat3(mat, pchan->eul, pchan->rotmode);
+ }
+ else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
+ /* axis-angle - not really that great for 3D-changing orientations */
+ axis_angle_to_mat3(mat, pchan->rotAxis, pchan->rotAngle);
+ }
+ else {
+ /* quats are normalized before use to eliminate scaling issues */
+ float quat[4];
+
+ /* NOTE: we now don't normalize the stored values anymore,
+ * since this was kindof evil in some cases but if this proves to be too problematic,
+ * switch back to the old system of operating directly on the stored copy. */
+ normalize_qt_qt(quat, pchan->quat);
+ quat_to_mat3(mat, quat);
+ }
+}
+
+/**
* Apply a 4x4 matrix to the pose bone,
* similar to #BKE_object_apply_mat4().
*/
@@ -1902,7 +2028,8 @@ void BKE_rotMode_change_values(
quat_to_axis_angle(axis, angle, quat);
}
- /* when converting to axis-angle, we need a special exception for the case when there is no axis */
+ /* When converting to axis-angle,
+ * we need a special exception for the case when there is no axis. */
if (IS_EQF(axis[0], axis[1]) && IS_EQF(axis[1], axis[2])) {
/* for now, rotate around y-axis then (so that it simply becomes the roll) */
axis[1] = 1.0f;
@@ -1957,50 +2084,72 @@ void mat3_vec_to_roll(const float mat[3][3], const float vec[3], float *r_roll)
}
/* Calculates the rest matrix of a bone based on its vector and a roll around that vector. */
-/* Given v = (v.x, v.y, v.z) our (normalized) bone vector, we want the rotation matrix M
- * from the Y axis (so that M * (0, 1, 0) = v).
- * -> The rotation axis a lays on XZ plane, and it is orthonormal to v, hence to the projection of v onto XZ plane.
- * -> a = (v.z, 0, -v.x)
+/**
+ * Given `v = (v.x, v.y, v.z)` our (normalized) bone vector, we want the rotation matrix M
+ * from the Y axis (so that `M * (0, 1, 0) = v`).
+ * - The rotation axis a lays on XZ plane, and it is orthonormal to v,
+ * hence to the projection of v onto XZ plane.
+ * - `a = (v.z, 0, -v.x)`
+ *
* We know a is eigenvector of M (so M * a = a).
- * Finally, we have w, such that M * w = (0, 1, 0) (i.e. the vector that will be aligned with Y axis once transformed).
+ * Finally, we have w, such that M * w = (0, 1, 0)
+ * (i.e. the vector that will be aligned with Y axis once transformed).
* We know w is symmetric to v by the Y axis.
- * -> w = (-v.x, v.y, -v.z)
+ * - `w = (-v.x, v.y, -v.z)`
*
* Solving this, we get (x, y and z being the components of v):
+ * <pre>
* ┌ (x^2 * y + z^2) / (x^2 + z^2), x, x * z * (y - 1) / (x^2 + z^2) ┐
* M = │ x * (y^2 - 1) / (x^2 + z^2), y, z * (y^2 - 1) / (x^2 + z^2) │
* └ x * z * (y - 1) / (x^2 + z^2), z, (x^2 + z^2 * y) / (x^2 + z^2) ┘
+ * </pre>
*
- * This is stable as long as v (the bone) is not too much aligned with +/-Y (i.e. x and z components
- * are not too close to 0).
+ * This is stable as long as v (the bone) is not too much aligned with +/-Y
+ * (i.e. x and z components are not too close to 0).
+ *
+ * Since v is normalized, we have `x^2 + y^2 + z^2 = 1`,
+ * hence `x^2 + z^2 = 1 - y^2 = (1 - y)(1 + y)`.
*
- * Since v is normalized, we have x^2 + y^2 + z^2 = 1, hence x^2 + z^2 = 1 - y^2 = (1 - y)(1 + y).
* This allows to simplifies M like this:
+ * <pre>
* ┌ 1 - x^2 / (1 + y), x, -x * z / (1 + y) ┐
* M = │ -x, y, -z │
* └ -x * z / (1 + y), z, 1 - z^2 / (1 + y) ┘
+ * </pre>
*
- * Written this way, we see the case v = +Y is no more a singularity. The only one remaining is the bone being
- * aligned with -Y.
+ * Written this way, we see the case v = +Y is no more a singularity.
+ * The only one
+ * remaining is the bone being aligned with -Y.
*
- * Let's handle the asymptotic behavior when bone vector is reaching the limit of y = -1. Each of the four corner
- * elements can vary from -1 to 1, depending on the axis a chosen for doing the rotation. And the "rotation" here
- * is in fact established by mirroring XZ plane by that given axis, then inversing the Y-axis.
- * For sufficiently small x and z, and with y approaching -1, all elements but the four corner ones of M
- * will degenerate. So let's now focus on these corner elements.
+ * Let's handle
+ * the asymptotic behavior when bone vector is reaching the limit of y = -1.
+ * Each of the four corner elements can vary from -1 to 1,
+ * depending on the axis a chosen for doing the rotation.
+ * And the "rotation" here is in fact established by mirroring XZ plane by that given axis,
+ * then inversing the Y-axis.
+ * For sufficiently small x and z, and with y approaching -1,
+ * all elements but the four corner ones of M will degenerate.
+ * So let's now focus on these corner elements.
*
- * We rewrite M so that it only contains its four corner elements, and combine the 1 / (1 + y) factor:
+ * We rewrite M so that it only contains its four corner elements,
+ * and combine the `1 / (1 + y)` factor:
+ * <pre>
* ┌ 1 + y - x^2, -x * z ┐
* M* = 1 / (1 + y) * │ │
* └ -x * z, 1 + y - z^2 ┘
+ * </pre>
+ *
+ * When y is close to -1, computing 1 / (1 + y) will cause severe numerical instability,
+ * so we ignore it and normalize M instead.
+ * We know `y^2 = 1 - (x^2 + z^2)`, and `y < 0`, hence `y = -sqrt(1 - (x^2 + z^2))`.
*
- * When y is close to -1, computing 1 / (1 + y) will cause severe numerical instability, so we ignore it and
- * normalize M instead. We know y^2 = 1 - (x^2 + z^2), and y < 0, hence y = -sqrt(1 - (x^2 + z^2)).
* Since x and z are both close to 0, we apply the binomial expansion to the first order:
- * y = -sqrt(1 - (x^2 + z^2)) = -1 + (x^2 + z^2) / 2. Which gives:
+ * `y = -sqrt(1 - (x^2 + z^2)) = -1 + (x^2 + z^2) / 2`. Which gives:
+ * <pre>
* ┌ z^2 - x^2, -2 * x * z ┐
* M* = 1 / (x^2 + z^2) * │ │
* └ -2 * x * z, x^2 - z^2 ┘
+ * </pre>
*/
void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float mat[3][3])
{
@@ -2200,13 +2349,14 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
}
}
- /* constraints - proxy constraints are flushed... local ones are added after
- * 1. extract constraints not from proxy (CONSTRAINT_PROXY_LOCAL) from pchan's constraints
- * 2. copy proxy-pchan's constraints on-to new
- * 3. add extracted local constraints back on top
+ /* Constraints - proxy constraints are flushed... local ones are added after
+ * 1: extract constraints not from proxy (CONSTRAINT_PROXY_LOCAL) from pchan's constraints.
+ * 2: copy proxy-pchan's constraints on-to new.
+ * 3: add extracted local constraints back on top.
*
- * Note for BKE_constraints_copy: when copying constraints, disable 'do_extern' otherwise
- * we get the libs direct linked in this blend.
+ * Note for BKE_constraints_copy:
+ * When copying constraints, disable 'do_extern' otherwise
+ * we get the libs direct linked in this blend.
*/
BKE_constraints_proxylocal_extract(&proxylocal_constraints, &pchan->constraints);
BKE_constraints_copy(&pchanw.constraints, &pchanp->constraints, false);
@@ -2295,7 +2445,8 @@ static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int
}
/**
- * Clear pointers of object's pose (needed in remap case, since we cannot always wait for a complete pose rebuild).
+ * Clear pointers of object's pose
+ * (needed in remap case, since we cannot always wait for a complete pose rebuild).
*/
void BKE_pose_clear_pointers(bPose *pose)
{
@@ -2381,7 +2532,8 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
/* synchronize protected layers with proxy */
/* HACK! To preserve 2.7x behavior that you always can pose even locked bones,
* do not do any restoration if this is a COW temp copy! */
- /* Switched back to just NO_MAIN tag, for some reasons (c) using COW tag was working this morning, but not anymore... */
+ /* Switched back to just NO_MAIN tag, for some reasons (c)
+ * using COW tag was working this morning, but not anymore... */
if (ob->proxy != NULL && (ob->id.tag & LIB_TAG_NO_MAIN) == 0) {
BKE_object_copy_proxy_drivers(ob, ob->proxy);
pose_proxy_synchronize(ob, ob->proxy, arm->layer_protected);
@@ -2392,7 +2544,8 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
pose->flag &= ~POSE_RECALC;
pose->flag |= POSE_WAS_REBUILT;
- /* Rebuilding poses forces us to also rebuild the dependency graph, since there is one node per pose/bone... */
+ /* Rebuilding poses forces us to also rebuild the dependency graph,
+ * since there is one node per pose/bone. */
if (bmain != NULL) {
DEG_relations_tag_update(bmain);
}
@@ -2401,7 +2554,7 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
/* ********************** THE POSE SOLVER ******************* */
/* loc/rot/size to given mat4 */
-void BKE_pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4])
+void BKE_pchan_to_mat4(const bPoseChannel *pchan, float chan_mat[4][4])
{
float smat[3][3];
float rmat[3][3];
@@ -2410,26 +2563,8 @@ void BKE_pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4])
/* get scaling matrix */
size_to_mat3(smat, pchan->size);
- /* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
- if (pchan->rotmode > 0) {
- /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
- eulO_to_mat3(rmat, pchan->eul, pchan->rotmode);
- }
- else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
- /* axis-angle - not really that great for 3D-changing orientations */
- axis_angle_to_mat3(rmat, pchan->rotAxis, pchan->rotAngle);
- }
- else {
- /* quats are normalized before use to eliminate scaling issues */
- float quat[4];
-
- /* NOTE: we now don't normalize the stored values anymore, since this was kindof evil in some cases
- * but if this proves to be too problematic, switch back to the old system of operating directly on
- * the stored copy
- */
- normalize_qt_qt(quat, pchan->quat);
- quat_to_mat3(rmat, quat);
- }
+ /* get rotation matrix */
+ BKE_pchan_rot_to_mat3(pchan, rmat);
/* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */
mul_m3_m3m3(tmat, rmat, smat);
@@ -2548,7 +2683,8 @@ void BKE_pose_where_is(struct Depsgraph *depsgraph, Scene *scene, Object *ob)
return;
}
if ((ob->pose == NULL) || (ob->pose->flag & POSE_RECALC)) {
- /* WARNING! passing NULL bmain here means we won't tag depsgraph's as dirty - hopefully this is OK. */
+ /* WARNING! passing NULL bmain here means we won't tag depsgraph's as dirty -
+ * hopefully this is OK. */
BKE_pose_rebuild(NULL, ob, arm, true);
}
@@ -2615,7 +2751,8 @@ static int minmax_armature(Object *ob, float r_min[3], float r_max[3])
{
bPoseChannel *pchan;
- /* For now, we assume BKE_pose_where_is has already been called (hence we have valid data in pachan). */
+ /* For now, we assume BKE_pose_where_is has already been called
+ * (hence we have valid data in pachan). */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
minmax_v3v3_v3(r_min, r_max, pchan->pose_head);
minmax_v3v3_v3(r_min, r_max, pchan->pose_tail);
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index 5af818b9a91..c71c2dc86cf 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -165,7 +165,8 @@ static void splineik_init_tree_from_pchan(Scene *UNUSED(scene),
CLAMP_MIN(ikData->points[segcount], 0.0f);
/* make a new Spline-IK chain, and store it in the IK chains */
- /* TODO: we should check if there is already an IK chain on this, since that would take precedence... */
+ /* TODO: we should check if there is already an IK chain on this,
+ * since that would take precedence... */
{
/* make new tree */
tSplineIK_Tree *tree = MEM_callocN(sizeof(tSplineIK_Tree), "SplineIK Tree");
@@ -199,7 +200,8 @@ static void splineik_init_tree(Scene *scene, Object *ob, float UNUSED(ctime))
{
bPoseChannel *pchan;
- /* find the tips of Spline IK chains, which are simply the bones which have been tagged as such */
+ /* find the tips of Spline IK chains,
+ * which are simply the bones which have been tagged as such */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->constflag & PCHAN_HAS_SPLINEIK) {
splineik_init_tree_from_pchan(scene, ob, pchan);
@@ -330,9 +332,9 @@ static void splineik_evaluate_bone(
}
}
- /* step 2: determine the implied transform from these endpoints
- * - splineVec: the vector direction that the spline applies on the bone
- * - scaleFac: the factor that the bone length is scaled by to get the desired amount
+ /* Step 2: determine the implied transform from these endpoints.
+ * - splineVec: the vector direction that the spline applies on the bone.
+ * - scaleFac: the factor that the bone length is scaled by to get the desired amount.
*/
sub_v3_v3v3(splineVec, poseTail, poseHead);
scaleFac = len_v3(splineVec) / pchan->bone->length;
@@ -340,8 +342,10 @@ static void splineik_evaluate_bone(
/* Adjust the scale factor towards the neutral state when rolling off the curve end. */
scaleFac = interpf(scaleFac, baseScale, tailBlendFac);
- /* step 3: compute the shortest rotation needed to map from the bone rotation to the current axis
- * - this uses the same method as is used for the Damped Track Constraint (see the code there for details)
+ /* Step 3: compute the shortest rotation needed
+ * to map from the bone rotation to the current axis.
+ * - this uses the same method as is used for the Damped Track Constraint
+ * (see the code there for details).
*/
{
float dmat[3][3], rmat[3][3];
@@ -353,7 +357,8 @@ static void splineik_evaluate_bone(
mul_m3_m4m4(basePoseMat, state->locrot_offset, pchan->pose_mat);
normalize_m3_m3(rmat, basePoseMat);
- /* also, normalize the orientation imposed by the bone, now that we've extracted the scale factor */
+ /* Also, normalize the orientation imposed by the bone,
+ * now that we've extracted the scale factor. */
normalize_v3(splineVec);
/* calculate smallest axis-angle rotation necessary for getting from the
@@ -375,12 +380,12 @@ static void splineik_evaluate_bone(
*/
axis_angle_to_mat3(dmat, raxis, rangle);
- /* combine these rotations so that the y-axis of the bone is now aligned as the spline dictates,
- * while still maintaining roll control from the existing bone animation
- */
+ /* Combine these rotations so that the y-axis of the bone is now aligned as the
+ * spline dictates, while still maintaining roll control from the existing bone animation. */
mul_m3_m3m3(poseMat, dmat, rmat);
- normalize_m3(
- poseMat); /* attempt to reduce shearing, though I doubt this'll really help too much now... */
+
+ /* attempt to reduce shearing, though I doubt this'll really help too much now... */
+ normalize_m3(poseMat);
mul_m3_m3m3(basePoseMat, dmat, basePoseMat);
@@ -539,7 +544,8 @@ static void splineik_execute_tree(
while ((tree = pchan_root->siktree.first) != NULL) {
int i;
- /* Firstly, calculate the bone matrix the standard way, since this is needed for roll control. */
+ /* Firstly, calculate the bone matrix the standard way,
+ * since this is needed for roll control. */
for (i = tree->chainlen - 1; i >= 0; i--) {
BKE_pose_where_is_bone(depsgraph, scene, ob, tree->chain[i], ctime, 1);
}
@@ -549,8 +555,8 @@ static void splineik_execute_tree(
if (splineik_evaluate_init(tree, &state)) {
/* Walk over each bone in the chain, calculating the effects of spline IK
- * - the chain is traversed in the opposite order to storage order (i.e. parent to children)
- * so that dependencies are correct
+ * - the chain is traversed in the opposite order to storage order (i.e. parent to children)
+ * so that dependencies are correct
*/
for (i = tree->chainlen - 1; i >= 0; i--) {
bPoseChannel *pchan = tree->chain[i];
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 789d7a6a05d..48b271cf277 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -75,7 +75,9 @@ void BKE_blender_free(void)
{
/* samples are in a global list..., also sets G_MAIN->sound->sample NULL */
- BKE_studiolight_free(); /* needs to run before main free as wm is still referenced for icons preview jobs */
+ /* Needs to run before main free as wm is still referenced for icons preview jobs. */
+ BKE_studiolight_free();
+
BKE_main_free(G_MAIN);
G_MAIN = NULL;
@@ -95,7 +97,6 @@ void BKE_blender_free(void)
BLI_callback_global_finalize();
- BKE_sequencer_cache_destruct();
IMB_moviecache_destruct();
free_nodesystem();
diff --git a/source/blender/blenkernel/intern/blender_copybuffer.c b/source/blender/blenkernel/intern/blender_copybuffer.c
index c801c1780c8..32c6f74dc2d 100644
--- a/source/blender/blenkernel/intern/blender_copybuffer.c
+++ b/source/blender/blenkernel/intern/blender_copybuffer.c
@@ -110,7 +110,8 @@ bool BKE_copybuffer_read(Main *bmain_dst,
}
/**
- * \return Number of IDs directly pasted from the buffer (does not includes indirectly pulled out ones).
+ * \return Number of IDs directly pasted from the buffer
+ * (does not includes indirectly pulled out ones).
*/
int BKE_copybuffer_paste(bContext *C,
const char *libname,
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 383d8e6bf61..d1a3045a829 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -152,7 +152,8 @@ static void setup_app_data(bContext *C,
/* no load screens? */
if (mode != LOAD_UI) {
/* Logic for 'track_undo_scene' is to keep using the scene which the active screen has,
- * as long as the scene associated with the undo operation is visible in one of the open windows.
+ * as long as the scene associated with the undo operation is visible
+ * in one of the open windows.
*
* - 'curscreen->scene' - scene the user is currently looking at.
* - 'bfd->curscene' - scene undo-step was created in.
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index fc3e12accea..becef327fab 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -230,7 +230,7 @@ static int rule_avoid_collision(BoidRule *rule,
int n, neighbors = 0, nearest = 0;
int ret = 0;
- //check deflector objects first
+ // check deflector objects first
if (acbr->options & BRULE_ACOLL_WITH_DEFLECTORS && bbd->sim->colliders) {
ParticleCollision col;
BVHTreeRayHit hit;
@@ -292,7 +292,7 @@ static int rule_avoid_collision(BoidRule *rule,
}
}
- //check boids in own system
+ // check boids in own system
if (acbr->options & BRULE_ACOLL_WITH_BOIDS) {
neighbors = BLI_kdtree_3d_range_search_with_len_squared_cb(bbd->sim->psys->tree,
pa->prev_state.co,
@@ -820,11 +820,11 @@ static boid_rule_cb boid_rules[] = {
rule_follow_leader,
rule_average_speed,
rule_fight,
- //rule_help,
- //rule_protect,
- //rule_hide,
- //rule_follow_path,
- //rule_follow_wall,
+ // rule_help,
+ // rule_protect,
+ // rule_hide,
+ // rule_follow_path,
+ // rule_follow_wall,
};
static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData *pa)
@@ -1069,7 +1069,7 @@ static BoidState *get_boid_state(BoidSettings *boids, ParticleData *pa)
return state;
}
-//static int boid_condition_is_true(BoidCondition *cond)
+// static int boid_condition_is_true(BoidCondition *cond)
//{
// /* TODO */
// return 0;
@@ -1085,7 +1085,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
BoidParticle *bpa = pa->boid;
ParticleSystem *psys = bbd->sim->psys;
int rand;
- //BoidCondition *cond;
+ // BoidCondition *cond;
if (bpa->data.health <= 0.0f) {
pa->alive = PARS_DYING;
@@ -1093,9 +1093,9 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
return;
}
- //planned for near future
- //cond = state->conditions.first;
- //for (; cond; cond=cond->next) {
+ // planned for near future
+ // cond = state->conditions.first;
+ // for (; cond; cond=cond->next) {
// if (boid_condition_is_true(cond)) {
// pa->boid->state_id = cond->state_id;
// state = get_boid_state(boids, pa);
@@ -1420,7 +1420,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
madd_v3_v3fl(pa->state.vel, acc, dtime);
- //if (bpa->data.mode != eBoidMode_InAir)
+ // if (bpa->data.mode != eBoidMode_InAir)
bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
/* change modes, constrain movement & keep track of down vector */
@@ -1506,20 +1506,20 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
}
case eBoidMode_Climbing: {
boid_climb(boids, pa, ground_co, ground_nor);
- //float nor[3];
- //copy_v3_v3(nor, ground_nor);
+ // float nor[3];
+ // copy_v3_v3(nor, ground_nor);
///* gather apparent gravity to r_ve */
- //madd_v3_v3fl(pa->r_ve, ground_nor, -1.0);
- //normalize_v3(pa->r_ve);
+ // madd_v3_v3fl(pa->r_ve, ground_nor, -1.0);
+ // normalize_v3(pa->r_ve);
///* raise boid it's size from surface */
- //mul_v3_fl(nor, pa->size * boids->height);
- //add_v3_v3v3(pa->state.co, ground_co, nor);
+ // mul_v3_fl(nor, pa->size * boids->height);
+ // add_v3_v3v3(pa->state.co, ground_co, nor);
///* remove normal component from velocity */
- //project_v3_v3v3(v, pa->state.vel, ground_nor);
- //sub_v3_v3v3(pa->state.vel, pa->state.vel, v);
+ // project_v3_v3v3(v, pa->state.vel, ground_nor);
+ // sub_v3_v3v3(pa->state.vel, pa->state.vel, v);
break;
}
case eBoidMode_OnLand: {
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index dcca6e2bf84..e28f1fc566f 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -148,7 +148,8 @@ void BKE_brush_init(Brush *brush)
}
/**
- * \note Resulting brush will have two users: one as a fake user, another is assumed to be used by the caller.
+ * \note Resulting brush will have two users: one as a fake user,
+ * another is assumed to be used by the caller.
*/
Brush *BKE_brush_add(Main *bmain, const char *name, const eObjectMode ob_mode)
{
@@ -584,8 +585,10 @@ struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mo
}
/**
- * Only copy internal data of Brush ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Brush ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index ab7baf6ce7a..8600d60c5c6 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -568,7 +568,8 @@ BVHTree *bvhtree_from_editmesh_verts(BVHTreeFromEditMesh *data,
* Builds a bvh tree where nodes are the given vertices (note: does not copy given mverts!).
* \param vert_allocated: if true, vert freeing will be done when freeing data.
* \param verts_mask: if not null, true elements give which vert to add to BVH tree.
- * \param verts_num_active: if >= 0, number of active verts to add to BVH tree (else will be computed from mask).
+ * \param verts_num_active: if >= 0, number of active verts to add to BVH tree
+ * (else will be computed from mask).
*/
BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
const MVert *vert,
@@ -758,7 +759,8 @@ BVHTree *bvhtree_from_editmesh_edges(BVHTreeFromEditMesh *data,
* \param vert, vert_allocated: if true, elem freeing will be done when freeing data.
* \param edge, edge_allocated: if true, elem freeing will be done when freeing data.
* \param edges_mask: if not null, true elements give which vert to add to BVH tree.
- * \param edges_num_active: if >= 0, number of active edges to add to BVH tree (else will be computed from mask).
+ * \param edges_num_active: if >= 0, number of active edges to add to BVH tree
+ * (else will be computed from mask).
*/
BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
const MVert *vert,
@@ -860,11 +862,13 @@ static void bvhtree_from_mesh_faces_setup_data(BVHTreeFromMesh *data,
}
/**
- * Builds a bvh tree where nodes are the given tessellated faces (note: does not copy given mfaces!).
+ * Builds a bvh tree where nodes are the given tessellated faces
+ * (note: does not copy given mfaces!).
* \param vert_allocated: if true, vert freeing will be done when freeing data.
* \param face_allocated: if true, face freeing will be done when freeing data.
* \param faces_mask: if not null, true elements give which faces to add to BVH tree.
- * \param faces_num_active: if >= 0, number of active faces to add to BVH tree (else will be computed from mask).
+ * \param faces_num_active: if >= 0, number of active faces to add to BVH tree
+ * (else will be computed from mask).
*/
BVHTree *bvhtree_from_mesh_faces_ex(BVHTreeFromMesh *data,
const MVert *vert,
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index 4fe8cabde65..44e951a43da 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -21,18 +21,21 @@
* \ingroup bke
*/
+#include <string.h>
+
#include "DNA_anim_types.h"
#include "DNA_cachefile_types.h"
#include "DNA_constraint_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "BLI_utildefines.h"
#include "BLI_fileops.h"
+#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_threads.h"
-#include "BLI_utildefines.h"
#include "BKE_animsys.h"
#include "BKE_cachefile.h"
@@ -41,10 +44,13 @@
#include "BKE_modifier.h"
#include "BKE_scene.h"
+#include "DEG_depsgraph_query.h"
+
#ifdef WITH_ALEMBIC
# include "ABC_alembic.h"
#endif
+/* TODO: make this per cache file to avoid global locks. */
static SpinLock spin;
void BKE_cachefiles_init(void)
@@ -57,6 +63,94 @@ void BKE_cachefiles_exit(void)
BLI_spin_end(&spin);
}
+void BKE_cachefile_reader_open(CacheFile *cache_file,
+ struct CacheReader **reader,
+ Object *object,
+ const char *object_path)
+{
+#ifdef WITH_ALEMBIC
+ BLI_assert(cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE);
+
+ if (cache_file->handle == NULL) {
+ return;
+ }
+
+ /* Open Alembic cache reader. */
+ *reader = CacheReader_open_alembic_object(cache_file->handle, *reader, object, object_path);
+
+ /* Multiple modifiers and constraints can call this function concurrently. */
+ BLI_spin_lock(&spin);
+ if (*reader) {
+ /* Register in set so we can free it when the cache file changes. */
+ if (cache_file->handle_readers == NULL) {
+ cache_file->handle_readers = BLI_gset_ptr_new("CacheFile.handle_readers");
+ }
+ BLI_gset_reinsert(cache_file->handle_readers, reader, NULL);
+ }
+ else if (cache_file->handle_readers) {
+ /* Remove in case CacheReader_open_alembic_object free the existing reader. */
+ BLI_gset_remove(cache_file->handle_readers, reader, NULL);
+ }
+ BLI_spin_unlock(&spin);
+#else
+ UNUSED_VARS(cache_file, reader, object, object_path);
+#endif
+}
+
+void BKE_cachefile_reader_free(CacheFile *cache_file, struct CacheReader **reader)
+{
+#ifdef WITH_ALEMBIC
+ BLI_assert(cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE);
+
+ if (*reader != NULL) {
+ CacheReader_free(*reader);
+ *reader = NULL;
+
+ /* Multiple modifiers and constraints can call this function concurrently. */
+ BLI_spin_lock(&spin);
+ if (cache_file->handle_readers) {
+ BLI_gset_remove(cache_file->handle_readers, reader, NULL);
+ }
+ BLI_spin_unlock(&spin);
+ }
+#else
+ UNUSED_VARS(cache_file, reader);
+#endif
+}
+
+static void cachefile_handle_free(CacheFile *cache_file)
+{
+#ifdef WITH_ALEMBIC
+ /* Free readers in all modifiers and constraints that use the handle, before
+ * we free the handle itself. */
+ BLI_spin_lock(&spin);
+ if (cache_file->handle_readers) {
+ GSetIterator gs_iter;
+ GSET_ITER (gs_iter, cache_file->handle_readers) {
+ struct CacheReader **reader = BLI_gsetIterator_getKey(&gs_iter);
+ if (*reader != NULL) {
+ CacheReader_free(*reader);
+ *reader = NULL;
+ }
+ }
+
+ BLI_gset_free(cache_file->handle_readers, NULL);
+ cache_file->handle_readers = NULL;
+ }
+ BLI_spin_unlock(&spin);
+
+ /* Free handle. */
+ if (cache_file->handle) {
+ ABC_free_handle(cache_file->handle);
+ cache_file->handle = NULL;
+ }
+
+ cache_file->handle_filepath[0] = '\0';
+#else
+ UNUSED_VARS(cache_file);
+#endif
+}
+
void *BKE_cachefile_add(Main *bmain, const char *name)
{
CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, name, 0);
@@ -68,43 +162,31 @@ void *BKE_cachefile_add(Main *bmain, const char *name)
void BKE_cachefile_init(CacheFile *cache_file)
{
- cache_file->handle = NULL;
cache_file->filepath[0] = '\0';
cache_file->override_frame = false;
cache_file->frame = 0.0f;
cache_file->is_sequence = false;
cache_file->scale = 1.0f;
- cache_file->handle_mutex = BLI_mutex_alloc();
BLI_listbase_clear(&cache_file->object_paths);
+
+ cache_file->handle = NULL;
+ cache_file->handle_filepath[0] = '\0';
+ cache_file->handle_readers = NULL;
}
/** Free (or release) any data used by this cachefile (does not free the cachefile itself). */
void BKE_cachefile_free(CacheFile *cache_file)
{
BKE_animdata_free((ID *)cache_file, false);
-
- if (cache_file->id.tag & LIB_TAG_NO_MAIN) {
- /* CoW/no-main copies reuse the existing ArchiveReader and mutex */
- return;
- }
-
- if (cache_file->handle) {
-#ifdef WITH_ALEMBIC
- ABC_free_handle(cache_file->handle);
-#endif
- cache_file->handle = NULL;
- }
- if (cache_file->handle_mutex) {
- BLI_mutex_free(cache_file->handle_mutex);
- cache_file->handle_mutex = NULL;
- }
-
+ cachefile_handle_free(cache_file);
BLI_freelistN(&cache_file->object_paths);
}
/**
- * Only copy internal data of CacheFile ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of CacheFile ID from source to already
+ * allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -115,13 +197,8 @@ void BKE_cachefile_copy_data(Main *UNUSED(bmain),
const CacheFile *UNUSED(cache_file_src),
const int UNUSED(flag))
{
- if (cache_file_dst->id.tag & LIB_TAG_NO_MAIN) {
- /* CoW/no-main copies reuse the existing ArchiveReader and mutex */
- return;
- }
-
cache_file_dst->handle = NULL;
- cache_file_dst->handle_mutex = NULL;
+ cache_file_dst->handle_readers = NULL;
BLI_duplicatelist(&cache_file_dst->object_paths, &cache_file_dst->object_paths);
}
@@ -137,72 +214,51 @@ void BKE_cachefile_make_local(Main *bmain, CacheFile *cache_file, const bool lib
BKE_id_make_local_generic(bmain, &cache_file->id, true, lib_local);
}
-void BKE_cachefile_reload(const Main *bmain, CacheFile *cache_file)
+void BKE_cachefile_reload(Depsgraph *depsgraph, CacheFile *cache_file)
{
- char filepath[FILE_MAX];
-
- BLI_strncpy(filepath, cache_file->filepath, sizeof(filepath));
- BLI_path_abs(filepath, ID_BLEND_PATH(bmain, &cache_file->id));
-
-#ifdef WITH_ALEMBIC
- if (cache_file->handle) {
- ABC_free_handle(cache_file->handle);
+ /* To force reload, free the handle and tag depsgraph to load it again. */
+ CacheFile *cache_file_eval = (CacheFile *)DEG_get_evaluated_id(depsgraph, &cache_file->id);
+ if (cache_file_eval) {
+ cachefile_handle_free(cache_file_eval);
}
- cache_file->handle = ABC_create_handle(filepath, &cache_file->object_paths);
-#endif
+ DEG_id_tag_update(&cache_file->id, ID_RECALC_COPY_ON_WRITE);
}
-void BKE_cachefile_ensure_handle(const Main *bmain, CacheFile *cache_file)
+void BKE_cachefile_eval(Main *bmain, Depsgraph *depsgraph, CacheFile *cache_file)
{
- BLI_spin_lock(&spin);
- if (cache_file->handle_mutex == NULL) {
- cache_file->handle_mutex = BLI_mutex_alloc();
- }
- BLI_spin_unlock(&spin);
-
- BLI_mutex_lock(cache_file->handle_mutex);
+ BLI_assert(cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE);
- if (cache_file->handle == NULL) {
- /* Assigning to a CoW copy is a bad idea; assign to the original instead. */
- BLI_assert((cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0);
- BKE_cachefile_reload(bmain, cache_file);
+ /* Compute filepath. */
+ char filepath[FILE_MAX];
+ if (!BKE_cachefile_filepath_get(bmain, depsgraph, cache_file, filepath)) {
+ return;
}
- BLI_mutex_unlock(cache_file->handle_mutex);
-}
-
-void BKE_cachefile_update_frame(
- Main *bmain, struct Depsgraph *depsgraph, Scene *scene, const float ctime, const float fps)
-{
- CacheFile *cache_file;
- char filename[FILE_MAX];
-
- for (cache_file = bmain->cachefiles.first; cache_file; cache_file = cache_file->id.next) {
- /* TODO: dependency graph should be updated to do drivers on cachefile.
- * Execute drivers only, as animation has already been done. */
- BKE_animsys_evaluate_animdata(
- depsgraph, scene, &cache_file->id, cache_file->adt, ctime, ADT_RECALC_DRIVERS);
-
- if (!cache_file->is_sequence) {
- continue;
- }
+ /* Test if filepath change or if we can keep the existing handle. */
+ if (STREQ(cache_file->handle_filepath, filepath)) {
+ return;
+ }
- const float time = BKE_cachefile_time_offset(cache_file, ctime, fps);
+ cachefile_handle_free(cache_file);
+ BLI_freelistN(&cache_file->object_paths);
- if (BKE_cachefile_filepath_get(bmain, cache_file, time, filename)) {
- BKE_cachefile_clean(bmain, cache_file);
#ifdef WITH_ALEMBIC
- ABC_free_handle(cache_file->handle);
- cache_file->handle = ABC_create_handle(filename, NULL);
+ cache_file->handle = ABC_create_handle(filepath, &cache_file->object_paths);
+ BLI_strncpy(cache_file->handle_filepath, filepath, FILE_MAX);
#endif
- }
+
+ if (DEG_is_active(depsgraph)) {
+ /* Flush object paths back to original datablock for UI. */
+ CacheFile *cache_file_orig = (CacheFile *)DEG_get_original_id(&cache_file->id);
+ BLI_freelistN(&cache_file_orig->object_paths);
+ BLI_duplicatelist(&cache_file_orig->object_paths, &cache_file->object_paths);
}
}
bool BKE_cachefile_filepath_get(const Main *bmain,
+ const Depsgraph *depsgraph,
const CacheFile *cache_file,
- float frame,
char r_filepath[FILE_MAX])
{
BLI_strncpy(r_filepath, cache_file->filepath, FILE_MAX);
@@ -212,6 +268,11 @@ bool BKE_cachefile_filepath_get(const Main *bmain,
int frame_len;
if (cache_file->is_sequence && BLI_path_frame_get(r_filepath, &fframe, &frame_len)) {
+ Scene *scene = DEG_get_evaluated_scene(depsgraph);
+ const float ctime = BKE_scene_frame_get(scene);
+ const float fps = (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base);
+ const float frame = BKE_cachefile_time_offset(cache_file, ctime, fps);
+
char ext[32];
BLI_path_frame_strip(r_filepath, ext);
BLI_path_frame(r_filepath, frame, frame_len);
@@ -224,47 +285,9 @@ bool BKE_cachefile_filepath_get(const Main *bmain,
return true;
}
-float BKE_cachefile_time_offset(CacheFile *cache_file, const float time, const float fps)
+float BKE_cachefile_time_offset(const CacheFile *cache_file, const float time, const float fps)
{
const float time_offset = cache_file->frame_offset / fps;
const float frame = (cache_file->override_frame ? cache_file->frame : time);
return cache_file->is_sequence ? frame : frame / fps - time_offset;
}
-
-/* TODO(kevin): replace this with some depsgraph mechanism, or something similar. */
-void BKE_cachefile_clean(struct Main *bmain, CacheFile *cache_file)
-{
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md = modifiers_findByType(ob, eModifierType_MeshSequenceCache);
-
- if (md) {
- MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
-
- if (cache_file == mcmd->cache_file) {
-#ifdef WITH_ALEMBIC
- if (mcmd->reader != NULL) {
- CacheReader_free(mcmd->reader);
- }
-#endif
- mcmd->reader = NULL;
- }
- }
-
- for (bConstraint *con = ob->constraints.first; con; con = con->next) {
- if (con->type != CONSTRAINT_TYPE_TRANSFORM_CACHE) {
- continue;
- }
-
- bTransformCacheConstraint *data = con->data;
-
- if (cache_file == data->cache_file) {
-#ifdef WITH_ALEMBIC
- if (data->reader != NULL) {
- CacheReader_free(data->reader);
- }
-#endif
- data->reader = NULL;
- }
- }
- }
-}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 59811cfe373..25399d342e1 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -88,8 +88,10 @@ void *BKE_camera_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Camera ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Camera ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index ea3834be68a..667219e0eec 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -385,7 +385,8 @@ static void cdDM_foreachMappedLoop(DerivedMesh *dm,
void *userData,
DMForeachFlag flag)
{
- /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData, EditDerivedBMesh would
+ /* We can't use dm->getLoopDataLayout(dm) here,
+ * we want to always access dm->loopData, EditDerivedBMesh would
* return loop data from bmesh itself. */
const float(*lnors)[3] = (flag & DM_FOREACH_USE_NORMAL) ? DM_get_loop_data_layer(dm, CD_NORMAL) :
NULL;
@@ -633,7 +634,8 @@ DerivedMesh *CDDM_from_mesh_ex(Mesh *mesh,
if (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) {
dm->dirty |= DM_DIRTY_NORMALS;
}
- /* TODO DM_DIRTY_TESS_CDLAYERS ? Maybe not though, since we probably want to switch to looptris ? */
+ /* TODO DM_DIRTY_TESS_CDLAYERS ? Maybe not though,
+ * since we probably want to switch to looptris? */
CustomData_merge(&mesh->vdata, &dm->vertData, cddata_masks.vmask, alloctype, mesh->totvert);
CustomData_merge(&mesh->edata, &dm->edgeData, cddata_masks.emask, alloctype, mesh->totedge);
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 6db5745dd42..fcc0e1856af 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -432,9 +432,9 @@ void clothModifier_do(ClothModifierData *clmd,
else if (cache_result == PTCACHE_READ_OLD) {
BKE_cloth_solver_set_positions(clmd);
}
- else if (/*ob->id.lib ||*/ (
- cache->flag &
- PTCACHE_BAKED)) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */
+ else if (
+ /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */
+ /*ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED)) {
/* if baked and nothing in cache, do nothing */
BKE_ptcache_invalidate(cache);
return;
@@ -722,7 +722,8 @@ static void cloth_apply_vgroup(ClothModifierData *clmd, Mesh *mesh)
}
if (clmd->sim_parms->vgroup_shrink > 0) {
if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shrink - 1)) {
- /* Used for linear interpolation between min and max shrink factor based on weight. */
+ /* Used for linear interpolation between min and max
+ * shrink factor based on weight. */
verts->shrink_factor = dvert->dw[j].weight;
}
}
@@ -1148,7 +1149,8 @@ static void cloth_update_springs(ClothModifierData *clmd)
spring->lin_stiffness = (v1->bend_stiff + v2->bend_stiff) / 2.0f;
}
else if (spring->type == CLOTH_SPRING_TYPE_GOAL) {
- /* Warning: Appending NEW goal springs does not work because implicit solver would need reset! */
+ /* Warning: Appending NEW goal springs does not work
+ * because implicit solver would need reset! */
/* Activate / Deactivate existing springs */
if ((!(cloth->verts[spring->ij].flags & CLOTH_VERT_FLAG_PINNED)) &&
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 16b330d9e7f..d33d4e344b5 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -188,8 +188,10 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy)
/***************************** Collection Copy *******************************/
/**
- * Only copy internal data of Collection ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Collection ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -248,7 +250,8 @@ static Collection *collection_duplicate_recursive(Main *bmain,
collection_new = (Collection *)collection_old->id.newid;
}
- /* Optionally add to parent (we always want to do that, even if collection_old had already been duplicated). */
+ /* Optionally add to parent (we always want to do that,
+ * even if collection_old had already been duplicated). */
if (parent != NULL) {
if (collection_child_add(parent, collection_new, 0, true)) {
/* Put collection right after existing one. */
@@ -263,14 +266,15 @@ static Collection *collection_duplicate_recursive(Main *bmain,
}
/* If we are not doing any kind of deep-copy, we can return immediately.
- * False do_full_process means collection_old had already been duplicated, no need to redo some deep-copy on it. */
+ * False do_full_process means collection_old had already been duplicated,
+ * no need to redo some deep-copy on it. */
if (!do_hierarchy || !do_full_process) {
return collection_new;
}
if (do_objects) {
- /* We can loop on collection_old's objects, that list is currently identical the collection_new' objects,
- * and won't be changed here. */
+ /* We can loop on collection_old's objects, that list is currently identical the collection_new
+ * objects, and won't be changed here. */
for (CollectionObject *cob = collection_old->gobject.first; cob; cob = cob->next) {
Object *ob_old = cob->ob;
Object *ob_new = (Object *)ob_old->id.newid;
@@ -285,8 +289,8 @@ static Collection *collection_duplicate_recursive(Main *bmain,
}
}
- /* We can loop on collection_old's children, that list is currently identical the collection_new' children,
- * and won't be changed here. */
+ /* We can loop on collection_old's children,
+ * that list is currently identical the collection_new' children, and won't be changed here. */
for (CollectionChild *child = collection_old->children.first; child; child = child->next) {
Collection *child_collection_old = child->collection;
@@ -314,13 +318,15 @@ Collection *BKE_collection_copy(Main *bmain, Collection *parent, Collection *col
*
* If \a do_hierarchy and \a do_deep_copy are false, this is a regular (shallow) ID copy.
*
- * \warning If any 'deep copy' behavior is enabled, this functions will clear all \a bmain id.idnew pointers.
+ * \warning If any 'deep copy' behavior is enabled,
+ * this functions will clear all \a bmain id.idnew pointers.
*
* \param do_hierarchy If true, it will recursively make shallow copies of children collections.
* \param do_objects If true, it will also make duplicates of objects.
* This one does nothing if \a do_hierarchy is not set.
- * \param do_obdata If true, it will also make deep duplicates of objects, using behavior defined in user settings
- * (U.dupflag). This one does nothing if \a do_hierarchy and \a do_objects are not set.
+ * \param do_obdata If true, it will also make deep duplicates of objects,
+ * using behavior defined in user settings (U.dupflag).
+ * This one does nothing if \a do_hierarchy and \a do_objects are not set.
*/
Collection *BKE_collection_duplicate(Main *bmain,
Collection *parent,
@@ -835,7 +841,8 @@ static void collection_missing_parents_remove(Collection *collection)
*
* \note caller must ensure #BKE_main_collection_sync_remap() is called afterwards!
*
- * \param collection: may be \a NULL, in which case whole \a bmain database of collections is checked.
+ * \param collection: may be \a NULL,
+ * in which case whole \a bmain database of collections is checked.
*/
void BKE_collections_child_remove_nulls(Main *bmain, Collection *collection)
{
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index a8ca6d40b51..ff6258ac339 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -539,7 +539,8 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
sub_v3_v3v3(relativeVelocity, v2, v1);
- /* Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). */
+ /* Calculate the normal component of the relative velocity
+ * (actually only the magnitude - the direction is stored in 'normal'). */
magrelVel = dot_v3v3(relativeVelocity, collpair->normal);
/* If magrelVel < 0 the edges are approaching each other. */
@@ -557,7 +558,8 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp);
/* Decrease in magnitude of relative tangential velocity due to coulomb friction
- * in original formula "magrelVel" should be the "change of relative velocity in normal direction". */
+ * in original formula "magrelVel" should be the
+ * "change of relative velocity in normal direction". */
magtangent = min_ff(collob->pd->pdef_cfrict * 0.01f * magrelVel, len_v3(vrel_t_pre));
/* Apply friction impulse. */
@@ -720,7 +722,8 @@ static int cloth_selfcollision_response_static(ClothModifierData *clmd,
sub_v3_v3v3(relativeVelocity, v2, v1);
- /* Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). */
+ /* Calculate the normal component of the relative velocity
+ * (actually only the magnitude - the direction is stored in 'normal'). */
magrelVel = dot_v3v3(relativeVelocity, collpair->normal);
/* TODO: Impulses should be weighed by mass as this is self col,
@@ -740,7 +743,8 @@ static int cloth_selfcollision_response_static(ClothModifierData *clmd,
sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp);
/* Decrease in magnitude of relative tangential velocity due to coulomb friction
- * in original formula "magrelVel" should be the "change of relative velocity in normal direction". */
+ * in original formula "magrelVel" should be the
+ * "change of relative velocity in normal direction". */
magtangent = min_ff(clmd->coll_parms->self_friction * 0.01f * magrelVel, len_v3(vrel_t_pre));
/* Apply friction impulse. */
@@ -1548,7 +1552,8 @@ static CollPair *cloth_point_collpair(float p1[3],
return collpair;
}
-//Determines collisions on overlap, collisions are written to collpair[i] and collision+number_collision_found is returned
+/* Determines collisions on overlap,
+ * collisions are written to collpair[i] and collision+number_collision_found is returned. */
static CollPair *cloth_point_collision(ModifierData *md1,
ModifierData *md2,
BVHTreeOverlap *overlap,
@@ -1696,8 +1701,11 @@ void cloth_find_point_contacts(Depsgraph *depsgraph,
clmd, collmd, &ct->collisions, &collisions_index, result, overlap, epsilon, dt);
ct->totcollisions = (int)(collisions_index - ct->collisions);
- // resolve nearby collisions
- // ret += cloth_points_objcollisions_resolve(clmd, collmd, collob->pd, collisions[i], collisions_index[i], dt);
+ /* Resolve nearby collisions. */
+#if 0
+ ret += cloth_points_objcollisions_resolve(
+ clmd, collmd, collob->pd, collisions[i], collisions_index[i], dt);
+#endif
}
if (overlap) {
diff --git a/source/blender/blenkernel/intern/colorband.c b/source/blender/blenkernel/intern/colorband.c
index 3d13c16d595..8701f06d9dd 100644
--- a/source/blender/blenkernel/intern/colorband.c
+++ b/source/blender/blenkernel/intern/colorband.c
@@ -420,8 +420,9 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
cbd1 = coba->data;
- /* Note: when ipotype >= COLBAND_INTERP_B_SPLINE, we cannot do early-out with a constant color before
- * first color stop and after last one, because interpolation starts before and ends after those... */
+ /* Note: when ipotype >= COLBAND_INTERP_B_SPLINE,
+ * we cannot do early-out with a constant color before first color stop and after last one,
+ * because interpolation starts before and ends after those... */
ipotype = (coba->color_mode == COLBAND_BLEND_RGB) ? coba->ipotype : COLBAND_INTERP_LINEAR;
if (coba->tot == 1) {
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index d6b68121c94..0e29f165992 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -120,7 +120,8 @@ void BKE_constraint_unique_name(bConstraint *con, ListBase *list)
/* ----------------- Evaluation Loop Preparation --------------- */
/* package an object/bone for use in constraint evaluation */
-/* This function MEM_calloc's a bConstraintOb struct, that will need to be freed after evaluation */
+/* This function MEM_calloc's a bConstraintOb struct,
+ * that will need to be freed after evaluation */
bConstraintOb *BKE_constraints_make_evalob(
Depsgraph *depsgraph, Scene *scene, Object *ob, void *subdata, short datatype)
{
@@ -210,10 +211,10 @@ void BKE_constraints_clear_evalob(bConstraintOb *cob)
/* calculate delta of constraints evaluation */
invert_m4_m4(imat, cob->startmat);
- /* XXX This would seem to be in wrong order. However, it does not work in 'right' order - would be nice to
- * understand why premul is needed here instead of usual postmul?
- * In any case, we **do not get a delta** here (e.g. startmat & matrix having same location, still gives
- * a 'delta' with non-null translation component :/ ).*/
+ /* XXX This would seem to be in wrong order. However, it does not work in 'right' order -
+ * would be nice to understand why premul is needed here instead of usual postmul?
+ * In any case, we **do not get a delta** here (e.g. startmat & matrix having same location,
+ * still gives a 'delta' with non-null translation component :/ ).*/
mul_m4_m4m4(delta, cob->matrix, imat);
/* copy matrices back to source */
@@ -352,8 +353,9 @@ void BKE_constraint_mat_convertspace(
*/
/* XXX This is actually an ugly hack, local space of a parent-less object *is* the same as
* global space!
- * Think what we want actually here is some kind of 'Final Space', i.e. once transformations
- * are applied - users are often confused about this too, this is not consistent with bones
+ * Think what we want actually here is some kind of 'Final Space', i.e
+ * . once transformations are applied - users are often confused about this too,
+ * this is not consistent with bones
* local space either... Meh :|
* --mont29
*/
@@ -1139,7 +1141,8 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
float size[3], vec[3];
float totmat[3][3];
- /* Get size property, since ob->scale is only the object's own relative size, not its global one */
+ /* Get size property, since ob->scale is only the object's own relative size,
+ * not its global one. */
mat4_to_size(size, cob->matrix);
/* Clear the object's rotation */
@@ -1357,12 +1360,11 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
Nurb *nu = cu->nurb.first;
curvetime = cu->ctime - data->offset;
- /* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
- * but this will only work if it actually is animated...
+ /* ctime is now a proper var setting of Curve which gets set by Animato like any other var
+ * that's animated, but this will only work if it actually is animated...
*
- * we divide the curvetime calculated in the previous step by the length of the path, to get a time
- * factor, which then gets clamped to lie within 0.0 - 1.0 range
- */
+ * we divide the curvetime calculated in the previous step by the length of the path,
+ * to get a time factor, which then gets clamped to lie within 0.0 - 1.0 range. */
curvetime /= cu->pathlen;
if (nu && nu->flagu & CU_NURB_CYCLIC) {
@@ -1806,9 +1808,10 @@ static void rotlike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
copy_v3_v3(loc, cob->matrix[3]);
mat4_to_size(size, cob->matrix);
- /* to allow compatible rotations, must get both rotations in the order of the owner... */
+ /* To allow compatible rotations, must get both rotations in the order of the owner... */
mat4_to_eulO(obeul, cob->rotOrder, cob->matrix);
- /* we must get compatible eulers from the beginning because some of them can be modified below (see bug #21875) */
+ /* We must get compatible eulers from the beginning because
+ * some of them can be modified below (see bug T21875). */
mat4_to_compatible_eulO(eul, obeul, cob->rotOrder, ct->matrix);
if ((data->flag & ROTLIKE_X) == 0) {
@@ -1850,7 +1853,8 @@ static void rotlike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
}
}
- /* good to make eulers compatible again, since we don't know how much they were changed above */
+ /* Good to make eulers compatible again,
+ * since we don't know how much they were changed above. */
compatible_eul(eul, obeul);
loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder);
}
@@ -2575,9 +2579,9 @@ static void actcon_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
bPose pose = {{0}};
bPoseChannel *pchan, *tchan;
- /* make a copy of the bone of interest in the temp pose before evaluating action, so that it can get set
- * - we need to manually copy over a few settings, including rotation order, otherwise this fails
- */
+ /* make a copy of the bone of interest in the temp pose before evaluating action,
+ * so that it can get set - we need to manually copy over a few settings,
+ * including rotation order, otherwise this fails. */
pchan = cob->pchan;
tchan = BKE_pose_channel_verify(&pose, pchan->name);
@@ -3559,7 +3563,8 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
offset = curveMin[clamp_axis] -
ceilf((curveMin[clamp_axis] - ownLoc[clamp_axis]) / len) * len;
- /* now, we calculate as per normal, except using offset instead of curveMin[clamp_axis] */
+ /* Now, we calculate as per normal,
+ * except using offset instead of curveMin[clamp_axis]. */
curvetime = (ownLoc[clamp_axis] - offset) / (len);
}
else if (ownLoc[clamp_axis] > curveMax[clamp_axis]) {
@@ -3567,7 +3572,8 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
offset = curveMax[clamp_axis] +
(int)((ownLoc[clamp_axis] - curveMax[clamp_axis]) / len) * len;
- /* now, we calculate as per normal, except using offset instead of curveMax[clamp_axis] */
+ /* Now, we calculate as per normal,
+ * except using offset instead of curveMax[clamp_axis]. */
curvetime = (ownLoc[clamp_axis] - offset) / (len);
}
else {
@@ -3689,11 +3695,10 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
mat4_to_size(dvec, ct->matrix);
if (is_negative_m4(ct->matrix)) {
- /* Bugfix [#27886]
- * We can't be sure which axis/axes are negative, though we know that something is negative.
- * Assume we don't care about negativity of separate axes. <--- This is a limitation that
- * riggers will have to live with for now.
- */
+ /* Bugfix T27886: (this is a limitation that riggers will have to live with for now).
+ * We can't be sure which axis/axes are negative,
+ * though we know that something is negative.
+ * Assume we don't care about negativity of separate axes. */
negate_v3(dvec);
}
from_min = data->from_min_scale;
@@ -3932,9 +3937,10 @@ static void shrinkwrap_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
break;
}
- /* transform normal into requested space */
- /* Note that in this specific case, we need to keep scaling in non-parented 'local2world' object
- * case, because SpaceTransform also takes it into account when handling normals. See T42447. */
+ /* Transform normal into requested space */
+ /* Note that in this specific case, we need to keep scaling in non-parented 'local2world'
+ * object case, because SpaceTransform also takes it into account when handling normals.
+ * See T42447. */
unit_m4(mat);
BKE_constraint_mat_convertspace(
cob->ob, cob->pchan, mat, CONSTRAINT_SPACE_LOCAL, scon->projAxisSpace, true);
@@ -4829,13 +4835,9 @@ static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBa
const float frame = DEG_get_ctime(cob->depsgraph);
const float time = BKE_cachefile_time_offset(cache_file, frame, FPS);
- /* Must always load ABC handle on original. */
- CacheFile *cache_file_orig = (CacheFile *)DEG_get_original_id(&cache_file->id);
- BKE_cachefile_ensure_handle(G.main, cache_file_orig);
-
- if (!data->reader) {
- data->reader = CacheReader_open_alembic_object(
- cache_file_orig->handle, data->reader, cob->ob, data->object_path);
+ if (!data->reader || !STREQ(data->reader_object_path, data->object_path)) {
+ STRNCPY(data->reader_object_path, data->object_path);
+ BKE_cachefile_reader_open(cache_file, &data->reader, cob->ob, data->object_path);
}
ABC_get_transform(data->reader, cob->matrix, time, cache_file->scale);
@@ -4853,12 +4855,8 @@ static void transformcache_copy(bConstraint *con, bConstraint *srccon)
BLI_strncpy(dst->object_path, src->object_path, sizeof(dst->object_path));
dst->cache_file = src->cache_file;
-
-#ifdef WITH_ALEMBIC
- if (dst->reader) {
- CacheReader_incref(dst->reader);
- }
-#endif
+ dst->reader = NULL;
+ dst->reader_object_path[0] = '\0';
}
static void transformcache_free(bConstraint *con)
@@ -4866,10 +4864,8 @@ static void transformcache_free(bConstraint *con)
bTransformCacheConstraint *data = con->data;
if (data->reader) {
-#ifdef WITH_ALEMBIC
- CacheReader_free(data->reader);
-#endif
- data->reader = NULL;
+ BKE_cachefile_reader_free(data->cache_file, &data->reader);
+ data->reader_object_path[0] = '\0';
}
}
@@ -5225,7 +5221,8 @@ static void con_extern_cb(bConstraint *UNUSED(con),
}
}
-/* helper for BKE_constraints_copy(), to be used for making sure that usercounts of copied ID's are fixed up */
+/* helper for BKE_constraints_copy(),
+ * to be used for making sure that usercounts of copied ID's are fixed up */
static void con_fix_copied_refs_cb(bConstraint *UNUSED(con),
ID **idpoin,
bool is_reference,
@@ -5460,7 +5457,8 @@ static bConstraint *constraint_find_original_for_update(bConstraintOb *cob, bCon
/* -------- Constraints and Proxies ------- */
-/* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL (i.e. added to bone that's proxy-synced in this file) */
+/* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL
+ * (i.e. added to bone that's proxy-synced in this file) */
void BKE_constraints_proxylocal_extract(ListBase *dst, ListBase *src)
{
bConstraint *con, *next;
@@ -5502,8 +5500,8 @@ bool BKE_constraints_proxylocked_owner(Object *ob, bPoseChannel *pchan)
/* -------- Target-Matrix Stuff ------- */
/* This function is a relic from the prior implementations of the constraints system, when all
- * constraints either had one or no targets. It used to be called during the main constraint solving
- * loop, but is now only used for the remaining cases for a few constraints.
+ * constraints either had one or no targets. It used to be called during the main constraint
+ * solving loop, but is now only used for the remaining cases for a few constraints.
*
* None of the actual calculations of the matrices should be done here! Also, this function is
* not to be used by any new constraints, particularly any that have multiple targets.
@@ -5694,9 +5692,9 @@ void BKE_constraints_solve(struct Depsgraph *depsgraph,
}
/* Interpolate the enforcement, to blend result of constraint into final owner transform
- * - all this happens in worldspace to prevent any weirdness creeping in ([#26014] and [#25725]),
- * since some constraints may not convert the solution back to the input space before blending
- * but all are guaranteed to end up in good "worldspace" result
+ * - all this happens in worldspace to prevent any weirdness creeping in
+ * (T26014 and T25725), since some constraints may not convert the solution back to the input
+ * space before blending but all are guaranteed to end up in good "worldspace" result.
*/
/* Note: all kind of stuff here before (caused trouble), much easier to just interpolate,
* or did I miss something? -jahka (r.32105) */
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 293d2c34b07..dc677449a4c 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -196,8 +196,10 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
}
/**
- * Only copy internal data of Curve ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Curve ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -337,7 +339,8 @@ void BKE_curve_boundbox_calc(Curve *cu, float r_loc[3], float r_size[3])
BoundBox *BKE_curve_boundbox_get(Object *ob)
{
- /* This is Object-level data access, DO NOT touch to Mesh's bb, would be totally thread-unsafe. */
+ /* This is Object-level data access,
+ * DO NOT touch to Mesh's bb, would be totally thread-unsafe. */
if (ob->runtime.bb == NULL || ob->runtime.bb->flag & BOUNDBOX_DIRTY) {
Curve *cu = ob->data;
float min[3], max[3];
@@ -2962,8 +2965,11 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
bev = &ob->runtime.curve_cache->bev;
+#if 0
/* do we need to calculate the radius for each point? */
- /* do_radius = (cu->bevobj || cu->taperobj || (cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ? 0 : 1; */
+ do_radius = (cu->bevobj || cu->taperobj || (cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ? 0 :
+ 1;
+#endif
/* STEP 1: MAKE POLYS */
@@ -2974,7 +2980,6 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
}
for (; nu; nu = nu->next) {
-
if (nu->hide && is_editmode) {
continue;
}
@@ -3896,7 +3901,8 @@ static bool tridiagonal_solve_with_limits(
all = true;
} while (overshoot && !locked);
- /* if no handles overshot and were locked, see if it may be a good idea to unlock some handles */
+ /* If no handles overshot and were locked,
+ * see if it may be a good idea to unlock some handles. */
if (!locked) {
for (int i = 0; i < solve_count; i++) {
// to definitely avoid infinite loops limit this to 2 times
@@ -3922,6 +3928,8 @@ static bool tridiagonal_solve_with_limits(
return true;
}
+/* Keep ascii art. */
+/* clang-format off */
/*
* This function computes the handles of a series of auto bezier points
* on the basis of 'no acceleration discontinuities' at the points.
@@ -3949,30 +3957,31 @@ static bool tridiagonal_solve_with_limits(
* |-------t1---------t2--------- ~ --------tN-------------------> time (co 0)
* Mathematical basis:
*
- * 1. Handle lengths on either side of each point are connected by a factor
- * ensuring continuity of the first derivative:
+ * 1. Handle lengths on either side of each point are connected by a factor
+ * ensuring continuity of the first derivative:
*
- * l[i] = t[i+1]/t[i]
+ * l[i] = t[i+1]/t[i]
*
- * 2. The tridiagonal system is formed by the following equation, which is derived
- * by differentiating the bezier curve and specifies second derivative continuity
- * at every point:
+ * 2. The tridiagonal system is formed by the following equation, which is derived
+ * by differentiating the bezier curve and specifies second derivative continuity
+ * at every point:
*
- * l[i]^2 * h[i-1] + (2*l[i]+2) * h[i] + 1/l[i+1] * h[i+1] = (y[i]-y[i-1])*l[i]^2 + y[i+1]-y[i]
+ * l[i]^2 * h[i-1] + (2*l[i]+2) * h[i] + 1/l[i+1] * h[i+1] = (y[i]-y[i-1])*l[i]^2 + y[i+1]-y[i]
*
- * 3. If this point is adjacent to a manually set handle with X size not equal to 1/3
- * of the horizontal interval, this equation becomes slightly more complex:
+ * 3. If this point is adjacent to a manually set handle with X size not equal to 1/3
+ * of the horizontal interval, this equation becomes slightly more complex:
*
- * l[i]^2 * h[i-1] + (3*(1-R[i-1])*l[i] + 3*(1-L[i+1])) * h[i] + 1/l[i+1] * h[i+1] = (y[i]-y[i-1])*l[i]^2 + y[i+1]-y[i]
+ * l[i]^2 * h[i-1] + (3*(1-R[i-1])*l[i] + 3*(1-L[i+1])) * h[i] + 1/l[i+1] * h[i+1] = (y[i]-y[i-1])*l[i]^2 + y[i+1]-y[i]
*
- * The difference between equations amounts to this, and it's obvious that when R[i-1]
- * and L[i+1] are both 1/3, it becomes zero:
+ * The difference between equations amounts to this, and it's obvious that when R[i-1]
+ * and L[i+1] are both 1/3, it becomes zero:
*
- * ( (1-3*R[i-1])*l[i] + (1-3*L[i+1]) ) * h[i]
+ * ( (1-3*R[i-1])*l[i] + (1-3*L[i+1]) ) * h[i]
*
- * 4. The equations for zero acceleration border conditions are basically the above
- * equation with parts omitted, so the handle size correction also applies.
+ * 4. The equations for zero acceleration border conditions are basically the above
+ * equation with parts omitted, so the handle size correction also applies.
*/
+/* clang-format on */
static void bezier_eq_continuous(
float *a, float *b, float *c, float *d, float *dy, float *l, int i)
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index c2ef575d086..22bc44a88d8 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -159,7 +159,8 @@ typedef struct LayerTypeInfo {
/** a function to determine file size */
size_t (*filesize)(CDataFile *cdf, const void *data, int count);
- /** a function to determine max allowed number of layers, should be NULL or return -1 if no limit */
+ /** a function to determine max allowed number of layers,
+ * should be NULL or return -1 if no limit */
int (*layers_max)(void);
} LayerTypeInfo;
@@ -324,7 +325,8 @@ static void layerInterp_normal(const void **sources,
void *dest)
{
/* Note: This is linear interpolation, which is not optimal for vectors.
- * Unfortunately, spherical interpolation of more than two values is hairy, so for now it will do... */
+ * Unfortunately, spherical interpolation of more than two values is hairy,
+ * so for now it will do... */
float no[3] = {0.0f};
while (count--) {
@@ -923,7 +925,8 @@ static void layerCopyValue_mloopuv(const void *source,
const MLoopUV *luv1 = source;
MLoopUV *luv2 = dest;
- /* We only support a limited subset of advanced mixing here - namely the mixfactor interpolation. */
+ /* We only support a limited subset of advanced mixing here -
+ * namely the mixfactor interpolation. */
if (mixmode == CDT_MIX_NOMIX) {
copy_v2_v2(luv2->uv, luv1->uv);
@@ -1429,7 +1432,8 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
/* 14: CD_ORCO */
{sizeof(float) * 3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 15: CD_MTEXPOLY */ /* DEPRECATED */
- /* note, when we expose the UV Map / TexFace split to the user, change this back to face Texture */
+ /* note, when we expose the UV Map / TexFace split to the user,
+ * change this back to face Texture. */
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 16: CD_MLOOPUV */
{sizeof(MLoopUV),
@@ -2197,7 +2201,8 @@ void CustomData_set_layer_stencil(CustomData *data, int type, int n)
}
}
-/* for using with an index from CustomData_get_active_layer_index and CustomData_get_render_layer_index */
+/* For using with an index from CustomData_get_active_layer_index and
+ * CustomData_get_render_layer_index. */
void CustomData_set_layer_active_index(CustomData *data, int type, int n)
{
int i;
@@ -2877,8 +2882,8 @@ void CustomData_interp(const CustomData *source,
/**
* Swap data inside each item, for all layers.
- * This only applies to item types that may store several sub-item data (e.g. corner data [UVs, VCol, ...] of
- * tessellated faces).
+ * This only applies to item types that may store several sub-item data
+ * (e.g. corner data [UVs, VCol, ...] of tessellated faces).
*
* \param corner_indices: A mapping 'new_index -> old_index' of sub-item data.
*/
@@ -3502,7 +3507,9 @@ void CustomData_bmesh_copy_data(const CustomData *source,
}
}
-/*Bmesh Custom Data Functions. Should replace editmesh ones with these as well, due to more efficient memory alloc*/
+/* BMesh Custom Data Functions.
+ * Should replace edit-mesh ones with these as well, due to more efficient memory alloc.
+ */
void *CustomData_bmesh_get(const CustomData *data, void *block, int type)
{
int layer_index;
@@ -3965,15 +3972,20 @@ void CustomData_file_write_info(int type, const char **r_struct_name, int *r_str
* Prepare given custom data for file writing.
*
* \param data: the customdata to tweak for .blend file writing (modified in place).
- * \param r_write_layers: contains a reduced set of layers to be written to file, use it with writestruct_at_address()
- * (caller must free it if != \a write_layers_buff).
+ * \param r_write_layers: contains a reduced set of layers to be written to file,
+ * use it with writestruct_at_address()
+ * (caller must free it if != \a write_layers_buff).
+ *
* \param write_layers_buff: an optional buffer for r_write_layers (to avoid allocating it).
* \param write_layers_size: the size of pre-allocated \a write_layer_buff.
*
- * \warning After this func has ran, given custom data is no more valid from Blender PoV (its totlayer is invalid).
- * This func shall always be called with localized data (as it is in write_meshes()).
- * \note data->typemap is not updated here, since it is always rebuilt on file read anyway. This means written
- * typemap does not match written layers (as returned by \a r_write_layers). Trivial to fix is ever needed.
+ * \warning After this func has ran, given custom data is no more valid from Blender PoV
+ * (its totlayer is invalid). This func shall always be called with localized data
+ * (as it is in write_meshes()).
+ *
+ * \note data->typemap is not updated here, since it is always rebuilt on file read anyway.
+ * This means written typemap does not match written layers (as returned by \a r_write_layers).
+ * Trivial to fix is ever needed.
*/
void CustomData_file_write_prepare(CustomData *data,
CustomDataLayer **r_write_layers,
@@ -4164,9 +4176,11 @@ bool CustomData_verify_versions(struct CustomData *data, int index)
if (!typeInfo->defaultname && (index > 0) && data->layers[index - 1].type == layer->type) {
keeplayer = false; /* multiple layers of which we only support one */
}
- /* This is a pre-emptive fix for cases that should not happen (layers that should not be written
- * in .blend files), but can happen due to bugs (see e.g. T62318).
- * Also for forward compatibility, in future, we may put into .blend file some currently un-written data types,
+ /* This is a pre-emptive fix for cases that should not happen
+ * (layers that should not be written in .blend files),
+ * but can happen due to bugs (see e.g. T62318).
+ * Also for forward compatibility, in future,
+ * we may put into `.blend` file some currently un-written data types,
* this should cover that case as well.
* Better to be safe here, and fix issue on the fly rather than crash... */
/* 0 structnum is used in writing code to tag layer types that should not be written. */
@@ -4189,7 +4203,8 @@ bool CustomData_verify_versions(struct CustomData *data, int index)
}
/**
- * Validate and fix data of \a layer, if possible (needs relevant callback in layer's type to be defined).
+ * 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.
*/
@@ -4449,7 +4464,7 @@ void CustomData_external_remove(CustomData *data, ID *id, int type, int totelem)
{
CustomDataExternal *external = data->external;
CustomDataLayer *layer;
- //char filename[FILE_MAX];
+ // char filename[FILE_MAX];
int layer_index; // i, remove_file;
layer_index = CustomData_get_active_layer_index(data, type);
@@ -4511,7 +4526,7 @@ static void copy_bit_flag(void *dst, const void *src, const size_t data_size, co
COPY_BIT_FLAG(uint64_t, dst, src, flag);
break;
default:
- //CLOG_ERROR(&LOG, "Unknown flags-container size (%zu)", datasize);
+ // CLOG_ERROR(&LOG, "Unknown flags-container size (%zu)", datasize);
break;
}
@@ -4530,7 +4545,7 @@ static bool check_bit_flag(const void *data, const size_t data_size, const uint6
case 8:
return ((*((uint64_t *)data) & ((uint64_t)flag)) != 0);
default:
- //CLOG_ERROR(&LOG, "Unknown flags-container size (%zu)", datasize);
+ // CLOG_ERROR(&LOG, "Unknown flags-container size (%zu)", datasize);
return false;
}
}
@@ -4543,9 +4558,9 @@ static void customdata_data_transfer_interp_generic(const CustomDataTransferLaye
const float mix_factor)
{
/* Fake interpolation, we actually copy highest weighted source to dest.
- * Note we also handle bitflags here, in which case we rather choose to transfer value of elements totaling
+ * Note we also handle bitflags here,
+ * in which case we rather choose to transfer value of elements totaling
* more than 0.5 of weight. */
-
int best_src_idx = 0;
const int data_type = laymap->data_type;
@@ -4581,7 +4596,8 @@ static void customdata_data_transfer_interp_generic(const CustomDataTransferLaye
int i;
if (data_flag) {
- /* Boolean case, we can 'interpolate' in two groups, and choose value from highest weighted group. */
+ /* Boolean case, we can 'interpolate' in two groups,
+ * and choose value from highest weighted group. */
float tot_weight_true = 0.0f;
int item_true_idx = -1, item_false_idx = -1;
@@ -4626,7 +4642,8 @@ static void customdata_data_transfer_interp_generic(const CustomDataTransferLaye
}
if (data_flag) {
- /* Bool flags, only copy if dest data is set (resp. unset) - only 'advanced' modes we can support here! */
+ /* Bool flags, only copy if dest data is set (resp. unset) -
+ * only 'advanced' modes we can support here! */
if (mix_factor >= 0.5f && ((mix_mode == CDT_MIX_TRANSFER) ||
(mix_mode == CDT_MIX_REPLACE_ABOVE_THRESHOLD &&
check_bit_flag(data_dst, data_size, data_flag)) ||
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index a57db5a7cbe..98c6d519d17 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -90,7 +90,8 @@ void BKE_object_data_transfer_dttypes_to_cdmask(const int dtdata_types,
}
}
-/* Check what can do each layer type (if it is actually handled by transferdata, if it supports advanced mixing... */
+/* Check what can do each layer type
+ * (if it is actually handled by transferdata, if it supports advanced mixing... */
bool BKE_object_data_transfer_get_dttypes_capacity(const int dtdata_types,
bool *r_advanced_mixing,
bool *r_threshold)
@@ -340,6 +341,10 @@ static void data_transfer_dtdata_type_postprocess(Object *UNUSED(ob_src),
const bool changed)
{
if (dtdata_type == DT_TYPE_LNOR) {
+ if (!changed) {
+ return;
+ }
+
/* Bake edited destination loop normals into custom normals again. */
MVert *verts_dst = me_dst->mvert;
const int num_verts_dst = me_dst->totvert;
@@ -358,10 +363,6 @@ static void data_transfer_dtdata_type_postprocess(Object *UNUSED(ob_src),
BLI_assert(poly_nors_dst);
- if (!changed) {
- return;
- }
-
if (!custom_nors_dst) {
custom_nors_dst = CustomData_add_layer(
ldata_dst, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, num_loops_dst);
@@ -458,7 +459,8 @@ static void data_transfer_interp_char(const CustomDataTransferLayerMap *laymap,
*data_dst = (char)(val_src * 255.0f);
}
-/* Helpers to match sources and destinations data layers (also handles 'conversions' in CD_FAKE cases). */
+/* Helpers to match sources and destinations data layers
+ * (also handles 'conversions' in CD_FAKE cases). */
void data_transfer_layersmapping_add_item(ListBase *r_map,
const int cddata_type,
@@ -537,12 +539,13 @@ static void data_transfer_layersmapping_add_item_cd(ListBase *r_map,
interp_data);
}
-/* Note: All those layer mapping handlers return false *only* if they were given invalid parameters.
- * This means that even if they do nothing, they will return true if all given parameters were OK.
- * Also, r_map may be NULL, in which case they will 'only' create/delete destination layers according
- * to given parameters.
+/**
+ * \note
+ * All those layer mapping handlers return false *only* if they were given invalid parameters.
+ * This means that even if they do nothing, they will return true if all given parameters were OK.
+ * Also, r_map may be NULL, in which case they will 'only' create/delete destination layers
+ * according to given parameters.
*/
-
static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map,
const int cddata_type,
const int mix_mode,
@@ -582,7 +585,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
/* Find last source actually used! */
while (idx_src-- && !use_layers_src[idx_src]) {
- ;
+ /* pass */
}
idx_src++;
@@ -609,7 +612,8 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
continue;
}
data_src = CustomData_get_layer_n(cd_src, cddata_type, idx_src);
- /* If dest is a evaluated mesh (fro; ;odifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
if (use_dupref_dst) {
data_dst = CustomData_duplicate_referenced_layer_n(
cd_dst, cddata_type, idx_src, num_elem_dst);
@@ -654,7 +658,8 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
}
else {
- /* If we are not allowed to create missing dst data layers, just skip matching src one. */
+ /* If we are not allowed to create missing dst data layers,
+ * just skip matching src one. */
continue;
}
}
@@ -662,7 +667,8 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
data_dst_to_delete[idx_dst] = false;
}
if (r_map) {
- /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
if (use_dupref_dst) {
data_dst = CustomData_duplicate_referenced_layer_n(
cd_dst, cddata_type, idx_dst, num_elem_dst);
@@ -683,9 +689,10 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
}
if (data_dst_to_delete) {
- /* Note: This won't affect newly created layers, if any, since tot_dst has not been updated!
- * Also, looping backward ensures us we do not suffer from index shifting when deleting a layer.
- */
+ /* Note:
+ * This won't affect newly created layers, if any, since tot_dst has not been updated!
+ * Also, looping backward ensures us we do not suffer
+ * from index shifting when deleting a layer. */
for (idx_dst = tot_dst; idx_dst--;) {
if (data_dst_to_delete[idx_dst]) {
CustomData_free_layer(cd_dst, cddata_type, num_elem_dst, idx_dst);
@@ -737,7 +744,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
}
else if (use_dupref_dst && r_map) {
- /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
data_dst = CustomData_duplicate_referenced_layer(cd_dst, cddata_type, num_elem_dst);
}
@@ -771,7 +779,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
if (tolayers >= 0) { /* Real-layer index */
idx_dst = tolayers;
- /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
if (use_dupref_dst && r_map) {
data_dst = CustomData_duplicate_referenced_layer_n(
cd_dst, cddata_type, idx_dst, num_elem_dst);
@@ -788,7 +797,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
}
else {
- /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
if (use_dupref_dst && r_map) {
data_dst = CustomData_duplicate_referenced_layer_n(
cd_dst, cddata_type, idx_dst, num_elem_dst);
@@ -810,7 +820,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
}
}
- /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
if (use_dupref_dst && r_map) {
data_dst = CustomData_duplicate_referenced_layer_n(
cd_dst, cddata_type, idx_dst, num_elem_dst);
@@ -828,7 +839,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
CustomData_add_layer_named(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst, name);
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
}
- /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
if (use_dupref_dst && r_map) {
data_dst = CustomData_duplicate_referenced_layer_n(
cd_dst, cddata_type, idx_dst, num_elem_dst);
@@ -1002,7 +1014,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
return ret;
}
else if (cddata_type == CD_FAKE_SHAPEKEY) {
- /* TODO: leaving shapekeys aside for now, quite specific case, since we can't access them from MVert :/ */
+ /* TODO: leaving shapekeys aside for now, quite specific case,
+ * since we can't access them from MVert :/ */
return false;
}
}
@@ -1127,7 +1140,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
cddata_type = CD_MLOOPUV;
}
else if (cddata_type == CD_FAKE_LNOR) {
- /* Preprocess should have generated it, Postprocess will convert it back to CD_CUSTOMLOOPNORMAL. */
+ /* Pre-process should have generated it,
+ * Post-process will convert it back to CD_CUSTOMLOOPNORMAL. */
cddata_type = CD_NORMAL;
interp_data = space_transform;
interp = customdata_data_transfer_interp_normal_normals;
@@ -1224,8 +1238,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
/**
* Transfer data *layout* of selected types from source to destination object.
* By default, it only creates new data layers if needed on \a ob_dst.
- * If \a use_delete is true, it will also delete data layers on \a ob_dst that do not match those from \a ob_src,
- * to get (as much as possible) exact copy of source data layout.
+ * If \a use_delete is true, it will also delete data layers on \a ob_dst that do not match those
+ * from \a ob_src, to get (as much as possible) exact copy of source data layout.
*/
void BKE_object_data_transfer_layout(struct Depsgraph *depsgraph,
Scene *scene,
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 57ab0a9c94e..a964cab3fa5 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -646,11 +646,11 @@ float defvert_array_find_weight_safe(const struct MDeformVert *dvert,
const int index,
const int defgroup)
{
- /* Invalid defgroup index means the vgroup selected is invalid, does not exist, in that case it is OK to return 1.0
+ /* Invalid defgroup index means the vgroup selected is invalid,
+ * does not exist, in that case it is OK to return 1.0
* (i.e. maximum weight, as if no vgroup was selected).
* But in case of valid defgroup and NULL dvert data pointer, it means that vgroup **is** valid,
- * and just totally empty, so we shall return '0.0' value then!
- */
+ * and just totally empty, so we shall return '0.0' value then! */
if (defgroup == -1) {
return 1.0f;
}
@@ -1124,7 +1124,7 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
/* Find last source actually used! */
idx_src = num_layers_src;
while (idx_src-- && !use_layers_src[idx_src]) {
- ;
+ /* pass */
}
idx_src++;
@@ -1258,12 +1258,13 @@ bool data_transfer_layersmapping_vgroups(ListBase *r_map,
const size_t elem_size = sizeof(*((MDeformVert *)NULL));
- /* Note: VGroups are a bit hairy, since their layout is defined on object level (ob->defbase), while their actual
- * data is a (mesh) CD layer.
- * This implies we may have to handle data layout itself while having NULL data itself,
- * and even have to support NULL data_src in transfer data code (we always create a data_dst, though).
+ /* Note:
+ * VGroups are a bit hairy, since their layout is defined on object level (ob->defbase),
+ * while their actual data is a (mesh) CD layer.
+ * This implies we may have to handle data layout itself while having NULL data itself,
+ * and even have to support NULL data_src in transfer data code
+ * (we always create a data_dst, though).
*/
-
if (BLI_listbase_is_empty(&ob_src->defbase)) {
if (use_delete) {
BKE_object_defgroup_remove_all(ob_dst);
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index e3ee28ed022..c228595b6e8 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1028,7 +1028,10 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
}
/* If we need normals, no choice, have to convert to mesh now. */
- if (mti->dependsOnNormals != NULL && mti->dependsOnNormals(md) && modified == NULL) {
+ bool need_normal = mti->dependsOnNormals != NULL && mti->dependsOnNormals(md);
+ /* XXX 2.8 : now that batch cache is stored inside the ob->data
+ * we need to create a Mesh for each curve that uses modifiers. */
+ if (modified == NULL /* && need_normal */) {
if (vertCos != NULL) {
displist_apply_allverts(dispbase, vertCos);
}
@@ -1046,7 +1049,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
if (!vertCos) {
vertCos = BKE_mesh_vertexCos_get(modified, &totvert);
}
- if (mti->dependsOnNormals != NULL && mti->dependsOnNormals(md)) {
+ if (need_normal) {
BKE_mesh_ensure_normals(modified);
}
mti->deformVerts(md, &mectx_deform, modified, vertCos, totvert);
@@ -1095,7 +1098,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
vertCos = NULL;
}
- if (mti->dependsOnNormals != NULL && mti->dependsOnNormals(md)) {
+ if (need_normal) {
BKE_mesh_ensure_normals(modified);
}
mesh_applied = mti->applyModifier(md, &mectx_apply, modified);
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 7fef07346c3..93b6fd34a8f 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -153,12 +153,17 @@ typedef struct Bounds3D {
typedef struct VolumeGrid {
int dim[3];
- Bounds3D grid_bounds; /* whole grid bounds */
-
- Bounds3D *bounds; /* (x*y*z) precalculated grid cell bounds */
- int *s_pos; /* (x*y*z) t_index begin id */
- int *s_num; /* (x*y*z) number of t_index points */
- int *t_index; /* actual surface point index, access: (s_pos + s_num) */
+ /** whole grid bounds */
+ Bounds3D grid_bounds;
+
+ /** (x*y*z) precalculated grid cell bounds */
+ Bounds3D *bounds;
+ /** (x*y*z) t_index begin id */
+ int *s_pos;
+ /** (x*y*z) number of t_index points */
+ int *s_num;
+ /** actual surface point index, access: (s_pos + s_num) */
+ int *t_index;
int *temp_t_index;
} VolumeGrid;
@@ -168,51 +173,67 @@ typedef struct Vec3f {
} Vec3f;
typedef struct BakeAdjPoint {
- float dir[3]; /* vector pointing towards this neighbor */
- float dist; /* distance to */
+ /** vector pointing towards this neighbor */
+ float dir[3];
+ /** distance to */
+ float dist;
} BakeAdjPoint;
-/* Surface data used while processing a frame */
+/** Surface data used while processing a frame */
typedef struct PaintBakeNormal {
- float invNorm[3]; /* current pixel world-space inverted normal */
- float normal_scale; /* normal directional scale for displace mapping */
+ /** current pixel world-space inverted normal */
+ float invNorm[3];
+ /** normal directional scale for displace mapping */
+ float normal_scale;
} PaintBakeNormal;
-/* Temp surface data used to process a frame */
+/** Temp surface data used to process a frame */
typedef struct PaintBakeData {
/* point space data */
PaintBakeNormal *bNormal;
- int *s_pos; /* index to start reading point sample realCoord */
- int *s_num; /* num of realCoord samples */
- Vec3f *
- realCoord; /* current pixel center world-space coordinates for each sample ordered as (s_pos + s_num) */
+ /** index to start reading point sample realCoord */
+ int *s_pos;
+ /** num of realCoord samples */
+ int *s_num;
+ /** current pixel center world-space coordinates for each sample ordered as (s_pos + s_num) */
+ Vec3f *realCoord;
Bounds3D mesh_bounds;
float dim[3];
/* adjacency info */
- BakeAdjPoint *bNeighs; /* current global neighbor distances and directions, if required */
+ /** current global neighbor distances and directions, if required */
+ BakeAdjPoint *bNeighs;
double average_dist;
/* space partitioning */
- VolumeGrid *grid; /* space partitioning grid to optimize brush checks */
+ /** space partitioning grid to optimize brush checks */
+ VolumeGrid *grid;
/* velocity and movement */
- Vec3f *velocity; /* speed vector in global space movement per frame, if required */
+ /** speed vector in global space movement per frame, if required */
+ Vec3f *velocity;
Vec3f *prev_velocity;
- float *brush_velocity; /* special temp data for post-p velocity based brushes like smudge
- * 3 float dir vec + 1 float str */
- MVert *prev_verts; /* copy of previous frame vertices. used to observe surface movement */
- float prev_obmat[4][4]; /* previous frame object matrix */
- int clear; /* flag to check if surface was cleared/reset -> have to redo velocity etc. */
+ /** special temp data for post-p velocity based brushes like smudge
+ * 3 float dir vec + 1 float str */
+ float *brush_velocity;
+ /** copy of previous frame vertices. used to observe surface movement. */
+ MVert *prev_verts;
+ /** Previous frame object matrix. */
+ float prev_obmat[4][4];
+ /** flag to check if surface was cleared/reset -> have to redo velocity etc. */
+ int clear;
} PaintBakeData;
-/* UV Image sequence format point */
+/** UV Image sequence format point */
typedef struct PaintUVPoint {
/* Pixel / mesh data */
- unsigned int tri_index, pixel_index; /* tri index on domain derived mesh */
- unsigned int v1, v2, v3; /* vertex indexes */
-
- unsigned int
- neighbour_pixel; /* If this pixel isn't uv mapped to any face, but it's neighboring pixel is */
+ /** tri index on domain derived mesh */
+ unsigned int tri_index;
+ unsigned int pixel_index;
+ /* vertex indexes */
+ unsigned int v1, v2, v3;
+
+ /** If this pixel isn't uv mapped to any face, but it's neighboring pixel is. */
+ unsigned int neighbour_pixel;
} PaintUVPoint;
typedef struct ImgSeqFormatData {
@@ -225,14 +246,20 @@ typedef struct ImgSeqFormatData {
#define ADJ_BORDER_PIXEL (1 << 1)
typedef struct PaintAdjData {
- int *
- n_target; /* array of neighboring point indexes, for single sample use (n_index + neigh_num) */
- int *n_index; /* index to start reading n_target for each point */
- int *n_num; /* num of neighs for each point */
- int *flags; /* vertex adjacency flags */
- int total_targets; /* size of n_target */
- int *border; /* indices of border pixels (only for texture paint) */
- int total_border; /* size of border */
+ /** Array of neighboring point indexes, for single sample use (n_index + neigh_num). */
+ int *n_target;
+ /** Index to start reading n_target for each point. */
+ int *n_index;
+ /** Num of neighs for each point. */
+ int *n_num;
+ /** Vertex adjacency flags. */
+ int *flags;
+ /** Size of n_target. */
+ int total_targets;
+ /** Indices of border pixels (only for texture paint). */
+ int *border;
+ /** Size of border. */
+ int total_border;
} PaintAdjData;
/************************* Runtime evaluation store ***************************/
@@ -302,56 +329,12 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface)
return 0;
}
-/* checks whether surface's format/type has realtime preview */
-bool dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface)
-{
- if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
- return false;
- }
- else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
- return !ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WAVE);
- }
-
- return true;
-}
-
/* get currently active surface (in user interface) */
DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas)
{
return BLI_findlink(&canvas->surfaces, canvas->active_sur);
}
-/* set preview to first previewable surface */
-void dynamicPaint_resetPreview(DynamicPaintCanvasSettings *canvas)
-{
- DynamicPaintSurface *surface = canvas->surfaces.first;
- bool done = false;
-
- for (; surface; surface = surface->next) {
- if (!done && dynamicPaint_surfaceHasColorPreview(surface)) {
- surface->flags |= MOD_DPAINT_PREVIEW;
- done = true;
- }
- else {
- surface->flags &= ~MOD_DPAINT_PREVIEW;
- }
- }
-}
-
-/* set preview to defined surface */
-static void dynamicPaint_setPreview(DynamicPaintSurface *t_surface)
-{
- DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
- for (; surface; surface = surface->next) {
- if (surface == t_surface) {
- surface->flags |= MOD_DPAINT_PREVIEW;
- }
- else {
- surface->flags &= ~MOD_DPAINT_PREVIEW;
- }
- }
-}
-
bool dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, Object *ob, int output)
{
const char *name;
@@ -471,14 +454,6 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface)
}
surface_setUniqueOutputName(surface, surface->output_name, 0);
-
- /* update preview */
- if (dynamicPaint_surfaceHasColorPreview(surface)) {
- dynamicPaint_setPreview(surface);
- }
- else {
- dynamicPaint_resetPreview(surface->canvas);
- }
}
static int surface_totalSamples(DynamicPaintSurface *surface)
@@ -1079,8 +1054,8 @@ DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *c
/* Set initial values */
surface->flags = MOD_DPAINT_ANTIALIAS | MOD_DPAINT_MULALPHA | MOD_DPAINT_DRY_LOG |
- MOD_DPAINT_DISSOLVE_LOG | MOD_DPAINT_ACTIVE | MOD_DPAINT_PREVIEW |
- MOD_DPAINT_OUT1 | MOD_DPAINT_USE_DRYING;
+ MOD_DPAINT_DISSOLVE_LOG | MOD_DPAINT_ACTIVE | MOD_DPAINT_OUT1 |
+ MOD_DPAINT_USE_DRYING;
surface->effect = 0;
surface->effect_ui = 1;
@@ -1280,7 +1255,6 @@ void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd,
t_surface->disp_type = surface->disp_type;
t_surface->image_fileformat = surface->image_fileformat;
t_surface->effect_ui = surface->effect_ui;
- t_surface->preview_id = surface->preview_id;
t_surface->init_color_type = surface->init_color_type;
t_surface->flags = surface->flags;
t_surface->effect = surface->effect;
@@ -1323,7 +1297,6 @@ void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd,
BLI_strncpy(t_surface->output_name, surface->output_name, sizeof(t_surface->output_name));
BLI_strncpy(t_surface->output_name2, surface->output_name2, sizeof(t_surface->output_name2));
}
- dynamicPaint_resetPreview(tpmd->canvas);
}
else if (tpmd->brush) {
DynamicPaintBrushSettings *brush = pmd->brush, *t_brush = tpmd->brush;
@@ -1841,7 +1814,6 @@ typedef struct DynamicPaintModifierApplyData {
float (*fcolor)[4];
MLoopCol *mloopcol;
MLoopCol *mloopcol_wet;
- MLoopCol *mloopcol_preview;
} DynamicPaintModifierApplyData;
static void dynamic_paint_apply_surface_displace_cb(void *__restrict userdata,
@@ -1906,7 +1878,6 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
const ParallelRangeTLS *__restrict UNUSED(tls))
{
const DynamicPaintModifierApplyData *data = userdata;
- Object *ob = data->ob;
const MLoop *mloop = data->mloop;
const MPoly *mpoly = data->mpoly;
@@ -1917,11 +1888,6 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
MLoopCol *mloopcol = data->mloopcol;
MLoopCol *mloopcol_wet = data->mloopcol_wet;
- MLoopCol *mloopcol_preview = data->mloopcol_preview;
-
- const Material *material = mloopcol_preview ?
- give_current_material(ob, mpoly[p_index].mat_nr + 1) :
- NULL;
for (int j = 0; j < mpoly[p_index].totloop; j++) {
const int l_index = mpoly[p_index].loopstart + j;
@@ -1940,37 +1906,6 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
mloopcol_wet[l_index].b = c;
mloopcol_wet[l_index].a = 255;
}
-
- /* viewport preview */
- if (mloopcol_preview) {
- if (surface->preview_id == MOD_DPAINT_SURFACE_PREV_PAINT) {
- float c[3];
-
- /* Apply material color as base vertex color for preview */
- mloopcol_preview[l_index].a = 255;
- if (material) {
- c[0] = material->r;
- c[1] = material->g;
- c[2] = material->b;
- }
- else { /* default gray */
- c[0] = 0.65f;
- c[1] = 0.65f;
- c[2] = 0.65f;
- }
- /* mix surface color */
- interp_v3_v3v3(c, c, fcolor[v_index], fcolor[v_index][3]);
-
- rgb_float_to_uchar((unsigned char *)&mloopcol_preview[l_index].r, c);
- }
- else {
- const char c = unit_float_to_uchar_clamp(pPoint[v_index].wetness);
- mloopcol_preview[l_index].r = c;
- mloopcol_preview[l_index].g = c;
- mloopcol_preview[l_index].b = c;
- mloopcol_preview[l_index].a = 255;
- }
- }
}
}
@@ -2056,22 +1991,11 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
&result->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, totloop, surface->output_name2);
}
- /* Save preview results to weight layer to be able to share same drawing methods */
- MLoopCol *mloopcol_preview = NULL;
- if (surface->flags & MOD_DPAINT_PREVIEW) {
- mloopcol_preview = CustomData_get_layer(&result->ldata, CD_PREVIEW_MLOOPCOL);
- if (!mloopcol_preview) {
- mloopcol_preview = CustomData_add_layer(
- &result->ldata, CD_PREVIEW_MLOOPCOL, CD_CALLOC, NULL, totloop);
- }
- }
-
data.ob = ob;
data.mloop = mloop;
data.mpoly = mpoly;
data.mloopcol = mloopcol;
data.mloopcol_wet = mloopcol_wet;
- data.mloopcol_preview = mloopcol_preview;
{
ParallelRangeSettings settings;
@@ -2084,7 +2008,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
MEM_freeN(fcolor);
/* Mark tessellated CD layers as dirty. */
- //result->dirty |= DM_DIRTY_TESS_CDLAYERS;
+ // result->dirty |= DM_DIRTY_TESS_CDLAYERS;
}
/* vertex group paint */
else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
@@ -2092,15 +2016,6 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
MDeformVert *dvert = CustomData_get_layer(&result->vdata, CD_MDEFORMVERT);
float *weight = (float *)sData->type_data;
- /* viewport preview */
- if (surface->flags & MOD_DPAINT_PREVIEW) {
- /* Save preview results to weight layer to be
- * able to share same drawing methods.
- * Note this func also sets DM_DIRTY_TESS_CDLAYERS flag! */
- //TODO port this function
- //DM_update_weight_mcol(ob, result, 0, weight, 0, NULL);
- }
-
/* apply weights into a vertex group, if doesn't exists add a new layer */
if (defgrp_index != -1 && !dvert && (surface->output_name[0] != '\0')) {
dvert = CustomData_add_layer(
@@ -2151,7 +2066,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
}
if (update_normals) {
- //result->dirty |= DM_DIRTY_NORMALS;
+ // result->dirty |= DM_DIRTY_NORMALS;
}
}
/* make a copy of mesh to use as brush data */
@@ -2303,11 +2218,11 @@ Mesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd,
}
}
-/***************************** Image Sequence / UV Image Surface Calls ******************************/
+/* -------------------------------------------------------------------- */
+/** \name Image Sequence / UV Image Surface Calls
+ * \{ */
-/*
- * Create a surface for uv image sequence format
- */
+/* Create a surface for uv image sequence format. */
#define JITTER_SAMPLES \
{ \
0.0f, 0.0f, -0.2f, -0.4f, 0.2f, 0.4f, 0.4f, -0.2f, -0.4f, 0.3f, \
@@ -2585,7 +2500,8 @@ static int dynamic_paint_find_neighbour_pixel(const DynamicPaintCreateUVSurfaceD
const PaintUVPoint *tPoint = &tempPoints[x + w * y]; /* UV neighbor */
const PaintUVPoint *cPoint = &tempPoints[px + w * py]; /* Origin point */
- /* Check if shifted point is on same face -> it's a correct neighbor (and if it isn't marked as an "edge pixel") */
+ /* Check if shifted point is on same face -> it's a correct neighbor
+ * (and if it isn't marked as an "edge pixel") */
if ((tPoint->tri_index == cPoint->tri_index) && (tPoint->neighbour_pixel == -1)) {
return (x + w * y);
}
@@ -2680,7 +2596,8 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
const int vert0 = mloop[loop_idx[(edge_idx + 0)]].v;
const int vert1 = mloop[loop_idx[(edge_idx + 1) % 3]].v;
- /* Use a pre-computed vert-to-looptri mapping, speeds up things a lot compared to looping over all loopti. */
+ /* Use a pre-computed vert-to-looptri mapping,
+ * speeds up things a lot compared to looping over all loopti. */
const MeshElemMap *map = &bdata->vert_to_looptri_map[vert0];
bool found_other = false;
@@ -2822,7 +2739,8 @@ static bool dynamicPaint_pointHasNeighbor(PaintAdjData *ed, int index, int neigh
return false;
}
-/* Makes the adjacency data symmetric, except for border pixels. I.e. if A is neighbor of B, B is neighbor of A. */
+/* Makes the adjacency data symmetric, except for border pixels.
+ * I.e. if A is neighbor of B, B is neighbor of A. */
static bool dynamicPaint_symmetrizeAdjData(PaintAdjData *ed, int active_points)
{
int *new_n_index = MEM_callocN(sizeof(int) * active_points, "Surface Adj Index");
@@ -3112,7 +3030,8 @@ int dynamicPaint_createUVSurface(Scene *scene,
}
for (int i = 0; i < 8; i++) {
- /* Try to find a neighboring pixel in defined direction. If not found, -1 is returned */
+ /* Try to find a neighboring pixel in defined direction.
+ * If not found, -1 is returned */
const int n_target = dynamic_paint_find_neighbour_pixel(
&data, vert_to_looptri_map, w, h, tx, ty, i);
@@ -3522,10 +3441,13 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface,
IMB_freeImBuf(ibuf);
}
+/** \} */
+
/***************************** Ray / Nearest Point Utils ******************************/
-/* A modified callback to bvh tree raycast. The tree must have been built using bvhtree_from_mesh_looptri.
- * userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
+/* A modified callback to bvh tree raycast.
+ * The tree must have been built using bvhtree_from_mesh_looptri.
+ * userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
*
* To optimize brush detection speed this doesn't calculate hit coordinates or normal.
*/
@@ -3555,7 +3477,8 @@ static void mesh_tris_spherecast_dp(void *userdata,
}
}
-/* A modified callback to bvh tree nearest point. The tree must have been built using bvhtree_from_mesh_looptri.
+/* A modified callback to bvh tree nearest point.
+ * The tree must have been built using bvhtree_from_mesh_looptri.
* userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
*
* To optimize brush detection speed this doesn't calculate hit normal.
@@ -4960,7 +4883,8 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, cons
0, sData->total_points, sData, dynamic_paint_prepare_adjacency_cb, &settings);
/* calculate average values (single thread).
- * Note: tried to put this in threaded callback (using _finalize feature), but gave ~30% slower result! */
+ * Note: tried to put this in threaded callback (using _finalize feature),
+ * but gave ~30% slower result! */
bData->average_dist = 0.0;
for (index = 0; index < sData->total_points; index++) {
int numOfNeighs = adj_data->n_num[index];
@@ -4972,7 +4896,8 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, cons
bData->average_dist /= adj_data->total_targets;
}
-/* find two adjacency points (closest_id) and influence (closest_d) to move paint towards when affected by a force */
+/* Find two adjacency points (closest_id) and influence (closest_d)
+ * to move paint towards when affected by a force. */
static void surface_determineForceTargetPoints(const PaintSurfaceData *sData,
const int index,
const float force[3],
@@ -5462,13 +5387,13 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata,
const unsigned int n_trgt = (unsigned int)n_target[n_idx];
/* Sort of spinlock, but only for given ePoint.
- * Since the odds a same ePoint is modified at the same time by several threads is very low, this is
- * much more efficient than a global spin lock. */
+ * Since the odds a same ePoint is modified at the same time by several threads is very low,
+ * this is much more efficient than a global spin lock. */
const unsigned int epointlock_idx = n_trgt / 8;
const uint8_t epointlock_bitmask = 1 << (n_trgt & 7); /* 7 == 0b111 */
while (atomic_fetch_and_or_uint8(&point_locks[epointlock_idx], epointlock_bitmask) &
epointlock_bitmask) {
- ;
+ /* pass */
}
PaintPoint *ePoint = &((PaintPoint *)sData->type_data)[n_trgt];
@@ -5494,8 +5419,8 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata,
CLAMP_MAX(ePoint->e_color[3], pPoint_prev->e_color[3]);
}
- /* Decrease paint wetness on current point
- * (just store diff here, that way we can only lock current point once at the end to apply it). */
+ /* Decrease paint wetness on current point (just store diff here,
+ * that way we can only lock current point once at the end to apply it). */
ppoint_wetness_diff += (ePoint->wetness - e_wet);
#ifndef NDEBUG
@@ -5515,7 +5440,7 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata,
const uint8_t ppointlock_bitmask = 1 << (index & 7); /* 7 == 0b111 */
while (atomic_fetch_and_or_uint8(&point_locks[ppointlock_idx], ppointlock_bitmask) &
ppointlock_bitmask) {
- ;
+ /* pass */
}
pPoint->wetness -= ppoint_wetness_diff;
@@ -5923,10 +5848,10 @@ static void dynamic_paint_surface_pre_step_cb(void *__restrict userdata,
/* reduce wet layer alpha by dry factor */
pPoint->e_color[3] *= dry_ratio;
- /* now calculate new alpha for dry layer that keeps final blended color unchanged */
+ /* Now calculate new alpha for dry layer that keeps final blended color unchanged. */
pPoint->color[3] = (f_color[3] - pPoint->e_color[3]) / (1.0f - pPoint->e_color[3]);
- /* for each rgb component, calculate a new dry layer color that keeps the final blend color
- * with these new alpha values. (wet layer color doesn't change)*/
+ /* For each rgb component, calculate a new dry layer color that keeps the final blend
+ * color with these new alpha values. (wet layer color doesn't change). */
if (pPoint->color[3]) {
for (i = 0; i < 3; i++) {
pPoint->color[i] = (f_color[i] * f_color[3] -
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index 794b1d669d2..06f297b23e0 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -399,7 +399,7 @@ static void statvis_calc_sharp(BMEditMesh *em,
BMIter iter;
BMesh *bm = em->bm;
BMEdge *e;
- //float f_no[3];
+ // float f_no[3];
const float minmax_irange = 1.0f / (max - min);
int i;
diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c
index 12f70eed2c6..130f4ae88f1 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -233,11 +233,11 @@ void BKE_editmesh_lnorspace_update(BMEditMesh *em)
BMesh *bm = em->bm;
/* We need to create clnors data if none exist yet, otherwise there is no way to edit them.
- * Similar code to MESH_OT_customdata_custom_splitnormals_add operator, we want to keep same shading
- * in case we were using autosmooth so far...
- * Note: there is a problem here, which is that if someone starts a normal editing operation on previously
- * autosmooth-ed mesh, and cancel that operation, generated clnors data remain, with related sharp edges
- * (and hence autosmooth is 'lost').
+ * Similar code to MESH_OT_customdata_custom_splitnormals_add operator,
+ * we want to keep same shading in case we were using autosmooth so far.
+ * Note: there is a problem here, which is that if someone starts a normal editing operation on
+ * previously autosmooth-ed mesh, and cancel that operation, generated clnors data remain,
+ * with related sharp edges (and hence autosmooth is 'lost').
* Not sure how critical this is, and how to fix that issue? */
if (!CustomData_has_layer(&bm->ldata, CD_CUSTOMLOOPNORMAL)) {
Mesh *me = em->ob->data;
diff --git a/source/blender/blenkernel/intern/editmesh_tangent.c b/source/blender/blenkernel/intern/editmesh_tangent.c
index 6a644b2ed4b..df2fb8c8348 100644
--- a/source/blender/blenkernel/intern/editmesh_tangent.c
+++ b/source/blender/blenkernel/intern/editmesh_tangent.c
@@ -104,7 +104,7 @@ static void emdm_ts_GetPosition(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLEditMeshToTangent *pMesh = pContext->m_pUserData;
const BMLoop **lt;
const BMLoop *l;
@@ -138,7 +138,7 @@ static void emdm_ts_GetTextureCoordinate(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLEditMeshToTangent *pMesh = pContext->m_pUserData;
const BMLoop **lt;
const BMLoop *l;
@@ -176,7 +176,7 @@ static void emdm_ts_GetNormal(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLEditMeshToTangent *pMesh = pContext->m_pUserData;
const BMLoop **lt;
const BMLoop *l;
@@ -221,7 +221,7 @@ static void emdm_ts_SetTSpace(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLEditMeshToTangent *pMesh = pContext->m_pUserData;
const BMLoop **lt;
const BMLoop *l;
@@ -276,7 +276,8 @@ static void emDM_calc_loop_tangents_thread(TaskPool *__restrict UNUSED(pool),
/**
* \see #BKE_mesh_calc_loop_tangent, same logic but used arrays instead of #BMesh data.
*
- * \note This function is not so normal, its using `bm->ldata` as input, but output's to `dm->loopData`.
+ * \note This function is not so normal, its using `bm->ldata` as input,
+ * but output's to `dm->loopData`.
* This is done because #CD_TANGENT is cache data used only for drawing.
*/
void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
@@ -382,9 +383,8 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
mesh2tangent->num_face_as_quad_map = num_face_as_quad_map;
#endif
mesh2tangent->precomputedFaceNormals = poly_normals;
- /* Note, we assume we do have tessellated loop normals at this point (in case it is object-enabled),
- * have to check this is valid...
- */
+ /* Note, we assume we do have tessellated loop normals at this point
+ * (in case it is object-enabled), have to check this is valid. */
mesh2tangent->precomputedLoopNormals = loop_normals;
mesh2tangent->cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, n);
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 1105d210e13..51715c3a223 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -646,8 +646,8 @@ int get_effector_data(EffectorCache *eff,
float cfra = DEG_get_ctime(eff->depsgraph);
int ret = 0;
- /* In case surface object is in Edit mode when loading the .blend, surface modifier is never executed
- * and bvhtree never built, see T48415. */
+ /* In case surface object is in Edit mode when loading the .blend,
+ * surface modifier is never executed and bvhtree never built, see T48415. */
if (eff->pd && eff->pd->shape == PFIELD_SHAPE_SURFACE && eff->surmd && eff->surmd->bvhtree) {
/* closest point in the object surface is an effector */
float vec[3];
@@ -698,7 +698,7 @@ int get_effector_data(EffectorCache *eff,
ret = psys_get_particle_state(&sim, *efd->index, &state, 0);
/* TODO */
- //if (eff->pd->forcefiled == PFIELD_HARMONIC && ret==0) {
+ // if (eff->pd->forcefiled == PFIELD_HARMONIC && ret==0) {
// if (pa->dietime < eff->psys->cfra)
// eff->flag |= PE_VELOCITY_TO_IMPULSE;
//}
@@ -750,7 +750,8 @@ int get_effector_data(EffectorCache *eff,
sub_v3_v3v3(efd->vec_to_point, point->loc, efd->loc);
efd->distance = len_v3(efd->vec_to_point);
- /* rest length for harmonic effector, will have to see later if this could be extended to other effectors */
+ /* Rest length for harmonic effector,
+ * will have to see later if this could be extended to other effectors. */
if (eff->pd && eff->pd->forcefield == PFIELD_HARMONIC && eff->pd->f_size) {
mul_v3_fl(efd->vec_to_point, (efd->distance - eff->pd->f_size) / efd->distance);
}
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index f4ac586d9c4..8c95e4c7ff3 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -230,7 +230,8 @@ FCurve *id_data_find_fcurve(
return fcu;
}
-/* Find the F-Curve affecting the given RNA-access path + index, in the list of F-Curves provided */
+/* Find the F-Curve affecting the given RNA-access path + index,
+ * in the list of F-Curves provided. */
FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_index)
{
FCurve *fcu;
@@ -277,7 +278,10 @@ FCurve *iter_step_fcurve(FCurve *fcu_iter, const char rna_path[])
return NULL;
}
-/* Get list of LinkData's containing pointers to the F-Curves which control the types of data indicated
+/**
+ * Get list of LinkData's containing pointers to the F-Curves
+ * which control the types of data indicated.
+ *
* Lists...
* - dst: list of LinkData's matching the criteria returned.
* List must be freed after use, and is assumed to be empty when passed.
@@ -380,9 +384,9 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
/* there must be some RNA-pointer + property combon */
if (prop && tptr.id.data && RNA_property_animateable(&tptr, prop)) {
AnimData *adt = BKE_animdata_from_id(tptr.id.data);
- int step =
- C ? 2 :
- 1; /* Always 1 in case we have no context (can't check in 'ancestors' of given RNA ptr). */
+ int step = (
+ /* Always 1 in case we have no context (can't check in 'ancestors' of given RNA ptr). */
+ C ? 2 : 1);
char *path = NULL;
if (!adt && C) {
@@ -451,7 +455,8 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
/* ----------------- Finding Keyframes/Extents -------------------------- */
-/* Binary search algorithm for finding where to insert BezTriple, with optional argument for precision required.
+/* Binary search algorithm for finding where to insert BezTriple,
+ * with optional argument for precision required.
* Returns the index to insert at (data already at that index will be offset if replace is 0)
*/
static int binarysearch_bezt_index_ex(
@@ -648,8 +653,8 @@ bool calc_fcurve_bounds(FCurve *fcu,
if (include_handles) {
/* left handle - only if applicable
- * NOTE: for the very first keyframe, the left handle actually has no bearings on anything
- */
+ * NOTE: for the very first keyframe,
+ * the left handle actually has no bearings on anything. */
if (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)) {
yminv = min_ff(yminv, bezt->vec[0][1]);
ymaxv = max_ff(ymaxv, bezt->vec[0][1]);
@@ -999,13 +1004,15 @@ eFCU_Cycle_Type BKE_fcurve_get_cycle_type(FCurve *fcu)
return FCU_CYCLE_NONE;
}
-/* Checks if the F-Curve has a Cycles modifier with simple settings that warrant transition smoothing */
+/* Checks if the F-Curve has a Cycles modifier with simple settings
+ * that warrant transition smoothing. */
bool BKE_fcurve_is_cyclic(FCurve *fcu)
{
return BKE_fcurve_get_cycle_type(fcu) != FCU_CYCLE_NONE;
}
-/* Shifts 'in' by the difference in coordinates between 'to' and 'from', using 'out' as the output buffer.
+/* Shifts 'in' by the difference in coordinates between 'to' and 'from',
+ * using 'out' as the output buffer.
* When 'to' and 'from' are end points of the loop, this moves the 'in' point one loop cycle.
*/
static BezTriple *cycle_offset_triple(
@@ -1240,7 +1247,10 @@ static ID *dtar_id_ensure_proxy_from(ID *id)
return id;
}
-/* Helper function to obtain a value using RNA from the specified source (for evaluating drivers) */
+/**
+ * Helper function to obtain a value using RNA from the specified source
+ * (for evaluating drivers).
+ */
static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar)
{
PointerRNA id_ptr, ptr;
@@ -1879,12 +1889,14 @@ void driver_variable_name_validate(DriverVar *dvar)
}
/* 1) Must start with a letter */
- /* XXX: We assume that valid unicode letters in other languages are ok too, hence the blacklisting */
+ /* XXX: We assume that valid unicode letters in other languages are ok too,
+ * hence the blacklisting. */
if (IN_RANGE_INCL(dvar->name[0], '0', '9')) {
dvar->flag |= DVAR_FLAG_INVALID_START_NUM;
}
else if (dvar->name[0] == '_') {
- /* NOTE: We don't allow names to start with underscores (i.e. it helps when ruling out security risks) */
+ /* NOTE: We don't allow names to start with underscores
+ * (i.e. it helps when ruling out security risks) */
dvar->flag |= DVAR_FLAG_INVALID_START_CHAR;
}
@@ -1984,7 +1996,8 @@ void fcurve_free_driver(FCurve *fcu)
BLI_expr_pylike_free(driver->expr_simple);
- /* free driver itself, then set F-Curve's point to this to NULL (as the curve may still be used) */
+ /* Free driver itself, then set F-Curve's point to this to NULL
+ * (as the curve may still be used). */
MEM_freeN(driver);
fcu->driver = NULL;
}
@@ -2005,9 +2018,9 @@ ChannelDriver *fcurve_copy_driver(const ChannelDriver *driver)
ndriver->expr_simple = NULL;
/* copy variables */
- BLI_listbase_clear(
- &ndriver
- ->variables); /* to get rid of refs to non-copied data (that's still used on original) */
+
+ /* to get rid of refs to non-copied data (that's still used on original) */
+ BLI_listbase_clear(&ndriver->variables);
driver_variables_copy(&ndriver->variables, &driver->variables);
/* return the new driver */
@@ -2603,15 +2616,14 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
/* Use binary search to find appropriate keyframes...
*
* The threshold here has the following constraints:
- * - 0.001 is too coarse -> We get artifacts with 2cm driver movements at 1BU = 1m (see T40332)
- * - 0.00001 is too fine -> Weird errors, like selecting the wrong keyframe range (see T39207), occur.
- * This lower bound was established in b888a32eee8147b028464336ad2404d8155c64dd
+ * - 0.001 is too coarse:
+ * We get artifacts with 2cm driver movements at 1BU = 1m (see T40332)
+ *
+ * - 0.00001 is too fine:
+ * Weird errors, like selecting the wrong keyframe range (see T39207), occur.
+ * This lower bound was established in b888a32eee8147b028464336ad2404d8155c64dd.
*/
a = binarysearch_bezt_index_ex(bezts, evaltime, fcu->totvert, 0.0001, &exact);
- if (G.debug & G_DEBUG) {
- printf(
- "eval fcurve '%s' - %f => %u/%u, %d\n", fcu->rna_path, evaltime, a, fcu->totvert, exact);
- }
if (exact) {
/* index returned must be interpreted differently when it sits on top of an existing keyframe
@@ -2628,7 +2640,8 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
prevbezt = (a > 0) ? (bezt - 1) : bezt;
}
- /* use if the key is directly on the frame, rare cases this is needed else we get 0.0 instead. */
+ /* use if the key is directly on the frame,
+ * rare cases this is needed else we get 0.0 instead. */
/* XXX: consult T39207 for examples of files where failure of these checks can cause issues */
if (exact) {
cvalue = prevbezt->vec[1][1];
@@ -3013,9 +3026,9 @@ float evaluate_fcurve_driver(PathResolvedRNA *anim_rna,
BLI_assert(fcu->driver != NULL);
float cvalue = 0.0f;
- /* if there is a driver (only if this F-Curve is acting as 'driver'), evaluate it to find value to use as "evaltime"
- * since drivers essentially act as alternative input (i.e. in place of 'time') for F-Curves
- */
+ /* If there is a driver (only if this F-Curve is acting as 'driver'),
+ * evaluate it to find value to use as "evaltime" since drivers essentially act as alternative
+ * input (i.e. in place of 'time') for F-Curves. */
if (fcu->driver) {
/* evaltime now serves as input for the curve */
evaltime = evaluate_driver(anim_rna, fcu->driver, driver_orig, evaltime);
@@ -3032,12 +3045,12 @@ float evaluate_fcurve_driver(PathResolvedRNA *anim_rna,
/* if there are range-restrictions, we must definitely block [#36950] */
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime))) {
- /* within range: here it probably doesn't matter, though we'd want to check on additive... */
+ /* Within range: here it probably doesn't matter,
+ * though we'd want to check on additive. */
}
else {
- /* outside range: modifier shouldn't contribute to the curve here, though it does in other areas,
- * so neither should the driver!
- */
+ /* Outside range: modifier shouldn't contribute to the curve here,
+ * though it does in other areas, so neither should the driver! */
do_linear = false;
}
}
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 79808d20193..c6188642e41 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -95,8 +95,10 @@ static FModifierTypeInfo FMI_MODNAME = {
/* Generators available:
* 1) simple polynomial generator:
- * - Expanded form - (y = C[0]*(x^(n)) + C[1]*(x^(n-1)) + ... + C[n])
- * - Factorized form - (y = (C[0][0]*x + C[0][1]) * (C[1][0]*x + C[1][1]) * ... * (C[n][0]*x + C[n][1]))
+ * - Expanded form:
+ * (y = C[0]*(x^(n)) + C[1]*(x^(n-1)) + ... + C[n])
+ * - Factorized form:
+ * (y = (C[0][0]*x + C[0][1]) * (C[1][0]*x + C[1][1]) * ... * (C[n][0]*x + C[n][1]))
*/
static void fcm_generator_free(FModifier *fcm)
@@ -217,9 +219,9 @@ static void fcm_generator_evaluate(
float value = 1.0f, *cp = NULL;
unsigned int i;
- /* for each coefficient pair, solve for that bracket before accumulating in value by multiplying */
- for (cp = data->coefficients, i = 0; (cp) && (i < (unsigned int)data->poly_order);
- cp += 2, i++) {
+ /* For each coefficient pair,
+ * solve for that bracket before accumulating in value by multiplying. */
+ for (cp = data->coefficients, i = 0; (cp) && (i < (uint)data->poly_order); cp += 2, i++) {
value *= (cp[0] * evaltime + cp[1]);
}
@@ -594,14 +596,14 @@ int BKE_fcm_envelope_find_index(FCM_EnvelopeData array[],
/* This modifier changes evaltime to something that exists within the curve's frame-range,
* then re-evaluates modifier stack up to this point using the new time. This re-entrant behavior
- * is very likely to be more time-consuming than the original approach... (which was tightly integrated into
- * the calculation code...).
+ * is very likely to be more time-consuming than the original approach...
+ * (which was tightly integrated into the calculation code...).
*
- * NOTE: this needs to be at the start of the stack to be of use, as it needs to know the extents of the
- * keyframes/sample-data.
+ * NOTE: this needs to be at the start of the stack to be of use,
+ * as it needs to know the extents of the keyframes/sample-data.
*
- * Possible TODO - store length of cycle information that can be initialized from the extents of the
- * keyframes/sample-data, and adjusted as appropriate.
+ * Possible TODO - store length of cycle information that can be initialized from the extents of
+ * the keyframes/sample-data, and adjusted as appropriate.
*/
/* temp data used during evaluation */
@@ -740,9 +742,10 @@ static float fcm_cycles_time(
}
/* calculate where in the cycle we are (overwrite evaltime to reflect this) */
else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle + 1) % 2)) {
- /* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse
+ /* When 'mirror' option is used and cycle number is odd, this cycle is played in reverse
* - for 'before' extrapolation, we need to flip in a different way, otherwise values past
- * then end of the curve get referenced (result of fmod will be negative, and with different phase)
+ * then end of the curve get referenced
+ * (result of fmod will be negative, and with different phase).
*/
if (side < 0) {
evaltime = prevkey[0] - cyct;
@@ -891,7 +894,7 @@ static void fcm_python_evaluate(FCurve *UNUSED(fcu),
void *UNUSED(storage))
{
#ifdef WITH_PYTHON
- //FMod_Python *data = (FMod_Python *)fcm->data;
+ // FMod_Python *data = (FMod_Python *)fcm->data;
/* FIXME... need to implement this modifier...
* It will need it execute a script using the custom properties
@@ -1455,9 +1458,9 @@ float evaluate_time_fmodifiers(FModifiersStackStorage *storage,
continue;
}
- /* if modifier cannot be applied on this frame (whatever scale it is on, it won't affect the results)
- * hence we shouldn't bother seeing what it would do given the chance
- */
+ /* If modifier cannot be applied on this frame
+ * (whatever scale it is on, it won't affect the results)
+ * hence we shouldn't bother seeing what it would do given the chance. */
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime))) {
/* only evaluate if there's a callback for this */
@@ -1508,7 +1511,8 @@ void evaluate_value_fmodifiers(FModifiersStackStorage *storage,
continue;
}
- /* only evaluate if there's a callback for this, and if F-Modifier can be evaluated on this frame */
+ /* Only evaluate if there's a callback for this,
+ * and if F-Modifier can be evaluated on this frame. */
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime))) {
if (fmi->evaluate_modifier) {
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 9ee8ecd1b64..70a8f4f124c 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -674,7 +674,8 @@ enum {
* Descent: the recommended distance below the baseline to fit most characters.
*
* We obtain ascent and descent from the font itself (FT_Face->ascender / face->height).
- * And in some cases it is even the same value as FT_Face->bbox.yMax/yMin (font top and bottom respectively).
+ * And in some cases it is even the same value as FT_Face->bbox.yMax/yMin
+ * (font top and bottom respectively).
*
* The em_height here is relative to FT_Face->bbox.
*/
@@ -1405,7 +1406,8 @@ static bool vfont_to_curve(Object *ob,
}
if (ob == NULL || info->mat_nr > (ob->totcol)) {
- /* CLOG_ERROR(&LOG, "Illegal material index (%d) in text object, setting to 0", info->mat_nr); */
+ // CLOG_ERROR(
+ // &LOG, "Illegal material index (%d) in text object, setting to 0", info->mat_nr);
info->mat_nr = 0;
}
/* We do not want to see any character for \n or \r */
@@ -1625,7 +1627,8 @@ bool BKE_vfont_to_curve_nubase(Object *ob, int mode, ListBase *r_nubase)
return BKE_vfont_to_curve_ex(ob, ob->data, mode, r_nubase, NULL, NULL, NULL, NULL);
}
-/** Warning: expects to have access to evaluated data (i.e. passed object should be evaluated one...). */
+/** Warning: expects to have access to evaluated data
+ * (i.e. passed object should be evaluated one...). */
bool BKE_vfont_to_curve(Object *ob, int mode)
{
Curve *cu = ob->data;
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index e45a4f4d649..439005ca1b4 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -622,8 +622,10 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src)
}
/**
- * Only copy internal data of GreasePencil ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of GreasePencil ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -1107,7 +1109,8 @@ Material *BKE_gpencil_object_material_new(Main *bmain, Object *ob, const char *n
/* Returns the material for a brush with respect to its pinned state. */
Material *BKE_gpencil_object_material_get_from_brush(Object *ob, Brush *brush)
{
- if ((brush) && (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED)) {
+ if ((brush) && (brush->gpencil_settings) &&
+ (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED)) {
Material *ma = BKE_gpencil_brush_material_get(brush);
return ma;
}
@@ -1159,7 +1162,10 @@ Material *BKE_gpencil_object_material_ensure_from_active_input_brush(Main *bmain
return BKE_gpencil_object_material_ensure_from_active_input_material(bmain, ob);
}
-/* Guaranteed to return a material assigned to object. Returns never NULL. Only use this for materials unrelated to user input */
+/**
+ * Guaranteed to return a material assigned to object. Returns never NULL.
+ * Only use this for materials unrelated to user input.
+ */
Material *BKE_gpencil_object_material_ensure_from_active_input_material(Main *bmain, Object *ob)
{
Material *ma = give_current_material(ob, ob->actcol);
@@ -1416,9 +1422,11 @@ bool BKE_gpencil_smooth_stroke(bGPDstroke *gps, int i, float inf)
}
/* Compute smoothed coordinate by taking the ones nearby */
- /* XXX: This is potentially slow, and suffers from accumulation error as earlier points are handled before later ones */
+ /* XXX: This is potentially slow,
+ * and suffers from accumulation error as earlier points are handled before later ones. */
{
- // XXX: this is hardcoded to look at 2 points on either side of the current one (i.e. 5 items total)
+ /* XXX: this is hardcoded to look at 2 points on either side of the current one
+ * (i.e. 5 items total). */
const int steps = 2;
const float average_fac = 1.0f / (float)(steps * 2 + 1);
int step;
@@ -1427,8 +1435,9 @@ bool BKE_gpencil_smooth_stroke(bGPDstroke *gps, int i, float inf)
madd_v3_v3fl(sco, &pt->x, average_fac);
/* n-steps before/after current point */
- // XXX: review how the endpoints are treated by this algorithm
- // XXX: falloff measures should also introduce some weighting variations, so that further-out points get less weight
+ /* XXX: review how the endpoints are treated by this algorithm. */
+ /* XXX: falloff measures should also introduce some weighting variations,
+ * so that further-out points get less weight. */
for (step = 1; step <= steps; step++) {
bGPDspoint *pt1, *pt2;
int before = i - step;
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index 08162276a64..8a5a36481cf 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -300,7 +300,10 @@ PreviewImage *BKE_previewimg_copy(const PreviewImage *prv)
return prv_img;
}
-/** Duplicate preview image from \a id and clear icon_id, to be used by datablock copy functions. */
+/**
+ * Duplicate preview image from \a id and clear icon_id,
+ * to be used by datablock copy functions.
+ */
void BKE_previewimg_id_copy(ID *new_id, const ID *old_id)
{
PreviewImage **old_prv_p = BKE_previewimg_id_get_p(old_id);
@@ -534,8 +537,9 @@ void BKE_icon_changed(const int icon_id)
BLI_assert(icon->id_type != 0);
BLI_assert(icon->obj_type == ICON_DATA_ID);
- /* Do not enforce creation of previews for valid ID types using BKE_previewimg_id_ensure() here ,
- * we only want to ensure *existing* preview images are properly tagged as changed/invalid, that's all. */
+ /* Do not enforce creation of previews for valid ID types using BKE_previewimg_id_ensure()
+ * here, we only want to ensure *existing* preview images are properly tagged as
+ * changed/invalid, that's all. */
PreviewImage **p_prv = BKE_previewimg_id_get_p((ID *)icon->obj);
/* If we have previews, they all are now invalid changed. */
@@ -676,7 +680,8 @@ int BKE_icon_preview_ensure(ID *id, PreviewImage *preview)
return 0;
}
- /* Ensure we synchronize ID icon_id with its previewimage if available, and generate suitable 'ID' icon. */
+ /* Ensure we synchronize ID icon_id with its previewimage if available,
+ * and generate suitable 'ID' icon. */
if (id) {
id->icon_id = preview->icon_id;
return icon_id_ensure_create_icon(id);
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index aebed7e0e91..39e72d7e3a8 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -665,13 +665,14 @@ void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overw
*
* The sanity check just means the property is not added to the group if another property
* exists with the same name; the client code using ID properties then needs to detect this
- * (the function that adds new properties to groups, IDP_AddToGroup, returns false if a property can't
- * be added to the group, and true if it can) and free the property.
+ * (the function that adds new properties to groups, #IDP_AddToGroup,
+ * returns false if a property can't be added to the group, and true if it can)
+ * and free the property.
*
* Currently the code to free ID properties is designed to leave the actual struct
* you pass it un-freed, this is needed for how the system works. This means
- * to free an ID property, you first call IDP_FreeProperty then MEM_freeN the
- * struct. In the future this will just be IDP_FreeProperty and the code will
+ * to free an ID property, you first call #IDP_FreeProperty then #MEM_freeN the struct.
+ * In the future this will just be #IDP_FreeProperty and the code will
* be reorganized to work properly.
*/
bool IDP_AddToGroup(IDProperty *group, IDProperty *prop)
@@ -787,7 +788,8 @@ IDProperty *IDP_CopyProperty(const IDProperty *prop)
}
/* Updates ID pointers after an object has been copied */
-/* TODO Nuke this once its only user has been correctly converted to use generic ID management from BKE_library! */
+/* TODO Nuke this once its only user has been correctly converted
+ * to use generic ID management from BKE_library! */
void IDP_RelinkProperty(struct IDProperty *prop)
{
if (!prop) {
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index eaf90bd4ebb..f23c58befdf 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -383,8 +383,10 @@ static void copy_image_packedfiles(ListBase *lb_dst, const ListBase *lb_src)
}
/**
- * Only copy internal data of Image ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Image ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -5311,9 +5313,11 @@ bool BKE_image_remove_renderslot(Image *ima, ImageUser *iuser, int index)
next_slot = current_slot;
}
- /* If the slot to be removed is the slot with the last render, make another slot the last render slot. */
+ /* If the slot to be removed is the slot with the last render,
+ * make another slot the last render slot. */
if (remove_slot == current_last_slot) {
- /* Choose the currently selected slot unless that one is being removed, in that case take the next one. */
+ /* Choose the currently selected slot unless that one is being removed,
+ * in that case take the next one. */
RenderSlot *next_last_slot;
if (current_slot == remove_slot) {
next_last_slot = next_slot;
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index d641229d5e0..63ef1458de8 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -337,7 +337,8 @@ static const char *constraint_adrcodes_to_paths(int adrcode, int *array_index)
switch (adrcode) {
case CO_ENFORCE:
return "influence";
- case CO_HEADTAIL: // XXX this needs to be wrapped in RNA.. probably then this path will be invalid
+ case CO_HEADTAIL:
+ /* XXX this needs to be wrapped in RNA.. probably then this path will be invalid. */
return "data.head_tail";
}
@@ -510,10 +511,10 @@ static const char *texture_adrcodes_to_paths(int adrcode, int *array_index)
return "turbulence";
case TE_NDEPTH: // XXX texture RNA undefined
- //poin= &(tex->noisedepth); *type= IPO_SHORT; break;
+ // poin= &(tex->noisedepth); *type= IPO_SHORT; break;
break;
case TE_NTYPE: // XXX texture RNA undefined
- //poin= &(tex->noisetype); *type= IPO_SHORT; break;
+ // poin= &(tex->noisetype); *type= IPO_SHORT; break;
break;
case TE_N_BAS1:
@@ -685,12 +686,13 @@ static const char *camera_adrcodes_to_paths(int adrcode, int *array_index)
/* result depends on adrcode */
switch (adrcode) {
case CAM_LENS:
-#if 0 // XXX this cannot be resolved easily... perhaps we assume camera is perspective (works for most cases...
+#if 0 /* XXX this cannot be resolved easily... \
+ * perhaps we assume camera is perspective (works for most cases... */
if (ca->type == CAM_ORTHO)
return "ortho_scale";
else
return "lens";
-#else // XXX lazy hack for now...
+#else // XXX lazy hack for now...
return "lens";
#endif // XXX this cannot be resolved easily
@@ -775,7 +777,8 @@ static const char *sound_adrcodes_to_paths(int adrcode, int *array_index)
return "volume";
case SND_PITCH:
return "pitch";
- /* XXX Joshua -- I had wrapped panning in rna, but someone commented out, calling it "unused" */
+ /* XXX Joshua -- I had wrapped panning in rna,
+ * but someone commented out, calling it "unused" */
#if 0
case SND_PANNING:
return "panning";
@@ -912,14 +915,17 @@ static const char *particle_adrcodes_to_paths(int adrcode, int *array_index)
/* ------- */
-/* Allocate memory for RNA-path for some property given a blocktype, adrcode, and 'root' parts of path
+/* Allocate memory for RNA-path for some property given a blocktype, adrcode,
+ * and 'root' parts of path.
+ *
* Input:
- * - id - the datablock that the curve's IPO block is attached to and/or which the new paths will start from
- * - blocktype, adrcode - determines setting to get
- * - actname, constname,seq - used to build path
+ * - id - the datablock that the curve's IPO block
+ * is attached to and/or which the new paths will start from
+ * - blocktype, adrcode - determines setting to get
+ * - actname, constname, seq - used to build path
* Output:
- * - array_index - index in property's array (if applicable) to use
- * - return - the allocated path...
+ * - array_index - index in property's array (if applicable) to use
+ * - return - the allocated path...
*/
static char *get_rna_access(ID *id,
int blocktype,
@@ -995,7 +1001,7 @@ static char *get_rna_access(ID *id,
/* XXX problematic blocktypes */
case ID_SEQ: /* sequencer strip */
- //SEQ_FAC1:
+ // SEQ_FAC1:
switch (adrcode) {
case SEQ_FAC1:
propname = "effect_fader";
@@ -1022,7 +1028,8 @@ static char *get_rna_access(ID *id,
}
/* check if any property found
- * - blocktype < 0 is special case for a specific type of driver, where we don't need a property name...
+ * - blocktype < 0 is special case for a specific type of driver,
+ * where we don't need a property name...
*/
if ((propname == NULL) && (blocktype > 0)) {
/* nothing was found, so exit */
@@ -1053,7 +1060,8 @@ static char *get_rna_access(ID *id,
buf[0] = '\0'; /* empty string */
}
else if ((blocktype == ID_KE) && STREQ(actname, "Shape")) {
- /* Actionified "Shape" IPO's - these are forced onto object level via the action container there... */
+ /* Actionified "Shape" IPO's -
+ * these are forced onto object level via the action container there... */
strcpy(buf, "data.shape_keys");
}
else {
@@ -1257,7 +1265,8 @@ static void fcurve_add_to_list(
}
/* add F-Curve to group */
- /* WARNING: this func should only need to look at the stuff we initialized, if not, things may crash */
+ /* WARNING: this func should only need to look at the stuff we initialized,
+ * if not, things may crash. */
action_groups_add_channel(&tmp_act, agrp, fcu);
if (agrp->flag & AGRP_MUTED) { /* flush down */
@@ -1276,11 +1285,14 @@ static void fcurve_add_to_list(
}
}
-/* Convert IPO-Curve to F-Curve (including Driver data), and free any of the old data that
+/**
+ * Convert IPO-Curve to F-Curve (including Driver data), and free any of the old data that
* is not relevant, BUT do not free the IPO-Curve itself...
- * actname: name of Action-Channel (if applicable) that IPO-Curve's IPO-block belonged to
- * constname: name of Constraint-Channel (if applicable) that IPO-Curve's IPO-block belonged to
- * seq: sequencer-strip (if applicable) that IPO-Curve's IPO-block belonged to
+ *
+ * \param actname: name of Action-Channel (if applicable) that IPO-Curve's IPO-block belonged to.
+ * \param constname: name of Constraint-Channel (if applicable)
+ * that IPO-Curve's IPO-block belonged to \a seq.
+ * \param seq: sequencer-strip (if applicable) that IPO-Curve's IPO-block belonged to.
*/
static void icu_to_fcurves(ID *id,
ListBase *groups,
@@ -1385,9 +1397,11 @@ static void icu_to_fcurves(ID *id,
fcurve->rna_path = BLI_strdup(abp->path);
fcurve->array_index = abp->array_index;
- /* convert keyframes
- * - beztriples and bpoints are mutually exclusive, so we won't have both at the same time
- * - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet)
+ /* Convert keyframes:
+ * - Beztriples and bpoints are mutually exclusive,
+ * so we won't have both at the same time.
+ * - Beztriples are more likely to be encountered as they are keyframes
+ * (the other type wasn't used yet).
*/
fcurve->totvert = icu->totvert;
@@ -1428,9 +1442,10 @@ static void icu_to_fcurves(ID *id,
}
}
else if (icu->bp) {
- /* TODO: need to convert from BPoint type to the more compact FPoint type... but not priority, since no data used this */
- //BPoint *bp;
- //FPoint *fpt;
+ /* TODO: need to convert from BPoint type to the more compact FPoint type...
+ * but not priority, since no data used this. */
+ // BPoint *bp;
+ // FPoint *fpt;
}
/* add new F-Curve to list */
@@ -1449,9 +1464,10 @@ static void icu_to_fcurves(ID *id,
fcu->flag |= FCURVE_DISABLED;
}
- /* convert keyframes
- * - beztriples and bpoints are mutually exclusive, so we won't have both at the same time
- * - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet)
+ /* Convert keyframes:
+ * - Beztriples and bpoints are mutually exclusive, so we won't have both at the same time.
+ * - Beztriples are more likely to be encountered as they are keyframes
+ * (the other type wasn't used yet).
*/
fcu->totvert = icu->totvert;
@@ -1490,7 +1506,7 @@ static void icu_to_fcurves(ID *id,
*/
if (((icu->blocktype == ID_OB) && ELEM(icu->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) ||
((icu->blocktype == ID_PO) && ELEM(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z))) {
- const float fac = (float)M_PI / 18.0f; //10.0f * M_PI/180.0f;
+ const float fac = (float)M_PI / 18.0f; // 10.0f * M_PI/180.0f;
dst->vec[0][1] *= fac;
dst->vec[1][1] *= fac;
@@ -1548,9 +1564,10 @@ static void icu_to_fcurves(ID *id,
}
}
else if (icu->bp) {
- /* TODO: need to convert from BPoint type to the more compact FPoint type... but not priority, since no data used this */
- //BPoint *bp;
- //FPoint *fpt;
+ /* TODO: need to convert from BPoint type to the more compact FPoint type...
+ * but not priority, since no data used this */
+ // BPoint *bp;
+ // FPoint *fpt;
}
/* add new F-Curve to list */
@@ -1602,10 +1619,11 @@ static void ipo_to_animato(ID *id,
/* loop over IPO-Curves, freeing as we progress */
for (icu = ipo->curve.first; icu; icu = icu->next) {
/* Since an IPO-Curve may end up being made into many F-Curves (i.e. bitflag curves),
- * we figure out the best place to put the channel, then tell the curve-converter to just dump there
- */
+ * we figure out the best place to put the channel,
+ * then tell the curve-converter to just dump there. */
if (icu->driver) {
- /* Blender 2.4x allowed empty drivers, but we don't now, since they cause more trouble than they're worth */
+ /* Blender 2.4x allowed empty drivers,
+ * but we don't now, since they cause more trouble than they're worth. */
if ((icu->driver->ob) || (icu->driver->type == IPO_DRIVER_TYPE_PYTHON)) {
icu_to_fcurves(id, NULL, drivers, icu, actname, constname, seq, ipo->muteipo);
}
@@ -1734,9 +1752,9 @@ static void ipo_to_animdata(
BLI_listbase_count(&ipo->curve));
}
- /* Convert curves to animato system (separated into separate lists of F-Curves for animation and drivers),
- * and the try to put these lists in the right places, but do not free the lists here
- */
+ /* Convert curves to animato system
+ * (separated into separate lists of F-Curves for animation and drivers),
+ * and the try to put these lists in the right places, but do not free the lists here. */
// XXX there shouldn't be any need for the groups, so don't supply pointer for that now...
ipo_to_animato(id, ipo, actname, constname, seq, NULL, &anim, &drivers);
@@ -1819,7 +1837,8 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips)
/* convert Action data (if not yet converted), storing the results in the same Action */
action_to_animato(id, as->act, &as->act->groups, &as->act->curves, &adt->drivers);
- /* create a new-style NLA-strip which references this Action, then copy over relevant settings */
+ /* Create a new-style NLA-strip which references this Action,
+ * then copy over relevant settings. */
{
/* init a new strip, and assign the action to it
* - no need to muck around with the user-counts, since this is just
@@ -2295,12 +2314,12 @@ void do_versions_ipos_to_animato(Main *bmain)
/* --------- Unconverted Animation Data ------------------ */
/* For Animation data which may not be directly connected (i.e. not linked) to any other
* data, we need to perform a separate pass to make sure that they are converted to standalone
- * Actions which may then be able to be reused. This does mean that we will be going over data that's
- * already been converted, but there are no problems with that.
+ * Actions which may then be able to be reused. This does mean that we will be going over data
+ * that's already been converted, but there are no problems with that.
*
* The most common case for this will be Action Constraints, or IPO's with Fake-Users.
- * We collect all drivers that were found into a temporary collection, and free them in one go, as they're
- * impossible to resolve.
+ * We collect all drivers that were found into a temporary collection, and free them in one go,
+ * as they're impossible to resolve.
*/
/* actions */
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index e0246f874f3..61de6a8c06a 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -151,8 +151,10 @@ Key *BKE_key_add(Main *bmain, ID *id) /* common function */
}
/**
- * Only copy internal data of ShapeKey ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of ShapeKey ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -2254,8 +2256,9 @@ void BKE_keyblock_update_from_offset(Object *ob, KeyBlock *kb, float (*ofs)[3])
/* ==========================================================*/
-/** Move shape key from org_index to new_index. Safe, clamps index to valid range, updates reference keys,
- * the object's active shape index, the 'frame' value in case of absolute keys, etc.
+/** Move shape key from org_index to new_index. Safe, clamps index to valid range,
+ * updates reference keys, the object's active shape index,
+ * the 'frame' value in case of absolute keys, etc.
* Note indices are expected in real values (not 'fake' shapenr +1 ones).
*
* \param org_index: if < 0, current object's active shape will be used as skey to move.
@@ -2283,8 +2286,8 @@ bool BKE_keyblock_move(Object *ob, int org_index, int new_index)
rev = ((new_index - org_index) < 0) ? true : false;
- /* We swap 'org' element with its previous/next neighbor (depending on direction of the move) repeatedly,
- * until we reach final position.
+ /* We swap 'org' element with its previous/next neighbor (depending on direction of the move)
+ * repeatedly, until we reach final position.
* This allows us to only loop on the list once! */
for (kb = (rev ? key->block.last : key->block.first), i = (rev ? totkey - 1 : 0); kb;
kb = (rev ? kb->prev : kb->next), rev ? i-- : i++) {
@@ -2321,7 +2324,8 @@ bool BKE_keyblock_move(Object *ob, int org_index, int new_index)
}
}
- /* Need to update active shape number if it's affected, same principle as for relative indices above. */
+ /* Need to update active shape number if it's affected,
+ * same principle as for relative indices above. */
if (org_index == act_index) {
ob->shapenr = new_index + 1;
}
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 5570d39f43f..b8178bec52f 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -32,6 +32,7 @@
#include "BLI_listbase.h"
#include "BLI_bitmap.h"
#include "BLI_math.h"
+#include "BLI_task.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -268,8 +269,10 @@ Lattice *BKE_lattice_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Lattice ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Lattice ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -681,8 +684,8 @@ static bool calc_curve_deform(
if (cd->no_rot_axis) { /* set by caller */
- /* this is not exactly the same as 2.4x, since the axis is having rotation removed rather than
- * changing the axis before calculating the tilt but serves much the same purpose */
+ /* This is not exactly the same as 2.4x, since the axis is having rotation removed rather
+ * than changing the axis before calculating the tilt but serves much the same purpose. */
float dir_flat[3] = {0, 0, 0}, q[4];
copy_v3_v3(dir_flat, dir);
dir_flat[cd->no_rot_axis - 1] = 0.0f;
@@ -699,8 +702,10 @@ static bool calc_curve_deform(
*
* The way 'co' is copied to 'cent' may seem to have no meaning, but it does.
*
- * Use a curve modifier to stretch a cube out, color each side RGB, positive side light, negative dark.
- * view with X up (default), from the angle that you can see 3 faces RGB colors (light), anti-clockwise
+ * Use a curve modifier to stretch a cube out, color each side RGB,
+ * positive side light, negative dark.
+ * view with X up (default), from the angle that you can see 3 faces RGB colors (light),
+ * anti-clockwise
* Notice X,Y,Z Up all have light colors and each ordered CCW.
*
* Now for Neg Up XYZ, the colors are all dark, and ordered clockwise - Campbell
@@ -874,6 +879,31 @@ void curve_deform_vector(
mul_m4_v3(cd.objectspace, vec);
}
+typedef struct LatticeDeformUserdata {
+ LatticeDeformData *lattice_deform_data;
+ float (*vertexCos)[3];
+ MDeformVert *dvert;
+ int defgrp_index;
+ float fac;
+} LatticeDeformUserdata;
+
+static void lattice_deform_vert_task(void *__restrict userdata,
+ const int index,
+ const ParallelRangeTLS *__restrict UNUSED(tls))
+{
+ const LatticeDeformUserdata *data = userdata;
+
+ if (data->dvert != NULL) {
+ const float weight = defvert_find_weight(data->dvert + index, data->defgrp_index);
+ if (weight > 0.0f) {
+ calc_latt_deform(data->lattice_deform_data, data->vertexCos[index], weight * data->fac);
+ }
+ }
+ else {
+ calc_latt_deform(data->lattice_deform_data, data->vertexCos[index], data->fac);
+ }
+}
+
void lattice_deform_verts(Object *laOb,
Object *target,
Mesh *mesh,
@@ -885,7 +915,6 @@ void lattice_deform_verts(Object *laOb,
LatticeDeformData *lattice_deform_data;
MDeformVert *dvert = NULL;
int defgrp_index = -1;
- int a;
if (laOb->type != OB_LATTICE) {
return;
@@ -912,20 +941,18 @@ void lattice_deform_verts(Object *laOb,
}
}
}
- if (dvert) {
- MDeformVert *dvert_iter;
- for (a = 0, dvert_iter = dvert; a < numVerts; a++, dvert_iter++) {
- const float weight = defvert_find_weight(dvert_iter, defgrp_index);
- if (weight > 0.0f) {
- calc_latt_deform(lattice_deform_data, vertexCos[a], weight * fac);
- }
- }
- }
- else {
- for (a = 0; a < numVerts; a++) {
- calc_latt_deform(lattice_deform_data, vertexCos[a], fac);
- }
- }
+
+ LatticeDeformUserdata data = {.lattice_deform_data = lattice_deform_data,
+ .vertexCos = vertexCos,
+ .dvert = dvert,
+ .defgrp_index = defgrp_index,
+ .fac = fac};
+
+ ParallelRangeSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.min_iter_per_thread = 32;
+ BLI_task_parallel_range(0, numVerts, &data, lattice_deform_vert_task, &settings);
+
end_latt_deform(lattice_deform_data);
}
@@ -1061,7 +1088,8 @@ void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3])
void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Object *ob)
{
Lattice *lt = ob->data;
- /* Get vertex coordinates from the original copy; otherwise we get already-modified coordinates. */
+ /* Get vertex coordinates from the original copy;
+ * otherwise we get already-modified coordinates. */
Object *ob_orig = DEG_get_original_object(ob);
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index f0c2c1e5477..fc349e62809 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -35,7 +35,6 @@
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_object.h"
-#include "BKE_scene.h"
#include "DNA_ID.h"
#include "DNA_space_types.h"
@@ -91,7 +90,9 @@ static Base *object_base_new(Object *ob)
{
Base *base = MEM_callocN(sizeof(Base), "Object Base");
base->object = ob;
- BKE_scene_object_base_flag_sync_from_object(base);
+ if (ob->base_flag & BASE_SELECTED) {
+ base->flag |= BASE_SELECTED;
+ }
return base;
}
@@ -345,19 +346,14 @@ void BKE_view_layer_base_deselect_all(ViewLayer *view_layer)
}
}
-void BKE_view_layer_base_select(Base *selbase)
+void BKE_view_layer_base_select_and_set_active(struct ViewLayer *view_layer, Base *selbase)
{
+ view_layer->basact = selbase;
if ((selbase->flag & BASE_SELECTABLE) != 0) {
selbase->flag |= BASE_SELECTED;
}
}
-void BKE_view_layer_base_select_and_set_active(struct ViewLayer *view_layer, Base *selbase)
-{
- view_layer->basact = selbase;
- BKE_view_layer_base_select(selbase);
-}
-
/**************************** Copy View Layer and Layer Collections ***********************/
static void layer_collections_copy_data(ViewLayer *view_layer_dst,
@@ -1100,7 +1096,8 @@ static void layer_collection_bases_hide_recursive(ViewLayer *view_layer, LayerCo
/**
* Hide/show all the elements of a collection.
- * Don't change the collection children enable/disable state, but it may change it for the collection itself.
+ * Don't change the collection children enable/disable state,
+ * but it may change it for the collection itself.
*
* Return true if depsgraph needs update.
*/
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index ca73415b962..ad0c405ab28 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -170,11 +170,14 @@ void id_lib_extern(ID *id)
}
}
-/* ensure we have a real user */
-/* Note: Now that we have flags, we could get rid of the 'fake_user' special case, flags are enough to ensure
- * we always have a real user.
- * However, ID_REAL_USERS is used in several places outside of core library.c, so think we can wait later
- * to make this change... */
+/**
+ * Ensure we have a real user
+ *
+ * \note Now that we have flags, we could get rid of the 'fake_user' special case,
+ * flags are enough to ensure we always have a real user.
+ * However, #ID_REAL_USERS is used in several places outside of core library.c,
+ * so think we can wait later to make this change.
+ */
void id_us_ensure_real(ID *id)
{
if (id) {
@@ -254,7 +257,8 @@ void id_us_min(ID *id)
}
if ((id->us == limit) && (id->tag & LIB_TAG_EXTRAUSER)) {
- /* We need an extra user here, but never actually incremented user count for it so far, do it now. */
+ /* We need an extra user here, but never actually incremented user count for it so far,
+ * do it now. */
id_us_ensure_real(id);
}
}
@@ -293,7 +297,8 @@ static int id_expand_local_callback(void *UNUSED(user_data),
return IDWALK_RET_NOP;
}
- /* Can happen that we get unlinkable ID here, e.g. with shapekey referring to itself (through drivers)...
+ /* Can happen that we get un-linkable ID here, e.g. with shape-key referring to itself
+ * (through drivers)...
* Just skip it, shape key can only be either indirectly linked, or fully local, period.
* And let's curse one more time that stupid useless shapekey ID type! */
if (*id_pointer && *id_pointer != id_self && BKE_idcode_is_linkable(GS((*id_pointer)->name))) {
@@ -304,7 +309,8 @@ static int id_expand_local_callback(void *UNUSED(user_data),
}
/**
- * Expand ID usages of given id as 'extern' (and no more indirect) linked data. Used by ID copy/make_local functions.
+ * Expand ID usages of given id as 'extern' (and no more indirect) linked data.
+ * Used by ID copy/make_local functions.
*/
void BKE_id_expand_local(Main *bmain, ID *id)
{
@@ -335,7 +341,8 @@ void BKE_id_make_local_generic(Main *bmain,
/* - only lib users: do nothing (unless force_local is set)
* - only local users: set flag
* - mixed: make copy
- * In case we make a whole lib's content local, we always want to localize, and we skip remapping (done later).
+ * In case we make a whole lib's content local,
+ * we always want to localize, and we skip remapping (done later).
*/
if (!ID_IS_LINKED(id)) {
@@ -352,7 +359,8 @@ void BKE_id_make_local_generic(Main *bmain,
else {
ID *id_new;
- /* Should not fail in expected usecases, but a few ID types cannot be copied (LIB, WM, SCR...). */
+ /* Should not fail in expected use cases,
+ * but a few ID types cannot be copied (LIB, WM, SCR...). */
if (BKE_id_copy(bmain, id, &id_new)) {
id_new->us = 0;
@@ -380,13 +388,15 @@ void BKE_id_make_local_generic(Main *bmain,
*
* \note Always set ID->newid pointer in case it gets duplicated...
*
- * \param lib_local: Special flag used when making a whole library's content local, it needs specific handling.
+ * \param lib_local: Special flag used when making a whole library's content local,
+ * it needs specific handling.
*
* \return true if the block can be made local.
*/
bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
{
- /* We don't care whether ID is directly or indirectly linked in case we are making a whole lib local... */
+ /* We don't care whether ID is directly or indirectly linked
+ * in case we are making a whole lib local... */
if (!lib_local && (id->tag & LIB_TAG_INDIRECT)) {
return false;
}
@@ -601,15 +611,18 @@ bool BKE_id_copy_is_allowed(const ID *id)
/**
* Generic entry point for copying a datablock (new API).
*
- * \note Copy is only affecting given data-block (no ID used by copied one will be affected, besides usercount).
- * There is only one exception, if LIB_ID_COPY_ACTIONS is defined, actions used by animdata will be duplicated.
+ * \note Copy is only affecting given data-block
+ * (no ID used by copied one will be affected, besides usercount).
+ * There is only one exception, if #LIB_ID_COPY_ACTIONS is defined,
+ * actions used by animdata will be duplicated.
*
* \note Usercount of new copy is always set to 1.
*
* \param bmain: Main database, may be NULL only if LIB_ID_CREATE_NO_MAIN is specified.
* \param id: Source datablock.
* \param r_newid: Pointer to new (copied) ID pointer.
- * \param flag: Set of copy options, see DNA_ID.h enum for details (leave to zero for default, full copy).
+ * \param flag: Set of copy options, see DNA_ID.h enum for details
+ * (leave to zero for default, full copy).
* \return False when copying that ID type is not supported, true otherwise.
*/
bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
@@ -848,7 +861,8 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
PointerRNA idptr;
if (id) {
- /* if property isn't editable, we're going to have an extra block hanging around until we save */
+ /* If property isn't editable,
+ * we're going to have an extra block hanging around until we save. */
if (RNA_property_editable(ptr, prop)) {
Main *bmain = CTX_data_main(C);
/* copy animation actions too */
@@ -1372,7 +1386,9 @@ void *BKE_id_new(Main *bmain, const short type, const char *name)
return id;
}
-/** Generic helper to create a new temporary empty datablock of given type, *outside* of any Main database.
+/**
+ * Generic helper to create a new temporary empty datablock of given type,
+ * *outside* of any Main database.
*
* \param name: can be NULL, in which case we get default name for this ID type. */
void *BKE_id_new_nomain(const short type, const char *name)
@@ -1743,7 +1759,8 @@ void id_clear_lib_data_ex(Main *bmain, ID *id, const bool id_in_mainlist)
}
}
- /* Internal bNodeTree blocks inside datablocks also stores id->lib, make sure this stays in sync. */
+ /* Internal bNodeTree blocks inside datablocks also stores id->lib,
+ * make sure this stays in sync. */
if ((ntree = ntreeFromID(id))) {
id_clear_lib_data_ex(bmain, &ntree->id, false); /* Datablocks' nodetree is never in Main. */
}
@@ -1788,14 +1805,15 @@ static void library_make_local_copying_check(ID *id,
/* Our oh-so-beloved 'from' pointers... */
if (entry->usage_flag & IDWALK_CB_LOOPBACK) {
- /* We totally disregard Object->proxy_from 'usage' here, this one would only generate fake positives. */
+ /* We totally disregard Object->proxy_from 'usage' here,
+ * this one would only generate fake positives. */
if (GS(par_id->name) == ID_OB) {
BLI_assert(((Object *)par_id)->proxy_from == (Object *)id);
continue;
}
- /* Shapekeys are considered 'private' to their owner ID here, and never tagged (since they cannot be linked),
- * so we have to switch effective parent to their owner. */
+ /* Shapekeys are considered 'private' to their owner ID here, and never tagged
+ * (since they cannot be linked), * so we have to switch effective parent to their owner. */
if (GS(par_id->name) == ID_KE) {
par_id = ((Key *)par_id)->from;
}
@@ -1809,8 +1827,9 @@ static void library_make_local_copying_check(ID *id,
if (BLI_gset_haskey(loop_tags, par_id)) {
/* We are in a 'dependency loop' of IDs, this does not say us anything, skip it.
* Note that this is the situation that can lead to archipelagoes of linked data-blocks
- * (since all of them have non-local users, they would all be duplicated, leading to a loop of unused
- * linked data-blocks that cannot be freed since they all use each other...). */
+ * (since all of them have non-local users, they would all be duplicated,
+ * leading to a loop of unused linked data-blocks that cannot be freed since they all use
+ * each other...). */
continue;
}
/* Else, recursively check that user ID. */
@@ -1818,10 +1837,12 @@ static void library_make_local_copying_check(ID *id,
}
if (par_id->tag & LIB_TAG_DOIT) {
- /* This user will be fully local in future, so far so good, nothing to do here but check next user. */
+ /* This user will be fully local in future, so far so good,
+ * nothing to do here but check next user. */
}
else {
- /* This user won't be fully local in future, so current ID won't be either. And we are done checking it. */
+ /* This user won't be fully local in future, so current ID won't be either.
+ * And we are done checking it. */
id->tag &= ~LIB_TAG_DOIT;
break;
}
@@ -1835,15 +1856,16 @@ static void library_make_local_copying_check(ID *id,
* \param bmain: Almost certainly global main.
* \param lib: If not NULL, only make local datablocks from this library.
* \param untagged_only: If true, only make local datablocks not tagged with LIB_TAG_PRE_EXISTING.
- * \param set_fake: If true, set fake user on all localized datablocks (except group and objects ones).
+ * \param set_fake: If true, set fake user on all localized data-blocks
+ * (except group and objects ones).
*/
-/* Note: Old (2.77) version was simply making (tagging) datablocks as local, without actually making any check whether
- * they were also indirectly used or not...
+/* Note: Old (2.77) version was simply making (tagging) data-blocks as local,
+ * without actually making any check whether * they were also indirectly used or not...
*
- * Current version uses regular id_make_local callback, with advanced pre-processing step to detect all cases of
- * IDs currently indirectly used, but which will be used by local data only once this function is finished.
- * This allows to avoid any unneeded duplication of IDs, and hence all time lost afterwards to remove
- * orphaned linked data-blocks...
+ * Current version uses regular id_make_local callback, with advanced pre-processing step to detect
+ * all cases of IDs currently indirectly used, but which will be used by local data only once this
+ * function is finished. This allows to avoid any unneeded duplication of IDs, and hence all time
+ * lost afterwards to remove orphaned linked data-blocks...
*/
void BKE_library_make_local(Main *bmain,
const Library *lib,
@@ -1874,8 +1896,8 @@ void BKE_library_make_local(Main *bmain,
for (int a = set_listbasepointers(bmain, lbarray); a--;) {
ID *id = lbarray[a]->first;
- /* Do not explicitly make local non-linkable IDs (shapekeys, in fact), they are assumed to be handled
- * by real datablocks responsible of them. */
+ /* Do not explicitly make local non-linkable IDs (shapekeys, in fact),
+ * they are assumed to be handled by real datablocks responsible of them. */
const bool do_skip = (id && !BKE_idcode_is_linkable(GS(id->name)));
for (; id; id = id->next) {
@@ -1889,14 +1911,17 @@ void BKE_library_make_local(Main *bmain,
if (id->lib == NULL) {
id->tag &= ~(LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW);
}
- /* The check on the fourth line (LIB_TAG_PRE_EXISTING) is done so its possible to tag data you don't want to
- * be made local, used for appending data, so any libdata already linked wont become local (very nasty
+ /* The check on the fourth line (LIB_TAG_PRE_EXISTING) is done so it's possible to tag data
+ * you don't want to be made local, used for appending data,
+ * so any libdata already linked wont become local (very nasty
* to discover all your links are lost after appending).
* Also, never ever make proxified objects local, would not make any sense. */
/* Some more notes:
* - Shapekeys are never tagged here (since they are not linkable).
- * - Nodetrees used in materials etc. have to be tagged manually, since they do not exist in Main (!).
- * This is ok-ish on 'make local' side of things (since those are handled by their 'owner' IDs),
+ * - Nodetrees used in materials etc. have to be tagged manually,
+ * since they do not exist in Main (!).
+ * This is ok-ish on 'make local' side of things
+ * (since those are handled by their 'owner' IDs),
* but complicates slightly the pre-processing of relations between IDs at step 2... */
else if (!do_skip && id->tag & (LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW) &&
ELEM(lib, NULL, id->lib) &&
@@ -1905,8 +1930,9 @@ void BKE_library_make_local(Main *bmain,
BLI_linklist_prepend_arena(&todo_ids, id, linklist_mem);
id->tag |= LIB_TAG_DOIT;
- /* Tag those nasty non-ID nodetrees, but do not add them to todo list, making them local is handled
- * by 'owner' ID. This is needed for library_make_local_copying_check() to work OK at step 2. */
+ /* Tag those nasty non-ID nodetrees,
+ * but do not add them to todo list, making them local is handled by 'owner' ID.
+ * This is needed for library_make_local_copying_check() to work OK at step 2. */
if (ntree != NULL) {
ntree->tag |= LIB_TAG_DOIT;
}
@@ -1923,8 +1949,9 @@ void BKE_library_make_local(Main *bmain,
TIMEIT_VALUE_PRINT(make_local);
#endif
- /* Step 2: Check which datablocks we can directly make local (because they are only used by already, or future,
- * local data), others will need to be duplicated. */
+ /* Step 2: Check which datablocks we can directly make local
+ * (because they are only used by already, or future, local data),
+ * others will need to be duplicated. */
GSet *loop_tags = BLI_gset_ptr_new(__func__);
for (LinkNode *it = todo_ids; it; it = it->next) {
library_make_local_copying_check(it->link, loop_tags, bmain->relations, done_ids);
@@ -1942,15 +1969,17 @@ void BKE_library_make_local(Main *bmain,
#endif
/* Step 3: Make IDs local, either directly (quick and simple), or using generic process,
- * which involves more complex checks and might instead create a local copy of original linked ID. */
+ * which involves more complex checks and might instead
+ * create a local copy of original linked ID. */
for (LinkNode *it = todo_ids, *it_next; it; it = it_next) {
it_next = it->next;
ID *id = it->link;
if (id->tag & LIB_TAG_DOIT) {
- /* We know all users of this object are local or will be made fully local, even if currently there are
- * some indirect usages. So instead of making a copy that we'll likely get rid of later, directly make
- * that data block local. Saves a tremendous amount of time with complex scenes... */
+ /* We know all users of this object are local or will be made fully local, even if currently
+ * there are some indirect usages. So instead of making a copy that we'll likely get rid of
+ * later, directly make that data block local.
+ * Saves a tremendous amount of time with complex scenes... */
id_clear_lib_data_ex(bmain, id, true);
BKE_id_expand_local(bmain, id);
id->tag &= ~LIB_TAG_DOIT;
@@ -1986,16 +2015,19 @@ void BKE_library_make_local(Main *bmain,
TIMEIT_VALUE_PRINT(make_local);
#endif
- /* At this point, we are done with directly made local IDs. Now we have to handle duplicated ones, since their
+ /* At this point, we are done with directly made local IDs.
+ * Now we have to handle duplicated ones, since their
* remaining linked original counterpart may not be needed anymore... */
todo_ids = NULL;
- /* Step 4: We have to remap local usages of old (linked) ID to new (local) ID in a separated loop,
+ /* Step 4: We have to remap local usages of old (linked) ID to new (local)
+ * ID in a separated loop,
* as lbarray ordering is not enough to ensure us we did catch all dependencies
* (e.g. if making local a parent object before its child...). See T48907. */
- /* TODO This is now the biggest step by far (in term of processing time). We may be able to gain here by
- * using again main->relations mapping, but... this implies BKE_libblock_remap & co to be able to update
- * main->relations on the fly. Have to think about it a bit more, and see whether new code is OK first, anyway. */
+ /* TODO This is now the biggest step by far (in term of processing time).
+ * We may be able to gain here by using again main->relations mapping, but...
+ * this implies BKE_libblock_remap & co to be able to update main->relations on the fly.
+ * Have to think about it a bit more, and see whether new code is OK first, anyway. */
for (LinkNode *it = copied_ids; it; it = it->next) {
ID *id = it->link;
@@ -2076,10 +2108,11 @@ void BKE_library_make_local(Main *bmain,
#endif
/* This is probably more of a hack than something we should do here, but...
- * Issue is, the whole copying + remapping done in complex cases above may leave pose channels of armatures
- * in complete invalid state (more precisely, the bone pointers of the pchans - very crappy cross-datablocks
- * relationship), se we tag it to be fully recomputed, but this does not seems to be enough in some cases,
- * and evaluation code ends up trying to evaluate a not-yet-updated armature object's deformations.
+ * Issue is, the whole copying + remapping done in complex cases above may leave pose-channels of
+ * armatures in complete invalid state (more precisely, the bone pointers of the pose-channels -
+ * very crappy cross-data-blocks relationship), se we tag it to be fully recomputed,
+ * but this does not seems to be enough in some cases, and evaluation code ends up trying to
+ * evaluate a not-yet-updated armature object's deformations.
* Try "make all local" in 04_01_H.lighting.blend from Agent327 without this, e.g. */
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->data != NULL && ob->type == OB_ARMATURE && ob->pose != NULL &&
@@ -2160,7 +2193,8 @@ void BKE_libblock_rename(Main *bmain, ID *id, const char *name)
*
* \note Result is unique to a given ID type in a given Main database.
*
- * \param name: An allocated string of minimal length MAX_ID_FULL_NAME, will be filled with generated string.
+ * \param name: An allocated string of minimal length #MAX_ID_FULL_NAME,
+ * will be filled with generated string.
*/
void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id)
{
@@ -2179,12 +2213,14 @@ 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 if any), with a 3-character prefix prepended
- * indicating whether it comes from a library, is overriding, has a fake or no user, etc.
+ * 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.
*
- * \param name: An allocated string of minimal length MAX_ID_FULL_NAME_UI, will be filled with generated string.
+ * \param name: An allocated string of minimal length #MAX_ID_FULL_NAME_UI,
+ * will be filled with generated string.
*/
void BKE_id_full_name_ui_prefix_get(char name[MAX_ID_FULL_NAME_UI], const ID *id)
{
@@ -2232,8 +2268,8 @@ void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
* outliner, and its not really supported but allow from here for now
* since making local could cause this to be directly linked - campbell
*/
- /* Never make paths relative to parent lib - reading code (blenloader) always set *all* lib->name relative to
- * current main, not to their parent for indirectly linked ones. */
+ /* Never make paths relative to parent lib - reading code (blenloader) always set *all*
+ * lib->name relative to current main, not to their parent for indirectly linked ones. */
const char *basepath = BKE_main_blendfile_path(bmain);
BLI_path_abs(lib->filepath, basepath);
}
diff --git a/source/blender/blenkernel/intern/library_idmap.c b/source/blender/blenkernel/intern/library_idmap.c
index d520df31a75..cc7e2e31d07 100644
--- a/source/blender/blenkernel/intern/library_idmap.c
+++ b/source/blender/blenkernel/intern/library_idmap.c
@@ -182,7 +182,8 @@ ID *BKE_main_idmap_lookup(struct IDNameLib_Map *id_map,
ID *BKE_main_idmap_lookup_id(struct IDNameLib_Map *id_map, const ID *id)
{
/* When used during undo/redo, this function cannot assume that given id points to valid memory
- * (i.e. has not been freed), so it has to check that it does exist in 'old' (aka current) Main database.
+ * (i.e. has not been freed),
+ * so it has to check that it does exist in 'old' (aka current) Main database.
* Otherwise, we cannot provide new ID pointer that way (would crash accessing freed memory
* when trying to get ID name).
*/
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c
index 30307eb1266..231e0b8ee60 100644
--- a/source/blender/blenkernel/intern/library_override.c
+++ b/source/blender/blenkernel/intern/library_override.c
@@ -55,7 +55,8 @@ static void bke_override_property_operation_copy(IDOverrideStaticPropertyOperati
static void bke_override_property_clear(IDOverrideStaticProperty *op);
static void bke_override_property_operation_clear(IDOverrideStaticPropertyOperation *opop);
-/* Temp, for until static override is ready and tested enough to go 'public', we hide it by default in UI and such. */
+/* Temp, for until static override is ready and tested enough to go 'public',
+ * we hide it by default in UI and such. */
static bool _override_static_enabled = false;
void BKE_override_static_enable(const bool do_enable)
@@ -80,7 +81,7 @@ IDOverrideStatic *BKE_override_static_init(ID *local_id, ID *reference_id)
for (ancestor_id = reference_id; ancestor_id != NULL && ancestor_id->override_static != NULL &&
ancestor_id->override_static->reference != NULL;
ancestor_id = ancestor_id->override_static->reference) {
- ;
+ /* pass */
}
if (ancestor_id != NULL && ancestor_id->override_static != NULL) {
@@ -189,7 +190,8 @@ ID *BKE_override_static_create_from_id(Main *bmain, ID *reference_id)
ID *local_id = override_static_create_from(bmain, reference_id);
- /* Remapping, we obviously only want to affect local data (and not our own reference pointer to overridden ID). */
+ /* Remapping, we obviously only want to affect local data
+ * (and not our own reference pointer to overridden ID). */
BKE_libblock_remap(
bmain, reference_id, local_id, ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_STATIC_OVERRIDE);
@@ -198,8 +200,8 @@ ID *BKE_override_static_create_from_id(Main *bmain, ID *reference_id)
/** Create overridden local copies of all tagged data-blocks in given Main.
*
- * \note Set id->newid of overridden libs with newly created overrides, caller is responsible to clean those pointers
- * before/after usage as needed.
+ * \note Set id->newid of overridden libs with newly created overrides,
+ * caller is responsible to clean those pointers before/after usage as needed.
*
* \return \a true on success, \a false otherwise.
*/
@@ -474,11 +476,11 @@ void BKE_override_static_property_operation_delete(
/**
* Check that status of local data-block is still valid against current reference one.
*
- * It means that all overridable, but not overridden, properties' local values must be equal to reference ones.
- * Clears LIB_TAG_OVERRIDE_OK if they do not.
+ * It means that all overridable, but not overridden, properties' local values must be equal to
+ * reference ones. Clears #LIB_TAG_OVERRIDE_OK if they do not.
*
- * This is typically used to detect whether some property has been changed in local and a new IDOverrideProperty
- * (of IDOverridePropertyOperation) has to be added.
+ * This is typically used to detect whether some property has been changed in local and a new
+ * #IDOverrideProperty (of #IDOverridePropertyOperation) has to be added.
*
* \return true if status is OK, false otherwise. */
bool BKE_override_static_status_check_local(Main *bmain, ID *local)
@@ -521,7 +523,8 @@ bool BKE_override_static_status_check_local(Main *bmain, ID *local)
* It means that all non-overridden properties' local values must be equal to reference ones.
* Clears LIB_TAG_OVERRIDE_OK if they do not.
*
- * This is typically used to detect whether some reference has changed and local needs to be updated against it.
+ * This is typically used to detect whether some reference has changed and local
+ * needs to be updated against it.
*
* \return true if status is OK, false otherwise. */
bool BKE_override_static_status_check_reference(Main *bmain, ID *local)
@@ -569,12 +572,13 @@ bool BKE_override_static_status_check_reference(Main *bmain, ID *local)
* Compares local and reference data-blocks and create new override operations as needed,
* or reset to reference values if overriding is not allowed.
*
- * \note Defining override operations is only mandatory before saving a .blend file on disk (not for undo!).
+ * \note Defining override operations is only mandatory before saving a `.blend` file on disk
+ * (not for undo!).
* Knowing that info at runtime is only useful for UI/UX feedback.
*
- * \note This is by far the biggest operation (the more time-consuming) of the three so far, since it has to go over
- * all properties in depth (all overridable ones at least). Generating diff values and applying overrides
- * are much cheaper.
+ * \note This is by far the biggest operation (the more time-consuming) of the three so far,
+ * since it has to go over all properties in depth (all overridable ones at least).
+ * Generating diff values and applying overrides are much cheaper.
*
* \return true if new overriding op was created, or some local data was reset. */
bool BKE_override_static_operations_create(Main *bmain, ID *local, const bool force_auto)
@@ -642,19 +646,20 @@ void BKE_override_static_update(Main *bmain, ID *local)
BKE_override_static_update(bmain, local->override_static->reference);
}
- /* We want to avoid having to remap here, however creating up-to-date override is much simpler if based
- * on reference than on current override.
+ /* We want to avoid having to remap here, however creating up-to-date override is much simpler
+ * if based on reference than on current override.
* So we work on temp copy of reference, and 'swap' its content with local. */
/* XXX We need a way to get off-Main copies of IDs (similar to localized mats/texts/ etc.)!
- * However, this is whole bunch of code work in itself, so for now plain stupid ID copy will do,
- * as innefficient as it is. :/
- * Actually, maybe not! Since we are swapping with original ID's local content, we want to keep
- * usercount in correct state when freeing tmp_id (and that usercounts of IDs used by 'new' local data
- * also remain correct). */
- /* This would imply change in handling of usercout all over RNA (and possibly all over Blender code).
- * Not impossible to do, but would rather see first if extra useless usual user handling is actually
- * a (performances) issue here. */
+ * However, this is whole bunch of code work in itself, so for now plain stupid ID copy will
+ * do, as inn-efficient as it is. :/
+ * Actually, maybe not! Since we are swapping with original ID's local content, we want to
+ * keep user-count in correct state when freeing tmp_id
+ * (and that user-counts of IDs used by 'new' local data also remain correct). */
+ /* This would imply change in handling of usercout all over RNA
+ * (and possibly all over Blender code).
+ * Not impossible to do, but would rather see first if extra useless usual user handling
+ * is actually a (performances) issue here. */
ID *tmp_id;
BKE_id_copy(bmain, local->override_static->reference, &tmp_id);
@@ -674,11 +679,12 @@ void BKE_override_static_update(Main *bmain, ID *local)
RNA_struct_override_apply(
bmain, &rnaptr_dst, &rnaptr_src, rnaptr_storage, local->override_static);
- /* This also transfers all pointers (memory) owned by local to tmp_id, and vice-versa. So when we'll free tmp_id,
- * we'll actually free old, outdated data from local. */
+ /* This also transfers all pointers (memory) owned by local to tmp_id, and vice-versa.
+ * So when we'll free tmp_id, we'll actually free old, outdated data from local. */
BKE_id_swap(bmain, local, tmp_id);
- /* Again, horribly innefficient in our case, we need something off-Main (aka moar generic nolib copy/free stuff)! */
+ /* Again, horribly inn-efficient in our case, we need something off-Main
+ * (aka more generic nolib copy/free stuff)! */
/* XXX And crashing in complex cases (e.g. because depsgraph uses same data...). */
BKE_id_free_ex(bmain, tmp_id, LIB_ID_FREE_NO_UI_USER, true);
@@ -711,18 +717,21 @@ void BKE_main_override_static_update(Main *bmain)
FOREACH_MAIN_ID_END;
}
-/***********************************************************************************************************************
- * Storage (how to wtore overriding data into .blend files).
+/**
+ * Storage (how to store overriding data into `.blend` files).
*
* Basically:
- * I) Only 'differential' storage needs special handling here. All others (replacing values or
- * inserting/removing items from a collection) can be handled with simply storing current content of local data-block.
- * II) We store the differential value into a second 'ghost' data-block, which is an empty ID of same type as local one,
- * where we only define values that need differential data.
+ * 1) Only 'differential' storage needs special handling here. All others (replacing values or
+ * inserting/removing items from a collection) can be handled with simply storing current
+ * content of local data-block.
+ * 2) We store the differential value into a second 'ghost' data-block,
+ * which is an empty ID of same type as local one,
+ * where we only define values that need differential data.
*
- * This avoids us having to modify 'real' data-block at write time (and restoring it afterwards), which is inneficient,
- * and potentially dangerous (in case of concurrent access...), while not using much extra memory in typical cases.
- * It also ensures stored data-block always contains exact same data as "desired" ones (kind of "baked" data-blocks).
+ * This avoids us having to modify 'real' data-block at write time (and restoring it afterwards),
+ * which is inneficient, and potentially dangerous (in case of concurrent access...), while not
+ * using much extra memory in typical cases. It also ensures stored data-block always contains
+ * exact same data as "desired" ones (kind of "baked" data-blocks).
*/
/** Initialize an override storage. */
@@ -734,7 +743,8 @@ OverrideStaticStorage *BKE_override_static_operations_store_initialize(void)
/**
* Generate suitable 'write' data (this only affects differential override operations).
*
- * Note that \a local ID is no more modified by this call, all extra data are stored in its temp \a storage_id copy. */
+ * Note that \a local ID is no more modified by this call,
+ * all extra data are stored in its temp \a storage_id copy. */
ID *BKE_override_static_operations_store_start(Main *bmain,
OverrideStaticStorage *override_storage,
ID *local)
@@ -756,11 +766,13 @@ ID *BKE_override_static_operations_store_start(Main *bmain,
TIMEIT_START_AVERAGED(BKE_override_operations_store_start);
#endif
- /* XXX TODO We may also want a specialized handling of things here too, to avoid copying heavy never-overridable
- * data (like Mesh geometry etc.)? And also maybe avoid lib refcounting completely (shallow copy...). */
- /* This would imply change in handling of usercout all over RNA (and possibly all over Blender code).
- * Not impossible to do, but would rather see first is extra useless usual user handling is actually
- * a (performances) issue here, before doing it. */
+ /* XXX TODO We may also want a specialized handling of things here too, to avoid copying heavy
+ * never-overridable data (like Mesh geometry etc.)? And also maybe avoid lib reference-counting
+ * completely (shallow copy...). */
+ /* This would imply change in handling of user-count all over RNA
+ * (and possibly all over Blender code).
+ * Not impossible to do, but would rather see first is extra useless usual user handling is
+ * actually a (performances) issue here, before doing it. */
BKE_id_copy((Main *)override_storage, local, &storage_id);
if (storage_id != NULL) {
@@ -790,15 +802,15 @@ void BKE_override_static_operations_store_end(OverrideStaticStorage *UNUSED(over
{
BLI_assert(local->override_static != NULL);
- /* Nothing else to do here really, we need to keep all temp override storage data-blocks in memory until
- * whole file is written anyway (otherwise we'd get mem pointers overlap...). */
+ /* Nothing else to do here really, we need to keep all temp override storage data-blocks in
+ * memory until whole file is written anyway (otherwise we'd get mem pointers overlap...). */
local->override_static->storage = NULL;
}
void BKE_override_static_operations_store_finalize(OverrideStaticStorage *override_storage)
{
- /* We cannot just call BKE_main_free(override_storage), not until we have option to make 'ghost' copies of IDs
- * without increasing usercount of used data-blocks... */
+ /* We cannot just call BKE_main_free(override_storage), not until we have option to make 'ghost'
+ * copies of IDs without increasing usercount of used data-blocks. */
ID *id;
FOREACH_MAIN_ID_BEGIN (override_storage, id) {
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 92ed6ea4e04..d0515d8783d 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -352,8 +352,8 @@ static void library_foreach_ID_as_subdata_link(ID **id_pp,
BLI_assert(id == *id_pp);
if (flag & IDWALK_RECURSE) {
- /* Defer handling into main loop, recursively calling BKE_library_foreach_ID_link in IDWALK_RECURSE case is
- * troublesome, see T49553. */
+ /* Defer handling into main loop, recursively calling BKE_library_foreach_ID_link in
+ * IDWALK_RECURSE case is troublesome, see T49553. */
if (BLI_gset_add(data->ids_handled, id)) {
BLI_LINKSTACK_PUSH(data->ids_todo, id);
}
@@ -402,8 +402,8 @@ static void library_foreach_ID_link(Main *bmain,
/* inherit_data is non-NULL when this function is called for some sub-data ID
* (like root nodetree of a material).
- * In that case, we do not want to generate those 'generic flags' from our current sub-data ID (the node tree),
- * but re-use those generated for the 'owner' ID (the material)... */
+ * In that case, we do not want to generate those 'generic flags' from our current sub-data ID
+ * (the node tree), but re-use those generated for the 'owner' ID (the material). */
if (inherit_data == NULL) {
data.cb_flag = ID_IS_LINKED(id) ? IDWALK_CB_INDIRECT_USAGE : 0;
/* When an ID is not in Main database, it should never refcount IDs it is using.
@@ -416,10 +416,11 @@ static void library_foreach_ID_link(Main *bmain,
}
if (bmain != NULL && bmain->relations != NULL && (flag & IDWALK_READONLY)) {
- /* Note that this is minor optimization, even in worst cases (like id being an object with lots of
- * drivers and constraints and modifiers, or material etc. with huge node tree),
- * but we might as well use it (Main->relations is always assumed valid, it's responsibility of code
- * creating it to free it, especially if/when it starts modifying Main database). */
+ /* Note that this is minor optimization, even in worst cases (like id being an object with
+ * lots of drivers and constraints and modifiers, or material etc. with huge node tree),
+ * but we might as well use it (Main->relations is always assumed valid,
+ * it's responsibility of code creating it to free it,
+ * especially if/when it starts modifying Main database). */
MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->id_user_to_used, id);
for (; entry != NULL; entry = entry->next) {
FOREACH_CALLBACK_INVOKE_ID_PP(&data, entry->id_pointer, entry->usage_flag);
@@ -594,8 +595,8 @@ static void library_foreach_ID_link(Main *bmain,
CALLBACK_INVOKE(object->proxy_group, IDWALK_CB_NOP);
/* Special case!
- * Since this field is set/owned by 'user' of this ID (and not ID itself), it is only indirect usage
- * if proxy object is linked... Twisted. */
+ * Since this field is set/owned by 'user' of this ID (and not ID itself),
+ * it is only indirect usage if proxy object is linked... Twisted. */
if (object->proxy_from) {
data.cb_flag = ID_IS_LINKED(object->proxy_from) ? IDWALK_CB_INDIRECT_USAGE : 0;
}
@@ -1018,7 +1019,8 @@ static void library_foreach_ID_link(Main *bmain,
bScreen *screen = BKE_workspace_layout_screen_get(layout);
/* CALLBACK_INVOKE expects an actual pointer, not a variable holding the pointer.
- * However we can't access layout->screen here since we are outside the workspace project. */
+ * However we can't access layout->screen here
+ * since we are outside the workspace project. */
CALLBACK_INVOKE(screen, IDWALK_CB_USER);
/* allow callback to set a different screen */
BKE_workspace_layout_screen_set(layout, screen);
@@ -1096,11 +1098,12 @@ void BKE_library_update_ID_link_user(ID *id_dst, ID *id_src, const int cb_flag)
/**
* Say whether given \a id_type_owner can use (in any way) a datablock of \a id_type_used.
*
- * This is a 'simplified' abstract version of #BKE_library_foreach_ID_link() above, quite useful to reduce
- * useless iterations in some cases.
+ * This is a 'simplified' abstract version of #BKE_library_foreach_ID_link() above,
+ * quite useful to reduce* useless iterations in some cases.
*/
-/* XXX This has to be fully rethink, basing check on ID type is not really working anymore (and even worth once
- * IDProps will support ID pointers), we'll have to do some quick checks on IDs themselves... */
+/* XXX This has to be fully rethink, basing check on ID type is not really working anymore
+ * (and even worth once IDProps will support ID pointers),
+ * we'll have to do some quick checks on IDs themselves... */
bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used)
{
/* any type of ID can be used in custom props. */
@@ -1120,7 +1123,8 @@ bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used)
}
if (BKE_animdata_from_id(id_owner)) {
- return true; /* AnimationData can use virtually any kind of datablocks, through drivers especially. */
+ /* AnimationData can use virtually any kind of datablocks, through drivers especially. */
+ return true;
}
switch ((ID_Type)id_type_owner) {
@@ -1267,8 +1271,8 @@ static int foreach_libblock_id_users_callback(void *user_data,
/**
* Return the number of times given \a id_user uses/references \a id_used.
*
- * \note This only checks for pointer references of an ID, shallow usages (like e.g. by RNA paths, as done
- * for FCurves) are not detected at all.
+ * \note This only checks for pointer references of an ID, shallow usages
+ * (like e.g. by RNA paths, as done for FCurves) are not detected at all.
*
* \param id_user: the ID which is supposed to use (reference) \a id_used.
* \param id_used: the ID which is supposed to be used (referenced) by \a id_user.
@@ -1339,7 +1343,8 @@ bool BKE_library_ID_is_indirectly_used(Main *bmain, void *idv)
}
/**
- * Combine #BKE_library_ID_is_locally_used() and #BKE_library_ID_is_indirectly_used() in a single call.
+ * Combine #BKE_library_ID_is_locally_used() and #BKE_library_ID_is_indirectly_used()
+ * in a single call.
*/
void BKE_library_ID_test_usages(Main *bmain, void *idv, bool *is_used_local, bool *is_used_linked)
{
@@ -1390,7 +1395,8 @@ static int foreach_libblock_used_linked_data_tag_clear_cb(void *user_data,
return IDWALK_RET_NOP;
}
- /* If checked id is used by an assumed used ID, then it is also used and not part of any linked archipelago. */
+ /* If checked id is used by an assumed used ID,
+ * then it is also used and not part of any linked archipelago. */
if (!(self_id->tag & LIB_TAG_DOIT) && ((*id_p)->tag & LIB_TAG_DOIT)) {
(*id_p)->tag &= ~LIB_TAG_DOIT;
*is_changed = true;
@@ -1401,12 +1407,13 @@ static int foreach_libblock_used_linked_data_tag_clear_cb(void *user_data,
}
/**
- * Detect orphaned linked data blocks (i.e. linked data not used (directly or indirectly) in any way by any local data),
- * including complex cases like 'linked archipelagoes', i.e. linked datablocks that use each other in loops,
- * which prevents their deletion by 'basic' usage checks...
+ * Detect orphaned linked data blocks (i.e. linked data not used (directly or indirectly)
+ * in any way by any local data), including complex cases like 'linked archipelagoes', i.e.
+ * linked datablocks that use each other in loops,
+ * which prevents their deletion by 'basic' usage checks.
*
- * \param do_init_tag: if \a true, all linked data are checked, if \a false, only linked datablocks already tagged with
- * LIB_TAG_DOIT are checked.
+ * \param do_init_tag: if \a true, all linked data are checked, if \a false,
+ * only linked datablocks already tagged with #LIB_TAG_DOIT are checked.
*/
void BKE_library_unused_linked_data_set_tag(Main *bmain, const bool do_init_tag)
{
@@ -1439,9 +1446,11 @@ void BKE_library_unused_linked_data_set_tag(Main *bmain, const bool do_init_tag)
/**
* Untag linked data blocks used by other untagged linked datablocks.
- * Used to detect datablocks that we can forcefully make local (instead of copying them to later get rid of original):
- * All datablocks we want to make local are tagged by caller, after this function has ran caller knows datablocks still
- * tagged can directly be made local, since they are only used by other datablocks that will also be made fully local.
+ * Used to detect datablocks that we can forcefully make local
+ * (instead of copying them to later get rid of original):
+ * All datablocks we want to make local are tagged by caller,
+ * after this function has ran caller knows datablocks still tagged can directly be made local,
+ * since they are only used by other datablocks that will also be made fully local.
*/
void BKE_library_indirectly_used_data_tag_clear(Main *bmain)
{
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 7657b47bcf5..3b6f11935d1 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -185,7 +185,8 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
}
if (*id_p && (*id_p == old_id)) {
- /* Better remap to NULL than not remapping at all, then we can handle it as a regular remap-to-NULL case... */
+ /* Better remap to NULL than not remapping at all,
+ * then we can handle it as a regular remap-to-NULL case. */
if ((cb_flag & IDWALK_CB_NEVER_SELF) && (new_id == id_self)) {
new_id = NULL;
}
@@ -194,8 +195,8 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
const bool is_indirect = (cb_flag & IDWALK_CB_INDIRECT_USAGE) != 0;
const bool skip_indirect = (id_remap_data->flag & ID_REMAP_SKIP_INDIRECT_USAGE) != 0;
/* Note: proxy usage implies LIB_TAG_EXTERN, so on this aspect it is direct,
- * on the other hand since they get reset to lib data on file open/reload it is indirect too...
- * Edit Mode is also a 'skip direct' case. */
+ * on the other hand since they get reset to lib data on file open/reload it is indirect too.
+ * Edit Mode is also a 'skip direct' case. */
const bool is_obj = (GS(id->name) == ID_OB);
const bool is_obj_proxy = (is_obj && (((Object *)id)->proxy || ((Object *)id)->proxy_group));
const bool is_obj_editmode = (is_obj && BKE_object_is_in_editmode((Object *)id));
@@ -280,8 +281,8 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
}
else if (cb_flag & IDWALK_CB_USER_ONE) {
id_us_ensure_real(new_id);
- /* We cannot affect old_id->us directly, LIB_TAG_EXTRAUSER(_SET) are assumed to be set as needed,
- * that extra user is processed in final handling... */
+ /* We cannot affect old_id->us directly, LIB_TAG_EXTRAUSER(_SET)
+ * are assumed to be set as needed, that extra user is processed in final handling. */
}
if (!is_indirect || is_obj_proxy) {
id_remap_data->status |= ID_REMAP_IS_LINKED_DIRECT;
@@ -300,15 +301,16 @@ static void libblock_remap_data_preprocess(IDRemap *r_id_remap_data)
if (!old_id || GS(old_id->name) == ID_AR) {
Object *ob = (Object *)r_id_remap_data->id;
/* Object's pose holds reference to armature bones... sic */
- /* Note that in theory, we should have to bother about linked/non-linked/never-null/etc. flags/states.
- * Fortunately, this is just a tag, so we can accept to 'over-tag' a bit for pose recalc, and avoid
- * another complex and risky condition nightmare like the one we have in
+ /* Note that in theory, we should have to bother about
+ * linked/non-linked/never-null/etc. flags/states.
+ * Fortunately, this is just a tag, so we can accept to 'over-tag' a bit for pose recalc,
+ * and avoid another complex and risky condition nightmare like the one we have in
* foreach_libblock_remap_callback()... */
if (ob->pose && (!old_id || ob->data == old_id)) {
BLI_assert(ob->type == OB_ARMATURE);
ob->pose->flag |= POSE_RECALC;
- /* We need to clear pose bone pointers immediately, things like undo writefile may be called
- * before pose is actually recomputed, can lead to segfault... */
+ /* We need to clear pose bone pointers immediately, things like undo writefile may be
+ * called before pose is actually recomputed, can lead to segfault... */
BKE_pose_clear_pointers(ob->pose);
}
}
@@ -319,7 +321,10 @@ static void libblock_remap_data_preprocess(IDRemap *r_id_remap_data)
}
}
-/* Can be called with both old_ob and new_ob being NULL, this means we have to check whole Main database then. */
+/**
+ * Can be called with both old_ob and new_ob being NULL,
+ * this means we have to check whole Main database then.
+ */
static void libblock_remap_data_postprocess_object_update(Main *bmain,
Object *old_ob,
Object *new_ob)
@@ -358,8 +363,8 @@ static void libblock_remap_data_postprocess_collection_update(Main *bmain,
{
if (new_collection == NULL) {
/* XXX Complex cases can lead to NULL pointers in other collections than old_collection,
- * and BKE_main_collection_sync_remap() does not tolerate any of those, so for now always check whole
- * existing collections for NULL pointers.
+ * and BKE_main_collection_sync_remap() does not tolerate any of those, so for now always check
+ * whole existing collections for NULL pointers.
* I'd consider optimizing that whole collection remapping process a TODO for later. */
BKE_collections_child_remove_nulls(bmain, NULL /*old_collection*/);
}
@@ -387,15 +392,8 @@ static void libblock_remap_data_postprocess_obdata_relink(Main *bmain, Object *o
static void libblock_remap_data_postprocess_nodetree_update(Main *bmain, ID *new_id)
{
- /* Verify all nodetree user nodes. */
- ntreeVerifyNodes(bmain, new_id);
-
- /* Update node trees as necessary. */
- FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
- /* make an update call for the tree */
- ntreeUpdateTree(bmain, ntree);
- }
- FOREACH_NODETREE_END;
+ /* Update all group nodes using a node group. */
+ ntreeUpdateAllUsers(bmain, new_id);
}
/**
@@ -403,18 +401,22 @@ static void libblock_remap_data_postprocess_nodetree_update(Main *bmain, ID *new
*
* Behavior differs depending on whether given \a id is NULL or not:
* - \a id NULL: \a old_id must be non-NULL, \a new_id may be NULL (unlinking \a old_id) or not
- * (remapping \a old_id to \a new_id). The whole \a bmain database is checked, and all pointers to \a old_id
+ * (remapping \a old_id to \a new_id).
+ * The whole \a bmain database is checked, and all pointers to \a old_id
* are remapped to \a new_id.
* - \a id is non-NULL:
- * + If \a old_id is NULL, \a new_id must also be NULL, and all ID pointers from \a id are cleared (i.e. \a id
- * does not references any other datablock anymore).
+ * + If \a old_id is NULL, \a new_id must also be NULL,
+ * and all ID pointers from \a id are cleared
+ * (i.e. \a id does not references any other datablock anymore).
* + If \a old_id is non-NULL, behavior is as with a NULL \a id, but only within given \a id.
*
* \param bmain: the Main data storage to operate on (must never be NULL).
- * \param id: the datablock to operate on (can be NULL, in which case we operate over all IDs from given bmain).
+ * \param id: the datablock to operate on
+ * (can be NULL, in which case we operate over all IDs from given bmain).
* \param old_id: the datablock to dereference (may be NULL if \a id is non-NULL).
* \param new_id: the new datablock to replace \a old_id references with (may be NULL).
- * \param r_id_remap_data: if non-NULL, the IDRemap struct to use (uselful to retrieve info about remapping process).
+ * \param r_id_remap_data: if non-NULL, the IDRemap struct to use
+ * (uselful to retrieve info about remapping process).
*/
ATTR_NONNULL(1)
static void libblock_remap_data(
@@ -448,14 +450,15 @@ static void libblock_remap_data(
NULL, id, foreach_libblock_remap_callback, (void *)r_id_remap_data, foreach_id_flags);
}
else {
- /* Note that this is a very 'brute force' approach, maybe we could use some depsgraph to only process
- * objects actually using given old_id... sounds rather unlikely currently, though, so this will do for now. */
+ /* Note that this is a very 'brute force' approach,
+ * maybe we could use some depsgraph to only process objects actually using given old_id...
+ * sounds rather unlikely currently, though, so this will do for now. */
ID *id_curr;
FOREACH_MAIN_ID_BEGIN (bmain, id_curr) {
if (BKE_library_id_can_use_idtype(id_curr, GS(old_id->name))) {
- /* Note that we cannot skip indirect usages of old_id here (if requested), we still need to check it for
- * the user count handling...
+ /* Note that we cannot skip indirect usages of old_id here (if requested),
+ * we still need to check it for the user count handling...
* XXX No more true (except for debug usage of those skipping counters). */
r_id_remap_data->id = id_curr;
libblock_remap_data_preprocess(r_id_remap_data);
@@ -469,8 +472,9 @@ static void libblock_remap_data(
FOREACH_MAIN_ID_END;
}
- /* XXX We may not want to always 'transfer' fakeuser from old to new id... Think for now it's desired behavior
- * though, we can always add an option (flag) to control this later if needed. */
+ /* XXX We may not want to always 'transfer' fakeuser from old to new id...
+ * Think for now it's desired behavior though,
+ * we can always add an option (flag) to control this later if needed. */
if (old_id && (old_id->flag & LIB_FAKEUSER)) {
id_fake_user_clear(old_id);
id_fake_user_set(new_id);
@@ -515,7 +519,8 @@ void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const
}
/* We assume editors do not hold references to their IDs... This is false in some cases
- * (Image is especially tricky here), editors' code is to handle refcount (id->us) itself then. */
+ * (Image is especially tricky here),
+ * editors' code is to handle refcount (id->us) itself then. */
if (remap_editor_id_reference_cb) {
remap_editor_id_reference_cb(old_id, new_id);
}
@@ -523,9 +528,9 @@ void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const
skipped_direct = id_remap_data.skipped_direct;
skipped_refcounted = id_remap_data.skipped_refcounted;
- /* If old_id was used by some ugly 'user_one' stuff (like Image or Clip editors...), and user count has actually
- * been incremented for that, we have to decrease once more its user count... unless we had to skip
- * some 'user_one' cases. */
+ /* If old_id was used by some ugly 'user_one' stuff (like Image or Clip editors...), and user
+ * count has actually been incremented for that, we have to decrease once more its user count...
+ * unless we had to skip some 'user_one' cases. */
if ((old_id->tag & LIB_TAG_EXTRAUSER_SET) &&
!(id_remap_data.status & ID_REMAP_IS_USER_ONE_SKIPPED)) {
id_us_clear_real(old_id);
@@ -552,8 +557,8 @@ void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const
}
/* Some after-process updates.
- * This is a bit ugly, but cannot see a way to avoid it. Maybe we should do a per-ID callback for this instead?
- */
+ * This is a bit ugly, but cannot see a way to avoid it.
+ * Maybe we should do a per-ID callback for this instead? */
switch (GS(old_id->name)) {
case ID_OB:
libblock_remap_data_postprocess_object_update(bmain, (Object *)old_id, (Object *)new_id);
@@ -597,10 +602,11 @@ void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, const short r
}
/**
- * Unlink given \a id from given \a bmain (does not touch to indirect, i.e. library, usages of the ID).
+ * Unlink given \a id from given \a bmain
+ * (does not touch to indirect, i.e. library, usages of the ID).
*
- * \param do_flag_never_null: If true, all IDs using \a idv in a 'non-NULL' way are flagged by \a LIB_TAG_DOIT flag
- * (quite obviously, 'non-NULL' usages can never be unlinked by this function...).
+ * \param do_flag_never_null: If true, all IDs using \a idv in a 'non-NULL' way are flagged by
+ * #LIB_TAG_DOIT flag (quite obviously, 'non-NULL' usages can never be unlinked by this function).
*/
void BKE_libblock_unlink(Main *bmain,
void *idv,
@@ -655,7 +661,8 @@ void BKE_libblock_relink_ex(
libblock_remap_data(bmain, id, old_id, new_id, remap_flags, NULL);
/* Some after-process updates.
- * This is a bit ugly, but cannot see a way to avoid it. Maybe we should do a per-ID callback for this instead?
+ * This is a bit ugly, but cannot see a way to avoid it.
+ * Maybe we should do a per-ID callback for this instead?
*/
switch (GS(id->name)) {
case ID_SCE: {
@@ -714,9 +721,12 @@ static int id_relink_to_newid_looper(void *UNUSED(user_data),
return IDWALK_RET_NOP;
}
-/** Similar to libblock_relink_ex, but is remapping IDs to their newid value if non-NULL, in given \a id.
+/**
+ * Similar to #libblock_relink_ex,
+ * but is remapping IDs to their newid value if non-NULL, in given \a id.
*
- * Very specific usage, not sure we'll keep it on the long run, currently only used in Object/Collection duplication code...
+ * Very specific usage, not sure we'll keep it on the long run,
+ * currently only used in Object/Collection duplication code...
*/
void BKE_libblock_relink_to_newid(ID *id)
{
@@ -738,7 +748,8 @@ void BKE_libblock_free_data(ID *id, const bool do_id_user)
BKE_override_static_free(&id->override_static);
}
- /* XXX TODO remove animdata handling from each type's freeing func, and do it here, like for copy! */
+ /* XXX TODO remove animdata handling from each type's freeing func,
+ * and do it here, like for copy! */
}
void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
@@ -865,13 +876,14 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
* At that point, given id is assumed to not be used by any other data-block already
* (might not be actually true, in case e.g. several inter-related IDs get freed together...).
* However, they might still be using (referencing) other IDs, this code takes care of it if
- * \a LIB_TAG_NO_USER_REFCOUNT is not defined.
+ * #LIB_TAG_NO_USER_REFCOUNT is not defined.
*
- * \param bmain: Main database containing the freed ID, can be NULL in case it's a temp ID outside of any Main.
+ * \param bmain: #Main database containing the freed #ID,
+ * can be NULL in case it's a temp ID outside of any #Main.
* \param idv: Pointer to ID to be freed.
* \param flag: Set of \a LIB_ID_FREE_... flags controlling/overriding usual freeing process,
* 0 to get default safe behavior.
- * \param use_flag_from_idtag: Still use freeing info flags from given ID datablock,
+ * \param use_flag_from_idtag: Still use freeing info flags from given #ID datablock,
* even if some overriding ones are passed in \a flag parameter.
*/
void BKE_id_free_ex(Main *bmain, void *idv, int flag, const bool use_flag_from_idtag)
@@ -962,7 +974,8 @@ void BKE_id_free_ex(Main *bmain, void *idv, int flag, const bool use_flag_from_i
*
* See #BKE_id_free_ex description for full details.
*
- * \param bmain: Main database containing the freed ID, can be NULL in case it's a temp ID outside of any Main.
+ * \param bmain: Main database containing the freed ID,
+ * can be NULL in case it's a temp ID outside of any Main.
* \param idv: Pointer to ID to be freed.
*/
void BKE_id_free(Main *bmain, void *idv)
@@ -971,7 +984,8 @@ void BKE_id_free(Main *bmain, void *idv)
}
/**
- * Not really a freeing function by itself, it decrements usercount of given id, and only frees it if it reaches 0.
+ * Not really a freeing function by itself,
+ * it decrements usercount of given id, and only frees it if it reaches 0.
*/
void BKE_id_free_us(Main *bmain, void *idv) /* test users */
{
@@ -979,12 +993,13 @@ void BKE_id_free_us(Main *bmain, void *idv) /* test users */
id_us_min(id);
- /* XXX This is a temp (2.77) hack so that we keep same behavior as in 2.76 regarding collections when deleting an object.
- * Since only 'user_one' usage of objects is collections, and only 'real user' usage of objects is scenes,
- * removing that 'user_one' tag when there is no more real (scene) users of an object ensures it gets
- * fully unlinked.
+ /* XXX This is a temp (2.77) hack so that we keep same behavior as in 2.76 regarding collections
+ * when deleting an object. Since only 'user_one' usage of objects is collections,
+ * and only 'real user' usage of objects is scenes, removing that 'user_one' tag when there
+ * is no more real (scene) users of an object ensures it gets fully unlinked.
* But only for local objects, not linked ones!
- * Otherwise, there is no real way to get rid of an object anymore - better handling of this is TODO.
+ * Otherwise, there is no real way to get rid of an object anymore -
+ * better handling of this is TODO.
*/
if ((GS(id->name) == ID_OB) && (id->us == 1) && (id->lib == NULL)) {
id_us_clear_real(id);
@@ -1041,8 +1056,9 @@ static void id_delete(Main *bmain, const bool do_tagged_deletion)
if ((id->tag & tag) || (id->lib != NULL && (id->lib->id.tag & tag))) {
BLI_remlink(lb, id);
BLI_addtail(&tagged_deleted_ids, id);
- /* Do not tag as no_main now, we want to unlink it first (lower-level ID management code
- * has some specific handling of 'nom main' IDs that would be a problem in that case). */
+ /* Do not tag as no_main now, we want to unlink it first (lower-level ID management
+ * code has some specific handling of 'nom main'
+ * IDs that would be a problem in that case). */
id->tag |= tag;
keep_looping = true;
}
@@ -1054,24 +1070,28 @@ static void id_delete(Main *bmain, const bool do_tagged_deletion)
}
for (id = last_remapped_id->next; id; id = id->next) {
/* Will tag 'never NULL' users of this ID too.
- * Note that we cannot use BKE_libblock_unlink() here, since it would ignore indirect (and proxy!)
+ * Note that we cannot use BKE_libblock_unlink() here,
+ * since it would ignore indirect (and proxy!)
* links, this can lead to nasty crashing here in second, actual deleting loop.
* Also, this will also flag users of deleted data that cannot be unlinked
* (object using deleted obdata, etc.), so that they also get deleted. */
BKE_libblock_remap_locked(
bmain, id, NULL, ID_REMAP_FLAG_NEVER_NULL_USAGE | ID_REMAP_FORCE_NEVER_NULL_USAGE);
- /* Since we removed ID from Main, we also need to unlink its own other IDs usages ourself. */
+ /* Since we removed ID from Main,
+ * we also need to unlink its own other IDs usages ourself. */
BKE_libblock_relink_ex(bmain, id, NULL, NULL, true);
/* Now we can safely mark that ID as not being in Main database anymore. */
id->tag |= LIB_TAG_NO_MAIN;
- /* This is needed because we may not have remapped usages of that ID by other deleted ones. */
- // id->us = 0; /* Is it actually? */
+ /* This is needed because we may not have remapped usages
+ * of that ID by other deleted ones. */
+ // id->us = 0; /* Is it actually? */
}
}
}
else {
/* First tag all datablocks directly from target lib.
- * Note that we go forward here, since we want to check dependencies before users (e.g. meshes before objects).
+ * Note that we go forward here, since we want to check dependencies before users
+ * (e.g. meshes before objects).
* Avoids to have to loop twice. */
for (i = 0; i < base_count; i++) {
ListBase *lb = lbarray[i];
@@ -1084,8 +1104,9 @@ static void id_delete(Main *bmain, const bool do_tagged_deletion)
id->tag |= tag;
/* Will tag 'never NULL' users of this ID too.
- * Note that we cannot use BKE_libblock_unlink() here, since it would ignore indirect (and proxy!)
- * links, this can lead to nasty crashing here in second, actual deleting loop.
+ * Note that we cannot use BKE_libblock_unlink() here, since it would ignore indirect
+ * (and proxy!) links, this can lead to nasty crashing here in second,
+ * actual deleting loop.
* Also, this will also flag users of deleted data that cannot be unlinked
* (object using deleted obdata, etc.), so that they also get deleted. */
BKE_libblock_remap_locked(
@@ -1096,8 +1117,9 @@ static void id_delete(Main *bmain, const bool do_tagged_deletion)
}
BKE_main_unlock(bmain);
- /* In usual reversed order, such that all usage of a given ID, even 'never NULL' ones, have been already cleared
- * when we reach it (e.g. Objects being processed before meshes, they'll have already released their 'reference'
+ /* In usual reversed order, such that all usage of a given ID, even 'never NULL' ones,
+ * have been already cleared when we reach it
+ * (e.g. Objects being processed before meshes, they'll have already released their 'reference'
* over meshes when we come to freeing obdata). */
for (i = do_tagged_deletion ? 1 : base_count; i--;) {
ListBase *lb = lbarray[i];
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index 0a7cb2a30a0..05b2eb82daf 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -96,8 +96,10 @@ Light *BKE_light_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Light ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Light ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c
index 6b1951498cc..5e6d298adbf 100644
--- a/source/blender/blenkernel/intern/lightprobe.c
+++ b/source/blender/blenkernel/intern/lightprobe.c
@@ -60,8 +60,10 @@ void *BKE_lightprobe_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of LightProbe ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of LightProbe ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index 4d159adbb57..31e6d2e89e5 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -151,8 +151,10 @@ void BKE_linestyle_free(FreestyleLineStyle *linestyle)
}
/**
- * Only copy internal data of Linestyle ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Linestyle ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c
index 8ae5ed7fbdd..e50e37c5428 100644
--- a/source/blender/blenkernel/intern/main.c
+++ b/source/blender/blenkernel/intern/main.c
@@ -56,7 +56,8 @@ void BKE_main_free(Main *mainvar)
ListBase *lbarray[MAX_LIBARRAY];
int a;
- /* Since we are removing whole main, no need to bother 'properly' (and slowly) removing each ID from it. */
+ /* Since we are removing whole main, no need to bother 'properly'
+ * (and slowly) removing each ID from it. */
const int free_flag = (LIB_ID_FREE_NO_MAIN | LIB_ID_FREE_NO_UI_USER |
LIB_ID_FREE_NO_USER_REFCOUNT | LIB_ID_FREE_NO_DEG_TAG);
@@ -285,7 +286,8 @@ void BKE_main_relations_free(Main *bmain)
/**
* Create a GSet storing all IDs present in given \a bmain, by their pointers.
*
- * \param gset: If not NULL, given GSet will be extended with IDs from given \a bmain, instead of creating a new one.
+ * \param gset: If not NULL, given GSet will be extended with IDs from given \a bmain,
+ * instead of creating a new one.
*/
GSet *BKE_main_gset_create(Main *bmain, GSet *gset)
{
@@ -348,8 +350,8 @@ ImBuf *BKE_main_thumbnail_to_imbuf(Main *bmain, BlendThumbnail *data)
}
if (data) {
- /* Note: we cannot use IMB_allocFromBuffer(), since it tries to dupalloc passed buffer, which will fail
- * here (we do not want to pass the first two ints!). */
+ /* Note: we cannot use IMB_allocFromBuffer(), since it tries to dupalloc passed buffer,
+ * which will fail here (we do not want to pass the first two ints!). */
img = IMB_allocImBuf(
(unsigned int)data->width, (unsigned int)data->height, 32, IB_rect | IB_metadata);
memcpy(img->rect, data->rect, BLEN_THUMB_MEMSIZE(data->width, data->height) - sizeof(*data));
@@ -381,7 +383,8 @@ const char *BKE_main_blendfile_path(const Main *bmain)
/**
* Return filepath of global main #G_MAIN.
*
- * \warning Usage is not recommended, you should always try to get a valid Main pointer from context...
+ * \warning Usage is not recommended,
+ * you should always try to get a valid Main pointer from context...
*/
const char *BKE_main_blendfile_path_from_global(void)
{
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index c925ebe26cf..9a9b3757ef2 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -273,7 +273,10 @@ MaskSpline *BKE_mask_spline_add(MaskLayer *masklay)
spline->tot_point = 1;
/* cyclic shapes are more usually used */
- // spline->flag |= MASK_SPLINE_CYCLIC; // disable because its not so nice for drawing. could be done differently
+ /* Disable because its not so nice for drawing. could be done differently. */
+#if 0
+ spline->flag |= MASK_SPLINE_CYCLIC;
+#endif
spline->weight_interp = MASK_SPLINE_INTERP_EASE;
@@ -863,8 +866,10 @@ Mask *BKE_mask_copy_nolib(Mask *mask)
}
/**
- * Only copy internal data of Mask ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Mask ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -1223,7 +1228,7 @@ static void mask_calc_point_handle(MaskSplinePoint *point,
{
BezTriple *bezt = &point->bezt;
BezTriple *bezt_prev = NULL, *bezt_next = NULL;
- //int handle_type = bezt->h1;
+ // int handle_type = bezt->h1;
if (point_prev) {
bezt_prev = &point_prev->bezt;
@@ -1802,7 +1807,8 @@ void BKE_mask_layer_shape_changed_add(MaskLayer *masklay,
if (BKE_mask_layer_shape_spline_from_index(masklay, index, &spline, &spline_point_index)) {
/* sanity check */
- /* the point has already been removed in this array so subtract one when comparing with the shapes */
+ /* The point has already been removed in this array
+ * so subtract one when comparing with the shapes. */
int tot = BKE_mask_layer_shape_totvert(masklay) - 1;
/* for interpolation */
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index 31cb0e54785..fe6ef2e047d 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -20,14 +20,16 @@
/** \file
* \ingroup bke
*
- * This module exposes a rasterizer that works as a black box - implementation details are confined to this file,
+ * This module exposes a rasterizer that works as a black box - implementation details
+ * are confined to this file.
*
* The basic method to access is:
* - create & initialize a handle from a #Mask datablock.
* - execute pixel lookups.
* - free the handle.
*
- * This file is admittedly a bit confusticated, in quite few areas speed was chosen over readability,
+ * This file is admittedly a bit confusticated,
+ * in quite few areas speed was chosen over readability,
* though it is commented - so shouldn't be so hard to see what's going on.
* Implementation:
*
@@ -35,12 +37,16 @@
*
* Initially 'kdopbvh' was used but this ended up being too slow.
*
- * To gain some extra speed we take advantage of a few shortcuts that can be made rasterizing masks specifically.
- * - all triangles are known to be completely white - so no depth check is done on triangle intersection.
- * - all quads are known to be feather outlines - the 1 and 0 depths are known by the vertex order in the quad,
- * - there is no color - just a value for each mask pixel.
- * - the mask spacial structure always maps to space 0-1 on X and Y axis.
- * - bucketing is used to speed up lookups for geometry.
+ * To gain some extra speed we take advantage of a few shortcuts
+ * that can be made rasterizing masks specifically.
+ *
+ * - All triangles are known to be completely white -
+ * so no depth check is done on triangle intersection.
+ * - All quads are known to be feather outlines -
+ * the 1 and 0 depths are known by the vertex order in the quad,
+ * - There is no color - just a value for each mask pixel.
+ * - The mask spacial structure always maps to space 0-1 on X and Y axis.
+ * - Bucketing is used to speed up lookups for geometry.
*
* Other Details:
* - used unsigned values all over for some extra speed on some arch's.
@@ -48,7 +54,8 @@
* - initializing the spacial structure doesn't need to be as optimized as pixel lookups are.
* - mask lookups need not be pixel aligned so any sub-pixel values from x/y (0 - 1), can be found.
* (perhaps masks can be used as a vector texture in 3D later on)
- * Currently, to build the spacial structure we have to calculate the total number of faces ahead of time.
+ * Currently, to build the spacial structure we have to calculate
+ * the total number of faces ahead of time.
*
* This is getting a bit complicated with the addition of unfilled splines and end capping -
* If large changes are needed here we would be better off using an iterable
@@ -504,16 +511,18 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
for (yi = yi_min; yi <= yi_max; yi++) {
unsigned int bucket_index = (layer->buckets_x * yi) + xi_min;
for (xi = xi_min; xi <= xi_max; xi++, bucket_index++) {
- // unsigned int bucket_index = (layer->buckets_x * yi) + xi; /* correct but do in outer loop */
+ /* correct but do in outer loop */
+ // unsigned int bucket_index = (layer->buckets_x * yi) + xi;
BLI_assert(xi < layer->buckets_x);
BLI_assert(yi < layer->buckets_y);
BLI_assert(bucket_index < bucket_tot);
- /* check if the bucket intersects with the face */
- /* note: there is a trade off here since checking box/tri intersections isn't
- * as optimal as it could be, but checking pixels against faces they will never intersect
- * with is likely the greater slowdown here - so check if the cell intersects the face */
+ /* Check if the bucket intersects with the face. */
+ /* Note: there is a trade off here since checking box/tri intersections isn't as
+ * optimal as it could be, but checking pixels against faces they will never
+ * intersect with is likely the greater slowdown here -
+ * so check if the cell intersects the face. */
if (layer_bucket_isect_test(layer,
face_index,
xi,
@@ -1160,7 +1169,15 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
MEM_freeN(open_spline_ranges);
- // fprintf(stderr, "%u %u (%u %u), %u\n", face_index, sf_tri_tot + tot_feather_quads, sf_tri_tot, tot_feather_quads, tot_boundary_used - tot_boundary_found);
+#if 0
+ fprintf(stderr,
+ "%u %u (%u %u), %u\n",
+ face_index,
+ sf_tri_tot + tot_feather_quads,
+ sf_tri_tot,
+ tot_feather_quads,
+ tot_boundary_used - tot_boundary_found);
+#endif
#ifdef USE_SCANFILL_EDGE_WORKAROUND
BLI_assert(face_index + (tot_boundary_used - tot_boundary_found) ==
@@ -1232,7 +1249,7 @@ static float maskrasterize_layer_z_depth_quad(
{
float w[4];
barycentric_weights_v2_quad(v1, v2, v3, v4, pt, w);
- //return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]) + (v4[2] * w[3]);
+ // return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]) + (v4[2] * w[3]);
return w[2] + w[3]; /* we can make this assumption for small speedup */
}
@@ -1270,7 +1287,7 @@ static float maskrasterize_layer_isect(unsigned int *face,
/* needs work */
#if 1
/* quad check fails for bow-tie, so keep using 2 tri checks */
- //if (isect_point_quad_v2(xy, cos[face[0]], cos[face[1]], cos[face[2]], cos[face[3]]))
+ // if (isect_point_quad_v2(xy, cos[face[0]], cos[face[1]], cos[face[2]], cos[face[3]]))
if (isect_point_tri_v2(xy, cos[face[0]], cos[face[1]], cos[face[2]]) ||
isect_point_tri_v2(xy, cos[face[0]], cos[face[2]], cos[face[3]])) {
return maskrasterize_layer_z_depth_quad(
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 599dc1e15d5..75b9e355df9 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -169,8 +169,10 @@ Material *BKE_material_add_gpencil(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Material ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Material ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 0980089a1f7..d6fa071009e 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -99,8 +99,10 @@ MetaBall *BKE_mball_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of MetaBall ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of MetaBall ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -238,7 +240,8 @@ BoundBox *BKE_mball_boundbox_get(Object *ob)
return ob->runtime.bb;
}
- /* This should always only be called with evaluated objects, but currently RNA is a problem here... */
+ /* This should always only be called with evaluated objects,
+ * but currently RNA is a problem here... */
if (ob->runtime.curve_cache != NULL) {
BKE_mball_texspace_calc(ob);
}
@@ -283,12 +286,15 @@ float *BKE_mball_make_orco(Object *ob, ListBase *dispbase)
/* Note on mball basis stuff 2.5x (this is a can of worms)
* This really needs a rewrite/refactor its totally broken in anything other then basic cases
- * Multiple Scenes + Set Scenes & mixing mball basis SHOULD work but fails to update the depsgraph on rename
- * and linking into scenes or removal of basis mball. so take care when changing this code.
+ * Multiple Scenes + Set Scenes & mixing mball basis SHOULD work but fails to update the depsgraph
+ * on rename and linking into scenes or removal of basis mball.
+ * So take care when changing this code.
*
- * Main idiot thing here is that the system returns find_basis_mball() objects which fail a is_basis_mball() test.
+ * Main idiot thing here is that the system returns find_basis_mball()
+ * objects which fail a is_basis_mball() test.
*
- * Not only that but the depsgraph and their areas depend on this behavior!, so making small fixes here isn't worth it.
+ * Not only that but the depsgraph and their areas depend on this behavior!,
+ * so making small fixes here isn't worth it.
* - Campbell
*/
@@ -360,8 +366,8 @@ bool BKE_mball_is_any_unselected(const MetaBall *mb)
/* \brief copy some properties from object to other metaball object with same base name
*
- * When some properties (wiresize, threshold, update flags) of metaball are changed, then this properties
- * are copied to all metaballs in same "group" (metaballs with same base name: MBall,
+ * When some properties (wiresize, threshold, update flags) of metaball are changed, then this
+ * properties are copied to all metaballs in same "group" (metaballs with same base name: MBall,
* MBall.001, MBall.002, etc). The most important is to copy properties to the base metaball,
* because this metaball influence polygonisation of metaballs. */
void BKE_mball_properties_copy(Scene *scene, Object *active_object)
@@ -427,7 +433,8 @@ Object *BKE_mball_basis_find(Scene *scene, Object *basis)
if (ob != bob) {
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
- /* object ob has to be in same "group" ... it means, that it has to have same base of its name */
+ /* Object ob has to be in same "group" ... it means,
+ * that it has to have same base of its name. */
if (STREQ(obname, basisname)) {
if (obnr < basisnr) {
basis = ob;
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index b008eca2258..1218e78c6f0 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.c
+++ b/source/blender/blenkernel/intern/mball_tessellate.c
@@ -1291,7 +1291,14 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje
/* Rotation of MetaElem is stored in quat */
quat_to_mat4(rot, ml->quat);
- /* basis object space -> world -> ml object space -> position -> rotation -> ml local space */
+ /* Matrix multiply is as follows:
+ * basis object space ->
+ * world ->
+ * ml object space ->
+ * position ->
+ * rotation ->
+ * ml local space
+ */
mul_m4_series((float(*)[4])new_ml->mat, obinv, bob->obmat, pos, rot);
/* ml local space -> basis object space */
invert_m4_m4((float(*)[4])new_ml->imat, (float(*)[4])new_ml->mat);
@@ -1324,7 +1331,8 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje
}
/* untransformed Bounding Box of MetaElem */
- /* TODO, its possible the elem type has been changed and the exp* values can use a fallback */
+ /* TODO, its possible the elem type has been changed and the exp*
+ * values can use a fallback. */
copy_v3_fl3(new_ml->bb->vec[0], -expx, -expy, -expz); /* 0 */
copy_v3_fl3(new_ml->bb->vec[1], +expx, -expy, -expz); /* 1 */
copy_v3_fl3(new_ml->bb->vec[2], +expx, +expy, -expz); /* 2 */
@@ -1424,8 +1432,9 @@ void BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob, ListBa
if (process.totelem > 0) {
build_bvh_spatial(&process, &process.metaball_bvh, 0, process.totelem, &process.allbb);
- /* don't polygonize metaballs with too high resolution (base mball to small)
- * note: Eps was 0.0001f but this was giving problems for blood animation for durian, using 0.00001f */
+ /* Don't polygonize metaballs with too high resolution (base mball to small)
+ * note: Eps was 0.0001f but this was giving problems for blood animation for durian,
+ * using 0.00001f. */
if (ob->scale[0] > 0.00001f * (process.allbb.max[0] - process.allbb.min[0]) ||
ob->scale[1] > 0.00001f * (process.allbb.max[1] - process.allbb.min[1]) ||
ob->scale[2] > 0.00001f * (process.allbb.max[2] - process.allbb.min[2])) {
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 117567621c9..56832c1724a 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -536,8 +536,10 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Mesh ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Mesh ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -926,7 +928,8 @@ void BKE_mesh_texspace_calc(Mesh *me)
BoundBox *BKE_mesh_boundbox_get(Object *ob)
{
- /* This is Object-level data access, DO NOT touch to Mesh's bb, would be totally thread-unsafe. */
+ /* This is Object-level data access,
+ * DO NOT touch to Mesh's bb, would be totally thread-unsafe. */
if (ob->runtime.bb == NULL || ob->runtime.bb->flag & BOUNDBOX_DIRTY) {
Mesh *me = ob->data;
float min[3], max[3];
@@ -1064,7 +1067,8 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
nr--;
}
- /* check corrupt cases, bow-tie geometry, cant handle these because edge data wont exist so just return 0 */
+ /* Check corrupt cases, bow-tie geometry,
+ * cant handle these because edge data wont exist so just return 0. */
if (nr == 3) {
if (
/* real edges */
@@ -1363,7 +1367,8 @@ void BKE_mesh_transform(Mesh *me, float mat[4][4], bool do_keys)
}
/* don't update normals, caller can do this explicitly.
- * We do update loop normals though, those may not be auto-generated (see e.g. STL import script)! */
+ * We do update loop normals though, those may not be auto-generated
+ * (see e.g. STL import script)! */
if (lnors) {
float m3[3][3];
@@ -1640,8 +1645,9 @@ void BKE_mesh_apply_vert_normals(Mesh *mesh, short (*vertNormals)[3])
/**
* Compute 'split' (aka loop, or per face corner's) normals.
*
- * \param r_lnors_spacearr: Allows to get computed loop normal space array. That data, among other things,
- * contains 'smooth fan' info, useful e.g. to split geometry along sharp edges...
+ * \param r_lnors_spacearr: Allows to get computed loop normal space array.
+ * That data, among other things, contains 'smooth fan' info, useful e.g.
+ * to split geometry along sharp edges...
*/
void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spacearr)
{
@@ -1651,7 +1657,8 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spac
bool free_polynors = false;
/* Note that we enforce computing clnors when the clnor space array is requested by caller here.
- * However, we obviously only use the autosmooth angle threshold only in case autosmooth is enabled. */
+ * However, we obviously only use the autosmooth angle threshold
+ * only in case autosmooth is enabled. */
const bool use_split_normals = (r_lnors_spacearr != NULL) || ((mesh->flag & ME_AUTOSMOOTH) != 0);
const float split_angle = (mesh->flag & ME_AUTOSMOOTH) != 0 ? mesh->smoothresh : (float)M_PI;
@@ -1668,7 +1675,8 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spac
clnors = CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL);
if (CustomData_has_layer(&mesh->pdata, CD_NORMAL)) {
- /* This assume that layer is always up to date, not sure this is the case (esp. in Edit mode?)... */
+ /* This assume that layer is always up to date, not sure this is the case
+ * (esp. in Edit mode?)... */
polynors = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
free_polynors = false;
}
@@ -1738,8 +1746,9 @@ static int split_faces_prepare_new_verts(const Mesh *mesh,
SplitFaceNewVert **new_verts,
MemArena *memarena)
{
- /* This is now mandatory, trying to do the job in simple way without that data is doomed to fail, even when only
- * dealing with smooth/flat faces one can find cases that no simple algorithm can handle properly. */
+ /* This is now mandatory, trying to do the job in simple way without that data is doomed to fail,
+ * even when only dealing with smooth/flat faces one can find cases that no simple algorithm
+ * can handle properly. */
BLI_assert(lnors_spacearr != NULL);
const int loops_len = mesh->totloop;
@@ -1785,8 +1794,9 @@ static int split_faces_prepare_new_verts(const Mesh *mesh,
if (!vert_used) {
BLI_BITMAP_ENABLE(verts_used, vert_idx);
/* We need to update that vertex's normal here, we won't go over it again. */
- /* This is important! *DO NOT* set vnor to final computed lnor, vnor should always be defined to
- * 'automatic normal' value computed from its polys, not some custom normal.
+ /* This is important! *DO NOT* set vnor to final computed lnor,
+ * vnor should always be defined to 'automatic normal' value computed from its polys,
+ * not some custom normal.
* Fortunately, that's the loop normal space's 'lnor' reference vector. ;) */
normal_float_to_short_v3(mvert[vert_idx].no, (*lnor_space)->vec_lnor);
}
@@ -1938,8 +1948,9 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals)
mesh, &lnors_spacearr, &new_verts, memarena);
if (num_new_verts > 0) {
- /* Reminder: beyond this point, there is no way out, mesh is in invalid state (due to early-reassignment of
- * loops' vertex and edge indices to new, to-be-created split ones). */
+ /* Reminder: beyond this point, there is no way out, mesh is in invalid state
+ * (due to early-reassignment of loops' vertex and edge indices to new,
+ * to-be-created split ones). */
const int num_new_edges = split_faces_prepare_new_edges(mesh, &new_edges, memarena);
/* We can have to split a vertex without having to add a single new edge... */
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index 93017e77d36..3f4e504867c 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -656,7 +656,8 @@ void BKE_mesh_from_nurbs_displist(Main *bmain,
cu->mat = NULL;
cu->totcol = 0;
- /* Do not decrement ob->data usercount here, it's done at end of func with BKE_id_free_us() call. */
+ /* Do not decrement ob->data usercount here,
+ * it's done at end of func with BKE_id_free_us() call. */
ob->data = me;
ob->type = OB_MESH;
@@ -1036,9 +1037,10 @@ Mesh *BKE_mesh_new_from_object(Depsgraph *depsgraph,
BKE_id_free(NULL, tmpobj);
- /* XXX The curve to mesh conversion is convoluted... But essentially, BKE_mesh_from_nurbs_displist()
- * already transfers the ownership of materials from the temp copy of the Curve ID to the new
- * Mesh ID, so we do not want to increase materials' usercount later. */
+ /* XXX The curve to mesh conversion is convoluted...
+ * But essentially, BKE_mesh_from_nurbs_displist()
+ * already transfers the ownership of materials from the temp copy of the Curve ID to the
+ * new Mesh ID, so we do not want to increase materials' usercount later. */
do_mat_id_data_us = false;
break;
@@ -1236,25 +1238,26 @@ static void add_shapekey_layers(Mesh *mesh_dest, Mesh *mesh_src)
Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
Scene *scene,
- Object *ob,
- ModifierData *md,
+ Object *ob_eval,
+ ModifierData *md_eval,
int build_shapekey_layers)
{
- Mesh *me = ob->runtime.mesh_orig ? ob->runtime.mesh_orig : ob->data;
- const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ Mesh *me = ob_eval->runtime.mesh_orig ? ob_eval->runtime.mesh_orig : ob_eval->data;
+ const ModifierTypeInfo *mti = modifierType_getInfo(md_eval->type);
Mesh *result;
KeyBlock *kb;
- ModifierEvalContext mectx = {depsgraph, ob, 0};
+ ModifierEvalContext mectx = {depsgraph, ob_eval, 0};
- if (!(md->mode & eModifierMode_Realtime)) {
+ if (!(md_eval->mode & eModifierMode_Realtime)) {
return NULL;
}
- if (mti->isDisabled && mti->isDisabled(scene, md, 0)) {
+ if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) {
return NULL;
}
- if (build_shapekey_layers && me->key && (kb = BLI_findlink(&me->key->block, ob->shapenr - 1))) {
+ if (build_shapekey_layers && me->key &&
+ (kb = BLI_findlink(&me->key->block, ob_eval->shapenr - 1))) {
BKE_keyblock_convert_to_mesh(kb, me);
}
@@ -1262,8 +1265,8 @@ Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
int numVerts;
float(*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
- mti->deformVerts(md, &mectx, NULL, deformedVerts, numVerts);
BKE_id_copy_ex(NULL, &me->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
+ mti->deformVerts(md_eval, &mectx, result, deformedVerts, numVerts);
BKE_mesh_apply_vert_coords(result, deformedVerts);
if (build_shapekey_layers) {
@@ -1280,7 +1283,7 @@ Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
add_shapekey_layers(mesh_temp, me);
}
- result = mti->applyModifier(md, &mectx, mesh_temp);
+ result = mti->applyModifier(md_eval, &mectx, mesh_temp);
ASSERT_IS_VALID_MESH(result);
if (mesh_temp != result) {
@@ -1361,7 +1364,8 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src,
bool take_ownership)
{
/* mesh_src might depend on mesh_dst, so we need to do everything with a local copy */
- /* TODO(Sybren): the above claim came from DM_to_mesh(); check whether it is still true with Mesh */
+ /* TODO(Sybren): the above claim came from DM_to_mesh();
+ * check whether it is still true with Mesh */
Mesh tmp = *mesh_dst;
int totvert, totedge /*, totface */ /* UNUSED */, totloop, totpoly;
int did_shapekeys = 0;
@@ -1429,8 +1433,8 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src,
/* not all DerivedMeshes store their verts/edges/faces in CustomData, so
* we set them here in case they are missing */
- /* TODO(Sybren): we could probably replace CD_ASSIGN with alloctype and always directly pass mesh_src->mxxx,
- * instead of using a ternary operator. */
+ /* TODO(Sybren): we could probably replace CD_ASSIGN with alloctype and
+ * always directly pass mesh_src->mxxx, instead of using a ternary operator. */
if (!CustomData_has_layer(&tmp.vdata, CD_MVERT)) {
CustomData_add_layer(&tmp.vdata,
CD_MVERT,
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 800d61a6a66..d889fca3a3a 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -168,7 +168,8 @@ void BKE_mesh_calc_normals_mapping_ex(MVert *mverts,
if (!pnors) {
pnors = MEM_calloc_arrayN((size_t)numPolys, sizeof(float[3]), __func__);
}
- /* if (!fnors) fnors = MEM_calloc_arrayN(numFaces, sizeof(float[3]), "face nors mesh.c"); */ /* NO NEED TO ALLOC YET */
+ /* NO NEED TO ALLOC YET */
+ /* if (!fnors) fnors = MEM_calloc_arrayN(numFaces, sizeof(float[3]), "face nors mesh.c"); */
if (only_face_normals == false) {
/* vertex normals are optional, they require some extra calculations,
@@ -366,7 +367,8 @@ void BKE_mesh_calc_normals_poly(MVert *mverts,
BLI_task_parallel_range(0, numPolys, &data, mesh_calc_normals_poly_prepare_cb, &settings);
/* Actually accumulate weighted loop normals into vertex ones. */
- /* Unfortunately, not possible to thread that (not in a reasonable, totally lock- and barrier-free fashion),
+ /* Unfortunately, not possible to thread that
+ * (not in a reasonable, totally lock- and barrier-free fashion),
* since several loops will point to the same vertex... */
for (int lidx = 0; lidx < numLoops; lidx++) {
add_v3_v3(vnors[mloop[lidx].v], data.lnors_weighted[lidx]);
@@ -424,7 +426,8 @@ void BKE_mesh_ensure_normals_for_display(Mesh *mesh)
}
}
-/* Note that this does not update the CD_NORMAL layer, but does update the normals in the CD_MVERT layer. */
+/* Note that this does not update the CD_NORMAL layer,
+ * but does update the normals in the CD_MVERT layer. */
void BKE_mesh_calc_normals(Mesh *mesh)
{
#ifdef DEBUG_TIME
@@ -609,7 +612,8 @@ MLoopNorSpace *BKE_lnor_space_create(MLoopNorSpaceArray *lnors_spacearr)
/* Should only be called once.
* Beware, this modifies ref_vec and other_vec in place!
- * In case no valid space can be generated, ref_alpha and ref_beta are set to zero (which means 'use auto lnors').
+ * In case no valid space can be generated, ref_alpha and ref_beta are set to zero
+ * (which means 'use auto lnors').
*/
void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
const float lnor[3],
@@ -646,8 +650,10 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
BLI_stack_discard(edge_vectors);
nbr++;
}
- /* Note: In theory, this could be 'nbr > 2', but there is one case where we only have two edges for
- * two loops: a smooth vertex with only two edges and two faces (our Monkey's nose has that, e.g.). */
+ /* Note: In theory, this could be 'nbr > 2',
+ * but there is one case where we only have two edges for two loops:
+ * a smooth vertex with only two edges and two faces (our Monkey's nose has that, e.g.).
+ */
BLI_assert(nbr >= 2); /* This piece of code shall only be called for more than one loop... */
lnor_space->ref_alpha = alpha / (float)nbr;
}
@@ -683,10 +689,11 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
/**
* Add a new given loop to given lnor_space.
- * Depending on \a lnor_space->data_type, we expect \a bm_loop to be a pointer to BMLoop struct (in case of BMLOOP_PTR),
- * or NULL (in case of LOOP_INDEX), loop index is then stored in pointer.
- * If \a is_single is set, the BMLoop or loop index is directly stored in \a lnor_space->loops pointer (since there
- * is only one loop in this fan), else it is added to the linked list of loops in the fan.
+ * Depending on \a lnor_space->data_type, we expect \a bm_loop to be a pointer to BMLoop struct
+ * (in case of BMLOOP_PTR), or NULL (in case of LOOP_INDEX), loop index is then stored in pointer.
+ * If \a is_single is set, the BMLoop or loop index is directly stored in \a lnor_space->loops
+ * pointer (since there is only one loop in this fan),
+ * else it is added to the linked list of loops in the fan.
*/
void BKE_lnor_space_add_loop(MLoopNorSpaceArray *lnors_spacearr,
MLoopNorSpace *lnor_space,
@@ -775,7 +782,8 @@ void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space,
alpha = saacosf(cos_alpha);
if (alpha > lnor_space->ref_alpha) {
- /* Note we could stick to [0, pi] range here, but makes decoding more complex, not worth it. */
+ /* Note we could stick to [0, pi] range here,
+ * but makes decoding more complex, not worth it. */
r_clnor_data[0] = unit_float_to_short(-(pi2 - alpha) / (pi2 - lnor_space->ref_alpha));
}
else {
@@ -812,17 +820,20 @@ void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space,
typedef struct LoopSplitTaskData {
/* Specific to each instance (each task). */
- MLoopNorSpace *
- lnor_space; /* We have to create those outside of tasks, since afaik memarena is not threadsafe. */
+
+ /** We have to create those outside of tasks, since afaik memarena is not threadsafe. */
+ MLoopNorSpace *lnor_space;
float (*lnor)[3];
const MLoop *ml_curr;
const MLoop *ml_prev;
int ml_curr_index;
int ml_prev_index;
- const int *e2l_prev; /* Also used a flag to switch between single or fan process! */
+ /** Also used a flag to switch between single or fan process! */
+ const int *e2l_prev;
int mp_index;
- /* This one is special, it's owned and managed by worker tasks, avoid to have to create it for each fan! */
+ /** This one is special, it's owned and managed by worker tasks,
+ * avoid to have to create it for each fan! */
BLI_Stack *edge_vectors;
char pad_c;
@@ -830,8 +841,8 @@ typedef struct LoopSplitTaskData {
typedef struct LoopSplitTaskDataCommon {
/* Read/write.
- * Note we do not need to protect it, though, since two different tasks will *always* affect different
- * elements in the arrays. */
+ * Note we do not need to protect it, though, since two different tasks will *always* affect
+ * different elements in the arrays. */
MLoopNorSpaceArray *lnors_spacearr;
float (*loopnors)[3];
short (*clnors_data)[2];
@@ -895,8 +906,8 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data,
loop_to_poly[ml_curr_index] = mp_index;
- /* Pre-populate all loop normals as if their verts were all-smooth, this way we don't have to compute
- * those later!
+ /* Pre-populate all loop normals as if their verts were all-smooth,
+ * this way we don't have to compute those later!
*/
if (loopnors) {
normal_short_to_float_v3(loopnors[ml_curr_index], mverts[ml_curr->v].no);
@@ -916,8 +927,8 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data,
/* Second loop using this edge, time to test its sharpness.
* An edge is sharp if it is tagged as such, or its face is not smooth,
- * or both poly have opposed (flipped) normals, i.e. both loops on the same edge share the same vertex,
- * or angle between both its polys' normals is above split_angle value.
+ * or both poly have opposed (flipped) normals, i.e. both loops on the same edge share the
+ * same vertex, or angle between both its polys' normals is above split_angle value.
*/
if (!(mp->flag & ME_SMOOTH) || (medges[ml_curr->e].flag & ME_SHARP) ||
ml_curr->v == mloops[e2l[0]].v || is_angle_sharp) {
@@ -964,7 +975,8 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data,
/** Define sharp edges as needed to mimic 'autosmooth' from angle threshold.
*
- * Used when defining an empty custom loop normals data layer, to keep same shading as with autosmooth!
+ * Used when defining an empty custom loop normals data layer,
+ * to keep same shading as with autosmooth!
*/
void BKE_edges_sharp_from_angle_set(const struct MVert *mverts,
const int UNUSED(numVerts),
@@ -1079,7 +1091,13 @@ static void split_loop_nor_single_do(LoopSplitTaskDataCommon *common_data, LoopS
*/
copy_v3_v3(*lnor, polynors[mp_index]);
- // printf("BASIC: handling loop %d / edge %d / vert %d / poly %d\n", ml_curr_index, ml_curr->e, ml_curr->v, mp_index);
+#if 0
+ printf("BASIC: handling loop %d / edge %d / vert %d / poly %d\n",
+ ml_curr_index,
+ ml_curr->e,
+ ml_curr->v,
+ mp_index);
+#endif
/* If needed, generate this (simple!) lnor space. */
if (lnors_spacearr) {
@@ -1100,7 +1118,8 @@ static void split_loop_nor_single_do(LoopSplitTaskDataCommon *common_data, LoopS
normalize_v3(vec_prev);
BKE_lnor_space_define(lnor_space, *lnor, vec_curr, vec_prev, NULL);
- /* We know there is only one loop in this space, no need to create a linklist in this case... */
+ /* We know there is only one loop in this space,
+ * no need to create a linklist in this case... */
BKE_lnor_space_add_loop(lnors_spacearr, lnor_space, ml_curr_index, NULL, true);
if (clnors_data) {
@@ -1138,10 +1157,10 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
/* Gah... We have to fan around current vertex, until we find the other non-smooth edge,
* and accumulate face normals into the vertex!
- * Note in case this vertex has only one sharp edges, this is a waste because the normal is the same as
- * the vertex normal, but I do not see any easy way to detect that (would need to count number
- * of sharp edges per vertex, I doubt the additional memory usage would be worth it, especially as
- * it should not be a common case in real-life meshes anyway).
+ * Note in case this vertex has only one sharp edges, this is a waste because the normal is the
+ * same as the vertex normal, but I do not see any easy way to detect that (would need to count
+ * number of sharp edges per vertex, I doubt the additional memory usage would be worth it,
+ * especially as it should not be a common case in real-life meshes anyway).
*/
const unsigned int mv_pivot_index = ml_curr->v; /* The vertex we are "fanning" around! */
const MVert *mv_pivot = &mverts[mv_pivot_index];
@@ -1193,8 +1212,8 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
while (true) {
const MEdge *me_curr = &medges[mlfan_curr->e];
/* Compute edge vectors.
- * NOTE: We could pre-compute those into an array, in the first iteration, instead of computing them
- * twice (or more) here. However, time gained is not worth memory and time lost,
+ * NOTE: We could pre-compute those into an array, in the first iteration, instead of computing
+ * them twice (or more) here. However, time gained is not worth memory and time lost,
* given the fact that this code should not be called that much in real-life meshes...
*/
{
@@ -1293,13 +1312,14 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
printf("Invalid clnors in this fan!\n");
}
while ((clnor = BLI_SMALLSTACK_POP(clnors))) {
- //print_v2("org clnor", clnor);
+ // print_v2("org clnor", clnor);
clnor[0] = (short)clnors_avg[0];
clnor[1] = (short)clnors_avg[1];
}
- //print_v2("new clnors", clnors_avg);
+ // print_v2("new clnors", clnors_avg);
}
- /* Extra bonus: since smallstack is local to this func, no more need to empty it at all cost! */
+ /* Extra bonus: since smallstack is local to this func,
+ * no more need to empty it at all cost! */
BKE_lnor_space_custom_data_to_normal(lnor_space, *clnor_ref, lnor);
}
@@ -1314,7 +1334,8 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
copy_v3_v3(nor, lnor);
}
}
- /* Extra bonus: since smallstack is local to this func, no more need to empty it at all cost! */
+ /* Extra bonus: since smallstack is local to this func,
+ * no more need to empty it at all cost! */
}
}
@@ -1367,7 +1388,8 @@ static void loop_split_worker(TaskPool *__restrict pool, void *taskdata, int UNU
}
/* Check whether gievn loop is part of an unknown-so-far cyclic smooth fan, or not.
- * Needed because cyclic smooth fans have no obvious 'entry point', and yet we need to walk them once, and only once. */
+ * Needed because cyclic smooth fans have no obvious 'entry point',
+ * and yet we need to walk them once, and only once. */
static bool loop_split_generator_check_cyclic_smooth_fan(const MLoop *mloops,
const MPoly *mpolys,
const int (*edge_to_loops)[2],
@@ -1425,8 +1447,8 @@ static bool loop_split_generator_check_cyclic_smooth_fan(const MLoop *mloops,
/* Smooth loop/edge... */
else if (BLI_BITMAP_TEST(skip_loops, mlfan_vert_index)) {
if (mlfan_vert_index == ml_curr_index) {
- /* We walked around a whole cyclic smooth fan without finding any already-processed loop, means we can
- * use initial ml_curr/ml_prev edge as start for this smooth fan. */
+ /* We walked around a whole cyclic smooth fan without finding any already-processed loop,
+ * means we can use initial ml_curr/ml_prev edge as start for this smooth fan. */
return true;
}
/* ... already checked in some previous looping, we can abort. */
@@ -1464,7 +1486,8 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
LoopSplitTaskData *data_buff = NULL;
int data_idx = 0;
- /* Temp edge vectors stack, only used when computing lnor spacearr (and we are not multi-threading). */
+ /* Temp edge vectors stack, only used when computing lnor spacearr
+ * (and we are not multi-threading). */
BLI_Stack *edge_vectors = NULL;
#ifdef DEBUG_TIME
@@ -1477,8 +1500,8 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
}
}
- /* We now know edges that can be smoothed (with their vector, and their two loops), and edges that will be hard!
- * Now, time to generate the normals.
+ /* We now know edges that can be smoothed (with their vector, and their two loops),
+ * and edges that will be hard! Now, time to generate the normals.
*/
for (mp = mpolys, mp_index = 0; mp_index < numPolys; mp++, mp_index++) {
float(*lnors)[3];
@@ -1494,17 +1517,25 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
const int *e2l_curr = edge_to_loops[ml_curr->e];
const int *e2l_prev = edge_to_loops[ml_prev->e];
- // printf("Checking loop %d / edge %u / vert %u (sharp edge: %d, skiploop: %d)...",
- // ml_curr_index, ml_curr->e, ml_curr->v, IS_EDGE_SHARP(e2l_curr), BLI_BITMAP_TEST_BOOL(skip_loops, ml_curr_index));
+#if 0
+ printf("Checking loop %d / edge %u / vert %u (sharp edge: %d, skiploop: %d)...",
+ ml_curr_index,
+ ml_curr->e,
+ ml_curr->v,
+ IS_EDGE_SHARP(e2l_curr),
+ BLI_BITMAP_TEST_BOOL(skip_loops, ml_curr_index));
+#endif
/* A smooth edge, we have to check for cyclic smooth fan case.
- * If we find a new, never-processed cyclic smooth fan, we can do it now using that loop/edge as
- * 'entry point', otherwise we can skip it. */
+ * If we find a new, never-processed cyclic smooth fan, we can do it now using that loop/edge
+ * as 'entry point', otherwise we can skip it. */
+
/* Note: In theory, we could make loop_split_generator_check_cyclic_smooth_fan() store
- * mlfan_vert_index'es and edge indexes in two stacks, to avoid having to fan again around the vert during
- * actual computation of clnor & clnorspace. However, this would complicate the code, add more memory usage,
- * and despite its logical complexity, loop_manifold_fan_around_vert_next() is quite cheap in term of
- * CPU cycles, so really think it's not worth it. */
+ * mlfan_vert_index'es and edge indexes in two stacks, to avoid having to fan again around
+ * the vert during actual computation of clnor & clnorspace. However, this would complicate
+ * the code, add more memory usage, and despite its logical complexity,
+ * loop_manifold_fan_around_vert_next() is quite cheap in term of CPU cycles,
+ * so really think it's not worth it. */
if (!IS_EDGE_SHARP(e2l_curr) && (BLI_BITMAP_TEST(skip_loops, ml_curr_index) ||
!loop_split_generator_check_cyclic_smooth_fan(mloops,
mpolys,
@@ -1551,10 +1582,11 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
}
}
/* We *do not need* to check/tag loops as already computed!
- * Due to the fact a loop only links to one of its two edges, a same fan *will never be walked
- * more than once!*
- * Since we consider edges having neighbor polys with inverted (flipped) normals as sharp, we are sure
- * that no fan will be skipped, even only considering the case (sharp curr_edge, smooth prev_edge),
+ * Due to the fact a loop only links to one of its two edges,
+ * a same fan *will never be walked more than once!*
+ * Since we consider edges having neighbor polys with inverted
+ * (flipped) normals as sharp, we are sure that no fan will be skipped,
+ * even only considering the case (sharp curr_edge, smooth prev_edge),
* and not the alternative (smooth curr_edge, sharp prev_edge).
* All this due/thanks to link between normals and loop ordering (i.e. winding).
*/
@@ -1590,7 +1622,8 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
}
}
- /* Last block of data... Since it is calloc'ed and we use first NULL item as stopper, everything is fine. */
+ /* Last block of data... Since it is calloc'ed and we use first NULL item as stopper,
+ * everything is fine. */
if (pool && data_idx) {
BLI_task_pool_push(pool, loop_split_worker, data_buff, true, TASK_PRIORITY_LOW);
}
@@ -1607,7 +1640,8 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
/**
* Compute split normals, i.e. vertex normals associated with each poly (hence 'loop normals').
- * Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry (splitting edges).
+ * Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry
+ * (splitting edges).
*/
void BKE_mesh_normals_loop_split(const MVert *mverts,
const int UNUSED(numVerts),
@@ -1625,14 +1659,17 @@ void BKE_mesh_normals_loop_split(const MVert *mverts,
short (*clnors_data)[2],
int *r_loop_to_poly)
{
- /* For now this is not supported. If we do not use split normals, we do not generate anything fancy! */
+ /* For now this is not supported.
+ * If we do not use split normals, we do not generate anything fancy! */
BLI_assert(use_split_normals || !(r_lnors_spacearr));
if (!use_split_normals) {
/* In this case, we simply fill lnors with vnors (or fnors for flat faces), quite simple!
* Note this is done here to keep some logic and consistency in this quite complex code,
- * since we may want to use lnors even when mesh's 'autosmooth' is disabled (see e.g. mesh mapping code).
- * As usual, we could handle that on case-by-case basis, but simpler to keep it well confined here.
+ * since we may want to use lnors even when mesh's 'autosmooth' is disabled
+ * (see e.g. mesh mapping code).
+ * As usual, we could handle that on case-by-case basis,
+ * but simpler to keep it well confined here.
*/
int mp_index;
@@ -1657,15 +1694,20 @@ void BKE_mesh_normals_loop_split(const MVert *mverts,
return;
}
- /* Mapping edge -> loops.
- * If that edge is used by more than two loops (polys), it is always sharp (and tagged as such, see below).
- * We also use the second loop index as a kind of flag: smooth edge: > 0,
- * sharp edge: < 0 (INDEX_INVALID || INDEX_UNSET),
- * unset: INDEX_UNSET
- * Note that currently we only have two values for second loop of sharp edges. However, if needed, we can
- * store the negated value of loop index instead of INDEX_INVALID to retrieve the real value later in code).
- * Note also that lose edges always have both values set to 0!
- */
+ /**
+ * Mapping edge -> loops.
+ * If that edge is used by more than two loops (polys),
+ * it is always sharp (and tagged as such, see below).
+ * We also use the second loop index as a kind of flag:
+ *
+ * - smooth edge: > 0.
+ * - sharp edge: < 0 (INDEX_INVALID || INDEX_UNSET).
+ * - unset: INDEX_UNSET.
+ *
+ * Note that currently we only have two values for second loop of sharp edges.
+ * However, if needed, we can store the negated value of loop index instead of INDEX_INVALID
+ * to retrieve the real value later in code).
+ * Note also that lose edges always have both values set to 0! */
int(*edge_to_loops)[2] = MEM_calloc_arrayN((size_t)numEdges, sizeof(*edge_to_loops), __func__);
/* Simple mapping from a loop to its polygon index. */
@@ -1750,12 +1792,12 @@ void BKE_mesh_normals_loop_split(const MVert *mverts,
/**
* Compute internal representation of given custom normals (as an array of float[2]).
- * It also makes sure the mesh matches those custom normals, by setting sharp edges flag as needed to get a
- * same custom lnor for all loops sharing a same smooth fan.
+ * It also makes sure the mesh matches those custom normals, by setting sharp edges flag as needed
+ * to get a same custom lnor for all loops sharing a same smooth fan.
* If use_vertices if true, r_custom_loopnors is assumed to be per-vertex, not per-loop
* (this allows to set whole vert's normals at once, useful in some cases).
- * r_custom_loopnors is expected to have normalized normals, or zero ones, in which case they will be replaced
- * by default loop/vertex normal.
+ * r_custom_loopnors is expected to have normalized normals, or zero ones,
+ * in which case they will be replaced by default loop/vertex normal.
*/
static void mesh_normals_loop_custom_set(const MVert *mverts,
const int numVerts,
@@ -1770,17 +1812,19 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
short (*r_clnors_data)[2],
const bool use_vertices)
{
- /* We *may* make that poor BKE_mesh_normals_loop_split() even more complex by making it handling that
- * feature too, would probably be more efficient in absolute.
+ /* We *may* make that poor BKE_mesh_normals_loop_split() even more complex by making it handling
+ * that feature too, would probably be more efficient in absolute.
* However, this function *is not* performance-critical, since it is mostly expected to be called
- * by io addons when importing custom normals, and modifier (and perhaps from some editing tools later?).
+ * by io addons when importing custom normals, and modifier
+ * (and perhaps from some editing tools later?).
* So better to keep some simplicity here, and just call BKE_mesh_normals_loop_split() twice!
*/
MLoopNorSpaceArray lnors_spacearr = {NULL};
BLI_bitmap *done_loops = BLI_BITMAP_NEW((size_t)numLoops, __func__);
float(*lnors)[3] = MEM_calloc_arrayN((size_t)numLoops, sizeof(*lnors), __func__);
int *loop_to_poly = MEM_malloc_arrayN((size_t)numLoops, sizeof(int), __func__);
- /* In this case we always consider split nors as ON, and do not want to use angle to define smooth fans! */
+ /* In this case we always consider split nors as ON,
+ * and do not want to use angle to define smooth fans! */
const bool use_split_normals = true;
const float split_angle = (float)M_PI;
int i;
@@ -1822,12 +1866,12 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
BLI_assert(lnors_spacearr.data_type == MLNOR_SPACEARR_LOOP_INDEX);
- /* Now, check each current smooth fan (one lnor space per smooth fan!), and if all its matching custom lnors
- * are not (enough) equal, add sharp edges as needed.
- * This way, next time we run BKE_mesh_normals_loop_split(), we'll get lnor spacearr/smooth fans matching
- * given custom lnors.
- * Note this code *will never* unsharp edges!
- * And quite obviously, when we set custom normals per vertices, running this is absolutely useless.
+ /* Now, check each current smooth fan (one lnor space per smooth fan!),
+ * and if all its matching custom lnors are not (enough) equal, add sharp edges as needed.
+ * This way, next time we run BKE_mesh_normals_loop_split(), we'll get lnor spacearr/smooth fans
+ * matching given custom lnors.
+ * Note this code *will never* unsharp edges! And quite obviously,
+ * when we set custom normals per vertices, running this is absolutely useless.
*/
if (!use_vertices) {
for (i = 0; i < numLoops; i++) {
@@ -1845,13 +1889,13 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
if (!BLI_BITMAP_TEST(done_loops, i)) {
/* Notes:
- * * In case of mono-loop smooth fan, we have nothing to do.
- * * Loops in this linklist are ordered (in reversed order compared to how they were discovered by
- * BKE_mesh_normals_loop_split(), but this is not a problem). Which means if we find a
- * mismatching clnor, we know all remaining loops will have to be in a new, different smooth fan/
- * lnor space.
- * * In smooth fan case, we compare each clnor against a ref one, to avoid small differences adding
- * up into a real big one in the end!
+ * * In case of mono-loop smooth fan, we have nothing to do.
+ * * Loops in this linklist are ordered (in reversed order compared to how they were
+ * discovered by BKE_mesh_normals_loop_split(), but this is not a problem).
+ * Which means if we find a mismatching clnor,
+ * we know all remaining loops will have to be in a new, different smooth fan/lnor space.
+ * * In smooth fan case, we compare each clnor against a ref one,
+ * to avoid small differences adding up into a real big one in the end!
*/
if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
BLI_BITMAP_ENABLE(done_loops, i);
@@ -1874,8 +1918,8 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
else if (dot_v3v3(org_nor, nor) < LNOR_SPACE_TRIGO_THRESHOLD) {
/* Current normal differs too much from org one, we have to tag the edge between
* previous loop's face and current's one as sharp.
- * We know those two loops do not point to the same edge, since we do not allow reversed winding
- * in a same smooth fan.
+ * We know those two loops do not point to the same edge,
+ * since we do not allow reversed winding in a same smooth fan.
*/
const MPoly *mp = &mpolys[loop_to_poly[lidx]];
const MLoop *mlp =
@@ -1890,7 +1934,8 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
BLI_BITMAP_ENABLE(done_loops, lidx);
}
- /* We also have to check between last and first loops, otherwise we may miss some sharp edges here!
+ /* We also have to check between last and first loops,
+ * otherwise we may miss some sharp edges here!
* This is just a simplified version of above while loop.
* See T45984. */
loops = lnors_spacearr.lspacearr[i]->loops;
@@ -1932,7 +1977,8 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
BLI_bitmap_set_all(done_loops, true, (size_t)numLoops);
}
- /* And we just have to convert plain object-space custom normals to our lnor space-encoded ones. */
+ /* And we just have to convert plain object-space custom normals to our
+ * lnor space-encoded ones. */
for (i = 0; i < numLoops; i++) {
if (!lnors_spacearr.lspacearr[i]) {
BLI_BITMAP_DISABLE(done_loops, i);
@@ -1943,9 +1989,9 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
}
if (BLI_BITMAP_TEST_BOOL(done_loops, i)) {
- /* Note we accumulate and average all custom normals in current smooth fan, to avoid getting different
- * clnors data (tiny differences in plain custom normals can give rather huge differences in
- * computed 2D factors).
+ /* Note we accumulate and average all custom normals in current smooth fan,
+ * to avoid getting different clnors data (tiny differences in plain custom normals can
+ * give rather huge differences in computed 2D factors).
*/
LinkNode *loops = lnors_spacearr.lspacearr[i]->loops;
if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
@@ -2092,7 +2138,8 @@ static void mesh_set_custom_normals(Mesh *mesh, float (*r_custom_nors)[3], const
}
/**
- * Higher level functions hiding most of the code needed around call to #BKE_mesh_normals_loop_custom_set().
+ * Higher level functions hiding most of the code needed around call to
+ * #BKE_mesh_normals_loop_custom_set().
*
* \param r_custom_loopnors is not const, since code will replace zero_v3 normals there
* with automatically computed vectors.
@@ -2103,7 +2150,8 @@ void BKE_mesh_set_custom_normals(Mesh *mesh, float (*r_custom_loopnors)[3])
}
/**
- * Higher level functions hiding most of the code needed around call to #BKE_mesh_normals_loop_custom_from_vertices_set().
+ * Higher level functions hiding most of the code needed around call to
+ * #BKE_mesh_normals_loop_custom_from_vertices_set().
*
* \param r_custom_loopnors is not const, since code will replace zero_v3 normals there
* with automatically computed vectors.
@@ -2327,7 +2375,8 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly, const MLoop *loopstart, const
}
/**
- * Calculate the volume and volume-weighted centroid of the volume formed by the polygon and the origin.
+ * Calculate the volume and volume-weighted centroid of the volume
+ * formed by the polygon and the origin.
* Results will be negative if the origin is "outside" the polygon
* (+ve normal side), but the polygon may be non-planar with no effect.
*
@@ -2339,8 +2388,8 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly, const MLoop *loopstart, const
* - Volume is 6x actual volume, and centroid is 4x actual volume-weighted centroid
* (so division can be done once at the end).
* - Results will have bias if polygon is non-planar.
- * - The resulting volume will only be correct if the mesh is manifold and has consistent face winding
- * (non-contiguous face normals or holes in the mesh surface).
+ * - The resulting volume will only be correct if the mesh is manifold and has consistent
+ * face winding (non-contiguous face normals or holes in the mesh surface).
*/
static float mesh_calc_poly_volume_centroid(const MPoly *mpoly,
const MLoop *loopstart,
@@ -2369,7 +2418,8 @@ static float mesh_calc_poly_volume_centroid(const MPoly *mpoly,
* of the triangle and the origin as the fourth vertex.
* The centroid is simply the average of the 4 vertices.
*
- * Note that the vector is 4x the actual centroid so the division can be done once at the end. */
+ * Note that the vector is 4x the actual centroid
+ * so the division can be done once at the end. */
for (uint j = 0; j < 3; j++) {
r_cent[j] += tetra_volume * (v_pivot[j] + v_step1[j] + v_step2[j]);
}
@@ -2541,7 +2591,8 @@ bool BKE_mesh_center_of_surface(const Mesh *me, float r_cent[3])
}
/**
- * \note Mesh must be manifold with consistent face-winding, see #mesh_calc_poly_volume_centroid for details.
+ * \note Mesh must be manifold with consistent face-winding,
+ * see #mesh_calc_poly_volume_centroid for details.
*/
bool BKE_mesh_center_of_volume(const Mesh *me, float r_cent[3])
{
@@ -2565,7 +2616,8 @@ bool BKE_mesh_center_of_volume(const Mesh *me, float r_cent[3])
/* otherwise we get NAN for 0 polys */
if (total_volume != 0.0f) {
/* multiply by 0.25 to get the correct centroid */
- /* no need to divide volume by 6 as the centroid is weighted by 6x the volume, so it all cancels out */
+ /* no need to divide volume by 6 as the centroid is weighted by 6x the volume,
+ * so it all cancels out. */
mul_v3_fl(r_cent, 0.25f / total_volume);
}
@@ -2774,9 +2826,11 @@ void BKE_mesh_loops_to_mface_corners(
/**
* Convert all CD layers from loop/poly to tessface data.
*
- * \param loopindices: is an array of an int[4] per tessface, mapping tessface's verts to loops indices.
+ * \param loopindices: is an array of an int[4] per tessface,
+ * mapping tessface's verts to loops indices.
*
- * \note when mface is not NULL, mface[face_index].v4 is used to test quads, else, loopindices[face_index][3] is used.
+ * \note when mface is not NULL, mface[face_index].v4
+ * is used to test quads, else, loopindices[face_index][3] is used.
*/
void BKE_mesh_loops_to_tessdata(CustomData *fdata,
CustomData *ldata,
@@ -2785,9 +2839,10 @@ void BKE_mesh_loops_to_tessdata(CustomData *fdata,
unsigned int (*loopindices)[4],
const int num_faces)
{
- /* Note: performances are sub-optimal when we get a NULL mface, we could be ~25% quicker with dedicated code...
- * Issue is, unless having two different functions with nearly the same code, there's not much ways to solve
- * this. Better imho to live with it for now. :/ --mont29
+ /* Note: performances are sub-optimal when we get a NULL mface,
+ * we could be ~25% quicker with dedicated code...
+ * Issue is, unless having two different functions with nearly the same code,
+ * there's not much ways to solve this. Better imho to live with it for now. :/ --mont29
*/
const int numUV = CustomData_number_of_layers(ldata, CD_MLOOPUV);
const int numCol = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
@@ -2878,9 +2933,10 @@ void BKE_mesh_tangent_loops_to_tessdata(CustomData *fdata,
const int num_faces,
const char *layer_name)
{
- /* Note: performances are sub-optimal when we get a NULL mface, we could be ~25% quicker with dedicated code...
- * Issue is, unless having two different functions with nearly the same code, there's not much ways to solve
- * this. Better imho to live with it for now. :/ --mont29
+ /* Note: performances are sub-optimal when we get a NULL mface,
+ * we could be ~25% quicker with dedicated code...
+ * Issue is, unless having two different functions with nearly the same code,
+ * there's not much ways to solve this. Better imho to live with it for now. :/ --mont29
*/
float(*ftangents)[4] = NULL;
@@ -2920,7 +2976,8 @@ void BKE_mesh_tangent_loops_to_tessdata(CustomData *fdata,
/**
* Recreate tessellation.
*
- * \param do_face_nor_copy: Controls whether the normals from the poly are copied to the tessellated faces.
+ * \param do_face_nor_copy: Controls whether the normals from the poly
+ * are copied to the tessellated faces.
*
* \return number of tessellation faces.
*/
@@ -3150,9 +3207,11 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
/* NOTE: quad detection issue - fourth vertidx vs fourth loopidx:
* Polygons take care of their loops ordering, hence not of their vertices ordering.
- * Currently, our tfaces' fourth vertex index might be 0 even for a quad. However, we know our fourth loop index is
- * never 0 for quads (because they are sorted for polygons, and our quads are still mere copies of their polygons).
- * So we pass NULL as MFace pointer, and BKE_mesh_loops_to_tessdata will use the fourth loop index as quad test.
+ * Currently, our tfaces' fourth vertex index might be 0 even for a quad. However,
+ * we know our fourth loop index is never 0 for quads (because they are sorted for polygons,
+ * and our quads are still mere copies of their polygons).
+ * So we pass NULL as MFace pointer, and BKE_mesh_loops_to_tessdata
+ * will use the fourth loop index as quad test.
* ...
*/
BKE_mesh_loops_to_tessdata(fdata, ldata, NULL, mface_to_poly_map, lindices, totface);
@@ -3451,15 +3510,17 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
BKE_mesh_update_customdata_pointers(mesh, true);
}
-/* the same as BKE_mesh_convert_mfaces_to_mpolys but oriented to be used in do_versions from readfile.c
+/**
+ * The same as #BKE_mesh_convert_mfaces_to_mpolys
+ * but oriented to be used in #do_versions from readfile.c
* the difference is how active/render/clone/stencil indices are handled here
*
* normally thay're being set from pdata which totally makes sense for meshes which are already
* converted to bmesh structures, but when loading older files indices shall be updated in other
* way around, so newly added pdata and ldata would have this indices set based on fdata layer
*
- * this is normally only needed when reading older files, in all other cases BKE_mesh_convert_mfaces_to_mpolys
- * shall be always used
+ * this is normally only needed when reading older files,
+ * in all other cases #BKE_mesh_convert_mfaces_to_mpolys shall be always used
*/
void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh)
{
@@ -3544,7 +3605,8 @@ void BKE_mesh_convert_mfaces_to_mpolys_ex(ID *id,
for (i = 0; i < totedge_i; i++, me++) {
BLI_edgehash_insert(eh, me->v1, me->v2, POINTER_FROM_UINT(i));
- /* unrelated but avoid having the FGON flag enabled, so we can reuse it later for something else */
+ /* unrelated but avoid having the FGON flag enabled,
+ * so we can reuse it later for something else */
me->flag &= ~ME_FGON;
}
@@ -3673,7 +3735,8 @@ void BKE_mesh_polygon_flip_ex(MPoly *mpoly,
/* Note that we keep same start vertex for flipped face. */
/* We also have to update loops edge
- * (they will get their original 'other edge', that is, the original edge of their original previous loop)... */
+ * (they will get their original 'other edge', that is,
+ * the original edge of their original previous loop)... */
unsigned int prev_edge_index = mloop[loopstart].e;
mloop[loopstart].e = mloop[loopend].e;
diff --git a/source/blender/blenkernel/intern/mesh_iterators.c b/source/blender/blenkernel/intern/mesh_iterators.c
index 1f8436408fb..df6517066b8 100644
--- a/source/blender/blenkernel/intern/mesh_iterators.c
+++ b/source/blender/blenkernel/intern/mesh_iterators.c
@@ -99,7 +99,8 @@ void BKE_mesh_foreach_mapped_loop(Mesh *mesh,
void *userData,
MeshForeachFlag flag)
{
- /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData, EditDerivedBMesh would
+ /* We can't use dm->getLoopDataLayout(dm) here,
+ * we want to always access dm->loopData, EditDerivedBMesh would
* return loop data from bmesh itself. */
const float(*lnors)[3] = (flag & MESH_FOREACH_USE_NORMAL) ?
CustomData_get_layer(&mesh->ldata, CD_NORMAL) :
diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c
index 69ed804a75c..40e300e6e2d 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -42,8 +42,8 @@
* \{ */
/* ngon version wip, based on BM_uv_vert_map_create */
-/* this replaces the non bmesh function (in trunk) which takes MTFace's, if we ever need it back we could
- * but for now this replaces it because its unused. */
+/* this replaces the non bmesh function (in trunk) which takes MTFace's,
+ * if we ever need it back we could but for now this replaces it because its unused. */
UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
const MLoop *mloop,
@@ -251,7 +251,8 @@ static void mesh_vert_poly_or_loop_map_create(MeshElemMap **r_map,
}
/**
- * Generates a map where the key is the vertex and the value is a list of polys that use that vertex as a corner.
+ * Generates a map where the key is the vertex and the value
+ * is a list of polys that use that vertex as a corner.
* The lists are allocated from one memory pool.
*/
void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map,
@@ -266,7 +267,8 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map,
}
/**
- * Generates a map where the key is the vertex and the value is a list of loops that use that vertex as a corner.
+ * Generates a map where the key is the vertex and the value
+ * is a list of loops that use that vertex as a corner.
* The lists are allocated from one memory pool.
*/
void BKE_mesh_vert_loop_map_create(MeshElemMap **r_map,
@@ -281,7 +283,8 @@ void BKE_mesh_vert_loop_map_create(MeshElemMap **r_map,
}
/**
- * Generates a map where the key is the edge and the value is a list of looptris that use that edge.
+ * Generates a map where the key is the edge and the value
+ * is a list of looptris that use that edge.
* The lists are allocated from one memory pool.
*/
void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map,
@@ -329,7 +332,8 @@ void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map,
}
/**
- * Generates a map where the key is the vertex and the value is a list of edges that use that vertex as an endpoint.
+ * Generates a map where the key is the vertex and the value
+ * is a list of edges that use that vertex as an endpoint.
* The lists are allocated from one memory pool.
*/
void BKE_mesh_vert_edge_map_create(
@@ -372,7 +376,8 @@ void BKE_mesh_vert_edge_map_create(
}
/**
- * A version of #BKE_mesh_vert_edge_map_create that references connected vertices directly (not their edges).
+ * A version of #BKE_mesh_vert_edge_map_create that references connected vertices directly
+ * (not their edges).
*/
void BKE_mesh_vert_edge_vert_map_create(
MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int totedge)
@@ -472,7 +477,8 @@ void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map,
}
/**
- * Generates a map where the key is the edge and the value is a list of polygons that use that edge.
+ * Generates a map where the key is the edge and the value
+ * is a list of polygons that use that edge.
* The lists are allocated from one memory pool.
*/
void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map,
@@ -739,7 +745,8 @@ static void poly_edge_loop_islands_calc(const MEdge *medge,
num_edgeborders++;
}
if (use_bitflags) {
- /* Find contiguous smooth groups already assigned, these are the values we can't reuse! */
+ /* Find contiguous smooth groups already assigned,
+ * these are the values we can't reuse! */
for (; i--; p++) {
int bit = poly_groups[*p];
if (!ELEM(bit, 0, poly_group_id, poly_group_id_overflowed) &&
@@ -751,8 +758,9 @@ static void poly_edge_loop_islands_calc(const MEdge *medge,
}
}
}
- /* And now, we have all our poly from current group in poly_stack (from 0 to (ps_end_idx - 1)), as well as
- * all smoothgroups bits we can't use in bit_poly_group_mask.
+ /* And now, we have all our poly from current group in poly_stack
+ * (from 0 to (ps_end_idx - 1)),
+ * as well as all smoothgroups bits we can't use in bit_poly_group_mask.
*/
if (use_bitflags) {
int i, *p, gid_bit = 0;
@@ -764,8 +772,9 @@ static void poly_edge_loop_islands_calc(const MEdge *medge,
}
if (UNLIKELY(gid_bit > 31)) {
/* All bits used in contiguous smooth groups, we can't do much!
- * Note: this is *very* unlikely - theoretically, four groups are enough, I don't think we can reach
- * this goal with such a simple algo, but I don't think either we'll never need all 32 groups!
+ * Note: this is *very* unlikely - theoretically, four groups are enough,
+ * I don't think we can reach this goal with such a simple algo,
+ * but I don't think either we'll never need all 32 groups!
*/
printf(
"Warning, could not find an available id for current smooth group, faces will me "
@@ -821,7 +830,8 @@ static bool poly_is_island_boundary_smooth_cb(const MPoly *mp,
const int nbr_egde_users,
void *UNUSED(user_data))
{
- /* Edge is sharp if its poly is sharp, or edge itself is sharp, or edge is not used by exactly two polygons. */
+ /* Edge is sharp if its poly is sharp, or edge itself is sharp,
+ * or edge is not used by exactly two polygons. */
return (!(mp->flag & ME_SMOOTH) || (me->flag & ME_SHARP) || (nbr_egde_users != 2));
}
@@ -829,9 +839,9 @@ static bool poly_is_island_boundary_smooth_cb(const MPoly *mp,
* Calculate smooth groups from sharp edges.
*
* \param r_totgroup: The total number of groups, 1 or more.
- * \return Polygon aligned array of group index values (bitflags if use_bitflags is true), starting at 1
- * (0 being used as 'invalid' flag).
- * Note it's callers's responsibility to MEM_freeN returned array.
+ * \return Polygon aligned array of group index values (bitflags if use_bitflags is true),
+ * starting at 1 (0 being used as 'invalid' flag).
+ * Note it's callers's responsibility to MEM_freeN returned array.
*/
int *BKE_mesh_calc_smoothgroups(const MEdge *medge,
const int totedge,
@@ -972,10 +982,11 @@ void BKE_mesh_loop_islands_add(MeshIslandStore *island_store,
sizeof(*innrcut->indices) * (size_t)num_innercut_items);
}
-/* TODO: I'm not sure edge seam flag is enough to define UV islands? Maybe we should also consider UVmaps values
+/* TODO: I'm not sure edge seam flag is enough to define UV islands?
+ * Maybe we should also consider UVmaps values
* themselves (i.e. different UV-edges for a same mesh-edge => boundary edge too?).
- * Would make things much more complex though, and each UVMap would then need its own mesh mapping,
- * not sure we want that at all!
+ * Would make things much more complex though,
+ * and each UVMap would then need its own mesh mapping, not sure we want that at all!
*/
typedef struct MeshCheckIslandBoundaryUv {
const MLoop *loops;
@@ -1052,8 +1063,9 @@ static bool mesh_calc_islands_loop_poly_uv(MVert *UNUSED(verts),
int *loop_indices;
int num_pidx, num_lidx;
- /* Those are used to detect 'inner cuts', i.e. edges that are borders, and yet have two or more polys of
- * a same group using them (typical case: seam used to unwrap properly a cylinder). */
+ /* Those are used to detect 'inner cuts', i.e. edges that are borders,
+ * and yet have two or more polys of a same group using them
+ * (typical case: seam used to unwrap properly a cylinder). */
BLI_bitmap *edge_borders = NULL;
int num_edge_borders = 0;
char *edge_border_count = NULL;
@@ -1175,7 +1187,8 @@ static bool mesh_calc_islands_loop_poly_uv(MVert *UNUSED(verts),
}
/**
- * Calculate 'generic' UV islands, i.e. based only on actual geometry data (edge seams), not some UV layers coordinates.
+ * Calculate 'generic' UV islands, i.e. based only on actual geometry data (edge seams),
+ * not some UV layers coordinates.
*/
bool BKE_mesh_calc_islands_loop_poly_edgeseam(MVert *verts,
const int totvert,
@@ -1195,12 +1208,14 @@ bool BKE_mesh_calc_islands_loop_poly_edgeseam(MVert *verts,
* Calculate UV islands.
*
* \note If no MLoopUV layer is passed, we only consider edges tagged as seams as UV boundaries.
- * This has the advantages of simplicity, and being valid/common to all UV maps.
- * However, it means actual UV islands without matching UV seams will not be handled correctly...
- * If a valid UV layer is passed as \a luvs parameter, UV coordinates are also used to detect islands boundaries.
+ * This has the advantages of simplicity, and being valid/common to all UV maps.
+ * However, it means actual UV islands without matching UV seams will not be handled correctly...
+ * If a valid UV layer is passed as \a luvs parameter,
+ * UV coordinates are also used to detect islands boundaries.
*
* \note All this could be optimized...
- * Not sure it would be worth the more complex code, though, those loops are supposed to be really quick to do...
+ * Not sure it would be worth the more complex code, though,
+ * those loops are supposed to be really quick to do...
*/
bool BKE_mesh_calc_islands_loop_poly_uvmap(MVert *verts,
const int totvert,
diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c
index 31988c7b566..71cc20c78b7 100644
--- a/source/blender/blenkernel/intern/mesh_merge.c
+++ b/source/blender/blenkernel/intern/mesh_merge.c
@@ -41,8 +41,8 @@
* Poly compare with vtargetmap
* Function used by #BKE_mesh_merge_verts.
* The function compares poly_source after applying vtargetmap, with poly_target.
- * The two polys are identical if they share the same vertices in the same order, or in reverse order,
- * but starting position loopstart may be different.
+ * The two polys are identical if they share the same vertices in the same order,
+ * or in reverse order, but starting position loopstart may be different.
* The function is called with direct_reverse=1 for same order (i.e. same normal),
* and may be called again with direct_reverse=-1 for reverse order.
* \return 1 if polys are identical, 0 if polys are different.
@@ -159,7 +159,8 @@ static int cddm_poly_compare(MLoop *mloop_array,
break;
}
- /* Adjust i_loop_target for cycling around and for direct/reverse order defined by delta = +1 or -1 */
+ /* Adjust i_loop_target for cycling around and for direct/reverse order
+ * defined by delta = +1 or -1 */
i_loop_target_adjusted = (i_loop_target_start + direct_reverse * i_loop_target_offset) %
mpoly_target->totloop;
if (i_loop_target_adjusted < 0) {
@@ -213,8 +214,8 @@ static bool poly_gset_compare_fn(const void *k1, const void *k2)
* \param vtargetmap: The table that maps vertices to target vertices. a value of -1
* indicates a vertex is a target, and is to be kept.
* This array is aligned with 'mesh->totvert'
- * \warning \a vtargetmap must **not** contain any chained mapping (v1 -> v2 -> v3 etc.), this is not supported
- * and will likely generate corrupted geometry.
+ * \warning \a vtargetmap must **not** contain any chained mapping (v1 -> v2 -> v3 etc.),
+ * this is not supported and will likely generate corrupted geometry.
*
* \param tot_vtargetmap: The number of non '-1' values in vtargetmap. (not the size)
*
@@ -230,10 +231,12 @@ static bool poly_gset_compare_fn(const void *k1, const void *k2)
* Indeed it could be that all of a poly's vertices are merged,
* but merged to vertices that do not make up a single poly,
* in which case the original poly should not be dumped.
- * Actually this later behavior could apply to the Mirror Modifier as well, but the additional checks are
- * costly and not necessary in the case of mirror, because each vertex is only merged to its own mirror.
+ * Actually this later behavior could apply to the Mirror Modifier as well,
+ * but the additional checks are costly and not necessary in the case of mirror,
+ * because each vertex is only merged to its own mirror.
*
- * \note #BKE_mesh_recalc_tessellation has to run on the returned DM if you want to access tessfaces.
+ * \note #BKE_mesh_recalc_tessellation has to run on the returned DM
+ * if you want to access tessfaces.
*/
Mesh *BKE_mesh_merge_verts(Mesh *mesh,
const int *vtargetmap,
@@ -258,9 +261,9 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
STACK_DECLARE(mvert);
STACK_DECLARE(oldv);
- /* Note: create (totedge + totloop) elements because partially invalid polys due to merge may require
- * generating new edges, and while in 99% cases we'll still end with less final edges than totedge,
- * cases can be forged that would end requiring more... */
+ /* Note: create (totedge + totloop) elements because partially invalid polys due to merge may
+ * require generating new edges, and while in 99% cases we'll still end with less final edges
+ * than totedge, cases can be forged that would end requiring more. */
MEdge *med, *medge = MEM_malloc_arrayN((totedge + totloop), sizeof(*medge), __func__);
int *olde = MEM_malloc_arrayN((totedge + totloop), sizeof(*olde), __func__);
int *newe = MEM_malloc_arrayN((totedge + totloop), sizeof(*newe), __func__);
@@ -354,7 +357,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
if (merge_mode == MESH_MERGE_VERTS_DUMP_IF_EQUAL) {
/* In this mode, we need to determine, whenever a poly' vertices are all mapped */
/* if the targets already make up a poly, in which case the new poly is dropped */
- /* This poly equality check is rather complex. We use a BLI_ghash to speed it up with a first level check */
+ /* This poly equality check is rather complex.
+ * We use a BLI_ghash to speed it up with a first level check */
PolyKey *mpgh;
poly_keys = MEM_malloc_arrayN(totpoly, sizeof(PolyKey), __func__);
poly_gset = BLI_gset_new_ex(poly_gset_hash_fn, poly_gset_compare_fn, __func__, totpoly);
@@ -484,7 +488,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
BLI_assert((mlv == v1 && next_mlv == v2) || (mlv == v2 && next_mlv == v1));
}
#endif
- /* A loop is only valid if its matching edge is, and it's not reusing a vertex already used by this poly. */
+ /* A loop is only valid if its matching edge is,
+ * and it's not reusing a vertex already used by this poly. */
if (LIKELY((newe[ml->e] != -1) && ((mv[mlv].flag & ME_VERT_TMP_TAG) == 0))) {
mv[mlv].flag |= ME_VERT_TMP_TAG;
@@ -505,7 +510,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
STACK_PUSH(medge, mesh->medge[last_valid_ml->e]);
medge[new_eidx].v1 = last_valid_ml->v;
medge[new_eidx].v2 = ml->v;
- /* DO NOT change newe mapping, could break actual values due to some deleted original edges. */
+ /* DO NOT change newe mapping,
+ * could break actual values due to some deleted original edges. */
*val_p = POINTER_FROM_INT(new_eidx);
created_edges++;
@@ -525,8 +531,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
}
c++;
- /* We absolutely HAVE to handle edge index remapping here, otherwise potential newly created edges
- * in that part of code make remapping later totally unreliable. */
+ /* We absolutely HAVE to handle edge index remapping here, otherwise potential newly
+ * created edges in that part of code make remapping later totally unreliable. */
BLI_assert(newe[ml->e] != -1);
last_valid_ml->e = newe[ml->e];
}
@@ -558,7 +564,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
STACK_PUSH(medge, mesh->medge[last_valid_ml->e]);
medge[new_eidx].v1 = last_valid_ml->v;
medge[new_eidx].v2 = first_valid_ml->v;
- /* DO NOT change newe mapping, could break actual values due to some deleted original edges. */
+ /* DO NOT change newe mapping,
+ * could break actual values due to some deleted original edges. */
*val_p = POINTER_FROM_INT(new_eidx);
created_edges++;
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index 6799c6f5c43..db158ca8fb2 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -124,9 +124,11 @@ static bool mesh_remap_bvhtree_query_raycast(BVHTreeFromMesh *treedata,
* Compute a value of the difference between both given meshes.
* The smaller the result, the better the match.
*
- * We return the inverse of the average of the inversed shortest distance from each dst vertex to src ones.
- * In other words, beyond a certain (relatively small) distance, all differences have more or less the same weight
- * in final result, which allows to reduce influence of a few high differences, in favor of a global good matching.
+ * We return the inverse of the average of the inversed
+ * shortest distance from each dst vertex to src ones.
+ * In other words, beyond a certain (relatively small) distance, all differences have more or less
+ * the same weight in final result, which allows to reduce influence of a few high differences,
+ * in favor of a global good matching.
*/
float BKE_mesh_remap_calc_difference_from_mesh(const SpaceTransform *space_transform,
const MVert *verts_dst,
@@ -164,20 +166,24 @@ float BKE_mesh_remap_calc_difference_from_mesh(const SpaceTransform *space_trans
result = ((float)numverts_dst / result) - 1.0f;
- // printf("%s: Computed difference between meshes (the lower the better): %f\n", __func__, result);
+#if 0
+ printf("%s: Computed difference between meshes (the lower the better): %f\n", __func__, result);
+#endif
return result;
}
-/* This helper computes the eigen values & vectors for covariance matrix of all given vertices coordinates.
+/* This helper computes the eigen values & vectors for
+ * covariance matrix of all given vertices coordinates.
*
* Those vectors define the 'average ellipsoid' of the mesh (i.e. the 'best fitting' ellipsoid
* containing 50% of the vertices).
*
- * Note that it will not perform fantastic in case two or more eigen values are equal (e.g. a cylinder or
- * parallelepiped with a square section give two identical eigenvalues, a sphere or tetrahedron give
- * three identical ones, etc.), since you cannot really define all axes in those cases. We default to dummy
- * generated orthogonal vectors in this case, instead of using eigen vectors.
+ * Note that it will not perform fantastic in case two or more eigen values are equal
+ * (e.g. a cylinder or parallelepiped with a square section give two identical eigenvalues,
+ * a sphere or tetrahedron give three identical ones, etc.), since you cannot really define all
+ * axes in those cases. We default to dummy generated orthogonal vectors in this case,
+ * instead of using eigen vectors.
*/
static void mesh_calc_eigen_matrix(const MVert *verts,
const float (*vcos)[3],
@@ -207,8 +213,8 @@ static void mesh_calc_eigen_matrix(const MVert *verts,
}
unit_m4(r_mat);
- /* Note: here we apply sample correction to covariance matrix, since we consider the vertices as a sample
- * of the whole 'surface' population of our mesh... */
+ /* Note: here we apply sample correction to covariance matrix, since we consider the vertices
+ * as a sample of the whole 'surface' population of our mesh. */
BLI_covariance_m3_v3n(vcos, numverts, true, covmat, center);
if (cos) {
@@ -247,8 +253,9 @@ static void mesh_calc_eigen_matrix(const MVert *verts,
float evi = eigen_val[i];
/* Protect against 1D/2D degenerated cases! */
- /* Note: not sure why we need square root of eigen values here (which are equivalent to singular values,
- * as far as I have understood), but it seems to heavily reduce (if not completely nullify)
+ /* Note: not sure why we need square root of eigen values here
+ * (which are equivalent to singular values, as far as I have understood),
+ * but it seems to heavily reduce (if not completely nullify)
* the error due to non-uniform scalings... */
evi = (evi < 1e-6f && evi > -1e-6f) ? ((evi < 0.0f) ? -1e-3f : 1e-3f) : sqrtf_signed(evi);
mul_v3_fl(eigen_vec[i], evi);
@@ -266,7 +273,8 @@ void BKE_mesh_remap_find_best_match_from_mesh(const MVert *verts_dst,
Mesh *me_src,
SpaceTransform *r_space_transform)
{
- /* Note that those are done so that we successively get actual mirror matrix (by multiplication of columns)... */
+ /* Note that those are done so that we successively get actual mirror matrix
+ * (by multiplication of columns). */
const float mirrors[][3] = {
{-1.0f, 1.0f, 1.0f}, /* -> -1, 1, 1 */
{1.0f, -1.0f, 1.0f}, /* -> -1, -1, 1 */
@@ -323,7 +331,7 @@ void BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(const int UNUSED(ver
const int UNUSED(edge_mode),
const int loop_mode,
const int UNUSED(poly_mode),
- CustomData_MeshMasks *cddata_mask)
+ CustomData_MeshMasks *r_cddata_mask)
{
/* vert, edge and poly mapping modes never need extra cddata from source object. */
const bool need_lnors_src = (loop_mode & MREMAP_USE_LOOP) && (loop_mode & MREMAP_USE_NORMAL);
@@ -331,10 +339,10 @@ void BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(const int UNUSED(ver
((loop_mode & MREMAP_USE_POLY) && (loop_mode & MREMAP_USE_NORMAL));
if (need_lnors_src) {
- cddata_mask->lmask |= CD_MASK_NORMAL;
+ r_cddata_mask->lmask |= CD_MASK_NORMAL;
}
if (need_pnors_src) {
- cddata_mask->pmask |= CD_MASK_NORMAL;
+ r_cddata_mask->pmask |= CD_MASK_NORMAL;
}
}
@@ -457,16 +465,20 @@ typedef struct IslandResult {
float hit_point[3];
} IslandResult;
-/* Note about all bvh/raycasting stuff below:
- * * We must use our ray radius as BVH epsilon too, else rays not hitting anything but 'passing near' an item
- * would be missed (since BVH handling would not detect them, 'refining' callbacks won't be executed,
- * even though they would return a valid hit).
- * * However, in 'islands' case where each hit gets a weight, 'precise' hits should have a better weight than
- * 'approximate' hits. To address that, we simplify things with:
- * ** A first raycast with default, given rayradius;
- * ** If first one fails, we do more raycasting with bigger radius, but if hit is found
- * it will get smaller weight.
- * This only concerns loops, currently (because of islands), and 'sampled' edges/polys norproj.
+/**
+ * \note About all bvh/raycasting stuff below:
+ *
+ * * We must use our ray radius as BVH epsilon too, else rays not hitting anything but
+ * 'passing near' an item would be missed (since BVH handling would not detect them,
+ * 'refining' callbacks won't be executed, even though they would return a valid hit).
+ * * However, in 'islands' case where each hit gets a weight, 'precise' hits should have a better
+ * weight than 'approximate' hits.
+ * To address that, we simplify things with:
+ * * A first raycast with default, given rayradius;
+ * * If first one fails, we do more raycasting with bigger radius, but if hit is found
+ * it will get smaller weight.
+ *
+ * This only concerns loops, currently (because of islands), and 'sampled' edges/polys norproj.
*/
/* At most n raycasts per 'real' ray. */
@@ -794,8 +806,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
}
}
- /* Now, check all source edges of closest sources vertices, and select the one giving the smallest
- * total verts-to-verts distance. */
+ /* Now, check all source edges of closest sources vertices,
+ * and select the one giving the smallest total verts-to-verts distance. */
for (j = 2; j--;) {
const unsigned int vidx_dst = j ? e_dst->v1 : e_dst->v2;
const float first_dist = v_dst_to_src_map[vidx_dst].hit_dist;
@@ -1012,8 +1024,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
w /= MREMAP_RAYCAST_APPROXIMATE_FAC;
}
}
- /* A sampling is valid (as in, its result can be considered as valid sources) only if at least
- * half of the rays found a source! */
+ /* A sampling is valid (as in, its result can be considered as valid sources)
+ * only if at least half of the rays found a source! */
if (totweights > ((float)grid_size / 2.0f)) {
for (j = 0; j < (int)numedges_src; j++) {
if (!weights[j]) {
@@ -1204,7 +1216,8 @@ static void mesh_island_to_astar_graph(MeshIslandStore *islands,
#undef POLY_COMPLETE
/* Our 'f_cost' callback func, to find shortest poly-path between two remapped-loops.
- * Note we do not want to make innercuts 'walls' here, just detect when the shortest path goes by those. */
+ * Note we do not want to make innercuts 'walls' here,
+ * just detect when the shortest path goes by those. */
static float mesh_remap_calc_loops_astar_f_cost(BLI_AStarGraph *as_graph,
BLI_AStarSolution *as_solution,
BLI_AStarGNLink *link,
@@ -1224,8 +1237,8 @@ static float mesh_remap_calc_loops_astar_f_cost(BLI_AStarGraph *as_graph,
}
/* Our heuristic part of current f_cost is distance from next node to destination one.
- * It is guaranteed to be less than (or equal to) actual shortest poly-path between next node and destination one.
- */
+ * It is guaranteed to be less than (or equal to)
+ * actual shortest poly-path between next node and destination one. */
co_next = (float *)as_graph->nodes[node_idx_next].custom_data;
co_dest = (float *)as_graph->nodes[node_idx_dst].custom_data;
return (link ? (as_solution->g_costs[node_idx_curr] + link->cost) : 0.0f) +
@@ -1601,8 +1614,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
for (pidx_dst = 0, mp_dst = polys_dst; pidx_dst < numpolys_dst; pidx_dst++, mp_dst++) {
float pnor_dst[3];
- /* Only in use_from_vert case, we may need polys' centers as fallback in case we cannot decide which
- * corner to use from normals only. */
+ /* Only in use_from_vert case, we may need polys' centers as fallback
+ * in case we cannot decide which corner to use from normals only. */
float pcent_dst[3];
bool pcent_dst_valid = false;
@@ -1763,8 +1776,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
/* Fallback to 'nearest' hit here, loops usually comes in 'face group', not good to
* have only part of one dest face's loops to map to source.
* Note that since we give this a null weight, if whole weight for a given face
- * is null, it means none of its loop mapped to this source island, hence we can skip it
- * later.
+ * is null, it means none of its loop mapped to this source island,
+ * hence we can skip it later.
*/
copy_v3_v3(tmp_co, verts_dst[ml_dst->v].co);
nearest.index = -1;
@@ -1821,12 +1834,14 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
/* We have to first select the 'best source island' for given dst poly and its loops.
* Then, we have to check that poly does not 'spread' across some island's limits
* (like inner seams for UVs, etc.).
- * Note we only still partially support that kind of situation here, i.e. polys spreading over actual cracks
- * (like a narrow space without faces on src, splitting a 'tube-like' geometry). That kind of situation
- * should be relatively rare, though.
+ * Note we only still partially support that kind of situation here, i.e.
+ * Polys spreading over actual cracks
+ * (like a narrow space without faces on src, splitting a 'tube-like' geometry).
+ * That kind of situation should be relatively rare, though.
*/
- /* XXX This block in itself is big and complex enough to be a separate function but... it uses a bunch
- * of locale vars. Not worth sending all that through parameters (for now at least). */
+ /* XXX This block in itself is big and complex enough to be a separate function but...
+ * it uses a bunch of locale vars.
+ * Not worth sending all that through parameters (for now at least). */
{
BLI_AStarGraph *as_graph = NULL;
int *poly_island_index_map = NULL;
@@ -1896,7 +1911,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
if (POINTER_AS_INT(as_solution.custom_data) && (as_solution.steps > 0)) {
/* Find first 'cutting edge' on path, and bring back lidx_src on poly just
* before that edge.
- * Note we could try to be much smarter (like e.g. storing a whole poly's indices,
+ * Note we could try to be much smarter, g.g. Storing a whole poly's indices,
* and making decision (on which side of cutting edge(s!) to be) on the end,
* but this is one more level of complexity, better to first see if
* simple solution works!
@@ -1922,7 +1937,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
ml_dst = &loops_dst[lidx_dst];
copy_v3_v3(tmp_co, verts_dst[ml_dst->v].co);
- /* We do our transform here, since we may do several raycast/nearest queries. */
+ /* We do our transform here,
+ * since we may do several raycast/nearest queries. */
if (space_transform) {
BLI_space_transform_apply(space_transform, tmp_co);
}
@@ -1952,7 +1968,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
}
else {
/* No source for this loop in this island. */
- /* TODO: would probably be better to get a source at all cost in best island anyway? */
+ /* TODO: would probably be better to get a source
+ * at all cost in best island anyway? */
mesh_remap_item_define(r_map, lidx_dst, FLT_MAX, best_island_index, 0, NULL, NULL);
}
}
@@ -1985,8 +2002,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
if (POINTER_AS_INT(as_solution.custom_data) && (as_solution.steps > 0)) {
/* Find first 'cutting edge' on path, and bring back lidx_src on poly just
* before that edge.
- * Note we could try to be much smarter (like e.g. storing a whole poly's indices,
- * and making decision (one which side of cutting edge(s!) to be on the end,
+ * Note we could try to be much smarter: e.g. Storing a whole poly's indices,
+ * and making decision (one which side of cutting edge(s)!) to be on the end,
* but this is one more level of complexity, better to first see if
* simple solution works!
*/
@@ -2012,7 +2029,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
ml_dst = &loops_dst[lidx_dst];
copy_v3_v3(tmp_co, verts_dst[ml_dst->v].co);
- /* We do our transform here, since we may do several raycast/nearest queries. */
+ /* We do our transform here,
+ * since we may do several raycast/nearest queries. */
if (space_transform) {
BLI_space_transform_apply(space_transform, tmp_co);
}
@@ -2100,7 +2118,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
}
else {
/* No source for this loop in this island. */
- /* TODO: would probably be better to get a source at all cost in best island anyway? */
+ /* TODO: would probably be better to get a source
+ * at all cost in best island anyway? */
mesh_remap_item_define(r_map, lidx_dst, FLT_MAX, best_island_index, 0, NULL, NULL);
}
}
@@ -2283,7 +2302,8 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
}
}
else if (mode == MREMAP_MODE_POLY_POLYINTERP_PNORPROJ) {
- /* We cast our rays randomly, with a pseudo-even distribution (since we spread across tessellated tris,
+ /* We cast our rays randomly, with a pseudo-even distribution
+ * (since we spread across tessellated tris,
* with additional weighting based on each tri's relative area).
*/
RNG *rng = BLI_rng_new(0);
@@ -2399,8 +2419,8 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
float *v3 = poly_vcos_2d[tri_vidx_2d[j][2]];
int rays_num;
- /* All this allows us to get 'absolute' number of rays for each tri, avoiding accumulating
- * errors over iterations, and helping better even distribution. */
+ /* All this allows us to get 'absolute' number of rays for each tri,
+ * avoiding accumulating errors over iterations, and helping better even distribution. */
done_area += area_tri_v2(v1, v2, v3);
rays_num = max_ii(
(int)((float)tot_rays * done_area * poly_area_2d_inv + 0.5f) - done_rays, 0);
diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c
index c82126c39d0..06abd80b86f 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.c
+++ b/source/blender/blenkernel/intern/mesh_runtime.c
@@ -78,7 +78,8 @@ void BKE_mesh_runtime_clear_cache(Mesh *mesh)
/**
* Ensure the array is large enough
*
- * \note This function must always be thread-protected by caller. It should only be used by internal code.
+ * \note This function must always be thread-protected by caller.
+ * It should only be used by internal code.
*/
static void mesh_ensure_looptri_data(Mesh *mesh)
{
@@ -149,8 +150,8 @@ const MLoopTri *BKE_mesh_runtime_looptri_ensure(Mesh *mesh)
}
else {
BLI_rw_mutex_lock(&loops_cache_lock, THREAD_LOCK_WRITE);
- /* We need to ensure array is still NULL inside mutex-protected code, some other thread might have already
- * recomputed those looptris. */
+ /* We need to ensure array is still NULL inside mutex-protected code,
+ * some other thread might have already recomputed those looptris. */
if (mesh->runtime.looptris.array == NULL) {
BKE_mesh_runtime_looptri_recalc(mesh);
}
diff --git a/source/blender/blenkernel/intern/mesh_tangent.c b/source/blender/blenkernel/intern/mesh_tangent.c
index d6d39ca0f1d..19d94be9b6e 100644
--- a/source/blender/blenkernel/intern/mesh_tangent.c
+++ b/source/blender/blenkernel/intern/mesh_tangent.c
@@ -116,7 +116,8 @@ static void set_tspace(const SMikkTSpaceContext *pContext,
}
/**
- * Compute simplified tangent space normals, i.e. tangent vector + sign of bi-tangent one, which combined with
+ * Compute simplified tangent space normals, i.e.
+ * tangent vector + sign of bi-tangent one, which combined with
* split normals can be used to recreate the full tangent space.
* Note: * The mesh should be made of only tris and quads!
*/
@@ -284,7 +285,7 @@ static void dm_ts_GetPosition(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = pContext->m_pUserData;
const MLoopTri *lt;
uint loop_index;
@@ -318,7 +319,7 @@ static void dm_ts_GetTextureCoordinate(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = pContext->m_pUserData;
const MLoopTri *lt;
uint loop_index;
@@ -357,7 +358,7 @@ static void dm_ts_GetNormal(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *)pContext->m_pUserData;
const MLoopTri *lt;
uint loop_index;
@@ -420,7 +421,7 @@ static void dm_ts_SetTSpace(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *)pContext->m_pUserData;
const MLoopTri *lt;
uint loop_index;
@@ -487,7 +488,8 @@ void BKE_mesh_add_loop_tangent_named_layer_for_uv(CustomData *uv_data,
}
/**
- * Here we get some useful information such as active uv layer name and search if it is already in tangent_names.
+ * Here we get some useful information such as active uv layer name and
+ * search if it is already in tangent_names.
* Also, we calculate tangent_mask that works as a descriptor of tangents state.
* If tangent_mask has changed, then recalculate tangents.
*/
@@ -677,9 +679,8 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
mesh2tangent->mpoly = mpoly;
mesh2tangent->mloop = mloop;
mesh2tangent->looptri = looptri;
- /* Note, we assume we do have tessellated loop normals at this point (in case it is object-enabled),
- * have to check this is valid...
- */
+ /* Note, we assume we do have tessellated loop normals at this point
+ * (in case it is object-enabled), have to check this is valid. */
mesh2tangent->precomputedLoopNormals = loop_normals;
mesh2tangent->precomputedFaceNormals = poly_normals;
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index e2515665728..dac12233539 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -573,8 +573,9 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
sp->numverts = mp->totloop;
sp->loopstart = mp->loopstart;
- /* Ideally we would only have to do that once on all vertices before we start checking each poly, but
- * several polys can use same vert, so we have to ensure here all verts of current poly are cleared. */
+ /* Ideally we would only have to do that once on all vertices
+ * before we start checking each poly, but several polys can use same vert,
+ * so we have to ensure here all verts of current poly are cleared. */
for (j = 0, ml = &mloops[sp->loopstart]; j < mp->totloop; j++, ml++) {
if (ml->v < totvert) {
mverts[ml->v].flag &= ~ME_VERT_TMP_TAG;
@@ -638,7 +639,8 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
if (IS_REMOVED_EDGE(me) ||
!((me->v1 == v1 && me->v2 == v2) || (me->v1 == v2 && me->v2 == v1))) {
/* The pointed edge is invalid (tagged as removed, or vert idx mismatch),
- * and we already know from previous test that a valid one exists, use it (if allowed)! */
+ * and we already know from previous test that a valid one exists,
+ * use it (if allowed)! */
if (do_fixes) {
int prev_e = ml->e;
ml->e = POINTER_AS_INT(BLI_edgehash_lookup(edge_hash, v1, v2));
@@ -676,7 +678,8 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
const int *p1_v = sp->verts, *p2_v = prev_sp->verts;
if (sp->invalid) {
- /* break, because all known invalid polys have been put at the end by qsort with search_poly_cmp. */
+ /* Break, because all known invalid polys have been put at the end
+ * by qsort with search_poly_cmp. */
break;
}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index b244a69ec09..9bc9865631f 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -36,6 +36,7 @@
#include "DNA_armature_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
@@ -501,7 +502,8 @@ bool modifiers_isParticleEnabled(Object *ob)
/**
* Check whether is enabled.
*
- * \param scene: Current scene, may be NULL, in which case isDisabled callback of the modifier is never called.
+ * \param scene: Current scene, may be NULL,
+ * in which case isDisabled callback of the modifier is never called.
*/
bool modifier_isEnabled(const struct Scene *scene, ModifierData *md, int required_mode)
{
@@ -656,7 +658,7 @@ Object *modifiers_isDeformedByArmature(Object *ob)
for (; md; md = md->next) {
if (md->type == eModifierType_Armature) {
amd = (ArmatureModifierData *)md;
- if (amd->object && (amd->object->flag & SELECT)) {
+ if (amd->object && (amd->object->base_flag & BASE_SELECTED)) {
return amd->object;
}
}
@@ -679,7 +681,7 @@ Object *modifiers_isDeformedByMeshDeform(Object *ob)
for (; md; md = md->next) {
if (md->type == eModifierType_MeshDeform) {
mdmd = (MeshDeformModifierData *)md;
- if (mdmd->object && (mdmd->object->flag & SELECT)) {
+ if (mdmd->object && (mdmd->object->base_flag & BASE_SELECTED)) {
return mdmd->object;
}
}
@@ -705,7 +707,7 @@ Object *modifiers_isDeformedByLattice(Object *ob)
for (; md; md = md->next) {
if (md->type == eModifierType_Lattice) {
lmd = (LatticeModifierData *)md;
- if (lmd->object && (lmd->object->flag & SELECT)) {
+ if (lmd->object && (lmd->object->base_flag & BASE_SELECTED)) {
return lmd->object;
}
}
@@ -731,7 +733,7 @@ Object *modifiers_isDeformedByCurve(Object *ob)
for (; md; md = md->next) {
if (md->type == eModifierType_Curve) {
cmd = (CurveModifierData *)md;
- if (cmd->object && (cmd->object->flag & SELECT)) {
+ if (cmd->object && (cmd->object->base_flag & BASE_SELECTED)) {
return cmd->object;
}
}
@@ -929,7 +931,8 @@ void modwrap_deformVertsEM(ModifierData *md,
/**
* Get evaluated mesh for other evaluated object, which is used as an operand for the modifier,
* e.g. second operand for boolean modifier.
- * Note that 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.
*
* \param get_cage_mesh Return evaluated mesh with only deforming modifiers applied
* (i.e. mesh topology remains the same as original one, a.k.a. 'cage' mesh).
@@ -942,8 +945,8 @@ Mesh *BKE_modifier_get_evaluated_mesh_from_evaluated_object(Object *ob_eval,
if ((ob_eval->type == OB_MESH) && (ob_eval->mode & OB_MODE_EDIT)) {
/* In EditMode, evaluated mesh is stored in BMEditMesh, not the object... */
BMEditMesh *em = BKE_editmesh_from_object(ob_eval);
- if (em !=
- NULL) { /* em might not exist yet in some cases, just after loading a .blend file, see T57878. */
+ /* 'em' might not exist yet in some cases, just after loading a .blend file, see T57878. */
+ if (em != NULL) {
me = (get_cage_mesh && em->mesh_eval_cage != NULL) ? em->mesh_eval_cage :
em->mesh_eval_final;
}
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 1a61fa2c537..8d149af6a1f 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -1619,8 +1619,10 @@ void BKE_movieclip_free(MovieClip *clip)
}
/**
- * Only copy internal data of MovieClip ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of MovieClip ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 6af92422b30..e3953af7cbf 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -1712,7 +1712,8 @@ void multires_free(Multires *mr)
lvl = lvl->next;
}
- /* mr->verts may be NULL when loading old files, see direct_link_mesh() in readfile.c, and T43560. */
+ /* mr->verts may be NULL when loading old files,
+ * see direct_link_mesh() in readfile.c, and T43560. */
MEM_SAFE_FREE(mr->verts);
BLI_freelistN(&mr->levels);
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 6953339f287..15e53e12ece 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -90,7 +90,7 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user)
}
/* free remapping info */
- //if (strip->remap)
+ // if (strip->remap)
// BKE_animremap_free();
/* free own F-Curves */
@@ -163,7 +163,8 @@ void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user)
* Copy NLA strip
*
* \param use_same_action: When true, the existing action is used (instead of being duplicated)
- * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
+ * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_...
+ * flags in BKE_library.h
*/
NlaStrip *BKE_nlastrip_copy(Main *bmain,
NlaStrip *strip,
@@ -216,7 +217,8 @@ NlaStrip *BKE_nlastrip_copy(Main *bmain,
/**
* Copy a single NLA Track.
- * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
+ * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_...
+ * flags in BKE_library.h
*/
NlaTrack *BKE_nlatrack_copy(Main *bmain,
NlaTrack *nlt,
@@ -249,7 +251,8 @@ NlaTrack *BKE_nlatrack_copy(Main *bmain,
/**
* Copy all NLA data.
- * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
+ * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_...
+ * flags in BKE_library.h
*/
void BKE_nla_tracks_copy(Main *bmain, ListBase *dst, ListBase *src, const int flag)
{
@@ -354,7 +357,8 @@ NlaStrip *BKE_nlastrip_new(bAction *act)
return strip;
}
-/* Add new NLA-strip to the top of the NLA stack - i.e. into the last track if space, or a new one otherwise */
+/* Add new NLA-strip to the top of the NLA stack - i.e.
+ * into the last track if space, or a new one otherwise. */
NlaStrip *BKE_nlastack_add_strip(AnimData *adt, bAction *act)
{
NlaStrip *strip;
@@ -467,10 +471,9 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short
}
else { /* if (mode == NLATIME_CONVERT_EVAL) */
if (IS_EQF((float)cframe, strip->end) && IS_EQF(strip->repeat, floorf(strip->repeat))) {
- /* this case prevents the motion snapping back to the first frame at the end of the strip
- * by catching the case where repeats is a whole number, which means that the end of the strip
- * could also be interpreted as the end of the start of a repeat
- */
+ /* This case prevents the motion snapping back to the first frame at the end of the strip
+ * by catching the case where repeats is a whole number, which means that the end of the
+ * strip could also be interpreted as the end of the start of a repeat. */
return strip->actstart;
}
else {
@@ -490,10 +493,9 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short
}
else { /* if (mode == NLATIME_CONVERT_EVAL) */
if (IS_EQF(cframe, strip->end) && IS_EQF(strip->repeat, floorf(strip->repeat))) {
- /* this case prevents the motion snapping back to the first frame at the end of the strip
- * by catching the case where repeats is a whole number, which means that the end of the strip
- * could also be interpreted as the end of the start of a repeat
- */
+ /* This case prevents the motion snapping back to the first frame at the end of the strip
+ * by catching the case where repeats is a whole number, which means that the end of the
+ * strip could also be interpreted as the end of the start of a repeat. */
return strip->actend;
}
else {
@@ -544,7 +546,8 @@ static float nlastrip_get_frame_transition(NlaStrip *strip, float cframe, short
float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode)
{
switch (strip->type) {
- case NLASTRIP_TYPE_META: /* meta - for now, does the same as transition (is really just an empty container) */
+ case NLASTRIP_TYPE_META: /* Meta - for now, does the same as transition
+ * (is really just an empty container). */
case NLASTRIP_TYPE_TRANSITION: /* transition */
return nlastrip_get_frame_transition(strip, cframe, mode);
@@ -589,10 +592,10 @@ float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode)
}
strip = adt->actstrip;
- /* sanity checks
- * - in rare cases, we may not be able to find this strip for some reason (internal error)
- * - for now, if the user has defined a curve to control the time, this correction cannot be performed
- * reliably...
+ /* Sanity checks:
+ * - In rare cases, we may not be able to find this strip for some reason (internal error)
+ * - For now, if the user has defined a curve to control the time, this correction cannot be
+ * performed reliably.
*/
if ((strip == NULL) || (strip->flag & NLASTRIP_FLAG_USR_TIME)) {
return cframe;
@@ -943,7 +946,8 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
p1 = (strip->start - oStart) / oLen;
p2 = (strip->end - oStart) / oLen;
- /* apply new strip endpoints using the proportions, then wait for second pass to flush scale properly */
+ /* Apply new strip endpoints using the proportions,
+ * then wait for second pass to flush scale properly. */
strip->start = (p1 * nLen) + mstrip->start;
strip->end = (p2 * nLen) + mstrip->start;
}
@@ -1252,7 +1256,8 @@ bool BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max)
return true;
}
-/* Ensure that strip doesn't overlap those around it after resizing by offsetting those which follow */
+/* Ensure that strip doesn't overlap those around it after resizing
+ * by offsetting those which follow. */
static void nlastrip_fix_resize_overlaps(NlaStrip *strip)
{
/* next strips - do this first, since we're often just getting longer */
@@ -1613,13 +1618,15 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
continue;
}
- /* use the name of the strip as the key, and the strip as the value, since we're mostly interested in the keys */
+ /* Use the name of the strip as the key, and the strip as the value,
+ * since we're mostly interested in the keys. */
BLI_ghash_insert(gh, tstrip->name, tstrip);
}
}
- /* if the hash-table has a match for this name, try other names...
- * - in an extreme case, it might not be able to find a name, but then everything else in Blender would fail too :)
+ /* If the hash-table has a match for this name, try other names...
+ * - In an extreme case, it might not be able to find a name,
+ * but then everything else in Blender would fail too :).
*/
BLI_uniquename_cb(nla_editbone_name_check,
(void *)gh,
@@ -1651,7 +1658,8 @@ static void nlastrip_get_endpoint_overlaps(NlaStrip *strip,
*/
/* TODO: this scheme could get quite slow for doing this on many strips... */
for (nls = track->strips.first; nls; nls = nls->next) {
- /* check if strip overlaps (extends over or exactly on) the entire range of the strip we're validating */
+ /* Check if strip overlaps (extends over or exactly on)
+ * the entire range of the strip we're validating. */
if ((nls->start <= strip->start) && (nls->end >= strip->end)) {
*start = NULL;
*end = NULL;
@@ -1750,7 +1758,8 @@ void BKE_nla_validate_state(AnimData *adt)
return;
}
- /* adjust blending values for auto-blending, and also do an initial pass to find the earliest strip */
+ /* Adjust blending values for auto-blending,
+ * and also do an initial pass to find the earliest strip. */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* auto-blending first */
@@ -1849,7 +1858,8 @@ bool BKE_nla_action_stash(AnimData *adt)
nlt = BKE_nlatrack_add(adt, prev_track);
BLI_assert(nlt != NULL);
- /* we need to ensure that if there wasn't any previous instance, it must go to tbe bottom of the stack */
+ /* We need to ensure that if there wasn't any previous instance,
+ * it must go to tbe bottom of the stack. */
if (prev_track == NULL) {
BLI_remlink(&adt->nla_tracks, nlt);
BLI_addhead(&adt->nla_tracks, nlt);
@@ -1955,9 +1965,9 @@ void BKE_nla_action_pushdown(AnimData *adt)
* mode accordingly
*/
if (nlastrip_is_first(adt, strip) == 0) {
- /* not first, so extend mode can only be NLASTRIP_EXTEND_HOLD_FORWARD not NLASTRIP_EXTEND_HOLD,
- * so that it doesn't override strips in previous tracks
- */
+ /* Not first, so extend mode can only be:
+ * NLASTRIP_EXTEND_HOLD_FORWARD not NLASTRIP_EXTEND_HOLD,
+ * so that it doesn't override strips in previous tracks. */
/* FIXME: this needs to be more automated, since user can rearrange strips */
if (strip->extendmode == NLASTRIP_EXTEND_HOLD) {
strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD;
@@ -2004,9 +2014,10 @@ bool BKE_nla_tweakmode_enter(AnimData *adt)
}
}
- /* There are situations where we may have multiple strips selected and we want to enter tweakmode on all
- * of those at once. Usually in those cases, it will usually just be a single strip per AnimData.
- * In such cases, compromise and take the last selected track and/or last selected strip [#28468]
+ /* There are situations where we may have multiple strips selected and we want to enter tweakmode
+ * on all of those at once. Usually in those cases,
+ * it will usually just be a single strip per AnimData.
+ * In such cases, compromise and take the last selected track and/or last selected strip, T28468.
*/
if (activeTrack == NULL) {
/* try last selected track for active strip */
@@ -2022,7 +2033,8 @@ bool BKE_nla_tweakmode_enter(AnimData *adt)
}
}
if ((activeTrack) && (activeStrip == NULL)) {
- /* no active strip in active or last selected track; compromise for first selected (assuming only single)... */
+ /* No active strip in active or last selected track;
+ * compromise for first selected (assuming only single). */
for (strip = activeTrack->strips.first; strip; strip = strip->next) {
if (strip->flag & (NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE)) {
activeStrip = strip;
@@ -2071,10 +2083,12 @@ bool BKE_nla_tweakmode_enter(AnimData *adt)
}
/* handle AnimData level changes:
- * - 'real' active action to temp storage (no need to change user-counts)
- * - action of active strip set to be the 'active action', and have its usercount incremented
- * - editing-flag for this AnimData block should also get turned on (for more efficient restoring)
- * - take note of the active strip for mapping-correction of keyframes in the action being edited
+ * - 'real' active action to temp storage (no need to change user-counts).
+ * - Action of active strip set to be the 'active action', and have its usercount incremented.
+ * - Editing-flag for this AnimData block should also get turned on
+ * (for more efficient restoring).
+ * - Take note of the active strip for mapping-correction of keyframes
+ * in the action being edited.
*/
adt->tmpact = adt->action;
adt->action = activeStrip->act;
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 8a3f973ae5f..3adb6cfe960 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -126,8 +126,9 @@ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
/* initialize the node name with the node label.
* note: do this after the initfunc so nodes get their data set which may be used in naming
* (node groups for example) */
- /* XXX Do not use nodeLabel() here, it returns translated content for UI, which should *only* be used
- * in UI, *never* in data... Data have their own translation option!
+ /* XXX Do not use nodeLabel() here, it returns translated content for UI,
+ * which should *only* be used in UI, *never* in data...
+ * Data have their own translation option!
* This solution may be a bit rougher than nodeLabel()'s returned string, but it's simpler
* than adding "do_translate" flags to this func (and labelfunc() as well). */
BLI_strncpy(node->name, DATA_(ntype->ui_name), NODE_MAXSTR);
@@ -284,7 +285,8 @@ static void update_typeinfo(Main *bmain,
}
/* Try to initialize all typeinfo in a node tree.
- * NB: In general undefined typeinfo is a perfectly valid case, the type may just be registered later.
+ * NB: In general undefined typeinfo is a perfectly valid case,
+ * the type may just be registered later.
* In that case the update_typeinfo function will set typeinfo on registration
* and do necessary updates.
*/
@@ -339,8 +341,8 @@ void ntreeTypeAdd(bNodeTreeType *nt)
{
BLI_ghash_insert(nodetreetypes_hash, nt->idname, nt);
/* XXX pass Main to register function? */
- /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
- * active Mains, which we cannot do anyway currently. */
+ /* Probably not. It is pretty much expected we want to update G_MAIN here I think -
+ * or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, NULL, nt, NULL, NULL, false);
}
@@ -349,8 +351,8 @@ static void ntree_free_type(void *treetype_v)
{
bNodeTreeType *treetype = treetype_v;
/* XXX pass Main to unregister function? */
- /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
- * active Mains, which we cannot do anyway currently. */
+ /* Probably not. It is pretty much expected we want to update G_MAIN here I think -
+ * or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, NULL, treetype, NULL, NULL, true);
MEM_freeN(treetype);
}
@@ -401,8 +403,8 @@ static void node_free_type(void *nodetype_v)
{
bNodeType *nodetype = nodetype_v;
/* XXX pass Main to unregister function? */
- /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
- * active Mains, which we cannot do anyway currently. */
+ /* Probably not. It is pretty much expected we want to update G_MAIN here I think -
+ * or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, NULL, NULL, nodetype, NULL, true);
/* XXX deprecated */
@@ -423,8 +425,8 @@ void nodeRegisterType(bNodeType *nt)
BLI_ghash_insert(nodetypes_hash, nt->idname, nt);
/* XXX pass Main to register function? */
- /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
- * active Mains, which we cannot do anyway currently. */
+ /* Probably not. It is pretty much expected we want to update G_MAIN here I think -
+ * or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, NULL, NULL, nt, NULL, false);
}
@@ -462,8 +464,8 @@ static void node_free_socket_type(void *socktype_v)
{
bNodeSocketType *socktype = socktype_v;
/* XXX pass Main to unregister function? */
- /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
- * active Mains, which we cannot do anyway currently. */
+ /* Probably not. It is pretty much expected we want to update G_MAIN here I think -
+ * or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, NULL, NULL, NULL, socktype, true);
MEM_freeN(socktype);
@@ -473,8 +475,8 @@ void nodeRegisterSocketType(bNodeSocketType *st)
{
BLI_ghash_insert(nodesockettypes_hash, (void *)st->idname, st);
/* XXX pass Main to register function? */
- /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
- * active Mains, which we cannot do anyway currently. */
+ /* Probably not. It is pretty much expected we want to update G_MAIN here I think -
+ * or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, NULL, NULL, NULL, st, false);
}
@@ -931,7 +933,8 @@ void nodeChainIter(const bNodeTree *ntree,
continue;
}
if (link->tonode && link->fromnode) {
- /* is the link part of the chain meaning node_start == fromnode (or tonode for reversed case)? */
+ /* Is the link part of the chain meaning node_start == fromnode
+ * (or tonode for reversed case)? */
if ((reversed && (link->tonode == node_start)) ||
(!reversed && link->fromnode == node_start)) {
if (!callback(link->fromnode, link->tonode, userdata, reversed)) {
@@ -945,7 +948,8 @@ void nodeChainIter(const bNodeTree *ntree,
}
/**
- * Iterate over all parents of \a node, executing \a callback for each parent (which can return false to end iterator)
+ * Iterate over all parents of \a node, executing \a callback for each parent
+ * (which can return false to end iterator)
*
* \note Recursive
*/
@@ -1370,8 +1374,10 @@ bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname)
}
/**
- * Only copy internal data of NodeTree ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of NodeTree ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -1716,7 +1722,8 @@ void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, boo
BKE_node_instance_hash_insert(to_ntree->previews, key, preview);
}
- /* Note: NULL free function here, because pointers have already been moved over to to_ntree->previews! */
+ /* Note: NULL free function here,
+ * because pointers have already been moved over to to_ntree->previews! */
BKE_node_instance_hash_free(from_ntree->previews, NULL);
from_ntree->previews = NULL;
}
@@ -1741,9 +1748,9 @@ void BKE_node_preview_set_pixel(
rgba_float_to_uchar(tar, col);
}
}
- //else printf("prv out bound x y %d %d\n", x, y);
+ // else printf("prv out bound x y %d %d\n", x, y);
}
- //else printf("prv out bound x y %d %d\n", x, y);
+ // else printf("prv out bound x y %d %d\n", x, y);
}
}
@@ -2269,25 +2276,6 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
else {
BLI_snprintf(sock->identifier, MAX_NAME, "Output_%d", own_index);
}
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* XXX forward compatibility:
- * own_index is deprecated, but needs to be set here.
- * Node sockets generally use the identifier string instead now,
- * but reconstructing own_index in writefile.c would require parsing the identifier string.
- */
-
-# if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) || defined(__clang__)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-# endif
-
- sock->own_index = own_index;
-
-# if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) || defined(__clang__)
-# pragma GCC diagnostic pop
-# endif
-
-#endif /* USE_NODE_COMPAT_CUSTOMNODES */
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
@@ -3225,16 +3213,44 @@ static void ntree_validate_links(bNodeTree *ntree)
}
}
-void ntreeVerifyNodes(struct Main *main, struct ID *id)
+void ntreeUpdateAllNew(Main *main)
{
+ /* Update all new node trees on file read or append, to add/remove sockets
+ * in groups nodes if the group changed, and handle any update flags that
+ * might have been set in file reading or versioning. */
FOREACH_NODETREE_BEGIN (main, ntree, owner_id) {
- bNode *node;
+ if (owner_id->tag & LIB_TAG_NEW) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->typeinfo->group_update_func) {
+ node->typeinfo->group_update_func(ntree, node);
+ }
+ }
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->typeinfo->verifyfunc) {
- node->typeinfo->verifyfunc(ntree, node, id);
+ ntreeUpdateTree(NULL, ntree);
+ }
+ }
+ FOREACH_NODETREE_END;
+}
+
+void ntreeUpdateAllUsers(Main *main, ID *ngroup)
+{
+ /* Update all users of ngroup, to add/remove sockets as needed. */
+ FOREACH_NODETREE_BEGIN (main, ntree, owner_id) {
+ bool need_update = false;
+
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->id == ngroup) {
+ if (node->typeinfo->group_update_func) {
+ node->typeinfo->group_update_func(ntree, node);
+ }
+
+ need_update = true;
}
}
+
+ if (need_update) {
+ ntreeUpdateTree(NULL, ntree);
+ }
}
FOREACH_NODETREE_END;
}
@@ -3283,7 +3299,7 @@ void ntreeUpdateTree(Main *bmain, bNodeTree *ntree)
/* XXX hack, should be done by depsgraph!! */
if (bmain) {
- ntreeVerifyNodes(bmain, &ntree->id);
+ ntreeUpdateAllUsers(bmain, &ntree->id);
}
if (ntree->update & (NTREE_UPDATE_LINKS | NTREE_UPDATE_NODES)) {
@@ -3600,13 +3616,15 @@ void node_type_label(
}
void node_type_update(struct bNodeType *ntype,
- void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node),
- void (*verifyfunc)(struct bNodeTree *ntree,
- struct bNode *node,
- struct ID *id))
+ void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node))
{
ntype->updatefunc = updatefunc;
- ntype->verifyfunc = verifyfunc;
+}
+
+void node_type_group_update(struct bNodeType *ntype,
+ void (*group_update_func)(struct bNodeTree *ntree, struct bNode *node))
+{
+ ntype->group_update_func = group_update_func;
}
void node_type_exec(struct bNodeType *ntype,
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index a623baf7b71..38a8ad2769a 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -223,7 +223,8 @@ void BKE_object_modifier_hook_reset(Object *ob, HookModifierData *hmd)
if (hmd->subtarget[0] && pchan) {
float imat[4][4], mat[4][4];
- /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */
+ /* Calculate the world-space matrix for the pose-channel target first,
+ * then carry on as usual. */
mul_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat);
invert_m4_m4(imat, mat);
@@ -247,7 +248,8 @@ void BKE_object_modifier_gpencil_hook_reset(Object *ob, HookGpencilModifierData
if (hmd->subtarget[0] && pchan) {
float imat[4][4], mat[4][4];
- /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */
+ /* Calculate the world-space matrix for the pose-channel target first,
+ * then carry on as usual. */
mul_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat);
invert_m4_m4(imat, mat);
@@ -1159,7 +1161,8 @@ static void copy_object_pose(Object *obn, const Object *ob, const int flag)
chan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE);
- /* XXX Remapping object pointing onto itself should be handled by generic BKE_library_remap stuff, but...
+ /* XXX Remapping object pointing onto itself should be handled by generic
+ * BKE_library_remap stuff, but...
* the flush_constraint_targets callback am not sure about, so will delay that for now. */
for (con = chan->constraints.first; con; con = con->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
@@ -1334,8 +1337,10 @@ void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src)
}
/**
- * Only copy internal data of Object ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Object ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -1438,7 +1443,8 @@ void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, con
copy_object_lod(ob_dst, ob_src, flag_subdata);
- /* Do not copy object's preview (mostly due to the fact renderers create temp copy of objects). */
+ /* Do not copy object's preview
+ * (mostly due to the fact renderers create temp copy of objects). */
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { /* XXX TODO temp hack */
BKE_previewimg_id_copy(&ob_dst->id, &ob_src->id);
}
@@ -1461,11 +1467,13 @@ Object *BKE_object_copy(Main *bmain, const Object *ob)
/** Perform deep-copy of object and its 'children' data-blocks (obdata, materials, actions, etc.).
*
- * \param dupflag Controls which sub-data are also duplicated (see #eDupli_ID_Flags in DNA_userdef_types.h).
+ * \param dupflag Controls which sub-data are also duplicated
+ * (see #eDupli_ID_Flags in DNA_userdef_types.h).
*
- * \note This function does not do any remapping to new IDs, caller must do it (\a #BKE_libblock_relink_to_newid()).
- * \note Caller MUST free \a newid pointers itself (#BKE_main_id_clear_newpoins()) and call updates of DEG too
- * (#DAG_relations_tag_update()).
+ * \note This function does not do any remapping to new IDs, caller must do it
+ * (\a #BKE_libblock_relink_to_newid()).
+ * \note Caller MUST free \a newid pointers itself (#BKE_main_id_clear_newpoins()) and call updates
+ * of DEG too (#DAG_relations_tag_update()).
*/
Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag)
{
@@ -1643,7 +1651,7 @@ Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag)
}
break;
case OB_LIGHTPROBE:
- if (dupflag != 0) {
+ if (dupflag & USER_DUP_LIGHTPROBE) {
ID_NEW_REMAP_US2(obn->data)
else
{
@@ -1665,7 +1673,7 @@ Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag)
}
break;
case OB_GPENCIL:
- if (dupflag != 0) {
+ if (dupflag & USER_DUP_GPENCIL) {
ID_NEW_REMAP_US2(obn->data)
else
{
@@ -1731,7 +1739,8 @@ void BKE_object_make_local_ex(Main *bmain,
/* - only lib users: do nothing (unless force_local is set)
* - only local users: set flag
* - mixed: make copy
- * In case we make a whole lib's content local, we always want to localize, and we skip remapping (done later).
+ * In case we make a whole lib's content local,
+ * we always want to localize, and we skip remapping (done later).
*/
if (!ID_IS_LINKED(ob)) {
@@ -1844,10 +1853,12 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
}
}
-/* proxy rule: lib_object->proxy_from == the one we borrow from, set temporally while object_update */
-/* local_object->proxy == pointer to library object, saved in files and read */
-/* local_object->proxy_group == pointer to collection dupli-object, saved in files and read */
-
+/**
+ * Proxy rule:
+ * - lib_object->proxy_from == the one we borrow from, set temporally while object_update.
+ * - local_object->proxy == pointer to library object, saved in files and read.
+ * - local_object->proxy_group == pointer to collection dupli-object, saved in files and read.
+ */
void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob)
{
/* paranoia checks */
@@ -2005,7 +2016,7 @@ void BKE_object_scale_to_mat3(Object *ob, float mat[3][3])
size_to_mat3(mat, vec);
}
-void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], bool use_drot)
+void BKE_object_rot_to_mat3(const Object *ob, float mat[3][3], bool use_drot)
{
float rmat[3][3], dmat[3][3];
@@ -2015,7 +2026,8 @@ void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], bool use_drot)
/* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
if (ob->rotmode > 0) {
- /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
+ /* Euler rotations
+ * (will cause gimble lock, but this can be alleviated a bit with rotation orders). */
eulO_to_mat3(rmat, ob->rot, ob->rotmode);
eulO_to_mat3(dmat, ob->drot, ob->rotmode);
}
@@ -2242,11 +2254,11 @@ static bool ob_parcurve(Object *ob, Object *par, float mat[4][4])
return false;
}
- /* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
- * but this will only work if it actually is animated...
+ /* ctime is now a proper var setting of Curve which gets set by Animato like any other var
+ * that's animated, but this will only work if it actually is animated.
*
- * we divide the curvetime calculated in the previous step by the length of the path, to get a time
- * factor, which then gets clamped to lie within 0.0 - 1.0 range
+ * We divide the curvetime calculated in the previous step by the length of the path,
+ * to get a time factor, which then gets clamped to lie within 0.0 - 1.0 range.
*/
if (cu->pathlen) {
ctime = cu->ctime / cu->pathlen;
@@ -2491,7 +2503,8 @@ void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4]
}
/**
- * \param r_originmat: Optional matrix that stores the space the object is in (without its own matrix applied)
+ * \param r_originmat: Optional matrix that stores the space the object is in
+ * (without its own matrix applied)
*/
static void solve_parenting(
Object *ob, Object *par, float obmat[4][4], float r_originmat[3][3], const bool set_origin)
@@ -2614,7 +2627,8 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *o
unit_m4(workob->parentinv);
unit_m4(workob->constinv);
- /* Since this is used while calculating parenting, at this moment ob_eval->parent is still NULL. */
+ /* Since this is used while calculating parenting,
+ * at this moment ob_eval->parent is still NULL. */
workob->parent = DEG_get_evaluated_object(depsgraph, ob->parent);
workob->trackflag = ob->trackflag;
@@ -2636,8 +2650,10 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *o
* Applies the global transformation \a mat to the \a ob using a relative parent space if supplied.
*
* \param mat: the global transformation mat that the object should be set object to.
- * \param parent: the parent space in which this object will be set relative to (should probably always be parent_eval).
- * \param use_compat: true to ensure that rotations are set using the min difference between the old and new orientation.
+ * \param parent: the parent space in which this object will be set relative to
+ * (should probably always be parent_eval).
+ * \param use_compat: true to ensure that rotations are set using the
+ * min difference between the old and new orientation.
*/
void BKE_object_apply_mat4_ex(
Object *ob, float mat[4][4], Object *parent, float parentinv[4][4], const bool use_compat)
@@ -3177,14 +3193,19 @@ static void object_handle_update_proxy(Depsgraph *depsgraph,
}
}
-/* proxy rule: lib_object->proxy_from == the one we borrow from, only set temporal and cleared here */
-/* local_object->proxy == pointer to library object, saved in files and read */
-
-/* function below is polluted with proxy exceptions, cleanup will follow! */
-
-/* the main object update call, for object matrix, constraints, keys and displist (modifiers) */
-/* requires flags to be set! */
-/* Ideally we shouldn't have to pass the rigid body world, but need bigger restructuring to avoid id */
+/**
+ * Proxy rule:
+ * - lib_object->proxy_from == the one we borrow from, only set temporal and cleared here.
+ * - local_object->proxy == pointer to library object, saved in files and read.
+ *
+ * Function below is polluted with proxy exceptions, cleanup will follow!
+ *
+ * The main object update call, for object matrix, constraints, keys and displist (modifiers)
+ * requires flags to be set!
+ *
+ * Ideally we shouldn't have to pass the rigid body world,
+ * but need bigger restructuring to avoid id.
+ */
void BKE_object_handle_update_ex(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c
index 751110affaf..0ce6094771c 100644
--- a/source/blender/blenkernel/intern/object_deform.c
+++ b/source/blender/blenkernel/intern/object_deform.c
@@ -347,7 +347,8 @@ static void object_defgroup_remove_edit_mode(Object *ob, bDeformGroup *dg)
BLI_assert(def_nr != -1);
- /* Make sure that no verts are using this group - if none were removed, we can skip next per-vert update. */
+ /* Make sure that no verts are using this group - if none were removed,
+ * we can skip next per-vert update. */
if (!BKE_object_defgroup_clear(ob, dg, false)) {
/* Nothing to do. */
}
@@ -577,7 +578,7 @@ bool *BKE_object_defgroup_lock_flags_get(Object *ob, const int defbase_tot)
{
bool is_locked = false;
int i;
- //int defbase_tot = BLI_listbase_count(&ob->defbase);
+ // int defbase_tot = BLI_listbase_count(&ob->defbase);
bool *lock_flags = MEM_mallocN(defbase_tot * sizeof(bool), "defflags");
bDeformGroup *defgroup;
@@ -601,7 +602,7 @@ bool *BKE_object_defgroup_validmap_get(Object *ob, const int defbase_tot)
bool *defgroup_validmap;
GHash *gh;
int i, step1 = 1;
- //int defbase_tot = BLI_listbase_count(&ob->defbase);
+ // int defbase_tot = BLI_listbase_count(&ob->defbase);
VirtualModifierData virtualModifierData;
if (BLI_listbase_is_empty(&ob->defbase)) {
@@ -692,7 +693,9 @@ bool *BKE_object_defgroup_selected_get(Object *ob, int defbase_tot, int *r_dg_fl
return dg_selection;
}
-/* Marks mirror vgroups in output and counts them. Output and counter assumed to be already initialized.
+/**
+ * Marks mirror vgroups in output and counts them.
+ * Output and counter assumed to be already initialized.
* Designed to be usable after BKE_object_defgroup_selected_get to extend selection to mirror.
*/
void BKE_object_defgroup_mirror_selection(struct Object *ob,
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 00ef5d9c469..8080834a53a 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -122,7 +122,8 @@ static void copy_dupli_context(
{
*r_ctx = *ctx;
- /* XXX annoying, previously was done by passing an ID* argument, this at least is more explicit */
+ /* XXX annoying, previously was done by passing an ID* argument,
+ * this at least is more explicit. */
if (ctx->gen->type == OB_DUPLICOLLECTION) {
r_ctx->collection = ctx->object->instance_collection;
}
@@ -525,7 +526,8 @@ static void make_duplis_font(const DupliContext *ctx)
for (a = 0; a < text_len; a++, ct++) {
/* XXX That G.main is *really* ugly, but not sure what to do here...
- * Definitively don't think it would be safe to put back Main *bmain pointer in DupliContext as done in 2.7x? */
+ * Definitively don't think it would be safe to put back Main *bmain pointer
+ * in DupliContext as done in 2.7x? */
ob = find_family_object(G.main, cu->family, family_len, (unsigned int)text[a], family_gh);
if (ob) {
vec[0] = fsize * (ct->xof - xof);
@@ -988,7 +990,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
copy_v3_v3(vec, obmat[3]);
zero_v3(obmat[3]);
- /* particle rotation uses x-axis as the aligned axis, so pre-rotate the object accordingly */
+ /* Particle rotation uses x-axis as the aligned axis,
+ * so pre-rotate the object accordingly. */
if ((part->draw & PART_DRAW_ROTATE_OB) == 0) {
float xvec[3], q[4], size_mat[4][4], original_size[3];
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 66a3b418f3a..183bc968897 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -369,14 +369,6 @@ void BKE_object_eval_transform_all(Depsgraph *depsgraph, Scene *scene, Object *o
BKE_object_eval_transform_final(depsgraph, object);
}
-void BKE_object_eval_update_shading(Depsgraph *depsgraph, Object *object)
-{
- DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
- if (object->type == OB_MESH) {
- BKE_mesh_batch_cache_dirty_tag(object->data, BKE_MESH_BATCH_DIRTY_SHADING);
- }
-}
-
void BKE_object_data_select_update(Depsgraph *depsgraph, ID *object_data)
{
DEG_debug_print_eval(depsgraph, __func__, object_data->name, object_data);
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 606df3a7a96..b5df7d5fe9b 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -116,7 +116,8 @@ typedef struct Ocean {
/* two dimensional arrays of float */
double *_disp_y; /* init w sim w via plan? */
double *_N_x; /* init w sim w via plan? */
- /* all member of this array has same values, so convert this array to a float to reduce memory usage (MEM01)*/
+ /* all member of this array has same values,
+ * so convert this array to a float to reduce memory usage (MEM01). */
/*float * _N_y; */
double _N_y; /* sim w ********* can be rearranged? */
double *_N_z; /* init w sim w via plan? */
@@ -148,9 +149,9 @@ static float nextfr(RNG *rng, float min, float max)
static float gaussRand(RNG *rng)
{
- /* Note: to avoid numerical problems with very small numbers, we make these variables singe-precision floats,
- * but later we call the double-precision log() and sqrt() functions instead of logf() and sqrtf().
- */
+ /* Note: to avoid numerical problems with very small numbers, we make these variables
+ * singe-precision floats, but later we call the double-precision log() and sqrt() functions
+ * instead of logf() and sqrtf(). */
float x;
float y;
float length2;
@@ -464,9 +465,8 @@ void BKE_ocean_eval_xz_catrom(struct Ocean *oc, struct OceanResult *ocr, float x
BKE_ocean_eval_uv_catrom(oc, ocr, x / oc->_Lx, z / oc->_Lz);
}
-/* note that this doesn't wrap properly for i, j < 0, but its not really meant for that being just a way to get
- * the raw data out to save in some image format.
- */
+/* note that this doesn't wrap properly for i, j < 0, but its not really meant for that being
+ * just a way to get the raw data out to save in some image format. */
void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i, int j)
{
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ);
@@ -519,7 +519,8 @@ static void ocean_compute_htilda(void *__restrict userdata,
int j;
- /* note the <= _N/2 here, see the fftw doco about the mechanics of the complex->real fft storage */
+ /* note the <= _N/2 here, see the fftw doco
+ * about the mechanics of the complex->real fft storage. */
for (j = 0; j <= o->_N / 2; ++j) {
fftw_complex exp_param1;
fftw_complex exp_param2;
@@ -770,11 +771,12 @@ void BKE_ocean_simulate(struct Ocean *o, float t, float scale, float chop_amount
BLI_rw_mutex_lock(&o->oceanmutex, THREAD_LOCK_WRITE);
- /* Note about multi-threading here: we have to run a first set of computations (htilda one) before we can run
- * all others, since they all depend on it.
- * So we make a first parallelized forloop run for htilda, and then pack all other computations into
- * a set of parallel tasks.
- * This is not optimal in all cases, but remains reasonably simple and should be OK most of the time. */
+ /* Note about multi-threading here: we have to run a first set of computations (htilda one)
+ * before we can run all others, since they all depend on it.
+ * So we make a first parallelized forloop run for htilda,
+ * and then pack all other computations into a set of parallel tasks.
+ * This is not optimal in all cases,
+ * but remains reasonably simple and should be OK most of the time. */
/* compute a new htilda */
ParallelRangeSettings settings;
@@ -1342,7 +1344,8 @@ void BKE_ocean_simulate_cache(struct OceanCache *och, int frame)
return;
}
- /* use default color spaces since we know for sure cache files were saved with default settings too */
+ /* Use default color spaces since we know for sure cache
+ * files were saved with default settings too. */
cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_DISPLACE);
och->ibufs_disp[f] = IMB_loadiffname(string, 0, NULL);
@@ -1374,7 +1377,7 @@ void BKE_ocean_bake(struct Ocean *o,
int res_x = och->resolution_x;
int res_y = och->resolution_y;
char string[FILE_MAX];
- //RNG *rng;
+ // RNG *rng;
if (!o) {
return;
@@ -1387,7 +1390,7 @@ void BKE_ocean_bake(struct Ocean *o,
prev_foam = NULL;
}
- //rng = BLI_rng_new(0);
+ // rng = BLI_rng_new(0);
/* setup image format */
imf.imtype = R_IMF_IMTYPE_OPENEXR;
@@ -1429,9 +1432,9 @@ void BKE_ocean_bake(struct Ocean *o,
/* pr = pr * och->foam_fade; */ /* overall fade */
- /* remember ocean coord sys is Y up!
- * break up the foam where height (Y) is low (wave valley), and X and Z displacement is greatest
- */
+ /* Remember ocean coord sys is Y up!
+ * break up the foam where height (Y) is low (wave valley),
+ * and X and Z displacement is greatest. */
neg_disp = ocr.disp[1] < 0.0f ? 1.0f + ocr.disp[1] : 1.0f;
neg_disp = neg_disp < 0.0f ? 0.0f : neg_disp;
@@ -1494,12 +1497,12 @@ void BKE_ocean_bake(struct Ocean *o,
if (prev_foam) {
MEM_freeN(prev_foam);
}
- //BLI_rng_free(rng);
+ // BLI_rng_free(rng);
return;
}
}
- //BLI_rng_free(rng);
+ // BLI_rng_free(rng);
if (prev_foam) {
MEM_freeN(prev_foam);
}
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 29e9295df1d..dd91878a15b 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -181,7 +181,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
return NULL;
}
- //XXX waitcursor(1);
+ // XXX waitcursor(1);
/* convert relative filenames to absolute filenames */
@@ -216,7 +216,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
close(file);
}
- //XXX waitcursor(0);
+ // XXX waitcursor(0);
return (pf);
}
@@ -281,7 +281,7 @@ int writePackedFile(ReportList *reports,
/* void *data; */
if (guimode) {
- } //XXX waitcursor(1);
+ } // XXX waitcursor(1);
BLI_strncpy(name, filename, sizeof(name));
BLI_path_abs(name, ref_file_name);
@@ -336,7 +336,7 @@ int writePackedFile(ReportList *reports,
}
if (guimode) {
- } //XXX waitcursor(0);
+ } // XXX waitcursor(0);
return (ret_value);
}
@@ -407,7 +407,8 @@ int checkPackedFile(const char *ref_file_name, const char *filename, PackedFile
* It returns a char *to the existing file name / new file name or NULL when
* there was an error or when the user decides to cancel the operation.
*
- * \warning 'abs_name' may be relative still! (use a "//" prefix) be sure to run #BLI_path_abs on it first.
+ * \warning 'abs_name' may be relative still! (use a "//" prefix)
+ * be sure to run #BLI_path_abs on it first.
*/
char *unpackFile(ReportList *reports,
const char *ref_file_name,
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 7e8e724cfcc..b594232193d 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -82,8 +82,11 @@ static eOverlayControlFlags overlay_flags = 0;
void BKE_paint_invalidate_overlay_tex(Scene *scene, ViewLayer *view_layer, const Tex *tex)
{
Paint *p = BKE_paint_get_active(scene, view_layer);
- Brush *br = p->brush;
+ if (!p) {
+ return;
+ }
+ Brush *br = p->brush;
if (!br) {
return;
}
@@ -140,6 +143,40 @@ void BKE_paint_reset_overlay_invalid(eOverlayControlFlags flag)
overlay_flags &= ~(flag);
}
+bool BKE_paint_ensure_from_paintmode(Scene *sce, ePaintMode mode)
+{
+ ToolSettings *ts = sce->toolsettings;
+ Paint **paint_ptr = NULL;
+
+ switch (mode) {
+ case PAINT_MODE_SCULPT:
+ paint_ptr = (Paint **)&ts->sculpt;
+ break;
+ case PAINT_MODE_VERTEX:
+ paint_ptr = (Paint **)&ts->vpaint;
+ break;
+ case PAINT_MODE_WEIGHT:
+ paint_ptr = (Paint **)&ts->wpaint;
+ break;
+ case PAINT_MODE_TEXTURE_2D:
+ case PAINT_MODE_TEXTURE_3D:
+ break;
+ case PAINT_MODE_SCULPT_UV:
+ paint_ptr = (Paint **)&ts->uvsculpt;
+ break;
+ case PAINT_MODE_GPENCIL:
+ paint_ptr = (Paint **)&ts->gp_paint;
+ break;
+ case PAINT_MODE_INVALID:
+ break;
+ }
+ if (paint_ptr && (*paint_ptr == NULL)) {
+ BKE_paint_ensure(ts, paint_ptr);
+ return true;
+ }
+ return false;
+}
+
Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode)
{
if (sce) {
@@ -182,6 +219,7 @@ const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode)
case PAINT_MODE_TEXTURE_3D:
return rna_enum_brush_image_tool_items;
case PAINT_MODE_SCULPT_UV:
+ return rna_enum_brush_uv_sculpt_tool_items;
return NULL;
case PAINT_MODE_GPENCIL:
return rna_enum_brush_gpencil_types_items;
@@ -203,6 +241,8 @@ const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode)
case PAINT_MODE_TEXTURE_2D:
case PAINT_MODE_TEXTURE_3D:
return "image_tool";
+ case PAINT_MODE_SCULPT_UV:
+ return "uv_sculpt_tool";
case PAINT_MODE_GPENCIL:
return "gpencil_tool";
default:
@@ -229,10 +269,7 @@ Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer)
case OB_MODE_PAINT_GPENCIL:
return &ts->gp_paint->paint;
case OB_MODE_EDIT:
- if (ts->use_uv_sculpt) {
- return &ts->uvsculpt->paint;
- }
- return &ts->imapaint.paint;
+ return &ts->uvsculpt->paint;
default:
break;
}
@@ -264,7 +301,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
if (sima->mode == SI_MODE_PAINT) {
return &ts->imapaint.paint;
}
- else if (ts->use_uv_sculpt) {
+ else if (sima->mode == SI_MODE_UV) {
return &ts->uvsculpt->paint;
}
}
@@ -287,7 +324,6 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
SpaceImage *sima;
if (sce && view_layer) {
- ToolSettings *ts = sce->toolsettings;
Object *obact = NULL;
if (view_layer->basact && view_layer->basact->object) {
@@ -299,7 +335,7 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
if (sima->mode == SI_MODE_PAINT) {
return PAINT_MODE_TEXTURE_2D;
}
- else if (ts->use_uv_sculpt) {
+ else if (sima->mode == SI_MODE_UV) {
return PAINT_MODE_SCULPT_UV;
}
}
@@ -318,10 +354,7 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
case OB_MODE_TEXTURE_PAINT:
return PAINT_MODE_TEXTURE_3D;
case OB_MODE_EDIT:
- if (ts->use_uv_sculpt) {
- return PAINT_MODE_SCULPT_UV;
- }
- return PAINT_MODE_TEXTURE_2D;
+ return PAINT_MODE_SCULPT_UV;
default:
return PAINT_MODE_TEXTURE_2D;
}
@@ -355,6 +388,8 @@ ePaintMode BKE_paintmode_get_from_tool(const struct bToolRef *tref)
switch (tref->mode) {
case SI_MODE_PAINT:
return PAINT_MODE_TEXTURE_2D;
+ case SI_MODE_UV:
+ return PAINT_MODE_SCULPT_UV;
}
}
@@ -395,15 +430,14 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint)
paint->runtime.tool_offset = offsetof(Brush, weightpaint_tool);
paint->runtime.ob_mode = OB_MODE_WEIGHT_PAINT;
}
+ else if (paint == &ts->uvsculpt->paint) {
+ paint->runtime.tool_offset = offsetof(Brush, uv_sculpt_tool);
+ paint->runtime.ob_mode = OB_MODE_EDIT;
+ }
else if (paint == &ts->gp_paint->paint) {
paint->runtime.tool_offset = offsetof(Brush, gpencil_tool);
paint->runtime.ob_mode = OB_MODE_PAINT_GPENCIL;
}
- else if (paint == &ts->uvsculpt->paint) {
- /* We don't use these yet. */
- paint->runtime.tool_offset = 0;
- paint->runtime.ob_mode = 0;
- }
else {
BLI_assert(0);
}
@@ -421,9 +455,10 @@ uint BKE_paint_get_brush_tool_offset_from_paintmode(const ePaintMode mode)
return offsetof(Brush, vertexpaint_tool);
case PAINT_MODE_WEIGHT:
return offsetof(Brush, weightpaint_tool);
+ case PAINT_MODE_SCULPT_UV:
+ return offsetof(Brush, uv_sculpt_tool);
case PAINT_MODE_GPENCIL:
return offsetof(Brush, gpencil_tool);
- case PAINT_MODE_SCULPT_UV:
case PAINT_MODE_INVALID:
break; /* We don't use these yet. */
}
@@ -447,8 +482,10 @@ PaintCurve *BKE_paint_curve_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of PaintCurve ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of PaintCurve ID from source to
+ * already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -504,7 +541,7 @@ void BKE_paint_curve_clamp_endpoint_add_index(PaintCurve *pc, const int add_inde
pc->add_index = (add_index || pc->tot_points == 1) ? (add_index + 1) : 0;
}
-/* remove colour from palette. Must be certain color is inside the palette! */
+/** Remove color from palette. Must be certain color is inside the palette! */
void BKE_palette_color_remove(Palette *palette, PaletteColor *color)
{
if (BLI_listbase_count_at_most(&palette->colors, palette->active_color) ==
@@ -534,8 +571,10 @@ Palette *BKE_palette_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Palette ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Palette ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -938,7 +977,8 @@ void BKE_sculptsession_bm_to_me(Object *ob, bool reorder)
if (ob && ob->sculpt) {
sculptsession_bm_to_me_update_data_only(ob, reorder);
- /* ensure the objects evaluated mesh doesn't hold onto arrays now realloc'd in the mesh [#34473] */
+ /* Ensure the objects evaluated mesh doesn't hold onto arrays
+ * now realloc'd in the mesh T34473. */
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
@@ -1134,7 +1174,10 @@ void BKE_sculpt_update_mesh_elements(
if (!CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) {
#if 1
BKE_sculpt_mask_layers_ensure(ob, mmd);
-#else /* if we wanted to support adding mask data while multi-res painting, we would need to do this */
+#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 |= ID_RECALC_GEOMETRY;
diff --git a/source/blender/blenkernel/intern/paint_toolslots.c b/source/blender/blenkernel/intern/paint_toolslots.c
index 942d5e758f3..fbf586e3f49 100644
--- a/source/blender/blenkernel/intern/paint_toolslots.c
+++ b/source/blender/blenkernel/intern/paint_toolslots.c
@@ -70,6 +70,7 @@ void BKE_paint_toolslots_init_from_main(struct Main *bmain)
paint_toolslots_init(bmain, &ts->sculpt->paint);
paint_toolslots_init(bmain, &ts->vpaint->paint);
paint_toolslots_init(bmain, &ts->wpaint->paint);
+ paint_toolslots_init(bmain, &ts->uvsculpt->paint);
paint_toolslots_init(bmain, &ts->gp_paint->paint);
}
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 986e47894ca..c6cc72ba989 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -477,7 +477,9 @@ static void fluid_free_settings(SPHFluidSettings *fluid)
}
}
-/** Free (or release) any data used by this particle settings (does not free the partsett itself). */
+/**
+ * Free (or release) any data used by this particle settings (does not free the partsett itself).
+ */
void BKE_particlesettings_free(ParticleSettings *part)
{
int a;
@@ -603,7 +605,8 @@ void psys_free_particles(ParticleSystem *psys)
PARTICLE_P;
if (psys->particles) {
- /* Even though psys->part should never be NULL, this can happen as an exception during deletion.
+ /* Even though psys->part should never be NULL,
+ * this can happen as an exception during deletion.
* See ID_REMAP_SKIP/FORCE/FLAG_NEVER_NULL_USAGE in BKE_library_remap. */
if (psys->part && psys->part->type == PART_HAIR) {
LOOP_PARTICLES
@@ -846,8 +849,12 @@ typedef struct ParticleInterpolationData {
float birthtime, dietime;
int bspline;
} ParticleInterpolationData;
-/* Assumes pointcache->mem_cache exists, so for disk cached particles call psys_make_temp_pointcache() before use */
-/* It uses ParticleInterpolationData->pm to store the current memory cache frame so it's thread safe. */
+/**
+ * Assumes pointcache->mem_cache exists, so for disk cached particles
+ * call #psys_make_temp_pointcache() before use.
+ * It uses #ParticleInterpolationData.pm to store the current memory cache frame
+ * so it's thread safe.
+ */
static void get_pointcache_keys_for_time(Object *UNUSED(ob),
PointCache *cache,
PTCacheMem **cur,
@@ -1194,7 +1201,8 @@ static void do_particle_interpolation(ParticleSystem *psys,
interp_qt_qtqt(result->rot, keys[1].rot, keys[2].rot, keytime);
}
- /* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0, 1]->[k2, k3] (k1 & k4 used for cardinal & bspline interpolation)*/
+ /* Now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between
+ * [0, 1]->[k2, k3] (k1 & k4 used for cardinal & bspline interpolation). */
psys_interpolate_particle((pind->keyed || pind->cache || point_vel) ?
-1 /* signal for cubic interpolation */
:
@@ -1538,7 +1546,7 @@ int psys_particle_dm_face_lookup(Mesh *mesh_final,
if (osface_final == NULL) {
/* Assume we don't need osface_final data, and we get a direct 1-1 mapping... */
if (findex_orig < totface_final) {
- //printf("\tNO CD_ORIGSPACE, assuming not needed\n");
+ // printf("\tNO CD_ORIGSPACE, assuming not needed\n");
return findex_orig;
}
else {
@@ -1574,7 +1582,8 @@ int psys_particle_dm_face_lookup(Mesh *mesh_final,
}
else { /* if we have no node, try every face */
for (int findex_dst = 0; findex_dst < totface_final; findex_dst++) {
- /* If current tessface from 'final' DM and orig tessface (given by index) map to the same orig poly... */
+ /* If current tessface from 'final' DM and orig tessface (given by index)
+ * map to the same orig poly. */
if (BKE_mesh_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, findex_dst) ==
pindex_orig) {
faceuv = osface_final[findex_dst].uv;
@@ -2090,7 +2099,7 @@ int do_guides(Depsgraph *depsgraph,
add_v3_v3(vec_to_point, guidevec);
- //sub_v3_v3v3(pa_loc, pa_loc, pa_zero);
+ // sub_v3_v3v3(pa_loc, pa_loc, pa_zero);
madd_v3_v3fl(effect, vec_to_point, data->strength);
madd_v3_v3fl(veffect, guidedir, data->strength);
totstrength += data->strength;
@@ -2106,7 +2115,7 @@ int do_guides(Depsgraph *depsgraph,
mul_v3_fl(effect, 1.0f / totstrength);
}
CLAMP(totstrength, 0.0f, 1.0f);
- //add_v3_v3(effect, pa_zero);
+ // add_v3_v3(effect, pa_zero);
interp_v3_v3v3(state->co, state->co, effect, totstrength);
normalize_v3(veffect);
@@ -2245,7 +2254,8 @@ void psys_find_parents(ParticleSimulationData *sim, const bool use_render_params
psys_particle_on_emitter(
sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco);
- /* Check if particle doesn't exist because of texture influence. Insert only existing particles into kdtree. */
+ /* Check if particle doesn't exist because of texture influence.
+ * Insert only existing particles into kdtree. */
get_cpa_texture(sim->psmd->mesh_final,
psys,
part,
@@ -2463,7 +2473,8 @@ static void psys_thread_create_path(ParticleTask *task,
const ParticleCacheKey *key_w_last = pcache_key_segment_endpoint_safe(key[w]);
float d;
if (part->flag & PART_CHILD_LONG_HAIR) {
- /* For long hair use tip distance/root distance as parting factor instead of root to tip angle. */
+ /* For long hair use tip distance/root distance as parting
+ * factor instead of root to tip angle. */
float d1 = len_v3v3(key[0]->co, key[w]->co);
float d2 = len_v3v3(key_0_last->co, key_w_last->co);
@@ -2676,7 +2687,8 @@ static void psys_thread_create_path(ParticleTask *task,
pa = &psys->particles[cpa->parent];
par = pcache[cpa->parent];
- /* If particle is unexisting, try to pick a viable parent from particles used for interpolation. */
+ /* If particle is unexisting, try to pick a viable parent from particles
+ * used for interpolation. */
for (k = 0; k < 4 && pa && (pa->flag & PARS_UNEXIST); k++) {
if (cpa->pa[k] >= 0) {
pa = &psys->particles[cpa->pa[k]];
@@ -3741,8 +3753,10 @@ void BKE_particlesettings_twist_curve_init(ParticleSettings *part)
}
/**
- * Only copy internal data of ParticleSettings ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of ParticleSettings ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -4324,7 +4338,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
}
}
else if (totchild) {
- //invert_m4_m4(imat, ob->obmat);
+ // invert_m4_m4(imat, ob->obmat);
/* interpolate childcache directly if it exists */
if (psys->childcache) {
@@ -4368,10 +4382,11 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
psys_particle_on_emitter(
psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa->fuv, foffset, co, 0, 0, 0, orco);
- /* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */
- //copy_v3_v3(cpa_1st, co);
+ /* We need to save the actual root position of the child for
+ * positioning it accurately to the surface of the emitter. */
+ // copy_v3_v3(cpa_1st, co);
- //mul_m4_v3(ob->obmat, cpa_1st);
+ // mul_m4_v3(ob->obmat, cpa_1st);
pa = psys->particles + cpa->parent;
@@ -4455,7 +4470,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
w++;
}
/* apply offset for correct positioning */
- //add_v3_v3(state->co, cpa_1st);
+ // add_v3_v3(state->co, cpa_1st);
}
else {
/* offset the child from the parent position */
@@ -4614,7 +4629,8 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
/* let's interpolate to try to be as accurate as possible */
if (pa->state.time + 2.f >= state->time && pa->prev_state.time - 2.f <= state->time) {
if (pa->prev_state.time >= pa->state.time || pa->prev_state.time < 0.f) {
- /* prev_state is wrong so let's not use it, this can happen at frames 1, 0 or particle birth */
+ /* prev_state is wrong so let's not use it,
+ * this can happen at frames 1, 0 or particle birth. */
dfra = state->time - pa->state.time;
copy_particle_key(state, &pa->state, 1);
@@ -4655,7 +4671,8 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec);
}
else {
- /* extrapolating over big ranges is not accurate so let's just give something close to reasonable back */
+ /* Extrapolating over big ranges is not accurate
+ * so let's just give something close to reasonable back. */
copy_particle_key(state, &pa->state, 0);
}
}
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index 45aa55a401b..070c3c7a566 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -909,14 +909,14 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
!CustomData_get_layer(&final_mesh->fdata, CD_ORIGINDEX)) {
printf(
"Can't create particles with the current modifier stack, disable destructive modifiers\n");
- // XXX error("Can't paint with the current modifier stack, disable destructive modifiers");
+ // XXX error("Can't paint with the current modifier stack, disable destructive modifiers");
return 0;
}
- /* XXX This distribution code is totally broken in case from == PART_FROM_CHILD, it's always using finaldm
- * even if use_modifier_stack is unset... But making things consistent here break all existing edited
- * hair systems, so better wait for complete rewrite.
- */
+ /* XXX This distribution code is totally broken in case from == PART_FROM_CHILD,
+ * it's always using finaldm even if use_modifier_stack is unset...
+ * But making things consistent here break all existing edited
+ * hair systems, so better wait for complete rewrite. */
psys_thread_context_init(ctx, sim);
@@ -1170,7 +1170,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
int i_mapped = 0;
for (i = 0; i < totelem && element_weight[i] == 0.0f; i++) {
- ;
+ /* pass */
}
element_sum[i_mapped] = element_weight[i] * inv_totweight;
element_map[i_mapped] = i;
@@ -1204,9 +1204,10 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
double step, pos;
step = (totpart < 2) ? 0.5 : 1.0 / (double)totpart;
- /* This is to address tricky issues with vertex-emitting when user tries (and expects) exact 1-1 vert/part
- * distribution (see T47983 and its two example files). It allows us to consider pos as
- * 'midpoint between v and v+1' (or 'p and p+1', depending whether we have more vertices than particles or not),
+ /* This is to address tricky issues with vertex-emitting when user tries
+ * (and expects) exact 1-1 vert/part distribution (see T47983 and its two example files).
+ * It allows us to consider pos as 'midpoint between v and v+1'
+ * (or 'p and p+1', depending whether we have more vertices than particles or not),
* and avoid stumbling over float impression in element_sum.
* Note: moved face and volume distribution to this as well (instead of starting at zero),
* for the same reasons, see T52682. */
@@ -1215,7 +1216,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
for (i = 0, p = 0; p < totpart; p++, pos += step) {
for (; (i < totmapped - 1) && (pos > (double)element_sum[i]); i++) {
- ;
+ /* pass */
}
particle_element[p] = element_map[i];
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 38183f97b72..cba15aed55f 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -567,7 +567,7 @@ void psys_thread_context_free(ParticleThreadContext *ctx)
if (ctx->seams) {
MEM_freeN(ctx->seams);
}
- //if (ctx->vertpart) MEM_freeN(ctx->vertpart);
+ // if (ctx->vertpart) MEM_freeN(ctx->vertpart);
BLI_kdtree_3d_free(ctx->tree);
if (ctx->clumpcurve != NULL) {
@@ -619,7 +619,7 @@ void initialize_particle(ParticleSimulationData *sim, ParticleData *pa)
pa->hair_index = 0;
/* we can't reset to -1 anymore since we've figured out correct index in distribute_particles */
/* usage other than straight after distribute has to handle this index by itself - jahka*/
- //pa->num_dmcache = DMCACHE_NOTFOUND; /* assume we don't have a derived mesh face */
+ // pa->num_dmcache = DMCACHE_NOTFOUND; /* assume we don't have a derived mesh face */
}
static void initialize_all_particles(ParticleSimulationData *sim)
@@ -791,8 +791,15 @@ void psys_get_birth_coords(
/* -tangent */
if (use_tangents) {
- //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f;
+#if 0
+ float phase = vg_rot ?
+ 2.0f *
+ (psys_particle_value_from_verts(sim->psmd->dm, part->from, pa, vg_rot) -
+ 0.5f) :
+ 0.0f;
+#else
float phase = 0.0f;
+#endif
mul_v3_fl(vtan, -cosf((float)M_PI * (part->tanphase + phase)));
fac = -sinf((float)M_PI * (part->tanphase + phase));
madd_v3_v3fl(vtan, utan, fac);
@@ -1554,12 +1561,13 @@ static void integrate_particle(
}
}
-/*********************************************************************************************************
- * SPH fluid physics
+/* -------------------------------------------------------------------- */
+/** \name SPH fluid physics
*
* In theory, there could be unlimited implementation of SPH simulators
*
- * This code uses in some parts adapted algorithms from the pseudo code as outlined in the Research paper:
+ * This code uses in some parts adapted algorithms
+ * from the pseudo code as outlined in the Research paper:
*
* Titled: Particle-based Viscoelastic Fluid Simulation.
* Authors: Simon Clavet, Philippe Beaudoin and Pierre Poulin
@@ -1567,7 +1575,8 @@ static void integrate_particle(
*
* Presented at Siggraph, (2005)
*
- * ********************************************************************************************************/
+ * \{ */
+
#define PSYS_FLUID_SPRINGS_INITIAL_SIZE 256
static ParticleSpring *sph_spring_add(ParticleSystem *psys, ParticleSpring *spring)
{
@@ -2199,7 +2208,7 @@ static void sph_integrate(ParticleSimulationData *sim,
sphdata->pa = pa;
sphdata->mass = pa_mass;
sphdata->pass = 0;
- //sphdata.element_size and sphdata.flow are set in the callback.
+ // sphdata.element_size and sphdata.flow are set in the callback.
/* restore previous state and treat gravity & effectors as external acceleration*/
sub_v3_v3v3(effector_acceleration, pa->state.vel, pa->prev_state.vel);
@@ -2210,6 +2219,8 @@ static void sph_integrate(ParticleSimulationData *sim,
integrate_particle(part, pa, dtime, effector_acceleration, sphdata->force_cb, sphdata);
}
+/** \} */
+
/************************************************/
/* Basic physics */
/************************************************/
@@ -2289,7 +2300,7 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa
mul_v3_fl(pa->state.vel, 1.f - part->dampfac * efdata.ptex.damp * 25.f * dtime);
}
- //copy_v3_v3(pa->state.ave, states->ave);
+ // copy_v3_v3(pa->state.ave, states->ave);
/* finally we do guides */
time = (cfra - pa->time) / pa->lifetime;
@@ -2435,7 +2446,8 @@ static void collision_interpolate_element(ParticleCollisionElement *pce,
{
/* t is the current time for newton rhapson */
/* fac is the starting factor for current collision iteration */
- /* the col->fac's are factors for the particle subframe step start and end during collision modifier step */
+ /* The col->fac's are factors for the particle subframe step start
+ * and end during collision modifier step. */
float f = fac + t * (1.f - fac);
float mul = col->fac1 + f * (col->fac2 - col->fac1);
if (pce->tot > 0) {
@@ -2928,7 +2940,8 @@ static int collision_response(ParticleSimulationData *sim,
/* get exact velocity right before collision */
madd_v3_v3v3fl(v0, col->ve1, col->acc, dt1);
- /* convert collider velocity from 1/framestep to 1/s TODO: here we assume 1 frame step for collision modifier */
+ /* Convert collider velocity from 1/framestep to 1/s TODO:
+ * here we assume 1 frame step for collision modifier. */
mul_v3_fl(pce->vel, col->inv_timestep);
/* calculate tangential particle velocity */
@@ -2983,8 +2996,10 @@ static int collision_response(ParticleSimulationData *sim,
}
}
- /* stickiness was possibly added before, so cancel that before calculating new normal velocity */
- /* otherwise particles go flying out of the surface because of high reversed sticky velocity */
+ /* Stickiness was possibly added before,
+ * so cancel that before calculating new normal velocity.
+ * Otherwise particles go flying out of the surface
+ * because of high reversed sticky velocity. */
if (v0_dot < 0.0f) {
v0_dot += pd->pdef_stickness;
if (v0_dot > 0.0f) {
@@ -3578,7 +3593,8 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra))
pa->totkey++;
- /* root is always in the origin of hair space so we set it to be so after the last key is saved*/
+ /* Root is always in the origin of hair space
+ * so we set it to be so after the last key is saved. */
if (pa->totkey == psys->part->hair_step + 1) {
zero_v3(root->co);
}
@@ -4185,7 +4201,7 @@ static void particles_fluid_step(ParticleSimulationData *sim,
float wrf;
gzread(gzf, &wrf, sizeof(wrf));
pa->state.co[j] = wrf;
- //fprintf(stderr,"Rj%d ",j);
+ // fprintf(stderr,"Rj%d ",j);
}
for (j = 0; j < 3; j++) {
float wrf;
@@ -4200,7 +4216,18 @@ static void particles_fluid_step(ParticleSimulationData *sim,
pa->dietime = sim->scene->r.efra + 1;
pa->lifetime = sim->scene->r.efra;
pa->alive = PARS_ALIVE;
- //if (a < 25) fprintf(stderr,"FSPARTICLE debug set %s, a%d = %f,%f,%f, life=%f\n", filename, a, pa->co[0],pa->co[1],pa->co[2], pa->lifetime );
+# if 0
+ if (a < 25) {
+ fprintf(stderr,
+ "FSPARTICLE debug set %s, a%d = %f,%f,%f, life=%f\n",
+ filename,
+ a,
+ pa->co[0],
+ pa->co[1],
+ pa->co[2],
+ pa->lifetime);
+ }
+# endif
}
else {
// skip...
@@ -4759,7 +4786,8 @@ void particle_system_update(struct Depsgraph *depsgraph,
}
}
- /* save matrix for duplicators, at rendertime the actual dupliobject's matrix is used so don't update! */
+ /* Save matrix for duplicators,
+ * at rendertime the actual dupliobject's matrix is used so don't update! */
invert_m4_m4(psys->imat, ob->obmat);
BKE_particle_batch_cache_dirty_tag(psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 0a82d086862..f1d5347c48b 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -154,12 +154,12 @@ static void update_node_vb(PBVH *bvh, PBVHNode *node)
node->vb = vb;
}
-//void BKE_pbvh_node_BB_reset(PBVHNode *node)
+// void BKE_pbvh_node_BB_reset(PBVHNode *node)
//{
// BB_reset(&node->vb);
//}
//
-//void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3])
+// void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3])
//{
// BB_expand(&node->vb, co);
//}
@@ -181,10 +181,10 @@ static int partition_indices(int *prim_indices, int lo, int hi, int axis, float
int i = lo, j = hi;
for (;;) {
for (; prim_bbc[prim_indices[i]].bcentroid[axis] < mid; i++) {
- ;
+ /* pass */
}
for (; mid < prim_bbc[prim_indices[j]].bcentroid[axis]; j--) {
- ;
+ /* pass */
}
if (!(i < j)) {
@@ -216,18 +216,18 @@ static int partition_indices_material(PBVH *bvh, int lo, int hi)
for (;;) {
if (bvh->looptri) {
for (; face_materials_match(first, &mpoly[looptri[indices[i]].poly]); i++) {
- ;
+ /* pass */
}
for (; !face_materials_match(first, &mpoly[looptri[indices[j]].poly]); j--) {
- ;
+ /* pass */
}
}
else {
for (; grid_materials_match(first, &flagmats[indices[i]]); i++) {
- ;
+ /* pass */
}
for (; !grid_materials_match(first, &flagmats[indices[j]]); j--) {
- ;
+ /* pass */
}
}
@@ -1038,9 +1038,10 @@ static void pbvh_update_normals_accum_task_cb(void *__restrict userdata,
const int v = vtri[j];
if (bvh->verts[v].flag & ME_VERT_PBVH_UPDATE) {
- /* Note: This avoids `lock, add_v3_v3, unlock` and is five to ten times quicker than a spinlock.
- * Not exact equivalent though, since atomicity is only ensured for one component
- * of the vector at a time, but here it shall not make any sensible difference. */
+ /* Note: This avoids `lock, add_v3_v3, unlock`
+ * and is five to ten times quicker than a spinlock.
+ * Not exact equivalent though, since atomicity is only ensured for one component
+ * of the vector at a time, but here it shall not make any sensible difference. */
for (int k = 3; k--;) {
atomic_add_and_fetch_fl(&vnors[v][k], fn[k]);
}
@@ -1924,8 +1925,8 @@ void BKE_pbvh_raycast_project_ray_root(
BKE_pbvh_node_get_BB(bvh->nodes, bb_min_root, bb_max_root);
}
- /* slightly offset min and max in case we have a zero width node (due to a plane mesh for instance),
- * or faces very close to the bounding box boundary. */
+ /* Slightly offset min and max in case we have a zero width node
+ * (due to a plane mesh for instance), or faces very close to the bounding box boundary. */
mid_v3_v3v3(bb_center, bb_max_root, bb_min_root);
/* diff should be same for both min/max since it's calculated from center */
sub_v3_v3v3(bb_diff, bb_max_root, bb_center);
@@ -2201,26 +2202,17 @@ bool BKE_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data)
return test_planes_aabb(bb_min, bb_max, data) != ISECT_INSIDE;
}
-struct PBVHNodeDrawCallbackData {
- void (*draw_fn)(void *user_data, GPUBatch *batch);
+typedef struct PBVHNodeDrawCallbackData {
+ void (*draw_fn)(void *user_data, GPU_PBVH_Buffers *buffers);
void *user_data;
- bool fast;
- bool only_mask; /* Only draw nodes that have mask data. */
- bool wires;
-};
+} PBVHNodeDrawCallbackData;
static void pbvh_node_draw_cb(PBVHNode *node, void *data_v)
{
- struct PBVHNodeDrawCallbackData *data = data_v;
+ PBVHNodeDrawCallbackData *data = data_v;
if (!(node->flag & PBVH_FullyHidden)) {
- GPUBatch *batch = GPU_pbvh_buffers_batch_get(node->draw_buffers, data->fast, data->wires);
- bool show_mask = GPU_pbvh_buffers_has_mask(node->draw_buffers);
- if (!data->only_mask || show_mask) {
- if (batch != NULL) {
- data->draw_fn(data->user_data, batch);
- }
- }
+ data->draw_fn(data->user_data, node->draw_buffers);
}
}
@@ -2230,20 +2222,10 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v)
void BKE_pbvh_draw_cb(PBVH *bvh,
float (*planes)[4],
float (*fnors)[3],
- bool fast,
- bool wires,
- bool only_mask,
bool show_vcol,
- void (*draw_fn)(void *user_data, GPUBatch *batch),
+ void (*draw_fn)(void *user_data, GPU_PBVH_Buffers *buffers),
void *user_data)
{
- struct PBVHNodeDrawCallbackData draw_data = {
- .only_mask = only_mask,
- .fast = fast,
- .wires = wires,
- .draw_fn = draw_fn,
- .user_data = user_data,
- };
PBVHNode **nodes;
int totnode;
@@ -2260,6 +2242,11 @@ void BKE_pbvh_draw_cb(PBVH *bvh,
MEM_freeN(nodes);
}
+ PBVHNodeDrawCallbackData draw_data = {
+ .draw_fn = draw_fn,
+ .user_data = user_data,
+ };
+
if (planes) {
BKE_pbvh_search_callback(
bvh, BKE_pbvh_node_planes_contain_AABB, planes, pbvh_node_draw_cb, &draw_data);
@@ -2267,10 +2254,18 @@ void BKE_pbvh_draw_cb(PBVH *bvh,
else {
BKE_pbvh_search_callback(bvh, NULL, NULL, pbvh_node_draw_cb, &draw_data);
}
-#if 0
- if (G.debug_value == 14)
- pbvh_draw_BB(bvh);
-#endif
+}
+
+void BKE_pbvh_draw_debug_cb(
+ PBVH *bvh,
+ void (*draw_fn)(void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag),
+ void *user_data)
+{
+ for (int a = 0; a < bvh->totnode; a++) {
+ PBVHNode *node = &bvh->nodes[a];
+
+ draw_fn(user_data, node->vb.bmin, node->vb.bmax, node->flag);
+ }
}
void BKE_pbvh_grids_update(
@@ -2341,7 +2336,8 @@ void BKE_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3], const int totvert)
/* unneeded deformation -- duplicate verts/faces to avoid this */
pbvh->verts = MEM_dupallocN(pbvh->verts);
- /* No need to dupalloc pbvh->looptri, this one is 'totally owned' by pbvh, it's never some mesh data. */
+ /* No need to dupalloc pbvh->looptri, this one is 'totally owned' by pbvh,
+ * it's never some mesh data. */
pbvh->deformed = true;
}
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index bc84b3737aa..25f9948a835 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -1916,7 +1916,8 @@ void BKE_pbvh_build_bmesh(PBVH *bvh,
/* start recursion, assign faces to nodes accordingly */
pbvh_bmesh_node_limit_ensure_fast(bvh, nodeinfo, bbc_array, &rootnode, arena);
- /* we now have all faces assigned to a node, next we need to assign those to the gsets of the nodes */
+ /* We now have all faces assigned to a node,
+ * next we need to assign those to the gsets of the nodes. */
/* Start with all faces in the root node */
bvh->nodes = MEM_callocN(sizeof(PBVHNode), "PBVHNode");
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index c07ae89e250..a55d0be4f95 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -293,7 +293,8 @@ static int ptcache_particle_write(int index, void *psys_v, void **data, int cfra
PTCACHE_DATA_FROM(data, BPHYS_DATA_BOIDS, &boid->data);
}
- /* return flag 1+1=2 for newly born particles to copy exact birth location to previously cached frame */
+ /* Return flag 1+1=2 for newly born particles
+ * to copy exact birth location to previously cached frame. */
return 1 + (pa->state.time >= pa->time && pa->prev_state.time <= pa->time);
}
static void ptcache_particle_read(
@@ -630,7 +631,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
unsigned int in_len = sizeof(float) * (unsigned int)res;
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len) * 4,
"pointcache_lzo_buffer");
- //int mode = res >= 1000000 ? 2 : 1;
+ // int mode = res >= 1000000 ? 2 : 1;
int mode = 1; // light
if (sds->cache_comp == SM_CACHE_HEAVY) {
mode = 2; // heavy
@@ -703,7 +704,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
smoke_turbulence_get_res(sds->wt, res_big_array);
res_big = res_big_array[0] * res_big_array[1] * res_big_array[2];
- //mode = res_big >= 1000000 ? 2 : 1;
+ // mode = res_big >= 1000000 ? 2 : 1;
mode = 1; // light
if (sds->cache_high_comp == SM_CACHE_HEAVY) {
mode = 2; // heavy
@@ -2285,7 +2286,7 @@ static int ptcache_file_compressed_write(
r = LzmaCompress(out,
&out_len,
in,
- in_len, //assume sizeof(char)==1....
+ in_len, // assume sizeof(char)==1....
props,
&sizeOfIt,
5,
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index b5960962e17..ad15214c3b8 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -114,7 +114,8 @@ void BKE_rigidbody_free_world(Scene *scene)
}
if (is_orig && rbw->shared->physics_world) {
- /* free physics references, we assume that all physics objects in will have been added to the world */
+ /* Free physics references,
+ * we assume that all physics objects in will have been added to the world. */
if (rbw->constraints) {
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->constraints, object) {
if (object->rigidbody_constraint) {
@@ -685,7 +686,8 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool
}
/* make sure collision shape exists */
- /* FIXME we shouldn't always have to rebuild collision shapes when rebuilding objects, but it's needed for constraints to update correctly */
+ /* FIXME we shouldn't always have to rebuild collision shapes when rebuilding objects,
+ * but it's needed for constraints to update correctly. */
if (rbo->shared->physics_shape == NULL || rebuild) {
rigidbody_validate_sim_shape(ob, true);
}
@@ -990,8 +992,12 @@ static void rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, b
/* --------------------- */
-/* Create physics sim world given RigidBody world settings */
-// NOTE: this does NOT update object references that the scene uses, in case those aren't ready yet!
+/**
+ * Create physics sim world given RigidBody world settings
+ *
+ * \note this does NOT update object references that the scene uses,
+ * in case those aren't ready yet!
+ */
void BKE_rigidbody_validate_sim_world(Scene *scene, RigidBodyWorld *rbw, bool rebuild)
{
/* sanity checks */
@@ -1411,6 +1417,10 @@ static void rigidbody_update_sim_ob(
return;
}
+ ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+ const bool is_selected = base ? (base->flag & BASE_SELECTED) != 0 : false;
+
if (rbo->shape == RB_SHAPE_TRIMESH && rbo->flag & RBO_FLAG_USE_DEFORM) {
Mesh *mesh = ob->runtime.mesh_deform_eval;
if (mesh) {
@@ -1437,14 +1447,15 @@ static void rigidbody_update_sim_ob(
RBO_GET_MARGIN(rbo) * MIN3(scale[0], scale[1], scale[2]));
}
- /* make transformed objects temporarily kinmatic so that they can be moved by the user during simulation */
- if (ob->flag & SELECT && G.moving & G_TRANSFORM_OBJ) {
+ /* Make transformed objects temporarily kinmatic
+ * so that they can be moved by the user during simulation. */
+ if (is_selected && (G.moving & G_TRANSFORM_OBJ)) {
RB_body_set_kinematic_state(rbo->shared->physics_object, true);
RB_body_set_mass(rbo->shared->physics_object, 0.0f);
}
/* update rigid body location and rotation for kinematic bodies */
- if (rbo->flag & RBO_FLAG_KINEMATIC || (ob->flag & SELECT && G.moving & G_TRANSFORM_OBJ)) {
+ if (rbo->flag & RBO_FLAG_KINEMATIC || (is_selected && (G.moving & G_TRANSFORM_OBJ))) {
RB_body_activate(rbo->shared->physics_object);
RB_body_set_loc_rot(rbo->shared->physics_object, loc, rot);
}
@@ -1463,15 +1474,16 @@ static void rigidbody_update_sim_ob(
float eff_loc[3], eff_vel[3];
/* create dummy 'point' which represents last known position of object as result of sim */
- // XXX: this can create some inaccuracies with sim position, but is probably better than using unsimulated vals?
+ /* XXX: this can create some inaccuracies with sim position,
+ * but is probably better than using unsimulated vals? */
RB_body_get_position(rbo->shared->physics_object, eff_loc);
RB_body_get_linear_velocity(rbo->shared->physics_object, eff_vel);
pd_point_from_loc(scene, eff_loc, eff_vel, 0, &epoint);
- /* calculate net force of effectors, and apply to sim object
- * - we use 'central force' since apply force requires a "relative position" which we don't have...
- */
+ /* Calculate net force of effectors, and apply to sim object:
+ * - we use 'central force' since apply force requires a "relative position"
+ * which we don't have... */
BKE_effectors_apply(effectors, NULL, effector_weights, &epoint, eff_force, NULL);
if (G.f & G_DEBUG) {
printf("\tapplying force (%f,%f,%f) to '%s'\n",
@@ -1541,13 +1553,15 @@ static void rigidbody_update_simulation(Depsgraph *depsgraph,
if (ob->type == OB_MESH) {
/* validate that we've got valid object set up here... */
RigidBodyOb *rbo = ob->rigidbody_object;
- /* update transformation matrix of the object so we don't get a frame of lag for simple animations */
+ /* Update transformation matrix of the object
+ * so we don't get a frame of lag for simple animations. */
BKE_object_where_is_calc_time(depsgraph, scene, ob, ctime);
/* TODO remove this whole block once we are sure we never get NULL rbo here anymore. */
/* This cannot be done in CoW evaluation context anymore... */
if (rbo == NULL) {
- BLI_assert(!"CoW object part of RBW object collection without RB object data, should not happen.\n");
+ BLI_assert(!"CoW object part of RBW object collection without RB object data, "
+ "should not happen.\n");
/* Since this object is included in the sim group but doesn't have
* rigid body settings (perhaps it was added manually), add!
* - assume object to be active? That is the default for newly added settings...
@@ -1563,7 +1577,8 @@ static void rigidbody_update_simulation(Depsgraph *depsgraph,
if (rebuild) {
/* World has been rebuilt so rebuild object */
/* TODO(Sybren): rigidbody_validate_sim_object() can call rigidbody_validate_sim_shape(),
- * but neither resets the RBO_FLAG_NEEDS_RESHAPE flag nor calls RB_body_set_collision_shape().
+ * but neither resets the RBO_FLAG_NEEDS_RESHAPE flag nor
+ * calls RB_body_set_collision_shape().
* This results in the collision shape being created twice, which is unnecessary. */
rigidbody_validate_sim_object(rbw, ob, true);
}
@@ -1575,7 +1590,8 @@ static void rigidbody_update_simulation(Depsgraph *depsgraph,
/* mesh/shape data changed, so force shape refresh */
rigidbody_validate_sim_shape(ob, true);
/* now tell RB sim about it */
- // XXX: we assume that this can only get applied for active/passive shapes that will be included as rigidbodies
+ /* XXX: we assume that this can only get applied for active/passive shapes
+ * that will be included as rigidbodies. */
RB_body_set_collision_shape(rbo->shared->physics_object, rbo->shared->physics_shape);
}
}
@@ -1595,13 +1611,15 @@ static void rigidbody_update_simulation(Depsgraph *depsgraph,
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->constraints, ob) {
/* validate that we've got valid object set up here... */
RigidBodyCon *rbc = ob->rigidbody_constraint;
- /* update transformation matrix of the object so we don't get a frame of lag for simple animations */
+ /* Update transformation matrix of the object
+ * so we don't get a frame of lag for simple animations. */
BKE_object_where_is_calc_time(depsgraph, scene, ob, ctime);
/* TODO remove this whole block once we are sure we never get NULL rbo here anymore. */
/* This cannot be done in CoW evaluation context anymore... */
if (rbc == NULL) {
- BLI_assert(!"CoW object part of RBW constraints collection without RB constraint data, should not happen.\n");
+ BLI_assert(!"CoW object part of RBW constraints collection without RB constraint data, "
+ "should not happen.\n");
/* Since this object is included in the group but doesn't have
* constraint settings (perhaps it was added manually), add!
*/
@@ -1663,7 +1681,7 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime)
/* use rigid body transform after cache start frame if objects is not being transformed */
if (BKE_rigidbody_check_sim_running(rbw, ctime) &&
- !(ob->flag & SELECT && G.moving & G_TRANSFORM_OBJ)) {
+ !(ob->base_flag & BASE_SELECTED && G.moving & G_TRANSFORM_OBJ)) {
float mat[4][4], size_mat[4][4], size[3];
normalize_qt(rbo->orn); // RB_TODO investigate why quaternion isn't normalized at this point
@@ -1748,7 +1766,8 @@ void BKE_rigidbody_aftertrans_update(
}
RB_body_set_loc_rot(rbo->shared->physics_object, rbo->pos, rbo->orn);
}
- // RB_TODO update rigid body physics object's loc/rot for dynamic objects here as well (needs to be done outside bullet's update loop)
+ /* RB_TODO update rigid body physics object's loc/rot for dynamic objects here as well
+ * (needs to be done outside bullet's update loop). */
}
void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw)
@@ -1773,7 +1792,8 @@ void BKE_rigidbody_rebuild_world(Depsgraph *depsgraph, Scene *scene, float ctime
BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL);
cache = rbw->shared->pointcache;
- /* flag cache as outdated if we don't have a world or number of objects in the simulation has changed */
+ /* Flag cache as outdated if we don't have a world or number of objects
+ * in the simulation has changed. */
int n = 0;
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->group, object) {
(void)object;
@@ -1854,7 +1874,8 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
/* calculate how much time elapsed since last step in seconds */
timestep = 1.0f / (float)FPS * (ctime - rbw->ltime) * rbw->time_scale;
- /* step simulation by the requested timestep, steps per second are adjusted to take time scale into account */
+ /* Step simulation by the requested timestep,
+ * steps per second are adjusted to take time scale into account. */
RB_dworld_step_simulation(rbw->shared->physics_world,
timestep,
INT_MAX,
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index bc67046b9a9..8a70db8704f 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -37,6 +37,7 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_sequence_types.h"
+#include "DNA_sound_types.h"
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
@@ -225,8 +226,10 @@ void BKE_toolsettings_free(ToolSettings *toolsettings)
}
/**
- * Only copy internal data of Scene ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Scene ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -306,8 +309,7 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons
flag_subdata);
}
- /* before scene copy */
- BKE_sound_create_scene(sce_dst);
+ BKE_sound_reset_scene_runtime(sce_dst);
/* Copy sequencer, this is local data! */
if (sce_src->ed) {
@@ -397,8 +399,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
sce_copy->r.ffcodecdata.properties = IDP_CopyProperty(sce->r.ffcodecdata.properties);
}
- /* before scene copy */
- BKE_sound_create_scene(sce_copy);
+ BKE_sound_reset_scene_runtime(sce_copy);
/* grease pencil */
sce_copy->gpd = NULL;
@@ -412,7 +413,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
id_us_min(&sce_copy->id);
id_us_ensure_real(&sce_copy->id);
- /* Extra actions, most notably SCE_FULL_COPY also duplicates several 'children' datablocks... */
+ /* Extra actions, most notably SCE_FULL_COPY also duplicates several 'children' datablocks. */
if (type == SCE_COPY_FULL) {
/* Copy Freestyle LineStyle datablocks. */
@@ -564,7 +565,7 @@ void BKE_scene_init(Scene *sce)
sce->cursor.rotation_quaternion[0] = 1.0f;
sce->cursor.rotation_axis[1] = 1.0f;
- sce->r.mode = R_OSA;
+ sce->r.mode = 0;
sce->r.cfra = 1;
sce->r.sfra = 1;
sce->r.efra = 250;
@@ -765,9 +766,9 @@ void BKE_scene_init(Scene *sce)
BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic));
BLI_rctf_init(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f);
- sce->r.osa = 8;
- /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */
+ /* Note; in header_info.c the scene copy happens...,
+ * if you add more to renderdata it has to be checked there. */
/* multiview - stereo */
BKE_scene_add_render_view(sce, STEREO_LEFT_NAME);
@@ -778,7 +779,7 @@ void BKE_scene_init(Scene *sce)
srv = sce->r.views.last;
BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
- BKE_sound_create_scene(sce);
+ BKE_sound_reset_scene_runtime(sce);
/* color management */
colorspace_name = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_SEQUENCER);
@@ -902,6 +903,9 @@ void BKE_scene_init(Scene *sce)
sce->display.matcap_ssao_attenuation = 1.0f;
sce->display.matcap_ssao_samples = 16;
+ sce->display.render_aa = SCE_DISPLAY_AA_SAMPLES_8;
+ sce->display.viewport_aa = SCE_DISPLAY_AA_FXAA;
+
/* OpenGL Render. */
BKE_screen_view3d_shading_init(&sce->display.shading);
@@ -1029,7 +1033,8 @@ Object *BKE_scene_object_find_by_name(Scene *scene, const char *name)
}
/**
- * Sets the active scene, mainly used when running in background mode (``--scene`` command line argument).
+ * Sets the active scene, mainly used when running in background mode
+ * (``--scene`` command line argument).
* This is also called to set the scene directly, bypassing windowing code.
* Otherwise #WM_window_set_active_scene is used when changing scenes by the user.
*/
@@ -1054,7 +1059,8 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
BKE_scene_object_base_flag_sync_from_base(base);
}
}
- /* no full animation update, this to enable render code to work (render code calls own animation updates) */
+ /* No full animation update, this to enable render code to work
+ * (render code calls own animation updates). */
}
/* called from creator_args.c */
@@ -1071,7 +1077,8 @@ Scene *BKE_scene_set_name(Main *bmain, const char *name)
return NULL;
}
-/* Used by metaballs, return *all* objects (including duplis) existing in the scene (including scene's sets) */
+/* Used by metaballs, return *all* objects (including duplis)
+ * existing in the scene (including scene's sets). */
int BKE_scene_base_iter_next(
Depsgraph *depsgraph, SceneBaseIter *iter, Scene **scene, int val, Base **base, Object **ob)
{
@@ -1357,8 +1364,10 @@ bool BKE_scene_validate_setscene(Main *bmain, Scene *sce)
return true;
}
-/* This function is needed to cope with fractional frames - including two Blender rendering features
- * mblur (motion blur that renders 'subframes' and blurs them together), and fields rendering.
+/**
+ * This function is needed to cope with fractional frames - including two Blender rendering
+ * features mblur (motion blur that renders 'subframes' and blurs them together),
+ * and fields rendering.
*/
float BKE_scene_frame_get(const Scene *scene)
{
@@ -1521,6 +1530,13 @@ static void prepare_mesh_for_viewport_render(Main *bmain, const ViewLayer *view_
}
}
+static void scene_update_sound(Depsgraph *depsgraph, Main *bmain)
+{
+ Scene *scene = DEG_get_evaluated_scene(depsgraph);
+ BKE_sound_ensure_scene(scene);
+ BKE_sound_update_scene(bmain, scene);
+}
+
/* TODO(sergey): This actually should become view_layer_graph or so.
* Same applies to update_for_newframe.
*/
@@ -1549,10 +1565,9 @@ void BKE_scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain)
* by depgraph or manual, no layer check here, gets correct flushed.
*/
DEG_evaluate_on_refresh(depsgraph);
- /* Update sound system animation (TODO, move to depsgraph). */
- BKE_sound_update_scene(bmain, scene);
-
- /* Notify python about depsgraph update */
+ /* Update sound system. */
+ scene_update_sound(depsgraph, bmain);
+ /* Notify python about depsgraph update. */
if (run_callbacks) {
BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_DEPSGRAPH_UPDATE_POST);
}
@@ -1580,15 +1595,6 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain)
BKE_image_editors_update_frame(bmain, scene->r.cfra);
BKE_sound_set_cfra(scene->r.cfra);
DEG_graph_relations_update(depsgraph, bmain, scene, view_layer);
- /* Update animated cache files for modifiers.
- *
- * TODO(sergey): Make this a depsgraph node?
- */
- BKE_cachefile_update_frame(bmain,
- depsgraph,
- scene,
- ctime,
- (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base));
#ifdef POSE_ANIMATION_WORKAROUND
scene_armature_depsgraph_workaround(bmain, depsgraph);
#endif
@@ -1596,8 +1602,8 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain)
* by depgraph or manual, no layer check here, gets correct flushed.
*/
DEG_evaluate_on_framechange(bmain, depsgraph, ctime);
- /* Update sound system animation (TODO, move to depsgraph). */
- BKE_sound_update_scene(bmain, scene);
+ /* Update sound system animation. */
+ scene_update_sound(depsgraph, bmain);
/* Notify editors and python about recalc. */
BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_FRAME_CHANGE_POST);
/* Inform editors about possible changes. */
@@ -1608,8 +1614,8 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain)
/** Ensures given scene/view_layer pair has a valid, up-to-date depsgraph.
*
- * \warning Sets matching depsgraph as active, so should only be called from the active editing context
- * (usually, from operators).
+ * \warning Sets matching depsgraph as active,
+ * so should only be called from the active editing context (usually, from operators).
*/
void BKE_scene_view_layer_graph_evaluated_ensure(Main *bmain, Scene *scene, ViewLayer *view_layer)
{
@@ -1766,31 +1772,20 @@ void BKE_scene_base_flag_to_objects(ViewLayer *view_layer)
}
}
+/**
+ * Synchronize object base flags
+ *
+ * This is usually handled by the depsgraph.
+ * However, in rare occasions we need to use the latest object flags
+ * before depsgraph is fully updated.
+ *
+ * It should (ideally) only run for copy-on-written objects since this is
+ * runtime data generated per-viewlayer.
+ */
void BKE_scene_object_base_flag_sync_from_base(Base *base)
{
Object *ob = base->object;
-
- ob->flag = base->flag;
-
- if ((base->flag & BASE_SELECTED) != 0) {
- ob->flag |= SELECT;
- }
- else {
- ob->flag &= ~SELECT;
- }
-}
-
-void BKE_scene_object_base_flag_sync_from_object(Base *base)
-{
- Object *ob = base->object;
- base->flag = ob->flag;
-
- if ((ob->flag & SELECT) != 0 && (base->flag & BASE_SELECTABLE) != 0) {
- base->flag |= BASE_SELECTED;
- }
- else {
- base->flag &= ~BASE_SELECTED;
- }
+ ob->base_flag = base->flag;
}
void BKE_scene_disable_color_management(Scene *scene)
@@ -1859,8 +1854,9 @@ int BKE_render_preview_pixel_size(const RenderData *r)
return r->preview_pixel_size;
}
-/* Apply the needed correction factor to value, based on unit_type (only length-related are affected currently)
- * and unit->scale_length.
+/**
+ * Apply the needed correction factor to value, based on unit_type
+ * (only length-related are affected currently) and unit->scale_length.
*/
double BKE_scene_unit_scale(const UnitSettings *unit, const int unit_type, double value)
{
@@ -2321,7 +2317,8 @@ TransformOrientation *BKE_scene_transform_orientation_find(const Scene *scene, c
}
/**
- * \return the index that \a orientation has within \a scene's transform-orientation list or -1 if not found.
+ * \return the index that \a orientation has within \a scene's transform-orientation list
+ * or -1 if not found.
*/
int BKE_scene_transform_orientation_get_index(const Scene *scene,
const TransformOrientation *orientation)
@@ -2418,3 +2415,23 @@ void BKE_scene_cursor_quat_to_rot(View3DCursor *cursor, const float quat[4], boo
}
/** \} */
+
+/* Dependency graph evaluation. */
+
+void BKE_scene_eval_sequencer_sequences(Depsgraph *depsgraph, Scene *scene)
+{
+ DEG_debug_print_eval(depsgraph, __func__, scene->id.name, scene);
+ if (scene->ed == NULL) {
+ return;
+ }
+ BKE_sound_ensure_scene(scene);
+ Sequence *seq;
+ SEQ_BEGIN (scene->ed, seq) {
+ if (seq->sound != NULL && seq->scene_sound == NULL) {
+ seq->scene_sound = BKE_sound_add_scene_sound_defaults(scene, seq);
+ }
+ }
+ SEQ_END;
+ BKE_sequencer_update_muting(scene->ed);
+ BKE_sequencer_update_sound_bounds_all(scene);
+}
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index a3ec3364436..9799f7c2943 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -308,7 +308,8 @@ 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.
+ * 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)
{
diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c
index b022819ca8c..1c0aa63f590 100644
--- a/source/blender/blenkernel/intern/seqcache.c
+++ b/source/blender/blenkernel/intern/seqcache.c
@@ -21,49 +21,84 @@
*/
#include <stddef.h>
-
-#include "BLI_sys_types.h" /* for intptr_t */
+#include <memory.h>
#include "MEM_guardedalloc.h"
#include "DNA_sequence_types.h"
#include "DNA_scene_types.h"
-#include "IMB_moviecache.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "BLI_mempool.h"
+#include "BLI_threads.h"
#include "BLI_listbase.h"
+#include "BLI_ghash.h"
#include "BKE_sequencer.h"
#include "BKE_scene.h"
+#include "BKE_main.h"
+
+/* ***************************** Sequencer cache design notes ******************************
+ *
+ * Cache key members:
+ * is_temp_cache - this cache entry will be freed before rendering next frame
+ * creator_id - ID of thread that created entry
+ * cost - In short: render time divided by playback frame rate
+ * link_prev/next - link to another entry created during rendering of the frame
+ *
+ * Linking: We use links to reduce number of iterations needed to manage cache.
+ * Entries are linked in order as they are put into cache.
+ * Only pernament (is_temp_cache = 0) cache entries are linked.
+ * Putting SEQ_CACHE_STORE_FINAL_OUT will reset linking
+ *
+ * Function:
+ * All images created during rendering are added to cache, even if the cache is already full.
+ * This is because:
+ * - one image may be needed multiple times during rendering.
+ * - keeping the last rendered frame allows us for faster re-render when user edits strip in stack
+ * - we can decide if we keep frame only when it's completely rendered. Otherwise we risk having
+ * "holes" in the cache, which can be annoying
+ * If the cache is full all entries for pending frame will have is_temp_cache set.
+ *
+ * Only entire frame can be freed to release resources for new entries (recycling).
+ * Once again, this is to reduce number of iterations, but also more controllable than removing
+ * entries one by one in reverse order to their creation.
+ *
+ * User can exclude caching of some images. Such entries will have is_temp_cache set.
+ */
+
+typedef struct SeqCache {
+ struct GHash *hash;
+ ThreadMutex iterator_mutex;
+ struct BLI_mempool *keys_pool;
+ struct BLI_mempool *items_pool;
+ struct SeqCacheKey *last_key;
+ size_t memory_used;
+} SeqCache;
+
+typedef struct SeqCacheItem {
+ struct SeqCache *cache_owner;
+ struct ImBuf *ibuf;
+} SeqCacheItem;
typedef struct SeqCacheKey {
+ struct SeqCache *cache_owner;
+ void *userkey;
+ struct SeqCacheKey *link_prev; /* Used for linking intermediate items to final frame */
+ struct SeqCacheKey *link_next; /* Used for linking intermediate items to final frame */
struct Sequence *seq;
SeqRenderData context;
float cfra;
- eSeqStripElemIBuf type;
+ float nfra;
+ float cost;
+ bool is_temp_cache;
+ short creator_id;
+ int type;
} SeqCacheKey;
-typedef struct SeqPreprocessCacheElem {
- struct SeqPreprocessCacheElem *next, *prev;
-
- struct Sequence *seq;
- SeqRenderData context;
- eSeqStripElemIBuf type;
-
- ImBuf *ibuf;
-} SeqPreprocessCacheElem;
-
-typedef struct SeqPreprocessCache {
- int cfra;
- ListBase elems;
-} SeqPreprocessCache;
-
-static struct MovieCache *moviecache = NULL;
-static struct SeqPreprocessCache *preprocess_cache = NULL;
-
-static void preprocessed_cache_destruct(void);
+static ThreadMutex cache_create_lock = BLI_MUTEX_INITIALIZER;
static bool seq_cmp_render_data(const SeqRenderData *a, const SeqRenderData *b)
{
@@ -88,209 +123,536 @@ static unsigned int seq_hash_render_data(const SeqRenderData *a)
return rval;
}
-static unsigned int seqcache_hashhash(const void *key_)
+static unsigned int seq_cache_hashhash(const void *key_)
{
const SeqCacheKey *key = key_;
unsigned int rval = seq_hash_render_data(&key->context);
- rval ^= *(const unsigned int *)&key->cfra;
+ rval ^= *(const unsigned int *)&key->nfra;
rval += key->type;
rval ^= ((intptr_t)key->seq) << 6;
return rval;
}
-static bool seqcache_hashcmp(const void *a_, const void *b_)
+static bool seq_cache_hashcmp(const void *a_, const void *b_)
{
const SeqCacheKey *a = a_;
const SeqCacheKey *b = b_;
- return ((a->seq != b->seq) || (a->cfra != b->cfra) || (a->type != b->type) ||
+ return ((a->seq != b->seq) || (a->nfra != b->nfra) || (a->type != b->type) ||
seq_cmp_render_data(&a->context, &b->context));
}
-void BKE_sequencer_cache_destruct(void)
+static SeqCache *seq_cache_get_from_scene(Scene *scene)
{
- if (moviecache) {
- IMB_moviecache_free(moviecache);
+ if (scene && scene->ed && scene->ed->cache) {
+ return scene->ed->cache;
}
- preprocessed_cache_destruct();
+ return NULL;
+}
+
+static void seq_cache_lock(Scene *scene)
+{
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+
+ if (cache) {
+ BLI_mutex_lock(&cache->iterator_mutex);
+ }
}
-void BKE_sequencer_cache_cleanup(void)
+static void seq_cache_unlock(Scene *scene)
{
- if (moviecache) {
- IMB_moviecache_free(moviecache);
- moviecache = IMB_moviecache_create(
- "seqcache", sizeof(SeqCacheKey), seqcache_hashhash, seqcache_hashcmp);
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+
+ if (cache) {
+ BLI_mutex_unlock(&cache->iterator_mutex);
}
+}
- BKE_sequencer_preprocessed_cache_cleanup();
+static void seq_cache_keyfree(void *val)
+{
+ SeqCacheKey *key = val;
+ BLI_mempool_free(key->cache_owner->keys_pool, key);
}
-static bool seqcache_key_check_seq(ImBuf *UNUSED(ibuf), void *userkey, void *userdata)
+static void seq_cache_valfree(void *val)
{
- SeqCacheKey *key = (SeqCacheKey *)userkey;
- Sequence *seq = (Sequence *)userdata;
+ SeqCacheItem *item = (SeqCacheItem *)val;
+ SeqCache *cache = item->cache_owner;
+
+ if (item->ibuf) {
+ cache->memory_used -= IMB_get_size_in_memory(item->ibuf);
+ IMB_freeImBuf(item->ibuf);
+ }
- return key->seq == seq;
+ BLI_mempool_free(item->cache_owner->items_pool, item);
}
-void BKE_sequencer_cache_cleanup_sequence(Sequence *seq)
+static void seq_cache_put(SeqCache *cache, SeqCacheKey *key, ImBuf *ibuf)
{
- if (moviecache) {
- IMB_moviecache_cleanup(moviecache, seqcache_key_check_seq, seq);
+ SeqCacheItem *item;
+ item = BLI_mempool_alloc(cache->items_pool);
+ item->cache_owner = cache;
+ item->ibuf = ibuf;
+
+ if (BLI_ghash_reinsert(cache->hash, key, item, seq_cache_keyfree, seq_cache_valfree)) {
+ IMB_refImBuf(ibuf);
+ cache->last_key = key;
+ cache->memory_used += IMB_get_size_in_memory(ibuf);
}
}
-struct ImBuf *BKE_sequencer_cache_get(const SeqRenderData *context,
- Sequence *seq,
- float cfra,
- eSeqStripElemIBuf type)
+static ImBuf *seq_cache_get(SeqCache *cache, void *key)
{
- if (moviecache && seq) {
- SeqCacheKey key;
+ SeqCacheItem *item = BLI_ghash_lookup(cache->hash, key);
- key.seq = seq;
- key.context = *context;
- key.cfra = cfra - seq->start;
- key.type = type;
+ if (item && item->ibuf) {
+ IMB_refImBuf(item->ibuf);
- return IMB_moviecache_get(moviecache, &key);
+ return item->ibuf;
}
return NULL;
}
-void BKE_sequencer_cache_put(
- const SeqRenderData *context, Sequence *seq, float cfra, eSeqStripElemIBuf type, ImBuf *i)
+static void seq_cache_relink_keys(SeqCacheKey *link_next, SeqCacheKey *link_prev)
+{
+ if (link_next) {
+ link_next->link_prev = link_prev;
+ }
+ if (link_prev) {
+ link_prev->link_next = link_next;
+ }
+}
+
+static SeqCacheKey *seq_cache_choose_key(Scene *scene, SeqCacheKey *lkey, SeqCacheKey *rkey)
{
- SeqCacheKey key;
+ SeqCacheKey *finalkey = NULL;
+
+ if (rkey && lkey) {
+ if (lkey->cfra > rkey->cfra) {
+ SeqCacheKey *swapkey = lkey;
+ lkey = rkey;
+ rkey = swapkey;
+ }
+
+ int l_diff = scene->r.cfra - lkey->cfra;
+ int r_diff = rkey->cfra - scene->r.cfra;
+
+ if (l_diff > r_diff) {
+ finalkey = lkey;
+ }
+ else {
+ finalkey = rkey;
+ }
+ }
+ else {
+ if (lkey) {
+ finalkey = lkey;
+ }
+ else {
+ finalkey = rkey;
+ }
+ }
+ return finalkey;
+}
- if (i == NULL || context->skip_cache) {
+static void seq_cache_recycle_linked(Scene *scene, SeqCacheKey *base)
+{
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
return;
}
- if (!moviecache) {
- moviecache = IMB_moviecache_create(
- "seqcache", sizeof(SeqCacheKey), seqcache_hashhash, seqcache_hashcmp);
+ SeqCacheKey *next = base->link_next;
+
+ while (base) {
+ SeqCacheKey *prev = base->link_prev;
+ BLI_ghash_remove(cache->hash, base, seq_cache_keyfree, seq_cache_valfree);
+ base = prev;
+ }
+
+ base = next;
+ while (base) {
+ next = base->link_next;
+ BLI_ghash_remove(cache->hash, base, seq_cache_keyfree, seq_cache_valfree);
+ base = next;
+ }
+}
+
+static SeqCacheKey *seq_cache_get_item_for_removal(Scene *scene)
+{
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ SeqCacheKey *finalkey = NULL;
+ /*leftmost key*/
+ SeqCacheKey *lkey = NULL;
+ /*rightmost key*/
+ SeqCacheKey *rkey = NULL;
+ SeqCacheKey *key = NULL;
+
+ GHashIterator gh_iter;
+ BLI_ghashIterator_init(&gh_iter, cache->hash);
+ int total_count = 0;
+ int cheap_count = 0;
+
+ while (!BLI_ghashIterator_done(&gh_iter)) {
+ key = BLI_ghashIterator_getKey(&gh_iter);
+ SeqCacheItem *item = BLI_ghashIterator_getValue(&gh_iter);
+ BLI_ghashIterator_step(&gh_iter);
+
+ /* this shouldn't happen, but better be safe than sorry */
+ if (!item->ibuf) {
+ seq_cache_recycle_linked(scene, key);
+ /* can not continue iterating after linked remove */
+ BLI_ghashIterator_init(&gh_iter, cache->hash);
+ continue;
+ }
+
+ if (key->is_temp_cache || key->link_next != NULL) {
+ continue;
+ }
+
+ total_count++;
+
+ if (key->cost <= scene->ed->recycle_max_cost) {
+ cheap_count++;
+ if (lkey) {
+ if (key->cfra < lkey->cfra) {
+ lkey = key;
+ }
+ }
+ else {
+ lkey = key;
+ }
+ if (rkey) {
+ if (key->cfra > rkey->cfra) {
+ rkey = key;
+ }
+ }
+ else {
+ rkey = key;
+ }
+ }
+ }
+
+ finalkey = seq_cache_choose_key(scene, lkey, rkey);
+ return finalkey;
+}
+
+/* Find only "base" keys
+ * Sources(other types) for a frame must be freed all at once
+ */
+static bool seq_cache_recycle_item(Scene *scene)
+{
+ size_t memory_total = ((size_t)U.memcachelimit) * 1024 * 1024;
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
+ return false;
}
- key.seq = seq;
- key.context = *context;
- key.cfra = cfra - seq->start;
- key.type = type;
+ seq_cache_lock(scene);
+
+ while (cache->memory_used > memory_total) {
+ SeqCacheKey *finalkey = seq_cache_get_item_for_removal(scene);
- IMB_moviecache_put(moviecache, &key, i);
+ if (finalkey) {
+ seq_cache_recycle_linked(scene, finalkey);
+ }
+ else {
+ seq_cache_unlock(scene);
+ return false;
+ }
+ }
+ seq_cache_unlock(scene);
+ return true;
}
-void BKE_sequencer_preprocessed_cache_cleanup(void)
+static void seq_cache_set_temp_cache_linked(Scene *scene, SeqCacheKey *base)
{
- SeqPreprocessCacheElem *elem;
+ SeqCache *cache = seq_cache_get_from_scene(scene);
- if (!preprocess_cache) {
+ if (!cache || !base) {
return;
}
- for (elem = preprocess_cache->elems.first; elem; elem = elem->next) {
- IMB_freeImBuf(elem->ibuf);
+ SeqCacheKey *next = base->link_next;
+
+ while (base) {
+ SeqCacheKey *prev = base->link_prev;
+ base->is_temp_cache = true;
+ base = prev;
}
- BLI_freelistN(&preprocess_cache->elems);
- BLI_listbase_clear(&preprocess_cache->elems);
+ base = next;
+ while (base) {
+ next = base->link_next;
+ base->is_temp_cache = true;
+ base = next;
+ }
}
-static void preprocessed_cache_destruct(void)
+static void BKE_sequencer_cache_create(Scene *scene)
{
- if (!preprocess_cache) {
+ BLI_mutex_lock(&cache_create_lock);
+ if (scene->ed->cache == NULL) {
+ SeqCache *cache = MEM_callocN(sizeof(SeqCache), "SeqCache");
+ cache->keys_pool = BLI_mempool_create(sizeof(SeqCacheKey), 0, 64, BLI_MEMPOOL_NOP);
+ cache->items_pool = BLI_mempool_create(sizeof(SeqCacheItem), 0, 64, BLI_MEMPOOL_NOP);
+ cache->hash = BLI_ghash_new(seq_cache_hashhash, seq_cache_hashcmp, "SeqCache hash");
+ cache->last_key = NULL;
+ BLI_mutex_init(&cache->iterator_mutex);
+ scene->ed->cache = cache;
+ }
+ BLI_mutex_unlock(&cache_create_lock);
+}
+
+/* ***************************** API ****************************** */
+
+void BKE_sequencer_cache_free_temp_cache(Scene *scene, short id, int cfra)
+{
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
return;
}
- BKE_sequencer_preprocessed_cache_cleanup();
+ seq_cache_lock(scene);
- MEM_freeN(preprocess_cache);
- preprocess_cache = NULL;
+ GHashIterator gh_iter;
+ BLI_ghashIterator_init(&gh_iter, cache->hash);
+ while (!BLI_ghashIterator_done(&gh_iter)) {
+ SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
+ BLI_ghashIterator_step(&gh_iter);
+
+ if (key->is_temp_cache && key->creator_id == id && key->cfra != cfra) {
+ BLI_ghash_remove(cache->hash, key, seq_cache_keyfree, seq_cache_valfree);
+ }
+ }
+ seq_cache_unlock(scene);
}
-ImBuf *BKE_sequencer_preprocessed_cache_get(const SeqRenderData *context,
- Sequence *seq,
- float cfra,
- eSeqStripElemIBuf type)
+void BKE_sequencer_cache_destruct(Scene *scene)
{
- SeqPreprocessCacheElem *elem;
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
+ return;
+ }
- if (!preprocess_cache) {
- return NULL;
+ BLI_ghash_free(cache->hash, seq_cache_keyfree, seq_cache_valfree);
+ BLI_mempool_destroy(cache->keys_pool);
+ BLI_mempool_destroy(cache->items_pool);
+ BLI_mutex_end(&cache->iterator_mutex);
+ MEM_freeN(cache);
+ scene->ed->cache = NULL;
+}
+
+void BKE_sequencer_cache_cleanup_all(Main *bmain)
+{
+ for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
+ BKE_sequencer_cache_cleanup(scene);
+ }
+}
+void BKE_sequencer_cache_cleanup(Scene *scene)
+{
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
+ return;
}
- if (preprocess_cache->cfra != cfra) {
- return NULL;
+ seq_cache_lock(scene);
+
+ GHashIterator gh_iter;
+ BLI_ghashIterator_init(&gh_iter, cache->hash);
+ while (!BLI_ghashIterator_done(&gh_iter)) {
+ SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
+
+ BLI_ghashIterator_step(&gh_iter);
+ BLI_ghash_remove(cache->hash, key, seq_cache_keyfree, seq_cache_valfree);
}
+ cache->last_key = NULL;
+ seq_cache_unlock(scene);
+}
- for (elem = preprocess_cache->elems.first; elem; elem = elem->next) {
- if (elem->seq != seq) {
- continue;
- }
+void BKE_sequencer_cache_cleanup_sequence(Scene *scene, Sequence *seq)
+{
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
+ return;
+ }
- if (elem->type != type) {
- continue;
- }
+ seq_cache_lock(scene);
- if (seq_cmp_render_data(&elem->context, context) != 0) {
- continue;
+ GHashIterator gh_iter;
+ BLI_ghashIterator_init(&gh_iter, cache->hash);
+ while (!BLI_ghashIterator_done(&gh_iter)) {
+ SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
+ BLI_ghashIterator_step(&gh_iter);
+
+ if (key->seq == seq) {
+ /* Relink keys, so we don't end up with orphaned keys */
+ if (key->link_next || key->link_prev) {
+ seq_cache_relink_keys(key->link_next, key->link_prev);
+ }
+
+ BLI_ghash_remove(cache->hash, key, seq_cache_keyfree, seq_cache_valfree);
}
+ }
+ cache->last_key = NULL;
+ seq_cache_unlock(scene);
+}
+
+struct ImBuf *BKE_sequencer_cache_get(const SeqRenderData *context,
+ Sequence *seq,
+ float cfra,
+ int type)
+{
+ Scene *scene = context->scene;
- IMB_refImBuf(elem->ibuf);
- return elem->ibuf;
+ if (!scene->ed->cache) {
+ BKE_sequencer_cache_create(scene);
+ return NULL;
}
- return NULL;
+ seq_cache_lock(scene);
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ ImBuf *ibuf = NULL;
+
+ if (cache && seq) {
+ SeqCacheKey key;
+
+ key.seq = seq;
+ key.context = *context;
+ key.nfra = cfra - seq->start;
+ key.type = type;
+
+ ibuf = seq_cache_get(cache, &key);
+ }
+ seq_cache_unlock(scene);
+
+ return ibuf;
}
-void BKE_sequencer_preprocessed_cache_put(
- const SeqRenderData *context, Sequence *seq, float cfra, eSeqStripElemIBuf type, ImBuf *ibuf)
+bool BKE_sequencer_cache_put_if_possible(
+ const SeqRenderData *context, Sequence *seq, float cfra, int type, ImBuf *ibuf, float cost)
{
- SeqPreprocessCacheElem *elem;
+ Scene *scene = context->scene;
- if (!preprocess_cache) {
- preprocess_cache = MEM_callocN(sizeof(SeqPreprocessCache), "sequencer preprocessed cache");
+ if (seq_cache_recycle_item(scene)) {
+ BKE_sequencer_cache_put(context, seq, cfra, type, ibuf, cost);
+ return true;
}
else {
- if (preprocess_cache->cfra != cfra) {
- BKE_sequencer_preprocessed_cache_cleanup();
- }
+ seq_cache_set_temp_cache_linked(scene, scene->ed->cache->last_key);
+ scene->ed->cache->last_key = NULL;
+ return false;
}
+}
+
+void BKE_sequencer_cache_put(
+ const SeqRenderData *context, Sequence *seq, float cfra, int type, ImBuf *i, float cost)
+{
+ Scene *scene = context->scene;
+ short creator_id = 0;
- elem = MEM_callocN(sizeof(SeqPreprocessCacheElem), "sequencer preprocessed cache element");
+ if (i == NULL || context->skip_cache || context->is_proxy_render || !seq) {
+ return;
+ }
- elem->seq = seq;
- elem->type = type;
- elem->context = *context;
- elem->ibuf = ibuf;
+ /* Prevent reinserting, it breaks cache key linking */
+ ImBuf *test = BKE_sequencer_cache_get(context, seq, cfra, type);
+ if (test) {
+ IMB_freeImBuf(test);
+ return;
+ }
- preprocess_cache->cfra = cfra;
+ if (!scene->ed->cache) {
+ BKE_sequencer_cache_create(scene);
+ }
- IMB_refImBuf(ibuf);
+ seq_cache_lock(scene);
- BLI_addtail(&preprocess_cache->elems, elem);
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ int flag;
+
+ if (seq->cache_flag & SEQ_CACHE_OVERRIDE) {
+ flag = seq->cache_flag;
+ flag |= scene->ed->cache_flag & SEQ_CACHE_STORE_FINAL_OUT;
+ }
+ else {
+ flag = scene->ed->cache_flag;
+ }
+
+ if (cost > SEQ_CACHE_COST_MAX) {
+ cost = SEQ_CACHE_COST_MAX;
+ }
+
+ SeqCacheKey *key;
+ key = BLI_mempool_alloc(cache->keys_pool);
+ key->cache_owner = cache;
+ key->seq = seq;
+ key->context = *context;
+ key->cfra = cfra;
+ key->nfra = cfra - seq->start;
+ key->type = type;
+ key->cost = cost;
+ key->cache_owner = cache;
+ key->link_prev = NULL;
+ key->link_next = NULL;
+ key->is_temp_cache = true;
+ key->creator_id = creator_id;
+
+ /* Item stored for later use */
+ if (flag & type) {
+ key->is_temp_cache = false;
+ key->link_prev = cache->last_key;
+ }
+
+ SeqCacheKey *temp_last_key = cache->last_key;
+ seq_cache_put(cache, key, i);
+
+ /* Restore pointer to previous item as this one will be freed when stack is rendered */
+ if (key->is_temp_cache) {
+ cache->last_key = temp_last_key;
+ }
+
+ /* Set last_key's reference to this key so we can look up chain backwards
+ * Item is already put in cache, so cache->last_key points to current key;
+ */
+ if (flag & type && temp_last_key) {
+ temp_last_key->link_next = cache->last_key;
+ }
+
+ /* Reset linking */
+ if (key->type == SEQ_CACHE_STORE_FINAL_OUT) {
+ cache->last_key = NULL;
+ }
+
+ seq_cache_unlock(scene);
}
-void BKE_sequencer_preprocessed_cache_cleanup_sequence(Sequence *seq)
+void BKE_sequencer_cache_iterate(
+ struct Scene *scene,
+ void *userdata,
+ bool callback(void *userdata, struct Sequence *seq, int cfra, int cache_type, float cost))
{
- SeqPreprocessCacheElem *elem, *elem_next;
-
- if (!preprocess_cache) {
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
return;
}
- for (elem = preprocess_cache->elems.first; elem; elem = elem_next) {
- elem_next = elem->next;
+ seq_cache_lock(scene);
+ GHashIterator gh_iter;
+ BLI_ghashIterator_init(&gh_iter, cache->hash);
+ bool interrupt = false;
- if (elem->seq == seq) {
- IMB_freeImBuf(elem->ibuf);
+ while (!BLI_ghashIterator_done(&gh_iter) && !interrupt) {
+ SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
+ BLI_ghashIterator_step(&gh_iter);
- BLI_freelinkN(&preprocess_cache->elems, elem);
- }
+ interrupt = callback(userdata, key->seq, key->cfra, key->type, key->cost);
}
+
+ cache->last_key = NULL;
+ seq_cache_unlock(scene);
}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index b2d5609ad07..74541c13c4f 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -27,7 +27,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#include <math.h>
+#include <time.h>
#include "MEM_guardedalloc.h"
@@ -273,7 +273,8 @@ static void BKE_sequence_free_ex(Scene *scene,
* also invalidate cache for all dependent sequences
*
* be _very_ careful here, invalidating cache loops over the scene sequences and
- * assumes the listbase is valid for all strips, this may not be the case if lists are being freed.
+ * assumes the listbase is valid for all strips,
+ * this may not be the case if lists are being freed.
* this is optional BKE_sequence_invalidate_cache
*/
if (do_cache) {
@@ -463,6 +464,11 @@ Editing *BKE_sequencer_editing_ensure(Scene *scene)
ed = scene->ed = MEM_callocN(sizeof(Editing), "addseq");
ed->seqbasep = &ed->seqbase;
+ ed->cache = NULL;
+ ed->cache_flag = SEQ_CACHE_STORE_FINAL_OUT;
+ ed->cache_flag |= SEQ_CACHE_VIEW_FINAL_OUT;
+ ed->cache_flag |= SEQ_CACHE_VIEW_ENABLE;
+ ed->recycle_max_cost = 10.0f;
}
return scene->ed;
@@ -477,8 +483,7 @@ void BKE_sequencer_editing_free(Scene *scene, const bool do_id_user)
return;
}
- /* this may not be the active scene!, could be smarter about this */
- BKE_sequencer_cache_cleanup();
+ BKE_sequencer_cache_destruct(scene);
SEQ_BEGIN (ed, seq) {
/* handle cache freeing above */
@@ -630,8 +635,6 @@ void BKE_sequencer_new_render_data(Main *bmain,
r_context->is_proxy_render = false;
r_context->view_id = 0;
r_context->gpu_offscreen = NULL;
- r_context->gpu_samples = (scene->r.mode & R_OSA) ? scene->r.osa : 0;
- r_context->gpu_full_samples = (r_context->gpu_samples) && (scene->r.scemode & R_FULL_SAMPLE);
}
/* ************************* iterator ************************** */
@@ -805,10 +808,7 @@ void BKE_sequence_calc_disp(Scene *scene, Sequence *seq)
seq->handsize = (float)((seq->enddisp - seq->startdisp) / 25);
}
- if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
- BKE_sequencer_update_sound_bounds(scene, seq);
- }
- else if (seq->type == SEQ_TYPE_META) {
+ if (seq->type == SEQ_TYPE_META) {
seq_update_sound_bounds_recursive(scene, seq);
}
}
@@ -1307,7 +1307,7 @@ ListBase *BKE_sequence_seqbase_get(Sequence *seq, int *r_offset)
break;
}
case SEQ_TYPE_SCENE: {
- if (seq->flag & SEQ_SCENE_STRIPS) {
+ if (seq->flag & SEQ_SCENE_STRIPS && seq->scene) {
Editing *ed = BKE_sequencer_editing_get(seq->scene, false);
if (ed) {
seqbase = &ed->seqbase;
@@ -2342,7 +2342,7 @@ static void color_balance_byte_byte(StripColorBalance *cb_,
int height,
float mul)
{
- //unsigned char cb_tab[3][256];
+ // unsigned char cb_tab[3][256];
unsigned char *cp = rect;
unsigned char *e = cp + width * 4 * height;
unsigned char *m = mask_rect;
@@ -2638,7 +2638,7 @@ bool BKE_sequencer_input_have_to_preprocess(const SeqRenderData *context,
{
float mul;
- if (context->is_proxy_render) {
+ if (context && context->is_proxy_render) {
return false;
}
@@ -2787,7 +2787,7 @@ static ImBuf *input_preprocess(const SeqRenderData *context,
}
if (ibuf->x != context->rectx || ibuf->y != context->recty) {
- if (scene->r.mode & R_OSA) {
+ if (scene->display.render_aa > SCE_DISPLAY_AA_FXAA) {
IMB_scaleImBuf(ibuf, (short)context->rectx, (short)context->recty);
}
else {
@@ -2808,54 +2808,6 @@ static ImBuf *input_preprocess(const SeqRenderData *context,
return ibuf;
}
-static ImBuf *copy_from_ibuf_still(const SeqRenderData *context, Sequence *seq, float nr)
-{
- ImBuf *rval = NULL;
- ImBuf *ibuf = NULL;
-
- if (nr == 0) {
- ibuf = BKE_sequencer_cache_get(context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL);
- }
- else if (nr == seq->len - 1) {
- ibuf = BKE_sequencer_cache_get(context, seq, seq->start, SEQ_STRIPELEM_IBUF_ENDSTILL);
- }
-
- if (ibuf) {
- rval = IMB_dupImBuf(ibuf);
- IMB_metadata_copy(rval, ibuf);
- IMB_freeImBuf(ibuf);
- }
-
- return rval;
-}
-
-static void copy_to_ibuf_still(const SeqRenderData *context, Sequence *seq, float nr, ImBuf *ibuf)
-{
- /* warning: ibuf may be NULL if the video fails to load */
- if (nr == 0 || nr == seq->len - 1) {
- /* we have to store a copy, since the passed ibuf
- * could be preprocessed afterwards (thereby silently
- * changing the cached image... */
- ImBuf *oibuf = ibuf;
- ibuf = IMB_dupImBuf(oibuf);
-
- if (ibuf) {
- IMB_metadata_copy(ibuf, oibuf);
- sequencer_imbuf_assign_spaces(context->scene, ibuf);
- }
-
- if (nr == 0) {
- BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf);
- }
-
- if (nr == seq->len - 1) {
- BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_ENDSTILL, ibuf);
- }
-
- IMB_freeImBuf(ibuf);
- }
-}
-
/*********************** strip rendering functions *************************/
typedef struct RenderEffectInitData {
@@ -3061,7 +3013,7 @@ static ImBuf *seq_render_effect_strip_impl(const SeqRenderData *context,
static ImBuf *seq_render_image_strip(const SeqRenderData *context,
Sequence *seq,
- float nr,
+ float UNUSED(nr),
float cfra)
{
ImBuf *ibuf = NULL;
@@ -3137,8 +3089,8 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context,
BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibufs_arr[i], false);
if (i != context->view_id) {
- copy_to_ibuf_still(&localcontext, seq, nr, ibufs_arr[i]);
- BKE_sequencer_cache_put(&localcontext, seq, cfra, SEQ_STRIPELEM_IBUF, ibufs_arr[i]);
+ BKE_sequencer_cache_put(
+ &localcontext, seq, cfra, SEQ_CACHE_STORE_PREPROCESSED, ibufs_arr[i], 0);
}
}
}
@@ -3252,8 +3204,8 @@ static ImBuf *seq_render_movie_strip(const SeqRenderData *context,
BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibuf_arr[i], false);
}
if (i != context->view_id) {
- copy_to_ibuf_still(&localcontext, seq, nr, ibuf_arr[i]);
- BKE_sequencer_cache_put(&localcontext, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf_arr[i]);
+ BKE_sequencer_cache_put(
+ &localcontext, seq, cfra, SEQ_CACHE_STORE_PREPROCESSED, ibuf_arr[i], 0);
}
}
@@ -3497,9 +3449,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
const bool is_rendering = G.is_rendering;
const bool is_background = G.background;
- const bool do_seq_gl = is_rendering ? 0 /* (context->scene->r.seq_flag & R_SEQ_GL_REND) */ :
- (context->scene->r.seq_prev_type) != OB_RENDER;
- // bool have_seq = false; /* UNUSED */
+ const bool do_seq_gl = is_rendering ? 0 : (context->scene->r.seq_prev_type) != OB_RENDER;
bool have_comp = false;
bool use_gpencil = true;
/* do we need to re-evaluate the frame after rendering? */
@@ -3515,7 +3465,9 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
scene = seq->scene;
frame = (double)scene->r.sfra + (double)nr + (double)seq->anim_startofs;
- // have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first); /* UNUSED */
+#if 0 /* UNUSED */
+ have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first);
+#endif
have_comp = (scene->r.scemode & R_DOCOMP) && scene->use_nodes && scene->nodetree;
/* Get view layer for the strip. */
@@ -3562,15 +3514,13 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
char err_out[256] = "unknown";
const int width = (scene->r.xsch * scene->r.size) / 100;
const int height = (scene->r.ysch * scene->r.size) / 100;
- const bool use_background = (scene->r.alphamode == R_ADDSKY);
const char *viewname = BKE_scene_multiview_render_view_name_get(&scene->r, context->view_id);
- unsigned int draw_flags = SEQ_OFSDRAW_NONE;
- draw_flags |= (use_gpencil) ? SEQ_OFSDRAW_USE_GPENCIL : 0;
- draw_flags |= (use_background) ? SEQ_OFSDRAW_USE_BACKGROUND : 0;
- draw_flags |= (context->gpu_full_samples) ? SEQ_OFSDRAW_USE_FULL_SAMPLE : 0;
- draw_flags |= (context->scene->r.seq_flag & R_SEQ_SOLID_TEX) ? SEQ_OFSDRAW_USE_SOLID_TEX : 0;
- draw_flags |= (context->scene->r.seq_flag & R_SEQ_CAMERA_DOF) ? SEQ_OFSDRAW_USE_CAMERA_DOF : 0;
+ unsigned int draw_flags = V3D_OFSDRAW_NONE;
+ draw_flags |= (use_gpencil) ? V3D_OFSDRAW_SHOW_ANNOTATION : 0;
+ draw_flags |= (context->scene->r.seq_flag & R_SEQ_OVERRIDE_SCENE_SETTINGS) ?
+ V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS :
+ 0;
/* for old scene this can be uninitialized,
* should probably be added to do_versions at some point if the functionality stays */
@@ -3585,6 +3535,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
/* set for OpenGL render (NULL when scrubbing) */
depsgraph,
scene,
+ &context->scene->display.shading,
context->scene->r.seq_prev_type,
camera,
width,
@@ -3592,7 +3543,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
IB_rect,
draw_flags,
scene->r.alphamode,
- context->gpu_samples,
+ 0, /* no aa samples */
viewname,
context->gpu_offscreen,
err_out);
@@ -3653,8 +3604,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
}
if (i != context->view_id) {
- copy_to_ibuf_still(&localcontext, seq, nr, ibufs_arr[i]);
- BKE_sequencer_cache_put(&localcontext, seq, cfra, SEQ_STRIPELEM_IBUF, ibufs_arr[i]);
+ BKE_sequencer_cache_put(&localcontext, seq, cfra, SEQ_CACHE_STORE_RAW, ibufs_arr[i], 0);
}
RE_ReleaseResultImage(re);
@@ -3684,7 +3634,7 @@ finally:
#ifdef DURIAN_CAMERA_SWITCH
/* stooping to new low's in hackyness :( */
- scene->r.mode &= ~(orig_data.mode & R_NO_CAMERA_SWITCH);
+ scene->r.mode &= orig_data.mode | ~R_NO_CAMERA_SWITCH;
#endif
return ibuf;
@@ -3706,6 +3656,12 @@ static ImBuf *do_render_strip_seqbase(const SeqRenderData *context,
seqbase = BKE_sequence_seqbase_get(seq, &offset);
if (seqbase && !BLI_listbase_is_empty(seqbase)) {
+
+ if (seq->flag & SEQ_SCENE_STRIPS && seq->scene) {
+ BKE_animsys_evaluate_all_animation(
+ context->bmain, context->depsgraph, seq->scene, nr + offset);
+ }
+
meta_ibuf = seq_render_strip_stack(context,
state,
seqbase,
@@ -3764,6 +3720,7 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
*/
SeqRenderData local_context = *context;
local_context.scene = seq->scene;
+ local_context.skip_cache = true;
ibuf = do_render_strip_seqbase(&local_context, state, seq, nr, use_preprocess);
@@ -3774,13 +3731,11 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
else {
/* scene can be NULL after deletions */
ibuf = seq_render_scene_strip(context, seq, nr, cfra);
+ }
- /* Scene strips update all animation, so we need to restore original state.*/
- BKE_animsys_evaluate_all_animation(
- context->bmain, context->depsgraph, context->scene, cfra);
+ /* Scene strips update all animation, so we need to restore original state.*/
+ BKE_animsys_evaluate_all_animation(context->bmain, context->depsgraph, context->scene, cfra);
- copy_to_ibuf_still(context, seq, nr, ibuf);
- }
break;
}
@@ -3817,13 +3772,11 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
case SEQ_TYPE_IMAGE: {
ibuf = seq_render_image_strip(context, seq, nr, cfra);
- copy_to_ibuf_still(context, seq, nr, ibuf);
break;
}
case SEQ_TYPE_MOVIE: {
ibuf = seq_render_movie_strip(context, seq, nr, cfra);
- copy_to_ibuf_still(context, seq, nr, ibuf);
break;
}
@@ -3839,8 +3792,6 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
if (ibuf->rect_float) {
BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibuf, false);
}
-
- copy_to_ibuf_still(context, seq, nr, ibuf);
}
break;
@@ -3849,8 +3800,6 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
case SEQ_TYPE_MASK: {
/* ibuf is always new */
ibuf = seq_render_mask_strip(context, seq, nr);
-
- copy_to_ibuf_still(context, seq, nr, ibuf);
break;
}
}
@@ -3862,6 +3811,26 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
return ibuf;
}
+/* Estimate time spent by the program rendering the strip */
+static clock_t seq_estimate_render_cost_begin(void)
+{
+ return clock();
+}
+
+static float seq_estimate_render_cost_end(Scene *scene, clock_t begin)
+{
+ clock_t end = clock();
+ float time_spent = (float)(end - begin);
+ float time_max = (1.0f / scene->r.frs_sec) * CLOCKS_PER_SEC;
+
+ if (time_max != 0) {
+ return time_spent / time_max;
+ }
+ else {
+ return 1;
+ }
+}
+
static ImBuf *seq_render_strip(const SeqRenderData *context,
SeqRenderState *state,
Sequence *seq,
@@ -3870,37 +3839,32 @@ static ImBuf *seq_render_strip(const SeqRenderData *context,
ImBuf *ibuf = NULL;
bool use_preprocess = false;
bool is_proxy_image = false;
- float nr = give_stripelem_index(seq, cfra);
/* all effects are handled similarly with the exception of speed effect */
int type = (seq->type & SEQ_TYPE_EFFECT && seq->type != SEQ_TYPE_SPEED) ? SEQ_TYPE_EFFECT :
seq->type;
bool is_preprocessed = !ELEM(
type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_SCENE, SEQ_TYPE_MOVIECLIP);
- ibuf = BKE_sequencer_cache_get(context, seq, cfra, SEQ_STRIPELEM_IBUF);
+ clock_t begin = seq_estimate_render_cost_begin();
- if (ibuf == NULL) {
- ibuf = copy_from_ibuf_still(context, seq, nr);
+ ibuf = BKE_sequencer_cache_get(context, seq, cfra, SEQ_CACHE_STORE_PREPROCESSED);
+ if (ibuf == NULL) {
+ ibuf = BKE_sequencer_cache_get(context, seq, cfra, SEQ_CACHE_STORE_RAW);
if (ibuf == NULL) {
- ibuf = BKE_sequencer_preprocessed_cache_get(context, seq, cfra, SEQ_STRIPELEM_IBUF);
+ /* MOVIECLIPs have their own proxy management */
+ if (seq->type != SEQ_TYPE_MOVIECLIP) {
+ ibuf = seq_proxy_fetch(context, seq, cfra);
+ is_proxy_image = (ibuf != NULL);
+ }
if (ibuf == NULL) {
- /* MOVIECLIPs have their own proxy management */
- if (seq->type != SEQ_TYPE_MOVIECLIP) {
- ibuf = seq_proxy_fetch(context, seq, cfra);
- is_proxy_image = (ibuf != NULL);
- }
-
- if (ibuf == NULL) {
- ibuf = do_render_strip_uncached(context, state, seq, cfra);
- }
+ ibuf = do_render_strip_uncached(context, state, seq, cfra);
+ }
- if (ibuf) {
- if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP)) {
- is_proxy_image = (context->preview_render_size != 100);
- }
- BKE_sequencer_preprocessed_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf);
+ if (ibuf) {
+ if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP)) {
+ is_proxy_image = (context->preview_render_size != 100);
}
}
}
@@ -3908,30 +3872,29 @@ static ImBuf *seq_render_strip(const SeqRenderData *context,
if (ibuf) {
use_preprocess = BKE_sequencer_input_have_to_preprocess(context, seq, cfra);
}
- }
- else {
- /* currently, we cache preprocessed images in SEQ_STRIPELEM_IBUF,
- * but not(!) on SEQ_STRIPELEM_IBUF_ENDSTILL and ..._STARTSTILL
- * so, no need in check for preprocess here
- */
- }
- if (ibuf == NULL) {
- ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
- sequencer_imbuf_assign_spaces(context->scene, ibuf);
- }
+ if (ibuf == NULL) {
+ ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
+ sequencer_imbuf_assign_spaces(context->scene, ibuf);
+ }
- if (context->is_proxy_render == false &&
- (ibuf->x != context->rectx || ibuf->y != context->recty)) {
- use_preprocess = true;
- }
+ if (context->is_proxy_render == false &&
+ (ibuf->x != context->rectx || ibuf->y != context->recty)) {
+ use_preprocess = true;
+ }
- if (use_preprocess) {
- ibuf = input_preprocess(context, seq, cfra, ibuf, is_proxy_image, is_preprocessed);
- }
+ if (use_preprocess) {
+ float cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put(context, seq, cfra, SEQ_CACHE_STORE_RAW, ibuf, cost);
- BKE_sequencer_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf);
+ /* reset timer so we can get partial render time */
+ begin = seq_estimate_render_cost_begin();
+ ibuf = input_preprocess(context, seq, cfra, ibuf, is_proxy_image, is_preprocessed);
+ }
+ float cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put(context, seq, cfra, SEQ_CACHE_STORE_PREPROCESSED, ibuf, cost);
+ }
return ibuf;
}
@@ -4012,6 +3975,7 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
int count;
int i;
ImBuf *out = NULL;
+ clock_t begin;
count = get_shown_sequences(seqbasep, cfra, chanshown, (Sequence **)&seq_arr);
@@ -4019,73 +3983,11 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
return NULL;
}
-#if 0 /* commentind since this breaks keyframing, since it resets the value on draw */
- if (scene->r.cfra != cfra) {
- /* XXX for prefetch and overlay offset!..., very bad!!! */
- AnimData *adt = BKE_animdata_from_id(&scene->id);
- BKE_animsys_evaluate_animdata(scene, &scene->id, adt, cfra, ADT_RECALC_ANIM);
- }
-#endif
-
- out = BKE_sequencer_cache_get(context, seq_arr[count - 1], cfra, SEQ_STRIPELEM_IBUF_COMP);
-
- if (out) {
- return out;
- }
-
- if (count == 1) {
- Sequence *seq = seq_arr[0];
-
- /* Some of the blend modes are unclear how to apply with only single input,
- * or some of them will just produce an empty result..
- */
- if (ELEM(seq->blend_mode, SEQ_BLEND_REPLACE, SEQ_TYPE_CROSS, SEQ_TYPE_ALPHAOVER)) {
- int early_out;
- if (seq->blend_mode == SEQ_BLEND_REPLACE) {
- early_out = EARLY_NO_INPUT;
- }
- else {
- early_out = seq_get_early_out_for_blend_mode(seq);
- }
-
- if (ELEM(early_out, EARLY_NO_INPUT, EARLY_USE_INPUT_2)) {
- out = seq_render_strip(context, state, seq, cfra);
- }
- else if (early_out == EARLY_USE_INPUT_1) {
- out = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
- }
- else {
- out = seq_render_strip(context, state, seq, cfra);
-
- if (early_out == EARLY_DO_EFFECT) {
- ImBuf *ibuf1 = IMB_allocImBuf(
- context->rectx, context->recty, 32, out->rect_float ? IB_rectfloat : IB_rect);
- ImBuf *ibuf2 = out;
-
- out = seq_render_strip_stack_apply_effect(context, seq, cfra, ibuf1, ibuf2);
- if (out) {
- IMB_metadata_copy(out, ibuf2);
- }
-
- IMB_freeImBuf(ibuf1);
- IMB_freeImBuf(ibuf2);
- }
- }
- }
- else {
- out = seq_render_strip(context, state, seq, cfra);
- }
-
- BKE_sequencer_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF_COMP, out);
-
- return out;
- }
-
for (i = count - 1; i >= 0; i--) {
int early_out;
Sequence *seq = seq_arr[i];
- out = BKE_sequencer_cache_get(context, seq, cfra, SEQ_STRIPELEM_IBUF_COMP);
+ out = BKE_sequencer_cache_get(context, seq, cfra, SEQ_CACHE_STORE_COMPOSITE);
if (out) {
break;
@@ -4109,15 +4011,19 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
break;
case EARLY_DO_EFFECT:
if (i == 0) {
+ begin = seq_estimate_render_cost_begin();
+
ImBuf *ibuf1 = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
ImBuf *ibuf2 = seq_render_strip(context, state, seq, cfra);
out = seq_render_strip_stack_apply_effect(context, seq, cfra, ibuf1, ibuf2);
+ float cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put(context, seq_arr[i], cfra, SEQ_CACHE_STORE_COMPOSITE, out, cost);
+
IMB_freeImBuf(ibuf1);
IMB_freeImBuf(ibuf2);
}
-
break;
}
if (out) {
@@ -4125,11 +4031,9 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
}
}
- BKE_sequencer_cache_put(context, seq_arr[i], cfra, SEQ_STRIPELEM_IBUF_COMP, out);
-
i++;
-
for (; i < count; i++) {
+ begin = seq_estimate_render_cost_begin();
Sequence *seq = seq_arr[i];
if (seq_get_early_out_for_blend_mode(seq) == EARLY_DO_EFFECT) {
@@ -4142,7 +4046,8 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
IMB_freeImBuf(ibuf2);
}
- BKE_sequencer_cache_put(context, seq_arr[i], cfra, SEQ_STRIPELEM_IBUF_COMP, out);
+ float cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put(context, seq_arr[i], cfra, SEQ_CACHE_STORE_COMPOSITE, out, cost);
}
return out;
@@ -4155,7 +4060,8 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
ImBuf *BKE_sequencer_give_ibuf(const SeqRenderData *context, float cfra, int chanshown)
{
- Editing *ed = BKE_sequencer_editing_get(context->scene, false);
+ Scene *scene = context->scene;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
ListBase *seqbasep;
if (ed == NULL) {
@@ -4173,8 +4079,29 @@ ImBuf *BKE_sequencer_give_ibuf(const SeqRenderData *context, float cfra, int cha
SeqRenderState state;
sequencer_state_init(&state);
+ ImBuf *out = NULL;
+ Sequence *seq_arr[MAXSEQ + 1];
+ int count;
- return seq_render_strip_stack(context, &state, seqbasep, cfra, chanshown);
+ count = get_shown_sequences(seqbasep, cfra, chanshown, seq_arr);
+
+ if (count) {
+ out = BKE_sequencer_cache_get(context, seq_arr[count - 1], cfra, SEQ_CACHE_STORE_FINAL_OUT);
+ }
+
+ BKE_sequencer_cache_free_temp_cache(context->scene, 0, cfra);
+
+ clock_t begin = seq_estimate_render_cost_begin();
+ float cost = 0;
+
+ if (count && !out) {
+ out = seq_render_strip_stack(context, &state, seqbasep, cfra, chanshown);
+ cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put_if_possible(
+ context, seq_arr[count - 1], cfra, SEQ_CACHE_STORE_FINAL_OUT, out, cost);
+ }
+
+ return out;
}
ImBuf *BKE_sequencer_give_ibuf_seqbase(const SeqRenderData *context,
@@ -4193,7 +4120,9 @@ ImBuf *BKE_sequencer_give_ibuf_direct(const SeqRenderData *context, float cfra,
SeqRenderState state;
sequencer_state_init(&state);
- return seq_render_strip(context, &state, seq, cfra);
+ ImBuf *ibuf = seq_render_strip(context, &state, seq, cfra);
+
+ return ibuf;
}
/* *********************** threading api ******************* */
@@ -4206,8 +4135,8 @@ static pthread_mutex_t queue_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t wakeup_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t wakeup_cond = PTHREAD_COND_INITIALIZER;
-//static pthread_mutex_t prefetch_ready_lock = PTHREAD_MUTEX_INITIALIZER;
-//static pthread_cond_t prefetch_ready_cond = PTHREAD_COND_INITIALIZER;
+// static pthread_mutex_t prefetch_ready_lock = PTHREAD_MUTEX_INITIALIZER;
+// static pthread_cond_t prefetch_ready_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t frame_done_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t frame_done_cond = PTHREAD_COND_INITIALIZER;
@@ -4365,7 +4294,7 @@ bool BKE_sequence_check_depend(Sequence *seq, Sequence *cur)
return true;
}
-static void sequence_do_invalidate_dependent(Sequence *seq, ListBase *seqbase)
+static void sequence_do_invalidate_dependent(Scene *scene, Sequence *seq, ListBase *seqbase)
{
Sequence *cur;
@@ -4375,12 +4304,11 @@ static void sequence_do_invalidate_dependent(Sequence *seq, ListBase *seqbase)
}
if (BKE_sequence_check_depend(seq, cur)) {
- BKE_sequencer_cache_cleanup_sequence(cur);
- BKE_sequencer_preprocessed_cache_cleanup_sequence(cur);
+ BKE_sequencer_cache_cleanup_sequence(scene, cur);
}
if (cur->seqbase.first) {
- sequence_do_invalidate_dependent(seq, &cur->seqbase);
+ sequence_do_invalidate_dependent(scene, seq, &cur->seqbase);
}
}
}
@@ -4388,7 +4316,7 @@ static void sequence_do_invalidate_dependent(Sequence *seq, ListBase *seqbase)
static void sequence_invalidate_cache(Scene *scene,
Sequence *seq,
bool invalidate_self,
- bool invalidate_preprocess)
+ bool UNUSED(invalidate_preprocess))
{
Editing *ed = scene->ed;
@@ -4399,7 +4327,7 @@ static void sequence_invalidate_cache(Scene *scene,
* re-open the animation.
*/
BKE_sequence_free_anim(seq);
- BKE_sequencer_cache_cleanup_sequence(seq);
+ BKE_sequencer_cache_cleanup_sequence(scene, seq);
}
/* if invalidation is invoked from sequence free routine, effectdata would be NULL here */
@@ -4407,16 +4335,12 @@ static void sequence_invalidate_cache(Scene *scene,
BKE_sequence_effect_speed_rebuild_map(scene, seq, true);
}
- if (invalidate_preprocess) {
- BKE_sequencer_preprocessed_cache_cleanup_sequence(seq);
- }
-
/* invalidate cache for all dependent sequences */
/* NOTE: can not use SEQ_BEGIN/SEQ_END here because that macro will change sequence's depth,
* which makes transformation routines work incorrect
*/
- sequence_do_invalidate_dependent(seq, &ed->seqbase);
+ sequence_do_invalidate_dependent(scene, seq, &ed->seqbase);
}
void BKE_sequence_invalidate_cache(Scene *scene, Sequence *seq)
@@ -4438,7 +4362,7 @@ void BKE_sequencer_free_imbuf(Scene *scene, ListBase *seqbase, bool for_render)
{
Sequence *seq;
- BKE_sequencer_cache_cleanup();
+ BKE_sequencer_cache_cleanup(scene);
for (seq = seqbase->first; seq; seq = seq->next) {
if (for_render && CFRA >= seq->startdisp && CFRA <= seq->enddisp) {
@@ -4723,8 +4647,8 @@ bool BKE_sequence_tx_test(Sequence *seq)
/**
* Return \a true if given \a seq needs a complete cleanup of its cache when it is transformed.
*
- * Some (effect) strip types need a complete recache of themselves when they are transformed, because
- * they do not 'contain' anything and do not have any explicit relations to other strips.
+ * Some (effect) strip types need a complete recache of themselves when they are transformed,
+ * because they do not 'contain' anything and do not have any explicit relations to other strips.
*/
bool BKE_sequence_tx_fullupdate_test(Sequence *seq)
{
@@ -5446,6 +5370,7 @@ Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine)
seq->scene_sound = NULL;
seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Sequence Stereo Format");
+ seq->cache_flag = SEQ_CACHE_ALL_TYPES;
return seq;
}
@@ -5529,7 +5454,7 @@ Sequence *BKE_sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoad
seq = BKE_sequence_alloc(seqbasep, seq_load->start_frame, seq_load->channel);
seq->type = SEQ_TYPE_IMAGE;
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
/* basic defaults */
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
@@ -5563,17 +5488,18 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad
Strip *strip;
StripElem *se;
- AUD_SoundInfo info;
-
sound = BKE_sound_new_file(bmain, seq_load->path); /* handles relative paths */
+ /* Load the original sound, so we can access number of channels and length information.
+ * We free the sound handle on the original bSound datablock before existing this function, it is
+ * to be allocated on an evaluated version after this. */
+ BKE_sound_load_audio(bmain, sound);
+ AUD_SoundInfo info = AUD_getInfo(sound->playback_handle);
if (sound->playback_handle == NULL) {
BKE_id_free(bmain, sound);
return NULL;
}
- info = AUD_getInfo(sound->playback_handle);
-
if (info.specs.channels == AUD_CHANNELS_INVALID) {
BKE_id_free(bmain, sound);
return NULL;
@@ -5588,7 +5514,8 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad
/* basic defaults */
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
- /* We add a very small negative offset here, because ceil(132.0) == 133.0, not nice with videos, see T47135. */
+ /* We add a very small negative offset here, because
+ * ceil(132.0) == 133.0, not nice with videos, see T47135. */
seq->len = (int)ceil((double)info.length * FPS - 1e-4);
strip->us = 1;
@@ -5597,8 +5524,7 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad
BLI_split_dirfile(seq_load->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name));
- seq->scene_sound = BKE_sound_add_scene_sound(
- scene, seq, seq_load->start_frame, seq_load->start_frame + seq->len, 0);
+ seq->scene_sound = NULL;
BKE_sequence_calc_disp(scene, seq);
@@ -5607,6 +5533,11 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad
seq_load_apply(bmain, scene, seq, seq_load);
+ BKE_sound_free_audio(sound);
+
+ /* TODO(sergey): Shall we tag here or in the oeprator? */
+ DEG_relations_tag_update(bmain);
+
return seq;
}
#else // WITH_AUDASPACE
@@ -5693,7 +5624,7 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
seq->flag |= seq_load->flag & SEQ_USE_VIEWS;
seq->type = SEQ_TYPE_MOVIE;
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
for (i = 0; i < totfiles; i++) {
if (anim_arr[i]) {
@@ -5818,10 +5749,7 @@ static Sequence *seq_dupli(const Scene *scene_src,
}
else if (seq->type == SEQ_TYPE_SOUND_RAM) {
seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata);
- if (seq->scene_sound) {
- seqn->scene_sound = BKE_sound_add_scene_sound_defaults(scene_dst, seqn);
- }
-
+ seqn->scene_sound = NULL;
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
id_us_plus((ID *)seqn->sound);
}
@@ -5846,9 +5774,9 @@ static Sequence *seq_dupli(const Scene *scene_src,
/* When using SEQ_DUPE_UNIQUE_NAME, it is mandatory to add new sequences in relevant container
* (scene or meta's one), *before* checking for unique names. Otherwise the meta's list is empty
* and hence we miss all seqs in that meta that have already been duplicated (see T55668).
- * Note that unique name check itslef could be done at a later step in calling code, once all seqs
- * have bee duplicated (that was first, simpler solution), but then handling of animation data will
- * be broken (see T60194). */
+ * Note that unique name check itslef could be done at a later step in calling code, once all
+ * seqs have bee duplicated (that was first, simpler solution), but then handling of animation
+ * data will be broken (see T60194). */
if (new_seq_list != NULL) {
BLI_addtail(new_seq_list, seqn);
}
@@ -6000,7 +5928,8 @@ int BKE_sequencer_find_next_prev_edit(Scene *scene,
int dist, best_dist, best_frame = cfra;
int seq_frames[2], seq_frames_tot;
- /* in case where both is passed, frame just finds the nearest end while frame_left the nearest start */
+ /* In case where both is passed,
+ * frame just finds the nearest end while frame_left the nearest start. */
best_dist = MAXFRAME * 2;
@@ -6073,15 +6002,12 @@ static void sequencer_all_free_anim_ibufs(ListBase *seqbase, int cfra)
}
}
-void BKE_sequencer_all_free_anim_ibufs(Main *bmain, int cfra)
+void BKE_sequencer_all_free_anim_ibufs(Scene *scene, int cfra)
{
- BKE_sequencer_cache_cleanup();
- for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (ed == NULL) {
- /* Ignore scenes without sequencer. */
- continue;
- }
- sequencer_all_free_anim_ibufs(&ed->seqbase, cfra);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ if (ed == NULL) {
+ return;
}
+ sequencer_all_free_anim_ibufs(&ed->seqbase, cfra);
+ BKE_sequencer_cache_cleanup(scene);
}
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 3cd2131c22b..6a72b46a8f2 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -69,25 +69,25 @@
#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n"))
typedef struct ShrinkwrapCalcData {
- ShrinkwrapModifierData *smd; //shrinkwrap modifier data
+ ShrinkwrapModifierData *smd; // shrinkwrap modifier data
- struct Object *ob; //object we are applying shrinkwrap to
+ struct Object *ob; // object we are applying shrinkwrap to
- struct MVert *vert; //Array of verts being projected (to fetch normals or other data)
- float (*vertexCos)[3]; //vertexs being shrinkwraped
+ struct MVert *vert; // Array of verts being projected (to fetch normals or other data)
+ float (*vertexCos)[3]; // vertexs being shrinkwraped
int numVerts;
- struct MDeformVert *dvert; //Pointer to mdeform array
- int vgroup; //Vertex group num
+ struct MDeformVert *dvert; // Pointer to mdeform array
+ int vgroup; // Vertex group num
bool invert_vgroup; /* invert vertex group influence */
- struct Mesh *target; //mesh we are shrinking to
- struct SpaceTransform local2target; //transform to move between local and target space
+ struct Mesh *target; // mesh we are shrinking to
+ struct SpaceTransform local2target; // transform to move between local and target space
struct ShrinkwrapTreeData *tree; // mesh BVH tree data
struct Object *aux_target;
- float keepDist; //Distance to keep above target surface (units are in local space)
+ float keepDist; // Distance to keep above target surface (units are in local space)
} ShrinkwrapCalcData;
typedef struct ShrinkwrapCalcCBData {
@@ -375,8 +375,8 @@ static void shrinkwrap_calc_nearest_vertex_cb_ex(void *__restrict userdata,
/* Use local proximity heuristics (to reduce the nearest search)
*
- * If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex
- * so we can initiate the "nearest.dist" with the expected value to that last hit.
+ * If we already had an hit before.. we assume this vertex is going to have a close hit to that
+ * other vertex so we can initiate the "nearest.dist" with the expected value to that last hit.
* This will lead in pruning of the search tree. */
if (nearest->index != -1) {
nearest->dist_sq = len_squared_v3v3(tmp_co, nearest->co);
@@ -538,8 +538,9 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata,
if (calc->vert != NULL && calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
/* calc->vert contains verts from evaluated mesh. */
- /* 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 */
+ /* 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);
}
@@ -549,8 +550,9 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata,
}
hit->index = -1;
- hit->dist =
- BVH_RAYCAST_DIST_MAX; /* TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that */
+
+ /* TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that */
+ hit->dist = BVH_RAYCAST_DIST_MAX;
bool is_aux = false;
@@ -938,7 +940,8 @@ static bool update_hit(BVHTreeNearest *nearest,
return false;
}
-/* Target projection on a non-manifold boundary edge - treats it like an infinitely thin cylinder. */
+/* Target projection on a non-manifold boundary edge -
+ * treats it like an infinitely thin cylinder. */
static void target_project_edge(const ShrinkwrapTreeData *tree,
int index,
const float co[3],
@@ -1142,8 +1145,8 @@ static void shrinkwrap_calc_nearest_surface_point_cb_ex(void *__restrict userdat
/* Use local proximity heuristics (to reduce the nearest search)
*
- * If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex
- * so we can initiate the "nearest.dist" with the expected value to that last hit.
+ * If we already had an hit before.. we assume this vertex is going to have a close hit to that
+ * other vertex so we can initiate the "nearest.dist" with the expected value to that last hit.
* This will lead in pruning of the search tree. */
if (nearest->index != -1) {
if (calc->smd->shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index a815aaefb29..d6858e2d4d2 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -119,7 +119,7 @@ struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res),
{
return NULL;
}
-//struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(dx), float *UNUSED(dtdef), int UNUSED(use_heat), int UNUSED(use_fire), int UNUSED(use_colors)) { return NULL; }
+
void smoke_free(struct FLUID_3D *UNUSED(fluid))
{
}
@@ -914,7 +914,8 @@ static void obstacles_from_mesh(Object *coll_ob,
// DG TODO
// if (scs->type > SM_COLL_STATIC)
- // if line above is used, the code is in trouble if the object moves but is declared as "does not move"
+ // if line above is used, the code is in trouble if the object moves
+ // but is declared as "does not move".
{
vert_vel = MEM_callocN(sizeof(float) * numverts * 3, "smoke_obs_velocity");
@@ -1680,7 +1681,8 @@ static void sample_mesh(SmokeFlowSettings *sfs,
interp_v3_v3v3v3(hit_normal, n1, n2, n3, weights);
normalize_v3(hit_normal);
/* apply normal directional and random velocity
- * - TODO: random disabled for now since it doesn't really work well as pressure calc smoothens it out... */
+ * - TODO: random disabled for now since it doesn't really work well
+ * as pressure calc smoothens it out. */
velocity_map[index * 3] += hit_normal[0] * sfs->vel_normal * 0.25f;
velocity_map[index * 3 + 1] += hit_normal[1] * sfs->vel_normal * 0.25f;
velocity_map[index * 3 + 2] += hit_normal[2] * sfs->vel_normal * 0.25f;
@@ -2674,7 +2676,7 @@ static void update_flowsfluids(
float *velocity_x = smoke_get_velocity_x(sds->fluid);
float *velocity_y = smoke_get_velocity_y(sds->fluid);
float *velocity_z = smoke_get_velocity_z(sds->fluid);
- //unsigned char *obstacle = smoke_get_obstacle(sds->fluid);
+ // unsigned char *obstacle = smoke_get_obstacle(sds->fluid);
// DG TODO UNUSED unsigned char *obstacleAnim = smoke_get_obstacle_anim(sds->fluid);
int bigres[3];
float *velocity_map = em->velocity;
@@ -2734,7 +2736,8 @@ static void update_flowsfluids(
/* loop through high res blocks if high res enabled */
if (bigdensity) {
- // neighbor cell emission densities (for high resolution smoke smooth interpolation)
+ /* Neighbor cell emission densities
+ * (for high resolution smoke smooth interpolation). */
float c000, c001, c010, c011, c100, c101, c110, c111;
smoke_turbulence_get_res(sds->wt, bigres);
@@ -3034,12 +3037,9 @@ static void step(Depsgraph *depsgraph,
update_obstacles(depsgraph, ob, sds, dtSubdiv, substep, totalSubsteps);
if (sds->total_cells > 1) {
- update_effectors(
- depsgraph,
- scene,
- ob,
- sds,
- dtSubdiv); // DG TODO? problem --> uses forces instead of velocity, need to check how they need to be changed with variable dt
+ // DG TODO? problem --> uses forces instead of velocity,
+ // need to check how they need to be changed with variable dt.
+ update_effectors(depsgraph, scene, ob, sds, dtSubdiv);
smoke_step(sds->fluid, gravity, dtSubdiv);
}
}
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 6903021e0cf..2a3145bee6c 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -190,8 +190,8 @@ static float sb_time_scale(Object *ob)
/* hrms .. this could be IPO as well :)
* estimated range [0.001 sluggish slug - 100.0 very fast (i hope ODE solver can handle that)]
* 1 approx = a unit 1 pendulum at g = 9.8 [earth conditions] has period 65 frames
- * theory would give a 50 frames period .. so there must be something inaccurate .. looking for that (BM)
- */
+ * theory would give a 50 frames period .. so there must be something inaccurate ..
+ * looking for that (BM). */
}
return (1.0f);
/*
@@ -599,7 +599,7 @@ static void add_mesh_quad_diag_springs(Object *ob)
if (ob->soft) {
int nofquads;
- //float s_shear = ob->soft->shearstiff*ob->soft->shearstiff;
+ // float s_shear = ob->soft->shearstiff*ob->soft->shearstiff;
nofquads = count_mesh_quads(me);
if (nofquads) {
@@ -1459,7 +1459,7 @@ static void _scan_for_ext_spring_forces(
sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos, &damp, feedback, ob, timenow)) {
add_v3_v3(bs->ext_force, feedback);
bs->flag |= BSF_INTERSECT;
- //bs->cf=damp;
+ // bs->cf=damp;
bs->cf = sb->choke * 0.01f;
}
}
@@ -1528,8 +1528,10 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph,
ListBase threads;
SB_thread_context *sb_threads;
int i, totthread, left, dec;
- int lowsprings =
- 100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
+
+ /* wild guess .. may increase with better thread management 'above'
+ * or even be UI option sb->spawn_cf_threads_nopts */
+ int lowsprings = 100;
ListBase *effectors = BKE_effectors_create(depsgraph, ob, NULL, ob->soft->effector_weights);
@@ -1823,7 +1825,10 @@ static int sb_deflect_face(Object *ob,
copy_v3_v3(s_actpos, actpos);
deflected = sb_detect_vertex_collisionCached(
s_actpos, facenormal, cf, force, ob, time, vel, intrusion);
- //deflected= sb_detect_vertex_collisionCachedEx(s_actpos, facenormal, cf, force, ob, time, vel, intrusion);
+#if 0
+ deflected = sb_detect_vertex_collisionCachedEx(
+ s_actpos, facenormal, cf, force, ob, time, vel, intrusion);
+#endif
return (deflected);
}
@@ -2006,7 +2011,8 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene,
float compare;
float bstune = sb->ballstiff;
- /* running in a slice we must not assume anything done with obp neither alter the data of obp */
+ /* Running in a slice we must not assume anything done with obp
+ * neither alter the data of obp. */
for (c = sb->totpoint, obp = sb->bpoint; c > 0; c--, obp++) {
compare = (obp->colball + bp->colball);
sub_v3_v3v3(def, bp->pos, obp->pos);
@@ -2196,8 +2202,10 @@ static void sb_cf_threads_run(Scene *scene,
ListBase threads;
SB_thread_context *sb_threads;
int i, totthread, left, dec;
- int lowpoints =
- 100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
+
+ /* wild guess .. may increase with better thread management 'above'
+ * or even be UI option sb->spawn_cf_threads_nopts. */
+ int lowpoints = 100;
/* figure the number of threads while preventing pretty pointless threading overhead */
totthread = BKE_scene_num_threads(scene);
@@ -2266,7 +2274,9 @@ static void softbody_calc_forces(
/* check conditions for various options */
do_deflector = query_external_colliders(depsgraph, sb->collision_group);
- /* do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); */ /* UNUSED */
+#if 0
+ do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF));
+#endif
do_springcollision = do_deflector && (ob->softflag & OB_SB_EDGES) &&
(ob->softflag & OB_SB_EDGECOLL);
do_aero = ((sb->aeroedge) && (ob->softflag & OB_SB_EDGES));
@@ -2333,7 +2343,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
#endif
for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
- /* now we have individual masses */
+ /* Now we have individual masses. */
/* claim a minimum mass for vertex */
if (_final_mass(ob, bp) > 0.009999f) {
timeovermass = forcetime / _final_mass(ob, bp);
@@ -2348,10 +2358,20 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
copy_v3_v3(dx, bp->vec);
}
- /* so here is (v)' = a(cceleration) = sum(F_springs)/m + gravitation + some friction forces + more forces*/
- /* the ( ... )' operator denotes derivate respective time */
- /* the euler step for velocity then becomes */
- /* v(t + dt) = v(t) + a(t) * dt */
+ /**
+ * So here is:
+ * <pre>
+ * (v)' = a(cceleration) =
+ * sum(F_springs)/m + gravitation + some friction forces + more forces.
+ * </pre>
+ *
+ * The ( ... )' operator denotes derivate respective time.
+ *
+ * The euler step for velocity then becomes:
+ * <pre>
+ * v(t + dt) = v(t) + a(t) * dt
+ * </pre>
+ */
mul_v3_fl(bp->force, timeovermass); /* individual mass of node here */
/* some nasty if's to have heun in here too */
copy_v3_v3(dv, bp->force);
@@ -2446,7 +2466,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
else {
*err = maxerrpos;
}
- //printf("EP %f EV %f\n", maxerrpos, maxerrvel);
+ // printf("EP %f EV %f\n", maxerrpos, maxerrvel);
if (fuzzy) {
*err /= sb->fuzzyness;
}
@@ -2970,10 +2990,15 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob)
for (nu = cu->nurb.first; nu; nu = nu->next) {
if (nu->bezt) {
- /* bezier case ; this is nicly said naive; who ever wrote this part, it was not me (JOW) :) */
- /* a: never ever make tangent handles (sub) and or (ob)ject to collision */
- /* b: rather calculate them using some C2 (C2= continuous in second derivate -> no jump in bending ) condition */
- /* not too hard to do, but needs some more code to care for; some one may want look at it JOW 2010/06/12*/
+ /* Bezier case; this is nicly said naive; who ever wrote this part,
+ * it was not me (JOW) :).
+ *
+ * a: never ever make tangent handles (sub) and or (ob)ject to collision.
+ * b: rather calculate them using some C2
+ * (C2= continuous in second derivate -> no jump in bending ) condition.
+ *
+ * Not too hard to do, but needs some more code to care for;
+ * some one may want look at it JOW 2010/06/12. */
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++, bp += 3, curindex += 3) {
if (setgoal) {
bp->goal *= bezt->weight;
@@ -3158,7 +3183,7 @@ void sbFreeSimulation(SoftBody *sb)
/* makes totally fresh start situation */
void sbObjectToSoftbody(Object *ob)
{
- //ob->softflag |= OB_SB_REDO;
+ // ob->softflag |= OB_SB_REDO;
free_softbody_intern(ob->soft);
}
@@ -3213,10 +3238,9 @@ static void softbody_update_positions(Object *ob,
* that is:
* a precise position vector denoting the motion of the center of mass
* give a rotation/scale matrix using averaging method, that's why estimate and not calculate
- * see: this is kind of reverse engineering: having to states of a point cloud and recover what happened
- * our advantage here we know the identity of the vertex
- * there are others methods giving other results.
- * lloc, lrot, lscale are allowed to be NULL, just in case you don't need it.
+ * see: this is kind of reverse engineering: having to states of a point cloud and recover what
+ * happened our advantage here we know the identity of the vertex there are others methods giving
+ * other results. lloc, lrot, lscale are allowed to be NULL, just in case you don't need it.
* should be pretty useful for pythoneers :)
* not! velocity .. 2nd order stuff
* vcloud_estimate_transform_v3 see
@@ -3248,7 +3272,7 @@ void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float ls
}
vcloud_estimate_transform_v3(sb->totpoint, opos, NULL, rpos, NULL, com, rcom, lrot, lscale);
- //sub_v3_v3(com, rcom);
+ // sub_v3_v3(com, rcom);
if (lloc) {
copy_v3_v3(lloc, com);
}
@@ -3397,7 +3421,7 @@ static void softbody_step(
if (forcetime > forcetimemin) {
forcetime = max_ff(forcetime / 2.0f, forcetimemin);
softbody_restore_prev_step(ob);
- //printf("down, ");
+ // printf("down, ");
}
else {
timedone += forcetime;
@@ -3407,7 +3431,8 @@ static void softbody_step(
float newtime = forcetime * 1.1f; /* hope for 1.1 times better conditions in next step */
if (sb->scratch->flag & SBF_DOFUZZY) {
- //if (err > SoftHeunTol/(2.0f*sb->fuzzyness)) { /* stay with this stepsize unless err really small */
+ ///* stay with this stepsize unless err really small */
+ // if (err > SoftHeunTol/(2.0f*sb->fuzzyness)) {
newtime = forcetime;
//}
}
@@ -3418,7 +3443,7 @@ static void softbody_step(
}
timedone += forcetime;
newtime = min_ff(forcetimemax, max_ff(newtime, forcetimemin));
- //if (newtime > forcetime) printf("up, ");
+ // if (newtime > forcetime) printf("up, ");
if (forcetime > 0.0f) {
forcetime = min_ff(dtime - timedone, newtime);
}
@@ -3451,14 +3476,14 @@ static void softbody_step(
}
else if (sb->solver_ID == 2) {
/* do semi "fake" implicit euler */
- //removed
+ // removed
} /*SOLVER SELECT*/
else if (sb->solver_ID == 4) {
/* do semi "fake" implicit euler */
} /*SOLVER SELECT*/
else if (sb->solver_ID == 3) {
/* do "stupid" semi "fake" implicit euler */
- //removed
+ // removed
} /*SOLVER SELECT*/
else {
@@ -3591,9 +3616,9 @@ void sbObjectStep(struct Depsgraph *depsgraph,
else if (cache_result == PTCACHE_READ_OLD) {
/* pass */
}
- else if (/*ob->id.lib || */ (
- cache->flag &
- PTCACHE_BAKED)) { /* "library linking & pointcaches" has to be solved properly at some point */
+ else if (/*ob->id.lib || */
+ /* "library linking & pointcaches" has to be solved properly at some point */
+ (cache->flag & PTCACHE_BAKED)) {
/* if baked and nothing in cache, do nothing */
if (can_write_cache) {
BKE_ptcache_invalidate(cache);
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 857d59d9e5c..9ccb90b5cdc 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -38,6 +38,7 @@
#include "DNA_screen_types.h"
#include "DNA_sound_types.h"
#include "DNA_speaker_types.h"
+#include "DNA_windowmanager_types.h"
#ifdef WITH_AUDASPACE
# include <AUD_Sound.h>
@@ -55,13 +56,38 @@
#include "BKE_sequencer.h"
#include "BKE_scene.h"
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
+
#ifdef WITH_AUDASPACE
/* evil globals ;-) */
static int sound_cfra;
static char **audio_device_names = NULL;
#endif
-bSound *BKE_sound_new_file(struct Main *bmain, const char *filepath)
+BLI_INLINE void sound_verify_evaluated_id(ID *id)
+{
+ UNUSED_VARS_NDEBUG(id);
+ /* This is a bit tricky and not quite reliable, but good enough check.
+ *
+ * We don't want audio system handles to be allocated on amn original datablocks, and only want
+ * them to be allocated on a datablocks which are result of dependency graph evaluation.
+ *
+ * Datablocks which are covered by a copy-on-write system of dependency graph will have
+ * LIB_TAG_COPIED_ON_WRITE tag set on them. But if some of datablocks during its evaluation
+ * decides to re-allocate it's nested one (for example, object evaluation could re-allocate mesh
+ * when evaluating modifier stack). Such datablocks will have LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT
+ * tag set on them.
+ *
+ * Additionally, we also allow datablocks outside of main database. Those can not be "original"
+ * and could be used as a temporary evaluated result during operations like baking.
+ *
+ * NOTE: We conder ID evaluated if ANY of those flags is set. We do NOT require ALL of them. */
+ BLI_assert(id->tag &
+ (LIB_TAG_COPIED_ON_WRITE | LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT | LIB_TAG_NO_MAIN));
+}
+
+bSound *BKE_sound_new_file(Main *bmain, const char *filepath)
{
bSound *sound;
const char *path;
@@ -77,12 +103,15 @@ bSound *BKE_sound_new_file(struct Main *bmain, const char *filepath)
BLI_strncpy(sound->name, filepath, FILE_MAX);
/* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */
- BKE_sound_load(bmain, sound);
+ sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
+ BLI_spin_init(sound->spinlock);
+
+ BKE_sound_reset_runtime(sound);
return sound;
}
-bSound *BKE_sound_new_file_exists_ex(struct Main *bmain, const char *filepath, bool *r_exists)
+bSound *BKE_sound_new_file_exists_ex(Main *bmain, const char *filepath, bool *r_exists)
{
bSound *sound;
char str[FILE_MAX], strtest[FILE_MAX];
@@ -110,7 +139,7 @@ bSound *BKE_sound_new_file_exists_ex(struct Main *bmain, const char *filepath, b
return BKE_sound_new_file(bmain, filepath);
}
-bSound *BKE_sound_new_file_exists(struct Main *bmain, const char *filepath)
+bSound *BKE_sound_new_file_exists(Main *bmain, const char *filepath)
{
return BKE_sound_new_file_exists_ex(bmain, filepath, NULL);
}
@@ -125,6 +154,18 @@ void BKE_sound_free(bSound *sound)
sound->packedfile = NULL;
}
+ BKE_sound_free_audio(sound);
+ BKE_sound_free_waveform(sound);
+
+ if (sound->spinlock) {
+ BLI_spin_end(sound->spinlock);
+ MEM_freeN(sound->spinlock);
+ sound->spinlock = NULL;
+ }
+}
+
+void BKE_sound_free_audio(bSound *sound)
+{
#ifdef WITH_AUDASPACE
if (sound->handle) {
AUD_Sound_free(sound->handle);
@@ -136,26 +177,22 @@ void BKE_sound_free(bSound *sound)
AUD_Sound_free(sound->cache);
sound->cache = NULL;
}
-
- BKE_sound_free_waveform(sound);
-
+#else
+ UNUSED_VARS(sound);
#endif /* WITH_AUDASPACE */
- if (sound->spinlock) {
- BLI_spin_end(sound->spinlock);
- MEM_freeN(sound->spinlock);
- sound->spinlock = NULL;
- }
}
/**
- * Only copy internal data of Sound ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Sound ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
* \param flag: Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
*/
-void BKE_sound_copy_data(Main *bmain,
+void BKE_sound_copy_data(Main *UNUSED(bmain),
bSound *sound_dst,
const bSound *UNUSED(sound_src),
const int UNUSED(flag))
@@ -164,8 +201,8 @@ void BKE_sound_copy_data(Main *bmain,
sound_dst->cache = NULL;
sound_dst->waveform = NULL;
sound_dst->playback_handle = NULL;
- sound_dst->spinlock =
- NULL; /* Think this is OK? Otherwise, easy to create new spinlock here... */
+ sound_dst->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
+ BLI_spin_init(sound_dst->spinlock);
/* Just to be sure, should not have any value actually after reading time. */
sound_dst->ipo = NULL;
@@ -175,8 +212,7 @@ void BKE_sound_copy_data(Main *bmain,
sound_dst->packedfile = dupPackedFile(sound_dst->packedfile);
}
- /* Initialize whole runtime (audaspace) stuff. */
- BKE_sound_load(bmain, sound_dst);
+ BKE_sound_reset_runtime(sound_dst);
}
void BKE_sound_make_local(Main *bmain, bSound *sound, const bool lib_local)
@@ -189,31 +225,15 @@ void BKE_sound_make_local(Main *bmain, bSound *sound, const bool lib_local)
static const char *force_device = NULL;
# ifdef WITH_JACK
+static SoundJackSyncCallback sound_jack_sync_callback = NULL;
+
static void sound_sync_callback(void *data, int mode, float time)
{
- // Ugly: Blender doesn't like it when the animation is played back during rendering
- if (G.is_rendering) {
+ if (sound_jack_sync_callback == NULL) {
return;
}
-
- struct Main *bmain = (struct Main *)data;
- struct Scene *scene;
-
- scene = bmain->scenes.first;
- while (scene) {
- if (scene->audio.flag & AUDIO_SYNC) {
- if (mode) {
- BKE_sound_play_scene(scene);
- }
- else {
- BKE_sound_stop_scene(scene);
- }
- if (scene->playback_handle) {
- AUD_Handle_setPosition(scene->playback_handle, time);
- }
- }
- scene = scene->id.next;
- }
+ Main *bmain = (Main *)data;
+ sound_jack_sync_callback(bmain, mode, time);
}
# endif
@@ -235,7 +255,7 @@ void *BKE_sound_get_device(void)
return sound_device;
}
-void BKE_sound_init(struct Main *bmain)
+void BKE_sound_init(Main *bmain)
{
/* Make sure no instance of the sound system is running, otherwise we get leaks. */
BKE_sound_exit();
@@ -289,14 +309,14 @@ void BKE_sound_init(struct Main *bmain)
BKE_sound_init_main(bmain);
}
-void BKE_sound_init_main(struct Main *bmain)
+void BKE_sound_init_main(Main *bmain)
{
# ifdef WITH_JACK
if (sound_device) {
AUD_setSynchronizerCallback(sound_sync_callback, bmain);
}
# else
- (void)bmain; /* unused */
+ UNUSED_VARS(bmain);
# endif
}
@@ -324,7 +344,7 @@ void BKE_sound_exit_once(void)
/* XXX unused currently */
# if 0
-bSound *BKE_sound_new_buffer(struct Main *bmain, bSound *source)
+bSound *BKE_sound_new_buffer(Main *bmain, bSound *source)
{
bSound *sound = NULL;
@@ -342,7 +362,7 @@ bSound *BKE_sound_new_buffer(struct Main *bmain, bSound *source)
return sound;
}
-bSound *BKE_sound_new_limiter(struct Main *bmain, bSound *source, float start, float end)
+bSound *BKE_sound_new_limiter(Main *bmain, bSound *source, float start, float end)
{
bSound *sound = NULL;
@@ -365,6 +385,8 @@ bSound *BKE_sound_new_limiter(struct Main *bmain, bSound *source, float start, f
void BKE_sound_cache(bSound *sound)
{
+ sound_verify_evaluated_id(&sound->id);
+
sound->flags |= SOUND_FLAGS_CACHING;
if (sound->cache) {
AUD_Sound_free(sound->cache);
@@ -389,46 +411,52 @@ void BKE_sound_delete_cache(bSound *sound)
}
}
-void BKE_sound_load(struct Main *bmain, bSound *sound)
+void BKE_sound_load(Main *bmain, bSound *sound)
{
- if (sound) {
- if (sound->cache) {
- AUD_Sound_free(sound->cache);
- sound->cache = NULL;
- }
+ sound_verify_evaluated_id(&sound->id);
+ BKE_sound_load_audio(bmain, sound);
+}
- if (sound->handle) {
- AUD_Sound_free(sound->handle);
- sound->handle = NULL;
- sound->playback_handle = NULL;
- }
+void BKE_sound_load_audio(Main *bmain, bSound *sound)
+{
- BKE_sound_free_waveform(sound);
+ if (sound->cache) {
+ AUD_Sound_free(sound->cache);
+ sound->cache = NULL;
+ }
+
+ if (sound->handle) {
+ AUD_Sound_free(sound->handle);
+ sound->handle = NULL;
+ sound->playback_handle = NULL;
+ }
+
+ BKE_sound_free_waveform(sound);
/* XXX unused currently */
# if 0
switch (sound->type) {
case SOUND_TYPE_FILE:
# endif
- {
- char fullpath[FILE_MAX];
+ {
+ char fullpath[FILE_MAX];
- /* load sound */
- PackedFile *pf = sound->packedfile;
+ /* load sound */
+ PackedFile *pf = sound->packedfile;
- /* don't modify soundact->sound->name, only change a copy */
- BLI_strncpy(fullpath, sound->name, sizeof(fullpath));
- BLI_path_abs(fullpath, ID_BLEND_PATH(bmain, &sound->id));
+ /* don't modify soundact->sound->name, only change a copy */
+ BLI_strncpy(fullpath, sound->name, sizeof(fullpath));
+ BLI_path_abs(fullpath, ID_BLEND_PATH(bmain, &sound->id));
- /* but we need a packed file then */
- if (pf) {
- sound->handle = AUD_Sound_bufferFile((unsigned char *)pf->data, pf->size);
- }
- else {
- /* or else load it from disk */
- sound->handle = AUD_Sound_file(fullpath);
- }
+ /* but we need a packed file then */
+ if (pf) {
+ sound->handle = AUD_Sound_bufferFile((unsigned char *)pf->data, pf->size);
+ }
+ else {
+ /* or else load it from disk */
+ sound->handle = AUD_Sound_file(fullpath);
}
+ }
/* XXX unused currently */
# if 0
break;
@@ -445,34 +473,34 @@ void BKE_sound_load(struct Main *bmain, bSound *sound)
break;
}
# endif
- if (sound->flags & SOUND_FLAGS_MONO) {
- void *handle = AUD_Sound_rechannel(sound->handle, AUD_CHANNELS_MONO);
- AUD_Sound_free(sound->handle);
- sound->handle = handle;
- }
-
- if (sound->flags & SOUND_FLAGS_CACHING) {
- sound->cache = AUD_Sound_cache(sound->handle);
- }
+ if (sound->flags & SOUND_FLAGS_MONO) {
+ void *handle = AUD_Sound_rechannel(sound->handle, AUD_CHANNELS_MONO);
+ AUD_Sound_free(sound->handle);
+ sound->handle = handle;
+ }
- if (sound->cache) {
- sound->playback_handle = sound->cache;
- }
- else {
- sound->playback_handle = sound->handle;
- }
+ if (sound->flags & SOUND_FLAGS_CACHING) {
+ sound->cache = AUD_Sound_cache(sound->handle);
+ }
- BKE_sound_update_sequencer(bmain, sound);
+ if (sound->cache) {
+ sound->playback_handle = sound->cache;
+ }
+ else {
+ sound->playback_handle = sound->handle;
}
}
-AUD_Device *BKE_sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume)
+AUD_Device *BKE_sound_mixdown(Scene *scene, AUD_DeviceSpecs specs, int start, float volume)
{
+ sound_verify_evaluated_id(&scene->id);
return AUD_openMixdownDevice(specs, scene->sound_scene, volume, start / FPS);
}
-void BKE_sound_create_scene(struct Scene *scene)
+void BKE_sound_create_scene(Scene *scene)
{
+ sound_verify_evaluated_id(&scene->id);
+
/* should be done in version patch, but this gets called before */
if (scene->r.frs_sec_base == 0) {
scene->r.frs_sec_base = 1;
@@ -487,7 +515,7 @@ void BKE_sound_create_scene(struct Scene *scene)
scene->speaker_handles = NULL;
}
-void BKE_sound_destroy_scene(struct Scene *scene)
+void BKE_sound_destroy_scene(Scene *scene)
{
if (scene->playback_handle) {
AUD_Handle_stop(scene->playback_handle);
@@ -503,25 +531,32 @@ void BKE_sound_destroy_scene(struct Scene *scene)
}
}
-void BKE_sound_reset_scene_specs(struct Scene *scene)
+void BKE_sound_reset_scene_specs(Scene *scene)
{
- AUD_Specs specs;
+ sound_verify_evaluated_id(&scene->id);
- specs.channels = AUD_Device_getChannels(sound_device);
- specs.rate = AUD_Device_getRate(sound_device);
+ if (scene->sound_scene) {
+ AUD_Specs specs;
- AUD_Sequence_setSpecs(scene->sound_scene, specs);
+ specs.channels = AUD_Device_getChannels(sound_device);
+ specs.rate = AUD_Device_getRate(sound_device);
+
+ AUD_Sequence_setSpecs(scene->sound_scene, specs);
+ }
}
-void BKE_sound_mute_scene(struct Scene *scene, int muted)
+void BKE_sound_mute_scene(Scene *scene, int muted)
{
+ sound_verify_evaluated_id(&scene->id);
if (scene->sound_scene) {
AUD_Sequence_setMuted(scene->sound_scene, muted);
}
}
-void BKE_sound_update_fps(struct Scene *scene)
+void BKE_sound_update_fps(Scene *scene)
{
+ sound_verify_evaluated_id(&scene->id);
+
if (scene->sound_scene) {
AUD_Sequence_setFPS(scene->sound_scene, FPS);
}
@@ -529,16 +564,19 @@ void BKE_sound_update_fps(struct Scene *scene)
BKE_sequencer_refresh_sound_length(scene);
}
-void BKE_sound_update_scene_listener(struct Scene *scene)
+void BKE_sound_update_scene_listener(Scene *scene)
{
+ sound_verify_evaluated_id(&scene->id);
+
AUD_Sequence_setSpeedOfSound(scene->sound_scene, scene->audio.speed_of_sound);
AUD_Sequence_setDopplerFactor(scene->sound_scene, scene->audio.doppler_factor);
AUD_Sequence_setDistanceModel(scene->sound_scene, scene->audio.distance_model);
}
void *BKE_sound_scene_add_scene_sound(
- struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip)
+ Scene *scene, Sequence *sequence, int startframe, int endframe, int frameskip)
{
+ sound_verify_evaluated_id(&scene->id);
if (sequence->scene && scene != sequence->scene) {
const double fps = FPS;
return AUD_Sequence_add(scene->sound_scene,
@@ -550,7 +588,7 @@ void *BKE_sound_scene_add_scene_sound(
return NULL;
}
-void *BKE_sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence)
+void *BKE_sound_scene_add_scene_sound_defaults(Scene *scene, Sequence *sequence)
{
return BKE_sound_scene_add_scene_sound(scene,
sequence,
@@ -560,8 +598,9 @@ void *BKE_sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Seque
}
void *BKE_sound_add_scene_sound(
- struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip)
+ Scene *scene, Sequence *sequence, int startframe, int endframe, int frameskip)
{
+ sound_verify_evaluated_id(&scene->id);
/* Happens when sequence's sound datablock was removed. */
if (sequence->sound == NULL) {
return NULL;
@@ -579,7 +618,7 @@ void *BKE_sound_add_scene_sound(
return handle;
}
-void *BKE_sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence)
+void *BKE_sound_add_scene_sound_defaults(Scene *scene, Sequence *sequence)
{
return BKE_sound_add_scene_sound(scene,
sequence,
@@ -588,7 +627,7 @@ void *BKE_sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence *s
sequence->startofs + sequence->anim_startofs);
}
-void BKE_sound_remove_scene_sound(struct Scene *scene, void *handle)
+void BKE_sound_remove_scene_sound(Scene *scene, void *handle)
{
AUD_Sequence_remove(scene->sound_scene, handle);
}
@@ -599,14 +638,16 @@ void BKE_sound_mute_scene_sound(void *handle, char mute)
}
void BKE_sound_move_scene_sound(
- struct Scene *scene, void *handle, int startframe, int endframe, int frameskip)
+ Scene *scene, void *handle, int startframe, int endframe, int frameskip)
{
+ sound_verify_evaluated_id(&scene->id);
const double fps = FPS;
AUD_SequenceEntry_move(handle, startframe / fps, endframe / fps, frameskip / fps);
}
-void BKE_sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence)
+void BKE_sound_move_scene_sound_defaults(Scene *scene, Sequence *sequence)
{
+ sound_verify_evaluated_id(&scene->id);
if (sequence->scene_sound) {
BKE_sound_move_scene_sound(scene,
sequence->scene_sound,
@@ -626,8 +667,9 @@ void BKE_sound_set_cfra(int cfra)
sound_cfra = cfra;
}
-void BKE_sound_set_scene_volume(struct Scene *scene, float volume)
+void BKE_sound_set_scene_volume(Scene *scene, float volume)
{
+ sound_verify_evaluated_id(&scene->id);
AUD_Sequence_setAnimationData(scene->sound_scene,
AUD_AP_VOLUME,
CFRA,
@@ -651,17 +693,21 @@ void BKE_sound_set_scene_sound_pan(void *handle, float pan, char animated)
AUD_SequenceEntry_setAnimationData(handle, AUD_AP_PANNING, sound_cfra, &pan, animated);
}
-void BKE_sound_update_sequencer(struct Main *main, bSound *sound)
+void BKE_sound_update_sequencer(Main *main, bSound *sound)
{
- struct Scene *scene;
+ BLI_assert(!"is not supposed to be used, is weird function.");
+
+ Scene *scene;
for (scene = main->scenes.first; scene; scene = scene->id.next) {
BKE_sequencer_update_sound(scene, sound);
}
}
-static void sound_start_play_scene(struct Scene *scene)
+static void sound_start_play_scene(Scene *scene)
{
+ sound_verify_evaluated_id(&scene->id);
+
if (scene->playback_handle) {
AUD_Handle_stop(scene->playback_handle);
}
@@ -673,8 +719,10 @@ static void sound_start_play_scene(struct Scene *scene)
}
}
-void BKE_sound_play_scene(struct Scene *scene)
+void BKE_sound_play_scene(Scene *scene)
{
+ sound_verify_evaluated_id(&scene->id);
+
AUD_Status status;
const float cur_time = (float)((double)CFRA / FPS);
@@ -704,7 +752,7 @@ void BKE_sound_play_scene(struct Scene *scene)
AUD_Device_unlock(sound_device);
}
-void BKE_sound_stop_scene(struct Scene *scene)
+void BKE_sound_stop_scene(Scene *scene)
{
if (scene->playback_handle) {
AUD_Handle_pause(scene->playback_handle);
@@ -715,8 +763,10 @@ void BKE_sound_stop_scene(struct Scene *scene)
}
}
-void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene)
+void BKE_sound_seek_scene(Main *bmain, Scene *scene)
{
+ sound_verify_evaluated_id(&scene->id);
+
AUD_Status status;
bScreen *screen;
int animation_playing;
@@ -748,9 +798,10 @@ void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene)
}
}
- if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) {
+ Scene *scene_orig = (Scene *)DEG_get_original_id(&scene->id);
+ if (scene_orig->audio.flag & AUDIO_SCRUB && !animation_playing) {
AUD_Handle_setPosition(scene->playback_handle, cur_time);
- if (scene->audio.flag & AUDIO_SYNC) {
+ if (scene_orig->audio.flag & AUDIO_SYNC) {
AUD_seekSynchronizer(scene->playback_handle, cur_time);
}
AUD_Handle_resume(scene->playback_handle);
@@ -766,7 +817,7 @@ void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene)
}
}
else {
- if (scene->audio.flag & AUDIO_SYNC) {
+ if (scene_orig->audio.flag & AUDIO_SYNC) {
AUD_seekSynchronizer(scene->playback_handle, cur_time);
}
else {
@@ -779,8 +830,10 @@ void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene)
AUD_Device_unlock(sound_device);
}
-float BKE_sound_sync_scene(struct Scene *scene)
+float BKE_sound_sync_scene(Scene *scene)
{
+ sound_verify_evaluated_id(&scene->id);
+
// Ugly: Blender doesn't like it when the animation is played back during rendering
if (G.is_rendering) {
return NAN_FLT;
@@ -797,8 +850,10 @@ float BKE_sound_sync_scene(struct Scene *scene)
return NAN_FLT;
}
-int BKE_sound_scene_playing(struct Scene *scene)
+int BKE_sound_scene_playing(Scene *scene)
{
+ sound_verify_evaluated_id(&scene->id);
+
// Ugly: Blender doesn't like it when the animation is played back during rendering
if (G.is_rendering) {
return -1;
@@ -829,6 +884,9 @@ void BKE_sound_free_waveform(bSound *sound)
sound->tags &= ~SOUND_TAGS_WAVEFORM_NO_RELOAD;
}
+/* TODO(sergey): Consider mamakinging this function fully autonomous, as in, not require having
+ * an existing playback handle. That would make it easy to read waveforms, which doesn't seem to
+ * be affected by evaluated scene (waveworm comes from file). */
void BKE_sound_read_waveform(bSound *sound, short *stop)
{
AUD_SoundInfo info = AUD_getInfo(sound->playback_handle);
@@ -877,11 +935,14 @@ static void sound_update_base(Scene *scene, Base *base, void *new_set)
Speaker *speaker;
float quat[4];
- if ((ob->id.tag & LIB_TAG_DOIT) == 0) {
- return;
- }
+ sound_verify_evaluated_id(&scene->id);
+ sound_verify_evaluated_id(&ob->id);
- ob->id.tag &= ~LIB_TAG_DOIT;
+ // TODO(sergey): Bring the test back, or make it a part of dependency graph update.
+ // if ((ob->id.tag & LIB_TAG_DOIT) == 0) {
+ // return;
+ // }
+ // ob->id.tag &= ~LIB_TAG_DOIT;
if ((ob->type != OB_SPEAKER) || !ob->adt) {
return;
@@ -944,6 +1005,8 @@ static void sound_update_base(Scene *scene, Base *base, void *new_set)
void BKE_sound_update_scene(Main *bmain, Scene *scene)
{
+ sound_verify_evaluated_id(&scene->id);
+
Base *base;
Scene *sce_it;
@@ -953,7 +1016,8 @@ void BKE_sound_update_scene(Main *bmain, Scene *scene)
/* cheap test to skip looping over all objects (no speakers is a common case) */
if (!BLI_listbase_is_empty(&bmain->speakers)) {
- BKE_main_id_tag_listbase(&bmain->objects, LIB_TAG_DOIT, true);
+ // TODO(sergey): Bring the test back, or make it a part of dependency graph update.
+ // BKE_main_id_tag_listbase(&bmain->objects, LIB_TAG_DOIT, true);
for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
view_layer = view_layer->next) {
@@ -990,6 +1054,7 @@ void *BKE_sound_get_factory(void *sound)
/* stupid wrapper because AUD_C-API.h includes Python.h which makesrna doesn't like */
float BKE_sound_get_length(bSound *sound)
{
+ sound_verify_evaluated_id(&sound->id);
AUD_SoundInfo info = AUD_getInfo(sound->playback_handle);
return info.length;
@@ -1014,7 +1079,7 @@ void BKE_sound_force_device(const char *UNUSED(device))
void BKE_sound_init_once(void)
{
}
-void BKE_sound_init(struct Main *UNUSED(bmain))
+void BKE_sound_init(Main *UNUSED(bmain))
{
}
void BKE_sound_exit(void)
@@ -1023,110 +1088,107 @@ void BKE_sound_exit(void)
void BKE_sound_exit_once(void)
{
}
-void BKE_sound_cache(struct bSound *UNUSED(sound))
+void BKE_sound_cache(bSound *UNUSED(sound))
{
}
-void BKE_sound_delete_cache(struct bSound *UNUSED(sound))
+void BKE_sound_delete_cache(bSound *UNUSED(sound))
{
}
-void BKE_sound_load(struct Main *UNUSED(bmain), struct bSound *UNUSED(sound))
+void BKE_sound_load(Main *UNUSED(bmain), bSound *UNUSED(sound))
{
}
-void BKE_sound_create_scene(struct Scene *UNUSED(scene))
+void BKE_sound_create_scene(Scene *UNUSED(scene))
{
}
-void BKE_sound_destroy_scene(struct Scene *UNUSED(scene))
+void BKE_sound_destroy_scene(Scene *UNUSED(scene))
{
}
-void BKE_sound_reset_scene_specs(struct Scene *UNUSED(scene))
+void BKE_sound_reset_scene_specs(Scene *UNUSED(scene))
{
}
-void BKE_sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted))
+void BKE_sound_mute_scene(Scene *UNUSED(scene), int UNUSED(muted))
{
}
-void *BKE_sound_scene_add_scene_sound(struct Scene *UNUSED(scene),
- struct Sequence *UNUSED(sequence),
+void *BKE_sound_scene_add_scene_sound(Scene *UNUSED(scene),
+ Sequence *UNUSED(sequence),
int UNUSED(startframe),
int UNUSED(endframe),
int UNUSED(frameskip))
{
return NULL;
}
-void *BKE_sound_scene_add_scene_sound_defaults(struct Scene *UNUSED(scene),
- struct Sequence *UNUSED(sequence))
+void *BKE_sound_scene_add_scene_sound_defaults(Scene *UNUSED(scene), Sequence *UNUSED(sequence))
{
return NULL;
}
-void *BKE_sound_add_scene_sound(struct Scene *UNUSED(scene),
- struct Sequence *UNUSED(sequence),
+void *BKE_sound_add_scene_sound(Scene *UNUSED(scene),
+ Sequence *UNUSED(sequence),
int UNUSED(startframe),
int UNUSED(endframe),
int UNUSED(frameskip))
{
return NULL;
}
-void *BKE_sound_add_scene_sound_defaults(struct Scene *UNUSED(scene),
- struct Sequence *UNUSED(sequence))
+void *BKE_sound_add_scene_sound_defaults(Scene *UNUSED(scene), Sequence *UNUSED(sequence))
{
return NULL;
}
-void BKE_sound_remove_scene_sound(struct Scene *UNUSED(scene), void *UNUSED(handle))
+void BKE_sound_remove_scene_sound(Scene *UNUSED(scene), void *UNUSED(handle))
{
}
void BKE_sound_mute_scene_sound(void *UNUSED(handle), char UNUSED(mute))
{
}
-void BKE_sound_move_scene_sound(struct Scene *UNUSED(scene),
+void BKE_sound_move_scene_sound(Scene *UNUSED(scene),
void *UNUSED(handle),
int UNUSED(startframe),
int UNUSED(endframe),
int UNUSED(frameskip))
{
}
-void BKE_sound_move_scene_sound_defaults(struct Scene *UNUSED(scene),
- struct Sequence *UNUSED(sequence))
+void BKE_sound_move_scene_sound_defaults(Scene *UNUSED(scene), Sequence *UNUSED(sequence))
{
}
-void BKE_sound_play_scene(struct Scene *UNUSED(scene))
+void BKE_sound_play_scene(Scene *UNUSED(scene))
{
}
-void BKE_sound_stop_scene(struct Scene *UNUSED(scene))
+void BKE_sound_stop_scene(Scene *UNUSED(scene))
{
}
-void BKE_sound_seek_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene))
+void BKE_sound_seek_scene(Main *UNUSED(bmain), Scene *UNUSED(scene))
{
}
-float BKE_sound_sync_scene(struct Scene *UNUSED(scene))
+float BKE_sound_sync_scene(Scene *UNUSED(scene))
{
return NAN_FLT;
}
-int BKE_sound_scene_playing(struct Scene *UNUSED(scene))
+int BKE_sound_scene_playing(Scene *UNUSED(scene))
{
return -1;
}
-void BKE_sound_read_waveform(struct bSound *sound, short *stop)
+void BKE_sound_read_waveform(bSound *sound, short *stop)
{
UNUSED_VARS(sound, stop);
}
-void BKE_sound_init_main(struct Main *UNUSED(bmain))
+void BKE_sound_init_main(Main *UNUSED(bmain))
{
}
void BKE_sound_set_cfra(int UNUSED(cfra))
{
}
-void BKE_sound_update_sequencer(struct Main *UNUSED(main), struct bSound *UNUSED(sound))
+void BKE_sound_update_sequencer(Main *UNUSED(main), bSound *UNUSED(sound))
{
}
-void BKE_sound_update_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene))
+void BKE_sound_update_scene(Main *UNUSED(bmain), Scene *UNUSED(scene))
{
}
-void BKE_sound_update_scene_sound(void *UNUSED(handle), struct bSound *UNUSED(sound))
+void BKE_sound_update_scene_sound(void *UNUSED(handle), bSound *UNUSED(sound))
{
}
-void BKE_sound_update_scene_listener(struct Scene *UNUSED(scene))
+void BKE_sound_update_scene_listener(Scene *UNUSED(scene))
{
}
-void BKE_sound_update_fps(struct Scene *UNUSED(scene))
+void BKE_sound_update_fps(Scene *UNUSED(scene))
{
}
void BKE_sound_set_scene_sound_volume(void *UNUSED(handle),
@@ -1137,7 +1199,7 @@ void BKE_sound_set_scene_sound_volume(void *UNUSED(handle),
void BKE_sound_set_scene_sound_pan(void *UNUSED(handle), float UNUSED(pan), char UNUSED(animated))
{
}
-void BKE_sound_set_scene_volume(struct Scene *UNUSED(scene), float UNUSED(volume))
+void BKE_sound_set_scene_volume(Scene *UNUSED(scene), float UNUSED(volume))
{
}
void BKE_sound_set_scene_sound_pitch(void *UNUSED(handle),
@@ -1145,7 +1207,7 @@ void BKE_sound_set_scene_sound_pitch(void *UNUSED(handle),
char UNUSED(animated))
{
}
-float BKE_sound_get_length(struct bSound *UNUSED(sound))
+float BKE_sound_get_length(bSound *UNUSED(sound))
{
return 0;
}
@@ -1155,4 +1217,94 @@ char **BKE_sound_get_device_names(void)
return names;
}
+void BKE_sound_free_waveform(bSound *UNUSED(sound))
+{
+}
+
+void BKE_sound_load_audio(Main *UNUSED(bmain), bSound *UNUSED(sound))
+{
+}
+
#endif /* WITH_AUDASPACE */
+
+void BKE_sound_update_and_seek(Main *bmain, Depsgraph *depsgraph)
+{
+ Scene *scene_orig = DEG_get_input_scene(depsgraph);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ /* NOTE: We don't do copy-on-write or anything like that here because we need to know scene's
+ * flags like "scrubbing" in the BKE_sound_seek_scene(). So we simply update frame to which
+ * seek needs to happen.
+ *
+ * TODO(sergey): Might change API so the frame is passes explicitly. */
+ scene_eval->r.cfra = scene_orig->r.cfra;
+ BKE_sound_seek_scene(bmain, scene_eval);
+}
+
+void BKE_sound_reset_scene_runtime(Scene *scene)
+{
+ scene->sound_scene = NULL;
+ scene->playback_handle = NULL;
+ scene->sound_scrub_handle = NULL;
+ scene->speaker_handles = NULL;
+}
+
+void BKE_sound_ensure_scene(struct Scene *scene)
+{
+ if (scene->sound_scene != NULL) {
+ return;
+ }
+ BKE_sound_create_scene(scene);
+}
+
+void BKE_sound_reset_runtime(bSound *sound)
+{
+ sound->cache = NULL;
+ sound->playback_handle = NULL;
+}
+
+void BKE_sound_ensure_loaded(Main *bmain, bSound *sound)
+{
+ if (sound->cache != NULL) {
+ return;
+ }
+ BKE_sound_load(bmain, sound);
+}
+
+void BKE_sound_jack_sync_callback_set(SoundJackSyncCallback callback)
+{
+#if defined(WITH_AUDASPACE) && defined(WITH_JACK)
+ sound_jack_sync_callback = callback;
+#else
+ UNUSED_VARS(callback);
+#endif
+}
+
+void BKE_sound_jack_scene_update(Scene *scene, int mode, float time)
+{
+ sound_verify_evaluated_id(&scene->id);
+
+ /* Ugly: Blender doesn't like it when the animation is played back during rendering. */
+ if (G.is_rendering) {
+ return;
+ }
+
+ if (mode) {
+ BKE_sound_play_scene(scene);
+ }
+ else {
+ BKE_sound_stop_scene(scene);
+ }
+#ifdef WITH_AUDASPACE
+ if (scene->playback_handle != NULL) {
+ AUD_Handle_setPosition(scene->playback_handle, time);
+ }
+#else
+ UNUSED_VARS(time);
+#endif
+}
+
+void BKE_sound_evaluate(Depsgraph *depsgraph, Main *bmain, bSound *sound)
+{
+ DEG_debug_print_eval(depsgraph, __func__, sound->id.name, sound);
+ BKE_sound_ensure_loaded(bmain, sound);
+}
diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c
index 8565fde4565..c7a0d65a2a9 100644
--- a/source/blender/blenkernel/intern/speaker.c
+++ b/source/blender/blenkernel/intern/speaker.c
@@ -60,8 +60,10 @@ void *BKE_speaker_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Speaker ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Speaker ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index 315bd0cabc9..e0ff5fcccca 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -692,7 +692,8 @@ static float studiolight_spherical_harmonics_geomerics_eval(
const float normal[3], float sh0, float sh1, float sh2, float sh3)
{
/* Use Geomerics non-linear SH. */
- /* http://www.geomerics.com/wp-content/uploads/2015/08/CEDEC_Geomerics_ReconstructingDiffuseLighting1.pdf */
+ /* http://www.geomerics.com/wp-content/uploads/2015/08/CEDEC_Geomerics_ReconstructingDiffuseLighting1.pdf
+ */
float R0 = sh0 * M_1_PI;
float R1[3] = {-sh3, sh2, -sh1};
@@ -1283,7 +1284,8 @@ void BKE_studiolight_init(void)
BLI_addtail(&studiolights, sl);
/* 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 */
+ /* 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,
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index a58d1eaff3e..ad81fc49b19 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -305,8 +305,8 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
limit[0] = limit[1] = STD_UV_CONNECT_LIMIT;
/* previous behavior here is without accounting for winding, however this causes stretching in
- * UV map in really simple cases with mirror + subsurf, see second part of T44530. Also, initially
- * intention is to treat merged vertices from mirror modifier as seams.
+ * UV map in really simple cases with mirror + subsurf, see second part of T44530.
+ * Also, initially intention is to treat merged vertices from mirror modifier as seams.
* This fixes a very old regression (2.49 was correct here) */
vmap = BKE_mesh_uv_vert_map_create(mpoly, mloop, mloopuv, totface, totvert, limit, false, true);
if (!vmap) {
@@ -746,7 +746,7 @@ static void ss_sync_ccg_from_derivedmesh(CCGSubSurf *ss,
static int hasGivenError = 0;
if (!hasGivenError) {
- //XXX error("Unrecoverable error in SubSurf calculation,"
+ // XXX error("Unrecoverable error in SubSurf calculation,"
// " mesh is inconsistent.");
hasGivenError = 1;
@@ -1729,8 +1729,8 @@ static void ccgDM_foreachMappedLoop(DerivedMesh *dm,
void *userData,
DMForeachFlag flag)
{
- /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData, EditDerivedBMesh would
- * return loop data from bmesh itself. */
+ /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData,
+ * EditDerivedBMesh would return loop data from bmesh itself. */
const float(*lnors)[3] = (flag & DM_FOREACH_USE_NORMAL) ? DM_get_loop_data_layer(dm, CD_NORMAL) :
NULL;
@@ -1978,10 +1978,9 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
if (type == CD_TESSLOOPNORMAL) {
/* Create tessloopnormal on demand to save memory. */
- /* Note that since tessellated face corners are the same a loops in CCGDM, and since all faces have four
- * loops/corners, we can simplify the code here by converting tessloopnormals from 'short (*)[4][3]'
- * to 'short (*)[3]'.
- */
+ /* Note that since tessellated face corners are the same a loops in CCGDM,
+ * and since all faces have four loops/corners, we can simplify the code
+ * here by converting tessloopnormals from 'short (*)[4][3]' to 'short (*)[3]'. */
short(*tlnors)[3];
/* Avoid re-creation if the layer exists already */
@@ -2000,7 +1999,8 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
DM_add_tessface_layer(dm, CD_TESSLOOPNORMAL, CD_CALLOC, NULL);
tlnors = tlnors_it = (short(*)[3])DM_get_tessface_data_layer(dm, CD_TESSLOOPNORMAL);
- /* With ccgdm, we have a simple one to one mapping between loops and tessellated face corners. */
+ /* With ccgdm, we have a simple one to one mapping between loops
+ * and tessellated face corners. */
for (i = 0; i < numLoops; ++i, ++tlnors_it, ++lnors) {
normal_float_to_short_v3(*tlnors_it, *lnors);
}
@@ -2255,8 +2255,8 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
bool grid_pbvh = ccgDM_use_grid_pbvh(ccgdm);
if ((ob->mode & OB_MODE_SCULPT) == 0) {
/* In vwpaint, we may use a grid_pbvh for multires/subsurf, under certain conditions.
- * More complex cases break 'history' trail back to original vertices, in that case we fall back to
- * deformed cage only (i.e. original deformed mesh). */
+ * More complex cases break 'history' trail back to original vertices,
+ * in that case we fall back to deformed cage only (i.e. original deformed mesh). */
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
@@ -2294,8 +2294,8 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
}
if (ob->sculpt->pbvh) {
- /* Note that we have to clean up exisitng pbvh instead of updating it in case it does not match current
- * grid_pbvh status. */
+ /* Note that we have to clean up exisitng pbvh instead of updating it in case it does not
+ * match current grid_pbvh status. */
const PBVHType pbvh_type = BKE_pbvh_type(ob->sculpt->pbvh);
if (grid_pbvh) {
if (pbvh_type == PBVH_GRIDS) {
@@ -2438,7 +2438,8 @@ static void set_default_ccgdm_callbacks(CCGDerivedMesh *ccgdm)
ccgdm->dm.getNumVerts = ccgDM_getNumVerts;
ccgdm->dm.getNumEdges = ccgDM_getNumEdges;
ccgdm->dm.getNumLoops = ccgDM_getNumLoops;
- /* reuse of ccgDM_getNumTessFaces is intentional here: subsurf polys are just created from tessfaces */
+ /* reuse of ccgDM_getNumTessFaces is intentional here:
+ * subsurf polys are just created from tessfaces */
ccgdm->dm.getNumPolys = ccgDM_getNumPolys;
ccgdm->dm.getNumTessFaces = ccgDM_getNumTessFaces;
diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c
index 42e1ef6fa0a..47d536f4f4f 100644
--- a/source/blender/blenkernel/intern/suggestions.c
+++ b/source/blender/blenkernel/intern/suggestions.c
@@ -39,7 +39,7 @@
static Text *activeToolText = NULL;
static SuggList suggestions = {NULL, NULL, NULL, NULL, NULL};
static char *documentation = NULL;
-//static int doc_lines = 0;
+// static int doc_lines = 0;
static void txttl_free_suggest(void)
{
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 9047aa51dea..f07751e349f 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -464,8 +464,10 @@ Text *BKE_text_load(Main *bmain, const char *file, const char *relpath)
}
/**
- * Only copy internal data of Text ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Text ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -2004,7 +2006,7 @@ static void txt_undo_add_unprefix_op(Text *text,
BLI_assert(BLI_listbase_count(line_index_mask) == line_index_mask_len);
- /* OP byte + UInt32 count + counted UInt32 line numbers + UInt32 count + 12-bytes selection + OP byte */
+ /* OP byte + u32 count + counted u32 line numbers + u32 count + 12-bytes selection + OP byte. */
if (!max_undo_test(utxt, 2 + 4 + (line_index_mask_len * 4) + 4 + 12 + 1)) {
return;
}
@@ -2446,7 +2448,7 @@ void txt_do_undo(Text *text, TextUndoBuf *utxt)
break;
}
default:
- //XXX error("Undo buffer error - resetting");
+ // XXX error("Undo buffer error - resetting");
utxt->pos = -1;
break;
@@ -2638,7 +2640,7 @@ void txt_do_redo(Text *text, TextUndoBuf *utxt)
break;
}
default:
- //XXX error("Undo buffer error - resetting");
+ // XXX error("Undo buffer error - resetting");
utxt->pos = -1;
break;
@@ -3266,7 +3268,7 @@ int txt_setcurr_tab_spaces(Text *text, int space)
}
while (text->curl->line[i] == indent) {
- //we only count those tabs/spaces that are before any text or before the curs;
+ // we only count those tabs/spaces that are before any text or before the curs;
if (i == text->curc) {
return i;
}
@@ -3331,7 +3333,8 @@ int text_check_bracket(const char ch)
return 0;
}
-/* TODO, have a function for operators - http://docs.python.org/py3k/reference/lexical_analysis.html#operators */
+/* TODO, have a function for operators -
+ * http://docs.python.org/py3k/reference/lexical_analysis.html#operators */
bool text_check_delim(const char ch)
{
int a;
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index dd307880eb6..9baa8bd20e1 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -214,7 +214,8 @@ void BKE_texture_free(Tex *tex)
void BKE_texture_default(Tex *tex)
{
- /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(tex, id)); */ /* Not here, can be called with some pointers set. :/ */
+ /* Not here, can be called with some pointers set. :/ */
+ /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(tex, id)); */
tex->type = TEX_IMAGE;
tex->ima = NULL;
@@ -411,8 +412,10 @@ MTex *BKE_texture_mtex_add_id(ID *id, int slot)
/* ------------------------------------------------------------------------- */
/**
- * Only copy internal data of Texture ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Texture ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 73f50be612e..a5445be7ce5 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -209,7 +209,8 @@ static void tracking_tracks_copy(ListBase *tracks_dst,
}
}
-/* copy the whole list of plane tracks (need whole MovieTracking structures due to embedded pointers to tracks).
+/* Copy the whole list of plane tracks
+ * (need whole MovieTracking structures due to embedded pointers to tracks).
* WARNING: implies tracking_[dst/src] and their tracks have already been copied. */
static void tracking_plane_tracks_copy(ListBase *plane_tracks_list_dst,
const ListBase *plane_tracks_list_src,
@@ -321,7 +322,8 @@ void BKE_tracking_copy(MovieTracking *tracking_dst,
/* Warning! Will override tracks_mapping. */
tracking_objects_copy(&tracking_dst->objects, &tracking_src->objects, tracks_mapping, flag);
- /* Those remaining are runtime data, they will be reconstructed as needed, do not bother copying them. */
+ /* Those remaining are runtime data, they will be reconstructed as needed,
+ * do not bother copying them. */
tracking_dst->dopesheet.ok = false;
BLI_listbase_clear(&tracking_dst->dopesheet.channels);
BLI_listbase_clear(&tracking_dst->dopesheet.coverage_segments);
@@ -2093,7 +2095,8 @@ static void reconstructed_camera_scale_set(MovieTrackingObject *object, float ma
void BKE_tracking_camera_shift_get(
MovieTracking *tracking, int winx, int winy, float *shiftx, float *shifty)
{
- /* indeed in both of cases it should be winx -- it's just how camera shift works for blender's camera */
+ /* Indeed in both of cases it should be winx -
+ * it's just how camera shift works for blender's camera. */
*shiftx = (0.5f * winx - tracking->camera.principal[0]) / winx;
*shifty = (0.5f * winy - tracking->camera.principal[1]) / winx;
}
diff --git a/source/blender/blenkernel/intern/tracking_region_tracker.c b/source/blender/blenkernel/intern/tracking_region_tracker.c
index 0d2113aebe8..1d6bb88c3f4 100644
--- a/source/blender/blenkernel/intern/tracking_region_tracker.c
+++ b/source/blender/blenkernel/intern/tracking_region_tracker.c
@@ -252,7 +252,8 @@ static bool configure_and_run_tracker(ImBuf *destination_ibuf,
/* configure the tracker */
tracking_configure_tracker(track, mask, &options);
- /* convert the marker corners and center into pixel coordinates in the search/destination images. */
+ /* Convert the marker corners and center into pixel coordinates in the
+ * search/destination images. */
tracking_get_marker_coords_for_tracking(
frame_width, frame_height, reference_marker, src_pixel_x, src_pixel_y);
tracking_get_marker_coords_for_tracking(
diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c
index 1fe63e21e78..695f9b21559 100644
--- a/source/blender/blenkernel/intern/tracking_stabilize.c
+++ b/source/blender/blenkernel/intern/tracking_stabilize.c
@@ -275,10 +275,10 @@ static int search_closest_marker_index(MovieTrackingTrack *track, int ref_frame)
i = MAX2(0, i);
i = MIN2(i, end - 1);
for (; i < end - 1 && markers[i].framenr <= ref_frame; ++i) {
- ;
+ /* pass */
}
for (; 0 < i && markers[i].framenr > ref_frame; --i) {
- ;
+ /* pass */
}
track->last_marker = i;
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index d32bc7c6054..d3e0ff56977 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -135,7 +135,8 @@ static void undosys_id_ref_store(void *UNUSED(user_data), UndoRefID *id_ref)
static void undosys_id_ref_resolve(void *user_data, UndoRefID *id_ref)
{
- /* Note: we could optimize this, for now it's not too bad since it only runs when we access undo! */
+ /* Note: we could optimize this,
+ * for now it's not too bad since it only runs when we access undo! */
Main *bmain = user_data;
ListBase *lb = which_libbase(bmain, GS(id_ref->name));
for (ID *id = lb->first; id; id = id->next) {
@@ -154,7 +155,8 @@ static bool undosys_step_encode(bContext *C, Main *bmain, UndoStack *ustack, Und
UNDO_NESTED_CHECK_END;
if (ok) {
if (us->type->step_foreach_ID_ref != NULL) {
- /* Don't use from context yet because sometimes context is fake and not all members are filled in. */
+ /* Don't use from context yet because sometimes context is fake and
+ * not all members are filled in. */
us->type->step_foreach_ID_ref(us, undosys_id_ref_store, bmain);
}
#ifdef WITH_GLOBAL_UNDO_CORRECT_ORDER
@@ -193,7 +195,8 @@ static void undosys_step_decode(bContext *C, Main *bmain, UndoStack *ustack, Und
}
}
#endif
- /* Don't use from context yet because sometimes context is fake and not all members are filled in. */
+ /* Don't use from context yet because sometimes context is fake and
+ * not all members are filled in. */
us->type->step_foreach_ID_ref(us, undosys_id_ref_resolve, bmain);
}
@@ -429,7 +432,8 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size
}
}
#endif
- /* Free from first to last, free functions may update de-duplication info (see #MemFileUndoStep). */
+ /* Free from first to last, free functions may update de-duplication info
+ * (see #MemFileUndoStep). */
undosys_stack_clear_all_first(ustack, us->prev);
#ifdef WITH_GLOBAL_UNDO_KEEP_ONE
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index aa08370e139..f5b73d88867 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -426,8 +426,8 @@ static size_t unit_as_string(char *str,
value_conv = value / unit->scalar;
/* Adjust precision to expected number of significant digits.
- * Note that here, we shall not have to worry about very big/small numbers, units are expected to replace
- * 'scientific notation' in those cases. */
+ * Note that here, we shall not have to worry about very big/small numbers, units are expected to
+ * replace 'scientific notation' in those cases. */
prec -= integer_digits_d(value_conv);
CLAMP(prec, 0, 6);
@@ -663,7 +663,7 @@ static const char *unit_find_str(const char *str, const char *substr, bool case_
}
/* If str_found is not a valid unit, we have to check further in the string... */
for (str_found++; isalpha_or_utf8(*str_found); str_found++) {
- ;
+ /* pass */
}
str = str_found;
}
@@ -803,7 +803,8 @@ static const bUnitDef *unit_detect_from_str(const bUnitCollection *usys,
{
/* Try to find a default unit from current or previous string.
* This allows us to handle cases like 2 + 2mm, people would expect to get 4mm, not 2.002m!
- * Note this does not handle corner cases like 2 + 2cm + 1 + 2.5mm... We can't support everything. */
+ * Note this does not handle corner cases like 2 + 2cm + 1 + 2.5mm... We can't support
+ * everything. */
const bUnitDef *unit = NULL;
/* see which units the new value has */
@@ -889,10 +890,12 @@ bool bUnit_ReplaceString(
/* Try to find a default unit from current or previous string. */
default_unit = unit_detect_from_str(usys, str, str_prev);
- /* We apply the default unit to the whole expression (default unit is now the reference '1.0' one). */
+ /* We apply the default unit to the whole expression (default unit is now the reference '1.0'
+ * one). */
scale_pref_base *= default_unit->scalar;
- /* Apply the default unit on the whole expression, this allows to handle nasty cases like '2+2in'. */
+ /* Apply the default unit on the whole expression, this allows to handle nasty cases like
+ * '2+2in'. */
if (BLI_snprintf(str_tmp, sizeof(str_tmp), "(%s)*%.9g", str, default_unit->scalar) <
sizeof(str_tmp)) {
strncpy(str, str_tmp, len_max);
@@ -913,9 +916,9 @@ bool bUnit_ReplaceString(
{
/* try other unit systems now, so we can evaluate imperial when metric is set for eg. */
- /* Note that checking other systems at that point means we do not support their units as 'default' one.
- * In other words, when in metrics, typing '2+2in' will give 2 meters 2 inches, not 4 inches.
- * I do think this is the desired behavior!
+ /* Note that checking other systems at that point means we do not support their units as
+ * 'default' one. In other words, when in metrics, typing '2+2in' will give 2 meters 2 inches,
+ * not 4 inches. I do think this is the desired behavior!
*/
const bUnitCollection *usys_iter;
int system_iter;
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 2e9591a99c7..f9584adc6e0 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -113,8 +113,9 @@ static void *workspace_relation_get_data_matching_parent(const ListBase *relatio
}
/**
- * Checks if \a screen is already used within any workspace. A screen should never be assigned to multiple
- * WorkSpaceLayouts, but that should be ensured outside of the BKE_workspace module and without such checks.
+ * Checks if \a screen is already used within any workspace. A screen should never be assigned to
+ * multiple WorkSpaceLayouts, but that should be ensured outside of the BKE_workspace module
+ * and without such checks.
* Hence, this should only be used as assert check before assigining a screen to a workspace.
*/
#ifndef NDEBUG
@@ -143,8 +144,9 @@ WorkSpace *BKE_workspace_add(Main *bmain, const char *name)
}
/**
- * The function that actually frees the workspace data (not workspace itself). It shouldn't be called
- * directly, instead #BKE_workspace_remove should be, which calls this through #BKE_id_free then.
+ * The function that actually frees the workspace data (not workspace itself).
+ * It shouldn't be called directly, instead #BKE_workspace_remove should be,
+ * which calls this through #BKE_id_free then.
*
* Should something like a bke_internal.h be added, this should go there!
*/
@@ -275,7 +277,8 @@ WorkSpaceLayout *BKE_workspace_layout_find(const WorkSpace *workspace, const bSc
* Find the layout for \a screen without knowing which workspace to look in.
* Can also be used to find the workspace that contains \a screen.
*
- * \param r_workspace: Optionally return the workspace that contains the looked up layout (if found).
+ * \param r_workspace: Optionally return the workspace that contains the
+ * looked up layout (if found).
*/
WorkSpaceLayout *BKE_workspace_layout_find_global(const Main *bmain,
const bScreen *screen,
@@ -303,7 +306,8 @@ WorkSpaceLayout *BKE_workspace_layout_find_global(const Main *bmain,
/**
* Circular workspace layout iterator.
*
- * \param callback: Custom function which gets executed for each layout. Can return false to stop iterating.
+ * \param callback: Custom function which gets executed for each layout.
+ * Can return false to stop iterating.
* \param arg: Custom data passed to each \a callback call.
*
* \return the layout at which \a callback returned false.
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 741d67296df..109d615ae83 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -95,8 +95,10 @@ World *BKE_world_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of World ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of World ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 8456a2cddfc..a74d5b241ed 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -637,7 +637,7 @@ static AVStream *alloc_video_stream(FFMpegContext *context,
}
/* Deprecated and not doing anything since July 2015, deleted in recent ffmpeg */
- //c->me_method = ME_EPZS;
+ // c->me_method = ME_EPZS;
codec = avcodec_find_encoder(c->codec_id);
if (!codec) {
@@ -787,15 +787,16 @@ static AVStream *alloc_audio_stream(FFMpegContext *context,
codec = avcodec_find_encoder(c->codec_id);
if (!codec) {
- //XXX error("Couldn't find a valid audio codec");
+ // XXX error("Couldn't find a valid audio codec");
return NULL;
}
if (codec->sample_fmts) {
- /* check if the preferred sample format for this codec is supported.
- * this is because, depending on the version of libav, and with the whole ffmpeg/libav fork situation,
- * you have various implementations around. float samples in particular are not always supported.
- */
+ /* Check if the preferred sample format for this codec is supported.
+ * this is because, depending on the version of libav,
+ * and with the whole ffmpeg/libav fork situation,
+ * you have various implementations around.
+ * Float samples in particular are not always supported. */
const enum AVSampleFormat *p = codec->sample_fmts;
for (; *p != -1; p++) {
if (*p == st->codec->sample_fmt) {
@@ -830,7 +831,7 @@ static AVStream *alloc_audio_stream(FFMpegContext *context,
set_ffmpeg_properties(rd, c, "audio", &opts);
if (avcodec_open2(c, codec, &opts) < 0) {
- //XXX error("Couldn't initialize audio codec");
+ // XXX error("Couldn't initialize audio codec");
BLI_strncpy(error, IMB_ffmpeg_last_error(), error_size);
av_dict_free(&opts);
return NULL;
@@ -1522,7 +1523,6 @@ static IDProperty *BKE_ffmpeg_property_add(RenderData *rd,
(char
*)" ";
val.string.len = 80;
- /* val.str = (char *)" ";*/
idp_type = IDP_STRING;
break;
case AV_OPT_TYPE_CONST:
@@ -1636,7 +1636,9 @@ static void ffmpeg_set_expert_options(RenderData *rd)
* The other options were taken from the libx264-default.preset
* included in the ffmpeg distribution.
*/
- // ffmpeg_property_add_string(rd, "video", "flags:loop"); // this breaks compatibility for QT
+
+ /* This breaks compatibility for QT. */
+ // BKE_ffmpeg_property_add_string(rd, "video", "flags:loop");
BKE_ffmpeg_property_add_string(rd, "video", "cmp:chroma");
BKE_ffmpeg_property_add_string(rd, "video", "partitions:parti4x4"); // Deprecated.
BKE_ffmpeg_property_add_string(rd, "video", "partitions:partp8x8"); // Deprecated.
diff --git a/source/blender/blenkernel/nla_private.h b/source/blender/blenkernel/nla_private.h
index 59c9b4e7d33..dc086987e21 100644
--- a/source/blender/blenkernel/nla_private.h
+++ b/source/blender/blenkernel/nla_private.h
@@ -163,7 +163,8 @@ typedef struct NlaKeyframingContext {
float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode);
/* --------------- NLA Evaluation (very-private stuff) ----------------------- */
-/* these functions are only defined here to avoid problems with the order in which they get defined... */
+/* these functions are only defined here to avoid problems with the order
+ * in which they get defined. */
NlaEvalStrip *nlastrips_ctime_get_strip(
struct Depsgraph *depsgraph, ListBase *list, ListBase *strips, short index, float ctime);
diff --git a/source/blender/blenlib/BLI_compiler_compat.h b/source/blender/blenlib/BLI_compiler_compat.h
index 80c564a70c7..bd1cd327d3c 100644
--- a/source/blender/blenlib/BLI_compiler_compat.h
+++ b/source/blender/blenlib/BLI_compiler_compat.h
@@ -45,4 +45,10 @@ template<typename T> static inline T decltype_helper(T x)
# define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
# endif
+# if defined(__GNUC__)
+# define BLI_NOINLINE __attribute__((noinline))
+# else
+# define BLI_NOINLINE
+# endif
+
#endif /* __BLI_COMPILER_COMPAT_H__ */
diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h
index 5d7fc5eeee3..aa3d7520506 100644
--- a/source/blender/blenlib/BLI_listbase.h
+++ b/source/blender/blenlib/BLI_listbase.h
@@ -27,8 +27,8 @@
#include "BLI_compiler_attrs.h"
#include "BLI_utildefines.h"
#include "DNA_listBase.h"
-//struct ListBase;
-//struct LinkData;
+// struct ListBase;
+// struct LinkData;
#ifdef __cplusplus
extern "C" {
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index f73f2e6706e..f23580916b1 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -66,7 +66,7 @@ void BLI_rctf_interp(struct rctf *rect,
const struct rctf *rect_a,
const struct rctf *rect_b,
const float fac);
-//void BLI_rcti_interp(struct rctf *rect, struct rctf *rect_a, struct rctf *rect_b, float fac);
+// void BLI_rcti_interp(struct rctf *rect, struct rctf *rect_a, struct rctf *rect_b, float fac);
bool BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2]);
bool BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2]);
bool BLI_rctf_clamp(struct rctf *rect, const struct rctf *rect_bounds, float r_xy[2]);
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index f4b951dc8a3..dbc72ff1213 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -22,9 +22,9 @@ set(INC
.
# ../blenkernel # dont add this back!
../makesdna
- ../../../intern/guardedalloc
../../../intern/atomic
../../../intern/eigen
+ ../../../intern/guardedalloc
../../../intern/numaapi/include
../../../extern/wcwidth
)
diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c
index 59d80b45a84..7917730cd6a 100644
--- a/source/blender/blenlib/intern/DLRB_tree.c
+++ b/source/blender/blenlib/intern/DLRB_tree.c
@@ -515,7 +515,7 @@ static void insert_check_3(DLRBT_Tree *tree, DLRBT_Node *node)
if ((node == node->parent->left) && (node->parent == gp->left)) {
rotate_right(tree, gp);
}
- else { //if ((node == node->parent->right) && (node->parent == gp->right))
+ else { // if ((node == node->parent->right) && (node->parent == gp->right))
rotate_left(tree, gp);
}
}
diff --git a/source/blender/blenlib/intern/expr_pylike_eval.c b/source/blender/blenlib/intern/expr_pylike_eval.c
index 6dc0203ead2..49c7fb19b7d 100644
--- a/source/blender/blenlib/intern/expr_pylike_eval.c
+++ b/source/blender/blenlib/intern/expr_pylike_eval.c
@@ -164,7 +164,8 @@ eExprPyLike_EvalStatus BLI_expr_pylike_eval(ExprPyLike_Parsed *expr,
#define FAIL_IF(condition) \
if (condition) { \
return EXPR_PYLIKE_FATAL_ERROR; \
- }
+ } \
+ ((void)0)
/* Check the stack requirement is at least remotely sane and allocate on the actual stack. */
FAIL_IF(expr->max_stack <= 0 || expr->max_stack > 1000);
@@ -391,7 +392,8 @@ static BuiltinOpDef builtin_ops[] = {
#define CHECK_ERROR(condition) \
if (!(condition)) { \
return false; \
- }
+ } \
+ ((void)0)
/* For simplicity simple token types are represented by their own character;
* these are special identifiers for multi-character tokens. */
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index 92553ae89a9..7be7674069c 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -386,7 +386,7 @@ static int check_freetypefont(PackedFile *pf)
err = FT_New_Memory_Face(library, pf->data, pf->size, 0, &face);
if (err) {
success = 0;
- //XXX error("This is not a valid font");
+ // XXX error("This is not a valid font");
}
else {
glyph_index = FT_Get_Char_Index(face, 'A');
@@ -400,7 +400,7 @@ static int check_freetypefont(PackedFile *pf)
success = 1;
}
else {
- //XXX error("Selected Font has no outline data");
+ // XXX error("Selected Font has no outline data");
success = 0;
}
}
diff --git a/source/blender/blenlib/intern/hash_mm2a.c b/source/blender/blenlib/intern/hash_mm2a.c
index 32b6e1a5465..0899491cd0d 100644
--- a/source/blender/blenlib/intern/hash_mm2a.c
+++ b/source/blender/blenlib/intern/hash_mm2a.c
@@ -25,7 +25,7 @@
* See also:
* reference implementation:
* - https://smhasher.googlecode.com/svn-history/r130/trunk/MurmurHash2.cpp
- * - http://programmers.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed
+ * - http://programmers.stackexchange.com/questions/49550
*
* \warning Do not store that hash in files or such, it is not endian-agnostic,
* so you should only use it for temporary data.
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index fa018cca642..898e97613c1 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -2856,7 +2856,7 @@ bool isect_ray_aabb_v3(const struct IsectRayAABB_Precalc *data,
/* Note: tmax does not need to be updated since we don't use it
* keeping this here for future reference - jwilkins */
- //if (tzmax < tmax) tmax = tzmax;
+ // if (tzmax < tmax) tmax = tzmax;
if (tmin_out) {
(*tmin_out) = tmin;
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index 2fbf64e1200..e388cc06295 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -27,8 +27,8 @@
/* local */
static float noise3_perlin(float vec[3]);
-//static float turbulence_perlin(const float point[3], float lofreq, float hifreq);
-//static float turbulencep(float noisesize, float x, float y, float z, int nr);
+// static float turbulence_perlin(const float point[3], float lofreq, float hifreq);
+// static float turbulencep(float noisesize, float x, float y, float z, int nr);
/* UNUSED */
// #define HASHVEC(x, y, z) hashvectf + 3 * hash[(hash[(hash[(z) & 255] + (y)) & 255] + (x)) & 255]
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 64b8ff40bcf..b34a9c0a44e 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -52,7 +52,9 @@
#ifdef WIN32
# include <io.h>
# include <direct.h>
+# include <stdbool.h>
# include "BLI_winstuff.h"
+# include "BLI_string_utf8.h"
# include "utfconv.h"
#else
# include <sys/ioctl.h>
@@ -77,6 +79,15 @@
*/
char *BLI_current_working_dir(char *dir, const size_t maxncpy)
{
+#if defined(WIN32)
+ wchar_t path[MAX_PATH];
+ if (_wgetcwd(path, MAX_PATH)) {
+ if (BLI_strncpy_wchar_as_utf8(dir, path, maxncpy) != maxncpy) {
+ return dir;
+ }
+ }
+ return NULL;
+#else
const char *pwd = BLI_getenv("PWD");
if (pwd) {
size_t srclen = BLI_strnlen(pwd, maxncpy);
@@ -88,8 +99,8 @@ char *BLI_current_working_dir(char *dir, const size_t maxncpy)
return NULL;
}
}
-
return getcwd(dir, maxncpy);
+#endif
}
/**
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index 5b6c91ee1fe..8ab93ba382c 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -53,6 +53,7 @@ set(SRC
intern/versioning_260.c
intern/versioning_270.c
intern/versioning_280.c
+ intern/versioning_cycles.c
intern/versioning_defaults.c
intern/versioning_dna.c
intern/versioning_legacy.c
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 5e4fe4ce269..4b22a59a155 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -439,8 +439,9 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
#endif
}
}
- /* In any case, we need to move all lib datablocks themselves - those are 'first level data',
- * getting rid of them would imply updating spaces & co to prevent invalid pointers access. */
+ /* In any case, we need to move all lib datablocks themselves - those are
+ * 'first level data', getting rid of them would imply updating spaces & co
+ * to prevent invalid pointers access. */
BLI_movelisttolist(&newmain->libraries, &oldmain->libraries);
blo_join_main(&new_mainlist);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index b0f91dd4560..28412bf6f34 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -155,7 +155,6 @@
#include "DEG_depsgraph.h"
-#include "NOD_common.h"
#include "NOD_socket.h"
#include "BLO_blend_defs.h"
@@ -3307,7 +3306,8 @@ static void direct_link_cachefile(FileData *fd, CacheFile *cache_file)
{
BLI_listbase_clear(&cache_file->object_paths);
cache_file->handle = NULL;
- cache_file->handle_mutex = NULL;
+ cache_file->handle_filepath[0] = '\0';
+ cache_file->handle_readers = NULL;
/* relink animdata */
cache_file->adt = newdataadr(fd, cache_file->adt);
@@ -3401,35 +3401,46 @@ static void lib_link_workspace_instance_hook(FileData *fd, WorkSpaceInstanceHook
/* Single node tree (also used for material/scene trees), ntree is not NULL */
static void lib_link_ntree(FileData *fd, ID *id, bNodeTree *ntree)
{
- bNode *node;
- bNodeSocket *sock;
-
IDP_LibLinkProperty(ntree->id.properties, fd);
lib_link_animdata(fd, &ntree->id, ntree->adt);
ntree->gpd = newlibadr_us(fd, id->lib, ntree->gpd);
- for (node = ntree->nodes.first; node; node = node->next) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
/* Link ID Properties -- and copy this comment EXACTLY for easy finding
* of library blocks that implement this.*/
IDP_LibLinkProperty(node->prop, fd);
node->id = newlibadr_us(fd, id->lib, node->id);
- for (sock = node->inputs.first; sock; sock = sock->next) {
+ for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
IDP_LibLinkProperty(sock->prop, fd);
}
- for (sock = node->outputs.first; sock; sock = sock->next) {
+ for (bNodeSocket *sock = node->outputs.first; sock; sock = sock->next) {
IDP_LibLinkProperty(sock->prop, fd);
}
}
- for (sock = ntree->inputs.first; sock; sock = sock->next) {
+ for (bNodeSocket *sock = ntree->inputs.first; sock; sock = sock->next) {
IDP_LibLinkProperty(sock->prop, fd);
}
- for (sock = ntree->outputs.first; sock; sock = sock->next) {
+ for (bNodeSocket *sock = ntree->outputs.first; sock; sock = sock->next) {
IDP_LibLinkProperty(sock->prop, fd);
}
+
+ /* Set node->typeinfo pointers. This is done in lib linking, after the
+ * first versioning that can change types still without functions that
+ * update the typeinfo pointers. Versioning after lib linking needs
+ * these top be valid. */
+ ntreeSetTypes(NULL, ntree);
+
+ /* For nodes with static socket layout, add/remove sockets as needed
+ * to match the static layout. */
+ if (fd->memfile == NULL) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ node_verify_socket_templates(ntree, node);
+ }
+ }
}
/* library ntree linking after fileread */
@@ -3445,229 +3456,6 @@ static void lib_link_nodetree(FileData *fd, Main *main)
}
}
-/* updates group node socket identifier so that
- * external links to/from the group node are preserved.
- */
-static void lib_node_do_versions_group_indices(bNode *gnode)
-{
- bNodeTree *ngroup = (bNodeTree *)gnode->id;
- bNodeSocket *sock;
- bNodeLink *link;
-
- for (sock = gnode->outputs.first; sock; sock = sock->next) {
- int old_index = sock->to_index;
-
- for (link = ngroup->links.first; link; link = link->next) {
- if (link->tonode == NULL && link->fromsock->own_index == old_index) {
- strcpy(sock->identifier, link->fromsock->identifier);
- /* deprecated */
- sock->own_index = link->fromsock->own_index;
- sock->to_index = 0;
- sock->groupsock = NULL;
- }
- }
- }
- for (sock = gnode->inputs.first; sock; sock = sock->next) {
- int old_index = sock->to_index;
-
- for (link = ngroup->links.first; link; link = link->next) {
- if (link->fromnode == NULL && link->tosock->own_index == old_index) {
- strcpy(sock->identifier, link->tosock->identifier);
- /* deprecated */
- sock->own_index = link->tosock->own_index;
- sock->to_index = 0;
- sock->groupsock = NULL;
- }
- }
- }
-}
-
-/* verify types for nodes and groups, all data has to be read */
-/* open = 0: appending/linking, open = 1: open new file (need to clean out dynamic
- * typedefs */
-static void lib_verify_nodetree(Main *main, int UNUSED(open))
-{
- /* this crashes blender on undo/redo */
-#if 0
- if (open == 1) {
- reinit_nodesystem();
- }
-#endif
-
- /* set node->typeinfo pointers */
- FOREACH_NODETREE_BEGIN (main, ntree, id) {
- ntreeSetTypes(NULL, ntree);
- }
- FOREACH_NODETREE_END;
-
- /* verify static socket templates */
- FOREACH_NODETREE_BEGIN (main, ntree, id) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- node_verify_socket_templates(ntree, node);
- }
- }
- FOREACH_NODETREE_END;
-
- {
- bool has_old_groups = false;
- /* XXX this should actually be part of do_versions, but since we need
- * finished library linking, it is not possible there. Instead in do_versions
- * we have set the NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2 flag, so at this point we can do the
- * actual group node updates.
- */
- for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
- if (ntree->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2) {
- has_old_groups = 1;
- }
- }
-
- if (has_old_groups) {
- 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;
- if (ngroup && (ngroup->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2)) {
- lib_node_do_versions_group_indices(node);
- }
- }
- }
- }
- FOREACH_NODETREE_END;
- }
-
- for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
- ntree->flag &= ~NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2;
- }
- }
-
- {
- /* Convert the previously used ntree->inputs/ntree->outputs lists to interface nodes.
- * Pre 2.56.2 node trees automatically have all unlinked sockets exposed already
- * (see NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2).
- *
- * XXX this should actually be part of do_versions,
- * but needs valid typeinfo pointers to create interface nodes.
- *
- * Note: theoretically only needed in node groups (main->nodetree),
- * but due to a temporary bug such links could have been added in all trees,
- * so have to clean up all of them ...
- */
-
- 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;
- bNodeLink *link, *next_link;
- /* Only create new interface nodes for actual older files.
- * New file versions already have input/output nodes with duplicate links,
- * in that case just remove the invalid links.
- */
- const bool create_io_nodes = (ntree->flag &
- NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE) != 0;
-
- 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 offsety = 0.0f;*/
-
- if (create_io_nodes) {
- if (ntree->inputs.first) {
- input_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_INPUT);
- }
-
- if (ntree->outputs.first) {
- output_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_OUTPUT);
- }
- }
-
- /* Redirect links from/to the node tree interface to input/output node.
- * If the fromnode/tonode pointers are NULL, this means a link from/to
- * the ntree interface sockets, which need to be redirected to new interface nodes.
- */
- for (link = ntree->links.first; link; link = next_link) {
- bool free_link = false;
- next_link = link->next;
-
- if (link->fromnode == NULL) {
- if (input_node) {
- link->fromnode = input_node;
- link->fromsock = node_group_input_find_socket(input_node,
- link->fromsock->identifier);
- ++num_inputs;
-
- if (link->tonode) {
- if (input_locx > link->tonode->locx - offsetx) {
- input_locx = link->tonode->locx - offsetx;
- }
- input_locy += link->tonode->locy;
- }
- }
- else {
- free_link = true;
- }
- }
-
- if (link->tonode == NULL) {
- if (output_node) {
- link->tonode = output_node;
- link->tosock = node_group_output_find_socket(output_node, link->tosock->identifier);
- ++num_outputs;
-
- if (link->fromnode) {
- if (output_locx < link->fromnode->locx + offsetx) {
- output_locx = link->fromnode->locx + offsetx;
- }
- output_locy += link->fromnode->locy;
- }
- }
- else {
- free_link = true;
- }
- }
-
- if (free_link) {
- nodeRemLink(ntree, link);
- }
- }
-
- if (num_inputs > 0) {
- input_locy /= num_inputs;
- input_node->locx = input_locx;
- input_node->locy = input_locy;
- }
- if (num_outputs > 0) {
- output_locy /= num_outputs;
- output_node->locx = output_locx;
- output_node->locy = output_locy;
- }
-
- /* clear do_versions flags */
- ntree->flag &= ~(NTREE_DO_VERSIONS_CUSTOMNODES_GROUP |
- NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE);
- }
- }
- FOREACH_NODETREE_END;
- }
-
- /* verify all group user nodes */
- for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
- ntreeVerifyNodes(main, &ntree->id);
- }
-
- /* make update calls where necessary */
- {
- FOREACH_NODETREE_BEGIN (main, ntree, id) {
- /* make an update call for the tree */
- ntreeUpdateTree(main, ntree);
- }
- FOREACH_NODETREE_END;
- }
-}
-
static void direct_link_node_socket(FileData *fd, bNodeSocket *sock)
{
sock->prop = newdataadr(fd, sock->prop);
@@ -3953,6 +3741,7 @@ static void direct_link_constraints(FileData *fd, ListBase *lb)
case CONSTRAINT_TYPE_TRANSFORM_CACHE: {
bTransformCacheConstraint *data = con->data;
data->reader = NULL;
+ data->reader_object_path[0] = '\0';
}
}
}
@@ -5959,6 +5748,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
else if (md->type == eModifierType_MeshSequenceCache) {
MeshSeqCacheModifierData *msmcd = (MeshSeqCacheModifierData *)md;
msmcd->reader = NULL;
+ msmcd->reader_object_path[0] = '\0';
}
else if (md->type == eModifierType_SurfaceDeform) {
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
@@ -6676,9 +6466,7 @@ static void lib_link_scene(FileData *fd, Main *main)
seq->scene_sound = NULL;
if (seq->scene) {
seq->scene = newlibadr(fd, sce->id.lib, seq->scene);
- if (seq->scene) {
- seq->scene_sound = BKE_sound_scene_add_scene_sound_defaults(sce, seq);
- }
+ seq->scene_sound = NULL;
}
if (seq->clip) {
seq->clip = newlibadr_us(fd, sce->id.lib, seq->clip);
@@ -6699,7 +6487,7 @@ static void lib_link_scene(FileData *fd, Main *main)
}
if (seq->sound) {
id_us_plus_no_lib((ID *)seq->sound);
- seq->scene_sound = BKE_sound_add_scene_sound_defaults(sce, seq);
+ seq->scene_sound = NULL;
}
}
if (seq->type == SEQ_TYPE_TEXT) {
@@ -6718,9 +6506,6 @@ static void lib_link_scene(FileData *fd, Main *main)
}
}
- BKE_sequencer_update_muting(sce->ed);
- BKE_sequencer_update_sound_bounds_all(sce);
-
/* rigidbody world relies on it's linked collections */
if (sce->rigidbody_world) {
RigidBodyWorld *rbw = sce->rigidbody_world;
@@ -6902,7 +6687,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
memset(&sce->customdata_mask, 0, sizeof(sce->customdata_mask));
memset(&sce->customdata_mask_modal, 0, sizeof(sce->customdata_mask_modal));
- BKE_sound_create_scene(sce);
+ BKE_sound_reset_scene_runtime(sce);
/* set users to one by default, not in lib-link, this will increase it for compo nodes */
id_us_ensure_real(&sce->id);
@@ -6959,6 +6744,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
ed = sce->ed = newdataadr(fd, sce->ed);
ed->act_seq = newdataadr(fd, ed->act_seq);
+ ed->cache = NULL;
/* recursive link sequences, lb will be correctly initialized */
link_recurs_seq(fd, &ed->seqbase);
@@ -7087,6 +6873,11 @@ static void direct_link_scene(FileData *fd, Scene *sce)
}
}
+#ifdef DURIAN_CAMERA_SWITCH
+ /* Runtime */
+ sce->r.mode &= ~R_NO_CAMERA_SWITCH;
+#endif
+
sce->r.avicodecdata = newdataadr(fd, sce->r.avicodecdata);
if (sce->r.avicodecdata) {
sce->r.avicodecdata->lpFormat = newdataadr(fd, sce->r.avicodecdata->lpFormat);
@@ -7601,7 +7392,7 @@ static void direct_link_area(FileData *fd, ScrArea *area)
link_list(fd, &sconsole->scrollback);
link_list(fd, &sconsole->history);
- //for (cl= sconsole->scrollback.first; cl; cl= cl->next)
+ // for (cl= sconsole->scrollback.first; cl; cl= cl->next)
// cl->line= newdataadr(fd, cl->line);
/* comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
@@ -8289,7 +8080,8 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
BLI_mempool_iternew(so->treestore, &iter);
while ((tselem = BLI_mempool_iterstep(&iter))) {
- /* Do not try to restore pointers to drivers/sequence/etc., can crash in undo case! */
+ /* Do not try to restore pointers to drivers/sequence/etc.,
+ * can crash in undo case! */
if (TSE_IS_REAL_ID(tselem)) {
tselem->id = restore_pointer_by_name(id_map, tselem->id, USER_IGNORE);
}
@@ -8636,10 +8428,9 @@ static void direct_link_sound(FileData *fd, bSound *sound)
sound->waveform = NULL;
}
- if (sound->spinlock) {
- sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
- BLI_spin_init(sound->spinlock);
- }
+ sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
+ BLI_spin_init(sound->spinlock);
+
/* clear waveform loading flag */
sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING;
@@ -8656,7 +8447,7 @@ static void lib_link_sound(FileData *fd, Main *main)
sound->ipo = newlibadr_us(
fd, sound->id.lib, sound->ipo); // XXX deprecated - old animation system
- BKE_sound_load(main, sound);
+ BKE_sound_reset_runtime(sound);
sound->id.tag &= ~LIB_TAG_NEED_LINK;
}
@@ -9660,6 +9451,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
blo_do_versions_260(fd, lib, main);
blo_do_versions_270(fd, lib, main);
blo_do_versions_280(fd, lib, main);
+ blo_do_versions_cycles(fd, lib, main);
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */
@@ -9672,8 +9464,11 @@ static void do_versions_after_linking(Main *main)
// printf("%s for %s (%s), %d.%d\n", __func__, main->curlib ? main->curlib->name : main->name,
// main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile);
+ do_versions_after_linking_250(main);
+ do_versions_after_linking_260(main);
do_versions_after_linking_270(main);
do_versions_after_linking_280(main);
+ do_versions_after_linking_cycles(main);
}
/** \} */
@@ -9952,14 +9747,15 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
do_versions_after_linking(mainvar);
}
blo_join_main(&mainlist);
+
+ /* After all data has been read and versioned, uses LIB_TAG_NEW. */
+ ntreeUpdateAllNew(bfd->main);
}
BKE_main_id_tag_all(bfd->main, LIB_TAG_NEW, false);
- /* Before static overrides, which needs typeinfo. */
- lib_verify_nodetree(bfd->main, true);
-
- /* Now that all our data-blocks are loaded, we can re-generate overrides from their references. */
+ /* Now that all our data-blocks are loaded,
+ * we can re-generate overrides from their references. */
if (fd->memfile == NULL) {
/* Do not apply in undo case! */
BKE_main_override_static_update(bfd->main);
@@ -11736,9 +11532,11 @@ static void library_link_end(Main *mainl,
mainvar = (*fd)->mainlist->first;
MEM_freeN((*fd)->mainlist);
+ /* After all data has been read and versioned, uses LIB_TAG_NEW. */
+ ntreeUpdateAllNew(mainvar);
+
BKE_main_id_tag_all(mainvar, LIB_TAG_NEW, false);
- lib_verify_nodetree(mainvar, false);
fix_relpaths_library(BKE_main_blendfile_path(mainvar),
mainvar); /* make all relative paths, relative to the open blend file */
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 1122950771c..7cd5bb7ac93 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -182,8 +182,12 @@ void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *
void blo_do_versions_260(struct FileData *fd, struct Library *lib, struct Main *bmain);
void blo_do_versions_270(struct FileData *fd, struct Library *lib, struct Main *bmain);
void blo_do_versions_280(struct FileData *fd, struct Library *lib, struct Main *bmain);
+void blo_do_versions_cycles(struct FileData *fd, struct Library *lib, struct Main *bmain);
+void do_versions_after_linking_250(struct Main *bmain);
+void do_versions_after_linking_260(struct Main *bmain);
void do_versions_after_linking_270(struct Main *bmain);
void do_versions_after_linking_280(struct Main *bmain);
+void do_versions_after_linking_cycles(struct Main *bmain);
#endif
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index d7c26564576..face4b61d1e 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -277,7 +277,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
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.flag |= V2D_IS_INITIALISED;
break;
}
case SPACE_GRAPH: {
@@ -294,7 +294,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
ar->v2d.max[0] = MAXFRAMEF;
ar->v2d.max[1] = FLT_MAX;
- //ar->v2d.flag |= V2D_IS_INITIALISED;
+ // ar->v2d.flag |= V2D_IS_INITIALISED;
break;
}
case SPACE_NLA: {
@@ -386,7 +386,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
SpaceText *st = (SpaceText *)sl;
st->flags |= ST_FIND_WRAP;
}
- //case SPACE_XXX: // FIXME... add other ones
+ // case SPACE_XXX: // FIXME... add other ones
// memcpy(&ar->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D));
// break;
}
@@ -645,8 +645,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
Tex *tx;
ParticleSettings *part;
Object *ob;
- //PTCacheID *pid;
- //ListBase pidlist;
+ // PTCacheID *pid;
+ // ListBase pidlist;
bSound *sound;
Sequence *seq;
@@ -756,12 +756,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
/* set old pointcaches to have disk cache flag */
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- //BKE_ptcache_ids_from_object(&pidlist, ob);
+ // BKE_ptcache_ids_from_object(&pidlist, ob);
- //for (pid = pidlist.first; pid; pid = pid->next)
+ // for (pid = pidlist.first; pid; pid = pid->next)
// pid->cache->flag |= PTCACHE_DISK_CACHE;
- //BLI_freelistN(&pidlist);
+ // BLI_freelistN(&pidlist);
}
/* type was a mixed flag & enum. move the 2d flag elsewhere */
@@ -780,18 +780,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
Tex *tex;
Scene *sce;
ToolSettings *ts;
- //PTCacheID *pid;
- //ListBase pidlist;
+ // PTCacheID *pid;
+ // ListBase pidlist;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- //BKE_ptcache_ids_from_object(&pidlist, ob);
+ // BKE_ptcache_ids_from_object(&pidlist, ob);
- //for (pid = pidlist.first; pid; pid = pid->next) {
+ // for (pid = pidlist.first; pid; pid = pid->next) {
// if (BLI_listbase_is_empty(pid->ptcaches))
// pid->ptcaches->first = pid->ptcaches->last = pid->cache;
//}
- //BLI_freelistN(&pidlist);
+ // BLI_freelistN(&pidlist);
if (ob->type == OB_MESH) {
Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data);
@@ -2030,12 +2030,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- /* XXX The external group node sockets needs to adjust their own_index to point at
- * associated ntree inputs/outputs internal sockets. However, this can only happen
- * after lib-linking (needs access to internal node group tree)!
- * Setting a temporary flag here, actual do_versions happens in lib_verify_nodetree.
- */
- ntree->flag |= NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2;
+ /* Externl group node socket need to adjust their own_index to point at
+ * associated ntree inputs/outputs internal sockets. This happens in
+ * do_versions_after_linking_250, after lib linking. */
}
}
@@ -2296,3 +2293,59 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
}
+
+/* updates group node socket identifier so that
+ * external links to/from the group node are preserved.
+ */
+static void lib_node_do_versions_group_indices(bNode *gnode)
+{
+ bNodeTree *ngroup = (bNodeTree *)gnode->id;
+ bNodeSocket *sock;
+ bNodeLink *link;
+
+ for (sock = gnode->outputs.first; sock; sock = sock->next) {
+ int old_index = sock->to_index;
+
+ for (link = ngroup->links.first; link; link = link->next) {
+ if (link->tonode == NULL && link->fromsock->own_index == old_index) {
+ strcpy(sock->identifier, link->fromsock->identifier);
+ /* deprecated */
+ sock->own_index = link->fromsock->own_index;
+ sock->to_index = 0;
+ sock->groupsock = NULL;
+ }
+ }
+ }
+ for (sock = gnode->inputs.first; sock; sock = sock->next) {
+ int old_index = sock->to_index;
+
+ for (link = ngroup->links.first; link; link = link->next) {
+ if (link->fromnode == NULL && link->tosock->own_index == old_index) {
+ strcpy(sock->identifier, link->tosock->identifier);
+ /* deprecated */
+ sock->own_index = link->tosock->own_index;
+ sock->to_index = 0;
+ sock->groupsock = NULL;
+ }
+ }
+ }
+}
+
+void do_versions_after_linking_250(Main *bmain)
+{
+ if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
+ FOREACH_NODETREE_BEGIN (bmain, 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;
+ if (ngroup) {
+ lib_node_do_versions_group_indices(node);
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+}
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 6c9ec7607a2..77ef27182f2 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -67,6 +67,7 @@
#include "IMB_imbuf.h" // for proxy / timecode versioning stuff
+#include "NOD_common.h"
#include "NOD_texture.h"
#include "BLO_readfile.h"
@@ -1949,28 +1950,6 @@ 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_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
- * on file load in new versions.
- * Once forward compatibility is not required any longer, make a subversion bump
- * and only execute this for older versions.
- */
- ntree->flag |= NTREE_DO_VERSIONS_CUSTOMNODES_GROUP;
-
- /* Only add interface nodes once.
- * In old Blender versions they will be removed automatically due to undefined type */
- if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
- ntree->flag |= NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE;
- }
- }
- FOREACH_NODETREE_END;
- }
-
if (MAIN_VERSION_OLDER(bmain, 266, 3)) {
{
/* Fix for a very old issue:
@@ -2018,7 +1997,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (bmain->versionfile < 267) {
- //if (!DNA_struct_elem_find(fd->filesdna, "Brush", "int", "stencil_pos")) {
+ // if (!DNA_struct_elem_find(fd->filesdna, "Brush", "int", "stencil_pos")) {
Brush *brush;
for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
@@ -2571,3 +2550,126 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+void do_versions_after_linking_260(Main *bmain)
+{
+ /* Convert the previously used ntree->inputs/ntree->outputs lists to interface nodes.
+ * Pre 2.56.2 node trees automatically have all unlinked sockets exposed already,
+ * see do_versions_after_linking_250.
+ *
+ * This assumes valid typeinfo pointers, as set in lib_link_ntree.
+ *
+ * Note: theoretically only needed in node groups (main->nodetree),
+ * but due to a temporary bug such links could have been added in all trees,
+ * so have to clean up all of them ...
+ *
+ * Note: this always runs, without it links with NULL fromnode and tonode remain
+ * which causes problems.
+ */
+ if (!MAIN_VERSION_ATLEAST(bmain, 266, 3)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ bNode *input_node = NULL, *output_node = NULL;
+ int num_inputs = 0, num_outputs = 0;
+ bNodeLink *link, *next_link;
+ /* Only create new interface nodes for actual older files.
+ * New file versions already have input/output nodes with duplicate links,
+ * in that case just remove the invalid links.
+ */
+ const bool create_io_nodes = MAIN_VERSION_OLDER(bmain, 266, 2);
+
+ 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 offsety = 0.0f;*/
+
+ if (create_io_nodes) {
+ if (ntree->inputs.first) {
+ input_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_INPUT);
+ }
+
+ if (ntree->outputs.first) {
+ output_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_OUTPUT);
+ }
+ }
+
+ /* Redirect links from/to the node tree interface to input/output node.
+ * If the fromnode/tonode pointers are NULL, this means a link from/to
+ * the ntree interface sockets, which need to be redirected to new interface nodes.
+ */
+ for (link = ntree->links.first; link; link = next_link) {
+ bool free_link = false;
+ next_link = link->next;
+
+ if (link->fromnode == NULL) {
+ if (input_node) {
+ link->fromnode = input_node;
+ link->fromsock = node_group_input_find_socket(input_node, link->fromsock->identifier);
+ ++num_inputs;
+
+ if (link->tonode) {
+ if (input_locx > link->tonode->locx - offsetx) {
+ input_locx = link->tonode->locx - offsetx;
+ }
+ input_locy += link->tonode->locy;
+ }
+ }
+ else {
+ free_link = true;
+ }
+ }
+
+ if (link->tonode == NULL) {
+ if (output_node) {
+ link->tonode = output_node;
+ link->tosock = node_group_output_find_socket(output_node, link->tosock->identifier);
+ ++num_outputs;
+
+ if (link->fromnode) {
+ if (output_locx < link->fromnode->locx + offsetx) {
+ output_locx = link->fromnode->locx + offsetx;
+ }
+ output_locy += link->fromnode->locy;
+ }
+ }
+ else {
+ free_link = true;
+ }
+ }
+
+ if (free_link) {
+ nodeRemLink(ntree, link);
+ }
+ }
+
+ if (num_inputs > 0) {
+ input_locy /= num_inputs;
+ input_node->locx = input_locx;
+ input_node->locy = input_locy;
+ }
+ if (num_outputs > 0) {
+ output_locy /= num_outputs;
+ output_node->locx = output_locx;
+ output_node->locy = output_locy;
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 60)) {
+ /* From this point we no longer write incomplete links for forward
+ * compatibility with 2.66, we have to clean them up for all previous
+ * versions. */
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ bNodeLink *link, *next_link;
+
+ for (link = ntree->links.first; link; link = next_link) {
+ next_link = link->next;
+ if (link->fromnode == NULL || link->tonode == NULL) {
+ nodeRemLink(ntree, link);
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 4b78993fc2f..3a16389dfda 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1077,6 +1077,14 @@ static void do_versions_seq_unique_name_all_strips(Scene *sce, ListBase *seqbase
}
}
+static void do_versions_seq_set_cache_defaults(Editing *ed)
+{
+ ed->cache_flag = SEQ_CACHE_STORE_FINAL_OUT;
+ ed->cache_flag |= SEQ_CACHE_VIEW_FINAL_OUT;
+ ed->cache_flag |= SEQ_CACHE_VIEW_ENABLE;
+ ed->recycle_max_cost = 10.0f;
+}
+
void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
bool use_collection_compat_28 = true;
@@ -3254,21 +3262,27 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
/* All spaces that use tools must be eventually added. */
+ ARegion *ar = NULL;
if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_IMAGE) &&
- (do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOL_HEADER) == NULL)) {
+ ((ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOL_HEADER)) == NULL)) {
/* Add tool header. */
- ARegion *ar = do_versions_add_region(RGN_TYPE_TOOL_HEADER, "tool header");
+ ar = do_versions_add_region(RGN_TYPE_TOOL_HEADER, "tool header");
ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER);
BLI_insertlinkbefore(regionbase, ar_header, ar);
+ /* Hide by default, enable for painting workspaces (startup only). */
+ ar->flag |= RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
+ }
+ if (ar != NULL) {
+ SET_FLAG_FROM_TEST(ar->flag, ar->flag & RGN_FLAG_HIDDEN_BY_USER, RGN_FLAG_HIDDEN);
}
}
}
}
}
- {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 60)) {
if (!DNA_struct_elem_find(fd->filesdna, "bSplineIKConstraint", "short", "yScaleMode")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->pose) {
@@ -3299,6 +3313,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "char", "render_aa")) {
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ scene->display.render_aa = SCE_DISPLAY_AA_SAMPLES_8;
+ scene->display.viewport_aa = SCE_DISPLAY_AA_FXAA;
+ }
+ }
/* Split bbone_scalein/bbone_scaleout into x and y fields. */
if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "scale_out_y")) {
@@ -3326,6 +3346,14 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
BKE_animdata_main_cb(bmain, do_version_bbone_scale_animdata_cb, NULL);
}
+ for (Scene *sce = bmain->scenes.first; sce != NULL; sce = sce->id.next) {
+ if (sce->ed != NULL) {
+ do_versions_seq_set_cache_defaults(sce->ed);
+ }
+ }
+ }
+
+ {
/* Versioning code until next subversion bump goes here. */
}
}
diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c
new file mode 100644
index 00000000000..023bd685352
--- /dev/null
+++ b/source/blender/blenloader/intern/versioning_cycles.c
@@ -0,0 +1,332 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup blenloader
+ */
+
+/* allow readfile to use deprecated functionality */
+#define DNA_DEPRECATED_ALLOW
+
+#include <float.h>
+#include <string.h>
+
+#include "BLI_math.h"
+#include "BLI_string.h"
+#include "BLI_utildefines.h"
+
+#include "DNA_color_types.h"
+#include "DNA_light_types.h"
+#include "DNA_node_types.h"
+#include "DNA_particle_types.h"
+
+#include "BKE_colortools.h"
+#include "BKE_idprop.h"
+#include "BKE_main.h"
+#include "BKE_node.h"
+
+#include "BLO_readfile.h"
+#include "readfile.h"
+
+static float *cycles_node_socket_float_value(bNodeSocket *socket)
+{
+ bNodeSocketValueFloat *socket_data = socket->default_value;
+ return &socket_data->value;
+}
+
+static IDProperty *cycles_properties_from_ID(ID *id)
+{
+ IDProperty *idprop = IDP_GetProperties(id, false);
+ return (idprop) ? IDP_GetPropertyTypeFromGroup(idprop, "cycles", IDP_GROUP) : NULL;
+}
+
+static float cycles_property_float(IDProperty *idprop, const char *name, float default_value)
+{
+ IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_FLOAT);
+ return (prop) ? IDP_Float(prop) : default_value;
+}
+
+static bool cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value)
+{
+ IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_INT);
+ return (prop) ? IDP_Int(prop) : default_value;
+}
+
+static void displacement_node_insert(bNodeTree *ntree)
+{
+ bool need_update = false;
+
+ /* Iterate backwards from end so we don't encounter newly added links. */
+ bNodeLink *prevlink;
+ for (bNodeLink *link = ntree->links.last; link; link = prevlink) {
+ prevlink = link->prev;
+
+ /* Detect link to replace. */
+ bNode *fromnode = link->fromnode;
+ bNodeSocket *fromsock = link->fromsock;
+ bNode *tonode = link->tonode;
+ bNodeSocket *tosock = link->tosock;
+
+ if (!(tonode->type == SH_NODE_OUTPUT_MATERIAL && fromnode->type != SH_NODE_DISPLACEMENT &&
+ STREQ(tosock->identifier, "Displacement"))) {
+ continue;
+ }
+
+ /* Replace link with displacement node. */
+ nodeRemLink(ntree, link);
+
+ /* Add displacement node. */
+ bNode *node = nodeAddStaticNode(NULL, ntree, SH_NODE_DISPLACEMENT);
+ node->locx = 0.5f * (fromnode->locx + tonode->locx);
+ node->locy = 0.5f * (fromnode->locy + tonode->locy);
+
+ bNodeSocket *scale_socket = nodeFindSocket(node, SOCK_IN, "Scale");
+ bNodeSocket *midlevel_socket = nodeFindSocket(node, SOCK_IN, "Midlevel");
+ bNodeSocket *height_socket = nodeFindSocket(node, SOCK_IN, "Height");
+ bNodeSocket *displacement_socket = nodeFindSocket(node, SOCK_OUT, "Displacement");
+
+ /* Set default values for compatibility. */
+ *cycles_node_socket_float_value(scale_socket) = 0.1f;
+ *cycles_node_socket_float_value(midlevel_socket) = 0.0f;
+
+ /* Link to input and material output node. */
+ nodeAddLink(ntree, fromnode, fromsock, node, height_socket);
+ nodeAddLink(ntree, node, displacement_socket, tonode, tosock);
+
+ need_update = true;
+ }
+
+ if (need_update) {
+ ntreeUpdateTree(NULL, ntree);
+ }
+}
+
+static void displacement_principled_nodes(bNode *node)
+{
+ if (node->type == SH_NODE_DISPLACEMENT) {
+ if (node->custom1 != SHD_SPACE_WORLD) {
+ node->custom1 = SHD_SPACE_OBJECT;
+ }
+ }
+ else if (node->type == SH_NODE_BSDF_PRINCIPLED) {
+ if (node->custom2 != SHD_SUBSURFACE_RANDOM_WALK) {
+ node->custom2 = SHD_SUBSURFACE_BURLEY;
+ }
+ }
+}
+
+static bool node_has_roughness(bNode *node)
+{
+ return ELEM(node->type,
+ SH_NODE_BSDF_ANISOTROPIC,
+ SH_NODE_BSDF_GLASS,
+ SH_NODE_BSDF_GLOSSY,
+ SH_NODE_BSDF_REFRACTION);
+}
+
+static void square_roughness_node_insert(bNodeTree *ntree)
+{
+ bool need_update = false;
+
+ /* Update default values */
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node_has_roughness(node)) {
+ bNodeSocket *roughness_input = nodeFindSocket(node, SOCK_IN, "Roughness");
+ float *roughness_value = cycles_node_socket_float_value(roughness_input);
+ *roughness_value = sqrtf(max_ff(*roughness_value, 0.0f));
+ }
+ }
+
+ /* Iterate backwards from end so we don't encounter newly added links. */
+ bNodeLink *prevlink;
+ for (bNodeLink *link = ntree->links.last; link; link = prevlink) {
+ prevlink = link->prev;
+
+ /* Detect link to replace. */
+ bNode *fromnode = link->fromnode;
+ bNodeSocket *fromsock = link->fromsock;
+ bNode *tonode = link->tonode;
+ bNodeSocket *tosock = link->tosock;
+
+ if (!(node_has_roughness(tonode) && STREQ(tosock->identifier, "Roughness"))) {
+ continue;
+ }
+
+ /* Replace links with sqrt node */
+ nodeRemLink(ntree, link);
+
+ /* Add sqrt node. */
+ bNode *node = nodeAddStaticNode(NULL, ntree, SH_NODE_MATH);
+ node->custom1 = NODE_MATH_POW;
+ node->locx = 0.5f * (fromnode->locx + tonode->locx);
+ node->locy = 0.5f * (fromnode->locy + tonode->locy);
+
+ /* Link to input and material output node. */
+ *cycles_node_socket_float_value(node->inputs.last) = 0.5f;
+ nodeAddLink(ntree, fromnode, fromsock, node, node->inputs.first);
+ nodeAddLink(ntree, node, node->outputs.first, tonode, tosock);
+
+ need_update = true;
+ }
+
+ if (need_update) {
+ ntreeUpdateTree(NULL, ntree);
+ }
+}
+
+static void mapping_node_order_flip(bNode *node)
+{
+ /* Flip euler order of mapping shader node */
+ if (node->type == SH_NODE_MAPPING) {
+ TexMapping *texmap = node->storage;
+
+ float quat[4];
+ eulO_to_quat(quat, texmap->rot, EULER_ORDER_ZYX);
+ quat_to_eulO(texmap->rot, EULER_ORDER_XYZ, quat);
+ }
+}
+
+static void vector_curve_node_remap(bNode *node)
+{
+ /* Remap values of vector curve node from normalized to absolute values */
+ if (node->type == SH_NODE_CURVE_VEC) {
+ CurveMapping *mapping = node->storage;
+ mapping->flag &= ~CUMA_DO_CLIP;
+
+ for (int curve_index = 0; curve_index < CM_TOT; curve_index++) {
+ CurveMap *cm = &mapping->cm[curve_index];
+ if (cm->curve) {
+ for (int i = 0; i < mapping->cm->totpoint; i++) {
+ cm->curve[i].x = (cm->curve[i].x * 2.0f) - 1.0f;
+ cm->curve[i].y = (cm->curve[i].y - 0.5f) * 2.0f;
+ }
+ }
+ }
+
+ curvemapping_changed_all(mapping);
+ }
+}
+
+static void ambient_occlusion_node_relink(bNodeTree *ntree)
+{
+ bool need_update = false;
+
+ /* Set default values. */
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == SH_NODE_AMBIENT_OCCLUSION) {
+ node->custom1 = 1; /* samples */
+ node->custom2 &= ~SHD_AO_LOCAL;
+
+ bNodeSocket *distance_socket = nodeFindSocket(node, SOCK_IN, "Distance");
+ *cycles_node_socket_float_value(distance_socket) = 0.0f;
+ }
+ }
+
+ /* Iterate backwards from end so we don't encounter newly added links. */
+ bNodeLink *prevlink;
+ for (bNodeLink *link = ntree->links.last; link; link = prevlink) {
+ prevlink = link->prev;
+
+ /* Detect link to replace. */
+ bNode *fromnode = link->fromnode;
+ bNode *tonode = link->tonode;
+ bNodeSocket *tosock = link->tosock;
+
+ if (!(fromnode->type == SH_NODE_AMBIENT_OCCLUSION)) {
+ continue;
+ }
+
+ /* Replace links with color socket. */
+ nodeRemLink(ntree, link);
+ bNodeSocket *color_socket = nodeFindSocket(fromnode, SOCK_OUT, "Color");
+ nodeAddLink(ntree, fromnode, color_socket, tonode, tosock);
+
+ need_update = true;
+ }
+
+ if (need_update) {
+ ntreeUpdateTree(NULL, ntree);
+ }
+}
+
+void blo_do_versions_cycles(FileData *UNUSED(fd), Library *UNUSED(lib), Main *bmain)
+{
+ /* Particle shape shared with Eevee. */
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 16)) {
+ for (ParticleSettings *part = bmain->particles.first; part; part = part->id.next) {
+ IDProperty *cpart = cycles_properties_from_ID(&part->id);
+
+ if (cpart) {
+ part->shape = cycles_property_float(cpart, "shape", 0.0);
+ part->rad_root = cycles_property_float(cpart, "root_width", 1.0);
+ part->rad_tip = cycles_property_float(cpart, "tip_width", 0.0);
+ part->rad_scale = cycles_property_float(cpart, "radius_scale", 0.01);
+ if (cycles_property_boolean(cpart, "use_closetip", true)) {
+ part->shape_flag |= PART_SHAPE_CLOSE_TIP;
+ }
+ }
+ }
+ }
+}
+
+void do_versions_after_linking_cycles(Main *bmain)
+{
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 5)) {
+ /* Shader node tree changes. After lib linking so we have all the typeinfo
+ * pointers and updated sockets and we can use the high level node API to
+ * manipulate nodes. */
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type != NTREE_SHADER) {
+ continue;
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 5)) {
+ /* Euler order was ZYX in previous versions. */
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ mapping_node_order_flip(node);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 276, 6)) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ vector_curve_node_remap(node);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 2) ||
+ (MAIN_VERSION_ATLEAST(bmain, 280, 0) && !MAIN_VERSION_ATLEAST(bmain, 280, 4))) {
+ displacement_node_insert(ntree);
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 3)) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ displacement_principled_nodes(node);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 4) ||
+ (MAIN_VERSION_ATLEAST(bmain, 280, 0) && !MAIN_VERSION_ATLEAST(bmain, 280, 5))) {
+ /* Switch to squared roughness convention */
+ square_roughness_node_insert(ntree);
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 5)) {
+ ambient_occlusion_node_relink(ntree);
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index b5b86224644..1da9d692440 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -68,6 +68,11 @@ 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;
+
+ U.flag &= ~(USER_DEVELOPER_UI | USER_TOOLTIPS_PYTHON);
+
/* Clear addon preferences. */
for (bAddon *addon = U.addons.first, *addon_next; addon != NULL; addon = addon_next) {
addon_next = addon->next;
@@ -79,9 +84,6 @@ void BLO_update_defaults_userpref_blend(void)
}
}
- /* 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' */
{
@@ -293,6 +295,39 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
}
}
+ /* Show toopbar for sculpt/paint modes. */
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ bool show_tool_header = false;
+ if (app_template == NULL) {
+ if (STR_ELEM(screen->id.name + 2, "Sculpting", "Texture Paint")) {
+ show_tool_header = true;
+ }
+ }
+ else if (STREQ(app_template, "2D_Animation")) {
+ if (STR_ELEM(screen->id.name + 2, "2D Animation", "2D Full Canvas")) {
+ show_tool_header = true;
+ }
+ }
+ else if (STREQ(app_template, "Sculpting")) {
+ if (STR_ELEM(screen->id.name + 2, "Sculpting")) {
+ show_tool_header = true;
+ }
+ }
+
+ if (show_tool_header) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_TOOL_HEADER) {
+ ar->flag &= ~(RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER);
+ }
+ }
+ }
+ }
+ }
+ }
+
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
@@ -354,6 +389,13 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
copy_v2_fl2(scene->safe_areas.action, 0.035f, 0.035f);
}
+ if (app_template == NULL) {
+ /* Enable for UV sculpt (other brush types will be created as needed),
+ * without this the grab brush will be active but not selectable from the list. */
+ Brush *brush = BLI_findstring(&bmain->brushes, "Grab", offsetof(ID, name) + 2);
+ brush->ob_mode |= OB_MODE_EDIT;
+ }
+
for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
brush->blur_kernel_radius = 2;
}
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 6329a3959b9..df26ca37826 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -1042,33 +1042,33 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (sbuts->mainb == BUTS_LAMP) {
sbuts->mainb = CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_LAMP;
+ // sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_LAMP;
}
else if (sbuts->mainb == BUTS_MAT) {
sbuts->mainb = CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_MAT;
+ // sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_MAT;
}
else if (sbuts->mainb == BUTS_TEX) {
sbuts->mainb = CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_TEX;
+ // sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_TEX;
}
else if (sbuts->mainb == BUTS_ANIM) {
sbuts->mainb = CONTEXT_OBJECT;
}
else if (sbuts->mainb == BUTS_WORLD) {
sbuts->mainb = CONTEXT_SCENE;
- //sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_WORLD;
+ // sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_WORLD;
}
else if (sbuts->mainb == BUTS_RENDER) {
sbuts->mainb = CONTEXT_SCENE;
- //sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_RENDER;
+ // sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_RENDER;
}
else if (sbuts->mainb == BUTS_FPAINT) {
sbuts->mainb = CONTEXT_EDITING;
}
else if (sbuts->mainb == BUTS_RADIO) {
sbuts->mainb = CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_RAD;
+ // sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_RAD;
}
else if (sbuts->mainb == BUTS_CONSTRAINT) {
sbuts->mainb = CONTEXT_OBJECT;
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 91f605460c9..46fd58e59c1 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -113,6 +113,15 @@ static void do_versions_theme(UserDef *userdef, bTheme *btheme)
FROM_DEFAULT_V4_UCHAR(space_info.info_info);
}
+ /**
+ * Include next version bump.
+ */
+ {
+ if (btheme->space_view3d.obcenter_dia == 0) {
+ btheme->space_view3d.obcenter_dia = U_theme_default.space_view3d.obcenter_dia;
+ }
+ }
+
#undef FROM_DEFAULT_V4_UCHAR
#undef USER_VERSION_ATLEAST
@@ -212,9 +221,6 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
}
if (!USER_VERSION_ATLEAST(240, 0)) {
userdef->uiflag |= USER_PLAINMENUS;
- if (userdef->obcenter_dia == 0) {
- userdef->obcenter_dia = 6;
- }
}
if (!USER_VERSION_ATLEAST(242, 0)) {
/* set defaults for 3D View rotating axis indicator */
@@ -530,6 +536,12 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
}
}
+ /* patch to set Dupli Lightprobes and Grease Pencil */
+ if (!USER_VERSION_ATLEAST(280, 58)) {
+ userdef->dupflag |= USER_DUP_LIGHTPROBE;
+ userdef->dupflag |= USER_DUP_GPENCIL;
+ }
+
/**
* Include next version bump.
*/
@@ -539,6 +551,10 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
userdef->vbocollectrate = 60;
userdef->vbotimeout = 120;
}
+
+ if (userdef->lookdev_ball_size == 0) {
+ userdef->lookdev_ball_size = 150;
+ }
}
if (userdef->pixelsize == 0.0f) {
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 8d3815eb319..1e2bbc138a3 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -168,10 +168,6 @@
#include "BKE_subsurf.h"
#include "BKE_workspace.h"
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
-# include "NOD_socket.h" /* for sock->default_value data */
-#endif
-
#include "BLO_blend_defs.h"
#include "BLO_blend_validate.h"
#include "BLO_readfile.h"
@@ -959,32 +955,8 @@ static void write_curvemapping(WriteData *wd, CurveMapping *cumap)
write_curvemapping_curves(wd, cumap);
}
-static void write_node_socket(WriteData *wd,
- bNodeTree *UNUSED(ntree),
- bNode *node,
- bNodeSocket *sock)
+static void write_node_socket(WriteData *wd, bNodeSocket *sock)
{
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* forward compatibility code, so older blenders still open (not for undo) */
- if (wd->use_memfile == false) {
- sock->stack_type = 1;
-
- if (node->type == NODE_GROUP) {
- bNodeTree *ngroup = (bNodeTree *)node->id;
- if (ngroup) {
- /* for node groups: look up the deprecated groupsock pointer */
- sock->groupsock = ntreeFindSocketInterface(ngroup, sock->in_out, sock->identifier);
- BLI_assert(sock->groupsock != NULL);
-
- /* node group sockets now use the generic identifier string to verify group nodes,
- * old blender uses the own_index.
- */
- sock->own_index = sock->groupsock->own_index;
- }
- }
- }
-#endif
-
/* actual socket writing */
writestruct(wd, DATA, bNodeSocket, 1, sock);
@@ -996,18 +968,8 @@ static void write_node_socket(WriteData *wd,
writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value);
}
}
-static void write_node_socket_interface(WriteData *wd, bNodeTree *UNUSED(ntree), bNodeSocket *sock)
+static void write_node_socket_interface(WriteData *wd, bNodeSocket *sock)
{
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* forward compatibility code, so older blenders still open */
- sock->stack_type = 1;
-
- /* Reconstruct the deprecated default_value structs in socket interface DNA. */
- if (sock->default_value == NULL && sock->typeinfo) {
- node_socket_init_default_value(sock);
- }
-#endif
-
/* actual socket writing */
writestruct(wd, DATA, bNodeSocket, 1, sock);
@@ -1040,10 +1002,10 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree)
}
for (sock = node->inputs.first; sock; sock = sock->next) {
- write_node_socket(wd, ntree, node, sock);
+ write_node_socket(wd, sock);
}
for (sock = node->outputs.first; sock; sock = sock->next) {
- write_node_socket(wd, ntree, node, sock);
+ write_node_socket(wd, sock);
}
for (link = node->internal_links.first; link; link = link->next) {
@@ -1127,10 +1089,10 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree)
}
for (sock = ntree->inputs.first; sock; sock = sock->next) {
- write_node_socket_interface(wd, ntree, sock);
+ write_node_socket_interface(wd, sock);
}
for (sock = ntree->outputs.first; sock; sock = sock->next) {
- write_node_socket_interface(wd, ntree, sock);
+ write_node_socket_interface(wd, sock);
}
}
@@ -3172,76 +3134,6 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree)
}
}
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
-static void customnodes_add_deprecated_data(Main *mainvar)
-{
- FOREACH_NODETREE_BEGIN (mainvar, ntree, id) {
- bNodeLink *link, *last_link = ntree->links.last;
-
- /* only do this for node groups */
- if (id != &ntree->id) {
- continue;
- }
-
- /* Forward compatibility for group nodes: add links to node tree interface sockets.
- * These links are invalid by new rules (missing node pointer)!
- * They will be removed again in customnodes_free_deprecated_data,
- * cannot do this directly lest bNodeLink pointer mapping becomes ambiguous.
- * When loading files with such links in a new Blender version
- * they will be removed as well.
- */
- for (link = ntree->links.first; link; link = link->next) {
- bNode *fromnode = link->fromnode, *tonode = link->tonode;
- bNodeSocket *fromsock = link->fromsock, *tosock = link->tosock;
-
- /* check both sides of the link, to handle direct input-to-output links */
- if (fromnode->type == NODE_GROUP_INPUT) {
- fromnode = NULL;
- fromsock = ntreeFindSocketInterface(ntree, SOCK_IN, fromsock->identifier);
- }
- /* only the active output node defines links */
- if (tonode->type == NODE_GROUP_OUTPUT && (tonode->flag & NODE_DO_OUTPUT)) {
- tonode = NULL;
- tosock = ntreeFindSocketInterface(ntree, SOCK_OUT, tosock->identifier);
- }
-
- if (!fromnode || !tonode) {
- /* Note: not using nodeAddLink here, it asserts existing node pointers */
- bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "group node link");
- tlink->fromnode = fromnode;
- tlink->fromsock = fromsock;
- tlink->tonode = tonode;
- tlink->tosock = tosock;
- tosock->link = tlink;
- tlink->flag |= NODE_LINK_VALID;
- BLI_addtail(&ntree->links, tlink);
- }
-
- /* don't check newly created compatibility links */
- if (link == last_link) {
- break;
- }
- }
- }
- FOREACH_NODETREE_END;
-}
-
-static void customnodes_free_deprecated_data(Main *mainvar)
-{
- FOREACH_NODETREE_BEGIN (mainvar, ntree, id) {
- bNodeLink *link, *next_link;
-
- for (link = ntree->links.first; link; link = next_link) {
- next_link = link->next;
- if (link->fromnode == NULL || link->tonode == NULL) {
- nodeRemLink(ntree, link);
- }
- }
- }
- FOREACH_NODETREE_END;
-}
-#endif
-
static void write_brush(WriteData *wd, Brush *brush)
{
if (brush->id.us > 0 || wd->use_memfile) {
@@ -3876,14 +3768,6 @@ static bool write_file_handle(Main *mainvar,
wd = mywrite_begin(ww, compare, current);
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* don't write compatibility data on undo */
- if (!current) {
- /* deprecated forward compat data is freed again below */
- customnodes_add_deprecated_data(mainvar);
- }
-#endif
-
sprintf(buf,
"BLENDER%c%c%.3d",
(sizeof(void *) == 8) ? '-' : '_',
@@ -4076,17 +3960,6 @@ static bool write_file_handle(Main *mainvar,
* so writing each time uses the same address and doesn't cause unnecessary undo overhead. */
writedata(wd, DNA1, wd->sdna->data_len, wd->sdna->data);
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* compatibility data not created on undo */
- if (!current) {
- /* Ugly, forward compatibility code generates deprecated data during writing,
- * this has to be freed again. Can not be done directly after writing, otherwise
- * the data pointers could be reused and not be mapped correctly.
- */
- customnodes_free_deprecated_data(mainvar);
- }
-#endif
-
/* end of file */
memset(&bhead, 0, sizeof(BHead));
bhead.code = ENDB;
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index 4ba9d13c8a0..f5095ca2b5f 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -24,9 +24,9 @@ set(INC
../blenlib
../blentranslation
../makesdna
- ../../../intern/guardedalloc
../../../intern/atomic
../../../intern/eigen
+ ../../../intern/guardedalloc
../../../extern/rangetree
)
diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h
index dce6b8b79ec..b7356a89314 100644
--- a/source/blender/bmesh/bmesh.h
+++ b/source/blender/bmesh/bmesh.h
@@ -22,7 +22,8 @@
*
* \addtogroup bmesh BMesh
*
- * \brief BMesh is a non-manifold boundary representation designed to support advanced editing operations.
+ * \brief BMesh is a non-manifold boundary representation
+ * designed to support advanced editing operations.
* \section bm_structure The Structure
*
* BMesh stores topology in four main element structures:
@@ -32,7 +33,8 @@
* - Edges - BMEdge
* - Verts - BMVert
* \subsection bm_header_flags Header Flags
- * Each element (vertex/edge/face/loop) in a mesh has an associated bit-field called "header flags".
+ * Each element (vertex/edge/face/loop)
+ * in a mesh has an associated bit-field called "header flags".
*
* BMHeader flags should **never** be read or written to by bmesh operators (see Operators below).
*
@@ -81,7 +83,8 @@
* See source/blender/bmesh/bmesh_query.h for more misc. queries.
* \section bm_api The BMesh API
*
- * One of the goals of the BMesh API is to make it easy and natural to produce highly maintainable code.
+ * One of the goals of the BMesh API is to make it easy
+ * and natural to produce highly maintainable code.
* Code duplication, etc are avoided where possible.
* \subsection bm_iter_api Iterator API
*
@@ -95,15 +98,18 @@
* though a mechanism for plugging in new walkers needs to be added at some point.
*
* Most topological queries should go through these two APIs;
- * there are additional functions you can use for topological iteration, but their meant for internal bmesh code.
+ * there are additional functions you can use for topological iteration,
+ * but their meant for internal bmesh code.
*
- * Note that the walker API supports delimiter flags, to allow the caller to flag elements not to walk past.
+ * Note that the walker API supports delimiter flags,
+ * to allow the caller to flag elements not to walk past.
* \subsection bm_ops Operators
*
* Operators are an integral part of BMesh. Unlike regular blender operators,
* BMesh operators **bmo's** are designed to be nested (e.g. call other operators).
*
- * Each operator has a number of input/output "slots" which are used to pass settings & data into/out of the operator
+ * Each operator has a number of input/output "slots"
+ * which are used to pass settings & data into/out of the operator
* (and allows for chaining operators together).
*
* These slots are identified by name, using strings.
@@ -111,7 +117,8 @@
* Access to slots is done with ``BMO_slot_***()`` functions.
* \subsection bm_tool_flags Tool Flags
*
- * The BMesh API provides a set of flags for faces, edges and vertices, which are private to an operator.
+ * The BMesh API provides a set of flags for faces, edges and vertices,
+ * which are private to an operator.
* These flags may be used by the client operator code as needed
* (a common example is flagging elements for use in another operator).
* Each call to an operator allocates it's own set of tool flags when it's executed,
@@ -140,7 +147,8 @@
* - map - BMO_OP_SLOT_MAPPING - simple hash map.
* \subsection bm_slot_iter Slot Iterators
*
- * Access to element buffers or maps must go through the slot iterator api, defined in bmesh_operators.h.
+ * Access to element buffers or maps must go through the slot iterator api,
+ * defined in bmesh_operators.h.
* Use #BMO_ITER where ever possible.
* \subsection bm_elem_buf Element Buffers
*
@@ -149,14 +157,16 @@
* Many operators take in a buffer of elements, process it,
* then spit out a new one; this allows operators to be chained together.
*
- * \note Element buffers may have elements of different types within the same buffer (this is supported by the API.
+ * \note Element buffers may have elements of different types within the same buffer
+ * (this is supported by the API.
* \section bm_fname Function Naming Conventions
*
* These conventions should be used throughout the bmesh module.
*
* - ``bmesh_kernel_*()`` - Low level API, for primitive functions that others are built ontop of.
* - ``bmesh_***()`` - Low level API function.
- * - ``bm_***()`` - 'static' functions, not apart of the API at all, but use prefix since they operate on BMesh data.
+ * - ``bm_***()`` - 'static' functions, not apart of the API at all,
+ * but use prefix since they operate on BMesh data.
* - ``BM_***()`` - High level BMesh API function for use anywhere.
* - ``BMO_***()`` - High level operator API function for use anywhere.
* - ``bmo_***()`` - Low level / internal operator API functions.
@@ -168,11 +178,14 @@
*
* \subsection bm_todo_optimize Optimizations
*
- * - skip normal calc when its not needed (when calling chain of operators & for modifiers, flag as dirty)
- * - skip BMO flag allocation, its not needed in many cases, this is fairly redundant to calc by default.
- * - ability to call BMO's with option not to create return data (will save some time)
- * - binary diff UNDO, currently this uses huge amount of ram when all shapes are stored for each undo step for eg.
- * - use two different iterator types for BMO map/buffer types.
+ * - Skip normal calc when its not needed
+ * (when calling chain of operators & for modifiers, flag as dirty)
+ * - Skip BMO flag allocation, its not needed in many cases,
+ * this is fairly redundant to calc by default.
+ * - Ability to call BMO's with option not to create return data (will save some time)
+ * - Binary diff UNDO, currently this uses huge amount of ram
+ * when all shapes are stored for each undo step for eg.
+ * - Use two different iterator types for BMO map/buffer types.
*/
#ifdef __cplusplus
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 2cc5b1b8097..8349dee06e2 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -23,7 +23,8 @@
/* bmesh data structures */
-/* dissable holes for now, these are ifdef'd because they use more memory and cant be saved in DNA currently */
+/* dissable holes for now,
+ * these are ifdef'd because they use more memory and cant be saved in DNA currently */
// #define USE_BMESH_HOLES
struct BMEdge;
@@ -98,10 +99,12 @@ typedef struct BMVert {
float co[3]; /* vertex coordinates */
float no[3]; /* vertex normal */
- /* pointer to (any) edge using this vertex (for disk cycles)
+ /**
+ * Pointer to (any) edge using this vertex (for disk cycles).
*
- * note: some higher level functions set this to different edges that use this vertex,
- * which is a bit of an abuse of internal bmesh data but also works OK for now (use with care!).
+ * \note Some higher level functions set this to different edges that use this vertex,
+ * which is a bit of an abuse of internal bmesh data but also works OK for now
+ * (use with care!).
*/
struct BMEdge *e;
} BMVert;
@@ -125,8 +128,12 @@ typedef struct BMEdge {
* to access the other loops using the edge */
struct BMLoop *l;
- /* disk cycle pointers
- * relative data: d1 indicates indicates the next/prev edge around vertex v1 and d2 does the same for v2 */
+ /**
+ * Disk Cycle Pointers
+ *
+ * relative data: d1 indicates indicates the next/prev
+ * edge around vertex v1 and d2 does the same for v2.
+ */
BMDiskLink v1_disk_link, v2_disk_link;
} BMEdge;
@@ -281,7 +288,10 @@ typedef struct BMLoopNorEditData {
typedef struct BMLoopNorEditDataArray {
BMLoopNorEditData *lnor_editdata;
- /* This one has full amount of loops, used to map loop index to actual BMLoopNorEditData struct. */
+ /**
+ * This one has full amount of loops,
+ * used to map loop index to actual BMLoopNorEditData struct.
+ */
BMLoopNorEditData **lidx_to_lnor_editdata;
int cd_custom_normal_offset;
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index 4a4ea1e17a7..224f6ad1e5c 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -124,7 +124,8 @@ BMFace *BM_face_create_quad_tri(BMesh *bm,
/**
* \brief copies face loop data from shared adjacent faces.
*
- * \param filter_fn: A function that filters the source loops before copying (don't always want to copy all)
+ * \param filter_fn: A function that filters the source loops before copying
+ * (don't always want to copy all).
*
* \note when a matching edge is found, both loops of that edge are copied
* this is done since the face may not be completely surrounded by faces,
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index 36abb1dc5c4..6ece32e57e8 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -140,7 +140,8 @@ BMVert *BM_vert_create(BMesh *bm,
* \brief Main function for creating a new edge.
*
* \note Duplicate edges are supported by the API however users should _never_ see them.
- * so unless you need a unique edge or know the edge won't exist, you should call with \a no_double = true
+ * so unless you need a unique edge or know the edge won't exist,
+ * you should call with \a no_double = true.
*/
BMEdge *BM_edge_create(
BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *e_example, const eBMCreateFlag create_flag)
@@ -1417,8 +1418,9 @@ static BMFace *bm_face_create__sfme(BMesh *bm, BMFace *f_example)
*
* \warning this is a low level function, most likely you want to use #BM_face_split()
*
- * Takes as input two vertices in a single face. An edge is created which divides the original face
- * into two distinct regions. One of the regions is assigned to the original face and it is closed off.
+ * Takes as input two vertices in a single face.
+ * An edge is created which divides the original face into two distinct regions.
+ * One of the regions is assigned to the original face and it is closed off.
* The second region has a new face assigned to it.
*
* \par Examples:
@@ -1573,7 +1575,7 @@ BMFace *bmesh_kernel_split_face_make_edge(BMesh *bm,
}
else {
/* this code is not significant until holes actually work */
- //printf("warning: call to split face euler without holes argument; holes will be tossed.\n");
+ // printf("warning: call to split face euler without holes argument; holes will be tossed.\n");
for (lst = f->loops.last; lst != f->loops.first; lst = lst2) {
lst2 = lst->prev;
BLI_mempool_free(bm->looplistpool, lst);
@@ -1715,7 +1717,7 @@ BMVert *bmesh_kernel_split_edge_make_vert(BMesh *bm, BMVert *tv, BMEdge *e, BMEd
/* verify loop->v and loop->next->v pointers for e */
for (i = 0, l = e->l; i < radlen; i++, l = l->radial_next) {
BMESH_ASSERT(l->e == e);
- //BMESH_ASSERT(l->radial_next == l);
+ // BMESH_ASSERT(l->radial_next == l);
BMESH_ASSERT(!(l->prev->e != e_new && l->next->e != e_new));
edok = BM_verts_in_edge(l->v, l->next->v, e);
@@ -1944,7 +1946,8 @@ BMEdge *bmesh_kernel_join_edge_kill_vert(BMesh *bm,
*
* Collapse an edge, merging surrounding data.
*
- * Unlike #BM_vert_collapse_edge & #bmesh_kernel_join_edge_kill_vert which only handle 2 valence verts,
+ * Unlike #BM_vert_collapse_edge & #bmesh_kernel_join_edge_kill_vert
+ * which only handle 2 valence verts,
* this can handle any number of connected edges/faces.
*
* <pre>
@@ -2065,8 +2068,8 @@ BMVert *bmesh_kernel_join_vert_kill_edge(BMesh *bm,
* before attempting to fuse \a f1 and \a f2.
*
* \note The order of arguments decides whether or not certain per-face attributes are present
- * in the resultant face. For instance vertex winding, material index, smooth flags, etc are inherited
- * from \a f1, not \a f2.
+ * in the resultant face. For instance vertex winding, material index, smooth flags,
+ * etc are inherited from \a f1, not \a f2.
*
* \return A BMFace pointer
*/
@@ -2413,7 +2416,8 @@ void bmesh_kernel_vert_separate(
*
* Takes a list of edges, which have been split from their original.
*
- * Any edges which failed to split off in #bmesh_kernel_vert_separate will be merged back into the original edge.
+ * Any edges which failed to split off in #bmesh_kernel_vert_separate
+ * will be merged back into the original edge.
*
* \param edges_separate:
* A list-of-lists, each list is from a single original edge (the first edge is the original),
diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c
index f97ae0ace1e..2ca9c7e6340 100644
--- a/source/blender/bmesh/intern/bmesh_edgeloop.c
+++ b/source/blender/bmesh/intern/bmesh_edgeloop.c
@@ -264,7 +264,9 @@ static bool bm_loop_path_build_step(BLI_mempool *vs_pool,
BLI_mempool_free(vs_pool, vs);
}
- /* bm->elem_index_dirty |= BM_VERT; */ /* Commented because used in a loop, and this flag has already been set. */
+
+ /* Commented because used in a loop, and this flag has already been set. */
+ /* bm->elem_index_dirty |= BM_VERT; */
/* lb is now full of free'd items, overwrite */
*lb = lb_tmp;
diff --git a/source/blender/bmesh/intern/bmesh_iterators_inline.h b/source/blender/bmesh/intern/bmesh_iterators_inline.h
index ed3a9a5be09..4b9fbf52630 100644
--- a/source/blender/bmesh/intern/bmesh_iterators_inline.h
+++ b/source/blender/bmesh/intern/bmesh_iterators_inline.h
@@ -174,7 +174,8 @@ ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) BLI_INLINE
}
/**
- * \brief Parallel (threaded) iterator, only available for most basic itertypes (verts/edges/faces of mesh).
+ * \brief Parallel (threaded) iterator,
+ * only available for most basic itertypes (verts/edges/faces of mesh).
*
* Uses BLI_task_parallel_mempool to iterate over all items of underlying matching mempool.
*
diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c
index e6696236fac..8cbbf765f66 100644
--- a/source/blender/bmesh/intern/bmesh_log.c
+++ b/source/blender/bmesh/intern/bmesh_log.c
@@ -730,8 +730,8 @@ void BM_log_entry_drop(BMLogEntry *entry)
* Also, design wise, a first entry should not have any deleted vertices since it
* should not have anything to delete them -from-
*/
- //bm_log_id_ghash_release(log, entry->deleted_faces);
- //bm_log_id_ghash_release(log, entry->deleted_verts);
+ // bm_log_id_ghash_release(log, entry->deleted_faces);
+ // bm_log_id_ghash_release(log, entry->deleted_verts);
}
else if (!entry->next) {
/* Release IDs of elements that are added by this entry. Since
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index f8ec69b6fe9..579fbbdc05e 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -1231,7 +1231,8 @@ void BM_mesh_elem_hflag_enable_test(BMesh *bm,
/* note, better not attempt a fast path for selection as done with de-select
* because hidden geometry and different selection modes can give different results,
- * we could of course check for no hidden faces and then use quicker method but its not worth it. */
+ * we could of course check for no hidden faces and then use
+ * quicker method but its not worth it. */
for (i = 0; i < 3; i++) {
if (htype & flag_types[i]) {
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 7a42ee35440..cb10ec9d701 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -321,7 +321,8 @@ void BM_mesh_free(BMesh *bm)
* Helpers for #BM_mesh_normals_update and #BM_verts_calc_normal_vcos
*/
-/* We use that existing internal API flag, assuming no other tool using it would run concurrently to clnors editing. */
+/* We use that existing internal API flag,
+ * assuming no other tool using it would run concurrently to clnors editing. */
#define BM_LNORSPACE_UPDATE _FLAG_MF
typedef struct BMEdgesCalcVectorsData {
@@ -433,7 +434,8 @@ static void mesh_verts_calc_normals_accum_cb(void *userdata, MempoolIterData *mp
virtual_lock += f_no[0] * fac;
v_no[1] += f_no[1] * fac;
v_no[2] += f_no[2] * fac;
- /* Second atomic operation to 'release' our lock on that vector and set its first scalar value. */
+ /* Second atomic operation to 'release'
+ * our lock on that vector and set its first scalar value. */
/* Note that we do not need to loop here, since we 'locked' v_no[0],
* nobody should have changed it in the mean time. */
virtual_lock = atomic_cas_float(&v_no[0], FLT_MAX, virtual_lock);
@@ -529,7 +531,8 @@ void BM_mesh_normals_update(BMesh *bm)
/**
* \brief BMesh Compute Normals from/to external data.
*
- * Computes the vertex normals of a mesh into vnos, using given vertex coordinates (vcos) and polygon normals (fnos).
+ * Computes the vertex normals of a mesh into vnos,
+ * using given vertex coordinates (vcos) and polygon normals (fnos).
*/
void BM_verts_calc_normal_vcos(BMesh *bm,
const float (*fnos)[3],
@@ -573,9 +576,8 @@ static void bm_mesh_edges_sharp_tag(BMesh *bm,
BM_mesh_elem_index_ensure(bm, htype);
}
- /* This first loop checks which edges are actually smooth, and pre-populate lnos with vnos (as if they were
- * all smooth).
- */
+ /* This first loop checks which edges are actually smooth,
+ * and pre-populate lnos with vnos (as if they were all smooth). */
BM_ITER_MESH_INDEX (e, &eiter, bm, BM_EDGES_OF_MESH, i) {
BMLoop *l_a, *l_b;
@@ -613,7 +615,8 @@ static void bm_mesh_edges_sharp_tag(BMesh *bm,
}
}
else if (do_sharp_edges_tag) {
- /* Note that we do not care about the other sharp-edge cases (sharp poly, non-manifold edge, etc.),
+ /* Note that we do not care about the other sharp-edge cases
+ * (sharp poly, non-manifold edge, etc.),
* only tag edge as sharp when it is due to angle threashold. */
BM_elem_flag_disable(e, BM_ELEM_SMOOTH);
}
@@ -626,7 +629,8 @@ static void bm_mesh_edges_sharp_tag(BMesh *bm,
/**
* Check whether given loop is part of an unknown-so-far cyclic smooth fan, or not.
- * Needed because cyclic smooth fans have no obvious 'entry point', and yet we need to walk them once, and only once.
+ * Needed because cyclic smooth fans have no obvious 'entry point',
+ * and yet we need to walk them once, and only once.
*/
bool BM_loop_check_cyclic_smooth_fan(BMLoop *l_curr)
{
@@ -647,8 +651,9 @@ bool BM_loop_check_cyclic_smooth_fan(BMLoop *l_curr)
/* Smooth loop/edge... */
else if (BM_elem_flag_test(lfan_pivot_next, BM_ELEM_TAG)) {
if (lfan_pivot_next == l_curr) {
- /* We walked around a whole cyclic smooth fan without finding any already-processed loop, means we can
- * use initial l_curr/l_prev edge as start for this smooth fan. */
+ /* We walked around a whole cyclic smooth fan
+ * without finding any already-processed loop,
+ * means we can use initial l_curr/l_prev edge as start for this smooth fan. */
return true;
}
/* ... already checked in some previous looping, we can abort. */
@@ -661,8 +666,11 @@ bool BM_loop_check_cyclic_smooth_fan(BMLoop *l_curr)
}
}
-/* BMesh version of BKE_mesh_normals_loop_split() in mesh_evaluate.c
- * Will use first clnors_data array, and fallback to cd_loop_clnors_offset (use NULL and -1 to not use clnors). */
+/**
+ * BMesh version of BKE_mesh_normals_loop_split() in mesh_evaluate.c
+ * Will use first clnors_data array, and fallback to cd_loop_clnors_offset
+ * (use NULL and -1 to not use clnors).
+ */
static void bm_mesh_loops_calc_normals(BMesh *bm,
const float (*vcos)[3],
const float (*fnos)[3],
@@ -718,7 +726,8 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
}
bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP);
- /* We now know edges that can be smoothed (they are tagged), and edges that will be hard (they aren't).
+ /* We now know edges that can be smoothed (they are tagged),
+ * and edges that will be hard (they aren't).
* Now, time to generate the normals.
*/
BM_ITER_MESH (f_curr, &fiter, bm, BM_FACES_OF_MESH) {
@@ -731,12 +740,15 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
continue;
}
/* A smooth edge, we have to check for cyclic smooth fan case.
- * If we find a new, never-processed cyclic smooth fan, we can do it now using that loop/edge as
- * 'entry point', otherwise we can skip it. */
- /* Note: In theory, we could make bm_mesh_loop_check_cyclic_smooth_fan() store mlfan_pivot's in a stack,
- * to avoid having to fan again around the vert during actual computation of clnor & clnorspace.
- * However, this would complicate the code, add more memory usage, and BM_vert_step_fan_loop()
- * is quite cheap in term of CPU cycles, so really think it's not worth it. */
+ * If we find a new, never-processed cyclic smooth fan, we can do it now using that loop/edge
+ * as 'entry point', otherwise we can skip it. */
+
+ /* Note: In theory, we could make bm_mesh_loop_check_cyclic_smooth_fan() store
+ * mlfan_pivot's in a stack, to avoid having to fan again around
+ * the vert during actual computation of clnor & clnorspace. However, this would complicate
+ * the code, add more memory usage, and
+ * BM_vert_step_fan_loop() is quite cheap in term of CPU cycles,
+ * so really think it's not worth it. */
if (BM_elem_flag_test(l_curr->e, BM_ELEM_TAG) &&
(BM_elem_flag_test(l_curr, BM_ELEM_TAG) || !BM_loop_check_cyclic_smooth_fan(l_curr))) {
}
@@ -769,7 +781,8 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
}
BKE_lnor_space_define(lnor_space, r_lnos[l_curr_index], vec_curr, vec_prev, NULL);
- /* We know there is only one loop in this space, no need to create a linklist in this case... */
+ /* We know there is only one loop in this space,
+ * no need to create a linklist in this case... */
BKE_lnor_space_add_loop(r_lnors_spacearr, lnor_space, l_curr_index, l_curr, true);
if (has_clnors) {
@@ -780,20 +793,22 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
}
}
/* We *do not need* to check/tag loops as already computed!
- * Due to the fact a loop only links to one of its two edges, a same fan *will never be walked more than
- * once!*
- * Since we consider edges having neighbor faces with inverted (flipped) normals as sharp, we are sure that
- * no fan will be skipped, even only considering the case (sharp curr_edge, smooth prev_edge), and not the
- * alternative (smooth curr_edge, sharp prev_edge).
+ * Due to the fact a loop only links to one of its two edges,
+ * a same fan *will never be walked more than once!*
+ * Since we consider edges having neighbor faces with inverted (flipped) normals as sharp,
+ * we are sure that no fan will be skipped, even only considering the case
+ * (sharp curr_edge, smooth prev_edge), and not the alternative
+ * (smooth curr_edge, sharp prev_edge).
* All this due/thanks to link between normals and loop ordering.
*/
else {
/* We have to fan around current vertex, until we find the other non-smooth edge,
* and accumulate face normals into the vertex!
- * Note in case this vertex has only one sharp edge, this is a waste because the normal is the same as
- * the vertex normal, but I do not see any easy way to detect that (would need to count number
- * of sharp edges per vertex, I doubt the additional memory usage would be worth it, especially as
- * it should not be a common case in real-life meshes anyway).
+ * Note in case this vertex has only one sharp edge,
+ * this is a waste because the normal is the same as the vertex normal,
+ * but I do not see any easy way to detect that (would need to count number of sharp edges
+ * per vertex, I doubt the additional memory usage would be worth it, especially as it
+ * should not be a common case in real-life meshes anyway).
*/
BMVert *v_pivot = l_curr->v;
BMEdge *e_next;
@@ -820,7 +835,8 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
lfan_pivot_index = BM_elem_index_get(lfan_pivot);
e_next = lfan_pivot->e; /* Current edge here, actually! */
- /* Only need to compute previous edge's vector once, then we can just reuse old current one! */
+ /* Only need to compute previous edge's vector once,
+ * then we can just reuse old current one! */
{
const BMVert *v_2 = BM_edge_other_vert(e_next, v_pivot);
const float *co_2 = vcos ? vcos[BM_elem_index_get(v_2)] : v_2->co;
@@ -846,9 +862,10 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
}
/* Compute edge vector.
- * NOTE: We could pre-compute those into an array, in the first iteration, instead of computing them
- * twice (or more) here. However, time gained is not worth memory and time lost,
- * given the fact that this code should not be called that much in real-life meshes...
+ * NOTE: We could pre-compute those into an array, in the first iteration,
+ * instead of computing them twice (or more) here.
+ * However, time gained is not worth memory and time lost,
+ * given the fact that this code should not be called that much in real-life meshes.
*/
{
const BMVert *v_2 = BM_edge_other_vert(e_next, v_pivot);
@@ -937,11 +954,11 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
/* printf("Invalid clnors in this fan!\n"); */
while ((clnor = BLI_SMALLSTACK_POP(clnors))) {
- //print_v2("org clnor", clnor);
+ // print_v2("org clnor", clnor);
clnor[0] = (short)clnors_avg[0];
clnor[1] = (short)clnors_avg[1];
}
- //print_v2("new clnors", clnors_avg);
+ // print_v2("new clnors", clnors_avg);
}
else {
/* We still have to consume the stack! */
@@ -970,7 +987,8 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
}
}
- /* Tag related vertex as sharp, to avoid fanning around it again (in case it was a smooth one). */
+ /* Tag related vertex as sharp, to avoid fanning around it again
+ * (in case it was a smooth one). */
if (r_lnors_spacearr) {
BM_elem_flag_enable(l_curr->v, BM_ELEM_TAG);
}
@@ -1023,8 +1041,8 @@ static void bm_mesh_loops_calc_normals_no_autosmooth(BMesh *bm,
/**
* \brief BMesh Compute Loop Normals
*
- * Updates the loop normals of a mesh. Assumes vertex and face normals are valid (else call BM_mesh_normals_update()
- * first)!
+ * Updates the loop normals of a mesh.
+ * Assumes vertex and face normals are valid (else call BM_mesh_normals_update() first)!
*/
void BM_mesh_loop_normals_update(BMesh *bm,
const bool use_split_normals,
@@ -1041,7 +1059,8 @@ void BM_mesh_loop_normals_update(BMesh *bm,
* When using custom loop normals, disable the angle feature! */
bm_mesh_edges_sharp_tag(bm, NULL, NULL, has_clnors ? (float)M_PI : split_angle, r_lnos);
- /* Finish computing lnos by accumulating face normals in each fan of faces defined by sharp edges. */
+ /* Finish computing lnos by accumulating face normals
+ * in each fan of faces defined by sharp edges. */
bm_mesh_loops_calc_normals(
bm, NULL, NULL, r_lnos, r_lnors_spacearr, clnors_data, cd_loop_clnors_offset);
}
@@ -1056,7 +1075,8 @@ void BM_mesh_loop_normals_update(BMesh *bm,
* \brief BMesh Compute Loop Normals from/to external data.
*
* Compute split normals, i.e. vertex normals associated with each poly (hence 'loop normals').
- * Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry (splitting edges).
+ * Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry
+ * (splitting edges).
*/
void BM_loops_calc_normal_vcos(BMesh *bm,
const float (*vcos)[3],
@@ -1077,7 +1097,8 @@ void BM_loops_calc_normal_vcos(BMesh *bm,
* When using custom loop normals, disable the angle feature! */
bm_mesh_edges_sharp_tag(bm, vnos, fnos, r_lnos, has_clnors ? (float)M_PI : split_angle, false);
- /* Finish computing lnos by accumulating face normals in each fan of faces defined by sharp edges. */
+ /* Finish computing lnos by accumulating face normals
+ * in each fan of faces defined by sharp edges. */
bm_mesh_loops_calc_normals(
bm, vcos, fnos, r_lnos, r_lnors_spacearr, clnors_data, cd_loop_clnors_offset, do_rebuild);
}
@@ -1089,7 +1110,8 @@ void BM_loops_calc_normal_vcos(BMesh *bm,
/** Define sharp edges as needed to mimic 'autosmooth' from angle threshold.
*
- * Used when defining an empty custom loop normals data layer, to keep same shading as with autosmooth!
+ * Used when defining an empty custom loop normals data layer,
+ * to keep same shading as with autosmooth!
*/
void BM_edges_sharp_from_angle_set(BMesh *bm, const float split_angle)
{
@@ -1144,7 +1166,8 @@ void BM_lnorspace_invalidate(BMesh *bm, const bool do_invalidate_all)
BMVert *v;
BMLoop *l;
BMIter viter, liter;
- /* Note: we could use temp tag of BMItem for that, but probably better not use it in such a low-level func?
+ /* Note: we could use temp tag of BMItem for that,
+ * but probably better not use it in such a low-level func?
* --mont29 */
BLI_bitmap *done_verts = BLI_BITMAP_NEW(bm->totvert, __func__);
@@ -1414,13 +1437,15 @@ static int bm_loop_normal_mark_indiv(BMesh *bm, BLI_bitmap *loops)
if (use_sel_face_history) {
/* Using face history allows to select a single loop from a single face...
- * Note that this is On² piece of code, but it is not designed to be used with huge selection sets,
+ * Note that this is On² piece of code,
+ * but it is not designed to be used with huge selection sets,
* rather with only a few items selected at most.*/
printf("using face history selection\n");
/* Goes from last selected to the first selected element. */
for (ese = bm->selected.last; ese; ese = ese->prev) {
if (ese->htype == BM_FACE) {
- /* If current face is selected, then any verts to be edited must have been selected before it. */
+ /* If current face is selected,
+ * then any verts to be edited must have been selected before it. */
for (ese_prev = ese->prev; ese_prev; ese_prev = ese_prev->prev) {
if (ese_prev->htype == BM_VERT) {
bm_loop_normal_mark_indiv_do_loop(
@@ -2078,11 +2103,13 @@ int BM_mesh_elem_count(BMesh *bm, const char htype)
*
* A NULL array means no changes.
*
- * Note: - Does not mess with indices, just sets elem_index_dirty flag.
- * - For verts/edges/faces only (as loops must remain "ordered" and "aligned"
- * on a per-face basis...).
+ * \note
+ * - Does not mess with indices, just sets elem_index_dirty flag.
+ * - For verts/edges/faces only (as loops must remain "ordered" and "aligned"
+ * on a per-face basis...).
*
- * WARNING: Be careful if you keep pointers to affected BM elements, or arrays, when using this func!
+ * \warning Be careful if you keep pointers to affected BM elements,
+ * or arrays, when using this func!
*/
void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const uint *face_idx)
{
@@ -2134,7 +2161,10 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const
for (i = totvert; i--; new_idx--, ve--, vep--) {
BMVert *new_vep = verts_pool[*new_idx];
*new_vep = *ve;
- /* printf("mapping vert from %d to %d (%p/%p to %p)\n", i, *new_idx, *vep, verts_pool[i], new_vep);*/
+#if 0
+ printf(
+ "mapping vert from %d to %d (%p/%p to %p)\n", i, *new_idx, *vep, verts_pool[i], new_vep);
+#endif
BLI_ghash_insert(vptr_map, *vep, new_vep);
if (cd_vert_pyptr != -1) {
void **pyptr = BM_ELEM_CD_GET_VOID_P(((BMElem *)new_vep), cd_vert_pyptr);
@@ -2183,7 +2213,10 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const
BMEdge *new_edp = edges_pool[*new_idx];
*new_edp = *ed;
BLI_ghash_insert(eptr_map, *edp, new_edp);
- /* printf("mapping edge from %d to %d (%p/%p to %p)\n", i, *new_idx, *edp, edges_pool[i], new_edp);*/
+#if 0
+ printf(
+ "mapping edge from %d to %d (%p/%p to %p)\n", i, *new_idx, *edp, edges_pool[i], new_edp);
+#endif
if (cd_edge_pyptr != -1) {
void **pyptr = BM_ELEM_CD_GET_VOID_P(((BMElem *)new_edp), cd_edge_pyptr);
*pyptr = pyptrs[*new_idx];
@@ -2258,27 +2291,28 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const
}
}
- /* Edges' pointers, only vert pointers (as we don't mess with loops!), and - ack! - edge pointers,
+ /* Edges' pointers, only vert pointers (as we don't mess with loops!),
+ * and - ack! - edge pointers,
* as we have to handle disklinks... */
if (vptr_map || eptr_map) {
BM_ITER_MESH (ed, &iter, bm, BM_EDGES_OF_MESH) {
if (vptr_map) {
- /* printf("Edge v1: %p -> %p\n", ed->v1, BLI_ghash_lookup(vptr_map, ed->v1));*/
- /* printf("Edge v2: %p -> %p\n", ed->v2, BLI_ghash_lookup(vptr_map, ed->v2));*/
+ /* printf("Edge v1: %p -> %p\n", ed->v1, BLI_ghash_lookup(vptr_map, ed->v1));*/
+ /* printf("Edge v2: %p -> %p\n", ed->v2, BLI_ghash_lookup(vptr_map, ed->v2));*/
ed->v1 = BLI_ghash_lookup(vptr_map, ed->v1);
ed->v2 = BLI_ghash_lookup(vptr_map, ed->v2);
BLI_assert(ed->v1);
BLI_assert(ed->v2);
}
if (eptr_map) {
- /* printf("Edge v1_disk_link prev: %p -> %p\n", ed->v1_disk_link.prev,*/
- /* BLI_ghash_lookup(eptr_map, ed->v1_disk_link.prev));*/
- /* printf("Edge v1_disk_link next: %p -> %p\n", ed->v1_disk_link.next,*/
- /* BLI_ghash_lookup(eptr_map, ed->v1_disk_link.next));*/
- /* printf("Edge v2_disk_link prev: %p -> %p\n", ed->v2_disk_link.prev,*/
- /* BLI_ghash_lookup(eptr_map, ed->v2_disk_link.prev));*/
- /* printf("Edge v2_disk_link next: %p -> %p\n", ed->v2_disk_link.next,*/
- /* BLI_ghash_lookup(eptr_map, ed->v2_disk_link.next));*/
+ /* printf("Edge v1_disk_link prev: %p -> %p\n", ed->v1_disk_link.prev,*/
+ /* BLI_ghash_lookup(eptr_map, ed->v1_disk_link.prev));*/
+ /* printf("Edge v1_disk_link next: %p -> %p\n", ed->v1_disk_link.next,*/
+ /* BLI_ghash_lookup(eptr_map, ed->v1_disk_link.next));*/
+ /* printf("Edge v2_disk_link prev: %p -> %p\n", ed->v2_disk_link.prev,*/
+ /* BLI_ghash_lookup(eptr_map, ed->v2_disk_link.prev));*/
+ /* printf("Edge v2_disk_link next: %p -> %p\n", ed->v2_disk_link.next,*/
+ /* BLI_ghash_lookup(eptr_map, ed->v2_disk_link.next));*/
ed->v1_disk_link.prev = BLI_ghash_lookup(eptr_map, ed->v1_disk_link.prev);
ed->v1_disk_link.next = BLI_ghash_lookup(eptr_map, ed->v1_disk_link.next);
ed->v2_disk_link.prev = BLI_ghash_lookup(eptr_map, ed->v2_disk_link.prev);
@@ -2571,7 +2605,8 @@ void BM_mesh_rebuild(BMesh *bm,
#undef REMAP_EDGE
/* Cleanup, re-use local tables if the current mesh had tables allocated.
- * could use irrespective but it may use more memory then the caller wants (and not be needed). */
+ * could use irrespective but it may use more memory then the caller wants
+ * (and not be needed). */
if (remap & BM_VERT) {
if (bm->vtable) {
SWAP(BMVert **, vtable_dst, bm->vtable);
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index f2db451888a..0ea33049458 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -33,33 +33,41 @@
*
* - Editmode operations when a shape key-block is active edits only that key-block.
* - The first Basis key-block always matches the Mesh verts.
- * - Changing vertex locations of _any_ Basis will apply offsets to those shape keys using this as their Basis.
+ * - Changing vertex locations of _any_ Basis
+ * will apply offsets to those shape keys using this as their Basis.
+ *
* \subsection enter_editmode Entering EditMode - #BM_mesh_bm_from_me
*
- * - the active key-block is used for BMesh vertex locations on entering edit-mode.
- * So obviously the meshes vertex locations remain unchanged and the shape key its self is not being edited directly.
- * Simply the #BMVert.co is a initialized from active shape key (when its set).
- * - all key-blocks are added as CustomData layers (read code for details).
+ * - The active key-block is used for BMesh vertex locations on entering edit-mode.
+ * So obviously the meshes vertex locations remain unchanged and the shape key
+ * its self is not being edited directly.
+ * Simply the #BMVert.co is a initialized from active shape key (when its set).
+ * - All key-blocks are added as CustomData layers (read code for details).
+ *
* \subsection exit_editmode Exiting EditMode - #BM_mesh_bm_to_me
*
- * This is where the most confusing code is! Won't attempt to document the details here, for that read the code.
+ * This is where the most confusing code is! Won't attempt to document the details here,
+ * for that read the code.
* But basics are as follows.
*
- * - Vertex locations (possibly modified from initial active key-block) are copied directly into #MVert.co
- * (special confusing note that these may be restored later, when editing the 'Basis', read on).
- * - if the 'Key' is relative, and the active key-block is the basis for ANY other key-blocks - get an array of offsets
- * between the new vertex locations and the original shape key (before entering edit-mode),
- * these offsets get applied later on to inactive key-blocks using the active one (which we are editing) as their Basis.
+ * - Vertex locations (possibly modified from initial active key-block)
+ * are copied directly into #MVert.co
+ * (special confusing note that these may be restored later, when editing the 'Basis', read on).
+ * - if the 'Key' is relative, and the active key-block is the basis for ANY other key-blocks -
+ * get an array of offsets between the new vertex locations and the original shape key
+ * (before entering edit-mode), these offsets get applied later on to inactive key-blocks
+ * using the active one (which we are editing) as their Basis.
*
* Copying the locations back to the shape keys is quite confusing...
* One main area of confusion is that when editing a 'Basis' key-block 'me->key->refkey'
- * The coords are written into the mesh, from the users perspective the Basis coords are written into the mesh
- * when exiting edit-mode.
+ * The coords are written into the mesh, from the users perspective the Basis coords are written
+ * into the mesh when exiting edit-mode.
*
- * When _not_ editing the 'Basis', the original vertex locations (stored in the mesh and unchanged during edit-mode),
- * are copied back into the mesh.
+ * When _not_ editing the 'Basis', the original vertex locations
+ * (stored in the mesh and unchanged during edit-mode), are copied back into the mesh.
*
- * This has the effect from the users POV of leaving the mesh un-touched, and only editing the active shape key-block.
+ * This has the effect from the users POV of leaving the mesh un-touched,
+ * and only editing the active shape key-block.
*/
#include "DNA_mesh_types.h"
@@ -490,7 +498,8 @@ static BMVert **bm_to_mesh_vertex_map(BMesh *bm, int ototvert)
const int keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset);
if ((keyi != ORIGINDEX_NONE) && (keyi < ototvert) &&
/* not fool-proof, but chances are if we have many verts with the same index,
- * we will want to use the first one, since the second is more likely to be a duplicate. */
+ * we will want to use the first one,
+ * since the second is more likely to be a duplicate. */
(vertMap[keyi] == NULL)) {
vertMap[keyi] = eve;
}
@@ -944,8 +953,9 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
if (apply_offset) {
add_v3_v3(fp, *ofs_pt++);
/* Apply back new coordinates of offsetted shapekeys into BMesh.
- * Otherwise, in case we call again BM_mesh_bm_to_me on same BMesh, we'll apply diff from previous
- * call to BM_mesh_bm_to_me, to shapekey values from *original creation of the BMesh*. See T50524. */
+ * Otherwise, in case we call again BM_mesh_bm_to_me on same BMesh,
+ * we'll apply diff from previous call to BM_mesh_bm_to_me,
+ * to shapekey values from *original creation of the BMesh*. See T50524. */
copy_v3_v3(BM_ELEM_CD_GET_VOID_P(eve, cd_shape_offset), fp);
}
@@ -977,8 +987,10 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
}
/**
- * A version of #BM_mesh_bm_to_me intended for getting the mesh to pass to the modifier stack for evaluation,
- * instad of mode switching (where we make sure all data is kept and do expensive lookups to maintain shape keys).
+ * A version of #BM_mesh_bm_to_me intended for getting the mesh
+ * to pass to the modifier stack for evaluation,
+ * instad of mode switching (where we make sure all data is kept
+ * and do expensive lookups to maintain shape keys).
*
* Key differences:
*
diff --git a/source/blender/bmesh/intern/bmesh_mesh_validate.c b/source/blender/bmesh/intern/bmesh_mesh_validate.c
index 3b6f63df089..83ab29940f3 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_validate.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_validate.c
@@ -51,7 +51,8 @@
# endif
/**
- * Check of this BMesh is valid, this function can be slow since its intended to help with debugging.
+ * Check of this BMesh is valid,
+ * this function can be slow since its intended to help with debugging.
*
* \return true when the mesh is valid.
*/
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index 8728186ef33..888393de47a 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -322,13 +322,14 @@ BMFace *BM_face_split(BMesh *bm,
*
* Like BM_face_split, but with an edge split by \a n intermediate points with given coordinates.
*
- * \param bm: The bmesh
- * \param f: the original face
- * \param l_a, l_b: Vertices which define the split edge, must be different
- * \param cos: Array of coordinates for intermediate points
- * \param n: Length of \a cos (must be > 0)
- * \param r_l: pointer which will receive the BMLoop for the first split edge (from \a l_a) in the new face
- * \param example: Edge used for attributes of splitting edge, if non-NULL
+ * \param bm: The bmesh.
+ * \param f: the original face.
+ * \param l_a, l_b: Vertices which define the split edge, must be different.
+ * \param cos: Array of coordinates for intermediate points.
+ * \param n: Length of \a cos (must be > 0).
+ * \param r_l: pointer which will receive the BMLoop.
+ * for the first split edge (from \a l_a) in the new face.
+ * \param example: Edge used for attributes of splitting edge, if non-NULL.
*
* \return Pointer to the newly created face representing one side of the split
* if the split is successful (and the original original face will be the
@@ -370,7 +371,8 @@ BMFace *BM_face_split_n(BMesh *bm,
#else
f_new = bmesh_kernel_split_face_make_edge(bm, f, l_a, l_b, &l_new, example, false);
#endif
- /* bmesh_kernel_split_face_make_edge returns in 'l_new' a Loop for f_new going from 'v_a' to 'v_b'.
+ /* bmesh_kernel_split_face_make_edge returns in 'l_new'
+ * a Loop for f_new going from 'v_a' to 'v_b'.
* The radial_next is for 'f' and goes from 'v_b' to 'v_a' */
if (f_new) {
@@ -378,7 +380,8 @@ BMFace *BM_face_split_n(BMesh *bm,
for (i = 0; i < n; i++) {
v_new = bmesh_kernel_split_edge_make_vert(bm, v_b, e, &e_new);
BLI_assert(v_new != NULL);
- /* bmesh_kernel_split_edge_make_vert returns in 'e_new' the edge going from 'v_new' to 'v_b' */
+ /* bmesh_kernel_split_edge_make_vert returns in 'e_new'
+ * the edge going from 'v_new' to 'v_b'. */
copy_v3_v3(v_new->co, cos[i]);
/* interpolate the loop data for the loops with (v == v_new), using orig face */
diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h
index 5085eb801ce..3b543835586 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api.h
@@ -628,7 +628,7 @@ void BMO_slot_buffer_from_all(BMesh *bm,
* don't directly access. */
typedef struct BMOIter {
BMOpSlot *slot;
- int cur; //for arrays
+ int cur; // for arrays
GHashIterator giter;
void **val;
char restrictmask; /* bitwise '&' with BMHeader.htype */
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 0e9b615afe7..84c177a4d04 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -272,7 +272,7 @@ BMOpSlot *BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identif
int slot_code = bmo_name_to_slotcode_check(slot_args, identifier);
if (UNLIKELY(slot_code < 0)) {
- //return &BMOpEmptySlot;
+ // return &BMOpEmptySlot;
BLI_assert(0);
return NULL; /* better crash */
}
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index 1a0e167b93d..172f7050aa0 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -121,7 +121,8 @@ static void bm_face_calc_poly_center_median_vertex_cos(const BMFace *f,
/**
* For tools that insist on using triangles, ideally we would cache this data.
*
- * \param use_fixed_quad: When true, always split quad along (0 -> 2) regardless of concave corners,
+ * \param use_fixed_quad: When true,
+ * always split quad along (0 -> 2) regardless of concave corners,
* (as done in #BM_mesh_calc_tessellation).
* \param r_loops: Store face loop pointers, (f->len)
* \param r_index: Store triangle triples, indices into \a r_loops, `((f->len - 2) * 3)`
@@ -963,8 +964,8 @@ bool BM_face_point_inside_test(const BMFace *f, const float co[3])
* with a length equal to (f->len - 3). It will be filled with the new
* triangles (not including the original triangle).
*
- * \param r_faces_double: When newly created faces are duplicates of existing faces, they're added to this list.
- * Caller must handle de-duplication.
+ * \param r_faces_double: When newly created faces are duplicates of existing faces,
+ * they're added to this list. Caller must handle de-duplication.
* This is done because its possible _all_ faces exist already,
* and in that case we would have to remove all faces including the one passed,
* which causes complications adding/removing faces while looking over them.
@@ -1068,10 +1069,10 @@ void BM_face_triangulate(BMesh *bm,
/* named confusingly, l_v1 is in fact the second vertex */
if (split_24) {
l_v1 = l_v4;
- //l_v2 = l_v2;
+ // l_v2 = l_v2;
}
else {
- //l_v1 = l_v1;
+ // l_v1 = l_v1;
l_v2 = l_v3;
}
break;
@@ -1156,8 +1157,8 @@ void BM_face_triangulate(BMesh *bm,
l_iter = l_first = l_new;
do {
BMEdge *e = l_iter->e;
- /* confusing! if its not a boundary now, we know it will be later
- * since this will be an edge of one of the new faces which we're in the middle of creating */
+ /* Confusing! if its not a boundary now, we know it will be later since this will be an
+ * edge of one of the new faces which we're in the middle of creating. */
bool is_new_edge = (l_iter == l_iter->radial_next);
if (is_new_edge) {
diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
index e2b117536f3..14b73693b03 100644
--- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
+++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
@@ -987,8 +987,10 @@ static int bm_face_split_edgenet_find_connection(const struct EdgeGroup_FindConn
* Method for finding connection is as follows:
*
* - Cast a ray along either the positive or negative directions.
- * - Take the hit-edge, and cast rays to their vertices checking those rays don't intersect a closer edge.
- * - Keep taking the hit-edge and testing its verts until a vertex is found which isn't blocked by an edge.
+ * - Take the hit-edge, and cast rays to their vertices
+ * checking those rays don't intersect a closer edge.
+ * - Keep taking the hit-edge and testing its verts
+ * until a vertex is found which isn't blocked by an edge.
*
* \note It's possible none of the verts can be accessed (with self-intersecting lines).
* In that case theres no right answer (without subdividing edges),
@@ -1146,7 +1148,8 @@ static BMVert *bm_face_split_edgenet_partial_connect(BMesh *bm, BMVert *v_delimi
}
}
- /* Detect if this is a delimiter by checking if we didn't walk any of edges connected to 'v_delimit' */
+ /* Detect if this is a delimiter
+ * by checking if we didn't walk any of edges connected to 'v_delimit'. */
bool is_delimit = false;
FOREACH_VERT_EDGE(v_delimit, e_iter, {
BMVert *v_step = BM_edge_other_vert(e_iter, v_delimit);
@@ -1500,7 +1503,8 @@ bool BM_face_split_edgenet_connect_islands(BMesh *bm,
/* Now create bvh tree
*
- * Note that a large epsilon is used because meshes with dimensions of around 100+ need it. see T52329. */
+ * Note that a large epsilon is used because meshes with dimensions of around 100+ need it.
+ * see T52329. */
BVHTree *bvhtree = BLI_bvhtree_new(edge_arr_len, 1e-4f, 8, 8);
for (uint i = 0; i < edge_arr_len; i++) {
const float e_cos[2][3] = {
diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c
index d7266121874..a2f95a013a2 100644
--- a/source/blender/bmesh/intern/bmesh_query.c
+++ b/source/blender/bmesh/intern/bmesh_query.c
@@ -311,9 +311,11 @@ float BM_loop_point_side_of_edge_test(const BMLoop *l, const float co[3])
}
/**
- * Given 2 verts, find a face they share that has the lowest angle across these verts and give back both loops.
+ * Given 2 verts,
+ * find a face they share that has the lowest angle across these verts and give back both loops.
*
- * This can be better then #BM_vert_pair_share_face_by_len because concave splits are ranked lowest.
+ * This can be better then #BM_vert_pair_share_face_by_len
+ * because concave splits are ranked lowest.
*/
BMFace *BM_vert_pair_share_face_by_angle(
BMVert *v_a, BMVert *v_b, BMLoop **r_l_a, BMLoop **r_l_b, const bool allow_adjacent)
@@ -1410,7 +1412,8 @@ BMLoop *BM_face_edge_share_loop(BMFace *f, BMEdge *e)
* BM_face_create_ngon() on an arbitrary array of verts,
* though be sure to pick an edge which has a face.
*
- * \note This is in fact quite a simple check, mainly include this function so the intent is more obvious.
+ * \note This is in fact quite a simple check,
+ * mainly include this function so the intent is more obvious.
* We know these 2 verts will _always_ make up the loops edge
*/
void BM_edge_ordered_verts_ex(const BMEdge *edge,
@@ -1507,10 +1510,13 @@ float BM_loop_calc_face_angle(const BMLoop *l)
*/
float BM_loop_calc_face_normal_safe_ex(const BMLoop *l, const float epsilon_sq, float r_normal[3])
{
- /* Note: we cannot use result of normal_tri_v3 here to detect colinear vectors (vertex on a straight line)
- * from zero value, because it does not normalize both vectors before making crossproduct.
- * Instead of adding two costly normalize computations, just check ourselves for colinear case. */
- /* Note: FEPSILON might need some finer tweaking at some point? Seems to be working OK for now though. */
+ /* Note: we cannot use result of normal_tri_v3 here to detect colinear vectors
+ * (vertex on a straight line) from zero value,
+ * because it does not normalize both vectors before making crossproduct.
+ * Instead of adding two costly normalize computations,
+ * just check ourselves for colinear case. */
+ /* Note: FEPSILON might need some finer tweaking at some point?
+ * Seems to be working OK for now though. */
float v1[3], v2[3], v_tmp[3];
sub_v3_v3v3(v1, l->prev->v->co, l->v->co);
sub_v3_v3v3(v2, l->next->v->co, l->v->co);
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index 0097e0a3056..20042e65287 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -726,9 +726,9 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
iwalk = BMW_state_add(walker);
iwalk->base = owalk.base;
- //if (!BMO_face_flag_test(walker->bm, l->f, walker->restrictflag))
+ // if (!BMO_face_flag_test(walker->bm, l->f, walker->restrictflag))
// iwalk->curloop = l->radial_next;
- iwalk->curloop = l; //else iwalk->curloop = l;
+ iwalk->curloop = l; // else iwalk->curloop = l;
iwalk->lastv = v;
return owalk.curloop;
@@ -989,8 +989,9 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker)
vert_edge_tot = BM_vert_edge_count_nonwire(v);
- /* typical loopiong over edges in the middle of a mesh */
- /* however, why use 2 here at all? I guess for internal ngon loops it can be useful. Antony R. */
+ /* Typical loopiong over edges in the middle of a mesh */
+ /* However, why use 2 here at all?
+ * I guess for internal ngon loops it can be useful. Antony R. */
if (vert_edge_tot == 4 || vert_edge_tot == 2) {
int i_opposite = vert_edge_tot / 2;
int i = 0;
diff --git a/source/blender/bmesh/operators/bmo_bridge.c b/source/blender/bmesh/operators/bmo_bridge.c
index 39ccc0c631e..7ec73412373 100644
--- a/source/blender/bmesh/operators/bmo_bridge.c
+++ b/source/blender/bmesh/operators/bmo_bridge.c
@@ -211,8 +211,11 @@ static void bridge_loop_pair(BMesh *bm,
* +--------+ +--------+
* </pre>
*
- * When loops are aligned to the direction between the loops values of 'dir_a/b' is degenerate,
- * in this case compare the original directions (before they were corrected by 'el_dir'), see: T43013
+ * When loops are aligned to the direction between
+ * the loops values of 'dir_a/b' is degenerate,
+ * in this case compare the original directions
+ * (before they were corrected by 'el_dir'),
+ * see: T43013
*/
test_a = dir_a_orig;
test_b = dir_b_orig;
diff --git a/source/blender/bmesh/operators/bmo_connect_pair.c b/source/blender/bmesh/operators/bmo_connect_pair.c
index 18568c364d6..07ead2b8a96 100644
--- a/source/blender/bmesh/operators/bmo_connect_pair.c
+++ b/source/blender/bmesh/operators/bmo_connect_pair.c
@@ -43,9 +43,11 @@
* - never step over the same element twice (tag elements as #ELE_TOUCHED).
* this avoids going into an eternal loop if there are many possible branches (see T45582).
* - when running into a branch, create a new #PathLinkState state and add to the heap.
- * - when the target is reached, finish - since none of the other paths can be shorter then the one just found.
+ * - when the target is reached,
+ * finish - since none of the other paths can be shorter then the one just found.
* - if the connection can't be found - fail.
- * - with the connection found, split all edges tagging verts (or tag verts that sit on the intersection).
+ * - with the connection found, split all edges tagging verts
+ * (or tag verts that sit on the intersection).
* - run the standard connect operator.
*/
@@ -520,7 +522,8 @@ static void bm_vert_pair_to_matrix(BMVert *v_pair[2], float r_unit_mat[3][3])
project_plane_normalized_v3_v3v3(basis_nor_a, v_pair[0]->no, basis_dir);
project_plane_normalized_v3_v3v3(basis_nor_b, v_pair[1]->no, basis_dir);
- /* don't normalize before combining so as normals approach the direction, they have less effect (T46784). */
+ /* Don't normalize before combining so as normals approach the direction,
+ * they have less effect (T46784). */
/* combine the normals */
/* for flipped faces */
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index c799b177843..c6813a864a8 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -230,8 +230,8 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
*
* Rather then do nothing, when 5+ verts are selected, check if they are in our history,
* when this is so, we can make edges from them, but _not_ a face,
- * if it is the intention to make a face the user can just hit F again since there will be edges next
- * time around.
+ * if it is the intention to make a face the user can just hit F again
+ * since there will be edges next time around.
*
* if all history verts have ELE_NEW flagged and the total number of history verts == totv,
* then we know the history contains all verts here and we can continue...
diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c
index 9cea982f6bd..6c662323ec1 100644
--- a/source/blender/bmesh/operators/bmo_dissolve.c
+++ b/source/blender/bmesh/operators/bmo_dissolve.c
@@ -161,15 +161,15 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
BLI_array_clear(faces);
faces = NULL; /* forces different allocatio */
- BMW_init(
- &regwalker,
- bm,
- BMW_ISLAND_MANIFOLD,
- BMW_MASK_NOP,
- BMW_MASK_NOP,
- FACE_MARK,
- BMW_FLAG_NOP, /* no need to check BMW_FLAG_TEST_HIDDEN, faces are already marked by the bmo */
- BMW_NIL_LAY);
+ BMW_init(&regwalker,
+ bm,
+ BMW_ISLAND_MANIFOLD,
+ BMW_MASK_NOP,
+ BMW_MASK_NOP,
+ FACE_MARK,
+ /* no need to check BMW_FLAG_TEST_HIDDEN, faces are already marked by the bmo. */
+ BMW_FLAG_NOP,
+ BMW_NIL_LAY);
for (f_iter = BMW_begin(&regwalker, f); f_iter; f_iter = BMW_step(&regwalker)) {
BLI_array_append(faces, f_iter);
diff --git a/source/blender/bmesh/operators/bmo_fill_grid.c b/source/blender/bmesh/operators/bmo_fill_grid.c
index c97a5c0f38e..c3d19862ffb 100644
--- a/source/blender/bmesh/operators/bmo_fill_grid.c
+++ b/source/blender/bmesh/operators/bmo_fill_grid.c
@@ -485,7 +485,7 @@ static void bm_grid_fill(BMesh *bm,
const uint xtot = (uint)BM_edgeloop_length_get(estore_a);
const uint ytot = (uint)BM_edgeloop_length_get(estore_rail_a);
- //BMVert *v;
+ // BMVert *v;
uint i;
#ifdef DEBUG
uint x, y;
diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c
index eede35ae7b7..12ec4617f0a 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -659,7 +659,8 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
BM_edge_calc_face_tangent(es->e_new, es->l, es->no);
if (es->e_new == es->e_old) { /* happens on boundary edges */
- /* take care here, we're creating this double edge which _must_ have its verts replaced later on */
+ /* Take care here, we're creating this double edge which _must_
+ * have its verts replaced later on. */
es->e_old = BM_edge_create(bm, es->e_new->v1, es->e_new->v2, es->e_new, BM_CREATE_NOP);
}
@@ -709,9 +710,10 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
}
#endif
- /* execute the split and position verts, it would be most obvious to loop over verts
- * here but don't do this since we will be splitting them off (iterating stuff you modify is bad juju)
- * instead loop over edges then their verts */
+ /* Execute the split and position verts, it would be most obvious to loop
+ * over verts here but don't do this since we will be splitting them off
+ * (iterating stuff you modify is bad juju)
+ * instead loop over edges then their verts. */
for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
for (int j = 0; j < 2; j++) {
v = (j == 0) ? es->e_new->v1 : es->e_new->v2;
@@ -1048,7 +1050,8 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
/* Copy for loop data, otherwise UV's and vcols are no good.
* tiny speedup here we could be more clever and copy from known adjacent data
- * also - we could attempt to interpolate the loop data, this would be much slower but more useful too */
+ * also - we could attempt to interpolate the loop data,
+ * this would be much slower but more useful too. */
if (0) {
/* Don't use this because face boundaries have no adjacent loops and won't be filled in.
* instead copy from the opposite side with the code below */
@@ -1163,8 +1166,8 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
float(*varr_co)[3];
BMOIter oiter;
- /* we need to re-calculate tagged normals, but for this purpose we can copy tagged verts from the
- * faces they inset from, */
+ /* We need to re-calculate tagged normals,
+ * but for this purpose we can copy tagged verts from the faces they inset from. */
for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
zero_v3(es->e_new->v1->no);
zero_v3(es->e_new->v2->no);
diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c
index 9734dab7ca4..848669301c3 100644
--- a/source/blender/bmesh/operators/bmo_join_triangles.c
+++ b/source/blender/bmesh/operators/bmo_join_triangles.c
@@ -42,7 +42,8 @@ static float quad_calc_error(const float v1[3],
const float v3[3],
const float v4[3])
{
- /* gives a 'weight' to a pair of triangles that join an edge to decide how good a join they would make */
+ /* Gives a 'weight' to a pair of triangles that join an edge
+ * to decide how good a join they would make. */
/* Note: this is more complicated than it needs to be and should be cleaned up.. */
float error = 0.0f;
diff --git a/source/blender/bmesh/operators/bmo_normals.c b/source/blender/bmesh/operators/bmo_normals.c
index ee55165244b..b24afc0f8e6 100644
--- a/source/blender/bmesh/operators/bmo_normals.c
+++ b/source/blender/bmesh/operators/bmo_normals.c
@@ -44,7 +44,8 @@ static bool bmo_recalc_normal_loop_filter_cb(const BMLoop *l, void *UNUSED(user_
* This uses a more comprehensive test to see if the furthest face from the center
* is pointing towards the center or not.
*
- * A simple test could just check the dot product of the faces-normal and the direction from the center,
+ * A simple test could just check the dot product
+ * of the faces-normal and the direction from the center,
* however this can fail for faces which make a sharp spike. eg:
*
* <pre>
@@ -67,7 +68,8 @@ static bool bmo_recalc_normal_loop_filter_cb(const BMLoop *l, void *UNUSED(user_
*/
/**
- * \return a face index in \a faces and set \a r_is_flip if the face is flipped away from the center.
+ * \return a face index in \a faces and set \a r_is_flip
+ * if the face is flipped away from the center.
*/
static int recalc_face_normals_find_index(BMesh *bm,
BMFace **faces,
@@ -83,16 +85,23 @@ static int recalc_face_normals_find_index(BMesh *bm,
int f_start_index;
int i;
- /* Search for the best loop. Members are compared in-order defined here. */
+ /** Search for the best loop. Members are compared in-order defined here. */
struct {
- /* Squared distance from the center to the loops vertex 'l->v'.
- * The normalized direction between the center and this vertex is also used for the dot-products below. */
+ /**
+ * Squared distance from the center to the loops vertex 'l->v'.
+ * The normalized direction between the center and this vertex
+ * is also used for the dot-products below.
+ */
float dist_sq;
- /* Signed dot product using the normalized edge vector,
- * (best of 'l->prev->v' or 'l->next->v'). */
+ /**
+ * Signed dot product using the normalized edge vector,
+ * (best of 'l->prev->v' or 'l->next->v').
+ */
float edge_dot;
- /* Unsigned dot product using the loop-normal
- * (sign is used to check if we need to flip) */
+ /**
+ * Unsigned dot product using the loop-normal
+ * (sign is used to check if we need to flip).
+ */
float loop_dot;
} best, test;
@@ -247,13 +256,14 @@ static void bmo_recalc_face_normals_array(BMesh *bm,
}
}
-/*
- * put normal to the outside, and set the first direction flags in edges
+/**
+ * Put normal to the outside, and set the first direction flags in edges
*
- * then check the object, and set directions / direction-flags: but only for edges with 1 or 2 faces
- * this is in fact the 'select connected'
+ * then check the object, and set directions / direction-flags:
+ * but only for edges with 1 or 2 faces this is in fact the 'select connected'
*
- * in case all faces were not done: start over with 'find the ultimate ...' */
+ * in case all faces were not done: start over with 'find the ultimate ...'.
+ */
void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op)
{
diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c
index 3ed74d68317..cf3d6b8bf56 100644
--- a/source/blender/bmesh/operators/bmo_primitive.c
+++ b/source/blender/bmesh/operators/bmo_primitive.c
@@ -941,8 +941,8 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
BMLoop *l;
BMIter fiter, liter;
- /* We cannot tag faces for UVs computing above, so we have to do it now, based on all its vertices
- * being tagged. */
+ /* We cannot tag faces for UVs computing above,
+ * so we have to do it now, based on all its vertices being tagged. */
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
bool valid = true;
@@ -1537,7 +1537,8 @@ void BM_mesh_calc_uvs_cone(BMesh *bm,
const float uv_width = 1.0f / (float)segments;
const float uv_height = cap_ends ? 0.5f : 1.0f;
- /* Note that all this allows us to handle all cases (real cone, truncated cone, with or without ends capped)
+ /* Note that all this allows us to handle all cases
+ * (real cone, truncated cone, with or without ends capped)
* with a single common code. */
const float uv_center_y = cap_ends ? 0.25f : 0.5f;
const float uv_center_x_top = cap_ends ? 0.25f : 0.5f;
@@ -1601,7 +1602,8 @@ void BM_mesh_calc_uvs_cone(BMesh *bm,
}
}
else {
- /* top or bottom face - so unwrap it by transforming back to a circle and using the X/Y coords */
+ /* Top or bottom face - so unwrap it by transforming
+ * back to a circle and using the X/Y coords. */
BM_face_normal_update(f);
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index 144d944e939..616886deba1 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -182,7 +182,8 @@ finally : {
}
/**
- * \note with 'targetmap', multiple 'keys' are currently supported, though no callers should be using.
+ * \note with 'targetmap', multiple 'keys' are currently supported,
+ * though no callers should be using.
* (because slot maps currently use GHash without the GHASH_FLAG_ALLOW_DUPES flag set)
*/
void bmo_weld_verts_exec(BMesh *bm, BMOperator *op)
@@ -428,7 +429,7 @@ void bmo_pointmerge_exec(BMesh *bm, BMOperator *op)
BMO_slot_vec_get(op->slots_in, "merge_co", vec);
- //BMO_op_callf(bm, op->flag, "collapse_uvs edges=%s", op, "edges");
+ // BMO_op_callf(bm, op->flag, "collapse_uvs edges=%s", op, "edges");
BMO_op_init(bm, &weldop, op->flag, "weld_verts");
slot_targetmap = BMO_slot_get(weldop.slots_in, "targetmap");
diff --git a/source/blender/bmesh/operators/bmo_rotate_edges.c b/source/blender/bmesh/operators/bmo_rotate_edges.c
index b999e942d10..56eaac03970 100644
--- a/source/blender/bmesh/operators/bmo_rotate_edges.c
+++ b/source/blender/bmesh/operators/bmo_rotate_edges.c
@@ -151,14 +151,17 @@ static void bm_rotate_edges_shared(
if (ok) {
float cost = bm_edge_calc_rotate_cost(e);
if (pass_type == PASS_TYPE_BOUNDARY) {
- /* Trick to ensure once started, non boundaries are handled before other boundary edges.
+ /* Trick to ensure once started,
+ * non boundaries are handled before other boundary edges.
* This means the first longest boundary defines the starting point which is rotated
- * until all its connected edges are exhausted and the next boundary is popped off the heap.
+ * until all its connected edges are exhausted
+ * and the next boundary is popped off the heap.
*
* Without this we may rotate from different starting points and meet in the middle
* with obviously uneven topology.
*
- * Move from negative to positive value, inverting so large values are still handled first.
+ * Move from negative to positive value,
+ * inverting so large values are still handled first.
*/
cost = cost != 0.0f ? -1.0f / cost : FLT_MAX;
}
@@ -190,10 +193,12 @@ static void bm_rotate_edges_shared(
/* Note: we could validate all edges which have not been rotated
* (not just previously degenerate edges).
- * However there is no real need - they can be left until they're popped off the queue. */
+ * However there is no real need -
+ * they can be left until they're popped off the queue. */
/* We don't know the exact topology after rotating the edge,
- * so loop over all faces attached to the new edge, typically this will only be two faces. */
+ * so loop over all faces attached to the new edge,
+ * typically this will only be two faces. */
BMLoop *l_radial_iter = e_rotate->l;
do {
/* Skip this edge. */
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c
index 66021624025..74635be4681 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -40,7 +40,7 @@ typedef struct SubDParams {
int smooth_falloff;
float fractal;
float along_normal;
- //int beauty;
+ // int beauty;
bool use_smooth;
bool use_smooth_even;
bool use_sphere;
@@ -391,7 +391,7 @@ static BMVert *bm_subdivide_edge_addvert(BMesh *bm,
/* offset for smooth or sphere or fractal */
alter_co(v_new, e_orig, params, factor_subd, v_a, v_b);
-#if 0 //BMESH_TODO
+#if 0 // BMESH_TODO
/* clip if needed by mirror modifier */
if (edge->v1->f2) {
if (edge->v1->f2 & edge->v2->f2 & 1) {
diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c
index be7527ae349..00368364616 100644
--- a/source/blender/bmesh/tools/bmesh_beautify.c
+++ b/source/blender/bmesh/tools/bmesh_beautify.c
@@ -187,7 +187,8 @@ static float bm_edge_calc_rotate_beauty__area(const float v1[3],
/**
* Important to lock degenerate here,
* since the triangle pars will be projected into different 2D spaces.
- * Allowing to rotate out of a degenerate state can flip the faces (when performed iteratively).
+ * Allowing to rotate out of a degenerate state can flip the faces
+ * (when performed iteratively).
*/
return BLI_polyfill_beautify_quad_rotate_calc_ex(v1_xy, v2_xy, v3_xy, v4_xy, true);
} while (false);
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 3cb4cbfdf41..af5ce4ed9ac 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -131,22 +131,36 @@ typedef struct ProfileSpacing {
/* An element in a cyclic boundary of a Vertex Mesh (VMesh) */
typedef struct BoundVert {
- struct BoundVert *next, *prev; /* in CCW order */
+ /** In CCW order. */
+ struct BoundVert *next, *prev;
NewVert nv;
- EdgeHalf *efirst; /* first of edges attached here: in CCW order */
+ /** First of edges attached here: in CCW order. */
+ EdgeHalf *efirst;
EdgeHalf *elast;
- EdgeHalf *eon; /* the "edge between" that this is on, in offset_on_edge_between case */
- EdgeHalf *ebev; /* beveled edge whose left side is attached here, if any */
- int index; /* used for vmesh indexing */
- float sinratio; /* when eon set, ratio of sines of angles to eon edge */
- struct BoundVert *adjchain; /* adjustment chain or cycle link pointer */
- Profile profile; /* edge profile between this and next BoundVert */
- bool any_seam; /* are any of the edges attached here seams? */
- bool visited; /* used during delta adjust pass */
- bool is_arc_start; /* this boundvert begins an arc profile */
- bool is_patch_start; /* this boundvert begins a patch profile */
- int seam_len; /* length of seam starting from current boundvert to next boundvert with ccw ordering */
- int sharp_len; /* Same as seam_len but defines length of sharp edges */
+ /** The "edge between" that this is on, in offset_on_edge_between case. */
+ EdgeHalf *eon;
+ /** Beveled edge whose left side is attached here, if any. */
+ EdgeHalf *ebev;
+ /** Used for vmesh indexing. */
+ int index;
+ /** When eon set, ratio of sines of angles to eon edge. */
+ float sinratio;
+ /** Adjustment chain or cycle link pointer. */
+ struct BoundVert *adjchain;
+ /** Edge profile between this and next BoundVert. */
+ Profile profile;
+ /** Are any of the edges attached here seams? */
+ bool any_seam;
+ /** Used during delta adjust pass */
+ bool visited;
+ /** This boundvert begins an arc profile */
+ bool is_arc_start;
+ /** This boundvert begins a patch profile */
+ bool is_patch_start;
+ /** Length of seam starting from current boundvert to next boundvert with ccw ordering */
+ int seam_len;
+ /** Same as seam_len but defines length of sharp edges */
+ int sharp_len;
// int _pad;
} BoundVert;
@@ -167,78 +181,122 @@ typedef struct VMesh {
/* Data for a vertex involved in a bevel */
typedef struct BevVert {
- BMVert *v; /* original mesh vertex */
- int edgecount; /* total number of edges around the vertex (excluding wire edges if edge beveling) */
- int selcount; /* number of selected edges around the vertex */
- int wirecount; /* count of wire edges */
- float offset; /* offset for this vertex, if vertex_only bevel */
- bool any_seam; /* any seams on attached edges? */
- bool visited; /* used in graph traversal */
- EdgeHalf *edges; /* array of size edgecount; CCW order from vertex normal side */
- BMEdge **wire_edges; /* array of size wirecount of wire edges */
- VMesh *vmesh; /* mesh structure for replacing vertex */
+ /** Original mesh vertex */
+ BMVert *v;
+ /** Total number of edges around the vertex (excluding wire edges if edge beveling) */
+ int edgecount;
+ /** Number of selected edges around the vertex */
+ int selcount;
+ /** Count of wire edges */
+ int wirecount;
+ /** Offset for this vertex, if vertex_only bevel */
+ float offset;
+ /** Any seams on attached edges? */
+ bool any_seam;
+ /** Used in graph traversal */
+ bool visited;
+ /** Array of size edgecount; CCW order from vertex normal side */
+ EdgeHalf *edges;
+ /** Array of size wirecount of wire edges */
+ BMEdge **wire_edges;
+ /** Mesh structure for replacing vertex */
+ VMesh *vmesh;
} BevVert;
/* face classification: note depend on F_RECON > F_EDGE > F_VERT */
typedef enum {
- F_NONE, /* used when there is no face at all */
- F_ORIG, /* original face, not touched */
- F_VERT, /* face for construction aroun a vert */
- F_EDGE, /* face for a beveled edge */
- F_RECON, /* reconstructed original face with some new verts */
+ /** Used when there is no face at all */
+ F_NONE,
+ /** Original face, not touched */
+ F_ORIG,
+ /** Face for construction aroun a vert */
+ F_VERT,
+ /** Face for a beveled edge */
+ F_EDGE,
+ /** Reconstructed original face with some new verts */
+ F_RECON,
} FKind;
-// static const char* fkind_names[] = {"F_NONE", "F_ORIG", "F_VERT", "F_EDGE", "F_RECON"}; /* DEBUG */
+#if 0
+static const char* fkind_names[] = {"F_NONE", "F_ORIG", "F_VERT", "F_EDGE", "F_RECON"}; /* DEBUG */
+#endif
/* Bevel parameters and state */
typedef struct BevelParams {
- GHash *vert_hash; /* records BevVerts made: key BMVert*, value BevVert* */
- GHash *face_hash; /* records new faces: key BMFace*, value one of {VERT/EDGE/RECON}_POLY */
- MemArena *
- mem_arena; /* use for all allocs while bevel runs, if we need to free we can switch to mempool */
- ProfileSpacing pro_spacing; /* parameter values for evenly spaced profiles */
-
- float offset; /* blender units to offset each side of a beveled edge */
- int offset_type; /* how offset is measured; enum defined in bmesh_operators.h */
- int seg; /* number of segments in beveled edge profile */
- float profile; /* user profile setting */
- float pro_super_r; /* superellipse parameter for edge profile */
- bool vertex_only; /* bevel vertices only */
- bool use_weights; /* bevel amount affected by weights on edges or verts */
- bool loop_slide; /* should bevel prefer to slide along edges rather than keep widths spec? */
- bool limit_offset; /* should offsets be limited by collisions? */
- bool offset_adjust; /* should offsets be adjusted to try to get even widths? */
- bool mark_seam; /* should we propagate seam edge markings? */
- bool mark_sharp; /* should we propagate sharp edge markings? */
- bool harden_normals; /* should we harden normals? */
- const struct MDeformVert *dvert; /* vertex group array, maybe set if vertex_only */
- int vertex_group; /* vertex group index, maybe set if vertex_only */
- int mat_nr; /* if >= 0, material number for bevel; else material comes from adjacent faces */
- int face_strength_mode; /* setting face strength if > 0 */
- int miter_outer; /* what kind of miter pattern to use on reflex angles */
- int miter_inner; /* what kind of miter pattern to use on non-reflex angles */
- float spread; /* amount to spread when doing inside miter */
- float smoothresh; /* mesh's smoothresh, used if hardening */
+ /** Records BevVerts made: key BMVert*, value BevVert* */
+ GHash *vert_hash;
+ /** Records new faces: key BMFace*, value one of {VERT/EDGE/RECON}_POLY */
+ GHash *face_hash;
+ /** Use for all allocs while bevel runs, if we need to free we can switch to mempool. */
+ MemArena *mem_arena;
+ /** Parameter values for evenly spaced profiles. */
+ ProfileSpacing pro_spacing;
+
+ /** Blender units to offset each side of a beveled edge. */
+ float offset;
+ /** How offset is measured; enum defined in bmesh_operators.h */
+ int offset_type;
+ /** Number of segments in beveled edge profile. */
+ int seg;
+ /** User profile setting. */
+ float profile;
+ /** Superellipse parameter for edge profile. */
+ float pro_super_r;
+ /** Bevel vertices only. */
+ bool vertex_only;
+ /** Bevel amount affected by weights on edges or verts. */
+ bool use_weights;
+ /** Should bevel prefer to slide along edges rather than keep widths spec? */
+ bool loop_slide;
+ /** Should offsets be limited by collisions? */
+ bool limit_offset;
+ /** Should offsets be adjusted to try to get even widths? */
+ bool offset_adjust;
+ /** Should we propagate seam edge markings? */
+ bool mark_seam;
+ /** Should we propagate sharp edge markings? */
+ bool mark_sharp;
+ /** Should we harden normals? */
+ bool harden_normals;
+ /** Vertex group array, maybe set if vertex_only. */
+ const struct MDeformVert *dvert;
+ /** Vertex group index, maybe set if vertex_only. */
+ int vertex_group;
+ /** If >= 0, material number for bevel; else material comes from adjacent faces. */
+ int mat_nr;
+ /** Setting face strength if > 0. */
+ int face_strength_mode;
+ /** What kind of miter pattern to use on reflex angles. */
+ int miter_outer;
+ /** What kind of miter pattern to use on non-reflex angles. */
+ int miter_inner;
+ /** Amount to spread when doing inside miter. */
+ float spread;
+ /** Mesh's smoothresh, used if hardening. */
+ float smoothresh;
} BevelParams;
// #pragma GCC diagnostic ignored "-Wpadded"
// #include "bevdebug.c"
-/* some flags to re-enable old behavior for a while, in case fixes broke things not caught by regression tests */
+/* Some flags to re-enable old behavior for a while,
+ * in case fixes broke things not caught by regression tests. */
static int bev_debug_flags = 0;
#define DEBUG_OLD_PLANE_SPECIAL (bev_debug_flags & 1)
#define DEBUG_OLD_PROJ_TO_PERP_PLANE (bev_debug_flags & 2)
#define DEBUG_OLD_FLAT_MID (bev_debug_flags & 4)
-/* use the unused _BM_ELEM_TAG_ALT flag to flag the 'long' loops (parallel to beveled edge) of edge-polygons */
+/* use the unused _BM_ELEM_TAG_ALT flag to flag the 'long' loops (parallel to beveled edge)
+ * of edge-polygons. */
#define BM_ELEM_LONG_TAG (1 << 6)
/* these flag values will get set on geom we want to return in 'out' slots for edges and verts */
#define EDGE_OUT 4
#define VERT_OUT 8
-/* If we're called from the modifier, tool flags aren't available, but don't need output geometry */
+/* If we're called from the modifier, tool flags aren't available,
+ * but don't need output geometry. */
static void flag_out_edge(BMesh *bm, BMEdge *bme)
{
if (bm->use_toolflags) {
@@ -622,7 +680,8 @@ static bool contig_ldata_across_loops(BMesh *bm, BMLoop *l1, BMLoop *l2, int lay
type, (char *)l1->head.data + offset, (char *)l2->head.data + offset);
}
-/* Are all loop layers with have math (e.g., UVs) contiguous from face f1 to face f2 across edge e? */
+/* Are all loop layers with have math (e.g., UVs)
+ * contiguous from face f1 to face f2 across edge e? */
static bool contig_ldata_across_edge(BMesh *bm, BMEdge *e, BMFace *f1, BMFace *f2)
{
BMLoop *lef1, *lef2;
@@ -867,8 +926,8 @@ static bool point_between_edges(float co[3], BMVert *v, BMFace *f, EdgeHalf *e1,
* but if the offsets are not equal (allowing for this, as bevel modifier has edge weights that may
* lead to different offsets) then meeting point can be found be intersecting offset lines.
* If making the meeting point significantly changes the left or right offset from the user spec,
- * record the change in offset_l (or offset_r); later we can tell that a change has happened because
- * the offset will differ from its original value in offset_l_spec (or offset_r_spec).
+ * record the change in offset_l (or offset_r); later we can tell that a change has happened
+ * because the offset will differ from its original value in offset_l_spec (or offset_r_spec).
*/
static void offset_meet(
EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool edges_between, float meetco[3])
@@ -1024,7 +1083,8 @@ static void offset_meet(
}
}
-/* chosen so that 1/sin(BEVEL_GOOD_ANGLE) is about 4, giving that expansion factor to bevel width */
+/* Chosen so that 1/sin(BEVEL_GOOD_ANGLE) is about 4,
+ * giving that expansion factor to bevel width. */
#define BEVEL_GOOD_ANGLE 0.25f
/* Calculate the meeting point between e1 and e2 (one of which should have zero offsets),
@@ -1780,7 +1840,8 @@ static void bevel_extend_edge_data(BevVert *bv)
for (int k = 1; k < vm->seg; k++) {
v2 = mesh_vert(vm, i % vm->count, 0, k)->v;
- /* Here v1 & v2 are current and next BMverts, we find common edge and set its edge data */
+ /* Here v1 & v2 are current and next BMverts,
+ * we find common edge and set its edge data. */
e = v1->e;
while (e->v1 != v2 && e->v2 != v2) {
if (e->v1 == v1) {
@@ -1794,7 +1855,7 @@ static void bevel_extend_edge_data(BevVert *bv)
v1 = v2;
}
BMVert *v3 = mesh_vert(vm, (i + 1) % vm->count, 0, 0)->v;
- e = v1->e; //Do same as above for first and last vert
+ e = v1->e; // Do same as above for first and last vert
while (e->v1 != v3 && e->v2 != v3) {
if (e->v1 == v1) {
e = e->v1_disk_link.next;
@@ -1918,14 +1979,16 @@ static void bevel_harden_normals(BMesh *bm, BevelParams *bp)
/* If there is not already a custom split normal layer then making one (with BM_lnorspace_update)
* will not respect the autosmooth angle between smooth faces. To get that to happen, we have
- * to mark the sharpen the edges that are only sharp because of the angle test -- otherwise would be smooth.
+ * to mark the sharpen the edges that are only sharp because
+ * of the angle test -- otherwise would be smooth.
*/
if (cd_clnors_offset == -1) {
BM_edges_sharp_from_angle_set(bm, bp->smoothresh);
bevel_edges_sharp_boundary(bm, bp);
}
- /* ensure that bm->lnor_spacearr has properly stored loop normals; side effect: ensures loop indices */
+ /* Ensure that bm->lnor_spacearr has properly stored loop normals;
+ * side effect: ensures loop indices. */
BM_lnorspace_update(bm);
if (cd_clnors_offset == -1) {
@@ -3143,7 +3206,8 @@ static VMesh *new_adj_vmesh(MemArena *mem_arena, int count, int seg, BoundVert *
return vm;
}
-/* VMesh verts for vertex i have data for (i, 0 <= j <= ns2, 0 <= k <= ns), where ns2 = floor(nseg / 2).
+/* VMesh verts for vertex i have data for (i, 0 <= j <= ns2, 0 <= k <= ns),
+ * where ns2 = floor(nseg / 2).
* But these overlap data from previous and next i: there are some forced equivalences.
* Let's call these indices the canonical ones: we will just calculate data for these
* 0 <= j <= ns2, 0 <= k < ns2 (for odd ns2)
@@ -4148,13 +4212,15 @@ static void closer_v3_v3v3v3(float r[3], float a[3], float b[3], float v[3])
}
/* Special case of VMesh when profile == 1 and there are 3 or more beveled edges.
- * We want the effect of parallel offset lines (n/2 of them) on each side of the center, for even n.
- * Wherever they intersect with each other between two successive beveled edges, those intersections
- * are part of the vmesh rings.
+ * We want the effect of parallel offset lines (n/2 of them)
+ * on each side of the center, for even n.
+ * Wherever they intersect with each other between two successive beveled edges,
+ * those intersections are part of the vmesh rings.
* We have to move the boundary edges too -- the usual method is to make one profile plane between
- * successive BoundVerts, but for the effect we want here, there will be two planes, one on each side
- * of the original edge.
- * At the moment, this is not called for odd number of segments, though code does something if it is.
+ * successive BoundVerts, but for the effect we want here, there will be two planes,
+ * one on each side of the original edge.
+ * At the moment, this is not called for odd number of segments,
+ * though code does something if it is.
*/
static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
{
@@ -4574,8 +4640,9 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv)
/* If we make a poly out of verts around bv, snapping to rep frep, will uv poly have zero area?
* The uv poly is made by snapping all outside-of-frep vertices to the closest edge in frep.
* Assume that this function is called when the only inside-of-frep vertex is vm->boundstart.
- * The poly will have zero area if the distance of that first vertex to some edge e is zero, and all
- * the other vertices snap to e or snap to an edge at a point that is essentially on e too. */
+ * The poly will have zero area if the distance of that first vertex to some edge e is zero,
+ * and all the other vertices snap to e or snap to an edge
+ * at a point that is essentially on e too. */
static bool is_bad_uv_poly(BevVert *bv, BMFace *frep)
{
BoundVert *v;
@@ -4958,7 +5025,8 @@ static int bevel_edge_order_extend(BMesh *bm, BevVert *bv, int i)
}
/* at this point we should be back at invariant on entrance: path up to j */
if (bestj > j) {
- /* save_path should have from j + 1 to bestj inclusive edges to add to edges[] before returning */
+ /* save_path should have from j + 1 to bestj inclusive
+ * edges to add to edges[] before returning. */
for (k = j + 1; k <= bestj; k++) {
BLI_assert(save_path[k - (j + 1)] != NULL);
bv->edges[k].e = save_path[k - (j + 1)];
@@ -4978,9 +5046,10 @@ static int bevel_edge_order_extend(BMesh *bm, BevVert *bv, int i)
* Assume the first edge is already in bv->edges[0].e and it is tagged. */
#ifdef FASTER_FASTORDER
/* The alternative older code is O(n^2) where n = # of edges incident to bv->v.
- * This implementation is O(n * m) where m = average number of faces attached to an edge incident to bv->v,
- * which is almost certainly a small constant except in very strange cases. But this code produces different
- * choices of ordering than the legacy system, leading to differences in vertex orders etc. in user models,
+ * This implementation is O(n * m) where m = average number of faces attached to an edge incident
+ * to bv->v, which is almost certainly a small constant except in very strange cases.
+ * But this code produces different choices of ordering than the legacy system,
+ * leading to differences in vertex orders etc. in user models,
* so for now will continue to use the legacy code. */
static bool fast_bevel_edge_order(BevVert *bv)
{
@@ -5153,6 +5222,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
BMIter iter;
EdgeHalf *e;
float weight, z;
+ float vert_axis[3];
int i, ccw_test_sum;
int nsel = 0;
int ntot = 0;
@@ -5221,21 +5291,6 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
bv->vmesh = (VMesh *)BLI_memarena_alloc(bp->mem_arena, sizeof(VMesh));
bv->vmesh->seg = bp->seg;
- if (bp->vertex_only) {
- /* if weighted, modify offset by weight */
- if (bp->dvert != NULL && bp->vertex_group != -1) {
- weight = defvert_find_weight(bp->dvert + BM_elem_index_get(v), bp->vertex_group);
- if (weight <= 0.0f) {
- BM_elem_flag_disable(v, BM_ELEM_TAG);
- return NULL;
- }
- bv->offset *= weight;
- }
- else if (bp->use_weights) {
- weight = BM_elem_float_data_get(&bm->vdata, v, CD_BWEIGHT);
- bv->offset *= weight;
- }
- }
BLI_ghash_insert(bp->vert_hash, v, bv);
find_bevel_edge_order(bm, bv, first_bme);
@@ -5283,6 +5338,29 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
}
}
+ if (bp->vertex_only) {
+ /* if weighted, modify offset by weight */
+ if (bp->dvert != NULL && bp->vertex_group != -1) {
+ weight = defvert_find_weight(bp->dvert + BM_elem_index_get(v), bp->vertex_group);
+ bv->offset *= weight;
+ }
+ else if (bp->use_weights) {
+ weight = BM_elem_float_data_get(&bm->vdata, v, CD_BWEIGHT);
+ bv->offset *= weight;
+ }
+ /* Find center axis. Note: Don't use vert normal, can give unwanted results. */
+ if (ELEM(bp->offset_type, BEVEL_AMT_WIDTH, BEVEL_AMT_DEPTH)) {
+ float edge_dir[3];
+ for (i = 0, e = bv->edges; i < ntot; i++, e++) {
+ v2 = BM_edge_other_vert(e->e, bv->v);
+ sub_v3_v3v3(edge_dir, bv->v->co, v2->co);
+ normalize_v3(edge_dir);
+ add_v3_v3v3(vert_axis, vert_axis, edge_dir);
+ }
+ mul_v3_fl(vert_axis, 1 / ntot);
+ }
+ }
+
for (i = 0, e = bv->edges; i < ntot; i++, e++) {
e->next = &bv->edges[(i + 1) % ntot];
e->prev = &bv->edges[(i + ntot - 1) % ntot];
@@ -5342,13 +5420,43 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
}
else if (bp->vertex_only) {
/* Weight has already been applied to bv->offset, if present.
- * Transfer to e->offset_[lr]_spec and treat percent as special case */
- if (bp->offset_type == BEVEL_AMT_PERCENT) {
- v2 = BM_edge_other_vert(e->e, bv->v);
- e->offset_l_spec = BM_edge_calc_length(e->e) * bv->offset / 100.0f;
- }
- else {
- e->offset_l_spec = bv->offset;
+ * Transfer to e->offset_[lr]_spec according to offset_type. */
+ float edge_dir[3];
+ switch (bp->offset_type) {
+ case BEVEL_AMT_OFFSET: {
+ e->offset_l_spec = bv->offset;
+ break;
+ }
+ case BEVEL_AMT_WIDTH: {
+ v2 = BM_edge_other_vert(e->e, bv->v);
+ sub_v3_v3v3(edge_dir, bv->v->co, v2->co);
+ normalize_v3(edge_dir);
+ z = fabsf(2.0f * sinf(angle_normalized_v3v3(vert_axis, edge_dir)));
+ if (z < BEVEL_EPSILON) {
+ e->offset_l_spec = 0.01f * bp->offset; /* undefined behavior, so tiny bevel. */
+ }
+ else {
+ e->offset_l_spec = bp->offset / z;
+ }
+ break;
+ }
+ case BEVEL_AMT_DEPTH: {
+ v2 = BM_edge_other_vert(e->e, bv->v);
+ sub_v3_v3v3(edge_dir, bv->v->co, v2->co);
+ normalize_v3(edge_dir);
+ z = fabsf(cosf(angle_normalized_v3v3(vert_axis, edge_dir)));
+ if (z < BEVEL_EPSILON) {
+ e->offset_l_spec = 0.01f * bp->offset; /* undefined behavior, so tiny bevel. */
+ }
+ else {
+ e->offset_l_spec = bp->offset / z;
+ }
+ break;
+ }
+ case BEVEL_AMT_PERCENT: {
+ e->offset_l_spec = BM_edge_calc_length(e->e) * bv->offset / 100.0f;
+ break;
+ }
}
e->offset_r_spec = e->offset_l_spec;
}
diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
index 3838f199847..da525becc78 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
@@ -204,7 +204,7 @@ static bool bm_edge_collapse_is_degenerate_flip(BMEdge *e, const float optimize_
/* use a small value rather then zero so we don't flip a face in multiple steps
* (first making it zero area, then flipping again) */
if (dot_v3v3(cross_exist, cross_optim) <= FLT_EPSILON) {
- //printf("no flip\n");
+ // printf("no flip\n");
return true;
}
#endif
@@ -690,7 +690,8 @@ static void bm_decim_triangulate_end(BMesh *bm, const int edges_tri_tot)
static void bm_edge_collapse_loop_customdata(
BMesh *bm, BMLoop *l, BMVert *v_clear, BMVert *v_other, const float customdata_fac)
{
- /* disable seam check - the seam check would have to be done per layer, its not really that important */
+ /* Disable seam check - the seam check would have to be done per layer,
+ * its not really that important. */
//#define USE_SEAM
/* these don't need to be updated, since they will get removed when the edge collapses */
BMLoop *l_clear, *l_other;
diff --git a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
index 0fbb2d14766..010245fa93d 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
@@ -350,7 +350,8 @@ void BM_mesh_decimate_dissolve_ex(BMesh *bm,
BM_ITER_MESH_INDEX (e_iter, &iter, bm, BM_EDGES_OF_MESH, i) {
earray[i] = e_iter;
}
- /* remove all edges/verts left behind from dissolving, NULL'ing the vertex array so we dont re-use */
+ /* Remove all edges/verts left behind from dissolving,
+ * NULL'ing the vertex array so we dont re-use. */
for (i = bm->totedge - 1; i != -1; i--) {
e_iter = earray[i];
diff --git a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
index 13ada1756de..27b4fa15f26 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
@@ -264,7 +264,7 @@ void BM_mesh_decimate_unsubdivide_ex(BMesh *bm, const int iterations, const bool
}
else {
/* works better to allow these verts to be checked again */
- //BM_elem_index_set(v, VERT_INDEX_IGNORE); /* set_dirty! */
+ // BM_elem_index_set(v, VERT_INDEX_IGNORE); /* set_dirty! */
}
}
}
diff --git a/source/blender/bmesh/tools/bmesh_path_region.c b/source/blender/bmesh/tools/bmesh_path_region.c
index 9ec3b51f29a..8b139e6a5ff 100644
--- a/source/blender/bmesh/tools/bmesh_path_region.c
+++ b/source/blender/bmesh/tools/bmesh_path_region.c
@@ -116,7 +116,8 @@ static bool bm_vert_region_test_chain(BMVert *v, int *const depths[2], const int
*
* This is done in both directions, after that each vertices 'depth' is added to check
* if its less than the number of passes needed to complete the search.
- * When it is, we know the path is one of possible paths that have the minimum topological distance.
+ * When it is, we know the path is one of possible paths
+ * that have the minimum topological distance.
*
* \note Only verts without BM_ELEM_TAG will be walked over.
*/
@@ -201,7 +202,8 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm,
#ifdef USE_EDGE_CHAIN
/* Expand initial state to end-point vertices when they only have 2x edges,
- * this prevents odd behavior when source or destination are in the middle of a long chain of edges. */
+ * this prevents odd behavior when source or destination are in the middle
+ * of a long chain of edges. */
if (ELEM(path_htype, BM_VERT, BM_EDGE)) {
for (int i = 0; i < ele_verts_len[side]; i++) {
BMVert *v = ele_verts[side][i];
@@ -221,8 +223,8 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm,
}
#endif /* USE_EDGE_CHAIN */
- /* Keep walking over connected geometry until we find all the vertices in `ele_verts[side_other]`,
- * or exit the loop when theres no connection. */
+ /* Keep walking over connected geometry until we find all the vertices in
+ * `ele_verts[side_other]`, or exit the loop when theres no connection. */
found_all = false;
for (pass = 1; (STACK_SIZE(stack) != 0); pass++) {
while (STACK_SIZE(stack) != 0) {
@@ -321,7 +323,8 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm,
} while ((l_iter = l_iter->next) != l_first);
#else
/* Allowing a single failure on a face gives fewer 'gaps'.
- * While correct, in practice they're often part of what a user would consider the 'region'. */
+ * While correct, in practice they're often part of what
+ * a user would consider the 'region'. */
int ok_tests = f->len > 3 ? 1 : 0; /* how many times we may fail */
do {
if (!bm_vert_region_test_chain(l_iter->v, depths, pass)) {
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 826306fa789..a34f92f66d6 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -130,7 +130,7 @@ void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler)
{
bool container_is_open = false;
- //Transform animations (trans, rot, scale)
+ /* Transform animations (trans, rot, scale). */
container_is_open = open_animation_container(container_is_open, ob);
/* Now take care of the Object Animations
@@ -141,8 +141,8 @@ void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler)
BC_TRANSFORMATION_TYPE_MATRIX;
if (export_as_matrix) {
- export_matrix_animation(
- ob, sampler); // export all transform_curves as one single matrix animation
+ /* export all transform_curves as one single matrix animation */
+ export_matrix_animation(ob, sampler);
}
export_curve_animation_set(ob, sampler, export_as_matrix);
@@ -237,7 +237,7 @@ void AnimationExporter::export_matrix_animation(Object *ob, BCAnimationSampler &
}
}
-//write bone animations in transform matrix sources
+/* Write bone animations in transform matrix sources. */
void AnimationExporter::export_bone_animations_recursive(Object *ob,
Bone *bone,
BCAnimationSampler &sampler)
@@ -280,7 +280,7 @@ BCAnimationCurve *AnimationExporter::get_modified_export_curve(Object *ob,
BCCurveKey key(BC_ANIMATION_TYPE_CAMERA, "xfov", 0);
mcurve = new BCAnimationCurve(key, ob);
- // now tricky part: transform the fcurve
+ /* now tricky part: transform the fcurve */
BCValueMap lens_values;
curve.get_value_map(lens_values);
@@ -306,7 +306,8 @@ BCAnimationCurve *AnimationExporter::get_modified_export_curve(Object *ob,
float value = RAD2DEGF(focallength_to_fov(lens_value, sensor_value));
mcurve->add_value(value, frame);
}
- mcurve->clean_handles(); // to reset the handles
+ /* to reset the handles */
+ mcurve->clean_handles();
}
return mcurve;
}
@@ -322,7 +323,8 @@ void AnimationExporter::export_curve_animation(Object *ob, BCAnimationCurve &cur
*/
int channel_index = curve.get_channel_index();
- std::string axis = get_axis_name(channel_target, channel_index); // RGB or XYZ or ""
+ /* RGB or XYZ or "" */
+ std::string axis = get_axis_name(channel_target, channel_index);
std::string action_name;
bAction *action = bc_getSceneObjectAction(ob);
@@ -365,19 +367,19 @@ void AnimationExporter::export_bone_animation(Object *ob,
bool AnimationExporter::is_bone_deform_group(Bone *bone)
{
bool is_def;
- //Check if current bone is deform
+ /* Check if current bone is deform */
if ((bone->flag & BONE_NO_DEFORM) == 0)
return true;
- //Check child bones
+ /* Check child bones */
else {
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
- //loop through all the children until deform bone is found, and then return
+ /* loop through all the children until deform bone is found, and then return */
is_def = is_bone_deform_group(child);
if (is_def)
return true;
}
}
- //no deform bone found in children also
+ /* no deform bone found in children also */
return false;
}
@@ -466,7 +468,7 @@ void AnimationExporter::export_collada_matrix_animation(std::string id,
sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION,
COLLADABU::URI(EMPTY_STRING, interpolation_id));
- // Matrix animation has no tangents
+ /* Matrix animation has no tangents */
addSampler(sampler);
addChannel(COLLADABU::URI(EMPTY_STRING, sampler_id), target);
@@ -514,7 +516,8 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa
else if (transform) {
param.push_back("TRANSFORM");
}
- else { //assumes if axis isn't specified all axises are added
+ else {
+ /* assumes if axis isn't specified all axises are added */
param.push_back("X");
param.push_back("Y");
param.push_back("Z");
@@ -641,7 +644,8 @@ std::string AnimationExporter::collada_source_from_values(BCMatrixSampleMap &sam
source.prepareToAppendValues();
BCMatrixSampleMap::iterator it;
- int precision = (this->export_settings->limit_precision) ? 6 : -1; // could be made configurable
+ /* could be made configurable */
+ int precision = (this->export_settings->limit_precision) ? 6 : -1;
for (it = samples.begin(); it != samples.end(); it++) {
const BCMatrix *sample = it->second;
double daemat[4][4];
@@ -686,11 +690,12 @@ std::string AnimationExporter::collada_interpolation_source(const BCAnimationCur
else if (ipo == BEZT_IPO_CONST) {
source.appendValues(STEP_NAME);
}
- else { // BEZT_IPO_LIN
+ else {
+ /* BEZT_IPO_LIN */
source.appendValues(LINEAR_NAME);
}
}
- // unsupported? -- HERMITE, CARDINAL, BSPLINE, NURBS
+ /* unsupported? -- HERMITE, CARDINAL, BSPLINE, NURBS */
source.finish();
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index 8a9a8e5eb7b..3ab859bdb00 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -48,7 +48,7 @@
#include <algorithm>
-// first try node name, if not available (since is optional), fall back to original id
+/* first try node name, if not available (since is optional), fall back to original id */
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
@@ -69,7 +69,7 @@ void AnimationImporter::add_bezt(FCurve *fcu,
float value,
eBezTriple_Interpolation ipo)
{
- //float fps = (float)FPS;
+ // float fps = (float)FPS;
BezTriple bez;
memset(&bez, 0, sizeof(BezTriple));
bez.vec[1][0] = frame;
@@ -81,7 +81,7 @@ void AnimationImporter::add_bezt(FCurve *fcu,
calchandles_fcurve(fcu);
}
-// create one or several fcurves depending on the number of parameters being animated
+/* create one or several fcurves depending on the number of parameters being animated */
void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
{
COLLADAFW::FloatOrDoubleArray &input = curve->getInputValues();
@@ -94,10 +94,10 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
std::vector<FCurve *> &fcurves = curve_map[curve->getUniqueId()];
switch (dim) {
- case 1: // X, Y, Z or angle
- case 3: // XYZ
+ case 1: /* X, Y, Z or angle */
+ case 3: /* XYZ */
case 4:
- case 16: // matrix
+ case 16: /* matrix */
{
for (i = 0; i < dim; i++) {
FCurve *fcu = (FCurve *)MEM_callocN(sizeof(FCurve), "FCurve");
@@ -110,7 +110,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
BezTriple bez;
memset(&bez, 0, sizeof(BezTriple));
- // input, output
+ /* input, output */
bez.vec[1][0] = bc_get_float_value(input, j) * fps;
bez.vec[1][1] = bc_get_float_value(output, j * dim + i);
bez.h1 = bez.h2 = HD_AUTO;
@@ -120,11 +120,11 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
COLLADAFW::FloatOrDoubleArray &intan = curve->getInTangentValues();
COLLADAFW::FloatOrDoubleArray &outtan = curve->getOutTangentValues();
- // intangent
+ /* intangent */
bez.vec[0][0] = bc_get_float_value(intan, (j * 2 * dim) + (2 * i)) * fps;
bez.vec[0][1] = bc_get_float_value(intan, (j * 2 * dim) + (2 * i) + 1);
- // outtangent
+ /* outtangent */
bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i)) * fps;
bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i) + 1);
if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER) {
@@ -138,7 +138,9 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
else {
bez.ipo = BEZT_IPO_LIN;
}
- // bez.ipo = U.ipo_new; /* use default interpolation mode here... */
+#if 0
+ bez.ipo = U.ipo_new; /* use default interpolation mode here... */
+#endif
bez.f1 = bez.f2 = bez.f3 = SELECT;
insert_bezt_fcurve(fcu, &bez, INSERTKEY_NOFLAGS);
@@ -161,7 +163,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
void AnimationImporter::fcurve_deg_to_rad(FCurve *cu)
{
for (unsigned int i = 0; i < cu->totvert; i++) {
- // TODO convert handles too
+ /* TODO convert handles too */
cu->bezt[i].vec[1][1] *= DEG2RADF(1.0f);
cu->bezt[i].vec[0][1] *= DEG2RADF(1.0f);
cu->bezt[i].vec[2][1] *= DEG2RADF(1.0f);
@@ -195,7 +197,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain,
char *p = strstr(rna_path, "rotation_euler");
bool is_rotation = p && *(p + strlen("rotation_euler")) == '\0';
- // convert degrees to radians for rotation
+ /* convert degrees to radians for rotation */
if (is_rotation)
fcurve_deg_to_rad(fcu);
#endif
@@ -253,7 +255,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain,
AnimationImporter::~AnimationImporter()
{
- // free unused FCurves
+ /* free unused FCurves */
for (std::vector<FCurve *>::iterator it = unused_curves.begin(); it != unused_curves.end(); it++)
free_fcurve(*it);
@@ -266,15 +268,15 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
if (anim->getAnimationType() == COLLADAFW::Animation::ANIMATION_CURVE) {
COLLADAFW::AnimationCurve *curve = (COLLADAFW::AnimationCurve *)anim;
- // XXX Don't know if it's necessary
- // Should we check outPhysicalDimension?
+ /* XXX Don't know if it's necessary
+ * Should we check outPhysicalDimension? */
if (curve->getInPhysicalDimension() != COLLADAFW::PHYSICAL_DIMENSION_TIME) {
fprintf(stderr, "Inputs physical dimension is not time.\n");
return true;
}
- // a curve can have mixed interpolation type,
- // in this case curve->getInterpolationTypes returns a list of interpolation types per key
+ /* a curve can have mixed interpolation type,
+ * in this case curve->getInterpolationTypes returns a list of interpolation types per key */
COLLADAFW::AnimationCurve::InterpolationType interp = curve->getInterpolationType();
if (interp != COLLADAFW::AnimationCurve::INTERPOLATION_MIXED) {
@@ -285,14 +287,14 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
animation_to_fcurves(curve);
break;
default:
- // TODO there're also CARDINAL, HERMITE, BSPLINE and STEP types
+ /* TODO there're also CARDINAL, HERMITE, BSPLINE and STEP types */
fprintf(stderr,
"CARDINAL, HERMITE and BSPLINE anim interpolation types not supported yet.\n");
break;
}
}
else {
- // not supported yet
+ /* not supported yet */
fprintf(stderr, "MIXED anim interpolation type is not supported yet.\n");
}
}
@@ -303,7 +305,7 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
return true;
}
-// called on post-process stage after writeVisualScenes
+/* called on post-process stage after writeVisualScenes */
bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList *animlist)
{
const COLLADAFW::UniqueId &animlist_id = animlist->getUniqueId();
@@ -311,21 +313,21 @@ bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList *ani
#if 0
- // should not happen
+ /* should not happen */
if (uid_animated_map.find(animlist_id) == uid_animated_map.end()) {
return true;
}
- // for bones rna_path is like: pose.bones["bone-name"].rotation
+ /* for bones rna_path is like: pose.bones["bone-name"].rotation */
#endif
return true;
}
-// \todo refactor read_node_transform to not automatically apply anything,
-// but rather return the transform matrix, so caller can do with it what is
-// necessary. Same for \ref get_node_mat
+/* \todo refactor read_node_transform to not automatically apply anything,
+ * but rather return the transform matrix, so caller can do with it what is
+ * necessary. Same for \ref get_node_mat */
void AnimationImporter::read_node_transform(COLLADAFW::Node *node, Object *ob)
{
float mat[4][4];
@@ -392,7 +394,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
eulcu[2] ? evaluate_fcurve(eulcu[2], frame) : 0.0f,
};
- // make eul relative to bone rest pose
+ /* make eul relative to bone rest pose */
float rot[3][3], rel[3][3], quat[4];
# if 0
@@ -408,7 +410,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
}
}
- // now replace old Euler curves
+ /* now replace old Euler curves */
for (i = 0; i < 3; i++) {
if (!eulcu[i])
@@ -431,7 +433,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
}
#endif
-//sets the rna_path and array index to curve
+/* sets the rna_path and array index to curve */
void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves,
const char *rna_path,
int array_index)
@@ -453,7 +455,7 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves,
void AnimationImporter::unused_fcurve(std::vector<FCurve *> *curves)
{
- // when an error happens and we can't actually use curve remove it from unused_curves
+ /* when an error happens and we can't actually use curve remove it from unused_curves */
std::vector<FCurve *>::iterator it;
for (it = curves->begin(); it != curves->end(); it++) {
FCurve *fcu = *it;
@@ -468,16 +470,17 @@ void AnimationImporter::find_frames(std::vector<float> *frames, std::vector<FCur
FCurve *fcu = *iter;
for (unsigned int k = 0; k < fcu->totvert; k++) {
- //get frame value from bezTriple
+ /* get frame value from bezTriple */
float fra = fcu->bezt[k].vec[1][0];
- //if frame already not added add frame to frames
+ /* if frame already not added add frame to frames */
if (std::find(frames->begin(), frames->end(), fra) == frames->end())
frames->push_back(fra);
}
}
}
-//creates the rna_paths and array indices of fcurves from animations using transformation and bound animation class of each animation.
+/* creates the rna_paths and array indices of fcurves from animations using transformation and
+ * bound animation class of each animation. */
void AnimationImporter::Assign_transform_animations(
COLLADAFW::Transformation *transform,
const COLLADAFW::AnimationList::AnimationBinding *binding,
@@ -489,7 +492,7 @@ void AnimationImporter::Assign_transform_animations(
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
- //to check if the no of curves are valid
+ /* to check if the no of curves are valid */
bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE ||
tm_type == COLLADAFW::Transformation::SCALE) &&
binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
@@ -542,7 +545,7 @@ void AnimationImporter::Assign_transform_animations(
for (iter = curves->begin(); iter != curves->end(); iter++) {
FCurve *fcu = *iter;
- //if transform is rotation the fcurves values must be turned in to radian.
+ /* if transform is rotation the fcurves values must be turned in to radian. */
if (is_rotation)
fcurve_deg_to_rad(fcu);
}
@@ -564,7 +567,7 @@ void AnimationImporter::Assign_transform_animations(
unused_fcurve(curves);
break;
case COLLADAFW::AnimationList::AXISANGLE:
- // TODO convert axis-angle to quat? or XYZ?
+ /* TODO convert axis-angle to quat? or XYZ? */
default:
unused_fcurve(curves);
fprintf(stderr,
@@ -594,7 +597,8 @@ void AnimationImporter::Assign_transform_animations(
}
}
-//creates the rna_paths and array indices of fcurves from animations using color and bound animation class of each animation.
+/* creates the rna_paths and array indices of fcurves from animations using color and bound
+ * animation class of each animation. */
void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listid,
ListBase *AnimCurves,
const char *anim_type)
@@ -612,7 +616,7 @@ void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listi
}
const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
- //all the curves belonging to the current binding
+ /* all the curves belonging to the current binding */
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
@@ -628,7 +632,7 @@ void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listi
modify_fcurve(&animcurves, rna_path, 2);
break;
case COLLADAFW::AnimationList::COLOR_RGB:
- case COLLADAFW::AnimationList::COLOR_RGBA: // to do-> set intensity
+ case COLLADAFW::AnimationList::COLOR_RGBA: /* to do-> set intensity */
modify_fcurve(&animcurves, rna_path, -1);
break;
@@ -641,7 +645,7 @@ void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listi
}
std::vector<FCurve *>::iterator iter;
- //Add the curves of the current animation to the object
+ /* Add the curves of the current animation to the object */
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
BLI_addtail(AnimCurves, fcu);
@@ -659,10 +663,10 @@ void AnimationImporter::Assign_float_animations(const COLLADAFW::UniqueId &listi
return;
}
else {
- //anim_type has animations
+ /* anim_type has animations */
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
- //all the curves belonging to the current binding
+ /* all the curves belonging to the current binding */
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
@@ -670,10 +674,11 @@ void AnimationImporter::Assign_float_animations(const COLLADAFW::UniqueId &listi
BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
modify_fcurve(&animcurves, rna_path, 0);
std::vector<FCurve *>::iterator iter;
- //Add the curves of the current animation to the object
+ /* Add the curves of the current animation to the object */
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
- /* All anim_types whose values are to be converted from Degree to Radians can be ORed here */
+ /* All anim_types whose values are to be converted from Degree to Radians can be ORed here
+ */
if (STREQ("spot_size", anim_type)) {
/* NOTE: Do NOT convert if imported file was made by blender <= 2.69.10
* Reason: old blender versions stored spot_size in radians (was a bug)
@@ -697,7 +702,7 @@ float AnimationImporter::convert_to_focal_length(float in_xfov,
float aspect,
float sensorx)
{
- // NOTE: Needs more testing (As we curretnly have no official test data for this)
+ /* NOTE: Needs more testing (As we curretnly have no official test data for this) */
float xfov = (fov_type == CAMERA_YFOV) ?
(2.0f * atanf(aspect * tanf(DEG2RADF(in_xfov) * 0.5f))) :
DEG2RADF(in_xfov);
@@ -721,10 +726,10 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId &listid
return;
}
else {
- //anim_type has animations
+ /* anim_type has animations */
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
- //all the curves belonging to the current binding
+ /* all the curves belonging to the current binding */
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
@@ -733,7 +738,7 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId &listid
modify_fcurve(&animcurves, rna_path, 0);
std::vector<FCurve *>::iterator iter;
- //Add the curves of the current animation to the object
+ /* Add the curves of the current animation to the object */
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
@@ -785,8 +790,8 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
copy_m4_m4(rest, bone->arm_mat);
invert_m4_m4(irest, rest);
}
- // new curves to assign matrix transform animation
- FCurve *newcu[10]; // if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale
+ /* new curves to assign matrix transform animation */
+ FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale */
unsigned int totcu = 10;
const char *tm_str = NULL;
char rna_path[200];
@@ -822,10 +827,12 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
std::vector<float>::iterator it;
- //float qref[4];
- //unit_qt(qref);
+#if 0
+ float qref[4];
+ unit_qt(qref);
+#endif
- // sample values at each frame
+ /* sample values at each frame */
for (it = frames.begin(); it != frames.end(); it++) {
float fra = *it;
@@ -834,23 +841,26 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
unit_m4(matfra);
- // calc object-space mat
+ /* calc object-space mat */
evaluate_transform_at_frame(matfra, node, fra);
- // for joints, we need a special matrix
+ /* for joints, we need a special matrix */
if (is_joint) {
- // special matrix: iR * M * iR_dae * R
- // where R, iR are bone rest and inverse rest mats in world space (Blender bones),
- // iR_dae is joint inverse rest matrix (DAE) and M is an evaluated joint world-space matrix (DAE)
+ /* special matrix: iR * M * iR_dae * R
+ * where R, iR are bone rest and inverse rest mats in world space (Blender bones),
+ * iR_dae is joint inverse rest matrix (DAE)
+ * and M is an evaluated joint world-space matrix (DAE) */
float temp[4][4], par[4][4];
- // calc M
+ /* calc M */
calc_joint_parent_mat_rest(par, NULL, root, node);
mul_m4_m4m4(temp, par, matfra);
- // evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
+#if 0
+ evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
+#endif
- // calc special matrix
+ /* calc special matrix */
mul_m4_series(mat, irest, temp, irest_dae, rest);
}
else {
@@ -860,7 +870,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
float rot[4], loc[3], scale[3];
mat4_decompose(loc, rot, scale, mat);
- // add keys
+ /* add keys */
for (int i = 0; i < totcu; i++) {
if (i < 4)
add_bezt(newcu[i], fra, rot[i]);
@@ -875,13 +885,15 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
ListBase *curves = &ob->adt->action->curves;
- // add curves
+ /* add curves */
for (int i = 0; i < totcu; i++) {
if (is_joint)
add_bone_fcurve(ob, node, newcu[i]);
else
BLI_addtail(curves, newcu[i]);
- // fcurve_is_used(newcu[i]); // never added to unused
+#if 0
+ fcurve_is_used(newcu[i]); /* never added to unused */
+#endif
}
if (is_joint) {
@@ -913,7 +925,7 @@ static const double get_aspect_ratio(const COLLADAFW::Camera *camera)
const double yfov = camera->getYFov().getValue();
if (yfov == 0) {
- aspect = 1; // assume yfov and xfov are equal
+ aspect = 1; /* assume yfov and xfov are equal */
}
else {
const double xfov = camera->getXFov().getValue();
@@ -976,12 +988,12 @@ void AnimationImporter::translate_Animations(
else
act = ob->adt->action;
- //Get the list of animation curves of the object
+ /* Get the list of animation curves of the object */
ListBase *AnimCurves = &(act->curves);
const COLLADAFW::TransformationPointerArray &nodeTransforms = node->getTransformations();
- //for each transformation in node
+ /* for each transformation in node */
for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) {
COLLADAFW::Transformation *transform = nodeTransforms[i];
COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType();
@@ -991,16 +1003,16 @@ void AnimationImporter::translate_Animations(
const COLLADAFW::UniqueId &listid = transform->getAnimationList();
- //check if transformation has animations
+ /* check if transformation has animations */
if (animlist_map.find(listid) == animlist_map.end()) {
continue;
}
else {
- //transformation has animations
+ /* transformation has animations */
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings &bindings =
animlist->getAnimationBindings();
- //all the curves belonging to the current binding
+ /* all the curves belonging to the current binding */
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
@@ -1012,12 +1024,13 @@ void AnimationImporter::translate_Animations(
add_bone_animation_sampled(ob, animcurves, root, node, transform);
}
else {
- //calculate rnapaths and array index of fcurves according to transformation and animation class
+ /* calculate rnapaths and array index of fcurves according to transformation and
+ * animation class */
Assign_transform_animations(
transform, &bindings[j], &animcurves, is_joint, joint_path);
std::vector<FCurve *>::iterator iter;
- //Add the curves of the current animation to the object
+ /* Add the curves of the current animation to the object */
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
@@ -1192,7 +1205,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
std::vector<float> frames;
find_frames(&frames, &animcurves);
- // convert degrees to radians
+ /* convert degrees to radians */
if (tm->getTransformationType() == COLLADAFW::Transformation::ROTATE) {
std::vector<FCurve *>::iterator iter;
@@ -1219,8 +1232,8 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
copy_m4_m4(rest, bone->arm_mat);
invert_m4_m4(irest, rest);
- // new curves to assign matrix transform animation
- FCurve *newcu[10]; // if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale
+ /* new curves to assign matrix transform animation */
+ FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale. */
unsigned int totcu = 10;
const char *tm_str = NULL;
char rna_path[200];
@@ -1257,7 +1270,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
std::vector<float>::iterator it;
- // sample values at each frame
+ /* sample values at each frame */
for (it = frames.begin(); it != frames.end(); it++) {
float fra = *it;
@@ -1266,22 +1279,23 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
unit_m4(matfra);
- // calc object-space mat
+ /* calc object-space mat */
evaluate_transform_at_frame(matfra, node, fra);
- // for joints, we need a special matrix
- // special matrix: iR * M * iR_dae * R
- // where R, iR are bone rest and inverse rest mats in world space (Blender bones),
- // iR_dae is joint inverse rest matrix (DAE) and M is an evaluated joint world-space matrix (DAE)
+ /* for joints, we need a special matrix
+ * special matrix: iR * M * iR_dae * R
+ * where R, iR are bone rest and inverse rest mats in world space (Blender bones),
+ * iR_dae is joint inverse rest matrix (DAE)
+ * and M is an evaluated joint world-space matrix (DAE). */
float temp[4][4], par[4][4];
- // calc M
+ /* calc M */
calc_joint_parent_mat_rest(par, NULL, root, node);
mul_m4_m4m4(temp, par, matfra);
- // evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
+ /* evaluate_joint_world_transform_at_frame(temp, NULL, node, fra); */
- // calc special matrix
+ /* calc special matrix */
mul_m4_series(mat, irest, temp, irest_dae, rest);
float rot[4], loc[3], scale[3];
@@ -1292,7 +1306,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
copy_v3_v3(loc, mat[3]);
mat4_to_size(scale, mat);
- // add keys
+ /* add keys */
for (int i = 0; i < totcu; i++) {
if (i < 4)
add_bezt(newcu[i], fra, rot[i]);
@@ -1305,17 +1319,20 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
Main *bmain = CTX_data_main(mContext);
verify_adt_action(bmain, (ID *)&ob->id, 1);
- // add curves
+ /* add curves */
for (int i = 0; i < totcu; i++) {
add_bone_fcurve(ob, node, newcu[i]);
- // fcurve_is_used(newcu[i]); // never added to unused
+#if 0
+ fcurve_is_used(newcu[i]); /* never added to unused */
+#endif
}
bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, bone_name);
chan->rotmode = ROT_MODE_QUAT;
}
-//Check if object is animated by checking if animlist_map holds the animlist_id of node transforms
+/* Check if object is animated by checking if animlist_map
+ * holds the animlist_id of node transforms */
AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
const COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map)
@@ -1324,12 +1341,12 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
const COLLADAFW::TransformationPointerArray &nodeTransforms = node->getTransformations();
- //for each transformation in node
+ /* for each transformation in node */
for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) {
COLLADAFW::Transformation *transform = nodeTransforms[i];
const COLLADAFW::UniqueId &listid = transform->getAnimationList();
- //check if transformation has animations
+ /* check if transformation has animations */
if (animlist_map.find(listid) == animlist_map.end()) {
continue;
}
@@ -1356,7 +1373,7 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
const COLLADAFW::Camera *camera = (COLLADAFW::Camera *)
FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
if (camera == NULL) {
- // Can happen if the node refers to an unknown camera.
+ /* Can happen if the node refers to an unknown camera. */
continue;
}
@@ -1398,7 +1415,9 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
&(efc->getSpecular().getColor()), (types->material), MATERIAL_SPEC_COLOR);
types->material = setAnimType(
&(efc->getDiffuse().getColor()), (types->material), MATERIAL_DIFF_COLOR);
- // types->material = setAnimType(&(efc->get()), (types->material), MATERIAL_TRANSPARENCY);
+#if 0
+ types->material = setAnimType(&(efc->get()), (types->material), MATERIAL_TRANSPARENCY);
+#endif
types->material = setAnimType(
&(efc->getIndexOfRefraction()), (types->material), MATERIAL_IOR);
}
@@ -1420,26 +1439,26 @@ int AnimationImporter::setAnimType(const COLLADAFW::Animatable *prop, int types,
return anim_type;
}
-// Is not used anymore.
+/* Is not used anymore. */
void AnimationImporter::find_frames_old(std::vector<float> *frames,
COLLADAFW::Node *node,
COLLADAFW::Transformation::TransformationType tm_type)
{
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
- // for each <rotate>, <translate>, etc. there is a separate Transformation
+ /* for each <rotate>, <translate>, etc. there is a separate Transformation */
const COLLADAFW::TransformationPointerArray &nodeTransforms = node->getTransformations();
unsigned int i;
- // find frames at which to sample plus convert all rotation keys to radians
+ /* find frames at which to sample plus convert all rotation keys to radians */
for (i = 0; i < nodeTransforms.getCount(); i++) {
COLLADAFW::Transformation *transform = nodeTransforms[i];
COLLADAFW::Transformation::TransformationType nodeTmType = transform->getTransformationType();
if (nodeTmType == tm_type) {
- //get animation bindings for the current transformation
+ /* get animation bindings for the current transformation */
const COLLADAFW::UniqueId &listid = transform->getAnimationList();
- //if transform is animated its animlist must exist.
+ /* if transform is animated its animlist must exist. */
if (animlist_map.find(listid) != animlist_map.end()) {
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
@@ -1447,7 +1466,7 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames,
animlist->getAnimationBindings();
if (bindings.getCount()) {
- //for each AnimationBinding get the fcurves which animate the transform
+ /* for each AnimationBinding get the fcurves which animate the transform */
for (unsigned int j = 0; j < bindings.getCount(); j++) {
std::vector<FCurve *> &curves = curve_map[bindings[j].animation];
bool xyz = ((nodeTmType == COLLADAFW::Transformation::TRANSLATE ||
@@ -1460,14 +1479,14 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames,
for (iter = curves.begin(); iter != curves.end(); iter++) {
FCurve *fcu = *iter;
- //if transform is rotation the fcurves values must be turned in to radian.
+ /* if transform is rotation the fcurves values must be turned in to radian. */
if (is_rotation)
fcurve_deg_to_rad(fcu);
for (unsigned int k = 0; k < fcu->totvert; k++) {
- //get frame value from bezTriple
+ /* get frame value from bezTriple */
float fra = fcu->bezt[k].vec[1][0];
- //if frame already not added add frame to frames
+ /* if frame already not added add frame to frames */
if (std::find(frames->begin(), frames->end(), fra) == frames->end())
frames->push_back(fra);
}
@@ -1483,9 +1502,9 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames,
}
}
-// prerequisites:
-// animlist_map - map animlist id -> animlist
-// curve_map - map anim id -> curve(s)
+/* prerequisites:
+ * animlist_map - map animlist id -> animlist
+ * curve_map - map anim id -> curve(s) */
Object *AnimationImporter::translate_animation_OLD(
COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, Object *> &object_map,
@@ -1509,7 +1528,7 @@ Object *AnimationImporter::translate_animation_OLD(
return NULL;
}
- // frames at which to sample
+ /* frames at which to sample */
std::vector<float> frames;
find_frames_old(&frames, node, tm_type);
@@ -1569,8 +1588,8 @@ Object *AnimationImporter::translate_animation_OLD(
if (is_joint)
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
- // new curves
- FCurve *newcu[10]; // if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale
+ /* new curves */
+ FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale */
unsigned int totcu = is_matrix ? 10 : (is_rotation ? 4 : 3);
for (i = 0; i < totcu; i++) {
@@ -1606,7 +1625,7 @@ Object *AnimationImporter::translate_animation_OLD(
std::vector<float>::iterator it;
- // sample values at each frame
+ /* sample values at each frame */
for (it = frames.begin(); it != frames.end(); it++) {
float fra = *it;
@@ -1615,23 +1634,24 @@ Object *AnimationImporter::translate_animation_OLD(
unit_m4(matfra);
- // calc object-space mat
+ /* calc object-space mat */
evaluate_transform_at_frame(matfra, node, fra);
- // for joints, we need a special matrix
+ /* for joints, we need a special matrix */
if (is_joint) {
- // special matrix: iR * M * iR_dae * R
- // where R, iR are bone rest and inverse rest mats in world space (Blender bones),
- // iR_dae is joint inverse rest matrix (DAE) and M is an evaluated joint world-space matrix (DAE)
+ /* special matrix: iR * M * iR_dae * R
+ * where R, iR are bone rest and inverse rest mats in world space (Blender bones),
+ * iR_dae is joint inverse rest matrix (DAE)
+ * and M is an evaluated joint world-space matrix (DAE). */
float temp[4][4], par[4][4];
- // calc M
+ /* calc M */
calc_joint_parent_mat_rest(par, NULL, root, node);
mul_m4_m4m4(temp, par, matfra);
- // evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
+ /* evaluate_joint_world_transform_at_frame(temp, NULL, node, fra); */
- // calc special matrix
+ /* calc special matrix */
mul_m4_series(mat, irest, temp, irest_dae, rest);
}
else {
@@ -1660,7 +1680,7 @@ Object *AnimationImporter::translate_animation_OLD(
break;
}
- // add keys
+ /* add keys */
for (i = 0; i < totcu; i++) {
if (is_matrix) {
if (i < 4)
@@ -1717,7 +1737,7 @@ Object *AnimationImporter::translate_animation_OLD(
ListBase *curves = &ob->adt->action->curves;
- // add curves
+ /* add curves */
for (i = 0; i < totcu; i++) {
if (is_joint)
add_bone_fcurve(ob, node, newcu[i]);
@@ -1743,9 +1763,9 @@ Object *AnimationImporter::translate_animation_OLD(
return job;
}
-// internal, better make it private
-// warning: evaluates only rotation and only assigns matrix transforms now
-// prerequisites: animlist_map, curve_map
+/* internal, better make it private
+ * warning: evaluates only rotation and only assigns matrix transforms now
+ * prerequisites: animlist_map, curve_map */
void AnimationImporter::evaluate_transform_at_frame(float mat[4][4],
COLLADAFW::Node *node,
float fra)
@@ -1804,7 +1824,7 @@ static void report_class_type_unsupported(const char *path,
}
}
-// return true to indicate that mat contains a sane value
+/* return true to indicate that mat contains a sane value */
bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
float mat[4][4],
float fra,
@@ -1865,7 +1885,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
return false;
}
- // TODO support other animclasses
+ /* TODO support other animclasses */
if (animclass != COLLADAFW::AnimationList::ANGLE) {
report_class_type_unsupported(path, animclass, type);
return false;
@@ -1911,7 +1931,8 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
}
}
else if (type == COLLADAFW::Transformation::MATRIX) {
- // for now, of matrix animation, support only the case when all values are packed into one animation
+ /* for now, of matrix animation,
+ * support only the case when all values are packed into one animation */
if (curves.size() != 16) {
fprintf(stderr, "%s: expected 16 curves, got %d\n", path, (int)curves.size());
return false;
@@ -1945,13 +1966,13 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
return false;
}
-// gives a world-space mat of joint at rest position
+/* gives a world-space mat of joint at rest position */
void AnimationImporter::get_joint_rest_mat(float mat[4][4],
COLLADAFW::Node *root,
COLLADAFW::Node *node)
{
- // if bind mat is not available,
- // use "current" node transform, i.e. all those tms listed inside <node>
+ /* if bind mat is not available,
+ * use "current" node transform, i.e. all those tms listed inside <node> */
if (!armature_importer->get_joint_bind_mat(mat, node)) {
float par[4][4], m[4][4];
@@ -1961,7 +1982,7 @@ void AnimationImporter::get_joint_rest_mat(float mat[4][4],
}
}
-// gives a world-space mat, end's mat not included
+/* gives a world-space mat, end's mat not included */
bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4],
float par[4][4],
COLLADAFW::Node *node,
@@ -1974,7 +1995,7 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4],
return true;
}
- // use bind matrix if available or calc "current" world mat
+ /* use bind matrix if available or calc "current" world mat */
if (!armature_importer->get_joint_bind_mat(m, node)) {
if (par) {
float temp[4][4];
@@ -2033,7 +2054,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root,
BKE_object_where_is_calc(scene, job);
- // after parenting and layer change
+ /* after parenting and layer change */
DEG_relations_tag_update(CTX_data_main(C));
joint_objects[node->getUniqueId()] = job;
@@ -2044,8 +2065,8 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root,
#endif
#if 0
-// recursively evaluates joint tree until end is found, mat then is world-space matrix of end
-// mat must be identity on enter, node must be root
+/* recursively evaluates joint tree until end is found,
+ * mat then is world-space matrix of end mat must be identity on enter, node must be root. */
bool AnimationImporter::evaluate_joint_world_transform_at_frame(
float mat[4][4], float par[4][4], COLLADAFW::Node *node, COLLADAFW::Node *end, float fra)
{
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index 0b84f844dbf..be50b255f13 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -246,7 +246,7 @@ void ArmatureExporter::add_bone_node(Bone *bone,
void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node &node)
{
- //bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name);
+ // bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name);
float mat[4][4];
float bone_rest_mat[4][4]; /* derived from bone->arm_mat */
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index 70ee3274d14..1c540b6cdaa 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -39,7 +39,7 @@ extern "C" {
#include "collada_utils.h"
#include "ArmatureImporter.h"
-// use node name, or fall back to original id if not present (name is optional)
+/* use node name, or fall back to original id if not present (name is optional) */
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
@@ -65,7 +65,7 @@ ArmatureImporter::ArmatureImporter(UnitConverter *conv,
ArmatureImporter::~ArmatureImporter()
{
- // free skin controller data if we forget to do this earlier
+ /* free skin controller data if we forget to do this earlier */
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator it;
for (it = skin_by_data_uid.begin(); it != skin_by_data_uid.end(); it++) {
it->second.free();
@@ -102,7 +102,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
float joint_bind_mat[4][4];
int chain_length = 0;
- //Checking if bone is already made.
+ /* Checking if bone is already made. */
std::vector<COLLADAFW::Node *>::iterator it;
it = std::find(finished_joints.begin(), finished_joints.end(), node);
if (it != finished_joints.end())
@@ -122,10 +122,10 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
SkinInfo *b = &skin_it->second;
if (b->get_joint_inv_bind_matrix(joint_inv_bind_mat, node)) {
- // get original world-space matrix
+ /* get original world-space matrix */
invert_m4_m4(mat, joint_inv_bind_mat);
copy_m4_m4(joint_bind_mat, mat);
- // And make local to armature
+ /* And make local to armature */
Object *ob_arm = skin->BKE_armature_from_object();
if (ob_arm) {
float invmat[4][4];
@@ -138,7 +138,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
}
}
- // create a bone even if there's no joint data for it (i.e. it has no influence)
+ /* create a bone even if there's no joint data for it (i.e. it has no influence) */
if (!bone_is_skinned) {
get_node_mat(mat, node, NULL, NULL, parent_mat);
}
@@ -185,7 +185,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
bc_set_IDPropertyMatrix(bone, "rest_mat", rest_mat);
}
- add_v3_v3v3(bone->tail, bone->head, tail); //tail must be non zero
+ add_v3_v3v3(bone->tail, bone->head, tail); /* tail must be non zero */
/* find smallest bone length in armature (used later for leaf bone length) */
if (parent) {
@@ -385,7 +385,7 @@ void ArmatureImporter::set_leaf_bone_shapes(Object *ob_arm)
void ArmatureImporter::set_euler_rotmode()
{
- // just set rotmode = ROT_MODE_EUL on pose channel for each joint
+ /* just set rotmode = ROT_MODE_EUL on pose channel for each joint */
std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>::iterator it;
@@ -445,14 +445,14 @@ Object *ArmatureImporter::find_armature(COLLADAFW::Node *node)
ArmatureJoints &ArmatureImporter::get_armature_joints(Object *ob_arm)
{
- // try finding it
+ /* try finding it */
std::vector<ArmatureJoints>::iterator it;
for (it = armature_joints.begin(); it != armature_joints.end(); it++) {
if ((*it).ob_arm == ob_arm)
return *it;
}
- // not found, create one
+ /* not found, create one */
ArmatureJoints aj;
aj.ob_arm = ob_arm;
armature_joints.push_back(aj);
@@ -465,7 +465,7 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *>
std::vector<COLLADAFW::Node *>::iterator ri;
std::vector<std::string> layer_labels;
- //if there is an armature created for root_joint next root_joint
+ /* if there is an armature created for root_joint next root_joint */
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
if (get_armature_for_joint(*ri) != NULL)
continue;
@@ -519,12 +519,12 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *>
Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
{
- // just do like so:
- // - get armature
- // - enter editmode
- // - add edit bones and head/tail properties using matrices and parent-child info
- // - exit edit mode
- // - set a sphere shape to leaf bones
+ /* just do like so:
+ * - get armature
+ * - enter editmode
+ * - add edit bones and head/tail properties using matrices and parent-child info
+ * - exit edit mode
+ * - set a sphere shape to leaf bones */
Object *ob_arm = NULL;
@@ -543,8 +543,8 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
* for each root in root_joints:
* for each joint in joints:
* if find_node_in_tree(joint, root):
- * if (std::find(root_joints.begin(), root_joints.end(), root) == root_joints.end())
- * root_joints.push_back(root);
+ * if (std::find(root_joints.begin(), root_joints.end(), root) ==
+ * root_joints.end()) root_joints.push_back(root);
*
* for (each skin B with armature) {
* find all root joints for skin B
@@ -588,13 +588,13 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
}
if (!shared && this->joint_parent_map.size() > 0) {
- // All armatures have been created while creating the Node tree.
- // The Collada exporter currently does not create a
- // strict relationship between geometries and armatures
- // So when we reimport a Blender collada file, then we have
- // to guess what is meant.
- // XXX This is not safe when we have more than one armatures
- // in the import.
+ /* All armatures have been created while creating the Node tree.
+ * The Collada exporter currently does not create a
+ * strict relationship between geometries and armatures
+ * So when we reimport a Blender collada file, then we have
+ * to guess what is meant.
+ * XXX This is not safe when we have more than one armatures
+ * in the import. */
shared = this->joint_parent_map.begin()->second;
}
@@ -602,28 +602,29 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
ob_arm = skin.set_armature(shared);
}
else {
- ob_arm = skin.create_armature(m_bmain, scene, view_layer); //once for every armature
+ ob_arm = skin.create_armature(m_bmain, scene, view_layer); // once for every armature
}
- // enter armature edit mode
+ /* enter armature edit mode */
bArmature *armature = (bArmature *)ob_arm->data;
ED_armature_to_edit(armature);
totbone = 0;
- // bone_direction_row = 1; // TODO: don't default to Y but use asset and based on it decide on default row
+ // bone_direction_row = 1; // TODO: don't default to Y but use asset and based on it decide on
+ /* default row */
- // create bones
+ /* create bones */
/* TODO:
* check if bones have already been created for a given joint */
std::vector<COLLADAFW::Node *>::iterator ri;
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
- // for shared armature check if bone tree is already created
+ /* for shared armature check if bone tree is already created */
if (shared &&
std::find(skin_root_joints.begin(), skin_root_joints.end(), *ri) != skin_root_joints.end())
continue;
- // since root_joints may contain joints for multiple controllers, we need to filter
+ /* since root_joints may contain joints for multiple controllers, we need to filter */
if (skin.uses_joint_or_descendant(*ri)) {
create_bone(
@@ -662,14 +663,14 @@ void ArmatureImporter::set_pose(Object *ob_arm,
float mat[4][4];
float obmat[4][4];
- // object-space
+ /* object-space */
get_node_mat(obmat, root_node, NULL, NULL);
- //if (*edbone)
+ // if (*edbone)
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone_name);
- //else fprintf ( "",
+ // else fprintf ( "",
- // get world-space
+ /* get world-space */
if (parentname) {
mul_m4_m4m4(mat, parent_mat, obmat);
bPoseChannel *parchan = BKE_pose_channel_find_name(ob_arm->pose, parentname);
@@ -725,7 +726,7 @@ void ArmatureImporter::add_root_joint(COLLADAFW::Node *node)
}
#endif
-// here we add bones to armatures, having armatures previously created in write_controller
+/* here we add bones to armatures, having armatures previously created in write_controller */
void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &objects_to_scale)
{
Main *bmain = CTX_data_main(C);
@@ -741,7 +742,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
Object *ob_arm = create_armature_bones(bmain, skin);
- // link armature with a mesh object
+ /* link armature with a mesh object */
const COLLADAFW::UniqueId &uid = skin.get_controller_uid();
const COLLADAFW::UniqueId *guid = get_geometry_uid(uid);
if (guid != NULL) {
@@ -772,19 +773,19 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
else
fprintf(stderr, "Cannot find geometry to link armature with.\n");
- // set armature parent if any
+ /* set armature parent if any */
Object *par = skin.get_parent();
if (par)
bc_set_parent(skin.BKE_armature_from_object(), par, C, false);
- // free memory stolen from SkinControllerData
+ /* free memory stolen from SkinControllerData */
skin.free();
}
- //for bones without skins
+ /* for bones without skins */
create_armature_bones(bmain, ob_arms);
- // Fix bone relations
+ /* Fix bone relations */
std::vector<Object *>::iterator ob_arm_it;
for (ob_arm_it = ob_arms.begin(); ob_arm_it != ob_arms.end(); ob_arm_it++) {
@@ -802,7 +803,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
}
#if 0
-// link with meshes, create vertex groups, assign weights
+/* link with meshes, create vertex groups, assign weights */
void ArmatureImporter::link_armature(Object *ob_arm,
const COLLADAFW::UniqueId &geom_id,
const COLLADAFW::UniqueId &controller_data_id)
@@ -821,25 +822,25 @@ void ArmatureImporter::link_armature(Object *ob_arm,
SkinInfo &skin = skin_by_data_uid[conroller_data_id];
- // create vertex groups
+ /* create vertex groups */
}
#endif
bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControllerData *data)
{
- // at this stage we get vertex influence info that should go into me->verts and ob->defbase
- // there's no info to which object this should be long so we associate it with skin controller data UID
+ /* at this stage we get vertex influence info that should go into me->verts and ob->defbase
+ * there's no info to which object this should be long so we associate it with
+ * skin controller data UID. */
- // don't forget to call defgroup_unique_name before we copy
+ /* don't forget to call defgroup_unique_name before we copy */
- // controller data uid -> [armature] -> joint data,
- // [mesh object]
- //
+ /* controller data uid -> [armature] -> joint data,
+ * [mesh object] */
SkinInfo skin(unit_converter);
skin.borrow_skin_controller_data(data);
- // store join inv bind matrix to use it later in armature construction
+ /* store join inv bind matrix to use it later in armature construction */
const COLLADAFW::Matrix4Array &inv_bind_mats = data->getInverseBindMatrices();
for (unsigned int i = 0; i < data->getJointsCount(); i++) {
skin.add_joint(inv_bind_mats[i]);
@@ -852,12 +853,12 @@ bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControlle
bool ArmatureImporter::write_controller(const COLLADAFW::Controller *controller)
{
- // - create and store armature object
+ /* - create and store armature object */
const COLLADAFW::UniqueId &con_id = controller->getUniqueId();
if (controller->getControllerType() == COLLADAFW::Controller::CONTROLLER_TYPE_SKIN) {
COLLADAFW::SkinController *co = (COLLADAFW::SkinController *)controller;
- // to be able to find geom id by controller id
+ /* to be able to find geom id by controller id */
geom_uid_by_controller_uid[con_id] = co->getSource();
const COLLADAFW::UniqueId &data_uid = co->getSkinControllerData();
@@ -868,12 +869,12 @@ bool ArmatureImporter::write_controller(const COLLADAFW::Controller *controller)
skin_by_data_uid[data_uid].set_controller(co);
}
- // morph controller
+ /* morph controller */
else if (controller->getControllerType() == COLLADAFW::Controller::CONTROLLER_TYPE_MORPH) {
COLLADAFW::MorphController *co = (COLLADAFW::MorphController *)controller;
- // to be able to find geom id by controller id
+ /* to be able to find geom id by controller id */
geom_uid_by_controller_uid[con_id] = co->getSource();
- //Shape keys are applied in DocumentImporter->finish()
+ /* Shape keys are applied in DocumentImporter->finish() */
morph_controllers.push_back(co);
}
@@ -887,29 +888,29 @@ void ArmatureImporter::make_shape_keys(bContext *C)
float weight;
for (mc = morph_controllers.begin(); mc != morph_controllers.end(); mc++) {
- //Controller data
+ /* Controller data */
COLLADAFW::UniqueIdArray &morphTargetIds = (*mc)->getMorphTargets();
COLLADAFW::FloatOrDoubleArray &morphWeights = (*mc)->getMorphWeights();
- //Prereq: all the geometries must be imported and mesh objects must be made
+ /* Prereq: all the geometries must be imported and mesh objects must be made */
Object *source_ob = this->mesh_importer->get_object_by_geom_uid((*mc)->getSource());
if (source_ob) {
Mesh *source_me = (Mesh *)source_ob->data;
- //insert key to source mesh
+ /* insert key to source mesh */
Key *key = source_me->key = BKE_key_add(bmain, (ID *)source_me);
key->type = KEY_RELATIVE;
KeyBlock *kb;
- //insert basis key
+ /* insert basis key */
kb = BKE_keyblock_add_ctime(key, "Basis", false);
BKE_keyblock_convert_from_mesh(source_me, key, kb);
- //insert other shape keys
+ /* insert other shape keys */
for (int i = 0; i < morphTargetIds.getCount(); i++) {
- //better to have a separate map of morph objects,
- //This'll do for now since only mesh morphing is imported
+ /* better to have a separate map of morph objects,
+ * This'll do for now since only mesh morphing is imported */
Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]);
@@ -920,7 +921,7 @@ void ArmatureImporter::make_shape_keys(bContext *C)
kb = BKE_keyblock_add_ctime(key, morph_name.c_str(), false);
BKE_keyblock_convert_from_mesh(me, key, kb);
- //apply weights
+ /* apply weights */
weight = morphWeights.getFloatValues()->getData()[i];
kb->curval = weight;
}
@@ -973,7 +974,7 @@ void ArmatureImporter::get_rna_path_for_joint(COLLADAFW::Node *node,
BLI_snprintf(joint_path, count, "pose.bones[\"%s\"]", bc_get_joint_name(node));
}
-// gives a world-space mat
+/* gives a world-space mat */
bool ArmatureImporter::get_joint_bind_mat(float m[4][4], COLLADAFW::Node *joint)
{
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator it;
diff --git a/source/blender/collada/BCAnimationCurve.cpp b/source/blender/collada/BCAnimationCurve.cpp
index 90da5907c6f..3f46d43840c 100644
--- a/source/blender/collada/BCAnimationCurve.cpp
+++ b/source/blender/collada/BCAnimationCurve.cpp
@@ -118,7 +118,7 @@ void BCAnimationCurve::create_bezt(float frame, float output)
BCAnimationCurve::~BCAnimationCurve()
{
if (curve_is_local_copy && fcurve) {
- //fprintf(stderr, "removed fcurve %s\n", fcurve->rna_path);
+ // fprintf(stderr, "removed fcurve %s\n", fcurve->rna_path);
delete_fcurve(fcurve);
this->fcurve = NULL;
}
@@ -637,7 +637,8 @@ void BCBezTriple::get_tangent(Scene *scene, float point[2], bool as_angle, int i
{
point[0] = FRA2TIME(bezt.vec[index][0]);
if (bezt.ipo != BEZT_IPO_BEZ) {
- /* We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data */
+ /* We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain
+ * unused data */
point[0] = 0;
point[1] = 0;
}
diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt
index d104d01af56..e54b788903d 100644
--- a/source/blender/collada/CMakeLists.txt
+++ b/source/blender/collada/CMakeLists.txt
@@ -41,10 +41,10 @@ set(INC
../blentranslation
../depsgraph
../editors/include
+ ../imbuf
../makesdna
../makesrna
../windowmanager
- ../imbuf
../../../intern/guardedalloc
../ikplugin
../../../intern/iksolver/extern
diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp
index 0c9ca400dd2..c79a4e1a1f7 100644
--- a/source/blender/collada/ControllerExporter.cpp
+++ b/source/blender/collada/ControllerExporter.cpp
@@ -82,7 +82,7 @@ bool ControllerExporter::add_instance_controller(Object *ob)
if (!me->dvert)
return false;
- // write root bone URLs
+ /* write root bone URLs */
Bone *bone;
for (bone = (Bone *)arm->bonebase.first; bone; bone = bone->next) {
write_bone_URLs(ins, ob_arm, bone);
@@ -162,17 +162,17 @@ std::string ControllerExporter::get_controller_id(Key *key, Object *ob)
return translate_id(id_name(ob)) + MORPH_CONTROLLER_ID_SUFFIX;
}
-// ob should be of type OB_MESH
-// both args are required
+/* ob should be of type OB_MESH
+ * both args are required */
void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
{
- // joint names
- // joint inverse bind matrices
- // vertex weights
+ /* joint names
+ * joint inverse bind matrices
+ * vertex weights */
- // input:
- // joint names: ob -> vertex group names
- // vertex group weights: me->dvert -> groups -> index, weight
+ /* input:
+ * joint names: ob -> vertex group names
+ * vertex group weights: me->dvert -> groups -> index, weight */
#if 0
me->dvert :
@@ -222,7 +222,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
{
int i, j;
- // def group index -> joint index
+ /* def group index -> joint index */
std::vector<int> joint_index_by_def_index;
bDeformGroup *def;
@@ -238,14 +238,14 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
MDeformVert *vert = &me->dvert[i];
std::map<int, float> jw;
- // We're normalizing the weights later
+ /* We're normalizing the weights later */
float sumw = 0.0f;
for (j = 0; j < vert->totweight; j++) {
int idx = vert->dw[j].def_nr;
if (idx >= joint_index_by_def_index.size()) {
- // XXX: Maybe better find out where and
- // why the Out Of Bound indexes get created ?
+ /* XXX: Maybe better find out where and
+ * why the Out Of Bound indexes get created ? */
oob_counter += 1;
}
else {
@@ -331,8 +331,8 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key)
BKE_id_free(NULL, me);
- //support for animations
- //can also try the base element and param alternative
+ /* support for animations
+ * can also try the base element and param alternative */
add_weight_extras(key);
closeMorph();
closeController();
@@ -354,7 +354,7 @@ std::string ControllerExporter::add_morph_targets(Key *key, Object *ob)
source.prepareToAppendValues();
KeyBlock *kb = (KeyBlock *)key->block.first;
- //skip the basis
+ /* skip the basis */
kb = kb->next;
for (; kb; kb = kb->next) {
std::string geom_id = get_geometry_id(ob, false) + "_morph_" + translate_id(kb->name);
@@ -382,7 +382,7 @@ std::string ControllerExporter::add_morph_weights(Key *key, Object *ob)
source.prepareToAppendValues();
KeyBlock *kb = (KeyBlock *)key->block.first;
- //skip the basis
+ /* skip the basis */
kb = kb->next;
for (; kb; kb = kb->next) {
float weight = kb->curval;
@@ -393,18 +393,18 @@ std::string ControllerExporter::add_morph_weights(Key *key, Object *ob)
return source_id;
}
-//Added to implement support for animations.
+/* Added to implement support for animations. */
void ControllerExporter::add_weight_extras(Key *key)
{
- // can also try the base element and param alternative
+ /* can also try the base element and param alternative */
COLLADASW::BaseExtraTechnique extra;
KeyBlock *kb = (KeyBlock *)key->block.first;
- //skip the basis
+ /* skip the basis */
kb = kb->next;
for (; kb; kb = kb->next) {
- // XXX why is the weight not used here and set to 0.0?
- // float weight = kb->curval;
+ /* XXX why is the weight not used here and set to 0.0?
+ * float weight = kb->curval; */
extra.addExtraTechniqueParameter("KHR", "morph_weights", 0.000, "MORPH_WEIGHT_TO_TARGET");
}
}
@@ -431,7 +431,7 @@ void ControllerExporter::add_bind_shape_mat(Object *ob)
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, ob->obmat);
UnitConverter::mat4_to_dae_double(bind_mat, f_obmat);
if (this->export_settings->limit_precision)
bc_sanitize_mat(bind_mat, LIMITTED_PRECISION);
@@ -489,7 +489,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
COLLADASW::FloatSourceF source(mSW);
source.setId(source_id);
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
- source.setAccessorCount(totjoint); //BLI_listbase_count(defbase));
+ source.setAccessorCount(totjoint); // BLI_listbase_count(defbase));
source.setAccessorStride(16);
source.setParameterTypeName(&COLLADASW::CSWC::CSW_VALUE_TYPE_FLOAT4x4);
@@ -503,7 +503,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
int flag = arm->flag;
- // put armature in rest position
+ /* put armature in rest position */
if (!(arm->flag & ARM_RESTPOS)) {
Depsgraph *depsgraph = blender_context.get_depsgraph();
Scene *scene = blender_context.get_scene();
@@ -531,7 +531,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
bc_create_restpose_mat(
this->export_settings, pchan->bone, bind_mat, pchan->bone->arm_mat, true);
- // SL/OPEN_SIM COMPATIBILITY
+ /* SL/OPEN_SIM COMPATIBILITY */
if (export_settings->open_sim) {
float loc[3];
@@ -539,12 +539,12 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
float scale[3];
bc_decompose(bind_mat, loc, NULL, NULL, scale);
- // Only translations, no rotation vs armature
+ /* Only translations, no rotation vs armature */
loc_eulO_size_to_mat4(bind_mat, loc, rot, scale, 6);
}
}
- // make world-space matrix (bind_mat is armature-space)
+ /* make world-space matrix (bind_mat is armature-space) */
mul_m4_m4m4(world, ob_arm->obmat, bind_mat);
invert_m4_m4(mat, world);
@@ -555,7 +555,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
}
}
- // back from rest position
+ /* back from rest position */
if (!(flag & ARM_RESTPOS)) {
Depsgraph *depsgraph = blender_context.get_depsgraph();
Scene *scene = blender_context.get_scene();
@@ -625,7 +625,7 @@ void ControllerExporter::add_vertex_weights_element(const std::string &weights_s
weightselem.setCount(vcounts.size());
- // write number of deformers per vertex
+ /* write number of deformers per vertex */
COLLADASW::PrimitivesBase::VCountList vcountlist;
vcountlist.resize(vcounts.size());
@@ -636,7 +636,7 @@ void ControllerExporter::add_vertex_weights_element(const std::string &weights_s
weightselem.CloseVCountAndOpenVElement();
- // write deformer index - weight index pairs
+ /* write deformer index - weight index pairs */
int weight_index = 0;
for (std::list<int>::const_iterator i = joints.begin(); i != joints.end(); ++i) {
weightselem.appendValues(*i, weight_index++);
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index 71c0d6c155e..c8202eb3cf6 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -198,7 +198,7 @@ int DocumentExporter::exportCurrentScene()
RNA_id_pointer_create(&(sce->id), &sceneptr);
unit_settings = RNA_pointer_get(&sceneptr, "unit_settings");
system = RNA_struct_find_property(&unit_settings, "system");
- //scale = RNA_struct_find_property(&unit_settings, "scale_length");
+ // scale = RNA_struct_find_property(&unit_settings, "scale_length");
std::string unitname = "meter";
float linearmeasure = RNA_float_get(&unit_settings, "scale_length");
@@ -338,5 +338,6 @@ void DocumentExporter::exportScenes(const char *filename)
/*
* NOTES:
*
- * AnimationExporter::sample_animation enables all curves on armature, this is undesirable for a user
+ * AnimationExporter::sample_animation enables all curves on armature, this is undesirable for a
+ * user
*/
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 567f215ac04..91dda6955ef 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -18,9 +18,9 @@
* \ingroup collada
*/
-// TODO:
-// * name imported objects
-// * import object rotation as euler
+/* TODO:
+ * * name imported objects
+ * * import object rotation as euler */
#include <string>
#include <map>
@@ -131,7 +131,7 @@ bool DocumentImporter::import()
loader.registerExtraDataCallbackHandler(ehandler);
- // deselect all to select new objects
+ /* deselect all to select new objects */
BKE_view_layer_base_deselect_all(view_layer);
std::string mFilename = std::string(this->import_settings->filepath);
@@ -165,12 +165,12 @@ bool DocumentImporter::import()
void DocumentImporter::cancel(const COLLADAFW::String &errorMessage)
{
- // TODO: if possible show error info
- //
- // Should we get rid of invisible Meshes that were created so far
- // or maybe create objects at coordinate space origin?
- //
- // The latter sounds better.
+ /* TODO: if possible show error info
+ *
+ * Should we get rid of invisible Meshes that were created so far
+ * or maybe create objects at coordinate space origin?
+ *
+ * The latter sounds better. */
}
void DocumentImporter::start()
@@ -183,7 +183,8 @@ void DocumentImporter::finish()
return;
Main *bmain = CTX_data_main(mContext);
- // TODO: create a new scene except the selected <visual_scene> - use current blender scene for it
+ /* TODO: create a new scene except the selected <visual_scene> -
+ * use current blender scene for it */
Scene *sce = CTX_data_scene(mContext);
unit_converter.calculate_scale(*sce);
@@ -195,7 +196,7 @@ void DocumentImporter::finish()
PointerRNA sceneptr, unit_settings;
PropertyRNA *system, *scale;
- // for scene unit settings: system, scale_length
+ /* for scene unit settings: system, scale_length */
RNA_id_pointer_create(&sce->id, &sceneptr);
unit_settings = RNA_pointer_get(&sceneptr, "unit_settings");
@@ -220,7 +221,7 @@ void DocumentImporter::finish()
fprintf(stdout, "Collada: Adjusting Blender units to Importset units: %f.\n", unit_factor);
}
- // Write nodes to scene
+ /* Write nodes to scene */
fprintf(stderr, "+-- Import Scene --------\n");
const COLLADAFW::NodePointerArray &roots = (*sit)->getRootNodes();
for (unsigned int i = 0; i < roots.getCount(); i++) {
@@ -254,7 +255,7 @@ void DocumentImporter::finish()
if (libnode_ob.size()) {
fprintf(stderr, "| Cleanup: free %d library nodes\n", (int)libnode_ob.size());
- // free all library_nodes
+ /* free all library_nodes */
std::vector<Object *>::iterator it;
for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) {
Object *ob = *it;
@@ -267,7 +268,7 @@ void DocumentImporter::finish()
delete objects_to_scale;
- // update scene
+ /* update scene */
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);
@@ -277,15 +278,15 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node,
COLLADAFW::Node *par = NULL,
Object *parob = NULL)
{
- // The split in #29246, rootmap must point at actual root when
- // calculating bones in apply_curves_as_matrix. - actual root is the root node.
- // This has to do with inverse bind poses being world space
- // (the sources for skinned bones' restposes) and the way
- // non-skinning nodes have their "restpose" recursively calculated.
- // XXX TODO: design issue, how to support unrelated joints taking
- // part in skinning.
+ /* The split in #29246, rootmap must point at actual root when
+ * calculating bones in apply_curves_as_matrix. - actual root is the root node.
+ * This has to do with inverse bind poses being world space
+ * (the sources for skinned bones' restposes) and the way
+ * non-skinning nodes have their "restpose" recursively calculated.
+ * XXX TODO: design issue, how to support unrelated joints taking
+ * part in skinning. */
if (par) { // && par->getType() == COLLADAFW::Node::JOINT) {
- // par is root if there's no corresp. key in root_map
+ /* par is root if there's no corresp. key in root_map */
if (root_map.find(par->getUniqueId()) == root_map.end())
root_map[node->getUniqueId()] = node;
else
@@ -305,9 +306,9 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node,
unsigned int i;
if (node->getType() == COLLADAFW::Node::JOINT && par == NULL) {
- // For Skeletons without root node we have to simulate the
- // root node here and recursively enter the same function
- // XXX: maybe this can be made more elegant.
+ /* For Skeletons without root node we have to simulate the
+ * root node here and recursively enter the same function
+ * XXX: maybe this can be made more elegant. */
translate_anim_recursive(node, node, parob);
}
else {
@@ -335,7 +336,7 @@ std::string DocumentImporter::get_import_version(const COLLADAFW::FileInfo *asse
const COLLADAFW::String &value = valuePair->second;
if (key == AUTORING_TOOL) {
if (value.compare(0, BLENDER.length(), BLENDER) == 0) {
- // Was made with Blender, now get version string
+ /* Was made with Blender, now get version string */
std::string v = value.substr(BLENDER.length());
std::string::size_type n = v.find(" ");
if (n > 0) {
@@ -361,7 +362,7 @@ bool DocumentImporter::writeGlobalAsset(const COLLADAFW::FileInfo *asset)
* \return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeScene(const COLLADAFW::Scene *scene)
{
- // XXX could store the scene id, but do nothing for now
+ /* XXX could store the scene id, but do nothing for now */
return true;
}
Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene *sce)
@@ -404,7 +405,9 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
Scene *sce,
bool is_library_node)
{
- //fprintf(stderr, "create <instance_node> under node id=%s from node id=%s\n", instance_node ? instance_node->getOriginalId().c_str() : NULL, source_node ? source_node->getOriginalId().c_str() : NULL);
+ // fprintf(stderr, "create <instance_node> under node id=%s from node id=%s\n", instance_node ?
+ // instance_node->getOriginalId().c_str() : NULL, source_node ?
+ // source_node->getOriginalId().c_str() : NULL);
Main *bmain = CTX_data_main(mContext);
Object *obn = BKE_object_copy(bmain, source_ob);
@@ -413,10 +416,10 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
if (instance_node) {
anim_importer.read_node_transform(instance_node, obn);
- // if we also have a source_node (always ;), take its
- // transformation matrix and apply it to the newly instantiated
- // object to account for node hierarchy transforms in
- // .dae
+ /* if we also have a source_node (always ;), take its
+ * transformation matrix and apply it to the newly instantiated
+ * object to account for node hierarchy transforms in
+ * .dae */
if (source_node) {
COLLADABU::Math::Matrix4 mat4 = source_node->getTransformationMatrix();
COLLADABU::Math::Matrix4 bmat4 =
@@ -427,7 +430,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
mat[i][j] = bmat4[i][j];
}
}
- // calc new matrix and apply
+ /* calc new matrix and apply */
mul_m4_m4m4(obn->obmat, obn->obmat, mat);
BKE_object_apply_mat4(obn, obn->obmat, 0, 0);
}
@@ -467,8 +470,8 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
return obn;
}
-// to create constraints off node <extra> tags. Assumes only constraint data in
-// current <extra> with blender profile.
+/* to create constraints off node <extra> tags. Assumes only constraint data in
+ * current <extra> with blender profile. */
void DocumentImporter::create_constraints(ExtraTags *et, Object *ob)
{
if (et && et->isProfile("blender")) {
@@ -504,7 +507,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
std::string id = node->getOriginalId();
std::string name = node->getName();
- // if node has child nodes write them
+ /* if node has child nodes write them */
COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes();
std::vector<Object *> *objects_done = new std::vector<Object *>();
@@ -515,8 +518,8 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
if (is_joint) {
if (parent_node == NULL && !is_library_node) {
- // A Joint on root level is a skeleton without root node.
- // Here we add the armature "on the fly":
+ /* A Joint on root level is a skeleton without root node.
+ * Here we add the armature "on the fly": */
par = bc_add_object(bmain, sce, view_layer, OB_ARMATURE, std::string("Armature").c_str());
objects_done->push_back(par);
root_objects->push_back(par);
@@ -528,8 +531,8 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
if (parent_node == NULL) {
- // for skeletons without root node all has been done above.
- // Skeletons with root node are handled further down.
+ /* for skeletons without root node all has been done above.
+ * Skeletons with root node are handled further down. */
goto finally;
}
}
@@ -545,9 +548,9 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
size_t controller_done = 0;
size_t inst_done = 0;
- // XXX linking object with the first <instance_geometry>, though a node may have more of them...
- // maybe join multiple <instance_...> meshes into 1, and link object with it? not sure...
- // <instance_geometry>
+ /* XXX linking object with the first <instance_geometry>, though a node may have more of
+ * them... maybe join multiple <instance_...> meshes into 1, and link object with it? not
+ * sure... <instance_geometry> */
while (geom_done < geom.getCount()) {
ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map);
if (ob == NULL) {
@@ -602,7 +605,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
++controller_done;
}
- // XXX instance_node is not supported yet
+ /* XXX instance_node is not supported yet */
while (inst_done < inst_node.getCount()) {
const COLLADAFW::UniqueId &node_id = inst_node[inst_done]->getInstanciatedObjectId();
if (object_map.find(node_id) == object_map.end()) {
@@ -632,10 +635,10 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
read_transform = false;
}
- // if node is empty - create empty object
- // XXX empty node may not mean it is empty object, not sure about this
+ /* if node is empty - create empty object
+ * XXX empty node may not mean it is empty object, not sure about this */
if ((geom_done + camera_done + lamp_done + controller_done + inst_done) < 1) {
- //Check if Object is armature, by checking if immediate child is a JOINT node.
+ /* Check if Object is armature, by checking if immediate child is a JOINT node. */
if (is_armature(node)) {
ob = bc_add_object(bmain, sce, view_layer, OB_ARMATURE, name.c_str());
}
@@ -648,7 +651,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
}
- // XXX: if there're multiple instances, only one is stored
+ /* XXX: if there're multiple instances, only one is stored */
if (!ob) {
goto finally;
@@ -666,7 +669,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
libnode_ob.push_back(ob);
}
- //create_constraints(et,ob);
+ // create_constraints(et,ob);
}
for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end();
@@ -682,7 +685,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
ob->partype = PAROBJECT;
ob->parsubstr[0] = 0;
- //bc_set_parent(ob, par, mContext, false);
+ // bc_set_parent(ob, par, mContext, false);
}
}
}
@@ -715,16 +718,17 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen
if (mImportStage == Fetching_Controller_data)
return true;
- // this method called on post process after writeGeometry, writeMaterial, etc.
-
- // for each <node> in <visual_scene>:
- // create an Object
- // if Mesh (previously created in writeGeometry) to which <node> corresponds exists, link Object with that mesh
-
- // update: since we cannot link a Mesh with Object in
- // writeGeometry because <geometry> does not reference <node>,
- // we link Objects with Meshes here
-
+ /* This method called on post process after writeGeometry, writeMaterial, etc. */
+
+ /* For each <node> in <visual_scene>:
+ * create an Object
+ * if Mesh (previously created in writeGeometry) to which <node> corresponds exists,
+ * link Object with that mesh.
+ *
+ * Update: since we cannot link a Mesh with Object in
+ * writeGeometry because <geometry> does not reference <node>,
+ * we link Objects with Meshes here.
+ */
vscenes.push_back(visualScene);
return true;
@@ -819,8 +823,8 @@ bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
fprintf(stderr, "Couldn't find <profile_COMMON>.\n");
return true;
}
- // XXX TODO: Take all <profile_common>s
- // Currently only first <profile_common> is supported
+ /* XXX TODO: Take all <profile_common>s
+ * Currently only first <profile_common> is supported */
COLLADAFW::EffectCommon *ef = common_efs[0];
write_profile_COMMON(ef, ma);
this->FW_object_map[effect->getUniqueId()] = effect;
@@ -888,7 +892,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
double yfov = camera->getYFov().getValue();
double aspect = camera->getAspectRatio().getValue();
- // NOTE: Needs more testing (As we curretnly have no official test data for this)
+ /* NOTE: Needs more testing (As we curretnly have no official test data for this) */
double xfov = 2.0f * atanf(aspect * tanf(DEG2RADF(yfov) * 0.5f));
cam->lens = fov_to_focallength(xfov, cam->sensor_x);
@@ -907,7 +911,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
case CAM_PERSP:
default: {
double x = camera->getXFov().getValue();
- // x is in degrees, cam->lens is in millimiters
+ /* x is in degrees, cam->lens is in millimiters */
cam->lens = fov_to_focallength(DEG2RADF(x), cam->sensor_x);
} break;
}
@@ -920,19 +924,19 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
case CAM_PERSP:
default: {
double yfov = camera->getYFov().getValue();
- // yfov is in degrees, cam->lens is in millimiters
+ /* yfov is in degrees, cam->lens is in millimiters */
cam->lens = fov_to_focallength(DEG2RADF(yfov), cam->sensor_x);
} break;
}
} break;
case COLLADAFW::Camera::UNDEFINED:
- // read nothing, use blender defaults.
+ /* read nothing, use blender defaults. */
break;
}
this->uid_camera_map[camera->getUniqueId()] = cam;
this->FW_object_map[camera->getUniqueId()] = camera;
- // XXX import camera options
+ /* XXX import camera options */
return true;
}
@@ -955,7 +959,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
workpath = absolute_path;
}
else {
- // Maybe imagepath was already absolute ?
+ /* Maybe imagepath was already absolute ? */
if (!BLI_exists(imagepath.c_str())) {
fprintf(stderr, "|! Image not found: %s\n", imagepath.c_str());
return true;
@@ -1006,7 +1010,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
return true;
}
- // if we find an ExtraTags for this, use that instead.
+ /* if we find an ExtraTags for this, use that instead. */
if (et && et->isProfile("blender")) {
et->setData("type", &(lamp->type));
et->setData("flag", &(lamp->flag));
@@ -1057,7 +1061,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
att2 = quadatt;
d = sqrt(1.0f / quadatt);
}
- // linear light
+ /* linear light */
else if (IS_EQ(quadatt, 0.0f) && linatt > 0.0f) {
att1 = linatt;
d = (1.0f / linatt);
@@ -1066,7 +1070,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
att1 = 1.0f;
}
else {
- // assuming point light (const att = 1.0);
+ /* assuming point light (const att = 1.0); */
att1 = 1.0f;
}
@@ -1077,7 +1081,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
switch (light->getLightType()) {
case COLLADAFW::Light::AMBIENT_LIGHT: {
- lamp->type = LA_SUN; //TODO needs more thoughts
+ lamp->type = LA_SUN; // TODO needs more thoughts
} break;
case COLLADAFW::Light::SPOT_LIGHT: {
lamp->type = LA_SPOT;
@@ -1115,36 +1119,37 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
return true;
}
-// this function is called only for animations that pass COLLADAFW::validate
+/* this function is called only for animations that pass COLLADAFW::validate */
bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim)
{
if (mImportStage == Fetching_Controller_data)
return true;
- // return true;
+ /* return true; */
return anim_importer.write_animation(anim);
}
-// called on post-process stage after writeVisualScenes
+/* called on post-process stage after writeVisualScenes */
bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animationList)
{
if (mImportStage == Fetching_Controller_data)
return true;
- // return true;
+ /* return true; */
return anim_importer.write_animation_list(animationList);
}
#if WITH_OPENCOLLADA_ANIMATION_CLIP
-// Since opencollada 1.6.68
-// called on post-process stage after writeVisualScenes
+/* 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
+ /* TODO: implement import of AnimationClips */
+ // return animation_clip_importer.write_animation_clip(animationClip);
}
#endif
@@ -1155,7 +1160,7 @@ bool DocumentImporter::writeSkinControllerData(const COLLADAFW::SkinControllerDa
return armature_importer.write_skin_controller_data(skin);
}
-// this is called on postprocess, before writeVisualScenes
+/* this is called on postprocess, before writeVisualScenes */
bool DocumentImporter::writeController(const COLLADAFW::Controller *controller)
{
if (mImportStage == Fetching_Controller_data)
@@ -1200,6 +1205,6 @@ bool DocumentImporter::is_armature(COLLADAFW::Node *node)
}
}
- //no child is JOINT
+ /* no child is JOINT */
return false;
}
diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h
index b48ddaaa827..e47c844f7c6 100644
--- a/source/blender/collada/DocumentImporter.h
+++ b/source/blender/collada/DocumentImporter.h
@@ -81,7 +81,8 @@ class DocumentImporter : COLLADAFW::IWriter {
/** This is the method called. The writer hast to prepare to receive data.*/
void start();
- /** This method is called after the last write* method. No other methods will be called after this.*/
+ /** This method is called after the last write* method. No other methods will be called after
+ * this.*/
void finish();
bool writeGlobalAsset(const COLLADAFW::FileInfo *);
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
index 280a0c4b860..279113f46d9 100644
--- a/source/blender/collada/EffectExporter.cpp
+++ b/source/blender/collada/EffectExporter.cpp
@@ -92,8 +92,8 @@ void EffectsExporter::exportEffects(bContext *C, Scene *sce)
void EffectsExporter::set_shader_type(COLLADASW::EffectProfile &ep, Material *ma)
{
- ep.setShaderType(
- COLLADASW::EffectProfile::LAMBERT); //XXX check if BLINN and PHONG can be supported as well
+ /* XXX check if BLINN and PHONG can be supported as well */
+ ep.setShaderType(COLLADASW::EffectProfile::LAMBERT);
}
void EffectsExporter::set_transparency(COLLADASW::EffectProfile &ep, Material *ma)
@@ -268,7 +268,7 @@ COLLADASW::ColorOrTexture EffectsExporter::createTexture(Image *ima,
COLLADASW::Texture texture(translate_id(id_name(ima)));
texture.setTexcoord(uv_layer_name);
- //texture.setSurface(*surface);
+ // texture.setSurface(*surface);
texture.setSampler(*sampler);
COLLADASW::ColorOrTexture cot(texture);
diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp
index 5aed0050a06..8109952b4ae 100644
--- a/source/blender/collada/ExtraHandler.cpp
+++ b/source/blender/collada/ExtraHandler.cpp
@@ -35,9 +35,9 @@ ExtraHandler::~ExtraHandler()
bool ExtraHandler::elementBegin(const char *elementName, const char **attributes)
{
- // \todo attribute handling for profile tags
+ /* \todo attribute handling for profile tags */
currentElement = std::string(elementName);
- //addToSidTree(attributes[0], attributes[1]);
+ // addToSidTree(attributes[0], attributes[1]);
return true;
}
@@ -72,7 +72,11 @@ bool ExtraHandler::parseElement(const char *profileName,
COLLADAFW::Object *object)
{
if (BLI_strcaseeq(profileName, "blender")) {
- //printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
+#if 0
+ printf("In parseElement for supported profile %s for id %s\n",
+ profileName,
+ uniqueId.toAscii().c_str());
+#endif
currentUid = uniqueId;
ExtraTags *et = dimp->getExtraTags(uniqueId);
if (!et) {
@@ -82,6 +86,7 @@ bool ExtraHandler::parseElement(const char *profileName,
currentExtraTags = et;
return true;
}
- //printf("In parseElement for unsupported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
+ // printf("In parseElement for unsupported profile %s for id %s\n", profileName,
+ // uniqueId.toAscii().c_str());
return false;
}
diff --git a/source/blender/collada/ExtraHandler.h b/source/blender/collada/ExtraHandler.h
index 8203b364953..b695f5221f6 100644
--- a/source/blender/collada/ExtraHandler.h
+++ b/source/blender/collada/ExtraHandler.h
@@ -50,7 +50,8 @@ class ExtraHandler : public COLLADASaxFWL::IExtraDataCallbackHandler {
/** Receive the data in text format. */
bool textData(const char *text, size_t textLength);
- /** Method to ask, if the current callback handler want to read the data of the given extra element. */
+ /** Method to ask, if the current callback handler want to read the data of the given extra
+ * element. */
bool parseElement(const char *profileName,
const unsigned long &elementHash,
const COLLADAFW::UniqueId &uniqueId,
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
index 41452f9f35a..f9279538742 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -66,7 +66,7 @@ void GeometryExporter::operator()(Object *ob)
std::vector<Normal> nor;
std::vector<BCPolygonNormalsIndices> norind;
- // Skip if linked geometry was already exported from another reference
+ /* Skip if linked geometry was already exported from another reference */
if (use_instantiation && exportedGeometry.find(geom_id) != exportedGeometry.end()) {
return;
}
@@ -80,18 +80,18 @@ void GeometryExporter::operator()(Object *ob)
create_normals(nor, norind, me);
- // openMesh(geoId, geoName, meshId)
+ /* openMesh(geoId, geoName, meshId) */
openMesh(geom_id, geom_name);
- // writes <source> for vertex coords
+ /* writes <source> for vertex coords */
createVertsSource(geom_id, me);
- // writes <source> for normal coords
+ /* writes <source> for normal coords */
createNormalsSource(geom_id, me, nor);
bool has_uvs = (bool)CustomData_has_layer(&me->ldata, CD_MLOOPUV);
- // writes <source> for uv coords if mesh has uv coords
+ /* writes <source> for uv coords if mesh has uv coords */
if (has_uvs) {
createTexcoordsSource(geom_id, me);
}
@@ -99,7 +99,7 @@ void GeometryExporter::operator()(Object *ob)
if (has_color) {
createVertexColorSource(geom_id, me);
}
- // <vertices>
+ /* <vertices> */
COLLADASW::Vertices verts(mSW);
verts.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX));
@@ -111,9 +111,9 @@ void GeometryExporter::operator()(Object *ob)
createLooseEdgeList(ob, me, geom_id);
- // Only create Polylists if number of faces > 0
+ /* Only create Polylists if number of faces > 0 */
if (me->totface > 0) {
- // XXX slow
+ /* XXX slow */
if (ob->totcol) {
for (int a = 0; a < ob->totcol; a++) {
create_mesh_primitive_list(a, has_uvs, has_color, ob, me, geom_id, norind);
@@ -137,7 +137,7 @@ void GeometryExporter::operator()(Object *ob)
Key *key = BKE_key_from_object(ob);
if (key) {
KeyBlock *kb = (KeyBlock *)key->block.first;
- //skip the basis
+ /* skip the basis */
kb = kb->next;
for (; kb; kb = kb->next) {
BKE_keyblock_convert_to_mesh(kb, me);
@@ -170,15 +170,15 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
// openMesh(geoId, geoName, meshId)
openMesh(geom_id, geom_name);
- // writes <source> for vertex coords
+ /* writes <source> for vertex coords */
createVertsSource(geom_id, me);
- // writes <source> for normal coords
+ /* writes <source> for normal coords */
createNormalsSource(geom_id, me, nor);
bool has_uvs = (bool)CustomData_has_layer(&me->ldata, CD_MLOOPUV);
- // writes <source> for uv coords if mesh has uv coords
+ /* writes <source> for uv coords if mesh has uv coords */
if (has_uvs) {
createTexcoordsSource(geom_id, me);
}
@@ -187,7 +187,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
createVertexColorSource(geom_id, me);
}
- // <vertices>
+ /* <vertices> */
COLLADASW::Vertices verts(mSW);
verts.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX));
@@ -197,9 +197,9 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
input_list.push_back(input);
verts.add();
- //createLooseEdgeList(ob, me, geom_id, norind);
+ // createLooseEdgeList(ob, me, geom_id, norind);
- // XXX slow
+ /* XXX slow */
if (ob->totcol) {
for (int a = 0; a < ob->totcol; a++) {
create_mesh_primitive_list(a, has_uvs, has_color, ob, me, geom_id, norind);
@@ -228,8 +228,8 @@ void GeometryExporter::createLooseEdgeList(Object *ob, Mesh *me, std::string &ge
std::vector<unsigned int> edge_list;
int index;
- // Find all loose edges in Mesh
- // and save vertex indices in edge_list
+ /* Find all loose edges in Mesh
+ * and save vertex indices in edge_list */
for (index = 0; index < totedges; index++) {
MEdge *edge = &medges[index];
@@ -241,14 +241,14 @@ void GeometryExporter::createLooseEdgeList(Object *ob, Mesh *me, std::string &ge
}
if (edges_in_linelist > 0) {
- // Create the list of loose edges
+ /* Create the list of loose edges */
COLLADASW::Lines lines(mSW);
lines.setCount(edges_in_linelist);
COLLADASW::InputList &til = lines.getInputList();
- // creates <input> in <lines> for vertices
+ /* creates <input> in <lines> for vertices */
COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX,
getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX),
0);
@@ -268,12 +268,12 @@ static void prepareToAppendValues(bool is_triangulated,
COLLADASW::PrimitivesBase &primitive_list,
std::vector<unsigned long> &vcount_list)
{
- // performs the actual writing
+ /* performs the actual writing */
if (is_triangulated) {
((COLLADASW::Triangles &)primitive_list).prepareToAppendValues();
}
else {
- // sets <vcount>
+ /* sets <vcount> */
primitive_list.setVCountList(vcount_list);
((COLLADASW::Polylist &)primitive_list).prepareToAppendValues();
}
@@ -314,7 +314,7 @@ static bool collect_vertex_counts_per_poly(Mesh *me,
bool is_triangulated = true;
int i;
- // Expecting that p->mat_nr is always 0 if the mesh has no materials assigned
+ /* Expecting that p->mat_nr is always 0 if the mesh has no materials assigned */
for (i = 0; i < totpolys; i++) {
MPoly *p = &mpolys[i];
if (p->mat_nr == material_index) {
@@ -334,7 +334,7 @@ std::string GeometryExporter::makeVertexColorSourceId(std::string &geom_id, char
return result;
}
-// powerful because it handles both cases when there is material and when there's not
+/* powerful because it handles both cases when there is material and when there's not */
void GeometryExporter::create_mesh_primitive_list(short material_index,
bool has_uvs,
bool has_color,
@@ -353,7 +353,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
bool is_triangulated = collect_vertex_counts_per_poly(me, material_index, vcount_list);
int polygon_count = vcount_list.size();
- // no faces using this material
+ /* no faces using this material */
if (polygon_count == 0) {
fprintf(
stderr, "%s: material with index %d is not used.\n", id_name(ob).c_str(), material_index);
@@ -363,10 +363,10 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
Material *ma = ob->totcol ? give_current_material(ob, material_index + 1) : NULL;
COLLADASW::PrimitivesBase *primitive_list = create_primitive_list(is_triangulated, mSW);
- // sets count attribute in <polylist>
+ /* sets count attribute in <polylist> */
primitive_list->setCount(polygon_count);
- // sets material name
+ /* sets material name */
if (ma) {
std::string material_id = get_material_id(ma);
std::ostringstream ostr;
@@ -385,7 +385,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
til.push_back(vertex_input);
til.push_back(normals_input);
- // if mesh has uv coords writes <input> for TEXCOORD
+ /* if mesh has uv coords writes <input> for TEXCOORD */
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 (int i = 0; i < num_layers; i++) {
@@ -397,7 +397,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
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 : layer_index - 1 //set (0,1,2,...)
+ (this->export_settings->active_uv_only) ? 0 : layer_index - 1 /* set (0,1,2,...) */
);
til.push_back(texcoord_input);
}
@@ -419,10 +419,10 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
}
}
- // performs the actual writing
+ /* performs the actual writing */
prepareToAppendValues(is_triangulated, *primitive_list, vcount_list);
- // <p>
+ /* <p> */
int texindex = 0;
for (int i = 0; i < totpolys; i++) {
MPoly *p = &mpolys[i];
@@ -449,7 +449,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
finish_and_delete_primitive_List(is_triangulated, primitive_list);
}
-// creates <source> for positions
+/* creates <source> for positions */
void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
{
#if 0
@@ -473,7 +473,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
/* main function, it creates <source id = "">, <float_array id = ""
* count = ""> */
source.prepareToAppendValues();
- //appends data to <float_array>
+ /* appends data to <float_array> */
int i = 0;
for (i = 0; i < totverts; i++) {
source.appendValues(verts[i].co[0], verts[i].co[1], verts[i].co[2]);
@@ -542,7 +542,7 @@ std::string GeometryExporter::makeTexcoordSourceId(std::string &geom_id,
return getIdBySemantics(geom_id, COLLADASW::InputSemantic::TEXCOORD) + suffix;
}
-//creates <source> for texcoords
+/* creates <source> for texcoords */
void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
{
@@ -552,8 +552,8 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
- // write <source> for each layer
- // each <source> will get id like meshName + "map-channel-1"
+ /* write <source> for each layer
+ * each <source> will get id like meshName + "map-channel-1" */
int active_uv_index = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV);
for (int a = 0; a < num_layers; a++) {
int layer_index = CustomData_get_layer_index_n(&me->ldata, CD_MLOOPUV, a);
@@ -593,7 +593,7 @@ bool operator<(const Normal &a, const Normal &b)
return a.x < b.x || (a.x == b.x && (a.y < b.y || (a.y == b.y && a.z < b.z)));
}
-//creates <source> for normals
+/* creates <source> for normals */
void GeometryExporter::createNormalsSource(std::string geom_id, Mesh *me, std::vector<Normal> &nor)
{
#if 0
@@ -645,7 +645,7 @@ void GeometryExporter::create_normals(std::vector<Normal> &normals,
bool use_vertex_normals = use_custom_normals || mpoly->flag & ME_SMOOTH;
if (!use_vertex_normals) {
- // For flat faces use face normal as vertex normal:
+ /* For flat faces use face normal as vertex normal: */
float vector[3];
BKE_mesh_calc_poly_normal(mpoly, mloops + mpoly->loopstart, verts, vector);
diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h
index 1e2643b7e57..976059b0925 100644
--- a/source/blender/collada/GeometryExporter.h
+++ b/source/blender/collada/GeometryExporter.h
@@ -54,7 +54,7 @@ class Normal {
bool operator<(const Normal &, const Normal &);
-// TODO: optimize UV sets by making indexed list with duplicates removed
+/* TODO: optimize UV sets by making indexed list with duplicates removed */
class GeometryExporter : COLLADASW::LibraryGeometries {
struct Face {
unsigned int v1, v2, v3, v4;
@@ -63,7 +63,7 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
Normal n;
public:
- // TODO: optimize UV sets by making indexed list with duplicates removed
+ /* TODO: optimize UV sets by making indexed list with duplicates removed */
GeometryExporter(BlenderContext &blender_context,
COLLADASW::StreamWriter *sw,
const ExportSettings *export_settings)
@@ -79,7 +79,7 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
void createLooseEdgeList(Object *ob, Mesh *me, std::string &geom_id);
- // powerful because it handles both cases when there is material and when there's not
+ /* powerful because it handles both cases when there is material and when there's not */
void create_mesh_primitive_list(short material_index,
bool has_uvs,
bool has_color,
@@ -88,18 +88,18 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
std::string &geom_id,
std::vector<BCPolygonNormalsIndices> &norind);
- // creates <source> for positions
+ /* creates <source> for positions */
void createVertsSource(std::string geom_id, Mesh *me);
void createVertexColorSource(std::string geom_id, Mesh *me);
std::string makeTexcoordSourceId(std::string &geom_id, int layer_index, bool is_single_layer);
- //creates <source> for texcoords
+ /* creates <source> for texcoords */
void createTexcoordsSource(std::string geom_id, Mesh *me);
void createTesselatedTexcoordsSource(std::string geom_id, Mesh *me);
- //creates <source> for normals
+ /* creates <source> for normals */
void createNormalsSource(std::string geom_id, Mesh *me, std::vector<Normal> &nor);
void create_normals(std::vector<Normal> &nor,
@@ -128,8 +128,8 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
};
struct GeometryFunctor {
- // f should have
- // void operator()(Object *ob)
+ /* f should have
+ * void operator()(Object *ob) */
template<class Functor>
void forEachMeshObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
{
diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp
index 1a5c42aee52..650e1bfcd57 100644
--- a/source/blender/collada/ImageExporter.cpp
+++ b/source/blender/collada/ImageExporter.cpp
@@ -75,27 +75,27 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
char export_dir[FILE_MAX];
char export_file[FILE_MAX];
- // Destination folder for exported assets
+ /* Destination folder for exported assets */
BLI_split_dir_part(this->export_settings->filepath, export_dir, sizeof(export_dir));
if (is_generated || is_dirty || use_copies || is_packed) {
- // make absolute destination path
+ /* make absolute destination path */
BLI_strncpy(export_file, name.c_str(), sizeof(export_file));
BKE_image_path_ensure_ext_from_imformat(export_file, &imageFormat);
BLI_join_dirfile(export_path, sizeof(export_path), export_dir, export_file);
- // make dest directory if it doesn't exist
+ /* make dest directory if it doesn't exist */
BLI_make_existing_file(export_path);
}
if (is_generated || is_dirty || is_packed) {
- // This image in its current state only exists in Blender memory.
- // So we have to export it. The export will keep the image state intact,
- // so the exported file will not be associated with the image.
+ /* This image in its current state only exists in Blender memory.
+ * So we have to export it. The export will keep the image state intact,
+ * so the exported file will not be associated with the image. */
if (BKE_imbuf_write_as(imbuf, export_path, &imageFormat, true) == 0) {
fprintf(stderr, "Collada export: Cannot export image to:\n%s\n", export_path);
@@ -105,18 +105,18 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
}
else {
- // make absolute source path
+ /* make absolute source path */
BLI_strncpy(source_path, image->name, sizeof(source_path));
BLI_path_abs(source_path, BKE_main_blendfile_path_from_global());
BLI_cleanup_path(NULL, source_path);
if (use_copies) {
- // This image is already located on the file system.
- // But we want to create copies here.
- // To move images into the same export directory.
- // Note: If an image is already located in the export folder,
- // then skip the copy (as it would result in a file copy error).
+ /* This image is already located on the file system.
+ * But we want to create copies here.
+ * To move images into the same export directory.
+ * Note: If an image is already located in the export folder,
+ * then skip the copy (as it would result in a file copy error). */
if (BLI_path_cmp(source_path, export_path) != 0) {
if (BLI_copy(source_path, export_path) != 0) {
@@ -132,17 +132,18 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
}
else {
- // Do not make any copies, but use the source path directly as reference
- // to the original image
+ /* Do not make any copies, but use the source path directly as reference
+ * to the original image */
BLI_strncpy(export_path, source_path, sizeof(export_path));
}
}
- COLLADASW::Image img(
- COLLADABU::URI(COLLADABU::URI::nativePathToUri(export_path)),
- translated_name,
- translated_name); /* set name also to mNameNC. This helps other viewers import files exported from Blender better */
+ /* Set name also to mNameNC.
+ * This helps other viewers import files exported from Blender better. */
+ COLLADASW::Image img(COLLADABU::URI(COLLADABU::URI::nativePathToUri(export_path)),
+ translated_name,
+ translated_name);
img.add(mSW);
fprintf(stdout, "Collada export: Added image: %s\n", export_file);
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index 0c87b139c0c..00484295694 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -266,9 +266,8 @@ void MeshImporter::print_index_list(COLLADAFW::IndexList &index_list)
}
#endif
-bool MeshImporter::is_nice_mesh(
- COLLADAFW::Mesh *
- mesh) // checks if mesh has supported primitive types: lines, polylist, triangles, triangle_fans
+/* checks if mesh has supported primitive types: lines, polylist, triangles, triangle_fans */
+bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh)
{
COLLADAFW::MeshPrimitiveArray &prim_arr = mesh->getMeshPrimitives();
diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h
index 68ab6e73732..9517587013d 100644
--- a/source/blender/collada/MeshImporter.h
+++ b/source/blender/collada/MeshImporter.h
@@ -47,7 +47,7 @@ extern "C" {
#include "DNA_scene_types.h"
}
-// only for ArmatureImporter to "see" MeshImporter::get_object_by_geom_uid
+/* only for ArmatureImporter to "see" MeshImporter::get_object_by_geom_uid */
class MeshImporterBase {
public:
virtual Object *get_object_by_geom_uid(const COLLADAFW::UniqueId &geom_uid) = 0;
@@ -86,22 +86,24 @@ class MeshImporter : public MeshImporterBase {
ArmatureImporter *armature_importer;
- std::map<std::string, std::string> mesh_geom_map; // needed for correct shape key naming
- std::map<COLLADAFW::UniqueId, Mesh *> uid_mesh_map; // geometry unique id-to-mesh map
- std::map<COLLADAFW::UniqueId, Object *> uid_object_map; // geom uid-to-object
- std::vector<Object *> imported_objects; // list of imported objects
+ std::map<std::string, std::string> mesh_geom_map; /* needed for correct shape key naming */
+ std::map<COLLADAFW::UniqueId, Mesh *> uid_mesh_map; /* geometry unique id-to-mesh map */
+ std::map<COLLADAFW::UniqueId, Object *> uid_object_map; /* geom uid-to-object */
+ std::vector<Object *> imported_objects; /* list of imported objects */
- // this structure is used to assign material indices to polygons
- // it holds a portion of Mesh faces and corresponds to a DAE primitive list (<triangles>, <polylist>, etc.)
+ /* this structure is used to assign material indices to polygons
+ * it holds a portion of Mesh faces and corresponds to a DAE primitive list
+ * (<triangles>, <polylist>, etc.) */
struct Primitive {
MPoly *mpoly;
unsigned int totpoly;
};
typedef std::map<COLLADAFW::MaterialId, std::vector<Primitive>> MaterialIdPrimitiveArrayMap;
- std::map<COLLADAFW::UniqueId, MaterialIdPrimitiveArrayMap>
- geom_uid_mat_mapping_map; // crazy name!
- std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId>
- materials_mapped_to_geom; //< materials that have already been mapped to a geometry. A pair of geom uid and mat uid, one geometry can have several materials
+ /* crazy name! */
+ std::map<COLLADAFW::UniqueId, MaterialIdPrimitiveArrayMap> geom_uid_mat_mapping_map;
+ /* < materials that have already been mapped to a geometry.
+ * A pair/of geom uid and mat uid, one geometry can have several materials */
+ std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId> materials_mapped_to_geom;
bool set_poly_indices(
MPoly *mpoly, MLoop *mloop, int loop_index, unsigned int *indices, int loop_count);
@@ -137,7 +139,7 @@ class MeshImporter : public MeshImporterBase {
void allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me);
- // TODO: import uv set names
+ /* TODO: import uv set names */
void read_polys(COLLADAFW::Mesh *mesh, Mesh *me);
void read_lines(COLLADAFW::Mesh *mesh, Mesh *me);
unsigned int get_vertex_count(COLLADAFW::Polygons *mp, int index);
@@ -172,7 +174,7 @@ class MeshImporter : public MeshImporterBase {
bool isController,
std::map<COLLADAFW::UniqueId, Material *> &uid_material_map);
- // create a mesh storing a pointer in a map so it can be retrieved later by geometry UID
+ /* create a mesh storing a pointer in a map so it can be retrieved later by geometry UID */
bool write_geometry(const COLLADAFW::Geometry *geom);
std::string *get_geometry_name(const std::string &mesh_name);
};
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index 7cb211c7c35..8017790572f 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -32,7 +32,7 @@ void SceneExporter::exportScene()
{
Scene *scene = blender_context.get_scene();
- // <library_visual_scenes> <visual_scene>
+ /* <library_visual_scenes> <visual_scene> */
std::string name = id_name(scene);
openVisualScene(translate_id(name), encode_xml(name));
exportHierarchy();
@@ -45,13 +45,13 @@ void SceneExporter::exportHierarchy()
LinkNode *node;
std::vector<Object *> base_objects;
- // Ensure all objects in the export_set are marked
+ /* Ensure all objects in the export_set are marked */
for (node = this->export_settings->export_set; node; node = node->next) {
Object *ob = (Object *)node->link;
ob->id.tag |= LIB_TAG_DOIT;
}
- // Now find all exportable base objects (highest in export hierarchy)
+ /* Now find all exportable base objects (highest in export hierarchy) */
for (node = this->export_settings->export_set; node; node = node->next) {
Object *ob = (Object *)node->link;
if (bc_is_base_node(this->export_settings->export_set, ob)) {
@@ -68,7 +68,7 @@ void SceneExporter::exportHierarchy()
}
}
- // And now export the base objects:
+ /* And now export the base objects: */
for (int index = 0; index < base_objects.size(); index++) {
Object *ob = base_objects[index];
if (bc_is_marked(ob)) {
@@ -103,7 +103,7 @@ void SceneExporter::writeNodes(Object *ob)
bc_get_children(child_objects, ob, view_layer);
bool can_export = bc_is_in_Export_set(this->export_settings->export_set, ob, view_layer);
- // Add associated armature first if available
+ /* Add associated armature first if available */
bool armature_exported = false;
Object *ob_arm = bc_get_assigned_armature(ob);
@@ -125,7 +125,7 @@ void SceneExporter::writeNodes(Object *ob)
colladaNode.start();
if (ob->type == OB_MESH && armature_exported) {
- // for skinned mesh we write obmat in <bind_shape_matrix>
+ /* for skinned mesh we write obmat in <bind_shape_matrix> */
TransformWriter::add_node_transform_identity(colladaNode);
}
else {
@@ -135,7 +135,7 @@ void SceneExporter::writeNodes(Object *ob)
this->export_settings->limit_precision);
}
- // <instance_geometry>
+ /* <instance_geometry> */
if (ob->type == OB_MESH) {
bool instance_controller_created = false;
if (armature_exported) {
@@ -153,27 +153,27 @@ void SceneExporter::writeNodes(Object *ob)
}
}
- // <instance_controller>
+ /* <instance_controller> */
else if (ob->type == OB_ARMATURE) {
arm_exporter->add_armature_bones(ob, view_layer, this, child_objects);
}
- // <instance_camera>
+ /* <instance_camera> */
else if (ob->type == OB_CAMERA) {
COLLADASW::InstanceCamera instCam(
mSW, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_camera_id(ob)));
instCam.add();
}
- // <instance_light>
+ /* <instance_light> */
else if (ob->type == OB_LAMP) {
COLLADASW::InstanceLight instLa(
mSW, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_light_id(ob)));
instLa.add();
}
- // empty object
- else if (ob->type == OB_EMPTY) { // TODO: handle groups (OB_DUPLICOLLECTION
+ /* empty object */
+ else if (ob->type == OB_EMPTY) { /* TODO: handle groups (OB_DUPLICOLLECTION */
if ((ob->transflag & OB_DUPLICOLLECTION) == OB_DUPLICOLLECTION && ob->instance_collection) {
Collection *collection = ob->instance_collection;
/* printf("group detected '%s'\n", group->id.name + 2); */
@@ -206,9 +206,9 @@ void SceneExporter::writeNodes(Object *ob)
colladaNode.addExtraTechniqueChildParameter(
"blender", con_tag, "lin_error", con->lin_error);
- //not ideal: add the target object name as another parameter.
- //No real mapping in the .dae
- //Need support for multiple target objects also.
+ /* not ideal: add the target object name as another parameter.
+ * No real mapping in the .dae
+ * Need support for multiple target objects also. */
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
if (cti && cti->get_constraint_targets) {
diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp
index d0f2e2d6332..3b5ea90d459 100644
--- a/source/blender/collada/SkinInfo.cpp
+++ b/source/blender/collada/SkinInfo.cpp
@@ -45,16 +45,16 @@
#include "SkinInfo.h"
#include "collada_utils.h"
-// use name, or fall back to original id if name not present (name is optional)
+/* use name, or fall back to original id if name not present (name is optional) */
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
return id.size() ? id.c_str() : node->getOriginalId().c_str();
}
-// This is used to store data passed in write_controller_data.
-// Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members
-// so that arrays don't get freed until we free them explicitly.
+/* This is used to store data passed in write_controller_data.
+ * Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members
+ * so that arrays don't get freed until we free them explicitly. */
SkinInfo::SkinInfo()
{
/* pass */
@@ -79,7 +79,7 @@ SkinInfo::SkinInfo(UnitConverter *conv) : unit_converter(conv), ob_arm(NULL), pa
{
}
-// nobody owns the data after this, so it should be freed manually with releaseMemory
+/* nobody owns the data after this, so it should be freed manually with releaseMemory */
template<class T> void SkinInfo::transfer_array_data(T &src, T &dest)
{
dest.setData(src.getData(), src.getCount());
@@ -87,7 +87,7 @@ template<class T> void SkinInfo::transfer_array_data(T &src, T &dest)
dest.yieldOwnerShip();
}
-// when src is const we cannot src.yieldOwnerShip, this is used by copy constructor
+/* when src is const we cannot src.yieldOwnerShip, this is used by copy constructor */
void SkinInfo::transfer_int_array_data_const(const COLLADAFW::IntValuesArray &src,
COLLADAFW::IntValuesArray &dest)
{
@@ -109,7 +109,7 @@ void SkinInfo::borrow_skin_controller_data(const COLLADAFW::SkinControllerData *
transfer_array_data((COLLADAFW::IntValuesArray &)skin->getJointIndices(), joint_indices);
// transfer_array_data(skin->getWeights(), weights);
- // cannot transfer data for FloatOrDoubleArray, copy values manually
+ /* cannot transfer data for FloatOrDoubleArray, copy values manually */
const COLLADAFW::FloatOrDoubleArray &weight = skin->getWeights();
for (unsigned int i = 0; i < weight.getValuesCount(); i++)
weights.push_back(bc_get_float_value(weight, i));
@@ -125,9 +125,9 @@ void SkinInfo::free()
// weights.releaseMemory();
}
-// using inverse bind matrices to construct armature
-// it is safe to invert them to get the original matrices
-// because if they are inverse matrices, they can be inverted
+/* using inverse bind matrices to construct armature
+ * it is safe to invert them to get the original matrices
+ * because if they are inverse matrices, they can be inverted */
void SkinInfo::add_joint(const COLLADABU::Math::Matrix4 &matrix)
{
JointData jd;
@@ -139,21 +139,21 @@ void SkinInfo::set_controller(const COLLADAFW::SkinController *co)
{
controller_uid = co->getUniqueId();
- // fill in joint UIDs
+ /* fill in joint UIDs */
const COLLADAFW::UniqueIdArray &joint_uids = co->getJoints();
for (unsigned int i = 0; i < joint_uids.getCount(); i++) {
joint_data[i].joint_uid = joint_uids[i];
- // // store armature pointer
+ /* store armature pointer */
// JointData& jd = joint_index_to_joint_info_map[i];
// jd.ob_arm = ob_arm;
- // now we'll be able to get inv bind matrix from joint id
+ /* now we'll be able to get inv bind matrix from joint id */
// joint_id_to_joint_index_map[joint_ids[i]] = i;
}
}
-// called from write_controller
+/* called from write_controller */
Object *SkinInfo::create_armature(Main *bmain, Scene *scene, ViewLayer *view_layer)
{
ob_arm = bc_add_object(bmain, scene, view_layer, OB_ARMATURE, NULL);
@@ -193,11 +193,11 @@ const COLLADAFW::UniqueId &SkinInfo::get_controller_uid()
return controller_uid;
}
-// check if this skin controller references a joint or any descendant of it
-//
-// some nodes may not be referenced by SkinController,
-// in this case to determine if the node belongs to this armature,
-// we need to search down the tree
+/* check if this skin controller references a joint or any descendant of it
+ *
+ * some nodes may not be referenced by SkinController,
+ * in this case to determine if the node belongs to this armature,
+ * we need to search down the tree */
bool SkinInfo::uses_joint_or_descendant(COLLADAFW::Node *node)
{
const COLLADAFW::UniqueId &uid = node->getUniqueId();
@@ -248,17 +248,17 @@ void SkinInfo::link_armature(bContext *C,
amd->deformflag = ARM_DEF_VGROUP;
- // create all vertex groups
+ /* create all vertex groups */
std::vector<JointData>::iterator it;
int joint_index;
for (it = joint_data.begin(), joint_index = 0; it != joint_data.end(); it++, joint_index++) {
const char *name = "Group";
- // skip joints that have invalid UID
+ /* skip joints that have invalid UID */
if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID)
continue;
- // name group by joint node name
+ /* name group by joint node name */
if (joint_by_uid.find((*it).joint_uid) != joint_by_uid.end()) {
name = bc_get_joint_name(joint_by_uid[(*it).joint_uid]);
@@ -267,16 +267,16 @@ void SkinInfo::link_armature(bContext *C,
BKE_object_defgroup_add_name(ob, name);
}
- // <vcount> - number of joints per vertex - joints_per_vertex
- // <v> - [[bone index, weight index] * joints per vertex] * vertices - weight indices
- // ^ bone index can be -1 meaning weight toward bind shape, how to express this in Blender?
-
- // for each vertex in weight indices
- // for each bone index in vertex
- // add vertex to group at group index
- // treat group index -1 specially
-
- // get def group by index with BLI_findlink
+ /* <vcount> - number of joints per vertex - joints_per_vertex
+ * <v> - [[bone index, weight index] * joints per vertex] * vertices - weight indices
+ * ^ bone index can be -1 meaning weight toward bind shape, how to express this in Blender?
+ *
+ * for each vertex in weight indices
+ * for each bone index in vertex
+ * add vertex to group at group index
+ * treat group index -1 specially
+ *
+ * get def group by index with BLI_findlink */
for (unsigned int vertex = 0, weight = 0; vertex < joints_per_vertex.getCount(); vertex++) {
@@ -284,7 +284,7 @@ void SkinInfo::link_armature(bContext *C,
for (; weight < limit; weight++) {
int joint = joint_indices[weight], joint_weight = weight_indices[weight];
- // -1 means "weight towards the bind shape", we just don't assign it to any group
+ /* -1 means "weight towards the bind shape", we just don't assign it to any group */
if (joint != -1) {
bDeformGroup *def = (bDeformGroup *)BLI_findlink(&ob->defbase, joint);
@@ -314,17 +314,17 @@ void SkinInfo::find_root_joints(const std::vector<COLLADAFW::Node *> &root_joint
std::vector<COLLADAFW::Node *> &result)
{
std::vector<COLLADAFW::Node *>::const_iterator it;
- // for each root_joint
+ /* for each root_joint */
for (it = root_joints.begin(); it != root_joints.end(); it++) {
COLLADAFW::Node *root = *it;
std::vector<JointData>::iterator ji;
- //for each joint_data in this skin
+ /* for each joint_data in this skin */
for (ji = joint_data.begin(); ji != joint_data.end(); ji++) {
if (joint_by_uid.find((*ji).joint_uid) != joint_by_uid.end()) {
- //get joint node from joint map
+ /* get joint node from joint map */
COLLADAFW::Node *joint = joint_by_uid[(*ji).joint_uid];
- //find if joint node is in the tree belonging to the root_joint
+ /* find if joint node is in the tree belonging to the root_joint */
if (find_node_in_tree(joint, root)) {
if (std::find(result.begin(), result.end(), root) == result.end())
result.push_back(root);
diff --git a/source/blender/collada/TransformReader.h b/source/blender/collada/TransformReader.h
index 6add2950c06..2cf3ee795ae 100644
--- a/source/blender/collada/TransformReader.h
+++ b/source/blender/collada/TransformReader.h
@@ -35,7 +35,7 @@
#include "collada_internal.h"
-//struct Object;
+// struct Object;
class TransformReader {
protected:
diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp
index 8ebf529cc25..2ab9105976e 100644
--- a/source/blender/collada/TransformWriter.cpp
+++ b/source/blender/collada/TransformWriter.cpp
@@ -98,7 +98,8 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node &node,
add_transform(node, loc, rot, scale);
#endif
- /* Export the local Matrix (relative to the object parent, be it an object, bone or vertex(-tices)) */
+ /* 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);
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index c18f70676bc..9f2d3f951ec 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -63,7 +63,7 @@ extern "C" {
#include "MEM_guardedalloc.h"
-#include "WM_api.h" // XXX hrm, see if we can do without this
+#include "WM_api.h" /* XXX hrm, see if we can do without this */
#include "WM_types.h"
#include "bmesh.h"
@@ -91,7 +91,7 @@ float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray &array, unsigned in
return array.getDoubleValues()->getData()[index];
}
-// copied from /editors/object/object_relations.c
+/* copied from /editors/object/object_relations.c */
int bc_test_parent_loop(Object *par, Object *ob)
{
/* test if 'ob' is a parent somewhere in par's parents */
@@ -146,8 +146,8 @@ bool bc_validateConstraints(bConstraint *con)
return true;
}
-// a shortened version of parent_set_exec()
-// if is_parent_space is true then ob->obmat will be multiplied by par->obmat before parenting
+/* a shortened version of parent_set_exec()
+ * if is_parent_space is true then ob->obmat will be multiplied by par->obmat before parenting */
int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
{
Object workob;
@@ -164,18 +164,18 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
if (is_parent_space) {
float mat[4][4];
- // calc par->obmat
+ /* calc par->obmat */
BKE_object_where_is_calc(depsgraph, sce, par);
- // move child obmat into world space
+ /* move child obmat into world space */
mul_m4_m4m4(mat, par->obmat, ob->obmat);
copy_m4_m4(ob->obmat, mat);
}
- // apply child obmat (i.e. decompose it into rot/loc/size)
+ /* apply child obmat (i.e. decompose it into rot/loc/size) */
BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
- // compute parentinv
+ /* compute parentinv */
BKE_object_workob_calc_parent(depsgraph, sce, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
@@ -381,7 +381,7 @@ void bc_set_mark(Object *ob)
ob->id.tag |= LIB_TAG_DOIT;
}
-// Use bubble sort algorithm for sorting the export set
+/* Use bubble sort algorithm for sorting the export set */
void bc_bubble_sort_by_Object_name(LinkNode *export_set)
{
bool sorted = false;
@@ -520,21 +520,22 @@ void bc_rotate_from_reference_quat(float quat_to[4], float quat_from[4], float m
float mat_from[4][4];
quat_to_mat4(mat_from, quat_from);
- // Calculate the difference matrix matd between mat_from and mat_to
+ /* Calculate the difference matrix matd between mat_from and mat_to */
invert_m4_m4(mati, mat_from);
mul_m4_m4m4(matd, mati, mat_to);
mat4_to_quat(qd, matd);
- mul_qt_qtqt(quat_to, qd, quat_from); // rot is the final rotation corresponding to mat_to
+ mul_qt_qtqt(quat_to, qd, quat_from); /* rot is the final rotation corresponding to mat_to */
}
void bc_triangulate_mesh(Mesh *me)
{
bool use_beauty = false;
bool tag_only = false;
- int quad_method =
- MOD_TRIANGULATE_QUAD_SHORTEDGE; /* XXX: The triangulation method selection could be offered in the UI */
+
+ /* XXX: The triangulation method selection could be offered in the UI. */
+ int quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE;
const struct BMeshCreateParams bm_create_params = {0};
BMesh *bm = BM_mesh_create(&bm_mesh_allocsize_default, &bm_create_params);
@@ -774,8 +775,8 @@ std::string BoneExtended::get_bone_layers(int bitfield)
int BoneExtended::get_bone_layers()
{
- return (bone_layers == 0) ? 1 :
- bone_layers; // ensure that the bone is in at least one bone layer!
+ /* ensure that the bone is in at least one bone layer! */
+ return (bone_layers == 0) ? 1 : bone_layers;
}
void BoneExtended::set_use_connect(int use_connect)
@@ -983,7 +984,7 @@ bool bc_is_animated(BCMatrixSampleMap &values)
static float MIN_DISTANCE = 0.00001;
if (values.size() < 2)
- return false; // need at least 2 entries to be not flat
+ return false; /* need at least 2 entries to be not flat */
BCMatrixSampleMap::iterator it;
const BCMatrix *refmat = NULL;
@@ -1009,7 +1010,7 @@ bool bc_has_animations(Object *ob)
(bc_getSceneCameraAction(ob) && bc_getSceneCameraAction(ob)->curves.first))
return true;
- //Check Material Effect parameter animations.
+ /* Check Material Effect parameter animations. */
for (int a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a + 1);
if (!ma)
@@ -1254,7 +1255,7 @@ bNode *bc_add_node(bContext *C, bNodeTree *ntree, int node_type, int locx, int l
}
#if 0
-// experimental, probably not used
+/* experimental, probably not used */
static bNodeSocket *bc_group_add_input_socket(bNodeTree *ntree,
bNode *to_node,
int to_index,
@@ -1337,7 +1338,7 @@ void bc_add_default_shader(bContext *C, Material *ma)
bc_node_add_link(ntree, nmap["transparent"], 0, nmap["mix"], 2);
bc_node_add_link(ntree, nmap["mix"], 0, nmap["out"], 0);
- // experimental, probably not used.
+ /* experimental, probably not used. */
bc_make_group(C, ntree, nmap);
#else
nmap["main"] = bc_add_node(C, ntree, SH_NODE_BSDF_PRINCIPLED, 0, 300);
@@ -1366,7 +1367,7 @@ COLLADASW::ColorOrTexture bc_get_base_color(bNode *shader)
return bc_get_cot(col[0], col[1], col[2], col[3]);
}
else {
- return bc_get_cot(0.8, 0.8, 0.8, 1.0); //default white
+ return bc_get_cot(0.8, 0.8, 0.8, 1.0); /* default white */
}
}
@@ -1383,7 +1384,7 @@ bool bc_get_reflectivity(bNode *shader, double &reflectivity)
double bc_get_reflectivity(Material *ma)
{
- double reflectivity = ma->spec; // fallback if no socket found
+ double reflectivity = ma->spec; /* fallback if no socket found */
bNode *master_shader = bc_get_master_shader(ma);
if (ma->use_nodes && master_shader) {
bc_get_reflectivity(master_shader, reflectivity);
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index 49aee93c8a4..308a95c0e0c 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -30,15 +30,15 @@ set(INC
../imbuf
../makesdna
../makesrna
- ../windowmanager
../nodes
+ ../windowmanager
../nodes/composite
../nodes/intern
../render/extern/include
../render/intern/include
../../../extern/clew/include
- ../../../intern/guardedalloc
../../../intern/atomic
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h
index 9046a5e5dc3..55f68f2b5c1 100644
--- a/source/blender/compositor/COM_compositor.h
+++ b/source/blender/compositor/COM_compositor.h
@@ -26,6 +26,8 @@ extern "C" {
#include "DNA_color_types.h"
#include "DNA_node_types.h"
+/* Keep ascii art. */
+/* clang-format off */
/**
* \defgroup Model The data model of the compositor
* \defgroup Memory The memory management stuff
@@ -37,7 +39,8 @@ extern "C" {
* \page Introduction of the Blender Compositor
*
* \section bcomp Blender compositor
- * This project redesigns the internals of Blender's compositor. The project has been executed in 2011 by At Mind.
+ * This project redesigns the internals of Blender's compositor.
+ * The project has been executed in 2011 by At Mind.
* At Mind is a technology company located in Amsterdam, The Netherlands.
* The project has been crowd-funded. This code has been released under GPL2 to be used in Blender.
*
@@ -47,21 +50,24 @@ extern "C" {
* - Make the compositor work faster for you (workflow)
*
* \section speed Faster compositor
- * The speedup has been done by making better use of the hardware Blenders is working on. The previous compositor only
- * used a single threaded model to calculate a node. The only exception to this is the Defocus node.
+ * The speedup has been done by making better use of the hardware Blenders is working on.
+ * The previous compositor only used a single threaded model to calculate a node.
+ * The only exception to this is the Defocus node.
* Only when it is possible to calculate two full nodes in parallel a second thread was used.
* Current workstations have 8-16 threads available, and most of the time these are idle.
*
- * In the new compositor we want to use as much of threads as possible. Even new OpenCL capable GPU-hardware can be
- * used for calculation.
+ * In the new compositor we want to use as much of threads as possible.
+ * Even new OpenCL capable GPU-hardware can be used for calculation.
*
* \section workflow Work faster
- * The previous compositor only showed the final image. The compositor could wait a long time before seeing the result
- * of his work. The new compositor will work in a way that it will focus on getting information back to the user.
- * It will prioritize its work to get earlier user feedback.
+ * The previous compositor only showed the final image.
+ * The compositor could wait a long time before seeing the result of his work.
+ * The new compositor will work in a way that it will focus on
+ * getting information back to the user. It will prioritize its work to get earlier user feedback.
*
* \page memory Memory model
- * The main issue is the type of memory model to use. Blender is used by consumers and professionals.
+ * The main issue is the type of memory model to use.
+ * Blender is used by consumers and professionals.
* Ranging from low-end machines to very high-end machines.
* The system should work on high-end machines and on low-end machines.
* \page executing Executing
@@ -74,11 +80,15 @@ extern "C" {
* this all is controlled from \see ExecutionSystem.execute
*
* \section priority Render priority
- * Render priority is an priority of an output node. A user has a different need of Render priorities of output nodes
+ * Render priority is an priority of an output node.
+ * A user has a different need of Render priorities of output nodes
* than during editing.
- * for example. the Active ViewerNode has top priority during editing, but during rendering a CompositeNode has.
- * All NodeOperation has a setting for their render-priority, but only for output NodeOperation these have effect.
- * In ExecutionSystem.execute all priorities are checked. For every priority the ExecutionGroup's are check if the
+ * for example. the Active ViewerNode has top priority during editing,
+ * but during rendering a CompositeNode has.
+ * All NodeOperation has a setting for their render-priority,
+ * but only for output NodeOperation these have effect.
+ * In ExecutionSystem.execute all priorities are checked.
+ * For every priority the ExecutionGroup's are check if the
* priority do match.
* When match the ExecutionGroup will be executed (this happens in serial)
*
@@ -89,27 +99,35 @@ extern "C" {
* \section order Chunk order
*
* When a ExecutionGroup is executed, first the order of chunks are determined.
- * The settings are stored in the ViewerNode inside the ExecutionGroup. ExecutionGroups that have no viewer-node,
+ * The settings are stored in the ViewerNode inside the ExecutionGroup.
+ * ExecutionGroups that have no viewer-node,
* will use a default one.
* There are several possible chunk orders
- * - [@ref OrderOfChunks.COM_TO_CENTER_OUT]: Start calculating from a configurable point and order by nearest chunk
- * - [@ref OrderOfChunks.COM_TO_RANDOM]: Randomize all chunks.
- * - [@ref OrderOfChunks.COM_TO_TOP_DOWN]: Start calculation from the bottom to the top of the image
- * - [@ref OrderOfChunks.COM_TO_RULE_OF_THIRDS]: Experimental order based on 9 hot-spots in the image
+ * - [@ref OrderOfChunks.COM_TO_CENTER_OUT]:
+ * Start calculating from a configurable point and order by nearest chunk.
+ * - [@ref OrderOfChunks.COM_TO_RANDOM]:
+ * Randomize all chunks.
+ * - [@ref OrderOfChunks.COM_TO_TOP_DOWN]:
+ * Start calculation from the bottom to the top of the image.
+ * - [@ref OrderOfChunks.COM_TO_RULE_OF_THIRDS]:
+ * Experimental order based on 9 hot-spots in the image.
*
* When the chunk-order is determined, the first few chunks will be checked if they can be scheduled.
* Chunks can have three states:
- * - [@ref ChunkExecutionState.COM_ES_NOT_SCHEDULED]: Chunk is not yet scheduled, or dependencies are not met
- * - [@ref ChunkExecutionState.COM_ES_SCHEDULED]: All dependencies are met, chunk is scheduled, but not finished
- * - [@ref ChunkExecutionState.COM_ES_EXECUTED]: Chunk is finished
+ * - [@ref ChunkExecutionState.COM_ES_NOT_SCHEDULED]:
+ * Chunk is not yet scheduled, or dependencies are not met.
+ * - [@ref ChunkExecutionState.COM_ES_SCHEDULED]:
+ * All dependencies are met, chunk is scheduled, but not finished.
+ * - [@ref ChunkExecutionState.COM_ES_EXECUTED]:
+ * Chunk is finished.
*
* \see ExecutionGroup.execute
* \see ViewerOperation.getChunkOrder
* \see OrderOfChunks
*
* \section interest Area of interest
- * An ExecutionGroup can have dependencies to other ExecutionGroup's. Data passing from one ExecutionGroup to another
- * one are stored in 'chunks'.
+ * An ExecutionGroup can have dependencies to other ExecutionGroup's.
+ * Data passing from one ExecutionGroup to another one are stored in 'chunks'.
* If not all input chunks are available the chunk execution will not be scheduled.
* <pre>
* +-------------------------------------+ +--------------------------------------+
@@ -133,10 +151,12 @@ extern "C" {
* +---------------------------+
* </pre>
*
- * In the above example ExecutionGroup B has an outputoperation (ViewerOperation) and is being executed.
+ * In the above example ExecutionGroup B has an outputoperation (ViewerOperation)
+ * and is being executed.
* The first chunk is evaluated [@ref ExecutionGroup.scheduleChunkWhenPossible],
- * but not all input chunks are available. The relevant ExecutionGroup (that can calculate the missing chunks;
- * ExecutionGroup A) is asked to calculate the area ExecutionGroup B is missing.
+ * but not all input chunks are available.
+ * The relevant ExecutionGroup (that can calculate the missing chunks; ExecutionGroup A)
+ * is asked to calculate the area ExecutionGroup B is missing.
* [@ref ExecutionGroup.scheduleAreaWhenPossible]
* ExecutionGroup B checks what chunks the area spans, and tries to schedule these chunks.
* If all input data is available these chunks are scheduled [@ref ExecutionGroup.scheduleChunk]
@@ -200,47 +220,56 @@ extern "C" {
*
* </pre>
*
- * \see ExecutionGroup.execute Execute a complete ExecutionGroup. Halts until finished or breaked by user
+ * \see ExecutionGroup.execute Execute a complete ExecutionGroup.
+ * Halts until finished or breaked by user
* \see ExecutionGroup.scheduleChunkWhenPossible Tries to schedule a single chunk,
* checks if all input data is available. Can trigger dependent chunks to be calculated
- * \see ExecutionGroup.scheduleAreaWhenPossible Tries to schedule an area. This can be multiple chunks
+ * \see ExecutionGroup.scheduleAreaWhenPossible
+ * Tries to schedule an area. This can be multiple chunks
* (is called from [@ref ExecutionGroup.scheduleChunkWhenPossible])
* \see ExecutionGroup.scheduleChunk Schedule a chunk on the WorkScheduler
* \see NodeOperation.determineDependingAreaOfInterest Influence the area of interest of a chunk.
* \see WriteBufferOperation Operation to write to a MemoryProxy/MemoryBuffer
* \see ReadBufferOperation Operation to read from a MemoryProxy/MemoryBuffer
- * \see MemoryProxy proxy for information about memory image (a image consist out of multiple chunks)
+ * \see MemoryProxy proxy for information about memory image
+ * (a image consist out of multiple chunks)
* \see MemoryBuffer Allocated memory for a single chunk
*
* \section workscheduler WorkScheduler
- * the WorkScheduler is implemented as a static class. the responsibility of the WorkScheduler is to balance
- * WorkPackages to the available and free devices.
- * the work-scheduler can work in 2 states. For witching these between the state you need to recompile blender
+ * the WorkScheduler is implemented as a static class. the responsibility of the WorkScheduler
+ * is to balance WorkPackages to the available and free devices.
+ * the work-scheduler can work in 2 states.
+ * For witching these between the state you need to recompile blender
*
* \subsection multithread Multi threaded
* Default the work-scheduler will place all work as WorkPackage in a queue.
- * For every CPUcore a working thread is created. These working threads will ask the WorkScheduler if there is work
+ * For every CPUcore a working thread is created.
+ * These working threads will ask the WorkScheduler if there is work
* for a specific Device.
- * the work-scheduler will find work for the device and the device will be asked to execute the WorkPackage
+ * the work-scheduler will find work for the device and the device
+ * will be asked to execute the WorkPackage.
*
* \subsection singlethread Single threaded
- * For debugging reasons the multi-threading can be disabled. This is done by changing the COM_CURRENT_THREADING_MODEL
+ * For debugging reasons the multi-threading can be disabled.
+ * This is done by changing the COM_CURRENT_THREADING_MODEL
* to COM_TM_NOTHREAD. When compiling the work-scheduler
* will be changes to support no threading and run everything on the CPU.
*
* \section devices Devices
* A Device within the compositor context is a Hardware component that can used to calculate chunks.
* This chunk is encapsulated in a WorkPackage.
- * the WorkScheduler controls the devices and selects the device where a WorkPackage will be calculated.
+ * the WorkScheduler controls the devices and selects the device where a
+ * WorkPackage will be calculated.
*
* \subsection WS_Devices Workscheduler
- * The WorkScheduler controls all Devices. When initializing the compositor the WorkScheduler selects
- * all devices that will be used during compositor.
+ * The WorkScheduler controls all Devices.
+ * When initializing the compositor the WorkScheduler selects all
+ * devices that will be used during compositor.
* There are two types of Devices, CPUDevice and OpenCLDevice.
* When an ExecutionGroup schedules a Chunk the schedule method of the WorkScheduler
* The Workscheduler determines if the chunk can be run on an OpenCLDevice
- * (and that there are available OpenCLDevice). If this is the case the chunk will be added to the worklist for
- * OpenCLDevice's
+ * (and that there are available OpenCLDevice).
+ * If this is the case the chunk will be added to the worklist for OpenCLDevice's
* otherwise the chunk will be added to the worklist of CPUDevices.
*
* A thread will read the work-list and sends a workpackage to its device.
@@ -249,8 +278,8 @@ extern "C" {
* \see Device.execute method called to execute a chunk
*
* \subsection CPUDevice CPUDevice
- * When a CPUDevice gets a WorkPackage the Device will get the inputbuffer that is needed to calculate the chunk.
- * Allocation is already done by the ExecutionGroup.
+ * When a CPUDevice gets a WorkPackage the Device will get the inputbuffer that is needed to
+ * calculate the chunk. Allocation is already done by the ExecutionGroup.
* The outputbuffer of the chunk is being created.
* The OutputOperation of the ExecutionGroup is called to execute the area of the outputbuffer.
*
@@ -282,7 +311,8 @@ extern "C" {
* reference to the compositor editing tree
*
* \param rendering: [true false]
- * This parameter determines whether the function is called from rendering (true) or editing (false).
+ * This parameter determines whether the function is called from rendering
+ * (true) or editing (false).
* based on this setting the system will work differently:
* - during rendering only Composite & the File output node will be calculated
* \see NodeOperation.isOutputProgram(int rendering) of the specific operations
@@ -290,7 +320,8 @@ extern "C" {
* - during editing all output nodes will be calculated
* \see NodeOperation.isOutputProgram(int rendering) of the specific operations
*
- * - another quality setting can be used bNodeTree. The quality is determined by the bNodeTree fields.
+ * - another quality setting can be used bNodeTree.
+ * The quality is determined by the bNodeTree fields.
* quality can be modified by the user from within the node panels.
* \see bNodeTree.edit_quality
* \see bNodeTree.render_quality
@@ -309,6 +340,8 @@ extern "C" {
* should be checked further, probably it'll be also needed for preview
* generation in display space
*/
+/* clang-format off */
+
void COM_execute(RenderData *rd,
Scene *scene,
bNodeTree *editingtree,
diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h
index de731b8e0da..7a38ad721bc 100644
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@ -68,12 +68,14 @@ typedef enum CompositorPriority {
// workscheduler threading models
/**
- * COM_TM_QUEUE is a multithreaded model, which uses the BLI_thread_queue pattern. This is the default option.
+ * COM_TM_QUEUE is a multithreaded model, which uses the BLI_thread_queue pattern.
+ * This is the default option.
*/
#define COM_TM_QUEUE 1
/**
- * COM_TM_NOTHREAD is a single threading model, everything is executed in the caller thread. easy for debugging
+ * COM_TM_NOTHREAD is a single threading model, everything is executed in the caller thread.
+ * easy for debugging
*/
#define COM_TM_NOTHREAD 0
diff --git a/source/blender/compositor/intern/COM_CPUDevice.h b/source/blender/compositor/intern/COM_CPUDevice.h
index d82046a729f..1d411569146 100644
--- a/source/blender/compositor/intern/COM_CPUDevice.h
+++ b/source/blender/compositor/intern/COM_CPUDevice.h
@@ -23,7 +23,8 @@
/**
* \brief class representing a CPU device.
- * \note for every hardware thread in the system a CPUDevice instance will exist in the workscheduler
+ * \note for every hardware thread in the system a CPUDevice instance
+ * will exist in the workscheduler.
*/
class CPUDevice : public Device {
public:
diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h
index 466779ec9bd..f4cd60e3ee0 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.h
+++ b/source/blender/compositor/intern/COM_CompositorContext.h
@@ -33,8 +33,8 @@
class CompositorContext {
private:
/**
- * \brief The rendering field describes if we are rendering (F12) or if we are editing (Node editor)
- * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * \brief The rendering field describes if we are rendering (F12) or if we are editing (Node
+ * editor) This field is initialized in ExecutionSystem and must only be read from that point on.
* \see ExecutionSystem
*/
bool m_rendering;
diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h
index 0d7fc40de17..1213246b9c9 100644
--- a/source/blender/compositor/intern/COM_Converter.h
+++ b/source/blender/compositor/intern/COM_Converter.h
@@ -41,7 +41,8 @@ class Converter {
*
* For all nodetypes a wrapper class is created.
*
- * \note When adding a new node to blender, this method needs to be changed to return the correct Node instance.
+ * \note When adding a new node to blender, this method needs to be changed to return the correct
+ * Node instance.
*
* \see Node
*/
@@ -55,7 +56,8 @@ class Converter {
static bool is_fast_node(bNode *b_node);
/**
- * \brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type.
+ * \brief This method will add a datetype conversion rule when the to-socket does not support the
+ * from-socket actual data type.
*
* \note this method is called when conversion is needed.
*
diff --git a/source/blender/compositor/intern/COM_Debug.cpp b/source/blender/compositor/intern/COM_Debug.cpp
index 8632b7ad0f0..72c1e0cf316 100644
--- a/source/blender/compositor/intern/COM_Debug.cpp
+++ b/source/blender/compositor/intern/COM_Debug.cpp
@@ -367,8 +367,12 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
system, operation, group, str + len, maxlen > len ? maxlen - len : 0);
}
- // len += snprintf(str+len, maxlen>len ? maxlen-len : 0, "// OUTPUTOPERATION: %p\r\n", group->getOutputOperation());
- // len += snprintf(str+len, maxlen>len ? maxlen-len : 0, " O_%p\r\n", group->getOutputOperation());
+ // len += snprintf(str+len,
+ // maxlen>len ? maxlen-len : 0,
+ // "// OUTPUTOPERATION: %p\r\n", group->getOutputOperation());
+ // len += snprintf(
+ // str+len, maxlen>len ? maxlen-len : 0,
+ // " O_%p\r\n", group->getOutputOperation());
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
}
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
index 367362c2c66..1718722e860 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -86,7 +86,8 @@ bool ExecutionGroup::canContainOperation(NodeOperation *operation)
if (m_complex) {
return false;
}
- /* complex ops can't be added to other groups (except their own, which they initialize, see above) */
+ /* complex ops can't be added to other groups (except their own, which they initialize, see
+ * above) */
if (operation->isComplex()) {
return false;
}
@@ -188,7 +189,8 @@ void ExecutionGroup::determineNumberOfChunks()
}
/**
- * this method is called for the top execution groups. containing the compositor node or the preview node or the viewer node)
+ * this method is called for the top execution groups. containing the compositor node or the
+ * preview node or the viewer node)
*/
void ExecutionGroup::execute(ExecutionSystem *graph)
{
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h
index ff9ac5d0582..41ae6f1c5b2 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.h
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.h
@@ -55,7 +55,8 @@ typedef enum ChunkExecutionState {
/**
* \brief Class ExecutionGroup is a group of Operations that are executed as one.
- * This grouping is used to combine Operations that can be executed as one whole when multi-processing.
+ * This grouping is used to combine Operations that can be executed as one whole when
+ * multi-processing.
* \ingroup Execution
*/
class ExecutionGroup {
@@ -72,7 +73,8 @@ class ExecutionGroup {
/**
* \brief is this ExecutionGroup an input ExecutionGroup
- * an input execution group is a group that is at the end of the calculation (the output is important for the user)
+ * an input execution group is a group that is at the end of the calculation
+ * (the output is important for the user).
*/
int m_isOutput;
@@ -134,8 +136,9 @@ class ExecutionGroup {
Operations m_cachedReadOperations;
/**
- * \brief reference to the original bNodeTree, this field is only set for the 'top' execution group.
- * \note can only be used to call the callbacks for progress, status and break
+ * \brief reference to the original bNodeTree,
+ * this field is only set for the 'top' execution group.
+ * \note can only be used to call the callbacks for progress, status and break.
*/
const bNodeTree *m_bTree;
@@ -154,7 +157,8 @@ class ExecutionGroup {
/**
* \brief indicator when this ExecutionGroup has valid Operations in its vector for Execution
- * \note When building the ExecutionGroup Operations are added via recursion. First a WriteBufferOperations is added, then the
+ * \note When building the ExecutionGroup Operations are added via recursion.
+ * First a WriteBufferOperations is added, then the.
* \note Operation containing the settings that is important for the ExecutiongGroup is added,
* \note When this occurs, these settings are copied over from the node to the ExecutionGroup
* \note and the Initialized flag is set to true.
@@ -204,7 +208,8 @@ class ExecutionGroup {
/**
* \brief try to schedule a specific chunk.
- * \note scheduling succeeds when all input requirements are met and the chunks hasn't been scheduled yet.
+ * \note scheduling succeeds when all input requirements are met and the chunks hasn't been
+ * scheduled yet.
* \param graph:
* \param xChunk:
* \param yChunk:
@@ -375,9 +380,11 @@ class ExecutionGroup {
/**
* \brief schedule an ExecutionGroup
- * \note this method will return when all chunks have been calculated, or the execution has breaked (by user)
+ * \note this method will return when all chunks have been calculated, or the execution has
+ * breaked (by user)
*
- * first the order of the chunks will be determined. This is determined by finding the ViewerOperation and get the relevant information from it.
+ * first the order of the chunks will be determined. This is determined by finding the
+ * ViewerOperation and get the relevant information from it.
* - ChunkOrdering
* - CenterX
* - CenterY
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
index 55c2ed6c22b..009b1fb28cd 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -30,12 +30,13 @@ class ExecutionGroup;
/**
* \page execution Execution model
- * In order to get to an efficient model for execution, several steps are being done. these steps are explained below.
+ * In order to get to an efficient model for execution, several steps are being done. these steps
+ * are explained below.
*
* \section EM_Step1 Step 1: translating blender node system to the new compsitor system
- * Blenders node structure is based on C structs (DNA). These structs are not efficient in the new architecture.
- * We want to use classes in order to simplify the system.
- * during this step the blender node_tree is evaluated and converted to a CPP node system.
+ * Blenders node structure is based on C structs (DNA). These structs are not efficient in the new
+ * architecture. We want to use classes in order to simplify the system. during this step the
+ * blender node_tree is evaluated and converted to a CPP node system.
*
* \see ExecutionSystem
* \see Converter.convert
@@ -43,35 +44,41 @@ class ExecutionGroup;
*
* \section EM_Step2 Step2: translating nodes to operations
* Ungrouping the GroupNodes. Group nodes are node_tree's in node_tree's.
- * The new system only supports a single level of node_tree. We will 'flatten' the system in a single level.
+ * The new system only supports a single level of node_tree.
+ * We will 'flatten' the system in a single level.
* \see GroupNode
* \see ExecutionSystemHelper.ungroup
*
- * Every node has the ability to convert itself to operations. The node itself is responsible to create a correct
- * NodeOperation setup based on its internal settings.
- * Most Node only need to convert it to its NodeOperation. Like a ColorToBWNode doesn't check anything,
- * but replaces itself with a ConvertColorToBWOperation.
- * More complex nodes can use different NodeOperation based on settings; like MixNode.
- * based on the selected Mixtype a different operation will be used.
- * for more information see the page about creating new Nodes. [@subpage newnode]
+ * Every node has the ability to convert itself to operations. The node itself is responsible to
+ * create a correct NodeOperation setup based on its internal settings. Most Node only need to
+ * convert it to its NodeOperation. Like a ColorToBWNode doesn't check anything, but replaces
+ * itself with a ConvertColorToBWOperation. More complex nodes can use different NodeOperation
+ * based on settings; like MixNode. based on the selected Mixtype a different operation will be
+ * used. for more information see the page about creating new Nodes. [@subpage newnode]
*
* \see ExecutionSystem.convertToOperations
* \see Node.convertToOperations
* \see NodeOperation base class for all operations in the system
*
* \section EM_Step3 Step3: add additional conversions to the operation system
- * - Data type conversions: the system has 3 data types COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR.
- * The user can connect a Value socket to a color socket.
- * As values are ordered differently than colors a conversion happens.
+ * - Data type conversions: the system has 3 data types COM_DT_VALUE, COM_DT_VECTOR,
+ * COM_DT_COLOR. The user can connect a Value socket to a color socket. As values are ordered
+ * differently than colors a conversion happens.
*
* - Image size conversions: the system can automatically convert when resolutions do not match.
* An NodeInput has a resize mode. This can be any of the following settings.
- * - [@ref InputSocketResizeMode.COM_SC_CENTER]: The center of both images are aligned
- * - [@ref InputSocketResizeMode.COM_SC_FIT_WIDTH]: The width of both images are aligned
- * - [@ref InputSocketResizeMode.COM_SC_FIT_HEIGHT]: the height of both images are aligned
- * - [@ref InputSocketResizeMode.COM_SC_FIT]: The width, or the height of both images are aligned to make sure that it fits.
- * - [@ref InputSocketResizeMode.COM_SC_STRETCH]: The width and the height of both images are aligned
- * - [@ref InputSocketResizeMode.COM_SC_NO_RESIZE]: bottom left of the images are aligned.
+ * - [@ref InputSocketResizeMode.COM_SC_CENTER]:
+ * The center of both images are aligned
+ * - [@ref InputSocketResizeMode.COM_SC_FIT_WIDTH]:
+ * The width of both images are aligned
+ * - [@ref InputSocketResizeMode.COM_SC_FIT_HEIGHT]:
+ * The height of both images are aligned
+ * - [@ref InputSocketResizeMode.COM_SC_FIT]:
+ * The width, or the height of both images are aligned to make sure that it fits.
+ * - [@ref InputSocketResizeMode.COM_SC_STRETCH]:
+ * The width and the height of both images are aligned.
+ * - [@ref InputSocketResizeMode.COM_SC_NO_RESIZE]:
+ * Bottom left of the images are aligned.
*
* \see Converter.convertDataType Datatype conversions
* \see Converter.convertResolution Image size conversions
@@ -79,8 +86,8 @@ class ExecutionGroup;
* \section EM_Step4 Step4: group operations in executions groups
* ExecutionGroup are groups of operations that are calculated as being one bigger operation.
* All operations will be part of an ExecutionGroup.
- * Complex nodes will be added to separate groups. Between ExecutionGroup's the data will be stored in MemoryBuffers.
- * ReadBufferOperations and WriteBufferOperations are added where needed.
+ * Complex nodes will be added to separate groups. Between ExecutionGroup's the data will be stored
+ * in MemoryBuffers. ReadBufferOperations and WriteBufferOperations are added where needed.
*
* <pre>
*
@@ -127,7 +134,7 @@ class ExecutionSystem {
*/
Groups m_groups;
- private: //methods
+ private: // methods
/**
* find all execution group with output nodes
*/
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index 01a8a86bb15..df936818f33 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -35,7 +35,8 @@ extern "C" {
* \ingroup Memory
*/
typedef enum MemoryBufferState {
- /** \brief memory has been allocated on creator device and CPU machine, but kernel has not been executed */
+ /** \brief memory has been allocated on creator device and CPU machine,
+ * but kernel has not been executed */
COM_MB_ALLOCATED = 1,
/** \brief memory is available for use, content has been created */
COM_MB_AVAILABLE = 2,
diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h
index 9bacf271283..c26f6cdfb8b 100644
--- a/source/blender/compositor/intern/COM_Node.h
+++ b/source/blender/compositor/intern/COM_Node.h
@@ -112,7 +112,8 @@ class Node {
/**
* \brief set the reference to the bNode
- * \note used in Node instances to receive the storage/settings and complex node for highlight during execution
+ * \note used in Node instances to receive the storage/settings and complex
+ * node for highlight during execution.
* \param bNode:
*/
void setbNode(bNode *node)
diff --git a/source/blender/compositor/intern/COM_NodeGraph.cpp b/source/blender/compositor/intern/COM_NodeGraph.cpp
index 39dc946f3bc..b4d6cc0ff60 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.cpp
+++ b/source/blender/compositor/intern/COM_NodeGraph.cpp
@@ -303,7 +303,8 @@ void NodeGraph::add_proxies_group(const CompositorContext &context,
/* missing node group datablock can happen with library linking */
if (!b_group_tree) {
- /* this error case its handled in convertToOperations() so we don't get un-convertred sockets */
+ /* This error case its handled in convertToOperations()
+ * so we don't get un-converted sockets. */
return;
}
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index 968dc171bd3..af9ed2648c9 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -53,17 +53,21 @@ class NodeOperationOutput;
* \ingroup Model
*/
typedef enum InputResizeMode {
- /** \brief Center the input image to the center of the working area of the node, no resizing occurs */
+ /** \brief Center the input image to the center of the working area of the node, no resizing
+ occurs */
COM_SC_CENTER = NS_CR_CENTER,
- /** \brief The bottom left of the input image is the bottom left of the working area of the node, no resizing occurs */
+ /** \brief The bottom left of the input image is the bottom left of the working area of the node,
+ no resizing occurs */
COM_SC_NO_RESIZE = NS_CR_NONE,
/** \brief Fit the width of the input image to the width of the working area of the node */
COM_SC_FIT_WIDTH = NS_CR_FIT_WIDTH,
/** \brief Fit the height of the input image to the height of the working area of the node */
COM_SC_FIT_HEIGHT = NS_CR_FIT_HEIGHT,
- /** \brief Fit the width or the height of the input image to the width or height of the working area of the node, image will be larger than the working area */
+ /** \brief Fit the width or the height of the input image to the width or height of the working
+ area of the node, image will be larger than the working area */
COM_SC_FIT = NS_CR_FIT,
- /** \brief Fit the width and the height of the input image to the width and height of the working area of the node, image will be equally larger than the working area */
+ /** \brief Fit the width and the height of the input image to the width and height of the working
+ area of the node, image will be equally larger than the working area */
COM_SC_STRETCH = NS_CR_STRETCH,
} InputResizeMode;
@@ -158,9 +162,11 @@ class NodeOperation : public SocketReader {
unsigned int preferredResolution[2]);
/**
- * \brief isOutputOperation determines whether this operation is an output of the ExecutionSystem during rendering or editing.
+ * \brief isOutputOperation determines whether this operation is an output of the ExecutionSystem
+ * during rendering or editing.
*
- * Default behavior if not overridden, this operation will not be evaluated as being an output of the ExecutionSystem.
+ * Default behavior if not overridden, this operation will not be evaluated as being an output of
+ * the ExecutionSystem.
*
* \see ExecutionSystem
* \group check
@@ -218,7 +224,8 @@ class NodeOperation : public SocketReader {
}
/**
- * \brief custom handle to add new tasks to the OpenCL command queue in order to execute a chunk on an GPUDevice
+ * \brief custom handle to add new tasks to the OpenCL command queue
+ * in order to execute a chunk on an GPUDevice.
* \ingroup execution
* \param context: the OpenCL context
* \param program: the OpenCL program containing all compositor kernels
@@ -226,8 +233,10 @@ class NodeOperation : public SocketReader {
* \param outputMemoryBuffer: the allocated memory buffer in main CPU memory
* \param clOutputBuffer: the allocated memory buffer in OpenCLDevice memory
* \param inputMemoryBuffers: all input MemoryBuffer's needed
- * \param clMemToCleanUp: all created cl_mem references must be added to this list. Framework will clean this after execution
- * \param clKernelsToCleanUp: all created cl_kernel references must be added to this list. Framework will clean this after execution
+ * \param clMemToCleanUp: all created cl_mem references must be added to this list.
+ * Framework will clean this after execution
+ * \param clKernelsToCleanUp: all created cl_kernel references must be added to this list.
+ * Framework will clean this after execution
*/
virtual void executeOpenCL(OpenCLDevice * /*device*/,
MemoryBuffer * /*outputMemoryBuffer*/,
@@ -297,7 +306,8 @@ class NodeOperation : public SocketReader {
/**
* \brief is this operation the active viewer output
- * user can select an ViewerNode to be active (the result of this node will be drawn on the backdrop)
+ * user can select an ViewerNode to be active
+ * (the result of this node will be drawn on the backdrop).
* \return [true:false]
* \see BaseViewerOperation
*/
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
index 853e0e768d3..2b17fc0e5f7 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
@@ -84,7 +84,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
const OpInputs &op_to_list = find_operation_inputs(inverse_input_map, to);
if (!op_from || op_to_list.empty()) {
/* XXX allow this? error/debug message? */
- //BLI_assert(false);
+ // BLI_assert(false);
/* XXX note: this can happen with certain nodes (e.g. OutputFile)
* which only generate operations in certain circumstances (rendering)
* just let this pass silently for now ...
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index c3d1e0cf511..48af823f8f5 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -58,7 +58,8 @@ static ThreadQueue *g_gpuqueue;
# ifdef COM_OPENCL_ENABLED
static cl_context g_context;
static cl_program g_program;
-/// \brief list of all OpenCLDevices. for every OpenCL GPU device an instance of OpenCLDevice is created
+/// \brief list of all OpenCLDevices. for every OpenCL GPU device an instance of OpenCLDevice is
+/// created
static vector<OpenCLDevice *> g_gpudevices;
/// \brief list of all thread for every GPUDevice in cpudevices a thread exists
static ListBase g_gputhreads;
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.h b/source/blender/compositor/intern/COM_WorkScheduler.h
index 2b523272123..390fde82b61 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.h
+++ b/source/blender/compositor/intern/COM_WorkScheduler.h
@@ -67,9 +67,10 @@ class WorkScheduler {
*
* during initialization the mutexes are initialized.
* there are two mutexes (for every device type one)
- * After mutex initialization the system is queried in order to count the number of CPUDevices and GPUDevices to be created.
- * For every hardware thread a CPUDevice and for every OpenCL GPU device a OpenCLDevice is created.
- * these devices are stored in a separate list (cpudevices & gpudevices)
+ * After mutex initialization the system is queried in order to count the number of CPUDevices
+ * and GPUDevices to be created. For every hardware thread a CPUDevice and for every OpenCL GPU
+ * device a OpenCLDevice is created. these devices are stored in a separate list (cpudevices &
+ * gpudevices)
*
* This function can be called multiple times to lazily initialize OpenCL.
*/
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
index cde94b23ed8..50fbe983c91 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
@@ -92,7 +92,8 @@ void DilateErodeNode::convertToOperations(NodeConverter &converter,
converter.addOperation(operationx);
converter.mapInputSocket(getInputSocket(0), operationx->getInputSocket(0));
- // converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1)); // no size input yet
+ // converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1)); // no size input
+ // yet
GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
operationy->setData(&m_alpha_blur);
@@ -101,7 +102,8 @@ void DilateErodeNode::convertToOperations(NodeConverter &converter,
converter.addOperation(operationy);
converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
- // converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1)); // no size input yet
+ // converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1)); // no size input
+ // yet
converter.mapOutputSocket(getOutputSocket(0), operationy->getOutputSocket());
converter.addPreview(operationy->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_FlipNode.cpp b/source/blender/compositor/nodes/COM_FlipNode.cpp
index 59b881bfcf7..4dfff9c8e49 100644
--- a/source/blender/compositor/nodes/COM_FlipNode.cpp
+++ b/source/blender/compositor/nodes/COM_FlipNode.cpp
@@ -33,7 +33,8 @@ void FlipNode::convertToOperations(NodeConverter &converter,
NodeOutput *outputSocket = this->getOutputSocket(0);
FlipOperation *operation = new FlipOperation();
switch (this->getbNode()->custom1) {
- case 0: /// \TODO: I didn't find any constants in the old implementation, should I introduce them.
+ case 0: /// \TODO: I didn't find any constants in the old implementation, should I introduce
+ /// them.
operation->setFlipX(true);
operation->setFlipY(false);
break;
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
index 5628c575b70..44cb4056c99 100644
--- a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
@@ -44,7 +44,8 @@ void BilateralBlurOperation::initExecution()
void BilateralBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- // read the determinator color at x, y, this will be used as the reference color for the determinator
+ // read the determinator color at x, y, this will be used as the reference color for the
+ // determinator
float determinatorReferenceColor[4];
float determinator[4];
float tempColor[4];
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h
index 58a1e2f85d8..2bb3e5bc1ab 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.h
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.h
@@ -21,8 +21,8 @@
#include "COM_NodeOperation.h"
/**
- * \brief The BokehImageOperation class is an operation that creates an image useful to mimic the internals
- *of a camera.
+ * \brief The BokehImageOperation class is an operation that creates an image useful to mimic the
+ *internals of a camera.
*
* features:
* - number of flaps
@@ -31,20 +31,21 @@
* - simulate catadioptric
* - simulate lensshift
*
- * Per pixel the algorithm determines the edge of the bokeh on the same line as the center of the image and the pixel
- * is evaluating.
+ * Per pixel the algorithm determines the edge of the bokeh on the same line as the center of the
+ *image and the pixel is evaluating.
*
- * The edge is detected by finding the closest point on the direct line between the two nearest flap-corners.
- * this edge is interpolated with a full circle.
- * Result of this edge detection is stored as the distance between the center of the image and the edge.
+ * The edge is detected by finding the closest point on the direct line between the two nearest
+ *flap-corners. this edge is interpolated with a full circle. Result of this edge detection is
+ *stored as the distance between the center of the image and the edge.
*
- * catadioptric lenses are simulated to interpolate between the center of the image and the distance of the edge.
- * We now have three distances:
+ * catadioptric lenses are simulated to interpolate between the center of the image and the
+ *distance of the edge. We now have three distances:
* - distance between the center of the image and the pixel to be evaluated
* - distance between the center of the image and the outer-edge
* - distance between the center of the image and the inner-edge
*
- * With a simple compare it can be detected if the evaluated pixel is between the outer and inner edge.
+ * With a simple compare it can be detected if the evaluated pixel is between the outer and inner
+ *edge.
*/
class BokehImageOperation : public NodeOperation {
private:
@@ -95,7 +96,8 @@ class BokehImageOperation : public NodeOperation {
/**
* \brief Determine if a coordinate is inside the bokeh image
*
- * \param distance: the distance that will be used. This parameter is modified a bit to mimic lens shifts
+ * \param distance: the distance that will be used.
+ * This parameter is modified a bit to mimic lens shifts.
* \param x: the x coordinate of the pixel to evaluate
* \param y: the y coordinate of the pixel to evaluate
* \return float range 0..1 0 is completely outside
@@ -121,9 +123,8 @@ class BokehImageOperation : public NodeOperation {
void deinitExecution();
/**
- * \brief determine the resolution of this operation. currently fixed at [COM_BLUR_BOKEH_PIXELS, COM_BLUR_BOKEH_PIXELS]
- * \param resolution:
- * \param preferredResolution:
+ * \brief determine the resolution of this operation. currently fixed at [COM_BLUR_BOKEH_PIXELS,
+ * COM_BLUR_BOKEH_PIXELS] \param resolution: \param preferredResolution:
*/
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
index 3f5c0896221..7fb9d839d2d 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
@@ -22,7 +22,8 @@
#include "DNA_node_types.h"
#include "COM_CalculateMeanOperation.h"
/**
- * \brief base class of CalculateStandardDeviation, implementing the simple CalculateStandardDeviation
+ * \brief base class of CalculateStandardDeviation,
+ * implementing the simple CalculateStandardDeviation.
* \ingroup operation
*/
class CalculateStandardDeviationOperation : public CalculateMeanOperation {
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
index c48c39f7726..68b5af3089a 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
@@ -24,7 +24,8 @@ inline float colorbalance_lgg(float in, float lift_lgg, float gamma_inv, float g
/* 1:1 match with the sequencer with linear/srgb conversions, the conversion isnt pretty
* but best keep it this way, sice testing for durian shows a similar calculation
* without lin/srgb conversions gives bad results (over-saturated shadows) with colors
- * slightly below 1.0. some correction can be done but it ends up looking bad for shadows or lighter tones - campbell */
+ * slightly below 1.0. some correction can be done but it ends up looking bad for shadows or
+ * lighter tones - campbell */
float x = (((linearrgb_to_srgb(in) - 1.0f) * lift_lgg) + 1.0f) * gain;
/* prevent NaN */
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
index c47e4d560a5..704f7cfad39 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
@@ -95,7 +95,8 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4],
#endif
radius = 0.5f * fabsf(this->m_aperture *
(this->m_dof_sp * (this->m_inverseFocalDistance - iZ) - 1.0f));
- // 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates the problem
+ // 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates
+ // the problem
if (radius < 0.0f) {
radius = 0.0f;
}
diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cpp b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
index 807450040de..9b8d72da26d 100644
--- a/source/blender/compositor/operations/COM_DespeckleOperation.cpp
+++ b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
@@ -70,7 +70,7 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void * /*da
CLAMP(y3, 0, getHeight() - 1);
float value[4];
this->m_inputValueOperation->read(value, x2, y2, NULL);
- //const float mval = 1.0f - value[0];
+ // const float mval = 1.0f - value[0];
this->m_inputOperation->read(color_org, x2, y2, NULL);
@@ -115,7 +115,7 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void * /*da
COLOR_ADD(TOT_DIV_CNR)
mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2)));
- //mul_v4_fl(color_mid, 1.0f / w);
+ // mul_v4_fl(color_mid, 1.0f / w);
if ((w != 0.0f) && ((w / WTOT) > (this->m_threshold_neighbor)) &&
color_diff(color_mid, color_org, this->m_threshold)) {
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
index cd1dae2c9b5..f872388e3c7 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
@@ -950,12 +950,16 @@ static void do_createEdgeLocationBuffer(unsigned int t,
unsigned int rsl; // long used for finding fast 1.0/sqrt
unsigned int gradientFillOffset;
- unsigned int innerAccum =
- 0; // for looping inner edge pixel indexes, represents current position from offset
- unsigned int outerAccum =
- 0; // for looping outer edge pixel indexes, represents current position from offset
- unsigned int gradientAccum =
- 0; // for looping gradient pixel indexes, represents current position from offset
+
+ /* For looping inner edge pixel indexes, represents current position from offset. */
+ unsigned int innerAccum = 0;
+ /* For looping outer edge pixel indexes, represents current position from offset. */
+ unsigned int outerAccum = 0;
+ /* For looping gradient pixel indexes, represents current position from offset. */
+ unsigned int gradientAccum = 0;
+
+ /* */
+ /* clang-format off */
/*
* Here we compute the size of buffer needed to hold (row,col) coordinates
* for each pixel previously determined to be either gradient, inner edge,
@@ -1017,6 +1021,7 @@ static void do_createEdgeLocationBuffer(unsigned int t,
* each iteration of the final gradient calculation than it is to deconstruct
* a memory location into x,y pairs each round.
*/
+ /* clang-format on */
gradientFillOffset = 0; // since there are likely "more" of these, put it first. :)
*innerEdgeOffset = gradientFillOffset + gsz; // set start of inner edge indexes
@@ -1025,7 +1030,7 @@ static void do_createEdgeLocationBuffer(unsigned int t,
gradientAccum = gradientFillOffset; // each accumulator variable starts at its respective
innerAccum = *innerEdgeOffset; // section's offset so when we start filling, each
outerAccum = *outerEdgeOffset; // section fills up it's allocated space in gbuf
- //uses dmin=row, rsl=col
+ // uses dmin=row, rsl=col
for (x = 0, dmin = 0; x < t; x += rw, dmin++) {
for (rsl = 0; rsl < rw; rsl++) {
a = x + rsl;
@@ -1187,7 +1192,7 @@ static void do_fillGradientBuffer(unsigned int rw,
* Pixel Index = Pixel Column + ( Pixel Row * Row Width )
*/
res[gbuf[gradientFillOffset + 1] + (gbuf[gradientFillOffset] * rw)] =
- (idist / (idist + odist)); //set intensity
+ (idist / (idist + odist)); // set intensity
}
}
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index 8d11328b63b..2c12091c458 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -147,7 +147,8 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
}
// see "Recursive Gabor Filtering" by Young/VanVliet
- // all factors here in double.prec. Required, because for single.prec it seems to blow up if sigma > ~200
+ // all factors here in double.prec.
+ // Required, because for single.prec it seems to blow up if sigma > ~200
if (sigma >= 3.556f) {
q = 0.9804f * (sigma - 3.556f) + 2.5091f;
}
diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
index ff75fb7090f..30a6a05ed2c 100644
--- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
@@ -83,7 +83,7 @@ static void FHT(fREAL *data, unsigned int M, unsigned int inverse)
n2 = n >> 1;
if (n > 2) {
fc = dc = cos(a);
- fs = ds = sqrt(1.0 - fc * fc); //sin(a);
+ fs = ds = sqrt(1.0 - fc * fc); // sin(a);
bd = n - 2;
for (bl = 1; bl < n2; bl++) {
fREAL *data_nbd = &data_n[bd];
@@ -154,7 +154,7 @@ static void FHT2D(
for (i = 0; stm > 0; i++) {
#define PRED(k) (((k & Nym) << Mx) + (k >> My))
for (j = PRED(i); j > i; j = PRED(j)) {
- ;
+ /* pass */
}
if (j < i) {
continue;
@@ -431,7 +431,7 @@ void GlareFogGlowOperation::generateGlare(float *data,
fcol[1] = expf(d * cs_g);
fcol[2] = expf(d * cs_b);
// linear window good enough here, visual result counts, not scientific analysis
- //w = (1.0f-fabs(u))*(1.0f-fabs(v));
+ // w = (1.0f-fabs(u))*(1.0f-fabs(v));
// actually, Hanning window is ok, cos^2 for some reason is slower
w = (0.5f + 0.5f * cosf(u * (float)M_PI)) * (0.5f + 0.5f * cosf(v * (float)M_PI));
mul_v3_fl(fcol, w);
diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.cpp b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
index 46bd015163b..ff5804a63a4 100644
--- a/source/blender/compositor/operations/COM_MapRangeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
@@ -39,7 +39,8 @@ void MapRangeOperation::initExecution()
this->m_destMaxOperation = this->getInputSocketReader(4);
}
-/* The code below assumes all data is inside range +- this, and that input buffer is single channel */
+/* The code below assumes all data is inside range +- this, and that input buffer is single channel
+ */
#define BLENDER_ZMAX 10000.0f
void MapRangeOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.cpp b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
index da594be2268..f7e689fa008 100644
--- a/source/blender/compositor/operations/COM_NormalizeOperation.cpp
+++ b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
@@ -80,7 +80,8 @@ bool NormalizeOperation::determineDependingAreaOfInterest(rcti * /*input*/,
return false;
}
-/* The code below assumes all data is inside range +- this, and that input buffer is single channel */
+/* The code below assumes all data is inside range +- this, and that input buffer is single channel
+ */
#define BLENDER_ZMAX 10000.0f
void *NormalizeOperation::initializeTileData(rcti *rect)
diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
index f6cbb8f69c1..9d1be09de0e 100644
--- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
@@ -39,7 +39,7 @@ extern "C" {
#include "IMB_imbuf_types.h"
}
-/************************************ OpenEXR Singlelayer Multiview *****************************************/
+/************************************ OpenEXR Singlelayer Multiview ******************************/
OutputOpenExrSingleLayerMultiViewOperation::OutputOpenExrSingleLayerMultiViewOperation(
const RenderData *rd,
@@ -142,7 +142,7 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinitExecution()
}
}
-/************************************ OpenEXR Multilayer Multiview *****************************************/
+/************************************ OpenEXR Multilayer Multiview *******************************/
OutputOpenExrMultiLayerMultiViewOperation::OutputOpenExrMultiLayerMultiViewOperation(
const RenderData *rd,
diff --git a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
index 90bc859a1bb..313be2f5ecf 100644
--- a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
+++ b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
@@ -223,5 +223,8 @@ bool PlaneCornerPinWarpImageOperation::determineDependingAreaOfInterest(
output->xmax = getInputOperation(0)->getWidth();
output->ymax = getInputOperation(0)->getHeight();
return true;
- // return PlaneDistortWarpImageOperation::determineDependingAreaOfInterest(input, readOperation, output);
+#if 0
+ return PlaneDistortWarpImageOperation::determineDependingAreaOfInterest(
+ input, readOperation, output);
+#endif
}
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp
index 3663d56dc87..1c5b2a71859 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp
@@ -155,7 +155,7 @@ void ScaleAbsoluteOperation::executePixelSampled(float output[4],
const float width = this->getWidth();
const float height = this->getHeight();
- //div
+ // div
float relativeXScale = scx / width;
float relativeYScale = scy / height;
@@ -181,7 +181,7 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input,
const float scy = scaleY[0];
const float width = this->getWidth();
const float height = this->getHeight();
- //div
+ // div
float relateveXScale = scx / width;
float relateveYScale = scy / height;
diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
index 80b1c1f798a..6f47e0e190b 100644
--- a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
+++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
@@ -146,8 +146,8 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator {
* Perform the actual accumulation along a ray segment from source to pt.
* Only pixels within dist_min..dist_max contribute.
*
- * The loop runs backwards(!) over the primary sector space axis u, i.e. increasing distance to pt.
- * After each step it decrements v by dv < 1, adding a buffer shift when necessary.
+ * The loop runs backwards(!) over the primary sector space axis u, i.e. increasing distance to
+ * pt. After each step it decrements v by dv < 1, adding a buffer shift when necessary.
*/
static void eval(MemoryBuffer *input,
float output[4],
@@ -229,11 +229,12 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator {
};
/**
- * Dispatch function which selects an appropriate accumulator based on the sector of the target point,
- * relative to the source.
+ * Dispatch function which selects an appropriate accumulator based on the sector of the target
+ * point, relative to the source.
*
* The BufferLineAccumulator defines the actual loop over the buffer, with an efficient inner loop
- * due to using compile time constants instead of a local matrix variable defining the sector space.
+ * due to using compile time constants instead of a local matrix variable defining the sector
+ * space.
*/
static void accumulate_line(MemoryBuffer *input,
float output[4],
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
index 4cc9d7a748c..f2d78845b6c 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cpp
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -29,8 +29,8 @@ extern "C" {
TextureBaseOperation::TextureBaseOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VECTOR); //offset
- this->addInputSocket(COM_DT_VECTOR); //size
+ this->addInputSocket(COM_DT_VECTOR); // offset
+ this->addInputSocket(COM_DT_VECTOR); // size
this->m_texture = NULL;
this->m_inputSize = NULL;
this->m_inputOffset = NULL;
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
index fb86b04cff7..8e67b8ac786 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -46,7 +46,7 @@ VectorBlurOperation::VectorBlurOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE); // ZBUF
- this->addInputSocket(COM_DT_COLOR); //SPEED
+ this->addInputSocket(COM_DT_COLOR); // SPEED
this->addOutputSocket(COM_DT_COLOR);
this->m_settings = NULL;
this->m_cachedInstance = NULL;
@@ -409,7 +409,8 @@ static void zbuf_fill_in_rgba(
}
/* char value==255 is filled in, rest should be zero */
-/* returns alpha values, but sets alpha to 1 for zero alpha pixels that have an alpha value as neighbor */
+/* returns alpha values,
+ * but sets alpha to 1 for zero alpha pixels that have an alpha value as neighbor. */
void antialias_tagbuf(int xsize, int ysize, char *rectmove)
{
char *row1, *row2, *row3;
diff --git a/source/blender/compositor/operations/COM_WrapOperation.cpp b/source/blender/compositor/operations/COM_WrapOperation.cpp
index cb119fb4f1d..c25e8ba897c 100644
--- a/source/blender/compositor/operations/COM_WrapOperation.cpp
+++ b/source/blender/compositor/operations/COM_WrapOperation.cpp
@@ -53,7 +53,7 @@ void WrapOperation::executePixelSampled(float output[4], float x, float y, Pixel
MemoryBufferExtend extend_x = COM_MB_CLIP, extend_y = COM_MB_CLIP;
switch (m_wrappingType) {
case CMP_NODE_WRAP_NONE:
- //Intentionally empty, originalXPos and originalYPos have been set before
+ // Intentionally empty, originalXPos and originalYPos have been set before
break;
case CMP_NODE_WRAP_X:
// wrap only on the x-axis
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
index 222f42e8241..767280e2cd2 100644
--- a/source/blender/compositor/operations/COM_ZCombineOperation.cpp
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
@@ -97,7 +97,7 @@ void ZCombineOperation::deinitExecution()
// MASK combine
ZCombineMaskOperation::ZCombineMaskOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE); //mask
+ this->addInputSocket(COM_DT_VALUE); // mask
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index e30b77ea742..ba6b3b32d60 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -37,6 +37,7 @@ set(INC_SYS
set(SRC
intern/builder/deg_builder.cc
+ intern/builder/deg_builder_cache.cc
intern/builder/deg_builder_cycle.cc
intern/builder/deg_builder_map.cc
intern/builder/deg_builder_nodes.cc
@@ -68,7 +69,6 @@ set(SRC
intern/depsgraph_eval.cc
intern/depsgraph_physics.cc
intern/depsgraph_query.cc
- intern/depsgraph_query_filter.cc
intern/depsgraph_query_foreach.cc
intern/depsgraph_query_iter.cc
intern/depsgraph_tag.cc
@@ -82,6 +82,7 @@ set(SRC
DEG_depsgraph_query.h
intern/builder/deg_builder.h
+ intern/builder/deg_builder_cache.h
intern/builder/deg_builder_cycle.h
intern/builder/deg_builder_map.h
intern/builder/deg_builder_nodes.h
diff --git a/source/blender/depsgraph/DEG_depsgraph_debug.h b/source/blender/depsgraph/DEG_depsgraph_debug.h
index 9ebd5f7ffae..73e03523003 100644
--- a/source/blender/depsgraph/DEG_depsgraph_debug.h
+++ b/source/blender/depsgraph/DEG_depsgraph_debug.h
@@ -68,7 +68,7 @@ void DEG_debug_stats_gnuplot(const struct Depsgraph *graph,
/* Compare two dependency graphs. */
bool DEG_debug_compare(const struct Depsgraph *graph1, const struct Depsgraph *graph2);
-/* Check that dependnecies in the graph are really up to date. */
+/* Check that dependencies in the graph are really up to date. */
bool DEG_debug_graph_relations_validate(struct Depsgraph *graph,
struct Main *bmain,
struct Scene *scene,
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index 89e4958eddc..78434411a22 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -20,7 +20,7 @@
/** \file
* \ingroup depsgraph
*
- * Public API for Querying and Filtering Depsgraph.
+ * Public API for Querying Depsgraph.
*/
#ifndef __DEG_DEPSGRAPH_QUERY_H__
@@ -205,38 +205,6 @@ void DEG_foreach_dependent_ID(const Depsgraph *depsgraph,
void DEG_foreach_ID(const Depsgraph *depsgraph, DEGForeachIDCallback callback, void *user_data);
-/* ********************* DEG graph filtering ****************** */
-
-/* ComponentKey for nodes we want to be able to evaluate in the filtered graph */
-typedef struct DEG_FilterTarget {
- struct DEG_FilterTarget *next, *prev;
-
- struct ID *id;
- /* TODO: component identifiers - Component Type, Subdata/Component Name */
-} DEG_FilterTarget;
-
-typedef enum eDEG_FilterQuery_Granularity {
- DEG_FILTER_NODES_ALL = 0,
- DEG_FILTER_NODES_NO_OPS = 1,
- DEG_FILTER_NODES_ID_ONLY = 2,
-} eDEG_FilterQuery_Granularity;
-
-typedef struct DEG_FilterQuery {
- /* List of DEG_FilterTarget's */
- struct ListBase targets;
-
- /* Level of detail in the resulting graph */
- eDEG_FilterQuery_Granularity detail_level;
-} DEG_FilterQuery;
-
-/* Obtain a new graph instance that only contains the subset of desired nodes
- * WARNING: Do NOT pass an already filtered depsgraph through this function again,
- * as we are currently unable to accurately recreate it.
- */
-Depsgraph *DEG_graph_filter(const Depsgraph *depsgraph,
- struct Main *bmain,
- DEG_FilterQuery *query);
-
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index ef36dec6f34..b8e0ba51019 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -26,6 +26,7 @@
#include <cstring>
#include "DNA_anim_types.h"
+#include "DNA_armature_types.h"
#include "DNA_layer_types.h"
#include "DNA_ID.h"
#include "DNA_object_types.h"
@@ -34,6 +35,8 @@
#include "BLI_ghash.h"
#include "BLI_stack.h"
+#include "BKE_action.h"
+
extern "C" {
#include "BKE_animsys.h"
}
@@ -41,6 +44,7 @@ extern "C" {
#include "intern/depsgraph.h"
#include "intern/depsgraph_tag.h"
#include "intern/depsgraph_type.h"
+#include "intern/builder/deg_builder_cache.h"
#include "intern/eval/deg_eval_copy_on_write.h"
#include "intern/node/deg_node.h"
#include "intern/node/deg_node_id.h"
@@ -51,70 +55,81 @@ extern "C" {
namespace DEG {
+bool deg_check_base_in_depsgraph(const Depsgraph *graph, Base *base)
+{
+ Object *object_orig = base->base_orig->object;
+ IDNode *id_node = graph->find_id_node(&object_orig->id);
+ if (id_node == NULL) {
+ return false;
+ }
+ return id_node->has_base;
+}
+
/*******************************************************************************
* Base class for builders.
*/
-namespace {
-
-struct VisibilityCheckData {
- eEvaluationMode eval_mode;
- bool is_visibility_animated;
-};
+DepsgraphBuilder::DepsgraphBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache)
+ : bmain_(bmain), graph_(graph), cache_(cache)
+{
+}
-void visibility_animated_check_cb(ID * /*id*/, FCurve *fcu, void *user_data)
+bool DepsgraphBuilder::need_pull_base_into_graph(Base *base)
{
- VisibilityCheckData *data = reinterpret_cast<VisibilityCheckData *>(user_data);
- if (data->is_visibility_animated) {
- return;
+ /* Simple check: enabled bases are always part of dependency graph. */
+ const int base_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT :
+ BASE_ENABLED_RENDER;
+ if (base->flag & base_flag) {
+ return true;
}
- if (data->eval_mode == DAG_EVAL_VIEWPORT) {
- if (STREQ(fcu->rna_path, "hide_viewport")) {
- data->is_visibility_animated = true;
- }
+ /* More involved check: since we don't support dynamic changes in dependency graph topology and
+ * all visible objects are to be part of dependency graph, we pull all objects which has animated
+ * visibility. */
+ Object *object = base->object;
+ AnimatedPropertyID property_id;
+ if (graph_->mode == DAG_EVAL_VIEWPORT) {
+ property_id = AnimatedPropertyID(&object->id, &RNA_Object, "hide_viewport");
}
- else if (data->eval_mode == DAG_EVAL_RENDER) {
- if (STREQ(fcu->rna_path, "hide_render")) {
- data->is_visibility_animated = true;
- }
+ else if (graph_->mode == DAG_EVAL_RENDER) {
+ property_id = AnimatedPropertyID(&object->id, &RNA_Object, "hide_render");
}
-}
-
-bool is_object_visibility_animated(const Depsgraph *graph, Object *object)
-{
- AnimData *anim_data = BKE_animdata_from_id(&object->id);
- if (anim_data == NULL) {
+ else {
+ BLI_assert(!"Unknown evaluation mode.");
return false;
}
- VisibilityCheckData data;
- data.eval_mode = graph->mode;
- data.is_visibility_animated = false;
- BKE_fcurves_id_cb(&object->id, visibility_animated_check_cb, &data);
- return data.is_visibility_animated;
+ return cache_->isPropertyAnimated(&object->id, property_id);
}
-} // namespace
-
-bool deg_check_base_available_for_build(const Depsgraph *graph, Base *base)
+bool DepsgraphBuilder::check_pchan_has_bbone(Object *object, const bPoseChannel *pchan)
{
- const int base_flag = (graph->mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT :
- BASE_ENABLED_RENDER;
- if (base->flag & base_flag) {
- return true;
+ BLI_assert(object->type == OB_ARMATURE);
+ if (pchan->bone == NULL) {
+ return false;
}
- if (is_object_visibility_animated(graph, base->object)) {
+ /* We don't really care whether segments are higher than 1 due to static user input (as in,
+ * rigger entered value like 3 manually), or due to animation. In either way we need to create
+ * special evaluation. */
+ if (pchan->bone->segments > 1) {
return true;
}
- return false;
+ bArmature *armature = static_cast<bArmature *>(object->data);
+ AnimatedPropertyID property_id(&armature->id, &RNA_Bone, pchan->bone, "bbone_segments");
+ return cache_->isPropertyAnimated(&armature->id, property_id);
}
-DepsgraphBuilder::DepsgraphBuilder(Main *bmain, Depsgraph *graph) : bmain_(bmain), graph_(graph)
+bool DepsgraphBuilder::check_pchan_has_bbone_segments(Object *object, const bPoseChannel *pchan)
{
+ /* Proxies don't have BONE_SEGMENTS */
+ if (ID_IS_LINKED(object) && object->proxy_from != NULL) {
+ return false;
+ }
+ return check_pchan_has_bbone(object, pchan);
}
-bool DepsgraphBuilder::need_pull_base_into_graph(Base *base)
+bool DepsgraphBuilder::check_pchan_has_bbone_segments(Object *object, const char *bone_name)
{
- return deg_check_base_available_for_build(graph_, base);
+ const bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone_name);
+ return check_pchan_has_bbone_segments(object, pchan);
}
/*******************************************************************************
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.h b/source/blender/depsgraph/intern/builder/deg_builder.h
index 310944f2f28..224e3212d57 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder.h
@@ -23,26 +23,35 @@
#pragma once
+struct bPoseChannel;
struct Base;
struct Main;
+struct Object;
namespace DEG {
struct Depsgraph;
+class DepsgraphBuilderCache;
class DepsgraphBuilder {
public:
- bool need_pull_base_into_graph(struct Base *base);
+ bool need_pull_base_into_graph(Base *base);
+
+ bool check_pchan_has_bbone(Object *object, const bPoseChannel *pchan);
+ bool check_pchan_has_bbone_segments(Object *object, const bPoseChannel *pchan);
+ bool check_pchan_has_bbone_segments(Object *object, const char *bone_name);
protected:
- DepsgraphBuilder(Main *bmain, Depsgraph *graph);
+ /* NOTE: The builder does NOT take ownership over any of those resources. */
+ DepsgraphBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache);
/* State which never changes, same for the whole builder time. */
Main *bmain_;
Depsgraph *graph_;
+ DepsgraphBuilderCache *cache_;
};
-bool deg_check_base_available_for_build(const Depsgraph *graph, Base *base);
-void deg_graph_build_finalize(struct Main *bmain, struct Depsgraph *graph);
+bool deg_check_base_in_depsgraph(const Depsgraph *graph, Base *base);
+void deg_graph_build_finalize(Main *bmain, Depsgraph *graph);
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
new file mode 100644
index 00000000000..3df707e92c1
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
@@ -0,0 +1,186 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#include "intern/builder/deg_builder_cache.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_anim_types.h"
+
+#include "BLI_utildefines.h"
+
+extern "C" {
+#include "BKE_animsys.h"
+}
+
+namespace DEG {
+
+/* Animated property storage. */
+
+AnimatedPropertyID::AnimatedPropertyID() : data(NULL), property_rna(NULL)
+{
+}
+
+AnimatedPropertyID::AnimatedPropertyID(const PointerRNA *pointer_rna,
+ const PropertyRNA *property_rna)
+ : AnimatedPropertyID(*pointer_rna, property_rna)
+{
+}
+
+AnimatedPropertyID::AnimatedPropertyID(const PointerRNA &pointer_rna,
+ const PropertyRNA *property_rna)
+ : data(pointer_rna.data), property_rna(property_rna)
+{
+}
+
+AnimatedPropertyID::AnimatedPropertyID(ID *id, StructRNA *type, const char *property_name)
+ : data(id)
+{
+ property_rna = RNA_struct_type_find_property(type, property_name);
+}
+
+AnimatedPropertyID::AnimatedPropertyID(ID * /*id*/,
+ StructRNA *type,
+ void *data,
+ const char *property_name)
+ : data(data)
+{
+ property_rna = RNA_struct_type_find_property(type, property_name);
+}
+
+bool AnimatedPropertyID::operator<(const AnimatedPropertyID &other) const
+{
+ if (data < other.data) {
+ return true;
+ }
+ else if (data == other.data) {
+ return property_rna < other.property_rna;
+ }
+ return false;
+}
+
+namespace {
+
+struct AnimatedPropertyCallbackData {
+ PointerRNA pointer_rna;
+ AnimatedPropertyStorage *animated_property_storage;
+ DepsgraphBuilderCache *builder_cache;
+};
+
+void animated_property_cb(ID * /*id*/, FCurve *fcurve, void *data_v)
+{
+ if (fcurve->rna_path == NULL || fcurve->rna_path[0] == '\0') {
+ return;
+ }
+ AnimatedPropertyCallbackData *data = static_cast<AnimatedPropertyCallbackData *>(data_v);
+ /* Resolve property. */
+ PointerRNA pointer_rna;
+ PropertyRNA *property_rna = NULL;
+ if (!RNA_path_resolve_property(
+ &data->pointer_rna, fcurve->rna_path, &pointer_rna, &property_rna)) {
+ return;
+ }
+ /* Get storage for the ID.
+ * This is needed to deal with cases when nested datablock is animated by its parent. */
+ AnimatedPropertyStorage *animated_property_storage = data->animated_property_storage;
+ if (pointer_rna.id.data != data->pointer_rna.id.data) {
+ animated_property_storage = data->builder_cache->ensureAnimatedPropertyStorage(
+ reinterpret_cast<ID *>(pointer_rna.id.data));
+ }
+ /* Set the property as animated. */
+ animated_property_storage->tagPropertyAsAnimated(&pointer_rna, property_rna);
+}
+
+} // namespace
+
+AnimatedPropertyStorage::AnimatedPropertyStorage() : is_fully_initialized(false)
+{
+}
+
+void AnimatedPropertyStorage::initializeFromID(DepsgraphBuilderCache *builder_cache, ID *id)
+{
+ AnimatedPropertyCallbackData data;
+ RNA_id_pointer_create(id, &data.pointer_rna);
+ data.animated_property_storage = this;
+ data.builder_cache = builder_cache;
+ BKE_fcurves_id_cb(id, animated_property_cb, &data);
+}
+
+void AnimatedPropertyStorage::tagPropertyAsAnimated(const AnimatedPropertyID &property_id)
+{
+ animated_properties_set.insert(property_id);
+}
+
+void AnimatedPropertyStorage::tagPropertyAsAnimated(const PointerRNA *pointer_rna,
+ const PropertyRNA *property_rna)
+{
+ tagPropertyAsAnimated(AnimatedPropertyID(pointer_rna, property_rna));
+}
+
+bool AnimatedPropertyStorage::isPropertyAnimated(const AnimatedPropertyID &property_id)
+{
+ return animated_properties_set.find(property_id) != animated_properties_set.end();
+}
+
+bool AnimatedPropertyStorage::isPropertyAnimated(const PointerRNA *pointer_rna,
+ const PropertyRNA *property_rna)
+{
+ return isPropertyAnimated(AnimatedPropertyID(pointer_rna, property_rna));
+}
+
+/* Builder cache itself. */
+
+DepsgraphBuilderCache::DepsgraphBuilderCache()
+{
+}
+
+DepsgraphBuilderCache::~DepsgraphBuilderCache()
+{
+ for (AnimatedPropertyStorageMap::value_type &iter : animated_property_storage_map_) {
+ AnimatedPropertyStorage *animated_property_storage = iter.second;
+ OBJECT_GUARDED_DELETE(animated_property_storage, AnimatedPropertyStorage);
+ }
+}
+
+AnimatedPropertyStorage *DepsgraphBuilderCache::ensureAnimatedPropertyStorage(ID *id)
+{
+ AnimatedPropertyStorageMap::iterator it = animated_property_storage_map_.find(id);
+ if (it != animated_property_storage_map_.end()) {
+ return it->second;
+ }
+ AnimatedPropertyStorage *animated_property_storage = OBJECT_GUARDED_NEW(AnimatedPropertyStorage);
+ animated_property_storage_map_.insert(make_pair(id, animated_property_storage));
+ return animated_property_storage;
+}
+
+AnimatedPropertyStorage *DepsgraphBuilderCache::ensureInitializedAnimatedPropertyStorage(ID *id)
+{
+ AnimatedPropertyStorage *animated_property_storage = ensureAnimatedPropertyStorage(id);
+ if (!animated_property_storage->is_fully_initialized) {
+ animated_property_storage->initializeFromID(this, id);
+ animated_property_storage->is_fully_initialized = true;
+ }
+ return animated_property_storage;
+}
+
+} // namespace DEG
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.h b/source/blender/depsgraph/intern/builder/deg_builder_cache.h
new file mode 100644
index 00000000000..949020e3a81
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.h
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "intern/depsgraph_type.h"
+
+#include "RNA_access.h"
+
+struct ID;
+struct PointerRNA;
+struct PropertyRNA;
+
+namespace DEG {
+
+class DepsgraphBuilderCache;
+
+/* Identifier for animated property. */
+class AnimatedPropertyID {
+ public:
+ AnimatedPropertyID();
+ AnimatedPropertyID(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
+ AnimatedPropertyID(const PointerRNA &pointer_rna, const PropertyRNA *property_rna);
+ AnimatedPropertyID(ID *id, StructRNA *type, const char *property_name);
+ AnimatedPropertyID(ID *id, StructRNA *type, void *data, const char *property_name);
+
+ bool operator<(const AnimatedPropertyID &other) const;
+
+ /* Corresponds to PointerRNA.data. */
+ void *data;
+ const PropertyRNA *property_rna;
+};
+
+class AnimatedPropertyStorage {
+ public:
+ AnimatedPropertyStorage();
+
+ void initializeFromID(DepsgraphBuilderCache *builder_cache, ID *id);
+
+ void tagPropertyAsAnimated(const AnimatedPropertyID &property_id);
+ void tagPropertyAsAnimated(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
+
+ bool isPropertyAnimated(const AnimatedPropertyID &property_id);
+ bool isPropertyAnimated(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
+
+ /* The storage is fully initialized from all F-Curves from corresponding ID. */
+ bool is_fully_initialized;
+
+ /* indexed by PointerRNA.data. */
+ set<AnimatedPropertyID> animated_properties_set;
+};
+
+typedef map<ID *, AnimatedPropertyStorage *> AnimatedPropertyStorageMap;
+
+/* Cached data which can be re-used by multiple builders. */
+class DepsgraphBuilderCache {
+ public:
+ DepsgraphBuilderCache();
+ ~DepsgraphBuilderCache();
+
+ /* Makes sure storage for animated properties exists and initialized for the given ID. */
+ AnimatedPropertyStorage *ensureAnimatedPropertyStorage(ID *id);
+ AnimatedPropertyStorage *ensureInitializedAnimatedPropertyStorage(ID *id);
+
+ /* Shortcuts to go through ensureInitializedAnimatedPropertyStorage and its
+ * isPropertyAnimated.
+ *
+ * NOTE: Avoid using for multiple subsequent lookups, query for the storage once, and then query
+ * the storage.
+ *
+ * TODO(sergey): Technically, this makes this class something else than just a cache, but what is
+ * the better name? */
+ template<typename... Args> bool isPropertyAnimated(ID *id, Args... args)
+ {
+ AnimatedPropertyStorage *animated_property_storage = ensureInitializedAnimatedPropertyStorage(
+ id);
+ return animated_property_storage->isPropertyAnimated(args...);
+ }
+
+ AnimatedPropertyStorageMap animated_property_storage_map_;
+};
+
+} // namespace DEG
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index c4a2fc71d1b..64ca5902136 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -58,6 +58,8 @@ extern "C" {
#include "DNA_lightprobe_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_sound_types.h"
#include "DNA_speaker_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
@@ -65,6 +67,7 @@ extern "C" {
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_animsys.h"
+#include "BKE_cachefile.h"
#include "BKE_collection.h"
#include "BKE_constraint.h"
#include "BKE_curve.h"
@@ -87,6 +90,8 @@ extern "C" {
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_rigidbody.h"
+#include "BKE_scene.h"
+#include "BKE_sequencer.h"
#include "BKE_shader_fx.h"
#include "BKE_sound.h"
#include "BKE_tracking.h"
@@ -129,8 +134,10 @@ void free_copy_on_write_datablock(void *id_info_v)
/* **** General purpose functions **** */
-DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph)
- : DepsgraphBuilder(bmain, graph),
+DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain,
+ Depsgraph *graph,
+ DepsgraphBuilderCache *cache)
+ : DepsgraphBuilder(bmain, graph, cache),
scene_(NULL),
view_layer_(NULL),
view_layer_index_(-1),
@@ -440,6 +447,9 @@ void DepsgraphNodeBuilder::build_id(ID *id)
case ID_SPK:
build_speaker((Speaker *)id);
break;
+ case ID_SO:
+ build_sound((bSound *)id);
+ break;
case ID_TXT:
/* Not a part of dependency graph. */
break;
@@ -526,6 +536,7 @@ void DepsgraphNodeBuilder::build_object(int base_index,
if (id_node->linked_state == DEG_ID_LINKED_DIRECTLY) {
id_node->is_directly_visible |= is_visible;
}
+ id_node->has_base |= (base_index != -1);
return;
}
/* Create ID node for object and begin init. */
@@ -538,6 +549,7 @@ void DepsgraphNodeBuilder::build_object(int base_index,
else {
id_node->is_directly_visible = is_visible;
}
+ id_node->has_base |= (base_index != -1);
/* Various flags, flushing from bases/collections. */
build_object_flags(base_index, object, linked_state);
/* Transform. */
@@ -703,7 +715,7 @@ void DepsgraphNodeBuilder::build_object_data_speaker(Object *object)
{
Speaker *speaker = (Speaker *)object->data;
build_speaker(speaker);
- add_operation_node(&object->id, NodeType::PARAMETERS, OperationCode::SPEAKER_EVAL);
+ add_operation_node(&object->id, NodeType::AUDIO, OperationCode::SPEAKER_EVAL);
}
void DepsgraphNodeBuilder::build_object_transform(Object *object)
@@ -1149,7 +1161,7 @@ void DepsgraphNodeBuilder::build_shapekeys(Key *key)
/* This is an exit operation for the entire key datablock, is what is used
* as dependency for modifiers evaluation. */
add_operation_node(&key->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_SHAPEKEY);
- /* Create per-key block properties, allowing tricky inter-dependnecies for
+ /* Create per-key block properties, allowing tricky inter-dependencies for
* drivers evaluation. */
LISTBASE_FOREACH (KeyBlock *, key_block, &key->block) {
add_operation_node(
@@ -1177,12 +1189,6 @@ void DepsgraphNodeBuilder::build_object_data_geometry(Object *object, bool is_ob
op_node->set_as_exit();
/* Materials. */
if (object->totcol != 0) {
- if (object->type == OB_MESH) {
- add_operation_node(&object->id,
- NodeType::SHADING,
- OperationCode::SHADING,
- function_bind(BKE_object_eval_update_shading, _1, object_cow));
- }
for (int a = 1; a <= object->totcol; a++) {
Material *ma = give_current_material(object, a);
if (ma != NULL) {
@@ -1441,7 +1447,7 @@ void DepsgraphNodeBuilder::build_compositor(Scene *scene)
/* For now, just a plain wrapper? */
// TODO: create compositing component?
// XXX: component type undefined!
- //graph->get_node(&scene->id, NULL, NodeType::COMPOSITING, NULL);
+ // graph->get_node(&scene->id, NULL, NodeType::COMPOSITING, NULL);
/* for now, nodetrees are just parameters; compositing occurs in internals
* of renderer... */
@@ -1471,11 +1477,16 @@ void DepsgraphNodeBuilder::build_cachefile(CacheFile *cache_file)
return;
}
ID *cache_file_id = &cache_file->id;
+ add_id_node(cache_file_id);
+ CacheFile *cache_file_cow = get_cow_datablock(cache_file);
/* Animation, */
build_animdata(cache_file_id);
build_parameters(cache_file_id);
/* Cache evaluation itself. */
- add_operation_node(cache_file_id, NodeType::CACHE, OperationCode::FILE_CACHE_UPDATE);
+ add_operation_node(cache_file_id,
+ NodeType::CACHE,
+ OperationCode::FILE_CACHE_UPDATE,
+ function_bind(BKE_cachefile_eval, bmain_, _1, cache_file_cow));
}
void DepsgraphNodeBuilder::build_mask(Mask *mask)
@@ -1539,9 +1550,53 @@ void DepsgraphNodeBuilder::build_speaker(Speaker *speaker)
return;
}
/* Placeholder so we can add relations and tag ID node for update. */
- add_operation_node(&speaker->id, NodeType::PARAMETERS, OperationCode::SPEAKER_EVAL);
+ add_operation_node(&speaker->id, NodeType::AUDIO, OperationCode::SPEAKER_EVAL);
build_animdata(&speaker->id);
build_parameters(&speaker->id);
+ if (speaker->sound != NULL) {
+ build_sound(speaker->sound);
+ }
+}
+
+void DepsgraphNodeBuilder::build_sound(bSound *sound)
+{
+ if (built_map_.checkIsBuiltAndTag(sound)) {
+ return;
+ }
+ add_id_node(&sound->id);
+ bSound *sound_cow = get_cow_datablock(sound);
+ add_operation_node(&sound->id,
+ NodeType::AUDIO,
+ OperationCode::SOUND_EVAL,
+ function_bind(BKE_sound_evaluate, _1, bmain_, sound_cow));
+ build_animdata(&sound->id);
+ build_parameters(&sound->id);
+}
+
+void DepsgraphNodeBuilder::build_sequencer(Scene *scene)
+{
+ if (scene->ed == NULL) {
+ return;
+ }
+ Scene *scene_cow = get_cow_datablock(scene_);
+ add_operation_node(&scene->id,
+ NodeType::SEQUENCER,
+ OperationCode::SEQUENCES_EVAL,
+ function_bind(BKE_scene_eval_sequencer_sequences, _1, scene_cow));
+ /* Make sure data for sequences is in the graph. */
+ Sequence *seq;
+ SEQ_BEGIN (scene->ed, seq) {
+ if (seq->sound != NULL) {
+ build_sound(seq->sound);
+ }
+ /* TODO(sergey): Movie clip, scene, camera, mask. */
+ }
+ SEQ_END;
+}
+
+void DepsgraphNodeBuilder::build_scene_audio(Scene *scene)
+{
+ add_operation_node(&scene->id, NodeType::AUDIO, OperationCode::SOUND_EVAL);
}
/* **** ID traversal callbacks functions **** */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index d88f5a792e0..9074efefe50 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -32,6 +32,7 @@
#include "DEG_depsgraph.h"
struct Base;
+struct bSound;
struct CacheFile;
struct Camera;
struct Collection;
@@ -69,6 +70,7 @@ namespace DEG {
struct ComponentNode;
struct Depsgraph;
+class DepsgraphBuilderCache;
struct IDNode;
struct Node;
struct OperationNode;
@@ -76,7 +78,7 @@ struct TimeSourceNode;
class DepsgraphNodeBuilder : public DepsgraphBuilder {
public:
- DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph);
+ DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache);
~DepsgraphNodeBuilder();
/* For given original ID get ID which is created by CoW system. */
@@ -205,6 +207,9 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
void build_movieclip(MovieClip *clip);
void build_lightprobe(LightProbe *probe);
void build_speaker(Speaker *speaker);
+ void build_sound(bSound *sound);
+ void build_sequencer(Scene *scene);
+ void build_scene_audio(Scene *scene);
/* Per-ID information about what was already in the dependency graph.
* Allows to re-use certain values, to speed up following evaluation. */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
index 6f141bd7222..979e1a02e71 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
@@ -231,7 +231,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object, bool is_object_visible)
function_bind(BKE_pose_bone_done, _1, object_cow, pchan_index));
/* B-Bone shape computation - the real last step if present. */
- if (pchan->bone != NULL && pchan->bone->segments > 1) {
+ if (check_pchan_has_bbone(object, pchan)) {
op_node = add_operation_node(
&object->id,
NodeType::BONE,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
index 60b711d76d3..1b9524e5832 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
@@ -152,6 +152,11 @@ void DepsgraphNodeBuilder::build_view_layer(Scene *scene,
build_collection(NULL, fls->group);
}
}
+ /* Sequencer. */
+ if (linked_state == DEG_ID_LINKED_DIRECTLY) {
+ build_scene_audio(scene);
+ build_sequencer(scene);
+ }
/* Collections. */
add_operation_node(
&scene->id,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc b/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
index 6d979724e7e..95c50c4f44e 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
@@ -95,14 +95,14 @@ bool RootPChanMap::has_common_root(const char *bone1, const char *bone2)
{
/* Ensure that both are in the map... */
if (BLI_ghash_haskey(map_, bone1) == false) {
- //fprintf("RootPChanMap: bone1 '%s' not found (%s => %s)\n", bone1, bone1, bone2);
- //print_debug();
+ // fprintf("RootPChanMap: bone1 '%s' not found (%s => %s)\n", bone1, bone1, bone2);
+ // print_debug();
return false;
}
if (BLI_ghash_haskey(map_, bone2) == false) {
- //fprintf("RootPChanMap: bone2 '%s' not found (%s => %s)\n", bone2, bone1, bone2);
- //print_debug();
+ // fprintf("RootPChanMap: bone2 '%s' not found (%s => %s)\n", bone2, bone1, bone2);
+ // print_debug();
return false;
}
@@ -116,13 +116,13 @@ bool RootPChanMap::has_common_root(const char *bone1, const char *bone2)
const char *v2 = (const char *)BLI_gsetIterator_getKey(&it2);
if (strcmp(v1, v2) == 0) {
- //fprintf("RootPchanMap: %s in common for %s => %s\n", v1, bone1, bone2);
+ // fprintf("RootPchanMap: %s in common for %s => %s\n", v1, bone1, bone2);
return true;
}
}
}
- //fprintf("RootPChanMap: No common root found (%s => %s)\n", bone1, bone2);
+ // fprintf("RootPChanMap: No common root found (%s => %s)\n", bone1, bone2);
return false;
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 87a8875f819..4c4bc01a3dd 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -58,6 +58,8 @@ extern "C" {
#include "DNA_object_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_sound_types.h"
#include "DNA_speaker_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
@@ -83,6 +85,7 @@ extern "C" {
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_rigidbody.h"
+#include "BKE_sequencer.h"
#include "BKE_shader_fx.h"
#include "BKE_shrinkwrap.h"
#include "BKE_sound.h"
@@ -196,21 +199,12 @@ static OperationCode bone_target_opcode(ID *target,
return OperationCode::BONE_DONE;
}
-static bool bone_has_segments(Object *object, const char *bone_name)
-{
- /* Proxies don't have BONE_SEGMENTS */
- if (ID_IS_LINKED(object) && object->proxy_from != NULL) {
- return false;
- }
- /* Only B-Bones have segments. */
- bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone_name);
- return pchan && pchan->bone && pchan->bone->segments > 1;
-}
-
/* **** General purpose functions **** */
-DepsgraphRelationBuilder::DepsgraphRelationBuilder(Main *bmain, Depsgraph *graph)
- : DepsgraphBuilder(bmain, graph), scene_(NULL), rna_node_query_(graph)
+DepsgraphRelationBuilder::DepsgraphRelationBuilder(Main *bmain,
+ Depsgraph *graph,
+ DepsgraphBuilderCache *cache)
+ : DepsgraphBuilder(bmain, graph, cache), scene_(NULL), rna_node_query_(graph, this)
{
}
@@ -496,6 +490,9 @@ void DepsgraphRelationBuilder::build_id(ID *id)
case ID_SPK:
build_speaker((Speaker *)id);
break;
+ case ID_SO:
+ build_sound((bSound *)id);
+ break;
case ID_TXT:
/* Not a part of dependency graph. */
break;
@@ -775,9 +772,9 @@ void DepsgraphRelationBuilder::build_object_data_speaker(Object *object)
{
Speaker *speaker = (Speaker *)object->data;
build_speaker(speaker);
- OperationKey probe_key(&speaker->id, NodeType::PARAMETERS, OperationCode::SPEAKER_EVAL);
- OperationKey object_key(&object->id, NodeType::PARAMETERS, OperationCode::SPEAKER_EVAL);
- add_relation(probe_key, object_key, "Speaker Update");
+ ComponentKey speaker_key(&speaker->id, NodeType::AUDIO);
+ ComponentKey object_key(&object->id, NodeType::AUDIO);
+ add_relation(speaker_key, object_key, "Speaker Update");
}
void DepsgraphRelationBuilder::build_object_parent(Object *object)
@@ -1017,7 +1014,7 @@ 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)) {
+ check_pchan_has_bbone_segments(ct->tar, ct->subtarget)) {
opcode = OperationCode::BONE_SEGMENTS;
}
OperationKey target_key(&ct->tar->id, NodeType::BONE, ct->subtarget, opcode);
@@ -1330,51 +1327,67 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu)
void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu)
{
- OperationKey driver_key(id,
- NodeType::PARAMETERS,
- OperationCode::DRIVER,
- fcu->rna_path ? fcu->rna_path : "",
- fcu->array_index);
- const char *rna_path = fcu->rna_path ? fcu->rna_path : "";
- if (GS(id->name) == ID_AR && strstr(rna_path, "bones[")) {
+ /* Validate the RNA path pointer just in case. */
+ const char *rna_path = fcu->rna_path;
+ if (rna_path == NULL || rna_path[0] == '\0') {
+ return;
+ }
+ /* Parse the RNA path to find the target property pointer. */
+ RNAPathKey property_entry_key(id, rna_path, RNAPointerSource::ENTRY);
+ if (RNA_pointer_is_null(&property_entry_key.ptr)) {
+ /* TODO(sergey): This would only mean that driver is broken.
+ * so we can't create relation anyway. However, we need to avoid
+ * adding drivers which are known to be buggy to a dependency
+ * graph, in order to save computational power. */
+ return;
+ }
+ OperationKey driver_key(
+ id, NodeType::PARAMETERS, OperationCode::DRIVER, rna_path, fcu->array_index);
+ /* If the target of the driver is a Bone property, find the Armature data,
+ * and then link the driver to all pose bone evaluation components that use
+ * it. This is necessary to provide more granular dependencies specifically for
+ * Bone objects, because the armature data doesn't have per-bone components,
+ * and generic add_relation can only add one link. */
+ ID *id_ptr = (ID *)property_entry_key.ptr.id.data;
+ bool is_bone = id_ptr && property_entry_key.ptr.type == &RNA_Bone;
+ /* If the Bone property is referenced via obj.pose.bones[].bone,
+ * the RNA pointer refers to the Object ID, so skip to data. */
+ if (is_bone && GS(id_ptr->name) == ID_OB) {
+ id_ptr = (ID *)((Object *)id_ptr)->data;
+ }
+ if (is_bone && GS(id_ptr->name) == ID_AR) {
/* Drivers on armature-level bone settings (i.e. bbone stuff),
* which will affect the evaluation of corresponding pose bones. */
- IDNode *arm_node = graph_->find_id_node(id);
- char *bone_name = BLI_str_quoted_substrN(rna_path, "bones[");
- if (arm_node != NULL && bone_name != NULL) {
+ Bone *bone = (Bone *)property_entry_key.ptr.data;
+ if (bone != NULL) {
/* Find objects which use this, and make their eval callbacks
* depend on this. */
- for (Relation *rel : arm_node->outlinks) {
- IDNode *to_node = (IDNode *)rel->to;
- /* We only care about objects with pose data which use this. */
+ for (IDNode *to_node : graph_->id_nodes) {
if (GS(to_node->id_orig->name) == ID_OB) {
Object *object = (Object *)to_node->id_orig;
- // NOTE: object->pose may be NULL
- bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone_name);
- if (pchan != NULL) {
- OperationKey bone_key(
- &object->id, NodeType::BONE, pchan->name, OperationCode::BONE_LOCAL);
- add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
+ /* We only care about objects with pose data which use this. */
+ if (object->data == id_ptr && object->pose != NULL) {
+ bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone->name);
+ if (pchan != NULL) {
+ OperationKey bone_key(
+ &object->id, NodeType::BONE, pchan->name, OperationCode::BONE_LOCAL);
+ add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
+ }
}
}
}
- /* Free temp data. */
- MEM_freeN(bone_name);
- bone_name = NULL;
+ /* Make the driver depend on COW, similar to the generic case below. */
+ if (id_ptr != id) {
+ ComponentKey cow_key(id_ptr, NodeType::COPY_ON_WRITE);
+ add_relation(cow_key, driver_key, "Driven CoW -> Driver", RELATION_CHECK_BEFORE_ADD);
+ }
}
else {
fprintf(stderr, "Couldn't find armature bone name for driver path - '%s'\n", rna_path);
}
}
- else if (rna_path != NULL && rna_path[0] != '\0') {
- RNAPathKey property_entry_key(id, rna_path, RNAPointerSource::ENTRY);
- if (RNA_pointer_is_null(&property_entry_key.ptr)) {
- /* TODO(sergey): This would only mean that driver is broken.
- * so we can't create relation anyway. However, we need to avoid
- * adding drivers which are known to be buggy to a dependency
- * graph, in order to save computational power. */
- return;
- }
+ else {
+ /* If it's not a Bone, handle the generic single dependency case. */
add_relation(driver_key, property_entry_key, "Driver -> Driven Property");
/* Similar to the case with f-curves, driver might drive a nested
* datablock, which means driver execution should wait for that
@@ -1411,27 +1424,34 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
/* Only used targets. */
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
- if (dtar->id == NULL) {
+ ID *target_id = dtar->id;
+ if (target_id == NULL) {
continue;
}
- build_id(dtar->id);
- build_driver_id_property(dtar->id, dtar->rna_path);
- /* Initialize relations coming to proxy_from. */
- Object *proxy_from = NULL;
- if ((GS(dtar->id->name) == ID_OB) && (((Object *)dtar->id)->proxy_from != NULL)) {
- proxy_from = ((Object *)dtar->id)->proxy_from;
- build_id(&proxy_from->id);
+ build_id(target_id);
+ build_driver_id_property(target_id, dtar->rna_path);
+ /* Look up the proxy - matches dtar_id_ensure_proxy_from during evaluation. */
+ Object *object = NULL;
+ if (GS(target_id->name) == ID_OB) {
+ object = (Object *)target_id;
+ if (object->proxy_from != NULL) {
+ /* Redirect the target to the proxy, like in evaluation. */
+ object = object->proxy_from;
+ target_id = &object->id;
+ /* Prepare the redirected target. */
+ build_id(target_id);
+ build_driver_id_property(target_id, dtar->rna_path);
+ }
}
/* Special handling for directly-named bones. */
- if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (((Object *)dtar->id)->type == OB_ARMATURE) &&
+ if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (object && object->type == OB_ARMATURE) &&
(dtar->pchan_name[0])) {
- Object *object = (Object *)dtar->id;
bPoseChannel *target_pchan = BKE_pose_channel_find_name(object->pose, dtar->pchan_name);
if (target_pchan == NULL) {
continue;
}
OperationKey variable_key(
- dtar->id, NodeType::BONE, target_pchan->name, OperationCode::BONE_DONE);
+ target_id, NodeType::BONE, target_pchan->name, OperationCode::BONE_DONE);
if (is_same_bone_dependency(variable_key, self_key)) {
continue;
}
@@ -1439,17 +1459,17 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
}
else if (dtar->flag & DTAR_FLAG_STRUCT_REF) {
/* Get node associated with the object's transforms. */
- if (dtar->id == id) {
+ if (target_id == id) {
/* Ignore input dependency if we're driving properties of
* the same ID, otherwise we'll be ending up in a cyclic
* dependency here. */
continue;
}
- OperationKey target_key(dtar->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL);
+ OperationKey target_key(target_id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL);
add_relation(target_key, driver_key, "Target -> Driver");
}
else if (dtar->rna_path != NULL && dtar->rna_path[0] != '\0') {
- RNAPathKey variable_exit_key(dtar->id, dtar->rna_path, RNAPointerSource::EXIT);
+ RNAPathKey variable_exit_key(target_id, dtar->rna_path, RNAPointerSource::EXIT);
if (RNA_pointer_is_null(&variable_exit_key.ptr)) {
continue;
}
@@ -1458,12 +1478,6 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
continue;
}
add_relation(variable_exit_key, driver_key, "RNA Target -> Driver");
- if (proxy_from != NULL) {
- RNAPathKey proxy_from_variable_key(
- &proxy_from->id, dtar->rna_path, RNAPointerSource::EXIT);
- RNAPathKey variable_entry_key(dtar->id, dtar->rna_path, RNAPointerSource::ENTRY);
- add_relation(proxy_from_variable_key, variable_entry_key, "Proxy From -> Variable");
- }
}
else {
/* If rna_path is NULL, and DTAR_FLAG_STRUCT_REF isn't set, this
@@ -1904,12 +1918,6 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
Material *ma = give_current_material(object, a);
if (ma != NULL) {
build_material(ma);
-
- if (object->type == OB_MESH) {
- OperationKey material_key(&ma->id, NodeType::SHADING, OperationCode::MATERIAL_UPDATE);
- OperationKey shading_key(&object->id, NodeType::SHADING, OperationCode::SHADING);
- add_relation(material_key, shading_key, "Material Update");
- }
}
}
}
@@ -1923,12 +1931,6 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
OperationKey obdata_ubereval_key(
&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL);
add_relation(geom_init_key, obdata_ubereval_key, "Object Geometry UberEval");
- if (object->totcol != 0 && object->type == OB_MESH) {
- ComponentKey object_shading_key(&object->id, NodeType::SHADING);
- Relation *rel = add_relation(
- obdata_ubereval_key, object_shading_key, "Object Geometry batch Update");
- rel->flag |= RELATION_FLAG_NO_FLUSH;
- }
}
if (object->type == OB_MBALL) {
Object *mom = BKE_mball_basis_find(scene_, object);
@@ -2243,6 +2245,14 @@ void DepsgraphRelationBuilder::build_cachefile(CacheFile *cache_file)
ComponentKey datablock_key(&cache_file->id, NodeType::CACHE);
add_relation(animation_key, datablock_key, "Datablock Animation");
}
+
+ /* Cache file updates */
+ if (cache_file->is_sequence) {
+ OperationKey cache_update_key(
+ &cache_file->id, NodeType::CACHE, OperationCode::FILE_CACHE_UPDATE);
+ TimeSourceKey time_src_key;
+ add_relation(time_src_key, cache_update_key, "TimeSrc -> Cache File Eval");
+ }
}
void DepsgraphRelationBuilder::build_mask(Mask *mask)
@@ -2289,6 +2299,50 @@ void DepsgraphRelationBuilder::build_speaker(Speaker *speaker)
}
build_animdata(&speaker->id);
build_parameters(&speaker->id);
+ if (speaker->sound != NULL) {
+ build_sound(speaker->sound);
+ ComponentKey speaker_key(&speaker->id, NodeType::AUDIO);
+ ComponentKey sound_key(&speaker->sound->id, NodeType::AUDIO);
+ add_relation(sound_key, speaker_key, "Sound -> Speaker");
+ }
+}
+
+void DepsgraphRelationBuilder::build_sound(bSound *sound)
+{
+ if (built_map_.checkIsBuiltAndTag(sound)) {
+ return;
+ }
+ build_animdata(&sound->id);
+ build_parameters(&sound->id);
+}
+
+void DepsgraphRelationBuilder::build_sequencer(Scene *scene)
+{
+ if (scene->ed == NULL) {
+ return;
+ }
+ /* Make sure dependencies from sequences data goes to the sequencer evaluation. */
+ ComponentKey sequencer_key(&scene->id, NodeType::SEQUENCER);
+ Sequence *seq;
+ bool has_audio_strips = false;
+ SEQ_BEGIN (scene->ed, seq) {
+ if (seq->sound != NULL) {
+ build_sound(seq->sound);
+ ComponentKey sound_key(&seq->sound->id, NodeType::AUDIO);
+ add_relation(sound_key, sequencer_key, "Sound -> Sequencer");
+ has_audio_strips = true;
+ }
+ /* TODO(sergey): Movie clip, scene, camera, mask. */
+ }
+ SEQ_END;
+ if (has_audio_strips) {
+ ComponentKey scene_audio_key(&scene->id, NodeType::AUDIO);
+ add_relation(sequencer_key, scene_audio_key, "Sequencer -> Audio");
+ }
+}
+
+void DepsgraphRelationBuilder::build_scene_audio(Scene * /*scene*/)
+{
}
void DepsgraphRelationBuilder::build_copy_on_write_relations()
@@ -2350,7 +2404,12 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node)
continue;
}
int rel_flag = (RELATION_FLAG_NO_FLUSH | RELATION_FLAG_GODMODE);
- if (id_type == ID_ME && comp_node->type == NodeType::GEOMETRY) {
+ if ((id_type == ID_ME && comp_node->type == NodeType::GEOMETRY) ||
+ (id_type == ID_CF && comp_node->type == NodeType::CACHE)) {
+ rel_flag &= ~RELATION_FLAG_NO_FLUSH;
+ }
+ /* TODO(sergey): Needs better solution for this. */
+ if (id_type == ID_SO) {
rel_flag &= ~RELATION_FLAG_NO_FLUSH;
}
/* Notes on exceptions:
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index 5b2d34a270c..30fbe5bcf6b 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -41,10 +41,12 @@
#include "intern/builder/deg_builder_rna.h"
#include "intern/depsgraph.h"
#include "intern/node/deg_node.h"
+#include "intern/node/deg_node_id.h"
#include "intern/node/deg_node_component.h"
#include "intern/node/deg_node_operation.h"
struct Base;
+struct bSound;
struct CacheFile;
struct Camera;
struct Collection;
@@ -86,6 +88,7 @@ namespace DEG {
struct ComponentNode;
struct DepsNodeHandle;
struct Depsgraph;
+class DepsgraphBuilderCache;
struct IDNode;
struct Node;
struct OperationNode;
@@ -155,7 +158,7 @@ struct RNAPathKey {
class DepsgraphRelationBuilder : public DepsgraphBuilder {
public:
- DepsgraphRelationBuilder(Main *bmain, Depsgraph *graph);
+ DepsgraphRelationBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache);
void begin_build();
@@ -193,7 +196,9 @@ class DepsgraphRelationBuilder : public DepsgraphBuilder {
void build_id(ID *id);
void build_layer_collections(ListBase *lb);
- void build_view_layer(Scene *scene, ViewLayer *view_layer);
+ void build_view_layer(Scene *scene,
+ ViewLayer *view_layer,
+ eDepsNode_LinkedState_Type linked_state);
void build_collection(LayerCollection *from_layer_collection,
Object *object,
Collection *collection);
@@ -263,6 +268,9 @@ class DepsgraphRelationBuilder : public DepsgraphBuilder {
void build_movieclip(MovieClip *clip);
void build_lightprobe(LightProbe *probe);
void build_speaker(Speaker *speaker);
+ void build_sound(bSound *sound);
+ void build_sequencer(Scene *scene);
+ void build_scene_audio(Scene *scene);
void build_nested_datablock(ID *owner, ID *id);
void build_nested_nodetree(ID *owner, bNodeTree *ntree);
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 c1f904150f3..fadce685d31 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -374,7 +374,7 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
* to done, with transitive reduction removing this one. */
add_relation(bone_ready_key, bone_done_key, "Ready -> Done");
/* B-Bone shape is the real final step after Done if present. */
- if (pchan->bone != NULL && pchan->bone->segments > 1) {
+ if (check_pchan_has_bbone(object, pchan)) {
OperationKey bone_segments_key(
&object->id, NodeType::BONE, pchan->name, OperationCode::BONE_SEGMENTS);
/* B-Bone shape depends on the final position of the bone. */
@@ -434,7 +434,7 @@ void DepsgraphRelationBuilder::build_proxy_rig(Object *object)
add_relation(bone_done_key, pose_cleanup_key, "Bone Done -> Pose Cleanup");
add_relation(bone_done_key, pose_done_key, "Bone Done -> Pose Done", RELATION_FLAG_GODMODE);
/* Make sure bone in the proxy is not done before it's FROM is done. */
- if (pchan->bone && pchan->bone->segments > 1) {
+ if (check_pchan_has_bbone(object, pchan)) {
OperationKey from_bone_segments_key(
&proxy_from->id, NodeType::BONE, pchan->name, OperationCode::BONE_SEGMENTS);
add_relation(from_bone_segments_key,
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 a325544e046..cadb4ab3611 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
@@ -75,7 +75,9 @@ void DepsgraphRelationBuilder::build_layer_collections(ListBase *lb)
}
}
-void DepsgraphRelationBuilder::build_view_layer(Scene *scene, ViewLayer *view_layer)
+void DepsgraphRelationBuilder::build_view_layer(Scene *scene,
+ ViewLayer *view_layer,
+ eDepsNode_LinkedState_Type linked_state)
{
/* Setup currently building context. */
scene_ = scene;
@@ -128,10 +130,15 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, ViewLayer *view_la
build_collection(NULL, NULL, fls->group);
}
}
+ /* Sequencer. */
+ if (linked_state == DEG_ID_LINKED_DIRECTLY) {
+ build_scene_audio(scene);
+ build_sequencer(scene);
+ }
/* Build all set scenes. */
if (scene->set != NULL) {
ViewLayer *set_view_layer = BKE_view_layer_default_render(scene->set);
- build_view_layer(scene->set, set_view_layer);
+ build_view_layer(scene->set, set_view_layer, DEG_ID_LINKED_VIA_SET);
}
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index 810d3ee3f66..ea5f86a31a8 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -45,6 +45,7 @@ extern "C" {
#include "RNA_access.h"
#include "intern/depsgraph.h"
+#include "intern/builder/deg_builder.h"
#include "intern/node/deg_node.h"
#include "intern/node/deg_node_component.h"
#include "intern/node/deg_node_id.h"
@@ -130,8 +131,10 @@ void ghash_id_data_free_func(void *value)
} // namespace
-RNANodeQuery::RNANodeQuery(Depsgraph *depsgraph)
- : depsgraph_(depsgraph), id_data_map_(BLI_ghash_ptr_new("rna node query id data hash"))
+RNANodeQuery::RNANodeQuery(Depsgraph *depsgraph, DepsgraphBuilder *builder)
+ : depsgraph_(depsgraph),
+ builder_(builder),
+ id_data_map_(BLI_ghash_ptr_new("rna node query id data hash"))
{
}
@@ -194,20 +197,26 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
node_identifier.type = NodeType::BONE;
node_identifier.component_name = pchan->name;
/* But B-Bone properties should connect to the actual operation. */
- if (!ELEM(NULL, pchan->bone, prop) && pchan->bone->segments > 1 &&
- STRPREFIX(RNA_property_identifier(prop), "bbone_")) {
+ Object *object = reinterpret_cast<Object *>(node_identifier.id);
+ if (!ELEM(NULL, pchan->bone, prop) && STRPREFIX(RNA_property_identifier(prop), "bbone_") &&
+ builder_->check_pchan_has_bbone_segments(object, pchan)) {
node_identifier.operation_code = OperationCode::BONE_SEGMENTS;
}
}
return node_identifier;
}
else if (ptr->type == &RNA_Bone) {
- const Bone *bone = static_cast<const Bone *>(ptr->data);
- /* Armature-level bone, but it ends up going to bone component
- * anyway. */
- // NOTE: the ID in this case will end up being bArmature.
- node_identifier.type = NodeType::BONE;
- node_identifier.component_name = bone->name;
+ /* Armature-level bone mapped to Armature Eval, and thus Pose Init.
+ * Drivers have special code elsewhere that links them to the pose
+ * bone components, instead of using this generic code. */
+ node_identifier.type = NodeType::PARAMETERS;
+ node_identifier.operation_code = OperationCode::ARMATURE_EVAL;
+ /* If trying to look up via an Object, e.g. due to lookup via
+ * obj.pose.bones[].bone in a driver attached to the Object,
+ * redirect to its data. */
+ if (GS(node_identifier.id->name) == ID_OB) {
+ node_identifier.id = (ID *)((Object *)node_identifier.id)->data;
+ }
return node_identifier;
}
else if (RNA_struct_is_a(ptr->type, &RNA_Constraint)) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.h b/source/blender/depsgraph/intern/builder/deg_builder_rna.h
index e8dbd7fb523..26d7963e0a8 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.h
@@ -36,6 +36,7 @@ namespace DEG {
struct Depsgraph;
struct Node;
class RNANodeQueryIDData;
+class DepsgraphBuilder;
/* For queries which gives operation node or key defines whether we are
* interested in a result of the given property or whether we are linking some
@@ -72,13 +73,14 @@ class RNANodeIdentifier {
* dependency graph which satisfies given RNA pointer or RAN path. */
class RNANodeQuery {
public:
- RNANodeQuery(Depsgraph *depsgraph);
+ RNANodeQuery(Depsgraph *depsgraph, DepsgraphBuilder *builder);
~RNANodeQuery();
Node *find_node(const PointerRNA *ptr, const PropertyRNA *prop, RNAPointerSource source);
protected:
Depsgraph *depsgraph_;
+ DepsgraphBuilder *builder_;
/* Indexed by an ID, returns RNANodeQueryIDData associated with that ID. */
GHash *id_data_map_;
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 068a04943e6..c4455a6e59f 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
@@ -434,6 +434,7 @@ static void deg_debug_graphviz_node(const DebugContext &ctx, const Node *node)
case NodeType::BATCH_CACHE:
case NodeType::DUPLI:
case NodeType::SYNCHRONIZATION:
+ case NodeType::AUDIO:
case NodeType::GENERIC_DATABLOCK: {
ComponentNode *comp_node = (ComponentNode *)node;
if (!comp_node->operations.empty()) {
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index e4c84264960..a4082c24dec 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -46,6 +46,7 @@ extern "C" {
#include "DEG_depsgraph_build.h"
#include "builder/deg_builder.h"
+#include "builder/deg_builder_cache.h"
#include "builder/deg_builder_cycle.h"
#include "builder/deg_builder_nodes.h"
#include "builder/deg_builder_relations.h"
@@ -238,16 +239,17 @@ void DEG_graph_build_from_view_layer(Depsgraph *graph,
BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1);
BLI_assert(deg_graph->scene == scene);
BLI_assert(deg_graph->view_layer == view_layer);
+ DEG::DepsgraphBuilderCache builder_cache;
/* Generate all the nodes in the graph first */
- DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph);
+ DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache);
node_builder.begin_build();
node_builder.build_view_layer(scene, view_layer, DEG::DEG_ID_LINKED_DIRECTLY);
node_builder.end_build();
/* Hook up relationships between operations - to determine evaluation
* order. */
- DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph);
+ DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache);
relation_builder.begin_build();
- relation_builder.build_view_layer(scene, view_layer);
+ relation_builder.build_view_layer(scene, view_layer, DEG::DEG_ID_LINKED_DIRECTLY);
relation_builder.build_copy_on_write_relations();
/* Detect and solve cycles. */
DEG::deg_graph_detect_cycles(deg_graph);
diff --git a/source/blender/depsgraph/intern/depsgraph_query_filter.cc b/source/blender/depsgraph/intern/depsgraph_query_filter.cc
deleted file mode 100644
index 987e9330d35..00000000000
--- a/source/blender/depsgraph/intern/depsgraph_query_filter.cc
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * 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.
- */
-
-/** \file
- * \ingroup depsgraph
- *
- * Implementation of Graph Filtering API
- */
-
-#include "MEM_guardedalloc.h"
-
-extern "C" {
-#include <string.h> // XXX: memcpy
-
-#include "BLI_utildefines.h"
-#include "BKE_idcode.h"
-#include "BKE_main.h"
-#include "BLI_listbase.h"
-#include "BLI_ghash.h"
-
-#include "BKE_action.h" // XXX: BKE_pose_channel_from_name
-} /* extern "C" */
-
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-
-#include "RNA_access.h"
-
-#include "DEG_depsgraph.h"
-#include "DEG_depsgraph_query.h"
-#include "DEG_depsgraph_debug.h"
-
-#include "intern/eval/deg_eval_copy_on_write.h"
-
-#include "intern/depsgraph.h"
-#include "intern/depsgraph_type.h"
-
-#include "intern/node/deg_node.h"
-#include "intern/node/deg_node_component.h"
-#include "intern/node/deg_node_id.h"
-#include "intern/node/deg_node_operation.h"
-
-/* *************************************************** */
-/* Graph Filtering Internals */
-
-namespace DEG {
-
-/* UserData for deg_add_retained_id_cb */
-struct RetainedIdUserData {
- DEG_FilterQuery *query;
- GSet *set;
-};
-
-/* Helper for DEG_foreach_ancestor_id()
- * Keep track of all ID's encountered in a set
- */
-static void deg_add_retained_id_cb(ID *id, void *user_data)
-{
- RetainedIdUserData *data = (RetainedIdUserData *)user_data;
- BLI_gset_add(data->set, (void *)id);
-}
-
-/* ------------------------------------------- */
-
-/* Remove relations pointing to the given OperationNode */
-/* TODO: Make this part of OperationNode? */
-static void deg_unlink_opnode(Depsgraph *graph, OperationNode *op_node)
-{
- vector<Relation *> all_links;
-
- /* Collect all inlinks to this operation */
- for (Relation *rel : op_node->inlinks) {
- all_links.push_back(rel);
- }
- /* Collect all outlinks from this operation */
- for (Relation *rel : op_node->outlinks) {
- all_links.push_back(rel);
- }
-
- /* Delete all collected relations */
- for (Relation *rel : all_links) {
- rel->unlink();
- OBJECT_GUARDED_DELETE(rel, Relation);
- }
-
- /* Remove from entry tags */
- if (BLI_gset_haskey(graph->entry_tags, op_node)) {
- BLI_gset_remove(graph->entry_tags, op_node, NULL);
- }
-}
-
-/* Remove every ID Node (and its associated subnodes, COW data) */
-static void deg_filter_remove_unwanted_ids(Depsgraph *graph, GSet *retained_ids)
-{
- /* 1) First pass over ID nodes + their operations
- * - Identify and tag ID's (via "custom_flags = 1") to be removed
- * - Remove all links to/from operations that will be removed. */
- for (IDNode *id_node : graph->id_nodes) {
- id_node->custom_flags = !BLI_gset_haskey(retained_ids, (void *)id_node->id_orig);
- if (id_node->custom_flags) {
- GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, id_node->components) {
- for (OperationNode *op_node : comp_node->operations) {
- deg_unlink_opnode(graph, op_node);
- }
- }
- GHASH_FOREACH_END();
- }
- }
-
- /* 2) Remove unwanted operations from graph->operations */
- for (Depsgraph::OperationNodes::iterator it_opnode = graph->operations.begin();
- it_opnode != graph->operations.end();) {
- OperationNode *op_node = *it_opnode;
- IDNode *id_node = op_node->owner->owner;
- if (id_node->custom_flags) {
- it_opnode = graph->operations.erase(it_opnode);
- }
- else {
- ++it_opnode;
- }
- }
-
- /* Free ID nodes that are no longer wanted
- *
- * This is loosely based on Depsgraph::clear_id_nodes().
- * However, we don't worry about the conditional freeing for physics
- * stuff, since it's rarely needed currently. */
- for (Depsgraph::IDDepsNodes::iterator it_id = graph->id_nodes.begin();
- it_id != graph->id_nodes.end();) {
- IDNode *id_node = *it_id;
- ID *id = id_node->id_orig;
-
- if (id_node->custom_flags) {
- /* Destroy node data, then remove from collections, and free */
- id_node->destroy();
-
- BLI_ghash_remove(graph->id_hash, id, NULL, NULL);
- it_id = graph->id_nodes.erase(it_id);
-
- OBJECT_GUARDED_DELETE(id_node, IDNode);
- }
- else {
- /* This node has not been marked for deletion. Increment iterator */
- ++it_id;
- }
- }
-}
-
-} //namespace DEG
-
-/* *************************************************** */
-/* Graph Filtering API */
-
-/* Obtain a new graph instance that only contains the subset of desired nodes
- * WARNING: Do NOT pass an already filtered depsgraph through this function again,
- * as we are currently unable to accurately recreate it.
- */
-Depsgraph *DEG_graph_filter(const Depsgraph *graph_src, Main *bmain, DEG_FilterQuery *query)
-{
- const DEG::Depsgraph *deg_graph_src = reinterpret_cast<const DEG::Depsgraph *>(graph_src);
- if (deg_graph_src == NULL) {
- return NULL;
- }
-
- /* Construct a full new depsgraph based on the one we got */
- /* TODO: Improve the builders to not add any ID nodes we don't need later (e.g. ProxyBuilder?) */
- Depsgraph *graph_new = DEG_graph_new(
- deg_graph_src->scene, deg_graph_src->view_layer, deg_graph_src->mode);
- DEG_graph_build_from_view_layer(
- graph_new, bmain, deg_graph_src->scene, deg_graph_src->view_layer);
-
- /* Build a set of all the id's we want to keep */
- GSet *retained_ids = BLI_gset_ptr_new(__func__);
- DEG::RetainedIdUserData retained_id_data = {query, retained_ids};
-
- LISTBASE_FOREACH (DEG_FilterTarget *, target, &query->targets) {
- /* Target Itself */
- BLI_gset_add(retained_ids, (void *)target->id);
-
- /* Target's Ancestors (i.e. things it depends on) */
- DEG_foreach_ancestor_ID(graph_new, target->id, DEG::deg_add_retained_id_cb, &retained_id_data);
- }
-
- /* Remove everything we don't want to keep around anymore */
- DEG::Depsgraph *deg_graph_new = reinterpret_cast<DEG::Depsgraph *>(graph_new);
- if (BLI_gset_len(retained_ids) > 0) {
- DEG::deg_filter_remove_unwanted_ids(deg_graph_new, retained_ids);
- }
- // TODO: query->LOD filters
-
- /* Free temp data */
- BLI_gset_free(retained_ids, NULL);
- retained_ids = NULL;
-
- /* Print Stats */
- // XXX: Hide behind debug flags
- size_t s_outer, s_operations, s_relations;
- size_t s_ids = deg_graph_src->id_nodes.size();
- unsigned int s_idh = BLI_ghash_len(deg_graph_src->id_hash);
-
- size_t n_outer, n_operations, n_relations;
- size_t n_ids = deg_graph_new->id_nodes.size();
- unsigned int n_idh = BLI_ghash_len(deg_graph_new->id_hash);
-
- DEG_stats_simple(graph_src, &s_outer, &s_operations, &s_relations);
- DEG_stats_simple(graph_new, &n_outer, &n_operations, &n_relations);
-
- printf("%s: src = (ID's: %zu (%u), Out: %zu, Op: %zu, Rel: %zu)\n",
- __func__,
- s_ids,
- s_idh,
- s_outer,
- s_operations,
- s_relations);
- printf("%s: new = (ID's: %zu (%u), Out: %zu, Op: %zu, Rel: %zu)\n",
- __func__,
- n_ids,
- n_idh,
- n_outer,
- n_operations,
- n_relations);
-
- /* Return this new graph instance */
- return graph_new;
-}
-
-/* *************************************************** */
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index f682dadee8e..f7d7b76cb69 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -215,6 +215,9 @@ void depsgraph_tag_to_component_opcode(const ID *id,
/* There is no such node in depsgraph, this tag is to be handled
* separately. */
break;
+ case ID_RECALC_SEQUENCER:
+ *component_type = NodeType::SEQUENCER;
+ break;
case ID_RECALC_ALL:
case ID_RECALC_PSYS_ALL:
BLI_assert(!"Should not happen");
@@ -615,6 +618,8 @@ const char *DEG_update_tag_as_string(IDRecalcFlag flag)
return "POINT_CACHE";
case ID_RECALC_EDITORS:
return "EDITORS";
+ case ID_RECALC_SEQUENCER:
+ return "SEQUENCER";
case ID_RECALC_ALL:
return "ALL";
}
diff --git a/source/blender/depsgraph/intern/depsgraph_type.h b/source/blender/depsgraph/intern/depsgraph_type.h
index 51ed31b8e25..cce64116907 100644
--- a/source/blender/depsgraph/intern/depsgraph_type.h
+++ b/source/blender/depsgraph/intern/depsgraph_type.h
@@ -37,6 +37,7 @@
#include <vector>
#include <algorithm>
#include <map>
+#include <set>
#include <unordered_map>
struct Depsgraph;
@@ -48,6 +49,7 @@ namespace DEG {
/* Commonly used types. */
using std::map;
using std::pair;
+using std::set;
using std::string;
using std::unordered_map;
using std::vector;
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 49975407c0b..bb4300e5330 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
@@ -59,6 +59,8 @@ extern "C" {
#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_sound_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
@@ -84,6 +86,8 @@ extern "C" {
#include "BKE_library_query.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
+#include "BKE_sequencer.h"
+#include "BKE_sound.h"
}
#include "intern/depsgraph.h"
@@ -380,7 +384,7 @@ void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, ViewLayer *vie
* points to is not yet copied. This is dangerous access from evaluated
* domain to original one, but this is how the entire copy-on-write works:
* it does need to access original for an initial copy. */
- const bool is_object_enabled = deg_check_base_available_for_build(depsgraph, base->base_orig);
+ const bool is_object_enabled = deg_check_base_in_depsgraph(depsgraph, base);
if (is_object_enabled) {
BLI_addtail(&enabled_bases, base);
}
@@ -424,6 +428,25 @@ void scene_setup_view_layers_after_remap(const Depsgraph *depsgraph,
* Still not an excuse to have those. */
}
+void update_sequence_orig_pointers(const ListBase *sequences_orig, ListBase *sequences_cow)
+{
+ Sequence *sequence_orig = reinterpret_cast<Sequence *>(sequences_orig->first);
+ Sequence *sequence_cow = reinterpret_cast<Sequence *>(sequences_cow->first);
+ while (sequence_orig != NULL) {
+ update_sequence_orig_pointers(&sequence_orig->seqbase, &sequence_cow->seqbase);
+ sequence_cow->orig_sequence = sequence_orig;
+ sequence_cow = sequence_cow->next;
+ sequence_orig = sequence_orig->next;
+ }
+}
+
+void update_scene_orig_pointers(const Scene *scene_orig, Scene *scene_cow)
+{
+ if (scene_orig->ed != NULL) {
+ update_sequence_orig_pointers(&scene_orig->ed->seqbase, &scene_cow->ed->seqbase);
+ }
+}
+
/* Check whether given ID is expanded or still a shallow copy. */
BLI_INLINE bool check_datablock_expanded(const ID *id_cow)
{
@@ -633,6 +656,40 @@ void update_modifiers_orig_pointers(const Object *object_orig, Object *object_co
&object_orig->modifiers, &object_cow->modifiers, &ModifierData::orig_modifier_data);
}
+void update_nla_strips_orig_pointers(const ListBase *strips_orig, ListBase *strips_cow)
+{
+ NlaStrip *strip_orig = reinterpret_cast<NlaStrip *>(strips_orig->first);
+ NlaStrip *strip_cow = reinterpret_cast<NlaStrip *>(strips_cow->first);
+ while (strip_orig != NULL) {
+ strip_cow->orig_strip = strip_orig;
+ update_nla_strips_orig_pointers(&strip_orig->strips, &strip_cow->strips);
+ strip_cow = strip_cow->next;
+ strip_orig = strip_orig->next;
+ }
+}
+
+void update_nla_tracks_orig_pointers(const ListBase *tracks_orig, ListBase *tracks_cow)
+{
+ NlaTrack *track_orig = reinterpret_cast<NlaTrack *>(tracks_orig->first);
+ NlaTrack *track_cow = reinterpret_cast<NlaTrack *>(tracks_cow->first);
+ while (track_orig != NULL) {
+ update_nla_strips_orig_pointers(&track_orig->strips, &track_cow->strips);
+ track_cow = track_cow->next;
+ track_orig = track_orig->next;
+ }
+}
+
+void update_animation_data_after_copy(const ID *id_orig, ID *id_cow)
+{
+ const AnimData *anim_data_orig = BKE_animdata_from_id(const_cast<ID *>(id_orig));
+ if (anim_data_orig == NULL) {
+ return;
+ }
+ AnimData *anim_data_cow = BKE_animdata_from_id(id_cow);
+ BLI_assert(anim_data_cow != NULL);
+ update_nla_tracks_orig_pointers(&anim_data_orig->nla_tracks, &anim_data_cow->nla_tracks);
+}
+
/* Do some special treatment of data transfer from original ID to it's
* CoW complementary part.
*
@@ -643,6 +700,7 @@ void update_id_after_copy(const Depsgraph *depsgraph,
ID *id_cow)
{
const ID_Type type = GS(id_orig->name);
+ update_animation_data_after_copy(id_orig, id_cow);
switch (type) {
case ID_OB: {
/* Ensure we don't drag someone's else derived mesh to the
@@ -673,6 +731,7 @@ void update_id_after_copy(const Depsgraph *depsgraph,
scene_cow->toolsettings = scene_orig->toolsettings;
scene_cow->eevee.light_cache = scene_orig->eevee.light_cache;
scene_setup_view_layers_after_remap(depsgraph, id_node, reinterpret_cast<Scene *>(id_cow));
+ update_scene_orig_pointers(scene_orig, scene_cow);
break;
}
default:
@@ -803,6 +862,205 @@ ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph,
namespace {
+/* Backup of sequencer strips runtime data. */
+
+/* Backup of a single strip. */
+class SequenceBackup {
+ public:
+ SequenceBackup()
+ {
+ reset();
+ }
+
+ inline void reset()
+ {
+ scene_sound = NULL;
+ }
+
+ void init_from_sequence(Sequence *sequence)
+ {
+ scene_sound = sequence->scene_sound;
+
+ sequence->scene_sound = NULL;
+ }
+
+ void restore_to_sequence(Sequence *sequence)
+ {
+ sequence->scene_sound = scene_sound;
+ reset();
+ }
+
+ inline bool isEmpty() const
+ {
+ return (scene_sound == NULL);
+ }
+
+ void *scene_sound;
+};
+
+class SequencerBackup {
+ public:
+ SequencerBackup();
+
+ void init_from_scene(Scene *scene);
+ void restore_to_scene(Scene *scene);
+
+ typedef map<Sequence *, SequenceBackup> SequencesBackupMap;
+ SequencesBackupMap sequences_backup;
+};
+
+SequencerBackup::SequencerBackup()
+{
+}
+
+void SequencerBackup::init_from_scene(Scene *scene)
+{
+ Sequence *sequence;
+ SEQ_BEGIN (scene->ed, sequence) {
+ SequenceBackup sequence_backup;
+ sequence_backup.init_from_sequence(sequence);
+ if (!sequence_backup.isEmpty()) {
+ sequences_backup.insert(make_pair(sequence->orig_sequence, sequence_backup));
+ }
+ }
+ SEQ_END;
+}
+
+void SequencerBackup::restore_to_scene(Scene *scene)
+{
+ Sequence *sequence;
+ SEQ_BEGIN (scene->ed, sequence) {
+ SequencesBackupMap::iterator it = sequences_backup.find(sequence->orig_sequence);
+ if (it == sequences_backup.end()) {
+ continue;
+ }
+ SequenceBackup &sequence_backup = it->second;
+ sequence_backup.restore_to_sequence(sequence);
+ }
+ SEQ_END;
+ /* Cleanup audio while the scene is still known. */
+ for (SequencesBackupMap::value_type &it : sequences_backup) {
+ SequenceBackup &sequence_backup = it.second;
+ if (sequence_backup.scene_sound != NULL) {
+ BKE_sound_remove_scene_sound(scene, sequence_backup.scene_sound);
+ }
+ }
+}
+
+/* Backup of scene runtime data. */
+
+class SceneBackup {
+ public:
+ SceneBackup();
+
+ void reset();
+
+ void init_from_scene(Scene *scene);
+ void restore_to_scene(Scene *scene);
+
+ /* Sound/audio related pointers of the scene itself.
+ *
+ * NOTE: Scene can not disappear after relations update, because otherwise the entire dependency
+ * graph will be gone. This means we don't need to compare original scene pointer, or worry about
+ * freeing those if they cant' be restorted: we just copy them over to a new scene. */
+ void *sound_scene;
+ void *playback_handle;
+ void *sound_scrub_handle;
+ void *speaker_handles;
+
+ SequencerBackup sequencer_backup;
+};
+
+SceneBackup::SceneBackup()
+{
+ reset();
+}
+
+void SceneBackup::reset()
+{
+ sound_scene = NULL;
+ playback_handle = NULL;
+ sound_scrub_handle = NULL;
+ speaker_handles = NULL;
+}
+
+void SceneBackup::init_from_scene(Scene *scene)
+{
+ sound_scene = scene->sound_scene;
+ playback_handle = scene->playback_handle;
+ sound_scrub_handle = scene->sound_scrub_handle;
+ speaker_handles = scene->speaker_handles;
+
+ /* Clear pointers stored in the scene, so they are not freed when copied-on-written datablock
+ * is freed for re-allocation. */
+ scene->sound_scene = NULL;
+ scene->playback_handle = NULL;
+ scene->sound_scrub_handle = NULL;
+ scene->speaker_handles = NULL;
+
+ sequencer_backup.init_from_scene(scene);
+}
+
+void SceneBackup::restore_to_scene(Scene *scene)
+{
+ scene->sound_scene = sound_scene;
+ scene->playback_handle = playback_handle;
+ scene->sound_scrub_handle = sound_scrub_handle;
+ scene->speaker_handles = speaker_handles;
+
+ sequencer_backup.restore_to_scene(scene);
+
+ reset();
+}
+
+/* Backup of sound datablocks runtime data. */
+
+class SoundBackup {
+ public:
+ SoundBackup();
+
+ void reset();
+
+ void init_from_sound(bSound *sound);
+ void restore_to_sound(bSound *sound);
+
+ void *cache;
+ void *waveform;
+ void *playback_handle;
+};
+
+SoundBackup::SoundBackup()
+{
+ reset();
+}
+
+void SoundBackup::reset()
+{
+ cache = NULL;
+ waveform = NULL;
+ playback_handle = NULL;
+}
+
+void SoundBackup::init_from_sound(bSound *sound)
+{
+ cache = sound->cache;
+ waveform = sound->waveform;
+ playback_handle = sound->playback_handle;
+
+ sound->cache = NULL;
+ sound->waveform = NULL;
+ sound->playback_handle = NULL;
+}
+
+void SoundBackup::restore_to_sound(bSound *sound)
+{
+ sound->cache = cache;
+ sound->waveform = waveform;
+ sound->playback_handle = playback_handle;
+
+ reset();
+}
+
/* Identifier used to match modifiers to backup/restore their runtime data.
* Identification is happening using original modifier data pointer and the
* modifier type.
@@ -843,7 +1101,8 @@ typedef map<ModifierDataBackupID, void *> ModifierRuntimeDataBackup;
/* Storage for backed up pose channel runtime data. */
typedef map<bPoseChannel *, bPoseChannel_Runtime> PoseChannelRuntimeDataBackup;
-struct ObjectRuntimeBackup {
+class ObjectRuntimeBackup {
+ public:
ObjectRuntimeBackup() : base_flag(0), base_local_view_bits(0)
{
/* TODO(sergey): Use something like BKE_object_runtime_reset(). */
@@ -1021,6 +1280,8 @@ class RuntimeBackup {
/* Restore fields to the given ID. */
void restore_to_id(ID *id);
+ SceneBackup scene_backup;
+ SoundBackup sound_backup;
ObjectRuntimeBackup object_backup;
DrawDataList drawdata_backup;
DrawDataList *drawdata_ptr;
@@ -1036,6 +1297,12 @@ void RuntimeBackup::init_from_id(ID *id)
case ID_OB:
object_backup.init_from_object(reinterpret_cast<Object *>(id));
break;
+ case ID_SCE:
+ scene_backup.init_from_scene(reinterpret_cast<Scene *>(id));
+ break;
+ case ID_SO:
+ sound_backup.init_from_sound(reinterpret_cast<bSound *>(id));
+ break;
default:
break;
}
@@ -1055,6 +1322,12 @@ void RuntimeBackup::restore_to_id(ID *id)
case ID_OB:
object_backup.restore_to_object(reinterpret_cast<Object *>(id));
break;
+ case ID_SCE:
+ scene_backup.restore_to_scene(reinterpret_cast<Scene *>(id));
+ break;
+ case ID_SO:
+ sound_backup.restore_to_sound(reinterpret_cast<bSound *>(id));
+ break;
default:
break;
}
diff --git a/source/blender/depsgraph/intern/node/deg_node.cc b/source/blender/depsgraph/intern/node/deg_node.cc
index 5692983fbe2..7df96330ef0 100644
--- a/source/blender/depsgraph/intern/node/deg_node.cc
+++ b/source/blender/depsgraph/intern/node/deg_node.cc
@@ -101,13 +101,12 @@ const char *nodeTypeAsString(NodeType type)
return "POINT_CACHE";
case NodeType::BATCH_CACHE:
return "BATCH_CACHE";
- /* Duplication. */
case NodeType::DUPLI:
return "DUPLI";
- /* Synchronization. */
case NodeType::SYNCHRONIZATION:
return "SYNCHRONIZATION";
- /* Generic datablock. */
+ case NodeType::AUDIO:
+ return "AUDIO";
case NodeType::GENERIC_DATABLOCK:
return "GENERIC_DATABLOCK";
diff --git a/source/blender/depsgraph/intern/node/deg_node.h b/source/blender/depsgraph/intern/node/deg_node.h
index ece43657b38..e350cc9a6f4 100644
--- a/source/blender/depsgraph/intern/node/deg_node.h
+++ b/source/blender/depsgraph/intern/node/deg_node.h
@@ -92,6 +92,8 @@ enum class NodeType {
/* Used by all operations which are updating object when something is
* changed in view layer. */
OBJECT_FROM_LAYER,
+ /* Audio-related evaluation. */
+ AUDIO,
/* Un-interestying datablock, which is a part of dependency graph, but does
* not have very distinctive update procedure. */
GENERIC_DATABLOCK,
diff --git a/source/blender/depsgraph/intern/node/deg_node_component.cc b/source/blender/depsgraph/intern/node/deg_node_component.cc
index dc7ca371de3..f67a81f594f 100644
--- a/source/blender/depsgraph/intern/node/deg_node_component.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_component.cc
@@ -131,7 +131,6 @@ string ComponentNode::identifier() const
const string typebuf = "" + to_string(static_cast<int>(type)) + ")";
return typebuf + name + " : " + idname +
"( affects_directly_visible: " + (affects_directly_visible ? "true" : "false") + ")";
- ;
}
OperationNode *ComponentNode::find_operation(OperationIDKey key) const
@@ -335,7 +334,7 @@ void BoneComponentNode::init(const ID *id, const char *subdata)
/* name of component comes is bone name */
/* TODO(sergey): This sets name to an empty string because subdata is
* empty. Is it a bug? */
- //this->name = subdata;
+ // this->name = subdata;
/* bone-specific node data */
Object *object = (Object *)id;
@@ -365,6 +364,7 @@ DEG_COMPONENT_NODE_DEFINE(Transform, TRANSFORM, ID_RECALC_TRANSFORM);
DEG_COMPONENT_NODE_DEFINE(ObjectFromLayer, OBJECT_FROM_LAYER, 0);
DEG_COMPONENT_NODE_DEFINE(Dupli, DUPLI, 0);
DEG_COMPONENT_NODE_DEFINE(Synchronization, SYNCHRONIZATION, 0);
+DEG_COMPONENT_NODE_DEFINE(Audio, AUDIO, 0);
DEG_COMPONENT_NODE_DEFINE(GenericDatablock, GENERIC_DATABLOCK, 0);
/* Node Types Register =================================== */
@@ -391,6 +391,7 @@ void deg_register_component_depsnodes()
register_node_typeinfo(&DNTI_OBJECT_FROM_LAYER);
register_node_typeinfo(&DNTI_DUPLI);
register_node_typeinfo(&DNTI_SYNCHRONIZATION);
+ register_node_typeinfo(&DNTI_AUDIO);
register_node_typeinfo(&DNTI_GENERIC_DATABLOCK);
}
diff --git a/source/blender/depsgraph/intern/node/deg_node_component.h b/source/blender/depsgraph/intern/node/deg_node_component.h
index 038b5917a86..733d32e9c2d 100644
--- a/source/blender/depsgraph/intern/node/deg_node_component.h
+++ b/source/blender/depsgraph/intern/node/deg_node_component.h
@@ -186,6 +186,7 @@ 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(Synchronization);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Audio);
DEG_COMPONENT_NODE_DECLARE_GENERIC(GenericDatablock);
/* Bone Component */
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc
index 77e8f4f37e0..c5b9c56bcf0 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_id.cc
@@ -111,6 +111,7 @@ void IDNode::init(const ID *id, const char *UNUSED(subdata))
linked_state = DEG_ID_LINKED_INDIRECTLY;
is_directly_visible = true;
is_collection_fully_expanded = false;
+ has_base = false;
visible_components_mask = 0;
previously_visible_components_mask = 0;
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.h b/source/blender/depsgraph/intern/node/deg_node_id.h
index 34d78e29060..b4351ec988c 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.h
+++ b/source/blender/depsgraph/intern/node/deg_node_id.h
@@ -96,6 +96,9 @@ struct IDNode : public Node {
* recursed into. */
bool is_collection_fully_expanded;
+ /* Is used to figure out whether object came to the dependency graph via a base. */
+ bool has_base;
+
IDComponentsMask visible_components_mask;
IDComponentsMask previously_visible_components_mask;
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.cc b/source/blender/depsgraph/intern/node/deg_node_operation.cc
index 154563303ad..09a761d282f 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.cc
@@ -100,6 +100,8 @@ const char *operationCodeAsString(OperationCode opcode)
return "LIGHT_PROBE_EVAL";
case OperationCode::SPEAKER_EVAL:
return "SPEAKER_EVAL";
+ case OperationCode::SOUND_EVAL:
+ return "SOUND_EVAL";
case OperationCode::ARMATURE_EVAL:
return "ARMATURE_EVAL";
/* Pose. */
@@ -183,6 +185,9 @@ const char *operationCodeAsString(OperationCode opcode)
/* Generic datablock. */
case OperationCode::GENERIC_DATABLOCK_UPDATE:
return "GENERIC_DATABLOCK_UPDATE";
+ /* Sequencer. */
+ case OperationCode::SEQUENCES_EVAL:
+ return "SEQUENCES_EVAL";
/* instancing/duplication. */
case OperationCode::DUPLI:
return "DUPLI";
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.h b/source/blender/depsgraph/intern/node/deg_node_operation.h
index c959f7f34e0..8fc565cfa77 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.h
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.h
@@ -106,6 +106,7 @@ enum class OperationCode {
/* Object data. --------------------------------------------------------- */
LIGHT_PROBE_EVAL,
SPEAKER_EVAL,
+ SOUND_EVAL,
ARMATURE_EVAL,
/* Pose. ---------------------------------------------------------------- */
@@ -184,12 +185,16 @@ enum class OperationCode {
/* Images. -------------------------------------------------------------- */
IMAGE_ANIMATION,
- /* Synchronization clips. ----------------------------------------------- */
+ /* Synchronization. ----------------------------------------------------- */
SYNCHRONIZE_TO_ORIGINAL,
/* Generic datablock ---------------------------------------------------- */
GENERIC_DATABLOCK_UPDATE,
+ /* Sequencer. ----------------------------------------------------------- */
+
+ SEQUENCES_EVAL,
+
/* Duplication/instancing system. --------------------------------------- */
DUPLI,
};
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 13888167d2c..f07568965bb 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -39,9 +39,9 @@ set(INC
../render/intern/include
../windowmanager
+ ../../../intern/atomic
../../../intern/glew-mx
../../../intern/guardedalloc
- ../../../intern/atomic
)
set(INC_SYS
@@ -301,6 +301,8 @@ data_to_c_simple(modes/shaders/edit_mesh_overlay_geom.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)
+data_to_c_simple(modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl SRC)
+data_to_c_simple(modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_curve_overlay_handle_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_curve_overlay_handle_geom.glsl SRC)
data_to_c_simple(modes/shaders/edit_curve_overlay_loosevert_vert.glsl SRC)
diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c
index 16788c10680..05ee485e053 100644
--- a/source/blender/draw/engines/basic/basic_engine.c
+++ b/source/blender/draw/engines/basic/basic_engine.c
@@ -169,8 +169,8 @@ static void basic_cache_populate(void *vedata, Object *ob)
const bool do_cull = (draw_ctx->v3d &&
(draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING));
/* Depth Prepass */
- DRW_shgroup_call_add(
- (do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat);
+ DRW_shgroup_call_object_add(
+ (do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob);
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_bloom.c b/source/blender/draw/engines/eevee/eevee_bloom.c
index e5d33daa0d0..b0013151a70 100644
--- a/source/blender/draw/engines/eevee/eevee_bloom.c
+++ b/source/blender/draw/engines/eevee/eevee_bloom.c
@@ -206,31 +206,32 @@ void EEVEE_bloom_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *ved
if ((effects->enabled_effects & EFFECT_BLOOM) != 0) {
/** Bloom algorithm
*
- * Overview :
+ * Overview:
* - Downsample the color buffer doing a small blur during each step.
* - Accumulate bloom color using previously downsampled color buffers
* and do an upsample blur for each new accumulated layer.
* - Finally add accumulation buffer onto the source color buffer.
*
* [1/1] is original copy resolution (can be half or quarter res for performance)
+ * <pre>
+ * [DOWNSAMPLE CHAIN] [UPSAMPLE CHAIN]
*
- * [DOWNSAMPLE CHAIN] [UPSAMPLE CHAIN]
- *
- * Source Color ── [Blit] ──> Bright Color Extract [1/1] Final Color
- * | Λ
- * [Downsample First] Source Color ─> + [Resolve]
- * v |
- * Color Downsampled [1/2] ────────────> + Accumulation Buffer [1/2]
- * | Λ
- * ─── ───
- * Repeat Repeat
- * ─── ───
- * v |
- * Color Downsampled [1/N-1] ──────────> + Accumulation Buffer [1/N-1]
- * | Λ
- * [Downsample] [Upsample]
- * v |
- * Color Downsampled [1/N] ─────────────────────────┘
+ * Source Color ─ [Blit] ─> Bright Color Extract [1/1] Final Color
+ * | Λ
+ * [Downsample First] Source Color ─> + [Resolve]
+ * v |
+ * Color Downsampled [1/2] ────────────> + Accumulation Buffer [1/2]
+ * | Λ
+ * ─── ───
+ * Repeat Repeat
+ * ─── ───
+ * v |
+ * Color Downsampled [1/N-1] ──────────> + Accumulation Buffer [1/N-1]
+ * | Λ
+ * [Downsample] [Upsample]
+ * v |
+ * Color Downsampled [1/N] ─────────────────────────┘
+ * </pre>
*/
DRWShadingGroup *grp;
const bool use_highres = true;
diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
index 62ccf30e12c..8fb73bd605f 100644
--- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c
+++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
@@ -141,10 +141,12 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata),
float focus_dist = BKE_camera_object_dof_distance(camera);
float focal_len = cam->lens;
- /* this is factor that converts to the scene scale. focal length and sensor are expressed in mm
- * unit.scale_length is how many meters per blender unit we have. We want to convert to blender units though
- * because the shader reads coordinates in world space, which is in blender units.
- * Note however that focus_distance is already in blender units and shall not be scaled here (see T48157). */
+ /* this is factor that converts to the scene scale. focal length and sensor are expressed in
+ * mm unit.scale_length is how many meters per blender unit we have. We want to convert to
+ * blender units though because the shader reads coordinates in world space, which is in
+ * blender units.
+ * Note however that focus_distance is already in blender units and shall not be scaled here
+ * (see T48157). */
float scale = (scene_eval->unit.system) ? scene_eval->unit.scale_length : 1.0f;
float scale_camera = 0.001f / scale;
/* we want radius here for the aperture number */
@@ -239,6 +241,7 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_
if (use_alpha) {
DRW_shgroup_uniform_texture_ref(grp, "scatterAlphaBuffer", &effects->dof_blur_alpha);
+ DRW_shgroup_uniform_bool_copy(grp, "unpremult", DRW_state_is_image_render());
}
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c
index 79b4cb231a8..a8b4159e030 100644
--- a/source/blender/draw/engines/eevee/eevee_effects.c
+++ b/source/blender/draw/engines/eevee/eevee_effects.c
@@ -168,6 +168,11 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata,
effects->enabled_effects |= EFFECT_NORMAL_BUFFER;
}
+ /* Alpha checker if background is not drawn in viewport. */
+ if (!DRW_state_is_image_render() && !DRW_state_draw_background()) {
+ effects->enabled_effects |= EFFECT_ALPHA_CHECKER;
+ }
+
/**
* Ping Pong buffer
*/
@@ -361,6 +366,23 @@ void EEVEE_effects_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRW_shgroup_uniform_mat4(grp, "pastPersmat", effects->velocity_past_persmat);
DRW_shgroup_call_add(grp, quad, NULL);
}
+
+ if ((effects->enabled_effects & EFFECT_ALPHA_CHECKER) != 0) {
+ psl->alpha_checker = DRW_pass_create("Alpha Checker",
+ DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_PREMUL_UNDER);
+
+ GPUShader *checker_sh = GPU_shader_get_builtin_shader(GPU_SHADER_2D_CHECKER);
+
+ DRWShadingGroup *grp = DRW_shgroup_create(checker_sh, psl->alpha_checker);
+
+ copy_v4_fl4(effects->color_checker_dark, 0.15f, 0.15f, 0.15f, 1.0f);
+ copy_v4_fl4(effects->color_checker_light, 0.2f, 0.2f, 0.2f, 1.0f);
+
+ DRW_shgroup_uniform_vec4(grp, "color1", effects->color_checker_dark, 1);
+ DRW_shgroup_uniform_vec4(grp, "color2", effects->color_checker_light, 1);
+ DRW_shgroup_uniform_int_copy(grp, "size", 8);
+ DRW_shgroup_call_add(grp, quad, NULL);
+ }
}
#if 0 /* Not required for now */
@@ -491,22 +513,50 @@ void EEVEE_downsample_cube_buffer(EEVEE_Data *vedata, GPUTexture *texture_src, i
DRW_stats_group_end();
}
-void EEVEE_draw_effects(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
+void EEVEE_draw_alpha_checker(EEVEE_Data *vedata)
+{
+ EEVEE_PassList *psl = vedata->psl;
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_EffectsInfo *effects = stl->effects;
+
+ if ((effects->enabled_effects & EFFECT_ALPHA_CHECKER) != 0) {
+ float mat[4][4];
+ unit_m4(mat);
+
+ /* Fragile, rely on the fact that GPU_SHADER_2D_CHECKER
+ * only use the persmat. */
+ DRW_viewport_matrix_override_set(mat, DRW_MAT_PERS);
+
+ DRW_draw_pass(psl->alpha_checker);
+
+ DRW_viewport_matrix_override_unset(DRW_MAT_PERS);
+ }
+}
+
+static void EEVEE_velocity_resolve(EEVEE_Data *vedata)
{
EEVEE_PassList *psl = vedata->psl;
- EEVEE_TextureList *txl = vedata->txl;
EEVEE_FramebufferList *fbl = vedata->fbl;
EEVEE_StorageList *stl = vedata->stl;
EEVEE_EffectsInfo *effects = stl->effects;
- /* First resolve the velocity. */
if ((effects->enabled_effects & EFFECT_VELOCITY_BUFFER) != 0) {
+ DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ e_data.depth_src = dtxl->depth;
DRW_viewport_matrix_get(effects->velocity_curr_persinv, DRW_MAT_PERSINV);
GPU_framebuffer_bind(fbl->velocity_resolve_fb);
DRW_draw_pass(psl->velocity_resolve);
}
DRW_viewport_matrix_get(effects->velocity_past_persmat, DRW_MAT_PERS);
+}
+
+void EEVEE_draw_effects(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
+{
+ EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_FramebufferList *fbl = vedata->fbl;
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_EffectsInfo *effects = stl->effects;
/* only once per frame after the first post process */
effects->swap_double_buffer = ((effects->enabled_effects & EFFECT_DOUBLE_BUFFER) != 0);
@@ -518,6 +568,14 @@ void EEVEE_draw_effects(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
/* Post process stack (order matters) */
EEVEE_motion_blur_draw(vedata);
EEVEE_depth_of_field_draw(vedata);
+
+ /* NOTE: Lookdev drawing happens before TAA but after
+ * motion blur and dof to avoid distortions.
+ * Velocity resolve use a hack to exclude lookdev
+ * balls from creating shimering reprojection vectors. */
+ EEVEE_lookdev_draw(vedata);
+ EEVEE_velocity_resolve(vedata);
+
EEVEE_temporal_sampling_draw(vedata);
EEVEE_bloom_draw(vedata);
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index 6232640aac8..26f33f4db31 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -180,12 +180,13 @@ static void eevee_draw_background(void *vedata)
/* Sort transparents before the loop. */
DRW_pass_sort_shgroup_z(psl->transparent_pass);
- /* Number of iteration: needed for all temporal effect (SSR, volumetrics)
- * when using opengl render. */
- int loop_len = (DRW_state_is_image_render() &&
- (stl->effects->enabled_effects & (EFFECT_VOLUMETRIC | EFFECT_SSR)) != 0) ?
- 4 :
- 1;
+ /* Number of iteration: Use viewport taa_samples when using viewport rendering */
+ int loop_len = 1;
+ if (DRW_state_is_image_render()) {
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const Scene *scene = draw_ctx->scene;
+ loop_len = MAX2(1, scene->eevee.taa_samples);
+ }
while (loop_len--) {
float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
@@ -301,16 +302,15 @@ static void eevee_draw_background(void *vedata)
}
}
- /* LookDev */
- EEVEE_lookdev_draw_background(vedata);
- /* END */
-
/* Tonemapping and transfer result to default framebuffer. */
bool use_render_settings = stl->g_data->use_color_render_settings;
GPU_framebuffer_bind(dfbl->default_fb);
DRW_transform_to_display(stl->effects->final_tx, true, use_render_settings);
+ /* Draw checkerboard with alpha under. */
+ EEVEE_draw_alpha_checker(vedata);
+
/* Debug : Output buffer to view. */
switch (G.debug_value) {
case 1:
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 550821ee92a..a4a17de7a57 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -145,7 +145,8 @@ static void planar_pool_ensure_alloc(EEVEE_Data *vedata, int num_planar_ref)
width, height, max_ii(1, num_planar_ref), GPU_DEPTH_COMPONENT24, 0, NULL);
}
else if (num_planar_ref == 0) {
- /* Makes Opengl Happy : Create a placeholder texture that will never be sampled but still bound to shader. */
+ /* Makes Opengl Happy : Create a placeholder texture that will never be sampled but still
+ * bound to shader. */
txl->planar_pool = DRW_texture_create_2d_array(
1, 1, 1, GPU_RGBA8, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
txl->planar_depth = DRW_texture_create_2d_array(1, 1, 1, GPU_DEPTH_COMPONENT24, 0, NULL);
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index 917043d70e7..270defb039b 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -680,7 +680,8 @@ static float light_shape_power_get(const Light *la, const EEVEE_Light *evli)
power = 1.0f / (evli->sizex * evli->sizey * 4.0f * M_PI) * /* 1/(w*h*Pi) */
80.0f; /* XXX : Empirical, Fit cycles power */
if (ELEM(la->area_shape, LA_AREA_DISK, LA_AREA_ELLIPSE)) {
- /* Scale power to account for the lower area of the ellipse compared to the surrounding rectangle. */
+ /* Scale power to account for the lower area of the ellipse compared to the surrounding
+ * rectangle. */
power *= 4.0f / M_PI;
}
}
@@ -693,8 +694,9 @@ static float light_shape_power_get(const Light *la, const EEVEE_Light *evli)
}
else {
power = 1.0f / (evli->radius * evli->radius * M_PI); /* 1/(r²*Pi) */
- /* Make illumation power closer to cycles for bigger radii. Cycles uses a cos^3 term that we cannot reproduce
- * so we account for that by scaling the light power. This function is the result of a rough manual fitting. */
+ /* Make illumation power closer to cycles for bigger radii. Cycles uses a cos^3 term that we
+ * cannot reproduce so we account for that by scaling the light power. This function is the
+ * result of a rough manual fitting. */
power += 1.0f / (2.0f * M_PI); /* power *= 1 + r²/2 */
}
return power;
@@ -1383,7 +1385,8 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRW_draw_pass(psl->shadow_pass);
}
- /* 0.001f is arbitrary, but it should be relatively small so that filter size is not too big. */
+ /* 0.001f is arbitrary, but it should be relatively small so that filter size is not too big.
+ */
float filter_texture_size = la->soft * 0.001f;
float filter_pixel_size = ceil(filter_texture_size / srd->cube_texel_size);
linfo->filter_size = srd->cube_texel_size * ((filter_pixel_size > 1.0f) ? 1.5f : 0.0f);
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index b000eebb92e..13f7ab1c562 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -24,6 +24,9 @@
#include "BKE_camera.h"
#include "BKE_studiolight.h"
+#include "BLI_rect.h"
+#include "BLI_rand.h"
+
#include "DNA_screen_types.h"
#include "DNA_world_types.h"
@@ -62,11 +65,34 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
{
EEVEE_StorageList *stl = vedata->stl;
EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_EffectsInfo *effects = stl->effects;
EEVEE_PrivateData *g_data = stl->g_data;
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
Scene *scene = draw_ctx->scene;
+ if (LOOK_DEV_OVERLAY_ENABLED(v3d)) {
+ /* Viewport / Ball size. */
+ rcti rect;
+ ED_region_visible_rect(draw_ctx->ar, &rect);
+
+ /* Make the viewport width scale the lookdev balls a bit.
+ * Scale between 1000px and 2000px. */
+ const float viewport_scale = clamp_f(
+ BLI_rcti_size_x(&rect) / (2000.0f * U.dpi_fac), 0.5f, 1.0f);
+ const int ball_size = U.lookdev_ball_size * U.dpi_fac * viewport_scale;
+
+ if (ball_size != effects->ball_size || rect.xmax != effects->anchor[0] ||
+ rect.ymin != effects->anchor[1]) {
+ /* If ball size or anchor point moves, reset TAA to avoid ghosting issue.
+ * This needs to happen early because we are changing taa_current_sample. */
+ effects->ball_size = ball_size;
+ effects->anchor[0] = rect.xmax;
+ effects->anchor[1] = rect.ymin;
+ EEVEE_temporal_sampling_reset(vedata);
+ }
+ }
+
if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) {
StudioLight *sl = BKE_studiolight_find(v3d->shading.lookdev_light,
STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE);
@@ -157,56 +183,35 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
}
}
-void EEVEE_lookdev_draw_background(EEVEE_Data *vedata)
+static void eevee_lookdev_apply_taa(const EEVEE_EffectsInfo *effects,
+ int ball_size,
+ float winmat[4][4])
+{
+ if (DRW_state_is_image_render() || ((effects->enabled_effects & EFFECT_TAA) != 0)) {
+ double ht_point[2];
+ double ht_offset[2] = {0.0, 0.0};
+ uint ht_primes[2] = {2, 3};
+ float ofs[2];
+
+ BLI_halton_2d(ht_primes, ht_offset, effects->taa_current_sample, ht_point);
+ EEVEE_temporal_sampling_offset_calc(ht_point, 1.5f, ofs);
+ winmat[3][0] += ofs[0] / ball_size;
+ winmat[3][1] += ofs[1] / ball_size;
+ }
+}
+
+void EEVEE_lookdev_draw(EEVEE_Data *vedata)
{
EEVEE_PassList *psl = vedata->psl;
+ EEVEE_FramebufferList *fbl = vedata->fbl;
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
EEVEE_EffectsInfo *effects = stl->effects;
EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
- DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
const DRWContextState *draw_ctx = DRW_context_state_get();
- if (psl->lookdev_pass && LOOK_DEV_OVERLAY_ENABLED(draw_ctx->v3d)) {
- DRW_stats_group_start("Look Dev");
- CameraParams params;
- BKE_camera_params_init(&params);
- View3D *v3d = draw_ctx->v3d;
- RegionView3D *rv3d = draw_ctx->rv3d;
- ARegion *ar = draw_ctx->ar;
-
- const float *viewport_size = DRW_viewport_size_get();
- rcti rect;
- ED_region_visible_rect(draw_ctx->ar, &rect);
-
- const float viewport_size_target[2] = {
- viewport_size[0] / 4,
- viewport_size[1] / 4,
- };
- const int viewport_inset[2] = {
- max_ii(viewport_size_target[0], 300),
- max_ii(viewport_size_target[0], 300) / 2, /* intentionally use 'x' here for 'y' value. */
- };
-
- /* minimum size for preview spheres viewport */
- const float aspect[2] = {
- viewport_inset[0] / viewport_size_target[0],
- viewport_inset[1] / viewport_size_target[1],
- };
-
- BKE_camera_params_from_view3d(&params, draw_ctx->depsgraph, v3d, rv3d);
- params.is_ortho = true;
- params.ortho_scale = 3.0f;
- params.zoom = CAMERA_PARAM_ZOOM_INIT_PERSP;
- params.offsetx = 0.0f;
- params.offsety = 0.0f;
- params.shiftx = 0.0f;
- params.shifty = 0.0f;
- params.clip_start = 0.001f;
- params.clip_end = 20.0f;
- BKE_camera_params_compute_viewplane(&params, ar->winx, ar->winy, aspect[0], aspect[1]);
- BKE_camera_params_compute_matrix(&params);
-
+ if (psl->lookdev_diffuse_pass && LOOK_DEV_OVERLAY_ENABLED(draw_ctx->v3d)) {
+ /* Config renderer. */
EEVEE_CommonUniformBuffer *common = &sldata->common_data;
common->la_num_light = 0;
common->prb_num_planar = 0;
@@ -218,34 +223,53 @@ void EEVEE_lookdev_draw_background(EEVEE_Data *vedata)
DRW_uniformbuffer_update(sldata->common_ubo, common);
/* override matrices */
- float winmat[4][4];
- float winmat_inv[4][4];
- copy_m4_m4(winmat, params.winmat);
- invert_m4_m4(winmat_inv, winmat);
- DRW_viewport_matrix_override_set(winmat, DRW_MAT_WIN);
- DRW_viewport_matrix_override_set(winmat_inv, DRW_MAT_WININV);
- float viewmat[4][4];
- DRW_viewport_matrix_get(viewmat, DRW_MAT_VIEW);
- float persmat[4][4];
- float persmat_inv[4][4];
- mul_m4_m4m4(persmat, winmat, viewmat);
- invert_m4_m4(persmat_inv, persmat);
- DRW_viewport_matrix_override_set(persmat, DRW_MAT_PERS);
- DRW_viewport_matrix_override_set(persmat_inv, DRW_MAT_PERSINV);
-
- GPUFrameBuffer *fb = effects->final_fb;
- GPU_framebuffer_bind(fb);
- GPU_framebuffer_viewport_set(
- fb, rect.xmax - viewport_inset[0], rect.ymin, viewport_inset[0], viewport_inset[1]);
- DRW_draw_pass(psl->lookdev_pass);
+ DRWMatrixState matstate;
+ unit_m4(matstate.winmat);
+
+ eevee_lookdev_apply_taa(effects, effects->ball_size, matstate.winmat);
+
+ /* "Remove" view matrix location. Leaving only rotation. */
+ DRW_viewport_matrix_get(matstate.viewmat, DRW_MAT_VIEW);
+ zero_v3(matstate.viewmat[3]);
+ mul_m4_m4m4(matstate.persmat, matstate.winmat, matstate.viewmat);
+ invert_m4_m4(matstate.wininv, matstate.winmat);
+ invert_m4_m4(matstate.viewinv, matstate.viewmat);
+ invert_m4_m4(matstate.persinv, matstate.persmat);
+
+ DRW_viewport_matrix_override_set_all(&matstate);
+
+ /* Find the right framebuffers to render to. */
+ GPUFrameBuffer *fb = (effects->target_buffer == fbl->effect_color_fb) ? fbl->main_fb :
+ fbl->effect_fb;
+
+ DRW_stats_group_start("Look Dev");
- fb = dfbl->depth_only_fb;
GPU_framebuffer_bind(fb);
- GPU_framebuffer_viewport_set(
- fb, rect.xmax - viewport_inset[0], rect.ymin, viewport_inset[0], viewport_inset[1]);
- DRW_draw_pass(psl->lookdev_pass);
- DRW_viewport_matrix_override_unset_all();
+ const int ball_margin = effects->ball_size / 6.0f;
+ float offset[2] = {0.0f, ball_margin};
+
+ offset[0] = effects->ball_size + ball_margin;
+ GPU_framebuffer_viewport_set(fb,
+ effects->anchor[0] - offset[0],
+ effects->anchor[1] + offset[1],
+ effects->ball_size,
+ effects->ball_size);
+
+ DRW_draw_pass(psl->lookdev_diffuse_pass);
+
+ offset[0] = (effects->ball_size + ball_margin) +
+ (ball_margin + effects->ball_size + ball_margin);
+ GPU_framebuffer_viewport_set(fb,
+ effects->anchor[0] - offset[0],
+ effects->anchor[1] + offset[1],
+ effects->ball_size,
+ effects->ball_size);
+
+ DRW_draw_pass(psl->lookdev_glossy_pass);
+
DRW_stats_group_end();
+
+ DRW_viewport_matrix_override_unset_all();
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 86a87121683..c55f3f0150c 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -296,9 +296,6 @@ static char *eevee_get_defines(int options)
if ((options & VAR_MAT_PROBE) != 0) {
BLI_dynstr_append(ds, "#define PROBE_CAPTURE\n");
}
- if ((options & VAR_MAT_FLAT) != 0) {
- BLI_dynstr_append(ds, "#define USE_FLAT_NORMAL\n");
- }
if ((options & VAR_MAT_CLIP) != 0) {
BLI_dynstr_append(ds, "#define USE_ALPHA_CLIP\n");
}
@@ -336,7 +333,10 @@ static char *eevee_get_defines(int options)
BLI_dynstr_append(ds, "#define USE_ALPHA_BLEND_VOLUMETRICS\n");
}
if ((options & VAR_MAT_LOOKDEV) != 0) {
+ /* Auto config shadow method. Avoid more permutation. */
+ BLI_assert((options & (VAR_MAT_VSM | VAR_MAT_ESM)) == 0);
BLI_dynstr_append(ds, "#define LOOKDEV\n");
+ BLI_dynstr_append(ds, "#define SHADOW_ESM\n");
}
str = BLI_dynstr_get_cstring(ds);
@@ -591,6 +591,7 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata,
datatoc_lit_surface_frag_glsl,
datatoc_lit_surface_frag_glsl,
datatoc_lit_surface_frag_glsl,
+ datatoc_lit_surface_frag_glsl,
datatoc_volumetric_lib_glsl);
e_data.volume_shader_lib = BLI_string_joinN(datatoc_common_view_lib_glsl,
@@ -901,7 +902,6 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_create(EEVEE_ViewLaye
EEVEE_Data *vedata,
DRWPass *pass,
bool is_hair,
- bool is_flat_normal,
bool use_blend,
bool use_ssr,
int shadow_method)
@@ -914,9 +914,6 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_create(EEVEE_ViewLaye
if (is_hair) {
options |= VAR_MAT_HAIR;
}
- if (is_flat_normal) {
- options |= VAR_MAT_FLAT;
- }
if (use_blend) {
options |= VAR_MAT_BLEND;
}
@@ -945,7 +942,6 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(EEVEE_ViewLayerDa
ParticleSystem *psys,
ModifierData *md,
bool is_hair,
- bool is_flat_normal,
bool use_ssr,
int shadow_method)
{
@@ -958,9 +954,6 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(EEVEE_ViewLayerDa
if (is_hair) {
options |= VAR_MAT_HAIR;
}
- if (is_flat_normal) {
- options |= VAR_MAT_FLAT;
- }
options |= eevee_material_shadow_option(shadow_method);
@@ -994,42 +987,11 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(EEVEE_ViewLayerDa
}
}
-/**
- * Create a default shading group inside the lookdev pass without standard uniforms.
- */
-static struct DRWShadingGroup *EEVEE_lookdev_shading_group_get(EEVEE_ViewLayerData *sldata,
- EEVEE_Data *vedata,
- bool use_ssr,
- int shadow_method)
-{
- static int ssr_id;
- ssr_id = (use_ssr) ? 1 : -1;
- int options = VAR_MAT_MESH | VAR_MAT_LOOKDEV;
-
- options |= eevee_material_shadow_option(shadow_method);
-
- if (e_data.default_lit[options] == NULL) {
- create_default_shader(options);
- }
-
- if (vedata->psl->lookdev_pass == NULL) {
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS |
- DRW_STATE_CULL_BACK;
- vedata->psl->lookdev_pass = DRW_pass_create("LookDev Pass", state);
-
- DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options],
- vedata->psl->lookdev_pass);
- /* XXX / WATCH: This creates non persistent binds for the ubos and textures.
- * But it's currently OK because the following shgroups does not add any bind. */
- add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, true, true, false, false, false);
- }
-
- return DRW_shgroup_create(e_data.default_lit[options], vedata->psl->lookdev_pass);
-}
void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
/* Create Material Ghash */
{
@@ -1043,16 +1005,13 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
DRWShadingGroup *grp = NULL;
- const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
World *wo = scene->world;
const float *col = G_draw.block.colorBackground;
- /* LookDev */
EEVEE_lookdev_cache_init(
vedata, &grp, psl->background_pass, stl->g_data->background_alpha, wo, NULL);
- /* END */
if (!grp && wo) {
col = &wo->horr;
@@ -1183,21 +1142,49 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRW_shgroup_uniform_vec3(grp, "offsets", e_data.noise_offsets, 1);
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
}
+
+ if (LOOK_DEV_OVERLAY_ENABLED(draw_ctx->v3d)) {
+ DRWShadingGroup *shgrp;
+
+ struct GPUBatch *sphere = DRW_cache_sphere_get();
+ static float color_chrome[3] = {1.0f, 1.0f, 1.0f};
+ static float color_diffuse[3] = {0.8f, 0.8f, 0.8f};
+ int options = VAR_MAT_MESH | VAR_MAT_LOOKDEV;
+
+ if (e_data.default_lit[options] == NULL) {
+ create_default_shader(options);
+ }
+
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS |
+ DRW_STATE_CULL_BACK;
+
+ psl->lookdev_diffuse_pass = DRW_pass_create("LookDev Diffuse Pass", state);
+ shgrp = DRW_shgroup_create(e_data.default_lit[options], psl->lookdev_diffuse_pass);
+ add_standard_uniforms(shgrp, sldata, vedata, NULL, NULL, true, true, false, false, false);
+ DRW_shgroup_uniform_vec3(shgrp, "basecol", color_diffuse, 1);
+ DRW_shgroup_uniform_float_copy(shgrp, "metallic", 0.0f);
+ DRW_shgroup_uniform_float_copy(shgrp, "specular", 0.5f);
+ DRW_shgroup_uniform_float_copy(shgrp, "roughness", 1.0f);
+ DRW_shgroup_call_add(shgrp, sphere, NULL);
+
+ psl->lookdev_glossy_pass = DRW_pass_create("LookDev Glossy Pass", state);
+ shgrp = DRW_shgroup_create(e_data.default_lit[options], psl->lookdev_glossy_pass);
+ add_standard_uniforms(shgrp, sldata, vedata, NULL, NULL, true, true, false, false, false);
+ DRW_shgroup_uniform_vec3(shgrp, "basecol", color_chrome, 1);
+ DRW_shgroup_uniform_float_copy(shgrp, "metallic", 1.0f);
+ DRW_shgroup_uniform_float_copy(shgrp, "roughness", 0.0f);
+ DRW_shgroup_call_add(shgrp, sphere, NULL);
+ }
}
#define ADD_SHGROUP_CALL(shgrp, ob, ma, geom, oedata) \
do { \
- if (is_sculpt_mode_draw) { \
- DRW_shgroup_call_sculpt_add(shgrp, ob, ob->obmat); \
+ if (oedata) { \
+ DRW_shgroup_call_object_add_with_callback( \
+ shgrp, geom, ob, ma, EEVEE_lightprobes_obj_visibility_cb, oedata); \
} \
else { \
- if (oedata) { \
- DRW_shgroup_call_object_add_with_callback( \
- shgrp, geom, ob, ma, EEVEE_lightprobes_obj_visibility_cb, oedata); \
- } \
- else { \
- DRW_shgroup_call_object_add_ex(shgrp, geom, ob, ma, false); \
- } \
+ DRW_shgroup_call_object_add_ex(shgrp, geom, ob, ma, false); \
} \
} while (0)
@@ -1219,7 +1206,6 @@ static void material_opaque(Material *ma,
EEVEE_ViewLayerData *sldata,
EEVEE_Data *vedata,
bool do_cull,
- bool use_flat_nor,
struct GPUMaterial **gpumat,
struct GPUMaterial **gpumat_depth,
struct DRWShadingGroup **shgrp,
@@ -1408,9 +1394,9 @@ static void material_opaque(Material *ma,
}
else {
if (use_translucency) {
- /* NOTE: This is a nasty workaround, because the sss profile might not have been generated
- * but the UBO is still declared in this case even if not used. But rendering without a
- * bound UBO might result in crashes on certain platform. */
+ /* NOTE: This is a nasty workaround, because the sss profile might not have been
+ * generated but the UBO is still declared in this case even if not used.
+ * But rendering without a bound UBO might result in crashes on certain platform. */
DRW_shgroup_uniform_block(*shgrp, "sssProfile", e_data.dummy_sss_profile);
}
}
@@ -1439,7 +1425,7 @@ static void material_opaque(Material *ma,
if (*shgrp == NULL) {
bool use_ssr = ((effects->enabled_effects & EFFECT_SSR) != 0);
*shgrp = EEVEE_default_shading_group_get(
- sldata, vedata, NULL, NULL, NULL, false, use_flat_nor, use_ssr, linfo->shadow_method);
+ sldata, vedata, NULL, NULL, NULL, false, use_ssr, linfo->shadow_method);
DRW_shgroup_uniform_vec3(*shgrp, "basecol", color_p, 1);
DRW_shgroup_uniform_float(*shgrp, "metallic", metal_p, 1);
DRW_shgroup_uniform_float(*shgrp, "specular", spec_p, 1);
@@ -1472,7 +1458,6 @@ static void material_transparent(Material *ma,
EEVEE_ViewLayerData *sldata,
EEVEE_Data *vedata,
bool do_cull,
- bool use_flat_nor,
struct GPUMaterial **gpumat,
struct DRWShadingGroup **shgrp,
struct DRWShadingGroup **shgrp_depth)
@@ -1545,14 +1530,8 @@ static void material_transparent(Material *ma,
/* Fallback to default shader */
if (*shgrp == NULL) {
- *shgrp = EEVEE_default_shading_group_create(sldata,
- vedata,
- psl->transparent_pass,
- false,
- use_flat_nor,
- true,
- false,
- linfo->shadow_method);
+ *shgrp = EEVEE_default_shading_group_create(
+ sldata, vedata, psl->transparent_pass, false, true, false, linfo->shadow_method);
DRW_shgroup_uniform_vec3(*shgrp, "basecol", color_p, 1);
DRW_shgroup_uniform_float(*shgrp, "metallic", metal_p, 1);
DRW_shgroup_uniform_float(*shgrp, "specular", spec_p, 1);
@@ -1601,6 +1580,16 @@ static void material_transparent(Material *ma,
}
}
+/* Return correct material or &defmaterial if slot is empty. */
+BLI_INLINE Material *eevee_object_material_get(Object *ob, int slot)
+{
+ Material *ma = give_current_material(ob, slot + 1);
+ if (ma == NULL) {
+ ma = &defmaterial;
+ }
+ return ma;
+}
+
void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
EEVEE_ViewLayerData *sldata,
Object *ob,
@@ -1614,17 +1603,14 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
const bool do_cull = (draw_ctx->v3d &&
(draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING));
- const bool is_active = (ob == draw_ctx->obact);
- const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
+ bool is_sculpt_mode = DRW_object_use_pbvh_drawing(ob);
/* For now just force fully shaded with eevee when supported. */
- const bool is_sculpt_mode_draw = is_sculpt_mode &&
- ((ob->sculpt && ob->sculpt->pbvh) &&
- (BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_FACES));
- const bool is_default_mode_shader = is_sculpt_mode;
+ is_sculpt_mode = is_sculpt_mode &&
+ !(ob->sculpt->pbvh && BKE_pbvh_type(ob->sculpt->pbvh) == PBVH_FACES);
/* First get materials for this mesh. */
if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
- const int materials_len = MAX2(1, (is_sculpt_mode_draw ? 1 : ob->totcol));
+ const int materials_len = MAX2(1, ob->totcol);
struct DRWShadingGroup **shgrp_array = BLI_array_alloca(shgrp_array, materials_len);
struct DRWShadingGroup **shgrp_depth_array = BLI_array_alloca(shgrp_depth_array,
@@ -1634,45 +1620,25 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len);
struct GPUMaterial **gpumat_depth_array = BLI_array_alloca(gpumat_array, materials_len);
-
- bool use_flat_nor = false;
-
- if (is_default_mode_shader) {
- if (is_sculpt_mode_draw) {
- use_flat_nor = DRW_object_is_flat_normal(ob);
- }
- }
+ struct Material **ma_array = BLI_array_alloca(ma_array, materials_len);
for (int i = 0; i < materials_len; ++i) {
- Material *ma;
-
- if (is_sculpt_mode_draw) {
- ma = NULL;
- }
- else {
- ma = give_current_material(ob, i + 1);
- }
-
+ ma_array[i] = eevee_object_material_get(ob, i);
gpumat_array[i] = NULL;
gpumat_depth_array[i] = NULL;
shgrp_array[i] = NULL;
shgrp_depth_array[i] = NULL;
shgrp_depth_clip_array[i] = NULL;
- if (ma == NULL) {
- ma = &defmaterial;
- }
-
- switch (ma->blend_method) {
+ switch (ma_array[i]->blend_method) {
case MA_BM_SOLID:
case MA_BM_CLIP:
case MA_BM_HASHED:
- material_opaque(ma,
+ material_opaque(ma_array[i],
material_hash,
sldata,
vedata,
do_cull,
- use_flat_nor,
&gpumat_array[i],
&gpumat_depth_array[i],
&shgrp_array[i],
@@ -1682,11 +1648,10 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
case MA_BM_ADD:
case MA_BM_MULTIPLY:
case MA_BM_BLEND:
- material_transparent(ma,
+ material_transparent(ma_array[i],
sldata,
vedata,
do_cull,
- use_flat_nor,
&gpumat_array[i],
&shgrp_array[i],
&shgrp_depth_array[i]);
@@ -1697,10 +1662,6 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
}
}
- if (is_sculpt_mode && is_sculpt_mode_draw == false) {
- DRW_cache_mesh_sculpt_coords_ensure(ob);
- }
-
/* Only support single volume material for now. */
/* XXX We rely on the previously compiled surface shader
* to know if the material has a "volume nodetree".
@@ -1715,7 +1676,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
int auto_layer_count;
struct GPUBatch **mat_geom = NULL;
- if (!is_sculpt_mode_draw) {
+ if (!is_sculpt_mode) {
mat_geom = DRW_cache_object_surface_material_get(ob,
gpumat_array,
materials_len,
@@ -1724,17 +1685,18 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
&auto_layer_count);
}
- if (is_sculpt_mode_draw || mat_geom) {
+ if (is_sculpt_mode) {
+ /* TODO(fclem): Support Vcol. */
+ DRW_shgroup_call_sculpt_with_materials_add(shgrp_array, ma_array, ob, false);
+ DRW_shgroup_call_sculpt_with_materials_add(shgrp_depth_array, ma_array, ob, false);
+ DRW_shgroup_call_sculpt_with_materials_add(shgrp_depth_clip_array, ma_array, ob, false);
+ /* TODO(fclem): Support shadows in sculpt mode. */
+ }
+ else if (mat_geom) {
for (int i = 0; i < materials_len; ++i) {
- if (!is_sculpt_mode_draw && mat_geom[i] == NULL) {
+ if (mat_geom[i] == NULL) {
continue;
}
- EEVEE_ObjectEngineData *oedata = NULL;
- Material *ma = give_current_material(ob, i + 1);
-
- if (ma == NULL) {
- ma = &defmaterial;
- }
/* Do not render surface if we are rendering a volume object
* and do not have a surface closure. */
@@ -1745,23 +1707,16 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
/* XXX TODO rewrite this to include the dupli objects.
* This means we cannot exclude dupli objects from reflections!!! */
+ EEVEE_ObjectEngineData *oedata = NULL;
if ((ob->base_flag & BASE_FROM_DUPLI) == 0) {
oedata = EEVEE_object_data_ensure(ob);
oedata->ob = ob;
oedata->test_data = &sldata->probes->vis_data;
}
- /* Shading pass */
- ADD_SHGROUP_CALL(shgrp_array[i], ob, ma, mat_geom[i], oedata);
-
- /* Depth Prepass */
- ADD_SHGROUP_CALL_SAFE(shgrp_depth_array[i], ob, ma, mat_geom[i], oedata);
- ADD_SHGROUP_CALL_SAFE(shgrp_depth_clip_array[i], ob, ma, mat_geom[i], oedata);
-
- /* TODO(fclem): Don't support shadows in sculpt mode. */
- if (is_sculpt_mode_draw) {
- break;
- }
+ ADD_SHGROUP_CALL(shgrp_array[i], ob, ma_array[i], mat_geom[i], oedata);
+ ADD_SHGROUP_CALL_SAFE(shgrp_depth_array[i], ob, ma_array[i], mat_geom[i], oedata);
+ ADD_SHGROUP_CALL_SAFE(shgrp_depth_clip_array[i], ob, ma_array[i], mat_geom[i], oedata);
char *name = auto_layer_names;
for (int j = 0; j < auto_layer_count; ++j) {
@@ -1784,19 +1739,19 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
/* Shadow Pass */
struct GPUMaterial *gpumat;
- switch (ma->blend_shadow) {
+ switch (ma_array[i]->blend_shadow) {
case MA_BS_SOLID:
EEVEE_lights_cache_shcaster_add(sldata, stl, mat_geom[i], ob);
*cast_shadow = true;
break;
case MA_BS_CLIP:
- gpumat = EEVEE_material_mesh_depth_get(scene, ma, false, true);
+ gpumat = EEVEE_material_mesh_depth_get(scene, ma_array[i], false, true);
EEVEE_lights_cache_shcaster_material_add(
- sldata, psl, gpumat, mat_geom[i], ob, &ma->alpha_threshold);
+ sldata, psl, gpumat, mat_geom[i], ob, &ma_array[i]->alpha_threshold);
*cast_shadow = true;
break;
case MA_BS_HASHED:
- gpumat = EEVEE_material_mesh_depth_get(scene, ma, true, true);
+ gpumat = EEVEE_material_mesh_depth_get(scene, ma_array[i], true, true);
EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, NULL);
*cast_shadow = true;
break;
@@ -1844,11 +1799,7 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata,
}
DRWShadingGroup *shgrp = NULL;
- Material *ma = give_current_material(ob, part->omat);
-
- if (ma == NULL) {
- ma = &defmaterial;
- }
+ Material *ma = eevee_object_material_get(ob, part->omat - 1);
float *color_p = &ma->r;
float *metal_p = &ma->metallic;
@@ -1880,6 +1831,13 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata,
shgrp = DRW_shgroup_material_hair_create(ob, psys, md, psl->material_pass, gpumat);
+ if (!use_diffuse && !use_glossy && !use_refract) {
+ /* FIXME: Small hack to avoid issue when utilTex is needed for
+ * world_normals_get and none of the bsdfs that need it are present.
+ * This can try to bind utilTex even if not needed. */
+ DRW_shgroup_uniform_texture(shgrp, "utilTex", e_data.util_tex);
+ }
+
add_standard_uniforms(shgrp,
sldata,
vedata,
@@ -1908,7 +1866,7 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata,
/* Fallback to default shader */
if (shgrp == NULL) {
shgrp = EEVEE_default_shading_group_get(
- sldata, vedata, ob, psys, md, true, false, use_ssr, sldata->lights->shadow_method);
+ sldata, vedata, ob, psys, md, true, use_ssr, sldata->lights->shadow_method);
DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
@@ -1927,46 +1885,6 @@ void EEVEE_materials_cache_finish(EEVEE_Data *vedata)
{
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
- /* Look-Dev */
- const DRWContextState *draw_ctx = DRW_context_state_get();
- const View3D *v3d = draw_ctx->v3d;
- if (LOOK_DEV_OVERLAY_ENABLED(v3d)) {
- EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
- EEVEE_LightsInfo *linfo = sldata->lights;
- struct GPUBatch *sphere = DRW_cache_sphere_get();
- static float mat1[4][4];
- static float color[3] = {0.8f, 0.8f, 0.8f};
- static float metallic_on = 1.0f;
- static float metallic_off = 0.00f;
- static float specular_off = 0.5f;
- static float specular_on = 1.0f;
- static float roughness_off = 0.05f;
- static float roughness_on = 1.00f;
-
- float view_mat[4][4];
- DRW_viewport_matrix_get(view_mat, DRW_MAT_VIEWINV);
-
- DRWShadingGroup *shgrp = EEVEE_lookdev_shading_group_get(
- sldata, vedata, false, linfo->shadow_method);
- DRW_shgroup_uniform_vec3(shgrp, "basecol", color, 1);
- DRW_shgroup_uniform_float(shgrp, "metallic", &metallic_on, 1);
- DRW_shgroup_uniform_float(shgrp, "specular", &specular_on, 1);
- DRW_shgroup_uniform_float(shgrp, "roughness", &roughness_off, 1);
- unit_m4(mat1);
- mul_m4_m4m4(mat1, mat1, view_mat);
- translate_m4(mat1, -1.5f, 0.0f, -5.0f);
- DRW_shgroup_call_add(shgrp, sphere, mat1);
-
- shgrp = EEVEE_lookdev_shading_group_get(sldata, vedata, false, linfo->shadow_method);
- DRW_shgroup_uniform_vec3(shgrp, "basecol", color, 1);
- DRW_shgroup_uniform_float(shgrp, "metallic", &metallic_off, 1);
- DRW_shgroup_uniform_float(shgrp, "specular", &specular_off, 1);
- DRW_shgroup_uniform_float(shgrp, "roughness", &roughness_on, 1);
- translate_m4(mat1, 3.0f, 0.0f, 0.0f);
- DRW_shgroup_call_add(shgrp, sphere, mat1);
- }
- /* END */
-
BLI_ghash_free(stl->g_data->material_hash, NULL, MEM_freeN);
}
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 8e21c7f389c..6112921ff39 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -147,26 +147,25 @@ enum {
VAR_MAT_MESH = (1 << 0),
VAR_MAT_PROBE = (1 << 1),
VAR_MAT_HAIR = (1 << 2),
- VAR_MAT_FLAT = (1 << 3),
- VAR_MAT_BLEND = (1 << 4),
- VAR_MAT_VSM = (1 << 5),
- VAR_MAT_ESM = (1 << 6),
- VAR_MAT_VOLUME = (1 << 7),
- VAR_MAT_LOOKDEV = (1 << 8),
+ VAR_MAT_BLEND = (1 << 3),
+ VAR_MAT_VSM = (1 << 4),
+ VAR_MAT_ESM = (1 << 5),
+ VAR_MAT_VOLUME = (1 << 6),
+ VAR_MAT_LOOKDEV = (1 << 7),
/* Max number of variation */
/* IMPORTANT : Leave it last and set
* it's value accordingly. */
- VAR_MAT_MAX = (1 << 9),
+ VAR_MAT_MAX = (1 << 8),
/* These are options that are not counted in VAR_MAT_MAX
* because they are not cumulative with the others above. */
- VAR_MAT_CLIP = (1 << 10),
- VAR_MAT_HASH = (1 << 11),
- VAR_MAT_MULT = (1 << 12),
- VAR_MAT_SHADOW = (1 << 13),
- VAR_MAT_REFRACT = (1 << 14),
- VAR_MAT_SSS = (1 << 15),
- VAR_MAT_TRANSLUC = (1 << 16),
- VAR_MAT_SSSALBED = (1 << 17),
+ VAR_MAT_CLIP = (1 << 9),
+ VAR_MAT_HASH = (1 << 10),
+ VAR_MAT_MULT = (1 << 11),
+ VAR_MAT_SHADOW = (1 << 12),
+ VAR_MAT_REFRACT = (1 << 13),
+ VAR_MAT_SSS = (1 << 14),
+ VAR_MAT_TRANSLUC = (1 << 15),
+ VAR_MAT_SSSALBED = (1 << 16),
};
/* ************ PROBE UBO ************* */
@@ -246,6 +245,7 @@ typedef struct EEVEE_PassList {
struct DRWPass *color_downsample_cube_ps;
struct DRWPass *velocity_resolve;
struct DRWPass *taa_resolve;
+ struct DRWPass *alpha_checker;
/* HiZ */
struct DRWPass *minz_downlevel_ps;
@@ -275,7 +275,8 @@ typedef struct EEVEE_PassList {
struct DRWPass *transparent_pass;
struct DRWPass *background_pass;
struct DRWPass *update_noise_pass;
- struct DRWPass *lookdev_pass;
+ struct DRWPass *lookdev_glossy_pass;
+ struct DRWPass *lookdev_diffuse_pass;
} EEVEE_PassList;
typedef struct EEVEE_FramebufferList {
@@ -537,6 +538,7 @@ typedef enum EEVEE_EffectsFlag {
EFFECT_VELOCITY_BUFFER = (1 << 12), /* Not really an effect but a feature */
EFFECT_TAA_REPROJECT = (1 << 13), /* should be mutually exclusive with EFFECT_TAA */
EFFECT_DEPTH_DOUBLE_BUFFER = (1 << 14), /* Not really an effect but a feature */
+ EFFECT_ALPHA_CHECKER = (1 << 15), /* Not really an effect but a feature */
} EEVEE_EffectsFlag;
typedef struct EEVEE_EffectsInfo {
@@ -598,8 +600,14 @@ typedef struct EEVEE_EffectsInfo {
struct GPUTexture *dof_coc;
struct GPUTexture *dof_blur;
struct GPUTexture *dof_blur_alpha;
+ /* Alpha Checker */
+ float color_checker_dark[4];
+ float color_checker_light[4];
/* Other */
float prev_persmat[4][4];
+ /* Lookdev */
+ int ball_size;
+ int anchor[2];
/* Bloom */
int bloom_iteration_len;
float source_texel_size[2];
@@ -1044,6 +1052,9 @@ void EEVEE_mist_free(void);
/* eevee_temporal_sampling.c */
void EEVEE_temporal_sampling_reset(EEVEE_Data *vedata);
int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
+void EEVEE_temporal_sampling_offset_calc(const double ht_point[2],
+ const float filter_size,
+ float r_offset[2]);
void EEVEE_temporal_sampling_matrices_calc(EEVEE_EffectsInfo *effects,
float viewmat[4][4],
float persmat[4][4],
@@ -1073,6 +1084,7 @@ void EEVEE_effects_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_create_minmax_buffer(EEVEE_Data *vedata, struct GPUTexture *depth_src, int layer);
void EEVEE_downsample_buffer(EEVEE_Data *vedata, struct GPUTexture *texture_src, int level);
void EEVEE_downsample_cube_buffer(EEVEE_Data *vedata, struct GPUTexture *texture_src, int level);
+void EEVEE_draw_alpha_checker(EEVEE_Data *vedata);
void EEVEE_draw_effects(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_effects_free(void);
@@ -1099,7 +1111,7 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
float background_alpha,
struct World *world,
EEVEE_LightProbesInfo *pinfo);
-void EEVEE_lookdev_draw_background(EEVEE_Data *vedata);
+void EEVEE_lookdev_draw(EEVEE_Data *vedata);
/** eevee_engine.c */
void EEVEE_cache_populate(void *vedata, Object *ob);
diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
index a3603fc3d64..22c7dd00b97 100644
--- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
+++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
@@ -296,8 +296,9 @@ void EEVEE_reflection_compute(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
/* Resolve at fullres */
int sample = (DRW_state_is_image_render()) ? effects->taa_render_sample :
effects->taa_current_sample;
- /* Doing a neighbor shift only after a few iteration. We wait for a prime number of cycles to avoid
- * noise correlation. This reduces variance faster. */
+ /* Doing a neighbor shift only after a few iteration.
+ * We wait for a prime number of cycles to avoid noise correlation.
+ * This reduces variance faster. */
effects->ssr_neighbor_ofs = ((sample / 5) % 8) * 4;
switch ((sample / 11) % 4) {
case 0:
diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
index 54ceb1a167a..194fff9b93c 100644
--- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
+++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
@@ -131,6 +131,14 @@ static void eevee_create_cdf_table_temporal_sampling(void)
e_data.inited = true;
}
+void EEVEE_temporal_sampling_offset_calc(const double ht_point[2],
+ const float filter_size,
+ float r_offset[2])
+{
+ r_offset[0] = eval_table(e_data.inverted_cdf, (float)(ht_point[0])) * filter_size;
+ r_offset[1] = eval_table(e_data.inverted_cdf, (float)(ht_point[1])) * filter_size;
+}
+
void EEVEE_temporal_sampling_matrices_calc(EEVEE_EffectsInfo *effects,
float viewmat[4][4],
float persmat[4][4],
@@ -141,13 +149,11 @@ void EEVEE_temporal_sampling_matrices_calc(EEVEE_EffectsInfo *effects,
Scene *scene = draw_ctx->scene;
RenderData *rd = &scene->r;
- float filter_size = rd->gauss; /* Sigh.. Stupid legacy naming. */
-
- float ofs_x = eval_table(e_data.inverted_cdf, (float)(ht_point[0])) * filter_size;
- float ofs_y = eval_table(e_data.inverted_cdf, (float)(ht_point[1])) * filter_size;
+ float ofs[2];
+ EEVEE_temporal_sampling_offset_calc(ht_point, rd->gauss, ofs);
window_translate_m4(
- effects->overide_winmat, persmat, ofs_x / viewport_size[0], ofs_y / viewport_size[1]);
+ effects->overide_winmat, persmat, ofs[0] / viewport_size[0], ofs[1] / viewport_size[1]);
mul_m4_m4m4(effects->overide_persmat, effects->overide_winmat, viewmat);
invert_m4_m4(effects->overide_persinv, effects->overide_persmat);
@@ -157,6 +163,7 @@ void EEVEE_temporal_sampling_matrices_calc(EEVEE_EffectsInfo *effects,
void EEVEE_temporal_sampling_reset(EEVEE_Data *vedata)
{
vedata->stl->effects->taa_render_sample = 1;
+ vedata->stl->effects->taa_current_sample = 1;
}
int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
diff --git a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
index f23303c5b93..32076b47d8c 100644
--- a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
@@ -1,7 +1,8 @@
/* Based on Practical Realtime Strategies for Accurate Indirect Occlusion
* http://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pdf
- * http://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pptx */
+ * http://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pptx
+ */
#if defined(MESH_SHADER)
# if !defined(USE_ALPHA_HASH)
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
index 9ed0ab9a5d4..3a5f20b952e 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -319,7 +319,8 @@ float line_unit_sphere_intersect_dist(vec3 lineorigin, vec3 linedirection)
float line_unit_box_intersect_dist(vec3 lineorigin, vec3 linedirection)
{
- /* https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ */
+ /* https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
+ */
vec3 firstplane = (vec3(1.0) - lineorigin) / linedirection;
vec3 secondplane = (vec3(-1.0) - lineorigin) / linedirection;
vec3 furthestplane = max(firstplane, secondplane);
@@ -837,9 +838,16 @@ Closure closure_mix(Closure cl1, Closure cl2, float fac)
# ifdef USE_SSS
cl.sss_data.rgb = mix(cl1.sss_data.rgb, cl2.sss_data.rgb, fac);
cl.sss_data.a = (cl1.sss_data.a > 0.0) ? cl1.sss_data.a : cl2.sss_data.a;
+
# ifdef USE_SSS_ALBEDO
/* TODO Find a solution to this. Dither? */
cl.sss_albedo = (cl1.sss_data.a > 0.0) ? cl1.sss_albedo : cl2.sss_albedo;
+ /* Add radiance that was supposed to be filtered but was rejected. */
+ cl.radiance += (cl1.sss_data.a > 0.0) ? cl2.sss_data.rgb * cl2.sss_albedo :
+ cl1.sss_data.rgb * cl1.sss_albedo;
+# else
+ /* Add radiance that was supposed to be filtered but was rejected. */
+ cl.radiance += (cl1.sss_data.a > 0.0) ? cl2.sss_data.rgb : cl1.sss_data.rgb;
# endif
# endif
@@ -920,10 +928,19 @@ void main()
/* For Probe capture */
# ifdef USE_SSS
+ float fac = float(!sssToggle);
+
+# ifdef USE_REFRACTION
+ /* SSRefraction pass is done after the SSS pass.
+ * In order to not loose the diffuse light totally we
+ * need to merge the SSS radiance to the main radiance. */
+ fac = 1.0;
+# endif
+
# ifdef USE_SSS_ALBEDO
- fragColor.rgb += cl.sss_data.rgb * cl.sss_albedo.rgb * float(!sssToggle);
+ fragColor.rgb += cl.sss_data.rgb * cl.sss_albedo.rgb * fac;
# else
- fragColor.rgb += cl.sss_data.rgb * float(!sssToggle);
+ fragColor.rgb += cl.sss_data.rgb * fac;
# endif
# endif
}
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
index 8a10962c6ef..d8cec17af58 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
@@ -5,6 +5,7 @@ uniform sampler2D colorBuffer;
uniform sampler2D depthBuffer;
uniform vec2 dofParams;
+uniform bool unpremult;
#define dof_mul dofParams.x /* distance * aperturesize * invsensorsize */
#define dof_bias dofParams.y /* aperturesize * invsensorsize */
@@ -241,8 +242,12 @@ void main(void)
fragColor = (far_col + near_col + focus_col) * inv_weight_sum;
# ifdef USE_ALPHA_DOF
- /* Unpremult */
- fragColor.rgb /= (fragColor.a > 0.0) ? fragColor.a : 1.0;
+ /* Sigh... viewport expect premult output but
+ * the final render output needs to be with
+ * associated alpha. */
+ if (unpremult) {
+ fragColor.rgb /= (fragColor.a > 0.0) ? fragColor.a : 1.0;
+ }
# endif
}
diff --git a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
index 3ec695fcdbc..ac6751fb5fb 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
@@ -14,7 +14,8 @@ vec4 safe_color(vec4 c)
/**
* Adapted from https://casual-effects.com/g3d/G3D10/data-files/shader/Film/Film_temporalAA.pix
- * which is adapted from https://github.com/gokselgoktas/temporal-anti-aliasing/blob/master/Assets/Resources/Shaders/TemporalAntiAliasing.cginc
+ * which is adapted from
+ * https://github.com/gokselgoktas/temporal-anti-aliasing/blob/master/Assets/Resources/Shaders/TemporalAntiAliasing.cginc
* which is adapted from https://github.com/playdeadgames/temporal
* Optimization by Stubbesaurus and epsilon adjustment to avoid division by zero.
*
@@ -38,7 +39,6 @@ vec3 clip_to_aabb(vec3 color, vec3 minimum, vec3 maximum, vec3 average)
void main()
{
ivec2 texel = ivec2(gl_FragCoord.xy);
- float depth = texelFetch(depthBuffer, texel, 0).r;
vec2 motion = texelFetch(velocityBuffer, texel, 0).rg;
/* Decode from unsigned normalized 16bit texture. */
@@ -95,6 +95,9 @@ void main()
color_history = (out_of_view) ? color : color_history;
FragColor = safe_color(color_history);
+ /* There is some ghost issue if we use the alpha
+ * in the viewport. Overwritting alpha fixes it. */
+ FragColor.a = color.a;
}
#else
diff --git a/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl
index b9e038ceeaf..7d701bce5cb 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl
@@ -17,6 +17,9 @@ void main()
outData = uv - uv_history;
+ /* HACK: Reject lookdev spheres from TAA reprojection. */
+ outData = (depth > 0.0) ? outData : vec2(0.0);
+
/* Encode to unsigned normalized 16bit texture. */
outData = outData * 0.5 + 0.5;
}
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
index 0c7be71d914..a70ac686efd 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
@@ -161,7 +161,8 @@ vec3 probe_evaluate_cube(int pd_id, vec3 W, vec3 R, float roughness)
/* From Frostbite PBR Course
* Distance based roughness
- * http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf */
+ * http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
+ */
float original_roughness = roughness;
float linear_roughness = sqrt(roughness);
float distance_roughness = saturate(dist * linear_roughness / length(intersection));
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
index 7dba3738c12..fe3225b1086 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
@@ -13,13 +13,8 @@ uniform sampler2DArray utilTex;
in vec3 worldPosition;
in vec3 viewPosition;
-#ifdef USE_FLAT_NORMAL
-flat in vec3 worldNormal;
-flat in vec3 viewNormal;
-#else
in vec3 worldNormal;
in vec3 viewNormal;
-#endif
#ifdef HAIR_SHADER
in vec3 hairTangent; /* world space */
@@ -44,6 +39,14 @@ uniform int hairThicknessRes = 1;
#define CLOSURE_GLOSSY
#endif /* SURFACE_DEFAULT */
+#if !defined(SURFACE_DEFAULT_CLEARCOAT) && !defined(CLOSURE_NAME)
+#define SURFACE_DEFAULT_CLEARCOAT
+#define CLOSURE_NAME eevee_closure_default_clearcoat
+#define CLOSURE_DIFFUSE
+#define CLOSURE_GLOSSY
+#define CLOSURE_CLEARCOAT
+#endif /* SURFACE_DEFAULT_CLEARCOAT */
+
#if !defined(SURFACE_PRINCIPLED) && !defined(CLOSURE_NAME)
#define SURFACE_PRINCIPLED
#define CLOSURE_NAME eevee_closure_principled
@@ -274,7 +277,8 @@ void CLOSURE_NAME(vec3 N
/* ---------------- SPECULAR ENVIRONMENT LIGHTING ----------------- */
/* ---------------------------------------------------------------- */
- /* Accumulate incoming light from all sources until accumulator is full. Then apply Occlusion and BRDF. */
+ /* Accumulate incoming light from all sources until accumulator is full. Then apply Occlusion and
+ * BRDF. */
#ifdef CLOSURE_GLOSSY
vec4 spec_accum = vec4(0.0);
#endif
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
index 29ecbd694c9..40075ed64be 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
@@ -23,13 +23,8 @@ layout(std140) uniform clip_block
vec4 ClipPlanes[1];
};
-#ifdef USE_FLAT_NORMAL
-flat out vec3 worldNormal;
-flat out vec3 viewNormal;
-#else
out vec3 worldNormal;
out vec3 viewNormal;
-#endif
#ifdef HAIR_SHADER
out vec3 hairTangent;
diff --git a/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl b/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
index 88dd9f46b55..2cf8501de9b 100644
--- a/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
@@ -164,8 +164,8 @@ void ltc_transform_quad(vec3 N, vec3 V, mat3 Minv, inout vec3 corners[4])
corners[3] = normalize(Minv * corners[3]);
}
-/* If corners have already pass through ltc_transform_quad(), then N **MUST** be vec3(0.0, 0.0, 1.0),
- * corresponding to the Up axis of the shading basis. */
+/* If corners have already pass through ltc_transform_quad(),
+ * then N **MUST** be vec3(0.0, 0.0, 1.0), corresponding to the Up axis of the shading basis. */
float ltc_evaluate_quad(vec3 corners[4], vec3 N)
{
/* Approximation using a sphere of the same solid angle than the quad.
diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
index 49c4569f585..82581f2327b 100644
--- a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
@@ -84,8 +84,8 @@ void prepare_raycast(vec3 ray_origin,
ss_end.w = project_point(ProjectionMatrix, ray_end).z;
/* XXX This is a hack a better method is welcome ! */
- /* We take the delta between the offseted depth and the depth and substract it from the ray depth.
- * This will change the world space thickness appearance a bit but we can have negative
+ /* We take the delta between the offseted depth and the depth and substract it from the ray
+ * depth. This will change the world space thickness appearance a bit but we can have negative
* values without worries. We cannot do this in viewspace because of the perspective division. */
ss_start.w = 2.0 * ss_start.z - ss_start.w;
ss_end.w = 2.0 * ss_end.z - ss_end.w;
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
index 5c0f5adda27..f24032c4360 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
@@ -36,7 +36,8 @@ vec3 octahedral_to_cubemap_proj(vec2 co)
}
/* Marco Salvi's GDC 2008 presentation about shadow maps pre-filtering techniques slide 24 */
-/* http://advances.realtimerendering.com/s2009/SIGGRAPH%202009%20-%20Lighting%20Research%20at%20Bungie.pdf Slide 55*/
+/* http://advances.realtimerendering.com/s2009/SIGGRAPH%202009%20-%20Lighting%20Research%20at%20Bungie.pdf
+ * Slide 55. */
#define ln_space_prefilter_step(ref, sample) exp(sample - ref)
#define ln_space_prefilter_finalize(ref, sum) (ref + log(shadowInvSampleCount * sum))
diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c
index 29749ce6712..ed8c609c01f 100644
--- a/source/blender/draw/engines/external/external_engine.c
+++ b/source/blender/draw/engines/external/external_engine.c
@@ -54,12 +54,12 @@ typedef struct EXTERNAL_StorageList {
} EXTERNAL_StorageList;
typedef struct EXTERNAL_FramebufferList {
- struct GPUFrameBuffer *default_fb;
+ struct GPUFrameBuffer *depth_buffer_fb;
} EXTERNAL_FramebufferList;
typedef struct EXTERNAL_TextureList {
/* default */
- struct GPUTexture *depth;
+ struct GPUTexture *depth_buffer_tx;
} EXTERNAL_TextureList;
typedef struct EXTERNAL_PassList {
@@ -80,30 +80,77 @@ typedef struct EXTERNAL_Data {
static struct {
/* Depth Pre Pass */
struct GPUShader *depth_sh;
+ bool draw_depth;
} e_data = {NULL}; /* Engine data */
typedef struct EXTERNAL_PrivateData {
DRWShadingGroup *depth_shgrp;
+
+ /* Do we need to update the depth or can we reuse the last calculated texture. */
+ bool update_depth;
+ bool view_updated;
+
+ float last_mat[4][4];
+ float curr_mat[4][4];
} EXTERNAL_PrivateData; /* Transient data */
/* Functions */
-static void external_engine_init(void *UNUSED(vedata))
+static void external_engine_init(void *vedata)
{
+ EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ RegionView3D *rv3d = draw_ctx->rv3d;
+
/* Depth prepass */
if (!e_data.depth_sh) {
e_data.depth_sh = DRW_shader_create_3d_depth_only(GPU_SHADER_CFG_DEFAULT);
}
+
+ if (!stl->g_data) {
+ /* Alloc transient pointers */
+ stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
+ stl->g_data->update_depth = true;
+ stl->g_data->view_updated = false;
+ }
+
+ if (stl->g_data->update_depth == false) {
+ if (rv3d && rv3d->rflag & RV3D_NAVIGATING) {
+ stl->g_data->update_depth = true;
+ }
+ }
+
+ if (stl->g_data->view_updated) {
+ stl->g_data->update_depth = true;
+ stl->g_data->view_updated = false;
+ }
+
+ {
+ float view[4][4];
+ float win[4][4];
+ DRW_viewport_matrix_get(view, DRW_MAT_VIEW);
+ DRW_viewport_matrix_get(win, DRW_MAT_WIN);
+ mul_m4_m4m4(stl->g_data->curr_mat, view, win);
+ if (!equals_m4m4(stl->g_data->curr_mat, stl->g_data->last_mat)) {
+ stl->g_data->update_depth = true;
+ }
+ }
}
static void external_cache_init(void *vedata)
{
EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl;
EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
+ EXTERNAL_TextureList *txl = ((EXTERNAL_Data *)vedata)->txl;
+ EXTERNAL_FramebufferList *fbl = ((EXTERNAL_Data *)vedata)->fbl;
- if (!stl->g_data) {
- /* Alloc transient pointers */
- stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
+ {
+ DRW_texture_ensure_fullscreen_2d(&txl->depth_buffer_tx, GPU_DEPTH24_STENCIL8, 0);
+
+ GPU_framebuffer_ensure_config(&fbl->depth_buffer_fb,
+ {
+ GPU_ATTACHMENT_TEXTURE(txl->depth_buffer_tx),
+ });
}
/* Depth Pass */
@@ -112,6 +159,16 @@ static void external_cache_init(void *vedata)
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL);
stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
}
+
+ /* Do not draw depth pass when overlays are turned off. */
+ e_data.draw_depth = false;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const View3D *v3d = draw_ctx->v3d;
+ if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
+ /* mark `update_depth` for when overlays are turned on again. */
+ stl->g_data->update_depth = true;
+ return;
+ }
}
static void external_cache_populate(void *vedata, Object *ob)
@@ -122,10 +179,20 @@ static void external_cache_populate(void *vedata, Object *ob)
return;
}
- struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
- if (geom) {
- /* Depth Prepass */
- DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat);
+ /* Do not draw depth pass when overlays are turned off. */
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const View3D *v3d = draw_ctx->v3d;
+ if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
+ return;
+ }
+
+ if (stl->g_data->update_depth) {
+ e_data.draw_depth = true;
+ struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
+ if (geom) {
+ /* Depth Prepass */
+ DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat);
+ }
}
}
@@ -181,7 +248,10 @@ static void external_draw_scene_do(void *vedata)
static void external_draw_scene(void *vedata)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
+ EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl;
+ EXTERNAL_FramebufferList *fbl = ((EXTERNAL_Data *)vedata)->fbl;
+ const DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
/* Will be NULL during OpenGL render.
* OpenGL render is used for quick preview (thumbnails or sequencer preview)
@@ -189,7 +259,28 @@ static void external_draw_scene(void *vedata)
if (draw_ctx->evil_C) {
external_draw_scene_do(vedata);
}
- DRW_draw_pass(psl->depth_pass);
+
+ if (e_data.draw_depth) {
+ DRW_draw_pass(psl->depth_pass);
+ // copy result to tmp buffer
+ GPU_framebuffer_blit(dfbl->depth_only_fb, 0, fbl->depth_buffer_fb, 0, GPU_DEPTH_BIT);
+ stl->g_data->update_depth = false;
+ }
+ else {
+ // copy tmp buffer to default
+ GPU_framebuffer_blit(fbl->depth_buffer_fb, 0, dfbl->depth_only_fb, 0, GPU_DEPTH_BIT);
+ }
+
+ copy_m4_m4(stl->g_data->last_mat, stl->g_data->curr_mat);
+}
+
+static void external_view_update(void *vedata)
+{
+ EXTERNAL_Data *data = vedata;
+ EXTERNAL_StorageList *stl = data->stl;
+ if (stl && stl->g_data) {
+ stl->g_data->view_updated = true;
+ }
}
static void external_engine_free(void)
@@ -211,12 +302,13 @@ static DrawEngineType draw_engine_external_type = {
&external_cache_finish,
NULL,
&external_draw_scene,
- NULL,
+ &external_view_update,
NULL,
NULL,
};
-/* Note: currently unused, we should not register unless we want to see this when debugging the view. */
+/* Note: currently unused,
+ * we should not register unless we want to see this when debugging the view. */
RenderEngineType DRW_engine_viewport_external_type = {
NULL,
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 ea33c004191..7dabbcf4c41 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -176,16 +176,20 @@ void DRW_gpencil_get_point_geom(GpencilBatchCacheElem *be,
/* use previous point to determine stroke direction */
bGPDspoint *pt2 = NULL;
+ float fpt[3];
if (i == 0) {
if (gps->totpoints > 1) {
/* extrapolate a point before first point */
- float fpt[3];
pt2 = &gps->points[1];
interp_v3_v3v3(fpt, &pt2->x, &pt->x, 1.5f);
GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, fpt);
}
else {
- GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, &pt->x);
+ /* add small offset to get a vector */
+ copy_v3_v3(fpt, &pt->x);
+ fpt[0] += 0.00001f;
+ fpt[1] += 0.00001f;
+ GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, fpt);
}
}
else {
@@ -630,8 +634,9 @@ GPUBatch *DRW_gpencil_get_buffer_fill_geom(bGPdata *gpd)
float(*points2d)[2] = MEM_mallocN(sizeof(*points2d) * totpoints, __func__);
/* Convert points to array and triangulate
- * Here a cache is not used because while drawing the information changes all the time, so the cache
- * would be recalculated constantly, so it is better to do direct calculation for each function call
+ * Here a cache is not used because while drawing the information changes all the time, so the
+ * cache would be recalculated constantly, so it is better to do direct calculation for each
+ * function call
*/
for (int i = 0; i < totpoints; i++) {
const tGPspoint *pt = &points[i];
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 8c2dee66d92..4b6c913785d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1072,7 +1072,8 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache,
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 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) ||
@@ -1367,7 +1368,8 @@ static void gpencil_copy_frame(bGPDframe *gpf, bGPDframe *derived_gpf)
}
}
-/* Triangulate stroke for high quality fill (this is done only if cache is null or stroke was modified) */
+/* Triangulate stroke for high quality fill (this is done only if cache is null or stroke was
+ * modified) */
void DRW_gpencil_triangulate_stroke_fill(Object *ob, bGPDstroke *gps)
{
BLI_assert(gps->totpoints >= 3);
@@ -1456,6 +1458,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data,
View3D *v3d = draw_ctx->v3d;
const bool overlay = v3d != NULL ? (bool)((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) : true;
Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
+ const bool is_paint_tool = (bool)((brush) && (brush->gpencil_tool == GPAINT_TOOL_DRAW));
bGPdata *gpd_eval = ob->data;
/* need the original to avoid cow overhead while drawing */
bGPdata *gpd = (bGPdata *)DEG_get_original_id(&gpd_eval->id);
@@ -1581,7 +1584,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data,
const bool is_show_gizmo = (((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) &&
((v3d->gizmo_flag & V3D_GIZMO_HIDE_TOOL) == 0));
- if ((overlay) && (is_cppoint || is_speed_guide) && (is_show_gizmo) &&
+ if ((overlay) && (is_paint_tool) && (is_cppoint || is_speed_guide) && (is_show_gizmo) &&
((gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0)) {
DRWShadingGroup *shgrp = DRW_shgroup_create(e_data->gpencil_edit_point_sh, psl->drawing_pass);
const float *viewport_size = DRW_viewport_size_get();
@@ -1909,6 +1912,28 @@ void DRW_gpencil_populate_multiedit(GPENCIL_e_data *e_data,
cache->is_dirty = false;
}
+/* ensure there is a derived frame */
+static void gpencil_ensure_derived_frame(bGPdata *gpd,
+ bGPDlayer *gpl,
+ bGPDframe *gpf,
+ GpencilBatchCache *cache,
+ bGPDframe **derived_gpf)
+{
+ /* create derived frames array data or expand */
+ int derived_idx = BLI_findindex(&gpd->layers, gpl);
+ *derived_gpf = &cache->derived_array[derived_idx];
+
+ /* if no derived frame or dirty cache, create a new one */
+ if ((*derived_gpf == NULL) || (cache->is_dirty)) {
+ if (*derived_gpf != NULL) {
+ /* first clear temp data */
+ BKE_gpencil_free_frame_runtime_data(*derived_gpf);
+ }
+ /* create new data (do not assign new memory)*/
+ gpencil_copy_frame(gpf, *derived_gpf);
+ }
+}
+
/* helper for populate a complete grease pencil datablock */
void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data,
void *vedata,
@@ -2001,18 +2026,7 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data,
}
/* create derived frames array data or expand */
- int derived_idx = BLI_findindex(&gpd->layers, gpl);
- derived_gpf = &cache->derived_array[derived_idx];
-
- /* if no derived frame or dirty cache, create a new one */
- if ((derived_gpf == NULL) || (cache->is_dirty)) {
- if (derived_gpf != NULL) {
- /* first clear temp data */
- BKE_gpencil_free_frame_runtime_data(derived_gpf);
- }
- /* create new data (do not assign new memory)*/
- gpencil_copy_frame(gpf, derived_gpf);
- }
+ gpencil_ensure_derived_frame(gpd, gpl, gpf, cache, &derived_gpf);
/* draw onion skins */
if (!ID_IS_LINKED(&gpd->id)) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 6fa07245396..ea578187765 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -328,7 +328,8 @@ void GPENCIL_cache_init(void *vedata)
stl->g_data->shgrps_edit_point = NULL;
if (!stl->shgroups) {
- /* Alloc maximum size because count strokes is very slow and can be very complex due onion skinning.
+ /* Alloc maximum size because count strokes is very slow and can be very complex due onion
+ * skinning.
*/
stl->shgroups = MEM_mallocN(sizeof(GPENCIL_shgroup) * GPENCIL_MAX_SHGROUPS, "GPENCIL_shgroup");
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index b133d9310b0..355235618f6 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -119,10 +119,11 @@ static void GPENCIL_dof_nearfar(Object *camera, float coc, float nearfar[2])
float focus_dist = BKE_camera_object_dof_distance(camera);
float focal_len = cam->lens;
- /* this is factor that converts to the scene scale. focal length and sensor are expressed in mm
- * unit.scale_length is how many meters per blender unit we have. We want to convert to blender units though
- * because the shader reads coordinates in world space, which is in blender units.
- * Note however that focus_distance is already in blender units and shall not be scaled here (see T48157). */
+ /* This is factor that converts to the scene scale. focal length and sensor are expressed in mm
+ * unit.scale_length is how many meters per blender unit we have. We want to convert to blender
+ * units though because the shader reads coordinates in world space, which is in blender units.
+ * Note however that focus_distance is already in blender units and shall not be scaled here
+ * (see T48157). */
float scale = (scene->unit.system) ? scene->unit.scale_length : 1.0f;
float scale_camera = 0.001f / scale;
/* we want radius here for the aperture number */
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl
index b5d0a5bce71..8c3fd022004 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl
@@ -16,6 +16,12 @@ vec2 toScreenSpace(vec4 vertex)
return vec2(vertex.xy / vertex.w) * Viewport;
}
+/* get zdepth value */
+float getZdepth(vec4 point)
+{
+ return min(-0.05, (point.z / point.w));
+}
+
void main(void)
{
vec4 P0 = gl_in[0].gl_Position;
@@ -26,22 +32,22 @@ void main(void)
/* generate the triangle strip */
mTexCoord = vec2(0, 1);
mColor = finalColor[0];
- gl_Position = vec4(vec2(sp0.x - size, sp0.y + size) / Viewport, 0, 1.0);
+ gl_Position = vec4(vec2(sp0.x - size, sp0.y + size) / Viewport, getZdepth(P0), 1.0);
EmitVertex();
mTexCoord = vec2(0, 0);
mColor = finalColor[0];
- gl_Position = vec4(vec2(sp0.x - size, sp0.y - size) / Viewport, 0, 1.0);
+ gl_Position = vec4(vec2(sp0.x - size, sp0.y - size) / Viewport, getZdepth(P0), 1.0);
EmitVertex();
mTexCoord = vec2(1, 1);
mColor = finalColor[0];
- gl_Position = vec4(vec2(sp0.x + size, sp0.y + size) / Viewport, 0, 1.0);
+ gl_Position = vec4(vec2(sp0.x + size, sp0.y + size) / Viewport, getZdepth(P0), 1.0);
EmitVertex();
mTexCoord = vec2(1, 0);
mColor = finalColor[0];
- gl_Position = vec4(vec2(sp0.x + size, sp0.y - size) / Viewport, 0, 1.0);
+ gl_Position = vec4(vec2(sp0.x + size, sp0.y - size) / Viewport, getZdepth(P0), 1.0);
EmitVertex();
EndPrimitive();
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
index 632c63a39aa..acf60fc2d59 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
@@ -177,10 +177,11 @@ void main()
/* set zdepth */
if (xraymode == GP_XRAY_FRONT) {
- gl_FragDepth = 0.000001;
+ gl_FragDepth = min(-0.05, (gl_FragCoord.z / gl_FragCoord.w));
}
else if (xraymode == GP_XRAY_3DSPACE) {
- /* if 3D mode, move slightly the fill to avoid z-fighting between stroke and fill on same stroke */
+ /* if 3D mode, move slightly the fill to avoid z-fighting between stroke and fill on same
+ * stroke */
if (drawmode == GP_DRAWMODE_3D) {
gl_FragDepth = gl_FragCoord.z * 1.0001;
}
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
index b7206ac2e80..cc47e12b303 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
@@ -7,6 +7,7 @@ uniform vec2 gradient_s;
uniform vec4 colormix;
uniform float mix_stroke_factor;
+uniform int shading_type[2];
in vec4 mColor;
in vec2 mTexCoord;
@@ -23,6 +24,11 @@ out vec4 fragColor;
#define GPENCIL_COLOR_TEXTURE 1
#define GPENCIL_COLOR_PATTERN 2
+#define OB_SOLID 3
+#define V3D_SHADING_TEXTURE_COLOR 3
+
+bool no_texture = (shading_type[0] == OB_SOLID) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR);
+
/* Function to check the point inside ellipse */
float check_ellipse_point(vec2 pt, vec2 radius)
{
@@ -56,17 +62,17 @@ void main()
box = check_box_point(centered, vec2(gradient_s / 2.0));
if ((box.x > 1.0) || (box.y > 1.0)) {
discard;
- }
+ }
}
vec4 tmp_color = texture2D(myTexture, mTexCoord);
/* Solid */
- if (color_type == GPENCIL_COLOR_SOLID) {
+ if ((color_type == GPENCIL_COLOR_SOLID) || (no_texture)) {
fragColor = mColor;
}
/* texture */
- if (color_type == GPENCIL_COLOR_TEXTURE) {
+ if ((color_type == GPENCIL_COLOR_TEXTURE) && (!no_texture)) {
vec4 text_color = texture2D(myTexture, mTexCoord);
if (mix_stroke_factor > 0.0) {
fragColor.rgb = mix(text_color.rgb, colormix.rgb, mix_stroke_factor);
@@ -80,7 +86,7 @@ void main()
fragColor.a = min(fragColor.a * mColor.a, fragColor.a);
}
/* pattern */
- if (color_type == GPENCIL_COLOR_PATTERN) {
+ if ((color_type == GPENCIL_COLOR_PATTERN) && (!no_texture)) {
vec4 text_color = texture2D(myTexture, mTexCoord);
fragColor = mColor;
/* mult both alpha factor to use strength factor with color alpha limit */
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
index 2fb48ac5147..a64a7ecb9be 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
@@ -31,7 +31,7 @@ vec2 toScreenSpace(vec4 vertex)
float getZdepth(vec4 point)
{
if (xraymode == GP_XRAY_FRONT) {
- return 0.000001;
+ return min(-0.05, (point.z / point.w));
}
if (xraymode == GP_XRAY_3DSPACE) {
return (point.z / point.w);
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
index 92c9acf1f2a..9cef7601770 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
@@ -42,7 +42,7 @@ void main()
else {
float size = (ProjectionMatrix[3][3] == 0.0) ? (thickness / (gl_Position.z * defaultpixsize)) :
(thickness / defaultpixsize);
- finalThickness = max(size * objscale, 4.0); /* minimum 4 pixels */
+ finalThickness = max(size * objscale, 0.5); /* set a minimum size */
}
/* for wireframe override size and color */
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
index 8964bee69ff..6b7cee888ea 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
@@ -5,6 +5,7 @@ uniform float gradient_f;
uniform vec4 colormix;
uniform float mix_stroke_factor;
+uniform int shading_type[2];
in vec4 mColor;
in vec2 mTexCoord;
@@ -21,6 +22,11 @@ out vec4 fragColor;
#define ENDCAP 1.0
+#define OB_SOLID 3
+#define V3D_SHADING_TEXTURE_COLOR 3
+
+bool no_texture = (shading_type[0] == OB_SOLID) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR);
+
void main()
{
@@ -33,8 +39,8 @@ void main()
discard;
}
}
- /* Solid */
- if (color_type == GPENCIL_COLOR_SOLID) {
+
+ if ((color_type == GPENCIL_COLOR_SOLID) || (no_texture)) {
fragColor = tColor;
}
@@ -48,7 +54,7 @@ void main()
}
/* texture */
- if (color_type == GPENCIL_COLOR_TEXTURE) {
+ if ((color_type == GPENCIL_COLOR_TEXTURE) && (!no_texture)) {
if (mix_stroke_factor > 0.0) {
fragColor.rgb = mix(text_color.rgb, colormix.rgb, mix_stroke_factor);
fragColor.a = text_color.a;
@@ -61,7 +67,7 @@ void main()
fragColor.a = min(fragColor.a * tColor.a, fragColor.a);
}
/* pattern */
- if (color_type == GPENCIL_COLOR_PATTERN) {
+ if ((color_type == GPENCIL_COLOR_PATTERN) && (!no_texture)) {
fragColor = tColor;
/* mult both alpha factor to use strength factor with color alpha limit */
fragColor.a = min(text_color.a * tColor.a, tColor.a);
@@ -73,7 +79,7 @@ void main()
float d = abs(mTexCoord.y - 0.5) * (1.1 - gradient_f);
float alpha = 1.0 - clamp((fragColor.a - (d * 2.0)), 0.03, 1.0);
fragColor.a = smoothstep(fragColor.a, 0.0, alpha);
-
+
}
*/
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
index 7e62d6f0d64..b90f5b33a57 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
@@ -35,7 +35,7 @@ vec2 toScreenSpace(vec4 vertex)
float getZdepth(vec4 point)
{
if (xraymode == GP_XRAY_FRONT) {
- return 0.000001;
+ return min(-0.05, (point.z / point.w));
}
if (xraymode == GP_XRAY_3DSPACE) {
return (point.z / point.w);
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
index 54440f7b120..0428b0d408c 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
@@ -362,9 +362,9 @@ void main()
for (int dX = -1; dX <= 1; ++dX) {
for (int dY = -1; dY <= 1; ++dY) {
vec2 offset = vec2(float(dX), float(dY));
- /* If a pixel in the window is located at (x+dX, y+dY), put it at index (dX + R)(2R + 1) + (dY + R) of the
- * pixel array. This will fill the pixel array, with the top left pixel of the window at pixel[0] and the
- * bottom right pixel of the window at pixel[N-1]. */
+ /* If a pixel in the window is located at (x+dX, y+dY), put it at index (dX + R)(2R + 1) +
+ * (dY + R) of the pixel array. This will fill the pixel array, with the top left pixel of
+ * the window at pixel[0] and the bottom right pixel of the window at pixel[N-1]. */
v[(dX + 1) * 3 + (dY + 1)] = toVec(texture(blurTex, uv + offset * pixel_size * rad));
}
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
index 26ebe7a4553..a1c269d5a65 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
@@ -64,7 +64,8 @@ float max_v3(vec3 v)
float line_unit_box_intersect_dist(vec3 lineorigin, vec3 linedirection)
{
- /* https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ */
+ /* https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
+ */
vec3 firstplane = (vec3(1.0) - lineorigin) / linedirection;
vec3 secondplane = (vec3(-1.0) - lineorigin) / linedirection;
vec3 furthestplane = min(firstplane, secondplane);
diff --git a/source/blender/draw/engines/workbench/solid_mode.c b/source/blender/draw/engines/workbench/solid_mode.c
index a01b14f17fb..e1050751830 100644
--- a/source/blender/draw/engines/workbench/solid_mode.c
+++ b/source/blender/draw/engines/workbench/solid_mode.c
@@ -61,8 +61,12 @@ static void workbench_solid_cache_finish(void *vedata)
static void workbench_solid_draw_background(void *vedata)
{
WORKBENCH_Data *data = vedata;
- workbench_deferred_draw_background(data);
- workbench_deferred_draw_scene(data);
+ const int num_samples = workbench_num_viewport_rendering_iterations(data);
+
+ for (int sample = 0; sample < num_samples; sample++) {
+ workbench_deferred_draw_background(data);
+ workbench_deferred_draw_scene(data);
+ }
workbench_deferred_draw_finish(data);
}
diff --git a/source/blender/draw/engines/workbench/transparent_mode.c b/source/blender/draw/engines/workbench/transparent_mode.c
index 0f4150ff986..bd2fb24dd85 100644
--- a/source/blender/draw/engines/workbench/transparent_mode.c
+++ b/source/blender/draw/engines/workbench/transparent_mode.c
@@ -59,8 +59,12 @@ static void workbench_transparent_cache_finish(void *vedata)
static void workbench_transparent_draw_background(void *vedata)
{
WORKBENCH_Data *data = vedata;
- workbench_forward_draw_background(data);
- workbench_forward_draw_scene(data);
+ const int num_samples = workbench_num_viewport_rendering_iterations(data);
+
+ for (int sample = 0; sample < num_samples; sample++) {
+ workbench_forward_draw_background(data);
+ workbench_forward_draw_scene(data);
+ }
workbench_forward_draw_finish(data);
}
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c
index efbe33b45da..abf167d53b0 100644
--- a/source/blender/draw/engines/workbench/workbench_deferred.c
+++ b/source/blender/draw/engines/workbench/workbench_deferred.c
@@ -935,13 +935,13 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
WORKBENCH_MaterialData *material;
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 is_sculpt_mode = DRW_object_use_pbvh_drawing(ob);
const bool use_hide = is_active && DRW_object_use_hide_faces(ob);
- const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol));
+ const int materials_len = MAX2(1, ob->totcol);
const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL;
bool has_transp_mat = false;
- if (!is_sculpt_mode && me && me->mloopuv && TEXTURE_DRAWING_ENABLED(wpd)) {
+ if (!is_sculpt_mode && TEXTURE_DRAWING_ENABLED(wpd) && me && me->mloopuv) {
/* Draw textured */
struct GPUBatch **geom_array = DRW_cache_mesh_surface_texpaint_get(ob);
for (int i = 0; i < materials_len; i++) {
@@ -983,8 +983,10 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
/* Draw solid color */
material = get_or_create_material_data(vedata, ob, NULL, NULL, NULL, color_type, 0);
}
+
if (is_sculpt_mode) {
- DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat);
+ bool use_vcol = (color_type == V3D_SHADING_VERTEX_COLOR);
+ DRW_shgroup_call_sculpt_add(material->shgrp, ob, false, false, use_vcol);
}
else {
struct GPUBatch *geom;
@@ -1003,11 +1005,25 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
else {
/* Draw material color */
if (is_sculpt_mode) {
- /* Multiple materials are not supported in sculpt mode yet. */
- Material *mat = give_current_material(ob, 1);
- material = get_or_create_material_data(
- vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
- DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat);
+ struct DRWShadingGroup **shgrps = BLI_array_alloca(shgrps, materials_len);
+ struct Material **mats = BLI_array_alloca(mats, materials_len);
+
+ for (int i = 0; i < materials_len; ++i) {
+ mats[i] = give_current_material(ob, i + 1);
+ if (mats[i] != NULL && mats[i]->a < 1.0f) {
+ /* Hack */
+ wpd->shading.xray_alpha = mats[i]->a;
+ material = workbench_forward_get_or_create_material_data(
+ vedata, ob, mats[i], NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, is_sculpt_mode);
+ has_transp_mat = true;
+ }
+ else {
+ material = get_or_create_material_data(
+ vedata, ob, mats[i], NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
+ }
+ shgrps[i] = material->shgrp;
+ }
+ DRW_shgroup_call_sculpt_with_materials_add(shgrps, mats, ob, false);
}
else {
struct GPUBatch **geoms;
@@ -1156,7 +1172,7 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata)
WORKBENCH_PrivateData *wpd = stl->g_data;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
- if (TAA_ENABLED(wpd)) {
+ if (workbench_is_taa_enabled(wpd)) {
workbench_taa_draw_scene_start(vedata);
}
diff --git a/source/blender/draw/engines/workbench/workbench_effect_aa.c b/source/blender/draw/engines/workbench/workbench_effect_aa.c
index a80f6ce338b..b4cdcfcfc99 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_aa.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_aa.c
@@ -40,10 +40,10 @@ void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx)
wpd->is_playback = false;
}
- if (TAA_ENABLED(wpd)) {
+ if (workbench_is_taa_enabled(wpd)) {
psl->effect_aa_pass = workbench_taa_create_pass(vedata, tx);
}
- else if (FXAA_ENABLED(wpd)) {
+ else if (workbench_is_fxaa_enabled(wpd)) {
psl->effect_aa_pass = workbench_fxaa_create_pass(tx);
effect_info->jitter_index = 0;
}
@@ -73,13 +73,13 @@ void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx)
WORKBENCH_EffectInfo *effect_info = stl->effects;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
- if (FXAA_ENABLED(wpd)) {
+ if (workbench_is_fxaa_enabled(wpd)) {
GPU_framebuffer_bind(fbl->effect_fb);
workspace_aa_draw_transform(tx, wpd);
GPU_framebuffer_bind(dfbl->color_only_fb);
DRW_draw_pass(psl->effect_aa_pass);
}
- else if (TAA_ENABLED(wpd)) {
+ else if (workbench_is_taa_enabled(wpd)) {
/*
* when drawing the first TAA frame, we transform directly to the
* color_only_fb as the TAA shader is just performing a direct copy.
diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c
index f55b744481e..3dea99a76cf 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c
@@ -243,9 +243,10 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera)
/* TODO(fclem) deduplicate with eevee */
/* this is factor that converts to the scene scale. focal length and sensor are expressed in mm
- * unit.scale_length is how many meters per blender unit we have. We want to convert to blender units though
- * because the shader reads coordinates in world space, which is in blender units.
- * Note however that focus_distance is already in blender units and shall not be scaled here (see T48157). */
+ * unit.scale_length is how many meters per blender unit we have. We want to convert to blender
+ * units though because the shader reads coordinates in world space, which is in blender units.
+ * Note however that focus_distance is already in blender units and shall not be scaled here
+ * (see T48157). */
float scale = (scene_eval->unit.system) ? scene_eval->unit.scale_length : 1.0f;
float scale_camera = 0.001f / scale;
/* we want radius here for the aperture number */
diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c
index 0435a804fab..7c411135634 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_taa.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c
@@ -90,26 +90,40 @@ int workbench_taa_calculate_num_iterations(WORKBENCH_Data *vedata)
{
WORKBENCH_StorageList *stl = vedata->stl;
WORKBENCH_PrivateData *wpd = stl->g_data;
- int result = 1;
- if (TAA_ENABLED(wpd)) {
+ const Scene *scene = DRW_context_state_get()->scene;
+ int result = scene->display.viewport_aa;
+ if (workbench_is_taa_enabled(wpd)) {
if (DRW_state_is_image_render()) {
- const Scene *scene = DRW_context_state_get()->scene;
- result = (scene->r.mode & R_OSA) ? scene->r.osa : 1;
+ result = scene->display.render_aa;
}
else if (IN_RANGE_INCL(wpd->preferences->gpu_viewport_quality,
GPU_VIEWPORT_QUALITY_TAA8,
GPU_VIEWPORT_QUALITY_TAA16)) {
- result = 8;
+ result = MIN2(result, 8);
}
else if (IN_RANGE_INCL(wpd->preferences->gpu_viewport_quality,
GPU_VIEWPORT_QUALITY_TAA16,
GPU_VIEWPORT_QUALITY_TAA32)) {
- result = 16;
+ result = MIN2(result, 16);
}
else {
- result = 32;
+ result = MIN2(result, 32);
}
}
+ else {
+ /* when no TAA is disabled return 1 to render a single sample
+ * see `workbench_render.c` */
+ result = 1;
+ }
+ return result;
+}
+
+int workbench_num_viewport_rendering_iterations(WORKBENCH_Data *UNUSED(vedata))
+{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const Scene *scene = draw_ctx->scene;
+ int result = DRW_state_is_image_render() ? scene->display.viewport_aa : 1;
+ result = MAX2(result, 1);
return result;
}
diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c
index 1117ee0126b..fe3e0579c8e 100644
--- a/source/blender/draw/engines/workbench/workbench_forward.c
+++ b/source/blender/draw/engines/workbench/workbench_forward.c
@@ -565,71 +565,79 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
WORKBENCH_MaterialData *material;
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;
- 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 GPUBatch **geom_array = DRW_cache_mesh_surface_texpaint_get(ob);
- for (int i = 0; i < materials_len; i++) {
- Material *mat;
- Image *image;
- ImageUser *iuser;
- int interp;
- workbench_material_get_image_and_mat(ob, i + 1, &image, &iuser, &interp, &mat);
- int color_type = workbench_material_determine_color_type(wpd, image, ob, is_sculpt_mode);
- material = workbench_forward_get_or_create_material_data(
- vedata, ob, mat, image, iuser, color_type, interp, is_sculpt_mode);
- DRW_shgroup_call_object_add(material->shgrp_object_outline, geom_array[i], ob);
- DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob);
- }
- is_drawn = true;
+ const bool is_sculpt_mode = DRW_object_use_pbvh_drawing(ob);
+ const int materials_len = MAX2(1, ob->totcol);
+ const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL;
+
+ if (!is_sculpt_mode && TEXTURE_DRAWING_ENABLED(wpd) && me && me->mloopuv) {
+ struct GPUBatch **geom_array = DRW_cache_mesh_surface_texpaint_get(ob);
+ for (int i = 0; i < materials_len; i++) {
+ Material *mat;
+ Image *image;
+ ImageUser *iuser;
+ int interp;
+ workbench_material_get_image_and_mat(ob, i + 1, &image, &iuser, &interp, &mat);
+ int color_type = workbench_material_determine_color_type(wpd, image, ob, is_sculpt_mode);
+ material = workbench_forward_get_or_create_material_data(
+ vedata, ob, mat, image, iuser, color_type, interp, is_sculpt_mode);
+ DRW_shgroup_call_object_add(material->shgrp_object_outline, geom_array[i], ob);
+ DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob);
}
}
-
- /* Fallback from not drawn OB_TEXTURE mode or just OB_SOLID mode */
- if (!is_drawn) {
- if (ELEM(wpd->shading.color_type,
- V3D_SHADING_SINGLE_COLOR,
- V3D_SHADING_OBJECT_COLOR,
- V3D_SHADING_RANDOM_COLOR,
- V3D_SHADING_VERTEX_COLOR)) {
- /* No material split needed */
- int color_type = workbench_material_determine_color_type(wpd, NULL, ob, is_sculpt_mode);
-
- struct GPUBatch *geom;
- if (color_type == V3D_SHADING_VERTEX_COLOR) {
- geom = DRW_cache_mesh_surface_vertpaint_get(ob);
- }
- else {
- geom = DRW_cache_object_surface_get(ob);
+ else if (ELEM(wpd->shading.color_type,
+ V3D_SHADING_SINGLE_COLOR,
+ V3D_SHADING_OBJECT_COLOR,
+ V3D_SHADING_RANDOM_COLOR,
+ V3D_SHADING_VERTEX_COLOR)) {
+ /* No material split needed */
+ int color_type = workbench_material_determine_color_type(wpd, NULL, ob, is_sculpt_mode);
+
+ if (is_sculpt_mode) {
+ material = workbench_forward_get_or_create_material_data(
+ vedata, ob, NULL, NULL, NULL, color_type, 0, is_sculpt_mode);
+ bool use_vcol = (color_type == V3D_SHADING_VERTEX_COLOR);
+ /* TODO(fclem) make this call optional */
+ DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, false, false, false);
+ if (!is_wire) {
+ DRW_shgroup_call_sculpt_add(material->shgrp, ob, false, false, use_vcol);
}
+ }
+ else {
+ struct GPUBatch *geom = (color_type == V3D_SHADING_VERTEX_COLOR) ?
+ DRW_cache_mesh_surface_vertpaint_get(ob) :
+ DRW_cache_object_surface_get(ob);
if (geom) {
material = workbench_forward_get_or_create_material_data(
vedata, ob, NULL, NULL, NULL, color_type, 0, is_sculpt_mode);
- if (is_sculpt_mode) {
- DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat);
- if (!is_wire) {
- DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat);
- }
- }
- else {
- DRW_shgroup_call_object_add(material->shgrp_object_outline, geom, ob);
- if (!is_wire) {
- DRW_shgroup_call_object_add(material->shgrp, geom, ob);
- }
+ /* TODO(fclem) make this call optional */
+ DRW_shgroup_call_object_add(material->shgrp_object_outline, geom, ob);
+ if (!is_wire) {
+ DRW_shgroup_call_object_add(material->shgrp, geom, ob);
}
}
}
+ }
+ else {
+ /* Draw material color */
+ if (is_sculpt_mode) {
+ struct DRWShadingGroup **shgrps = BLI_array_alloca(shgrps, materials_len);
+ struct Material **mats = BLI_array_alloca(mats, materials_len);
+
+ for (int i = 0; i < materials_len; ++i) {
+ mats[i] = give_current_material(ob, i + 1);
+ material = workbench_forward_get_or_create_material_data(
+ vedata, ob, mats[i], NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, is_sculpt_mode);
+ shgrps[i] = material->shgrp;
+ }
+ /* TODO(fclem) make this call optional */
+ DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, false, false, false);
+ if (!is_wire) {
+ DRW_shgroup_call_sculpt_with_materials_add(shgrps, mats, ob, false);
+ }
+ }
else {
- const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol));
struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len);
- for (int i = 0; i < materials_len; i++) {
- gpumat_array[i] = NULL;
- }
+ memset(gpumat_array, 0, sizeof(*gpumat_array) * materials_len);
struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get(
ob, gpumat_array, materials_len, NULL, NULL, NULL);
@@ -642,17 +650,10 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
Material *mat = give_current_material(ob, i + 1);
material = workbench_forward_get_or_create_material_data(
vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, is_sculpt_mode);
- if (is_sculpt_mode) {
- DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat);
- if (!is_wire) {
- DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat);
- }
- }
- else {
- DRW_shgroup_call_object_add(material->shgrp_object_outline, mat_geom[i], ob);
- if (!is_wire) {
- DRW_shgroup_call_object_add(material->shgrp, mat_geom[i], ob);
- }
+ /* TODO(fclem) make this call optional */
+ DRW_shgroup_call_object_add(material->shgrp_object_outline, mat_geom[i], ob);
+ if (!is_wire) {
+ DRW_shgroup_call_object_add(material->shgrp, mat_geom[i], ob);
}
}
}
@@ -683,7 +684,7 @@ void workbench_forward_draw_scene(WORKBENCH_Data *vedata)
WORKBENCH_PrivateData *wpd = stl->g_data;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
- if (TAA_ENABLED(wpd)) {
+ if (workbench_is_taa_enabled(wpd)) {
workbench_taa_draw_scene_start(vedata);
}
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index 6151c1f54dd..c403e358d6a 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -43,7 +43,8 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd,
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 */
+ /* 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;
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index 3cfb1283416..e25503aef6e 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -75,18 +75,7 @@
#define IS_NAVIGATING(wpd) \
((DRW_context_state_get()->rv3d) && (DRW_context_state_get()->rv3d->rflag & RV3D_NAVIGATING))
-#define FXAA_ENABLED(wpd) \
- ((!DRW_state_is_opengl_render()) && \
- (IN_RANGE(wpd->preferences->gpu_viewport_quality, \
- GPU_VIEWPORT_QUALITY_FXAA, \
- GPU_VIEWPORT_QUALITY_TAA8) || \
- ((IS_NAVIGATING(wpd) || wpd->is_playback) && \
- (wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8))))
-#define TAA_ENABLED(wpd) \
- ((DRW_state_is_image_render() && DRW_context_state_get()->scene->r.mode & R_OSA) || \
- (!DRW_state_is_image_render() && \
- wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8 && !IS_NAVIGATING(wpd) && \
- !wpd->is_playback))
+
#define SPECULAR_HIGHLIGHT_ENABLED(wpd) \
(STUDIOLIGHT_ENABLED(wpd) && (wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT) && \
(!STUDIOLIGHT_TYPE_MATCAP_ENABLED(wpd)))
@@ -326,6 +315,35 @@ typedef struct WORKBENCH_ObjectData {
int object_id;
} WORKBENCH_ObjectData;
+/* inline helper functions */
+BLI_INLINE bool workbench_is_taa_enabled(WORKBENCH_PrivateData *wpd)
+{
+ if (DRW_state_is_image_render()) {
+ return DRW_context_state_get()->scene->display.render_aa > SCE_DISPLAY_AA_FXAA;
+ }
+ else {
+ return DRW_context_state_get()->scene->display.viewport_aa > SCE_DISPLAY_AA_FXAA &&
+ wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8 &&
+ !wpd->is_playback;
+ }
+}
+
+BLI_INLINE bool workbench_is_fxaa_enabled(WORKBENCH_PrivateData *wpd)
+{
+ if (DRW_state_is_image_render()) {
+ return DRW_context_state_get()->scene->display.render_aa == SCE_DISPLAY_AA_FXAA;
+ }
+ else {
+ if (wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_FXAA &&
+ DRW_context_state_get()->scene->display.viewport_aa == SCE_DISPLAY_AA_FXAA) {
+ return true;
+ }
+
+ /* when navigating or animation playback use FXAA. */
+ return (IS_NAVIGATING(wpd) || wpd->is_playback) && workbench_is_taa_enabled(wpd);
+ }
+}
+
/* workbench_deferred.c */
void workbench_deferred_engine_init(WORKBENCH_Data *vedata);
void workbench_deferred_engine_free(void);
@@ -375,6 +393,7 @@ void workbench_taa_draw_scene_start(WORKBENCH_Data *vedata);
void workbench_taa_draw_scene_end(WORKBENCH_Data *vedata);
void workbench_taa_view_updated(WORKBENCH_Data *vedata);
int workbench_taa_calculate_num_iterations(WORKBENCH_Data *vedata);
+int workbench_num_viewport_rendering_iterations(WORKBENCH_Data *vedata);
/* workbench_effect_dof.c */
void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera);
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index bfb258e5c31..51747c4aecc 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -334,7 +334,7 @@ typedef enum {
DRW_STATE_BLEND = (1 << 15),
DRW_STATE_ADDITIVE = (1 << 16),
DRW_STATE_MULTIPLY = (1 << 17),
- /* DRW_STATE_TRANSMISSION = (1 << 18), */ /* Not used */
+ DRW_STATE_BLEND_PREMUL_UNDER = (1 << 18),
DRW_STATE_CLIP_PLANES = (1 << 19),
/** Same as DRW_STATE_ADDITIVE but let alpha accumulate without premult. */
DRW_STATE_ADDITIVE_FULL = (1 << 20),
@@ -406,10 +406,6 @@ DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader,
DRWPass *pass,
struct GPUVertBuf *tf_target);
-typedef void(DRWCallGenerateFn)(DRWShadingGroup *shgroup,
- void (*draw_fn)(DRWShadingGroup *shgroup, struct GPUBatch *geom),
- void *user_data);
-
/* return final visibility */
typedef bool(DRWCallVisibilityFn)(bool vis_in, void *user_data);
@@ -427,9 +423,6 @@ void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup,
void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup,
uint tria_count,
float (*obmat)[4]);
-void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup,
- uint tria_count,
- struct Object *ob);
void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup,
struct GPUBatch *geom,
struct Object *ob,
@@ -445,6 +438,17 @@ void DRW_shgroup_call_object_add_with_callback(DRWShadingGroup *shgroup,
struct Material *ma,
DRWCallVisibilityFn *callback,
void *user_data);
+
+void DRW_shgroup_call_sculpt_add(DRWShadingGroup *shading_group,
+ Object *object,
+ bool use_wire,
+ bool use_mask,
+ bool use_vert_color);
+void DRW_shgroup_call_sculpt_with_materials_add(DRWShadingGroup **shgroups,
+ Material **materials,
+ Object *ob,
+ bool use_vcol);
+
/* Used for drawing a batch with instancing without instance attributes. */
void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup,
struct GPUBatch *geom,
@@ -454,14 +458,6 @@ void DRW_shgroup_call_object_instances_add(DRWShadingGroup *shgroup,
struct GPUBatch *geom,
struct Object *ob,
uint *count);
-void DRW_shgroup_call_sculpt_add(DRWShadingGroup *shgroup, struct Object *ob, float (*obmat)[4]);
-void DRW_shgroup_call_sculpt_wires_add(DRWShadingGroup *shgroup,
- struct Object *ob,
- float (*obmat)[4]);
-void DRW_shgroup_call_generate_add(DRWShadingGroup *shgroup,
- DRWCallGenerateFn *geometry_fn,
- void *user_data,
- float (*obmat)[4]);
void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup,
const void *attr[],
uint attr_len);
@@ -646,6 +642,7 @@ bool DRW_object_is_renderable(const struct Object *ob);
int DRW_object_visibility_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_use_pbvh_drawing(const struct Object *ob);
bool DRW_object_is_visible_psys_in_active_context(const struct Object *object,
const struct ParticleSystem *psys);
@@ -664,8 +661,6 @@ void DRW_state_reset_ex(DRWState state);
void DRW_state_reset(void);
void DRW_state_lock(DRWState state);
-void DRW_state_invert_facing(void);
-
void DRW_state_clip_planes_len_set(uint plane_len);
void DRW_state_clip_planes_reset(void);
void DRW_state_clip_planes_set_from_rv3d(struct RegionView3D *rv3d);
diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c
index 8ff2916b040..a6026c9da3a 100644
--- a/source/blender/draw/intern/draw_anim_viz.c
+++ b/source/blender/draw/intern/draw_anim_viz.c
@@ -184,7 +184,7 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl,
struct DRWTextStore *dt = DRW_text_cache_ensure();
int txt_flag = DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_ASCII;
int cfra = (int)DEG_get_ctime(draw_ctx->depsgraph);
- bool sel = (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->flag & SELECT);
+ bool sel = (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->base_flag & BASE_SELECTED);
bool show_keyframes = (avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) != 0;
int sfra, efra, stepsize;
@@ -259,7 +259,8 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl,
else if (avs->path_viewflag & MOTIONPATH_VIEW_FNUMS) {
bMotionPathVert *mpvP = (mpv - stepsize);
bMotionPathVert *mpvN = (mpv + stepsize);
- /* only draw framenum if several consecutive highlighted points don't occur on same point */
+ /* only draw framenum if several consecutive highlighted points don't occur on same point
+ */
if ((equals_v3v3(mpv->co, mpvP->co) == 0) || (equals_v3v3(mpv->co, mpvN->co) == 0)) {
numstr_len = sprintf(numstr, " %d", frame);
DRW_text_cache_add(dt, mpv->co, numstr, numstr_len, 0, 0, txt_flag, col);
diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index 7d1f0568e63..9b52f282944 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -345,36 +345,61 @@ static void drw_shgroup_bone_custom_solid(const float (*bone_mat)[4],
const eGPUShaderConfig sh_cfg,
Object *custom)
{
- /* grr, not re-using instances! */
struct GPUBatch *surf = DRW_cache_object_surface_get(custom);
struct GPUBatch *edges = DRW_cache_object_edge_detection_get(custom, NULL);
struct GPUBatch *ledges = DRW_cache_object_loose_edges_get(custom);
float final_bonemat[4][4];
- /* XXXXXXX needs to be moved elsewhere. */
- drw_batch_cache_generate_requested(custom);
-
if (surf || edges || ledges) {
mul_m4_m4m4(final_bonemat, g_data.ob->obmat, bone_mat);
}
+ BLI_assert(g_data.passes.custom_shapes != NULL);
+
if (surf && g_data.passes.bone_solid != NULL) {
- DRWShadingGroup *shgrp_geom_solid = shgroup_instance_bone_shape_solid(
- g_data.passes.bone_solid, surf, g_data.transparent, sh_cfg);
+ DRWShadingGroup *shgrp_geom_solid = BLI_ghash_lookup(g_data.passes.custom_shapes, surf);
+
+ if (shgrp_geom_solid == NULL) {
+ /* TODO(fclem) needs to be moved elsewhere. */
+ drw_batch_cache_generate_requested(custom);
+
+ /* NOTE! g_data.transparent require a separate shading group if the
+ * object is transparent. This is done by passing a different ghash
+ * for transparent armature in pose mode. */
+ shgrp_geom_solid = shgroup_instance_bone_shape_solid(
+ g_data.passes.bone_solid, surf, g_data.transparent, sh_cfg);
+ BLI_ghash_insert(g_data.passes.custom_shapes, surf, shgrp_geom_solid);
+ }
DRW_shgroup_call_dynamic_add(shgrp_geom_solid, final_bonemat, bone_color, hint_color);
}
if (edges && outline_color[3] > 0.0f) {
- DRWShadingGroup *shgrp_geom_wire = shgroup_instance_bone_shape_outline(
- g_data.passes.bone_outline, edges, sh_cfg);
+ DRWShadingGroup *shgrp_geom_wire = BLI_ghash_lookup(g_data.passes.custom_shapes, edges);
+
+ if (shgrp_geom_wire == NULL) {
+ /* TODO(fclem) needs to be moved elsewhere. */
+ drw_batch_cache_generate_requested(custom);
+
+ shgrp_geom_wire = shgroup_instance_bone_shape_outline(
+ g_data.passes.bone_outline, edges, sh_cfg);
+
+ BLI_ghash_insert(g_data.passes.custom_shapes, edges, shgrp_geom_wire);
+ }
DRW_shgroup_call_dynamic_add(shgrp_geom_wire, final_bonemat, outline_color);
}
if (ledges) {
- DRWShadingGroup *shgrp_geom_ledges = shgroup_instance_wire(g_data.passes.bone_wire, ledges);
- float final_color[4];
- copy_v3_v3(final_color, outline_color);
- final_color[3] = 1.0f; /* hack */
+ DRWShadingGroup *shgrp_geom_ledges = BLI_ghash_lookup(g_data.passes.custom_shapes, ledges);
+
+ if (shgrp_geom_ledges == NULL) {
+ /* TODO(fclem) needs to be moved elsewhere. */
+ drw_batch_cache_generate_requested(custom);
+
+ shgrp_geom_ledges = shgroup_instance_wire(g_data.passes.bone_wire, ledges);
+
+ BLI_ghash_insert(g_data.passes.custom_shapes, ledges, shgrp_geom_ledges);
+ }
+ float final_color[4] = {outline_color[0], outline_color[1], outline_color[2], 1.0f};
DRW_shgroup_call_dynamic_add(shgrp_geom_ledges, final_bonemat, final_color);
}
}
@@ -383,18 +408,22 @@ static void drw_shgroup_bone_custom_wire(const float (*bone_mat)[4],
const float color[4],
Object *custom)
{
- /* grr, not re-using instances! */
struct GPUBatch *geom = DRW_cache_object_all_edges_get(custom);
- /* XXXXXXX needs to be moved elsewhere. */
- drw_batch_cache_generate_requested(custom);
-
if (geom) {
- DRWShadingGroup *shgrp_geom_wire = shgroup_instance_wire(g_data.passes.bone_wire, geom);
- float final_bonemat[4][4], final_color[4];
+ DRWShadingGroup *shgrp_geom_wire = BLI_ghash_lookup(g_data.passes.custom_shapes, geom);
+
+ if (shgrp_geom_wire == NULL) {
+ /* TODO(fclem) needs to be moved elsewhere. */
+ drw_batch_cache_generate_requested(custom);
+
+ shgrp_geom_wire = shgroup_instance_wire(g_data.passes.bone_wire, geom);
+
+ BLI_ghash_insert(g_data.passes.custom_shapes, geom, shgrp_geom_wire);
+ }
+ float final_color[4] = {color[0], color[1], color[2], 1.0f};
+ float final_bonemat[4][4];
mul_m4_m4m4(final_bonemat, g_data.ob->obmat, bone_mat);
- copy_v3_v3(final_color, color);
- final_color[3] = 1.0f; /* hack */
DRW_shgroup_call_dynamic_add(shgrp_geom_wire, final_bonemat, final_color);
}
}
@@ -1156,8 +1185,8 @@ static void draw_bone_update_disp_matrix_bbone(EditBone *eBone, bPoseChannel *pc
size_to_mat4(s, (const float[3]){xwidth, length / bbone_segments, zwidth});
/* Compute BBones segment matrices... */
- /* Note that we need this even for one-segment bones, because box drawing need specific weirdo matrix for the box,
- * that we cannot use to draw end points & co. */
+ /* Note that we need this even for one-segment bones, because box drawing need specific weirdo
+ * matrix for the box, that we cannot use to draw end points & co. */
if (pchan) {
Mat4 *bbones_mat = (Mat4 *)pchan->draw_data->bbone_matrix;
if (bbone_segments > 1) {
@@ -1768,7 +1797,8 @@ static void draw_bone_relations(EditBone *ebone,
}
else if (pchan && pchan->parent) {
if (do_relations) {
- /* Only draw if bone or its parent is selected - reduces viewport complexity with complex rigs */
+ /* Only draw if bone or its parent is selected - reduces viewport complexity with complex
+ * rigs */
if ((boneflag & BONE_SELECTED) ||
(pchan->parent->bone && (pchan->parent->bone->flag & BONE_SELECTED))) {
if ((boneflag & BONE_CONNECTED) == 0) {
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 8a13d8be622..08cf56982ea 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -3017,7 +3017,8 @@ GPUBatch *DRW_cache_bone_dof_lines_get(void)
* We could make these more generic functions.
* although filling 1d lines is not common.
*
- * \note Use x coordinate to identify the vertex the vertex shader take care to place it appropriately.
+ * \note Use x coordinate to identify the vertex the vertex shader take care to place it
+ * appropriately.
*/
static const float camera_coords_frame_bounds[5] = {
@@ -3283,12 +3284,10 @@ GPUBatch *DRW_cache_mesh_face_wireframe_get(Object *ob)
return DRW_mesh_batch_cache_get_wireframes_face(ob->data);
}
-void DRW_cache_mesh_sculpt_coords_ensure(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_mesh_analysis_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
-
- Mesh *me = ob->data;
- DRW_mesh_cache_sculpt_coords_ensure(me);
+ return DRW_mesh_batch_cache_get_edit_mesh_analysis(ob->data);
}
/** \} */
@@ -3302,7 +3301,13 @@ GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob)
BLI_assert(ob->type == OB_CURVE);
struct Curve *cu = ob->data;
- return DRW_curve_batch_cache_get_wire_edge(cu);
+ struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ if (mesh_eval != NULL) {
+ return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
+ }
+ else {
+ return DRW_curve_batch_cache_get_wire_edge(cu);
+ }
}
GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob)
@@ -3448,7 +3453,13 @@ GPUBatch *DRW_cache_text_edge_wire_get(Object *ob)
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
- return DRW_curve_batch_cache_get_wire_edge(cu);
+ struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ if (mesh_eval != NULL) {
+ return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
+ }
+ else {
+ return DRW_curve_batch_cache_get_wire_edge(cu);
+ }
}
GPUBatch *DRW_cache_text_surface_get(Object *ob)
@@ -3560,7 +3571,13 @@ GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob)
BLI_assert(ob->type == OB_SURF);
struct Curve *cu = ob->data;
- return DRW_curve_batch_cache_get_wire_edge(cu);
+ struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ if (mesh_eval != NULL) {
+ return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
+ }
+ else {
+ return DRW_curve_batch_cache_get_wire_edge(cu);
+ }
}
GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob)
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index c9ae0a01cb9..129b180957a 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -140,6 +140,7 @@ struct GPUBatch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_surface_vertpaint_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_surface_weights_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_surface_mesh_analysis_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_face_wireframe_get(struct Object *ob);
void DRW_cache_mesh_sculpt_coords_ensure(struct Object *ob);
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index e4ce3ed9d49..508ae678778 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -157,8 +157,7 @@ struct GPUBatch *DRW_mesh_batch_cache_get_edituv_verts(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_edituv_facedots(struct Mesh *me);
/* For Image UV editor. */
struct GPUBatch *DRW_mesh_batch_cache_get_uv_edges(struct Mesh *me);
-
-void DRW_mesh_cache_sculpt_coords_ensure(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_edit_mesh_analysis(struct Mesh *me);
/* Edit mesh bitflags (is this the right place?) */
enum {
@@ -204,10 +203,19 @@ struct GPUBatch *DRW_particles_batch_cache_get_edit_tip_points(struct Object *ob
struct PTCacheEdit *edit);
/* Common */
-#define DRW_ADD_FLAG_FROM_VBO_REQUEST(flag, vbo, value) \
- (flag |= DRW_vbo_requested(vbo) ? (value) : 0)
-#define DRW_ADD_FLAG_FROM_IBO_REQUEST(flag, ibo, value) \
- (flag |= DRW_ibo_requested(ibo) ? (value) : 0)
+// #define DRW_DEBUG_MESH_CACHE_REQUEST
+
+#ifdef DRW_DEBUG_MESH_CACHE_REQUEST
+# define DRW_ADD_FLAG_FROM_VBO_REQUEST(flag, vbo, value) \
+ (flag |= DRW_vbo_requested(vbo) ? (printf(" VBO requested " #vbo "\n") ? value : value) : 0)
+# define DRW_ADD_FLAG_FROM_IBO_REQUEST(flag, ibo, value) \
+ (flag |= DRW_ibo_requested(ibo) ? (printf(" IBO requested " #ibo "\n") ? value : value) : 0)
+#else
+# define DRW_ADD_FLAG_FROM_VBO_REQUEST(flag, vbo, value) \
+ (flag |= DRW_vbo_requested(vbo) ? (value) : 0)
+# define DRW_ADD_FLAG_FROM_IBO_REQUEST(flag, ibo, value) \
+ (flag |= DRW_ibo_requested(ibo) ? (value) : 0)
+#endif
/* Test and assign NULL if test fails */
#define DRW_TEST_ASSIGN_VBO(v) (v = (DRW_vbo_requested(v) ? (v) : NULL))
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index 8e7a2253e21..33b872109a5 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -988,6 +988,10 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
}
}
+#ifdef DRW_DEBUG_MESH_CACHE_REQUEST
+ printf("-- %s %s --\n", __func__, ob->id.name + 2);
+#endif
+
/* Generate MeshRenderData flags */
int mr_flag = 0;
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.pos_nor, CU_DATATYPE_SURFACE);
@@ -1011,6 +1015,10 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->surf_per_mat_tris[i], CU_DATATYPE_SURFACE);
}
+#ifdef DRW_DEBUG_MESH_CACHE_REQUEST
+ printf(" mr_flag %d\n\n", mr_flag);
+#endif
+
CurveRenderData *rdata = curve_render_data_create(cu, ob->runtime.curve_cache, mr_flag);
/* DispLists */
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index dcc249e90cf..f3b7e7adff0 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -304,7 +304,7 @@ typedef struct MeshRenderData {
bool *edge_visible_bool;
} MeshRenderData;
-enum {
+typedef enum eMRDataType {
MR_DATATYPE_VERT = 1 << 0,
MR_DATATYPE_EDGE = 1 << 1,
MR_DATATYPE_LOOPTRI = 1 << 2,
@@ -317,11 +317,16 @@ enum {
MR_DATATYPE_LOOPUV = 1 << 9,
MR_DATATYPE_LOOSE_VERT = 1 << 10,
MR_DATATYPE_LOOSE_EDGE = 1 << 11,
-};
+ MR_DATATYPE_LOOP_NORMALS = 1 << 12,
+} eMRDataType;
+
+#define MR_DATATYPE_VERT_LOOP_POLY (MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP)
+#define MR_DATATYPE_VERT_LOOP_TRI_POLY (MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_LOOPTRI)
+#define MR_DATATYPE_LOOSE_VERT_EGDE (MR_DATATYPE_LOOSE_VERT | MR_DATATYPE_LOOSE_EDGE)
/**
- * These functions look like they would be slow but they will typically return true on the first iteration.
- * Only false when all attached elements are hidden.
+ * These functions look like they would be slow but they will typically return true on the first
+ * iteration. Only false when all attached elements are hidden.
*/
static bool bm_vert_has_visible_edge(const BMVert *v)
{
@@ -675,9 +680,17 @@ static MeshRenderData *mesh_render_data_create_ex(Mesh *me,
bm_ensure_types |= BM_LOOP;
}
if (types & MR_DATATYPE_LOOP) {
- int totloop = bm->totloop;
+ rdata->loop_len = bm->totloop;
+ bm_ensure_types |= BM_LOOP;
+ }
+ if (types & MR_DATATYPE_POLY) {
+ rdata->poly_len = bm->totface;
+ bm_ensure_types |= BM_FACE;
+ }
+ if (types & MR_DATATYPE_LOOP_NORMALS) {
+ BLI_assert(types & MR_DATATYPE_LOOP);
if (is_auto_smooth) {
- rdata->loop_normals = MEM_mallocN(sizeof(*rdata->loop_normals) * totloop, __func__);
+ rdata->loop_normals = MEM_mallocN(sizeof(*rdata->loop_normals) * bm->totloop, __func__);
int cd_loop_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
BM_loops_calc_normal_vcos(bm,
NULL,
@@ -691,12 +704,6 @@ static MeshRenderData *mesh_render_data_create_ex(Mesh *me,
cd_loop_clnors_offset,
false);
}
- rdata->loop_len = totloop;
- bm_ensure_types |= BM_LOOP;
- }
- if (types & MR_DATATYPE_POLY) {
- rdata->poly_len = bm->totface;
- bm_ensure_types |= BM_FACE;
}
if (types & MR_DATATYPE_OVERLAY) {
rdata->efa_act_uv = EDBM_uv_active_face_get(embm, false, false);
@@ -833,7 +840,9 @@ static MeshRenderData *mesh_render_data_create_ex(Mesh *me,
if (types & MR_DATATYPE_LOOP) {
rdata->loop_len = me->totloop;
rdata->mloop = CustomData_get_layer(&me->ldata, CD_MLOOP);
-
+ }
+ if (types & MR_DATATYPE_LOOP_NORMALS) {
+ BLI_assert(types & MR_DATATYPE_LOOP);
if (is_auto_smooth) {
mesh_render_calc_normals_loop_and_poly(me, split_angle, rdata);
}
@@ -1150,7 +1159,8 @@ static MeshRenderData *mesh_render_data_create_ex(Mesh *me,
/* note: BKE_editmesh_loop_tangent_calc calculates 'CD_TANGENT',
* not 'CD_MLOOPTANGENT' (as done below). It's OK, they're compatible. */
- /* note: normally we'd use 'i_src' here, but 'i_dst' is in sync with 'rdata->cd.output' */
+ /* note: normally we'd use 'i_src' here, but 'i_dst' is in sync with 'rdata->cd.output'
+ */
rdata->cd.layers.tangent[i_dst] = CustomData_get_layer_n(
&rdata->cd.output.ldata, CD_TANGENT, i_dst);
if (rdata->tri_len != 0) {
@@ -1349,10 +1359,6 @@ static int mesh_render_data_polys_len_get_maybe_mapped(const MeshRenderData *rda
/* ---------------------------------------------------------------------- */
-/* TODO remove prototype. */
-static void mesh_create_edit_facedots(MeshRenderData *rdata,
- GPUVertBuf *vbo_facedots_pos_nor_data);
-
/** \name Internal Cache (Lazy Initialization)
* \{ */
@@ -1911,6 +1917,7 @@ typedef struct MeshBatchCache {
GPUVertBuf *loop_data;
GPUVertBuf *loop_lnor;
GPUVertBuf *facedots_pos_nor_data;
+ GPUVertBuf *loop_mesh_analysis;
/* UV data without modifier applied.
* Vertex count is always the one of the cage. */
GPUVertBuf *loop_uv;
@@ -1958,6 +1965,7 @@ typedef struct MeshBatchCache {
GPUBatch *edit_edges;
GPUBatch *edit_lnor;
GPUBatch *edit_facedots;
+ GPUBatch *edit_mesh_analysis;
/* Edit UVs */
GPUBatch *edituv_faces_strech_area;
GPUBatch *edituv_faces_strech_angle;
@@ -2169,8 +2177,13 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode)
GPU_BATCH_DISCARD_SAFE(cache->batch.edit_vertices);
GPU_BATCH_DISCARD_SAFE(cache->batch.edit_edges);
GPU_BATCH_DISCARD_SAFE(cache->batch.edit_facedots);
- /* Paint mode selection */
- /* TODO only do that in paint mode. */
+ GPU_BATCH_DISCARD_SAFE(cache->batch.edit_mesh_analysis);
+ /* Because visible UVs depends on edit mode selection, discard everything. */
+ mesh_batch_cache_discard_uvedit(cache);
+ break;
+ case BKE_MESH_BATCH_DIRTY_SELECT_PAINT:
+ /* Paint mode selection flag is packed inside the nor attrib.
+ * Note that it can be slow if auto smooth is enabled. (see T63946) */
GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_pos_nor);
GPU_BATCH_DISCARD_SAFE(cache->batch.surface);
GPU_BATCH_DISCARD_SAFE(cache->batch.wire_loops);
@@ -2179,8 +2192,6 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode)
GPU_BATCH_DISCARD_SAFE(cache->surf_per_mat[i]);
}
}
- /* Because visible UVs depends on edit mode selection, discard everything. */
- mesh_batch_cache_discard_uvedit(cache);
break;
case BKE_MESH_BATCH_DIRTY_ALL:
cache->is_dirty = true;
@@ -3383,6 +3394,71 @@ static void mesh_create_edit_facedots(MeshRenderData *rdata, GPUVertBuf *vbo_fac
}
}
+static void mesh_create_edit_mesh_analysis(MeshRenderData *rdata, GPUVertBuf *vbo_mesh_analysis)
+{
+ const MeshStatVis *mesh_stat_vis = &rdata->toolsettings->statvis;
+
+ int mesh_analysis_len_used = 0;
+
+ const uint loops_len = mesh_render_data_loops_len_get(rdata);
+ BMesh *bm = rdata->edit_bmesh->bm;
+ BMIter iter_efa, iter_loop;
+ BMFace *efa;
+ BMLoop *loop;
+
+ static struct {
+ uint weight;
+ } attr_id;
+ static GPUVertFormat mesh_analysis_format = {0};
+ if (mesh_analysis_format.attr_len == 0) {
+ attr_id.weight = GPU_vertformat_attr_add(
+ &mesh_analysis_format, "weight_color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ }
+
+ /* TODO(jbakker): Maybe move data generation to mesh_render_data_create() */
+ BKE_editmesh_statvis_calc(rdata->edit_bmesh, rdata->edit_data, mesh_stat_vis);
+
+ if (DRW_TEST_ASSIGN_VBO(vbo_mesh_analysis)) {
+ GPU_vertbuf_init_with_format(vbo_mesh_analysis, &mesh_analysis_format);
+ GPU_vertbuf_data_alloc(vbo_mesh_analysis, loops_len);
+ }
+
+ const bool is_vertex_data = mesh_stat_vis->type == SCE_STATVIS_SHARP;
+ if (is_vertex_data) {
+ BM_ITER_MESH (efa, &iter_efa, bm, BM_FACES_OF_MESH) {
+ BM_ITER_ELEM (loop, &iter_loop, efa, BM_LOOPS_OF_FACE) {
+ uint vertex_index = BM_elem_index_get(loop->v);
+ GPU_vertbuf_attr_set(vbo_mesh_analysis,
+ attr_id.weight,
+ mesh_analysis_len_used,
+ &rdata->edit_bmesh->derivedVertColor[vertex_index]);
+ mesh_analysis_len_used += 1;
+ }
+ }
+ }
+ else {
+ uint face_index;
+ BM_ITER_MESH_INDEX (efa, &iter_efa, bm, BM_FACES_OF_MESH, face_index) {
+ BM_ITER_ELEM (loop, &iter_loop, efa, BM_LOOPS_OF_FACE) {
+ GPU_vertbuf_attr_set(vbo_mesh_analysis,
+ attr_id.weight,
+ mesh_analysis_len_used,
+ &rdata->edit_bmesh->derivedFaceColor[face_index]);
+ mesh_analysis_len_used += 1;
+ }
+ }
+ }
+
+ // Free temp data in edit bmesh
+ BKE_editmesh_color_free(rdata->edit_bmesh);
+
+ /* Resize & Finish */
+ if (mesh_analysis_len_used != loops_len) {
+ if (vbo_mesh_analysis != NULL) {
+ GPU_vertbuf_data_resize(vbo_mesh_analysis, mesh_analysis_len_used);
+ }
+ }
+}
/* Indices */
#define NO_EDGE INT_MAX
@@ -4195,6 +4271,12 @@ GPUBatch *DRW_mesh_batch_cache_get_wireframes_face(Mesh *me)
return DRW_batch_request(&cache->batch.wire_edges);
}
+GPUBatch *DRW_mesh_batch_cache_get_edit_mesh_analysis(Mesh *me)
+{
+ MeshBatchCache *cache = mesh_batch_cache_get(me);
+ return DRW_batch_request(&cache->batch.edit_mesh_analysis);
+}
+
GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(Mesh *me,
struct GPUMaterial **gpumat_array,
uint gpumat_array_len,
@@ -4373,25 +4455,6 @@ GPUBatch *DRW_mesh_batch_cache_get_surface_edges(Mesh *me)
return DRW_batch_request(&cache->batch.wire_loops);
}
-/**
- * Needed for when we draw with shaded data.
- */
-void DRW_mesh_cache_sculpt_coords_ensure(Mesh *UNUSED(me))
-{
-#if 0 /* Unused for now */
- if (me->runtime.batch_cache) {
- MeshBatchCache *cache = mesh_batch_cache_get(me);
- if (cache && cache->pos_with_normals && cache->is_sculpt_points_tag) {
- /* XXX Force update of all the batches that contains the pos_with_normals buffer.
- * TODO(fclem): Ideally, Gawain should provide a way to update a buffer without destroying it. */
- mesh_batch_cache_clear_selective(me, cache->pos_with_normals);
- GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals);
- }
- cache->is_sculpt_points_tag = false;
- }
-#endif
-}
-
/* Compute 3D & 2D areas and their sum. */
BLI_INLINE void edit_uv_preprocess_stretch_area(BMFace *efa,
const int cd_loop_uv_offset,
@@ -4520,11 +4583,21 @@ static void uvedit_fill_buffer_data(MeshRenderData *rdata,
}
/* Skip hidden faces. */
- if (elb_face && face_visible) {
- for (i = 0; i < efa->len; ++i) {
- GPU_indexbuf_add_generic_vert(elb_face, vidx + i);
- GPU_indexbuf_add_generic_vert(elb_vert, vidx + i);
- GPU_indexbuf_add_line_verts(elb_edge, vidx + i, vidx + (i + 1) % efa->len);
+ if (face_visible) {
+ if (elb_face) {
+ for (i = 0; i < efa->len; ++i) {
+ GPU_indexbuf_add_generic_vert(elb_face, vidx + i);
+ }
+ }
+ if (elb_vert) {
+ for (i = 0; i < efa->len; ++i) {
+ GPU_indexbuf_add_generic_vert(elb_vert, vidx + i);
+ }
+ }
+ if (elb_edge) {
+ for (i = 0; i < efa->len; ++i) {
+ GPU_indexbuf_add_line_verts(elb_edge, vidx + i, vidx + (i + 1) % efa->len);
+ }
}
}
@@ -4588,18 +4661,24 @@ static void uvedit_fill_buffer_data(MeshRenderData *rdata,
GPU_vertbuf_attr_set(vbo_fdots_data, uv_attr_id.fdots_flag, fdot_idx, &face_flag);
}
/* Skip hidden faces. */
- if (elb_face && face_visible) {
- for (i = 0; i < mpoly->totloop; ++i) {
- GPU_indexbuf_add_generic_vert(elb_face, vidx + i);
- if (e_origindex[l[i].e] != ORIGINDEX_NONE) {
+ if (face_visible) {
+ if (elb_face) {
+ for (i = 0; i < mpoly->totloop; ++i) {
+ GPU_indexbuf_add_generic_vert(elb_face, vidx + i);
+ }
+ GPU_indexbuf_add_generic_vert(elb_face, vidx);
+ GPU_indexbuf_add_primitive_restart(elb_face);
+ }
+ if (elb_edge && e_origindex[l[i].e] != ORIGINDEX_NONE) {
+ for (i = 0; i < mpoly->totloop; ++i) {
GPU_indexbuf_add_line_verts(elb_edge, vidx + i, vidx + (i + 1) % mpoly->totloop);
}
- if (v_origindex[l[i].v] != ORIGINDEX_NONE) {
+ }
+ if (elb_vert && v_origindex[l[i].v] != ORIGINDEX_NONE) {
+ for (i = 0; i < mpoly->totloop; ++i) {
GPU_indexbuf_add_generic_vert(elb_vert, vidx + i);
}
}
- GPU_indexbuf_add_generic_vert(elb_face, vidx);
- GPU_indexbuf_add_primitive_restart(elb_face);
}
for (i = 0; i < mpoly->totloop; i++, l++) {
/* TODO support stretch. */
@@ -4824,8 +4903,10 @@ void DRW_mesh_batch_cache_create_requested(
}
}
+ bool has_request = false;
/* Init batches and request VBOs & IBOs */
if (DRW_batch_requested(cache->batch.surface, GPU_PRIM_TRIS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.surface, &cache->ibo.loops_tris);
DRW_vbo_request(cache->batch.surface, &cache->ordered.loop_pos_nor);
/* For paint overlay. Active layer should have been queried. */
@@ -4837,35 +4918,43 @@ void DRW_mesh_batch_cache_create_requested(
}
}
if (DRW_batch_requested(cache->batch.all_verts, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_vbo_request(cache->batch.all_verts, &cache->ordered.pos_nor);
}
if (DRW_batch_requested(cache->batch.all_edges, GPU_PRIM_LINES)) {
+ has_request = true;
DRW_ibo_request(cache->batch.all_edges, &cache->ibo.edges_lines);
DRW_vbo_request(cache->batch.all_edges, &cache->ordered.pos_nor);
}
if (DRW_batch_requested(cache->batch.loose_edges, GPU_PRIM_LINES)) {
+ has_request = true;
DRW_ibo_request(cache->batch.loose_edges, &cache->ibo.loose_edges_lines);
DRW_vbo_request(cache->batch.loose_edges, &cache->ordered.pos_nor);
}
if (DRW_batch_requested(cache->batch.edge_detection, GPU_PRIM_LINES_ADJ)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edge_detection, &cache->ibo.edges_adj_lines);
DRW_vbo_request(cache->batch.edge_detection, &cache->ordered.pos_nor);
}
if (DRW_batch_requested(cache->batch.surface_weights, GPU_PRIM_TRIS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.surface_weights, &cache->ibo.surf_tris);
DRW_vbo_request(cache->batch.surface_weights, &cache->ordered.pos_nor);
DRW_vbo_request(cache->batch.surface_weights, &cache->ordered.weights);
}
if (DRW_batch_requested(cache->batch.wire_loops, GPU_PRIM_LINE_STRIP)) {
+ has_request = true;
DRW_ibo_request(cache->batch.wire_loops, &cache->ibo.loops_line_strips);
DRW_vbo_request(cache->batch.wire_loops, &cache->ordered.loop_pos_nor);
}
if (DRW_batch_requested(cache->batch.wire_edges, GPU_PRIM_LINES)) {
+ has_request = true;
DRW_ibo_request(cache->batch.wire_edges, &cache->ibo.loops_lines);
DRW_vbo_request(cache->batch.wire_edges, &cache->ordered.loop_pos_nor);
DRW_vbo_request(cache->batch.wire_edges, &cache->ordered.loop_edge_fac);
}
if (DRW_batch_requested(cache->batch.wire_loops_uvs, GPU_PRIM_LINE_STRIP)) {
+ has_request = true;
DRW_ibo_request(cache->batch.wire_loops_uvs, &cache->ibo.loops_line_strips);
/* For paint overlay. Active layer should have been queried. */
if (cache->cd_used.uv != 0) {
@@ -4875,58 +4964,77 @@ void DRW_mesh_batch_cache_create_requested(
/* Edit Mesh */
if (DRW_batch_requested(cache->batch.edit_triangles, GPU_PRIM_TRIS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_triangles, &cache->ibo.edit_loops_tris);
DRW_vbo_request(cache->batch.edit_triangles, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_triangles, &cache->edit.loop_data);
}
if (DRW_batch_requested(cache->batch.edit_vertices, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_vertices, &cache->ibo.edit_loops_points);
DRW_vbo_request(cache->batch.edit_vertices, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_vertices, &cache->edit.loop_data);
}
if (DRW_batch_requested(cache->batch.edit_edges, GPU_PRIM_LINES)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_edges, &cache->ibo.edit_loops_lines);
DRW_vbo_request(cache->batch.edit_edges, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_edges, &cache->edit.loop_data);
}
if (DRW_batch_requested(cache->batch.edit_lnor, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_lnor, &cache->ibo.edit_loops_tris);
DRW_vbo_request(cache->batch.edit_lnor, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_lnor, &cache->edit.loop_lnor);
}
if (DRW_batch_requested(cache->batch.edit_facedots, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_vbo_request(cache->batch.edit_facedots, &cache->edit.facedots_pos_nor_data);
}
+ /* Mesh Analysis */
+ if (DRW_batch_requested(cache->batch.edit_mesh_analysis, GPU_PRIM_TRIS)) {
+ has_request = true;
+ DRW_ibo_request(cache->batch.edit_mesh_analysis, &cache->ibo.edit_loops_tris);
+ DRW_vbo_request(cache->batch.edit_mesh_analysis, &cache->edit.loop_pos_nor);
+ DRW_vbo_request(cache->batch.edit_mesh_analysis, &cache->edit.loop_mesh_analysis);
+ }
+
/* Edit UV */
if (DRW_batch_requested(cache->batch.edituv_faces, GPU_PRIM_TRI_FAN)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edituv_faces, &cache->ibo.edituv_loops_tri_fans);
DRW_vbo_request(cache->batch.edituv_faces, &cache->edit.loop_uv);
DRW_vbo_request(cache->batch.edituv_faces, &cache->edit.loop_uv_data);
}
if (DRW_batch_requested(cache->batch.edituv_faces_strech_area, GPU_PRIM_TRI_FAN)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edituv_faces_strech_area, &cache->ibo.edituv_loops_tri_fans);
DRW_vbo_request(cache->batch.edituv_faces_strech_area, &cache->edit.loop_uv);
DRW_vbo_request(cache->batch.edituv_faces_strech_area, &cache->edit.loop_uv_data);
DRW_vbo_request(cache->batch.edituv_faces_strech_area, &cache->edit.loop_stretch_area);
}
if (DRW_batch_requested(cache->batch.edituv_faces_strech_angle, GPU_PRIM_TRI_FAN)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edituv_faces_strech_angle, &cache->ibo.edituv_loops_tri_fans);
DRW_vbo_request(cache->batch.edituv_faces_strech_angle, &cache->edit.loop_uv);
DRW_vbo_request(cache->batch.edituv_faces_strech_angle, &cache->edit.loop_uv_data);
DRW_vbo_request(cache->batch.edituv_faces_strech_angle, &cache->edit.loop_stretch_angle);
}
if (DRW_batch_requested(cache->batch.edituv_edges, GPU_PRIM_LINES)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edituv_edges, &cache->ibo.edituv_loops_line_strips);
DRW_vbo_request(cache->batch.edituv_edges, &cache->edit.loop_uv);
DRW_vbo_request(cache->batch.edituv_edges, &cache->edit.loop_uv_data);
}
if (DRW_batch_requested(cache->batch.edituv_verts, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edituv_verts, &cache->ibo.edituv_loops_points);
DRW_vbo_request(cache->batch.edituv_verts, &cache->edit.loop_uv);
DRW_vbo_request(cache->batch.edituv_verts, &cache->edit.loop_uv_data);
}
if (DRW_batch_requested(cache->batch.edituv_facedots, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_vbo_request(cache->batch.edituv_facedots, &cache->edit.facedots_uv);
DRW_vbo_request(cache->batch.edituv_facedots, &cache->edit.facedots_uv_data);
}
@@ -4934,21 +5042,25 @@ void DRW_mesh_batch_cache_create_requested(
/* Selection */
/* TODO reuse ordered.loop_pos_nor if possible. */
if (DRW_batch_requested(cache->batch.edit_selection_verts, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_selection_verts, &cache->ibo.edit_loops_points);
DRW_vbo_request(cache->batch.edit_selection_verts, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_selection_verts, &cache->edit.loop_vert_idx);
}
if (DRW_batch_requested(cache->batch.edit_selection_edges, GPU_PRIM_LINES)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_selection_edges, &cache->ibo.edit_loops_lines);
DRW_vbo_request(cache->batch.edit_selection_edges, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_selection_edges, &cache->edit.loop_edge_idx);
}
if (DRW_batch_requested(cache->batch.edit_selection_faces, GPU_PRIM_TRIS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_selection_faces, &cache->ibo.edit_loops_tris);
DRW_vbo_request(cache->batch.edit_selection_faces, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_selection_faces, &cache->edit.loop_face_idx);
}
if (DRW_batch_requested(cache->batch.edit_selection_facedots, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_vbo_request(cache->batch.edit_selection_facedots, &cache->edit.facedots_pos_nor_data);
DRW_vbo_request(cache->batch.edit_selection_facedots, &cache->edit.facedots_idx);
}
@@ -4956,6 +5068,7 @@ void DRW_mesh_batch_cache_create_requested(
/* Per Material */
for (int i = 0; i < cache->mat_len; ++i) {
if (DRW_batch_requested(cache->surf_per_mat[i], GPU_PRIM_TRIS)) {
+ has_request = true;
if (cache->mat_len > 1) {
DRW_ibo_request(cache->surf_per_mat[i], &cache->surf_per_mat_tris[i]);
}
@@ -4976,34 +5089,34 @@ void DRW_mesh_batch_cache_create_requested(
}
}
+ /* Early out if no request. */
+ if (!has_request) {
+ return;
+ }
+
+#ifdef DRW_DEBUG_MESH_CACHE_REQUEST
+ printf("-- %s %s --\n", __func__, ob->id.name + 2);
+#endif
+
/* Generate MeshRenderData flags */
- int mr_flag = 0, mr_edit_flag = 0;
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.pos_nor, MR_DATATYPE_VERT);
+ eMRDataType mr_flag = 0, mr_edit_flag = 0;
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_flag, cache->ordered.pos_nor, MR_DATATYPE_VERT /* A comment to wrap the line ;) */);
DRW_ADD_FLAG_FROM_VBO_REQUEST(
mr_flag, cache->ordered.weights, MR_DATATYPE_VERT | MR_DATATYPE_DVERT);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag,
- cache->ordered.loop_pos_nor,
- MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag,
- cache->ordered.loop_uv_tan,
- MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP |
- MR_DATATYPE_SHADING | MR_DATATYPE_LOOPTRI);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag,
- cache->ordered.loop_orco,
- MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP |
- MR_DATATYPE_SHADING);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag,
- cache->ordered.loop_vcol,
- MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP |
- MR_DATATYPE_SHADING);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag,
- cache->ordered.loop_edge_fac,
- MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_EDGE |
- MR_DATATYPE_LOOP);
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag,
- cache->ibo.surf_tris,
- MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY |
- MR_DATATYPE_LOOPTRI);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_flag, cache->ordered.loop_pos_nor, MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_LOOP_NORMALS);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_flag, cache->ordered.loop_uv_tan, MR_DATATYPE_VERT_LOOP_TRI_POLY | MR_DATATYPE_SHADING);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_flag, cache->ordered.loop_orco, MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_SHADING);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_flag, cache->ordered.loop_vcol, MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_SHADING);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_flag, cache->ordered.loop_edge_fac, MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_EDGE);
+
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(
+ mr_flag, cache->ibo.surf_tris, MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_LOOPTRI);
DRW_ADD_FLAG_FROM_IBO_REQUEST(
mr_flag, cache->ibo.loops_tris, MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI);
DRW_ADD_FLAG_FROM_IBO_REQUEST(
@@ -5012,74 +5125,69 @@ void DRW_mesh_batch_cache_create_requested(
mr_flag, cache->ibo.loops_line_strips, MR_DATATYPE_LOOP | MR_DATATYPE_POLY);
DRW_ADD_FLAG_FROM_IBO_REQUEST(
mr_flag, cache->ibo.edges_lines, MR_DATATYPE_VERT | MR_DATATYPE_EDGE);
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag,
- cache->ibo.edges_adj_lines,
- MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY |
- MR_DATATYPE_LOOPTRI);
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(
+ mr_flag, cache->ibo.edges_adj_lines, MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_LOOPTRI);
DRW_ADD_FLAG_FROM_IBO_REQUEST(
mr_flag, cache->ibo.loose_edges_lines, MR_DATATYPE_VERT | MR_DATATYPE_EDGE);
for (int i = 0; i < cache->mat_len; ++i) {
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag,
- cache->surf_per_mat_tris[i],
- MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI);
- }
-
- int combined_edit_flag = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP |
- MR_DATATYPE_POLY | MR_DATATYPE_LOOSE_VERT | MR_DATATYPE_LOOSE_EDGE |
- MR_DATATYPE_OVERLAY;
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_pos_nor, combined_edit_flag);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_lnor, combined_edit_flag);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_data, combined_edit_flag);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_uv_data, combined_edit_flag);
+ int combined_flag = MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI;
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->surf_per_mat_tris[i], combined_flag);
+ }
+
+ int combined_edit_flag = MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_EDGE |
+ MR_DATATYPE_LOOSE_VERT_EGDE;
+ int combined_edit_with_lnor_flag = combined_edit_flag | MR_DATATYPE_LOOP_NORMALS;
+ int combined_edituv_flag = combined_edit_flag | MR_DATATYPE_LOOPUV;
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_pos_nor, combined_edit_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_lnor, combined_edit_with_lnor_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_data, combined_edit_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_uv_data, combined_edit_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_uv, combined_edituv_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_stretch_angle, combined_edit_flag | MR_DATATYPE_OVERLAY);
DRW_ADD_FLAG_FROM_VBO_REQUEST(
- mr_edit_flag, cache->edit.loop_uv, combined_edit_flag | MR_DATATYPE_LOOPUV);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag,
- cache->edit.loop_vert_idx,
- MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOSE_VERT |
- MR_DATATYPE_LOOSE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag,
- cache->edit.loop_edge_idx,
- MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOSE_VERT |
- MR_DATATYPE_LOOSE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag,
- cache->edit.loop_face_idx,
- MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOSE_VERT |
- MR_DATATYPE_LOOSE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP);
+ mr_edit_flag, cache->edit.loop_stretch_area, combined_edit_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_mesh_analysis, MR_DATATYPE_VERT_LOOP_POLY);
+
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_vert_idx, combined_edit_flag);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_edge_idx, combined_edit_flag);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_face_idx, combined_edit_flag);
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.facedots_idx, MR_DATATYPE_POLY);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag,
- cache->edit.facedots_pos_nor_data,
- MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY |
- MR_DATATYPE_OVERLAY);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_stretch_angle, combined_edit_flag);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_stretch_area, combined_edit_flag);
+
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.facedots_pos_nor_data, MR_DATATYPE_POLY | MR_DATATYPE_OVERLAY);
DRW_ADD_FLAG_FROM_VBO_REQUEST(
- mr_edit_flag, cache->edit.facedots_uv, combined_edit_flag | MR_DATATYPE_LOOPUV);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.facedots_uv_data, combined_edit_flag);
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_edit_flag, cache->ibo.edituv_loops_points, combined_edit_flag);
+ mr_edit_flag, cache->edit.facedots_uv, combined_edituv_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.facedots_uv_data, combined_edit_flag | MR_DATATYPE_OVERLAY);
+
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(
+ mr_edit_flag, cache->ibo.edituv_loops_points, combined_edit_flag | MR_DATATYPE_OVERLAY);
DRW_ADD_FLAG_FROM_IBO_REQUEST(
- mr_edit_flag, cache->ibo.edituv_loops_line_strips, combined_edit_flag);
+ mr_edit_flag, cache->ibo.edituv_loops_line_strips, combined_edit_flag | MR_DATATYPE_OVERLAY);
DRW_ADD_FLAG_FROM_IBO_REQUEST(
- mr_edit_flag, cache->ibo.edituv_loops_tri_fans, combined_edit_flag);
- /* TODO: Some of the flags here may not be needed. */
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_edit_flag,
- cache->ibo.edit_loops_points,
- MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOSE_VERT |
- MR_DATATYPE_LOOSE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP |
- MR_DATATYPE_LOOPTRI);
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_edit_flag,
- cache->ibo.edit_loops_lines,
- MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOSE_VERT |
- MR_DATATYPE_LOOSE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP |
- MR_DATATYPE_LOOPTRI);
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_edit_flag,
- cache->ibo.edit_loops_tris,
- MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOSE_VERT |
- MR_DATATYPE_LOOSE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP |
- MR_DATATYPE_LOOPTRI);
+ mr_edit_flag, cache->ibo.edituv_loops_tri_fans, combined_edit_flag | MR_DATATYPE_OVERLAY);
+
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(
+ mr_edit_flag, cache->ibo.edit_loops_points, combined_edit_flag | MR_DATATYPE_LOOPTRI);
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(
+ mr_edit_flag, cache->ibo.edit_loops_lines, combined_edit_flag | MR_DATATYPE_LOOPTRI);
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(
+ mr_edit_flag, cache->ibo.edit_loops_tris, combined_edit_flag | MR_DATATYPE_LOOPTRI);
Mesh *me_original = me;
MBC_GET_FINAL_MESH(me);
+#ifdef DRW_DEBUG_MESH_CACHE_REQUEST
+ printf(" mr_flag %u, mr_edit_flag %u\n\n", mr_flag, mr_edit_flag);
+#endif
+
if (me_original == me) {
mr_flag |= mr_edit_flag;
}
@@ -5177,6 +5285,9 @@ void DRW_mesh_batch_cache_create_requested(
if (DRW_ibo_requested(cache->ibo.edit_loops_tris)) {
mesh_create_edit_loops_tris(rdata, cache->ibo.edit_loops_tris);
}
+ if (DRW_vbo_requested(cache->edit.loop_mesh_analysis)) {
+ mesh_create_edit_mesh_analysis(rdata, cache->edit.loop_mesh_analysis);
+ }
/* UV editor */
/**
diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c
index 2c06d536f3d..432c5092274 100644
--- a/source/blender/draw/intern/draw_cache_impl_metaball.c
+++ b/source/blender/draw/intern/draw_cache_impl_metaball.c
@@ -265,4 +265,4 @@ struct GPUBatch *DRW_metaball_batch_cache_get_edge_detection(struct Object *ob,
}
return cache->edge_detection;
-} \ No newline at end of file
+}
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index e998b17a44f..9a15c51598f 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -99,7 +99,7 @@ typedef struct HairAttributeID {
typedef struct EditStrandData {
float pos[3];
- uchar color;
+ float color;
} EditStrandData;
static GPUVertFormat *edit_points_vert_format_get(uint *r_pos_id, uint *r_color_id)
@@ -110,7 +110,7 @@ static GPUVertFormat *edit_points_vert_format_get(uint *r_pos_id, uint *r_color_
/* 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);
+ &edit_point_format, "color", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
}
*r_pos_id = pos_id;
*r_color_id = color_id;
@@ -693,12 +693,12 @@ static int particle_batch_cache_fill_segments_edit(
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);
+ /* NaN or unclamped become 1.0f */
+ seg_data->color = (weight < 1.0f) ? weight : 1.0f;
}
else {
float selected = particle_key_select_ratio(edit, i, strand_t);
- seg_data->color = (uchar)(0xFF * selected);
+ seg_data->color = selected;
}
GPU_indexbuf_add_generic_vert(elb, curr_point);
curr_point++;
@@ -1565,7 +1565,7 @@ static void particle_batch_cache_ensure_edit_inner_pos(PTCacheEdit *edit,
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;
+ float color = (key->flag & PEK_SELECT) ? 1.0f : 0.0f;
GPU_vertbuf_attr_set(cache->edit_inner_pos, pos_id, global_key_index, key->world_co);
GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, &color);
global_key_index++;
@@ -1611,7 +1611,8 @@ static void particle_batch_cache_ensure_edit_tip_pos(PTCacheEdit *edit, Particle
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;
+ float color = (key->flag & PEK_SELECT) ? 1.0f : 0.0f;
+
GPU_vertbuf_attr_set(cache->edit_tip_pos, pos_id, point_index, key->world_co);
GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, &color);
}
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index 465a4f7a897..b4eb354ec59 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -90,8 +90,8 @@ void DRW_globals_update(void)
dot_v3v3(gb->colorEditMeshMiddle, (float[3]){0.3333f, 0.3333f, 0.3333f})); /* Desaturate */
interp_v4_v4v4(gb->colorDupliSelect, gb->colorBackground, gb->colorSelect, 0.5f);
- /* Was 50% in 2.7x since the background was lighter making it easier to tell the color from black,
- * with a darker background we need a more faded color. */
+ /* Was 50% in 2.7x since the background was lighter making it easier to tell the color from
+ * black, with a darker background we need a more faded color. */
interp_v4_v4v4(gb->colorDupli, gb->colorBackground, gb->colorWire, 0.3f);
#ifdef WITH_FREESTYLE
@@ -142,7 +142,7 @@ void DRW_globals_update(void)
UI_GetThemeColorShadeAlpha4fv(TH_WIRE, 0, -30, gb->colorOutline);
UI_GetThemeColorShadeAlpha4fv(TH_LIGHT, 0, 255, gb->colorLightNoAlpha);
- gb->sizeLightCenter = (U.obcenter_dia + 1.5f) * U.pixelsize;
+ gb->sizeLightCenter = (UI_GetThemeValuef(TH_OBCENTER_DIA) + 1.5f) * U.pixelsize;
gb->sizeLightCircle = U.pixelsize * 9.0f;
gb->sizeLightCircleShadow = gb->sizeLightCircle + U.pixelsize * 3.0f;
@@ -1045,7 +1045,7 @@ struct GPUShader *volume_velocity_shader_get(bool use_needle)
}
}
-/* ******************************************** COLOR UTILS *********************************************** */
+/* ******************************************** COLOR UTILS ************************************ */
/* TODO FINISH */
/**
diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
index db8f8d46e85..489bc7459df 100644
--- a/source/blender/draw/intern/draw_common.h
+++ b/source/blender/draw/intern/draw_common.h
@@ -216,6 +216,7 @@ typedef struct DRWArmaturePasses {
struct DRWPass *bone_envelope;
struct DRWPass *bone_axes;
struct DRWPass *relationship_lines;
+ struct GHash *custom_shapes;
} DRWArmaturePasses;
void DRW_shgroup_armature_object(struct Object *ob,
diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c
index b3081a44dfb..cb83265195a 100644
--- a/source/blender/draw/intern/draw_hair.c
+++ b/source/blender/draw/intern/draw_hair.c
@@ -193,7 +193,8 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(Object *object,
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);
- /* TODO(fclem): Until we have a better way to cull the hair and render with orco, bypass culling test. */
+ /* TODO(fclem): Until we have a better way to cull the hair and render with orco, bypass culling
+ * test. */
DRW_shgroup_call_object_add_no_cull(
shgrp, hair_cache->final[subdiv].proc_hairs[thickness_res - 1], object);
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c
index 27e03a3495a..e8d91309e06 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -22,11 +22,11 @@
/**
* DRW Instance Data Manager
- * This is a special memory manager that keeps memory blocks ready to send as vbo data in one continuous allocation.
- * This way we avoid feeding gawain each instance data one by one and unnecessary memcpy.
- * Since we loose which memory block was used each #DRWShadingGroup we need to redistribute them in the same order/size
- * to avoid to realloc each frame.
- * This is why #DRWInstanceDatas are sorted in a list for each different data size.
+ * This is a special memory manager that keeps memory blocks ready to send as vbo data in one
+ * continuous allocation. This way we avoid feeding gawain each instance data one by one and
+ * unnecessary memcpy. Since we loose which memory block was used each #DRWShadingGroup we need to
+ * redistribute them in the same order/size to avoid to realloc each frame. This is why
+ * #DRWInstanceDatas are sorted in a list for each different data size.
*/
#include "draw_instance_data.h"
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 881b0a8579d..3161528be79 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -40,6 +40,7 @@
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_particle.h"
+#include "BKE_paint.h"
#include "BKE_pointcache.h"
#include "draw_manager.h"
@@ -213,6 +214,11 @@ bool DRW_object_use_hide_faces(const struct Object *ob)
return false;
}
+bool DRW_object_use_pbvh_drawing(const struct Object *ob)
+{
+ return ob->sculpt && (ob->sculpt->mode_type == OB_MODE_SCULPT);
+}
+
bool DRW_object_is_visible_psys_in_active_context(const Object *object, const ParticleSystem *psys)
{
const bool for_render = DRW_state_is_image_render();
@@ -1137,9 +1143,8 @@ static void drw_engines_draw_background(void)
}
/* No draw_background found, doing default background */
- if (DRW_state_draw_background()) {
- DRW_draw_background();
- }
+ const bool do_alpha_checker = !DRW_state_draw_background();
+ DRW_draw_background(do_alpha_checker);
}
static void drw_engines_draw_scene(void)
@@ -1488,6 +1493,7 @@ void DRW_draw_view(const bContext *C)
drw_state_prepare_clean_for_draw(&DST);
DST.options.draw_text = ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0 &&
(v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) != 0);
+ DST.options.draw_background = scene->r.alphamode == R_ADDSKY;
DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, viewport, C);
}
@@ -1554,11 +1560,10 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph,
drw_engines_world_update(scene);
const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
- 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) {
+ const int iter_flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE |
+ DEG_ITER_OBJECT_FLAG_DUPLI;
+ DEG_OBJECT_ITER_BEGIN (depsgraph, ob, iter_flag) {
if ((object_type_exclude_viewport & (1 << ob->type)) != 0) {
continue;
}
@@ -2005,11 +2010,10 @@ void DRW_render_object_iter(
const int object_type_exclude_viewport = draw_ctx->v3d ?
draw_ctx->v3d->object_type_exclude_viewport :
0;
- 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) {
+ const int iter_flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE |
+ DEG_ITER_OBJECT_FLAG_DUPLI;
+ DEG_OBJECT_ITER_BEGIN (depsgraph, ob, iter_flag) {
if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
DST.dupli_parent = data_.dupli_parent;
DST.dupli_source = data_.dupli_object_current;
@@ -2259,14 +2263,13 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
# endif
}
else {
+ const int iter_flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE |
+ DEG_ITER_OBJECT_FLAG_DUPLI;
const int object_type_exclude_select = (v3d->object_type_exclude_viewport |
v3d->object_type_exclude_select);
bool filter_exclude = false;
- 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) {
+ DEG_OBJECT_ITER_BEGIN (depsgraph, ob, iter_flag) {
if (v3d->localvd && ((v3d->local_view_uuid & ob->base_local_view_bits) == 0)) {
continue;
}
@@ -2378,11 +2381,10 @@ static void drw_draw_depth_loop_imp(void)
View3D *v3d = DST.draw_ctx.v3d;
const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
- DEG_OBJECT_ITER_BEGIN (DST.draw_ctx.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) {
+ const int iter_flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE |
+ DEG_ITER_OBJECT_FLAG_DUPLI;
+ DEG_OBJECT_ITER_BEGIN (DST.draw_ctx.depsgraph, ob, iter_flag) {
if ((object_type_exclude_viewport & (1 << ob->type)) != 0) {
continue;
}
@@ -2735,9 +2737,6 @@ bool DRW_state_draw_support(void)
*/
bool DRW_state_draw_background(void)
{
- if (DRW_state_is_image_render() == false) {
- return true;
- }
return DST.options.draw_background;
}
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index a70438a2d37..77cf6d20117 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -142,8 +142,6 @@ typedef enum {
DRW_CALL_RANGE,
/** Draw instances without any instancing attributes. */
DRW_CALL_INSTANCES,
- /** Uses a callback to draw with any number of batches. */
- DRW_CALL_GENERATE,
/** Generate a drawcall without any #GPUBatch. */
DRW_CALL_PROCEDURAL,
} DRWCallType;
@@ -166,10 +164,6 @@ typedef struct DRWCall {
/* Count can be adjusted between redraw. If needed, we can add fixed count. */
uint *count;
} instances;
- struct { /* type == DRW_CALL_GENERATE */
- DRWCallGenerateFn *geometry_fn;
- void *user_data;
- } generate;
struct { /* type == DRW_CALL_PROCEDURAL */
uint vert_count;
GPUPrimType prim_type;
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index de3505b4ccd..8f324cf08cb 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -38,6 +38,8 @@
#include "BLI_link_utils.h"
#include "BLI_mempool.h"
+#include "GPU_buffers.h"
+
#include "intern/gpu_codegen.h"
struct GPUVertFormat *g_pos_format = NULL;
@@ -161,7 +163,8 @@ void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, con
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_TEXTURE, tex, 0, 1);
}
-/* Same as DRW_shgroup_uniform_texture but is guaranteed to be bound if shader does not change between shgrp. */
+/* Same as DRW_shgroup_uniform_texture but is guaranteed to be bound if shader does not change
+ * between shgrp. */
void DRW_shgroup_uniform_texture_persistent(DRWShadingGroup *shgroup,
const char *name,
const GPUTexture *tex)
@@ -178,7 +181,8 @@ void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup,
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_BLOCK, ubo, 0, 1);
}
-/* Same as DRW_shgroup_uniform_block but is guaranteed to be bound if shader does not change between shgrp. */
+/* Same as DRW_shgroup_uniform_block but is guaranteed to be bound if shader does not change
+ * between shgrp. */
void DRW_shgroup_uniform_block_persistent(DRWShadingGroup *shgroup,
const char *name,
const GPUUniformBuffer *ubo)
@@ -518,15 +522,6 @@ void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup,
drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_TRIS, tria_count * 3, obmat, NULL);
}
-/* TODO (fclem): this is a sign that the api is starting to be limiting.
- * Maybe add special function that general purpose for special cases. */
-void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup,
- uint tria_count,
- Object *ob)
-{
- drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_TRIS, tria_count * 3, NULL, ob);
-}
-
/* These calls can be culled and are optimized for redraw */
void DRW_shgroup_call_object_add_ex(
DRWShadingGroup *shgroup, GPUBatch *geom, Object *ob, Material *ma, bool bypass_culling)
@@ -614,110 +609,150 @@ void DRW_shgroup_call_object_instances_add(DRWShadingGroup *shgroup,
BLI_LINKS_APPEND(&shgroup->calls, call);
}
-void DRW_shgroup_call_generate_add(DRWShadingGroup *shgroup,
- DRWCallGenerateFn *geometry_fn,
- void *user_data,
- float (*obmat)[4])
-{
- BLI_assert(geometry_fn != NULL);
- BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM));
+// #define SCULPT_DEBUG_BUFFERS
- DRWCall *call = BLI_mempool_alloc(DST.vmempool->calls);
- call->state = drw_call_state_create(shgroup, obmat, NULL);
- call->type = DRW_CALL_GENERATE;
- call->generate.geometry_fn = geometry_fn;
- call->generate.user_data = user_data;
-#ifdef USE_GPU_SELECT
- call->select_id = DST.select_id;
+typedef struct DRWSculptCallbackData {
+ Object *ob;
+ DRWShadingGroup **shading_groups;
+ Material **materials;
+ bool use_wire;
+ bool use_mats;
+ bool use_mask;
+ bool fast_mode; /* Set by draw manager. Do not init. */
+#ifdef SCULPT_DEBUG_BUFFERS
+ int node_nr;
+#endif
+} DRWSculptCallbackData;
+
+#ifdef SCULPT_DEBUG_BUFFERS
+# define SCULPT_DEBUG_COLOR(id) (sculpt_debug_colors[id % 9])
+static float sculpt_debug_colors[9][4] = {
+ {1.0f, 0.2f, 0.2f, 1.0f},
+ {0.2f, 1.0f, 0.2f, 1.0f},
+ {0.2f, 0.2f, 1.0f, 1.0f},
+ {1.0f, 1.0f, 0.2f, 1.0f},
+ {0.2f, 1.0f, 1.0f, 1.0f},
+ {1.0f, 0.2f, 1.0f, 1.0f},
+ {1.0f, 0.7f, 0.2f, 1.0f},
+ {0.2f, 1.0f, 0.7f, 1.0f},
+ {0.7f, 0.2f, 1.0f, 1.0f},
+};
#endif
- BLI_LINKS_APPEND(&shgroup->calls, call);
-}
-
-/* This function tests if the current draw engine draws the vertex colors
- * It is used when drawing sculpts
- *
- * XXX: should we use a callback to a the draw engine to retrieve this
- * setting, this makes the draw manager more clean? */
-static bool DRW_draw_vertex_color_active(const DRWContextState *draw_ctx)
-{
- View3D *v3d = draw_ctx->v3d;
- return v3d->shading.type == OB_SOLID && v3d->shading.color_type == V3D_SHADING_VERTEX_COLOR;
-}
-
-static void sculpt_draw_cb(DRWShadingGroup *shgroup,
- void (*draw_fn)(DRWShadingGroup *shgroup, GPUBatch *geom),
- void *user_data)
+static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers)
{
- Object *ob = user_data;
-
- /* XXX should be ensured before but sometime it's not... go figure (see T57040). */
- PBVH *pbvh = BKE_sculpt_object_pbvh_ensure(DST.draw_ctx.depsgraph, ob);
+ GPUBatch *geom = GPU_pbvh_buffers_batch_get(buffers, scd->fast_mode, scd->use_wire);
+ Material *ma = NULL;
+ short index = 0;
- const DRWContextState *drwctx = DRW_context_state_get();
- int fast_mode = 0;
+ /* Meh... use_mask is a bit misleading here. */
+ if (scd->use_mask && !GPU_pbvh_buffers_has_mask(buffers)) {
+ return;
+ }
- if (drwctx->evil_C != NULL) {
- Paint *p = BKE_paint_get_active_from_context(drwctx->evil_C);
- if (p && (p->flags & PAINT_FAST_NAVIGATE)) {
- fast_mode = drwctx->rv3d->rflag & RV3D_NAVIGATING;
- }
+ if (scd->use_mats) {
+ index = GPU_pbvh_buffers_material_index_get(buffers);
+ ma = scd->materials[index];
}
- if (pbvh) {
- const bool show_vcol = DRW_draw_vertex_color_active(drwctx);
- BKE_pbvh_draw_cb(pbvh,
- NULL,
- NULL,
- fast_mode,
- false,
- false,
- show_vcol,
- (void (*)(void *, GPUBatch *))draw_fn,
- shgroup);
+ DRWShadingGroup *shgrp = scd->shading_groups[index];
+ if (geom != NULL && shgrp != NULL) {
+#ifdef SCULPT_DEBUG_BUFFERS
+ /* Color each buffers in different colors. Only work in solid/Xray mode. */
+ shgrp = DRW_shgroup_create_sub(shgrp);
+ DRW_shgroup_uniform_vec3(shgrp, "materialDiffuseColor", SCULPT_DEBUG_COLOR(scd->node_nr++), 1);
+#endif
+ /* DRW_shgroup_call_object_add_ex reuses matrices calculations for all the drawcalls of this
+ * object. */
+ DRW_shgroup_call_object_add_ex(shgrp, geom, scd->ob, ma, true);
}
}
-static void sculpt_draw_wires_cb(DRWShadingGroup *shgroup,
- void (*draw_fn)(DRWShadingGroup *shgroup, GPUBatch *geom),
- void *user_data)
+#ifdef SCULPT_DEBUG_BUFFERS
+static void sculpt_debug_cb(void *user_data,
+ const float bmin[3],
+ const float bmax[3],
+ PBVHNodeFlags flag)
{
- Object *ob = user_data;
+ int *node_nr = (int *)user_data;
+ BoundBox bb;
+ BKE_boundbox_init_from_minmax(&bb, bmin, bmax);
+# if 0 /* Nodes hierarchy. */
+ if (flag & PBVH_Leaf) {
+ DRW_debug_bbox(&bb, (float[4]){0.0f, 1.0f, 0.0f, 1.0f});
+ }
+ else {
+ DRW_debug_bbox(&bb, (float[4]){0.5f, 0.5f, 0.5f, 0.6f});
+ }
+# else /* Color coded leaf bounds. */
+ if (flag & PBVH_Leaf) {
+ DRW_debug_bbox(&bb, SCULPT_DEBUG_COLOR((*node_nr)++));
+ }
+# endif
+}
+#endif
+
+static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol)
+{
/* XXX should be ensured before but sometime it's not... go figure (see T57040). */
- PBVH *pbvh = BKE_sculpt_object_pbvh_ensure(DST.draw_ctx.depsgraph, ob);
+ PBVH *pbvh = BKE_sculpt_object_pbvh_ensure(DST.draw_ctx.depsgraph, scd->ob);
+ if (!pbvh) {
+ return;
+ }
- const DRWContextState *drwctx = DRW_context_state_get();
- int fast_mode = 0;
+ float(*planes)[4] = NULL; /* TODO proper culling. */
+ scd->fast_mode = false;
+ const DRWContextState *drwctx = DRW_context_state_get();
if (drwctx->evil_C != NULL) {
Paint *p = BKE_paint_get_active_from_context(drwctx->evil_C);
if (p && (p->flags & PAINT_FAST_NAVIGATE)) {
- fast_mode = drwctx->rv3d->rflag & RV3D_NAVIGATING;
+ scd->fast_mode = (drwctx->rv3d->rflag & RV3D_NAVIGATING) != 0;
}
}
- if (pbvh) {
- BKE_pbvh_draw_cb(pbvh,
- NULL,
- NULL,
- fast_mode,
- true,
- false,
- false,
- (void (*)(void *, GPUBatch *))draw_fn,
- shgroup);
- }
+ BKE_pbvh_draw_cb(
+ pbvh, planes, NULL, use_vcol, (void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb, scd);
+
+#ifdef SCULPT_DEBUG_BUFFERS
+ int node_nr = 0;
+ DRW_debug_modelmat(scd->ob->obmat);
+ BKE_pbvh_draw_debug_cb(
+ pbvh,
+ (void (*)(void *d, const float min[3], const float max[3], PBVHNodeFlags f))sculpt_debug_cb,
+ &node_nr);
+#endif
}
-void DRW_shgroup_call_sculpt_add(DRWShadingGroup *shgroup, Object *ob, float (*obmat)[4])
+void DRW_shgroup_call_sculpt_add(
+ DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask, bool use_vcol)
{
- DRW_shgroup_call_generate_add(shgroup, sculpt_draw_cb, ob, obmat);
+ DRWSculptCallbackData scd = {
+ .ob = ob,
+ .shading_groups = &shgroup,
+ .materials = NULL,
+ .use_wire = use_wire,
+ .use_mats = false,
+ .use_mask = use_mask,
+ };
+ drw_sculpt_generate_calls(&scd, use_vcol);
}
-void DRW_shgroup_call_sculpt_wires_add(DRWShadingGroup *shgroup, Object *ob, float (*obmat)[4])
+void DRW_shgroup_call_sculpt_with_materials_add(DRWShadingGroup **shgroups,
+ Material **materials,
+ Object *ob,
+ bool use_vcol)
{
- DRW_shgroup_call_generate_add(shgroup, sculpt_draw_wires_cb, ob, obmat);
+ DRWSculptCallbackData scd = {
+ .ob = ob,
+ .shading_groups = shgroups,
+ .materials = materials,
+ .use_wire = false,
+ .use_mats = true,
+ .use_mask = false,
+ };
+ drw_sculpt_generate_calls(&scd, use_vcol);
}
void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup,
@@ -1178,7 +1213,7 @@ void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct GPUBatch *batch
/* PERF : This destroys the vaos cache so better check if it's necessary. */
/* Note: This WILL break if batch->verts[0] is destroyed and reallocated
* at the same address. Bindings/VAOs would remain obsolete. */
- //if (shgroup->instancing_geom->inst != batch->verts[0])
+ // if (shgroup->instancing_geom->inst != batch->verts[0])
GPU_batch_instbuf_set(shgroup->instance_geom, batch->verts[0], false);
#ifdef USE_GPU_SELECT
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index c5e3ecd0752..46f4d0620c8 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -205,7 +205,7 @@ void drw_state_set(DRWState state)
int test;
if (CHANGED_ANY_STORE_VAR(DRW_STATE_BLEND | DRW_STATE_BLEND_PREMUL | DRW_STATE_ADDITIVE |
DRW_STATE_MULTIPLY | DRW_STATE_ADDITIVE_FULL |
- DRW_STATE_BLEND_OIT,
+ DRW_STATE_BLEND_OIT | DRW_STATE_BLEND_PREMUL_UNDER,
test)) {
if (test) {
glEnable(GL_BLEND);
@@ -216,6 +216,9 @@ void drw_state_set(DRWState state)
GL_ONE,
GL_ONE_MINUS_SRC_ALPHA); /* Alpha */
}
+ else if ((state & DRW_STATE_BLEND_PREMUL_UNDER) != 0) {
+ glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE);
+ }
else if ((state & DRW_STATE_BLEND_PREMUL) != 0) {
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
@@ -401,13 +404,6 @@ void DRW_state_reset(void)
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
-/* NOTE : Make sure to reset after use! */
-void DRW_state_invert_facing(void)
-{
- SWAP(GLenum, DST.backface, DST.frontface);
- glFrontFace(DST.frontface);
-}
-
/**
* This only works if DRWPasses have been tagged with DRW_STATE_CLIP_PLANES,
* and if the shaders have support for it (see usage of gl_ClipDistance).
@@ -445,8 +441,9 @@ void DRW_state_clip_planes_set_from_rv3d(RegionView3D *rv3d)
/* Extract the 8 corners from a Projection Matrix.
* Although less accurate, this solution can be simplified as follows:
- * BKE_boundbox_init_from_minmax(&bbox, (const float[3]){-1.0f, -1.0f, -1.0f}, (const float[3]){1.0f, 1.0f, 1.0f});
- * for (int i = 0; i < 8; i++) {mul_project_m4_v3(projinv, bbox.vec[i]);}
+ * BKE_boundbox_init_from_minmax(&bbox, (const float[3]){-1.0f, -1.0f, -1.0f}, (const
+ * float[3]){1.0f, 1.0f, 1.0f}); for (int i = 0; i < 8; i++) {mul_project_m4_v3(projinv,
+ * bbox.vec[i]);}
*/
static void draw_frustum_boundbox_calc(const float (*projmat)[4], BoundBox *r_bbox)
{
@@ -683,12 +680,16 @@ bool DRW_culling_sphere_test(BoundSphere *bsphere)
/* Do a rough test first: Sphere VS Sphere intersect. */
BoundSphere *frustum_bsphere = &DST.clipping.frustum_bsphere;
- float center_dist = len_squared_v3v3(bsphere->center, frustum_bsphere->center);
- if (center_dist > SQUARE(bsphere->radius + frustum_bsphere->radius)) {
+ float center_dist_sq = len_squared_v3v3(bsphere->center, frustum_bsphere->center);
+ float radius_sum = bsphere->radius + frustum_bsphere->radius;
+ if (center_dist_sq > SQUARE(radius_sum)) {
return false;
}
+ /* TODO we could test against the inscribed sphere of the frustum to early out positively. */
/* Test against the 6 frustum planes. */
+ /* TODO order planes with sides first then far then near clip. Should be better culling heuristic
+ * when sculpting. */
for (int p = 0; p < 6; p++) {
float dist = plane_point_side_v3(DST.clipping.frustum_planes[p], bsphere->center);
if (dist < -bsphere->radius) {
@@ -1322,9 +1323,6 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
draw_geometry_execute_ex(
shgroup, call->instances.geometry, 0, *call->instances.count, true);
break;
- case DRW_CALL_GENERATE:
- call->generate.geometry_fn(shgroup, draw_geometry_execute, call->generate.user_data);
- break;
case DRW_CALL_PROCEDURAL:
GPU_draw_primitive(call->procedural.prim_type, call->procedural.vert_count);
break;
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 9cb3c1bf226..b60a41ab0c9 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -161,8 +161,10 @@ static void drw_deferred_shader_compilation_free(void *custom_data)
static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred)
{
- /* Do not deferre the compilation if we are rendering for image. */
- if (DRW_state_is_image_render() || !USE_DEFERRED_COMPILATION || !deferred) {
+ /* Do not deferre the compilation if we are rendering for image.
+ * deferred rendering is only possible when `evil_C` is available */
+ if (DST.draw_ctx.evil_C == NULL || DRW_state_is_image_render() || !USE_DEFERRED_COMPILATION ||
+ !deferred) {
/* Double checking that this GPUMaterial is not going to be
* compiled by another thread. */
DRW_deferred_shader_remove(mat);
@@ -181,7 +183,8 @@ static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred)
/* Use original scene ID since this is what the jobs template tests for. */
Scene *scene = (Scene *)DEG_get_original_id(&DST.draw_ctx.scene->id);
- /* Get the running job or a new one if none is running. Can only have one job per type & owner. */
+ /* Get the running job or a new one if none is running. Can only have one job per type & owner.
+ */
wmJob *wm_job = WM_jobs_get(wm,
win,
scene,
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 1543e381d8c..7aa2e007f79 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -61,19 +61,35 @@ void DRW_draw_region_info(void)
/* ************************* Background ************************** */
-void DRW_draw_background(void)
+void DRW_draw_background(bool do_alpha_checker)
{
/* Just to make sure */
glDepthMask(GL_TRUE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glStencilMask(0xFF);
- if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
+ if (do_alpha_checker) {
+ /* Transparent render, do alpha checker. */
+ GPU_depth_test(false);
+
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
+ GPU_matrix_identity_projection_set();
+
+ imm_draw_box_checker_2d(-1.0f, -1.0f, 1.0f, 1.0f);
+
+ GPU_matrix_pop();
+
+ GPU_clear(GPU_DEPTH_BIT | GPU_STENCIL_BIT);
+
+ GPU_depth_test(true);
+ }
+ else if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
float m[4][4];
unit_m4(m);
/* Gradient background Color */
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -104,14 +120,15 @@ void DRW_draw_background(void)
GPU_matrix_pop();
- glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+ GPU_clear(GPU_DEPTH_BIT | GPU_STENCIL_BIT);
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
}
else {
/* Solid background Color */
UI_ThemeClearColorAlpha(TH_BACK, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+ GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT | GPU_STENCIL_BIT);
}
}
diff --git a/source/blender/draw/intern/draw_view.h b/source/blender/draw/intern/draw_view.h
index 08a8e984c87..715c3c0d40c 100644
--- a/source/blender/draw/intern/draw_view.h
+++ b/source/blender/draw/intern/draw_view.h
@@ -24,7 +24,7 @@
#define __DRAW_VIEW_H__
void DRW_draw_region_info(void);
-void DRW_draw_background(void);
+void DRW_draw_background(bool do_alpha_checker);
void DRW_draw_cursor(void);
void DRW_draw_gizmo_3d(void);
void DRW_draw_gizmo_2d(void);
diff --git a/source/blender/draw/modes/edit_armature_mode.c b/source/blender/draw/modes/edit_armature_mode.c
index 12bf4982ffb..d1ef0d0e104 100644
--- a/source/blender/draw/modes/edit_armature_mode.c
+++ b/source/blender/draw/modes/edit_armature_mode.c
@@ -126,6 +126,7 @@ static void EDIT_ARMATURE_cache_populate(void *vedata, Object *ob)
.bone_envelope = psl->bone_envelope[ghost],
.bone_axes = psl->bone_axes,
.relationship_lines = psl->relationship[ghost],
+ .custom_shapes = NULL, /* Not needed in edit mode. */
};
DRW_shgroup_armature_edit(ob, passes, transp);
}
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index 31f1515d8f5..ffe7fe5845c 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -55,6 +55,8 @@ extern char datatoc_edit_mesh_overlay_geom_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[];
+extern char datatoc_edit_mesh_overlay_mesh_analysis_frag_glsl[];
+extern char datatoc_edit_mesh_overlay_mesh_analysis_vert_glsl[];
extern char datatoc_edit_normals_vert_glsl[];
extern char datatoc_edit_normals_geom_glsl[];
extern char datatoc_common_globals_lib_glsl[];
@@ -75,6 +77,7 @@ typedef struct EDIT_MESH_PassList {
struct DRWPass *edit_face_occluded;
struct DRWPass *mix_occlude;
struct DRWPass *facefill_occlude;
+ struct DRWPass *mesh_analysis_pass;
struct DRWPass *normals;
} EDIT_MESH_PassList;
@@ -115,6 +118,10 @@ typedef struct EDIT_MESH_Shaders {
GPUShader *normals_loop;
GPUShader *normals;
GPUShader *depth;
+
+ /* Mesh analysis shader */
+ GPUShader *mesh_analysis_face;
+ GPUShader *mesh_analysis_vertex;
} EDIT_MESH_Shaders;
/* *********** STATIC *********** */
@@ -149,6 +156,7 @@ typedef struct EDIT_MESH_PrivateData {
DRWShadingGroup *facedot_shgrp_in_front;
DRWShadingGroup *facefill_occluded_shgrp;
+ DRWShadingGroup *mesh_analysis_shgrp;
int data_mask[4];
int ghost_ob;
@@ -278,6 +286,22 @@ static void EDIT_MESH_engine_init(void *vedata)
.defs = (const char *[]){sh_cfg_data->def, NULL},
});
+ /* Mesh Analysis */
+ sh_data->mesh_analysis_face = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib,
+ datatoc_edit_mesh_overlay_mesh_analysis_vert_glsl,
+ NULL},
+ .frag = (const char *[]){datatoc_edit_mesh_overlay_mesh_analysis_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, "#define FACE_COLOR\n", NULL},
+ });
+ sh_data->mesh_analysis_vertex = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib,
+ datatoc_edit_mesh_overlay_mesh_analysis_vert_glsl,
+ NULL},
+ .frag = (const char *[]){datatoc_edit_mesh_overlay_mesh_analysis_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, "#define VERTEX_COLOR\n", NULL},
+ });
+
sh_data->depth = DRW_shader_create_3d_depth_only(draw_ctx->sh_cfg);
}
}
@@ -509,6 +533,18 @@ static void EDIT_MESH_cache_init(void *vedata)
}
}
+ {
+ /* Mesh Analysis Pass */
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND;
+ psl->mesh_analysis_pass = DRW_pass_create("Mesh Analysis", state);
+ const bool is_vertex_color = scene->toolsettings->statvis.type == SCE_STATVIS_SHARP;
+ stl->g_data->mesh_analysis_shgrp = DRW_shgroup_create(
+ is_vertex_color ? sh_data->mesh_analysis_vertex : sh_data->mesh_analysis_face,
+ psl->mesh_analysis_pass);
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->mesh_analysis_shgrp, rv3d);
+ }
+ }
/* For in front option */
psl->edit_face_overlay_in_front = edit_mesh_create_overlay_pass(
&face_mod,
@@ -534,7 +570,8 @@ static void EDIT_MESH_cache_init(void *vedata)
&stl->g_data->vert_shgrp);
}
else {
- /* We render all wires with depth and opaque to a new fbo and blend the result based on depth values */
+ /* We render all wires with depth and opaque to a new fbo and blend the result based on depth
+ * values */
psl->edit_face_occluded = edit_mesh_create_overlay_pass(&zero,
stl->g_data->data_mask,
stl->g_data->do_edges,
@@ -628,6 +665,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
bool do_in_front = (ob->dtx & OB_DRAWXRAY) != 0;
bool do_occlude_wire = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) != 0;
bool do_show_weight = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_WEIGHT) != 0;
+ bool do_show_mesh_analysis = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_STATVIS) != 0;
bool fnormals_do = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_NORMALS) != 0;
bool vnormals_do = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_VERT_NORMALS) != 0;
bool lnormals_do = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_LOOP_NORMALS) != 0;
@@ -656,6 +694,19 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
DRW_shgroup_call_add(g_data->fweights_shgrp, geom, ob->obmat);
}
+ if (do_show_mesh_analysis) {
+ Mesh *me = (Mesh *)ob->data;
+ BMEditMesh *embm = me->edit_mesh;
+ const bool is_original = embm->mesh_eval_final &&
+ (embm->mesh_eval_final->runtime.is_original == true);
+ if (is_original) {
+ geom = DRW_cache_mesh_surface_mesh_analysis_get(ob);
+ if (geom) {
+ DRW_shgroup_call_add(g_data->mesh_analysis_shgrp, geom, ob->obmat);
+ }
+ }
+ }
+
if (do_occlude_wire || do_in_front) {
geom = DRW_cache_mesh_surface_get(ob);
DRW_shgroup_call_add(do_in_front ? g_data->depth_shgrp_hidden_wire_in_front :
@@ -731,6 +782,7 @@ static void EDIT_MESH_draw_scene(void *vedata)
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
DRW_draw_pass(psl->weight_faces);
+ DRW_draw_pass(psl->mesh_analysis_pass);
DRW_draw_pass(psl->depth_hidden_wire);
diff --git a/source/blender/draw/modes/edit_mesh_mode_text.c b/source/blender/draw/modes/edit_mesh_mode_text.c
index f97d1083876..f3630a77e9a 100644
--- a/source/blender/draw/modes/edit_mesh_mode_text.c
+++ b/source/blender/draw/modes/edit_mesh_mode_text.c
@@ -47,8 +47,8 @@ void DRW_edit_mesh_mode_text_measure_stats(ARegion *ar,
Object *ob,
const UnitSettings *unit)
{
- /* Do not use ascii when using non-default unit system, some unit chars are utf8 (micro, square, etc.).
- * See bug #36090.
+ /* Do not use ascii when using non-default unit system, some unit chars are utf8 (micro, square,
+ * etc.). See bug #36090.
*/
struct DRWTextStore *dt = DRW_text_cache_ensure();
const short txt_flag = DRW_TEXT_CACHE_GLOBALSPACE | (unit->system ? 0 : DRW_TEXT_CACHE_ASCII);
@@ -159,15 +159,14 @@ void DRW_edit_mesh_mode_text_measure_stats(ARegion *ar,
if (BM_edge_loop_pair(eed, &l_a, &l_b)) {
/* Draw selected edges, or edges next to selected verts while dragging. */
if (BM_elem_flag_test(eed, BM_ELEM_SELECT) ||
- (do_moving &&
- (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
- BM_elem_flag_test(eed->v2, BM_ELEM_SELECT) ||
- /* Special case, this is useful to show when verts connected to this edge
- * via a face are being transformed. */
- BM_elem_flag_test(l_a->next->next->v, BM_ELEM_SELECT) ||
- BM_elem_flag_test(l_a->prev->v, BM_ELEM_SELECT) ||
- BM_elem_flag_test(l_b->next->next->v, BM_ELEM_SELECT) ||
- BM_elem_flag_test(l_b->prev->v, BM_ELEM_SELECT)))) {
+ (do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
+ BM_elem_flag_test(eed->v2, BM_ELEM_SELECT) ||
+ /* Special case, this is useful to show when verts connected
+ * to this edge via a face are being transformed. */
+ BM_elem_flag_test(l_a->next->next->v, BM_ELEM_SELECT) ||
+ BM_elem_flag_test(l_a->prev->v, BM_ELEM_SELECT) ||
+ BM_elem_flag_test(l_b->next->next->v, BM_ELEM_SELECT) ||
+ BM_elem_flag_test(l_b->prev->v, BM_ELEM_SELECT)))) {
float v1_clip[3], v2_clip[3];
copy_v3_v3(v1, eed->v1->co);
@@ -320,7 +319,8 @@ void DRW_edit_mesh_mode_text_measure_stats(ARegion *ar,
}
}
- /* This option is for mesh ops and addons debugging; only available in UI if Blender starts with --debug */
+ /* This option is for mesh ops and addons debugging; only available in UI if Blender starts with
+ * --debug */
if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_INDICES) {
int i;
diff --git a/source/blender/draw/modes/edit_metaball_mode.c b/source/blender/draw/modes/edit_metaball_mode.c
index 90c5676727f..aa7c6863423 100644
--- a/source/blender/draw/modes/edit_metaball_mode.c
+++ b/source/blender/draw/modes/edit_metaball_mode.c
@@ -126,7 +126,7 @@ static void EDIT_METABALL_cache_init(void *vedata)
/* Add geometry to shadingGroups. Execute for each objects */
static void EDIT_METABALL_cache_populate(void *vedata, Object *ob)
{
- //EDIT_METABALL_PassList *psl = ((EDIT_METABALL_Data *)vedata)->psl;
+ // EDIT_METABALL_PassList *psl = ((EDIT_METABALL_Data *)vedata)->psl;
EDIT_METABALL_StorageList *stl = ((EDIT_METABALL_Data *)vedata)->stl;
if (ob->type == OB_MBALL) {
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index f113f60e731..378f810551e 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -53,6 +53,8 @@
#include "BKE_particle.h"
#include "BKE_tracking.h"
+#include "BLI_ghash.h"
+
#include "ED_view3d.h"
#include "GPU_batch.h"
@@ -273,6 +275,8 @@ typedef struct OBJECT_PrivateData {
OBJECT_ShadingGroupList sgl;
OBJECT_ShadingGroupList sgl_ghost;
+ GHash *custom_shapes;
+
/* Outlines */
DRWShadingGroup *outlines_active;
DRWShadingGroup *outlines_select;
@@ -949,7 +953,8 @@ static void DRW_shgroup_empty_image(OBJECT_Shaders *sh_data,
return;
}
- /* Calling 'BKE_image_get_size' may free the texture. Get the size from 'tex' instead, see: T59347 */
+ /* Calling 'BKE_image_get_size' may free the texture. Get the size from 'tex' instead,
+ * see: T59347 */
int size[2] = {0};
const bool use_alpha_blend = (ob->empty_image_flag & OB_EMPTY_IMAGE_USE_ALPHA_BLEND) != 0;
@@ -1040,6 +1045,8 @@ static void OBJECT_cache_init(void *vedata)
g_data->xray_enabled_and_not_wire = g_data->xray_enabled &&
draw_ctx->v3d->shading.type > OB_WIRE;
+ g_data->custom_shapes = BLI_ghash_ptr_new(__func__);
+
{
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
DRW_STATE_WIRE;
@@ -1495,7 +1502,7 @@ static void OBJECT_cache_init(void *vedata)
psl->ob_center = DRW_pass_create("Obj Center Pass", state);
outlineWidth = 1.0f * U.pixelsize;
- size = U.obcenter_dia * U.pixelsize + outlineWidth;
+ size = UI_GetThemeValuef(TH_OBCENTER_DIA) * U.pixelsize + outlineWidth;
GPUShader *sh = GPU_shader_get_builtin_shader_with_config(
GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA, draw_ctx->sh_cfg);
@@ -3288,6 +3295,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
.bone_envelope = sgl->bone_envelope,
.bone_axes = sgl->bone_axes,
.relationship_lines = NULL, /* Don't draw relationship lines */
+ .custom_shapes = stl->g_data->custom_shapes,
};
DRW_shgroup_armature_object(ob, view_layer, passes, is_wire);
}
@@ -3395,6 +3403,11 @@ static void OBJECT_cache_finish(void *vedata)
DRW_pass_sort_shgroup_z(stl->g_data->sgl.image_empties);
DRW_pass_sort_shgroup_z(stl->g_data->sgl_ghost.image_empties);
+
+ if (stl->g_data->custom_shapes) {
+ /* TODO(fclem): Do not free it for each frame but reuse it. Avoiding alloc cost. */
+ BLI_ghash_free(stl->g_data->custom_shapes, NULL, NULL);
+ }
}
static void OBJECT_draw_scene(void *vedata)
diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c
index 4d583066f44..90fac136f73 100644
--- a/source/blender/draw/modes/overlay_mode.c
+++ b/source/blender/draw/modes/overlay_mode.c
@@ -359,8 +359,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
if ((!pd->show_overlays) ||
(((ob != draw_ctx->object_edit) && !is_edit_mode) || 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 is_sculpt_mode = DRW_object_use_pbvh_drawing(ob);
const bool all_wires = (ob->dtx & OB_DRAW_ALL_EDGES);
const bool is_wire = (ob->dt < OB_SOLID);
const bool use_coloring = (pd->show_overlays && !is_edit_mode && !is_sculpt_mode &&
@@ -390,7 +389,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
}
if (is_sculpt_mode) {
- DRW_shgroup_call_sculpt_wires_add(shgrp, ob, ob->obmat);
+ DRW_shgroup_call_sculpt_add(shgrp, ob, true, false, false);
}
else {
DRW_shgroup_call_add(shgrp, geom, ob->obmat);
diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c
index 84852ff7ab3..3e292f4e4bc 100644
--- a/source/blender/draw/modes/paint_texture_mode.c
+++ b/source/blender/draw/modes/paint_texture_mode.c
@@ -294,7 +294,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
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;
+ 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;
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index 5e3353414f5..a37901a1fa9 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -72,6 +72,7 @@ typedef struct POSE_Data {
typedef struct POSE_PrivateData {
DRWShadingGroup *bone_selection_shgrp;
DRWShadingGroup *bone_selection_invert_shgrp;
+ GHash *custom_shapes[2];
float blend_color[4];
float blend_color_invert[4];
bool transparent_bones;
@@ -139,6 +140,8 @@ static void POSE_cache_init(void *vedata)
state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
DRW_STATE_BLEND | DRW_STATE_WIRE;
psl->relationship[i] = DRW_pass_create("Bone Relationship Pass", state);
+
+ ppd->custom_shapes[i] = BLI_ghash_ptr_new(__func__);
}
{
@@ -213,6 +216,7 @@ static void POSE_cache_populate(void *vedata, Object *ob)
.bone_envelope = psl->bone_envelope[ghost],
.bone_axes = psl->bone_axes,
.relationship_lines = psl->relationship[ghost],
+ .custom_shapes = ppd->custom_shapes[transp],
};
DRW_shgroup_armature_pose(ob, passes, transp);
}
@@ -231,6 +235,16 @@ static void POSE_cache_populate(void *vedata, Object *ob)
}
}
+static void POSE_cache_finish(void *vedata)
+{
+ POSE_PrivateData *ppd = ((POSE_Data *)vedata)->stl->g_data;
+
+ /* TODO(fclem): Do not free it for each frame but reuse it. Avoiding alloc cost. */
+ for (int i = 0; i < 2; i++) {
+ BLI_ghash_free(ppd->custom_shapes[i], NULL, NULL);
+ }
+}
+
/**
* Return true if armature should be handled by the pose mode engine.
*/
@@ -323,7 +337,7 @@ DrawEngineType draw_engine_pose_type = {
&POSE_engine_free,
&POSE_cache_init,
&POSE_cache_populate,
- NULL,
+ &POSE_cache_finish,
NULL,
&POSE_draw_scene,
NULL,
diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c
index e5d10a5d6e1..053e73e4068 100644
--- a/source/blender/draw/modes/sculpt_mode.c
+++ b/source/blender/draw/modes/sculpt_mode.c
@@ -90,18 +90,11 @@ typedef struct SCULPT_Data {
/* *********** STATIC *********** */
static struct {
- /* Custom shaders :
- * Add sources to source/blender/draw/modes/shaders
- * init in SCULPT_engine_init();
- * free in SCULPT_engine_free(); */
- struct GPUShader *shader_smooth;
+ struct GPUShader *shader_mask;
} e_data = {NULL}; /* Engine data */
typedef struct SCULPT_PrivateData {
- /* This keeps the references of the shading groups for
- * easy access in SCULPT_cache_populate() */
- DRWShadingGroup *group_flat;
- DRWShadingGroup *group_smooth;
+ DRWShadingGroup *mask_overlay_grp;
} SCULPT_PrivateData; /* Transient data */
/* *********** FUNCTIONS *********** */
@@ -117,8 +110,8 @@ static void SCULPT_engine_init(void *vedata)
UNUSED_VARS(txl, fbl, stl);
- if (!e_data.shader_smooth) {
- e_data.shader_smooth = DRW_shader_create(
+ if (!e_data.shader_mask) {
+ e_data.shader_mask = DRW_shader_create(
datatoc_sculpt_mask_vert_glsl, NULL, datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL);
}
}
@@ -141,47 +134,9 @@ static void SCULPT_cache_init(void *vedata)
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_MULTIPLY;
psl->pass = DRW_pass_create("Sculpt Pass", state);
- DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.shader_smooth, psl->pass);
+ DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.shader_mask, psl->pass);
DRW_shgroup_uniform_float(shgrp, "maskOpacity", &v3d->overlay.sculpt_mode_mask_opacity, 1);
- stl->g_data->group_smooth = shgrp;
- }
-}
-
-static void sculpt_draw_mask_cb(DRWShadingGroup *shgroup,
- void (*draw_fn)(DRWShadingGroup *shgroup, struct GPUBatch *geom),
- void *user_data)
-{
- Object *ob = user_data;
- PBVH *pbvh = ob->sculpt->pbvh;
-
- if (pbvh) {
- BKE_pbvh_draw_cb(pbvh,
- NULL,
- NULL,
- false,
- false,
- true,
- false,
- (void (*)(void *, struct GPUBatch *))draw_fn,
- shgroup);
- }
-}
-
-static void sculpt_update_pbvh_normals(Object *object)
-{
- Mesh *mesh = object->data;
- PBVH *pbvh = object->sculpt->pbvh;
- SubdivCCG *subdiv_ccg = mesh->runtime.subdiv_ccg;
- if (pbvh == NULL || subdiv_ccg == NULL) {
- return;
- }
- BKE_sculpt_bvh_update_from_ccg(pbvh, subdiv_ccg);
- struct CCGFace **faces;
- int num_faces;
- BKE_pbvh_get_grid_updates(pbvh, 1, (void ***)&faces, &num_faces);
- if (num_faces > 0) {
- BKE_subdiv_ccg_update_normals(subdiv_ccg, faces, num_faces);
- MEM_freeN(faces);
+ stl->g_data->mask_overlay_grp = shgrp;
}
}
@@ -197,72 +152,24 @@ static void SCULPT_cache_populate(void *vedata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
if (ob->sculpt && (ob == draw_ctx->obact)) {
- sculpt_update_pbvh_normals(ob);
-
- /* XXX, needed for dyntopo-undo (which clears).
- * probably depsgraph should handlle? in 2.7x getting derived-mesh does this (mesh_build_data) */
- if (ob->sculpt->pbvh == NULL) {
- /* create PBVH immediately (would be created on the fly too,
- * but this avoids waiting on first stroke) */
- Scene *scene = draw_ctx->scene;
-
- BKE_sculpt_update_mesh_elements(
- draw_ctx->depsgraph, scene, scene->toolsettings->sculpt, ob, false, false);
- }
-
PBVH *pbvh = ob->sculpt->pbvh;
if (pbvh && pbvh_has_mask(pbvh)) {
- DRW_shgroup_call_generate_add(
- stl->g_data->group_smooth, sculpt_draw_mask_cb, ob, ob->obmat);
+ DRW_shgroup_call_sculpt_add(stl->g_data->mask_overlay_grp, ob, false, true, false);
}
}
}
}
-/* Optional: Post-cache_populate callback */
-static void SCULPT_cache_finish(void *vedata)
-{
- SCULPT_PassList *psl = ((SCULPT_Data *)vedata)->psl;
- SCULPT_StorageList *stl = ((SCULPT_Data *)vedata)->stl;
-
- /* Do something here! dependent on the objects gathered */
- UNUSED_VARS(psl, stl);
-}
-
-/* Draw time ! Control rendering pipeline from here */
static void SCULPT_draw_scene(void *vedata)
{
SCULPT_PassList *psl = ((SCULPT_Data *)vedata)->psl;
- SCULPT_FramebufferList *fbl = ((SCULPT_Data *)vedata)->fbl;
-
- /* Default framebuffer and texture */
- DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
- DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
-
- UNUSED_VARS(fbl, dfbl, dtxl);
- /* Show / hide entire passes, swap framebuffers ... whatever you fancy */
- /*
- * DRW_framebuffer_texture_detach(dtxl->depth);
- * DRW_framebuffer_bind(fbl->custom_fb);
- * DRW_draw_pass(psl->pass);
- * DRW_framebuffer_texture_attach(dfbl->default_fb, dtxl->depth, 0, 0);
- * DRW_framebuffer_bind(dfbl->default_fb);
- */
-
- /* ... or just render passes on default framebuffer. */
DRW_draw_pass(psl->pass);
-
- /* If you changed framebuffer, double check you rebind
- * the default one with its textures attached before finishing */
}
-/* Cleanup when destroying the engine.
- * This is not per viewport ! only when quitting blender.
- * Mostly used for freeing shaders */
static void SCULPT_engine_free(void)
{
- DRW_SHADER_FREE_SAFE(e_data.shader_smooth);
+ DRW_SHADER_FREE_SAFE(e_data.shader_mask);
}
static const DrawEngineDataSize SCULPT_data_size = DRW_VIEWPORT_DATA_SIZE(SCULPT_Data);
@@ -276,7 +183,7 @@ DrawEngineType draw_engine_sculpt_type = {
&SCULPT_engine_free,
&SCULPT_cache_init,
&SCULPT_cache_populate,
- &SCULPT_cache_finish,
+ NULL,
NULL, /* draw_background but not needed by mode engines */
&SCULPT_draw_scene,
NULL,
diff --git a/source/blender/draw/modes/shaders/common_fxaa_lib.glsl b/source/blender/draw/modes/shaders/common_fxaa_lib.glsl
index dcb7c0ba7f2..d9e78855dc9 100644
--- a/source/blender/draw/modes/shaders/common_fxaa_lib.glsl
+++ b/source/blender/draw/modes/shaders/common_fxaa_lib.glsl
@@ -674,7 +674,7 @@ vec4 FxaaPixelShader(
posP.x += offNP.x * FXAA_QUALITY__P10;
if (!doneP)
posP.y += offNP.y * FXAA_QUALITY__P10;
- /*--------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------*/
# if (FXAA_QUALITY__PS > 11)
if (doneNP) {
if (!doneN)
@@ -696,7 +696,7 @@ vec4 FxaaPixelShader(
posP.x += offNP.x * FXAA_QUALITY__P11;
if (!doneP)
posP.y += offNP.y * FXAA_QUALITY__P11;
- /*--------------------------------------------------------------------------*/
+ /*-----------------------------------------------------------------------*/
# if (FXAA_QUALITY__PS > 12)
if (doneNP) {
if (!doneN)
@@ -718,10 +718,10 @@ vec4 FxaaPixelShader(
posP.x += offNP.x * FXAA_QUALITY__P12;
if (!doneP)
posP.y += offNP.y * FXAA_QUALITY__P12;
- /*--------------------------------------------------------------------------*/
+ /*-----------------------------------------------------------------------*/
}
# endif
- /*--------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
diff --git a/source/blender/draw/modes/shaders/common_hair_lib.glsl b/source/blender/draw/modes/shaders/common_hair_lib.glsl
index 02254908232..1c0a31c59fd 100644
--- a/source/blender/draw/modes/shaders/common_hair_lib.glsl
+++ b/source/blender/draw/modes/shaders/common_hair_lib.glsl
@@ -38,8 +38,8 @@ uniform usamplerBuffer hairStrandBuffer; /* R32UI */
uniform usamplerBuffer hairStrandSegBuffer; /* R16UI */
/* Not used, use one buffer per uv layer */
-//uniform samplerBuffer hairUVBuffer; /* RG32F */
-//uniform samplerBuffer hairColBuffer; /* RGBA16 linear color */
+// uniform samplerBuffer hairUVBuffer; /* RG32F */
+// uniform samplerBuffer hairColBuffer; /* RGBA16 linear color */
/* -- Subdivision stage -- */
/**
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
index 2c2cd1f0610..7fe3cea8a42 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
@@ -5,8 +5,8 @@
* We want to know how much a pixel is covered by a line.
* We replace the square pixel with acircle of the same area and try to find the intersection area.
* The area we search is the circular segment. https://en.wikipedia.org/wiki/Circular_segment
- * The formula for the area uses inverse trig function and is quite complexe.
- * Instead, we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
+ * The formula for the area uses inverse trig function and is quite complexe. Instead,
+ * we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
*/
#define DISC_RADIUS (M_1_SQRTPI * 1.05)
#define GRID_LINE_SMOOTH_START (0.5 - DISC_RADIUS)
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl
new file mode 100644
index 00000000000..8581453e810
--- /dev/null
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl
@@ -0,0 +1,14 @@
+out vec4 fragColor;
+
+#ifdef FACE_COLOR
+flat in vec4 weightColor;
+#endif
+
+#ifdef VERTEX_COLOR
+in vec4 weightColor;
+#endif
+
+void main()
+{
+ fragColor = weightColor;
+}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl
new file mode 100644
index 00000000000..94d8d2e701c
--- /dev/null
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl
@@ -0,0 +1,23 @@
+uniform mat4 ModelViewProjectionMatrix;
+uniform mat4 ModelMatrix;
+
+in vec3 pos;
+in vec4 weight_color;
+
+#ifdef FACE_COLOR
+flat out vec4 weightColor;
+#endif
+
+#ifdef VERTEX_COLOR
+out vec4 weightColor;
+#endif
+
+void main()
+{
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+ weightColor = vec4(weight_color.rgb, 1.0);
+
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
+#endif
+}
diff --git a/source/blender/draw/modes/shaders/object_grid_frag.glsl b/source/blender/draw/modes/shaders/object_grid_frag.glsl
index 841b4a95b21..df2cfe7be82 100644
--- a/source/blender/draw/modes/shaders/object_grid_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_grid_frag.glsl
@@ -40,8 +40,8 @@ uniform int gridFlag;
* We want to know how much a pixel is covered by a line.
* We replace the square pixel with acircle of the same area and try to find the intersection area.
* The area we search is the circular segment. https://en.wikipedia.org/wiki/Circular_segment
- * The formula for the area uses inverse trig function and is quite complexe.
- * Instead, we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
+ * The formula for the area uses inverse trig function and is quite complexe. Instead,
+ * we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
*/
#define DISC_RADIUS (M_1_SQRTPI * 1.05)
#define GRID_LINE_SMOOTH_START (0.5 - DISC_RADIUS)
diff --git a/source/blender/draw/modes/shaders/particle_strand_vert.glsl b/source/blender/draw/modes/shaders/particle_strand_vert.glsl
index 745499800e5..6dac6d6b980 100644
--- a/source/blender/draw/modes/shaders/particle_strand_vert.glsl
+++ b/source/blender/draw/modes/shaders/particle_strand_vert.glsl
@@ -45,14 +45,12 @@ vec3 weight_to_rgb(float weight)
return r_rgb;
}
-#define DECOMPRESS_RANGE 1.0039
-
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
#ifdef USE_WEIGHT
- finalColor = vec4(weight_to_rgb(color * DECOMPRESS_RANGE), 1.0);
+ finalColor = vec4(weight_to_rgb(color), 1.0);
#else
finalColor = mix(colorWire, colorEdgeSelect, color);
#endif
diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt
index b67298a6df6..978bd772b6f 100644
--- a/source/blender/editors/animation/CMakeLists.txt
+++ b/source/blender/editors/animation/CMakeLists.txt
@@ -26,8 +26,8 @@ set(INC
../../makesrna
../../windowmanager
../../../../intern/clog
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index bab76911449..6d1ee08d5e9 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -222,7 +222,8 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
rgb_uchar_to_float(r_color, cp);
}
else {
- // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)?
+ /* FIXME: what happens when the indention is 1 greater than what it should be
+ * (due to grouping)? */
int colOfs = 10 - 10 * indent;
UI_GetThemeColorShade3fv(TH_SHADE2, colOfs, r_color);
}
@@ -360,7 +361,7 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale)
offset += (short)(0.7f * U.widget_unit);
/* If not in Action Editor mode, action-groups (and their children)
- * must carry some offset too. */
+ * must carry some offset too. */
}
else if (ac->datatype != ANIMCONT_ACTION) {
offset += (short)(0.7f * U.widget_unit);
@@ -4525,7 +4526,7 @@ static void draw_setting_widget(bAnimContext *ac,
/* get the base icon for the setting */
switch (setting) {
case ACHANNEL_SETTING_VISIBLE: /* visibility eyes */
- //icon = ((enabled) ? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF);
+ // icon = ((enabled) ? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF);
icon = ICON_VISIBLE_IPO_OFF;
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
@@ -4550,13 +4551,13 @@ static void draw_setting_widget(bAnimContext *ac,
break;
case ACHANNEL_SETTING_EXPAND: /* expanded triangle */
- //icon = ((enabled) ? ICON_TRIA_DOWN : ICON_TRIA_RIGHT);
+ // icon = ((enabled) ? ICON_TRIA_DOWN : ICON_TRIA_RIGHT);
icon = ICON_TRIA_RIGHT;
tooltip = TIP_("Make channels grouped under this channel visible");
break;
case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */
- //icon = ((enabled) ? ICON_SOLO_OFF : ICON_SOLO_ON);
+ // icon = ((enabled) ? ICON_SOLO_OFF : ICON_SOLO_ON);
icon = ICON_SOLO_OFF;
tooltip = TIP_(
"NLA Track is the only one evaluated in this animation data-block, with all others "
@@ -4567,7 +4568,7 @@ static void draw_setting_widget(bAnimContext *ac,
case ACHANNEL_SETTING_PROTECT: /* protected lock */
// TODO: what about when there's no protect needed?
- //icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED);
+ // icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED);
icon = ICON_UNLOCKED;
if (ale->datatype != ALE_NLASTRIP) {
@@ -4598,7 +4599,7 @@ static void draw_setting_widget(bAnimContext *ac,
break;
case ACHANNEL_SETTING_PINNED: /* pin icon */
- //icon = ((enabled) ? ICON_PINNED : ICON_UNPINNED);
+ // icon = ((enabled) ? ICON_PINNED : ICON_UNPINNED);
icon = ICON_UNPINNED;
if (ale->type == ANIMTYPE_NLAACTION) {
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index d0eb2d187fd..adc6ec3f6be 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -474,7 +474,8 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
for (ale = anim_data->first; ale; ale = ale->next) {
/* compare data, and type as main way of identifying the channel */
if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) {
- /* we also have to check the ID, this is assigned to, since a block may have multiple users */
+ /* We also have to check the ID, this is assigned to,
+ * since a block may have multiple users. */
/* TODO: is the owner-data more revealing? */
if (ale->id == ale_setting->id) {
match = ale;
@@ -549,8 +550,8 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
if (prevLevel == 0) {
break;
/* otherwise, this level weaves into another sibling hierarchy to the previous one just
- * finished, so skip until we get to the parent of this level
- */
+ * finished, so skip until we get to the parent of this level
+ */
}
else {
continue;
@@ -582,9 +583,10 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
if (level > matchLevel) {
ANIM_channel_setting_set(ac, ale, setting, mode);
/* however, if the level is 'less than or equal to' the channel that was changed,
- * (i.e. the current channel is as important if not more important than the changed channel)
- * then we should stop, since we've found the last one of the children we should flush
- */
+ * (i.e. the current channel is as important if not more important than the changed
+ * channel) then we should stop, since we've found the last one of the children we should
+ * flush
+ */
}
else {
break;
@@ -647,14 +649,28 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
* channel list that are empty, and linger around long after the data they
* are for has disappeared (and probably won't come back).
*/
+ ANIM_remove_empty_action_from_animdata(adt);
+ }
+
+ /* free the F-Curve itself */
+ free_fcurve(fcu);
+}
+
+/* If the action has no F-Curves, unlink it from AnimData if it did not
+ * come from a NLA Strip being tweaked. */
+bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt)
+{
+ if (adt->action != NULL) {
+ bAction *act = adt->action;
+
if (BLI_listbase_is_empty(&act->curves) && (adt->flag & ADT_NLA_EDIT_ON) == 0) {
id_us_min(&act->id);
adt->action = NULL;
+ return true;
}
}
- /* free the F-Curve itself */
- free_fcurve(fcu);
+ return false;
}
/* ************************************************************************** */
@@ -1233,9 +1249,10 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GROUP);
- /* rearrange groups first
- * - the group's channels will only get considered if nothing happened when rearranging the groups
- * i.e. the rearrange function returned 0
+ /* Rearrange groups first:
+ * - The group's channels will only get considered
+ * if nothing happened when rearranging the groups
+ * i.e. the rearrange function returned 0.
*/
do_channels = (rearrange_animchannel_islands(
&act->groups, rearrange_func, mode, ANIMTYPE_GROUP, &anim_data_visible) == 0);
@@ -2514,17 +2531,6 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm
SpaceNla *snla = (SpaceNla *)ac->sl;
View2D *v2d = &ac->ar->v2d;
rctf rectf;
- float ymin, ymax;
-
- /* set initial y extents */
- if (ac->datatype == ANIMCONT_NLA) {
- ymin = (float)(-NLACHANNEL_HEIGHT(snla));
- ymax = 0.0f;
- }
- else {
- ymin = 0.0f;
- ymax = (float)(-ACHANNEL_HEIGHT(ac));
- }
/* convert border-region to view coordinates */
UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin + 2, &rectf.xmin, &rectf.ymin);
@@ -2534,8 +2540,17 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+ float ymax;
+ if (ac->datatype == ANIMCONT_NLA) {
+ ymax = NLACHANNEL_FIRST_TOP(snla);
+ }
+ else {
+ ymax = ACHANNEL_FIRST_TOP(ac);
+ }
+
/* loop over data, doing box select */
for (ale = anim_data.first; ale; ale = ale->next) {
+ float ymin;
if (ac->datatype == ANIMCONT_NLA) {
ymin = ymax - NLACHANNEL_STEP(snla);
}
@@ -2712,32 +2727,25 @@ static int animchannels_channel_get(bAnimContext *ac, const int mval[2])
ar = ac->ar;
v2d = &ar->v2d;
- /* Figure out which channel user clicked in.
- *
- * Note: although channels technically start at (y = ACHANNEL_FIRST),
- * we need to adjust by half a channel's height so that the tops of channels get caught ok.
- * Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use ACHANNEL_HEIGHT_HALF.
- */
+ /* Figure out which channel user clicked in. */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
if (ac->datatype == ANIMCONT_NLA) {
SpaceNla *snla = (SpaceNla *)ac->sl;
- UI_view2d_listview_view_to_cell(v2d,
- NLACHANNEL_NAMEWIDTH,
+ UI_view2d_listview_view_to_cell(NLACHANNEL_NAMEWIDTH,
NLACHANNEL_STEP(snla),
0,
- (float)NLACHANNEL_HEIGHT_HALF(snla),
+ NLACHANNEL_FIRST_TOP(snla),
x,
y,
NULL,
&channel_index);
}
else {
- UI_view2d_listview_view_to_cell(v2d,
- ACHANNEL_NAMEWIDTH,
+ UI_view2d_listview_view_to_cell(ACHANNEL_NAMEWIDTH,
ACHANNEL_STEP(ac),
0,
- (float)ACHANNEL_HEIGHT_HALF(ac),
+ ACHANNEL_FIRST_TOP(ac),
x,
y,
NULL,
@@ -2858,7 +2866,6 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
if (selectmode == SELECT_INVERT) {
/* swap select */
ED_object_base_select(base, BA_INVERT);
- BKE_scene_object_base_flag_sync_from_base(base);
if (adt) {
adt->flag ^= ADT_UI_SELECTED;
@@ -2871,7 +2878,6 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
/* TODO: should this deselect all other types of channels too? */
for (b = view_layer->object_bases.first; b; b = b->next) {
ED_object_base_select(b, BA_DESELECT);
- BKE_scene_object_base_flag_sync_from_base(b);
if (b->object->adt) {
b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
}
@@ -2879,7 +2885,6 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
/* select object now */
ED_object_base_select(base, BA_SELECT);
- BKE_scene_object_base_flag_sync_from_base(base);
if (adt) {
adt->flag |= ADT_UI_SELECTED;
}
@@ -3192,19 +3197,12 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE
selectmode = SELECT_REPLACE;
}
- /* figure out which channel user clicked in
- *
- * Note:
- * although channels technically start at (y = ACHANNEL_FIRST),
- * we need to adjust by half a channel's height so that the tops of channels get caught ok.
- * Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use ACHANNEL_HEIGHT_HALF.
- */
+ /* figure out which channel user clicked in */
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y);
- UI_view2d_listview_view_to_cell(v2d,
- ACHANNEL_NAMEWIDTH,
+ UI_view2d_listview_view_to_cell(ACHANNEL_NAMEWIDTH,
ACHANNEL_STEP(&ac),
0,
- (float)ACHANNEL_HEIGHT_HALF(&ac),
+ ACHANNEL_FIRST_TOP(&ac),
x,
y,
NULL,
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index d7fe326f2ee..5c9f0707aa9 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -377,7 +377,7 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data)
if (ale->update & ANIM_UPDATE_ORDER) {
ale->update &= ~ANIM_UPDATE_ORDER;
if (gpl) {
- //gpencil_sort_frames(gpl);
+ // gpencil_sort_frames(gpl);
}
}
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index d5116858970..61bf7f95340 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -169,7 +169,7 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_ANIM_PREVIEW_RANGE, -25, -30);
/* XXX: Fix this hardcoded color (anim_active) */
- //immUniformColor4f(0.8f, 0.44f, 0.1f, 0.2f);
+ // immUniformColor4f(0.8f, 0.44f, 0.1f, 0.2f);
/* only draw two separate 'curtains' if there's no overlap between them */
if (PSFRA < PEFRA + end_frame_width) {
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 674f530894d..b94d0e3ada7 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -117,7 +117,7 @@ static void animedit_get_yscale_factor(bAnimContext *ac)
if (ac->yscale_fac < 0.1f) {
ac->yscale_fac = 1.0f;
}
- //printf("yscale_fac = %f\n", ac->yscale_fac);
+ // printf("yscale_fac = %f\n", ac->yscale_fac);
}
/* ----------- Private Stuff - Action Editor ------------- */
@@ -136,7 +136,7 @@ static Key *actedit_get_shapekeys(bAnimContext *ac)
}
/* XXX pinning is not available in 'ShapeKey' mode... */
- //if (saction->pin) return NULL;
+ // if (saction->pin) return NULL;
/* shapekey data is stored with geometry data */
key = BKE_key_from_object(ob);
@@ -218,7 +218,7 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
{
/* TODO, other methods to get the mask */
// Sequence *seq = BKE_sequencer_active_get(ac->scene);
- //MovieClip *clip = ac->scene->clip;
+ // MovieClip *clip = ac->scene->clip;
// struct Mask *mask = seq ? seq->mask : NULL;
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
@@ -425,7 +425,8 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
animedit_get_yscale_factor(ac);
/* get data context info */
- // XXX: if the below fails, try to grab this info from context instead... (to allow for scripting)
+ /* XXX: if the below fails, try to grab this info from context instead...
+ * (to allow for scripting). */
return ANIM_animdata_context_getdata(ac);
}
@@ -486,7 +487,8 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
* Quick macro to test for all three above usability tests, performing the appropriate provided
* action for each when the AnimData context is appropriate.
*
- * Priority order for this goes (most important, to least): AnimData blocks, NLA, Drivers, Keyframes.
+ * Priority order for this goes (most important, to least):
+ * AnimData blocks, NLA, Drivers, Keyframes.
*
* For this to work correctly,
* a standard set of data needs to be available within the scope that this
@@ -582,7 +584,8 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
#define ANIMCHANNEL_ACTIVEOK(ale) \
(!(filter_mode & ANIMFILTER_ACTIVE) || !(ale->adt) || (ale->adt->flag & ADT_UI_ACTIVE))
-/* quick macro to test if an anim-channel (F-Curve, Group, etc.) is selected in an acceptable way */
+/* Quick macro to test if an anim-channel (F-Curve, Group, etc.)
+ * is selected in an acceptable way. */
#define ANIMCHANNEL_SELOK(test_func) \
(!(filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) || \
((filter_mode & ANIMFILTER_SEL) && test_func) || \
@@ -1210,12 +1213,13 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads,
*/
for (fcu = first; ((fcu) && (fcu->grp == grp)); fcu = fcu->next) {
/* special exception for Pose-Channel/Sequence-Strip/Node Based F-Curves:
- * - the 'Only Selected' and 'Include Hidden' data filters should be applied to sub-ID data which
- * can be independently selected/hidden, such as Pose-Channels, Sequence Strips, and Nodes.
- * Since these checks were traditionally done as first check for objects, we do the same here
- * - we currently use an 'approximate' method for getting these F-Curves that doesn't require
- * carefully checking the entire path
- * - this will also affect things like Drivers, and also works for Bone Constraints
+ * - The 'Only Selected' and 'Include Hidden' data filters should be applied to sub-ID data
+ * which can be independently selected/hidden, such as Pose-Channels, Sequence Strips,
+ * and Nodes. Since these checks were traditionally done as first check for objects,
+ * we do the same here.
+ * - We currently use an 'approximate' method for getting these F-Curves that doesn't require
+ * carefully checking the entire path.
+ * - This will also affect things like Drivers, and also works for Bone Constraints.
*/
if (ads && owner_id) {
if ((filter_mode & ANIMFILTER_TMP_IGNORE_ONLYSEL) == 0) {
@@ -1320,7 +1324,7 @@ static size_t animfilter_act_group(bAnimContext *ac,
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
- //int ofilter = filter_mode;
+ // int ofilter = filter_mode;
/* if we care about the selection status of the channels,
* but the group isn't expanded (1)...
@@ -1380,7 +1384,7 @@ static size_t animfilter_act_group(bAnimContext *ac,
/* add this group as a channel first */
if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
/* restore original filter mode so that this next step works ok... */
- //filter_mode = ofilter;
+ // filter_mode = ofilter;
/* filter selection of channel specially here again,
* since may be open and not subject to previous test */
@@ -1498,7 +1502,8 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac),
next = nlt->next;
}
- /* if we're in NLA-tweakmode, don't show this track if it was disabled (due to tweaking) for now
+ /* if we're in NLA-tweakmode, don't show this track if it was disabled
+ * (due to tweaking) for now:
* - active track should still get shown though (even though it has disabled flag set)
*/
// FIXME: the channels after should still get drawn, just 'differently',
@@ -1811,7 +1816,8 @@ static size_t animdata_filter_gpencil(bAnimContext *ac,
*/
if ((filter_mode & ANIMFILTER_DATA_VISIBLE) &&
!(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) {
- /* layer visibility - we check both object and base, since these may not be in sync yet */
+ /* Layer visibility - we check both object and base,
+ * since these may not be in sync yet. */
if ((base->flag & BASE_VISIBLE) == 0) {
continue;
}
@@ -2223,7 +2229,8 @@ static size_t animdata_filter_ds_textures(
}
}
- /* firstly check that we actuallly have some textures, by gathering all textures in a temp list */
+ /* Firstly check that we actuallly have some textures,
+ * by gathering all textures in a temp list. */
for (a = 0; a < MAX_MTEX; a++) {
Tex *tex = (mtex[a]) ? mtex[a]->tex : NULL;
@@ -2393,7 +2400,8 @@ static size_t animdata_filter_ds_modifiers(
/* 1) create a temporary "context" containing all the info we have here to pass to the callback
* use to walk through the dependencies of the modifiers
*
- * ! Assumes that all other unspecified values (i.e. accumulation buffers) are zero'd out properly
+ * Assumes that all other unspecified values (i.e. accumulation buffers)
+ * are zero'd out properly!
*/
afm.ac = ac;
afm.ads = ads;
@@ -2915,7 +2923,8 @@ static size_t animdata_filter_dopesheet_scene(
tmp_items += animdata_filter_ds_gpencil(ac, &tmp_data, ads, gpd, filter_mode);
}
- /* TODO: one day, when sequencer becomes its own datatype, perhaps it should be included here */
+ /* TODO: one day, when sequencer becomes its own datatype,
+ * perhaps it should be included here. */
}
END_ANIMFILTER_SUBCHANNELS;
@@ -3148,7 +3157,8 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac,
/* If filtering for channel drawing, we want the objects in alphabetical order,
* to make it easier to predict where items are in the hierarchy
- * - This order only really matters if we need to show all channels in the list (e.g. for drawing)
+ * - This order only really matters
+ * if we need to show all channels in the list (e.g. for drawing).
* (XXX: What about lingering "active" flags? The order may now become unpredictable)
* - Don't do this if this behavior has been turned off (i.e. due to it being too slow)
* - Don't do this if there's just a single object
@@ -3320,7 +3330,8 @@ static size_t animdata_filter_remove_duplis(ListBase *anim_data)
/* check if hash has any record of an entry like this
* - just use ale->data for now, though it would be nicer to involve
- * ale->type in combination too to capture corner cases (where same data performs differently)
+ * ale->type in combination too to capture corner cases
+ * (where same data performs differently)
*/
if (BLI_gset_add(gs, ale->data)) {
/* this entry is 'unique' and can be kept */
@@ -3439,7 +3450,8 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
break;
}
- /* Timeline Mode - Basically the same as dopesheet, except we only have the summary for now */
+ /* Timeline Mode - Basically the same as dopesheet,
+ * except we only have the summary for now */
case ANIMCONT_TIMELINE: {
/* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */
if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index e90599b05c8..66cdae07a36 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -203,7 +203,7 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
float min, max;
/* sanity check */
- //printf("markers = %p - %p, %p\n", markers, markers->first, markers->last);
+ // printf("markers = %p - %p, %p\n", markers, markers->first, markers->last);
if (ELEM(NULL, markers, markers->first, markers->last)) {
*first = 0.0f;
*last = 0.0f;
@@ -361,45 +361,38 @@ void debug_markers_print_list(ListBase *markers)
/* ************* Marker Drawing ************ */
-static void draw_marker_name(const uiFontStyle *fstyle,
- TimeMarker *marker,
- const char *name,
- int cfra,
- const float xpos,
- const float ypixels)
+static void marker_color_get(TimeMarker *marker, unsigned char *color)
{
- unsigned char text_col[4];
- float x, y;
-
- /* minimal y coordinate which wouldn't be occluded by scroll */
- int min_y = 17.0f * UI_DPI_FAC;
-
if (marker->flag & SELECT) {
- UI_GetThemeColor4ubv(TH_TEXT_HI, text_col);
- x = xpos + 4.0f * UI_DPI_FAC;
- y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC;
- y = max_ii(y, min_y);
+ UI_GetThemeColor4ubv(TH_TEXT_HI, color);
}
else {
- UI_GetThemeColor4ubv(TH_TEXT, text_col);
- if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) {
- x = xpos + 8.0f * UI_DPI_FAC;
- y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC;
- y = max_ii(y, min_y);
- }
- else {
- x = xpos + 8.0f * UI_DPI_FAC;
- y = 17.0f * UI_DPI_FAC;
- }
+ UI_GetThemeColor4ubv(TH_TEXT, color);
}
+}
+
+static void draw_marker_name(const uiFontStyle *fstyle,
+ TimeMarker *marker,
+ float marker_x,
+ float text_y)
+{
+ unsigned char text_color[4];
+ marker_color_get(marker, text_color);
+
+ const char *name = marker->name;
#ifdef DURIAN_CAMERA_SWITCH
- if (marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) {
- text_col[3] = 100;
+ if (marker->camera) {
+ Object *camera = marker->camera;
+ name = camera->id.name + 2;
+ if (camera->restrictflag & OB_RESTRICT_RENDER) {
+ text_color[3] = 100;
+ }
}
#endif
- UI_fontstyle_draw_simple(fstyle, x, y, name, text_col);
+ int name_x = marker_x + UI_DPI_ICON_SIZE * 0.6;
+ UI_fontstyle_draw_simple(fstyle, name_x, text_y, name, text_color);
}
static void draw_marker_line(const float color[4], float x, float ymin, float ymax)
@@ -426,29 +419,24 @@ static void draw_marker_line(const float color[4], float x, float ymin, float ym
immUnbindProgram();
}
-/* function to draw markers */
-static void draw_marker(const uiFontStyle *fstyle,
- TimeMarker *marker,
- int cfra,
- int flag,
- /* avoid re-calculating each time */
- const float ypixels,
- const float xscale,
- int height)
+static int marker_get_icon_id(TimeMarker *marker, int flag)
{
- const float xpos = marker->frame * xscale;
+ if (flag & DRAW_MARKERS_LOCAL) {
+ return (marker->flag & ACTIVE) ? ICON_PMARKER_ACT :
+ (marker->flag & SELECT) ? ICON_PMARKER_SEL : ICON_PMARKER;
+ }
#ifdef DURIAN_CAMERA_SWITCH
- const float yoffs = (marker->camera) ? 0.2f * UI_DPI_ICON_SIZE : 0.0f;
-#else
- const float yoffs = 0.0f;
+ else if (marker->camera) {
+ return (marker->flag & SELECT) ? ICON_OUTLINER_OB_CAMERA : ICON_CAMERA_DATA;
+ }
#endif
- int icon_id;
-
- GPU_blend(true);
- GPU_blend_set_func_separate(
- GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+ else {
+ return (marker->flag & SELECT) ? ICON_MARKER_HLT : ICON_MARKER;
+ }
+}
- /* vertical line - dotted */
+static void draw_marker_line_if_necessary(TimeMarker *marker, int flag, int xpos, int height)
+{
#ifdef DURIAN_CAMERA_SWITCH
if ((marker->camera) || (flag & DRAW_MARKERS_LINES))
#else
@@ -463,103 +451,114 @@ static void draw_marker(const uiFontStyle *fstyle,
copy_v4_fl4(color, 0.0f, 0.0f, 0.0f, 0.38f);
}
- draw_marker_line(color, xpos, yoffs + 1.5f * UI_DPI_ICON_SIZE, height);
+ draw_marker_line(color, xpos, UI_DPI_FAC * 20, height);
}
+}
- /* 5 px to offset icon to align properly, space / pixels corrects for zoom */
- if (flag & DRAW_MARKERS_LOCAL) {
- icon_id = (marker->flag & ACTIVE) ? ICON_PMARKER_ACT :
- (marker->flag & SELECT) ? ICON_PMARKER_SEL : ICON_PMARKER;
- }
-#ifdef DURIAN_CAMERA_SWITCH
- else if (marker->camera) {
- icon_id = (marker->flag & SELECT) ? ICON_OUTLINER_OB_CAMERA : ICON_CAMERA_DATA;
- }
-#endif
- else {
- icon_id = (marker->flag & SELECT) ? ICON_MARKER_HLT : ICON_MARKER;
- }
+static void draw_marker(
+ const uiFontStyle *fstyle, TimeMarker *marker, int xpos, int flag, int region_height)
+{
+ GPU_blend(true);
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+
+ draw_marker_line_if_necessary(marker, flag, xpos, region_height);
- UI_icon_draw(xpos - 0.55f * UI_DPI_ICON_SIZE, yoffs + UI_DPI_ICON_SIZE, icon_id);
+ int icon_id = marker_get_icon_id(marker, flag);
+ UI_icon_draw(xpos - 0.55f * UI_DPI_ICON_SIZE, UI_DPI_FAC * 18, icon_id);
GPU_blend(false);
- /* and the marker name too, shifted slightly to the top-right */
-#ifdef DURIAN_CAMERA_SWITCH
- if (marker->camera) {
- draw_marker_name(fstyle, marker, marker->camera->id.name + 2, cfra, xpos, ypixels);
+ float name_y = UI_DPI_FAC * 18;
+ if (marker->flag & SELECT) {
+ name_y += UI_DPI_FAC * 10;
}
- else if (marker->name[0]) {
- draw_marker_name(fstyle, marker, marker->name, cfra, xpos, ypixels);
+ draw_marker_name(fstyle, marker, xpos, name_y);
+}
+
+static void draw_markers_background(rctf *rect)
+{
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+ const unsigned char shade[4] = {0, 0, 0, 16};
+ immUniformColor4ubv(shade);
+
+ GPU_blend(true);
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+
+ immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+
+ GPU_blend(false);
+
+ immUnbindProgram();
+}
+
+static bool marker_is_in_frame_range(TimeMarker *marker, int frame_range[2])
+{
+ if (marker->frame < frame_range[0]) {
+ return false;
}
-#else
- if (marker->name[0]) {
- draw_marker_name(fstyle, marker, marker->name, cfra, xpos, ypixels);
+ if (marker->frame > frame_range[1]) {
+ return false;
}
-#endif
+ return true;
+}
+
+static void get_marker_region_rect(View2D *v2d, rctf *rect)
+{
+ rect->xmin = v2d->cur.xmin;
+ rect->xmax = v2d->cur.xmax;
+ rect->ymin = 0;
+ rect->ymax = UI_MARKER_MARGIN_Y;
+}
+
+static void get_marker_clip_frame_range(View2D *v2d, float xscale, int r_range[2])
+{
+ float font_width_max = (10 * UI_DPI_FAC) / xscale;
+ r_range[0] = v2d->cur.xmin - sizeof(((TimeMarker *)NULL)->name) * font_width_max;
+ r_range[1] = v2d->cur.xmax + font_width_max;
}
/* Draw Scene-Markers in time window */
void ED_markers_draw(const bContext *C, int flag)
{
- const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
ListBase *markers = ED_context_get_markers(C);
- View2D *v2d;
- TimeMarker *marker;
- Scene *scene;
- int select_pass;
- int v2d_clip_range_x[2];
- float font_width_max;
-
- /* cache values */
- float ypixels, xscale, yscale;
-
if (markers == NULL || BLI_listbase_is_empty(markers)) {
return;
}
- scene = CTX_data_scene(C);
- v2d = UI_view2d_fromcontext(C);
- int height = v2d->mask.ymax - v2d->mask.ymin;
-
- if (flag & DRAW_MARKERS_MARGIN) {
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- const unsigned char shade[4] = {0, 0, 0, 16};
- immUniformColor4ubv(shade);
-
- GPU_blend(true);
- GPU_blend_set_func_separate(
- GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+ ARegion *ar = CTX_wm_region(C);
+ View2D *v2d = UI_view2d_fromcontext(C);
- immRectf(pos, v2d->cur.xmin, 0, v2d->cur.xmax, UI_MARKER_MARGIN_Y);
+ rctf markers_region_rect;
+ get_marker_region_rect(v2d, &markers_region_rect);
- GPU_blend(false);
-
- immUnbindProgram();
- }
+ draw_markers_background(&markers_region_rect);
/* no time correction for framelen! space is drawn with old values */
- ypixels = BLI_rcti_size_y(&v2d->mask);
- UI_view2d_scale_get(v2d, &xscale, &yscale);
+ float xscale, dummy;
+ UI_view2d_scale_get(v2d, &xscale, &dummy);
GPU_matrix_push();
GPU_matrix_scale_2f(1.0f / xscale, 1.0f);
- /* x-bounds with offset for text (adjust for long string, avoid checking string width) */
- font_width_max = (10 * UI_DPI_FAC) / xscale;
- v2d_clip_range_x[0] = v2d->cur.xmin - (sizeof(marker->name) * font_width_max);
- v2d_clip_range_x[1] = v2d->cur.xmax + font_width_max;
+ int clip_frame_range[2];
+ get_marker_clip_frame_range(v2d, xscale, clip_frame_range);
- /* loop [unselected, selected] */
- for (select_pass = 0; select_pass <= SELECT; select_pass += SELECT) {
- /* unselected markers are drawn at the first time */
- for (marker = markers->first; marker; marker = marker->next) {
- if ((marker->flag & SELECT) == select_pass) {
- /* bounds check */
- if ((marker->frame >= v2d_clip_range_x[0]) && (marker->frame <= v2d_clip_range_x[1])) {
- draw_marker(fstyle, marker, scene->r.cfra, flag, ypixels, xscale, height);
- }
+ const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
+
+ for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ if ((marker->flag & SELECT) == 0) {
+ if (marker_is_in_frame_range(marker, clip_frame_range)) {
+ draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy);
+ }
+ }
+ }
+ for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ if (marker->flag & SELECT) {
+ if (marker_is_in_frame_range(marker, clip_frame_range)) {
+ draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy);
}
}
}
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 45bb8f3b11e..97ba7132c3d 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -52,6 +52,9 @@
#include "ED_sequencer.h"
#include "ED_util.h"
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
+
#include "anim_intern.h"
/* ********************** frame change operator ***************************/
@@ -88,7 +91,6 @@ static bool change_frame_poll(bContext *C)
/* Set the new frame number */
static void change_frame_apply(bContext *C, wmOperator *op)
{
- Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
float frame = RNA_float_get(op->ptr, "frame");
bool do_snap = RNA_boolean_get(op->ptr, "snap");
@@ -114,7 +116,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
FRAMENUMBER_MIN_CLAMP(CFRA);
/* do updates */
- BKE_sound_seek_scene(bmain, scene);
+ BKE_sound_update_and_seek(CTX_data_main(C), CTX_data_depsgraph(C));
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 34d7fac041f..2a8702802aa 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -1140,7 +1140,7 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot)
/* callbacks */
ot->exec = remove_driver_button_exec;
- //op->poll = ??? // TODO: need to have some driver to be able to do this...
+ // op->poll = ??? // TODO: need to have some driver to be able to do this...
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -1177,7 +1177,7 @@ void ANIM_OT_driver_button_edit(wmOperatorType *ot)
/* callbacks */
ot->exec = edit_driver_button_exec;
- //op->poll = ??? // TODO: need to have some driver to be able to do this...
+ // op->poll = ??? // TODO: need to have some driver to be able to do this...
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -1221,7 +1221,7 @@ void ANIM_OT_copy_driver_button(wmOperatorType *ot)
/* callbacks */
ot->exec = copy_driver_button_exec;
- //op->poll = ??? // TODO: need to have some driver to be able to do this...
+ // op->poll = ??? // TODO: need to have some driver to be able to do this...
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -1270,7 +1270,7 @@ void ANIM_OT_paste_driver_button(wmOperatorType *ot)
/* callbacks */
ot->exec = paste_driver_button_exec;
- //op->poll = ??? // TODO: need to have some driver to be able to do this...
+ // op->poll = ??? // TODO: need to have some driver to be able to do this...
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 22350f997f3..678afef5773 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -715,7 +715,7 @@ static void draw_keylist(View2D *v2d,
float sel_mhcol[4], unsel_mhcol[4];
float ipo_color[4], ipo_color_mix[4];
- /* cache colours first */
+ /* cache colors first */
UI_GetThemeColor4fv(TH_STRIP_SELECT, sel_color);
UI_GetThemeColor4fv(TH_STRIP, unsel_color);
UI_GetThemeColor4fv(TH_DOPESHEET_IPOLINE, ipo_color);
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index 815d4c5f3af..884a8c20b19 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -240,7 +240,8 @@ static short ob_keyframes_loop(KeyframeEditData *ked,
filter = ANIMFILTER_DATA_VISIBLE; // curves only
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- /* loop through each F-Curve, applying the operation as required, but stopping on the first one */
+ /* Loop through each F-Curve, applying the operation as required,
+ * but stopping on the first one. */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) {
ret = 1;
@@ -288,7 +289,8 @@ static short scene_keyframes_loop(KeyframeEditData *ked,
filter = ANIMFILTER_DATA_VISIBLE; // curves only
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- /* loop through each F-Curve, applying the operation as required, but stopping on the first one */
+ /* Loop through each F-Curve, applying the operation as required,
+ * but stopping on the first one. */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) {
ret = 1;
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 4851665c9f3..a0433b49b16 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1071,7 +1071,10 @@ static float *visualkey_get_values(Depsgraph *depsgraph,
/* ------------------------- Insert Key API ------------------------- */
-/* Retrieve current property values to keyframe, possibly applying NLA correction when necessary. */
+/**
+ * Retrieve current property values to keyframe,
+ * possibly applying NLA correction when necessary.
+ */
static float *get_keyframe_values(Depsgraph *depsgraph,
ReportList *reports,
PointerRNA ptr,
@@ -2206,6 +2209,11 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
changed = true;
}
}
+
+ /* Delete the action itself if it is empty. */
+ if (ANIM_remove_empty_action_from_animdata(adt)) {
+ changed = true;
+ }
}
}
CTX_DATA_END;
@@ -2787,8 +2795,10 @@ bool fcurve_is_changed(PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float fra
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...
+/**
+ * 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.
*/
static bool action_frame_has_keyframe(bAction *act, float frame, short filter)
{
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 7362a7e04a1..ab5e3186c47 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -377,7 +377,7 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot)
/* callbacks */
ot->exec = add_keyingset_button_exec;
- //op->poll = ???
+ // op->poll = ???
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -459,7 +459,7 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot)
/* callbacks */
ot->exec = remove_keyingset_button_exec;
- //op->poll = ???
+ // op->poll = ???
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1021,8 +1021,10 @@ static short keyingset_apply_keying_flags(const short base_flags,
return result;
}
-/* Given a KeyingSet and context info (if required), modify keyframes for the channels specified
- * by the KeyingSet. This takes into account many of the different combinations of using KeyingSets.
+/**
+ * Given a KeyingSet and context info (if required),
+ * modify keyframes for the channels specified by the KeyingSet.
+ * This takes into account many of the different combinations of using KeyingSets.
* Returns the number of channels that keyframes were added to
*/
int ANIM_apply_keyingset(
diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt
index 274fa86184d..71c7febe192 100644
--- a/source/blender/editors/armature/CMakeLists.txt
+++ b/source/blender/editors/armature/CMakeLists.txt
@@ -26,9 +26,9 @@ set(INC
../../makesrna
../../windowmanager
../../../../intern/clog
- ../../../../intern/guardedalloc
../../../../intern/eigen
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 4aed4217b6d..6c2d9fe8f42 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -217,8 +217,9 @@ void POSE_OT_propagate(struct wmOperatorType *ot);
/* ******************************************************* */
/* Various Armature Edit/Pose Editing API's */
-/* Ideally, many of these defines would not be needed as everything would be strictly self-contained
- * within each file, but some tools still have a bit of overlap which makes things messy -- Feb 2013
+/* Ideally, many of these defines would not be needed as everything would be strictly
+ * self-contained within each file,
+ * but some tools still have a bit of overlap which makes things messy -- Feb 2013
*/
EditBone *make_boneList(struct ListBase *edbo, struct ListBase *bones, struct Bone *actBone);
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index 6d25fac79f6..083967d5d41 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -328,9 +328,10 @@ void ED_armature_bone_rename(Main *bmain,
/* Fix all animdata that may refer to this bone -
* we can't just do the ones attached to objects,
- * since other ID-blocks may have drivers referring to this bone T29822.
- */
- // XXX: the ID here is for armatures, but most bone drivers are actually on the object instead...
+ * since other ID-blocks may have drivers referring to this bone T29822. */
+
+ /* XXX: the ID here is for armatures,
+ * but most bone drivers are actually on the object instead. */
{
BKE_animdata_fix_paths_rename_all(&arm->id, "pose.bones", oldname, newname);
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index 3401c6ed157..b53ae813f10 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -161,7 +161,7 @@ void ED_operatormacros_armature(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move",
"Extrude",
@@ -170,7 +170,7 @@ void ED_operatormacros_armature(void)
otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
RNA_boolean_set(otmacro->ptr, "forked", false);
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
/* XXX would it be nicer to just be able to have standard extrude_move,
* but set the forked property separate?
@@ -182,7 +182,7 @@ void ED_operatormacros_armature(void)
otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
RNA_boolean_set(otmacro->ptr, "forked", true);
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
}
void ED_keymap_armature(wmKeyConfig *keyconf)
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 037703c50bf..b2ca1d84520 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -296,7 +296,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
/* Get Pose of current armature */
opose = ob_iter->pose;
ob_iter->mode &= ~OB_MODE_POSE;
- //BASACT->flag &= ~OB_MODE_POSE;
+ // BASACT->flag &= ~OB_MODE_POSE;
/* Find the difference matrix */
invert_m4_m4(oimat, ob_active->obmat);
@@ -432,9 +432,10 @@ static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *n
cti->get_constraint_targets(con, &targets);
for (ct = targets.first; ct; ct = ct->next) {
- /* any targets which point to original armature are redirected to the new one only if:
- * - the target isn't origArm/newArm itself
- * - the target is one that can be found in newArm/origArm
+ /* Any targets which point to original armature
+ * are redirected to the new one only if:
+ * - The target isn't origArm/newArm itself.
+ * - The target is one that can be found in newArm/origArm.
*/
if (ct->subtarget[0] != 0) {
if (ct->tar == origArm) {
@@ -611,7 +612,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
oldob = obedit;
oldbase = base_iter;
oldob->mode &= ~OB_MODE_POSE;
- //oldbase->flag &= ~OB_POSEMODE;
+ // oldbase->flag &= ~OB_POSEMODE;
ED_armature_from_edit(bmain, obedit->data);
ED_armature_edit_free(obedit->data);
@@ -763,11 +764,11 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
else if (arm->flag & ARM_MIRROR_EDIT) {
- /* For X-Axis Mirror Editing option, we may need a mirror copy of actbone
- * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
+ /* For X-Axis Mirror Editing option, we may need a mirror copy of actbone:
+ * - If there's a mirrored copy of selbone, try to find a mirrored copy of actbone
* (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R").
- * This is useful for arm-chains, for example parenting lower arm to upper arm
- * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
+ * This is useful for arm-chains, for example parenting lower arm to upper arm.
+ * - If there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
* then just use actbone. Useful when doing upper arm to spine.
*/
actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
@@ -776,10 +777,22 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
}
}
- /* if there is only 1 selected bone, we assume that that is the active bone,
- * since a user will need to have clicked on a bone (thus selecting it) to make it active
- */
- if (CTX_DATA_COUNT(C, selected_editable_bones) <= 1) {
+ /* If there is only 1 selected bone, we assume that that is the active bone,
+ * since a user will need to have clicked on a bone (thus selecting it) to make it active. */
+ bool is_active_only_selected = false;
+ if (actbone->flag & BONE_SELECTED) {
+ is_active_only_selected = true;
+ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) {
+ if (ebone != actbone) {
+ is_active_only_selected = false;
+ break;
+ }
+ }
+ }
+ }
+
+ if (is_active_only_selected) {
/* When only the active bone is selected, and it has a parent,
* connect it to the parent, as that is the only possible outcome.
*/
@@ -792,26 +805,31 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
}
}
else {
- /* Parent 'selected' bones to the active one
- * - the context iterator contains both selected bones and their mirrored copies,
- * so we assume that unselected bones are mirrored copies of some selected bone
- * - since the active one (and/or its mirror) will also be selected, we also need
+ /* Parent 'selected' bones to the active one:
+ * - The context iterator contains both selected bones and their mirrored copies,
+ * so we assume that unselected bones are mirrored copies of some selected bone.
+ * - Since the active one (and/or its mirror) will also be selected, we also need
* to check that we are not trying to operate on them, since such an operation
- * would cause errors
+ * would cause errors.
*/
- /* parent selected bones to the active one */
- CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
- if (ELEM(ebone, actbone, actmirb) == 0) {
- if (ebone->flag & BONE_SELECTED) {
+ /* Parent selected bones to the active one. */
+ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) {
+ if (ebone != actbone) {
bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
}
- else {
- bone_connect_to_new_parent(arm->edbo, ebone, actmirb, val);
+
+ if (arm->flag & ARM_MIRROR_EDIT) {
+ EditBone *ebone_mirror = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
+ if (ebone_mirror && (ebone_mirror->flag & BONE_SELECTED) == 0) {
+ if (ebone_mirror != actmirb) {
+ bone_connect_to_new_parent(arm->edbo, ebone_mirror, actmirb, val);
+ }
+ }
}
}
}
- CTX_DATA_END;
}
/* note, notifier might evolve */
@@ -824,25 +842,29 @@ static int armature_parent_set_invoke(bContext *C,
wmOperator *UNUSED(op),
const wmEvent *UNUSED(event))
{
- EditBone *actbone = CTX_data_active_bone(C);
- uiPopupMenu *pup = UI_popup_menu_begin(
- C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Make Parent"), ICON_NONE);
- uiLayout *layout = UI_popup_menu_layout(pup);
- int allchildbones = 0;
-
- CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
- if (ebone != actbone) {
- if (ebone->parent != actbone) {
- allchildbones = 1;
+ bool all_childbones = false;
+ {
+ Object *ob = CTX_data_edit_object(C);
+ bArmature *arm = ob->data;
+ EditBone *actbone = arm->act_edbone;
+ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) {
+ if (ebone != actbone) {
+ if (ebone->parent != actbone) {
+ all_childbones = true;
+ break;
+ }
+ }
}
}
}
- CTX_DATA_END;
+ uiPopupMenu *pup = UI_popup_menu_begin(
+ C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Make Parent"), ICON_NONE);
+ uiLayout *layout = UI_popup_menu_layout(pup);
uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_CONNECT);
-
- /* ob becomes parent, make the associated menus */
- if (allchildbones) {
+ if (all_childbones) {
+ /* Object becomes parent, make the associated menus. */
uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET);
}
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 95c10b79678..fbbb68d2003 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -867,8 +867,8 @@ static bool armature_edit_select_op_apply(bArmature *arm,
}
/**
- * Perform a selection operation on elements which have been 'touched', use for lasso & border select
- * but can be used elsewhere too.
+ * Perform a selection operation on elements which have been 'touched',
+ * use for lasso & border select but can be used elsewhere too.
*
* Tagging is done via #EditBone.temp.i using: #BONESEL_ROOT, #BONESEL_TIP, #BONESEL_BONE
* And optionally ignoring end-points using the #BONESEL_ROOT, #BONESEL_TIP right shifted 16 bits.
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index fb3fb310b9d..b23081cd6fa 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -466,8 +466,8 @@ static EditBone *make_boneList_rec(ListBase *edbo,
eBone->parent->flag |= BONE_TIPSEL;
}
- /* For connected bones, take care when changing the selection when we have a connected parent,
- * this flag is a copy of '(eBone->parent->flag & BONE_TIPSEL)'. */
+ /* For connected bones, take care when changing the selection when we have a
+ * connected parent, this flag is a copy of '(eBone->parent->flag & BONE_TIPSEL)'. */
eBone->flag |= BONE_ROOTSEL;
}
else {
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index b194650060a..81030c7f199 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -365,7 +365,7 @@ int laplacian_system_solve(LaplacianSystem *sys)
{
sys->variablesdone = false;
- //EIG_linear_solver_print_matrix(sys->context, );
+ // EIG_linear_solver_print_matrix(sys->context, );
return EIG_linear_solver_solve(sys->context);
}
@@ -451,7 +451,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys)
BLI_bvhtree_insert(sys->heat.bvhtree, a, bb, 2);
- //Setup inverse pointers to use on isect.orig
+ // Setup inverse pointers to use on isect.orig
sys->heat.vltree[vtri[0]] = lt;
sys->heat.vltree[vtri[1]] = lt;
sys->heat.vltree[vtri[2]] = lt;
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index cf64210ebdb..954beda7777 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -65,7 +65,7 @@
#include "armature_intern.h"
-#define DEBUG_TIME
+#undef DEBUG_TIME
#include "PIL_time.h"
#ifdef DEBUG_TIME
@@ -197,38 +197,6 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, bool curre
ListBase targets = {NULL, NULL};
bool free_depsgraph = false;
- /* Override depsgraph with a filtered, simpler copy */
- if (!current_frame_only && G.debug_value != -1) {
- DEG_FilterQuery query = {{0}};
-
- DEG_FilterTarget *dft_ob = MEM_callocN(sizeof(DEG_FilterTarget), "DEG_FilterTarget");
- dft_ob->id = &ob->id;
- BLI_addtail(&query.targets, dft_ob);
-
-#ifdef DEBUG_TIME
- TIMEIT_START(filter_pose_depsgraph);
-#endif
-
- depsgraph = DEG_graph_filter(depsgraph, bmain, &query);
-
-#ifdef DEBUG_TIME
- TIMEIT_END(filter_pose_depsgraph);
-#endif
-
- free_depsgraph = true;
- MEM_freeN(dft_ob);
-
-#ifdef DEBUG_TIME
- TIMEIT_START(filter_pose_update);
-#endif
-
- BKE_scene_graph_update_tagged(depsgraph, bmain);
-
-#ifdef DEBUG_TIME
- TIMEIT_END(filter_pose_update);
-#endif
- }
-
/* set flag to force recalc, then grab the relevant bones to target */
ob->pose->avs.recalc |= ANIMVIZ_RECALC_PATHS;
animviz_get_object_motionpaths(ob, &targets);
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 010f1c0e654..7b31897766d 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -77,7 +77,9 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS
}
/* ************************************************************* */
-/* == POSE-LIBRARY TOOL FOR BLENDER ==
+/**
+ * Pose-Library Tool for Blender
+ * =============================
*
* Overview:
* This tool allows animators to store a set of frequently used poses to dump into
@@ -85,13 +87,13 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS
* It acts as a kind of "glorified clipboard for poses", allowing for naming of poses.
*
* Features:
- * - PoseLibs are simply normal Actions
- * - Each "pose" is simply a set of keyframes that occur on a particular frame
- * -> a set of TimeMarkers that belong to each Action, help 'label' where a 'pose' can be
- * found in the Action
+ * - PoseLibs are simply normal Actions.
+ * - Each "pose" is simply a set of keyframes that occur on a particular frame.
+ * - A set of TimeMarkers that belong to each Action, help 'label' where a 'pose' can be
+ * found in the Action.
* - The Scrollwheel or PageUp/Down buttons when used in a special mode or after pressing/holding
- * [a modifier] key, cycles through the poses available for the active pose's poselib, allowing the
- * animator to preview what action best suits that pose
+ * [a modifier] key, cycles through the poses available for the active pose's poselib,
+ * allowing the animator to preview what action best suits that pose.
*/
/* ************************************************************* */
@@ -1453,7 +1455,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case PADMINUS:
case MIDDLEMOUSE:
case MOUSEMOVE:
- //pld->redraw = PL_PREVIEW_REDRAWHEADER;
+ // pld->redraw = PL_PREVIEW_REDRAWHEADER;
ret = OPERATOR_PASS_THROUGH;
break;
@@ -1585,7 +1587,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
*/
case MIDDLEMOUSE:
case MOUSEMOVE:
- //pld->redraw = PL_PREVIEW_REDRAWHEADER;
+ // pld->redraw = PL_PREVIEW_REDRAWHEADER;
ret = OPERATOR_PASS_THROUGH;
break;
@@ -1608,7 +1610,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
}
else {
/* view manipulation (see above) */
- //pld->redraw = PL_PREVIEW_REDRAWHEADER;
+ // pld->redraw = PL_PREVIEW_REDRAWHEADER;
ret = OPERATOR_PASS_THROUGH;
}
break;
@@ -1746,7 +1748,7 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
/* updates */
if (IS_AUTOKEY_MODE(scene, NORMAL)) {
- //remake_action_ipos(ob->action);
+ // remake_action_ipos(ob->action);
}
else {
BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob);
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 79182a89096..d683c599f7b 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -335,12 +335,6 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo
/* next/end */
eVal = evaluate_fcurve(fcu, nextFrameF);
- /* if both values are equal, don't do anything */
- if (IS_EQF(sVal, eVal)) {
- (*val) = sVal;
- return;
- }
-
/* calculate the relative weights of the endpoints */
if (pso->mode == POSESLIDE_BREAKDOWN) {
/* get weights from the percentage control */
@@ -362,9 +356,10 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo
w2 = (w2 / wtot);
}
- /* depending on the mode, calculate the new value
- * - in all of these, the start+end values are multiplied by w2 and w1 (respectively),
- * since multiplication in another order would decrease the value the current frame is closer to
+ /* Depending on the mode, calculate the new value:
+ * - In all of these, the start+end values are multiplied by w2 and w1 (respectively),
+ * since multiplication in another order would decrease
+ * the value the current frame is closer to.
*/
switch (pso->mode) {
case POSESLIDE_PUSH: /* make the current pose more pronounced */
@@ -509,7 +504,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
default:
/* cannot handle */
- //printf("Cannot Pose Slide non-numerical property\n");
+ // printf("Cannot Pose Slide non-numerical property\n");
break;
}
}
@@ -698,9 +693,8 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
}
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_PROPS) && (pfl->oldprops)) {
- /* not strictly a transform, but custom properties contribute to the pose produced in many rigs
- * (e.g. the facial rigs used in Sintel)
- */
+ /* Not strictly a transform, but custom properties contribute
+ * to the pose produced in many rigs (e.g. the facial rigs used in Sintel). */
pose_slide_apply_props(pso, pfl, "[\""); /* dummy " for texteditor bugs */
}
}
@@ -982,35 +976,41 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
case LEFTMOUSE: /* confirm */
case RETKEY:
case PADENTER: {
- /* return to normal cursor and header status */
- ED_area_status_text(pso->sa, NULL);
- WM_cursor_modal_restore(win);
+ if (event->val == KM_PRESS) {
+ /* return to normal cursor and header status */
+ ED_area_status_text(pso->sa, NULL);
+ WM_cursor_modal_restore(win);
- /* insert keyframes as required... */
- pose_slide_autoKeyframe(C, pso);
- pose_slide_exit(op);
+ /* insert keyframes as required... */
+ pose_slide_autoKeyframe(C, pso);
+ pose_slide_exit(op);
- /* done! */
- return OPERATOR_FINISHED;
+ /* done! */
+ return OPERATOR_FINISHED;
+ }
+ break;
}
case ESCKEY: /* cancel */
case RIGHTMOUSE: {
- /* return to normal cursor and header status */
- ED_area_status_text(pso->sa, NULL);
- WM_cursor_modal_restore(win);
+ if (event->val == KM_PRESS) {
+ /* return to normal cursor and header status */
+ ED_area_status_text(pso->sa, NULL);
+ WM_cursor_modal_restore(win);
- /* reset transforms back to original state */
- pose_slide_reset(pso);
+ /* reset transforms back to original state */
+ pose_slide_reset(pso);
- /* depsgraph updates + redraws */
- pose_slide_refresh(C, pso);
+ /* depsgraph updates + redraws */
+ pose_slide_refresh(C, pso);
- /* clean up temp data */
- pose_slide_exit(op);
+ /* clean up temp data */
+ pose_slide_exit(op);
- /* canceled! */
- return OPERATOR_CANCELLED;
+ /* canceled! */
+ return OPERATOR_CANCELLED;
+ }
+ break;
}
/* Percentage Chane... */
@@ -1162,8 +1162,8 @@ static void pose_slide_opdef_properties(wmOperatorType *ot)
1.0f,
"Percentage",
"Weighting factor for which keyframe is favored more",
- 0.3,
- 0.7);
+ 0.0,
+ 1.0);
RNA_def_int(ot->srna,
"prev_frame",
@@ -1254,7 +1254,7 @@ void POSE_OT_push(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
/* Properties */
pose_slide_opdef_properties(ot);
@@ -1316,7 +1316,7 @@ void POSE_OT_relax(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
/* Properties */
pose_slide_opdef_properties(ot);
@@ -1378,7 +1378,7 @@ void POSE_OT_breakdown(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
/* Properties */
pose_slide_opdef_properties(ot);
@@ -1783,7 +1783,7 @@ void POSE_OT_propagate(wmOperatorType *ot)
ot->poll = ED_operator_posemode; /* XXX: needs selected bones! */
/* flag */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
/* properties */
/* TODO: add "fade out" control for tapering off amount of propagation as time goes by? */
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index 45c51897cbf..a1f763ac57d 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -220,24 +220,9 @@ void poseAnim_mapping_free(ListBase *pfLinks)
/* ------------------------- */
/* helper for apply() / reset() - refresh the data */
-void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
+void poseAnim_mapping_refresh(bContext *C, Scene *UNUSED(scene), Object *ob)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- bArmature *arm = (bArmature *)ob->data;
-
- /* old optimize trick... this enforces to bypass the depgraph
- * - note: code copied from transform_generics.c -> recalcData()
- */
- /* FIXME: shouldn't this use the builtin stuff? */
- if ((arm->flag & ARM_DELAYDEFORM) == 0) {
- DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); /* sets recalc flags */
- }
- else {
- BKE_pose_where_is(depsgraph, scene, ob);
- }
-
- /* otherwise animation doesn't get updated */
- DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
}
@@ -342,7 +327,7 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks,
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
+ // ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
ED_pose_recalculate_paths(C, scene, ob, false);
}
}
diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt
index 3df6f3c97d4..8c9309055c8 100644
--- a/source/blender/editors/curve/CMakeLists.txt
+++ b/source/blender/editors/curve/CMakeLists.txt
@@ -26,8 +26,8 @@ set(INC
../../makesrna
../../windowmanager
../../../../intern/clog
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
../../../../extern/curve_fit_nd
)
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c
index 782b093fab4..3d2ac009072 100644
--- a/source/blender/editors/curve/curve_ops.c
+++ b/source/blender/editors/curve/curve_ops.c
@@ -147,7 +147,7 @@ void ED_operatormacros_curve(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "CURVE_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("CURVE_OT_extrude_move",
@@ -156,7 +156,7 @@ void ED_operatormacros_curve(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "CURVE_OT_extrude");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
}
diff --git a/source/blender/editors/gizmo_library/CMakeLists.txt b/source/blender/editors/gizmo_library/CMakeLists.txt
index 8b035d3207d..d9503c4e759 100644
--- a/source/blender/editors/gizmo_library/CMakeLists.txt
+++ b/source/blender/editors/gizmo_library/CMakeLists.txt
@@ -27,9 +27,9 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/eigen
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil/CMakeLists.txt
index 5573c88c710..21f1801f7eb 100644
--- a/source/blender/editors/gpencil/CMakeLists.txt
+++ b/source/blender/editors/gpencil/CMakeLists.txt
@@ -22,13 +22,13 @@ set(INC
../../blenlib
../../blentranslation
../../depsgraph
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index 84dc29afab3..f325422fec7 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -91,12 +91,12 @@ typedef enum eDrawStrokeFlags {
/* ----- Tool Buffer Drawing ------ */
/* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */
-static void gp_draw_stroke_buffer(const tGPspoint *points,
- int totpoints,
- short thickness,
- short dflag,
- short sflag,
- float ink[4])
+static void annotation_draw_stroke_buffer(const tGPspoint *points,
+ int totpoints,
+ short thickness,
+ short dflag,
+ short sflag,
+ float ink[4])
{
int draw_points = 0;
@@ -181,7 +181,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points,
/* --------- 2D Stroke Drawing Helpers --------- */
/* change in parameter list */
-static void gp_calc_2d_stroke_fxy(
+static void annotation_calc_2d_stroke_fxy(
const float pt[3], short sflag, int offsx, int offsy, int winx, int winy, float r_co[2])
{
if (sflag & GP_STROKE_2DSPACE) {
@@ -207,15 +207,15 @@ static void gp_calc_2d_stroke_fxy(
/* ----- Existing Strokes Drawing (3D and Point) ------ */
/* draw a given stroke - just a single dot (only one point) */
-static void gp_draw_stroke_point(const bGPDspoint *points,
- short thickness,
- short UNUSED(dflag),
- short sflag,
- int offsx,
- int offsy,
- int winx,
- int winy,
- const float ink[4])
+static void annotation_draw_stroke_point(const bGPDspoint *points,
+ short thickness,
+ short UNUSED(dflag),
+ short sflag,
+ int offsx,
+ int offsy,
+ int winx,
+ int winy,
+ const float ink[4])
{
const bGPDspoint *pt = points;
@@ -234,7 +234,7 @@ static void gp_draw_stroke_point(const bGPDspoint *points,
/* get 2D coordinates of point */
float co[3] = {0.0f};
- gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co);
+ annotation_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co);
copy_v3_v3(fpt, co);
}
@@ -252,12 +252,12 @@ static void gp_draw_stroke_point(const bGPDspoint *points,
}
/* 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,
- short UNUSED(sflag),
- const float ink[4],
- bool cyclic)
+static void annotation_draw_stroke_3d(const bGPDspoint *points,
+ int totpoints,
+ short thickness,
+ short UNUSED(sflag),
+ const float ink[4],
+ bool cyclic)
{
float curpressure = points[0].pressure;
float cyclic_fpt[3];
@@ -336,16 +336,16 @@ static void gp_draw_stroke_3d(const bGPDspoint *points,
/* ----- Fancy 2D-Stroke Drawing ------ */
/* draw a given stroke in 2d */
-static void gp_draw_stroke_2d(const bGPDspoint *points,
- int totpoints,
- short thickness_s,
- short dflag,
- short sflag,
- int offsx,
- int offsy,
- int winx,
- int winy,
- const float ink[4])
+static void annotation_draw_stroke_2d(const bGPDspoint *points,
+ int totpoints,
+ short thickness_s,
+ short dflag,
+ short sflag,
+ 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;
@@ -374,7 +374,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
immBegin(GPU_PRIM_TRI_STRIP, totpoints * 2 + 4);
/* get x and y coordinates from first point */
- gp_calc_2d_stroke_fxy(&points->x, sflag, offsx, offsy, winx, winy, s0);
+ annotation_calc_2d_stroke_fxy(&points->x, sflag, offsx, offsy, winx, winy, s0);
for (i = 0, pt1 = points, pt2 = points + 1; i < (totpoints - 1); i++, pt1++, pt2++) {
float t0[2], t1[2]; /* tessellated coordinates */
@@ -384,7 +384,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
/* Get x and y coordinates from point2
* (point1 has already been computed in previous iteration). */
- gp_calc_2d_stroke_fxy(&pt2->x, sflag, offsx, offsy, winx, winy, s1);
+ annotation_calc_2d_stroke_fxy(&pt2->x, sflag, offsx, offsy, winx, winy, s1);
/* calculate gradient and normal - 'angle'=(ny/nx) */
m1[1] = s1[1] - s0[1];
@@ -513,7 +513,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
/* ----- Strokes Drawing ------ */
/* Helper for doing all the checks on whether a stroke can be drawn */
-static bool gp_can_draw_stroke(const bGPDstroke *gps, const int dflag)
+static bool annotation_can_draw_stroke(const bGPDstroke *gps, const int dflag)
{
/* skip stroke if it isn't in the right display space for this drawing context */
/* 1) 3D Strokes */
@@ -550,22 +550,22 @@ 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,
- short lthick,
- const float color[4])
+static void annotation_draw_strokes(bGPdata *UNUSED(gpd),
+ bGPDlayer *UNUSED(gpl),
+ const bGPDframe *gpf,
+ int offsx,
+ int offsy,
+ int winx,
+ int winy,
+ int dflag,
+ short lthick,
+ const float color[4])
{
GPU_enable_program_point_size();
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* check if stroke can be drawn */
- if (gp_can_draw_stroke(gps, dflag) == false) {
+ if (annotation_can_draw_stroke(gps, dflag) == false) {
continue;
}
@@ -586,11 +586,11 @@ static void gp_draw_strokes(bGPdata *UNUSED(gpd),
/* 3D Lines - OpenGL primitives-based */
if (gps->totpoints == 1) {
- gp_draw_stroke_point(
+ annotation_draw_stroke_point(
gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy, color);
}
else {
- gp_draw_stroke_3d(
+ annotation_draw_stroke_3d(
gps->points, gps->totpoints, lthick, gps->flag, color, gps->flag & GP_STROKE_CYCLIC);
}
@@ -604,20 +604,20 @@ static void gp_draw_strokes(bGPdata *UNUSED(gpd),
else {
/* 2D Strokes... */
if (gps->totpoints == 1) {
- gp_draw_stroke_point(
+ annotation_draw_stroke_point(
gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy, color);
}
else {
- gp_draw_stroke_2d(gps->points,
- gps->totpoints,
- lthick,
- dflag,
- gps->flag,
- offsx,
- offsy,
- winx,
- winy,
- color);
+ annotation_draw_stroke_2d(gps->points,
+ gps->totpoints,
+ lthick,
+ dflag,
+ gps->flag,
+ offsx,
+ offsy,
+ winx,
+ winy,
+ color);
}
}
}
@@ -626,16 +626,16 @@ static void gp_draw_strokes(bGPdata *UNUSED(gpd),
}
/* Draw selected verts for strokes being edited */
-static void gp_draw_strokes_edit(bGPdata *gpd,
- bGPDlayer *gpl,
- const bGPDframe *gpf,
- int offsx,
- int offsy,
- int winx,
- int winy,
- short dflag,
- short UNUSED(lflag),
- float alpha)
+static void annotation_draw_strokes_edit(bGPdata *gpd,
+ bGPDlayer *gpl,
+ const bGPDframe *gpf,
+ int offsx,
+ int offsy,
+ int winx,
+ int winy,
+ short dflag,
+ short UNUSED(lflag),
+ float alpha)
{
/* if alpha 0 do not draw */
if (alpha == 0.0f) {
@@ -663,7 +663,7 @@ static void gp_draw_strokes_edit(bGPdata *gpd,
/* draw stroke verts */
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* check if stroke can be drawn */
- if (gp_can_draw_stroke(gps, dflag) == false) {
+ if (annotation_can_draw_stroke(gps, dflag) == false) {
continue;
}
@@ -742,7 +742,7 @@ static void gp_draw_strokes_edit(bGPdata *gpd,
}
else {
float co[2];
- gp_calc_2d_stroke_fxy(&pt->x, gps->flag, offsx, offsy, winx, winy, co);
+ annotation_calc_2d_stroke_fxy(&pt->x, gps->flag, offsx, offsy, winx, winy, co);
immVertex2fv(pos, co);
}
}
@@ -770,15 +770,15 @@ static void gp_draw_strokes_edit(bGPdata *gpd,
/* ----- 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)
+static void annotation_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];
@@ -797,7 +797,8 @@ static void gp_draw_onionskins(bGPdata *gpd,
/* 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);
+ annotation_draw_strokes(
+ gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
else {
break;
@@ -808,7 +809,8 @@ static void gp_draw_onionskins(bGPdata *gpd,
/* 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);
+ annotation_draw_strokes(
+ gpd, gpl, gpf->prev, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
}
else {
@@ -829,7 +831,8 @@ static void gp_draw_onionskins(bGPdata *gpd,
/* 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);
+ annotation_draw_strokes(
+ gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
else {
break;
@@ -840,7 +843,8 @@ static void gp_draw_onionskins(bGPdata *gpd,
/* 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);
+ annotation_draw_strokes(
+ gpd, gpl, gpf->next, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
}
else {
@@ -849,7 +853,7 @@ static void gp_draw_onionskins(bGPdata *gpd,
}
/* loop over gpencil data layers, drawing them */
-static void gp_draw_data_layers(
+static void annotation_draw_data_layers(
bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag, float alpha)
{
float ink[4];
@@ -887,23 +891,25 @@ static void gp_draw_data_layers(
/* Draw 'onionskins' (frame left + right) */
if (gpl->onion_flag & GP_LAYER_ONIONSKIN) {
- gp_draw_onionskins(gpd, gpl, gpf, offsx, offsy, winx, winy, cfra, dflag);
+ annotation_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, lthick, ink);
+ annotation_draw_strokes(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, lthick, ink);
- /* Draw verts of selected strokes
+ /* Draw verts of selected strokes:
* - when doing OpenGL renders, we don't want to be showing these, as that ends up flickering
* - locked layers can't be edited, so there's no point showing these verts
* as they will have no bearings on what gets edited
* - only show when in editmode, since operators shouldn't work otherwise
- * (NOTE: doing it this way means that the toggling editmode shows visible change immediately)
+ * (NOTE: doing it this way means that the toggling editmode
+ * shows visible change immediately).
*/
/* XXX: perhaps we don't want to show these when users are drawing... */
if ((G.f & G_FLAG_RENDER_VIEWPORT) == 0 && (gpl->flag & GP_LAYER_LOCKED) == 0 &&
(gpd->flag & GP_DATA_STROKE_EDITMODE)) {
- gp_draw_strokes_edit(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, gpl->flag, alpha);
+ annotation_draw_strokes_edit(
+ gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, gpl->flag, alpha);
}
/* Check if may need to draw the active stroke cache, only if this layer is the active layer
@@ -917,18 +923,18 @@ static void gp_draw_data_layers(
* It should also be noted that sbuffer contains temporary point types
* i.e. tGPspoints NOT bGPDspoints
*/
- gp_draw_stroke_buffer(gpd->runtime.sbuffer,
- gpd->runtime.sbuffer_size,
- lthick,
- dflag,
- gpd->runtime.sbuffer_sflag,
- ink);
+ annotation_draw_stroke_buffer(gpd->runtime.sbuffer,
+ gpd->runtime.sbuffer_size,
+ lthick,
+ dflag,
+ gpd->runtime.sbuffer_sflag,
+ ink);
}
}
}
/* draw a short status message in the top-right corner */
-static void gp_draw_status_text(const bGPdata *gpd, ARegion *ar)
+static void annotation_draw_status_text(const bGPdata *gpd, ARegion *ar)
{
rcti rect;
@@ -977,7 +983,7 @@ static void gp_draw_status_text(const bGPdata *gpd, ARegion *ar)
}
/* draw grease-pencil datablock */
-static void gp_draw_data(
+static void annotation_draw_data(
bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag, float alpha)
{
/* turn on smooth lines (i.e. anti-aliasing) */
@@ -989,7 +995,7 @@ static void gp_draw_data(
GPU_blend(true);
/* draw! */
- gp_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha);
+ annotation_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha);
/* turn off alpha blending, then smooth lines */
GPU_blend(false); // alpha blending
@@ -998,15 +1004,15 @@ static void gp_draw_data(
/* if we have strokes for scenes (3d view)/clips (movie clip editor)
* and objects/tracks, multiple data blocks have to be drawn */
-static void gp_draw_data_all(Scene *scene,
- bGPdata *gpd,
- int offsx,
- int offsy,
- int winx,
- int winy,
- int cfra,
- int dflag,
- const char spacetype)
+static void annotation_draw_data_all(Scene *scene,
+ bGPdata *gpd,
+ int offsx,
+ int offsy,
+ int winx,
+ int winy,
+ int cfra,
+ int dflag,
+ const char spacetype)
{
bGPdata *gpd_source = NULL;
float alpha = 1.0f;
@@ -1022,14 +1028,14 @@ static void gp_draw_data_all(Scene *scene,
}
if (gpd_source) {
- gp_draw_data(gpd_source, offsx, offsy, winx, winy, cfra, dflag, alpha);
+ annotation_draw_data(gpd_source, offsx, offsy, winx, winy, cfra, dflag, alpha);
}
}
/* scene/clip data has already been drawn, only object/track data is drawn here
* if gpd_source == gpd, we don't have any object/track data and we can skip */
if (gpd_source == NULL || (gpd_source && gpd_source != gpd)) {
- gp_draw_data(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha);
+ annotation_draw_data(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha);
}
}
@@ -1106,12 +1112,16 @@ void ED_annotation_draw_2dimage(const bContext *C)
}
/* draw it! */
- gp_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype);
+ annotation_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype);
}
-/* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly
- * Note: this gets called twice - first time with onlyv2d=true to draw 'canvas' strokes,
- * second time with onlyv2d=false for screen-aligned strokes */
+/**
+ * Draw grease-pencil sketches to specified 2d-view
+ * assuming that matrices are already set correctly.
+ *
+ * \note This gets called twice - first time with onlyv2d=true to draw 'canvas' strokes,
+ * second time with onlyv2d=false for screen-aligned strokes.
+ */
void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@ -1130,7 +1140,8 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
}
/* special hack for Image Editor */
- /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */
+ /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way,
+ * so disabled. */
if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) {
dflag |= GP_DRAWDATA_IEDITHACK;
}
@@ -1143,11 +1154,11 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
dflag |= GP_DRAWDATA_NO_ONIONS;
}
- gp_draw_data_all(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype);
+ annotation_draw_data_all(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype);
/* draw status text (if in screen/pixel-space) */
if (!onlyv2d) {
- gp_draw_status_text(gpd, ar);
+ annotation_draw_status_text(gpd, ar);
}
}
@@ -1201,7 +1212,7 @@ void ED_annotation_draw_view3d(
}
/* draw it! */
- gp_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype);
+ annotation_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype);
}
void ED_annotation_draw_ex(
@@ -1209,7 +1220,7 @@ void ED_annotation_draw_ex(
{
int dflag = GP_DRAWDATA_NOSTATUS | GP_DRAWDATA_ONLYV2D;
- gp_draw_data_all(scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype);
+ annotation_draw_data_all(scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype);
}
/* ************************************************** */
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 0363fd6c754..73230e5fb0e 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -285,17 +285,17 @@ static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float pmval[2
return true;
/* check if mouse moved at least certain distance on both axes (best case)
- * - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand
- */
+ * - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand
+ */
}
else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) {
return true;
/* Check if the distance since the last point is significant enough:
- * - Prevents points being added too densely
- * - Distance here doesn't use sqrt to prevent slowness.
- * We should still be safe from overflows though.
- */
+ * - Prevents points being added too densely
+ * - Distance here doesn't use sqrt to prevent slowness.
+ * We should still be safe from overflows though.
+ */
}
else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) {
return true;
@@ -1361,7 +1361,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
if (has_layer_to_erase == false) {
p->status = GP_STATUS_CAPTURE;
- //if (G.debug & G_DEBUG)
+ // if (G.debug & G_DEBUG)
printf("Error: Eraser will not be affecting anything (gpencil_paint_init)\n");
return;
}
@@ -1544,14 +1544,13 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
immUniform1f("dash_width", 12.0f);
immUniform1f("dash_factor", 0.5f);
- imm_draw_circle_wire_2d(
- shdr_pos,
- x,
- y,
- p->radius,
- /* XXX Dashed shader gives bad results with sets of small segments currently,
- * temp hack around the issue. :( */
- max_ii(8, p->radius / 2)); /* was fixed 40 */
+ imm_draw_circle_wire_2d(shdr_pos,
+ x,
+ y,
+ p->radius,
+ /* XXX Dashed shader gives bad results with sets of small segments
+ * currently, temp hack around the issue. :( */
+ max_ii(8, p->radius / 2)); /* was fixed 40 */
immUnbindProgram();
@@ -2205,7 +2204,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
p->ar = ar;
}
- /* we don't pass on key events, GP is used with key-modifiers - prevents Dkey to insert drivers */
+ /* We don't pass on key events, GP is used with key-modifiers -
+ * prevents Dkey to insert drivers. */
if (ISKEYBOARD(event->type)) {
if (ELEM(event->type, LEFTARROWKEY, DOWNARROWKEY, RIGHTARROWKEY, UPARROWKEY, ZKEY)) {
/* allow some keys:
@@ -2233,10 +2233,12 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- //printf("\tGP - handle modal event...\n");
+ // printf("\tGP - handle modal event...\n");
- /* exit painting mode (and/or end current stroke)
- * NOTE: cannot do RIGHTMOUSE (as is standard for canceling) as that would break polyline [#32647]
+ /* Exit painting mode (and/or end current stroke)
+ *
+ * NOTE: cannot do RIGHTMOUSE (as is standard for canceling)
+ * as that would break polyline T32647.
*/
if (ELEM(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY, EKEY)) {
/* exit() ends the current stroke before cleaning up */
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index c54598fd549..ef74aa28b63 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -121,9 +121,15 @@ static void gp_set_point_uniform_color(const bGPDspoint *pt, const float ink[4])
immUniformColor3fvAlpha(ink, alpha);
}
-static void gp_set_point_varying_color(const bGPDspoint *pt, const float ink[4], uint attr_id)
+static void gp_set_point_varying_color(const bGPDspoint *pt,
+ const float ink[4],
+ uint attr_id,
+ bool fix_strength)
{
float alpha = ink[3] * pt->strength;
+ if ((fix_strength) && (alpha >= 0.1f)) {
+ alpha = 1.0f;
+ }
CLAMP(alpha, GPENCIL_STRENGTH_MIN, 1.0f);
immAttr4ub(attr_id, F2UB(ink[0]), F2UB(ink[1]), F2UB(ink[2]), F2UB(alpha));
}
@@ -186,7 +192,7 @@ static void gp_draw_stroke_volumetric_2d(const bGPDspoint *points,
mul_v3_m4v3(fpt, diff_mat, &pt->x);
gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co);
- gp_set_point_varying_color(pt, ink, color);
+ gp_set_point_varying_color(pt, ink, color, false);
immAttr1f(size, pt->pressure * thickness); /* TODO: scale based on view transform */
immVertex2f(pos, co[0], co[1]);
}
@@ -214,7 +220,7 @@ static void gp_draw_stroke_volumetric_3d(const bGPDspoint *points,
const bGPDspoint *pt = points;
for (int i = 0; i < totpoints && pt; i++, pt++) {
- gp_set_point_varying_color(pt, ink, color);
+ gp_set_point_varying_color(pt, ink, color, false);
/* TODO: scale based on view transform */
immAttr1f(size, pt->pressure * thickness);
/* we can adjust size in vertex shader based on view/projection! */
@@ -576,7 +582,7 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
for (int i = 0; i < totpoints; i++, pt++) {
/* first point for adjacency (not drawn) */
if (i == 0) {
- gp_set_point_varying_color(points, ink, attr_id.color);
+ gp_set_point_varying_color(points, ink, attr_id.color, (bool)tgpw->is_fill_stroke);
if ((cyclic) && (totpoints > 2)) {
immAttr1f(attr_id.thickness, max_ff((points + totpoints - 1)->pressure * thickness, 1.0f));
@@ -589,7 +595,7 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
immVertex3fv(attr_id.pos, fpt);
}
/* set point */
- gp_set_point_varying_color(pt, ink, attr_id.color);
+ gp_set_point_varying_color(pt, ink, attr_id.color, (bool)tgpw->is_fill_stroke);
immAttr1f(attr_id.thickness, max_ff(pt->pressure * thickness, 1.0f));
mul_v3_m4v3(fpt, tgpw->diff_mat, &pt->x);
immVertex3fv(attr_id.pos, fpt);
@@ -608,7 +614,9 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
}
/* last adjacency point (not drawn) */
else {
- gp_set_point_varying_color(points + totpoints - 2, ink, attr_id.color);
+ gp_set_point_varying_color(
+ points + totpoints - 2, ink, attr_id.color, (bool)tgpw->is_fill_stroke);
+
immAttr1f(attr_id.thickness, max_ff((points + totpoints - 2)->pressure * thickness, 1.0f));
mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + totpoints - 2)->x);
immVertex3fv(attr_id.pos, fpt);
@@ -693,7 +701,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
pthick = (pt1->pressure * thickness * scalefac);
/* color of point */
- gp_set_point_varying_color(pt1, ink, attr_id.color);
+ gp_set_point_varying_color(pt1, ink, attr_id.color, false);
/* if the first segment, start of segment is segment's normal */
if (i == 0) {
@@ -768,7 +776,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
pthick = (pt2->pressure * thickness * scalefac);
/* color of point */
- gp_set_point_varying_color(pt2, ink, attr_id.color);
+ gp_set_point_varying_color(pt2, ink, attr_id.color, false);
/* calculate points for end of segment */
mt[0] = m2[0] * pthick;
@@ -861,7 +869,9 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
GPU_enable_program_point_size();
- for (bGPDstroke *gps = tgpw->t_gpf->strokes.first; gps; gps = gps->next) {
+ bGPDstroke *gps_init = (tgpw->gps) ? tgpw->gps : tgpw->t_gpf->strokes.first;
+
+ for (bGPDstroke *gps = gps_init; gps; gps = gps->next) {
/* check if stroke can be drawn */
if (gp_can_draw_stroke(gps, tgpw->dflag) == false) {
continue;
@@ -909,7 +919,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
}
/* 3D Fill */
- //if ((dflag & GP_DRAWDATA_FILL) && (gps->totpoints >= 3)) {
+ // if ((dflag & GP_DRAWDATA_FILL) && (gps->totpoints >= 3)) {
if ((gps->totpoints >= 3) && (tgpw->disable_fill != 1)) {
/* set color using material, tint color and opacity */
interp_v3_v3v3(tfill, gp_style->fill_rgba, tgpw->tintcolor, tgpw->tintcolor[3]);
@@ -955,6 +965,14 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
copy_v4_v4(ink, tcolor);
}
}
+
+ /* if used for fill, set opacity to 1 */
+ if (tgpw->is_fill_stroke) {
+ if (ink[3] >= GPENCIL_ALPHA_OPACITY_THRESH) {
+ ink[3] = 1.0f;
+ }
+ }
+
if (gp_style->mode == GP_STYLE_MODE_DOTS) {
/* volumetric stroke drawing */
if (tgpw->disable_fill != 1) {
@@ -1080,6 +1098,10 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
}
}
}
+ /* if only one stroke, exit from loop */
+ if (tgpw->gps) {
+ break;
+ }
}
GPU_disable_program_point_size();
@@ -1126,6 +1148,7 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in
tgpw.gpl = tgpil->gpl;
tgpw.gpf = tgpil->interFrame;
tgpw.t_gpf = tgpil->interFrame;
+ tgpw.gps = NULL;
tgpw.lthick = tgpil->gpl->line_change;
tgpw.opacity = 1.0;
diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index c433b374d4c..6ad89d2e38d 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -480,6 +480,8 @@ static void gpencil_object_vgroup_calc_from_armature(const bContext *C,
*/
gpencil_add_verts_to_dgroups(C, ob, ob_arm, ratio, decay);
}
+
+ DEG_relations_tag_update(CTX_data_main(C));
}
bool ED_gpencil_add_armature_weights(
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index f9a5ff3a0cf..9777a8190c1 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -88,6 +88,7 @@ typedef struct tGP_BrushEditData {
/* Current editor/region/etc. */
/* NOTE: This stuff is mainly needed to handle 3D view projection stuff... */
Depsgraph *depsgraph;
+ struct Main *bmain;
Scene *scene;
Object *object;
@@ -907,6 +908,7 @@ static bool gp_brush_weight_apply(
if (gso->vrgroup == -1) {
if (gso->object) {
BKE_object_defgroup_add(gso->object);
+ DEG_relations_tag_update(gso->bmain);
gso->vrgroup = 0;
}
}
@@ -969,7 +971,7 @@ typedef struct tGPSB_CloneBrushData {
/* for "stamp" mode, the currently pasted brushes */
bGPDstroke **new_strokes;
- /* mapping from colors referenced per stroke, to the new colours in the "pasted" strokes */
+ /** Mapping from colors referenced per stroke, to the new colors in the "pasted" strokes. */
GHash *new_colors;
} tGPSB_CloneBrushData;
@@ -1017,7 +1019,7 @@ static void gp_brush_clone_init(bContext *C, tGP_BrushEditData *gso)
}
/* Init colormap for mapping between the pasted stroke's source color (names)
- * and the final colours that will be used here instead.
+ * and the final colors that will be used here instead.
*/
data->new_colors = gp_copybuf_validate_colormap(C);
}
@@ -1167,7 +1169,8 @@ static bool gpsculpt_brush_apply_clone(bContext *C, tGP_BrushEditData *gso)
}
else {
/* Continuous - Just keep pasting everytime we move */
- /* TODO: The spacing of repeat should be controlled using a "stepsize" or similar property? */
+ /* TODO: The spacing of repeat should be controlled using a
+ * "stepsize" or similar property? */
gp_brush_clone_add(C, gso);
}
}
@@ -1219,6 +1222,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
op->customdata = gso;
gso->depsgraph = CTX_data_depsgraph(C);
+ gso->bmain = CTX_data_main(C);
/* store state */
gso->settings = gpsculpt_get_settings(scene);
gso->gp_brush = gpsculpt_get_brush(scene, is_weight_mode);
@@ -1322,7 +1326,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
gpsculpt_brush_header_set(C, gso);
/* setup cursor drawing */
- //WM_cursor_modal_set(CTX_wm_window(C), BC_CROSSCURSOR);
+ // WM_cursor_modal_set(CTX_wm_window(C), BC_CROSSCURSOR);
if (gso->sa->spacetype != SPACE_VIEW3D) {
ED_gpencil_toggle_brush_cursor(C, true, NULL);
}
@@ -1406,9 +1410,10 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso)
if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
bGPDframe *gpf = gpl->actframe;
- /* Make a new frame to work on if the layer's frame and the current scene frame don't match up
+ /* Make a new frame to work on if the layer's frame
+ * and the current scene frame don't match up:
* - This is useful when animating as it saves that "uh-oh" moment when you realize you've
- * spent too much time editing the wrong frame...
+ * spent too much time editing the wrong frame.
*/
// XXX: should this be allowed when framelock is enabled?
if (gpf->framenum != cfra_eval) {
@@ -2002,7 +2007,7 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
/* Painting mbut release = Stop painting (back to idle) */
case LEFTMOUSE:
- //BLI_assert(event->val == KM_RELEASE);
+ // BLI_assert(event->val == KM_RELEASE);
if (is_modal) {
/* go back to idling... */
gso->is_painting = false;
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index ded663276a4..5afa379e04f 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -79,6 +79,7 @@
#include "ED_view3d.h"
#include "ED_clip.h"
#include "ED_keyframing.h"
+#include "ED_object.h"
#include "gpencil_intern.h"
@@ -328,9 +329,9 @@ static int gp_find_end_of_stroke_idx(tGpTimingData *gtd,
else {
float delta, min, max;
- /* This code ensures that if the first gaps have been shorter than average gap_duration,
- * next gaps will tend to be longer (i.e. try to recover the lateness), and vice-versa!
- */
+ /* This code ensures that if the first gaps
+ * have been shorter than average gap_duration, next gaps
+ * will tend to be longer (i.e. try to recover the lateness), and vice-versa! */
delta = delta_time - (gtd->gap_duration * (*nbr_done_gaps));
/* Clamp min between [-gap_randomness, 0.0], with lower delta giving higher min */
@@ -963,10 +964,10 @@ static void gp_stroke_to_bezier(bContext *C,
/* Create "link points" */
/* About "zero-radius" point interpolations:
- * - If we have at least two points in current curve (most common case), we linearly extrapolate
- * the last segment to get the first point (p1) position and timing.
- * - If we do not have those (quite odd, but may happen), we linearly interpolate the last point
- * with the first point of the current stroke.
+ * - If we have at least two points in current curve (most common case),
+ * we linearly extrapolate the last segment to get the first point (p1) position and timing.
+ * - If we do not have those (quite odd, but may happen),
+ * we linearly interpolate the last point with the first point of the current stroke.
*
* The same goes for the second point,
* first segment of the current stroke is "negatively" extrapolated
@@ -1395,9 +1396,7 @@ static void gp_layer_to_curve(bContext *C,
}
}
- /* set the layer and select */
- base_new->flag |= SELECT;
- BKE_scene_object_base_flag_sync_from_base(base_new);
+ ED_object_base_select(base_new, BA_SELECT);
}
/* --- */
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 5ac8cc1761f..463c2144276 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -619,7 +619,7 @@ static void gp_duplicate_points(const bGPDstroke *gps,
else if (i == gps->totpoints - 1) {
len = i - start_idx + 1;
}
- //printf("copying from %d to %d = %d\n", start_idx, i, len);
+ // printf("copying from %d to %d = %d\n", start_idx, i, len);
/* make copies of the relevant data */
if (len) {
@@ -1069,7 +1069,8 @@ void ED_gpencil_strokes_copybuf_free(void)
gp_strokes_copypastebuf.first = gp_strokes_copypastebuf.last = NULL;
}
-/* Ensure that destination datablock has all the colours the pasted strokes need
+/**
+ * Ensure that destination datablock has all the colors the pasted strokes need.
* Helper function for copy-pasting strokes
*/
GHash *gp_copybuf_validate_colormap(bContext *C)
@@ -1211,7 +1212,7 @@ void GPENCIL_OT_copy(wmOperatorType *ot)
ot->poll = gp_stroke_edit_poll;
/* flags */
- //ot->flag = OPTYPE_REGISTER;
+ // ot->flag = OPTYPE_REGISTER;
}
/* --------------------- */
@@ -2211,7 +2212,8 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf,
/* Watch out for special case where No islands = All points selected = Delete Stroke only */
if (num_islands) {
- /* there are islands, so create a series of new strokes, adding them before the "next" stroke */
+ /* There are islands, so create a series of new strokes,
+ * adding them before the "next" stroke. */
int idx;
bGPDstroke *new_stroke = NULL;
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 616db4b73f7..96f405fab2f 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -455,7 +455,7 @@ static void get_pixel(const ImBuf *ibuf, const int idx, float r_col[4])
/* set pixel data (rgba) at index */
static void set_pixel(ImBuf *ibuf, int idx, const float col[4])
{
- //BLI_assert(idx <= ibuf->x * ibuf->y);
+ // BLI_assert(idx <= ibuf->x * ibuf->y);
if (ibuf->rect) {
uint *rrect = &ibuf->rect[idx];
uchar ccol[4];
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index fce8fa79217..db4c601709c 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -362,7 +362,7 @@ void ED_operatormacros_gpencil(void)
WM_operatortype_macro_define(ot, "GPENCIL_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_boolean_set(otmacro->ptr, "gpencil_strokes", true);
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
/* Extrude + Move = Interactively add new points */
@@ -373,7 +373,7 @@ void ED_operatormacros_gpencil(void)
WM_operatortype_macro_define(ot, "GPENCIL_OT_extrude");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_boolean_set(otmacro->ptr, "gpencil_strokes", true);
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index f985ade9c7e..b1b29356060 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -372,10 +372,10 @@ static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float mvalo[2
return true;
/* Check if the distance since the last point is significant enough:
- * - Prevents points being added too densely
- * - Distance here doesn't use sqrt to prevent slowness.
- * We should still be safe from overflows though.
- */
+ * - Prevents points being added too densely
+ * - Distance here doesn't use sqrt to prevent slowness.
+ * We should still be safe from overflows though.
+ */
}
else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) {
return true;
@@ -1205,10 +1205,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
gp_randomize_stroke(gps, brush, p->rng);
}
- /* smooth stroke after subdiv - only if there's something to do
- * for each iteration, the factor is reduced to get a better smoothing without changing too much
- * the original stroke
- */
+ /* Smooth stroke after subdiv - only if there's something to do for each iteration,
+ * the factor is reduced to get a better smoothing
+ * without changing too much the original stroke. */
if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) &&
(brush->gpencil_settings->draw_smoothfac > 0.0f)) {
float reduce = 0.0f;
@@ -2320,14 +2319,13 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
immUniform1f("dash_width", 12.0f);
immUniform1f("dash_factor", 0.5f);
- imm_draw_circle_wire_2d(
- shdr_pos,
- x,
- y,
- p->radius,
- /* XXX Dashed shader gives bad results with sets of small segments currently,
- * temp hack around the issue. :( */
- max_ii(8, p->radius / 2)); /* was fixed 40 */
+ imm_draw_circle_wire_2d(shdr_pos,
+ x,
+ y,
+ p->radius,
+ /* XXX Dashed shader gives bad results with sets of small segments
+ * currently, temp hack around the issue. :( */
+ max_ii(8, p->radius / 2)); /* was fixed 40 */
immUnbindProgram();
@@ -2718,6 +2716,8 @@ static void gpencil_draw_apply_event(
PointerRNA itemptr;
float mousef[2];
int tablet = 0;
+ bool is_speed_guide = ((guide->use_guide) &&
+ (p->brush && (p->brush->gpencil_tool == GPAINT_TOOL_DRAW)));
/* convert from window-space to area-space mouse coordinates
* add any x,y override position for fake events
@@ -2727,7 +2727,7 @@ static void gpencil_draw_apply_event(
p->shift = event->shift;
/* verify direction for straight lines */
- if ((guide->use_guide) ||
+ if ((is_speed_guide) ||
((event->alt > 0) && (RNA_boolean_get(op->ptr, "disable_straight") == false))) {
if (p->straight == 0) {
int dx = (int)fabsf(p->mval[0] - p->mvali[0]);
@@ -2825,7 +2825,7 @@ static void gpencil_draw_apply_event(
/* special exception for grid snapping
* it requires direction which needs at least two points
*/
- if (!ELEM(p->paintmode, GP_PAINTMODE_ERASER, GP_PAINTMODE_SET_CP) && guide->use_guide &&
+ if (!ELEM(p->paintmode, GP_PAINTMODE_ERASER, GP_PAINTMODE_SET_CP) && is_speed_guide &&
guide->use_snapping && (guide->type == GP_GUIDE_GRID)) {
p->flags |= GP_PAINTFLAG_REQ_VECTOR;
}
@@ -2853,9 +2853,9 @@ static void gpencil_draw_apply_event(
}
/* check if stroke is straight or guided */
- if ((p->paintmode != GP_PAINTMODE_ERASER) && ((p->straight) || (guide->use_guide))) {
+ if ((p->paintmode != GP_PAINTMODE_ERASER) && ((p->straight) || (is_speed_guide))) {
/* guided stroke */
- if (guide->use_guide) {
+ if (is_speed_guide) {
switch (guide->type) {
default:
case GP_GUIDE_CIRCULAR: {
@@ -3474,7 +3474,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- /* we don't pass on key events, GP is used with key-modifiers - prevents Dkey to insert drivers */
+ /* We don't pass on key events, GP is used with key-modifiers -
+ * prevents Dkey to insert drivers. */
if (ISKEYBOARD(event->type)) {
if (ELEM(event->type, LEFTARROWKEY, DOWNARROWKEY, RIGHTARROWKEY, UPARROWKEY, ZKEY)) {
/* allow some keys:
@@ -3506,10 +3507,12 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- //printf("\tGP - handle modal event...\n");
+ // printf("\tGP - handle modal event...\n");
- /* exit painting mode (and/or end current stroke)
- * NOTE: cannot do RIGHTMOUSE (as is standard for canceling) as that would break polyline [#32647]
+ /* Exit painting mode (and/or end current stroke).
+ *
+ * NOTE: cannot do RIGHTMOUSE (as is standard for canceling)
+ * as that would break polyline T32647.
*/
/* if polyline and release shift must cancel */
if ((ELEM(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY, EKEY)) ||
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 365fb319b3b..ba806022d3e 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -294,7 +294,7 @@ typedef enum eGP_SelectGrouped {
/* TODO: All with same prefix -
* Useful for isolating all layers for a particular character for instance. */
- /* TODO: All with same appearance - colour/opacity/volumetric/fills ? */
+ /* TODO: All with same appearance - color/opacity/volumetric/fills ? */
} eGP_SelectGrouped;
/* ----------------------------------- */
@@ -1298,6 +1298,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
bool deselect = RNA_boolean_get(op->ptr, "deselect");
bool toggle = RNA_boolean_get(op->ptr, "toggle");
bool whole = RNA_boolean_get(op->ptr, "entire_strokes");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
int mval[2] = {0};
@@ -1360,15 +1361,18 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* Abort if nothing hit... */
if (ELEM(NULL, hit_stroke, hit_point)) {
+ if (deselect_all) {
+ /* since left mouse select change, deselect all if click outside any hit */
+ deselect_all_selected(C);
- /* 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);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
- /* 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);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+ return OPERATOR_FINISHED;
+ }
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c
index bf077d528dd..7b57dacd3e4 100644
--- a/source/blender/editors/gpencil/gpencil_undo.c
+++ b/source/blender/editors/gpencil/gpencil_undo.c
@@ -68,7 +68,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name)
gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
if (step == 1) { /* undo */
- //printf("\t\tGP - undo step\n");
+ // printf("\t\tGP - undo step\n");
if (cur_node->prev) {
if (!name || STREQ(cur_node->name, name)) {
cur_node = cur_node->prev;
@@ -77,7 +77,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name)
}
}
else if (step == -1) {
- //printf("\t\tGP - redo step\n");
+ // printf("\t\tGP - redo step\n");
if (cur_node->next) {
if (!name || STREQ(cur_node->name, name)) {
cur_node = cur_node->next;
@@ -134,7 +134,7 @@ void gpencil_undo_push(bGPdata *gpd)
{
bGPundonode *undo_node;
- //printf("\t\tGP - undo push\n");
+ // printf("\t\tGP - undo push\n");
if (cur_node) {
/* remove all un-done nodes from stack */
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 0d920641c5d..129bd01574c 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -1689,14 +1689,13 @@ void ED_gpencil_brush_draw_eraser(Brush *brush, int x, int y)
immUniform1f("dash_width", 12.0f);
immUniform1f("dash_factor", 0.5f);
- imm_draw_circle_wire_2d(
- shdr_pos,
- x,
- y,
- radius,
- /* XXX Dashed shader gives bad results with sets of small segments currently,
- * temp hack around the issue. :( */
- max_ii(8, radius / 2)); /* was fixed 40 */
+ imm_draw_circle_wire_2d(shdr_pos,
+ x,
+ y,
+ radius,
+ /* XXX Dashed shader gives bad results with sets of small segments
+ * currently, temp hack around the issue. :( */
+ max_ii(8, radius / 2)); /* was fixed 40 */
immUnbindProgram();
@@ -2514,7 +2513,7 @@ void ED_gpencil_select_toggle_all(bContext *C, int action)
case SEL_SELECT:
pt->flag |= GP_SPOINT_SELECT;
break;
- //case SEL_DESELECT:
+ // case SEL_DESELECT:
// pt->flag &= ~GP_SPOINT_SELECT;
// break;
case SEL_INVERT:
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index c88277c2ea5..7d4b6dbeea2 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -121,8 +121,8 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
/* Image buffer drawing functions, with display transform
*
- * The view and display settings can either be specified manually, or retrived
- * from the context with the _ctx variations.
+ * The view and display settings can either be specified manually,
+ * or retrieved from the context with the '_ctx' variations.
*
* For better performance clipping coordinates can be specified so parts of the
* image outside the view are skipped. */
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 3a9539ee52c..6342a8b26d9 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -276,7 +276,8 @@ typedef enum eAnim_Update_Flags {
typedef enum eAnimFilter_Flags {
/** data which channel represents is fits the dopesheet filters
* (i.e. scene visibility criteria) */
- // XXX: it's hard to think of any examples where this *ISN'T* the case... perhaps becomes implicit?
+ /* XXX: it's hard to think of any examples where this *ISN'T* the case...
+ * perhaps becomes implicit?. */
ANIMFILTER_DATA_VISIBLE = (1 << 0),
/** channel is visible within the channel-list hierarchy
* (i.e. F-Curves within Groups in ActEdit) */
@@ -402,11 +403,13 @@ typedef enum eAnimFilter_Flags {
/* -------------- Channel Defines -------------- */
/* channel heights */
-#define ACHANNEL_FIRST(ac) (-0.8f * (ac)->yscale_fac * U.widget_unit)
+#define ACHANNEL_FIRST_TOP(ac) (-0.4f * (ac)->yscale_fac * U.widget_unit)
#define ACHANNEL_HEIGHT(ac) (0.8f * (ac)->yscale_fac * U.widget_unit)
-#define ACHANNEL_HEIGHT_HALF(ac) (0.4f * (ac)->yscale_fac * U.widget_unit)
#define ACHANNEL_SKIP (0.1f * U.widget_unit)
#define ACHANNEL_STEP(ac) (ACHANNEL_HEIGHT(ac) + ACHANNEL_SKIP)
+/* Additional offset to give some room at the end. */
+#define ACHANNEL_TOT_HEIGHT(ac, item_amount) \
+ (-ACHANNEL_FIRST_TOP(ac) + ACHANNEL_STEP(ac) * (item_amount + 1))
/* channel widths */
#define ACHANNEL_NAMEWIDTH (10 * U.widget_unit)
@@ -417,13 +420,14 @@ typedef enum eAnimFilter_Flags {
/* -------------- NLA Channel Defines -------------- */
/* NLA channel heights */
-#define NLACHANNEL_FIRST (-0.8f * U.widget_unit)
+#define NLACHANNEL_FIRST_TOP(snla) (-0.4f * U.widget_unit)
#define NLACHANNEL_HEIGHT(snla) \
((snla && (snla->flag & SNLA_NOSTRIPCURVES)) ? (0.8f * U.widget_unit) : (1.2f * U.widget_unit))
-#define NLACHANNEL_HEIGHT_HALF(snla) \
- ((snla && (snla->flag & SNLA_NOSTRIPCURVES)) ? (0.4f * U.widget_unit) : (0.6f * U.widget_unit))
#define NLACHANNEL_SKIP (0.1f * U.widget_unit)
#define NLACHANNEL_STEP(snla) (NLACHANNEL_HEIGHT(snla) + NLACHANNEL_SKIP)
+/* Additional offset to give some room at the end. */
+#define NLACHANNEL_TOT_HEIGHT(snla, item_amount) \
+ (-NLACHANNEL_FIRST_TOP(snla) + NLACHANNEL_STEP(snla) * (item_amount + 1))
/* channel widths */
#define NLACHANNEL_NAMEWIDTH (10 * U.widget_unit)
@@ -611,6 +615,9 @@ void ANIM_set_active_channel(bAnimContext *ac,
* as appropriate according to animation context */
void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, struct AnimData *adt, struct FCurve *fcu);
+/* Unlink the action from animdata if it's empty. */
+bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt);
+
/* ************************************************ */
/* DRAWING API */
/* anim_draw.c */
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index ba5a6a8a339..5bd806b3dbf 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -71,9 +71,6 @@ void ED_space_image_scopes_update(const struct bContext *C,
void ED_space_image_paint_update(struct Main *bmain,
struct wmWindowManager *wm,
struct Scene *scene);
-void ED_space_image_uv_sculpt_update(struct Main *bmain,
- struct wmWindowManager *wm,
- struct Scene *scene);
void ED_image_get_uv_aspect(struct Image *ima, struct ImageUser *iuser, float *aspx, float *aspy);
void ED_image_mouse_pos(struct SpaceImage *sima,
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 543b2a5781f..264eb6abdf1 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -142,6 +142,13 @@ void ED_area_do_mgs_subscribe_for_tool_header(const struct bContext *C,
struct ScrArea *sa,
struct ARegion *ar,
struct wmMsgBus *mbus);
+void ED_area_do_mgs_subscribe_for_tool_ui(const struct bContext *C,
+ struct WorkSpace *workspace,
+ struct Scene *scene,
+ struct bScreen *screen,
+ struct ScrArea *sa,
+ struct ARegion *ar,
+ struct wmMsgBus *mbus);
/* message bus */
void ED_region_message_subscribe(struct bContext *C,
diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h
index 3cbeab247ef..c515d501a8d 100644
--- a/source/blender/editors/include/ED_screen_types.h
+++ b/source/blender/editors/include/ED_screen_types.h
@@ -108,15 +108,29 @@ typedef struct AZone {
float alpha;
} AZone;
-/* actionzone type */
+/** Action-Zone Type: #AZone.type */
enum {
- /* corner widgets for splitting areas */
+ /**
+ * Corner widgets for:
+ * - Splitting areas.
+ * - Swapping areas (Ctrl).
+ * - Copying the area into a new window (Shift).
+ */
AZONE_AREA = 1,
- /* when a region is collapsed, draw a handle to expose */
+ /**
+ * Use for region show/hide state:
+ * - When a region is collapsed, draw a handle to expose.
+ * - When a region is expanded, use the action zone to resize the region.
+ */
AZONE_REGION,
- /* when in editor fullscreen draw a corner to go to normal mode */
+ /**
+ * Used when in editor fullscreen draw a corner to return to normal mode.
+ */
AZONE_FULLSCREEN,
- /* Hotspot azone around scrollbars to show/hide them. */
+ /**
+ * Hotspot azone around scroll-bars to show/hide them.
+ * Only show the scroll-bars when the cursor is close.
+ */
AZONE_REGION_SCROLL,
};
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index 9259afd1d5f..8dd2dab5209 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -178,7 +178,6 @@ void ED_uvedit_add_simple_uvs(struct Main *bmain, struct Scene *scene, struct Ob
/* uvedit_draw.c */
void ED_image_draw_cursor(struct ARegion *ar, const float cursor[2]);
void ED_uvedit_draw_main(struct SpaceImage *sima,
- struct ARegion *ar,
struct Scene *scene,
struct ViewLayer *view_layer,
struct Object *obedit,
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index caa202c46a8..fd51419a3ee 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -54,6 +54,7 @@ struct RenderEngineType;
struct Scene;
struct ScrArea;
struct View3D;
+struct View3DShading;
struct ViewContext;
struct ViewLayer;
struct WorkSpace;
@@ -584,16 +585,6 @@ void ED_view3d_draw_setup_view(struct wmWindow *win,
float winmat[4][4],
const struct rcti *rect);
-enum {
- V3D_OFSDRAW_NONE = (0),
-
- V3D_OFSDRAW_USE_FULL_SAMPLE = (1 << 0),
-
- /* Only works with ED_view3d_draw_offscreen_imbuf_simple(). */
- V3D_OFSDRAW_USE_GPENCIL = (1 << 1),
- V3D_OFSDRAW_USE_CAMERA_DOF = (1 << 2),
-};
-
struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Depsgraph *depsgraph,
struct Scene *scene,
int drawtype,
@@ -610,6 +601,7 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Depsgraph *depsgraph,
char err_out[256]);
struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Depsgraph *depsgraph,
struct Scene *scene,
+ struct View3DShading *shading_override,
int drawtype,
struct Object *camera,
int width,
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index 2f624007c98..b4d345a3344 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -139,12 +139,12 @@ DEF_ICON_BLANK(145)
DEF_ICON_BLANK(146)
DEF_ICON(SCRIPT)
DEF_ICON_MODIFIER(PARTICLES)
-DEF_ICON(PHYSICS)
-DEF_ICON(SPEAKER)
+DEF_ICON_MODIFIER(PHYSICS)
+DEF_ICON_OBJECT_DATA(SPEAKER)
DEF_ICON_BLANK(151)
DEF_ICON(TOOL_SETTINGS)
-DEF_ICON(SHADERFX)
-DEF_ICON(MODIFIER)
+DEF_ICON_MODIFIER(SHADERFX)
+DEF_ICON_MODIFIER(MODIFIER)
DEF_ICON_BLANK(155)
DEF_ICON_BLANK(156)
DEF_ICON_BLANK(157)
@@ -163,7 +163,7 @@ DEF_ICON(FILEBROWSER)
DEF_ICON(IMAGE)
DEF_ICON(INFO)
DEF_ICON(SEQUENCE)
-DEF_ICON(TEXT)
+DEF_ICON_OBJECT_DATA(TEXT)
DEF_ICON_BLANK(174)
DEF_ICON(SOUND)
DEF_ICON(ACTION)
@@ -214,24 +214,24 @@ DEF_ICON_BLANK(77b)
DEF_ICON(SCENE_DATA)
DEF_ICON(RENDERLAYERS)
DEF_ICON_SHADING(WORLD_DATA)
-DEF_ICON(OBJECT_DATA)
-DEF_ICON(MESH_DATA)
-DEF_ICON(CURVE_DATA)
-DEF_ICON(META_DATA)
-DEF_ICON(LATTICE_DATA)
-DEF_ICON_SHADING(LIGHT_DATA)
+DEF_ICON_OBJECT(OBJECT_DATA)
+DEF_ICON_OBJECT_DATA(MESH_DATA)
+DEF_ICON_OBJECT_DATA(CURVE_DATA)
+DEF_ICON_OBJECT_DATA(META_DATA)
+DEF_ICON_OBJECT_DATA(LATTICE_DATA)
+DEF_ICON_OBJECT_DATA(LIGHT_DATA)
DEF_ICON_SHADING(MATERIAL_DATA)
DEF_ICON_SHADING(TEXTURE_DATA)
DEF_ICON(ANIM_DATA)
-DEF_ICON(CAMERA_DATA)
-DEF_ICON(PARTICLE_DATA)
+DEF_ICON_OBJECT_DATA(CAMERA_DATA)
+DEF_ICON_OBJECT_DATA(PARTICLE_DATA)
DEF_ICON(LIBRARY_DATA_DIRECT)
DEF_ICON_COLLECTION(GROUP)
-DEF_ICON(ARMATURE_DATA)
+DEF_ICON_OBJECT_DATA(ARMATURE_DATA)
DEF_ICON(COMMUNITY)
-DEF_ICON(BONE_DATA)
+DEF_ICON_OBJECT_DATA(BONE_DATA)
DEF_ICON_MODIFIER(CONSTRAINT)
-DEF_ICON(SHAPEKEY_DATA)
+DEF_ICON_OBJECT_DATA(SHAPEKEY_DATA)
DEF_ICON_MODIFIER(CONSTRAINT_BONE)
DEF_ICON(CAMERA_STEREO)
DEF_ICON(PACKAGE)
@@ -245,8 +245,8 @@ DEF_ICON(FILE)
DEF_ICON(FCURVE)
DEF_ICON(FONT_DATA)
DEF_ICON(RENDER_RESULT)
-DEF_ICON(SURFACE_DATA)
-DEF_ICON(EMPTY_DATA)
+DEF_ICON_OBJECT_DATA(SURFACE_DATA)
+DEF_ICON_OBJECT_DATA(EMPTY_DATA)
DEF_ICON(PRESET)
DEF_ICON(RENDER_ANIMATION)
DEF_ICON(RENDER_STILL)
@@ -254,7 +254,7 @@ DEF_ICON(LIBRARY_DATA_BROKEN)
DEF_ICON(BOIDS)
DEF_ICON(STRANDS)
DEF_ICON(LIBRARY_DATA_INDIRECT)
-DEF_ICON(GREASEPENCIL)
+DEF_ICON_OBJECT_DATA(GREASEPENCIL)
DEF_ICON_SHADING(LINE_DATA)
DEF_ICON(LIBRARY_DATA_OVERRIDE)
DEF_ICON(GROUP_BONE)
@@ -363,11 +363,11 @@ DEF_ICON(MESH_TORUS)
DEF_ICON(MESH_CONE)
DEF_ICON(MESH_CAPSULE)
DEF_ICON(EMPTY_SINGLE_ARROW)
-DEF_ICON_SHADING(LIGHT_POINT)
-DEF_ICON_SHADING(LIGHT_SUN)
-DEF_ICON_SHADING(LIGHT_SPOT)
-DEF_ICON_SHADING(LIGHT_HEMI)
-DEF_ICON_SHADING(LIGHT_AREA)
+DEF_ICON_OBJECT_DATA(LIGHT_POINT)
+DEF_ICON_OBJECT_DATA(LIGHT_SUN)
+DEF_ICON_OBJECT_DATA(LIGHT_SPOT)
+DEF_ICON_OBJECT_DATA(LIGHT_HEMI)
+DEF_ICON_OBJECT_DATA(LIGHT_AREA)
DEF_ICON(CUBE)
DEF_ICON(SPHERE)
DEF_ICON(CONE)
@@ -393,9 +393,9 @@ DEF_ICON(CURVE_BEZCIRCLE)
DEF_ICON(CURVE_NCURVE)
DEF_ICON(CURVE_NCIRCLE)
DEF_ICON(CURVE_PATH)
-DEF_ICON_SHADING(LIGHTPROBE_CUBEMAP)
-DEF_ICON_SHADING(LIGHTPROBE_PLANAR)
-DEF_ICON_SHADING(LIGHTPROBE_GRID)
+DEF_ICON_OBJECT_DATA(LIGHTPROBE_CUBEMAP)
+DEF_ICON_OBJECT_DATA(LIGHTPROBE_PLANAR)
+DEF_ICON_OBJECT_DATA(LIGHTPROBE_GRID)
DEF_ICON_BLANK(406)
DEF_ICON_BLANK(407)
DEF_ICON(COLOR_RED)
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index d6cfe7aea1f..18960853011 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -520,6 +520,7 @@ bool UI_but_is_tool(const uiBut *but);
#define UI_but_is_decorator(but) ((but)->func == ui_but_anim_decorate_cb)
bool UI_block_is_empty(const uiBlock *block);
+bool UI_block_can_add_separator(const uiBlock *block);
/* interface_region_menu_popup.c */
/**
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 18962f9d9da..af94889a1bb 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -92,6 +92,7 @@ typedef enum ThemeColorID {
TH_VERTEX_UNREFERENCED,
TH_VERTEX_SIZE,
TH_OUTLINE_WIDTH,
+ TH_OBCENTER_DIA,
TH_EDGE,
TH_EDGE_SELECT,
TH_EDGE_SEAM,
@@ -356,7 +357,7 @@ void UI_GetThemeColorType4fv(int colorid, int spacetype, float col[4]);
void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4]);
void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]);
-// get four colour values ranged between 0 and 255; includes the alpha channel
+// get four color values ranged between 0 and 255; includes the alpha channel
void UI_GetThemeColorShadeAlpha4ubv(int colorid,
int coloffset,
int alphaoffset,
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index a16c1efd6cf..064951d40ed 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -56,40 +56,7 @@ enum eView2D_CommonViewTypes {
V2D_COMMONVIEW_PANELS_UI,
};
-/* ---- Defines for Scroller/Grid Arguments ----- */
-
-/* 'dummy' argument to pass when argument is irrelevant */
-#define V2D_ARG_DUMMY -1
-
-/* Grid units */
-enum eView2D_Units {
- /* for drawing time */
- V2D_UNIT_SECONDS = 0,
- V2D_UNIT_FRAMES,
- V2D_UNIT_FRAMESCALE,
-
- /* for drawing values */
- V2D_UNIT_VALUES,
-};
-
-/* clamping of grid values to whole numbers */
-enum eView2D_Clamp {
- V2D_GRID_NOCLAMP = 0,
- V2D_GRID_CLAMP,
-};
-
-/* flags for grid-lines to draw */
-enum eView2D_Gridlines {
- V2D_HORIZONTAL_LINES = (1 << 0),
- V2D_VERTICAL_LINES = (1 << 1),
- V2D_HORIZONTAL_AXIS = (1 << 2),
- V2D_VERTICAL_AXIS = (1 << 3),
- V2D_HORIZONTAL_FINELINES = (1 << 4),
-
- V2D_GRIDLINES_MAJOR = (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS | V2D_HORIZONTAL_LINES |
- V2D_HORIZONTAL_AXIS),
- V2D_GRIDLINES_ALL = (V2D_GRIDLINES_MAJOR | V2D_HORIZONTAL_FINELINES),
-};
+/* ---- Defines for Scroller Arguments ----- */
/* ------ Defines for Scrollers ----- */
@@ -124,7 +91,6 @@ enum eView2D_Gridlines {
/* Type definitions: */
struct View2D;
-struct View2DGrid;
struct View2DScrollers;
struct ARegion;
@@ -135,7 +101,6 @@ struct bScreen;
struct rctf;
struct wmKeyConfig;
-typedef struct View2DGrid View2DGrid;
typedef struct View2DScrollers View2DScrollers;
/* ----------------------------------------- */
@@ -159,62 +124,60 @@ bool UI_view2d_tab_set(struct View2D *v2d, int tab);
void UI_view2d_zoom_cache_reset(void);
/* view matrix operations */
-void UI_view2d_view_ortho(struct View2D *v2d);
+void UI_view2d_view_ortho(const struct View2D *v2d);
void UI_view2d_view_orthoSpecial(struct ARegion *ar, struct View2D *v2d, const bool xaxis);
void UI_view2d_view_restore(const struct bContext *C);
/* grid drawing */
-View2DGrid *UI_view2d_grid_calc(struct Scene *scene,
- struct View2D *v2d,
- short xunits,
- short xclamp,
- short yunits,
- short yclamp,
- int winx,
- int winy);
-void UI_view2d_grid_draw(struct View2D *v2d, View2DGrid *grid, int flag);
void UI_view2d_constant_grid_draw(struct View2D *v2d, float step);
void UI_view2d_multi_grid_draw(
struct View2D *v2d, int colorid, float step, int level_size, int totlevels);
-void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy);
-void UI_view2d_grid_draw_numbers_horizontal(const struct Scene *scene,
- const struct View2D *v2d,
- const View2DGrid *grid,
- const struct rcti *rect,
- int unit,
- bool whole_numbers_only);
-void UI_view2d_grid_draw_numbers_vertical(const struct Scene *scene,
- const struct View2D *v2d,
- const View2DGrid *grid,
- const struct rcti *rect,
- int unit,
- float text_offset);
-void UI_view2d_grid_free(View2DGrid *grid);
+
+void UI_view2d_draw_lines_y__values(const struct View2D *v2d);
+void UI_view2d_draw_lines_x__values(const struct View2D *v2d);
+void UI_view2d_draw_lines_x__discrete_values(const struct View2D *v2d);
+void UI_view2d_draw_lines_x__discrete_time(const struct View2D *v2d, const struct Scene *scene);
+void UI_view2d_draw_lines_x__discrete_frames_or_seconds(const struct View2D *v2d,
+ const struct Scene *scene,
+ bool display_seconds);
+void UI_view2d_draw_lines_x__frames_or_seconds(const struct View2D *v2d,
+ const struct Scene *scene,
+ bool display_seconds);
+
+float UI_view2d_grid_resolution_x__frames_or_seconds(const struct View2D *v2d,
+ const struct Scene *scene,
+ bool display_seconds);
+float UI_view2d_grid_resolution_y__values(const struct View2D *v2d);
+
+/* scale indicator text drawing */
+void UI_view2d_draw_scale_y__values(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect,
+ int colorid);
+void UI_view2d_draw_scale_y__block(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect,
+ int colorid);
+void UI_view2d_draw_scale_x__discrete_frames_or_seconds(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect,
+ const struct Scene *scene,
+ bool display_seconds,
+ int colorid);
+void UI_view2d_draw_scale_x__frames_or_seconds(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect,
+ const struct Scene *scene,
+ bool display_seconds,
+ int colorid);
/* scrollbar drawing */
-View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C,
- struct View2D *v2d,
- const struct rcti *mask_custom,
- short xunits,
- short xclamp,
- short yunits,
- short yclamp);
-void UI_view2d_scrollers_draw(const struct bContext *C,
- struct View2D *v2d,
- View2DScrollers *scrollers);
+View2DScrollers *UI_view2d_scrollers_calc(struct View2D *v2d, const struct rcti *mask_custom);
+void UI_view2d_scrollers_draw(struct View2D *v2d, View2DScrollers *scrollers);
void UI_view2d_scrollers_free(View2DScrollers *scrollers);
/* list view tools */
-void UI_view2d_listview_cell_to_view(struct View2D *v2d,
- float columnwidth,
- float rowheight,
- float startx,
- float starty,
- int column,
- int row,
- struct rctf *rect);
-void UI_view2d_listview_view_to_cell(struct View2D *v2d,
- float columnwidth,
+void UI_view2d_listview_view_to_cell(float columnwidth,
float rowheight,
float startx,
float starty,
@@ -222,15 +185,6 @@ void UI_view2d_listview_view_to_cell(struct View2D *v2d,
float viewy,
int *column,
int *row);
-void UI_view2d_listview_visible_cells(struct View2D *v2d,
- float columnwidth,
- float rowheight,
- float startx,
- float starty,
- int *column_min,
- int *column_max,
- int *row_min,
- int *row_max);
/* coordinate conversion */
float UI_view2d_region_to_view_x(const struct View2D *v2d, float x);
diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt
index 622f89b1f87..6ab1761e7f8 100644
--- a/source/blender/editors/interface/CMakeLists.txt
+++ b/source/blender/editors/interface/CMakeLists.txt
@@ -30,8 +30,8 @@ set(INC
../../makesrna
../../python
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
@@ -72,6 +72,7 @@ set(SRC
interface_widgets.c
resources.c
view2d.c
+ view2d_draw.c
view2d_ops.c
interface_eyedropper_intern.h
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index a5abbb2b86f..42f4b4495c3 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1299,10 +1299,10 @@ static bool ui_but_event_property_operator_string(const bContext *C,
}
}
else {
- //puts("other id");
+ // puts("other id");
}
- //printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(prop), data_path);
+ // printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(prop), data_path);
}
/* we have a datapath! */
@@ -1615,7 +1615,7 @@ void ui_fontscale(short *points, float aspect)
/* for some reason scaling fonts goes too fast compared to widget size */
/* XXX not true anymore? (ton) */
- //aspect = sqrt(aspect);
+ // aspect = sqrt(aspect);
pointsf /= aspect;
if (aspect > 1.0f) {
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index b6d9863f9b5..748d6e6c183 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -148,7 +148,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
if (prop) {
prop = IDP_CopyProperty(prop);
}
- WM_keymap_properties_reset(kmi, prop);
+ WM_keymap_item_properties_reset(kmi, prop);
/* update and get pointers again */
WM_keyconfig_update(wm);
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 671a004f9fe..640d5127446 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1610,16 +1610,10 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
/* Drawing the checkerboard. */
- immUniform4f("color1",
- UI_ALPHA_CHECKER_DARK / 255.0f,
- UI_ALPHA_CHECKER_DARK / 255.0f,
- UI_ALPHA_CHECKER_DARK / 255.0f,
- 1.0f);
- immUniform4f("color2",
- UI_ALPHA_CHECKER_LIGHT / 255.0f,
- UI_ALPHA_CHECKER_LIGHT / 255.0f,
- UI_ALPHA_CHECKER_LIGHT / 255.0f,
- 1.0f);
+ const float checker_dark = UI_ALPHA_CHECKER_DARK / 255.0f;
+ const float checker_light = UI_ALPHA_CHECKER_LIGHT / 255.0f;
+ immUniform4f("color1", checker_dark, checker_dark, checker_dark, 1.0f);
+ immUniform4f("color2", checker_light, checker_light, checker_light, 1.0f);
immUniform1i("size", 8);
immRectf(pos_id, x1, y1, x1 + sizex, rect->ymax);
immUnbindProgram();
@@ -1804,12 +1798,12 @@ static void ui_draw_but_curve_grid(
1.0f);
immBegin(GPU_PRIM_LINES, (int)line_count * 2);
- while (fx < rect->xmax) {
+ while (fx <= rect->xmax) {
immVertex2f(pos, fx, rect->ymin);
immVertex2f(pos, fx, rect->ymax);
fx += dx;
}
- while (fy < rect->ymax) {
+ while (fy <= rect->ymax) {
immVertex2f(pos, rect->xmin, fy);
immVertex2f(pos, rect->xmax, fy);
fy += dy;
@@ -1849,6 +1843,17 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons
cumap = (CurveMapping *)but->poin;
}
+ /* calculate offset and zoom */
+ float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&cumap->curr);
+ float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&cumap->curr);
+ float offsx = cumap->curr.xmin - (1.0f / zoomx);
+ float offsy = cumap->curr.ymin - (1.0f / zoomy);
+
+ /* exit early if too narrow */
+ if (zoomx == 0.0f) {
+ return;
+ }
+
CurveMap *cuma = &cumap->cm[cumap->cur];
/* need scissor test, curve can draw outside of boundary */
@@ -1867,12 +1872,6 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons
BLI_rcti_size_x(&scissor_new),
BLI_rcti_size_y(&scissor_new));
- /* calculate offset and zoom */
- float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&cumap->curr);
- float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&cumap->curr);
- float offsx = cumap->curr.xmin - (1.0f / zoomx);
- float offsy = cumap->curr.ymin - (1.0f / zoomy);
-
/* Do this first to not mess imm context */
if (but->a1 == UI_GRAD_H) {
/* magic trigger for curve backgrounds */
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 608ef69c4cc..111dfe01319 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3797,7 +3797,7 @@ static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *dat
#endif
/* this makes adjacent blocks auto open from now on */
- //if (but->block->auto_open == 0) {
+ // if (but->block->auto_open == 0) {
// but->block->auto_open = 1;
//}
}
@@ -3949,6 +3949,9 @@ static int ui_do_but_HOTKEYEVT(bContext *C,
if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
return WM_UI_HANDLER_CONTINUE;
}
+ else if (event->type == UNKNOWNKEY) {
+ return WM_UI_HANDLER_CONTINUE;
+ }
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
/* only cancel if click outside the button */
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 4b66461e186..7e295f83390 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1826,15 +1826,14 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
ui_id_icon_render(C, id, true);
}
else {
- WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
const EnumPropertyItem *items = NULL;
ePaintMode paint_mode = PAINT_MODE_INVALID;
ScrArea *sa = CTX_wm_area(C);
char space_type = sa->spacetype;
- /* When in an unsupported space. */
- if (!ELEM(space_type, SPACE_VIEW3D, SPACE_IMAGE)) {
- space_type = workspace->tools_space_type;
+ /* Fallback to 3D view. */
+ if (space_type == SPACE_PROPERTIES) {
+ space_type = SPACE_VIEW3D;
}
/* XXX: this is not nice, should probably make brushes
@@ -1856,17 +1855,11 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
}
}
else if (space_type == SPACE_IMAGE) {
- int sima_mode;
if (sa->spacetype == space_type) {
- SpaceImage *sima = sa->spacedata.first;
- sima_mode = sima->mode;
- }
- else {
- sima_mode = workspace->tools_mode;
- }
-
- if (sima_mode == SI_MODE_PAINT) {
- paint_mode = PAINT_MODE_TEXTURE_2D;
+ const SpaceImage *sima = sa->spacedata.first;
+ if (sima->mode == SI_MODE_PAINT) {
+ paint_mode = PAINT_MODE_TEXTURE_2D;
+ }
}
}
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index cfedd40bfd1..15e507483ad 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -304,10 +304,14 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool
layout->item.flag |= UI_ITEM_MIN;
}
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
- /* it may seem odd that the icon only adds (unit_x / 4)
- * but taking margins into account its fine */
- return (UI_fontstyle_string_width(fstyle, name) +
- (unit_x * ((compact ? 1.25f : 1.50f) + (icon ? 0.25f : 0.0f))));
+ float margin = compact ? 1.25 : 1.50;
+ if (icon) {
+ /* It may seem odd that the icon only adds (unit_x / 4)
+ * but taking margins into account its fine, except
+ * in compact mode a bit more margin is required. */
+ margin += compact ? 0.35 : 0.25;
+ }
+ return UI_fontstyle_string_width(fstyle, name) + (unit_x * margin);
}
else {
return unit_x * 10;
@@ -840,7 +844,7 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
/* Separate items, potentially with a label. */
if (next_item->identifier) {
/* Item without identifier but with name:
- * Add group label for the following items. */
+ * Add group label for the following items. */
if (item->name) {
if (!is_first) {
uiItemS(block->curlayout);
@@ -2968,6 +2972,9 @@ void uiItemS_ex(uiLayout *layout, float factor)
{
uiBlock *block = layout->root->block;
bool is_menu = ui_block_is_menu(block);
+ if (is_menu && !UI_block_can_add_separator(block)) {
+ return;
+ }
int space = (is_menu) ? 0.45f * UI_UNIT_X : 0.3f * UI_UNIT_X;
space *= factor;
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index ae28c09b7e2..87e58a4b3b5 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -701,11 +701,10 @@ void ui_draw_aligned_panel(uiStyle *style,
const bool is_closed_x = (panel->flag & PNL_CLOSEDX) ? true : false;
const bool is_closed_y = (panel->flag & PNL_CLOSEDY) ? true : false;
const bool is_subpanel = (panel->type && panel->type->parent);
- const bool show_drag =
- (!is_subpanel &&
- /* FIXME(campbell): currently no background means floating panel which can't be dragged.
- * This may be changed in future. */
- show_background);
+ const bool show_drag = (!is_subpanel &&
+ /* FIXME(campbell): currently no background means floating panel which
+ * can't be dragged. This may be changed in future. */
+ show_background);
if (panel->paneltab) {
return;
@@ -1672,7 +1671,7 @@ static void ui_handle_panel_header(
if (mx <= block->rect.xmax - 8 - PNL_ICON) {
button = 2;
}
- //else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) {
+ // else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) {
// button = 1;
//}
}
@@ -2064,7 +2063,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
BLF_enable(fontid, BLF_ROTATION);
BLF_rotation(fontid, M_PI_2);
- //UI_fontstyle_set(&style->widget);
+ // UI_fontstyle_set(&style->widget);
ui_fontscale(&fstyle_points, aspect / (U.pixelsize * 1.1f));
BLF_size(fontid, fstyle_points, U.dpi);
@@ -2569,7 +2568,7 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
* is very hard to control and use, and has no real benefit." - BillRey
* Aligorith, 2009Sep
*/
- //test_add_new_tabs(ar); // also copies locations of tabs in dragged panel
+ // test_add_new_tabs(ar); // also copies locations of tabs in dragged panel
check_panel_overlap(ar, NULL); /* clears */
}
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index e1f91be1631..b0fd0cdc35f 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -473,6 +473,15 @@ bool UI_block_is_empty(const uiBlock *block)
return true;
}
+bool UI_block_can_add_separator(const uiBlock *block)
+{
+ if (ui_block_is_menu(block) && !ui_block_is_pie_menu(block)) {
+ const uiBut *but = block->buttons.last;
+ return (but && !ELEM(but->type, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR));
+ }
+ return true;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index 110c8827849..f149ccd626c 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -257,6 +257,8 @@ static void ui_block_free_func_POPOVER(uiPopupBlockHandle *UNUSED(handle), void
uiPopupBlockHandle *ui_popover_panel_create(
bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg)
{
+ wmWindow *window = CTX_wm_window(C);
+
/* Create popover, buttons are created from callback. */
uiPopover *pup = MEM_callocN(sizeof(uiPopover), __func__);
pup->but = but;
@@ -271,7 +273,11 @@ uiPopupBlockHandle *ui_popover_panel_create(
pup->menu_arg = arg;
#ifdef USE_UI_POPOVER_ONCE
- pup->is_once = true;
+ {
+ /* Ideally this would be passed in. */
+ const wmEvent *event = window->eventstate;
+ pup->is_once = (event->type == LEFTMOUSE) && (event->val == KM_PRESS);
+ }
#endif
/* Create popup block. */
@@ -283,7 +289,6 @@ uiPopupBlockHandle *ui_popover_panel_create(
/* Add handlers. If attached to a button, the button will already
* add a modal handler and pass on events. */
if (!but) {
- wmWindow *window = CTX_wm_window(C);
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
WM_event_add_mousemove(C);
handle->popup = true;
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c
index 11b2e069d6c..c4bcd7074d8 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.c
@@ -236,10 +236,13 @@ static void ui_popup_block_position(wmWindow *window,
}
/* Compute offset based on direction. */
- int offset_x = 0, offset_y = 0;
+ float offset_x = 0, offset_y = 0;
+
+ /* Ensure buttons don't come between the parent button and the popup, see: T63566. */
+ const float offset_overlap = max_ff(U.pixelsize, 1.0f);
if (dir1 == UI_DIR_LEFT) {
- offset_x = butrct.xmin - block->rect.xmax;
+ offset_x = (butrct.xmin - block->rect.xmax) + offset_overlap;
if (dir2 == UI_DIR_UP) {
offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING;
}
@@ -248,7 +251,7 @@ static void ui_popup_block_position(wmWindow *window,
}
}
else if (dir1 == UI_DIR_RIGHT) {
- offset_x = butrct.xmax - block->rect.xmin;
+ offset_x = (butrct.xmax - block->rect.xmin) - offset_overlap;
if (dir2 == UI_DIR_UP) {
offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING;
}
@@ -257,7 +260,7 @@ static void ui_popup_block_position(wmWindow *window,
}
}
else if (dir1 == UI_DIR_UP) {
- offset_y = butrct.ymax - block->rect.ymin;
+ offset_y = (butrct.ymax - block->rect.ymin) - offset_overlap;
if (dir2 == UI_DIR_RIGHT) {
offset_x = butrct.xmax - block->rect.xmax + center_x;
}
@@ -271,7 +274,7 @@ static void ui_popup_block_position(wmWindow *window,
}
}
else if (dir1 == UI_DIR_DOWN) {
- offset_y = butrct.ymin - block->rect.ymax;
+ offset_y = (butrct.ymin - block->rect.ymax) + offset_overlap;
if (dir2 == UI_DIR_RIGHT) {
offset_x = butrct.xmax - block->rect.xmax + center_x;
}
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index 930f9e3fe1f..251bc86a3f5 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -598,7 +598,7 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but
winx = WM_window_pixels_x(win);
// winy = WM_window_pixels_y(win); /* UNUSED */
- //wm_window_get_size(win, &winx, &winy);
+ // wm_window_get_size(win, &winx, &winy);
if (rect_i.xmax > winx) {
/* super size */
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index 017b7dea352..4a9c7b689c1 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -1063,7 +1063,7 @@ static ARegion *ui_tooltip_create_with_data(bContext *C,
field->geom.x_pos = x_pos;
}
- //fontw *= aspect;
+ // fontw *= aspect;
BLF_disable(data->fstyle.uifont_id, font_flag);
BLF_disable(blf_mono_font, font_flag);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index bbff2c16636..e96141eaa05 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -798,7 +798,7 @@ static void template_ID(bContext *C,
char name[UI_MAX_NAME_STR];
const bool user_alert = (id->us <= 0);
- //text_idbutton(id, name);
+ // text_idbutton(id, name);
name[0] = '\0';
but = uiDefButR(block,
UI_BTYPE_TEXT,
@@ -4282,7 +4282,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL);
/* curve itself */
- size = uiLayoutGetWidth(layout);
+ size = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
row = uiLayoutRow(layout, false);
uiDefBut(
block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, bg, 0, "");
@@ -4997,7 +4997,7 @@ static void uilist_filter_items_default(struct uiList *ui_list,
dyn_data->items_shown++;
do_order = order_by_name;
}
- //printf("%s: '%s' matches '%s'\n", __func__, name, filter);
+ // printf("%s: '%s' matches '%s'\n", __func__, name, filter);
}
else if (filter_exclude) {
dyn_data->items_shown++;
@@ -5321,16 +5321,16 @@ void uiTemplateList(uiLayout *layout,
dyn_data->items_len = dyn_data->items_shown = RNA_property_collection_length(dataptr, prop);
}
else {
- //printf("%s: filtering...\n", __func__);
+ // printf("%s: filtering...\n", __func__);
filter_items(ui_list, C, dataptr, propname);
- //printf("%s: filtering done.\n", __func__);
+ // printf("%s: filtering done.\n", __func__);
}
items_shown = dyn_data->items_shown;
if (items_shown >= 0) {
bool activei_mapping_pending = true;
items_ptr = MEM_mallocN(sizeof(_uilist_item) * items_shown, __func__);
- //printf("%s: items shown: %d.\n", __func__, items_shown);
+ // printf("%s: items shown: %d.\n", __func__, items_shown);
RNA_PROP_BEGIN (dataptr, itemptr, prop) {
if (!dyn_data->items_filter_flags ||
((dyn_data->items_filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude)) {
@@ -5342,7 +5342,7 @@ void uiTemplateList(uiLayout *layout,
else {
ii = order_reverse ? items_shown - ++idx : idx++;
}
- //printf("%s: ii: %d\n", __func__, ii);
+ // printf("%s: ii: %d\n", __func__, ii);
items_ptr[ii].item = itemptr;
items_ptr[ii].org_idx = i;
items_ptr[ii].flt_flag = dyn_data->items_filter_flags ? dyn_data->items_filter_flags[i] :
@@ -6711,17 +6711,18 @@ void uiTemplateCacheFile(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
uiItemR(row, &fileptr, "override_frame", 0, "Override Frame", ICON_NONE);
row = uiLayoutRow(layout, false);
- uiLayoutSetEnabled(row, RNA_boolean_get(&fileptr, "override_frame"));
+ uiLayoutSetActive(row, RNA_boolean_get(&fileptr, "override_frame"));
uiItemR(row, &fileptr, "frame", 0, "Frame", ICON_NONE);
row = uiLayoutRow(layout, false);
uiItemR(row, &fileptr, "frame_offset", 0, "Frame Offset", ICON_NONE);
+ uiLayoutSetActive(row, !RNA_boolean_get(&fileptr, "is_sequence"));
row = uiLayoutRow(layout, false);
uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);
row = uiLayoutRow(layout, false);
- uiLayoutSetEnabled(row, (sbuts->mainb == BCONTEXT_CONSTRAINT));
+ uiLayoutSetActive(row, (sbuts->mainb == BCONTEXT_CONSTRAINT));
uiItemR(row, &fileptr, "scale", 0, "Scale", ICON_NONE);
/* TODO: unused for now, so no need to expose. */
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 32ec7910b36..a9cd2f9cee1 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -2787,8 +2787,8 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
/* menu is 2nd level or deeper */
if (flag & UI_BLOCK_POPUP) {
- //rect->ymin -= 4.0;
- //rect->ymax += 4.0;
+ // rect->ymin -= 4.0;
+ // rect->ymax += 4.0;
}
else if (direction == UI_DIR_DOWN) {
roundboxalign = (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
@@ -4686,7 +4686,7 @@ 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 */
+ // rcti disablerect = *rect; /* rect gets clipped smaller for text */
int roundboxalign, state, drawflag;
bool disabled = false;
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index fa56dc04143..8ed7dd87e9f 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -366,6 +366,10 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
case TH_OUTLINE_WIDTH:
cp = &ts->outline_width;
break;
+ case TH_OBCENTER_DIA:
+ cp = &ts->obcenter_dia;
+ break;
+ break;
case TH_EDGE:
cp = ts->edge;
break;
@@ -1352,7 +1356,9 @@ bool UI_GetIconThemeColor4fv(int colorid, float col[4])
/* Only colored icons in outliner and popups, overall UI is intended
* to stay monochrome and out of the way except a few places where it
* is important to communicate different data types. */
- if (!((theme_spacetype == SPACE_OUTLINER) || (theme_regionid == RGN_TYPE_TEMPORARY))) {
+ if (!((theme_spacetype == SPACE_OUTLINER && theme_regionid == RGN_TYPE_WINDOW) ||
+ (theme_spacetype == SPACE_PROPERTIES && theme_regionid == RGN_TYPE_NAV_BAR) ||
+ (theme_regionid == RGN_TYPE_TEMPORARY))) {
return false;
}
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 952778cfc6d..9de7a33b757 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -31,12 +31,14 @@
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
+#include "BLI_array.h"
#include "BLI_utildefines.h"
#include "BLI_link_utils.h"
#include "BLI_rect.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_timecode.h"
+#include "BLI_string.h"
#include "BKE_context.h"
#include "BKE_screen.h"
@@ -1117,7 +1119,7 @@ void UI_view2d_zoom_cache_reset(void)
/* View Matrix Setup */
/* mapping function to ensure 'cur' draws extended over the area where sliders are */
-static void view2d_map_cur_using_mask(View2D *v2d, rctf *r_curmasked)
+static void view2d_map_cur_using_mask(const View2D *v2d, rctf *r_curmasked)
{
*r_curmasked = v2d->cur;
@@ -1149,7 +1151,7 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *r_curmasked)
}
/* Set view matrices to use 'cur' rect as viewing frame for View2D drawing */
-void UI_view2d_view_ortho(View2D *v2d)
+void UI_view2d_view_ortho(const View2D *v2d)
{
rctf curmasked;
const int sizex = BLI_rcti_size_x(&v2d->mask);
@@ -1238,338 +1240,6 @@ void UI_view2d_view_restore(const bContext *C)
/* *********************************************************************** */
/* Gridlines */
-/* View2DGrid is typedef'd in UI_view2d.h */
-struct View2DGrid {
- float dx, dy; /* stepsize (in pixels) between gridlines */
- float startx, starty; /* initial coordinates to start drawing grid from */
- int powerx, powery; /* step as power of 10 */
-};
-
-/* --------------- */
-
-/* try to write step as a power of 10 */
-static void step_to_grid(float *step, const int unit, int *r_power)
-{
- const float loga = (float)log10(*step);
- float rem;
-
- int power = (int)(loga);
-
- rem = loga - power;
- rem = (float)pow(10.0, rem);
-
- if (loga < 0.0f) {
- if (rem < 0.2f) {
- rem = 0.2f;
- }
- else if (rem < 0.5f) {
- rem = 0.5f;
- }
- else {
- rem = 1.0f;
- }
-
- *step = rem * (float)pow(10.0, power);
-
- /* for frames, we want 1.0 frame intervals only */
- if (unit == V2D_UNIT_FRAMES) {
- rem = 1.0f;
- /* use 2 since there are grid lines drawn in between,
- * this way to get 1 line per frame */
- *step = 2.0f;
- }
-
- /* prevents printing 1.0 2.0 3.0 etc */
- if (rem == 1.0f) {
- power++;
- }
- }
- else {
- if (rem < 2.0f) {
- rem = 2.0f;
- }
- else if (rem < 5.0f) {
- rem = 5.0f;
- }
- else {
- rem = 10.0f;
- }
-
- *step = rem * (float)pow(10.0, power);
-
- power++;
- /* prevents printing 1.0, 2.0, 3.0, etc. */
- if (rem == 10.0f) {
- power++;
- }
- }
-
- *r_power = power;
-}
-
-/**
- * Initialize settings necessary for drawing gridlines in a 2d-view
- *
- * - Currently, will return pointer to View2DGrid struct that needs to
- * be freed with UI_view2d_grid_free()
- * - Is used for scrollbar drawing too (for units drawing)
- * - Units + clamping args will be checked, to make sure they are valid values that can be used
- * so it is very possible that we won't return grid at all!
- *
- * - xunits,yunits = V2D_UNIT_* grid steps in seconds or frames
- * - xclamp,yclamp = V2D_CLAMP_* only show whole-number intervals
- * - winx = width of region we're drawing to, note: not used but keeping for completeness.
- * - winy = height of region we're drawing into
- */
-View2DGrid *UI_view2d_grid_calc(Scene *scene,
- View2D *v2d,
- short xunits,
- short xclamp,
- short yunits,
- short yclamp,
- int UNUSED(winx),
- int winy)
-{
-
- View2DGrid *grid;
- float space, seconddiv;
-
- /* check that there are at least some workable args */
- if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) && ELEM(V2D_ARG_DUMMY, yunits, yclamp)) {
- return NULL;
- }
-
- /* grid here is allocated... */
- grid = MEM_callocN(sizeof(View2DGrid), "View2DGrid");
-
- /* rule: gridstep is minimal GRIDSTEP pixels */
- if (xunits == V2D_UNIT_SECONDS) {
- seconddiv = (float)(0.01 * FPS);
- }
- else {
- seconddiv = 1.0f;
- }
-
- /* calculate x-axis grid scale (only if both args are valid) */
- if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
- space = BLI_rctf_size_x(&v2d->cur);
-
- if (space != 0.0f) {
- const float pixels = (float)BLI_rcti_size_x(&v2d->mask);
- if (pixels != 0.0f) {
- grid->dx = (U.v2d_min_gridsize * UI_DPI_FAC * space) / (seconddiv * pixels);
- step_to_grid(&grid->dx, xunits, &grid->powerx);
- grid->dx *= seconddiv;
- }
- }
-
- if (xclamp == V2D_GRID_CLAMP) {
- CLAMP_MIN(grid->dx, 0.1f);
- CLAMP_MIN(grid->powerx, 0);
- grid->powerx -= 2;
- }
- }
-
- /* calculate y-axis grid scale (only if both args are valid) */
- if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
- space = BLI_rctf_size_y(&v2d->cur);
- if (space != 0.0f) {
- const float pixels = (float)winy;
- if (pixels != 0.0f) {
- grid->dy = U.v2d_min_gridsize * UI_DPI_FAC * space / pixels;
- step_to_grid(&grid->dy, yunits, &grid->powery);
- }
- }
-
- if (yclamp == V2D_GRID_CLAMP) {
- CLAMP_MIN(grid->dy, 1.0f);
- CLAMP_MIN(grid->powery, 1);
- }
- }
-
- /* calculate start position */
- if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
- grid->startx = seconddiv * (v2d->cur.xmin / seconddiv -
- (float)fmod(v2d->cur.xmin / seconddiv, grid->dx / seconddiv));
- if (v2d->cur.xmin < 0.0f) {
- grid->startx -= grid->dx;
- }
- }
- else {
- grid->startx = v2d->cur.xmin;
- }
-
- if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
- grid->starty = (v2d->cur.ymin - (float)fmod(v2d->cur.ymin, grid->dy));
- if (v2d->cur.ymin < 0.0f) {
- grid->starty -= grid->dy;
- }
- }
- else {
- grid->starty = v2d->cur.ymin;
- }
-
- return grid;
-}
-
-/* Draw gridlines in the given 2d-region */
-void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
-{
- float vec1[2], vec2[2];
- int a, step;
- int vertical_minor_step = (BLI_rcti_size_x(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC);
- int horizontal_major_step = (BLI_rcti_size_y(&v2d->mask) + 1) /
- (U.v2d_min_gridsize * UI_DPI_FAC);
- uchar grid_line_color[3];
-
- /* check for grid first, as it may not exist */
- if (grid == NULL) {
- return;
- }
-
- /* Count the needed vertices for the gridlines */
- unsigned vertex_count = 0;
- if (flag & V2D_VERTICAL_LINES) {
- /* vertical lines */
- vertex_count += 2 * vertical_minor_step; /* minor gridlines */
- vertex_count += 2 * (vertical_minor_step + 2); /* major gridlines */
- }
- if (flag & V2D_HORIZONTAL_LINES) {
- /* horizontal lines */
- vertex_count += 2 * (horizontal_major_step + 1); /* major gridlines */
-
- /* fine lines */
- if (flag & V2D_HORIZONTAL_FINELINES) {
- vertex_count += 2 * (horizontal_major_step + 1);
- }
- }
- /* axes */
- if (flag & V2D_HORIZONTAL_AXIS) {
- vertex_count += 2;
- }
- if (flag & V2D_VERTICAL_AXIS) {
- vertex_count += 2;
- }
-
- /* If there is nothing to render, exit early */
- if (vertex_count == 0) {
- return;
- }
-
- GPUVertFormat *format = immVertexFormat();
- 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, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GPU_PRIM_LINES, vertex_count);
-
- /* vertical lines */
- if (flag & V2D_VERTICAL_LINES) {
- /* initialize initial settings */
- vec1[0] = vec2[0] = grid->startx;
- vec1[1] = grid->starty;
- vec2[1] = v2d->cur.ymax;
-
- /* minor gridlines */
- step = vertical_minor_step;
- if (step != 0) {
- UI_GetThemeColor3ubv(TH_GRID, grid_line_color);
-
- for (a = 0; a < step; a++) {
- immAttrSkip(color);
- immVertex2fv(pos, vec1);
- immAttr3ubv(color, grid_line_color);
- immVertex2fv(pos, vec2);
-
- vec2[0] = vec1[0] += grid->dx;
- }
- }
-
- /* major gridlines */
- vec2[0] = vec1[0] -= 0.5f * grid->dx;
-
- UI_GetThemeColorShade3ubv(TH_GRID, 16, grid_line_color);
-
- step++;
- for (a = 0; a <= step; a++) {
- immAttrSkip(color);
- immVertex2fv(pos, vec1);
- immAttr3ubv(color, grid_line_color);
- immVertex2fv(pos, vec2);
-
- vec2[0] = vec1[0] -= grid->dx;
- }
- }
-
- /* horizontal lines */
- if (flag & V2D_HORIZONTAL_LINES) {
- /* only major gridlines */
- vec1[1] = vec2[1] = grid->starty;
- vec1[0] = grid->startx;
- vec2[0] = v2d->cur.xmax;
-
- step = horizontal_major_step;
-
- UI_GetThemeColor3ubv(TH_GRID, grid_line_color);
-
- for (a = 0; a <= step; a++) {
- immAttrSkip(color);
- immVertex2fv(pos, vec1);
- immAttr3ubv(color, grid_line_color);
- immVertex2fv(pos, vec2);
-
- vec2[1] = vec1[1] += grid->dy;
- }
-
- /* fine grid lines */
- vec2[1] = vec1[1] -= 0.5f * grid->dy;
- step++;
-
- if (flag & V2D_HORIZONTAL_FINELINES) {
- UI_GetThemeColorShade3ubv(TH_GRID, 16, grid_line_color);
- for (a = 0; a < step; a++) {
- immAttrSkip(color);
- immVertex2fv(pos, vec1);
- immAttr3ubv(color, grid_line_color);
- immVertex2fv(pos, vec2);
-
- vec2[1] = vec1[1] -= grid->dy;
- }
- }
- }
-
- /* Axes are drawn as darker lines */
- UI_GetThemeColorShade3ubv(TH_GRID, -50, grid_line_color);
-
- /* horizontal axis */
- if (flag & V2D_HORIZONTAL_AXIS) {
- vec1[0] = v2d->cur.xmin;
- vec2[0] = v2d->cur.xmax;
- vec1[1] = vec2[1] = 0.0f;
-
- immAttrSkip(color);
- immVertex2fv(pos, vec1);
- immAttr3ubv(color, grid_line_color);
- immVertex2fv(pos, vec2);
- }
-
- /* vertical axis */
- if (flag & V2D_VERTICAL_AXIS) {
- vec1[1] = v2d->cur.ymin;
- vec2[1] = v2d->cur.ymax;
- vec1[0] = vec2[0] = 0.0f;
-
- immAttrSkip(color);
- immVertex2fv(pos, vec1);
- immAttr3ubv(color, grid_line_color);
- immVertex2fv(pos, vec2);
- }
-
- immEnd();
- immUnbindProgram();
-}
-
/* Draw a constant grid in given 2d-region */
void UI_view2d_constant_grid_draw(View2D *v2d, float step)
{
@@ -1727,135 +1397,6 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
immUnbindProgram();
}
-static void get_scale_indicator_text(
- const Scene *scene, float value, int brevity_level, short unit, uint max_length, char *r_str)
-{
- if (unit == V2D_UNIT_SECONDS) {
- BLI_timecode_string_from_time(
- r_str, max_length, brevity_level, value / (float)FPS, FPS, U.timecode_style);
- }
- else {
- BLI_timecode_string_from_time_seconds(r_str, max_length, brevity_level, value);
- }
-}
-
-void UI_view2d_grid_draw_numbers_horizontal(const Scene *scene,
- const View2D *v2d,
- const View2DGrid *grid,
- const rcti *rect,
- int unit,
- bool whole_numbers_only)
-{
- BLI_assert(grid);
- float xstep = grid->dx * UI_view2d_scale_get_x(v2d);
- if (xstep <= 0.0f) {
- return;
- }
-
- float initial_xpos = UI_view2d_view_to_region_x(v2d, grid->startx);
- float ypos = (float)rect->ymin + 2 * UI_DPI_FAC;
- float initial_value = grid->startx;
- float value_step = grid->dx;
- int brevity_level = grid->powerx;
-
- /* Make sure that the value_step is >= 1 when only whole numbers are displayed.
- * Otherwise the same number could be displayed more than once. */
- if (whole_numbers_only) {
- while (value_step < 0.9999f) {
- xstep *= 2.0f;
- value_step *= 2.0f;
- }
- }
-
- /* Skip first few steps if they don't intersect
- * the rectangle that will contain the numbers. */
- while (initial_xpos < rect->xmin) {
- initial_xpos += xstep;
- initial_value += value_step;
- }
-
- if (unit == V2D_UNIT_FRAMES) {
- brevity_level = 1;
- }
-
- const int font_id = BLF_default();
- UI_FontThemeColor(font_id, TH_TEXT);
-
- BLF_batch_draw_begin();
-
- for (float xpos = initial_xpos, value = initial_value; xpos < rect->xmax;
- xpos += xstep, value += value_step) {
- char text[32];
- get_scale_indicator_text(scene, value, brevity_level, unit, sizeof(text), text);
- float text_width = BLF_width(font_id, text, strlen(text));
- BLF_draw_default_ascii(xpos - text_width / 2.0f, ypos, 0.0f, text, sizeof(text));
- }
-
- BLF_batch_draw_end();
-}
-
-void UI_view2d_grid_draw_numbers_vertical(const Scene *scene,
- const View2D *v2d,
- const View2DGrid *grid,
- const rcti *rect,
- int unit,
- float text_offset)
-{
- BLI_assert(grid);
- float ystep = grid->dy * UI_view2d_scale_get_y(v2d);
- if (ystep <= 0.0f) {
- return;
- }
-
- const int font_id = BLF_default();
- UI_FontThemeColor(font_id, TH_TEXT);
-
- BLF_enable(font_id, BLF_ROTATION);
- BLF_rotation(font_id, M_PI_2);
-
- float initial_value = grid->starty;
- float value_step = grid->dy;
- float xpos = rect->xmax - 2.0f * UI_DPI_FAC;
- float initial_ypos = UI_view2d_view_to_region_y(v2d, grid->starty);
-
- /* Currently only used by the sequencer to display
- * channel numbers in the center. */
- initial_ypos += text_offset * ystep;
-
- /* Skip first few steps if they don't intersect
- * the rectangle that will contain the numbers. */
- while (initial_ypos < rect->ymin) {
- initial_ypos += ystep;
- initial_value += value_step;
- }
-
- for (float ypos = initial_ypos, value = initial_value; ypos < rect->ymax;
- ypos += ystep, value += value_step) {
- char text[32];
- get_scale_indicator_text(scene, value, grid->powery, unit, sizeof(text), text);
- float text_width = BLF_width(font_id, text, sizeof(text));
- BLF_draw_default_ascii(xpos, ypos - text_width / 2.0f, 0.0f, text, sizeof(text));
- }
-
- BLF_disable(font_id, BLF_ROTATION);
-}
-
-/* the price we pay for not exposting structs :( */
-void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy)
-{
- *r_dx = grid->dx;
- *r_dy = grid->dy;
-}
-
-/* free temporary memory used for drawing grid */
-void UI_view2d_grid_free(View2DGrid *grid)
-{
- /* only free if there's a grid */
- if (grid) {
- MEM_freeN(grid);
- }
-}
-
/* *********************************************************************** */
/* Scrollers */
@@ -1872,21 +1413,10 @@ struct View2DScrollers {
rcti hor, vert; /* exact size of slider backdrop */
int horfull, vertfull; /* set if sliders are full, we don't draw them */
-
- /* scales */
- View2DGrid *grid; /* grid for coordinate drawing */
- short xunits, xclamp; /* units and clamping options for x-axis */
- short yunits, yclamp; /* units and clamping options for y-axis */
};
/* Calculate relevant scroller properties */
-View2DScrollers *UI_view2d_scrollers_calc(const bContext *C,
- View2D *v2d,
- const rcti *mask_custom,
- short xunits,
- short xclamp,
- short yunits,
- short yclamp)
+View2DScrollers *UI_view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom)
{
View2DScrollers *scrollers;
rcti vert, hor;
@@ -2014,30 +1544,11 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C,
}
}
- /* grid markings on scrollbars */
- if (scroll & (V2D_SCROLL_SCALE_HORIZONTAL | V2D_SCROLL_SCALE_VERTICAL)) {
- /* store clamping */
- scrollers->xclamp = xclamp;
- scrollers->xunits = xunits;
- scrollers->yclamp = yclamp;
- scrollers->yunits = yunits;
-
- scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C),
- v2d,
- xunits,
- xclamp,
- yunits,
- yclamp,
- BLI_rcti_size_x(&hor),
- BLI_rcti_size_y(&vert));
- }
-
- /* return scrollers */
return scrollers;
}
/* Draw scrollbars in the given 2d-region */
-void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *vs)
+void UI_view2d_scrollers_draw(View2D *v2d, View2DScrollers *vs)
{
bTheme *btheme = UI_GetTheme();
rcti vert, hor;
@@ -2084,13 +1595,6 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
}
UI_draw_widget_scroll(&wcol, &hor, &slider, state);
-
- {
- if (scroll & V2D_SCROLL_SCALE_HORIZONTAL) {
- UI_view2d_grid_draw_numbers_horizontal(
- CTX_data_scene(C), v2d, vs->grid, &vs->hor, vs->xunits, vs->xclamp == V2D_GRID_CLAMP);
- }
- }
}
/* vertical scrollbar */
@@ -2125,17 +1629,6 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
}
UI_draw_widget_scroll(&wcol, &vert, &slider, state);
-
- {
- if (scroll & V2D_SCROLL_SCALE_VERTICAL) {
- float text_offset = 0.0f;
- if (vs->yclamp & V2D_GRID_CLAMP) {
- text_offset = 0.5f;
- }
- UI_view2d_grid_draw_numbers_vertical(
- CTX_data_scene(C), v2d, vs->grid, &vs->vert, vs->yunits, text_offset);
- }
- }
}
/* Was changed above, so reset. */
@@ -2145,69 +1638,12 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* free temporary memory used for drawing scrollers */
void UI_view2d_scrollers_free(View2DScrollers *scrollers)
{
- /* need to free grid as well... */
- if (scrollers->grid) {
- MEM_freeN(scrollers->grid);
- }
MEM_freeN(scrollers);
}
/* *********************************************************************** */
/* List View Utilities */
-/** Get the view-coordinates of the nominated cell
- *
- * \param columnwidth, rowheight: size of each 'cell'
- * \param startx, starty: coordinates (in 'tot' rect space) that the list starts from.
- * This should be (0,0) for most views. However, for those where the starting row was offsetted
- * (like for Animation Editor channel lists, to make the first entry more visible), these will be
- * the min-coordinates of the first item.
- * \param column, row: The 2d-coordinates
- * (in 2D-view / 'tot' rect space) the cell exists at
- * \param rect: coordinates of the cell
- * (passed as single var instead of 4 separate, as it's more useful this way)
- */
-void UI_view2d_listview_cell_to_view(View2D *v2d,
- float columnwidth,
- float rowheight,
- float startx,
- float starty,
- int column,
- int row,
- rctf *rect)
-{
- /* sanity checks */
- if (ELEM(NULL, v2d, rect)) {
- return;
- }
-
- if ((columnwidth <= 0) && (rowheight <= 0)) {
- rect->xmin = rect->xmax = 0.0f;
- rect->ymin = rect->ymax = 0.0f;
- return;
- }
-
- /* x-coordinates */
- rect->xmin = startx + (float)(columnwidth * column);
- rect->xmax = startx + (float)(columnwidth * (column + 1));
-
- if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
- /* simply negate the values for the coordinates if in negative half */
- rect->xmin = -rect->xmin;
- rect->xmax = -rect->xmax;
- }
-
- /* y-coordinates */
- rect->ymin = starty + (float)(rowheight * row);
- rect->ymax = starty + (float)(rowheight * (row + 1));
-
- if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
- /* simply negate the values for the coordinates if in negative half */
- rect->ymin = -rect->ymin;
- rect->ymax = -rect->ymax;
- }
-}
-
/**
* Get the 'cell' (row, column) that the given 2D-view coordinates
* (i.e. in 'tot' rect space) lie in.
@@ -2220,8 +1656,7 @@ void UI_view2d_listview_cell_to_view(View2D *v2d,
* \param viewx, viewy: 2D-coordinates (in 2D-view / 'tot' rect space) to get the cell for
* \param r_column, r_row: the 'coordinates' of the relevant 'cell'
*/
-void UI_view2d_listview_view_to_cell(View2D *v2d,
- float columnwidth,
+void UI_view2d_listview_view_to_cell(float columnwidth,
float rowheight,
float startx,
float starty,
@@ -2230,80 +1665,24 @@ void UI_view2d_listview_view_to_cell(View2D *v2d,
int *r_column,
int *r_row)
{
- /* adjust view coordinates to be all positive ints, corrected for the start offset */
- const int x = (int)(floorf(fabsf(viewx) + 0.5f) - startx);
- const int y = (int)(floorf(fabsf(viewy) + 0.5f) - starty);
-
- /* sizes must not be negative */
- if ((v2d == NULL) || ((columnwidth <= 0) && (rowheight <= 0))) {
- if (r_column) {
- *r_column = 0;
+ if (r_column) {
+ if (columnwidth > 0) {
+ /* Columns go from left to right (x increases). */
+ *r_column = floorf((viewx - startx) / columnwidth);
}
- if (r_row) {
- *r_row = 0;
+ else {
+ *r_column = 0;
}
-
- return;
}
- /* get column */
- if ((r_column) && (columnwidth > 0)) {
- *r_column = x / columnwidth;
- }
- else if (r_column) {
- *r_column = 0;
- }
-
- /* get row */
- if ((r_row) && (rowheight > 0)) {
- *r_row = y / rowheight;
- }
- else if (r_row) {
- *r_row = 0;
- }
-}
-
-/**
- * Get the 'extreme' (min/max) column and row indices which are visible within the 'cur' rect
- *
- * \param columnwidth, rowheight: Size of each 'cell'
- * \param startx, starty: Coordinates that the list starts from,
- * which should be (0,0) for most views.
- * \param column_min, column_max, row_min, row_max: The starting and ending column/row indices
- */
-void UI_view2d_listview_visible_cells(View2D *v2d,
- float columnwidth,
- float rowheight,
- float startx,
- float starty,
- int *column_min,
- int *column_max,
- int *row_min,
- int *row_max)
-{
- /* using 'cur' rect coordinates, call the cell-getting function to get the cells for this */
- if (v2d) {
- /* min */
- UI_view2d_listview_view_to_cell(v2d,
- columnwidth,
- rowheight,
- startx,
- starty,
- v2d->cur.xmin,
- v2d->cur.ymin,
- column_min,
- row_min);
-
- /* max*/
- UI_view2d_listview_view_to_cell(v2d,
- columnwidth,
- rowheight,
- startx,
- starty,
- v2d->cur.xmax,
- v2d->cur.ymax,
- column_max,
- row_max);
+ if (r_row) {
+ if (rowheight > 0) {
+ /* Rows got from top to bottom (y decreases). */
+ *r_row = floorf((starty - viewy) / rowheight);
+ }
+ else {
+ *r_row = 0;
+ }
}
}
diff --git a/source/blender/editors/interface/view2d_draw.c b/source/blender/editors/interface/view2d_draw.c
new file mode 100644
index 00000000000..2568193ee23
--- /dev/null
+++ b/source/blender/editors/interface/view2d_draw.c
@@ -0,0 +1,546 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup edinterface
+ */
+
+#include <float.h>
+#include <limits.h>
+#include <math.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_userdef_types.h"
+
+#include "BLI_array.h"
+#include "BLI_utildefines.h"
+#include "BLI_rect.h"
+#include "BLI_math.h"
+#include "BLI_timecode.h"
+#include "BLI_string.h"
+
+#include "GPU_immediate.h"
+#include "GPU_matrix.h"
+
+#include "WM_api.h"
+
+#include "BLF_api.h"
+
+#include "UI_interface.h"
+#include "UI_view2d.h"
+
+#include "interface_intern.h"
+
+/* Compute display grid resolution
+ ********************************************************/
+
+#define MIN_MAJOR_LINE_DISTANCE (UI_DPI_FAC * 50)
+
+static float select_major_distance(const float *possible_distances,
+ uint amount,
+ float pixel_width,
+ float view_width)
+{
+ BLI_assert(amount >= 1);
+
+ if (IS_EQF(view_width, 0.0f)) {
+ return possible_distances[0];
+ }
+
+ float pixels_per_view_unit = pixel_width / view_width;
+
+ for (uint i = 0; i < amount; i++) {
+ float distance = possible_distances[i];
+ if (pixels_per_view_unit * distance >= MIN_MAJOR_LINE_DISTANCE) {
+ return distance;
+ }
+ }
+ return possible_distances[amount - 1];
+}
+
+static const float discrete_value_scales[] = {
+ 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000};
+
+static const float continuous_value_scales[] = {0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2,
+ 5, 10, 20, 50, 100, 200, 500, 1000,
+ 2000, 5000, 10000, 20000, 50000, 100000};
+
+static uint view2d_major_step_x__discrete(const View2D *v2d)
+{
+ return select_major_distance(discrete_value_scales,
+ ARRAY_SIZE(discrete_value_scales),
+ BLI_rcti_size_x(&v2d->mask),
+ BLI_rctf_size_x(&v2d->cur));
+}
+
+static float view2d_major_step_x__continuous(const View2D *v2d)
+{
+ return select_major_distance(continuous_value_scales,
+ ARRAY_SIZE(continuous_value_scales),
+ BLI_rcti_size_x(&v2d->mask),
+ BLI_rctf_size_x(&v2d->cur));
+}
+
+static float view2d_major_step_y__continuous(const View2D *v2d)
+{
+ return select_major_distance(continuous_value_scales,
+ ARRAY_SIZE(continuous_value_scales),
+ BLI_rcti_size_y(&v2d->mask),
+ BLI_rctf_size_y(&v2d->cur));
+}
+
+static float view2d_major_step_x__time(const View2D *v2d, const Scene *scene)
+{
+ double fps = FPS;
+
+ float *possible_distances = NULL;
+ BLI_array_staticdeclare(possible_distances, 32);
+
+ for (uint step = 1; step < fps; step *= 2) {
+ BLI_array_append(possible_distances, step);
+ }
+ BLI_array_append(possible_distances, fps);
+ BLI_array_append(possible_distances, 2 * fps);
+ BLI_array_append(possible_distances, 5 * fps);
+ BLI_array_append(possible_distances, 10 * fps);
+ BLI_array_append(possible_distances, 30 * fps);
+ BLI_array_append(possible_distances, 60 * fps);
+ BLI_array_append(possible_distances, 2 * 60 * fps);
+ BLI_array_append(possible_distances, 5 * 60 * fps);
+ BLI_array_append(possible_distances, 10 * 60 * fps);
+ BLI_array_append(possible_distances, 30 * 60 * fps);
+ BLI_array_append(possible_distances, 60 * 60 * fps);
+
+ float distance = select_major_distance(possible_distances,
+ BLI_array_len(possible_distances),
+ BLI_rcti_size_x(&v2d->mask),
+ BLI_rctf_size_x(&v2d->cur));
+
+ BLI_array_free(possible_distances);
+ return distance;
+}
+
+/* Draw parallel lines
+ ************************************/
+
+typedef struct ParallelLinesSet {
+ float offset;
+ float distance;
+} ParallelLinesSet;
+
+static void get_parallel_lines_draw_steps(const ParallelLinesSet *lines,
+ float region_start,
+ float region_end,
+ float *r_first,
+ uint *r_steps)
+{
+ if (region_start >= region_end) {
+ *r_first = 0;
+ *r_steps = 0;
+ return;
+ }
+
+ BLI_assert(lines->distance > 0);
+ BLI_assert(region_start <= region_end);
+
+ *r_first = ceilf((region_start - lines->offset) / lines->distance) * lines->distance +
+ lines->offset;
+
+ if (region_start <= *r_first && region_end >= *r_first) {
+ *r_steps = MAX2(0, floorf((region_end - *r_first) / lines->distance)) + 1;
+ }
+ else {
+ *r_steps = 0;
+ }
+}
+
+static void draw_parallel_lines(const ParallelLinesSet *lines,
+ const rctf *rect,
+ const uchar *color,
+ char direction)
+{
+ float first;
+ uint steps;
+
+ if (direction == 'v') {
+ get_parallel_lines_draw_steps(lines, rect->xmin, rect->xmax, &first, &steps);
+ }
+ else {
+ BLI_assert(direction == 'h');
+ get_parallel_lines_draw_steps(lines, rect->ymin, rect->ymax, &first, &steps);
+ }
+
+ if (steps == 0) {
+ return;
+ }
+
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor3ubv(color);
+ immBegin(GPU_PRIM_LINES, steps * 2);
+
+ if (direction == 'v') {
+ for (uint i = 0; i < steps; i++) {
+ float xpos = first + i * lines->distance;
+ immVertex2f(pos, xpos, rect->ymin);
+ immVertex2f(pos, xpos, rect->ymax);
+ }
+ }
+ else {
+ for (uint i = 0; i < steps; i++) {
+ float ypos = first + i * lines->distance;
+ immVertex2f(pos, rect->xmin, ypos);
+ immVertex2f(pos, rect->xmax, ypos);
+ }
+ }
+
+ immEnd();
+ immUnbindProgram();
+}
+
+static void view2d_draw_lines_internal(const View2D *v2d,
+ const ParallelLinesSet *lines,
+ const uchar *color,
+ char direction)
+{
+ GPU_matrix_push_projection();
+ UI_view2d_view_ortho(v2d);
+ draw_parallel_lines(lines, &v2d->cur, color, direction);
+ GPU_matrix_pop_projection();
+}
+
+static void view2d_draw_lines(const View2D *v2d,
+ float major_distance,
+ bool display_minor_lines,
+ char direction)
+{
+ uchar major_color[3];
+ uchar minor_color[3];
+ UI_GetThemeColor3ubv(TH_GRID, major_color);
+ UI_GetThemeColorShade3ubv(TH_GRID, 16, minor_color);
+
+ ParallelLinesSet major_lines;
+ major_lines.distance = major_distance;
+ major_lines.offset = 0;
+ view2d_draw_lines_internal(v2d, &major_lines, major_color, direction);
+
+ if (display_minor_lines) {
+ ParallelLinesSet minor_lines;
+ minor_lines.distance = major_distance;
+ minor_lines.offset = major_distance / 2.0f;
+ view2d_draw_lines_internal(v2d, &minor_lines, minor_color, direction);
+ }
+}
+
+/* Scale indicator text drawing
+ **************************************************/
+
+typedef void (*PositionToString)(
+ void *user_data, float v2d_pos, float v2d_step, uint max_len, char *r_str);
+
+static void draw_horizontal_scale_indicators(const ARegion *ar,
+ const View2D *v2d,
+ float distance,
+ const rcti *rect,
+ PositionToString to_string,
+ void *to_string_data,
+ int colorid)
+{
+ GPU_matrix_push_projection();
+ wmOrtho2_region_pixelspace(ar);
+
+ float start;
+ uint steps;
+ {
+ ParallelLinesSet lines;
+ lines.distance = distance;
+ lines.offset = 0;
+ get_parallel_lines_draw_steps(&lines,
+ UI_view2d_region_to_view_x(v2d, rect->xmin),
+ UI_view2d_region_to_view_x(v2d, rect->xmax),
+ &start,
+ &steps);
+ }
+
+ const int font_id = BLF_default();
+ UI_FontThemeColor(font_id, colorid);
+
+ BLF_batch_draw_begin();
+
+ float ypos = rect->ymin + 4 * UI_DPI_FAC;
+ float xmin = rect->xmin;
+ float xmax = rect->xmax;
+
+ for (uint i = 0; i < steps; i++) {
+ float xpos_view = start + i * distance;
+ float xpos_region = UI_view2d_view_to_region_x(v2d, xpos_view);
+ char text[32];
+ to_string(to_string_data, xpos_view, distance, sizeof(text), text);
+ float text_width = BLF_width(font_id, text, strlen(text));
+
+ if (xpos_region - text_width / 2.0f >= xmin && xpos_region + text_width / 2.0f <= xmax) {
+ BLF_draw_default_ascii(xpos_region - text_width / 2.0f, ypos, 0.0f, text, sizeof(text));
+ }
+ }
+
+ BLF_batch_draw_end();
+
+ GPU_matrix_pop_projection();
+}
+
+static void draw_vertical_scale_indicators(const ARegion *ar,
+ const View2D *v2d,
+ float distance,
+ float display_offset,
+ const rcti *rect,
+ PositionToString to_string,
+ void *to_string_data,
+ int colorid)
+{
+ GPU_matrix_push_projection();
+ wmOrtho2_region_pixelspace(ar);
+
+ float start;
+ uint steps;
+ {
+ ParallelLinesSet lines;
+ lines.distance = distance;
+ lines.offset = 0;
+ get_parallel_lines_draw_steps(&lines,
+ UI_view2d_region_to_view_y(v2d, rect->ymin),
+ UI_view2d_region_to_view_y(v2d, rect->ymax),
+ &start,
+ &steps);
+ }
+
+ const int font_id = BLF_default();
+ UI_FontThemeColor(font_id, colorid);
+
+ BLF_enable(font_id, BLF_ROTATION);
+ BLF_rotation(font_id, M_PI_2);
+
+ BLF_batch_draw_begin();
+
+ float xpos = rect->xmax - 2.0f * UI_DPI_FAC;
+ float ymin = rect->ymin;
+ float ymax = rect->ymax;
+
+ for (uint i = 0; i < steps; i++) {
+ float ypos_view = start + i * distance;
+ float ypos_region = UI_view2d_view_to_region_y(v2d, ypos_view + display_offset);
+ char text[32];
+ to_string(to_string_data, ypos_view, distance, sizeof(text), text);
+ float text_width = BLF_width(font_id, text, strlen(text));
+
+ if (ypos_region - text_width / 2.0f >= ymin && ypos_region + text_width / 2.0f <= ymax) {
+ BLF_draw_default_ascii(xpos, ypos_region - text_width / 2.0f, 0.0f, text, sizeof(text));
+ }
+ }
+
+ BLF_batch_draw_end();
+ BLF_disable(font_id, BLF_ROTATION);
+
+ GPU_matrix_pop_projection();
+}
+
+static void view_to_string__frame_number(
+ void *UNUSED(user_data), float v2d_pos, float UNUSED(v2d_step), uint max_len, char *r_str)
+{
+ BLI_snprintf(r_str, max_len, "%d", (int)v2d_pos);
+}
+
+static void view_to_string__time(
+ void *user_data, float v2d_pos, float UNUSED(v2d_step), uint max_len, char *r_str)
+{
+ const Scene *scene = (const Scene *)user_data;
+
+ int brevity_level = 0;
+ BLI_timecode_string_from_time(
+ r_str, max_len, brevity_level, v2d_pos / (float)FPS, FPS, U.timecode_style);
+}
+
+static void view_to_string__value(
+ void *UNUSED(user_data), float v2d_pos, float v2d_step, uint max_len, char *r_str)
+{
+ if (v2d_step >= 1.0f) {
+ BLI_snprintf(r_str, max_len, "%d", (int)v2d_pos);
+ }
+ else if (v2d_step >= 0.1f) {
+ BLI_snprintf(r_str, max_len, "%.1f", v2d_pos);
+ }
+ else if (v2d_step >= 0.01f) {
+ BLI_snprintf(r_str, max_len, "%.2f", v2d_pos);
+ }
+ else {
+ BLI_snprintf(r_str, max_len, "%.3f", v2d_pos);
+ }
+}
+
+/* Grid Resolution API
+ **************************************************/
+
+float UI_view2d_grid_resolution_x__frames_or_seconds(const struct View2D *v2d,
+ const struct Scene *scene,
+ bool display_seconds)
+{
+ if (display_seconds) {
+ return view2d_major_step_x__time(v2d, scene);
+ }
+ else {
+ return view2d_major_step_x__continuous(v2d);
+ }
+}
+
+float UI_view2d_grid_resolution_y__values(const struct View2D *v2d)
+{
+ return view2d_major_step_y__continuous(v2d);
+}
+
+/* Line Drawing API
+ **************************************************/
+
+void UI_view2d_draw_lines_x__discrete_values(const View2D *v2d)
+{
+ uint major_line_distance = view2d_major_step_x__discrete(v2d);
+ view2d_draw_lines(v2d, major_line_distance, major_line_distance > 1, 'v');
+}
+
+void UI_view2d_draw_lines_x__values(const View2D *v2d)
+{
+ float major_line_distance = view2d_major_step_x__continuous(v2d);
+ view2d_draw_lines(v2d, major_line_distance, true, 'v');
+}
+
+void UI_view2d_draw_lines_y__values(const View2D *v2d)
+{
+ float major_line_distance = view2d_major_step_y__continuous(v2d);
+ view2d_draw_lines(v2d, major_line_distance, true, 'h');
+}
+
+void UI_view2d_draw_lines_x__discrete_time(const View2D *v2d, const Scene *scene)
+{
+ float major_line_distance = view2d_major_step_x__time(v2d, scene);
+ view2d_draw_lines(v2d, major_line_distance, major_line_distance > 1, 'v');
+}
+
+void UI_view2d_draw_lines_x__discrete_frames_or_seconds(const View2D *v2d,
+ const Scene *scene,
+ bool display_seconds)
+{
+ if (display_seconds) {
+ UI_view2d_draw_lines_x__discrete_time(v2d, scene);
+ }
+ else {
+ UI_view2d_draw_lines_x__discrete_values(v2d);
+ }
+}
+
+void UI_view2d_draw_lines_x__frames_or_seconds(const View2D *v2d,
+ const Scene *scene,
+ bool display_seconds)
+{
+ if (display_seconds) {
+ UI_view2d_draw_lines_x__discrete_time(v2d, scene);
+ }
+ else {
+ UI_view2d_draw_lines_x__values(v2d);
+ }
+}
+
+/* Scale indicator text drawing API
+ **************************************************/
+
+static void UI_view2d_draw_scale_x__discrete_values(const ARegion *ar,
+ const View2D *v2d,
+ const rcti *rect,
+ int colorid)
+{
+ float number_step = view2d_major_step_x__discrete(v2d);
+ draw_horizontal_scale_indicators(
+ ar, v2d, number_step, rect, view_to_string__frame_number, NULL, colorid);
+}
+
+static void UI_view2d_draw_scale_x__discrete_time(
+ const ARegion *ar, const View2D *v2d, const rcti *rect, const Scene *scene, int colorid)
+{
+ float step = view2d_major_step_x__time(v2d, scene);
+ draw_horizontal_scale_indicators(
+ ar, v2d, step, rect, view_to_string__time, (void *)scene, colorid);
+}
+
+static void UI_view2d_draw_scale_x__values(const ARegion *ar,
+ const View2D *v2d,
+ const rcti *rect,
+ int colorid)
+{
+ float step = view2d_major_step_x__continuous(v2d);
+ draw_horizontal_scale_indicators(ar, v2d, step, rect, view_to_string__value, NULL, colorid);
+}
+
+void UI_view2d_draw_scale_y__values(const ARegion *ar,
+ const View2D *v2d,
+ const rcti *rect,
+ int colorid)
+{
+ float step = view2d_major_step_y__continuous(v2d);
+ draw_vertical_scale_indicators(ar, v2d, step, 0.0f, rect, view_to_string__value, NULL, colorid);
+}
+
+void UI_view2d_draw_scale_y__block(const ARegion *ar,
+ const View2D *v2d,
+ const rcti *rect,
+ int colorid)
+{
+ draw_vertical_scale_indicators(ar, v2d, 1.0f, 0.5f, rect, view_to_string__value, NULL, colorid);
+}
+
+void UI_view2d_draw_scale_x__discrete_frames_or_seconds(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect,
+ const struct Scene *scene,
+ bool display_seconds,
+ int colorid)
+{
+ if (display_seconds) {
+ UI_view2d_draw_scale_x__discrete_time(ar, v2d, rect, scene, colorid);
+ }
+ else {
+ UI_view2d_draw_scale_x__discrete_values(ar, v2d, rect, colorid);
+ }
+}
+
+void UI_view2d_draw_scale_x__frames_or_seconds(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect,
+ const struct Scene *scene,
+ bool display_seconds,
+ int colorid)
+{
+ if (display_seconds) {
+ UI_view2d_draw_scale_x__discrete_time(ar, v2d, rect, scene, colorid);
+ }
+ else {
+ UI_view2d_draw_scale_x__values(ar, v2d, rect, colorid);
+ }
+}
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 8880072b82b..ab8d1cf9bf6 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1785,8 +1785,7 @@ static void scroller_activate_init(bContext *C,
/* 'zone' depends on where mouse is relative to bubble
* - zooming must be allowed on this axis, otherwise, default to pan
*/
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
/* use a union of 'cur' & 'tot' incase the current view is far outside 'tot'. In this cases
* moving the scroll bars has far too little effect and the view can get stuck T31476. */
diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt
index fbbb8621ae6..5a35b251d0c 100644
--- a/source/blender/editors/io/CMakeLists.txt
+++ b/source/blender/editors/io/CMakeLists.txt
@@ -17,16 +17,16 @@
set(INC
../include
+ ../../alembic
../../blenkernel
../../blenlib
../../blentranslation
../../bmesh
+ ../../collada
../../depsgraph
../../makesdna
../../makesrna
../../windowmanager
- ../../collada
- ../../alembic
../../../../intern/guardedalloc
)
diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c
index 6358c2c1370..3dd3b20bda3 100644
--- a/source/blender/editors/io/io_cache.c
+++ b/source/blender/editors/io/io_cache.c
@@ -38,6 +38,8 @@
#include "RNA_access.h"
+#include "DEG_depsgraph.h"
+
#include "UI_interface.h"
#include "WM_api.h"
@@ -93,7 +95,7 @@ static int cachefile_open_exec(bContext *C, wmOperator *op)
CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, BLI_path_basename(filename), 0);
BLI_strncpy(cache_file->filepath, filename, FILE_MAX);
- BKE_cachefile_reload(bmain, cache_file);
+ DEG_id_tag_update(&cache_file->id, ID_RECALC_COPY_ON_WRITE);
/* Will be set when running invoke, not exec directly. */
if (op->customdata != NULL) {
@@ -137,7 +139,7 @@ void CACHEFILE_OT_open(wmOperatorType *ot)
/* ***************************** Reload Operator **************************** */
-static int cachefile_reload_exec(bContext *C, wmOperator *op)
+static int cachefile_reload_exec(bContext *C, wmOperator *UNUSED(op))
{
CacheFile *cache_file = CTX_data_edit_cachefile(C);
@@ -145,14 +147,10 @@ static int cachefile_reload_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- Main *bmain = CTX_data_main(C);
-
- BLI_freelistN(&cache_file->object_paths);
- BKE_cachefile_reload(bmain, cache_file);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ BKE_cachefile_reload(depsgraph, cache_file);
return OPERATOR_FINISHED;
-
- UNUSED_VARS(op);
}
void CACHEFILE_OT_reload(wmOperatorType *ot)
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index bfbd3722142..9796bf89cf3 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -174,7 +174,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
/* get editmode results */
ED_object_editmode_load(bmain, CTX_data_edit_object(C));
- //Scene *scene = CTX_data_scene(C);
+ // Scene *scene = CTX_data_scene(C);
ExportSettings export_settings;
@@ -748,7 +748,7 @@ void WM_OT_collada_import(wmOperatorType *ot)
ot->exec = wm_collada_import_exec;
ot->poll = WM_operator_winactive;
- //ot->flag |= OPTYPE_PRESET;
+ // ot->flag |= OPTYPE_PRESET;
ot->ui = wm_collada_import_draw;
diff --git a/source/blender/editors/mask/CMakeLists.txt b/source/blender/editors/mask/CMakeLists.txt
index 9dabcc0e8bb..81c861ab4e4 100644
--- a/source/blender/editors/mask/CMakeLists.txt
+++ b/source/blender/editors/mask/CMakeLists.txt
@@ -26,8 +26,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index 454e7e2a731..0c5591ed89b 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -520,6 +520,6 @@ void ED_operatormacros_mask(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MASK_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
}
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index ab774fa13df..c0f3b1f8338 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -245,7 +245,7 @@ bool ED_mask_feather_find_nearest(const bContext *C,
MaskSpline *spline;
for (spline = masklay->splines.first; spline; spline = spline->next) {
- //MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
+ // MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
int i, tot_feather_point;
float(*feather_points)[2], (*fp)[2];
diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c
index bb9359bad71..75b2aee3570 100644
--- a/source/blender/editors/mask/mask_relationships.c
+++ b/source/blender/editors/mask/mask_relationships.c
@@ -184,7 +184,7 @@ void MASK_OT_parent_set(wmOperatorType *ot)
ot->idname = "MASK_OT_parent_set";
/* api callbacks */
- //ot->invoke = mask_parent_set_invoke;
+ // ot->invoke = mask_parent_set_invoke;
ot->exec = mask_parent_set_exec;
ot->poll = ED_space_clip_maskedit_mask_poll;
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 00699c8ffe0..a592f39d24b 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -262,6 +262,7 @@ static int select_exec(bContext *C, wmOperator *op)
bool extend = RNA_boolean_get(op->ptr, "extend");
bool deselect = RNA_boolean_get(op->ptr, "deselect");
bool toggle = RNA_boolean_get(op->ptr, "toggle");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
eMaskWhichHandle which_handle;
const float threshold = 19;
@@ -368,6 +369,15 @@ static int select_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+ else if (deselect_all) {
+ ED_mask_select_toggle_all(mask, SEL_DESELECT);
+
+ ED_mask_select_flush_all(mask);
+
+ WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask);
+
+ return OPERATOR_FINISHED;
+ }
}
return OPERATOR_PASS_THROUGH;
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index e67d63b01a5..57bf67e825e 100644
--- a/source/blender/editors/mesh/CMakeLists.txt
+++ b/source/blender/editors/mesh/CMakeLists.txt
@@ -21,8 +21,8 @@ set(INC
../../blenkernel
../../blenlib
../../blentranslation
- ../../depsgraph
../../bmesh
+ ../../depsgraph
../../gpu
../../imbuf
../../makesdna
@@ -30,8 +30,8 @@ set(INC
../../render/extern/include
../../windowmanager
../../../../intern/clog
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 28b697531ab..990250792a1 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -121,7 +121,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag)
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);
+ BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_SELECT_PAINT);
}
DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index 815f51a4772..a7d1e54ad59 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -490,8 +490,8 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
- /* Note that if you use MESH_ADD_VERTS_MAXI for both x and y at the same time you will still reach
- * impossible values (10^12 vertices or so...). */
+ /* Note that if you use MESH_ADD_VERTS_MAXI for both x and y at the same time
+ * you will still reach impossible values (10^12 vertices or so...). */
RNA_def_int(
ot->srna, "x_subdivisions", 10, 2, MESH_ADD_VERTS_MAXI, "X Subdivisions", "", 2, 1000);
RNA_def_int(
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index f6940cae953..f5810d9ff61 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -907,7 +907,7 @@ void MESH_OT_bevel(wmOperatorType *ot)
/* identifiers */
ot->name = "Bevel";
- ot->description = "Edge Bevel";
+ ot->description = "Cut into selected items at an angle to create flat or rounded bevel or chamfer";
ot->idname = "MESH_OT_bevel";
/* api callbacks */
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index 9314b96afee..82cff8363f8 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -440,7 +440,7 @@ void MESH_OT_extrude_region(wmOperatorType *ot)
ot->description = "Extrude region of faces";
/* api callbacks */
- //ot->invoke = mesh_extrude_region_invoke;
+ // ot->invoke = mesh_extrude_region_invoke;
ot->exec = edbm_extrude_region_exec;
ot->poll = ED_operator_editmesh;
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
index 85be7d902ad..269ead7b23f 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
@@ -1018,7 +1018,8 @@ static void gizmo_mesh_spin_redo_draw_prepare(const bContext *UNUSED(C), wmGizmo
ggd->data.op = WM_operator_last_redo((bContext *)ggd->data.context);
}
- /* Not essential, just avoids feedback loop where matrices could shift because of float precision.
+ /* Not essential, just avoids feedback loop where matrices
+ * could shift because of float precision.
* Updates in this case are also redundant. */
bool is_modal = false;
for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index cd5281e1273..cc0c2f5bbe4 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -157,7 +157,7 @@ typedef struct KnifeTool_OpData {
void *draw_handle; /* for drawing preview loop */
ViewContext vc; /* note: _don't_ use 'mval', instead use the one we define below */
float mval[2]; /* mouse value with snapping applied */
- //bContext *C;
+ // bContext *C;
Scene *scene;
Object *ob;
diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c
index 062008cd656..f8ec4334427 100644
--- a/source/blender/editors/mesh/editmesh_path.c
+++ b/source/blender/editors/mesh/editmesh_path.c
@@ -434,12 +434,12 @@ static bool facetag_filter_cb(BMFace *f, void *UNUSED(user_data_v))
{
return !BM_elem_flag_test(f, BM_ELEM_HIDDEN);
}
-//static bool facetag_test_cb(Scene *UNUSED(scene), BMesh *UNUSED(bm), BMFace *f)
+// static bool facetag_test_cb(Scene *UNUSED(scene), BMesh *UNUSED(bm), BMFace *f)
static bool facetag_test_cb(BMFace *f, void *UNUSED(user_data_v))
{
return BM_elem_flag_test_bool(f, BM_ELEM_SELECT);
}
-//static void facetag_set_cb(BMesh *bm, Scene *UNUSED(scene), BMFace *f, const bool val)
+// static void facetag_set_cb(BMesh *bm, Scene *UNUSED(scene), BMFace *f, const bool val)
static void facetag_set_cb(BMFace *f, bool val, void *user_data_v)
{
struct UserData *user_data = user_data_v;
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index a39944fc145..ffdb434405e 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -939,8 +939,8 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed
l_b;
l = BM_loop_other_edge_loop(l, v);
- /* important edge is manifold else we can be attempting to split off a fan that don't budge,
- * not crashing but adds duplicate edge. */
+ /* Important edge is manifold else we can be attempting to split off
+ * a fan that don't budge, not crashing but adds duplicate edge. */
if (BM_edge_is_manifold(l->e)) {
l = l->radial_next;
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index d81de37add3..9df03a81762 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -462,7 +462,8 @@ static void findnearestvert__doClosest(void *userData,
*
* \param r_dist: (in/out), minimal distance to the nearest and at the end, actual distance
* \param use_select_bias:
- * - When true, selected vertices are given a 5 pixel bias to make them further than unselect verts.
+ * - When true, selected vertices are given a 5 pixel bias
+ * to make them further than unselect verts.
* - When false, unselected vertices are given the bias.
* \param use_cycle: Cycle over elements within #FIND_NEAR_CYCLE_THRESHOLD_MIN in order of index.
*/
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 701d7f15abc..2181bf01583 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -336,6 +336,7 @@ void MESH_OT_subdivide_edgering(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Subdivide Edge-Ring";
+ ot->description = "Subdivide perpendicular edges to the selected edge ring";
ot->idname = "MESH_OT_subdivide_edgering";
/* api callbacks */
@@ -2209,7 +2210,7 @@ static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op)
void MESH_OT_normals_make_consistent(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Make Normals Consistent";
+ ot->name = "Recalculate Normals";
ot->description = "Make face and vertex normals point either outside or inside the mesh";
ot->idname = "MESH_OT_normals_make_consistent";
@@ -2774,7 +2775,7 @@ void MESH_OT_uvs_reverse(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
- //RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror UVs around");
+ // RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror UVs around");
}
void MESH_OT_colors_rotate(wmOperatorType *ot)
@@ -2810,7 +2811,9 @@ void MESH_OT_colors_reverse(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
- //RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror colors around");
+#if 0
+ RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror colors around");
+#endif
}
/** \} */
@@ -3167,8 +3170,8 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op)
void MESH_OT_remove_doubles(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Remove Doubles";
- ot->description = "Remove duplicate vertices";
+ ot->name = "Merge by Distance";
+ ot->description = "Merge vertices based on their proximity";
ot->idname = "MESH_OT_remove_doubles";
/* api callbacks */
@@ -3571,7 +3574,7 @@ static float bm_edge_seg_isect(const float sco_a[2],
float threshold = 0.0;
int i;
- //threshold = 0.000001; /* tolerance for vertex intersection */
+ // threshold = 0.000001; /* tolerance for vertex intersection */
// XXX threshold = scene->toolsettings->select_thresh / 100;
/* Get screen coords of verts */
@@ -3713,7 +3716,7 @@ static float bm_edge_seg_isect(const float sco_a[2],
else {
perc = (yi - y21) / (y22 - y21); /* lower slope more accurate */
}
- //isect = 32768.0 * (perc + 0.0000153); /* Percentage in 1 / 32768ths */
+ // isect = 32768.0 * (perc + 0.0000153); /* Percentage in 1 / 32768ths */
break;
}
@@ -6791,7 +6794,7 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot)
/* identifiers */
ot->name = "Bridge Edge Loops";
- ot->description = "Make faces between two or more edge loops";
+ ot->description = "Create a bridge of faces between two or more selected edge loops";
ot->idname = "MESH_OT_bridge_edge_loops";
/* api callbacks */
@@ -7010,7 +7013,8 @@ void MESH_OT_offset_edge_loops(wmOperatorType *ot)
ot->exec = edbm_offset_edgeloop_exec;
ot->poll = ED_operator_editmesh;
- /* Keep internal, since this is only meant to be accessed via 'MESH_OT_offset_edge_loops_slide' */
+ /* Keep internal, since this is only meant to be accessed via
+ * 'MESH_OT_offset_edge_loops_slide'. */
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -8925,7 +8929,7 @@ static int edbm_smoothen_normals_exec(bContext *C, wmOperator *op)
void MESH_OT_smoothen_normals(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Smoothen Normals";
+ ot->name = "Smooth Normals Vectors";
ot->description = "Smoothen custom normals based on adjacent vertex normals";
ot->idname = "MESH_OT_smoothen_normals";
@@ -9002,7 +9006,7 @@ static int edbm_mod_weighted_strength_exec(bContext *C, wmOperator *op)
void MESH_OT_mod_weighted_strength(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Face Strength";
+ ot->name = "Face Normals Strength";
ot->description = "Set/Get strength of face (used in Weighted Normal modifier)";
ot->idname = "MESH_OT_mod_weighted_strength";
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 275bbf36198..2a950677f13 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -242,7 +242,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_rip_move",
@@ -251,7 +251,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_rip_edge_move",
@@ -260,7 +260,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_rip_edge");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move",
@@ -269,34 +269,34 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_context_move",
"Extrude Region and Move",
- "Extrude context and move result",
+ "Extrude region together along the average normal",
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_context");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_region_shrink_fatten",
"Extrude Region and Shrink/Fatten",
- "Extrude along normals and move result",
+ "Extrude region together along local normals",
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move",
"Extrude Individual Faces and Move",
- "Extrude faces and move result",
+ "Extrude each individual face separately along local normals",
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move",
@@ -305,7 +305,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move",
@@ -314,7 +314,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_polybuild_face_at_cursor_move",
@@ -323,7 +323,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_polybuild_face_at_cursor");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_polybuild_split_at_cursor_move",
@@ -332,7 +332,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_polybuild_split_at_cursor");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
}
diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c
index 4de277901f4..c203ca56d74 100644
--- a/source/blender/editors/metaball/mball_ops.c
+++ b/source/blender/editors/metaball/mball_ops.c
@@ -59,7 +59,7 @@ void ED_operatormacros_metaball(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MBALL_OT_duplicate_metaelems");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
}
void ED_keymap_metaball(wmKeyConfig *keyconf)
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt
index 8ef0d85bcfd..eaef9313431 100644
--- a/source/blender/editors/object/CMakeLists.txt
+++ b/source/blender/editors/object/CMakeLists.txt
@@ -22,19 +22,19 @@ set(INC
../../blentranslation
../../bmesh
../../depsgraph
+ ../../gpencil_modifiers
../../gpu
../../ikplugin
../../imbuf
../../makesdna
../../makesrna
../../modifiers
- ../../gpencil_modifiers
- ../../shader_fx
../../python
+ ../../shader_fx
../../render/extern/include
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 87782e895b5..f8a13579732 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1452,7 +1452,8 @@ static int object_delete_exec(bContext *C, wmOperator *op)
}
/* remove from Grease Pencil parent */
- /* XXX This is likely not correct? Will also remove parent from grease pencil from other scenes,
+ /* XXX This is likely not correct?
+ * Will also remove parent from grease pencil from other scenes,
* even when use_global is false... */
for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -2480,7 +2481,6 @@ static int add_named_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BKE_scene_object_base_flag_sync_from_object(basen);
basen->object->restrictflag &= ~OB_RESTRICT_VIEW;
if (event) {
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index 6e2f0dba969..70a9870e6ae 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -382,7 +382,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
bkr.number_of_rays = scene->r.bake_samples;
bkr.threads = BKE_scene_num_threads(scene);
bkr.user_scale = (scene->r.bake_flag & R_BAKE_USERSCALE) ? scene->r.bake_user_scale : -1.0f;
- //bkr.reports= op->reports;
+ // bkr.reports= op->reports;
/* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */
bkr.ob_image.array = bake_object_image_get_array(ob);
@@ -427,7 +427,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj)
bkj->number_of_rays = scene->r.bake_samples;
bkj->threads = BKE_scene_num_threads(scene);
bkj->user_scale = (scene->r.bake_flag & R_BAKE_USERSCALE) ? scene->r.bake_user_scale : -1.0f;
- //bkj->reports = op->reports;
+ // bkj->reports = op->reports;
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) {
MultiresBakerJobData *data;
@@ -484,7 +484,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa
bkr.mode = bkj->mode;
bkr.use_lores_mesh = bkj->use_lores_mesh;
bkr.user_scale = bkj->user_scale;
- //bkr.reports = bkj->reports;
+ // bkr.reports = bkj->reports;
bkr.ob_image.array = data->ob_image.array;
bkr.ob_image.len = data->ob_image.len;
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 85801dbdd0a..5ae757cac56 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -386,7 +386,7 @@ static bool write_external_bake_pixels(const char *filepath,
#ifndef WIN32
chmod(filepath, S_IRUSR | S_IWUSR);
#endif
- //printf("%s saving bake map: '%s'\n", __func__, filepath);
+ // printf("%s saving bake map: '%s'\n", __func__, filepath);
}
/* garbage collection */
diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.c
index 54c50db99a5..fcaefaf220d 100644
--- a/source/blender/editors/object/object_collection.c
+++ b/source/blender/editors/object/object_collection.c
@@ -481,7 +481,7 @@ static int collection_link_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- /* Adding object to collection which is used as duplicollection for self is bad idea.
+ /* Adding object to collection which is used as dupli-collection for self is bad idea.
*
* It is also bad idea to add object to collection which is in collection which
* contains our current object.
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 8ae736d42c0..078135f46ff 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -160,7 +160,7 @@ static void validate_pyconstraint_cb(Main *bmain, void *arg1, void *arg2)
if (index) {
/* innovative use of a for...loop to search */
for (text = bmain->texts.first, i = 1; text && index != i; i++, text = text->id.next) {
- ;
+ /* pass */
}
}
data->text = text;
@@ -1828,9 +1828,8 @@ static bool get_new_constraint_target(
/* transform cent to global coords for loc */
if (pchanact) {
- /* since by default, IK targets the tip of the last bone, use the tip of the active PoseChannel
- * if adding a target for an IK Constraint
- */
+ /* Since by default, IK targets the tip of the last bone,
+ * use the tip of the active PoseChannel if adding a target for an IK Constraint. */
if (con_type == CONSTRAINT_TYPE_KINEMATIC) {
mul_v3_m4v3(obt->loc, obact->obmat, pchanact->pose_tail);
}
@@ -1844,7 +1843,7 @@ static bool get_new_constraint_target(
/* restore, BKE_object_add sets active */
BASACT(view_layer) = base;
- base->flag |= BASE_SELECTED;
+ ED_object_base_select(base, BA_SELECT);
/* make our new target the new object */
*tar_ob = obt;
@@ -1879,14 +1878,6 @@ static int constraint_add_exec(
if (type == CONSTRAINT_TYPE_NULL) {
return OPERATOR_CANCELLED;
}
- if ((type == CONSTRAINT_TYPE_KINEMATIC) && ((!pchan) || (list != &pchan->constraints))) {
- BKE_report(op->reports, RPT_ERROR, "IK constraint can only be added to bones");
- return OPERATOR_CANCELLED;
- }
- if ((type == CONSTRAINT_TYPE_SPLINEIK) && ((!pchan) || (list != &pchan->constraints))) {
- BKE_report(op->reports, RPT_ERROR, "Spline IK constraint can only be added to bones");
- return OPERATOR_CANCELLED;
- }
/* Create a new constraint of the type required,
* and add it to the active/given constraints list. */
@@ -2024,8 +2015,33 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op)
/* ------------------ */
+/* Filters constraints that are only compatible with bones */
+static const EnumPropertyItem *object_constraint_add_itemf(bContext *UNUSED(C),
+ PointerRNA *UNUSED(ptr),
+ PropertyRNA *UNUSED(prop),
+ bool *r_free)
+{
+ const EnumPropertyItem *item = rna_enum_constraint_type_items;
+ EnumPropertyItem *object_constraint_items = NULL;
+ int totitem = 0;
+
+ while(item->identifier) {
+ if((item->value != CONSTRAINT_TYPE_KINEMATIC) && (item->value != CONSTRAINT_TYPE_SPLINEIK)) {
+ RNA_enum_item_add(&object_constraint_items, &totitem, item);
+ }
+ item++;
+ }
+
+ RNA_enum_item_end(&object_constraint_items, &totitem);
+ *r_free = true;
+
+ return object_constraint_items;
+}
+
void OBJECT_OT_constraint_add(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "Add Constraint";
ot->description = "Add a constraint to the active object";
@@ -2040,11 +2056,15 @@ void OBJECT_OT_constraint_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", "");
+ prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "");
+ RNA_def_enum_funcs(prop, object_constraint_add_itemf);
+ ot->prop = prop;
}
void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "Add Constraint (with Targets)";
ot->description =
@@ -2061,7 +2081,9 @@ void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", "");
+ prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "");
+ RNA_def_enum_funcs(prop, object_constraint_add_itemf);
+ ot->prop = prop;
}
void POSE_OT_constraint_add(wmOperatorType *ot)
@@ -2215,7 +2237,8 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op))
CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
bConstraint *con, *next;
- /* TODO: should we be checking if these constraints were local before we try and remove them? */
+ /* TODO: should we be checking if these constraints were local
+ * before we try and remove them? */
for (con = pchan->constraints.first; con; con = next) {
next = con->next;
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index afa2c342452..690bc270605 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -520,7 +520,8 @@ static int data_transfer_exec(bContext *C, wmOperator *op)
}
/* Used by both OBJECT_OT_data_transfer and OBJECT_OT_datalayout_transfer */
-/* Note this context poll is only really partial, it cannot check for all possible invalid cases. */
+/* Note this context poll is only really partial,
+ * it cannot check for all possible invalid cases. */
static bool data_transfer_poll(bContext *C)
{
Object *ob = ED_object_active_context(C);
@@ -773,8 +774,8 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
dtmd = (DataTransferModifierData *)edit_modifier_property_get(
op, ob_act, eModifierType_DataTransfer);
- /* If we have a modifier, we transfer data layout from this modifier's source object to active one.
- * Else, we transfer data layout from active object to all selected ones. */
+ /* If we have a modifier, we transfer data layout from this modifier's source object to
+ * active one. Else, we transfer data layout from active object to all selected ones. */
if (dtmd) {
Object *ob_src = dtmd->ob_source;
Object *ob_dst = ob_act;
@@ -841,6 +842,7 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
BLI_freelistN(&ctx_objects);
}
+ DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 95737453777..795e1dd66a5 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -703,8 +703,6 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
}
}
- ED_space_image_uv_sculpt_update(bmain, CTX_wm_manager(C), scene);
-
WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode);
if (G.background == false) {
@@ -1420,7 +1418,7 @@ void OBJECT_OT_mode_set(wmOperatorType *ot)
/* api callbacks */
ot->exec = object_mode_set_exec;
- ot->poll = object_mode_set_poll; //ED_operator_object_active_editable;
+ ot->poll = object_mode_set_poll; // ED_operator_object_active_editable;
/* flags */
ot->flag = 0; /* no register/undo here, leave it to operators being called */
@@ -1446,7 +1444,7 @@ void OBJECT_OT_mode_set_or_submode(wmOperatorType *ot)
/* api callbacks */
ot->exec = object_mode_set_exec;
- ot->poll = object_mode_set_poll; //ED_operator_object_active_editable;
+ ot->poll = object_mode_set_poll; // ED_operator_object_active_editable;
/* flags */
ot->flag = 0; /* no register/undo here, leave it to operators being called */
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index c1205635a96..c939cb0a61d 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -489,7 +489,7 @@ static bool hook_op_edit_poll(bContext *C)
if (ED_operator_editlattice(C)) {
return 1;
}
- //if (ED_operator_editmball(C)) return 1;
+ // if (ED_operator_editmball(C)) return 1;
}
return 0;
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index bc95360eab9..e555f0d940d 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -578,12 +578,11 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports),
static Mesh *modifier_apply_create_mesh_for_modifier(Depsgraph *depsgraph,
Scene *UNUSED(scene),
Object *object,
- ModifierData *md,
+ ModifierData *md_eval,
bool build_shapekey_layers)
{
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
- ModifierData *md_eval = modifiers_findByName(object_eval, md->name);
Mesh *mesh_applied = BKE_mesh_create_derived_for_modifier(
depsgraph, scene_eval, object_eval, md_eval, build_shapekey_layers);
return mesh_applied;
@@ -594,11 +593,11 @@ static int modifier_apply_shape(Main *bmain,
Depsgraph *depsgraph,
Scene *scene,
Object *ob,
- ModifierData *md)
+ ModifierData *md_eval)
{
- const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ const ModifierTypeInfo *mti = modifierType_getInfo(md_eval->type);
- if (mti->isDisabled && mti->isDisabled(scene, md, 0)) {
+ if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) {
BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply");
return 0;
}
@@ -620,12 +619,12 @@ static int modifier_apply_shape(Main *bmain,
Key *key = me->key;
KeyBlock *kb;
- if (!modifier_isSameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) {
+ if (!modifier_isSameTopology(md_eval) || mti->type == eModifierTypeType_NonGeometrical) {
BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to shapes");
return 0;
}
- mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md, false);
+ mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md_eval, false);
if (!mesh_applied) {
BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply");
return 0;
@@ -640,7 +639,7 @@ static int modifier_apply_shape(Main *bmain,
BKE_keyblock_convert_from_mesh(me, key, kb);
}
- kb = BKE_keyblock_add(key, md->name);
+ kb = BKE_keyblock_add(key, md_eval->name);
BKE_mesh_nomain_to_meshkey(mesh_applied, me, kb);
BKE_id_free(NULL, mesh_applied);
@@ -653,11 +652,11 @@ static int modifier_apply_shape(Main *bmain,
}
static int modifier_apply_obdata(
- ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md)
+ ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md_eval)
{
- const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ const ModifierTypeInfo *mti = modifierType_getInfo(md_eval->type);
- if (mti->isDisabled && mti->isDisabled(scene, md, 0)) {
+ if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) {
BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply");
return 0;
}
@@ -665,7 +664,7 @@ static int modifier_apply_obdata(
if (ob->type == OB_MESH) {
Mesh *mesh_applied;
Mesh *me = ob->data;
- MultiresModifierData *mmd = find_multires_modifier_before(scene, md);
+ MultiresModifierData *mmd = find_multires_modifier_before(scene, md_eval);
if (me->key && mti->type != eModifierTypeType_NonGeometrical) {
BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to a mesh with shape keys");
@@ -673,18 +672,18 @@ static int modifier_apply_obdata(
}
/* Multires: ensure that recent sculpting is applied */
- if (md->type == eModifierType_Multires) {
+ if (md_eval->type == eModifierType_Multires) {
multires_force_update(ob);
}
if (mmd && mmd->totlvl && mti->type == eModifierTypeType_OnlyDeform) {
- if (!multiresModifier_reshapeFromDeformModifier(depsgraph, mmd, ob, md)) {
+ if (!multiresModifier_reshapeFromDeformModifier(depsgraph, mmd, ob, md_eval)) {
BKE_report(reports, RPT_ERROR, "Multires modifier returned error, skipping apply");
return 0;
}
}
else {
- mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md, true);
+ mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md_eval, true);
if (!mesh_applied) {
BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply");
return 0;
@@ -692,7 +691,7 @@ static int modifier_apply_obdata(
BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, &CD_MASK_MESH, true);
- if (md->type == eModifierType_Multires) {
+ if (md_eval->type == eModifierType_Multires) {
multires_customdata_delete(me);
}
}
@@ -716,7 +715,7 @@ static int modifier_apply_obdata(
"Applied modifier only changed CV points, not tessellated/bevel vertices");
vertexCos = BKE_curve_nurbs_vertexCos_get(&curve_eval->nurb, &numVerts);
- mti->deformVerts(md, &mectx, NULL, vertexCos, numVerts);
+ mti->deformVerts(md_eval, &mectx, NULL, vertexCos, numVerts);
BK_curve_nurbs_vertexCos_apply(&curve->nurb, vertexCos);
MEM_freeN(vertexCos);
@@ -2211,8 +2210,8 @@ static void oceanbake_free(void *customdata)
/* called by oceanbake, only to check job 'stop' value */
static int oceanbake_breakjob(void *UNUSED(customdata))
{
- //OceanBakeJob *ob = (OceanBakeJob *)customdata;
- //return *(ob->stop);
+ // OceanBakeJob *ob = (OceanBakeJob *)customdata;
+ // return *(ob->stop);
/* this is not nice yet, need to make the jobs list template better
* for identifying/acting upon various different jobs */
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 8e3f916b2e4..afc0297cb01 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -271,7 +271,7 @@ void ED_operatormacros_object(void)
if (ot) {
WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
}
/* grr, should be able to pass options on... */
@@ -283,7 +283,7 @@ void ED_operatormacros_object(void)
otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
RNA_boolean_set(otmacro->ptr, "linked", true);
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
}
}
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index bf74c17c361..e15d85a7953 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -994,15 +994,13 @@ static int parent_set_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
+static int parent_set_invoke_menu(bContext *C, wmOperatorType *ot)
{
Object *parent = ED_object_active_context(C);
uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Set Parent To"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
- wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_parent_set", true);
PointerRNA opptr;
-
#if 0
uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_OBJECT);
#else
@@ -1072,6 +1070,14 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
return OPERATOR_INTERFACE;
}
+static int parent_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ if (RNA_property_is_set(op->ptr, op->type->prop)) {
+ return parent_set_exec(C, op);
+ }
+ return parent_set_invoke_menu(C, op->type);
+}
+
static bool parent_set_poll_property(const bContext *UNUSED(C),
wmOperator *op,
const PropertyRNA *prop)
@@ -2152,8 +2158,7 @@ static bool make_local_all__instance_indirect_unused(Main *bmain,
BKE_collection_object_add(bmain, collection, ob);
base = BKE_view_layer_base_find(view_layer, ob);
- base->flag |= BASE_SELECTED;
- BKE_scene_object_base_flag_sync_from_base(base);
+ ED_object_base_select(base, BA_SELECT);
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
changed = true;
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index f0508b5f35c..afdda8d6b7f 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -87,7 +87,7 @@
* \{ */
/**
- * simple API for object selection, rather than just using the flag
+ * Simple API for object selection, rather than just using the flag
* this takes into account the 'restrict selection in 3d view' flag.
* deselect works always, the restriction just prevents selection
*
@@ -655,8 +655,8 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
if (nr == OBJECT_SELECT_LINKED_IPO) {
// XXX old animation system
- //if (ob->ipo == 0) return OPERATOR_CANCELLED;
- //object_select_all_by_ipo(C, ob->ipo)
+ // if (ob->ipo == 0) return OPERATOR_CANCELLED;
+ // object_select_all_by_ipo(C, ob->ipo)
return OPERATOR_CANCELLED;
}
else if (nr == OBJECT_SELECT_LINKED_OBDATA) {
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 9e1ef96ab93..8836d913475 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -1298,7 +1298,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
ignore_parent_tx(C, bmain, scene, ob);
/* other users? */
- //CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects)
+ // CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects)
//{
/* use existing context looper */
@@ -1324,7 +1324,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
ignore_parent_tx(C, bmain, scene, ob_other);
}
}
- //CTX_DATA_END;
+ // CTX_DATA_END;
}
}
}
diff --git a/source/blender/editors/object/object_utils.c b/source/blender/editors/object/object_utils.c
index 06a755c30bd..dbca0bbf97b 100644
--- a/source/blender/editors/object/object_utils.c
+++ b/source/blender/editors/object/object_utils.c
@@ -133,7 +133,7 @@ bool ED_object_calc_active_center(Object *ob, const bool select_only, float r_ce
return false;
}
else {
- if (!select_only || (ob->flag & SELECT)) {
+ if (!select_only || (ob->base_flag & BASE_SELECTED)) {
copy_v3_v3(r_center, ob->obmat[3]);
return true;
}
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index d422ee565a3..05a3d86a23c 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -58,6 +58,7 @@
#include "BKE_lattice.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
#include "DNA_armature_types.h"
#include "RNA_access.h"
@@ -893,7 +894,8 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum)
* deform group.
*/
- /* TODO, this is slow in a loop, better pass def_nr directly, but leave for later... - campbell */
+ /* TODO(campbell): This is slow in a loop, better pass def_nr directly,
+ * but leave for later. */
const int def_nr = BLI_findindex(&ob->defbase, dg);
if (def_nr != -1) {
@@ -1297,7 +1299,7 @@ static void getVerticalAndHorizontalChange(const float norm[3],
dists[index] = dot_v3v3(norm, end) + d;
/* vertical change */
changes[index][0] = dists[index] - distToStart;
- //printf("vc %f %f\n", distance(end, projB, 3) - distance(start, projA, 3), changes[index][0]);
+ // printf("vc %f %f\n", distance(end, projB, 3) - distance(start, projA, 3), changes[index][0]);
/* horizontal change */
changes[index][1] = len_v3v3(projA, projB);
}
@@ -2701,6 +2703,7 @@ static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
BKE_object_defgroup_add(ob);
+ DEG_relations_tag_update(CTX_data_main(C));
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);
@@ -2738,6 +2741,7 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op)
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -2941,6 +2945,7 @@ static int vertex_group_copy_exec(bContext *C, wmOperator *UNUSED(op))
vgroup_duplicate(ob);
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);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
@@ -3471,6 +3476,7 @@ static int vertex_group_mirror_exec(bContext *C, wmOperator *op)
ED_mesh_report_mirror(op, totmirr, totfail);
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);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -3559,6 +3565,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, ID_RECALC_GEOMETRY);
+ DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob);
changed_tot++;
}
diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt
index 3eb443320c3..021c17a94c2 100644
--- a/source/blender/editors/physics/CMakeLists.txt
+++ b/source/blender/editors/physics/CMakeLists.txt
@@ -25,8 +25,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 7178a485a6e..40b7a245f69 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -47,6 +47,7 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "ED_mesh.h"
#include "ED_screen.h"
@@ -83,10 +84,8 @@ static int surface_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- /* set preview for this surface only and set active */
canvas->active_sur = 0;
for (surface = surface->prev; surface; surface = surface->prev) {
- surface->flags &= ~MOD_DPAINT_PREVIEW;
canvas->active_sur++;
}
@@ -136,7 +135,6 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
id++;
}
- dynamicPaint_resetPreview(canvas);
DEG_id_tag_update(&obj_ctx->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obj_ctx);
@@ -258,11 +256,13 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
if (!exists) {
BKE_object_defgroup_add_name(ob, name);
+ DEG_relations_tag_update(CTX_data_main(C));
}
else {
bDeformGroup *defgroup = defgroup_find_name(ob, name);
if (defgroup) {
BKE_object_defgroup_remove(ob, defgroup);
+ DEG_relations_tag_update(CTX_data_main(C));
}
}
}
@@ -361,6 +361,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
DynamicPaintSurface *surface = job->surface;
Object *cObject = job->ob;
DynamicPaintCanvasSettings *canvas = surface->canvas;
+ Scene *input_scene = DEG_get_input_scene(job->depsgraph);
Scene *scene = job->scene;
int frame = 1, orig_frame;
int frames;
@@ -376,8 +377,8 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
/* Set frame to start point (also inits modifier data) */
frame = surface->start_frame;
- orig_frame = scene->r.cfra;
- scene->r.cfra = (int)frame;
+ orig_frame = input_scene->r.cfra;
+ input_scene->r.cfra = (int)frame;
ED_update_for_newframe(job->bmain, job->depsgraph);
/* Init surface */
@@ -403,7 +404,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
*(job->progress) = progress;
/* calculate a frame */
- scene->r.cfra = (int)frame;
+ input_scene->r.cfra = (int)frame;
ED_update_for_newframe(job->bmain, job->depsgraph);
if (!dynamicPaint_calculateFrame(surface, job->depsgraph, scene, cObject, frame)) {
job->success = 0;
@@ -439,7 +440,8 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
}
}
- scene->r.cfra = orig_frame;
+ input_scene->r.cfra = orig_frame;
+ ED_update_for_newframe(job->bmain, job->depsgraph);
}
static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update, float *progress)
@@ -471,25 +473,26 @@ static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update
*/
static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
{
- DynamicPaintModifierData *pmd = NULL;
- DynamicPaintCanvasSettings *canvas;
- Object *ob = ED_object_context(C);
- Scene *scene = CTX_data_scene(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Object *ob_ = ED_object_context(C);
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, ob_);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
DynamicPaintSurface *surface;
/*
* Get modifier data
*/
- pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
- if (!pmd) {
+ DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(
+ object_eval, eModifierType_DynamicPaint);
+ if (pmd == NULL) {
BKE_report(op->reports, RPT_ERROR, "Bake failed: no Dynamic Paint modifier found");
return OPERATOR_CANCELLED;
}
/* Make sure we're dealing with a canvas */
- canvas = pmd->canvas;
- if (!canvas) {
+ DynamicPaintCanvasSettings *canvas = pmd->canvas;
+ if (canvas == NULL) {
BKE_report(op->reports, RPT_ERROR, "Bake failed: invalid canvas");
return OPERATOR_CANCELLED;
}
@@ -501,15 +504,15 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
DynamicPaintBakeJob *job = MEM_mallocN(sizeof(DynamicPaintBakeJob), "DynamicPaintBakeJob");
job->bmain = CTX_data_main(C);
- job->scene = scene;
+ job->scene = scene_eval;
job->depsgraph = CTX_data_depsgraph(C);
- job->ob = ob;
+ job->ob = object_eval;
job->canvas = canvas;
job->surface = surface;
wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
CTX_wm_window(C),
- scene,
+ CTX_data_scene(C),
"Dynamic Paint Bake",
WM_JOB_PROGRESS,
WM_JOB_TYPE_DPAINT_BAKE);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 9921ca02af9..dc634865a0a 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -371,7 +371,7 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
}
else {
key->flag |= PEK_HIDE;
- //key->flag &= ~PEK_SELECT;
+ // key->flag &= ~PEK_SELECT;
}
}
}
@@ -4162,7 +4162,8 @@ static void brush_add_count_iter(void *__restrict iter_data_v,
add_pars[iter].num_dmcache = DMCACHE_ISCHILD;
}
else if (iter_data->mesh == psmd_eval->mesh_original) {
- /* Final DM is not same topology as orig mesh, we have to map num_dmcache to real final dm. */
+ /* Final DM is not same topology as orig mesh,
+ * we have to map num_dmcache to real final dm. */
add_pars[iter].num = add_pars[iter].num_dmcache;
add_pars[iter].num_dmcache = psys_particle_dm_face_lookup(psmd_eval->mesh_final,
psmd_eval->mesh_original,
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 1ec0aeffa17..fd092eb4b78 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -434,7 +434,8 @@ static void fluid_init_all_channels(bContext *C,
/* now scene data should be current according to animation system, so we fill the channels */
/* Domain time */
- // TODO: have option for not running sim, time mangling, in which case second case comes in handy
+ /* TODO: have option for not running sim, time mangling,
+ * in which case second case comes in handy. */
if (channels->DomainTime) {
time = get_fluid_rate(domainSettings) * (float)channels->aniFrameTime;
timeAtFrame = channels->timeAtFrame[i] + time;
diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt
index 5d414c3af0f..6c62dbcb3a2 100644
--- a/source/blender/editors/render/CMakeLists.txt
+++ b/source/blender/editors/render/CMakeLists.txt
@@ -21,17 +21,17 @@ set(INC
../../blenlib
../../blenloader
../../blentranslation
+ ../../bmesh
../../depsgraph
../../draw
../../gpu
../../imbuf
- ../../bmesh
../../makesdna
../../makesrna
../../render/extern/include
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 8403f178284..09bcc0a3058 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -358,7 +358,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
* otherwise, invalidated cache entries can make their way into
* the output rendering. We can't put that into RE_BlenderFrame,
* since sequence rendering can call that recursively... (peter) */
- BKE_sequencer_cache_cleanup();
+ BKE_sequencer_cache_cleanup(scene);
RE_SetReports(re, op->reports);
@@ -978,7 +978,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
* otherwise, invalidated cache entries can make their way into
* the output rendering. We can't put that into RE_BlenderFrame,
* since sequence rendering can call that recursively... (peter) */
- BKE_sequencer_cache_cleanup();
+ BKE_sequencer_cache_cleanup(scene);
// store spare
// get view3d layer, local layer, make this nice api call to render
@@ -1115,7 +1115,10 @@ void RENDER_OT_render(wmOperatorType *ot)
ot->cancel = screen_render_cancel;
ot->exec = screen_render_exec;
- /*ot->poll = ED_operator_screenactive;*/ /* this isn't needed, causes failer in background mode */
+ /* this isn't needed, causes failer in background mode */
+#if 0
+ ot->poll = ED_operator_screenactive;
+#endif
prop = RNA_def_boolean(ot->srna,
"animation",
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 41ef5d81901..342c6269419 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -381,9 +381,10 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
}
}
else {
- draw_flags |= V3D_OFSDRAW_USE_GPENCIL;
+ draw_flags |= V3D_OFSDRAW_SHOW_ANNOTATION;
ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(depsgraph,
scene,
+ NULL,
OB_SOLID,
scene->camera,
oglrender->sizex,
@@ -488,8 +489,6 @@ static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender)
for (view_id = 0; view_id < oglrender->views_len; view_id++) {
context.view_id = view_id;
context.gpu_offscreen = oglrender->ofs;
- context.gpu_full_samples = oglrender->ofs_full_samples;
-
oglrender->seq_data.ibufs_arr[view_id] = BKE_sequencer_give_ibuf(&context, CFRA, chanshown);
}
}
@@ -516,24 +515,6 @@ static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender)
}
}
-static bool screen_opengl_fullsample_enabled(Scene *scene)
-{
- if (scene->r.scemode & R_FULL_SAMPLE) {
- return true;
- }
- else {
- /* XXX TODO:
- * Technically if the hardware supports MSAA we could keep using Blender 2.7x approach.
- * However anti-aliasing without full_sample is not playing well even in 2.7x.
- *
- * For example, if you enable depth of field, there is aliasing, even if the viewport is fine.
- * For 2.8x this is more complicated because so many things rely on shader.
- * So until we fix the gpu_framebuffer anti-aliasing suupport we need to force full sample.
- */
- return true;
- }
-}
-
static bool screen_opengl_render_init(bContext *C, wmOperator *op)
{
/* new render clears all callbacks */
@@ -547,8 +528,6 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
GPUOffScreen *ofs;
OGLRender *oglrender;
int sizex, sizey;
- const int samples = (scene->r.mode & R_OSA) ? scene->r.osa : 0;
- const bool full_samples = (samples != 0) && screen_opengl_fullsample_enabled(scene);
bool is_view_context = RNA_boolean_get(op->ptr, "view_context");
const bool is_animation = RNA_boolean_get(op->ptr, "animation");
const bool is_sequencer = RNA_boolean_get(op->ptr, "sequencer");
@@ -597,7 +576,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
/* corrects render size with actual size, not every card supports non-power-of-two dimensions */
DRW_opengl_context_enable(); /* Offscreen creation needs to be done in DRW context. */
- ofs = GPU_offscreen_create(sizex, sizey, full_samples ? 0 : samples, true, true, err_out);
+ ofs = GPU_offscreen_create(sizex, sizey, 0, true, true, err_out);
DRW_opengl_context_disable();
if (!ofs) {
@@ -610,8 +589,6 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
op->customdata = oglrender;
oglrender->ofs = ofs;
- oglrender->ofs_samples = samples;
- oglrender->ofs_full_samples = full_samples;
oglrender->sizex = sizex;
oglrender->sizey = sizey;
oglrender->bmain = CTX_data_main(C);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index c9a4f1948ce..64f20a4a348 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -331,28 +331,22 @@ static World *preview_get_localized_world(ShaderPreview *sp, World *world)
return sp->worldcopy;
}
-static ID *duplicate_ids(ID *id, Depsgraph *depsgraph)
+static ID *duplicate_ids(ID *id)
{
if (id == NULL) {
/* Non-ID preview render. */
return NULL;
}
- ID *id_eval = id;
-
- if (depsgraph) {
- id_eval = DEG_get_evaluated_id(depsgraph, id);
- }
-
switch (GS(id->name)) {
case ID_MA:
- return (ID *)BKE_material_localize((Material *)id_eval);
+ return (ID *)BKE_material_localize((Material *)id);
case ID_TE:
- return (ID *)BKE_texture_localize((Tex *)id_eval);
+ return (ID *)BKE_texture_localize((Tex *)id);
case ID_LA:
- return (ID *)BKE_light_localize((Light *)id_eval);
+ return (ID *)BKE_light_localize((Light *)id);
case ID_WO:
- return (ID *)BKE_world_localize((World *)id_eval);
+ return (ID *)BKE_world_localize((World *)id);
case ID_IM:
case ID_BR:
case ID_SCR:
@@ -455,7 +449,7 @@ static Scene *preview_prepare_scene(
}
}
else {
- sce->r.mode &= ~(R_OSA);
+ sce->display.render_aa = SCE_DISPLAY_AA_OFF;
}
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
@@ -820,11 +814,6 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
char name[32];
int sizex;
Main *pr_main = sp->pr_main;
- ID *id_eval = id;
-
- if (sp->depsgraph) {
- id_eval = DEG_get_evaluated_id(sp->depsgraph, id);
- }
/* in case of split preview, use border render */
if (split) {
@@ -848,7 +837,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
}
/* get the stuff from the builtin preview dbase */
- sce = preview_prepare_scene(sp->bmain, sp->scene, id_eval, idtype, sp);
+ sce = preview_prepare_scene(sp->bmain, sp->scene, id, idtype, sp);
if (sce == NULL) {
return;
}
@@ -872,7 +861,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
if (sp->pr_method == PR_ICON_RENDER) {
sce->r.scemode |= R_NO_IMAGE_LOAD;
- sce->r.mode |= R_OSA;
+ sce->display.render_aa = SCE_DISPLAY_AA_SAMPLES_8;
}
else if (sp->pr_method == PR_NODE_RENDER) {
if (idtype == ID_MA) {
@@ -881,10 +870,10 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
else if (idtype == ID_TE) {
sce->r.scemode |= R_TEXNODE_PREVIEW;
}
- sce->r.mode &= ~R_OSA;
+ sce->display.render_aa = SCE_DISPLAY_AA_OFF;
}
else { /* PR_BUTS_RENDER */
- sce->r.mode |= R_OSA;
+ sce->display.render_aa = SCE_DISPLAY_AA_SAMPLES_8;
}
/* callbacs are cleared on GetRender() */
@@ -1327,7 +1316,7 @@ void ED_preview_icon_render(
ip.scene = scene;
ip.owner = BKE_previewimg_id_ensure(id);
ip.id = id;
- ip.id_copy = duplicate_ids(id, NULL);
+ ip.id_copy = duplicate_ids(id);
icon_preview_add_size(&ip, rect, sizex, sizey);
@@ -1368,7 +1357,7 @@ void ED_preview_icon_job(
ip->depsgraph = CTX_data_depsgraph(C);
ip->owner = owner;
ip->id = id;
- ip->id_copy = duplicate_ids(id, ip->depsgraph);
+ ip->id_copy = duplicate_ids(id);
icon_preview_add_size(ip, rect, sizex, sizey);
@@ -1434,7 +1423,7 @@ void ED_preview_shader_job(const bContext *C,
sp->sizey = sizey;
sp->pr_method = method;
sp->id = id;
- sp->id_copy = duplicate_ids(id, sp->depsgraph);
+ sp->id_copy = duplicate_ids(id);
sp->own_id_copy = true;
sp->parent = parent;
sp->slot = slot;
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 3f3f98bc6e5..55353039b24 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -265,7 +265,7 @@ static void image_changed(Main *bmain, Image *ima)
/* textures */
for (tex = bmain->textures.first; tex; tex = tex->id.next) {
- if (tex->ima == ima) {
+ if (tex->type == TEX_IMAGE && tex->ima == ima) {
texture_changed(bmain, tex);
}
}
diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt
index 9576920bcd2..dc355148ad3 100644
--- a/source/blender/editors/screen/CMakeLists.txt
+++ b/source/blender/editors/screen/CMakeLists.txt
@@ -29,8 +29,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 5cd5153b060..8c73f4cd649 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -457,19 +457,6 @@ void ED_area_do_msg_notify_tag_refresh(
ED_area_tag_refresh(sa);
}
-static void region_do_msg_notify_tag_redraw(
- /* Follow wmMsgNotifyFn spec */
- bContext *UNUSED(C),
- wmMsgSubscribeKey *UNUSED(msg_key),
- wmMsgSubscribeValue *msg_val)
-{
- ARegion *ar = msg_val->owner;
- ED_region_tag_redraw(ar);
-
- /* FIXME(campbell): shouldn't be needed. */
- WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL);
-}
-
void ED_area_do_mgs_subscribe_for_tool_header(
/* Follow ARegionType.message_subscribe */
const struct bContext *UNUSED(C),
@@ -480,18 +467,39 @@ void ED_area_do_mgs_subscribe_for_tool_header(
struct ARegion *ar,
struct wmMsgBus *mbus)
{
+ BLI_assert(ar->regiontype == RGN_TYPE_TOOL_HEADER);
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = ar,
.user_data = ar,
- /* TODO(campbell): investigate why
- * ED_region_do_msg_notify_tag_redraw doesn't work here. */
- // .notify = ED_region_do_msg_notify_tag_redraw,
- .notify = region_do_msg_notify_tag_redraw,
+ .notify = ED_region_do_msg_notify_tag_redraw,
};
WM_msg_subscribe_rna_prop(
mbus, &workspace->id, workspace, WorkSpace, tools, &msg_sub_value_region_tag_redraw);
}
+void ED_area_do_mgs_subscribe_for_tool_ui(
+ /* Follow ARegionType.message_subscribe */
+ const struct bContext *UNUSED(C),
+ struct WorkSpace *workspace,
+ struct Scene *UNUSED(scene),
+ struct bScreen *UNUSED(screen),
+ struct ScrArea *UNUSED(sa),
+ struct ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ BLI_assert(ar->regiontype == RGN_TYPE_UI);
+ const char *category = UI_panel_category_active_get(ar, false);
+ if (category && STREQ(category, "Tool")) {
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+ WM_msg_subscribe_rna_prop(
+ mbus, &workspace->id, workspace, WorkSpace, tools, &msg_sub_value_region_tag_redraw);
+ }
+}
+
/**
* Although there's no general support for minimizing areas, the status-bar can
* be snapped to be only a few pixels high. A few pixels rather than 0 so it
@@ -1110,7 +1118,7 @@ static int rct_fits(const rcti *rect, char dir, int size)
static void region_overlap_fix(ScrArea *sa, ARegion *ar)
{
ARegion *ar1;
- const int align = ar->alignment & ~RGN_SPLIT_PREV;
+ const int align = RGN_ALIGN_ENUM_FROM_MASK(ar->alignment);
int align1 = 0;
/* find overlapping previous region on same place */
@@ -1227,7 +1235,7 @@ static void region_rect_recursive(
}
}
- int alignment = ar->alignment & ~RGN_SPLIT_PREV;
+ int alignment = RGN_ALIGN_ENUM_FROM_MASK(ar->alignment);
/* set here, assuming userpref switching forces to call this again */
ar->overlap = ED_region_is_overlap(sa->spacetype, ar->regiontype);
@@ -1524,7 +1532,8 @@ static void area_calc_totrct(ScrArea *sa, const rcti *window_rect)
sa->totrct.ymax -= px;
}
/* Although the following asserts are correct they lead to a very unstable Blender.
- * And the asserts would fail even in 2.7x (they were added in 2.8x as part of the top-bar commit).
+ * And the asserts would fail even in 2.7x
+ * (they were added in 2.8x as part of the top-bar commit).
* For more details see T54864. */
#if 0
BLI_assert(sa->totrct.xmin >= 0);
@@ -1550,6 +1559,13 @@ static void region_subwindow(ARegion *ar)
ar->visible = !hidden;
}
+static bool event_in_markers_region(const ARegion *ar, const wmEvent *event)
+{
+ rcti rect = ar->winrct;
+ rect.ymax = rect.ymin + UI_MARKER_MARGIN_Y;
+ return BLI_rcti_isect_pt(&rect, event->x, event->y);
+}
+
/**
* \param ar: Region, may be NULL when adding handlers for \a sa.
*/
@@ -1591,13 +1607,7 @@ static void ed_default_handlers(
if (flag & ED_KEYMAP_MARKERS) {
/* time-markers */
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Markers", 0, 0);
-
- /* use a boundbox restricted map */
- /* same local check for all areas */
- static rcti rect = {0, 10000, 0, -1};
- rect.ymax = UI_MARKER_MARGIN_Y;
- BLI_assert(ar->type->regionid == RGN_TYPE_WINDOW);
- WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct);
+ WM_event_add_keymap_handler_poll(handlers, keymap, event_in_markers_region);
}
if (flag & ED_KEYMAP_ANIMATION) {
/* frame changing and timeline operators (for time spaces) */
@@ -1688,7 +1698,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar
}
/* Some AZones use View2D data which is only updated in region init, so call that first! */
- region_azones_add(screen, area, ar, ar->alignment & ~RGN_SPLIT_PREV);
+ region_azones_add(screen, area, ar, RGN_ALIGN_ENUM_FROM_MASK(ar->alignment));
}
ED_area_azones_update(area, &win->eventstate->x);
@@ -1759,7 +1769,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
}
/* Some AZones use View2D data which is only updated in region init, so call that first! */
- region_azones_add(screen, sa, ar, ar->alignment & ~RGN_SPLIT_PREV);
+ region_azones_add(screen, sa, ar, RGN_ALIGN_ENUM_FROM_MASK(ar->alignment));
}
/* Avoid re-initializing tools while resizing the window. */
@@ -2514,9 +2524,8 @@ void ED_region_panels_draw(const bContext *C, ARegion *ar)
mask_buf.xmax -= UI_PANEL_CATEGORY_MARGIN_WIDTH;
mask = &mask_buf;
}
- View2DScrollers *scrollers = UI_view2d_scrollers_calc(
- C, v2d, mask, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ View2DScrollers *scrollers = UI_view2d_scrollers_calc(v2d, mask);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 6dcb9f8a82c..c60469e092f 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -98,7 +98,6 @@ const char *screen_context_dir[] = {
"weight_paint_object",
"image_paint_object",
"particle_edit_object",
- "uv_sculpt_object",
"pose_object",
"sequences",
"selected_sequences",
@@ -520,22 +519,6 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
- else if (CTX_data_equals(member, "uv_sculpt_object")) {
- /* TODO(campbell): most likely we change rules for uv_sculpt. */
- if (obact && (obact->mode & OB_MODE_EDIT)) {
- const ToolSettings *ts = scene->toolsettings;
- if (ts->use_uv_sculpt) {
- if (ED_uvedit_test(obedit)) {
- WorkSpace *workspace = CTX_wm_workspace(C);
- if ((workspace->tools_space_type == SPACE_IMAGE) &&
- (workspace->tools_mode == SI_MODE_UV)) {
- CTX_data_id_pointer_set(result, &obact->id);
- }
- }
- }
- }
- return 1;
- }
else if (CTX_data_equals(member, "pose_object")) {
Object *obpose = BKE_object_pose_armature_get(obact);
if (obpose) {
diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c
index 6fea27a9cff..1124070486f 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -40,7 +40,8 @@
#include "screen_intern.h"
/**
- * Draw horizontal shape visualizing future joining (left as well right direction of future joining).
+ * Draw horizontal shape visualizing future joining
+ * (left as well right direction of future joining).
*/
static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos)
{
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 50f0ab9b96b..07a87982890 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -424,31 +424,6 @@ void ED_screen_do_listen(bContext *C, wmNotifier *note)
}
}
-/* helper call for below, dpi changes headers */
-static void screen_refresh_headersizes(void)
-{
- const ListBase *lb = BKE_spacetypes_list();
- SpaceType *st;
-
- for (st = lb->first; st; st = st->next) {
- ARegionType *art;
- art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER);
- if (art) {
- art->prefsizey = ED_area_headersize();
- }
-
- art = BKE_regiontype_from_id(st, RGN_TYPE_TOOL_HEADER);
- if (art) {
- art->prefsizey = ED_area_headersize();
- }
-
- art = BKE_regiontype_from_id(st, RGN_TYPE_FOOTER);
- if (art) {
- art->prefsizey = ED_area_headersize();
- }
- }
-}
-
/* make this screen usable */
/* for file read and first use, for scaling window, area moves */
void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
@@ -461,7 +436,6 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
WM_window_set_dpi(win);
ED_screen_global_areas_refresh(win);
- screen_refresh_headersizes();
screen_geom_vertices_scale(win, screen);
@@ -910,9 +884,11 @@ static bScreen *screen_fullscreen_find_associated_normal_screen(const Main *bmai
{
for (bScreen *screen_iter = bmain->screens.first; screen_iter;
screen_iter = screen_iter->id.next) {
- ScrArea *sa = screen_iter->areabase.first;
- if (sa && sa->full == screen) {
- return screen_iter;
+ if ((screen_iter != screen) && ELEM(screen_iter->state, SCREENMAXIMIZED, SCREENFULL)) {
+ ScrArea *sa = screen_iter->areabase.first;
+ if (sa && sa->full == screen) {
+ return screen_iter;
+ }
}
}
@@ -931,9 +907,7 @@ bScreen *screen_change_prepare(
return NULL;
}
- if (ELEM(screen_new->state, SCREENMAXIMIZED, SCREENFULL)) {
- screen_new = screen_fullscreen_find_associated_normal_screen(bmain, screen_new);
- }
+ screen_new = screen_fullscreen_find_associated_normal_screen(bmain, screen_new);
/* check for valid winid */
if (!(screen_new->winid == 0 || screen_new->winid == win->winid)) {
diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c
index a0d9c232195..25855382307 100644
--- a/source/blender/editors/screen/screen_geometry.c
+++ b/source/blender/editors/screen/screen_geometry.c
@@ -160,7 +160,6 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
WM_window_rect_calc(win, &window_rect);
WM_window_screen_rect_calc(win, &screen_rect);
- const int headery_init = ED_area_headersize();
const int screen_size_x = BLI_rcti_size_x(&screen_rect);
const int screen_size_y = BLI_rcti_size_y(&screen_rect);
ScrVert *sv = NULL;
@@ -192,37 +191,55 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
sv->vec.y = screen_rect.ymin + round_fl_to_short((sv->vec.y - min[1]) * facy);
CLAMP(sv->vec.y, screen_rect.ymin, screen_rect.ymax - 1);
}
- }
-
- /* test for collapsed areas. This could happen in some blender version... */
- /* ton: removed option now, it needs Context... */
-
- /* make each window at least ED_area_headersize() high */
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- int headery = headery_init;
- /* adjust headery if verts are along the edge of window */
- if (sa->v1->vec.y > window_rect.ymin) {
- headery += U.pixelsize;
- }
- if (sa->v2->vec.y < (window_rect.ymax - 1)) {
- headery += U.pixelsize;
+ /* test for collapsed areas. This could happen in some blender version... */
+ /* ton: removed option now, it needs Context... */
+
+ int headery = ED_area_headersize() + (U.pixelsize * 2);
+
+ if (facy > 1) {
+ /* Keep timeline small in video edit workspace. */
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ if (sa->spacetype == SPACE_ACTION && sa->v1->vec.y == screen_rect.ymin &&
+ screen_geom_area_height(sa) <= headery * facy + 1) {
+ ScrEdge *se = BKE_screen_find_edge(sc, sa->v2, sa->v3);
+ if (se) {
+ const int yval = sa->v1->vec.y + headery - 1;
+
+ screen_geom_select_connected_edge(win, se);
+
+ /* all selected vertices get the right offset */
+ for (sv = sc->vertbase.first; sv; sv = sv->next) {
+ /* if is a collapsed area */
+ if (sv != sa->v1 && sv != sa->v4) {
+ if (sv->flag) {
+ sv->vec.y = yval;
+ }
+ }
+ }
+ }
+ }
+ }
}
-
- if (screen_geom_area_height(sa) < headery) {
- /* lower edge */
- ScrEdge *se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
- if (se && sa->v1 != sa->v2) {
- const int yval = sa->v2->vec.y - headery + 1;
-
- screen_geom_select_connected_edge(win, se);
-
- /* all selected vertices get the right offset */
- for (sv = sc->vertbase.first; sv; sv = sv->next) {
- /* if is a collapsed area */
- if (sv != sa->v2 && sv != sa->v3) {
- if (sv->flag) {
- sv->vec.y = yval;
+ if (facy < 1) {
+ /* make each window at least ED_area_headersize() high */
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ if (screen_geom_area_height(sa) < headery) {
+ /* lower edge */
+ ScrEdge *se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
+ if (se && sa->v1 != sa->v2) {
+ const int yval = sa->v2->vec.y - headery + 1;
+
+ screen_geom_select_connected_edge(win, se);
+
+ /* all selected vertices get the right offset */
+ for (sv = sc->vertbase.first; sv; sv = sv->next) {
+ /* if is not a collapsed area */
+ if (sv != sa->v2 && sv != sa->v3) {
+ if (sv->flag) {
+ sv->vec.y = yval;
+ }
+ }
}
}
}
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 8e7475ec511..61fa05f243f 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -67,6 +67,7 @@
#include "WM_types.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "ED_anim_api.h"
#include "ED_armature.h"
@@ -728,7 +729,9 @@ static bool azone_clipped_rect_calc(const AZone *az, rcti *r_rect_clip)
const ARegion *ar = az->ar;
*r_rect_clip = az->rect;
if (az->type == AZONE_REGION) {
- if (ar->overlap && (ar->v2d.keeptot != V2D_KEEPTOT_STRICT)) {
+ if (ar->overlap && (ar->v2d.keeptot != V2D_KEEPTOT_STRICT) &&
+ /* Only when this isn't hidden (where it's displayed as an button that expands). */
+ ((az->ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) == 0)) {
/* A floating region to be resized, clip by the visible region. */
switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
@@ -988,7 +991,8 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
AZone *az = screen_actionzone_find_xy(sc, &event->x);
sActionzoneData *sad;
- /* quick escape - Scroll azones only hide/unhide the scroll-bars, they have their own handling. */
+ /* Quick escape - Scroll azones only hide/unhide the scroll-bars,
+ * they have their own handling. */
if (az == NULL || ELEM(az->type, AZONE_REGION_SCROLL)) {
return OPERATOR_PASS_THROUGH;
}
@@ -2428,7 +2432,7 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
/* regions in regions. */
if (scalear->alignment & RGN_SPLIT_PREV) {
- const int align = scalear->alignment & RGN_ALIGN_ENUM_MASK;
+ const int align = RGN_ALIGN_ENUM_FROM_MASK(scalear->alignment);
if (ELEM(align, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
ARegion *ar = scalear->prev;
@@ -2767,7 +2771,7 @@ static int frame_offset_exec(bContext *C, wmOperator *op)
areas_do_frame_follow(C, false);
- BKE_sound_seek_scene(bmain, scene);
+ BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C));
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
@@ -2829,7 +2833,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
areas_do_frame_follow(C, true);
- BKE_sound_seek_scene(bmain, scene);
+ BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C));
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
@@ -2945,7 +2949,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
else {
areas_do_frame_follow(C, true);
- BKE_sound_seek_scene(bmain, scene);
+ BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C));
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
@@ -3012,7 +3016,7 @@ static int marker_jump_exec(bContext *C, wmOperator *op)
areas_do_frame_follow(C, true);
- BKE_sound_seek_scene(bmain, scene);
+ BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C));
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
@@ -4284,7 +4288,8 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
if (screen->animtimer && screen->animtimer == event->customdata) {
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
wmTimer *wt = screen->animtimer;
ScreenAnimData *sad = wt->customdata;
wmWindowManager *wm = CTX_wm_manager(C);
@@ -4305,7 +4310,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
}
if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false &&
- isfinite(time = BKE_sound_sync_scene(scene))) {
+ isfinite(time = BKE_sound_sync_scene(scene_eval))) {
double newfra = (double)time * FPS;
/* give some space here to avoid jumps */
@@ -4398,7 +4403,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
}
if (sad->flag & ANIMPLAY_FLAG_JUMPED) {
- BKE_sound_seek_scene(bmain, scene);
+ BKE_sound_update_and_seek(bmain, depsgraph);
#ifdef PROFILE_AUDIO_SYNCH
old_frame = CFRA;
#endif
@@ -4520,11 +4525,12 @@ int ED_screen_animation_play(bContext *C, int sync, int mode)
{
bScreen *screen = CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
+ Scene *scene_eval = DEG_get_evaluated_scene(CTX_data_depsgraph(C));
if (ED_screen_animation_playing(CTX_wm_manager(C))) {
/* stop playback now */
ED_screen_animation_timer(C, 0, 0, 0, 0);
- BKE_sound_stop_scene(scene);
+ BKE_sound_stop_scene(scene_eval);
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
@@ -4533,7 +4539,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode)
int refresh = SPACE_ACTION;
if (mode == 1) { /* XXX only play audio forwards!? */
- BKE_sound_play_scene(scene);
+ BKE_sound_play_scene(scene_eval);
}
ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode);
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 6294a64af0f..2dfa05cf6b0 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -165,7 +165,9 @@ bool ED_workspace_change(WorkSpace *workspace_new, bContext *C, wmWindowManager
}
screen_new = screen_change_prepare(screen_old, screen_new, bmain, C, win);
- BLI_assert(BKE_workspace_layout_screen_get(layout_new) == screen_new);
+ if (BKE_workspace_layout_screen_get(layout_new) != screen_new) {
+ layout_new = BKE_workspace_layout_find(workspace_new, screen_new);
+ }
if (screen_new == NULL) {
return false;
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index cddaf69b965..23617e687ea 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -29,8 +29,8 @@ set(INC
../../makesrna
../../render/extern/include
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 697622aae96..65e24cecf82 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -833,7 +833,7 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups,
x -= vc->ar->winrct.xmin;
y -= vc->ar->winrct.ymin;
- /* coloured overlay should be drawn separately */
+ /* Colored overlay should be drawn separately. */
if (col) {
if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY)) {
paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, true, true);
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 78832bbbd8f..474d3a8ceba 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -999,8 +999,8 @@ static void paint_2d_lift_soften(
/* subtract blurred image from normal image gives high pass filter */
sub_v3_v3v3(outrgb, rgba, outrgb);
- /* now rgba_ub contains the edge result, but this should be converted to luminance to avoid
- * colored speckles appearing in final image, and also to check for threshold */
+ /* Now rgba_ub contains the edge result, but this should be converted to luminance to
+ * avoid colored speckles appearing in final image, and also to check for threshold. */
outrgb[0] = outrgb[1] = outrgb[2] = IMB_colormanagement_get_luminance(outrgb);
if (fabsf(outrgb[0]) > threshold) {
float mask = BKE_brush_alpha_get(s->scene, s->brush);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 5436c5912bc..0340a4989e1 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -759,9 +759,9 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
}
}
else {
- //xi = (int)((uv[0]*ibuf->x) + 0.5f);
- //yi = (int)((uv[1]*ibuf->y) + 0.5f);
- //if (xi < 0 || xi >= ibuf->x || yi < 0 || yi >= ibuf->y) return 0;
+ // xi = (int)((uv[0]*ibuf->x) + 0.5f);
+ // yi = (int)((uv[1]*ibuf->y) + 0.5f);
+ // if (xi < 0 || xi >= ibuf->x || yi < 0 || yi >= ibuf->y) return 0;
/* wrap */
xi = mod_i((int)(uv[0] * ibuf->x), ibuf->x);
@@ -1772,8 +1772,8 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps,
} /* otherwise no mask normal is needed, were within the limit */
}
- /* This only works when the opacity doesn't change while painting, stylus pressure messes with this
- * so don't use it. */
+ /* This only works when the opacity doesn't change while painting, stylus pressure messes with
+ * this so don't use it. */
// if (ps->is_airbrush == 0) mask *= BKE_brush_alpha_get(ps->brush);
return mask;
@@ -1888,14 +1888,14 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
x_round = x_tile * IMAPAINT_TILE_SIZE;
y_round = y_tile * IMAPAINT_TILE_SIZE;
- //memset(projPixel, 0, size);
+ // memset(projPixel, 0, size);
tile_offset = (x_px - x_round) + (y_px - y_round) * IMAPAINT_TILE_SIZE;
tile_index = project_paint_undo_subtiles(tinf, x_tile, y_tile);
/* other thread may be initializing the tile so wait here */
while (projima->undoRect[tile_index] == TILE_PENDING) {
- ;
+ /* pass */
}
BLI_assert(tile_index < (IMAPAINT_TILE_NUMBER(ibuf->x) * IMAPAINT_TILE_NUMBER(ibuf->y)));
@@ -2203,8 +2203,8 @@ static bool line_clip_rect2f(const rctf *cliprect,
/**
* Scale the tri about its center
- * scaling by #PROJ_FACE_SCALE_SEAM (0.99x) is used for getting fake UV pixel coords that are on the
- * edge of the face but slightly inside it occlusion tests don't return hits on adjacent faces
+ * scaling by #PROJ_FACE_SCALE_SEAM (0.99x) is used for getting fake UV pixel coords that are on
+ * the edge of the face but slightly inside it occlusion tests don't return hits on adjacent faces.
*/
#ifndef PROJ_DEBUG_NOSEAMBLEED
@@ -2227,7 +2227,7 @@ static void scale_tri(float insetCos[3][3], const float *origCos[4], const float
add_v3_v3(insetCos[1], cent);
add_v3_v3(insetCos[2], cent);
}
-#endif //PROJ_DEBUG_NOSEAMBLEED
+#endif // PROJ_DEBUG_NOSEAMBLEED
static float len_squared_v2v2_alt(const float v1[2], const float v2_1, const float v2_2)
{
@@ -2303,8 +2303,8 @@ static bool project_bucket_isect_circle(const float cent[2],
/* Note for rect_to_uvspace_ortho() and rect_to_uvspace_persp()
* in ortho view this function gives good results when bucket_bounds are outside the triangle
- * however in some cases, perspective view will mess up with faces that have minimal screenspace area
- * (viewed from the side)
+ * however in some cases, perspective view will mess up with faces
+ * that have minimal screenspace area (viewed from the side).
*
* for this reason its not reliable in this case so we'll use the Simple Barycentric'
* funcs that only account for points inside the triangle.
@@ -2329,17 +2329,17 @@ static void rect_to_uvspace_ortho(const rctf *bucket_bounds,
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 3 : 0], uv1co, uv2co, uv3co, w);
- //uv[0] = bucket_bounds->xmax; // set above
+ // uv[0] = bucket_bounds->xmax; // set above
uv[1] = bucket_bounds->ymax;
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 2 : 1], uv1co, uv2co, uv3co, w);
uv[0] = bucket_bounds->xmin;
- //uv[1] = bucket_bounds->ymax; // set above
+ // uv[1] = bucket_bounds->ymax; // set above
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 1 : 2], uv1co, uv2co, uv3co, w);
- //uv[0] = bucket_bounds->xmin; // set above
+ // uv[0] = bucket_bounds->xmin; // set above
uv[1] = bucket_bounds->ymin;
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 0 : 3], uv1co, uv2co, uv3co, w);
@@ -2365,17 +2365,17 @@ static void rect_to_uvspace_persp(const rctf *bucket_bounds,
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 3 : 0], uv1co, uv2co, uv3co, w);
- //uv[0] = bucket_bounds->xmax; // set above
+ // uv[0] = bucket_bounds->xmax; // set above
uv[1] = bucket_bounds->ymax;
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 2 : 1], uv1co, uv2co, uv3co, w);
uv[0] = bucket_bounds->xmin;
- //uv[1] = bucket_bounds->ymax; // set above
+ // uv[1] = bucket_bounds->ymax; // set above
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 1 : 2], uv1co, uv2co, uv3co, w);
- //uv[0] = bucket_bounds->xmin; // set above
+ // uv[0] = bucket_bounds->xmin; // set above
uv[1] = bucket_bounds->ymin;
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 0 : 3], uv1co, uv2co, uv3co, w);
@@ -3093,13 +3093,13 @@ static void project_paint_face_init(const ProjPaintState *ps,
has_isect = 0;
for (y = bounds_px.ymin; y < bounds_px.ymax; y++) {
- //uv[1] = (((float)y) + 0.5f) / (float)ibuf->y;
+ // uv[1] = (((float)y) + 0.5f) / (float)ibuf->y;
/* use pixel offset UV coords instead */
uv[1] = (float)y / ibuf_yf;
has_x_isect = 0;
for (x = bounds_px.xmin; x < bounds_px.xmax; x++) {
- //uv[0] = (((float)x) + 0.5f) / ibuf->x;
+ // uv[0] = (((float)x) + 0.5f) / ibuf->x;
/* use pixel offset UV coords instead */
uv[0] = (float)x / ibuf_xf;
@@ -3134,7 +3134,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
/* Is this UV visible from the view? - raytrace */
/* project_paint_PickFace is less complex, use for testing */
- //if (project_paint_PickFace(ps, pixelScreenCo, w, &side) == tri_index) {
+ // if (project_paint_PickFace(ps, pixelScreenCo, w, &side) == tri_index) {
if ((ps->do_occlude == false) ||
!project_bucket_point_occluded(ps, bucketFaceNodes, tri_index, pixelScreenCo)) {
mask = project_paint_uvpixel_mask(ps, tri_index, w);
@@ -3307,7 +3307,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
for (x = bounds_px.xmin; x < bounds_px.xmax; x++) {
float puv[2] = {(float)x, (float)y};
bool in_bounds;
- //uv[0] = (((float)x) + 0.5f) / (float)ibuf->x;
+ // uv[0] = (((float)x) + 0.5f) / (float)ibuf->x;
/* use offset uvs instead */
uv[0] = (float)x / ibuf_xf;
@@ -4228,7 +4228,7 @@ static bool project_paint_winclip(const ProjPaintState *ps, const ProjPaintFaceC
(coSS->v1[1] > ps->screenMax[1] && coSS->v2[1] > ps->screenMax[1] &&
coSS->v3[1] > ps->screenMax[1])));
}
-#endif //PROJ_DEBUG_WINCLIP
+#endif // PROJ_DEBUG_WINCLIP
static void project_paint_build_proj_ima(ProjPaintState *ps,
MemArena *arena,
@@ -4306,6 +4306,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
* It's less trouble to set all faces to valid UV's,
* avoiding NULL checks all over. */
skip_tri = true;
+ tpage = NULL;
}
else {
tpage = slot->ima;
@@ -4343,7 +4344,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
continue;
}
-#endif //PROJ_DEBUG_WINCLIP
+#endif // PROJ_DEBUG_WINCLIP
/* backface culls individual triangles but mask normal will use polygon */
if (ps->do_backfacecull) {
@@ -4448,7 +4449,7 @@ static void project_paint_begin(const bContext *C,
proj_paint_layer_clone_init(ps, &layer_clone);
if (ps->do_layer_stencil || ps->do_stencil_brush) {
- //int layer_num = CustomData_get_stencil_layer(&ps->me_eval->ldata, CD_MLOOPUV);
+ // int layer_num = CustomData_get_stencil_layer(&ps->me_eval->ldata, CD_MLOOPUV);
int layer_num = CustomData_get_stencil_layer(&((Mesh *)ps->ob->data)->ldata, CD_MLOOPUV);
if (layer_num != -1) {
ps->mloopuv_stencil_eval = CustomData_get_layer_n(
@@ -4740,7 +4741,7 @@ static bool project_bucket_iter_next(ProjPaintState *ps,
BLI_thread_lock(LOCK_CUSTOM1);
}
- //printf("%d %d\n", ps->context_bucket_x, ps->context_bucket_y);
+ // printf("%d %d\n", ps->context_bucket_x, ps->context_bucket_y);
for (; ps->context_bucket_y < ps->bucketMax[1]; ps->context_bucket_y++) {
for (; ps->context_bucket_x < ps->bucketMax[0]; ps->context_bucket_x++) {
@@ -5564,7 +5565,7 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
for (a = 0; a < ps->thread_tot; a++) {
/* set defaults in handles */
- //memset(&handles[a], 0, sizeof(BakeShade));
+ // memset(&handles[a], 0, sizeof(BakeShade));
handles[a].ps = ps;
copy_v2_v2(handles[a].mval, pos);
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 1a8d2f79290..ea4814857ba 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -279,9 +279,6 @@ struct ListBase *ED_image_undosys_step_get_tiles(struct UndoStep *us_p);
struct ListBase *ED_image_undo_get_tiles(void);
/* sculpt_uv.c */
-bool uv_sculpt_poll(struct bContext *C);
-bool uv_sculpt_keymap_poll(struct bContext *C);
-
void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot);
/* paint_utils.c */
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index e15912efdd4..f58afcdadc1 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -524,37 +524,6 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
-static int brush_uv_sculpt_tool_set_exec(bContext *C, wmOperator *op)
-{
- Brush *brush;
- Scene *scene = CTX_data_scene(C);
- ToolSettings *ts = scene->toolsettings;
- ts->uv_sculpt_tool = RNA_enum_get(op->ptr, "tool");
- brush = ts->uvsculpt->paint.brush;
- /* To update toolshelf */
- WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
-
- return OPERATOR_FINISHED;
-}
-
-static void BRUSH_OT_uv_sculpt_tool_set(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "UV Sculpt Tool Set";
- ot->description = "Set the UV sculpt tool";
- ot->idname = "BRUSH_OT_uv_sculpt_tool_set";
-
- /* api callbacks */
- ot->exec = brush_uv_sculpt_tool_set_exec;
- ot->poll = uv_sculpt_poll;
-
- /* flags */
- ot->flag = 0;
-
- /* props */
- ot->prop = RNA_def_enum(ot->srna, "tool", rna_enum_uv_sculpt_tool_items, 0, "Tool", "");
-}
-
/***** Stencil Control *****/
typedef enum {
@@ -583,7 +552,8 @@ typedef struct {
float area_size[2];
StencilControlMode mode;
StencilConstraint constrain_mode;
- int mask; /* we are twaking mask or colour stencil */
+ /** We are tweaking mask or color stencil. */
+ int mask;
Brush *br;
float *dim_target;
float *rot_target;
@@ -1013,7 +983,6 @@ void ED_operatortypes_paint(void)
/* note, particle uses a different system, can be added with existing operators in wm.py */
WM_operatortype_append(PAINT_OT_brush_select);
- WM_operatortype_append(BRUSH_OT_uv_sculpt_tool_set);
/* image */
WM_operatortype_append(PAINT_OT_texture_paint_toggle);
@@ -1100,9 +1069,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
keymap = WM_keymap_ensure(keyconf, "Face Mask", 0, 0);
keymap->poll = facemask_paint_poll;
- keymap = WM_keymap_ensure(keyconf, "UV Sculpt", 0, 0);
- keymap->poll = uv_sculpt_keymap_poll;
-
/* paint stroke */
keymap = paint_stroke_modal_keymap(keyconf);
WM_modalkeymap_assign(keymap, "SCULPT_OT_brush_stroke");
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 91a2ebd0603..6d003820723 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -483,7 +483,7 @@ void paint_sample_color(
}
if (CTX_wm_view3d(C) && texpaint_proj) {
- /* first try getting a colour directly from the mesh faces if possible */
+ /* first try getting a color directly from the mesh faces if possible */
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
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 29d150c44fe..c1c2964156f 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -130,6 +130,7 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op)
op->reports, depsgraph, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
DEG_id_tag_update(&me->id, 0);
+ DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
index 88aed201b48..c71315872f6 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
@@ -41,6 +41,8 @@
#include "BKE_report.h"
#include "BKE_object.h"
+#include "DEG_depsgraph_build.h"
+
/* Only for blend modes. */
#include "IMB_imbuf.h"
@@ -93,6 +95,7 @@ bool ED_wpaint_ensure_data(bContext *C,
bDeformGroup *dg = defgroup_find_name(ob, pchan->name);
if (dg == NULL) {
dg = BKE_object_defgroup_add_name(ob, pchan->name); /* sets actdef */
+ DEG_relations_tag_update(CTX_data_main(C));
}
else {
int actdef = 1 + BLI_findindex(&ob->defbase, dg);
@@ -105,6 +108,7 @@ bool ED_wpaint_ensure_data(bContext *C,
}
if (BLI_listbase_is_empty(&ob->defbase)) {
BKE_object_defgroup_add(ob);
+ DEG_relations_tag_update(CTX_data_main(C));
}
/* ensure we don't try paint onto an invalid group */
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 5ae004fde5f..9ba7561b18b 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3455,6 +3455,10 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
return;
}
+ if (is_zero_v3(ss->cache->grab_delta_symmetry)) {
+ return;
+ }
+
mul_v3_v3v3(temp, area_no_sp, ss->cache->scale);
mul_v3_fl(temp, displace);
add_v3_v3(area_co, temp);
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 3cda90ea3f9..36cc3605273 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -139,121 +139,6 @@ typedef struct UvSculptData {
char invert;
} UvSculptData;
-static Brush *uv_sculpt_brush(bContext *C)
-{
- Scene *scene = CTX_data_scene(C);
- ToolSettings *settings = scene->toolsettings;
-
- if (!settings->uvsculpt) {
- return NULL;
- }
- return BKE_paint_brush(&settings->uvsculpt->paint);
-}
-
-static bool uv_sculpt_brush_poll_do(bContext *C, const bool check_region)
-{
- BMEditMesh *em;
- int ret;
- Object *obedit = CTX_data_edit_object(C);
- SpaceImage *sima = CTX_wm_space_image(C);
- Scene *scene = CTX_data_scene(C);
- ToolSettings *toolsettings = scene->toolsettings;
-
- if (!uv_sculpt_brush(C) || !obedit || obedit->type != OB_MESH || !sima ||
- ED_space_image_show_render(sima) || (sima->mode == SI_MODE_PAINT)) {
- return 0;
- }
-
- em = BKE_editmesh_from_object(obedit);
- ret = EDBM_uv_check(em);
-
- if (ret) {
- ARegion *ar = CTX_wm_region(C);
- if ((!toolsettings->use_uv_sculpt) ||
- (check_region && ar && (ar->regiontype != RGN_TYPE_WINDOW))) {
- ret = 0;
- }
- }
-
- return ret;
-}
-
-static bool uv_sculpt_brush_poll(bContext *C)
-{
- return uv_sculpt_brush_poll_do(C, true);
-}
-
-static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(customdata))
-{
-#define PX_SIZE_FADE_MAX 12.0f
-#define PX_SIZE_FADE_MIN 4.0f
-
- Scene *scene = CTX_data_scene(C);
- //Brush *brush = image_paint_brush(C);
- Paint *paint = BKE_paint_get_active_from_context(C);
- Brush *brush = BKE_paint_brush(paint);
-
- if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) {
- const float size = (float)BKE_brush_size_get(scene, brush);
- float alpha = 0.5f;
-
- /* fade out the brush (cheap trick to work around brush interfering with sampling [#])*/
- if (size < PX_SIZE_FADE_MIN) {
- return;
- }
- else if (size < PX_SIZE_FADE_MAX) {
- alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN);
- }
-
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformColor3fvAlpha(brush->add_col, alpha);
-
- GPU_line_smooth(true);
- GPU_blend(true);
- imm_draw_circle_wire_2d(pos, (float)x, (float)y, size, 40);
- GPU_blend(false);
- GPU_line_smooth(false);
-
- immUnbindProgram();
- }
-#undef PX_SIZE_FADE_MAX
-#undef PX_SIZE_FADE_MIN
-}
-
-void ED_space_image_uv_sculpt_update(Main *bmain, wmWindowManager *wm, Scene *scene)
-{
- ToolSettings *settings = scene->toolsettings;
- if (settings->use_uv_sculpt) {
- if (settings->uvsculpt == NULL) {
- settings->uv_sculpt_tool = UV_SCULPT_TOOL_GRAB;
- settings->uv_sculpt_settings = UV_SCULPT_LOCK_BORDERS | UV_SCULPT_ALL_ISLANDS;
- settings->uv_relax_method = UV_SCULPT_TOOL_RELAX_LAPLACIAN;
- }
- BKE_paint_ensure(settings, (Paint **)&settings->uvsculpt);
- BKE_paint_init(bmain, scene, PAINT_MODE_SCULPT_UV, PAINT_CURSOR_SCULPT);
-
- settings->uvsculpt->paint.paint_cursor = WM_paint_cursor_activate(
- wm, SPACE_IMAGE, RGN_TYPE_WINDOW, uv_sculpt_brush_poll, brush_drawcursor_uvsculpt, NULL);
- }
- else {
- if (settings->uvsculpt) {
- WM_paint_cursor_end(wm, settings->uvsculpt->paint.paint_cursor);
- settings->uvsculpt->paint.paint_cursor = NULL;
- }
- }
-}
-
-bool uv_sculpt_poll(bContext *C)
-{
- return uv_sculpt_brush_poll_do(C, true);
-}
-
-bool uv_sculpt_keymap_poll(bContext *C)
-{
- return uv_sculpt_brush_poll_do(C, false);
-}
-
/*********** Improved Laplacian Relaxation Operator ************************/
/* original code by Raul Fernandez Hernandez "farsthary" *
* adapted to uv smoothing by Antony Riakiatakis *
@@ -631,8 +516,9 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
int island_index = 0;
/* Holds, for each UvElement in elementMap, a pointer to its unique uv.*/
int *uniqueUv;
- data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH) ? UV_SCULPT_TOOL_RELAX :
- ts->uv_sculpt_tool;
+ data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH) ?
+ UV_SCULPT_TOOL_RELAX :
+ ts->uvsculpt->paint.brush->uv_sculpt_tool;
data->invert = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT) ? 1 : 0;
data->uvsculpt = &ts->uvsculpt->paint;
@@ -714,7 +600,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
if (do_island_optimization && (element->island != island_index)) {
/* skip this uv if not on the active island */
for (; element->next && !(element->next->separate); element = element->next) {
- ;
+ /* pass */
}
continue;
}
@@ -951,7 +837,7 @@ void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot)
/* api callbacks */
ot->invoke = uv_sculpt_stroke_invoke;
ot->modal = uv_sculpt_stroke_modal;
- ot->poll = uv_sculpt_poll;
+ ot->poll = ED_operator_uvedit_space_image;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/sound/CMakeLists.txt b/source/blender/editors/sound/CMakeLists.txt
index c2a88041a85..7f4b5a45aa3 100644
--- a/source/blender/editors/sound/CMakeLists.txt
+++ b/source/blender/editors/sound/CMakeLists.txt
@@ -19,6 +19,7 @@ set(INC
../include
../../blenkernel
../../blenlib
+ ../../depsgraph
../../makesdna
../../makesrna
../../windowmanager
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index c2165e8ec70..8ac49e447fe 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -62,6 +62,8 @@
# include <AUD_Special.h>
#endif
+#include "DEG_depsgraph_query.h"
+
#include "ED_sound.h"
#include "ED_util.h"
@@ -88,7 +90,6 @@ static int sound_open_exec(bContext *C, wmOperator *op)
bSound *sound;
PropertyPointerRNA *pprop;
PointerRNA idptr;
- AUD_SoundInfo info;
Main *bmain = CTX_data_main(C);
RNA_string_get(op->ptr, "filepath", path);
@@ -98,29 +99,8 @@ static int sound_open_exec(bContext *C, wmOperator *op)
sound_open_init(C, op);
}
- if (sound->playback_handle == NULL) {
- if (op->customdata) {
- MEM_freeN(op->customdata);
- }
- BKE_id_free(bmain, sound);
- BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
- return OPERATOR_CANCELLED;
- }
-
- info = AUD_getInfo(sound->playback_handle);
-
- if (info.specs.channels == AUD_CHANNELS_INVALID) {
- BKE_id_free(bmain, sound);
- if (op->customdata) {
- MEM_freeN(op->customdata);
- }
- BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
- return OPERATOR_CANCELLED;
- }
-
if (RNA_boolean_get(op->ptr, "mono")) {
sound->flags |= SOUND_FLAGS_MONO;
- BKE_sound_load(bmain, sound);
}
if (RNA_boolean_get(op->ptr, "cache")) {
@@ -140,11 +120,13 @@ static int sound_open_exec(bContext *C, wmOperator *op)
RNA_property_update(C, &pprop->ptr, pprop->prop);
}
+ DEG_relations_tag_update(bmain);
+
MEM_freeN(op->customdata);
return OPERATOR_FINISHED;
}
-#else //WITH_AUDASPACE
+#else // WITH_AUDASPACE
static int sound_open_exec(bContext *UNUSED(C), wmOperator *op)
{
@@ -361,8 +343,9 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
#ifdef WITH_AUDASPACE
char path[FILE_MAX];
char filename[FILE_MAX];
- Scene *scene;
- Main *bmain;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Main *bmain = CTX_data_main(C);
int split;
int bitrate, accuracy;
@@ -380,18 +363,20 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
container = RNA_enum_get(op->ptr, "container");
codec = RNA_enum_get(op->ptr, "codec");
split = RNA_boolean_get(op->ptr, "split_channels");
- scene = CTX_data_scene(C);
- bmain = CTX_data_main(C);
- specs.channels = scene->r.ffcodecdata.audio_channels;
- specs.rate = scene->r.ffcodecdata.audio_mixrate;
+ specs.channels = scene_eval->r.ffcodecdata.audio_channels;
+ specs.rate = scene_eval->r.ffcodecdata.audio_mixrate;
BLI_strncpy(filename, path, sizeof(filename));
BLI_path_abs(filename, BKE_main_blendfile_path(bmain));
+ const double fps = (((double)scene_eval->r.frs_sec) / (double)scene_eval->r.frs_sec_base);
+ const int start_frame = scene_eval->r.sfra;
+ const int end_frame = scene_eval->r.efra;
+
if (split) {
- result = AUD_mixdown_per_channel(scene->sound_scene,
- SFRA * specs.rate / FPS,
- (EFRA - SFRA + 1) * specs.rate / FPS,
+ result = AUD_mixdown_per_channel(scene_eval->sound_scene,
+ start_frame * specs.rate / fps,
+ (end_frame - start_frame + 1) * specs.rate / fps,
accuracy,
filename,
specs,
@@ -400,9 +385,9 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
bitrate);
}
else {
- result = AUD_mixdown(scene->sound_scene,
- SFRA * specs.rate / FPS,
- (EFRA - SFRA + 1) * specs.rate / FPS,
+ result = AUD_mixdown(scene_eval->sound_scene,
+ start_frame * specs.rate / fps,
+ (end_frame - start_frame + 1) * specs.rate / fps,
accuracy,
filename,
specs,
@@ -411,7 +396,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
bitrate);
}
- BKE_sound_reset_scene_specs(scene);
+ BKE_sound_reset_scene_specs(scene_eval);
if (result) {
BKE_report(op->reports, RPT_ERROR, result);
diff --git a/source/blender/editors/space_action/CMakeLists.txt b/source/blender/editors/space_action/CMakeLists.txt
index 5251ebb1267..6c43f8b9549 100644
--- a/source/blender/editors/space_action/CMakeLists.txt
+++ b/source/blender/editors/space_action/CMakeLists.txt
@@ -24,8 +24,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 9827967f947..2a6ae93fc99 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -71,68 +71,50 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
int filter;
View2D *v2d = &ar->v2d;
- float y = 0.0f;
size_t items;
- int height;
/* build list of channels to draw */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac)));
- if (height > BLI_rcti_size_y(&v2d->mask)) {
- /* don't use totrect set, as the width stays the same
- * (NOTE: this is ok here, the configuration is pretty straightforward)
- */
- v2d->tot.ymin = (float)(-height);
- }
+ int height = ACHANNEL_TOT_HEIGHT(ac, items);
+ v2d->tot.ymin = -height;
+
/* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */
UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY);
/* loop through channels, and set up drawing depending on their type */
{ /* first pass: just the standard GL-drawing for backdrop + text */
size_t channel_index = 0;
+ float ymax = ACHANNEL_FIRST_TOP(ac);
- y = (float)ACHANNEL_FIRST(ac);
-
- for (ale = anim_data.first; ale; ale = ale->next) {
- float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
- float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
+ for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) {
+ float ymin = ymax - ACHANNEL_HEIGHT(ac);
/* check if visible */
- if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
- IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
+ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
+ IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
/* draw all channels using standard channel-drawing API */
- ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index);
+ ANIM_channel_draw(ac, ale, ymin, ymax, channel_index);
}
-
- /* adjust y-position for next one */
- y -= ACHANNEL_STEP(ac);
- channel_index++;
}
}
{ /* second pass: widgets */
uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
size_t channel_index = 0;
+ float ymax = ACHANNEL_FIRST_TOP(ac);
- y = (float)ACHANNEL_FIRST(ac);
-
- for (ale = anim_data.first; ale; ale = ale->next) {
- float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
- float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
+ for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) {
+ float ymin = ymax - ACHANNEL_HEIGHT(ac);
/* check if visible */
- if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
- IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
+ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
+ IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
/* draw all channels using standard channel-drawing API */
rctf channel_rect;
- BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax, yminc, ymaxc);
+ BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax, ymin, ymax);
ANIM_channel_draw_widgets(C, ac, ale, block, &channel_rect, channel_index);
}
-
- /* adjust y-position for next one */
- y -= ACHANNEL_STEP(ac);
- channel_index++;
}
UI_block_end(C, block);
@@ -159,8 +141,6 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
bDopeSheet *ads = &saction->ads;
AnimData *adt = NULL;
- float y;
-
unsigned char col1[4], col2[4];
unsigned char col1a[4], col2a[4];
unsigned char col1b[4], col2b[4];
@@ -181,14 +161,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- int height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac)));
- /* don't use totrect set, as the width stays the same
- * (NOTE: this is ok here, the configuration is pretty straightforward)
- */
- v2d->tot.ymin = (float)(-height);
-
- /* first backdrop strips */
- y = (float)(-ACHANNEL_HEIGHT(ac));
+ int height = ACHANNEL_TOT_HEIGHT(ac, items);
+ v2d->tot.ymin = -height;
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -197,13 +171,15 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
GPU_blend(true);
- for (ale = anim_data.first; ale; ale = ale->next) {
- const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
- const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
+ /* first backdrop strips */
+ float ymax = ACHANNEL_FIRST_TOP(ac);
+
+ for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) {
+ float ymin = ymax - ACHANNEL_HEIGHT(ac);
/* check if visible */
- if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
- IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
+ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
+ IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
int sel = 0;
@@ -264,11 +240,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
}
/* draw region twice: firstly backdrop, then the current range */
- immRectf(pos,
- v2d->cur.xmin,
- (float)y - ACHANNEL_HEIGHT_HALF(ac),
- v2d->cur.xmax + EXTRA_SCROLL_PAD,
- (float)y + ACHANNEL_HEIGHT_HALF(ac));
+ immRectf(pos, v2d->cur.xmin, ymin, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymax);
}
else if (ac->datatype == ANIMCONT_GPENCIL) {
unsigned char *color;
@@ -285,44 +257,25 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
}
/* frames less than one get less saturated background */
immUniformColor4ubv(color);
- immRectf(pos,
- 0.0f,
- (float)y - ACHANNEL_HEIGHT_HALF(ac),
- v2d->cur.xmin,
- (float)y + ACHANNEL_HEIGHT_HALF(ac));
+ immRectf(pos, 0.0f, ymin, v2d->cur.xmin, ymax);
/* frames one and higher get a saturated background */
immUniformColor3ubvAlpha(color, MIN2(255, color[3] * 2));
- immRectf(pos,
- v2d->cur.xmin,
- (float)y - ACHANNEL_HEIGHT_HALF(ac),
- v2d->cur.xmax + EXTRA_SCROLL_PAD,
- (float)y + ACHANNEL_HEIGHT_HALF(ac));
+ immRectf(pos, v2d->cur.xmin, ymin, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymax);
}
else if (ac->datatype == ANIMCONT_MASK) {
/* TODO --- this is a copy of gpencil */
/* frames less than one get less saturated background */
unsigned char *color = sel ? col1 : col2;
immUniformColor4ubv(color);
- immRectf(pos,
- 0.0f,
- (float)y - ACHANNEL_HEIGHT_HALF(ac),
- v2d->cur.xmin,
- (float)y + ACHANNEL_HEIGHT_HALF(ac));
+ immRectf(pos, 0.0f, ymin, v2d->cur.xmin, ymax);
/* frames one and higher get a saturated background */
immUniformColor3ubvAlpha(color, MIN2(255, color[3] * 2));
- immRectf(pos,
- v2d->cur.xmin,
- (float)y - ACHANNEL_HEIGHT_HALF(ac),
- v2d->cur.xmax + EXTRA_SCROLL_PAD,
- (float)y + ACHANNEL_HEIGHT_HALF(ac));
+ immRectf(pos, v2d->cur.xmin, ymin, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymax);
}
}
}
-
- /* Increment the step */
- y -= ACHANNEL_STEP(ac);
}
GPU_blend(false);
@@ -342,21 +295,21 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
* This is to try to optimize this for heavier data sets
* 2) Keyframes which are out of view horizontally are disregarded
*/
- y = (float)(-ACHANNEL_HEIGHT(ac));
-
int action_flag = saction->flag;
if (saction->mode == SACTCONT_TIMELINE) {
action_flag &= ~(SACTION_SHOW_INTERPOLATION | SACTION_SHOW_EXTREMES);
}
- for (ale = anim_data.first; ale; ale = ale->next) {
- const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
- const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
+ ymax = ACHANNEL_FIRST_TOP(ac);
+
+ for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) {
+ float ymin = ymax - ACHANNEL_HEIGHT(ac);
+ float ycenter = (ymin + ymax) / 2.0f;
/* check if visible */
- if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
- IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
+ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
+ IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
/* check if anything to show for this channel */
if (ale->datatype != ALE_NONE) {
adt = ANIM_nla_mapping_get(ac, ale);
@@ -364,34 +317,32 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* draw 'keyframes' for each specific datatype */
switch (ale->datatype) {
case ALE_ALL:
- draw_summary_channel(v2d, ale->data, y, ac->yscale_fac, action_flag);
+ draw_summary_channel(v2d, ale->data, ycenter, ac->yscale_fac, action_flag);
break;
case ALE_SCE:
- draw_scene_channel(v2d, ads, ale->key_data, y, ac->yscale_fac, action_flag);
+ draw_scene_channel(v2d, ads, ale->key_data, ycenter, ac->yscale_fac, action_flag);
break;
case ALE_OB:
- draw_object_channel(v2d, ads, ale->key_data, y, ac->yscale_fac, action_flag);
+ draw_object_channel(v2d, ads, ale->key_data, ycenter, ac->yscale_fac, action_flag);
break;
case ALE_ACT:
- draw_action_channel(v2d, adt, ale->key_data, y, ac->yscale_fac, action_flag);
+ draw_action_channel(v2d, adt, ale->key_data, ycenter, ac->yscale_fac, action_flag);
break;
case ALE_GROUP:
- draw_agroup_channel(v2d, adt, ale->data, y, ac->yscale_fac, action_flag);
+ draw_agroup_channel(v2d, adt, ale->data, ycenter, ac->yscale_fac, action_flag);
break;
case ALE_FCURVE:
- draw_fcurve_channel(v2d, adt, ale->key_data, y, ac->yscale_fac, action_flag);
+ draw_fcurve_channel(v2d, adt, ale->key_data, ycenter, ac->yscale_fac, action_flag);
break;
case ALE_GPFRAME:
- draw_gpl_channel(v2d, ads, ale->data, y, ac->yscale_fac, action_flag);
+ draw_gpl_channel(v2d, ads, ale->data, ycenter, ac->yscale_fac, action_flag);
break;
case ALE_MASKLAY:
- draw_masklay_channel(v2d, ads, ale->data, y, ac->yscale_fac, action_flag);
+ draw_masklay_channel(v2d, ads, ale->data, ycenter, ac->yscale_fac, action_flag);
break;
}
}
}
-
- y -= ACHANNEL_STEP(ac);
}
/* free temporary channels used for drawing */
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 93beb3e851e..d8ed25c86d3 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -132,7 +132,8 @@ static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- /* now enable the "show posemarkers only" setting, so that we can see that something did happen */
+ /* Now enable the "show posemarkers only" setting,
+ * so that we can see that something did happen */
sact->flag |= SACTION_POSEMARKERS_SHOW;
/* notifiers - both sets, as this change affects both */
@@ -324,24 +325,23 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min,
/* NOTE: not bool, since we want prioritise individual channels over expanders */
short found = 0;
- float y;
/* get all items - we need to do it this way */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* loop through all channels, finding the first one that's selected */
- y = (float)ACHANNEL_FIRST(ac);
+ float ymax = ACHANNEL_FIRST_TOP(ac);
- for (ale = anim_data.first; ale; ale = ale->next) {
+ for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
/* must be selected... */
if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) &&
ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) {
/* update best estimate */
- *min = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
- *max = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
+ *min = ymax - ACHANNEL_HEIGHT(ac);
+ *max = ymax;
/* is this high enough priority yet? */
found = acf->channel_role;
@@ -353,9 +353,6 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min,
break;
}
}
-
- /* adjust y-position for next one */
- y -= ACHANNEL_STEP(ac);
}
/* free all temp data */
@@ -733,11 +730,14 @@ static void insert_action_keys(bAnimContext *ac, short mode)
FCurve *fcu = (FCurve *)ale->key_data;
float cfra = (float)CFRA;
- /* read value from property the F-Curve represents, or from the curve only?
- * - ale->id != NULL: Typically, this means that we have enough info to try resolving the path
- * - ale->owner != NULL: If this is set, then the path may not be resolvable from the ID alone,
- * so it's easier for now to just read the F-Curve directly.
- * (TODO: add the full-blown PointerRNA relative parsing case here...)
+ /* Read value from property the F-Curve represents, or from the curve only?
+ * - ale->id != NULL:
+ * Typically, this means that we have enough info to try resolving the path.
+ *
+ * - ale->owner != NULL:
+ * If this is set, then the path may not be resolvable from the ID alone,
+ * so it's easier for now to just read the F-Curve directly.
+ * (TODO: add the full-blown PointerRNA relative parsing case here...)
*/
if (ale->id && !ale->owner) {
insert_keyframe(ac->bmain,
@@ -1099,7 +1099,7 @@ void ACTION_OT_clean(wmOperatorType *ot)
ot->description = "Simplify F-Curves by removing closely spaced keyframes";
/* api callbacks */
- //ot->invoke = // XXX we need that number popup for this!
+ // ot->invoke = // XXX we need that number popup for this!
ot->exec = actkeys_clean_exec;
ot->poll = ED_operator_action_active;
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index b91ac3c39a3..cba86ac5131 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -102,7 +102,7 @@ void ED_operatormacros_action(void)
WM_operatortype_macro_define(ot, "ACTION_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform");
RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE);
- RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
}
/* ************************** registration - keymaps **********************************/
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index fb35afb6770..8ecd25bda76 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -230,7 +230,6 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho
KeyframeEditFunc ok_cb, select_cb;
View2D *v2d = &ac->ar->v2d;
rctf rectf;
- float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac));
/* Convert mouse coordinates to frame ranges and channel
* coordinates corrected for view pan/zoom. */
@@ -254,12 +253,14 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho
/* init editing data */
memset(&ked, 0, sizeof(KeyframeEditData));
+ float ymax = ACHANNEL_FIRST_TOP(ac);
+
/* loop over data, doing box select */
- for (ale = anim_data.first; ale; ale = ale->next) {
+ for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* get new vertical minimum extent of channel */
- ymin = ymax - ACHANNEL_STEP(ac);
+ float ymin = ymax - ACHANNEL_STEP(ac);
/* set horizontal range (if applicable) */
if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) {
@@ -314,9 +315,6 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho
}
}
}
-
- /* set minimum extent to be the maximum of the next channel */
- ymax = ymin;
}
/* cleanup */
@@ -418,7 +416,6 @@ static void region_select_action_keys(
KeyframeEditFunc ok_cb, select_cb;
View2D *v2d = &ac->ar->v2d;
rctf rectf, scaled_rectf;
- float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac));
/* Convert mouse coordinates to frame ranges and channel
* coordinates corrected for view pan/zoom. */
@@ -448,15 +445,17 @@ static void region_select_action_keys(
ked.data = &scaled_rectf;
}
+ float ymax = ACHANNEL_FIRST_TOP(ac);
+
/* loop over data, doing region select */
- for (ale = anim_data.first; ale; ale = ale->next) {
+ for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* get new vertical minimum extent of channel */
- ymin = ymax - ACHANNEL_STEP(ac);
+ float ymin = ymax - ACHANNEL_STEP(ac);
/* compute midpoint of channel (used for testing if the key is in the region or not) */
- ked.channel_y = ymin + ACHANNEL_HEIGHT_HALF(ac);
+ ked.channel_y = (ymin + ymax) / 2.0f;
/* if channel is mapped in NLA, apply correction
* - Apply to the bounds being checked, not all the keyframe points,
@@ -520,9 +519,6 @@ static void region_select_action_keys(
break;
}
}
-
- /* set minimum extent to be the maximum of the next channel */
- ymax = ymin;
}
/* cleanup */
@@ -1423,8 +1419,12 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s
/* ------------------- */
-static void mouse_action_keys(
- bAnimContext *ac, const int mval[2], short select_mode, bool column, bool same_channel)
+static void mouse_action_keys(bAnimContext *ac,
+ const int mval[2],
+ short select_mode,
+ const bool deselect_all,
+ const bool column,
+ const bool same_channel)
{
ListBase anim_data = {NULL, NULL};
DLRBT_Tree anim_keys;
@@ -1449,7 +1449,7 @@ static void mouse_action_keys(
/* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
UI_view2d_listview_view_to_cell(
- v2d, 0, ACHANNEL_STEP(ac), 0, (float)ACHANNEL_HEIGHT_HALF(ac), x, y, NULL, &channel_index);
+ 0, ACHANNEL_STEP(ac), 0, ACHANNEL_FIRST_TOP(ac), x, y, NULL, &channel_index);
/* x-range to check is +/- 7px for standard keyframe under standard dpi/y-scale
* (in screen/region-space), on either side of mouse click (size of keyframe icon).
@@ -1469,14 +1469,7 @@ static void mouse_action_keys(
/* try to get channel */
ale = BLI_findlink(&anim_data, channel_index);
- if (ale == NULL) {
- /* channel not found */
- printf("Error: animation channel (index = %d) not found in mouse_action_keys()\n",
- channel_index);
- ANIM_animdata_freelist(&anim_data);
- return;
- }
- else {
+ if (ale != NULL) {
/* found match - must return here... */
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
ActKeyColumn *ak, *akn = NULL;
@@ -1556,13 +1549,15 @@ static void mouse_action_keys(
/* cleanup temporary lists */
BLI_dlrbTree_free(&anim_keys);
-
- /* free list of channels, since it's not used anymore */
- ANIM_animdata_freelist(&anim_data);
}
- /* for replacing selection, firstly need to clear existing selection */
- if (select_mode == SELECT_REPLACE) {
+ /* free list of channels, since it's not used anymore */
+ ANIM_animdata_freelist(&anim_data);
+
+ /* For replacing selection, if we have something to select, we have to clear existing selection.
+ * The same goes if we found nothing to select, and deselect_all is true
+ * (deselect on nothing behavior). */
+ if ((select_mode == SELECT_REPLACE && found) || (!found && deselect_all)) {
/* reset selection mode for next steps */
select_mode = SELECT_ADD;
@@ -1575,7 +1570,7 @@ static void mouse_action_keys(
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
/* Highlight Action-Group or F-Curve? */
- if (ale && ale->data) {
+ if (ale != NULL && ale->data) {
if (ale->type == ANIMTYPE_GROUP) {
bActionGroup *agrp = ale->data;
@@ -1595,11 +1590,11 @@ static void mouse_action_keys(
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
/* Highlight GPencil Layer */
- if ((ale && ale->data) && (ale->type == ANIMTYPE_GPLAYER)) {
+ if (ale != NULL && ale->data != NULL && ale->type == ANIMTYPE_GPLAYER) {
bGPDlayer *gpl = ale->data;
gpl->flag |= GP_LAYER_SELECT;
- //gpencil_layer_setactive(gpd, gpl);
+ // gpencil_layer_setactive(gpd, gpl);
}
}
else if (ac->datatype == ANIMCONT_MASK) {
@@ -1607,17 +1602,17 @@ static void mouse_action_keys(
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
/* Highlight GPencil Layer */
- if ((ale && ale->data) && (ale->type == ANIMTYPE_MASKLAYER)) {
+ if (ale != NULL && ale->data != NULL && ale->type == ANIMTYPE_MASKLAYER) {
MaskLayer *masklay = ale->data;
masklay->flag |= MASK_LAYERFLAG_SELECT;
- //gpencil_layer_setactive(gpd, gpl);
+ // gpencil_layer_setactive(gpd, gpl);
}
}
}
/* only select keyframes if we clicked on a valid channel and hit something */
- if (ale) {
+ if (ale != NULL) {
if (found) {
/* apply selection to keyframes */
if (column) {
@@ -1652,9 +1647,6 @@ static void mouse_action_keys(
static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
bAnimContext ac;
- /* ARegion *ar; */ /* UNUSED */
- short selectmode;
- bool column, channel;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -1665,19 +1657,15 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
/* ar = ac.ar; */ /* UNUSED */
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend")) {
- selectmode = SELECT_INVERT;
- }
- else {
- selectmode = SELECT_REPLACE;
- }
+ const short selectmode = RNA_boolean_get(op->ptr, "extend") ? SELECT_INVERT : SELECT_REPLACE;
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
/* column selection */
- column = RNA_boolean_get(op->ptr, "column");
- channel = RNA_boolean_get(op->ptr, "channel");
+ const bool column = RNA_boolean_get(op->ptr, "column");
+ const bool channel = RNA_boolean_get(op->ptr, "channel");
/* select keyframe(s) based upon mouse position*/
- mouse_action_keys(&ac, event->mval, selectmode, column, channel);
+ mouse_action_keys(&ac, event->mval, selectmode, deselect_all, column, channel);
/* set notifier that keyframe selection (and channels too) have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
@@ -1712,6 +1700,13 @@ void ACTION_OT_clickselect(wmOperatorType *ot)
"Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
prop = RNA_def_boolean(
ot->srna,
"column",
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index d6d46904db3..5ac6297e108 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -166,7 +166,7 @@ static void action_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet", SPACE_ACTION, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -179,11 +179,9 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
Object *obact = CTX_data_active_object(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
- View2DGrid *grid;
View2DScrollers *scrollers;
short marker_flag = 0;
short cfra_flag = 0;
- short unit = 0;
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -192,17 +190,7 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* time grid */
- unit = (saction->flag & SACTION_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
- grid = UI_view2d_grid_calc(CTX_data_scene(C),
- v2d,
- unit,
- V2D_GRID_CLAMP,
- V2D_ARG_DUMMY,
- V2D_ARG_DUMMY,
- ar->winx,
- ar->winy);
- UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
- UI_view2d_grid_free(grid);
+ UI_view2d_draw_lines_x__discrete_frames_or_seconds(v2d, scene, saction->flag & SACTION_DRAWTIME);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
@@ -247,11 +235,14 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
+ /* frame numbers */
+ UI_view2d_draw_scale_x__discrete_frames_or_seconds(
+ ar, v2d, &v2d->hor, scene, saction->flag & SACTION_DRAWTIME, TH_TEXT);
+
/* draw current frame number-indicator on top of scrollers */
if ((saction->flag & SACTION_NODRAWCFRANUM) == 0) {
UI_view2d_view_orthoSpecial(ar, v2d, 1);
@@ -271,7 +262,7 @@ static void action_channel_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
@@ -710,7 +701,7 @@ static void action_header_region_listener(
break;
case ND_KEYFRAME: /* new keyframed added -> active action may have changed */
- //saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ // saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
ED_region_tag_redraw(ar);
break;
}
diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt
index ce08b62e8ef..25ff6bbd098 100644
--- a/source/blender/editors/space_buttons/CMakeLists.txt
+++ b/source/blender/editors/space_buttons/CMakeLists.txt
@@ -24,8 +24,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 607c3ddbb10..577f7a7af8a 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -785,7 +785,8 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
SpaceProperties *sbuts = CTX_wm_space_properties(C);
ButsContextPath *path = sbuts ? sbuts->path : NULL;
- if (!path) {
+ /* A zero sized path will be set for 'BCONTEXT_TOOL'. */
+ if (!path || !path->len) {
return 0;
}
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 1b1c3bf6d13..f9244049d54 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -203,14 +203,14 @@ static void buttons_main_region_layout_properties(const bContext *C,
static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
const enum eContextObjectMode mode = CTX_data_mode_enum(C);
const char *contexts_base[5] = {NULL};
contexts_base[0] = ".active_tool";
const char **contexts = &contexts_base[1];
- if (workspace->tools_space_type == SPACE_VIEW3D) {
+ /* Hard coded to 3D view. */
+ {
switch (mode) {
case CTX_MODE_EDIT_MESH:
ARRAY_SET_ITEMS(contexts, ".mesh_edit");
@@ -267,22 +267,6 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
break;
}
}
- else if (workspace->tools_space_type == SPACE_IMAGE) {
- switch (workspace->tools_mode) {
- case SI_MODE_VIEW:
- break;
- case SI_MODE_PAINT:
- ARRAY_SET_ITEMS(contexts, ".paint_common_2d", ".imagepaint_2d");
- break;
- case SI_MODE_MASK:
- break;
- case SI_MODE_UV:
- if (mode == CTX_MODE_EDIT_MESH) {
- ARRAY_SET_ITEMS(contexts, ".uv_sculpt");
- }
- break;
- }
- }
/* for grease pencil we don't use tool system yet, so we need check outside
* workspace->tools_space_type because this value is not available
diff --git a/source/blender/editors/space_clip/CMakeLists.txt b/source/blender/editors/space_clip/CMakeLists.txt
index ed98dcdc159..2ea4bc97d18 100644
--- a/source/blender/editors/space_clip/CMakeLists.txt
+++ b/source/blender/editors/space_clip/CMakeLists.txt
@@ -24,13 +24,13 @@ set(INC
../../blenlib
../../blentranslation
../../depsgraph
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index 8a5f48d11d2..ef5de1acee3 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -339,14 +339,10 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
View2D *v2d = &ar->v2d;
- View2DGrid *grid;
- short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES;
/* grid */
- grid = UI_view2d_grid_calc(
- scene, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy);
- UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
- UI_view2d_grid_free(grid);
+ UI_view2d_draw_lines_x__values(v2d);
+ UI_view2d_draw_lines_y__values(v2d);
if (clip) {
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 3f971c4444a..8b3f221f3a5 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -971,7 +971,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
SUBFRA = 0.0f;
/* do updates */
- BKE_sound_seek_scene(CTX_data_main(C), scene);
+ BKE_sound_update_and_seek(CTX_data_main(C), CTX_data_depsgraph(C));
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index f176763abf5..5364c4bc3ca 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -859,14 +859,14 @@ static void clip_main_region_init(wmWindowManager *wm, ARegion *ar)
/* mask polls mode */
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Editor", SPACE_CLIP, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void clip_main_region_draw(const bContext *C, ARegion *ar)
@@ -1002,13 +1002,13 @@ static void clip_preview_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Graph Editor", SPACE_CLIP, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void graph_region_draw(const bContext *C, ARegion *ar)
@@ -1017,7 +1017,6 @@ static void graph_region_draw(const bContext *C, ARegion *ar)
View2DScrollers *scrollers;
SpaceClip *sc = CTX_wm_space_clip(C);
Scene *scene = CTX_data_scene(C);
- short unitx, unity;
short cfra_flag = 0;
if (sc->flag & SC_LOCK_TIMECURSOR) {
@@ -1043,13 +1042,15 @@ static void graph_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- unitx = (sc->flag & SC_SHOW_SECONDS) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
- unity = V2D_UNIT_VALUES;
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
+ /* scale indicators */
+ UI_view2d_draw_scale_x__discrete_frames_or_seconds(
+ ar, v2d, &v2d->hor, scene, sc->flag & SC_SHOW_SECONDS, TH_TEXT);
+ UI_view2d_draw_scale_y__values(ar, v2d, &v2d->vert, TH_TEXT);
+
/* current frame indicator */
if (sc->flag & SC_SHOW_SECONDS) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
@@ -1064,9 +1065,8 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
View2D *v2d = &ar->v2d;
- View2DGrid *grid;
View2DScrollers *scrollers;
- short unit = 0, cfra_flag = 0;
+ short cfra_flag = 0;
if (clip) {
BKE_tracking_dopesheet_update(&clip->tracking);
@@ -1079,11 +1079,7 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* time grid */
- unit = (sc->flag & SC_SHOW_SECONDS) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
- 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_GRIDLINES_ALL);
- UI_view2d_grid_free(grid);
+ UI_view2d_draw_lines_x__discrete_frames_or_seconds(v2d, scene, sc->flag & SC_SHOW_SECONDS);
/* data... */
clip_draw_dopesheet_main(sc, ar, scene);
@@ -1098,11 +1094,14 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
+ /* frame numbers */
+ UI_view2d_draw_scale_x__discrete_frames_or_seconds(
+ ar, v2d, &v2d->hor, scene, sc->flag & SC_SHOW_SECONDS, TH_TEXT);
+
/* current frame number indicator */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
ANIM_draw_cfra_number(C, v2d, cfra_flag);
@@ -1140,7 +1139,7 @@ static void clip_channels_region_init(wmWindowManager *wm, ARegion *ar)
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void clip_channels_region_draw(const bContext *C, ARegion *ar)
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index 18d48b426e0..441e65cefe4 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -1350,7 +1350,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
if (CFRA != sc->user.framenr) {
CFRA = sc->user.framenr;
- BKE_sound_seek_scene(CTX_data_main(C), scene);
+ BKE_sound_update_and_seek(CTX_data_main(C), CTX_data_depsgraph(C));
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
diff --git a/source/blender/editors/space_clip/tracking_ops_detect.c b/source/blender/editors/space_clip/tracking_ops_detect.c
index ead150bba7f..a9c97258def 100644
--- a/source/blender/editors/space_clip/tracking_ops_detect.c
+++ b/source/blender/editors/space_clip/tracking_ops_detect.c
@@ -90,7 +90,7 @@ static int detect_features_exec(bContext *C, wmOperator *op)
}
/* Deselect existing tracks. */
- ed_tracking_delect_all_tracks(tracksbase);
+ ed_tracking_deselect_all_tracks(tracksbase);
/* Run detector. */
BKE_tracking_detect_harris(tracking,
tracksbase,
diff --git a/source/blender/editors/space_clip/tracking_ops_intern.h b/source/blender/editors/space_clip/tracking_ops_intern.h
index 8d2d61f050e..c29a485e234 100644
--- a/source/blender/editors/space_clip/tracking_ops_intern.h
+++ b/source/blender/editors/space_clip/tracking_ops_intern.h
@@ -38,7 +38,7 @@ void clip_tracking_hide_cursor(struct bContext *C);
/* tracking_select.h */
-void ed_tracking_delect_all_tracks(struct ListBase *tracks_base);
-void ed_tracking_delect_all_plane_tracks(struct ListBase *plane_tracks_base);
+void ed_tracking_deselect_all_tracks(struct ListBase *tracks_base);
+void ed_tracking_deselect_all_plane_tracks(struct ListBase *plane_tracks_base);
#endif /* __TRACKING_OPS_INTERN_H__ */
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c
index 207a0f1aff6..2b70aec02bb 100644
--- a/source/blender/editors/space_clip/tracking_select.c
+++ b/source/blender/editors/space_clip/tracking_select.c
@@ -263,7 +263,7 @@ static MovieTrackingPlaneTrack *find_nearest_plane_track(SpaceClip *sc,
return plane_track;
}
-void ed_tracking_delect_all_tracks(ListBase *tracks_base)
+void ed_tracking_deselect_all_tracks(ListBase *tracks_base)
{
MovieTrackingTrack *track;
for (track = tracks_base->first; track != NULL; track = track->next) {
@@ -271,7 +271,7 @@ void ed_tracking_delect_all_tracks(ListBase *tracks_base)
}
}
-void ed_tracking_delect_all_plane_tracks(ListBase *plane_tracks_base)
+void ed_tracking_deselect_all_plane_tracks(ListBase *plane_tracks_base)
{
MovieTrackingPlaneTrack *plane_track;
for (plane_track = plane_tracks_base->first; plane_track != NULL;
@@ -280,7 +280,7 @@ void ed_tracking_delect_all_plane_tracks(ListBase *plane_tracks_base)
}
}
-static int mouse_select(bContext *C, float co[2], int extend)
+static int mouse_select(bContext *C, float co[2], const bool extend, const bool deselect_all)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -295,6 +295,15 @@ static int mouse_select(bContext *C, float co[2], int extend)
track = find_nearest_track(sc, tracksbase, co, &distance_to_track);
plane_track = find_nearest_plane_track(sc, plane_tracks_base, co, &distance_to_plane_track);
+ /* Do not select beyond some reasonable distance, that is useless and
+ * prevents the 'deselect on nothing' behavior. */
+ if (distance_to_track > 0.05f) {
+ track = NULL;
+ }
+ if (distance_to_plane_track > 0.05f) {
+ plane_track = NULL;
+ }
+
/* Between track and plane we choose closest to the mouse for selection here. */
if (track && plane_track) {
if (distance_to_track < distance_to_plane_track) {
@@ -305,11 +314,11 @@ static int mouse_select(bContext *C, float co[2], int extend)
}
}
- if (!extend) {
- ed_tracking_delect_all_plane_tracks(plane_tracks_base);
- }
-
if (track) {
+ if (!extend) {
+ ed_tracking_deselect_all_plane_tracks(plane_tracks_base);
+ }
+
int area = track_mouse_area(C, co, track);
if (!extend || !TRACK_VIEW_SELECTED(sc, track)) {
@@ -337,7 +346,7 @@ static int mouse_select(bContext *C, float co[2], int extend)
}
else if (plane_track) {
if (!extend) {
- ed_tracking_delect_all_tracks(tracksbase);
+ ed_tracking_deselect_all_tracks(tracksbase);
}
if (PLANE_TRACK_VIEW_SELECTED(plane_track)) {
@@ -352,6 +361,10 @@ static int mouse_select(bContext *C, float co[2], int extend)
clip->tracking.act_track = NULL;
clip->tracking.act_plane_track = plane_track;
}
+ else if (deselect_all) {
+ ed_tracking_deselect_all_tracks(tracksbase);
+ ed_tracking_deselect_all_plane_tracks(plane_tracks_base);
+ }
if (!extend) {
sc->xlockof = 0.0f;
@@ -380,12 +393,12 @@ static bool select_poll(bContext *C)
static int select_exec(bContext *C, wmOperator *op)
{
float co[2];
- int extend;
RNA_float_get_array(op->ptr, "location", co);
- extend = RNA_boolean_get(op->ptr, "extend");
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
- return mouse_select(C, co, extend);
+ return mouse_select(C, co, extend, deselect_all);
}
static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -433,11 +446,19 @@ void CLIP_OT_select(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
+ PropertyRNA *prop;
RNA_def_boolean(ot->srna,
"extend",
0,
"Extend",
"Extend selection rather than clearing the existing selection");
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
RNA_def_float_vector(
ot->srna,
"location",
diff --git a/source/blender/editors/space_console/CMakeLists.txt b/source/blender/editors/space_console/CMakeLists.txt
index 5070b6fcf65..33934832ccc 100644
--- a/source/blender/editors/space_console/CMakeLists.txt
+++ b/source/blender/editors/space_console/CMakeLists.txt
@@ -24,8 +24,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 2cf8f6c46b9..999255aef88 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -77,7 +77,7 @@ static SpaceLink *console_new(const ScrArea *UNUSED(area), const Scene *UNUSED(s
ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
- //ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM);
+ // ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM);
return (SpaceLink *)sconsole;
}
@@ -136,7 +136,7 @@ static void console_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Console", SPACE_CONSOLE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* add drop boxes */
lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
@@ -231,9 +231,8 @@ static void console_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt
index 6bf975b98e0..33f57b9c235 100644
--- a/source/blender/editors/space_file/CMakeLists.txt
+++ b/source/blender/editors/space_file/CMakeLists.txt
@@ -22,15 +22,15 @@ set(INC
../../blenlib
../../blenloader
../../blentranslation
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../render/extern/include
../../windowmanager
../../../../intern/atomic
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 7d3a042d75a..674735f3e1d 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1461,8 +1461,7 @@ int file_exec(bContext *C, wmOperator *exec_op)
else if (sfile->op) {
wmOperator *op = sfile->op;
- /* when used as a macro, for doubleclick,
- * to prevent closing when doubleclicking on .. item */
+ /* When used as a macro, for double-click, to prevent closing when double-clicking on item. */
if (RNA_boolean_get(exec_op->ptr, "need_active")) {
const int numfiles = filelist_files_ensure(sfile->files);
int i, active = 0;
@@ -1723,8 +1722,8 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
(sfile->scroll_offset < offset + numfiles_layout - numfiles_layout_margin)) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer);
sfile->smoothscroll_timer = NULL;
- /* Postscroll (after rename has been validated by user) is done,
- * rename process is totally finisehd, cleanup. */
+ /* Post-scroll (after rename has been validated by user) is done,
+ * rename process is totally finished, cleanup. */
if ((params->rename_flag & FILE_PARAMS_RENAME_POSTSCROLL_ACTIVE) != 0) {
params->renamefile[0] = '\0';
params->rename_flag = 0;
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index 982c663cd18..38423a87447 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -296,8 +296,8 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu,
fsm_iter->save = (flag & FS_INSERT_SAVE) != 0;
if ((category == FS_CATEGORY_RECENT) && (!name || !name[0])) {
- /* Special handling when adding new recent entry - check if dir exists in some other categories,
- * and try to use name from there if so. */
+ /* Special handling when adding new recent entry - check if dir exists in
+ * some other categories, and try to use name from there if so. */
FSMenuCategory cats[] = {
FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, FS_CATEGORY_BOOKMARKS};
int i = ARRAY_SIZE(cats);
@@ -522,7 +522,8 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
# ifdef __APPLE__
{
/* Get mounted volumes better method OSX 10.6 and higher, see:
- * https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html */
+ * https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html
+ */
/* We get all volumes sorted including network and do not relay
* on user-defined finder visibility, less confusing. */
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index e0d370cdde2..4629f33d210 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -83,6 +83,7 @@ static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
BLI_addtail(&sfile->regionbase, ar);
ar->regiontype = RGN_TYPE_TOOL_PROPS;
ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
+ ar->flag |= RGN_FLAG_DYNAMIC_SIZE;
/* ui list region */
ar = MEM_callocN(sizeof(ARegion), "ui region for file");
@@ -316,10 +317,10 @@ static void file_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser Main", SPACE_FILE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void file_main_region_listener(wmWindow *UNUSED(win),
@@ -441,9 +442,8 @@ static void file_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
@@ -498,7 +498,7 @@ static void file_tools_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void file_tools_region_draw(const bContext *C, ARegion *ar)
@@ -528,7 +528,7 @@ static void file_header_region_init(wmWindowManager *wm, ARegion *ar)
ED_region_header_init(ar);
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void file_header_region_draw(const bContext *C, ARegion *ar)
@@ -545,10 +545,10 @@ static void file_ui_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser Buttons", SPACE_FILE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void file_ui_region_draw(const bContext *C, ARegion *ar)
diff --git a/source/blender/editors/space_graph/CMakeLists.txt b/source/blender/editors/space_graph/CMakeLists.txt
index cf5ffdb2be5..f4d31886e3f 100644
--- a/source/blender/editors/space_graph/CMakeLists.txt
+++ b/source/blender/editors/space_graph/CMakeLists.txt
@@ -25,8 +25,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index eb392538d23..062c9f86fab 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -493,20 +493,18 @@ static void draw_fcurve_samples(SpaceGraph *sipo, ARegion *ar, FCurve *fcu)
/* Helper func - just draw the F-Curve by sampling the visible region
* (for drawing curves with modifiers). */
static void draw_fcurve_curve(
- bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2d, View2DGrid *grid, unsigned int pos)
+ bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2d, unsigned int pos)
{
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
float samplefreq;
float stime, etime;
float unitFac, offset;
- float dx, dy;
short mapping_flag = ANIM_get_normalization_flags(ac);
int i, n;
/* when opening a blend file on a different sized screen or while dragging the toolbar this can
* happen best just bail out in this case. */
- UI_view2d_grid_size(grid, &dx, &dy);
- if (dx <= 0.0f) {
+ if (UI_view2d_scale_get_x(v2d) <= 0.0f) {
return;
}
@@ -529,11 +527,11 @@ static void draw_fcurve_curve(
* loop (i.e. too close to 0), then clamp it to a determined "safe" value. The value
* chosen here is just the coarsest value which still looks reasonable...
*/
- /* grid->dx represents the number of 'frames' between gridlines,
- * but we divide by U.v2d_min_gridsize to get pixels-steps */
+
/* TODO: perhaps we should have 1.0 frames
* as upper limit so that curves don't get too distorted? */
- samplefreq = dx / (U.v2d_min_gridsize * U.pixelsize);
+ float pixels_per_sample = 1.5f;
+ samplefreq = pixels_per_sample / UI_view2d_scale_get_x(v2d);
if (sipo->flag & SIPO_BEAUTYDRAW_OFF) {
/* Low Precision = coarse lower-bound clamping
@@ -883,7 +881,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
/* for now, only show when debugging driver... */
- //if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0)
+ // if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0)
// return;
const uint shdr_pos = GPU_vertformat_attr_add(
@@ -1043,8 +1041,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *ar)
/* This is called twice from space_graph.c -> graph_main_region_draw()
* Unselected then selected F-Curves are drawn so that they do not occlude each other.
*/
-void graph_draw_curves(
- bAnimContext *ac, SpaceGraph *sipo, ARegion *ar, View2DGrid *grid, short sel)
+void graph_draw_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *ar, short sel)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
@@ -1131,7 +1128,7 @@ void graph_draw_curves(
/* draw a curve affected by modifiers or only allowed to have integer values
* by sampling it at various small-intervals over the visible region
*/
- draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid, shdr_pos);
+ draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, shdr_pos);
}
else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) {
/* just draw curve based on defined data (i.e. no modifiers) */
@@ -1140,7 +1137,7 @@ void graph_draw_curves(
draw_fcurve_curve_bezts(ac, ale->id, fcu, &ar->v2d, shdr_pos);
}
else {
- draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid, shdr_pos);
+ draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, shdr_pos);
}
}
else if (fcu->fpt) {
@@ -1157,7 +1154,8 @@ void graph_draw_curves(
}
/* 2) draw handles and vertices as appropriate based on active
- * - if the option to only show controls if the F-Curve is selected is enabled, we must obey this
+ * - If the option to only show controls if the F-Curve is selected is enabled,
+ * we must obey this.
*/
if (!(sipo->flag & SIPO_SELCUVERTSONLY) || (fcu->flag & FCURVE_SELECTED)) {
if (!fcurve_are_keyframes_usable(fcu) && !(fcu->fpt && fcu->totvert)) {
@@ -1181,7 +1179,8 @@ void graph_draw_curves(
GPU_matrix_scale_2f(1.0f, unit_scale);
GPU_matrix_translate_2f(0.0f, offset);
- /* set this once and for all - all handles and handle-verts should use the same thickness */
+ /* Set this once and for all -
+ * all handles and handle-verts should use the same thickness. */
GPU_line_width(1.0);
if (fcu->bezt) {
@@ -1231,9 +1230,8 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
int filter;
View2D *v2d = &ar->v2d;
- float y = 0.0f, height;
+ float height;
size_t items;
- int i = 0;
/* build list of channels to draw */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
@@ -1241,62 +1239,47 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
/* Update max-extent of channels here (taking into account scrollers):
* - this is done to allow the channel list to be scrollable, but must be done here
- * to avoid regenerating the list again and/or also because channels list is drawn first
- * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
- * start of list offset, and the second is as a correction for the scrollers.
- */
- height = (float)((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac) * 2));
- UI_view2d_totRect_set(v2d, BLI_rcti_size_x(&ar->v2d.mask), height);
+ * to avoid regenerating the list again and/or also because channels list is drawn first */
+ height = ACHANNEL_TOT_HEIGHT(ac, items);
+ v2d->tot.ymin = -height;
/* loop through channels, and set up drawing depending on their type */
{ /* first pass: just the standard GL-drawing for backdrop + text */
size_t channel_index = 0;
+ float ymax = ACHANNEL_FIRST_TOP(ac);
- y = (float)ACHANNEL_FIRST(ac);
-
- for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
- const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
- const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
+ for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) {
+ float ymin = ymax - ACHANNEL_HEIGHT(ac);
/* check if visible */
- if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
- IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
+ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
+ IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
/* draw all channels using standard channel-drawing API */
- ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index);
+ ANIM_channel_draw(ac, ale, ymin, ymax, channel_index);
}
-
- /* adjust y-position for next one */
- y -= ACHANNEL_STEP(ac);
- channel_index++;
}
}
{ /* second pass: widgets */
uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
size_t channel_index = 0;
-
- y = (float)ACHANNEL_FIRST(ac);
+ float ymax = ACHANNEL_FIRST_TOP(ac);
/* set blending again, as may not be set in previous step */
GPU_blend_set_func_separate(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
GPU_blend(true);
- for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
- const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
- const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
+ for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) {
+ float ymin = ymax - ACHANNEL_HEIGHT(ac);
/* check if visible */
- if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
- IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
+ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
+ IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
/* draw all channels using standard channel-drawing API */
rctf channel_rect;
- BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax - V2D_SCROLL_WIDTH, yminc, ymaxc);
+ BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax - V2D_SCROLL_WIDTH, ymin, ymax);
ANIM_channel_draw_widgets(C, ac, ale, block, &channel_rect, channel_index);
}
-
- /* adjust y-position for next one */
- y -= ACHANNEL_STEP(ac);
- channel_index++;
}
UI_block_end(C, block);
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 1bb14bc3ce2..0954538e430 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -932,9 +932,15 @@ static short copy_graph_keys(bAnimContext *ac)
/* clear buffer first */
ANIM_fcurves_copybuf_free();
- /* filter data */
+ /* filter data
+ * - First time we try to filter more strictly, allowing only selected channels
+ * to allow copying animation between channels
+ */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
- ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
+ if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) {
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+ }
/* copy keyframes */
ok = copy_animedit_keys(ac, &anim_data);
@@ -1275,7 +1281,7 @@ void GRAPH_OT_clean(wmOperatorType *ot)
ot->description = "Simplify F-Curves by removing closely spaced keyframes";
/* api callbacks */
- //ot->invoke = // XXX we need that number popup for this!
+ // ot->invoke = // XXX we need that number popup for this!
ot->exec = graphkeys_clean_exec;
ot->poll = graphop_editable_keyframes_poll;
@@ -1484,7 +1490,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-#else //WITH_AUDASPACE
+#else // WITH_AUDASPACE
static int graphkeys_sound_bake_exec(bContext *UNUSED(C), wmOperator *op)
{
@@ -1493,7 +1499,7 @@ static int graphkeys_sound_bake_exec(bContext *UNUSED(C), wmOperator *op)
return OPERATOR_CANCELLED;
}
-#endif //WITH_AUDASPACE
+#endif // WITH_AUDASPACE
static int graphkeys_sound_bake_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index 606f4bc3fe3..6ec8e54dce9 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -28,7 +28,6 @@ struct ARegion;
struct ARegionType;
struct ScrArea;
struct SpaceGraph;
-struct View2DGrid;
struct bAnimContext;
struct bAnimListElem;
struct bContext;
@@ -42,7 +41,6 @@ void graph_draw_channel_names(struct bContext *C, struct bAnimContext *ac, struc
void graph_draw_curves(struct bAnimContext *ac,
struct SpaceGraph *sipo,
struct ARegion *ar,
- struct View2DGrid *grid,
short sel);
void graph_draw_ghost_curves(struct bAnimContext *ac, struct SpaceGraph *sipo, struct ARegion *ar);
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 79df4760939..054a1e3d8ee 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -105,7 +105,7 @@ static void graphview_cursor_apply(bContext *C, wmOperator *op)
}
SUBFRA = 0.0f;
- BKE_sound_seek_scene(bmain, scene);
+ BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C));
}
/* set the cursor value */
@@ -494,7 +494,7 @@ void ED_operatormacros_graph(void)
WM_operatortype_macro_define(ot, "GRAPH_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform");
RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE);
- RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
}
/* ************************** registration - keymaps **********************************/
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index a5376cd0c0e..13a42f091f6 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -117,7 +117,8 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel
/* affect channel selection status? */
if (do_channels) {
- /* only change selection of channel when the visibility of keyframes doesn't depend on this */
+ /* Only change selection of channel when the visibility of keyframes
+ * doesn't depend on this. */
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
/* deactivate the F-Curve, and deselect if deselecting keyframes.
* otherwise select the F-Curve too since we've selected all the keyframes
@@ -324,7 +325,8 @@ static void box_select_graphkeys(bAnimContext *ac,
/* select keyframes that are in the appropriate places */
ANIM_fcurve_keyframes_loop(&ked, fcu, ok_cb, select_cb, NULL);
- /* only change selection of channel when the visibility of keyframes doesn't depend on this */
+ /* Only change selection of channel when the visibility of keyframes
+ * doesn't depend on this. */
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
/* select the curve too now that curve will be touched */
if (selectmode == SELECT_ADD) {
@@ -1188,7 +1190,8 @@ static void nearest_fcurve_vert_store(ListBase *matches,
tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last;
bool replace = false;
- /* if there is already a point for the F-Curve, check if this point is closer than that was */
+ /* If there is already a point for the F-Curve,
+ * check if this point is closer than that was. */
if ((nvi) && (nvi->fcu == fcu)) {
/* replace if we are closer, or if equal and that one wasn't selected but we are... */
if ((nvi->dist > dist) || ((nvi->sel == 0) && BEZT_ISSEL_ANY(bezt))) {
@@ -1343,8 +1346,9 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
for (nvi = matches->first; nvi; nvi = nvi->next) {
/* which mode of search are we in: find first selected, or find vert? */
if (found) {
- /* just take this vert now that we've found the selected one
- * - we'll need to remove this from the list so that it can be returned to the original caller
+ /* Just take this vert now that we've found the selected one
+ * - We'll need to remove this from the list
+ * so that it can be returned to the original caller.
*/
BLI_remlink(matches, nvi);
return nvi;
@@ -1392,7 +1396,8 @@ static tNearestVertInfo *find_nearest_fcurve_vert(bAnimContext *ac, const int mv
static void mouse_graph_keys(bAnimContext *ac,
const int mval[2],
short select_mode,
- short curves_only)
+ const bool deselect_all,
+ const bool curves_only)
{
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
tNearestVertInfo *nvi;
@@ -1401,13 +1406,10 @@ static void mouse_graph_keys(bAnimContext *ac,
/* find the beztriple that we're selecting, and the handle that was clicked on */
nvi = find_nearest_fcurve_vert(ac, mval);
- /* check if anything to select */
- if (nvi == NULL) {
- return;
- }
-
- /* deselect all other curves? */
- if (select_mode == SELECT_REPLACE) {
+ /* For replacing selection, if we have something to select, we have to clear existing selection.
+ * The same goes if we found nothing to select, and deselect_all is true
+ * (deselect on nothing behavior). */
+ if ((nvi != NULL && select_mode == SELECT_REPLACE) || (nvi == NULL && deselect_all)) {
/* reset selection mode */
select_mode = SELECT_ADD;
@@ -1423,9 +1425,13 @@ static void mouse_graph_keys(bAnimContext *ac,
}
}
+ if (nvi == NULL) {
+ return;
+ }
+
/* if points can be selected on this F-Curve */
// TODO: what about those with no keyframes?
- if ((curves_only == 0) && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) {
+ if (!curves_only && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) {
/* only if there's keyframe */
if (nvi->bezt) {
bezt = nvi->bezt; /* used to check bezt seletion is set */
@@ -1600,7 +1606,6 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short
static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
bAnimContext ac;
- short selectmode;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -1608,12 +1613,8 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEve
}
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend")) {
- selectmode = SELECT_INVERT;
- }
- else {
- selectmode = SELECT_REPLACE;
- }
+ const short selectmode = RNA_boolean_get(op->ptr, "extend") ? SELECT_INVERT : SELECT_REPLACE;
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
/* figure out action to take */
if (RNA_boolean_get(op->ptr, "column")) {
@@ -1622,11 +1623,11 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEve
}
else if (RNA_boolean_get(op->ptr, "curves")) {
/* select all keyframes in the same F-Curve as the one under the mouse */
- mouse_graph_keys(&ac, event->mval, selectmode, 1);
+ mouse_graph_keys(&ac, event->mval, selectmode, deselect_all, true);
}
else {
/* select keyframe under mouse */
- mouse_graph_keys(&ac, event->mval, selectmode, 0);
+ mouse_graph_keys(&ac, event->mval, selectmode, deselect_all, false);
}
/* set notifier that keyframe selection (and also channel selection in some cases) has changed */
@@ -1662,6 +1663,13 @@ void GRAPH_OT_clickselect(wmOperatorType *ot)
"Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
prop = RNA_def_boolean(
ot->srna,
"column",
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c
index b823ddec696..d582ac557fa 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -50,7 +50,8 @@
/* Set Up Drivers Editor */
/* Set up UI configuration for Drivers Editor */
-/* NOTE: Currently called from windowmanager (new drivers editor window) and RNA (mode switching) */
+/* NOTE: Currently called from windowmanager
+ * (new drivers editor window) and RNA (mode switching) */
void ED_drivers_editor_init(bContext *C, ScrArea *sa)
{
SpaceGraph *sipo = (SpaceGraph *)sa->spacedata.first;
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index e45a27a08fb..390ea0cf00b 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -186,7 +186,7 @@ static void graph_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor", SPACE_GRAPH, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -198,10 +198,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
Scene *scene = CTX_data_scene(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
- View2DGrid *grid;
View2DScrollers *scrollers;
float col[3];
- short unitx = 0, unity = V2D_UNIT_VALUES, cfra_flag = 0;
+ short cfra_flag = 0;
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
@@ -211,18 +210,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* grid */
- unitx = ((sipo->mode == SIPO_MODE_ANIMATION) && (sipo->flag & SIPO_DRAWTIME)) ?
- V2D_UNIT_SECONDS :
- V2D_UNIT_FRAMESCALE;
- grid = UI_view2d_grid_calc(CTX_data_scene(C),
- v2d,
- unitx,
- V2D_GRID_NOCLAMP,
- unity,
- V2D_GRID_NOCLAMP,
- ar->winx,
- ar->winy);
- UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
+ bool display_seconds = (sipo->mode == SIPO_MODE_ANIMATION) && (sipo->flag & SIPO_DRAWTIME);
+ UI_view2d_draw_lines_x__frames_or_seconds(v2d, scene, display_seconds);
+ UI_view2d_draw_lines_y__values(v2d);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
@@ -237,8 +227,8 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
graph_draw_ghost_curves(&ac, sipo, ar);
/* draw curves twice - unselected, then selected, so that the are fewer occlusion problems */
- graph_draw_curves(&ac, sipo, ar, grid, 0);
- graph_draw_curves(&ac, sipo, ar, grid, 1);
+ graph_draw_curves(&ac, sipo, ar, 0);
+ graph_draw_curves(&ac, sipo, ar, 1);
/* XXX the slow way to set tot rect... but for nice sliders needed (ton) */
get_graph_keyframe_extents(
@@ -248,9 +238,6 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
v2d->tot.xmax += 10.0f;
}
- /* only free grid after drawing data, as we need to use it to determine sampling rate */
- UI_view2d_grid_free(grid);
-
if (((sipo->flag & SIPO_NODRAWCURSOR) == 0) || (sipo->mode == SIPO_MODE_DRIVERS)) {
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -324,11 +311,14 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
/* scrollers */
// FIXME: args for scrollers depend on the type of data being shown...
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
+ /* scale numbers */
+ UI_view2d_draw_scale_x__frames_or_seconds(ar, v2d, &v2d->hor, scene, display_seconds, TH_TEXT);
+ UI_view2d_draw_scale_y__values(ar, v2d, &v2d->vert, TH_TEXT);
+
/* draw current frame number-indicator on top of scrollers */
if ((sipo->mode != SIPO_MODE_DRIVERS) && ((sipo->flag & SIPO_NODRAWCFRANUM) == 0)) {
UI_view2d_view_orthoSpecial(ar, v2d, 1);
@@ -353,7 +343,7 @@ static void graph_channel_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -381,9 +371,8 @@ static void graph_channel_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
@@ -406,7 +395,7 @@ static void graph_buttons_region_init(wmWindowManager *wm, ARegion *ar)
ED_region_panels_init(wm, ar);
keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void graph_buttons_region_draw(const bContext *C, ARegion *ar)
@@ -627,7 +616,7 @@ static void graph_listener(wmWindow *UNUSED(win),
break;
// XXX: restore the case below if not enough updates occur...
- //default:
+ // default:
// if (wmn->data == ND_KEYS)
// ED_area_tag_redraw(sa);
}
diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt
index 70b7387bf6b..61e6b065cba 100644
--- a/source/blender/editors/space_image/CMakeLists.txt
+++ b/source/blender/editors/space_image/CMakeLists.txt
@@ -23,14 +23,14 @@ set(INC
../../blentranslation
../../bmesh
../../depsgraph
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../render/extern/include
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index f5dd0c4ad53..752eedebe71 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -1371,6 +1371,7 @@ void image_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype image panel metadata");
strcpy(pt->idname, "IMAGE_PT_metadata");
strcpy(pt->label, N_("Metadata"));
+ strcpy(pt->category, "Image");
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
pt->poll = metadata_panel_context_poll;
pt->draw = metadata_panel_context_draw;
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 3baee1d723b..9b57644b6ec 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -673,7 +673,7 @@ void draw_image_grease_pencil(bContext *C, bool onlyv2d)
}
else {
/* assume that UI_view2d_restore(C) has been called... */
- //SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C);
+ // SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C);
/* draw grease-pencil ('screen' strokes) */
ED_annotation_draw_view2d(C, 0);
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 2c99997bbad..0710ecf3bd6 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -65,6 +65,7 @@
#include "DEG_depsgraph.h"
#include "GPU_draw.h"
+#include "GPU_state.h"
#include "GPU_immediate.h"
#include "IMB_colormanagement.h"
@@ -290,7 +291,8 @@ static bool image_sample_poll(bContext *C)
if (sima) {
Object *obedit = CTX_data_edit_object(C);
if (obedit) {
- /* Disable when UV editing so it doesn't swallow all click events (use for setting cursor). */
+ /* Disable when UV editing so it doesn't swallow all click events
+ * (use for setting cursor). */
if (ED_space_image_show_uvedit(sima, obedit)) {
return false;
}
@@ -579,7 +581,7 @@ static void image_zoom_apply(ViewZoomData *vpd,
zfac = 1.0f + ((fac / 20.0f) * time_step);
vpd->timer_lastdraw = time;
/* this is the final zoom, but instead make it into a factor */
- //zoom = vpd->sima->zoom * zfac;
+ // zoom = vpd->sima->zoom * zfac;
factor = (vpd->sima->zoom * zfac) / vpd->zoom;
}
else {
@@ -1734,7 +1736,7 @@ static int image_save_options_init(Main *bmain,
}
///* XXX - this is lame, we need to make these available too! */
- //opts->subimtype = scene->r.subimtype;
+ // opts->subimtype = scene->r.subimtype;
BLI_strncpy(opts->filepath, ibuf->name, sizeof(opts->filepath));
@@ -2759,6 +2761,7 @@ static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info)
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);
+ GPU_line_width(1.0f);
imm_draw_box_wire_2d(pos,
(float)sample_rect_fl.xmin,
(float)sample_rect_fl.ymin,
@@ -3539,7 +3542,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
SUBFRA = 0.0f;
/* do updates */
- BKE_sound_seek_scene(CTX_data_main(C), scene);
+ BKE_sound_update_and_seek(CTX_data_main(C), CTX_data_depsgraph(C));
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 1e1d1e570b3..3b2386d94e6 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -140,6 +140,7 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce
BLI_addtail(&simage->regionbase, ar);
ar->regiontype = RGN_TYPE_TOOL_HEADER;
ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
+ ar->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for image");
@@ -536,29 +537,26 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar)
/* mask polls mode */
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* image paint polls for mode */
keymap = WM_keymap_ensure(wm->defaultconf, "Curve", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Paint Curve", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Image Paint", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "UV Editor", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
- keymap = WM_keymap_ensure(wm->defaultconf, "UV Sculpt", 0, 0);
- WM_event_add_keymap_handler(&ar->handlers, keymap);
-
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Image", SPACE_IMAGE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void image_main_region_draw(const bContext *C, ARegion *ar)
@@ -573,7 +571,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
View2D *v2d = &ar->v2d;
- //View2DScrollers *scrollers;
+ // View2DScrollers *scrollers;
float col[3];
/* XXX This is in order to draw UI batches with the DRW
@@ -607,7 +605,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
- ED_uvedit_draw_main(sima, ar, scene, view_layer, obedit, obact, depsgraph);
+ ED_uvedit_draw_main(sima, scene, view_layer, obedit, obact, depsgraph);
/* check for mask (delay draw) */
if (ED_space_image_show_uvedit(sima, obedit)) {
@@ -685,14 +683,6 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
WM_gizmomap_draw(ar->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D);
draw_image_cache(C, ar);
-
- /* scrollers? */
-#if 0
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, V2D_UNIT_VALUES, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
- UI_view2d_scrollers_free(scrollers);
-#endif
}
static void image_main_region_listener(
@@ -750,6 +740,33 @@ static void image_buttons_region_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
+static void image_buttons_region_layout(const bContext *C, ARegion *ar)
+{
+ const enum eContextObjectMode mode = CTX_data_mode_enum(C);
+ const char *contexts_base[3] = {NULL};
+
+ const char **contexts = contexts_base;
+
+ SpaceImage *sima = CTX_wm_space_image(C);
+ switch (sima->mode) {
+ case SI_MODE_VIEW:
+ break;
+ case SI_MODE_PAINT:
+ ARRAY_SET_ITEMS(contexts, ".paint_common_2d", ".imagepaint_2d");
+ break;
+ case SI_MODE_MASK:
+ break;
+ case SI_MODE_UV:
+ if (mode == CTX_MODE_EDIT_MESH) {
+ ARRAY_SET_ITEMS(contexts, ".uv_sculpt");
+ }
+ break;
+ }
+
+ const bool vertical = true;
+ ED_region_panels_layout_ex(C, ar, contexts_base, -1, vertical);
+}
+
static void image_buttons_region_draw(const bContext *C, ARegion *ar)
{
SpaceImage *sima = CTX_wm_space_image(C);
@@ -776,7 +793,8 @@ static void image_buttons_region_draw(const bContext *C, ARegion *ar)
}
ED_space_image_release_buffer(sima, ibuf, lock);
- ED_region_panels(C, ar);
+ /* Layout handles details. */
+ ED_region_panels_draw(C, ar);
}
static void image_buttons_region_listener(wmWindow *UNUSED(win),
@@ -1020,7 +1038,9 @@ void ED_spacetype_image(void)
art->prefsizex = 220; // XXX
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
art->listener = image_buttons_region_listener;
+ art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_ui;
art->init = image_buttons_region_init;
+ art->layout = image_buttons_region_layout;
art->draw = image_buttons_region_draw;
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt
index bb403751fe2..ad410e0aade 100644
--- a/source/blender/editors/space_info/CMakeLists.txt
+++ b/source/blender/editors/space_info/CMakeLists.txt
@@ -22,15 +22,15 @@ set(INC
../../blenlib
../../blenloader
../../blentranslation
- ../../depsgraph
- ../../imbuf
../../bmesh
+ ../../depsgraph
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index a7d6694b362..c588df9528f 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -116,7 +116,7 @@ static int report_textview_begin(TextViewContext *tvc)
// SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
ReportList *reports = (ReportList *)tvc->arg2;
- tvc->lheight = 14 * UI_DPI_FAC; //sc->lheight;
+ tvc->lheight = 14 * UI_DPI_FAC; // sc->lheight;
tvc->sel_start = 0;
tvc->sel_end = 0;
@@ -256,7 +256,7 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo,
/* view */
tvc.sel_start = 0;
tvc.sel_end = 0;
- tvc.lheight = 14 * UI_DPI_FAC; //sc->lheight;
+ tvc.lheight = 14 * UI_DPI_FAC; // sc->lheight;
tvc.ymin = v2d->cur.ymin;
tvc.ymax = v2d->cur.ymax;
tvc.winx = ar->winx - V2D_SCROLL_WIDTH;
diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c
index 1521a400779..4c00512d838 100644
--- a/source/blender/editors/space_info/info_report.c
+++ b/source/blender/editors/space_info/info_report.c
@@ -41,6 +41,37 @@
#include "info_intern.h"
+static void reports_select_all(ReportList *reports, int report_mask, int action)
+{
+ if (action == SEL_TOGGLE) {
+ action = SEL_SELECT;
+ for (Report *report = reports->list.last; report; report = report->prev) {
+ if ((report->type & report_mask) && (report->flag & SELECT)) {
+ action = SEL_DESELECT;
+ break;
+ }
+ }
+ }
+
+ for (Report *report = reports->list.last; report; report = report->prev) {
+ if (report->type & report_mask) {
+ switch (action) {
+ case SEL_SELECT:
+ report->flag = SELECT;
+ break;
+ case SEL_DESELECT:
+ report->flag = ~SELECT;
+ break;
+ case SEL_INVERT:
+ report->flag ^= SELECT;
+ break;
+ default:
+ BLI_assert(0);
+ }
+ }
+ }
+}
+
int info_report_mask(SpaceInfo *UNUSED(sinfo))
{
#if 0
@@ -112,12 +143,20 @@ void INFO_OT_report_replay(wmOperatorType *ot)
static int select_report_pick_exec(bContext *C, wmOperator *op)
{
int report_index = RNA_int_get(op->ptr, "report_index");
+ bool extend = RNA_boolean_get(op->ptr, "extend");
+
Report *report = BLI_findlink(&CTX_wm_reports(C)->list, report_index);
+ SpaceInfo *sinfo = CTX_wm_space_info(C);
+ ReportList *reports = CTX_wm_reports(C);
+ const int report_mask = info_report_mask(sinfo);
if (!report) {
return OPERATOR_CANCELLED;
}
+ if (!extend) {
+ reports_select_all(reports, report_mask, SEL_DESELECT);
+ }
report->flag ^= SELECT; /* toggle */
ED_area_tag_redraw(CTX_wm_area(C));
@@ -155,8 +194,11 @@ void INFO_OT_select_pick(wmOperatorType *ot)
/* ot->flag = OPTYPE_REGISTER; */
/* properties */
+ PropertyRNA *prop;
RNA_def_int(
ot->srna, "report_index", 0, 0, INT_MAX, "Report", "Index of the report", 0, INT_MAX);
+ prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend report selection");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
static int report_select_all_exec(bContext *C, wmOperator *op)
@@ -166,34 +208,7 @@ static int report_select_all_exec(bContext *C, wmOperator *op)
const int report_mask = info_report_mask(sinfo);
int action = RNA_enum_get(op->ptr, "action");
-
- if (action == SEL_TOGGLE) {
- action = SEL_SELECT;
- for (Report *report = reports->list.last; report; report = report->prev) {
- if ((report->type & report_mask) && (report->flag & SELECT)) {
- action = SEL_DESELECT;
- break;
- }
- }
- }
-
- for (Report *report = reports->list.last; report; report = report->prev) {
- if (report->type & report_mask) {
- switch (action) {
- case SEL_SELECT:
- report->flag = SELECT;
- break;
- case SEL_DESELECT:
- report->flag = ~SELECT;
- break;
- case SEL_INVERT:
- report->flag ^= SELECT;
- break;
- default:
- BLI_assert(0);
- }
- }
- }
+ reports_select_all(reports, report_mask, action);
ED_area_tag_redraw(CTX_wm_area(C));
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 6ed9d80d145..8eddf90b06b 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -85,7 +85,7 @@ static SpaceLink *info_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
- //ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM);
+ // ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM);
return (SpaceLink *)sinfo;
}
@@ -160,9 +160,8 @@ static void info_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
diff --git a/source/blender/editors/space_nla/CMakeLists.txt b/source/blender/editors/space_nla/CMakeLists.txt
index 3048c64c49e..60152bffaf4 100644
--- a/source/blender/editors/space_nla/CMakeLists.txt
+++ b/source/blender/editors/space_nla/CMakeLists.txt
@@ -25,8 +25,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index d6353a9b0d4..719efc7eeac 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -59,7 +59,7 @@
static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int UNUSED(event))
{
- //Scene *scene = CTX_data_scene(C);
+ // Scene *scene = CTX_data_scene(C);
#if 0
switch (event) {
/* pass */
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index 638ad62592e..3e4eb6af098 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -136,7 +136,6 @@ static int mouse_nla_channels(
if (selectmode == SELECT_INVERT) {
/* swap select */
ED_object_base_select(base, BA_INVERT);
- BKE_scene_object_base_flag_sync_from_base(base);
if (adt) {
adt->flag ^= ADT_UI_SELECTED;
@@ -147,7 +146,6 @@ static int mouse_nla_channels(
/* TODO: should this deselect all other types of channels too? */
for (Base *b = view_layer->object_bases.first; b; b = b->next) {
ED_object_base_select(b, BA_DESELECT);
- BKE_scene_object_base_flag_sync_from_base(b);
if (b->object->adt) {
b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
}
@@ -155,7 +153,6 @@ static int mouse_nla_channels(
/* select object now */
ED_object_base_select(base, BA_SELECT);
- BKE_scene_object_base_flag_sync_from_base(base);
if (adt) {
adt->flag |= ADT_UI_SELECTED;
}
@@ -387,19 +384,12 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEv
selectmode = SELECT_REPLACE;
}
- /**
- * Figure out which channel user clicked in:
- *
- * \note Although channels technically start at y= NLACHANNEL_FIRST,
- * we need to adjust by half a channel's height so that the tops of channels get caught ok.
- * Since NLACHANNEL_FIRST is really NLACHANNEL_HEIGHT, we simply use NLACHANNEL_HEIGHT_HALF.
- */
+ /* Figure out which channel user clicked in. */
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y);
- UI_view2d_listview_view_to_cell(v2d,
- NLACHANNEL_NAMEWIDTH,
+ UI_view2d_listview_view_to_cell(NLACHANNEL_NAMEWIDTH,
NLACHANNEL_STEP(snla),
0,
- (float)NLACHANNEL_HEIGHT_HALF(snla),
+ NLACHANNEL_FIRST_TOP(snla),
x,
y,
NULL,
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 1df2190b7af..b821a246dc5 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -689,23 +689,19 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
* - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
* start of list offset, and the second is as a correction for the scrollers.
*/
- int height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2));
-
- /* don't use totrect set, as the width stays the same
- * (NOTE: this is ok here, the configuration is pretty straightforward)
- */
- v2d->tot.ymin = (float)(-height);
+ int height = NLACHANNEL_TOT_HEIGHT(snla, items);
+ v2d->tot.ymin = -height;
/* loop through channels, and set up drawing depending on their type */
- float y = (float)(-NLACHANNEL_HEIGHT(snla));
+ float ymax = NLACHANNEL_FIRST_TOP(snla);
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
- const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla));
- const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla));
+ for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next, ymax -= NLACHANNEL_STEP(snla)) {
+ float ymin = ymax - NLACHANNEL_HEIGHT(snla);
+ float ycenter = (ymax + ymin) / 2.0f;
/* check if visible */
- if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
- IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
+ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
+ IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
/* data to draw depends on the type of channel */
switch (ale->type) {
case ANIMTYPE_NLATRACK: {
@@ -721,18 +717,18 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
const float xmaxc = strip->end + text_margin_x;
/* draw the visualization of the strip */
- nla_draw_strip(snla, adt, nlt, strip, v2d, yminc, ymaxc);
+ nla_draw_strip(snla, adt, nlt, strip, v2d, ymin, ymax);
/* add the text for this strip to the cache */
if (xminc < xmaxc) {
- nla_draw_strip_text(adt, nlt, strip, index, v2d, xminc, xmaxc, yminc, ymaxc);
+ nla_draw_strip_text(adt, nlt, strip, index, v2d, xminc, xmaxc, ymin, ymax);
}
/* if transforming strips (only real reason for temp-metas currently),
* add to the cache the frame numbers of the strip's extents
*/
if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
- nla_draw_strip_frames_text(nlt, strip, v2d, yminc, ymaxc);
+ nla_draw_strip_frames_text(nlt, strip, v2d, ymin, ymax);
}
}
}
@@ -761,27 +757,27 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
* but also slightly shorter for some more contrast when viewing the strips
*/
immRectf(
- pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP);
+ pos, v2d->cur.xmin, ymin + NLACHANNEL_SKIP, v2d->cur.xmax, ymax - NLACHANNEL_SKIP);
/* draw 'embossed' lines above and below the strip for effect */
/* white base-lines */
GPU_line_width(2.0f);
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.3f);
immBegin(GPU_PRIM_LINES, 4);
- immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP);
- immVertex2f(pos, v2d->cur.xmax, yminc + NLACHANNEL_SKIP);
- immVertex2f(pos, v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP);
- immVertex2f(pos, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP);
+ immVertex2f(pos, v2d->cur.xmin, ymin + NLACHANNEL_SKIP);
+ immVertex2f(pos, v2d->cur.xmax, ymin + NLACHANNEL_SKIP);
+ immVertex2f(pos, v2d->cur.xmin, ymax - NLACHANNEL_SKIP);
+ immVertex2f(pos, v2d->cur.xmax, ymax - NLACHANNEL_SKIP);
immEnd();
/* black top-lines */
GPU_line_width(1.0f);
immUniformColor3f(0.0f, 0.0f, 0.0f);
immBegin(GPU_PRIM_LINES, 4);
- immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP);
- immVertex2f(pos, v2d->cur.xmax, yminc + NLACHANNEL_SKIP);
- immVertex2f(pos, v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP);
- immVertex2f(pos, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP);
+ immVertex2f(pos, v2d->cur.xmin, ymin + NLACHANNEL_SKIP);
+ immVertex2f(pos, v2d->cur.xmax, ymin + NLACHANNEL_SKIP);
+ immVertex2f(pos, v2d->cur.xmin, ymax - NLACHANNEL_SKIP);
+ immVertex2f(pos, v2d->cur.xmax, ymax - NLACHANNEL_SKIP);
immEnd();
/* TODO: these lines but better --^ */
@@ -790,16 +786,13 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
/* draw keyframes in the action */
nla_action_draw_keyframes(
- v2d, adt, ale->data, y, yminc + NLACHANNEL_SKIP, ymaxc - NLACHANNEL_SKIP);
+ v2d, adt, ale->data, ycenter, ymin + NLACHANNEL_SKIP, ymax - NLACHANNEL_SKIP);
GPU_blend(false);
break;
}
}
}
-
- /* adjust y-position for next one */
- y -= NLACHANNEL_STEP(snla);
}
/* free tempolary channels */
@@ -817,7 +810,6 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar)
SpaceNla *snla = (SpaceNla *)ac->sl;
View2D *v2d = &ar->v2d;
- float y = 0.0f;
size_t items;
/* build list of channels to draw */
@@ -830,11 +822,9 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar)
* - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
* start of list offset, and the second is as a correction for the scrollers.
*/
- int height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2));
- /* don't use totrect set, as the width stays the same
- * (NOTE: this is ok here, the configuration is pretty straightforward)
- */
- v2d->tot.ymin = (float)(-height);
+ int height = NLACHANNEL_TOT_HEIGHT(snla, items);
+ v2d->tot.ymin = -height;
+
/* need to do a view-sync here, so that the keys area doesn't jump around
* (it must copy this) */
UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY);
@@ -842,30 +832,24 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar)
/* draw channels */
{ /* first pass: just the standard GL-drawing for backdrop + text */
size_t channel_index = 0;
+ float ymax = NLACHANNEL_FIRST_TOP(snla);
- y = (float)(-NLACHANNEL_HEIGHT(snla));
-
- for (ale = anim_data.first; ale; ale = ale->next) {
- float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla));
- float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla));
+ for (ale = anim_data.first; ale;
+ ale = ale->next, ymax -= NLACHANNEL_STEP(snla), channel_index++) {
+ float ymin = ymax - NLACHANNEL_HEIGHT(snla);
/* check if visible */
- if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
- IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
+ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
+ IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
/* draw all channels using standard channel-drawing API */
- ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index);
+ ANIM_channel_draw(ac, ale, ymin, ymax, channel_index);
}
-
- /* adjust y-position for next one */
- y -= NLACHANNEL_STEP(snla);
- channel_index++;
}
}
{ /* second pass: UI widgets */
uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
size_t channel_index = 0;
-
- y = (float)(-NLACHANNEL_HEIGHT(snla));
+ float ymax = NLACHANNEL_FIRST_TOP(snla);
/* set blending again, as may not be set in previous step */
GPU_blend_set_func_separate(
@@ -873,22 +857,18 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar)
GPU_blend(true);
/* loop through channels, and set up drawing depending on their type */
- for (ale = anim_data.first; ale; ale = ale->next) {
- const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla));
- const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla));
+ for (ale = anim_data.first; ale;
+ ale = ale->next, ymax -= NLACHANNEL_STEP(snla), channel_index++) {
+ float ymin = ymax - NLACHANNEL_HEIGHT(snla);
/* check if visible */
- if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
- IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
+ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
+ IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
/* draw all channels using standard channel-drawing API */
rctf channel_rect;
- BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax, yminc, ymaxc);
+ BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax, ymin, ymax);
ANIM_channel_draw_widgets(C, ac, ale, block, &channel_rect, channel_index);
}
-
- /* adjust y-position for next one */
- y -= NLACHANNEL_STEP(snla);
- channel_index++;
}
UI_block_end(C, block);
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 76930d3117b..07853e5850a 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -421,27 +421,25 @@ static bool nla_channels_get_selected_extents(bAnimContext *ac, float *min, floa
int filter;
SpaceNla *snla = (SpaceNla *)ac->sl;
- const float half_height = NLACHANNEL_HEIGHT_HALF(snla);
/* NOTE: not bool, since we want prioritise individual channels over expanders */
short found = 0;
- float y;
/* get all items - we need to do it this way */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* loop through all channels, finding the first one that's selected */
- y = (float)NLACHANNEL_FIRST;
+ float ymax = NLACHANNEL_FIRST_TOP(snla);
- for (ale = anim_data.first; ale; ale = ale->next) {
+ for (ale = anim_data.first; ale; ale = ale->next, ymax -= NLACHANNEL_STEP(snla)) {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
/* must be selected... */
if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) &&
ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) {
/* update best estimate */
- *min = (float)(y - half_height);
- *max = (float)(y + half_height);
+ *min = ymax - NLACHANNEL_HEIGHT(snla);
+ *max = ymax;
/* is this high enough priority yet? */
found = acf->channel_role;
@@ -453,9 +451,6 @@ static bool nla_channels_get_selected_extents(bAnimContext *ac, float *min, floa
break;
}
}
-
- /* adjust y-position for next one */
- y -= NLACHANNEL_STEP(snla);
}
/* free all temp data */
@@ -617,7 +612,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
if (act == NULL) {
BKE_report(op->reports, RPT_ERROR, "No valid action to add");
- //printf("Add strip - actname = '%s'\n", actname);
+ // printf("Add strip - actname = '%s'\n", actname);
return OPERATOR_CANCELLED;
}
else if (act->idroot == 0) {
@@ -657,8 +652,9 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
AnimData *adt = ale->adt;
NlaStrip *strip = NULL;
- /* sanity check: only apply actions of the right type for this ID
- * NOTE: in the case that this hasn't been set, we've already warned the user about this already
+ /* Sanity check: only apply actions of the right type for this ID.
+ * NOTE: in the case that this hasn't been set,
+ * we've already warned the user about this already
*/
if ((act->idroot) && (act->idroot != GS(ale->id->name))) {
BKE_reportf(
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index cb54129a820..accd82525f5 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -523,7 +523,8 @@ void NLA_OT_select_leftright(wmOperatorType *ot)
/* ******************** Mouse-Click Select Operator *********************** */
/* select strip directly under mouse */
-static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], short select_mode)
+static void mouse_nla_strips(
+ bContext *C, bAnimContext *ac, const int mval[2], short select_mode, const bool deselect_all)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale = NULL;
@@ -540,15 +541,8 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
/* use View2D to determine the index of the channel
* (i.e a row in the list) where keyframe was */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
- UI_view2d_listview_view_to_cell(v2d,
- 0,
- NLACHANNEL_STEP(snla),
- 0,
- (float)NLACHANNEL_HEIGHT_HALF(snla),
- x,
- y,
- NULL,
- &channel_index);
+ UI_view2d_listview_view_to_cell(
+ 0, NLACHANNEL_STEP(snla), 0, NLACHANNEL_FIRST_TOP(snla), x, y, NULL, &channel_index);
/* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click
* (that is the size of keyframe icons, so user should be expecting similar tolerances)
@@ -562,14 +556,7 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
/* try to get channel */
ale = BLI_findlink(&anim_data, channel_index);
- if (ale == NULL) {
- /* channel not found */
- printf("Error: animation channel (index = %d) not found in mouse_nla_strips()\n",
- channel_index);
- ANIM_animdata_freelist(&anim_data);
- return;
- }
- else {
+ if (ale != NULL) {
/* found some channel - we only really should do something when its an Nla-Track */
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
@@ -586,11 +573,11 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
/* remove active channel from list of channels for separate treatment
* (since it's needed later on) */
BLI_remlink(&anim_data, ale);
-
- /* free list of channels, since it's not used anymore */
- ANIM_animdata_freelist(&anim_data);
}
+ /* free list of channels, since it's not used anymore */
+ ANIM_animdata_freelist(&anim_data);
+
/* if currently in tweakmode, exit tweakmode before changing selection states
* now that we've found our target...
*/
@@ -598,8 +585,10 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL);
}
- /* for replacing selection, firstly need to clear existing selection */
- if (select_mode == SELECT_REPLACE) {
+ /* For replacing selection, if we have something to select, we have to clear existing selection.
+ * The same goes if we found nothing to select, and deselect_all is true
+ * (deselect on nothing behavior). */
+ if ((strip != NULL && select_mode == SELECT_REPLACE) || (strip == NULL && deselect_all)) {
/* reset selection mode for next steps */
select_mode = SELECT_ADD;
@@ -611,9 +600,9 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
}
/* only select strip if we clicked on a valid channel and hit something */
- if (ale) {
+ if (ale != NULL) {
/* select the strip accordingly (if a matching one was found) */
- if (strip) {
+ if (strip != NULL) {
select_mode = selmodes_to_flagmodes(select_mode);
ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT);
@@ -647,31 +636,18 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
bAnimContext ac;
- /* Scene *scene; */ /* UNUSED */
- /* ARegion *ar; */ /* UNUSED */
- // View2D *v2d; /*UNUSED*/
- short selectmode;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
}
- /* get useful pointers from animation context data */
- /* scene= ac.scene; */ /* UNUSED */
- /* ar= ac.ar; */ /* UNUSED */
- // v2d= &ar->v2d;
-
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend")) {
- selectmode = SELECT_INVERT;
- }
- else {
- selectmode = SELECT_REPLACE;
- }
+ const short selectmode = RNA_boolean_get(op->ptr, "extend") ? SELECT_INVERT : SELECT_REPLACE;
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
/* select strips based upon mouse position */
- mouse_nla_strips(C, &ac, event->mval, selectmode);
+ mouse_nla_strips(C, &ac, event->mval, selectmode, deselect_all);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL);
@@ -699,6 +675,13 @@ void NLA_OT_click_select(wmOperatorType *ot)
/* properties */
prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/* *********************************************** */
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 527a4f6e5f6..ba660945d32 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -174,13 +174,13 @@ static void nla_channel_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
/* own channels map first to override some channel keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Channels", SPACE_NLA, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* now generic channels map for everything else that can apply */
keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
/* draw entirely, view changes should be handled here */
@@ -205,9 +205,8 @@ static void nla_channel_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
@@ -220,7 +219,7 @@ static void nla_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Editor", SPACE_NLA, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -232,9 +231,8 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
Scene *scene = CTX_data_scene(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
- View2DGrid *grid;
View2DScrollers *scrollers;
- short unit = 0, cfra_flag = 0;
+ short cfra_flag = 0;
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -243,17 +241,7 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* time grid */
- unit = (snla->flag & SNLA_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
- grid = UI_view2d_grid_calc(CTX_data_scene(C),
- v2d,
- unit,
- V2D_GRID_CLAMP,
- V2D_ARG_DUMMY,
- V2D_ARG_DUMMY,
- ar->winx,
- ar->winy);
- UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
- UI_view2d_grid_free(grid);
+ UI_view2d_draw_lines_x__discrete_frames_or_seconds(v2d, scene, snla->flag & SNLA_DRAWTIME);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
@@ -297,11 +285,14 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
+ /* frame numbers */
+ UI_view2d_draw_scale_x__discrete_frames_or_seconds(
+ ar, v2d, &v2d->hor, scene, snla->flag & SNLA_DRAWTIME, TH_TEXT);
+
/* draw current frame number-indicator on top of scrollers */
if ((snla->flag & SNLA_NODRAWCFRANUM) == 0) {
UI_view2d_view_orthoSpecial(ar, v2d, 1);
@@ -328,7 +319,7 @@ static void nla_buttons_region_init(wmWindowManager *wm, ARegion *ar)
ED_region_panels_init(wm, ar);
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void nla_buttons_region_draw(const bContext *C, ARegion *ar)
diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt
index df1b7c03aab..03c83305618 100644
--- a/source/blender/editors/space_node/CMakeLists.txt
+++ b/source/blender/editors/space_node/CMakeLists.txt
@@ -22,16 +22,16 @@ set(INC
../../blenlib
../../blentranslation
../../depsgraph
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../nodes
../../render/extern/include
- ../../windowmanager
../../compositor
- ../../../../intern/guardedalloc
+ ../../windowmanager
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index a694ac2c38b..020bdbf60a1 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -1309,7 +1309,7 @@ static void node_draw_hidden(const bContext *C,
nodeLabel(ntree, node, showname, sizeof(showname));
/* XXX - don't print into self! */
- //if (node->flag & NODE_MUTED)
+ // if (node->flag & NODE_MUTED)
// BLI_snprintf(showname, sizeof(showname), "[%s]", showname);
uiBut *but = uiDefBut(node->block,
@@ -1728,8 +1728,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
draw_tree_path(snode);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index 3c65c4854b8..08328681f7a 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -823,8 +823,8 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
/* update the group node and interface node sockets,
* so the new interface socket can be linked.
*/
- node_group_verify(ntree, gnode, (ID *)ngroup);
- node_group_input_verify(ngroup, input_node, (ID *)ngroup);
+ node_group_update(ntree, gnode);
+ node_group_input_update(ngroup, input_node);
/* create new internal link */
input_sock = node_group_input_find_socket(input_node, iosock->identifier);
@@ -857,8 +857,8 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
/* update the group node and interface node sockets,
* so the new interface socket can be linked.
*/
- node_group_verify(ntree, gnode, (ID *)ngroup);
- node_group_output_verify(ngroup, output_node, (ID *)ngroup);
+ node_group_update(ntree, gnode);
+ node_group_output_update(ngroup, output_node);
/* create new internal link */
output_sock = node_group_output_find_socket(output_node, iosock->identifier);
@@ -898,7 +898,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
- node_group_input_verify(ngroup, input_node, (ID *)ngroup);
+ node_group_input_update(ngroup, input_node);
/* create new internal link */
input_sock = node_group_input_find_socket(input_node, iosock->identifier);
@@ -919,7 +919,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
- node_group_output_verify(ngroup, output_node, (ID *)ngroup);
+ node_group_output_update(ngroup, output_node);
/* create new internal link */
output_sock = node_group_output_find_socket(output_node, iosock->identifier);
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 58531ec32b1..b52d1d3b78f 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -429,8 +429,13 @@ void node_select_single(bContext *C, bNode *node)
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
}
-static int node_mouse_select(
- Main *bmain, SpaceNode *snode, ARegion *ar, const int mval[2], bool extend, bool socket_select)
+static int node_mouse_select(Main *bmain,
+ SpaceNode *snode,
+ ARegion *ar,
+ const int mval[2],
+ const bool extend,
+ const bool socket_select,
+ const bool deselect_all)
{
bNode *node, *tnode;
bNodeSocket *sock = NULL;
@@ -500,13 +505,15 @@ static int node_mouse_select(
/* find the closest visible node */
node = node_under_mouse_select(snode->edittree, cursor[0], cursor[1]);
- if (node) {
+ if (node != NULL || deselect_all) {
for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
nodeSetSelected(tnode, false);
}
- nodeSetSelected(node, true);
- ED_node_set_active(bmain, snode->edittree, node);
selected = true;
+ if (node != NULL) {
+ nodeSetSelected(node, true);
+ ED_node_set_active(bmain, snode->edittree, node);
+ }
}
}
}
@@ -526,19 +533,18 @@ static int node_select_exec(bContext *C, wmOperator *op)
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
int mval[2];
- short extend;
- bool socket_select;
/* get settings from RNA properties for operator */
mval[0] = RNA_int_get(op->ptr, "mouse_x");
mval[1] = RNA_int_get(op->ptr, "mouse_y");
- extend = RNA_boolean_get(op->ptr, "extend");
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
/* always do socket_select when extending selection. */
- socket_select = extend || RNA_boolean_get(op->ptr, "socket_select");
+ const bool socket_select = extend || RNA_boolean_get(op->ptr, "socket_select");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
/* perform the select */
- if (node_mouse_select(bmain, snode, ar, mval, extend, socket_select)) {
+ if (node_mouse_select(bmain, snode, ar, mval, extend, socket_select, deselect_all)) {
/* send notifiers */
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
@@ -575,10 +581,17 @@ void NODE_OT_select(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
+ PropertyRNA *prop;
RNA_def_int(ot->srna, "mouse_x", 0, INT_MIN, INT_MAX, "Mouse X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX);
RNA_def_boolean(ot->srna, "extend", false, "Extend", "");
RNA_def_boolean(ot->srna, "socket_select", false, "Socket Select", "");
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/** \} */
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 94380814fe8..2152bb9847a 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -617,7 +617,7 @@ static void node_main_region_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Node Editor", SPACE_NODE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* add drop boxes */
lb = WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW);
diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt
index f08069c418b..d235dd47136 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -21,13 +21,13 @@ set(INC
../../blenlib
../../blentranslation
../../depsgraph
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index 4cb80bd1394..49ba397a108 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -175,7 +175,8 @@ static TreeElement *outliner_drop_insert_find(bContext *C,
}
}
else {
- /* mouse doesn't hover any item (ignoring x-axis), so it's either above list bounds or below. */
+ /* Mouse doesn't hover any item (ignoring x-axis),
+ * so it's either above list bounds or below. */
TreeElement *first = soops->tree.first;
TreeElement *last = soops->tree.last;
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 9dbea3c5b1b..9d6008ce3a8 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -627,6 +627,10 @@ static void outliner_draw_restrictbuts(uiBlock *block,
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE);
}
+ else if ((tselem->type == 0 && te->idcode == ID_OB) &&
+ (te->flag & TE_CHILD_NOT_IN_COLLECTION)) {
+ /* Don't show restrict columns for children that are not directly inside the collection. */
+ }
else if (tselem->type == 0 && te->idcode == ID_OB) {
PointerRNA ptr;
Object *ob = (Object *)tselem->id;
@@ -898,7 +902,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
ICON_HIDE_OFF;
}
bt = uiDefIconBut(block,
- UI_BTYPE_TOGGLE,
+ UI_BTYPE_ICON_TOGGLE,
0,
icon,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX),
@@ -1010,7 +1014,7 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOutliner *s
tip = TIP_("Data-block has no users and will be deleted");
}
bt = uiDefIconButBitS(block,
- UI_BTYPE_TOGGLE,
+ UI_BTYPE_ICON_TOGGLE,
LIB_FAKEUSER,
1,
icon,
@@ -1045,7 +1049,7 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOutliner *s
UI_but_flag_enable(bt, but_flag);
bt = uiDefButBitS(block,
- UI_BTYPE_TOGGLE,
+ UI_BTYPE_ICON_TOGGLE,
LIB_FAKEUSER,
1,
(id->flag & LIB_FAKEUSER) ? "F" : " ",
@@ -2074,7 +2078,10 @@ static void outliner_draw_tree_element(bContext *C,
tselem = TREESTORE(te);
if (*starty + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) {
- const float alpha_fac = ((te->flag & TE_DISABLED) || draw_grayed_out) ? 0.5f : 1.0f;
+ const float alpha_fac = ((te->flag & TE_DISABLED) || (te->flag & TE_CHILD_NOT_IN_COLLECTION) ||
+ draw_grayed_out) ?
+ 0.5f :
+ 1.0f;
const float alpha = 0.5f * alpha_fac;
int xmax = ar->v2d.cur.xmax;
@@ -2100,7 +2107,8 @@ static void outliner_draw_tree_element(bContext *C,
}
else if (te->idcode == ID_OB) {
Object *ob = (Object *)tselem->id;
- Base *base = BKE_view_layer_base_find(view_layer, ob);
+ Base *base = (te->directdata) ? (Base *)te->directdata :
+ BKE_view_layer_base_find(view_layer, ob);
const bool is_selected = (base != NULL) && ((base->flag & BASE_SELECTED) != 0);
if (ob == obact || is_selected) {
@@ -2255,26 +2263,6 @@ static void outliner_draw_tree_element(bContext *C,
GPU_blend(true);
- /* divider */
- {
- GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(
- format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
- unsigned char col[4];
-
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- UI_GetThemeColorShade4ubv(TH_BACK, -40, col);
- col[3] *= alpha_fac;
-
- immUniformColor4ubv(col);
- immRecti(pos,
- tempx - 10.0f * ufac,
- *starty + 4.0f * ufac,
- tempx - 8.0f * ufac,
- *starty + UI_UNIT_Y - 4.0f * ufac);
- immUnbindProgram();
- }
-
MergedIconRow merged = {{0}};
outliner_draw_iconrow(C,
block,
@@ -2338,17 +2326,28 @@ static void outliner_draw_hierarchy_lines_recursive(unsigned pos,
bool draw_grayed_out,
int *starty)
{
- TreeElement *te, *te_vertical_line_last = NULL;
- int y1, y2;
+ TreeElement *te, *te_vertical_line_last = NULL, *te_vertical_line_last_dashed = NULL;
+ int y1, y2, y1_dashed, y2_dashed;
if (BLI_listbase_is_empty(lb)) {
return;
}
+ struct {
+ int steps_num;
+ int step_len;
+ int gap_len;
+ } dash = {
+ .steps_num = 4,
+ };
+
+ dash.step_len = UI_UNIT_X / dash.steps_num;
+ dash.gap_len = dash.step_len / 2;
+
const unsigned char grayed_alpha = col[3] / 2;
/* For vertical lines between objects. */
- y1 = y2 = *starty;
+ y1 = y2 = y1_dashed = y2_dashed = *starty;
for (te = lb->first; te; te = te->next) {
bool draw_childs_grayed_out = draw_grayed_out || (te->flag & TE_DRAGGING);
TreeStoreElem *tselem = TREESTORE(te);
@@ -2360,15 +2359,30 @@ static void outliner_draw_hierarchy_lines_recursive(unsigned pos,
immUniformColor4ubv(col);
}
- /* Horizontal Line? */
- if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) {
- immRecti(pos, startx, *starty, startx + UI_UNIT_X, *starty - 1);
+ if ((te->flag & TE_CHILD_NOT_IN_COLLECTION) == 0) {
+ /* Horizontal Line? */
+ if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) {
+ immRecti(pos, startx, *starty, startx + UI_UNIT_X, *starty - U.pixelsize);
- /* Vertical Line? */
- if (te->idcode == ID_OB) {
- te_vertical_line_last = te;
- y2 = *starty;
+ /* Vertical Line? */
+ if (te->idcode == ID_OB) {
+ te_vertical_line_last = te;
+ y2 = *starty;
+ }
+ y1_dashed = *starty - UI_UNIT_Y;
+ }
+ }
+ else {
+ BLI_assert(te->idcode == ID_OB);
+ /* Horizontal line - dashed. */
+ int start = startx;
+ for (int i = 0; i < dash.steps_num; i++) {
+ immRecti(pos, start, *starty, start + dash.step_len - dash.gap_len, *starty - U.pixelsize);
+ start += dash.step_len;
}
+
+ te_vertical_line_last_dashed = te;
+ y2_dashed = *starty;
}
*starty -= UI_UNIT_Y;
@@ -2389,7 +2403,19 @@ static void outliner_draw_hierarchy_lines_recursive(unsigned pos,
/* Vertical line. */
te = te_vertical_line_last;
if ((te != NULL) && (te->parent || lb->first != lb->last)) {
- immRecti(pos, startx, y1 + UI_UNIT_Y, startx + 1, y2);
+ immRecti(pos, startx, y1 + UI_UNIT_Y, startx + U.pixelsize, y2);
+ }
+
+ /* Children that are not in the collection are always in the end of the subtree.
+ * This way we can draw their own dashed vertical lines. */
+ te = te_vertical_line_last_dashed;
+ if ((te != NULL) && (te->parent || lb->first != lb->last)) {
+ const int steps_num = ((y1_dashed + UI_UNIT_Y) - y2_dashed) / dash.step_len;
+ int start = y1_dashed + UI_UNIT_Y;
+ for (int i = 0; i < steps_num; i++) {
+ immRecti(pos, startx, start, startx + U.pixelsize, start - dash.step_len + dash.gap_len);
+ start -= dash.step_len;
+ }
}
}
@@ -2473,7 +2499,7 @@ static void outliner_draw_highlights_recursive(unsigned pos,
/* selection status */
if (tselem->flag & TSE_SELECTED) {
immUniformColor4fv(col_selection);
- immRecti(pos, 0, start_y + 1, (int)ar->v2d.cur.xmax, start_y + UI_UNIT_Y - 1);
+ immRecti(pos, 0, start_y, (int)ar->v2d.cur.xmax, start_y + UI_UNIT_Y);
}
/* highlights */
@@ -2487,15 +2513,19 @@ static void outliner_draw_highlights_recursive(unsigned pos,
if (tselem->flag & TSE_DRAG_BEFORE) {
immUniformColor4fv(col);
- immRecti(pos, start_x, start_y + UI_UNIT_Y - 1, end_x, start_y + UI_UNIT_Y + 1);
+ immRecti(pos,
+ start_x,
+ start_y + UI_UNIT_Y - U.pixelsize,
+ end_x,
+ start_y + UI_UNIT_Y + U.pixelsize);
}
else if (tselem->flag & TSE_DRAG_AFTER) {
immUniformColor4fv(col);
- immRecti(pos, start_x, start_y - 1, end_x, start_y + 1);
+ immRecti(pos, start_x, start_y - U.pixelsize, end_x, start_y + U.pixelsize);
}
else {
immUniformColor3fvAlpha(col, col[3] * 0.5f);
- immRecti(pos, start_x, start_y + 1, end_x, start_y + UI_UNIT_Y - 1);
+ immRecti(pos, start_x, start_y, end_x, start_y + UI_UNIT_Y);
}
}
else {
@@ -2504,12 +2534,12 @@ static void outliner_draw_highlights_recursive(unsigned pos,
* we don't expand items when searching in the datablocks but we
* still want to highlight any filter matches. */
immUniformColor4fv(col_searchmatch);
- immRecti(pos, start_x, start_y + 1, end_x, start_y + UI_UNIT_Y - 1);
+ immRecti(pos, start_x, start_y, end_x, start_y + UI_UNIT_Y);
}
else if (tselem->flag & TSE_HIGHLIGHTED) {
/* mouse hover highlight */
immUniformColor4fv(col_highlight);
- immRecti(pos, 0, start_y + 1, end_x, start_y + UI_UNIT_Y - 1);
+ immRecti(pos, 0, start_y, end_x, start_y + UI_UNIT_Y);
}
}
}
@@ -2588,7 +2618,7 @@ static void outliner_draw_tree(bContext *C,
// gray hierarchy lines
starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET;
- startx = UI_UNIT_X / 2 - 1.0f;
+ startx = UI_UNIT_X / 2 - (U.pixelsize + 1) / 2;
outliner_draw_hierarchy_lines(soops, &soops->tree, startx, &starty);
// items themselves
@@ -2650,29 +2680,6 @@ static void outliner_back(ARegion *ar)
immUnbindProgram();
}
-static void outliner_draw_restrictcols(ARegion *ar)
-{
- GPU_line_width(1.0f);
-
- uint pos = GPU_vertformat_attr_add(
- immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformThemeColorShadeAlpha(TH_BACK, -15, -200);
- immBegin(GPU_PRIM_LINES, 6);
-
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymax);
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymin);
-
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)ar->v2d.cur.ymax);
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)ar->v2d.cur.ymin);
-
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)ar->v2d.cur.ymax);
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)ar->v2d.cur.ymin);
-
- immEnd();
- immUnbindProgram();
-}
-
/* ****************************************************** */
/* Main Entrypoint - Draw contents of Outliner editor */
@@ -2717,7 +2724,7 @@ void draw_outliner(const bContext *C)
else {
/* width must take into account restriction columns (if visible)
* so that entries will still be visible */
- //outliner_width(soops, &soops->tree, &sizex);
+ // outliner_width(soops, &soops->tree, &sizex);
// XXX should use outliner_width instead when te->xend will be set correctly...
outliner_rna_width(soops, &soops->tree, &sizex, 0);
@@ -2760,13 +2767,10 @@ void draw_outliner(const bContext *C)
}
else if ((soops->outlinevis == SO_ID_ORPHANS) && has_restrict_icons) {
/* draw user toggle columns */
- outliner_draw_restrictcols(ar);
outliner_draw_userbuts(block, ar, soops, &soops->tree);
}
else if (has_restrict_icons) {
/* draw restriction columns */
- outliner_draw_restrictcols(ar);
-
outliner_draw_restrictbuts(block, scene, view_layer, ar, soops, &soops->tree);
}
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index d939f84e186..a943e972cf5 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -1634,7 +1634,8 @@ static void tree_element_to_path(TreeElement *te,
/* check if we're looking for first ID, or appending to path */
if (*id) {
/* just 'append' property to path
- * - to prevent memory leaks, we must write to newpath not path, then free old path + swap them
+ * - to prevent memory leaks, we must write to newpath not path,
+ * then free old path + swap them.
*/
if (tse->type == TSE_RNA_PROPERTY) {
if (RNA_property_type(prop) == PROP_POINTER) {
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index d382384076b..8211e3005c7 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -130,6 +130,7 @@ enum {
TE_FREE_NAME = (1 << 3),
TE_DISABLED = (1 << 4),
TE_DRAGGING = (1 << 5),
+ TE_CHILD_NOT_IN_COLLECTION = (1 << 6),
};
/* button events */
@@ -235,10 +236,6 @@ eOLDrawState tree_element_active(struct bContext *C,
void outliner_item_do_activate_from_tree_element(
struct bContext *C, TreeElement *te, TreeStoreElem *tselem, bool extend, bool recursive);
-int outliner_item_do_activate_from_cursor(struct bContext *C,
- const int mval[2],
- bool extend,
- bool recursive);
void outliner_item_select(struct SpaceOutliner *soops,
const struct TreeElement *te,
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 459736a730d..995f41382cd 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1297,10 +1297,11 @@ void outliner_item_do_activate_from_tree_element(
*
* May expend/collapse branches or activate items.
* */
-int outliner_item_do_activate_from_cursor(bContext *C,
- const int mval[2],
- bool extend,
- bool recursive)
+static int outliner_item_do_activate_from_cursor(bContext *C,
+ const int mval[2],
+ const bool extend,
+ const bool recursive,
+ const bool deselect_all)
{
ARegion *ar = CTX_wm_region(C);
SpaceOutliner *soops = CTX_wm_space_outliner(C);
@@ -1315,7 +1316,10 @@ int outliner_item_do_activate_from_cursor(bContext *C,
}
if (!(te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]))) {
- /* skip */
+ if (deselect_all) {
+ outliner_flag_set(&soops->tree, TSE_SELECTED, false);
+ changed = true;
+ }
}
else if (outliner_item_is_co_within_close_toggle(te, view_mval[0])) {
outliner_item_toggle_closed(te, extend);
@@ -1351,9 +1355,10 @@ int outliner_item_do_activate_from_cursor(bContext *C,
/* event can enterkey, then it opens/closes */
static int outliner_item_activate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- bool extend = RNA_boolean_get(op->ptr, "extend");
- bool recursive = RNA_boolean_get(op->ptr, "recursive");
- return outliner_item_do_activate_from_cursor(C, event->mval, extend, recursive);
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+ const bool recursive = RNA_boolean_get(op->ptr, "recursive");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
+ return outliner_item_do_activate_from_cursor(C, event->mval, extend, recursive, deselect_all);
}
void OUTLINER_OT_item_activate(wmOperatorType *ot)
@@ -1366,8 +1371,15 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot)
ot->poll = ED_operator_outliner_active;
+ PropertyRNA *prop;
RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection for activation");
RNA_def_boolean(ot->srna, "recursive", false, "Recursive", "Select Objects and their children");
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/* ****************************************************** */
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 650827a17c7..0f9efb0d2e1 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -283,7 +283,7 @@ static void unlink_collection_cb(bContext *C,
static void unlink_object_cb(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
- TreeElement *UNUSED(te),
+ TreeElement *te,
TreeStoreElem *tsep,
TreeStoreElem *tselem,
void *UNUSED(user_data))
@@ -291,6 +291,15 @@ static void unlink_object_cb(bContext *C,
Main *bmain = CTX_data_main(C);
Object *ob = (Object *)tselem->id;
+ if (GS(tsep->id->name) == ID_OB) {
+ /* Parented objects need to find which collection to unlink from. */
+ TreeElement *te_parent = te->parent;
+ while (tsep && GS(tsep->id->name) == ID_OB) {
+ te_parent = te_parent->parent;
+ tsep = te_parent ? TREESTORE(te_parent) : NULL;
+ }
+ }
+
if (tsep) {
if (GS(tsep->id->name) == ID_GR) {
Collection *parent = (Collection *)tsep->id;
@@ -452,8 +461,8 @@ static void object_select_cb(bContext *C,
Object *ob = (Object *)tselem->id;
Base *base = BKE_view_layer_base_find(view_layer, ob);
- if (base && ((base->flag & BASE_VISIBLE) != 0)) {
- base->flag |= BASE_SELECTED;
+ if (base) {
+ ED_object_base_select(base, BA_SELECT);
}
}
@@ -1837,8 +1846,8 @@ typedef enum eOutliner_AnimDataOps {
OUTLINER_ANIMOP_REFRESH_DRV,
OUTLINER_ANIMOP_CLEAR_DRV
- //OUTLINER_ANIMOP_COPY_DRIVERS,
- //OUTLINER_ANIMOP_PASTE_DRIVERS
+ // OUTLINER_ANIMOP_COPY_DRIVERS,
+ // OUTLINER_ANIMOP_PASTE_DRIVERS
} eOutliner_AnimDataOps;
static const EnumPropertyItem prop_animdata_op_types[] = {
@@ -1904,7 +1913,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
soops, datalevel, event, &soops->tree, refreshdrivers_animdata_cb, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL);
- //ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */
+ // ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */
updateDeps = 1;
break;
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 69449f46677..4e3fd6037bb 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -48,6 +48,7 @@
#include "DNA_linestyle_types.h"
#include "BLI_blenlib.h"
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLI_mempool.h"
#include "BLI_fnmatch.h"
@@ -359,12 +360,12 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
pchan->temp = (void *)ten;
if (pchan->constraints.first) {
- //Object *target;
+ // Object *target;
bConstraint *con;
TreeElement *ten1;
TreeElement *tenla1 = outliner_add_element(
soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0);
- //char *str;
+ // char *str;
tenla1->name = IFACE_("Constraints");
for (con = pchan->constraints.first; con; con = con->next, const_index++) {
@@ -425,11 +426,11 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
}
if (ob->constraints.first) {
- //Object *target;
+ // Object *target;
bConstraint *con;
TreeElement *ten;
TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0);
- //char *str;
+ // char *str;
int a;
tenla->name = IFACE_("Constraints");
@@ -653,7 +654,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
}
case ID_AC: {
// XXX do we want to be exposing the F-Curves here?
- //bAction *act = (bAction *)id;
+ // bAction *act = (bAction *)id;
break;
}
case ID_AR: {
@@ -1477,6 +1478,104 @@ static void outliner_make_object_parent_hierarchy(ListBase *lb)
}
}
+/**
+ * For all objects in the tree, lookup the parent in this map,
+ * and move or add tree elements as needed.
+ */
+static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soops,
+ GHash *object_tree_elements_hash)
+{
+ GHashIterator gh_iter;
+ GHASH_ITER (gh_iter, object_tree_elements_hash) {
+ Object *child = BLI_ghashIterator_getKey(&gh_iter);
+
+ if (child->parent == NULL) {
+ continue;
+ }
+
+ ListBase *child_ob_tree_elements = BLI_ghashIterator_getValue(&gh_iter);
+ ListBase *parent_ob_tree_elements = BLI_ghash_lookup(object_tree_elements_hash, child->parent);
+ if (parent_ob_tree_elements == NULL) {
+ continue;
+ }
+
+ for (LinkData *link = parent_ob_tree_elements->first; link; link = link->next) {
+ TreeElement *parent_ob_tree_element = link->data;
+ TreeElement *parent_ob_collection_tree_element = NULL;
+ bool found = false;
+
+ /* We always want to remove the child from the direct collection its parent is nested under.
+ * This is particularly important when dealing with multi-level nesting (grandchildren). */
+ parent_ob_collection_tree_element = parent_ob_tree_element->parent;
+ while (!ELEM(TREESTORE(parent_ob_collection_tree_element)->type,
+ TSE_VIEW_COLLECTION_BASE,
+ TSE_LAYER_COLLECTION)) {
+ parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent;
+ }
+
+ for (LinkData *link_iter = child_ob_tree_elements->first; link_iter;
+ link_iter = link_iter->next) {
+ TreeElement *child_ob_tree_element = link_iter->data;
+
+ if (child_ob_tree_element->parent == parent_ob_collection_tree_element) {
+ /* Move from the collection subtree into the parent object subtree. */
+ BLI_remlink(&parent_ob_collection_tree_element->subtree, child_ob_tree_element);
+ BLI_addtail(&parent_ob_tree_element->subtree, child_ob_tree_element);
+ child_ob_tree_element->parent = parent_ob_tree_element;
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ /* We add the child in the tree even if it is not in the collection.
+ * We deliberately clear its subtree though, to make it less proeminent. */
+ TreeElement *child_ob_tree_element = outliner_add_element(
+ soops, &parent_ob_tree_element->subtree, child, parent_ob_tree_element, 0, 0);
+ outliner_free_tree(&child_ob_tree_element->subtree);
+ child_ob_tree_element->flag |= TE_CHILD_NOT_IN_COLLECTION;
+ BLI_addtail(child_ob_tree_elements, BLI_genericNodeN(child_ob_tree_element));
+ }
+ }
+ }
+}
+
+/**
+ * Build a map from Object* to a list of TreeElement* matching the object.
+ */
+static void outliner_object_tree_elements_lookup_create_recursive(GHash *object_tree_elements_hash,
+ TreeElement *te_parent)
+{
+ for (TreeElement *te = te_parent->subtree.first; te; te = te->next) {
+ TreeStoreElem *tselem = TREESTORE(te);
+
+ if (tselem->type == TSE_LAYER_COLLECTION) {
+ outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te);
+ }
+ else if (tselem->type == 0 && te->idcode == ID_OB) {
+ Object *ob = (Object *)tselem->id;
+ ListBase *tree_elements = BLI_ghash_lookup(object_tree_elements_hash, ob);
+
+ if (tree_elements == NULL) {
+ tree_elements = MEM_callocN(sizeof(ListBase), __func__);
+ BLI_ghash_insert(object_tree_elements_hash, ob, tree_elements);
+ }
+
+ BLI_addtail(tree_elements, BLI_genericNodeN(te));
+ outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te);
+ }
+ }
+}
+
+static void outliner_object_tree_elements_lookup_free(GHash *object_tree_elements_hash)
+{
+ GHASH_FOREACH_BEGIN (ListBase *, tree_elements, object_tree_elements_hash) {
+ BLI_freelistN(tree_elements);
+ MEM_freeN(tree_elements);
+ }
+ GHASH_FOREACH_END();
+}
+
/* Sorting ------------------------------------------------------ */
typedef struct tTreeSort {
@@ -1505,6 +1604,13 @@ static int treesort_alpha_ob(const void *v1, const void *v2)
return -1;
}
else if (comp == 3) {
+ /* Among objects first come the ones in the collection, followed by the ones not on it.
+ * This way we can have the dashed lines in a separate style connecting the former. */
+ if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) !=
+ (x2->te->flag & TE_CHILD_NOT_IN_COLLECTION)) {
+ return (x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) ? 1 : -1;
+ }
+
comp = strcmp(x1->name, x2->name);
if (comp > 0) {
@@ -1518,6 +1624,19 @@ static int treesort_alpha_ob(const void *v1, const void *v2)
return 0;
}
+/* Move children that are not in the collection to the end of the list. */
+static int treesort_child_not_in_collection(const void *v1, const void *v2)
+{
+ const tTreeSort *x1 = v1, *x2 = v2;
+
+ /* Among objects first come the ones in the collection, followed by the ones not on it.
+ * This way we can have the dashed lines in a separate style connecting the former. */
+ if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) != (x2->te->flag & TE_CHILD_NOT_IN_COLLECTION)) {
+ return (x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) ? 1 : -1;
+ }
+ return 0;
+}
+
/* alphabetical comparator */
static int treesort_alpha(const void *v1, const void *v2)
{
@@ -1641,6 +1760,50 @@ static void outliner_sort(ListBase *lb)
}
}
+static void outliner_collections_children_sort(ListBase *lb)
+{
+ TreeElement *te;
+ TreeStoreElem *tselem;
+
+ te = lb->last;
+ if (te == NULL) {
+ return;
+ }
+ tselem = TREESTORE(te);
+
+ /* Sorting rules: only object lists. */
+ if (tselem->type == 0 && te->idcode == ID_OB) {
+ int totelem = BLI_listbase_count(lb);
+
+ if (totelem > 1) {
+ tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array");
+ tTreeSort *tp = tear;
+
+ for (te = lb->first; te; te = te->next, tp++) {
+ tselem = TREESTORE(te);
+ tp->te = te;
+ tp->name = te->name;
+ tp->idcode = te->idcode;
+ tp->id = tselem->id;
+ }
+
+ qsort(tear, totelem, sizeof(tTreeSort), treesort_child_not_in_collection);
+
+ BLI_listbase_clear(lb);
+ tp = tear;
+ while (totelem--) {
+ BLI_addtail(lb, tp->te);
+ tp++;
+ }
+ MEM_freeN(tear);
+ }
+ }
+
+ for (te = lb->first; te; te = te->next) {
+ outliner_sort(&te->subtree);
+ }
+}
+
/* Filtering ----------------------------------------------- */
typedef struct OutlinerTreeElementFocus {
@@ -2191,12 +2354,28 @@ void outliner_build_tree(
bool show_objects = !(soops->filter & SO_FILTER_NO_OBJECT);
outliner_add_view_layer(soops, &ten->subtree, ten, view_layer, show_objects);
+
+ if ((soops->filter & SO_FILTER_NO_CHILDREN) == 0) {
+ GHash *object_tree_elements_hash = BLI_ghash_new(
+ BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
+ outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, ten);
+ outliner_make_object_parent_hierarchy_collections(soops, object_tree_elements_hash);
+ outliner_object_tree_elements_lookup_free(object_tree_elements_hash);
+ BLI_ghash_free(object_tree_elements_hash, NULL, NULL);
+ }
}
}
if ((soops->flag & SO_SKIP_SORT_ALPHA) == 0) {
outliner_sort(&soops->tree);
}
+ else if ((soops->filter & SO_FILTER_NO_CHILDREN) == 0) {
+ /* We group the children that are in the collection before the ones that are not.
+ * This way we can try to draw them in a different style altogether.
+ * We also have to respect the original order of the elements in case alphabetical
+ * sorting is not enabled. This keep object data and modifiers before its children. */
+ outliner_collections_children_sort(&soops->tree);
+ }
outliner_filter_tree(soops, view_layer);
outliner_restore_scrolling_position(soops, ar, &focus);
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 26b97a1cdd9..a8e3129b5b4 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -74,8 +74,7 @@ static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Outliner", SPACE_OUTLINER, 0);
- /* don't pass on view2d mask, it's always set with scrollbar space, hide fails */
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* Add dropboxes */
lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW);
@@ -97,9 +96,8 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
diff --git a/source/blender/editors/space_script/CMakeLists.txt b/source/blender/editors/space_script/CMakeLists.txt
index 1abc05d2270..0bd2a01a151 100644
--- a/source/blender/editors/space_script/CMakeLists.txt
+++ b/source/blender/editors/space_script/CMakeLists.txt
@@ -23,8 +23,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c
index 3ffa54727e6..b99c2eaf54e 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -47,7 +47,7 @@
#include "script_intern.h" // own include
#include "GPU_framebuffer.h"
-//static script_run_python(char *funcname, )
+// static script_run_python(char *funcname, )
/* ******************** default callbacks for script space ***************** */
@@ -116,7 +116,7 @@ static void script_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Script", SPACE_SCRIPT, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void script_main_region_draw(const bContext *C, ARegion *ar)
diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt
index 8b97f7537f8..d57be0c85c3 100644
--- a/source/blender/editors/space_sequencer/CMakeLists.txt
+++ b/source/blender/editors/space_sequencer/CMakeLists.txt
@@ -20,14 +20,15 @@ set(INC
../../blenkernel
../../blenlib
../../blentranslation
- ../../imbuf
../../gpu
+ ../../depsgraph
+ ../../imbuf
../../makesdna
../../makesrna
../../windowmanager
../../../../intern/atomic
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 218804b0ab4..1cad9e4f734 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -64,6 +64,8 @@
# include <AUD_Sequence.h>
#endif
+#include "DEG_depsgraph.h"
+
/* own include */
#include "sequencer_intern.h"
@@ -334,7 +336,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
seq->type = SEQ_TYPE_SCENE;
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
seq->scene = sce_seq;
@@ -355,6 +357,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
sequencer_add_apply_replace_sel(C, op, seq);
sequencer_add_apply_overlap(C, op, seq);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
@@ -422,7 +425,7 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
seq->type = SEQ_TYPE_MOVIECLIP;
- seq->blend_mode = SEQ_TYPE_CROSS;
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
seq->clip = clip;
id_us_ensure_real(&seq->clip->id);
@@ -441,6 +444,7 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
sequencer_add_apply_replace_sel(C, op, seq);
sequencer_add_apply_overlap(C, op, seq);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
@@ -508,7 +512,7 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
seq->type = SEQ_TYPE_MASK;
- seq->blend_mode = SEQ_TYPE_CROSS;
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
seq->mask = mask;
id_us_ensure_real(&seq->mask->id);
@@ -527,6 +531,7 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
sequencer_add_apply_replace_sel(C, op, seq);
sequencer_add_apply_overlap(C, op, seq);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
@@ -641,6 +646,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
BKE_sequencer_sort(scene);
BKE_sequencer_update_muting(ed);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
@@ -715,7 +721,7 @@ static int sequencer_add_movie_strip_invoke(bContext *C,
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
- //return sequencer_add_movie_strip_exec(C, op);
+ // return sequencer_add_movie_strip_exec(C, op);
}
static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
@@ -797,7 +803,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C,
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
- //return sequencer_add_sound_strip_exec(C, op);
+ // return sequencer_add_sound_strip_exec(C, op);
}
void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
@@ -968,6 +974,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
MEM_freeN(op->customdata);
}
+ DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
@@ -1098,14 +1105,8 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
if (seq->type == SEQ_TYPE_COLOR) {
SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
RNA_float_get_array(op->ptr, "color", colvars->col);
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
- }
- else if (seq->type == SEQ_TYPE_ADJUSTMENT) {
- seq->blend_mode = SEQ_TYPE_CROSS;
- }
- else if (seq->type == SEQ_TYPE_TEXT) {
- seq->blend_mode = SEQ_TYPE_ALPHAOVER;
}
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
/* an unset channel is a special case where we automatically go above
* the other strips. */
@@ -1129,6 +1130,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
* it was NOT called in blender 2.4x, but wont hurt */
BKE_sequencer_sort(scene);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
@@ -1180,7 +1182,7 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot)
RNA_def_enum(ot->srna,
"type",
sequencer_prop_effect_types,
- SEQ_TYPE_CROSS,
+ SEQ_TYPE_ALPHAOVER,
"Type",
"Sequencer effect type");
RNA_def_float_vector(ot->srna,
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 550aa9d7f8d..72f186d4c1a 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -259,11 +259,6 @@ static void drawseqwave(View2D *v2d,
return;
}
- if (!sound->spinlock) {
- sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
- BLI_spin_init(sound->spinlock);
- }
-
BLI_spin_lock(sound->spinlock);
if (!sound->waveform) {
if (!(sound->tags & SOUND_TAGS_WAVEFORM_LOADING)) {
@@ -461,7 +456,7 @@ static void draw_seq_handle(View2D *v2d,
const short direction,
unsigned int pos)
{
- float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; //for triangles and rect
+ float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; // for triangles and rect
float x1, x2, y1, y2;
unsigned int whichsel = 0;
@@ -817,7 +812,7 @@ static void draw_seq_strip(const bContext *C,
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* get the correct color per strip type*/
- //color3ubv_from_seq(scene, seq, col);
+ // color3ubv_from_seq(scene, seq, col);
color3ubv_from_seq(scene, seq, background_col);
if (seq->flag & SEQ_MUTE) {
@@ -1812,6 +1807,181 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
GPU_blend(false);
}
+typedef struct CacheDrawData {
+ const bContext *C;
+ uint pos;
+ float stripe_offs;
+ float stripe_ht;
+} CacheDrawData;
+
+/* Called as a callback */
+static bool draw_cache_view_cb(
+ void *userdata, struct Sequence *seq, int cfra, int cache_type, float UNUSED(cost))
+{
+ CacheDrawData *drawdata = userdata;
+ const bContext *C = drawdata->C;
+ Scene *scene = CTX_data_scene(C);
+ ARegion *ar = CTX_wm_region(C);
+ struct View2D *v2d = &ar->v2d;
+ Editing *ed = scene->ed;
+ uint pos = drawdata->pos;
+
+ if ((ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) == 0) {
+ return true;
+ }
+
+ float stripe_bot, stripe_top, stripe_offs, stripe_ht;
+ float color[4];
+ color[3] = 0.4f;
+
+ switch (cache_type) {
+ case SEQ_CACHE_STORE_FINAL_OUT:
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) {
+ color[0] = 1.0f;
+ color[1] = 0.4f;
+ color[2] = 0.2f;
+ stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_DPI_FAC * U.pixelsize) -
+ v2d->cur.ymin;
+ stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HEIGHT_TEXT);
+ stripe_top = stripe_bot + stripe_ht;
+ break;
+ }
+ else {
+ return false;
+ }
+
+ case SEQ_CACHE_STORE_RAW:
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_RAW) {
+ color[0] = 1.0f;
+ color[1] = 0.1f;
+ color[2] = 0.02f;
+ stripe_offs = drawdata->stripe_offs;
+ stripe_ht = drawdata->stripe_ht;
+ stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + stripe_offs;
+ stripe_top = stripe_bot + stripe_ht;
+ break;
+ }
+ else {
+ return false;
+ }
+
+ case SEQ_CACHE_STORE_PREPROCESSED:
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED) {
+ color[0] = 0.1f;
+ color[1] = 0.1f;
+ color[2] = 0.75f;
+ stripe_offs = drawdata->stripe_offs;
+ stripe_ht = drawdata->stripe_ht;
+ stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + (stripe_offs + stripe_ht) + stripe_offs;
+ stripe_top = stripe_bot + stripe_ht;
+ break;
+ }
+ else {
+ return false;
+ }
+
+ case SEQ_CACHE_STORE_COMPOSITE:
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_COMPOSITE) {
+ color[0] = 1.0f;
+ color[1] = 0.6f;
+ color[2] = 0.0f;
+ stripe_offs = drawdata->stripe_offs;
+ stripe_ht = drawdata->stripe_ht;
+ stripe_top = seq->machine + SEQ_STRIP_OFSTOP - stripe_offs;
+ stripe_bot = stripe_top - stripe_ht;
+ break;
+ }
+ else {
+ return false;
+ }
+ }
+
+ immUniformColor4f(color[0], color[1], color[2], color[3]);
+ immRectf(pos, cfra, stripe_bot, cfra + 1, stripe_top);
+
+ return false;
+}
+
+static void draw_cache_view(const bContext *C)
+{
+ Scene *scene = CTX_data_scene(C);
+ ARegion *ar = CTX_wm_region(C);
+ struct View2D *v2d = &ar->v2d;
+
+ if ((scene->ed->cache_flag & SEQ_CACHE_VIEW_ENABLE) == 0) {
+ return;
+ }
+
+ GPU_blend(true);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+ float stripe_bot, stripe_top, stripe_offs;
+ float stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_DPI_FAC * U.pixelsize) -
+ v2d->cur.ymin;
+
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) {
+ stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HEIGHT_TEXT);
+ stripe_top = stripe_bot + stripe_ht;
+ float bg_color[4] = {1.0f, 0.4f, 0.2f, 0.1f};
+
+ immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]);
+ immRectf(pos, scene->r.sfra, stripe_bot, scene->r.efra, stripe_top);
+ }
+
+ for (Sequence *seq = scene->ed->seqbasep->first; seq != NULL; seq = seq->next) {
+ if (seq->type == SEQ_TYPE_SOUND_RAM) {
+ continue;
+ }
+
+ if (seq->startdisp > v2d->cur.xmax || seq->enddisp < v2d->cur.xmin) {
+ continue;
+ }
+
+ CLAMP_MAX(stripe_ht, 0.2f);
+ stripe_offs = UI_view2d_region_to_view_y(v2d, 1.0f) - v2d->cur.ymin;
+ CLAMP_MIN(stripe_offs, stripe_ht / 2);
+
+ stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + stripe_offs;
+ stripe_top = stripe_bot + stripe_ht;
+
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_RAW) {
+ float bg_color[4] = {1.0f, 0.1f, 0.02f, 0.1f};
+ immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]);
+ immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top);
+ }
+
+ stripe_bot += stripe_ht + stripe_offs;
+ stripe_top = stripe_bot + stripe_ht;
+
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED) {
+ float bg_color[4] = {0.1f, 0.1f, 0.75f, 0.1f};
+ immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]);
+ immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top);
+ }
+
+ stripe_top = seq->machine + SEQ_STRIP_OFSTOP - stripe_offs;
+ stripe_bot = stripe_top - stripe_ht;
+
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_COMPOSITE) {
+ float bg_color[4] = {1.0f, 0.6f, 0.0f, 0.1f};
+ immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]);
+ immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top);
+ }
+ }
+
+ CacheDrawData userdata;
+ userdata.C = C;
+ userdata.pos = pos;
+ userdata.stripe_offs = stripe_offs;
+ userdata.stripe_ht = stripe_ht;
+
+ BKE_sequencer_cache_iterate(scene, &userdata, draw_cache_view_cb);
+
+ immUnbindProgram();
+ GPU_blend(false);
+}
+
/* Draw Timeline/Strip Editor Mode for Sequencer */
void draw_timeline_seq(const bContext *C, ARegion *ar)
{
@@ -1820,7 +1990,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
SpaceSeq *sseq = CTX_wm_space_seq(C);
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
- short unit = 0, cfra_flag = 0;
+ short cfra_flag = 0;
float col[3];
/* clear and setup matrix */
@@ -1860,6 +2030,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
if (ed) {
/* draw the data */
draw_seq_strips(C, ed, ar);
+ draw_cache_view(C);
/* text draw cached (for sequence names), in pixelspace now */
UI_view2d_text_cache_draw(ar);
@@ -1910,12 +2081,15 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- unit = (sseq->flag & SEQ_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS;
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
+ /* scale numbers */
+ UI_view2d_draw_scale_x__discrete_frames_or_seconds(
+ ar, v2d, &v2d->hor, scene, !(sseq->flag & SEQ_DRAWFRAMES), TH_TEXT);
+ UI_view2d_draw_scale_y__block(ar, v2d, &v2d->vert, TH_TEXT);
+
/* draw current frame number-indicator on top of scrollers */
if ((sseq->flag & SEQ_NO_DRAW_CFRANUM) == 0) {
UI_view2d_view_orthoSpecial(ar, v2d, 1);
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 4a6cfaae42f..0f5c02327cc 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -64,6 +64,8 @@
#include "UI_view2d.h"
#include "UI_interface.h"
+#include "DEG_depsgraph.h"
+
/* own include */
#include "sequencer_intern.h"
@@ -2379,6 +2381,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
ms = ms->prev;
}
+ DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
@@ -3891,7 +3894,7 @@ void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot)
ot->prop = RNA_def_enum(ot->srna,
"type",
sequencer_prop_effect_types,
- SEQ_TYPE_CROSS,
+ SEQ_TYPE_ALPHAOVER,
"Type",
"Sequencer effect type");
}
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index 9244bbb3034..dd04260d80e 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -91,7 +91,7 @@ int seq_effect_find_selected(struct Scene *scene,
/* operator helpers */
bool sequencer_edit_poll(struct bContext *C);
/* UNUSED */
-//bool sequencer_strip_poll(struct bContext *C);
+// bool sequencer_strip_poll(struct bContext *C);
bool sequencer_strip_has_path_poll(struct bContext *C);
bool sequencer_view_preview_poll(struct bContext *C);
bool sequencer_view_strips_poll(struct bContext *C);
diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c
index 546c2a8a9f0..8a4e8c007f7 100644
--- a/source/blender/editors/space_sequencer/sequencer_preview.c
+++ b/source/blender/editors/space_sequencer/sequencer_preview.c
@@ -50,6 +50,7 @@ typedef struct PreviewJob {
typedef struct PreviewJobAudio {
struct PreviewJobAudio *next, *prev;
+ struct Main *bmain;
bSound *sound;
int lr; /* sample left or right */
int startframe;
@@ -79,7 +80,9 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p
PreviewJobAudio *preview_next;
bSound *sound = previewjb->sound;
+ BKE_sound_load_audio(previewjb->bmain, sound);
BKE_sound_read_waveform(sound, stop);
+ BKE_sound_free_audio(sound);
if (*stop || G.is_break) {
BLI_mutex_lock(pj->mutex);
@@ -153,6 +156,7 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq)
/* attempt to lock mutex of job here */
+ audiojob->bmain = CTX_data_main(C);
audiojob->sound = seq->sound;
BLI_mutex_lock(pj->mutex);
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 09cc4635254..f40514e7574 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -60,8 +60,8 @@ static void select_surrounding_handles(Scene *scene, Sequence *test) /* XXX BRIN
neighbor = find_neighboring_sequence(scene, test, SEQ_SIDE_LEFT, -1);
if (neighbor) {
- /* Only select neighbor handle if matching handle from test seq is also selected, or if neighbor
- * was not selected at all up till now.
+ /* Only select neighbor handle if matching handle from test seq is also selected,
+ * or if neighbor was not selected at all up till now.
* Otherwise, we get odd mismatch when shift-alt-rmb selecting neighbor strips... */
if (!(neighbor->flag & SELECT) || (test->flag & SEQ_LEFTSEL)) {
neighbor->flag |= SEQ_RIGHTSEL;
@@ -318,6 +318,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
const bool extend = RNA_boolean_get(op->ptr, "extend");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
const bool linked_handle = RNA_boolean_get(op->ptr, "linked_handle");
const bool linked_time = RNA_boolean_get(op->ptr, "linked_time");
int left_right = RNA_enum_get(op->ptr, "left_right");
@@ -330,7 +331,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
return OPERATOR_CANCELLED;
}
- marker = find_nearest_marker(SCE_MARKERS, 1); //XXX - dummy function for now
+ marker = find_nearest_marker(SCE_MARKERS, 1); // XXX - dummy function for now
seq = find_nearest_seq(scene, v2d, &hand, event->mval);
@@ -401,15 +402,13 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
}
}
else {
- // seq = find_nearest_seq(scene, v2d, &hand, mval);
-
act_orig = ed->act_seq;
- if (extend == 0 && linked_handle == 0) {
- ED_sequencer_deselect_all(scene);
- }
-
if (seq) {
+ if (!extend && !linked_handle) {
+ ED_sequencer_deselect_all(scene);
+ }
+
BKE_sequencer_active_set(scene, seq);
if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) {
@@ -427,8 +426,8 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
if (linked_handle) {
if (!ELEM(hand, SEQ_SIDE_LEFT, SEQ_SIDE_RIGHT)) {
/* First click selects the strip and its adjacent handles (if valid).
- * Second click selects the strip, both of its handles and its adjacent handles (if valid).
- */
+ * Second click selects the strip,
+ * both of its handles and its adjacent handles (if valid). */
const bool is_striponly_selected = ((seq->flag & SEQ_ALLSEL) == SELECT);
if (!extend) {
@@ -535,25 +534,10 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
select_linked_time(ed->seqbasep, seq);
}
}
- }
-
- /* marker transform */
-#if 0 // XXX probably need to redo this differently for 2.5
- if (marker) {
- int mval[2], xo, yo;
- // getmouseco_areawin(mval);
- xo = mval[0];
- yo = mval[1];
-
- while (get_mbut()) {
- // getmouseco_areawin(mval);
- if (abs(mval[0] - xo) + abs(mval[1] - yo) > 4) {
- transform_markers('g', 0);
- return;
- }
+ else if (deselect_all) {
+ ED_sequencer_deselect_all(scene);
}
}
-#endif
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
@@ -584,7 +568,14 @@ void SEQUENCER_OT_select(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
+ PropertyRNA *prop;
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
RNA_def_boolean(
ot->srna, "linked_handle", 0, "Linked Handle", "Select handles next to the active strip");
/* for animation this is an enum but atm having an enum isn't useful for us */
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 30aca84f4e0..2b0c29a02ad 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -468,15 +468,15 @@ static void sequencer_main_region_init(wmWindowManager *wm, ARegion *ar)
#if 0
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
#endif
keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Sequencer", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* add drop boxes */
lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW);
@@ -614,15 +614,15 @@ static void sequencer_preview_region_init(wmWindowManager *wm, ARegion *ar)
#if 0
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
#endif
keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "SequencerPreview", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void sequencer_preview_region_draw(const bContext *C, ARegion *ar)
@@ -695,8 +695,6 @@ static void sequencer_preview_region_listener(wmWindow *UNUSED(win),
case NC_ANIMATION:
switch (wmn->data) {
case ND_KEYFRAME:
- /* Otherwise, often prevents seeing immediately effects of keyframe editing... */
- BKE_sequencer_cache_cleanup();
ED_region_tag_redraw(ar);
break;
}
@@ -729,7 +727,7 @@ static void sequencer_buttons_region_init(wmWindowManager *wm, ARegion *ar)
wmKeyMap *keymap;
keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
ED_region_panels_init(wm, ar);
}
diff --git a/source/blender/editors/space_statusbar/CMakeLists.txt b/source/blender/editors/space_statusbar/CMakeLists.txt
index 39957c6792c..ad4c060a1f6 100644
--- a/source/blender/editors/space_statusbar/CMakeLists.txt
+++ b/source/blender/editors/space_statusbar/CMakeLists.txt
@@ -25,8 +25,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt
index f5db86ac4c2..740fc9948ef 100644
--- a/source/blender/editors/space_text/CMakeLists.txt
+++ b/source/blender/editors/space_text/CMakeLists.txt
@@ -25,8 +25,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 49d5ae06413..24f282ff920 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -273,9 +273,9 @@ static void text_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Text", SPACE_TEXT, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* add drop boxes */
lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
@@ -287,7 +287,7 @@ static void text_main_region_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceText *st = CTX_wm_space_text(C);
- //View2D *v2d = &ar->v2d;
+ // View2D *v2d = &ar->v2d;
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -394,7 +394,7 @@ static void text_properties_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void text_properties_region_draw(const bContext *C, ARegion *ar)
diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c
index 243642b2e8c..c36175489b3 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -74,7 +74,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar)
/* Count the visible lines to the cursor */
for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++) {
- ;
+ /* pass */
}
if (l < 0) {
return 0;
@@ -101,7 +101,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar)
/* Work out which of the items is at the top of the visible list */
for (i = 0, item = first; i < *top && item->next; i++, item = item->next) {
- ;
+ /* pass */
}
/* Work out the target item index in the visible list */
@@ -111,7 +111,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar)
}
for (i = tgti; i > 0 && item->next; i--, item = item->next) {
- ;
+ /* pass */
}
if (item) {
texttool_suggest_select(item);
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index cdd691fe879..678879018a7 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -1186,7 +1186,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
/* Set the top 'item' of the visible list */
for (i = 0, item = first; i < *top && item->next; i++, item = item->next) {
- ;
+ /* pass */
}
for (i = 0; i < SUGG_LIST_SIZE && item; i++, item = item->next) {
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 4d904822360..d0809ec33fc 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -61,6 +61,83 @@
static void txt_screen_clamp(SpaceText *st, ARegion *ar);
+/************************ util ***************************/
+
+/**
+ * Tests if the given character represents a start of a new line or the
+ * indentation part of a line.
+ * \param c: The current character.
+ * \param r_last_state: A pointer to a flag representing the last state. The
+ * flag may be modified.
+ */
+static void test_line_start(char c, bool *r_last_state)
+{
+ if (c == '\n') {
+ *r_last_state = true;
+ }
+ else if (!ELEM(c, '\t', ' ')) {
+ *r_last_state = false;
+ }
+}
+
+/**
+ * This function converts the indentation tabs from a buffer to spaces.
+ * \param buf: A pointer to a cstring.
+ * \param tab_size: The size, in spaces, of the tab character.
+ */
+static char *buf_tabs_to_spaces(const char *in_buf, const int tab_size)
+{
+ /* Get the number of tab characters in buffer. */
+ bool line_start = true;
+ int num_tabs = 0;
+
+ for (int in_offset = 0; in_buf[in_offset]; in_offset++) {
+ /* Verify if is an indentation whitespace character. */
+ test_line_start(in_buf[in_offset], &line_start);
+
+ if (in_buf[in_offset] == '\t' && line_start) {
+ num_tabs++;
+ }
+ }
+
+ /* Allocate output before with extra space for expanded tabs. */
+ const int out_size = strlen(in_buf) + num_tabs * (tab_size - 1);
+ char *out_buf = MEM_mallocN(out_size * sizeof(char), __func__);
+
+ /* Fill output buffer. */
+ int spaces_until_tab = 0;
+ int out_offset = 0;
+ line_start = true;
+
+ for (int in_offset = 0; in_buf[in_offset]; in_offset++) {
+ /* Verify if is an indentation whitespace character. */
+ test_line_start(in_buf[in_offset], &line_start);
+
+ if (in_buf[in_offset] == '\t' && line_start) {
+ /* Calculate tab size so it fills until next indentation. */
+ int num_spaces = tab_size - (spaces_until_tab % tab_size);
+ spaces_until_tab = 0;
+
+ /* Write to buffer. */
+ memset(&out_buf[out_offset], ' ', num_spaces);
+ out_offset += num_spaces;
+ }
+ else {
+ if (in_buf[in_offset] == ' ') {
+ spaces_until_tab++;
+ }
+ else if (in_buf[in_offset] == '\n') {
+ spaces_until_tab = 0;
+ }
+
+ out_buf[out_offset++] = in_buf[in_offset];
+ }
+ }
+
+ out_buf[out_offset] = '\0';
+ return out_buf;
+}
+
/************************ poll ***************************/
BLI_INLINE int text_pixel_x_to_column(SpaceText *st, const int x)
@@ -308,7 +385,7 @@ void TEXT_OT_open(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA); //XXX TODO, relative_path
+ FILE_SORT_ALPHA); // XXX TODO, relative_path
RNA_def_boolean(
ot->srna, "internal", 0, "Make internal", "Make text file internal after loading");
}
@@ -608,7 +685,7 @@ void TEXT_OT_save_as(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA); //XXX TODO, relative_path
+ FILE_SORT_ALPHA); // XXX TODO, relative_path
}
/******************* run script operator *********************/
@@ -764,6 +841,14 @@ static int text_paste_exec(bContext *C, wmOperator *op)
text_drawcache_tag_update(CTX_wm_space_text(C), 0);
TextUndoBuf *utxt = ED_text_undo_push_init(C);
+
+ /* Convert clipboard content indentation to spaces if specified */
+ if (text->flags & TXT_TABSTOSPACES) {
+ char *new_buf = buf_tabs_to_spaces(buf, TXT_TABSIZE);
+ MEM_freeN(buf);
+ buf = new_buf;
+ }
+
txt_insert_buf(text, utxt, buf);
text_update_edited(text);
@@ -1183,7 +1268,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
for (j = 1;
(j < tab_len) && (a + j < text_check_line_len) && (text_check_line[a + j] == ' ');
j++) {
- ;
+ /* pass */
}
if (j == tab_len) {
diff --git a/source/blender/editors/space_topbar/CMakeLists.txt b/source/blender/editors/space_topbar/CMakeLists.txt
index 71e61a07ff7..d56e1da334d 100644
--- a/source/blender/editors/space_topbar/CMakeLists.txt
+++ b/source/blender/editors/space_topbar/CMakeLists.txt
@@ -25,8 +25,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index 1514f7a236b..dc375958eb4 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -28,10 +28,10 @@ set(INC
../../makesdna
../../makesrna
../../render/extern/include
- ../../windowmanager
../../depsgraph
- ../../../../intern/guardedalloc
+ ../../windowmanager
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
../../../../intern/smoke/extern
)
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 42dd3dec538..dbf2160d39b 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -303,6 +303,7 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
BLI_addtail(&v3d->regionbase, ar);
ar->regiontype = RGN_TYPE_TOOL_HEADER;
ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
+ ar->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for view3d");
@@ -1510,6 +1511,7 @@ void ED_spacetype_view3d(void)
art->prefsizex = 180; /* XXX */
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
art->listener = view3d_buttons_region_listener;
+ art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_ui;
art->init = view3d_buttons_region_init;
art->draw = view3d_buttons_region_draw;
BLI_addhead(&st->regiontypes, art);
@@ -1535,9 +1537,9 @@ void ED_spacetype_view3d(void)
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
art->listener = view3d_header_region_listener;
+ art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_header;
art->init = view3d_header_region_init;
art->draw = view3d_header_region_draw;
- art->message_subscribe = view3d_header_region_message_subscribe;
BLI_addhead(&st->regiontypes, art);
/* regions: header */
@@ -1546,9 +1548,9 @@ void ED_spacetype_view3d(void)
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
art->listener = view3d_header_region_listener;
+ art->message_subscribe = view3d_header_region_message_subscribe;
art->init = view3d_header_region_init;
art->draw = view3d_header_region_draw;
- art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_header;
BLI_addhead(&st->regiontypes, art);
/* regions: hud */
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index 52feff4b65a..3d3c73ad27c 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -1066,7 +1066,7 @@ static void v3d_object_dimension_buts(bContext *C, uiLayout *layout, View3D *v3d
0,
"");
UI_block_align_begin(block);
- const float lim = 10000;
+ const float lim = FLT_MAX;
for (int i = 0; i < 3; i++) {
uiBut *but;
char text[3] = {'X' + i, ':', '\0'};
@@ -1605,7 +1605,7 @@ void view3d_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel object");
strcpy(pt->idname, "VIEW3D_PT_transform");
strcpy(pt->label, N_("Transform")); /* XXX C panels unavailable through RNA bpy.types! */
- strcpy(pt->category, "View");
+ strcpy(pt->category, "Item");
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw = view3d_panel_transform;
pt->poll = view3d_panel_transform_poll;
@@ -1614,7 +1614,7 @@ void view3d_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel vgroup");
strcpy(pt->idname, "VIEW3D_PT_vgroup");
strcpy(pt->label, N_("Vertex Weights")); /* XXX C panels unavailable through RNA bpy.types! */
- strcpy(pt->category, "View");
+ strcpy(pt->category, "Item");
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw = view3d_panel_vgroup;
pt->poll = view3d_panel_vgroup_poll;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 12ce793e3ef..8c5f1c16438 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -758,7 +758,6 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a
short flag = v3d->flag;
float glalphaclip = U.glalphaclip;
- int obcenter_dia = U.obcenter_dia;
/* temp set drawtype to solid */
/* Setting these temporarily is not nice */
v3d->flag &= ~V3D_SELECT_OUTLINE;
@@ -766,8 +765,6 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a
/* not that nice but means we wont zoom into billboards */
U.glalphaclip = alphaoverride ? 0.5f : glalphaclip;
- U.obcenter_dia = 0;
-
/* Tools may request depth outside of regular drawing code. */
UI_Theme_Store(&theme_state);
UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW);
@@ -797,7 +794,6 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a
U.glalphaclip = glalphaclip;
v3d->flag = flag;
- U.obcenter_dia = obcenter_dia;
UI_Theme_Restore(&theme_state);
}
@@ -1824,6 +1820,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph,
*/
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph,
Scene *scene,
+ View3DShading *shading_override,
int drawtype,
Object *camera,
int width,
@@ -1846,22 +1843,25 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph,
ar.regiontype = RGN_TYPE_WINDOW;
v3d.camera = camera;
+ View3DShading *source_shading_settings = &scene->display.shading;
+ if (draw_flags & V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS && shading_override != NULL) {
+ source_shading_settings = shading_override;
+ }
+ memcpy(&v3d.shading, source_shading_settings, sizeof(View3DShading));
v3d.shading.type = drawtype;
+
+ if (drawtype == OB_MATERIAL) {
+ v3d.shading.flag = V3D_SHADING_SCENE_WORLD | V3D_SHADING_SCENE_LIGHTS;
+ }
+
v3d.flag2 = V3D_HIDE_OVERLAYS;
- if (draw_flags & V3D_OFSDRAW_USE_GPENCIL) {
+ if (draw_flags & V3D_OFSDRAW_SHOW_ANNOTATION) {
v3d.flag2 |= V3D_SHOW_ANNOTATION;
}
v3d.shading.background_type = V3D_SHADING_BACKGROUND_WORLD;
- if (draw_flags & V3D_OFSDRAW_USE_CAMERA_DOF) {
- if (camera->type == OB_CAMERA) {
- v3d.fx_settings.dof = &((Camera *)camera->data)->gpu_dof;
- v3d.fx_settings.fx_flag |= GPU_FX_FLAG_DOF;
- }
- }
-
rv3d.persp = RV3D_CAMOB;
copy_m4_m4(rv3d.viewinv, v3d.camera->obmat);
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index f029fd9bfc7..b0cee18f8e3 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -347,7 +347,7 @@ uint ED_view3d_select_id_read_nearest(struct ViewContext *UNUSED(vc),
uint *r_dist)
{
/* Create region around mouse cursor. This must be square and have an odd
- * width, the spiralling algorithm does not work with arbitrary rectangles. */
+ * width, the spiraling algorithm does not work with arbitrary rectangles. */
rcti rect;
BLI_rcti_init_pt_radius(&rect, mval, *r_dist);
rect.xmax += 1;
@@ -995,8 +995,8 @@ void ED_scene_draw_fps(Scene *scene, int xoffset, int *yoffset)
if (tot) {
fpsi->redrawtime_index = (fpsi->redrawtime_index + 1) % REDRAW_FRAME_AVERAGE;
- //fpsi->redrawtime_index++;
- //if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE) {
+ // fpsi->redrawtime_index++;
+ // if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE) {
// fpsi->redrawtime = 0;
//}
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
index f98a87e84a8..5af6fd8b04b 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
@@ -259,8 +259,7 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g
navgroup->state.rv3d.is_camera = (rv3d->persp == RV3D_CAMOB);
navgroup->state.rv3d.viewlock = rv3d->viewlock;
- const bool show_rotate = (((rv3d->viewlock & RV3D_LOCKED) == 0) &&
- (navgroup->state.rv3d.is_camera == false));
+ const bool show_rotate = (rv3d->viewlock & RV3D_LOCKED) == 0;
const bool show_fixed_offset = navgroup->state.rv3d.is_camera;
const float icon_size = GIZMO_SIZE;
const float icon_offset = (icon_size * 0.52f) * GIZMO_OFFSET_FAC * UI_DPI_FAC;
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 443c7ab9368..2ce23486476 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -1911,8 +1911,7 @@ static bool ed_object_select_pick(bContext *C,
}
}
- basact->flag |= BASE_SELECTED;
- BKE_scene_object_base_flag_sync_from_base(basact);
+ ED_object_base_select(basact, BA_SELECT);
retval = true;
@@ -1945,8 +1944,7 @@ static bool ed_object_select_pick(bContext *C,
/* we make the armature selected:
* not-selected active object in posemode won't work well for tools */
- basact->flag |= BASE_SELECTED;
- BKE_scene_object_base_flag_sync_from_base(basact);
+ ED_object_base_select(basact, BA_SELECT);
retval = true;
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, basact->object);
@@ -2213,7 +2211,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
}
}
- /* passthrough allows tweaks
+ /* Pass-through allows tweaks
* FINISHED to signal one operator worked
* */
if (retval) {
@@ -2251,9 +2249,6 @@ void VIEW3D_OT_select(wmOperatorType *ot)
/* properties */
WM_operator_properties_mouse_select(ot);
- prop = RNA_def_boolean(
- ot->srna, "deselect_all", 0, "Deselect", "Deselect all when nothing under the cursor");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(
ot->srna,
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 7ac8291a385..2454358b687 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -146,7 +146,7 @@ void ED_view3d_smooth_view_ex(
}
sms.org_view = rv3d->view;
- /* sms.to_camera = false; */ /* initizlized to zero anyway */
+ /* sms.to_camera = false; */ /* initialized to zero anyway */
/* note on camera locking, this is a little confusing but works ok.
* we may be changing the view 'as if' there is no active camera, but in fact
diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt
index 05e0659637b..9696f0fb315 100644
--- a/source/blender/editors/transform/CMakeLists.txt
+++ b/source/blender/editors/transform/CMakeLists.txt
@@ -27,10 +27,10 @@ set(INC
../../makesdna
../../makesrna
../../render/extern/include
- ../../windowmanager
../../depsgraph
- ../../../../intern/guardedalloc
+ ../../windowmanager
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index c80a0eaa597..81405b55ac2 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -601,18 +601,18 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
}
}
else if (t->spacetype == SPACE_ACTION) {
- //SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
+ // SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_GRAPH) {
- //SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
+ // SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_NLA) {
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_NODE) {
- //ED_area_tag_redraw(t->sa);
+ // ED_area_tag_redraw(t->sa);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
}
else if (t->spacetype == SPACE_SEQ) {
@@ -2101,20 +2101,16 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
}
- /* convert flag to enum */
- switch (t->flag & T_PROP_EDIT_ALL) {
- case T_PROP_EDIT:
- proportional = PROP_EDIT_ON;
- break;
- case (T_PROP_EDIT | T_PROP_CONNECTED):
- proportional = PROP_EDIT_CONNECTED;
- break;
- case (T_PROP_EDIT | T_PROP_PROJECTED):
- proportional = PROP_EDIT_PROJECTED;
- break;
- default:
- proportional = PROP_EDIT_OFF;
- break;
+ if (t->flag & T_PROP_EDIT_ALL) {
+ if (t->flag & T_PROP_EDIT) {
+ proportional |= PROP_EDIT_USE;
+ }
+ if (t->flag & T_PROP_CONNECTED) {
+ proportional |= PROP_EDIT_CONNECTED;
+ }
+ if (t->flag & T_PROP_PROJECTED) {
+ proportional |= PROP_EDIT_PROJECTED;
+ }
}
// If modal, save settings back in scene if not set as operator argument
@@ -2123,7 +2119,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
/* skip saving proportional edit if it was not actually used */
if (!(t->options & CTX_NO_PET)) {
- if ((prop = RNA_struct_find_property(op->ptr, "proportional")) &&
+ if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit")) &&
!RNA_property_is_set(op->ptr, prop)) {
if (t->spacetype == SPACE_GRAPH) {
ts->proportional_fcurve = proportional;
@@ -2132,13 +2128,13 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
ts->proportional_action = proportional;
}
else if (t->obedit_type != -1) {
- ts->proportional = proportional;
+ ts->proportional_edit = proportional;
}
else if (t->options & CTX_MASK) {
- ts->proportional_mask = (proportional != PROP_EDIT_OFF);
+ ts->proportional_mask = proportional != 0;
}
else {
- ts->proportional_objects = (proportional != PROP_EDIT_OFF);
+ ts->proportional_objects = proportional != 0;
}
}
@@ -2177,8 +2173,10 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
}
- if ((prop = RNA_struct_find_property(op->ptr, "proportional"))) {
- RNA_property_enum_set(op->ptr, prop, proportional);
+ if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
+ RNA_property_boolean_set(op->ptr, prop, proportional & PROP_EDIT_USE);
+ RNA_boolean_set(op->ptr, "use_proportional_connected", proportional & PROP_EDIT_CONNECTED);
+ RNA_boolean_set(op->ptr, "use_proportional_projected", proportional & PROP_EDIT_PROJECTED);
RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode);
RNA_float_set(op->ptr, "proportional_size", t->prop_size);
}
@@ -3293,7 +3291,7 @@ static void initBend(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
- //copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view));
+ // copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view));
if ((t->flag & T_OVERRIDE_CENTER) == 0) {
calculateCenterCursor(t, t->center_global);
}
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index e4f2adff77d..6c1da5ae825 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -500,7 +500,7 @@ static void createTransEdge(TransInfo *t)
BM_mesh_cd_flag_ensure(em->bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_EDGE_BWEIGHT);
cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_BWEIGHT);
}
- else { //if (t->mode == TFM_CREASE) {
+ else { // if (t->mode == TFM_CREASE) {
BLI_assert(t->mode == TFM_CREASE);
BM_mesh_cd_flag_ensure(em->bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_EDGE_CREASE);
cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_CREASE);
@@ -611,38 +611,19 @@ static short apply_targetless_ik(Object *ob)
/* apply and decompose, doesn't work for constraints or non-uniform scale well */
{
float rmat3[3][3], qrmat[3][3], imat3[3][3], smat[3][3];
-
copy_m3_m4(rmat3, rmat);
/* rotation */
/* [#22409] is partially caused by this, as slight numeric error introduced during
* the solving process leads to locked-axis values changing. However, we cannot modify
* the values here, or else there are huge discrepancies between IK-solver (interactive)
- * and applied poses.
- */
- if (parchan->rotmode > 0) {
- mat3_to_eulO(parchan->eul, parchan->rotmode, rmat3);
- }
- else if (parchan->rotmode == ROT_MODE_AXISANGLE) {
- mat3_to_axis_angle(parchan->rotAxis, &parchan->rotAngle, rmat3);
- }
- else {
- mat3_to_quat(parchan->quat, rmat3);
- }
+ * and applied poses. */
+ BKE_pchan_mat3_to_rot(parchan, rmat3, false);
/* for size, remove rotation */
/* causes problems with some constraints (so apply only if needed) */
if (data->flag & CONSTRAINT_IK_STRETCH) {
- if (parchan->rotmode > 0) {
- eulO_to_mat3(qrmat, parchan->eul, parchan->rotmode);
- }
- else if (parchan->rotmode == ROT_MODE_AXISANGLE) {
- axis_angle_to_mat3(qrmat, parchan->rotAxis, parchan->rotAngle);
- }
- else {
- quat_to_mat3(qrmat, parchan->quat);
- }
-
+ BKE_pchan_rot_to_mat3(parchan, qrmat);
invert_m3_m3(imat3, qrmat);
mul_m3_m3m3(smat, rmat3, imat3);
mat3_to_size(parchan->size, smat);
@@ -1325,10 +1306,18 @@ static void createTransPose(TransInfo *t)
void restoreBones(TransDataContainer *tc)
{
- bArmature *arm = tc->obedit->data;
+ bArmature *arm;
BoneInitData *bid = tc->custom.type.data;
EditBone *ebo;
+ if (tc->obedit) {
+ arm = tc->obedit->data;
+ }
+ else {
+ BLI_assert(tc->poseobj != NULL);
+ arm = tc->poseobj->data;
+ }
+
while (bid->bone) {
ebo = bid->bone;
@@ -2764,9 +2753,9 @@ static void VertsToTransData(TransInfo *t,
BLI_assert(BM_elem_flag_test(eve, BM_ELEM_HIDDEN) == 0);
td->flag = 0;
- //if (key)
+ // if (key)
// td->loc = key->co;
- //else
+ // else
td->loc = eve->co;
copy_v3_v3(td->iloc, td->loc);
@@ -3052,7 +3041,7 @@ static void createTransEditVerts(TransInfo *t)
/* Mirror? */
if ((mirror > 0 && tob->iloc[0] > 0.0f) || (mirror < 0 && tob->iloc[0] < 0.0f)) {
- BMVert *vmir = EDBM_verts_mirror_get(em, eve); //t->obedit, em, eve, tob->iloc, a);
+ BMVert *vmir = EDBM_verts_mirror_get(em, eve); // t->obedit, em, eve, tob->iloc, a);
if (vmir && vmir != eve) {
tob->extra = vmir;
}
@@ -6471,7 +6460,7 @@ static void clear_trans_object_base_flags(TransInfo *t)
for (base = view_layer->object_bases.first; base; base = base->next) {
if (base->flag_legacy & BA_WAS_SEL) {
- base->flag |= BASE_SELECTED;
+ ED_object_base_select(base, BA_SELECT);
}
base->flag_legacy &= ~(BA_WAS_SEL | BA_SNAP_FIX_DEPS_FIASCO | BA_TEMP_TAG |
@@ -6851,7 +6840,7 @@ static void special_aftertrans_update__mask(bContext *C, TransInfo *t)
if (t->scene->nodetree) {
/* tracks can be used for stabilization nodes,
* flush update for such nodes */
- //if (nodeUpdateID(t->scene->nodetree, &mask->id))
+ // if (nodeUpdateID(t->scene->nodetree, &mask->id))
{
WM_event_add_notifier(C, NC_MASK | ND_DATA, &mask->id);
}
@@ -7740,7 +7729,7 @@ static void markerToTransDataInit(TransData *td,
td->loc = td2d->loc;
copy_v3_v3(td->iloc, td->loc);
- //copy_v3_v3(td->center, td->loc);
+ // copy_v3_v3(td->center, td->loc);
td->flag |= TD_INDIVIDUAL_SCALE;
td->center[0] = marker->pos[0] * aspect[0];
td->center[1] = marker->pos[1] * aspect[1];
@@ -9334,7 +9323,7 @@ void createTransData(bContext *C, TransInfo *t)
if (t->data_len_all && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
/* don't do that, distance has been set in createTransActionData already */
- //set_prop_dist(t, false);
+ // set_prop_dist(t, false);
sort_trans_data_dist(t);
}
}
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index e816f4b31ff..a840c04ab5a 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -968,6 +968,23 @@ static void recalcData_objects(TransInfo *t)
}
}
}
+ else if (t->flag & T_POSE && (t->mode == TFM_BONESIZE)) {
+ /* Handle the exception where for TFM_BONESIZE in edit mode we pretend to be
+ * in pose mode (to use bone orientation matrix),
+ * in that case we have to do mirroring as well. */
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ Object *ob = tc->poseobj;
+ bArmature *arm = ob->data;
+ if (arm->flag & ARM_MIRROR_EDIT) {
+ if (t->state != TRANS_CANCEL) {
+ ED_armature_edit_transform_mirror_update(ob);
+ }
+ else {
+ restoreBones(tc);
+ }
+ }
+ }
+ }
else if (t->flag & T_POSE) {
GSet *motionpath_updates = BLI_gset_ptr_new("motionpath updates");
@@ -1094,18 +1111,17 @@ static void recalcData_sequencer(TransInfo *t)
if (seq != seq_prev) {
if (BKE_sequence_tx_fullupdate_test(seq)) {
- /* A few effect strip types need a complete recache on transform. */
BKE_sequence_invalidate_cache(t->scene, seq);
}
else {
- BKE_sequence_invalidate_dependent(t->scene, seq);
+ BKE_sequence_invalidate_cache(t->scene, seq);
}
}
seq_prev = seq;
}
- BKE_sequencer_preprocessed_cache_cleanup();
+ DEG_id_tag_update(&t->scene->id, ID_RECALC_SEQUENCER);
flushTransSeq(t);
}
@@ -1225,16 +1241,17 @@ void resetTransRestrictions(TransInfo *t)
static int initTransInfo_edit_pet_to_flag(const int proportional)
{
- switch (proportional) {
- case PROP_EDIT_ON:
- return T_PROP_EDIT;
- case PROP_EDIT_CONNECTED:
- return T_PROP_EDIT | T_PROP_CONNECTED;
- case PROP_EDIT_PROJECTED:
- return T_PROP_EDIT | T_PROP_PROJECTED;
- default:
- return 0;
+ int flag = 0;
+ if (proportional & PROP_EDIT_USE) {
+ flag |= T_PROP_EDIT;
+ }
+ if (proportional & PROP_EDIT_CONNECTED) {
+ flag |= T_PROP_CONNECTED;
+ }
+ if (proportional & PROP_EDIT_PROJECTED) {
+ flag |= T_PROP_PROJECTED;
}
+ return flag;
}
void initTransDataContainers_FromObjectData(TransInfo *t,
@@ -1637,9 +1654,19 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
/* setting PET flag only if property exist in operator. Otherwise, assume it's not supported */
- if (op && (prop = RNA_struct_find_property(op->ptr, "proportional"))) {
+ if (op && (prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
if (RNA_property_is_set(op->ptr, prop)) {
- t->flag |= initTransInfo_edit_pet_to_flag(RNA_property_enum_get(op->ptr, prop));
+ int proportional = 0;
+ if (RNA_property_boolean_get(op->ptr, prop)) {
+ proportional |= PROP_EDIT_USE;
+ if (RNA_boolean_get(op->ptr, "use_proportional_connected")) {
+ proportional |= PROP_EDIT_CONNECTED;
+ }
+ if (RNA_boolean_get(op->ptr, "use_proportional_projected")) {
+ proportional |= PROP_EDIT_PROJECTED;
+ }
+ }
+ t->flag |= initTransInfo_edit_pet_to_flag(proportional);
}
else {
/* use settings from scene only if modal */
@@ -1652,16 +1679,16 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_action);
}
else if (t->obedit_type != -1) {
- t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional);
+ t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_edit);
}
else if (t->options & CTX_GPENCIL_STROKES) {
- t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional);
+ t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_edit);
}
else if (t->options & CTX_MASK) {
if (ts->proportional_mask) {
t->flag |= T_PROP_EDIT;
- if (ts->proportional == PROP_EDIT_CONNECTED) {
+ if (ts->proportional_edit & PROP_EDIT_CONNECTED) {
t->flag |= T_PROP_CONNECTED;
}
}
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index b4c539fba8e..8606cd19c96 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -547,10 +547,9 @@ static bool transform_poll_property(const bContext *UNUSED(C),
/* Proportional Editing. */
{
- PropertyRNA *prop_pet = RNA_struct_find_property(op->ptr, "proportional");
- if (prop_pet && (prop_pet != prop) &&
- (RNA_property_enum_get(op->ptr, prop_pet) == PROP_EDIT_OFF)) {
- if (STRPREFIX(prop_id, "proportional")) {
+ PropertyRNA *prop_pet = RNA_struct_find_property(op->ptr, "use_proportional_edit");
+ if (prop_pet && (prop_pet != prop) && (RNA_property_boolean_get(op->ptr, prop_pet) == false)) {
+ if (STRPREFIX(prop_id, "proportional") || STRPREFIX(prop_id, "use_proportional")) {
return false;
}
}
@@ -610,12 +609,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
}
if (flags & P_PROPORTIONAL) {
- RNA_def_enum(ot->srna,
- "proportional",
- rna_enum_proportional_editing_items,
- 0,
- "Proportional Editing",
- "");
+ RNA_def_boolean(ot->srna, "use_proportional_edit", 0, "Proportional Editing", "");
prop = RNA_def_enum(ot->srna,
"proportional_edit_falloff",
rna_enum_proportional_falloff_items,
@@ -633,6 +627,9 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
"",
0.001f,
100.0f);
+
+ RNA_def_boolean(ot->srna, "use_proportional_connected", 0, "Connected", "");
+ RNA_def_boolean(ot->srna, "use_proportional_projected", 0, "Projected (2D)", "");
}
if (flags & P_SNAP) {
@@ -977,7 +974,7 @@ static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "To Sphere";
- //added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()"
+ // added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()"
ot->description = "Move selected vertices outward in a spherical shape around mesh center";
ot->idname = OP_TOSPHERE;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
@@ -1163,7 +1160,7 @@ static void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot)
static void TRANSFORM_OT_rotate_normal(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Normal Rotate";
+ ot->name = "Rotate Normals";
ot->description = "Rotate split normal of selected items";
ot->idname = OP_NORMAL_ROTATION;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index e8bd8e905c9..58a50da9846 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -360,7 +360,7 @@ void applyProject(TransInfo *t)
}
}
- //XXX constraintTransLim(t, td);
+ // XXX constraintTransLim(t, td);
}
}
}
@@ -1563,24 +1563,11 @@ static void applyGridIncrement(
/* custom aspect for fcurve */
if (t->spacetype == SPACE_GRAPH) {
View2D *v2d = &t->ar->v2d;
- View2DGrid *grid;
+ Scene *scene = t->scene;
SpaceGraph *sipo = t->sa->spacedata.first;
- int unity = V2D_UNIT_VALUES;
- int unitx = (sipo->flag & SIPO_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE;
-
- /* grid */
- grid = UI_view2d_grid_calc(t->scene,
- v2d,
- unitx,
- V2D_GRID_NOCLAMP,
- unity,
- V2D_GRID_NOCLAMP,
- t->ar->winx,
- t->ar->winy);
-
- UI_view2d_grid_size(grid, &asp_local[0], &asp_local[1]);
- UI_view2d_grid_free(grid);
-
+ asp_local[0] = UI_view2d_grid_resolution_x__frames_or_seconds(
+ v2d, scene, sipo->flag & SIPO_DRAWTIME);
+ asp_local[1] = UI_view2d_grid_resolution_y__values(v2d);
asp = asp_local;
}
}
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 9174f6950ae..829365367ee 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -953,7 +953,7 @@ static void cb_mlooptri_edges_get(const int index, int v_index[3], const BVHTree
const MEdge *ed = &medge[mloop[lt->tri[j]].e];
unsigned int tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v};
if (ELEM(ed->v1, tri_edge[0], tri_edge[1]) && ELEM(ed->v2, tri_edge[0], tri_edge[1])) {
- //printf("real edge found\n");
+ // printf("real edge found\n");
v_index[j] = mloop[lt->tri[j]].e;
}
else {
diff --git a/source/blender/editors/undo/CMakeLists.txt b/source/blender/editors/undo/CMakeLists.txt
index 7c1a074bb13..0f4152c9128 100644
--- a/source/blender/editors/undo/CMakeLists.txt
+++ b/source/blender/editors/undo/CMakeLists.txt
@@ -24,8 +24,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/clog
+ ../../../../intern/guardedalloc
)
set(SRC
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt
index a1893d8e6f1..3b49784d5eb 100644
--- a/source/blender/editors/util/CMakeLists.txt
+++ b/source/blender/editors/util/CMakeLists.txt
@@ -22,14 +22,14 @@ set(INC
../../blentranslation
../../bmesh
../../depsgraph
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/clog
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 867271229e2..df1906ea8a8 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -330,7 +330,7 @@ void unpack_menu(bContext *C,
break;
case PF_EQUAL:
BLI_snprintf(line, sizeof(line), IFACE_("Use %s (identical)"), local_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name);
@@ -338,13 +338,13 @@ void unpack_menu(bContext *C,
break;
case PF_DIFFERS:
BLI_snprintf(line, sizeof(line), IFACE_("Use %s (differs)"), local_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name);
BLI_snprintf(line, sizeof(line), IFACE_("Overwrite %s"), local_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name);
@@ -356,27 +356,27 @@ void unpack_menu(bContext *C,
switch (checkPackedFile(BKE_main_blendfile_path(bmain), abs_name, pf)) {
case PF_NOFILE:
BLI_snprintf(line, sizeof(line), IFACE_("Create %s"), abs_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
case PF_EQUAL:
BLI_snprintf(line, sizeof(line), IFACE_("Use %s (identical)"), abs_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
case PF_DIFFERS:
BLI_snprintf(line, sizeof(line), IFACE_("Use %s (differs)"), abs_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
BLI_snprintf(line, sizeof(line), IFACE_("Overwrite %s"), abs_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt
index 240cfd382a4..d2ba9ab9591 100644
--- a/source/blender/editors/uvedit/CMakeLists.txt
+++ b/source/blender/editors/uvedit/CMakeLists.txt
@@ -26,9 +26,9 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/eigen
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c
index 3983cce6769..1482fea456d 100644
--- a/source/blender/editors/uvedit/uvedit_buttons.c
+++ b/source/blender/editors/uvedit/uvedit_buttons.c
@@ -258,6 +258,8 @@ void ED_uvedit_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype image panel uv");
strcpy(pt->idname, "IMAGE_PT_uv");
strcpy(pt->label, N_("UV Vertex")); /* XXX C panels unavailable through RNA bpy.types! */
+ /* Could be 'Item' matching 3D view, avoid new tab for two buttons. */
+ strcpy(pt->category, "Image");
pt->draw = image_panel_uv;
pt->poll = image_panel_uv_poll;
BLI_addtail(&art->paneltypes, pt);
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 4fb2c6441a3..804b9c22104 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -479,14 +479,12 @@ static void draw_uv_shadows_get(
}
void ED_uvedit_draw_main(SpaceImage *sima,
- ARegion *ar,
Scene *scene,
ViewLayer *view_layer,
Object *obedit,
Object *obact,
Depsgraph *depsgraph)
{
- ToolSettings *toolsettings = scene->toolsettings;
bool show_uvedit, show_uvshadow, show_texpaint_uvshadow;
show_uvedit = ED_space_image_show_uvedit(sima, obedit);
@@ -509,9 +507,5 @@ void ED_uvedit_draw_main(SpaceImage *sima,
else {
draw_uvs_texpaint(scene, obact, depsgraph);
}
-
- if (show_uvedit && !(toolsettings->use_uv_sculpt)) {
- ED_image_draw_cursor(ar, sima->cursor);
- }
}
}
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 16a4b647cfe..30ded60bd84 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -128,15 +128,6 @@ bool ED_uvedit_test(Object *obedit)
return ret;
}
-static bool ED_operator_uvedit_can_uv_sculpt(struct bContext *C)
-{
- SpaceImage *sima = CTX_wm_space_image(C);
- ToolSettings *toolsettings = CTX_data_tool_settings(C);
- Object *obedit = CTX_data_edit_object(C);
-
- return ED_space_image_show_uvedit(sima, obedit) && !(toolsettings->use_uv_sculpt);
-}
-
static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C)
{
Object *ob = CTX_data_active_object(C);
@@ -2212,7 +2203,7 @@ static int uv_remove_doubles_exec(bContext *C, wmOperator *op)
static void UV_OT_remove_doubles(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Remove Doubles UV";
+ ot->name = "Merge UVs by Distance";
ot->description =
"Selected UV vertices that are within a radius of each other are welded together";
ot->idname = "UV_OT_remove_doubles";
@@ -2457,8 +2448,13 @@ static bool uv_sticky_select(
return false;
}
-static int uv_mouse_select_multi(
- bContext *C, Object **objects, uint objects_len, const float co[2], bool extend, bool loop)
+static int uv_mouse_select_multi(bContext *C,
+ Object **objects,
+ uint objects_len,
+ const float co[2],
+ const bool extend,
+ const bool deselect_all,
+ const bool loop)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
SpaceImage *sima = CTX_wm_space_image(C);
@@ -2472,6 +2468,7 @@ static int uv_mouse_select_multi(
UvNearestHit hit = UV_NEAREST_HIT_INIT;
int i, selectmode, sticky, sync, *hitv = NULL;
bool select = true;
+ bool found_item = false;
/* 0 == don't flush, 1 == sel, -1 == desel; only use when selection sync is enabled */
int flush = 0;
int hitlen = 0;
@@ -2516,79 +2513,86 @@ static int uv_mouse_select_multi(
/* find nearest element */
if (loop) {
/* find edge */
- if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) {
- return OPERATOR_CANCELLED;
- }
-
- hitlen = 0;
+ found_item = uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit);
}
else if (selectmode == UV_SELECT_VERTEX) {
/* find vertex */
- if (!uv_find_nearest_vert_multi(scene, ima, objects, objects_len, co, penalty_dist, &hit)) {
- return OPERATOR_CANCELLED;
- }
+ found_item = uv_find_nearest_vert_multi(
+ scene, ima, objects, objects_len, co, penalty_dist, &hit);
+ found_item = found_item && (!deselect_all || hit.dist_sq < penalty_dist);
- /* mark 1 vertex as being hit */
- hitv = BLI_array_alloca(hitv, hit.efa->len);
- hituv = BLI_array_alloca(hituv, hit.efa->len);
- copy_vn_i(hitv, hit.efa->len, 0xFFFFFFFF);
+ if (found_item) {
+ /* mark 1 vertex as being hit */
+ hitv = BLI_array_alloca(hitv, hit.efa->len);
+ hituv = BLI_array_alloca(hituv, hit.efa->len);
+ copy_vn_i(hitv, hit.efa->len, 0xFFFFFFFF);
- hitv[hit.lindex] = BM_elem_index_get(hit.l->v);
- hituv[hit.lindex] = hit.luv->uv;
+ hitv[hit.lindex] = BM_elem_index_get(hit.l->v);
+ hituv[hit.lindex] = hit.luv->uv;
- hitlen = hit.efa->len;
+ hitlen = hit.efa->len;
+ }
}
else if (selectmode == UV_SELECT_EDGE) {
/* find edge */
- if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) {
- return OPERATOR_CANCELLED;
- }
+ found_item = uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit);
+ found_item = found_item && (!deselect_all || hit.dist_sq < penalty_dist);
- /* mark 2 edge vertices as being hit */
- hitv = BLI_array_alloca(hitv, hit.efa->len);
- hituv = BLI_array_alloca(hituv, hit.efa->len);
- copy_vn_i(hitv, hit.efa->len, 0xFFFFFFFF);
+ if (found_item) {
+ /* mark 2 edge vertices as being hit */
+ hitv = BLI_array_alloca(hitv, hit.efa->len);
+ hituv = BLI_array_alloca(hituv, hit.efa->len);
+ copy_vn_i(hitv, hit.efa->len, 0xFFFFFFFF);
- hitv[hit.lindex] = BM_elem_index_get(hit.l->v);
- hitv[(hit.lindex + 1) % hit.efa->len] = BM_elem_index_get(hit.l->next->v);
- hituv[hit.lindex] = hit.luv->uv;
- hituv[(hit.lindex + 1) % hit.efa->len] = hit.luv_next->uv;
+ hitv[hit.lindex] = BM_elem_index_get(hit.l->v);
+ hitv[(hit.lindex + 1) % hit.efa->len] = BM_elem_index_get(hit.l->next->v);
+ hituv[hit.lindex] = hit.luv->uv;
+ hituv[(hit.lindex + 1) % hit.efa->len] = hit.luv_next->uv;
- hitlen = hit.efa->len;
+ hitlen = hit.efa->len;
+ }
}
else if (selectmode == UV_SELECT_FACE) {
/* find face */
- if (!uv_find_nearest_face_multi(scene, ima, objects, objects_len, co, &hit)) {
- return OPERATOR_CANCELLED;
- }
+ found_item = uv_find_nearest_face_multi(scene, ima, objects, objects_len, co, &hit);
+ found_item = found_item && (!deselect_all || hit.dist_sq < penalty_dist);
- BMEditMesh *em = BKE_editmesh_from_object(hit.ob);
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+ if (found_item) {
+ BMEditMesh *em = BKE_editmesh_from_object(hit.ob);
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
- /* make active */
- BM_mesh_active_face_set(em->bm, hit.efa);
+ /* make active */
+ BM_mesh_active_face_set(em->bm, hit.efa);
- /* mark all face vertices as being hit */
+ /* mark all face vertices as being hit */
- hitv = BLI_array_alloca(hitv, hit.efa->len);
- hituv = BLI_array_alloca(hituv, hit.efa->len);
- BM_ITER_ELEM_INDEX (l, &liter, hit.efa, BM_LOOPS_OF_FACE, i) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- hituv[i] = luv->uv;
- hitv[i] = BM_elem_index_get(l->v);
- }
+ hitv = BLI_array_alloca(hitv, hit.efa->len);
+ hituv = BLI_array_alloca(hituv, hit.efa->len);
+ BM_ITER_ELEM_INDEX (l, &liter, hit.efa, BM_LOOPS_OF_FACE, i) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ hituv[i] = luv->uv;
+ hitv[i] = BM_elem_index_get(l->v);
+ }
- hitlen = hit.efa->len;
+ hitlen = hit.efa->len;
+ }
}
else if (selectmode == UV_SELECT_ISLAND) {
- if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) {
- return OPERATOR_CANCELLED;
- }
-
- hitlen = 0;
+ found_item = uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit);
+ found_item = found_item && (!deselect_all || hit.dist_sq < penalty_dist);
}
- else {
- hitlen = 0;
+
+ if (!found_item) {
+ if (deselect_all) {
+ uv_select_all_perform_multi(scene, ima, objects, objects_len, SEL_DESELECT);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ uv_select_tag_update_for_object(depsgraph, ts, obedit);
+ }
+
+ return OPERATOR_PASS_THROUGH | OPERATOR_FINISHED;
+ }
return OPERATOR_CANCELLED;
}
@@ -2742,13 +2746,14 @@ static int uv_mouse_select_multi(
return OPERATOR_PASS_THROUGH | OPERATOR_FINISHED;
}
-static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loop)
+static int uv_mouse_select(
+ bContext *C, const float co[2], const bool extend, const bool deselect_all, const bool loop)
{
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, ((View3D *)NULL), &objects_len);
- int ret = uv_mouse_select_multi(C, objects, objects_len, co, extend, loop);
+ int ret = uv_mouse_select_multi(C, objects, objects_len, co, extend, deselect_all, loop);
MEM_freeN(objects);
return ret;
}
@@ -2756,13 +2761,13 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo
static int uv_select_exec(bContext *C, wmOperator *op)
{
float co[2];
- bool extend, loop;
RNA_float_get_array(op->ptr, "location", co);
- extend = RNA_boolean_get(op->ptr, "extend");
- loop = false;
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
+ const bool loop = false;
- return uv_mouse_select(C, co, extend, loop);
+ return uv_mouse_select(C, co, extend, deselect_all, loop);
}
static int uv_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -2790,11 +2795,19 @@ static void UV_OT_select(wmOperatorType *ot)
ot->poll = ED_operator_uvedit; /* requires space image */
/* properties */
+ PropertyRNA *prop;
RNA_def_boolean(ot->srna,
"extend",
0,
"Extend",
"Extend selection rather than clearing the existing selection");
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
RNA_def_float_vector(
ot->srna,
"location",
@@ -2817,13 +2830,13 @@ static void UV_OT_select(wmOperatorType *ot)
static int uv_select_loop_exec(bContext *C, wmOperator *op)
{
float co[2];
- bool extend, loop;
RNA_float_get_array(op->ptr, "location", co);
- extend = RNA_boolean_get(op->ptr, "extend");
- loop = true;
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+ const bool deselect_all = false;
+ const bool loop = true;
- return uv_mouse_select(C, co, extend, loop);
+ return uv_mouse_select(C, co, extend, deselect_all, loop);
}
static int uv_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -2875,7 +2888,7 @@ static void UV_OT_select_loop(wmOperatorType *ot)
/** \name Select Linked Operator
* \{ */
-static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent *event, int pick)
+static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent *event, bool pick)
{
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
@@ -2962,7 +2975,7 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
static int uv_select_linked_exec(bContext *C, wmOperator *op)
{
- return uv_select_linked_internal(C, op, NULL, 0);
+ return uv_select_linked_internal(C, op, NULL, false);
}
static void UV_OT_select_linked(wmOperatorType *ot)
@@ -2976,6 +2989,9 @@ static void UV_OT_select_linked(wmOperatorType *ot)
/* api callbacks */
ot->exec = uv_select_linked_exec;
ot->poll = ED_operator_uvedit; /* requires space image */
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
@@ -2986,12 +3002,12 @@ static void UV_OT_select_linked(wmOperatorType *ot)
static int uv_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- return uv_select_linked_internal(C, op, event, 1);
+ return uv_select_linked_internal(C, op, event, true);
}
static int uv_select_linked_pick_exec(bContext *C, wmOperator *op)
{
- return uv_select_linked_internal(C, op, NULL, 1);
+ return uv_select_linked_internal(C, op, NULL, true);
}
static void UV_OT_select_linked_pick(wmOperatorType *ot)
@@ -3000,7 +3016,9 @@ static void UV_OT_select_linked_pick(wmOperatorType *ot)
ot->name = "Select Linked Pick";
ot->description = "Select all UV vertices linked under the mouse";
ot->idname = "UV_OT_select_linked_pick";
- ot->flag = OPTYPE_UNDO;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* api callbacks */
ot->invoke = uv_select_linked_pick_invoke;
@@ -4986,7 +5004,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
wmKeyMap *keymap;
keymap = WM_keymap_ensure(keyconf, "UV Editor", 0, 0);
- keymap->poll = ED_operator_uvedit_can_uv_sculpt;
+ keymap->poll = ED_operator_uvedit;
}
/** \} */
diff --git a/source/blender/freestyle/intern/application/AppView.h b/source/blender/freestyle/intern/application/AppView.h
index 0b029895b8c..deb099349cb 100644
--- a/source/blender/freestyle/intern/application/AppView.h
+++ b/source/blender/freestyle/intern/application/AppView.h
@@ -43,7 +43,7 @@ class AppView {
virtual ~AppView();
public:
- //inherited
+ // inherited
inline unsigned int width()
{
return _width;
@@ -246,7 +246,7 @@ class AppView {
protected:
float _Fovy;
- //The root node container
+ // The root node container
NodeGroup _RootNode;
NodeDrawingStyle *_ModelRootNode;
NodeDrawingStyle *_SilhouetteRootNode;
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index d516b865eab..4d5ffda5f38 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -179,7 +179,7 @@ Controller::~Controller()
_ProgressBar = NULL;
}
- //delete _current_dirs;
+ // delete _current_dirs;
}
void Controller::setView(AppView *iView)
@@ -300,7 +300,7 @@ int Controller::LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph
_RootNode->AddChild(new NodeViewLayer(*re->scene, *view_layer));
sceneHashFunc.reset();
- //blenderScene->accept(sceneHashFunc);
+ // blenderScene->accept(sceneHashFunc);
_RootNode->accept(sceneHashFunc);
if (G.debug & G_DEBUG_FREESTYLE) {
cout << "Scene hash : " << sceneHashFunc.toString() << endl;
@@ -626,7 +626,7 @@ void Controller::ComputeViewMap()
void Controller::ComputeSteerableViewMap()
{
-#if 0 //soc
+#if 0 // soc
if ((!_Canvas) || (!_ViewMap))
return;
diff --git a/source/blender/freestyle/intern/application/Controller.h b/source/blender/freestyle/intern/application/Controller.h
index b287a515ba1..613ea2cb45c 100644
--- a/source/blender/freestyle/intern/application/Controller.h
+++ b/source/blender/freestyle/intern/application/Controller.h
@@ -58,7 +58,7 @@ class Controller {
void setPassZ(float *buf, int width, int height);
void setContext(bContext *C);
- //soc
+ // soc
void init_options();
int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph);
@@ -175,15 +175,15 @@ class Controller {
private:
// Main Window:
- //AppMainWindow *_pMainWindow;
+ // AppMainWindow *_pMainWindow;
// List of models currently loaded
vector<string> _ListOfModels;
// Current directories
- //ConfigIO* _current_dirs;
+ // ConfigIO* _current_dirs;
- //View
+ // View
// 3D
AppView *_pView;
@@ -195,7 +195,7 @@ class Controller {
RenderMonitor *_pRenderMonitor;
- //Model
+ // Model
// Drawing Structure
NodeGroup *_RootNode;
@@ -217,7 +217,7 @@ class Controller {
#endif
// debug
- //NodeUser<ViewMap> *_ViewMapNode; // FIXME
+ // NodeUser<ViewMap> *_ViewMapNode; // FIXME
// Chronometer:
Chronometer _Chrono;
@@ -229,7 +229,7 @@ class Controller {
int _edgeTesselationNature;
FastGrid _Grid;
- //HashGrid _Grid;
+ // HashGrid _Grid;
BBox<Vec3r> _Scene3dBBox;
unsigned int _SceneNumFaces;
@@ -241,9 +241,9 @@ class Controller {
int _render_count;
- //AppStyleWindow *_pStyleWindow;
- //AppOptionsWindow *_pOptionsWindow;
- //AppDensityCurvesWindow *_pDensityCurvesWindow;
+ // AppStyleWindow *_pStyleWindow;
+ // AppOptionsWindow *_pOptionsWindow;
+ // AppDensityCurvesWindow *_pDensityCurvesWindow;
ViewMapBuilder::visibility_algo _VisibilityAlgo;
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index 63ff4cc5457..7ef3e23d379 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -384,9 +384,10 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
bool logical_and = ((lineset->flags & FREESTYLE_LINESET_FE_AND) != 0);
// negation operator
if (lineset->flags & FREESTYLE_LINESET_FE_NOT) {
- // convert an Exclusive condition into an Inclusive equivalent using De Morgan's laws:
- // NOT (X OR Y) --> (NOT X) AND (NOT Y)
- // NOT (X AND Y) --> (NOT X) OR (NOT Y)
+ // convert an Exclusive condition into an
+ // Inclusive equivalent using De Morgan's laws:
+ // - NOT (X OR Y) --> (NOT X) AND (NOT Y)
+ // - NOT (X AND Y) --> (NOT X) OR (NOT Y)
for (int i = 0; i < num_edge_types; i++)
conditions[i].value *= -1;
logical_and = !logical_and;
diff --git a/source/blender/freestyle/intern/geometry/FastGrid.h b/source/blender/freestyle/intern/geometry/FastGrid.h
index e2345d4831c..a3b20661fa6 100644
--- a/source/blender/freestyle/intern/geometry/FastGrid.h
+++ b/source/blender/freestyle/intern/geometry/FastGrid.h
@@ -28,7 +28,8 @@ namespace Freestyle {
/*! Class to define a regular grid used for ray casting computations
* We don't use a hashtable here. The grid is explicitly stored for faster computations.
- * However, this might result in significant increase in memory usage (compared to the regular grid)
+ * However, this might result in significant increase in memory usage
+ * (compared to the regular grid).
*/
class FastGrid : public Grid {
public:
@@ -43,8 +44,9 @@ class FastGrid : public Grid {
clear();
}
- /*! clears the grid
- * Deletes all the cells, clears the hashtable, resets size, size of cell, number of cells.
+ /*!
+ * clears the grid
+ * Deletes all the cells, clears the hashtable, resets size, size of cell, number of cells.
*/
virtual void clear();
diff --git a/source/blender/freestyle/intern/geometry/FitCurve.cpp b/source/blender/freestyle/intern/geometry/FitCurve.cpp
index b0408826763..368c3d2f46c 100644
--- a/source/blender/freestyle/intern/geometry/FitCurve.cpp
+++ b/source/blender/freestyle/intern/geometry/FitCurve.cpp
@@ -181,8 +181,8 @@ static BezierCurve GenerateBezier(
alpha_l = det_X_C1 / det_C0_C1;
alpha_r = det_C0_X / det_C0_C1;
- /* If alpha negative, use the Wu/Barsky heuristic (see text) (if alpha is 0, you get coincident control points
- * that lead to divide by zero in any subsequent NewtonRaphsonRootFind() call).
+ /* If alpha negative, use the Wu/Barsky heuristic (see text) (if alpha is 0, you get coincident
+ * control points that lead to divide by zero in any subsequent NewtonRaphsonRootFind() call).
*/
if (alpha_l < 1.0e-6 || alpha_r < 1.0e-6) {
double dist = V2DistanceBetween2Points(&d[last], &d[first]) / 3.0;
@@ -194,8 +194,9 @@ static BezierCurve GenerateBezier(
return bezCurve;
}
- /* First and last control points of the Bezier curve are positioned exactly at the first and last data points
- * Control points 1 and 2 are positioned an alpha distance out on the tangent vectors, left and right, respectively
+ /* First and last control points of the Bezier curve are positioned exactly at the first and last
+ * data points Control points 1 and 2 are positioned an alpha distance out on the tangent
+ * vectors, left and right, respectively
*/
bezCurve[0] = d[first];
bezCurve[3] = d[last];
diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.h b/source/blender/freestyle/intern/geometry/GeomCleaner.h
index 5fedf94b479..253d3553010 100644
--- a/source/blender/freestyle/intern/geometry/GeomCleaner.h
+++ b/source/blender/freestyle/intern/geometry/GeomCleaner.h
@@ -45,20 +45,24 @@ class GeomCleaner {
/*! Sorts an array of Indexed vertices
* iVertices
- * Array of vertices to sort. It is organized as a float series of vertex coordinates: XYZXYZXYZ...
+ * Array of vertices to sort.
+ * It is organized as a float series of vertex coordinates: XYZXYZXYZ...
* iVSize
* The size of iVertices array.
* iIndices
- * The array containing the vertex indices (used to refer to the vertex coordinates in an indexed face). Each
- * element is an unsignedeger multiple of 3.
+ * The array containing the vertex indices
+ * (used to refer to the vertex coordinates in an indexed face).
+ * Each element is an unsignedeger multiple of 3.
* iISize
* The size of iIndices array
* oVertices
- * Output of sorted vertices. A vertex v1 precedes another one v2 in this array if v1.x<v2.x,
- * or v1.x=v2.x && v1.y < v2.y or v1.x=v2.y && v1.y=v2.y && v1.z < v2.z.
+ * Output of sorted vertices.
+ * A vertex v1 precedes another one v2 in this array
+ * if v1.x<v2.x, or v1.x=v2.x && v1.y < v2.y or v1.x=v2.y && v1.y=v2.y && v1.z < v2.z.
* The array is organized as a 3-float serie giving the vertices coordinates: XYZXYZXYZ...
* oIndices
- * Output corresponding to the iIndices array but reorganized in order to match the sorted vertex array.
+ * Output corresponding to the iIndices array but reorganized in
+ * order to match the sorted vertex array.
*/
static void SortIndexedVertexArray(const float *iVertices,
unsigned iVSize,
@@ -67,13 +71,16 @@ class GeomCleaner {
float **oVertices,
unsigned **oIndices);
- /*! Compress a SORTED indexed vertex array by eliminating multiple appearing occurences of a single vertex.
+ /*! Compress a SORTED indexed vertex array by eliminating multiple
+ * appearing occurences of a single vertex.
* iVertices
- * The SORTED vertex array to compress. It is organized as a float series of vertex coordinates: XYZXYZXYZ...
+ * The SORTED vertex array to compress.
+ * It is organized as a float series of vertex coordinates: XYZXYZXYZ...
* iVSize
* The size of iVertices array.
* iIndices
- * The array containing the vertex indices (used to refer to the vertex coordinates in an indexed face).
+ * The array containing the vertex indices
+ * (used to refer to the vertex coordinates in an indexed face).
* Each element is an unsignedeger multiple of 3.
* iISize
* The size of iIndices array
@@ -100,7 +107,8 @@ class GeomCleaner {
* iVSize
* The size of iVertices array.
* iIndices
- * The array containing the vertex indices (used to refer to the vertex coordinates in an indexed face).
+ * The array containing the vertex indices
+ * (used to refer to the vertex coordinates in an indexed face).
* Each element is an unsignedeger multiple of 3.
* iISize
* The size of iIndices array
@@ -120,15 +128,16 @@ class GeomCleaner {
unsigned *oVSize,
unsigned **oIndices);
- /*! Cleans an indexed vertex array. (Identical to SortAndCompress except that we use here a hash table
- * to create the new array.)
+ /*! Cleans an indexed vertex array.
+ * (Identical to SortAndCompress except that we use here a hash table to create the new array.)
* iVertices
* The vertex array to sort then compress. It is organized as a float series of
* vertex coordinates: XYZXYZXYZ...
* iVSize
* The size of iVertices array.
* iIndices
- * The array containing the vertex indices (used to refer to the vertex coordinates in an indexed face).
+ * The array containing the vertex indices
+ * (used to refer to the vertex coordinates in an indexed face).
* Each element is an unsignedeger multiple of 3.
* iISize
* The size of iIndices array
@@ -154,9 +163,10 @@ class GeomCleaner {
};
/*! Binary operators */
-//inline bool operator<(const IndexedVertex& iv1, const IndexedVertex& iv2);
+// inline bool operator<(const IndexedVertex& iv1, const IndexedVertex& iv2);
-/*! Class Indexed Vertex. Used to represent an indexed vertex by storing the vertex coordinates as well as its index */
+/*! Class Indexed Vertex. Used to represent an indexed vertex by storing the vertex coordinates as
+ * well as its index */
class IndexedVertex {
private:
Vec3f _Vector;
@@ -223,7 +233,7 @@ class IndexedVertex {
return _Vector[i];
}
- //friend inline bool operator<(const IndexedVertex& iv1, const IndexedVertex& iv2);
+ // friend inline bool operator<(const IndexedVertex& iv1, const IndexedVertex& iv2);
inline bool operator<(const IndexedVertex &v) const
{
return (_Vector < v._Vector);
diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.cpp b/source/blender/freestyle/intern/geometry/GeomUtils.cpp
index 2ac83526268..bec6ed27cc4 100644
--- a/source/blender/freestyle/intern/geometry/GeomUtils.cpp
+++ b/source/blender/freestyle/intern/geometry/GeomUtils.cpp
@@ -88,8 +88,8 @@ intersection_test intersect2dSeg2dSeg(
r1 = a2 * p1[0] + b2 * p1[1] + c2;
r2 = a2 * p2[0] + b2 * p2[1] + c2;
- // Check signs of r1 and r2. If both point 1 and point 2 lie on same side of second line segment,
- // the line segments do not intersect.
+ // Check signs of r1 and r2. If both point 1 and point 2 lie on same side of second line
+ // segment, the line segments do not intersect.
if (r1 != 0 && r2 != 0 && r1 * r2 > 0.0)
return (DONT_INTERSECT);
@@ -172,8 +172,8 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
r1 = a2 * p1[0] + b2 * p1[1] + c2;
r2 = a2 * p2[0] + b2 * p2[1] + c2;
- // Check signs of r1 and r2. If both point 1 and point 2 lie on same side of second line segment,
- // the line segments do not intersect.
+ // Check signs of r1 and r2. If both point 1 and point 2 lie on same side of second line
+ // segment, the line segments do not intersect.
if (r1 != 0 && r2 != 0 && r1 * r2 > 0.0)
return (DONT_INTERSECT);
@@ -202,8 +202,8 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
// 2001-03-05: released the code in its first version
// 2001-06-18: changed the order of the tests, faster
//
-// Acknowledgement: Many thanks to Pierre Terdiman for suggestions and discussions on how to optimize code.
-// Thanks to David Hunt for finding a ">="-bug!
+// Acknowledgement: Many thanks to Pierre Terdiman for suggestions and discussions on how to
+// optimize code. Thanks to David Hunt for finding a ">="-bug!
#define X 0
#define Y 1
@@ -337,10 +337,10 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
// This internal procedure is defined below.
bool overlapPlaneBox(Vec3r &normal, real d, Vec3r &maxbox);
-// Use separating axis theorem to test overlap between triangle and box need to test for overlap in these directions:
-// 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle we do not even need to test these)
-// 2) normal of the triangle
-// 3) crossproduct(edge from tri, {x,y,z}-directin) this gives 3x3=9 more tests
+// Use separating axis theorem to test overlap between triangle and box need to test for overlap in
+// these directions: 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle we
+// do not even need to test these) 2) normal of the triangle 3) crossproduct(edge from tri,
+// {x,y,z}-directin) this gives 3x3=9 more tests
bool overlapTriangleBox(Vec3r &boxcenter, Vec3r &boxhalfsize, Vec3r triverts[3])
{
Vec3r v0, v1, v2, normal, e0, e1, e2;
@@ -382,8 +382,8 @@ bool overlapTriangleBox(Vec3r &boxcenter, Vec3r &boxhalfsize, Vec3r triverts[3])
// Bullet 1:
// first test overlap in the {x,y,z}-directions
- // find min, max of the triangle each direction, and test for overlap in that direction -- this is equivalent
- // to testing a minimal AABB around the triangle against the AABB
+ // find min, max of the triangle each direction, and test for overlap in that direction -- this
+ // is equivalent to testing a minimal AABB around the triangle against the AABB
// test in X-direction
FINDMINMAX(v0[X], v1[X], v2[X], min, max);
@@ -664,7 +664,7 @@ void fromWorldToImage(const Vec3r &p, Vec3r &q, const real transform[4][4], cons
// winX:
q[0] = viewport[0] + viewport[2] * (q[0] + 1.0) / 2.0;
- //winY:
+ // winY:
q[1] = viewport[1] + viewport[3] * (q[1] + 1.0) / 2.0;
}
@@ -709,10 +709,10 @@ void fromCameraToWorld(const Vec3r &p, Vec3r &q, const real model_view_matrix[4]
/////////////////////////////////////////////////////////////////////////////
// Copyright 2001, softSurfer (www.softsurfer.com)
-// This code may be freely used and modified for any purpose providing that this copyright notice is included with it.
-// SoftSurfer makes no warranty for this code, and cannot be held liable for any real or imagined damage resulting
-// from its use.
-// Users of this code must verify correctness for their application.
+// This code may be freely used and modified for any purpose providing that this copyright notice
+// is included with it. SoftSurfer makes no warranty for this code, and cannot be held liable for
+// any real or imagined damage resulting from its use. Users of this code must verify correctness
+// for their application.
#define PERP(u, v) ((u)[0] * (v)[1] - (u)[1] * (v)[0]) // 2D perp product
diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.h b/source/blender/freestyle/intern/geometry/GeomUtils.h
index 42ef9612074..c469f10cc49 100644
--- a/source/blender/freestyle/intern/geometry/GeomUtils.h
+++ b/source/blender/freestyle/intern/geometry/GeomUtils.h
@@ -105,7 +105,8 @@ bool include2dSeg2dArea(const Vec2r &min, const Vec2r &max, const Vec2r &A, cons
/*! Box-triangle overlap test, adapted from Tomas Akenine-Möller code */
bool overlapTriangleBox(Vec3r &boxcenter, Vec3r &boxhalfsize, Vec3r triverts[3]);
-/*! Fast, Minimum Storage Ray-Triangle Intersection, adapted from Tomas Möller and Ben Trumbore code. */
+/*! Fast, Minimum Storage Ray-Triangle Intersection, adapted from Tomas Möller and Ben Trumbore
+ * code. */
bool intersectRayTriangle(const Vec3r &orig,
const Vec3r &dir,
const Vec3r &v0,
@@ -126,7 +127,8 @@ intersection_test intersectRayPlane(const Vec3r &orig,
const real epsilon = M_EPSILON); // the epsilon to use
/*! Intersection Ray-Bounding box (axis aligned).
- * Adapted from Williams et al, "An Efficient Robust Ray-Box Intersection Algorithm", JGT 10:1 (2005), pp. 49-54.
+ * Adapted from Williams et al, "An Efficient Robust Ray-Box Intersection Algorithm", JGT 10:1
+ * (2005), pp. 49-54.
*/
bool intersectRayBBox(const Vec3r &orig,
const Vec3r &dir, // ray origin and direction
diff --git a/source/blender/freestyle/intern/geometry/Grid.cpp b/source/blender/freestyle/intern/geometry/Grid.cpp
index 51afb5c1a45..aeb82d56009 100644
--- a/source/blender/freestyle/intern/geometry/Grid.cpp
+++ b/source/blender/freestyle/intern/geometry/Grid.cpp
@@ -49,10 +49,10 @@ void firstIntersectionGridVisitor::examineOccluder(Polygon3r *occ)
{
// check whether the edge and the polygon plane are coincident:
//-------------------------------------------------------------
- //first let us compute the plane equation.
+ // first let us compute the plane equation.
Vec3r v1(((occ)->getVertices())[0]);
Vec3d normal((occ)->getNormal());
- //soc unused - double d = -(v1 * normal);
+ // soc unused - double d = -(v1 * normal);
double tmp_u, tmp_v, tmp_t;
if ((occ)->rayIntersect(ray_org_, ray_dir_, tmp_t, tmp_u, tmp_v)) {
@@ -167,8 +167,9 @@ void Grid::insertOccluder(Polygon3r *occluder)
getCellCoordinates(min, imin);
// We are now going to fill in the cells overlapping with the polygon bbox.
- // If the polygon is a triangle (most of cases), we also check for each of these cells if it is overlapping with
- // the triangle in order to only fill in the ones really overlapping the triangle.
+ // If the polygon is a triangle (most of cases), we also check for each of these cells if it is
+ // overlapping with the triangle in order to only fill in the ones really overlapping the
+ // triangle.
unsigned i, x, y, z;
vector<Vec3r>::const_iterator it;
@@ -239,8 +240,8 @@ bool Grid::nextRayCell(Vec3u &current_cell, Vec3u &next_cell)
t_min = FLT_MAX; // init tmin with handle of the case where one or 2 _u[i] = 0.
unsigned coord = 0; // predominant coord(0=x, 1=y, 2=z)
- // using a parametric equation of a line : B = A + t u, we find the tx, ty and tz respectively coresponding
- // to the intersections with the plans:
+ // using a parametric equation of a line : B = A + t u, we find the tx, ty and tz respectively
+ // coresponding to the intersections with the plans:
// x = _cell_size[0], y = _cell_size[1], z = _cell_size[2]
for (i = 0; i < 3; i++) {
if (_ray_dir[i] == 0)
@@ -318,8 +319,8 @@ Polygon3r *Grid::castRayToFindFirstIntersection(
firstIntersectionGridVisitor visitor(orig, dir, _cell_size);
castRayInternal(visitor);
// ARB: This doesn't work, because occluders are unordered within any cell
- // visitor.occluder() will be an occluder, but we have no guarantee it will be the *first* occluder.
- // I assume that is the reason this code is not actually used for FindOccludee.
+ // visitor.occluder() will be an occluder, but we have no guarantee it will be the *first*
+ // occluder. I assume that is the reason this code is not actually used for FindOccludee.
occluder = visitor.occluder();
t = visitor.t_;
u = visitor.u_;
@@ -337,7 +338,7 @@ void Grid::initRay(const Vec3r &orig, const Vec3r &end, unsigned timestamp)
for (unsigned i = 0; i < 3; i++) {
_current_cell[i] = (unsigned)floor((orig[i] - _orig[i]) / _cell_size[i]);
- //soc unused - unsigned u = _current_cell[i];
+ // soc unused - unsigned u = _current_cell[i];
_pt[i] = orig[i] - _orig[i] - _current_cell[i] * _cell_size[i];
}
//_ray_occluders.clear();
@@ -358,7 +359,7 @@ bool Grid::initInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timesta
if (box.inside(orig)) {
for (unsigned int i = 0; i < 3; i++) {
_current_cell[i] = (unsigned int)floor((orig[i] - _orig[i]) / _cell_size[i]);
- //soc unused - unsigned u = _current_cell[i];
+ // soc unused - unsigned u = _current_cell[i];
_pt[i] = orig[i] - _orig[i] - _current_cell[i] * _cell_size[i];
}
}
@@ -372,7 +373,7 @@ bool Grid::initInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timesta
_current_cell[i] = (unsigned)floor((newOrig[i] - _orig[i]) / _cell_size[i]);
if (_current_cell[i] == _cells_nb[i])
_current_cell[i] = _cells_nb[i] - 1;
- //soc unused - unsigned u = _current_cell[i];
+ // soc unused - unsigned u = _current_cell[i];
_pt[i] = newOrig[i] - _orig[i] - _current_cell[i] * _cell_size[i];
}
}
diff --git a/source/blender/freestyle/intern/geometry/Grid.h b/source/blender/freestyle/intern/geometry/Grid.h
index a2b64a446b6..67aae73a578 100644
--- a/source/blender/freestyle/intern/geometry/Grid.h
+++ b/source/blender/freestyle/intern/geometry/Grid.h
@@ -92,7 +92,7 @@ class Cell {
class GridVisitor {
public:
- virtual ~GridVisitor(){}; //soc
+ virtual ~GridVisitor(){}; // soc
virtual void discoverCell(Cell * /*cell*/)
{
@@ -143,7 +143,7 @@ class allOccludersGridVisitor : public GridVisitor {
* The occluder and the intersection information are stored and accessible.
*/
class firstIntersectionGridVisitor : public GridVisitor {
- //soc - changed order to remove warnings
+ // soc - changed order to remove warnings
public:
double u_, v_, t_;
@@ -217,7 +217,8 @@ class Grid {
*/
virtual void configure(const Vec3r &orig, const Vec3r &size, unsigned nb);
- /*! returns a vector of integer containing the coordinates of the cell containing the point passed as argument
+ /*! returns a vector of integer containing the coordinates of the cell containing the point
+ * passed as argument
* p
* The point for which we're looking the cell
*/
@@ -241,8 +242,8 @@ class Grid {
/*! returns the cell whose coordinates are pased as argument */
virtual Cell *getCell(const Vec3u &coord) = 0;
- /*! returns the cell containing the point passed as argument. If the cell is empty (contains no occluder),
- * NULL is returned
+ /*! returns the cell containing the point passed as argument.
+ * If the cell is empty (contains no occluder), NULL is returned:
* p
* The point for which we're looking the cell
*/
@@ -253,7 +254,8 @@ class Grid {
return getCell(coord);
}
- /*! Retrieves the x,y,z coordinates of the origin of the cell whose coordinates (i,j,k) is passed as argument
+ /*! Retrieves the x,y,z coordinates of the origin of the cell whose coordinates (i,j,k)
+ * is passed as argument:
* cell_coord
* i,j,k integer coordinates for the cell
* orig
@@ -265,7 +267,7 @@ class Grid {
orig[i] = _orig[i] + cell_coord[i] * _cell_size[i];
}
- /*! Retrieves the box corresponding to the cell whose coordinates are passed as argument.
+ /*! Retrieves the box corresponding to the cell whose coordinates are passed as argument:
* cell_coord
* i,j,k integer coordinates for the cell
* min_out
@@ -280,9 +282,8 @@ class Grid {
}
/*! inserts a convex polygon occluder
- * This method is quite coarse insofar as it adds all cells intersecting the polygon bounding box
- * convex_poly
- * The list of 3D points constituting a convex polygon
+ * This method is quite coarse insofar as it adds all cells intersecting the polygon bounding
+ * box convex_poly The list of 3D points constituting a convex polygon
*/
void insertOccluder(Polygon3r *convex_poly);
@@ -301,8 +302,8 @@ class Grid {
// Prepares to cast ray without generating OccludersSet
void initAcceleratedRay(const Vec3r &orig, const Vec3r &end, unsigned timestamp);
- /*! Casts an infinite ray (still finishing at the end of the grid) from a starting point and in a given direction.
- * Returns the list of occluders contained in the cells intersected by this ray
+ /*! Casts an infinite ray (still finishing at the end of the grid) from a starting point and in a
+ * given direction. Returns the list of occluders contained in the cells intersected by this ray
* Starts with a call to InitRay.
*/
void castInfiniteRay(const Vec3r &orig,
@@ -313,9 +314,9 @@ class Grid {
// Prepares to cast ray without generating OccludersSet.
bool initAcceleratedInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timestamp);
- /*! Casts an infinite ray (still finishing at the end of the grid) from a starting point and in a given direction.
- * Returns the first intersection (occluder,t,u,v) or null.
- * Starts with a call to InitRay.
+ /*! Casts an infinite ray (still finishing at the end of the grid) from a starting point and in a
+ * given direction. Returns the first intersection (occluder,t,u,v) or null. Starts with a call
+ * to InitRay.
*/
Polygon3r *castRayToFindFirstIntersection(
const Vec3r &orig, const Vec3r &dir, double &t, double &u, double &v, unsigned timestamp);
@@ -344,7 +345,7 @@ class Grid {
return _cell_size;
}
- //ARB profiling only:
+ // ARB profiling only:
inline OccludersSet *getOccluders()
{
return &_occluders;
@@ -392,12 +393,13 @@ class Grid {
Vec3r _ray_dir; // direction vector for the ray
Vec3u _current_cell; // The current cell being processed (designated by its 3 coordinates)
- Vec3r
- _pt; // Points corresponding to the incoming and outgoing intersections of one cell with the ray
+ Vec3r _pt; // Points corresponding to the incoming and outgoing intersections of one cell with
+ // the ray
real _t_end; // To know when we are at the end of the ray
real _t;
- //OccludersSet _ray_occluders; // Set storing the occluders contained in the cells traversed by a ray
+ // OccludersSet _ray_occluders; // Set storing the occluders contained in the cells traversed by
+ // a ray
OccludersSet _occluders; // List of all occluders inserted in the grid
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/blender/freestyle/intern/geometry/GridHelpers.cpp b/source/blender/freestyle/intern/geometry/GridHelpers.cpp
index 1f87bb7b76a..a83dc385758 100644
--- a/source/blender/freestyle/intern/geometry/GridHelpers.cpp
+++ b/source/blender/freestyle/intern/geometry/GridHelpers.cpp
@@ -26,14 +26,15 @@ namespace Freestyle {
void GridHelpers::getDefaultViewProscenium(real viewProscenium[4])
{
// Get proscenium boundary for culling
- // bufferZone determines the amount by which the area processed should exceed the actual image area.
- // This is intended to avoid visible artifacts generated along the proscenium edge.
- // Perhaps this is no longer needed now that entire view edges are culled at once, since that theoretically
- // should eliminate visible artifacts.
- // To the extent it is still useful, bufferZone should be put into the UI as configurable percentage value
+ // bufferZone determines the amount by which the area processed should exceed the actual image
+ // area. This is intended to avoid visible artifacts generated along the proscenium edge. Perhaps
+ // this is no longer needed now that entire view edges are culled at once, since that
+ // theoretically should eliminate visible artifacts. To the extent it is still useful, bufferZone
+ // should be put into the UI as configurable percentage value
const real bufferZone = 0.05;
// borderZone describes a blank border outside the proscenium, but still inside the image area.
- // Only intended for exposing possible artifacts along or outside the proscenium edge during debugging.
+ // Only intended for exposing possible artifacts along or outside the proscenium edge during
+ // debugging.
const real borderZone = 0.0;
viewProscenium[0] = g_freestyle.viewport[2] * (borderZone - bufferZone);
viewProscenium[1] = g_freestyle.viewport[2] * (1.0f - borderZone + bufferZone);
diff --git a/source/blender/freestyle/intern/geometry/GridHelpers.h b/source/blender/freestyle/intern/geometry/GridHelpers.h
index 8a7503350a3..3f3c669cb57 100644
--- a/source/blender/freestyle/intern/geometry/GridHelpers.h
+++ b/source/blender/freestyle/intern/geometry/GridHelpers.h
@@ -126,8 +126,8 @@ class Transform {
inline bool insideProscenium(const real proscenium[4], const Polygon3r &polygon)
{
- // N.B. The bounding box check is redundant for inserting occluders into cells, because the cell selection code
- // in insertOccluders has already guaranteed that the bounding boxes will overlap.
+ // N.B. The bounding box check is redundant for inserting occluders into cells, because the cell
+ // selection code in insertOccluders has already guaranteed that the bounding boxes will overlap.
// First check the viewport edges, since they are the easiest case
// Check if the bounding box is entirely outside the proscenium
Vec3r bbMin, bbMax;
diff --git a/source/blender/freestyle/intern/geometry/SweepLine.h b/source/blender/freestyle/intern/geometry/SweepLine.h
index 81b0fd90d82..36094bf5086 100644
--- a/source/blender/freestyle/intern/geometry/SweepLine.h
+++ b/source/blender/freestyle/intern/geometry/SweepLine.h
@@ -188,8 +188,8 @@ template<class T, class Point> class Segment {
# pragma warning(pop)
#endif
-/*! defines a binary function that can be overload by the user to specify at each condition the intersection
- * between 2 edges must be computed
+/*! defines a binary function that can be overload by the user to specify at each condition the
+ * intersection between 2 edges must be computed
*/
template<class T1, class T2> struct binary_rule {
binary_rule()
diff --git a/source/blender/freestyle/intern/image/GaussianFilter.h b/source/blender/freestyle/intern/image/GaussianFilter.h
index 5b74e622c33..e6824fcb81e 100644
--- a/source/blender/freestyle/intern/image/GaussianFilter.h
+++ b/source/blender/freestyle/intern/image/GaussianFilter.h
@@ -46,7 +46,8 @@ class GaussianFilter {
float _sigma;
float *_mask;
int _bound;
- // the real mask size (must be odd)(the size of the mask we store is ((_maskSize+1)/2)*((_maskSize+1)/2))
+ // the real mask size (must be odd)(the size of the mask we store is
+ // ((_maskSize+1)/2)*((_maskSize+1)/2))
int _maskSize;
int _storedMaskSize; // (_maskSize+1)/2)
@@ -56,13 +57,13 @@ class GaussianFilter {
GaussianFilter &operator=(const GaussianFilter &);
virtual ~GaussianFilter();
- /*! Returns the value for pixel x,y of image "map" after a gaussian blur, made using the sigma value.
- * The sigma value determines the mask size (~ 2 x sigma).
- * \param map:
- * The image we wish to work on. The Map template must implement the following methods:
- * - float pixel(unsigned int x,unsigned int y) const;
- * - unsigned width() const;
- * - unsigned height() const;
+ /*! Returns the value for pixel x,y of image "map" after a gaussian blur, made using the sigma
+ * value. The sigma value determines the mask size (~ 2 x sigma).
+ * \param map: The image we wish to work on.
+ * The Map template must implement the following methods:
+ * - float pixel(unsigned int x,unsigned int y) const;
+ * - unsigned width() const;
+ * - unsigned height() const;
* \param x:
* The abscissa of the pixel where we want to evaluate the gaussian blur.
* \param y:
@@ -127,8 +128,8 @@ template<class Map> float GaussianFilter::getSmoothedPixel(Map *map, int x, int
{
float sum = 0.0f;
float L = 0.0f;
- int w = (int)map->width(); //soc
- int h = (int)map->height(); //soc
+ int w = (int)map->width(); // soc
+ int h = (int)map->height(); // soc
// Current pixel is x,y
// Sum surrounding pixels L value:
@@ -145,7 +146,7 @@ template<class Map> float GaussianFilter::getSmoothedPixel(Map *map, int x, int
sum += m;
}
}
- //L /= sum;
+ // L /= sum;
return L;
}
diff --git a/source/blender/freestyle/intern/image/Image.h b/source/blender/freestyle/intern/image/Image.h
index 344766bfa63..b854e411a83 100644
--- a/source/blender/freestyle/intern/image/Image.h
+++ b/source/blender/freestyle/intern/image/Image.h
@@ -35,9 +35,10 @@ namespace Freestyle {
//
///////////////////////////////////////////////////////////////////////////////
-/*! This class allows the storing of part of an image, while allowing a normal access to its pixel values.
- * You can for example only a rectangle of sw*sh, whose lower-left corner is at (ox, oy), of an image of
- * size w*h, and access these pixels using x,y coordinates specified in the whole image coordinate system.
+/*! This class allows the storing of part of an image, while allowing a normal access to its pixel
+ * values. You can for example only a rectangle of sw*sh, whose lower-left corner is at (ox, oy),
+ * of an image of size w*h, and access these pixels using x,y coordinates specified in the whole
+ * image coordinate system.
*/
class FrsImage {
public:
@@ -209,7 +210,8 @@ class RGBImage : public FrsImage {
/*! Builds an RGB partial image from the useful part buffer.
* \param rgb:
* The array of size 3*sw*sh containing the RGB values of the sw*sh pixels we need to stored.
- * These sw*sh pixels constitute a rectangular part of a bigger RGB image containing w*h pixels.
+ * These sw*sh pixels constitute a rectangular part of a bigger
+ * RGB image containing w*h pixels.
* \param w:
* The width of the complete image
* \param h:
@@ -346,7 +348,8 @@ class GrayImage : public FrsImage {
/*! Builds a partial image from the useful part buffer.
* \param lvl:
* The array of size sw*sh containing the gray values of the sw*sh pixels we need to stored.
- * These sw*sh pixels constitute a rectangular part of a bigger gray image containing w*h pixels.
+ * These sw*sh pixels constitute a rectangular part of a bigger
+ * gray image containing w*h pixels.
* \param w:
* The width of the complete image
* \param h:
diff --git a/source/blender/freestyle/intern/image/ImagePyramid.cpp b/source/blender/freestyle/intern/image/ImagePyramid.cpp
index 12d322d7472..e5b4053fbf4 100644
--- a/source/blender/freestyle/intern/image/ImagePyramid.cpp
+++ b/source/blender/freestyle/intern/image/ImagePyramid.cpp
@@ -153,7 +153,7 @@ void GaussianPyramid::BuildPyramid(GrayImage *level0, unsigned nbLevels)
unsigned w = pLevel->width();
unsigned h = pLevel->height();
if (nbLevels != 0) {
- for (unsigned int i = 0; i < nbLevels; ++i) { //soc
+ for (unsigned int i = 0; i < nbLevels; ++i) { // soc
w = pLevel->width() >> 1;
h = pLevel->height() >> 1;
GrayImage *img = new GrayImage(w, h);
diff --git a/source/blender/freestyle/intern/image/ImagePyramid.h b/source/blender/freestyle/intern/image/ImagePyramid.h
index 0e388fdf20c..8c6a8bcdff4 100644
--- a/source/blender/freestyle/intern/image/ImagePyramid.h
+++ b/source/blender/freestyle/intern/image/ImagePyramid.h
@@ -43,7 +43,7 @@ class ImagePyramid {
{
}
ImagePyramid(const ImagePyramid &iBrother);
- //ImagePyramid(const GrayImage& level0, unsigned nbLevels);
+ // ImagePyramid(const GrayImage& level0, unsigned nbLevels);
virtual ~ImagePyramid();
/*! Builds the pyramid.
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
index 2068fe820d0..2169ee18166 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
@@ -31,7 +31,7 @@ extern "C" {
//------------------------INSTANCE METHODS ----------------------------------
-//ViewMapGradientNormBP1D(int level, IntegrationType iType=MEAN, float sampling=2.0)
+// ViewMapGradientNormBP1D(int level, IntegrationType iType=MEAN, float sampling=2.0)
static char ViewMapGradientNormBP1D___doc__[] =
"Class hierarchy: :class:`freestyle.types.BinaryPredicate1D` > "
@@ -82,7 +82,7 @@ static int ViewMapGradientNormBP1D___init__(BPy_ViewMapGradientNormBP1D *self,
return 0;
}
-/*-----------------------BPy_ViewMapGradientNormBP1D type definition ------------------------------*/
+/*-----------------------BPy_ViewMapGradientNormBP1D type definition ----------------------------*/
PyTypeObject ViewMapGradientNormBP1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ViewMapGradientNormBP1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
index e685491f682..8a5bb0b17ff 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
@@ -136,7 +136,7 @@ static int CurvePoint_init(BPy_CurvePoint *self, PyObject *args, PyObject *kwds)
return 0;
}
-///bool operator== (const CurvePoint &b)
+/// bool operator== (const CurvePoint &b)
/*----------------------CurvePoint get/setters ----------------------------*/
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
index f25435b421c..189d41e78a3 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
@@ -161,7 +161,7 @@ static void ChainPredicateIterator_dealloc(BPy_ChainPredicateIterator *self)
ChainingIterator_Type.tp_dealloc((PyObject *)self);
}
-/*-----------------------BPy_ChainPredicateIterator type definition ------------------------------*/
+/*-----------------------BPy_ChainPredicateIterator type definition ----------------------------*/
PyTypeObject ChainPredicateIterator_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ChainPredicateIterator", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
index 6a4af0f8053..d72e830e293 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
@@ -31,8 +31,8 @@ extern "C" {
//------------------------INSTANCE METHODS ----------------------------------
-// ChainSilhouetteIterator (bool restrict_to_selection=true, ViewEdge *begin=NULL, bool orientation=true)
-// ChainSilhouetteIterator (const ChainSilhouetteIterator &brother)
+// ChainSilhouetteIterator (bool restrict_to_selection=true, ViewEdge *begin=NULL, bool
+// orientation=true) ChainSilhouetteIterator (const ChainSilhouetteIterator &brother)
PyDoc_STRVAR(ChainSilhouetteIterator_doc,
"Class hierarchy: :class:`freestyle.types.Iterator` >\n"
@@ -117,7 +117,7 @@ static int ChainSilhouetteIterator_init(BPy_ChainSilhouetteIterator *self,
return 0;
}
-/*-----------------------BPy_ChainSilhouetteIterator type definition ------------------------------*/
+/*-----------------------BPy_ChainSilhouetteIterator type definition ----------------------------*/
PyTypeObject ChainSilhouetteIterator_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ChainSilhouetteIterator", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
index 3cb114a0037..21e3e821214 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
@@ -137,7 +137,7 @@ static PyGetSetDef BPy_orientedViewEdgeIterator_getseters[] = {
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
-/*-----------------------BPy_orientedViewEdgeIterator type definition ------------------------------*/
+/*-----------------------BPy_orientedViewEdgeIterator type definition ---------------------------*/
PyTypeObject orientedViewEdgeIterator_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "orientedViewEdgeIterator", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
index 7ee1372aa22..9a37acbd788 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
@@ -63,7 +63,7 @@ static int BackboneStretcherShader___init__(BPy_BackboneStretcherShader *self,
return 0;
}
-/*-----------------------BPy_BackboneStretcherShader type definition ------------------------------*/
+/*-----------------------BPy_BackboneStretcherShader type definition ----------------------------*/
PyTypeObject BackboneStretcherShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "BackboneStretcherShader", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h
index 8acb1215980..35a94a1620d 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h
@@ -31,7 +31,8 @@ extern "C" {
extern PyTypeObject CalligraphicShader_Type;
-#define BPy_CalligraphicShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&CalligraphicShader_Type)
+#define BPy_CalligraphicShader_Check(v) \
+ (PyObject_IsInstance((PyObject *)v, (PyObject *)&CalligraphicShader_Type)
/*---------------------------Python BPy_CalligraphicShader structure definition----------*/
typedef struct {
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
index c226cc0df25..5177d275a10 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
@@ -62,7 +62,7 @@ static int ConstantThicknessShader___init__(BPy_ConstantThicknessShader *self,
return 0;
}
-/*-----------------------BPy_ConstantThicknessShader type definition ------------------------------*/
+/*-----------------------BPy_ConstantThicknessShader type definition ----------------------------*/
PyTypeObject ConstantThicknessShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ConstantThicknessShader", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
index 22a67c65df8..4afe148c066 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
@@ -68,7 +68,7 @@ static int ConstrainedIncreasingThicknessShader___init__(
return 0;
}
-/*-----------------------BPy_ConstrainedIncreasingThicknessShader type definition ------------------------------*/
+/*-----------------------BPy_ConstrainedIncreasingThicknessShader type definition ---------------*/
PyTypeObject ConstrainedIncreasingThicknessShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ConstrainedIncreasingThicknessShader", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h
index 907355ea69c..04912499c04 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h
@@ -34,7 +34,8 @@ extern PyTypeObject ConstrainedIncreasingThicknessShader_Type;
#define BPy_ConstrainedIncreasingThicknessShader_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&ConstrainedIncreasingThicknessShader_Type))
-/*---------------------------Python BPy_ConstrainedIncreasingThicknessShader structure definition----------*/
+/*---------------------------Python BPy_ConstrainedIncreasingThicknessShader structure
+ * definition----------*/
typedef struct {
BPy_StrokeShader py_ss;
} BPy_ConstrainedIncreasingThicknessShader;
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
index 324f1c1a40b..b791fc598df 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
@@ -68,7 +68,7 @@ static int IncreasingThicknessShader___init__(BPy_IncreasingThicknessShader *sel
return 0;
}
-/*-----------------------BPy_IncreasingThicknessShader type definition ------------------------------*/
+/*-----------------------BPy_IncreasingThicknessShader type definition --------------------------*/
PyTypeObject IncreasingThicknessShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "IncreasingThicknessShader", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
index 273e41a7b9f..7eb20d47539 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
@@ -69,7 +69,7 @@ static int PolygonalizationShader___init__(BPy_PolygonalizationShader *self,
return 0;
}
-/*-----------------------BPy_PolygonalizationShader type definition ------------------------------*/
+/*-----------------------BPy_PolygonalizationShader type definition -----------------------------*/
PyTypeObject PolygonalizationShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "PolygonalizationShader", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
index 3d76d71bab6..e8183b41d05 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
@@ -62,7 +62,7 @@ static int StrokeTextureStepShader___init__(BPy_StrokeTextureStepShader *self,
return 0;
}
-/*-----------------------BPy_StrokeTextureStepShader type definition ------------------------------*/
+/*-----------------------BPy_StrokeTextureStepShader type definition ----------------------------*/
PyTypeObject StrokeTextureStepShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "StrokeTextureStepShader", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
index 76dbe2ef023..f6292f0086a 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
@@ -115,7 +115,7 @@ static PyObject *UnaryFunction0DEdgeNature___call__(BPy_UnaryFunction0DEdgeNatur
return BPy_Nature_from_Nature(self->uf0D_edgenature->result);
}
-/*-----------------------BPy_UnaryFunction0DEdgeNature type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction0DEdgeNature type definition --------------------------*/
PyTypeObject UnaryFunction0DEdgeNature_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DEdgeNature", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
index a375ac506f0..63f9ff0deb8 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
@@ -114,7 +114,7 @@ static PyObject *UnaryFunction0DMaterial___call__(BPy_UnaryFunction0DMaterial *s
return BPy_FrsMaterial_from_FrsMaterial(self->uf0D_material->result);
}
-/*-----------------------BPy_UnaryFunction0DMaterial type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction0DMaterial type definition ----------------------------*/
PyTypeObject UnaryFunction0DMaterial_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DMaterial", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
index 756e5cde3ce..65d8d630fce 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
@@ -115,7 +115,7 @@ static PyObject *UnaryFunction0DUnsigned___call__(BPy_UnaryFunction0DUnsigned *s
return PyLong_FromLong(self->uf0D_unsigned->result);
}
-/*-----------------------BPy_UnaryFunction0DUnsigned type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction0DUnsigned type definition ----------------------------*/
PyTypeObject UnaryFunction0DUnsigned_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DUnsigned", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
index 039727f4fab..d908b3fa6ed 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
@@ -124,7 +124,7 @@ static PyObject *UnaryFunction0DVectorViewShape___call__(BPy_UnaryFunction0DVect
return list;
}
-/*-----------------------BPy_UnaryFunction0DVectorViewShape type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction0DVectorViewShape type definition ---------------------*/
PyTypeObject UnaryFunction0DVectorViewShape_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DVectorViewShape", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
index 22cf50ce5a2..586f7ec40e5 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
@@ -37,13 +37,15 @@ extern PyTypeObject UnaryFunction0DVectorViewShape_Type;
#define BPy_UnaryFunction0DVectorViewShape_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction0DVectorViewShape_Type))
-/*---------------------------Python BPy_UnaryFunction0DVectorViewShape structure definition----------*/
+/*---------------------------Python BPy_UnaryFunction0DVectorViewShape structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction0D py_uf0D;
UnaryFunction0D<std::vector<ViewShape *>> *uf0D_vectorviewshape;
} BPy_UnaryFunction0DVectorViewShape;
-/*---------------------------Python BPy_UnaryFunction0DVectorViewShape visible prototypes-----------*/
+/*---------------------------Python BPy_UnaryFunction0DVectorViewShape visible
+ * prototypes-----------*/
int UnaryFunction0DVectorViewShape_Init(PyObject *module);
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
index 1df3be084c0..8c04d8eabaa 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
@@ -121,7 +121,7 @@ static PyObject *UnaryFunction0DViewShape___call__(BPy_UnaryFunction0DViewShape
return BPy_ViewShape_from_ViewShape(*(self->uf0D_viewshape->result));
}
-/*-----------------------BPy_UnaryFunction0DViewShape type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction0DViewShape type definition ---------------------------*/
PyTypeObject UnaryFunction0DViewShape_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DViewShape", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp
index 623ec4db50e..ec3755987d1 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp
@@ -64,7 +64,7 @@ static int VertexOrientation2DF0D___init__(BPy_VertexOrientation2DF0D *self,
return 0;
}
-/*-----------------------BPy_VertexOrientation2DF0D type definition ------------------------------*/
+/*-----------------------BPy_VertexOrientation2DF0D type definition -----------------------------*/
PyTypeObject VertexOrientation2DF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "VertexOrientation2DF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp
index 6ed52014719..d5e073b5802 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp
@@ -64,7 +64,7 @@ static int VertexOrientation3DF0D___init__(BPy_VertexOrientation3DF0D *self,
return 0;
}
-/*-----------------------BPy_VertexOrientation3DF0D type definition ------------------------------*/
+/*-----------------------BPy_VertexOrientation3DF0D type definition -----------------------------*/
PyTypeObject VertexOrientation3DF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "VertexOrientation3DF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp
index ce8852a2b6c..2db536d2a90 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp
@@ -62,7 +62,7 @@ static int GetCurvilinearAbscissaF0D___init__(BPy_GetCurvilinearAbscissaF0D *sel
return 0;
}
-/*-----------------------BPy_GetCurvilinearAbscissaF0D type definition ------------------------------*/
+/*-----------------------BPy_GetCurvilinearAbscissaF0D type definition --------------------------*/
PyTypeObject GetCurvilinearAbscissaF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "GetCurvilinearAbscissaF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp
index 3cf5efc59d7..21e05323b07 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp
@@ -67,7 +67,7 @@ static int GetViewMapGradientNormF0D___init__(BPy_GetViewMapGradientNormF0D *sel
return 0;
}
-/*-----------------------BPy_GetViewMapGradientNormF0D type definition ------------------------------*/
+/*-----------------------BPy_GetViewMapGradientNormF0D type definition --------------------------*/
PyTypeObject GetViewMapGradientNormF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "GetViewMapGradientNormF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp
index a70cf817b46..506aa15e245 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp
@@ -65,7 +65,7 @@ static int ReadCompleteViewMapPixelF0D___init__(BPy_ReadCompleteViewMapPixelF0D
return 0;
}
-/*-----------------------BPy_ReadCompleteViewMapPixelF0D type definition ------------------------------*/
+/*-----------------------BPy_ReadCompleteViewMapPixelF0D type definition ------------------------*/
PyTypeObject ReadCompleteViewMapPixelF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ReadCompleteViewMapPixelF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h
index 6ccfd9764c5..48d36543ca0 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h
@@ -34,7 +34,8 @@ extern PyTypeObject ReadCompleteViewMapPixelF0D_Type;
#define BPy_ReadCompleteViewMapPixelF0D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&ReadCompleteViewMapPixelF0D_Type))
-/*---------------------------Python BPy_ReadCompleteViewMapPixelF0D structure definition----------*/
+/*---------------------------Python BPy_ReadCompleteViewMapPixelF0D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction0DFloat py_uf0D_float;
} BPy_ReadCompleteViewMapPixelF0D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp
index 3dec389f1f1..0eee141f15f 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp
@@ -69,7 +69,7 @@ static int ReadSteerableViewMapPixelF0D___init__(BPy_ReadSteerableViewMapPixelF0
return 0;
}
-/*-----------------------BPy_ReadSteerableViewMapPixelF0D type definition ------------------------------*/
+/*-----------------------BPy_ReadSteerableViewMapPixelF0D type definition -----------------------*/
PyTypeObject ReadSteerableViewMapPixelF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ReadSteerableViewMapPixelF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h
index c0c62a50941..3cff99be633 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h
@@ -34,7 +34,8 @@ extern PyTypeObject ReadSteerableViewMapPixelF0D_Type;
#define BPy_ReadSteerableViewMapPixelF0D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&ReadSteerableViewMapPixelF0D_Type))
-/*---------------------------Python BPy_ReadSteerableViewMapPixelF0D structure definition----------*/
+/*---------------------------Python BPy_ReadSteerableViewMapPixelF0D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction0DFloat py_uf0D_float;
} BPy_ReadSteerableViewMapPixelF0D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp
index f35f6ad7814..0b6a116fa65 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp
@@ -67,7 +67,7 @@ static int QuantitativeInvisibilityF0D___init__(BPy_QuantitativeInvisibilityF0D
return 0;
}
-/*-----------------------BPy_QuantitativeInvisibilityF0D type definition ------------------------------*/
+/*-----------------------BPy_QuantitativeInvisibilityF0D type definition ------------------------*/
PyTypeObject QuantitativeInvisibilityF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "QuantitativeInvisibilityF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h
index 933deb706ee..dd64fb40d85 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h
@@ -34,7 +34,8 @@ extern PyTypeObject QuantitativeInvisibilityF0D_Type;
#define BPy_QuantitativeInvisibilityF0D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&QuantitativeInvisibilityF0D_Type))
-/*---------------------------Python BPy_QuantitativeInvisibilityF0D structure definition----------*/
+/*---------------------------Python BPy_QuantitativeInvisibilityF0D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction0DUnsigned py_uf0D_unsigned;
} BPy_QuantitativeInvisibilityF0D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
index 2bcda9718c3..262fdbc68c6 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
@@ -166,7 +166,7 @@ static PyGetSetDef BPy_UnaryFunction1DEdgeNature_getseters[] = {
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
-/*-----------------------BPy_UnaryFunction1DEdgeNature type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction1DEdgeNature type definition --------------------------*/
PyTypeObject UnaryFunction1DEdgeNature_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DEdgeNature", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
index a28448314cd..37d37db51e4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
@@ -166,7 +166,7 @@ static PyGetSetDef BPy_UnaryFunction1DUnsigned_getseters[] = {
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
-/*-----------------------BPy_UnaryFunction1DUnsigned type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction1DUnsigned type definition ----------------------------*/
PyTypeObject UnaryFunction1DUnsigned_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DUnsigned", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
index f7a80a270b6..eb4974e64fe 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
@@ -190,7 +190,7 @@ static PyGetSetDef BPy_UnaryFunction1DVectorViewShape_getseters[] = {
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
-/*-----------------------BPy_UnaryFunction1DVectorViewShape type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction1DVectorViewShape type definition ---------------------*/
PyTypeObject UnaryFunction1DVectorViewShape_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DVectorViewShape", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
index 92889ddbfd9..2869b364ea6 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
@@ -37,13 +37,15 @@ extern PyTypeObject UnaryFunction1DVectorViewShape_Type;
#define BPy_UnaryFunction1DVectorViewShape_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction1DVectorViewShape_Type))
-/*---------------------------Python BPy_UnaryFunction1DVectorViewShape structure definition----------*/
+/*---------------------------Python BPy_UnaryFunction1DVectorViewShape structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction1D py_uf1D;
UnaryFunction1D<std::vector<ViewShape *>> *uf1D_vectorviewshape;
} BPy_UnaryFunction1DVectorViewShape;
-/*---------------------------Python BPy_UnaryFunction1DVectorViewShape visible prototypes-----------*/
+/*---------------------------Python BPy_UnaryFunction1DVectorViewShape visible
+ * prototypes-----------*/
int UnaryFunction1DVectorViewShape_Init(PyObject *module);
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp
index 419ea1f54a9..4b2f444f719 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp
@@ -84,7 +84,7 @@ static int GetCompleteViewMapDensityF1D___init__(BPy_GetCompleteViewMapDensityF1
return 0;
}
-/*-----------------------BPy_GetCompleteViewMapDensityF1D type definition ------------------------------*/
+/*-----------------------BPy_GetCompleteViewMapDensityF1D type definition -----------------------*/
PyTypeObject GetCompleteViewMapDensityF1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "GetCompleteViewMapDensityF1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h
index c0a78e89551..dacfb33553e 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h
@@ -34,7 +34,8 @@ extern PyTypeObject GetCompleteViewMapDensityF1D_Type;
#define BPy_GetCompleteViewMapDensityF1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&GetCompleteViewMapDensityF1D_Type))
-/*---------------------------Python BPy_GetCompleteViewMapDensityF1D structure definition----------*/
+/*---------------------------Python BPy_GetCompleteViewMapDensityF1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction1DDouble py_uf1D_double;
} BPy_GetCompleteViewMapDensityF1D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp
index 58290f6b45f..8b31c31a4a4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp
@@ -91,7 +91,7 @@ static int GetDirectionalViewMapDensityF1D___init__(BPy_GetDirectionalViewMapDen
return 0;
}
-/*-----------------------BPy_GetDirectionalViewMapDensityF1D type definition ------------------------------*/
+/*-----------------------BPy_GetDirectionalViewMapDensityF1D type definition --------------------*/
PyTypeObject GetDirectionalViewMapDensityF1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "GetDirectionalViewMapDensityF1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h
index d78ffe84381..b039fadcdca 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h
@@ -34,7 +34,8 @@ extern PyTypeObject GetDirectionalViewMapDensityF1D_Type;
#define BPy_GetDirectionalViewMapDensityF1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&GetDirectionalViewMapDensityF1D_Type))
-/*---------------------------Python BPy_GetDirectionalViewMapDensityF1D structure definition----------*/
+/*---------------------------Python BPy_GetDirectionalViewMapDensityF1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction1DDouble py_uf1D_double;
} BPy_GetDirectionalViewMapDensityF1D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp
index a112dee15c7..615faed2282 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp
@@ -81,7 +81,7 @@ static int GetSteerableViewMapDensityF1D___init__(BPy_GetSteerableViewMapDensity
return 0;
}
-/*-----------------------BPy_GetSteerableViewMapDensityF1D type definition ------------------------------*/
+/*-----------------------BPy_GetSteerableViewMapDensityF1D type definition ----------------------*/
PyTypeObject GetSteerableViewMapDensityF1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "GetSteerableViewMapDensityF1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h
index c4881a79649..47f168af2a8 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h
@@ -33,7 +33,8 @@ extern PyTypeObject GetSteerableViewMapDensityF1D_Type;
#define BPy_GetSteerableViewMapDensityF1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&GetSteerableViewMapDensityF1D_Type))
-/*---------------------------Python BPy_GetSteerableViewMapDensityF1D structure definition----------*/
+/*---------------------------Python BPy_GetSteerableViewMapDensityF1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction1DDouble py_uf1D_double;
} BPy_GetSteerableViewMapDensityF1D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp
index b2bb2947be7..7e77e79af63 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp
@@ -81,7 +81,7 @@ static int GetViewMapGradientNormF1D___init__(BPy_GetViewMapGradientNormF1D *sel
return 0;
}
-/*-----------------------BPy_GetViewMapGradientNormF1D type definition ------------------------------*/
+/*-----------------------BPy_GetViewMapGradientNormF1D type definition --------------------------*/
PyTypeObject GetViewMapGradientNormF1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "GetViewMapGradientNormF1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp
index f955c90842a..bce95e50048 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp
@@ -72,7 +72,7 @@ static int QuantitativeInvisibilityF1D___init__(BPy_QuantitativeInvisibilityF1D
return 0;
}
-/*-----------------------BPy_QuantitativeInvisibilityF1D type definition ------------------------------*/
+/*-----------------------BPy_QuantitativeInvisibilityF1D type definition ------------------------*/
PyTypeObject QuantitativeInvisibilityF1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "QuantitativeInvisibilityF1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h
index 35cd9e779bd..0d4d118995b 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h
@@ -34,7 +34,8 @@ extern PyTypeObject QuantitativeInvisibilityF1D_Type;
#define BPy_QuantitativeInvisibilityF1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&QuantitativeInvisibilityF1D_Type))
-/*---------------------------Python BPy_QuantitativeInvisibilityF1D structure definition----------*/
+/*---------------------------Python BPy_QuantitativeInvisibilityF1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction1DUnsigned py_uf1D_unsigned;
} BPy_QuantitativeInvisibilityF1D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp
index 3aa694a5739..04d724b7862 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp
@@ -59,7 +59,7 @@ static int IncrementChainingTimeStampF1D___init__(BPy_IncrementChainingTimeStamp
return 0;
}
-/*-----------------------BPy_IncrementChainingTimeStampF1D type definition ------------------------------*/
+/*-----------------------BPy_IncrementChainingTimeStampF1D type definition ----------------------*/
PyTypeObject IncrementChainingTimeStampF1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "IncrementChainingTimeStampF1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h
index 3030528a49b..0d74b1f7756 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h
@@ -34,7 +34,8 @@ extern PyTypeObject IncrementChainingTimeStampF1D_Type;
#define BPy_IncrementChainingTimeStampF1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&IncrementChainingTimeStampF1D_Type))
-/*---------------------------Python BPy_IncrementChainingTimeStampF1D structure definition----------*/
+/*---------------------------Python BPy_IncrementChainingTimeStampF1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction1DVoid py_uf1D_void;
} BPy_IncrementChainingTimeStampF1D;
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
index f3b6a71585f..fb42b29f9ee 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
@@ -62,7 +62,7 @@ static int EqualToChainingTimeStampUP1D___init__(BPy_EqualToChainingTimeStampUP1
return 0;
}
-/*-----------------------BPy_EqualToChainingTimeStampUP1D type definition ------------------------------*/
+/*-----------------------BPy_EqualToChainingTimeStampUP1D type definition -----------------------*/
PyTypeObject EqualToChainingTimeStampUP1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "EqualToChainingTimeStampUP1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h
index eab08c6588d..e2ba8b7709b 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h
@@ -34,7 +34,8 @@ extern PyTypeObject EqualToChainingTimeStampUP1D_Type;
#define BPy_EqualToChainingTimeStampUP1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&EqualToChainingTimeStampUP1D_Type))
-/*---------------------------Python BPy_EqualToChainingTimeStampUP1D structure definition----------*/
+/*---------------------------Python BPy_EqualToChainingTimeStampUP1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryPredicate1D py_up1D;
} BPy_EqualToChainingTimeStampUP1D;
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
index 885ecb16695..907a86477e3 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
@@ -66,7 +66,7 @@ static int QuantitativeInvisibilityUP1D___init__(BPy_QuantitativeInvisibilityUP1
return 0;
}
-/*-----------------------BPy_QuantitativeInvisibilityUP1D type definition ------------------------------*/
+/*-----------------------BPy_QuantitativeInvisibilityUP1D type definition -----------------------*/
PyTypeObject QuantitativeInvisibilityUP1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "QuantitativeInvisibilityUP1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h
index 879c6c5b7be..bbb1dce5ed1 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h
@@ -34,7 +34,8 @@ extern PyTypeObject QuantitativeInvisibilityUP1D_Type;
#define BPy_QuantitativeInvisibilityUP1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&QuantitativeInvisibilityUP1D_Type))
-/*---------------------------Python BPy_QuantitativeInvisibilityUP1D structure definition----------*/
+/*---------------------------Python BPy_QuantitativeInvisibilityUP1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryPredicate1D py_up1D;
} BPy_QuantitativeInvisibilityUP1D;
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
index 83672199e37..2a38e6ffcc6 100644
--- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
@@ -99,13 +99,11 @@ class IndexedFaceSet : public Rep {
* iMISize
* The size of iMIndices
* iTIndices
- * The Texture coordinates indices (per vertex). The integers contained in this array must be multiple of 2.
- * iTISize
- * The size of iMIndices
- * iCopy
- * 0 : the arrays are not copied. The pointers passed as arguments are used. IndexedFaceSet takes these
- * arrays desallocation in charge.
- * 1 : the arrays are copied. The caller is in charge of the arrays, passed as arguments desallocation.
+ * The Texture coordinates indices (per vertex). The integers contained in this array must
+ * be multiple of 2. iTISize The size of iMIndices iCopy 0 : the arrays are not copied. The
+ * pointers passed as arguments are used. IndexedFaceSet takes these arrays desallocation in
+ * charge. 1 : the arrays are copied. The caller is in charge of the arrays, passed as arguments
+ * desallocation.
*/
IndexedFaceSet(float *iVertices,
unsigned iVSize,
diff --git a/source/blender/freestyle/intern/scene_graph/Node.h b/source/blender/freestyle/intern/scene_graph/Node.h
index a9424fe14d2..2e0e94ed5de 100644
--- a/source/blender/freestyle/intern/scene_graph/Node.h
+++ b/source/blender/freestyle/intern/scene_graph/Node.h
@@ -19,7 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Abstract class for scene graph nodes. Inherits from BaseObject which defines the addRef release mechanism.
+ * \brief Abstract class for scene graph nodes. Inherits from BaseObject which defines the addRef
+ * release mechanism.
*/
#include "SceneVisitor.h"
diff --git a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp
index 2564a462407..75acccef666 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp
@@ -16,7 +16,8 @@
/** \file
* \ingroup freestyle
- * \brief Class to define a Drawing Style to be applied to the underlying children. Inherits from NodeGroup.
+ * \brief Class to define a Drawing Style to be applied to the underlying children. Inherits from
+ * NodeGroup.
*/
#include "NodeDrawingStyle.h"
diff --git a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
index ea617a912f6..f1dfad06250 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
@@ -19,7 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Class to define a Drawing Style to be applied to the underlying children. Inherits from NodeGroup.
+ * \brief Class to define a Drawing Style to be applied to the underlying children. Inherits from
+ * NodeGroup.
*/
#include "DrawingStyle.h"
diff --git a/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp b/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
index 204e5e1c60e..7ea495c4166 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
@@ -17,7 +17,8 @@
/** \file
* \ingroup freestyle
* \brief Class to represent a group node. This node can contains several children.
- * \brief It also contains a transform matrix indicating the transform state of the underlying children.
+ * \brief It also contains a transform matrix indicating the transform state of the underlying
+ * children.
*/
#include "NodeGroup.h"
@@ -36,10 +37,9 @@ void NodeGroup::AddChild(Node *iChild)
int NodeGroup::destroy()
{
/*! Node::destroy makes a release on the object and then returns the reference counter.
- * If the reference counter is equal to 0, that means that nobody else is linking this node group and
- * that we can destroy the whole underlying tree.
- * Else, one or several Node link this node group, and we only returns the reference counter
- * decremented by Node::destroy();
+ * If the reference counter is equal to 0, that means that nobody else is linking this node
+ * group and that we can destroy the whole underlying tree. Else, one or several Node link this
+ * node group, and we only returns the reference counter decremented by Node::destroy();
*/
int refThis = Node::destroy();
diff --git a/source/blender/freestyle/intern/scene_graph/NodeGroup.h b/source/blender/freestyle/intern/scene_graph/NodeGroup.h
index 89f81cc2b13..f40deb13a3e 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeGroup.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeGroup.h
@@ -20,7 +20,8 @@
/** \file
* \ingroup freestyle
* \brief Class to represent a group node. This node can contains several children.
- * \brief It also contains a transform matrix indicating the transform state of the underlying children.
+ * \brief It also contains a transform matrix indicating the transform state of the underlying
+ * children.
*/
#include <vector>
diff --git a/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp b/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp
index 69179eb6c84..5452c233e2c 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp
@@ -35,7 +35,7 @@ void NodeTransform::Translate(real x, real y, real z)
void NodeTransform::Rotate(real iAngle, real x, real y, real z)
{
- //Normalize the x,y,z vector;
+ // Normalize the x,y,z vector;
real norm = (real)sqrt(x * x + y * y + z * z);
if (0 == norm)
return;
diff --git a/source/blender/freestyle/intern/scene_graph/Rep.cpp b/source/blender/freestyle/intern/scene_graph/Rep.cpp
index 94f6e1fa9d3..5b49243faef 100644
--- a/source/blender/freestyle/intern/scene_graph/Rep.cpp
+++ b/source/blender/freestyle/intern/scene_graph/Rep.cpp
@@ -16,7 +16,8 @@
/** \file
* \ingroup freestyle
- * \brief Base class for all shapes. Inherits from BasicObjects for references counter management (addRef, release).
+ * \brief Base class for all shapes. Inherits from BasicObjects for references counter management
+ * (addRef, release).
*/
#include "Rep.h"
diff --git a/source/blender/freestyle/intern/scene_graph/Rep.h b/source/blender/freestyle/intern/scene_graph/Rep.h
index 7b5e752ea07..22078422af6 100644
--- a/source/blender/freestyle/intern/scene_graph/Rep.h
+++ b/source/blender/freestyle/intern/scene_graph/Rep.h
@@ -19,7 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Base class for all shapes. Inherits from BasicObjects for references counter management (addRef, release).
+ * \brief Base class for all shapes.
+ * Inherits from BasicObjects for references counter management (addRef, release).
*/
#include <string>
@@ -111,8 +112,8 @@ class Rep : public BaseObject {
}
/*! Computes the rep bounding box.
- * Each Inherited rep must compute its bbox depending on the way the data are stored. So, each inherited class
- * must overload this method
+ * Each Inherited rep must compute its bbox depending on the way the data are stored. So, each
+ * inherited class must overload this method
*/
virtual void ComputeBBox() = 0;
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
index 24c710bd163..dcab48fd12f 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
@@ -38,15 +38,15 @@ namespace Functions0D {
// DensityF0D
/*! Returns the density of the (result) image evaluated at an Interface0D.
- * This density is evaluated using a pixels square window around the evaluation point and integrating
- * these values using a gaussian.
+ * This density is evaluated using a pixels square window around the evaluation point and
+ * integrating these values using a gaussian.
*/
class DensityF0D : public UnaryFunction0D<double> {
public:
/*! Builds the functor from the gaussian sigma value.
* \param sigma:
- * sigma indicates the x value for which the gaussian function is 0.5. It leads to the window size value.
- * (the larger, the smoother)
+ * sigma indicates the x value for which the gaussian function is 0.5.
+ * It leads to the window size value. (the larger, the smoother)
*/
DensityF0D(double sigma = 2) : UnaryFunction0D<double>()
{
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp
index eadc8993dc6..fd97138c91b 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp
@@ -104,14 +104,14 @@ int GetSteerableViewMapDensityF1D::operator()(Interface1D &inter)
int GetDirectionalViewMapDensityF1D::operator()(Interface1D &inter)
{
- //soc unsigned size;
+ // soc unsigned size;
result = integrate(_fun, inter.pointsBegin(_sampling), inter.pointsEnd(_sampling), _integration);
return 0;
}
int GetCompleteViewMapDensityF1D::operator()(Interface1D &inter)
{
- //soc unsigned size;
+ // soc unsigned size;
/* Id id = inter.getId(); */ /* UNUSED */
result = integrate(_fun, inter.pointsBegin(_sampling), inter.pointsEnd(_sampling), _integration);
return 0;
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
index 76a70d4f50d..a1fd3fb2665 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
@@ -37,8 +37,9 @@ namespace Functions1D {
// DensityF1D
/*! Returns the density evaluated for an Interface1D.
- * The density is evaluated for a set of points along the Interface1D (using the DensityF0D functor) with a
- * user-defined sampling and then integrated into a single value using a user-defined integration method.
+ * The density is evaluated for a set of points along the Interface1D (using the DensityF0D
+ * functor) with a user-defined sampling and then integrated into a single value using a
+ * user-defined integration method.
*/
class DensityF1D : public UnaryFunction1D<double> {
private:
@@ -51,9 +52,9 @@ class DensityF1D : public UnaryFunction1D<double> {
* \param iType:
* The integration method used to compute a single value from a set of values.
* \param sampling:
- * The resolution used to sample the chain: the corresponding 0D function is evaluated at each sample point and
- * the result is obtained by combining the resulting values into a single one, following the method specified
- * by iType.
+ * The resolution used to sample the chain: the corresponding 0D function is evaluated at each
+ * sample point and the result is obtained by combining the resulting values into a single one,
+ * following the method specified by iType.
*/
DensityF1D(double sigma = 2, IntegrationType iType = MEAN, float sampling = 2.0f)
: UnaryFunction1D<double>(iType), _fun(sigma)
@@ -86,8 +87,9 @@ class DensityF1D : public UnaryFunction1D<double> {
// LocalAverageDepthF1D
/*! Returns the average depth evaluated for an Interface1D.
- * The average depth is evaluated for a set of points along the Interface1D (using the LocalAverageDepthF0D functor)
- * with a user-defined sampling and then integrated into a single value using a user-defined integration method.
+ * The average depth is evaluated for a set of points along the Interface1D (using the
+ * LocalAverageDepthF0D functor) with a user-defined sampling and then integrated into a single
+ * value using a user-defined integration method.
*/
class LocalAverageDepthF1D : public UnaryFunction1D<double> {
public:
@@ -121,8 +123,9 @@ class LocalAverageDepthF1D : public UnaryFunction1D<double> {
// GetCompleteViewMapDensity
/*! Returns the density evaluated for an Interface1D in the complete viewmap image.
- * The density is evaluated for a set of points along the Interface1D (using the ReadCompleteViewMapPixelF0D functor)
- * and then integrated into a single value using a user-defined integration method.
+ * The density is evaluated for a set of points along the Interface1D (using the
+ * ReadCompleteViewMapPixelF0D functor) and then integrated into a single value using a
+ * user-defined integration method.
*/
class GetCompleteViewMapDensityF1D : public UnaryFunction1D<double> {
public:
@@ -162,7 +165,8 @@ class GetCompleteViewMapDensityF1D : public UnaryFunction1D<double> {
// GetDirectionalViewMapDensity
/*! Returns the density evaluated for an Interface1D in of the steerable viewmaps image.
* The direction telling which Directional map to choose is explicitly specified by the user.
- * The density is evaluated for a set of points along the Interface1D (using the ReadSteerableViewMapPixelF0D functor)
+ * The density is evaluated for a set of points along the Interface1D
+ * (using the ReadSteerableViewMapPixelF0D functor)
* and then integrated into a single value using a user-defined integration method.
*/
class GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double> {
@@ -175,9 +179,9 @@ class GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double> {
* \param iType:
* The integration method used to compute a single value from a set of values.
* \param sampling:
- * The resolution used to sample the chain: the corresponding 0D function is evaluated at each sample point and
- * the result is obtained by combining the resulting values into a single one, following the method specified
- * by iType.
+ * The resolution used to sample the chain: the corresponding 0D function is evaluated at
+ * each sample point and the result is obtained by combining the resulting values into a
+ * single one, following the method specified by iType.
*/
GetDirectionalViewMapDensityF1D(unsigned iOrientation,
unsigned level,
@@ -203,8 +207,8 @@ class GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double> {
};
// GetSteerableViewMapDensityF1D
-/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is evaluated
- * in the proper steerable ViewMap depending on its oorientation.
+/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is
+ * evaluated in the proper steerable ViewMap depending on its oorientation.
*/
class GetSteerableViewMapDensityF1D : public UnaryFunction1D<double> {
private:
@@ -218,9 +222,9 @@ class GetSteerableViewMapDensityF1D : public UnaryFunction1D<double> {
* \param iType:
* The integration method used to compute a single value from a set of values.
* \param sampling:
- * The resolution used to sample the chain: the corresponding 0D function is evaluated at each sample point and
- * the result is obtained by combining the resulting values into a single one, following the method specified
- * by iType.
+ * The resolution used to sample the chain: the corresponding 0D function is evaluated at each
+ * sample point and the result is obtained by combining the resulting values into a single one,
+ * following the method specified by iType.
*/
GetSteerableViewMapDensityF1D(int level, IntegrationType iType = MEAN, float sampling = 2.0f)
: UnaryFunction1D<double>(iType)
@@ -245,8 +249,8 @@ class GetSteerableViewMapDensityF1D : public UnaryFunction1D<double> {
};
// GetViewMapGradientNormF1D
-/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is evaluated in
- * the proper steerable ViewMap depending on its oorientation.
+/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is
+ * evaluated in the proper steerable ViewMap depending on its oorientation.
*/
class GetViewMapGradientNormF1D : public UnaryFunction1D<double> {
private:
@@ -261,9 +265,9 @@ class GetViewMapGradientNormF1D : public UnaryFunction1D<double> {
* \param iType:
* The integration method used to compute a single value from a set of values.
* \param sampling:
- * The resolution used to sample the chain: the corresponding 0D function is evaluated at each sample point and
- * the result is obtained by combining the resulting values into a single one, following the method specified
- * by iType.
+ * The resolution used to sample the chain: the corresponding 0D function is evaluated at each
+ * sample point and the result is obtained by combining the resulting values into a single
+ * one, following the method specified by iType.
*/
GetViewMapGradientNormF1D(int level, IntegrationType iType = MEAN, float sampling = 2.0f)
: UnaryFunction1D<double>(iType), _func(level)
diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
index a7883187066..6a0d3b0b793 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
@@ -261,7 +261,7 @@ void Smoother::iteration()
edgeStopping(diffC2, _anisoCurvature) *
diffC2; //_factorCurvatureDifference;
motionCurvature *= _factorCurvatureDifference;
- //motionCurvature = _factorCurvatureDifference * (diffC1 + diffC2);
+ // motionCurvature = _factorCurvatureDifference * (diffC1 + diffC2);
if (_safeTest)
_vertex[i] = Vec2r(_vertex[i] + (motionNormal + motionCurvature) * _normal[i]);
Vec2r v1(_vertex[i - 1] - _vertex[i]);
@@ -283,7 +283,7 @@ void Smoother::iteration()
edgeStopping(diffC2, _anisoCurvature) *
diffC2; //_factorCurvatureDifference;
motionCurvature *= _factorCurvatureDifference;
- //motionCurvature = _factorCurvatureDifference * (diffC1 + diffC2);
+ // motionCurvature = _factorCurvatureDifference * (diffC1 + diffC2);
_vertex[0] = Vec2r(_vertex[0] + (motionNormal + motionCurvature) * _normal[0]);
_vertex[_nbVertices - 1] = _vertex[0];
}
diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
index 17b180531a2..8f05db28194 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
@@ -27,9 +27,9 @@
namespace Freestyle {
/*! [ Thickness Shader ].
- * Assigns thicknesses to the stroke vertices so that the stroke looks like made with a calligraphic tool.
- * i.e. The stroke will be the thickest in a main direction, the thinest in the direction perpendicular to this one,
- * and an interpolation inbetween.
+ * Assigns thicknesses to the stroke vertices so that the stroke looks like made with a
+ * calligraphic tool. i.e. The stroke will be the thickest in a main direction, the thinest in the
+ * direction perpendicular to this one, and an interpolation inbetween.
*/
class CalligraphicShader : public StrokeShader {
public:
@@ -103,9 +103,9 @@ class SpatialNoiseShader : public StrokeShader {
/*! [ Geometry Shader ].
* Smoothes the stroke.
* (Moves the vertices to make the stroke smoother).
- * Uses curvature flow to converge towards a curve of constant curvature. The diffusion method we use is anisotropic
- * to prevent the diffusion accross corners.
- * \see \htmlonly <a href=/smoothing/smoothing.html>smoothing/smoothing.html</a> \endhtmlonly
+ * Uses curvature flow to converge towards a curve of constant curvature. The diffusion method we
+ * use is anisotropic to prevent the diffusion accross corners. \see \htmlonly <a
+ * href=/smoothing/smoothing.html>smoothing/smoothing.html</a> \endhtmlonly
*/
class SmoothingShader : public StrokeShader {
public:
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
index 15541c1f438..9bdad9f1b32 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
@@ -57,7 +57,8 @@ int ConstantThicknessShader::shade(Stroke &stroke) const
int i = 0;
int size = stroke.strokeVerticesSize();
for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) {
- // XXX What's the use of i here? And is not the thickness always overriden by the last line of the loop?
+ // XXX What's the use of i here? And is not the thickness always overriden by the last line of
+ // the loop?
if ((1 == i) || (size - 2 == i))
v->attribute().setThickness(_thickness / 4.0, _thickness / 4.0);
if ((0 == i) || (size - 1 == i))
@@ -74,7 +75,8 @@ int ConstantExternThicknessShader::shade(Stroke &stroke) const
int i = 0;
int size = stroke.strokeVerticesSize();
for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) {
- // XXX What's the use of i here? And is not the thickness always overriden by the last line of the loop?
+ // XXX What's the use of i here? And is not the thickness always overriden by the last line of
+ // the loop?
if ((1 == i) || (size - 2 == i))
v->attribute().setThickness(_thickness / 2.0, 0);
if ((0 == i) || (size - 1 == i))
@@ -109,7 +111,8 @@ int ConstrainedIncreasingThicknessShader::shade(Stroke &stroke) const
StrokeInternal::StrokeVertexIterator v, vend;
for (i = 0, v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend;
++v, ++i) {
- // XXX Why not using an if/else here? Else, if last condition is true, everything else is computed for nothing!
+ // XXX Why not using an if/else here? Else, if last condition is true, everything else is
+ // computed for nothing!
float t;
if (i < (float)n / 2.0f)
t = (1.0 - (float)i / (float)n) * _ThicknessMin + (float)i / (float)n * maxT;
@@ -140,7 +143,8 @@ int LengthDependingThicknessShader::shade(Stroke &stroke) const
int i = 0;
int size = stroke.strokeVerticesSize();
for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) {
- // XXX What's the use of i here? And is not the thickness always overriden by the last line of the loop?
+ // XXX What's the use of i here? And is not the thickness always overriden by the last line of
+ // the loop?
if ((1 == i) || (size - 2 == i))
v->attribute().setThickness(thickness / 4.0, thickness / 4.0);
if ((0 == i) || (size - 1 == i))
@@ -337,7 +341,7 @@ int SamplingShader::shade(Stroke &stroke) const
int ExternalContourStretcherShader::shade(Stroke &stroke) const
{
- //float l = stroke.getLength2D();
+ // float l = stroke.getLength2D();
Interface0DIterator it;
Functions0D::Normal2DF0D fun;
StrokeVertex *sv;
@@ -362,7 +366,7 @@ int BezierCurveShader::shade(Stroke &stroke) const
// Build the Bezier curve from this set of data points:
vector<Vec2d> data;
StrokeInternal::StrokeVertexIterator v = stroke.strokeVerticesBegin(), vend;
- data.push_back(Vec2d(v->x(), v->y())); //first one
+ data.push_back(Vec2d(v->x(), v->y())); // first one
StrokeInternal::StrokeVertexIterator previous = v;
++v;
for (vend = stroke.strokeVerticesEnd(); v != vend; ++v) {
@@ -562,7 +566,7 @@ int PolygonalizationShader::shade(Stroke &stroke) const
Vec2d u = (*cp)->B - (*cp)->A;
Vec2d n(u[1], -u[0]);
n.normalize();
- //Vec2d n(0, 0);
+ // Vec2d n(0, 0);
float offset = ((*cp)->_error);
StrokeInternal::StrokeVertexIterator v;
for (v = a; v != b; ++v) {
@@ -653,7 +657,7 @@ int TipRemoverShader::shade(Stroke &stroke) const
// Resample so that our new stroke have the same number of vertices than before
stroke.Resample(originalSize);
- if ((int)stroke.strokeVerticesSize() != originalSize) //soc
+ if ((int)stroke.strokeVerticesSize() != originalSize) // soc
cerr << "Warning: resampling problem" << endl;
// assign old attributes to new stroke vertices:
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
index e128817ffa5..db5738449e6 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
@@ -81,9 +81,9 @@ class ConstantThicknessShader : public StrokeShader {
};
/* [ Thickness Shader ].
- * Assigns an absolute constant external thickness to every vertices of the Stroke. The external thickness of a point
- * is its thickness from the point to the strip border in the direction pointing outside the object the
- * Stroke delimitates.
+ * Assigns an absolute constant external thickness to every vertices of the Stroke. The external
+ * thickness of a point is its thickness from the point to the strip border in the direction
+ * pointing outside the object the Stroke delimitates.
*/
class ConstantExternThicknessShader : public StrokeShader {
public:
@@ -108,10 +108,10 @@ class ConstantExternThicknessShader : public StrokeShader {
};
/*! [ Thickness Shader ].
- * Assigns thicknesses values such as the thickness increases from a thickness value A to a thickness value B between
- * the first vertex to the midpoint vertex and then decreases from B to a A between this midpoint vertex
- * and the last vertex.
- * The thickness is linearly interpolated from A to B.
+ * Assigns thicknesses values such as the thickness increases from a thickness value A to a
+ * thickness value B between the first vertex to the midpoint vertex and then decreases from B to a
+ * A between this midpoint vertex and the last vertex. The thickness is linearly interpolated from
+ * A to B.
*/
class IncreasingThicknessShader : public StrokeShader {
public:
@@ -146,8 +146,8 @@ class IncreasingThicknessShader : public StrokeShader {
};
/*! [ Thickness shader ].
- * Same as previous but here we allow the user to control the ratio thickness/length so that we don't get
- * fat short lines
+ * Same as previous but here we allow the user to control the ratio thickness/length so that we
+ * don't get fat short lines
*/
class ConstrainedIncreasingThicknessShader : public StrokeShader {
private:
@@ -288,8 +288,8 @@ class ConstantColorShader : public StrokeShader {
/*! [ Color Shader ].
* Assigns a varying color to the stroke.
- * The user specifies 2 colors A and B. The stroke color will change linearly from A to B between the
- * first and the last vertex.
+ * The user specifies 2 colors A and B. The stroke color will change linearly from A to B between
+ * the first and the last vertex.
*/
class IncreasingColorShader : public StrokeShader {
private:
@@ -346,7 +346,8 @@ class IncreasingColorShader : public StrokeShader {
};
/* [ Color Shader ].
- * Assigns a color to the stroke depending on the material of the shape to which ot belongs to. (Disney shader)
+ * Assigns a color to the stroke depending on the material of the shape to which ot belongs to.
+ * (Disney shader)
*/
class MaterialColorShader : public StrokeShader {
private:
@@ -399,7 +400,8 @@ class ColorNoiseShader : public StrokeShader {
//
///////////////////////////////////////////////////////////////////////////////
/*! [ Geometry Shader ].
- * Stretches the stroke at its two extremities and following the respective directions: v(1)v(0) and v(n-1)v(n).
+ * Stretches the stroke at its two extremities and following the respective directions: v(1)v(0)
+ * and v(n-1)v(n).
*/
class BackboneStretcherShader : public StrokeShader {
private:
@@ -471,9 +473,9 @@ class ExternalContourStretcherShader : public StrokeShader {
// Bezier curve stroke shader
/*! [ Geometry Shader ].
- * Transforms the stroke backbone geometry so that it corresponds to a Bezier Curve approximation of the
- * original backbone geometry.
- * \see \htmlonly <a href=bezier/bezier.html>bezier/bezier.html</a> \endhtmlonly
+ * Transforms the stroke backbone geometry so that it corresponds to a Bezier Curve approximation
+ * of the original backbone geometry. \see \htmlonly <a
+ * href=bezier/bezier.html>bezier/bezier.html</a> \endhtmlonly
*/
class BezierCurveShader : public StrokeShader {
private:
@@ -501,8 +503,9 @@ class BezierCurveShader : public StrokeShader {
/*! [ Geometry Shader ].
* Shader to modify the Stroke geometry so that it looks more "polygonal".
- * The basic idea is to start from the minimal stroke approximation consisting in a line joining the first vertex
- * to the last one and to subdivide using the original stroke vertices until a certain error is reached.
+ * The basic idea is to start from the minimal stroke approximation consisting in a line joining
+ * the first vertex to the last one and to subdivide using the original stroke vertices until a
+ * certain error is reached.
*/
class PolygonalizationShader : public StrokeShader {
private:
@@ -511,9 +514,9 @@ class PolygonalizationShader : public StrokeShader {
public:
/*! Builds the shader.
* \param iError:
- * The error we want our polygonal approximation to have with respect to the original geometry.
- * The smaller, the closer the new stroke to the orinal one.
- * This error corresponds to the maximum distance between the new stroke and the old one.
+ * The error we want our polygonal approximation to have with respect to the original
+ * geometry. The smaller, the closer the new stroke to the orinal one. This error corresponds to
+ * the maximum distance between the new stroke and the old one.
*/
PolygonalizationShader(float iError) : StrokeShader()
{
@@ -542,8 +545,9 @@ class GuidingLinesShader : public StrokeShader {
public:
/*! Builds a Guiding Lines shader
* \param iOffset:
- * The line that replaces the stroke is initially in the middle of the initial stroke "bbox".
- * iOffset is the value of the displacement which is applied to this line along its normal.
+ * The line that replaces the stroke is initially in the middle of the initial stroke
+ * "bbox". iOffset is the value of the displacement which is applied to this line along its
+ * normal.
*/
GuidingLinesShader(float iOffset) : StrokeShader()
{
diff --git a/source/blender/freestyle/intern/stroke/Canvas.cpp b/source/blender/freestyle/intern/stroke/Canvas.cpp
index b497b470492..95bbafc0aa0 100644
--- a/source/blender/freestyle/intern/stroke/Canvas.cpp
+++ b/source/blender/freestyle/intern/stroke/Canvas.cpp
@@ -38,8 +38,8 @@
#include "BKE_global.h"
-//soc #include <qimage.h>
-//soc #include <QString>
+// soc #include <qimage.h>
+// soc #include <QString>
extern "C" {
#include "IMB_imbuf.h"
@@ -325,7 +325,7 @@ void Canvas::loadMap(const char *iFileName,
filePath = iFileName;
}
-#if 0 //soc
+#if 0 // soc
QImage *qimg;
QImage newMap(filePath.c_str());
if (newMap.isNull()) {
@@ -402,7 +402,7 @@ void Canvas::loadMap(const char *iFileName,
GaussianPyramid *pyramid = new GaussianPyramid(tmp, iNbLevels, iSigma);
int ow = pyramid->width(0);
int oh = pyramid->height(0);
- string base(iMapName); //soc
+ string base(iMapName); // soc
for (int i = 0; i < pyramid->getNumberOfLevels(); ++i) {
// save each image:
#if 0
@@ -410,19 +410,19 @@ void Canvas::loadMap(const char *iFileName,
h = pyramid.height(i);
#endif
- //soc QImage qtmp(ow, oh, QImage::Format_RGB32);
+ // soc QImage qtmp(ow, oh, QImage::Format_RGB32);
ImBuf *qtmp = IMB_allocImBuf(ow, oh, 32, IB_rect);
- //int k = (1 << i);
+ // int k = (1 << i);
for (y = 0; y < oh; ++y) {
for (x = 0; x < ow; ++x) {
int c = pyramid->pixel(x, y, i); // 255 * pyramid->pixel(x, y, i);
- //soc qtmp.setPixel(x, y, qRgb(c, c, c));
+ // soc qtmp.setPixel(x, y, qRgb(c, c, c));
pix = (char *)qtmp->rect + y * rowbytes + x * 4;
pix[0] = pix[1] = pix[2] = c;
}
}
- //soc qtmp.save(base + QString::number(i) + ".bmp", "BMP");
+ // soc qtmp.save(base + QString::number(i) + ".bmp", "BMP");
stringstream filename;
filename << base;
filename << i << ".bmp";
@@ -443,7 +443,7 @@ void Canvas::loadMap(const char *iFileName,
#endif
_maps[iMapName] = pyramid;
- //newMap->save("toto.bmp", "BMP");
+ // newMap->save("toto.bmp", "BMP");
}
float Canvas::readMapPixel(const char *iMapName, int level, int x, int y)
diff --git a/source/blender/freestyle/intern/stroke/Canvas.h b/source/blender/freestyle/intern/stroke/Canvas.h
index e059bb07eda..2a0ebbe17c5 100644
--- a/source/blender/freestyle/intern/stroke/Canvas.h
+++ b/source/blender/freestyle/intern/stroke/Canvas.h
@@ -137,8 +137,8 @@ class Canvas {
}
/* Maps management */
- /*! Loads an image map. The map will be scaled (without preserving the ratio in order to fit the actual
- * canvas size.).
+ /*! Loads an image map. The map will be scaled
+ * (without preserving the ratio in order to fit the actual canvas size.).
* The image must be a gray values image...
* \param iFileName:
* The name of the image file
@@ -160,9 +160,11 @@ class Canvas {
* \param level:
* The level of the pyramid from which the pixel must be read.
* \param x:
- * The abscissa of the desired pixel specified in level0 coordinate system. The origin is the lower left corner.
+ * The abscissa of the desired pixel specified in level0 coordinate system.
+ * The origin is the lower left corner.
* \param y:
- * The ordinate of the desired pixel specified in level0 coordinate system. The origin is the lower left corner.
+ * The ordinate of the desired pixel specified in level0 coordinate system.
+ * The origin is the lower left corner.
*/
float readMapPixel(const char *iMapName, int level, int x, int y);
diff --git a/source/blender/freestyle/intern/stroke/Chain.cpp b/source/blender/freestyle/intern/stroke/Chain.cpp
index 32b3ec2de31..d4cc4fd68c3 100644
--- a/source/blender/freestyle/intern/stroke/Chain.cpp
+++ b/source/blender/freestyle/intern/stroke/Chain.cpp
@@ -76,7 +76,7 @@ void Chain::push_viewedge_back(ViewEdge *iViewEdge, bool orientation)
} while ((v != vend) && (v != vfirst));
if (v == vfirst) {
- //Add last one:
+ // Add last one:
current = (*v)->point2d();
Curve::push_vertex_back(*v);
//_Length += (current - previous).norm();
@@ -138,7 +138,7 @@ void Chain::push_viewedge_front(ViewEdge *iViewEdge, bool orientation)
} while ((v != vend) && (v != vfirst));
if (v == vfirst) {
- //Add last one:
+ // Add last one:
current = (*v)->point2d();
Curve::push_vertex_front(*v);
//_Length += (current - previous).norm();
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
index de6c50fe571..551b9aa4043 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
@@ -143,10 +143,11 @@ int ChainSilhouetteIterator::traverse(const AdjacencyIterator &ait)
return 0;
}
if (nextVertex->getNature() & Nature::NON_T_VERTEX) {
- //soc NonTVertex *nontvertex = (NonTVertex*)nextVertex;
+ // soc NonTVertex *nontvertex = (NonTVertex*)nextVertex;
ViewEdge *newEdge(0);
// we'll try to chain the edges by keeping the same nature...
- // the preseance order is : SILHOUETTE, BORDER, CREASE, MATERIAL_BOUNDARY, EDGE_MARK, SUGGESTIVE, VALLEY, RIDGE
+ // the preseance order is : SILHOUETTE, BORDER, CREASE, MATERIAL_BOUNDARY, EDGE_MARK,
+ // SUGGESTIVE, VALLEY, RIDGE
Nature::EdgeNature natures[8] = {
Nature::SILHOUETTE,
Nature::BORDER,
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.h b/source/blender/freestyle/intern/stroke/ChainingIterators.h
index 57a73c64b3d..52da85ccc58 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.h
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.h
@@ -32,7 +32,7 @@
#include "../view_map/ViewMapIterators.h"
#include "../view_map/ViewMapAdvancedIterators.h"
-//using namespace ViewEdgeInternal;
+// using namespace ViewEdgeInternal;
namespace Freestyle {
@@ -98,7 +98,8 @@ class AdjacencyIterator : public Iterator {
return _internalIterator.isBegin();
}
- /*! Returns true if the current ViewEdge is coming towards the iteration vertex. False otherwise. */
+ /*! Returns true if the current ViewEdge is coming towards the iteration vertex.
+ * False otherwise. */
bool isIncoming() const;
/*! Returns a *pointer* to the pointed ViewEdge. */
@@ -144,14 +145,15 @@ class AdjacencyIterator : public Iterator {
* It makes the works of chaining rules description easier.
* The two main methods that need to overloaded are traverse() and init().
* traverse() tells which ViewEdge to follow, among the adjacent ones.
- * If you specify restriction rules (such as "Chain only ViewEdges of the selection"), they will be included
- * in the adjacency iterator. (i.e, the adjacent iterator will only stop on "valid" edges).
+ * If you specify restriction rules (such as "Chain only ViewEdges of the selection"),
+ * they will be included in the adjacency iterator.
+ * (i.e, the adjacent iterator will only stop on "valid" edges).
*/
class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
protected:
bool _restrictToSelection;
bool _restrictToUnvisited;
- bool _increment; //true if we're currently incrementing, false when decrementing
+ bool _increment; // true if we're currently incrementing, false when decrementing
public:
ViewEdge *result;
@@ -159,13 +161,15 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
/*! Builds a Chaining Iterator from the first ViewEdge used for iteration and its orientation.
* \param iRestrictToSelection:
- * Indicates whether to force the chaining to stay within the set of selected ViewEdges or not.
+ * Indicates whether to force the chaining to stay within
+ * the set of selected ViewEdges or not.
* \param iRestrictToUnvisited:
* Indicates whether a ViewEdge that has already been chained must be ignored ot not.
* \param begin:
* The ViewEdge from which to start the chain.
* \param orientation:
- * The direction to follow to explore the graph. If true, the direction indicated by the first ViewEdge is used.
+ * The direction to follow to explore the graph. If true,
+ * the direction indicated by the first ViewEdge is used.
*/
ChainingIterator(bool iRestrictToSelection = true,
bool iRestrictToUnvisited = true,
@@ -200,17 +204,19 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
*/
virtual int init();
- /*! This method iterates over the potential next ViewEdges and returns the one that will be followed next.
- * returns the next ViewEdge to follow or 0 when the end of the chain is reached.
+ /*! This method iterates over the potential next ViewEdges and returns the one that will be
+ * followed next. returns the next ViewEdge to follow or 0 when the end of the chain is reached.
* \param it:
* The iterator over the ViewEdges adjacent to the end vertex of the current ViewEdge.
- * The Adjacency iterator reflects the restriction rules by only iterating over the valid ViewEdges.
+ * The Adjacency iterator reflects the restriction rules by only iterating over the valid
+ * ViewEdges.
*/
virtual int traverse(const AdjacencyIterator &it);
/* accessors */
- /*! Returns true if the orientation of the current ViewEdge corresponds to its natural orientation */
- //inline bool getOrientation() const {}
+ /*! Returns true if the orientation of the current ViewEdge corresponds to its natural
+ * orientation */
+ // inline bool getOrientation() const {}
/*! Returns the vertex which is the next crossing */
inline ViewVertex *getVertex()
@@ -251,20 +257,23 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
/*! A ViewEdge Iterator used to follow ViewEdges the most naturally.
* For example, it will follow visible ViewEdges of same nature.
- * As soon, as the nature or the visibility changes, the iteration stops (by setting the pointed ViewEdge to 0).
- * In the case of an iteration over a set of ViewEdge that are both Silhouette and Crease, there will be a precedence
- * of the silhouette over the crease criterion.
+ * As soon, as the nature or the visibility changes, the iteration stops (by setting the pointed
+ * ViewEdge to 0). In the case of an iteration over a set of ViewEdge that are both Silhouette
+ * and Crease, there will be a precedence of the silhouette over the crease criterion.
*/
class ChainSilhouetteIterator : public ChainingIterator {
public:
- /*! Builds a ChainSilhouetteIterator from the first ViewEdge used for iteration and its orientation.
+ /*! Builds a ChainSilhouetteIterator from the first ViewEdge used for iteration and its
+ * orientation.
* \param iRestrictToSelection:
- * Indicates whether to force the chaining to stay within the set of selected ViewEdges or not.
+ * Indicates whether to force the chaining to stay within the set of selected ViewEdges or
+ * not.
* \param begin:
* The ViewEdge from where to start the iteration.
* \param orientation:
- * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending ViewVertex of begin.
- * If false, we'll search over the ViewEdges surrounding the ending ViewVertex of begin.
+ * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending
+ * ViewVertex of begin. If false, we'll search over the ViewEdges surrounding the ending
+ * ViewVertex of begin.
*/
ChainSilhouetteIterator(bool iRestrictToSelection = true,
ViewEdge *begin = NULL,
@@ -284,7 +293,8 @@ class ChainSilhouetteIterator : public ChainingIterator {
return "ChainSilhouetteIterator";
}
- /*! This method iterates over the potential next ViewEdges and returns the one that will be followed next.
+ /*! This method iterates over the potential next ViewEdges and returns the one that will be
+ * followed next.
* When reaching the end of a chain, 0 is returned.
*/
virtual int traverse(const AdjacencyIterator &it);
@@ -301,13 +311,14 @@ class ChainSilhouetteIterator : public ChainingIterator {
//
///////////////////////////////////////////////////////////
-/*! A "generic" user-controlled ViewEdge iterator. This iterator is in particular built from a unary predicate and
- * a binary predicate.
- * First, the unary predicate is evaluated for all potential next ViewEdges in order to only keep the ones respecting
- * a certain constraint.
- * Then, the binary predicate is evaluated on the current ViewEdge together with each ViewEdge of the previous
- * selection. The first ViewEdge respecting both the unary predicate and the binary predicate is kept as the next one.
- * If none of the potential next ViewEdge respects these 2 predicates, 0 is returned.
+/*! A "generic" user-controlled ViewEdge iterator. This iterator is in particular built from a
+ * unary predicate and a binary predicate.
+ * First, the unary predicate is evaluated for all potential next ViewEdges in order to only
+ * keep the ones respecting a certain constraint.
+ * Then, the binary predicate is evaluated on the current ViewEdge together with each ViewEdge
+ * of the previous selection. The first ViewEdge respecting both the unary predicate and the
+ * binary predicate is kept as the next one. If none of the potential next ViewEdge respects
+ * these 2 predicates, 0 is returned.
*/
class ChainPredicateIterator : public ChainingIterator {
protected:
@@ -318,14 +329,16 @@ class ChainPredicateIterator : public ChainingIterator {
public:
/*! Builds a ChainPredicateIterator from a starting ViewEdge and its orientation.
* \param iRestrictToSelection:
- * Indicates whether to force the chaining to stay within the set of selected ViewEdges or not.
+ * Indicates whether to force the chaining to stay
+ * within the set of selected ViewEdges or not.
* \param iRestrictToUnvisited:
* Indicates whether a ViewEdge that has already been chained must be ignored ot not.
* \param begin:
* The ViewEdge from where to start the iteration.
* \param orientation:
- * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending ViewVertex of begin.
- * If false, we'll search over the ViewEdges surrounding the ending ViewVertex of begin.
+ * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending
+ * ViewVertex of begin. If false, we'll search over the ViewEdges surrounding the ending
+ * ViewVertex of begin.
*/
ChainPredicateIterator(bool iRestrictToSelection = true,
bool iRestrictToUnvisited = true,
@@ -337,21 +350,24 @@ class ChainPredicateIterator : public ChainingIterator {
_unary_predicate = 0;
}
- /*! Builds a ChainPredicateIterator from a unary predicate, a binary predicate, a starting ViewEdge and
- * its orientation.
+ /*! Builds a ChainPredicateIterator from a unary predicate, a binary predicate, a starting
+ * ViewEdge and its orientation.
* \param iRestrictToSelection:
- * Indicates whether to force the chaining to stay within the set of selected ViewEdges or not.
+ * Indicates whether to force the chaining to stay
+ * within the set of selected ViewEdges or not.
* \param iRestrictToUnvisited:
* Indicates whether a ViewEdge that has already been chained must be ignored ot not.
* \param upred:
* The unary predicate that the next ViewEdge must satisfy.
* \param bpred:
- * The binary predicate that the next ViewEdge must satisfy together with the actual pointed ViewEdge.
+ * The binary predicate that the next ViewEdge must satisfy together with the actual pointed
+ * ViewEdge.
* \param begin:
* The ViewEdge from where to start the iteration.
* \param orientation:
- * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending ViewVertex of begin.
- * If false, we'll search over the ViewEdges surrounding the ending ViewVertex of begin.
+ * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending
+ * ViewVertex of begin. If false, we'll search over the ViewEdges surrounding the ending
+ * ViewVertex of begin.
*/
ChainPredicateIterator(UnaryPredicate1D &upred,
BinaryPredicate1D &bpred,
@@ -385,8 +401,8 @@ class ChainPredicateIterator : public ChainingIterator {
return "ChainPredicateIterator";
}
- /*! This method iterates over the potential next ViewEdges and returns the one that will be followed next.
- * When reaching the end of a chain, 0 is returned.
+ /*! This method iterates over the potential next ViewEdges and returns the one that will be
+ * followed next. When reaching the end of a chain, 0 is returned.
*/
virtual int traverse(const AdjacencyIterator &it);
diff --git a/source/blender/freestyle/intern/stroke/Curve.cpp b/source/blender/freestyle/intern/stroke/Curve.cpp
index a0709b0e2be..fe617646442 100644
--- a/source/blender/freestyle/intern/stroke/Curve.cpp
+++ b/source/blender/freestyle/intern/stroke/Curve.cpp
@@ -527,7 +527,7 @@ Curve::point_iterator Curve::points_begin(float step)
++second;
return point_iterator(
_Vertices.begin(), second, _Vertices.begin(), _Vertices.end(), _nSegments, step, 0.0f, 0.0f);
- //return point_iterator(_Vertices.begin(), second, _nSegments, step, 0.0f, 0.0f);
+ // return point_iterator(_Vertices.begin(), second, _nSegments, step, 0.0f, 0.0f);
}
Curve::const_point_iterator Curve::points_begin(float step) const
@@ -536,7 +536,7 @@ Curve::const_point_iterator Curve::points_begin(float step) const
++second;
return const_point_iterator(
_Vertices.begin(), second, _Vertices.begin(), _Vertices.end(), _nSegments, step, 0.0f, 0.0f);
- //return const_point_iterator(_Vertices.begin(), second, _nSegments, step, 0.0f, 0.0f);
+ // return const_point_iterator(_Vertices.begin(), second, _nSegments, step, 0.0f, 0.0f);
}
Curve::point_iterator Curve::points_end(float step)
@@ -549,7 +549,7 @@ Curve::point_iterator Curve::points_end(float step)
step,
1.0f,
_Length);
- //return point_iterator(_Vertices.end(), _Vertices.end(), _nSegments, step, 1.0f, _Length);
+ // return point_iterator(_Vertices.end(), _Vertices.end(), _nSegments, step, 1.0f, _Length);
}
Curve::const_point_iterator Curve::points_end(float step) const
@@ -562,7 +562,8 @@ Curve::const_point_iterator Curve::points_end(float step) const
step,
1.0f,
_Length);
- //return const_point_iterator(_Vertices.end(), _Vertices.end(), _nSegments, step, 1.0f, _Length);
+ // return const_point_iterator(_Vertices.end(), _Vertices.end(), _nSegments, step, 1.0f,
+ // _Length);
}
// Adavnced Iterators access
diff --git a/source/blender/freestyle/intern/stroke/Curve.h b/source/blender/freestyle/intern/stroke/Curve.h
index 2a1d80f3029..b84ce45fb6d 100644
--- a/source/blender/freestyle/intern/stroke/Curve.h
+++ b/source/blender/freestyle/intern/stroke/Curve.h
@@ -55,10 +55,10 @@ using namespace Geometry;
/*! Class to represent a point of a curve.
* A CurvePoint can be any point of a 1D curve (it doesn't have to be a vertex of the curve).
- * Any Interface1D is built upon ViewEdges, themselves built upon FEdges. Therefore, a curve is basically
- * a polyline made of a list SVertex.
- * Thus, a CurvePoint is built by lineraly interpolating two SVertex.
- * CurvePoint can be used as virtual points while querying 0D information along a curve at a given resolution.
+ * Any Interface1D is built upon ViewEdges, themselves built upon FEdges. Therefore, a curve is
+ * basically a polyline made of a list SVertex. Thus, a CurvePoint is built by lineraly
+ * interpolating two SVertex. CurvePoint can be used as virtual points while querying 0D
+ * information along a curve at a given resolution.
*/
class CurvePoint : public Interface0D {
public: // Implementation of Interface0D
@@ -188,7 +188,7 @@ class CurvePoint : public Interface0D {
SVertex *__A;
SVertex *__B;
float _t2d;
- //float _t3d;
+ // float _t3d;
Vec3r _Point2d;
Vec3r _Point3d;
@@ -216,7 +216,7 @@ class CurvePoint : public Interface0D {
*/
CurvePoint(CurvePoint *iA, CurvePoint *iB, float t2d);
- //CurvePoint(SVertex *iA, SVertex *iB, float t2d, float t3d);
+ // CurvePoint(SVertex *iA, SVertex *iB, float t2d, float t3d);
/*! Copy Constructor. */
CurvePoint(const CurvePoint &iBrother);
@@ -302,12 +302,12 @@ class CurvePoint : public Interface0D {
}
Vec3r normal() const;
- //FrsMaterial material() const;
- //Id shape_id() const;
+ // FrsMaterial material() const;
+ // Id shape_id() const;
const SShape *shape() const;
- //float shape_importance() const;
+ // float shape_importance() const;
- //const unsigned qi() const;
+ // const unsigned qi() const;
occluder_container::const_iterator occluders_begin() const;
occluder_container::const_iterator occluders_end() const;
bool occluders_empty() const;
@@ -564,25 +564,25 @@ class Curve : public Interface1D {
CurveInternal::CurvePointIterator curveVerticesEnd();
// Iterators access
- /*! Returns an Interface0DIterator pointing onto the first vertex of the Curve and that can iterate
- * over the \a vertices of the Curve.
+ /*! Returns an Interface0DIterator pointing onto the first vertex of the Curve and that can
+ * iterate over the \a vertices of the Curve.
*/
virtual Interface0DIterator verticesBegin();
- /*! Returns an Interface0DIterator pointing after the last vertex of the Curve and that can iterate
- * over the \a vertices of the Curve.
+ /*! Returns an Interface0DIterator pointing after the last vertex of the Curve and that can
+ * iterate over the \a vertices of the Curve.
*/
virtual Interface0DIterator verticesEnd();
- /*! Returns an Interface0DIterator pointing onto the first point of the Curve and that can iterate
- * over the \a points of the Curve at any resolution.
- * At each iteration a virtual temporary CurvePoint is created.
+ /*! Returns an Interface0DIterator pointing onto the first point of the Curve and that can
+ * iterate over the \a points of the Curve at any resolution. At each iteration a virtual
+ * temporary CurvePoint is created.
*/
virtual Interface0DIterator pointsBegin(float t = 0.0f);
- /*! Returns an Interface0DIterator pointing after the last point of the Curve and that can iterate
- * over the \a points of the Curve at any resolution.
- * At each iteration a virtual temporary CurvePoint is created.
+ /*! Returns an Interface0DIterator pointing after the last point of the Curve and that can
+ * iterate over the \a points of the Curve at any resolution. At each iteration a virtual
+ * temporary CurvePoint is created.
*/
virtual Interface0DIterator pointsEnd(float t = 0.0f);
diff --git a/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h b/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
index f993c21ddb6..5cbdd26be57 100644
--- a/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
+++ b/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
@@ -50,8 +50,8 @@ class CurvePoint_nonconst_traits : public Nonconst_traits<CurvePoint *> {
/* */
/**********************************/
-/*! iterator on a curve. Allows an iterating outside initial vertices. A CurvePoint is instanciated an returned
- * when the iterator is dereferenced.
+/*! iterator on a curve. Allows an iterating outside initial vertices. A CurvePoint is
+ * instanciated an returned when the iterator is dereferenced.
*/
template<class Traits>
class __point_iterator : public IteratorBase<Traits, BidirectionalIteratorTag_Traits> {
@@ -86,7 +86,7 @@ class __point_iterator : public IteratorBase<Traits, BidirectionalIteratorTag_Tr
friend class __point_iterator<CurvePoint_nonconst_traits>;
friend class iterator;
#endif
- //protected:
+ // protected:
public:
float _CurvilinearLength;
float _step;
@@ -169,7 +169,7 @@ class __point_iterator : public IteratorBase<Traits, BidirectionalIteratorTag_Tr
delete _Point;
}
- //protected: //FIXME
+ // protected: //FIXME
public:
inline __point_iterator(vertex_container_iterator iA,
vertex_container_iterator iB,
@@ -307,7 +307,7 @@ class __point_iterator : public IteratorBase<Traits, BidirectionalIteratorTag_Tr
else {
_t = 1.0f; // AB is a null segment, we're directly at its end
}
- //if normAB ~= 0, we don't change these values
+ // if normAB ~= 0, we don't change these values
if (_t >= 1) {
_CurvilinearLength -= normAB * (_t - 1);
if (_currentn == _n - 1) {
diff --git a/source/blender/freestyle/intern/stroke/CurveIterators.h b/source/blender/freestyle/intern/stroke/CurveIterators.h
index 428ea022dfd..b05c9838a3b 100644
--- a/source/blender/freestyle/intern/stroke/CurveIterators.h
+++ b/source/blender/freestyle/intern/stroke/CurveIterators.h
@@ -187,7 +187,7 @@ class CurvePointIterator : public Interface0DIteratorNested {
return false;
}
- //protected:
+ // protected:
virtual int increment()
{
if ((_currentn == _n - 1) && (_t == 1.0f)) {
@@ -223,7 +223,7 @@ class CurvePointIterator : public Interface0DIteratorNested {
else {
_t = 1.0f; // AB is a null segment, we're directly at its end
}
- //if normAB ~= 0, we don't change these values
+ // if normAB ~= 0, we don't change these values
if (_t >= 1) {
_CurvilinearLength -= normAB * (_t - 1);
if (_currentn == _n - 1) {
@@ -241,7 +241,7 @@ class CurvePointIterator : public Interface0DIteratorNested {
virtual int decrement()
{
- if (_t == 0.0f) { //we're at the beginning of the edge
+ if (_t == 0.0f) { // we're at the beginning of the edge
_t = 1.0f;
--_currentn;
--__A;
diff --git a/source/blender/freestyle/intern/stroke/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp
index fc4d099061c..0374e605ff2 100644
--- a/source/blender/freestyle/intern/stroke/Operators.cpp
+++ b/source/blender/freestyle/intern/stroke/Operators.cpp
@@ -278,7 +278,7 @@ void Operators::bidirectionalChain(ViewEdgeIterator &it, UnaryPredicate1D &pred)
Chain *new_chain = new Chain(id);
++id;
-# if 0 //FIXME
+# if 0 // FIXME
ViewEdgeIterator it_back(it);
--it_back;
# endif
@@ -841,7 +841,7 @@ static int __recursiveSplit(Chain *_curve,
real _min = FLT_MAX;
++it;
real mean = 0.f;
- //soc unused - real variance = 0.0f;
+ // soc unused - real variance = 0.0f;
unsigned count = 0;
CurveInternal::CurvePointIterator next = it;
++next;
@@ -865,7 +865,7 @@ static int __recursiveSplit(Chain *_curve,
}
mean /= (float)count;
- //if ((!bsplit) || (mean - _min > mean)) { // we didn't find any minimum
+ // if ((!bsplit) || (mean - _min > mean)) { // we didn't find any minimum
if (!bsplit) { // we didn't find any minimum
newChains.push_back(_curve);
return 0;
@@ -1210,7 +1210,7 @@ inline int applyShading(Stroke &stroke, vector<StrokeShader *> &shaders)
int Operators::create(UnaryPredicate1D &pred, vector<StrokeShader *> shaders)
{
- //Canvas* canvas = Canvas::getInstance();
+ // Canvas* canvas = Canvas::getInstance();
if (!_current_set) {
cerr << "Warning: current set empty" << endl;
return 0;
@@ -1229,7 +1229,7 @@ int Operators::create(UnaryPredicate1D &pred, vector<StrokeShader *> shaders)
delete stroke;
goto error;
}
- //canvas->RenderStroke(stroke);
+ // canvas->RenderStroke(stroke);
new_strokes_set.push_back(stroke);
}
}
diff --git a/source/blender/freestyle/intern/stroke/Operators.h b/source/blender/freestyle/intern/stroke/Operators.h
index 9d63108a813..2da9d30f172 100644
--- a/source/blender/freestyle/intern/stroke/Operators.h
+++ b/source/blender/freestyle/intern/stroke/Operators.h
@@ -43,8 +43,9 @@
namespace Freestyle {
/*! Class defining the operators used in a style module.
- * There are 4 classes of operators: Selection, Chaining, Splitting and Creating. All these operators are
- * user controlled in the scripting language through Functors, Predicates and Shaders that are taken as arguments.
+ * There are 4 classes of operators: Selection, Chaining, Splitting and Creating.
+ * All these operators are user controlled in the scripting language through Functors, Predicates
+ * and Shaders that are taken as arguments.
*/
class Operators {
@@ -63,7 +64,8 @@ class Operators {
static int select(UnaryPredicate1D &pred);
/*! Builds a set of chains from the current set of ViewEdges.
- * Each ViewEdge of the current list starts a new chain. The chaining operator then iterates over the ViewEdges
+ * Each ViewEdge of the current list starts a new chain.
+ * The chaining operator then iterates over the ViewEdges
* of the ViewMap using the user specified iterator.
* This operator only iterates using the increment operator and is therefore unidirectional.
* \param it:
@@ -71,19 +73,22 @@ class Operators {
* \param pred:
* The predicate on the ViewEdge that expresses the stopping condition.
* \param modifier:
- * A function that takes a ViewEdge as argument and that is used to modify the processed ViewEdge
- * state (the timestamp incrementation is a typical illustration of such a modifier)
+ * A function that takes a ViewEdge as argument and that is used to modify the
+ * processed ViewEdge state (the timestamp incrementation is a typical illustration of
+ * such a modifier)
*/
static int chain(ViewEdgeInternal::ViewEdgeIterator &it,
UnaryPredicate1D &pred,
UnaryFunction1D_void &modifier);
/*! Builds a set of chains from the current set of ViewEdges.
- * Each ViewEdge of the current list starts a new chain. The chaining operator then iterates over the ViewEdges
+ * Each ViewEdge of the current list starts a new chain. The chaining operator then iterates
+ * over the ViewEdges
* of the ViewMap using the user specified iterator.
* This operator only iterates using the increment operator and is therefore unidirectional.
- * This chaining operator is different from the previous one because it doesn't take any modifier as argument.
- * Indeed, the time stamp (insuring that a ViewEdge is processed one time) is automatically managed in this case.
+ * This chaining operator is different from the previous one because it doesn't take any
+ * modifier as argument. Indeed, the time stamp (insuring that a ViewEdge is processed one time)
+ * is automatically managed in this case.
* \param it:
* The iterator on the ViewEdges of the ViewMap. It contains the chaining rule.
* \param pred:
@@ -92,13 +97,14 @@ class Operators {
static int chain(ViewEdgeInternal::ViewEdgeIterator &it, UnaryPredicate1D &pred);
/*! Builds a set of chains from the current set of ViewEdges.
- * Each ViewEdge of the current list potentially starts a new chain. The chaining operator then iterates over
- * the ViewEdges of the ViewMap using the user specified iterator.
- * This operator iterates both using the increment and decrement operators and is therefore bidirectional.
- * This operator works with a ChainingIterator which contains the chaining rules. It is this last one which can
- * be told to chain only edges that belong to the selection or not to process twice a ViewEdge during the chaining.
- * Each time a ViewEdge is added to a chain, its chaining time stamp is incremented. This allows you to keep track
- * of the number of chains to which a ViewEdge belongs to.
+ * Each ViewEdge of the current list potentially starts a new chain. The chaining operator then
+ * iterates over the ViewEdges of the ViewMap using the user specified iterator.
+ * This operator iterates both using the increment and decrement operators and is therefore
+ * bidirectional. This operator works with a ChainingIterator which contains the chaining rules.
+ * It is this last one which can be told to chain only edges that belong to the selection or not
+ * to process twice a ViewEdge during the chaining. Each time a ViewEdge is added to a chain,
+ * its chaining time stamp is incremented. This allows you to keep track of the number of chains
+ * to which a ViewEdge belongs to.
* \param it:
* The ChainingIterator on the ViewEdges of the ViewMap. It contains the chaining rule.
* \param pred:
@@ -106,16 +112,17 @@ class Operators {
*/
static int bidirectionalChain(ChainingIterator &it, UnaryPredicate1D &pred);
- /*! The only difference with the above bidirectional chaining algorithm is that we don't need to pass a stopping
- * criterion. This might be desirable when the stopping criterion is already contained in the iterator definition.
- * Builds a set of chains from the current set of ViewEdges.
- * Each ViewEdge of the current list potentially starts a new chain. The chaining operator then iterates over
- * the ViewEdges of the ViewMap using the user specified iterator.
- * This operator iterates both using the increment and decrement operators and is therefore bidirectional.
- * This operator works with a ChainingIterator which contains the chaining rules. It is this last one which can be
- * told to chain only edges that belong to the selection or not to process twice a ViewEdge during the chaining.
- * Each time a ViewEdge is added to a chain, its chaining time stamp is incremented. This allows you to keep track
- * of the number of chains to which a ViewEdge belongs to.
+ /*! The only difference with the above bidirectional chaining algorithm is that we don't need to
+ * pass a stopping criterion. This might be desirable when the stopping criterion is already
+ * contained in the iterator definition. Builds a set of chains from the current set of
+ * ViewEdges. Each ViewEdge of the current list potentially starts a new chain. The chaining
+ * operator then iterates over the ViewEdges of the ViewMap using the user specified iterator.
+ * This operator iterates both using the increment and decrement operators and is therefore
+ * bidirectional. This operator works with a ChainingIterator which contains the chaining rules.
+ * It is this last one which can be told to chain only edges that belong to the selection or not
+ * to process twice a ViewEdge during the chaining. Each time a ViewEdge is added to a chain,
+ * its chaining time stamp is incremented. This allows you to keep track of the number of chains
+ * to which a ViewEdge belongs to.
* \param it:
* The ChainingIterator on the ViewEdges of the ViewMap. It contains the chaining rule.
*/
@@ -123,8 +130,8 @@ class Operators {
/*! Splits each chain of the current set of chains in a sequential way.
* The points of each chain are processed (with a specified sampling) sequentially.
- * Each time a user specified starting condition is verified, a new chain begins and ends as soon as a
- * user-defined stopping predicate is verified.
+ * Each time a user specified starting condition is verified, a new chain begins and ends as
+ * soon as a user-defined stopping predicate is verified.
* This allows chains overlapping rather than chains partitioning.
* The first point of the initial chain is the first point of one of the resulting chains.
* The splitting ends when no more chain can start.
@@ -133,30 +140,32 @@ class Operators {
* \param stoppingPred:
* The predicate on a point that expresses the stopping condition
* \param sampling:
- * The resolution used to sample the chain for the predicates evaluation. (The chain is not actually
- * resampled, a virtual point only progresses along the curve using this resolution)
+ * The resolution used to sample the chain for the predicates evaluation.
+ * (The chain is not actually resampled, a virtual point only progresses along the
+ * curve using this resolution)
*/
static int sequentialSplit(UnaryPredicate0D &startingPred,
UnaryPredicate0D &stoppingPred,
float sampling = 0.0f);
/*! Splits each chain of the current set of chains in a sequential way.
- * The points of each chain are processed (with a specified sampling) sequentially and each time a user
- * specified condition is verified, the chain is split into two chains.
+ * The points of each chain are processed (with a specified sampling) sequentially and each time
+ * a user specified condition is verified, the chain is split into two chains.
* The resulting set of chains is a partition of the initial chain
* \param pred:
* The predicate on a point that expresses the splitting condition
* \param sampling:
- * The resolution used to sample the chain for the predicate evaluation. (The chain is not actually
- * resampled, a virtual point only progresses along the curve using this resolution)
+ * The resolution used to sample the chain for the predicate evaluation.
+ * (The chain is not actually resampled, a virtual point only progresses along the
+ * curve using this resolution)
*/
static int sequentialSplit(UnaryPredicate0D &pred, float sampling = 0.0f);
/*! Splits the current set of chains in a recursive way.
- * We process the points of each chain (with a specified sampling) to find the point minimizing a specified
- * function. The chain is split in two at this point and the two new chains are processed in the same way.
- * The recursivity level is controlled through a predicate 1D that expresses a stopping condition
- * on the chain that is about to be processed.
+ * We process the points of each chain (with a specified sampling) to find the point
+ * minimizing a specified function. The chain is split in two at this point and the two new
+ * chains are processed in the same way. The recursivity level is controlled through a
+ * predicate 1D that expresses a stopping condition on the chain that is about to be processed.
* \param func:
* The Unary Function evaluated at each point of the chain.
* The splitting point is the point minimizing this function
@@ -165,42 +174,45 @@ class Operators {
* This predicate is evaluated for each curve before it actually gets split.
* If pred(chain) is true, the curve won't be split anymore.
* \param sampling:
- * The resolution used to sample the chain for the predicates evaluation. (The chain is not actually
- * resampled, a virtual point only progresses along the curve using this resolution)
+ * The resolution used to sample the chain for the predicates evaluation. (The chain
+ * is not actually resampled, a virtual point only progresses along the curve using
+ * this resolution)
*/
static int recursiveSplit(UnaryFunction0D<double> &func,
UnaryPredicate1D &pred,
float sampling = 0);
/*! Splits the current set of chains in a recursive way.
- * We process the points of each chain (with a specified sampling) to find the point minimizing a specified
- * function. The chain is split in two at this point and the two new chains are processed in the same way.
- * The user can specify a 0D predicate to make a first selection on the points that can potentially be split.
- * A point that doesn't verify the 0D predicate won't be candidate in realizing the min.
- * The recursivity level is controlled through a predicate 1D that expresses a stopping condition
- * on the chain that is about to be processed.
+ * We process the points of each chain (with a specified sampling) to find the point minimizing
+ * a specified function. The chain is split in two at this point and the two new chains are
+ * processed in the same way. The user can specify a 0D predicate to make a first selection on
+ * the points that can potentially be split. A point that doesn't verify the 0D predicate
+ * won't be candidate in realizing the min. The recursivity level is controlled through a
+ * predicate 1D that expresses a stopping condition on the chain that is about to be processed.
* \param func:
* The Unary Function evaluated at each point of the chain.
* The splitting point is the point minimizing this function
* \param pred0d:
- * The Unary Predicate 0D used to select the candidate points where the split can occur.
- * For example, it is very likely that would rather have your chain splitting around its middle point
- * than around one of its extremities. A 0D predicate working on the curvilinear abscissa allows
- * to add this kind of constraints.
+ * The Unary Predicate 0D used to select the candidate points where the split can
+ * occur. For example, it is very likely that would rather have your chain splitting
+ * around its middle point than around one of its extremities. A 0D predicate working
+ * on the curvilinear abscissa allows to add this kind of constraints.
* \param pred:
* The Unary Predicate ex pressing the recursivity stopping condition.
* This predicate is evaluated for each curve before it actually gets split.
* If pred(chain) is true, the curve won't be split anymore.
* \param sampling:
- * The resolution used to sample the chain for the predicates evaluation. (The chain is not actually
- * resampled, a virtual point only progresses along the curve using this resolution)
+ * The resolution used to sample the chain for the predicates evaluation. (The chain
+ * is not actually resampled, a virtual point only progresses along the curve using
+ * this resolution)
*/
static int recursiveSplit(UnaryFunction0D<double> &func,
UnaryPredicate0D &pred0d,
UnaryPredicate1D &pred,
float sampling = 0.0f);
- /*! Sorts the current set of chains (or viewedges) according to the comparison predicate given as argument.
+ /*! Sorts the current set of chains (or viewedges)
+ * according to the comparison predicate given as argument.
* \param pred:
* The binary predicate used for the comparison
*/
diff --git a/source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp b/source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp
index 20dac647cdc..e7428c795fc 100644
--- a/source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp
@@ -70,8 +70,8 @@ void PSStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
svRep[2] = *(v[2]);
color[0] = svRep[0]->color();
- //color[1] = svRep[1]->color();
- //color[2] = svRep[2]->color();
+ // color[1] = svRep[1]->color();
+ // color[2] = svRep[2]->color();
_ofstream << "newpath" << endl;
_ofstream << (color[0])[0] << " " << (color[0])[1] << " " << (color[0])[2] << " setrgbcolor"
diff --git a/source/blender/freestyle/intern/stroke/Predicates0D.h b/source/blender/freestyle/intern/stroke/Predicates0D.h
index f511c0ceade..90b6d99f2db 100644
--- a/source/blender/freestyle/intern/stroke/Predicates0D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates0D.h
@@ -65,8 +65,8 @@ class UnaryPredicate0D {
/*! The () operator. Must be overload by inherited classes.
* \param it:
- * The Interface0DIterator pointing onto the Interface0D at which we wish to evaluate the predicate.
- * \return true if the condition is satisfied, false otherwise.
+ * The Interface0DIterator pointing onto the Interface0D at which we wish to evaluate the
+ * predicate. \return true if the condition is satisfied, false otherwise.
*/
virtual int operator()(Interface0DIterator &it);
diff --git a/source/blender/freestyle/intern/stroke/Predicates1D.h b/source/blender/freestyle/intern/stroke/Predicates1D.h
index be70907b51b..3560f29ee36 100644
--- a/source/blender/freestyle/intern/stroke/Predicates1D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates1D.h
@@ -183,8 +183,8 @@ class FalseUP1D : public UnaryPredicate1D {
};
// QuantitativeInvisibilityUP1D
-/*! Returns true if the Quantitative Invisibility evaluated at an Interface1D, using the QuantitativeInvisibilityF1D
- * functor, equals a certain user-defined value.
+/*! Returns true if the Quantitative Invisibility evaluated at an Interface1D, using the
+ * QuantitativeInvisibilityF1D functor, equals a certain user-defined value.
*/
class QuantitativeInvisibilityUP1D : public UnaryPredicate1D {
public:
@@ -344,7 +344,8 @@ class EqualToChainingTimeStampUP1D : public UnaryPredicate1D {
};
// ShapeUP1D
-/*! Returns true if the shape to which the Interface1D belongs to has the same Id as the one specified by the user. */
+/*! Returns true if the shape to which the Interface1D belongs to has the same Id as the one
+ * specified by the user. */
class ShapeUP1D : public UnaryPredicate1D {
private:
Id _id;
@@ -487,7 +488,8 @@ class FalseBP1D : public BinaryPredicate1D {
};
// Length2DBP1D
-/*! Returns true if the 2D length of the Interface1D i1 is less than the 2D length of the Interface1D i2. */
+/*! Returns true if the 2D length of the Interface1D i1 is less than the 2D length of the
+ * Interface1D i2. */
class Length2DBP1D : public BinaryPredicate1D {
public:
/*! Returns the string "Length2DBP1D" */
@@ -538,7 +540,8 @@ class SameShapeIdBP1D : public BinaryPredicate1D {
};
// ViewMapGradientNormBP1D
-/*! Returns true if the evaluation of the Gradient norm Function is higher for Interface1D i1 than for i2. */
+/*! Returns true if the evaluation of the Gradient norm Function is higher for Interface1D i1 than
+ * for i2. */
class ViewMapGradientNormBP1D : public BinaryPredicate1D {
private:
Functions1D::GetViewMapGradientNormF1D _func;
diff --git a/source/blender/freestyle/intern/stroke/QInformationMap.h b/source/blender/freestyle/intern/stroke/QInformationMap.h
index 99393a8949c..d3a4218f9d7 100644
--- a/source/blender/freestyle/intern/stroke/QInformationMap.h
+++ b/source/blender/freestyle/intern/stroke/QInformationMap.h
@@ -38,7 +38,7 @@ class QInformationMap : public InformationMap {
QInformationMap(const QInformationMap &);
QInformationMap &operator=(const QInformationMap &);
- //float getSmoothedPixel(int x, int y, float sigma = 0.2f);1
+ // float getSmoothedPixel(int x, int y, float sigma = 0.2f);1
virtual float getMean(int x, int y);
virtual void retrieveMeanAndVariance(int x, int y, float &oMean, float &oVariance);
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp
index ef40865ecf1..ff0cd64fdaa 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.cpp
+++ b/source/blender/freestyle/intern/stroke/Stroke.cpp
@@ -484,7 +484,7 @@ void Stroke::setLength(float iLength)
float Stroke::ComputeSampling(int iNVertices)
{
- if (iNVertices <= (int)_Vertices.size()) //soc
+ if (iNVertices <= (int)_Vertices.size()) // soc
return _sampling;
float sampling = _Length / (float)(iNVertices - _Vertices.size() + 1);
@@ -563,7 +563,7 @@ int Stroke::Resample(int iNPoints)
if (s->_resampled == false) {
if ((!checkEveryone) && (s->_length < meanlength))
continue;
- //resample
+ // resample
s->_n = s->_n + 1;
s->_sampling = s->_length / (float)(s->_n + 1);
s->_resampled = resampled = true;
@@ -577,10 +577,11 @@ int Stroke::Resample(int iNPoints)
checkEveryone = true;
}
if (N < NPointsToAdd) {
- // fatal error, likely because _Length is inconsistent with the stroke length computed with the vertices
+ // fatal error, likely because _Length is inconsistent with the stroke length computed with the
+ // vertices
return -1;
}
- //actually resample:
+ // actually resample:
for (vector<StrokeSegment>::iterator s = strokeSegments.begin(), send = strokeSegments.end();
s != send;
++s) {
@@ -617,7 +618,7 @@ int Stroke::Resample(int iNPoints)
int Stroke::Resample(float iSampling)
{
- //cerr << "old size :" << strokeVerticesSize() << endl;
+ // cerr << "old size :" << strokeVerticesSize() << endl;
if (iSampling == 0)
return 0;
if (iSampling >= _sampling)
@@ -625,7 +626,7 @@ int Stroke::Resample(float iSampling)
_sampling = iSampling;
// Resample...
- //real curvilinearLength = 0.0f;
+ // real curvilinearLength = 0.0f;
vertex_container newVertices;
real t = 0.0f;
const real limit = 0.99;
@@ -641,17 +642,17 @@ int Stroke::Resample(float iSampling)
Vec2r vec_tmp(b - a);
real norm_var = vec_tmp.norm();
if (norm_var <= _sampling) {
- //curvilinearLength += norm_var;
+ // curvilinearLength += norm_var;
++it;
++next;
continue;
}
- //curvilinearLength += _sampling;
+ // curvilinearLength += _sampling;
t = _sampling / norm_var;
while (t < limit) {
newVertex = new StrokeVertex(&(*it), &(*next), t);
- //newVertex->setCurvilinearAbscissa(curvilinearLength);
+ // newVertex->setCurvilinearAbscissa(curvilinearLength);
newVertices.push_back(newVertex);
t = t + _sampling / norm_var;
}
@@ -798,7 +799,7 @@ Stroke::vertex_iterator Stroke::vertices_begin(float sampling)
if ((sampling != 0) && (sampling < _sampling))
Resample(sampling);
return vertex_iterator(_Vertices.begin(), _Vertices.begin(), _Vertices.end());
- //return _Vertices.begin();
+ // return _Vertices.begin();
}
#if 0
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index 3eae5e91b6a..ec722516d2a 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -143,8 +143,8 @@ class StrokeAttribute {
}
/*! Returns the attribute's thickness.
- * \return an array of 2 floats. the first value is the thickness on the right of the vertex when following
- * the stroke, the second one is the thickness on the left.
+ * \return an array of 2 floats. the first value is the thickness on the right of the vertex
+ * when following the stroke, the second one is the thickness on the left.
*/
inline const float *getThickness() const
{
@@ -163,7 +163,8 @@ class StrokeAttribute {
return _thickness[1];
}
- /*! Returns the thickness on the right and on the left of the vertex when following the stroke. */
+ /*! Returns the thickness on the right and on the left of the vertex when following the stroke.
+ */
inline Vec2f getThicknessRL() const
{
return Vec2f(_thickness[0], _thickness[1]);
@@ -462,8 +463,8 @@ class StrokeVertex : public CurvePoint {
_CurvilignAbscissa = iAbscissa;
}
- /*! sets the Stroke's length (it's only a value stored by the Stroke Vertex, it won't change the real
- * Stroke's length.)
+ /*! sets the Stroke's length (it's only a value stored by the Stroke Vertex, it won't change the
+ * real Stroke's length.)
*/
inline void setStrokeLength(float iLength)
{
@@ -498,7 +499,8 @@ class StrokeVertexIterator;
/*! Class to define a stroke.
* A stroke is made of a set of 2D vertices (StrokeVertex), regularly spaced out.
* This set of vertices defines the stroke's backbone geometry.
- * Each of these stroke vertices defines the stroke's shape and appearance at this vertex position.
+ * Each of these stroke vertices defines the stroke's shape and appearance at this vertex
+ * position.
*/
class Stroke : public Interface1D {
public: // Implementation of Interface1D
@@ -532,7 +534,7 @@ class Stroke : public Interface1D {
const_vertex_iterator;
public:
- //typedef StrokeVertex vertex_type;
+ // typedef StrokeVertex vertex_type;
private:
vertex_container _Vertices; //! The stroke's backbone vertices
@@ -575,8 +577,8 @@ class Stroke : public Interface1D {
Stroke &operator=(const Stroke &iBrother);
/*! Compute the sampling needed to get iNVertices vertices.
- * If the specified number of vertices is less than the actual number of vertices, the actual sampling value
- * is returned. (To remove Vertices, use the RemoveVertex() method of this class).
+ * If the specified number of vertices is less than the actual number of vertices, the actual
+ * sampling value is returned. (To remove Vertices, use the RemoveVertex() method of this class).
* \param iNVertices:
* The number of StrokeVertices we eventually want in our Stroke.
* \return the sampling that must be used in the Resample(float) method.
@@ -586,11 +588,10 @@ class Stroke : public Interface1D {
float ComputeSampling(int iNVertices);
/*! Resampling method.
- * Resamples the curve so that it eventually has iNPoints. That means it is going to add iNPoints-vertices_size,
- * if vertices_size is the number of points we already have.
- * If vertices_size >= iNPoints, no resampling is done.
- * \param iNPoints:
- * The number of vertices we eventually want in our stroke.
+ * Resamples the curve so that it eventually has iNPoints. That means it is going to add
+ * iNPoints-vertices_size, if vertices_size is the number of points we already have. If
+ * vertices_size >= iNPoints, no resampling is done. \param iNPoints: The number of vertices we
+ * eventually want in our stroke.
*/
int Resample(int iNPoints);
@@ -838,11 +839,9 @@ class Stroke : public Interface1D {
const_vertex_iterator vertices_end() const;
vertex_iterator vertices_end();
- /*! Returns a StrokeVertexIterator pointing on the first StrokeVertex of the Stroke. One can specify a sampling
- * value to resample the Stroke on the fly if needed.
- * \param t:
- * The resampling value with which we want our Stroke to be resampled.
- * If 0 is specified, no resampling is done.
+ /*! Returns a StrokeVertexIterator pointing on the first StrokeVertex of the Stroke. One can
+ * specify a sampling value to resample the Stroke on the fly if needed. \param t: The resampling
+ * value with which we want our Stroke to be resampled. If 0 is specified, no resampling is done.
*/
StrokeInternal::StrokeVertexIterator strokeVerticesBegin(float t = 0.0f);
diff --git a/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h b/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h
index e9d4659f320..ccf5773a4c8 100644
--- a/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h
+++ b/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h
@@ -51,7 +51,7 @@ class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTa
typedef vertex_iterator_base<vertex_nonconst_traits> iterator;
typedef vertex_iterator_base<vertex_const_traits> const_iterator;
- //protected:
+ // protected:
public:
vertex_container_iterator _it;
vertex_container_iterator _begin;
@@ -59,7 +59,7 @@ class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTa
public:
friend class Stroke;
- //friend class vertex_iterator;
+ // friend class vertex_iterator;
inline vertex_iterator_base() : parent_class()
{
@@ -79,7 +79,7 @@ class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTa
_end = iBrother._end;
}
- //protected: //FIXME
+ // protected: //FIXME
public:
inline vertex_iterator_base(vertex_container_iterator it,
vertex_container_iterator begin,
diff --git a/source/blender/freestyle/intern/stroke/StrokeIterators.h b/source/blender/freestyle/intern/stroke/StrokeIterators.h
index 1999b028424..624f2a03877 100644
--- a/source/blender/freestyle/intern/stroke/StrokeIterators.h
+++ b/source/blender/freestyle/intern/stroke/StrokeIterators.h
@@ -34,15 +34,14 @@ namespace StrokeInternal {
/////////////////////////////////////////////////
/*! Class defining an iterator designed to iterate over the StrokeVertex of a Stroke.
- * An instance of a StrokeVertexIterator can only be obtained from a Stroke by calling strokeVerticesBegin() or
- * strokeVerticesEnd().
- * It is iterating over the same vertices as an Interface0DIterator.
- * The difference resides in the object access. Indeed, an Interface0DIterator allows only an access to an
- * Interface0D whereas we could need to access the specialized StrokeVertex type. In this case, one
- * should use a StrokeVertexIterator.
- * The castToInterface0DIterator() method is useful to get an Interface0DIterator from a StrokeVertexIterator in
- * order to call any functions of the type UnaryFunction0D.
- * \attention In the scripting language, you must call \code it2 = StrokeVertexIterator(it1) \endcode instead of
+ * An instance of a StrokeVertexIterator can only be obtained from a Stroke by calling
+ * strokeVerticesBegin() or strokeVerticesEnd(). It is iterating over the same vertices as an
+ * Interface0DIterator. The difference resides in the object access. Indeed, an Interface0DIterator
+ * allows only an access to an Interface0D whereas we could need to access the specialized
+ * StrokeVertex type. In this case, one should use a StrokeVertexIterator. The
+ * castToInterface0DIterator() method is useful to get an Interface0DIterator from a
+ * StrokeVertexIterator in order to call any functions of the type UnaryFunction0D. \attention In
+ * the scripting language, you must call \code it2 = StrokeVertexIterator(it1) \endcode instead of
* \code it2 = it1 \endcode where \a it1 and \a it2 are 2 StrokeVertexIterator.
* Otherwise, incrementing \a it1 will also increment \a it2.
*/
@@ -84,9 +83,9 @@ class StrokeVertexIterator : public Interface0DIteratorNested {
}
/*! operator=
- * \attention In the scripting language, you must call \code it2 = StrokeVertexIterator(it1) \endcode instead of
- * \code it2 = it1 \endcode where \a it1 and \a it2 are 2 StrokeVertexIterator.
- * Otherwise, incrementing \a it1 will also increment \a it2.
+ * \attention In the scripting language, you must call \code it2 = StrokeVertexIterator(it1)
+ * \endcode instead of \code it2 = it1 \endcode where \a it1 and \a it2 are 2
+ * StrokeVertexIterator. Otherwise, incrementing \a it1 will also increment \a it2.
*/
StrokeVertexIterator &operator=(const StrokeVertexIterator &vi)
{
diff --git a/source/blender/freestyle/intern/stroke/StrokeRenderer.h b/source/blender/freestyle/intern/stroke/StrokeRenderer.h
index 03e6893b578..79767b48d83 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRenderer.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRenderer.h
@@ -116,7 +116,8 @@ class TextureManager {
/* */
/**********************************/
-/*! Class to render a stroke. Creates a triangle strip and stores it strip is lazily created at the first rendering */
+/*! Class to render a stroke. Creates a triangle strip and stores it strip is lazily created at the
+ * first rendering */
class StrokeRenderer {
public:
StrokeRenderer();
@@ -130,7 +131,7 @@ class StrokeRenderer {
// lazy, checks if it has already been done
static bool loadTextures();
- //static unsigned int getTextureIndex(unsigned int index);
+ // static unsigned int getTextureIndex(unsigned int index);
static TextureManager *_textureManager;
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
index f1483e80083..a6c00f66056 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
@@ -113,7 +113,7 @@ static real crossP(const Vec2r &A, const Vec2r &B)
void Strip::createStrip(const vector<StrokeVertex *> &iStrokeVertices)
{
- //computeParameterization();
+ // computeParameterization();
if (iStrokeVertices.size() < 2) {
if (G.debug & G_DEBUG_FREESTYLE) {
cout << "Warning: strip has less than 2 vertices" << endl;
@@ -134,11 +134,11 @@ void Strip::createStrip(const vector<StrokeVertex *> &iStrokeVertices)
StrokeVertex *sv, *sv2, *svPrev;
int orientationErrors = 0;
- //special case of first vertex
+ // special case of first vertex
v2 = v = iStrokeVertices.begin();
++v2;
sv = *v;
- vPrev = v; //in case the stroke has only 2 vertices;
+ vPrev = v; // in case the stroke has only 2 vertices;
sv2 = *v2;
Vec2r dir(sv2->getPoint() - sv->getPoint());
Vec2r orthDir(-dir[1], dir[0]);
@@ -195,7 +195,7 @@ void Strip::createStrip(const vector<StrokeVertex *> &iStrokeVertices)
svPrev = (*vPrev);
Vec2r p(sv->getPoint()), p2(sv2->getPoint()), pPrev(svPrev->getPoint());
- //direction and orthogonal vector to the next segment
+ // direction and orthogonal vector to the next segment
Vec2r dir(p2 - p);
float dirNorm = dir.norm();
dir.normalize();
@@ -215,7 +215,7 @@ void Strip::createStrip(const vector<StrokeVertex *> &iStrokeVertices)
}
}
- //direction and orthogonal vector to the previous segment
+ // direction and orthogonal vector to the previous segment
Vec2r dirPrev(p - pPrev);
float dirPrevNorm = dirPrev.norm();
dirPrev.normalize();
@@ -287,7 +287,7 @@ void Strip::createStrip(const vector<StrokeVertex *> &iStrokeVertices)
}
} // end of for
- //special case of last vertex
+ // special case of last vertex
sv = *v;
sv2 = *vPrev;
dir = Vec2r(sv->getPoint() - sv2->getPoint());
@@ -342,7 +342,7 @@ void Strip::createStrip(const vector<StrokeVertex *> &iStrokeVertices)
#endif
_averageThickness /= float(iStrokeVertices.size() - 2);
- //I did not use the first and last vertex for the average
+ // I did not use the first and last vertex for the average
if (iStrokeVertices.size() < 3)
_averageThickness = 0.5 * (thicknessLast[1] + thicknessLast[0] + thickness[0] + thickness[1]);
@@ -379,7 +379,7 @@ void Strip::cleanUpSingularities(const vector<StrokeVertex *> &iStrokeVertices)
}
}
- //return;
+ // return;
if (iStrokeVertices.size() < 2)
return;
int i = 0, j;
@@ -389,7 +389,7 @@ void Strip::cleanUpSingularities(const vector<StrokeVertex *> &iStrokeVertices)
bool singu1 = false, singu2 = false;
int timeSinceSingu1 = 0, timeSinceSingu2 = 0;
- //special case of first vertex
+ // special case of first vertex
v = iStrokeVertices.begin();
for (vend = iStrokeVertices.end(); v != vend; v++) {
v2 = v;
@@ -416,7 +416,7 @@ void Strip::cleanUpSingularities(const vector<StrokeVertex *> &iStrokeVertices)
int toto = i - timeSinceSingu1;
if (toto < 0)
cerr << "Stephane dit \"Toto\"" << endl;
- //traverse all the vertices of the singularity and average them
+ // traverse all the vertices of the singularity and average them
Vec2r avP(0.0, 0.0);
for (j = i - timeSinceSingu1; j <= i; j++)
avP = Vec2r(avP + _vertices[2 * j]->point2d());
@@ -437,7 +437,7 @@ void Strip::cleanUpSingularities(const vector<StrokeVertex *> &iStrokeVertices)
int toto = i - timeSinceSingu2;
if (toto < 0)
cerr << "Stephane dit \"Toto\"" << endl;
- //traverse all the vertices of the singularity and average them
+ // traverse all the vertices of the singularity and average them
Vec2r avP(0.0, 0.0);
for (j = i - timeSinceSingu2; j <= i; j++)
avP = Vec2r(avP + _vertices[2 * j + 1]->point2d());
@@ -453,7 +453,7 @@ void Strip::cleanUpSingularities(const vector<StrokeVertex *> &iStrokeVertices)
}
if (singu1) {
- //traverse all the vertices of the singularity and average them
+ // traverse all the vertices of the singularity and average them
Vec2r avP(0.0, 0.0);
for (j = i - timeSinceSingu1; j < i; j++)
avP = Vec2r(avP + _vertices[2 * j]->point2d());
@@ -462,7 +462,7 @@ void Strip::cleanUpSingularities(const vector<StrokeVertex *> &iStrokeVertices)
_vertices[2 * j]->setPoint2d(avP);
}
if (singu2) {
- //traverse all the vertices of the singularity and average them
+ // traverse all the vertices of the singularity and average them
Vec2r avP(0.0, 0.0);
for (j = i - timeSinceSingu2; j < i; j++)
avP = Vec2r(avP + _vertices[2 * j + 1]->point2d());
@@ -760,7 +760,7 @@ StrokeRep::StrokeRep(Stroke *iStroke)
StrokeRep::StrokeRep(const StrokeRep &iBrother)
{
- //soc unused - int i = 0;
+ // soc unused - int i = 0;
_stroke = iBrother._stroke;
_strokeType = iBrother._strokeType;
_textureId = iBrother._textureId;
diff --git a/source/blender/freestyle/intern/stroke/StrokeShader.h b/source/blender/freestyle/intern/stroke/StrokeShader.h
index 3f312395559..7b1f12a8c9d 100644
--- a/source/blender/freestyle/intern/stroke/StrokeShader.h
+++ b/source/blender/freestyle/intern/stroke/StrokeShader.h
@@ -44,20 +44,17 @@ class Stroke;
* Any Stroke Shader must inherit from this class and overload the shade() method.
* A StrokeShader is designed to modify any Stroke's attribute such as Thickness, Color,
* Geometry, Texture, Blending mode...
- * The basic way to achieve this operation consists in iterating over the StrokeVertices of the Stroke
- * and to modify each one's StrokeAttribute.
- * Here is a python code example of such an iteration:
- * \code
- * it = ioStroke.strokeVerticesBegin()
- * while not it.isEnd():
- * att = it.getObject().attribute()
+ * The basic way to achieve this operation consists in iterating over the StrokeVertices of the
+ * Stroke and to modify each one's StrokeAttribute. Here is a python code example of such an
+ * iteration: \code it = ioStroke.strokeVerticesBegin() while not it.isEnd(): att =
+ * it.getObject().attribute()
* ## perform here any attribute modification
* it.increment()
* \endcode
* Here is a C++ code example of such an iteration:
* \code
- * for (StrokeInternal::StrokeVertexIterator v = ioStroke.strokeVerticesBegin(), vend = ioStroke.strokeVerticesEnd();
- * v != vend;
+ * for (StrokeInternal::StrokeVertexIterator v = ioStroke.strokeVerticesBegin(), vend =
+ * ioStroke.strokeVerticesEnd(); v != vend;
* ++v)
* {
* StrokeAttribute& att = v->attribute();
diff --git a/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp b/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp
index e135f83cfef..8d2e554a67b 100644
--- a/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp
@@ -72,7 +72,7 @@ NodeGroup *StrokeTesselator::Tesselate(StrokeVertexIterator begin, StrokeVertexI
NodeGroup *group = new NodeGroup;
NodeShape *tshape = new NodeShape;
group->AddChild(tshape);
- //tshape->material().setDiffuse(0.0f, 0.0f, 0.0f, 1.0f);
+ // tshape->material().setDiffuse(0.0f, 0.0f, 0.0f, 1.0f);
tshape->setFrsMaterial(_FrsMaterial);
for (StrokeVertexIterator c = begin, cend = end; c != cend; c++) {
diff --git a/source/blender/freestyle/intern/system/PointerSequence.h b/source/blender/freestyle/intern/system/PointerSequence.h
index 015033beeb4..d136632f060 100644
--- a/source/blender/freestyle/intern/system/PointerSequence.h
+++ b/source/blender/freestyle/intern/system/PointerSequence.h
@@ -23,23 +23,25 @@
*
* PointerSequence
*
- * Produces a wrapped version of a sequence type (std::vector, std::deque, std::list) that will take ownership of
- * pointers that it stores. Those pointers will be deleted in its destructor.
+ * Produces a wrapped version of a sequence type (std::vector, std::deque, std::list) that will
+ * take ownership of pointers that it stores. Those pointers will be deleted in its destructor.
*
- * Because the contained pointers are wholly owned by the sequence, you cannot make a copy of the sequence.
- * Making a copy would result in a double free.
+ * Because the contained pointers are wholly owned by the sequence, you cannot make a copy of the
+ * sequence. Making a copy would result in a double free.
*
- * This is a no-frills class that provides no additional facilities. The user is responsible for managing any
- * pointers that are removed from the list, and for making sure that any pointers contained in the class are not
- * deleted elsewhere. Because this class does no reference counting, the user must also make sure that any pointer
- * appears only once in the sequence.
+ * This is a no-frills class that provides no additional facilities. The user is responsible for
+ * managing any pointers that are removed from the list, and for making sure that any pointers
+ * contained in the class are not deleted elsewhere. Because this class does no reference
+ * counting, the user must also make sure that any pointer appears only once in the sequence.
*
* If more sophisticated facilities are needed, use tr1::shared_ptr or boost::shared_ptr.
- * This class is only intended to allow one to eke by in projects where tr1 or boost are not available.
+ * This class is only intended to allow one to eke by in projects where tr1 or boost are not
+ * available.
*
- * Usage: The template takes two parameters, the standard container, and the class held in the container. This is a
- * limitation of C++ templates, where T::iterator is not a type when T is a template parameter. If anyone knows a way
- * around this limitation, then the second parameter can be eliminated.
+ * Usage: The template takes two parameters, the standard container, and the class held in the
+ * container. This is a limitation of C++ templates, where T::iterator is not a type when T is a
+ * template parameter. If anyone knows a way around this limitation, then the second parameter can
+ * be eliminated.
*
* Example:
* PointerSequence<vector<Widget*>, Widget*> v;
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h
index bcb36d8d6b5..1fed6a00463 100644
--- a/source/blender/freestyle/intern/system/PythonInterpreter.h
+++ b/source/blender/freestyle/intern/system/PythonInterpreter.h
@@ -31,7 +31,7 @@ extern "C" {
#include "StringUtils.h"
#include "Interpreter.h"
-//soc
+// soc
extern "C" {
#include "MEM_guardedalloc.h"
diff --git a/source/blender/freestyle/intern/system/RandGen.cpp b/source/blender/freestyle/intern/system/RandGen.cpp
index 77eb9a8c10a..719287b102f 100644
--- a/source/blender/freestyle/intern/system/RandGen.cpp
+++ b/source/blender/freestyle/intern/system/RandGen.cpp
@@ -49,7 +49,8 @@ namespace Freestyle {
long l = (long)(x) * (long)(y); \
(z)[0] = LOW(l); \
(z)[1] = HIGH(l); \
- }
+ } \
+ ((void)0)
#define CARRY(x, y) ((unsigned long)((long)(x) + (long)(y)) > MASK)
#define ADDEQU(x, y, z) (z = CARRY(x, (y)), x = LOW(x + (y)))
diff --git a/source/blender/freestyle/intern/system/StringUtils.cpp b/source/blender/freestyle/intern/system/StringUtils.cpp
index 027491a790f..99ec9aed632 100644
--- a/source/blender/freestyle/intern/system/StringUtils.cpp
+++ b/source/blender/freestyle/intern/system/StringUtils.cpp
@@ -19,7 +19,7 @@
* \brief String utilities
*/
-//soc #include <qfileinfo.h>
+// soc #include <qfileinfo.h>
#include "FreestyleConfig.h"
#include "StringUtils.h"
diff --git a/source/blender/freestyle/intern/view_map/BoxGrid.h b/source/blender/freestyle/intern/view_map/BoxGrid.h
index 83c379102f5..35b5e4d6b55 100644
--- a/source/blender/freestyle/intern/view_map/BoxGrid.h
+++ b/source/blender/freestyle/intern/view_map/BoxGrid.h
@@ -58,9 +58,9 @@ class BoxGrid {
Polygon3r poly;
Polygon3r cameraSpacePolygon;
real shallowest, deepest;
- // N.B. We could, of course, store face in poly's userdata member, like the old ViewMapBuilder code does.
- // However, code comments make it clear that userdata is deprecated, so we avoid the temptation
- // to save 4 or 8 bytes.
+ // N.B. We could, of course, store face in poly's userdata member, like the old ViewMapBuilder
+ // code does. However, code comments make it clear that userdata is deprecated, so we avoid the
+ // temptation to save 4 or 8 bytes.
WFace *face;
#ifdef WITH_CXX_GUARDEDALLOC
@@ -84,24 +84,27 @@ class BoxGrid {
void indexPolygons();
real boundary[4];
- //deque<OccluderData*> faces;
+ // deque<OccluderData*> faces;
vector<OccluderData *> faces;
};
public:
/* Iterator needs to allow the user to avoid full 3D comparison in two cases:
*
- * (1) Where (*current)->deepest < target[2], where the occluder is unambiguously in front of the target point.
+ * (1) Where (*current)->deepest < target[2], where the occluder is unambiguously in front of the
+ * target point.
*
- * (2) Where (*current)->shallowest > target[2], where the occluder is unambiguously in back of the target point.
+ * (2) Where (*current)->shallowest > target[2], where the occluder is unambiguously in back of
+ * the target point.
*
- * In addition, when used by OptimizedFindOccludee, Iterator should stop iterating as soon as it has an
- * occludee candidate and (*current)->shallowest > candidate[2], because at that point forward no new occluder
- * could possibly be a better occludee.
+ * In addition, when used by OptimizedFindOccludee, Iterator should stop iterating as soon as it
+ * has an occludee candidate and (*current)->shallowest > candidate[2], because at that point
+ * forward no new occluder could possibly be a better occludee.
*/
class Iterator {
public:
- // epsilon is not used in this class, but other grids with the same interface may need an epsilon
+ // epsilon is not used in this class, but other grids with the same interface may need an
+ // epsilon
explicit Iterator(BoxGrid &grid, Vec3r &center, real epsilon = 1.0e-06);
~Iterator();
void initBeforeTarget();
@@ -122,7 +125,7 @@ class BoxGrid {
Vec3r _target;
bool _foundOccludee;
real _occludeeDepth;
- //deque<OccluderData*>::iterator _current, _occludeeCandidate;
+ // deque<OccluderData*>::iterator _current, _occludeeCandidate;
vector<OccluderData *>::iterator _current, _occludeeCandidate;
#ifdef WITH_CXX_GUARDEDALLOC
@@ -171,7 +174,7 @@ class BoxGrid {
void getCellCoordinates(const Vec3r &point, unsigned &x, unsigned &y);
typedef PointerSequence<vector<Cell *>, Cell *> cellContainer;
- //typedef PointerSequence<deque<OccluderData*>, OccluderData*> occluderContainer;
+ // typedef PointerSequence<deque<OccluderData*>, OccluderData*> occluderContainer;
typedef PointerSequence<vector<OccluderData *>, OccluderData *> occluderContainer;
unsigned _cellsX, _cellsY;
float _cellSize;
@@ -222,8 +225,8 @@ inline bool BoxGrid::Iterator::testOccluder(bool wantOccludee)
{
// End-of-list is not even a valid iterator position
if (_current == _cell->faces.end()) {
- // Returning true seems strange, but it will break us out of whatever loop is calling testOccluder,
- // and _current = _cell->face.end() will make the calling routine give up.
+ // Returning true seems strange, but it will break us out of whatever loop is calling
+ // testOccluder, and _current = _cell->face.end() will make the calling routine give up.
return true;
}
#if BOX_GRID_LOGGING
diff --git a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
index 214852001b6..8e10d06d623 100644
--- a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
+++ b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
@@ -35,8 +35,8 @@ CulledOccluderSource::CulledOccluderSource(const GridHelpers::Transform &t,
{
cullViewEdges(viewMap, extensiveFEdgeSearch);
- // If we have not found any visible FEdges during our cull, then there is nothing to iterate over.
- // Short-circuit everything.
+ // If we have not found any visible FEdges during our cull, then there is nothing to iterate
+ // over. Short-circuit everything.
valid = gridSpaceOccluderProsceniumInitialized;
if (valid && !testCurrent()) {
@@ -107,8 +107,8 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
// Non-displayable view edges will be skipped over during visibility calculation.
- // View edges will be culled according to their position w.r.t. the viewport proscenium (viewport + 5% border,
- // or some such).
+ // View edges will be culled according to their position w.r.t. the viewport proscenium (viewport
+ // + 5% border, or some such).
// Get proscenium boundary for culling
real viewProscenium[4];
@@ -123,17 +123,16 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
cout << "Origin: [" << prosceniumOrigin[0] << ", " << prosceniumOrigin[1] << "]" << endl;
}
- // A separate occluder proscenium will also be maintained, starting out the same as the viewport proscenium, and
- // expanding as necessary so that it encompasses the center point of at least one feature edge in each
- // retained view edge.
- // The occluder proscenium will be used later to cull occluding triangles before they are inserted into the Grid.
- // The occluder proscenium starts out the same size as the view proscenium
+ // A separate occluder proscenium will also be maintained, starting out the same as the viewport
+ // proscenium, and expanding as necessary so that it encompasses the center point of at least one
+ // feature edge in each retained view edge. The occluder proscenium will be used later to cull
+ // occluding triangles before they are inserted into the Grid. The occluder proscenium starts out
+ // the same size as the view proscenium
GridHelpers::getDefaultViewProscenium(occluderProscenium);
- // XXX Freestyle is inconsistent in its use of ViewMap::viewedges_container and vector<ViewEdge*>::iterator.
- // Probably all occurences of vector<ViewEdge*>::iterator should be replaced ViewMap::viewedges_container
- // throughout the code.
- // For each view edge
+ // XXX Freestyle is inconsistent in its use of ViewMap::viewedges_container and
+ // vector<ViewEdge*>::iterator. Probably all occurences of vector<ViewEdge*>::iterator should be
+ // replaced ViewMap::viewedges_container throughout the code. For each view edge
ViewMap::viewedges_container::iterator ve, veend;
for (ve = viewMap.ViewEdges().begin(), veend = viewMap.ViewEdges().end(); ve != veend; ve++) {
@@ -154,8 +153,8 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
// All ViewEdges start culled
(*ve)->setIsInImage(false);
- // For simple visibility calculation: mark a feature edge that is known to have a center point inside
- // the occluder proscenium. Cull all other feature edges.
+ // For simple visibility calculation: mark a feature edge that is known to have a center point
+ // inside the occluder proscenium. Cull all other feature edges.
do {
// All FEdges start culled
fe->setIsInImage(false);
@@ -190,8 +189,8 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
fe = fe->nextEdge();
} while (fe != NULL && fe != festart && !(bestOccluderTargetFound && (*ve)->isInImage()));
- // Either we have run out of FEdges, or we already have the one edge we need to determine visibility
- // Cull all remaining edges.
+ // Either we have run out of FEdges, or we already have the one edge we need to determine
+ // visibility Cull all remaining edges.
while (fe != NULL && fe != festart) {
fe->setIsInImage(false);
fe = fe->nextEdge();
@@ -229,14 +228,14 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
// For "Normal" or "Fast" style visibility computation only:
- // For more detailed visibility calculation, make a second pass through the view map, marking all feature edges
- // with center points inside the final occluder proscenium. All of these feature edges can be considered during
- // visibility calculation.
+ // For more detailed visibility calculation, make a second pass through the view map, marking all
+ // feature edges with center points inside the final occluder proscenium. All of these feature
+ // edges can be considered during visibility calculation.
- // So far we have only found one FEdge per ViewEdge. The "Normal" and "Fast" styles of visibility computation
- // want to consider many FEdges for each ViewEdge.
- // Here we re-scan the view map to find any usable FEdges that we skipped on the first pass, or that have become
- // usable because the occluder proscenium has been expanded since the edge was visited on the first pass.
+ // So far we have only found one FEdge per ViewEdge. The "Normal" and "Fast" styles of visibility
+ // computation want to consider many FEdges for each ViewEdge. Here we re-scan the view map to
+ // find any usable FEdges that we skipped on the first pass, or that have become usable because
+ // the occluder proscenium has been expanded since the edge was visited on the first pass.
if (extensiveFEdgeSearch) {
// For each view edge,
for (ve = viewMap.ViewEdges().begin(), veend = viewMap.ViewEdges().end(); ve != veend; ve++) {
@@ -259,9 +258,9 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
}
// Up until now, all calculations have been done in camera space.
- // However, the occluder source's iteration and the grid that consumes the occluders both work in gridspace,
- // so we need a version of the occluder proscenium in gridspace.
- // Set the gridspace occlude proscenium
+ // However, the occluder source's iteration and the grid that consumes the occluders both work in
+ // gridspace, so we need a version of the occluder proscenium in gridspace. Set the gridspace
+ // occlude proscenium
}
void CulledOccluderSource::expandGridSpaceOccluderProscenium(FEdge *fe)
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
index 1de4a87886c..6c144807e35 100644
--- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
+++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
@@ -184,7 +184,7 @@ void FEdgeXDetector::computeCurvatures(WXVertex *vertex)
// CURVATURE LAYER
// store all the curvature datas for each vertex
- //soc unused - real K1, K2
+ // soc unused - real K1, K2
real cos2theta, sin2theta;
Vec3r e1, n, v;
// one vertex curvature info :
@@ -206,8 +206,8 @@ void FEdgeXDetector::computeCurvatures(WXVertex *vertex)
ncycle.end();
C->K1 = ncycle.kmin();
C->K2 = ncycle.kmax();
- C->e1 = ncycle.Kmax(); //ncycle.kmin() * ncycle.Kmax();
- C->e2 = ncycle.Kmin(); //ncycle.kmax() * ncycle.Kmin();
+ C->e1 = ncycle.Kmax(); // ncycle.kmin() * ncycle.Kmax();
+ C->e2 = ncycle.Kmin(); // ncycle.kmax() * ncycle.Kmin();
real absK1 = fabs(C->K1);
_meanK1 += absK1;
@@ -320,8 +320,8 @@ void FEdgeXDetector::ProcessSilhouetteEdge(WXEdge *iEdge)
if ((fA->front()) ^
(fB->front())) { // fA->visible XOR fB->visible (true if one is 0 and the other is 1)
- // The only edges we want to set as silhouette edges in this way are the ones with 2 different normals
- // for 1 vertex for these two faces
+ // The only edges we want to set as silhouette edges in this way are the ones with 2 different
+ // normals for 1 vertex for these two faces
//--------------------
// In reality we only test the normals for 1 of the 2 vertices.
if (fA->GetVertexNormal(iEdge->GetaVertex()) == fB->GetVertexNormal(iEdge->GetaVertex()))
@@ -392,7 +392,7 @@ void FEdgeXDetector::ProcessCreaseEdge(WXEdge *iEdge)
void FEdgeXDetector::processRidgesAndValleysShape(WXShape *iWShape)
{
// Don't forget to add the built layer to the face at the end of the ProcessFace:
- //iFace->AddSmoothLayer(faceLayer);
+ // iFace->AddSmoothLayer(faceLayer);
if (!_computeViewIndependent)
return;
@@ -671,7 +671,8 @@ void FEdgeXDetector::postProcessSuggestiveContourFace(WXFace *iFace)
}
// At that point, we have the derivatives for each vertex of iFace.
- // All we have to do now is to use linear interpolation to compute the values at the extremities of the smooth edge.
+ // All we have to do now is to use linear interpolation to compute the values at the extremities
+ // of the smooth edge.
WXSmoothEdge *sc_edge = sc_layer->getSmoothEdge();
WOEdge *sc_oedge = sc_edge->woea();
t = sc_edge->ta();
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
index fafc391aa8f..9df0b4bb4bd 100644
--- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
+++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
@@ -89,8 +89,9 @@ class FEdgeXDetector {
/*! Sets the minimum angle for detecting crease edges
* \param angle:
- * The angular threshold in degrees (between 0 and 180) for detecting crease edges. An edge is considered
- * a crease edge if the angle between two faces sharing the edge is smaller than the given threshold.
+ * The angular threshold in degrees (between 0 and 180) for detecting crease edges. An edge is
+ * considered a crease edge if the angle between two faces sharing the edge is smaller than the
+ * given threshold.
*/
// XXX angle should be in radian...
inline void setCreaseAngle(float angle)
@@ -211,7 +212,7 @@ class FEdgeXDetector {
#if 0
real _bbox_diagonal; // diagonal of the current processed shape bbox
#endif
- //oldtmp values
+ // oldtmp values
bool _computeViewIndependent;
real _meanK1;
real _meanKr;
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.cpp b/source/blender/freestyle/intern/view_map/Functions0D.cpp
index 5b04b66eeeb..2a9a654981a 100644
--- a/source/blender/freestyle/intern/view_map/Functions0D.cpp
+++ b/source/blender/freestyle/intern/view_map/Functions0D.cpp
@@ -343,7 +343,7 @@ int GetOccludersF0D::operator()(Interface0DIterator &iter)
set<ViewShape *> occluders;
getOccludersF0D(iter, occluders);
result.clear();
- //vsOccluders.insert(vsOccluders.begin(), occluders.begin(), occluders.end());
+ // vsOccluders.insert(vsOccluders.begin(), occluders.begin(), occluders.end());
for (set<ViewShape *>::iterator it = occluders.begin(), itend = occluders.end(); it != itend;
++it) {
result.push_back((*it));
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.h b/source/blender/freestyle/intern/view_map/Functions0D.h
index ecf94b29d60..7149c1909fd 100644
--- a/source/blender/freestyle/intern/view_map/Functions0D.h
+++ b/source/blender/freestyle/intern/view_map/Functions0D.h
@@ -55,9 +55,9 @@ using namespace Geometry;
/*! Base class for Unary Functions (functors) working on Interface0DIterator.
* A unary function will be used by calling its operator() on an Interface0DIterator.
- * \attention In the scripting language, there exists several prototypes depending on the returned value type.
- * For example, you would inherit from a UnaryFunction0DDouble if you wish to define a function that returns a double.
- * The different existing prototypes are:
+ * \attention In the scripting language, there exists several prototypes depending on the returned
+ * value type. For example, you would inherit from a UnaryFunction0DDouble if you wish to define a
+ * function that returns a double. The different existing prototypes are:
* - UnaryFunction0DDouble
* - UnaryFunction0DEdgeNature
* - UnaryFunction0DFloat
@@ -284,8 +284,9 @@ class GetParameterF0D : public UnaryFunction0D<float> {
};
// VertexOrientation2DF0D
-/*! Returns a Vec2r giving the 2D oriented tangent to the 1D element to which the Interface0DIterator& belongs to and
- * evaluated at the Interface0D pointed by this Interface0DIterator&.
+/*! Returns a Vec2r giving the 2D oriented tangent to the 1D element to which the
+ * Interface0DIterator& belongs to and evaluated at the Interface0D pointed by this
+ * Interface0DIterator&.
*/
class VertexOrientation2DF0D : public UnaryFunction0D<Vec2f> {
public:
@@ -300,8 +301,9 @@ class VertexOrientation2DF0D : public UnaryFunction0D<Vec2f> {
};
// VertexOrientation3DF0D
-/*! Returns a Vec3r giving the 3D oriented tangent to the 1D element to which the Interface0DIterator& belongs to and
- * evaluated at the Interface0D pointed by this Interface0DIterator&.
+/*! Returns a Vec3r giving the 3D oriented tangent to the 1D element to which the
+ * Interface0DIterator& belongs to and evaluated at the Interface0D pointed by this
+ * Interface0DIterator&.
*/
class VertexOrientation3DF0D : public UnaryFunction0D<Vec3f> {
public:
@@ -316,8 +318,9 @@ class VertexOrientation3DF0D : public UnaryFunction0D<Vec3f> {
};
// Curvature2DAngleF0D
-/*! Returns a real giving the 2D curvature (as an angle) of the 1D element to which the Interface0DIterator&
- * belongs to and evaluated at the Interface0D pointed by this Interface0DIterator&.
+/*! Returns a real giving the 2D curvature (as an angle) of the 1D element to which the
+ * Interface0DIterator& belongs to and evaluated at the Interface0D pointed by this
+ * Interface0DIterator&.
*/
class Curvature2DAngleF0D : public UnaryFunction0D<double> {
public:
@@ -332,9 +335,10 @@ class Curvature2DAngleF0D : public UnaryFunction0D<double> {
};
// ZDiscontinuity
-/*! Returns a real giving the distance between and Interface0D and the shape that lies behind (occludee).
- * This distance is evaluated in the camera space and normalized between 0 and 1. Therefore, if no object is occluded
- * by the shape to which the Interface0D belongs to, 1 is returned.
+/*! Returns a real giving the distance between and Interface0D and the shape that lies behind
+ * (occludee). This distance is evaluated in the camera space and normalized between 0 and 1.
+ * Therefore, if no object is occluded by the shape to which the Interface0D belongs to, 1 is
+ * returned.
*/
class ZDiscontinuityF0D : public UnaryFunction0D<double> {
public:
@@ -349,8 +353,9 @@ class ZDiscontinuityF0D : public UnaryFunction0D<double> {
};
// Normal2DF0D
-/*! Returns a Vec2f giving the normalized 2D normal to the 1D element to which the Interface0DIterator& belongs to and
- * evaluated at the Interface0D pointed by this Interface0DIterator&.
+/*! Returns a Vec2f giving the normalized 2D normal to the 1D element to which the
+ * Interface0DIterator& belongs to and evaluated at the Interface0D pointed by this
+ * Interface0DIterator&.
*/
class Normal2DF0D : public UnaryFunction0D<Vec2f> {
public:
@@ -367,11 +372,11 @@ class Normal2DF0D : public UnaryFunction0D<Vec2f> {
// MaterialF0D
/*! Returns the material of the object evaluated at the Interface0D.
* This evaluation can be ambiguous (in the case of a TVertex for example.
- * This functor tries to remove this ambiguity using the context offered by the 1D element to which the
- * Interface0DIterator& belongs to and by arbitrary choosing the material of the face that lies on its left when
- * following the 1D element if there are two different materials on each side of the point.
- * However, there still can be problematic cases, and the user willing to deal with this cases in a specific way
- * should implement its own getMaterial functor.
+ * This functor tries to remove this ambiguity using the context offered by the 1D element to
+ * which the Interface0DIterator& belongs to and by arbitrary choosing the material of the face
+ * that lies on its left when following the 1D element if there are two different materials on each
+ * side of the point. However, there still can be problematic cases, and the user willing to deal
+ * with this cases in a specific way should implement its own getMaterial functor.
*/
class MaterialF0D : public UnaryFunction0D<FrsMaterial> {
public:
@@ -388,10 +393,10 @@ class MaterialF0D : public UnaryFunction0D<FrsMaterial> {
// ShapeIdF0D
/*! Returns the Id of the Shape the Interface0D belongs to.
* This evaluation can be ambiguous (in the case of a TVertex for example).
- * This functor tries to remove this ambiguity using the context offered by the 1D element to which the
- * Interface0DIterator& belongs to.
- * However, there still can be problematic cases, and the user willing to deal with this cases in a specific way
- * should implement its own getShapeIdF0D functor.
+ * This functor tries to remove this ambiguity using the context offered by the 1D element to
+ * which the Interface0DIterator& belongs to. However, there still can be problematic cases, and
+ * the user willing to deal with this cases in a specific way should implement its own
+ * getShapeIdF0D functor.
*/
class ShapeIdF0D : public UnaryFunction0D<Id> {
public:
@@ -408,10 +413,10 @@ class ShapeIdF0D : public UnaryFunction0D<Id> {
// QiF0D
/*! Returns the quantitative invisibility of this Interface0D.
* This evaluation can be ambiguous (in the case of a TVertex for example).
- * This functor tries to remove this ambiguity using the context offered by the 1D element to which the
- * Interface0DIterator& belongs to.
- * However, there still can be problematic cases, and the user willing to deal with this cases in a specific way
- * should implement its own getQIF0D functor.
+ * This functor tries to remove this ambiguity using the context offered by the 1D element to
+ * which the Interface0DIterator& belongs to. However, there still can be problematic cases, and
+ * the user willing to deal with this cases in a specific way should implement its own getQIF0D
+ * functor.
*/
class QuantitativeInvisibilityF0D : public UnaryFunction0D<unsigned int> {
public:
diff --git a/source/blender/freestyle/intern/view_map/Functions1D.h b/source/blender/freestyle/intern/view_map/Functions1D.h
index 581ab9c459a..20aa9f2a27f 100644
--- a/source/blender/freestyle/intern/view_map/Functions1D.h
+++ b/source/blender/freestyle/intern/view_map/Functions1D.h
@@ -45,9 +45,9 @@ namespace Freestyle {
/*! Base class for Unary Functions (functors) working on Interface1D.
* A unary function will be used by calling its operator() on an Interface1D.
- * \attention In the scripting language, there exists several prototypes depending on the returned value type.
- * For example, you would inherit from a UnaryFunction1DDouble if you wish to define a function that returns a double.
- * The different existing prototypes are:
+ * \attention In the scripting language, there exists several prototypes depending on the returned
+ * value type. For example, you would inherit from a UnaryFunction1DDouble if you wish to define a
+ * function that returns a double. The different existing prototypes are:
* - UnaryFunction1DDouble
* - UnaryFunction1DEdgeNature
* - UnaryFunction1DFloat
@@ -73,8 +73,8 @@ template<class T> class UnaryFunction1D {
/*! Builds a UnaryFunction1D from an integration type.
* \param iType:
- * In case the result for the Interface1D would be obtained by evaluating a 0D function over the different
- * Interface0D of the Interface1D, \a iType tells which integration method to use.
+ * In case the result for the Interface1D would be obtained by evaluating a 0D function over
+ * the different Interface0D of the Interface1D, \a iType tells which integration method to use.
* The default integration method is the MEAN.
*/
UnaryFunction1D(IntegrationType iType)
@@ -379,9 +379,10 @@ class Orientation3DF1D : public UnaryFunction1D<Vec3f> {
};
// ZDiscontinuityF1D
-/*! Returns a real giving the distance between and Interface1D and the shape that lies behind (occludee).
- * This distance is evaluated in the camera space and normalized between 0 and 1. Therefore, if no object is occluded
- * by the shape to which the Interface1D belongs to, 1 is returned.
+/*! Returns a real giving the distance between and Interface1D and the shape that lies behind
+ * (occludee). This distance is evaluated in the camera space and normalized between 0 and 1.
+ * Therefore, if no object is occluded by the shape to which the Interface1D belongs to, 1 is
+ * returned.
*/
class ZDiscontinuityF1D : public UnaryFunction1D<double> {
private:
@@ -408,9 +409,9 @@ class ZDiscontinuityF1D : public UnaryFunction1D<double> {
// QuantitativeInvisibilityF1D
/*! Returns the Quantitative Invisibility of an Interface1D element.
- * If the Interface1D is a ViewEdge, then there is no ambiguity concerning the result. But, if the Interface1D
- * results of a chaining (chain, stroke), then it might be made of several 1D elements of different
- * Quantitative Invisibilities.
+ * If the Interface1D is a ViewEdge, then there is no ambiguity concerning the result. But, if the
+ * Interface1D results of a chaining (chain, stroke), then it might be made of several 1D elements
+ * of different Quantitative Invisibilities.
*/
class QuantitativeInvisibilityF1D : public UnaryFunction1D<unsigned> {
private:
@@ -438,8 +439,9 @@ class QuantitativeInvisibilityF1D : public UnaryFunction1D<unsigned> {
// CurveNatureF1D
/*! Returns the nature of the Interface1D (silhouette, ridge, crease...).
* Except if the Interface1D is a ViewEdge, this result might be ambiguous.
- * Indeed, the Interface1D might result from the gathering of several 1D elements, each one being of a different
- * nature. An integration method, such as the MEAN, might give, in this case, irrelevant results.
+ * Indeed, the Interface1D might result from the gathering of several 1D elements, each one being
+ * of a different nature. An integration method, such as the MEAN, might give, in this case,
+ * irrelevant results.
*/
class CurveNatureF1D : public UnaryFunction1D<Nature::EdgeNature> {
private:
diff --git a/source/blender/freestyle/intern/view_map/GridDensityProvider.h b/source/blender/freestyle/intern/view_map/GridDensityProvider.h
index dacdb345c86..8d6ba521dde 100644
--- a/source/blender/freestyle/intern/view_map/GridDensityProvider.h
+++ b/source/blender/freestyle/intern/view_map/GridDensityProvider.h
@@ -110,7 +110,8 @@ class GridDensityProvider {
Vec3r p6 = transform(Vec3r(xM, ym, zM));
Vec3r p7 = transform(Vec3r(xM, yM, zm));
Vec3r p8 = transform(Vec3r(xM, yM, zM));
- // Determine the proscenium face according to the min and max values of the transformed x and y coordinates
+ // Determine the proscenium face according to the min and max values of the transformed x and y
+ // coordinates
proscenium[0] = std::min(std::min(std::min(p1.x(), p2.x()), std::min(p3.x(), p4.x())),
std::min(std::min(p5.x(), p6.x()), std::min(p7.x(), p8.x())));
proscenium[1] = std::max(std::max(std::max(p1.x(), p2.x()), std::max(p3.x(), p4.x())),
diff --git a/source/blender/freestyle/intern/view_map/Interface0D.h b/source/blender/freestyle/intern/view_map/Interface0D.h
index bab996d9308..3d50e978147 100644
--- a/source/blender/freestyle/intern/view_map/Interface0D.h
+++ b/source/blender/freestyle/intern/view_map/Interface0D.h
@@ -95,7 +95,8 @@ class Interface0D {
/*! Returns the 2D point. */
virtual Geometry::Vec2r getPoint2D() const;
- /*! Returns the FEdge that lies between this Interface0D and the Interface0D given as argument. */
+ /*! Returns the FEdge that lies between this Interface0D and the Interface0D given as argument.
+ */
virtual FEdge *getFEdge(Interface0D &);
/*! Returns the Id of the point. */
@@ -175,8 +176,8 @@ class Interface0DIteratorNested : public Iterator {
/*! Class defining an iterator over Interface0D elements.
* An instance of this iterator is always obtained from a 1D element.
- * \attention In the scripting language, you must call \code it2 = Interface0DIterator(it1) \endcode instead of
- * \code it2 = it1 \endcode where \a it1 and \a it2 are 2 Interface0DIterator.
+ * \attention In the scripting language, you must call \code it2 = Interface0DIterator(it1)
+ * \endcode instead of \code it2 = it1 \endcode where \a it1 and \a it2 are 2 Interface0DIterator.
* Otherwise, incrementing \a it1 will also increment \a it2.
*/
class Interface0DIterator : public Iterator {
@@ -200,9 +201,9 @@ class Interface0DIterator : public Iterator {
}
/*! Operator =
- * \attention In the scripting language, you must call \code it2 = Interface0DIterator(it1) \endcode instead of
- * \code it2 = it1 \endcode where \a it1 and \a it2 are 2 Interface0DIterator.
- * Otherwise, incrementing \a it1 will also increment \a it2.
+ * \attention In the scripting language, you must call \code it2 = Interface0DIterator(it1)
+ * \endcode instead of \code it2 = it1 \endcode where \a it1 and \a it2 are 2
+ * Interface0DIterator. Otherwise, incrementing \a it1 will also increment \a it2.
*/
Interface0DIterator &operator=(const Interface0DIterator &it)
{
@@ -280,16 +281,16 @@ class Interface0DIterator : public Iterator {
return _iterator->decrement();
}
- /*! Returns true if the pointed Interface0D is the first of the 1D element containing the points over which
- * we're iterating.
+ /*! Returns true if the pointed Interface0D is the first of the 1D element containing the points
+ * over which we're iterating.
*/
virtual bool isBegin() const
{
return _iterator->isBegin();
}
- /*! Returns true if the pointed Interface0D is after the after the last point of the 1D element we're
- * iterating from. */
+ /*! Returns true if the pointed Interface0D is after the after the last point of the 1D element
+ * we're iterating from. */
virtual bool isEnd() const
{
return _iterator->isEnd();
diff --git a/source/blender/freestyle/intern/view_map/Interface1D.h b/source/blender/freestyle/intern/view_map/Interface1D.h
index e56a58096f8..e47a5ad8f31 100644
--- a/source/blender/freestyle/intern/view_map/Interface1D.h
+++ b/source/blender/freestyle/intern/view_map/Interface1D.h
@@ -42,24 +42,28 @@ using namespace std;
namespace Freestyle {
// Integration method
-/*! The different integration methods that can be invoked to integrate into a single value the set of values obtained
- * from each 0D element of a 1D element.
+/*! The different integration methods that can be invoked to integrate into a single value the set
+ * of values obtained from each 0D element of a 1D element.
*/
typedef enum {
- MEAN, /*!< The value computed for the 1D element is the mean of the values obtained for the 0D elements.*/
- MIN, /*!< The value computed for the 1D element is the minimum of the values obtained for the 0D elements.*/
- MAX, /*!< The value computed for the 1D element is the maximum of the values obtained for the 0D elements.*/
- FIRST, /*!< The value computed for the 1D element is the first of the values obtained for the 0D elements.*/
- LAST, /*!< The value computed for the 1D element is the last of the values obtained for the 0D elements.*/
+ MEAN, /*!< The value computed for the 1D element is the mean of the values obtained for the 0D
+ elements.*/
+ MIN, /*!< The value computed for the 1D element is the minimum of the values obtained for the 0D
+ elements.*/
+ MAX, /*!< The value computed for the 1D element is the maximum of the values obtained for the 0D
+ elements.*/
+ FIRST, /*!< The value computed for the 1D element is the first of the values obtained for the 0D
+ elements.*/
+ LAST, /*!< The value computed for the 1D element is the last of the values obtained for the 0D
+ elements.*/
} IntegrationType;
/*! Returns a single value from a set of values evaluated at each 0D element of this 1D element.
* \param fun:
* The UnaryFunction0D used to compute a value at each Interface0D.
* \param it:
- * The Interface0DIterator used to iterate over the 0D elements of this 1D element. The integration will occur
- * over the 0D elements starting from the one pointed by it.
- * \param it_end:
+ * The Interface0DIterator used to iterate over the 0D elements of this 1D element. The
+ * integration will occur over the 0D elements starting from the one pointed by it. \param it_end:
* The Interface0DIterator pointing the end of the 0D elements of the 1D element.
* \param integration_type:
* The integration method used to compute a single value from a set of values.
@@ -148,19 +152,17 @@ class Interface1D {
/*! Returns an iterator over the Interface1D vertices, pointing after the last vertex. */
virtual Interface0DIterator verticesEnd();
- /*! Returns an iterator over the Interface1D points, pointing to the first point. The difference with
- * verticesBegin() is that here we can iterate over points of the 1D element at a any given sampling.
- * Indeed, for each iteration, a virtual point is created.
- * \param t:
- * The sampling with which we want to iterate over points of this 1D element.
+ /*! Returns an iterator over the Interface1D points, pointing to the first point. The difference
+ * with verticesBegin() is that here we can iterate over points of the 1D element at a any given
+ * sampling. Indeed, for each iteration, a virtual point is created. \param t: The sampling with
+ * which we want to iterate over points of this 1D element.
*/
virtual Interface0DIterator pointsBegin(float t = 0.0f);
- /*! Returns an iterator over the Interface1D points, pointing after the last point. The difference with
- * verticesEnd() is that here we can iterate over points of the 1D element at a any given sampling.
- * Indeed, for each iteration, a virtual point is created.
- * \param t:
- * The sampling with which we want to iterate over points of this 1D element.
+ /*! Returns an iterator over the Interface1D points, pointing after the last point. The
+ * difference with verticesEnd() is that here we can iterate over points of the 1D element at a
+ * any given sampling. Indeed, for each iteration, a virtual point is created. \param t: The
+ * sampling with which we want to iterate over points of this 1D element.
*/
virtual Interface0DIterator pointsEnd(float t = 0.0f);
diff --git a/source/blender/freestyle/intern/view_map/Silhouette.cpp b/source/blender/freestyle/intern/view_map/Silhouette.cpp
index af97efa1406..15fe55874ca 100644
--- a/source/blender/freestyle/intern/view_map/Silhouette.cpp
+++ b/source/blender/freestyle/intern/view_map/Silhouette.cpp
@@ -286,9 +286,9 @@ real FEdge::z_discontinuity() const
Vec3r bbox_size_vec(box.getMax() - box.getMin());
real bboxsize = bbox_size_vec.norm();
if (occludee_empty()) {
- //return FLT_MAX;
+ // return FLT_MAX;
return 1.0;
- //return bboxsize;
+ // return bboxsize;
}
#if 0
@@ -302,7 +302,7 @@ real FEdge::z_discontinuity() const
real res = disc_vec.norm() / bboxsize;
return res;
- //return fabs((middle.z() - _occludeeIntersection.z()));
+ // return fabs((middle.z() - _occludeeIntersection.z()));
}
#if 0
diff --git a/source/blender/freestyle/intern/view_map/Silhouette.h b/source/blender/freestyle/intern/view_map/Silhouette.h
index b9f84e7077f..b5bbe66e51e 100644
--- a/source/blender/freestyle/intern/view_map/Silhouette.h
+++ b/source/blender/freestyle/intern/view_map/Silhouette.h
@@ -303,7 +303,8 @@ class SVertex : public Interface0D {
_Point2D = iPoint2D;
}
- /*! Adds a normal to the Svertex's set of normals. If the same normal is already in the set, nothing changes. */
+ /*! Adds a normal to the Svertex's set of normals. If the same normal is already in the set,
+ * nothing changes. */
inline void AddNormal(const Vec3r &iNormal)
{
_Normals.insert(iNormal); // if iNormal in the set already exists, nothing is done
@@ -420,7 +421,7 @@ class SVertex : public Interface0D {
return *(_Normals.begin());
}
- //Material material() const ;
+ // Material material() const ;
Id shape_id() const;
const SShape *shape() const;
float shape_importance() const;
@@ -462,13 +463,12 @@ class SVertex : public Interface0D {
class ViewEdge;
/*! Base Class for feature edges.
- * This FEdge can represent a silhouette, a crease, a ridge/valley, a border or a suggestive contour.
- * For silhouettes, the FEdge is oriented such as, the visible face lies on the left of the edge.
- * For borders, the FEdge is oriented such as, the face lies on the left of the edge.
- * An FEdge can represent an initial edge of the mesh or runs accross a face of the initial mesh depending
- * on the smoothness or sharpness of the mesh.
- * This class is specialized into a smooth and a sharp version since their properties slightly vary from
- * one to the other.
+ * This FEdge can represent a silhouette, a crease, a ridge/valley, a border or a suggestive
+ * contour. For silhouettes, the FEdge is oriented such as, the visible face lies on the left of
+ * the edge. For borders, the FEdge is oriented such as, the face lies on the left of the edge. An
+ * FEdge can represent an initial edge of the mesh or runs accross a face of the initial mesh
+ * depending on the smoothness or sharpness of the mesh. This class is specialized into a smooth
+ * and a sharp version since their properties slightly vary from one to the other.
*/
class FEdge : public Interface1D {
public: // Implementation of Interface0D
@@ -509,13 +509,13 @@ class FEdge : public Interface1D {
SVertex *_VertexB;
Id _Id;
Nature::EdgeNature _Nature;
- //vector<Polygon3r> _Occluders; // visibility // NOT HANDLED BY THE COPY CONSTRUCTOR!!
+ // vector<Polygon3r> _Occluders; // visibility // NOT HANDLED BY THE COPY CONSTRUCTOR!!
FEdge *_NextEdge; // next edge on the chain
FEdge *_PreviousEdge;
ViewEdge *_ViewEdge;
- // Sometimes we need to deport the visibility computation onto another edge. For example the exact edges use
- // edges of the mesh to compute their visibility
+ // Sometimes we need to deport the visibility computation onto another edge. For example the
+ // exact edges use edges of the mesh to compute their visibility
Polygon3r _aFace; // The occluded face which lies on the right of a silhouette edge
Vec3r _occludeeIntersection;
@@ -868,7 +868,7 @@ class FEdge : public Interface1D {
/* Information access interface */
- //Material material() const;
+ // Material material() const;
Id shape_id() const;
const SShape *shape() const;
float shape_importance() const;
@@ -911,7 +911,7 @@ class FEdge : public Interface1D {
int viewedge_nature() const;
- //float viewedge_length() const;
+ // float viewedge_length() const;
inline Vec3r orientation2d() const
{
@@ -942,16 +942,16 @@ class FEdge : public Interface1D {
/*! Returns an iterator over the 2 (!) SVertex pointing after the last SVertex. */
virtual inline Interface0DIterator verticesEnd();
- /*! Returns an iterator over the FEdge points, pointing to the first point. The difference with verticesBegin()
- * is that here we can iterate over points of the FEdge at a any given sampling.
+ /*! Returns an iterator over the FEdge points, pointing to the first point. The difference with
+ * verticesBegin() is that here we can iterate over points of the FEdge at a any given sampling.
* Indeed, for each iteration, a virtual point is created.
* \param t:
* The sampling with which we want to iterate over points of this FEdge.
*/
virtual inline Interface0DIterator pointsBegin(float t = 0.0f);
- /*! Returns an iterator over the FEdge points, pointing after the last point. The difference with verticesEnd()
- * is that here we can iterate over points of the FEdge at a any given sampling.
+ /*! Returns an iterator over the FEdge points, pointing after the last point. The difference with
+ * verticesEnd() is that here we can iterate over points of the FEdge at a any given sampling.
* Indeed, for each iteration, a virtual point is created.
* \param t:
* The sampling with which we want to iterate over points of this FEdge.
@@ -1277,8 +1277,8 @@ class FEdgeSharp : public FEdge {
#endif
};
-/*! Class defining a smooth edge. This kind of edge typically runs across a face of the input mesh. It can be
- * a silhouette, a ridge or valley, a suggestive contour.
+/*! Class defining a smooth edge. This kind of edge typically runs across a face of the input mesh.
+ * It can be a silhouette, a ridge or valley, a suggestive contour.
*/
class FEdgeSmooth : public FEdge {
protected:
@@ -1402,7 +1402,8 @@ class FEdgeSmooth : public FEdge {
/* */
/**********************************/
-/*! Class to define a feature shape. It is the gathering of feature elements from an identified input shape */
+/*! Class to define a feature shape. It is the gathering of feature elements from an identified
+ * input shape */
class SShape {
private:
vector<FEdge *> _chains; // list of fedges that are chains starting points.
@@ -1578,10 +1579,10 @@ class SShape {
}
/*! Splits an edge into several edges.
- * The edge's vertices are passed rather than the edge itself. This way, all feature edges (SILHOUETTE,
- * CREASE, BORDER) are splitted in the same time.
- * The processed edges are flagged as done (using the userdata flag).One single new vertex is created whereas
- * several splitted edges might created for the different kinds of edges. These new elements are added to the lists
+ * The edge's vertices are passed rather than the edge itself. This way, all feature edges
+ * (SILHOUETTE, CREASE, BORDER) are splitted in the same time. The processed edges are flagged as
+ * done (using the userdata flag).One single new vertex is created whereas several splitted edges
+ * might created for the different kinds of edges. These new elements are added to the lists
* maintained by the shape.
* New chains are also created.
* ioA
@@ -1589,12 +1590,11 @@ class SShape {
* ioB
* The second vertex for the edge that gets splitted
* iParameters
- * A vector containing 2D real vectors indicating the parameters giving the intersections coordinates in
- * 3D and in 2D. These intersections points must be sorted from B to A.
- * Each parameter defines the intersection point I as I=A+T*AB. T<0 and T>1 are then incorrect insofar as
- * they give intersections points that lie outside the segment.
- * ioNewEdges
- * The edges that are newly created (the initial edges are not included) are added to this list.
+ * A vector containing 2D real vectors indicating the parameters giving the intersections
+ * coordinates in 3D and in 2D. These intersections points must be sorted from B to A. Each
+ * parameter defines the intersection point I as I=A+T*AB. T<0 and T>1 are then incorrect insofar
+ * as they give intersections points that lie outside the segment. ioNewEdges The edges that are
+ * newly created (the initial edges are not included) are added to this list.
*/
inline void SplitEdge(FEdge *fe, const vector<Vec2r> &iParameters, vector<FEdge *> &ioNewEdges)
{
@@ -1637,7 +1637,7 @@ class SShape {
for (vector<SVertex *>::iterator sv = intersections.begin(), svend = intersections.end();
sv != svend;
sv++) {
- //SVertex *svA = fe->vertexA();
+ // SVertex *svA = fe->vertexA();
SVertex *svB = fe->vertexB();
// We split edge AB into AA' and A'B. A' and A'B are created.
@@ -1678,7 +1678,7 @@ class SShape {
fe->setId(id);
// update edge AA' for the next pointing edge
- //ioEdge->setNextEdge(newEdge);
+ // ioEdge->setNextEdge(newEdge);
(fe)->setNextEdge(NULL);
// update vertex pointing edges list:
@@ -1690,17 +1690,13 @@ class SShape {
}
}
- /* splits an edge into 2 edges. The new vertex and edge are added to the sshape list of vertices and edges
- * a new chain is also created.
- * returns the new edge.
- * ioEdge
- * The edge that gets splitted
- * newpoint
- * x,y,z coordinates of the new point.
+ /* splits an edge into 2 edges. The new vertex and edge are added to the sshape list of vertices
+ * and edges a new chain is also created. returns the new edge. ioEdge The edge that gets
+ * splitted newpoint x,y,z coordinates of the new point.
*/
inline FEdge *SplitEdgeIn2(FEdge *ioEdge, SVertex *ioNewVertex)
{
- //soc unused - SVertex *A = ioEdge->vertexA();
+ // soc unused - SVertex *A = ioEdge->vertexA();
SVertex *B = ioEdge->vertexB();
// We split edge AB into AA' and A'B. A' and A'B are created.
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
index eeec347efc6..1d0ac8634dd 100644
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
@@ -16,8 +16,8 @@
/** \file
* \ingroup freestyle
- * \brief Class to perform all geometric operations dedicated to silhouette. That, for example, implies that
- * this geom engine has as member data the viewpoint, transformations, projections...
+ * \brief Class to perform all geometric operations dedicated to silhouette. That, for example,
+ * implies that this geom engine has as member data the viewpoint, transformations, projections...
*/
#include <cstring>
@@ -150,7 +150,8 @@ real SilhouetteGeomEngine::ImageToWorldParameter(FEdge *fe, real t)
if (_isOrthographicProjection)
return t;
- // we need to compute for each parameter t the corresponding parameter T which gives the intersection in 3D.
+ // we need to compute for each parameter t the corresponding parameter T which gives the
+ // intersection in 3D.
real T;
// suffix w for world, c for camera, r for retina, i for image
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
index 306eb3a55be..79d863e81e7 100644
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
@@ -19,8 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Class to perform all geometric operations dedicated to silhouette. That, for example, implies that
- * this geom engine has as member data the viewpoint, transformations, projections...
+ * \brief Class to perform all geometric operations dedicated to silhouette. That, for example,
+ * implies that this geom engine has as member data the viewpoint, transformations, projections...
*/
#include <vector>
diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
index 1a7f01d288f..0c6e9741fbd 100644
--- a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
+++ b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
@@ -187,9 +187,9 @@ void SphericalGrid::distributePolygons(OccluderSource &source)
}
}
catch (...) {
- // If an exception was thrown, _faces.push_back() cannot have succeeded. Occluder is not owned by anyone,
- // and must be deleted. If the exception was thrown before or during new OccluderData(), then
- // occluder is NULL, and this delete is harmless.
+ // If an exception was thrown, _faces.push_back() cannot have succeeded. Occluder is not
+ // owned by anyone, and must be deleted. If the exception was thrown before or during new
+ // OccluderData(), then occluder is NULL, and this delete is harmless.
delete occluder;
throw;
}
diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.h b/source/blender/freestyle/intern/view_map/SphericalGrid.h
index ae00c270c1d..c32ceb09805 100644
--- a/source/blender/freestyle/intern/view_map/SphericalGrid.h
+++ b/source/blender/freestyle/intern/view_map/SphericalGrid.h
@@ -24,8 +24,9 @@
#define SPHERICAL_GRID_LOGGING 0
-// I would like to avoid using deque because including ViewMap.h and <deque> or <vector> separately results in
-// redefinitions of identifiers. ViewMap.h already includes <vector> so it should be a safe fall-back.
+// I would like to avoid using deque because including ViewMap.h and <deque> or <vector> separately
+// results in redefinitions of identifiers. ViewMap.h already includes <vector> so it should be a
+// safe fall-back.
//#include <vector>
//#include <deque>
@@ -57,9 +58,9 @@ class SphericalGrid {
Polygon3r poly;
Polygon3r cameraSpacePolygon;
real shallowest, deepest;
- // N.B. We could, of course, store face in poly's userdata member, like the old ViewMapBuilder code does.
- // However, code comments make it clear that userdata is deprecated, so we avoid the temptation to save
- // 4 or 8 bytes.
+ // N.B. We could, of course, store face in poly's userdata member, like the old ViewMapBuilder
+ // code does. However, code comments make it clear that userdata is deprecated, so we avoid the
+ // temptation to save 4 or 8 bytes.
WFace *face;
#ifdef WITH_CXX_GUARDEDALLOC
@@ -70,8 +71,8 @@ class SphericalGrid {
private:
struct Cell {
// Can't store Cell in a vector without copy and assign
- //Cell(const Cell& other);
- //Cell& operator=(const Cell& other);
+ // Cell(const Cell& other);
+ // Cell& operator=(const Cell& other);
explicit Cell();
~Cell();
@@ -83,25 +84,28 @@ class SphericalGrid {
void indexPolygons();
real boundary[4];
- //deque<OccluderData*> faces;
+ // deque<OccluderData*> faces;
vector<OccluderData *> faces;
};
public:
/*! Iterator needs to allow the user to avoid full 3D comparison in two cases:
*
- * (1) Where (*current)->deepest < target[2], where the occluder is unambiguously in front of the target point.
+ * (1) Where (*current)->deepest < target[2], where the occluder is unambiguously in front of
+ * the target point.
*
- * (2) Where (*current)->shallowest > target[2], where the occluder is unambiguously in back of the target point.
+ * (2) Where (*current)->shallowest > target[2], where the occluder is unambiguously in back of
+ * the target point.
*
- * In addition, when used by OptimizedFindOccludee, Iterator should stop iterating as soon as it has an occludee
- * candidate and (*current)->shallowest > candidate[2], because at that point forward no new occluder could
- * possibly be a better occludee.
+ * In addition, when used by OptimizedFindOccludee, Iterator should stop iterating as soon as it
+ * has an occludee candidate and (*current)->shallowest > candidate[2], because at that point
+ * forward no new occluder could possibly be a better occludee.
*/
class Iterator {
public:
- // epsilon is not used in this class, but other grids with the same interface may need an epsilon
+ // epsilon is not used in this class, but other grids with the same interface may need an
+ // epsilon
explicit Iterator(SphericalGrid &grid, Vec3r &center, real epsilon = 1.0e-06);
~Iterator();
void initBeforeTarget();
@@ -122,7 +126,7 @@ class SphericalGrid {
Vec3r _target;
bool _foundOccludee;
real _occludeeDepth;
- //deque<OccluderData*>::iterator _current, _occludeeCandidate;
+ // deque<OccluderData*>::iterator _current, _occludeeCandidate;
vector<OccluderData *>::iterator _current, _occludeeCandidate;
#ifdef WITH_CXX_GUARDEDALLOC
@@ -171,7 +175,7 @@ class SphericalGrid {
void getCellCoordinates(const Vec3r &point, unsigned &x, unsigned &y);
typedef PointerSequence<vector<Cell *>, Cell *> cellContainer;
- //typedef PointerSequence<deque<OccluderData*>, OccluderData*> occluderContainer;
+ // typedef PointerSequence<deque<OccluderData*>, OccluderData*> occluderContainer;
typedef PointerSequence<vector<OccluderData *>, OccluderData *> occluderContainer;
unsigned _cellsX, _cellsY;
float _cellSize;
@@ -222,8 +226,8 @@ inline bool SphericalGrid::Iterator::testOccluder(bool wantOccludee)
{
// End-of-list is not even a valid iterator position
if (_current == _cell->faces.end()) {
- // Returning true seems strange, but it will break us out of whatever loop is calling testOccluder, and
- // _current=_cell->face.end() will make the calling routine give up.
+ // Returning true seems strange, but it will break us out of whatever loop is calling
+ // testOccluder, and _current=_cell->face.end() will make the calling routine give up.
return true;
}
#if SPHERICAL_GRID_LOGGING
@@ -286,15 +290,17 @@ inline bool SphericalGrid::Iterator::testOccluder(bool wantOccludee)
return false;
}
- // We've done all the corner cutting we can. Let the caller work out whether or not the geometry is correct.
+ // We've done all the corner cutting we can. Let the caller work out whether or not the geometry
+ // is correct.
return true;
}
inline void SphericalGrid::Iterator::reportDepth(Vec3r origin, Vec3r u, real t)
{
- // The reported depth is the length of a ray in camera space. We need to convert it into the distance from viewpoint
- // If origin is the viewpoint, depth == t. A future optimization could allow the caller to tell us if origin is
- // viewponit or target, at the cost of changing the OptimizedGrid API.
+ // The reported depth is the length of a ray in camera space. We need to convert it into the
+ // distance from viewpoint If origin is the viewpoint, depth == t. A future optimization could
+ // allow the caller to tell us if origin is viewponit or target, at the cost of changing the
+ // OptimizedGrid API.
real depth = (origin + u * t).norm();
#if SPHERICAL_GRID_LOGGING
if (G.debug & G_DEBUG_FREESTYLE) {
diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
index d9258a05ebd..d1f9a5b41bd 100644
--- a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
+++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
@@ -16,7 +16,8 @@
/** \file
* \ingroup freestyle
- * \brief Convenient access to the steerable ViewMap to which any element of the ViewMap belongs to.
+ * \brief Convenient access to the steerable ViewMap to which any element of the ViewMap belongs
+ * to.
*/
#include <sstream>
@@ -146,7 +147,7 @@ double *SteerableViewMap::AddFEdge(FEdge *iFEdge)
unsigned SteerableViewMap::getSVMNumber(const Vec2f &orient)
{
Vec2f dir(orient);
- //soc unsigned res = 0;
+ // soc unsigned res = 0;
real norm = dir.norm();
if (norm < 1.0e-6) {
return _nbOrientations + 1;
@@ -211,11 +212,11 @@ float SteerableViewMap::readSteerableViewMapPixel(unsigned iOrientation, int iLe
}
if ((x < 0) || (x >= pyramid->width()) || (y < 0) || (y >= pyramid->height()))
return 0;
- //float v = pyramid->pixel(x, pyramid->height() - 1 - y, iLevel) * 255.0f;
- // We encode both the directionality and the lines counting on 8 bits (because of frame buffer). Thus, we allow
- // until 8 lines to pass through the same pixel, so that we can discretize the Pi/_nbOrientations angle into
- // 32 slices. Therefore, for example, in the vertical direction, a vertical line will have the value 32 on
- // each pixel it passes through.
+ // float v = pyramid->pixel(x, pyramid->height() - 1 - y, iLevel) * 255.0f;
+ // We encode both the directionality and the lines counting on 8 bits (because of frame buffer).
+ // Thus, we allow until 8 lines to pass through the same pixel, so that we can discretize the
+ // Pi/_nbOrientations angle into 32 slices. Therefore, for example, in the vertical direction, a
+ // vertical line will have the value 32 on each pixel it passes through.
float v = pyramid->pixel(x, pyramid->height() - 1 - y, iLevel) / 32.0f;
return v;
}
@@ -243,31 +244,31 @@ void SteerableViewMap::saveSteerableViewMap() const
int ow = _imagesPyramids[i]->width(0);
int oh = _imagesPyramids[i]->height(0);
- //soc QString base("SteerableViewMap");
+ // soc QString base("SteerableViewMap");
string base("SteerableViewMap");
stringstream filename;
- for (int j = 0; j < _imagesPyramids[i]->getNumberOfLevels(); ++j) { //soc
+ for (int j = 0; j < _imagesPyramids[i]->getNumberOfLevels(); ++j) { // soc
float coeff = 1.0f; // 1 / 255.0f; // 100 * 255; // * pow(2, j);
- //soc QImage qtmp(ow, oh, QImage::Format_RGB32);
+ // soc QImage qtmp(ow, oh, QImage::Format_RGB32);
ImBuf *ibuf = IMB_allocImBuf(ow, oh, 32, IB_rect);
int rowbytes = ow * 4;
char *pix;
- for (int y = 0; y < oh; ++y) { //soc
- for (int x = 0; x < ow; ++x) { //soc
+ for (int y = 0; y < oh; ++y) { // soc
+ for (int x = 0; x < ow; ++x) { // soc
int c = (int)(coeff * _imagesPyramids[i]->pixel(x, y, j));
if (c > 255)
c = 255;
- //int c = (int)(_imagesPyramids[i]->pixel(x, y, j));
+ // int c = (int)(_imagesPyramids[i]->pixel(x, y, j));
- //soc qtmp.setPixel(x, y, qRgb(c, c, c));
+ // soc qtmp.setPixel(x, y, qRgb(c, c, c));
pix = (char *)ibuf->rect + y * rowbytes + x * 4;
pix[0] = pix[1] = pix[2] = c;
}
}
- //soc qtmp.save(base+QString::number(i)+"-"+QString::number(j)+".png", "PNG");
+ // soc qtmp.save(base+QString::number(i)+"-"+QString::number(j)+".png", "PNG");
filename << base;
filename << i << "-" << j << ".png";
ibuf->ftype = IMB_FTYPE_PNG;
diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.h b/source/blender/freestyle/intern/view_map/SteerableViewMap.h
index 16f57f39737..537f07f44f4 100644
--- a/source/blender/freestyle/intern/view_map/SteerableViewMap.h
+++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.h
@@ -19,7 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Convenient access to the steerable ViewMap to which any element of the ViewMap belongs to.
+ * \brief Convenient access to the steerable ViewMap to which any element of the ViewMap belongs
+ * to.
*/
#include <map>
@@ -42,8 +43,8 @@ class FEdge;
class ImagePyramid;
class GrayImage;
-/*! This class checks for every FEdge in which steerable it belongs and stores the mapping allowing to retrieve
- * this information from the FEdge Id.
+/*! This class checks for every FEdge in which steerable it belongs and stores the mapping
+ * allowing to retrieve this information from the FEdge Id.
*/
class SteerableViewMap {
protected:
@@ -66,8 +67,8 @@ class SteerableViewMap {
virtual void Reset();
/*! Adds a FEdge to steerable VM.
- * Returns the nbOrientations weights corresponding to the FEdge contributions to the nbOrientations
- * directional maps.
+ * Returns the nbOrientations weights corresponding to the FEdge contributions to the
+ * nbOrientations directional maps.
*/
double *AddFEdge(FEdge *iFEdge);
@@ -86,12 +87,14 @@ class SteerableViewMap {
*/
unsigned getSVMNumber(unsigned id);
- /*! Builds _nbOrientations+1 pyramids of images from the _nbOrientations+1 base images of the steerable viewmap.
+ /*! Builds _nbOrientations+1 pyramids of images from the _nbOrientations+1 base images of the
+ * steerable viewmap.
* \param steerableBases:
* The _nbOrientations+1 images constituting the basis for the steerable pyramid.
* \param copy:
* If false, the data is not duplicated, and Canvas deals with the memory management of these
- * _nbOrientations+1 images. If true, data is copied, and it's up to the caller to delete the images.
+ * _nbOrientations+1 images. If true, data is copied, and it's up to the caller to delete
+ * the images.
* \param iNbLevels:
* The number of levels desired for each pyramid.
* If iNbLevels == 0, the complete pyramid is built.
@@ -116,13 +119,16 @@ class SteerableViewMap {
* \param iLevel:
* The level of the pyramid we want to read
* \param x:
- * The abscissa of the desired pixel specified in level0 coordinate system. The origin is the lower left corner.
+ * The abscissa of the desired pixel specified in level0 coordinate system.
+ * The origin is the lower left corner.
* \param y:
- * The ordinate of the desired pixel specified in level0 coordinate system. The origin is the lower left corner.
+ * The ordinate of the desired pixel specified in level0 coordinate system.
+ * The origin is the lower left corner.
*/
float readSteerableViewMapPixel(unsigned iOrientation, int iLevel, int x, int y);
- /*! Reads a pixel in the one of the level of the pyramid containing the images of the complete ViewMap.
+ /*! Reads a pixel in the one of the level of the pyramid containing the images
+ * of the complete ViewMap.
* Returns a value between 0 and 1.
* Equivalent to : readSteerableViewMapPixel(nbOrientations, x, y)
*/
diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
index 629ec3d5d77..8715f4f52d9 100644
--- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
@@ -79,8 +79,8 @@ void ViewEdgeXBuilder::BuildViewEdges(WXShape *iWShape,
continue;
if (stopSmoothViewEdge((*sl))) // has it been parsed already ?
continue;
- // here we know that we're dealing with a face layer that has not been processed yet and that contains
- // a smooth edge.
+ // here we know that we're dealing with a face layer that has not been processed yet and that
+ // contains a smooth edge.
/* vedge =*//* UNUSED */ BuildSmoothViewEdge(OWXFaceLayer(*sl, true));
}
}
@@ -89,7 +89,7 @@ void ViewEdgeXBuilder::BuildViewEdges(WXShape *iWShape,
//----------------------------------
// Reset all userdata for WXEdge structure
//----------------------------------------
- //iWShape->ResetUserData();
+ // iWShape->ResetUserData();
WXEdge *wxe;
vector<WEdge *> &wedges = iWShape->getEdgeList();
@@ -339,7 +339,8 @@ OWXFaceLayer ViewEdgeXBuilder::FindNextFaceLayer(const OWXFaceLayer &iFaceLayer)
nextFace = dynamic_cast<WXFace *>(iFaceLayer.fl->getFace()->GetBordingFace(woeend));
if (!nextFace)
return OWXFaceLayer(NULL, true);
- // if the next face layer has either no smooth edge or no smooth edge of same nature, no next face
+ // if the next face layer has either no smooth edge or no smooth edge of same nature, no next
+ // face
if (!nextFace->hasSmoothEdges())
return OWXFaceLayer(NULL, true);
vector<WXFaceLayer *> sameNatureLayers;
@@ -411,7 +412,8 @@ OWXFaceLayer ViewEdgeXBuilder::FindPreviousFaceLayer(const OWXFaceLayer &iFaceLa
previousFace = dynamic_cast<WXFace *>(iFaceLayer.fl->getFace()->GetBordingFace(woebegin));
if (0 == previousFace)
return OWXFaceLayer(NULL, true);
- // if the next face layer has either no smooth edge or no smooth edge of same nature, no next face
+ // if the next face layer has either no smooth edge or no smooth edge of same nature, no next
+ // face
if (!previousFace->hasSmoothEdges())
return OWXFaceLayer(NULL, true);
vector<WXFaceLayer *> sameNatureLayers;
@@ -688,7 +690,7 @@ FEdge *ViewEdgeXBuilder::BuildSharpFEdge(FEdge *feprevious, const OWXEdge &iwe)
_pCurrentSShape->AddEdge(fe);
va->AddFEdge(fe);
vb->AddFEdge(fe);
- //Add normals:
+ // Add normals:
va->AddNormal(normalA);
va->AddNormal(normalB);
vb->AddNormal(normalA);
diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
index 6f3604a1029..26f114497c0 100644
--- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
+++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
@@ -28,7 +28,8 @@
#if 0 // soc
# if defined(__GNUC__) && (__GNUC__ >= 3)
-//hash_map is not part of the C++ standard anymore; hash_map.h has been kept though for backward compatibility
+/* hash_map is not part of the C++ standard anymore;
+ * hash_map.h has been kept though for backward compatibility */
# include <hash_map.h>
# else
# include <hash_map>
@@ -278,9 +279,9 @@ class ViewEdgeXBuilder {
/*! instanciate a ViewVertex from a SVertex, if it doesn't exist yet */
ViewVertex *MakeViewVertex(SVertex *iSVertex);
- //oldtmp values
- //IdHashTable _hashtable;
- //VVIdHashTable _multivertexHashTable;
+ // oldtmp values
+ // IdHashTable _hashtable;
+ // VVIdHashTable _multivertexHashTable;
SVertexMap _SVertexMap;
SShape *_pCurrentSShape;
ViewShape *_pCurrentVShape;
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.cpp b/source/blender/freestyle/intern/view_map/ViewMap.cpp
index d859f83079c..0b352be1a89 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMap.cpp
@@ -155,8 +155,8 @@ TVertex *ViewMap::CreateTVertex(const Vec3r &iA3D,
SVertex *Ia = shapeA->CreateSVertex(iA3D, iA2D, iFEdgeA->vertexA()->getId());
SVertex *Ib = shapeB->CreateSVertex(iB3D, iB2D, iFEdgeB->vertexA()->getId());
- // depending on which of these 2 svertices is the nearest from the viewpoint, we're going to build the TVertex
- // by giving them in an order or another (the first one must be the nearest)
+ // depending on which of these 2 svertices is the nearest from the viewpoint, we're going to
+ // build the TVertex by giving them in an order or another (the first one must be the nearest)
real dista = Ia->point2D()[2];
real distb = Ib->point2D()[2];
@@ -185,8 +185,8 @@ ViewVertex *ViewMap::InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newV
NonTVertex *vva = dynamic_cast<NonTVertex *>(iVertex->viewvertex());
if (vva)
return vva;
- // because it is not already a ViewVertex, this SVertex must have only 2 FEdges. The incoming one still belongs
- // to ioEdge, the outgoing one now belongs to newVEdge
+ // because it is not already a ViewVertex, this SVertex must have only 2 FEdges. The incoming one
+ // still belongs to ioEdge, the outgoing one now belongs to newVEdge
const vector<FEdge *> &fedges = iVertex->fedges();
if (fedges.size() != 2) {
cerr << "ViewMap warning: Can't split the ViewEdge" << endl;
@@ -235,7 +235,7 @@ ViewVertex *ViewMap::InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newV
ViewEdge *newVEdge = new ViewEdge(vva, ioEdge->B(), fbegin, ioEdge->fedgeB(), vshape);
newVEdge->setId(Id(ioEdge->getId().getFirst(), ioEdge->getId().getSecond() + 1));
newVEdge->setNature(ioEdge->getNature());
- //newVEdge->UpdateFEdges(); // done in the ViewEdge constructor
+ // newVEdge->UpdateFEdges(); // done in the ViewEdge constructor
// Update old ViewEdge
ioEdge->setB(vva);
ioEdge->setFEdgeB(fend);
@@ -253,7 +253,7 @@ ViewVertex *ViewMap::InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newV
vvb->Replace(ioEdge, newVEdge);
// update ViewShape
- //vshape->AddEdge(newVEdge);
+ // vshape->AddEdge(newVEdge);
// update SShape
vshape->sshape()->AddChain(fbegin);
// update ViewMap
@@ -421,25 +421,27 @@ void TVertex::Replace(ViewEdge *iOld, ViewEdge *iNew)
/*! iterators access */
ViewVertex::edge_iterator TVertex::edges_begin()
{
- //return edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, _FrontEdgeA);
+ // return edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, _FrontEdgeA);
return edge_iterator(_sortedEdges.begin(), _sortedEdges.end(), _sortedEdges.begin());
}
ViewVertex::const_edge_iterator TVertex::edges_begin() const
{
- //return const_edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, _FrontEdgeA);
+ // return const_edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, _FrontEdgeA);
return const_edge_iterator(_sortedEdges.begin(), _sortedEdges.end(), _sortedEdges.begin());
}
ViewVertex::edge_iterator TVertex::edges_end()
{
- //return edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, directedViewEdge(0,true));
+ // return edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB,
+ // directedViewEdge(0,true));
return edge_iterator(_sortedEdges.begin(), _sortedEdges.end(), _sortedEdges.end());
}
ViewVertex::const_edge_iterator TVertex::edges_end() const
{
- //return const_edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, directedViewEdge(0, true));
+ // return const_edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB,
+ // directedViewEdge(0, true));
return const_edge_iterator(_sortedEdges.begin(), _sortedEdges.end(), _sortedEdges.end());
}
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h
index 96c9c3c0b4a..9b1eab0d905 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.h
+++ b/source/blender/freestyle/intern/view_map/ViewMap.h
@@ -75,8 +75,8 @@ class ViewMap {
fedges_container _FEdges; // feature edges (embedded edges)
svertices_container _SVertices; // embedded vertices
BBox<Vec3r> _scene3DBBox;
- // Mapping between the WShape or VShape id to the VShape index in the _VShapes vector. Used in the method
- // viewShape(int id) to access a shape from its id.
+ // Mapping between the WShape or VShape id to the VShape index in the _VShapes vector. Used in
+ // the method viewShape(int id) to access a shape from its id.
id_to_index_map _shapeIdToIndex;
public:
@@ -222,16 +222,15 @@ class ViewMap {
FEdge *iFEdgeB,
const Id &id);
- /* Updates the structures to take into account the fact that a SVertex must now be considered as a ViewVertex
- * iVertex
- * The SVertex on top of which the ViewVertex is built (it is necessarily a NonTVertex because it is a SVertex)
- * newViewEdges
- * The new ViewEdges that must be add to the ViewMap
+ /* Updates the structures to take into account the fact that a SVertex must now be considered as
+ * a ViewVertex iVertex The SVertex on top of which the ViewVertex is built (it is necessarily a
+ * NonTVertex because it is a SVertex) newViewEdges The new ViewEdges that must be add to the
+ * ViewMap
*/
ViewVertex *InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newViewEdges);
/* connects a FEdge to the graph trough a SVertex */
- //FEdge *Connect(FEdge *ioEdge, SVertex *ioVertex);
+ // FEdge *Connect(FEdge *ioEdge, SVertex *ioVertex);
/* Clean temporary FEdges created by chaining */
virtual void Clean();
@@ -262,11 +261,12 @@ class orientedViewEdgeIterator;
} // namespace ViewVertexInternal
/*! Class to define a view vertex.
- * A view vertex is a feature vertex corresponding to a point of the image graph, where the characteristics of an
- * edge might change (nature, visibility, ...).
- * A ViewVertex can be of two kinds: a TVertex when it corresponds to the intersection between two ViewEdges or a
- * NonTVertex when it corresponds to a vertex of the initial input mesh (it is the case for vertices such as corners
- * for example). Thus, this class can be specialized into two classes, the TVertex class and the NonTVertex class.
+ * A view vertex is a feature vertex corresponding to a point of the image graph, where the
+ * characteristics of an edge might change (nature, visibility, ...). A ViewVertex can be of two
+ * kinds: a TVertex when it corresponds to the intersection between two ViewEdges or a NonTVertex
+ * when it corresponds to a vertex of the initial input mesh (it is the case for vertices such as
+ * corners for example). Thus, this class can be specialized into two classes, the TVertex class
+ * and the NonTVertex class.
*/
class ViewVertex : public Interface0D {
public: // Implementation of Interface0D
@@ -348,8 +348,8 @@ class ViewVertex : public Interface0D {
public:
/* iterators access */
- // allows iteration on the edges that comes from/goes to this vertex in CCW order (order defined in 2D in the
- // image plan)
+ // allows iteration on the edges that comes from/goes to this vertex in CCW order (order defined
+ // in 2D in the image plan)
virtual edge_iterator edges_begin() = 0;
virtual const_edge_iterator edges_begin() const = 0;
virtual edge_iterator edges_end() = 0;
@@ -358,13 +358,14 @@ class ViewVertex : public Interface0D {
virtual const_edge_iterator edges_iterator(ViewEdge *iEdge) const = 0;
// Iterator access
- /*! Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to the first
- * ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order over these ViewEdges
- * and to get the orientation for each ViewEdge (incoming/outgoing).
+ /*! Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to
+ * the first ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order
+ * over these ViewEdges and to get the orientation for each ViewEdge (incoming/outgoing).
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesBegin() = 0;
- /*! Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after the last ViewEdge.
+ /*! Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after
+ * the last ViewEdge.
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesEnd() = 0;
@@ -477,7 +478,8 @@ class TVertex : public ViewVertex {
directedViewEdge _FrontEdgeB;
directedViewEdge _BackEdgeA;
directedViewEdge _BackEdgeB;
- Id _Id; // id to identify t vertices . these id will be negative in order not to be mixed with NonTVertex ids.
+ Id _Id; // id to identify t vertices . these id will be negative in order not to be mixed with
+ // NonTVertex ids.
edge_pointers_container
_sortedEdges; // the list of the four ViewEdges, ordered in CCW order (in the image plan)
@@ -606,8 +608,8 @@ class TVertex : public ViewVertex {
virtual void Replace(ViewEdge *iOld, ViewEdge *iNew);
/*! returns the mate edge of iEdgeA.
- * For example, if iEdgeA is frontEdgeA, then frontEdgeB is returned. If iEdgeA is frontEdgeB then frontEdgeA
- * is returned. Same for back edges
+ * For example, if iEdgeA is frontEdgeA, then frontEdgeB is returned. If iEdgeA is frontEdgeB
+ * then frontEdgeA is returned. Same for back edges
*/
virtual ViewEdge *mate(ViewEdge *iEdgeA)
{
@@ -630,13 +632,14 @@ class TVertex : public ViewVertex {
virtual edge_iterator edges_iterator(ViewEdge *iEdge);
virtual const_edge_iterator edges_iterator(ViewEdge *iEdge) const;
- /*! Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to the first
- * ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order over these ViewEdges
- * and to get the orientation for each ViewEdge (incoming/outgoing).
+ /*! Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to
+ * the first ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order
+ * over these ViewEdges and to get the orientation for each ViewEdge (incoming/outgoing).
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesBegin();
- /*! Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after the last ViewEdge.
+ /*! Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after
+ * the last ViewEdge.
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesEnd();
@@ -847,13 +850,14 @@ class NonTVertex : public ViewVertex {
virtual edge_iterator edges_iterator(ViewEdge *iEdge);
virtual const_edge_iterator edges_iterator(ViewEdge *iEdge) const;
- /*! Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to the first
- * ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order over these ViewEdges
- * and to get the orientation for each ViewEdge (incoming/outgoing).
+ /*! Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to
+ * the first ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order
+ * over these ViewEdges and to get the orientation for each ViewEdge (incoming/outgoing).
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesBegin();
- /*! Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after the last ViewEdge.
+ /*! Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after
+ * the last ViewEdge.
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesEnd();
@@ -891,8 +895,8 @@ template<class Traits> class vertex_iterator_base;
} // end of namespace ViewEdgeInternal
-/*! Class defining a ViewEdge. A ViewEdge in an edge of the image graph. it connects two ViewVertex.
- * It is made by connecting a set of FEdges.
+/*! Class defining a ViewEdge. A ViewEdge in an edge of the image graph. it connects two
+ * ViewVertex. It is made by connecting a set of FEdges.
*/
class ViewEdge : public Interface1D {
public: // Implementation of Interface0D
@@ -937,9 +941,9 @@ class ViewEdge : public Interface1D {
FEdge *_FEdgeB; // last edge of the embedded fedges chain
Id _Id;
unsigned _ChainingTimeStamp;
- // The silhouette view edge separates 2 2D spaces. The one on the left is necessarly the Shape _Shape (the one to
- // which this edge belongs to) and _aShape is the one on its right
- // NOT HANDLED BY THE COPY CONSTRUCTOR
+ // The silhouette view edge separates 2 2D spaces. The one on the left is necessarly the Shape
+ // _Shape (the one to which this edge belongs to) and _aShape is the one on its right NOT HANDLED
+ // BY THE COPY CONSTRUCTOR
ViewShape *_aShape;
int _qi;
vector<ViewShape *> _Occluders;
@@ -1016,7 +1020,7 @@ class ViewEdge : public Interface1D {
UpdateFEdges(); // tells every FEdge between iFEdgeA and iFEdgeB that this is theit ViewEdge
}
- //soc protected:
+ // soc protected:
/*! Copy constructor. */
inline ViewEdge(ViewEdge &iBrother)
{
@@ -1091,9 +1095,8 @@ class ViewEdge : public Interface1D {
return _Shape;
}
- /*! Returns the shape that is occluded by the ViewShape to which this ViewEdge belongs to. If no object is occluded,
- * NULL is returned.
- * \return The occluded ViewShape.
+ /*! Returns the shape that is occluded by the ViewShape to which this ViewEdge belongs to. If no
+ * object is occluded, NULL is returned. \return The occluded ViewShape.
*/
inline ViewShape *aShape()
{
@@ -1316,7 +1319,7 @@ class ViewEdge : public Interface1D {
return false;
}
- //inline real z_discontinuity(int iCombination = 0) const;
+ // inline real z_discontinuity(int iCombination = 0) const;
inline Id shape_id() const
{
@@ -1353,25 +1356,25 @@ class ViewEdge : public Interface1D {
vertex_iterator vertices_end();
// Iterator access (Interface1D)
- /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this ViewEdge.
- * The returned Interface0DIterator points to the first SVertex of the ViewEdge.
+ /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this
+ * ViewEdge. The returned Interface0DIterator points to the first SVertex of the ViewEdge.
*/
virtual Interface0DIterator verticesBegin();
- /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this ViewEdge.
- * The returned Interface0DIterator points after the last SVertex of the ViewEdge.
+ /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this
+ * ViewEdge. The returned Interface0DIterator points after the last SVertex of the ViewEdge.
*/
virtual Interface0DIterator verticesEnd();
- /*! Returns an Interface0DIterator to iterate over the points of this ViewEdge at a given resolution.
- * The returned Interface0DIterator points on the first Point of the ViewEdge.
+ /*! Returns an Interface0DIterator to iterate over the points of this ViewEdge at a given
+ * resolution. The returned Interface0DIterator points on the first Point of the ViewEdge.
* \param t:
* the sampling value.
*/
virtual Interface0DIterator pointsBegin(float t = 0.0f);
- /*! Returns an Interface0DIterator to iterate over the points of this ViewEdge at a given resolution.
- * The returned Interface0DIterator points after the last Point of the ViewEdge.
+ /*! Returns an Interface0DIterator to iterate over the points of this ViewEdge at a given
+ * resolution. The returned Interface0DIterator points after the last Point of the ViewEdge.
* \param t:
* the sampling value.
*/
@@ -1390,7 +1393,8 @@ class ViewEdge : public Interface1D {
/* */
/**********************************/
-/*! Class gathering the elements of the ViewMap (ViewVertex, ViewEdge) that are issued from the same input shape. */
+/*! Class gathering the elements of the ViewMap (ViewVertex, ViewEdge) that are issued from the
+ * same input shape. */
class ViewShape {
private:
vector<ViewVertex *> _Vertices;
@@ -1520,11 +1524,10 @@ class ViewShape {
* The FEdge that gets splitted
* iViewVertices
* The view vertices corresponding to the different intersections for the edge fe.
- * This list need to be sorted such as the first view vertex is the farther away from fe->vertexA.
- * ioNewEdges
- * The feature edges that are newly created (the initial edges are not included) are added to this list.
- * ioNewViewEdges
- * The view edges that are newly created (the initial edges are not included) are added to this list.
+ * This list need to be sorted such as the first view vertex is the farther away from
+ * fe->vertexA. ioNewEdges The feature edges that are newly created (the initial edges are not
+ * included) are added to this list. ioNewViewEdges The view edges that are newly created (the
+ * initial edges are not included) are added to this list.
*/
inline void SplitEdge(FEdge *fe,
const vector<TVertex *> &iViewVertices,
@@ -1608,7 +1611,8 @@ class ViewShape {
//_SShape->AddNewEdge(iEdge->fedge());
}
- /* removes the view edge iViewEdge in the View Shape and the associated FEdge chain entry in the underlying SShape
+ /* removes the view edge iViewEdge in the View Shape and the associated FEdge chain entry in the
+ * underlying SShape
*/
void RemoveEdge(ViewEdge *iViewEdge);
@@ -1681,28 +1685,30 @@ void ViewShape::SplitEdge(FEdge *fe,
ViewEdge *newVEdge;
if ((vva == 0) || (vvb == 0)) { // that means we're dealing with a closed viewedge (loop)
- // remove the chain that was starting by the fedge A of vEdge (which is different from fe !!!!)
+ // remove the chain that was starting by the fedge A of vEdge (which is different from fe
+ // !!!!)
shape->RemoveEdgeFromChain(vEdge->fedgeA());
// we set
vEdge->setA(*vv);
vEdge->setB(*vv);
vEdge->setFEdgeA(newEdge);
- //FEdge *previousEdge = newEdge->previousEdge();
+ // FEdge *previousEdge = newEdge->previousEdge();
vEdge->setFEdgeB(fe);
newVEdge = vEdge;
vEdge->fedgeA()->setViewEdge(newVEdge);
}
else {
- // while we create the view edge, it updates the "ViewEdge" pointer of every underlying FEdges to this.
+ // while we create the view edge, it updates the "ViewEdge" pointer of every underlying
+ // FEdges to this.
newVEdge = new ViewEdge((*vv), vvb); //, newEdge, vEdge->fedgeB());
newVEdge->setNature((fe)->getNature());
newVEdge->setFEdgeA(newEdge);
- //newVEdge->setFEdgeB(fe);
+ // newVEdge->setFEdgeB(fe);
// If our original viewedge is made of one FEdge, then
if ((vEdge->fedgeA() == vEdge->fedgeB()) || (fe == vEdge->fedgeB()))
newVEdge->setFEdgeB(newEdge);
else
- newVEdge->setFEdgeB(vEdge->fedgeB()); //MODIF
+ newVEdge->setFEdgeB(vEdge->fedgeB()); // MODIF
Id *newId = vEdge->splittingId();
if (newId == 0) {
@@ -1728,7 +1734,7 @@ void ViewShape::SplitEdge(FEdge *fe,
// we split the view edge:
vEdge->setB((*vv));
- vEdge->setFEdgeB(fe); //MODIF
+ vEdge->setFEdgeB(fe); // MODIF
// Update fedges so that they point to the new viewedge:
newVEdge->UpdateFEdges();
diff --git a/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h b/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
index 6af70120832..63343c33c4f 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
@@ -165,7 +165,7 @@ class edge_iterator_base : public IteratorBase<Traits, InputIteratorTag_Traits>
{
}
- //protected://FIXME
+ // protected://FIXME
public:
#if 0
inline edge_iterator_base(
@@ -208,7 +208,7 @@ class edge_iterator_base : public IteratorBase<Traits, InputIteratorTag_Traits>
{
if (_Nature & Nature::T_VERTEX)
return (_tvertex_iter == _tbegin);
- //return (_tvertex_iter == _feA);
+ // return (_tvertex_iter == _feA);
else
return (_nontvertex_iter == _begin);
}
@@ -216,7 +216,7 @@ class edge_iterator_base : public IteratorBase<Traits, InputIteratorTag_Traits>
virtual bool end() const
{
if (_Nature & Nature::T_VERTEX)
- //return (_tvertex_iter.first == 0);
+ // return (_tvertex_iter.first == 0);
return (_tvertex_iter == _tend);
else
return (_nontvertex_iter == _end);
@@ -257,7 +257,7 @@ class edge_iterator_base : public IteratorBase<Traits, InputIteratorTag_Traits>
virtual reference operator*() const
{
if (_Nature & Nature::T_VERTEX)
- //return _tvertex_iter;
+ // return _tvertex_iter;
return **_tvertex_iter;
else
return (*_nontvertex_iter);
@@ -362,8 +362,8 @@ class edge_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag_
public:
mutable value_type _ViewEdge;
- //friend class edge_iterator_base<Nonconst_traits<ViewEdge*> >;
- //friend class edge_iterator_base<Const_traits<ViewEdge*> >;
+ // friend class edge_iterator_base<Nonconst_traits<ViewEdge*> >;
+ // friend class edge_iterator_base<Const_traits<ViewEdge*> >;
value_type _first;
bool _orientation;
typedef IteratorBase<Traits, BidirectionalIteratorTag_Traits> parent_class;
@@ -392,7 +392,7 @@ class edge_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag_
_orientation = iBrother._orientation;
}
- //protected://FIXME
+ // protected://FIXME
public:
inline edge_iterator_base(value_type iEdge, bool orientation = true) : parent_class()
{
@@ -550,7 +550,7 @@ class fedge_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag
_FEdgeB = iBrother._FEdgeB;
}
- //protected://FIXME
+ // protected://FIXME
public:
inline fedge_iterator_base(value_type iEdge, value_type iFEdgeB) : parent_class()
{
@@ -687,7 +687,7 @@ class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTa
_PreviousFEdge = iBrother._PreviousFEdge;
}
- //protected://FIXME
+ // protected://FIXME
public:
inline vertex_iterator_base(value_type iVertex, FEdge *iPreviousFEdge, FEdge *iNextFEdge)
: parent_class()
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
index 44d840c2cc5..f990b7bd63a 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
@@ -125,7 +125,7 @@ static void findOccludee(FEdge *fe,
else {
// check whether the edge and the polygon plane are coincident:
//-------------------------------------------------------------
- //first let us compute the plane equation.
+ // first let us compute the plane equation.
if (GeomUtils::COINCIDENT ==
GeomUtils::intersectRayPlane(origin, edgeDir, p->getNormal(), d, t, epsilon)) {
#if LOGGING
@@ -255,8 +255,9 @@ static int computeVisibility(ViewMap *viewMap,
I occluders(grid, center, epsilon);
for (occluders.initBeforeTarget(); occluders.validBeforeTarget(); occluders.nextOccluder()) {
- // If we're dealing with an exact silhouette, check whether we must take care of this occluder of not.
- // (Indeed, we don't consider the occluders that share at least one vertex with the face containing this edge).
+ // If we're dealing with an exact silhouette, check whether we must take care of this occluder
+ // of not. (Indeed, we don't consider the occluders that share at least one vertex with the
+ // face containing this edge).
//-----------
oface = occluders.getWFace();
Polygon3r *p = occluders.getCameraSpacePolygon();
@@ -324,8 +325,8 @@ static int computeVisibility(ViewMap *viewMap,
continue;
WFace *sface = (*ie)->GetbFace();
- //WFace *sfacea = (*ie)->GetaFace();
- //if ((sface == oface) || (sfacea == oface))
+ // WFace *sfacea = (*ie)->GetaFace();
+ // if ((sface == oface) || (sfacea == oface))
if (sface == oface) {
skipFace = true;
break;
@@ -346,7 +347,7 @@ static int computeVisibility(ViewMap *viewMap,
else {
// check whether the edge and the polygon plane are coincident:
//-------------------------------------------------------------
- //first let us compute the plane equation.
+ // first let us compute the plane equation.
if (GeomUtils::COINCIDENT ==
GeomUtils::intersectRayPlane(origin, edgeDir, p->getNormal(), d, t, epsilon)) {
#if LOGGING
@@ -412,11 +413,12 @@ static int computeVisibility(ViewMap *viewMap,
// computeCumulativeVisibility returns the lowest x such that the majority of FEdges have QI <= x
//
-// This was probably the original intention of the "normal" algorithm on which computeDetailedVisibility is based.
-// But because the "normal" algorithm chooses the most popular QI, without considering any other values, a ViewEdge
-// with FEdges having QIs of 0, 21, 22, 23, 24 and 25 will end up having a total QI of 0, even though most of the
-// FEdges are heavily occluded. computeCumulativeVisibility will treat this case as a QI of 22 because 3 out of
-// 6 occluders have QI <= 22.
+// This was probably the original intention of the "normal" algorithm on which
+// computeDetailedVisibility is based. But because the "normal" algorithm chooses the most popular
+// QI, without considering any other values, a ViewEdge with FEdges having QIs of 0, 21, 22, 23, 24
+// and 25 will end up having a total QI of 0, even though most of the FEdges are heavily occluded.
+// computeCumulativeVisibility will treat this case as a QI of 22 because 3 out of 6 occluders have
+// QI <= 22.
template<typename G, typename I>
static void computeCumulativeVisibility(ViewMap *ioViewMap,
@@ -513,7 +515,7 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
continue;
}
if ((maxCard < qiMajority)) {
- //ARB: change &wFace to wFace and use reference in called function
+ // ARB: change &wFace to wFace and use reference in called function
tmpQI = computeVisibility<G, I>(
ioViewMap, fe, grid, epsilon, *ve, &wFace, &foundOccluders);
#if LOGGING
@@ -522,11 +524,11 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
}
#endif
- //ARB: This is an error condition, not an alert condition.
+ // ARB: This is an error condition, not an alert condition.
// Some sort of recovery or abort is necessary.
if (tmpQI >= 256) {
cerr << "Warning: too many occluding levels" << endl;
- //ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
+ // ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
tmpQI = 255;
}
@@ -536,8 +538,8 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
}
}
else {
- //ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
- //ARB: change &wFace to wFace and use reference in called function
+ // ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
+ // ARB: change &wFace to wFace and use reference in called function
findOccludee<G, I>(fe, grid, epsilon, *ve, &wFace);
#if LOGGING
if (_global.debug & G_DEBUG_FREESTYLE) {
@@ -589,8 +591,8 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
}
}
// occluders --
- // I would rather not have to go through the effort of creating this set and then copying out its contents.
- // Is there a reason why ViewEdge::_Occluders cannot be converted to a set<>?
+ // I would rather not have to go through the effort of creating this set and then copying out
+ // its contents. Is there a reason why ViewEdge::_Occluders cannot be converted to a set<>?
for (set<ViewShape *>::iterator o = foundOccluders.begin(), oend = foundOccluders.end();
o != oend;
++o) {
@@ -710,7 +712,7 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
continue;
}
if ((maxCard < qiMajority)) {
- //ARB: change &wFace to wFace and use reference in called function
+ // ARB: change &wFace to wFace and use reference in called function
tmpQI = computeVisibility<G, I>(
ioViewMap, fe, grid, epsilon, *ve, &wFace, &foundOccluders);
#if LOGGING
@@ -719,11 +721,11 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
}
#endif
- //ARB: This is an error condition, not an alert condition.
+ // ARB: This is an error condition, not an alert condition.
// Some sort of recovery or abort is necessary.
if (tmpQI >= 256) {
cerr << "Warning: too many occluding levels" << endl;
- //ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
+ // ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
tmpQI = 255;
}
@@ -733,8 +735,8 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
}
}
else {
- //ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
- //ARB: change &wFace to wFace and use reference in called function
+ // ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
+ // ARB: change &wFace to wFace and use reference in called function
findOccludee<G, I>(fe, grid, epsilon, *ve, &wFace);
#if LOGGING
if (_global.debug & G_DEBUG_FREESTYLE) {
@@ -779,8 +781,8 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
// qi --
(*ve)->setQI(maxIndex);
// occluders --
- // I would rather not have to go through the effort of creating this this set and then copying out its contents.
- // Is there a reason why ViewEdge::_Occluders cannot be converted to a set<>?
+ // I would rather not have to go through the effort of creating this this set and then copying
+ // out its contents. Is there a reason why ViewEdge::_Occluders cannot be converted to a set<>?
for (set<ViewShape *>::iterator o = foundOccluders.begin(), oend = foundOccluders.end();
o != oend;
++o) {
@@ -877,15 +879,15 @@ static void computeFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
}
if (even_test) {
if ((maxCard < qiMajority)) {
- //ARB: change &wFace to wFace and use reference in called function
+ // ARB: change &wFace to wFace and use reference in called function
tmpQI = computeVisibility<G, I>(
ioViewMap, fe, grid, epsilon, *ve, &wFace, &foundOccluders);
- //ARB: This is an error condition, not an alert condition.
+ // ARB: This is an error condition, not an alert condition.
// Some sort of recovery or abort is necessary.
if (tmpQI >= 256) {
cerr << "Warning: too many occluding levels" << endl;
- //ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
+ // ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
tmpQI = 255;
}
@@ -895,8 +897,8 @@ static void computeFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
}
}
else {
- //ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
- //ARB: change &wFace to wFace and use reference in called function
+ // ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
+ // ARB: change &wFace to wFace and use reference in called function
findOccludee<G, I>(fe, grid, epsilon, *ve, &wFace);
}
@@ -1008,7 +1010,8 @@ void ViewMapBuilder::BuildGrid(WingedEdge &we, const BBox<Vec3r> &bbox, unsigned
Vec3r size;
for (unsigned int i = 0; i < 3; i++) {
size[i] = fabs(bbox.getMax()[i] - bbox.getMin()[i]);
- // let make the grid 1/10 bigger to avoid numerical errors while computing triangles/cells intersections.
+ // let make the grid 1/10 bigger to avoid numerical errors while computing triangles/cells
+ // intersections.
size[i] += size[i] / 10.0;
if (size[i] == 0) {
if (_global.debug & G_DEBUG_FREESTYLE) {
@@ -1083,8 +1086,8 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
// Non-displayable view edges will be skipped over during visibility calculation.
- // View edges will be culled according to their position w.r.t. the viewport proscenium (viewport + 5% border,
- // or some such).
+ // View edges will be culled according to their position w.r.t. the viewport proscenium (viewport
+ // + 5% border, or some such).
// Get proscenium boundary for culling
GridHelpers::getDefaultViewProscenium(viewProscenium);
@@ -1098,17 +1101,16 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
cout << "Origin: [" << prosceniumOrigin[0] << ", " << prosceniumOrigin[1] << "]" << endl;
}
- // A separate occluder proscenium will also be maintained, starting out the same as the viewport proscenium, and
- // expanding as necessary so that it encompasses the center point of at least one feature edge in each retained view
- // edge.
- // The occluder proscenium will be used later to cull occluding triangles before they are inserted into the Grid.
- // The occluder proscenium starts out the same size as the view proscenium
+ // A separate occluder proscenium will also be maintained, starting out the same as the viewport
+ // proscenium, and expanding as necessary so that it encompasses the center point of at least one
+ // feature edge in each retained view edge. The occluder proscenium will be used later to cull
+ // occluding triangles before they are inserted into the Grid. The occluder proscenium starts out
+ // the same size as the view proscenium
GridHelpers::getDefaultViewProscenium(occluderProscenium);
- // N.B. Freestyle is inconsistent in its use of ViewMap::viewedges_container and vector<ViewEdge*>::iterator.
- // Probably all occurences of vector<ViewEdge*>::iterator should be replaced ViewMap::viewedges_container
- // throughout the code.
- // For each view edge
+ // N.B. Freestyle is inconsistent in its use of ViewMap::viewedges_container and
+ // vector<ViewEdge*>::iterator. Probably all occurences of vector<ViewEdge*>::iterator should be
+ // replaced ViewMap::viewedges_container throughout the code. For each view edge
ViewMap::viewedges_container::iterator ve, veend;
for (ve = ioViewMap->ViewEdges().begin(), veend = ioViewMap->ViewEdges().end(); ve != veend;
@@ -1130,8 +1132,8 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
// All ViewEdges start culled
(*ve)->setIsInImage(false);
- // For simple visibility calculation: mark a feature edge that is known to have a center point inside the
- // occluder proscenium. Cull all other feature edges.
+ // For simple visibility calculation: mark a feature edge that is known to have a center point
+ // inside the occluder proscenium. Cull all other feature edges.
do {
// All FEdges start culled
fe->setIsInImage(false);
@@ -1165,15 +1167,15 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
fe = fe->nextEdge();
} while (fe && fe != festart && !(bestOccluderTargetFound && (*ve)->isInImage()));
- // Either we have run out of FEdges, or we already have the one edge we need to determine visibility
- // Cull all remaining edges.
+ // Either we have run out of FEdges, or we already have the one edge we need to determine
+ // visibility Cull all remaining edges.
while (fe && fe != festart) {
fe->setIsInImage(false);
fe = fe->nextEdge();
}
- // If bestOccluderTarget was not found inside the occluder proscenium, we need to expand the occluder
- // proscenium to include it.
+ // If bestOccluderTarget was not found inside the occluder proscenium, we need to expand the
+ // occluder proscenium to include it.
if ((*ve)->isInImage() && bestOccluderTarget != NULL && !bestOccluderTargetFound) {
// Expand occluder proscenium to enclose bestOccluderTarget
Vec3r point = bestOccluderTarget->center2d();
@@ -1204,14 +1206,15 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
// For "Normal" or "Fast" style visibility computation only:
- // For more detailed visibility calculation, make a second pass through the view map, marking all feature edges
- // with center points inside the final occluder proscenium. All of these feature edges can be considered during
- // visibility calculation.
+ // For more detailed visibility calculation, make a second pass through the view map, marking all
+ // feature edges with center points inside the final occluder proscenium. All of these feature
+ // edges can be considered during visibility calculation.
- // So far we have only found one FEdge per ViewEdge. The "Normal" and "Fast" styles of visibility computation
- // want to consider many FEdges for each ViewEdge.
- // Here we re-scan the view map to find any usable FEdges that we skipped on the first pass, or that have become
- // usable because the occluder proscenium has been expanded since the edge was visited on the first pass.
+ // So far we have only found one FEdge per ViewEdge. The "Normal" and "Fast" styles of
+ // visibility computation want to consider many FEdges for each ViewEdge. Here we re-scan the
+ // view map to find any usable FEdges that we skipped on the first pass, or that have become
+ // usable because the occluder proscenium has been expanded since the edge was visited on the
+ // first pass.
if (extensiveFEdgeSearch) {
// For each view edge,
for (ve = ioViewMap->ViewEdges().begin(), veend = ioViewMap->ViewEdges().end(); ve != veend;
@@ -1465,15 +1468,15 @@ void ViewMapBuilder::ComputeEdgesVisibility(ViewMap *ioViewMap,
ComputeDetailedVisibility(ioViewMap, we, bbox, epsilon, true, factory);
}
catch (...) {
- // Last resort catch to make sure RAII semantics hold for OptimizedGrid. Can be replaced with
- // try...catch block around main() if the program as a whole is converted to RAII
+ // Last resort catch to make sure RAII semantics hold for OptimizedGrid. Can be replaced
+ // with try...catch block around main() if the program as a whole is converted to RAII
- // This is the little-mentioned caveat of RAII: RAII does not work unless destructors are always
- // called, but destructors are only called if all exceptions are caught (or std::terminate() is
- // replaced).
+ // This is the little-mentioned caveat of RAII: RAII does not work unless destructors are
+ // always called, but destructors are only called if all exceptions are caught (or
+ // std::terminate() is replaced).
- // We don't actually handle the exception here, so re-throw it now that our destructors have had a
- // chance to run.
+ // We don't actually handle the exception here, so re-throw it now that our destructors
+ // have had a chance to run.
throw;
}
break;
@@ -1591,11 +1594,11 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
cout << "\tFEdge: visibility " << tmpQI << endl;
}
#endif
- //ARB: This is an error condition, not an alert condition.
+ // ARB: This is an error condition, not an alert condition.
// Some sort of recovery or abort is necessary.
if (tmpQI >= 256) {
cerr << "Warning: too many occluding levels" << endl;
- //ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
+ // ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
tmpQI = 255;
}
@@ -1605,7 +1608,7 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
}
}
else {
- //ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
+ // ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
FindOccludee(fe, _Grid, epsilon, &aFace, timestamp++);
#if LOGGING
if (_global.debug & G_DEBUG_FREESTYLE) {
@@ -1626,7 +1629,8 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
#endif
}
else {
- //ARB: We are arbitrarily using the last observed value for occludee (almost always the value observed
+ // ARB: We are arbitrarily using the last observed value for occludee (almost always the
+ // value observed
// for the edge before festart). Is that meaningful?
// ...in fact, _occludeeEmpty seems to be unused.
fe->setOccludeeEmpty(true);
@@ -1736,11 +1740,11 @@ void ViewMapBuilder::ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real ep
if ((maxCard < qiMajority)) {
tmpQI = ComputeRayCastingVisibility(fe, _Grid, epsilon, occluders, &aFace, timestamp++);
- //ARB: This is an error condition, not an alert condition.
+ // ARB: This is an error condition, not an alert condition.
// Some sort of recovery or abort is necessary.
if (tmpQI >= 256) {
cerr << "Warning: too many occluding levels" << endl;
- //ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
+ // ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
tmpQI = 255;
}
@@ -1750,7 +1754,7 @@ void ViewMapBuilder::ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real ep
}
}
else {
- //ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
+ // ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
FindOccludee(fe, _Grid, epsilon, &aFace, timestamp++);
}
@@ -1895,7 +1899,7 @@ void ViewMapBuilder::FindOccludee(FEdge *fe,
for (p = occluders.begin(), pend = occluders.end(); p != pend; p++) {
// check whether the edge and the polygon plane are coincident:
//-------------------------------------------------------------
- //first let us compute the plane equation.
+ // first let us compute the plane equation.
oface = (WFace *)(*p)->userdata;
Vec3r v1(((*p)->getVertices())[0]);
Vec3r normal((*p)->getNormal());
@@ -2022,7 +2026,7 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe,
(center.z() < gridOrigin.z()) || (center.x() > gridExtremity.x()) ||
(center.y() > gridExtremity.y()) || (center.z() > gridExtremity.z())) {
cerr << "Warning: point is out of the grid for fedge " << fe->getId() << endl;
- //return 0;
+ // return 0;
}
#if 0
@@ -2073,8 +2077,9 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe,
face->RetrieveVertexList(faceVertices);
for (p = occluders.begin(), pend = occluders.end(); p != pend; p++) {
- // If we're dealing with an exact silhouette, check whether we must take care of this occluder of not.
- // (Indeed, we don't consider the occluders that share at least one vertex with the face containing this edge).
+ // If we're dealing with an exact silhouette, check whether we must take care of this occluder
+ // of not. (Indeed, we don't consider the occluders that share at least one vertex with the
+ // face containing this edge).
//-----------
oface = (WFace *)(*p)->userdata;
#if LOGGING
@@ -2126,8 +2131,8 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe,
continue;
WFace *sface = (*ie)->GetbFace();
- //WFace *sfacea = (*ie)->GetaFace();
- //if ((sface == oface) || (sfacea == oface)) {
+ // WFace *sfacea = (*ie)->GetaFace();
+ // if ((sface == oface) || (sfacea == oface)) {
if (sface == oface) {
skipFace = true;
break;
@@ -2148,7 +2153,7 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe,
else {
// check whether the edge and the polygon plane are coincident:
//-------------------------------------------------------------
- //first let us compute the plane equation.
+ // first let us compute the plane equation.
if (GeomUtils::COINCIDENT ==
GeomUtils::intersectRayPlane(origin, edgeDir, normal, d, t, epsilon)) {
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.h b/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
index 0e3dbf9148e..eac5b348555 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
@@ -57,7 +57,7 @@ using namespace Geometry;
class ViewMapBuilder {
private:
ViewMap *_ViewMap; // result
- //SilhouetteGeomEngine _GeomEngine;
+ // SilhouetteGeomEngine _GeomEngine;
ProgressBar *_pProgressBar;
RenderMonitor *_pRenderMonitor;
Vec3r _viewpoint;
@@ -117,8 +117,8 @@ class ViewMapBuilder {
/*! Compute Cusps */
void computeCusps(ViewMap *ioViewMap);
- /*! Detects cusps (for a single ViewEdge) among SVertices and builds a ViewVertex on top of each cusp SVertex
- * We use a hysteresis approach to avoid noise.
+ /*! Detects cusps (for a single ViewEdge) among SVertices and builds a ViewVertex on top of each
+ * cusp SVertex We use a hysteresis approach to avoid noise.
*/
void DetectCusps(ViewEdge *ioEdge);
@@ -174,10 +174,9 @@ class ViewMapBuilder {
* ioViewMap
* The view map. It is modified by the method.
* The list of all features edges of the scene.
- * Each time an intersection is found, the 2 intersecting edges are splitted (creating 2 new vertices)
- * At the end, this list is updated with the adding of all new created edges (resulting from splitting).
- * iAlgo
- * The algo to use for computing the intersections
+ * Each time an intersection is found, the 2 intersecting edges are splitted (creating 2 new
+ * vertices) At the end, this list is updated with the adding of all new created edges (resulting
+ * from splitting). iAlgo The algo to use for computing the intersections
*/
void ComputeIntersections(ViewMap *ioViewMap,
intersection_algo iAlgo = sweep_line,
@@ -221,14 +220,11 @@ class ViewMapBuilder {
/*! Computes intersections on all edges of the scene using a sweep line algorithm */
void ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsilon = 1.0e-6);
- /*! Computes the 2D scene silhouette edges visibility using a ray casting. On each edge, a ray is cast
- * to check its quantitative invisibility. The list of occluders are each time stored in the tested edge.
- * ioViewMap
- * The view map.
- * The 2D scene silhouette edges as FEdges.
- * These edges have already been splitted at their intersections points.
- * Thus, these edges do not intersect anymore.
- * The visibility corresponding to each edge of ioScene is set is this edge.
+ /*! Computes the 2D scene silhouette edges visibility using a ray casting. On each edge, a ray is
+ * cast to check its quantitative invisibility. The list of occluders are each time stored in the
+ * tested edge. ioViewMap The view map. The 2D scene silhouette edges as FEdges. These edges have
+ * already been splitted at their intersections points. Thus, these edges do not intersect
+ * anymore. The visibility corresponding to each edge of ioScene is set is this edge.
*/
void ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilon = 1.0e-6);
void ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real epsilon = 1.0e-6);
@@ -257,10 +253,10 @@ class ViewMapBuilder {
* The epsilon used for computation
* oShapeId
* fe is the border (in 2D) between 2 2D spaces.
- * if fe is a silhouette, One of these 2D spaces is occupied by the shape to which fe belongs (on its left)
- * and the other one is either occupied by another shape or empty or occupied by the same shape.
- * We use this ray csating operation to determine which shape lies on fe's right.
- * The result is the shape id stored in oShapeId
+ * if fe is a silhouette, One of these 2D spaces is occupied by the shape to which fe
+ * belongs (on its left) and the other one is either occupied by another shape or empty or
+ * occupied by the same shape. We use this ray csating operation to determine which shape lies on
+ * fe's right. The result is the shape id stored in oShapeId
*/
int ComputeRayCastingVisibility(FEdge *fe,
Grid *iGrid,
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIO.cpp b/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
index 65336f593c7..24ed798709a 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
@@ -801,8 +801,8 @@ static int save(ostream &out, SVertex *sv)
WRITE_IF_NON_NULL(sv->viewvertex());
// Normals (List)
- // Note: the 'size()' method of a set doesn't seem to return the actual size of the given set, so we have to
- // hack it...
+ // Note: the 'size()' method of a set doesn't seem to return the actual size of the given set, so
+ // we have to hack it...
set<Vec3r>::const_iterator i;
for (i = sv->normals().begin(), tmp = 0; i != sv->normals().end(); i++, tmp++)
;
@@ -955,7 +955,7 @@ int load(istream &in, ViewMap *vm, ProgressBar *pb)
if (!vm)
return 1;
- //soc unused - unsigned tmp;
+ // soc unused - unsigned tmp;
int err = 0;
Internal::g_vm = vm;
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIterators.h b/source/blender/freestyle/intern/view_map/ViewMapIterators.h
index 7182c5d3362..0fb5438a153 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapIterators.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapIterators.h
@@ -46,10 +46,9 @@ namespace Freestyle {
namespace ViewVertexInternal {
-/*! Class representing an iterator over oriented ViewEdges around a ViewVertex. This iterator allows a CCW iteration
- * (in the image plane).
- * An instance of an orientedViewEdgeIterator can only be obtained from a ViewVertex by calling edgesBegin()
- * or edgesEnd().
+/*! Class representing an iterator over oriented ViewEdges around a ViewVertex. This iterator
+ * allows a CCW iteration (in the image plane). An instance of an orientedViewEdgeIterator can only
+ * be obtained from a ViewVertex by calling edgesBegin() or edgesEnd().
*/
class orientedViewEdgeIterator : public Iterator {
public:
@@ -127,7 +126,8 @@ class orientedViewEdgeIterator : public Iterator {
}
public:
- /*! Tells whether the ViewEdge pointed by this iterator is the first one of the iteration list or not. */
+ /*! Tells whether the ViewEdge pointed by this iterator is the first one of the iteration list or
+ * not. */
virtual bool isBegin() const
{
if (_Nature & Nature::T_VERTEX)
@@ -136,7 +136,8 @@ class orientedViewEdgeIterator : public Iterator {
return (_nontvertex_iter == _begin);
}
- /*! Tells whether the ViewEdge pointed by this iterator is after the last one of the iteration list or not. */
+ /*! Tells whether the ViewEdge pointed by this iterator is after the last one of the iteration
+ * list or not. */
virtual bool isEnd() const
{
if (_Nature & Nature::T_VERTEX)
@@ -186,7 +187,7 @@ class orientedViewEdgeIterator : public Iterator {
virtual ViewVertex::directedViewEdge &operator*() const
{
if (_Nature & Nature::T_VERTEX)
- //return _tvertex_iter;
+ // return _tvertex_iter;
return **_tvertex_iter;
else
return (*_nontvertex_iter);
@@ -406,8 +407,8 @@ class SVertexIterator : public Interface0DIteratorNested {
///////////////////////////////////////////////////////////
/*! Base class for iterators over ViewEdges of the ViewMap Graph.
- * Basically the "increment()" operator of this class should be able to take the decision of "where" (on which
- * ViewEdge) to go when pointing on a given ViewEdge.
+ * Basically the "increment()" operator of this class should be able to take the decision of
+ * "where" (on which ViewEdge) to go when pointing on a given ViewEdge.
* ::Caution::: the dereferencing operator returns a *pointer* to the pointed ViewEdge.
*/
class ViewEdgeIterator : public Iterator {
@@ -416,8 +417,9 @@ class ViewEdgeIterator : public Iterator {
* \param begin:
* The ViewEdge from where to start the iteration.
* \param orientation:
- * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending ViewVertex of begin.
- * If false, we'll search over the ViewEdges surrounding the ending ViewVertex of begin.
+ * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending
+ * ViewVertex of begin. If false, we'll search over the ViewEdges surrounding the ending
+ * ViewVertex of begin.
*/
ViewEdgeIterator(ViewEdge *begin = NULL, bool orientation = true)
{
diff --git a/source/blender/freestyle/intern/view_map/ViewMapTesselator.h b/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
index 2173ea42fab..f8ae885f5d7 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
@@ -57,11 +57,12 @@ class ViewMapTesselator {
{
}
- /*! Builds a set of lines rep contained under a a NodeShape, itself contained under a NodeGroup from a ViewMap */
+ /*! Builds a set of lines rep contained under a a NodeShape, itself contained under a NodeGroup
+ * from a ViewMap */
NodeGroup *Tesselate(ViewMap *iViewMap);
- /*! Builds a set of lines rep contained under a a NodeShape, itself contained under a NodeGroup from a set of
- * view edges
+ /*! Builds a set of lines rep contained under a a NodeShape, itself contained under a NodeGroup
+ * from a set of view edges
*/
template<class ViewEdgesIterator>
NodeGroup *Tesselate(ViewEdgesIterator begin, ViewEdgesIterator end);
@@ -156,7 +157,7 @@ NodeGroup *ViewMapTesselator::Tesselate(ViewEdgesIterator begin, ViewEdgesIterat
NodeGroup *group = new NodeGroup;
NodeShape *tshape = new NodeShape;
group->AddChild(tshape);
- //tshape->frs_material().setDiffuse(0.0f, 0.0f, 0.0f, 1.0f);
+ // tshape->frs_material().setDiffuse(0.0f, 0.0f, 0.0f, 1.0f);
tshape->setFrsMaterial(_FrsMaterial);
LineRep *line;
@@ -165,7 +166,8 @@ NodeGroup *ViewMapTesselator::Tesselate(ViewEdgesIterator begin, ViewEdgesIterat
FEdge *nextFEdge, *currentEdge;
int id = 0;
- //for (vector<ViewEdge*>::const_iterator c = viewedges.begin(), cend = viewedges.end(); c != cend; c++)
+ // for (vector<ViewEdge*>::const_iterator c = viewedges.begin(), cend = viewedges.end(); c !=
+ // cend; c++)
for (ViewEdgesIterator c = begin, cend = end; c != cend; c++) {
#if 0
if ((*c)->qi() > 0) {
@@ -189,25 +191,25 @@ NodeGroup *ViewMapTesselator::Tesselate(ViewEdgesIterator begin, ViewEdgesIterat
// there might be chains containing a single element
if (0 == (firstEdge)->nextEdge()) {
line->setStyle(LineRep::LINES);
- //line->AddVertex((*c)->vertexA()->point3D());
- //line->AddVertex((*c)->vertexB()->point3D());
+ // line->AddVertex((*c)->vertexA()->point3D());
+ // line->AddVertex((*c)->vertexB()->point3D());
AddVertexToLine(line, firstEdge->vertexA());
AddVertexToLine(line, firstEdge->vertexB());
}
else {
line->setStyle(LineRep::LINE_STRIP);
- //firstEdge = (*c);
+ // firstEdge = (*c);
nextFEdge = firstEdge;
currentEdge = firstEdge;
do {
- //line->AddVertex(nextFEdge->vertexA()->point3D());
+ // line->AddVertex(nextFEdge->vertexA()->point3D());
AddVertexToLine(line, nextFEdge->vertexA());
currentEdge = nextFEdge;
nextFEdge = nextFEdge->nextEdge();
} while ((nextFEdge != NULL) && (nextFEdge != firstEdge));
// Add the last vertex
- //line->AddVertex(currentEdge->vertexB()->point3D());
+ // line->AddVertex(currentEdge->vertexB()->point3D());
AddVertexToLine(line, currentEdge->vertexB());
}
diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.cpp b/source/blender/freestyle/intern/winged_edge/Curvature.cpp
index ada1b20780a..4fb92e35b40 100644
--- a/source/blender/freestyle/intern/winged_edge/Curvature.cpp
+++ b/source/blender/freestyle/intern/winged_edge/Curvature.cpp
@@ -78,7 +78,8 @@ static real cotan(WVertex *vo, WVertex *v1, WVertex *v2)
udotv = u * v;
denom = sqrt(u.squareNorm() * v.squareNorm() - udotv * udotv);
- /* denom can be zero if u==v. Returning 0 is acceptable, based on the callers of this function below. */
+ /* denom can be zero if u==v. Returning 0 is acceptable, based on the callers of this function
+ * below. */
if (denom == 0.0)
return 0.0;
return (udotv / denom);
@@ -109,9 +110,9 @@ static real angle_from_cotan(WVertex *vo, WVertex *v1, WVertex *v2)
* Computes the Discrete Mean Curvature Normal approximation at @v.
* The mean curvature at @v is half the magnitude of the vector @Kh.
*
- * Note: the normal computed is not unit length, and may point either into or out of the surface, depending on
- * the curvature at @v. It is the responsibility of the caller of the function to use the mean curvature normal
- * appropriately.
+ * Note: the normal computed is not unit length, and may point either into or out of the surface,
+ * depending on the curvature at @v. It is the responsibility of the caller of the function to use
+ * the mean curvature normal appropriately.
*
* This approximation is from the paper:
* Discrete Differential-Geometry Operators for Triangulated 2-Manifolds
@@ -119,8 +120,8 @@ static real angle_from_cotan(WVertex *vo, WVertex *v1, WVertex *v2)
* VisMath '02, Berlin (Germany)
* http://www-grail.usc.edu/pubs.html
*
- * Returns: %true if the operator could be evaluated, %false if the evaluation failed for some reason (@v is
- * boundary or is the endpoint of a non-manifold edge.)
+ * Returns: %true if the operator could be evaluated, %false if the evaluation failed for some
+ * reason (@v is boundary or is the endpoint of a non-manifold edge.)
*/
bool gts_vertex_mean_curvature_normal(WVertex *v, Vec3r &Kh)
{
@@ -181,8 +182,8 @@ bool gts_vertex_mean_curvature_normal(WVertex *v, Vec3r &Kh)
* VisMath '02, Berlin (Germany)
* http://www-grail.usc.edu/pubs.html
*
- * Returns: %true if the operator could be evaluated, %false if the evaluation failed for some reason (@v is
- * boundary or is the endpoint of a non-manifold edge.)
+ * Returns: %true if the operator could be evaluated, %false if the evaluation failed for some
+ * reason (@v is boundary or is the endpoint of a non-manifold edge.)
*/
bool gts_vertex_gaussian_curvature(WVertex *v, real *Kg)
{
@@ -223,7 +224,8 @@ bool gts_vertex_gaussian_curvature(WVertex *v, real *Kg)
* @K1: first principal curvature.
* @K2: second principal curvature.
*
- * Computes the principal curvatures at a point given the mean and Gaussian curvatures at that point.
+ * Computes the principal curvatures at a point given the mean and Gaussian curvatures at that
+ * point.
*
* The mean curvature can be computed as one-half the magnitude of the vector computed by
* gts_vertex_mean_curvature_normal().
@@ -275,12 +277,12 @@ static void eigenvector(real a, real b, real c, Vec3r e)
* @e1: first principal curvature direction (direction of largest curvature).
* @e2: second principal curvature direction.
*
- * Computes the principal curvature directions at a point given @Kh and @Kg, the mean curvature normal and
- * Gaussian curvatures at that point, computed with gts_vertex_mean_curvature_normal() and
- * gts_vertex_gaussian_curvature(), respectively.
+ * Computes the principal curvature directions at a point given @Kh and @Kg, the mean curvature
+ * normal and Gaussian curvatures at that point, computed with gts_vertex_mean_curvature_normal()
+ * and gts_vertex_gaussian_curvature(), respectively.
*
- * Note that this computation is very approximate and tends to be unstable. Smoothing of the surface or the principal
- * directions may be necessary to achieve reasonable results.
+ * Note that this computation is very approximate and tends to be unstable. Smoothing of the
+ * surface or the principal directions may be necessary to achieve reasonable results.
*/
void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, Vec3r &e2)
{
@@ -306,8 +308,8 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
Kh.normalize();
}
else {
- /* This vertex is a point of zero mean curvature (flat or saddle point). Compute a normal by averaging
- * the adjacent triangles
+ /* This vertex is a point of zero mean curvature (flat or saddle point). Compute a normal by
+ * averaging the adjacent triangles
*/
N[0] = N[1] = N[2] = 0.0;
@@ -354,8 +356,9 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
continue;
e = *itE;
- /* since this vertex passed the tests in gts_vertex_mean_curvature_normal(), this should be true. */
- //g_assert(gts_edge_face_number (e, s) == 2);
+ /* since this vertex passed the tests in gts_vertex_mean_curvature_normal(), this should be
+ * true. */
+ // g_assert(gts_edge_face_number (e, s) == 2);
/* identify the two triangles bordering e in s */
f1 = e->GetaFace();
@@ -365,17 +368,18 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
* B = [ a b ; b c ].
* The computations here are from section 5 of [Meyer et al 2002].
*
- * The first step is to calculate the linear equations governing the values of (a,b,c). These can be computed
- * by setting the derivatives of the error E to zero (section 5.3).
+ * The first step is to calculate the linear equations governing the values of (a,b,c). These
+ * can be computed by setting the derivatives of the error E to zero (section 5.3).
*
- * Since a + c = norm(Kh), we only compute the linear equations for dE/da and dE/db. (NB: [Meyer et al 2002]
- * has the equation a + b = norm(Kh), but I'm almost positive this is incorrect).
+ * Since a + c = norm(Kh), we only compute the linear equations for dE/da and dE/db. (NB:
+ * [Meyer et al 2002] has the equation a + b = norm(Kh), but I'm almost positive this is
+ * incorrect).
*
- * Note that the w_ij (defined in section 5.2) are all scaled by (1/8*A_mixed). We drop this uniform scale
- * factor because the solution of the linear equations doesn't rely on it.
+ * Note that the w_ij (defined in section 5.2) are all scaled by (1/8*A_mixed). We drop this
+ * uniform scale factor because the solution of the linear equations doesn't rely on it.
*
- * The terms of the linear equations are xterm_dy with x in {a,b,c} and y in {a,b}. There are also const_dy
- * terms that are the constant factors in the equations.
+ * The terms of the linear equations are xterm_dy with x in {a,b,c} and y in {a,b}. There are
+ * also const_dy terms that are the constant factors in the equations.
*/
/* find the vector from v along edge e */
@@ -389,8 +393,9 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
/* section 5.2 */
- /* I don't like performing a minimization where some of the weights can be negative (as can be the case
- * if f1 or f2 are obtuse). To ensure all-positive weights, we check for obtuseness. */
+ /* I don't like performing a minimization where some of the weights can be negative (as can be
+ * the case if f1 or f2 are obtuse). To ensure all-positive weights, we check for obtuseness.
+ */
weight = 0.0;
if (!triangle_obtuse(v, f1)) {
weight += ve2 *
@@ -471,12 +476,14 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
eig[1] = 0.0;
}
- /* Although the eigenvectors of B are good estimates of the principal directions, it seems that which one is
- * attached to which curvature direction is a bit arbitrary. This may be a bug in my implementation, or just
- * a side-effect of the inaccuracy of B due to the discrete nature of the sampling.
+ /* Although the eigenvectors of B are good estimates of the principal directions, it seems that
+ * which one is attached to which curvature direction is a bit arbitrary. This may be a bug in my
+ * implementation, or just a side-effect of the inaccuracy of B due to the discrete nature of the
+ * sampling.
*
- * To overcome this behavior, we'll evaluate which assignment best matches the given eigenvectors by comparing
- * the curvature estimates computed above and the curvatures calculated from the discrete differential operators.
+ * To overcome this behavior, we'll evaluate which assignment best matches the given eigenvectors
+ * by comparing the curvature estimates computed above and the curvatures calculated from the
+ * discrete differential operators.
*/
gts_vertex_principal_curvatures(0.5 * normKh, Kg, &K1, &K2);
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.cpp b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
index c884c6f5df6..3dc574515c1 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
@@ -293,7 +293,7 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
// Adds the edge to the face
AddEdge(woea);
(*it1)->setNumberOfOEdges((*it1)->GetNumberOfOEdges() + 1);
- //sets these vertices as border:
+ // sets these vertices as border:
v1->setBorder(true);
v2->setBorder(true);
return woea;
@@ -307,7 +307,7 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
// Adds the edge to the face
AddEdge(woeb);
(*it1)->setNumberOfOEdges((*it1)->GetNumberOfOEdges() + 1);
- //sets these vertices as border:
+ // sets these vertices as border:
v1->setBorder(true);
v2->setBorder(true);
return woeb;
@@ -334,7 +334,7 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
}
}
- //DEBUG:
+ // DEBUG:
if (true == exist) { // The invert edge already exists
// Retrieves the corresponding edge
edge = pInvertEdge->GetOwner();
@@ -347,7 +347,7 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
}
else { // The invert edge does not exist yet
// we must create a new edge
- //edge = new WEdge;
+ // edge = new WEdge;
edge = instanciateEdge();
// updates the a,b vertex edges list:
@@ -365,7 +365,7 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
cerr << "Warning: edge " << this << " null with vertex " << v1->GetId() << endl;
edge->AddOEdge(pOEdge);
- //edge->setNumberOfOEdges(edge->GetNumberOfOEdges() + 1);
+ // edge->setNumberOfOEdges(edge->GetNumberOfOEdges() + 1);
// Add this face (the b face)
pOEdge->setbFace(this);
@@ -468,7 +468,7 @@ WShape::WShape(WShape &iBrother)
vector<WVertex *> &vertexList = iBrother.getVertexList();
vector<WVertex *>::iterator v = vertexList.begin(), vend = vertexList.end();
for (; v != vend; ++v) {
- //WVertex *newVertex = new WVertex(*(*v));
+ // WVertex *newVertex = new WVertex(*(*v));
WVertex *newVertex = (*v)->duplicate();
newVertex->setShape(this);
@@ -478,7 +478,7 @@ WShape::WShape(WShape &iBrother)
vector<WEdge *> &edgeList = iBrother.getEdgeList();
vector<WEdge *>::iterator e = edgeList.begin(), eend = edgeList.end();
for (; e != eend; ++e) {
- //WEdge *newEdge = new WEdge(*(*e));
+ // WEdge *newEdge = new WEdge(*(*e));
WEdge *newEdge = (*e)->duplicate();
AddEdge(newEdge);
}
@@ -486,7 +486,7 @@ WShape::WShape(WShape &iBrother)
vector<WFace *> &faceList = iBrother.GetFaceList();
vector<WFace *>::iterator f = faceList.begin(), fend = faceList.end();
for (; f != fend; ++f) {
- //WFace *newFace = new WFace(*(*f));
+ // WFace *newFace = new WFace(*(*f));
WFace *newFace = (*f)->duplicate();
AddFace(newFace);
}
@@ -539,8 +539,8 @@ WShape::WShape(WShape &iBrother)
WOEdge *current = oedgeList[i];
oedgedata *currentoedata = (oedgedata *)current->userdata;
newoedgelist.push_back(currentoedata->_copy);
- //oedgeList[i] = currentoedata->_copy;
- //oedgeList[i] = ((oedgedata *)(oedgeList[i]->userdata))->_copy;
+ // oedgeList[i] = currentoedata->_copy;
+ // oedgeList[i] = ((oedgedata *)(oedgeList[i]->userdata))->_copy;
}
(*f)->setEdgeList(newoedgelist);
}
@@ -662,11 +662,11 @@ WFace *WShape::MakeFace(vector<WVertex *> &iVertexList,
for (; va != iVertexList.end(); va = vb) {
++vb;
// Adds va to the vertex list:
- //face->AddVertex(*va);
+ // face->AddVertex(*va);
WOEdge *oedge;
if (*va == iVertexList.back())
- oedge = face->MakeEdge(*va, iVertexList.front()); //for the last (closing) edge
+ oedge = face->MakeEdge(*va, iVertexList.front()); // for the last (closing) edge
else
oedge = face->MakeEdge(*va, *vb);
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.h b/source/blender/freestyle/intern/winged_edge/WEdge.h
index f645c3d7520..1a141629c6d 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.h
@@ -178,7 +178,7 @@ class WVertex {
{
}
#endif
- virtual ~incoming_edge_iterator(){}; //soc
+ virtual ~incoming_edge_iterator(){}; // soc
protected:
friend class WVertex;
@@ -237,7 +237,7 @@ class WVertex {
// dereferencing
virtual WOEdge *operator*();
- //virtual WOEdge **operator->();
+ // virtual WOEdge **operator->();
protected:
virtual void increment();
@@ -266,7 +266,7 @@ class WVertex {
{
}
#endif
- virtual ~face_iterator(){}; //soc
+ virtual ~face_iterator(){}; // soc
protected:
friend class WVertex;
@@ -321,7 +321,7 @@ class WVertex {
// dereferencing
virtual WFace *operator*();
- //virtual WOEdge **operator->();
+ // virtual WOEdge **operator->();
protected:
inline void increment()
@@ -401,7 +401,7 @@ class WOEdge {
userdata = NULL;
}
- virtual ~WOEdge(){}; //soc
+ virtual ~WOEdge(){}; // soc
/*! copy constructor */
WOEdge(WOEdge &iBrother);
@@ -1196,10 +1196,9 @@ class WShape {
/*! adds a new face to the shape
* returns the built face.
* iVertexList
- * List of face's vertices. These vertices are not added to the WShape vertex list; they are supposed to be
- * already stored when calling MakeFace.
- * The order in which the vertices are stored in the list determines the face's edges orientation and (so) the
- * face orientation.
+ * List of face's vertices. These vertices are not added to the WShape vertex list; they are
+ * supposed to be already stored when calling MakeFace. The order in which the vertices are
+ * stored in the list determines the face's edges orientation and (so) the face orientation.
* iMaterialIndex
* The material index for this face
*/
@@ -1207,21 +1206,16 @@ class WShape {
vector<bool> &iFaceEdgeMarksList,
unsigned iMaterialIndex);
- /*! adds a new face to the shape. The difference with the previous method is that this one is designed
- * to build a WingedEdge structure for which there are per vertex normals, opposed to per face normals.
- * returns the built face.
- * iVertexList
- * List of face's vertices. These vertices are not added to the WShape vertex list; they are supposed to be
- * already stored when calling MakeFace.
- * The order in which the vertices are stored in the list determines the face's edges orientation and (so) the
- * face orientation.
- * iMaterialIndex
- * The materialIndex for this face
+ /*! adds a new face to the shape. The difference with the previous method is that this one is
+ * designed to build a WingedEdge structure for which there are per vertex normals, opposed to
+ * per face normals. returns the built face. iVertexList List of face's vertices. These vertices
+ * are not added to the WShape vertex list; they are supposed to be already stored when calling
+ * MakeFace. The order in which the vertices are stored in the list determines the face's edges
+ * orientation and (so) the face orientation. iMaterialIndex The materialIndex for this face
* iNormalsList
- * The list of normals, iNormalsList[i] corresponding to the normal of the vertex iVertexList[i] for that face.
- * iTexCoordsList
- * The list of tex coords, iTexCoordsList[i] corresponding to the normal of the vertex iVertexList[i] for
- * that face.
+ * The list of normals, iNormalsList[i] corresponding to the normal of the vertex
+ * iVertexList[i] for that face. iTexCoordsList The list of tex coords, iTexCoordsList[i]
+ * corresponding to the normal of the vertex iVertexList[i] for that face.
*/
virtual WFace *MakeFace(vector<WVertex *> &iVertexList,
vector<Vec3f> &iNormalsList,
@@ -1300,16 +1294,17 @@ class WShape {
#endif
protected:
- /*! Builds the face passed as argument (which as already been allocated)
- * iVertexList
- * List of face's vertices. These vertices are not added to the WShape vertex list; they are supposed to be
- * already stored when calling MakeFace.
- * The order in which the vertices are stored in the list determines the face's edges orientation and (so) the
- * face orientation.
- * iMaterialIndex
- * The material index for this face
- * face
- * The Face that is filled in
+ /*!
+ * Builds the face passed as argument (which as already been allocated)
+ * - iVertexList
+ * List of face's vertices. These vertices are not added to the WShape vertex list;
+ * they are supposed to be already stored when calling MakeFace.
+ * The order in which the vertices are stored in the list determines
+ * the face's edges orientation and (so) the face orientation.
+ * - iMaterialIndex
+ * The material index for this face
+ * - face
+ * The Face that is filled in
*/
virtual WFace *MakeFace(vector<WVertex *> &iVertexList,
vector<bool> &iFaceEdgeMarksList,
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
index 26c75accc12..2e36790563e 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
@@ -91,8 +91,9 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
return 0;
// let us determine which cusp edge corresponds to the starting:
- // We can do that because we defined that a silhouette edge had the back facing part on its right.
- // So if the WOEdge woea is such that woea[0].dotp > 0 and woea[1].dotp < 0, it is the starting edge.
+ // We can do that because we defined that a silhouette edge had the back facing part on its
+ // right. So if the WOEdge woea is such that woea[0].dotp > 0 and woea[1].dotp < 0, it is the
+ // starting edge.
//-------------------------------------------
if (_DotP[cuspEdgesIndices[0]] > 0.0f) {
@@ -114,7 +115,8 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
ok = true;
}
else if (_nNullDotP == 1) {
- // that means that we have exactly one of the 2 extremities of our silhouette edge is a vertex of the mesh
+ // that means that we have exactly one of the 2 extremities of our silhouette edge is a vertex
+ // of the mesh
if ((_nPosDotP == 2) || (_nPosDotP == 0)) {
_pSmoothEdge = NULL;
return _pSmoothEdge;
@@ -193,7 +195,8 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
if ((front()) ^
(bface->front())) { // fA->front XOR fB->front (true if one is 0 and the other is 1)
// that means that the edge i of the face is a silhouette edge
- // CHECK FIRST WHETHER THE EXACTSILHOUETTEEDGE HAS NOT YET BEEN BUILT ON THE OTHER FACE (1 is enough).
+ // CHECK FIRST WHETHER THE EXACTSILHOUETTEEDGE HAS
+ // NOT YET BEEN BUILT ON THE OTHER FACE (1 is enough).
if (((WSExactFace *)bface)->exactSilhouetteEdge()) {
// that means that this silhouette edge has already been built
return ((WSExactFace *)bface)->exactSilhouetteEdge();
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.h b/source/blender/freestyle/intern/winged_edge/WXEdge.h
index 01ce9bf2ea5..0f1b8d77c59 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.h
@@ -108,8 +108,8 @@ class WXEdge : public WEdge {
WXNature _nature;
// 0: the order doesn't matter. 1: the order is the orginal one. -1: the order is not good
short _order;
- // A front facing edge is an edge for which the bording face which is the nearest from the viewpoint is front.
- // A back facing edge is the opposite.
+ // A front facing edge is an edge for which the bording face which is the nearest from the
+ // viewpoint is front. A back facing edge is the opposite.
bool _front;
public:
@@ -322,13 +322,13 @@ class WXFaceLayer {
public:
void *userdata;
WXFace *_pWXFace;
- // in case of silhouette: the values obtained when computing the normal-view direction dot product. _DotP[i] is
- // this value for the vertex i for that face.
+ // in case of silhouette: the values obtained when computing the normal-view direction dot
+ // product. _DotP[i] is this value for the vertex i for that face.
vector<float> _DotP;
WXSmoothEdge *_pSmoothEdge;
WXNature _Nature;
- //oldtmp values
+ // oldtmp values
// count the number of positive dot products for vertices.
// if this number is != 0 and !=_DotP.size() -> it is a silhouette fac
unsigned _nPosDotP;
@@ -435,14 +435,16 @@ class WXFaceLayer {
}
}
- /*! If one of the face layer vertex has a DotP equal to 0, this method returns the vertex where it happens */
+ /*! If one of the face layer vertex has a DotP equal to 0, this method returns the vertex where
+ * it happens */
unsigned int Get0VertexIndex() const;
- /*! In case one of the edge of the triangle is a smooth edge, this method allows to retrieve the concerned edge */
+ /*! In case one of the edge of the triangle is a smooth edge, this method allows to retrieve the
+ * concerned edge */
unsigned int GetSmoothEdgeIndex() const;
- /*! retrieves the edges of the triangle for which the signs are different (a null value is not considered) for
- * the dotp values at each edge extrimity
+ /*! retrieves the edges of the triangle for which the signs are different (a null value is not
+ * considered) for the dotp values at each edge extrimity
*/
void RetrieveCuspEdgesIndices(vector<int> &oCuspEdges);
@@ -492,8 +494,8 @@ class WXFace : public WFace {
bool _front; // flag to tell whether the face is front facing or back facing
float _dotp; // value obtained when computing the normal-viewpoint dot product
- vector<WXFaceLayer *>
- _SmoothLayers; // The data needed to store one or several smooth edges that traverse the face
+ vector<WXFaceLayer *> _SmoothLayers; // The data needed to store one or several smooth edges
+ // that traverse the face
public:
inline WXFace() : WFace()
@@ -701,8 +703,8 @@ class WXShape : public WShape {
#endif
protected:
- bool
- _computeViewIndependent; // flag to indicate whether the view independent stuff must be computed or not
+ bool _computeViewIndependent; // flag to indicate whether the view independent stuff must be
+ // computed or not
public:
inline WXShape() : WShape()
@@ -742,29 +744,35 @@ class WXShape : public WShape {
return new WXFace;
}
- /*! adds a new face to the shape returns the built face.
- * iVertexList
- * List of face's vertices. These vertices are not added to the WShape vertex list; they are supposed
- * to be already stored when calling MakeFace. The order in which the vertices are stored in the list
- * determines the face's edges orientation and (so) the face orientation.
+ /*!
+ * Adds a new face to the shape returns the built face.
+ * - iVertexList
+ * List of face's vertices.
+ * These vertices are not added to the WShape vertex list; they are
+ * supposed to be already stored when calling MakeFace. The order in which the vertices are
+ * stored in the list determines the face's edges orientation and (so) the face orientation.
*/
virtual WFace *MakeFace(vector<WVertex *> &iVertexList,
vector<bool> &iFaceEdgeMarksList,
unsigned iMaterialIndex);
- /*! adds a new face to the shape. The difference with the previous method is that this one is designed to build
- * a WingedEdge structure for which there are per vertex normals, opposed to per face normals.
- * returns the built face.
- * iVertexList
- * List of face's vertices. These vertices are not added to the WShape vertex list; they are supposed to be
- * already stored when calling MakeFace.
- * The order in which the vertices are stored in the list determines the face's edges orientation and (so) the
- * face orientation.
- * iNormalsList
- * The list of normals, iNormalsList[i] corresponding to the normal of the vertex iVertexList[i] for that face.
- * iTexCoordsList
- * The list of tex coords, iTexCoordsList[i] corresponding to the normal of the vertex iVertexList[i] for
- * that face.
+ /*!
+ * Adds a new face to the shape.
+ * The difference with the previous method is that this one is designed to build a WingedEdge
+ * structure for which there are per vertex normals, opposed to per face normals.
+ * returns the built face.
+ *
+ * - iVertexList:
+ * List of face's vertices. These vertices are not added to the WShape vertex list;
+ * they are supposed to be already stored when calling MakeFace.
+ * The order in which the vertices are stored in the list determines
+ * the face's edges orientation and (so) the face orientation.
+ * - iNormalsList:
+ * The list of normals, iNormalsList[i]
+ * corresponding to the normal of the vertex iVertexList[i] for that face.
+ * - iTexCoordsList:
+ * The list of tex coords, iTexCoordsList[i]
+ * corresponding to the normal of the vertex iVertexList[i] for that face.
*/
virtual WFace *MakeFace(vector<WVertex *> &iVertexList,
vector<Vec3f> &iNormalsList,
@@ -781,7 +789,7 @@ class WXShape : public WShape {
((WXEdge *)(*we))->Reset();
}
- //Reset faces:
+ // Reset faces:
vector<WFace *> &wfaces = GetFaceList();
for (vector<WFace *>::iterator wf = wfaces.begin(), wfend = wfaces.end(); wf != wfend; ++wf) {
((WXFace *)(*wf))->Reset();
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp
index fb0b6a9b63f..a34f2272200 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp
@@ -16,8 +16,8 @@
/** \file
* \ingroup freestyle
- * \brief Class inherited from WingedEdgeBuilder and designed to build a WX (WingedEdge + extended info
- * (silhouette etc...)) structure from a polygonal model
+ * \brief Class inherited from WingedEdgeBuilder and designed to build a WX (WingedEdge + extended
+ * info (silhouette etc...)) structure from a polygonal model
*/
#include "WXEdge.h"
@@ -37,7 +37,7 @@ void WXEdgeBuilder::visitIndexedFaceSet(IndexedFaceSet &ifs)
shape->setId(ifs.getId().getFirst());
shape->setName(ifs.getName());
shape->setLibraryPath(ifs.getLibraryPath());
- //ifs.setId(shape->GetId());
+ // ifs.setId(shape->GetId());
}
void WXEdgeBuilder::buildWVertices(WShape &shape, const float *vertices, unsigned vsize)
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
index e98832f4fba..08189c5010e 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
+++ b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
@@ -19,8 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Class inherited from WingedEdgeBuilder and designed to build a WX (WingedEdge + extended info
- * (silhouette etc...)) structure from a polygonal model
+ * \brief Class inherited from WingedEdgeBuilder and designed to build a WX (WingedEdge + extended
+ * info (silhouette etc...)) structure from a polygonal model
*/
#include "WingedEdgeBuilder.h"
diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
index 977eb2b4d57..f190d78014d 100644
--- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
@@ -16,8 +16,8 @@
/** \file
* \ingroup freestyle
- * \brief Class to render a WingedEdge data structure from a polyhedral data structure organized in nodes
- * of a scene graph
+ * \brief Class to render a WingedEdge data structure from a polyhedral data structure organized in
+ * nodes of a scene graph
*/
#include <set>
@@ -42,12 +42,12 @@ void WingedEdgeBuilder::visitIndexedFaceSet(IndexedFaceSet &ifs)
return;
}
shape->setId(ifs.getId().getFirst());
- //ifs.setId(shape->GetId());
+ // ifs.setId(shape->GetId());
}
void WingedEdgeBuilder::visitNodeShape(NodeShape &ns)
{
- //Sets the current material to iShapeode->material:
+ // Sets the current material to iShapeode->material:
_current_frs_material = &(ns.frs_material());
}
@@ -81,7 +81,7 @@ bool WingedEdgeBuilder::buildWShape(WShape &shape, IndexedFaceSet &ifs)
{
unsigned int vsize = ifs.vsize();
unsigned int nsize = ifs.nsize();
- //soc unused - unsigned tsize = ifs.tsize();
+ // soc unused - unsigned tsize = ifs.tsize();
const float *vertices = ifs.vertices();
const float *normals = ifs.normals();
@@ -256,7 +256,7 @@ void WingedEdgeBuilder::buildTriangleStrip(const float * /*vertices*/,
{
unsigned nDoneVertices = 2; // number of vertices already treated
unsigned nTriangle = 0; // number of the triangle currently being treated
- //int nVertex = 0; // vertex number
+ // int nVertex = 0; // vertex number
WShape *currentShape = _current_wshape; // the current shape being built
vector<WVertex *> triangleVertices;
@@ -265,9 +265,9 @@ void WingedEdgeBuilder::buildTriangleStrip(const float * /*vertices*/,
vector<bool> triangleFaceEdgeMarks;
while (nDoneVertices < nvertices) {
- //clear the vertices list:
+ // clear the vertices list:
triangleVertices.clear();
- //Then rebuild it:
+ // Then rebuild it:
if (0 == nTriangle % 2) { // if nTriangle is even
triangleVertices.push_back(currentShape->getVertexList()[vindices[nTriangle] / 3]);
triangleVertices.push_back(currentShape->getVertexList()[vindices[nTriangle + 1] / 3]);
diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
index 606e8561401..a4aa08d50b6 100644
--- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
+++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
@@ -19,8 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Class to render a WingedEdge data structure from a polyhedral data structure organized in nodes
- * of a scene graph
+ * \brief Class to render a WingedEdge data structure
+ * from a polyhedral data structure organized in nodes of a scene graph.
*/
#include "WEdge.h"
diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt
index 6c7f2bb3685..41543448a15 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -22,17 +22,17 @@
set(INC
.
intern
+ ../blenfont
../blenkernel
../blenlib
- ../blenfont
+ ../bmesh
../depsgraph
../makesdna
../makesrna
- ../bmesh
../render/extern/include
../../../intern/elbeem/extern
- ../../../intern/guardedalloc
../../../intern/eigen
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
index 5f7f8165ed2..d72ace7a191 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
@@ -74,7 +74,8 @@ static bool dependsOnTime(GpencilModifierData *UNUSED(md))
/* Build Modifier - Stroke generation logic
*
* There are two modes for how the strokes are sequenced (at a macro-level):
- * - Sequential Mode - Strokes appear/disappear one after the other. Only a single one changes at a time.
+ * - Sequential Mode - Strokes appear/disappear one after the other. Only a single one changes at a
+ * time.
* - Concurrent Mode - Multiple strokes appear/disappear at once.
*
* Assumptions:
@@ -121,8 +122,10 @@ static void reduce_stroke_points(bGPDstroke *gps,
/* Which end should points be removed from */
// TODO: free stroke weights
switch (transition) {
- case GP_BUILD_TRANSITION_GROW: /* Show in forward order = Remove ungrown-points from end of stroke */
- case GP_BUILD_TRANSITION_SHRINK: /* Hide in reverse order = Remove dead-points from end of stroke */
+ case GP_BUILD_TRANSITION_GROW: /* Show in forward order =
+ * Remove ungrown-points from end of stroke. */
+ case GP_BUILD_TRANSITION_SHRINK: /* Hide in reverse order =
+ * Remove dead-points from end of stroke. */
{
/* copy over point data */
memcpy(new_points, gps->points, sizeof(bGPDspoint) * num_points);
@@ -353,7 +356,8 @@ static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa
}
case GP_BUILD_TIMEALIGN_END: /* all end on same frame */
{
- /* Build effect occurs over 1.0 - relative_len, to 1.0 (i.e. over the end of the range) */
+ /* Build effect occurs over 1.0 - relative_len, to 1.0 (i.e. over the end of the range)
+ */
const float start_fac = 1.0f - relative_len;
if (fac >= start_fac) {
@@ -408,7 +412,7 @@ static void generateStrokes(GpencilModifierData *md,
const bool reverse = (mmd->transition != GP_BUILD_TRANSITION_GROW);
const float ctime = DEG_get_ctime(depsgraph);
- //printf("GP Build Modifier - %f\n", ctime);
+ // printf("GP Build Modifier - %f\n", ctime);
/* Early exit if it's an empty frame */
if (gpf->strokes.first == NULL) {
@@ -463,7 +467,8 @@ static void generateStrokes(GpencilModifierData *md,
}
/* Early exit if current frame is outside start/end bounds */
- /* NOTE: If we're beyond the next/prev frames (if existent), then we wouldn't have this problem anyway... */
+ /* NOTE: If we're beyond the next/prev frames (if existent), then we wouldn't have this problem
+ * anyway... */
if (ctime < start_frame) {
/* Before Start - Animation hasn't started. Display initial state. */
if (reverse) {
@@ -501,7 +506,7 @@ static void generateStrokes(GpencilModifierData *md,
/* Determine how far along we are between the keyframes */
float fac = (ctime - start_frame) / (end_frame - start_frame);
- //printf(" Progress on %d = %f (%f - %f)\n", gpf->framenum, fac, start_frame, end_frame);
+ // printf(" Progress on %d = %f (%f - %f)\n", gpf->framenum, fac, start_frame, end_frame);
/* Time management mode */
switch (mmd->mode) {
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
index 2e374ba1acd..a3052b4f6b6 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
@@ -165,7 +165,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
static bool isDisabled(GpencilModifierData *UNUSED(md), int UNUSED(userRenderParams))
{
- //MirrorGpencilModifierData *mmd = (MirrorGpencilModifierData *)md;
+ // MirrorGpencilModifierData *mmd = (MirrorGpencilModifierData *)md;
return false;
}
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index f949a79d039..5a42c4d3d1b 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -31,10 +31,10 @@ set(INC
../blenkernel
../blenlib
../bmesh
+ ../draw
../imbuf
../makesdna
../makesrna
- ../draw
../editors/include
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index 20047174bb1..718553e2b1c 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -88,10 +88,9 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers,
/* draw */
struct GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast, bool wires);
-bool GPU_pbvh_buffers_has_mask(GPU_PBVH_Buffers *buffers);
+short GPU_pbvh_buffers_material_index_get(GPU_PBVH_Buffers *buffers);
-/* debug PBVH draw */
-void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, unsigned int pos);
+bool GPU_pbvh_buffers_has_mask(GPU_PBVH_Buffers *buffers);
void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers);
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index a2f63882860..e30fccbf29d 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -83,6 +83,8 @@ struct GPU_PBVH_Buffers {
uint tot_tri, tot_quad;
+ short material_index;
+
/* The PBVH ensures that either all faces in the node are
* smooth-shaded or all faces are flat-shaded */
bool smooth;
@@ -289,6 +291,11 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
}
}
+ /* Get material index from the first face of this buffer. */
+ const MLoopTri *lt = &buffers->looptri[buffers->face_indices[0]];
+ const MPoly *mp = &buffers->mpoly[lt->poly];
+ buffers->material_index = mp->mat_nr;
+
buffers->show_mask = !empty_mask;
buffers->mvert = mvert;
}
@@ -538,7 +545,6 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers,
int i, j, k, x, y;
const bool smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH;
- static char vcol[4] = {255, 255, 255, 255};
/* Build VBO */
const int has_mask = key->has_mask;
@@ -603,6 +609,7 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers,
}
if (show_vcol) {
+ char vcol[4] = {255, 255, 255, 255};
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, &vcol);
}
@@ -652,6 +659,8 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers,
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index + 3, &fmask);
empty_mask = empty_mask && (fmask == 0.0f);
}
+
+ char vcol[4] = {255, 255, 255, 255};
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 0, &vcol);
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 1, &vcol);
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 2, &vcol);
@@ -666,14 +675,15 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers,
gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS);
}
+ /* Get material index from the first face of this buffer. */
+ buffers->material_index = grid_flag_mats[grid_indices[0]].mat_nr;
+
buffers->grids = grids;
buffers->grid_indices = grid_indices;
buffers->totgrid = totgrid;
buffers->grid_flag_mats = grid_flag_mats;
buffers->gridkey = *key;
buffers->show_mask = !empty_mask;
-
- //printf("node updated %p\n", buffers);
}
GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build(int totgrid, BLI_bitmap **grid_hidden)
@@ -793,6 +803,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
const bool show_vcol = (update_flags & GPU_PBVH_BUFFERS_SHOW_VCOL) != 0;
int tottri, totvert, maxvert = 0;
bool empty_mask = true;
+ BMFace *f;
/* TODO, make mask layer optional for bmesh buffer */
const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
@@ -864,7 +875,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, totvert);
GSET_ITER (gs_iter, bm_faces) {
- BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
+ f = BLI_gsetIterator_getKey(&gs_iter);
BLI_assert(f->len == 3);
@@ -922,7 +933,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
GSetIterator gs_iter;
GSET_ITER (gs_iter, bm_faces) {
- BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
+ f = BLI_gsetIterator_getKey(&gs_iter);
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
BMVert *v[3];
@@ -952,6 +963,9 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
}
}
+ /* Get material index from the last face we iterated on. */
+ buffers->material_index = f->mat_nr;
+
buffers->show_mask = !empty_mask;
gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS);
@@ -990,6 +1004,11 @@ bool GPU_pbvh_buffers_has_mask(GPU_PBVH_Buffers *buffers)
return buffers->show_mask;
}
+short GPU_pbvh_buffers_material_index_get(GPU_PBVH_Buffers *buffers)
+{
+ return buffers->material_index;
+}
+
void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers)
{
if (buffers) {
@@ -1009,70 +1028,6 @@ void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers)
/** \} */
-/* -------------------------------------------------------------------- */
-/** \name Debug
- * \{ */
-
-/* debug function, draws the pbvh BB */
-void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, uint pos)
-{
- if (leaf) {
- immUniformColor4f(0.0, 1.0, 0.0, 0.5);
- }
- else {
- immUniformColor4f(1.0, 0.0, 0.0, 0.5);
- }
-
- /* TODO(merwin): revisit this after we have mutable VertexBuffers
- * could keep a static batch & index buffer, change the VBO contents per draw
- */
-
- immBegin(GPU_PRIM_LINES, 24);
-
- /* top */
- immVertex3f(pos, min[0], min[1], max[2]);
- immVertex3f(pos, min[0], max[1], max[2]);
-
- immVertex3f(pos, min[0], max[1], max[2]);
- immVertex3f(pos, max[0], max[1], max[2]);
-
- immVertex3f(pos, max[0], max[1], max[2]);
- immVertex3f(pos, max[0], min[1], max[2]);
-
- immVertex3f(pos, max[0], min[1], max[2]);
- immVertex3f(pos, min[0], min[1], max[2]);
-
- /* bottom */
- immVertex3f(pos, min[0], min[1], min[2]);
- immVertex3f(pos, min[0], max[1], min[2]);
-
- immVertex3f(pos, min[0], max[1], min[2]);
- immVertex3f(pos, max[0], max[1], min[2]);
-
- immVertex3f(pos, max[0], max[1], min[2]);
- immVertex3f(pos, max[0], min[1], min[2]);
-
- immVertex3f(pos, max[0], min[1], min[2]);
- immVertex3f(pos, min[0], min[1], min[2]);
-
- /* sides */
- immVertex3f(pos, min[0], min[1], min[2]);
- immVertex3f(pos, min[0], min[1], max[2]);
-
- immVertex3f(pos, min[0], max[1], min[2]);
- immVertex3f(pos, min[0], max[1], max[2]);
-
- immVertex3f(pos, max[0], max[1], min[2]);
- immVertex3f(pos, max[0], max[1], max[2]);
-
- immVertex3f(pos, max[0], min[1], min[2]);
- immVertex3f(pos, max[0], min[1], max[2]);
-
- immEnd();
-}
-
-/** \} */
-
void GPU_pbvh_fix_linking()
{
}
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index aef68333b6f..a77bba5ab86 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -892,7 +892,13 @@ static char *code_generate_fragment(GPUMaterial *material,
BLI_dynstr_append(ds, "\t#define invlocaltoviewmat ModelViewMatrixInverse\n");
}
if (builtins & GPU_VIEW_NORMAL) {
+ BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
+ BLI_dynstr_append(ds, "\tvec3 n;\n");
+ BLI_dynstr_append(ds, "\tworld_normals_get(n);\n");
+ BLI_dynstr_append(ds, "\tvec3 facingnormal = transform_direction(ViewMatrix, n);\n");
+ BLI_dynstr_append(ds, "#else\n");
BLI_dynstr_append(ds, "\tvec3 facingnormal = gl_FrontFacing? viewNormal: -viewNormal;\n");
+ BLI_dynstr_append(ds, "#endif\n");
}
if (builtins & GPU_VIEW_POSITION) {
BLI_dynstr_append(ds, "\t#define viewposition viewPosition\n");
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c
index 17d3321560d..010087e5536 100644
--- a/source/blender/gpu/intern/gpu_select.c
+++ b/source/blender/gpu/intern/gpu_select.c
@@ -120,7 +120,7 @@ bool GPU_select_load_id(uint id)
}
default: /* ALGO_GL_PICK */
{
- return gpu_select_pick_load_id(id);
+ return gpu_select_pick_load_id(id, false);
}
}
}
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index 6c3e05912b0..939279d82ff 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -476,10 +476,17 @@ static void gpu_select_load_id_pass_nearest(const DepthBufCache *rect_prev,
}
}
-bool gpu_select_pick_load_id(uint id)
+bool gpu_select_pick_load_id(uint id, bool end)
{
GPUPickState *ps = &g_pick_state;
+
if (ps->gl.is_init) {
+ if (id == ps->gl.prev_id && !end) {
+ /* No need to read if we are still drawing for the same id since
+ * all these depths will be merged / de-duplicated in the end. */
+ return true;
+ }
+
const uint rect_len = ps->src.rect_len;
glReadPixels(UNPACK4(ps->gl.clip_readpixels),
GL_DEPTH_COMPONENT,
@@ -536,7 +543,7 @@ uint gpu_select_pick_end(void)
if (ps->is_cached == false) {
if (ps->gl.is_init) {
/* force finishing last pass */
- gpu_select_pick_load_id(ps->gl.prev_id);
+ gpu_select_pick_load_id(ps->gl.prev_id, true);
}
gpuPopAttr();
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
diff --git a/source/blender/gpu/intern/gpu_select_private.h b/source/blender/gpu/intern/gpu_select_private.h
index bc40e58ba96..a0619bd4293 100644
--- a/source/blender/gpu/intern/gpu_select_private.h
+++ b/source/blender/gpu/intern/gpu_select_private.h
@@ -28,7 +28,7 @@
/* gpu_select_pick */
void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, char mode);
-bool gpu_select_pick_load_id(uint id);
+bool gpu_select_pick_load_id(uint id, bool end);
uint gpu_select_pick_end(void);
void gpu_select_pick_cache_begin(void);
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index b0b0fe01192..3d5b0dda5e4 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -648,7 +648,7 @@ void GPU_shader_transform_feedback_disable(GPUShader *UNUSED(shader))
void GPU_shader_free(GPUShader *shader)
{
-#if 0 /* Would be nice to have, but for now the Deferred compilation
+#if 0 /* Would be nice to have, but for now the Deferred compilation \
* does not have a GPUContext. */
BLI_assert(GPU_context_active_get() != NULL);
#endif
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index 13164c86ffb..ad4831ed903 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -544,6 +544,8 @@ static bool gpu_texture_check_capacity(
return false;
}
ATTR_FALLTHROUGH;
+ default:
+ break;
}
return true;
@@ -997,7 +999,8 @@ GPUTexture *GPU_texture_create_buffer(eGPUTextureFormat tex_format, const GLuint
ELEM(tex_format, GPU_RG16F, GPU_RG32F) ||
ELEM(tex_format, GPU_RG8I, GPU_RG16I, GPU_RG32I) ||
ELEM(tex_format, GPU_RG8UI, GPU_RG16UI, GPU_RG32UI) ||
- //ELEM(tex_format, GPU_RGB32F, GPU_RGB32I, GPU_RGB32UI) || /* Not available until gl 4.0 */
+ /* Not available until gl 4.0 */
+ // ELEM(tex_format, GPU_RGB32F, GPU_RGB32I, GPU_RGB32UI) ||
ELEM(tex_format, GPU_RGBA8, GPU_RGBA16) || ELEM(tex_format, GPU_RGBA16F, GPU_RGBA32F) ||
ELEM(tex_format, GPU_RGBA8I, GPU_RGBA16I, GPU_RGBA32I) ||
ELEM(tex_format, GPU_RGBA8UI, GPU_RGBA16UI, GPU_RGBA32UI))) {
diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.c b/source/blender/gpu/intern/gpu_uniformbuffer.c
index 651e3c1aaa7..d7766c51f38 100644
--- a/source/blender/gpu/intern/gpu_uniformbuffer.c
+++ b/source/blender/gpu/intern/gpu_uniformbuffer.c
@@ -65,7 +65,7 @@ static void gpu_uniformbuffer_inputs_sort(struct ListBase *inputs);
/* Only support up to this type, if you want to extend it, make sure the
* padding logic is correct for the new types. */
-#define MAX_UBO_GPU_TYPE GPU_VEC4
+#define MAX_UBO_GPU_TYPE GPU_MAT4
static void gpu_uniformbuffer_initialize(GPUUniformBuffer *ubo, const void *data)
{
@@ -243,7 +243,7 @@ static eGPUType get_padded_gpu_type(LinkData *link)
}
/**
- * Returns 1 if the first item shold be after second item.
+ * Returns 1 if the first item should be after second item.
* We make sure the vec4 uniforms come first.
*/
static int inputs_cmp(const void *a, const void *b)
@@ -255,11 +255,11 @@ static int inputs_cmp(const void *a, const void *b)
/**
* Make sure we respect the expected alignment of UBOs.
- * vec4, pad vec3 as vec4, then vec2, then floats.
+ * mat4, vec4, pad vec3 as vec4, then vec2, then floats.
*/
static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
{
- /* Order them as vec4, vec3, vec2, float. */
+ /* Order them as mat4, vec4, vec3, vec2, float. */
BLI_listbase_sort(inputs, inputs_cmp);
/* Creates a lookup table for the different types; */
@@ -268,6 +268,17 @@ static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
for (LinkData *link = inputs->first; link; link = link->next) {
GPUInput *input = link->data;
+
+ if (input->type == GPU_MAT3) {
+ /* Alignment for mat3 is not handled currently, so not supported */
+ BLI_assert(!"mat3 not supported in UBO");
+ continue;
+ }
+ else if (input->type > MAX_UBO_GPU_TYPE) {
+ BLI_assert(!"GPU type not supported in UBO");
+ continue;
+ }
+
if (input->type == cur_type) {
continue;
}
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 6ad93e88130..1cbf58f9d16 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -1162,8 +1162,9 @@ vec3 cellnoise_color(vec3 p)
float floorfrac(float x, out int i)
{
- i = floor_to_int(x);
- return x - i;
+ float x_floor = floor(x);
+ i = int(x_floor);
+ return x - x_floor;
}
/* bsdfs */
@@ -2771,7 +2772,9 @@ float noise_perlin(float x, float y, float z)
noise_v[1] = noise_nerp(v, noise_u[0], noise_u[1]);
- return noise_scale3(noise_nerp(w, noise_v[0], noise_v[1]));
+ float r = noise_scale3(noise_nerp(w, noise_v[0], noise_v[1]));
+
+ return (isinf(r)) ? 0.0 : r;
}
float noise(vec3 p)
@@ -3405,7 +3408,7 @@ void world_normals_get(out vec3 N)
/* Shade as a cylinder. */
cos_theta = hairThickTime / hairThickness;
}
- float sin_theta = sqrt(max(0.0, 1.0f - cos_theta * cos_theta));
+ float sin_theta = sqrt(max(0.0, 1.0 - cos_theta * cos_theta));
N = normalize(worldNormal * sin_theta + B * cos_theta);
# else
N = gl_FrontFacing ? worldNormal : -worldNormal;
@@ -3426,15 +3429,18 @@ void node_eevee_specular(vec4 diffuse,
out Closure result)
{
vec3 out_diff, out_spec, ssr_spec;
- eevee_closure_default(normal,
- diffuse.rgb,
- specular.rgb,
- int(ssr_id),
- roughness,
- occlusion,
- out_diff,
- out_spec,
- ssr_spec);
+ eevee_closure_default_clearcoat(normal,
+ diffuse.rgb,
+ specular.rgb,
+ int(ssr_id),
+ roughness,
+ clearcoat_normal,
+ clearcoat * 0.25,
+ clearcoat_roughness,
+ occlusion,
+ out_diff,
+ out_spec,
+ ssr_spec);
vec3 vN = normalize(mat3(ViewMatrix) * normal);
result = CLOSURE_DEFAULT;
diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h
index ade3113f041..0b118a25c13 100644
--- a/source/blender/ikplugin/BIK_api.h
+++ b/source/blender/ikplugin/BIK_api.h
@@ -68,9 +68,18 @@ void BIK_clear_cache(struct bPose *pose);
void BIK_update_param(struct bPose *pose);
void BIK_test_constraint(struct Object *ob, struct bConstraint *cons);
// not yet implemented
-// int BIK_get_constraint_param(struct bPose *pose, struct bConstraint *cons, int id, BIK_ParamValue *value);
-// int BIK_get_channel_param(struct bPose *pose, struct bPoseChannel *pchan, int id, BIK_ParamValue *value);
-// int BIK_get_solver_param(struct bPose *pose, struct bPoseChannel *pchan, int id, BIK_ParamValue *value);
+// int BIK_get_constraint_param(struct bPose *pose,
+// struct bConstraint *cons,
+// int id,
+// BIK_ParamValue *value);
+// int BIK_get_channel_param(struct bPose *pose,
+// struct bPoseChannel *pchan,
+// int id,
+// BIK_ParamValue *value);
+// int BIK_get_solver_param(struct bPose *pose,
+// struct bPoseChannel *pchan,
+// int id,
+// BIK_ParamValue *value);
// number of solver available
// 0 = iksolver
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index 5615cc4ea31..9ae8855bc85 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -47,7 +47,8 @@
/* ********************** THE IK SOLVER ******************* */
/* allocates PoseTree, and links that to root bone/channel */
-/* Note: detecting the IK chain is duplicate code... in drawarmature.c and in transform_conversions.c */
+/* Note: detecting the IK chain is duplicate code...
+ * in drawarmature.c and in transform_conversions.c */
static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_tip)
{
bPoseChannel *curchan, *pchan_root = NULL, *chanlist[256], **oldchan;
@@ -575,7 +576,8 @@ void iksolver_execute_tree(struct Depsgraph *depsgraph,
for (a = 0; a < tree->totchannel; a++) {
if (!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag
BKE_pose_where_is_bone(depsgraph, scene, ob, tree->pchan[a], ctime, 1);
- /* tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() */
+ /* Tell blender that this channel was controlled by IK,
+ * it's cleared on each BKE_pose_where_is(). */
tree->pchan[a]->flag |= POSE_CHAIN;
}
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index 819ddfd31b0..e05385feb17 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -89,16 +89,16 @@ struct IK_Target {
iTaSC::ConstraintSet *constraint;
struct bConstraint *blenderConstraint;
struct bPoseChannel *rootChannel;
- Object *owner; //for auto IK
+ Object *owner; // for auto IK
ErrorCallback errorCallback;
std::string targetName;
std::string constraintName;
unsigned short controlType;
- short channel; //index in IK channel array of channel on which this target is defined
- short ee; //end effector number
- bool simulation; //true when simulation mode is used (update feedback)
- bool eeBlend; //end effector affected by enforce blending
- float eeRest[4][4]; //end effector initial pose relative to armature
+ short channel; // index in IK channel array of channel on which this target is defined
+ short ee; // end effector number
+ bool simulation; // true when simulation mode is used (update feedback)
+ bool eeBlend; // end effector affected by enforce blending
+ float eeRest[4][4]; // end effector initial pose relative to armature
IK_Target()
{
@@ -289,7 +289,8 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
/* create a target */
target = (PoseTarget *)MEM_callocN(sizeof(PoseTarget), "posetarget");
target->con = con;
- // by contruction there can be only one tree per channel and each channel can be part of at most one tree.
+ // by contruction there can be only one tree per channel
+ // and each channel can be part of at most one tree.
tree = (PoseTree *)pchan_root->iktree.first;
if (tree == NULL) {
@@ -377,7 +378,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
static bool is_cartesian_constraint(bConstraint *con)
{
- //bKinematicConstraint* data=(bKinematicConstraint *)con->data;
+ // bKinematicConstraint* data=(bKinematicConstraint *)con->data;
return true;
}
@@ -656,7 +657,8 @@ static bool base_callback(const iTaSC::Timestamp &timestamp,
1.0);
// convert to armature space
mul_m4_m4m4(polemat, imat, mat);
- // get the target in world space (was computed before as target object are defined before base object)
+ // get the target in world space
+ // (was computed before as target object are defined before base object).
iktarget->target->getPose().getValue(mat[0]);
// convert to armature space
mul_m4_m4m4(goalmat, imat, mat);
@@ -849,11 +851,13 @@ static bool joint_callback(const iTaSC::Timestamp &timestamp,
float rmat[3][3];
if (chan->rotmode > 0) {
- /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
+ /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation
+ * orders) */
eulO_to_mat3(rmat, chan->eul, chan->rotmode);
}
else if (chan->rotmode == ROT_MODE_AXISANGLE) {
- /* axis-angle - stored in quaternion data, but not really that great for 3D-changing orientations */
+ /* axis-angle - stored in quaternion data,
+ * but not really that great for 3D-changing orientations */
axis_angle_to_mat3(rmat, &chan->quat[1], chan->quat[0]);
}
else {
@@ -936,7 +940,8 @@ static int convert_channels(struct Depsgraph *depsgraph,
// joint angles and can't be applied to the iTaSC armature dynamically
if (!(pchan->flag & POSE_DONE))
BKE_pose_where_is_bone(depsgraph, ikscene->blscene, ikscene->blArmature, pchan, ctime, 1);
- // tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is()
+ // tell blender that this channel was controlled by IK,
+ // it's cleared on each BKE_pose_where_is()
pchan->flag |= (POSE_DONE | POSE_CHAIN);
/* set DoF flag */
@@ -1645,8 +1650,9 @@ static void execute_scene(struct Depsgraph *depsgraph,
IK_Channel *ikchan;
if (ikparam->flag & ITASC_SIMULATION) {
for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ++ikchan) {
- // In simulation mode we don't allow external contraint to change our bones, mark the channel done
- // also tell Blender that this channel is part of IK tree (cleared on each BKE_pose_where_is()
+ // In simulation mode we don't allow external contraint to change our bones, mark the channel
+ // done also tell Blender that this channel is part of IK tree
+ // (cleared on each BKE_pose_where_is()
ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN);
ikchan->jointValid = 0;
}
@@ -1656,7 +1662,8 @@ static void execute_scene(struct Depsgraph *depsgraph,
for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ++ikchan) {
if (!(ikchan->pchan->flag & POSE_DONE))
BKE_pose_where_is_bone(depsgraph, blscene, ikscene->blArmature, ikchan->pchan, ctime, 1);
- // tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is()
+ // tell blender that this channel was controlled by IK,
+ // it's cleared on each BKE_pose_where_is()
ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN);
ikchan->jointValid = 0;
}
@@ -1906,8 +1913,8 @@ void itasc_update_param(struct bPose *pose)
CONSTRAINT_ID_ALL, iTaSC::Armature::ID_JOINT, iTaSC::ACT_FEEDBACK, ikparam->feedback);
}
else {
- // in animation mode timestep is 1s by convention =>
- // qmax becomes radiant and feedback becomes fraction of error gap corrected in one iteration
+ // in animation mode timestep is 1s by convention => qmax becomes radiant and feedback
+ // becomes fraction of error gap corrected in one iteration.
ikscene->scene->setParam(iTaSC::Scene::MIN_TIMESTEP, 1.0);
ikscene->scene->setParam(iTaSC::Scene::MAX_TIMESTEP, 1.0);
ikscene->solver->setParam(iTaSC::Solver::DLS_QMAX, 0.52);
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index bdc1abf3132..f8df14cf317 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -173,6 +173,13 @@ bool addzbufImBuf(struct ImBuf *ibuf);
bool addzbuffloatImBuf(struct ImBuf *ibuf);
/**
+ * Approximate size of ImBuf in memory
+ *
+ * \attention Defined in allocimbuf.c
+ */
+size_t IMB_get_size_in_memory(struct ImBuf *ibuf);
+
+/**
*
* \attention Defined in rectop.c
*/
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 76304b33a6f..fe24ccc99a9 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -618,6 +618,35 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
return (ibuf2);
}
+size_t IMB_get_size_in_memory(ImBuf *ibuf)
+{
+ int a;
+ size_t size = 0, channel_size = 0;
+
+ size += sizeof(ImBuf);
+
+ if (ibuf->rect)
+ channel_size += sizeof(char);
+
+ if (ibuf->rect_float)
+ channel_size += sizeof(float);
+
+ size += channel_size * ibuf->x * ibuf->y * ibuf->channels;
+
+ if (ibuf->miptot) {
+ for (a = 0; a < ibuf->miptot; a++) {
+ if (ibuf->mipmap[a])
+ size += IMB_get_size_in_memory(ibuf->mipmap[a]);
+ }
+ }
+
+ if (ibuf->tiles) {
+ size += sizeof(unsigned int) * ibuf->ytiles * ibuf->xtiles;
+ }
+
+ return size;
+}
+
#if 0 /* remove? - campbell */
/* support for cache limiting */
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 4ef4e15d1c9..483ccc9ea9d 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -87,7 +87,7 @@
# include <libswscale/swscale.h>
# include "ffmpeg_compat.h"
-#endif //WITH_FFMPEG
+#endif // WITH_FFMPEG
int ismovie(const char *UNUSED(filepath))
{
@@ -453,7 +453,7 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position)
if (lpbi) {
ibuf = IMB_ibImageFromMemory(
(const unsigned char *)lpbi, 100, IB_rect, anim->colorspace, "<avi_fetchibuf>");
- //Oh brother...
+ // Oh brother...
}
}
}
diff --git a/source/blender/imbuf/intern/cache.c b/source/blender/imbuf/intern/cache.c
index 01c588daedd..7ddf4423bbf 100644
--- a/source/blender/imbuf/intern/cache.c
+++ b/source/blender/imbuf/intern/cache.c
@@ -156,7 +156,7 @@ void imb_tile_cache_tile_free(ImBuf *ibuf, int tx, int ty)
if (gtile) {
/* in case another thread is loading this */
while (gtile->loading) {
- ;
+ /* pass */
}
BLI_ghash_remove(GLOBAL_CACHE.tilehash, gtile, NULL, NULL);
@@ -295,7 +295,7 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf,
BLI_mutex_unlock(&GLOBAL_CACHE.mutex);
while (gtile->loading) {
- ;
+ /* pass */
}
}
else {
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index abe8a0c1883..3f222a096ac 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -76,7 +76,7 @@ static const uint FOURCC_RXGB = DDS_MAKEFOURCC('R', 'X', 'G', 'B');
static const uint FOURCC_ATI1 = DDS_MAKEFOURCC('A', 'T', 'I', '1');
static const uint FOURCC_ATI2 = DDS_MAKEFOURCC('A', 'T', 'I', '2');
-//static const uint FOURCC_A2XY = DDS_MAKEFOURCC('A', '2', 'X', 'Y');
+// static const uint FOURCC_A2XY = DDS_MAKEFOURCC('A', '2', 'X', 'Y');
static const uint FOURCC_DX10 = DDS_MAKEFOURCC('D', 'X', '1', '0');
@@ -100,25 +100,25 @@ static const uint D3DFMT_X8B8G8R8 = 33;
static const uint D3DFMT_G16R16 = 34;
static const uint D3DFMT_A2R10G10B10 = 35;
-//static const uint D3DFMT_A16B16G16R16 = 36;
+// static const uint D3DFMT_A16B16G16R16 = 36;
// Palette formats.
-//static const uint D3DFMT_A8P8 = 40;
-//static const uint D3DFMT_P8 = 41;
+// static const uint D3DFMT_A8P8 = 40;
+// static const uint D3DFMT_P8 = 41;
// Luminance formats.
static const uint D3DFMT_L8 = 50;
-//static const uint D3DFMT_A8L8 = 51;
-//static const uint D3DFMT_A4L4 = 52;
+// static const uint D3DFMT_A8L8 = 51;
+// static const uint D3DFMT_A4L4 = 52;
static const uint D3DFMT_L16 = 81;
// Floating point formats
-//static const uint D3DFMT_R16F = 111;
-//static const uint D3DFMT_G16R16F = 112;
-//static const uint D3DFMT_A16B16G16R16F = 113;
-//static const uint D3DFMT_R32F = 114;
-//static const uint D3DFMT_G32R32F = 115;
-//static const uint D3DFMT_A32B32G32R32F = 116;
+// static const uint D3DFMT_R16F = 111;
+// static const uint D3DFMT_G16R16F = 112;
+// static const uint D3DFMT_A16B16G16R16F = 113;
+// static const uint D3DFMT_R32F = 114;
+// static const uint D3DFMT_G32R32F = 115;
+// static const uint D3DFMT_A32B32G32R32F = 116;
static const uint DDSD_CAPS = 0x00000001U;
static const uint DDSD_PIXELFORMAT = 0x00001000U;
@@ -722,7 +722,7 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask
}
// D3DX functions do not like this:
- this->pf.fourcc = 0; //findD3D9Format(bitcount, rmask, gmask, bmask, amask);
+ this->pf.fourcc = 0; // findD3D9Format(bitcount, rmask, gmask, bmask, amask);
#if 0
if (this->pf.fourcc) {
this->pf.flags |= DDPF_FOURCC;
@@ -742,7 +742,7 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask
void DDSHeader::setDX10Format(uint format)
{
- //this->pf.flags = 0;
+ // this->pf.flags = 0;
this->pf.fourcc = FOURCC_DX10;
this->header10.dxgiFormat = format;
}
diff --git a/source/blender/imbuf/intern/dds/PixelFormat.h b/source/blender/imbuf/intern/dds/PixelFormat.h
index e63b17c89e5..47585147dfb 100644
--- a/source/blender/imbuf/intern/dds/PixelFormat.h
+++ b/source/blender/imbuf/intern/dds/PixelFormat.h
@@ -95,10 +95,10 @@ inline void maskShiftAndSize(uint mask, uint *shift, uint *size)
inline float quantizeCeil(float f, int inbits, int outbits)
{
- //uint i = f * (float(1 << inbits) - 1);
- //i = convert(i, inbits, outbits);
- //float result = float(i) / (float(1 << outbits) - 1);
- //nvCheck(result >= f);
+ // uint i = f * (float(1 << inbits) - 1);
+ // i = convert(i, inbits, outbits);
+ // float result = float(i) / (float(1 << outbits) - 1);
+ // nvCheck(result >= f);
float result;
int offset = 0;
do {
diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c
index 4424e5548ca..3cb976a6d9f 100644
--- a/source/blender/imbuf/intern/moviecache.c
+++ b/source/blender/imbuf/intern/moviecache.c
@@ -186,58 +186,23 @@ static void IMB_moviecache_destructor(void *p)
}
}
-/* approximate size of ImBuf in memory */
-static size_t IMB_get_size_in_memory(ImBuf *ibuf)
+static size_t get_size_in_memory(ImBuf *ibuf)
{
- int a;
- size_t size = 0, channel_size = 0;
-
- /* Persistent images should have no affect on how "normal"
- * images are cached.
- *
- * This is a bit arbitrary, but would make it so only movies
- * and sequences are memory limited, keeping textures in the
- * memory in order to avoid constant file reload on viewport
- * update.
- */
+ /* Keep textures in the memory to avoid constant file reload on viewport update. */
if (ibuf->userflags & IB_PERSISTENT) {
return 0;
}
-
- size += sizeof(ImBuf);
-
- if (ibuf->rect) {
- channel_size += sizeof(char);
- }
-
- if (ibuf->rect_float) {
- channel_size += sizeof(float);
- }
-
- size += channel_size * ibuf->x * ibuf->y * ibuf->channels;
-
- if (ibuf->miptot) {
- for (a = 0; a < ibuf->miptot; a++) {
- if (ibuf->mipmap[a]) {
- size += IMB_get_size_in_memory(ibuf->mipmap[a]);
- }
- }
- }
-
- if (ibuf->tiles) {
- size += sizeof(unsigned int) * ibuf->ytiles * ibuf->xtiles;
+ else {
+ return IMB_get_size_in_memory(ibuf);
}
-
- return size;
}
-
static size_t get_item_size(void *p)
{
size_t size = sizeof(MovieCacheItem);
MovieCacheItem *item = (MovieCacheItem *)p;
if (item->ibuf) {
- size += IMB_get_size_in_memory(item->ibuf);
+ size += get_size_in_memory(item->ibuf);
}
return size;
@@ -407,7 +372,7 @@ bool IMB_moviecache_put_if_possible(MovieCache *cache, void *userkey, ImBuf *ibu
size_t mem_in_use, mem_limit, elem_size;
bool result = false;
- elem_size = IMB_get_size_in_memory(ibuf);
+ elem_size = get_size_in_memory(ibuf);
mem_limit = MEM_CacheLimiter_get_maximum();
BLI_mutex_lock(&limitor_lock);
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 31649330e11..a98ec2b0f15 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -1913,7 +1913,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
const int width = dw.max.x - dw.min.x + 1;
const int height = dw.max.y - dw.min.y + 1;
- //printf("OpenEXR-load: image data window %d %d %d %d\n",
+ // printf("OpenEXR-load: image data window %d %d %d %d\n",
// dw.min.x, dw.min.y, dw.max.x, dw.max.y);
if (0) { // debug
diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c
index d44ce1ac269..5e81b716619 100644
--- a/source/blender/imbuf/intern/radiance_hdr.c
+++ b/source/blender/imbuf/intern/radiance_hdr.c
@@ -202,7 +202,7 @@ int imb_is_a_hdr(const unsigned char *buf)
/* For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead */
/* update: actually, the 'RADIANCE' part is just an optional program name,
* the magic word is really only the '#?' part */
- //if (strstr((char *)buf, "#?RADIANCE")) return 1;
+ // if (strstr((char *)buf, "#?RADIANCE")) return 1;
if (strstr((char *)buf, "#?")) {
return 1;
}
@@ -300,9 +300,9 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem,
return ibuf;
}
- //else printf("Data not found!\n");
+ // else printf("Data not found!\n");
}
- //else printf("Not a valid radiance HDR file!\n");
+ // else printf("Not a valid radiance HDR file!\n");
return NULL;
}
@@ -354,7 +354,7 @@ static int fwritecolrs(FILE *file, int width, int channels, unsigned char *ibufs
for (cnt = 1; (cnt < 127) && ((beg + cnt) < width) &&
(rgbe_scan[beg + cnt][i] == rgbe_scan[beg][i]);
cnt++) {
- ;
+ /* pass */
}
if (cnt >= MINRUN) {
break; /* long enough */
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 2cdbfa06e30..14b3d97cef4 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -602,6 +602,10 @@ typedef enum IDRecalcFlag {
*/
ID_RECALC_COPY_ON_WRITE = (1 << 13),
+ /* Sequences in the sequencer did change.
+ * Use this tag with a scene ID which owns the sequences. */
+ ID_RECALC_SEQUENCER = (1 << 14),
+
/***************************************************************************
* Pseudonyms, to have more semantic meaning in the actual code without
* using too much low-level and implementation specific tags. */
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 5af7f9d0bbf..c524f50ff52 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -831,11 +831,11 @@ typedef enum eSAction_Flag {
/* draw time in seconds instead of time in frames */
SACTION_DRAWTIME = (1 << 2),
/* don't filter action channels according to visibility */
- //SACTION_NOHIDE = (1 << 3), // XXX deprecated... old animation system
+ // SACTION_NOHIDE = (1 << 3), // XXX deprecated... old animation system
/* don't kill overlapping keyframes after transform */
SACTION_NOTRANSKEYCULL = (1 << 4),
/* don't include keyframes that are out of view */
- //SACTION_HORIZOPTIMISEON = (1 << 5), // XXX deprecated... old irrelevant trick
+ // SACTION_HORIZOPTIMISEON = (1 << 5), // XXX deprecated... old irrelevant trick
/* show pose-markers (local to action) in Action Editor mode */
SACTION_POSEMARKERS_SHOW = (1 << 6),
/* don't draw action channels using group colors (where applicable) */
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 7e97ad387dc..c76d4895b25 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -508,7 +508,7 @@ typedef enum eDriver_Flags {
DRIVER_FLAG_DEPRECATED = (1 << 1),
/** Driver does replace value, but overrides (for layering of animation over driver) */
// TODO: this needs to be implemented at some stage or left out...
- //DRIVER_FLAG_LAYERING = (1 << 2),
+ // DRIVER_FLAG_LAYERING = (1 << 2),
/** Use when the expression needs to be recompiled. */
DRIVER_FLAG_RECOMPILE = (1 << 3),
/** The names are cached so they don't need have python unicode versions created each time */
@@ -710,6 +710,11 @@ typedef struct NlaStrip {
/** Settings. */
int flag;
char _pad2[4];
+
+ /* Pointer to an original NLA strip. */
+ struct NlaStrip *orig_strip;
+
+ void *_pad3;
} NlaStrip;
/* NLA Strip Blending Mode */
diff --git a/source/blender/makesdna/DNA_boid_types.h b/source/blender/makesdna/DNA_boid_types.h
index de1dac21ea0..47fe7d35596 100644
--- a/source/blender/makesdna/DNA_boid_types.h
+++ b/source/blender/makesdna/DNA_boid_types.h
@@ -117,13 +117,13 @@ typedef struct BoidData {
} BoidData;
// planned for near future
-//typedef enum BoidConditionMode {
+// typedef enum BoidConditionMode {
// eBoidConditionType_Then = 0,
// eBoidConditionType_And = 1,
// eBoidConditionType_Or = 2,
// NUM_BOID_CONDITION_MODES
//} BoidConditionMode;
-//typedef enum BoidConditionType {
+// typedef enum BoidConditionType {
// eBoidConditionType_None = 0,
// eBoidConditionType_Signal = 1,
// eBoidConditionType_NoSignal = 2,
@@ -135,7 +135,7 @@ typedef struct BoidData {
// eBoidConditionType_Touching = 8,
// NUM_BOID_CONDITION_TYPES
//} BoidConditionType;
-//typedef struct BoidCondition {
+// typedef struct BoidCondition {
// struct BoidCondition *next, *prev;
// int state_id;
// short type, mode;
@@ -170,19 +170,19 @@ typedef struct BoidState {
} BoidState;
// planned for near future
-//typedef struct BoidSignal {
+// typedef struct BoidSignal {
// struct BoidSignal *next, *prev;
// float loc[3];
// float volume, falloff;
// int id;
//} BoidSignal;
-//typedef struct BoidSignalDefine {
+// typedef struct BoidSignalDefine {
// struct BoidSignalDefine *next, *prev;
// int id, rt;
// char name[32];
//} BoidSignalDefine;
-//typedef struct BoidSimulationData {
+// typedef struct BoidSimulationData {
// ListBase signal_defines;/* list of defined signals */
// ListBase signals[20]; /* gathers signals from all channels */
// struct KDTree_3d *signaltrees[20];
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index abc9b8f7920..6f775e48d58 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -263,6 +263,8 @@ typedef struct Brush {
/** Active sculpt tool. */
char sculpt_tool;
+ /** Active sculpt tool. */
+ char uv_sculpt_tool;
/** Active vertex paint. */
char vertexpaint_tool;
/** Active weight paint. */
@@ -273,7 +275,7 @@ typedef struct Brush {
char mask_tool;
/** Active grease pencil tool. */
char gpencil_tool;
- char _pad0[2];
+ char _pad0[1];
float autosmooth_factor;
@@ -324,7 +326,7 @@ typedef struct PaletteColor {
typedef struct Palette {
ID id;
- /* pointer to individual colours */
+ /** Pointer to individual colors. */
ListBase colors;
int active_color;
@@ -437,6 +439,13 @@ typedef enum eBrushSculptTool {
SCULPT_TOOL_MASK = 19,
} eBrushSculptTool;
+/* Brush.uv_sculpt_tool */
+typedef enum eBrushUVSculptTool {
+ UV_SCULPT_TOOL_GRAB = 0,
+ UV_SCULPT_TOOL_RELAX = 1,
+ UV_SCULPT_TOOL_PINCH = 2,
+} eBrushUVSculptTool;
+
/** When #BRUSH_ACCUMULATE is used */
#define SCULPT_TOOL_HAS_ACCUMULATE(t) \
ELEM(t, \
diff --git a/source/blender/makesdna/DNA_cachefile_types.h b/source/blender/makesdna/DNA_cachefile_types.h
index e5f77f70720..bc57202367c 100644
--- a/source/blender/makesdna/DNA_cachefile_types.h
+++ b/source/blender/makesdna/DNA_cachefile_types.h
@@ -30,10 +30,12 @@
extern "C" {
#endif
+struct GSet;
+
/* CacheFile::flag */
enum {
CACHEFILE_DS_EXPAND = (1 << 0),
- CACHEFILE_DIRTY = (1 << 1),
+ CACHEFILE_UNUSED_0 = (1 << 1),
};
/* CacheFile::draw_flag */
@@ -53,9 +55,6 @@ typedef struct CacheFile {
ID id;
struct AnimData *adt;
- struct AbcArchiveHandle *handle;
- void *handle_mutex;
-
/** Paths of the objects inside of the Alembic archive referenced by this CacheFile. */
ListBase object_paths;
@@ -78,6 +77,11 @@ typedef struct CacheFile {
short draw_flag;
char _pad[4];
+
+ /* Runtime */
+ struct AbcArchiveHandle *handle;
+ char handle_filepath[1024];
+ struct GSet *handle_readers;
} CacheFile;
#ifdef __cplusplus
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index 3ca61400e2e..f839f22ec9f 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -593,9 +593,12 @@ typedef struct bObjectSolverConstraint {
/* Transform matrix cache constraint */
typedef struct bTransformCacheConstraint {
struct CacheFile *cache_file;
- struct CacheReader *reader;
/** FILE_MAX. */
char object_path[1024];
+
+ /* Runtime. */
+ struct CacheReader *reader;
+ char reader_object_path[1024];
} bTransformCacheConstraint;
/* ------------------------------------------ */
diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h
index 5d482024d07..d949b34cb57 100644
--- a/source/blender/makesdna/DNA_dynamicpaint_types.h
+++ b/source/blender/makesdna/DNA_dynamicpaint_types.h
@@ -48,7 +48,6 @@ enum {
MOD_DPAINT_MULALPHA = 1 << 3, /* Multiply color by alpha when saving image */
MOD_DPAINT_DISSOLVE_LOG = 1 << 4, /* Use 1/x for surface dissolve */
MOD_DPAINT_DRY_LOG = 1 << 5, /* Use 1/x for drying paint */
- MOD_DPAINT_PREVIEW = 1 << 6, /* preview this surface on viewport*/
MOD_DPAINT_WAVE_OPEN_BORDERS = 1 << 7, /* passes waves through mesh edges */
MOD_DPAINT_DISP_INCREMENTAL = 1 << 8, /* builds displace on top of earlier values */
@@ -77,12 +76,6 @@ enum {
MOD_DPAINT_EFFECT_DO_SHRINK = 1 << 2, /* do shrink effect */
};
-/* preview_id */
-enum {
- MOD_DPAINT_SURFACE_PREV_PAINT = 0,
- MOD_DPAINT_SURFACE_PREV_WETMAP = 1,
-};
-
/* init_color_type */
enum {
MOD_DPAINT_INITIAL_NONE = 0,
@@ -120,15 +113,11 @@ typedef struct DynamicPaintSurface {
short disp_type, image_fileformat;
/** Ui selection box. */
short effect_ui;
- /** Surface output id to preview. */
- short preview_id;
short init_color_type;
- char _pad0[2];
int flags, effect;
int image_resolution, substeps;
int start_frame, end_frame;
- char _pad[4];
/* initial color */
float init_color[4];
@@ -163,12 +152,6 @@ typedef struct DynamicPaintSurface {
/* canvas flags */
enum {
-/* This should not be needed, having a valid WEIGHT_MCOL layer should be enough.
- * And if not, should be a general flag. But seems unnecessary for now... */
-#if 0
- /** if viewport preview is ready */
- MOD_DPAINT_PREVIEW_READY = 1 << 0,
-#endif
/** surface is already baking, so it wont get updated (loop) */
MOD_DPAINT_BAKING = 1 << 1,
};
@@ -191,7 +174,7 @@ typedef struct DynamicPaintCanvasSettings {
enum {
/** use particle radius */
MOD_DPAINT_PART_RAD = 1 << 0,
- //MOD_DPAINT_USE_MATERIAL = 1 << 1, /* DNA_DEPRECATED */
+ // MOD_DPAINT_USE_MATERIAL = 1 << 1, /* DNA_DEPRECATED */
/** don't increase alpha unless paint alpha is higher than existing */
MOD_DPAINT_ABS_ALPHA = 1 << 2,
/** removes paint */
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index f39676f53ad..bb38311cbac 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -136,7 +136,7 @@ typedef enum eGPDpalettecolor_Flag {
typedef struct bGPDpalette {
struct bGPDpalette *next, *prev;
- /** Pointer to individual colours. */
+ /** Pointer to individual colors. */
ListBase colors;
/** Palette name. Must be unique. */
char info[64];
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index 1c7712dbb17..04d060b065d 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -188,7 +188,7 @@ typedef struct MVertTri {
unsigned int tri[3];
} MVertTri;
-//typedef struct MTexPoly {
+// typedef struct MTexPoly {
// void *_pad;
//} MTexPoly;
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index eeeadd16181..7baa08e4fbe 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1862,12 +1862,15 @@ typedef struct MeshSeqCacheModifierData {
ModifierData modifier;
struct CacheFile *cache_file;
- struct CacheReader *reader;
/** 1024 = FILE_MAX. */
char object_path[1024];
char read_flag;
char _pad[7];
+
+ /* Runtime. */
+ struct CacheReader *reader;
+ char reader_object_path[1024];
} MeshSeqCacheModifierData;
/* MeshSeqCacheModifierData.read_flag */
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 4bdb348c74f..226e1d2f841 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -42,12 +42,6 @@ struct bNodeTreeExec;
struct bNodeType;
struct uiBlock;
-/* In writefile.c: write deprecated DNA data,
- * to ensure forward compatibility in 2.6x versions.
- * Will be removed eventually.
- */
-#define USE_NODE_COMPAT_CUSTOMNODES
-
#define NODE_MAXSTR 64
typedef struct bNodeStack {
@@ -510,17 +504,6 @@ typedef struct bNodeTree {
/* tree is localized copy, free when deleting node groups */
/* #define NTREE_IS_LOCALIZED (1 << 5) */
-/* XXX not nice, but needed as a temporary flags
- * for group updates after library linking.
- */
-
-/* changes from r35033 */
-#define NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2 (1 << 10)
-/* custom_nodes branch: remove links to node tree sockets */
-#define NTREE_DO_VERSIONS_CUSTOMNODES_GROUP (1 << 11)
-/* custom_nodes branch: create group input/output nodes */
-#define NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE (1 << 12)
-
/* ntree->update */
typedef enum eNodeTreeUpdate {
NTREE_UPDATE = 0xFFFF, /* generic update flag (includes all others) */
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 781a2216029..1aeb4a2f4d2 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -573,8 +573,7 @@ enum {
/* **************** BASE ********************* */
-/* also needed for base!!!!! or rather, they interfere....*/
-/* base->flag and ob->flag */
+/* base->flag_legacy */
enum {
BA_WAS_SEL = (1 << 1),
/* NOTE: BA_HAS_RECALC_DATA can be re-used later if freed in readfile.c. */
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index f69c84cb7a1..ff4ada613c5 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -213,7 +213,7 @@ typedef enum eRigidBody_Shape {
RB_SHAPE_TRIMESH,
/* concave mesh approximated using primitives */
- //RB_SHAPE_COMPOUND,
+ // RB_SHAPE_COMPOUND,
} eRigidBody_Shape;
typedef enum eRigidBody_MeshSource {
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 8fb66dc4bd7..24becac20bf 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -661,19 +661,15 @@ typedef struct RenderData {
*/
int mode;
+ short frs_sec;
+
/**
* What to do with the sky/background.
* Picks sky/premul blending for the background.
*/
- short alphamode;
+ char alphamode;
- /**
- * The number of samples to use per pixel.
- */
- short osa;
-
- short frs_sec;
- char _pad[6];
+ char _pad0[1];
/* safety, border and display rect */
rctf safety, border;
@@ -803,11 +799,6 @@ typedef struct RenderProfile {
#define UV_SCULPT_LOCK_BORDERS 1
#define UV_SCULPT_ALL_ISLANDS 2
-/* ToolSettings.uv_sculpt_tool */
-#define UV_SCULPT_TOOL_PINCH 1
-#define UV_SCULPT_TOOL_RELAX 2
-#define UV_SCULPT_TOOL_GRAB 3
-
/* ToolSettings.uv_relax_method */
#define UV_SCULPT_TOOL_RELAX_LAPLACIAN 1
#define UV_SCULPT_TOOL_RELAX_HC 2
@@ -965,11 +956,11 @@ typedef struct Sculpt {
Paint paint;
/* For rotating around a pivot point */
- //float pivot[3]; XXX not used?
+ // float pivot[3]; XXX not used?
int flags;
/* Control tablet input */
- //char tablet_size, tablet_strength; XXX not used?
+ // char tablet_size, tablet_strength; XXX not used?
int radial_symm[3];
/* Maximum edge length for dynamic topology sculpting (in pixels) */
@@ -1467,7 +1458,7 @@ typedef struct ToolSettings {
char snap_target;
char snap_transform_mode_flag;
- char proportional, prop_mode;
+ char proportional_edit, prop_mode;
/** Proportional edit, object mode. */
char proportional_objects;
/** Proportional edit, mask editing. */
@@ -1479,7 +1470,7 @@ typedef struct ToolSettings {
/** Lock marker editing. */
char lock_markers;
- /**aUto normalizing mode in wpain.t*/
+ /** Auto normalizing mode in wpaint. */
char auto_normalize;
/** Paint multiple bones in wpaint. */
char multipaint;
@@ -1488,10 +1479,8 @@ typedef struct ToolSettings {
char vgroupsubset;
/* UV painting */
- char _pad2[1];
- char use_uv_sculpt;
+ char _pad2[3];
char uv_sculpt_settings;
- char uv_sculpt_tool;
char uv_relax_method;
/* XXX: these sculpt_paint_* fields are deprecated, use the
* unified_paint_settings field instead! */
@@ -1573,6 +1562,11 @@ typedef struct SceneDisplay {
float matcap_ssao_attenuation;
int matcap_ssao_samples;
+ /** Method of AA for viewport rendering and image rendering */
+ char viewport_aa;
+ char render_aa;
+ char _pad[6];
+
/** OpenGL render engine settings. */
View3DShading shading;
} SceneDisplay;
@@ -1713,7 +1707,7 @@ typedef struct TransformOrientationSlot {
char _pad0[7];
} TransformOrientationSlot;
-/* Indices when used in Scene.orientation. */
+/** Indices when used in #Scene.orientation_slots */
enum {
SCE_ORIENT_DEFAULT = 0,
SCE_ORIENT_TRANSLATE = 1,
@@ -1796,7 +1790,7 @@ typedef struct Scene {
/* Units */
struct UnitSettings unit;
- /* Grease Pencil - Annotations */
+ /** Grease Pencil - Annotations */
struct bGPdata *gpd;
/* Movie Tracking */
@@ -1840,15 +1834,15 @@ typedef struct Scene {
/* **************** RENDERDATA ********************* */
-/* RenderData.flag */
+/** #RenderData.flag */
/* use preview range */
#define SCER_PRV_RANGE (1 << 0)
#define SCER_LOCK_FRAME_SELECTION (1 << 1)
/* show/use subframes (for checking motion blur) */
#define SCER_SHOW_SUBFRAME (1 << 3)
-/* RenderData.mode */
-#define R_OSA (1 << 0)
+/** #RenderData.mode */
+#define R_MODE_UNUSED_0 (1 << 0) /* dirty */
#define R_MODE_UNUSED_1 (1 << 1) /* cleared */
#define R_MODE_UNUSED_2 (1 << 2) /* cleared */
#define R_MODE_UNUSED_3 (1 << 3) /* cleared */
@@ -1880,23 +1874,24 @@ typedef struct Scene {
#define R_PERSISTENT_DATA (1 << 26) /* keep data around for re-render */
#define R_MODE_UNUSED_27 (1 << 27) /* cleared */
-/* RenderData.seq_flag */
+/** #RenderData.seq_flag */
enum {
R_SEQ_UNUSED_0 = (1 << 0), /* cleared */
R_SEQ_UNUSED_1 = (1 << 1), /* cleared */
R_SEQ_UNUSED_2 = (1 << 2), /* cleared */
- R_SEQ_SOLID_TEX = (1 << 3),
- R_SEQ_CAMERA_DOF = (1 << 4),
+ R_SEQ_UNUSED_3 = (1 << 3), /* cleared */
+ R_SEQ_UNUSED_4 = (1 << 4), /* cleared */
+ R_SEQ_OVERRIDE_SCENE_SETTINGS = (1 << 5),
};
-/* RenderData.displaymode */
+/** #RenderData.displaymode */
#define R_OUTPUT_SCREEN 0
#define R_OUTPUT_AREA 1
#define R_OUTPUT_WINDOW 2
#define R_OUTPUT_NONE 3
/*#define R_OUTPUT_FORKED 4*/
-/* RenderData.filtertype (used for nodes) */
+/** #RenderData.filtertype (used for nodes) */
#define R_FILTER_BOX 0
#define R_FILTER_TENT 1
#define R_FILTER_QUAD 2
@@ -1906,7 +1901,7 @@ enum {
#define R_FILTER_MITCH 6
#define R_FILTER_FAST_GAUSS 7
-/* RenderData.scemode */
+/** #RenderData.scemode */
#define R_DOSEQ (1 << 0)
#define R_BG_RENDER (1 << 1)
/* passepartout is camera option now, keep this for backward compatibility */
@@ -1931,7 +1926,7 @@ enum {
#define R_EXR_CACHE_FILE (1 << 20)
#define R_MULTIVIEW (1 << 21)
-/* RenderData.stamp */
+/** #RenderData.stamp */
#define R_STAMP_TIME (1 << 0)
#define R_STAMP_FRAME (1 << 1)
#define R_STAMP_DATE (1 << 2)
@@ -1956,10 +1951,12 @@ enum {
R_STAMP_HOSTNAME)
/** #RenderData.alphamode */
-#define R_ADDSKY 0
-#define R_ALPHAPREMUL 1
+enum {
+ R_ADDSKY = 0,
+ R_ALPHAPREMUL = 1,
+};
-/* RenderData.color_mgt_flag */
+/** #RenderData.color_mgt_flag */
enum {
/** deprecated, should only be used in versioning code only */
R_COLOR_MANAGEMENT = (1 << 0),
@@ -2147,11 +2144,12 @@ enum {
#define PROP_INVSQUARE 7
#define PROP_MODE_MAX 8
-/* ToolSettings.proportional */
-#define PROP_EDIT_OFF 0
-#define PROP_EDIT_ON 1
-#define PROP_EDIT_CONNECTED 2
-#define PROP_EDIT_PROJECTED 3
+/** #ToolSettings.proportional_edit & similarly named members. */
+enum {
+ PROP_EDIT_USE = (1 << 0),
+ PROP_EDIT_CONNECTED = (1 << 1),
+ PROP_EDIT_PROJECTED = (1 << 2),
+};
/* ToolSettings.weightuser */
enum {
@@ -2471,6 +2469,17 @@ enum {
SHADOW_METHOD_MAX = 3,
};
+/* SceneDisplay->render_aa, SceneDisplay->viewport_aa */
+enum {
+ SCE_DISPLAY_AA_OFF = 0,
+ SCE_DISPLAY_AA_FXAA = 1,
+ SCE_DISPLAY_AA_SAMPLES_5 = 5,
+ SCE_DISPLAY_AA_SAMPLES_8 = 8,
+ SCE_DISPLAY_AA_SAMPLES_11 = 11,
+ SCE_DISPLAY_AA_SAMPLES_16 = 16,
+ SCE_DISPLAY_AA_SAMPLES_32 = 32,
+};
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 411777333a9..e014de183e3 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -599,31 +599,39 @@ enum {
/* Region supports panel tabs (categories). */
#define RGN_TYPE_HAS_CATEGORY_MASK (1 << RGN_TYPE_UI)
-/* region alignment */
-#define RGN_ALIGN_NONE 0
-#define RGN_ALIGN_TOP 1
-#define RGN_ALIGN_BOTTOM 2
-#define RGN_ALIGN_LEFT 3
-#define RGN_ALIGN_RIGHT 4
-#define RGN_ALIGN_HSPLIT 5
-#define RGN_ALIGN_VSPLIT 6
-#define RGN_ALIGN_FLOAT 7
-#define RGN_ALIGN_QSPLIT 8
-#define RGN_ALIGN_ENUM_MASK 0x0F
-
-#define RGN_SPLIT_PREV 32
+/** #ARegion.alignment */
+enum {
+ RGN_ALIGN_NONE = 0,
+ RGN_ALIGN_TOP = 1,
+ RGN_ALIGN_BOTTOM = 2,
+ RGN_ALIGN_LEFT = 3,
+ RGN_ALIGN_RIGHT = 4,
+ RGN_ALIGN_HSPLIT = 5,
+ RGN_ALIGN_VSPLIT = 6,
+ RGN_ALIGN_FLOAT = 7,
+ RGN_ALIGN_QSPLIT = 8,
+ /* Maximum 15. */
+
+ /* Flags start here. */
+ RGN_SPLIT_PREV = 32,
+};
+
+/** Mask out flags so we can check the alignment. */
+#define RGN_ALIGN_ENUM_FROM_MASK(align) ((align) & ((1 << 4) - 1))
/** #ARegion.flag */
enum {
RGN_FLAG_HIDDEN = (1 << 0),
RGN_FLAG_TOO_SMALL = (1 << 1),
- /* Force delayed reinit of region size data, so that region size is calculated
+ /**
+ * Force delayed reinit of region size data, so that region size is calculated
* just big enough to show all its content (if enough space is available).
- * Note that only ED_region_header supports this right now. */
+ * Note that only ED_region_header supports this right now.
+ */
RGN_FLAG_DYNAMIC_SIZE = (1 << 2),
- /* Region data is NULL'd on read, never written. */
+ /** Region data is NULL'd on read, never written. */
RGN_FLAG_TEMP_REGIONDATA = (1 << 3),
- /* The region must either use its prefsizex/y or be hidden. */
+ /** The region must either use its prefsizex/y or be hidden. */
RGN_FLAG_PREFSIZE_OR_HIDDEN = (1 << 4),
/** Size has been clamped (floating regions only). */
RGN_FLAG_SIZE_CLAMP_X = (1 << 5),
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index ba3dee405ad..5240de4aff9 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -134,7 +134,7 @@ typedef struct Sequence {
/** SEQ_NAME_MAXSTR - name, set by default and needs to be unique, for RNA paths. */
char name[64];
- /**fLags bitmap (see below) and the type of sequenc.e*/
+ /** Flags bitmap (see below) and the type of sequence. */
int flag, type;
/** The length of the contents of this strip - before handles are applied. */
int len;
@@ -155,7 +155,7 @@ typedef struct Sequence {
int startstill, endstill;
/** Machine: the strip channel, depth the depth in the sequence when dealing with metastrips. */
int machine, depth;
- /** Starting and ending points of the strip in the sequenc.e*/
+ /** Starting and ending points of the strip in the sequence. */
int startdisp, enddisp;
float sat;
float mul, handsize;
@@ -229,6 +229,12 @@ typedef struct Sequence {
/* modifiers */
ListBase modifiers;
+
+ int cache_flag;
+ int _pad2[3];
+
+ struct Sequence *orig_sequence;
+ void *_pad3;
} Sequence;
typedef struct MetaStack {
@@ -258,6 +264,12 @@ typedef struct Editing {
int over_ofs, over_cfra;
int over_flag, proxy_storage;
rctf over_border;
+
+ struct SeqCache *cache;
+
+ /* Cache control */
+ float recycle_max_cost;
+ int cache_flag;
} Editing;
/* ************* Effect Variable Structs ********* */
@@ -635,4 +647,33 @@ enum {
SEQUENCE_MASK_TIME_ABSOLUTE = 1,
};
+/* Sequence->cache_flag
+ * SEQ_CACHE_STORE_RAW
+ * SEQ_CACHE_STORE_PREPROCESSED
+ * SEQ_CACHE_STORE_COMPOSITE
+ * FINAL_OUT is ignored
+ *
+ * Editing->cache_flag
+ * all entries
+ */
+enum {
+ SEQ_CACHE_STORE_RAW = (1 << 0),
+ SEQ_CACHE_STORE_PREPROCESSED = (1 << 1),
+ SEQ_CACHE_STORE_COMPOSITE = (1 << 2),
+ SEQ_CACHE_STORE_FINAL_OUT = (1 << 3),
+
+ /* For lookup purposes */
+ SEQ_CACHE_ALL_TYPES = SEQ_CACHE_STORE_RAW | SEQ_CACHE_STORE_PREPROCESSED |
+ SEQ_CACHE_STORE_COMPOSITE | SEQ_CACHE_STORE_FINAL_OUT,
+
+ SEQ_CACHE_OVERRIDE = (1 << 4),
+
+ /* enable cache visualization overlay in timeline UI */
+ SEQ_CACHE_VIEW_ENABLE = (1 << 5),
+ SEQ_CACHE_VIEW_RAW = (1 << 6),
+ SEQ_CACHE_VIEW_PREPROCESSED = (1 << 7),
+ SEQ_CACHE_VIEW_COMPOSITE = (1 << 8),
+ SEQ_CACHE_VIEW_FINAL_OUT = (1 << 9),
+};
+
#endif /* __DNA_SEQUENCE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index 641a1fbf8e3..d795800df2f 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -276,13 +276,13 @@ typedef struct SmokeDomainSettings {
/* flags */
enum {
- /**old style emission*/
+ /** Old style emission. */
MOD_SMOKE_FLOW_ABSOLUTE = (1 << 1),
- /** passes particles speed to the smoke */
+ /** Passes particles speed to the smoke. */
MOD_SMOKE_FLOW_INITVELOCITY = (1 << 2),
- /** use texture to control emission speed */
+ /** Use texture to control emission speed. */
MOD_SMOKE_FLOW_TEXTUREEMIT = (1 << 3),
- /** use specific size for particles instead of closest cell */
+ /** Use specific size for particles instead of closest cell. */
MOD_SMOKE_FLOW_USE_PART_SIZE = (1 << 4),
};
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 6923619ef91..e3773e8b670 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -300,12 +300,12 @@ typedef struct ThemeSpace {
char keytype_keyframe_select[4], keytype_extreme_select[4], keytype_breakdown_select[4],
keytype_jitter_select[4], keytype_movehold_select[4];
char keyborder[4], keyborder_select[4];
- char _pad4[4];
+ char _pad4[3];
char console_output[4], console_input[4], console_info[4], console_error[4];
char console_cursor[4], console_select[4];
- char vertex_size, outline_width, facedot_size;
+ char vertex_size, outline_width, obcenter_dia, facedot_size;
char noodle_curving;
/* syntax for textwindow and nodes */
@@ -643,15 +643,14 @@ typedef struct UserDef {
char _pad3[4];
short gizmo_flag, gizmo_size;
short edit_studio_light;
- char _pad6[2];
+ short lookdev_ball_size;
short vbotimeout, vbocollectrate;
short textimeout, texcollectrate;
int memcachelimit;
int prefetchframes;
/** Control the rotation step of the view when PAD2, PAD4, PAD6&PAD8 is use. */
float pad_rot_angle;
- char _pad12[2];
- short obcenter_dia;
+ char _pad12[4];
/** Rotating view icon size. */
short rvisize;
/** Rotating view icon brightness. */
@@ -993,6 +992,8 @@ typedef enum eDupli_ID_Flags {
USER_DUP_ARM = (1 << 9),
USER_DUP_ACT = (1 << 10),
USER_DUP_PSYS = (1 << 11),
+ USER_DUP_LIGHTPROBE = (1 << 12),
+ USER_DUP_GPENCIL = (1 << 13),
} eDupli_ID_Flags;
/** Max anti alias draw method
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 0667ab3aee0..d5ac8cc197b 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -581,6 +581,14 @@ enum {
V3D_GIZMO_SHOW_CAMERA_DOF_DIST = (1 << 2),
};
+/** Settings for offscreen rendering */
+enum {
+ V3D_OFSDRAW_NONE = (0),
+ V3D_OFSDRAW_USE_FULL_SAMPLE = (1 << 0),
+ V3D_OFSDRAW_SHOW_ANNOTATION = (1 << 1),
+ V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS = (1 << 2),
+};
+
#define RV3D_CAMZOOM_MIN -30
#define RV3D_CAMZOOM_MAX 600
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index 49c709b972c..2b5d81d02a0 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -25,9 +25,6 @@
#include "DNA_scene_types.h"
-/* Currently testing, allow to disable. */
-#define USE_WORKSPACE_TOOL
-
#
#
typedef struct bToolRef_Runtime {
@@ -114,28 +111,20 @@ typedef struct WorkSpace {
/** #wmOwnerID. */
ListBase owner_ids;
- /* should be: '#ifdef USE_WORKSPACE_TOOL'. */
-
/** List of #bToolRef */
ListBase tools;
- /**
- * BAD DESIGN WARNING:
- * This is a workaround for the topbar not knowing which tools spec. */
- char tools_space_type;
- /** Type is different for each space-type. */
- char tools_mode;
- char _pad[2];
+ char _pad[4];
int object_mode;
/** Enum eWorkSpaceFlags. */
int flags;
- /* Number for workspace tab reordering in the UI. */
+ /** Number for workspace tab reordering in the UI. */
int order;
- /* Info text from modal operators (runtime). */
+ /** Info text from modal operators (runtime). */
char *status_text;
} WorkSpace;
@@ -165,10 +154,10 @@ typedef struct WorkSpace {
typedef struct WorkSpaceDataRelation {
struct WorkSpaceDataRelation *next, *prev;
- /* the data used to identify the relation
- * (e.g. to find screen-layout (= value) from/for a hook) */
+ /** The data used to identify the relation
+ * (e.g. to find screen-layout (= value) from/for a hook). */
void *parent;
- /* The value for this parent-data/workspace relation */
+ /** The value for this parent-data/workspace relation. */
void *value;
} WorkSpaceDataRelation;
@@ -180,7 +169,7 @@ typedef struct WorkSpaceInstanceHook {
WorkSpace *active;
struct WorkSpaceLayout *act_layout;
- /* Needed because we can't change workspaces/layouts in running handler loop,
+ /** Needed because we can't change workspaces/layouts in running handler loop,
* it would break context. */
WorkSpace *temp_workspace_store;
struct WorkSpaceLayout *temp_layout_store;
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt
index a5a98386347..178ef219c4d 100644
--- a/source/blender/makesdna/intern/CMakeLists.txt
+++ b/source/blender/makesdna/intern/CMakeLists.txt
@@ -23,8 +23,8 @@
add_definitions(-DWITH_DNA_GHASH)
blender_include_dirs(
- ../../../../intern/guardedalloc
../../../../intern/atomic
+ ../../../../intern/guardedalloc
../../blenlib
..
)
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 463d612094e..119186ff748 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -44,7 +44,6 @@ extern const EnumPropertyItem rna_enum_metaelem_type_items[];
extern const EnumPropertyItem rna_enum_proportional_falloff_items[];
extern const EnumPropertyItem rna_enum_proportional_falloff_curve_only_items[];
-extern const EnumPropertyItem rna_enum_proportional_editing_items[];
extern const EnumPropertyItem rna_enum_snap_target_items[];
extern const EnumPropertyItem rna_enum_snap_element_items[];
extern const EnumPropertyItem rna_enum_snap_node_element_items[];
@@ -115,6 +114,7 @@ extern const EnumPropertyItem rna_enum_operator_return_items[];
extern const EnumPropertyItem rna_enum_operator_property_tags[];
extern const EnumPropertyItem rna_enum_brush_sculpt_tool_items[];
+extern const EnumPropertyItem rna_enum_brush_uv_sculpt_tool_items[];
extern const EnumPropertyItem rna_enum_brush_vertex_tool_items[];
extern const EnumPropertyItem rna_enum_brush_weight_tool_items[];
extern const EnumPropertyItem rna_enum_brush_gpencil_types_items[];
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index ee5bb980bea..3953a948b09 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -321,13 +321,13 @@ blender_include_dirs(
../../blenfont
../../blenkernel
../../blenlib
- ../../bmesh
../../blentranslation
+ ../../bmesh
../../depsgraph
../../draw
../../gpu
- ../../imbuf
../../ikplugin
+ ../../imbuf
../../makesdna
../../nodes/
../../physics
@@ -335,9 +335,9 @@ blender_include_dirs(
../../editors/include
../../render/extern/include
../../../../intern/cycles/blender
- ../../../../intern/guardedalloc
- ../../../../intern/glew-mx
../../../../intern/atomic
+ ../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
../../../../intern/memutil
../../../../intern/smoke/extern
)
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 54530c1b2c9..0122587920c 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -2731,7 +2731,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
else if (cptr || (flag & PROP_DYNAMIC)) {
ptrstr = pout ? "**" : "*";
/* Fixed size arrays and RNA pointers are pre-allocated on the ParameterList stack,
- * pass a pointer to it. */
+ * pass a pointer to it. */
}
else if (type == PROP_POINTER || dparm->prop->arraydimension) {
ptrstr = "*";
@@ -2740,7 +2740,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
!(flag & PROP_THICK_WRAP)) {
ptrstr = "*";
/* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack,
- * but type name for string props is already (char *), so leave empty */
+ * but type name for string props is already (char *), so leave empty */
}
else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
ptrstr = "";
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index c893fb86851..d5dfd0b5503 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -844,7 +844,7 @@ bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
{
if (identifier[0] == '[' && identifier[1] == '"') { /* " (dummy comment to avoid confusing some
- * function lists in text editors) */
+ * function lists in text editors) */
/* id prop lookup, not so common */
PropertyRNA *r_prop = NULL;
PointerRNA r_ptr; /* only support single level props */
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 27a9333cd9e..15429ec6b5e 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -600,7 +600,7 @@ static FCurve *rna_Driver_from_existing(AnimData *adt, bContext *C, FCurve *src_
}
static FCurve *rna_Driver_new(
- ID *id, AnimData *adt, ReportList *reports, const char *rna_path, int array_index)
+ ID *id, AnimData *adt, Main *bmain, ReportList *reports, const char *rna_path, int array_index)
{
if (rna_path[0] == '\0') {
BKE_report(reports, RPT_ERROR, "F-Curve data path empty, invalid argument");
@@ -615,16 +615,20 @@ static FCurve *rna_Driver_new(
short add_mode = 1;
FCurve *fcu = verify_driver_fcurve(id, rna_path, array_index, add_mode);
BLI_assert(fcu != NULL);
+
+ DEG_relations_tag_update(bmain);
+
return fcu;
}
-static void rna_Driver_remove(AnimData *adt, ReportList *reports, FCurve *fcu)
+static void rna_Driver_remove(AnimData *adt, Main *bmain, ReportList *reports, FCurve *fcu)
{
if (!BLI_remlink_safe(&adt->drivers, fcu)) {
BKE_report(reports, RPT_ERROR, "Driver not found in this animation data");
return;
}
free_fcurve(fcu);
+ DEG_relations_tag_update(bmain);
}
static FCurve *rna_Driver_find(AnimData *adt,
@@ -1129,7 +1133,7 @@ static void rna_api_animdata_drivers(BlenderRNA *brna, PropertyRNA *cprop)
/* AnimData.drivers.new(...) */
func = RNA_def_function(srna, "new", "rna_Driver_new");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS | FUNC_USE_MAIN);
parm = RNA_def_string(func, "data_path", NULL, 0, "Data Path", "F-Curve data path to use");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Array index", 0, INT_MAX);
@@ -1139,7 +1143,7 @@ static void rna_api_animdata_drivers(BlenderRNA *brna, PropertyRNA *cprop)
/* AnimData.drivers.remove(...) */
func = RNA_def_function(srna, "remove", "rna_Driver_remove");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_MAIN);
parm = RNA_def_pointer(func, "driver", "FCurve", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 6c31d256cb7..5461aaa0f1a 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -1143,7 +1143,7 @@ static void rna_def_edit_bone(BlenderRNA *brna)
prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
/*RNA_def_property_float_sdna(prop, NULL, ""); */ /* doesn't access any real data */
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
- //RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_THICK_WRAP); /* no reference to original data */
RNA_def_property_ui_text(
prop,
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index d5c9dfb8d02..40c3a75df85 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -94,6 +94,13 @@ const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = {
{0, NULL, 0, NULL, NULL},
};
+const EnumPropertyItem rna_enum_brush_uv_sculpt_tool_items[] = {
+ {UV_SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", "Grab UVs"},
+ {UV_SCULPT_TOOL_RELAX, "RELAX", 0, "Relax", "Relax UVs"},
+ {UV_SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", "Pinch UVs"},
+ {0, NULL, 0, NULL, NULL},
+};
+
const EnumPropertyItem rna_enum_brush_vertex_tool_items[] = {
{VPAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_MIX, "Draw", ""},
{VPAINT_TOOL_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", ""},
@@ -1575,6 +1582,11 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Sculpt Tool", "");
RNA_def_property_update(prop, 0, "rna_Brush_update_and_reset_icon");
+ prop = RNA_def_property(srna, "uv_sculpt_tool", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, rna_enum_brush_uv_sculpt_tool_items);
+ RNA_def_property_ui_text(prop, "Sculpt Tool", "");
+ RNA_def_property_update(prop, 0, "rna_Brush_update_and_reset_icon");
+
prop = RNA_def_property(srna, "vertex_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "vertexpaint_tool");
RNA_def_property_enum_items(prop, rna_enum_brush_vertex_tool_items);
@@ -2105,6 +2117,10 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_SCULPT);
RNA_def_property_ui_text(prop, "Use Sculpt", "Use this brush in sculpt mode");
+ prop = RNA_def_property(srna, "use_paint_uv_sculpt", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_EDIT);
+ RNA_def_property_ui_text(prop, "Use UV Sculpt", "Use this brush in UV sculpt mode");
+
prop = RNA_def_property(srna, "use_paint_vertex", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_VERTEX_PAINT);
RNA_def_property_ui_text(prop, "Use Vertex", "Use this brush in vertex paint mode");
diff --git a/source/blender/makesrna/intern/rna_cachefile.c b/source/blender/makesrna/intern/rna_cachefile.c
index fb61be69ee6..189a4a7de86 100644
--- a/source/blender/makesrna/intern/rna_cachefile.c
+++ b/source/blender/makesrna/intern/rna_cachefile.c
@@ -45,29 +45,12 @@
# include "../../../alembic/ABC_alembic.h"
# endif
-static void rna_CacheFile_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_CacheFile_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
CacheFile *cache_file = (CacheFile *)ptr->data;
- DEG_id_tag_update(&cache_file->id, 0);
+ DEG_id_tag_update(&cache_file->id, ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
-
- UNUSED_VARS(bmain, scene);
-}
-
-static void rna_CacheFile_update_handle(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- CacheFile *cache_file = ptr->data;
-
- if ((cache_file->flag & CACHEFILE_DIRTY) != 0) {
- BKE_cachefile_clean(bmain, cache_file);
- BLI_freelistN(&cache_file->object_paths);
- cache_file->flag &= ~CACHEFILE_DIRTY;
- }
-
- BKE_cachefile_reload(bmain, cache_file);
-
- rna_CacheFile_update(bmain, scene, ptr);
}
static void rna_CacheFile_object_paths_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@@ -76,20 +59,6 @@ static void rna_CacheFile_object_paths_begin(CollectionPropertyIterator *iter, P
rna_iterator_listbase_begin(iter, &cache_file->object_paths, NULL);
}
-static void rna_CacheFile_filename_set(PointerRNA *ptr, const char *value)
-{
- CacheFile *cache_file = ptr->data;
-
- if (STREQ(cache_file->filepath, value)) {
- return;
- }
-
- /* Different file is opened, close all readers. */
- cache_file->flag |= CACHEFILE_DIRTY;
-
- BLI_strncpy(cache_file->filepath, value, sizeof(cache_file->filepath));
-}
-
#else
/* cachefile.object_paths */
@@ -122,9 +91,8 @@ static void rna_def_cachefile(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_FILE);
PropertyRNA *prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_CacheFile_filename_set");
RNA_def_property_ui_text(prop, "File Path", "Path to external displacements file");
- RNA_def_property_update(prop, 0, "rna_CacheFile_update_handle");
+ RNA_def_property_update(prop, 0, "rna_CacheFile_update");
prop = RNA_def_property(srna, "is_sequence", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(
diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c
index ddea98a135a..1f356624f3f 100644
--- a/source/blender/makesrna/intern/rna_camera.c
+++ b/source/blender/makesrna/intern/rna_camera.c
@@ -124,11 +124,10 @@ static void rna_Camera_background_images_clear(Camera *cam)
WM_main_add_notifier(NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, cam);
}
-static void rna_Camera_dof_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
+static void rna_Camera_dof_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
{
/* TODO(sergey): Can be more selective here. */
- BKE_sequencer_cache_cleanup();
- BKE_sequencer_preprocessed_cache_cleanup();
+ BKE_sequencer_cache_cleanup_all(bmain);
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
}
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 934847fed50..40ee069657c 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -577,10 +577,6 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain,
BKE_movieclip_reload(bmain, clip);
- /* all sequencers for now, we don't know which scenes are using this clip as a strip */
- BKE_sequencer_cache_cleanup();
- BKE_sequencer_preprocessed_cache_cleanup();
-
WM_main_add_notifier(NC_MOVIECLIP | ND_DISPLAY, &clip->id);
WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, &clip->id);
}
@@ -612,21 +608,19 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain,
}
BKE_sequence_invalidate_cache(scene, seq);
- BKE_sequencer_preprocessed_cache_cleanup_sequence(seq);
}
else {
SEQ_BEGIN (scene->ed, seq) {
BKE_sequence_free_anim(seq);
}
SEQ_END;
-
- BKE_sequencer_cache_cleanup();
- BKE_sequencer_preprocessed_cache_cleanup();
}
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
}
}
+
+ BKE_sequencer_cache_cleanup_all(bmain);
}
static char *rna_ColorManagedSequencerColorspaceSettings_path(PointerRNA *UNUSED(ptr))
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index 44445181402..c1c235d497b 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -729,22 +729,6 @@ static void rna_Constraint_objectSolver_camera_set(PointerRNA *ptr, PointerRNA v
}
}
-static void rna_Constraint_transformCache_object_path_update(Main *bmain,
- Scene *scene,
- PointerRNA *ptr)
-{
-# ifdef WITH_ALEMBIC
- bConstraint *con = (bConstraint *)ptr->data;
- bTransformCacheConstraint *data = (bTransformCacheConstraint *)con->data;
- Object *ob = (Object *)ptr->id.data;
-
- data->reader = CacheReader_open_alembic_object(
- data->cache_file->handle, data->reader, ob, data->object_path);
-# endif
-
- rna_Constraint_update(bmain, scene, ptr);
-}
-
#else
static const EnumPropertyItem constraint_distance_items[] = {
@@ -2902,7 +2886,7 @@ static void rna_def_constraint_transform_cache(BlenderRNA *brna)
prop,
"Object Path",
"Path to the object in the Alembic archive used to lookup the transform matrix");
- RNA_def_property_update(prop, 0, "rna_Constraint_transformCache_object_path_update");
+ RNA_def_property_update(prop, 0, "rna_Constraint_update");
}
/* base struct for constraints */
diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c
index 215c513c003..92e63b1c778 100644
--- a/source/blender/makesrna/intern/rna_dynamicpaint.c
+++ b/source/blender/makesrna/intern/rna_dynamicpaint.c
@@ -117,20 +117,6 @@ static void rna_DynamicPaintSurface_initialcolortype(Main *bmain, Scene *scene,
rna_DynamicPaint_redoModifier(bmain, scene, ptr);
}
-static void rna_DynamicPaintSurface_changePreview(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- DynamicPaintSurface *act_surface = (DynamicPaintSurface *)ptr->data;
- DynamicPaintSurface *surface = act_surface->canvas->surfaces.first;
-
- /* since only one color surface can show preview at time
- * disable preview on other surfaces. */
- for (; surface; surface = surface->next) {
- if (surface != act_surface)
- surface->flags &= ~MOD_DPAINT_PREVIEW;
- }
- rna_DynamicPaint_redoModifier(bmain, scene, ptr);
-}
-
static void rna_DynamicPaintSurface_uniqueName(Main *UNUSED(bmain),
Scene *UNUSED(scene),
PointerRNA *ptr)
@@ -239,14 +225,6 @@ static bool rna_DynamicPaint_is_cache_user_get(PointerRNA *ptr)
return (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ) ? 1 : 0;
}
-/* is some 3D view preview available */
-static bool rna_DynamicPaint_use_color_preview_get(PointerRNA *ptr)
-{
- DynamicPaintSurface *surface = (DynamicPaintSurface *)ptr->data;
-
- return dynamicPaint_surfaceHasColorPreview(surface);
-}
-
/* does output layer exist*/
static bool rna_DynamicPaint_is_output_exists(DynamicPaintSurface *surface, Object *ob, int index)
{
@@ -354,13 +332,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
- /* Surface output preview. currently only paint has multiple outputs */
- static const EnumPropertyItem prop_dynamicpaint_surface_preview[] = {
- {MOD_DPAINT_SURFACE_PREV_PAINT, "PAINT", 0, "Paint", ""},
- {MOD_DPAINT_SURFACE_PREV_WETMAP, "WETMAP", 0, "Wetmap", ""},
- {0, NULL, 0, NULL, NULL},
- };
-
/* Initial color setting */
static const EnumPropertyItem prop_dynamicpaint_init_color_type[] = {
{MOD_DPAINT_INITIAL_NONE, "NONE", 0, "None", ""},
@@ -421,11 +392,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Is Active", "Toggle whether surface is processed or ignored");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
- prop = RNA_def_property(srna, "show_preview", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_PREVIEW);
- RNA_def_property_ui_text(prop, "Show Preview", "Display surface preview in 3D-views");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurface_changePreview");
-
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "Surface name");
RNA_def_property_update(prop, NC_OBJECT, "rna_DynamicPaintSurface_uniqueName");
@@ -667,13 +633,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_OUT2);
RNA_def_property_ui_text(prop, "Use Output", "Save this output layer");
- prop = RNA_def_property(srna, "preview_id", PROP_ENUM, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_enum_sdna(prop, NULL, "preview_id");
- RNA_def_property_enum_items(prop, prop_dynamicpaint_surface_preview);
- RNA_def_property_ui_text(prop, "Preview", "");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
/* to check if output name exists */
func = RNA_def_function(srna, "output_exists", "rna_DynamicPaint_is_output_exists");
RNA_def_function_ui_description(func, "Checks if surface output layer of given name exists");
@@ -767,15 +726,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, "rna_DynamicPaint_is_cache_user_get", NULL);
RNA_def_property_ui_text(prop, "Use Cache", "");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
-
- /* whether this surface has preview data for 3D view */
- RNA_define_verify_sdna(false);
- prop = RNA_def_property(srna, "use_color_preview", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_DynamicPaint_use_color_preview_get", NULL);
- RNA_def_property_ui_text(
- prop, "Use Color Preview", "Whether this surface has some color preview for 3D view");
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_define_verify_sdna(true);
}
static void rna_def_dynamic_paint_canvas_settings(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index f87bb69a94f..737dbe36d17 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1819,6 +1819,11 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Surface Offset", "Offset amount when drawing in surface mode");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ prop = RNA_def_property(srna, "is_annotation", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_ANNOTATIONS);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Annotation", "Current datablock is an annotation");
+
/* Nested Structs */
prop = RNA_def_property(srna, "grid", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 6ac36ef097e..b21cd3324b8 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -273,6 +273,15 @@ static void rna_Main_materials_gpencil_data(Main *UNUSED(bmain), PointerRNA *id_
BKE_material_init_gpencil_settings(ma);
}
+static void rna_Main_materials_gpencil_remove(Main *UNUSED(bmain), PointerRNA *id_ptr)
+{
+ ID *id = id_ptr->data;
+ Material *ma = (Material *)id;
+ if (ma->gp_style) {
+ MEM_SAFE_FREE(ma->gp_style);
+ }
+}
+
static const EnumPropertyItem *rna_Main_nodetree_type_itemf(bContext *UNUSED(C),
PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
@@ -667,7 +676,7 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(textures, textures, ID_TE)
RNA_MAIN_ID_TAG_FUNCS_DEF(brushes, brushes, ID_BR)
RNA_MAIN_ID_TAG_FUNCS_DEF(worlds, worlds, ID_WO)
RNA_MAIN_ID_TAG_FUNCS_DEF(collections, collections, ID_GR)
-//RNA_MAIN_ID_TAG_FUNCS_DEF(shape_keys, key, ID_KE)
+// RNA_MAIN_ID_TAG_FUNCS_DEF(shape_keys, key, ID_KE)
RNA_MAIN_ID_TAG_FUNCS_DEF(texts, texts, ID_TXT)
RNA_MAIN_ID_TAG_FUNCS_DEF(speakers, speakers, ID_SPK)
RNA_MAIN_ID_TAG_FUNCS_DEF(sounds, sounds, ID_SO)
@@ -850,6 +859,11 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop)
parm = RNA_def_pointer(func, "material", "Material", "", "Material");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+ func = RNA_def_function(srna, "remove_gpencil_data", "rna_Main_materials_gpencil_remove");
+ RNA_def_function_ui_description(func, "Remove grease pencil material settings");
+ parm = RNA_def_pointer(func, "material", "Material", "", "Material");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+
func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a material from the current blendfile");
diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c
index c5b2f70366e..8b27c69604e 100644
--- a/source/blender/makesrna/intern/rna_mask.c
+++ b/source/blender/makesrna/intern/rna_mask.c
@@ -632,7 +632,7 @@ static void rna_def_maskParent(BlenderRNA *brna)
RNA_def_property_enum_items(prop, mask_id_type_items);
RNA_def_property_enum_default(prop, ID_MC);
RNA_def_property_enum_funcs(prop, NULL, "rna_MaskParent_id_type_set", NULL);
- //RNA_def_property_editable_func(prop, "rna_MaskParent_id_type_editable");
+ // RNA_def_property_editable_func(prop, "rna_MaskParent_id_type_editable");
RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
RNA_def_property_update(prop, 0, "rna_Mask_update_parent");
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 4fcc6c7d72d..6ab83bc063c 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1302,19 +1302,6 @@ static bool rna_SurfaceDeformModifier_is_bound_get(PointerRNA *ptr)
return (((SurfaceDeformModifierData *)ptr->data)->verts != NULL);
}
-static void rna_MeshSequenceCache_object_path_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
-# ifdef WITH_ALEMBIC
- MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)ptr->data;
- Object *ob = (Object *)ptr->id.data;
-
- mcmd->reader = CacheReader_open_alembic_object(
- mcmd->cache_file->handle, mcmd->reader, ob, mcmd->object_path);
-# endif
-
- rna_Modifier_update(bmain, scene, ptr);
-}
-
static bool rna_ParticleInstanceModifier_particle_system_poll(PointerRNA *ptr,
const PointerRNA value)
{
@@ -2121,13 +2108,15 @@ static void rna_def_modifier_armature(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Use Bone Envelopes", "Bind Bone envelopes to armature modifier");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop = RNA_def_property(srna, "use_vertex_groups", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Use Vertex Groups", "Bind vertex groups to armature modifier");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop = RNA_def_property(srna, "use_deform_preserve_volume", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION);
@@ -5107,7 +5096,7 @@ static void rna_def_modifier_meshseqcache(BlenderRNA *brna)
prop,
"Object Path",
"Path to the object in the Alembic archive used to lookup geometric data");
- RNA_def_property_update(prop, 0, "rna_MeshSequenceCache_object_path_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
static const EnumPropertyItem read_flag_items[] = {
{MOD_MESHSEQ_READ_VERT, "VERT", 0, "Vertex", ""},
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 1ce7b776126..e4270f3854e 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -2597,7 +2597,7 @@ static StructRNA *rna_NodeCustomGroup_register(Main *bmain,
return NULL;
/* this updates the group node instance from the tree's interface */
- nt->verifyfunc = node_group_verify;
+ nt->group_update_func = node_group_update;
nodeRegisterType(nt);
@@ -2621,7 +2621,7 @@ static StructRNA *rna_ShaderNodeCustomGroup_register(Main *bmain,
if (!nt)
return NULL;
- nt->verifyfunc = node_group_verify;
+ nt->group_update_func = node_group_update;
nt->type = NODE_CUSTOM_GROUP;
register_node_type_sh_custom_group(nt);
@@ -2646,7 +2646,7 @@ static StructRNA *rna_CompositorNodeCustomGroup_register(Main *bmain,
if (!nt)
return NULL;
- nt->verifyfunc = node_group_verify;
+ nt->group_update_func = node_group_update;
nt->type = NODE_CUSTOM_GROUP;
register_node_type_cmp_custom_group(nt);
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index aed7b83e34f..219445f629f 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -381,6 +381,12 @@ void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene),
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
}
+void rna_Object_internal_update_data_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ DEG_relations_tag_update(bmain);
+ rna_Object_internal_update_data(bmain, scene, ptr);
+}
+
static void rna_Object_active_shape_update(bContext *C, PointerRNA *ptr)
{
Object *ob = ptr->id.data;
@@ -1539,16 +1545,20 @@ static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
}
}
-static bDeformGroup *rna_Object_vgroup_new(Object *ob, const char *name)
+static bDeformGroup *rna_Object_vgroup_new(Object *ob, Main *bmain, const char *name)
{
bDeformGroup *defgroup = BKE_object_defgroup_add_name(ob, name);
+ DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
return defgroup;
}
-static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA *defgroup_ptr)
+static void rna_Object_vgroup_remove(Object *ob,
+ Main *bmain,
+ ReportList *reports,
+ PointerRNA *defgroup_ptr)
{
bDeformGroup *defgroup = defgroup_ptr->data;
if (BLI_findindex(&ob->defbase, defgroup) == -1) {
@@ -1563,13 +1573,15 @@ static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA
BKE_object_defgroup_remove(ob, defgroup);
RNA_POINTER_INVALIDATE(defgroup_ptr);
+ DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
-static void rna_Object_vgroup_clear(Object *ob)
+static void rna_Object_vgroup_clear(Object *ob, Main *bmain)
{
BKE_object_defgroup_remove_all(ob);
+ DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
@@ -1757,7 +1769,8 @@ static void rna_def_vertex_group(BlenderRNA *brna)
RNA_def_struct_name_property(srna, prop);
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_VertexGroup_name_set");
/* update data because modifiers may use [#24761] */
- RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
+ RNA_def_property_update(
+ prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data_dependency");
prop = RNA_def_property(srna, "lock_weight", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "", "Maintain the relative weights for the group");
@@ -2160,19 +2173,21 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
/* vertex groups */ /* add_vertex_group */
func = RNA_def_function(srna, "new", "rna_Object_vgroup_new");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Add vertex group to object");
RNA_def_string(func, "name", "Group", 0, "", "Vertex group name"); /* optional */
parm = RNA_def_pointer(func, "group", "VertexGroup", "", "New vertex group");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", "rna_Object_vgroup_remove");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Delete vertex group from object");
parm = RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
func = RNA_def_function(srna, "clear", "rna_Object_vgroup_clear");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Delete all vertex groups from object");
}
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 02b700a03c1..5f41bf68572 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -106,12 +106,7 @@ static void rna_Object_select_set(
return;
}
- if (select) {
- BKE_view_layer_base_select(base);
- }
- else {
- base->flag &= ~BASE_SELECTED;
- }
+ ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT);
Scene *scene = CTX_data_scene(C);
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
@@ -438,6 +433,14 @@ static void rna_Object_shape_key_remove(Object *ob,
RNA_POINTER_INVALIDATE(kb_ptr);
}
+static void rna_Object_shape_key_clear(Object *ob, Main *bmain)
+{
+ BKE_object_shapekey_free(bmain, ob);
+
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
+}
+
# if 0
static void rna_Mesh_assign_verts_to_group(
Object *ob, bDeformGroup *group, int *indices, int totindex, float weight, int assignmode)
@@ -926,6 +929,10 @@ void RNA_api_object(StructRNA *srna)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+ func = RNA_def_function(srna, "shape_key_clear", "rna_Object_shape_key_clear");
+ RNA_def_function_ui_description(func, "Remove all Shape Keys from this object");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
+
/* Ray Cast */
func = RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast");
RNA_def_function_ui_description(
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 2363b87d264..5f9e72f74b4 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -107,13 +107,6 @@ static const EnumPropertyItem uv_sculpt_relaxation_items[] = {
};
#endif
-const EnumPropertyItem rna_enum_uv_sculpt_tool_items[] = {
- {UV_SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", "Pinch UVs"},
- {UV_SCULPT_TOOL_RELAX, "RELAX", 0, "Relax", "Relax UVs"},
- {UV_SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", "Grab UVs"},
- {0, NULL, 0, NULL, NULL},
-};
-
const EnumPropertyItem rna_enum_snap_target_items[] = {
{SCE_SNAP_TARGET_CLOSEST, "CLOSEST", 0, "Closest", "Snap closest point onto target"},
{SCE_SNAP_TARGET_CENTER, "CENTER", 0, "Center", "Snap transformation center onto target"},
@@ -149,22 +142,6 @@ const EnumPropertyItem rna_enum_proportional_falloff_curve_only_items[] = {
{0, NULL, 0, NULL, NULL},
};
-const EnumPropertyItem rna_enum_proportional_editing_items[] = {
- {PROP_EDIT_OFF, "DISABLED", ICON_PROP_OFF, "Disable", "Proportional Editing disabled"},
- {PROP_EDIT_ON, "ENABLED", ICON_PROP_ON, "Enable", "Proportional Editing enabled"},
- {PROP_EDIT_PROJECTED,
- "PROJECTED",
- ICON_PROP_PROJECTED,
- "Projected (2D)",
- "Proportional Editing using screen space locations"},
- {PROP_EDIT_CONNECTED,
- "CONNECTED",
- ICON_PROP_CON,
- "Connected",
- "Proportional Editing using connected geometry only"},
- {0, NULL, 0, NULL, NULL},
-};
-
/* keep for operators, not used here */
const EnumPropertyItem rna_enum_mesh_select_mode_items[] = {
{SCE_SELECT_VERTEX, "VERTEX", ICON_VERTEXSEL, "Vertex", "Vertex selection mode"},
@@ -216,6 +193,45 @@ static const EnumPropertyItem snap_uv_element_items[] = {
{SCE_SNAP_MODE_VERTEX, "VERTEX", ICON_SNAP_VERTEX, "Vertex", "Snap to vertices"},
{0, NULL, 0, NULL, NULL},
};
+
+static const EnumPropertyItem rna_enum_scene_display_aa_methods[] = {
+ {SCE_DISPLAY_AA_OFF,
+ "OFF",
+ 0,
+ "No Anti-Aliasing",
+ "Scene will be rendering without any anti-aliasing"},
+ {SCE_DISPLAY_AA_FXAA,
+ "FXAA",
+ 0,
+ "Single Pass Anti-Aliasing",
+ "Scene will be rendered using a single pass anti-aliasing method (FXAA)"},
+ {SCE_DISPLAY_AA_SAMPLES_5,
+ "5",
+ 0,
+ "5 Samples",
+ "Scene will be rendered using 5 anti-aliasing samples"},
+ {SCE_DISPLAY_AA_SAMPLES_8,
+ "8",
+ 0,
+ "8 Samples",
+ "Scene will be rendered using 8 anti-aliasing samples"},
+ {SCE_DISPLAY_AA_SAMPLES_11,
+ "11",
+ 0,
+ "11 Samples",
+ "Scene will be rendered using 11 anti-aliasing samples"},
+ {SCE_DISPLAY_AA_SAMPLES_16,
+ "16",
+ 0,
+ "16 Samples",
+ "Scene will be rendered using 16 anti-aliasing samples"},
+ {SCE_DISPLAY_AA_SAMPLES_32,
+ "32",
+ 0,
+ "32 Samples",
+ "Scene will be rendered using 32 anti-aliasing samples"},
+ {0, NULL, 0, NULL, NULL},
+};
#endif
const EnumPropertyItem rna_enum_curve_fit_method_items[] = {
@@ -725,13 +741,6 @@ static void rna_GPencilInterpolateSettings_type_set(PointerRNA *ptr, int value)
}
}
-static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain,
- Scene *scene,
- PointerRNA *UNUSED(ptr))
-{
- ED_space_image_uv_sculpt_update(bmain, bmain->wm.first, scene);
-}
-
/* Read-only Iterator of all the scene objects. */
static void rna_Scene_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@@ -1989,22 +1998,21 @@ static void rna_Scene_update_active_object_data(bContext *C, PointerRNA *UNUSED(
}
}
-static void rna_SceneCamera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_SceneCamera_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->id.data;
Object *camera = scene->camera;
+ BKE_sequencer_cache_cleanup_all(bmain);
+
if (camera && (camera->type == OB_CAMERA)) {
DEG_id_tag_update(&camera->id, ID_RECALC_GEOMETRY);
}
}
-static void rna_SceneSequencer_update(Main *UNUSED(bmain),
- Scene *UNUSED(scene),
- PointerRNA *UNUSED(ptr))
+static void rna_SceneSequencer_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
{
- BKE_sequencer_cache_cleanup();
- BKE_sequencer_preprocessed_cache_cleanup();
+ BKE_sequencer_cache_cleanup(scene);
}
static char *rna_ToolSettings_path(PointerRNA *UNUSED(ptr))
@@ -2158,11 +2166,10 @@ static void rna_GPUDOFSettings_blades_set(PointerRNA *ptr, const int value)
}
}
-static void rna_GPUDOFSettings_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
+static void rna_GPUDOFSettings_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
{
/* TODO(sergey): Can be more selective here. */
- BKE_sequencer_cache_cleanup();
- BKE_sequencer_preprocessed_cache_cleanup();
+ BKE_sequencer_cache_cleanup_all(bmain);
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
}
@@ -2820,13 +2827,6 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "particle");
RNA_def_property_ui_text(prop, "Particle Edit", "");
- prop = RNA_def_property(srna, "use_uv_sculpt", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "use_uv_sculpt", 1);
- RNA_def_property_ui_text(prop, "UV Sculpt", "Enable brush for UV sculpting");
- RNA_def_property_ui_icon(prop, ICON_TPAINT_HLT, 0);
- RNA_def_property_update(
- prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_uv_sculpt_update");
-
prop = RNA_def_property(srna, "uv_sculpt_lock_borders", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uv_sculpt_settings", UV_SCULPT_LOCK_BORDERS);
RNA_def_property_ui_text(prop, "Lock Borders", "Disable editing of boundary edges");
@@ -2835,11 +2835,6 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "uv_sculpt_settings", UV_SCULPT_ALL_ISLANDS);
RNA_def_property_ui_text(prop, "Sculpt All Islands", "Brush operates on all islands");
- prop = RNA_def_property(srna, "uv_sculpt_tool", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "uv_sculpt_tool");
- RNA_def_property_enum_items(prop, rna_enum_uv_sculpt_tool_items);
- RNA_def_property_ui_text(prop, "UV Sculpt Tools", "Select Tools for the UV sculpt brushes");
-
prop = RNA_def_property(srna, "uv_relax_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "uv_relax_method");
RNA_def_property_enum_items(prop, uv_sculpt_relaxation_items);
@@ -2851,19 +2846,29 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
/* Transform */
- prop = RNA_def_property(srna, "proportional_edit", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "proportional");
- RNA_def_property_enum_items(prop, rna_enum_proportional_editing_items);
- RNA_def_property_ui_text(prop,
- "Proportional Editing",
- "Proportional Editing mode, allows transforms with distance fall-off");
+ prop = RNA_def_property(srna, "use_proportional_edit", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "proportional_edit", PROP_EDIT_USE);
+ RNA_def_property_ui_text(prop, "Proportional Editing", "Proportional edit mode");
+ RNA_def_property_ui_icon(prop, ICON_PROP_ON, 0);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
prop = RNA_def_property(srna, "use_proportional_edit_objects", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "proportional_objects", 0);
RNA_def_property_ui_text(
prop, "Proportional Editing Objects", "Proportional editing object mode");
- RNA_def_property_ui_icon(prop, ICON_PROP_OFF, 1);
+ RNA_def_property_ui_icon(prop, ICON_PROP_ON, 0);
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
+
+ prop = RNA_def_property(srna, "use_proportional_projected", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "proportional_edit", PROP_EDIT_PROJECTED);
+ RNA_def_property_ui_text(
+ prop, "Projected from View", "Proportional Editing using screen space locations");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
+
+ prop = RNA_def_property(srna, "use_proportional_connected", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "proportional_edit", PROP_EDIT_CONNECTED);
+ RNA_def_property_ui_text(
+ prop, "Connected Only", "Proportional Editing using connected geometry only");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
prop = RNA_def_property(srna, "use_proportional_edit_mask", PROP_BOOLEAN, PROP_NONE);
@@ -3614,7 +3619,7 @@ static void rna_def_unit_settings(BlenderRNA *brna)
/* Units */
prop = RNA_def_property(srna, "system", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, unit_systems);
- RNA_def_property_ui_text(prop, "Unit System", "The unit system to use for button display");
+ RNA_def_property_ui_text(prop, "Unit System", "The unit system to use for user interface controls");
RNA_def_property_update(prop, NC_WINDOW, "rna_UnitSettings_system_update");
prop = RNA_def_property(srna, "system_rotation", PROP_ENUM, PROP_NONE);
@@ -5562,14 +5567,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
- static const EnumPropertyItem fixed_oversample_items[] = {
- {5, "5", 0, "5", ""},
- {8, "8", 0, "8", ""},
- {11, "11", 0, "11", ""},
- {16, "16", 0, "16", ""},
- {0, NULL, 0, NULL, NULL},
- };
-
static const EnumPropertyItem threads_mode_items[] = {
{0,
"AUTO",
@@ -5659,7 +5656,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_range(prop, 1, SHRT_MAX);
RNA_def_property_ui_range(prop, 1, 100, 10, 1);
RNA_def_property_ui_text(prop, "Resolution %", "Percentage scale for render resolution");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneSequencer_update");
prop = RNA_def_property(srna, "tile_x", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "tilex");
@@ -5771,21 +5768,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop, "Alpha Mode", "Representation of alpha information in the RGBA pixels");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
- prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", R_OSA);
- RNA_def_property_ui_text(
- prop,
- "Anti-Aliasing",
- "Render and combine multiple samples per pixel to prevent jagged edges");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "antialiasing_samples", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "osa");
- RNA_def_property_enum_items(prop, fixed_oversample_items);
- RNA_def_property_ui_text(
- prop, "Anti-Aliasing Samples", "Amount of anti-aliasing samples per pixel");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE_FRS);
@@ -6213,17 +6195,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop, "Sequencer Preview Shading", "Method to draw in the sequencer view");
# endif
- prop = RNA_def_property(srna, "use_sequencer_gl_textured_solid", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_SOLID_TEX);
- RNA_def_property_ui_text(
- prop, "Textured Solid", "Display face-assigned textures in solid draw method");
- RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update");
-
- prop = RNA_def_property(srna, "use_sequencer_gl_dof", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_CAMERA_DOF);
+ prop = RNA_def_property(srna, "use_sequencer_override_scene_strip", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_OVERRIDE_SCENE_SETTINGS);
RNA_def_property_ui_text(prop,
- "Depth of Field",
- "Use depth of field using the values from scene strip active camera");
+ "Override Scene Settings",
+ "Use workbench render settings from the sequencer scene, instead of "
+ "each individual scene used in the strip");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update");
prop = RNA_def_property(srna, "use_single_layer", PROP_BOOLEAN, PROP_NONE);
@@ -6663,6 +6640,17 @@ static void rna_def_scene_display(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Samples", "Number of samples");
RNA_def_property_range(prop, 1, 500);
+ prop = RNA_def_property(srna, "render_aa", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, rna_enum_scene_display_aa_methods);
+ RNA_def_property_ui_text(prop, "Render Anti-Aliasing", "Method of anti-aliasing when rendering");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
+ prop = RNA_def_property(srna, "viewport_aa", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, rna_enum_scene_display_aa_methods);
+ RNA_def_property_ui_text(
+ prop, "Viewport Anti-Aliasing", "Method of anti-aliasing in 3d viewport");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
/* OpenGL render engine settings. */
prop = RNA_def_property(srna, "shading", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Shading Settings", "Shading settings for OpenGL render engine");
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index 89996cf3241..9c349d64953 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -93,7 +93,7 @@ static bool rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr))
static int rna_region_alignment_get(PointerRNA *ptr)
{
ARegion *region = ptr->data;
- return (region->alignment & ~RGN_SPLIT_PREV);
+ return RGN_ALIGN_ENUM_FROM_MASK(region->alignment);
}
static bool rna_Screen_fullscreen_get(PointerRNA *ptr)
@@ -149,11 +149,16 @@ static void rna_Area_type_set(PointerRNA *ptr, int value)
static void rna_Area_type_update(bContext *C, PointerRNA *ptr)
{
- wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win;
bScreen *sc = (bScreen *)ptr->id.data;
ScrArea *sa = (ScrArea *)ptr->data;
+ /* Running update without having called 'set', see: T64049 */
+ if (sa->butspacetype == SPACE_EMPTY) {
+ return;
+ }
+
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win;
/* XXX this call still use context, so we trick it to work in the right context */
for (win = wm->windows.first; win; win = win->next) {
if (sc == WM_window_get_active_screen(win)) {
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index be76a8136c0..2791c49b3d9 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -365,6 +365,12 @@ static bool rna_Brush_mode_with_tool_poll(PointerRNA *ptr, PointerRNA value)
}
mode = OB_MODE_SCULPT;
}
+ else if (paint_contains_brush_slot(&ts->uvsculpt->paint, tslot, &slot_index)) {
+ if (slot_index != brush->uv_sculpt_tool) {
+ return false;
+ }
+ mode = OB_MODE_EDIT;
+ }
else if (paint_contains_brush_slot(&ts->vpaint->paint, tslot, &slot_index)) {
if (slot_index != brush->vertexpaint_tool) {
return false;
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index 6f524be7473..0b1e35e3a74 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -1726,6 +1726,31 @@ static void rna_def_sequence(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting this strip");
rna_def_sequence_modifiers(brna, prop);
+ prop = RNA_def_property(srna, "use_cache_raw", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_RAW);
+ RNA_def_property_ui_text(prop,
+ "Cache Raw",
+ "Cache raw images read from disk, for faster tweaking of strip "
+ "parameters at the cost of memory usage");
+
+ prop = RNA_def_property(srna, "use_cache_preprocessed", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_PREPROCESSED);
+ RNA_def_property_ui_text(
+ prop,
+ "Cache Rreprocessed",
+ "Cache preprocessed images, for faster tweaking of effects at the cost of memory usage");
+
+ prop = RNA_def_property(srna, "use_cache_composite", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_COMPOSITE);
+ RNA_def_property_ui_text(prop,
+ "Cache Composite",
+ "Cache intermediate composited images, for faster tweaking of stacked "
+ "strips at the cost of memory usage");
+
+ prop = RNA_def_property(srna, "override_cache_settings", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_OVERRIDE);
+ RNA_def_property_ui_text(prop, "Override Cache Settings", "Override global cache settings");
+
RNA_api_sequence_strip(srna);
}
@@ -1809,6 +1834,65 @@ static void rna_def_editor(BlenderRNA *brna)
RNA_def_property_string_sdna(prop, NULL, "proxy_dir");
RNA_def_property_ui_text(prop, "Proxy Directory", "");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, "rna_SequenceEditor_update_cache");
+
+ /* cache flags */
+
+ prop = RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_ENABLE);
+ RNA_def_property_ui_text(prop, "Show Cache", "Visualize cached images on the timeline");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
+ prop = RNA_def_property(srna, "show_cache_final_out", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_FINAL_OUT);
+ RNA_def_property_ui_text(prop, "Final Images", "Visualize cached complete frames");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
+ prop = RNA_def_property(srna, "show_cache_raw", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_RAW);
+ RNA_def_property_ui_text(prop, "Raw Images", "Visualize cached raw images");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
+ prop = RNA_def_property(srna, "show_cache_preprocessed", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_PREPROCESSED);
+ RNA_def_property_ui_text(prop, "Preprocessed Images", "Visualize cached preprocessed images");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
+ prop = RNA_def_property(srna, "show_cache_composite", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_COMPOSITE);
+ RNA_def_property_ui_text(prop, "Composite Images", "Visualize cached composite images");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
+ prop = RNA_def_property(srna, "use_cache_raw", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_RAW);
+ RNA_def_property_ui_text(prop,
+ "Cache Raw",
+ "Cache raw images read from disk, for faster tweaking of strip "
+ "parameters at the cost of memory usage");
+
+ prop = RNA_def_property(srna, "use_cache_preprocessed", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_PREPROCESSED);
+ RNA_def_property_ui_text(
+ prop,
+ "Cache Preprocessed",
+ "Cache preprocessed images, for faster tweaking of effects at the cost of memory usage");
+
+ prop = RNA_def_property(srna, "use_cache_composite", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_COMPOSITE);
+ RNA_def_property_ui_text(prop,
+ "Cache Composite",
+ "Cache intermediate composited images, for faster tweaking of stacked "
+ "strips at the cost of memory usage");
+
+ prop = RNA_def_property(srna, "use_cache_final", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_FINAL_OUT);
+ RNA_def_property_ui_text(prop, "Cache Final", "Cache final image for each frame");
+
+ prop = RNA_def_property(srna, "recycle_max_cost", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.0f, SEQ_CACHE_COST_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, SEQ_CACHE_COST_MAX, 0.1f, 1);
+ RNA_def_property_float_sdna(prop, NULL, "recycle_max_cost");
+ RNA_def_property_ui_text(
+ prop, "Recycle Up To Cost", "Only frames with cost lower than this value will be recycled");
}
static void rna_def_filter_video(StructRNA *srna)
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index ca00ce993d3..1e14fd06b4f 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -112,12 +112,7 @@ const EnumPropertyItem rna_enum_space_type_items[] = {
"Python Console",
"Interactive programmatic console for "
"advanced editing and script development"},
- {SPACE_INFO,
- "INFO",
- ICON_INFO,
- "Info",
- "Main menu bar and list of error messages "
- "(drag down to expand and display)"},
+ {SPACE_INFO, "INFO", ICON_INFO, "Info", "Log of operations, warnings and error messages"},
/* Special case: Top-bar and Status-bar aren't supposed to be a regular editor for the user. */
{SPACE_TOPBAR,
"TOPBAR",
@@ -2613,7 +2608,7 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
prop = RNA_def_property(srna, "edge_display_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "dt_uv");
RNA_def_property_enum_items(prop, dt_uv_items);
- RNA_def_property_ui_text(prop, "Edge Display Type", "Display type for drawing UV edges");
+ RNA_def_property_ui_text(prop, "Display As", "Display style for UV edges");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
prop = RNA_def_property(srna, "show_smooth_edges", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 0236820e4d9..a9bec8262dd 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -1581,7 +1581,7 @@ static void rna_def_userdef_theme_spaces_vertex(StructRNA *srna)
RNA_def_property_ui_text(prop, "Vertex Select", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
- prop = RNA_def_property(srna, "vertex_size", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "vertex_size", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 1, 32);
RNA_def_property_ui_text(prop, "Vertex Size", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
@@ -1656,7 +1656,7 @@ static void rna_def_userdef_theme_spaces_face(StructRNA *srna)
RNA_def_property_ui_text(prop, "Face Dot Selected", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
- prop = RNA_def_property(srna, "facedot_size", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "facedot_size", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 1, 10);
RNA_def_property_ui_text(prop, "Face Dot Size", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
@@ -1803,7 +1803,7 @@ static void rna_def_userdef_theme_spaces_curves(
RNA_def_property_ui_text(prop, "Handle Vertex Select", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
- prop = RNA_def_property(srna, "handle_vertex_size", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "handle_vertex_size", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 1, 100);
RNA_def_property_ui_text(prop, "Handle Vertex Size", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
@@ -1824,7 +1824,7 @@ static void rna_def_userdef_theme_spaces_gpencil(StructRNA *srna)
RNA_def_property_ui_text(prop, "Grease Pencil Vertex Select", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
- prop = RNA_def_property(srna, "gp_vertex_size", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "gp_vertex_size", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 1, 10);
RNA_def_property_ui_text(prop, "Grease Pencil Vertex Size", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
@@ -2027,10 +2027,17 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
rna_def_userdef_theme_spaces_paint_curves(srna);
- prop = RNA_def_property(srna, "outline_width", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "outline_width", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 1, 5);
RNA_def_property_ui_text(prop, "Outline Width", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
+
+ prop = RNA_def_property(srna, "object_origin_size", PROP_INT, PROP_PIXEL);
+ RNA_def_property_int_sdna(prop, NULL, "obcenter_dia");
+ RNA_def_property_range(prop, 4, 10);
+ RNA_def_property_ui_text(
+ prop, "Object Origin Size", "Diameter in Pixels for Object/Light origin display");
+ RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
}
static void rna_def_userdef_theme_space_graph(BlenderRNA *brna)
@@ -4064,7 +4071,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
"Show a small rotating 3D axes in the top right corner of the 3D View");
RNA_def_property_update(prop, 0, "rna_userdef_update");
- prop = RNA_def_property(srna, "mini_axis_size", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "mini_axis_size", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "rvisize");
RNA_def_property_range(prop, 10, 64);
RNA_def_property_ui_text(prop, "Mini Axes Size", "The axes icon's size");
@@ -4101,11 +4108,13 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Gizmo Size", "Diameter of the gizmo");
RNA_def_property_update(prop, 0, "rna_userdef_update");
- prop = RNA_def_property(srna, "object_origin_size", PROP_INT, PROP_PIXEL);
- RNA_def_property_int_sdna(prop, NULL, "obcenter_dia");
- RNA_def_property_range(prop, 4, 10);
+ /* Lookdev */
+ prop = RNA_def_property(srna, "lookdev_ball_size", PROP_INT, PROP_PIXEL);
+ RNA_def_property_int_sdna(prop, NULL, "lookdev_ball_size");
+ RNA_def_property_range(prop, 50, 400);
+ RNA_def_property_int_default(prop, 150);
RNA_def_property_ui_text(
- prop, "Object Origin Size", "Diameter in Pixels for Object/Light origin display");
+ prop, "LookDev Balls Size", "Maximum diameter of the LookDev balls size");
RNA_def_property_update(prop, 0, "rna_userdef_update");
/* View2D Grid Displays */
@@ -4472,6 +4481,16 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Duplicate Particle", "Causes particle systems to be duplicated with the object");
+ prop = RNA_def_property(srna, "use_duplicate_lightprobe", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_LIGHTPROBE);
+ RNA_def_property_ui_text(
+ prop, "Duplicate Light Probe", "Causes light probe data to be duplicated with the object");
+
+ prop = RNA_def_property(srna, "use_duplicate_grease_pencil", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_GPENCIL);
+ RNA_def_property_ui_text(
+ prop, "Duplicate GPencil", "Causes grease pencil data to be duplicated with the object");
+
/* Currently only used for insert offset (aka auto-offset),
* maybe also be useful for later stuff though. */
prop = RNA_def_property(srna, "node_margin", PROP_INT, PROP_NONE);
@@ -5449,7 +5468,7 @@ void RNA_def_userdef(BlenderRNA *brna)
{USER_SECTION_ANIMATION, "ANIMATION", 0, "Animation", ""},
{0, "", 0, NULL, NULL},
{USER_SECTION_ADDONS, "ADDONS", 0, "Add-ons", ""},
-# if 0 //def WITH_USERDEF_WORKSPACES
+# if 0 // def WITH_USERDEF_WORKSPACES
{0, "", 0, NULL, NULL},
{USER_SECTION_WORKSPACE_CONFIG, "WORKSPACE_CONFIG", 0, "Configuration File", ""},
{USER_SECTION_WORKSPACE_ADDONS, "WORKSPACE_ADDONS", 0, "Add-on Overrides", ""},
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 34faf13fa7e..3f904df6e00 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -847,7 +847,7 @@ static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr)
{
wmKeyMapItem *kmi = ptr->data;
- return WM_keymap_map_type_get(kmi);
+ return WM_keymap_item_map_type_get(kmi);
}
static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
@@ -1169,7 +1169,7 @@ static void rna_wmKeyMapItem_idname_set(PointerRNA *ptr, const char *value)
if (!STREQ(idname, kmi->idname)) {
BLI_strncpy(kmi->idname, idname, sizeof(kmi->idname));
- WM_keymap_properties_reset(kmi, NULL);
+ WM_keymap_item_properties_reset(kmi, NULL);
}
}
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 3e7d16c636e..e4caeb2a5ae 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -82,7 +82,7 @@ static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C)
static void rna_keymap_restore_item_to_default(wmKeyMap *km, bContext *C, wmKeyMapItem *kmi)
{
- WM_keymap_restore_item_to_default(C, km, kmi);
+ WM_keymap_item_restore_to_default(C, km, kmi);
}
static void rna_Operator_report(wmOperator *op, int type, const char *msg)
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index 5e4791b8b7a..6349b5206d6 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -158,9 +158,8 @@ const EnumPropertyItem *rna_WorkSpace_tools_mode_itemf(bContext *UNUSED(C),
PropertyRNA *UNUSED(prop),
bool *UNUSED(r_free))
{
- WorkSpace *workspace = ptr->id.data;
-
- switch (workspace->tools_space_type) {
+ bToolRef *tref = ptr->data;
+ switch (tref->space_type) {
case SPACE_VIEW3D:
return rna_enum_context_mode_items;
case SPACE_IMAGE:
@@ -372,19 +371,6 @@ static void rna_def_workspace(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Tools", "");
rna_def_workspace_tools(brna, prop);
- prop = RNA_def_property(srna, "tools_space_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "tools_space_type");
- RNA_def_property_enum_items(prop, rna_enum_space_type_items);
- RNA_def_property_ui_text(prop, "Active Tool Space", "");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "tools_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "tools_mode");
- RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items);
- RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_WorkSpace_tools_mode_itemf");
- RNA_def_property_ui_text(prop, "Active Tool Mode", "");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_workspace_object_mode_items);
RNA_def_property_ui_text(
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index a53c3a96937..80238e8cab8 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -21,17 +21,17 @@
set(INC
.
intern
+ ../blenfont
../blenkernel
../blenlib
- ../blenfont
+ ../bmesh
../depsgraph
../makesdna
../makesrna
- ../bmesh
../render/extern/include
../../../intern/elbeem/extern
- ../../../intern/guardedalloc
../../../intern/eigen
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index 6a01b01c0d9..72215659915 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -24,11 +24,13 @@
#include <string.h>
#include "BLI_utildefines.h"
+#include "BLI_listbase.h"
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
+#include "BKE_action.h"
#include "BKE_editmesh.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@@ -91,7 +93,27 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
ArmatureModifierData *amd = (ArmatureModifierData *)md;
if (amd->object != NULL) {
- DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_EVAL_POSE, "Armature Modifier");
+ /* If not using envelopes,
+ * create relations to individual bones for more rigging flexibility. */
+ if ((amd->deformflag & ARM_DEF_ENVELOPE) == 0 && (amd->object->pose != NULL) &&
+ ELEM(ctx->object->type, OB_MESH, OB_LATTICE, OB_GPENCIL)) {
+ /* If neither vertex groups nor envelopes are used, the modifier has no bone dependencies. */
+ if ((amd->deformflag & ARM_DEF_VGROUP) != 0) {
+ /* Enumerate groups that match existing bones. */
+ LISTBASE_FOREACH (bDeformGroup *, dg, &ctx->object->defbase) {
+ if (BKE_pose_channel_find_name(amd->object->pose, dg->name) != NULL) {
+ /* Can't check BONE_NO_DEFORM because it can be animated. */
+ DEG_add_bone_relation(
+ ctx->node, amd->object, dg->name, DEG_OB_COMP_BONE, "Armature Modifier");
+ }
+ }
+ }
+ }
+ /* Otherwise require the whole pose to be complete. */
+ else {
+ DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_EVAL_POSE, "Armature Modifier");
+ }
+
DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_TRANSFORM, "Armature Modifier");
}
DEG_add_modifier_to_transform_relation(ctx->node, "Armature Modifier");
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 3443d275c81..fd6f58a21d4 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -148,7 +148,8 @@ static void svert_from_mvert(SortVertsElem *sv,
/**
* Take as inputs two sets of verts, to be processed for detection of doubles and mapping.
* Each set of verts is defined by its start within mverts array and its num_verts;
- * It builds a mapping for all vertices within source, to vertices within target, or -1 if no double found
+ * It builds a mapping for all vertices within source,
+ * to vertices within target, or -1 if no double found.
* The int doubles_map[num_verts_source] array must have been allocated by caller.
*/
static void dm_mvert_map_doubles(int *doubles_map,
@@ -220,11 +221,13 @@ static void dm_mvert_map_doubles(int *doubles_map,
target_scan_completed = true;
continue;
}
- /* Test target candidates starting at the low bound of possible doubles, ordered in terms of sumco */
+ /* Test target candidates starting at the low bound of possible doubles,
+ * ordered in terms of sumco. */
i_target = i_target_low_bound;
sve_target = sve_target_low_bound;
- /* i_target will scan vertices in the [v_source_sumco - dist3; v_source_sumco + dist3] range */
+ /* i_target will scan vertices in the
+ * [v_source_sumco - dist3; v_source_sumco + dist3] range */
while ((i_target < target_num_verts) && (sve_target->sum_co <= sve_source_sumco + dist3)) {
/* Testing distance for candidate double in target */
@@ -237,8 +240,9 @@ static void dm_mvert_map_doubles(int *doubles_map,
/* If target is already mapped, we only follow that mapping if final target remains
* close enough from current vert (otherwise no mapping at all).
- * Note that if we later find another target closer than this one, then we check it. But if other
- * potential targets are farther, then there will be no mapping at all for this source. */
+ * Note that if we later find another target closer than this one, then we check it.
+ * But if other potential targets are farther,
+ * then there will be no mapping at all for this source. */
while (best_target_vertex != -1 &&
!ELEM(doubles_map[best_target_vertex], -1, best_target_vertex)) {
if (compare_len_v3v3(mverts[sve_source->vertex_num].co,
@@ -720,7 +724,8 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
for (i = 0; i < result_nverts; i++) {
int new_i = full_doubles_map[i];
if (new_i != -1) {
- /* We have to follow chains of doubles (merge start/end especially is likely to create some),
+ /* We have to follow chains of doubles
+ * (merge start/end especially is likely to create some),
* those are not supported at all by BKE_mesh_merge_verts! */
while (!ELEM(full_doubles_map[new_i], -1, new_i)) {
new_i = full_doubles_map[new_i];
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 02d3bd305be..26b45bbef0d 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -110,19 +110,19 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
const int miter_inner = bmd->miter_inner;
const float spread = bmd->spread;
- bm = BKE_mesh_to_bmesh_ex(
- mesh,
- &(struct BMeshCreateParams){0},
- &(struct BMeshFromMeshParams){
- .calc_face_normal = true,
- .add_key_index = false,
- .use_shapekey = false,
- .active_shapekey = 0,
- /* XXX We probably can use CD_MASK_BAREMESH_ORIGDINDEX here instead (also for other modifiers cases)? */
- .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX,
- .emask = CD_MASK_ORIGINDEX,
- .pmask = CD_MASK_ORIGINDEX},
- });
+ bm = BKE_mesh_to_bmesh_ex(mesh,
+ &(struct BMeshCreateParams){0},
+ &(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ .add_key_index = false,
+ .use_shapekey = false,
+ .active_shapekey = 0,
+ /* XXX We probably can use CD_MASK_BAREMESH_ORIGDINDEX here instead
+ * (also for other modifiers cases)? */
+ .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX,
+ .emask = CD_MASK_ORIGINDEX,
+ .pmask = CD_MASK_ORIGINDEX},
+ });
if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0]) {
MOD_get_vgroup(ctx->object, mesh, bmd->defgrp_name, &dvert, &vgroup);
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c
index 2a332bc9709..705ffb266c5 100644
--- a/source/blender/modifiers/intern/MOD_correctivesmooth.c
+++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c
@@ -307,7 +307,8 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd,
/* fast-path */
for (i = 0; i < numVerts; i++) {
struct SmoothingData_Weighted *sd = &smooth_data[i];
- /* divide by sum of all neighbour distances (weighted) and amount of neighbors, (mean average) */
+ /* Divide by sum of all neighbour distances (weighted) and amount of neighbors,
+ * (mean average). */
const float div = sd->edge_length_sum * vertex_edge_count[i];
if (div > eps) {
#if 0
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index 4de99ea6fe6..3235d64cbbb 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -179,8 +179,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
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
- * modify org mesh, see T43671. */
+ /* We need to duplicate data here, otherwise setting custom normals, edges' shaprness, etc.,
+ * could modify org mesh, see T43671. */
BKE_id_copy_ex(NULL, &me_mod->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
}
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index ccd71455b21..ce488a224aa 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -129,7 +129,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
ctx->node, ctx->object, surface->effector_weights, true, 0, "Dynamic Paint Field");
}
- /* Actual code uses custom loop over group/scene without layer checks in dynamicPaint_doStep */
+ /* Actual code uses custom loop over group/scene
+ * without layer checks in dynamicPaint_doStep. */
DEG_add_collision_relations(ctx->node,
ctx->object,
surface->brush_group,
@@ -167,7 +168,7 @@ static void foreachTexLink(ModifierData *UNUSED(md),
TexWalkFunc UNUSED(walk),
void *UNUSED(userData))
{
- //walk(userData, ob, md, ""); /* re-enable when possible */
+ // walk(userData, ob, md, ""); /* re-enable when possible */
}
ModifierTypeInfo modifierType_DynamicPaint = {
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index 7d87ba240d5..4ed787810a8 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -743,7 +743,7 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh)
* have to stop using tessface - campbell */
facepa = MEM_calloc_arrayN((totface + (totfsplit * 2)), sizeof(int), "explode_facepa");
- //memcpy(facepa, emd->facepa, totface*sizeof(int));
+ // memcpy(facepa, emd->facepa, totface*sizeof(int));
emd->facepa = facepa;
/* create new verts */
@@ -766,7 +766,7 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh)
/* create new faces */
curdupface = 0; //=totface;
- //curdupin=totesplit;
+ // curdupin=totesplit;
for (i = 0, fs = facesplit; i < totface; i++, fs++) {
mf = &mesh->mface[i];
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 3744c527983..0776806f541 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -435,8 +435,10 @@ static Mesh *fluidsim_read_cache(
Object *ob, Mesh *orgmesh, FluidsimModifierData *fluidmd, int framenr, int useRenderParams)
{
int curFrame = framenr /* - 1 */ /*scene->r.sfra*/; /* start with 0 at start frame */
- /* why start with 0 as start frame?? Animations + time are frozen for frame 0 anyway. (See physics_fluid.c for that. - DG */
- /* If we start with frame 0, we need to remap all animation channels, too, because they will all be 1 frame late if using frame-1! - DG */
+ /* why start with 0 as start frame?? Animations + time are frozen for frame 0 anyway.
+ * (See physics_fluid.c for that. - DG) */
+ /* If we start with frame 0, we need to remap all animation channels, too,
+ * because they will all be 1 frame late if using frame-1! - DG */
char targetFile[FILE_MAX];
FluidsimSettings *fss = fluidmd->fss;
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index 71636463f70..e27d2786751 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -214,7 +214,8 @@ static void createVertRingMap(const int mvert_tot,
}
/**
- * This method computes the Laplacian Matrix and Differential Coordinates for all vertex in the mesh.
+ * This method computes the Laplacian Matrix and Differential Coordinates
+ * for all vertex in the mesh..
* The Linear system is LV = d
* Where L is Laplacian Matrix, V as the vertices in Mesh, d is the differential coordinates
* The Laplacian Matrix is computes as a
@@ -227,18 +228,21 @@ static void createVertRingMap(const int mvert_tot,
* Where :
* di is the Differential Coordinate i
* sum (Wij) is the sum of all weights between vertex Vi and its vertices neighbors (Vj)
- * sum (Wij * Vj) is the sum of the product between vertex neighbor Vj and weight Wij for all neighborhood.
+ * sum (Wij * Vj) is the sum of the product between vertex neighbor Vj and weight Wij
+ * for all neighborhood.
*
* This Laplacian Matrix is described in the paper:
- * Desbrun M. et.al, Implicit fairing of irregular meshes using diffusion and curvature flow, SIGGRAPH '99, pag 317-324,
- * New York, USA
+ * Desbrun M. et.al, Implicit fairing of irregular meshes using diffusion and curvature flow,
+ * SIGGRAPH '99, pag 317-324, New York, USA
*
- * The computation of Laplace Beltrami operator on Hybrid Triangle/Quad Meshes is described in the paper:
- * Pinzon A., Romero E., Shape Inflation With an Adapted Laplacian Operator For Hybrid Quad/Triangle Meshes,
+ * The computation of Laplace Beltrami operator on Hybrid Triangle/Quad Meshes is described in the
+ * paper: Pinzon A., Romero E., Shape Inflation With an Adapted Laplacian Operator For
+ * Hybrid Quad/Triangle Meshes,
* Conference on Graphics Patterns and Images, SIBGRAPI, 2013
*
* The computation of Differential Coordinates is described in the paper:
- * Sorkine, O. Laplacian Surface Editing. Proceedings of the EUROGRAPHICS/ACM SIGGRAPH Symposium on Geometry Processing,
+ * Sorkine, O. Laplacian Surface Editing.
+ * Proceedings of the EUROGRAPHICS/ACM SIGGRAPH Symposium on Geometry Processing,
* 2004. p. 179-188.
*/
static void initLaplacianMatrix(LaplacianSystem *sys)
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index a13e75c76de..3417aaeeb5c 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -105,9 +105,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
/* Overview of Method:
- * 1. Get the vertices that are in the vertexgroup of interest
- * 2. Filter out unwanted geometry (i.e. not in vertexgroup), by populating mappings with new vs old indices
- * 3. Make a new mesh containing only the mapping data
+ * 1. Get the vertices that are in the vertexgroup of interest.
+ * 2. Filter out unwanted geometry (i.e. not in vertexgroup),
+ * by populating mappings with new vs old indices.
+ * 3. Make a new mesh containing only the mapping data.
*/
/* get original number of verts, edges, and faces */
@@ -137,9 +138,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
return mesh;
}
- /* determine whether each vertexgroup is associated with a selected bone or not
- * - each cell is a boolean saying whether bone corresponding to the ith group is selected
- * - groups that don't match a bone are treated as not existing (along with the corresponding ungrouped verts)
+ /* Determine whether each vertexgroup is associated with a selected bone or not:
+ * - Each cell is a boolean saying whether bone corresponding to the ith group is selected.
+ * - Groups that don't match a bone are treated as not existing
+ * (along with the corresponding ungrouped verts).
*/
bone_select_array = MEM_malloc_arrayN((size_t)defbase_tot, sizeof(char), "mask array");
@@ -154,7 +156,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
}
- /* verthash gives mapping from original vertex indices to the new indices (including selected matches only)
+ /* verthash gives mapping from original vertex indices to the new indices
+ * (including selected matches only):
* key = oldindex, value = newindex
*/
vertHash = BLI_ghash_int_new_ex("mask vert gh", (unsigned int)maxVerts);
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index 7710082150b..760830ffb24 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -18,6 +18,11 @@
* \ingroup modifiers
*/
+#include <string.h>
+
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+
#include "DNA_cachefile_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -47,6 +52,9 @@ static void initData(ModifierData *md)
mcmd->cache_file = NULL;
mcmd->object_path[0] = '\0';
mcmd->read_flag = MOD_MESHSEQ_READ_ALL;
+
+ mcmd->reader = NULL;
+ mcmd->reader_object_path[0] = '\0';
}
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
@@ -59,6 +67,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
modifier_copyData_generic(md, target, flag);
tmcmd->reader = NULL;
+ tmcmd->reader_object_path[0] = '\0';
}
static void freeData(ModifierData *md)
@@ -66,10 +75,8 @@ static void freeData(ModifierData *md)
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
if (mcmd->reader) {
-#ifdef WITH_ALEMBIC
- CacheReader_free(mcmd->reader);
-#endif
- mcmd->reader = NULL;
+ mcmd->reader_object_path[0] = '\0';
+ BKE_cachefile_reader_free(mcmd->cache_file, &mcmd->reader);
}
}
@@ -93,17 +100,14 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
Mesh *org_mesh = mesh;
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
+ CacheFile *cache_file = mcmd->cache_file;
const float frame = DEG_get_ctime(ctx->depsgraph);
- const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS);
+ const float time = BKE_cachefile_time_offset(cache_file, frame, FPS);
const char *err_str = NULL;
- CacheFile *cache_file = (CacheFile *)DEG_get_original_id(&mcmd->cache_file->id);
-
- BKE_cachefile_ensure_handle(G.main, cache_file);
-
- if (!mcmd->reader) {
- mcmd->reader = CacheReader_open_alembic_object(
- cache_file->handle, NULL, ctx->object, mcmd->object_path);
+ if (!mcmd->reader || !STREQ(mcmd->reader_object_path, mcmd->object_path)) {
+ STRNCPY(mcmd->reader_object_path, mcmd->object_path);
+ BKE_cachefile_reader_open(cache_file, &mcmd->reader, ctx->object, mcmd->object_path);
if (!mcmd->reader) {
modifier_setError(md, "Could not create Alembic reader for file %s", cache_file->filepath);
return mesh;
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 5c1f0435270..10852ed6148 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -62,13 +62,15 @@ static void generate_vert_coordinates(Mesh *mesh,
}
}
- /* Get size (i.e. deformation of the spheroid generating normals), either from target object, or own geometry. */
+ /* Get size (i.e. deformation of the spheroid generating normals),
+ * either from target object, or own geometry. */
if (r_size != NULL) {
if (ob_center != NULL) {
/* Using 'scale' as 'size' here. The input object is typically an empty
* who's scale is used to define an ellipsoid instead of a simple sphere. */
- /* Not we are not interested in signs here - they are even troublesome actually, due to security clamping! */
+ /* Not we are not interested in signs here - they are even troublesome actually,
+ * due to security clamping! */
abs_v3_v3(r_size, ob_center->scale);
}
else {
@@ -247,7 +249,8 @@ static void normalEditModifier_do_radial(NormalEditModifierData *enmd,
* Then, we want to find out for each vert its (a, b, c) triple (proportional to (A, B, C) one).
*
* Ellipsoid basic equation: ``(x^2/a^2) + (y^2/b^2) + (z^2/c^2) = 1.``
- * Since we want to find (a, b, c) matching this equation and proportional to (A, B, C), we can do:
+ * Since we want to find (a, b, c) matching this equation and proportional to (A, B, C),
+ * we can do:
* <pre>
* m = B / A
* n = C / A
@@ -480,9 +483,11 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd,
return mesh;
}
- /* XXX TODO ARG GRRR XYQWNMPRXTYY
- * Once we fully switch to Mesh evaluation of modifiers, we can expect to get that flag from the COW copy.
- * But for now, it is lost in the DM intermediate step, so we need to directly check orig object's data. */
+ /* XXX TODO(Rohan Rathi):
+ * Once we fully switch to Mesh evaluation of modifiers,
+ * we can expect to get that flag from the COW copy.
+ * But for now, it is lost in the DM intermediate step,
+ * so we need to directly check orig object's data. */
#if 0
if (!(mesh->flag & ME_AUTOSMOOTH))
#else
@@ -495,7 +500,8 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd,
Mesh *result;
if (mesh->medge == ((Mesh *)ob->data)->medge) {
- /* We need to duplicate data here, otherwise setting custom normals (which may also affect sharp edges) could
+ /* We need to duplicate data here, otherwise setting custom normals
+ * (which may also affect sharp edges) could
* modify org mesh, see T43671. */
BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
}
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 1ca25cbb068..cd0046b8a31 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -434,7 +434,8 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
/* displace the geometry */
- /* Note: tried to parallelized that one and previous foam loop, but gives 20% slower results... odd. */
+ /* Note: tried to parallelized that one and previous foam loop,
+ * but gives 20% slower results... odd. */
{
const int num_verts = result->totvert;
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index bfd1858df09..dd894e86dcc 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -345,8 +345,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/* multiplying the steps is a bit tricky, this works best */
step_tot = ((step_tot + 1) * ltmd->iter) - (ltmd->iter - 1);
- /* will the screw be closed?
- * Note! smaller then FLT_EPSILON * 100 gives problems with float precision so its never closed. */
+ /* Will the screw be closed?
+ * Note! smaller then `FLT_EPSILON * 100`
+ * gives problems with float precision so its never closed. */
if (fabsf(screw_ofs) <= (FLT_EPSILON * 100.0f) &&
fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON * 100.0f)) {
close = 1;
@@ -493,7 +494,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
*/
vert_connect = MEM_malloc_arrayN(totvert, sizeof(ScrewVertConnect), "ScrewVertConnect");
- //vert_connect = (ScrewVertConnect *) &medge_new[totvert]; /* skip the first slice of verts */
+ /* skip the first slice of verts. */
+ // vert_connect = (ScrewVertConnect *) &medge_new[totvert];
vc = vert_connect;
/* Copy Vert Locations */
@@ -605,7 +607,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/*printf("\t\tVERT: %i\n", lt_iter.v);*/
if (lt_iter.v_poin->flag) {
/*printf("\t\t\tBreaking Found end\n");*/
- //endpoints[0] = endpoints[1] = SV_UNUSED;
+ // endpoints[0] = endpoints[1] = SV_UNUSED;
ed_loop_closed = 1; /* circle */
break;
}
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 7ddde7236c0..a344141bf4a 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -1216,7 +1216,7 @@ static BMFace *skin_hole_target_face(BMesh *bm, Frame *frame)
}
/* This case is unlikely now, but could still happen. Should look
- * into splitting edges to make new faces. */
+ * into splitting edges to make new faces. */
#if PRINT_HOLE_INFO
if (!f) {
printf("no good face found\n");
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 78006147ab5..88135b8790b 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -380,7 +380,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/* DO NOT copy here the 'copied' part of loop data, we want to reverse loops
* (so that winding of copied face get reversed, so that normals get reversed
* and point in expected direction...).
- * If we also copy data here, then this data get overwritten (and allocated memory becomes memleak). */
+ * If we also copy data here, then this data get overwritten
+ * (and allocated memory becomes memleak). */
CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)numPolys);
CustomData_copy_data(&mesh->pdata, &result->pdata, 0, (int)numPolys, (int)numPolys);
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 2a9fff47e5d..47c0114f02f 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -441,7 +441,8 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
bwdata->bind_polys = bpoly;
- /* Loop over all adjacent edges, and build the SDefBindPoly data for each poly adjacent to those */
+ /* Loop over all adjacent edges,
+ * and build the SDefBindPoly data for each poly adjacent to those. */
for (vedge = vert_edges; vedge; vedge = vedge->next) {
unsigned int edge_ind = vedge->index;
@@ -860,7 +861,8 @@ static void bindVert(void *__restrict userdata,
interp_weights_poly_v2(
sdbind->vert_weights, bpoly->coords_v2, bpoly->numverts, bpoly->point_v2);
- /* Reproject vert based on weights and original poly verts, to reintroduce poly non-planarity */
+ /* Reproject vert based on weights and original poly verts,
+ * to reintroduce poly non-planarity */
zero_v3(point_co_proj);
for (int j = 0; j < bpoly->numverts; j++, loop++) {
madd_v3_v3fl(point_co_proj, bpoly->coords[j], sdbind->vert_weights[j]);
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index 7d890b29365..1582c27960e 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -133,7 +133,7 @@ ModifierTypeInfo modifierType_Triangulate = {
/* applyModifier */ applyModifier,
/* initData */ initData,
- /* requiredDataMask */ NULL, //requiredDataMask,
+ /* requiredDataMask */ NULL, // requiredDataMask,
/* freeData */ NULL,
/* isDisabled */ NULL,
/* updateDepsgraph */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 330c7860882..d5c966e09ad 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -208,11 +208,13 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob,
}
}
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. */
+ /* 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... ). */
+ * (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;
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index 210f67ef07a..7fbaa24b579 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -51,7 +51,8 @@ static int modepair_cmp_by_val_inverse(const void *p1, const void *p2)
return (r1->val < r2->val) ? 1 : ((r1->val > r2->val) ? -1 : 0);
}
-/* There will be one of those per vertex (simple case, computing one normal per vertex), or per smooth fan. */
+/* There will be one of those per vertex
+ * (simple case, computing one normal per vertex), or per smooth fan. */
typedef struct WeightedNormalDataAggregateItem {
float normal[3];
@@ -97,8 +98,10 @@ typedef struct WeightedNormalData {
int *loop_to_poly;
} WeightedNormalData;
-/* Check strength of given poly compared to those found so far for that given item (vertex or smooth fan),
- * and reset matching item_data in case we get a stronger new strength. */
+/**
+ * Check strength of given poly compared to those found so far for that given item
+ * (vertex or smooth fan), and reset matching item_data in case we get a stronger new strength.
+ */
static bool check_item_poly_strength(WeightedNormalData *wn_data,
WeightedNormalDataAggregateItem *item_data,
const int mp_index)
@@ -158,7 +161,8 @@ static void aggregate_item_normal(WeightedNormalModifierData *wnmd,
item_data->curr_val = curr_val;
}
- /* Exponentially divided weight for each normal (since a few values will be used by most cases, we cache those). */
+ /* Exponentially divided weight for each normal
+ * (since a few values will be used by most cases, we cache those). */
const int num_loops = item_data->num_loops;
if (num_loops < NUM_CACHED_INVERSE_POWERS_OF_WEIGHT &&
cached_inverse_powers_of_weight[num_loops] == 0.0f) {
@@ -211,7 +215,8 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
if (keep_sharp) {
BLI_bitmap *done_loops = BLI_BITMAP_NEW(numLoops, __func__);
- /* This will give us loop normal spaces, we do not actually care about computed loop_normals for now... */
+ /* This will give us loop normal spaces,
+ * we do not actually care about computed loop_normals for now... */
loop_normals = MEM_calloc_arrayN((size_t)numLoops, sizeof(*loop_normals), __func__);
BKE_mesh_normals_loop_split(mvert,
numVerts,
@@ -329,8 +334,9 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
if (keep_sharp) {
/* Set loop normals for normal computed for each lnor space (smooth fan).
- * Note that loop_normals is already populated with clnors (before this modifier is applied, at start of
- * this function), so no need to recompute them here. */
+ * Note that loop_normals is already populated with clnors
+ * (before this modifier is applied, at start of this function),
+ * so no need to recompute them here. */
for (int ml_index = 0; ml_index < numLoops; ml_index++) {
WeightedNormalDataAggregateItem *item_data = lnors_spacearr.lspacearr[ml_index]->user_data;
if (!is_zero_v3(item_data->normal)) {
@@ -351,12 +357,14 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
clnors);
}
else {
- /* TODO: Ideally, we could add an option to BKE_mesh_normals_loop_custom_[from_vertices_]set() to keep current
- * clnors instead of resetting them to default autocomputed ones, when given new custom normal is zero-vec.
+ /* TODO: Ideally, we could add an option to BKE_mesh_normals_loop_custom_[from_vertices_]set()
+ * to keep current clnors instead of resetting them to default autocomputed ones,
+ * when given new custom normal is zero-vec.
* But this is not exactly trivial change, better to keep this optimization for later...
*/
if (!has_vgroup) {
- /* Note: in theory, we could avoid this extra allocation & copying... But think we can live with it for now,
+ /* Note: in theory, we could avoid this extra allocation & copying...
+ * But think we can live with it for now,
* and it makes code simpler & cleaner. */
float(*vert_normals)[3] = MEM_calloc_arrayN(
(size_t)numVerts, sizeof(*loop_normals), __func__);
@@ -540,118 +548,122 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
WeightedNormalModifierData *wnmd = (WeightedNormalModifierData *)md;
Object *ob = ctx->object;
- /* XXX TODO ARG GRRR XYQWNMPRXTYY
- * Once we fully switch to Mesh evaluation of modifiers, we can expect to get that flag from the COW copy.
- * But for now, it is lost in the DM intermediate step, so we need to directly check orig object's data. */
+ /* XXX TODO(Rohan Rathi):
+ * Once we fully switch to Mesh evaluation of modifiers,
+ * we can expect to get that flag from the COW copy.
+ * But for now, it is lost in the DM intermediate step,
+ * so we need to directly check orig object's data. */
#if 0
- if (!(mesh->flag & ME_AUTOSMOOTH)) {
+ if (!(mesh->flag & ME_AUTOSMOOTH))
#else
- if (!(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH)) {
+ if (!(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH))
#endif
- modifier_setError((ModifierData *)wnmd, "Enable 'Auto Smooth' option in mesh settings");
- return mesh;
-}
-
-Mesh *result;
-BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
-
-const int numVerts = result->totvert;
-const int numEdges = result->totedge;
-const int numLoops = result->totloop;
-const int numPolys = result->totpoly;
-
-MEdge *medge = result->medge;
-MPoly *mpoly = result->mpoly;
-MVert *mvert = result->mvert;
-MLoop *mloop = result->mloop;
+ {
+ modifier_setError((ModifierData *)wnmd, "Enable 'Auto Smooth' option in mesh settings");
+ return mesh;
+ }
-/* Right now:
- * If weight = 50 then all faces are given equal weight.
- * If weight > 50 then more weight given to faces with larger vals (face area / corner angle).
- * If weight < 50 then more weight given to faces with lesser vals. However current calculation
- * does not converge to min/max.
- */
-float weight = ((float)wnmd->weight) / 50.0f;
-if (wnmd->weight == 100) {
- weight = (float)SHRT_MAX;
-}
-else if (wnmd->weight == 1) {
- weight = 1 / (float)SHRT_MAX;
-}
-else if ((weight - 1) * 25 > 1) {
- weight = (weight - 1) * 25;
-}
+ Mesh *result;
+ BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
+
+ const int numVerts = result->totvert;
+ const int numEdges = result->totedge;
+ const int numLoops = result->totloop;
+ const int numPolys = result->totpoly;
+
+ MEdge *medge = result->medge;
+ MPoly *mpoly = result->mpoly;
+ MVert *mvert = result->mvert;
+ MLoop *mloop = result->mloop;
+
+ /* Right now:
+ * If weight = 50 then all faces are given equal weight.
+ * If weight > 50 then more weight given to faces with larger vals (face area / corner angle).
+ * If weight < 50 then more weight given to faces with lesser vals. However current calculation
+ * does not converge to min/max.
+ */
+ float weight = ((float)wnmd->weight) / 50.0f;
+ if (wnmd->weight == 100) {
+ weight = (float)SHRT_MAX;
+ }
+ else if (wnmd->weight == 1) {
+ weight = 1 / (float)SHRT_MAX;
+ }
+ else if ((weight - 1) * 25 > 1) {
+ weight = (weight - 1) * 25;
+ }
-CustomData *pdata = &result->pdata;
-float (*polynors)[3] = CustomData_get_layer(pdata, CD_NORMAL);
-if (!polynors) {
- polynors = CustomData_add_layer(pdata, CD_NORMAL, CD_CALLOC, NULL, numPolys);
- CustomData_set_layer_flag(pdata, CD_NORMAL, CD_FLAG_TEMPORARY);
-}
-BKE_mesh_calc_normals_poly(
- mvert, NULL, numVerts, mloop, mpoly, numLoops, numPolys, polynors, false);
-
-const float split_angle = mesh->smoothresh;
-short (*clnors)[2];
-CustomData *ldata = &result->ldata;
-clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL);
-
-/* Keep info whether we had clnors, it helps when generating clnor spaces and default normals. */
-const bool has_clnors = clnors != NULL;
-if (!clnors) {
- clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numLoops);
-}
+ CustomData *pdata = &result->pdata;
+ float(*polynors)[3] = CustomData_get_layer(pdata, CD_NORMAL);
+ if (!polynors) {
+ polynors = CustomData_add_layer(pdata, CD_NORMAL, CD_CALLOC, NULL, numPolys);
+ CustomData_set_layer_flag(pdata, CD_NORMAL, CD_FLAG_TEMPORARY);
+ }
+ BKE_mesh_calc_normals_poly(
+ mvert, NULL, numVerts, mloop, mpoly, numLoops, numPolys, polynors, false);
+
+ const float split_angle = mesh->smoothresh;
+ short(*clnors)[2];
+ CustomData *ldata = &result->ldata;
+ clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL);
+
+ /* Keep info whether we had clnors,
+ * it helps when generating clnor spaces and default normals. */
+ const bool has_clnors = clnors != NULL;
+ if (!clnors) {
+ clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numLoops);
+ }
-MDeformVert *dvert;
-int defgrp_index;
-MOD_get_vgroup(ctx->object, mesh, wnmd->defgrp_name, &dvert, &defgrp_index);
+ MDeformVert *dvert;
+ int defgrp_index;
+ MOD_get_vgroup(ctx->object, mesh, wnmd->defgrp_name, &dvert, &defgrp_index);
-WeightedNormalData wn_data = {
- .numVerts = numVerts,
- .numEdges = numEdges,
- .numLoops = numLoops,
- .numPolys = numPolys,
+ WeightedNormalData wn_data = {
+ .numVerts = numVerts,
+ .numEdges = numEdges,
+ .numLoops = numLoops,
+ .numPolys = numPolys,
- .mvert = mvert,
- .medge = medge,
+ .mvert = mvert,
+ .medge = medge,
- .mloop = mloop,
- .clnors = clnors,
- .has_clnors = has_clnors,
- .split_angle = split_angle,
+ .mloop = mloop,
+ .clnors = clnors,
+ .has_clnors = has_clnors,
+ .split_angle = split_angle,
- .mpoly = mpoly,
- .polynors = polynors,
- .poly_strength = CustomData_get_layer_named(
- &result->pdata, CD_PROP_INT, MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID),
+ .mpoly = mpoly,
+ .polynors = polynors,
+ .poly_strength = CustomData_get_layer_named(
+ &result->pdata, CD_PROP_INT, MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID),
- .dvert = dvert,
- .defgrp_index = defgrp_index,
- .use_invert_vgroup = (wnmd->flag & MOD_WEIGHTEDNORMAL_INVERT_VGROUP) != 0,
+ .dvert = dvert,
+ .defgrp_index = defgrp_index,
+ .use_invert_vgroup = (wnmd->flag & MOD_WEIGHTEDNORMAL_INVERT_VGROUP) != 0,
- .weight = weight,
- .mode = wnmd->mode,
-};
+ .weight = weight,
+ .mode = wnmd->mode,
+ };
-switch (wnmd->mode) {
- case MOD_WEIGHTEDNORMAL_MODE_FACE:
- wn_face_area(wnmd, &wn_data);
- break;
- case MOD_WEIGHTEDNORMAL_MODE_ANGLE:
- wn_corner_angle(wnmd, &wn_data);
- break;
- case MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE:
- wn_face_with_angle(wnmd, &wn_data);
- break;
-}
+ switch (wnmd->mode) {
+ case MOD_WEIGHTEDNORMAL_MODE_FACE:
+ wn_face_area(wnmd, &wn_data);
+ break;
+ case MOD_WEIGHTEDNORMAL_MODE_ANGLE:
+ wn_corner_angle(wnmd, &wn_data);
+ break;
+ case MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE:
+ wn_face_with_angle(wnmd, &wn_data);
+ break;
+ }
-MEM_SAFE_FREE(wn_data.loop_to_poly);
-MEM_SAFE_FREE(wn_data.mode_pair);
-MEM_SAFE_FREE(wn_data.items_data);
+ MEM_SAFE_FREE(wn_data.loop_to_poly);
+ MEM_SAFE_FREE(wn_data.mode_pair);
+ MEM_SAFE_FREE(wn_data.items_data);
-/* Currently Modifier stack assumes there is no poly normal data passed around... */
-CustomData_free_layers(pdata, CD_NORMAL, numPolys);
-return result;
+ /* Currently Modifier stack assumes there is no poly normal data passed around... */
+ CustomData_free_layers(pdata, CD_NORMAL, numPolys);
+ return result;
}
static void initData(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index 871da8dfba9..61872cbe464 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -50,8 +50,8 @@
/* Maps new_w weights in place, using either one of the predefined functions, or a custom curve.
* Return values are in new_w.
- * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real
- * vertex index (in case the weight tables do not cover the whole vertices...).
+ * If indices is not NULL, it must be a table of same length as org_w and new_w,
+ * mapping to the real vertex index (in case the weight tables do not cover the whole vertices...).
* cmap might be NULL, in which case curve mapping mode will return unmodified data.
*/
void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cmap, RNG *rng)
@@ -111,9 +111,10 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm
/* Applies new_w weights to org_w ones, using either a texture, vgroup or constant value as factor.
* Return values are in org_w.
- * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real
- * vertex index (in case the weight tables do not cover the whole vertices...).
- * XXX The standard "factor" value is assumed in [0.0, 1.0] range. Else, weird results might appear.
+ * If indices is not NULL, it must be a table of same length as org_w and new_w,
+ * mapping to the real vertex index (in case the weight tables do not cover the whole vertices...).
+ * XXX The standard "factor" value is assumed in [0.0, 1.0] range.
+ * Else, weird results might appear.
*/
void weightvg_do_mask(const ModifierEvalContext *ctx,
const int num,
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.h
index d73cca935d7..08967b7400d 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.h
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.h
@@ -52,21 +52,9 @@ struct Tex;
*/
#define MOD_WVG_ZEROFLOOR 1.0e-32f
-/* Maps new_w weights in place, using either one of the predefined functions, or a custom curve.
- * Return values are in new_w.
- * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real
- * vertex index (in case the weight tables do not cover the whole vertices...).
- * cmap might be NULL, in which case curve mapping mode will return unmodified data.
- */
void weightvg_do_map(
int num, float *new_w, short mode, struct CurveMapping *cmap, struct RNG *rng);
-/* Applies new_w weights to org_w ones, using either a texture, vgroup or constant value as factor.
- * Return values are in org_w.
- * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real
- * vertex index (in case the weight tables do not cover the whole vertices...).
- * XXX The standard "factor" value is assumed in [0.0, 1.0] range. Else, weird results might appear.
- */
void weightvg_do_mask(const ModifierEvalContext *ctx,
const int num,
const int *indices,
@@ -83,10 +71,6 @@ void weightvg_do_mask(const ModifierEvalContext *ctx,
Object *tex_map_object,
const char *tex_uvlayer_name);
-/* Applies weights to given vgroup (defgroup), and optionally add/remove vertices from the group.
- * If indices is not NULL, it must be a table of same length as weights, mapping to the real
- * vertex index (in case the weight table does not cover the whole vertices...).
- */
void weightvg_update_vg(struct MDeformVert *dvert,
int defgrp_idx,
struct MDeformWeight **dws,
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 9699b5f15dd..9b3bc4678a1 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -79,7 +79,8 @@ typedef struct Vert2GeomData {
float *dist[3];
} Vert2GeomData;
-/* Data which is localized to each computed chunk (i.e. thread-safe, and with continuous subset of index range). */
+/** Data which is localized to each computed chunk
+ * (i.e. thread-safe, and with continuous subset of index range). */
typedef struct Vert2GeomDataChunk {
/* Read-only data */
float last_hit_co[3][3];
@@ -110,8 +111,8 @@ static void vert2geom_task_cb_ex(void *__restrict userdata,
/* Note that we use local proximity heuristics (to reduce the nearest search).
*
* If we already had an hit before in same chunk of tasks (i.e. previous vertex by index),
- * we assume this vertex is going to have a close hit to that other vertex, so we can initiate
- * the "nearest.dist" with the expected value to that last hit.
+ * we assume this vertex is going to have a close hit to that other vertex,
+ * so we can initiate the "nearest.dist" with the expected value to that last hit.
* This will lead in pruning of the search tree.
*/
nearest.dist_sq = data_chunk->is_init[i] ?
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index b76a87d7132..80afcada4b9 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -33,8 +33,8 @@ set(INC
../makesdna
../makesrna
../render/extern/include
- ../../../intern/guardedalloc
../../../intern/glew-mx
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/nodes/NOD_common.h b/source/blender/nodes/NOD_common.h
index 7bbdc2129cd..26c78eab4ec 100644
--- a/source/blender/nodes/NOD_common.h
+++ b/source/blender/nodes/NOD_common.h
@@ -35,11 +35,11 @@ void register_node_type_group_output(void);
/* internal functions for editor */
struct bNodeSocket *node_group_find_input_socket(struct bNode *groupnode, const char *identifier);
struct bNodeSocket *node_group_find_output_socket(struct bNode *groupnode, const char *identifier);
-void node_group_verify(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
+void node_group_update(struct bNodeTree *ntree, struct bNode *node);
struct bNodeSocket *node_group_input_find_socket(struct bNode *node, const char *identifier);
struct bNodeSocket *node_group_output_find_socket(struct bNode *node, const char *identifier);
-void node_group_input_verify(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
-void node_group_output_verify(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
+void node_group_input_update(struct bNodeTree *ntree, struct bNode *node);
+void node_group_output_update(struct bNodeTree *ntree, struct bNode *node);
#endif /* __NOD_COMMON_H__ */
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index fd6435312b9..43a70a62350 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -247,11 +247,12 @@ void ntreeCompositExecTree(Scene *scene,
/* Update the outputs of the render layer nodes.
* Since the outputs depend on the render engine, this part is a bit complex:
- * - ntreeCompositUpdateRLayers is called and loops over all render layer nodes
- * - Each render layer node calls the update function of the render engine that's used for its scene
- * - The render engine calls RE_engine_register_pass for each pass
- * - RE_engine_register_pass calls ntreeCompositRegisterPass,
- * which calls node_cmp_rlayers_register_pass for every render layer node
+ * - ntreeCompositUpdateRLayers is called and loops over all render layer nodes.
+ * - Each render layer node calls the update function of the
+ * render engine that's used for its scene.
+ * - The render engine calls RE_engine_register_pass for each pass.
+ * - RE_engine_register_pass calls ntreeCompositRegisterPass,.
+ * which calls node_cmp_rlayers_register_pass for every render layer node.
*/
void ntreeCompositUpdateRLayers(bNodeTree *ntree)
{
@@ -292,7 +293,9 @@ void ntreeCompositTagRender(Scene *curscene)
/* XXX Think using G_MAIN here is valid, since you want to update current file's scene nodes,
* not the ones in temp main generated for rendering?
- * This is still rather weak though, ideally render struct would store own main AND original G_MAIN... */
+ * This is still rather weak though,
+ * ideally render struct would store own main AND original G_MAIN. */
+
for (sce = G_MAIN->scenes.first; sce; sce = sce->id.next) {
if (sce->nodetree) {
bNode *node;
diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c
index 1ba81330d72..b6cbffea413 100644
--- a/source/blender/nodes/composite/node_composite_util.c
+++ b/source/blender/nodes/composite/node_composite_util.c
@@ -33,8 +33,8 @@ void cmp_node_update_default(bNodeTree *UNUSED(ntree), bNode *node)
bNodeSocket *sock;
for (sock = node->outputs.first; sock; sock = sock->next) {
if (sock->cache) {
- //free_compbuf(sock->cache);
- //sock->cache = NULL;
+ // free_compbuf(sock->cache);
+ // sock->cache = NULL;
}
}
node->need_exec = 1;
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
index b0fbade8da4..db0689df775 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
+++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
@@ -36,7 +36,8 @@ static bNodeSocketTemplate cmp_node_colorbalance_out[] = {
};
/* Sync functions update formula parameters for other modes, such that the result is comparable.
- * Note that the results are not exactly the same due to differences in color handling (sRGB conversion happens for LGG),
+ * Note that the results are not exactly the same due to differences in color handling
+ * (sRGB conversion happens for LGG),
* but this keeps settings comparable.
*/
diff --git a/source/blender/nodes/composite/nodes/node_composite_common.c b/source/blender/nodes/composite/nodes/node_composite_common.c
index 78254cc7404..a22835ba85b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_common.c
+++ b/source/blender/nodes/composite/nodes/node_composite_common.c
@@ -53,7 +53,7 @@ void register_node_type_cmp_group(void)
node_type_socket_templates(&ntype, NULL, NULL);
node_type_size(&ntype, 140, 60, 400);
node_type_label(&ntype, node_group_label);
- node_type_update(&ntype, NULL, node_group_verify);
+ node_type_group_update(&ntype, node_group_update);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
index e4c9b8dd0cd..68a7e8d1589 100644
--- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
@@ -71,7 +71,8 @@ static void cryptomatte_add(NodeCryptomatte *n, float f)
/* Be aware that token_len still contains any trailing white space. */
token_len = token_end - (n->matte_id + start);
- /* If this has a leading bracket, assume a raw floating point number and look for the closing bracket. */
+ /* If this has a leading bracket,
+ * assume a raw floating point number and look for the closing bracket. */
if (n->matte_id[start] == '<') {
if (strncmp(n->matte_id + start, number, strlen(number)) == 0) {
/* This number is already there, so continue. */
@@ -152,7 +153,8 @@ static void cryptomatte_remove(NodeCryptomatte *n, float f)
if (token_len == 1) {
skip = true;
}
- /* If this has a leading bracket, assume a raw floating point number and look for the closing bracket. */
+ /* If this has a leading bracket,
+ * assume a raw floating point number and look for the closing bracket. */
else if (n->matte_id[start] == '<') {
if (strncmp(n->matte_id + start, number, strlen(number)) == 0) {
/* This number is already there, so skip it. */
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index a1649d9f8f0..e1e23b843a1 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -87,8 +87,11 @@ static void cmp_node_image_add_pass_output(bNodeTree *ntree,
if (sock_index < 0) {
/* The first 31 sockets always are the legacy hardcoded sockets.
- * Any dynamically allocated sockets follow afterwards, and are sorted in the order in which they were stored in the RenderResult.
- * Therefore, we remember the index of the last matched socket. New sockets are placed behind the previously traversed one, but always after the first 31. */
+ * Any dynamically allocated sockets follow afterwards,
+ * and are sorted in the order in which they were stored in the RenderResult.
+ * Therefore, we remember the index of the last matched socket.
+ * New sockets are placed behind the previously traversed one,
+ * but always after the first 31. */
int after_index = *prev_index;
if (is_rlayers && after_index < 30) {
after_index = 30;
@@ -340,7 +343,8 @@ static void cmp_node_rlayer_create_outputs(bNodeTree *ntree,
&prev_index);
}
-/* XXX make this into a generic socket verification function for dynamic socket replacement (multilayer, groups, static templates) */
+/* XXX make this into a generic socket verification function for dynamic socket replacement
+ * (multilayer, groups, static templates) */
static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rlayer)
{
bNodeSocket *sock, *sock_next;
@@ -363,7 +367,8 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl
* Another important detail comes from compatibility with the older socket model, where there
* was a fixed socket per pass type that was just hidden or not. Therefore, older versions expect
* the first 31 passes to belong to a specific pass type.
- * So, we keep those 31 always allocated before the others as well, even if they have no links attached. */
+ * So, we keep those 31 always allocated before the others as well,
+ * even if they have no links attached. */
sock_index = 0;
for (sock = node->outputs.first; sock; sock = sock_next, sock_index++) {
sock_next = sock->next;
@@ -446,7 +451,7 @@ void register_node_type_cmp_image(void)
cmp_node_type_base(&ntype, CMP_NODE_IMAGE, "Image", NODE_CLASS_INPUT, NODE_PREVIEW);
node_type_init(&ntype, node_composit_init_image);
node_type_storage(&ntype, "ImageUser", node_composit_free_image, node_composit_copy_image);
- node_type_update(&ntype, cmp_node_image_update, NULL);
+ node_type_update(&ntype, cmp_node_image_update);
node_type_label(&ntype, node_image_label);
nodeRegisterType(&ntype);
@@ -580,7 +585,7 @@ void register_node_type_cmp_rlayers(void)
ntype.initfunc_api = node_composit_init_rlayers;
ntype.poll = node_composit_poll_rlayers;
node_type_storage(&ntype, NULL, node_composit_free_rlayers, node_composit_copy_rlayers);
- node_type_update(&ntype, cmp_node_rlayers_update, NULL);
+ node_type_update(&ntype, cmp_node_rlayers_update);
node_type_init(&ntype, node_cmp_rlayers_outputs);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c
index 806a05757d0..c700aee1bc1 100644
--- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c
+++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c
@@ -281,7 +281,7 @@ void register_node_type_cmp_output_file(void)
node_type_socket_templates(&ntype, NULL, NULL);
ntype.initfunc_api = init_output_file;
node_type_storage(&ntype, "NodeImageMultiFile", free_output_file, copy_output_file);
- node_type_update(&ntype, update_output_file, NULL);
+ node_type_update(&ntype, update_output_file);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.c b/source/blender/nodes/composite/nodes/node_composite_scale.c
index 1a0268f2a3e..1304ba4c87a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_scale.c
+++ b/source/blender/nodes/composite/nodes/node_composite_scale.c
@@ -56,7 +56,7 @@ void register_node_type_cmp_scale(void)
cmp_node_type_base(&ntype, CMP_NODE_SCALE, "Scale", NODE_CLASS_DISTORT, 0);
node_type_socket_templates(&ntype, cmp_node_scale_in, cmp_node_scale_out);
- node_type_update(&ntype, node_composite_update_scale, NULL);
+ node_type_update(&ntype, node_composite_update_scale);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_switchview.c b/source/blender/nodes/composite/nodes/node_composite_switchview.c
index f61c6bdd83b..12401a8bbdf 100644
--- a/source/blender/nodes/composite/nodes/node_composite_switchview.c
+++ b/source/blender/nodes/composite/nodes/node_composite_switchview.c
@@ -148,7 +148,7 @@ void register_node_type_cmp_switch_view(void)
ntype.initfunc_api = init_switch_view;
- node_type_update(&ntype, cmp_node_switch_view_update, NULL);
+ node_type_update(&ntype, cmp_node_switch_view_update);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index ed4cdde67f0..2b6a89d5e65 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -179,18 +179,16 @@ static void group_verify_socket_list(
}
/* make sure all group node in ntree, which use ngroup, are sync'd */
-void node_group_verify(struct bNodeTree *ntree, struct bNode *node, struct ID *id)
+void node_group_update(struct bNodeTree *ntree, struct bNode *node)
{
/* check inputs and outputs, and remove or insert them */
- if (id == node->id) {
- if (id == NULL) {
- nodeRemoveAllSockets(ntree, node);
- }
- else {
- bNodeTree *ngroup = (bNodeTree *)node->id;
- group_verify_socket_list(ntree, node, &ngroup->inputs, &node->inputs, SOCK_IN);
- group_verify_socket_list(ntree, node, &ngroup->outputs, &node->outputs, SOCK_OUT);
- }
+ if (node->id == NULL) {
+ nodeRemoveAllSockets(ntree, node);
+ }
+ else {
+ bNodeTree *ngroup = (bNodeTree *)node->id;
+ group_verify_socket_list(ntree, node, &ngroup->inputs, &node->inputs, SOCK_IN);
+ group_verify_socket_list(ntree, node, &ngroup->outputs, &node->outputs, SOCK_OUT);
}
}
@@ -408,7 +406,7 @@ void BKE_node_tree_unlink_id(ID *id, struct bNodeTree *ntree)
static void node_group_input_init(bNodeTree *ntree, bNode *node)
{
- node_group_input_verify(ntree, node, (ID *)ntree);
+ node_group_input_update(ntree, node);
}
bNodeSocket *node_group_input_find_socket(bNode *node, const char *identifier)
@@ -422,19 +420,7 @@ bNodeSocket *node_group_input_find_socket(bNode *node, const char *identifier)
return NULL;
}
-void node_group_input_verify(bNodeTree *ntree, bNode *node, ID *id)
-{
- /* check inputs and outputs, and remove or insert them */
- if (id == (ID *)ntree) {
- /* value_in_out inverted for interface nodes to get correct socket value_property */
- group_verify_socket_list(ntree, node, &ntree->inputs, &node->outputs, SOCK_OUT);
-
- /* add virtual extension socket */
- nodeAddSocket(ntree, node, SOCK_OUT, "NodeSocketVirtual", "__extend__", "");
- }
-}
-
-static void node_group_input_update(bNodeTree *ntree, bNode *node)
+void node_group_input_update(bNodeTree *ntree, bNode *node)
{
bNodeSocket *extsock = node->outputs.last;
bNodeLink *link, *linknext, *exposelink;
@@ -480,7 +466,7 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->tonode, exposelink->tosock);
- node_group_input_verify(ntree, node, (ID *)ntree);
+ node_group_input_update(ntree, node);
newsock = node_group_input_find_socket(node, gsock->identifier);
/* redirect links from the extension socket */
@@ -490,6 +476,15 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
}
BLI_freelistN(&tmplinks);
+
+ /* check inputs and outputs, and remove or insert them */
+ {
+ /* value_in_out inverted for interface nodes to get correct socket value_property */
+ group_verify_socket_list(ntree, node, &ntree->inputs, &node->outputs, SOCK_OUT);
+
+ /* add virtual extension socket */
+ nodeAddSocket(ntree, node, SOCK_OUT, "NodeSocketVirtual", "__extend__", "");
+ }
}
void register_node_type_group_input(void)
@@ -500,7 +495,7 @@ void register_node_type_group_input(void)
node_type_base(ntype, NODE_GROUP_INPUT, "Group Input", NODE_CLASS_INTERFACE, 0);
node_type_size(ntype, 140, 80, 400);
node_type_init(ntype, node_group_input_init);
- node_type_update(ntype, node_group_input_update, node_group_input_verify);
+ node_type_update(ntype, node_group_input_update);
ntype->needs_free = 1;
nodeRegisterType(ntype);
@@ -508,7 +503,7 @@ void register_node_type_group_input(void)
static void node_group_output_init(bNodeTree *ntree, bNode *node)
{
- node_group_output_verify(ntree, node, (ID *)ntree);
+ node_group_output_update(ntree, node);
}
bNodeSocket *node_group_output_find_socket(bNode *node, const char *identifier)
@@ -522,19 +517,7 @@ bNodeSocket *node_group_output_find_socket(bNode *node, const char *identifier)
return NULL;
}
-void node_group_output_verify(bNodeTree *ntree, bNode *node, ID *id)
-{
- /* check inputs and outputs, and remove or insert them */
- if (id == (ID *)ntree) {
- /* value_in_out inverted for interface nodes to get correct socket value_property */
- group_verify_socket_list(ntree, node, &ntree->outputs, &node->inputs, SOCK_IN);
-
- /* add virtual extension socket */
- nodeAddSocket(ntree, node, SOCK_IN, "NodeSocketVirtual", "__extend__", "");
- }
-}
-
-static void node_group_output_update(bNodeTree *ntree, bNode *node)
+void node_group_output_update(bNodeTree *ntree, bNode *node)
{
bNodeSocket *extsock = node->inputs.last;
bNodeLink *link, *linknext, *exposelink;
@@ -581,7 +564,7 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
/* XXX what if connecting virtual to virtual socket?? */
gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->fromnode, exposelink->fromsock);
- node_group_output_verify(ntree, node, (ID *)ntree);
+ node_group_output_update(ntree, node);
newsock = node_group_output_find_socket(node, gsock->identifier);
/* redirect links to the extension socket */
@@ -591,6 +574,15 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
}
BLI_freelistN(&tmplinks);
+
+ /* check inputs and outputs, and remove or insert them */
+ {
+ /* value_in_out inverted for interface nodes to get correct socket value_property */
+ group_verify_socket_list(ntree, node, &ntree->outputs, &node->inputs, SOCK_IN);
+
+ /* add virtual extension socket */
+ nodeAddSocket(ntree, node, SOCK_IN, "NodeSocketVirtual", "__extend__", "");
+ }
}
void register_node_type_group_output(void)
@@ -601,7 +593,7 @@ void register_node_type_group_output(void)
node_type_base(ntype, NODE_GROUP_OUTPUT, "Group Output", NODE_CLASS_INTERFACE, 0);
node_type_size(ntype, 140, 80, 400);
node_type_init(ntype, node_group_output_init);
- node_type_update(ntype, node_group_output_update, node_group_output_verify);
+ node_type_update(ntype, node_group_output_update);
ntype->needs_free = 1;
nodeRegisterType(ntype);
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index 7fcba8cb472..24376e39f3d 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -169,7 +169,8 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context,
/* ensure all sock->link pointers and node levels are correct */
/* Using global main here is likely totally wrong, not sure what to do about that one though...
- * We cannot even check ntree is in global main, since most of the time it won't be (thanks to ntree design)!!! */
+ * We cannot even check ntree is in global main,
+ * since most of the time it won't be (thanks to ntree design)!!! */
ntreeUpdateTree(G.main, ntree);
/* get a dependency-sorted list of nodes */
diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c
index 4141ccccafa..6ad1c9b6925 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -86,7 +86,8 @@ void node_blend_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int ma
void node_image_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
{
- /* if there is no loaded image, return an empty string, and let nodeLabel() fill in the proper type translation. */
+ /* If there is no loaded image, return an empty string,
+ * and let nodeLabel() fill in the proper type translation. */
BLI_strncpy(label, (node->id) ? node->id->name + 2 : "", maxlen);
}
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index ed531a092ca..05ca9394786 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -68,7 +68,8 @@ static bool shader_tree_poll(const bContext *C, bNodeTreeType *UNUSED(treetype))
Scene *scene = CTX_data_scene(C);
const char *engine_id = scene->r.engine;
- /* allow empty engine string too, this is from older versions that didn't have registerable engines yet */
+ /* Allow empty engine string too,
+ * this is from older versions that didn't have registerable engines yet. */
return (engine_id[0] == '\0' || STREQ(engine_id, RE_engine_id_CYCLES) ||
!BKE_scene_use_shading_nodes_custom(scene));
}
@@ -235,8 +236,8 @@ static bNode *ntree_shader_relink_output_from_group(bNodeTree *ntree,
}
/* Need to update tree so all node instances nodes gets proper sockets. */
- node_group_verify(ntree, group_node, &group_ntree->id);
- node_group_output_verify(group_ntree, group_output_node, &group_ntree->id);
+ node_group_update(ntree, group_node);
+ node_group_output_update(group_ntree, group_output_node);
ntreeUpdateTree(G.main, group_ntree);
/* Remove other shader output nodes so that only the new one can be selected as active. */
@@ -576,9 +577,9 @@ static void ntree_shader_link_builtin_group_normal(bNodeTree *ntree,
group_ntree, SOCK_IN, "NodeSocketVector", "Normal");
/* Need to update tree so all node instances nodes gets proper sockets. */
bNode *group_input_node = ntreeFindType(group_ntree, NODE_GROUP_INPUT);
- node_group_verify(ntree, group_node, &group_ntree->id);
+ node_group_update(ntree, group_node);
if (group_input_node) {
- node_group_input_verify(group_ntree, group_input_node, &group_ntree->id);
+ node_group_input_update(group_ntree, group_input_node);
}
ntreeUpdateTree(G.main, group_ntree);
/* Assumes sockets are always added at the end. */
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index e75cb8a6642..2e8f81979a8 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -88,7 +88,8 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
memset(gs, 0, sizeof(*gs));
if (ns == NULL) {
- /* node_get_stack() will generate NULL bNodeStack pointers for unknown/unsupported types of sockets... */
+ /* node_get_stack() will generate NULL bNodeStack pointers
+ * for unknown/unsupported types of sockets. */
zero_v4(gs->vec);
gs->link = NULL;
gs->type = GPU_NONE;
diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c
index 489bb8c3557..ec1bb988c1c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_attribute.c
+++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c
@@ -42,7 +42,8 @@ static int node_shader_gpu_attribute(GPUMaterial *mat,
{
NodeShaderAttribute *attr = node->storage;
- /* FIXME : if an attribute layer (like vertex color) has one of theses name, it will not work as expected. */
+ /* FIXME : if an attribute layer (like vertex color) has one of theses name,
+ * it will not work as expected. */
if (strcmp(attr->name, "density") == 0) {
return GPU_stack_link(
mat, node, "node_attribute_volume_density", in, out, GPU_builtin(GPU_VOLUME_DENSITY));
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
index ce90933fcc4..4f78f2b6a76 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
@@ -129,7 +129,7 @@ void register_node_type_sh_bsdf_hair_principled(void)
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_init(&ntype, node_shader_init_hair_principled);
node_type_storage(&ntype, "", NULL, NULL);
- node_type_update(&ntype, node_shader_update_hair_principled, NULL);
+ node_type_update(&ntype, node_shader_update_hair_principled);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
index b45249e11b2..37c35c0adc8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
@@ -217,7 +217,7 @@ void register_node_type_sh_bsdf_principled(void)
node_type_init(&ntype, node_shader_init_principled);
node_type_storage(&ntype, "", NULL, NULL);
node_type_gpu(&ntype, node_shader_gpu_bsdf_principled);
- node_type_update(&ntype, node_shader_update_principled, NULL);
+ node_type_update(&ntype, node_shader_update_principled);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c
index 64dd2f28208..cee4d2505b2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_common.c
+++ b/source/blender/nodes/shader/nodes/node_shader_common.c
@@ -245,7 +245,7 @@ void register_node_type_sh_group(void)
node_type_socket_templates(&ntype, NULL, NULL);
node_type_size(&ntype, 140, 60, 400);
node_type_label(&ntype, node_group_label);
- node_type_update(&ntype, NULL, node_group_verify);
+ node_type_group_update(&ntype, node_group_update);
node_type_exec(&ntype, group_initexec, group_freeexec, group_execute);
node_type_gpu(&ntype, gpu_group_execute);
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c
index f8d1617887e..70432e04180 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.c
+++ b/source/blender/nodes/shader/nodes/node_shader_math.c
@@ -159,7 +159,8 @@ static void node_shader_exec_math(void *UNUSED(data),
else {
float y_mod_1 = fabsf(fmodf(b, 1.0f));
- /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */
+ /* if input value is not nearly an integer,
+ * fall back to zero, nicer than straight rounding. */
if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
r = powf(a, floorf(b + 0.5f));
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
index d590f229c1a..f1b4a0e9fe3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
+++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
@@ -107,7 +107,7 @@ void register_node_type_sh_subsurface_scattering(void)
node_type_init(&ntype, node_shader_init_subsurface_scattering);
node_type_storage(&ntype, "", NULL, NULL);
node_type_gpu(&ntype, node_shader_gpu_subsurface_scattering);
- node_type_update(&ntype, node_shader_update_subsurface_scattering, NULL);
+ node_type_update(&ntype, node_shader_update_subsurface_scattering);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
index d4dcb6857d2..91d58bc41d0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -110,10 +110,11 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
do_texco_extend = false;
}
- GPUNodeLink *norm, *col1, *col2, *col3, *input_coords;
+ GPUNodeLink *norm, *col1, *col2, *col3, *input_coords, *gpu_image;
+ GPUNodeLink *vnor, *nor_mat_inv, *blend;
+ GPUNodeLink **texco = &in[0].link;
int isdata = tex->color_space == SHD_COLORSPACE_NONE;
- float blend = tex->projection_blend;
if (!ima) {
return GPU_stack_link(mat, node, "node_tex_image_empty", in, out);
@@ -127,8 +128,8 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
}
BKE_image_release_ibuf(ima, ibuf, NULL);
- if (!in[0].link) {
- in[0].link = GPU_attribute(CD_MTFACE, "");
+ if (!*texco) {
+ *texco = GPU_attribute(CD_MTFACE, "");
}
node_shader_gpu_tex_mapping(mat, node, in, out);
@@ -136,80 +137,66 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
switch (tex->projection) {
case SHD_PROJ_FLAT:
if (do_texco_clip) {
- GPU_link(mat, "set_rgb", in[0].link, &input_coords);
+ GPU_link(mat, "set_rgb", *texco, &input_coords);
}
if (do_texco_extend) {
- GPU_link(mat, "point_texco_clamp", in[0].link, GPU_image(ima, iuser, isdata), &in[0].link);
+ GPU_link(mat, "point_texco_clamp", *texco, GPU_image(ima, iuser, isdata), texco);
}
GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
+
case SHD_PROJ_BOX:
- GPU_link(mat,
- "mat3_mul",
- GPU_builtin(GPU_VIEW_NORMAL),
- GPU_builtin(GPU_INVERSE_NORMAL_MATRIX),
- &norm);
- GPU_link(mat,
- gpu_node_name,
- in[0].link,
- norm,
- GPU_image(ima, iuser, isdata),
- &col1,
- &col2,
- &col3);
+ vnor = GPU_builtin(GPU_VIEW_NORMAL);
+ nor_mat_inv = GPU_builtin(GPU_INVERSE_NORMAL_MATRIX);
+ blend = GPU_uniform(&tex->projection_blend);
+ gpu_image = GPU_image(ima, iuser, isdata);
+
+ GPU_link(mat, "mat3_mul", vnor, nor_mat_inv, &norm);
+ GPU_link(
+ mat, gpu_node_name, *texco, norm, GPU_image(ima, iuser, isdata), &col1, &col2, &col3);
if (do_color_correction) {
GPU_link(mat, "srgb_to_linearrgb", col1, &col1);
GPU_link(mat, "srgb_to_linearrgb", col2, &col2);
GPU_link(mat, "srgb_to_linearrgb", col3, &col3);
}
- GPU_link(mat,
- "node_tex_image_box",
- in[0].link,
- norm,
- col1,
- col2,
- col3,
- GPU_image(ima, iuser, isdata),
- GPU_uniform(&blend),
- &out[0].link,
- &out[1].link);
+ GPU_stack_link(
+ mat, node, "node_tex_image_box", in, out, norm, col1, col2, col3, gpu_image, blend);
break;
+
case SHD_PROJ_SPHERE:
- GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link);
- GPU_link(mat, "point_map_to_sphere", in[0].link, &in[0].link);
+ GPU_link(mat, "point_texco_remap_square", *texco, texco);
+ GPU_link(mat, "point_map_to_sphere", *texco, texco);
if (do_texco_clip) {
- GPU_link(mat, "set_rgb", in[0].link, &input_coords);
+ GPU_link(mat, "set_rgb", *texco, &input_coords);
}
if (do_texco_extend) {
- GPU_link(mat, "point_texco_clamp", in[0].link, GPU_image(ima, iuser, isdata), &in[0].link);
+ GPU_link(mat, "point_texco_clamp", *texco, GPU_image(ima, iuser, isdata), texco);
}
GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
+
case SHD_PROJ_TUBE:
- GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link);
- GPU_link(mat, "point_map_to_tube", in[0].link, &in[0].link);
+ GPU_link(mat, "point_texco_remap_square", *texco, texco);
+ GPU_link(mat, "point_map_to_tube", *texco, texco);
if (do_texco_clip) {
- GPU_link(mat, "set_rgb", in[0].link, &input_coords);
+ GPU_link(mat, "set_rgb", *texco, &input_coords);
}
if (do_texco_extend) {
- GPU_link(mat, "point_texco_clamp", in[0].link, GPU_image(ima, iuser, isdata), &in[0].link);
+ GPU_link(mat, "point_texco_clamp", *texco, GPU_image(ima, iuser, isdata), texco);
}
GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
}
- if (do_texco_clip && (tex->projection != SHD_PROJ_BOX)) {
- GPU_link(mat,
- names_clip[tex->interpolation],
- input_coords,
- GPU_image(ima, iuser, isdata),
- out[0].link,
- &out[0].link,
- &out[1].link);
- }
-
- if (do_color_correction && (tex->projection != SHD_PROJ_BOX)) {
- GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
+ if (tex->projection != SHD_PROJ_BOX) {
+ if (do_texco_clip) {
+ gpu_node_name = names_clip[tex->interpolation];
+ GPU_stack_link(
+ mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata), out[0].link);
+ }
+ if (do_color_correction) {
+ GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
+ }
}
return true;
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
index 99668741f65..e0b4de985d8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
@@ -122,7 +122,7 @@ void register_node_type_sh_tex_voronoi(void)
node_type_storage(
&ntype, "NodeTexVoronoi", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_voronoi);
- node_type_update(&ntype, node_shader_update_tex_voronoi, NULL);
+ node_type_update(&ntype, node_shader_update_tex_voronoi);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index 60630da586d..43deea9c2de 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -325,8 +325,9 @@ int ntreeTexExecTree(bNodeTree *nodes,
retval |= TEX_NOR;
}
retval |= TEX_RGB;
- /* confusing stuff; the texture output node sets this to NULL to indicate no normal socket was set
- * however, the texture code checks this for other reasons (namely, a normal is required for material) */
+ /* confusing stuff; the texture output node sets this to NULL to indicate no normal socket was
+ * set however, the texture code checks this for other reasons
+ * (namely, a normal is required for material). */
texres->nor = nor;
return retval;
diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c
index 929bf92dec3..b8435d3a352 100644
--- a/source/blender/nodes/texture/nodes/node_texture_common.c
+++ b/source/blender/nodes/texture/nodes/node_texture_common.c
@@ -174,7 +174,7 @@ void register_node_type_tex_group(void)
node_type_socket_templates(&ntype, NULL, NULL);
node_type_size(&ntype, 140, 60, 400);
node_type_label(&ntype, node_group_label);
- node_type_update(&ntype, NULL, node_group_verify);
+ node_type_group_update(&ntype, node_group_update);
node_type_exec(&ntype, group_initexec, group_freeexec, group_execute);
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c
index bf7cdf18d44..b0b646dfd16 100644
--- a/source/blender/nodes/texture/nodes/node_texture_proc.c
+++ b/source/blender/nodes/texture/nodes/node_texture_proc.c
@@ -44,7 +44,8 @@ static bNodeSocketTemplate outputs_color_only[] = {{SOCK_RGBA, 0, N_("Color")},
SOCK_RGBA, 1, "Color 2", 1.0f, 1.0f, 1.0f, 1.0f \
}
-/* Calls multitex and copies the result to the outputs. Called by xxx_exec, which handles inputs. */
+/* Calls multitex and copies the result to the outputs.
+ * Called by xxx_exec, which handles inputs. */
static void do_proc(float *result,
TexParams *p,
const float col1[4],
diff --git a/source/blender/physics/CMakeLists.txt b/source/blender/physics/CMakeLists.txt
index e40d1de666b..edcfdceb697 100644
--- a/source/blender/physics/CMakeLists.txt
+++ b/source/blender/physics/CMakeLists.txt
@@ -21,8 +21,8 @@
set(INC
.
intern
- ../blenlib
../blenkernel
+ ../blenlib
../depsgraph
../imbuf
../makesdna
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index 8eb22bd57ad..f7a9cadc9cf 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -232,7 +232,7 @@ static void cloth_setup_constraints(ClothModifierData *clmd,
ColliderContacts *ct = &contacts[i];
for (j = 0; j < ct->totcollisions; ++j) {
CollPair *collpair = &ct->collisions[j];
- // float restitution = (1.0f - clmd->coll_parms->damping) * (1.0f - ct->ob->pd->pdef_sbdamp);
+ // float restitution = (1.0f - clmd->coll_parms->damping) * (1.0f - ct->ob->pd->pdef_sbdamp);
float restitution = 0.0f;
int v = collpair->face1;
float impulse[3];
@@ -334,7 +334,7 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob),
sub_v3_v3v3(vec, cos[i], cv->tx);
mul_v3_fl(vec, cv->mass * dt * 20.0f);
add_v3_v3(cv->tv, vec);
- //copy_v3_v3(cv->tx, cos[i]);
+ // copy_v3_v3(cv->tx, cos[i]);
}
MEM_freeN(cos);
@@ -382,8 +382,9 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
k_tension = scaling_tension / (parms->avg_spring_len + FLT_EPSILON);
if (s->type & CLOTH_SPRING_TYPE_SEWING) {
- // TODO: verify, half verified (couldn't see error)
- // sewing springs usually have a large distance at first so clamp the force so we don't get tunnelling through colission objects
+ /* TODO: verify, half verified (couldn't see error)
+ * sewing springs usually have a large distance at first so clamp the force so we don't get
+ * tunnelling through colission objects */
BPH_mass_spring_force_spring_linear(data,
s->ij,
s->kl,
@@ -459,9 +460,9 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
- /* XXX WARNING: angular bending springs for hair apply stiffness factor as an overall factor, unlike cloth springs!
- * this is crap, but needed due to cloth/hair mixing ...
- * max_bend factor is not even used for hair, so ...
+ /* XXX WARNING: angular bending springs for hair apply stiffness factor as an overall factor,
+ * unlike cloth springs! this is crap, but needed due to cloth/hair mixing ... max_bend factor
+ * is not even used for hair, so ...
*/
scaling = s->lin_stiffness * parms->bending;
kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
@@ -469,7 +470,8 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
// Fix for [#45084] for cloth stiffness must have cb proportional to kb
cb = kb * parms->bending_damping;
- /* XXX assuming same restlen for ij and jk segments here, this can be done correctly for hair later */
+ /* XXX assuming same restlen for ij and jk segments here,
+ * this can be done correctly for hair later. */
BPH_mass_spring_force_spring_bending_hair(data, s->ij, s->kl, s->mn, s->target, kb, cb);
# if 0
@@ -487,8 +489,8 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
BKE_sim_debug_data_add_vector(
clmd->debug_data, x_kl, d, 0.8, 0.8, 0.2, "target", 7982, s->kl);
- // copy_v3_v3(d, s->target_ij);
- // BKE_sim_debug_data_add_vector(clmd->debug_data, x, d, 1, 0.4, 0.4, "target", 7983, s->kl);
+ // copy_v3_v3(d, s->target_ij);
+ // BKE_sim_debug_data_add_vector(clmd->debug_data, x, d, 1, 0.4, 0.4, "target", 7983, s->kl);
}
# endif
#endif
@@ -861,12 +863,18 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
BPH_hair_volume_grid_interpolate(grid, x, &gdensity, gvel, gvel_smooth, NULL, NULL);
- // BKE_sim_debug_data_add_circle(clmd->debug_data, x, gdensity, 0.7, 0.3, 1, "grid density", i, j, 3111);
+ // BKE_sim_debug_data_add_circle(
+ // clmd->debug_data, x, gdensity, 0.7, 0.3, 1,
+ // "grid density", i, j, 3111);
if (!is_zero_v3(gvel) || !is_zero_v3(gvel_smooth)) {
float dvel[3];
sub_v3_v3v3(dvel, gvel_smooth, gvel);
- // BKE_sim_debug_data_add_vector(clmd->debug_data, x, gvel, 0.4, 0, 1, "grid velocity", i, j, 3112);
- // BKE_sim_debug_data_add_vector(clmd->debug_data, x, gvel_smooth, 0.6, 1, 1, "grid velocity", i, j, 3113);
+ // BKE_sim_debug_data_add_vector(
+ // clmd->debug_data, x, gvel, 0.4, 0, 1,
+ // "grid velocity", i, j, 3112);
+ // BKE_sim_debug_data_add_vector(
+ // clmd->debug_data, x, gvel_smooth, 0.6, 1, 1,
+ // "grid velocity", i, j, 3113);
BKE_sim_debug_data_add_vector(
clmd->debug_data, x, dvel, 0.4, 1, 0.7, "grid velocity", i, j, 3114);
# if 0
@@ -875,10 +883,16 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
float col1[3] = {0.0, 1.0, 0.0};
float col[3];
- interp_v3_v3v3(col, col0, col1, CLAMPIS(gdensity * clmd->sim_parms->density_strength, 0.0, 1.0));
-// BKE_sim_debug_data_add_circle(clmd->debug_data, x, gdensity * clmd->sim_parms->density_strength, 0, 1, 0.4, "grid velocity", i, j, 3115);
-// BKE_sim_debug_data_add_dot(clmd->debug_data, x, col[0], col[1], col[2], "grid velocity", i, j, 3115);
- BKE_sim_debug_data_add_circle(clmd->debug_data, x, 0.01f, col[0], col[1], col[2], "grid velocity", i, j, 3115);
+ interp_v3_v3v3(col, col0, col1,
+ CLAMPIS(gdensity * clmd->sim_parms->density_strength, 0.0, 1.0));
+ // BKE_sim_debug_data_add_circle(
+ // clmd->debug_data, x, gdensity * clmd->sim_parms->density_strength, 0, 1, 0.4,
+ // "grid velocity", i, j, 3115);
+ // BKE_sim_debug_data_add_dot(
+ // clmd->debug_data, x, col[0], col[1], col[2],
+ // "grid velocity", i, j, 3115);
+ BKE_sim_debug_data_add_circle(
+ clmd->debug_data, x, 0.01f, col[0], col[1], col[2], "grid velocity", i, j, 3115);
}
# endif
}
@@ -1118,7 +1132,8 @@ int BPH_cloth_solve(
if (clmd->sim_parms->vgroup_mass > 0) {
if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) {
float x[3];
- /* divide by time_scale to prevent pinned vertices' delta locations from being multiplied */
+ /* divide by time_scale to prevent pinned vertices'
+ * delta locations from being multiplied */
interp_v3_v3v3(
x, verts[i].xold, verts[i].xconst, (step + dt) / clmd->sim_parms->time_scale);
BPH_mass_spring_set_position(id, i, x);
diff --git a/source/blender/physics/intern/ConstrainedConjugateGradient.h b/source/blender/physics/intern/ConstrainedConjugateGradient.h
index 8d375d00056..4a0a6ab298c 100644
--- a/source/blender/physics/intern/ConstrainedConjugateGradient.h
+++ b/source/blender/physics/intern/ConstrainedConjugateGradient.h
@@ -31,9 +31,11 @@ namespace internal {
* \param rhs: The right hand side vector b
* \param x: On input and initial solution, on output the computed solution.
* \param precond: A preconditioner being able to efficiently solve for an
- * approximation of Ax=b (regardless of b)
- * \param iters: On input the max number of iteration, on output the number of performed iterations.
- * \param tol_error: On input the tolerance error, on output an estimation of the relative error.
+ * approximation of Ax=b (regardless of b)
+ * \param iters: On input the max number of iteration,
+ * on output the number of performed iterations.
+ * \param tol_error: On input the tolerance error,
+ * on output an estimation of the relative error.
*/
template<typename MatrixType,
typename Rhs,
@@ -59,7 +61,7 @@ EIGEN_DONT_INLINE void constrained_conjugate_gradient(const MatrixType &mat,
int n = mat.cols();
- VectorType residual = filter * (rhs - mat * x); //initial residual
+ VectorType residual = filter * (rhs - mat * x); // initial residual
RealScalar rhsNorm2 = (filter * rhs).squaredNorm();
if (rhsNorm2 == 0) {
@@ -78,7 +80,7 @@ EIGEN_DONT_INLINE void constrained_conjugate_gradient(const MatrixType &mat,
}
VectorType p(n);
- p = filter * precond.solve(residual); //initial search direction
+ p = filter * precond.solve(residual); // initial search direction
VectorType z(n), tmp(n);
RealScalar absNew = numext::real(
@@ -157,17 +159,18 @@ struct traits<
/** \ingroup IterativeLinearSolvers_Module
* \brief A conjugate gradient solver for sparse self-adjoint problems with additional constraints
*
- * This class allows to solve for A.x = b sparse linear problems using a conjugate gradient algorithm.
- * The sparse matrix A must be selfadjoint. The vectors x and b can be either dense or sparse.
+ * This class allows to solve for A.x = b sparse linear problems using a conjugate gradient
+ * algorithm. The sparse matrix A must be selfadjoint. The vectors x and b can be either dense or
+ * sparse.
*
* \tparam _MatrixType the type of the sparse matrix A, can be a dense or a sparse matrix.
* \tparam _UpLo the triangular part that will be used for the computations. It can be Lower
* or Upper. Default is Lower.
* \tparam _Preconditioner the type of the preconditioner. Default is DiagonalPreconditioner
*
- * The maximal number of iterations and tolerance value can be controlled via the setMaxIterations()
- * and setTolerance() methods. The defaults are the size of the problem for the maximal number of iterations
- * and NumTraits<Scalar>::epsilon() for the tolerance.
+ * The maximal number of iterations and tolerance value can be controlled via the
+ * setMaxIterations() and setTolerance() methods. The defaults are the size of the problem for the
+ * maximal number of iterations and NumTraits<Scalar>::epsilon() for the tolerance.
*
* This class can be used as the direct solver classes. Here is a typical usage example:
* \code
diff --git a/source/blender/physics/intern/eigen_utils.h b/source/blender/physics/intern/eigen_utils.h
index 7d56fe1a608..361ebadf5d2 100644
--- a/source/blender/physics/intern/eigen_utils.h
+++ b/source/blender/physics/intern/eigen_utils.h
@@ -140,8 +140,9 @@ typedef Eigen::SparseMatrix<Scalar> lMatrix;
/* Constructor type that provides more convenient handling of Eigen triplets
* for efficient construction of sparse 3x3 block matrices.
- * This should be used for building lMatrix instead of writing to such lMatrix directly (which is very inefficient).
- * After all elements have been defined using the set() method, the actual matrix can be filled using construct().
+ * This should be used for building lMatrix instead of writing to such lMatrix directly (which is
+ * very inefficient). After all elements have been defined using the set() method, the actual
+ * matrix can be filled using construct().
*/
struct lMatrix3fCtor {
lMatrix3fCtor()
diff --git a/source/blender/physics/intern/hair_volume.cpp b/source/blender/physics/intern/hair_volume.cpp
index 44d2aaceac5..a07d1fe8f75 100644
--- a/source/blender/physics/intern/hair_volume.cpp
+++ b/source/blender/physics/intern/hair_volume.cpp
@@ -487,7 +487,9 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
BKE_sim_debug_data_add_dot(x2w, 0.1, 0.1, 0.7, "grid", 649, debug_i, j, k);
BKE_sim_debug_data_add_line(wloc, x2w, 0.3, 0.8, 0.3, "grid", 253, debug_i, j, k);
BKE_sim_debug_data_add_line(wloc, x3w, 0.8, 0.3, 0.3, "grid", 254, debug_i, j, k);
-// BKE_sim_debug_data_add_circle(x2w, len_v3v3(wloc, x2w), 0.2, 0.7, 0.2, "grid", 255, i, j, k);
+ // BKE_sim_debug_data_add_circle(
+ // x2w, len_v3v3(wloc, x2w), 0.2, 0.7, 0.2,
+ // "grid", 255, i, j, k);
}
}
# endif
@@ -980,7 +982,9 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid,
if (!is_margin) {
float dvel[3];
sub_v3_v3v3(dvel, vert->velocity_smooth, vert->velocity);
- // BKE_sim_debug_data_add_vector(grid->debug_data, wloc, dvel, 1, 1, 1, "grid", 5566, i, j, k);
+ // BKE_sim_debug_data_add_vector(
+ // grid->debug_data, wloc, dvel, 1, 1, 1,
+ // "grid", 5566, i, j, k);
}
if (!is_margin) {
@@ -990,8 +994,11 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid,
float col[3];
interp_v3_v3v3(col, col0, colp, d);
- // if (d > 0.05f)
- // BKE_sim_debug_data_add_dot(grid->debug_data, wloc, col[0], col[1], col[2], "grid", 5544, i, j, k);
+ // if (d > 0.05f) {
+ // BKE_sim_debug_data_add_dot(
+ // grid->debug_data, wloc, col[0], col[1], col[2],
+ // "grid", 5544, i, j, k);
+ // }
}
}
}
diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c
index 654825e814b..cdd4d66d485 100644
--- a/source/blender/physics/intern/implicit_blender.c
+++ b/source/blender/physics/intern/implicit_blender.c
@@ -766,7 +766,9 @@ DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
}
}
-# if 0 /* this version of the CG algorithm does not work very well with partial constraints (where S has non-zero elements) */
+/* this version of the CG algorithm does not work very well with partial constraints
+ * (where S has non-zero elements). */
+# if 0
static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S)
{
// Solves for unknown X in equation AX=B
@@ -1455,7 +1457,8 @@ static float calc_nor_area_tri(float nor[3],
return normalize_v3(nor);
}
-/* XXX does not support force jacobians yet, since the effector system does not provide them either */
+/* 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])
{
@@ -1538,7 +1541,7 @@ void BPH_mass_spring_force_vertex_wind(Implicit_Data *data,
BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, float L, float k)
{
// dir is unit length direction, rest is spring's restlength, k is spring constant.
- //return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k;
+ // return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k;
outerproduct(to, dir, dir);
sub_m3_m3m3(to, I, to);
@@ -1699,7 +1702,8 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data,
dfdx_spring(dfdx, dir, length, restlen, stiffness_tension);
}
else if (new_compress) {
- /* This is based on the Choi and Ko bending model, which works surprisingly well for compression. */
+ /* This is based on the Choi and Ko bending model,
+ * which works surprisingly well for compression. */
float kb = stiffness_compression;
float cb = kb; /* cb equal to kb seems to work, but a factor can be added if necessary */
@@ -1828,7 +1832,8 @@ BLI_INLINE void spring_angle(Implicit_Data *data,
sub_v3_v3(r_vel_b, vel_e);
}
-/* Angular springs roughly based on the bending model proposed by Baraff and Witkin in "Large Steps in Cloth Simulation". */
+/* Angular springs roughly based on the bending model proposed by Baraff and Witkin in "Large Steps
+ * in Cloth Simulation". */
bool BPH_mass_spring_force_spring_angular(Implicit_Data *data,
int i,
int j,
diff --git a/source/blender/physics/intern/implicit_eigen.cpp b/source/blender/physics/intern/implicit_eigen.cpp
index cfa3d653961..04ca24e0382 100644
--- a/source/blender/physics/intern/implicit_eigen.cpp
+++ b/source/blender/physics/intern/implicit_eigen.cpp
@@ -182,8 +182,9 @@ typedef Eigen::SparseMatrix<Scalar> lMatrix;
/* Constructor type that provides more convenient handling of Eigen triplets
* for efficient construction of sparse 3x3 block matrices.
- * This should be used for building lMatrix instead of writing to such lMatrix directly (which is very inefficient).
- * After all elements have been defined using the set() method, the actual matrix can be filled using construct().
+ * This should be used for building lMatrix instead of writing to such lMatrix directly (which is
+ * very inefficient). After all elements have been defined using the set() method, the actual
+ * matrix can be filled using construct().
*/
struct lMatrixCtor {
lMatrixCtor()
@@ -814,7 +815,8 @@ static float calc_nor_area_tri(float nor[3],
return normalize_v3(nor);
}
-/* XXX does not support force jacobians yet, since the effector system does not provide them either */
+/* 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])
{
@@ -855,8 +857,8 @@ void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, const
BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, float L, float k)
{
- // dir is unit length direction, rest is spring's restlength, k is spring constant.
- //return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k;
+ /* dir is unit length direction, rest is spring's restlength, k is spring constant. */
+ // return ((I - outerprod(dir, dir)) * Min(1.0f, rest / length) - I) * -k;
outerproduct(to, dir, dir);
sub_m3_m3m3(to, I, to);
diff --git a/source/blender/python/bmesh/CMakeLists.txt b/source/blender/python/bmesh/CMakeLists.txt
index 14baa08abc1..3875057185a 100644
--- a/source/blender/python/bmesh/CMakeLists.txt
+++ b/source/blender/python/bmesh/CMakeLists.txt
@@ -17,9 +17,9 @@
set(INC
.
- ../../bmesh
../../blenkernel
../../blenlib
+ ../../bmesh
../../depsgraph
../../makesdna
../../../../intern/guardedalloc
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index f540b2e102c..eb611e6566a 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -875,10 +875,20 @@ static PyGetSetDef bpy_bmface_getseters[] = {
};
static PyGetSetDef bpy_bmloop_getseters[] = {
- /* generic */
- /* flags are available but not used for loops. */
- // {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
- // {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN},
+/* generic */
+/* flags are available but not used for loops. */
+#if 0
+ {(char *)"select",
+ (getter)bpy_bm_elem_hflag_get,
+ (setter)bpy_bm_elem_hflag_set,
+ (char *)bpy_bm_elem_select_doc,
+ (void *)BM_ELEM_SELECT},
+ {(char *)"hide",
+ (getter)bpy_bm_elem_hflag_get,
+ (setter)bpy_bm_elem_hflag_set,
+ (char *)bpy_bm_elem_hide_doc,
+ (void *)BM_ELEM_HIDDEN},
+#endif
{(char *)"tag",
(getter)bpy_bm_elem_hflag_get,
(setter)bpy_bm_elem_hflag_set,
diff --git a/source/blender/python/generic/CMakeLists.txt b/source/blender/python/generic/CMakeLists.txt
index fa73f161a5d..c878103e19d 100644
--- a/source/blender/python/generic/CMakeLists.txt
+++ b/source/blender/python/generic/CMakeLists.txt
@@ -21,8 +21,8 @@ set(INC
../../blenlib
../../gpu
../../makesdna
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index 056e3a33b6e..dd5baaa661c 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -164,7 +164,8 @@ PyObject *BPy_IDGroup_WrapData(ID *id, IDProperty *prop, IDProperty *parent)
}
}
-#if 0 /* UNUSED, currently assignment overwrites into new properties, rather than setting in-place */
+/* UNUSED, currently assignment overwrites into new properties, rather than setting in-place. */
+#if 0
static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject *value)
{
switch (prop->type) {
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 191863a862d..25549c95896 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -37,7 +37,8 @@
#include "BLI_string.h"
#ifndef MATH_STANDALONE
-/* only for BLI_strncpy_wchar_from_utf8, should replace with py funcs but too late in release now */
+/* Only for BLI_strncpy_wchar_from_utf8,
+ * should replace with py funcs but too late in release now. */
# include "BLI_string_utf8.h"
#endif
@@ -273,7 +274,8 @@ void PyC_ObSpitStr(char *result, size_t result_len, PyObject *var)
const PyTypeObject *type = Py_TYPE(var);
PyObject *var_str = PyObject_Repr(var);
if (var_str == NULL) {
- /* We could print error here, but this may be used for generating errors - so don't for now. */
+ /* We could print error here,
+ * but this may be used for generating errors - so don't for now. */
PyErr_Clear();
}
BLI_snprintf(result,
@@ -765,7 +767,8 @@ void PyC_MainModule_Restore(PyObject *main_mod)
Py_XDECREF(main_mod);
}
-/* must be called before Py_Initialize, expects output of BKE_appdir_folder_id(BLENDER_PYTHON, NULL) */
+/* Must be called before Py_Initialize,
+ * expects output of BKE_appdir_folder_id(BLENDER_PYTHON, NULL). */
void PyC_SetHomePath(const char *py_path_bundle)
{
if (py_path_bundle == NULL) {
@@ -803,7 +806,8 @@ void PyC_SetHomePath(const char *py_path_bundle)
{
static wchar_t py_path_bundle_wchar[1024];
- /* cant use this, on linux gives bug: #23018, TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 22008 */
+ /* Can't use this, on linux gives bug: #23018,
+ * TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 2008 */
/* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */
BLI_strncpy_wchar_from_utf8(
diff --git a/source/blender/python/generic/python_utildefines.h b/source/blender/python/generic/python_utildefines.h
index 40cec436dea..653122c9c33 100644
--- a/source/blender/python/generic/python_utildefines.h
+++ b/source/blender/python/generic/python_utildefines.h
@@ -45,7 +45,8 @@ Py_LOCAL_INLINE(PyObject *) Py_INCREF_RET(PyObject *op)
return op;
}
-/* append & transfer ownership to the list, avoids inline Py_DECREF all over (which is quite a large macro) */
+/* Append & transfer ownership to the list,
+ * avoids inline Py_DECREF all over (which is quite a large macro). */
Py_LOCAL_INLINE(int) PyList_APPEND(PyObject *op, PyObject *v)
{
int ret = PyList_Append(op, v);
diff --git a/source/blender/python/gpu/CMakeLists.txt b/source/blender/python/gpu/CMakeLists.txt
index cda866510e3..ca0e6ced42b 100644
--- a/source/blender/python/gpu/CMakeLists.txt
+++ b/source/blender/python/gpu/CMakeLists.txt
@@ -21,8 +21,8 @@ set(INC
../../blenlib
../../gpu
../../makesdna
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c
index 094052b724f..a9e65413767 100644
--- a/source/blender/python/gpu/gpu_py_batch.c
+++ b/source/blender/python/gpu/gpu_py_batch.c
@@ -127,7 +127,8 @@ PyDoc_STRVAR(bpygpu_Batch_vertbuf_add_doc,
" Add another vertex buffer to the Batch.\n"
" It is not possible to add more vertices to the batch using this method.\n"
" Instead it can be used to add more attributes to the existing vertices.\n"
-" A good use case would be when you have a separate vertex buffer for vertex positions and vertex normals.\n"
+" A good use case would be when you have a separate\n"
+" vertex buffer for vertex positions and vertex normals.\n"
" Current a batch can have at most " STRINGIFY(GPU_BATCH_VBO_MAX_LEN) " vertex buffers.\n"
"\n"
" :param buf: The vertex buffer that will be added to the batch.\n"
diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt
index 7eb008efeef..fc945562c98 100644
--- a/source/blender/python/intern/CMakeLists.txt
+++ b/source/blender/python/intern/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenlib
../../blenloader
../../blentranslation
+ ../../depsgraph
../../editors/include
../../gpu
../../imbuf
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 08f4df543a8..92ba7704b19 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -177,7 +177,8 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
return NULL;
}
- /* same logic as BKE_appdir_folder_id_create(), but best leave it up to the script author to create */
+ /* same logic as BKE_appdir_folder_id_create(),
+ * but best leave it up to the script author to create */
path = BKE_appdir_folder_id_user_notest(folder_id, subdir);
return PyC_UnicodeFromByte(path ? path : "");
diff --git a/source/blender/python/intern/bpy_app_ocio.c b/source/blender/python/intern/bpy_app_ocio.c
index 2a56075e00e..9dcadbac2af 100644
--- a/source/blender/python/intern/bpy_app_ocio.c
+++ b/source/blender/python/intern/bpy_app_ocio.c
@@ -40,10 +40,12 @@ static PyStructSequence_Field app_ocio_info_fields[] = {
};
static PyStructSequence_Desc app_ocio_info_desc = {
- (char *)"bpy.app.ocio", /* name */
- (char
- *)"This module contains information about OpenColorIO blender is linked against", /* doc */
- app_ocio_info_fields, /* fields */
+ /* name */
+ (char *)"bpy.app.ocio",
+ /* doc */
+ (char *)"This module contains information about OpenColorIO blender is linked against",
+ /* fields */
+ app_ocio_info_fields,
ARRAY_SIZE(app_ocio_info_fields) - 1,
};
diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c
index 56de6dd1405..a48cd742448 100644
--- a/source/blender/python/intern/bpy_app_translations.c
+++ b/source/blender/python/intern/bpy_app_translations.c
@@ -47,13 +47,16 @@
typedef struct {
PyObject_HEAD
- /* The string used to separate context from actual message in PY_TRANSLATE RNA props. */
+ /** The string used to separate context from actual message in PY_TRANSLATE RNA props. */
const char *context_separator;
- /* A "named tuple" (StructSequence actually...) containing all C-defined contexts. */
+ /** A "named tuple" (StructSequence actually...) containing all C-defined contexts. */
PyObject *contexts;
- /* A readonly mapping {C context id: python id} (actually, a MappingProxy). */
+ /** A readonly mapping {C context id: python id} (actually, a MappingProxy). */
PyObject *contexts_C_to_py;
- /* A py dict containing all registered py dicts (order is more or less random, first match wins!). */
+ /**
+ * A py dict containing all registered py dicts
+ * (order is more or less random, first match wins!).
+ */
PyObject *py_messages;
} BlenderAppTranslations;
@@ -111,8 +114,8 @@ static void _ghashutil_keyfree(void *ptr)
/***** Python's messages cache *****/
/* We cache all messages available for a given locale from all py dicts into a single ghash.
- * Changing of locale is not so common, while looking for a message translation is, so let's try to optimize
- * the later as much as we can!
+ * Changing of locale is not so common, while looking for a message translation is,
+ * so let's try to optimize the later as much as we can!
* Note changing of locale, as well as (un)registering a message dict, invalidate that cache.
*/
static GHash *_translations_cache = NULL;
@@ -148,7 +151,8 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale)
printf("\n");
# endif
- /* Try to get first complete locale, then language+country, then language+variant, then only language */
+ /* Try to get first complete locale, then language+country,
+ * then language+variant, then only language. */
lang_dict = PyDict_GetItemString(uuid_dict, locale);
if (!lang_dict && language_country) {
lang_dict = PyDict_GetItemString(uuid_dict, language_country);
@@ -393,8 +397,8 @@ static PyTypeObject BlenderAppTranslationsContextsType;
static BLT_i18n_contexts_descriptor _contexts[] = BLT_I18NCONTEXTS_DESC;
/* These fields are just empty placeholders, actual values get set in app_translations_struct().
- * This allows us to avoid many handwriting, and above all, to keep all context definition stuff in BLT_translation.h!
- */
+ * This allows us to avoid many handwriting, and above all,
+ * to keep all context definition stuff in BLT_translation.h! */
static PyStructSequence_Field app_translations_contexts_fields[ARRAY_SIZE(_contexts)] = {{NULL}};
static PyStructSequence_Desc app_translations_contexts_desc = {
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index 3457e614708..726599ff06e 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -54,7 +54,10 @@ extern void BPY_update_rna_module(void);
# include <opcode.h>
#endif
-/* for pydrivers (drivers using one-line Python expressions to express relationships between targets) */
+/**
+ * For PyDrivers
+ * (drivers using one-line Python expressions to express relationships between targets).
+ */
PyObject *bpy_pydriver_Dict = NULL;
#ifdef USE_BYTECODE_WHITELIST
@@ -399,8 +402,10 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
{
PyObject *driver_vars = NULL;
PyObject *retval = NULL;
- PyObject *
- expr_vars; /* speed up by pre-hashing string & avoids re-converting unicode strings for every execution */
+
+ /* Speed up by pre-hashing string & avoids re-converting unicode strings for every execution. */
+ PyObject *expr_vars;
+
PyObject *expr_code;
PyGILState_STATE gilstate;
bool use_gil;
@@ -475,8 +480,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
PyTuple_SET_ITEM(((PyObject *)driver_orig->expr_comp), 0, expr_code);
driver_orig->flag &= ~DRIVER_FLAG_RECOMPILE;
- driver_orig->flag |=
- DRIVER_FLAG_RENAMEVAR; /* maybe this can be removed but for now best keep until were sure */
+
+ /* Maybe this can be removed but for now best keep until were sure. */
+ driver_orig->flag |= DRIVER_FLAG_RENAMEVAR;
#ifdef USE_BYTECODE_WHITELIST
is_recompile = true;
#endif
diff --git a/source/blender/python/intern/bpy_gizmo_wrap.c b/source/blender/python/intern/bpy_gizmo_wrap.c
index 41ff630753f..c66cad5f4a3 100644
--- a/source/blender/python/intern/bpy_gizmo_wrap.c
+++ b/source/blender/python/intern/bpy_gizmo_wrap.c
@@ -116,8 +116,9 @@ static void gizmo_properties_init(wmGizmoType *gzt)
/* Extract target property definitions from 'bl_target_properties' */
{
- /* picky developers will notice that 'bl_targets' won't work with inheritance
- * get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal) - campbell */
+ /* Picky developers will notice that 'bl_targets' won't work with inheritance
+ * get direct from the dict to avoid raising a load of attribute errors
+ * (yes this isnt ideal) - campbell. */
PyObject *py_class_dict = py_class->tp_dict;
PyObject *bl_target_properties = PyDict_GetItem(py_class_dict,
bpy_intern_str_bl_target_properties);
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 90dfdcd33b7..b34a41b5af6 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -80,7 +80,8 @@ CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_RNA, "bpy.rna");
/* for internal use, when starting and ending python scripts */
-/* in case a python script triggers another python call, stop bpy_context_clear from invalidating */
+/* In case a python script triggers another python call,
+ * stop bpy_context_clear from invalidating. */
static int py_call_level = 0;
// #define TIME_PY_RUN // simple python tests. prints on exit.
@@ -806,7 +807,7 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
else if (BPy_StructRNA_Check(item)) {
ptr = &(((BPy_StructRNA *)item)->ptr);
- //result->ptr = ((BPy_StructRNA *)item)->ptr;
+ // result->ptr = ((BPy_StructRNA *)item)->ptr;
CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data);
CTX_data_type_set(result, CTX_DATA_TYPE_POINTER);
done = true;
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 0f66a9cbeb9..aef4ab6667a 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -314,8 +314,9 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
- /* when calling bpy.ops.wm.read_factory_settings() bpy.data's main pointer is freed by clear_globals(),
- * further access will crash blender. setting context is not needed in this case, only calling because this
+ /* When calling bpy.ops.wm.read_factory_settings() bpy.data's main pointer
+ * is freed by clear_globals(), further access will crash blender.
+ * Setting context is not needed in this case, only calling because this
* function corrects bpy.data (internal Main pointer) */
BPY_modules_update(C);
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index 976ed4611b0..8f2f08c7c37 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -45,7 +45,8 @@ static void operator_properties_init(wmOperatorType *ot)
/* Only call this so pyrna_deferred_register_class gives a useful error
* WM_operatortype_append_ptr will call RNA_def_struct_identifier later.
*
- * Note the 'no_struct_map' function is used since the actual struct name is already used by the operator.
+ * Note the 'no_struct_map' function is used since the actual struct name
+ * is already used by the operator.
*/
RNA_def_struct_identifier_no_struct_map(ot->srna, ot->idname);
@@ -56,8 +57,9 @@ static void operator_properties_init(wmOperatorType *ot)
/* set the default property: ot->prop */
{
- /* picky developers will notice that 'bl_property' won't work with inheritance
- * get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal) - campbell */
+ /* Picky developers will notice that 'bl_property' won't work with inheritance
+ * get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal)
+ * - campbell. */
PyObject *py_class_dict = py_class->tp_dict;
PyObject *bl_property = PyDict_GetItem(py_class_dict, bpy_intern_str_bl_property);
const char *prop_id;
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index a0a6c73fe1f..074d72f094f 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -2277,7 +2277,10 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
return NULL;
}
- // prop = RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name ? name : id, description);
+#if 0
+ prop = RNA_def_boolean_array(
+ srna, id, size, pydef ? def : NULL, name ? name : id, description);
+#endif
prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
RNA_def_property_array(prop, size);
if (pydef) {
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 0ca96071ee0..a87deeabc65 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -189,7 +189,8 @@ static void id_weakref_pool_add(ID *id, BPy_DummyPointerRNA *pyrna)
PyObject *weakref_capsule;
PyObject *weakref_cb_py;
- /* create a new function instance and insert the list as 'self' so we can remove ourself from it */
+ /* Create a new function instance and insert the list as 'self'
+ * so we can remove ourself from it. */
GHash *weakinfo_hash = id_weakref_pool_get(id); /* new or existing */
weakref_capsule = PyCapsule_New(weakinfo_hash, NULL, NULL);
@@ -704,7 +705,8 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
case PROP_QUATERNION:
if (len == 3) { /* euler */
if (is_thick) {
- /* attempt to get order, only needed for thick types since wrapped with update via callbacks */
+ /* Attempt to get order,
+ * only needed for thick types since wrapped with update via callbacks. */
PropertyRNA *prop_eul_order = NULL;
short order = pyrna_rotation_euler_order_get(ptr, EULER_ORDER_XYZ, &prop_eul_order);
@@ -1433,7 +1435,8 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
RNA_property_enum_items_ex(NULL, ptr, prop, true, &enum_item, NULL, &free_dummy);
BLI_assert(!free_dummy);
- /* Do not print warning in case of DummyRNA_NULL_items, this one will never match any value... */
+ /* Do not print warning in case of DummyRNA_NULL_items,
+ * this one will never match any value... */
if (enum_item != DummyRNA_NULL_items) {
const char *ptr_name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
@@ -1846,7 +1849,8 @@ static int pyrna_py_to_prop(
}
else {
/* same as bytes */
- /* XXX, this is suspect but needed for function calls, need to see if theres a better way */
+ /* XXX, this is suspect but needed for function calls,
+ * need to see if theres a better way. */
if (data) {
*((char **)data) = (char *)param;
}
@@ -1902,7 +1906,8 @@ static int pyrna_py_to_prop(
* if the prop is not an operator type and the pyobject is an operator,
* use its properties in place of its self.
*
- * this is so bad that its almost a good reason to do away with fake 'self.properties -> self'
+ * This is so bad that its almost a good reason to do away with fake
+ * 'self.properties -> self'
* class mixing if this causes problems in the future it should be removed.
*/
if ((ptr_type == &RNA_AnyType) && (BPy_StructRNA_Check(value))) {
@@ -1997,8 +2002,9 @@ static int pyrna_py_to_prop(
}
}
else {
- /* for function calls, we sometimes want to pass the 'ptr' directly,
- * watch out that it remains valid!, possibly we could support this later if needed */
+ /* For function calls, we sometimes want to pass the 'ptr' directly,
+ * watch out that it remains valid!,
+ * possibly we could support this later if needed. */
BLI_assert(value_new == NULL);
if (value == Py_None) {
*((void **)data) = NULL;
@@ -4187,8 +4193,8 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
ret = NULL;
}
else if (
- name[0] ==
- '_') { /* rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups */
+ /* rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups */
+ name[0] == '_') {
/* annoying exception, maybe we need to have different types for this... */
if (STR_ELEM(name, "__getitem__", "__setitem__") &&
!RNA_struct_idprops_check(self->ptr.type)) {
@@ -4312,9 +4318,11 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr
* >>> bpy.types.Scene.foo = BoolProperty()
* >>> bpy.types.Scene.foo
* <bpy_struct, BoolProperty("foo")>
- * ...rather than returning the deferred class register tuple as checked by pyrna_is_deferred_prop()
+ * ...rather than returning the deferred class register tuple
+ * as checked by pyrna_is_deferred_prop()
*
- * Disable for now, this is faking internal behavior in a way that's too tricky to maintain well. */
+ * Disable for now,
+ * this is faking internal behavior in a way that's too tricky to maintain well. */
# if 0
if (ret == NULL) { // || pyrna_is_deferred_prop(ret)
StructRNA *srna = srna_from_self(cls, "StructRNA.__getattr__");
@@ -4424,7 +4432,8 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
}
}
else if (self->ptr.type == &RNA_Context) {
- /* code just raises correct error, context prop's cant be set, unless its apart of the py class */
+ /* Code just raises correct error, context prop's cant be set,
+ * unless its apart of the py class. */
bContext *C = self->ptr.data;
if (C == NULL) {
PyErr_Format(PyExc_AttributeError,
@@ -5105,7 +5114,8 @@ static int foreach_parse_args(BPy_PropertyRNA *self,
}
*size = RNA_raw_type_sizeof(*raw_type);
-#if 0 /* works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks */
+#if 0 /* works fine but not strictly needed, \
+ * we could allow RNA_property_collection_raw_* to do the checks */
if ((*attr_tot) < 1) {
*attr_tot = 1;
}
@@ -5130,8 +5140,9 @@ static int foreach_parse_args(BPy_PropertyRNA *self,
#endif
}
- /* check 'attr_tot' otherwise we don't know if any values were set
- * this isn't ideal because it means running on an empty list may fail silently when its not compatible. */
+ /* Check 'attr_tot' otherwise we don't know if any values were set
+ * this isn't ideal because it means running on an empty list may
+ * fail silently when its not compatible. */
if (*size == 0 && *attr_tot != 0) {
PyErr_SetString(PyExc_AttributeError, "attribute does not support foreach method");
return -1;
@@ -5997,7 +6008,8 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
/* Check if we gave args that don't exist in the function
* printing the error is slow but it should only happen when developing.
* the if below is quick, checking if it passed less keyword args then we gave.
- * (Don't overwrite the error if we have one, otherwise can skip important messages and confuse with args)
+ * (Don't overwrite the error if we have one,
+ * otherwise can skip important messages and confuse with args).
*/
if (err == 0 && kw && (pykw_len > kw_tot)) {
PyObject *key, *value;
@@ -6894,7 +6906,8 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA *
if ((PyObject *)pyrna != Py_None) {
/* hold a reference to the iterator since it may have
* allocated memory 'pyrna' needs. eg: introspecting dynamic enum's */
- /* TODO, we could have an api call to know if this is needed since most collections don't */
+ /* TODO, we could have an api call to know if this is
+ * needed since most collections don't */
pyrna_struct_reference_set(pyrna, (PyObject *)self);
}
}
@@ -7025,8 +7038,10 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna)
/* sanity check, could skip this unless in debug mode */
if (newclass) {
PyObject *base_compare = pyrna_srna_PyBase(srna);
- //PyObject *slots = PyObject_GetAttrString(newclass, "__slots__"); // cant do this because it gets superclasses values!
- //PyObject *bases = PyObject_GetAttrString(newclass, "__bases__"); // can do this but faster not to.
+ /* Can't do this because it gets superclasses values! */
+ // PyObject *slots = PyObject_GetAttrString(newclass, "__slots__");
+ /* Can do this but faster not to. */
+ // PyObject *bases = PyObject_GetAttrString(newclass, "__bases__");
PyObject *tp_bases = ((PyTypeObject *)newclass)->tp_bases;
PyObject *tp_slots = PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict,
bpy_intern_str___slots__);
@@ -7077,7 +7092,10 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
/* subclass equivalents
* - class myClass(myBase):
* some = 'value' # or ...
- * - myClass = type(name='myClass', bases=(myBase,), dict={'__module__': 'bpy.types', '__slots__': ()})
+ * - myClass = type(
+ * name='myClass',
+ * bases=(myBase,), dict={'__module__': 'bpy.types', '__slots__': ()}
+ * )
*/
/* Assume RNA_struct_py_type_get(srna) was already checked */
@@ -7132,7 +7150,8 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
}
#endif
- /* newclass will now have 2 ref's, ???, probably 1 is internal since decrefing here segfaults */
+ /* Newclass will now have 2 ref's, ???,
+ * probably 1 is internal since decrefing here segfaults. */
/* PyC_ObSpit("new class ref", newclass); */
@@ -7884,7 +7903,8 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
const int flag = RNA_function_flag(func);
/* TODO(campbell): this is used for classmethod's too,
* even though class methods should have 'FUNC_USE_SELF_TYPE' set, see Operator.poll for eg.
- * Keep this as-is since its working but we should be using 'FUNC_USE_SELF_TYPE' for many functions. */
+ * Keep this as-is since its working but we should be using
+ * 'FUNC_USE_SELF_TYPE' for many functions. */
const bool is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE);
if (!(flag & FUNC_REGISTER)) {
@@ -7909,8 +7929,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
PyErr_Clear();
}
else {
- Py_DECREF(
- item); /* no need to keep a ref, the class owns it (technically we should keep a ref but...) */
+ /* No need to keep a ref, the class owns it (technically we should keep a ref but...). */
+ Py_DECREF(item);
+
if (is_staticmethod) {
if (PyMethod_Check(item) == 0) {
PyErr_Format(PyExc_TypeError,
@@ -8198,7 +8219,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
else {
arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
}
- // args = PyTuple_New(rna_function_arg_count(func)); /* first arg is included in 'item' */
+#if 0
+ /* First arg is included in 'item'. */
+ args = PyTuple_New(rna_function_arg_count(func));
+#endif
args = PyTuple_New(arg_count); /* first arg is included in 'item' */
if (is_staticmethod) {
@@ -8761,7 +8785,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
PyDict_DelItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna);
if (PyErr_Occurred()) {
- PyErr_Clear(); //return NULL;
+ PyErr_Clear(); // return NULL;
}
Py_RETURN_NONE;
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index 588c3cbf171..cf6bd54d8a5 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -24,7 +24,10 @@
/* --- bpy build options --- */
#ifdef WITH_PYTHON_SAFETY
-/* play it safe and keep optional for now, need to test further now this affects looping on 10000's of verts for eg. */
+/**
+ * Play it safe and keep optional for now,
+ * need to test further now this affects looping on 10000's of verts for eg.
+ */
# define USE_WEAKREFS
/* method to invalidate removed py data, XXX, slow to remove objects, otherwise no overhead */
@@ -146,8 +149,10 @@ typedef struct {
PropertyRNA *prop;
/* Arystan: this is a hack to allow sub-item r/w access like: face.uv[n][m] */
- int arraydim; /* array dimension, e.g: 0 for face.uv, 2 for face.uv[n][m], etc. */
- int arrayoffset; /* array first item offset, e.g. if face.uv is [4][2], arrayoffset for face.uv[n] is 2n */
+ /** Array dimension, e.g: 0 for face.uv, 2 for face.uv[n][m], etc. */
+ int arraydim;
+ /** Array first item offset, e.g. if face.uv is [4][2], arrayoffset for face.uv[n] is 2n. */
+ int arrayoffset;
} BPy_PropertyArrayRNA;
typedef struct {
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index 2cd8c8641bb..79c31c8caad 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -55,6 +55,8 @@
#include "../generic/python_utildefines.h"
+#include "DEG_depsgraph_build.h"
+
/* for keyframes and drivers */
static int pyrna_struct_anim_args_parse_ex(PointerRNA *ptr,
const char *error_prefix,
@@ -586,7 +588,9 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
ret = pyrna_struct_CreatePyObject(&tptr);
}
+ bContext *context = BPy_GetContext();
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
+ DEG_relations_tag_update(CTX_data_main(context));
}
else {
/* XXX, should be handled by reports, */
@@ -644,7 +648,9 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
return NULL;
}
- WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
+ bContext *context = BPy_GetContext();
+ WM_event_add_notifier(context, NC_ANIMATION | ND_FCURVES_ORDER, NULL);
+ DEG_relations_tag_update(CTX_data_main(context));
return PyBool_FromLong(result);
}
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index 847ecde354a..9d8fff5dfe4 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -86,7 +86,8 @@ typedef struct ItemConvert_FuncArg {
*/
/* arr[3] = x, self->arraydim is 0, lvalue_dim is 1 */
-/* Ensures that a python sequence has expected number of items/sub-items and items are of desired type. */
+/* Ensures that a python sequence has expected number of
+ * items/sub-items and items are of desired type. */
static int validate_array_type(PyObject *seq,
int dim,
int totdim,
@@ -203,7 +204,10 @@ static int validate_array_type(PyObject *seq,
else if (!check_item_type(item)) {
Py_DECREF(item);
- /* BLI_snprintf(error_str, error_str_size, "sequence items should be of type %s", item_type_str); */
+#if 0
+ BLI_snprintf(
+ error_str, error_str_size, "sequence items should be of type %s", item_type_str);
+#endif
PyErr_Format(PyExc_TypeError,
"%s expected sequence items of type %s, not %s",
error_prefix,
diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c
index 78dae50efe6..dfd7624bd3d 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.c
+++ b/source/blender/python/intern/bpy_rna_id_collection.c
@@ -34,7 +34,8 @@
#include "BKE_main.h"
#include "DNA_ID.h"
-/* Those folowing are only to support hack of not listing some internal 'backward' pointers in generated user_map... */
+/* Those folowing are only to support hack of not listing some internal
+ * 'backward' pointers in generated user_map. */
#include "DNA_object_types.h"
#include "DNA_key_types.h"
@@ -97,11 +98,13 @@ static int foreach_libblock_id_user_map_callback(void *user_data,
}
if ((GS(self_id->name) == ID_OB) && (id_p == (ID **)&((Object *)self_id)->proxy_from)) {
- /* We skip proxy_from here, since it's some internal pointer which is not relevant info for py/API level. */
+ /* We skip proxy_from here,
+ * since it's some internal pointer which is not relevant info for py/API level. */
return IDWALK_RET_NOP;
}
else if ((GS(self_id->name) == ID_KE) && (id_p == (ID **)&((Key *)self_id)->from)) {
- /* We skip from here, since it's some internal pointer which is not relevant info for py/API level. */
+ /* We skip from here,
+ * since it's some internal pointer which is not relevant info for py/API level. */
return IDWALK_RET_NOP;
}
@@ -245,14 +248,16 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
if (!data_cb.is_subset &&
/* We do not want to pre-add keys of flitered out types. */
(key_types_bitmap == NULL || id_check_type(id, key_types_bitmap)) &&
- /* We do not want to pre-add keys when we have filter on value types, but not on key types. */
+ /* We do not want to pre-add keys when we have filter on value types,
+ * but not on key types. */
(val_types_bitmap == NULL || key_types_bitmap != NULL)) {
PyObject *key = data_cb.py_id_key_lookup_only;
PyObject *set;
RNA_id_pointer_create(id, &((BPy_StructRNA *)key)->ptr);
- /* We have to insert the key now, otherwise ID unused would be missing from final dict... */
+ /* We have to insert the key now,
+ * otherwise ID unused would be missing from final dict... */
if ((set = PyDict_GetItem(data_cb.user_map, key)) == NULL) {
/* Cannot use our placeholder key here! */
key = pyrna_id_CreatePyObject(id);
diff --git a/source/blender/python/intern/bpy_utils_units.c b/source/blender/python/intern/bpy_utils_units.c
index b80ea50dd09..645b7e1c7af 100644
--- a/source/blender/python/intern/bpy_utils_units.c
+++ b/source/blender/python/intern/bpy_utils_units.c
@@ -66,8 +66,8 @@ static const char *bpyunits_ucategorie_items[] = {
/**
* These fields are just empty placeholders, actual values get set in initializations functions.
- * This allows us to avoid many handwriting, and above all, to keep all systems/categories definition stuff in
- * ``BKE_unit.h``.
+ * This allows us to avoid many handwriting, and above all,
+ * to keep all systems/categories definition stuff in ``BKE_unit.h``.
*/
static PyStructSequence_Field bpyunits_systems_fields[ARRAY_SIZE(bpyunits_usystem_items)];
static PyStructSequence_Field bpyunits_categories_fields[ARRAY_SIZE(bpyunits_ucategorie_items)];
@@ -281,9 +281,11 @@ static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyOb
{
/* Maximum expected length of string result:
- * - number itself: precision + decimal dot + up to four 'above dot' digits.
- * - unit: up to ten chars (six currently, let's be conservative, also because we use some utf8 chars).
- * This can be repeated twice (e.g. 1m20cm), and we add ten more spare chars (spaces, trailing '\0'...).
+ * - Number itself: precision + decimal dot + up to four 'above dot' digits.
+ * - Unit: up to ten chars
+ * (six currently, let's be conservative, also because we use some utf8 chars).
+ * This can be repeated twice (e.g. 1m20cm), and we add ten more spare chars
+ * (spaces, trailing '\0'...).
* So in practice, 64 should be more than enough.
*/
char buf1[64], buf2[64], *str;
diff --git a/source/blender/python/intern/stubs.c b/source/blender/python/intern/stubs.c
index 448751b1155..56ee36086c4 100644
--- a/source/blender/python/intern/stubs.c
+++ b/source/blender/python/intern/stubs.c
@@ -31,8 +31,8 @@
#endif
/* python, will come back */
-//void BPY_script_exec(void) {}
-//void BPY_python_start(void) {}
+// void BPY_script_exec(void) {}
+// void BPY_python_start(void) {}
void BPY_pyconstraint_exec(struct bPythonConstraint *con,
struct bConstraintOb *cob,
struct ListBase *targets)
diff --git a/source/blender/python/mathutils/CMakeLists.txt b/source/blender/python/mathutils/CMakeLists.txt
index a58260a84f6..cdb562a3233 100644
--- a/source/blender/python/mathutils/CMakeLists.txt
+++ b/source/blender/python/mathutils/CMakeLists.txt
@@ -17,8 +17,8 @@
set(INC
.
- ../../blenlib
../../blenkernel
+ ../../blenlib
../../bmesh
../../depsgraph
../../makesdna
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index 32ffa4ad2da..d0fa9f5c565 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -381,13 +381,16 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
/* LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon */
/* XXX We may want to use 'safer' BLI's compare_ff_relative ultimately?
- * LomontRRDCompare4() is an optimized version of Dawson's AlmostEqual2sComplement() (see [1] and [2]).
- * Dawson himself now claims this is not a 'safe' thing to do (pushing ULP method beyond its limits),
- * an recommends using work from [3] instead, which is done in BLI func...
+ * LomontRRDCompare4() is an optimized version of Dawson's AlmostEqual2sComplement()
+ * (see [1] and [2]).
+ * Dawson himself now claims this is not a 'safe' thing to do
+ * (pushing ULP method beyond its limits),
+ * an recommends using work from [3] instead, which is done in BLI func...
*
- * [1] http://www.randydillon.org/Papers/2007/everfast.htm
- * [2] http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
- * [3] https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ instead
+ * [1] http://www.randydillon.org/Papers/2007/everfast.htm
+ * [2] http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
+ * [3] https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
+ * instead.
*/
#define SIGNMASK(i) (-(int)(((unsigned int)(i)) >> 31))
@@ -437,7 +440,8 @@ PyObject *mathutils_dynstr_to_py(struct DynStr *ds)
/* Mathutils Callbacks */
-/* for mathutils internal use only, eventually should re-alloc but to start with we only have a few users */
+/* For mathutils internal use only,
+ * eventually should re-alloc but to start with we only have a few users. */
#define MATHUTILS_TOT_CB 17
static Mathutils_Callback *mathutils_callbacks[MATHUTILS_TOT_CB] = {NULL};
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 6ccb3c2a291..7cc9ba50d90 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -1072,7 +1072,8 @@ static void matrix_invert_safe_internal(const MatrixObject *self, float *r_mat)
if (det == 0.0f) {
const float eps = PSEUDOINVERSE_EPSILON;
- /* We will copy self->matrix into r_mat (if needed), and modify it in place to add diagonal epsilon. */
+ /* We will copy self->matrix into r_mat (if needed),
+ * and modify it in place to add diagonal epsilon. */
in_mat = r_mat;
switch (self->num_col) {
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index 7d73f165c1e..29861c56dc0 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -2377,12 +2377,15 @@ static PyObject *Vector_length_squared_get(VectorObject *self, void *UNUSED(clos
* '((%s | SWIZZLE_VALID_AXIS) | '
* '((%s | SWIZZLE_VALID_AXIS) << SWIZZLE_BITS_PER_AXIS) | '
* '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 2)) | '
- * '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3))) ' %
+ * '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3))) '
+ * %
* (axis_0_pos, axis_1_pos, axis_2_pos, axis_3_pos))
*
* axises = axises[:-1]
* items = list(axis_dict.items())
- * items.sort(key=lambda a: a[0].replace('x', '0').replace('y', '1').replace('z', '2').replace('w', '3'))
+ * items.sort(
+ * key=lambda a: a[0].replace('x', '0').replace('y', '1').replace('z', '2').replace('w', '3')
+ * )
*
* unique = set()
* for key, val in items:
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 5fe3536d899..c39954713b1 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -1043,7 +1043,13 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a
if (len_squared_v3(n3n1) > eps) {
const float quotient = dot_v3v3(N1, n2n3);
if (fabsf(quotient) > eps) {
- /* potentialVertex = (n2n3 * N1[3] + n3n1 * N2[3] + n1n2 * N3[3]) * (-1.0 / quotient); */
+ /**
+ * <pre>
+ * potentialVertex = (
+ * (n2n3 * N1[3] + n3n1 * N2[3] + n1n2 * N3[3]) *
+ * (-1.0 / quotient));
+ * </pre>
+ */
const float quotient_ninv = -1.0f / quotient;
potentialVertex[0] = ((n2n3[0] * N1[3]) + (n3n1[0] * N2[3]) +
(n1n2[0] * N3[3])) *
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt
index da82e606bda..e265197646c 100644
--- a/source/blender/render/CMakeLists.txt
+++ b/source/blender/render/CMakeLists.txt
@@ -25,14 +25,14 @@ set(INC
../blenkernel
../blenlib
../blentranslation
- ../imbuf
../depsgraph
+ ../draw
+ ../gpu
+ ../imbuf
../makesdna
../makesrna
../nodes
../physics
- ../draw
- ../gpu
../../../intern/atomic
../../../intern/guardedalloc
../../../intern/mikktspace
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index c62322a2af4..c147794dae7 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -1781,8 +1781,8 @@ int imagewraposa(Tex *tex,
if (texres->nor && (tex->imaflag & TEX_NORMALMAP) == 0) {
/* a bit extra filter */
- //minx*= 1.35f;
- //miny*= 1.35f;
+ // minx*= 1.35f;
+ // miny*= 1.35f;
boxsample(
curibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend);
@@ -2005,8 +2005,8 @@ void ibuf_sample(ImBuf *ibuf, float fx, float fy, float dx, float dy, float resu
AFD.dxt[1] = dx;
AFD.dyt[0] = dy;
AFD.dyt[1] = dy;
- //copy_v2_v2(AFD.dxt, dx);
- //copy_v2_v2(AFD.dyt, dy);
+ // copy_v2_v2(AFD.dxt, dx);
+ // copy_v2_v2(AFD.dyt, dy);
AFD.intpol = 1;
AFD.extflag = TXC_EXTD;
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index cfe7f4923a0..7d3002ea71d 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -1693,7 +1693,7 @@ static void do_render_all_options(Render *re)
/* ensure no images are in memory from previous animated sequences */
BKE_image_all_free_anim_ibufs(re->main, re->r.cfra);
- BKE_sequencer_all_free_anim_ibufs(re->main, re->r.cfra);
+ BKE_sequencer_all_free_anim_ibufs(re->scene, re->r.cfra);
/* Update for sequencer and compositing animation.
* TODO: ideally we would create a depsgraph with a copy of the scene
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index de3cff62537..67555b70be2 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -271,10 +271,10 @@ static float tex_tri(float a)
static float wood_int(Tex *tex, float x, float y, float z)
{
float wi = 0;
- short wf =
- tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
- short wt =
- tex->stype; /* wood type: TEX_BAND=0, TEX_RING=1, TEX_BANDNOISE=2, TEX_RINGNOISE=3 */
+ /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
+ short wf = tex->noisebasis2;
+ /* wood type: TEX_BAND=0, TEX_RING=1, TEX_BANDNOISE=2, TEX_RINGNOISE=3 */
+ short wt = tex->stype;
float (*waveform[3])(float); /* create array of pointers to waveform functions */
waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
diff --git a/source/blender/shader_fx/CMakeLists.txt b/source/blender/shader_fx/CMakeLists.txt
index 7d36e8836fd..57c7345076e 100644
--- a/source/blender/shader_fx/CMakeLists.txt
+++ b/source/blender/shader_fx/CMakeLists.txt
@@ -22,17 +22,17 @@
set(INC
.
intern
+ ../blenfont
../blenkernel
../blenlib
- ../blenfont
+ ../bmesh
../depsgraph
../makesdna
../makesrna
- ../bmesh
../render/extern/include
../../../intern/elbeem/extern
- ../../../intern/guardedalloc
../../../intern/eigen
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt
index d6107033eb7..7e53c652ab5 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -39,8 +39,8 @@ set(INC
../render/extern/include
../../../intern/clog
../../../intern/ghost
- ../../../intern/guardedalloc
../../../intern/glew-mx
+ ../../../intern/guardedalloc
../../../intern/memutil
)
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 5cc70aecd8d..f1037dadf85 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -208,12 +208,13 @@ int WM_userdef_event_type_from_keymap_type(int kmitype);
/* handlers */
+typedef bool (*EventHandlerPoll)(const ARegion *ar, const struct wmEvent *event);
struct wmEventHandler_Keymap *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
-/* boundbox, optional subwindow boundbox for offset */
-struct wmEventHandler_Keymap *WM_event_add_keymap_handler_bb(ListBase *handlers,
- wmKeyMap *keymap,
- const rcti *bb,
- const rcti *swinbb);
+struct wmEventHandler_Keymap *WM_event_add_keymap_handler_poll(ListBase *handlers,
+ wmKeyMap *keymap,
+ EventHandlerPoll poll);
+struct wmEventHandler_Keymap *WM_event_add_keymap_handler_v2d_mask(ListBase *handlers,
+ wmKeyMap *keymap);
/* priority not implemented, it adds in begin */
struct wmEventHandler_Keymap *WM_event_add_keymap_handler_priority(ListBase *handlers,
wmKeyMap *keymap,
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index 06e970d8ba1..53488cd1f71 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -149,11 +149,11 @@ void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname);
/* Keymap Editor */
void WM_keymap_restore_to_default(struct wmKeyMap *keymap, struct bContext *C);
-void WM_keymap_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties);
-void WM_keymap_restore_item_to_default(struct bContext *C,
+void WM_keymap_item_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties);
+void WM_keymap_item_restore_to_default(struct bContext *C,
struct wmKeyMap *keymap,
struct wmKeyMapItem *kmi);
-int WM_keymap_map_type_get(struct wmKeyMapItem *kmi);
+int WM_keymap_item_map_type_get(const struct wmKeyMapItem *kmi);
/* Key Event */
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index f21baa21006..31c5e1fb94c 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -908,6 +908,7 @@ bool WM_gizmomap_cursor_set(const wmGizmoMap *gzmap, wmWindow *win)
bool wm_gizmomap_highlight_set(wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz, int part)
{
if ((gz != gzmap->gzmap_context.highlight) || (gz && part != gz->highlight_part)) {
+ const bool init_last_cursor = (gzmap->gzmap_context.highlight == NULL);
if (gzmap->gzmap_context.highlight) {
gzmap->gzmap_context.highlight->state &= ~WM_GIZMO_STATE_HIGHLIGHT;
gzmap->gzmap_context.highlight->highlight_part = -1;
@@ -918,11 +919,15 @@ bool wm_gizmomap_highlight_set(wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz
if (gz) {
gz->state |= WM_GIZMO_STATE_HIGHLIGHT;
gz->highlight_part = part;
- gzmap->gzmap_context.last_cursor = -1;
+ if (init_last_cursor) {
+ gzmap->gzmap_context.last_cursor = -1;
+ }
if (C && gz->type->cursor_get) {
wmWindow *win = CTX_wm_window(C);
- gzmap->gzmap_context.last_cursor = win->cursor;
+ if (init_last_cursor) {
+ gzmap->gzmap_context.last_cursor = win->cursor;
+ }
WM_cursor_set(win, gz->type->cursor_get(gz));
}
}
@@ -931,6 +936,7 @@ bool wm_gizmomap_highlight_set(wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz
wmWindow *win = CTX_wm_window(C);
WM_cursor_set(win, gzmap->gzmap_context.last_cursor);
}
+ gzmap->gzmap_context.last_cursor = -1;
}
/* tag the region for redraw */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 76a59944832..a13b28b7853 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -86,6 +86,7 @@
#include "RNA_enum_types.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
/* Motion in pixels allowed before we don't consider single/double click,
* or detect the start of a tweak event. */
@@ -2203,7 +2204,7 @@ static int wm_handler_operator_call(bContext *C,
wm_event_free_handler(&handler->head);
/* prevent silly errors from operator users */
- //retval &= ~OPERATOR_PASS_THROUGH;
+ // retval &= ~OPERATOR_PASS_THROUGH;
}
}
}
@@ -2470,38 +2471,6 @@ static int wm_handler_fileselect_call(bContext *C,
return wm_handler_fileselect_do(C, handlers, handler, event->val);
}
-static bool handler_boundbox_test(wmEventHandler *handler, const wmEvent *event)
-{
- if (handler->bbwin) {
- if (handler->bblocal) {
- rcti rect = *handler->bblocal;
- BLI_rcti_translate(&rect, handler->bbwin->xmin, handler->bbwin->ymin);
-
- if (BLI_rcti_isect_pt_v(&rect, &event->x)) {
- return 1;
- }
- else if (event->type == MOUSEMOVE && BLI_rcti_isect_pt_v(&rect, &event->prevx)) {
- return 1;
- }
- else {
- return 0;
- }
- }
- else {
- if (BLI_rcti_isect_pt_v(handler->bbwin, &event->x)) {
- return 1;
- }
- else if (event->type == MOUSEMOVE && BLI_rcti_isect_pt_v(handler->bbwin, &event->prevx)) {
- return 1;
- }
- else {
- return 0;
- }
- }
- }
- return 1;
-}
-
static int wm_action_not_handled(int action)
{
return action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL);
@@ -2540,7 +2509,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
if (handler_base->flag & WM_HANDLER_DO_FREE) {
/* pass */
}
- else if (handler_boundbox_test(handler_base, event)) { /* optional boundbox */
+ else if (handler_base->poll == NULL || handler_base->poll(CTX_wm_region(C), event)) {
/* in advance to avoid access to freed event on window close */
always_pass = wm_event_always_pass(event);
@@ -3122,10 +3091,12 @@ void wm_event_do_handlers(bContext *C)
wm_event_free_all(win);
}
else {
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = WM_window_get_active_scene(win);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
if (scene) {
- int is_playing_sound = BKE_sound_scene_playing(scene);
+ const int is_playing_sound = BKE_sound_scene_playing(scene_eval);
if (is_playing_sound != -1) {
bool is_playing_screen;
@@ -3145,7 +3116,6 @@ void wm_event_do_handlers(bContext *C)
int ncfra = time * (float)FPS + 0.5f;
if (ncfra != scene->r.cfra) {
scene->r.cfra = ncfra;
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
ED_update_for_newframe(CTX_data_main(C), depsgraph);
WM_event_add_notifier(C, NC_WINDOW, NULL);
}
@@ -3608,20 +3578,44 @@ wmEventHandler_Keymap *WM_event_add_keymap_handler_priority(ListBase *handlers,
return handler;
}
-wmEventHandler_Keymap *WM_event_add_keymap_handler_bb(ListBase *handlers,
- wmKeyMap *keymap,
- const rcti *bblocal,
- const rcti *bbwin)
+static bool event_or_prev_in_rect(const wmEvent *event, const rcti *rect)
{
- wmEventHandler_Keymap *handler = WM_event_add_keymap_handler(handlers, keymap);
+ if (BLI_rcti_isect_pt(rect, event->x, event->y)) {
+ return true;
+ }
+ else if (event->type == MOUSEMOVE && BLI_rcti_isect_pt(rect, event->prevx, event->prevy)) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
- if (handler) {
- handler->head.bblocal = bblocal;
- handler->head.bbwin = bbwin;
+static bool handler_region_v2d_mask_test(const ARegion *ar, const wmEvent *event)
+{
+ rcti rect = ar->v2d.mask;
+ BLI_rcti_translate(&rect, ar->winrct.xmin, ar->winrct.ymin);
+ return event_or_prev_in_rect(event, &rect);
+}
+
+wmEventHandler_Keymap *WM_event_add_keymap_handler_poll(ListBase *handlers,
+ wmKeyMap *keymap,
+ EventHandlerPoll poll)
+{
+ wmEventHandler_Keymap *handler = WM_event_add_keymap_handler(handlers, keymap);
+ if (handler == NULL) {
+ return NULL;
}
+
+ handler->head.poll = poll;
return handler;
}
+wmEventHandler_Keymap *WM_event_add_keymap_handler_v2d_mask(ListBase *handlers, wmKeyMap *keymap)
+{
+ return WM_event_add_keymap_handler_poll(handlers, keymap, handler_region_v2d_mask_test);
+}
+
void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap)
{
LISTBASE_FOREACH (wmEventHandler *, handler_base, handlers) {
@@ -4802,7 +4796,7 @@ static wmKeyMapItem *wm_kmi_from_event(bContext *C,
if (handler_base->flag & WM_HANDLER_DO_FREE) {
/* pass */
}
- else if (handler_boundbox_test(handler_base, event)) { /* optional boundbox */
+ else if (handler_base->poll == NULL || handler_base->poll(CTX_wm_region(C), event)) {
if (handler_base->type == WM_HANDLER_TYPE_KEYMAP) {
wmEventHandler_Keymap *handler = (wmEventHandler_Keymap *)handler_base;
wmKeyMap *keymap = WM_event_get_keymap_from_handler(wm, handler);
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index f9e420a987f..6d90d4745a6 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -1223,6 +1223,7 @@ static ImBuf *blend_file_thumb(const bContext *C,
if (scene->camera) {
ibuf = ED_view3d_draw_offscreen_imbuf_simple(depsgraph,
scene,
+ NULL,
OB_SOLID,
scene->camera,
BLEN_THUMB_SIZE * 2,
@@ -1846,22 +1847,15 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int wm_homefile_read_invoke(bContext *C,
- wmOperator *UNUSED(op),
- const wmEvent *UNUSED(event))
+static int wm_homefile_read_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- /* Draw menu which includes default startup and application templates. */
- uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("New File"), ICON_FILE_NEW);
- uiLayout *layout = UI_popup_menu_layout(pup);
-
- MenuType *mt = WM_menutype_find("TOPBAR_MT_file_new", false);
- if (mt) {
- UI_menutype_draw(C, mt, layout);
+ wmWindowManager *wm = CTX_wm_manager(C);
+ if (U.uiflag & USER_SAVE_PROMPT && !wm->file_saved) {
+ return WM_operator_confirm_message(C, op, "Changes in current file will be lost. Continue?");
+ }
+ else {
+ return wm_homefile_read_exec(C, op);
}
-
- UI_popup_menu_end(C, pup);
-
- return OPERATOR_INTERFACE;
}
void WM_OT_read_homefile(wmOperatorType *ot)
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 97ba9190351..5529aec1aa5 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -64,6 +64,8 @@
#include "BKE_node.h"
#include "BKE_report.h"
#include "BKE_screen.h"
+#include "BKE_scene.h"
+#include "BKE_sound.h"
#include "BKE_keyconfig.h"
#include "BKE_addon.h"
@@ -122,6 +124,7 @@
#include "COM_compositor.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "DRW_engine.h"
@@ -194,6 +197,30 @@ void WM_init_opengl(Main *bmain)
opengl_is_init = true;
}
+static void sound_jack_sync_callback(Main *bmain, int mode, float time)
+{
+ /* Ugly: Blender doesn't like it when the animation is played back during rendering. */
+ if (G.is_rendering) {
+ return;
+ }
+
+ wmWindowManager *wm = bmain->wm.first;
+
+ for (wmWindow *window = wm->windows.first; window != NULL; window = window->next) {
+ Scene *scene = WM_window_get_active_scene(window);
+ if ((scene->audio.flag & AUDIO_SYNC) == 0) {
+ continue;
+ }
+ ViewLayer *view_layer = WM_window_get_active_view_layer(window);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false);
+ if (depsgraph == NULL) {
+ continue;
+ }
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ BKE_sound_jack_scene_update(scene_eval, mode, time);
+ }
+}
+
/* only called once, for startup */
void WM_init(bContext *C, int argc, const char **argv)
{
@@ -201,6 +228,7 @@ void WM_init(bContext *C, int argc, const char **argv)
if (!G.background) {
wm_ghost_init(C); /* note: it assigns C to ghost! */
wm_init_cursor_data();
+ BKE_sound_jack_sync_callback_set(sound_jack_sync_callback);
}
GHOST_CreateSystemPaths();
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index d67fb064dbe..bae9a5de1e6 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -39,6 +39,8 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
+#include "BLF_api.h"
+
#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_global.h"
@@ -61,8 +63,11 @@ struct wmKeyMapItemFind_Params {
void *user_data;
};
-/******************************* Keymap Item **********************************
- * Item in a keymap, that maps from an event to an operator or modal map item */
+/* -------------------------------------------------------------------- */
+/** \name Keymap Item
+ *
+ * Item in a keymap, that maps from an event to an operator or modal map item.
+ * \{ */
static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi)
{
@@ -140,7 +145,7 @@ static void wm_keymap_item_properties_update_ot(wmKeyMapItem *kmi)
}
}
-static void wm_keyconfig_properties_update_ot(ListBase *km_lb)
+static void wm_keymap_item_properties_update_ot_from_list(ListBase *km_lb)
{
wmKeyMap *km;
wmKeyMapItem *kmi;
@@ -179,7 +184,7 @@ static bool wm_keymap_item_equals(wmKeyMapItem *a, wmKeyMapItem *b)
}
/* properties can be NULL, otherwise the arg passed is used and ownership is given to the kmi */
-void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties)
+void WM_keymap_item_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties)
{
if (LIKELY(kmi->ptr)) {
WM_operator_properties_free(kmi->ptr);
@@ -193,7 +198,7 @@ void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties
wm_keymap_item_properties_set(kmi);
}
-int WM_keymap_map_type_get(wmKeyMapItem *kmi)
+int WM_keymap_item_map_type_get(const wmKeyMapItem *kmi)
{
if (ISTIMER(kmi->type)) {
return KMI_TYPE_TIMER;
@@ -219,8 +224,13 @@ int WM_keymap_map_type_get(wmKeyMapItem *kmi)
return KMI_TYPE_KEYBOARD;
}
-/**************************** Keymap Diff Item *********************************
- * Item in a diff keymap, used for saving diff of keymaps in user preferences */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Keymap Diff Item
+ *
+ * Item in a diff keymap, used for saving diff of keymaps in user preferences.
+ * \{ */
static wmKeyMapDiffItem *wm_keymap_diff_item_copy(wmKeyMapDiffItem *kmdi)
{
@@ -249,9 +259,15 @@ static void wm_keymap_diff_item_free(wmKeyMapDiffItem *kmdi)
}
}
-/***************************** Key Configuration ******************************
- * List of keymaps for all editors, modes, ... . There is a builtin default key
- * configuration, a user key configuration, and other preset configurations. */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Key Configuration
+ *
+ * List of keymaps for all editors, modes, etc.
+ * There is a builtin default key configuration,
+ * a user key configuration, and other preset configurations.
+ * \{ */
wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname, bool user_defined)
{
@@ -349,8 +365,13 @@ void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname)
WM_keyconfig_update(wm);
}
-/********************************** Keymap *************************************
- * List of keymap items for one editor, mode, modal operator, ... */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Keymap
+ *
+ * List of keymap items for one editor, mode, modal operator.
+ * \{ */
static wmKeyMap *wm_keymap_new(const char *idname, int spaceid, int regionid)
{
@@ -554,11 +575,16 @@ bool WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
}
}
-/************************** Keymap Diff and Patch ****************************
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Keymap Diff and Patch
+ *
* Rather than saving the entire keymap for user preferences, we only save a
* diff so that changes in the defaults get synced. This system is not perfect
* but works better than overriding the keymap entirely when only few items
- * are changed. */
+ * are changed.
+ * \{ */
static void wm_keymap_addon_add(wmKeyMap *keymap, wmKeyMap *addonmap)
{
@@ -824,11 +850,16 @@ static void wm_keymap_diff_update(ListBase *lb,
}
}
-/* ****************** storage in WM ************ */
+/** \} */
-/* name id's are for storing general or multiple keymaps,
- * space/region ids are same as DNA_space_types.h */
-/* gets freed in wm.c */
+/* -------------------------------------------------------------------- */
+/** \name Storage in WM
+ *
+ * Name id's are for storing general or multiple keymaps.
+ *
+ * - Space/region ids are same as DNA_space_types.h
+ * - Gets freed in wm.c
+ * \{ */
wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid)
{
@@ -894,10 +925,14 @@ wmKeyMap *WM_keymap_find_all_spaceid_or_empty(const bContext *C,
return WM_keymap_list_find_spaceid_or_empty(&wm->userconf->keymaps, idname, spaceid, regionid);
}
-/* ****************** modal keymaps ************ */
+/** \} */
-/* Modal key-maps get linked to a running operator,
- * and filter the keys before sending to modal() callback. */
+/* -------------------------------------------------------------------- */
+/** \name Modal Keymaps
+ *
+ * Modal key-maps get linked to a running operator,
+ * and filter the keys before sending to #wmOperatorType.modal callback.
+ * \{ */
wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf,
const char *idname,
@@ -1046,10 +1081,98 @@ static void wm_user_modal_keymap_set_items(wmWindowManager *wm, wmKeyMap *km)
}
}
-/* ***************** get string from key events **************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Text from Key Events
+ * \{ */
+
+static const char *key_event_icon_or_text(const int font_id, const char *text, const char *icon)
+{
+ BLI_assert(icon == NULL || (BLI_strlen_utf8(icon) == 1));
+ return (icon && BLF_has_glyph(font_id, BLI_str_utf8_as_unicode(icon))) ? icon : text;
+}
const char *WM_key_event_string(const short type, const bool compact)
{
+ if (compact) {
+ /* String storing a single unicode character or NULL. */
+ const char *icon_glyph = NULL;
+ int font_id = BLF_default();
+ const enum {
+ UNIX,
+ MACOS,
+ MSWIN,
+ } platform =
+
+#if defined(__APPLE__)
+ MACOS
+#elif defined(_WIN32)
+ MSWIN
+#else
+ UNIX
+#endif
+ ;
+
+ switch (type) {
+ case LEFTSHIFTKEY:
+ case RIGHTSHIFTKEY: {
+ if (platform == MACOS) {
+ icon_glyph = "\xe2\x87\xa7";
+ }
+ return key_event_icon_or_text(font_id, IFACE_("Shift"), icon_glyph);
+ }
+ case LEFTCTRLKEY:
+ case RIGHTCTRLKEY:
+ if (platform == MACOS) {
+ return "^";
+ }
+ return IFACE_("Ctrl");
+ case LEFTALTKEY:
+ case RIGHTALTKEY: {
+ if (platform == MACOS) {
+ icon_glyph = "\xe2\x8c\xa5";
+ }
+ return key_event_icon_or_text(font_id, IFACE_("Alt"), icon_glyph);
+ }
+ case OSKEY: {
+ if (platform == MACOS) {
+ return key_event_icon_or_text(font_id, IFACE_("Cmd"), "\xe2\x8c\x98");
+ }
+ else if (platform == MSWIN) {
+ return key_event_icon_or_text(font_id, IFACE_("Win"), "\xe2\x8a\x9e");
+ }
+ return IFACE_("OSkey");
+ } break;
+ case TABKEY: {
+ if (platform == MACOS) {
+ icon_glyph = "\xe2\x86\xb9";
+ }
+ return key_event_icon_or_text(font_id, IFACE_("Tab"), icon_glyph);
+ }
+ case BACKSPACEKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Bksp"), "\xe2\x8c\xab");
+ case ESCKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Esc"), NULL /* "\xe2\x8e\x8b" */);
+ case RETKEY: {
+ if (platform == MACOS) {
+ icon_glyph = "\xe2\x8f\x8e";
+ }
+ return key_event_icon_or_text(font_id, IFACE_("Enter"), icon_glyph);
+ }
+ case SPACEKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Space"), NULL /* "\xe2\x90\xa3" */);
+ case LEFTARROWKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Left"), "\xe2\x86\x90");
+ case UPARROWKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Up"), "\xe2\x86\x91");
+ case RIGHTARROWKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Right"), "\xe2\x86\x92");
+ case DOWNARROWKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Down"), "\xe2\x86\x93");
+ }
+ }
+
const EnumPropertyItem *it;
const int i = RNA_enum_from_value(rna_enum_event_type_items, (int)type);
@@ -1097,22 +1220,22 @@ int WM_keymap_item_raw_to_string(const short shift,
else {
if (shift) {
ADD_SEP;
- p += BLI_strcpy_rlen(p, IFACE_("Shift"));
+ p += BLI_strcpy_rlen(p, WM_key_event_string(LEFTSHIFTKEY, true));
}
if (ctrl) {
ADD_SEP;
- p += BLI_strcpy_rlen(p, IFACE_("Ctrl"));
+ p += BLI_strcpy_rlen(p, WM_key_event_string(LEFTCTRLKEY, true));
}
if (alt) {
ADD_SEP;
- p += BLI_strcpy_rlen(p, IFACE_("Alt"));
+ p += BLI_strcpy_rlen(p, WM_key_event_string(LEFTALTKEY, true));
}
if (oskey) {
ADD_SEP;
- p += BLI_strcpy_rlen(p, IFACE_("Cmd"));
+ p += BLI_strcpy_rlen(p, WM_key_event_string(OSKEY, true));
}
}
@@ -1218,6 +1341,8 @@ char *WM_modalkeymap_operator_items_to_string_buf(wmOperatorType *ot,
return ret;
}
+/** \} */
+
static wmKeyMapItem *wm_keymap_item_find_in_keymap(wmKeyMap *keymap,
const char *opname,
IDProperty *properties,
@@ -1645,10 +1770,15 @@ bool WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2)
return 1;
}
-/************************* Update Final Configuration *************************
- * On load or other changes, the final user key configuration is rebuilt from
- * the preset, addon and user preferences keymaps. We also test if the final
- * configuration changed and write the changes to the user preferences. */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Update Final Configuration
+ *
+ * On load or other changes, the final user key configuration is rebuilt from the preset,
+ * add-on and user preferences keymaps. We also test if the final configuration changed and write
+ * the changes to the user preferences.
+ * \{ */
/* so operator removal can trigger update */
enum {
@@ -1738,11 +1868,11 @@ void WM_keyconfig_update(wmWindowManager *wm)
int i;
for (i = 0; keymaps_lb[i]; i++) {
- wm_keyconfig_properties_update_ot(keymaps_lb[i]);
+ wm_keymap_item_properties_update_ot_from_list(keymaps_lb[i]);
}
for (kc = wm->keyconfigs.first; kc; kc = kc->next) {
- wm_keyconfig_properties_update_ot(&kc->keymaps);
+ wm_keymap_item_properties_update_ot_from_list(&kc->keymaps);
}
wm_keymap_update_flag &= ~WM_KEYMAP_UPDATE_OPERATORTYPE;
@@ -1818,10 +1948,14 @@ void WM_keyconfig_update(wmWindowManager *wm)
}
}
-/********************************* Event Handling *****************************
- * Handlers have pointers to the keymap in the default configuration. During
- * event handling this function is called to get the keymap from the final
- * configuration. */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Event Handling
+ *
+ * Handlers have pointers to the keymap in the default configuration.
+ * During event handling this function is called to get the keymap from the final configuration.
+ * \{ */
wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
{
@@ -1842,10 +1976,15 @@ wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
return keymap;
}
-/******************************* Keymap Editor ********************************
- * In the keymap editor the user key configuration is edited. */
+/** \} */
-void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapItem *kmi)
+/* -------------------------------------------------------------------- */
+/** \name Keymap Editor
+ *
+ * In the keymap editor the user key configuration is edited.
+ * \{ */
+
+void WM_keymap_item_restore_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapItem *kmi)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmKeyMap *defaultmap, *addonmap;
@@ -1872,7 +2011,7 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt
/* restore to original */
if (!STREQ(orig->idname, kmi->idname)) {
BLI_strncpy(kmi->idname, orig->idname, sizeof(kmi->idname));
- WM_keymap_properties_reset(kmi, NULL);
+ WM_keymap_item_properties_reset(kmi, NULL);
}
if (orig->properties) {
@@ -1941,3 +2080,5 @@ const char *WM_bool_as_string(bool test)
{
return test ? IFACE_("ON") : IFACE_("OFF");
}
+
+/** \} */
diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c
index 37a7ed4d751..626e9e88845 100644
--- a/source/blender/windowmanager/intern/wm_keymap_utils.c
+++ b/source/blender/windowmanager/intern/wm_keymap_utils.c
@@ -295,9 +295,6 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
case CTX_MODE_SCULPT:
km = WM_keymap_find_all(C, "Sculpt", 0, 0);
break;
- case CTX_MODE_EDIT_MESH:
- km = WM_keymap_find_all(C, "UV Sculpt", 0, 0);
- break;
default:
break;
}
diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c
index 39594a66e4e..ece57f5a63b 100644
--- a/source/blender/windowmanager/intern/wm_operator_props.c
+++ b/source/blender/windowmanager/intern/wm_operator_props.c
@@ -449,6 +449,13 @@ void WM_operator_properties_mouse_select(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle Selection", "Toggle the selection");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/**
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 9680f82fe8b..ec803c9bba7 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1158,8 +1158,8 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2)
WM_operator_call_ex(C, data->op, true);
/* let execute handle freeing it */
- //data->free_op = false;
- //data->op = NULL;
+ // data->free_op = false;
+ // data->op = NULL;
/* in this case, wm_operator_ui_popup_cancel wont run */
MEM_freeN(data);
@@ -3814,7 +3814,7 @@ const EnumPropertyItem *RNA_scene_without_active_itemf(bContext *C,
ptr,
r_free,
C ? (ID *)CTX_data_main(C)->scenes.first : NULL,
- true,
+ false,
rna_id_enum_filter_single,
scene_active);
}
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 098284de0d1..844316bc925 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -1284,7 +1284,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
GHOST_GetMainDisplayDimensions(g_WS.ghost_system, &maxwinx, &maxwiny);
- //GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
+ // GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
/* initialize OpenGL immediate mode */
g_WS.gpu_context = GPU_context_create();
diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c
index 41e63cc0aca..874f8516caa 100644
--- a/source/blender/windowmanager/intern/wm_stereo.c
+++ b/source/blender/windowmanager/intern/wm_stereo.c
@@ -165,7 +165,7 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view)
soffx = 0;
}
}
- else { //RIGHT_LEFT_ID
+ else { // RIGHT_LEFT_ID
if (cross_eyed) {
soffx = 0;
}
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index 0abb5678800..f429415bee9 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -169,14 +169,6 @@ void WM_toolsystem_unlink(bContext *C, WorkSpace *workspace, const bToolKey *tke
}
}
-static void toolsystem_ref_link__refresh_image_uv_sculpt(bContext *C, Scene *scene)
-{
- PointerRNA ptr;
- RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &ptr);
- PropertyRNA *prop = RNA_struct_find_property(&ptr, "use_uv_sculpt");
- RNA_property_update(C, &ptr, prop);
-}
-
/**
* \see #toolsystem_ref_link
*/
@@ -244,29 +236,6 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
}
}
}
- else if ((tref->space_type == SPACE_IMAGE) && (tref->mode == SI_MODE_UV)) {
- /* Note that switching uv-sculpt boolean is a hack at the moment.
- * It would be best to make this either an operator or a higher level mode
- * (like mesh-object sculpt mode). */
- const EnumPropertyItem *items = rna_enum_uv_sculpt_tool_items;
- const int i = RNA_enum_from_identifier(items, tref_rt->data_block);
- if (i != -1) {
- const int value = items[i].value;
- wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- if (workspace == WM_window_get_active_workspace(win)) {
- Scene *scene = WM_window_get_active_scene(win);
- ToolSettings *ts = scene->toolsettings;
- ts->uv_sculpt_tool = value;
-
- if (ts->use_uv_sculpt == false) {
- ts->use_uv_sculpt = true;
- toolsystem_ref_link__refresh_image_uv_sculpt(C, scene);
- }
- }
- }
- }
- }
else {
const ePaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
BLI_assert(paint_mode != PAINT_MODE_INVALID);
@@ -280,6 +249,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
for (wmWindow *win = wm->windows.first; win; win = win->next) {
if (workspace == WM_window_get_active_workspace(win)) {
Scene *scene = WM_window_get_active_scene(win);
+ BKE_paint_ensure_from_paintmode(scene, paint_mode);
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
struct Brush *brush = BKE_paint_toolslots_brush_get(paint, slot_index);
if (brush == NULL) {
@@ -300,23 +270,6 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
}
}
}
- else {
- /* XXX, this part is weak, disables uv_sculpt when non uv-tool set. */
- if ((tref->space_type == SPACE_IMAGE) && (tref->mode == SI_MODE_UV)) {
- Main *bmain = CTX_data_main(C);
- wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- if (workspace == WM_window_get_active_workspace(win)) {
- Scene *scene = WM_window_get_active_scene(win);
- ToolSettings *ts = scene->toolsettings;
- if (ts->use_uv_sculpt == true) {
- ts->use_uv_sculpt = false;
- toolsystem_ref_link__refresh_image_uv_sculpt(C, scene);
- }
- }
- }
- }
- }
}
static void toolsystem_refresh_ref(bContext *C, WorkSpace *workspace, bToolRef *tref)
@@ -409,10 +362,6 @@ void WM_toolsystem_ref_set_from_runtime(struct bContext *C,
STRNCPY(tref->idname, idname);
- /* BAD DESIGN WARNING: used for topbar. */
- workspace->tools_space_type = tref->space_type;
- workspace->tools_mode = tref->mode;
-
if (tref->runtime == NULL) {
tref->runtime = MEM_callocN(sizeof(*tref->runtime), __func__);
}
@@ -489,17 +438,6 @@ void WM_toolsystem_ref_sync_from_context(Main *bmain, WorkSpace *workspace, bToo
}
}
}
- else if ((tref->space_type == SPACE_IMAGE) && (tref->mode == SI_MODE_UV)) {
- if (ob->mode & OB_MODE_EDIT) {
- const EnumPropertyItem *items = rna_enum_uv_sculpt_tool_items;
- const int i = RNA_enum_from_value(items, ts->uv_sculpt_tool);
- const EnumPropertyItem *item = &items[i];
- if (!STREQ(tref_rt->data_block, item->identifier)) {
- STRNCPY(tref_rt->data_block, item->identifier);
- SNPRINTF(tref->idname, "builtin_brush.%s", item->name);
- }
- }
- }
else {
const ePaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
@@ -616,31 +554,24 @@ void WM_toolsystem_refresh_active(bContext *C)
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);
- int mode_other = 0;
- enum { UNSET = -1, CHANGE = 0, MATCH = 1 } mode_match = UNSET;
/* Could skip loop for modes that don't depend on space type. */
+ int space_type_mask_handled = 0;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
/* Don't change the space type of the active tool, only update it's mode. */
- if (sa->spacetype == workspace->tools_space_type) {
- const int mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype);
- if (workspace->tools_mode == mode) {
- mode_match = MATCH;
- break;
- }
- else if (mode_match == -1) {
- mode_match = CHANGE;
- mode_other = mode;
+ const int space_type_mask = (1 << sa->spacetype);
+ if ((space_type_mask & WM_TOOLSYSTEM_SPACE_MASK) &&
+ ((space_type_mask_handled & space_type_mask) == 0)) {
+ space_type_mask_handled |= space_type_mask;
+ 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 != sa->runtime.tool) {
+ toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL);
}
}
}
-
- if (mode_match == CHANGE) {
- const bToolKey tkey = {
- .space_type = workspace->tools_space_type,
- .mode = mode_other,
- };
- toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL);
- }
}
}
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 2dbe738dd86..e98067d78cc 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -770,7 +770,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
wm_window_swap_buffers(win);
- //GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified);
+ // GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified);
/* standard state vars for window */
GPU_state_init();
diff --git a/source/blender/windowmanager/wm_cursors.h b/source/blender/windowmanager/wm_cursors.h
index dcc92396770..b4b0bcf0149 100644
--- a/source/blender/windowmanager/wm_cursors.h
+++ b/source/blender/windowmanager/wm_cursors.h
@@ -42,7 +42,7 @@ enum {
CURSOR_COPY,
};
-//typedef struct BCursor_s BCursor;
+// typedef struct BCursor_s BCursor;
typedef struct BCursor {
char *small_bm;
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index 9a2f8bda041..049e4d44994 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -44,14 +44,15 @@ enum eWM_EventHandlerType {
WM_HANDLER_TYPE_KEYMAP,
};
+typedef bool (*EventHandlerPoll)(const ARegion *ar, const wmEvent *event);
+
typedef struct wmEventHandler {
struct wmEventHandler *next, *prev;
enum eWM_EventHandlerType type;
char flag; /* WM_HANDLER_BLOCKING, ... */
- /** Optional local and windowspace bb. */
- const rcti *bblocal, *bbwin;
+ EventHandlerPoll poll;
} wmEventHandler;
/** Run after the keymap item runs. */
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 877d9c971a3..0f7612abb0c 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -22,18 +22,18 @@ setup_libdirs()
blender_include_dirs(
../../intern/clog
- ../../intern/guardedalloc
../../intern/glew-mx
- ../blender/blenlib
+ ../../intern/guardedalloc
../blender/blenkernel
+ ../blender/blenlib
../blender/blenloader
../blender/depsgraph
../blender/editors/include
- ../blender/makesrna
../blender/imbuf
+ ../blender/makesrna
../blender/render/extern/include
- ../blender/makesdna
../blender/gpu
+ ../blender/makesdna
../blender/windowmanager
)
diff --git a/tests/gtests/blenlib/BLI_path_util_test.cc b/tests/gtests/blenlib/BLI_path_util_test.cc
index a9ac5816380..c07ff2b0b05 100644
--- a/tests/gtests/blenlib/BLI_path_util_test.cc
+++ b/tests/gtests/blenlib/BLI_path_util_test.cc
@@ -487,3 +487,134 @@ TEST(path_util, PathFrameStrip)
PATH_FRAME_STRIP("/ext/shorter/somefile.123001.abc", "/ext/shorter/somefile.######", ".abc");
}
#undef PATH_FRAME_STRIP
+
+#define PATH_EXTENSION_CHECK(input_path, input_ext, expect_ext) \
+ { \
+ const bool ret = BLI_path_extension_check(input_path, input_ext); \
+ if (strcmp(input_ext, expect_ext) == 0) { \
+ EXPECT_TRUE(ret); \
+ } \
+ else { \
+ EXPECT_FALSE(ret); \
+ } \
+ } \
+ ((void)0)
+
+/* BLI_path_extension_check */
+TEST(path_util, PathExtensionCheck)
+{
+ PATH_EXTENSION_CHECK("a/b/c.exe", ".exe", ".exe");
+ PATH_EXTENSION_CHECK("correct/path/to/file.h", ".h", ".h");
+ PATH_EXTENSION_CHECK("correct/path/to/file.BLEND", ".BLEND", ".BLEND");
+ PATH_EXTENSION_CHECK("../tricky/path/to/file.h", ".h", ".h");
+ PATH_EXTENSION_CHECK("../dirty//../path\\to/file.h", ".h", ".h");
+ PATH_EXTENSION_CHECK("a/b/c.veryveryverylonglonglongextension",
+ ".veryveryverylonglonglongextension",
+ ".veryveryverylonglonglongextension");
+ PATH_EXTENSION_CHECK("filename.PNG", "pnG", "pnG");
+ PATH_EXTENSION_CHECK("a/b/c.h.exe", ".exe", ".exe");
+ PATH_EXTENSION_CHECK("a/b/c.h.exe", "exe", "exe");
+ PATH_EXTENSION_CHECK("a/b/c.exe", "c.exe", "c.exe");
+ PATH_EXTENSION_CHECK("a/b/noext", "noext", "noext");
+
+ PATH_EXTENSION_CHECK("a/b/c.exe", ".png", ".exe");
+ PATH_EXTENSION_CHECK("a/b/c.exe", "c.png", ".exe");
+ PATH_EXTENSION_CHECK("a/b/s.l", "l.s", "s.l");
+ PATH_EXTENSION_CHECK(".hiddenfolder", "", ".hiddenfolder");
+ PATH_EXTENSION_CHECK("../dirty//../path\\to/actual.h.file.ext", ".h", ".ext");
+ PATH_EXTENSION_CHECK("..\\dirty//../path//to/.hiddenfile.JPEG", ".hiddenfile", ".JPEG");
+}
+#undef PATH_EXTENSION_CHECK
+
+#define PATH_FRAME_CHECK_CHARS(input_path, expect_hasChars) \
+ { \
+ const bool ret = BLI_path_frame_check_chars(input_path); \
+ if (expect_hasChars) { \
+ EXPECT_TRUE(ret); \
+ } \
+ else { \
+ EXPECT_FALSE(ret); \
+ } \
+ } \
+ ((void)0)
+
+/* BLI_path_frame_check_chars */
+TEST(path_util, PathFrameCheckChars)
+{
+ PATH_FRAME_CHECK_CHARS("a#", true);
+ PATH_FRAME_CHECK_CHARS("aaaaa#", true);
+ PATH_FRAME_CHECK_CHARS("#aaaaa", true);
+ PATH_FRAME_CHECK_CHARS("a##.###", true);
+ PATH_FRAME_CHECK_CHARS("####.abc#", true);
+ PATH_FRAME_CHECK_CHARS("path/to/chars/a#", true);
+ PATH_FRAME_CHECK_CHARS("path/to/chars/123#123.exe", true);
+
+ PATH_FRAME_CHECK_CHARS("&", false);
+ PATH_FRAME_CHECK_CHARS("\35", false);
+ PATH_FRAME_CHECK_CHARS("path#/to#/chars#/$.h", false);
+ PATH_FRAME_CHECK_CHARS("path#/to#/chars#/nochars.h", false);
+ PATH_FRAME_CHECK_CHARS("..\\dirty\\path#/..//to#\\chars#/nochars.h", false);
+ PATH_FRAME_CHECK_CHARS("..\\dirty\\path#/..//to#/chars#\\nochars.h", false);
+}
+#undef PATH_FRAME_CHECK_CHARS
+
+#define PATH_FRAME_RANGE(input_path, sta, end, digits, expect_outpath) \
+ { \
+ char path[FILE_MAX]; \
+ bool ret; \
+ BLI_strncpy(path, input_path, FILE_MAX); \
+ ret = BLI_path_frame_range(path, sta, end, digits); \
+ if (expect_outpath == NULL) { \
+ EXPECT_FALSE(ret); \
+ } \
+ else { \
+ EXPECT_TRUE(ret); \
+ EXPECT_STREQ(path, expect_outpath); \
+ } \
+ } \
+ ((void)0)
+
+/* BLI_path_frame_range */
+TEST(path_util, PathFrameRange)
+{
+ int dummy = -1;
+ PATH_FRAME_RANGE("#", 1, 2, dummy, "1-2");
+ PATH_FRAME_RANGE("##", 1, 2, dummy, "01-02");
+ PATH_FRAME_RANGE("##", 1000, 2000, dummy, "1000-2000");
+ PATH_FRAME_RANGE("###", 100, 200, dummy, "100-200");
+ PATH_FRAME_RANGE("###", 8, 9, dummy, "008-009");
+
+ PATH_FRAME_RANGE("", 100, 200, 1, "100-200");
+ PATH_FRAME_RANGE("", 123, 321, 4, "0123-0321");
+ PATH_FRAME_RANGE("", 1, 0, 20, "00000000000000000001-00000000000000000000");
+}
+#undef PATH_FRAME_RANGE
+
+#define PATH_FRAME_GET(input_path, expect_frame, expect_numdigits, expect_pathisvalid) \
+ { \
+ char path[FILE_MAX]; \
+ int out_frame = -1, out_numdigits = -1; \
+ BLI_strncpy(path, input_path, FILE_MAX); \
+ const bool ret = BLI_path_frame_get(path, &out_frame, &out_numdigits); \
+ if (expect_pathisvalid) { \
+ EXPECT_TRUE(ret); \
+ } \
+ else { \
+ EXPECT_FALSE(ret); \
+ } \
+ EXPECT_EQ(out_frame, expect_frame); \
+ EXPECT_EQ(out_numdigits, expect_numdigits); \
+ } \
+ ((void)0)
+
+/* BLI_path_frame_get */
+TEST(path_util, PathFrameGet)
+{
+ PATH_FRAME_GET("001.avi", 1, 3, true);
+ PATH_FRAME_GET("0000299.ext", 299, 7, true);
+ PATH_FRAME_GET("path/to/frame_2810.dummy_quite_long_extension", 2810, 4, true);
+ PATH_FRAME_GET("notframe_7_frame00018.bla", 18, 5, true);
+
+ PATH_FRAME_GET("", -1, -1, false);
+}
+#undef PATH_FRAME_GET