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-format1
-rw-r--r--build_files/build_environment/cmake/versions.cmake4
-rwxr-xr-xbuild_files/build_environment/install_deps.sh2
-rw-r--r--build_files/cmake/platform/platform_win32.cmake3
-rw-r--r--extern/audaspace/include/devices/SoftwareDevice.h6
-rw-r--r--extern/audaspace/include/respec/Mixer.h6
-rw-r--r--extern/audaspace/plugins/pulseaudio/PulseAudioDevice.cpp6
-rw-r--r--extern/audaspace/plugins/pulseaudio/PulseAudioSymbols.h4
-rw-r--r--extern/audaspace/plugins/wasapi/WASAPIDevice.cpp197
-rw-r--r--extern/audaspace/plugins/wasapi/WASAPIDevice.h5
-rw-r--r--extern/audaspace/src/devices/SoftwareDevice.cpp22
-rw-r--r--extern/audaspace/src/respec/Mixer.cpp30
-rw-r--r--intern/clog/clog.c6
-rw-r--r--intern/cycles/app/cycles_xml.cpp14
-rw-r--r--intern/cycles/blender/addon/properties.py9
-rw-r--r--intern/cycles/blender/addon/ui.py31
-rw-r--r--intern/cycles/blender/blender_curves.cpp2
-rw-r--r--intern/cycles/blender/blender_light.cpp2
-rw-r--r--intern/cycles/blender/blender_object.cpp8
-rw-r--r--intern/cycles/blender/blender_sync.cpp9
-rw-r--r--intern/cycles/blender/blender_sync.h2
-rw-r--r--intern/cycles/bvh/bvh_embree.cpp2
-rw-r--r--intern/cycles/bvh/bvh_node.h2
-rw-r--r--intern/cycles/bvh/bvh_params.h2
-rw-r--r--intern/cycles/bvh/bvh_split.cpp2
-rw-r--r--intern/cycles/device/device_task.h4
-rw-r--r--intern/cycles/device/opencl/opencl_util.cpp2
-rw-r--r--intern/cycles/kernel/bvh/bvh.h2
-rw-r--r--intern/cycles/kernel/bvh/bvh_util.h81
-rw-r--r--intern/cycles/kernel/closure/bsdf.h9
-rw-r--r--intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h4
-rw-r--r--intern/cycles/kernel/geom/geom_motion_triangle_shader.h2
-rw-r--r--intern/cycles/kernel/geom/geom_primitive.h2
-rw-r--r--intern/cycles/kernel/geom/geom_triangle.h20
-rw-r--r--intern/cycles/kernel/geom/geom_volume.h24
-rw-r--r--intern/cycles/kernel/kernel_emission.h3
-rw-r--r--intern/cycles/kernel/kernel_globals.h2
-rw-r--r--intern/cycles/kernel/kernel_projection.h2
-rw-r--r--intern/cycles/kernel/kernel_queues.h2
-rw-r--r--intern/cycles/kernel/kernel_shader.h3
-rw-r--r--intern/cycles/kernel/kernel_subsurface.h2
-rw-r--r--intern/cycles/kernel/kernel_types.h13
-rw-r--r--intern/cycles/kernel/osl/osl_services.h2
-rw-r--r--intern/cycles/kernel/osl/osl_shader.cpp2
-rw-r--r--intern/cycles/kernel/split/kernel_split_data_types.h2
-rw-r--r--intern/cycles/kernel/svm/svm_closure.h2
-rw-r--r--intern/cycles/kernel/svm/svm_geometry.h6
-rw-r--r--intern/cycles/kernel/svm/svm_image.h2
-rw-r--r--intern/cycles/render/alembic.cpp2
-rw-r--r--intern/cycles/render/constant_fold.cpp2
-rw-r--r--intern/cycles/render/geometry.cpp4
-rw-r--r--intern/cycles/render/graph.h10
-rw-r--r--intern/cycles/render/image_vdb.cpp200
-rw-r--r--intern/cycles/render/nodes.cpp10
-rw-r--r--intern/cycles/render/object.cpp7
-rw-r--r--intern/cycles/render/object.h3
-rw-r--r--intern/cycles/render/osl.h2
-rw-r--r--intern/cycles/render/session.cpp2
-rw-r--r--intern/cycles/render/svm.cpp2
-rw-r--r--intern/cycles/util/util_color.h2
-rw-r--r--intern/cycles/util/util_debug.h2
-rw-r--r--intern/cycles/util/util_math_fast.h2
-rw-r--r--intern/cycles/util/util_openvdb.h36
-rw-r--r--intern/cycles/util/util_task.h4
-rw-r--r--intern/ghost/CMakeLists.txt13
-rw-r--r--intern/ghost/GHOST_C-api.h6
-rw-r--r--intern/ghost/GHOST_ISystemPaths.h2
-rw-r--r--intern/ghost/intern/GHOST_ContextEGL.cpp4
-rw-r--r--intern/ghost/intern/GHOST_ContextEGL.h6
-rw-r--r--intern/ghost/intern/GHOST_ContextGLX.cpp2
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerCocoa.mm2
-rw-r--r--intern/ghost/intern/GHOST_IXrGraphicsBinding.h3
-rw-r--r--intern/ghost/intern/GHOST_System.h6
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.h2
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm55
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.cpp39
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp21
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp47
-rw-r--r--intern/ghost/intern/GHOST_Window.h2
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm6
-rw-r--r--intern/ghost/intern/GHOST_WindowWayland.cpp21
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp200
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.h11
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp6
-rw-r--r--intern/ghost/intern/GHOST_XrContext.cpp2
-rw-r--r--intern/ghost/intern/GHOST_XrGraphicsBinding.cpp26
-rw-r--r--intern/ghost/test/gears/GHOST_C-Test.c2
-rw-r--r--intern/ghost/test/multitest/MultiTest.c2
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h2
-rw-r--r--intern/guardedalloc/test/simpletest/memtest.c4
-rw-r--r--intern/itasc/kdl/frames.inl2
-rw-r--r--intern/libmv/libmv/image/array_nd.h2
-rw-r--r--intern/mantaflow/intern/manta_fluid_API.cpp2
-rw-r--r--intern/mikktspace/mikktspace.c10
-rw-r--r--intern/opencolorio/CMakeLists.txt4
-rw-r--r--intern/opencolorio/gpu_shader_display_transform.glsl2
-rw-r--r--intern/openvdb/openvdb_capi.h2
-rw-r--r--release/datafiles/userdef/userdef_default_theme.c5
-rw-r--r--release/freedesktop/blender.desktop2
-rw-r--r--release/scripts/modules/bpy_extras/anim_utils.py5
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/blender_default.py9
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py15
-rw-r--r--release/scripts/startup/bl_ui/properties_collection.py17
-rw-r--r--release/scripts/startup/bl_ui/properties_constraint.py1
-rw-r--r--release/scripts/startup/bl_ui/properties_data_mesh.py89
-rw-r--r--release/scripts/startup/bl_ui/properties_material.py14
-rw-r--r--release/scripts/startup/bl_ui/space_outliner.py4
-rw-r--r--release/scripts/startup/bl_ui/space_sequencer.py32
-rw-r--r--release/scripts/startup/bl_ui/space_spreadsheet.py4
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py2
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py1
-rw-r--r--release/scripts/startup/nodeitems_builtins.py9
-rw-r--r--source/blender/blenfont/intern/blf.c2
-rw-r--r--source/blender/blenfont/intern/blf_internal.h2
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h2
-rw-r--r--source/blender/blenkernel/BKE_action.h2
-rw-r--r--source/blender/blenkernel/BKE_animsys.h2
-rw-r--r--source/blender/blenkernel/BKE_armature.h20
-rw-r--r--source/blender/blenkernel/BKE_attribute.h8
-rw-r--r--source/blender/blenkernel/BKE_attribute_math.hh2
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/BKE_blendfile.h7
-rw-r--r--source/blender/blenkernel/BKE_bvhutils.h2
-rw-r--r--source/blender/blenkernel/BKE_cloth.h8
-rw-r--r--source/blender/blenkernel/BKE_collection.h3
-rw-r--r--source/blender/blenkernel/BKE_collision.h2
-rw-r--r--source/blender/blenkernel/BKE_constraint.h2
-rw-r--r--source/blender/blenkernel/BKE_curve.h4
-rw-r--r--source/blender/blenkernel/BKE_customdata.h19
-rw-r--r--source/blender/blenkernel/BKE_displist.h10
-rw-r--r--source/blender/blenkernel/BKE_editmesh.h10
-rw-r--r--source/blender/blenkernel/BKE_effect.h2
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h18
-rw-r--r--source/blender/blenkernel/BKE_font.h4
-rw-r--r--source/blender/blenkernel/BKE_geometry_set.hh2
-rw-r--r--source/blender/blenkernel/BKE_global.h2
-rw-r--r--source/blender/blenkernel/BKE_gpencil.h4
-rw-r--r--source/blender/blenkernel/BKE_gpencil_geom.h2
-rw-r--r--source/blender/blenkernel/BKE_idprop.h2
-rw-r--r--source/blender/blenkernel/BKE_idtype.h4
-rw-r--r--source/blender/blenkernel/BKE_key.h2
-rw-r--r--source/blender/blenkernel/BKE_layer.h14
-rw-r--r--source/blender/blenkernel/BKE_lib_id.h3
-rw-r--r--source/blender/blenkernel/BKE_lib_override.h7
-rw-r--r--source/blender/blenkernel/BKE_mesh.h9
-rw-r--r--source/blender/blenkernel/BKE_mesh_remap.h2
-rw-r--r--source/blender/blenkernel/BKE_mesh_runtime.h2
-rw-r--r--source/blender/blenkernel/BKE_multires.h2
-rw-r--r--source/blender/blenkernel/BKE_node.h5
-rw-r--r--source/blender/blenkernel/BKE_object.h23
-rw-r--r--source/blender/blenkernel/BKE_particle.h4
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h2
-rw-r--r--source/blender/blenkernel/BKE_screen.h4
-rw-r--r--source/blender/blenkernel/BKE_shader_fx.h2
-rw-r--r--source/blender/blenkernel/BKE_spline.hh8
-rw-r--r--source/blender/blenkernel/BKE_subsurf.h2
-rw-r--r--source/blender/blenkernel/BKE_text.h8
-rw-r--r--source/blender/blenkernel/BKE_tracking.h2
-rw-r--r--source/blender/blenkernel/BKE_undo_system.h2
-rw-r--r--source/blender/blenkernel/CMakeLists.txt4
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.cc26
-rw-r--r--source/blender/blenkernel/intern/action.c7
-rw-r--r--source/blender/blenkernel/intern/action_mirror.c2
-rw-r--r--source/blender/blenkernel/intern/anim_data.c4
-rw-r--r--source/blender/blenkernel/intern/anim_path.c2
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c6
-rw-r--r--source/blender/blenkernel/intern/appdir.c2
-rw-r--r--source/blender/blenkernel/intern/armature.c14
-rw-r--r--source/blender/blenkernel/intern/armature_test.cc2
-rw-r--r--source/blender/blenkernel/intern/armature_update.c2
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc2
-rw-r--r--source/blender/blenkernel/intern/blender_copybuffer.c6
-rw-r--r--source/blender/blenkernel/intern/blender_undo.c7
-rw-r--r--source/blender/blenkernel/intern/blendfile.c35
-rw-r--r--source/blender/blenkernel/intern/bvhutils.cc (renamed from source/blender/blenkernel/intern/bvhutils.c)216
-rw-r--r--source/blender/blenkernel/intern/camera.c4
-rw-r--r--source/blender/blenkernel/intern/collection.c13
-rw-r--r--source/blender/blenkernel/intern/colorband.c2
-rw-r--r--source/blender/blenkernel/intern/colortools.c8
-rw-r--r--source/blender/blenkernel/intern/constraint.c163
-rw-r--r--source/blender/blenkernel/intern/context.c7
-rw-r--r--source/blender/blenkernel/intern/curve.c40
-rw-r--r--source/blender/blenkernel/intern/curve_bevel.c2
-rw-r--r--source/blender/blenkernel/intern/curve_decimate.c4
-rw-r--r--source/blender/blenkernel/intern/curve_eval.cc10
-rw-r--r--source/blender/blenkernel/intern/customdata.c24
-rw-r--r--source/blender/blenkernel/intern/customdata_file.c4
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c4
-rw-r--r--source/blender/blenkernel/intern/displist.cc217
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c4
-rw-r--r--source/blender/blenkernel/intern/editmesh.c2
-rw-r--r--source/blender/blenkernel/intern/effect.c8
-rw-r--r--source/blender/blenkernel/intern/fcurve.c23
-rw-r--r--source/blender/blenkernel/intern/fluid.c4
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c2
-rw-r--r--source/blender/blenkernel/intern/font.c10
-rw-r--r--source/blender/blenkernel/intern/geometry_component_mesh.cc2
-rw-r--r--source/blender/blenkernel/intern/geometry_set.cc14
-rw-r--r--source/blender/blenkernel/intern/geometry_set_instances.cc6
-rw-r--r--source/blender/blenkernel/intern/gpencil.c79
-rw-r--r--source/blender/blenkernel/intern/gpencil_curve.c6
-rw-r--r--source/blender/blenkernel/intern/gpencil_geom.c118
-rw-r--r--source/blender/blenkernel/intern/idprop.c40
-rw-r--r--source/blender/blenkernel/intern/image.c12
-rw-r--r--source/blender/blenkernel/intern/image_save.c2
-rw-r--r--source/blender/blenkernel/intern/ipo.c20
-rw-r--r--source/blender/blenkernel/intern/key.c12
-rw-r--r--source/blender/blenkernel/intern/keyconfig.c2
-rw-r--r--source/blender/blenkernel/intern/lattice_deform.c6
-rw-r--r--source/blender/blenkernel/intern/layer.c20
-rw-r--r--source/blender/blenkernel/intern/layer_utils.c12
-rw-r--r--source/blender/blenkernel/intern/lib_id.c4
-rw-r--r--source/blender/blenkernel/intern/lib_id_eval.c48
-rw-r--r--source/blender/blenkernel/intern/lib_override.c121
-rw-r--r--source/blender/blenkernel/intern/lib_query.c2
-rw-r--r--source/blender/blenkernel/intern/mask.c2
-rw-r--r--source/blender/blenkernel/intern/mball.c2
-rw-r--r--source/blender/blenkernel/intern/mball_tessellate.c31
-rw-r--r--source/blender/blenkernel/intern/mesh.c25
-rw-r--r--source/blender/blenkernel/intern/mesh_boolean_convert.cc4
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c34
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c2114
-rw-r--r--source/blender/blenkernel/intern/mesh_mapping.c2
-rw-r--r--source/blender/blenkernel/intern/mesh_merge.c16
-rw-r--r--source/blender/blenkernel/intern/mesh_mirror.c6
-rw-r--r--source/blender/blenkernel/intern/mesh_normals.c2144
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.c10
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c4
-rw-r--r--source/blender/blenkernel/intern/movieclip.c6
-rw-r--r--source/blender/blenkernel/intern/multires.c6
-rw-r--r--source/blender/blenkernel/intern/multires_reshape.c2
-rw-r--r--source/blender/blenkernel/intern/multires_reshape_smooth.c6
-rw-r--r--source/blender/blenkernel/intern/multires_unsubdivide.c2
-rw-r--r--source/blender/blenkernel/intern/nla.c4
-rw-r--r--source/blender/blenkernel/intern/node.cc11
-rw-r--r--source/blender/blenkernel/intern/object.c17
-rw-r--r--source/blender/blenkernel/intern/object_dupli.cc14
-rw-r--r--source/blender/blenkernel/intern/object_update.c2
-rw-r--r--source/blender/blenkernel/intern/ocean.c16
-rw-r--r--source/blender/blenkernel/intern/ocean_intern.h2
-rw-r--r--source/blender/blenkernel/intern/ocean_spectrum.c2
-rw-r--r--source/blender/blenkernel/intern/paint.c2
-rw-r--r--source/blender/blenkernel/intern/particle.c2
-rw-r--r--source/blender/blenkernel/intern/particle_child.c2
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c2
-rw-r--r--source/blender/blenkernel/intern/particle_system.c26
-rw-r--r--source/blender/blenkernel/intern/pbvh.c2
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c4
-rw-r--r--source/blender/blenkernel/intern/pointcache.c26
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c6
-rw-r--r--source/blender/blenkernel/intern/scene.c7
-rw-r--r--source/blender/blenkernel/intern/screen.c4
-rw-r--r--source/blender/blenkernel/intern/shader_fx.c4
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c2
-rw-r--r--source/blender/blenkernel/intern/softbody.c184
-rw-r--r--source/blender/blenkernel/intern/spline_nurbs.cc2
-rw-r--r--source/blender/blenkernel/intern/subdiv_ccg.c6
-rw-r--r--source/blender/blenkernel/intern/subdiv_eval.c2
-rw-r--r--source/blender/blenkernel/intern/subdiv_foreach.c2
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c32
-rw-r--r--source/blender/blenkernel/intern/text.c6
-rw-r--r--source/blender/blenkernel/intern/tracking_stabilize.c2
-rw-r--r--source/blender/blenkernel/intern/undo_system.c4
-rw-r--r--source/blender/blenkernel/intern/unit.c6
-rw-r--r--source/blender/blenkernel/intern/volume.cc2
-rw-r--r--source/blender/blenkernel/intern/workspace.c4
-rw-r--r--source/blender/blenkernel/nla_private.h10
-rw-r--r--source/blender/blenlib/BLI_array.h5
-rw-r--r--source/blender/blenlib/BLI_buffer.h2
-rw-r--r--source/blender/blenlib/BLI_color.hh2
-rw-r--r--source/blender/blenlib/BLI_dlrbTree.h2
-rw-r--r--source/blender/blenlib/BLI_dynstr.h6
-rw-r--r--source/blender/blenlib/BLI_edgehash.h22
-rw-r--r--source/blender/blenlib/BLI_fnmatch.h26
-rw-r--r--source/blender/blenlib/BLI_ghash.h32
-rw-r--r--source/blender/blenlib/BLI_hash_md5.h4
-rw-r--r--source/blender/blenlib/BLI_linklist_stack.h2
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h1
-rw-r--r--source/blender/blenlib/BLI_math_vector.h7
-rw-r--r--source/blender/blenlib/BLI_mempool.h2
-rw-r--r--source/blender/blenlib/BLI_rand.h6
-rw-r--r--source/blender/blenlib/BLI_smallhash.h4
-rw-r--r--source/blender/blenlib/BLI_strict_flags.h2
-rw-r--r--source/blender/blenlib/BLI_string.h2
-rw-r--r--source/blender/blenlib/BLI_task.h2
-rw-r--r--source/blender/blenlib/BLI_threads.h2
-rw-r--r--source/blender/blenlib/BLI_utildefines.h13
-rw-r--r--source/blender/blenlib/BLI_vector.hh13
-rw-r--r--source/blender/blenlib/intern/BLI_dynstr.c8
-rw-r--r--source/blender/blenlib/intern/BLI_filelist.c2
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c50
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c2
-rw-r--r--source/blender/blenlib/intern/BLI_mempool.c2
-rw-r--r--source/blender/blenlib/intern/DLRB_tree.c4
-rw-r--r--source/blender/blenlib/intern/boxpack_2d.c10
-rw-r--r--source/blender/blenlib/intern/delaunay_2d.cc4
-rw-r--r--source/blender/blenlib/intern/edgehash.c14
-rw-r--r--source/blender/blenlib/intern/expr_pylike_eval.c20
-rw-r--r--source/blender/blenlib/intern/fnmatch.c2
-rw-r--r--source/blender/blenlib/intern/hash_md5.c30
-rw-r--r--source/blender/blenlib/intern/kdtree_impl.h2
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c6
-rw-r--r--source/blender/blenlib/intern/math_color.c18
-rw-r--r--source/blender/blenlib/intern/math_geom.c26
-rw-r--r--source/blender/blenlib/intern/math_matrix.c34
-rw-r--r--source/blender/blenlib/intern/math_rotation.c2
-rw-r--r--source/blender/blenlib/intern/mesh_intersect.cc28
-rw-r--r--source/blender/blenlib/intern/rand.cc37
-rw-r--r--source/blender/blenlib/intern/stack.c4
-rw-r--r--source/blender/blenlib/intern/storage.c2
-rw-r--r--source/blender/blenlib/intern/string.c43
-rw-r--r--source/blender/blenlib/intern/string_utf8.c4
-rw-r--r--source/blender/blenlib/intern/string_utils.c2
-rw-r--r--source/blender/blenlib/intern/system_win32.c2
-rw-r--r--source/blender/blenlib/intern/winstuff.c2
-rw-r--r--source/blender/blenlib/tests/BLI_kdopbvh_test.cc2
-rw-r--r--source/blender/blenlib/tests/BLI_listbase_test.cc2
-rw-r--r--source/blender/blenlib/tests/BLI_mesh_intersect_test.cc72
-rw-r--r--source/blender/blenlib/tests/BLI_string_test.cc95
-rw-r--r--source/blender/blenlib/tests/BLI_string_utf8_test.cc4
-rw-r--r--source/blender/blenloader/BLO_read_write.h11
-rw-r--r--source/blender/blenloader/BLO_readfile.h42
-rw-r--r--source/blender/blenloader/intern/blend_validate.c3
-rw-r--r--source/blender/blenloader/intern/readblenentry.c19
-rw-r--r--source/blender/blenloader/intern/readfile.c205
-rw-r--r--source/blender/blenloader/intern/readfile.h14
-rw-r--r--source/blender/blenloader/intern/readfile_tempload.c4
-rw-r--r--source/blender/blenloader/intern/versioning_250.c2
-rw-r--r--source/blender/blenloader/intern/versioning_260.c10
-rw-r--r--source/blender/blenloader/intern/versioning_280.c43
-rw-r--r--source/blender/blenloader/intern/versioning_290.c4
-rw-r--r--source/blender/blenloader/intern/versioning_300.c76
-rw-r--r--source/blender/blenloader/intern/versioning_cycles.c2
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c8
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c9
-rw-r--r--source/blender/blenloader/intern/writefile.c2
-rw-r--r--source/blender/blenloader/tests/blendfile_loading_base_test.cc3
-rw-r--r--source/blender/blentranslation/BLT_translation.h4
-rw-r--r--source/blender/bmesh/bmesh_class.h10
-rw-r--r--source/blender/bmesh/intern/bmesh_edgeloop.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_error.h41
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators.h4
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.h4
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c38
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_convert.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_normals.c12
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_partial_update.c261
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_partial_update.h19
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_tessellate.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c14
-rw-r--r--source/blender/bmesh/intern/bmesh_opdefines.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api.h16
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api_inline.h11
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c46
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_private.h17
-rw-r--r--source/blender/bmesh/intern/bmesh_query.c6
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c4
-rw-r--r--source/blender/bmesh/operators/bmo_bisect_plane.c2
-rw-r--r--source/blender/bmesh/operators/bmo_bridge.c8
-rw-r--r--source/blender/bmesh/operators/bmo_connect.c2
-rw-r--r--source/blender/bmesh/operators/bmo_connect_pair.c10
-rw-r--r--source/blender/bmesh/operators/bmo_dissolve.c11
-rw-r--r--source/blender/bmesh/operators/bmo_dupe.c10
-rw-r--r--source/blender/bmesh/operators/bmo_extrude.c6
-rw-r--r--source/blender/bmesh/operators/bmo_fill_grid.c8
-rw-r--r--source/blender/bmesh/operators/bmo_hull.c4
-rw-r--r--source/blender/bmesh/operators/bmo_inset.c6
-rw-r--r--source/blender/bmesh/operators/bmo_join_triangles.c2
-rw-r--r--source/blender/bmesh/operators/bmo_smooth_laplacian.c24
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c2
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide_edgering.c10
-rw-r--r--source/blender/bmesh/operators/bmo_triangulate.c3
-rw-r--r--source/blender/bmesh/tools/bmesh_beautify.c8
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c11
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_collapse.c4
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_dissolve.c3
-rw-r--r--source/blender/bmesh/tools/bmesh_intersect.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_separate.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_wireframe.c2
-rw-r--r--source/blender/compositor/COM_defines.h18
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.h8
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cc316
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h77
-rw-r--r--source/blender/compositor/intern/COM_MetaData.cc2
-rw-r--r--source/blender/compositor/intern/COM_MultiThreadedOperation.cc8
-rw-r--r--source/blender/compositor/intern/COM_MultiThreadedOperation.h9
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.cc2
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.cc68
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.h10
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.cc4
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.cc10
-rw-r--r--source/blender/compositor/operations/COM_ColorMatteOperation.cc6
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.cc4
-rw-r--r--source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cc6
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.cc18
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.h8
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.cc34
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.h19
-rw-r--r--source/blender/compositor/operations/COM_LuminanceMatteOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.cc7
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_SMAAOperation.cc2
-rw-r--r--source/blender/datatoc/datatoc_icon.c2
-rw-r--r--source/blender/depsgraph/CMakeLists.txt1
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_build.h4
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc32
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc10
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc5
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.h2
-rw-r--r--source/blender/depsgraph/intern/node/deg_node.h2
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_component.h42
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.h4
-rw-r--r--source/blender/draw/CMakeLists.txt20
-rw-r--r--source/blender/draw/engines/eevee/eevee_depth_of_field.c22
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c4
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c4
-rw-r--r--source/blender/draw/engines/eevee/eevee_motion_blur.c6
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h2
-rw-r--r--source/blender/draw/engines/eevee/eevee_shaders.c4
-rw-r--r--source/blender/draw/engines/eevee/eevee_shadows.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_subsurface.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_volumes.c2
-rw-r--r--source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/closure_type_lib.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_dilate_tiles_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_downsample_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_filter_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_flatten_tiles_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_reduce_frag.glsl6
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_resolve_frag.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_scatter_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_scatter_vert.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_setup_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/random_lib.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/surface_lib.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl2
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_cache_utils.c2
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c2
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_antialiasing_frag.glsl2
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl16
-rw-r--r--source/blender/draw/engines/image/shaders/engine_image_frag.glsl2
-rw-r--r--source/blender/draw/engines/overlay/overlay_armature.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_edit_uv.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_extra.c4
-rw-r--r--source/blender/draw/engines/overlay/overlay_motion_path.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_outline.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_particle.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_private.h2
-rw-r--r--source/blender/draw/engines/overlay/shaders/armature_shape_outline_geom.glsl2
-rw-r--r--source/blender/draw/engines/overlay/shaders/extra_vert.glsl8
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl2
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl2
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_image_lib.glsl2
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_dof.c6
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h8
-rw-r--r--source/blender/draw/engines/workbench/workbench_volume.c4
-rw-r--r--source/blender/draw/intern/DRW_render.h2
-rw-r--r--source/blender/draw/intern/draw_cache.c2
-rw-r--r--source/blender/draw/intern/draw_cache_extract.h5
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh.cc89
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh_extractors.c3552
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh_private.h79
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.cc2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_displist.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_lattice.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c416
-rw-r--r--source/blender/draw/intern/draw_common.h8
-rw-r--r--source/blender/draw/intern/draw_manager.c4
-rw-r--r--source/blender/draw/intern/draw_manager.h4
-rw-r--r--source/blender/draw/intern/draw_manager_data.c4
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc2
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc241
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc265
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc140
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc236
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc157
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_edituv_data.cc101
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_nor.cc200
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc119
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc127
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc228
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc654
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_orco.cc115
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc415
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc141
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_select_idx.cc295
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_skin_roots.cc93
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc266
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc136
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc191
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc189
-rw-r--r--source/blender/draw/tests/draw_testing.cc4
-rw-r--r--source/blender/draw/tests/draw_testing.hh8
-rw-r--r--source/blender/draw/tests/shaders_test.cc18
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c80
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c5
-rw-r--r--source/blender/editors/animation/anim_deps.c4
-rw-r--r--source/blender/editors/animation/anim_draw.c4
-rw-r--r--source/blender/editors/animation/anim_filter.c6
-rw-r--r--source/blender/editors/animation/drivers.c6
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c2
-rw-r--r--source/blender/editors/animation/keyframes_edit.c8
-rw-r--r--source/blender/editors/animation/keyframes_general.c10
-rw-r--r--source/blender/editors/animation/keyframing.c8
-rw-r--r--source/blender/editors/animation/keyingsets.c2
-rw-r--r--source/blender/editors/armature/armature_add.c12
-rw-r--r--source/blender/editors/armature/armature_edit.c8
-rw-r--r--source/blender/editors/armature/armature_relations.c6
-rw-r--r--source/blender/editors/armature/armature_utils.c2
-rw-r--r--source/blender/editors/armature/pose_edit.c6
-rw-r--r--source/blender/editors/armature/pose_lib.c8
-rw-r--r--source/blender/editors/armature/pose_slide.c6
-rw-r--r--source/blender/editors/armature/pose_transform.c2
-rw-r--r--source/blender/editors/armature/pose_utils.c6
-rw-r--r--source/blender/editors/curve/editcurve.c6
-rw-r--r--source/blender/editors/curve/editcurve_query.c4
-rw-r--r--source/blender/editors/curve/editcurve_select.c211
-rw-r--r--source/blender/editors/curve/editcurve_undo.c4
-rw-r--r--source/blender/editors/geometry/geometry_attributes.c21
-rw-r--r--source/blender/editors/gizmo_library/gizmo_library_utils.c4
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c4
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c17
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c2
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_armature.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_bake_animation.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c35
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c23
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c12
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h51
-rw-r--r--source/blender/editors/gpencil/gpencil_mesh.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c25
-rw-r--r--source/blender/editors/gpencil/gpencil_sculpt_paint.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_trace_utils.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c32
-rw-r--r--source/blender/editors/gpencil/gpencil_vertex_ops.c14
-rw-r--r--source/blender/editors/gpencil/gpencil_vertex_paint.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_weight_paint.c4
-rw-r--r--source/blender/editors/include/ED_curve.h8
-rw-r--r--source/blender/editors/include/ED_datafiles.h176
-rw-r--r--source/blender/editors/include/ED_fileselect.h10
-rw-r--r--source/blender/editors/include/ED_gizmo_library.h2
-rw-r--r--source/blender/editors/include/ED_gpencil.h16
-rw-r--r--source/blender/editors/include/ED_keyframes_edit.h2
-rw-r--r--source/blender/editors/include/ED_keyframing.h4
-rw-r--r--source/blender/editors/include/ED_mask.h2
-rw-r--r--source/blender/editors/include/ED_mesh.h7
-rw-r--r--source/blender/editors/include/ED_node.h2
-rw-r--r--source/blender/editors/include/ED_object.h5
-rw-r--r--source/blender/editors/include/ED_spreadsheet.h4
-rw-r--r--source/blender/editors/include/ED_undo.h2
-rw-r--r--source/blender/editors/include/ED_view3d.h4
-rw-r--r--source/blender/editors/include/UI_icons.h2
-rw-r--r--source/blender/editors/include/UI_interface.h41
-rw-r--r--source/blender/editors/include/UI_view2d.h2
-rw-r--r--source/blender/editors/interface/interface.c105
-rw-r--r--source/blender/editors/interface/interface_align.c3
-rw-r--r--source/blender/editors/interface/interface_draw.c3
-rw-r--r--source/blender/editors/interface/interface_eyedropper_gpencil_color.c2
-rw-r--r--source/blender/editors/interface/interface_handlers.c34
-rw-r--r--source/blender/editors/interface/interface_intern.h34
-rw-r--r--source/blender/editors/interface/interface_layout.c66
-rw-r--r--source/blender/editors/interface/interface_panel.c1
-rw-r--r--source/blender/editors/interface/interface_query.c6
-rw-r--r--source/blender/editors/interface/interface_region_menu_popup.c7
-rw-r--r--source/blender/editors/interface/interface_region_popup.c2
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c10
-rw-r--r--source/blender/editors/interface/interface_style.c2
-rw-r--r--source/blender/editors/interface/interface_templates.c16
-rw-r--r--source/blender/editors/interface/interface_undo.c2
-rw-r--r--source/blender/editors/interface/interface_widgets.c42
-rw-r--r--source/blender/editors/interface/view2d.c16
-rw-r--r--source/blender/editors/interface/view2d_gizmo_navigate.c2
-rw-r--r--source/blender/editors/interface/view2d_ops.c10
-rw-r--r--source/blender/editors/lattice/editlattice_select.c31
-rw-r--r--source/blender/editors/mask/mask_editaction.c12
-rw-r--r--source/blender/editors/mask/mask_ops.c4
-rw-r--r--source/blender/editors/mask/mask_query.c2
-rw-r--r--source/blender/editors/mask/mask_select.c1
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c2
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c8
-rw-r--r--source/blender/editors/mesh/editmesh_knife_project.c4
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c2
-rw-r--r--source/blender/editors/mesh/editmesh_select.c17
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c34
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c119
-rw-r--r--source/blender/editors/mesh/mesh_data.c5
-rw-r--r--source/blender/editors/mesh/mesh_intern.h8
-rw-r--r--source/blender/editors/object/object_add.c30
-rw-r--r--source/blender/editors/object/object_bake_api.c2
-rw-r--r--source/blender/editors/object/object_constraint.c6
-rw-r--r--source/blender/editors/object/object_data_transfer.c10
-rw-r--r--source/blender/editors/object/object_edit.c8
-rw-r--r--source/blender/editors/object/object_hook.c4
-rw-r--r--source/blender/editors/object/object_modes.c4
-rw-r--r--source/blender/editors/object/object_modifier.c4
-rw-r--r--source/blender/editors/object/object_ops.c2
-rw-r--r--source/blender/editors/object/object_relations.c4
-rw-r--r--source/blender/editors/object/object_remesh.c11
-rw-r--r--source/blender/editors/object/object_select.c28
-rw-r--r--source/blender/editors/object/object_transform.c12
-rw-r--r--source/blender/editors/object/object_vgroup.c16
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c2
-rw-r--r--source/blender/editors/physics/particle_edit.c14
-rw-r--r--source/blender/editors/physics/physics_intern.h2
-rw-r--r--source/blender/editors/render/render_opengl.c10
-rw-r--r--source/blender/editors/render/render_preview.c2
-rw-r--r--source/blender/editors/render/render_shading.c6
-rw-r--r--source/blender/editors/render/render_update.c2
-rw-r--r--source/blender/editors/render/render_view.c8
-rw-r--r--source/blender/editors/screen/area.c6
-rw-r--r--source/blender/editors/screen/screen_context.c2
-rw-r--r--source/blender/editors/screen/screen_draw.c2
-rw-r--r--source/blender/editors/screen/screen_edit.c8
-rw-r--r--source/blender/editors/screen/screen_ops.c16
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c46
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c3
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c20
-rw-r--r--source/blender/editors/space_action/action_data.c2
-rw-r--r--source/blender/editors/space_action/action_draw.c2
-rw-r--r--source/blender/editors/space_action/action_edit.c6
-rw-r--r--source/blender/editors/space_action/action_select.c8
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c21
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c8
-rw-r--r--source/blender/editors/space_clip/clip_utils.c2
-rw-r--r--source/blender/editors/space_console/console_ops.c2
-rw-r--r--source/blender/editors/space_file/file_draw.c42
-rw-r--r--source/blender/editors/space_file/file_ops.c10
-rw-r--r--source/blender/editors/space_file/file_panels.c4
-rw-r--r--source/blender/editors/space_file/filelist.c183
-rw-r--r--source/blender/editors/space_file/filelist.h9
-rw-r--r--source/blender/editors/space_file/filesel.c18
-rw-r--r--source/blender/editors/space_file/space_file.c4
-rw-r--r--source/blender/editors/space_graph/graph_draw.c4
-rw-r--r--source/blender/editors/space_graph/graph_edit.c2
-rw-r--r--source/blender/editors/space_graph/graph_select.c10
-rw-r--r--source/blender/editors/space_graph/graph_slider_ops.c6
-rw-r--r--source/blender/editors/space_graph/graph_view.c4
-rw-r--r--source/blender/editors/space_graph/space_graph.c4
-rw-r--r--source/blender/editors/space_image/image_ops.c2
-rw-r--r--source/blender/editors/space_image/image_undo.c2
-rw-r--r--source/blender/editors/space_info/info_report.c4
-rw-r--r--source/blender/editors/space_info/info_stats.c12
-rw-r--r--source/blender/editors/space_nla/nla_draw.c4
-rw-r--r--source/blender/editors/space_nla/nla_edit.c6
-rw-r--r--source/blender/editors/space_nla/nla_select.c2
-rw-r--r--source/blender/editors/space_node/drawnode.cc12
-rw-r--r--source/blender/editors/space_node/node_draw.cc6
-rw-r--r--source/blender/editors/space_node/node_edit.cc8
-rw-r--r--source/blender/editors/space_node/node_group.cc2
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c8
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c12
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c1
-rw-r--r--source/blender/editors/space_outliner/tree/tree_display_libraries.cc4
-rw-r--r--source/blender/editors/space_outliner/tree/tree_display_view_layer.cc68
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_overrides.cc4
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_overrides.hh1
-rw-r--r--source/blender/editors/space_script/space_script.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c8
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c13
-rw-r--r--source/blender/editors/space_spreadsheet/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_spreadsheet/space_spreadsheet.cc109
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_context.cc4
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc9
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc287
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.hh64
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_dataset_layout.cc112
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_dataset_layout.hh68
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_intern.hh13
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_ops.cc53
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc12
-rw-r--r--source/blender/editors/space_statusbar/space_statusbar.c2
-rw-r--r--source/blender/editors/space_text/text_draw.c2
-rw-r--r--source/blender/editors/space_text/text_format_pov.c4
-rw-r--r--source/blender/editors/space_text/text_ops.c6
-rw-r--r--source/blender/editors/space_view3d/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_view3d/drawobject.c6
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_camera_control.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h4
-rw-r--r--source/blender/editors/space_view3d/view3d_iterators.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_navigate_fly.c (renamed from source/blender/editors/space_view3d/view3d_fly.c)18
-rw-r--r--source/blender/editors/space_view3d/view3d_navigate_walk.c (renamed from source/blender/editors/space_view3d/view3d_walk.c)9
-rw-r--r--source/blender/editors/space_view3d/view3d_placement.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_project.c11
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c4
-rw-r--r--source/blender/editors/transform/CMakeLists.txt1
-rw-r--r--source/blender/editors/transform/transform.c26
-rw-r--r--source/blender/editors/transform/transform.h27
-rw-r--r--source/blender/editors/transform/transform_constraints.c84
-rw-r--r--source/blender/editors/transform/transform_constraints.h4
-rw-r--r--source/blender/editors/transform/transform_convert.c7
-rw-r--r--source/blender/editors/transform/transform_convert.h4
-rw-r--r--source/blender/editors/transform/transform_convert_action.c17
-rw-r--r--source/blender/editors/transform/transform_convert_armature.c8
-rw-r--r--source/blender/editors/transform/transform_convert_curve.c2
-rw-r--r--source/blender/editors/transform/transform_convert_gpencil.c8
-rw-r--r--source/blender/editors/transform/transform_convert_mesh.c393
-rw-r--r--source/blender/editors/transform/transform_convert_sequencer.c77
-rw-r--r--source/blender/editors/transform/transform_data.h4
-rw-r--r--source/blender/editors/transform/transform_generics.c5
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c2
-rw-r--r--source/blender/editors/transform/transform_input.c11
-rw-r--r--source/blender/editors/transform/transform_mode.c49
-rw-r--r--source/blender/editors/transform/transform_mode.h22
-rw-r--r--source/blender/editors/transform/transform_mode_bend.c236
-rw-r--r--source/blender/editors/transform/transform_mode_edge_bevelweight.c70
-rw-r--r--source/blender/editors/transform/transform_mode_edge_crease.c76
-rw-r--r--source/blender/editors/transform/transform_mode_edge_seq_slide.c23
-rw-r--r--source/blender/editors/transform/transform_mode_edge_slide.c16
-rw-r--r--source/blender/editors/transform/transform_mode_push_pull.c119
-rw-r--r--source/blender/editors/transform/transform_mode_resize.c52
-rw-r--r--source/blender/editors/transform/transform_mode_rotate.c219
-rw-r--r--source/blender/editors/transform/transform_mode_shear.c136
-rw-r--r--source/blender/editors/transform/transform_mode_shrink_fatten.c72
-rw-r--r--source/blender/editors/transform/transform_mode_skin_resize.c96
-rw-r--r--source/blender/editors/transform/transform_mode_tosphere.c123
-rw-r--r--source/blender/editors/transform/transform_mode_trackball.c80
-rw-r--r--source/blender/editors/transform/transform_mode_translate.c323
-rw-r--r--source/blender/editors/transform/transform_snap.c289
-rw-r--r--source/blender/editors/transform/transform_snap.h14
-rw-r--r--source/blender/editors/transform/transform_snap_object.c10
-rw-r--r--source/blender/editors/transform/transform_snap_sequencer.c270
-rw-r--r--source/blender/editors/undo/memfile_undo.c14
-rw-r--r--source/blender/editors/util/ed_transverts.c4
-rw-r--r--source/blender/editors/util/ed_util.c7
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c14
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c24
-rw-r--r--source/blender/editors/uvedit/uvedit_rip.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c19
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c8
-rw-r--r--source/blender/freestyle/intern/application/AppCanvas.h14
-rw-r--r--source/blender/freestyle/intern/application/AppView.h10
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h10
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h2
-rw-r--r--source/blender/freestyle/intern/geometry/FastGrid.h10
-rw-r--r--source/blender/freestyle/intern/geometry/FitCurve.h4
-rw-r--r--source/blender/freestyle/intern/geometry/GeomCleaner.cpp2
-rw-r--r--source/blender/freestyle/intern/geometry/GeomCleaner.h18
-rw-r--r--source/blender/freestyle/intern/geometry/GeomUtils.h32
-rw-r--r--source/blender/freestyle/intern/geometry/Grid.h42
-rw-r--r--source/blender/freestyle/intern/geometry/GridHelpers.h2
-rw-r--r--source/blender/freestyle/intern/geometry/HashGrid.h12
-rw-r--r--source/blender/freestyle/intern/geometry/Noise.h18
-rw-r--r--source/blender/freestyle/intern/geometry/Polygon.h2
-rw-r--r--source/blender/freestyle/intern/geometry/SweepLine.h8
-rw-r--r--source/blender/freestyle/intern/image/GaussianFilter.h8
-rw-r--r--source/blender/freestyle/intern/image/Image.h36
-rw-r--r--source/blender/freestyle/intern/image/ImagePyramid.h12
-rw-r--r--source/blender/freestyle/intern/python/BPy_BBox.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_BBox.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsMaterial.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsNoise.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsNoise.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_Id.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Id.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_IntegrationType.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface0D.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface1D.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_Iterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Iterator.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_MediumType.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Nature.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Operators.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_SShape.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_SShape.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeShader.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewMap.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewMap.h3
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewShape.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewShape.h3
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp2
-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_BezierCurveShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp2
-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_GuidingLinesShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp2
-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_SamplingShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.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_UnaryFunction0DVec2f.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.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_ViewShape/BPy_GetOccludeeF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.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_GetParameterF0D.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_ReadMapPixelF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp2
-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_vector_ViewShape/BPy_GetOccludersF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp2
-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_GetDirectionalViewMapDensityF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp2
-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_GetViewMapGradientNormF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.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_vector_ViewShape/BPy_GetOccludeeF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp2
-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_TimeStampF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/scene_graph/DrawingStyle.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/FrsMaterial.h80
-rw-r--r--source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h18
-rw-r--r--source/blender/freestyle/intern/scene_graph/LineRep.h18
-rw-r--r--source/blender/freestyle/intern/scene_graph/Node.h14
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeCamera.h14
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h12
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeGroup.cpp2
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeGroup.h18
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeLight.h16
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeShape.h14
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeTransform.h18
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeViewLayer.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/OrientedLineRep.h8
-rw-r--r--source/blender/freestyle/intern/scene_graph/Rep.h8
-rw-r--r--source/blender/freestyle/intern/scene_graph/TriangleRep.h14
-rw-r--r--source/blender/freestyle/intern/scene_graph/VertexRep.h8
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h48
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp2
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h52
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedPredicates1D.h8
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h26
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.h102
-rw-r--r--source/blender/freestyle/intern/stroke/Canvas.h18
-rw-r--r--source/blender/freestyle/intern/stroke/Chain.h16
-rw-r--r--source/blender/freestyle/intern/stroke/ChainingIterators.h52
-rw-r--r--source/blender/freestyle/intern/stroke/ContextFunctions.h18
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.cpp2
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.h98
-rw-r--r--source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h2
-rw-r--r--source/blender/freestyle/intern/stroke/CurveIterators.h2
-rw-r--r--source/blender/freestyle/intern/stroke/Modifiers.h12
-rw-r--r--source/blender/freestyle/intern/stroke/Operators.h24
-rw-r--r--source/blender/freestyle/intern/stroke/PSStrokeRenderer.h2
-rw-r--r--source/blender/freestyle/intern/stroke/Predicates0D.h36
-rw-r--r--source/blender/freestyle/intern/stroke/Predicates1D.h114
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.h202
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h2
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeIterators.h42
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeLayer.h8
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRenderer.h6
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.h8
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeShader.h10
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeTesselator.h4
-rw-r--r--source/blender/freestyle/intern/stroke/TextStrokeRenderer.h2
-rw-r--r--source/blender/freestyle/intern/system/BaseObject.h6
-rw-r--r--source/blender/freestyle/intern/system/Id.h26
-rw-r--r--source/blender/freestyle/intern/system/ProgressBar.h2
-rw-r--r--source/blender/freestyle/intern/view_map/FEdgeXDetector.h12
-rw-r--r--source/blender/freestyle/intern/view_map/Functions0D.h132
-rw-r--r--source/blender/freestyle/intern/view_map/Functions1D.h164
-rw-r--r--source/blender/freestyle/intern/view_map/Interface0D.h82
-rw-r--r--source/blender/freestyle/intern/view_map/Interface1D.h50
-rw-r--r--source/blender/freestyle/intern/view_map/Silhouette.h250
-rw-r--r--source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h16
-rw-r--r--source/blender/freestyle/intern/view_map/SphericalGrid.h2
-rw-r--r--source/blender/freestyle/intern/view_map/SteerableViewMap.h24
-rw-r--r--source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h28
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.cpp4
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.h238
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h6
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.h28
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapIterators.h66
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapTesselator.h10
-rw-r--r--source/blender/freestyle/intern/winged_edge/Curvature.cpp8
-rw-r--r--source/blender/freestyle/intern/winged_edge/Nature.h32
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.cpp2
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.h72
-rw-r--r--source/blender/freestyle/intern/winged_edge/WFillGrid.h4
-rw-r--r--source/blender/freestyle/intern/winged_edge/WSFillGrid.h4
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.h42
-rw-r--r--source/blender/functions/FN_cpp_type.hh469
-rw-r--r--source/blender/functions/FN_cpp_type_make.hh201
-rw-r--r--source/blender/functions/FN_generic_pointer.hh2
-rw-r--r--source/blender/functions/FN_generic_value_map.hh6
-rw-r--r--source/blender/functions/FN_generic_vector_array.hh2
-rw-r--r--source/blender/functions/FN_generic_virtual_array.hh4
-rw-r--r--source/blender/functions/FN_multi_function_builder.hh2
-rw-r--r--source/blender/functions/intern/cpp_types.cc22
-rw-r--r--source/blender/functions/intern/generic_vector_array.cc4
-rw-r--r--source/blender/functions/intern/generic_virtual_array.cc30
-rw-r--r--source/blender/functions/intern/generic_virtual_vector_array.cc4
-rw-r--r--source/blender/functions/intern/multi_function_builder.cc11
-rw-r--r--source/blender/functions/intern/multi_function_network_optimization.cc2
-rw-r--r--source/blender/functions/tests/FN_cpp_type_test.cc42
-rw-r--r--source/blender/gpencil_modifiers/CMakeLists.txt1
-rw-r--r--source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h1
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c14
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c7
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c128
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c111
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c84
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c43
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilweight.c335
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h39
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c97
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c238
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h6
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c2
-rw-r--r--source/blender/gpu/CMakeLists.txt3
-rw-r--r--source/blender/gpu/GPU_shader.h1
-rw-r--r--source/blender/gpu/GPU_viewport.h20
-rw-r--r--source/blender/gpu/intern/gpu_index_buffer_private.hh2
-rw-r--r--source/blender/gpu/intern/gpu_select_pick.c6
-rw-r--r--source/blender/gpu/intern/gpu_select_sample_query.cc8
-rw-r--r--source/blender/gpu/intern/gpu_shader.cc202
-rw-r--r--source/blender/gpu/intern/gpu_shader_log.cc217
-rw-r--r--source/blender/gpu/intern/gpu_shader_private.hh44
-rw-r--r--source/blender/gpu/intern/gpu_texture.cc2
-rw-r--r--source/blender/gpu/intern/gpu_vertex_buffer.cc2
-rw-r--r--source/blender/gpu/intern/gpu_vertex_format.cc11
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c2
-rw-r--r--source/blender/gpu/opengl/gl_backend.cc38
-rw-r--r--source/blender/gpu/opengl/gl_framebuffer.cc2
-rw-r--r--source/blender/gpu/opengl/gl_immediate.cc2
-rw-r--r--source/blender/gpu/opengl/gl_shader.cc12
-rw-r--r--source/blender/gpu/opengl/gl_shader.hh11
-rw-r--r--source/blender/gpu/opengl/gl_shader_log.cc87
-rw-r--r--source/blender/gpu/opengl/gl_texture.cc4
-rw-r--r--source/blender/gpu/opengl/gl_texture.hh2
-rw-r--r--source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl4
-rw-r--r--source/blender/gpu/tests/gpu_index_buffer_test.cc4
-rw-r--r--source/blender/gpu/tests/gpu_shader_builtin_test.cc94
-rw-r--r--source/blender/gpu/tests/gpu_shader_test.cc15
-rw-r--r--source/blender/gpu/tests/gpu_testing.hh18
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c2
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp2
-rw-r--r--source/blender/imbuf/IMB_imbuf.h19
-rw-r--r--source/blender/imbuf/intern/anim_movie.c2
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.c2
-rw-r--r--source/blender/imbuf/intern/dds/ColorBlock.cpp2
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.h2
-rw-r--r--source/blender/imbuf/intern/divers.c2
-rw-r--r--source/blender/imbuf/intern/imageprocess.c4
-rw-r--r--source/blender/imbuf/intern/indexer.c2
-rw-r--r--source/blender/imbuf/intern/iris.c4
-rw-r--r--source/blender/imbuf/intern/jp2.c30
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp2
-rw-r--r--source/blender/imbuf/intern/targa.c22
-rw-r--r--source/blender/imbuf/intern/thumbs.c6
-rw-r--r--source/blender/imbuf/intern/thumbs_blend.c3
-rw-r--r--source/blender/io/alembic/intern/abc_reader_object.cc2
-rw-r--r--source/blender/io/alembic/intern/alembic_capi.cc2
-rw-r--r--source/blender/io/collada/ArmatureImporter.cpp4
-rw-r--r--source/blender/io/collada/BCAnimationCurve.cpp2
-rw-r--r--source/blender/io/collada/BCAnimationSampler.cpp4
-rw-r--r--source/blender/io/collada/BCAnimationSampler.h2
-rw-r--r--source/blender/io/collada/DocumentImporter.h8
-rw-r--r--source/blender/io/collada/GeometryExporter.cpp2
-rw-r--r--source/blender/io/collada/MeshImporter.cpp2
-rw-r--r--source/blender/io/collada/SkinInfo.cpp2
-rw-r--r--source/blender/io/collada/collada_utils.cpp6
-rw-r--r--source/blender/io/gpencil/intern/gpencil_io_base.cc2
-rw-r--r--source/blender/io/gpencil/intern/gpencil_io_export_svg.cc2
-rw-r--r--source/blender/io/gpencil/intern/gpencil_io_export_svg.hh2
-rw-r--r--source/blender/io/usd/intern/usd_writer_mesh.cc2
-rw-r--r--source/blender/makesdna/DNA_ID.h27
-rw-r--r--source/blender/makesdna/DNA_ID_enums.h4
-rw-r--r--source/blender/makesdna/DNA_action_types.h2
-rw-r--r--source/blender/makesdna/DNA_anim_types.h18
-rw-r--r--source/blender/makesdna/DNA_armature_types.h12
-rw-r--r--source/blender/makesdna/DNA_boid_types.h2
-rw-r--r--source/blender/makesdna/DNA_brush_defaults.h2
-rw-r--r--source/blender/makesdna/DNA_brush_enums.h2
-rw-r--r--source/blender/makesdna/DNA_camera_types.h8
-rw-r--r--source/blender/makesdna/DNA_cloth_types.h4
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h35
-rw-r--r--source/blender/makesdna/DNA_curveprofile_types.h2
-rw-r--r--source/blender/makesdna/DNA_effect_types.h20
-rw-r--r--source/blender/makesdna/DNA_fluid_types.h6
-rw-r--r--source/blender/makesdna/DNA_genfile.h4
-rw-r--r--source/blender/makesdna/DNA_gpencil_modifier_defaults.h19
-rw-r--r--source/blender/makesdna/DNA_gpencil_modifier_types.h97
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h6
-rw-r--r--source/blender/makesdna/DNA_ipo_types.h6
-rw-r--r--source/blender/makesdna/DNA_key_types.h8
-rw-r--r--source/blender/makesdna/DNA_lightprobe_types.h2
-rw-r--r--source/blender/makesdna/DNA_lineart_types.h22
-rw-r--r--source/blender/makesdna/DNA_material_types.h17
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h4
-rw-r--r--source/blender/makesdna/DNA_meta_types.h2
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h10
-rw-r--r--source/blender/makesdna/DNA_node_types.h20
-rw-r--r--source/blender/makesdna/DNA_object_fluidsim_types.h2
-rw-r--r--source/blender/makesdna/DNA_object_force_types.h4
-rw-r--r--source/blender/makesdna/DNA_object_types.h20
-rw-r--r--source/blender/makesdna/DNA_particle_types.h10
-rw-r--r--source/blender/makesdna/DNA_scene_types.h38
-rw-r--r--source/blender/makesdna/DNA_screen_types.h4
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h4
-rw-r--r--source/blender/makesdna/DNA_shader_fx_types.h4
-rw-r--r--source/blender/makesdna/DNA_space_types.h116
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h4
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h8
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h2
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h2
-rw-r--r--source/blender/makesdna/intern/dna_defaults.c2
-rw-r--r--source/blender/makesdna/intern/dna_rename_defs.h3
-rw-r--r--source/blender/makesdna/intern/makesdna.c22
-rw-r--r--source/blender/makesrna/RNA_access.h6
-rw-r--r--source/blender/makesrna/RNA_types.h2
-rw-r--r--source/blender/makesrna/intern/makesrna.c6
-rw-r--r--source/blender/makesrna/intern/rna_access.c26
-rw-r--r--source/blender/makesrna/intern/rna_access_compare_override.c2
-rw-r--r--source/blender/makesrna/intern/rna_action.c2
-rw-r--r--source/blender/makesrna/intern/rna_animation.c4
-rw-r--r--source/blender/makesrna/intern/rna_animation_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_armature.c4
-rw-r--r--source/blender/makesrna/intern/rna_attribute.c10
-rw-r--r--source/blender/makesrna/intern/rna_boid.c10
-rw-r--r--source/blender/makesrna/intern/rna_camera.c2
-rw-r--r--source/blender/makesrna/intern/rna_color.c6
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c62
-rw-r--r--source/blender/makesrna/intern/rna_context.c2
-rw-r--r--source/blender/makesrna/intern/rna_curve.c10
-rw-r--r--source/blender/makesrna/intern/rna_define.c12
-rw-r--r--source/blender/makesrna/intern/rna_dynamicpaint.c2
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c14
-rw-r--r--source/blender/makesrna/intern/rna_fluid.c2
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c2
-rw-r--r--source/blender/makesrna/intern/rna_gpencil_modifier.c374
-rw-r--r--source/blender/makesrna/intern/rna_internal_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_layer.c2
-rw-r--r--source/blender/makesrna/intern/rna_mask.c4
-rw-r--r--source/blender/makesrna/intern/rna_material.c18
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c28
-rw-r--r--source/blender/makesrna/intern/rna_mesh_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c2
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c55
-rw-r--r--source/blender/makesrna/intern/rna_object.c2
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c7
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c10
-rw-r--r--source/blender/makesrna/intern/rna_particle.c48
-rw-r--r--source/blender/makesrna/intern/rna_pose.c2
-rw-r--r--source/blender/makesrna/intern/rna_render.c1
-rw-r--r--source/blender/makesrna/intern/rna_rna.c8
-rw-r--r--source/blender/makesrna/intern/rna_scene.c51
-rw-r--r--source/blender/makesrna/intern/rna_screen.c2
-rw-r--r--source/blender/makesrna/intern/rna_sound.c2
-rw-r--r--source/blender/makesrna/intern/rna_space.c33
-rw-r--r--source/blender/makesrna/intern/rna_texture.c2
-rw-r--r--source/blender/makesrna/intern/rna_texture_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_ui.c2
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c33
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c15
-rw-r--r--source/blender/makesrna/intern/rna_wm.c4
-rw-r--r--source/blender/modifiers/intern/MOD_array.c2
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c2
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c2
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c26
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache.c6
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c2
-rw-r--r--source/blender/modifiers/intern/MOD_nodes.cc12
-rw-r--r--source/blender/modifiers/intern/MOD_nodes_evaluator.cc32
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c4
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c49
-rw-r--r--source/blender/modifiers/intern/MOD_solidify_extrude.c4
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c2
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c2
-rw-r--r--source/blender/modifiers/intern/MOD_ui_common.c2
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c2
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c4
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c6
-rw-r--r--source/blender/nodes/CMakeLists.txt5
-rw-r--r--source/blender/nodes/NOD_derived_node_tree.hh2
-rw-r--r--source/blender/nodes/NOD_geometry.h5
-rw-r--r--source/blender/nodes/NOD_geometry_exec.hh2
-rw-r--r--source/blender/nodes/NOD_node_tree_ref.hh4
-rw-r--r--source/blender/nodes/NOD_static_types.h5
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_channelMatte.c8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_levels.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_rotate.c2
-rw-r--r--source/blender/nodes/geometry/node_geometry_exec.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc13
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc3
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc1
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_attribute_transfer.cc6
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc6
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc149
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc227
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc82
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc107
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc81
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc10
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc6
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc3
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_raycast.cc2
-rw-r--r--source/blender/nodes/intern/derived_node_tree.cc2
-rw-r--r--source/blender/nodes/intern/node_socket.cc8
-rw-r--r--source/blender/nodes/intern/node_tree_ref.cc37
-rw-r--r--source/blender/nodes/intern/type_conversions.cc2
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_hair_info.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops.c6
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops_call.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops_call.h4
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c4
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_meshdata.c4
-rw-r--r--source/blender/python/generic/bgl.c44
-rw-r--r--source/blender/python/generic/idprop_py_api.c36
-rw-r--r--source/blender/python/generic/imbuf_py_api.c2
-rw-r--r--source/blender/python/gpu/gpu_py_buffer.c12
-rw-r--r--source/blender/python/gpu/gpu_py_framebuffer.c4
-rw-r--r--source/blender/python/gpu/gpu_py_framebuffer.h3
-rw-r--r--source/blender/python/gpu/gpu_py_matrix.c4
-rw-r--r--source/blender/python/gpu/gpu_py_offscreen.c4
-rw-r--r--source/blender/python/gpu/gpu_py_offscreen.h3
-rw-r--r--source/blender/python/gpu/gpu_py_texture.h3
-rw-r--r--source/blender/python/gpu/gpu_py_uniformbuffer.h3
-rw-r--r--source/blender/python/intern/bpy_app_translations.c10
-rw-r--r--source/blender/python/intern/bpy_driver.c4
-rw-r--r--source/blender/python/intern/bpy_interface.c6
-rw-r--r--source/blender/python/intern/bpy_interface_run.c3
-rw-r--r--source/blender/python/intern/bpy_library_load.c15
-rw-r--r--source/blender/python/intern/bpy_operator.h2
-rw-r--r--source/blender/python/intern/bpy_props.h4
-rw-r--r--source/blender/python/intern/bpy_rna.c74
-rw-r--r--source/blender/python/intern/bpy_rna.h26
-rw-r--r--source/blender/python/intern/bpy_rna_array.c4
-rw-r--r--source/blender/python/intern/bpy_rna_data.c10
-rw-r--r--source/blender/python/mathutils/mathutils_Color.h2
-rw-r--r--source/blender/python/mathutils/mathutils_Euler.c4
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c52
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.c12
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c22
-rw-r--r--source/blender/python/mathutils/mathutils_bvhtree.c3
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c4
-rw-r--r--source/blender/python/mathutils/mathutils_kdtree.c3
-rw-r--r--source/blender/python/mathutils/mathutils_noise.c12
-rw-r--r--source/blender/render/RE_bake.h2
-rw-r--r--source/blender/render/intern/bake.c2
-rw-r--r--source/blender/render/intern/engine.c8
-rw-r--r--source/blender/render/intern/initrender.c4
-rw-r--r--source/blender/render/intern/multires_bake.c4
-rw-r--r--source/blender/render/intern/pipeline.c2
-rw-r--r--source/blender/render/intern/render_result.c6
-rw-r--r--source/blender/render/intern/render_result.h2
-rw-r--r--source/blender/render/intern/texture_image.c10
-rw-r--r--source/blender/render/intern/texture_pointdensity.c2
-rw-r--r--source/blender/sequencer/SEQ_iterator.h3
-rw-r--r--source/blender/sequencer/SEQ_sequencer.h3
-rw-r--r--source/blender/sequencer/SEQ_utils.h2
-rw-r--r--source/blender/sequencer/intern/clipboard.c2
-rw-r--r--source/blender/sequencer/intern/effects.c12
-rw-r--r--source/blender/sequencer/intern/iterator.c20
-rw-r--r--source/blender/sequencer/intern/modifier.c2
-rw-r--r--source/blender/sequencer/intern/prefetch.c8
-rw-r--r--source/blender/sequencer/intern/render.c4
-rw-r--r--source/blender/sequencer/intern/sequence_lookup.c2
-rw-r--r--source/blender/sequencer/intern/sequencer.c21
-rw-r--r--source/blender/sequencer/intern/strip_edit.c4
-rw-r--r--source/blender/sequencer/intern/strip_time.c2
-rw-r--r--source/blender/sequencer/intern/utils.c2
-rw-r--r--source/blender/simulation/intern/SIM_mass_spring.cpp10
-rw-r--r--source/blender/simulation/intern/hair_volume.cpp4
-rw-r--r--source/blender/simulation/intern/implicit_blender.c8
-rw-r--r--source/blender/windowmanager/WM_api.h24
-rw-r--r--source/blender/windowmanager/WM_toolsystem.h2
-rw-r--r--source/blender/windowmanager/WM_types.h9
-rw-r--r--source/blender/windowmanager/gizmo/WM_gizmo_types.h4
-rw-r--r--source/blender/windowmanager/intern/wm.c2
-rw-r--r--source/blender/windowmanager/intern/wm_event_query.c2
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c10
-rw-r--r--source/blender/windowmanager/intern/wm_files.c110
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c6
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c40
-rw-r--r--source/blender/windowmanager/intern/wm_keymap_utils.c2
-rw-r--r--source/blender/windowmanager/intern/wm_operator_type.c2
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c10
-rw-r--r--source/blender/windowmanager/intern/wm_platform_support.c2
-rw-r--r--source/blender/windowmanager/intern/wm_stereo.c2
-rw-r--r--source/blender/windowmanager/intern/wm_window.c13
-rw-r--r--source/blender/windowmanager/wm_event_types.h2
-rw-r--r--tests/python/bl_constraints.py64
1331 files changed, 21024 insertions, 14001 deletions
diff --git a/.clang-format b/.clang-format
index 9cc3cdeaaf8..bf20a4e4c4a 100644
--- a/.clang-format
+++ b/.clang-format
@@ -265,4 +265,5 @@ ForEachMacros:
- VECTOR_SET_SLOT_PROBING_BEGIN
StatementMacros:
+ - PyObject_HEAD
- PyObject_VAR_HEAD
diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake
index d93b8463b4b..38cadff2202 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -216,9 +216,9 @@ set(OPENVDB_HASH 01b490be16cc0e15c690f9a153c21461)
set(OPENVDB_HASH_TYPE MD5)
set(OPENVDB_FILE openvdb-${OPENVDB_VERSION}.tar.gz)
-set(NANOVDB_GIT_UID e62f7a0bf1e27397223c61ddeaaf57edf111b77f)
+set(NANOVDB_GIT_UID dc37d8a631922e7bef46712947dc19b755f3e841)
set(NANOVDB_URI https://github.com/AcademySoftwareFoundation/openvdb/archive/${NANOVDB_GIT_UID}.tar.gz)
-set(NANOVDB_HASH 90919510bc6ccd630fedc56f748cb199)
+set(NANOVDB_HASH e7b9e863ec2f3b04ead171dec2322807)
set(NANOVDB_HASH_TYPE MD5)
set(NANOVDB_FILE nano-vdb-${NANOVDB_GIT_UID}.tar.gz)
diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
index 808e154955d..22fb6602d7a 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -1073,7 +1073,7 @@ OPENVDB_SOURCE=( "https://github.com/AcademySoftwareFoundation/openvdb/archive/v
#~ OPENVDB_SOURCE_REPO_BRANCH="dev"
NANOVDB_USE_REPO=false
-NANOVDB_SOURCE_REPO_UID="e62f7a0bf1e27397223c61ddeaaf57edf111b77f"
+NANOVDB_SOURCE_REPO_UID="dc37d8a631922e7bef46712947dc19b755f3e841"
NANOVDB_SOURCE=( "https://github.com/AcademySoftwareFoundation/openvdb/archive/${NANOVDB_SOURCE_REPO_UID}.tar.gz" )
ALEMBIC_USE_REPO=false
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 8b9a48fca74..a0e91199c72 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -550,7 +550,6 @@ if(WITH_OPENIMAGEIO)
set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG})
set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0")
- set(OPENCOLORIO_DEFINITIONS "-DDOpenColorIO_SKIP_IMPORTS")
set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe")
add_definitions(-DOIIO_STATIC_DEFINE)
add_definitions(-DOIIO_NO_SSE=1)
@@ -596,7 +595,7 @@ if(WITH_OPENCOLORIO)
debug ${OPENCOLORIO_LIBPATH}/libexpatdMD.lib
debug ${OPENCOLORIO_LIBPATH}/pystring_d.lib
)
- set(OPENCOLORIO_DEFINITIONS)
+ set(OPENCOLORIO_DEFINITIONS "-DOpenColorIO_SKIP_IMPORTS")
endif()
if(WITH_OPENVDB)
diff --git a/extern/audaspace/include/devices/SoftwareDevice.h b/extern/audaspace/include/devices/SoftwareDevice.h
index 209be9941b1..c3af5cfd902 100644
--- a/extern/audaspace/include/devices/SoftwareDevice.h
+++ b/extern/audaspace/include/devices/SoftwareDevice.h
@@ -266,6 +266,12 @@ protected:
void setSpecs(Specs specs);
/**
+ * Sets the audio output specification of the device.
+ * \param specs The output specification.
+ */
+ void setSpecs(DeviceSpecs specs);
+
+ /**
* Empty default constructor. To setup the device call the function create()
* and to uninitialize call destroy().
*/
diff --git a/extern/audaspace/include/respec/Mixer.h b/extern/audaspace/include/respec/Mixer.h
index 600467826cd..9880d5fdcae 100644
--- a/extern/audaspace/include/respec/Mixer.h
+++ b/extern/audaspace/include/respec/Mixer.h
@@ -88,6 +88,12 @@ public:
void setSpecs(Specs specs);
/**
+ * Sets the target specification for superposing.
+ * \param specs The target specification.
+ */
+ void setSpecs(DeviceSpecs specs);
+
+ /**
* Mixes a buffer.
* \param buffer The buffer to superpose.
* \param start The start sample of the buffer.
diff --git a/extern/audaspace/plugins/pulseaudio/PulseAudioDevice.cpp b/extern/audaspace/plugins/pulseaudio/PulseAudioDevice.cpp
index 3ffe97661d8..cbfb5e96e6c 100644
--- a/extern/audaspace/plugins/pulseaudio/PulseAudioDevice.cpp
+++ b/extern/audaspace/plugins/pulseaudio/PulseAudioDevice.cpp
@@ -78,6 +78,7 @@ void PulseAudioDevice::runMixingThread()
if(shouldStop())
{
AUD_pa_stream_cork(m_stream, 1, nullptr, nullptr);
+ AUD_pa_stream_flush(m_stream, nullptr, nullptr);
doStop();
return;
}
@@ -86,7 +87,10 @@ void PulseAudioDevice::runMixingThread()
if(AUD_pa_stream_is_corked(m_stream))
AUD_pa_stream_cork(m_stream, 0, nullptr, nullptr);
- AUD_pa_mainloop_iterate(m_mainloop, true, nullptr);
+ // similar to AUD_pa_mainloop_iterate(m_mainloop, false, nullptr); except with a longer timeout
+ AUD_pa_mainloop_prepare(m_mainloop, 1 << 14);
+ AUD_pa_mainloop_poll(m_mainloop);
+ AUD_pa_mainloop_dispatch(m_mainloop);
}
}
diff --git a/extern/audaspace/plugins/pulseaudio/PulseAudioSymbols.h b/extern/audaspace/plugins/pulseaudio/PulseAudioSymbols.h
index 4b9e1ffea2b..361aa518087 100644
--- a/extern/audaspace/plugins/pulseaudio/PulseAudioSymbols.h
+++ b/extern/audaspace/plugins/pulseaudio/PulseAudioSymbols.h
@@ -24,6 +24,7 @@ PULSEAUDIO_SYMBOL(pa_context_unref);
PULSEAUDIO_SYMBOL(pa_stream_begin_write);
PULSEAUDIO_SYMBOL(pa_stream_connect_playback);
PULSEAUDIO_SYMBOL(pa_stream_cork);
+PULSEAUDIO_SYMBOL(pa_stream_flush);
PULSEAUDIO_SYMBOL(pa_stream_is_corked);
PULSEAUDIO_SYMBOL(pa_stream_new);
PULSEAUDIO_SYMBOL(pa_stream_set_buffer_attr);
@@ -35,3 +36,6 @@ PULSEAUDIO_SYMBOL(pa_mainloop_free);
PULSEAUDIO_SYMBOL(pa_mainloop_get_api);
PULSEAUDIO_SYMBOL(pa_mainloop_new);
PULSEAUDIO_SYMBOL(pa_mainloop_iterate);
+PULSEAUDIO_SYMBOL(pa_mainloop_prepare);
+PULSEAUDIO_SYMBOL(pa_mainloop_poll);
+PULSEAUDIO_SYMBOL(pa_mainloop_dispatch);
diff --git a/extern/audaspace/plugins/wasapi/WASAPIDevice.cpp b/extern/audaspace/plugins/wasapi/WASAPIDevice.cpp
index b4632ebb83e..a5382bb9692 100644
--- a/extern/audaspace/plugins/wasapi/WASAPIDevice.cpp
+++ b/extern/audaspace/plugins/wasapi/WASAPIDevice.cpp
@@ -31,65 +31,81 @@ template <class T> void SafeRelease(T **ppT)
}
}
-void WASAPIDevice::runMixingThread()
+HRESULT WASAPIDevice::setupRenderClient(IAudioRenderClient*& render_client, UINT32& buffer_size)
{
- UINT32 buffer_size;
+ const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);
+
UINT32 padding;
UINT32 length;
data_t* buffer;
- IAudioRenderClient* render_client = nullptr;
+ HRESULT result;
- {
- std::lock_guard<ILockable> lock(*this);
+ if(FAILED(result = m_audio_client->GetBufferSize(&buffer_size)))
+ return result;
- const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);
+ if(FAILED(result = m_audio_client->GetService(IID_IAudioRenderClient, reinterpret_cast<void**>(&render_client))))
+ return result;
- if(FAILED(m_audio_client->GetBufferSize(&buffer_size)))
- goto init_error;
+ if(FAILED(result = m_audio_client->GetCurrentPadding(&padding)))
+ return result;
- if(FAILED(m_audio_client->GetService(IID_IAudioRenderClient, reinterpret_cast<void**>(&render_client))))
- goto init_error;
+ length = buffer_size - padding;
- if(FAILED(m_audio_client->GetCurrentPadding(&padding)))
- goto init_error;
+ if(FAILED(result = render_client->GetBuffer(length, &buffer)))
+ return result;
- length = buffer_size - padding;
+ mix((data_t*)buffer, length);
- if(FAILED(render_client->GetBuffer(length, &buffer)))
- goto init_error;
+ if(FAILED(result = render_client->ReleaseBuffer(length, 0)))
+ return result;
- mix((data_t*)buffer, length);
+ m_audio_client->Start();
- if(FAILED(render_client->ReleaseBuffer(length, 0)))
- {
- init_error:
- SafeRelease(&render_client);
- doStop();
- return;
- }
- }
+ return result;
+}
- m_audio_client->Start();
+void WASAPIDevice::runMixingThread()
+{
+ UINT32 buffer_size;
+
+ IAudioRenderClient* render_client = nullptr;
+
+ std::chrono::milliseconds sleep_duration;
- auto sleepDuration = std::chrono::milliseconds(buffer_size * 1000 / int(m_specs.rate) / 2);
+ bool run_init = true;
for(;;)
{
+ HRESULT result = S_OK;
+
{
+ UINT32 padding;
+ UINT32 length;
+ data_t* buffer;
std::lock_guard<ILockable> lock(*this);
- if(FAILED(m_audio_client->GetCurrentPadding(&padding)))
+ if(run_init)
+ {
+ result = setupRenderClient(render_client, buffer_size);
+
+ if(FAILED(result))
+ goto stop_thread;
+
+ sleep_duration = std::chrono::milliseconds(buffer_size * 1000 / int(m_specs.rate) / 2);
+ }
+
+ if(FAILED(result = m_audio_client->GetCurrentPadding(&padding)))
goto stop_thread;
length = buffer_size - padding;
- if(FAILED(render_client->GetBuffer(length, &buffer)))
+ if(FAILED(result = render_client->GetBuffer(length, &buffer)))
goto stop_thread;
mix((data_t*)buffer, length);
- if(FAILED(render_client->ReleaseBuffer(length, 0)))
+ if(FAILED(result = render_client->ReleaseBuffer(length, 0)))
goto stop_thread;
// stop thread
@@ -98,53 +114,51 @@ void WASAPIDevice::runMixingThread()
stop_thread:
m_audio_client->Stop();
SafeRelease(&render_client);
- doStop();
- return;
+
+ if(result == AUDCLNT_E_DEVICE_INVALIDATED)
+ {
+ DeviceSpecs specs = m_specs;
+ if(!setupDevice(specs))
+ result = S_FALSE;
+ else
+ {
+ setSpecs(specs);
+
+ run_init = true;
+ }
+ }
+
+ if(result != AUDCLNT_E_DEVICE_INVALIDATED)
+ {
+ doStop();
+ return;
+ }
}
}
- std::this_thread::sleep_for(sleepDuration);
+ std::this_thread::sleep_for(sleep_duration);
}
}
-WASAPIDevice::WASAPIDevice(DeviceSpecs specs, int buffersize) :
- m_imm_device_enumerator(nullptr),
- m_imm_device(nullptr),
- m_audio_client(nullptr),
-
- m_wave_format_extensible({})
+bool WASAPIDevice::setupDevice(DeviceSpecs &specs)
{
- // initialize COM if it hasn't happened yet
- CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+ SafeRelease(&m_audio_client);
+ SafeRelease(&m_imm_device);
- const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
- const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
const IID IID_IAudioClient = __uuidof(IAudioClient);
+ if(FAILED(m_imm_device_enumerator->GetDefaultAudioEndpoint(eRender, eMultimedia, &m_imm_device)))
+ return false;
+
+ if(FAILED(m_imm_device->Activate(IID_IAudioClient, CLSCTX_ALL, nullptr, reinterpret_cast<void**>(&m_audio_client))))
+ return false;
+
WAVEFORMATEXTENSIBLE wave_format_extensible_closest_match;
WAVEFORMATEXTENSIBLE* closest_match_pointer = &wave_format_extensible_closest_match;
- HRESULT result;
-
REFERENCE_TIME minimum_time = 0;
REFERENCE_TIME buffer_duration;
- if(FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, IID_IMMDeviceEnumerator, reinterpret_cast<void**>(&m_imm_device_enumerator))))
- goto error;
-
- if(FAILED(m_imm_device_enumerator->GetDefaultAudioEndpoint(eRender, eMultimedia, &m_imm_device)))
- goto error;
-
- if(FAILED(m_imm_device->Activate(IID_IAudioClient, CLSCTX_ALL, nullptr, reinterpret_cast<void**>(&m_audio_client))))
- goto error;
-
- if(specs.channels == CHANNELS_INVALID)
- specs.channels = CHANNELS_STEREO;
- if(specs.format == FORMAT_INVALID)
- specs.format = FORMAT_FLOAT32;
- if(specs.rate == RATE_INVALID)
- specs.rate = RATE_48000;
-
switch(specs.format)
{
case FORMAT_U8:
@@ -203,12 +217,14 @@ WASAPIDevice::WASAPIDevice(DeviceSpecs specs, int buffersize) :
m_wave_format_extensible.Format.cbSize = 22;
m_wave_format_extensible.Samples.wValidBitsPerSample = m_wave_format_extensible.Format.wBitsPerSample;
- result = m_audio_client->IsFormatSupported(AUDCLNT_SHAREMODE_SHARED, reinterpret_cast<const WAVEFORMATEX*>(&m_wave_format_extensible), reinterpret_cast<WAVEFORMATEX**>(&closest_match_pointer));
+ HRESULT result = m_audio_client->IsFormatSupported(AUDCLNT_SHAREMODE_SHARED, reinterpret_cast<const WAVEFORMATEX*>(&m_wave_format_extensible), reinterpret_cast<WAVEFORMATEX**>(&closest_match_pointer));
if(result == S_FALSE)
{
+ bool errored = false;
+
if(closest_match_pointer->Format.wFormatTag != WAVE_FORMAT_EXTENSIBLE)
- goto error;
+ goto closest_match_error;
specs.channels = Channels(closest_match_pointer->Format.nChannels);
specs.rate = closest_match_pointer->Format.nSamplesPerSec;
@@ -220,7 +236,7 @@ WASAPIDevice::WASAPIDevice(DeviceSpecs specs, int buffersize) :
else if(closest_match_pointer->Format.wBitsPerSample == 64)
specs.format = FORMAT_FLOAT64;
else
- goto error;
+ goto closest_match_error;
}
else if(closest_match_pointer->SubFormat == KSDATAFORMAT_SUBTYPE_PCM)
{
@@ -239,44 +255,81 @@ WASAPIDevice::WASAPIDevice(DeviceSpecs specs, int buffersize) :
specs.format = FORMAT_S32;
break;
default:
- goto error;
+ goto closest_match_error;
break;
}
}
else
- goto error;
+ goto closest_match_error;
m_wave_format_extensible = *closest_match_pointer;
+ if(false)
+ {
+ closest_match_error:
+ errored = true;
+ }
+
if(closest_match_pointer != &wave_format_extensible_closest_match)
{
CoTaskMemFree(closest_match_pointer);
closest_match_pointer = &wave_format_extensible_closest_match;
}
+
+ if(errored)
+ return false;
}
else if(FAILED(result))
- goto error;
+ return false;
if(FAILED(m_audio_client->GetDevicePeriod(nullptr, &minimum_time)))
- goto error;
+ return false;
- buffer_duration = REFERENCE_TIME(buffersize) * REFERENCE_TIME(10000000) / REFERENCE_TIME(specs.rate);
+ buffer_duration = REFERENCE_TIME(m_buffersize) * REFERENCE_TIME(10000000) / REFERENCE_TIME(specs.rate);
if(minimum_time > buffer_duration)
buffer_duration = minimum_time;
- m_specs = specs;
-
if(FAILED(m_audio_client->Initialize(AUDCLNT_SHAREMODE_SHARED, 0, buffer_duration, 0, reinterpret_cast<WAVEFORMATEX*>(&m_wave_format_extensible), nullptr)))
+ return false;
+
+ return true;
+}
+
+WASAPIDevice::WASAPIDevice(DeviceSpecs specs, int buffersize) :
+ m_buffersize(buffersize),
+ m_imm_device_enumerator(nullptr),
+ m_imm_device(nullptr),
+ m_audio_client(nullptr),
+
+ m_wave_format_extensible({})
+{
+ // initialize COM if it hasn't happened yet
+ CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+
+ const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
+ const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
+
+ if(specs.channels == CHANNELS_INVALID)
+ specs.channels = CHANNELS_STEREO;
+ if(specs.format == FORMAT_INVALID)
+ specs.format = FORMAT_FLOAT32;
+ if(specs.rate == RATE_INVALID)
+ specs.rate = RATE_48000;
+
+ if(FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, IID_IMMDeviceEnumerator, reinterpret_cast<void**>(&m_imm_device_enumerator))))
+ goto error;
+
+ if(!setupDevice(specs))
goto error;
+ m_specs = specs;
+
create();
return;
error:
- if(closest_match_pointer != &wave_format_extensible_closest_match)
- CoTaskMemFree(closest_match_pointer);
SafeRelease(&m_imm_device);
SafeRelease(&m_imm_device_enumerator);
SafeRelease(&m_audio_client);
diff --git a/extern/audaspace/plugins/wasapi/WASAPIDevice.h b/extern/audaspace/plugins/wasapi/WASAPIDevice.h
index 375f03bd255..3b11adc98ef 100644
--- a/extern/audaspace/plugins/wasapi/WASAPIDevice.h
+++ b/extern/audaspace/plugins/wasapi/WASAPIDevice.h
@@ -43,16 +43,21 @@ AUD_NAMESPACE_BEGIN
class AUD_PLUGIN_API WASAPIDevice : public ThreadedDevice
{
private:
+ int m_buffersize;
IMMDeviceEnumerator* m_imm_device_enumerator;
IMMDevice* m_imm_device;
IAudioClient* m_audio_client;
WAVEFORMATEXTENSIBLE m_wave_format_extensible;
+ AUD_LOCAL HRESULT setupRenderClient(IAudioRenderClient*& render_client, UINT32& buffer_size);
+
/**
* Streaming thread main function.
*/
AUD_LOCAL void runMixingThread();
+ AUD_LOCAL bool setupDevice(DeviceSpecs& specs);
+
// delete copy constructor and operator=
WASAPIDevice(const WASAPIDevice&) = delete;
WASAPIDevice& operator=(const WASAPIDevice&) = delete;
diff --git a/extern/audaspace/src/devices/SoftwareDevice.cpp b/extern/audaspace/src/devices/SoftwareDevice.cpp
index 7a2561515f4..e11b49a0967 100644
--- a/extern/audaspace/src/devices/SoftwareDevice.cpp
+++ b/extern/audaspace/src/devices/SoftwareDevice.cpp
@@ -756,6 +756,7 @@ void SoftwareDevice::mix(data_t* buffer, int length)
// get the buffer from the source
pos = 0;
len = length;
+ eos = false;
// update 3D Info
sound->update();
@@ -842,6 +843,27 @@ void SoftwareDevice::setSpecs(Specs specs)
{
sound->setSpecs(specs);
}
+
+ for(auto& sound : m_pausedSounds)
+ {
+ sound->setSpecs(specs);
+ }
+}
+
+void SoftwareDevice::setSpecs(DeviceSpecs specs)
+{
+ m_specs = specs;
+ m_mixer->setSpecs(specs);
+
+ for(auto& sound : m_playingSounds)
+ {
+ sound->setSpecs(specs.specs);
+ }
+
+ for(auto& sound : m_pausedSounds)
+ {
+ sound->setSpecs(specs.specs);
+ }
}
SoftwareDevice::SoftwareDevice()
diff --git a/extern/audaspace/src/respec/Mixer.cpp b/extern/audaspace/src/respec/Mixer.cpp
index ad8d885df4e..15872fbcff2 100644
--- a/extern/audaspace/src/respec/Mixer.cpp
+++ b/extern/audaspace/src/respec/Mixer.cpp
@@ -21,9 +21,25 @@
AUD_NAMESPACE_BEGIN
-Mixer::Mixer(DeviceSpecs specs) :
- m_specs(specs)
+Mixer::Mixer(DeviceSpecs specs)
{
+ setSpecs(specs);
+}
+
+DeviceSpecs Mixer::getSpecs() const
+{
+ return m_specs;
+}
+
+void Mixer::setSpecs(Specs specs)
+{
+ m_specs.specs = specs;
+}
+
+void Mixer::setSpecs(DeviceSpecs specs)
+{
+ m_specs = specs;
+
switch(m_specs.format)
{
case FORMAT_U8:
@@ -54,16 +70,6 @@ Mixer::Mixer(DeviceSpecs specs) :
}
}
-DeviceSpecs Mixer::getSpecs() const
-{
- return m_specs;
-}
-
-void Mixer::setSpecs(Specs specs)
-{
- m_specs.specs = specs;
-}
-
void Mixer::clear(int length)
{
m_buffer.assureSize(length * AUD_SAMPLE_SIZE(m_specs));
diff --git a/intern/clog/clog.c b/intern/clog/clog.c
index 416ea25ee0c..13f656d67ab 100644
--- a/intern/clog/clog.c
+++ b/intern/clog/clog.c
@@ -79,15 +79,15 @@ typedef struct CLG_IDFilter {
} CLG_IDFilter;
typedef struct CLogContext {
- /** Single linked list of types. */
+ /** Single linked list of types. */
CLG_LogType *types;
- /** Single linked list of references. */
+ /** Single linked list of references. */
CLG_LogRef *refs;
#ifdef WITH_CLOG_PTHREADS
pthread_mutex_t types_lock;
#endif
- /* exclude, include filters. */
+ /* exclude, include filters. */
CLG_IDFilter *filters[2];
bool use_color;
bool use_basename;
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index d2aecf75121..276d850f1b3 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -51,12 +51,12 @@ CCL_NAMESPACE_BEGIN
/* XML reading state */
struct XMLReadState : public XMLReader {
- Scene *scene; /* scene pointer */
- Transform tfm; /* current transform state */
- bool smooth; /* smooth normal state */
- Shader *shader; /* current shader */
- string base; /* base path to current file*/
- float dicing_rate; /* current dicing rate */
+ Scene *scene; /* Scene pointer. */
+ Transform tfm; /* Current transform state. */
+ bool smooth; /* Smooth normal state. */
+ Shader *shader; /* Current shader. */
+ string base; /* Base path to current file. */
+ float dicing_rate; /* Current dicing rate. */
XMLReadState() : scene(NULL), smooth(false), shader(NULL), dicing_rate(1.0f)
{
@@ -385,7 +385,7 @@ static Mesh *xml_add_mesh(Scene *scene, const Transform &tfm)
Mesh *mesh = new Mesh();
scene->geometry.push_back(mesh);
- /* create object*/
+ /* Create object. */
Object *object = new Object();
object->set_geometry(mesh);
object->set_tfm(tfm);
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index cda1355eb2d..71e2f9fc3a5 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -1254,12 +1254,19 @@ class CyclesObjectSettings(bpy.types.PropertyGroup):
)
shadow_terminator_offset: FloatProperty(
- name="Shadow Terminator Offset",
+ name="Shadow Terminator Shading Offset",
description="Push the shadow terminator towards the light to hide artifacts on low poly geometry",
min=0.0, max=1.0,
default=0.0,
)
+ shadow_terminator_geometry_offset: FloatProperty(
+ name="Shadow Terminator Geometry Offset",
+ description="Offset rays from the surface to reduce shadow terminator artifact on low poly geometry. Only affects triangles at grazing angles to light",
+ min=0.0, max=1.0,
+ default=0.1,
+ )
+
is_shadow_catcher: BoolProperty(
name="Shadow Catcher",
description="Only render shadows on this object, for compositing renders into real footage",
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index ce93bd96bd5..3d990467f04 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -821,6 +821,11 @@ class CYCLES_RENDER_PT_filter(CyclesButtonsPanel, Panel):
col.prop(view_layer, "use_strand", text="Hair")
col.prop(view_layer, "use_volumes", text="Volumes")
+ col = layout.column(heading="Use")
+ sub = col.row()
+ sub.prop(view_layer, "use_motion_blur", text="Motion Blur")
+ sub.active = rd.use_motion_blur
+
class CYCLES_RENDER_PT_override(CyclesButtonsPanel, Panel):
bl_label = "Override"
@@ -1218,20 +1223,31 @@ class CYCLES_OBJECT_PT_shading(CyclesButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- return CyclesButtonsPanel.poll(context) and (context.object)
+ if not CyclesButtonsPanel.poll(context):
+ return False
+
+ ob = context.object
+ return ob and has_geometry_visibility(ob)
+
+ def draw(self, context):
+ pass
+
+
+class CYCLES_OBJECT_PT_shading_shadow_terminator(CyclesButtonsPanel, Panel):
+ bl_label = "Shadow Terminator"
+ bl_parent_id = "CYCLES_OBJECT_PT_shading"
+ bl_context = "object"
def draw(self, context):
layout = self.layout
layout.use_property_split = True
- flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
- layout = self.layout
+ flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
+
ob = context.object
cob = ob.cycles
-
- if has_geometry_visibility(ob):
- col = flow.column()
- col.prop(cob, "shadow_terminator_offset")
+ flow.prop(cob, "shadow_terminator_geometry_offset", text="Geometry Offset")
+ flow.prop(cob, "shadow_terminator_offset", text="Shading Offset")
class CYCLES_OBJECT_PT_visibility(CyclesButtonsPanel, Panel):
@@ -2311,6 +2327,7 @@ classes = (
CYCLES_PT_context_material,
CYCLES_OBJECT_PT_motion_blur,
CYCLES_OBJECT_PT_shading,
+ CYCLES_OBJECT_PT_shading_shadow_terminator,
CYCLES_OBJECT_PT_visibility,
CYCLES_OBJECT_PT_visibility_ray_visibility,
CYCLES_OBJECT_PT_visibility_culling,
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 7fe49a6c63b..85d886fd850 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -533,7 +533,7 @@ void BlenderSync::sync_particle_hair(
return;
}
- /* extract particle hair data - should be combined with connecting to mesh later*/
+ /* Extract particle hair data - should be combined with connecting to mesh later. */
ParticleCurveData CData;
diff --git a/intern/cycles/blender/blender_light.cpp b/intern/cycles/blender/blender_light.cpp
index ae353b32633..50cd9e3db5c 100644
--- a/intern/cycles/blender/blender_light.cpp
+++ b/intern/cycles/blender/blender_light.cpp
@@ -44,7 +44,7 @@ void BlenderSync::sync_light(BL::Object &b_parent,
const bool tfm_updated = (light && light->get_tfm() != tfm);
/* Update if either object or light data changed. */
- if (!tfm_updated && !light_map.add_or_update(&light, b_ob, b_parent, key)) {
+ if (!light_map.add_or_update(&light, b_ob, b_parent, key) && !tfm_updated) {
Shader *shader;
if (!shader_map.add_or_update(&shader, b_light)) {
if (light->get_is_portal())
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index cb84013c551..635392fb3d4 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -290,8 +290,12 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
bool is_shadow_catcher = get_boolean(cobject, "is_shadow_catcher");
object->set_is_shadow_catcher(is_shadow_catcher);
- float shadow_terminator_offset = get_float(cobject, "shadow_terminator_offset");
- object->set_shadow_terminator_offset(shadow_terminator_offset);
+ float shadow_terminator_shading_offset = get_float(cobject, "shadow_terminator_offset");
+ object->set_shadow_terminator_shading_offset(shadow_terminator_shading_offset);
+
+ float shadow_terminator_geometry_offset = get_float(cobject,
+ "shadow_terminator_geometry_offset");
+ object->set_shadow_terminator_geometry_offset(shadow_terminator_geometry_offset);
/* sync the asset name for Cryptomatte */
BL::Object parent = b_ob.parent();
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index 82b3abd4432..3b3a193b3e8 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -281,7 +281,6 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render,
void BlenderSync::sync_integrator()
{
- BL::RenderSettings r = b_scene.render();
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
experimental = (get_enum(cscene, "feature_set") != 0);
@@ -325,7 +324,7 @@ void BlenderSync::sync_integrator()
integrator->set_sample_clamp_direct(get_float(cscene, "sample_clamp_direct"));
integrator->set_sample_clamp_indirect(get_float(cscene, "sample_clamp_indirect"));
if (!preview) {
- integrator->set_motion_blur(r.use_motion_blur());
+ integrator->set_motion_blur(view_layer.use_motion_blur);
}
integrator->set_method((Integrator::Method)get_enum(
@@ -456,6 +455,8 @@ void BlenderSync::sync_view_layer(BL::ViewLayer &b_view_layer)
view_layer.use_surfaces = b_view_layer.use_solid() || scene->bake_manager->get_baking();
view_layer.use_hair = b_view_layer.use_strand();
view_layer.use_volumes = b_view_layer.use_volumes();
+ view_layer.use_motion_blur = b_view_layer.use_motion_blur() &&
+ b_scene.render().use_motion_blur();
/* Material override. */
view_layer.material_override = b_view_layer.material_override();
@@ -602,8 +603,10 @@ vector<Pass> BlenderSync::sync_render_passes(BL::Scene &b_scene,
for (BL::RenderPass &b_pass : b_rlay.passes) {
PassType pass_type = get_pass_type(b_pass);
- if (pass_type == PASS_MOTION && b_scene.render().use_motion_blur())
+ if (pass_type == PASS_MOTION &&
+ (b_view_layer.use_motion_blur() && b_scene.render().use_motion_blur())) {
continue;
+ }
if (pass_type != PASS_NONE)
Pass::add(pass_type, passes, b_pass.name().c_str());
}
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index 1c98e529190..949482b1f9c 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -246,6 +246,7 @@ class BlenderSync {
use_surfaces(true),
use_hair(true),
use_volumes(true),
+ use_motion_blur(true),
samples(0),
bound_samples(false)
{
@@ -258,6 +259,7 @@ class BlenderSync {
bool use_surfaces;
bool use_hair;
bool use_volumes;
+ bool use_motion_blur;
int samples;
bool bound_samples;
} view_layer;
diff --git a/intern/cycles/bvh/bvh_embree.cpp b/intern/cycles/bvh/bvh_embree.cpp
index 07d5d672dce..62f543941a9 100644
--- a/intern/cycles/bvh/bvh_embree.cpp
+++ b/intern/cycles/bvh/bvh_embree.cpp
@@ -181,7 +181,7 @@ static void rtc_filter_occluded_func(const RTCFilterFunctionNArguments *args)
/* record intersection */
ctx->local_isect->hits[hit_idx] = current_isect;
ctx->local_isect->Ng[hit_idx] = normalize(make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z));
- /* This tells Embree to continue tracing .*/
+ /* This tells Embree to continue tracing. */
*args->valid = 0;
break;
}
diff --git a/intern/cycles/bvh/bvh_node.h b/intern/cycles/bvh/bvh_node.h
index 797dd5b694e..b3b5c43a394 100644
--- a/intern/cycles/bvh/bvh_node.h
+++ b/intern/cycles/bvh/bvh_node.h
@@ -179,7 +179,7 @@ class InnerNode : public BVHNode {
}
/* NOTE: This function is only used during binary BVH builder, and it
- * supposed to be configured to have 2 children which will be filled in in a
+ * supposed to be configured to have 2 children which will be filled-in in a
* bit. But this is important to have children reset to NULL. */
explicit InnerNode(const BoundBox &bounds) : BVHNode(bounds), num_children_(0)
{
diff --git a/intern/cycles/bvh/bvh_params.h b/intern/cycles/bvh/bvh_params.h
index 1a50742dc33..2dc10f30363 100644
--- a/intern/cycles/bvh/bvh_params.h
+++ b/intern/cycles/bvh/bvh_params.h
@@ -297,7 +297,7 @@ struct BVHSpatialBin {
*/
struct BVHSpatialStorage {
- /* Accumulated bounds when sweeping from right to left. */
+ /* Accumulated bounds when sweeping from right to left. */
vector<BoundBox> right_bounds;
/* Bins used for histogram when selecting best split plane. */
diff --git a/intern/cycles/bvh/bvh_split.cpp b/intern/cycles/bvh/bvh_split.cpp
index 834b07440d8..d4c79253834 100644
--- a/intern/cycles/bvh/bvh_split.cpp
+++ b/intern/cycles/bvh/bvh_split.cpp
@@ -388,7 +388,7 @@ void BVHSpatialSplit::split_curve_primitive(const Hair *hair,
BoundBox &left_bounds,
BoundBox &right_bounds)
{
- /* curve split: NOTE - Currently ignores curve width and needs to be fixed.*/
+ /* curve split: NOTE - Currently ignores curve width and needs to be fixed. */
Hair::Curve curve = hair->get_curve(prim_index);
const int k0 = curve.first_key + segment_index;
const int k1 = k0 + 1;
diff --git a/intern/cycles/device/device_task.h b/intern/cycles/device/device_task.h
index a9298a9126c..3f7cf47b692 100644
--- a/intern/cycles/device/device_task.h
+++ b/intern/cycles/device/device_task.h
@@ -65,7 +65,7 @@ class DenoiseParams {
/* Viewport start sample. */
int start_sample;
- /** Native Denoiser **/
+ /** Native Denoiser. */
/* Pixel radius for neighboring pixels to take into account. */
int radius;
@@ -81,7 +81,7 @@ class DenoiseParams {
/* Clamp the input to the range of +-1e8. Should be enough for any legitimate data. */
bool clamp_input;
- /** OIDN/Optix Denoiser **/
+ /** OIDN/Optix Denoiser. */
/* Passes handed over to the OIDN/OptiX denoiser (default to color + albedo). */
DenoiserInput input_passes;
diff --git a/intern/cycles/device/opencl/opencl_util.cpp b/intern/cycles/device/opencl/opencl_util.cpp
index be9efcd43ee..3929cf77f15 100644
--- a/intern/cycles/device/opencl/opencl_util.cpp
+++ b/intern/cycles/device/opencl/opencl_util.cpp
@@ -1186,7 +1186,7 @@ bool OpenCLInfo::get_device_extensions(cl_device_id device_id,
{
size_t extension_length = 0;
cl_int err;
- /* Determine the size of the extension string*/
+ /* Determine the size of the extension string. */
if ((err = clGetDeviceInfo(device_id, CL_DEVICE_EXTENSIONS, 0, 0, &extension_length)) !=
CL_SUCCESS) {
if (error != NULL) {
diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h
index 3a3f38539c5..acf29cf1baf 100644
--- a/intern/cycles/kernel/bvh/bvh.h
+++ b/intern/cycles/kernel/bvh/bvh.h
@@ -116,7 +116,7 @@ CCL_NAMESPACE_BEGIN
# endif
# endif /* __SHADOW_RECORD_ALL__ */
-/* Record all intersections - Volume BVH traversal */
+/* Record all intersections - Volume BVH traversal. */
# if defined(__VOLUME_RECORD_ALL__)
# define BVH_FUNCTION_NAME bvh_intersect_volume_all
diff --git a/intern/cycles/kernel/bvh/bvh_util.h b/intern/cycles/kernel/bvh/bvh_util.h
index a694e4dc259..6c152cbb249 100644
--- a/intern/cycles/kernel/bvh/bvh_util.h
+++ b/intern/cycles/kernel/bvh/bvh_util.h
@@ -71,6 +71,87 @@ ccl_device_inline float3 ray_offset(float3 P, float3 Ng)
#endif
}
+/* This function should be used to compute a modified ray start position for
+ * rays leaving from a surface. The algorithm slightly distorts flat surface
+ * of a triangle. Surface is lifted by amount h along normal n in the incident
+ * point. */
+
+ccl_device_inline float3 smooth_surface_offset(KernelGlobals *kg, ShaderData *sd, float3 Ng)
+{
+ float3 V[3], N[3];
+ triangle_vertices_and_normals(kg, sd->prim, V, N);
+
+ const float u = sd->u, v = sd->v;
+ const float w = 1 - u - v;
+ float3 P = V[0] * u + V[1] * v + V[2] * w; /* Local space */
+ float3 n = N[0] * u + N[1] * v + N[2] * w; /* We get away without normalization */
+
+ n = normalize(
+ transform_direction_transposed_auto(&sd->ob_itfm, n)); /* Normal x scale, world space */
+
+ /* Parabolic approximation */
+ float a = dot(N[2] - N[0], V[0] - V[2]);
+ float b = dot(N[2] - N[1], V[1] - V[2]);
+ float c = dot(N[1] - N[0], V[1] - V[0]);
+ float h = a * u * (u - 1) + (a + b + c) * u * v + b * v * (v - 1);
+
+ /* Check flipped normals */
+ if (dot(n, Ng) > 0) {
+ /* Local linear envelope */
+ float h0 = max(max(dot(V[1] - V[0], N[0]), dot(V[2] - V[0], N[0])), 0.0f);
+ float h1 = max(max(dot(V[0] - V[1], N[1]), dot(V[2] - V[1], N[1])), 0.0f);
+ float h2 = max(max(dot(V[0] - V[2], N[2]), dot(V[1] - V[2], N[2])), 0.0f);
+ h0 = max(dot(V[0] - P, N[0]) + h0, 0.0f);
+ h1 = max(dot(V[1] - P, N[1]) + h1, 0.0f);
+ h2 = max(dot(V[2] - P, N[2]) + h2, 0.0f);
+ h = max(min(min(h0, h1), h2), h * 0.5f);
+ }
+ else {
+ float h0 = max(max(dot(V[0] - V[1], N[0]), dot(V[0] - V[2], N[0])), 0.0f);
+ float h1 = max(max(dot(V[1] - V[0], N[1]), dot(V[1] - V[2], N[1])), 0.0f);
+ float h2 = max(max(dot(V[2] - V[0], N[2]), dot(V[2] - V[1], N[2])), 0.0f);
+ h0 = max(dot(P - V[0], N[0]) + h0, 0.0f);
+ h1 = max(dot(P - V[1], N[1]) + h1, 0.0f);
+ h2 = max(dot(P - V[2], N[2]) + h2, 0.0f);
+ h = min(-min(min(h0, h1), h2), h * 0.5f);
+ }
+
+ return n * h;
+}
+
+/* Ray offset to avoid shadow terminator artifact. */
+
+ccl_device_inline float3 ray_offset_shadow(KernelGlobals *kg, ShaderData *sd, float3 L)
+{
+ float NL = dot(sd->N, L);
+ bool transmit = (NL < 0.0f);
+ float3 Ng = (transmit ? -sd->Ng : sd->Ng);
+ float3 P = ray_offset(sd->P, Ng);
+
+ if ((sd->type & PRIMITIVE_ALL_TRIANGLE) && (sd->shader & SHADER_SMOOTH_NORMAL)) {
+ const float offset_cutoff =
+ kernel_tex_fetch(__objects, sd->object).shadow_terminator_geometry_offset;
+ /* Do ray offset (heavy stuff) only for close to be terminated triangles:
+ * offset_cutoff = 0.1f means that 10-20% of rays will be affected. Also
+ * make a smooth transition near the threshold. */
+ if (offset_cutoff > 0.0f) {
+ float NgL = dot(Ng, L);
+ float offset_amount = 0.0f;
+ if (NL < offset_cutoff) {
+ offset_amount = clamp(2.0f - (NgL + NL) / offset_cutoff, 0.0f, 1.0f);
+ }
+ else {
+ offset_amount = clamp(1.0f - NgL / offset_cutoff, 0.0f, 1.0f);
+ }
+ if (offset_amount > 0.0f) {
+ P += smooth_surface_offset(kg, sd, Ng) * offset_amount;
+ }
+ }
+ }
+
+ return P;
+}
+
#if defined(__VOLUME_RECORD_ALL__) || (defined(__SHADOW_RECORD_ALL__) && defined(__KERNEL_CPU__))
/* ToDo: Move to another file? */
ccl_device int intersections_compare(const void *a, const void *b)
diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h
index 6070fd983f5..6f2f2ebb202 100644
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@ -462,7 +462,7 @@ ccl_device_inline int bsdf_sample(KernelGlobals *kg,
else {
/* Shadow terminator offset. */
const float frequency_multiplier =
- kernel_tex_fetch(__objects, sd->object).shadow_terminator_offset;
+ kernel_tex_fetch(__objects, sd->object).shadow_terminator_shading_offset;
if (frequency_multiplier > 1.0f) {
*eval *= shift_cos_in(dot(*omega_in, sc->N), frequency_multiplier);
}
@@ -488,12 +488,9 @@ ccl_device_inline
const float3 omega_in,
float *pdf)
{
- /* For curves use the smooth normal, particularly for ribbons the geometric
- * normal gives too much darkening otherwise. */
- const float3 Ng = (sd->type & PRIMITIVE_ALL_CURVE) ? sd->N : sd->Ng;
float3 eval;
- if (dot(Ng, omega_in) >= 0.0f) {
+ if (dot(sd->N, omega_in) >= 0.0f) {
switch (sc->type) {
case CLOSURE_BSDF_DIFFUSE_ID:
case CLOSURE_BSDF_BSSRDF_ID:
@@ -589,7 +586,7 @@ ccl_device_inline
}
/* Shadow terminator offset. */
const float frequency_multiplier =
- kernel_tex_fetch(__objects, sd->object).shadow_terminator_offset;
+ kernel_tex_fetch(__objects, sd->object).shadow_terminator_shading_offset;
if (frequency_multiplier > 1.0f) {
eval *= shift_cos_in(dot(omega_in, sc->N), frequency_multiplier);
}
diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
index 0d50172a907..9814a7cf5c9 100644
--- a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
+++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
@@ -61,8 +61,8 @@ ccl_device_forceinline float3 bsdf_ashikhmin_shirley_eval_reflect(const ShaderCl
const MicrofacetBsdf *bsdf = (const MicrofacetBsdf *)sc;
float3 N = bsdf->N;
- float NdotI = dot(N, I); /* in Cycles/OSL convention I is omega_out */
- float NdotO = dot(N, omega_in); /* and consequently we use for O omaga_in ;) */
+ float NdotI = dot(N, I); /* in Cycles/OSL convention I is omega_out */
+ float NdotO = dot(N, omega_in); /* and consequently we use for O omaga_in ;) */
float out = 0.0f;
diff --git a/intern/cycles/kernel/geom/geom_motion_triangle_shader.h b/intern/cycles/kernel/geom/geom_motion_triangle_shader.h
index 5333e82b346..7a91f8041f7 100644
--- a/intern/cycles/kernel/geom/geom_motion_triangle_shader.h
+++ b/intern/cycles/kernel/geom/geom_motion_triangle_shader.h
@@ -66,7 +66,7 @@ ccl_device_noinline void motion_triangle_shader_setup(
sd->P = motion_triangle_refine_local(kg, sd, isect, ray, verts);
}
else
-#endif /* __BVH_LOCAL__*/
+#endif /* __BVH_LOCAL__*/
{
sd->P = motion_triangle_refine(kg, sd, isect, ray, verts);
}
diff --git a/intern/cycles/kernel/geom/geom_primitive.h b/intern/cycles/kernel/geom/geom_primitive.h
index 2c31e5cee03..aeb044c9ad3 100644
--- a/intern/cycles/kernel/geom/geom_primitive.h
+++ b/intern/cycles/kernel/geom/geom_primitive.h
@@ -138,7 +138,7 @@ ccl_device_inline float4 primitive_surface_attribute_float4(KernelGlobals *kg,
ccl_device_inline bool primitive_is_volume_attribute(const ShaderData *sd,
const AttributeDescriptor desc)
{
- return (sd->object != OBJECT_NONE && desc.element == ATTR_ELEMENT_VOXEL);
+ return sd->type == PRIMITIVE_VOLUME;
}
ccl_device_inline float primitive_volume_attribute_float(KernelGlobals *kg,
diff --git a/intern/cycles/kernel/geom/geom_triangle.h b/intern/cycles/kernel/geom/geom_triangle.h
index e8e5d8c5b34..208338a934b 100644
--- a/intern/cycles/kernel/geom/geom_triangle.h
+++ b/intern/cycles/kernel/geom/geom_triangle.h
@@ -22,7 +22,7 @@
CCL_NAMESPACE_BEGIN
-/* normal on triangle */
+/* Normal on triangle. */
ccl_device_inline float3 triangle_normal(KernelGlobals *kg, ShaderData *sd)
{
/* load triangle vertices */
@@ -40,7 +40,7 @@ ccl_device_inline float3 triangle_normal(KernelGlobals *kg, ShaderData *sd)
}
}
-/* point and normal on triangle */
+/* Point and normal on triangle. */
ccl_device_inline void triangle_point_normal(
KernelGlobals *kg, int object, int prim, float u, float v, float3 *P, float3 *Ng, int *shader)
{
@@ -75,6 +75,22 @@ ccl_device_inline void triangle_vertices(KernelGlobals *kg, int prim, float3 P[3
P[2] = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 2));
}
+/* Triangle vertex locations and vertex normals */
+
+ccl_device_inline void triangle_vertices_and_normals(KernelGlobals *kg,
+ int prim,
+ float3 P[3],
+ float3 N[3])
+{
+ const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, prim);
+ P[0] = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 0));
+ P[1] = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 1));
+ P[2] = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 2));
+ N[0] = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.x));
+ N[1] = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.y));
+ N[2] = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.z));
+}
+
/* Interpolate smooth vertex normal from vertices */
ccl_device_inline float3
diff --git a/intern/cycles/kernel/geom/geom_volume.h b/intern/cycles/kernel/geom/geom_volume.h
index 13b027a5f6c..809b76245ba 100644
--- a/intern/cycles/kernel/geom/geom_volume.h
+++ b/intern/cycles/kernel/geom/geom_volume.h
@@ -72,14 +72,22 @@ ccl_device float4 volume_attribute_float4(KernelGlobals *kg,
const ShaderData *sd,
const AttributeDescriptor desc)
{
- /* todo: optimize this so we don't have to transform both here and in
- * kernel_tex_image_interp_3d when possible. Also could optimize for the
- * common case where transform is translation/scale only. */
- float3 P = sd->P;
- object_inverse_position_transform(kg, sd, &P);
- InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC) ? INTERPOLATION_CUBIC :
- INTERPOLATION_NONE;
- return kernel_tex_image_interp_3d(kg, desc.offset, P, interp);
+ if (desc.element & (ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) {
+ return kernel_tex_fetch(__attributes_float3, desc.offset);
+ }
+ else if (desc.element == ATTR_ELEMENT_VOXEL) {
+ /* todo: optimize this so we don't have to transform both here and in
+ * kernel_tex_image_interp_3d when possible. Also could optimize for the
+ * common case where transform is translation/scale only. */
+ float3 P = sd->P;
+ object_inverse_position_transform(kg, sd, &P);
+ InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC) ? INTERPOLATION_CUBIC :
+ INTERPOLATION_NONE;
+ return kernel_tex_image_interp_3d(kg, desc.offset, P, interp);
+ }
+ else {
+ return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+ }
}
#endif
diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h
index 96ecc624067..aebf2ec8e28 100644
--- a/intern/cycles/kernel/kernel_emission.h
+++ b/intern/cycles/kernel/kernel_emission.h
@@ -176,8 +176,7 @@ ccl_device_noinline_cpu bool direct_emission(KernelGlobals *kg,
if (ls->shader & SHADER_CAST_SHADOW) {
/* setup ray */
- bool transmit = (dot(sd->Ng, ls->D) < 0.0f);
- ray->P = ray_offset(sd->P, (transmit) ? -sd->Ng : sd->Ng);
+ ray->P = ray_offset_shadow(kg, sd, ls->D);
if (ls->t == FLT_MAX) {
/* distant light */
diff --git a/intern/cycles/kernel/kernel_globals.h b/intern/cycles/kernel/kernel_globals.h
index c186e8560eb..70aed6d54ed 100644
--- a/intern/cycles/kernel/kernel_globals.h
+++ b/intern/cycles/kernel/kernel_globals.h
@@ -64,7 +64,7 @@ typedef struct KernelGlobals {
OSLThreadData *osl_tdata;
# endif
- /* **** Run-time data **** */
+ /* **** Run-time data **** */
/* Heap-allocated storage for transparent shadows intersections. */
Intersection *transparent_shadow_intersections;
diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h
index 387af54cf27..c33d7150b5c 100644
--- a/intern/cycles/kernel/kernel_projection.h
+++ b/intern/cycles/kernel/kernel_projection.h
@@ -35,7 +35,7 @@
CCL_NAMESPACE_BEGIN
-/* Spherical coordinates <-> Cartesian direction */
+/* Spherical coordinates <-> Cartesian direction. */
ccl_device float2 direction_to_spherical(float3 dir)
{
diff --git a/intern/cycles/kernel/kernel_queues.h b/intern/cycles/kernel/kernel_queues.h
index 451d2a0cedf..d8cc08b3e85 100644
--- a/intern/cycles/kernel/kernel_queues.h
+++ b/intern/cycles/kernel/kernel_queues.h
@@ -79,7 +79,7 @@ ccl_device void enqueue_ray_index_local(
{
int lidx = ccl_local_id(1) * ccl_local_size(0) + ccl_local_id(0);
- /* Get local queue id .*/
+ /* Get local queue id. */
unsigned int lqidx;
if (enqueue_flag) {
lqidx = atomic_fetch_and_inc_uint32(local_queue_atomics);
diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h
index e6bd99414cc..7f02e6fc7b3 100644
--- a/intern/cycles/kernel/kernel_shader.h
+++ b/intern/cycles/kernel/kernel_shader.h
@@ -274,7 +274,7 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals *kg,
/* primitive */
sd->object = object;
sd->lamp = LAMP_NONE;
- /* currently no access to bvh prim index for strand sd->prim*/
+ /* Currently no access to bvh prim index for strand sd->prim. */
sd->prim = prim;
sd->u = u;
sd->v = v;
@@ -1268,6 +1268,7 @@ ccl_device_inline void shader_eval_volume(KernelGlobals *kg,
sd->num_closure_left = max_closures;
sd->flag = 0;
sd->object_flag = 0;
+ sd->type = PRIMITIVE_VOLUME;
for (int i = 0; stack[i].shader != SHADER_NONE; i++) {
/* setup shaderdata from stack. it's mostly setup already in
diff --git a/intern/cycles/kernel/kernel_subsurface.h b/intern/cycles/kernel/kernel_subsurface.h
index dd922b86722..677504a4045 100644
--- a/intern/cycles/kernel/kernel_subsurface.h
+++ b/intern/cycles/kernel/kernel_subsurface.h
@@ -409,7 +409,7 @@ ccl_device void subsurface_random_walk_coefficients(const ShaderClosure *sc,
ccl_device_forceinline float eval_phase_dwivedi(float v, float phase_log, float cos_theta)
{
- /* Eq. 9 from [2] using precomputed log((v + 1) / (v - 1))*/
+ /* Eq. 9 from [2] using precomputed log((v + 1) / (v - 1)) */
return 1.0f / ((v - cos_theta) * phase_log);
}
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 74fa2826cd4..d224db91edc 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -302,7 +302,7 @@ enum PathRayFlag {
PATH_RAY_DIFFUSE_ANCESTOR = (1 << 15),
/* Single pass has been written. */
PATH_RAY_SINGLE_PASS_DONE = (1 << 16),
- /* Ray is behind a shadow catcher .*/
+ /* Ray is behind a shadow catcher. */
PATH_RAY_SHADOW_CATCHER = (1 << 17),
/* Store shadow data for shadow catcher or denoising. */
PATH_RAY_STORE_SHADOW_INFO = (1 << 18),
@@ -689,22 +689,24 @@ typedef enum PrimitiveType {
PRIMITIVE_MOTION_CURVE_THICK = (1 << 3),
PRIMITIVE_CURVE_RIBBON = (1 << 4),
PRIMITIVE_MOTION_CURVE_RIBBON = (1 << 5),
+ PRIMITIVE_VOLUME = (1 << 6),
/* Lamp primitive is not included below on purpose,
* since it is no real traceable primitive.
*/
- PRIMITIVE_LAMP = (1 << 6),
+ PRIMITIVE_LAMP = (1 << 7),
PRIMITIVE_ALL_TRIANGLE = (PRIMITIVE_TRIANGLE | PRIMITIVE_MOTION_TRIANGLE),
PRIMITIVE_ALL_CURVE = (PRIMITIVE_CURVE_THICK | PRIMITIVE_MOTION_CURVE_THICK |
PRIMITIVE_CURVE_RIBBON | PRIMITIVE_MOTION_CURVE_RIBBON),
+ PRIMITIVE_ALL_VOLUME = (PRIMITIVE_VOLUME),
PRIMITIVE_ALL_MOTION = (PRIMITIVE_MOTION_TRIANGLE | PRIMITIVE_MOTION_CURVE_THICK |
PRIMITIVE_MOTION_CURVE_RIBBON),
- PRIMITIVE_ALL = (PRIMITIVE_ALL_TRIANGLE | PRIMITIVE_ALL_CURVE),
+ PRIMITIVE_ALL = (PRIMITIVE_ALL_TRIANGLE | PRIMITIVE_ALL_CURVE | PRIMITIVE_ALL_VOLUME),
/* Total number of different traceable primitives.
* NOTE: This is an actual value, not a bitflag.
*/
- PRIMITIVE_NUM_TOTAL = 6,
+ PRIMITIVE_NUM_TOTAL = 7,
} PrimitiveType;
#define PRIMITIVE_PACK_SEGMENT(type, segment) ((segment << PRIMITIVE_NUM_TOTAL) | (type))
@@ -1479,7 +1481,8 @@ typedef struct KernelObject {
float cryptomatte_object;
float cryptomatte_asset;
- float shadow_terminator_offset;
+ float shadow_terminator_shading_offset;
+ float shadow_terminator_geometry_offset;
float pad1, pad2, pad3;
} KernelObject;
static_assert_align(KernelObject, 16);
diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h
index d8b29e3bc1c..891b9172dd4 100644
--- a/intern/cycles/kernel/osl/osl_services.h
+++ b/intern/cycles/kernel/osl/osl_services.h
@@ -317,4 +317,4 @@ class OSLRenderServices : public OSL::RendererServices {
CCL_NAMESPACE_END
-#endif /* __OSL_SERVICES_H__ */
+#endif /* __OSL_SERVICES_H__ */
diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp
index 8606c459375..389c854c495 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,
return;
}
- /* per thread kernel data init*/
+ /* Per thread kernel data init. */
kg->osl = osl_globals;
OSL::ShadingSystem *ss = kg->osl->ss;
diff --git a/intern/cycles/kernel/split/kernel_split_data_types.h b/intern/cycles/kernel/split/kernel_split_data_types.h
index ac4a450ca2b..06bdce9947d 100644
--- a/intern/cycles/kernel/split/kernel_split_data_types.h
+++ b/intern/cycles/kernel/split/kernel_split_data_types.h
@@ -68,7 +68,7 @@ typedef ccl_global struct SplitBranchedState {
uint lcg_state;
LocalIntersection ss_isect;
-# endif /*__SUBSURFACE__ */
+# endif /* __SUBSURFACE__ */
int shared_sample_count; /* number of branched samples shared with other threads */
int original_ray; /* index of original ray when sharing branched samples */
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index f6bf860631e..bbe8d72edf0 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -803,7 +803,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg,
float melanin_redness = stack_load_float_default(
stack, melanin_redness_ofs, data_node2.w);
- /* Randomize melanin. */
+ /* Randomize melanin. */
float random_color = stack_load_float_default(stack, random_color_ofs, data_node3.z);
random_color = clamp(random_color, 0.0f, 1.0f);
float factor_random_color = 1.0f + 2.0f * (random - 0.5f) * random_color;
diff --git a/intern/cycles/kernel/svm/svm_geometry.h b/intern/cycles/kernel/svm/svm_geometry.h
index 77df19b2298..e48e96dcfa4 100644
--- a/intern/cycles/kernel/svm/svm_geometry.h
+++ b/intern/cycles/kernel/svm/svm_geometry.h
@@ -220,11 +220,13 @@ ccl_device void svm_node_hair_info(
stack_store_float(stack, out_offset, data);
break;
}
- /*case NODE_INFO_CURVE_FADE: {
+# if 0
+ case NODE_INFO_CURVE_FADE: {
data = sd->curve_transparency;
stack_store_float(stack, out_offset, data);
break;
- }*/
+ }
+# endif
case NODE_INFO_CURVE_TANGENT_NORMAL: {
data3 = curve_tangent_normal(kg, sd);
stack_store_float3(stack, out_offset, data3);
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index 742addab611..9348ddabde5 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -182,7 +182,7 @@ ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float
}
}
else {
- /* Desperate mode, no valid choice anyway, fallback to one side.*/
+ /* Desperate mode, no valid choice anyway, fallback to one side. */
weight.x = 1.0f;
}
diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index dcb456dc1ce..6713531c9b0 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -333,7 +333,7 @@ static M44d get_interpolated_matrix_for_time(const MatrixSampleMap &samples, chr
chrono_t t = (time - prev_time) / (next_time - prev_time);
- /* ensure rotation around the shortest angle */
+ /* Ensure rotation around the shortest angle. */
if ((prev_rotation ^ next_rotation) < 0) {
next_rotation = -next_rotation;
}
diff --git a/intern/cycles/render/constant_fold.cpp b/intern/cycles/render/constant_fold.cpp
index 800056d2899..a4d40ae8183 100644
--- a/intern/cycles/render/constant_fold.cpp
+++ b/intern/cycles/render/constant_fold.cpp
@@ -48,6 +48,7 @@ void ConstantFolder::make_constant(float value) const
foreach (ShaderInput *sock, output->links) {
sock->set(value);
+ sock->constant_folded_in = true;
}
graph->disconnect(output);
@@ -59,6 +60,7 @@ void ConstantFolder::make_constant(float3 value) const
foreach (ShaderInput *sock, output->links) {
sock->set(value);
+ sock->constant_folded_in = true;
}
graph->disconnect(output);
diff --git a/intern/cycles/render/geometry.cpp b/intern/cycles/render/geometry.cpp
index ce76658acb6..6d084e82576 100644
--- a/intern/cycles/render/geometry.cpp
+++ b/intern/cycles/render/geometry.cpp
@@ -676,8 +676,8 @@ void GeometryManager::update_attribute_element_offset(Geometry *geom,
Mesh *mesh = static_cast<Mesh *>(geom);
if (mesh->subdivision_type == Mesh::SUBDIVISION_CATMULL_CLARK &&
desc.flags & ATTR_SUBDIVIDED) {
- /* indices for subdivided attributes are retrieved
- * from patch table so no need for correction here*/
+ /* Indices for subdivided attributes are retrieved
+ * from patch table so no need for correction here. */
}
else if (element == ATTR_ELEMENT_VERTEX)
offset -= mesh->vert_offset;
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index f6ee708b3f8..24de06123ca 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -79,7 +79,11 @@ enum ShaderNodeSpecialType {
class ShaderInput {
public:
ShaderInput(const SocketType &socket_type_, ShaderNode *parent_)
- : socket_type(socket_type_), parent(parent_), link(NULL), stack_offset(SVM_STACK_INVALID)
+ : socket_type(socket_type_),
+ parent(parent_),
+ link(NULL),
+ stack_offset(SVM_STACK_INVALID),
+ constant_folded_in(false)
{
}
@@ -111,6 +115,10 @@ class ShaderInput {
ShaderNode *parent;
ShaderOutput *link;
int stack_offset; /* for SVM compiler */
+
+ /* Keeps track of whether a constant was folded in this socket, to avoid over-optimizing when the
+ * link is null. */
+ bool constant_folded_in;
};
/* Output
diff --git a/intern/cycles/render/image_vdb.cpp b/intern/cycles/render/image_vdb.cpp
index fb6394e8917..6202035ba3b 100644
--- a/intern/cycles/render/image_vdb.cpp
+++ b/intern/cycles/render/image_vdb.cpp
@@ -16,8 +16,10 @@
#include "render/image_vdb.h"
+#include "util/util_logging.h"
+#include "util/util_openvdb.h"
+
#ifdef WITH_OPENVDB
-# include <openvdb/openvdb.h>
# include <openvdb/tools/Dense.h>
#endif
#ifdef WITH_NANOVDB
@@ -26,6 +28,57 @@
CCL_NAMESPACE_BEGIN
+#ifdef WITH_OPENVDB
+struct NumChannelsOp {
+ int num_channels = 0;
+
+ template<typename GridType, typename FloatGridType, typename FloatDataType, int channels>
+ bool operator()(const openvdb::GridBase::ConstPtr &grid)
+ {
+ num_channels = channels;
+ return true;
+ }
+};
+
+struct ToDenseOp {
+ openvdb::CoordBBox bbox;
+ void *pixels;
+
+ template<typename GridType, typename FloatGridType, typename FloatDataType, int channels>
+ bool operator()(const openvdb::GridBase::ConstPtr &grid)
+ {
+ openvdb::tools::Dense<FloatDataType, openvdb::tools::LayoutXYZ> dense(bbox,
+ (FloatDataType *)pixels);
+ openvdb::tools::copyToDense(*openvdb::gridConstPtrCast<GridType>(grid), dense);
+ return true;
+ }
+};
+
+# ifdef WITH_NANOVDB
+struct ToNanoOp {
+ nanovdb::GridHandle<> nanogrid;
+
+ template<typename GridType, typename FloatGridType, typename FloatDataType, int channels>
+ bool operator()(const openvdb::GridBase::ConstPtr &grid)
+ {
+ if constexpr (!std::is_same_v<GridType, openvdb::MaskGrid>) {
+ try {
+ nanogrid = nanovdb::openToNanoVDB(
+ FloatGridType(*openvdb::gridConstPtrCast<GridType>(grid)));
+ }
+ catch (const std::exception &e) {
+ VLOG(1) << "Error converting OpenVDB to NanoVDB grid: " << e.what();
+ }
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+};
+# endif
+#endif
+
VDBImageLoader::VDBImageLoader(const string &grid_name) : grid_name(grid_name)
{
}
@@ -41,98 +94,40 @@ bool VDBImageLoader::load_metadata(const ImageDeviceFeatures &features, ImageMet
return false;
}
- bbox = grid->evalActiveVoxelBoundingBox();
- if (bbox.empty()) {
+ /* Get number of channels from type. */
+ NumChannelsOp op;
+ if (!openvdb::grid_type_operation(grid, op)) {
return false;
}
- /* Set dimensions. */
- openvdb::Coord dim = bbox.dim();
- metadata.width = dim.x();
- metadata.height = dim.y();
- metadata.depth = dim.z();
+ metadata.channels = op.num_channels;
/* Set data type. */
- if (grid->isType<openvdb::FloatGrid>()) {
- metadata.channels = 1;
-# ifdef WITH_NANOVDB
- if (features.has_nanovdb) {
- nanogrid = nanovdb::openToNanoVDB(*openvdb::gridConstPtrCast<openvdb::FloatGrid>(grid));
- }
-# endif
- }
- else if (grid->isType<openvdb::Vec3fGrid>()) {
- metadata.channels = 3;
-# ifdef WITH_NANOVDB
- if (features.has_nanovdb) {
- nanogrid = nanovdb::openToNanoVDB(*openvdb::gridConstPtrCast<openvdb::Vec3fGrid>(grid));
- }
-# endif
- }
- else if (grid->isType<openvdb::BoolGrid>()) {
- metadata.channels = 1;
-# ifdef WITH_NANOVDB
- if (features.has_nanovdb) {
- nanogrid = nanovdb::openToNanoVDB(
- openvdb::FloatGrid(*openvdb::gridConstPtrCast<openvdb::BoolGrid>(grid)));
- }
-# endif
- }
- else if (grid->isType<openvdb::DoubleGrid>()) {
- metadata.channels = 1;
-# ifdef WITH_NANOVDB
- if (features.has_nanovdb) {
- nanogrid = nanovdb::openToNanoVDB(
- openvdb::FloatGrid(*openvdb::gridConstPtrCast<openvdb::DoubleGrid>(grid)));
- }
-# endif
- }
- else if (grid->isType<openvdb::Int32Grid>()) {
- metadata.channels = 1;
# ifdef WITH_NANOVDB
- if (features.has_nanovdb) {
- nanogrid = nanovdb::openToNanoVDB(
- openvdb::FloatGrid(*openvdb::gridConstPtrCast<openvdb::Int32Grid>(grid)));
+ if (features.has_nanovdb) {
+ /* NanoVDB expects no inactive leaf nodes. */
+ /*openvdb::FloatGrid &pruned_grid = *openvdb::gridPtrCast<openvdb::FloatGrid>(grid);
+ openvdb::tools::pruneInactive(pruned_grid.tree());
+ nanogrid = nanovdb::openToNanoVDB(pruned_grid);*/
+ ToNanoOp op;
+ if (!openvdb::grid_type_operation(grid, op)) {
+ return false;
}
-# endif
- }
- else if (grid->isType<openvdb::Int64Grid>()) {
- metadata.channels = 1;
-# ifdef WITH_NANOVDB
- if (features.has_nanovdb) {
- nanogrid = nanovdb::openToNanoVDB(
- openvdb::FloatGrid(*openvdb::gridConstPtrCast<openvdb::Int64Grid>(grid)));
- }
-# endif
+ nanogrid = std::move(op.nanogrid);
}
- else if (grid->isType<openvdb::Vec3IGrid>()) {
- metadata.channels = 3;
-# ifdef WITH_NANOVDB
- if (features.has_nanovdb) {
- nanogrid = nanovdb::openToNanoVDB(
- openvdb::Vec3fGrid(*openvdb::gridConstPtrCast<openvdb::Vec3IGrid>(grid)));
- }
-# endif
- }
- else if (grid->isType<openvdb::Vec3dGrid>()) {
- metadata.channels = 3;
-# ifdef WITH_NANOVDB
- if (features.has_nanovdb) {
- nanogrid = nanovdb::openToNanoVDB(
- openvdb::Vec3fGrid(*openvdb::gridConstPtrCast<openvdb::Vec3dGrid>(grid)));
- }
-# endif
- }
- else if (grid->isType<openvdb::MaskGrid>()) {
- metadata.channels = 1;
-# ifdef WITH_NANOVDB
- return false; // Unsupported
# endif
- }
- else {
+
+ /* Set dimensions. */
+ bbox = grid->evalActiveVoxelBoundingBox();
+ if (bbox.empty()) {
return false;
}
+ openvdb::Coord dim = bbox.dim();
+ metadata.width = dim.x();
+ metadata.height = dim.y();
+ metadata.depth = dim.z();
+
# ifdef WITH_NANOVDB
if (nanogrid) {
metadata.byte_size = nanogrid.size();
@@ -200,45 +195,10 @@ bool VDBImageLoader::load_pixels(const ImageMetaData &, void *pixels, const size
else
# endif
{
- if (grid->isType<openvdb::FloatGrid>()) {
- openvdb::tools::Dense<float, openvdb::tools::LayoutXYZ> dense(bbox, (float *)pixels);
- openvdb::tools::copyToDense(*openvdb::gridConstPtrCast<openvdb::FloatGrid>(grid), dense);
- }
- else if (grid->isType<openvdb::Vec3fGrid>()) {
- openvdb::tools::Dense<openvdb::Vec3f, openvdb::tools::LayoutXYZ> dense(
- bbox, (openvdb::Vec3f *)pixels);
- openvdb::tools::copyToDense(*openvdb::gridConstPtrCast<openvdb::Vec3fGrid>(grid), dense);
- }
- else if (grid->isType<openvdb::BoolGrid>()) {
- openvdb::tools::Dense<float, openvdb::tools::LayoutXYZ> dense(bbox, (float *)pixels);
- openvdb::tools::copyToDense(*openvdb::gridConstPtrCast<openvdb::BoolGrid>(grid), dense);
- }
- else if (grid->isType<openvdb::DoubleGrid>()) {
- openvdb::tools::Dense<float, openvdb::tools::LayoutXYZ> dense(bbox, (float *)pixels);
- openvdb::tools::copyToDense(*openvdb::gridConstPtrCast<openvdb::DoubleGrid>(grid), dense);
- }
- else if (grid->isType<openvdb::Int32Grid>()) {
- openvdb::tools::Dense<float, openvdb::tools::LayoutXYZ> dense(bbox, (float *)pixels);
- openvdb::tools::copyToDense(*openvdb::gridConstPtrCast<openvdb::Int32Grid>(grid), dense);
- }
- else if (grid->isType<openvdb::Int64Grid>()) {
- openvdb::tools::Dense<float, openvdb::tools::LayoutXYZ> dense(bbox, (float *)pixels);
- openvdb::tools::copyToDense(*openvdb::gridConstPtrCast<openvdb::Int64Grid>(grid), dense);
- }
- else if (grid->isType<openvdb::Vec3IGrid>()) {
- openvdb::tools::Dense<openvdb::Vec3f, openvdb::tools::LayoutXYZ> dense(
- bbox, (openvdb::Vec3f *)pixels);
- openvdb::tools::copyToDense(*openvdb::gridConstPtrCast<openvdb::Vec3IGrid>(grid), dense);
- }
- else if (grid->isType<openvdb::Vec3dGrid>()) {
- openvdb::tools::Dense<openvdb::Vec3f, openvdb::tools::LayoutXYZ> dense(
- bbox, (openvdb::Vec3f *)pixels);
- openvdb::tools::copyToDense(*openvdb::gridConstPtrCast<openvdb::Vec3dGrid>(grid), dense);
- }
- else if (grid->isType<openvdb::MaskGrid>()) {
- openvdb::tools::Dense<float, openvdb::tools::LayoutXYZ> dense(bbox, (float *)pixels);
- openvdb::tools::copyToDense(*openvdb::gridConstPtrCast<openvdb::MaskGrid>(grid), dense);
- }
+ ToDenseOp op;
+ op.pixels = pixels;
+ op.bbox = bbox;
+ openvdb::grid_type_operation(grid, op);
}
return true;
#else
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 5792d2458d1..42cba342bf8 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -4374,7 +4374,7 @@ NODE_DEFINE(HairInfoNode)
SOCKET_OUT_FLOAT(intercept, "Intercept");
SOCKET_OUT_FLOAT(thickness, "Thickness");
SOCKET_OUT_NORMAL(tangent_normal, "Tangent Normal");
-#if 0 /*output for minimum hair width transparency - deactivated */
+#if 0 /* Output for minimum hair width transparency - deactivated. */
SOCKET_OUT_FLOAT(fade, "Fade");
#endif
SOCKET_OUT_FLOAT(index, "Random");
@@ -4425,12 +4425,12 @@ void HairInfoNode::compile(SVMCompiler &compiler)
if (!out->links.empty()) {
compiler.add_node(NODE_HAIR_INFO, NODE_INFO_CURVE_TANGENT_NORMAL, compiler.stack_assign(out));
}
-
- /*out = output("Fade");
+#if 0
+ out = output("Fade");
if(!out->links.empty()) {
compiler.add_node(NODE_HAIR_INFO, NODE_INFO_CURVE_FADE, compiler.stack_assign(out));
- }*/
-
+ }
+#endif
out = output("Random");
if (!out->links.empty()) {
int attr = compiler.attribute(ATTR_STD_CURVE_RANDOM);
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index f65f8bc6e90..5fe4e9ed57f 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -93,7 +93,8 @@ NODE_DEFINE(Object)
SOCKET_POINT(dupli_generated, "Dupli Generated", zero_float3());
SOCKET_POINT2(dupli_uv, "Dupli UV", zero_float2());
SOCKET_TRANSFORM_ARRAY(motion, "Motion", array<Transform>());
- SOCKET_FLOAT(shadow_terminator_offset, "Terminator Offset", 0.0f);
+ SOCKET_FLOAT(shadow_terminator_shading_offset, "Shadow Terminator Shading Offset", 0.0f);
+ SOCKET_FLOAT(shadow_terminator_geometry_offset, "Shadow Terminator Geometry Offset", 0.1f);
SOCKET_STRING(asset_name, "Asset Name", ustring());
SOCKET_BOOLEAN(is_shadow_catcher, "Shadow Catcher", false);
@@ -507,7 +508,9 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
kobject.cryptomatte_asset = util_hash_to_float(hash_asset);
}
- kobject.shadow_terminator_offset = 1.0f / (1.0f - 0.5f * ob->shadow_terminator_offset);
+ kobject.shadow_terminator_shading_offset = 1.0f /
+ (1.0f - 0.5f * ob->shadow_terminator_shading_offset);
+ kobject.shadow_terminator_geometry_offset = ob->shadow_terminator_geometry_offset;
/* Object flag. */
if (ob->use_holdout) {
diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h
index e4bc7ac3d8e..ebb7733c2aa 100644
--- a/intern/cycles/render/object.h
+++ b/intern/cycles/render/object.h
@@ -64,7 +64,8 @@ class Object : public Node {
NODE_SOCKET_API(bool, hide_on_missing_motion)
NODE_SOCKET_API(bool, use_holdout)
NODE_SOCKET_API(bool, is_shadow_catcher)
- NODE_SOCKET_API(float, shadow_terminator_offset)
+ NODE_SOCKET_API(float, shadow_terminator_shading_offset)
+ NODE_SOCKET_API(float, shadow_terminator_geometry_offset)
NODE_SOCKET_API(float3, dupli_generated)
NODE_SOCKET_API(float2, dupli_uv)
diff --git a/intern/cycles/render/osl.h b/intern/cycles/render/osl.h
index f6aa98d867a..dfeec54d915 100644
--- a/intern/cycles/render/osl.h
+++ b/intern/cycles/render/osl.h
@@ -195,4 +195,4 @@ class OSLCompiler {
CCL_NAMESPACE_END
-#endif /* __OSL_H__ */
+#endif /* __OSL_H__ */
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index 7830ca2293a..ca90af77f6e 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -1252,7 +1252,7 @@ bool Session::update_progressive_refine(bool cancel)
double current_time = time_dt();
if (current_time - last_update_time < params.progressive_update_timeout) {
- /* if last sample was processed, we need to write buffers anyway */
+ /* If last sample was processed, we need to write buffers anyway. */
if (!write && sample != 1)
return false;
}
diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp
index 5c793c5c016..dcb3976e15c 100644
--- a/intern/cycles/render/svm.cpp
+++ b/intern/cycles/render/svm.cpp
@@ -304,7 +304,7 @@ int SVMCompiler::stack_assign(ShaderOutput *output)
int SVMCompiler::stack_assign_if_linked(ShaderInput *input)
{
- if (input->link)
+ if (input->link || input->constant_folded_in)
return stack_assign(input);
return SVM_STACK_INVALID;
diff --git a/intern/cycles/util/util_color.h b/intern/cycles/util/util_color.h
index 40c2c431aca..7b67b90e44d 100644
--- a/intern/cycles/util/util_color.h
+++ b/intern/cycles/util/util_color.h
@@ -224,7 +224,7 @@ ccl_device_inline ssef fastpow24(const ssef &arg)
ssef arg2 = arg * arg;
ssef arg4 = arg2 * arg2;
- /* error max = 0.018 avg = 0.0031 |avg| = 0.0031 */
+ /* error max = 0.018 avg = 0.0031 |avg| = 0.0031 */
x = improve_5throot_solution(x, arg4);
/* error max = 0.00021 avg = 1.6e-05 |avg| = 1.6e-05 */
x = improve_5throot_solution(x, arg4);
diff --git a/intern/cycles/util/util_debug.h b/intern/cycles/util/util_debug.h
index 6ac4beb55b8..f7e53f90f74 100644
--- a/intern/cycles/util/util_debug.h
+++ b/intern/cycles/util/util_debug.h
@@ -129,7 +129,7 @@ class DebugFlags {
DEVICE_NONE,
/* All OpenCL devices will be used. */
DEVICE_ALL,
- /* Default system OpenCL device will be used. */
+ /* Default system OpenCL device will be used. */
DEVICE_DEFAULT,
/* Host processor will be used. */
DEVICE_CPU,
diff --git a/intern/cycles/util/util_math_fast.h b/intern/cycles/util/util_math_fast.h
index 5ae56290f05..1113ede0f2d 100644
--- a/intern/cycles/util/util_math_fast.h
+++ b/intern/cycles/util/util_math_fast.h
@@ -243,7 +243,7 @@ ccl_device float fast_sinpif(float x)
const float P = 3.584135056f; /* P = 16-4*Q */
return y * (Q + P * fabsf(y));
- /* The original article used used inferior constants for Q and P and
+ /* The original article used inferior constants for Q and P and
* so had max error 1.091e-3.
*
* The optimal value for Q was determined by exhaustive search, minimizing
diff --git a/intern/cycles/util/util_openvdb.h b/intern/cycles/util/util_openvdb.h
index a3ebb03e5a4..ae5326e3199 100644
--- a/intern/cycles/util/util_openvdb.h
+++ b/intern/cycles/util/util_openvdb.h
@@ -25,6 +25,42 @@ namespace openvdb {
using Vec4fTree = tree::Tree4<Vec4f, 5, 4, 3>::Type;
using Vec4fGrid = Grid<Vec4fTree>;
+/* Apply operation to known grid types. */
+template<typename OpType>
+bool grid_type_operation(const openvdb::GridBase::ConstPtr &grid, OpType &&op)
+{
+ if (grid->isType<openvdb::FloatGrid>()) {
+ return op.template operator()<openvdb::FloatGrid, openvdb::FloatGrid, float, 1>(grid);
+ }
+ else if (grid->isType<openvdb::Vec3fGrid>()) {
+ return op.template operator()<openvdb::Vec3fGrid, openvdb::Vec3fGrid, openvdb::Vec3f, 3>(grid);
+ }
+ else if (grid->isType<openvdb::BoolGrid>()) {
+ return op.template operator()<openvdb::BoolGrid, openvdb::FloatGrid, float, 1>(grid);
+ }
+ else if (grid->isType<openvdb::DoubleGrid>()) {
+ return op.template operator()<openvdb::DoubleGrid, openvdb::FloatGrid, float, 1>(grid);
+ }
+ else if (grid->isType<openvdb::Int32Grid>()) {
+ return op.template operator()<openvdb::Int32Grid, openvdb::FloatGrid, float, 1>(grid);
+ }
+ else if (grid->isType<openvdb::Int64Grid>()) {
+ return op.template operator()<openvdb::Int64Grid, openvdb::FloatGrid, float, 1>(grid);
+ }
+ else if (grid->isType<openvdb::Vec3IGrid>()) {
+ return op.template operator()<openvdb::Vec3IGrid, openvdb::Vec3fGrid, openvdb::Vec3f, 3>(grid);
+ }
+ else if (grid->isType<openvdb::Vec3dGrid>()) {
+ return op.template operator()<openvdb::Vec3dGrid, openvdb::Vec3fGrid, openvdb::Vec3f, 3>(grid);
+ }
+ else if (grid->isType<openvdb::MaskGrid>()) {
+ return op.template operator()<openvdb::MaskGrid, openvdb::FloatGrid, float, 1>(grid);
+ }
+ else {
+ return false;
+ }
+}
+
}; // namespace openvdb
#endif
diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h
index 906bf420756..ec45dfa8040 100644
--- a/intern/cycles/util/util_task.h
+++ b/intern/cycles/util/util_task.h
@@ -68,7 +68,7 @@ class TaskPool {
/* ** Statistics ** */
- /* Time time stamp of first task pushed. */
+ /* Time stamp of first task pushed. */
double start_time;
/* Number of all tasks pushed to the pool. Cleared after wait_work() and cancel(). */
@@ -88,7 +88,7 @@ class TaskScheduler {
/* Approximate number of threads that will work on task, which may be lower
* or higher than the actual number of threads. Use as little as possible and
- * leave splitting up tasks to the scheduler.. */
+ * leave splitting up tasks to the scheduler. */
static int num_threads();
protected:
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 1815a46591a..77ec307e604 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -484,10 +484,15 @@ if(WITH_XR_OPENXR)
)
elseif(UNIX AND NOT APPLE)
list(APPEND XR_PLATFORM_DEFINES -DXR_OS_LINUX)
- if (WITH_GL_EGL)
- list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_EGL)
- else()
- list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_XLIB)
+ if (WITH_GHOST_WAYLAND)
+ list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_WAYLAND)
+ endif()
+ if (WITH_GHOST_X11)
+ if (WITH_GL_EGL)
+ list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_EGL)
+ else()
+ list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_XLIB)
+ endif()
endif()
endif()
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 2bd9af6df5c..6e22d4ca3a5 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -507,7 +507,7 @@ extern GHOST_TimerProcPtr GHOST_GetTimerProc(GHOST_TimerTaskHandle timertaskhand
/**
* Changes the timer callback.
- * \param timertaskhandle: The handle to the timertask.
+ * \param timertaskhandle: The handle to the timer-task.
* \param timerProc: The timer callback.
*/
extern void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle,
@@ -515,14 +515,14 @@ extern void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle,
/**
* Returns the timer user data.
- * \param timertaskhandle: The handle to the timertask.
+ * \param timertaskhandle: The handle to the timer-task.
* \return The timer user data.
*/
extern GHOST_TUserDataPtr GHOST_GetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle);
/**
* Changes the time user data.
- * \param timertaskhandle: The handle to the timertask.
+ * \param timertaskhandle: The handle to the timer-task.
* \param userdata: The timer user data.
*/
extern void GHOST_SetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle,
diff --git a/intern/ghost/GHOST_ISystemPaths.h b/intern/ghost/GHOST_ISystemPaths.h
index e7ac752d322..74285b7e0ce 100644
--- a/intern/ghost/GHOST_ISystemPaths.h
+++ b/intern/ghost/GHOST_ISystemPaths.h
@@ -95,7 +95,7 @@ class GHOST_ISystemPaths {
virtual void addToSystemRecentFiles(const char *filename) const = 0;
private:
- /** The one and only system paths*/
+ /** The one and only system paths. */
static GHOST_ISystemPaths *m_systemPaths;
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/intern/ghost/intern/GHOST_ContextEGL.cpp b/intern/ghost/intern/GHOST_ContextEGL.cpp
index 770ead5962e..0fee200ea1a 100644
--- a/intern/ghost/intern/GHOST_ContextEGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextEGL.cpp
@@ -202,7 +202,8 @@ template<typename T> T &choose_api(EGLenum api, T &a, T &b, T &c)
}
}
-GHOST_ContextEGL::GHOST_ContextEGL(bool stereoVisual,
+GHOST_ContextEGL::GHOST_ContextEGL(const GHOST_System *const system,
+ bool stereoVisual,
EGLNativeWindowType nativeWindow,
EGLNativeDisplayType nativeDisplay,
EGLint contextProfileMask,
@@ -212,6 +213,7 @@ GHOST_ContextEGL::GHOST_ContextEGL(bool stereoVisual,
EGLint contextResetNotificationStrategy,
EGLenum api)
: GHOST_Context(stereoVisual),
+ m_system(system),
m_nativeDisplay(nativeDisplay),
m_nativeWindow(nativeWindow),
m_contextProfileMask(contextProfileMask),
diff --git a/intern/ghost/intern/GHOST_ContextEGL.h b/intern/ghost/intern/GHOST_ContextEGL.h
index 170647177c2..00c8e33ebdf 100644
--- a/intern/ghost/intern/GHOST_ContextEGL.h
+++ b/intern/ghost/intern/GHOST_ContextEGL.h
@@ -24,6 +24,7 @@
#pragma once
#include "GHOST_Context.h"
+#include "GHOST_System.h"
#include <GL/eglew.h>
@@ -43,7 +44,8 @@ class GHOST_ContextEGL : public GHOST_Context {
/**
* Constructor.
*/
- GHOST_ContextEGL(bool stereoVisual,
+ GHOST_ContextEGL(const GHOST_System *const system,
+ bool stereoVisual,
EGLNativeWindowType nativeWindow,
EGLNativeDisplayType nativeDisplay,
EGLint contextProfileMask,
@@ -112,6 +114,8 @@ class GHOST_ContextEGL : public GHOST_Context {
private:
bool initContextEGLEW();
+ const GHOST_System *const m_system;
+
EGLNativeDisplayType m_nativeDisplay;
EGLNativeWindowType m_nativeWindow;
diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp
index ecf824aafb7..da8b1fd4941 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.cpp
+++ b/intern/ghost/intern/GHOST_ContextGLX.cpp
@@ -124,7 +124,7 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
GHOST_X11_ERROR_HANDLERS_OVERRIDE(handler_store);
/* -------------------------------------------------------------------- */
- /* Begin Inline Glew */
+ /* Begin Inline Glew */
#ifdef USE_GLXEW_INIT_WORKAROUND
const GLubyte *extStart = (GLubyte *)"";
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm
index 954c3efb22c..d899bb1c3c7 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm
+++ b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm
@@ -161,5 +161,5 @@ GHOST_TSuccess GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(
// CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues);
- return /*err == CGDisplayNoErr ?*/ GHOST_kSuccess /*: GHOST_kFailure*/;
+ return /* err == CGDisplayNoErr ? */ GHOST_kSuccess /* : GHOST_kFailure */;
}
diff --git a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h
index 5508d34e96c..a7339158dc4 100644
--- a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h
+++ b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h
@@ -40,6 +40,9 @@ class GHOST_IXrGraphicsBinding {
XrGraphicsBindingOpenGLWin32KHR wgl;
XrGraphicsBindingD3D11KHR d3d11;
#endif
+#if defined(WITH_GHOST_WAYLAND)
+ XrGraphicsBindingOpenGLWaylandKHR wl;
+#endif
} oxr_binding;
virtual ~GHOST_IXrGraphicsBinding() = default;
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 9915520691f..87ba0ae9c8c 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -239,7 +239,7 @@ class GHOST_System : public GHOST_ISystem {
* Set which tablet API to use. Only affects Windows, other platforms have a single API.
* \param api: Enum indicating which API to use.
*/
- virtual void setTabletAPI(GHOST_TTabletAPI api) override;
+ virtual void setTabletAPI(GHOST_TTabletAPI api);
GHOST_TTabletAPI getTabletAPI(void);
#ifdef WITH_INPUT_NDOF
@@ -328,8 +328,8 @@ class GHOST_System : public GHOST_ISystem {
*/
virtual GHOST_TSuccess showMessageBox(const char * /*title*/,
const char * /*message*/,
- const char * /*help_label */,
- const char * /*continue_label */,
+ const char * /*help_label*/,
+ const char * /*continue_label*/,
const char * /*link*/,
GHOST_DialogOptions /*dialog_options*/) const
{
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h
index cee6398b5a6..8a209c9efaf 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -137,7 +137,7 @@ class GHOST_SystemCocoa : public GHOST_System {
bool processEvents(bool waitForEvent);
/**
- * Handle User request to quit, from Menu bar Quit, and Cmd+Q
+ * Handle User request to quit, from Menu bar Quit, and Command+Q
* Display alert panel if changes performed since last save
*/
void handleQuitRequest();
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 6ddb7f031f5..97c5652f112 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -32,11 +32,7 @@
#include "GHOST_WindowCocoa.h"
#include "GHOST_WindowManager.h"
-#if defined(WITH_GL_EGL)
-# include "GHOST_ContextEGL.h"
-#else
-# include "GHOST_ContextCGL.h"
-#endif
+#include "GHOST_ContextCGL.h"
#ifdef WITH_INPUT_NDOF
# include "GHOST_NDOFManagerCocoa.h"
@@ -90,7 +86,8 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
{
// printf("\nrecvchar %c 0x%x",recvChar,recvChar);
switch (rawCode) {
- /*Physical keycodes not used due to map changes in int'l keyboards
+ /* Physical key-codes: (not used due to map changes in int'l keyboards). */
+#if 0
case kVK_ANSI_A: return GHOST_kKeyA;
case kVK_ANSI_B: return GHOST_kKeyB;
case kVK_ANSI_C: return GHOST_kKeyC;
@@ -116,9 +113,9 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
case kVK_ANSI_W: return GHOST_kKeyW;
case kVK_ANSI_X: return GHOST_kKeyX;
case kVK_ANSI_Y: return GHOST_kKeyY;
- case kVK_ANSI_Z: return GHOST_kKeyZ;*/
-
- /* Numbers keys mapped to handle some int'l keyboard (e.g. French)*/
+ case kVK_ANSI_Z: return GHOST_kKeyZ;
+#endif
+ /* Numbers keys: mapped to handle some int'l keyboard (e.g. French). */
case kVK_ISO_Section:
return GHOST_kKeyUnknown;
case kVK_ANSI_1:
@@ -248,8 +245,8 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
return GHOST_kKeyUpPage;
case kVK_PageDown:
return GHOST_kKeyDownPage;
-
- /*case kVK_ANSI_Minus: return GHOST_kKeyMinus;
+#if 0 /* TODO: why are these commented? */
+ case kVK_ANSI_Minus: return GHOST_kKeyMinus;
case kVK_ANSI_Equal: return GHOST_kKeyEqual;
case kVK_ANSI_Comma: return GHOST_kKeyComma;
case kVK_ANSI_Period: return GHOST_kKeyPeriod;
@@ -259,15 +256,15 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
case kVK_ANSI_Backslash: return GHOST_kKeyBackslash;
case kVK_ANSI_LeftBracket: return GHOST_kKeyLeftBracket;
case kVK_ANSI_RightBracket: return GHOST_kKeyRightBracket;
- case kVK_ANSI_Grave: return GHOST_kKeyAccentGrave;*/
-
+ case kVK_ANSI_Grave: return GHOST_kKeyAccentGrave;
+#endif
case kVK_VolumeUp:
case kVK_VolumeDown:
case kVK_Mute:
return GHOST_kKeyUnknown;
default: {
- /* alphanumerical or punctuation key that is remappable in int'l keyboards */
+ /* Alphanumerical or punctuation key that is remappable in int'l keyboards. */
if ((recvChar >= 'A') && (recvChar <= 'Z')) {
return (GHOST_TKey)(recvChar - 'A' + GHOST_kKeyA);
}
@@ -275,8 +272,8 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
return (GHOST_TKey)(recvChar - 'a' + GHOST_kKeyA);
}
else {
- /* Leopard and Snow Leopard 64bit compatible API*/
- CFDataRef uchrHandle; /*the keyboard layout*/
+ /* Leopard and Snow Leopard 64bit compatible API. */
+ CFDataRef uchrHandle; /* The keyboard layout. */
TISInputSourceRef kbdTISHandle;
kbdTISHandle = TISCopyCurrentKeyboardLayoutInputSource();
@@ -284,9 +281,9 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
kTISPropertyUnicodeKeyLayoutData);
CFRelease(kbdTISHandle);
- /*get actual character value of the "remappable" keys in int'l keyboards,
- if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger),
- then fallback on using the received charactersIgnoringModifiers */
+ /* Get actual character value of the "remappable" keys in int'l keyboards,
+ * if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger),
+ * then fallback on using the received #charactersIgnoringModifiers. */
if (uchrHandle) {
UInt32 deadKeyState = 0;
UniCharCount actualStrLength = 0;
@@ -437,8 +434,10 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
// So WM_exit needs to be called directly, as the event loop will never run before termination
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
- /*G.is_break = FALSE; //Let Cocoa perform the termination at the end
- WM_exit(C);*/
+#if 0
+ G.is_break = false; /* Let Cocoa perform the termination at the end. */
+ WM_exit(C);
+#endif
}
- (void)applicationWillBecomeActive:(NSNotification *)aNotification
@@ -553,10 +552,12 @@ GHOST_TSuccess GHOST_SystemCocoa::init()
// ProcessSerialNumber psn;
// Carbon stuff to move window & menu to foreground
- /*if (!GetCurrentProcess(&psn)) {
+#if 0
+ if (!GetCurrentProcess(&psn)) {
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
- }*/
+ }
+#endif
@autoreleasepool {
[NSApplication sharedApplication]; // initializes NSApp
@@ -1217,7 +1218,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
return GHOST_kFailure;
}
- /*Get the bitmap of the image*/
+ /* Get the bitmap of the image. */
enumerator = [[droppedImg representations] objectEnumerator];
while ((representation = [enumerator nextObject])) {
if ([representation isKindOfClass:[NSBitmapImageRep class]]) {
@@ -1230,7 +1231,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
if (([bitmapImage bitsPerPixel] == 32) && (([bitmapImage bitmapFormat] & 0x5) == 0) &&
![bitmapImage isPlanar]) {
- /* Try a fast copy if the image is a meshed RGBA 32bit bitmap*/
+ /* Try a fast copy if the image is a meshed RGBA 32bit bitmap. */
toIBuf = (GHOST_TUns8 *)ibuf->rect;
rasterRGB = (GHOST_TUns8 *)[bitmapImage bitmapData];
for (y = 0; y < imgSize.height; y++) {
@@ -1260,7 +1261,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat:(NSBitmapFormat)0
bytesPerRow:4 * imgSize.width
- bitsPerPixel:32 /*RGB format padded to 32bits*/];
+ bitsPerPixel:32 /* RGB format padded to 32bits. */];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext
@@ -1307,7 +1308,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
return GHOST_kFailure;
}
- /*Copy the image to ibuf, flipping it vertically*/
+ /* Copy the image to ibuf, flipping it vertically. */
toIBuf = (GHOST_TUns8 *)ibuf->rect;
for (y = 0; y < imgSize.height; y++) {
for (x = 0; x < imgSize.width; x++) {
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 83b9b2ba36b..f54a022f249 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -1590,15 +1590,36 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings /*g
d->os_surfaces.push_back(os_surface);
d->os_egl_windows.push_back(os_egl_window);
- GHOST_Context *context = new GHOST_ContextEGL(false,
- EGLNativeWindowType(os_egl_window),
- EGLNativeDisplayType(d->display),
- EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
- 3,
- 3,
- GHOST_OPENGL_EGL_CONTEXT_FLAGS,
- GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
- EGL_OPENGL_API);
+ GHOST_Context *context;
+
+ for (int minor = 6; minor >= 0; --minor) {
+ context = new GHOST_ContextEGL(this,
+ false,
+ EGLNativeWindowType(os_egl_window),
+ EGLNativeDisplayType(d->display),
+ EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
+ 4,
+ minor,
+ GHOST_OPENGL_EGL_CONTEXT_FLAGS,
+ GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
+ EGL_OPENGL_API);
+
+ if (context->initializeDrawingContext())
+ return context;
+ else
+ delete context;
+ }
+
+ context = new GHOST_ContextEGL(this,
+ false,
+ EGLNativeWindowType(os_egl_window),
+ EGLNativeDisplayType(d->display),
+ EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
+ 3,
+ 3,
+ GHOST_OPENGL_EGL_CONTEXT_FLAGS,
+ GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
+ EGL_OPENGL_API);
if (context->initializeDrawingContext()) {
return context;
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index aa8dad44799..a7cb4aee837 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -50,11 +50,7 @@
#include "GHOST_WindowManager.h"
#include "GHOST_WindowWin32.h"
-#if defined(WITH_GL_EGL)
-# include "GHOST_ContextEGL.h"
-#else
-# include "GHOST_ContextWGL.h"
-#endif
+#include "GHOST_ContextWGL.h"
#ifdef WITH_INPUT_NDOF
# include "GHOST_NDOFManagerWin32.h"
@@ -1016,8 +1012,8 @@ void GHOST_SystemWin32::processWintabEvent(GHOST_WindowWin32 *window)
void GHOST_SystemWin32::processPointerEvent(
UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventHandled)
{
- /* Pointer events might fire when changing windows for a device which is set to use Wintab, even
- * when when Wintab is left enabled but set to the bottom of Wintab overlap order. */
+ /* Pointer events might fire when changing windows for a device which is set to use Wintab,
+ * even when Wintab is left enabled but set to the bottom of Wintab overlap order. */
if (!window->usingTabletAPI(GHOST_kTabletWinPointer)) {
return;
}
@@ -1507,7 +1503,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
- /* These functions were replaced by WM_INPUT*/
+ /* These functions were replaced by #WM_INPUT. */
case WM_CHAR:
/* The WM_CHAR message is posted to the window with the keyboard focus when
* a WM_KEYDOWN message is translated by the TranslateMessage function. WM_CHAR
@@ -1638,7 +1634,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
}
/* Reset pointer pen info if pen device has left tracking range. */
- if (pointerInfo.pointerType == PT_PEN && !IS_POINTER_INRANGE_WPARAM(wParam)) {
+ if (pointerInfo.pointerType == PT_PEN) {
window->resetPointerPenInfo();
eventHandled = true;
}
@@ -1855,7 +1851,7 @@ 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.
*/
- /* see WM_SIZE comment*/
+ /* See #WM_SIZE comment. */
if (window->m_inLiveResize) {
system->pushEvent(processWindowEvent(GHOST_kEventWindowMove, window));
system->dispatchEvents();
@@ -1893,10 +1889,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
case WM_DISPLAYCHANGE: {
GHOST_Wintab *wt = window->getWintab();
if (wt) {
- for (GHOST_IWindow *iter_win : system->getWindowManager()->getWindows()) {
- GHOST_WindowWin32 *iter_win32win = (GHOST_WindowWin32 *)iter_win;
- wt->remapCoordinates();
- }
+ wt->remapCoordinates();
}
break;
}
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 34b44fde48a..c5564e9880e 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -89,7 +89,7 @@
/* see T34039 Fix Alt key glitch on Unity desktop */
#define USE_UNITY_WORKAROUND
-/* Fix 'shortcut' part of keyboard reading code only ever using first defined keymap
+/* Fix 'shortcut' part of keyboard reading code only ever using first defined key-map
* instead of active one. See T47228 and D1746 */
#define USE_NON_LATIN_KB_WORKAROUND
@@ -441,7 +441,8 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
for (int minor = 5; minor >= 0; --minor) {
#if defined(WITH_GL_EGL)
- context = new GHOST_ContextEGL(false,
+ context = new GHOST_ContextEGL(this,
+ false,
EGLNativeWindowType(nullptr),
EGLNativeDisplayType(m_display),
profile_mask,
@@ -471,7 +472,8 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
}
#if defined(WITH_GL_EGL)
- context = new GHOST_ContextEGL(false,
+ context = new GHOST_ContextEGL(this,
+ false,
EGLNativeWindowType(nullptr),
EGLNativeDisplayType(m_display),
profile_mask,
@@ -589,9 +591,7 @@ static void SleepTillEvent(Display *display, GHOST_TInt64 maxSleep)
}
}
-/* This function borrowed from Qt's X11 support
- * qclipboard_x11.cpp
- * */
+/* This function borrowed from Qt's X11 support qclipboard_x11.cpp */
struct init_timestamp_data {
Time timestamp;
};
@@ -1044,33 +1044,30 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
GHOST_TKey gkey;
#ifdef USE_NON_LATIN_KB_WORKAROUND
- /* XXX Code below is kinda awfully convoluted... Issues are:
- *
- * - In keyboards like latin ones, numbers need a 'Shift' to be accessed but key_sym
- * is unmodified (or anyone swapping the keys with xmodmap).
- *
- * - XLookupKeysym seems to always use first defined keymap (see T47228), which generates
- * keycodes unusable by ghost_key_from_keysym for non-Latin-compatible keymaps.
+ /* XXX: Code below is kinda awfully convoluted... Issues are:
+ * - In keyboards like latin ones, numbers need a 'Shift' to be accessed but key_sym
+ * is unmodified (or anyone swapping the keys with `xmodmap`).
+ * - #XLookupKeysym seems to always use first defined key-map (see T47228), which generates
+ * key-codes unusable by ghost_key_from_keysym for non-Latin-compatible key-maps.
*
* To address this, we:
- *
- * - Try to get a 'number' key_sym using XLookupKeysym (with virtual shift modifier),
- * in a very restrictive set of cases.
- * - Fallback to XLookupString to get a key_sym from active user-defined keymap.
+ * - Try to get a 'number' key_sym using #XLookupKeysym (with virtual shift modifier),
+ * in a very restrictive set of cases.
+ * - Fallback to #XLookupString to get a key_sym from active user-defined key-map.
*
* 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 key-map 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...
+ * 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,
+ /* 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;
@@ -2675,8 +2672,8 @@ void GHOST_SystemX11::refreshXInputDevices()
xtablet.PressureLevels = xvi->axes[2].max_value;
if (xvi->num_axes > 3) {
- /* this is assuming that the tablet has the same tilt resolution in both
- * positive and negative directions. It would be rather weird if it didn't.. */
+ /* This is assuming that the tablet has the same tilt resolution in both
+ * positive and negative directions. It would be rather weird if it didn't. */
xtablet.XtiltLevels = xvi->axes[3].max_value;
xtablet.YtiltLevels = xvi->axes[4].max_value;
}
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 1f2fed5b823..3542c6f2bcf 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -365,7 +365,7 @@ class GHOST_Window : public GHOST_IWindow {
/** The current grabbed state of the cursor */
GHOST_TGrabCursorMode m_cursorGrab;
- /** Grab cursor axis.*/
+ /** Grab cursor axis. */
GHOST_TAxisFlag m_cursorGrabAxis;
/** Initial grab location. */
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 1776b0d5ce0..d082fa99ad8 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -22,11 +22,7 @@
#include "GHOST_Debug.h"
#include "GHOST_SystemCocoa.h"
-#if defined(WITH_GL_EGL)
-# include "GHOST_ContextEGL.h"
-#else
-# include "GHOST_ContextCGL.h"
-#endif
+#include "GHOST_ContextCGL.h"
#include <Cocoa/Cocoa.h>
#include <Metal/Metal.h>
diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp
index cbac2d6eaa1..5be7724fd86 100644
--- a/intern/ghost/intern/GHOST_WindowWayland.cpp
+++ b/intern/ghost/intern/GHOST_WindowWayland.cpp
@@ -532,7 +532,25 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
context = new GHOST_ContextNone(m_wantStereoVisual);
break;
case GHOST_kDrawingContextTypeOpenGL:
- context = new GHOST_ContextEGL(m_wantStereoVisual,
+ for (int minor = 6; minor >= 0; --minor) {
+ context = new GHOST_ContextEGL(this->m_system,
+ m_wantStereoVisual,
+ EGLNativeWindowType(w->egl_window),
+ EGLNativeDisplayType(m_system->display()),
+ EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
+ 4,
+ minor,
+ GHOST_OPENGL_EGL_CONTEXT_FLAGS,
+ GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
+ EGL_OPENGL_API);
+
+ if (context->initializeDrawingContext())
+ return context;
+ else
+ delete context;
+ }
+ context = new GHOST_ContextEGL(this->m_system,
+ m_wantStereoVisual,
EGLNativeWindowType(w->egl_window),
EGLNativeDisplayType(m_system->display()),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
@@ -541,7 +559,6 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
- break;
}
return (context->initializeDrawingContext() == GHOST_kSuccess) ? context : nullptr;
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 33c79daf11d..762ee6bc0eb 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -30,17 +30,15 @@
#include "utf_winfunc.h"
#include "utfconv.h"
-#if defined(WITH_GL_EGL)
-# include "GHOST_ContextEGL.h"
-#else
-# include "GHOST_ContextWGL.h"
-#endif
+#include "GHOST_ContextWGL.h"
+
#ifdef WIN32_COMPOSITING
# include <Dwmapi.h>
#endif
#include <assert.h>
#include <math.h>
+#include <shellscalingapi.h>
#include <string.h>
#include <windowsx.h>
@@ -83,13 +81,10 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
m_wintab(NULL),
m_lastPointerTabletData(GHOST_TABLET_DATA_NONE),
m_normal_state(GHOST_kWindowStateNormal),
- m_user32(NULL),
+ m_user32(::LoadLibrary("user32.dll")),
m_parentWindowHwnd(parentwindow ? parentwindow->m_hWnd : HWND_DESKTOP),
m_debug_context(is_debug)
{
- wchar_t *title_16 = alloc_utf16_from_8((char *)title, 0);
- RECT win_rect = {left, top, (long)(left + width), (long)(top + height)};
-
DWORD style = parentwindow ?
WS_POPUPWINDOW | WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SIZEBOX :
WS_OVERLAPPEDWINDOW;
@@ -108,27 +103,10 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
*/
}
- /* Monitor details. */
- MONITORINFOEX monitor;
- monitor.cbSize = sizeof(MONITORINFOEX);
- monitor.dwFlags = 0;
- GetMonitorInfo(MonitorFromRect(&win_rect, MONITOR_DEFAULTTONEAREST), &monitor);
-
- /* Constrain requested size and position to fit within this monitor. */
- width = min(monitor.rcWork.right - monitor.rcWork.left, win_rect.right - win_rect.left);
- height = min(monitor.rcWork.bottom - monitor.rcWork.top, win_rect.bottom - win_rect.top);
- win_rect.left = min(max(monitor.rcWork.left, win_rect.left), monitor.rcWork.right - width);
- win_rect.right = win_rect.left + width;
- win_rect.top = min(max(monitor.rcWork.top, win_rect.top), monitor.rcWork.bottom - height);
- win_rect.bottom = win_rect.top + height;
-
- /* Adjust to allow for caption, borders, shadows, scaling, etc. Resulting values can be
- * correctly outside of monitor bounds. Note: You cannot specify WS_OVERLAPPED when calling. */
- AdjustWindowRectEx(&win_rect, style & ~WS_OVERLAPPED, FALSE, extended_style);
-
- /* But never allow a top position that can hide part of the title bar. */
- win_rect.top = max(monitor.rcWork.top, win_rect.top);
+ RECT win_rect = {left, top, (long)(left + width), (long)(top + height)};
+ adjustWindowRectForClosestMonitor(&win_rect, style, extended_style);
+ wchar_t *title_16 = alloc_utf16_from_8((char *)title, 0);
m_hWnd = ::CreateWindowExW(extended_style, // window extended style
s_windowClassName, // pointer to registered class name
title_16, // pointer to window name
@@ -143,81 +121,78 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
0); // pointer to window-creation data
free(title_16);
- m_user32 = ::LoadLibrary("user32.dll");
+ if (m_hWnd == NULL) {
+ return;
+ }
- if (m_hWnd) {
- RegisterTouchWindow(m_hWnd, 0);
+ /* Store the device context. */
+ m_hDC = ::GetDC(m_hWnd);
- // Register this window as a droptarget. Requires m_hWnd to be valid.
- // Note that OleInitialize(0) has to be called prior to this. Done in GHOST_SystemWin32.
- m_dropTarget = new GHOST_DropTargetWin32(this, m_system);
- if (m_dropTarget) {
- ::RegisterDragDrop(m_hWnd, m_dropTarget);
- }
+ if (!setDrawingContextType(type)) {
+ ::DestroyWindow(m_hWnd);
+ m_hWnd = NULL;
+ return;
+ }
- // Store a pointer to this class in the window structure
- ::SetWindowLongPtr(m_hWnd, GWLP_USERDATA, (LONG_PTR)this);
+ RegisterTouchWindow(m_hWnd, 0);
- if (!m_system->m_windowFocus) {
- // Lower to bottom and don't activate if we don't want focus
- ::SetWindowPos(m_hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- }
+ /* Register as drop-target. #OleInitialize(0) required first, done in GHOST_SystemWin32. */
+ m_dropTarget = new GHOST_DropTargetWin32(this, m_system);
+ ::RegisterDragDrop(m_hWnd, m_dropTarget);
- // Store the device context
- m_hDC = ::GetDC(m_hWnd);
-
- GHOST_TSuccess success = setDrawingContextType(type);
-
- if (success) {
- // Show the window
- int nCmdShow;
- switch (state) {
- case GHOST_kWindowStateMaximized:
- nCmdShow = SW_SHOWMAXIMIZED;
- break;
- case GHOST_kWindowStateMinimized:
- nCmdShow = (m_system->m_windowFocus) ? SW_SHOWMINIMIZED : SW_SHOWMINNOACTIVE;
- break;
- case GHOST_kWindowStateNormal:
- default:
- nCmdShow = (m_system->m_windowFocus) ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE;
- break;
- }
+ /* Store a pointer to this class in the window structure. */
+ ::SetWindowLongPtr(m_hWnd, GWLP_USERDATA, (LONG_PTR)this);
+
+ if (!m_system->m_windowFocus) {
+ /* If we don't want focus then lower to bottom. */
+ ::SetWindowPos(m_hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ }
+
+ /* Show the window. */
+ int nCmdShow;
+ switch (state) {
+ case GHOST_kWindowStateMaximized:
+ nCmdShow = SW_SHOWMAXIMIZED;
+ break;
+ case GHOST_kWindowStateMinimized:
+ nCmdShow = (m_system->m_windowFocus) ? SW_SHOWMINIMIZED : SW_SHOWMINNOACTIVE;
+ break;
+ case GHOST_kWindowStateNormal:
+ default:
+ nCmdShow = (m_system->m_windowFocus) ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE;
+ break;
+ }
+
+ ::ShowWindow(m_hWnd, nCmdShow);
- ::ShowWindow(m_hWnd, nCmdShow);
#ifdef WIN32_COMPOSITING
- if (alphaBackground && parentwindowhwnd == 0) {
+ if (alphaBackground && parentwindowhwnd == 0) {
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- // Create and populate the Blur Behind structure
- DWM_BLURBEHIND bb = {0};
+ /* Create and populate the Blur Behind structure. */
+ DWM_BLURBEHIND bb = {0};
- // Enable Blur Behind and apply to the entire client area
- bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
- bb.fEnable = true;
- bb.hRgnBlur = CreateRectRgn(0, 0, -1, -1);
+ /* Enable Blur Behind and apply to the entire client area. */
+ bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
+ bb.fEnable = true;
+ bb.hRgnBlur = CreateRectRgn(0, 0, -1, -1);
- // Apply Blur Behind
- hr = DwmEnableBlurBehindWindow(m_hWnd, &bb);
- DeleteObject(bb.hRgnBlur);
- }
-#endif
- // Force an initial paint of the window
- ::UpdateWindow(m_hWnd);
- }
- else {
- // invalidate the window
- ::DestroyWindow(m_hWnd);
- m_hWnd = NULL;
- }
+ /* Apply Blur Behind. */
+ hr = DwmEnableBlurBehindWindow(m_hWnd, &bb);
+ DeleteObject(bb.hRgnBlur);
}
+#endif
+
+ /* Force an initial paint of the window. */
+ ::UpdateWindow(m_hWnd);
- // Initialize Wintab
+ /* Initialize Wintab. */
if (system->getTabletAPI() != GHOST_kTabletWinPointer) {
loadWintab(GHOST_kWindowStateMinimized != state);
}
+ /* Allow the showing of a progress bar on the taskbar. */
CoCreateInstance(
CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (LPVOID *)&m_Bar);
}
@@ -271,6 +246,47 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
}
}
+void GHOST_WindowWin32::adjustWindowRectForClosestMonitor(LPRECT win_rect,
+ DWORD dwStyle,
+ DWORD dwExStyle)
+{
+ /* Get Details of the closest monitor. */
+ HMONITOR hmonitor = MonitorFromRect(win_rect, MONITOR_DEFAULTTONEAREST);
+ MONITORINFOEX monitor;
+ monitor.cbSize = sizeof(MONITORINFOEX);
+ monitor.dwFlags = 0;
+ GetMonitorInfo(hmonitor, &monitor);
+
+ /* Constrain requested size and position to fit within this monitor. */
+ LONG width = min(monitor.rcWork.right - monitor.rcWork.left, win_rect->right - win_rect->left);
+ LONG height = min(monitor.rcWork.bottom - monitor.rcWork.top, win_rect->bottom - win_rect->top);
+ win_rect->left = min(max(monitor.rcWork.left, win_rect->left), monitor.rcWork.right - width);
+ win_rect->right = win_rect->left + width;
+ win_rect->top = min(max(monitor.rcWork.top, win_rect->top), monitor.rcWork.bottom - height);
+ win_rect->bottom = win_rect->top + height;
+
+ /* With Windows 10 and newer we can adjust for chrome that differs with DPI and scale. */
+ GHOST_WIN32_AdjustWindowRectExForDpi fpAdjustWindowRectExForDpi = nullptr;
+ if (m_user32) {
+ fpAdjustWindowRectExForDpi = (GHOST_WIN32_AdjustWindowRectExForDpi)::GetProcAddress(
+ m_user32, "AdjustWindowRectExForDpi");
+ }
+
+ /* Adjust to allow for caption, borders, shadows, scaling, etc. Resulting values can be
+ * correctly outside of monitor bounds. Note: You cannot specify WS_OVERLAPPED when calling. */
+ if (fpAdjustWindowRectExForDpi) {
+ UINT dpiX, dpiY;
+ GetDpiForMonitor(hmonitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY);
+ fpAdjustWindowRectExForDpi(win_rect, dwStyle & ~WS_OVERLAPPED, FALSE, dwExStyle, dpiX);
+ }
+ else {
+ AdjustWindowRectEx(win_rect, dwStyle & ~WS_OVERLAPPED, FALSE, dwExStyle);
+ }
+
+ /* But never allow a top position that can hide part of the title bar. */
+ win_rect->top = max(monitor.rcWork.top, win_rect->top);
+}
+
bool GHOST_WindowWin32::getValid() const
{
return GHOST_Window::getValid() && m_hWnd != 0 && m_hDC != 0;
@@ -290,9 +306,13 @@ void GHOST_WindowWin32::setTitle(const char *title)
std::string GHOST_WindowWin32::getTitle() const
{
- char buf[s_maxTitleLength]; /*CHANGE + never used yet*/
- ::GetWindowText(m_hWnd, buf, s_maxTitleLength);
- return std::string(buf);
+ std::wstring wtitle(::GetWindowTextLengthW(m_hWnd) + 1, L'\0');
+ ::GetWindowTextW(m_hWnd, &wtitle[0], wtitle.capacity());
+
+ std::string title(count_utf_8_from_16(wtitle.c_str()) + 1, '\0');
+ conv_utf_16_to_8(wtitle.c_str(), &title[0], title.capacity());
+
+ return title;
}
void GHOST_WindowWin32::getWindowBounds(GHOST_Rect &bounds) const
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h
index f28ba266ed1..119092a001a 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -43,6 +43,9 @@ class GHOST_DropTargetWin32;
// typedefs for user32 functions to allow dynamic loading of Windows 10 DPI scaling functions
typedef UINT(API *GHOST_WIN32_GetDpiForWindow)(HWND);
+typedef BOOL(API *GHOST_WIN32_AdjustWindowRectExForDpi)(
+ LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi);
+
struct GHOST_PointerInfoWin32 {
GHOST_TInt32 pointerId;
GHOST_TInt32 isPrimary;
@@ -99,6 +102,14 @@ class GHOST_WindowWin32 : public GHOST_Window {
~GHOST_WindowWin32();
/**
+ * Adjusts a requested window rect to fit and position correctly in monitor.
+ * \param win_rect: pointer to rectangle that will be modified.
+ * \param dwStyle: The Window Style of the window whose required size is to be calculated.
+ * \param dwExStyle: The Extended Window Style of the window.
+ */
+ void adjustWindowRectForClosestMonitor(LPRECT win_rect, DWORD dwStyle, DWORD dwExStyle);
+
+ /**
* Returns indication as to whether the window is valid.
* \return The validity of the window.
*/
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index fc006c62803..ea798441adb 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -1241,7 +1241,7 @@ GHOST_WindowX11::~GHOST_WindowX11()
if (m_valid_setup) {
static Atom Primary_atom, Clipboard_atom;
Window p_owner, c_owner;
- /*Change the owner of the Atoms to None if we are the owner*/
+ /* Change the owner of the Atoms to None if we are the owner. */
Primary_atom = XInternAtom(m_display, "PRIMARY", False);
Clipboard_atom = XInternAtom(m_display, "CLIPBOARD", False);
@@ -1325,6 +1325,7 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
for (int minor = 5; minor >= 0; --minor) {
#ifdef WITH_GL_EGL
context = new GHOST_ContextEGL(
+ this->m_system,
m_wantStereoVisual,
EGLNativeWindowType(m_window),
EGLNativeDisplayType(m_display),
@@ -1355,7 +1356,8 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
}
#ifdef WITH_GL_EGL
- context = new GHOST_ContextEGL(m_wantStereoVisual,
+ context = new GHOST_ContextEGL(this->m_system,
+ m_wantStereoVisual,
EGLNativeWindowType(m_window),
EGLNativeDisplayType(m_display),
profile_mask,
diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp
index f057e679d56..2906a6b241e 100644
--- a/intern/ghost/intern/GHOST_XrContext.cpp
+++ b/intern/ghost/intern/GHOST_XrContext.cpp
@@ -420,7 +420,7 @@ void GHOST_XrContext::getExtensionsToEnable(
r_ext_names.push_back(gpu_binding);
}
-#if defined(WITH_GL_EGL)
+#if defined(WITH_GHOST_X11) && defined(WITH_GL_EGL)
assert(openxr_extension_is_available(m_oxr->extensions, XR_MNDX_EGL_ENABLE_EXTENSION_NAME));
r_ext_names.push_back(XR_MNDX_EGL_ENABLE_EXTENSION_NAME);
#endif
diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
index aeaa6e6b9e0..dd0205ea867 100644
--- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
+++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
@@ -24,6 +24,12 @@
#if defined(WITH_GL_EGL)
# include "GHOST_ContextEGL.h"
+# if defined(WITH_GHOST_X11)
+# include "GHOST_SystemX11.h"
+# endif
+# if defined(WITH_GHOST_WAYLAND)
+# include "GHOST_SystemWayland.h"
+# endif
#elif defined(WITH_GHOST_X11)
# include "GHOST_ContextGLX.h"
#elif defined(WIN32)
@@ -113,11 +119,13 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
# if defined(WITH_GL_EGL)
GHOST_ContextEGL &ctx_egl = static_cast<GHOST_ContextEGL &>(ghost_ctx);
- oxr_binding.egl.type = XR_TYPE_GRAPHICS_BINDING_EGL_MNDX;
- oxr_binding.egl.getProcAddress = eglGetProcAddress;
- oxr_binding.egl.display = ctx_egl.getDisplay();
- oxr_binding.egl.config = ctx_egl.getConfig();
- oxr_binding.egl.context = ctx_egl.getContext();
+ if (dynamic_cast<const GHOST_SystemX11 *const>(ctx_egl.m_system)) {
+ oxr_binding.egl.type = XR_TYPE_GRAPHICS_BINDING_EGL_MNDX;
+ oxr_binding.egl.getProcAddress = eglGetProcAddress;
+ oxr_binding.egl.display = ctx_egl.getDisplay();
+ oxr_binding.egl.config = ctx_egl.getConfig();
+ oxr_binding.egl.context = ctx_egl.getContext();
+ }
# else
GHOST_ContextGLX &ctx_glx = static_cast<GHOST_ContextGLX &>(ghost_ctx);
XVisualInfo *visual_info = glXGetVisualFromFBConfig(ctx_glx.m_display, ctx_glx.m_fbconfig);
@@ -139,6 +147,14 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
oxr_binding.wgl.hGLRC = ctx_wgl.m_hGLRC;
#endif
+#if defined(WITH_GHOST_WAYLAND)
+ GHOST_ContextEGL &ctx_wl_egl = static_cast<GHOST_ContextEGL &>(ghost_ctx);
+ if (dynamic_cast<const GHOST_SystemWayland *const>(ctx_wl_egl.m_system)) {
+ oxr_binding.wl.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_WAYLAND_KHR;
+ oxr_binding.wl.display = (struct wl_display *)ctx_wl_egl.m_nativeDisplay;
+ }
+#endif
+
/* Generate a frame-buffer to use for blitting into the texture. */
glGenFramebuffers(1, &m_fbo);
}
diff --git a/intern/ghost/test/gears/GHOST_C-Test.c b/intern/ghost/test/gears/GHOST_C-Test.c
index 8cd1b5acb89..1867218ec65 100644
--- a/intern/ghost/test/gears/GHOST_C-Test.c
+++ b/intern/ghost/test/gears/GHOST_C-Test.c
@@ -274,7 +274,7 @@ static void setViewPortGL(GHOST_WindowHandle hWindow)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-w, w, -h, h, 5.0, 60.0);
- /* glOrtho(0, bnds.getWidth(), 0, bnds.getHeight(), -10, 10); */
+ // glOrtho(0, bnds.getWidth(), 0, bnds.getHeight(), -10, 10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -40.0);
diff --git a/intern/ghost/test/multitest/MultiTest.c b/intern/ghost/test/multitest/MultiTest.c
index 3b424f1ca89..ccbbbceb5b6 100644
--- a/intern/ghost/test/multitest/MultiTest.c
+++ b/intern/ghost/test/multitest/MultiTest.c
@@ -60,7 +60,7 @@
#include "GPU_init_exit.h"
extern int datatoc_bfont_ttf_size;
-extern char datatoc_bfont_ttf[];
+extern char const datatoc_bfont_ttf[];
typedef struct _LoggerWindow LoggerWindow;
typedef struct _MultiTestApp MultiTestApp;
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index 89cb68010fb..713b1fac788 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -78,7 +78,7 @@ extern short (*MEM_testN)(void *vmemh);
/**
* Duplicates a block of memory, and returns a pointer to the
- * newly allocated block. */
+ * newly allocated block. */
extern void *(*MEM_dupallocN)(const void *vmemh) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT;
/**
diff --git a/intern/guardedalloc/test/simpletest/memtest.c b/intern/guardedalloc/test/simpletest/memtest.c
index f7a9a785f5a..498857de8ea 100644
--- a/intern/guardedalloc/test/simpletest/memtest.c
+++ b/intern/guardedalloc/test/simpletest/memtest.c
@@ -103,7 +103,7 @@ int main(int argc, char *argv[])
/* ----------------------------------------------------------------- */
/* Round two, do a normal allocation, and corrupt some blocks. */
/* ----------------------------------------------------------------- */
- /* switch off, because it will complain about some things. */
+ /* Switch off, because it will complain about some things. */
MEM_set_error_callback(NULL);
for (i = 0; i < NUM_BLOCKS; i++) {
@@ -115,7 +115,7 @@ int main(int argc, char *argv[])
p[i] = MEM_callocN(blocksize, strdup(tagstring));
}
- /* now corrupt a few blocks...*/
+ /* Now corrupt a few blocks. */
ip = (int *)p[5] - 50;
for (i = 0; i < 1000; i++, ip++)
*ip = i + 1;
diff --git a/intern/itasc/kdl/frames.inl b/intern/itasc/kdl/frames.inl
index a09b532762b..f7a805d10c4 100644
--- a/intern/itasc/kdl/frames.inl
+++ b/intern/itasc/kdl/frames.inl
@@ -867,7 +867,7 @@ IMETHOD void Vector2::Set3DYZ(const Vector& v)
data[1]=v(2);
}
IMETHOD void Vector2::Set3DZX(const Vector& v)
-// projects v in its XY plane, and and sets *this to these values
+// projects v in its XY plane, and sets *this to these values
{
data[0]=v(2);
data[1]=v(0);
diff --git a/intern/libmv/libmv/image/array_nd.h b/intern/libmv/libmv/image/array_nd.h
index 1a3c39d0461..8ece99a8376 100644
--- a/intern/libmv/libmv/image/array_nd.h
+++ b/intern/libmv/libmv/image/array_nd.h
@@ -378,7 +378,7 @@ void PrintArray(const Array3Df& array);
* (if automatic_range_detection = true)
* \note and TODO this automatic detection only works when the image contains
* at least one pixel of both bounds.
- **/
+ */
void FloatArrayToScaledByteArray(const Array3Df& float_array,
Array3Du* byte_array,
bool automatic_range_detection = false);
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp
index c04180c8c46..5b27bd91d91 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -323,7 +323,7 @@ static void get_rgba(
float *r, float *g, float *b, float *a, int total_cells, float *data, int sequential)
{
int i;
- /* Use offsets to map RGB grids to to correct location in data grid. */
+ /* Use offsets to map RGB grids to correct location in data grid. */
int m = 4, i_g = 1, i_b = 2, i_a = 3;
if (sequential) {
m = 1;
diff --git a/intern/mikktspace/mikktspace.c b/intern/mikktspace/mikktspace.c
index b0119f54019..96e8d433e30 100644
--- a/intern/mikktspace/mikktspace.c
+++ b/intern/mikktspace/mikktspace.c
@@ -425,14 +425,15 @@ tbool genTangSpace(const SMikkTSpaceContext *pContext, const float fAngularThres
index = 0;
for (f = 0; f < iNrFaces; f++) {
const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f);
- if (verts != 3 && verts != 4)
+ if (verts != 3 && verts != 4) {
continue;
+ }
// I've decided to let degenerate triangles and group-with-anythings
// vary between left/right hand coordinate systems at the vertices.
// All healthy triangles on the other hand are built to always be either or.
-
- /*// force the coordinate system orientation to be uniform for every face.
+#if 0
+ // force the coordinate system orientation to be uniform for every face.
// (this is already the case for good triangles but not for
// degenerate ones and those with bGroupWithAnything==true)
bool bOrient = psTspace[index].bOrient;
@@ -447,7 +448,8 @@ tbool genTangSpace(const SMikkTSpaceContext *pContext, const float fAngularThres
else ++i;
}
if (!bNotFound) bOrient = psTspace[index+i].bOrient;
- }*/
+ }
+#endif
// set data
for (i = 0; i < verts; i++) {
diff --git a/intern/opencolorio/CMakeLists.txt b/intern/opencolorio/CMakeLists.txt
index d2336692d22..0b46ae471d2 100644
--- a/intern/opencolorio/CMakeLists.txt
+++ b/intern/opencolorio/CMakeLists.txt
@@ -48,6 +48,7 @@ if(WITH_OPENCOLORIO)
)
add_definitions(${GL_DEFINITIONS})
+ add_definitions(${OPENCOLORIO_DEFINITIONS})
list(APPEND INC_SYS
${OPENCOLORIO_INCLUDE_DIRS}
@@ -67,9 +68,6 @@ if(WITH_OPENCOLORIO)
list(APPEND INC_SYS
${BOOST_INCLUDE_DIR}
)
- add_definitions(
- -DOpenColorIO_STATIC
- )
list(APPEND LIB
${BOOST_LIBRARIES}
)
diff --git a/intern/opencolorio/gpu_shader_display_transform.glsl b/intern/opencolorio/gpu_shader_display_transform.glsl
index ca0d2566ed1..d94ff9230e8 100644
--- a/intern/opencolorio/gpu_shader_display_transform.glsl
+++ b/intern/opencolorio/gpu_shader_display_transform.glsl
@@ -195,7 +195,7 @@ vec4 OCIO_ProcessColor(vec4 col, vec4 col_overlay, vec2 noise_uv)
return col;
}
-/* ------------------------------------------------------------------------ */
+/* ------------------------------------------------------------------------ */
in vec2 texCoord_interp;
out vec4 fragColor;
diff --git a/intern/openvdb/openvdb_capi.h b/intern/openvdb/openvdb_capi.h
index ea963a269fc..98d89c340bf 100644
--- a/intern/openvdb/openvdb_capi.h
+++ b/intern/openvdb/openvdb_capi.h
@@ -85,7 +85,7 @@ struct OpenVDBRemeshData {
int out_tottris;
int filter_type;
enum OpenVDBLevelSet_FilterType filter_bias;
- enum OpenVDBLevelSet_FilterBias filter_width; /* Parameter for gaussian, median, mean*/
+ enum OpenVDBLevelSet_FilterBias filter_width; /* Parameter for gaussian, median, mean. */
float voxel_size;
float isovalue;
diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c
index 48e675492f9..441a92127ea 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -1041,6 +1041,11 @@ const bTheme U_theme_default = {
.active_object = RGBA(0xffaf29ff),
.edited_object = RGBA(0x00806266),
.row_alternate = RGBA(0xffffff07),
+ .list = RGBA(0x424242ff),
+ .list_title = RGBA(0xc3c3c3ff),
+ .list_text = RGBA(0xc3c3c3ff),
+ .list_text_hi = RGBA(0xffffff),
+ .hilite = RGBA(0x80808080),
},
.tarm = {
{
diff --git a/release/freedesktop/blender.desktop b/release/freedesktop/blender.desktop
index d661a157bfb..792f98be505 100644
--- a/release/freedesktop/blender.desktop
+++ b/release/freedesktop/blender.desktop
@@ -83,5 +83,7 @@ Exec=blender %f
Icon=blender
Terminal=false
Type=Application
+PrefersNonDefaultGPU=true
+X-KDE-RunOnDiscreteGpu=true
Categories=Graphics;3DGraphics;
MimeType=application/x-blender;
diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py
index 0868b772a2b..dd19bb8f975 100644
--- a/release/scripts/modules/bpy_extras/anim_utils.py
+++ b/release/scripts/modules/bpy_extras/anim_utils.py
@@ -156,10 +156,9 @@ def bake_action_iter(
# Note: BBONE_PROPS is a list so we can preserve the ordering
BBONE_PROPS = [
'bbone_curveinx', 'bbone_curveoutx',
- 'bbone_curveiny', 'bbone_curveouty',
+ 'bbone_curveinz', 'bbone_curveoutz',
'bbone_rollin', 'bbone_rollout',
- 'bbone_scaleinx', 'bbone_scaleoutx',
- 'bbone_scaleiny', 'bbone_scaleouty',
+ 'bbone_scalein', 'bbone_scaleout',
'bbone_easein', 'bbone_easeout'
]
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index bd14b2c532c..7f1039a975b 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -187,7 +187,7 @@ def _template_items_context_panel(menu, key_args_primary):
]
-def _template_space_region_type_toggle(*, toolbar_key=None, sidebar_key=None):
+def _template_space_region_type_toggle(*, toolbar_key=None, sidebar_key=None, channels_key=None):
items = []
if toolbar_key is not None:
items.append(
@@ -199,6 +199,12 @@ def _template_space_region_type_toggle(*, toolbar_key=None, sidebar_key=None):
("wm.context_toggle", sidebar_key,
{"properties": [("data_path", 'space_data.show_region_ui')]}),
)
+ if channels_key is not None:
+ items.append(
+ ("wm.context_toggle", channels_key,
+ {"properties": [("data_path", 'space_data.show_region_channels')]}),
+ )
+
return items
@@ -3021,6 +3027,7 @@ def km_spreadsheet_generic(_params):
items.extend([
*_template_space_region_type_toggle(
sidebar_key={"type": 'N', "value": 'PRESS'},
+ channels_key={"type": 'T', "value": 'PRESS'},
),
])
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 e56783fcc21..b0144672745 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -2143,6 +2143,21 @@ def km_clip_dopesheet_editor(_params):
return keymap
+def km_spreadsheet_generic(_params):
+ items = []
+ keymap = (
+ "Spreadsheet Generic",
+ {"space_type": 'SPREADSHEET', "region_type": 'WINDOW'},
+ {"items": items},
+ )
+
+ items.extend([
+ *_template_space_region_type_toggle(
+ channels_key={"type": 'T', "value": 'PRESS'},
+ ),
+ ])
+
+ return keymap
# ------------------------------------------------------------------------------
# Animation
diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py
index a16410fcec9..27de80bb88d 100644
--- a/release/scripts/startup/bl_ui/properties_collection.py
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -25,6 +25,10 @@ class CollectionButtonsPanel:
bl_region_type = 'WINDOW'
bl_context = "collection"
+ @classmethod
+ def poll(cls, context):
+ return context.collection != context.scene.collection
+
def lineart_make_line_type_entry(col, line_type, text_disp, expand, search_from):
col.prop(line_type, "use", text=text_disp)
@@ -38,12 +42,6 @@ def lineart_make_line_type_entry(col, line_type, text_disp, expand, search_from)
class COLLECTION_PT_collection_flags(CollectionButtonsPanel, Panel):
bl_label = "Restrictions"
- @classmethod
- def poll(cls, context):
- vl = context.view_layer
- vlc = vl.active_layer_collection
- return (vlc.name != 'Master Collection')
-
def draw(self, context):
layout = self.layout
layout.use_property_split = True
@@ -89,8 +87,11 @@ class COLLECTION_PT_lineart_collection(CollectionButtonsPanel, Panel):
row.prop(collection, "lineart_usage")
layout.prop(collection, "lineart_use_intersection_mask")
- row = layout.row()
- row.prop(collection, "lineart_intersection_mask", text="Masks", toggle=True)
+
+ row = layout.row(align=True, heading="Masks")
+ row.active = collection.lineart_use_intersection_mask
+ for i in range(0,8):
+ row.prop(collection, "lineart_intersection_mask", index=i, text=str(i), toggle=True)
classes = (
diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py
index a88def34767..2a0cf56534c 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -505,6 +505,7 @@ class ConstraintButtonsPanel:
self.target_template(layout, con)
+ layout.prop(con, "remove_target_shear")
layout.prop(con, "mix_mode", text="Mix")
self.space_template(layout, con)
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index a9d7b8d71f3..fb8aedd1f49 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -20,6 +20,7 @@
import bpy
from bpy.types import Menu, Panel, UIList
from rna_prop_ui import PropertyPanel
+from collections import defaultdict
class MESH_MT_vertex_group_context_menu(Menu):
@@ -117,7 +118,7 @@ class MESH_UL_shape_keys(UIList):
split = layout.split(factor=0.66, align=False)
split.prop(key_block, "name", text="", emboss=False, icon_value=icon)
row = split.row(align=True)
- row.emboss = 'UI_EMBOSS_NONE_OR_STATUS'
+ row.emboss = 'NONE_OR_STATUS'
if key_block.mute or (obj.mode == 'EDIT' and not (obj.use_shape_key_edit_mode and obj.type == 'MESH')):
row.active = False
if not item.id_data.use_relative:
@@ -517,7 +518,6 @@ class DATA_PT_remesh(MeshButtonsPanel, Panel):
col.prop(mesh, "remesh_voxel_size")
col.prop(mesh, "remesh_voxel_adaptivity")
col.prop(mesh, "use_remesh_fix_poles")
- col.prop(mesh, "use_remesh_smooth_normals")
col = layout.column(heading="Preserve")
col.prop(mesh, "use_remesh_preserve_volume", text="Volume")
@@ -567,6 +567,89 @@ class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, Panel):
_property_type = bpy.types.Mesh
+class MESH_UL_attributes(UIList):
+ display_domain_names = {
+ 'POINT': "Vertex",
+ 'EDGE': "Edge",
+ 'FACE': "Face",
+ 'CORNER': "Face Corner",
+ }
+
+ def draw_item(self, _context, layout, _data, attribute, _icon, _active_data, _active_propname, _index):
+ data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type]
+
+ domain_name = self.display_domain_names.get(attribute.domain, "")
+
+ split = layout.split(factor=0.50)
+ split.emboss = 'NONE'
+ split.prop(attribute, "name", text="")
+ sub = split.row()
+ sub.alignment = 'RIGHT'
+ sub.active = False
+ sub.label(text="%s â–¶ %s" % (domain_name, data_type.name))
+
+
+class DATA_PT_mesh_attributes(MeshButtonsPanel, Panel):
+ bl_label = "Attributes"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
+
+ def draw(self, context):
+ mesh = context.mesh
+
+ layout = self.layout
+ row = layout.row()
+
+ col = row.column()
+ col.template_list(
+ "MESH_UL_attributes",
+ "attributes",
+ mesh,
+ "attributes",
+ mesh.attributes,
+ "active_index",
+ rows=3,
+ )
+
+ col = row.column(align=True)
+ col.operator("geometry.attribute_add", icon='ADD', text="")
+ col.operator("geometry.attribute_remove", icon='REMOVE', text="")
+
+ self.draw_attribute_warnings(context, layout)
+
+ def draw_attribute_warnings(self, context, layout):
+ attributes_by_name = defaultdict(list)
+
+ ob = context.object
+ mesh = ob.data
+
+ builtin_attribute = object()
+
+ def add_builtin(name):
+ attributes_by_name[name].append(builtin_attribute)
+
+ def add_attributes(layers):
+ for layer in layers:
+ attributes_by_name[layer.name].append(layer)
+
+ add_builtin("position")
+ add_builtin("material_index")
+ add_builtin("shade_smooth")
+ add_builtin("normal")
+ add_builtin("crease")
+
+ add_attributes(mesh.attributes)
+ add_attributes(mesh.uv_layers)
+ add_attributes(mesh.vertex_colors)
+ add_attributes(ob.vertex_groups)
+
+ colliding_names = [name for name, layers in attributes_by_name.items() if len(layers) >= 2]
+ if len(colliding_names) == 0:
+ return
+
+ layout.label(text="Name Collisions: {}".format(", ".join(colliding_names)), icon='INFO')
+
+
classes = (
MESH_MT_vertex_group_context_menu,
MESH_MT_shape_key_context_menu,
@@ -575,6 +658,7 @@ classes = (
MESH_UL_shape_keys,
MESH_UL_uvmaps,
MESH_UL_vcols,
+ MESH_UL_attributes,
DATA_PT_context_mesh,
DATA_PT_vertex_groups,
DATA_PT_shape_keys,
@@ -582,6 +666,7 @@ classes = (
DATA_PT_vertex_colors,
DATA_PT_sculpt_vertex_colors,
DATA_PT_face_maps,
+ DATA_PT_mesh_attributes,
DATA_PT_normals,
DATA_PT_texture_space,
DATA_PT_remesh,
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index 6c7837237e4..5df58f8ac4c 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -291,12 +291,18 @@ class MATERIAL_PT_lineart(MaterialButtonsPanel, Panel):
mat = context.material
lineart = mat.lineart
- layout.prop(lineart, "use_transparency")
+ layout.prop(lineart, "use_material_mask")
row = layout.row(align=True, heading="Masks")
- row.active = lineart.use_transparency
- for i in range(6):
- row.prop(lineart, "use_transparency_mask", text=str(i), index=i, toggle=True)
+ row.active = lineart.use_material_mask
+ for i in range(8):
+ row.prop(lineart, "use_material_mask_bits", text=str(i), index=i, toggle=True)
+
+ row = layout.row(align=True, heading="Custom Occlusion")
+ row.prop(lineart, "use_mat_occlusion", text="")
+ sub = row.row(align=False)
+ sub.active = lineart.use_mat_occlusion
+ sub.prop(lineart, "mat_occlusion", slider=True, text="Levels")
row = layout.row(align=True, heading="Custom occlusion effectiveness")
row.active = lineart.use_occlusion_effectiveness
diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py
index 6eafa570f4c..7a694108e14 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -370,6 +370,10 @@ class OUTLINER_PT_filter(Panel):
col = layout.column(align=True)
row = col.row()
+ row.label(icon='RENDERLAYERS')
+ row.prop(space, "use_filter_view_layers", text="All View Layers")
+
+ row = col.row()
row.label(icon='OUTLINER_COLLECTION')
row.prop(space, "use_filter_collection", text="Collections")
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 13a8e46e2b8..99384ac713d 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -162,6 +162,14 @@ class SEQUENCER_HT_header(Header):
if tool_settings.use_proportional_edit:
row.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
+ if st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}:
+ tool_settings = context.tool_settings
+ row = layout.row(align=True)
+ row.prop(tool_settings, "use_snap_sequencer", text="")
+ sub = row.row(align=True)
+ sub.popover(panel="SEQUENCER_PT_snapping")
+ layout.separator_spacer()
+
row = layout.row(align=True)
row.prop(st, "show_strip_overlay", text="", icon='OVERLAY')
sub = row.row(align=True)
@@ -2264,6 +2272,28 @@ class SEQUENCER_PT_custom_props(SequencerButtonsPanel, PropertyPanel, Panel):
bl_category = "Strip"
+class SEQUENCER_PT_snapping(Panel):
+ bl_space_type = 'SEQUENCE_EDITOR'
+ bl_region_type = 'HEADER'
+ bl_label = ""
+
+ def draw(self, context):
+ tool_settings = context.tool_settings
+ sequencer_tool_settings = tool_settings.sequencer_tool_settings
+
+ layout = self.layout
+ layout.use_property_split = True
+ layout.use_property_decorate = False
+
+ col = layout.column(heading="Snap to", align=True)
+ col.prop(sequencer_tool_settings, "snap_to_current_frame" )
+ col.prop(sequencer_tool_settings, "snap_to_hold_offset")
+
+ col = layout.column(heading="Ignore", align=True)
+ col.prop(sequencer_tool_settings, "snap_ignore_muted", text="Muted Strips")
+ col.prop(sequencer_tool_settings, "snap_ignore_sound",text="Sound Strips")
+
+
classes = (
SEQUENCER_MT_change,
SEQUENCER_HT_tool_header,
@@ -2333,6 +2363,8 @@ classes = (
SEQUENCER_PT_annotation,
SEQUENCER_PT_annotation_onion,
+
+ SEQUENCER_PT_snapping,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/space_spreadsheet.py b/release/scripts/startup/bl_ui/space_spreadsheet.py
index 360849a0c7a..178be9ef0b7 100644
--- a/release/scripts/startup/bl_ui/space_spreadsheet.py
+++ b/release/scripts/startup/bl_ui/space_spreadsheet.py
@@ -41,10 +41,6 @@ class SPREADSHEET_HT_header(bpy.types.Header):
return
layout.prop(space, "object_eval_state", text="")
- if space.object_eval_state != 'ORIGINAL':
- layout.prop(space, "geometry_component_type", text="")
- if space.geometry_component_type != 'INSTANCES':
- layout.prop(space, "attribute_domain", text="")
context_path = space.context_path
if space.object_eval_state == 'ORIGINAL':
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index bc66725b7fd..80cede9ee5a 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -2530,7 +2530,7 @@ class VIEW3D_MT_object_context_menu(Menu):
layout.operator_menu_enum("gpencil.convert", "type", text="Convert To")
if (
- obj.type in {'MESH', 'CURVE', 'SURFACE', 'GPENCIL', 'LATTICE', 'ARMATURE', 'META'} or
+ obj.type in {'MESH', 'CURVE', 'SURFACE', 'GPENCIL', 'LATTICE', 'ARMATURE', 'META', 'FONT'} or
(obj.type == 'EMPTY' and obj.instance_collection is not None)
):
layout.operator_context = 'INVOKE_REGION_WIN'
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 89bb2005f53..bc385faf378 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -832,7 +832,6 @@ class VIEW3D_PT_sculpt_voxel_remesh(Panel, View3DPaintPanel):
props.mode = 'VOXEL'
col.prop(mesh, "remesh_voxel_adaptivity")
col.prop(mesh, "use_remesh_fix_poles")
- col.prop(mesh, "use_remesh_smooth_normals")
col = layout.column(heading="Preserve", align=True)
col.prop(mesh, "use_remesh_preserve_volume", text="Volume")
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index e7d991622e8..c85d7a9db04 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -509,6 +509,13 @@ geometry_node_categories = [
NodeItem("GeometryNodeCurveLength"),
NodeItem("GeometryNodeCurveReverse"),
]),
+ GeometryNodeCategory("GEO_PRIMITIVES_CURVE", "Curve Primitives", items=[
+ NodeItem("GeometryNodeCurvePrimitiveCircle"),
+ NodeItem("GeometryNodeCurveStar"),
+ NodeItem("GeometryNodeCurveSpiral"),
+ NodeItem("GeometryNodeCurveQuadraticBezier"),
+ NodeItem("GeometryNodeCurvePrimitiveBezierSegment"),
+ ]),
GeometryNodeCategory("GEO_GEOMETRY", "Geometry", items=[
NodeItem("GeometryNodeBoundBox"),
NodeItem("GeometryNodeConvexHull"),
@@ -540,7 +547,7 @@ geometry_node_categories = [
NodeItem("GeometryNodeSubdivisionSurface"),
NodeItem("GeometryNodeSubdivide"),
]),
- GeometryNodeCategory("GEO_PRIMITIVES", "Mesh Primitives", items=[
+ GeometryNodeCategory("GEO_PRIMITIVES_MESH", "Mesh Primitives", items=[
NodeItem("GeometryNodeMeshCircle"),
NodeItem("GeometryNodeMeshCone"),
NodeItem("GeometryNodeMeshCube"),
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 4d483934717..7428798581d 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -206,7 +206,7 @@ int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size)
{
int i = blf_search(name);
if (i >= 0) {
- /*font = global_font[i];*/ /*UNUSED*/
+ // font = global_font[i]; /* UNUSED */
return i;
}
return BLF_load_mem_unique(name, mem, mem_size);
diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h
index ada772c53d2..63e1eb999cd 100644
--- a/source/blender/blenfont/intern/blf_internal.h
+++ b/source/blender/blenfont/intern/blf_internal.h
@@ -38,7 +38,7 @@ unsigned int blf_hash(unsigned int val);
char *blf_dir_search(const char *file);
char *blf_dir_metrics_search(const char *filename);
-/* int blf_dir_split(const char *str, char *file, int *size); */ /* UNUSED */
+/* int blf_dir_split(const char *str, char *file, int *size); */ /* UNUSED */
int blf_font_init(void);
void blf_font_exit(void);
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 7d553b68185..684296381eb 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -329,7 +329,7 @@ void DM_copy_vert_data(struct DerivedMesh *source,
int dest_index,
int count);
-/*sets up mpolys for a DM based on face iterators in source*/
+/* Sets up mpolys for a DM based on face iterators in source. */
void DM_DupPolys(DerivedMesh *source, DerivedMesh *target);
void DM_ensure_normals(DerivedMesh *dm);
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 3d81fcba37d..9f69c5e3976 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -108,7 +108,7 @@ void action_group_colors_sync(struct bActionGroup *grp, const struct bActionGrou
/* Add a new action group with the given name to the action */
struct bActionGroup *action_groups_add_new(struct bAction *act, const char name[]);
-/* Add given channel into (active) group */
+/* Add given channel into (active) group */
void action_groups_add_channel(struct bAction *act,
struct bActionGroup *agrp,
struct FCurve *fcurve);
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index d43332ae1ac..030560015a9 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -242,7 +242,7 @@ bool BKE_animsys_rna_path_resolve(struct PointerRNA *ptr,
bool BKE_animsys_read_from_rna_path(struct PathResolvedRNA *anim_rna, float *r_value);
bool BKE_animsys_write_to_rna_path(struct PathResolvedRNA *anim_rna, const float value);
-/* Evaluation loop for evaluating animation data */
+/* Evaluation loop for evaluating animation data. */
void BKE_animsys_evaluate_animdata(struct ID *id,
struct AnimData *adt,
const struct AnimationEvalContext *anim_eval_context,
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 112b8bf3ad4..86aa18e5739 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -49,24 +49,30 @@ typedef struct EditBone {
struct EditBone *next, *prev;
/** User-Defined Properties on this Bone */
struct IDProperty *prop;
- /** Editbones have a one-way link (i.e. children refer
+ /**
+ * Editbones have a one-way link (i.e. children refer
* to parents. This is converted to a two-way link for
- * normal bones when leaving editmode. */
+ * normal bones when leaving editmode.
+ */
struct EditBone *parent;
/** (64 == MAXBONENAME) */
char name[64];
- /** Roll along axis. We'll ultimately use the axis/angle method
+ /**
+ * Roll along axis. We'll ultimately use the axis/angle method
* for determining the transformation matrix of the bone. The axis
* is tail-head while roll provides the angle. Refer to Graphics
- * Gems 1 p. 466 (section IX.6) if it's not already in here somewhere*/
+ * Gems 1 p. 466 (section IX.6) if it's not already in here somewhere.
+ */
float roll;
/** Orientation and length is implicit during editing */
float head[3];
float tail[3];
- /** All joints are considered to have zero rotation with respect to
+ /**
+ * All joints are considered to have zero rotation with respect to
* their parents. Therefore any rotations specified during the
- * animation are automatically relative to the bones' rest positions*/
+ * animation are automatically relative to the bones' rest positions.
+ */
int flag;
int layer;
char inherit_scale_mode;
@@ -145,7 +151,7 @@ typedef struct PoseTree {
struct bArmature *BKE_armature_add(struct Main *bmain, const char *name);
struct bArmature *BKE_armature_from_object(struct Object *ob);
-int BKE_armature_bonelist_count(struct ListBase *lb);
+int BKE_armature_bonelist_count(const struct ListBase *lb);
void BKE_armature_bonelist_free(struct ListBase *lb, const bool do_id_user);
void BKE_armature_editbonelist_free(struct ListBase *lb, const bool do_id_user);
diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h
index 30a595dba8e..6a1f1feb14f 100644
--- a/source/blender/blenkernel/BKE_attribute.h
+++ b/source/blender/blenkernel/BKE_attribute.h
@@ -38,12 +38,16 @@ struct ID;
struct ReportList;
/* Attribute.domain */
+/**
+ * \warning: Careful when changing existing items. Arrays may be initialized from this (e.g.
+ * #DATASET_layout_hierarchy).
+ */
typedef enum AttributeDomain {
ATTR_DOMAIN_AUTO = -1, /* Use for nodes to choose automatically based on other data. */
ATTR_DOMAIN_POINT = 0, /* Mesh, Hair or PointCloud Point */
ATTR_DOMAIN_EDGE = 1, /* Mesh Edge */
- ATTR_DOMAIN_CORNER = 2, /* Mesh Corner */
- ATTR_DOMAIN_FACE = 3, /* Mesh Face */
+ ATTR_DOMAIN_FACE = 2, /* Mesh Face */
+ ATTR_DOMAIN_CORNER = 3, /* Mesh Corner */
ATTR_DOMAIN_CURVE = 4, /* Hair Curve */
ATTR_DOMAIN_NUM
diff --git a/source/blender/blenkernel/BKE_attribute_math.hh b/source/blender/blenkernel/BKE_attribute_math.hh
index ba683362e69..2ce41e95b65 100644
--- a/source/blender/blenkernel/BKE_attribute_math.hh
+++ b/source/blender/blenkernel/BKE_attribute_math.hh
@@ -306,7 +306,7 @@ template<> struct DefaultMixerStruct<float3> {
};
template<> struct DefaultMixerStruct<ColorGeometry4f> {
/* Use a special mixer for colors. ColorGeometry4f can't be added/multiplied, because this is not
- * something one should usually do with colors. */
+ * something one should usually do with colors. */
using type = ColorGeometryMixer;
};
template<> struct DefaultMixerStruct<int> {
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 1767077fa45..d5baeb08ccc 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 4
+#define BLENDER_FILE_SUBVERSION 7
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h
index 429e294a337..3e0a343a766 100644
--- a/source/blender/blenkernel/BKE_blendfile.h
+++ b/source/blender/blenkernel/BKE_blendfile.h
@@ -25,6 +25,7 @@ extern "C" {
struct BlendFileData;
struct BlendFileReadParams;
+struct BlendFileReadReport;
struct ID;
struct Main;
struct MemFile;
@@ -35,7 +36,7 @@ struct bContext;
void BKE_blendfile_read_setup_ex(struct bContext *C,
struct BlendFileData *bfd,
const struct BlendFileReadParams *params,
- struct ReportList *reports,
+ struct BlendFileReadReport *reports,
/* Extra args. */
const bool startup_update_defaults,
const char *startup_app_template);
@@ -43,11 +44,11 @@ void BKE_blendfile_read_setup_ex(struct bContext *C,
void BKE_blendfile_read_setup(struct bContext *C,
struct BlendFileData *bfd,
const struct BlendFileReadParams *params,
- struct ReportList *reports);
+ struct BlendFileReadReport *reports);
struct BlendFileData *BKE_blendfile_read(const char *filepath,
const struct BlendFileReadParams *params,
- struct ReportList *reports);
+ struct BlendFileReadReport *reports);
struct BlendFileData *BKE_blendfile_read_from_memory(const void *filebuf,
int filelength,
diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h
index 78908908343..8be2fcbdb83 100644
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@ -218,7 +218,7 @@ BVHTree *bvhtree_from_mesh_looptri_ex(struct BVHTreeFromMesh *data,
ThreadMutex *mesh_eval_mutex);
BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
- struct Mesh *mesh,
+ const struct Mesh *mesh,
const BVHCacheType bvh_cache_type,
const int tree_type);
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 04fcdd6ed6f..a0e3d5dc142 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -103,11 +103,11 @@ typedef struct Cloth {
* The definition of a cloth vertex.
*/
typedef struct ClothVertex {
- int flags; /* General flags per vertex. */
- float v[3]; /* The velocity of the point. */
+ int flags; /* General flags per vertex. */
+ float v[3]; /* The velocity of the point. */
float xconst[3]; /* constrained position */
float x[3]; /* The current position of this vertex. */
- float xold[3]; /* The previous position of this vertex.*/
+ float xold[3]; /* The previous position of this vertex. */
float tx[3]; /* temporary position */
float txold[3]; /* temporary old position */
float tv[3]; /* temporary "velocity", mostly used as tv = tx-txold */
@@ -194,7 +194,7 @@ typedef struct ClothSpring {
} \
((void)0)
-/* Spring types as defined in the paper.*/
+/* Spring types as defined in the paper. */
typedef enum {
CLOTH_SPRING_TYPE_STRUCTURAL = (1 << 1),
CLOTH_SPRING_TYPE_SHEAR = (1 << 2),
diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index 7963d54126e..f47cdf32ca0 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -164,7 +164,8 @@ bool BKE_collection_move(struct Main *bmain,
bool BKE_collection_cycle_find(struct Collection *new_ancestor, struct Collection *collection);
bool BKE_collection_cycles_fix(struct Main *bmain, struct Collection *collection);
-bool BKE_collection_has_collection(struct Collection *parent, struct Collection *collection);
+bool BKE_collection_has_collection(const struct Collection *parent,
+ const struct Collection *collection);
void BKE_collection_parent_relations_rebuild(struct Collection *collection);
void BKE_main_collections_parent_relations_rebuild(struct Main *bmain);
diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h
index ff1bca896b1..2c21b7355d6 100644
--- a/source/blender/blenkernel/BKE_collision.h
+++ b/source/blender/blenkernel/BKE_collision.h
@@ -63,7 +63,7 @@ typedef struct CollPair {
float time; /* collision time, from 0 up to 1 */
/* mesh-mesh collision */
-#ifdef WITH_ELTOPO /*either ap* or bp* can be set, but not both*/
+#ifdef WITH_ELTOPO /* Either ap* or bp* can be set, but not both. */
float bary[3];
int ap1, ap2, ap3, collp, bp1, bp2, bp3;
int collface;
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index afad1e26159..575df93a9fc 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -59,7 +59,7 @@ typedef struct bConstraintOb {
/** space matrix for custom object space */
float space_obj_world_matrix[4][4];
- /** type of owner */
+ /** type of owner. */
short type;
/** rotation order for constraint owner (as defined in eEulerRotationOrders in BLI_math.h) */
short rotOrder;
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 2687a5ea16c..c7c5f59cab2 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -121,6 +121,7 @@ void BKE_curve_material_remap(struct Curve *cu, const unsigned int *remap, unsig
void BKE_curve_smooth_flag_set(struct Curve *cu, const bool use_smooth);
ListBase *BKE_curve_nurbs_get(struct Curve *cu);
+const ListBase *BKE_curve_nurbs_get_for_read(const struct Curve *cu);
int BKE_curve_nurb_vert_index_get(const struct Nurb *nu, const void *vert);
void BKE_curve_nurb_active_set(struct Curve *cu, const struct Nurb *nu);
@@ -153,9 +154,10 @@ void BKE_curve_editNurb_keyIndex_delCV(struct GHash *keyindex, const void *cv);
void BKE_curve_editNurb_keyIndex_free(struct GHash **keyindex);
void BKE_curve_editNurb_free(struct Curve *cu);
struct ListBase *BKE_curve_editNurbs_get(struct Curve *cu);
+const struct ListBase *BKE_curve_editNurbs_get_for_read(const struct Curve *cu);
void BKE_curve_bevelList_free(struct ListBase *bev);
-void BKE_curve_bevelList_make(struct Object *ob, struct ListBase *nurbs, bool for_render);
+void BKE_curve_bevelList_make(struct Object *ob, const struct ListBase *nurbs, bool for_render);
ListBase BKE_curve_bevel_make(const struct Curve *curve);
void BKE_curve_forward_diff_bezier(
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index ed319948160..c4db8ee925e 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -41,7 +41,7 @@ struct CustomData_MeshMasks;
struct ID;
typedef uint64_t CustomDataMask;
-/*a data type large enough to hold 1 element from any customdata layer type*/
+/* A data type large enough to hold 1 element from any custom-data layer type. */
typedef struct {
unsigned char data[64];
} CDBlockBytes;
@@ -109,9 +109,9 @@ bool CustomData_bmesh_has_free(const struct CustomData *data);
*/
bool CustomData_has_referenced(const struct CustomData *data);
-/* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to
+/* Copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to
* another, while not overwriting anything else (e.g. flags). probably only
- * implemented for mloopuv/mloopcol, for now.*/
+ * 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.
@@ -121,7 +121,7 @@ void CustomData_data_mix_value(
/* compares if data1 is equal to data2. type is a valid CustomData type
* enum (e.g. CD_MLOOPUV). the layer type's equal function is used to compare
- * the data, if it exists, otherwise memcmp is used.*/
+ * the data, if it exists, otherwise memcmp is used. */
bool CustomData_data_equals(int type, const void *data1, const void *data2);
void CustomData_data_initminmax(int type, void *min, void *max);
void CustomData_data_dominmax(int type, const void *data, void *min, void *max);
@@ -158,7 +158,7 @@ void CustomData_realloc(struct CustomData *data, int totelem);
/* bmesh version of CustomData_merge; merges the layouts of source and dest,
* then goes through the mesh and makes sure all the customdata blocks are
- * consistent with the new layout.*/
+ * consistent with the new layout. */
bool CustomData_bmesh_merge(const struct CustomData *source,
struct CustomData *dest,
CustomDataMask mask,
@@ -186,7 +186,7 @@ void CustomData_free_temporary(struct CustomData *data, int totelem);
*/
void *CustomData_add_layer(
struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem);
-/*same as above but accepts a name */
+/* Same as above but accepts a name. */
void *CustomData_add_layer_named(struct CustomData *data,
int type,
eCDAllocType alloctype,
@@ -233,6 +233,9 @@ void *CustomData_duplicate_referenced_layer_named(struct CustomData *data,
const int totelem);
bool CustomData_is_referenced_layer(struct CustomData *data, int type);
+/* Duplicate all the layers with flag NOFREE, and remove the flag from duplicated layers. */
+void CustomData_duplicate_referenced_layers(CustomData *data, int totelem);
+
/* set the CD_FLAG_NOCOPY flag in custom data layers where the mask is
* zero for the layer type, so only layer types specified by the mask
* will be copied
@@ -443,7 +446,7 @@ void CustomData_validate_layer_name(const struct CustomData *data,
* only after this test passes, layer->data should be assigned */
bool CustomData_verify_versions(struct CustomData *data, int index);
-/*BMesh specific customdata stuff*/
+/* BMesh specific custom-data stuff. */
void CustomData_to_bmeshpoly(struct CustomData *fdata, struct CustomData *ldata, int totloop);
void CustomData_from_bmeshpoly(struct CustomData *fdata, struct CustomData *ldata, int total);
void CustomData_bmesh_update_active_layers(struct CustomData *fdata, struct CustomData *ldata);
@@ -536,7 +539,7 @@ enum {
CDT_MIX_ADD = 17,
CDT_MIX_SUB = 18,
CDT_MIX_MUL = 19,
- /* etc. etc. */
+ /* Etc. */
};
typedef struct CustomDataTransferLayerMap {
diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h
index a2d9bbcd011..0f37ba6c4ce 100644
--- a/source/blender/blenkernel/BKE_displist.h
+++ b/source/blender/blenkernel/BKE_displist.h
@@ -32,11 +32,11 @@ extern "C" {
/** #DispList.type */
enum {
- /** A closed polygon (that can be filled). */
+ /** A closed polygon (that can be filled). */
DL_POLY = 0,
- /** An open polygon. */
+ /** An open polygon. */
DL_SEGM = 1,
- /** A grid surface that respects #DL_CYCL_U & #DL_CYCL_V. */
+ /** A grid surface that respects #DL_CYCL_U & #DL_CYCL_V. */
DL_SURF = 2,
/** Triangles. */
DL_INDEX3 = 4,
@@ -87,13 +87,11 @@ bool BKE_displist_has_faces(const struct ListBase *lb);
void BKE_displist_make_curveTypes(struct Depsgraph *depsgraph,
const struct Scene *scene,
struct Object *ob,
- const bool for_render,
- const bool for_orco);
+ const bool for_render);
void BKE_displist_make_curveTypes_forRender(struct Depsgraph *depsgraph,
const struct Scene *scene,
struct Object *ob,
struct ListBase *dispbase,
- const bool for_orco,
struct Mesh **r_final);
void BKE_displist_make_mball(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
void BKE_displist_make_mball_forRender(struct Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/BKE_editmesh.h b/source/blender/blenkernel/BKE_editmesh.h
index 075a9bc0eac..e31a0a16408 100644
--- a/source/blender/blenkernel/BKE_editmesh.h
+++ b/source/blender/blenkernel/BKE_editmesh.h
@@ -53,12 +53,12 @@ struct Scene;
typedef struct BMEditMesh {
struct BMesh *bm;
- /*this is for undoing failed operations*/
+ /* This is for undoing failed operations. */
struct BMEditMesh *emcopy;
int emcopyusers;
/* we store tessellations as triplets of three loops,
- * which each define a triangle.*/
+ * which each define a triangle. */
struct BMLoop *(*looptris)[3];
int tottri;
@@ -67,14 +67,14 @@ typedef struct BMEditMesh {
/** Cached cage bounding box for selection. */
struct BoundBox *bb_cage;
- /*derivedmesh stuff*/
+ /** Evaluated mesh data-mask. */
CustomData_MeshMasks lastDataMask;
- /*selection mode*/
+ /* Selection mode. */
short selectmode;
short mat_nr;
- /*temp variables for x-mirror editing*/
+ /* Temp variables for x-mirror editing. */
int mirror_cdlayer; /* -1 is invalid */
/**
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index 231a4563630..3a964ddb1aa 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -179,7 +179,7 @@ unsigned int BKE_sim_debug_data_hash(int i);
unsigned int BKE_sim_debug_data_hash_combine(unsigned int kx, unsigned int ky);
/* _VA_SIM_DEBUG_HASH#(i, ...): combined hash value of multiple integers */
-/* internal helpers*/
+/* Internal helpers. */
#define _VA_SIM_DEBUG_HASH1(a) (BKE_sim_debug_data_hash(a))
#define _VA_SIM_DEBUG_HASH2(a, b) \
(BKE_sim_debug_data_hash_combine(BKE_sim_debug_data_hash(a), _VA_SIM_DEBUG_HASH1(b)))
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 589d1839dd4..f494c2e30cc 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -180,7 +180,7 @@ int BKE_fcm_envelope_find_index(struct FCM_EnvelopeData *array,
* but should become userpref */
#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */
-/* -------- Data Management -------- */
+/* -------- Data Management -------- */
struct FCurve *BKE_fcurve_create(void);
void BKE_fcurve_free(struct FCurve *fcu);
struct FCurve *BKE_fcurve_copy(const struct FCurve *fcu);
@@ -227,9 +227,9 @@ struct FCurve *BKE_fcurve_find_by_rna_context_ui(struct bContext *C,
/* Binary search algorithm for finding where to 'insert' BezTriple with given frame number.
* Returns the index to insert at (data already at that index will be offset if replace is 0)
*/
-int BKE_fcurve_bezt_binarysearch_index(struct BezTriple array[],
- float frame,
- int arraylen,
+int BKE_fcurve_bezt_binarysearch_index(const struct BezTriple array[],
+ const float frame,
+ const int arraylen,
bool *r_replace);
/* fcurve_cache.c */
@@ -302,7 +302,7 @@ bool BKE_fcurve_bezt_subdivide_handles(struct BezTriple *bezt,
struct BezTriple *next,
float *r_pdelta);
-/* -------- Curve Sanity -------- */
+/* -------- Curve Sanity -------- */
void calchandles_fcurve(struct FCurve *fcu);
void calchandles_fcurve_ex(struct FCurve *fcu, eBezTriple_Flag handle_sel_flag);
@@ -312,7 +312,7 @@ bool test_time_fcurve(struct FCurve *fcu);
void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2]);
-/* -------- Evaluation -------- */
+/* -------- Evaluation -------- */
/* evaluate fcurve */
float evaluate_fcurve(struct FCurve *fcu, float evaltime);
@@ -329,7 +329,7 @@ float calculate_fcurve(struct PathResolvedRNA *anim_rna,
/* ************* F-Curve Samples API ******************** */
-/* -------- Defines -------- */
+/* -------- Defines -------- */
/* Basic signature for F-Curve sample-creation function
* - fcu: the F-Curve being operated on
@@ -337,12 +337,12 @@ float calculate_fcurve(struct PathResolvedRNA *anim_rna,
*/
typedef float (*FcuSampleFunc)(struct FCurve *fcu, void *data, float evaltime);
-/* ----- Sampling Callbacks ------ */
+/* ----- Sampling Callbacks ------ */
/* Basic sampling callback which acts as a wrapper for evaluate_fcurve() */
float fcurve_samplingcb_evalcurve(struct FCurve *fcu, void *data, float evaltime);
-/* -------- Main Methods -------- */
+/* -------- Main Methods -------- */
/* Main API function for creating a set of sampled curve data, given some callback function
* used to retrieve the values to store.
diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index b23ccbe25ff..522d3843bb2 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -66,8 +66,8 @@ typedef struct EditFont {
} EditFont;
-bool BKE_vfont_is_builtin(struct VFont *vfont);
-void BKE_vfont_builtin_register(void *mem, int size);
+bool BKE_vfont_is_builtin(const struct VFont *vfont);
+void BKE_vfont_builtin_register(const void *mem, int size);
void BKE_vfont_free_data(struct VFont *vfont);
struct VFont *BKE_vfont_builtin_get(void);
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index b2342a5fd96..82c9a31dfce 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -280,8 +280,6 @@ struct GeometrySet {
void compute_boundbox_without_instances(blender::float3 *r_min, blender::float3 *r_max) const;
friend std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set);
- friend bool operator==(const GeometrySet &a, const GeometrySet &b);
- uint64_t hash() const;
void clear();
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 74f2bf7c6ad..69c950a86dc 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -149,7 +149,7 @@ enum {
G_DEBUG_DEPSGRAPH_TIME | G_DEBUG_DEPSGRAPH_UUID),
G_DEBUG_SIMDATA = (1 << 15), /* sim debug data display */
G_DEBUG_GPU = (1 << 16), /* gpu debug */
- G_DEBUG_IO = (1 << 17), /* IO Debugging (for Collada, ...)*/
+ G_DEBUG_IO = (1 << 17), /* IO Debugging (for Collada, ...). */
G_DEBUG_GPU_FORCE_WORKAROUNDS = (1 << 18), /* force gpu workarounds bypassing detections. */
G_DEBUG_XR = (1 << 19), /* XR/OpenXR messages */
G_DEBUG_XR_TIME = (1 << 20), /* XR/OpenXR timing messages */
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index d0a1f102a43..657e66729e1 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -214,6 +214,10 @@ void BKE_gpencil_layer_mask_remove_ref(struct bGPdata *gpd, const char *name);
struct bGPDlayer_Mask *BKE_gpencil_layer_mask_named_get(struct bGPDlayer *gpl, const char *name);
void BKE_gpencil_layer_mask_sort(struct bGPdata *gpd, struct bGPDlayer *gpl);
void BKE_gpencil_layer_mask_sort_all(struct bGPdata *gpd);
+void BKE_gpencil_layer_mask_copy(const struct bGPDlayer *gpl_src, struct bGPDlayer *gpl_dst);
+void BKE_gpencil_layer_mask_cleanup(struct bGPdata *gpd, struct bGPDlayer *gpl);
+void BKE_gpencil_layer_mask_cleanup_all_layers(struct bGPdata *gpd);
+
void BKE_gpencil_layer_frames_sort(struct bGPDlayer *gpl, bool *r_has_duplicate_frames);
struct bGPDlayer *BKE_gpencil_layer_get_by_name(struct bGPdata *gpd,
diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h b/source/blender/blenkernel/BKE_gpencil_geom.h
index 8fc3ce133a0..c1ccae7a437 100644
--- a/source/blender/blenkernel/BKE_gpencil_geom.h
+++ b/source/blender/blenkernel/BKE_gpencil_geom.h
@@ -90,7 +90,7 @@ typedef struct GPencilPointCoordinates {
float pressure;
} GPencilPointCoordinates;
-int BKE_gpencil_stroke_point_count(struct bGPdata *gpd);
+int BKE_gpencil_stroke_point_count(const struct bGPdata *gpd);
void BKE_gpencil_point_coords_get(struct bGPdata *gpd, GPencilPointCoordinates *elem_data);
void BKE_gpencil_point_coords_apply(struct bGPdata *gpd, const GPencilPointCoordinates *elem_data);
void BKE_gpencil_point_coords_apply_with_mat4(struct bGPdata *gpd,
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h
index bcf35bf1197..a5cb6489194 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -67,7 +67,7 @@ void IDP_AppendArray(struct IDProperty *prop, struct IDProperty *item);
void IDP_ResizeIDPArray(struct IDProperty *prop, int len);
/* ----------- Numeric Array Type ----------- */
-/*this function works for strings too!*/
+/* This function works for strings too! */
void IDP_ResizeArray(struct IDProperty *prop, int newlen);
void IDP_FreeArray(struct IDProperty *prop);
diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h
index 4578f1c3ca5..28171b2b363 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -82,8 +82,8 @@ typedef void (*IDTypeMakeLocalFunction)(struct Main *bmain, struct ID *id, const
typedef void (*IDTypeForeachIDFunction)(struct ID *id, struct LibraryForeachIDData *data);
typedef enum eIDTypeInfoCacheCallbackFlags {
- /** Indicates to the callback that that cache may be stored in the .blend file, so its pointer
- * should not be cleared at read-time. */
+ /** Indicates to the callback that cache may be stored in the .blend file,
+ * so its pointer should not be cleared at read-time. */
IDTYPE_CACHE_CB_FLAGS_PERSISTENT = 1 << 0,
} eIDTypeInfoCacheCallbackFlags;
typedef void (*IDTypeForeachCacheFunctionCallback)(struct ID *id,
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index c969ce07d74..58b8d19abaa 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -76,7 +76,7 @@ void BKE_keyblock_update_from_lattice(struct Lattice *lt, struct KeyBlock *kb);
void BKE_keyblock_convert_from_lattice(struct Lattice *lt, struct KeyBlock *kb);
void BKE_keyblock_convert_to_lattice(struct KeyBlock *kb, struct Lattice *lt);
-int BKE_keyblock_curve_element_count(struct ListBase *nurb);
+int BKE_keyblock_curve_element_count(const struct ListBase *nurb);
void BKE_keyblock_curve_data_transform(const struct ListBase *nurb,
const float mat[4][4],
const void *src,
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 240d6cb18ec..404f344919c 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -92,7 +92,7 @@ bool BKE_layer_collection_activate(struct ViewLayer *view_layer, struct LayerCol
struct LayerCollection *BKE_layer_collection_activate_parent(struct ViewLayer *view_layer,
struct LayerCollection *lc);
-int BKE_layer_collection_count(struct ViewLayer *view_layer);
+int BKE_layer_collection_count(const struct ViewLayer *view_layer);
struct LayerCollection *BKE_layer_collection_from_index(struct ViewLayer *view_layer,
const int index);
@@ -107,8 +107,8 @@ void BKE_layer_collection_local_sync_all(const struct Main *bmain);
void BKE_main_collection_sync_remap(const struct Main *bmain);
struct LayerCollection *BKE_layer_collection_first_from_scene_collection(
- struct ViewLayer *view_layer, const struct Collection *collection);
-bool BKE_view_layer_has_collection(struct ViewLayer *view_layer,
+ const struct ViewLayer *view_layer, const struct Collection *collection);
+bool BKE_view_layer_has_collection(const struct ViewLayer *view_layer,
const struct Collection *collection);
bool BKE_scene_has_object(struct Scene *scene, struct Object *ob);
@@ -367,7 +367,7 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
struct ObjectsInViewLayerParams {
uint no_dup_data : 1;
- bool (*filter_fn)(struct Object *ob, void *user_data);
+ bool (*filter_fn)(const struct Object *ob, void *user_data);
void *filter_userdata;
};
@@ -388,7 +388,7 @@ struct ObjectsInModeParams {
int object_mode;
uint no_dup_data : 1;
- bool (*filter_fn)(struct Object *ob, void *user_data);
+ bool (*filter_fn)(const struct Object *ob, void *user_data);
void *filter_userdata;
};
@@ -412,8 +412,8 @@ struct Object **BKE_view_layer_array_from_objects_in_mode_params(
BKE_view_layer_array_from_bases_in_mode_params( \
view_layer, v3d, r_len, &(const struct ObjectsInModeParams)__VA_ARGS__)
-bool BKE_view_layer_filter_edit_mesh_has_uvs(struct Object *ob, void *user_data);
-bool BKE_view_layer_filter_edit_mesh_has_edges(struct Object *ob, void *user_data);
+bool BKE_view_layer_filter_edit_mesh_has_uvs(const struct Object *ob, void *user_data);
+bool BKE_view_layer_filter_edit_mesh_has_edges(const struct Object *ob, void *user_data);
/* Utility macros that wrap common args (add more as needed). */
diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h
index e16507bf3cc..fac5dc8c010 100644
--- a/source/blender/blenkernel/BKE_lib_id.h
+++ b/source/blender/blenkernel/BKE_lib_id.h
@@ -315,6 +315,9 @@ void BKE_id_blend_write(struct BlendWriter *writer, struct ID *id);
#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT))
+/* lib_id_eval.c */
+void BKE_id_eval_properties_copy(struct ID *id_cow, struct ID *id);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_lib_override.h b/source/blender/blenkernel/BKE_lib_override.h
index 4dc99e64cf2..27076d908e7 100644
--- a/source/blender/blenkernel/BKE_lib_override.h
+++ b/source/blender/blenkernel/BKE_lib_override.h
@@ -43,6 +43,7 @@ extern "C" {
#endif
struct Collection;
+struct BlendFileReadReport;
struct ID;
struct IDOverrideLibrary;
struct IDOverrideLibraryProperty;
@@ -90,14 +91,16 @@ bool BKE_lib_override_library_resync(struct Main *bmain,
struct Collection *override_resync_residual_storage,
const bool do_hierarchy_enforce,
const bool do_post_process,
- struct ReportList *reports);
+ struct BlendFileReadReport *reports);
void BKE_lib_override_library_main_resync(struct Main *bmain,
struct Scene *scene,
struct ViewLayer *view_layer,
- struct ReportList *reports);
+ struct BlendFileReadReport *reports);
void BKE_lib_override_library_delete(struct Main *bmain, struct ID *id_root);
+void BKE_lib_override_library_make_local(struct ID *id);
+
struct IDOverrideLibraryProperty *BKE_lib_override_library_property_find(
struct IDOverrideLibrary *override, const char *rna_path);
struct IDOverrideLibraryProperty *BKE_lib_override_library_property_get(
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 8ddfb0c8eb2..8d76a025e87 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -128,7 +128,8 @@ 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. */
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);
+struct Mesh *BKE_mesh_new_nomain_from_curve_displist(const struct Object *ob,
+ const struct ListBase *dispbase);
bool BKE_mesh_ensure_facemap_customdata(struct Mesh *me);
bool BKE_mesh_clear_facemap_customdata(struct Mesh *me);
@@ -151,7 +152,7 @@ int BKE_mesh_nurbs_to_mdata(struct Object *ob,
struct MPoly **r_allpoly,
int *r_totloop,
int *r_totpoly);
-int BKE_mesh_nurbs_displist_to_mdata(struct Object *ob,
+int BKE_mesh_nurbs_displist_to_mdata(const struct Object *ob,
const struct ListBase *dispbase,
struct MVert **r_allvert,
int *r_totvert,
@@ -298,7 +299,7 @@ void BKE_mesh_recalc_looptri_with_normals(const struct MLoop *mloop,
struct MLoopTri *mlooptri,
const float (*poly_normals)[3]);
-/* *** mesh_evaluate.c *** */
+/* *** mesh_normals.c *** */
void BKE_mesh_calc_normals_mapping_simple(struct Mesh *me);
void BKE_mesh_calc_normals_mapping(struct MVert *mverts,
@@ -493,6 +494,8 @@ void BKE_mesh_calc_normals_split_ex(struct Mesh *mesh,
void BKE_mesh_set_custom_normals(struct Mesh *mesh, float (*r_custom_loopnors)[3]);
void BKE_mesh_set_custom_normals_from_vertices(struct Mesh *mesh, float (*r_custom_vertnors)[3]);
+/* *** mesh_evaluate.c *** */
+
void BKE_mesh_calc_poly_normal(const struct MPoly *mpoly,
const struct MLoop *loopstart,
const struct MVert *mvarray,
diff --git a/source/blender/blenkernel/BKE_mesh_remap.h b/source/blender/blenkernel/BKE_mesh_remap.h
index d9b6ab3813e..02f8af6443c 100644
--- a/source/blender/blenkernel/BKE_mesh_remap.h
+++ b/source/blender/blenkernel/BKE_mesh_remap.h
@@ -36,7 +36,7 @@ typedef struct MeshPairRemapItem {
int sources_num;
int *indices_src; /* NULL if no source found. */
float *weights_src; /* NULL if no source found, else, always normalized! */
- /* UNUSED (at the moment)*/
+ /* UNUSED (at the moment). */
// float hit_dist; /* FLT_MAX if irrelevant or no source found. */
int island; /* For loops only. */
} MeshPairRemapItem;
diff --git a/source/blender/blenkernel/BKE_mesh_runtime.h b/source/blender/blenkernel/BKE_mesh_runtime.h
index 67c87e96aff..3efbef94081 100644
--- a/source/blender/blenkernel/BKE_mesh_runtime.h
+++ b/source/blender/blenkernel/BKE_mesh_runtime.h
@@ -45,7 +45,7 @@ void BKE_mesh_runtime_reset(struct Mesh *mesh);
void BKE_mesh_runtime_reset_on_copy(struct Mesh *mesh, const int flag);
int BKE_mesh_runtime_looptri_len(const struct Mesh *mesh);
void BKE_mesh_runtime_looptri_recalc(struct Mesh *mesh);
-const struct MLoopTri *BKE_mesh_runtime_looptri_ensure(struct Mesh *mesh);
+const struct MLoopTri *BKE_mesh_runtime_looptri_ensure(const struct Mesh *mesh);
bool BKE_mesh_runtime_ensure_edit_data(struct Mesh *mesh);
bool BKE_mesh_runtime_clear_edit_data(struct Mesh *mesh);
bool BKE_mesh_runtime_reset_edit_data(struct Mesh *mesh);
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index fce25abba7f..11bfc4b2b3a 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -220,7 +220,7 @@ BLI_INLINE void BKE_multires_construct_tangent_matrix(float tangent_matrix[3][3]
/* Versioning. */
/* Convert displacement which is stored for simply-subdivided mesh to a Catmull-Clark
- * subdivided mesh. */
+ * subdivided mesh. */
void multires_do_versions_simple_to_catmull_clark(struct Object *object,
struct MultiresModifierData *mmd);
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index a0f6be6b3e9..3562a3e8d63 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1439,6 +1439,11 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
#define GEO_NODE_SEPARATE_COMPONENTS 1059
#define GEO_NODE_CURVE_SUBDIVIDE 1060
#define GEO_NODE_RAYCAST 1061
+#define GEO_NODE_CURVE_PRIMITIVE_STAR 1062
+#define GEO_NODE_CURVE_PRIMITIVE_SPIRAL 1063
+#define GEO_NODE_CURVE_PRIMITIVE_QUADRATIC_BEZIER 1064
+#define GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT 1065
+#define GEO_NODE_CURVE_PRIMITIVE_CIRCLE 1066
/** \} */
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index b0b1657c162..cd66f026828 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -243,7 +243,7 @@ void BKE_object_dimensions_set(struct Object *ob, const float value[3], int axis
void BKE_object_empty_draw_type_set(struct Object *ob, const int value);
void BKE_object_boundbox_flag(struct Object *ob, int flag, const bool set);
-void BKE_object_boundbox_calc_from_mesh(struct Object *ob, struct Mesh *me_eval);
+void BKE_object_boundbox_calc_from_mesh(struct Object *ob, const struct Mesh *me_eval);
void BKE_object_minmax(struct Object *ob, float r_min[3], float r_max[3], const bool use_hidden);
bool BKE_object_minmax_dupli(struct Depsgraph *depsgraph,
struct Scene *scene,
@@ -382,20 +382,19 @@ void BKE_object_data_batch_cache_dirty_tag(struct ID *object_data);
/* this function returns a superset of the scenes selection based on relationships */
typedef enum eObRelationTypes {
- OB_REL_NONE = 0, /* just the selection as is */
- OB_REL_PARENT = (1 << 0), /* immediate parent */
- OB_REL_PARENT_RECURSIVE = (1 << 1), /* parents up to root of selection tree*/
- OB_REL_CHILDREN = (1 << 2), /* immediate children */
- OB_REL_CHILDREN_RECURSIVE = (1 << 3), /* All children */
- OB_REL_MOD_ARMATURE = (1 << 4), /* Armatures related to the selected objects */
- /* OB_REL_SCENE_CAMERA = (1 << 5), */ /* you might want the scene camera too even if unselected?
- */
+ OB_REL_NONE = 0, /* Just the selection as is. */
+ OB_REL_PARENT = (1 << 0), /* Immediate parent. */
+ OB_REL_PARENT_RECURSIVE = (1 << 1), /* Parents up to root of selection tree. */
+ OB_REL_CHILDREN = (1 << 2), /* Immediate children. */
+ OB_REL_CHILDREN_RECURSIVE = (1 << 3), /* All children. */
+ OB_REL_MOD_ARMATURE = (1 << 4), /* Armatures related to the selected objects. */
+ // OB_REL_SCENE_CAMERA = (1 << 5), /* You might want the scene camera too even if unselected? */
} eObRelationTypes;
typedef enum eObjectSet {
- OB_SET_SELECTED, /* Selected Objects */
- OB_SET_VISIBLE, /* Visible Objects */
- OB_SET_ALL, /* All Objects */
+ OB_SET_SELECTED, /* Selected Objects. */
+ OB_SET_VISIBLE, /* Visible Objects. */
+ OB_SET_ALL, /* All Objects. */
} eObjectSet;
struct LinkNode *BKE_object_relational_superset(struct ViewLayer *view_layer,
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 3913ede9049..e5b547d2557 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -78,7 +78,7 @@ struct Scene;
for (p = 0; p < psys->totpart; p++) \
if ((pa = psys->particles + p)->state.time > 0.0f)
-/* fast but sure way to get the modifier*/
+/* Fast but sure way to get the modifier. */
#define PARTICLE_PSMD \
ParticleSystemModifierData *psmd = sim->psmd ? sim->psmd : psys_get_modifier(sim->ob, sim->psys)
@@ -190,7 +190,7 @@ typedef struct ParticleCollisionElement {
/* pointers to original data */
float *x[3], *v[3];
- /* values interpolated from original data*/
+ /* Values interpolated from original data. */
float x0[3], x1[3], x2[3], p[3];
/* results for found intersection point */
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 0fa44067b16..97e5698d6f9 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -474,7 +474,7 @@ bool BKE_pbvh_node_vert_update_check_any(PBVH *pbvh, PBVHNode *node);
// void BKE_pbvh_node_BB_reset(PBVHNode *node);
// void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3]);
-bool pbvh_has_mask(PBVH *pbvh);
+bool pbvh_has_mask(const PBVH *pbvh);
void pbvh_show_mask_set(PBVH *pbvh, bool show_mask);
bool pbvh_has_face_sets(PBVH *pbvh);
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 085851ba5e6..fed155626ed 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -62,7 +62,7 @@ struct wmWindow;
struct wmWindowManager;
/* spacetype has everything stored to get an editor working, it gets initialized via
- * ED_spacetypes_init() in editors/space_api/spacetypes.c */
+ * #ED_spacetypes_init() in `editors/space_api/spacetypes.c` */
/* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */
#define BKE_ST_MAXNAME 64
@@ -206,7 +206,7 @@ typedef struct ARegionType {
* performed.
*
* This callback is not called on indirect changes of the current viewport (which could happen
- * when the `v2d->tot is changed and `cur` is adopted accordingly). */
+ * when the `v2d->tot is changed and `cur` is adopted accordingly). */
void (*on_view2d_changed)(const struct bContext *C, struct ARegion *region);
/* custom drawing callbacks */
diff --git a/source/blender/blenkernel/BKE_shader_fx.h b/source/blender/blenkernel/BKE_shader_fx.h
index 7e3783a3ee9..8d1fe709355 100644
--- a/source/blender/blenkernel/BKE_shader_fx.h
+++ b/source/blender/blenkernel/BKE_shader_fx.h
@@ -172,7 +172,7 @@ void BKE_shaderfx_copydata_ex(struct ShaderFxData *fx,
void BKE_shaderfx_copy(struct ListBase *dst, const struct ListBase *src);
void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, void *userData);
-bool BKE_shaderfx_has_gpencil(struct Object *ob);
+bool BKE_shaderfx_has_gpencil(const struct Object *ob);
void BKE_shaderfx_blend_write(struct BlendWriter *writer, struct ListBase *fxbase);
void BKE_shaderfx_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb);
diff --git a/source/blender/blenkernel/BKE_spline.hh b/source/blender/blenkernel/BKE_spline.hh
index 24b5a78e598..1aac2e311e3 100644
--- a/source/blender/blenkernel/BKE_spline.hh
+++ b/source/blender/blenkernel/BKE_spline.hh
@@ -32,6 +32,7 @@
#include "BKE_attribute_math.hh"
struct Curve;
+struct ListBase;
class Spline;
using SplinePtr = std::unique_ptr<Spline>;
@@ -328,7 +329,8 @@ class BezierSpline final : public Spline {
};
InterpolationData interpolation_data_from_index_factor(const float index_factor) const;
- virtual blender::fn::GVArrayPtr interpolate_to_evaluated(const blender::fn::GVArray &src) const;
+ virtual blender::fn::GVArrayPtr interpolate_to_evaluated(
+ const blender::fn::GVArray &src) const override;
void evaluate_segment(const int index,
const int next_index,
@@ -545,4 +547,6 @@ struct CurveEval {
void assert_valid_point_attributes() const;
};
-std::unique_ptr<CurveEval> curve_eval_from_dna_curve(const Curve &curve);
+std::unique_ptr<CurveEval> curve_eval_from_dna_curve(const Curve &curve,
+ const ListBase &nurbs_list);
+std::unique_ptr<CurveEval> curve_eval_from_dna_curve(const Curve &dna_curve);
diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h
index 07bbeafb1ae..3816a822279 100644
--- a/source/blender/blenkernel/BKE_subsurf.h
+++ b/source/blender/blenkernel/BKE_subsurf.h
@@ -25,7 +25,7 @@
/* struct DerivedMesh is used directly */
#include "BKE_DerivedMesh.h"
-/* Thread sync primitives used directly. */
+/* Thread sync primitives used directly. */
#include "BLI_threads.h"
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h
index c60d5c7bfec..c7120c60020 100644
--- a/source/blender/blenkernel/BKE_text.h
+++ b/source/blender/blenkernel/BKE_text.h
@@ -48,7 +48,7 @@ char *txt_to_buf(struct Text *text, int *r_buf_strlen);
void txt_clean_text(struct Text *text);
void txt_order_cursors(struct Text *text, const bool reverse);
int txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case);
-bool txt_has_sel(struct Text *text);
+bool txt_has_sel(const struct Text *text);
int txt_get_span(struct TextLine *from, struct TextLine *to);
void txt_move_up(struct Text *text, const bool sel);
void txt_move_down(struct Text *text, const bool sel);
@@ -85,13 +85,13 @@ bool txt_uncomment(struct Text *text);
void txt_move_lines(struct Text *text, const int direction);
void txt_duplicate_line(struct Text *text);
int txt_setcurr_tab_spaces(struct Text *text, int space);
-bool txt_cursor_is_line_start(struct Text *text);
-bool txt_cursor_is_line_end(struct Text *text);
+bool txt_cursor_is_line_start(const struct Text *text);
+bool txt_cursor_is_line_end(const struct Text *text);
int txt_calc_tab_left(struct TextLine *tl, int ch);
int txt_calc_tab_right(struct TextLine *tl, int ch);
-/* utility functions, could be moved somewhere more generic but are python/text related */
+/* Utility functions, could be moved somewhere more generic but are python/text related. */
int text_check_bracket(const char ch);
bool text_check_delim(const char ch);
bool text_check_digit(const char ch);
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index c2544c06514..47145a7d6bd 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -161,7 +161,7 @@ struct MovieTrackingMarker *BKE_tracking_marker_get_exact(struct MovieTrackingTr
struct MovieTrackingMarker *BKE_tracking_marker_ensure(struct MovieTrackingTrack *track,
int framenr);
-/* Get marker position, possibly interpolating interpolating gap between keyframed/tracked markers.
+/* Get marker position, possibly interpolating gap between key-framed/tracked markers.
*
* The result marker frame number is set to the requested frame number. Its flags are 0 if the
* marker is interpolated, and is set to original marker flag if there were no interpolation
diff --git a/source/blender/blenkernel/BKE_undo_system.h b/source/blender/blenkernel/BKE_undo_system.h
index 620496864f5..efac5d9097f 100644
--- a/source/blender/blenkernel/BKE_undo_system.h
+++ b/source/blender/blenkernel/BKE_undo_system.h
@@ -178,7 +178,7 @@ UndoStack *BKE_undosys_stack_create(void);
void BKE_undosys_stack_destroy(UndoStack *ustack);
void BKE_undosys_stack_clear(UndoStack *ustack);
void BKE_undosys_stack_clear_active(UndoStack *ustack);
-bool BKE_undosys_stack_has_undo(UndoStack *ustack, const char *name);
+bool BKE_undosys_stack_has_undo(const UndoStack *ustack, const char *name);
void BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain);
void BKE_undosys_stack_init_from_context(UndoStack *ustack, struct bContext *C);
UndoStep *BKE_undosys_stack_active_with_type(UndoStack *ustack, const UndoType *ut);
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 0f36887b234..7a057d8fc1b 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -93,7 +93,7 @@ set(SRC
intern/boids.c
intern/bpath.c
intern/brush.c
- intern/bvhutils.c
+ intern/bvhutils.cc
intern/cachefile.c
intern/callbacks.c
intern/camera.c
@@ -165,6 +165,7 @@ set(SRC
intern/layer_utils.c
intern/lib_id.c
intern/lib_id_delete.c
+ intern/lib_id_eval.c
intern/lib_override.c
intern/lib_query.c
intern/lib_remap.c
@@ -189,6 +190,7 @@ set(SRC
intern/mesh_mapping.c
intern/mesh_merge.c
intern/mesh_mirror.c
+ intern/mesh_normals.c
intern/mesh_remap.c
intern/mesh_remesh_voxel.c
intern/mesh_runtime.c
diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc
index 6caed3936d4..bc49c086532 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.cc
+++ b/source/blender/blenkernel/intern/DerivedMesh.cc
@@ -960,7 +960,7 @@ static Mesh *modifier_modify_mesh_and_geometry_set(ModifierData *md,
mesh_output = mesh_component.release();
}
- /* Return an empty mesh instead of null. */
+ /* Return an empty mesh instead of null. */
if (mesh_output == nullptr) {
mesh_output = BKE_mesh_new_nomain(0, 0, 0, 0, 0);
BKE_mesh_copy_parameters_for_eval(mesh_output, input_mesh);
@@ -973,7 +973,7 @@ static Mesh *modifier_modify_mesh_and_geometry_set(ModifierData *md,
static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
Scene *scene,
Object *ob,
- int useDeform,
+ const bool use_deform,
const bool need_mapping,
const CustomData_MeshMasks *dataMask,
const int index,
@@ -1068,7 +1068,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
BKE_modifiers_clear_errors(ob);
/* Apply all leading deform modifiers. */
- if (useDeform) {
+ if (use_deform) {
for (; md; md = md->next, md_datamask = md_datamask->next) {
const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type);
@@ -1076,10 +1076,6 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
continue;
}
- if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) {
- continue;
- }
-
if (mti->type == eModifierTypeType_OnlyDeform && !sculpt_dyntopo) {
if (!deformed_verts) {
deformed_verts = BKE_mesh_vert_coords_alloc(mesh_input, &num_deformed_verts);
@@ -1128,7 +1124,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
continue;
}
- if (mti->type == eModifierTypeType_OnlyDeform && !useDeform) {
+ if (mti->type == eModifierTypeType_OnlyDeform && !use_deform) {
continue;
}
@@ -1173,10 +1169,6 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
continue;
}
- if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) {
- continue;
- }
-
/* Add orco mesh as layer if needed by this modifier. */
if (mesh_final && mesh_orco && mti->requiredDataMask) {
CustomData_MeshMasks mask = {0};
@@ -1937,7 +1929,7 @@ static void mesh_build_data(struct Depsgraph *depsgraph,
mesh_calc_modifiers(depsgraph,
scene,
ob,
- 1,
+ true,
need_mapping,
dataMask,
-1,
@@ -2162,7 +2154,7 @@ Mesh *mesh_create_eval_final(Depsgraph *depsgraph,
Mesh *final;
mesh_calc_modifiers(
- depsgraph, scene, ob, 1, false, dataMask, -1, false, false, nullptr, &final, nullptr);
+ depsgraph, scene, ob, true, false, dataMask, -1, false, false, nullptr, &final, nullptr);
return final;
}
@@ -2176,7 +2168,7 @@ Mesh *mesh_create_eval_final_index_render(Depsgraph *depsgraph,
Mesh *final;
mesh_calc_modifiers(
- depsgraph, scene, ob, 1, false, dataMask, index, false, false, nullptr, &final, nullptr);
+ depsgraph, scene, ob, true, false, dataMask, index, false, false, nullptr, &final, nullptr);
return final;
}
@@ -2189,7 +2181,7 @@ Mesh *mesh_create_eval_no_deform(Depsgraph *depsgraph,
Mesh *final;
mesh_calc_modifiers(
- depsgraph, scene, ob, 0, false, dataMask, -1, false, false, nullptr, &final, nullptr);
+ depsgraph, scene, ob, false, false, dataMask, -1, false, false, nullptr, &final, nullptr);
return final;
}
@@ -2202,7 +2194,7 @@ Mesh *mesh_create_eval_no_deform_render(Depsgraph *depsgraph,
Mesh *final;
mesh_calc_modifiers(
- depsgraph, scene, ob, 0, false, dataMask, -1, false, false, nullptr, &final, nullptr);
+ depsgraph, scene, ob, false, false, dataMask, -1, false, false, nullptr, &final, nullptr);
return final;
}
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 71d242e9c79..fdf3558abed 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -370,7 +370,7 @@ void set_active_action_group(bAction *act, bActionGroup *agrp, short select)
/* Sync colors used for action/bone group with theme settings */
void action_group_colors_sync(bActionGroup *grp, const bActionGroup *ref_grp)
{
- /* only do color copying if using a custom color (i.e. not default color) */
+ /* Only do color copying if using a custom color (i.e. not default color). */
if (grp->customCol) {
if (grp->customCol > 0) {
/* copy theme colors on-to group's custom color in case user tries to edit color */
@@ -486,8 +486,7 @@ 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.
- */
+ * the second in the chain, etc. */
if (grp == NULL) {
BLI_insertlinkbefore(&act->curves, act->curves.first, fcurve);
}
@@ -1856,7 +1855,7 @@ void BKE_pose_blend_write(BlendWriter *writer, bPose *pose, bArmature *arm)
/* Write channels */
LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
+ * of library blocks that implement this. */
if (chan->prop) {
IDP_BlendWrite(writer, chan->prop);
}
diff --git a/source/blender/blenkernel/intern/action_mirror.c b/source/blender/blenkernel/intern/action_mirror.c
index c975d2bfb9c..69e0091444b 100644
--- a/source/blender/blenkernel/intern/action_mirror.c
+++ b/source/blender/blenkernel/intern/action_mirror.c
@@ -343,7 +343,7 @@ static void action_flip_pchan(Object *ob_arm,
} \
((void)0)
- /* Write the values back the the F-curves. */
+ /* Write the values back the F-curves. */
WRITE_ARRAY_FLT(loc);
WRITE_ARRAY_FLT(eul);
WRITE_ARRAY_FLT(quat);
diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c
index 44b760aefc8..2f71dda17f2 100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -946,7 +946,7 @@ static bool nlastrips_path_rename_fix(ID *owner_id,
is_changed |= fcurves_path_rename_fix(
owner_id, prefix, oldName, newName, oldKey, newKey, &strip->act->curves, verify_paths);
}
- /* Ignore own F-Curves, since those are local. */
+ /* Ignore own F-Curves, since those are local. */
/* Check sub-strips (if meta-strips). */
is_changed |= nlastrips_path_rename_fix(
owner_id, prefix, oldName, newName, oldKey, newKey, &strip->strips, verify_paths);
@@ -1422,7 +1422,7 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id,
* NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]>
* i.e. pose.bones["Bone"]
*/
-/* TODO: use BKE_animdata_main_cb for looping over all data */
+/* TODO: use BKE_animdata_main_cb for looping over all data. */
void BKE_animdata_fix_paths_rename_all_ex(Main *bmain,
ID *ref_id,
const char *prefix,
diff --git a/source/blender/blenkernel/intern/anim_path.c b/source/blender/blenkernel/intern/anim_path.c
index af2b386a30a..e2c2708101b 100644
--- a/source/blender/blenkernel/intern/anim_path.c
+++ b/source/blender/blenkernel/intern/anim_path.c
@@ -327,7 +327,7 @@ bool BKE_where_on_path(const Object *ob,
}
const Nurb *nu = nurbs->first;
- /* make sure that first and last frame are included in the vectors here */
+ /* Make sure that first and last frame are included in the vectors here. */
if (ELEM(nu->type, CU_POLY, CU_BEZIER, CU_NURBS)) {
key_curve_position_weights(frac, w, KEY_LINEAR);
}
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index e347306e0ae..08a3f3fcf4f 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -852,7 +852,7 @@ NlaEvalStrip *nlastrips_ctime_get_strip(ListBase *list,
/* loop over strips, checking if they fall within the range */
for (strip = strips->first; strip; strip = strip->next) {
- /* check if current time occurs within this strip */
+ /* Check if current time occurs within this strip. */
if (IN_RANGE_INCL(ctime, strip->start, strip->end) ||
(strip->flag & NLASTRIP_FLAG_NO_TIME_MAP)) {
/* this strip is active, so try to use it */
@@ -1564,7 +1564,7 @@ static bool nla_blend_get_inverted_strip_value(const int blendmode,
}
}
-/** \returns true if solution exists and output is written to. */
+/** \returns true if solution exists and output is written to. */
static bool nla_combine_get_inverted_strip_value(const int mix_mode,
float base_value,
const float lower_value,
@@ -2017,7 +2017,7 @@ static void nlaeval_fmodifiers_join_stacks(ListBase *result, ListBase *list1, Li
{
FModifier *fcm1, *fcm2;
- /* if list1 is invalid... */
+ /* if list1 is invalid... */
if (ELEM(NULL, list1, list1->first)) {
if (list2 && list2->first) {
result->first = list2->first;
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index bcfd34ab42f..579f671e2b0 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -200,7 +200,7 @@ bool BKE_appdir_folder_documents(char *dir)
return true;
}
- /* Ghost couldn't give us a documents path, let's try if we can find it ourselves.*/
+ /* Ghost couldn't give us a documents path, let's try if we can find it ourselves. */
const char *home_path = BKE_appdir_folder_home();
if (!home_path || !BLI_is_dir(home_path)) {
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index a57e1d6b2dd..d0604f4bfda 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -198,7 +198,7 @@ static void write_bone(BlendWriter *writer, Bone *bone)
BLO_write_struct(writer, Bone, bone);
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
+ * of library blocks that implement this. */
if (bone->prop) {
IDP_BlendWrite(writer, bone->prop);
}
@@ -358,7 +358,7 @@ bArmature *BKE_armature_from_object(Object *ob)
return NULL;
}
-int BKE_armature_bonelist_count(ListBase *lb)
+int BKE_armature_bonelist_count(const ListBase *lb)
{
int i = 0;
LISTBASE_FOREACH (Bone *, bone, lb) {
@@ -1627,7 +1627,7 @@ void BKE_armature_mat_world_to_pose(Object *ob, const float inmat[4][4], float o
return;
}
- /* get inverse of (armature) object's matrix */
+ /* Get inverse of (armature) object's matrix. */
invert_m4_m4(obmat, ob->obmat);
/* multiply given matrix by object's-inverse to find pose-space matrix */
@@ -2063,9 +2063,11 @@ void BKE_armature_mat_pose_to_delta(float delta_mat[4][4],
* Used for Objects and Pose Channels, since both can have multiple rotation representations.
* \{ */
-/* Called from RNA when rotation mode changes
+/**
+ * Called from RNA when rotation mode changes
* - the result should be that the rotations given in the provided pointers have had conversions
- * applied (as appropriate), such that the rotation of the element hasn't 'visually' changed */
+ * applied (as appropriate), such that the rotation of the element hasn't 'visually' changed.
+ */
void BKE_rotMode_change_values(
float quat[4], float eul[3], float axis[3], float *angle, short oldMode, short newMode)
{
@@ -2333,7 +2335,7 @@ void BKE_armature_where_is_bone(Bone *bone, const Bone *bone_parent, const bool
/* yoffs(b-1) + root(b) + bonemat(b) */
BKE_bone_offset_matrix_get(bone, offs_bone);
- /* Compose the matrix for this bone */
+ /* Compose the matrix for this bone. */
mul_m4_m4m4(bone->arm_mat, bone_parent->arm_mat, offs_bone);
}
else {
diff --git a/source/blender/blenkernel/intern/armature_test.cc b/source/blender/blenkernel/intern/armature_test.cc
index 366bbe3e37c..589337d9d01 100644
--- a/source/blender/blenkernel/intern/armature_test.cc
+++ b/source/blender/blenkernel/intern/armature_test.cc
@@ -121,7 +121,7 @@ TEST(vec_roll_to_mat3_normalized, Rotationmatrix)
/* TODO: This test will pass after fixing T82455) */
/* If normalized_vector is close to -Y and
* it has X and Z values above a threshold,
- * apply the special case. */
+ * apply the special case. */
{
const float expected_roll_mat[3][3] = {{0.000000f, -9.99999975e-06f, 1.000000f},
{9.99999975e-06f, -0.999999881f, 9.99999975e-06f},
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index 4504f10967c..0f8956a1a91 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -837,7 +837,7 @@ void BKE_pose_eval_init_ik(struct Depsgraph *depsgraph, Scene *scene, Object *ob
BIK_init_tree(depsgraph, scene, object, ctime);
/* construct the Spline IK trees
* - this is not integrated as an IK plugin, since it should be able
- * to function in conjunction with standard IK. */
+ * to function in conjunction with standard IK. */
BKE_pose_splineik_init_tree(scene, object, ctime);
}
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 8bbb3014dac..aa0af294bc3 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -1197,7 +1197,7 @@ static blender::bke::OutputAttribute create_output_attribute(
cpp_type->size() * domain_size, cpp_type->alignment(), __func__);
if (ignore_old_values) {
/* This does nothing for trivially constructible types, but is necessary for correctness. */
- cpp_type->construct_default_n(data, domain);
+ cpp_type->default_construct_n(data, domain);
}
else {
/* Fill the temporary array with values from the existing attribute. */
diff --git a/source/blender/blenkernel/intern/blender_copybuffer.c b/source/blender/blenkernel/intern/blender_copybuffer.c
index dfd49a347ca..9c9f898afef 100644
--- a/source/blender/blenkernel/intern/blender_copybuffer.c
+++ b/source/blender/blenkernel/intern/blender_copybuffer.c
@@ -87,7 +87,8 @@ bool BKE_copybuffer_read(Main *bmain_dst,
ReportList *reports,
const uint64_t id_types_mask)
{
- BlendHandle *bh = BLO_blendhandle_from_file(libname, reports);
+ BlendFileReadReport bf_reports = {.reports = reports};
+ BlendHandle *bh = BLO_blendhandle_from_file(libname, &bf_reports);
if (bh == NULL) {
/* Error reports will have been made by BLO_blendhandle_from_file(). */
return false;
@@ -133,7 +134,8 @@ int BKE_copybuffer_paste(bContext *C,
BlendHandle *bh;
const int id_tag_extra = 0;
- bh = BLO_blendhandle_from_file(libname, reports);
+ BlendFileReadReport bf_reports = {.reports = reports};
+ bh = BLO_blendhandle_from_file(libname, &bf_reports);
if (bh == NULL) {
/* error reports will have been made by BLO_blendhandle_from_file() */
diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c
index ba41786c7fd..411ece21599 100644
--- a/source/blender/blenkernel/intern/blender_undo.c
+++ b/source/blender/blenkernel/intern/blender_undo.c
@@ -78,9 +78,10 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
if (UNDO_DISK) {
const struct BlendFileReadParams params = {0};
- struct BlendFileData *bfd = BKE_blendfile_read(mfu->filename, &params, NULL);
+ BlendFileReadReport bf_reports = {.reports = NULL};
+ struct BlendFileData *bfd = BKE_blendfile_read(mfu->filename, &params, &bf_reports);
if (bfd != NULL) {
- BKE_blendfile_read_setup(C, bfd, &params, NULL);
+ BKE_blendfile_read_setup(C, bfd, &params, &bf_reports);
success = true;
}
}
@@ -93,7 +94,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
struct BlendFileData *bfd = BKE_blendfile_read_from_memfile(
bmain, &mfu->memfile, &params, NULL);
if (bfd != NULL) {
- BKE_blendfile_read_setup(C, bfd, &params, NULL);
+ BKE_blendfile_read_setup(C, bfd, &params, &(BlendFileReadReport){NULL});
success = true;
}
}
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index e335dd4bdcd..f31d8f5ade7 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -36,6 +36,8 @@
#include "BLI_system.h"
#include "BLI_utildefines.h"
+#include "PIL_time.h"
+
#include "IMB_colormanagement.h"
#include "BKE_addon.h"
@@ -136,7 +138,7 @@ static void setup_app_userdef(BlendFileData *bfd)
static void setup_app_data(bContext *C,
BlendFileData *bfd,
const struct BlendFileReadParams *params,
- ReportList *reports)
+ BlendFileReadReport *reports)
{
Main *bmain = G_MAIN;
Scene *curscene = NULL;
@@ -155,7 +157,7 @@ static void setup_app_data(bContext *C,
/* may happen with library files - UNDO file should never have NULL curscene (but may have a
* NULL curscreen)... */
else if (ELEM(NULL, bfd->curscreen, bfd->curscene)) {
- BKE_report(reports, RPT_WARNING, "Library file, loading empty scene");
+ BKE_report(reports->reports, RPT_WARNING, "Library file, loading empty scene");
mode = LOAD_UI_OFF;
}
else if (G.fileflags & G_FILE_NO_UI) {
@@ -270,7 +272,7 @@ static void setup_app_data(bContext *C,
/* We need to tag this here because events may be handled immediately after.
* only the current screen is important because we won't have to handle
- * events from multiple screens at once.*/
+ * events from multiple screens at once. */
if (curscreen) {
BKE_screen_gizmo_tag_refresh(curscreen);
}
@@ -396,11 +398,17 @@ static void setup_app_data(bContext *C,
}
if (mode != LOAD_UNDO && !USER_EXPERIMENTAL_TEST(&U, no_override_auto_resync)) {
+ reports->duration.lib_overrides_resync = PIL_check_seconds_timer();
+
BKE_lib_override_library_main_resync(
bmain,
curscene,
bfd->cur_view_layer ? bfd->cur_view_layer : BKE_view_layer_default_view(curscene),
reports);
+
+ reports->duration.lib_overrides_resync = PIL_check_seconds_timer() -
+ reports->duration.lib_overrides_resync;
+
/* We need to rebuild some of the deleted override rules (for UI feedback purpose). */
BKE_lib_override_library_main_operations_create(bmain, true);
}
@@ -409,7 +417,7 @@ static void setup_app_data(bContext *C,
static void setup_app_blend_file_data(bContext *C,
BlendFileData *bfd,
const struct BlendFileReadParams *params,
- ReportList *reports)
+ BlendFileReadReport *reports)
{
if ((params->skip_flags & BLO_READ_SKIP_USERDEF) == 0) {
setup_app_userdef(bfd);
@@ -419,12 +427,12 @@ static void setup_app_blend_file_data(bContext *C,
}
}
-static void handle_subversion_warning(Main *main, ReportList *reports)
+static void handle_subversion_warning(Main *main, BlendFileReadReport *reports)
{
if (main->minversionfile > BLENDER_FILE_VERSION ||
(main->minversionfile == BLENDER_FILE_VERSION &&
main->minsubversionfile > BLENDER_FILE_SUBVERSION)) {
- BKE_reportf(reports,
+ BKE_reportf(reports->reports,
RPT_ERROR,
"File written by newer Blender binary (%d.%d), expect loss of data!",
main->minversionfile,
@@ -443,7 +451,7 @@ static void handle_subversion_warning(Main *main, ReportList *reports)
void BKE_blendfile_read_setup_ex(bContext *C,
BlendFileData *bfd,
const struct BlendFileReadParams *params,
- ReportList *reports,
+ BlendFileReadReport *reports,
/* Extra args. */
const bool startup_update_defaults,
const char *startup_app_template)
@@ -460,7 +468,7 @@ void BKE_blendfile_read_setup_ex(bContext *C,
void BKE_blendfile_read_setup(bContext *C,
BlendFileData *bfd,
const struct BlendFileReadParams *params,
- ReportList *reports)
+ BlendFileReadReport *reports)
{
BKE_blendfile_read_setup_ex(C, bfd, params, reports, false, NULL);
}
@@ -470,7 +478,7 @@ void BKE_blendfile_read_setup(bContext *C,
*/
struct BlendFileData *BKE_blendfile_read(const char *filepath,
const struct BlendFileReadParams *params,
- ReportList *reports)
+ BlendFileReadReport *reports)
{
/* Don't print startup file loading. */
if (params->is_startup == false) {
@@ -482,7 +490,7 @@ struct BlendFileData *BKE_blendfile_read(const char *filepath,
handle_subversion_warning(bfd->main, reports);
}
else {
- BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath);
+ BKE_reports_prependf(reports->reports, "Loading '%s' failed: ", filepath);
}
return bfd;
}
@@ -559,7 +567,9 @@ UserDef *BKE_blendfile_userdef_read(const char *filepath, ReportList *reports)
BlendFileData *bfd;
UserDef *userdef = NULL;
- bfd = BLO_read_from_file(filepath, BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF, reports);
+ bfd = BLO_read_from_file(filepath,
+ BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF,
+ &(struct BlendFileReadReport){.reports = reports});
if (bfd) {
if (bfd->user) {
userdef = bfd->user;
@@ -770,7 +780,8 @@ WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepat
WorkspaceConfigFileData *workspace_config = NULL;
if (filepath) {
- bfd = BLO_read_from_file(filepath, BLO_READ_SKIP_USERDEF, reports);
+ bfd = BLO_read_from_file(
+ filepath, BLO_READ_SKIP_USERDEF, &(struct BlendFileReadReport){.reports = reports});
}
else {
bfd = BLO_read_from_memory(filebuf, filelength, BLO_READ_SKIP_USERDEF, reports);
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.cc
index 116e6279657..3dea49d1953 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.cc
@@ -21,9 +21,9 @@
* \ingroup bke
*/
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
+#include <cmath>
+#include <cstdio>
+#include <cstring>
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -46,15 +46,15 @@
/** \name BVHCache
* \{ */
-typedef struct BVHCacheItem {
+struct BVHCacheItem {
bool is_filled;
BVHTree *tree;
-} BVHCacheItem;
+};
-typedef struct BVHCache {
+struct BVHCache {
BVHCacheItem items[BVHTREE_MAX_ITEM];
ThreadMutex mutex;
-} BVHCache;
+};
/**
* Queries a bvhcache for the cache bvhtree of the request type
@@ -74,14 +74,14 @@ static bool bvhcache_find(BVHCache **bvh_cache_p,
if (r_locked) {
*r_locked = false;
}
- if (*bvh_cache_p == NULL) {
+ if (*bvh_cache_p == nullptr) {
if (!do_lock) {
/* Cache does not exist and no lock is requested. */
return false;
}
/* Lazy initialization of the bvh_cache using the `mesh_eval_mutex`. */
BLI_mutex_lock(mesh_eval_mutex);
- if (*bvh_cache_p == NULL) {
+ if (*bvh_cache_p == nullptr) {
*bvh_cache_p = bvhcache_init();
}
BLI_mutex_unlock(mesh_eval_mutex);
@@ -94,7 +94,7 @@ static bool bvhcache_find(BVHCache **bvh_cache_p,
}
if (do_lock) {
BLI_mutex_lock(&bvh_cache->mutex);
- bool in_cache = bvhcache_find(bvh_cache_p, type, r_tree, NULL, NULL);
+ bool in_cache = bvhcache_find(bvh_cache_p, type, r_tree, nullptr, nullptr);
if (in_cache) {
BLI_mutex_unlock(&bvh_cache->mutex);
return in_cache;
@@ -113,11 +113,11 @@ static void bvhcache_unlock(BVHCache *bvh_cache, bool lock_started)
bool bvhcache_has_tree(const BVHCache *bvh_cache, const BVHTree *tree)
{
- if (bvh_cache == NULL) {
+ if (bvh_cache == nullptr) {
return false;
}
- for (BVHCacheType i = 0; i < BVHTREE_MAX_ITEM; i++) {
+ for (int i = 0; i < BVHTREE_MAX_ITEM; i++) {
if (bvh_cache->items[i].tree == tree) {
return true;
}
@@ -127,7 +127,7 @@ bool bvhcache_has_tree(const BVHCache *bvh_cache, const BVHTree *tree)
BVHCache *bvhcache_init(void)
{
- BVHCache *cache = MEM_callocN(sizeof(BVHCache), __func__);
+ BVHCache *cache = (BVHCache *)MEM_callocN(sizeof(BVHCache), __func__);
BLI_mutex_init(&cache->mutex);
return cache;
}
@@ -137,7 +137,7 @@ BVHCache *bvhcache_init(void)
* as that will be done when the cache is freed.
*
* A call to this assumes that there was no previous cached tree of the given type
- * \warning The #BVHTree can be NULL.
+ * \warning The #BVHTree can be nullptr.
*/
static void bvhcache_insert(BVHCache *bvh_cache, BVHTree *tree, BVHCacheType type)
{
@@ -152,10 +152,10 @@ static void bvhcache_insert(BVHCache *bvh_cache, BVHTree *tree, BVHCacheType typ
*/
void bvhcache_free(BVHCache *bvh_cache)
{
- for (BVHCacheType index = 0; index < BVHTREE_MAX_ITEM; index++) {
+ for (int index = 0; index < BVHTREE_MAX_ITEM; index++) {
BVHCacheItem *item = &bvh_cache->items[index];
BLI_bvhtree_free(item->tree);
- item->tree = NULL;
+ item->tree = nullptr;
}
BLI_mutex_end(&bvh_cache->mutex);
MEM_freeN(bvh_cache);
@@ -197,9 +197,10 @@ float bvhtree_ray_tri_intersection(const BVHTreeRay *ray,
float dist;
#ifdef USE_KDOPBVH_WATERTIGHT
- if (isect_ray_tri_watertight_v3(ray->origin, ray->isect_precalc, v0, v1, v2, &dist, NULL))
+ if (isect_ray_tri_watertight_v3(ray->origin, ray->isect_precalc, v0, v1, v2, &dist, nullptr))
#else
- if (isect_ray_tri_epsilon_v3(ray->origin, ray->direction, v0, v1, v2, &dist, NULL, FLT_EPSILON))
+ if (isect_ray_tri_epsilon_v3(
+ ray->origin, ray->direction, v0, v1, v2, &dist, nullptr, FLT_EPSILON))
#endif
{
return dist;
@@ -247,7 +248,7 @@ static void mesh_faces_nearest_point(void *userdata,
t0 = vert[face->v1].co;
t1 = vert[face->v2].co;
t2 = vert[face->v3].co;
- t3 = face->v4 ? vert[face->v4].co : NULL;
+ t3 = face->v4 ? vert[face->v4].co : nullptr;
do {
float nearest_tmp[3], dist_sq;
@@ -264,7 +265,7 @@ static void mesh_faces_nearest_point(void *userdata,
t1 = t2;
t2 = t3;
- t3 = NULL;
+ t3 = nullptr;
} while (t2);
}
@@ -300,7 +301,7 @@ static void editmesh_looptri_nearest_point(void *userdata,
const float co[3],
BVHTreeNearest *nearest)
{
- const BVHTreeFromEditMesh *data = userdata;
+ const BVHTreeFromEditMesh *data = (const BVHTreeFromEditMesh *)userdata;
BMEditMesh *em = data->em;
const BMLoop **ltri = (const BMLoop **)em->looptris[index];
@@ -339,7 +340,7 @@ static void mesh_faces_spherecast(void *userdata,
t0 = vert[face->v1].co;
t1 = vert[face->v2].co;
t2 = vert[face->v3].co;
- t3 = face->v4 ? vert[face->v4].co : NULL;
+ t3 = face->v4 ? vert[face->v4].co : nullptr;
do {
float dist;
@@ -360,7 +361,7 @@ static void mesh_faces_spherecast(void *userdata,
t1 = t2;
t2 = t3;
- t3 = NULL;
+ t3 = nullptr;
} while (t2);
}
@@ -457,7 +458,7 @@ static void mesh_edges_nearest_point(void *userdata,
}
}
-/* Helper, does all the point-spherecast work actually. */
+/* Helper, does all the point-sphere-cast work actually. */
static void mesh_verts_spherecast_do(int index,
const float v[3],
const BVHTreeRay *ray,
@@ -484,7 +485,7 @@ static void editmesh_verts_spherecast(void *userdata,
const BVHTreeRay *ray,
BVHTreeRayHit *hit)
{
- const BVHTreeFromEditMesh *data = userdata;
+ const BVHTreeFromEditMesh *data = (const BVHTreeFromEditMesh *)userdata;
BMVert *eve = BM_vert_at_index(data->em->bm, index);
mesh_verts_spherecast_do(index, eve->co, ray, hit);
@@ -600,7 +601,7 @@ static BVHTree *bvhtree_from_mesh_verts_create_tree(float epsilon,
const BLI_bitmap *verts_mask,
int verts_num_active)
{
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
if (verts_mask) {
BLI_assert(IN_RANGE_INCL(verts_num_active, 0, verts_num));
@@ -637,9 +638,9 @@ static void bvhtree_from_mesh_verts_setup_data(BVHTreeFromMesh *data,
data->tree = tree;
data->cached = is_cached;
- /* a NULL nearest callback works fine
+ /* a nullptr nearest callback works fine
* remember the min distance to point is the same as the min distance to BV of point */
- data->nearest_callback = NULL;
+ data->nearest_callback = nullptr;
data->raycast_callback = mesh_verts_spherecast;
data->vert = vert;
@@ -658,7 +659,7 @@ BVHTree *bvhtree_from_editmesh_verts_ex(BVHTreeFromEditMesh *data,
BVHCache **bvh_cache_p,
ThreadMutex *mesh_eval_mutex)
{
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
if (bvh_cache_p) {
bool lock_started = false;
@@ -671,7 +672,7 @@ BVHTree *bvhtree_from_editmesh_verts_ex(BVHTreeFromEditMesh *data,
bvhtree_balance(tree, true);
/* Save on cache for later use */
- /* printf("BVHTree built and saved on cache\n"); */
+ // printf("BVHTree built and saved on cache\n");
bvhcache_insert(*bvh_cache_p, tree, bvh_cache_type);
data->cached = true;
}
@@ -687,9 +688,9 @@ BVHTree *bvhtree_from_editmesh_verts_ex(BVHTreeFromEditMesh *data,
memset(data, 0, sizeof(*data));
data->tree = tree;
data->em = em;
- data->nearest_callback = NULL;
+ data->nearest_callback = nullptr;
data->raycast_callback = editmesh_verts_spherecast;
- data->cached = bvh_cache_p != NULL;
+ data->cached = bvh_cache_p != nullptr;
}
return tree;
@@ -699,11 +700,11 @@ BVHTree *bvhtree_from_editmesh_verts(
BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis)
{
return bvhtree_from_editmesh_verts_ex(
- data, em, NULL, -1, epsilon, tree_type, axis, 0, NULL, NULL);
+ data, em, nullptr, -1, epsilon, tree_type, axis, BVHTREE_FROM_VERTS, nullptr, nullptr);
}
/**
- * Builds a bvh tree where nodes are the given vertices (note: does not copy given mverts!).
+ * Builds a bvh tree where nodes are the given vertices (note: does not copy given `vert`!).
* \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
@@ -724,7 +725,7 @@ BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
{
bool in_cache = false;
bool lock_started = false;
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
if (bvh_cache_p) {
in_cache = bvhcache_find(bvh_cache_p, bvh_cache_type, &tree, &lock_started, mesh_eval_mutex);
}
@@ -732,11 +733,11 @@ BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
if (in_cache == false) {
tree = bvhtree_from_mesh_verts_create_tree(
epsilon, tree_type, axis, vert, verts_num, verts_mask, verts_num_active);
- bvhtree_balance(tree, bvh_cache_p != NULL);
+ bvhtree_balance(tree, bvh_cache_p != nullptr);
if (bvh_cache_p) {
/* Save on cache for later use */
- /* printf("BVHTree built and saved on cache\n"); */
+ // printf("BVHTree built and saved on cache\n");
BVHCache *bvh_cache = *bvh_cache_p;
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
in_cache = true;
@@ -807,7 +808,7 @@ static BVHTree *bvhtree_from_mesh_edges_create_tree(const MVert *vert,
int tree_type,
int axis)
{
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
if (edges_mask) {
BLI_assert(IN_RANGE_INCL(edges_num_active, 0, edge_num));
@@ -817,7 +818,7 @@ static BVHTree *bvhtree_from_mesh_edges_create_tree(const MVert *vert,
}
if (edges_num_active) {
- /* Create a bvh-tree of the given target */
+ /* Create a BVH-tree of the given target */
tree = BLI_bvhtree_new(edges_num_active, epsilon, tree_type, axis);
if (tree) {
for (int i = 0; i < edge_num; i++) {
@@ -871,7 +872,7 @@ BVHTree *bvhtree_from_editmesh_edges_ex(BVHTreeFromEditMesh *data,
BVHCache **bvh_cache_p,
ThreadMutex *mesh_eval_mutex)
{
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
if (bvh_cache_p) {
bool lock_started = false;
@@ -883,7 +884,7 @@ BVHTree *bvhtree_from_editmesh_edges_ex(BVHTreeFromEditMesh *data,
epsilon, tree_type, axis, em, edges_mask, edges_num_active);
bvhtree_balance(tree, true);
/* Save on cache for later use */
- /* printf("BVHTree built and saved on cache\n"); */
+ // printf("BVHTree built and saved on cache\n");
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
data->cached = true;
}
@@ -899,9 +900,9 @@ BVHTree *bvhtree_from_editmesh_edges_ex(BVHTreeFromEditMesh *data,
memset(data, 0, sizeof(*data));
data->tree = tree;
data->em = em;
- data->nearest_callback = NULL; /* TODO */
- data->raycast_callback = NULL; /* TODO */
- data->cached = bvh_cache_p != NULL;
+ data->nearest_callback = nullptr; /* TODO */
+ data->raycast_callback = nullptr; /* TODO */
+ data->cached = bvh_cache_p != nullptr;
}
return tree;
@@ -911,7 +912,7 @@ BVHTree *bvhtree_from_editmesh_edges(
BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis)
{
return bvhtree_from_editmesh_edges_ex(
- data, em, NULL, -1, epsilon, tree_type, axis, 0, NULL, NULL);
+ data, em, nullptr, -1, epsilon, tree_type, axis, BVHTREE_FROM_VERTS, nullptr, nullptr);
}
/**
@@ -939,7 +940,7 @@ BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
{
bool in_cache = false;
bool lock_started = false;
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
if (bvh_cache_p) {
in_cache = bvhcache_find(bvh_cache_p, bvh_cache_type, &tree, &lock_started, mesh_eval_mutex);
}
@@ -953,7 +954,7 @@ BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
BVHCache *bvh_cache = *bvh_cache_p;
/* Save on cache for later use */
- /* printf("BVHTree built and saved on cache\n"); */
+ // printf("BVHTree built and saved on cache\n");
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
in_cache = true;
}
@@ -988,7 +989,7 @@ static BVHTree *bvhtree_from_mesh_faces_create_tree(float epsilon,
const BLI_bitmap *faces_mask,
int faces_num_active)
{
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
if (faces_num) {
if (faces_mask) {
@@ -998,8 +999,8 @@ static BVHTree *bvhtree_from_mesh_faces_create_tree(float epsilon,
faces_num_active = faces_num;
}
- /* Create a bvh-tree of the given target */
- /* printf("%s: building BVH, total=%d\n", __func__, numFaces); */
+ /* Create a BVH-tree of the given target. */
+ // printf("%s: building BVH, total=%d\n", __func__, numFaces);
tree = BLI_bvhtree_new(faces_num_active, epsilon, tree_type, axis);
if (tree) {
if (vert && face) {
@@ -1074,7 +1075,7 @@ BVHTree *bvhtree_from_mesh_faces_ex(BVHTreeFromMesh *data,
{
bool in_cache = false;
bool lock_started = false;
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
if (bvh_cache_p) {
in_cache = bvhcache_find(bvh_cache_p, bvh_cache_type, &tree, &lock_started, mesh_eval_mutex);
}
@@ -1082,11 +1083,11 @@ BVHTree *bvhtree_from_mesh_faces_ex(BVHTreeFromMesh *data,
if (in_cache == false) {
tree = bvhtree_from_mesh_faces_create_tree(
epsilon, tree_type, axis, vert, face, numFaces, faces_mask, faces_num_active);
- bvhtree_balance(tree, bvh_cache_p != NULL);
+ bvhtree_balance(tree, bvh_cache_p != nullptr);
if (bvh_cache_p) {
/* Save on cache for later use */
- /* printf("BVHTree built and saved on cache\n"); */
+ // printf("BVHTree built and saved on cache\n");
BVHCache *bvh_cache = *bvh_cache_p;
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
in_cache = true;
@@ -1117,7 +1118,7 @@ static BVHTree *bvhtree_from_editmesh_looptri_create_tree(float epsilon,
const BLI_bitmap *looptri_mask,
int looptri_num_active)
{
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
const int looptri_num = em->tottri;
if (looptri_num) {
@@ -1128,11 +1129,11 @@ static BVHTree *bvhtree_from_editmesh_looptri_create_tree(float epsilon,
looptri_num_active = looptri_num;
}
- /* Create a bvh-tree of the given target */
- /* printf("%s: building BVH, total=%d\n", __func__, numFaces); */
+ /* Create a BVH-tree of the given target */
+ // printf("%s: building BVH, total=%d\n", __func__, numFaces);
tree = BLI_bvhtree_new(looptri_num_active, epsilon, tree_type, axis);
if (tree) {
- const struct BMLoop *(*looptris)[3] = (void *)em->looptris;
+ const BMLoop *(*looptris)[3] = (const BMLoop *(*)[3])em->looptris;
/* Insert BMesh-tessellation triangles into the bvh tree, unless they are hidden
* and/or selected. Even if the faces themselves are not selected for the snapped
@@ -1143,7 +1144,7 @@ static BVHTree *bvhtree_from_editmesh_looptri_create_tree(float epsilon,
bool insert = looptri_mask ? BLI_BITMAP_TEST_BOOL(looptri_mask, i) : true;
if (insert) {
- /* No reason found to block hit-testing the triangle for snap, so insert it now.*/
+ /* No reason found to block hit-testing the triangle for snap, so insert it now. */
float co[3][3];
copy_v3_v3(co[0], ltri[0]->v->co);
copy_v3_v3(co[1], ltri[1]->v->co);
@@ -1169,7 +1170,7 @@ static BVHTree *bvhtree_from_mesh_looptri_create_tree(float epsilon,
const BLI_bitmap *looptri_mask,
int looptri_num_active)
{
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
if (looptri_mask) {
BLI_assert(IN_RANGE_INCL(looptri_num_active, 0, looptri_num));
@@ -1179,8 +1180,8 @@ static BVHTree *bvhtree_from_mesh_looptri_create_tree(float epsilon,
}
if (looptri_num_active) {
- /* Create a bvh-tree of the given target */
- /* printf("%s: building BVH, total=%d\n", __func__, numFaces); */
+ /* Create a BVH-tree of the given target */
+ // printf("%s: building BVH, total=%d\n", __func__, numFaces);
tree = BLI_bvhtree_new(looptri_num_active, epsilon, tree_type, axis);
if (tree) {
if (vert && looptri) {
@@ -1247,7 +1248,7 @@ BVHTree *bvhtree_from_editmesh_looptri_ex(BVHTreeFromEditMesh *data,
/* BMESH specific check that we have tessfaces,
* we _could_ tessellate here but rather not - campbell */
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
if (bvh_cache_p) {
bool lock_started = false;
bool in_cache = bvhcache_find(
@@ -1260,7 +1261,7 @@ BVHTree *bvhtree_from_editmesh_looptri_ex(BVHTreeFromEditMesh *data,
epsilon, tree_type, axis, em, looptri_mask, looptri_num_active);
/* Save on cache for later use */
- /* printf("BVHTree built and saved on cache\n"); */
+ // printf("BVHTree built and saved on cache\n");
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
}
bvhcache_unlock(bvh_cache, lock_started);
@@ -1276,7 +1277,7 @@ BVHTree *bvhtree_from_editmesh_looptri_ex(BVHTreeFromEditMesh *data,
data->nearest_callback = editmesh_looptri_nearest_point;
data->raycast_callback = editmesh_looptri_spherecast;
data->em = em;
- data->cached = bvh_cache_p != NULL;
+ data->cached = bvh_cache_p != nullptr;
}
return tree;
}
@@ -1285,7 +1286,7 @@ BVHTree *bvhtree_from_editmesh_looptri(
BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis)
{
return bvhtree_from_editmesh_looptri_ex(
- data, em, NULL, -1, epsilon, tree_type, axis, 0, NULL, NULL);
+ data, em, nullptr, -1, epsilon, tree_type, axis, BVHTREE_FROM_VERTS, nullptr, nullptr);
}
/**
@@ -1312,7 +1313,7 @@ BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
{
bool in_cache = false;
bool lock_started = false;
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
if (bvh_cache_p) {
in_cache = bvhcache_find(bvh_cache_p, bvh_cache_type, &tree, &lock_started, mesh_eval_mutex);
}
@@ -1329,7 +1330,7 @@ BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
looptri_mask,
looptri_num_active);
- bvhtree_balance(tree, bvh_cache_p != NULL);
+ bvhtree_balance(tree, bvh_cache_p != nullptr);
if (bvh_cache_p) {
BVHCache *bvh_cache = *bvh_cache_p;
@@ -1437,19 +1438,22 @@ static BLI_bitmap *looptri_no_hidden_map_get(const MPoly *mpoly,
/**
* Builds or queries a bvhcache for the cache bvhtree of the request type.
+ *
+ * \note This function only fills a cache, and therefore the mesh argument can
+ * be considered logically const. Concurrent access is protected by a mutex.
*/
BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
- struct Mesh *mesh,
+ const struct Mesh *mesh,
const BVHCacheType bvh_cache_type,
const int tree_type)
{
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
BVHCache **bvh_cache_p = (BVHCache **)&mesh->runtime.bvh_cache;
ThreadMutex *mesh_eval_mutex = (ThreadMutex *)mesh->runtime.eval_mutex;
- bool is_cached = bvhcache_find(bvh_cache_p, bvh_cache_type, &tree, NULL, NULL);
+ const bool is_cached = bvhcache_find(bvh_cache_p, bvh_cache_type, &tree, nullptr, nullptr);
- if (is_cached && tree == NULL) {
+ if (is_cached && tree == nullptr) {
memset(data, 0, sizeof(*data));
return tree;
}
@@ -1458,7 +1462,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
case BVHTREE_FROM_VERTS:
case BVHTREE_FROM_LOOSEVERTS:
if (is_cached == false) {
- BLI_bitmap *loose_verts_mask = NULL;
+ BLI_bitmap *loose_verts_mask = nullptr;
int loose_vert_len = -1;
int verts_len = mesh->totvert;
@@ -1480,7 +1484,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
bvh_cache_p,
mesh_eval_mutex);
- if (loose_verts_mask != NULL) {
+ if (loose_verts_mask != nullptr) {
MEM_freeN(loose_verts_mask);
}
}
@@ -1493,7 +1497,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
case BVHTREE_FROM_EDGES:
case BVHTREE_FROM_LOOSEEDGES:
if (is_cached == false) {
- BLI_bitmap *loose_edges_mask = NULL;
+ BLI_bitmap *loose_edges_mask = nullptr;
int loose_edges_len = -1;
int edges_len = mesh->totedge;
@@ -1516,7 +1520,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
bvh_cache_p,
mesh_eval_mutex);
- if (loose_edges_mask != NULL) {
+ if (loose_edges_mask != nullptr) {
MEM_freeN(loose_edges_mask);
}
}
@@ -1538,7 +1542,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
mesh->mface,
num_faces,
false,
- NULL,
+ nullptr,
-1,
0.0,
tree_type,
@@ -1561,7 +1565,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
int looptri_len = BKE_mesh_runtime_looptri_len(mesh);
int looptri_mask_active_len = -1;
- BLI_bitmap *looptri_mask = NULL;
+ BLI_bitmap *looptri_mask = nullptr;
if (bvh_cache_type == BVHTREE_FROM_LOOPTRI_NO_HIDDEN) {
looptri_mask = looptri_no_hidden_map_get(
mesh->mpoly, looptri_len, &looptri_mask_active_len);
@@ -1584,7 +1588,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
bvh_cache_p,
mesh_eval_mutex);
- if (looptri_mask != NULL) {
+ if (looptri_mask != nullptr) {
MEM_freeN(looptri_mask);
}
}
@@ -1603,7 +1607,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
break;
}
- if (data->tree != NULL) {
+ if (data->tree != nullptr) {
#ifdef DEBUG
if (BLI_bvhtree_get_tree_type(data->tree) != tree_type) {
printf("tree_type %d obtained instead of %d\n",
@@ -1631,15 +1635,15 @@ BVHTree *BKE_bvhtree_from_editmesh_get(BVHTreeFromEditMesh *data,
BVHCache **bvh_cache_p,
ThreadMutex *mesh_eval_mutex)
{
- BVHTree *tree = NULL;
+ BVHTree *tree = nullptr;
bool is_cached = false;
memset(data, 0, sizeof(*data));
if (bvh_cache_p) {
- is_cached = bvhcache_find(bvh_cache_p, bvh_cache_type, &tree, NULL, NULL);
+ is_cached = bvhcache_find(bvh_cache_p, bvh_cache_type, &tree, nullptr, nullptr);
- if (is_cached && tree == NULL) {
+ if (is_cached && tree == nullptr) {
return tree;
}
}
@@ -1650,31 +1654,55 @@ BVHTree *BKE_bvhtree_from_editmesh_get(BVHTreeFromEditMesh *data,
switch (bvh_cache_type) {
case BVHTREE_FROM_EM_VERTS:
if (is_cached == false) {
- tree = bvhtree_from_editmesh_verts_ex(
- data, em, NULL, -1, 0.0f, tree_type, 6, bvh_cache_type, bvh_cache_p, mesh_eval_mutex);
+ tree = bvhtree_from_editmesh_verts_ex(data,
+ em,
+ nullptr,
+ -1,
+ 0.0f,
+ tree_type,
+ 6,
+ bvh_cache_type,
+ bvh_cache_p,
+ mesh_eval_mutex);
}
else {
- data->nearest_callback = NULL;
+ data->nearest_callback = nullptr;
data->raycast_callback = editmesh_verts_spherecast;
}
break;
case BVHTREE_FROM_EM_EDGES:
if (is_cached == false) {
- tree = bvhtree_from_editmesh_edges_ex(
- data, em, NULL, -1, 0.0f, tree_type, 6, bvh_cache_type, bvh_cache_p, mesh_eval_mutex);
+ tree = bvhtree_from_editmesh_edges_ex(data,
+ em,
+ nullptr,
+ -1,
+ 0.0f,
+ tree_type,
+ 6,
+ bvh_cache_type,
+ bvh_cache_p,
+ mesh_eval_mutex);
}
else {
/* Setup BVHTreeFromMesh */
- data->nearest_callback = NULL; /* TODO */
- data->raycast_callback = NULL; /* TODO */
+ data->nearest_callback = nullptr; /* TODO */
+ data->raycast_callback = nullptr; /* TODO */
}
break;
case BVHTREE_FROM_EM_LOOPTRI:
if (is_cached == false) {
- tree = bvhtree_from_editmesh_looptri_ex(
- data, em, NULL, -1, 0.0f, tree_type, 6, bvh_cache_type, bvh_cache_p, mesh_eval_mutex);
+ tree = bvhtree_from_editmesh_looptri_ex(data,
+ em,
+ nullptr,
+ -1,
+ 0.0f,
+ tree_type,
+ 6,
+ bvh_cache_type,
+ bvh_cache_p,
+ mesh_eval_mutex);
}
else {
/* Setup BVHTreeFromMesh */
@@ -1694,7 +1722,7 @@ BVHTree *BKE_bvhtree_from_editmesh_get(BVHTreeFromEditMesh *data,
break;
}
- if (data->tree != NULL) {
+ if (data->tree != nullptr) {
#ifdef DEBUG
if (BLI_bvhtree_get_tree_type(data->tree) != tree_type) {
printf("tree_type %d obtained instead of %d\n",
@@ -1763,7 +1791,7 @@ BVHTree *BKE_bvhtree_from_pointcloud_get(BVHTreeFromPointCloud *data,
{
BVHTree *tree = BLI_bvhtree_new(pointcloud->totpoint, 0.0f, tree_type, 6);
if (!tree) {
- return NULL;
+ return nullptr;
}
for (int i = 0; i < pointcloud->totpoint; i++) {
@@ -1774,7 +1802,7 @@ BVHTree *BKE_bvhtree_from_pointcloud_get(BVHTreeFromPointCloud *data,
data->coords = pointcloud->co;
data->tree = tree;
- data->nearest_callback = NULL;
+ data->nearest_callback = nullptr;
return tree;
}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index bab9e2a5592..5172b067eba 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -615,7 +615,7 @@ static void camera_frame_fit_data_init(const Scene *scene,
BKE_camera_params_init(params);
BKE_camera_params_from_object(params, ob);
- /* compute matrix, viewplane, .. */
+ /* Compute matrix, view-plane, etc. */
if (scene) {
BKE_camera_params_compute_viewplane(
params, scene->r.xsch, scene->r.ysch, scene->r.xasp, scene->r.yasp);
@@ -975,7 +975,7 @@ void BKE_camera_multiview_window_matrix(const RenderData *rd,
BKE_camera_params_from_object(&params, camera);
BKE_camera_multiview_params(rd, &params, camera, viewname);
- /* Compute matrix, viewplane, .. */
+ /* Compute matrix, view-plane, etc. */
BKE_camera_params_compute_viewplane(&params, rd->xsch, rd->ysch, rd->xasp, rd->yasp);
BKE_camera_params_compute_matrix(&params);
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index aa51ee0017e..24266dc6bea 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -79,7 +79,8 @@ static bool collection_object_remove(Main *bmain,
static CollectionChild *collection_find_child(Collection *parent, Collection *collection);
static CollectionParent *collection_find_parent(Collection *child, Collection *collection);
-static bool collection_find_child_recursive(Collection *parent, Collection *collection);
+static bool collection_find_child_recursive(const Collection *parent,
+ const Collection *collection);
/** \} */
@@ -710,7 +711,7 @@ Collection *BKE_collection_duplicate(Main *bmain,
* unless its duplication is a sub-process of another one. */
collection_new->id.tag &= ~LIB_TAG_NEW;
- /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW.*/
+ /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW. */
BKE_libblock_relink_to_newid(&collection_new->id);
#ifndef NDEBUG
@@ -1458,7 +1459,7 @@ bool BKE_collection_cycle_find(Collection *new_ancestor, Collection *collection)
}
/* Find possible objects in collection or its children, that would instantiate the given ancestor
- * collection (that would also make a fully invalid cycle of dependencies) .*/
+ * collection (that would also make a fully invalid cycle of dependencies). */
return collection_instance_find_recursive(collection, new_ancestor);
}
@@ -1521,9 +1522,9 @@ static CollectionChild *collection_find_child(Collection *parent, Collection *co
return BLI_findptr(&parent->children, collection, offsetof(CollectionChild, collection));
}
-static bool collection_find_child_recursive(Collection *parent, Collection *collection)
+static bool collection_find_child_recursive(const Collection *parent, const Collection *collection)
{
- LISTBASE_FOREACH (CollectionChild *, child, &parent->children) {
+ LISTBASE_FOREACH (const CollectionChild *, child, &parent->children) {
if (child->collection == collection) {
return true;
}
@@ -1536,7 +1537,7 @@ static bool collection_find_child_recursive(Collection *parent, Collection *coll
return false;
}
-bool BKE_collection_has_collection(Collection *parent, Collection *collection)
+bool BKE_collection_has_collection(const Collection *parent, const Collection *collection)
{
return collection_find_child_recursive(parent, collection);
}
diff --git a/source/blender/blenkernel/intern/colorband.c b/source/blender/blenkernel/intern/colorband.c
index 2884d7b3204..d6b318caa5e 100644
--- a/source/blender/blenkernel/intern/colorband.c
+++ b/source/blender/blenkernel/intern/colorband.c
@@ -490,7 +490,7 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
}
if (ELEM(ipotype, COLBAND_INTERP_B_SPLINE, COLBAND_INTERP_CARDINAL)) {
- /* ipo from right to left: 3 2 1 0 */
+ /* Interpolate from right to left: `3 2 1 0`. */
float t[4];
if (a >= coba->tot - 1) {
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index f30fcc54b23..1484021cb9d 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -638,7 +638,7 @@ static void curvemap_make_table(const CurveMapping *cumap, CurveMap *cuma)
cuma->mintable = clipr->xmin;
cuma->maxtable = clipr->xmax;
- /* hrmf... we now rely on blender ipo beziers, these are more advanced */
+ /* Rely on Blender interpolation for bezier curves, support extra functionality here as well. */
bezt = MEM_callocN(cuma->totpoint * sizeof(BezTriple), "beztarr");
for (int a = 0; a < cuma->totpoint; a++) {
@@ -1280,12 +1280,12 @@ static void save_sample_line(
{
float yuv[3];
- /* vectorscope*/
+ /* Vector-scope. */
rgb_to_yuv(rgb[0], rgb[1], rgb[2], &yuv[0], &yuv[1], &yuv[2], BLI_YUV_ITU_BT709);
scopes->vecscope[idx + 0] = yuv[1];
scopes->vecscope[idx + 1] = yuv[2];
- /* waveform */
+ /* Waveform. */
switch (scopes->wavefrm_mode) {
case SCOPES_WAVEFRM_RGB:
case SCOPES_WAVEFRM_RGB_PARADE:
@@ -1497,7 +1497,7 @@ static void scopes_update_cb(void *__restrict userdata,
mul_v3_fl(ycc, INV_255);
minmax_v3v3_v3(min, max, ycc);
}
- /* increment count for histo*/
+ /* Increment count for histo. */
bin_lum[get_bin_float(luma)]++;
bin_r[get_bin_float(rgba[0])]++;
bin_g[get_bin_float(rgba[1])]++;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 826c79c3764..fe207f81d7d 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -222,7 +222,7 @@ void BKE_constraints_clear_evalob(bConstraintOb *cob)
/* 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 :/ ).*/
+ * still gives a 'delta' with non-null translation component :/ ). */
mul_m4_m4m4(delta, cob->matrix, imat);
/* copy matrices back to source */
@@ -272,7 +272,7 @@ void BKE_constraint_mat_convertspace(Object *ob,
float diff_mat[4][4];
float imat[4][4];
- /* prevent crashes in these unlikely events */
+ /* Prevent crashes in these unlikely events. */
if (ob == NULL || mat == NULL) {
return;
}
@@ -299,7 +299,10 @@ void BKE_constraint_mat_convertspace(Object *ob,
mul_m4_m4m4(mat, imat, mat);
/* Use pose-space as stepping stone for other spaces. */
- if (ELEM(to, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_PARLOCAL)) {
+ if (ELEM(to,
+ CONSTRAINT_SPACE_LOCAL,
+ CONSTRAINT_SPACE_PARLOCAL,
+ CONSTRAINT_SPACE_OWNLOCAL)) {
/* Call self with slightly different values. */
BKE_constraint_mat_convertspace(
ob, pchan, cob, mat, CONSTRAINT_SPACE_POSE, to, keep_scale);
@@ -315,6 +318,17 @@ void BKE_constraint_mat_convertspace(Object *ob,
BKE_armature_mat_pose_to_bone(pchan, mat, mat);
}
}
+ /* pose to owner local */
+ else if (to == CONSTRAINT_SPACE_OWNLOCAL) {
+ /* pose to local */
+ if (pchan->bone) {
+ BKE_armature_mat_pose_to_bone(pchan, mat, mat);
+ }
+
+ /* local to owner local (recursive) */
+ BKE_constraint_mat_convertspace(
+ ob, pchan, cob, mat, CONSTRAINT_SPACE_LOCAL, to, keep_scale);
+ }
/* pose to local with parent */
else if (to == CONSTRAINT_SPACE_PARLOCAL) {
if (pchan->bone) {
@@ -336,17 +350,59 @@ void BKE_constraint_mat_convertspace(Object *ob,
}
case CONSTRAINT_SPACE_LOCAL: /* ------------ FROM LOCALSPACE --------- */
{
+ /* local to owner local */
+ if (to == CONSTRAINT_SPACE_OWNLOCAL) {
+ if (pchan->bone) {
+ copy_m4_m4(diff_mat, pchan->bone->arm_mat);
+
+ if (cob && cob->pchan && cob->pchan->bone) {
+ invert_m4_m4(imat, cob->pchan->bone->arm_mat);
+ mul_m4_m4m4(diff_mat, imat, diff_mat);
+ }
+
+ zero_v3(diff_mat[3]);
+ invert_m4_m4(imat, diff_mat);
+ mul_m4_series(mat, diff_mat, mat, imat);
+ }
+ }
/* local to pose - do inverse procedure that was done for pose to local */
+ else {
+ if (pchan->bone) {
+ /* we need the posespace_matrix = local_matrix + (parent_posespace_matrix + restpos) */
+ BKE_armature_mat_bone_to_pose(pchan, mat, mat);
+ }
+
+ /* use pose-space as stepping stone for other spaces */
+ if (ELEM(to,
+ CONSTRAINT_SPACE_WORLD,
+ CONSTRAINT_SPACE_PARLOCAL,
+ CONSTRAINT_SPACE_CUSTOM)) {
+ /* call self with slightly different values */
+ BKE_constraint_mat_convertspace(
+ ob, pchan, cob, mat, CONSTRAINT_SPACE_POSE, to, keep_scale);
+ }
+ }
+ break;
+ }
+ case CONSTRAINT_SPACE_OWNLOCAL: { /* -------------- FROM OWNER LOCAL ---------- */
+ /* owner local to local */
if (pchan->bone) {
- /* we need the posespace_matrix = local_matrix + (parent_posespace_matrix + restpos) */
- BKE_armature_mat_bone_to_pose(pchan, mat, mat);
+ copy_m4_m4(diff_mat, pchan->bone->arm_mat);
+
+ if (cob && cob->pchan && cob->pchan->bone) {
+ invert_m4_m4(imat, cob->pchan->bone->arm_mat);
+ mul_m4_m4m4(diff_mat, imat, diff_mat);
+ }
+
+ zero_v3(diff_mat[3]);
+ invert_m4_m4(imat, diff_mat);
+ mul_m4_series(mat, imat, mat, diff_mat);
}
- /* use pose-space as stepping stone for other spaces */
- if (ELEM(to, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_PARLOCAL, CONSTRAINT_SPACE_CUSTOM)) {
+ if (to != CONSTRAINT_SPACE_LOCAL) {
/* call self with slightly different values */
BKE_constraint_mat_convertspace(
- ob, pchan, cob, mat, CONSTRAINT_SPACE_POSE, to, keep_scale);
+ ob, pchan, cob, mat, CONSTRAINT_SPACE_LOCAL, to, keep_scale);
}
break;
}
@@ -358,7 +414,11 @@ void BKE_constraint_mat_convertspace(Object *ob,
}
/* use pose-space as stepping stone for other spaces */
- if (ELEM(to, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_CUSTOM)) {
+ if (ELEM(to,
+ CONSTRAINT_SPACE_WORLD,
+ CONSTRAINT_SPACE_LOCAL,
+ CONSTRAINT_SPACE_OWNLOCAL,
+ CONSTRAINT_SPACE_CUSTOM)) {
/* call self with slightly different values */
BKE_constraint_mat_convertspace(
ob, pchan, cob, mat, CONSTRAINT_SPACE_POSE, to, keep_scale);
@@ -470,7 +530,7 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[
/* when not in EditMode, use the 'final' evaluated mesh, depsgraph
* ensures we build with CD_MDEFORMVERT layer
*/
- Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
+ const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
BMEditMesh *em = BKE_editmesh_from_object(ob);
float plane[3];
float imat[3][3], tmat[3][3];
@@ -488,17 +548,17 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[
float normal[3] = {0.0f, 0.0f, 0.0f};
float weightsum = 0.0f;
if (me_eval) {
- MDeformVert *dvert = CustomData_get_layer(&me_eval->vdata, CD_MDEFORMVERT);
+ const MDeformVert *dvert = CustomData_get_layer(&me_eval->vdata, CD_MDEFORMVERT);
int numVerts = me_eval->totvert;
/* check that dvert is a valid pointers (just in case) */
if (dvert) {
- MDeformVert *dv = dvert;
- MVert *mv = me_eval->mvert;
/* get the average of all verts with that are in the vertex-group */
- for (int i = 0; i < numVerts; i++, dv++, mv++) {
- MDeformWeight *dw = BKE_defvert_find_index(dv, defgroup);
+ for (int i = 0; i < numVerts; i++) {
+ const MDeformVert *dv = &dvert[i];
+ const MVert *mv = &me_eval->mvert[i];
+ const MDeformWeight *dw = BKE_defvert_find_index(dv, defgroup);
if (dw && dw->weight > 0.0f) {
float nor[3];
@@ -1476,7 +1536,10 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
* to get a time factor. */
curvetime /= cu->pathlen;
- if (cu->flag & CU_PATH_CLAMP) {
+ Nurb *nu = cu->nurb.first;
+ if (!(nu && nu->flagu & CU_NURB_CYCLIC) && cu->flag & CU_PATH_CLAMP) {
+ /* If curve is not cyclic, clamp to the begin/end points if the curve clamp option is on.
+ */
CLAMP(curvetime, 0.0f, 1.0f);
}
}
@@ -1491,7 +1554,7 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
dir,
(data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL,
&radius,
- NULL)) { /* quat_pt is quat or NULL*/
+ NULL)) { /* quat_pt is quat or NULL. */
float totmat[4][4];
unit_m4(totmat);
@@ -2232,17 +2295,47 @@ static void translike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
bConstraintTarget *ct = targets->first;
if (VALID_CONS_TARGET(ct)) {
+ float target_mat[4][4];
+
+ copy_m4_m4(target_mat, ct->matrix);
+
+ /* Remove the shear of the target matrix if enabled.
+ * Use Y as the axis since it's the natural default for bones. */
+ if (data->flag & TRANSLIKE_REMOVE_TARGET_SHEAR) {
+ orthogonalize_m4_stable(target_mat, 1, false);
+ }
+
+ /* Finally, combine the matrices. */
switch (data->mix_mode) {
case TRANSLIKE_MIX_REPLACE:
- copy_m4_m4(cob->matrix, ct->matrix);
+ copy_m4_m4(cob->matrix, target_mat);
+ break;
+
+ /* Simple matrix multiplication. */
+ case TRANSLIKE_MIX_BEFORE_FULL:
+ mul_m4_m4m4(cob->matrix, target_mat, cob->matrix);
break;
+ case TRANSLIKE_MIX_AFTER_FULL:
+ mul_m4_m4m4(cob->matrix, cob->matrix, target_mat);
+ break;
+
+ /* Aligned Inherit Scale emulation. */
case TRANSLIKE_MIX_BEFORE:
- mul_m4_m4m4_aligned_scale(cob->matrix, ct->matrix, cob->matrix);
+ mul_m4_m4m4_aligned_scale(cob->matrix, target_mat, cob->matrix);
break;
case TRANSLIKE_MIX_AFTER:
- mul_m4_m4m4_aligned_scale(cob->matrix, cob->matrix, ct->matrix);
+ mul_m4_m4m4_aligned_scale(cob->matrix, cob->matrix, target_mat);
+ break;
+
+ /* Fully separate handling of channels. */
+ case TRANSLIKE_MIX_BEFORE_SPLIT:
+ mul_m4_m4m4_split_channels(cob->matrix, target_mat, cob->matrix);
+ break;
+
+ case TRANSLIKE_MIX_AFTER_SPLIT:
+ mul_m4_m4m4_split_channels(cob->matrix, cob->matrix, target_mat);
break;
default:
@@ -2361,7 +2454,7 @@ static void pycon_new_data(void *cdata)
{
bPythonConstraint *data = (bPythonConstraint *)cdata;
- /* everything should be set correctly by calloc, except for the prop->type constant.*/
+ /* Everything should be set correctly by calloc, except for the prop->type constant. */
data->prop = MEM_callocN(sizeof(IDProperty), "PyConstraintProps");
data->prop->type = IDP_GROUP;
}
@@ -3523,7 +3616,7 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
scale[0] = 1.0;
scale[2] = 1.0;
break;
- default: /* should not happen, but in case*/
+ default: /* Should not happen, but in case. */
return;
} /* switch (data->volmode) */
@@ -3536,34 +3629,34 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
damptrack_do_transform(cob->matrix, vec, TRACK_Y);
break;
case PLANE_X:
- /* new Y aligns object target connection*/
+ /* New Y aligns object target connection. */
copy_v3_v3(cob->matrix[1], vec);
- /* build new Z vector */
- /* othogonal to "new Y" "old X! plane */
+ /* Build new Z vector. */
+ /* Orthogonal to "new Y" "old X! plane. */
cross_v3_v3v3(orth, xx, vec);
normalize_v3(orth);
- /* new Z*/
+ /* New Z. */
copy_v3_v3(cob->matrix[2], orth);
- /* we decided to keep X plane*/
+ /* We decided to keep X plane. */
cross_v3_v3v3(xx, vec, orth);
normalize_v3_v3(cob->matrix[0], xx);
break;
case PLANE_Z:
- /* new Y aligns object target connection*/
+ /* New Y aligns object target connection. */
copy_v3_v3(cob->matrix[1], vec);
- /* build new X vector */
- /* othogonal to "new Y" "old Z! plane */
+ /* Build new X vector. */
+ /* Orthogonal to "new Y" "old Z! plane. */
cross_v3_v3v3(orth, zz, vec);
normalize_v3(orth);
- /* new X */
+ /* New X. */
negate_v3_v3(cob->matrix[0], orth);
- /* we decided to keep Z */
+ /* We decided to keep Z. */
cross_v3_v3v3(zz, vec, orth);
normalize_v3_v3(cob->matrix[2], zz);
break;
@@ -4678,7 +4771,7 @@ static void pivotcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *ta
}
}
- /* find the pivot-point to use */
+ /* Find the pivot-point to use. */
if (VALID_CONS_TARGET(ct)) {
/* apply offset to target location */
add_v3_v3v3(pivot, ct->matrix[3], data->offset);
@@ -5006,7 +5099,7 @@ static void followtrack_project_to_depth_object_if_needed(FollowTrackContext *co
}
Object *depth_object = context->depth_object;
- Mesh *depth_mesh = BKE_object_get_evaluated_mesh(depth_object);
+ const Mesh *depth_mesh = BKE_object_get_evaluated_mesh(depth_object);
if (depth_mesh == NULL) {
return;
}
@@ -6297,7 +6390,7 @@ void BKE_constraint_blend_write(BlendWriter *writer, ListBase *conlist)
}
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
+ * of library blocks that implement this. */
IDP_BlendWrite(writer, data->prop);
break;
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 81830f5bb61..1028790856c 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -1225,8 +1225,11 @@ enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
return CTX_data_mode_enum_ex(obedit, obact, obact ? obact->mode : OB_MODE_OBJECT);
}
-/* would prefer if we can use the enum version below over this one - Campbell */
-/* must be aligned with above enum */
+/**
+ * Would prefer if we can use the enum version below over this one - Campbell.
+ *
+ * \note Must be aligned with above enum.
+ */
static const char *data_mode_strings[] = {
"mesh_edit", "curve_edit", "surface_edit", "text_edit",
"armature_edit", "mball_edit", "lattice_edit", "posemode",
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 65cdb8503a4..a5538453248 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -442,6 +442,15 @@ ListBase *BKE_curve_editNurbs_get(Curve *cu)
return NULL;
}
+const ListBase *BKE_curve_editNurbs_get_for_read(const Curve *cu)
+{
+ if (cu->editnurb) {
+ return &cu->editnurb->nurbs;
+ }
+
+ return NULL;
+}
+
short BKE_curve_type_get(const Curve *cu)
{
int type = cu->type;
@@ -1926,7 +1935,7 @@ static int cu_isectLL(const float v1[3],
static bool bevelinside(const BevList *bl1, const BevList *bl2)
{
/* is bl2 INSIDE bl1 ? with left-right method and "lambda's" */
- /* returns '1' if correct hole */
+ /* returns '1' if correct hole. */
BevPoint *bevp, *prevbevp;
float min, max, vec[3], hvec1[3], hvec2[3], lab, mu;
int nr, links = 0, rechts = 0, mode;
@@ -1941,7 +1950,7 @@ static bool bevelinside(const BevList *bl1, const BevList *bl2)
hvec2[0] += 1000;
/* test it with all edges of potential surrounding poly */
- /* count number of transitions left-right */
+ /* count number of transitions left-right. */
bevp = bl1->bevpoints;
nr = bl1->nr;
@@ -2049,7 +2058,7 @@ static void calc_bevel_sin_cos(
static void tilt_bezpart(const BezTriple *prevbezt,
const BezTriple *bezt,
- Nurb *nu,
+ const Nurb *nu,
float *tilt_array,
float *radius_array,
float *weight_array,
@@ -2133,7 +2142,7 @@ static void tilt_bezpart(const BezTriple *prevbezt,
}
if (weight_array) {
- /* basic interpolation for now, could copy tilt interp too */
+ /* Basic interpolation for now, could copy tilt interp too. */
*weight_array = prevbezt->weight + (bezt->weight - prevbezt->weight) *
(3.0f * fac * fac - 2.0f * fac * fac * fac);
@@ -2611,7 +2620,7 @@ static void make_bevel_list_2D(BevList *bl)
}
}
-static void bevlist_firstlast_direction_calc_from_bpoint(Nurb *nu, BevList *bl)
+static void bevlist_firstlast_direction_calc_from_bpoint(const Nurb *nu, BevList *bl)
{
if (nu->pntsu > 1) {
BPoint *first_bp = nu->bp, *last_bp = nu->bp + (nu->pntsu - 1);
@@ -2646,7 +2655,7 @@ void BKE_curve_bevelList_free(ListBase *bev)
BLI_listbase_clear(bev);
}
-void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
+void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_render)
{
/*
* - convert all curves to polys, with indication of resol and flags for double-vertices
@@ -2684,14 +2693,14 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
1;
#endif
- /* STEP 1: MAKE POLYS */
+ /* STEP 1: MAKE POLYS */
BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
if (cu->editnurb && ob->type != OB_FONT) {
is_editmode = 1;
}
- LISTBASE_FOREACH (Nurb *, nu, nurbs) {
+ LISTBASE_FOREACH (const Nurb *, nu, nurbs) {
if (nu->hide && is_editmode) {
continue;
}
@@ -4361,7 +4370,7 @@ void BKE_nurbList_handles_set(ListBase *editnurb, const char code)
else {
char h_new = HD_FREE;
- /* there is 1 handle not FREE: FREE it all, else make ALIGNED */
+ /* There is 1 handle not FREE: FREE it all, else make ALIGNED. */
if (code == 5) {
h_new = HD_ALIGN;
}
@@ -4932,7 +4941,7 @@ bool BKE_nurb_type_convert(Nurb *nu,
int a, c, nr;
if (nu->type == CU_POLY) {
- if (type == CU_BEZIER) { /* to Bezier with vecthandles */
+ if (type == CU_BEZIER) { /* To Bezier with vecthandles. */
nr = nu->pntsu;
bezt = (BezTriple *)MEM_calloc_arrayN(nr, sizeof(BezTriple), "setsplinetype2");
nu->bezt = bezt;
@@ -5078,6 +5087,15 @@ ListBase *BKE_curve_nurbs_get(Curve *cu)
return &cu->nurb;
}
+const ListBase *BKE_curve_nurbs_get_for_read(const Curve *cu)
+{
+ if (cu->editnurb) {
+ return BKE_curve_editNurbs_get_for_read(cu);
+ }
+
+ return &cu->nurb;
+}
+
void BKE_curve_nurb_active_set(Curve *cu, const Nurb *nu)
{
if (nu == NULL) {
@@ -5135,7 +5153,7 @@ void BKE_curve_nurb_vert_active_set(Curve *cu, const Nurb *nu, const void *vert)
}
}
-/* Get points to active active nurb and active vert for curve */
+/* Get points to the active nurb and active vert for curve. */
bool BKE_curve_nurb_vert_active_get(Curve *cu, Nurb **r_nu, void **r_vert)
{
Nurb *nu = NULL;
diff --git a/source/blender/blenkernel/intern/curve_bevel.c b/source/blender/blenkernel/intern/curve_bevel.c
index 7f2cdfa59d3..d205d8cca46 100644
--- a/source/blender/blenkernel/intern/curve_bevel.c
+++ b/source/blender/blenkernel/intern/curve_bevel.c
@@ -97,7 +97,7 @@ static void curve_bevel_make_extrude_and_fill(const Curve *cu,
* in a consistent direction.
*
* These should be small enough for stack allocations because the current limit
- * for #Curve.bevresol is 32. */
+ * for #Curve.bevresol is 32. */
float *quarter_coords_x = alloca(sizeof(float) * (cu->bevresol + 1));
float *quarter_coords_y = alloca(sizeof(float) * (cu->bevresol + 1));
bevel_quarter_fill(cu, quarter_coords_x, quarter_coords_y);
diff --git a/source/blender/blenkernel/intern/curve_decimate.c b/source/blender/blenkernel/intern/curve_decimate.c
index e4647908b58..62de7c74183 100644
--- a/source/blender/blenkernel/intern/curve_decimate.c
+++ b/source/blender/blenkernel/intern/curve_decimate.c
@@ -32,8 +32,8 @@
struct Knot {
struct Knot *next, *prev;
- uint point_index; /* index in point array */
- uint knot_index; /* index in knot array*/
+ uint point_index; /* Index in point array. */
+ uint knot_index; /* Index in knot array. */
float tan[2][3];
float handles[2];
diff --git a/source/blender/blenkernel/intern/curve_eval.cc b/source/blender/blenkernel/intern/curve_eval.cc
index 0a6e4458a35..72ee2587c8a 100644
--- a/source/blender/blenkernel/intern/curve_eval.cc
+++ b/source/blender/blenkernel/intern/curve_eval.cc
@@ -257,9 +257,10 @@ static SplinePtr spline_from_dna_poly(const Nurb &nurb)
return spline;
}
-std::unique_ptr<CurveEval> curve_eval_from_dna_curve(const Curve &dna_curve)
+std::unique_ptr<CurveEval> curve_eval_from_dna_curve(const Curve &dna_curve,
+ const ListBase &nurbs_list)
{
- Vector<const Nurb *> nurbs(*BKE_curve_nurbs_get(&const_cast<Curve &>(dna_curve)));
+ Vector<const Nurb *> nurbs(nurbs_list);
std::unique_ptr<CurveEval> curve = std::make_unique<CurveEval>();
curve->resize(nurbs.size());
@@ -295,6 +296,11 @@ std::unique_ptr<CurveEval> curve_eval_from_dna_curve(const Curve &dna_curve)
return curve;
}
+std::unique_ptr<CurveEval> curve_eval_from_dna_curve(const Curve &dna_curve)
+{
+ return curve_eval_from_dna_curve(dna_curve, *BKE_curve_nurbs_get_for_read(&dna_curve));
+}
+
/**
* Check the invariants that curve control point attributes should always uphold, necessary
* because attributes are stored on splines rather than in a flat array on the curve:
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index b1bb8b9715e..08d0af45e92 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -2099,7 +2099,7 @@ bool CustomData_merge(const struct CustomData *source,
eCDAllocType alloctype,
int totelem)
{
- /*const LayerTypeInfo *typeInfo;*/
+ // const LayerTypeInfo *typeInfo;
CustomDataLayer *layer, *newlayer;
int lasttype = -1, lastactive = 0, lastrender = 0, lastclone = 0, lastmask = 0;
int number = 0, maxnumber = -1;
@@ -2107,7 +2107,7 @@ bool CustomData_merge(const struct CustomData *source,
for (int i = 0; i < source->totlayer; i++) {
layer = &source->layers[i];
- /*typeInfo = layerType_getInfo(layer->type);*/ /*UNUSED*/
+ // typeInfo = layerType_getInfo(layer->type); /* UNUSED */
int type = layer->type;
int flag = layer->flag;
@@ -2631,7 +2631,7 @@ void *CustomData_add_layer(
return NULL;
}
-/*same as above but accepts a name*/
+/* Same as above but accepts a name. */
void *CustomData_add_layer_named(CustomData *data,
int type,
eCDAllocType alloctype,
@@ -2813,6 +2813,14 @@ void *CustomData_duplicate_referenced_layer_named(CustomData *data,
return customData_duplicate_referenced_layer_index(data, layer_index, totelem);
}
+void CustomData_duplicate_referenced_layers(CustomData *data, int totelem)
+{
+ for (int i = 0; i < data->totlayer; i++) {
+ CustomDataLayer *layer = &data->layers[i];
+ layer->data = customData_duplicate_referenced_layer_index(data, i, totelem);
+ }
+}
+
bool CustomData_is_referenced_layer(struct CustomData *data, int type)
{
/* get the layer index of the first layer of type */
@@ -3559,7 +3567,7 @@ bool CustomData_bmesh_merge(const CustomData *source,
if (iter_type != BM_LOOPS_OF_FACE) {
BMHeader *h;
BMIter iter;
- /*ensure all current elements follow new customdata layout*/
+ /* Ensure all current elements follow new customdata layout. */
BM_ITER_MESH (h, &iter, bm, iter_type) {
void *tmp = NULL;
CustomData_bmesh_copy_data(&destold, dest, h->data, &tmp);
@@ -3573,7 +3581,7 @@ bool CustomData_bmesh_merge(const CustomData *source,
BMIter iter;
BMIter liter;
- /*ensure all current elements follow new customdata layout*/
+ /* Ensure all current elements follow new customdata layout. */
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
void *tmp = NULL;
@@ -3797,7 +3805,7 @@ void *CustomData_bmesh_get_n(const CustomData *data, void *block, int type, int
return POINTER_OFFSET(block, data->layers[layer_index + n].offset);
}
-/*gets from the layer at physical index n, note: doesn't check type.*/
+/* Gets from the layer at physical index n, note: doesn't check type. */
void *CustomData_bmesh_get_layer_n(const CustomData *data, void *block, int n)
{
if (n < 0 || n >= data->totlayer) {
@@ -3879,7 +3887,7 @@ bool CustomData_has_referenced(const struct CustomData *data)
}
/* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to
- * another, while not overwriting anything else (e.g. flags)*/
+ * another, while not overwriting anything else (e.g. flags). */
void CustomData_data_copy_value(int type, const void *source, void *dest)
{
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
@@ -3897,7 +3905,7 @@ void CustomData_data_copy_value(int type, const void *source, void *dest)
}
/* Mixes the "value" (e.g. mloopuv uv or mloopcol colors) from one block into
- * another, while not overwriting anything else (e.g. flags)*/
+ * another, while not overwriting anything else (e.g. flags). */
void CustomData_data_mix_value(
int type, const void *source, void *dest, const int mixmode, const float mixfactor)
{
diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c
index 314d5f4ff82..ef86a65f47d 100644
--- a/source/blender/blenkernel/intern/customdata_file.c
+++ b/source/blender/blenkernel/intern/customdata_file.c
@@ -361,9 +361,9 @@ bool cdf_write_open(CDataFile *cdf, const char *filename)
cdf->writef = f;
- /* fill header */
+ /* Fill header. */
header = &cdf->header;
- /* strcpy(, "BCDF"); // terminator out of range */
+ /* Copy "BCDF" (string terminator out of range). */
header->ID[0] = 'B';
header->ID[1] = 'C';
header->ID[2] = 'D';
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index 2bf58d9e764..12269cf0d51 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -1260,7 +1260,7 @@ void BKE_object_data_transfer_layout(struct Depsgraph *depsgraph,
me_dst = ob_dst->data;
- /* Get source evaluated mesh.*/
+ /* Get source evaluated mesh. */
BKE_object_data_transfer_dttypes_to_cdmask(data_types, &me_src_mask);
me_src = mesh_get_eval_final(depsgraph, scene, ob_src, &me_src_mask);
if (!me_src) {
@@ -1441,7 +1441,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
}
}
- /* Get source evaluated mesh.*/
+ /* Get source evaluated mesh. */
BKE_object_data_transfer_dttypes_to_cdmask(data_types, &me_src_mask);
BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(
map_vert_mode, map_edge_mode, map_loop_mode, map_poly_mode, &me_src_mask);
diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc
index 70355f3883d..a4ffaa8b10b 100644
--- a/source/blender/blenkernel/intern/displist.cc
+++ b/source/blender/blenkernel/intern/displist.cc
@@ -135,7 +135,7 @@ void BKE_displist_normals_add(ListBase *lb)
LISTBASE_FOREACH (DispList *, dl, lb) {
if (dl->type == DL_INDEX3) {
if (dl->nors == nullptr) {
- dl->nors = (float *)MEM_callocN(sizeof(float[3]), "dlnors");
+ dl->nors = (float *)MEM_callocN(sizeof(float[3]), __func__);
if (dl->flag & DL_BACK_CURVE) {
dl->nors[2] = -1.0f;
@@ -147,7 +147,7 @@ void BKE_displist_normals_add(ListBase *lb)
}
else if (dl->type == DL_SURF) {
if (dl->nors == nullptr) {
- dl->nors = (float *)MEM_callocN(sizeof(float[3]) * dl->nr * dl->parts, "dlnors");
+ dl->nors = (float *)MEM_callocN(sizeof(float[3]) * dl->nr * dl->parts, __func__);
vdata = dl->verts;
ndata = dl->nors;
@@ -323,12 +323,12 @@ static void curve_to_displist(const Curve *cu,
/* Check that there are more than two points so the curve doesn't loop back on itself. This
* needs to be separate from `is_cyclic` because cyclic sampling can work with two points
- * and resolution > 1. */
+ * and resolution > 1. */
const bool use_cyclic_sample = is_cyclic && (samples_len != 2);
DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__);
/* Add one to the length because of 'BKE_curve_forward_diff_bezier'. */
- dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * (samples_len + 1), "dlverts");
+ dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * (samples_len + 1), __func__);
BLI_addtail(r_dispbase, dl);
dl->parts = 1;
dl->nr = samples_len;
@@ -382,7 +382,7 @@ static void curve_to_displist(const Curve *cu,
else if (nu->type == CU_NURBS) {
const int len = (resolution * SEGMENTSU(nu));
DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__);
- dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), "dlverts");
+ dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__);
BLI_addtail(r_dispbase, dl);
dl->parts = 1;
dl->nr = len;
@@ -395,7 +395,7 @@ static void curve_to_displist(const Curve *cu,
else if (nu->type == CU_POLY) {
const int len = nu->pntsu;
DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__);
- dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), "dlverts");
+ dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__);
BLI_addtail(r_dispbase, dl);
dl->parts = 1;
dl->nr = len;
@@ -491,7 +491,7 @@ void BKE_displist_fill(const ListBase *dispbase,
const int triangles_len = BLI_scanfill_calc_ex(&sf_ctx, scanfill_flag, normal_proj);
if (totvert != 0 && triangles_len != 0) {
- DispList *dlnew = (DispList *)MEM_callocN(sizeof(DispList), "filldisplist");
+ DispList *dlnew = (DispList *)MEM_callocN(sizeof(DispList), __func__);
dlnew->type = DL_INDEX3;
dlnew->flag = (dl_flag_accum & (DL_BACK_CURVE | DL_FRONT_CURVE));
dlnew->rt = (dl_rt_accum & CU_SMOOTH);
@@ -499,8 +499,8 @@ void BKE_displist_fill(const ListBase *dispbase,
dlnew->nr = totvert;
dlnew->parts = triangles_len;
- dlnew->index = (int *)MEM_mallocN(sizeof(int[3]) * triangles_len, "dlindex");
- dlnew->verts = (float *)MEM_mallocN(sizeof(float[3]) * totvert, "dlverts");
+ dlnew->index = (int *)MEM_mallocN(sizeof(int[3]) * triangles_len, __func__);
+ dlnew->verts = (float *)MEM_mallocN(sizeof(float[3]) * totvert, __func__);
/* vert data */
int i;
@@ -630,7 +630,7 @@ static float displist_calc_taper(Depsgraph *depsgraph,
(DispList *)taperobj->runtime.curve_cache->disp.first :
nullptr;
if (dl == nullptr) {
- BKE_displist_make_curveTypes(depsgraph, scene, taperobj, false, false);
+ BKE_displist_make_curveTypes(depsgraph, scene, taperobj, false);
dl = (DispList *)taperobj->runtime.curve_cache->disp.first;
}
if (dl) {
@@ -681,8 +681,7 @@ void BKE_displist_make_mball(Depsgraph *depsgraph, Scene *scene, Object *ob)
BKE_displist_free(&(ob->runtime.curve_cache->disp));
}
else {
- ob->runtime.curve_cache = (CurveCache *)MEM_callocN(sizeof(CurveCache),
- "CurveCache for MBall");
+ ob->runtime.curve_cache = (CurveCache *)MEM_callocN(sizeof(CurveCache), __func__);
}
BKE_mball_polygonize(depsgraph, scene, ob, &ob->runtime.curve_cache->disp);
@@ -1068,7 +1067,7 @@ static void displist_surf_indices(DispList *dl)
dl->totindex = 0;
int *index = dl->index = (int *)MEM_mallocN(sizeof(int[4]) * (dl->parts + 1) * (dl->nr + 1),
- "index array nurbs");
+ __func__);
for (int a = 0; a < dl->parts; a++) {
@@ -1092,31 +1091,29 @@ static void displist_surf_indices(DispList *dl)
}
}
-static void displist_make_surf(Depsgraph *depsgraph,
- const Scene *scene,
- Object *ob,
- ListBase *dispbase,
- Mesh **r_final,
- const bool for_render,
- const bool for_orco)
+static void evaluate_surface_object(Depsgraph *depsgraph,
+ const Scene *scene,
+ Object *ob,
+ const bool for_render,
+ ListBase *r_dispbase,
+ Mesh **r_final)
{
- ListBase nubase = {nullptr, nullptr};
+ BLI_assert(ob->type == OB_SURF);
const Curve *cu = (const Curve *)ob->data;
+ ListBase *deformed_nurbs = &ob->runtime.curve_cache->deformed_nurbs;
+
if (!for_render && cu->editnurb) {
- BKE_nurbList_duplicate(&nubase, BKE_curve_editNurbs_get(const_cast<Curve *>(cu)));
+ BKE_nurbList_duplicate(deformed_nurbs, BKE_curve_editNurbs_get_for_read(cu));
}
else {
- BKE_nurbList_duplicate(&nubase, &cu->nurb);
+ BKE_nurbList_duplicate(deformed_nurbs, &cu->nurb);
}
- bool force_mesh_conversion = false;
- if (!for_orco) {
- force_mesh_conversion = BKE_curve_calc_modifiers_pre(
- depsgraph, scene, ob, &nubase, &nubase, for_render);
- }
+ bool force_mesh_conversion = BKE_curve_calc_modifiers_pre(
+ depsgraph, scene, ob, deformed_nurbs, deformed_nurbs, for_render);
- LISTBASE_FOREACH (Nurb *, nu, &nubase) {
+ LISTBASE_FOREACH (const Nurb *, nu, deformed_nurbs) {
if (!(for_render || nu->hide == 0) || !BKE_nurb_check_valid_uv(nu)) {
continue;
}
@@ -1127,10 +1124,10 @@ static void displist_make_surf(Depsgraph *depsgraph,
if (nu->pntsv == 1) {
const int len = SEGMENTSU(nu) * resolu;
- DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), "makeDispListsurf");
- dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), "dlverts");
+ DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__);
+ dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__);
- BLI_addtail(dispbase, dl);
+ BLI_addtail(r_dispbase, dl);
dl->parts = 1;
dl->nr = len;
dl->col = nu->mat_nr;
@@ -1150,9 +1147,9 @@ static void displist_make_surf(Depsgraph *depsgraph,
else {
const int len = (nu->pntsu * resolu) * (nu->pntsv * resolv);
- DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), "makeDispListsurf");
- dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), "dlverts");
- BLI_addtail(dispbase, dl);
+ DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__);
+ dl->verts = (float *)MEM_mallocN(len * sizeof(float[3]), __func__);
+ BLI_addtail(r_dispbase, dl);
dl->col = nu->mat_nr;
dl->charidx = nu->charidx;
@@ -1177,13 +1174,8 @@ static void displist_make_surf(Depsgraph *depsgraph,
}
}
- if (!for_orco) {
- BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
- curve_calc_modifiers_post(
- depsgraph, scene, ob, dispbase, for_render, force_mesh_conversion, r_final);
- }
-
- BKE_nurbList_free(&nubase);
+ curve_calc_modifiers_post(
+ depsgraph, scene, ob, r_dispbase, for_render, force_mesh_conversion, r_final);
}
static void rotateBevelPiece(const Curve *cu,
@@ -1252,8 +1244,8 @@ static void fillBevelCap(const Nurb *nu,
const float *prev_fp,
ListBase *dispbase)
{
- DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), "makeDispListbev2");
- dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr, "dlverts");
+ DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__);
+ dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr, __func__);
memcpy(dl->verts, prev_fp, sizeof(float[3]) * dlb->nr);
dl->type = DL_POLY;
@@ -1403,67 +1395,47 @@ static void calc_bevfac_mapping(const Curve *cu,
}
}
-static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
- const Scene *scene,
- Object *ob,
- ListBase *dispbase,
- const bool for_render,
- const bool for_orco,
- Mesh **r_final)
+static void evaluate_curve_type_object(Depsgraph *depsgraph,
+ const Scene *scene,
+ Object *ob,
+ const bool for_render,
+ ListBase *r_dispbase,
+ Mesh **r_final)
{
+ BLI_assert(ELEM(ob->type, OB_CURVE, OB_FONT));
const Curve *cu = (const Curve *)ob->data;
- /* we do allow duplis... this is only displist on curve level */
- if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
- return;
- }
-
- if (ob->type == OB_SURF) {
- displist_make_surf(depsgraph, scene, ob, dispbase, r_final, for_render, for_orco);
- return;
- }
-
- ListBase nubase = {nullptr, nullptr};
- bool force_mesh_conversion = false;
-
- BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
-
- /* We only re-evaluate path if evaluation is not happening for orco.
- * If the calculation happens for orco, we should never free data which
- * was needed before and only not needed for orco calculation. */
- if (!for_orco) {
- if (ob->runtime.curve_cache->anim_path_accum_length) {
- MEM_freeN((void *)ob->runtime.curve_cache->anim_path_accum_length);
- }
- ob->runtime.curve_cache->anim_path_accum_length = nullptr;
- }
+ ListBase *deformed_nurbs = &ob->runtime.curve_cache->deformed_nurbs;
if (ob->type == OB_FONT) {
- BKE_vfont_to_curve_nubase(ob, FO_EDIT, &nubase);
+ BKE_vfont_to_curve_nubase(ob, FO_EDIT, deformed_nurbs);
}
else {
- BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(const_cast<Curve *>(cu)));
+ BKE_nurbList_duplicate(deformed_nurbs, BKE_curve_nurbs_get_for_read(cu));
}
- if (!for_orco) {
- force_mesh_conversion = BKE_curve_calc_modifiers_pre(
- depsgraph, scene, ob, &nubase, &nubase, for_render);
- }
+ bool force_mesh_conversion = BKE_curve_calc_modifiers_pre(
+ depsgraph, scene, ob, deformed_nurbs, deformed_nurbs, for_render);
+
+ BKE_curve_bevelList_make(ob, deformed_nurbs, for_render);
- BKE_curve_bevelList_make(ob, &nubase, for_render);
+ if ((cu->flag & CU_PATH) ||
+ DEG_get_eval_flags_for_id(depsgraph, &ob->id) & DAG_EVAL_NEED_CURVE_PATH) {
+ BKE_anim_path_calc_data(ob);
+ }
/* If curve has no bevel will return nothing */
ListBase dlbev = BKE_curve_bevel_make(cu);
/* no bevel or extrude, and no width correction? */
if (BLI_listbase_is_empty(&dlbev) && cu->width == 1.0f) {
- curve_to_displist(cu, &nubase, for_render, dispbase);
+ curve_to_displist(cu, deformed_nurbs, for_render, r_dispbase);
}
else {
const float widfac = cu->width - 1.0f;
- BevList *bl = (BevList *)ob->runtime.curve_cache->bev.first;
- Nurb *nu = (Nurb *)nubase.first;
+ const BevList *bl = (BevList *)ob->runtime.curve_cache->bev.first;
+ const Nurb *nu = (Nurb *)deformed_nurbs->first;
for (; bl && nu; bl = bl->next, nu = nu->next) {
float *data;
@@ -1475,7 +1447,7 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
if (BLI_listbase_is_empty(&dlbev)) {
DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), "makeDispListbev");
dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * bl->nr, "dlverts");
- BLI_addtail(dispbase, dl);
+ BLI_addtail(r_dispbase, dl);
if (bl->poly != -1) {
dl->type = DL_POLY;
@@ -1523,9 +1495,9 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
LISTBASE_FOREACH (DispList *, dlb, &dlbev) {
/* for each part of the bevel use a separate displblock */
- DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), "makeDispListbev1");
- dl->verts = data = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr * steps, "dlverts");
- BLI_addtail(dispbase, dl);
+ DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), __func__);
+ dl->verts = data = (float *)MEM_mallocN(sizeof(float[3]) * dlb->nr * steps, __func__);
+ BLI_addtail(r_dispbase, dl);
dl->type = DL_SURF;
@@ -1621,62 +1593,51 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
}
if (bottom_capbase.first) {
- BKE_displist_fill(&bottom_capbase, dispbase, bottom_no, false);
- BKE_displist_fill(&top_capbase, dispbase, top_no, false);
+ BKE_displist_fill(&bottom_capbase, r_dispbase, bottom_no, false);
+ BKE_displist_fill(&top_capbase, r_dispbase, top_no, false);
BKE_displist_free(&bottom_capbase);
BKE_displist_free(&top_capbase);
}
}
}
- BKE_displist_free(&dlbev);
}
+ BKE_displist_free(&dlbev);
+
if (!(cu->flag & CU_DEFORM_FILL)) {
- curve_to_filledpoly(cu, dispbase);
+ curve_to_filledpoly(cu, r_dispbase);
}
- if (!for_orco) {
- if ((cu->flag & CU_PATH) ||
- DEG_get_eval_flags_for_id(depsgraph, &ob->id) & DAG_EVAL_NEED_CURVE_PATH) {
- BKE_anim_path_calc_data(ob);
- }
-
- BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
- curve_calc_modifiers_post(
- depsgraph, scene, ob, dispbase, for_render, force_mesh_conversion, r_final);
- }
+ curve_calc_modifiers_post(
+ depsgraph, scene, ob, r_dispbase, for_render, force_mesh_conversion, r_final);
if (cu->flag & CU_DEFORM_FILL && !ob->runtime.data_eval) {
- curve_to_filledpoly(cu, dispbase);
+ curve_to_filledpoly(cu, r_dispbase);
}
-
- BKE_nurbList_free(&nubase);
}
void BKE_displist_make_curveTypes(Depsgraph *depsgraph,
const Scene *scene,
Object *ob,
- const bool for_render,
- const bool for_orco)
+ const bool for_render)
{
- /* The same check for duplis as in do_makeDispListCurveTypes.
- * Happens when curve used for constraint/bevel was converted to mesh.
- * check there is still needed for render displist and orco displists. */
- if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
- return;
- }
+ BLI_assert(ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT));
BKE_object_free_derived_caches(ob);
if (!ob->runtime.curve_cache) {
- ob->runtime.curve_cache = (CurveCache *)MEM_callocN(sizeof(CurveCache),
- "CurveCache for curve types");
+ ob->runtime.curve_cache = (CurveCache *)MEM_callocN(sizeof(CurveCache), __func__);
}
ListBase *dispbase = &(ob->runtime.curve_cache->disp);
Mesh *mesh_eval = nullptr;
- do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, for_render, for_orco, &mesh_eval);
+ if (ob->type == OB_SURF) {
+ evaluate_surface_object(depsgraph, scene, ob, for_render, dispbase, &mesh_eval);
+ }
+ else {
+ evaluate_curve_type_object(depsgraph, scene, ob, for_render, dispbase, &mesh_eval);
+ }
if (mesh_eval != nullptr) {
BKE_object_eval_assign_data(ob, &mesh_eval->id, true);
@@ -1685,19 +1646,19 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph,
boundbox_displist_object(ob);
}
-void BKE_displist_make_curveTypes_forRender(Depsgraph *depsgraph,
- const Scene *scene,
- Object *ob,
- ListBase *dispbase,
- const bool for_orco,
- Mesh **r_final)
+void BKE_displist_make_curveTypes_forRender(
+ Depsgraph *depsgraph, const Scene *scene, Object *ob, ListBase *r_dispbase, Mesh **r_final)
{
if (ob->runtime.curve_cache == nullptr) {
- ob->runtime.curve_cache = (CurveCache *)MEM_callocN(sizeof(CurveCache),
- "CurveCache for Curve");
+ ob->runtime.curve_cache = (CurveCache *)MEM_callocN(sizeof(CurveCache), __func__);
}
- do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, true, for_orco, r_final);
+ if (ob->type == OB_SURF) {
+ evaluate_surface_object(depsgraph, scene, ob, true, r_dispbase, r_final);
+ }
+ else {
+ evaluate_curve_type_object(depsgraph, scene, ob, true, r_dispbase, r_final);
+ }
}
void BKE_displist_minmax(const ListBase *dispbase, float min[3], float max[3])
@@ -1730,10 +1691,10 @@ static void boundbox_displist_object(Object *ob)
/* object's BB is calculated from final displist */
if (ob->runtime.bb == nullptr) {
- ob->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), "boundbox");
+ ob->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), __func__);
}
- Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
+ const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval) {
BKE_object_boundbox_calc_from_mesh(ob, mesh_eval);
}
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 788a51257bf..2eb18a06799 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -1757,7 +1757,7 @@ void dynamicPaint_clearSurface(const Scene *scene, DynamicPaintSurface *surface)
}
}
-/* completely (re)initializes surface (only for point cache types)*/
+/* Completely (re)initializes surface (only for point cache types). */
bool dynamicPaint_resetSurface(const Scene *scene, DynamicPaintSurface *surface)
{
int numOfPoints = dynamicPaint_surfaceNumOfPoints(surface);
@@ -4145,7 +4145,7 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
/* mix final sample strength depending on brush settings */
if (hit_found) {
- /* if "negate volume" enabled, negate all factors within volume*/
+ /* If "negate volume" enabled, negate all factors within volume. */
if (brush->collision == MOD_DPAINT_COL_VOLDIST && brush->flags & MOD_DPAINT_NEGATE_VOLUME) {
volume_factor = 1.0f - volume_factor;
if (inner_proximity) {
diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c
index b512309a773..49c2a2cbd89 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -222,7 +222,7 @@ void BKE_editmesh_free_derivedmesh(BMEditMesh *em)
MEM_SAFE_FREE(em->bb_cage);
}
-/*does not free the BMEditMesh struct itself*/
+/* Does not free the #BMEditMesh struct itself. */
void BKE_editmesh_free(BMEditMesh *em)
{
BKE_editmesh_free_derivedmesh(em);
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index e39749225ea..1b628b16802 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -163,7 +163,7 @@ static void precalculate_effector(struct Depsgraph *depsgraph, EffectorCache *ef
if (cu->flag & CU_PATH) {
if (eff->ob->runtime.curve_cache == NULL ||
eff->ob->runtime.curve_cache->anim_path_accum_length == NULL) {
- BKE_displist_make_curveTypes(depsgraph, eff->scene, eff->ob, false, false);
+ BKE_displist_make_curveTypes(depsgraph, eff->scene, eff->ob, false);
}
if (eff->ob->runtime.curve_cache->anim_path_accum_length) {
@@ -716,7 +716,7 @@ int get_effector_data(EffectorCache *eff,
}
else if (eff->pd && eff->pd->shape == PFIELD_SHAPE_POINTS) {
/* TODO: hair and points object support */
- Mesh *me_eval = BKE_object_get_evaluated_mesh(eff->ob);
+ const Mesh *me_eval = BKE_object_get_evaluated_mesh(eff->ob);
if (me_eval != NULL) {
copy_v3_v3(efd->loc, me_eval->mvert[*efd->index].co);
normal_short_to_float_v3(efd->nor, me_eval->mvert[*efd->index].no);
@@ -773,7 +773,7 @@ int get_effector_data(EffectorCache *eff,
/* use center of object for distance calculus */
const Object *ob = eff->ob;
- /* use z-axis as normal*/
+ /* Use z-axis as normal. */
normalize_v3_v3(efd->nor, ob->obmat[2]);
if (eff->pd && ELEM(eff->pd->shape, PFIELD_SHAPE_PLANE, PFIELD_SHAPE_LINE)) {
@@ -830,7 +830,7 @@ static void get_effector_tot(
if (eff->pd->shape == PFIELD_SHAPE_POINTS) {
/* TODO: hair and points object support */
- Mesh *me_eval = BKE_object_get_evaluated_mesh(eff->ob);
+ const Mesh *me_eval = BKE_object_get_evaluated_mesh(eff->ob);
*tot = me_eval != NULL ? me_eval->totvert : 1;
if (*tot && eff->pd->forcefield == PFIELD_HARMONIC && point->index >= 0) {
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 68ed3c239ef..a670e7b9ac5 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -510,8 +510,11 @@ FCurve *BKE_fcurve_find_by_rna_context_ui(bContext *C,
* 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 BKE_fcurve_bezt_binarysearch_index_ex(
- BezTriple array[], float frame, int arraylen, float threshold, bool *r_replace)
+static int BKE_fcurve_bezt_binarysearch_index_ex(const BezTriple array[],
+ const float frame,
+ const int arraylen,
+ const float threshold,
+ bool *r_replace)
{
int start = 0, end = arraylen;
int loopbreaker = 0, maxloop = arraylen * 2;
@@ -597,9 +600,9 @@ static int BKE_fcurve_bezt_binarysearch_index_ex(
/* Binary search algorithm for finding where to insert BezTriple. (for use by insert_bezt_fcurve)
* Returns the index to insert at (data already at that index will be offset if replace is 0)
*/
-int BKE_fcurve_bezt_binarysearch_index(BezTriple array[],
- float frame,
- int arraylen,
+int BKE_fcurve_bezt_binarysearch_index(const BezTriple array[],
+ const float frame,
+ const int arraylen,
bool *r_replace)
{
/* This is just a wrapper which uses the default threshold. */
@@ -1309,7 +1312,7 @@ void calchandles_fcurve_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag)
* - Need bezier keys.
* - Only bezier-interpolation has handles (for now).
*/
- if (ELEM(NULL, fcu, fcu->bezt) || (a < 2) /*|| ELEM(fcu->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN)*/) {
+ if (ELEM(NULL, fcu, fcu->bezt) || (a < 2) /*|| ELEM(fcu->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN) */) {
return;
}
@@ -2191,9 +2194,9 @@ float evaluate_fcurve(FCurve *fcu, float evaltime)
float evaluate_fcurve_only_curve(FCurve *fcu, float evaltime)
{
- /* Can be used to evaluate the (keyframed) fcurve only.
- * Also works for driver-fcurves when the driver itself is not relevant.
- * E.g. when inserting a keyframe in a driver fcurve. */
+ /* Can be used to evaluate the (key-framed) f-curve only.
+ * Also works for driver-f-curves when the driver itself is not relevant.
+ * E.g. when inserting a keyframe in a driver f-curve. */
return evaluate_fcurve_ex(fcu, evaltime, 0.0);
}
@@ -2322,7 +2325,7 @@ void BKE_fmodifiers_blend_write(BlendWriter *writer, ListBase *fmodifiers)
FMod_Python *data = fcm->data;
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
+ * of library blocks that implement this. */
IDP_BlendWrite(writer, data->prop);
break;
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 553575b5c7b..947417af55d 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4395,7 +4395,7 @@ static void manta_smoke_calc_transparency(FluidDomainSettings *fds, ViewLayer *v
int cell[3];
float t_ray = 1.0;
- /* Reset shadow value.*/
+ /* Reset shadow value. */
shadow[index] = -1.0f;
voxel_center[0] = (float)x;
@@ -5023,7 +5023,7 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData *fmd,
/* viscosity options */
tfds->viscosity_value = fds->viscosity_value;
- /* diffusion options*/
+ /* Diffusion options. */
tfds->surface_tension = fds->surface_tension;
tfds->viscosity_base = fds->viscosity_base;
tfds->viscosity_exponent = fds->viscosity_exponent;
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 8d1e6b26d4d..b9f0b97ab46 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -875,7 +875,7 @@ static void fcm_python_new_data(void *mdata)
{
FMod_Python *data = (FMod_Python *)mdata;
- /* everything should be set correctly by calloc, except for the prop->type constant.*/
+ /* Everything should be set correctly by calloc, except for the prop->type constant. */
data->prop = MEM_callocN(sizeof(IDProperty), "PyFModifierProps");
data->prop->type = IDP_GROUP;
}
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 92cc3c763b6..8bb2c401b03 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -216,15 +216,15 @@ void BKE_vfont_free_data(struct VFont *vfont)
}
}
-static void *builtin_font_data = NULL;
+static const void *builtin_font_data = NULL;
static int builtin_font_size = 0;
-bool BKE_vfont_is_builtin(struct VFont *vfont)
+bool BKE_vfont_is_builtin(const struct VFont *vfont)
{
return STREQ(vfont->filepath, FO_BUILTIN_NAME);
}
-void BKE_vfont_builtin_register(void *mem, int size)
+void BKE_vfont_builtin_register(const void *mem, int size)
{
builtin_font_data = mem;
builtin_font_size = size;
@@ -1271,7 +1271,7 @@ static bool vfont_to_curve(Object *ob,
MEM_freeN(i_textbox_array);
/* TEXT ON CURVE */
- /* Note: Only OB_CURVE objects could have a path */
+ /* NOTE: Only OB_CURVE objects could have a path. */
if (cu->textoncurve && cu->textoncurve->type == OB_CURVE) {
BLI_assert(cu->textoncurve->runtime.curve_cache != NULL);
if (cu->textoncurve->runtime.curve_cache != NULL &&
@@ -1746,7 +1746,7 @@ void BKE_vfont_clipboard_set(const char32_t *text_buf, const CharInfo *info_buf,
char32_t *text;
CharInfo *info;
- /* clean previous buffers*/
+ /* Clean previous buffers. */
BKE_vfont_clipboard_free();
text = MEM_malloc_arrayN((len + 1), sizeof(*text), __func__);
diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc
index 42f3a854aec..28e46aab732 100644
--- a/source/blender/blenkernel/intern/geometry_component_mesh.cc
+++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc
@@ -29,7 +29,7 @@
#include "attribute_access_intern.hh"
-/* Can't include BKE_object_deform.h right now, due to an enum forward declaration. */
+/* Can't include BKE_object_deform.h right now, due to an enum forward declaration. */
extern "C" MDeformVert *BKE_object_defgroup_data_create(ID *id);
using blender::fn::GVArray;
diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc
index 3d85118deee..07b4e715ea9 100644
--- a/source/blender/blenkernel/intern/geometry_set.cc
+++ b/source/blender/blenkernel/intern/geometry_set.cc
@@ -199,20 +199,6 @@ std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set)
return stream;
}
-/* This generally should not be used. It is necessary currently, so that GeometrySet can by used by
- * the CPPType system. */
-bool operator==(const GeometrySet &UNUSED(a), const GeometrySet &UNUSED(b))
-{
- return false;
-}
-
-/* This generally should not be used. It is necessary currently, so that GeometrySet can by used by
- * the CPPType system. */
-uint64_t GeometrySet::hash() const
-{
- return reinterpret_cast<uint64_t>(this);
-}
-
/* Remove all geometry components from the geometry set. */
void GeometrySet::clear()
{
diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc
index 8cf08d05d9d..01b51d552a9 100644
--- a/source/blender/blenkernel/intern/geometry_set_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_set_instances.cc
@@ -56,7 +56,7 @@ static void add_curve_data_as_geometry_component(const Object &object, GeometryS
{
BLI_assert(object.type == OB_CURVE);
if (object.data != nullptr) {
- std::unique_ptr<CurveEval> curve = curve_eval_from_dna_curve(*(Curve *)object.data);
+ std::unique_ptr<CurveEval> curve = curve_eval_from_dna_curve(*(const Curve *)object.data);
CurveComponent &curve_component = geometry_set.get_component_for_write<CurveComponent>();
curve_component.replace(curve.release(), GeometryOwnershipType::Owned);
}
@@ -264,7 +264,7 @@ static bool instances_attribute_foreach_recursive(const GeometrySet &geometry_se
}
}
- /* Now that this this geometry set is visited, increase the count and check with the limit. */
+ /* Now that this geometry set is visited, increase the count and check with the limit. */
if (limit > 0 && count++ > limit) {
return false;
}
@@ -535,7 +535,7 @@ static void join_attributes(Span<GeometryInstanceGroup> set_groups,
const void *src_buffer = src_span.data();
for (const int UNUSED(i) : set_group.transforms.index_range()) {
void *dst_buffer = dst_span[offset];
- cpp_type->copy_to_initialized_n(src_buffer, dst_buffer, domain_size);
+ cpp_type->copy_assign_n(src_buffer, dst_buffer, domain_size);
offset += domain_size;
}
}
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index a66c3cf3573..459fc5e4c68 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -195,12 +195,12 @@ static void greasepencil_blend_write(BlendWriter *writer, ID *id, const void *id
void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd)
{
- /* we must firstly have some grease-pencil data to link! */
+ /* We must firstly have some grease-pencil data to link! */
if (gpd == NULL) {
return;
}
- /* relink animdata */
+ /* Relink anim-data. */
BLO_read_data_address(reader, &gpd->adt);
BKE_animdata_blend_read_data(reader, gpd->adt);
@@ -219,7 +219,7 @@ void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd)
gpd->runtime.sbuffer_size = 0;
gpd->runtime.tot_cp_points = 0;
- /* relink palettes (old palettes deprecated, only to convert old files) */
+ /* Relink palettes (old palettes deprecated, only to convert old files). */
BLO_read_list(reader, &gpd->palettes);
if (gpd->palettes.first != NULL) {
LISTBASE_FOREACH (bGPDpalette *, palette, &gpd->palettes) {
@@ -227,14 +227,14 @@ void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd)
}
}
- /* materials */
+ /* Materials. */
BLO_read_pointer_array(reader, (void **)&gpd->mat);
- /* relink layers */
+ /* Relink layers. */
BLO_read_list(reader, &gpd->layers);
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
- /* relink frames */
+ /* Relink frames. */
BLO_read_list(reader, &gpl->frames);
BLO_read_data_address(reader, &gpl->actframe);
@@ -245,23 +245,23 @@ void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd)
BLO_read_list(reader, &gpl->mask_layers);
LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
- /* relink strokes (and their points) */
+ /* Relink strokes (and their points). */
BLO_read_list(reader, &gpf->strokes);
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- /* relink stroke points array */
+ /* Relink stroke points array. */
BLO_read_data_address(reader, &gps->points);
- /* Relink geometry*/
+ /* Relink geometry. */
BLO_read_data_address(reader, &gps->triangles);
- /* relink stroke edit curve. */
+ /* Relink stroke edit curve. */
BLO_read_data_address(reader, &gps->editcurve);
if (gps->editcurve != NULL) {
- /* relink curve point array */
+ /* Relink curve point array. */
BLO_read_data_address(reader, &gps->editcurve->curve_points);
}
- /* relink weight data */
+ /* Relink weight data. */
if (gps->dvert) {
BLO_read_data_address(reader, &gps->dvert);
BKE_defvert_blend_read(reader, gps->totpoints, gps->dvert);
@@ -458,7 +458,7 @@ void BKE_gpencil_free_frames(bGPDlayer *gpl)
void BKE_gpencil_free_layer_masks(bGPDlayer *gpl)
{
- /* Free masks.*/
+ /* Free masks. */
bGPDlayer_Mask *mask_next = NULL;
for (bGPDlayer_Mask *mask = gpl->mask_layers.first; mask; mask = mask_next) {
mask_next = mask->next;
@@ -482,7 +482,7 @@ void BKE_gpencil_free_layers(ListBase *list)
/* free layers and their data */
BKE_gpencil_free_frames(gpl);
- /* Free masks.*/
+ /* Free masks. */
BKE_gpencil_free_layer_masks(gpl);
BLI_freelinkN(list, gpl);
@@ -1076,12 +1076,7 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src,
gpl_dst->prev = gpl_dst->next = NULL;
/* Copy masks. */
- BLI_listbase_clear(&gpl_dst->mask_layers);
- LISTBASE_FOREACH (bGPDlayer_Mask *, mask_src, &gpl_src->mask_layers) {
- bGPDlayer_Mask *mask_dst = MEM_dupallocN(mask_src);
- mask_dst->prev = mask_dst->next = NULL;
- BLI_addtail(&gpl_dst->mask_layers, mask_dst);
- }
+ BKE_gpencil_layer_mask_copy(gpl_src, gpl_dst);
/* copy frames */
BLI_listbase_clear(&gpl_dst->frames);
@@ -1122,13 +1117,8 @@ void BKE_gpencil_layer_copy_settings(const bGPDlayer *gpl_src, bGPDlayer *gpl_ds
copy_v3_v3(gpl_dst->scale, gpl_src->scale);
copy_m4_m4(gpl_dst->layer_mat, gpl_src->layer_mat);
copy_m4_m4(gpl_dst->layer_invmat, gpl_src->layer_invmat);
- /* Use Lights flag. */
- if (gpl_src->flag & GP_LAYER_USE_LIGHTS) {
- gpl_dst->flag |= GP_LAYER_USE_LIGHTS;
- }
- else {
- gpl_dst->flag &= ~GP_LAYER_USE_LIGHTS;
- }
+ gpl_dst->blend_mode = gpl_src->blend_mode;
+ gpl_dst->flag = gpl_src->flag;
}
/**
@@ -1647,6 +1637,41 @@ void BKE_gpencil_layer_mask_sort_all(bGPdata *gpd)
}
}
+/**
+ * Make a copy of a given gpencil mask layers.
+ */
+void BKE_gpencil_layer_mask_copy(const bGPDlayer *gpl_src, bGPDlayer *gpl_dst)
+{
+ BLI_listbase_clear(&gpl_dst->mask_layers);
+ LISTBASE_FOREACH (bGPDlayer_Mask *, mask_src, &gpl_src->mask_layers) {
+ bGPDlayer_Mask *mask_dst = MEM_dupallocN(mask_src);
+ mask_dst->prev = mask_dst->next = NULL;
+ BLI_addtail(&gpl_dst->mask_layers, mask_dst);
+ }
+}
+
+/**
+ * Clean any invalid mask layer.
+ */
+void BKE_gpencil_layer_mask_cleanup(bGPdata *gpd, bGPDlayer *gpl)
+{
+ LISTBASE_FOREACH_MUTABLE (bGPDlayer_Mask *, mask, &gpl->mask_layers) {
+ if (BKE_gpencil_layer_named_get(gpd, mask->name) == NULL) {
+ BKE_gpencil_layer_mask_remove(gpl, mask);
+ }
+ }
+}
+
+/**
+ * Clean any invalid mask layer for all layers.
+ */
+void BKE_gpencil_layer_mask_cleanup_all_layers(bGPdata *gpd)
+{
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ BKE_gpencil_layer_mask_cleanup(gpd, gpl);
+ }
+}
+
static int gpencil_cb_cmp_frame(void *thunk, const void *a, const void *b)
{
const bGPDframe *frame_a = a;
diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c
index 906d0fb0792..344be7bc0f5 100644
--- a/source/blender/blenkernel/intern/gpencil_curve.c
+++ b/source/blender/blenkernel/intern/gpencil_curve.c
@@ -242,8 +242,8 @@ static int gpencil_get_stroke_material_fromcurve(
float color_fill[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* If the curve has 2 materials, the first is considered as Fill and the second as Stroke.
- * If the has only one material, if the name contains _stroke, the is used
- * as stroke, else as fill.*/
+ * If the has only one material, if the name contains "_stroke",
+ * it's used as a stroke, otherwise as fill. */
if (ob_cu->totcol >= 2) {
*do_stroke = true;
*do_fill = true;
@@ -350,7 +350,7 @@ static void gpencil_convert_spline(Main *bmain,
/* Assign material index to stroke. */
gps->mat_nr = r_idx;
- /* Add stroke to frame.*/
+ /* Add stroke to frame. */
BLI_addtail(&gpf->strokes, gps);
float *coord_array = NULL;
diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index 982fc2abd65..077c1a65243 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -793,6 +793,7 @@ bool BKE_gpencil_stroke_smooth(bGPDstroke *gps, int i, float inf)
{
bGPDspoint *pt = &gps->points[i];
float sco[3] = {0.0f};
+ const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
/* Do nothing if not enough points to smooth out */
if (gps->totpoints <= 2) {
@@ -802,7 +803,7 @@ bool BKE_gpencil_stroke_smooth(bGPDstroke *gps, int i, float inf)
/* Only affect endpoints by a fraction of the normal strength,
* to prevent the stroke from shrinking too much
*/
- if (ELEM(i, 0, gps->totpoints - 1)) {
+ if (!is_cyclic && ELEM(i, 0, gps->totpoints - 1)) {
inf *= 0.1f;
}
@@ -828,8 +829,22 @@ bool BKE_gpencil_stroke_smooth(bGPDstroke *gps, int i, float inf)
int before = i - step;
int after = i + step;
- CLAMP_MIN(before, 0);
- CLAMP_MAX(after, gps->totpoints - 1);
+ if (is_cyclic) {
+ if (before < 0) {
+ /* Sub to end point (before is already negative). */
+ before = gps->totpoints + before;
+ CLAMP(before, 0, gps->totpoints - 1);
+ }
+ if (after > gps->totpoints - 1) {
+ /* Add to start point. */
+ after = after - gps->totpoints;
+ CLAMP(after, 0, gps->totpoints - 1);
+ }
+ }
+ else {
+ CLAMP_MIN(before, 0);
+ CLAMP_MAX(after, gps->totpoints - 1);
+ }
pt1 = &gps->points[before];
pt2 = &gps->points[after];
@@ -855,6 +870,7 @@ bool BKE_gpencil_stroke_smooth(bGPDstroke *gps, int i, float inf)
bool BKE_gpencil_stroke_smooth_strength(bGPDstroke *gps, int point_index, float influence)
{
bGPDspoint *ptb = &gps->points[point_index];
+ const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
/* Do nothing if not enough points */
if ((gps->totpoints <= 2) || (point_index < 1)) {
@@ -862,7 +878,7 @@ bool BKE_gpencil_stroke_smooth_strength(bGPDstroke *gps, int point_index, float
}
/* Only affect endpoints by a fraction of the normal influence */
float inf = influence;
- if (ELEM(point_index, 0, gps->totpoints - 1)) {
+ if (!is_cyclic && ELEM(point_index, 0, gps->totpoints - 1)) {
inf *= 0.01f;
}
/* Limit max influence to reduce pop effect. */
@@ -884,9 +900,22 @@ bool BKE_gpencil_stroke_smooth_strength(bGPDstroke *gps, int point_index, float
int before = point_index - step;
int after = point_index + step;
- CLAMP_MIN(before, 0);
- CLAMP_MAX(after, gps->totpoints - 1);
-
+ if (is_cyclic) {
+ if (before < 0) {
+ /* Sub to end point (before is already negative). */
+ before = gps->totpoints + before;
+ CLAMP(before, 0, gps->totpoints - 1);
+ }
+ if (after > gps->totpoints - 1) {
+ /* Add to start point. */
+ after = after - gps->totpoints;
+ CLAMP(after, 0, gps->totpoints - 1);
+ }
+ }
+ else {
+ CLAMP_MIN(before, 0);
+ CLAMP_MAX(after, gps->totpoints - 1);
+ }
pt1 = &gps->points[before];
pt2 = &gps->points[after];
@@ -919,6 +948,7 @@ bool BKE_gpencil_stroke_smooth_strength(bGPDstroke *gps, int point_index, float
bool BKE_gpencil_stroke_smooth_thickness(bGPDstroke *gps, int point_index, float influence)
{
bGPDspoint *ptb = &gps->points[point_index];
+ const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
/* Do nothing if not enough points */
if ((gps->totpoints <= 2) || (point_index < 1)) {
@@ -926,7 +956,7 @@ bool BKE_gpencil_stroke_smooth_thickness(bGPDstroke *gps, int point_index, float
}
/* Only affect endpoints by a fraction of the normal influence */
float inf = influence;
- if (ELEM(point_index, 0, gps->totpoints - 1)) {
+ if (!is_cyclic && ELEM(point_index, 0, gps->totpoints - 1)) {
inf *= 0.01f;
}
/* Limit max influence to reduce pop effect. */
@@ -948,9 +978,22 @@ bool BKE_gpencil_stroke_smooth_thickness(bGPDstroke *gps, int point_index, float
int before = point_index - step;
int after = point_index + step;
- CLAMP_MIN(before, 0);
- CLAMP_MAX(after, gps->totpoints - 1);
-
+ if (is_cyclic) {
+ if (before < 0) {
+ /* Sub to end point (before is already negative). */
+ before = gps->totpoints + before;
+ CLAMP(before, 0, gps->totpoints - 1);
+ }
+ if (after > gps->totpoints - 1) {
+ /* Add to start point. */
+ after = after - gps->totpoints;
+ CLAMP(after, 0, gps->totpoints - 1);
+ }
+ }
+ else {
+ CLAMP_MIN(before, 0);
+ CLAMP_MAX(after, gps->totpoints - 1);
+ }
pt1 = &gps->points[before];
pt2 = &gps->points[after];
@@ -982,6 +1025,7 @@ bool BKE_gpencil_stroke_smooth_thickness(bGPDstroke *gps, int point_index, float
bool BKE_gpencil_stroke_smooth_uv(bGPDstroke *gps, int point_index, float influence)
{
bGPDspoint *ptb = &gps->points[point_index];
+ const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
/* Do nothing if not enough points */
if (gps->totpoints <= 2) {
@@ -993,9 +1037,22 @@ bool BKE_gpencil_stroke_smooth_uv(bGPDstroke *gps, int point_index, float influe
int before = point_index - 1;
int after = point_index + 1;
- CLAMP_MIN(before, 0);
- CLAMP_MAX(after, gps->totpoints - 1);
-
+ if (is_cyclic) {
+ if (before < 0) {
+ /* Sub to end point (before is already negative). */
+ before = gps->totpoints + before;
+ CLAMP(before, 0, gps->totpoints - 1);
+ }
+ if (after > gps->totpoints - 1) {
+ /* Add to start point. */
+ after = after - gps->totpoints;
+ CLAMP(after, 0, gps->totpoints - 1);
+ }
+ }
+ else {
+ CLAMP_MIN(before, 0);
+ CLAMP_MAX(after, gps->totpoints - 1);
+ }
pta = &gps->points[before];
ptc = &gps->points[after];
@@ -1993,7 +2050,7 @@ void BKE_gpencil_stroke_subdivide(bGPdata *gpd, bGPDstroke *gps, int level, int
MEM_SAFE_FREE(temp_points);
MEM_SAFE_FREE(temp_dverts);
- /* move points to smooth stroke (not simple type )*/
+ /* Move points to smooth stroke (not simple type). */
if (type != GP_SUBDIV_SIMPLE) {
/* duplicate points in a temp area with the new subdivide data */
temp_points = MEM_dupallocN(gps->points);
@@ -2076,7 +2133,7 @@ void BKE_gpencil_stroke_merge_distance(bGPdata *gpd,
else {
pt->flag |= GP_SPOINT_TAG;
}
- /* Jump to next pair of points, keeping first point segment equals.*/
+ /* Jump to next pair of points, keeping first point segment equals. */
step++;
}
else {
@@ -2423,9 +2480,9 @@ bool BKE_gpencil_convert_mesh(Main *bmain,
/* Use evaluated data to get mesh with all modifiers on top. */
Object *ob_eval = (Object *)DEG_get_evaluated_object(depsgraph, ob_mesh);
- Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
- MPoly *mp, *mpoly = me_eval->mpoly;
- MLoop *mloop = me_eval->mloop;
+ const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
+ const MPoly *mpoly = me_eval->mpoly;
+ const MLoop *mloop = me_eval->mloop;
int mpoly_len = me_eval->totpoly;
char element_name[200];
@@ -2458,8 +2515,9 @@ bool BKE_gpencil_convert_mesh(Main *bmain,
bGPDframe *gpf_fill = BKE_gpencil_layer_frame_get(
gpl_fill, CFRA + frame_offset, GP_GETFRAME_ADD_NEW);
int i;
- for (i = 0, mp = mpoly; i < mpoly_len; i++, mp++) {
- MLoop *ml = &mloop[mp->loopstart];
+ for (i = 0; i < mpoly_len; i++) {
+ const MPoly *mp = &mpoly[i];
+
/* Find material. */
int mat_idx = 0;
Material *ma = BKE_object_material_get(ob_mesh, mp->mat_nr + 1);
@@ -2482,8 +2540,10 @@ bool BKE_gpencil_convert_mesh(Main *bmain,
gps_fill->flag |= GP_STROKE_CYCLIC;
/* Add points to strokes. */
- for (int j = 0; j < mp->totloop; j++, ml++) {
- MVert *mv = &me_eval->mvert[ml->v];
+ for (int j = 0; j < mp->totloop; j++) {
+ const MLoop *ml = &mloop[mp->loopstart + j];
+ const MVert *mv = &me_eval->mvert[ml->v];
+
bGPDspoint *pt = &gps_fill->points[j];
copy_v3_v3(&pt->x, mv->co);
mul_m4_v3(matrix, &pt->x);
@@ -2559,7 +2619,7 @@ void BKE_gpencil_transform(bGPdata *gpd, const float mat[4][4])
}
/* Used for "move only origins" in object_data_transform.c */
-int BKE_gpencil_stroke_point_count(bGPdata *gpd)
+int BKE_gpencil_stroke_point_count(const bGPdata *gpd)
{
int total_points = 0;
@@ -2567,7 +2627,7 @@ int BKE_gpencil_stroke_point_count(bGPdata *gpd)
return 0;
}
- LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ LISTBASE_FOREACH (const bGPDlayer *, gpl, &gpd->layers) {
/* FIXME: For now, we just skip parented layers.
* Otherwise, we have to update each frame to find
* the current parent position/effects.
@@ -2576,7 +2636,7 @@ int BKE_gpencil_stroke_point_count(bGPdata *gpd)
continue;
}
- LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
+ LISTBASE_FOREACH (const bGPDframe *, gpf, &gpl->frames) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
total_points += gps->totpoints;
}
@@ -2811,7 +2871,7 @@ static void gpencil_stroke_join_islands(bGPdata *gpd,
MDeformVert *dvert_src = NULL;
MDeformVert *dvert_dst = NULL;
- /* Copy weights (last before)*/
+ /* Copy weights (last before). */
e1 = 0;
e2 = 0;
for (int i = 0; i < totpoints; i++) {
@@ -3751,11 +3811,11 @@ static ListBase *gpencil_stroke_perimeter_ex(const bGPdata *gpd,
last_prev_pt[0] -= 1.0f;
}
- /* generate points for start cap */
+ /* Generate points for start cap. */
num_perimeter_points += generate_perimeter_cap(
first_pt, first_next_pt, first_radius, perimeter_right_side, subdivisions, gps->caps[0]);
- /* generate perimeter points */
+ /* Generate perimeter points. */
float curr_pt[3], next_pt[3], prev_pt[3];
float vec_next[2], vec_prev[2];
float nvec_next[2], nvec_prev[2];
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 58715ac2e05..a67e78ceea0 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -54,15 +54,15 @@
static CLG_LogRef LOG = {"bke.idprop"};
-/*local size table.*/
+/* Local size table. */
static size_t idp_size_table[] = {
1, /*strings*/
sizeof(int),
sizeof(float),
- sizeof(float[3]), /*Vector type, deprecated*/
- sizeof(float[16]), /*Matrix type, deprecated*/
- 0, /*arrays don't have a fixed size*/
- sizeof(ListBase), /*Group type*/
+ sizeof(float[3]), /* Vector type, deprecated. */
+ sizeof(float[16]), /* Matrix type, deprecated. */
+ 0, /* Arrays don't have a fixed size. */
+ sizeof(ListBase), /* Group type. */
sizeof(void *),
sizeof(double),
};
@@ -99,12 +99,12 @@ IDProperty *IDP_CopyIDPArray(const IDProperty *array, const int flag)
narray->data.pointer = MEM_dupallocN(array->data.pointer);
for (int i = 0; i < narray->len; i++) {
- /* ok, the copy functions always allocate a new structure,
+ /* OK, the copy functions always allocate a new structure,
* which doesn't work here. instead, simply copy the
* contents of the new structure into the array cell,
* then free it. this makes for more maintainable
* code than simply re-implementing the copy functions
- * in this loop.*/
+ * in this loop. */
IDProperty *tmp = IDP_CopyProperty_ex(GETPROP(narray, i), flag);
memcpy(GETPROP(narray, i), tmp, sizeof(IDProperty));
MEM_freeN(tmp);
@@ -228,7 +228,7 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
}
}
-/*this function works for strings too!*/
+/* This function works for strings too! */
void IDP_ResizeArray(IDProperty *prop, int newlen)
{
const bool is_grow = newlen >= prop->len;
@@ -390,8 +390,8 @@ void IDP_ConcatStringC(IDProperty *prop, const char *st)
BLI_assert(prop->type == IDP_STRING);
int newlen = prop->len + (int)strlen(st);
- /* we have to remember that prop->len includes the null byte for strings.
- * so there's no need to add +1 to the resize function.*/
+ /* We have to remember that prop->len includes the null byte for strings.
+ * so there's no need to add +1 to the resize function. */
IDP_ResizeArray(prop, newlen);
strcat(prop->data.pointer, st);
}
@@ -400,8 +400,8 @@ void IDP_ConcatString(IDProperty *str1, IDProperty *append)
{
BLI_assert(append->type == IDP_STRING);
- /* since ->len for strings includes the NULL byte, we have to subtract one or
- * we'll get an extra null byte after each concatenation operation.*/
+ /* Since ->len for strings includes the NULL byte, we have to subtract one or
+ * we'll get an extra null byte after each concatenation operation. */
int newlen = str1->len + append->len - 1;
IDP_ResizeArray(str1, newlen);
strcat(str1->data.pointer, append->data.pointer);
@@ -775,10 +775,10 @@ IDProperty *IDP_GetProperties(ID *id, const bool create_if_needed)
if (create_if_needed) {
id->properties = MEM_callocN(sizeof(IDProperty), "IDProperty");
id->properties->type = IDP_GROUP;
- /* don't overwrite the data's name and type
+ /* NOTE(campbell): Don't overwrite the data's name and type
* some functions might need this if they
- * don't have a real ID, should be named elsewhere - Campbell */
- /* strcpy(id->name, "top_level_group");*/
+ * don't have a real ID, should be named elsewhere. */
+ // strcpy(id->name, "top_level_group");
}
return id->properties;
}
@@ -1106,7 +1106,7 @@ void IDP_WriteProperty_OnlyData(const IDProperty *prop, BlendWriter *writer);
static void IDP_WriteArray(const IDProperty *prop, BlendWriter *writer)
{
- /*REMEMBER to set totalen to len in the linking code!!*/
+ /* Remember to set #IDProperty.totallen to len in the linking code! */
if (prop->data.pointer) {
BLO_write_raw(writer, MEM_allocN_len(prop->data.pointer), prop->data.pointer);
@@ -1123,7 +1123,7 @@ static void IDP_WriteArray(const IDProperty *prop, BlendWriter *writer)
static void IDP_WriteIDPArray(const IDProperty *prop, BlendWriter *writer)
{
- /*REMEMBER to set totalen to len in the linking code!!*/
+ /* Remember to set #IDProperty.totallen to len in the linking code! */
if (prop->data.pointer) {
const IDProperty *array = prop->data.pointer;
@@ -1137,7 +1137,7 @@ static void IDP_WriteIDPArray(const IDProperty *prop, BlendWriter *writer)
static void IDP_WriteString(const IDProperty *prop, BlendWriter *writer)
{
- /*REMEMBER to set totalen to len in the linking code!!*/
+ /* Remember to set #IDProperty.totallen to len in the linking code! */
BLO_write_raw(writer, (size_t)prop->len, prop->data.pointer);
}
@@ -1219,7 +1219,7 @@ static void IDP_DirectLinkArray(IDProperty *prop, BlendDataReader *reader)
static void IDP_DirectLinkString(IDProperty *prop, BlendDataReader *reader)
{
- /*since we didn't save the extra string buffer, set totallen to len.*/
+ /* Since we didn't save the extra string buffer, set totallen to len. */
prop->totallen = prop->len;
BLO_read_data_address(reader, &prop->data.pointer);
}
@@ -1230,7 +1230,7 @@ static void IDP_DirectLinkGroup(IDProperty *prop, BlendDataReader *reader)
BLO_read_list(reader, lb);
- /*Link child id properties now*/
+ /* Link child id properties now. */
LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) {
IDP_DirectLinkProperty(loop, reader);
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 7a3619154a6..740c9b3864c 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1056,9 +1056,11 @@ Image *BKE_image_add_generated(Main *bmain,
return ima;
}
-/* Create an image image from ibuf. The refcount of ibuf is increased,
+/**
+ * Create an image from ibuf. The refcount of ibuf is increased,
* caller should take care to drop its reference by calling
- * IMB_freeImBuf if needed. */
+ * #IMB_freeImBuf if needed.
+ */
Image *BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name)
{
/* on save, type is changed to FILE in editsima.c */
@@ -3208,7 +3210,7 @@ Image *BKE_image_ensure_viewer(Main *bmain, int type, const char *name)
ima = image_alloc(bmain, name, IMA_SRC_VIEWER, type);
}
- /* happens on reload, imagewindow cannot be image user when hidden*/
+ /* Happens on reload, imagewindow cannot be image user when hidden. */
if (ima->id.us == 0) {
id_us_ensure_real(&ima->id);
}
@@ -4349,7 +4351,7 @@ static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const i
BKE_image_user_file_path(&iuser_t, ima, str);
- /* FIXME: make several stream accessible in image editor, too*/
+ /* FIXME: make several stream accessible in image editor, too. */
ia->anim = openanim(str, flags, 0, ima->colorspace_settings.name);
/* let's initialize this user */
@@ -5188,7 +5190,7 @@ bool BKE_image_has_ibuf(Image *ima, ImageUser *iuser)
return ibuf != NULL;
}
-/* ******** Pool for image buffers ******** */
+/* ******** Pool for image buffers ******** */
typedef struct ImagePoolItem {
struct ImagePoolItem *next, *prev;
diff --git a/source/blender/blenkernel/intern/image_save.c b/source/blender/blenkernel/intern/image_save.c
index e571499ba8e..b68cd9e4d2d 100644
--- a/source/blender/blenkernel/intern/image_save.c
+++ b/source/blender/blenkernel/intern/image_save.c
@@ -207,7 +207,7 @@ static bool image_save_single(ReportList *reports,
goto cleanup;
}
- /* it shouldn't ever happen*/
+ /* It shouldn't ever happen. */
if ((BLI_findstring(&rr->views, STEREO_LEFT_NAME, offsetof(RenderView, name)) == NULL) ||
(BLI_findstring(&rr->views, STEREO_RIGHT_NAME, offsetof(RenderView, name)) == NULL)) {
BKE_reportf(reports,
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index bdc763cf4ca..f365e759221 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -262,7 +262,7 @@ static AdrBit2Path *adrcode_bitmaps_to_paths(int blocktype, int adrcode, int *to
/* Object types */
static const char *ob_adrcodes_to_paths(int adrcode, int *array_index)
{
- /* set array index like this in-case nothing sets it correctly */
+ /* Set array index like this in-case nothing sets it correctly. */
*array_index = 0;
/* result depends on adrcode */
@@ -377,7 +377,7 @@ static const char *ob_adrcodes_to_paths(int adrcode, int *array_index)
*/
static const char *pchan_adrcodes_to_paths(int adrcode, int *array_index)
{
- /* set array index like this in-case nothing sets it correctly */
+ /* Set array index like this in-case nothing sets it correctly. */
*array_index = 0;
/* result depends on adrcode */
@@ -434,7 +434,7 @@ static const char *pchan_adrcodes_to_paths(int adrcode, int *array_index)
/* Constraint types */
static const char *constraint_adrcodes_to_paths(int adrcode, int *array_index)
{
- /* set array index like this in-case nothing sets it correctly */
+ /* Set array index like this in-case nothing sets it correctly. */
*array_index = 0;
/* result depends on adrcode */
@@ -605,7 +605,7 @@ static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index))
/* Texture types */
static const char *texture_adrcodes_to_paths(int adrcode, int *array_index)
{
- /* set array index like this in-case nothing sets it correctly */
+ /* Set array index like this in-case nothing sets it correctly. */
*array_index = 0;
/* result depends on adrcode */
@@ -692,7 +692,7 @@ static const char *texture_adrcodes_to_paths(int adrcode, int *array_index)
/* Material Types */
static const char *material_adrcodes_to_paths(int adrcode, int *array_index)
{
- /* set array index like this in-case nothing sets it correctly */
+ /* Set array index like this in-case nothing sets it correctly. */
*array_index = 0;
/* result depends on adrcode */
@@ -785,7 +785,7 @@ static const char *material_adrcodes_to_paths(int adrcode, int *array_index)
/* Camera Types */
static const char *camera_adrcodes_to_paths(int adrcode, int *array_index)
{
- /* set array index like this in-case nothing sets it correctly */
+ /* Set array index like this in-case nothing sets it correctly. */
*array_index = 0;
/* result depends on adrcode */
@@ -830,7 +830,7 @@ static const char *camera_adrcodes_to_paths(int adrcode, int *array_index)
/* Light Types */
static const char *light_adrcodes_to_paths(int adrcode, int *array_index)
{
- /* set array index like this in-case nothing sets it correctly */
+ /* Set array index like this in-case nothing sets it correctly. */
*array_index = 0;
/* result depends on adrcode */
@@ -875,7 +875,7 @@ static const char *light_adrcodes_to_paths(int adrcode, int *array_index)
/* Sound Types */
static const char *sound_adrcodes_to_paths(int adrcode, int *array_index)
{
- /* set array index like this in-case nothing sets it correctly */
+ /* Set array index like this in-case nothing sets it correctly. */
*array_index = 0;
/* result depends on adrcode */
@@ -901,7 +901,7 @@ static const char *sound_adrcodes_to_paths(int adrcode, int *array_index)
/* World Types */
static const char *world_adrcodes_to_paths(int adrcode, int *array_index)
{
- /* set array index like this in-case nothing sets it correctly */
+ /* Set array index like this in-case nothing sets it correctly. */
*array_index = 0;
/* result depends on adrcode */
@@ -947,7 +947,7 @@ static const char *world_adrcodes_to_paths(int adrcode, int *array_index)
/* Particle Types */
static const char *particle_adrcodes_to_paths(int adrcode, int *array_index)
{
- /* set array index like this in-case nothing sets it correctly */
+ /* Set array index like this in-case nothing sets it correctly. */
*array_index = 0;
/* result depends on adrcode */
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 073276b7011..6cc90f86b4a 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -315,11 +315,11 @@ Key *BKE_key_add(Main *bmain, ID *id) /* common function */
return key;
}
-/* Sort shape keys and Ipo curves after a change. This assumes that at most
- * one key was moved, which is a valid assumption for the places it's
- * currently being called.
+/**
+ * Sort shape keys after a change.
+ * This assumes that at most one key was moved,
+ * which is a valid assumption for the places it's currently being called.
*/
-
void BKE_key_sort(Key *key)
{
KeyBlock *kb;
@@ -2048,9 +2048,9 @@ void BKE_keyblock_convert_to_lattice(KeyBlock *kb, Lattice *lt)
/************************* Curve ************************/
-int BKE_keyblock_curve_element_count(ListBase *nurb)
+int BKE_keyblock_curve_element_count(const ListBase *nurb)
{
- Nurb *nu;
+ const Nurb *nu;
int tot = 0;
nu = nurb->first;
diff --git a/source/blender/blenkernel/intern/keyconfig.c b/source/blender/blenkernel/intern/keyconfig.c
index 552760c9b34..d25f475c140 100644
--- a/source/blender/blenkernel/intern/keyconfig.c
+++ b/source/blender/blenkernel/intern/keyconfig.c
@@ -55,7 +55,7 @@ wmKeyConfigPref *BKE_keyconfig_pref_ensure(UserDef *userdef, const char *kc_idna
}
if (kpt->prop == NULL) {
IDPropertyTemplate val = {0};
- kpt->prop = IDP_New(IDP_GROUP, &val, kc_idname); /* name is unimportant */
+ kpt->prop = IDP_New(IDP_GROUP, &val, kc_idname); /* name is unimportant. */
}
return kpt;
}
diff --git a/source/blender/blenkernel/intern/lattice_deform.c b/source/blender/blenkernel/intern/lattice_deform.c
index a8126cb5538..a3133b58a0a 100644
--- a/source/blender/blenkernel/intern/lattice_deform.c
+++ b/source/blender/blenkernel/intern/lattice_deform.c
@@ -93,18 +93,18 @@ LatticeDeformData *BKE_lattice_deform_data_create(const Object *oblatt, const Ob
/* for example with a particle system: (ob == NULL) */
if (ob == NULL) {
- /* in deformspace, calc matrix */
+ /* In deform-space, calc matrix. */
invert_m4_m4(latmat, oblatt->obmat);
/* back: put in deform array */
invert_m4_m4(imat, latmat);
}
else {
- /* in deformspace, calc matrix */
+ /* In deform-space, calc matrix. */
invert_m4_m4(imat, oblatt->obmat);
mul_m4_m4m4(latmat, imat, ob->obmat);
- /* back: put in deform array */
+ /* back: put in deform array. */
invert_m4_m4(imat, latmat);
}
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 2ac10586fd9..d49eb0d4da8 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -676,10 +676,10 @@ LayerCollection *BKE_layer_collection_activate_parent(ViewLayer *view_layer, Lay
/**
* Recursively get the count of collections
*/
-static int collection_count(ListBase *lb)
+static int collection_count(const ListBase *lb)
{
int i = 0;
- LISTBASE_FOREACH (LayerCollection *, lc, lb) {
+ LISTBASE_FOREACH (const LayerCollection *, lc, lb) {
i += collection_count(&lc->layer_collections) + 1;
}
return i;
@@ -689,7 +689,7 @@ static int collection_count(ListBase *lb)
* Get the total number of collections
* (including all the nested collections)
*/
-int BKE_layer_collection_count(ViewLayer *view_layer)
+int BKE_layer_collection_count(const ViewLayer *view_layer)
{
return collection_count(&view_layer->layer_collections);
}
@@ -819,7 +819,7 @@ static void layer_collection_sync(ViewLayer *view_layer,
}
/* We separate restrict viewport and visible view layer because a layer collection can be
- * hidden in the view layer yet (locally) visible in a viewport (if it is not restricted).*/
+ * hidden in the view layer yet (locally) visible in a viewport (if it is not restricted). */
if (child_restrict & COLLECTION_RESTRICT_VIEWPORT) {
lc->runtime_flag |= LAYER_COLLECTION_RESTRICT_VIEWPORT;
}
@@ -1000,7 +1000,7 @@ void BKE_main_collection_sync_remap(const Main *bmain)
/* On remapping of object or collection pointers free caches. */
/* TODO: try to make this faster */
- for (const Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
MEM_SAFE_FREE(view_layer->object_bases_array);
@@ -1009,6 +1009,10 @@ void BKE_main_collection_sync_remap(const Main *bmain)
view_layer->object_bases_hash = NULL;
}
}
+
+ BKE_collection_object_cache_free(scene->master_collection);
+ DEG_id_tag_update_ex((Main *)bmain, &scene->master_collection->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update_ex((Main *)bmain, &scene->id, ID_RECALC_COPY_ON_WRITE);
}
for (Collection *collection = bmain->collections.first; collection;
@@ -1500,7 +1504,7 @@ static LayerCollection *find_layer_collection_by_scene_collection(LayerCollectio
/**
* Return the first matching LayerCollection in the ViewLayer for the Collection.
*/
-LayerCollection *BKE_layer_collection_first_from_scene_collection(ViewLayer *view_layer,
+LayerCollection *BKE_layer_collection_first_from_scene_collection(const ViewLayer *view_layer,
const Collection *collection)
{
LISTBASE_FOREACH (LayerCollection *, layer_collection, &view_layer->layer_collections) {
@@ -1516,7 +1520,7 @@ LayerCollection *BKE_layer_collection_first_from_scene_collection(ViewLayer *vie
/**
* See if view layer has the scene collection linked directly, or indirectly (nested)
*/
-bool BKE_view_layer_has_collection(ViewLayer *view_layer, const Collection *collection)
+bool BKE_view_layer_has_collection(const ViewLayer *view_layer, const Collection *collection)
{
return BKE_layer_collection_first_from_scene_collection(view_layer, collection) != NULL;
}
@@ -1823,7 +1827,7 @@ void BKE_view_layer_bases_in_mode_iterator_end(BLI_Iterator *UNUSED(iter))
/** \} */
-/* Evaluation */
+/* Evaluation. */
/* Applies object's restrict flags on top of flags coming from the collection
* and stores those in base->flag. BASE_VISIBLE_DEPSGRAPH ignores viewport flags visibility
diff --git a/source/blender/blenkernel/intern/layer_utils.c b/source/blender/blenkernel/intern/layer_utils.c
index 974a5a24e8a..10ab0a06dd0 100644
--- a/source/blender/blenkernel/intern/layer_utils.c
+++ b/source/blender/blenkernel/intern/layer_utils.c
@@ -164,11 +164,11 @@ Object **BKE_view_layer_array_from_objects_in_mode_params(ViewLayer *view_layer,
/** \name Filter Functions
* \{ */
-bool BKE_view_layer_filter_edit_mesh_has_uvs(Object *ob, void *UNUSED(user_data))
+bool BKE_view_layer_filter_edit_mesh_has_uvs(const Object *ob, void *UNUSED(user_data))
{
if (ob->type == OB_MESH) {
- Mesh *me = ob->data;
- BMEditMesh *em = me->edit_mesh;
+ const Mesh *me = ob->data;
+ const BMEditMesh *em = me->edit_mesh;
if (em != NULL) {
if (CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV) != -1) {
return true;
@@ -178,11 +178,11 @@ bool BKE_view_layer_filter_edit_mesh_has_uvs(Object *ob, void *UNUSED(user_data)
return false;
}
-bool BKE_view_layer_filter_edit_mesh_has_edges(Object *ob, void *UNUSED(user_data))
+bool BKE_view_layer_filter_edit_mesh_has_edges(const Object *ob, void *UNUSED(user_data))
{
if (ob->type == OB_MESH) {
- Mesh *me = ob->data;
- BMEditMesh *em = me->edit_mesh;
+ const Mesh *me = ob->data;
+ const BMEditMesh *em = me->edit_mesh;
if (em != NULL) {
if (em->bm->totedge != 0) {
return true;
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index b7cacba20b3..297ee565257 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -1941,13 +1941,13 @@ void BKE_library_make_local(Main *bmain,
ntree->tag &= ~LIB_TAG_DOIT;
}
- if (id->lib == NULL) {
+ if (!ID_IS_LINKED(id)) {
id->tag &= ~(LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW);
id->flag &= ~LIB_INDIRECT_WEAK_LINK;
if (ID_IS_OVERRIDE_LIBRARY_REAL(id) &&
ELEM(lib, NULL, id->override_library->reference->lib) &&
((untagged_only == false) || !(id->tag & LIB_TAG_PRE_EXISTING))) {
- BKE_lib_override_library_free(&id->override_library, true);
+ BKE_lib_override_library_make_local(id);
}
}
/* The check on the fourth line (LIB_TAG_PRE_EXISTING) is done so it's possible to tag data
diff --git a/source/blender/blenkernel/intern/lib_id_eval.c b/source/blender/blenkernel/intern/lib_id_eval.c
new file mode 100644
index 00000000000..140fe403ac3
--- /dev/null
+++ b/source/blender/blenkernel/intern/lib_id_eval.c
@@ -0,0 +1,48 @@
+/*
+ * 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 bke
+ *
+ * Contains management of ID's and libraries
+ * allocate and free of all library data
+ */
+
+#include "DNA_ID.h"
+#include "DNA_mesh_types.h"
+
+#include "BLI_utildefines.h"
+
+#include "BKE_lib_id.h"
+#include "BKE_mesh.h"
+
+/**
+ * Copy relatives parameters, from `id` to `id_cow`.
+ * Use handle the #ID_RECALC_PARAMETERS tag.
+ * \note Keep in sync with #ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW.
+ */
+void BKE_id_eval_properties_copy(ID *id_cow, ID *id)
+{
+ const ID_Type id_type = GS(id->name);
+ BLI_assert((id_cow->tag & LIB_TAG_COPIED_ON_WRITE) && !(id->tag & LIB_TAG_COPIED_ON_WRITE));
+ BLI_assert(ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW(id_type));
+ if (id_type == ID_ME) {
+ BKE_mesh_copy_parameters((Mesh *)id_cow, (const Mesh *)id);
+ }
+ else {
+ BLI_assert_unreachable();
+ }
+}
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index c93971e7b11..595e470876d 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -52,12 +52,17 @@
#include "BKE_report.h"
#include "BKE_scene.h"
+#include "BLO_readfile.h"
+
#include "BLI_ghash.h"
+#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_task.h"
#include "BLI_utildefines.h"
+#include "PIL_time.h"
+
#include "RNA_access.h"
#include "RNA_types.h"
@@ -466,11 +471,14 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain,
typedef struct LibOverrideGroupTagData {
Main *bmain;
+ Scene *scene;
ID *id_root;
uint tag;
uint missing_tag;
/* Whether we are looping on override data, or their references (linked) one. */
bool is_override;
+ /* Whether we are creating new override, or resyncing existing one. */
+ bool is_resync;
} LibOverrideGroupTagData;
/* Tag all IDs in dependency relationships within an override hierarchy/group.
@@ -591,7 +599,9 @@ static void lib_override_linked_group_tag_recursive(LibOverrideGroupTagData *dat
static void lib_override_linked_group_tag(LibOverrideGroupTagData *data)
{
Main *bmain = data->bmain;
+ Scene *scene = data->scene;
ID *id_root = data->id_root;
+ const bool is_resync = data->is_resync;
BLI_assert(!data->is_override);
if ((id_root->tag & LIB_TAG_MISSING)) {
@@ -616,6 +626,43 @@ static void lib_override_linked_group_tag(LibOverrideGroupTagData *data)
}
}
}
+
+ /* For each object tagged for override, ensure we get at least one local or liboverride
+ * collection to host it. Avoids getting a bunch of random object in the scene's master
+ * collection when all objects' dependencies are not properly 'packed' into a single root
+ * collection. */
+ LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
+ if (ID_IS_LINKED(ob) && (ob->id.tag & data->tag) != 0) {
+ Collection *instantiating_collection = NULL;
+ Collection *instantiating_collection_override_candidate = NULL;
+ /* Loop over all collections instantiating the object, if we already have a 'locale' one we
+ * have nothing to do, otherwise try to find a 'linked' one that we can override too. */
+ while ((instantiating_collection = BKE_collection_object_find(
+ bmain, scene, instantiating_collection, ob)) != NULL) {
+ /* In (recursive) resync case, if a collection of a 'parent' lib instantiates the linked
+ * object, it is also fine. */
+ if (!ID_IS_LINKED(instantiating_collection) ||
+ (is_resync && ID_IS_LINKED(id_root) &&
+ instantiating_collection->id.lib->temp_index < id_root->lib->temp_index)) {
+ break;
+ }
+ if (ID_IS_LINKED(instantiating_collection) &&
+ (!is_resync || instantiating_collection->id.lib == id_root->lib)) {
+ instantiating_collection_override_candidate = instantiating_collection;
+ }
+ }
+
+ if (instantiating_collection == NULL &&
+ instantiating_collection_override_candidate != NULL) {
+ if ((instantiating_collection_override_candidate->id.tag & LIB_TAG_MISSING)) {
+ instantiating_collection_override_candidate->id.tag |= data->missing_tag;
+ }
+ else {
+ instantiating_collection_override_candidate->id.tag |= data->tag;
+ }
+ }
+ }
+ }
}
}
@@ -694,14 +741,16 @@ static void lib_override_overrides_group_tag(LibOverrideGroupTagData *data)
lib_override_overrides_group_tag_recursive(data);
}
-static bool lib_override_library_create_do(Main *bmain, ID *id_root)
+static bool lib_override_library_create_do(Main *bmain, Scene *scene, ID *id_root)
{
BKE_main_relations_create(bmain, 0);
LibOverrideGroupTagData data = {.bmain = bmain,
+ .scene = scene,
.id_root = id_root,
.tag = LIB_TAG_DOIT,
.missing_tag = LIB_TAG_MISSING,
- .is_override = false};
+ .is_override = false,
+ .is_resync = false};
lib_override_linked_group_tag(&data);
BKE_main_relations_tag_set(bmain, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, false);
@@ -862,7 +911,7 @@ bool BKE_lib_override_library_create(Main *bmain,
*r_id_root_override = NULL;
}
- const bool success = lib_override_library_create_do(bmain, id_root);
+ const bool success = lib_override_library_create_do(bmain, scene, id_root);
if (!success) {
return success;
@@ -958,7 +1007,7 @@ bool BKE_lib_override_library_resync(Main *bmain,
Collection *override_resync_residual_storage,
const bool do_hierarchy_enforce,
const bool do_post_process,
- ReportList *reports)
+ BlendFileReadReport *reports)
{
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_root));
@@ -966,10 +1015,12 @@ bool BKE_lib_override_library_resync(Main *bmain,
BKE_main_relations_create(bmain, 0);
LibOverrideGroupTagData data = {.bmain = bmain,
+ .scene = scene,
.id_root = id_root,
.tag = LIB_TAG_DOIT,
.missing_tag = LIB_TAG_MISSING,
- .is_override = true};
+ .is_override = true,
+ .is_resync = true};
lib_override_overrides_group_tag(&data);
BKE_main_relations_tag_set(bmain, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, false);
@@ -1286,7 +1337,7 @@ bool BKE_lib_override_library_resync(Main *bmain,
id_root = id_root_reference->newid;
if (user_edited_overrides_deletion_count > 0) {
- BKE_reportf(reports,
+ BKE_reportf(reports != NULL ? reports->reports : NULL,
RPT_WARNING,
"During resync of data-block %s, %d obsolete overrides were deleted, that had "
"local changes defined by user",
@@ -1438,8 +1489,11 @@ static void lib_override_library_main_resync_on_library_indirect_level(
ViewLayer *view_layer,
Collection *override_resync_residual_storage,
const int library_indirect_level,
- ReportList *reports)
+ BlendFileReadReport *reports)
{
+ const bool do_reports_recursive_resync_timing = (library_indirect_level != 0);
+ const double init_time = do_reports_recursive_resync_timing ? PIL_check_seconds_timer() : 0.0;
+
BKE_main_relations_create(bmain, 0);
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
@@ -1460,10 +1514,12 @@ static void lib_override_library_main_resync_on_library_indirect_level(
}
LibOverrideGroupTagData data = {.bmain = bmain,
+ .scene = scene,
.id_root = id->override_library->reference,
.tag = LIB_TAG_DOIT,
.missing_tag = LIB_TAG_MISSING,
- .is_override = false};
+ .is_override = false,
+ .is_resync = true};
lib_override_linked_group_tag(&data);
BKE_main_relations_tag_set(bmain, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, false);
lib_override_hierarchy_dependencies_recursive_tag(&data);
@@ -1530,6 +1586,7 @@ static void lib_override_library_main_resync_on_library_indirect_level(
(!ID_IS_LINKED(id) && library_indirect_level != 0)) {
continue;
}
+ Library *library = id->lib;
int level = 0;
/* In complex non-supported cases, with several different override hierarchies sharing
@@ -1541,12 +1598,21 @@ static void lib_override_library_main_resync_on_library_indirect_level(
id = lib_override_library_main_resync_find_root_recurse(id, &level);
id->tag &= ~LIB_TAG_LIB_OVERRIDE_NEED_RESYNC;
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id));
+ BLI_assert(id->lib == library);
do_continue = true;
- CLOG_INFO(&LOG, 2, "Resyncing %s (%p)...", id->name, id->lib);
+ CLOG_INFO(&LOG, 2, "Resyncing %s (%p)...", id->name, library);
const bool success = BKE_lib_override_library_resync(
bmain, scene, view_layer, id, override_resync_residual_storage, false, false, reports);
CLOG_INFO(&LOG, 2, "\tSuccess: %d", success);
+ if (success) {
+ reports->count.resynced_lib_overrides++;
+ if (library_indirect_level > 0 &&
+ BLI_linklist_index(reports->resynced_lib_overrides_libraries, library) < 0) {
+ BLI_linklist_prepend(&reports->resynced_lib_overrides_libraries, library);
+ reports->resynced_lib_overrides_libraries_count++;
+ }
+ }
break;
}
FOREACH_MAIN_LISTBASE_ID_END;
@@ -1556,6 +1622,10 @@ static void lib_override_library_main_resync_on_library_indirect_level(
}
FOREACH_MAIN_LISTBASE_END;
}
+
+ if (do_reports_recursive_resync_timing) {
+ reports->duration.lib_overrides_recursive_resync += PIL_check_seconds_timer() - init_time;
+ }
}
static int lib_override_sort_libraries_func(LibraryIDLinkCallbackData *cb_data)
@@ -1633,7 +1703,7 @@ static int lib_override_libraries_index_define(Main *bmain)
void BKE_lib_override_library_main_resync(Main *bmain,
Scene *scene,
ViewLayer *view_layer,
- ReportList *reports)
+ BlendFileReadReport *reports)
{
/* We use a specific collection to gather/store all 'orphaned' override collections and objects
* generated by re-sync-process. This avoids putting them in scene's master collection. */
@@ -1688,10 +1758,12 @@ void BKE_lib_override_library_delete(Main *bmain, ID *id_root)
/* Tag all library overrides in the chains of dependencies from the given root one. */
BKE_main_relations_create(bmain, 0);
LibOverrideGroupTagData data = {.bmain = bmain,
+ .scene = NULL,
.id_root = id_root,
.tag = LIB_TAG_DOIT,
.missing_tag = LIB_TAG_MISSING,
- .is_override = true};
+ .is_override = true,
+ .is_resync = false};
lib_override_overrides_group_tag(&data);
BKE_main_relations_free(bmain);
@@ -1716,6 +1788,33 @@ void BKE_lib_override_library_delete(Main *bmain, ID *id_root)
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
}
+/** Make given ID fully local.
+ *
+ * \note Only differs from lower-level `BKE_lib_override_library_free in infamous embedded ID
+ * cases.
+ */
+void BKE_lib_override_library_make_local(ID *id)
+{
+ BKE_lib_override_library_free(&id->override_library, true);
+
+ Key *shape_key = BKE_key_from_id(id);
+ if (shape_key != NULL) {
+ shape_key->id.flag &= ~LIB_EMBEDDED_DATA_LIB_OVERRIDE;
+ }
+
+ if (GS(id->name) == ID_SCE) {
+ Collection *master_collection = ((Scene *)id)->master_collection;
+ if (master_collection != NULL) {
+ master_collection->id.flag &= ~LIB_EMBEDDED_DATA_LIB_OVERRIDE;
+ }
+ }
+
+ bNodeTree *node_tree = ntreeFromID(id);
+ if (node_tree != NULL) {
+ node_tree->id.flag &= ~LIB_EMBEDDED_DATA_LIB_OVERRIDE;
+ }
+}
+
BLI_INLINE IDOverrideLibraryRuntime *override_library_rna_path_runtime_ensure(
IDOverrideLibrary *override)
{
diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c
index b748061ef8a..9d2552777bf 100644
--- a/source/blender/blenkernel/intern/lib_query.c
+++ b/source/blender/blenkernel/intern/lib_query.c
@@ -83,7 +83,7 @@ bool BKE_lib_query_foreachid_process(LibraryForeachIDData *data, ID **id_pp, int
ID *old_id = *id_pp;
/* Update the callback flags with the ones defined (or forbidden) in `data` by the generic
- * caller code. */
+ * caller code. */
cb_flag = ((cb_flag | data->cb_flag) & ~data->cb_flag_clear);
/* Update the callback flags with some extra information regarding overrides: all 'loopback',
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index a3f122115d8..371af2a95ed 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -1923,7 +1923,7 @@ static void interp_weights_uv_v2_apply(const float uv[2],
r_pt[1] += dvec[0] * uv[1];
}
-/* when a new points added - resize all shapekey array */
+/* When a new points added - resize all shape-key array. */
void BKE_mask_layer_shape_changed_add(MaskLayer *masklay,
int index,
bool do_init,
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 6bef11dea76..f5d898e801b 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -158,7 +158,7 @@ static void metaball_blend_read_data(BlendDataReader *reader, ID *id)
mb->editelems = NULL;
/* Must always be cleared (meta's don't have their own edit-data). */
mb->needs_flush_to_id = 0;
- /* mb->edit_elems.first= mb->edit_elems.last= NULL;*/
+ // mb->edit_elems.first = mb->edit_elems.last = NULL;
mb->lastelem = NULL;
mb->batch_cache = NULL;
}
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index bb46c7b16c0..413cefd2271 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.c
+++ b/source/blender/blenkernel/intern/mball_tessellate.c
@@ -272,20 +272,20 @@ static void build_bvh_spatial(PROCESS *process,
* any and all purposes, provided that this notice appears in all copies.
*/
-#define L 0 /* left direction: -x, -i */
-#define R 1 /* right direction: +x, +i */
-#define B 2 /* bottom direction: -y, -j */
-#define T 3 /* top direction: +y, +j */
-#define N 4 /* near direction: -z, -k */
-#define F 5 /* far direction: +z, +k */
-#define LBN 0 /* left bottom near corner */
-#define LBF 1 /* left bottom far corner */
-#define LTN 2 /* left top near corner */
-#define LTF 3 /* left top far corner */
-#define RBN 4 /* right bottom near corner */
-#define RBF 5 /* right bottom far corner */
-#define RTN 6 /* right top near corner */
-#define RTF 7 /* right top far corner */
+#define L 0 /* Left direction: -x, -i. */
+#define R 1 /* Right direction: +x, +i. */
+#define B 2 /* Bottom direction: -y, -j. */
+#define T 3 /* Top direction: +y, +j. */
+#define N 4 /* Near direction: -z, -k. */
+#define F 5 /* Far direction: +z, +k. */
+#define LBN 0 /* Left bottom near corner. */
+#define LBF 1 /* Left bottom far corner. */
+#define LTN 2 /* Left top near corner. */
+#define LTF 3 /* Left top far corner. */
+#define RBN 4 /* Right bottom near corner. */
+#define RBF 5 /* Right bottom far corner. */
+#define RTN 6 /* Right top near corner. */
+#define RTF 7 /* Right top far corner. */
/**
* the LBN corner of cube (i, j, k), corresponds with location
@@ -293,7 +293,8 @@ static void build_bvh_spatial(PROCESS *process,
*/
#define HASHBIT (5)
-#define HASHSIZE (size_t)(1 << (3 * HASHBIT)) /*! < hash table size (32768) */
+/** Hash table size (32768). */
+#define HASHSIZE (size_t)(1 << (3 * HASHBIT))
#define HASH(i, j, k) ((((((i)&31) << 5) | ((j)&31)) << 5) | ((k)&31))
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 08d3236f3a9..b518f35fac7 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -413,8 +413,7 @@ static const char *cmpcode_to_str(int code)
}
}
-/* thresh is threshold for comparing vertices, uvs, vertex colors,
- * weights, etc.*/
+/** Thresh is threshold for comparing vertices, UV's, vertex colors, weights, etc. */
static int customdata_compare(
CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2, const float thresh)
{
@@ -479,11 +478,11 @@ static int customdata_compare(
if (len_squared_v3v3(v1->co, v2->co) > thresh_sq) {
return MESHCMP_VERTCOMISMATCH;
}
- /* I don't care about normals, let's just do coordinates */
+ /* I don't care about normals, let's just do coordinates. */
}
}
- /*we're order-agnostic for edges here*/
+ /* We're order-agnostic for edges here. */
if (l1->type == CD_MEDGE) {
MEdge *e1 = l1->data;
MEdge *e2 = l2->data;
@@ -748,12 +747,14 @@ bool BKE_mesh_clear_facemap_customdata(struct Mesh *me)
return changed;
}
-/* this ensures grouped customdata (e.g. mtexpoly and mloopuv and mtface, or
+/**
+ * This ensures grouped customdata (e.g. mtexpoly and mloopuv and mtface, or
* mloopcol and mcol) have the same relative active/render/clone/mask indices.
*
- * note that for undo mesh data we want to skip 'ensure_tess_cd' call since
+ * NOTE(campbell): that for undo mesh data we want to skip 'ensure_tess_cd' call since
* we don't want to store memory for tessface when its only used for older
- * versions of the mesh. - campbell*/
+ * Versions of the mesh.
+ */
static void mesh_update_linked_customdata(Mesh *me, const bool do_ensure_tess_cd)
{
if (do_ensure_tess_cd) {
@@ -811,7 +812,7 @@ static void mesh_clear_geometry(Mesh *mesh)
/* Note that materials and shape keys are not freed here. This is intentional, as freeing
* shape keys requires tagging the depsgraph for updated relations, which is expensive.
- * Material slots should be kept in sync with the object.*/
+ * Material slots should be kept in sync with the object. */
mesh->totvert = 0;
mesh->totedge = 0;
@@ -2087,6 +2088,14 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals)
SplitFaceNewVert *new_verts = NULL;
SplitFaceNewEdge *new_edges = NULL;
+ /* Ensure we own the layers, we need to do this before split_faces_prepare_new_verts as it will
+ * directly assign new indices to existing edges and loops. */
+ CustomData_duplicate_referenced_layers(&mesh->vdata, mesh->totvert);
+ CustomData_duplicate_referenced_layers(&mesh->edata, mesh->totedge);
+ CustomData_duplicate_referenced_layers(&mesh->ldata, mesh->totloop);
+ /* Update pointers in case we duplicated referenced layers. */
+ BKE_mesh_update_customdata_pointers(mesh, false);
+
/* Detect loop normal spaces (a.k.a. smooth fans) that will need a new vert. */
const int num_new_verts = split_faces_prepare_new_verts(
mesh, &lnors_spacearr, &new_verts, memarena);
diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc b/source/blender/blenkernel/intern/mesh_boolean_convert.cc
index cfb1c192afe..c162458ffb9 100644
--- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc
@@ -304,7 +304,7 @@ static IMesh meshes_to_imesh(Span<const Mesh *> meshes,
r_info->mesh_edge_offset[mi] = e;
r_info->mesh_poly_offset[mi] = f;
/* Get matrix that transforms a coordinate in objects[mi]'s local space
- * to the target space space.*/
+ * to the target space space. */
const float4x4 objn_mat = (obmats[mi] == nullptr) ? float4x4::identity() :
clean_obmat(*obmats[mi]);
r_info->to_target_transform[mi] = inv_target_mat * objn_mat;
@@ -776,7 +776,7 @@ static Mesh *imesh_to_mesh(IMesh *im, MeshesToIMeshInfo &mim)
/**
* Do a mesh boolean operation directly on meshes (without going back and forth to BMesh).
- * \param meshes: An array of of Mesh pointers.
+ * \param meshes: An array of Mesh pointers.
* \param obmats: An array of pointers to the obmat matrices that transform local
* coordinates to global ones. It is allowed for the pointers to be null, meaning the
* transformation is the identity.
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index 934f9ce5018..cfad5e1100d 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -247,7 +247,7 @@ int BKE_mesh_nurbs_to_mdata(Object *ob,
/* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */
/* use specified dispbase */
-int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
+int BKE_mesh_nurbs_displist_to_mdata(const Object *ob,
const ListBase *dispbase,
MVert **r_allvert,
int *r_totvert,
@@ -259,8 +259,7 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
int *r_totloop,
int *r_totpoly)
{
- Curve *cu = ob->data;
- DispList *dl;
+ const Curve *cu = ob->data;
MVert *mvert;
MPoly *mpoly;
MLoop *mloop;
@@ -276,8 +275,7 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
(ob->type == OB_SURF));
/* count */
- dl = dispbase->first;
- while (dl) {
+ LISTBASE_FOREACH (const DispList *, dl, dispbase) {
if (dl->type == DL_SEGM) {
totvert += dl->parts * dl->nr;
totedge += dl->parts * (dl->nr - 1);
@@ -305,7 +303,6 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
totpoly += tot;
totloop += tot * 3;
}
- dl = dl->next;
}
if (totvert == 0) {
@@ -327,8 +324,7 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
/* verts and faces */
vertcount = 0;
- dl = dispbase->first;
- while (dl) {
+ LISTBASE_FOREACH (const DispList *, dl, dispbase) {
const bool is_smooth = (dl->rt & CU_SMOOTH) != 0;
if (dl->type == DL_SEGM) {
@@ -507,8 +503,6 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
}
}
}
-
- dl = dl->next;
}
if (totpoly) {
@@ -523,7 +517,7 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
return 0;
}
-Mesh *BKE_mesh_new_nomain_from_curve_displist(Object *ob, ListBase *dispbase)
+Mesh *BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase *dispbase)
{
Mesh *mesh;
MVert *allvert;
@@ -551,10 +545,18 @@ Mesh *BKE_mesh_new_nomain_from_curve_displist(Object *ob, ListBase *dispbase)
mesh = BKE_mesh_new_nomain(totvert, totedge, 0, totloop, totpoly);
mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
- memcpy(mesh->mvert, allvert, totvert * sizeof(MVert));
- memcpy(mesh->medge, alledge, totedge * sizeof(MEdge));
- memcpy(mesh->mloop, allloop, totloop * sizeof(MLoop));
- memcpy(mesh->mpoly, allpoly, totpoly * sizeof(MPoly));
+ if (totvert != 0) {
+ memcpy(mesh->mvert, allvert, totvert * sizeof(MVert));
+ }
+ if (totedge != 0) {
+ memcpy(mesh->medge, alledge, totedge * sizeof(MEdge));
+ }
+ if (totloop != 0) {
+ memcpy(mesh->mloop, allloop, totloop * sizeof(MLoop));
+ }
+ if (totpoly != 0) {
+ memcpy(mesh->mpoly, allpoly, totpoly * sizeof(MPoly));
+ }
if (alluv) {
const char *uvname = "UVMap";
@@ -1113,7 +1115,7 @@ static void curve_to_mesh_eval_ensure(Object *object)
* Brecht says hold off with that. */
Mesh *mesh_eval = NULL;
BKE_displist_make_curveTypes_forRender(
- NULL, NULL, &remapped_object, &remapped_object.runtime.curve_cache->disp, false, &mesh_eval);
+ NULL, NULL, &remapped_object, &remapped_object.runtime.curve_cache->disp, &mesh_eval);
/* Note: this is to be consistent with `BKE_displist_make_curveTypes()`, however that is not a
* real issue currently, code here is broken in more than one way, fix(es) will be done
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 2260ffc668a..6eac96ba85b 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -25,8 +25,6 @@
#include <limits.h>
-#include "CLG_log.h"
-
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
@@ -36,2118 +34,14 @@
#include "BLI_alloca.h"
#include "BLI_bitmap.h"
#include "BLI_edgehash.h"
-#include "BLI_linklist.h"
-#include "BLI_linklist_stack.h"
+
#include "BLI_math.h"
-#include "BLI_memarena.h"
-#include "BLI_stack.h"
-#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "BKE_customdata.h"
-#include "BKE_editmesh_cache.h"
-#include "BKE_global.h"
+
#include "BKE_mesh.h"
#include "BKE_multires.h"
-#include "BKE_report.h"
-
-#include "BLI_strict_flags.h"
-
-#include "atomic_ops.h"
-#include "mikktspace.h"
-
-// #define DEBUG_TIME
-
-#include "PIL_time.h"
-#ifdef DEBUG_TIME
-# include "PIL_time_utildefines.h"
-#endif
-
-static CLG_LogRef LOG = {"bke.mesh_evaluate"};
-
-/* -------------------------------------------------------------------- */
-/** \name Mesh Normal Calculation
- * \{ */
-
-/**
- * Call when there are no polygons.
- */
-static void mesh_calc_normals_vert_fallback(MVert *mverts, int numVerts)
-{
- for (int i = 0; i < numVerts; i++) {
- MVert *mv = &mverts[i];
- float no[3];
-
- normalize_v3_v3(no, mv->co);
- normal_float_to_short_v3(mv->no, no);
- }
-}
-
-/* TODO(Sybren): we can probably rename this to BKE_mesh_calc_normals_mapping(),
- * and remove the function of the same name below, as that one doesn't seem to be
- * called anywhere. */
-void BKE_mesh_calc_normals_mapping_simple(struct Mesh *mesh)
-{
- const bool only_face_normals = CustomData_is_referenced_layer(&mesh->vdata, CD_MVERT);
-
- BKE_mesh_calc_normals_mapping_ex(mesh->mvert,
- mesh->totvert,
- mesh->mloop,
- mesh->mpoly,
- mesh->totloop,
- mesh->totpoly,
- NULL,
- mesh->mface,
- mesh->totface,
- NULL,
- NULL,
- only_face_normals);
-}
-
-/* Calculate vertex and face normals, face normals are returned in *r_faceNors if non-NULL
- * and vertex normals are stored in actual mverts.
- */
-void BKE_mesh_calc_normals_mapping(MVert *mverts,
- int numVerts,
- const MLoop *mloop,
- const MPoly *mpolys,
- int numLoops,
- int numPolys,
- float (*r_polyNors)[3],
- const MFace *mfaces,
- int numFaces,
- const int *origIndexFace,
- float (*r_faceNors)[3])
-{
- BKE_mesh_calc_normals_mapping_ex(mverts,
- numVerts,
- mloop,
- mpolys,
- numLoops,
- numPolys,
- r_polyNors,
- mfaces,
- numFaces,
- origIndexFace,
- r_faceNors,
- false);
-}
-/* extended version of 'BKE_mesh_calc_normals_poly' with option not to calc vertex normals */
-void BKE_mesh_calc_normals_mapping_ex(MVert *mverts,
- int numVerts,
- const MLoop *mloop,
- const MPoly *mpolys,
- int numLoops,
- int numPolys,
- float (*r_polyNors)[3],
- const MFace *mfaces,
- int numFaces,
- const int *origIndexFace,
- float (*r_faceNors)[3],
- const bool only_face_normals)
-{
- float(*pnors)[3] = r_polyNors, (*fnors)[3] = r_faceNors;
-
- if (numPolys == 0) {
- if (only_face_normals == false) {
- mesh_calc_normals_vert_fallback(mverts, numVerts);
- }
- return;
- }
-
- /* if we are not calculating verts and no verts were passes then we have nothing to do */
- if ((only_face_normals == true) && (r_polyNors == NULL) && (r_faceNors == NULL)) {
- CLOG_WARN(&LOG, "called with nothing to do");
- return;
- }
-
- if (!pnors) {
- pnors = MEM_calloc_arrayN((size_t)numPolys, sizeof(float[3]), __func__);
- }
- /* 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,
- * so make them optional */
- BKE_mesh_calc_normals_poly(
- mverts, NULL, numVerts, mloop, mpolys, numLoops, numPolys, pnors, false);
- }
- else {
- /* only calc poly normals */
- const MPoly *mp = mpolys;
- for (int i = 0; i < numPolys; i++, mp++) {
- BKE_mesh_calc_poly_normal(mp, mloop + mp->loopstart, mverts, pnors[i]);
- }
- }
-
- if (origIndexFace &&
- /* fnors == r_faceNors */ /* NO NEED TO ALLOC YET */
- fnors != NULL &&
- numFaces) {
- const MFace *mf = mfaces;
- for (int i = 0; i < numFaces; i++, mf++, origIndexFace++) {
- if (*origIndexFace < numPolys) {
- copy_v3_v3(fnors[i], pnors[*origIndexFace]);
- }
- else {
- /* eek, we're not corresponding to polys */
- CLOG_ERROR(&LOG, "tessellation face indices are incorrect. normals may look bad.");
- }
- }
- }
-
- if (pnors != r_polyNors) {
- MEM_freeN(pnors);
- }
- /* if (fnors != r_faceNors) MEM_freeN(fnors); */ /* NO NEED TO ALLOC YET */
-
- fnors = pnors = NULL;
-}
-
-typedef struct MeshCalcNormalsData {
- const MPoly *mpolys;
- const MLoop *mloop;
- MVert *mverts;
- float (*pnors)[3];
- float (*lnors_weighted)[3];
- float (*vnors)[3];
-} MeshCalcNormalsData;
-
-static void mesh_calc_normals_poly_cb(void *__restrict userdata,
- const int pidx,
- const TaskParallelTLS *__restrict UNUSED(tls))
-{
- MeshCalcNormalsData *data = userdata;
- const MPoly *mp = &data->mpolys[pidx];
-
- BKE_mesh_calc_poly_normal(mp, data->mloop + mp->loopstart, data->mverts, data->pnors[pidx]);
-}
-
-static void mesh_calc_normals_poly_prepare_cb(void *__restrict userdata,
- const int pidx,
- const TaskParallelTLS *__restrict UNUSED(tls))
-{
- MeshCalcNormalsData *data = userdata;
- const MPoly *mp = &data->mpolys[pidx];
- const MLoop *ml = &data->mloop[mp->loopstart];
- const MVert *mverts = data->mverts;
-
- float pnor_temp[3];
- float *pnor = data->pnors ? data->pnors[pidx] : pnor_temp;
- float(*lnors_weighted)[3] = data->lnors_weighted;
-
- const int nverts = mp->totloop;
- float(*edgevecbuf)[3] = BLI_array_alloca(edgevecbuf, (size_t)nverts);
-
- /* Polygon Normal and edge-vector */
- /* inline version of #BKE_mesh_calc_poly_normal, also does edge-vectors */
- {
- int i_prev = nverts - 1;
- const float *v_prev = mverts[ml[i_prev].v].co;
- const float *v_curr;
-
- zero_v3(pnor);
- /* Newell's Method */
- for (int i = 0; i < nverts; i++) {
- v_curr = mverts[ml[i].v].co;
- add_newell_cross_v3_v3v3(pnor, v_prev, v_curr);
-
- /* Unrelated to normalize, calculate edge-vector */
- sub_v3_v3v3(edgevecbuf[i_prev], v_prev, v_curr);
- normalize_v3(edgevecbuf[i_prev]);
- i_prev = i;
-
- v_prev = v_curr;
- }
- if (UNLIKELY(normalize_v3(pnor) == 0.0f)) {
- pnor[2] = 1.0f; /* other axes set to 0.0 */
- }
- }
-
- /* accumulate angle weighted face normal */
- /* inline version of #accumulate_vertex_normals_poly_v3,
- * split between this threaded callback and #mesh_calc_normals_poly_accum_cb. */
- {
- const float *prev_edge = edgevecbuf[nverts - 1];
-
- for (int i = 0; i < nverts; i++) {
- const int lidx = mp->loopstart + i;
- const float *cur_edge = edgevecbuf[i];
-
- /* calculate angle between the two poly edges incident on
- * this vertex */
- const float fac = saacos(-dot_v3v3(cur_edge, prev_edge));
-
- /* Store for later accumulation */
- mul_v3_v3fl(lnors_weighted[lidx], pnor, fac);
-
- prev_edge = cur_edge;
- }
- }
-}
-
-static void mesh_calc_normals_poly_finalize_cb(void *__restrict userdata,
- const int vidx,
- const TaskParallelTLS *__restrict UNUSED(tls))
-{
- MeshCalcNormalsData *data = userdata;
-
- MVert *mv = &data->mverts[vidx];
- float *no = data->vnors[vidx];
-
- if (UNLIKELY(normalize_v3(no) == 0.0f)) {
- /* following Mesh convention; we use vertex coordinate itself for normal in this case */
- normalize_v3_v3(no, mv->co);
- }
-
- normal_float_to_short_v3(mv->no, no);
-}
-
-void BKE_mesh_calc_normals_poly(MVert *mverts,
- float (*r_vertnors)[3],
- int numVerts,
- const MLoop *mloop,
- const MPoly *mpolys,
- int numLoops,
- int numPolys,
- float (*r_polynors)[3],
- const bool only_face_normals)
-{
- float(*pnors)[3] = r_polynors;
-
- TaskParallelSettings settings;
- BLI_parallel_range_settings_defaults(&settings);
- settings.min_iter_per_thread = 1024;
-
- if (only_face_normals) {
- BLI_assert((pnors != NULL) || (numPolys == 0));
- BLI_assert(r_vertnors == NULL);
-
- MeshCalcNormalsData data = {
- .mpolys = mpolys,
- .mloop = mloop,
- .mverts = mverts,
- .pnors = pnors,
- };
-
- BLI_task_parallel_range(0, numPolys, &data, mesh_calc_normals_poly_cb, &settings);
- return;
- }
-
- float(*vnors)[3] = r_vertnors;
- float(*lnors_weighted)[3] = MEM_malloc_arrayN(
- (size_t)numLoops, sizeof(*lnors_weighted), __func__);
- bool free_vnors = false;
-
- /* first go through and calculate normals for all the polys */
- if (vnors == NULL) {
- vnors = MEM_calloc_arrayN((size_t)numVerts, sizeof(*vnors), __func__);
- free_vnors = true;
- }
- else {
- memset(vnors, 0, sizeof(*vnors) * (size_t)numVerts);
- }
-
- MeshCalcNormalsData data = {
- .mpolys = mpolys,
- .mloop = mloop,
- .mverts = mverts,
- .pnors = pnors,
- .lnors_weighted = lnors_weighted,
- .vnors = vnors,
- };
-
- /* Compute poly normals, and prepare weighted loop normals. */
- 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),
- * 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]);
- }
-
- /* Normalize and validate computed vertex normals. */
- BLI_task_parallel_range(0, numVerts, &data, mesh_calc_normals_poly_finalize_cb, &settings);
-
- if (free_vnors) {
- MEM_freeN(vnors);
- }
- MEM_freeN(lnors_weighted);
-}
-
-void BKE_mesh_ensure_normals(Mesh *mesh)
-{
- if (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) {
- BKE_mesh_calc_normals(mesh);
- }
- BLI_assert((mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) == 0);
-}
-
-/**
- * Called after calculating all modifiers.
- */
-void BKE_mesh_ensure_normals_for_display(Mesh *mesh)
-{
- switch ((eMeshWrapperType)mesh->runtime.wrapper_type) {
- case ME_WRAPPER_TYPE_MDATA:
- /* Run code below. */
- break;
- case ME_WRAPPER_TYPE_BMESH: {
- struct BMEditMesh *em = mesh->edit_mesh;
- EditMeshData *emd = mesh->runtime.edit_data;
- if (emd->vertexCos) {
- BKE_editmesh_cache_ensure_vert_normals(em, emd);
- BKE_editmesh_cache_ensure_poly_normals(em, emd);
- }
- return;
- }
- }
-
- float(*poly_nors)[3] = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
- const bool do_vert_normals = (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) != 0;
- const bool do_poly_normals = (mesh->runtime.cd_dirty_poly & CD_MASK_NORMAL || poly_nors == NULL);
-
- if (do_vert_normals || do_poly_normals) {
- const bool do_add_poly_nors_cddata = (poly_nors == NULL);
- if (do_add_poly_nors_cddata) {
- poly_nors = MEM_malloc_arrayN((size_t)mesh->totpoly, sizeof(*poly_nors), __func__);
- }
-
- /* calculate poly/vert normals */
- BKE_mesh_calc_normals_poly(mesh->mvert,
- NULL,
- mesh->totvert,
- mesh->mloop,
- mesh->mpoly,
- mesh->totloop,
- mesh->totpoly,
- poly_nors,
- !do_vert_normals);
-
- if (do_add_poly_nors_cddata) {
- CustomData_add_layer(&mesh->pdata, CD_NORMAL, CD_ASSIGN, poly_nors, mesh->totpoly);
- }
-
- mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
- mesh->runtime.cd_dirty_poly &= ~CD_MASK_NORMAL;
- }
-}
-
-/* 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
- TIMEIT_START_AVERAGED(BKE_mesh_calc_normals);
-#endif
- BKE_mesh_calc_normals_poly(mesh->mvert,
- NULL,
- mesh->totvert,
- mesh->mloop,
- mesh->mpoly,
- mesh->totloop,
- mesh->totpoly,
- NULL,
- false);
-#ifdef DEBUG_TIME
- TIMEIT_END_AVERAGED(BKE_mesh_calc_normals);
-#endif
- mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
-}
-
-void BKE_mesh_calc_normals_looptri(MVert *mverts,
- int numVerts,
- const MLoop *mloop,
- const MLoopTri *looptri,
- int looptri_num,
- float (*r_tri_nors)[3])
-{
- float(*tnorms)[3] = MEM_calloc_arrayN((size_t)numVerts, sizeof(*tnorms), "tnorms");
- float(*fnors)[3] = (r_tri_nors) ?
- r_tri_nors :
- MEM_calloc_arrayN((size_t)looptri_num, sizeof(*fnors), "meshnormals");
-
- if (!tnorms || !fnors) {
- goto cleanup;
- }
-
- for (int i = 0; i < looptri_num; i++) {
- const MLoopTri *lt = &looptri[i];
- float *f_no = fnors[i];
- const uint vtri[3] = {
- mloop[lt->tri[0]].v,
- mloop[lt->tri[1]].v,
- mloop[lt->tri[2]].v,
- };
-
- normal_tri_v3(f_no, mverts[vtri[0]].co, mverts[vtri[1]].co, mverts[vtri[2]].co);
-
- accumulate_vertex_normals_tri_v3(tnorms[vtri[0]],
- tnorms[vtri[1]],
- tnorms[vtri[2]],
- f_no,
- mverts[vtri[0]].co,
- mverts[vtri[1]].co,
- mverts[vtri[2]].co);
- }
-
- /* following Mesh convention; we use vertex coordinate itself for normal in this case */
- for (int i = 0; i < numVerts; i++) {
- MVert *mv = &mverts[i];
- float *no = tnorms[i];
-
- if (UNLIKELY(normalize_v3(no) == 0.0f)) {
- normalize_v3_v3(no, mv->co);
- }
-
- normal_float_to_short_v3(mv->no, no);
- }
-
-cleanup:
- MEM_freeN(tnorms);
-
- if (fnors != r_tri_nors) {
- MEM_freeN(fnors);
- }
-}
-
-void BKE_lnor_spacearr_init(MLoopNorSpaceArray *lnors_spacearr,
- const int numLoops,
- const char data_type)
-{
- if (!(lnors_spacearr->lspacearr && lnors_spacearr->loops_pool)) {
- MemArena *mem;
-
- if (!lnors_spacearr->mem) {
- lnors_spacearr->mem = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
- }
- mem = lnors_spacearr->mem;
- lnors_spacearr->lspacearr = BLI_memarena_calloc(mem,
- sizeof(MLoopNorSpace *) * (size_t)numLoops);
- lnors_spacearr->loops_pool = BLI_memarena_alloc(mem, sizeof(LinkNode) * (size_t)numLoops);
-
- lnors_spacearr->num_spaces = 0;
- }
- BLI_assert(ELEM(data_type, MLNOR_SPACEARR_BMLOOP_PTR, MLNOR_SPACEARR_LOOP_INDEX));
- lnors_spacearr->data_type = data_type;
-}
-
-void BKE_lnor_spacearr_clear(MLoopNorSpaceArray *lnors_spacearr)
-{
- lnors_spacearr->num_spaces = 0;
- lnors_spacearr->lspacearr = NULL;
- lnors_spacearr->loops_pool = NULL;
- if (lnors_spacearr->mem != NULL) {
- BLI_memarena_clear(lnors_spacearr->mem);
- }
-}
-
-void BKE_lnor_spacearr_free(MLoopNorSpaceArray *lnors_spacearr)
-{
- lnors_spacearr->num_spaces = 0;
- lnors_spacearr->lspacearr = NULL;
- lnors_spacearr->loops_pool = NULL;
- BLI_memarena_free(lnors_spacearr->mem);
- lnors_spacearr->mem = NULL;
-}
-
-MLoopNorSpace *BKE_lnor_space_create(MLoopNorSpaceArray *lnors_spacearr)
-{
- lnors_spacearr->num_spaces++;
- return BLI_memarena_calloc(lnors_spacearr->mem, sizeof(MLoopNorSpace));
-}
-
-/* This threshold is a bit touchy (usual float precision issue), this value seems OK. */
-#define LNOR_SPACE_TRIGO_THRESHOLD (1.0f - 1e-4f)
-
-/* 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').
- */
-void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
- const float lnor[3],
- float vec_ref[3],
- float vec_other[3],
- BLI_Stack *edge_vectors)
-{
- const float pi2 = (float)M_PI * 2.0f;
- float tvec[3], dtp;
- const float dtp_ref = dot_v3v3(vec_ref, lnor);
- const float dtp_other = dot_v3v3(vec_other, lnor);
-
- if (UNLIKELY(fabsf(dtp_ref) >= LNOR_SPACE_TRIGO_THRESHOLD ||
- fabsf(dtp_other) >= LNOR_SPACE_TRIGO_THRESHOLD)) {
- /* If vec_ref or vec_other are too much aligned with lnor, we can't build lnor space,
- * tag it as invalid and abort. */
- lnor_space->ref_alpha = lnor_space->ref_beta = 0.0f;
-
- if (edge_vectors) {
- BLI_stack_clear(edge_vectors);
- }
- return;
- }
-
- copy_v3_v3(lnor_space->vec_lnor, lnor);
-
- /* Compute ref alpha, average angle of all available edge vectors to lnor. */
- if (edge_vectors) {
- float alpha = 0.0f;
- int nbr = 0;
- while (!BLI_stack_is_empty(edge_vectors)) {
- const float *vec = BLI_stack_peek(edge_vectors);
- alpha += saacosf(dot_v3v3(vec, lnor));
- 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.).
- */
- BLI_assert(nbr >= 2); /* This piece of code shall only be called for more than one loop... */
- lnor_space->ref_alpha = alpha / (float)nbr;
- }
- else {
- lnor_space->ref_alpha = (saacosf(dot_v3v3(vec_ref, lnor)) +
- saacosf(dot_v3v3(vec_other, lnor))) /
- 2.0f;
- }
-
- /* Project vec_ref on lnor's ortho plane. */
- mul_v3_v3fl(tvec, lnor, dtp_ref);
- sub_v3_v3(vec_ref, tvec);
- normalize_v3_v3(lnor_space->vec_ref, vec_ref);
-
- cross_v3_v3v3(tvec, lnor, lnor_space->vec_ref);
- normalize_v3_v3(lnor_space->vec_ortho, tvec);
-
- /* Project vec_other on lnor's ortho plane. */
- mul_v3_v3fl(tvec, lnor, dtp_other);
- sub_v3_v3(vec_other, tvec);
- normalize_v3(vec_other);
-
- /* Beta is angle between ref_vec and other_vec, around lnor. */
- dtp = dot_v3v3(lnor_space->vec_ref, vec_other);
- if (LIKELY(dtp < LNOR_SPACE_TRIGO_THRESHOLD)) {
- const float beta = saacos(dtp);
- lnor_space->ref_beta = (dot_v3v3(lnor_space->vec_ortho, vec_other) < 0.0f) ? pi2 - beta : beta;
- }
- else {
- lnor_space->ref_beta = pi2;
- }
-}
-
-/**
- * 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.
- */
-void BKE_lnor_space_add_loop(MLoopNorSpaceArray *lnors_spacearr,
- MLoopNorSpace *lnor_space,
- const int ml_index,
- void *bm_loop,
- const bool is_single)
-{
- BLI_assert((lnors_spacearr->data_type == MLNOR_SPACEARR_LOOP_INDEX && bm_loop == NULL) ||
- (lnors_spacearr->data_type == MLNOR_SPACEARR_BMLOOP_PTR && bm_loop != NULL));
-
- lnors_spacearr->lspacearr[ml_index] = lnor_space;
- if (bm_loop == NULL) {
- bm_loop = POINTER_FROM_INT(ml_index);
- }
- if (is_single) {
- BLI_assert(lnor_space->loops == NULL);
- lnor_space->flags |= MLNOR_SPACE_IS_SINGLE;
- lnor_space->loops = bm_loop;
- }
- else {
- BLI_assert((lnor_space->flags & MLNOR_SPACE_IS_SINGLE) == 0);
- BLI_linklist_prepend_nlink(&lnor_space->loops, bm_loop, &lnors_spacearr->loops_pool[ml_index]);
- }
-}
-
-MINLINE float unit_short_to_float(const short val)
-{
- return (float)val / (float)SHRT_MAX;
-}
-
-MINLINE short unit_float_to_short(const float val)
-{
- /* Rounding... */
- return (short)floorf(val * (float)SHRT_MAX + 0.5f);
-}
-
-void BKE_lnor_space_custom_data_to_normal(MLoopNorSpace *lnor_space,
- const short clnor_data[2],
- float r_custom_lnor[3])
-{
- /* NOP custom normal data or invalid lnor space, return. */
- if (clnor_data[0] == 0 || lnor_space->ref_alpha == 0.0f || lnor_space->ref_beta == 0.0f) {
- copy_v3_v3(r_custom_lnor, lnor_space->vec_lnor);
- return;
- }
-
- {
- /* TODO Check whether using sincosf() gives any noticeable benefit
- * (could not even get it working under linux though)! */
- const float pi2 = (float)(M_PI * 2.0);
- const float alphafac = unit_short_to_float(clnor_data[0]);
- const float alpha = (alphafac > 0.0f ? lnor_space->ref_alpha : pi2 - lnor_space->ref_alpha) *
- alphafac;
- const float betafac = unit_short_to_float(clnor_data[1]);
-
- mul_v3_v3fl(r_custom_lnor, lnor_space->vec_lnor, cosf(alpha));
-
- if (betafac == 0.0f) {
- madd_v3_v3fl(r_custom_lnor, lnor_space->vec_ref, sinf(alpha));
- }
- else {
- const float sinalpha = sinf(alpha);
- const float beta = (betafac > 0.0f ? lnor_space->ref_beta : pi2 - lnor_space->ref_beta) *
- betafac;
- madd_v3_v3fl(r_custom_lnor, lnor_space->vec_ref, sinalpha * cosf(beta));
- madd_v3_v3fl(r_custom_lnor, lnor_space->vec_ortho, sinalpha * sinf(beta));
- }
- }
-}
-
-void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space,
- const float custom_lnor[3],
- short r_clnor_data[2])
-{
- /* We use null vector as NOP custom normal (can be simpler than giving autocomputed lnor...). */
- if (is_zero_v3(custom_lnor) || compare_v3v3(lnor_space->vec_lnor, custom_lnor, 1e-4f)) {
- r_clnor_data[0] = r_clnor_data[1] = 0;
- return;
- }
-
- {
- const float pi2 = (float)(M_PI * 2.0);
- const float cos_alpha = dot_v3v3(lnor_space->vec_lnor, custom_lnor);
- float vec[3], cos_beta;
- float alpha;
-
- 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. */
- r_clnor_data[0] = unit_float_to_short(-(pi2 - alpha) / (pi2 - lnor_space->ref_alpha));
- }
- else {
- r_clnor_data[0] = unit_float_to_short(alpha / lnor_space->ref_alpha);
- }
-
- /* Project custom lnor on (vec_ref, vec_ortho) plane. */
- mul_v3_v3fl(vec, lnor_space->vec_lnor, -cos_alpha);
- add_v3_v3(vec, custom_lnor);
- normalize_v3(vec);
-
- cos_beta = dot_v3v3(lnor_space->vec_ref, vec);
-
- if (cos_beta < LNOR_SPACE_TRIGO_THRESHOLD) {
- float beta = saacosf(cos_beta);
- if (dot_v3v3(lnor_space->vec_ortho, vec) < 0.0f) {
- beta = pi2 - beta;
- }
-
- if (beta > lnor_space->ref_beta) {
- r_clnor_data[1] = unit_float_to_short(-(pi2 - beta) / (pi2 - lnor_space->ref_beta));
- }
- else {
- r_clnor_data[1] = unit_float_to_short(beta / lnor_space->ref_beta);
- }
- }
- else {
- r_clnor_data[1] = 0;
- }
- }
-}
-
-#define LOOP_SPLIT_TASK_BLOCK_SIZE 1024
-
-typedef struct LoopSplitTaskData {
- /* Specific to each instance (each task). */
-
- /** 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;
- /** 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! */
- BLI_Stack *edge_vectors;
-
- char pad_c;
-} 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. */
- MLoopNorSpaceArray *lnors_spacearr;
- float (*loopnors)[3];
- short (*clnors_data)[2];
-
- /* Read-only. */
- const MVert *mverts;
- const MEdge *medges;
- const MLoop *mloops;
- const MPoly *mpolys;
- int (*edge_to_loops)[2];
- int *loop_to_poly;
- const float (*polynors)[3];
-
- int numEdges;
- int numLoops;
- int numPolys;
-} LoopSplitTaskDataCommon;
-
-#define INDEX_UNSET INT_MIN
-#define INDEX_INVALID -1
-/* See comment about edge_to_loops below. */
-#define IS_EDGE_SHARP(_e2l) (ELEM((_e2l)[1], INDEX_UNSET, INDEX_INVALID))
-
-static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data,
- const bool check_angle,
- const float split_angle,
- const bool do_sharp_edges_tag)
-{
- const MVert *mverts = data->mverts;
- const MEdge *medges = data->medges;
- const MLoop *mloops = data->mloops;
-
- const MPoly *mpolys = data->mpolys;
-
- const int numEdges = data->numEdges;
- const int numPolys = data->numPolys;
-
- float(*loopnors)[3] = data->loopnors; /* Note: loopnors may be NULL here. */
- const float(*polynors)[3] = data->polynors;
-
- int(*edge_to_loops)[2] = data->edge_to_loops;
- int *loop_to_poly = data->loop_to_poly;
-
- BLI_bitmap *sharp_edges = do_sharp_edges_tag ? BLI_BITMAP_NEW(numEdges, __func__) : NULL;
-
- const MPoly *mp;
- int mp_index;
-
- const float split_angle_cos = check_angle ? cosf(split_angle) : -1.0f;
-
- for (mp = mpolys, mp_index = 0; mp_index < numPolys; mp++, mp_index++) {
- const MLoop *ml_curr;
- int *e2l;
- int ml_curr_index = mp->loopstart;
- const int ml_last_index = (ml_curr_index + mp->totloop) - 1;
-
- ml_curr = &mloops[ml_curr_index];
-
- for (; ml_curr_index <= ml_last_index; ml_curr++, ml_curr_index++) {
- e2l = edge_to_loops[ml_curr->e];
-
- 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!
- */
- if (loopnors) {
- normal_short_to_float_v3(loopnors[ml_curr_index], mverts[ml_curr->v].no);
- }
-
- /* Check whether current edge might be smooth or sharp */
- if ((e2l[0] | e2l[1]) == 0) {
- /* 'Empty' edge until now, set e2l[0] (and e2l[1] to INDEX_UNSET to tag it as unset). */
- e2l[0] = ml_curr_index;
- /* We have to check this here too, else we might miss some flat faces!!! */
- e2l[1] = (mp->flag & ME_SMOOTH) ? INDEX_UNSET : INDEX_INVALID;
- }
- else if (e2l[1] == INDEX_UNSET) {
- const bool is_angle_sharp = (check_angle &&
- dot_v3v3(polynors[loop_to_poly[e2l[0]]], polynors[mp_index]) <
- split_angle_cos);
-
- /* 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.
- */
- if (!(mp->flag & ME_SMOOTH) || (medges[ml_curr->e].flag & ME_SHARP) ||
- ml_curr->v == mloops[e2l[0]].v || is_angle_sharp) {
- /* Note: we are sure that loop != 0 here ;) */
- e2l[1] = INDEX_INVALID;
-
- /* We want to avoid tagging edges as sharp when it is already defined as such by
- * other causes than angle threshold... */
- if (do_sharp_edges_tag && is_angle_sharp) {
- BLI_BITMAP_SET(sharp_edges, ml_curr->e, true);
- }
- }
- else {
- e2l[1] = ml_curr_index;
- }
- }
- else if (!IS_EDGE_SHARP(e2l)) {
- /* More than two loops using this edge, tag as sharp if not yet done. */
- e2l[1] = INDEX_INVALID;
-
- /* We want to avoid tagging edges as sharp when it is already defined as such by
- * other causes than angle threshold... */
- if (do_sharp_edges_tag) {
- BLI_BITMAP_SET(sharp_edges, ml_curr->e, false);
- }
- }
- /* Else, edge is already 'disqualified' (i.e. sharp)! */
- }
- }
-
- /* If requested, do actual tagging of edges as sharp in another loop. */
- if (do_sharp_edges_tag) {
- MEdge *me;
- int me_index;
- for (me = (MEdge *)medges, me_index = 0; me_index < numEdges; me++, me_index++) {
- if (BLI_BITMAP_TEST(sharp_edges, me_index)) {
- me->flag |= ME_SHARP;
- }
- }
-
- MEM_freeN(sharp_edges);
- }
-}
-
-/**
- * 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!
- */
-void BKE_edges_sharp_from_angle_set(const struct MVert *mverts,
- const int UNUSED(numVerts),
- struct MEdge *medges,
- const int numEdges,
- struct MLoop *mloops,
- const int numLoops,
- struct MPoly *mpolys,
- const float (*polynors)[3],
- const int numPolys,
- const float split_angle)
-{
- if (split_angle >= (float)M_PI) {
- /* Nothing to do! */
- return;
- }
-
- /* Mapping edge -> loops. See BKE_mesh_normals_loop_split() for details. */
- 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. */
- int *loop_to_poly = MEM_malloc_arrayN((size_t)numLoops, sizeof(*loop_to_poly), __func__);
-
- LoopSplitTaskDataCommon common_data = {
- .mverts = mverts,
- .medges = medges,
- .mloops = mloops,
- .mpolys = mpolys,
- .edge_to_loops = edge_to_loops,
- .loop_to_poly = loop_to_poly,
- .polynors = polynors,
- .numEdges = numEdges,
- .numPolys = numPolys,
- };
-
- mesh_edges_sharp_tag(&common_data, true, split_angle, true);
-
- MEM_freeN(edge_to_loops);
- MEM_freeN(loop_to_poly);
-}
-
-void BKE_mesh_loop_manifold_fan_around_vert_next(const MLoop *mloops,
- const MPoly *mpolys,
- const int *loop_to_poly,
- const int *e2lfan_curr,
- const uint mv_pivot_index,
- const MLoop **r_mlfan_curr,
- int *r_mlfan_curr_index,
- int *r_mlfan_vert_index,
- int *r_mpfan_curr_index)
-{
- const MLoop *mlfan_next;
- const MPoly *mpfan_next;
-
- /* Warning! This is rather complex!
- * We have to find our next edge around the vertex (fan mode).
- * First we find the next loop, which is either previous or next to mlfan_curr_index, depending
- * whether both loops using current edge are in the same direction or not, and whether
- * mlfan_curr_index actually uses the vertex we are fanning around!
- * mlfan_curr_index is the index of mlfan_next here, and mlfan_next is not the real next one
- * (i.e. not the future mlfan_curr)...
- */
- *r_mlfan_curr_index = (e2lfan_curr[0] == *r_mlfan_curr_index) ? e2lfan_curr[1] : e2lfan_curr[0];
- *r_mpfan_curr_index = loop_to_poly[*r_mlfan_curr_index];
-
- BLI_assert(*r_mlfan_curr_index >= 0);
- BLI_assert(*r_mpfan_curr_index >= 0);
-
- mlfan_next = &mloops[*r_mlfan_curr_index];
- mpfan_next = &mpolys[*r_mpfan_curr_index];
- if (((*r_mlfan_curr)->v == mlfan_next->v && (*r_mlfan_curr)->v == mv_pivot_index) ||
- ((*r_mlfan_curr)->v != mlfan_next->v && (*r_mlfan_curr)->v != mv_pivot_index)) {
- /* We need the previous loop, but current one is our vertex's loop. */
- *r_mlfan_vert_index = *r_mlfan_curr_index;
- if (--(*r_mlfan_curr_index) < mpfan_next->loopstart) {
- *r_mlfan_curr_index = mpfan_next->loopstart + mpfan_next->totloop - 1;
- }
- }
- else {
- /* We need the next loop, which is also our vertex's loop. */
- if (++(*r_mlfan_curr_index) >= mpfan_next->loopstart + mpfan_next->totloop) {
- *r_mlfan_curr_index = mpfan_next->loopstart;
- }
- *r_mlfan_vert_index = *r_mlfan_curr_index;
- }
- *r_mlfan_curr = &mloops[*r_mlfan_curr_index];
- /* And now we are back in sync, mlfan_curr_index is the index of mlfan_curr! Pff! */
-}
-
-static void split_loop_nor_single_do(LoopSplitTaskDataCommon *common_data, LoopSplitTaskData *data)
-{
- MLoopNorSpaceArray *lnors_spacearr = common_data->lnors_spacearr;
- const short(*clnors_data)[2] = common_data->clnors_data;
-
- const MVert *mverts = common_data->mverts;
- const MEdge *medges = common_data->medges;
- const float(*polynors)[3] = common_data->polynors;
-
- MLoopNorSpace *lnor_space = data->lnor_space;
- float(*lnor)[3] = data->lnor;
- const MLoop *ml_curr = data->ml_curr;
- const MLoop *ml_prev = data->ml_prev;
- const int ml_curr_index = data->ml_curr_index;
-#if 0 /* Not needed for 'single' loop. */
- const int ml_prev_index = data->ml_prev_index;
- const int *e2l_prev = data->e2l_prev;
-#endif
- const int mp_index = data->mp_index;
-
- /* Simple case (both edges around that vertex are sharp in current polygon),
- * this loop just takes its poly normal.
- */
- copy_v3_v3(*lnor, polynors[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) {
- float vec_curr[3], vec_prev[3];
-
- const uint mv_pivot_index = ml_curr->v; /* The vertex we are "fanning" around! */
- const MVert *mv_pivot = &mverts[mv_pivot_index];
- const MEdge *me_curr = &medges[ml_curr->e];
- const MVert *mv_2 = (me_curr->v1 == mv_pivot_index) ? &mverts[me_curr->v2] :
- &mverts[me_curr->v1];
- const MEdge *me_prev = &medges[ml_prev->e];
- const MVert *mv_3 = (me_prev->v1 == mv_pivot_index) ? &mverts[me_prev->v2] :
- &mverts[me_prev->v1];
-
- sub_v3_v3v3(vec_curr, mv_2->co, mv_pivot->co);
- normalize_v3(vec_curr);
- sub_v3_v3v3(vec_prev, mv_3->co, mv_pivot->co);
- 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... */
- BKE_lnor_space_add_loop(lnors_spacearr, lnor_space, ml_curr_index, NULL, true);
-
- if (clnors_data) {
- BKE_lnor_space_custom_data_to_normal(lnor_space, clnors_data[ml_curr_index], *lnor);
- }
- }
-}
-
-static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSplitTaskData *data)
-{
- MLoopNorSpaceArray *lnors_spacearr = common_data->lnors_spacearr;
- float(*loopnors)[3] = common_data->loopnors;
- short(*clnors_data)[2] = common_data->clnors_data;
-
- const MVert *mverts = common_data->mverts;
- const MEdge *medges = common_data->medges;
- const MLoop *mloops = common_data->mloops;
- const MPoly *mpolys = common_data->mpolys;
- const int(*edge_to_loops)[2] = common_data->edge_to_loops;
- const int *loop_to_poly = common_data->loop_to_poly;
- const float(*polynors)[3] = common_data->polynors;
-
- MLoopNorSpace *lnor_space = data->lnor_space;
-#if 0 /* Not needed for 'fan' loops. */
- float(*lnor)[3] = data->lnor;
-#endif
- const MLoop *ml_curr = data->ml_curr;
- const MLoop *ml_prev = data->ml_prev;
- const int ml_curr_index = data->ml_curr_index;
- const int ml_prev_index = data->ml_prev_index;
- const int mp_index = data->mp_index;
- const int *e2l_prev = data->e2l_prev;
-
- BLI_Stack *edge_vectors = data->edge_vectors;
-
- /* 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).
- */
- const uint mv_pivot_index = ml_curr->v; /* The vertex we are "fanning" around! */
- const MVert *mv_pivot = &mverts[mv_pivot_index];
-
- /* ml_curr would be mlfan_prev if we needed that one. */
- const MEdge *me_org = &medges[ml_curr->e];
-
- const int *e2lfan_curr;
- float vec_curr[3], vec_prev[3], vec_org[3];
- const MLoop *mlfan_curr;
- float lnor[3] = {0.0f, 0.0f, 0.0f};
- /* mlfan_vert_index: the loop of our current edge might not be the loop of our current vertex! */
- int mlfan_curr_index, mlfan_vert_index, mpfan_curr_index;
-
- /* We validate clnors data on the fly - cheapest way to do! */
- int clnors_avg[2] = {0, 0};
- short(*clnor_ref)[2] = NULL;
- int clnors_nbr = 0;
- bool clnors_invalid = false;
-
- /* Temp loop normal stack. */
- BLI_SMALLSTACK_DECLARE(normal, float *);
- /* Temp clnors stack. */
- BLI_SMALLSTACK_DECLARE(clnors, short *);
-
- e2lfan_curr = e2l_prev;
- mlfan_curr = ml_prev;
- mlfan_curr_index = ml_prev_index;
- mlfan_vert_index = ml_curr_index;
- mpfan_curr_index = mp_index;
-
- BLI_assert(mlfan_curr_index >= 0);
- BLI_assert(mlfan_vert_index >= 0);
- BLI_assert(mpfan_curr_index >= 0);
-
- /* Only need to compute previous edge's vector once, then we can just reuse old current one! */
- {
- const MVert *mv_2 = (me_org->v1 == mv_pivot_index) ? &mverts[me_org->v2] : &mverts[me_org->v1];
-
- sub_v3_v3v3(vec_org, mv_2->co, mv_pivot->co);
- normalize_v3(vec_org);
- copy_v3_v3(vec_prev, vec_org);
-
- if (lnors_spacearr) {
- BLI_stack_push(edge_vectors, vec_org);
- }
- }
-
- // printf("FAN: vert %d, start edge %d\n", mv_pivot_index, ml_curr->e);
-
- 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,
- * given the fact that this code should not be called that much in real-life meshes...
- */
- {
- const MVert *mv_2 = (me_curr->v1 == mv_pivot_index) ? &mverts[me_curr->v2] :
- &mverts[me_curr->v1];
-
- sub_v3_v3v3(vec_curr, mv_2->co, mv_pivot->co);
- normalize_v3(vec_curr);
- }
-
- // printf("\thandling edge %d / loop %d\n", mlfan_curr->e, mlfan_curr_index);
-
- {
- /* Code similar to accumulate_vertex_normals_poly_v3. */
- /* Calculate angle between the two poly edges incident on this vertex. */
- const float fac = saacos(dot_v3v3(vec_curr, vec_prev));
- /* Accumulate */
- madd_v3_v3fl(lnor, polynors[mpfan_curr_index], fac);
-
- if (clnors_data) {
- /* Accumulate all clnors, if they are not all equal we have to fix that! */
- short(*clnor)[2] = &clnors_data[mlfan_vert_index];
- if (clnors_nbr) {
- clnors_invalid |= ((*clnor_ref)[0] != (*clnor)[0] || (*clnor_ref)[1] != (*clnor)[1]);
- }
- else {
- clnor_ref = clnor;
- }
- clnors_avg[0] += (*clnor)[0];
- clnors_avg[1] += (*clnor)[1];
- clnors_nbr++;
- /* We store here a pointer to all custom lnors processed. */
- BLI_SMALLSTACK_PUSH(clnors, (short *)*clnor);
- }
- }
-
- /* We store here a pointer to all loop-normals processed. */
- BLI_SMALLSTACK_PUSH(normal, (float *)(loopnors[mlfan_vert_index]));
-
- if (lnors_spacearr) {
- /* Assign current lnor space to current 'vertex' loop. */
- BKE_lnor_space_add_loop(lnors_spacearr, lnor_space, mlfan_vert_index, NULL, false);
- if (me_curr != me_org) {
- /* We store here all edges-normalized vectors processed. */
- BLI_stack_push(edge_vectors, vec_curr);
- }
- }
-
- if (IS_EDGE_SHARP(e2lfan_curr) || (me_curr == me_org)) {
- /* Current edge is sharp and we have finished with this fan of faces around this vert,
- * or this vert is smooth, and we have completed a full turn around it.
- */
- // printf("FAN: Finished!\n");
- break;
- }
-
- copy_v3_v3(vec_prev, vec_curr);
-
- /* Find next loop of the smooth fan. */
- BKE_mesh_loop_manifold_fan_around_vert_next(mloops,
- mpolys,
- loop_to_poly,
- e2lfan_curr,
- mv_pivot_index,
- &mlfan_curr,
- &mlfan_curr_index,
- &mlfan_vert_index,
- &mpfan_curr_index);
-
- e2lfan_curr = edge_to_loops[mlfan_curr->e];
- }
-
- {
- float lnor_len = normalize_v3(lnor);
-
- /* If we are generating lnor spacearr, we can now define the one for this fan,
- * and optionally compute final lnor from custom data too!
- */
- if (lnors_spacearr) {
- if (UNLIKELY(lnor_len == 0.0f)) {
- /* Use vertex normal as fallback! */
- copy_v3_v3(lnor, loopnors[mlfan_vert_index]);
- lnor_len = 1.0f;
- }
-
- BKE_lnor_space_define(lnor_space, lnor, vec_org, vec_curr, edge_vectors);
-
- if (clnors_data) {
- if (clnors_invalid) {
- short *clnor;
-
- clnors_avg[0] /= clnors_nbr;
- clnors_avg[1] /= clnors_nbr;
- /* Fix/update all clnors of this fan with computed average value. */
- if (G.debug & G_DEBUG) {
- printf("Invalid clnors in this fan!\n");
- }
- while ((clnor = BLI_SMALLSTACK_POP(clnors))) {
- // print_v2("org clnor", clnor);
- clnor[0] = (short)clnors_avg[0];
- clnor[1] = (short)clnors_avg[1];
- }
- // print_v2("new clnors", clnors_avg);
- }
- /* Extra bonus: since small-stack is local to this function,
- * no more need to empty it at all cost! */
-
- BKE_lnor_space_custom_data_to_normal(lnor_space, *clnor_ref, lnor);
- }
- }
-
- /* In case we get a zero normal here, just use vertex normal already set! */
- if (LIKELY(lnor_len != 0.0f)) {
- /* Copy back the final computed normal into all related loop-normals. */
- float *nor;
-
- while ((nor = BLI_SMALLSTACK_POP(normal))) {
- copy_v3_v3(nor, lnor);
- }
- }
- /* Extra bonus: since small-stack is local to this function,
- * no more need to empty it at all cost! */
- }
-}
-
-static void loop_split_worker_do(LoopSplitTaskDataCommon *common_data,
- LoopSplitTaskData *data,
- BLI_Stack *edge_vectors)
-{
- BLI_assert(data->ml_curr);
- if (data->e2l_prev) {
- BLI_assert((edge_vectors == NULL) || BLI_stack_is_empty(edge_vectors));
- data->edge_vectors = edge_vectors;
- split_loop_nor_fan_do(common_data, data);
- }
- else {
- /* No need for edge_vectors for 'single' case! */
- split_loop_nor_single_do(common_data, data);
- }
-}
-
-static void loop_split_worker(TaskPool *__restrict pool, void *taskdata)
-{
- LoopSplitTaskDataCommon *common_data = BLI_task_pool_user_data(pool);
- LoopSplitTaskData *data = taskdata;
-
- /* Temp edge vectors stack, only used when computing lnor spacearr. */
- BLI_Stack *edge_vectors = common_data->lnors_spacearr ?
- BLI_stack_new(sizeof(float[3]), __func__) :
- NULL;
-
-#ifdef DEBUG_TIME
- TIMEIT_START_AVERAGED(loop_split_worker);
-#endif
-
- for (int i = 0; i < LOOP_SPLIT_TASK_BLOCK_SIZE; i++, data++) {
- /* A NULL ml_curr is used to tag ended data! */
- if (data->ml_curr == NULL) {
- break;
- }
-
- loop_split_worker_do(common_data, data, edge_vectors);
- }
-
- if (edge_vectors) {
- BLI_stack_free(edge_vectors);
- }
-
-#ifdef DEBUG_TIME
- TIMEIT_END_AVERAGED(loop_split_worker);
-#endif
-}
-
-/**
- * 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.
- */
-static bool loop_split_generator_check_cyclic_smooth_fan(const MLoop *mloops,
- const MPoly *mpolys,
- const int (*edge_to_loops)[2],
- const int *loop_to_poly,
- const int *e2l_prev,
- BLI_bitmap *skip_loops,
- const MLoop *ml_curr,
- const MLoop *ml_prev,
- const int ml_curr_index,
- const int ml_prev_index,
- const int mp_curr_index)
-{
- const uint mv_pivot_index = ml_curr->v; /* The vertex we are "fanning" around! */
- const int *e2lfan_curr;
- const MLoop *mlfan_curr;
- /* mlfan_vert_index: the loop of our current edge might not be the loop of our current vertex! */
- int mlfan_curr_index, mlfan_vert_index, mpfan_curr_index;
-
- e2lfan_curr = e2l_prev;
- if (IS_EDGE_SHARP(e2lfan_curr)) {
- /* Sharp loop, so not a cyclic smooth fan... */
- return false;
- }
-
- mlfan_curr = ml_prev;
- mlfan_curr_index = ml_prev_index;
- mlfan_vert_index = ml_curr_index;
- mpfan_curr_index = mp_curr_index;
-
- BLI_assert(mlfan_curr_index >= 0);
- BLI_assert(mlfan_vert_index >= 0);
- BLI_assert(mpfan_curr_index >= 0);
-
- BLI_assert(!BLI_BITMAP_TEST(skip_loops, mlfan_vert_index));
- BLI_BITMAP_ENABLE(skip_loops, mlfan_vert_index);
-
- while (true) {
- /* Find next loop of the smooth fan. */
- BKE_mesh_loop_manifold_fan_around_vert_next(mloops,
- mpolys,
- loop_to_poly,
- e2lfan_curr,
- mv_pivot_index,
- &mlfan_curr,
- &mlfan_curr_index,
- &mlfan_vert_index,
- &mpfan_curr_index);
-
- e2lfan_curr = edge_to_loops[mlfan_curr->e];
-
- if (IS_EDGE_SHARP(e2lfan_curr)) {
- /* Sharp loop/edge, so not a cyclic smooth fan... */
- return false;
- }
- /* Smooth loop/edge... */
- 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. */
- return true;
- }
- /* ... already checked in some previous looping, we can abort. */
- return false;
- }
-
- /* ... we can skip it in future, and keep checking the smooth fan. */
- BLI_BITMAP_ENABLE(skip_loops, mlfan_vert_index);
- }
-}
-
-static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common_data)
-{
- MLoopNorSpaceArray *lnors_spacearr = common_data->lnors_spacearr;
- float(*loopnors)[3] = common_data->loopnors;
-
- const MLoop *mloops = common_data->mloops;
- const MPoly *mpolys = common_data->mpolys;
- const int *loop_to_poly = common_data->loop_to_poly;
- const int(*edge_to_loops)[2] = common_data->edge_to_loops;
- const int numLoops = common_data->numLoops;
- const int numPolys = common_data->numPolys;
-
- const MPoly *mp;
- int mp_index;
-
- const MLoop *ml_curr;
- const MLoop *ml_prev;
- int ml_curr_index;
- int ml_prev_index;
-
- BLI_bitmap *skip_loops = BLI_BITMAP_NEW(numLoops, __func__);
-
- LoopSplitTaskData *data_buff = NULL;
- int data_idx = 0;
-
- /* Temp edge vectors stack, only used when computing lnor spacearr
- * (and we are not multi-threading). */
- BLI_Stack *edge_vectors = NULL;
-
-#ifdef DEBUG_TIME
- TIMEIT_START_AVERAGED(loop_split_generator);
-#endif
-
- if (!pool) {
- if (lnors_spacearr) {
- edge_vectors = BLI_stack_new(sizeof(float[3]), __func__);
- }
- }
-
- /* 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];
- const int ml_last_index = (mp->loopstart + mp->totloop) - 1;
- ml_curr_index = mp->loopstart;
- ml_prev_index = ml_last_index;
-
- ml_curr = &mloops[ml_curr_index];
- ml_prev = &mloops[ml_prev_index];
- lnors = &loopnors[ml_curr_index];
-
- for (; ml_curr_index <= ml_last_index; ml_curr++, ml_curr_index++, lnors++) {
- const int *e2l_curr = edge_to_loops[ml_curr->e];
- const int *e2l_prev = edge_to_loops[ml_prev->e];
-
-#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. */
-
- /* 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. */
- if (!IS_EDGE_SHARP(e2l_curr) && (BLI_BITMAP_TEST(skip_loops, ml_curr_index) ||
- !loop_split_generator_check_cyclic_smooth_fan(mloops,
- mpolys,
- edge_to_loops,
- loop_to_poly,
- e2l_prev,
- skip_loops,
- ml_curr,
- ml_prev,
- ml_curr_index,
- ml_prev_index,
- mp_index))) {
- // printf("SKIPPING!\n");
- }
- else {
- LoopSplitTaskData *data, data_local;
-
- // printf("PROCESSING!\n");
-
- if (pool) {
- if (data_idx == 0) {
- data_buff = MEM_calloc_arrayN(
- LOOP_SPLIT_TASK_BLOCK_SIZE, sizeof(*data_buff), __func__);
- }
- data = &data_buff[data_idx];
- }
- else {
- data = &data_local;
- memset(data, 0, sizeof(*data));
- }
-
- if (IS_EDGE_SHARP(e2l_curr) && IS_EDGE_SHARP(e2l_prev)) {
- data->lnor = lnors;
- data->ml_curr = ml_curr;
- data->ml_prev = ml_prev;
- data->ml_curr_index = ml_curr_index;
-#if 0 /* Not needed for 'single' loop. */
- data->ml_prev_index = ml_prev_index;
- data->e2l_prev = NULL; /* Tag as 'single' task. */
-#endif
- data->mp_index = mp_index;
- if (lnors_spacearr) {
- data->lnor_space = BKE_lnor_space_create(lnors_spacearr);
- }
- }
- /* 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),
- * and not the alternative (smooth curr_edge, sharp prev_edge).
- * All this due/thanks to link between normals and loop ordering (i.e. winding).
- */
- else {
-#if 0 /* Not needed for 'fan' loops. */
- data->lnor = lnors;
-#endif
- data->ml_curr = ml_curr;
- data->ml_prev = ml_prev;
- data->ml_curr_index = ml_curr_index;
- data->ml_prev_index = ml_prev_index;
- data->e2l_prev = e2l_prev; /* Also tag as 'fan' task. */
- data->mp_index = mp_index;
- if (lnors_spacearr) {
- data->lnor_space = BKE_lnor_space_create(lnors_spacearr);
- }
- }
-
- if (pool) {
- data_idx++;
- if (data_idx == LOOP_SPLIT_TASK_BLOCK_SIZE) {
- BLI_task_pool_push(pool, loop_split_worker, data_buff, true, NULL);
- data_idx = 0;
- }
- }
- else {
- loop_split_worker_do(common_data, data, edge_vectors);
- }
- }
-
- ml_prev = ml_curr;
- ml_prev_index = ml_curr_index;
- }
- }
-
- /* 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, NULL);
- }
-
- if (edge_vectors) {
- BLI_stack_free(edge_vectors);
- }
- MEM_freeN(skip_loops);
-
-#ifdef DEBUG_TIME
- TIMEIT_END_AVERAGED(loop_split_generator);
-#endif
-}
-
-/**
- * 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).
- */
-void BKE_mesh_normals_loop_split(const MVert *mverts,
- const int UNUSED(numVerts),
- MEdge *medges,
- const int numEdges,
- MLoop *mloops,
- float (*r_loopnors)[3],
- const int numLoops,
- MPoly *mpolys,
- const float (*polynors)[3],
- const int numPolys,
- const bool use_split_normals,
- const float split_angle,
- MLoopNorSpaceArray *r_lnors_spacearr,
- 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! */
- 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.
- */
- int mp_index;
-
- for (mp_index = 0; mp_index < numPolys; mp_index++) {
- MPoly *mp = &mpolys[mp_index];
- int ml_index = mp->loopstart;
- const int ml_index_end = ml_index + mp->totloop;
- const bool is_poly_flat = ((mp->flag & ME_SMOOTH) == 0);
-
- for (; ml_index < ml_index_end; ml_index++) {
- if (r_loop_to_poly) {
- r_loop_to_poly[ml_index] = mp_index;
- }
- if (is_poly_flat) {
- copy_v3_v3(r_loopnors[ml_index], polynors[mp_index]);
- }
- else {
- normal_short_to_float_v3(r_loopnors[ml_index], mverts[mloops[ml_index].v].no);
- }
- }
- }
- 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 loose 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. */
- int *loop_to_poly = r_loop_to_poly ?
- r_loop_to_poly :
- MEM_malloc_arrayN((size_t)numLoops, sizeof(*loop_to_poly), __func__);
-
- /* When using custom loop normals, disable the angle feature! */
- const bool check_angle = (split_angle < (float)M_PI) && (clnors_data == NULL);
-
- MLoopNorSpaceArray _lnors_spacearr = {NULL};
-
-#ifdef DEBUG_TIME
- TIMEIT_START_AVERAGED(BKE_mesh_normals_loop_split);
-#endif
-
- if (!r_lnors_spacearr && clnors_data) {
- /* We need to compute lnor spacearr if some custom lnor data are given to us! */
- r_lnors_spacearr = &_lnors_spacearr;
- }
- if (r_lnors_spacearr) {
- BKE_lnor_spacearr_init(r_lnors_spacearr, numLoops, MLNOR_SPACEARR_LOOP_INDEX);
- }
-
- /* Init data common to all tasks. */
- LoopSplitTaskDataCommon common_data = {
- .lnors_spacearr = r_lnors_spacearr,
- .loopnors = r_loopnors,
- .clnors_data = clnors_data,
- .mverts = mverts,
- .medges = medges,
- .mloops = mloops,
- .mpolys = mpolys,
- .edge_to_loops = edge_to_loops,
- .loop_to_poly = loop_to_poly,
- .polynors = polynors,
- .numEdges = numEdges,
- .numLoops = numLoops,
- .numPolys = numPolys,
- };
-
- /* This first loop check which edges are actually smooth, and compute edge vectors. */
- mesh_edges_sharp_tag(&common_data, check_angle, split_angle, false);
-
- if (numLoops < LOOP_SPLIT_TASK_BLOCK_SIZE * 8) {
- /* Not enough loops to be worth the whole threading overhead... */
- loop_split_generator(NULL, &common_data);
- }
- else {
- TaskPool *task_pool = BLI_task_pool_create(&common_data, TASK_PRIORITY_HIGH);
-
- loop_split_generator(task_pool, &common_data);
-
- BLI_task_pool_work_and_wait(task_pool);
-
- BLI_task_pool_free(task_pool);
- }
-
- MEM_freeN(edge_to_loops);
- if (!r_loop_to_poly) {
- MEM_freeN(loop_to_poly);
- }
-
- if (r_lnors_spacearr) {
- if (r_lnors_spacearr == &_lnors_spacearr) {
- BKE_lnor_spacearr_free(r_lnors_spacearr);
- }
- }
-
-#ifdef DEBUG_TIME
- TIMEIT_END_AVERAGED(BKE_mesh_normals_loop_split);
-#endif
-}
-
-#undef INDEX_UNSET
-#undef INDEX_INVALID
-#undef IS_EDGE_SHARP
-
-/**
- * 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.
- * 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.
- */
-static void mesh_normals_loop_custom_set(const MVert *mverts,
- const int numVerts,
- MEdge *medges,
- const int numEdges,
- MLoop *mloops,
- float (*r_custom_loopnors)[3],
- const int numLoops,
- MPoly *mpolys,
- const float (*polynors)[3],
- const int numPolys,
- 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.
- * 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?).
- * 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! */
- const bool use_split_normals = true;
- const float split_angle = (float)M_PI;
-
- BLI_SMALLSTACK_DECLARE(clnors_data, short *);
-
- /* Compute current lnor spacearr. */
- BKE_mesh_normals_loop_split(mverts,
- numVerts,
- medges,
- numEdges,
- mloops,
- lnors,
- numLoops,
- mpolys,
- polynors,
- numPolys,
- use_split_normals,
- split_angle,
- &lnors_spacearr,
- NULL,
- loop_to_poly);
-
- /* Set all given zero vectors to their default value. */
- if (use_vertices) {
- for (int i = 0; i < numVerts; i++) {
- if (is_zero_v3(r_custom_loopnors[i])) {
- normal_short_to_float_v3(r_custom_loopnors[i], mverts[i].no);
- }
- }
- }
- else {
- for (int i = 0; i < numLoops; i++) {
- if (is_zero_v3(r_custom_loopnors[i])) {
- copy_v3_v3(r_custom_loopnors[i], lnors[i]);
- }
- }
- }
-
- 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.
- */
- if (!use_vertices) {
- for (int i = 0; i < numLoops; i++) {
- if (!lnors_spacearr.lspacearr[i]) {
- /* This should not happen in theory, but in some rare case (probably ugly geometry)
- * we can get some NULL loopspacearr at this point. :/
- * Maybe we should set those loops' edges as sharp?
- */
- BLI_BITMAP_ENABLE(done_loops, i);
- if (G.debug & G_DEBUG) {
- printf("WARNING! Getting invalid NULL loop space for loop %d!\n", i);
- }
- continue;
- }
-
- 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!
- */
- if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
- BLI_BITMAP_ENABLE(done_loops, i);
- continue;
- }
-
- LinkNode *loops = lnors_spacearr.lspacearr[i]->loops;
- MLoop *prev_ml = NULL;
- const float *org_nor = NULL;
-
- while (loops) {
- const int lidx = POINTER_AS_INT(loops->link);
- MLoop *ml = &mloops[lidx];
- const int nidx = lidx;
- float *nor = r_custom_loopnors[nidx];
-
- if (!org_nor) {
- org_nor = nor;
- }
- 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.
- */
- const MPoly *mp = &mpolys[loop_to_poly[lidx]];
- const MLoop *mlp =
- &mloops[(lidx == mp->loopstart) ? mp->loopstart + mp->totloop - 1 : lidx - 1];
- medges[(prev_ml->e == mlp->e) ? prev_ml->e : ml->e].flag |= ME_SHARP;
-
- org_nor = nor;
- }
-
- prev_ml = ml;
- loops = loops->next;
- BLI_BITMAP_ENABLE(done_loops, lidx);
- }
-
- /* 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;
- if (loops && org_nor) {
- const int lidx = POINTER_AS_INT(loops->link);
- MLoop *ml = &mloops[lidx];
- const int nidx = lidx;
- float *nor = r_custom_loopnors[nidx];
-
- if (dot_v3v3(org_nor, nor) < LNOR_SPACE_TRIGO_THRESHOLD) {
- const MPoly *mp = &mpolys[loop_to_poly[lidx]];
- const MLoop *mlp =
- &mloops[(lidx == mp->loopstart) ? mp->loopstart + mp->totloop - 1 : lidx - 1];
- medges[(prev_ml->e == mlp->e) ? prev_ml->e : ml->e].flag |= ME_SHARP;
- }
- }
- }
- }
-
- /* And now, recompute our new auto lnors and lnor spacearr! */
- BKE_lnor_spacearr_clear(&lnors_spacearr);
- BKE_mesh_normals_loop_split(mverts,
- numVerts,
- medges,
- numEdges,
- mloops,
- lnors,
- numLoops,
- mpolys,
- polynors,
- numPolys,
- use_split_normals,
- split_angle,
- &lnors_spacearr,
- NULL,
- loop_to_poly);
- }
- else {
- 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. */
- for (int i = 0; i < numLoops; i++) {
- if (!lnors_spacearr.lspacearr[i]) {
- BLI_BITMAP_DISABLE(done_loops, i);
- if (G.debug & G_DEBUG) {
- printf("WARNING! Still getting invalid NULL loop space in second loop for loop %d!\n", i);
- }
- continue;
- }
-
- 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).
- */
- LinkNode *loops = lnors_spacearr.lspacearr[i]->loops;
- if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
- BLI_assert(POINTER_AS_INT(loops) == i);
- const int nidx = use_vertices ? (int)mloops[i].v : i;
- float *nor = r_custom_loopnors[nidx];
-
- BKE_lnor_space_custom_normal_to_data(lnors_spacearr.lspacearr[i], nor, r_clnors_data[i]);
- BLI_BITMAP_DISABLE(done_loops, i);
- }
- else {
- int nbr_nors = 0;
- float avg_nor[3];
- short clnor_data_tmp[2], *clnor_data;
-
- zero_v3(avg_nor);
- while (loops) {
- const int lidx = POINTER_AS_INT(loops->link);
- const int nidx = use_vertices ? (int)mloops[lidx].v : lidx;
- float *nor = r_custom_loopnors[nidx];
-
- nbr_nors++;
- add_v3_v3(avg_nor, nor);
- BLI_SMALLSTACK_PUSH(clnors_data, (short *)r_clnors_data[lidx]);
-
- loops = loops->next;
- BLI_BITMAP_DISABLE(done_loops, lidx);
- }
-
- mul_v3_fl(avg_nor, 1.0f / (float)nbr_nors);
- BKE_lnor_space_custom_normal_to_data(lnors_spacearr.lspacearr[i], avg_nor, clnor_data_tmp);
-
- while ((clnor_data = BLI_SMALLSTACK_POP(clnors_data))) {
- clnor_data[0] = clnor_data_tmp[0];
- clnor_data[1] = clnor_data_tmp[1];
- }
- }
- }
- }
-
- MEM_freeN(lnors);
- MEM_freeN(loop_to_poly);
- MEM_freeN(done_loops);
- BKE_lnor_spacearr_free(&lnors_spacearr);
-}
-
-void BKE_mesh_normals_loop_custom_set(const MVert *mverts,
- const int numVerts,
- MEdge *medges,
- const int numEdges,
- MLoop *mloops,
- float (*r_custom_loopnors)[3],
- const int numLoops,
- MPoly *mpolys,
- const float (*polynors)[3],
- const int numPolys,
- short (*r_clnors_data)[2])
-{
- mesh_normals_loop_custom_set(mverts,
- numVerts,
- medges,
- numEdges,
- mloops,
- r_custom_loopnors,
- numLoops,
- mpolys,
- polynors,
- numPolys,
- r_clnors_data,
- false);
-}
-
-void BKE_mesh_normals_loop_custom_from_vertices_set(const MVert *mverts,
- float (*r_custom_vertnors)[3],
- const int numVerts,
- MEdge *medges,
- const int numEdges,
- MLoop *mloops,
- const int numLoops,
- MPoly *mpolys,
- const float (*polynors)[3],
- const int numPolys,
- short (*r_clnors_data)[2])
-{
- mesh_normals_loop_custom_set(mverts,
- numVerts,
- medges,
- numEdges,
- mloops,
- r_custom_vertnors,
- numLoops,
- mpolys,
- polynors,
- numPolys,
- r_clnors_data,
- true);
-}
-
-static void mesh_set_custom_normals(Mesh *mesh, float (*r_custom_nors)[3], const bool use_vertices)
-{
- short(*clnors)[2];
- const int numloops = mesh->totloop;
-
- clnors = CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL);
- if (clnors != NULL) {
- memset(clnors, 0, sizeof(*clnors) * (size_t)numloops);
- }
- else {
- clnors = CustomData_add_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numloops);
- }
-
- float(*polynors)[3] = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
- bool free_polynors = false;
- if (polynors == NULL) {
- polynors = MEM_mallocN(sizeof(float[3]) * (size_t)mesh->totpoly, __func__);
- BKE_mesh_calc_normals_poly(mesh->mvert,
- NULL,
- mesh->totvert,
- mesh->mloop,
- mesh->mpoly,
- mesh->totloop,
- mesh->totpoly,
- polynors,
- false);
- free_polynors = true;
- }
-
- mesh_normals_loop_custom_set(mesh->mvert,
- mesh->totvert,
- mesh->medge,
- mesh->totedge,
- mesh->mloop,
- r_custom_nors,
- mesh->totloop,
- mesh->mpoly,
- polynors,
- mesh->totpoly,
- clnors,
- use_vertices);
-
- if (free_polynors) {
- MEM_freeN(polynors);
- }
-}
-
-/**
- * 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.
- */
-void BKE_mesh_set_custom_normals(Mesh *mesh, float (*r_custom_loopnors)[3])
-{
- mesh_set_custom_normals(mesh, r_custom_loopnors, false);
-}
-
-/**
- * Higher level functions hiding most of the code needed around call to
- * #BKE_mesh_normals_loop_custom_from_vertices_set().
- *
- * \param r_custom_vertnors: is not const, since code will replace zero_v3 normals there
- * with automatically computed vectors.
- */
-void BKE_mesh_set_custom_normals_from_vertices(Mesh *mesh, float (*r_custom_vertnors)[3])
-{
- mesh_set_custom_normals(mesh, r_custom_vertnors, true);
-}
-
-/**
- * Computes average per-vertex normals from given custom loop normals.
- *
- * \param clnors: The computed custom loop normals.
- * \param r_vert_clnors: The (already allocated) array where to store averaged per-vertex normals.
- */
-void BKE_mesh_normals_loop_to_vertex(const int numVerts,
- const MLoop *mloops,
- const int numLoops,
- const float (*clnors)[3],
- float (*r_vert_clnors)[3])
-{
- int *vert_loops_nbr = MEM_calloc_arrayN((size_t)numVerts, sizeof(*vert_loops_nbr), __func__);
-
- copy_vn_fl((float *)r_vert_clnors, 3 * numVerts, 0.0f);
-
- int i;
- const MLoop *ml;
- for (i = 0, ml = mloops; i < numLoops; i++, ml++) {
- const uint v = ml->v;
-
- add_v3_v3(r_vert_clnors[v], clnors[i]);
- vert_loops_nbr[v]++;
- }
-
- for (i = 0; i < numVerts; i++) {
- mul_v3_fl(r_vert_clnors[i], 1.0f / (float)vert_loops_nbr[i]);
- }
-
- MEM_freeN(vert_loops_nbr);
-}
-
-#undef LNOR_SPACE_TRIGO_THRESHOLD
-
-/** \} */
/* -------------------------------------------------------------------- */
/** \name Polygon Calculations
@@ -3280,8 +1174,8 @@ void BKE_mesh_flush_select_from_polys_ex(MVert *mvert,
i = totpoly;
for (mp = mpoly; i--; mp++) {
- /* assume if its selected its not hidden and none of its verts/edges are hidden
- * (a common assumption)*/
+ /* Assume if its selected its not hidden and none of its verts/edges are hidden
+ * (a common assumption). */
if (mp->flag & ME_FACE_SEL) {
const MLoop *ml;
int j;
diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c
index d4119f48193..c469a65449d 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -535,7 +535,7 @@ void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map,
*
* This has the advantage that it can operate on any data-types.
*
- * \param totsource: The total number of elements the that \a final_origindex points to.
+ * \param totsource: The total number of elements that \a final_origindex points to.
* \param totfinal: The size of \a final_origindex
* \param final_origindex: The size of the final array.
*
diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c
index fb73152cb8e..1e51ee73c7c 100644
--- a/source/blender/blenkernel/intern/mesh_merge.c
+++ b/source/blender/blenkernel/intern/mesh_merge.c
@@ -109,7 +109,7 @@ static int cddm_poly_compare(MLoop *mloop_array,
i_loop_source++;
if (i_loop_source == mpoly_source->totloop) {
- /* End of loops for source, must match end of loop for target. */
+ /* End of loops for source, must match end of loop for target. */
if (i_loop_target_offset == mpoly_target->totloop - 1) {
compare_completed = true;
same_loops = true;
@@ -597,7 +597,7 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
mp_new->loopstart = STACK_SIZE(mloop) - c;
STACK_PUSH(oldp, i);
- } /* end of the loop that tests polys */
+ } /* End of the loop that tests polys. */
if (poly_gset) {
// printf("hash quality %.6f\n", BLI_gset_calc_quality(poly_gset));
@@ -606,11 +606,11 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
MEM_freeN(poly_keys);
}
- /*create new cddm*/
+ /* Create new cddm. */
result = BKE_mesh_new_nomain_from_template(
mesh, STACK_SIZE(mvert), STACK_SIZE(medge), 0, STACK_SIZE(mloop), STACK_SIZE(mpoly));
- /*update edge indices and copy customdata*/
+ /* Update edge indices and copy customdata. */
med = medge;
for (i = 0; i < result->totedge; i++, med++) {
BLI_assert(newv[med->v1] != -1);
@@ -624,7 +624,7 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
CustomData_copy_data(&mesh->edata, &result->edata, olde[i], i, 1);
}
- /*update loop indices and copy customdata*/
+ /* Update loop indices and copy customdata. */
ml = mloop;
for (i = 0; i < result->totloop; i++, ml++) {
/* Edge remapping has already be done in main loop handling part above. */
@@ -634,19 +634,19 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
CustomData_copy_data(&mesh->ldata, &result->ldata, oldl[i], i, 1);
}
- /*copy vertex customdata*/
+ /* Copy vertex customdata. */
mv = mvert;
for (i = 0; i < result->totvert; i++, mv++) {
CustomData_copy_data(&mesh->vdata, &result->vdata, oldv[i], i, 1);
}
- /*copy poly customdata*/
+ /* Copy poly customdata. */
mp = mpoly;
for (i = 0; i < result->totpoly; i++, mp++) {
CustomData_copy_data(&mesh->pdata, &result->pdata, oldp[i], i, 1);
}
- /*copy over data. CustomData_add_layer can do this, need to look it up.*/
+ /* Copy over data. #CustomData_add_layer can do this, need to look it up. */
memcpy(result->mvert, mvert, sizeof(MVert) * STACK_SIZE(mvert));
memcpy(result->medge, medge, sizeof(MEdge) * STACK_SIZE(medge));
memcpy(result->mloop, mloop, sizeof(MLoop) * STACK_SIZE(mloop));
diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c
index 3d30c218fba..9aeaa1ada52 100644
--- a/source/blender/blenkernel/intern/mesh_mirror.c
+++ b/source/blender/blenkernel/intern/mesh_mirror.c
@@ -70,9 +70,9 @@ Mesh *BKE_mesh_mirror_bisect_on_mirror_plane_for_modifier(MirrorModifierData *mm
/* Define bisecting plane (aka mirror plane). */
float plane[4];
if (!do_bisect_flip_axis) {
- /* That reversed condition is a tad weird, but for some reason that's how you keep
- * the part of the mesh which is on the non-mirrored side when flip option is disabled,
- * think that that is the expected behavior. */
+ /* That reversed condition is a little weird, but for some reason that's how you keep
+ * the part of the mesh which is on the non-mirrored side when flip option is disabled.
+ * I think this is the expected behavior. */
negate_v3(plane_no);
}
plane_from_point_normal_v3(plane, plane_co, plane_no);
diff --git a/source/blender/blenkernel/intern/mesh_normals.c b/source/blender/blenkernel/intern/mesh_normals.c
new file mode 100644
index 00000000000..a268f814cd0
--- /dev/null
+++ b/source/blender/blenkernel/intern/mesh_normals.c
@@ -0,0 +1,2144 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup bke
+ *
+ * Mesh normal calculation functions.
+ *
+ * \see bmesh_mesh_normals.c for the equivalent #BMesh functionality.
+ */
+
+#include <limits.h>
+
+#include "CLG_log.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BLI_alloca.h"
+#include "BLI_bitmap.h"
+
+#include "BLI_linklist.h"
+#include "BLI_linklist_stack.h"
+#include "BLI_math.h"
+#include "BLI_memarena.h"
+#include "BLI_stack.h"
+#include "BLI_task.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_customdata.h"
+#include "BKE_editmesh_cache.h"
+#include "BKE_global.h"
+#include "BKE_mesh.h"
+
+// #define DEBUG_TIME
+
+#ifdef DEBUG_TIME
+# include "PIL_time.h"
+# include "PIL_time_utildefines.h"
+#endif
+
+static CLG_LogRef LOG = {"bke.mesh_normals"};
+
+/* -------------------------------------------------------------------- */
+/** \name Mesh Normal Calculation
+ * \{ */
+
+/**
+ * Call when there are no polygons.
+ */
+static void mesh_calc_normals_vert_fallback(MVert *mverts, int numVerts)
+{
+ for (int i = 0; i < numVerts; i++) {
+ MVert *mv = &mverts[i];
+ float no[3];
+
+ normalize_v3_v3(no, mv->co);
+ normal_float_to_short_v3(mv->no, no);
+ }
+}
+
+/* TODO(Sybren): we can probably rename this to BKE_mesh_calc_normals_mapping(),
+ * and remove the function of the same name below, as that one doesn't seem to be
+ * called anywhere. */
+void BKE_mesh_calc_normals_mapping_simple(struct Mesh *mesh)
+{
+ const bool only_face_normals = CustomData_is_referenced_layer(&mesh->vdata, CD_MVERT);
+
+ BKE_mesh_calc_normals_mapping_ex(mesh->mvert,
+ mesh->totvert,
+ mesh->mloop,
+ mesh->mpoly,
+ mesh->totloop,
+ mesh->totpoly,
+ NULL,
+ mesh->mface,
+ mesh->totface,
+ NULL,
+ NULL,
+ only_face_normals);
+}
+
+/* Calculate vertex and face normals, face normals are returned in *r_faceNors if non-NULL
+ * and vertex normals are stored in actual mverts.
+ */
+void BKE_mesh_calc_normals_mapping(MVert *mverts,
+ int numVerts,
+ const MLoop *mloop,
+ const MPoly *mpolys,
+ int numLoops,
+ int numPolys,
+ float (*r_polyNors)[3],
+ const MFace *mfaces,
+ int numFaces,
+ const int *origIndexFace,
+ float (*r_faceNors)[3])
+{
+ BKE_mesh_calc_normals_mapping_ex(mverts,
+ numVerts,
+ mloop,
+ mpolys,
+ numLoops,
+ numPolys,
+ r_polyNors,
+ mfaces,
+ numFaces,
+ origIndexFace,
+ r_faceNors,
+ false);
+}
+/* extended version of 'BKE_mesh_calc_normals_poly' with option not to calc vertex normals */
+void BKE_mesh_calc_normals_mapping_ex(MVert *mverts,
+ int numVerts,
+ const MLoop *mloop,
+ const MPoly *mpolys,
+ int numLoops,
+ int numPolys,
+ float (*r_polyNors)[3],
+ const MFace *mfaces,
+ int numFaces,
+ const int *origIndexFace,
+ float (*r_faceNors)[3],
+ const bool only_face_normals)
+{
+ float(*pnors)[3] = r_polyNors, (*fnors)[3] = r_faceNors;
+
+ if (numPolys == 0) {
+ if (only_face_normals == false) {
+ mesh_calc_normals_vert_fallback(mverts, numVerts);
+ }
+ return;
+ }
+
+ /* if we are not calculating verts and no verts were passes then we have nothing to do */
+ if ((only_face_normals == true) && (r_polyNors == NULL) && (r_faceNors == NULL)) {
+ CLOG_WARN(&LOG, "called with nothing to do");
+ return;
+ }
+
+ if (!pnors) {
+ pnors = MEM_calloc_arrayN((size_t)numPolys, sizeof(float[3]), __func__);
+ }
+ /* 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,
+ * so make them optional */
+ BKE_mesh_calc_normals_poly(
+ mverts, NULL, numVerts, mloop, mpolys, numLoops, numPolys, pnors, false);
+ }
+ else {
+ /* only calc poly normals */
+ const MPoly *mp = mpolys;
+ for (int i = 0; i < numPolys; i++, mp++) {
+ BKE_mesh_calc_poly_normal(mp, mloop + mp->loopstart, mverts, pnors[i]);
+ }
+ }
+
+ if (origIndexFace &&
+ /* fnors == r_faceNors */ /* NO NEED TO ALLOC YET */
+ fnors != NULL &&
+ numFaces) {
+ const MFace *mf = mfaces;
+ for (int i = 0; i < numFaces; i++, mf++, origIndexFace++) {
+ if (*origIndexFace < numPolys) {
+ copy_v3_v3(fnors[i], pnors[*origIndexFace]);
+ }
+ else {
+ /* eek, we're not corresponding to polys */
+ CLOG_ERROR(&LOG, "tessellation face indices are incorrect. normals may look bad.");
+ }
+ }
+ }
+
+ if (pnors != r_polyNors) {
+ MEM_freeN(pnors);
+ }
+ /* if (fnors != r_faceNors) MEM_freeN(fnors); */ /* NO NEED TO ALLOC YET */
+
+ fnors = pnors = NULL;
+}
+
+typedef struct MeshCalcNormalsData {
+ const MPoly *mpolys;
+ const MLoop *mloop;
+ MVert *mverts;
+ float (*pnors)[3];
+ float (*lnors_weighted)[3];
+ float (*vnors)[3];
+} MeshCalcNormalsData;
+
+static void mesh_calc_normals_poly_cb(void *__restrict userdata,
+ const int pidx,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ MeshCalcNormalsData *data = userdata;
+ const MPoly *mp = &data->mpolys[pidx];
+
+ BKE_mesh_calc_poly_normal(mp, data->mloop + mp->loopstart, data->mverts, data->pnors[pidx]);
+}
+
+static void mesh_calc_normals_poly_prepare_cb(void *__restrict userdata,
+ const int pidx,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ MeshCalcNormalsData *data = userdata;
+ const MPoly *mp = &data->mpolys[pidx];
+ const MLoop *ml = &data->mloop[mp->loopstart];
+ const MVert *mverts = data->mverts;
+
+ float pnor_temp[3];
+ float *pnor = data->pnors ? data->pnors[pidx] : pnor_temp;
+ float(*lnors_weighted)[3] = data->lnors_weighted;
+
+ const int nverts = mp->totloop;
+ float(*edgevecbuf)[3] = BLI_array_alloca(edgevecbuf, (size_t)nverts);
+
+ /* Polygon Normal and edge-vector */
+ /* inline version of #BKE_mesh_calc_poly_normal, also does edge-vectors */
+ {
+ int i_prev = nverts - 1;
+ const float *v_prev = mverts[ml[i_prev].v].co;
+ const float *v_curr;
+
+ zero_v3(pnor);
+ /* Newell's Method */
+ for (int i = 0; i < nverts; i++) {
+ v_curr = mverts[ml[i].v].co;
+ add_newell_cross_v3_v3v3(pnor, v_prev, v_curr);
+
+ /* Unrelated to normalize, calculate edge-vector */
+ sub_v3_v3v3(edgevecbuf[i_prev], v_prev, v_curr);
+ normalize_v3(edgevecbuf[i_prev]);
+ i_prev = i;
+
+ v_prev = v_curr;
+ }
+ if (UNLIKELY(normalize_v3(pnor) == 0.0f)) {
+ pnor[2] = 1.0f; /* other axes set to 0.0 */
+ }
+ }
+
+ /* accumulate angle weighted face normal */
+ /* inline version of #accumulate_vertex_normals_poly_v3,
+ * split between this threaded callback and #mesh_calc_normals_poly_accum_cb. */
+ {
+ const float *prev_edge = edgevecbuf[nverts - 1];
+
+ for (int i = 0; i < nverts; i++) {
+ const int lidx = mp->loopstart + i;
+ const float *cur_edge = edgevecbuf[i];
+
+ /* calculate angle between the two poly edges incident on
+ * this vertex */
+ const float fac = saacos(-dot_v3v3(cur_edge, prev_edge));
+
+ /* Store for later accumulation */
+ mul_v3_v3fl(lnors_weighted[lidx], pnor, fac);
+
+ prev_edge = cur_edge;
+ }
+ }
+}
+
+static void mesh_calc_normals_poly_finalize_cb(void *__restrict userdata,
+ const int vidx,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ MeshCalcNormalsData *data = userdata;
+
+ MVert *mv = &data->mverts[vidx];
+ float *no = data->vnors[vidx];
+
+ if (UNLIKELY(normalize_v3(no) == 0.0f)) {
+ /* following Mesh convention; we use vertex coordinate itself for normal in this case */
+ normalize_v3_v3(no, mv->co);
+ }
+
+ normal_float_to_short_v3(mv->no, no);
+}
+
+void BKE_mesh_calc_normals_poly(MVert *mverts,
+ float (*r_vertnors)[3],
+ int numVerts,
+ const MLoop *mloop,
+ const MPoly *mpolys,
+ int numLoops,
+ int numPolys,
+ float (*r_polynors)[3],
+ const bool only_face_normals)
+{
+ float(*pnors)[3] = r_polynors;
+
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.min_iter_per_thread = 1024;
+
+ if (only_face_normals) {
+ BLI_assert((pnors != NULL) || (numPolys == 0));
+ BLI_assert(r_vertnors == NULL);
+
+ MeshCalcNormalsData data = {
+ .mpolys = mpolys,
+ .mloop = mloop,
+ .mverts = mverts,
+ .pnors = pnors,
+ };
+
+ BLI_task_parallel_range(0, numPolys, &data, mesh_calc_normals_poly_cb, &settings);
+ return;
+ }
+
+ float(*vnors)[3] = r_vertnors;
+ float(*lnors_weighted)[3] = MEM_malloc_arrayN(
+ (size_t)numLoops, sizeof(*lnors_weighted), __func__);
+ bool free_vnors = false;
+
+ /* first go through and calculate normals for all the polys */
+ if (vnors == NULL) {
+ vnors = MEM_calloc_arrayN((size_t)numVerts, sizeof(*vnors), __func__);
+ free_vnors = true;
+ }
+ else {
+ memset(vnors, 0, sizeof(*vnors) * (size_t)numVerts);
+ }
+
+ MeshCalcNormalsData data = {
+ .mpolys = mpolys,
+ .mloop = mloop,
+ .mverts = mverts,
+ .pnors = pnors,
+ .lnors_weighted = lnors_weighted,
+ .vnors = vnors,
+ };
+
+ /* Compute poly normals, and prepare weighted loop normals. */
+ 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),
+ * 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]);
+ }
+
+ /* Normalize and validate computed vertex normals. */
+ BLI_task_parallel_range(0, numVerts, &data, mesh_calc_normals_poly_finalize_cb, &settings);
+
+ if (free_vnors) {
+ MEM_freeN(vnors);
+ }
+ MEM_freeN(lnors_weighted);
+}
+
+void BKE_mesh_ensure_normals(Mesh *mesh)
+{
+ if (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) {
+ BKE_mesh_calc_normals(mesh);
+ }
+ BLI_assert((mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) == 0);
+}
+
+/**
+ * Called after calculating all modifiers.
+ */
+void BKE_mesh_ensure_normals_for_display(Mesh *mesh)
+{
+ switch ((eMeshWrapperType)mesh->runtime.wrapper_type) {
+ case ME_WRAPPER_TYPE_MDATA:
+ /* Run code below. */
+ break;
+ case ME_WRAPPER_TYPE_BMESH: {
+ struct BMEditMesh *em = mesh->edit_mesh;
+ EditMeshData *emd = mesh->runtime.edit_data;
+ if (emd->vertexCos) {
+ BKE_editmesh_cache_ensure_vert_normals(em, emd);
+ BKE_editmesh_cache_ensure_poly_normals(em, emd);
+ }
+ return;
+ }
+ }
+
+ float(*poly_nors)[3] = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
+ const bool do_vert_normals = (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) != 0;
+ const bool do_poly_normals = (mesh->runtime.cd_dirty_poly & CD_MASK_NORMAL || poly_nors == NULL);
+
+ if (do_vert_normals || do_poly_normals) {
+ const bool do_add_poly_nors_cddata = (poly_nors == NULL);
+ if (do_add_poly_nors_cddata) {
+ poly_nors = MEM_malloc_arrayN((size_t)mesh->totpoly, sizeof(*poly_nors), __func__);
+ }
+
+ /* calculate poly/vert normals */
+ BKE_mesh_calc_normals_poly(mesh->mvert,
+ NULL,
+ mesh->totvert,
+ mesh->mloop,
+ mesh->mpoly,
+ mesh->totloop,
+ mesh->totpoly,
+ poly_nors,
+ !do_vert_normals);
+
+ if (do_add_poly_nors_cddata) {
+ CustomData_add_layer(&mesh->pdata, CD_NORMAL, CD_ASSIGN, poly_nors, mesh->totpoly);
+ }
+
+ mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
+ mesh->runtime.cd_dirty_poly &= ~CD_MASK_NORMAL;
+ }
+}
+
+/* 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
+ TIMEIT_START_AVERAGED(BKE_mesh_calc_normals);
+#endif
+ BKE_mesh_calc_normals_poly(mesh->mvert,
+ NULL,
+ mesh->totvert,
+ mesh->mloop,
+ mesh->mpoly,
+ mesh->totloop,
+ mesh->totpoly,
+ NULL,
+ false);
+#ifdef DEBUG_TIME
+ TIMEIT_END_AVERAGED(BKE_mesh_calc_normals);
+#endif
+ mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
+}
+
+void BKE_mesh_calc_normals_looptri(MVert *mverts,
+ int numVerts,
+ const MLoop *mloop,
+ const MLoopTri *looptri,
+ int looptri_num,
+ float (*r_tri_nors)[3])
+{
+ float(*tnorms)[3] = MEM_calloc_arrayN((size_t)numVerts, sizeof(*tnorms), "tnorms");
+ float(*fnors)[3] = (r_tri_nors) ?
+ r_tri_nors :
+ MEM_calloc_arrayN((size_t)looptri_num, sizeof(*fnors), "meshnormals");
+
+ if (!tnorms || !fnors) {
+ goto cleanup;
+ }
+
+ for (int i = 0; i < looptri_num; i++) {
+ const MLoopTri *lt = &looptri[i];
+ float *f_no = fnors[i];
+ const uint vtri[3] = {
+ mloop[lt->tri[0]].v,
+ mloop[lt->tri[1]].v,
+ mloop[lt->tri[2]].v,
+ };
+
+ normal_tri_v3(f_no, mverts[vtri[0]].co, mverts[vtri[1]].co, mverts[vtri[2]].co);
+
+ accumulate_vertex_normals_tri_v3(tnorms[vtri[0]],
+ tnorms[vtri[1]],
+ tnorms[vtri[2]],
+ f_no,
+ mverts[vtri[0]].co,
+ mverts[vtri[1]].co,
+ mverts[vtri[2]].co);
+ }
+
+ /* following Mesh convention; we use vertex coordinate itself for normal in this case */
+ for (int i = 0; i < numVerts; i++) {
+ MVert *mv = &mverts[i];
+ float *no = tnorms[i];
+
+ if (UNLIKELY(normalize_v3(no) == 0.0f)) {
+ normalize_v3_v3(no, mv->co);
+ }
+
+ normal_float_to_short_v3(mv->no, no);
+ }
+
+cleanup:
+ MEM_freeN(tnorms);
+
+ if (fnors != r_tri_nors) {
+ MEM_freeN(fnors);
+ }
+}
+
+void BKE_lnor_spacearr_init(MLoopNorSpaceArray *lnors_spacearr,
+ const int numLoops,
+ const char data_type)
+{
+ if (!(lnors_spacearr->lspacearr && lnors_spacearr->loops_pool)) {
+ MemArena *mem;
+
+ if (!lnors_spacearr->mem) {
+ lnors_spacearr->mem = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
+ }
+ mem = lnors_spacearr->mem;
+ lnors_spacearr->lspacearr = BLI_memarena_calloc(mem,
+ sizeof(MLoopNorSpace *) * (size_t)numLoops);
+ lnors_spacearr->loops_pool = BLI_memarena_alloc(mem, sizeof(LinkNode) * (size_t)numLoops);
+
+ lnors_spacearr->num_spaces = 0;
+ }
+ BLI_assert(ELEM(data_type, MLNOR_SPACEARR_BMLOOP_PTR, MLNOR_SPACEARR_LOOP_INDEX));
+ lnors_spacearr->data_type = data_type;
+}
+
+void BKE_lnor_spacearr_clear(MLoopNorSpaceArray *lnors_spacearr)
+{
+ lnors_spacearr->num_spaces = 0;
+ lnors_spacearr->lspacearr = NULL;
+ lnors_spacearr->loops_pool = NULL;
+ if (lnors_spacearr->mem != NULL) {
+ BLI_memarena_clear(lnors_spacearr->mem);
+ }
+}
+
+void BKE_lnor_spacearr_free(MLoopNorSpaceArray *lnors_spacearr)
+{
+ lnors_spacearr->num_spaces = 0;
+ lnors_spacearr->lspacearr = NULL;
+ lnors_spacearr->loops_pool = NULL;
+ BLI_memarena_free(lnors_spacearr->mem);
+ lnors_spacearr->mem = NULL;
+}
+
+MLoopNorSpace *BKE_lnor_space_create(MLoopNorSpaceArray *lnors_spacearr)
+{
+ lnors_spacearr->num_spaces++;
+ return BLI_memarena_calloc(lnors_spacearr->mem, sizeof(MLoopNorSpace));
+}
+
+/* This threshold is a bit touchy (usual float precision issue), this value seems OK. */
+#define LNOR_SPACE_TRIGO_THRESHOLD (1.0f - 1e-4f)
+
+/* 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').
+ */
+void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
+ const float lnor[3],
+ float vec_ref[3],
+ float vec_other[3],
+ BLI_Stack *edge_vectors)
+{
+ const float pi2 = (float)M_PI * 2.0f;
+ float tvec[3], dtp;
+ const float dtp_ref = dot_v3v3(vec_ref, lnor);
+ const float dtp_other = dot_v3v3(vec_other, lnor);
+
+ if (UNLIKELY(fabsf(dtp_ref) >= LNOR_SPACE_TRIGO_THRESHOLD ||
+ fabsf(dtp_other) >= LNOR_SPACE_TRIGO_THRESHOLD)) {
+ /* If vec_ref or vec_other are too much aligned with lnor, we can't build lnor space,
+ * tag it as invalid and abort. */
+ lnor_space->ref_alpha = lnor_space->ref_beta = 0.0f;
+
+ if (edge_vectors) {
+ BLI_stack_clear(edge_vectors);
+ }
+ return;
+ }
+
+ copy_v3_v3(lnor_space->vec_lnor, lnor);
+
+ /* Compute ref alpha, average angle of all available edge vectors to lnor. */
+ if (edge_vectors) {
+ float alpha = 0.0f;
+ int nbr = 0;
+ while (!BLI_stack_is_empty(edge_vectors)) {
+ const float *vec = BLI_stack_peek(edge_vectors);
+ alpha += saacosf(dot_v3v3(vec, lnor));
+ 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.).
+ */
+ BLI_assert(nbr >= 2); /* This piece of code shall only be called for more than one loop... */
+ lnor_space->ref_alpha = alpha / (float)nbr;
+ }
+ else {
+ lnor_space->ref_alpha = (saacosf(dot_v3v3(vec_ref, lnor)) +
+ saacosf(dot_v3v3(vec_other, lnor))) /
+ 2.0f;
+ }
+
+ /* Project vec_ref on lnor's ortho plane. */
+ mul_v3_v3fl(tvec, lnor, dtp_ref);
+ sub_v3_v3(vec_ref, tvec);
+ normalize_v3_v3(lnor_space->vec_ref, vec_ref);
+
+ cross_v3_v3v3(tvec, lnor, lnor_space->vec_ref);
+ normalize_v3_v3(lnor_space->vec_ortho, tvec);
+
+ /* Project vec_other on lnor's ortho plane. */
+ mul_v3_v3fl(tvec, lnor, dtp_other);
+ sub_v3_v3(vec_other, tvec);
+ normalize_v3(vec_other);
+
+ /* Beta is angle between ref_vec and other_vec, around lnor. */
+ dtp = dot_v3v3(lnor_space->vec_ref, vec_other);
+ if (LIKELY(dtp < LNOR_SPACE_TRIGO_THRESHOLD)) {
+ const float beta = saacos(dtp);
+ lnor_space->ref_beta = (dot_v3v3(lnor_space->vec_ortho, vec_other) < 0.0f) ? pi2 - beta : beta;
+ }
+ else {
+ lnor_space->ref_beta = pi2;
+ }
+}
+
+/**
+ * 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.
+ */
+void BKE_lnor_space_add_loop(MLoopNorSpaceArray *lnors_spacearr,
+ MLoopNorSpace *lnor_space,
+ const int ml_index,
+ void *bm_loop,
+ const bool is_single)
+{
+ BLI_assert((lnors_spacearr->data_type == MLNOR_SPACEARR_LOOP_INDEX && bm_loop == NULL) ||
+ (lnors_spacearr->data_type == MLNOR_SPACEARR_BMLOOP_PTR && bm_loop != NULL));
+
+ lnors_spacearr->lspacearr[ml_index] = lnor_space;
+ if (bm_loop == NULL) {
+ bm_loop = POINTER_FROM_INT(ml_index);
+ }
+ if (is_single) {
+ BLI_assert(lnor_space->loops == NULL);
+ lnor_space->flags |= MLNOR_SPACE_IS_SINGLE;
+ lnor_space->loops = bm_loop;
+ }
+ else {
+ BLI_assert((lnor_space->flags & MLNOR_SPACE_IS_SINGLE) == 0);
+ BLI_linklist_prepend_nlink(&lnor_space->loops, bm_loop, &lnors_spacearr->loops_pool[ml_index]);
+ }
+}
+
+MINLINE float unit_short_to_float(const short val)
+{
+ return (float)val / (float)SHRT_MAX;
+}
+
+MINLINE short unit_float_to_short(const float val)
+{
+ /* Rounding... */
+ return (short)floorf(val * (float)SHRT_MAX + 0.5f);
+}
+
+void BKE_lnor_space_custom_data_to_normal(MLoopNorSpace *lnor_space,
+ const short clnor_data[2],
+ float r_custom_lnor[3])
+{
+ /* NOP custom normal data or invalid lnor space, return. */
+ if (clnor_data[0] == 0 || lnor_space->ref_alpha == 0.0f || lnor_space->ref_beta == 0.0f) {
+ copy_v3_v3(r_custom_lnor, lnor_space->vec_lnor);
+ return;
+ }
+
+ {
+ /* TODO: Check whether using #sincosf() gives any noticeable benefit
+ * (could not even get it working under linux though)! */
+ const float pi2 = (float)(M_PI * 2.0);
+ const float alphafac = unit_short_to_float(clnor_data[0]);
+ const float alpha = (alphafac > 0.0f ? lnor_space->ref_alpha : pi2 - lnor_space->ref_alpha) *
+ alphafac;
+ const float betafac = unit_short_to_float(clnor_data[1]);
+
+ mul_v3_v3fl(r_custom_lnor, lnor_space->vec_lnor, cosf(alpha));
+
+ if (betafac == 0.0f) {
+ madd_v3_v3fl(r_custom_lnor, lnor_space->vec_ref, sinf(alpha));
+ }
+ else {
+ const float sinalpha = sinf(alpha);
+ const float beta = (betafac > 0.0f ? lnor_space->ref_beta : pi2 - lnor_space->ref_beta) *
+ betafac;
+ madd_v3_v3fl(r_custom_lnor, lnor_space->vec_ref, sinalpha * cosf(beta));
+ madd_v3_v3fl(r_custom_lnor, lnor_space->vec_ortho, sinalpha * sinf(beta));
+ }
+ }
+}
+
+void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space,
+ const float custom_lnor[3],
+ short r_clnor_data[2])
+{
+ /* We use null vector as NOP custom normal (can be simpler than giving auto-computed `lnor`). */
+ if (is_zero_v3(custom_lnor) || compare_v3v3(lnor_space->vec_lnor, custom_lnor, 1e-4f)) {
+ r_clnor_data[0] = r_clnor_data[1] = 0;
+ return;
+ }
+
+ {
+ const float pi2 = (float)(M_PI * 2.0);
+ const float cos_alpha = dot_v3v3(lnor_space->vec_lnor, custom_lnor);
+ float vec[3], cos_beta;
+ float alpha;
+
+ 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. */
+ r_clnor_data[0] = unit_float_to_short(-(pi2 - alpha) / (pi2 - lnor_space->ref_alpha));
+ }
+ else {
+ r_clnor_data[0] = unit_float_to_short(alpha / lnor_space->ref_alpha);
+ }
+
+ /* Project custom lnor on (vec_ref, vec_ortho) plane. */
+ mul_v3_v3fl(vec, lnor_space->vec_lnor, -cos_alpha);
+ add_v3_v3(vec, custom_lnor);
+ normalize_v3(vec);
+
+ cos_beta = dot_v3v3(lnor_space->vec_ref, vec);
+
+ if (cos_beta < LNOR_SPACE_TRIGO_THRESHOLD) {
+ float beta = saacosf(cos_beta);
+ if (dot_v3v3(lnor_space->vec_ortho, vec) < 0.0f) {
+ beta = pi2 - beta;
+ }
+
+ if (beta > lnor_space->ref_beta) {
+ r_clnor_data[1] = unit_float_to_short(-(pi2 - beta) / (pi2 - lnor_space->ref_beta));
+ }
+ else {
+ r_clnor_data[1] = unit_float_to_short(beta / lnor_space->ref_beta);
+ }
+ }
+ else {
+ r_clnor_data[1] = 0;
+ }
+ }
+}
+
+#define LOOP_SPLIT_TASK_BLOCK_SIZE 1024
+
+typedef struct LoopSplitTaskData {
+ /* Specific to each instance (each task). */
+
+ /** We have to create those outside of tasks, since #MemArena is not thread-safe. */
+ MLoopNorSpace *lnor_space;
+ float (*lnor)[3];
+ const MLoop *ml_curr;
+ const MLoop *ml_prev;
+ int ml_curr_index;
+ int ml_prev_index;
+ /** 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! */
+ BLI_Stack *edge_vectors;
+
+ char pad_c;
+} 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. */
+ MLoopNorSpaceArray *lnors_spacearr;
+ float (*loopnors)[3];
+ short (*clnors_data)[2];
+
+ /* Read-only. */
+ const MVert *mverts;
+ const MEdge *medges;
+ const MLoop *mloops;
+ const MPoly *mpolys;
+ int (*edge_to_loops)[2];
+ int *loop_to_poly;
+ const float (*polynors)[3];
+
+ int numEdges;
+ int numLoops;
+ int numPolys;
+} LoopSplitTaskDataCommon;
+
+#define INDEX_UNSET INT_MIN
+#define INDEX_INVALID -1
+/* See comment about edge_to_loops below. */
+#define IS_EDGE_SHARP(_e2l) (ELEM((_e2l)[1], INDEX_UNSET, INDEX_INVALID))
+
+static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data,
+ const bool check_angle,
+ const float split_angle,
+ const bool do_sharp_edges_tag)
+{
+ const MVert *mverts = data->mverts;
+ const MEdge *medges = data->medges;
+ const MLoop *mloops = data->mloops;
+
+ const MPoly *mpolys = data->mpolys;
+
+ const int numEdges = data->numEdges;
+ const int numPolys = data->numPolys;
+
+ float(*loopnors)[3] = data->loopnors; /* Note: loopnors may be NULL here. */
+ const float(*polynors)[3] = data->polynors;
+
+ int(*edge_to_loops)[2] = data->edge_to_loops;
+ int *loop_to_poly = data->loop_to_poly;
+
+ BLI_bitmap *sharp_edges = do_sharp_edges_tag ? BLI_BITMAP_NEW(numEdges, __func__) : NULL;
+
+ const MPoly *mp;
+ int mp_index;
+
+ const float split_angle_cos = check_angle ? cosf(split_angle) : -1.0f;
+
+ for (mp = mpolys, mp_index = 0; mp_index < numPolys; mp++, mp_index++) {
+ const MLoop *ml_curr;
+ int *e2l;
+ int ml_curr_index = mp->loopstart;
+ const int ml_last_index = (ml_curr_index + mp->totloop) - 1;
+
+ ml_curr = &mloops[ml_curr_index];
+
+ for (; ml_curr_index <= ml_last_index; ml_curr++, ml_curr_index++) {
+ e2l = edge_to_loops[ml_curr->e];
+
+ 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!
+ */
+ if (loopnors) {
+ normal_short_to_float_v3(loopnors[ml_curr_index], mverts[ml_curr->v].no);
+ }
+
+ /* Check whether current edge might be smooth or sharp */
+ if ((e2l[0] | e2l[1]) == 0) {
+ /* 'Empty' edge until now, set e2l[0] (and e2l[1] to INDEX_UNSET to tag it as unset). */
+ e2l[0] = ml_curr_index;
+ /* We have to check this here too, else we might miss some flat faces!!! */
+ e2l[1] = (mp->flag & ME_SMOOTH) ? INDEX_UNSET : INDEX_INVALID;
+ }
+ else if (e2l[1] == INDEX_UNSET) {
+ const bool is_angle_sharp = (check_angle &&
+ dot_v3v3(polynors[loop_to_poly[e2l[0]]], polynors[mp_index]) <
+ split_angle_cos);
+
+ /* 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.
+ */
+ if (!(mp->flag & ME_SMOOTH) || (medges[ml_curr->e].flag & ME_SHARP) ||
+ ml_curr->v == mloops[e2l[0]].v || is_angle_sharp) {
+ /* Note: we are sure that loop != 0 here ;) */
+ e2l[1] = INDEX_INVALID;
+
+ /* We want to avoid tagging edges as sharp when it is already defined as such by
+ * other causes than angle threshold... */
+ if (do_sharp_edges_tag && is_angle_sharp) {
+ BLI_BITMAP_SET(sharp_edges, ml_curr->e, true);
+ }
+ }
+ else {
+ e2l[1] = ml_curr_index;
+ }
+ }
+ else if (!IS_EDGE_SHARP(e2l)) {
+ /* More than two loops using this edge, tag as sharp if not yet done. */
+ e2l[1] = INDEX_INVALID;
+
+ /* We want to avoid tagging edges as sharp when it is already defined as such by
+ * other causes than angle threshold... */
+ if (do_sharp_edges_tag) {
+ BLI_BITMAP_SET(sharp_edges, ml_curr->e, false);
+ }
+ }
+ /* Else, edge is already 'disqualified' (i.e. sharp)! */
+ }
+ }
+
+ /* If requested, do actual tagging of edges as sharp in another loop. */
+ if (do_sharp_edges_tag) {
+ MEdge *me;
+ int me_index;
+ for (me = (MEdge *)medges, me_index = 0; me_index < numEdges; me++, me_index++) {
+ if (BLI_BITMAP_TEST(sharp_edges, me_index)) {
+ me->flag |= ME_SHARP;
+ }
+ }
+
+ MEM_freeN(sharp_edges);
+ }
+}
+
+/**
+ * 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 auto-smooth!
+ */
+void BKE_edges_sharp_from_angle_set(const struct MVert *mverts,
+ const int UNUSED(numVerts),
+ struct MEdge *medges,
+ const int numEdges,
+ struct MLoop *mloops,
+ const int numLoops,
+ struct MPoly *mpolys,
+ const float (*polynors)[3],
+ const int numPolys,
+ const float split_angle)
+{
+ if (split_angle >= (float)M_PI) {
+ /* Nothing to do! */
+ return;
+ }
+
+ /* Mapping edge -> loops. See BKE_mesh_normals_loop_split() for details. */
+ 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. */
+ int *loop_to_poly = MEM_malloc_arrayN((size_t)numLoops, sizeof(*loop_to_poly), __func__);
+
+ LoopSplitTaskDataCommon common_data = {
+ .mverts = mverts,
+ .medges = medges,
+ .mloops = mloops,
+ .mpolys = mpolys,
+ .edge_to_loops = edge_to_loops,
+ .loop_to_poly = loop_to_poly,
+ .polynors = polynors,
+ .numEdges = numEdges,
+ .numPolys = numPolys,
+ };
+
+ mesh_edges_sharp_tag(&common_data, true, split_angle, true);
+
+ MEM_freeN(edge_to_loops);
+ MEM_freeN(loop_to_poly);
+}
+
+void BKE_mesh_loop_manifold_fan_around_vert_next(const MLoop *mloops,
+ const MPoly *mpolys,
+ const int *loop_to_poly,
+ const int *e2lfan_curr,
+ const uint mv_pivot_index,
+ const MLoop **r_mlfan_curr,
+ int *r_mlfan_curr_index,
+ int *r_mlfan_vert_index,
+ int *r_mpfan_curr_index)
+{
+ const MLoop *mlfan_next;
+ const MPoly *mpfan_next;
+
+ /* Warning! This is rather complex!
+ * We have to find our next edge around the vertex (fan mode).
+ * First we find the next loop, which is either previous or next to mlfan_curr_index, depending
+ * whether both loops using current edge are in the same direction or not, and whether
+ * mlfan_curr_index actually uses the vertex we are fanning around!
+ * mlfan_curr_index is the index of mlfan_next here, and mlfan_next is not the real next one
+ * (i.e. not the future mlfan_curr)...
+ */
+ *r_mlfan_curr_index = (e2lfan_curr[0] == *r_mlfan_curr_index) ? e2lfan_curr[1] : e2lfan_curr[0];
+ *r_mpfan_curr_index = loop_to_poly[*r_mlfan_curr_index];
+
+ BLI_assert(*r_mlfan_curr_index >= 0);
+ BLI_assert(*r_mpfan_curr_index >= 0);
+
+ mlfan_next = &mloops[*r_mlfan_curr_index];
+ mpfan_next = &mpolys[*r_mpfan_curr_index];
+ if (((*r_mlfan_curr)->v == mlfan_next->v && (*r_mlfan_curr)->v == mv_pivot_index) ||
+ ((*r_mlfan_curr)->v != mlfan_next->v && (*r_mlfan_curr)->v != mv_pivot_index)) {
+ /* We need the previous loop, but current one is our vertex's loop. */
+ *r_mlfan_vert_index = *r_mlfan_curr_index;
+ if (--(*r_mlfan_curr_index) < mpfan_next->loopstart) {
+ *r_mlfan_curr_index = mpfan_next->loopstart + mpfan_next->totloop - 1;
+ }
+ }
+ else {
+ /* We need the next loop, which is also our vertex's loop. */
+ if (++(*r_mlfan_curr_index) >= mpfan_next->loopstart + mpfan_next->totloop) {
+ *r_mlfan_curr_index = mpfan_next->loopstart;
+ }
+ *r_mlfan_vert_index = *r_mlfan_curr_index;
+ }
+ *r_mlfan_curr = &mloops[*r_mlfan_curr_index];
+ /* And now we are back in sync, mlfan_curr_index is the index of mlfan_curr! Pff! */
+}
+
+static void split_loop_nor_single_do(LoopSplitTaskDataCommon *common_data, LoopSplitTaskData *data)
+{
+ MLoopNorSpaceArray *lnors_spacearr = common_data->lnors_spacearr;
+ const short(*clnors_data)[2] = common_data->clnors_data;
+
+ const MVert *mverts = common_data->mverts;
+ const MEdge *medges = common_data->medges;
+ const float(*polynors)[3] = common_data->polynors;
+
+ MLoopNorSpace *lnor_space = data->lnor_space;
+ float(*lnor)[3] = data->lnor;
+ const MLoop *ml_curr = data->ml_curr;
+ const MLoop *ml_prev = data->ml_prev;
+ const int ml_curr_index = data->ml_curr_index;
+#if 0 /* Not needed for 'single' loop. */
+ const int ml_prev_index = data->ml_prev_index;
+ const int *e2l_prev = data->e2l_prev;
+#endif
+ const int mp_index = data->mp_index;
+
+ /* Simple case (both edges around that vertex are sharp in current polygon),
+ * this loop just takes its poly normal.
+ */
+ copy_v3_v3(*lnor, polynors[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) {
+ float vec_curr[3], vec_prev[3];
+
+ const uint mv_pivot_index = ml_curr->v; /* The vertex we are "fanning" around! */
+ const MVert *mv_pivot = &mverts[mv_pivot_index];
+ const MEdge *me_curr = &medges[ml_curr->e];
+ const MVert *mv_2 = (me_curr->v1 == mv_pivot_index) ? &mverts[me_curr->v2] :
+ &mverts[me_curr->v1];
+ const MEdge *me_prev = &medges[ml_prev->e];
+ const MVert *mv_3 = (me_prev->v1 == mv_pivot_index) ? &mverts[me_prev->v2] :
+ &mverts[me_prev->v1];
+
+ sub_v3_v3v3(vec_curr, mv_2->co, mv_pivot->co);
+ normalize_v3(vec_curr);
+ sub_v3_v3v3(vec_prev, mv_3->co, mv_pivot->co);
+ 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... */
+ BKE_lnor_space_add_loop(lnors_spacearr, lnor_space, ml_curr_index, NULL, true);
+
+ if (clnors_data) {
+ BKE_lnor_space_custom_data_to_normal(lnor_space, clnors_data[ml_curr_index], *lnor);
+ }
+ }
+}
+
+static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSplitTaskData *data)
+{
+ MLoopNorSpaceArray *lnors_spacearr = common_data->lnors_spacearr;
+ float(*loopnors)[3] = common_data->loopnors;
+ short(*clnors_data)[2] = common_data->clnors_data;
+
+ const MVert *mverts = common_data->mverts;
+ const MEdge *medges = common_data->medges;
+ const MLoop *mloops = common_data->mloops;
+ const MPoly *mpolys = common_data->mpolys;
+ const int(*edge_to_loops)[2] = common_data->edge_to_loops;
+ const int *loop_to_poly = common_data->loop_to_poly;
+ const float(*polynors)[3] = common_data->polynors;
+
+ MLoopNorSpace *lnor_space = data->lnor_space;
+#if 0 /* Not needed for 'fan' loops. */
+ float(*lnor)[3] = data->lnor;
+#endif
+ const MLoop *ml_curr = data->ml_curr;
+ const MLoop *ml_prev = data->ml_prev;
+ const int ml_curr_index = data->ml_curr_index;
+ const int ml_prev_index = data->ml_prev_index;
+ const int mp_index = data->mp_index;
+ const int *e2l_prev = data->e2l_prev;
+
+ BLI_Stack *edge_vectors = data->edge_vectors;
+
+ /* 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).
+ */
+ const uint mv_pivot_index = ml_curr->v; /* The vertex we are "fanning" around! */
+ const MVert *mv_pivot = &mverts[mv_pivot_index];
+
+ /* ml_curr would be mlfan_prev if we needed that one. */
+ const MEdge *me_org = &medges[ml_curr->e];
+
+ const int *e2lfan_curr;
+ float vec_curr[3], vec_prev[3], vec_org[3];
+ const MLoop *mlfan_curr;
+ float lnor[3] = {0.0f, 0.0f, 0.0f};
+ /* mlfan_vert_index: the loop of our current edge might not be the loop of our current vertex! */
+ int mlfan_curr_index, mlfan_vert_index, mpfan_curr_index;
+
+ /* We validate clnors data on the fly - cheapest way to do! */
+ int clnors_avg[2] = {0, 0};
+ short(*clnor_ref)[2] = NULL;
+ int clnors_nbr = 0;
+ bool clnors_invalid = false;
+
+ /* Temp loop normal stack. */
+ BLI_SMALLSTACK_DECLARE(normal, float *);
+ /* Temp clnors stack. */
+ BLI_SMALLSTACK_DECLARE(clnors, short *);
+
+ e2lfan_curr = e2l_prev;
+ mlfan_curr = ml_prev;
+ mlfan_curr_index = ml_prev_index;
+ mlfan_vert_index = ml_curr_index;
+ mpfan_curr_index = mp_index;
+
+ BLI_assert(mlfan_curr_index >= 0);
+ BLI_assert(mlfan_vert_index >= 0);
+ BLI_assert(mpfan_curr_index >= 0);
+
+ /* Only need to compute previous edge's vector once, then we can just reuse old current one! */
+ {
+ const MVert *mv_2 = (me_org->v1 == mv_pivot_index) ? &mverts[me_org->v2] : &mverts[me_org->v1];
+
+ sub_v3_v3v3(vec_org, mv_2->co, mv_pivot->co);
+ normalize_v3(vec_org);
+ copy_v3_v3(vec_prev, vec_org);
+
+ if (lnors_spacearr) {
+ BLI_stack_push(edge_vectors, vec_org);
+ }
+ }
+
+ // printf("FAN: vert %d, start edge %d\n", mv_pivot_index, ml_curr->e);
+
+ 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,
+ * given the fact that this code should not be called that much in real-life meshes...
+ */
+ {
+ const MVert *mv_2 = (me_curr->v1 == mv_pivot_index) ? &mverts[me_curr->v2] :
+ &mverts[me_curr->v1];
+
+ sub_v3_v3v3(vec_curr, mv_2->co, mv_pivot->co);
+ normalize_v3(vec_curr);
+ }
+
+ // printf("\thandling edge %d / loop %d\n", mlfan_curr->e, mlfan_curr_index);
+
+ {
+ /* Code similar to accumulate_vertex_normals_poly_v3. */
+ /* Calculate angle between the two poly edges incident on this vertex. */
+ const float fac = saacos(dot_v3v3(vec_curr, vec_prev));
+ /* Accumulate */
+ madd_v3_v3fl(lnor, polynors[mpfan_curr_index], fac);
+
+ if (clnors_data) {
+ /* Accumulate all clnors, if they are not all equal we have to fix that! */
+ short(*clnor)[2] = &clnors_data[mlfan_vert_index];
+ if (clnors_nbr) {
+ clnors_invalid |= ((*clnor_ref)[0] != (*clnor)[0] || (*clnor_ref)[1] != (*clnor)[1]);
+ }
+ else {
+ clnor_ref = clnor;
+ }
+ clnors_avg[0] += (*clnor)[0];
+ clnors_avg[1] += (*clnor)[1];
+ clnors_nbr++;
+ /* We store here a pointer to all custom lnors processed. */
+ BLI_SMALLSTACK_PUSH(clnors, (short *)*clnor);
+ }
+ }
+
+ /* We store here a pointer to all loop-normals processed. */
+ BLI_SMALLSTACK_PUSH(normal, (float *)(loopnors[mlfan_vert_index]));
+
+ if (lnors_spacearr) {
+ /* Assign current lnor space to current 'vertex' loop. */
+ BKE_lnor_space_add_loop(lnors_spacearr, lnor_space, mlfan_vert_index, NULL, false);
+ if (me_curr != me_org) {
+ /* We store here all edges-normalized vectors processed. */
+ BLI_stack_push(edge_vectors, vec_curr);
+ }
+ }
+
+ if (IS_EDGE_SHARP(e2lfan_curr) || (me_curr == me_org)) {
+ /* Current edge is sharp and we have finished with this fan of faces around this vert,
+ * or this vert is smooth, and we have completed a full turn around it.
+ */
+ // printf("FAN: Finished!\n");
+ break;
+ }
+
+ copy_v3_v3(vec_prev, vec_curr);
+
+ /* Find next loop of the smooth fan. */
+ BKE_mesh_loop_manifold_fan_around_vert_next(mloops,
+ mpolys,
+ loop_to_poly,
+ e2lfan_curr,
+ mv_pivot_index,
+ &mlfan_curr,
+ &mlfan_curr_index,
+ &mlfan_vert_index,
+ &mpfan_curr_index);
+
+ e2lfan_curr = edge_to_loops[mlfan_curr->e];
+ }
+
+ {
+ float lnor_len = normalize_v3(lnor);
+
+ /* If we are generating lnor spacearr, we can now define the one for this fan,
+ * and optionally compute final lnor from custom data too!
+ */
+ if (lnors_spacearr) {
+ if (UNLIKELY(lnor_len == 0.0f)) {
+ /* Use vertex normal as fallback! */
+ copy_v3_v3(lnor, loopnors[mlfan_vert_index]);
+ lnor_len = 1.0f;
+ }
+
+ BKE_lnor_space_define(lnor_space, lnor, vec_org, vec_curr, edge_vectors);
+
+ if (clnors_data) {
+ if (clnors_invalid) {
+ short *clnor;
+
+ clnors_avg[0] /= clnors_nbr;
+ clnors_avg[1] /= clnors_nbr;
+ /* Fix/update all clnors of this fan with computed average value. */
+ if (G.debug & G_DEBUG) {
+ printf("Invalid clnors in this fan!\n");
+ }
+ while ((clnor = BLI_SMALLSTACK_POP(clnors))) {
+ // print_v2("org clnor", clnor);
+ clnor[0] = (short)clnors_avg[0];
+ clnor[1] = (short)clnors_avg[1];
+ }
+ // print_v2("new clnors", clnors_avg);
+ }
+ /* Extra bonus: since small-stack is local to this function,
+ * no more need to empty it at all cost! */
+
+ BKE_lnor_space_custom_data_to_normal(lnor_space, *clnor_ref, lnor);
+ }
+ }
+
+ /* In case we get a zero normal here, just use vertex normal already set! */
+ if (LIKELY(lnor_len != 0.0f)) {
+ /* Copy back the final computed normal into all related loop-normals. */
+ float *nor;
+
+ while ((nor = BLI_SMALLSTACK_POP(normal))) {
+ copy_v3_v3(nor, lnor);
+ }
+ }
+ /* Extra bonus: since small-stack is local to this function,
+ * no more need to empty it at all cost! */
+ }
+}
+
+static void loop_split_worker_do(LoopSplitTaskDataCommon *common_data,
+ LoopSplitTaskData *data,
+ BLI_Stack *edge_vectors)
+{
+ BLI_assert(data->ml_curr);
+ if (data->e2l_prev) {
+ BLI_assert((edge_vectors == NULL) || BLI_stack_is_empty(edge_vectors));
+ data->edge_vectors = edge_vectors;
+ split_loop_nor_fan_do(common_data, data);
+ }
+ else {
+ /* No need for edge_vectors for 'single' case! */
+ split_loop_nor_single_do(common_data, data);
+ }
+}
+
+static void loop_split_worker(TaskPool *__restrict pool, void *taskdata)
+{
+ LoopSplitTaskDataCommon *common_data = BLI_task_pool_user_data(pool);
+ LoopSplitTaskData *data = taskdata;
+
+ /* Temp edge vectors stack, only used when computing lnor spacearr. */
+ BLI_Stack *edge_vectors = common_data->lnors_spacearr ?
+ BLI_stack_new(sizeof(float[3]), __func__) :
+ NULL;
+
+#ifdef DEBUG_TIME
+ TIMEIT_START_AVERAGED(loop_split_worker);
+#endif
+
+ for (int i = 0; i < LOOP_SPLIT_TASK_BLOCK_SIZE; i++, data++) {
+ /* A NULL ml_curr is used to tag ended data! */
+ if (data->ml_curr == NULL) {
+ break;
+ }
+
+ loop_split_worker_do(common_data, data, edge_vectors);
+ }
+
+ if (edge_vectors) {
+ BLI_stack_free(edge_vectors);
+ }
+
+#ifdef DEBUG_TIME
+ TIMEIT_END_AVERAGED(loop_split_worker);
+#endif
+}
+
+/**
+ * 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.
+ */
+static bool loop_split_generator_check_cyclic_smooth_fan(const MLoop *mloops,
+ const MPoly *mpolys,
+ const int (*edge_to_loops)[2],
+ const int *loop_to_poly,
+ const int *e2l_prev,
+ BLI_bitmap *skip_loops,
+ const MLoop *ml_curr,
+ const MLoop *ml_prev,
+ const int ml_curr_index,
+ const int ml_prev_index,
+ const int mp_curr_index)
+{
+ const uint mv_pivot_index = ml_curr->v; /* The vertex we are "fanning" around! */
+ const int *e2lfan_curr;
+ const MLoop *mlfan_curr;
+ /* mlfan_vert_index: the loop of our current edge might not be the loop of our current vertex! */
+ int mlfan_curr_index, mlfan_vert_index, mpfan_curr_index;
+
+ e2lfan_curr = e2l_prev;
+ if (IS_EDGE_SHARP(e2lfan_curr)) {
+ /* Sharp loop, so not a cyclic smooth fan... */
+ return false;
+ }
+
+ mlfan_curr = ml_prev;
+ mlfan_curr_index = ml_prev_index;
+ mlfan_vert_index = ml_curr_index;
+ mpfan_curr_index = mp_curr_index;
+
+ BLI_assert(mlfan_curr_index >= 0);
+ BLI_assert(mlfan_vert_index >= 0);
+ BLI_assert(mpfan_curr_index >= 0);
+
+ BLI_assert(!BLI_BITMAP_TEST(skip_loops, mlfan_vert_index));
+ BLI_BITMAP_ENABLE(skip_loops, mlfan_vert_index);
+
+ while (true) {
+ /* Find next loop of the smooth fan. */
+ BKE_mesh_loop_manifold_fan_around_vert_next(mloops,
+ mpolys,
+ loop_to_poly,
+ e2lfan_curr,
+ mv_pivot_index,
+ &mlfan_curr,
+ &mlfan_curr_index,
+ &mlfan_vert_index,
+ &mpfan_curr_index);
+
+ e2lfan_curr = edge_to_loops[mlfan_curr->e];
+
+ if (IS_EDGE_SHARP(e2lfan_curr)) {
+ /* Sharp loop/edge, so not a cyclic smooth fan... */
+ return false;
+ }
+ /* Smooth loop/edge... */
+ 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. */
+ return true;
+ }
+ /* ... already checked in some previous looping, we can abort. */
+ return false;
+ }
+
+ /* ... we can skip it in future, and keep checking the smooth fan. */
+ BLI_BITMAP_ENABLE(skip_loops, mlfan_vert_index);
+ }
+}
+
+static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common_data)
+{
+ MLoopNorSpaceArray *lnors_spacearr = common_data->lnors_spacearr;
+ float(*loopnors)[3] = common_data->loopnors;
+
+ const MLoop *mloops = common_data->mloops;
+ const MPoly *mpolys = common_data->mpolys;
+ const int *loop_to_poly = common_data->loop_to_poly;
+ const int(*edge_to_loops)[2] = common_data->edge_to_loops;
+ const int numLoops = common_data->numLoops;
+ const int numPolys = common_data->numPolys;
+
+ const MPoly *mp;
+ int mp_index;
+
+ const MLoop *ml_curr;
+ const MLoop *ml_prev;
+ int ml_curr_index;
+ int ml_prev_index;
+
+ BLI_bitmap *skip_loops = BLI_BITMAP_NEW(numLoops, __func__);
+
+ LoopSplitTaskData *data_buff = NULL;
+ int data_idx = 0;
+
+ /* Temp edge vectors stack, only used when computing lnor spacearr
+ * (and we are not multi-threading). */
+ BLI_Stack *edge_vectors = NULL;
+
+#ifdef DEBUG_TIME
+ TIMEIT_START_AVERAGED(loop_split_generator);
+#endif
+
+ if (!pool) {
+ if (lnors_spacearr) {
+ edge_vectors = BLI_stack_new(sizeof(float[3]), __func__);
+ }
+ }
+
+ /* 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];
+ const int ml_last_index = (mp->loopstart + mp->totloop) - 1;
+ ml_curr_index = mp->loopstart;
+ ml_prev_index = ml_last_index;
+
+ ml_curr = &mloops[ml_curr_index];
+ ml_prev = &mloops[ml_prev_index];
+ lnors = &loopnors[ml_curr_index];
+
+ for (; ml_curr_index <= ml_last_index; ml_curr++, ml_curr_index++, lnors++) {
+ const int *e2l_curr = edge_to_loops[ml_curr->e];
+ const int *e2l_prev = edge_to_loops[ml_prev->e];
+
+#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. */
+
+ /* 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. */
+ if (!IS_EDGE_SHARP(e2l_curr) && (BLI_BITMAP_TEST(skip_loops, ml_curr_index) ||
+ !loop_split_generator_check_cyclic_smooth_fan(mloops,
+ mpolys,
+ edge_to_loops,
+ loop_to_poly,
+ e2l_prev,
+ skip_loops,
+ ml_curr,
+ ml_prev,
+ ml_curr_index,
+ ml_prev_index,
+ mp_index))) {
+ // printf("SKIPPING!\n");
+ }
+ else {
+ LoopSplitTaskData *data, data_local;
+
+ // printf("PROCESSING!\n");
+
+ if (pool) {
+ if (data_idx == 0) {
+ data_buff = MEM_calloc_arrayN(
+ LOOP_SPLIT_TASK_BLOCK_SIZE, sizeof(*data_buff), __func__);
+ }
+ data = &data_buff[data_idx];
+ }
+ else {
+ data = &data_local;
+ memset(data, 0, sizeof(*data));
+ }
+
+ if (IS_EDGE_SHARP(e2l_curr) && IS_EDGE_SHARP(e2l_prev)) {
+ data->lnor = lnors;
+ data->ml_curr = ml_curr;
+ data->ml_prev = ml_prev;
+ data->ml_curr_index = ml_curr_index;
+#if 0 /* Not needed for 'single' loop. */
+ data->ml_prev_index = ml_prev_index;
+ data->e2l_prev = NULL; /* Tag as 'single' task. */
+#endif
+ data->mp_index = mp_index;
+ if (lnors_spacearr) {
+ data->lnor_space = BKE_lnor_space_create(lnors_spacearr);
+ }
+ }
+ /* 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),
+ * and not the alternative (smooth curr_edge, sharp prev_edge).
+ * All this due/thanks to link between normals and loop ordering (i.e. winding).
+ */
+ else {
+#if 0 /* Not needed for 'fan' loops. */
+ data->lnor = lnors;
+#endif
+ data->ml_curr = ml_curr;
+ data->ml_prev = ml_prev;
+ data->ml_curr_index = ml_curr_index;
+ data->ml_prev_index = ml_prev_index;
+ data->e2l_prev = e2l_prev; /* Also tag as 'fan' task. */
+ data->mp_index = mp_index;
+ if (lnors_spacearr) {
+ data->lnor_space = BKE_lnor_space_create(lnors_spacearr);
+ }
+ }
+
+ if (pool) {
+ data_idx++;
+ if (data_idx == LOOP_SPLIT_TASK_BLOCK_SIZE) {
+ BLI_task_pool_push(pool, loop_split_worker, data_buff, true, NULL);
+ data_idx = 0;
+ }
+ }
+ else {
+ loop_split_worker_do(common_data, data, edge_vectors);
+ }
+ }
+
+ ml_prev = ml_curr;
+ ml_prev_index = ml_curr_index;
+ }
+ }
+
+ /* 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, NULL);
+ }
+
+ if (edge_vectors) {
+ BLI_stack_free(edge_vectors);
+ }
+ MEM_freeN(skip_loops);
+
+#ifdef DEBUG_TIME
+ TIMEIT_END_AVERAGED(loop_split_generator);
+#endif
+}
+
+/**
+ * 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).
+ */
+void BKE_mesh_normals_loop_split(const MVert *mverts,
+ const int UNUSED(numVerts),
+ MEdge *medges,
+ const int numEdges,
+ MLoop *mloops,
+ float (*r_loopnors)[3],
+ const int numLoops,
+ MPoly *mpolys,
+ const float (*polynors)[3],
+ const int numPolys,
+ const bool use_split_normals,
+ const float split_angle,
+ MLoopNorSpaceArray *r_lnors_spacearr,
+ 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! */
+ 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.
+ */
+ int mp_index;
+
+ for (mp_index = 0; mp_index < numPolys; mp_index++) {
+ MPoly *mp = &mpolys[mp_index];
+ int ml_index = mp->loopstart;
+ const int ml_index_end = ml_index + mp->totloop;
+ const bool is_poly_flat = ((mp->flag & ME_SMOOTH) == 0);
+
+ for (; ml_index < ml_index_end; ml_index++) {
+ if (r_loop_to_poly) {
+ r_loop_to_poly[ml_index] = mp_index;
+ }
+ if (is_poly_flat) {
+ copy_v3_v3(r_loopnors[ml_index], polynors[mp_index]);
+ }
+ else {
+ normal_short_to_float_v3(r_loopnors[ml_index], mverts[mloops[ml_index].v].no);
+ }
+ }
+ }
+ 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 loose 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. */
+ int *loop_to_poly = r_loop_to_poly ?
+ r_loop_to_poly :
+ MEM_malloc_arrayN((size_t)numLoops, sizeof(*loop_to_poly), __func__);
+
+ /* When using custom loop normals, disable the angle feature! */
+ const bool check_angle = (split_angle < (float)M_PI) && (clnors_data == NULL);
+
+ MLoopNorSpaceArray _lnors_spacearr = {NULL};
+
+#ifdef DEBUG_TIME
+ TIMEIT_START_AVERAGED(BKE_mesh_normals_loop_split);
+#endif
+
+ if (!r_lnors_spacearr && clnors_data) {
+ /* We need to compute lnor spacearr if some custom lnor data are given to us! */
+ r_lnors_spacearr = &_lnors_spacearr;
+ }
+ if (r_lnors_spacearr) {
+ BKE_lnor_spacearr_init(r_lnors_spacearr, numLoops, MLNOR_SPACEARR_LOOP_INDEX);
+ }
+
+ /* Init data common to all tasks. */
+ LoopSplitTaskDataCommon common_data = {
+ .lnors_spacearr = r_lnors_spacearr,
+ .loopnors = r_loopnors,
+ .clnors_data = clnors_data,
+ .mverts = mverts,
+ .medges = medges,
+ .mloops = mloops,
+ .mpolys = mpolys,
+ .edge_to_loops = edge_to_loops,
+ .loop_to_poly = loop_to_poly,
+ .polynors = polynors,
+ .numEdges = numEdges,
+ .numLoops = numLoops,
+ .numPolys = numPolys,
+ };
+
+ /* This first loop check which edges are actually smooth, and compute edge vectors. */
+ mesh_edges_sharp_tag(&common_data, check_angle, split_angle, false);
+
+ if (numLoops < LOOP_SPLIT_TASK_BLOCK_SIZE * 8) {
+ /* Not enough loops to be worth the whole threading overhead... */
+ loop_split_generator(NULL, &common_data);
+ }
+ else {
+ TaskPool *task_pool = BLI_task_pool_create(&common_data, TASK_PRIORITY_HIGH);
+
+ loop_split_generator(task_pool, &common_data);
+
+ BLI_task_pool_work_and_wait(task_pool);
+
+ BLI_task_pool_free(task_pool);
+ }
+
+ MEM_freeN(edge_to_loops);
+ if (!r_loop_to_poly) {
+ MEM_freeN(loop_to_poly);
+ }
+
+ if (r_lnors_spacearr) {
+ if (r_lnors_spacearr == &_lnors_spacearr) {
+ BKE_lnor_spacearr_free(r_lnors_spacearr);
+ }
+ }
+
+#ifdef DEBUG_TIME
+ TIMEIT_END_AVERAGED(BKE_mesh_normals_loop_split);
+#endif
+}
+
+#undef INDEX_UNSET
+#undef INDEX_INVALID
+#undef IS_EDGE_SHARP
+
+/**
+ * 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.
+ * 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.
+ */
+static void mesh_normals_loop_custom_set(const MVert *mverts,
+ const int numVerts,
+ MEdge *medges,
+ const int numEdges,
+ MLoop *mloops,
+ float (*r_custom_loopnors)[3],
+ const int numLoops,
+ MPoly *mpolys,
+ const float (*polynors)[3],
+ const int numPolys,
+ 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.
+ * 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?).
+ * 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! */
+ const bool use_split_normals = true;
+ const float split_angle = (float)M_PI;
+
+ BLI_SMALLSTACK_DECLARE(clnors_data, short *);
+
+ /* Compute current lnor spacearr. */
+ BKE_mesh_normals_loop_split(mverts,
+ numVerts,
+ medges,
+ numEdges,
+ mloops,
+ lnors,
+ numLoops,
+ mpolys,
+ polynors,
+ numPolys,
+ use_split_normals,
+ split_angle,
+ &lnors_spacearr,
+ NULL,
+ loop_to_poly);
+
+ /* Set all given zero vectors to their default value. */
+ if (use_vertices) {
+ for (int i = 0; i < numVerts; i++) {
+ if (is_zero_v3(r_custom_loopnors[i])) {
+ normal_short_to_float_v3(r_custom_loopnors[i], mverts[i].no);
+ }
+ }
+ }
+ else {
+ for (int i = 0; i < numLoops; i++) {
+ if (is_zero_v3(r_custom_loopnors[i])) {
+ copy_v3_v3(r_custom_loopnors[i], lnors[i]);
+ }
+ }
+ }
+
+ 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.
+ */
+ if (!use_vertices) {
+ for (int i = 0; i < numLoops; i++) {
+ if (!lnors_spacearr.lspacearr[i]) {
+ /* This should not happen in theory, but in some rare case (probably ugly geometry)
+ * we can get some NULL loopspacearr at this point. :/
+ * Maybe we should set those loops' edges as sharp?
+ */
+ BLI_BITMAP_ENABLE(done_loops, i);
+ if (G.debug & G_DEBUG) {
+ printf("WARNING! Getting invalid NULL loop space for loop %d!\n", i);
+ }
+ continue;
+ }
+
+ 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!
+ */
+ if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
+ BLI_BITMAP_ENABLE(done_loops, i);
+ continue;
+ }
+
+ LinkNode *loops = lnors_spacearr.lspacearr[i]->loops;
+ MLoop *prev_ml = NULL;
+ const float *org_nor = NULL;
+
+ while (loops) {
+ const int lidx = POINTER_AS_INT(loops->link);
+ MLoop *ml = &mloops[lidx];
+ const int nidx = lidx;
+ float *nor = r_custom_loopnors[nidx];
+
+ if (!org_nor) {
+ org_nor = nor;
+ }
+ 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.
+ */
+ const MPoly *mp = &mpolys[loop_to_poly[lidx]];
+ const MLoop *mlp =
+ &mloops[(lidx == mp->loopstart) ? mp->loopstart + mp->totloop - 1 : lidx - 1];
+ medges[(prev_ml->e == mlp->e) ? prev_ml->e : ml->e].flag |= ME_SHARP;
+
+ org_nor = nor;
+ }
+
+ prev_ml = ml;
+ loops = loops->next;
+ BLI_BITMAP_ENABLE(done_loops, lidx);
+ }
+
+ /* 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;
+ if (loops && org_nor) {
+ const int lidx = POINTER_AS_INT(loops->link);
+ MLoop *ml = &mloops[lidx];
+ const int nidx = lidx;
+ float *nor = r_custom_loopnors[nidx];
+
+ if (dot_v3v3(org_nor, nor) < LNOR_SPACE_TRIGO_THRESHOLD) {
+ const MPoly *mp = &mpolys[loop_to_poly[lidx]];
+ const MLoop *mlp =
+ &mloops[(lidx == mp->loopstart) ? mp->loopstart + mp->totloop - 1 : lidx - 1];
+ medges[(prev_ml->e == mlp->e) ? prev_ml->e : ml->e].flag |= ME_SHARP;
+ }
+ }
+ }
+ }
+
+ /* And now, recompute our new auto lnors and lnor spacearr! */
+ BKE_lnor_spacearr_clear(&lnors_spacearr);
+ BKE_mesh_normals_loop_split(mverts,
+ numVerts,
+ medges,
+ numEdges,
+ mloops,
+ lnors,
+ numLoops,
+ mpolys,
+ polynors,
+ numPolys,
+ use_split_normals,
+ split_angle,
+ &lnors_spacearr,
+ NULL,
+ loop_to_poly);
+ }
+ else {
+ 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. */
+ for (int i = 0; i < numLoops; i++) {
+ if (!lnors_spacearr.lspacearr[i]) {
+ BLI_BITMAP_DISABLE(done_loops, i);
+ if (G.debug & G_DEBUG) {
+ printf("WARNING! Still getting invalid NULL loop space in second loop for loop %d!\n", i);
+ }
+ continue;
+ }
+
+ 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).
+ */
+ LinkNode *loops = lnors_spacearr.lspacearr[i]->loops;
+ if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
+ BLI_assert(POINTER_AS_INT(loops) == i);
+ const int nidx = use_vertices ? (int)mloops[i].v : i;
+ float *nor = r_custom_loopnors[nidx];
+
+ BKE_lnor_space_custom_normal_to_data(lnors_spacearr.lspacearr[i], nor, r_clnors_data[i]);
+ BLI_BITMAP_DISABLE(done_loops, i);
+ }
+ else {
+ int nbr_nors = 0;
+ float avg_nor[3];
+ short clnor_data_tmp[2], *clnor_data;
+
+ zero_v3(avg_nor);
+ while (loops) {
+ const int lidx = POINTER_AS_INT(loops->link);
+ const int nidx = use_vertices ? (int)mloops[lidx].v : lidx;
+ float *nor = r_custom_loopnors[nidx];
+
+ nbr_nors++;
+ add_v3_v3(avg_nor, nor);
+ BLI_SMALLSTACK_PUSH(clnors_data, (short *)r_clnors_data[lidx]);
+
+ loops = loops->next;
+ BLI_BITMAP_DISABLE(done_loops, lidx);
+ }
+
+ mul_v3_fl(avg_nor, 1.0f / (float)nbr_nors);
+ BKE_lnor_space_custom_normal_to_data(lnors_spacearr.lspacearr[i], avg_nor, clnor_data_tmp);
+
+ while ((clnor_data = BLI_SMALLSTACK_POP(clnors_data))) {
+ clnor_data[0] = clnor_data_tmp[0];
+ clnor_data[1] = clnor_data_tmp[1];
+ }
+ }
+ }
+ }
+
+ MEM_freeN(lnors);
+ MEM_freeN(loop_to_poly);
+ MEM_freeN(done_loops);
+ BKE_lnor_spacearr_free(&lnors_spacearr);
+}
+
+void BKE_mesh_normals_loop_custom_set(const MVert *mverts,
+ const int numVerts,
+ MEdge *medges,
+ const int numEdges,
+ MLoop *mloops,
+ float (*r_custom_loopnors)[3],
+ const int numLoops,
+ MPoly *mpolys,
+ const float (*polynors)[3],
+ const int numPolys,
+ short (*r_clnors_data)[2])
+{
+ mesh_normals_loop_custom_set(mverts,
+ numVerts,
+ medges,
+ numEdges,
+ mloops,
+ r_custom_loopnors,
+ numLoops,
+ mpolys,
+ polynors,
+ numPolys,
+ r_clnors_data,
+ false);
+}
+
+void BKE_mesh_normals_loop_custom_from_vertices_set(const MVert *mverts,
+ float (*r_custom_vertnors)[3],
+ const int numVerts,
+ MEdge *medges,
+ const int numEdges,
+ MLoop *mloops,
+ const int numLoops,
+ MPoly *mpolys,
+ const float (*polynors)[3],
+ const int numPolys,
+ short (*r_clnors_data)[2])
+{
+ mesh_normals_loop_custom_set(mverts,
+ numVerts,
+ medges,
+ numEdges,
+ mloops,
+ r_custom_vertnors,
+ numLoops,
+ mpolys,
+ polynors,
+ numPolys,
+ r_clnors_data,
+ true);
+}
+
+static void mesh_set_custom_normals(Mesh *mesh, float (*r_custom_nors)[3], const bool use_vertices)
+{
+ short(*clnors)[2];
+ const int numloops = mesh->totloop;
+
+ clnors = CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL);
+ if (clnors != NULL) {
+ memset(clnors, 0, sizeof(*clnors) * (size_t)numloops);
+ }
+ else {
+ clnors = CustomData_add_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numloops);
+ }
+
+ float(*polynors)[3] = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
+ bool free_polynors = false;
+ if (polynors == NULL) {
+ polynors = MEM_mallocN(sizeof(float[3]) * (size_t)mesh->totpoly, __func__);
+ BKE_mesh_calc_normals_poly(mesh->mvert,
+ NULL,
+ mesh->totvert,
+ mesh->mloop,
+ mesh->mpoly,
+ mesh->totloop,
+ mesh->totpoly,
+ polynors,
+ false);
+ free_polynors = true;
+ }
+
+ mesh_normals_loop_custom_set(mesh->mvert,
+ mesh->totvert,
+ mesh->medge,
+ mesh->totedge,
+ mesh->mloop,
+ r_custom_nors,
+ mesh->totloop,
+ mesh->mpoly,
+ polynors,
+ mesh->totpoly,
+ clnors,
+ use_vertices);
+
+ if (free_polynors) {
+ MEM_freeN(polynors);
+ }
+}
+
+/**
+ * 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.
+ */
+void BKE_mesh_set_custom_normals(Mesh *mesh, float (*r_custom_loopnors)[3])
+{
+ mesh_set_custom_normals(mesh, r_custom_loopnors, false);
+}
+
+/**
+ * Higher level functions hiding most of the code needed around call to
+ * #BKE_mesh_normals_loop_custom_from_vertices_set().
+ *
+ * \param r_custom_vertnors: is not const, since code will replace zero_v3 normals there
+ * with automatically computed vectors.
+ */
+void BKE_mesh_set_custom_normals_from_vertices(Mesh *mesh, float (*r_custom_vertnors)[3])
+{
+ mesh_set_custom_normals(mesh, r_custom_vertnors, true);
+}
+
+/**
+ * Computes average per-vertex normals from given custom loop normals.
+ *
+ * \param clnors: The computed custom loop normals.
+ * \param r_vert_clnors: The (already allocated) array where to store averaged per-vertex normals.
+ */
+void BKE_mesh_normals_loop_to_vertex(const int numVerts,
+ const MLoop *mloops,
+ const int numLoops,
+ const float (*clnors)[3],
+ float (*r_vert_clnors)[3])
+{
+ int *vert_loops_nbr = MEM_calloc_arrayN((size_t)numVerts, sizeof(*vert_loops_nbr), __func__);
+
+ copy_vn_fl((float *)r_vert_clnors, 3 * numVerts, 0.0f);
+
+ int i;
+ const MLoop *ml;
+ for (i = 0, ml = mloops; i < numLoops; i++, ml++) {
+ const uint v = ml->v;
+
+ add_v3_v3(r_vert_clnors[v], clnors[i]);
+ vert_loops_nbr[v]++;
+ }
+
+ for (i = 0; i < numVerts; i++) {
+ mul_v3_fl(r_vert_clnors[i], 1.0f / (float)vert_loops_nbr[i]);
+ }
+
+ MEM_freeN(vert_loops_nbr);
+}
+
+#undef LNOR_SPACE_TRIGO_THRESHOLD
+
+/** \} */
diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c
index 011dd7e25ee..47d300dc0c2 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.c
+++ b/source/blender/blenkernel/intern/mesh_runtime.c
@@ -158,8 +158,12 @@ static void mesh_runtime_looptri_recalc_isolated(void *userdata)
BKE_mesh_runtime_looptri_recalc(mesh);
}
-/* This is a ported copy of dm_getLoopTriArray(dm). */
-const MLoopTri *BKE_mesh_runtime_looptri_ensure(Mesh *mesh)
+/**
+ * \note This function only fills a cache, and therefore the mesh argument can
+ * be considered logically const. Concurrent access is protected by a mutex.
+ * \note This is a ported copy of dm_getLoopTriArray(dm).
+ */
+const MLoopTri *BKE_mesh_runtime_looptri_ensure(const Mesh *mesh)
{
ThreadMutex *mesh_eval_mutex = (ThreadMutex *)mesh->runtime.eval_mutex;
BLI_mutex_lock(mesh_eval_mutex);
@@ -171,7 +175,7 @@ const MLoopTri *BKE_mesh_runtime_looptri_ensure(Mesh *mesh)
}
else {
/* Must isolate multithreaded tasks while holding a mutex lock. */
- BLI_task_isolate(mesh_runtime_looptri_recalc_isolated, mesh);
+ BLI_task_isolate(mesh_runtime_looptri_recalc_isolated, (void *)mesh);
looptri = mesh->runtime.looptris.array;
}
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index df84cf6607f..bfdbf844a26 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -1105,7 +1105,7 @@ bool BKE_mesh_validate(Mesh *me, const bool do_verbose, const bool cddata_check_
&changed);
if (changed) {
- DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY_ALL_MODES);
return true;
}
@@ -1183,7 +1183,7 @@ bool BKE_mesh_validate_material_indices(Mesh *me)
}
if (!is_valid) {
- DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY_ALL_MODES);
return true;
}
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 0f2f56f4f2b..3a7910d1a9f 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -1320,7 +1320,7 @@ static ImBuf *movieclip_get_postprocessed_ibuf(
clip->lastframe = framenr;
real_ibuf_size(clip, user, ibuf, &clip->lastsize[0], &clip->lastsize[1]);
- /* postprocess frame and put to cache if needed*/
+ /* Post-process frame and put to cache if needed. */
if (need_postprocess) {
ImBuf *tmpibuf = ibuf;
ibuf = postprocess_frame(clip, user, tmpibuf, flag, postprocess_flag);
@@ -2128,9 +2128,9 @@ GPUTexture *BKE_movieclip_get_gpu_texture(MovieClip *clip, MovieClipUser *cuser)
void BKE_movieclip_free_gputexture(struct MovieClip *clip)
{
- /* number of gpu textures to keep around as cache
+ /* Number of gpu textures to keep around as cache.
* We don't want to keep too many GPU textures for
- * movie clips around, as they can be large.*/
+ * movie clips around, as they can be large. */
const int MOVIECLIP_NUM_GPUTEXTURES = 1;
while (BLI_listbase_count(&clip->runtime.gputextures) > MOVIECLIP_NUM_GPUTEXTURES) {
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 45ac20ef154..54f0da30a2b 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -994,7 +994,7 @@ static void multiresModifier_disp_run(
}
}
- /*numGrids = dm->getNumGrids(dm);*/ /*UNUSED*/
+ // numGrids = dm->getNumGrids(dm); /* UNUSED */
gridSize = dm->getGridSize(dm);
gridData = dm->getGridData(dm);
gridOffset = dm->getGridOffset(dm);
@@ -1285,7 +1285,7 @@ DerivedMesh *multires_make_derived_from_derived(
multires_set_tot_mdisps(me, mmd->totlvl);
multiresModifier_ensure_external_read(me, mmd);
- /*run displacement*/
+ /* Run displacement. */
multiresModifier_disp_run(result, ob->data, dm, APPLY_DISPLACEMENTS, subGridData, mmd->totlvl);
/* copy hidden elements for this level */
@@ -1514,7 +1514,7 @@ void multires_topology_changed(Mesh *me)
*
* Since the multires data files only contain displacement vectors without knowledge about
* subdivision level some extra work is needed. Namely make is to all displacement grids have
- * proper level and number of displacement vectors set. */
+ * proper level and number of displacement vectors set. */
void multires_ensure_external_read(struct Mesh *mesh, int top_level)
{
if (!CustomData_external_test(&mesh->ldata, CD_MDISPS)) {
diff --git a/source/blender/blenkernel/intern/multires_reshape.c b/source/blender/blenkernel/intern/multires_reshape.c
index 04ad78ec0de..bd52d70b223 100644
--- a/source/blender/blenkernel/intern/multires_reshape.c
+++ b/source/blender/blenkernel/intern/multires_reshape.c
@@ -235,7 +235,7 @@ void multiresModifier_subdivide_to_level(struct Object *object,
/* Free original grids which makes it so smoothing with details thinks all the details were
* added against base mesh's limit surface. This is similar behavior to as if we've done all
- * displacement in sculpt mode at the old top level and then propagated to the new top level.*/
+ * displacement in sculpt mode at the old top level and then propagated to the new top level. */
multires_reshape_free_original_grids(&reshape_context);
if (ELEM(mode, MULTIRES_SUBDIVIDE_LINEAR, MULTIRES_SUBDIVIDE_SIMPLE)) {
diff --git a/source/blender/blenkernel/intern/multires_reshape_smooth.c b/source/blender/blenkernel/intern/multires_reshape_smooth.c
index f10aae18142..aed8c3122a2 100644
--- a/source/blender/blenkernel/intern/multires_reshape_smooth.c
+++ b/source/blender/blenkernel/intern/multires_reshape_smooth.c
@@ -55,7 +55,7 @@
/* Surface refers to a simplified and lower-memory footprint representation of the limit surface.
*
* Used to store pre-calculated information which is expensive or impossible to evaluate when
- * traversing the final limit surface. */
+ * traversing the final limit surface. */
typedef struct SurfacePoint {
float P[3];
@@ -1027,7 +1027,7 @@ static void converter_init(const MultiresReshapeSmoothContext *reshape_smooth_co
converter->user_data = (void *)reshape_smooth_context;
}
-/* Create subdiv descriptor created for topology at a reshape level, */
+/* Create subdiv descriptor created for topology at a reshape level. */
static void reshape_subdiv_create(MultiresReshapeSmoothContext *reshape_smooth_context)
{
const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context;
@@ -1050,7 +1050,7 @@ typedef void(ReshapeSubdivCoarsePositionCb)(
const Vertex *vertex,
float r_P[3]);
-/* Refine subdivision surface topology at a reshape level for new coarse vertices positions. */
+/* Refine subdivision surface topology at a reshape level for new coarse vertices positions. */
static void reshape_subdiv_refine(const MultiresReshapeSmoothContext *reshape_smooth_context,
ReshapeSubdivCoarsePositionCb coarse_position_cb)
{
diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.c b/source/blender/blenkernel/intern/multires_unsubdivide.c
index 02b9bb852d6..4210f26a694 100644
--- a/source/blender/blenkernel/intern/multires_unsubdivide.c
+++ b/source/blender/blenkernel/intern/multires_unsubdivide.c
@@ -312,7 +312,7 @@ static bool unsubdivide_tag_disconnected_mesh_element(BMesh *bm, int *elem_id, i
/* Also try from the different 4 vertices of a quad in the current
* disconnected element ID. If a solution exists the search should return a valid solution from
- * one of these vertices.*/
+ * one of these vertices. */
BMFace *f, *init_face = NULL;
BMVert *v;
BMIter iter_a, iter_b;
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 92e21183acb..bf18765aa94 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -1289,7 +1289,7 @@ void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip)
return;
}
- /* loop over tracks, deactivating*/
+ /* Loop over tracks, deactivating. */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (nls = nlt->strips.first; nls; nls = nls->next) {
if (nls != strip) {
@@ -1560,7 +1560,7 @@ bool BKE_nlatracks_have_animated_strips(ListBase *tracks)
return false;
}
-/* Validate the NLA-Strips 'control' F-Curves based on the flags set*/
+/* Validate the NLA-Strips 'control' F-Curves based on the flags set. */
void BKE_nlastrip_validate_fcurves(NlaStrip *strip)
{
FCurve *fcu;
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index db18cecb5d3..e6635665567 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -875,7 +875,7 @@ void ntreeBlendReadLib(struct BlendLibReader *reader, struct bNodeTree *ntree)
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
/* Link ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
+ * of library blocks that implement this. */
IDP_BlendReadLib(reader, node->prop);
BLO_read_id_address(reader, lib, &node->id);
@@ -2365,7 +2365,7 @@ static void nodeUnMuteLink(bNodeLink *link)
link->tosock->flag |= SOCK_IN_USE;
}
-/* Upstream muting. Always happens when unmuting but checks when muting. O(n^2) algorithm.*/
+/* Upstream muting. Always happens when unmuting but checks when muting. O(n^2) algorithm. */
static void nodeMuteRerouteInputLinks(bNodeTree *ntree, bNode *node, const bool mute)
{
if (node->type != NODE_REROUTE) {
@@ -2388,7 +2388,7 @@ static void nodeMuteRerouteInputLinks(bNodeTree *ntree, bNode *node, const bool
}
}
-/* Downstream muting propagates when reaching reroute nodes. O(n^2) algorithm.*/
+/* Downstream muting propagates when reaching reroute nodes. O(n^2) algorithm. */
static void nodeMuteRerouteOutputLinks(bNodeTree *ntree, bNode *node, const bool mute)
{
if (node->type != NODE_REROUTE) {
@@ -5054,6 +5054,11 @@ static void registerGeometryNodes()
register_node_type_geo_collection_info();
register_node_type_geo_convex_hull();
register_node_type_geo_curve_length();
+ register_node_type_geo_curve_primitive_bezier_segment();
+ register_node_type_geo_curve_primitive_circle();
+ register_node_type_geo_curve_primitive_quadratic_bezier();
+ register_node_type_geo_curve_primitive_spiral();
+ register_node_type_geo_curve_primitive_star();
register_node_type_geo_curve_to_mesh();
register_node_type_geo_curve_to_points();
register_node_type_geo_curve_resample();
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 8cfd75b015c..ff5d94d20b7 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2759,7 +2759,7 @@ Object *BKE_object_duplicate(Main *bmain,
}
if (!is_subprocess) {
- /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW.*/
+ /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW. */
BKE_libblock_relink_to_newid(&obn->id);
#ifndef NDEBUG
@@ -2854,7 +2854,7 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
else {
/* only on local objects because this causes indirect links
* 'a -> b -> c', blend to point directly to a.blend
- * when a.blend has a proxy that's linked into c.blend */
+ * when a.blend has a proxy that's linked into `c.blend`. */
if (!ID_IS_LINKED(ob)) {
id_lib_extern((ID *)dtar->id);
}
@@ -3212,12 +3212,11 @@ void BKE_object_to_mat3(Object *ob, float r_mat[3][3]) /* no parent */
{
float smat[3][3];
float rmat[3][3];
- /*float q1[4];*/
- /* scale */
+ /* Scale. */
BKE_object_scale_to_mat3(ob, smat);
- /* rot */
+ /* Rotation. */
BKE_object_rot_to_mat3(ob, rmat, true);
mul_m3_m3m3(r_mat, rmat, smat);
}
@@ -3861,7 +3860,7 @@ void BKE_object_boundbox_flag(Object *ob, int flag, const bool set)
}
}
-void BKE_object_boundbox_calc_from_mesh(struct Object *ob, struct Mesh *me_eval)
+void BKE_object_boundbox_calc_from_mesh(struct Object *ob, const struct Mesh *me_eval)
{
float min[3], max[3];
@@ -4170,7 +4169,7 @@ void BKE_object_foreach_display_point(Object *ob,
void *user_data)
{
/* TODO: pointcloud and hair objects support */
- Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
+ const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
float co[3];
if (mesh_eval != NULL) {
@@ -4476,7 +4475,7 @@ Mesh *BKE_object_get_pre_modified_mesh(const Object *object)
}
/**
- * Get a mesh which corresponds to very very original mesh from #Main.
+ * Get a mesh which corresponds to the very original mesh from #Main.
* - For original objects it will be object->data.
* - For evaluated objects it will be same mesh as corresponding original
* object uses as data.
@@ -5304,7 +5303,7 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot)
tot = 0;
tree = BLI_kdtree_3d_new(totvert);
- /* we don't how how many verts from the DM we can use */
+ /* We don't how many verts from the DM we can use. */
for (i = 0; i < totvert; i++) {
if (index[i] != ORIGINDEX_NONE) {
float co[3];
diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc
index 768fa9373c1..77969328365 100644
--- a/source/blender/blenkernel/intern/object_dupli.cc
+++ b/source/blender/blenkernel/intern/object_dupli.cc
@@ -335,14 +335,14 @@ static void make_child_duplis(const DupliContext *ctx,
/** \name Internal Data Access Utilities
* \{ */
-static Mesh *mesh_data_from_duplicator_object(Object *ob,
- BMEditMesh **r_em,
- const float (**r_vert_coords)[3],
- const float (**r_vert_normals)[3])
+static const Mesh *mesh_data_from_duplicator_object(Object *ob,
+ BMEditMesh **r_em,
+ const float (**r_vert_coords)[3],
+ const float (**r_vert_normals)[3])
{
/* Gather mesh info. */
BMEditMesh *em = BKE_editmesh_from_object(ob);
- Mesh *me_eval;
+ const Mesh *me_eval;
*r_em = nullptr;
*r_vert_coords = nullptr;
@@ -603,7 +603,7 @@ static void make_duplis_verts(const DupliContext *ctx)
BMEditMesh *em = nullptr;
const float(*vert_coords)[3] = nullptr;
const float(*vert_normals)[3] = nullptr;
- Mesh *me_eval = mesh_data_from_duplicator_object(
+ const Mesh *me_eval = mesh_data_from_duplicator_object(
parent, &em, &vert_coords, use_rotation ? &vert_normals : nullptr);
if (em == nullptr && me_eval == nullptr) {
return;
@@ -1151,7 +1151,7 @@ static void make_duplis_faces(const DupliContext *ctx)
/* Gather mesh info. */
BMEditMesh *em = nullptr;
const float(*vert_coords)[3] = nullptr;
- Mesh *me_eval = mesh_data_from_duplicator_object(parent, &em, &vert_coords, nullptr);
+ const Mesh *me_eval = mesh_data_from_duplicator_object(parent, &em, &vert_coords, nullptr);
if (em == nullptr && me_eval == nullptr) {
return;
}
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index b1afd968bdc..ab247ef5507 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -224,7 +224,7 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *o
case OB_SURF:
case OB_FONT: {
bool for_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
- BKE_displist_make_curveTypes(depsgraph, scene, ob, for_render, false);
+ BKE_displist_make_curveTypes(depsgraph, scene, ob, for_render);
break;
}
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 9d53dad8d03..2e7152302c7 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -248,7 +248,7 @@ void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u, float
if (oc->_do_normals) {
ocr->normal[0] = BILERP(oc->_N_x);
- ocr->normal[1] = oc->_N_y /*BILERP(oc->_N_y) (MEM01)*/;
+ ocr->normal[1] = oc->_N_y /* BILERP(oc->_N_y) (MEM01) */;
ocr->normal[2] = BILERP(oc->_N_z);
}
@@ -347,7 +347,7 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u
}
if (oc->_do_normals) {
ocr->normal[0] = INTERP(oc->_N_x);
- ocr->normal[1] = oc->_N_y /*INTERP(oc->_N_y) (MEM01)*/;
+ ocr->normal[1] = oc->_N_y /* INTERP(oc->_N_y) (MEM01) */;
ocr->normal[2] = INTERP(oc->_N_z);
}
if (oc->_do_chop) {
@@ -1052,7 +1052,7 @@ void BKE_ocean_free_data(struct Ocean *oc)
fftw_destroy_plan(oc->_N_x_plan);
fftw_destroy_plan(oc->_N_z_plan);
MEM_freeN(oc->_N_x);
- /*fftwf_free(oc->_N_y); (MEM01)*/
+ /* fftwf_free(oc->_N_y); (MEM01) */
MEM_freeN(oc->_N_z);
}
@@ -1437,9 +1437,9 @@ void BKE_ocean_bake(struct Ocean *o,
rgb_to_rgba_unit_alpha(&ibuf_disp->rect_float[4 * (res_x * y + x)], ocr.disp);
if (o->_do_jacobian) {
- /* TODO, cleanup unused code - campbell */
+ /* TODO: cleanup unused code - campbell */
- float /*r, */ /* UNUSED */ pr = 0.0f, foam_result;
+ float /* r, */ /* UNUSED */ pr = 0.0f, foam_result;
float neg_disp, neg_eplus;
ocr.foam = BKE_ocean_jminus_to_foam(ocr.Jminus, och->foam_coverage);
@@ -1449,9 +1449,9 @@ void BKE_ocean_bake(struct Ocean *o,
pr = prev_foam[res_x * y + x];
}
- /* r = BLI_rng_get_float(rng); */ /* UNUSED */ /* randomly reduce foam */
+ // r = BLI_rng_get_float(rng); /* UNUSED */ /* randomly reduce foam */
- /* pr = pr * och->foam_fade; */ /* overall fade */
+ // 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),
@@ -1475,7 +1475,7 @@ void BKE_ocean_bake(struct Ocean *o,
prev_foam[res_x * y + x] = foam_result;
- /*foam_result = min_ff(foam_result, 1.0f); */
+ // foam_result = min_ff(foam_result, 1.0f);
value_to_rgba_unit_alpha(&ibuf_foam->rect_float[4 * (res_x * y + x)], foam_result);
diff --git a/source/blender/blenkernel/intern/ocean_intern.h b/source/blender/blenkernel/intern/ocean_intern.h
index b55b211fa33..4ebd03789af 100644
--- a/source/blender/blenkernel/intern/ocean_intern.h
+++ b/source/blender/blenkernel/intern/ocean_intern.h
@@ -99,7 +99,7 @@ typedef struct Ocean {
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). */
- /*float * _N_y; */
+ // float * _N_y;
double _N_y; /* sim w ********* can be rearranged? */
double *_N_z; /* init w sim w via plan? */
double *_disp_x; /* init w sim w via plan? */
diff --git a/source/blender/blenkernel/intern/ocean_spectrum.c b/source/blender/blenkernel/intern/ocean_spectrum.c
index 1f7cc56f1a9..7ed70234baf 100644
--- a/source/blender/blenkernel/intern/ocean_spectrum.c
+++ b/source/blender/blenkernel/intern/ocean_spectrum.c
@@ -122,7 +122,7 @@ static float jonswap(const Ocean *oc, const float k2)
float val = alpha_beta_spectrum(m_alpha, beta, GRAVITY, omega, m_peakomega);
- /* Peak sharpening */
+ /* Peak sharpening. */
val *= peak_sharpen(m_omega, m_peakomega, m_gamma);
return val;
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 3494630e1fa..a7c6dc2deb9 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1810,7 +1810,7 @@ void BKE_sculpt_color_layer_create_if_needed(struct Object *object)
CustomData_add_layer(&orig_me->vdata, CD_PROP_COLOR, CD_DEFAULT, NULL, orig_me->totvert);
BKE_mesh_update_customdata_pointers(orig_me, true);
- DEG_id_tag_update(&orig_me->id, ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&orig_me->id, ID_RECALC_GEOMETRY_ALL_MODES);
}
/** \warning Expects a fully evaluated depsgraph. */
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 021121034f1..d386967bf8b 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -2462,7 +2462,7 @@ int do_guides(Depsgraph *depsgraph,
(int)(data->strength * guidetime * 100.0f),
100));
}
- else { /* curve size*/
+ else { /* Curve size. */
if (cu->flag & CU_PATH_RADIUS) {
mul_v3_fl(vec_to_point, radius);
}
diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c
index 6e0965650d3..2231731287d 100644
--- a/source/blender/blenkernel/intern/particle_child.c
+++ b/source/blender/blenkernel/intern/particle_child.c
@@ -785,7 +785,7 @@ static void do_twist(const ParticleChildModifierContext *modifier_ctx,
return;
}
if (part->twist == 0.0f) {
- /* No twist along the strand. */
+ /* No twist along the strand. */
return;
}
/* Dependent on whether it's threaded update or not, curve comes
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index 13f0cb28428..1fd99bb2cbd 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -142,7 +142,7 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
size[(axis + 1) % 3] = (int)ceil(delta[(axis + 1) % 3] / d);
size[(axis + 2) % 3] = (int)ceil(delta[(axis + 2) % 3] / d);
- /* float errors grrr.. */
+ /* float errors grrr. */
size[(axis + 1) % 3] = MIN2(size[(axis + 1) % 3], res);
size[(axis + 2) % 3] = MIN2(size[(axis + 2) % 3], res);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index d236dbbf101..c35f703b072 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -250,7 +250,7 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
if (psys->particles) {
totsaved = MIN2(psys->totpart, totpart);
- /*save old pars*/
+ /* Save old pars. */
if (totsaved) {
memcpy(newpars, psys->particles, totsaved * sizeof(ParticleData));
@@ -607,8 +607,8 @@ void init_particle(ParticleSimulationData *sim, ParticleData *pa)
pa->time = part->sta + (part->end - part->sta) * birth_time;
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*/
+ /* 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 */
}
@@ -840,7 +840,7 @@ void psys_get_birth_coords(
copy_v3_v3(state->co, loc);
- /* boids don't get any initial velocity */
+ /* boids don't get any initial velocity. */
zero_v3(state->vel);
/* boids store direction in ave */
@@ -1473,7 +1473,7 @@ static void integrate_particle(
force_func(forcedata, states + i, force, impulse);
- /* force to acceleration*/
+ /* Force to acceleration. */
mul_v3_v3fl(acceleration, force, 1.0f / pa_mass);
if (external_acceleration) {
@@ -1920,7 +1920,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
}
}
- /* Artificial buoyancy force in negative gravity direction */
+ /* Artificial buoyancy force in negative gravity direction. */
if (fluid->buoyancy > 0.0f && gravity) {
madd_v3_v3fl(force, gravity, fluid->buoyancy * (density - rest_density));
}
@@ -2095,7 +2095,7 @@ static void sphclassical_force_cb(void *sphdata_v,
}
}
- /* Artificial buoyancy force in negative gravity direction */
+ /* Artificial buoyancy force in negative gravity direction. */
if (fluid->buoyancy > 0.0f && gravity) {
madd_v3_v3fl(force, gravity, fluid->buoyancy * (pa->sphdensity - rest_density));
}
@@ -2226,7 +2226,7 @@ static void sph_integrate(ParticleSimulationData *sim,
sphdata->pass = 0;
// sphdata.element_size and sphdata.flow are set in the callback.
- /* restore previous state and treat gravity & effectors as external acceleration*/
+ /* Restore previous state and treat gravity & effectors as external acceleration. */
sub_v3_v3v3(effector_acceleration, pa->state.vel, pa->prev_state.vel);
mul_v3_fl(effector_acceleration, 1.0f / dtime);
@@ -3001,7 +3001,7 @@ static int collision_response(ParticleSimulationData *sim,
/* get back to global coordinates */
add_v3_v3(v1_tan, vc_tan);
- /* convert to angular velocity*/
+ /* Convert to angular velocity. */
cross_v3_v3v3(ave, vr_tan, pce->nor);
mul_v3_fl(ave, 1.0f / MAX2(pa->size, 0.001f));
@@ -3369,7 +3369,7 @@ static void hair_create_input_mesh(ParticleSimulationData *sim,
/* XXX placeholder for more flexible future hair settings */
hair_radius = part->size;
- /* make vgroup for pin roots etc.. */
+ /* Make vgroup for pin roots etc. */
hair_index = 1;
LOOP_PARTICLES
{
@@ -3927,7 +3927,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
pa->alive = PARS_DYING;
}
else if (birthtime <= cfra && birthtime >= psys->cfra) {
- /* particle is born some time between this and last step*/
+ /* Particle is born some time between this and last step. */
reset_particle(sim, pa, dfra * timestep, cfra);
pa->alive = PARS_ALIVE;
pa->state.time = cfra - birthtime;
@@ -3936,7 +3936,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
/* nothing to be done when particle is dead */
}
- /* only reset unborn particles if they're shown or if the particle is born soon*/
+ /* Only reset unborn particles if they're shown or if the particle is born soon. */
if (pa->alive == PARS_UNBORN &&
(part->flag & PART_UNBORN || (cfra + psys->pointcache->step > pa->time))) {
reset_particle(sim, pa, dtime, cfra);
@@ -4104,7 +4104,7 @@ static void update_children(ParticleSimulationData *sim, const bool use_render_p
psys_free_children(sim->psys);
}
}
-/* updates cached particles' alive & other flags etc..*/
+/* Updates cached particles' alive & other flags etc. */
static void cached_step(ParticleSimulationData *sim, float cfra, const bool use_render_params)
{
ParticleSystem *psys = sim->psys;
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 9f316ec60c0..0d84022da77 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -2985,7 +2985,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
}
}
-bool pbvh_has_mask(PBVH *pbvh)
+bool pbvh_has_mask(const PBVH *pbvh)
{
switch (pbvh->type) {
case PBVH_GRIDS:
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 09e4ad93baa..c2483b265a5 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -180,7 +180,7 @@ static BMVert *bm_vert_hash_lookup_chain(GHash *deleted_verts, BMVert *v)
while (true) {
BMVert **v_next_p = (BMVert **)BLI_ghash_lookup_p(deleted_verts, v);
if (v_next_p == NULL) {
- /* not remapped*/
+ /* Not remapped. */
return v;
}
if (*v_next_p == NULL) {
@@ -2316,7 +2316,7 @@ static void pbvh_bmesh_verify(PBVH *pbvh)
vert_count++;
}
- /* if totvert differs from number of verts inside the hash. hash-totvert is checked above */
+ /* If totvert differs from number of verts inside the hash. hash-totvert is checked above. */
BLI_assert(vert_count == pbvh->bm->totvert);
# endif
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index be206f8a642..a05eb6962ce 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -2632,7 +2632,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
}
#endif
- /*if (!G.relbase_valid) return; */ /* save blend file before using pointcache */
+ // if (!G.relbase_valid) return; /* Save blend file before using pointcache. */
/* clear all files in the temp dir with the prefix of the ID and the ".bphys" suffix */
switch (mode) {
@@ -2659,8 +2659,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
ptcache_filename_ext_append(pid, ext, 0, false, 0);
while ((de = readdir(dir)) != NULL) {
- if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
- if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */
+ if (strstr(de->d_name, ext)) { /* Do we have the right extension? */
+ if (STREQLEN(filename, de->d_name, len)) { /* Do we have the right prefix. */
if (mode == PTCACHE_CLEAR_ALL) {
pid->cache->last_exact = MIN2(pid->cache->startframe, 0);
BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
@@ -2695,7 +2695,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
PTCacheMem *link = NULL;
if (mode == PTCACHE_CLEAR_ALL) {
- /*we want startframe if the cache starts before zero*/
+ /* We want startframe if the cache starts before zero. */
pid->cache->last_exact = MIN2(pid->cache->startframe, 0);
for (; pm; pm = pm->next) {
ptcache_mem_clear(pm);
@@ -2856,8 +2856,8 @@ void BKE_ptcache_id_time(
ptcache_filename_ext_append(pid, ext, 0, false, 0);
while ((de = readdir(dir)) != NULL) {
- if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
- if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */
+ if (strstr(de->d_name, ext)) { /* Do we have the right extension? */
+ if (STREQLEN(filename, de->d_name, len)) { /* Do we have the right prefix. */
/* read the number of the file */
const int frame = ptcache_frame_from_filename(de->d_name, ext);
@@ -3038,7 +3038,7 @@ void BKE_ptcache_remove(void)
if (FILENAME_IS_CURRPAR(de->d_name)) {
/* do nothing */
}
- else if (strstr(de->d_name, PTCACHE_EXT)) { /* do we have the right extension?*/
+ else if (strstr(de->d_name, PTCACHE_EXT)) { /* Do we have the right extension? */
BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
BLI_delete(path_full, false, false);
}
@@ -3050,7 +3050,7 @@ void BKE_ptcache_remove(void)
closedir(dir);
}
else {
- rmdir = 0; /* path doesn't exist */
+ rmdir = 0; /* Path doesn't exist. */
}
if (rmdir) {
@@ -3569,8 +3569,8 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c
BLI_strncpy(pid->cache->name, name_dst, sizeof(pid->cache->name));
while ((de = readdir(dir)) != NULL) {
- if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
- if (STREQLEN(old_filename, de->d_name, len)) { /* do we have the right prefix */
+ if (strstr(de->d_name, ext)) { /* Do we have the right extension? */
+ if (STREQLEN(old_filename, de->d_name, len)) { /* Do we have the right prefix. */
/* read the number of the file */
const int frame = ptcache_frame_from_filename(de->d_name, ext);
@@ -3589,7 +3589,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c
void BKE_ptcache_load_external(PTCacheID *pid)
{
- /*todo*/
+ /* TODO: */
PointCache *cache = pid->cache;
int len; /* store the length of the string */
int info = 0;
@@ -3626,8 +3626,8 @@ void BKE_ptcache_load_external(PTCacheID *pid)
}
while ((de = readdir(dir)) != NULL) {
- if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
- if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */
+ if (strstr(de->d_name, ext)) { /* Do we have the right extension? */
+ if (STREQLEN(filename, de->d_name, len)) { /* Do we have the right prefix. */
/* read the number of the file */
const int frame = ptcache_frame_from_filename(de->d_name, ext);
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 21b86aa8148..2d4cce4b953 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -668,7 +668,7 @@ void BKE_rigidbody_calc_volume(Object *ob, float *r_vol)
radius = max_fff(size[0], size[1], size[2]) * 0.5f;
}
- /* calculate volume as appropriate */
+ /* Calculate volume as appropriate. */
switch (rbo->shape) {
case RB_SHAPE_BOX:
volume = size[0] * size[1] * size[2];
@@ -744,10 +744,10 @@ void BKE_rigidbody_calc_center_of_mass(Object *ob, float r_center[3])
* (i.e. Object pivot is centralized in boundbox)
* - boundbox gives full width
*/
- /* XXX: all dimensions are auto-determined now... later can add stored settings for this */
+ /* XXX: all dimensions are auto-determined now... later can add stored settings for this. */
BKE_object_dimensions_get(ob, size);
- /* calculate volume as appropriate */
+ /* Calculate volume as appropriate. */
switch (rbo->shape) {
case RB_SHAPE_BOX:
case RB_SHAPE_SPHERE:
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 41f70db3fba..84741038164 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -228,7 +228,10 @@ static void scene_init_data(ID *id)
/* Curve Profile */
scene->toolsettings->custom_bevel_profile_preset = BKE_curveprofile_add(PROF_PRESET_LINE);
+
+ /* Sequencer */
scene->toolsettings->sequencer_tool_settings = SEQ_tool_settings_init();
+ scene->toolsettings->snap_flag |= SCE_SNAP_SEQ;
for (size_t i = 0; i < ARRAY_SIZE(scene->orientation_slots); i++) {
scene->orientation_slots[i].index_custom = -1;
@@ -2013,7 +2016,7 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
bmain, NULL, sce_copy->master_collection, duplicate_flags, LIB_ID_DUPLICATE_IS_SUBPROCESS);
if (!is_subprocess) {
- /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW.*/
+ /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW. */
BKE_libblock_relink_to_newid(&sce_copy->id);
#ifndef NDEBUG
@@ -3379,7 +3382,7 @@ static bool depsgraph_key_compare(const void *key_a_v, const void *key_b_v)
{
const DepsgraphKey *key_a = key_a_v;
const DepsgraphKey *key_b = key_b_v;
- /* TODO(sergey): Compare rest of */
+ /* TODO(sergey): Compare rest of. */
return !(key_a->view_layer == key_b->view_layer);
}
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 7a5892baaf6..608317933f5 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -1703,9 +1703,9 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
BLO_read_list(reader, &sconsole->scrollback);
BLO_read_list(reader, &sconsole->history);
- /* comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
+ /* Comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
* from left to right. the right-most expression sets the result of the comma
- * expression as a whole*/
+ * expression as a whole. */
LISTBASE_FOREACH_MUTABLE (ConsoleLine *, cl, &sconsole->history) {
BLO_read_data_address(reader, &cl->line);
if (cl->line) {
diff --git a/source/blender/blenkernel/intern/shader_fx.c b/source/blender/blenkernel/intern/shader_fx.c
index 60f0b744e59..b537bdc5479 100644
--- a/source/blender/blenkernel/intern/shader_fx.c
+++ b/source/blender/blenkernel/intern/shader_fx.c
@@ -58,9 +58,9 @@ static ShaderFxTypeInfo *shader_fx_types[NUM_SHADER_FX_TYPES] = {NULL};
/* Methods - Evaluation Loops, etc. */
/* check if exist grease pencil effects */
-bool BKE_shaderfx_has_gpencil(Object *ob)
+bool BKE_shaderfx_has_gpencil(const Object *ob)
{
- ShaderFxData *fx;
+ const ShaderFxData *fx;
for (fx = ob->shader_fx.first; fx; fx = fx->next) {
const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx->type);
if (fxi->type == eShaderFxType_GpencilType) {
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index ae39b200b56..aeb8133974e 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -546,7 +546,7 @@ 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. */
+ /* 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 */
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index fcc1afbc59b..9d871777c61 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -109,11 +109,11 @@ typedef struct ReferenceVert {
} ReferenceVert;
typedef struct ReferenceState {
- float com[3]; /* center of mass*/
- ReferenceVert *ivert; /* list of initial values */
+ float com[3]; /* Center of mass. */
+ ReferenceVert *ivert; /* List of initial values. */
} ReferenceState;
-/*private scratch pad for caching and other data only needed when alive*/
+/* Private scratch pad for caching and other data only needed when alive. */
typedef struct SBScratch {
GHash *colliderhash;
short needstobuildcollider;
@@ -150,11 +150,11 @@ typedef struct SB_thread_context {
#define BSF_INTERSECT 1 /* edge intersects collider face */
/* private definitions for bodypoint states */
-#define SBF_DOFUZZY 1 /* Bodypoint do fuzzy */
-#define SBF_OUTOFCOLLISION 2 /* Bodypoint does not collide */
+#define SBF_DOFUZZY 1 /* Bodypoint do fuzzy. */
+#define SBF_OUTOFCOLLISION 2 /* Bodypoint does not collide. */
-#define BFF_INTERSECT 1 /* collider edge intrudes face */
-#define BFF_CLOSEVERT 2 /* collider vertex repulses face */
+#define BFF_INTERSECT 1 /* collider edge intrudes face. */
+#define BFF_CLOSEVERT 2 /* collider vertex repulses face. */
/* humm .. this should be calculated from sb parameters and sizes. */
static float SoftHeunTol = 1.0f;
@@ -162,9 +162,9 @@ static float SoftHeunTol = 1.0f;
/* local prototypes */
static void free_softbody_intern(SoftBody *sb);
-/*+++ frame based timing +++*/
+/*+++ frame based timing +++ */
-/*physical unit of force is [kg * m / sec^2]*/
+/* Physical unit of force is `kg * m / sec^2`. */
/**
* Since unit of g is [m/sec^2] and F = mass * g we re-scale unit mass of node to 1 gram
@@ -207,7 +207,7 @@ static float sb_time_scale(Object *ob)
}
/*--- frame based timing ---*/
-/* helper functions for everything is animatable jow_go_for2_5 +++++++*/
+/* helper functions for everything is animatable jow_go_for2_5 +++++++ */
/* introducing them here, because i know: steps in properties ( at frame timing )
* will cause unwanted responses of the softbody system (which does inter frame calculations )
* so first 'cure' would be: interpolate linear in time ..
@@ -217,7 +217,7 @@ static float sb_time_scale(Object *ob)
*/
/* animate sb->maxgoal, sb->mingoal */
-static float _final_goal(Object *ob, BodyPoint *bp) /*jow_go_for2_5 */
+static float _final_goal(Object *ob, BodyPoint *bp) /* jow_go_for2_5 */
{
float f = -1999.99f;
if (ob) {
@@ -235,7 +235,7 @@ static float _final_goal(Object *ob, BodyPoint *bp) /*jow_go_for2_5 */
}
}
CLOG_ERROR(&LOG, "sb or bp == NULL");
- return f; /*using crude but spot able values some times helps debuggin */
+ return f; /* Using crude but spot able values some times helps debugging. */
}
static float _final_mass(Object *ob, BodyPoint *bp)
@@ -251,7 +251,7 @@ static float _final_mass(Object *ob, BodyPoint *bp)
}
/* helper functions for everything is animateble jow_go_for2_5 ------*/
-/*+++ collider caching and dicing +++*/
+/* +++ collider caching and dicing +++ */
/*
* for each target object/face the axis aligned bounding box (AABB) is stored
@@ -311,7 +311,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
/* blow it up with forcefield ranges */
hull = max_ff(ob->pd->pdef_sbift, ob->pd->pdef_sboft);
- /* alloc and copy verts*/
+ /* Allocate and copy verts. */
pccd_M->mvert = MEM_dupallocN(cmd->xnew);
/* note that xnew coords are already in global space, */
/* determine the ortho BB */
@@ -328,7 +328,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
pccd_M->bbmax[1] = max_ff(pccd_M->bbmax[1], v[1] + hull);
pccd_M->bbmax[2] = max_ff(pccd_M->bbmax[2], v[2] + hull);
}
- /* alloc and copy faces*/
+ /* Allocate and copy faces. */
pccd_M->tri = MEM_dupallocN(cmd->tri);
/* OBBs for idea1 */
@@ -401,7 +401,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
MEM_freeN((void *)pccd_M->mprevvert);
}
pccd_M->mprevvert = pccd_M->mvert;
- /* alloc and copy verts*/
+ /* Allocate and copy verts. */
pccd_M->mvert = MEM_dupallocN(cmd->xnew);
/* note that xnew coords are already in global space, */
/* determine the ortho BB */
@@ -598,7 +598,7 @@ static int count_mesh_quads(Mesh *me)
static void add_mesh_quad_diag_springs(Object *ob)
{
Mesh *me = ob->data;
- /*BodyPoint *bp;*/ /*UNUSED*/
+ // BodyPoint *bp; /* UNUSED */
int a;
if (ob->soft) {
@@ -618,7 +618,7 @@ static void add_mesh_quad_diag_springs(Object *ob)
/* fill the tail */
a = 0;
bs = &ob->soft->bspring[ob->soft->totspring];
- /*bp= ob->soft->bpoint; */ /*UNUSED*/
+ // bp = ob->soft->bpoint; /* UNUSED */
for (a = me->totpoly; a > 0; a--, mp++) {
if (mp->totloop == 4) {
bs->v1 = mloop[mp->loopstart + 0].v;
@@ -640,7 +640,7 @@ static void add_mesh_quad_diag_springs(Object *ob)
static void add_2nd_order_roller(Object *ob, float UNUSED(stiffness), int *counter, int addsprings)
{
- /*assume we have a softbody*/
+ /* Assume we have a softbody. */
SoftBody *sb = ob->soft; /* is supposed to be there */
BodyPoint *bp, *bpo;
BodySpring *bs, *bs2, *bs3 = NULL;
@@ -654,7 +654,7 @@ static void add_2nd_order_roller(Object *ob, float UNUSED(stiffness), int *count
bs3 = ob->soft->bspring + ob->soft->totspring;
}
for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
- /*scan for neighborhood*/
+ /* Scan for neighborhood. */
bpo = NULL;
v0 = (sb->totpoint - a);
for (b = bp->nofsprings; b > 0; b--) {
@@ -678,7 +678,7 @@ static void add_2nd_order_roller(Object *ob, float UNUSED(stiffness), int *count
for (c = bpo->nofsprings; c > 0; c--) {
bs2 = sb->bspring + bpo->springs[c - 1];
if ((bs2->v1 != notthis) && (bs2->v1 > v0)) {
- (*counter)++; /*hit */
+ (*counter)++; /* hit */
if (addsprings) {
bs3->v1 = v0;
bs3->v2 = bs2->v1;
@@ -698,7 +698,7 @@ static void add_2nd_order_roller(Object *ob, float UNUSED(stiffness), int *count
}
}
}
- /*scan for neighborhood done*/
+ /* Scan for neighborhood done. */
}
}
@@ -772,8 +772,8 @@ static void build_bps_springlist(Object *ob)
if (((sb->totpoint - a) == bs->v2)) {
add_bp_springlist(bp, sb->totspring - b);
}
- } /*for springs*/
- } /*for bp*/
+ } /* For springs. */
+ } /* For bp. */
}
static void calculate_collision_balls(Object *ob)
@@ -825,7 +825,7 @@ static void calculate_collision_balls(Object *ob)
else {
bp->colball = 0;
}
- } /*for bp*/
+ } /* For bp. */
}
/* creates new softbody if didn't exist yet, makes new points and springs arrays */
@@ -905,7 +905,7 @@ static void free_scratch(SoftBody *sb)
if (sb->scratch->colliderhash) {
BLI_ghash_free(sb->scratch->colliderhash,
NULL,
- (GHashValFreeFP)ccd_mesh_free); /*this hoepfully will free all caches*/
+ (GHashValFreeFP)ccd_mesh_free); /* This hopefully will free all caches. */
sb->scratch->colliderhash = NULL;
}
if (sb->scratch->bodyface) {
@@ -976,7 +976,7 @@ static void free_softbody_intern(SoftBody *sb)
* since that would only valid for 'slow' moving collision targets and dito particles
*/
-/* +++ dependency information functions*/
+/* +++ dependency information functions. */
/**
* \note collection overrides scene when not NULL.
@@ -990,9 +990,9 @@ static int query_external_colliders(Depsgraph *depsgraph, Collection *collection
return (numobjects != 0);
}
-/* --- dependency information functions*/
+/* --- dependency information functions. */
-/* +++ the aabb "force" section*/
+/* +++ the aabb "force" section. */
static int sb_detect_aabb_collisionCached(float UNUSED(force[3]),
struct Object *vertexowner,
float UNUSED(time))
@@ -1036,7 +1036,7 @@ static int sb_detect_aabb_collisionCached(float UNUSED(force[3]),
deflected = 2;
}
else {
- /*aye that should be cached*/
+ /* Aye that should be cached. */
CLOG_ERROR(&LOG, "missing cache error");
BLI_ghashIterator_step(ihash);
continue;
@@ -1048,9 +1048,9 @@ static int sb_detect_aabb_collisionCached(float UNUSED(force[3]),
BLI_ghashIterator_free(ihash);
return deflected;
}
-/* --- the aabb section*/
+/* --- the aabb section. */
-/* +++ the face external section*/
+/* +++ the face external section. */
static int sb_detect_face_pointCached(const float face_v1[3],
const float face_v2[3],
const float face_v3[3],
@@ -1104,13 +1104,13 @@ static int sb_detect_face_pointCached(const float face_v1[3],
}
}
else {
- /*aye that should be cached*/
+ /* Aye that should be cached. */
CLOG_ERROR(&LOG, "missing cache error");
BLI_ghashIterator_step(ihash);
continue;
}
- /* use mesh*/
+ /* Use mesh. */
if (mvert) {
while (a) {
copy_v3_v3(nv1, mvert[a - 1].co);
@@ -1118,7 +1118,7 @@ static int sb_detect_face_pointCached(const float face_v1[3],
mul_v3_fl(nv1, time);
madd_v3_v3fl(nv1, mprevvert[a - 1].co, 1.0f - time);
}
- /* origin to face_v2*/
+ /* Origin to face_v2. */
sub_v3_v3(nv1, face_v2);
facedist = dot_v3v3(nv1, d_nvect);
if (fabsf(facedist) < outerfacethickness) {
@@ -1139,7 +1139,7 @@ static int sb_detect_face_pointCached(const float face_v1[3],
}
}
a--;
- } /* while (a)*/
+ } /* while (a) */
} /* if (mvert) */
} /* if (ob->pd && ob->pd->deflect) */
BLI_ghashIterator_step(ihash);
@@ -1201,13 +1201,13 @@ static int sb_detect_face_collisionCached(const float face_v1[3],
}
}
else {
- /*aye that should be cached*/
+ /* Aye that should be cached. */
CLOG_ERROR(&LOG, "missing cache error");
BLI_ghashIterator_step(ihash);
continue;
}
- /* use mesh*/
+ /* Use mesh. */
while (a--) {
if ((aabbmax[0] < mima->minx) || (aabbmin[0] > mima->maxx) ||
(aabbmax[1] < mima->miny) || (aabbmin[1] > mima->maxy) ||
@@ -1235,7 +1235,7 @@ static int sb_detect_face_collisionCached(const float face_v1[3],
}
}
- /* switch origin to be nv2*/
+ /* Switch origin to be nv2. */
sub_v3_v3v3(edge1, nv1, nv2);
sub_v3_v3v3(edge2, nv3, nv2);
cross_v3_v3v3(d_nvect, edge2, edge1);
@@ -1272,7 +1272,7 @@ static void scan_for_ext_face_forces(Object *ob, float timenow)
bf = sb->scratch->bodyface;
for (a = 0; a < sb->scratch->totface; a++, bf++) {
bf->ext_force[0] = bf->ext_force[1] = bf->ext_force[2] = 0.0f;
- /*+++edges intruding*/
+ /*+++edges intruding. */
bf->flag &= ~BFF_INTERSECT;
zero_v3(feedback);
if (sb_detect_face_collisionCached(sb->bpoint[bf->v1].pos,
@@ -1289,9 +1289,9 @@ static void scan_for_ext_face_forces(Object *ob, float timenow)
bf->flag |= BFF_INTERSECT;
choke = min_ff(max_ff(damp, choke), 1.0f);
}
- /*---edges intruding*/
+ /*---edges intruding. */
- /*+++ close vertices*/
+ /*+++ close vertices. */
if ((bf->flag & BFF_INTERSECT) == 0) {
bf->flag &= ~BFF_CLOSEVERT;
tune = -1.0f;
@@ -1311,7 +1311,7 @@ static void scan_for_ext_face_forces(Object *ob, float timenow)
choke = min_ff(max_ff(damp, choke), 1.0f);
}
}
- /*--- close vertices*/
+ /*--- close vertices. */
}
bf = sb->scratch->bodyface;
for (a = 0; a < sb->scratch->totface; a++, bf++) {
@@ -1324,9 +1324,9 @@ static void scan_for_ext_face_forces(Object *ob, float timenow)
}
}
-/* --- the face external section*/
+/* --- the face external section. */
-/* +++ the spring external section*/
+/* +++ the spring external section. */
static int sb_detect_edge_collisionCached(const float edge_v1[3],
const float edge_v2[3],
@@ -1377,13 +1377,13 @@ static int sb_detect_edge_collisionCached(const float edge_v1[3],
}
}
else {
- /*aye that should be cached*/
+ /* Aye that should be cached. */
CLOG_ERROR(&LOG, "missing cache error");
BLI_ghashIterator_step(ihash);
continue;
}
- /* use mesh*/
+ /* Use mesh. */
while (a--) {
if ((aabbmax[0] < mima->minx) || (aabbmin[0] > mima->maxx) ||
(aabbmax[1] < mima->miny) || (aabbmin[1] > mima->maxy) ||
@@ -1411,7 +1411,7 @@ static int sb_detect_edge_collisionCached(const float edge_v1[3],
}
}
- /* switch origin to be nv2*/
+ /* Switch origin to be nv2. */
sub_v3_v3v3(edge1, nv1, nv2);
sub_v3_v3v3(edge2, nv3, nv2);
@@ -1469,12 +1469,12 @@ static void _scan_for_ext_spring_forces(
}
/* ---- springs colliding */
- /* +++ springs seeing wind ... n stuff depending on their orientation*/
- /* note we don't use sb->mediafrict but use sb->aeroedge for magnitude of effect*/
+ /* +++ springs seeing wind ... n stuff depending on their orientation. */
+ /* NOTE: we don't use `sb->mediafrict` but use `sb->aeroedge` for magnitude of effect. */
if (sb->aeroedge) {
float vel[3], sp[3], pr[3], force[3];
float f, windfactor = 0.25f;
- /*see if we have wind*/
+ /* See if we have wind. */
if (effectors) {
EffectedPoint epoint;
float speed[3] = {0.0f, 0.0f, 0.0f};
@@ -1543,7 +1543,7 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph,
/* figure the number of threads while preventing pretty pointless threading overhead */
totthread = BKE_scene_num_threads(scene);
- /* what if we got zillions of CPUs running but less to spread*/
+ /* What if we got zillions of CPUs running but less to spread. */
while ((totsprings / totthread < lowsprings) && (totthread > 1)) {
totthread--;
}
@@ -1590,7 +1590,7 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph,
BKE_effectors_free(effectors);
}
-/* --- the spring external section*/
+/* --- the spring external section. */
static int choose_winner(
float *w, float *pos, float *a, float *b, float *c, float *ca, float *cb, float *cc)
@@ -1683,7 +1683,7 @@ static int sb_detect_vertex_collisionCached(float opco[3],
}
}
else {
- /*aye that should be cached*/
+ /* Aye that should be cached. */
CLOG_ERROR(&LOG, "missing cache error");
BLI_ghashIterator_step(ihash);
continue;
@@ -1697,7 +1697,7 @@ static int sb_detect_vertex_collisionCached(float opco[3],
fa *= fa;
fa = 1.0f / fa;
avel[0] = avel[1] = avel[2] = 0.0f;
- /* use mesh*/
+ /* Use mesh. */
while (a--) {
if ((opco[0] < mima->minx) || (opco[0] > mima->maxx) || (opco[1] < mima->miny) ||
(opco[1] > mima->maxy) || (opco[2] < mima->minz) || (opco[2] > mima->maxz)) {
@@ -1733,7 +1733,7 @@ static int sb_detect_vertex_collisionCached(float opco[3],
}
}
- /* switch origin to be nv2*/
+ /* Switch origin to be nv2. */
sub_v3_v3v3(edge1, nv1, nv2);
sub_v3_v3v3(edge2, nv3, nv2);
/* Abuse dv1 to have vertex in question at *origin* of triangle. */
@@ -2068,7 +2068,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene,
bp->force[1] += -ks * (auxvect[1]);
bp->force[2] += -ks * (auxvect[2]);
- /* calculate damping forces generated by goals*/
+ /* Calculate damping forces generated by goals. */
sub_v3_v3v3(velgoal, bp->origS, bp->origE);
kd = sb->goalfrict * sb_fric_force_scale(ob);
add_v3_v3v3(auxvect, velgoal, bp->vec);
@@ -2113,7 +2113,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene,
pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint - bp, &epoint);
BKE_effectors_apply(effectors, NULL, sb->effector_weights, &epoint, force, NULL, speed);
- /* apply forcefield*/
+ /* Apply force-field. */
mul_v3_fl(force, fieldfactor * eval_sb_fric_force_scale);
add_v3_v3(bp->force, force);
@@ -2125,7 +2125,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene,
/* now we'll have nice centrifugal effect for vortex */
}
else {
- /* BP friction in media (not) moving*/
+ /* BP friction in media (not) moving. */
float kd = sb->mediafrict * sb_fric_force_scale(ob);
/* assume it to be proportional to actual velocity */
bp->force[0] -= bp->vec[0] * kd;
@@ -2160,7 +2160,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene,
/* +++springs */
iks = 1.0f / (1.0f - sb->inspring) - 1.0f; /* inner spring constants function */
if (ob->softflag & OB_SB_EDGES) {
- if (sb->bspring) { /* spring list exists at all ? */
+ if (sb->bspring) { /* Spring list exists at all? */
int b;
BodySpring *bs;
for (b = bp->nofsprings; b > 0; b--) {
@@ -2173,13 +2173,13 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene,
}
// sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, float forcetime)
sb_spring_force(ob, ilast - bb, bs, iks, forcetime);
- } /* loop springs */
- } /* existing spring list */
- } /*any edges*/
+ } /* loop springs. */
+ } /* existing spring list. */
+ } /* Any edges. */
/* ---springs */
- } /*omit on snap */
- } /*loop all bp's*/
- return 0; /*done fine*/
+ } /* Omit on snap. */
+ } /* Loop all bp's. */
+ return 0; /* Done fine. */
}
static void *exec_softbody_calc_forces(void *data)
@@ -2220,7 +2220,7 @@ static void sb_cf_threads_run(Scene *scene,
/* figure the number of threads while preventing pretty pointless threading overhead */
totthread = BKE_scene_num_threads(scene);
- /* what if we got zillions of CPUs running but less to spread*/
+ /* What if we got zillions of CPUs running but less to spread. */
while ((totpoint / totthread < lowpoints) && (totthread > 1)) {
totthread--;
}
@@ -2275,11 +2275,11 @@ static void softbody_calc_forces(
* this will ruin adaptive stepsize AKA heun! (BM)
*/
SoftBody *sb = ob->soft; /* is supposed to be there */
- /*BodyPoint *bproot;*/ /* UNUSED */
- /* float gravity; */ /* UNUSED */
- /* float iks; */
+ // BodyPoint *bproot; /* UNUSED */
+ // float gravity; /* UNUSED */
+ // float iks;
float fieldfactor = -1.0f, windfactor = 0.25;
- int do_deflector /*, do_selfcollision*/, do_springcollision, do_aero;
+ int do_deflector /*, do_selfcollision */, do_springcollision, do_aero;
/* gravity = sb->grav * sb_grav_force_scale(ob); */ /* UNUSED */
@@ -2292,8 +2292,8 @@ static void softbody_calc_forces(
(ob->softflag & OB_SB_EDGECOLL);
do_aero = ((sb->aeroedge) && (ob->softflag & OB_SB_EDGES));
- /* iks = 1.0f/(1.0f-sb->inspring)-1.0f; */ /* inner spring constants function */ /* UNUSED */
- /* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */
+ // iks = 1.0f / (1.0f - sb->inspring) - 1.0f; /* Inner spring constants function. */ /* UNUSED */
+ // bproot = sb->bpoint; /* Need this for proper spring addressing. */ /* UNUSED */
if (do_springcollision || do_aero) {
sb_sfesf_threads_run(depsgraph, scene, ob, timenow, sb->totspring, NULL);
@@ -2344,7 +2344,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
aabbmin[0] = aabbmin[1] = aabbmin[2] = 1e20f;
aabbmax[0] = aabbmax[1] = aabbmax[2] = -1e20f;
- /* old one with homogeneous masses */
+ /* old one with homogeneous masses */
/* claim a minimum mass for vertex */
#if 0
if (sb->nodemass > 0.009999f) {
@@ -2489,7 +2489,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
/* used by heun when it overshoots */
static void softbody_restore_prev_step(Object *ob)
{
- SoftBody *sb = ob->soft; /* is supposed to be there*/
+ SoftBody *sb = ob->soft; /* is supposed to be there. */
BodyPoint *bp;
int a;
@@ -2502,7 +2502,7 @@ static void softbody_restore_prev_step(Object *ob)
#if 0
static void softbody_store_step(Object *ob)
{
- SoftBody *sb = ob->soft; /* is supposed to be there*/
+ SoftBody *sb = ob->soft; /* is supposed to be there. */
BodyPoint *bp;
int a;
@@ -2515,7 +2515,7 @@ static void softbody_store_step(Object *ob)
/* used by predictors and correctors */
static void softbody_store_state(Object *ob, float *ppos, float *pvel)
{
- SoftBody *sb = ob->soft; /* is supposed to be there*/
+ SoftBody *sb = ob->soft; /* is supposed to be there. */
BodyPoint *bp;
int a;
float *pp = ppos, *pv = pvel;
@@ -2533,7 +2533,7 @@ static void softbody_store_state(Object *ob, float *ppos, float *pvel)
/* used by predictors and correctors */
static void softbody_retrieve_state(Object *ob, float *ppos, float *pvel)
{
- SoftBody *sb = ob->soft; /* is supposed to be there*/
+ SoftBody *sb = ob->soft; /* is supposed to be there. */
BodyPoint *bp;
int a;
float *pp = ppos, *pv = pvel;
@@ -2551,7 +2551,7 @@ static void softbody_retrieve_state(Object *ob, float *ppos, float *pvel)
/* used by predictors and correctors */
static void softbody_swap_state(Object *ob, float *ppos, float *pvel)
{
- SoftBody *sb = ob->soft; /* is supposed to be there*/
+ SoftBody *sb = ob->soft; /* is supposed to be there. */
BodyPoint *bp;
int a;
float *pp = ppos, *pv = pvel;
@@ -2773,7 +2773,7 @@ static void mesh_faces_to_scratch(Object *ob)
MLoopTri *looptri, *lt;
BodyFace *bodyface;
int a;
- /* alloc and copy faces*/
+ /* Allocate and copy faces. */
sb->scratch->totface = poly_to_tri_count(me->totpoly, me->totloop);
looptri = lt = MEM_mallocN(sizeof(*looptri) * sb->scratch->totface, __func__);
@@ -3000,8 +3000,8 @@ static void curve_surf_to_softbody(Object *ob)
bp = sb->bpoint;
bs = sb->bspring;
- /* weights from bpoints, same code used as for mesh vertices */
- /* if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) 2.4x hack*/
+ /* Weights from bpoints, same code used as for mesh vertices. */
+ /* if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) 2.4x hack. */
/* new! take the weights from curve vertex anyhow */
if (ob->softflag & OB_SB_GOAL) {
setgoal = 1;
@@ -3022,10 +3022,10 @@ static void curve_surf_to_softbody(Object *ob)
if (setgoal) {
bp->goal *= bezt->weight;
- /* all three triples */
+ /* All three triples. */
(bp + 1)->goal = bp->goal;
(bp + 2)->goal = bp->goal;
- /*do not collide handles */
+ /* Do not collide handles. */
(bp + 1)->loc_flag |= SBF_OUTOFCOLLISION;
(bp + 2)->loc_flag |= SBF_OUTOFCOLLISION;
}
@@ -3137,7 +3137,7 @@ SoftBody *sbNew(void)
sb->inspring = 0.5f;
sb->infrict = 0.5f;
- /*todo backward file compat should copy inspring to inpush while reading old files*/
+ /* TODO: backward file compat should copy `inspring` to `inpush` while reading old files. */
sb->inpush = 0.5f;
sb->colball = 0.49f;
@@ -3150,7 +3150,7 @@ SoftBody *sbNew(void)
sb->choke = 3;
sb_new_scratch(sb);
- /*todo backward file compat should set sb->shearstiff = 1.0f while reading old files*/
+ /* TODO: backward file compat should set `sb->shearstiff = 1.0f` while reading old files. */
sb->shearstiff = 1.0f;
sb->solverflags |= SBSO_OLDERR;
@@ -3205,7 +3205,7 @@ void sbObjectToSoftbody(Object *ob)
free_softbody_intern(ob->soft);
}
-static bool object_has_edges(Object *ob)
+static bool object_has_edges(const Object *ob)
{
if (ob->type == OB_MESH) {
return ((Mesh *)ob->data)->totedge;
@@ -3311,7 +3311,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
for (a = 0, bp = sb->bpoint; a < numVerts; a++, bp++) {
copy_v3_v3(bp->pos, vertexCos[a]);
- mul_m4_v3(ob->obmat, bp->pos); /* yep, sofbody is global coords*/
+ mul_m4_v3(ob->obmat, bp->pos); /* Yep, soft-body is global coords. */
copy_v3_v3(bp->origS, bp->pos);
copy_v3_v3(bp->origE, bp->pos);
copy_v3_v3(bp->origT, bp->pos);
@@ -3493,18 +3493,18 @@ static void softbody_step(
else if (sb->solver_ID == 2) {
/* do semi "fake" implicit euler */
/* removed */
- } /*SOLVER SELECT*/
+ } /* SOLVER SELECT */
else if (sb->solver_ID == 4) {
/* do semi "fake" implicit euler */
- } /*SOLVER SELECT*/
+ } /* SOLVER SELECT */
else if (sb->solver_ID == 3) {
/* do "stupid" semi "fake" implicit euler */
/* removed */
- } /*SOLVER SELECT*/
+ } /* SOLVER SELECT */
else {
CLOG_ERROR(&LOG, "softbody no valid solver ID!");
- } /*SOLVER SELECT*/
+ } /* SOLVER SELECT */
if (sb->plastic) {
apply_spring_memory(ob);
}
diff --git a/source/blender/blenkernel/intern/spline_nurbs.cc b/source/blender/blenkernel/intern/spline_nurbs.cc
index 85fb9730e83..76d046337c0 100644
--- a/source/blender/blenkernel/intern/spline_nurbs.cc
+++ b/source/blender/blenkernel/intern/spline_nurbs.cc
@@ -45,7 +45,7 @@ void NURBSpline::copy_data(Spline &dst) const
nurbs.positions_ = positions_;
nurbs.weights_ = weights_;
nurbs.knots_ = knots_;
- nurbs.knots_dirty_ = false;
+ nurbs.knots_dirty_ = knots_dirty_;
nurbs.radii_ = radii_;
nurbs.tilts_ = tilts_;
}
diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c
index 4ca6f93b014..8b672b2cb49 100644
--- a/source/blender/blenkernel/intern/subdiv_ccg.c
+++ b/source/blender/blenkernel/intern/subdiv_ccg.c
@@ -63,7 +63,7 @@ void subdiv_ccg_average_faces_boundaries_and_corners(SubdivCCG *subdiv_ccg,
/** \name Generally useful internal helpers
* \{ */
-/* Number of floats in per-vertex elements. */
+/* Number of floats in per-vertex elements. */
static int num_element_float_get(const SubdivCCG *subdiv_ccg)
{
/* We always have 3 floats for coordinate. */
@@ -1116,7 +1116,7 @@ typedef struct AverageGridsCornerData {
SubdivCCG *subdiv_ccg;
CCGKey *key;
- /* Optional lookup table. Maps task range index to index in subdiv_ccg->adjacent_vertices*/
+ /* Optional lookup table. Maps task range index to index in `subdiv_ccg->adjacent_vertices`. */
const int *adjacent_vert_index_map;
} AverageGridsCornerData;
@@ -1489,7 +1489,7 @@ BLI_INLINE SubdivCCGCoord coord_at_next_col(const SubdivCCG *subdiv_ccg,
return result;
}
-/* For the input coordinate which is at the boundary of the grid do one step inside. */
+/* For the input coordinate which is at the boundary of the grid do one step inside. */
static SubdivCCGCoord coord_step_inside_from_boundary(const SubdivCCG *subdiv_ccg,
const SubdivCCGCoord *coord)
diff --git a/source/blender/blenkernel/intern/subdiv_eval.c b/source/blender/blenkernel/intern/subdiv_eval.c
index 201d308e096..693827f99ac 100644
--- a/source/blender/blenkernel/intern/subdiv_eval.c
+++ b/source/blender/blenkernel/intern/subdiv_eval.c
@@ -282,7 +282,7 @@ static void buffer_apply_offset(void **buffer, const int offset)
*buffer = ((unsigned char *)*buffer) + offset;
}
-/* Write given number of floats to the beginning of given buffer. */
+/* Write given number of floats to the beginning of given buffer. */
static void buffer_write_float_value(void **buffer, const float *values_buffer, int num_values)
{
memcpy(*buffer, values_buffer, sizeof(float) * num_values);
diff --git a/source/blender/blenkernel/intern/subdiv_foreach.c b/source/blender/blenkernel/intern/subdiv_foreach.c
index 4400e9c976f..061c196df2a 100644
--- a/source/blender/blenkernel/intern/subdiv_foreach.c
+++ b/source/blender/blenkernel/intern/subdiv_foreach.c
@@ -1749,7 +1749,7 @@ static void subdiv_foreach_vertices_of_loose_edges_task(void *__restrict userdat
/* Subdivision vertices which corresponds to edge's v1 and v2. */
const int subdiv_v1_index = ctx->vertices_corner_offset + coarse_edge->v1;
const int subdiv_v2_index = ctx->vertices_corner_offset + coarse_edge->v2;
- /* First subdivided inner vertex of the edge. */
+ /* First subdivided inner vertex of the edge. */
const int subdiv_start_vertex = ctx->vertices_edge_offset +
coarse_edge_index * num_subdiv_vertices_per_coarse_edge;
/* Perform interpolation. */
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 23eccbfba9b..0dbfeaaaadb 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -580,16 +580,16 @@ static void ss_sync_ccg_from_derivedmesh(CCGSubSurf *ss,
#endif
MVert *mvert = dm->getVertArray(dm);
MEdge *medge = dm->getEdgeArray(dm);
- /* MFace *mface = dm->getTessFaceArray(dm); */ /* UNUSED */
+ // MFace *mface = dm->getTessFaceArray(dm); /* UNUSED */
MVert *mv;
MEdge *me;
MLoop *mloop = dm->getLoopArray(dm), *ml;
MPoly *mpoly = dm->getPolyArray(dm), *mp;
- /*MFace *mf;*/ /*UNUSED*/
+ // MFace *mf; /* UNUSED */
int totvert = dm->getNumVerts(dm);
int totedge = dm->getNumEdges(dm);
- /*int totface = dm->getNumTessFaces(dm);*/ /*UNUSED*/
- /*int totpoly = dm->getNumFaces(dm);*/ /*UNUSED*/
+ // int totface = dm->getNumTessFaces(dm); /* UNUSED */
+ // int totpoly = dm->getNumFaces(dm); /* UNUSED */
int i, j;
int *index;
@@ -641,10 +641,10 @@ static void ss_sync_ccg_from_derivedmesh(CCGSubSurf *ss,
fVerts[j] = POINTER_FROM_UINT(ml->v);
}
- /* this is very bad, means mesh is internally inconsistent.
+ /* This is very bad, means mesh is internally inconsistent.
* it is not really possible to continue without modifying
* other parts of code significantly to handle missing faces.
- * since this really shouldn't even be possible we just bail.*/
+ * since this really shouldn't even be possible we just bail. */
if (ccgSubSurf_syncFace(ss, POINTER_FROM_INT(i), mp->totloop, fVerts, &f) ==
eCCGError_InvalidValue) {
static int hasGivenError = 0;
@@ -1008,11 +1008,11 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf)
int gridFaces = gridSideEdges * gridSideEdges;
int i;
CCGFace *f;
- /*int numVerts;*/
+ // int numVerts;
int offset;
int grid;
int x, y;
- /*int lastface = ccgSubSurf_getNumFaces(ss) - 1;*/ /*UNUSED*/
+ // int lastface = ccgSubSurf_getNumFaces(ss) - 1; /* UNUSED */
DMFlagMat *faceFlags = ccgdm->faceFlags;
memset(mf, 0, sizeof(*mf));
@@ -1023,7 +1023,7 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf)
i = ccgdm->reverseFaceMap[faceNum];
f = ccgdm->faceMap[i].face;
- /*numVerts = ccgSubSurf_getFaceNumVerts(f);*/ /*UNUSED*/
+ // numVerts = ccgSubSurf_getFaceNumVerts(f); /* UNUSED */
offset = faceNum - ccgdm->faceMap[i].startFace;
grid = offset / gridFaces;
@@ -1781,7 +1781,7 @@ static void ccgdm_create_grids(DerivedMesh *dm)
numGrids = ccgDM_getNumGrids(dm);
numFaces = ccgSubSurf_getNumFaces(ss);
- /*gridSize = ccgDM_getGridSize(dm);*/ /*UNUSED*/
+ // gridSize = ccgDM_getGridSize(dm); /* UNUSED */
/* compute offset into grid array for each face */
gridOffset = MEM_mallocN(sizeof(int) * numFaces, "ccgdm.gridOffset");
@@ -2089,7 +2089,7 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm,
vertidx[s] = POINTER_AS_INT(ccgSubSurf_getVertVertHandle(v));
}
- /*I think this is for interpolating the center vert?*/
+ /* I think this is for interpolating the center vert? */
w2 = w; // + numVerts*(g2_wid-1) * (g2_wid-1); //numVerts*((g2_wid-1) * g2_wid+g2_wid-1);
DM_interp_vert_data(dm, &ccgdm->dm, vertidx, w2, numVerts, vertNum);
if (vertOrigIndex) {
@@ -2099,7 +2099,7 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm,
vertNum++;
- /*interpolate per-vert data*/
+ /* Interpolate per-vert data. */
for (s = 0; s < numVerts; s++) {
for (x = 1; x < gridFaces; x++) {
w2 = w + s * numVerts * g2_wid * g2_wid + x * numVerts;
@@ -2114,7 +2114,7 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm,
}
}
- /*interpolate per-vert data*/
+ /* Interpolate per-vert data. */
for (s = 0; s < numVerts; s++) {
for (y = 1; y < gridFaces; y++) {
for (x = 1; x < gridFaces; x++) {
@@ -2138,7 +2138,7 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm,
}
for (s = 0; s < numVerts; s++) {
- /*interpolate per-face data*/
+ /* Interpolate per-face data. */
for (y = 0; y < gridFaces; y++) {
for (x = 0; x < gridFaces; x++) {
w2 = w + s * numVerts * g2_wid * g2_wid + (y * g2_wid + x) * numVerts;
@@ -2161,10 +2161,10 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm,
&dm->loopData, &ccgdm->dm.loopData, loopidx, w2, NULL, numVerts, loopindex2);
loopindex2++;
- /*copy over poly data, e.g. mtexpoly*/
+ /* Copy over poly data, e.g. mtexpoly. */
CustomData_copy_data(&dm->polyData, &ccgdm->dm.polyData, origIndex, faceNum, 1);
- /*set original index data*/
+ /* Set original index data. */
if (faceOrigIndex) {
/* reference the index in 'polyOrigIndex' */
*faceOrigIndex = faceNum;
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 27f5593c2ca..74845e3f1b9 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -781,12 +781,12 @@ static void txt_curs_sel(Text *text, TextLine ***linep, int **charp)
*charp = &text->selc;
}
-bool txt_cursor_is_line_start(Text *text)
+bool txt_cursor_is_line_start(const Text *text)
{
return (text->selc == 0);
}
-bool txt_cursor_is_line_end(Text *text)
+bool txt_cursor_is_line_end(const Text *text)
{
return (text->selc == text->sell->len);
}
@@ -1239,7 +1239,7 @@ void txt_order_cursors(Text *text, const bool reverse)
}
}
-bool txt_has_sel(Text *text)
+bool txt_has_sel(const Text *text)
{
return ((text->curl != text->sell) || (text->curc != text->selc));
}
diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c
index 46589a578a8..3dff750edfb 100644
--- a/source/blender/blenkernel/intern/tracking_stabilize.c
+++ b/source/blender/blenkernel/intern/tracking_stabilize.c
@@ -1381,7 +1381,7 @@ ImBuf *BKE_tracking_stabilize_frame(
return ibuf;
}
- /* Allocate frame for stabilization result, copy alpha mode and colorspace. */
+ /* Allocate frame for stabilization result, copy alpha mode and colorspace. */
ibuf_flags = 0;
if (ibuf->rect) {
ibuf_flags |= IB_rect;
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index 377802f1af7..14dd286a315 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -368,10 +368,10 @@ void BKE_undosys_stack_init_from_context(UndoStack *ustack, bContext *C)
}
/* name optional */
-bool BKE_undosys_stack_has_undo(UndoStack *ustack, const char *name)
+bool BKE_undosys_stack_has_undo(const UndoStack *ustack, const char *name)
{
if (name) {
- UndoStep *us = BLI_rfindstring(&ustack->steps, name, offsetof(UndoStep, name));
+ const UndoStep *us = BLI_rfindstring(&ustack->steps, name, offsetof(UndoStep, name));
return us && us->prev;
}
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index c2fb5ef4238..290b880934e 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -744,10 +744,10 @@ static const char *unit_find_str(const char *str, const char *substr, bool case_
*
* "1m1cm+2mm" - Original value.
* "1*1#1*0.01#+2*0.001#" - Replace numbers.
- * "1*1+1*0.01 +2*0.001 " - Add add signs if ( + - * / | & ~ < > ^ ! = % ) not found in between.
+ * "1*1+1*0.01 +2*0.001 " - Add plus signs if ( + - * / | & ~ < > ^ ! = % ) not found in between.
*/
-/* Not too strict, (+ - * /) are most common. */
+/* Not too strict, (+ - * /) are most common. */
static bool ch_is_op(char op)
{
switch (op) {
@@ -917,7 +917,7 @@ static int unit_scale_str(char *str,
return 0;
}
- /* XXX - investigate, does not respect len_max properly. */
+ /* XXX - investigate, does not respect len_max properly. */
char *str_found = (char *)unit_find_str(str, replace_str, case_sensitive);
if (str_found == NULL) {
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index 5fc55aad6a2..272ecc71833 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -1224,7 +1224,7 @@ const VolumeGrid *BKE_volume_grid_active_get_for_read(const Volume *volume)
return BKE_volume_grid_get_for_read(volume, index);
}
-/* Tries to find a grid with the given name. Make sure that that the volume has been loaded. */
+/* Tries to find a grid with the given name. Make sure that the volume has been loaded. */
const VolumeGrid *BKE_volume_grid_find_for_read(const Volume *volume, const char *name)
{
int num_grids = BKE_volume_num_grids(volume);
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index be67b2370e3..533107b2bf6 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -105,8 +105,8 @@ static void workspace_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_list(reader, &workspace->tools);
LISTBASE_FOREACH (WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) {
- /* parent pointer does not belong to workspace data and is therefore restored in lib_link step
- * of window manager.*/
+ /* Parent pointer does not belong to workspace data and is therefore restored in lib_link step
+ * of window manager. */
BLO_read_data_address(reader, &relation->value);
}
diff --git a/source/blender/blenkernel/nla_private.h b/source/blender/blenkernel/nla_private.h
index 71b5a74ddf7..3e13ba602a4 100644
--- a/source/blender/blenkernel/nla_private.h
+++ b/source/blender/blenkernel/nla_private.h
@@ -39,13 +39,13 @@ struct AnimationEvalContext;
typedef struct NlaEvalStrip {
struct NlaEvalStrip *next, *prev;
- NlaTrack *track; /* track that this strip belongs to */
- NlaStrip *strip; /* strip that's being used */
+ NlaTrack *track; /* Track that this strip belongs to. */
+ NlaStrip *strip; /* Strip that's being used. */
- short track_index; /* the index of the track within the list */
- short strip_mode; /* which end of the strip are we looking at */
+ short track_index; /* The index of the track within the list. */
+ short strip_mode; /* Which end of the strip are we looking at. */
- float strip_time; /* time at which which strip is being evaluated */
+ float strip_time; /* Time at which this strip is being evaluated. */
} NlaEvalStrip;
/* NlaEvalStrip->strip_mode */
diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h
index 4e37314ed3e..e40a79dad21 100644
--- a/source/blender/blenlib/BLI_array.h
+++ b/source/blender/blenlib/BLI_array.h
@@ -105,8 +105,9 @@ void _bli_array_grow_func(void **arr_p,
((void)BLI_array_grow_one(arr), (void)(arr[_##arr##_len - 1] = item))
/**
- * appends an item to the array and returns a pointer to the item in the array.
- * item is not a pointer, but actual data value.*/
+ * Appends an item to the array and returns a pointer to the item in the array.
+ * item is not a pointer, but actual data value.
+ */
#define BLI_array_append_r(arr, item) \
((void)BLI_array_grow_one(arr), (void)(arr[_##arr##_len - 1] = item), (&arr[_##arr##_len - 1]))
diff --git a/source/blender/blenlib/BLI_buffer.h b/source/blender/blenlib/BLI_buffer.h
index f641c89e53b..9d66fe9a14e 100644
--- a/source/blender/blenlib/BLI_buffer.h
+++ b/source/blender/blenlib/BLI_buffer.h
@@ -42,7 +42,7 @@ enum {
BLI_Buffer name_ = { \
(name_##_static_), sizeof(type_), 0, static_count_, BLI_BUFFER_USE_STATIC | (flag_)}
-/* never use static*/
+/* Never use static. */
#define BLI_buffer_declare(type_, name_, flag_) \
bool name_##user; /* warn for free only */ \
BLI_Buffer name_ = {NULL, sizeof(type_), 0, 0, (flag_)}
diff --git a/source/blender/blenlib/BLI_color.hh b/source/blender/blenlib/BLI_color.hh
index 3b01bbfb86e..76dfcf0b57d 100644
--- a/source/blender/blenlib/BLI_color.hh
+++ b/source/blender/blenlib/BLI_color.hh
@@ -180,7 +180,7 @@ class ColorSceneLinear4f final : public ColorRGBA<float, eSpace::SceneLinear, Al
/**
* Convert to its byte encoded counter space.
- **/
+ */
ColorSceneLinearByteEncoded4b<Alpha> encode() const
{
ColorSceneLinearByteEncoded4b<Alpha> encoded;
diff --git a/source/blender/blenlib/BLI_dlrbTree.h b/source/blender/blenlib/BLI_dlrbTree.h
index fc52904d699..8c20e3d3988 100644
--- a/source/blender/blenlib/BLI_dlrbTree.h
+++ b/source/blender/blenlib/BLI_dlrbTree.h
@@ -35,7 +35,7 @@ extern "C" {
*/
/* ********************************************** */
-/* Data Types and Type Defines */
+/* Data Types and Type Defines */
/* Base Structs --------------------------------- */
diff --git a/source/blender/blenlib/BLI_dynstr.h b/source/blender/blenlib/BLI_dynstr.h
index 4733812746d..4df773c7cc6 100644
--- a/source/blender/blenlib/BLI_dynstr.h
+++ b/source/blender/blenlib/BLI_dynstr.h
@@ -53,9 +53,9 @@ void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format, ..
void BLI_dynstr_vappendf(DynStr *__restrict ds, const char *__restrict format, va_list args)
ATTR_PRINTF_FORMAT(2, 0) ATTR_NONNULL(1, 2);
-int BLI_dynstr_get_len(DynStr *ds) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
-char *BLI_dynstr_get_cstring(DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
-void BLI_dynstr_get_cstring_ex(DynStr *__restrict ds, char *__restrict rets) ATTR_NONNULL();
+int BLI_dynstr_get_len(const DynStr *ds) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+char *BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+void BLI_dynstr_get_cstring_ex(const DynStr *__restrict ds, char *__restrict rets) ATTR_NONNULL();
void BLI_dynstr_clear(DynStr *ds) ATTR_NONNULL();
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL();
diff --git a/source/blender/blenlib/BLI_edgehash.h b/source/blender/blenlib/BLI_edgehash.h
index 184e3bb57e7..41f0d41d1e0 100644
--- a/source/blender/blenlib/BLI_edgehash.h
+++ b/source/blender/blenlib/BLI_edgehash.h
@@ -57,8 +57,10 @@ void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP free_value);
void BLI_edgehash_print(EdgeHash *eh);
void BLI_edgehash_insert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
bool BLI_edgehash_reinsert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
-void *BLI_edgehash_lookup(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT;
-void *BLI_edgehash_lookup_default(EdgeHash *eh,
+void *BLI_edgehash_lookup(const EdgeHash *eh,
+ unsigned int v0,
+ unsigned int v1) ATTR_WARN_UNUSED_RESULT;
+void *BLI_edgehash_lookup_default(const EdgeHash *eh,
unsigned int v0,
unsigned int v1,
void *default_value) ATTR_WARN_UNUSED_RESULT;
@@ -73,8 +75,10 @@ bool BLI_edgehash_remove(EdgeHash *eh,
EdgeHashFreeFP free_value);
void *BLI_edgehash_popkey(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT;
-bool BLI_edgehash_haskey(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT;
-int BLI_edgehash_len(EdgeHash *eh) ATTR_WARN_UNUSED_RESULT;
+bool BLI_edgehash_haskey(const EdgeHash *eh,
+ unsigned int v0,
+ unsigned int v1) ATTR_WARN_UNUSED_RESULT;
+int BLI_edgehash_len(const EdgeHash *eh) ATTR_WARN_UNUSED_RESULT;
void BLI_edgehash_clear_ex(EdgeHash *eh, EdgeHashFreeFP free_value, const uint reserve);
void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP free_value);
@@ -86,7 +90,7 @@ BLI_INLINE void BLI_edgehashIterator_step(EdgeHashIterator *ehi)
{
ehi->index++;
}
-BLI_INLINE bool BLI_edgehashIterator_isDone(EdgeHashIterator *ehi)
+BLI_INLINE bool BLI_edgehashIterator_isDone(const EdgeHashIterator *ehi)
{
return ehi->index >= ehi->length;
}
@@ -128,10 +132,12 @@ typedef struct EdgeSetIterator {
EdgeSet *BLI_edgeset_new_ex(const char *info, const unsigned int nentries_reserve)
ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
EdgeSet *BLI_edgeset_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
-int BLI_edgeset_len(EdgeSet *es) ATTR_WARN_UNUSED_RESULT;
+int BLI_edgeset_len(const EdgeSet *es) ATTR_WARN_UNUSED_RESULT;
bool BLI_edgeset_add(EdgeSet *es, unsigned int v0, unsigned int v1);
void BLI_edgeset_insert(EdgeSet *es, unsigned int v0, unsigned int v1);
-bool BLI_edgeset_haskey(EdgeSet *es, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT;
+bool BLI_edgeset_haskey(const EdgeSet *es,
+ unsigned int v0,
+ unsigned int v1) ATTR_WARN_UNUSED_RESULT;
void BLI_edgeset_free(EdgeSet *es);
/* rely on inline api for now */
@@ -150,7 +156,7 @@ BLI_INLINE void BLI_edgesetIterator_step(EdgeSetIterator *esi)
{
esi->index++;
}
-BLI_INLINE bool BLI_edgesetIterator_isDone(EdgeSetIterator *esi)
+BLI_INLINE bool BLI_edgesetIterator_isDone(const EdgeSetIterator *esi)
{
return esi->index >= esi->length;
}
diff --git a/source/blender/blenlib/BLI_fnmatch.h b/source/blender/blenlib/BLI_fnmatch.h
index 2d0c13bc423..1df5b6f814a 100644
--- a/source/blender/blenlib/BLI_fnmatch.h
+++ b/source/blender/blenlib/BLI_fnmatch.h
@@ -34,36 +34,36 @@ extern "C" {
# if defined(__cplusplus) || (defined(__STDC__) && __STDC__)
# undef __P
# define __P(protos) protos
-# else /* Not C++ or ANSI C. */
+# else /* Not C++ or ANSI C. */
# undef __P
# define __P(protos) ()
/* We can get away without defining `const' here only because in this file
* it is used only inside the prototype for `fnmatch', which is elided in
- * non-ANSI C where `const' is problematical. */
-# endif /* C++ or ANSI C. */
+ * non-ANSI C where `const' is problematical. */
+# endif /* C++ or ANSI C. */
/* We #undef these before defining them because some losing systems
- * (HP-UX A.08.07 for example) define these in <unistd.h>. */
+ * (HP-UX A.08.07 for example) define these in <unistd.h>. */
# undef FNM_PATHNAME
# undef FNM_NOESCAPE
# undef FNM_PERIOD
-/* Bits set in the FLAGS argument to `fnmatch'. */
-# define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
-# define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
-# define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
+/* Bits set in the FLAGS argument to `fnmatch'. */
+# define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
+# define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
+# define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
# if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined(_GNU_SOURCE)
-# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
-# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
-# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
+# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
+# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
+# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
# endif
-/* Value returned by `fnmatch' if STRING does not match PATTERN. */
+/* Value returned by `fnmatch' if STRING does not match PATTERN. */
# define FNM_NOMATCH 1
/* Match STRING against the filename pattern PATTERN,
- * returning zero if it matches, FNM_NOMATCH if not. */
+ * returning zero if it matches, FNM_NOMATCH if not. */
extern int fnmatch __P((const char *__pattern, const char *__string, int __flags));
#else
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index bc517f81955..e708b327bd4 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -87,7 +87,7 @@ GHash *BLI_ghash_new_ex(GHashHashFP hashfp,
GHash *BLI_ghash_new(GHashHashFP hashfp,
GHashCmpFP cmpfp,
const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
-GHash *BLI_ghash_copy(GHash *gh,
+GHash *BLI_ghash_copy(const GHash *gh,
GHashKeyCopyFP keycopyfp,
GHashValCopyFP valcopyfp) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
@@ -96,8 +96,8 @@ void BLI_ghash_insert(GHash *gh, void *key, void *val);
bool BLI_ghash_reinsert(
GHash *gh, void *key, void *val, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
void *BLI_ghash_replace_key(GHash *gh, void *key);
-void *BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
-void *BLI_ghash_lookup_default(GHash *gh,
+void *BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
+void *BLI_ghash_lookup_default(const GHash *gh,
const void *key,
void *val_default) ATTR_WARN_UNUSED_RESULT;
void **BLI_ghash_lookup_p(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
@@ -116,10 +116,10 @@ void BLI_ghash_clear_ex(GHash *gh,
void *BLI_ghash_popkey(GHash *gh,
const void *key,
GHashKeyFreeFP keyfreefp) ATTR_WARN_UNUSED_RESULT;
-bool BLI_ghash_haskey(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
+bool BLI_ghash_haskey(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
bool BLI_ghash_pop(GHash *gh, GHashIterState *state, void **r_key, void **r_val)
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
-unsigned int BLI_ghash_len(GHash *gh) ATTR_WARN_UNUSED_RESULT;
+unsigned int BLI_ghash_len(const GHash *gh) ATTR_WARN_UNUSED_RESULT;
void BLI_ghash_flag_set(GHash *gh, unsigned int flag);
void BLI_ghash_flag_clear(GHash *gh, unsigned int flag);
@@ -138,7 +138,7 @@ void BLI_ghashIterator_step(GHashIterator *ghi);
BLI_INLINE void *BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
BLI_INLINE void *BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
BLI_INLINE void **BLI_ghashIterator_getValue_p(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
-BLI_INLINE bool BLI_ghashIterator_done(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
+BLI_INLINE bool BLI_ghashIterator_done(const GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT;
struct _gh_Entry {
void *next, *key, *val;
@@ -155,7 +155,7 @@ BLI_INLINE void **BLI_ghashIterator_getValue_p(GHashIterator *ghi)
{
return &((struct _gh_Entry *)ghi->curEntry)->val;
}
-BLI_INLINE bool BLI_ghashIterator_done(GHashIterator *ghi)
+BLI_INLINE bool BLI_ghashIterator_done(const GHashIterator *ghi)
{
return !ghi->curEntry;
}
@@ -202,8 +202,8 @@ GSet *BLI_gset_new_ex(GSetHashFP hashfp,
GSet *BLI_gset_new(GSetHashFP hashfp,
GSetCmpFP cmpfp,
const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
-GSet *BLI_gset_copy(GSet *gs, GSetKeyCopyFP keycopyfp) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
-unsigned int BLI_gset_len(GSet *gs) ATTR_WARN_UNUSED_RESULT;
+GSet *BLI_gset_copy(const GSet *gs, GSetKeyCopyFP keycopyfp) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
+unsigned int BLI_gset_len(const GSet *gs) ATTR_WARN_UNUSED_RESULT;
void BLI_gset_flag_set(GSet *gs, unsigned int flag);
void BLI_gset_flag_clear(GSet *gs, unsigned int flag);
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp);
@@ -212,7 +212,7 @@ bool BLI_gset_add(GSet *gs, void *key);
bool BLI_gset_ensure_p_ex(GSet *gs, const void *key, void ***r_key);
bool BLI_gset_reinsert(GSet *gh, void *key, GSetKeyFreeFP keyfreefp);
void *BLI_gset_replace_key(GSet *gs, void *key);
-bool BLI_gset_haskey(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
+bool BLI_gset_haskey(const GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
bool BLI_gset_pop(GSet *gs, GSetIterState *state, void **r_key) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL();
bool BLI_gset_remove(GSet *gs, const void *key, GSetKeyFreeFP keyfreefp);
@@ -220,7 +220,7 @@ void BLI_gset_clear_ex(GSet *gs, GSetKeyFreeFP keyfreefp, const unsigned int nen
void BLI_gset_clear(GSet *gs, GSetKeyFreeFP keyfreefp);
/* When set's are used for key & value. */
-void *BLI_gset_lookup(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
+void *BLI_gset_lookup(const GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
void *BLI_gset_pop_key(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
/** \} */
@@ -234,7 +234,7 @@ void *BLI_gset_pop_key(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
/* so we can cast but compiler sees as different */
typedef struct GSetIterator {
GHashIterator _ghi
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
__attribute__((deprecated))
#endif
;
@@ -260,9 +260,9 @@ BLI_INLINE void BLI_gsetIterator_step(GSetIterator *gsi)
{
BLI_ghashIterator_step((GHashIterator *)gsi);
}
-BLI_INLINE bool BLI_gsetIterator_done(GSetIterator *gsi)
+BLI_INLINE bool BLI_gsetIterator_done(const GSetIterator *gsi)
{
- return BLI_ghashIterator_done((GHashIterator *)gsi);
+ return BLI_ghashIterator_done((const GHashIterator *)gsi);
}
#define GSET_ITER(gs_iter_, gset_) \
@@ -282,8 +282,8 @@ BLI_INLINE bool BLI_gsetIterator_done(GSetIterator *gsi)
/* For testing, debugging only */
#ifdef GHASH_INTERNAL_API
-int BLI_ghash_buckets_len(GHash *gh);
-int BLI_gset_buckets_len(GSet *gs);
+int BLI_ghash_buckets_len(const GHash *gh);
+int BLI_gset_buckets_len(const GSet *gs);
double BLI_ghash_calc_quality_ex(GHash *gh,
double *r_load,
diff --git a/source/blender/blenlib/BLI_hash_md5.h b/source/blender/blenlib/BLI_hash_md5.h
index 4a5cd8b19f3..227cfcc8876 100644
--- a/source/blender/blenlib/BLI_hash_md5.h
+++ b/source/blender/blenlib/BLI_hash_md5.h
@@ -27,13 +27,13 @@ extern "C" {
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
* result is always in little endian byte order, so that a byte-wise
* output yields to the wanted ASCII representation of the message
- * digest. */
+ * digest. */
void *BLI_hash_md5_buffer(const char *buffer, size_t len, void *resblock);
/* Compute MD5 message digest for bytes read from STREAM. The
* resulting message digest number will be written into the 16 bytes
- * beginning at RESBLOCK. */
+ * beginning at RESBLOCK. */
int BLI_hash_md5_stream(FILE *stream, void *resblock);
diff --git a/source/blender/blenlib/BLI_linklist_stack.h b/source/blender/blenlib/BLI_linklist_stack.h
index be98304e6b5..8a5e94a7b56 100644
--- a/source/blender/blenlib/BLI_linklist_stack.h
+++ b/source/blender/blenlib/BLI_linklist_stack.h
@@ -119,7 +119,7 @@
_##var##_free = _##var##_free->next; \
} \
else { \
- _##var##_temp = alloca(sizeof(LinkNode)); \
+ _##var##_temp = (LinkNode *)alloca(sizeof(LinkNode)); \
} \
_##var##_temp->next = _##var##_stack; \
_##var##_temp->link = data; \
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 54df88ca541..0c3a184d302 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -211,6 +211,7 @@ void mul_transposed_mat3_m4_v3(const float M[4][4], float r[3]);
void mul_m3_v3_double(const float M[3][3], double r[3]);
void mul_m4_m4m4_aligned_scale(float R[4][4], const float A[4][4], const float B[4][4]);
+void mul_m4_m4m4_split_channels(float R[4][4], const float A[4][4], const float B[4][4]);
void mul_m3_fl(float R[3][3], float f);
void mul_m4_fl(float R[4][4], float f);
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 556a216bb89..2f4cf1721af 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -382,10 +382,11 @@ MINLINE float line_point_side_v2(const float l1[2],
const float pt[2]) ATTR_WARN_UNUSED_RESULT;
/********************************** Angles ***********************************/
-/* - angle with 2 arguments is angle between vector */
-/* - angle with 3 arguments is angle between 3 points at the middle point */
-/* - angle_normalized_* is faster equivalent if vectors are normalized */
+/* - angle with 2 arguments is angle between vector.
+ * - angle with 3 arguments is angle between 3 points at the middle point.
+ * - angle_normalized_* is faster equivalent if vectors are normalized.
+ */
float angle_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
float angle_signed_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT;
float angle_v2v2v2(const float a[2], const float b[2], const float c[2]) ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h
index 4d9381093c7..e5e0df02033 100644
--- a/source/blender/blenlib/BLI_mempool.h
+++ b/source/blender/blenlib/BLI_mempool.h
@@ -48,7 +48,7 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr) ATTR_NONNULL(1, 2);
void BLI_mempool_clear_ex(BLI_mempool *pool, const int totelem_reserve) ATTR_NONNULL(1);
void BLI_mempool_clear(BLI_mempool *pool) ATTR_NONNULL(1);
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1);
-int BLI_mempool_len(BLI_mempool *pool) ATTR_NONNULL(1);
+int BLI_mempool_len(const BLI_mempool *pool) ATTR_NONNULL(1);
void *BLI_mempool_findelem(BLI_mempool *pool, unsigned int index) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1);
diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h
index ec74cef9311..f8627952628 100644
--- a/source/blender/blenlib/BLI_rand.h
+++ b/source/blender/blenlib/BLI_rand.h
@@ -71,6 +71,9 @@ void BLI_rng_shuffle_array(struct RNG *rng,
unsigned int elem_size_i,
unsigned int elem_tot) ATTR_NONNULL(1, 2);
+void BLI_rng_shuffle_bitmap(struct RNG *rng, unsigned int *bitmap, unsigned int bits_tot)
+ ATTR_NONNULL(1, 2);
+
/** Note that skipping is as slow as generating n numbers! */
void BLI_rng_skip(struct RNG *rng, int n) ATTR_NONNULL(1);
@@ -89,6 +92,9 @@ void BLI_array_randomize(void *data,
unsigned int elem_tot,
unsigned int seed);
+void BLI_bitmap_randomize(unsigned int *bitmap, unsigned int bits_tot, unsigned int seed)
+ ATTR_NONNULL(1);
+
/** Better seed for the random number generator, using noise.c hash[] */
/** Allows up to BLENDER_MAX_THREADS threads to address */
void BLI_thread_srandom(int thread, unsigned int seed);
diff --git a/source/blender/blenlib/BLI_smallhash.h b/source/blender/blenlib/BLI_smallhash.h
index daea2fcd914..f7aec716e9e 100644
--- a/source/blender/blenlib/BLI_smallhash.h
+++ b/source/blender/blenlib/BLI_smallhash.h
@@ -34,8 +34,8 @@ typedef struct {
void *val;
} SmallHashEntry;
-/* how much stack space to use before dynamically allocating memory.
- * set to match one of the values in 'hashsizes' to avoid too many mallocs */
+/* How much stack space to use before dynamically allocating memory.
+ * set to match one of the values in 'hashsizes' to avoid too many mallocs. */
#define SMSTACKSIZE 131
typedef struct SmallHash {
unsigned int nbuckets;
diff --git a/source/blender/blenlib/BLI_strict_flags.h b/source/blender/blenlib/BLI_strict_flags.h
index 6cee6b64797..b967d7e494d 100644
--- a/source/blender/blenlib/BLI_strict_flags.h
+++ b/source/blender/blenlib/BLI_strict_flags.h
@@ -30,7 +30,7 @@
# pragma GCC diagnostic error "-Wconversion"
# endif
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408
-/* gcc4.8+ only (behavior changed to ignore globals)*/
+/* gcc4.8+ only (behavior changed to ignore globals). */
# pragma GCC diagnostic error "-Wshadow"
/* older gcc changed behavior with ternary */
# pragma GCC diagnostic error "-Wsign-conversion"
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index 5a80680c350..0c51d38e813 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -100,7 +100,7 @@ size_t BLI_str_format_int_grouped(char dst[16], int num) ATTR_NONNULL();
size_t BLI_str_format_uint64_grouped(char dst[16], uint64_t num) ATTR_NONNULL();
void BLI_str_format_byte_unit(char dst[15], long long int bytes, const bool base_10)
ATTR_NONNULL();
-
+void BLI_str_format_attribute_domain_size(char dst[7], int number_to_format) ATTR_NONNULL();
int BLI_strcaseeq(const char *a, const char *b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
char *BLI_strcasestr(const char *s, const char *find) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
char *BLI_strncasestr(const char *s, const char *find, size_t len) ATTR_WARN_UNUSED_RESULT
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h
index d6b068c3889..dbe8ec3dcc0 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -147,7 +147,7 @@ typedef struct TaskParallelSettings {
* (similar to OpenMP's firstprivate).
*/
void *userdata_chunk; /* Pointer to actual data. */
- size_t userdata_chunk_size; /* Size of that data. */
+ size_t userdata_chunk_size; /* Size of that data. */
/* Function called from calling thread once whole range have been
* processed.
*/
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index eefde1afefb..4f71e3aa6e4 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -38,7 +38,7 @@ struct ListBase;
/* Threading API */
-/*this is run once at startup*/
+/* This is run once at startup. */
void BLI_threadapi_init(void);
void BLI_threadapi_exit(void);
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 0bf117df43b..5b84e050f82 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -517,7 +517,7 @@ extern "C" {
# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*(arr)))
#endif
-/* ARRAY_SET_ITEMS#(v, ...): set indices of array 'v' */
+/* ARRAY_SET_ITEMS#(v, ...): set indices of array 'v' */
/* internal helpers */
#define _VA_ARRAY_SET_ITEMS2(v, a) ((v)[0] = (a))
#define _VA_ARRAY_SET_ITEMS3(v, a, b) \
@@ -788,23 +788,24 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
extern "C++" { \
inline constexpr _enum_type operator|(_enum_type a, _enum_type b) \
{ \
- return static_cast<_enum_type>(static_cast<int>(a) | b); \
+ return static_cast<_enum_type>(static_cast<uint64_t>(a) | static_cast<uint64_t>(b)); \
} \
inline constexpr _enum_type operator&(_enum_type a, _enum_type b) \
{ \
- return static_cast<_enum_type>(static_cast<int>(a) & b); \
+ return static_cast<_enum_type>(static_cast<uint64_t>(a) & static_cast<uint64_t>(b)); \
} \
inline constexpr _enum_type operator~(_enum_type a) \
{ \
- return static_cast<_enum_type>(~static_cast<int>(a) & (2 * _max_enum_value - 1)); \
+ return static_cast<_enum_type>(~static_cast<uint64_t>(a) & \
+ (2 * static_cast<uint64_t>(_max_enum_value) - 1)); \
} \
inline _enum_type &operator|=(_enum_type &a, _enum_type b) \
{ \
- return a = static_cast<_enum_type>(static_cast<int>(a) | b); \
+ return a = static_cast<_enum_type>(static_cast<uint64_t>(a) | static_cast<uint64_t>(b)); \
} \
inline _enum_type &operator&=(_enum_type &a, _enum_type b) \
{ \
- return a = static_cast<_enum_type>(static_cast<int>(a) & b); \
+ return a = static_cast<_enum_type>(static_cast<uint64_t>(a) & static_cast<uint64_t>(b)); \
} \
} /* extern "C++" */
diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh
index f6f546c90b9..da02c4f4ae1 100644
--- a/source/blender/blenlib/BLI_vector.hh
+++ b/source/blender/blenlib/BLI_vector.hh
@@ -213,7 +213,8 @@ class Vector {
* Example Usage:
* Vector<ModifierData *> modifiers(ob->modifiers);
*/
- Vector(ListBase &values, Allocator allocator = {}) : Vector(NoExceptConstructor(), allocator)
+ Vector(const ListBase &values, Allocator allocator = {})
+ : Vector(NoExceptConstructor(), allocator)
{
LISTBASE_FOREACH (T, value, &values) {
this->append(value);
@@ -507,10 +508,10 @@ class Vector {
}
/**
- * Enlarges the size of the internal buffer that is considered to be initialized. This invokes
- * undefined behavior when when the new size is larger than the capacity. The method can be
- * useful when you want to call constructors in the vector yourself. This should only be done in
- * very rare cases and has to be justified every time.
+ * Enlarges the size of the internal buffer that is considered to be initialized.
+ * This invokes undefined behavior when the new size is larger than the capacity.
+ * The method can be useful when you want to call constructors in the vector yourself.
+ * This should only be done in very rare cases and has to be justified every time.
*/
void increase_size_by_unchecked(const int64_t n) noexcept
{
@@ -963,7 +964,7 @@ class Vector {
}
/* At least double the size of the previous allocation. Otherwise consecutive calls to grow can
- * cause a reallocation every time even though min_capacity only increments. */
+ * cause a reallocation every time even though min_capacity only increments. */
const int64_t min_new_capacity = this->capacity() * 2;
const int64_t new_capacity = std::max(min_capacity, min_new_capacity);
diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c
index 5255e8b9902..86784557b25 100644
--- a/source/blender/blenlib/intern/BLI_dynstr.c
+++ b/source/blender/blenlib/intern/BLI_dynstr.c
@@ -283,7 +283,7 @@ void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format, ..
* \param ds: The DynStr of interest.
* \return The length of \a ds.
*/
-int BLI_dynstr_get_len(DynStr *ds)
+int BLI_dynstr_get_len(const DynStr *ds)
{
return ds->curlen;
}
@@ -296,10 +296,10 @@ int BLI_dynstr_get_len(DynStr *ds)
* \param ds: The DynStr of interest.
* \param rets: The string to fill.
*/
-void BLI_dynstr_get_cstring_ex(DynStr *__restrict ds, char *__restrict rets)
+void BLI_dynstr_get_cstring_ex(const DynStr *__restrict ds, char *__restrict rets)
{
char *s;
- DynStrElem *dse;
+ const DynStrElem *dse;
for (s = rets, dse = ds->elems; dse; dse = dse->next) {
int slen = strlen(dse->str);
@@ -320,7 +320,7 @@ void BLI_dynstr_get_cstring_ex(DynStr *__restrict ds, char *__restrict rets)
* \param ds: The DynStr of interest.
* \return The contents of \a ds as a c-string.
*/
-char *BLI_dynstr_get_cstring(DynStr *ds)
+char *BLI_dynstr_get_cstring(const DynStr *ds)
{
char *rets = MEM_mallocN(ds->curlen + 1, "dynstr_cstring");
BLI_dynstr_get_cstring_ex(ds, rets);
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index cc01693422c..55fd28667fc 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -26,7 +26,7 @@
# include <dirent.h>
#endif
-#include <string.h> /* strcpy etc.. */
+#include <string.h> /* #strcpy etc. */
#include <sys/stat.h>
#include <time.h>
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 82eac7e0b33..8463c0ec511 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -122,8 +122,8 @@ struct GHash {
BLI_INLINE void ghash_entry_copy(GHash *gh_dst,
Entry *dst,
- GHash *gh_src,
- Entry *src,
+ const GHash *gh_src,
+ const Entry *src,
GHashKeyCopyFP keycopyfp,
GHashValCopyFP valcopyfp)
{
@@ -143,7 +143,7 @@ BLI_INLINE void ghash_entry_copy(GHash *gh_dst,
/**
* Get the full hash for a key.
*/
-BLI_INLINE uint ghash_keyhash(GHash *gh, const void *key)
+BLI_INLINE uint ghash_keyhash(const GHash *gh, const void *key)
{
return gh->hashfp(key);
}
@@ -151,7 +151,7 @@ BLI_INLINE uint ghash_keyhash(GHash *gh, const void *key)
/**
* Get the full hash for an entry.
*/
-BLI_INLINE uint ghash_entryhash(GHash *gh, const Entry *e)
+BLI_INLINE uint ghash_entryhash(const GHash *gh, const Entry *e)
{
return gh->hashfp(e->key);
}
@@ -159,7 +159,7 @@ BLI_INLINE uint ghash_entryhash(GHash *gh, const Entry *e)
/**
* Get the bucket-index for an already-computed full hash.
*/
-BLI_INLINE uint ghash_bucket_index(GHash *gh, const uint hash)
+BLI_INLINE uint ghash_bucket_index(const GHash *gh, const uint hash)
{
#ifdef GHASH_USE_MODULO_BUCKETS
return hash % gh->nbuckets;
@@ -171,7 +171,7 @@ BLI_INLINE uint ghash_bucket_index(GHash *gh, const uint hash)
/**
* Find the index of next used bucket, starting from \a curr_bucket (\a gh is assumed non-empty).
*/
-BLI_INLINE uint ghash_find_next_bucket_index(GHash *gh, uint curr_bucket)
+BLI_INLINE uint ghash_find_next_bucket_index(const GHash *gh, uint curr_bucket)
{
if (curr_bucket >= gh->nbuckets) {
curr_bucket = 0;
@@ -381,7 +381,7 @@ BLI_INLINE void ghash_buckets_reset(GHash *gh, const uint nentries)
* Takes hash and bucket_index arguments to avoid calling #ghash_keyhash and #ghash_bucket_index
* multiple times.
*/
-BLI_INLINE Entry *ghash_lookup_entry_ex(GHash *gh, const void *key, const uint bucket_index)
+BLI_INLINE Entry *ghash_lookup_entry_ex(const GHash *gh, const void *key, const uint bucket_index)
{
Entry *e;
/* If we do not store GHash, not worth computing it for each entry here!
@@ -422,7 +422,7 @@ BLI_INLINE Entry *ghash_lookup_entry_prev_ex(GHash *gh,
/**
* Internal lookup function. Only wraps #ghash_lookup_entry_ex
*/
-BLI_INLINE Entry *ghash_lookup_entry(GHash *gh, const void *key)
+BLI_INLINE Entry *ghash_lookup_entry(const GHash *gh, const void *key)
{
const uint hash = ghash_keyhash(gh, key);
const uint bucket_index = ghash_bucket_index(gh, hash);
@@ -652,7 +652,7 @@ static void ghash_free_cb(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP va
/**
* Copy the GHash.
*/
-static GHash *ghash_copy(GHash *gh, GHashKeyCopyFP keycopyfp, GHashValCopyFP valcopyfp)
+static GHash *ghash_copy(const GHash *gh, GHashKeyCopyFP keycopyfp, GHashValCopyFP valcopyfp)
{
GHash *gh_new;
uint i;
@@ -724,7 +724,7 @@ GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info)
* Copy given GHash. Keys and values are also copied if relevant callback is provided,
* else pointers remain the same.
*/
-GHash *BLI_ghash_copy(GHash *gh, GHashKeyCopyFP keycopyfp, GHashValCopyFP valcopyfp)
+GHash *BLI_ghash_copy(const GHash *gh, GHashKeyCopyFP keycopyfp, GHashValCopyFP valcopyfp)
{
return ghash_copy(gh, keycopyfp, valcopyfp);
}
@@ -741,7 +741,7 @@ void BLI_ghash_reserve(GHash *gh, const uint nentries_reserve)
/**
* \return size of the GHash.
*/
-uint BLI_ghash_len(GHash *gh)
+uint BLI_ghash_len(const GHash *gh)
{
return gh->nentries;
}
@@ -800,7 +800,7 @@ void *BLI_ghash_replace_key(GHash *gh, void *key)
* \note When NULL is a valid value, use #BLI_ghash_lookup_p to differentiate a missing key
* from a key with a NULL value. (Avoids calling #BLI_ghash_haskey before #BLI_ghash_lookup)
*/
-void *BLI_ghash_lookup(GHash *gh, const void *key)
+void *BLI_ghash_lookup(const GHash *gh, const void *key)
{
GHashEntry *e = (GHashEntry *)ghash_lookup_entry(gh, key);
BLI_assert(!(gh->flag & GHASH_FLAG_IS_GSET));
@@ -810,7 +810,7 @@ void *BLI_ghash_lookup(GHash *gh, const void *key)
/**
* A version of #BLI_ghash_lookup which accepts a fallback argument.
*/
-void *BLI_ghash_lookup_default(GHash *gh, const void *key, void *val_default)
+void *BLI_ghash_lookup_default(const GHash *gh, const void *key, void *val_default)
{
GHashEntry *e = (GHashEntry *)ghash_lookup_entry(gh, key);
BLI_assert(!(gh->flag & GHASH_FLAG_IS_GSET));
@@ -938,7 +938,7 @@ void *BLI_ghash_popkey(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp)
/**
* \return true if the \a key is in \a gh.
*/
-bool BLI_ghash_haskey(GHash *gh, const void *key)
+bool BLI_ghash_haskey(const GHash *gh, const void *key)
{
return (ghash_lookup_entry(gh, key) != NULL);
}
@@ -1130,12 +1130,12 @@ GSet *BLI_gset_new(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info)
/**
* Copy given GSet. Keys are also copied if callback is provided, else pointers remain the same.
*/
-GSet *BLI_gset_copy(GSet *gs, GHashKeyCopyFP keycopyfp)
+GSet *BLI_gset_copy(const GSet *gs, GHashKeyCopyFP keycopyfp)
{
- return (GSet *)ghash_copy((GHash *)gs, keycopyfp, NULL);
+ return (GSet *)ghash_copy((const GHash *)gs, keycopyfp, NULL);
}
-uint BLI_gset_len(GSet *gs)
+uint BLI_gset_len(const GSet *gs)
{
return ((GHash *)gs)->nentries;
}
@@ -1172,7 +1172,7 @@ bool BLI_gset_ensure_p_ex(GSet *gs, const void *key, void ***r_key)
{
const uint hash = ghash_keyhash((GHash *)gs, key);
const uint bucket_index = ghash_bucket_index((GHash *)gs, hash);
- GSetEntry *e = (GSetEntry *)ghash_lookup_entry_ex((GHash *)gs, key, bucket_index);
+ GSetEntry *e = (GSetEntry *)ghash_lookup_entry_ex((const GHash *)gs, key, bucket_index);
const bool haskey = (e != NULL);
if (!haskey) {
@@ -1213,9 +1213,9 @@ bool BLI_gset_remove(GSet *gs, const void *key, GSetKeyFreeFP keyfreefp)
return BLI_ghash_remove((GHash *)gs, key, keyfreefp, NULL);
}
-bool BLI_gset_haskey(GSet *gs, const void *key)
+bool BLI_gset_haskey(const GSet *gs, const void *key)
{
- return (ghash_lookup_entry((GHash *)gs, key) != NULL);
+ return (ghash_lookup_entry((const GHash *)gs, key) != NULL);
}
/**
@@ -1277,9 +1277,9 @@ void BLI_gset_flag_clear(GSet *gs, uint flag)
/**
* Returns the pointer to the key if it's found.
*/
-void *BLI_gset_lookup(GSet *gs, const void *key)
+void *BLI_gset_lookup(const GSet *gs, const void *key)
{
- Entry *e = ghash_lookup_entry((GHash *)gs, key);
+ Entry *e = ghash_lookup_entry((const GHash *)gs, key);
return e ? e->key : NULL;
}
@@ -1311,13 +1311,13 @@ void *BLI_gset_pop_key(GSet *gs, const void *key)
/**
* \return number of buckets in the GHash.
*/
-int BLI_ghash_buckets_len(GHash *gh)
+int BLI_ghash_buckets_len(const GHash *gh)
{
return (int)gh->nbuckets;
}
-int BLI_gset_buckets_len(GSet *gs)
+int BLI_gset_buckets_len(const GSet *gs)
{
- return BLI_ghash_buckets_len((GHash *)gs);
+ return BLI_ghash_buckets_len((const GHash *)gs);
}
/**
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index a0e94e00634..8f556e0ddb6 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -1212,7 +1212,7 @@ static void tree_overlap_traverse_cb(BVHOverlapData_Thread *data_thread,
}
/**
- * a version of #tree_overlap_traverse_cb that that break on first true return.
+ * a version of #tree_overlap_traverse_cb that break on first true return.
*/
static bool tree_overlap_traverse_num(BVHOverlapData_Thread *data_thread,
const BVHNode *node1,
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index d3000ef38e8..8196438eb25 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -452,7 +452,7 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
}
}
-int BLI_mempool_len(BLI_mempool *pool)
+int BLI_mempool_len(const BLI_mempool *pool)
{
return (int)pool->totused;
}
diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c
index b0c3379ac97..09234dcfa26 100644
--- a/source/blender/blenlib/intern/DLRB_tree.c
+++ b/source/blender/blenlib/intern/DLRB_tree.c
@@ -414,7 +414,7 @@ static void rotate_right(DLRBT_Tree *tree, DLRBT_Node *root)
}
/* *********************************************** */
-/* Post-Insertion Balancing */
+/* Post-Insertion Balancing */
/* forward defines for insertion checks */
static void insert_check_1(DLRBT_Tree *tree, DLRBT_Node *node);
@@ -472,7 +472,7 @@ static void insert_check_2(DLRBT_Tree *tree, DLRBT_Node *node)
}
}
-/* W. 4+5) Perform rotation on sub-tree containing the 'new' node, then do any */
+/* W. 4+5) Perform rotation on sub-tree containing the 'new' node, then do any. */
static void insert_check_3(DLRBT_Tree *tree, DLRBT_Node *node)
{
DLRBT_Node *gp = get_grandparent(node);
diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c
index 84b3f728884..ea6c2d8d498 100644
--- a/source/blender/blenlib/intern/boxpack_2d.c
+++ b/source/blender/blenlib/intern/boxpack_2d.c
@@ -290,7 +290,7 @@ static int vertex_sort(const void *p1, const void *p2, void *vs_ctx_p)
* to have some way of writing the boxes back to the original data.
* \param len: the number of boxes in the array.
* \param r_tot_x, r_tot_y: set so you can normalize the data.
- * */
+ */
void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r_tot_y)
{
uint box_index, verts_pack_len, i, j, k;
@@ -298,8 +298,8 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
bool isect;
float tot_x = 0.0f, tot_y = 0.0f;
- BoxPack *box, *box_test; /*current box and another for intersection tests*/
- BoxVert *vert; /* the current vert */
+ BoxPack *box, *box_test; /* Current box and another for intersection tests. */
+ BoxVert *vert; /* The current vert. */
struct VertSortContext vs_ctx;
@@ -312,7 +312,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
/* Sort boxes, biggest first */
qsort(boxarray, (size_t)len, sizeof(BoxPack), box_areasort);
- /* add verts to the boxes, these are only used internally */
+ /* Add verts to the boxes, these are only used internally. */
vert = MEM_mallocN(sizeof(BoxVert[4]) * (size_t)len, "BoxPack Verts");
vertex_pack_indices = MEM_mallocN(sizeof(int[3]) * (size_t)len, "BoxPack Indices");
@@ -357,7 +357,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
/* Pack the First box!
* then enter the main box-packing loop */
- box = boxarray; /* get the first box */
+ box = boxarray; /* Get the first box. */
/* First time, no boxes packed */
box->v[BL]->free = 0; /* Can't use any if these */
box->v[BR]->free &= ~(BLF | BRF);
diff --git a/source/blender/blenlib/intern/delaunay_2d.cc b/source/blender/blenlib/intern/delaunay_2d.cc
index eb3e64c49e6..91d63e3444e 100644
--- a/source/blender/blenlib/intern/delaunay_2d.cc
+++ b/source/blender/blenlib/intern/delaunay_2d.cc
@@ -896,7 +896,9 @@ template<typename T> inline bool is_original_vert(const CDTVert<T> *v, CDT_state
return (v->index < cdt->input_vert_tot);
}
-/* Return the Symedge that goes from v1 to v2, if it exists, else return nullptr. */
+/**
+ * Return the #SymEdge that goes from v1 to v2, if it exists, else return nullptr.
+ */
template<typename T>
SymEdge<T> *find_symedge_between_verts(const CDTVert<T> *v1, const CDTVert<T> *v2)
{
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index b8bf535a3b4..f95619803bf 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -193,7 +193,7 @@ BLI_INLINE EdgeHashEntry *edgehash_insert(EdgeHash *eh, Edge edge, void *value)
}
}
-BLI_INLINE EdgeHashEntry *edgehash_lookup_entry(EdgeHash *eh, uint v0, uint v1)
+BLI_INLINE EdgeHashEntry *edgehash_lookup_entry(const EdgeHash *eh, uint v0, uint v1)
{
Edge edge = init_edge(v0, v1);
@@ -310,7 +310,7 @@ bool BLI_edgehash_reinsert(EdgeHash *eh, uint v0, uint v1, void *value)
/**
* A version of #BLI_edgehash_lookup which accepts a fallback argument.
*/
-void *BLI_edgehash_lookup_default(EdgeHash *eh, uint v0, uint v1, void *default_value)
+void *BLI_edgehash_lookup_default(const EdgeHash *eh, uint v0, uint v1, void *default_value)
{
EdgeHashEntry *entry = edgehash_lookup_entry(eh, v0, v1);
return entry ? entry->value : default_value;
@@ -322,7 +322,7 @@ void *BLI_edgehash_lookup_default(EdgeHash *eh, uint v0, uint v1, void *default_
* to differentiate between key-value being NULL and
* lack of key then see #BLI_edgehash_lookup_p().
*/
-void *BLI_edgehash_lookup(EdgeHash *eh, uint v0, uint v1)
+void *BLI_edgehash_lookup(const EdgeHash *eh, uint v0, uint v1)
{
EdgeHashEntry *entry = edgehash_lookup_entry(eh, v0, v1);
return entry ? entry->value : NULL;
@@ -423,7 +423,7 @@ void *BLI_edgehash_popkey(EdgeHash *eh, uint v0, uint v1)
/**
* Return boolean true/false if edge (v0,v1) in hash.
*/
-bool BLI_edgehash_haskey(EdgeHash *eh, uint v0, uint v1)
+bool BLI_edgehash_haskey(const EdgeHash *eh, uint v0, uint v1)
{
return edgehash_lookup_entry(eh, v0, v1) != NULL;
}
@@ -431,7 +431,7 @@ bool BLI_edgehash_haskey(EdgeHash *eh, uint v0, uint v1)
/**
* Return number of keys in hash.
*/
-int BLI_edgehash_len(EdgeHash *eh)
+int BLI_edgehash_len(const EdgeHash *eh)
{
return (int)eh->length;
}
@@ -533,7 +533,7 @@ void BLI_edgeset_free(EdgeSet *es)
MEM_freeN(es);
}
-int BLI_edgeset_len(EdgeSet *es)
+int BLI_edgeset_len(const EdgeSet *es)
{
return (int)es->length;
}
@@ -608,7 +608,7 @@ void BLI_edgeset_insert(EdgeSet *es, uint v0, uint v1)
}
}
-bool BLI_edgeset_haskey(EdgeSet *es, uint v0, uint v1)
+bool BLI_edgeset_haskey(const EdgeSet *es, uint v0, uint v1)
{
Edge edge = init_edge(v0, v1);
diff --git a/source/blender/blenlib/intern/expr_pylike_eval.c b/source/blender/blenlib/intern/expr_pylike_eval.c
index f8618c54ea4..a5d4130cb20 100644
--- a/source/blender/blenlib/intern/expr_pylike_eval.c
+++ b/source/blender/blenlib/intern/expr_pylike_eval.c
@@ -66,29 +66,29 @@
* \{ */
typedef enum eOpCode {
- /* Double constant: (-> dval) */
+ /* Double constant: (-> dval). */
OPCODE_CONST,
- /* 1 argument function call: (a -> func1(a)) */
+ /* 1 argument function call: (a -> func1(a)). */
OPCODE_FUNC1,
- /* 2 argument function call: (a b -> func2(a,b)) */
+ /* 2 argument function call: (a b -> func2(a,b)). */
OPCODE_FUNC2,
- /* 3 argument function call: (a b c -> func3(a,b,c)) */
+ /* 3 argument function call: (a b c -> func3(a,b,c)). */
OPCODE_FUNC3,
/* Parameter access: (-> params[ival]) */
OPCODE_PARAMETER,
- /* Minimum of multiple inputs: (a b c... -> min); ival = arg count */
+ /* Minimum of multiple inputs: (a b c... -> min); ival = arg count. */
OPCODE_MIN,
- /* Maximum of multiple inputs: (a b c... -> max); ival = arg count */
+ /* Maximum of multiple inputs: (a b c... -> max); ival = arg count. */
OPCODE_MAX,
/* Jump (pc += jmp_offset) */
OPCODE_JMP,
- /* Pop and jump if zero: (a -> ); JUMP IF NOT a */
+ /* Pop and jump if zero: (a -> ); JUMP IF NOT a. */
OPCODE_JMP_ELSE,
- /* Jump if nonzero, or pop: (a -> a JUMP) IF a ELSE (a -> ) */
+ /* Jump if nonzero, or pop: (a -> a JUMP) IF a ELSE (a -> ). */
OPCODE_JMP_OR,
- /* Jump if zero, or pop: (a -> a JUMP) IF NOT a ELSE (a -> ) */
+ /* Jump if zero, or pop: (a -> a JUMP) IF NOT a ELSE (a -> ). */
OPCODE_JMP_AND,
- /* For comparison chaining: (a b -> 0 JUMP) IF NOT func2(a,b) ELSE (a b -> b) */
+ /* For comparison chaining: (a b -> 0 JUMP) IF NOT func2(a,b) ELSE (a b -> b). */
OPCODE_CMP_CHAIN,
} eOpCode;
diff --git a/source/blender/blenlib/intern/fnmatch.c b/source/blender/blenlib/intern/fnmatch.c
index 33fe34e7c24..6709dfda1be 100644
--- a/source/blender/blenlib/intern/fnmatch.c
+++ b/source/blender/blenlib/intern/fnmatch.c
@@ -239,7 +239,7 @@ fnmatch (const char *pattern, const char *string, int flags)
# undef FOLD
}
-#endif /* _LIBC or not __GNU_LIBRARY__. */
+#endif /* _LIBC or not __GNU_LIBRARY__. */
/* clang-format on */
diff --git a/source/blender/blenlib/intern/hash_md5.c b/source/blender/blenlib/intern/hash_md5.c
index 8c869ce28c3..3db1b7df0fa 100644
--- a/source/blender/blenlib/intern/hash_md5.c
+++ b/source/blender/blenlib/intern/hash_md5.c
@@ -92,7 +92,7 @@ struct md5_ctx {
/* This array contains the bytes used to pad the buffer to the next 64-byte boundary.
* (RFC 1321, 3.1: Step 1) */
-static const unsigned char fillbuf[64] = {0x80, 0 /* , 0, 0, ... */};
+static const unsigned char fillbuf[64] = {0x80, 0 /* , 0, 0, ... */};
/**
* Initialize structure containing state of computation.
@@ -136,7 +136,7 @@ static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ct
md5_uint32 C = ctx->C;
md5_uint32 D = ctx->D;
- /* Process all bytes in the buffer with 64 bytes in each round of the loop. */
+ /* Process all bytes in the buffer with 64 bytes in each round of the loop. */
while (words < endp) {
md5_uint32 *cwp = correct_words;
md5_uint32 A_save = A;
@@ -161,7 +161,7 @@ static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ct
* T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
*/
- /* Round 1. */
+ /* Round 1. */
OP(A, B, C, D, 7, 0xd76aa478);
OP(D, A, B, C, 12, 0xe8c7b756);
OP(C, D, A, B, 17, 0x242070db);
@@ -190,7 +190,7 @@ static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ct
a += b; \
(void)0
- /* Round 2. */
+ /* Round 2. */
OP(FG, A, B, C, D, 1, 5, 0xf61e2562);
OP(FG, D, A, B, C, 6, 9, 0xc040b340);
OP(FG, C, D, A, B, 11, 14, 0x265e5a51);
@@ -208,7 +208,7 @@ static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ct
OP(FG, C, D, A, B, 7, 14, 0x676f02d9);
OP(FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
- /* Round 3. */
+ /* Round 3. */
OP(FH, A, B, C, D, 5, 4, 0xfffa3942);
OP(FH, D, A, B, C, 8, 11, 0x8771f681);
OP(FH, C, D, A, B, 11, 16, 0x6d9d6122);
@@ -226,7 +226,7 @@ static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ct
OP(FH, C, D, A, B, 15, 16, 0x1fa27cf8);
OP(FH, B, C, D, A, 2, 23, 0xc4ac5665);
- /* Round 4. */
+ /* Round 4. */
OP(FI, A, B, C, D, 0, 6, 0xf4292244);
OP(FI, D, A, B, C, 7, 10, 0x432aff97);
OP(FI, C, D, A, B, 14, 15, 0xab9423a7);
@@ -246,14 +246,14 @@ static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ct
#undef OP
- /* Add the starting values of the context. */
+ /* Add the starting values of the context. */
A += A_save;
B += B_save;
C += C_save;
D += D_save;
}
- /* Put checksum in context given as argument. */
+ /* Put checksum in context given as argument. */
ctx->A = A;
ctx->B = B;
ctx->C = C;
@@ -330,7 +330,7 @@ int BLI_hash_md5_stream(FILE *stream, void *resblock)
++len[1];
}
- /* If end of file is reached, end the loop. */
+ /* If end of file is reached, end the loop. */
if (n == 0) {
break;
}
@@ -354,10 +354,10 @@ int BLI_hash_md5_stream(FILE *stream, void *resblock)
*(md5_uint32 *)&buffer[sum + pad] = SWAP(len[0] << 3);
*(md5_uint32 *)&buffer[sum + pad + 4] = SWAP((len[1] << 3) | (len[0] >> 29));
- /* Process last bytes. */
+ /* Process last bytes. */
md5_process_block(buffer, sum + pad + 8, &ctx);
- /* Construct result in desired memory. */
+ /* Construct result in desired memory. */
md5_read_ctx(&ctx, resblock);
return 0;
}
@@ -374,15 +374,15 @@ void *BLI_hash_md5_buffer(const char *buffer, size_t len, void *resblock)
size_t blocks = len & ~63;
size_t pad, rest;
- /* Initialize the computation context. */
+ /* Initialize the computation context. */
md5_init_ctx(&ctx);
- /* Process whole buffer but last len % 64 bytes. */
+ /* Process whole buffer but last len % 64 bytes. */
md5_process_block(buffer, blocks, &ctx);
- /* REST bytes are not processed yet. */
+ /* REST bytes are not processed yet. */
rest = len - blocks;
- /* Copy to own buffer. */
+ /* Copy to own buffer. */
memcpy(restbuf, &buffer[blocks], rest);
/* Append needed fill bytes at end of buffer.
* We can copy 64 bytes because the buffer is always big enough. */
diff --git a/source/blender/blenlib/intern/kdtree_impl.h b/source/blender/blenlib/intern/kdtree_impl.h
index 2a0e8b3ec68..2aec3ce082a 100644
--- a/source/blender/blenlib/intern/kdtree_impl.h
+++ b/source/blender/blenlib/intern/kdtree_impl.h
@@ -967,7 +967,7 @@ static int kdtree_node_cmp_deduplicate(const void *n0_p, const void *n1_p)
}
/**
- * Remove exact duplicates (run before before balancing).
+ * Remove exact duplicates (run before balancing).
*
* Keep the first element added when duplicates are found.
*/
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index c1db9ec1a69..58b109eca10 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -192,14 +192,14 @@ MINLINE double ratiod(double min, double max, double pos)
return range == 0 ? 0 : ((pos - min) / range);
}
-/* Map a normalized value, i.e. from interval [0, 1] to interval [a, b] */
+/* Map a normalized value, i.e. from interval [0, 1] to interval [a, b]. */
MINLINE float scalenorm(float a, float b, float x)
{
BLI_assert(x <= 1 && x >= 0);
return (x * (b - a)) + a;
}
-/* used for zoom values*/
+/* Used for zoom values. */
MINLINE float power_of_2(float val)
{
return (float)pow(2.0, ceil(log((double)val) / M_LN2));
@@ -760,7 +760,7 @@ MALWAYS_INLINE __m128 _bli_math_fastpow24(const __m128 arg)
__m128 x = _bli_math_fastpow(0x3F4CCCCD, 0x4F55A7FB, arg);
__m128 arg2 = _mm_mul_ps(arg, arg);
__m128 arg4 = _mm_mul_ps(arg2, arg2);
- /* error max = 0.018 avg = 0.0031 |avg| = 0.0031 */
+ /* error max = 0.018 avg = 0.0031 |avg| = 0.0031 */
x = _bli_math_improve_5throot_solution(x, arg4);
/* error max = 0.00021 avg = 1.6e-05 |avg| = 1.6e-05 */
x = _bli_math_improve_5throot_solution(x, arg4);
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index abcb3139dc7..263c508c07c 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -478,7 +478,7 @@ void minmax_rgb(short c[3])
* accessible from the given triple of primaries. Desaturate
* it by adding white, equal quantities of R, G, and B, enough
* to make RGB all positive. The function returns 1 if the
- * components were modified, zero otherwise.*/
+ * components were modified, zero otherwise. */
int constrain_rgb(float *r, float *g, float *b)
{
/* Amount of white needed */
@@ -717,13 +717,17 @@ void blackbody_temperature_to_rgb_table(float *r_table, int width, float min, fl
/* ****************************** wavelength ******************************** */
/* Wavelength to RGB. */
-/* CIE colour matching functions xBar, yBar, and zBar for
- * wavelengths from 380 through 780 nanometers, every 5
- * nanometers.
+/**
+ * CIE color matching functions `xBar`, `yBar`, and `zBar` for
+ * wavelengths from 380 through 780 nanometers, every 5 nanometers.
+ *
* For a wavelength lambda in this range:
- * cie_colour_match[(lambda - 380) / 5][0] = xBar
- * cie_colour_match[(lambda - 380) / 5][1] = yBar
- * cie_colour_match[(lambda - 380) / 5][2] = zBar */
+ * \code{.txt}
+ * cie_color_match[(lambda - 380) / 5][0] = xBar
+ * cie_color_match[(lambda - 380) / 5][1] = yBar
+ * cie_color_match[(lambda - 380) / 5][2] = zBar
+ * \endcode
+ */
static float cie_colour_match[81][3] = {
{0.0014f, 0.0000f, 0.0065f}, {0.0022f, 0.0001f, 0.0105f}, {0.0042f, 0.0001f, 0.0201f},
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index de50ae27b94..3175bf116a0 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -856,7 +856,7 @@ void dist_squared_to_projected_aabb_precalc(struct DistProjectedAABBPrecalc *pre
}
#else
if (!isect_plane_plane_v3(px, py, precalc->ray_origin, precalc->ray_direction)) {
- /* Matrix with weird coplanar planes. Undetermined origin.*/
+ /* Matrix with weird co-planar planes. Undetermined origin. */
zero_v3(precalc->ray_origin);
precalc->ray_direction[0] = precalc->pmat[0][3];
precalc->ray_direction[1] = precalc->pmat[1][3];
@@ -2133,7 +2133,7 @@ bool isect_ray_line_v3(const float ray_origin[3],
const float nlen = len_squared_v3(n);
if (nlen == 0.0f) {
- /* the lines are parallel.*/
+ /* The lines are parallel. */
return false;
}
@@ -2903,7 +2903,7 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3],
/*---test edges---*/
sub_v3_v3v3(e3, v2, v1); /* wasn't yet calculated */
- /*e1*/
+ /* `e1` */
sub_v3_v3v3(bv, v0, p1);
elen2 = dot_v3v3(e1, e1);
@@ -2926,8 +2926,8 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3],
}
}
- /*e2*/
- /*bv is same*/
+ /* `e2` */
+ /* `bv` is same. */
elen2 = dot_v3v3(e2, e2);
edotv = dot_v3v3(e2, vel);
edotbv = dot_v3v3(e2, bv);
@@ -2948,11 +2948,11 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3],
}
}
- /*e3*/
- /* sub_v3_v3v3(bv, v0, p1); */ /* UNUSED */
- /* elen2 = dot_v3v3(e1, e1); */ /* UNUSED */
- /* edotv = dot_v3v3(e1, vel); */ /* UNUSED */
- /* edotbv = dot_v3v3(e1, bv); */ /* UNUSED */
+ /* `e3` */
+ // sub_v3_v3v3(bv, v0, p1); /* UNUSED */
+ // elen2 = dot_v3v3(e1, e1); /* UNUSED */
+ // edotv = dot_v3v3(e1, vel); /* UNUSED */
+ // edotbv = dot_v3v3(e1, bv); /* UNUSED */
sub_v3_v3v3(bv, v1, p1);
elen2 = dot_v3v3(e3, e3);
@@ -4642,7 +4642,7 @@ void resolve_quad_uv_v2_deriv(float r_uv[2],
(st3[0] * st0[1] - st3[1] * st0[0]);
/* X is 2D cross product (determinant)
- * A = (p0 - p) X (p0 - p3)*/
+ * A = (p0 - p) X (p0 - p3) */
const double a = (st0[0] - st[0]) * (st0[1] - st3[1]) - (st0[1] - st[1]) * (st0[0] - st3[0]);
/* B = ( (p0 - p) X (p1 - p2) + (p1 - p) X (p0 - p3) ) / 2 */
@@ -4731,7 +4731,7 @@ float resolve_quad_u_v2(const float st[2],
(st3[0] * st0[1] - st3[1] * st0[0]);
/* X is 2D cross product (determinant)
- * A = (p0 - p) X (p0 - p3)*/
+ * A = (p0 - p) X (p0 - p3) */
const double a = (st0[0] - st[0]) * (st0[1] - st3[1]) - (st0[1] - st[1]) * (st0[0] - st3[0]);
/* B = ( (p0 - p) X (p1 - p2) + (p1 - p) X (p0 - p3) ) / 2 */
@@ -6244,7 +6244,7 @@ float cubic_tangent_factor_circle_v3(const float tan_l[3], const float tan_r[3])
BLI_ASSERT_UNIT_V3(tan_l);
BLI_ASSERT_UNIT_V3(tan_r);
- /* -7f causes instability/glitches with Bendy Bones + Custom Refs */
+ /* -7f causes instability/glitches with Bendy Bones + Custom Refs. */
const float eps = 1e-5f;
const float tan_dot = dot_v3v3(tan_l, tan_r);
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index d447da4de64..88bef854213 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -1290,6 +1290,9 @@ bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
* Combines transformations, handling scale separately in a manner equivalent
* to the Aligned Inherit Scale mode, in order to avoid creating shear.
* If A scale is uniform, the result is equivalent to ordinary multiplication.
+ *
+ * Note: this effectively takes output location from simple multiplication,
+ * and uses mul_m4_m4m4_split_channels for rotation and scale.
*/
void mul_m4_m4m4_aligned_scale(float R[4][4], const float A[4][4], const float B[4][4])
{
@@ -1307,6 +1310,25 @@ void mul_m4_m4m4_aligned_scale(float R[4][4], const float A[4][4], const float B
loc_rot_size_to_mat4(R, loc_r, rot_r, size_r);
}
+/**
+ * Separately combines location, rotation and scale of the input matrices.
+ */
+void mul_m4_m4m4_split_channels(float R[4][4], const float A[4][4], const float B[4][4])
+{
+ float loc_a[3], rot_a[3][3], size_a[3];
+ float loc_b[3], rot_b[3][3], size_b[3];
+ float loc_r[3], rot_r[3][3], size_r[3];
+
+ mat4_to_loc_rot_size(loc_a, rot_a, size_a, A);
+ mat4_to_loc_rot_size(loc_b, rot_b, size_b, B);
+
+ add_v3_v3v3(loc_r, loc_a, loc_b);
+ mul_m3_m3m3_uniq(rot_r, rot_a, rot_b);
+ mul_v3_v3v3(size_r, size_a, size_b);
+
+ loc_rot_size_to_mat4(R, loc_r, rot_r, size_r);
+}
+
/****************************** Linear Algebra *******************************/
void transpose_m3(float R[3][3])
@@ -2665,7 +2687,7 @@ void loc_eul_size_to_mat4(float R[4][4],
size_to_mat3(smat, size);
mul_m3_m3m3(tmat, rmat, smat);
- /* copy rot/scale part to output matrix*/
+ /* Copy rot/scale part to output matrix. */
copy_m4_m3(R, tmat);
/* copy location to matrix */
@@ -2686,18 +2708,18 @@ void loc_eulO_size_to_mat4(float R[4][4],
{
float rmat[3][3], smat[3][3], tmat[3][3];
- /* initialize new matrix */
+ /* Initialize new matrix. */
unit_m4(R);
- /* make rotation + scaling part */
+ /* Make rotation + scaling part. */
eulO_to_mat3(rmat, eul, rotOrder);
size_to_mat3(smat, size);
mul_m3_m3m3(tmat, rmat, smat);
- /* copy rot/scale part to output matrix*/
+ /* Copy rot/scale part to output matrix. */
copy_m4_m3(R, tmat);
- /* copy location to matrix */
+ /* Copy location to matrix. */
R[3][0] = loc[0];
R[3][1] = loc[1];
R[3][2] = loc[2];
@@ -2722,7 +2744,7 @@ void loc_quat_size_to_mat4(float R[4][4],
size_to_mat3(smat, size);
mul_m3_m3m3(tmat, rmat, smat);
- /* copy rot/scale part to output matrix*/
+ /* Copy rot/scale part to output matrix. */
copy_m4_m3(R, tmat);
/* copy location to matrix */
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 469cd573372..52737de227b 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1999,7 +1999,7 @@ void mat4_to_dquat(DualQuat *dq, const float basemat[4][4], const float mat[4][4
if (!is_orthonormal_m3(mat3) || (determinant_m4(mat) < 0.0f) ||
len_squared_v3(dscale) > square_f(1e-4f)) {
- /* extract R and S */
+ /* Extract R and S. */
float tmp[4][4];
/* extra orthogonalize, to avoid flipping with stretched bones */
diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc
index 5b7b6d9a929..988988179fd 100644
--- a/source/blender/blenlib/intern/mesh_intersect.cc
+++ b/source/blender/blenlib/intern/mesh_intersect.cc
@@ -1386,7 +1386,7 @@ static ITT_value intersect_tri_tri(const IMesh &tm, int t1, int t2)
int sr1 = filter_plane_side(d_r1, d_r2, d_n2, abs_d_r1, abs_d_r2, abs_d_n2);
if ((sp1 > 0 && sq1 > 0 && sr1 > 0) || (sp1 < 0 && sq1 < 0 && sr1 < 0)) {
# ifdef PERFDEBUG
- incperfcount(2); /* Tri tri intersects decided by filter plane tests. */
+ incperfcount(2); /* Triangle-triangle intersects decided by filter plane tests. */
# endif
if (dbg_level > 0) {
std::cout << "no intersection, all t1's verts above or below t2\n";
@@ -1404,7 +1404,7 @@ static ITT_value intersect_tri_tri(const IMesh &tm, int t1, int t2)
int sr2 = filter_plane_side(d_r2, d_r1, d_n1, abs_d_r2, abs_d_r1, abs_d_n1);
if ((sp2 > 0 && sq2 > 0 && sr2 > 0) || (sp2 < 0 && sq2 < 0 && sr2 < 0)) {
# ifdef PERFDEBUG
- incperfcount(2); /* Tri tri intersects decided by filter plane tests. */
+ incperfcount(2); /* Triangle-triangle intersects decided by filter plane tests. */
# endif
if (dbg_level > 0) {
std::cout << "no intersection, all t2's verts above or below t1\n";
@@ -1446,7 +1446,7 @@ static ITT_value intersect_tri_tri(const IMesh &tm, int t1, int t2)
std::cout << "no intersection, all t1's verts above or below t2 (exact)\n";
}
# ifdef PERFDEBUG
- incperfcount(3); /* Tri tri intersects decided by exact plane tests. */
+ incperfcount(3); /* Triangle-triangle intersects decided by exact plane tests. */
# endif
return ITT_value(INONE);
}
@@ -1478,7 +1478,7 @@ static ITT_value intersect_tri_tri(const IMesh &tm, int t1, int t2)
std::cout << "no intersection, all t2's verts above or below t1 (exact)\n";
}
# ifdef PERFDEBUG
- incperfcount(3); /* Tri tri intersects decided by exact plane tests. */
+ incperfcount(3); /* Triangle-triangle intersects decided by exact plane tests. */
# endif
return ITT_value(INONE);
}
@@ -1998,6 +1998,10 @@ static Array<Face *> polyfill_triangulate_poly(Face *f, IMeshArena *arena)
* If this happens, we use the polyfill triangulator instead. We don't
* use the polyfill triangulator by default because it can create degenerate
* triangles (which we can handle but they'll create non-manifold meshes).
+ *
+ * While it is tempting to handle quadrilaterals specially, since that
+ * is by far the usual case, we need to know if the quad is convex when
+ * projected before doing so, and that takes a fair amount of computation by itself.
*/
static Array<Face *> triangulate_poly(Face *f, IMeshArena *arena)
{
@@ -2099,20 +2103,6 @@ IMesh triangulate_polymesh(IMesh &imesh, IMeshArena *arena)
if (flen == 3) {
face_tris.append(f);
}
- else if (flen == 4) {
- const Vert *v0 = (*f)[0];
- const Vert *v1 = (*f)[1];
- const Vert *v2 = (*f)[2];
- const Vert *v3 = (*f)[3];
- int eo_01 = f->edge_orig[0];
- int eo_12 = f->edge_orig[1];
- int eo_23 = f->edge_orig[2];
- int eo_30 = f->edge_orig[3];
- Face *f0 = arena->add_face({v0, v1, v2}, f->orig, {eo_01, eo_12, -1}, {false, false, false});
- Face *f1 = arena->add_face({v0, v2, v3}, f->orig, {-1, eo_23, eo_30}, {false, false, false});
- face_tris.append(f0);
- face_tris.append(f1);
- }
else {
Array<Face *> tris = triangulate_poly(f, arena);
for (Face *tri : tris) {
@@ -2246,7 +2236,7 @@ class TriOverlaps {
}
overlap_tot_ += overlap_tot_;
}
- /* Sort the overlaps to bring all the intersects with a given indexA together. */
+ /* Sort the overlaps to bring all the intersects with a given indexA together. */
std::sort(overlap_, overlap_ + overlap_tot_, bvhtreeverlap_cmp);
if (dbg_level > 0) {
std::cout << overlap_tot_ << " overlaps found:\n";
diff --git a/source/blender/blenlib/intern/rand.cc b/source/blender/blenlib/intern/rand.cc
index 8dbfffbad20..db5e08d37ce 100644
--- a/source/blender/blenlib/intern/rand.cc
+++ b/source/blender/blenlib/intern/rand.cc
@@ -28,6 +28,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_bitmap.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_rand.hh"
@@ -149,18 +150,16 @@ void BLI_rng_get_tri_sample_float_v3(
void BLI_rng_shuffle_array(RNG *rng, void *data, unsigned int elem_size_i, unsigned int elem_tot)
{
- const uint elem_size = elem_size_i;
- unsigned int i = elem_tot;
- void *temp;
-
if (elem_tot <= 1) {
return;
}
- temp = malloc(elem_size);
+ const uint elem_size = elem_size_i;
+ unsigned int i = elem_tot;
+ void *temp = malloc(elem_size);
while (i--) {
- unsigned int j = BLI_rng_get_uint(rng) % elem_tot;
+ const unsigned int j = BLI_rng_get_uint(rng) % elem_tot;
if (i != j) {
void *iElem = (unsigned char *)data + i * elem_size_i;
void *jElem = (unsigned char *)data + j * elem_size_i;
@@ -173,6 +172,24 @@ void BLI_rng_shuffle_array(RNG *rng, void *data, unsigned int elem_size_i, unsig
free(temp);
}
+void BLI_rng_shuffle_bitmap(struct RNG *rng, BLI_bitmap *bitmap, unsigned int bits_tot)
+{
+ if (bits_tot <= 1) {
+ return;
+ }
+
+ unsigned int i = bits_tot;
+ while (i--) {
+ const unsigned int j = BLI_rng_get_uint(rng) % bits_tot;
+ if (i != j) {
+ const bool i_bit = BLI_BITMAP_TEST(bitmap, i);
+ const bool j_bit = BLI_BITMAP_TEST(bitmap, j);
+ BLI_BITMAP_SET(bitmap, i, j_bit);
+ BLI_BITMAP_SET(bitmap, j, i_bit);
+ }
+ }
+}
+
/**
* Simulate getting \a n random values.
*
@@ -216,6 +233,14 @@ void BLI_array_randomize(void *data,
BLI_rng_shuffle_array(&rng, data, elem_size, elem_tot);
}
+void BLI_bitmap_randomize(BLI_bitmap *bitmap, unsigned int bits_tot, unsigned int seed)
+{
+ RNG rng;
+
+ BLI_rng_seed(&rng, seed);
+ BLI_rng_shuffle_bitmap(&rng, bitmap, bits_tot);
+}
+
/* ********* for threaded random ************** */
static RNG rng_tab[BLENDER_MAX_THREADS];
diff --git a/source/blender/blenlib/intern/stack.c b/source/blender/blenlib/intern/stack.c
index f2e8b352aab..4a9bdd48a0a 100644
--- a/source/blender/blenlib/intern/stack.c
+++ b/source/blender/blenlib/intern/stack.c
@@ -182,7 +182,7 @@ void BLI_stack_pop(BLI_Stack *stack, void *dst)
}
/**
- * A version of #BLI_stack_pop which which fills in an array.
+ * A version of #BLI_stack_pop which fills in an array.
*
* \param dst: The destination array,
* must be at least (#BLI_Stack.elem_size * \a n) bytes long.
@@ -201,7 +201,7 @@ void BLI_stack_pop_n(BLI_Stack *stack, void *dst, unsigned int n)
}
/**
- * A version of #BLI_stack_pop_n which which fills in an array (in the reverse order).
+ * A version of #BLI_stack_pop_n which fills in an array (in the reverse order).
*
* \note The first item in the array will be first item added to the stack.
*/
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 8964dac31a9..19b925535e2 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -47,7 +47,7 @@
#endif
#include <fcntl.h>
-#include <string.h> /* strcpy etc.. */
+#include <string.h> /* `strcpy` etc. */
#ifdef WIN32
# include "BLI_string_utf8.h"
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 3d40c6ef146..61d095658a3 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -370,7 +370,7 @@ size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, const si
* \param src: The escaped source string.
* \param dst_maxncpy: The maximum number of bytes allowable to copy.
*
- * \note This is used for for parsing animation paths in blend files.
+ * \note This is used for parsing animation paths in blend files.
*/
size_t BLI_str_unescape(char *__restrict dst, const char *__restrict src, const size_t src_maxncpy)
{
@@ -1230,6 +1230,47 @@ void BLI_str_format_byte_unit(char dst[15], long long int bytes, const bool base
}
/**
+ * Format a attribute domain to a up to 6 places (plus '\0' terminator) string using long number
+ * names abbreviations. This function is designed to produce a compact representation of large
+ * numbers.
+ *
+ * 1 -> 1
+ * 15 -> 15
+ * 155 -> 155
+ * 1555 -> 1.6K
+ * 15555 -> 15.6K
+ * 155555 -> 156K
+ * 1555555 -> 1.6M
+ * 15555555 -> 15.6M
+ * 155555555 -> 156M
+ * 1000000000 -> 1B
+ * ...
+ *
+ * Dimension of 7 is the maximum length of the resulting string
+ * A combination with 7 places would be -15.5K\0
+ */
+void BLI_str_format_attribute_domain_size(char dst[7], int number_to_format)
+{
+ float number_to_format_converted = number_to_format;
+ int order = 0;
+ const float base = 1000;
+ const char *units[] = {"", "K", "M", "B"};
+ const int tot_units = ARRAY_SIZE(units);
+
+ while ((fabsf(number_to_format_converted) >= base) && ((order + 1) < tot_units)) {
+ number_to_format_converted /= base;
+ order++;
+ }
+
+ const size_t dst_len = 7;
+ int decimals = 0;
+ if ((order > 0) && fabsf(number_to_format_converted) < 100.0f) {
+ decimals = 1;
+ }
+ BLI_snprintf(dst, dst_len, "%.*f%s", decimals, number_to_format_converted, units[order]);
+}
+
+/**
* Find the ranges needed to split \a str into its individual words.
*
* \param str: The string to search for words.
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c
index 7aa5930b4ad..3a02ddaa349 100644
--- a/source/blender/blenlib/intern/string_utf8.c
+++ b/source/blender/blenlib/intern/string_utf8.c
@@ -290,7 +290,7 @@ size_t BLI_strncpy_utf8_rlen(char *__restrict dst, const char *__restrict src, s
#undef BLI_STR_UTF8_CPY
/* --------------------------------------------------------------------------*/
-/* wchar_t / utf8 functions */
+/* wchar_t / utf8 functions */
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst,
const wchar_t *__restrict src,
@@ -401,7 +401,7 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w,
#endif
}
-/* end wchar_t / utf8 functions */
+/* end wchar_t / utf8 functions */
/* --------------------------------------------------------------------------*/
/* count columns that character/string occupies, based on wcwidth.c */
diff --git a/source/blender/blenlib/intern/string_utils.c b/source/blender/blenlib/intern/string_utils.c
index c847f7e1921..6a2ed8fac2c 100644
--- a/source/blender/blenlib/intern/string_utils.c
+++ b/source/blender/blenlib/intern/string_utils.c
@@ -194,7 +194,7 @@ void BLI_string_flip_side_name(char *r_name,
BLI_strncpy(prefix, r_name, name_len);
- /* first case; separator . - _ with extensions r R l L */
+ /* first case; separator . - _ with extensions r R l L. */
if ((len > 1) && is_char_sep(r_name[len - 2])) {
is_set = true;
switch (r_name[len - 1]) {
diff --git a/source/blender/blenlib/intern/system_win32.c b/source/blender/blenlib/intern/system_win32.c
index 7572936592e..f65234b656b 100644
--- a/source/blender/blenlib/intern/system_win32.c
+++ b/source/blender/blenlib/intern/system_win32.c
@@ -309,7 +309,7 @@ static bool BLI_windows_system_backtrace_stack(FILE *fp)
/* If we are handling an exception use the context record from that. */
if (current_exception && current_exception->ExceptionRecord->ExceptionAddress) {
/* The back trace code will write to the context record, to protect the original record from
- * modifications give the backtrace a copy to work on. */
+ * modifications give the backtrace a copy to work on. */
CONTEXT TempContext = *current_exception->ContextRecord;
return BLI_windows_system_backtrace_run_trace(fp, GetCurrentThread(), &TempContext);
}
diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c
index d40f665ba0d..beeae175869 100644
--- a/source/blender/blenlib/intern/winstuff.c
+++ b/source/blender/blenlib/intern/winstuff.c
@@ -45,7 +45,7 @@ int BLI_windows_get_executable_dir(char *str)
{
char dir[FILE_MAXDIR];
int a;
- /*change to utf support*/
+ /* Change to utf support. */
GetModuleFileName(NULL, str, FILE_MAX);
BLI_split_dir_part(str, dir, sizeof(dir)); /* shouldn't be relative */
a = strlen(dir);
diff --git a/source/blender/blenlib/tests/BLI_kdopbvh_test.cc b/source/blender/blenlib/tests/BLI_kdopbvh_test.cc
index f921c3ae2a4..04e4c3a1625 100644
--- a/source/blender/blenlib/tests/BLI_kdopbvh_test.cc
+++ b/source/blender/blenlib/tests/BLI_kdopbvh_test.cc
@@ -2,7 +2,7 @@
#include "testing/testing.h"
-/* TODO: ray intersection, overlap ... etc.*/
+/* TODO: ray intersection, overlap ... etc. */
#include "MEM_guardedalloc.h"
diff --git a/source/blender/blenlib/tests/BLI_listbase_test.cc b/source/blender/blenlib/tests/BLI_listbase_test.cc
index ff85cf79e87..0ba08a0cd48 100644
--- a/source/blender/blenlib/tests/BLI_listbase_test.cc
+++ b/source/blender/blenlib/tests/BLI_listbase_test.cc
@@ -192,7 +192,7 @@ TEST(listbase, Sort)
EXPECT_TRUE(listbase_is_valid(&words_lb));
}
- /* sort single single */
+ /* Sort single list. */
{
LinkData link;
link.data = words;
diff --git a/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc b/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc
index 769cadd2f47..1a9ffbd3403 100644
--- a/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc
+++ b/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc
@@ -174,6 +174,76 @@ TEST(mesh_intersect, Mesh)
EXPECT_TRUE(f->is_tri());
}
+TEST(mesh_intersect, TriangulateTri)
+{
+ const char *spec = R"(3 1
+ 0 0 0
+ 1 0 0
+ 1/2 1 0
+ 0 1 2
+ )";
+
+ IMeshBuilder mb(spec);
+ IMesh im_tri = triangulate_polymesh(mb.imesh, &mb.arena);
+ EXPECT_EQ(im_tri.faces().size(), 1);
+}
+
+TEST(mesh_intersect, TriangulateQuad)
+{
+ const char *spec = R"(4 1
+ 0 0 0
+ 1 0 0
+ 1 1 0
+ 0 1 0
+ 0 1 2 3
+ )";
+
+ IMeshBuilder mb(spec);
+ IMesh im_tri = triangulate_polymesh(mb.imesh, &mb.arena);
+ EXPECT_EQ(im_tri.faces().size(), 2);
+}
+
+TEST(mesh_intersect, TriangulatePentagon)
+{
+ const char *spec = R"(5 1
+ 0 0 0
+ 1 0 0
+ 1 1 0
+ 1/2 2 0
+ 0 1 0
+ 0 1 2 3 4
+ )";
+
+ IMeshBuilder mb(spec);
+ IMesh im_tri = triangulate_polymesh(mb.imesh, &mb.arena);
+ EXPECT_EQ(im_tri.faces().size(), 3);
+ if (DO_OBJ) {
+ write_obj_mesh(im_tri, "pentagon");
+ }
+}
+
+TEST(mesh_intersect, TriangulateTwoFaces)
+{
+ const char *spec = R"(7 2
+ 461/250 -343/125 103/1000
+ -3/40 -453/200 -97/500
+ 237/100 -321/200 -727/500
+ 451/1000 -563/500 -1751/1000
+ 12/125 -2297/1000 -181/1000
+ 12/125 -411/200 -493/1000
+ 1959/1000 -2297/1000 -493/1000
+ 1 3 2 0 6 5 4
+ 6 0 1 4
+ )";
+
+ IMeshBuilder mb(spec);
+ IMesh im_tri = triangulate_polymesh(mb.imesh, &mb.arena);
+ EXPECT_EQ(im_tri.faces().size(), 7);
+ if (DO_OBJ) {
+ write_obj_mesh(im_tri, "twofaces");
+ }
+}
+
TEST(mesh_intersect, OneTri)
{
const char *spec = R"(3 1
@@ -389,7 +459,7 @@ TEST(mesh_intersect, TwoTris)
{4, 13, 6, 2}, /* 11: non-parallel planes, not intersecting, all one side. */
{0, 14, 6, 2}, /* 12: non-paralel planes, not intersecting, alternate sides. */
/* Following are all coplanar cases. */
- {15, 16, 6, 8}, /* 13: T16 inside T15. Note: dup'd tri is expected. */
+ {15, 16, 6, 8}, /* 13: T16 inside T15. Note: dup'd tri is expected. */
{15, 17, 8, 8}, /* 14: T17 intersects one edge of T15 at (1,1,0)(3,3,0). */
{15, 18, 10, 12}, /* 15: T18 intersects T15 at (1,1,0)(3,3,0)(3,15/4,1/2)(0,3,2). */
{15, 19, 8, 10}, /* 16: T19 intersects T15 at (3,3,0)(0,3,2). */
diff --git a/source/blender/blenlib/tests/BLI_string_test.cc b/source/blender/blenlib/tests/BLI_string_test.cc
index 0b68ee8b93c..ccd2d01be98 100644
--- a/source/blender/blenlib/tests/BLI_string_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_test.cc
@@ -420,6 +420,101 @@ TEST(string, StrFormatByteUnits)
EXPECT_STREQ("-8191.8472 PiB", size_str);
}
+/* BLI_str_format_attribute_domain_size */
+TEST(string, StrFormatAttributeDomainSize)
+{
+ char size_str[7];
+ int size;
+
+ BLI_str_format_attribute_domain_size(size_str, size = 0);
+ EXPECT_STREQ("0", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 1);
+ EXPECT_STREQ("1", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 10);
+ EXPECT_STREQ("10", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 15);
+ EXPECT_STREQ("15", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 100);
+ EXPECT_STREQ("100", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 155);
+ EXPECT_STREQ("155", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 1000);
+ EXPECT_STREQ("1.0K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 1555);
+ EXPECT_STREQ("1.6K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 10000);
+ EXPECT_STREQ("10.0K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 15555);
+ EXPECT_STREQ("15.6K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 100000);
+ EXPECT_STREQ("100K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 100000);
+ EXPECT_STREQ("100K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 155555);
+ EXPECT_STREQ("156K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 1000000);
+ EXPECT_STREQ("1.0M", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 1555555);
+ EXPECT_STREQ("1.6M", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 10000000);
+ EXPECT_STREQ("10.0M", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 15555555);
+ EXPECT_STREQ("15.6M", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 100000000);
+ EXPECT_STREQ("100M", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 155555555);
+ EXPECT_STREQ("156M", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = 1000000000);
+ EXPECT_STREQ("1.0B", size_str);
+
+ /* Largest possible value. */
+ BLI_str_format_attribute_domain_size(size_str, size = INT32_MAX);
+ EXPECT_STREQ("2.1B", size_str);
+
+ BLI_str_format_attribute_domain_size(size_str, size = -0);
+ EXPECT_STREQ("0", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -1);
+ EXPECT_STREQ("-1", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -10);
+ EXPECT_STREQ("-10", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -15);
+ EXPECT_STREQ("-15", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -100);
+ EXPECT_STREQ("-100", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -155);
+ EXPECT_STREQ("-155", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -1000);
+ EXPECT_STREQ("-1.0K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -1555);
+ EXPECT_STREQ("-1.6K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -10000);
+ EXPECT_STREQ("-10.0K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -15555);
+ EXPECT_STREQ("-15.6K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -100000);
+ EXPECT_STREQ("-100K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -155555);
+ EXPECT_STREQ("-156K", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -1000000);
+ EXPECT_STREQ("-1.0M", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -1555555);
+ EXPECT_STREQ("-1.6M", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -10000000);
+ EXPECT_STREQ("-10.0M", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -15555555);
+ EXPECT_STREQ("-15.6M", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -100000000);
+ EXPECT_STREQ("-100M", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -155555555);
+ EXPECT_STREQ("-156M", size_str);
+ BLI_str_format_attribute_domain_size(size_str, size = -1000000000);
+ EXPECT_STREQ("-1.0B", size_str);
+
+ /* Smallest possible value. */
+ BLI_str_format_attribute_domain_size(size_str, size = -INT32_MAX);
+ EXPECT_STREQ("-2.1B", size_str);
+}
+
struct WordInfo {
WordInfo() = default;
WordInfo(int start, int end) : start(start), end(end)
diff --git a/source/blender/blenlib/tests/BLI_string_utf8_test.cc b/source/blender/blenlib/tests/BLI_string_utf8_test.cc
index 2796cbbfbda..9ddc372e6d1 100644
--- a/source/blender/blenlib/tests/BLI_string_utf8_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_utf8_test.cc
@@ -92,12 +92,12 @@ static const char *utf8_invalid_tests[][3] = {
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\" |",
- "3.1.9 \"\" |", "\x40"},
+ "3.1.9 \"\" |", "\x40"}, /* NOLINT: modernize-raw-string-literal. */
/* 3.2 Lonely start characters
* 3.2.1 All 32 first bytes of 2-byte sequences (0xc0-0xdf), each followed by a space character: */
{"3.2.1 \"\xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce \xcf "
"\xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd7 \xd8 \xd9 \xda \xdb \xdc \xdd \xde \xdf \" |",
- "3.2.1 \" \" |", "\x20"},
+ "3.2.1 \" \" |", "\x20"}, /* NOLINT: modernize-raw-string-literal. */
/* 3.2.2 All 16 first bytes of 3-byte sequences (0xe0-0xef), each followed by a space character: */
{"3.2.2 \"\xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee \xef \" |",
"3.2.2 \" \" |", "\x10"},
diff --git a/source/blender/blenloader/BLO_read_write.h b/source/blender/blenloader/BLO_read_write.h
index ea0532d884b..86c7c367816 100644
--- a/source/blender/blenloader/BLO_read_write.h
+++ b/source/blender/blenloader/BLO_read_write.h
@@ -54,6 +54,7 @@ typedef struct BlendExpander BlendExpander;
typedef struct BlendLibReader BlendLibReader;
typedef struct BlendWriter BlendWriter;
+struct BlendFileReadReport;
struct Main;
struct ReportList;
@@ -216,7 +217,7 @@ bool BLO_read_requires_endian_switch(BlendDataReader *reader);
bool BLO_read_data_is_undo(BlendDataReader *reader);
void BLO_read_data_globmap_add(BlendDataReader *reader, void *oldaddr, void *newaddr);
void BLO_read_glob_list(BlendDataReader *reader, struct ListBase *list);
-struct ReportList *BLO_read_data_reports(BlendDataReader *reader);
+struct BlendFileReadReport *BLO_read_data_reports(BlendDataReader *reader);
/* Blend Read Lib API
* ===================
@@ -233,7 +234,7 @@ ID *BLO_read_get_new_id_address(BlendLibReader *reader, struct Library *lib, str
/* Misc. */
bool BLO_read_lib_is_undo(BlendLibReader *reader);
struct Main *BLO_read_lib_get_main(BlendLibReader *reader);
-struct ReportList *BLO_read_lib_reports(BlendLibReader *reader);
+struct BlendFileReadReport *BLO_read_lib_reports(BlendLibReader *reader);
/* Blend Expand API
* ===================
@@ -250,8 +251,10 @@ void BLO_expand_id(BlendExpander *expander, struct ID *id);
* ===================
*/
-void BLO_reportf_wrap(struct ReportList *reports, ReportType type, const char *format, ...)
- ATTR_PRINTF_FORMAT(3, 4);
+void BLO_reportf_wrap(struct BlendFileReadReport *reports,
+ ReportType type,
+ const char *format,
+ ...) ATTR_PRINTF_FORMAT(3, 4);
#ifdef __cplusplus
}
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 89db216aada..52ef577fceb 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -82,13 +82,42 @@ typedef struct BlendFileData {
} BlendFileData;
struct BlendFileReadParams {
- uint skip_flags : 3; /* eBLOReadSkip */
+ uint skip_flags : 3; /* #eBLOReadSkip */
uint is_startup : 1;
/** Whether we are reading the memfile for an undo or a redo. */
- int undo_direction; /* eUndoStepDir */
+ int undo_direction; /* #eUndoStepDir */
};
+typedef struct BlendFileReadReport {
+ /* General reports handling. */
+ struct ReportList *reports;
+
+ /* Timing information. */
+ struct {
+ double whole;
+ double libraries;
+ double lib_overrides;
+ double lib_overrides_resync;
+ double lib_overrides_recursive_resync;
+ } duration;
+
+ /* Count information. */
+ struct {
+ /* Some numbers of IDs that ended up in a specific state, or required some specific process
+ * during this file read. */
+ int missing_libraries;
+ int missing_linked_id;
+ /* Number of root override IDs that were resynced. */
+ int resynced_lib_overrides;
+ } count;
+
+ /* Number of libraries which had overrides that needed to be resynced, and a single linked list
+ * of those. */
+ int resynced_lib_overrides_libraries_count;
+ struct LinkNode *resynced_lib_overrides_libraries;
+} BlendFileReadReport;
+
/* skip reading some data-block types (may want to skip screen data too). */
typedef enum eBLOReadSkip {
BLO_READ_SKIP_NONE = 0,
@@ -101,7 +130,7 @@ typedef enum eBLOReadSkip {
BlendFileData *BLO_read_from_file(const char *filepath,
eBLOReadSkip skip_flags,
- struct ReportList *reports);
+ struct BlendFileReadReport *reports);
BlendFileData *BLO_read_from_memory(const void *mem,
int memsize,
eBLOReadSkip skip_flags,
@@ -125,8 +154,10 @@ struct BLODataBlockInfo {
struct AssetMetaData *asset_data;
};
-BlendHandle *BLO_blendhandle_from_file(const char *filepath, struct ReportList *reports);
-BlendHandle *BLO_blendhandle_from_memory(const void *mem, int memsize);
+BlendHandle *BLO_blendhandle_from_file(const char *filepath, struct BlendFileReadReport *reports);
+BlendHandle *BLO_blendhandle_from_memory(const void *mem,
+ int memsize,
+ struct BlendFileReadReport *reports);
struct LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh,
int ofblocktype,
@@ -231,6 +262,7 @@ typedef struct TempLibraryContext {
/** Temporary main used to load data into (currently initialized from `real_main`). */
struct Main *bmain_base;
struct BlendHandle *blendhandle;
+ struct BlendFileReadReport bf_reports;
struct LibraryLink_Params liblink_params;
struct Library *lib;
diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c
index f3fc1453461..5b093223fda 100644
--- a/source/blender/blenloader/intern/blend_validate.c
+++ b/source/blender/blenloader/intern/blend_validate.c
@@ -83,7 +83,8 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
}
BKE_library_filepath_set(bmain, curlib, curlib->filepath);
- BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath_abs, reports);
+ BlendFileReadReport bf_reports = {.reports = reports};
+ BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath_abs, &bf_reports);
if (bh == NULL) {
BKE_reportf(reports,
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 19033ba9bf1..44a26b9bf85 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -68,7 +68,7 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp);
* \param reports: Report errors in opening the file (can be NULL).
* \return A handle on success, or NULL on failure.
*/
-BlendHandle *BLO_blendhandle_from_file(const char *filepath, ReportList *reports)
+BlendHandle *BLO_blendhandle_from_file(const char *filepath, BlendFileReadReport *reports)
{
BlendHandle *bh;
@@ -84,11 +84,13 @@ BlendHandle *BLO_blendhandle_from_file(const char *filepath, ReportList *reports
* \param memsize: The size of the data.
* \return A handle on success, or NULL on failure.
*/
-BlendHandle *BLO_blendhandle_from_memory(const void *mem, int memsize)
+BlendHandle *BLO_blendhandle_from_memory(const void *mem,
+ int memsize,
+ BlendFileReadReport *reports)
{
BlendHandle *bh;
- bh = (BlendHandle *)blo_filedata_from_memory(mem, memsize, NULL);
+ bh = (BlendHandle *)blo_filedata_from_memory(mem, memsize, reports);
return bh;
}
@@ -366,14 +368,13 @@ void BLO_blendhandle_close(BlendHandle *bh)
*/
BlendFileData *BLO_read_from_file(const char *filepath,
eBLOReadSkip skip_flags,
- ReportList *reports)
+ BlendFileReadReport *reports)
{
BlendFileData *bfd = NULL;
FileData *fd;
fd = blo_filedata_from_file(filepath, reports);
if (fd) {
- fd->reports = reports;
fd->skip_flags = skip_flags;
bfd = blo_read_file_internal(fd, filepath);
blo_filedata_free(fd);
@@ -398,10 +399,10 @@ BlendFileData *BLO_read_from_memory(const void *mem,
{
BlendFileData *bfd = NULL;
FileData *fd;
+ BlendFileReadReport bf_reports = {.reports = reports};
- fd = blo_filedata_from_memory(mem, memsize, reports);
+ fd = blo_filedata_from_memory(mem, memsize, &bf_reports);
if (fd) {
- fd->reports = reports;
fd->skip_flags = skip_flags;
bfd = blo_read_file_internal(fd, "");
blo_filedata_free(fd);
@@ -427,10 +428,10 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
BlendFileData *bfd = NULL;
FileData *fd;
ListBase old_mainlist;
+ BlendFileReadReport bf_reports = {.reports = reports};
- fd = blo_filedata_from_memfile(memfile, params, reports);
+ fd = blo_filedata_from_memfile(memfile, params, &bf_reports);
if (fd) {
- fd->reports = reports;
fd->skip_flags = params->skip_flags;
BLI_strncpy(fd->relabase, filename, sizeof(fd->relabase));
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index dab630d451c..5b668bf12eb 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -40,6 +40,8 @@
# include <io.h> /* for open close read */
#endif
+#include "CLG_log.h"
+
/* allow readfile to use deprecated functionality */
#define DNA_DEPRECATED_ALLOW
@@ -72,6 +74,8 @@
#include "BLI_mmap.h"
#include "BLI_threads.h"
+#include "PIL_time.h"
+
#include "BLT_translation.h"
#include "BKE_anim_data.h"
@@ -186,14 +190,8 @@
/* Use GHash for restoring pointers by name */
#define USE_GHASH_RESTORE_POINTER
-/* Define this to have verbose debug prints. */
-//#define USE_DEBUG_PRINT
-
-#ifdef USE_DEBUG_PRINT
-# define DEBUG_PRINTF(...) printf(__VA_ARGS__)
-#else
-# define DEBUG_PRINTF(...)
-#endif
+static CLG_LogRef LOG = {"blo.readfile"};
+static CLG_LogRef LOG_UNDO = {"blo.readfile.undo"};
/* local prototypes */
static void read_libraries(FileData *basefd, ListBase *mainlist);
@@ -227,7 +225,7 @@ typedef struct BHeadN {
* bit kludge but better than doubling up on prints,
* we could alternatively have a versions of a report function which forces printing - campbell
*/
-void BLO_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...)
+void BLO_reportf_wrap(BlendFileReadReport *reports, ReportType type, const char *format, ...)
{
char fixed_buf[1024]; /* should be long enough */
@@ -239,7 +237,7 @@ void BLO_reportf_wrap(ReportList *reports, ReportType type, const char *format,
fixed_buf[sizeof(fixed_buf) - 1] = '\0';
- BKE_report(reports, type, fixed_buf);
+ BKE_report(reports->reports, type, fixed_buf);
if (G.background == 0) {
printf("%s: %s\n", BKE_report_type_str(type), fixed_buf);
@@ -488,7 +486,7 @@ static void split_libdata(ListBase *lb_src, Main **lib_main_array, const uint li
BLI_addtail(lb_dst, id);
}
else {
- printf("%s: invalid library for '%s'\n", __func__, id->name);
+ CLOG_ERROR(&LOG, "Invalid library for '%s'", id->name);
BLI_assert(0);
}
}
@@ -635,7 +633,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
if (BLI_path_cmp(name1, libname) == 0) {
if (G.debug & G_DEBUG) {
- printf("blo_find_main: found library %s\n", libname);
+ CLOG_INFO(&LOG, 3, "Found library %s", libname);
}
return m;
}
@@ -662,7 +660,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
read_file_version(fd, m);
if (G.debug & G_DEBUG) {
- printf("blo_find_main: added new lib %s\n", filepath);
+ CLOG_INFO(&LOG, 3, "Added new lib %s", filepath);
}
return m;
}
@@ -731,7 +729,7 @@ static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, bool do_endian_swap)
BLI_endian_switch_uint64(&bhead8->old);
}
- /* this patch is to avoid a long long being read from not-eight aligned positions
+ /* this patch is to avoid `intptr_t` being read from not-eight aligned positions
* is necessary on any modern 64bit architecture) */
memcpy(&old, &bhead8->old, 8);
bhead4->old = (int)(old >> 3);
@@ -1296,7 +1294,7 @@ static ssize_t fd_read_from_memfile(FileData *filedata,
/* debug, should never happen */
if (chunk == NULL) {
- printf("illegal read, chunk zero\n");
+ CLOG_ERROR(&LOG, "Illegal read, got a NULL chunk");
return 0;
}
@@ -1331,8 +1329,10 @@ static ssize_t fd_read_from_memfile(FileData *filedata,
return 0;
}
-static FileData *filedata_new(void)
+static FileData *filedata_new(BlendFileReadReport *reports)
{
+ BLI_assert(reports != NULL);
+
FileData *fd = MEM_callocN(sizeof(FileData), "FileData");
fd->filedes = -1;
@@ -1344,6 +1344,8 @@ static FileData *filedata_new(void)
fd->globmap = oldnewmap_new();
fd->libmap = oldnewmap_new();
+ fd->reports = reports;
+
return fd;
}
@@ -1371,7 +1373,7 @@ static FileData *blo_decode_and_check(FileData *fd, ReportList *reports)
}
static FileData *blo_filedata_from_file_descriptor(const char *filepath,
- ReportList *reports,
+ BlendFileReadReport *reports,
int file)
{
FileDataReadFn *read_fn = NULL;
@@ -1386,7 +1388,7 @@ static FileData *blo_filedata_from_file_descriptor(const char *filepath,
/* Regular file. */
errno = 0;
if (read(file, header, sizeof(header)) != sizeof(header)) {
- BKE_reportf(reports,
+ BKE_reportf(reports->reports,
RPT_WARNING,
"Unable to read '%s': %s",
filepath,
@@ -1416,7 +1418,7 @@ static FileData *blo_filedata_from_file_descriptor(const char *filepath,
(header[0] == 0x1f && header[1] == 0x8b)) {
gzfile = BLI_gzopen(filepath, "rb");
if (gzfile == (gzFile)Z_NULL) {
- BKE_reportf(reports,
+ BKE_reportf(reports->reports,
RPT_WARNING,
"Unable to open '%s': %s",
filepath,
@@ -1431,11 +1433,11 @@ static FileData *blo_filedata_from_file_descriptor(const char *filepath,
}
if (read_fn == NULL) {
- BKE_reportf(reports, RPT_WARNING, "Unrecognized file format '%s'", filepath);
+ BKE_reportf(reports->reports, RPT_WARNING, "Unrecognized file format '%s'", filepath);
return NULL;
}
- FileData *fd = filedata_new();
+ FileData *fd = filedata_new(reports);
fd->filedes = file;
fd->gzfiledes = gzfile;
@@ -1448,12 +1450,12 @@ static FileData *blo_filedata_from_file_descriptor(const char *filepath,
return fd;
}
-static FileData *blo_filedata_from_file_open(const char *filepath, ReportList *reports)
+static FileData *blo_filedata_from_file_open(const char *filepath, BlendFileReadReport *reports)
{
errno = 0;
const int file = BLI_open(filepath, O_BINARY | O_RDONLY, 0);
if (file == -1) {
- BKE_reportf(reports,
+ BKE_reportf(reports->reports,
RPT_WARNING,
"Unable to open '%s': %s",
filepath,
@@ -1469,14 +1471,14 @@ static FileData *blo_filedata_from_file_open(const char *filepath, ReportList *r
/* cannot be called with relative paths anymore! */
/* on each new library added, it now checks for the current FileData and expands relativeness */
-FileData *blo_filedata_from_file(const char *filepath, ReportList *reports)
+FileData *blo_filedata_from_file(const char *filepath, BlendFileReadReport *reports)
{
FileData *fd = blo_filedata_from_file_open(filepath, reports);
if (fd != NULL) {
/* needed for library_append and read_libraries */
BLI_strncpy(fd->relabase, filepath, sizeof(fd->relabase));
- return blo_decode_and_check(fd, reports);
+ return blo_decode_and_check(fd, reports->reports);
}
return NULL;
}
@@ -1487,7 +1489,7 @@ FileData *blo_filedata_from_file(const char *filepath, ReportList *reports)
*/
static FileData *blo_filedata_from_file_minimal(const char *filepath)
{
- FileData *fd = blo_filedata_from_file_open(filepath, NULL);
+ FileData *fd = blo_filedata_from_file_open(filepath, &(BlendFileReadReport){.reports = NULL});
if (fd != NULL) {
decode_blender_header(fd);
if (fd->flags & FD_FLAGS_FILE_OK) {
@@ -1515,7 +1517,7 @@ static ssize_t fd_read_gzip_from_memory(FileData *filedata,
return 0;
}
if (err != Z_OK) {
- printf("fd_read_gzip_from_memory: zlib error\n");
+ CLOG_ERROR(&LOG, "ZLib error (code %d)", err);
return 0;
}
@@ -1542,14 +1544,15 @@ static int fd_read_gzip_from_memory_init(FileData *fd)
return 1;
}
-FileData *blo_filedata_from_memory(const void *mem, int memsize, ReportList *reports)
+FileData *blo_filedata_from_memory(const void *mem, int memsize, BlendFileReadReport *reports)
{
if (!mem || memsize < SIZEOFBLENDERHEADER) {
- BKE_report(reports, RPT_WARNING, (mem) ? TIP_("Unable to read") : TIP_("Unable to open"));
+ BKE_report(
+ reports->reports, RPT_WARNING, (mem) ? TIP_("Unable to read") : TIP_("Unable to open"));
return NULL;
}
- FileData *fd = filedata_new();
+ FileData *fd = filedata_new(reports);
const char *cp = mem;
fd->buffer = mem;
@@ -1568,26 +1571,26 @@ FileData *blo_filedata_from_memory(const void *mem, int memsize, ReportList *rep
fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
- return blo_decode_and_check(fd, reports);
+ return blo_decode_and_check(fd, reports->reports);
}
FileData *blo_filedata_from_memfile(MemFile *memfile,
const struct BlendFileReadParams *params,
- ReportList *reports)
+ BlendFileReadReport *reports)
{
if (!memfile) {
- BKE_report(reports, RPT_WARNING, "Unable to open blend <memory>");
+ BKE_report(reports->reports, RPT_WARNING, "Unable to open blend <memory>");
return NULL;
}
- FileData *fd = filedata_new();
+ FileData *fd = filedata_new(reports);
fd->memfile = memfile;
fd->undo_direction = params->undo_direction;
fd->read = fd_read_from_memfile;
fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
- return blo_decode_and_check(fd, reports);
+ return blo_decode_and_check(fd, reports->reports);
}
void blo_filedata_free(FileData *fd)
@@ -1602,8 +1605,9 @@ void blo_filedata_free(FileData *fd)
}
if (fd->strm.next_in) {
- if (inflateEnd(&fd->strm) != Z_OK) {
- printf("close gzip stream error\n");
+ int err = inflateEnd(&fd->strm);
+ if (err != Z_OK) {
+ CLOG_ERROR(&LOG, "Close gzip stream error (code %d)", err);
}
}
@@ -2470,7 +2474,7 @@ static void direct_link_id_common(
BKE_asset_metadata_read(reader, id->asset_data);
}
- /*link direct data of ID properties*/
+ /* Link direct data of ID properties. */
if (id->properties) {
BLO_read_data_address(reader, &id->properties);
/* this case means the data was written incorrectly, it should not happen */
@@ -2586,7 +2590,7 @@ static void lib_link_scenes_check_set(Main *bmain)
if (sce->flag & SCE_READFILE_LIBLINK_NEED_SETSCENE_CHECK) {
sce->flag &= ~SCE_READFILE_LIBLINK_NEED_SETSCENE_CHECK;
if (!scene_validate_setscene__liblink(sce, totscene)) {
- printf("Found cyclic background scene when linking %s\n", sce->id.name + 2);
+ CLOG_WARN(&LOG, "Found cyclic background scene when linking %s", sce->id.name + 2);
}
}
}
@@ -2839,7 +2843,7 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
}
/* TODO: restore path pointers: T40046
- * (complicated because this contains data pointers too, not just ID)*/
+ * (complicated because this contains data pointers too, not just ID). */
MEM_SAFE_FREE(sbuts->path);
}
else if (sl->spacetype == SPACE_FILE) {
@@ -3420,15 +3424,17 @@ static bool read_libblock_undo_restore_library(FileData *fd, Main *main, const I
* That means we have to carefully check whether current lib or
* libdata already exits in old main, if it does we merely copy it over into new main area,
* otherwise we have to do a full read of that bhead... */
- DEBUG_PRINTF("UNDO: restore library %s\n", id->name);
+ CLOG_INFO(&LOG_UNDO, 2, "UNDO: restore library %s", id->name);
Main *libmain = fd->old_mainlist->first;
/* Skip oldmain itself... */
for (libmain = libmain->next; libmain; libmain = libmain->next) {
- DEBUG_PRINTF(" compare with %s -> ", libmain->curlib ? libmain->curlib->id.name : "<NULL>");
if (libmain->curlib && STREQ(id->name, libmain->curlib->id.name)) {
Main *oldmain = fd->old_mainlist->first;
- DEBUG_PRINTF("match!\n");
+ CLOG_INFO(&LOG_UNDO,
+ 2,
+ " compare with %s -> match",
+ libmain->curlib ? libmain->curlib->id.name : "<NULL>");
/* In case of a library, we need to re-add its main to fd->mainlist,
* because if we have later a missing ID_LINK_PLACEHOLDER,
* we need to get the correct lib it is linked to!
@@ -3440,7 +3446,10 @@ static bool read_libblock_undo_restore_library(FileData *fd, Main *main, const I
BLI_addtail(&main->libraries, libmain->curlib);
return true;
}
- DEBUG_PRINTF("no match\n");
+ CLOG_INFO(&LOG_UNDO,
+ 2,
+ " compare with %s -> NO match",
+ libmain->curlib ? libmain->curlib->id.name : "<NULL>");
}
return false;
@@ -3449,14 +3458,15 @@ static bool read_libblock_undo_restore_library(FileData *fd, Main *main, const I
/* For undo, restore existing linked datablock from the old main. */
static bool read_libblock_undo_restore_linked(FileData *fd, Main *main, const ID *id, BHead *bhead)
{
- DEBUG_PRINTF("UNDO: restore linked datablock %s\n", id->name);
- DEBUG_PRINTF(" from %s (%s): ",
- main->curlib ? main->curlib->id.name : "<NULL>",
- main->curlib ? main->curlib->filepath : "<NULL>");
+ CLOG_INFO(&LOG_UNDO, 2, "UNDO: restore linked datablock %s", id->name);
ID *id_old = BKE_libblock_find_name(main, GS(id->name), id->name + 2);
if (id_old != NULL) {
- DEBUG_PRINTF(" found!\n");
+ CLOG_INFO(&LOG_UNDO,
+ 2,
+ " from %s (%s): found",
+ main->curlib ? main->curlib->id.name : "<NULL>",
+ main->curlib ? main->curlib->filepath : "<NULL>");
/* Even though we found our linked ID, there is no guarantee its address
* is still the same. */
if (id_old != bhead->old) {
@@ -3468,7 +3478,11 @@ static bool read_libblock_undo_restore_linked(FileData *fd, Main *main, const ID
return true;
}
- DEBUG_PRINTF(" not found\n");
+ CLOG_INFO(&LOG_UNDO,
+ 2,
+ " from %s (%s): NOT found",
+ main->curlib ? main->curlib->id.name : "<NULL>",
+ main->curlib ? main->curlib->filepath : "<NULL>");
return false;
}
@@ -3577,8 +3591,6 @@ static bool read_libblock_undo_restore(
}
/* Restore local datablocks. */
- DEBUG_PRINTF("UNDO: read %s (uuid %u) -> ", id->name, id->session_uuid);
-
ID *id_old = NULL;
const bool do_partial_undo = (fd->skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN) == 0;
if (do_partial_undo && (bhead->code != ID_LINK_PLACEHOLDER)) {
@@ -3593,7 +3605,11 @@ static bool read_libblock_undo_restore(
if (id_old != NULL && read_libblock_is_identical(fd, bhead)) {
/* Local datablock was unchanged, restore from the old main. */
- DEBUG_PRINTF("keep identical datablock\n");
+ CLOG_INFO(&LOG_UNDO,
+ 2,
+ "UNDO: read %s (uuid %u) -> keep identical datablock",
+ id->name,
+ id->session_uuid);
/* Do not add LIB_TAG_NEW here, this should not be needed/used in undo case anyway (as
* this is only for do_version-like code), but for sake of consistency, and also because
@@ -3613,13 +3629,18 @@ static bool read_libblock_undo_restore(
}
if (id_old != NULL) {
/* Local datablock was changed. Restore at the address of the old datablock. */
- DEBUG_PRINTF("read to old existing address\n");
+ CLOG_INFO(&LOG_UNDO,
+ 2,
+ "UNDO: read %s (uuid %u) -> read to old existing address",
+ id->name,
+ id->session_uuid);
*r_id_old = id_old;
return false;
}
/* Local datablock does not exist in the undo step, so read from scratch. */
- DEBUG_PRINTF("read at new address\n");
+ CLOG_INFO(
+ &LOG_UNDO, 2, "UNDO: read %s (uuid %u) -> read at new address", id->name, id->session_uuid);
return false;
}
@@ -3664,7 +3685,7 @@ static BHead *read_libblock(FileData *fd,
ListBase *lb = which_libbase(main, idcode);
if (lb == NULL) {
/* Unknown ID type. */
- printf("%s: unknown id code '%c%c'\n", __func__, (idcode & 0xff), (idcode >> 8));
+ CLOG_WARN(&LOG, "Unknown id code '%c%c'", (idcode & 0xff), (idcode >> 8));
MEM_freeN(id);
if (r_id) {
*r_id = NULL;
@@ -3856,12 +3877,14 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
BLI_strncpy(build_commit_datetime, "unknown", sizeof(build_commit_datetime));
}
- printf("read file %s\n Version %d sub %d date %s hash %s\n",
- fd->relabase,
- main->versionfile,
- main->subversionfile,
- build_commit_datetime,
- main->build_hash);
+ CLOG_INFO(&LOG, 0, "Read file %s", fd->relabase);
+ CLOG_INFO(&LOG,
+ 0,
+ " Version %d sub %d date %s hash %s",
+ main->versionfile,
+ main->subversionfile,
+ build_commit_datetime,
+ main->build_hash);
}
blo_do_versions_pre250(fd, lib, main);
@@ -3883,8 +3906,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
static void do_versions_after_linking(Main *main, ReportList *reports)
{
- // printf("%s for %s (%s), %d.%d\n", __func__, main->curlib ? main->curlib->filepath :
- // main->name, main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile);
+ CLOG_INFO(&LOG,
+ 2,
+ "Processing %s (%s), %d.%d",
+ main->curlib ? main->curlib->filepath : main->name,
+ main->curlib ? "LIB" : "MAIN",
+ main->versionfile,
+ main->subversionfile);
/* Don't allow versioning to create new data-blocks. */
main->is_locked_for_linking = true;
@@ -4105,7 +4133,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
ListBase mainlist = {NULL, NULL};
if (fd->memfile != NULL) {
- DEBUG_PRINTF("\nUNDO: read step\n");
+ CLOG_INFO(&LOG_UNDO, 2, "UNDO: read step");
}
bfd = MEM_callocN(sizeof(BlendFileData), "blendfiledata");
@@ -4206,6 +4234,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
}
if ((fd->skip_flags & BLO_READ_SKIP_DATA) == 0) {
+ fd->reports->duration.libraries = PIL_check_seconds_timer();
read_libraries(fd, &mainlist);
blo_join_main(&mainlist);
@@ -4213,6 +4242,8 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
lib_link_all(fd, bfd->main);
after_liblink_merged_bmain_process(bfd->main);
+ fd->reports->duration.libraries = PIL_check_seconds_timer() - fd->reports->duration.libraries;
+
/* Skip in undo case. */
if (fd->memfile == NULL) {
/* Note that we can't recompute user-counts at this point in undo case, we play too much with
@@ -4228,7 +4259,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
blo_split_main(&mainlist, bfd->main);
LISTBASE_FOREACH (Main *, mainvar, &mainlist) {
BLI_assert(mainvar->versionfile != 0);
- do_versions_after_linking(mainvar, fd->reports);
+ do_versions_after_linking(mainvar, fd->reports->reports);
}
blo_join_main(&mainlist);
@@ -4249,8 +4280,13 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
* we can re-generate overrides from their references. */
if (fd->memfile == NULL) {
/* Do not apply in undo case! */
- BKE_lib_override_library_main_validate(bfd->main, fd->reports);
+ fd->reports->duration.lib_overrides = PIL_check_seconds_timer();
+
+ BKE_lib_override_library_main_validate(bfd->main, fd->reports->reports);
BKE_lib_override_library_main_update(bfd->main);
+
+ fd->reports->duration.lib_overrides = PIL_check_seconds_timer() -
+ fd->reports->duration.lib_overrides;
}
BKE_collections_after_lib_link(bfd->main);
@@ -4908,9 +4944,7 @@ static ID *link_named_part(
}
else {
/* already linked */
- if (G.debug) {
- printf("append: already linked\n");
- }
+ CLOG_WARN(&LOG, "Append: ID '%s' is already linked", id->name);
oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
if (!force_indirect && (id->tag & LIB_TAG_INDIRECT)) {
id->tag &= ~LIB_TAG_INDIRECT;
@@ -5206,7 +5240,7 @@ static void library_link_end(Main *mainl,
* or they will go again through do_versions - bad, very bad! */
split_main_newid(mainvar, main_newid);
- do_versions_after_linking(main_newid, (*fd)->reports);
+ do_versions_after_linking(main_newid, (*fd)->reports->reports);
add_main_to_main(mainvar, main_newid);
}
@@ -5340,7 +5374,7 @@ static void read_library_linked_id(
id->name + 2,
mainvar->curlib->filepath_abs,
library_parent_filepath(mainvar->curlib));
- basefd->library_id_missing_count++;
+ basefd->reports->count.missing_linked_id++;
/* Generate a placeholder for this ID (simplified version of read_libblock actually...). */
if (r_id) {
@@ -5414,7 +5448,7 @@ static void read_library_clear_weak_links(FileData *basefd, ListBase *mainlist,
while (id) {
ID *id_next = id->next;
if ((id->tag & LIB_TAG_ID_LINK_PLACEHOLDER) && (id->flag & LIB_INDIRECT_WEAK_LINK)) {
- /* printf("Dropping weak link to %s\n", id->name); */
+ CLOG_INFO(&LOG, 3, "Dropping weak link to '%s'", id->name);
change_link_placeholder_to_real_ID_pointer(mainlist, basefd, id, NULL);
BLI_freelinkN(lbarray[a], id);
}
@@ -5495,7 +5529,7 @@ static FileData *read_library_file_data(FileData *basefd,
if (fd == NULL) {
BLO_reportf_wrap(
basefd->reports, RPT_INFO, TIP_("Cannot find lib '%s'"), mainptr->curlib->filepath_abs);
- basefd->library_file_missing_count++;
+ basefd->reports->count.missing_libraries++;
}
return fd;
@@ -5524,11 +5558,11 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
for (Main *mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
/* Does this library have any more linked data-blocks we need to read? */
if (has_linked_ids_to_read(mainptr)) {
-#if 0
- printf("Reading linked data-blocks from %s (%s)\n",
- mainptr->curlib->id.name,
- mainptr->curlib->filepath);
-#endif
+ CLOG_INFO(&LOG,
+ 3,
+ "Reading linked data-blocks from %s (%s)",
+ mainptr->curlib->id.name,
+ mainptr->curlib->filepath);
/* Open file if it has not been done yet. */
FileData *fd = read_library_file_data(basefd, mainlist, mainl, mainptr);
@@ -5589,15 +5623,6 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
mainptr->curlib->filedata = NULL;
}
BKE_main_free(main_newid);
-
- if (basefd->library_file_missing_count != 0 || basefd->library_id_missing_count != 0) {
- BKE_reportf(basefd->reports,
- RPT_WARNING,
- "LIB: %d libraries and %d linked data-blocks are missing, please check the "
- "Info and Outliner editors for details",
- basefd->library_file_missing_count,
- basefd->library_id_missing_count);
- }
}
void *BLO_read_get_new_data_address(BlendDataReader *reader, const void *old_address)
@@ -5785,7 +5810,7 @@ void BLO_read_glob_list(BlendDataReader *reader, ListBase *list)
link_glob_list(reader->fd, list);
}
-ReportList *BLO_read_data_reports(BlendDataReader *reader)
+BlendFileReadReport *BLO_read_data_reports(BlendDataReader *reader)
{
return reader->fd->reports;
}
@@ -5800,7 +5825,7 @@ Main *BLO_read_lib_get_main(BlendLibReader *reader)
return reader->main;
}
-ReportList *BLO_read_lib_reports(BlendLibReader *reader)
+BlendFileReadReport *BLO_read_lib_reports(BlendLibReader *reader)
{
return reader->fd->reports;
}
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index d1d4e0b3256..b04043f9641 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -145,11 +145,7 @@ typedef struct FileData {
ListBase *old_mainlist;
struct IDNameLib_Map *old_idmap;
- struct ReportList *reports;
- /* Counters for amount of missing libraries, and missing IDs in libraries.
- * Used to generate a synthetic report in the UI. */
- int library_file_missing_count;
- int library_id_missing_count;
+ struct BlendFileReadReport *reports;
} FileData;
#define SIZEOFBLENDERHEADER 12
@@ -161,11 +157,13 @@ void blo_split_main(ListBase *mainlist, struct Main *main);
BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath);
-FileData *blo_filedata_from_file(const char *filepath, struct ReportList *reports);
-FileData *blo_filedata_from_memory(const void *mem, int memsize, struct ReportList *reports);
+FileData *blo_filedata_from_file(const char *filepath, struct BlendFileReadReport *reports);
+FileData *blo_filedata_from_memory(const void *mem,
+ int memsize,
+ struct BlendFileReadReport *reports);
FileData *blo_filedata_from_memfile(struct MemFile *memfile,
const struct BlendFileReadParams *params,
- struct ReportList *reports);
+ struct BlendFileReadReport *reports);
void blo_clear_proxy_pointers_from_lib(struct Main *oldmain);
void blo_make_packed_pointer_map(FileData *fd, struct Main *oldmain);
diff --git a/source/blender/blenloader/intern/readfile_tempload.c b/source/blender/blenloader/intern/readfile_tempload.c
index 4566e1e9b4d..1b1cbb29ef5 100644
--- a/source/blender/blenloader/intern/readfile_tempload.c
+++ b/source/blender/blenloader/intern/readfile_tempload.c
@@ -36,11 +36,13 @@ TempLibraryContext *BLO_library_temp_load_id(struct Main *real_main,
{
TempLibraryContext *temp_lib_ctx = MEM_callocN(sizeof(*temp_lib_ctx), __func__);
temp_lib_ctx->bmain_base = BKE_main_new();
+ temp_lib_ctx->bf_reports.reports = reports;
/* Copy the file path so any path remapping is performed properly. */
STRNCPY(temp_lib_ctx->bmain_base->name, real_main->name);
- temp_lib_ctx->blendhandle = BLO_blendhandle_from_file(blend_file_path, reports);
+ temp_lib_ctx->blendhandle = BLO_blendhandle_from_file(blend_file_path,
+ &temp_lib_ctx->bf_reports);
BLO_library_link_params_init(
&temp_lib_ctx->liblink_params, temp_lib_ctx->bmain_base, 0, LIB_TAG_TEMP_MAIN);
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 990fc1d65d7..9399af5eb11 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -2052,7 +2052,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- /* replace 'rim material' option for in offset*/
+ /* Replace 'rim material' option for in offset. */
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index fe3d7f8e98f..070dd181509 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -2411,8 +2411,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
/* 'Increment' mode disabled for nodes, use true grid snapping instead */
- if (scene->toolsettings->snap_node_mode == SCE_SNAP_MODE_INCREMENT) {
- scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID;
+ if (scene->toolsettings->snap_node_mode == 0) { /* SCE_SNAP_MODE_INCREMENT */
+ scene->toolsettings->snap_node_mode = 8; /* SCE_SNAP_MODE_GRID */
}
#ifdef WITH_FFMPEG
@@ -2614,9 +2614,9 @@ void do_versions_after_linking_260(Main *bmain)
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;*/
+ /* Rough guess, not nice but we don't have access to UI constants here. */
+ const float offsetx = 42 + 3 * 20 + 20;
+ // const float offsety = 0.0f;
if (create_io_nodes) {
if (ntree->inputs.first) {
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index bf8f7eeca5c..399761ead8d 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -182,7 +182,7 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
workspace = BKE_workspace_add(bmain, screen->id.name + 2);
}
if (workspace == NULL) {
- continue; /* Not much we can do.. */
+ continue; /* Not much we can do. */
}
BKE_workspace_layout_add(bmain, workspace, screen, screen->id.name + 2);
}
@@ -1652,7 +1652,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
* which exact version fully deprecated tessfaces, so think we can keep that one here, no
* harm to be expected anyway for being over-conservative. */
for (Mesh *me = bmain->meshes.first; me != NULL; me = me->id.next) {
- /*check if we need to convert mfaces to mpolys*/
+ /* Check if we need to convert mfaces to mpolys. */
if (me->totface && !me->totpoly) {
/* temporarily switch main so that reading from
* external CustomData works */
@@ -1912,7 +1912,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_END;
if (error & NTREE_DOVERSION_NEED_OUTPUT) {
- BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
+ BKE_report(fd->reports != NULL ? fd->reports->reports : NULL,
+ RPT_ERROR,
+ "Eevee material conversion problem. Error in console");
printf(
"You need to connect Principled and Eevee Specular shader nodes to new material "
"output "
@@ -1920,7 +1922,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) {
- BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
+ BKE_report(fd->reports != NULL ? fd->reports->reports : NULL,
+ RPT_ERROR,
+ "Eevee material conversion problem. Error in console");
printf(
"You need to combine transparency and emission shaders to the converted Principled "
"shader nodes.\n");
@@ -2432,41 +2436,42 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
switch (scene->toolsettings->snap_mode) {
case 0:
- scene->toolsettings->snap_mode = SCE_SNAP_MODE_INCREMENT;
+ scene->toolsettings->snap_mode = (1 << 4); /* SCE_SNAP_MODE_INCREMENT */
break;
case 1:
- scene->toolsettings->snap_mode = SCE_SNAP_MODE_VERTEX;
+ scene->toolsettings->snap_mode = (1 << 0); /* SCE_SNAP_MODE_VERTEX */
break;
case 2:
- scene->toolsettings->snap_mode = SCE_SNAP_MODE_EDGE;
+ scene->toolsettings->snap_mode = (1 << 1); /* SCE_SNAP_MODE_EDGE */
break;
case 3:
- scene->toolsettings->snap_mode = SCE_SNAP_MODE_FACE;
+ scene->toolsettings->snap_mode = (1 << 2); /* SCE_SNAP_MODE_FACE */
break;
case 4:
- scene->toolsettings->snap_mode = SCE_SNAP_MODE_VOLUME;
+ scene->toolsettings->snap_mode = (1 << 3); /* SCE_SNAP_MODE_VOLUME */
break;
}
switch (scene->toolsettings->snap_node_mode) {
case 5:
- scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_X;
+ scene->toolsettings->snap_node_mode = (1 << 5); /* SCE_SNAP_MODE_NODE_X */
break;
case 6:
- scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_Y;
+ scene->toolsettings->snap_node_mode = (1 << 6); /* SCE_SNAP_MODE_NODE_Y */
break;
case 7:
- scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y;
+ scene->toolsettings->snap_node_mode =
+ (1 << 5) | (1 << 6); /* SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y */
break;
case 8:
- scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID;
+ scene->toolsettings->snap_node_mode = (1 << 7); /* SCE_SNAP_MODE_GRID */
break;
}
switch (scene->toolsettings->snap_uv_mode) {
case 0:
- scene->toolsettings->snap_uv_mode = SCE_SNAP_MODE_INCREMENT;
+ scene->toolsettings->snap_uv_mode = (1 << 4); /* SCE_SNAP_MODE_INCREMENT */
break;
case 1:
- scene->toolsettings->snap_uv_mode = SCE_SNAP_MODE_VERTEX;
+ scene->toolsettings->snap_uv_mode = (1 << 0); /* SCE_SNAP_MODE_VERTEX */
break;
}
}
@@ -3543,7 +3548,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- /* Grease pencil cutter/select segment intersection threshold */
+ /* Grease pencil cutter/select segment intersection threshold. */
if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "float", "isect_threshold")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
@@ -3553,7 +3558,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- /* Fix anamorphic bokeh eevee rna limits.*/
+ /* Fix anamorphic bokeh eevee rna limits. */
for (Camera *ca = bmain->cameras.first; ca; ca = ca->id.next) {
if (ca->gpu_dof.ratio < 0.01f) {
ca->gpu_dof.ratio = 0.01f;
@@ -4920,7 +4925,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- /* Corrective smooth modifier scale*/
+ /* Corrective smooth modifier scale. */
if (!DNA_struct_elem_find(fd->filesdna, "CorrectiveSmoothModifierData", "float", "scale")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
@@ -4969,7 +4974,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- /* Surface deform modifier strength*/
+ /* Surface deform modifier strength. */
if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "float", "strength")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 156b1f4198d..09d43676b8f 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -1450,7 +1450,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- /* Replace object hidden filter with inverted object visible filter. */
+ /* Replace object hidden filter with inverted object visible filter. */
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
@@ -2026,7 +2026,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- /* Initialize the spread parameter for area lights*/
+ /* Initialize the spread parameter for area lights. */
if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "area_spread")) {
LISTBASE_FOREACH (Light *, la, &bmain->lights) {
la->area_spread = DEG2RADF(180.0f);
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 0fe1267b871..ecee14d3d58 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -40,7 +40,11 @@
#include "BKE_node.h"
#include "BLO_readfile.h"
+#include "MEM_guardedalloc.h"
#include "readfile.h"
+#include "versioning_common.h"
+
+#include "SEQ_sequencer.h"
#include "MEM_guardedalloc.h"
@@ -122,6 +126,7 @@ void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports))
sort_linked_ids(bmain);
assert_sorted_ids(bmain);
}
+
if (MAIN_VERSION_ATLEAST(bmain, 300, 3)) {
assert_sorted_ids(bmain);
}
@@ -392,6 +397,77 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 300, 5)) {
+ /* Add a dataset sidebar to the spreadsheet editor. */
+ LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ if (sl->spacetype == SPACE_SPREADSHEET) {
+ ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
+ &sl->regionbase;
+ ARegion *spreadsheet_dataset_region = do_versions_add_region_if_not_found(
+ regionbase, RGN_TYPE_CHANNELS, "spreadsheet dataset region", RGN_TYPE_FOOTER);
+
+ if (spreadsheet_dataset_region) {
+ spreadsheet_dataset_region->alignment = RGN_ALIGN_LEFT;
+ spreadsheet_dataset_region->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 300, 6)) {
+ LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
+ /* Disable View Layers filter. */
+ if (space->spacetype == SPACE_OUTLINER) {
+ SpaceOutliner *space_outliner = (SpaceOutliner *)space;
+ space_outliner->filter |= SO_FILTER_NO_VIEW_LAYERS;
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 300, 7)) {
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ ToolSettings *tool_settings = scene->toolsettings;
+ tool_settings->snap_flag |= SCE_SNAP_SEQ;
+ short snap_mode = tool_settings->snap_mode;
+ short snap_node_mode = tool_settings->snap_node_mode;
+ short snap_uv_mode = tool_settings->snap_uv_mode;
+ tool_settings->snap_mode &= ~((1 << 4) | (1 << 5) | (1 << 6));
+ tool_settings->snap_node_mode &= ~((1 << 5) | (1 << 6));
+ tool_settings->snap_uv_mode &= ~(1 << 4);
+ if (snap_mode & (1 << 4)) {
+ tool_settings->snap_mode |= (1 << 6); /* SCE_SNAP_MODE_INCREMENT */
+ }
+ if (snap_mode & (1 << 5)) {
+ tool_settings->snap_mode |= (1 << 4); /* SCE_SNAP_MODE_EDGE_MIDPOINT */
+ }
+ if (snap_mode & (1 << 6)) {
+ tool_settings->snap_mode |= (1 << 5); /* SCE_SNAP_MODE_EDGE_PERPENDICULAR */
+ }
+ if (snap_node_mode & (1 << 5)) {
+ tool_settings->snap_node_mode |= (1 << 0); /* SCE_SNAP_MODE_NODE_X */
+ }
+ if (snap_node_mode & (1 << 6)) {
+ tool_settings->snap_node_mode |= (1 << 1); /* SCE_SNAP_MODE_NODE_Y */
+ }
+ if (snap_uv_mode & (1 << 4)) {
+ tool_settings->snap_uv_mode |= (1 << 6); /* SCE_SNAP_MODE_INCREMENT */
+ }
+
+ SequencerToolSettings *sequencer_tool_settings = SEQ_tool_settings_ensure(scene);
+ sequencer_tool_settings->snap_mode = SEQ_SNAP_TO_STRIPS | SEQ_SNAP_TO_CURRENT_FRAME |
+ SEQ_SNAP_TO_STRIP_HOLD;
+ sequencer_tool_settings->snap_distance = 15;
+ }
+ }
+
/**
* 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
index 816b90491aa..94ee89c5120 100644
--- a/source/blender/blenloader/intern/versioning_cycles.c
+++ b/source/blender/blenloader/intern/versioning_cycles.c
@@ -182,7 +182,7 @@ static void displacement_principled_nodes(bNode *node)
}
}
-static bool node_has_roughness(bNode *node)
+static bool node_has_roughness(const bNode *node)
{
return ELEM(node->type,
SH_NODE_BSDF_ANISOTROPIC,
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 56b2f18f8a6..46e25251fd4 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -363,7 +363,7 @@ static void customdata_version_242(Mesh *me)
BKE_mesh_update_customdata_pointers(me, true);
}
-/*only copy render texface layer from active*/
+/* Only copy render texface layer from active. */
static void customdata_version_243(Mesh *me)
{
CustomDataLayer *layer;
@@ -1266,8 +1266,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
cam = cam->id.next;
}
- /* force oops draw if depgraph was set*/
- /* set time line var */
+ /* Force oops draw if depgraph was set. */
+ /* Set time line var. */
/* softbody init new vars */
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
@@ -2021,7 +2021,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* fix all versions before 2.45 */
if (bmain->versionfile != 245) {
- /* repair preview from 242 - 244*/
+ /* Repair preview from 242 - 244. */
for (ima = bmain->images.first; ima; ima = ima->id.next) {
ima->preview = NULL;
}
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index be3834faa5a..42b27f57e2c 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -277,6 +277,15 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
btheme->space_spreadsheet = btheme->space_outliner;
}
+ if (!USER_VERSION_ATLEAST(300, 5)) {
+ FROM_DEFAULT_V4_UCHAR(space_spreadsheet.active);
+ FROM_DEFAULT_V4_UCHAR(space_spreadsheet.list);
+ FROM_DEFAULT_V4_UCHAR(space_spreadsheet.list_text);
+ FROM_DEFAULT_V4_UCHAR(space_spreadsheet.list_text_hi);
+ FROM_DEFAULT_V4_UCHAR(space_spreadsheet.hilite);
+ FROM_DEFAULT_V4_UCHAR(space_spreadsheet.selected_highlight);
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index fbcf690a773..930ce0ba06f 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -262,7 +262,7 @@ typedef struct {
size_t write_len;
#endif
- /** Set on unlikely case of an error (ignores further file writing). */
+ /** Set on unlikely case of an error (ignores further file writing). */
bool error;
/** #MemFile writing (used for undo). */
diff --git a/source/blender/blenloader/tests/blendfile_loading_base_test.cc b/source/blender/blenloader/tests/blendfile_loading_base_test.cc
index 280a4b42b36..8afa631ffc5 100644
--- a/source/blender/blenloader/tests/blendfile_loading_base_test.cc
+++ b/source/blender/blenloader/tests/blendfile_loading_base_test.cc
@@ -123,7 +123,8 @@ bool BlendfileLoadingBaseTest::blendfile_load(const char *filepath)
char abspath[FILENAME_MAX];
BLI_path_join(abspath, sizeof(abspath), test_assets_dir.c_str(), filepath, NULL);
- bfile = BLO_read_from_file(abspath, BLO_READ_SKIP_NONE, nullptr /* reports */);
+ BlendFileReadReport bf_reports = {nullptr};
+ bfile = BLO_read_from_file(abspath, BLO_READ_SKIP_NONE, &bf_reports);
if (bfile == nullptr) {
ADD_FAILURE() << "Unable to load file '" << filepath << "' from test assets dir '"
<< test_assets_dir << "'";
diff --git a/source/blender/blentranslation/BLT_translation.h b/source/blender/blentranslation/BLT_translation.h
index b8979caa909..341e648443e 100644
--- a/source/blender/blentranslation/BLT_translation.h
+++ b/source/blender/blentranslation/BLT_translation.h
@@ -119,7 +119,7 @@ bool BLT_lang_is_ime_supported(void);
#define BLT_I18NCONTEXT_ID_HAIR "Hair"
#define BLT_I18NCONTEXT_ID_ID "ID"
#define BLT_I18NCONTEXT_ID_IMAGE "Image"
-/*#define BLT_I18NCONTEXT_ID_IPO "Ipo"*/ /* Deprecated */
+// #define BLT_I18NCONTEXT_ID_IPO "Ipo" /* DEPRECATED */
#define BLT_I18NCONTEXT_ID_SHAPEKEY "Key"
#define BLT_I18NCONTEXT_ID_SIMULATION "Simulation"
#define BLT_I18NCONTEXT_ID_LIGHT "Light"
@@ -182,7 +182,7 @@ typedef struct {
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_ID, "id_id"), \
BLT_I18NCONTEXTS_ITEM( \
BLT_I18NCONTEXT_ID_IMAGE, \
- "id_image"), /*BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_IPO, "id_ipo"),*/ \
+ "id_image"), /* BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_IPO, "id_ipo"), */ \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SHAPEKEY, "id_shapekey"), \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_LIGHT, "id_light"), \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_LIBRARY, "id_library"), \
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index f60fc72f8a9..e3efeec951e 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -89,9 +89,9 @@ typedef struct BMHeader {
BLI_STATIC_ASSERT((sizeof(BMHeader) <= 16), "BMHeader size has grown!");
-/* note: need some way to specify custom locations for custom data layers. so we can
+/* NOTE: need some way to specify custom locations for custom data layers. so we can
* make them point directly into structs. and some way to make it only happen to the
- * active layer, and properly update when switching active layers.*/
+ * active layer, and properly update when switching active layers. */
typedef struct BMVert {
BMHeader head;
@@ -142,7 +142,7 @@ typedef struct BMEdge {
/**
* Disk Cycle Pointers
*
- * relative data: d1 indicates indicates the next/prev
+ * relative data: d1 indicates the next/prev
* edge around vertex v1 and d2 does the same for v2.
*/
BMDiskLink v1_disk_link, v2_disk_link;
@@ -267,7 +267,7 @@ typedef struct BMFace {
BMHeader head;
#ifdef USE_BMESH_HOLES
- int totbounds; /*total boundaries, is one plus the number of holes in the face*/
+ int totbounds; /* Total boundaries, is one plus the number of holes in the face. */
ListBase loops;
#else
BMLoop *l_first;
@@ -545,7 +545,7 @@ typedef bool (*BMLoopPairFilterFunc)(const BMLoop *, const BMLoop *, void *user_
#define BM_ELEM_CD_GET_FLOAT_AS_UCHAR(ele, offset) \
(BLI_assert(offset != -1), (uchar)(BM_ELEM_CD_GET_FLOAT(ele, offset) * 255.0f))
-/*forward declarations*/
+/* Forward declarations. */
#ifdef USE_BMESH_HOLES
# define BM_FACE_FIRST_LOOP(p) (((BMLoopList *)((p)->loops.first))->first)
diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c
index 51a6ada6c42..f937ccbccc5 100644
--- a/source/blender/bmesh/intern/bmesh_edgeloop.c
+++ b/source/blender/bmesh/intern/bmesh_edgeloop.c
@@ -50,7 +50,7 @@ typedef struct BMEdgeLoopStore {
#define EDGELOOP_EPS 1e-10f
/* -------------------------------------------------------------------- */
-/* BM_mesh_edgeloops_find & Util Functions */
+/* BM_mesh_edgeloops_find & Util Functions. */
static int bm_vert_other_tag(BMVert *v, BMVert *v_prev, BMEdge **r_e)
{
@@ -187,7 +187,7 @@ int BM_mesh_edgeloops_find(BMesh *bm,
}
/* -------------------------------------------------------------------- */
-/* BM_mesh_edgeloops_find_path & Util Functions */
+/* BM_mesh_edgeloops_find_path & Util Functions. */
/**
* Find s single, open edge loop - given 2 vertices.
diff --git a/source/blender/bmesh/intern/bmesh_error.h b/source/blender/bmesh/intern/bmesh_error.h
index 41d02e334fb..e9cdc120657 100644
--- a/source/blender/bmesh/intern/bmesh_error.h
+++ b/source/blender/bmesh/intern/bmesh_error.h
@@ -24,46 +24,29 @@
/*----------- bmop error system ----------*/
-/* pushes an error onto the bmesh error stack.
+/* Pushes an error onto the bmesh error stack.
* if msg is null, then the default message for the `errcode` is used. */
-void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg);
+void BMO_error_raise(BMesh *bm, BMOperator *owner, const char *msg) ATTR_NONNULL(1, 2, 3);
-/* gets the topmost error from the stack.
- * returns error code or 0 if no error.*/
-int BMO_error_get(BMesh *bm, const char **msg, BMOperator **op);
+/* Gets the topmost error from the stack.
+ * returns error code or 0 if no error. */
+bool BMO_error_get(BMesh *bm, const char **r_msg, BMOperator **r_op);
bool BMO_error_occurred(BMesh *bm);
/* Same as #BMO_error_get, only pops the error off the stack as well. */
-int BMO_error_pop(BMesh *bm, const char **msg, BMOperator **op);
+bool BMO_error_pop(BMesh *bm, const char **r_msg, BMOperator **r_op);
void BMO_error_clear(BMesh *bm);
-/* this is meant for handling errors, like self-intersection test failures.
+/* This is meant for handling errors, like self-intersection test failures.
* it's dangerous to handle errors in general though, so disabled for now. */
-/* catches an error raised by the op pointed to by catchop.
- * errorcode is either the errorcode, or BMERR_ALL for any
- * error.*/
-
-/* not yet implemented.
- * int BMO_error_catch_op(BMesh *bm, BMOperator *catchop, int errorcode, char **msg);
- */
+/* Catches an error raised by the op pointed to by catchop. */
+/* Not yet implemented. */
+// int BMO_error_catch_op(BMesh *bm, BMOperator *catchop, char **msg);
#define BM_ELEM_INDEX_VALIDATE(_bm, _msg_a, _msg_b) \
BM_mesh_elem_index_validate(_bm, __FILE__ ":" STRINGIFY(__LINE__), __func__, _msg_a, _msg_b)
-/*------ error code defines -------*/
-
-/*error messages*/
-enum {
- BMERR_CONNECTVERT_FAILED = 1,
- BMERR_DISSOLVEFACES_FAILED,
- BMERR_INVALID_SELECTION,
- BMERR_MESH_ERROR,
- BMERR_CONVEX_HULL_FAILED,
-
- BMERR_TOTAL,
-};
-
/* BMESH_ASSERT */
#ifdef WITH_ASSERT_ABORT
# define _BMESH_DUMMY_ABORT abort
@@ -71,8 +54,8 @@ enum {
# define _BMESH_DUMMY_ABORT() (void)0
#endif
-/* this is meant to be higher level than BLI_assert(),
- * its enabled even when in Release mode*/
+/* This is meant to be higher level than BLI_assert(),
+ * its enabled even when in Release mode. */
#define BMESH_ASSERT(a) \
(void)((!(a)) ? ((fprintf(stderr, \
"BMESH_ASSERT failed: %s, %s(), %d at \'%s\'\n", \
diff --git a/source/blender/bmesh/intern/bmesh_iterators.h b/source/blender/bmesh/intern/bmesh_iterators.h
index f2e7a48a16c..470aceeb756 100644
--- a/source/blender/bmesh/intern/bmesh_iterators.h
+++ b/source/blender/bmesh/intern/bmesh_iterators.h
@@ -61,11 +61,11 @@ typedef enum BMIterType {
BM_LOOPS_OF_FACE = 11,
/* returns elements from all boundaries, and returns
* the first element at the end to flag that we're entering
- * a different face hole boundary*/
+ * a different face hole boundary. */
// BM_ALL_LOOPS_OF_FACE = 12,
/* iterate through loops around this loop, which are fetched
* from the other faces in the radial cycle surrounding the
- * input loop's edge.*/
+ * input loop's edge. */
BM_LOOPS_OF_LOOP = 12,
BM_LOOPS_OF_EDGE = 13,
} BMIterType;
diff --git a/source/blender/bmesh/intern/bmesh_marking.h b/source/blender/bmesh/intern/bmesh_marking.h
index ff6c359138a..99feae1d66c 100644
--- a/source/blender/bmesh/intern/bmesh_marking.h
+++ b/source/blender/bmesh/intern/bmesh_marking.h
@@ -68,8 +68,8 @@ void BM_mesh_elem_hflag_disable_all(BMesh *bm,
const char hflag,
const bool respecthide);
-/* individual element select functions, BM_elem_select_set is a shortcut for these
- * that automatically detects which one to use*/
+/* Individual element select functions, BM_elem_select_set is a shortcut for these
+ * that automatically detects which one to use. */
void BM_vert_select_set(BMesh *bm, BMVert *v, const bool select);
void BM_edge_select_set(BMesh *bm, BMEdge *e, const bool select);
void BM_face_select_set(BMesh *bm, BMFace *f, const bool select);
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 80028564ff2..b2958a9e744 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -854,7 +854,7 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const
for (i = totvert, ve = verts_copy + totvert - 1, vep = verts_pool + totvert - 1; i--;
ve--, vep--) {
*ve = **vep;
- /* printf("*vep: %p, verts_pool[%d]: %p\n", *vep, i, verts_pool[i]);*/
+ // printf("*vep: %p, verts_pool[%d]: %p\n", *vep, i, verts_pool[i]);
if (cd_vert_pyptr != -1) {
void **pyptr = BM_ELEM_CD_GET_VOID_P(((BMElem *)ve), cd_vert_pyptr);
pyptrs[i] = *pyptr;
@@ -990,7 +990,7 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const
/* Verts' pointers, only edge pointers... */
if (eptr_map) {
BM_ITER_MESH (ve, &iter, bm, BM_VERTS_OF_MESH) {
- /* printf("Vert e: %p -> %p\n", ve->e, BLI_ghash_lookup(eptr_map, ve->e));*/
+ // printf("Vert e: %p -> %p\n", ve->e, BLI_ghash_lookup(eptr_map, ve->e));
if (ve->e) {
ve->e = BLI_ghash_lookup(eptr_map, ve->e);
BLI_assert(ve->e);
@@ -1004,22 +1004,30 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const
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));*/
+#if 0
+ 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));
+#endif
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));*/
+#if 0
+ 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));
+#endif
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);
@@ -1036,17 +1044,17 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const
BM_ITER_MESH (fa, &iter, bm, BM_FACES_OF_MESH) {
BM_ITER_ELEM (lo, &iterl, fa, BM_LOOPS_OF_FACE) {
if (vptr_map) {
- /* printf("Loop v: %p -> %p\n", lo->v, BLI_ghash_lookup(vptr_map, lo->v));*/
+ // printf("Loop v: %p -> %p\n", lo->v, BLI_ghash_lookup(vptr_map, lo->v));
lo->v = BLI_ghash_lookup(vptr_map, lo->v);
BLI_assert(lo->v);
}
if (eptr_map) {
- /* printf("Loop e: %p -> %p\n", lo->e, BLI_ghash_lookup(eptr_map, lo->e));*/
+ // printf("Loop e: %p -> %p\n", lo->e, BLI_ghash_lookup(eptr_map, lo->e));
lo->e = BLI_ghash_lookup(eptr_map, lo->e);
BLI_assert(lo->e);
}
if (fptr_map) {
- /* printf("Loop f: %p -> %p\n", lo->f, BLI_ghash_lookup(fptr_map, lo->f));*/
+ // printf("Loop f: %p -> %p\n", lo->f, BLI_ghash_lookup(fptr_map, lo->f));
lo->f = BLI_ghash_lookup(fptr_map, lo->f);
BLI_assert(lo->f);
}
diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.c b/source/blender/bmesh/intern/bmesh_mesh_convert.c
index ba413c3c547..9d29a90a7a4 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_convert.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_convert.c
@@ -1001,7 +1001,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
/* Topology could be changed, ensure #CD_MDISPS are ok. */
multires_topology_changed(me);
- /* To be removed as soon as COW is enabled by default.. */
+ /* To be removed as soon as COW is enabled by default. */
BKE_mesh_runtime_clear_geometry(me);
}
diff --git a/source/blender/bmesh/intern/bmesh_mesh_normals.c b/source/blender/bmesh/intern/bmesh_mesh_normals.c
index bddd3da98b7..6ab7b8a2057 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_normals.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_normals.c
@@ -18,6 +18,8 @@
* \ingroup bmesh
*
* BM mesh normal calculation functions.
+ *
+ * \see mesh_normals.c for the equivalent #Mesh functionality.
*/
#include "MEM_guardedalloc.h"
@@ -65,8 +67,8 @@ BLI_INLINE void bm_vert_calc_normals_accum_loop(const BMLoop *l_iter,
float v_no[3])
{
/* Calculate the dot product of the two edges that meet at the loop's vertex. */
- /* Edge vectors are calculated from e->v1 to e->v2, so adjust the dot product if one but not
- * both loops actually runs from from e->v2 to e->v1. */
+ /* Edge vectors are calculated from `e->v1` to `e->v2`, so adjust the dot product if one but not
+ * both loops actually runs from `e->v2` to `e->v1`. */
float dotprod = dot_v3v3(e1diff, e2diff);
if ((l_iter->prev->e->v1 == l_iter->prev->v) ^ (l_iter->e->v1 == l_iter->v)) {
dotprod = -dotprod;
@@ -292,6 +294,10 @@ void BM_mesh_normals_update_with_partial_ex(BMesh *UNUSED(bm),
const struct BMeshNormalsUpdate_Params *params)
{
BLI_assert(bmpinfo->params.do_normals);
+ /* While harmless, exit early if there is nothing to do. */
+ if (UNLIKELY((bmpinfo->verts_len == 0) && (bmpinfo->faces_len == 0))) {
+ return;
+ }
BMVert **verts = bmpinfo->verts;
BMFace **faces = bmpinfo->faces;
@@ -1542,7 +1548,7 @@ static int bm_loop_normal_mark_indiv(BMesh *bm, BLI_bitmap *loops, const bool do
/* Using face history allows to select a single loop from a single face...
* Note that this is O(n^2) piece of code,
* but it is not designed to be used with huge selection sets,
- * rather with only a few items selected at most.*/
+ * rather with only a few items selected at most. */
/* Goes from last selected to the first selected element. */
for (ese = bm->selected.last; ese; ese = ese->prev) {
if (ese->htype == BM_FACE) {
diff --git a/source/blender/bmesh/intern/bmesh_mesh_partial_update.c b/source/blender/bmesh/intern/bmesh_mesh_partial_update.c
index 267705aa7c7..46fd2ad9a31 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_partial_update.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_partial_update.c
@@ -25,16 +25,26 @@
*
* In the future this could be integrated into GPU updates too.
*
- * Potential Improvements
- * ======================
+ * Kinds of Partial Geometry
+ * =========================
*
- * Some calculations could be significantly limited in the case of affine transformations
- * (tessellation is an obvious candidate). Where only faces which have a mix
- * of tagged and untagged vertices would need to be recalculated.
+ * All Tagged
+ * ----------
+ * Operate on everything that's tagged as well as connected geometry.
+ * see: #BM_mesh_partial_create_from_verts
*
- * In general this would work well besides some corner cases such as scaling to zero.
- * Although the exact result may depend on the normal (for N-GONS),
- * so for now update the tessellation of all tagged geometry.
+ * Grouped
+ * -------
+ * Operate on everything that is connected to both tagged and un-tagged.
+ * see: #BM_mesh_partial_create_from_verts_group_single
+ *
+ * Reduces computations when transforming isolated regions.
+ *
+ * Optionally support multiple groups since axis-mirror (for example)
+ * will transform vertices in different directions, as well as keeping centered vertices.
+ * see: #BM_mesh_partial_create_from_verts_group_multi
+ *
+ * \note Others can be added as needed.
*/
#include "DNA_object_types.h"
@@ -93,21 +103,24 @@ BLI_INLINE bool partial_elem_face_ensure(BMPartialUpdate *bmpinfo,
return false;
}
+/**
+ * All Tagged & Connected, see: #BM_mesh_partial_create_from_verts
+ * Operate on everything that's tagged as well as connected geometry.
+ */
BMPartialUpdate *BM_mesh_partial_create_from_verts(BMesh *bm,
const BMPartialUpdate_Params *params,
- const int verts_len,
- bool (*filter_fn)(BMVert *, void *user_data),
- void *user_data)
+ const BLI_bitmap *verts_mask,
+ const int verts_mask_count)
{
/* The caller is doing something wrong if this isn't the case. */
- BLI_assert(verts_len <= bm->totvert);
+ BLI_assert(verts_mask_count <= bm->totvert);
BMPartialUpdate *bmpinfo = MEM_callocN(sizeof(*bmpinfo), __func__);
/* Reserve more edges than vertices since it's common for a grid topology
* to use around twice as many edges as vertices. */
- const int default_verts_len_alloc = verts_len;
- const int default_faces_len_alloc = min_ii(bm->totface, verts_len);
+ const int default_verts_len_alloc = verts_mask_count;
+ const int default_faces_len_alloc = min_ii(bm->totface, verts_mask_count);
/* Allocate tags instead of using #BM_ELEM_TAG because the caller may already be using tags.
* Further, walking over all geometry to clear the tags isn't so efficient. */
@@ -143,7 +156,7 @@ BMPartialUpdate *BM_mesh_partial_create_from_verts(BMesh *bm,
int i;
BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
BM_elem_index_set(v, i); /* set_inline */
- if (!filter_fn(v, user_data)) {
+ if (!BLI_BITMAP_TEST(verts_mask, i)) {
continue;
}
BMEdge *e_iter = v->e;
@@ -203,6 +216,224 @@ BMPartialUpdate *BM_mesh_partial_create_from_verts(BMesh *bm,
return bmpinfo;
}
+/**
+ * All Connected, operate on all faces that have both tagged and un-tagged vertices.
+ *
+ * Reduces computations when transforming isolated regions.
+ */
+BMPartialUpdate *BM_mesh_partial_create_from_verts_group_single(
+ BMesh *bm,
+ const BMPartialUpdate_Params *params,
+ const BLI_bitmap *verts_mask,
+ const int verts_mask_count)
+{
+ BMPartialUpdate *bmpinfo = MEM_callocN(sizeof(*bmpinfo), __func__);
+
+ BLI_bitmap *verts_tag = NULL;
+ BLI_bitmap *faces_tag = NULL;
+
+ /* It's not worth guessing a large number as isolated regions will allocate zero faces. */
+ const int default_faces_len_alloc = 1;
+
+ int face_tag_loop_len = 0;
+
+ if (params->do_normals || params->do_tessellate) {
+
+ /* Faces. */
+ if (bmpinfo->faces == NULL) {
+ bmpinfo->faces_len_alloc = default_faces_len_alloc;
+ bmpinfo->faces = MEM_mallocN((sizeof(BMFace *) * bmpinfo->faces_len_alloc), __func__);
+ faces_tag = BLI_BITMAP_NEW((size_t)bm->totface, __func__);
+ }
+
+ BMFace *f;
+ BMIter iter;
+ int i;
+ BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, i) {
+ enum { SIDE_A = (1 << 0), SIDE_B = (1 << 1) } side_flag = 0;
+ BM_elem_index_set(f, i); /* set_inline */
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int j = BM_elem_index_get(l_iter->v);
+ side_flag |= BLI_BITMAP_TEST(verts_mask, j) ? SIDE_A : SIDE_B;
+ if (UNLIKELY(side_flag == (SIDE_A | SIDE_B))) {
+ partial_elem_face_ensure(bmpinfo, faces_tag, f);
+ face_tag_loop_len += f->len;
+ break;
+ }
+ } while ((l_iter = l_iter->next) != l_first);
+ }
+ }
+
+ if (params->do_normals) {
+ /* Extend to all faces vertices:
+ * Any changes to the faces normal needs to update all surrounding vertices. */
+
+ /* Over allocate using the total number of face loops. */
+ const int default_verts_len_alloc = min_ii(bm->totvert, max_ii(1, face_tag_loop_len));
+
+ /* Vertices. */
+ if (bmpinfo->verts == NULL) {
+ bmpinfo->verts_len_alloc = default_verts_len_alloc;
+ bmpinfo->verts = MEM_mallocN((sizeof(BMVert *) * bmpinfo->verts_len_alloc), __func__);
+ verts_tag = BLI_BITMAP_NEW((size_t)bm->totvert, __func__);
+ }
+
+ for (int i = 0; i < bmpinfo->faces_len; i++) {
+ BMFace *f = bmpinfo->faces[i];
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ partial_elem_vert_ensure(bmpinfo, verts_tag, l_iter->v);
+ } while ((l_iter = l_iter->next) != l_first);
+ }
+
+ /* Loose vertex support, these need special handling as loose normals depend on location. */
+ if (bmpinfo->verts_len < verts_mask_count) {
+ BMVert *v;
+ BMIter iter;
+ int i;
+ BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
+ if (BLI_BITMAP_TEST(verts_mask, i) && (BM_vert_find_first_loop(v) == NULL)) {
+ partial_elem_vert_ensure(bmpinfo, verts_tag, v);
+ }
+ }
+ }
+ }
+
+ if (verts_tag) {
+ MEM_freeN(verts_tag);
+ }
+ if (faces_tag) {
+ MEM_freeN(faces_tag);
+ }
+
+ bmpinfo->params = *params;
+
+ return bmpinfo;
+}
+
+/**
+ * All Connected, operate on all faces that have vertices in the same group.
+ *
+ * Reduces computations when transforming isolated regions.
+ *
+ * This is a version of #BM_mesh_partial_create_from_verts_group_single
+ * that handles multiple groups instead of a bitmap mask.
+ *
+ * This is needed for example when transform has mirror enabled,
+ * since one side needs to have a different group to the other since a face that has vertices
+ * attached to both won't have an affine transformation.
+ *
+ * \param verts_groups: Vertex aligned array of groups.
+ * Values are used as follows:
+ * - >0: Each face is grouped with other faces of the same group.
+ * - 0: Not in a group (don't handle these).
+ * - -1: Don't use grouping logic (include any face that contains a vertex with this group).
+ * \param verts_groups_count: The number of non-zero values in `verts_groups`.
+ */
+BMPartialUpdate *BM_mesh_partial_create_from_verts_group_multi(
+ BMesh *bm,
+ const BMPartialUpdate_Params *params,
+ const int *verts_group,
+ const int verts_group_count)
+{
+ /* Provide a quick way of visualizing which faces are being manipulated. */
+ // #define DEBUG_MATERIAL
+
+ BMPartialUpdate *bmpinfo = MEM_callocN(sizeof(*bmpinfo), __func__);
+
+ BLI_bitmap *verts_tag = NULL;
+ BLI_bitmap *faces_tag = NULL;
+
+ /* It's not worth guessing a large number as isolated regions will allocate zero faces. */
+ const int default_faces_len_alloc = 1;
+
+ int face_tag_loop_len = 0;
+
+ if (params->do_normals || params->do_tessellate) {
+
+ /* Faces. */
+ if (bmpinfo->faces == NULL) {
+ bmpinfo->faces_len_alloc = default_faces_len_alloc;
+ bmpinfo->faces = MEM_mallocN((sizeof(BMFace *) * bmpinfo->faces_len_alloc), __func__);
+ faces_tag = BLI_BITMAP_NEW((size_t)bm->totface, __func__);
+ }
+
+ BMFace *f;
+ BMIter iter;
+ int i;
+ BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, i) {
+ BM_elem_index_set(f, i); /* set_inline */
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ const int group_test = verts_group[BM_elem_index_get(l_iter->prev->v)];
+#ifdef DEBUG_MATERIAL
+ f->mat_nr = 0;
+#endif
+ do {
+ const int group_iter = verts_group[BM_elem_index_get(l_iter->v)];
+ if (UNLIKELY((group_iter != group_test) || (group_iter == -1))) {
+ partial_elem_face_ensure(bmpinfo, faces_tag, f);
+ face_tag_loop_len += f->len;
+#ifdef DEBUG_MATERIAL
+ f->mat_nr = 1;
+#endif
+ break;
+ }
+ } while ((l_iter = l_iter->next) != l_first);
+ }
+ }
+
+ if (params->do_normals) {
+ /* Extend to all faces vertices:
+ * Any changes to the faces normal needs to update all surrounding vertices. */
+
+ /* Over allocate using the total number of face loops. */
+ const int default_verts_len_alloc = min_ii(bm->totvert, max_ii(1, face_tag_loop_len));
+
+ /* Vertices. */
+ if (bmpinfo->verts == NULL) {
+ bmpinfo->verts_len_alloc = default_verts_len_alloc;
+ bmpinfo->verts = MEM_mallocN((sizeof(BMVert *) * bmpinfo->verts_len_alloc), __func__);
+ verts_tag = BLI_BITMAP_NEW((size_t)bm->totvert, __func__);
+ }
+
+ for (int i = 0; i < bmpinfo->faces_len; i++) {
+ BMFace *f = bmpinfo->faces[i];
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ partial_elem_vert_ensure(bmpinfo, verts_tag, l_iter->v);
+ } while ((l_iter = l_iter->next) != l_first);
+ }
+
+ /* Loose vertex support, these need special handling as loose normals depend on location. */
+ if (bmpinfo->verts_len < verts_group_count) {
+ BMVert *v;
+ BMIter iter;
+ int i;
+ BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
+ if ((verts_group[i] != 0) && (BM_vert_find_first_loop(v) == NULL)) {
+ partial_elem_vert_ensure(bmpinfo, verts_tag, v);
+ }
+ }
+ }
+ }
+
+ if (verts_tag) {
+ MEM_freeN(verts_tag);
+ }
+ if (faces_tag) {
+ MEM_freeN(faces_tag);
+ }
+
+ bmpinfo->params = *params;
+
+ return bmpinfo;
+}
+
void BM_mesh_partial_destroy(BMPartialUpdate *bmpinfo)
{
if (bmpinfo->verts) {
diff --git a/source/blender/bmesh/intern/bmesh_mesh_partial_update.h b/source/blender/bmesh/intern/bmesh_mesh_partial_update.h
index 3dbfb985e92..cf4eab22836 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_partial_update.h
+++ b/source/blender/bmesh/intern/bmesh_mesh_partial_update.h
@@ -54,9 +54,20 @@ typedef struct BMPartialUpdate {
BMPartialUpdate *BM_mesh_partial_create_from_verts(BMesh *bm,
const BMPartialUpdate_Params *params,
- const int verts_len,
- bool (*filter_fn)(BMVert *, void *user_data),
- void *user_data)
- ATTR_NONNULL(1, 2, 4) ATTR_WARN_UNUSED_RESULT;
+ const unsigned int *verts_mask,
+ const int verts_mask_count)
+ ATTR_NONNULL(1, 2, 3) ATTR_WARN_UNUSED_RESULT;
+
+BMPartialUpdate *BM_mesh_partial_create_from_verts_group_single(
+ BMesh *bm,
+ const BMPartialUpdate_Params *params,
+ const unsigned int *verts_mask,
+ const int verts_mask_count) ATTR_NONNULL(1, 2, 3) ATTR_WARN_UNUSED_RESULT;
+
+BMPartialUpdate *BM_mesh_partial_create_from_verts_group_multi(
+ BMesh *bm,
+ const BMPartialUpdate_Params *params,
+ const int *verts_group,
+ const int verts_group_count) ATTR_NONNULL(1, 2, 3) ATTR_WARN_UNUSED_RESULT;
void BM_mesh_partial_destroy(BMPartialUpdate *bmpinfo) ATTR_NONNULL(1);
diff --git a/source/blender/bmesh/intern/bmesh_mesh_tessellate.c b/source/blender/bmesh/intern/bmesh_mesh_tessellate.c
index c9b027474e1..9f477bc8a9c 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_tessellate.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_tessellate.c
@@ -406,6 +406,10 @@ void BM_mesh_calc_tessellation_with_partial_ex(BMesh *bm,
const struct BMeshCalcTessellation_Params *params)
{
BLI_assert(bmpinfo->params.do_tessellate);
+ /* While harmless, exit early if there is nothing to do (avoids ensuring the index). */
+ if (UNLIKELY(bmpinfo->faces_len == 0)) {
+ return;
+ }
BM_mesh_elem_index_ensure(bm, BM_LOOP | BM_FACE);
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index 548dba242bf..f75497f2f19 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -118,7 +118,7 @@ bool BM_disk_dissolve(BMesh *bm, BMVert *v)
if (keepedge == NULL && len == 3) {
#if 0
/* handle specific case for three-valence. solve it by
- * increasing valence to four. this may be hackish. . */
+ * increasing valence to four. this may be hackish. */
BMLoop *l_a = BM_face_vert_share_loop(e->l->f, v);
BMLoop *l_b = (e->l->v == v) ? e->l->next : e->l;
@@ -246,8 +246,8 @@ BMFace *BM_faces_join_pair(BMesh *bm, BMLoop *l_a, BMLoop *l_b, const bool do_de
* \param no_double: Use an existing edge if found
*
* \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
- * other side). NULL if the split fails.
+ * if the split is successful (and the original face will be the other side).
+ * NULL if the split fails.
*/
BMFace *BM_face_split(BMesh *bm,
BMFace *f,
@@ -328,8 +328,8 @@ BMFace *BM_face_split(BMesh *bm,
* \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
- * other side). NULL if the split fails.
+ * if the split is successful (and the original face will be the other side).
+ * NULL if the split fails.
*/
BMFace *BM_face_split_n(BMesh *bm,
BMFace *f,
@@ -369,7 +369,7 @@ BMFace *BM_face_split_n(BMesh *bm,
#endif
/* 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' */
+ * The radial_next is for 'f' and goes from 'v_b' to 'v_a'. */
if (f_new) {
e = l_new->e;
@@ -962,7 +962,7 @@ bool BM_edge_rotate_check_beauty(BMEdge *e, BMLoop *l1, BMLoop *l2)
{
/* Stupid check for now:
* Could compare angles of surrounding edges
- * before & after, but this is OK.*/
+ * before & after, but this is OK. */
return (len_squared_v3v3(e->v1->co, e->v2->co) > len_squared_v3v3(l1->v->co, l2->v->co));
}
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index bccac006e8e..a5cce41eee4 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1337,7 +1337,7 @@ static BMOpDefine bmo_bisect_plane_def = {
{{'\0'}},
},
{{"geom_cut.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE}}, /* output geometry aligned with the plane (new and existing) */
- {"geom.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* input and output geometry (result of cut) */
+ {"geom.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* input and output geometry (result of cut). */
{{'\0'}}},
bmo_bisect_plane_exec,
(BMO_OPTYPE_FLAG_UNTAN_MULTIRES |
diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h
index 706979abeba..d09c0ee428d 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api.h
@@ -256,7 +256,7 @@ typedef struct BMO_FlagSet {
} BMO_FlagSet;
/* please ignore all these structures, don't touch them in tool code, except
- * for when your defining an operator with BMOpDefine.*/
+ * for when your defining an operator with BMOpDefine. */
typedef struct BMOpSlot {
const char *slot_name; /* pointer to BMOpDefine.slot_args */
@@ -345,16 +345,16 @@ typedef struct BMOpDefine {
/* data types that use pointers (arrays, etc) should never
* have it set directly. and never use BMO_slot_ptr_set to
- * pass in a list of edges or any arrays, really.*/
+ * pass in a list of edges or any arrays, really. */
void BMO_op_init(BMesh *bm, BMOperator *op, const int flag, const char *opname);
/* executes an operator, pushing and popping a new tool flag
- * layer as appropriate.*/
+ * layer as appropriate. */
void BMO_op_exec(BMesh *bm, BMOperator *op);
/* finishes an operator (though note the operator's tool flag is removed
- * after it finishes executing in BMO_op_exec).*/
+ * after it finishes executing in BMO_op_exec). */
void BMO_op_finish(BMesh *bm, BMOperator *op);
/* count the number of elements with the specified flag enabled.
@@ -369,7 +369,7 @@ int BMO_mesh_disabled_flag_count(BMesh *bm, const char htype, const short oflag)
void BMO_push(BMesh *bm, BMOperator *op);
void BMO_pop(BMesh *bm);
-/*executes an operator*/
+/* Executes an operator. */
bool BMO_op_callf(BMesh *bm, const int flag, const char *fmt, ...);
/* initializes, but doesn't execute an operator. this is so you can
@@ -538,7 +538,7 @@ void BMO_slot_buffer_hflag_disable(BMesh *bm,
/* puts every element of type 'type' (which is a bitmask) with header
* flag 'flag', into a slot. note: ignores hidden elements
- * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/
+ * (e.g. elements with header flag BM_ELEM_HIDDEN set). */
void BMO_slot_buffer_from_enabled_hflag(BMesh *bm,
BMOperator *op,
BMOpSlot slot_args[BMO_OP_MAX_SLOTS],
@@ -548,7 +548,7 @@ void BMO_slot_buffer_from_enabled_hflag(BMesh *bm,
/* puts every element of type 'type' (which is a bitmask) without
* header flag 'flag', into a slot. note: ignores hidden elements
- * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/
+ * (e.g. elements with header flag BM_ELEM_HIDDEN set). */
void BMO_slot_buffer_from_disabled_hflag(BMesh *bm,
BMOperator *op,
BMOpSlot slot_args[BMO_OP_MAX_SLOTS],
@@ -571,7 +571,7 @@ int BMO_slot_map_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na
void BMO_slot_map_insert(BMOperator *op, BMOpSlot *slot, const void *element, const void *data);
/* flags all elements in a mapping. note that the mapping must only have
- * bmesh elements in it.*/
+ * bmesh elements in it. */
void BMO_slot_map_to_flag(BMesh *bm,
BMOpSlot slot_args[BMO_OP_MAX_SLOTS],
const char *slot_name,
diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
index 43628f01bc8..85701a76433 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
@@ -22,15 +22,10 @@
#pragma once
-/* tool flag API. never, ever ever should tool code put junk in
- * header flags (element->head.flag), nor should they use
- * element->head.eflag1/eflag2. instead, use this api to set
- * flags.
- *
- * if you need to store a value per element, use a
- * ghash or a mapping slot to do it. */
+/* Tool Flag API: Tool code must never put junk in header flags (#BMHeader.hflag)
+ * instead, use this API to set flags.
+ * If you need to store a value per element, use a #GHash or a mapping slot to do it. */
-/* flags 15 and 16 (1 << 14 and 1 << 15) are reserved for bmesh api use */
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2) BLI_INLINE
short _bmo_elem_flag_test(BMesh *bm, const BMFlagLayer *oflags, const short oflag)
{
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index e47fd1c035d..303b5336a5c 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -42,17 +42,6 @@ static int bmo_name_to_slotcode(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char
static int bmo_name_to_slotcode_check(BMOpSlot slot_args[BMO_OP_MAX_SLOTS],
const char *identifier);
-static const char *bmo_error_messages[] = {
- NULL,
- N_("Could not connect vertices"),
- N_("Could not dissolve faces"),
- N_("Invalid selection"),
- N_("Internal mesh error"),
- N_("Convex hull failed"),
-};
-
-BLI_STATIC_ASSERT(ARRAY_SIZE(bmo_error_messages) == BMERR_TOTAL, "message mismatch");
-
/* operator slot type information - size of one element of the type given. */
const int BMO_OPSLOT_TYPEINFO[BMO_OP_SLOT_TOTAL_TYPES] = {
0, /* 0: BMO_OP_SLOT_SENTINEL */
@@ -1293,7 +1282,7 @@ static void bmo_flag_layer_alloc(BMesh *bm)
bm->ftoolflagpool = BLI_mempool_create(
sizeof(BMFlagLayer) * bm->totflags, bm->totface, 512, BLI_MEMPOOL_NOP);
- /* now go through and memcpy all the flags. Loops don't get a flag layer at this time.. */
+ /* now go through and memcpy all the flags. Loops don't get a flag layer at this time. */
BMIter iter;
int i;
@@ -1346,7 +1335,7 @@ static void bmo_flag_layer_free(BMesh *bm)
/* store memcpy size for reuse */
const size_t new_totflags_size = ((bm->totflags - 1) * sizeof(BMFlagLayer));
- /* de-increment the totflags first.. */
+ /* de-increment the totflags first. */
bm->totflags--;
bm->vtoolflagpool = BLI_mempool_create(new_totflags_size, bm->totvert, 512, BLI_MEMPOOL_NOP);
@@ -1562,7 +1551,6 @@ bool BMO_iter_map_value_bool(BMOIter *iter)
/* error system */
typedef struct BMOpError {
struct BMOpError *next, *prev;
- int errorcode;
BMOperator *op;
const char *msg;
} BMOpError;
@@ -1574,14 +1562,10 @@ void BMO_error_clear(BMesh *bm)
}
}
-void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg)
+void BMO_error_raise(BMesh *bm, BMOperator *owner, const char *msg)
{
BMOpError *err = MEM_callocN(sizeof(BMOpError), "bmop_error");
- err->errorcode = errcode;
- if (!msg) {
- msg = bmo_error_messages[errcode];
- }
err->msg = msg;
err->op = owner;
@@ -1594,35 +1578,35 @@ bool BMO_error_occurred(BMesh *bm)
}
/* returns error code or 0 if no error */
-int BMO_error_get(BMesh *bm, const char **msg, BMOperator **op)
+bool BMO_error_get(BMesh *bm, const char **r_msg, BMOperator **r_op)
{
BMOpError *err = bm->errorstack.first;
- if (!err) {
- return 0;
+ if (err == NULL) {
+ return false;
}
- if (msg) {
- *msg = err->msg;
+ if (r_msg) {
+ *r_msg = err->msg;
}
- if (op) {
- *op = err->op;
+ if (r_op) {
+ *r_op = err->op;
}
- return err->errorcode;
+ return true;
}
-int BMO_error_pop(BMesh *bm, const char **msg, BMOperator **op)
+bool BMO_error_pop(BMesh *bm, const char **msg, BMOperator **op)
{
- int errorcode = BMO_error_get(bm, msg, op);
+ bool result = BMO_error_get(bm, msg, op);
- if (errorcode) {
+ if (result) {
BMOpError *err = bm->errorstack.first;
BLI_remlink(&bm->errorstack, bm->errorstack.first);
MEM_freeN(err);
}
- return errorcode;
+ return result;
}
#define NEXT_CHAR(fmt) ((fmt)[0] != 0 ? (fmt)[1] : 0)
diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index 2d9e244e54d..a701fe3eb85 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -20,7 +20,7 @@
* \ingroup bmesh
*/
-/*see comments in intern/bmesh_opdefines.c for documentation of specific operators*/
+/* See comments in `intern/bmesh_opdefines.c` for documentation of specific operators. */
/*--------defines/enumerations for specific operators-------*/
diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h
index 2c3bac6df33..e1df7744e41 100644
--- a/source/blender/bmesh/intern/bmesh_private.h
+++ b/source/blender/bmesh/intern/bmesh_private.h
@@ -56,16 +56,17 @@ int bmesh_disk_count(const BMVert *v);
/**
* Internal BMHeader.api_flag
* \note Ensure different parts of the API do not conflict
- * on using these internal flags!*/
+ * on using these internal flags!
+ */
enum {
- _FLAG_JF = (1 << 0), /* join faces */
- _FLAG_MF = (1 << 1), /* make face */
- _FLAG_MV = (1 << 1), /* make face, vertex */
- _FLAG_OVERLAP = (1 << 2), /* general overlap flag */
- _FLAG_WALK = (1 << 3), /* general walk flag (keep clean) */
- _FLAG_WALK_ALT = (1 << 4), /* same as _FLAG_WALK, for when a second tag is needed */
+ _FLAG_JF = (1 << 0), /* Join faces. */
+ _FLAG_MF = (1 << 1), /* Make face. */
+ _FLAG_MV = (1 << 1), /* Make face, vertex. */
+ _FLAG_OVERLAP = (1 << 2), /* General overlap flag. */
+ _FLAG_WALK = (1 << 3), /* General walk flag (keep clean). */
+ _FLAG_WALK_ALT = (1 << 4), /* Same as #_FLAG_WALK, for when a second tag is needed. */
- _FLAG_ELEM_CHECK = (1 << 7), /* reserved for bmesh_elem_check */
+ _FLAG_ELEM_CHECK = (1 << 7), /* Reserved for bmesh_elem_check. */
};
#define BM_ELEM_API_FLAG_ENABLE(element, f) \
diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c
index da407abfb21..8047b52b625 100644
--- a/source/blender/bmesh/intern/bmesh_query.c
+++ b/source/blender/bmesh/intern/bmesh_query.c
@@ -1824,8 +1824,8 @@ float BM_vert_calc_edge_angle_ex(const BMVert *v, const float fallback)
{
BMEdge *e1, *e2;
- /* saves BM_vert_edge_count(v) and and edge iterator,
- * get the edges and count them both at once */
+ /* Saves `BM_vert_edge_count(v)` and edge iterator,
+ * get the edges and count them both at once. */
if ((e1 = v->e) && (e2 = bmesh_disk_edge_next(e1, v)) && (e1 != e2) &&
/* make sure we come full circle and only have 2 connected edges */
@@ -2365,7 +2365,7 @@ bool BM_face_exists_overlap_subset(BMVert **varr, const int len)
for (int i = 0; i < len; i++) {
BM_ITER_ELEM (f, &viter, varr[i], BM_FACES_OF_VERT) {
if ((f->len <= len) && (BM_ELEM_API_FLAG_TEST(f, _FLAG_OVERLAP) == 0)) {
- /* check if all vers in this face are flagged*/
+ /* Check if all vers in this face are flagged. */
BMLoop *l_iter, *l_first;
if (is_init == false) {
diff --git a/source/blender/bmesh/intern/bmesh_walkers.h b/source/blender/bmesh/intern/bmesh_walkers.h
index ce0f8ae8324..d0348aa11dc 100644
--- a/source/blender/bmesh/intern/bmesh_walkers.h
+++ b/source/blender/bmesh/intern/bmesh_walkers.h
@@ -80,7 +80,7 @@ void *BMW_step(struct BMWalker *walker);
void BMW_end(struct BMWalker *walker);
int BMW_current_depth(BMWalker *walker);
-/*these are used by custom walkers*/
+/* These are used by custom walkers. */
void *BMW_current_state(BMWalker *walker);
void *BMW_state_add(BMWalker *walker);
void BMW_state_remove(BMWalker *walker);
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index a8558ec4011..40f09d7e719 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -1631,7 +1631,7 @@ static void *bmw_NonManifoldedgeWalker_yield(BMWalker *walker)
/**
* Walk over manifold loops around `v` until loop-edge is found with `face_count` users.
* or return NULL if not found.
- * */
+ */
static BMLoop *bmw_NonManifoldLoop_find_next_around_vertex(BMLoop *l, BMVert *v, int face_count)
{
BLI_assert(!BM_loop_is_manifold(l));
@@ -1667,7 +1667,7 @@ static void *bmw_NonManifoldedgeWalker_step(BMWalker *walker)
v = BM_edge_other_vert(e, lwalk->lastv);
/* If `lwalk.lastv` can't be walked along, start walking in the opposite direction
- * on the initial edge, do this at most one time during this walk operation. */
+ * on the initial edge, do this at most one time during this walk operation. */
if (UNLIKELY(pass == 1)) {
e = lwalk->start;
v = lwalk->startv;
diff --git a/source/blender/bmesh/operators/bmo_bisect_plane.c b/source/blender/bmesh/operators/bmo_bisect_plane.c
index 337437fb607..2663f271b6e 100644
--- a/source/blender/bmesh/operators/bmo_bisect_plane.c
+++ b/source/blender/bmesh/operators/bmo_bisect_plane.c
@@ -50,7 +50,7 @@ void bmo_bisect_plane_exec(BMesh *bm, BMOperator *op)
BMO_slot_vec_get(op->slots_in, "plane_no", plane_no);
if (is_zero_v3(plane_no)) {
- BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Zero normal given");
+ BMO_error_raise(bm, op, "Zero normal given");
return;
}
diff --git a/source/blender/bmesh/operators/bmo_bridge.c b/source/blender/bmesh/operators/bmo_bridge.c
index 0a6540c0e5e..005b8a2f5e8 100644
--- a/source/blender/bmesh/operators/bmo_bridge.c
+++ b/source/blender/bmesh/operators/bmo_bridge.c
@@ -576,13 +576,12 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
BM_mesh_edgeloops_calc_center(bm, &eloops);
if (count < 2) {
- BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Select at least two edge loops");
+ BMO_error_raise(bm, op, "Select at least two edge loops");
goto cleanup;
}
if (use_pairs && (count % 2)) {
- BMO_error_raise(
- bm, op, BMERR_INVALID_SELECTION, "Select an even number of loops to bridge pairs");
+ BMO_error_raise(bm, op, "Select an even number of loops to bridge pairs");
goto cleanup;
}
@@ -596,8 +595,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
}
}
if (!match) {
- BMO_error_raise(
- bm, op, BMERR_INVALID_SELECTION, "Selected loops must have equal edge counts");
+ BMO_error_raise(bm, op, "Selected loops must have equal edge counts");
goto cleanup;
}
}
diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c
index 0f0427373d9..b701c1291a6 100644
--- a/source/blender/bmesh/operators/bmo_connect.c
+++ b/source/blender/bmesh/operators/bmo_connect.c
@@ -211,7 +211,7 @@ void bmo_connect_verts_exec(BMesh *bm, BMOperator *op)
/* connect faces */
while ((f = BLI_LINKSTACK_POP(faces))) {
if (bm_face_connect_verts(bm, f, check_degenerate) == -1) {
- BMO_error_raise(bm, op, BMERR_CONNECTVERT_FAILED, NULL);
+ BMO_error_raise(bm, op, "Could not connect vertices");
}
}
diff --git a/source/blender/bmesh/operators/bmo_connect_pair.c b/source/blender/bmesh/operators/bmo_connect_pair.c
index 8a0673c9b33..b57c8686e1c 100644
--- a/source/blender/bmesh/operators/bmo_connect_pair.c
+++ b/source/blender/bmesh/operators/bmo_connect_pair.c
@@ -436,7 +436,7 @@ static bool state_step(PathContext *pc, PathLinkState *state)
BM_ITER_ELEM (l_start, &liter, e, BM_LOOPS_OF_EDGE) {
if ((l_start->f != ele_from) && FACE_WALK_TEST(l_start->f)) {
MinDistDir mddir = MIN_DIST_DIR_INIT;
- /* very similar to block below */
+ /* Very similar to block below. */
state = state_step__face_edges(pc, state, &state_orig, l_start->next, l_start, &mddir);
state = state_step__face_verts(
pc, state, &state_orig, l_start->next->next, l_start, &mddir);
@@ -446,7 +446,7 @@ static bool state_step(PathContext *pc, PathLinkState *state)
else if (ele->head.htype == BM_VERT) {
BMVert *v = (BMVert *)ele;
- /* vert loops */
+ /* Vert loops. */
{
BMIter liter;
BMLoop *l_start;
@@ -454,11 +454,11 @@ static bool state_step(PathContext *pc, PathLinkState *state)
BM_ITER_ELEM (l_start, &liter, v, BM_LOOPS_OF_VERT) {
if ((l_start->f != ele_from) && FACE_WALK_TEST(l_start->f)) {
MinDistDir mddir = MIN_DIST_DIR_INIT;
- /* very similar to block above */
+ /* Very similar to block above. */
state = state_step__face_edges(
pc, state, &state_orig, l_start->next, l_start->prev, &mddir);
if (l_start->f->len > 3) {
- /* adjacent verts are handled in state_step__vert_edges */
+ /* Adjacent verts are handled in #state_step__vert_edges. */
state = state_step__face_verts(
pc, state, &state_orig, l_start->next->next, l_start->prev, &mddir);
}
@@ -466,7 +466,7 @@ static bool state_step(PathContext *pc, PathLinkState *state)
}
}
- /* vert edges */
+ /* Vert edges. */
{
BMIter eiter;
BMEdge *e;
diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c
index 7813e30e2a8..30c80d43b9c 100644
--- a/source/blender/bmesh/operators/bmo_dissolve.c
+++ b/source/blender/bmesh/operators/bmo_dissolve.c
@@ -182,12 +182,6 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
BMO_face_flag_enable(bm, f_iter, FACE_ORIG);
}
- if (BMO_error_occurred(bm)) {
- BMO_error_clear(bm);
- BMO_error_raise(bm, op, BMERR_DISSOLVEFACES_FAILED, NULL);
- goto cleanup;
- }
-
BLI_array_append(faces, NULL);
BLI_array_append(regions, faces);
}
@@ -201,8 +195,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
faces = regions[i];
if (!faces[0]) {
- BMO_error_raise(
- bm, op, BMERR_DISSOLVEFACES_FAILED, "Could not find boundary of dissolve region");
+ BMO_error_raise(bm, op, "Could not find boundary of dissolve region");
goto cleanup;
}
@@ -220,7 +213,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
totface_target -= tot - 1;
}
else {
- BMO_error_raise(bm, op, BMERR_DISSOLVEFACES_FAILED, "Could not create merged face");
+ BMO_error_raise(bm, op, "Could not create merged face");
goto cleanup;
}
diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c
index c128872be07..d8b30fc1a45 100644
--- a/source/blender/bmesh/operators/bmo_dupe.c
+++ b/source/blender/bmesh/operators/bmo_dupe.c
@@ -363,10 +363,12 @@ void bmo_duplicate_exec(BMesh *bm, BMOperator *op)
}
#if 0 /* UNUSED */
-/* executes the duplicate operation, feeding elements of
- * type flag etypeflag and header flag flag to it. note,
- * to get more useful information (such as the mapping from
- * original to new elements) you should run the dupe op manually */
+/**
+ * executes the duplicate operation, feeding elements of
+ * type flag etypeflag and header flag to it.
+ * \note to get more useful information (such as the mapping from
+ * original to new elements) you should run the dupe op manually.
+ */
void BMO_dupe_from_flag(BMesh *bm, int htype, const char hflag)
{
BMOperator dupeop;
diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c
index 0a08b340e87..ffdce943d9f 100644
--- a/source/blender/bmesh/operators/bmo_extrude.c
+++ b/source/blender/bmesh/operators/bmo_extrude.c
@@ -459,8 +459,10 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
}
/* Allocate array to store possible vertices that will be dissolved. */
- int boundary_verts_len = BMO_slot_map_count(dupeop.slots_out, "boundary_map.out");
- dissolve_verts = MEM_mallocN((size_t)boundary_verts_len * sizeof(*dissolve_verts), __func__);
+ int boundary_edges_len = BMO_slot_map_count(dupeop.slots_out, "boundary_map.out");
+ /* We do not know the real number of boundary vertices. */
+ int boundary_verts_len_maybe = 2 * boundary_edges_len;
+ dissolve_verts = MEM_mallocN(boundary_verts_len_maybe * sizeof(*dissolve_verts), __func__);
}
BMO_slot_copy(&dupeop, slots_out, "geom.out", op, slots_out, "geom.out");
diff --git a/source/blender/bmesh/operators/bmo_fill_grid.c b/source/blender/bmesh/operators/bmo_fill_grid.c
index bb07a247a4e..4ba7dbad736 100644
--- a/source/blender/bmesh/operators/bmo_fill_grid.c
+++ b/source/blender/bmesh/operators/bmo_fill_grid.c
@@ -619,7 +619,6 @@ void bmo_grid_fill_exec(BMesh *bm, BMOperator *op)
* extract two 'rail' loops from a single edge loop, see T72075. */
BMO_error_raise(bm,
op,
- BMERR_INVALID_SELECTION,
"Select two edge loops "
"or a single closed edge loop from which two edge loops can be calculated");
goto cleanup;
@@ -634,7 +633,7 @@ void bmo_grid_fill_exec(BMesh *bm, BMOperator *op)
v_b_last = ((LinkData *)BM_edgeloop_verts_get(estore_b)->last)->data;
if (BM_edgeloop_is_closed(estore_a) || BM_edgeloop_is_closed(estore_b)) {
- BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Closed loops unsupported");
+ BMO_error_raise(bm, op, "Closed loops unsupported");
goto cleanup;
}
@@ -672,8 +671,7 @@ void bmo_grid_fill_exec(BMesh *bm, BMOperator *op)
bm_edgeloop_flag_set(estore_b, BM_ELEM_HIDDEN, false);
if (BLI_listbase_is_empty(&eloops_rail)) {
- BMO_error_raise(
- bm, op, BMERR_INVALID_SELECTION, "Loops are not connected by wire/boundary edges");
+ BMO_error_raise(bm, op, "Loops are not connected by wire/boundary edges");
goto cleanup;
}
@@ -681,7 +679,7 @@ void bmo_grid_fill_exec(BMesh *bm, BMOperator *op)
BLI_assert(v_a_last != v_b_last);
if (BM_edgeloop_overlap_check(estore_rail_a, estore_rail_b)) {
- BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Connecting edge loops overlap");
+ BMO_error_raise(bm, op, "Connecting edge loops overlap");
goto cleanup;
}
diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c
index 4876a12a923..956d55695d6 100644
--- a/source/blender/bmesh/operators/bmo_hull.c
+++ b/source/blender/bmesh/operators/bmo_hull.c
@@ -554,7 +554,7 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op)
/* Verify that at least three verts in the input */
if (!hull_num_input_verts_is_ok(op)) {
- BMO_error_raise(bm, op, BMERR_CONVEX_HULL_FAILED, "Requires at least three vertices");
+ BMO_error_raise(bm, op, "Requires at least three vertices");
return;
}
@@ -603,7 +603,7 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op)
bm, op, op->slots_out, "geom_interior.out", BM_ALL_NOLOOP, HULL_FLAG_INTERIOR_ELE);
/* Output slot of input elements that ended up inside the hull and
- * are are unused by other geometry. */
+ * are unused by other geometry. */
BMO_slot_buffer_from_enabled_flag(
bm, op, op->slots_out, "geom_unused.out", BM_ALL_NOLOOP, HULL_FLAG_DEL);
diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c
index 9e8e330e87c..3f6619cc2ee 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -361,7 +361,7 @@ static void bmo_face_inset_individual(BMesh *bm,
madd_v3_v3fl(v_new_co, tvec, thickness);
- /* Set normal, add depth and write new vertex position*/
+ /* Set normal, add depth and write new vertex position. */
copy_v3_v3(l_iter->v->no, f->no);
if (depth != 0.0f) {
@@ -1016,8 +1016,8 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
if (use_even_boundary) {
/**
- * This case where only one edge attached to #v_split
- * is used - ei - the face to inset is on a boundary.
+ * This case where only one edge attached to #v_split is used.
+ * i.e. the face to inset is on a boundary.
*
* <pre>
* We want the inset to align flush with the
diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c
index 086114f64e9..c3e96a9b08e 100644
--- a/source/blender/bmesh/operators/bmo_join_triangles.c
+++ b/source/blender/bmesh/operators/bmo_join_triangles.c
@@ -44,7 +44,7 @@ static float quad_calc_error(const float v1[3],
{
/* 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.. */
+ /* Note: this is more complicated than it needs to be and should be cleaned up. */
float error = 0.0f;
/* Normal difference */
diff --git a/source/blender/bmesh/operators/bmo_smooth_laplacian.c b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
index a9879ce025a..b2b93bfd003 100644
--- a/source/blender/bmesh/operators/bmo_smooth_laplacian.c
+++ b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
@@ -36,17 +36,17 @@
#define SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE 0.15f
struct BLaplacianSystem {
- float *eweights; /* Length weights per Edge */
- float (*fweights)[3]; /* Cotangent weights per face */
- float *ring_areas; /* Total area per ring*/
- float *vlengths; /* Total sum of lengths(edges) per vertice*/
- float *vweights; /* Total sum of weights per vertice*/
- int numEdges; /* Number of edges*/
- int numFaces; /* Number of faces*/
- int numVerts; /* Number of verts*/
- short *zerola; /* Is zero area or length*/
-
- /* Pointers to data*/
+ float *eweights; /* Length weights per Edge. */
+ float (*fweights)[3]; /* Cotangent weights per face. */
+ float *ring_areas; /* Total area per ring. */
+ float *vlengths; /* Total sum of lengths(edges) per vertex. */
+ float *vweights; /* Total sum of weights per vertex. */
+ int numEdges; /* Number of edges. */
+ int numFaces; /* Number of faces. */
+ int numVerts; /* Number of verts. */
+ short *zerola; /* Is zero area or length. */
+
+ /* Pointers to data. */
BMesh *bm;
BMOperator *op;
LinearSolver *context;
@@ -343,7 +343,7 @@ static void fill_laplacian_matrix(LaplacianSystem *sys)
idv1 = BM_elem_index_get(vf[0]);
idv2 = BM_elem_index_get(vf[1]);
idv3 = BM_elem_index_get(vf[2]);
- /* Is ring if number of faces == number of edges around vertice*/
+ /* Is ring if number of faces == number of edges around vertice. */
i = BM_elem_index_get(f);
if (!vert_is_boundary(vf[0]) && sys->zerola[idv1] == 0) {
EIG_linear_solver_matrix_add(
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c
index 883420e59f6..ae4fa65b55c 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -240,7 +240,7 @@ static void interp_slerp_co_no_v3(
}
}
-/* calculates offset for co, based on fractal, sphere or smooth settings */
+/* Calculates offset for co, based on fractal, sphere or smooth settings. */
static void alter_co(BMVert *v,
BMEdge *UNUSED(e_orig),
const SubDParams *params,
diff --git a/source/blender/bmesh/operators/bmo_subdivide_edgering.c b/source/blender/bmesh/operators/bmo_subdivide_edgering.c
index 16d7b79a028..d9bfe96ddc4 100644
--- a/source/blender/bmesh/operators/bmo_subdivide_edgering.c
+++ b/source/blender/bmesh/operators/bmo_subdivide_edgering.c
@@ -586,7 +586,7 @@ static void bm_edgering_pair_interpolate(BMesh *bm,
}
/* now normals are correct, don't touch! */
- /* calculate the center spline, multiple */
+ /* Calculate the center spline, multiple. */
if ((interp_mode == SUBD_RING_INTERP_PATH) || falloff_cache) {
float handle_a[3], handle_b[3];
float handle_len;
@@ -1028,7 +1028,7 @@ static void bm_edgering_pair_subdiv(BMesh *bm,
} while ((l_iter = l_iter->next) != l_first);
}
- /* clear tags so subdiv verts don't get tagged too */
+ /* Clear tags so subdiv verts don't get tagged too. */
for (el_store_ring = eloops_ring->first; el_store_ring;
el_store_ring = BM_EDGELOOP_NEXT(el_store_ring)) {
bm_edgeloop_vert_tag(el_store_ring, false);
@@ -1143,7 +1143,7 @@ void bmo_subdivide_edgering_exec(BMesh *bm, BMOperator *op)
count = BM_mesh_edgeloops_find(bm, &eloops_rim, bm_edge_rim_test_cb, (void *)bm);
if (count < 2) {
- BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "No edge rings found");
+ BMO_error_raise(bm, op, "No edge rings found");
goto cleanup;
}
else if (count == 2) {
@@ -1167,7 +1167,7 @@ void bmo_subdivide_edgering_exec(BMesh *bm, BMOperator *op)
changed = true;
}
else {
- BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Edge-ring pair isn't connected");
+ BMO_error_raise(bm, op, "Edge-ring pair isn't connected");
goto cleanup;
}
}
@@ -1179,7 +1179,7 @@ void bmo_subdivide_edgering_exec(BMesh *bm, BMOperator *op)
LoopPairStore **lpair_arr;
if (eloop_pairs_gs == NULL) {
- BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Edge-rings are not connected");
+ BMO_error_raise(bm, op, "Edge-rings are not connected");
goto cleanup;
}
diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c
index b07494345ab..f6d612f31eb 100644
--- a/source/blender/bmesh/operators/bmo_triangulate.c
+++ b/source/blender/bmesh/operators/bmo_triangulate.c
@@ -253,9 +253,6 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
BMO_face_flag_enable(bm, f_new, ELE_NEW);
BM_edge_kill(bm, e);
}
- else {
- BMO_error_clear(bm);
- }
}
else if (e->l == NULL) {
BM_edge_kill(bm, e);
diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c
index 2d9b35697ff..4ef165fe6c1 100644
--- a/source/blender/bmesh/tools/bmesh_beautify.c
+++ b/source/blender/bmesh/tools/bmesh_beautify.c
@@ -277,10 +277,10 @@ float BM_verts_calc_rotate_beauty(const BMVert *v1,
static float bm_edge_calc_rotate_beauty(const BMEdge *e, const short flag, const short method)
{
const BMVert *v1, *v2, *v3, *v4;
- v1 = e->l->prev->v; /* first vert co */
- v2 = e->l->v; /* e->v1 or e->v2*/
- v3 = e->l->radial_next->prev->v; /* second vert co */
- v4 = e->l->next->v; /* e->v1 or e->v2*/
+ v1 = e->l->prev->v; /* First vert co */
+ v2 = e->l->v; /* `e->v1` or `e->v2`. */
+ v3 = e->l->radial_next->prev->v; /* Second vert co */
+ v4 = e->l->next->v; /* `e->v1` or `e->v2`. */
return BM_verts_calc_rotate_beauty(v1, v2, v3, v4, flag, method);
}
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index d39fb5e81f1..65cceb8dcfd 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -288,7 +288,10 @@ typedef struct BevVert {
VMesh *vmesh;
} BevVert;
-/* Face classification. Note: depends on F_RECON > F_EDGE > F_VERT .*/
+/**
+ * Face classification.
+ * \note depends on `F_RECON > F_EDGE > F_VERT`.
+ */
typedef enum {
/** Used when there is no face at all. */
F_NONE,
@@ -1680,7 +1683,7 @@ static void project_to_edge(const BMEdge *e,
}
/* If there is a bndv->ebev edge, find the mid control point if necessary.
- * It is the closest point on the beveled edge to the line segment between bndv and bndv->next. */
+ * It is the closest point on the beveled edge to the line segment between bndv and bndv->next. */
static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
{
bool do_linear_interp = true;
@@ -2160,7 +2163,7 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, b
/* Calculate the 3D locations for the profile points */
calculate_profile_segments(
pro, map, use_map, reversed, bp->seg, pro_spacing->xvals, pro_spacing->yvals, pro->prof_co);
- /* Also calculate for the is the seg_2 case if it's needed .*/
+ /* Also calculate for the seg_2 case if it's needed. */
if (need_2) {
calculate_profile_segments(pro,
map,
@@ -2255,7 +2258,7 @@ static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag, bool neg)
{
EdgeHalf *e = &bv->edges[0], *efirst = &bv->edges[0];
- /* First first edge with seam or sharp edge data. */
+ /* First edge with seam or sharp edge data. */
while ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(e, flag)) ||
(neg && BEV_EXTEND_EDGE_DATA_CHECK(e, flag))) {
e = e->next;
diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
index 82878c7618a..a1630d9d2ff 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
@@ -568,9 +568,9 @@ static bool bm_decim_triangulate_begin(BMesh *bm, int *r_edges_tri_tot)
pf_heap = NULL;
}
- /* adding new faces as we loop over faces
+ /* Adding new faces as we loop over faces
* is normally best avoided, however in this case its not so bad because any face touched twice
- * will already be triangulated*/
+ * will already be triangulated. */
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
if (f->len > 3) {
has_cut |= bm_face_triangulate(bm,
diff --git a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
index 8b4a9bb26ac..036dae1b9bd 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
@@ -376,9 +376,6 @@ void BM_mesh_decimate_dissolve_ex(BMesh *bm,
}
} while ((l_iter = l_iter->next) != l_first);
}
- else {
- BMO_error_clear(bm);
- }
}
if (UNLIKELY(f_new == NULL)) {
diff --git a/source/blender/bmesh/tools/bmesh_intersect.c b/source/blender/bmesh/tools/bmesh_intersect.c
index cc980a81aad..d51661a08bb 100644
--- a/source/blender/bmesh/tools/bmesh_intersect.c
+++ b/source/blender/bmesh/tools/bmesh_intersect.c
@@ -379,7 +379,7 @@ static BMVert *bm_isect_edge_tri(struct ISectState *s,
} \
(void)0
- /* order tri, then order (1-2, 2-3)*/
+ /* Order tri, then order (1-2, 2-3). */
#define KEY_EDGE_TRI_ORDER(k) \
{ \
if (k[2] > k[3]) { \
diff --git a/source/blender/bmesh/tools/bmesh_separate.c b/source/blender/bmesh/tools/bmesh_separate.c
index 701c7dc7e03..3c69ea111bf 100644
--- a/source/blender/bmesh/tools/bmesh_separate.c
+++ b/source/blender/bmesh/tools/bmesh_separate.c
@@ -67,7 +67,7 @@ void BM_mesh_separate_faces(BMesh *bm, BMFaceFilterFunc filter_fn, void *user_da
BMFace **faces_a = faces_array_all;
BMFace **faces_b = faces_array_all + faces_a_len;
- /* Enable for all */
+ /* Enable for all. */
BM_mesh_elem_hflag_enable_all(bm, BM_VERT, BM_ELEM_TAG, false);
/* Disable vert tag on faces_b */
diff --git a/source/blender/bmesh/tools/bmesh_wireframe.c b/source/blender/bmesh/tools/bmesh_wireframe.c
index a3db93be033..de2deee2929 100644
--- a/source/blender/bmesh/tools/bmesh_wireframe.c
+++ b/source/blender/bmesh/tools/bmesh_wireframe.c
@@ -195,7 +195,7 @@ void BM_mesh_wireframe(BMesh *bm,
BMVert **verts_neg = MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__);
BMVert **verts_pos = MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__);
- /* will over-alloc, but makes for easy lookups by index to keep aligned */
+ /* Will over-alloc, but makes for easy lookups by index to keep aligned. */
BMVert **verts_boundary = use_boundary ? MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__) :
NULL;
diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h
index 5a52d216117..857cbf0beee 100644
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@ -62,6 +62,24 @@ constexpr int COM_data_type_num_channels(const DataType datatype)
constexpr int COM_DATA_TYPE_VALUE_CHANNELS = COM_data_type_num_channels(DataType::Value);
constexpr int COM_DATA_TYPE_COLOR_CHANNELS = COM_data_type_num_channels(DataType::Color);
+constexpr float COM_VALUE_ZERO[1] = {0.0f};
+
+/**
+ * Utility to get data type for given number of channels.
+ */
+constexpr DataType COM_num_channels_data_type(const int num_channels)
+{
+ switch (num_channels) {
+ case 1:
+ return DataType::Value;
+ case 3:
+ return DataType::Vector;
+ case 4:
+ default:
+ return DataType::Color;
+ }
+}
+
// configurable items
// chunk size determination
diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h
index 56251511576..403ec62e359 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.h
+++ b/source/blender/compositor/intern/COM_CompositorContext.h
@@ -171,7 +171,7 @@ class CompositorContext {
}
/**
- * \brief set view settings of color color management
+ * \brief set view settings of color management
*/
void setViewSettings(const ColorManagedViewSettings *viewSettings)
{
@@ -179,7 +179,7 @@ class CompositorContext {
}
/**
- * \brief get view settings of color color management
+ * \brief get view settings of color management
*/
const ColorManagedViewSettings *getViewSettings() const
{
@@ -187,7 +187,7 @@ class CompositorContext {
}
/**
- * \brief set display settings of color color management
+ * \brief set display settings of color management
*/
void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings)
{
@@ -195,7 +195,7 @@ class CompositorContext {
}
/**
- * \brief get display settings of color color management
+ * \brief get display settings of color management
*/
const ColorManagedDisplaySettings *getDisplaySettings() const
{
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cc b/source/blender/compositor/intern/COM_MemoryBuffer.cc
index 8c30d3215d7..44d3f059374 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cc
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cc
@@ -18,10 +18,31 @@
#include "COM_MemoryBuffer.h"
+#include "IMB_colormanagement.h"
+#include "IMB_imbuf_types.h"
#include "MEM_guardedalloc.h"
+#define ASSERT_BUFFER_CONTAINS_AREA(buf, area) \
+ BLI_assert(BLI_rcti_inside_rcti(&(buf)->get_rect(), &(area)))
+
+#define ASSERT_BUFFER_CONTAINS_AREA_AT_COORDS(buf, area, x, y) \
+ BLI_assert((buf)->get_rect().xmin <= (x)); \
+ BLI_assert((buf)->get_rect().ymin <= (y)); \
+ BLI_assert((buf)->get_rect().xmax >= (x) + BLI_rcti_size_x(&(area))); \
+ BLI_assert((buf)->get_rect().ymax >= (y) + BLI_rcti_size_y(&(area)))
+
+#define ASSERT_VALID_ELEM_SIZE(buf, channel_offset, elem_size) \
+ BLI_assert((buf)->get_num_channels() <= (channel_offset) + (elem_size))
+
namespace blender::compositor {
+static rcti create_rect(const int width, const int height)
+{
+ rcti rect;
+ BLI_rcti_init(&rect, 0, width, 0, height);
+ return rect;
+}
+
MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBufferState state)
{
m_rect = rect;
@@ -30,6 +51,7 @@ MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBuf
this->m_num_channels = COM_data_type_num_channels(memoryProxy->getDataType());
this->m_buffer = (float *)MEM_mallocN_aligned(
sizeof(float) * buffer_len() * this->m_num_channels, 16, "COM_MemoryBuffer");
+ owns_data_ = true;
this->m_state = state;
this->m_datatype = memoryProxy->getDataType();
@@ -44,12 +66,44 @@ MemoryBuffer::MemoryBuffer(DataType dataType, const rcti &rect, bool is_a_single
this->m_num_channels = COM_data_type_num_channels(dataType);
this->m_buffer = (float *)MEM_mallocN_aligned(
sizeof(float) * buffer_len() * this->m_num_channels, 16, "COM_MemoryBuffer");
+ owns_data_ = true;
this->m_state = MemoryBufferState::Temporary;
this->m_datatype = dataType;
set_strides();
}
+/**
+ * Construct MemoryBuffer from a float buffer. MemoryBuffer is not responsible for
+ * freeing it.
+ */
+MemoryBuffer::MemoryBuffer(
+ float *buffer, int num_channels, int width, int height, bool is_a_single_elem)
+ : MemoryBuffer(buffer, num_channels, create_rect(width, height), is_a_single_elem)
+{
+}
+
+/**
+ * Construct MemoryBuffer from a float buffer area. MemoryBuffer is not responsible for
+ * freeing given buffer.
+ */
+MemoryBuffer::MemoryBuffer(float *buffer,
+ const int num_channels,
+ const rcti &rect,
+ const bool is_a_single_elem)
+{
+ m_rect = rect;
+ m_is_a_single_elem = is_a_single_elem;
+ m_memoryProxy = nullptr;
+ m_num_channels = num_channels;
+ m_datatype = COM_num_channels_data_type(num_channels);
+ m_buffer = buffer;
+ owns_data_ = false;
+ m_state = MemoryBufferState::Temporary;
+
+ set_strides();
+}
+
MemoryBuffer::MemoryBuffer(const MemoryBuffer &src)
: MemoryBuffer(src.m_datatype, src.m_rect, false)
{
@@ -112,31 +166,195 @@ float MemoryBuffer::get_max_value(const rcti &rect) const
MemoryBuffer::~MemoryBuffer()
{
- if (this->m_buffer) {
+ if (this->m_buffer && owns_data_) {
MEM_freeN(this->m_buffer);
this->m_buffer = nullptr;
}
}
-void MemoryBuffer::fill_from(const MemoryBuffer &src)
+void MemoryBuffer::copy_from(const MemoryBuffer *src, const rcti &area)
{
- BLI_assert(!this->is_a_single_elem());
+ copy_from(src, area, area.xmin, area.ymin);
+}
+
+void MemoryBuffer::copy_from(const MemoryBuffer *src,
+ const rcti &area,
+ const int to_x,
+ const int to_y)
+{
+ BLI_assert(this->get_num_channels() == src->get_num_channels());
+ copy_from(src, area, 0, src->get_num_channels(), to_x, to_y, 0);
+}
+
+void MemoryBuffer::copy_from(const MemoryBuffer *src,
+ const rcti &area,
+ const int channel_offset,
+ const int elem_size,
+ const int to_channel_offset)
+{
+ copy_from(src, area, channel_offset, elem_size, area.xmin, area.ymin, to_channel_offset);
+}
+
+void MemoryBuffer::copy_from(const MemoryBuffer *src,
+ const rcti &area,
+ const int channel_offset,
+ const int elem_size,
+ const int to_x,
+ const int to_y,
+ const int to_channel_offset)
+{
+ if (this->is_a_single_elem()) {
+ copy_single_elem_from(src, channel_offset, elem_size, to_channel_offset);
+ }
+ else if (!src->is_a_single_elem() && elem_size == src->get_num_channels() &&
+ elem_size == this->get_num_channels()) {
+ BLI_assert(to_channel_offset == 0);
+ BLI_assert(channel_offset == 0);
+ copy_rows_from(src, area, to_x, to_y);
+ }
+ else {
+ copy_elems_from(src, area, channel_offset, elem_size, to_x, to_y, to_channel_offset);
+ }
+}
+
+void MemoryBuffer::copy_from(const uchar *src, const rcti &area)
+{
+ copy_from(src, area, 0, this->get_num_channels(), this->get_num_channels(), 0);
+}
+
+void MemoryBuffer::copy_from(const uchar *src,
+ const rcti &area,
+ const int channel_offset,
+ const int elem_size,
+ const int elem_stride,
+ const int to_channel_offset)
+{
+ copy_from(
+ src, area, channel_offset, elem_size, elem_stride, area.xmin, area.ymin, to_channel_offset);
+}
+
+void MemoryBuffer::copy_from(const uchar *src,
+ const rcti &area,
+ const int channel_offset,
+ const int elem_size,
+ const int elem_stride,
+ const int to_x,
+ const int to_y,
+ const int to_channel_offset)
+{
+ ASSERT_BUFFER_CONTAINS_AREA_AT_COORDS(this, area, to_x, to_y);
+ ASSERT_VALID_ELEM_SIZE(this, to_channel_offset, elem_size);
+
+ const int width = BLI_rcti_size_x(&area);
+ const int height = BLI_rcti_size_y(&area);
+ const int src_row_stride = width * elem_stride;
+ const uchar *const src_start = src + area.ymin * src_row_stride + channel_offset;
+ for (int y = 0; y < height; y++) {
+ const uchar *from_elem = src_start + y * src_row_stride;
+ float *to_elem = &this->get_value(to_x, to_y + y, to_channel_offset);
+ const float *row_end = to_elem + width * this->elem_stride;
+ while (to_elem < row_end) {
+ for (int i = 0; i < elem_size; i++) {
+ to_elem[i] = ((float)from_elem[i]) * (1.0f / 255.0f);
+ }
+ to_elem += this->elem_stride;
+ from_elem += elem_stride;
+ }
+ }
+}
+
+static void colorspace_to_scene_linear(MemoryBuffer *buf, const rcti &area, ColorSpace *colorspace)
+{
+ const int width = BLI_rcti_size_x(&area);
+ const int height = BLI_rcti_size_y(&area);
+ float *out = buf->get_elem(area.xmin, area.ymin);
+ /* If area allows continuous memory do conversion in one step. Otherwise per row. */
+ if (buf->getWidth() == width) {
+ IMB_colormanagement_colorspace_to_scene_linear(
+ out, width, height, buf->get_num_channels(), colorspace, false);
+ }
+ else {
+ for (int y = 0; y < height; y++) {
+ IMB_colormanagement_colorspace_to_scene_linear(
+ out, width, 1, buf->get_num_channels(), colorspace, false);
+ out += buf->row_stride;
+ }
+ }
+}
+
+void MemoryBuffer::copy_from(const ImBuf *src, const rcti &area, const bool ensure_linear_space)
+{
+ copy_from(src, area, 0, this->get_num_channels(), 0, ensure_linear_space);
+}
- unsigned int otherY;
- unsigned int minX = MAX2(this->m_rect.xmin, src.m_rect.xmin);
- unsigned int maxX = MIN2(this->m_rect.xmax, src.m_rect.xmax);
- unsigned int minY = MAX2(this->m_rect.ymin, src.m_rect.ymin);
- unsigned int maxY = MIN2(this->m_rect.ymax, src.m_rect.ymax);
- int offset;
- int otherOffset;
+void MemoryBuffer::copy_from(const ImBuf *src,
+ const rcti &area,
+ const int channel_offset,
+ const int elem_size,
+ const int to_channel_offset,
+ const bool ensure_linear_space)
+{
+ copy_from(src,
+ area,
+ channel_offset,
+ elem_size,
+ area.xmin,
+ area.ymin,
+ to_channel_offset,
+ ensure_linear_space);
+}
- for (otherY = minY; otherY < maxY; otherY++) {
- otherOffset = src.get_coords_offset(minX, otherY);
- offset = this->get_coords_offset(minX, otherY);
- memcpy(&this->m_buffer[offset],
- &src.m_buffer[otherOffset],
- (maxX - minX) * this->m_num_channels * sizeof(float));
+void MemoryBuffer::copy_from(const ImBuf *src,
+ const rcti &area,
+ const int channel_offset,
+ const int elem_size,
+ const int to_x,
+ const int to_y,
+ const int to_channel_offset,
+ const bool ensure_linear_space)
+{
+ if (src->rect_float) {
+ const MemoryBuffer mem_buf(src->rect_float, src->channels, src->x, src->y, false);
+ copy_from(&mem_buf, area, channel_offset, elem_size, to_x, to_y, to_channel_offset);
}
+ else if (src->rect) {
+ const uchar *uc_buf = (uchar *)src->rect;
+ const int elem_stride = src->channels;
+ copy_from(uc_buf, area, channel_offset, elem_size, elem_stride, to_x, to_y, to_channel_offset);
+ if (ensure_linear_space) {
+ colorspace_to_scene_linear(this, area, src->rect_colorspace);
+ }
+ }
+ else {
+ /* Empty ImBuf source. Fill destination with empty values. */
+ const float *zero_elem = new float[elem_size]{0};
+ fill(area, to_channel_offset, zero_elem, elem_size);
+ delete[] zero_elem;
+ }
+}
+
+void MemoryBuffer::fill(const rcti &area, const float *value)
+{
+ fill(area, 0, value, this->get_num_channels());
+}
+
+void MemoryBuffer::fill(const rcti &area,
+ const int channel_offset,
+ const float *value,
+ const int value_size)
+{
+ const MemoryBuffer single_elem(const_cast<float *>(value), value_size, this->get_rect(), true);
+ copy_from(&single_elem, area, 0, value_size, area.xmin, area.ymin, channel_offset);
+}
+
+void MemoryBuffer::fill_from(const MemoryBuffer &src)
+{
+ rcti overlap;
+ overlap.xmin = MAX2(this->m_rect.xmin, src.m_rect.xmin);
+ overlap.xmax = MIN2(this->m_rect.xmax, src.m_rect.xmax);
+ overlap.ymin = MAX2(this->m_rect.ymin, src.m_rect.ymin);
+ overlap.ymax = MIN2(this->m_rect.ymax, src.m_rect.ymax);
+ copy_from(&src, overlap);
}
void MemoryBuffer::writePixel(int x, int y, const float color[4])
@@ -196,4 +414,70 @@ void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivat
}
}
+void MemoryBuffer::copy_single_elem_from(const MemoryBuffer *src,
+ const int channel_offset,
+ const int elem_size,
+ const int to_channel_offset)
+{
+ ASSERT_VALID_ELEM_SIZE(this, to_channel_offset, elem_size);
+ ASSERT_VALID_ELEM_SIZE(src, channel_offset, elem_size);
+ BLI_assert(this->is_a_single_elem());
+
+ float *to_elem = &this->get_value(
+ this->get_rect().xmin, this->get_rect().ymin, to_channel_offset);
+ const float *from_elem = &src->get_value(
+ src->get_rect().xmin, src->get_rect().ymin, channel_offset);
+ const int elem_bytes = elem_size * sizeof(float);
+ memcpy(to_elem, from_elem, elem_bytes);
+}
+
+void MemoryBuffer::copy_rows_from(const MemoryBuffer *src,
+ const rcti &area,
+ const int to_x,
+ const int to_y)
+{
+ ASSERT_BUFFER_CONTAINS_AREA(src, area);
+ ASSERT_BUFFER_CONTAINS_AREA_AT_COORDS(this, area, to_x, to_y);
+ BLI_assert(this->get_num_channels() == src->get_num_channels());
+ BLI_assert(!this->is_a_single_elem());
+ BLI_assert(!src->is_a_single_elem());
+
+ const int width = BLI_rcti_size_x(&area);
+ const int height = BLI_rcti_size_y(&area);
+ const int row_bytes = this->get_num_channels() * width * sizeof(float);
+ for (int y = 0; y < height; y++) {
+ float *to_row = this->get_elem(to_x, to_y + y);
+ const float *from_row = src->get_elem(area.xmin, area.ymin + y);
+ memcpy(to_row, from_row, row_bytes);
+ }
+}
+
+void MemoryBuffer::copy_elems_from(const MemoryBuffer *src,
+ const rcti &area,
+ const int channel_offset,
+ const int elem_size,
+ const int to_x,
+ const int to_y,
+ const int to_channel_offset)
+{
+ ASSERT_BUFFER_CONTAINS_AREA(src, area);
+ ASSERT_BUFFER_CONTAINS_AREA_AT_COORDS(this, area, to_x, to_y);
+ ASSERT_VALID_ELEM_SIZE(this, to_channel_offset, elem_size);
+ ASSERT_VALID_ELEM_SIZE(src, channel_offset, elem_size);
+
+ const int width = BLI_rcti_size_x(&area);
+ const int height = BLI_rcti_size_y(&area);
+ const int elem_bytes = elem_size * sizeof(float);
+ for (int y = 0; y < height; y++) {
+ float *to_elem = &this->get_value(to_x, to_y + y, to_channel_offset);
+ const float *from_elem = &src->get_value(area.xmin, area.ymin + y, channel_offset);
+ const float *row_end = to_elem + width * this->elem_stride;
+ while (to_elem < row_end) {
+ memcpy(to_elem, from_elem, elem_bytes);
+ to_elem += this->elem_stride;
+ from_elem += src->elem_stride;
+ }
+ }
+}
+
} // namespace blender::compositor
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index 045dc996e3e..fdfd1c1c37b 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -34,7 +34,7 @@ enum class MemoryBufferState {
/** \brief memory has been allocated on creator device and CPU machine,
* but kernel has not been executed */
Default = 0,
- /** \brief chunk is consolidated from other chunks. special state.*/
+ /** \brief chunk is consolidated from other chunks. special state. */
Temporary = 6,
};
@@ -106,6 +106,11 @@ class MemoryBuffer {
*/
bool m_is_a_single_elem;
+ /**
+ * Whether MemoryBuffer owns buffer data.
+ */
+ bool owns_data_;
+
public:
/**
* \brief construct new temporarily MemoryBuffer for an area
@@ -117,6 +122,11 @@ class MemoryBuffer {
*/
MemoryBuffer(DataType datatype, const rcti &rect, bool is_a_single_elem = false);
+ MemoryBuffer(
+ float *buffer, int num_channels, int width, int height, bool is_a_single_elem = false);
+
+ MemoryBuffer(float *buffer, int num_channels, const rcti &rect, bool is_a_single_elem = false);
+
/**
* Copy constructor
*/
@@ -223,7 +233,7 @@ class MemoryBuffer {
return is_a_single_elem() ? 1 : getHeight();
}
- uint8_t get_num_channels()
+ uint8_t get_num_channels() const
{
return this->m_num_channels;
}
@@ -404,6 +414,53 @@ class MemoryBuffer {
return this->m_state == MemoryBufferState::Temporary;
}
+ void copy_from(const MemoryBuffer *src, const rcti &area);
+ void copy_from(const MemoryBuffer *src, const rcti &area, int to_x, int to_y);
+ void copy_from(const MemoryBuffer *src,
+ const rcti &area,
+ int channel_offset,
+ int elem_size,
+ int to_channel_offset);
+ void copy_from(const MemoryBuffer *src,
+ const rcti &area,
+ int channel_offset,
+ int elem_size,
+ int to_x,
+ int to_y,
+ int to_channel_offset);
+ void copy_from(const uchar *src, const rcti &area);
+ void copy_from(const uchar *src,
+ const rcti &area,
+ int channel_offset,
+ int elem_size,
+ int elem_stride,
+ int to_channel_offset);
+ void copy_from(const uchar *src,
+ const rcti &area,
+ int channel_offset,
+ int elem_size,
+ int elem_stride,
+ int to_x,
+ int to_y,
+ int to_channel_offset);
+ void copy_from(const struct ImBuf *src, const rcti &area, bool ensure_linear_space = false);
+ void copy_from(const struct ImBuf *src,
+ const rcti &area,
+ int channel_offset,
+ int elem_size,
+ int to_channel_offset,
+ bool ensure_linear_space = false);
+ void copy_from(const struct ImBuf *src,
+ const rcti &src_area,
+ int channel_offset,
+ int elem_size,
+ int to_x,
+ int to_y,
+ int to_channel_offset,
+ bool ensure_linear_space = false);
+
+ void fill(const rcti &area, const float *value);
+ void fill(const rcti &area, int channel_offset, const float *value, int value_size);
/**
* \brief add the content from otherBuffer to this MemoryBuffer
* \param otherBuffer: source buffer
@@ -452,6 +509,22 @@ class MemoryBuffer {
return get_memory_width() * get_memory_height();
}
+ void copy_single_elem_from(const MemoryBuffer *src,
+ int channel_offset,
+ int elem_size,
+ const int to_channel_offset);
+ void copy_rows_from(const MemoryBuffer *src,
+ const rcti &src_area,
+ const int to_x,
+ const int to_y);
+ void copy_elems_from(const MemoryBuffer *src,
+ const rcti &area,
+ const int channel_offset,
+ const int elem_size,
+ const int to_x,
+ const int to_y,
+ const int to_channel_offset);
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryBuffer")
#endif
diff --git a/source/blender/compositor/intern/COM_MetaData.cc b/source/blender/compositor/intern/COM_MetaData.cc
index 88bfa385514..a6fb84dfb87 100644
--- a/source/blender/compositor/intern/COM_MetaData.cc
+++ b/source/blender/compositor/intern/COM_MetaData.cc
@@ -41,7 +41,7 @@ void MetaData::addCryptomatteEntry(const blender::StringRef layer_name,
/* Replace the hash neutral cryptomatte keys with hashed versions.
*
* When a conversion happens it will also add the cryptomatte name key with the given
- * `layer_name`.*/
+ * `layer_name`. */
void MetaData::replaceHashNeutralCryptomatteKeys(const blender::StringRef layer_name)
{
std::string cryptomatte_hash = entries_.pop_default(META_DATA_KEY_CRYPTOMATTE_HASH, "");
diff --git a/source/blender/compositor/intern/COM_MultiThreadedOperation.cc b/source/blender/compositor/intern/COM_MultiThreadedOperation.cc
index aebc3d5671c..e6e98d69b36 100644
--- a/source/blender/compositor/intern/COM_MultiThreadedOperation.cc
+++ b/source/blender/compositor/intern/COM_MultiThreadedOperation.cc
@@ -16,11 +16,11 @@ void MultiThreadedOperation::update_memory_buffer(MemoryBuffer *output,
ExecutionSystem &exec_system)
{
for (current_pass_ = 0; current_pass_ < num_passes_; current_pass_++) {
- update_memory_buffer_started(output, area, inputs, exec_system);
- exec_system.execute_work(area, [=, &exec_system](const rcti &split_rect) {
- update_memory_buffer_partial(output, split_rect, inputs, exec_system);
+ update_memory_buffer_started(output, area, inputs);
+ exec_system.execute_work(area, [=](const rcti &split_rect) {
+ update_memory_buffer_partial(output, split_rect, inputs);
});
- update_memory_buffer_finished(output, area, inputs, exec_system);
+ update_memory_buffer_finished(output, area, inputs);
}
}
diff --git a/source/blender/compositor/intern/COM_MultiThreadedOperation.h b/source/blender/compositor/intern/COM_MultiThreadedOperation.h
index d30201a7dcf..ad09c4df089 100644
--- a/source/blender/compositor/intern/COM_MultiThreadedOperation.h
+++ b/source/blender/compositor/intern/COM_MultiThreadedOperation.h
@@ -41,8 +41,7 @@ class MultiThreadedOperation : public NodeOperation {
*/
virtual void update_memory_buffer_started(MemoryBuffer *UNUSED(output),
const rcti &UNUSED(area),
- Span<MemoryBuffer *> UNUSED(inputs),
- ExecutionSystem &UNUSED(exec_system))
+ Span<MemoryBuffer *> UNUSED(inputs))
{
}
@@ -51,16 +50,14 @@ class MultiThreadedOperation : public NodeOperation {
*/
virtual void update_memory_buffer_partial(MemoryBuffer *output,
const rcti &area,
- Span<MemoryBuffer *> inputs,
- ExecutionSystem &exec_system) = 0;
+ Span<MemoryBuffer *> inputs) = 0;
/**
* Called after an update memory buffer pass is executed. Single-threaded calls.
*/
virtual void update_memory_buffer_finished(MemoryBuffer *UNUSED(output),
const rcti &UNUSED(area),
- Span<MemoryBuffer *> UNUSED(inputs),
- ExecutionSystem &UNUSED(exec_system))
+ Span<MemoryBuffer *> UNUSED(inputs))
{
}
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cc b/source/blender/compositor/nodes/COM_OutputFileNode.cc
index e5b9cfb8cc2..8b5140636c1 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.cc
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.cc
@@ -96,7 +96,7 @@ void OutputFileNode::convertToOperations(NodeConverter &converter,
converter.addOperation(outputOperation);
/* First add all inputs. Inputs are stored in a Vector and can be moved to a different
- * memory address during this time.*/
+ * memory address during this time. */
add_input_sockets(*outputOperation);
/* After adding the sockets the memory addresses will stick. */
map_input_sockets(converter, *outputOperation);
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cc b/source/blender/compositor/operations/COM_AntiAliasOperation.cc
index 23d6f4b80c7..deccbb28f49 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.cc
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cc
@@ -202,4 +202,72 @@ void *AntiAliasOperation::initializeTileData(rcti *rect)
return getInputOperation(0)->initializeTileData(rect);
}
+void AntiAliasOperation::get_area_of_interest(const int input_idx,
+ const rcti &output_area,
+ rcti &r_input_area)
+{
+ BLI_assert(input_idx == 0);
+ UNUSED_VARS_NDEBUG(input_idx);
+ r_input_area.xmax = output_area.xmax + 1;
+ r_input_area.xmin = output_area.xmin - 1;
+ r_input_area.ymax = output_area.ymax + 1;
+ r_input_area.ymin = output_area.ymin - 1;
+}
+
+void AntiAliasOperation::update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs)
+{
+ const MemoryBuffer *input = inputs[0];
+ const rcti &input_area = input->get_rect();
+ float ninepix[9];
+ for (int y = area.ymin; y < area.ymax; y++) {
+ float *out = output->get_elem(area.xmin, y);
+ const float *row_curr = input->get_elem(area.xmin, y);
+ const float *row_prev = row_curr - input->row_stride;
+ const float *row_next = row_curr + input->row_stride;
+ int x_offset = 0;
+ for (int x = area.xmin; x < area.xmax;
+ x++, out += output->elem_stride, x_offset += input->elem_stride) {
+ if (x == input_area.xmin || x == input_area.xmax - 1 || y == input_area.xmin ||
+ y == input_area.ymax - 1) {
+ out[0] = row_curr[x_offset];
+ continue;
+ }
+
+ if (extrapolate9(&ninepix[0],
+ &ninepix[1],
+ &ninepix[2],
+ &ninepix[3],
+ &ninepix[4],
+ &ninepix[5],
+ &ninepix[6],
+ &ninepix[7],
+ &ninepix[8],
+ &row_prev[x_offset - input->elem_stride],
+ &row_prev[x_offset],
+ &row_prev[x_offset + input->elem_stride],
+ &row_curr[x_offset - input->elem_stride],
+ &row_curr[x_offset],
+ &row_curr[x_offset + input->elem_stride],
+ &row_next[x_offset - input->elem_stride],
+ &row_next[x_offset],
+ &row_next[x_offset + input->elem_stride])) {
+ /* Some rounding magic to make weighting correct with the
+ * original coefficients. */
+ unsigned char result = ((3 * ninepix[0] + 5 * ninepix[1] + 3 * ninepix[2] +
+ 5 * ninepix[3] + 6 * ninepix[4] + 5 * ninepix[5] +
+ 3 * ninepix[6] + 5 * ninepix[7] + 3 * ninepix[8]) *
+ 255.0f +
+ 19.0f) /
+ 38.0f;
+ out[0] = result / 255.0f;
+ }
+ else {
+ out[0] = row_curr[x_offset];
+ }
+ }
+ }
+}
+
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.h b/source/blender/compositor/operations/COM_AntiAliasOperation.h
index fc9102b5b4c..b5048248425 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.h
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.h
@@ -18,7 +18,7 @@
#pragma once
-#include "COM_NodeOperation.h"
+#include "COM_MultiThreadedOperation.h"
#include "DNA_node_types.h"
namespace blender::compositor {
@@ -28,7 +28,7 @@ namespace blender::compositor {
* it only supports anti aliasing on BW buffers.
* \ingroup operation
*/
-class AntiAliasOperation : public NodeOperation {
+class AntiAliasOperation : public MultiThreadedOperation {
protected:
/**
* \brief Cached reference to the reader
@@ -57,6 +57,12 @@ class AntiAliasOperation : public NodeOperation {
bool determineDependingAreaOfInterest(rcti *input,
ReadBufferOperation *readOperation,
rcti *output) override;
+
+ void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
+
+ void update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs) override;
};
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cc b/source/blender/compositor/operations/COM_ChannelMatteOperation.cc
index 89290978608..ec4331dc231 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cc
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cc
@@ -104,12 +104,12 @@ void ChannelMatteOperation::executePixelSampled(float output[4],
/* test range */
if (alpha > limit_max) {
- alpha = inColor[3]; /*whatever it was prior */
+ alpha = inColor[3]; /* Whatever it was prior. */
}
else if (alpha < limit_min) {
alpha = 0.0f;
}
- else { /*blend */
+ else { /* Blend. */
alpha = (alpha - limit_min) / limit_range;
}
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cc b/source/blender/compositor/operations/COM_ChromaMatteOperation.cc
index 69aa4aac163..b7fec5f07e5 100644
--- a/source/blender/compositor/operations/COM_ChromaMatteOperation.cc
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cc
@@ -79,12 +79,12 @@ void ChromaMatteOperation::executePixelSampled(float output[4],
theta = atan2(inKey[2], inKey[1]);
- /*rotate the cb and cr into x/z space */
+ /* Rotate the cb and cr into x/z space. */
x_angle = inImage[1] * cosf(theta) + inImage[2] * sinf(theta);
z_angle = inImage[2] * cosf(theta) - inImage[1] * sinf(theta);
- /*if within the acceptance angle */
- /* if kfg is <0 then the pixel is outside of the key color */
+ /* If within the acceptance angle. */
+ /* If kfg is <0 then the pixel is outside of the key color. */
kfg = x_angle - (fabsf(z_angle) / tanf(acceptance / 2.0f));
if (kfg > 0.0f) { /* found a pixel that is within key color */
@@ -105,8 +105,8 @@ void ChromaMatteOperation::executePixelSampled(float output[4],
output[0] = inImage[3];
}
}
- else { /*pixel is outside key color */
- output[0] = inImage[3]; /* make pixel just as transparent as it was before */
+ else { /* Pixel is outside key color. */
+ output[0] = inImage[3]; /* Make pixel just as transparent as it was before. */
}
}
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cc b/source/blender/compositor/operations/COM_ColorMatteOperation.cc
index 89f56ac4aae..ddfbf415d9c 100644
--- a/source/blender/compositor/operations/COM_ColorMatteOperation.cc
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cc
@@ -65,7 +65,7 @@ void ColorMatteOperation::executePixelSampled(float output[4],
*/
if (
- /* do hue last because it needs to wrap, and does some more checks */
+ /* Do hue last because it needs to wrap, and does some more checks. */
/* sat */ (fabsf(inColor[1] - inKey[1]) < sat) &&
/* val */ (fabsf(inColor[2] - inKey[2]) < val) &&
@@ -77,8 +77,8 @@ void ColorMatteOperation::executePixelSampled(float output[4],
output[0] = 0.0f; /* make transparent */
}
- else { /*pixel is outside key color */
- output[0] = inColor[3]; /* make pixel just as transparent as it was before */
+ else { /* Pixel is outside key color. */
+ output[0] = inColor[3]; /* Make pixel just as transparent as it was before. */
}
}
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cc b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cc
index e380131634f..0acdfc1651f 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cc
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cc
@@ -68,11 +68,11 @@ void DifferenceMatteOperation::executePixelSampled(float output[4],
if (difference <= tolerance) {
output[0] = 0.0f;
}
- /*in the falloff region, make partially transparent */
+ /* In the falloff region, make partially transparent. */
else if (difference <= falloff + tolerance) {
difference = difference - tolerance;
alpha = difference / falloff;
- /*only change if more transparent than before */
+ /* Only change if more transparent than before. */
if (alpha < inColor1[3]) {
output[0] = alpha;
}
diff --git a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cc b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cc
index 12cb7e7d075..1b3403cbb29 100644
--- a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cc
+++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cc
@@ -71,15 +71,15 @@ void DistanceRGBMatteOperation::executePixelSampled(float output[4],
* COM_SetAlphaMultiplyOperation and the Value output.
*/
- /*make 100% transparent */
+ /* Make 100% transparent. */
if (distance < tolerance) {
output[0] = 0.0f;
}
- /*in the falloff region, make partially transparent */
+ /* In the falloff region, make partially transparent. */
else if (distance < falloff + tolerance) {
distance = distance - tolerance;
alpha = distance / falloff;
- /*only change if more transparent than before */
+ /* Only change if more transparent than before. */
if (alpha < inImage[3]) {
output[0] = alpha;
}
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc
index a3a86a6c502..c4099a6d33d 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc
@@ -960,7 +960,7 @@ static void do_createEdgeLocationBuffer(unsigned int t,
/* For looping gradient pixel indexes, represents current position from offset. */
unsigned int gradientAccum = 0;
- /* */
+ /* Disable clang-format to prevent line-wrapping. */
/* clang-format off */
/*
* Here we compute the size of buffer needed to hold (row,col) coordinates
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cc b/source/blender/compositor/operations/COM_IDMaskOperation.cc
index 1bb247e9bc5..38f8b7e075f 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.cc
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.cc
@@ -42,4 +42,22 @@ void IDMaskOperation::executePixel(float output[4], int x, int y, void *data)
output[0] = (roundf(buffer[buffer_index]) == this->m_objectIndex) ? 1.0f : 0.0f;
}
+void IDMaskOperation::update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs)
+{
+ const MemoryBuffer *input = inputs[0];
+ const int width = BLI_rcti_size_x(&area);
+ for (int y = area.ymin; y < area.ymax; y++) {
+ float *out = output->get_elem(area.xmin, y);
+ const float *in = input->get_elem(area.xmin, y);
+ const float *row_end = out + width * output->elem_stride;
+ while (out < row_end) {
+ out[0] = (roundf(in[0]) == m_objectIndex) ? 1.0f : 0.0f;
+ in += input->elem_stride;
+ out += output->elem_stride;
+ }
+ }
+}
+
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h
index 79b7e53b67c..c2e13641b46 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.h
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.h
@@ -18,11 +18,11 @@
#pragma once
-#include "COM_NodeOperation.h"
+#include "COM_MultiThreadedOperation.h"
namespace blender::compositor {
-class IDMaskOperation : public NodeOperation {
+class IDMaskOperation : public MultiThreadedOperation {
private:
float m_objectIndex;
@@ -36,6 +36,10 @@ class IDMaskOperation : public NodeOperation {
{
this->m_objectIndex = objectIndex;
}
+
+ void update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs) override;
};
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cc b/source/blender/compositor/operations/COM_ImageOperation.cc
index a1d401d4499..e78d389410f 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cc
+++ b/source/blender/compositor/operations/COM_ImageOperation.cc
@@ -44,6 +44,7 @@ BaseImageOperation::BaseImageOperation()
this->m_imageheight = 0;
this->m_framenumber = 0;
this->m_depthBuffer = nullptr;
+ depth_buffer_ = nullptr;
this->m_numberOfChannels = 0;
this->m_rd = nullptr;
this->m_viewName = nullptr;
@@ -91,6 +92,9 @@ void BaseImageOperation::initExecution()
this->m_imageFloatBuffer = stackbuf->rect_float;
this->m_imageByteBuffer = stackbuf->rect;
this->m_depthBuffer = stackbuf->zbuf_float;
+ if (stackbuf->zbuf_float) {
+ depth_buffer_ = new MemoryBuffer(stackbuf->zbuf_float, 1, stackbuf->x, stackbuf->y);
+ }
this->m_imagewidth = stackbuf->x;
this->m_imageheight = stackbuf->y;
this->m_numberOfChannels = stackbuf->channels;
@@ -102,6 +106,10 @@ void BaseImageOperation::deinitExecution()
this->m_imageFloatBuffer = nullptr;
this->m_imageByteBuffer = nullptr;
BKE_image_release_ibuf(this->m_image, this->m_buffer, nullptr);
+ if (depth_buffer_) {
+ delete depth_buffer_;
+ depth_buffer_ = nullptr;
+ }
}
void BaseImageOperation::determineResolution(unsigned int resolution[2],
@@ -170,6 +178,13 @@ void ImageOperation::executePixelSampled(float output[4], float x, float y, Pixe
}
}
+void ImageOperation::update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> UNUSED(inputs))
+{
+ output->copy_from(m_buffer, area, true);
+}
+
void ImageAlphaOperation::executePixelSampled(float output[4],
float x,
float y,
@@ -187,6 +202,13 @@ void ImageAlphaOperation::executePixelSampled(float output[4],
}
}
+void ImageAlphaOperation::update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> UNUSED(inputs))
+{
+ output->copy_from(m_buffer, area, 3, COM_DATA_TYPE_VALUE_CHANNELS, 0);
+}
+
void ImageDepthOperation::executePixelSampled(float output[4],
float x,
float y,
@@ -206,4 +228,16 @@ void ImageDepthOperation::executePixelSampled(float output[4],
}
}
+void ImageDepthOperation::update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> UNUSED(inputs))
+{
+ if (depth_buffer_) {
+ output->copy_from(depth_buffer_, area);
+ }
+ else {
+ output->fill(area, COM_VALUE_ZERO);
+ }
+}
+
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h
index 58373663db5..f8b4239c9f8 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.h
+++ b/source/blender/compositor/operations/COM_ImageOperation.h
@@ -21,7 +21,7 @@
#include "BKE_image.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
-#include "COM_NodeOperation.h"
+#include "COM_MultiThreadedOperation.h"
#include "MEM_guardedalloc.h"
#include "RE_pipeline.h"
@@ -32,14 +32,17 @@ namespace blender::compositor {
/**
* \brief Base class for all image operations
*/
-class BaseImageOperation : public NodeOperation {
+class BaseImageOperation : public MultiThreadedOperation {
protected:
ImBuf *m_buffer;
Image *m_image;
ImageUser *m_imageUser;
+ /* TODO: Remove raw buffers when removing Tiled implementation. */
float *m_imageFloatBuffer;
unsigned int *m_imageByteBuffer;
float *m_depthBuffer;
+
+ MemoryBuffer *depth_buffer_;
int m_imageheight;
int m_imagewidth;
int m_framenumber;
@@ -87,6 +90,10 @@ class ImageOperation : public BaseImageOperation {
*/
ImageOperation();
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
+
+ void update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs) override;
};
class ImageAlphaOperation : public BaseImageOperation {
public:
@@ -95,6 +102,10 @@ class ImageAlphaOperation : public BaseImageOperation {
*/
ImageAlphaOperation();
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
+
+ void update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs) override;
};
class ImageDepthOperation : public BaseImageOperation {
public:
@@ -103,6 +114,10 @@ class ImageDepthOperation : public BaseImageOperation {
*/
ImageDepthOperation();
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
+
+ void update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs) override;
};
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cc b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cc
index 0afc4278a45..5ca16e40ce3 100644
--- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cc
+++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cc
@@ -66,7 +66,7 @@ void LuminanceMatteOperation::executePixelSampled(float output[4],
else if (luminance < low) {
alpha = 0.0f;
}
- else { /*blend */
+ else { /* Blend. */
alpha = (luminance - low) / (high - low);
}
diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h
index 48fd54b00fe..92a2c291a72 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.h
+++ b/source/blender/compositor/operations/COM_MaskOperation.h
@@ -39,8 +39,8 @@ class MaskOperation : public NodeOperation {
* but they _do_ impact on mask detail */
int m_maskWidth;
int m_maskHeight;
- float m_maskWidthInv; /* 1 / m_maskWidth */
- float m_maskHeightInv; /* 1 / m_maskHeight */
+ float m_maskWidthInv; /* `1 / m_maskWidth` */
+ float m_maskHeightInv; /* `1 / m_maskHeight` */
float m_mask_px_ofs[2];
float m_frame_shutter;
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cc b/source/blender/compositor/operations/COM_MultilayerImageOperation.cc
index 647e93225e5..3a5de944a00 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cc
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cc
@@ -51,6 +51,13 @@ ImBuf *MultilayerBaseOperation::getImBuf()
return nullptr;
}
+void MultilayerBaseOperation::update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> UNUSED(inputs))
+{
+ output->copy_from(m_buffer, area);
+}
+
std::unique_ptr<MetaData> MultilayerColorOperation::getMetaData()
{
BLI_assert(this->m_buffer);
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
index 6e6062cf854..a682ca1941c 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.h
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
@@ -37,6 +37,10 @@ class MultilayerBaseOperation : public BaseImageOperation {
* Constructor
*/
MultilayerBaseOperation(RenderLayer *render_layer, RenderPass *render_pass, int view);
+
+ void update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs) override;
};
class MultilayerColorOperation : public MultilayerBaseOperation {
diff --git a/source/blender/compositor/operations/COM_SMAAOperation.cc b/source/blender/compositor/operations/COM_SMAAOperation.cc
index 74807f281d7..7a272fa8795 100644
--- a/source/blender/compositor/operations/COM_SMAAOperation.cc
+++ b/source/blender/compositor/operations/COM_SMAAOperation.cc
@@ -332,7 +332,7 @@ void SMAABlendingWeightCalculationOperation::executePixel(float output[4],
/* in one of the boundaries is enough. */
calculateDiagWeights(x, y, edges, output);
- /* We give priority to diagonals, so if we find a diagonal we skip */
+ /* We give priority to diagonals, so if we find a diagonal we skip. */
/* horizontal/vertical processing. */
if (!is_zero_v2(output)) {
return;
diff --git a/source/blender/datatoc/datatoc_icon.c b/source/blender/datatoc/datatoc_icon.c
index 7f1d90f20ea..2023260c168 100644
--- a/source/blender/datatoc/datatoc_icon.c
+++ b/source/blender/datatoc/datatoc_icon.c
@@ -453,7 +453,7 @@ static bool icondir_to_png(const char *path_src, const char *file_dst)
printf("%s: dir '%s' failed %d icons\n", __func__, path_src, fail);
}
- /* write pixels */
+ /* Write pixels. */
write_png(file_dst, pixels_canvas, canvas_w, canvas_h);
free(pixels_canvas);
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index 95ae587f4ce..3ad26c6f4db 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -158,6 +158,7 @@ set(SRC
)
set(LIB
+ bf_blenkernel
)
blender_add_lib(bf_depsgraph "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index b4acf9b010c..42c9cccceed 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -75,7 +75,7 @@ void DEG_graph_tag_relations_update(struct Depsgraph *graph);
/* Create or update relations in the specified graph. */
void DEG_graph_relations_update(struct Depsgraph *graph);
-/* Tag all relations in the database for update.*/
+/* Tag all relations in the database for update. */
void DEG_relations_tag_update(struct Main *bmain);
/* Add Dependencies ----------------------------- */
@@ -92,7 +92,7 @@ typedef enum eDepsSceneComponentType {
* (i.e. just SDNA property setting). */
DEG_SCENE_COMP_PARAMETERS,
/* Animation Component
- * TODO(sergey): merge in with parameters? */
+ * TODO(sergey): merge in with parameters? */
DEG_SCENE_COMP_ANIMATION,
/* Sequencer Component (Scene Only). */
DEG_SCENE_COMP_SEQUENCER,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index ae530cc010e..56168739fae 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -450,6 +450,22 @@ void DepsgraphNodeBuilder::update_invalid_cow_pointers()
/* Node/ID already tagged for COW flush, no need to check it. */
continue;
}
+ if ((id_node->id_cow->flag & LIB_EMBEDDED_DATA) != 0) {
+ /* For now, we assume embedded data are managed by their owner IDs and do not need to be
+ * checked here.
+ *
+ * NOTE: This exception somewhat weak, and ideally should not be needed. Currently however,
+ * embedded data are handled as full local (private) data of their owner IDs in part of
+ * Blender (like read/write code, including undo/redo), while depsgraph generally treat them
+ * as regular independent IDs. This leads to inconsistencies that can lead to bad level
+ * memory accesses.
+ *
+ * E.g. when undoing creation/deletion of a collection directly child of a scene's master
+ * collection, the scene itself is re-read in place, but its master collection becomes a
+ * completely new different pointer, and the existing COW of the old master collection in the
+ * matching deg node is therefore pointing to fully invalid (freed) memory. */
+ continue;
+ }
BKE_library_foreach_ID_link(nullptr,
id_node->id_cow,
deg::foreach_id_cow_detect_need_for_update_callback,
@@ -1199,7 +1215,19 @@ void DepsgraphNodeBuilder::build_parameters(ID *id)
op_node = add_operation_node(id, NodeType::PARAMETERS, OperationCode::PARAMETERS_ENTRY);
op_node->set_as_entry();
/* Generic evaluation node. */
- add_operation_node(id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EVAL);
+
+ if (ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW(GS(id->name))) {
+ ID *id_cow = get_cow_id(id);
+ add_operation_node(
+ id,
+ NodeType::PARAMETERS,
+ OperationCode::PARAMETERS_EVAL,
+ [id_cow, id](::Depsgraph * /*depsgraph*/) { BKE_id_eval_properties_copy(id_cow, id); });
+ }
+ else {
+ add_operation_node(id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EVAL);
+ }
+
/* Explicit exit operation. */
op_node = add_operation_node(id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EXIT);
op_node->set_as_exit();
@@ -1352,7 +1380,7 @@ void DepsgraphNodeBuilder::build_particle_systems(Object *object, bool is_object
ParticleSettings *part = psys->part;
/* Build particle settings operations.
*
- * NOTE: The call itself ensures settings are only build once. */
+ * NOTE: The call itself ensures settings are only build once. */
build_particle_settings(part);
/* Particle system evaluation. */
add_operation_node(psys_comp, OperationCode::PARTICLE_SYSTEM_EVAL, nullptr, psys->name);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
index 21a32b0d005..090b7f9dcb3 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
@@ -68,7 +68,7 @@ void DepsgraphNodeBuilder::build_scene_parameters(Scene *scene)
*
* Would be nice to find some reliable way of ignoring compositor here, but it's already pulled
* in when building scene from view layer, so this particular case does not make things
- * marginally worse. */
+ * marginally worse. */
build_scene_compositor(scene);
LISTBASE_FOREACH (TimeMarker *, marker, &scene->markers) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 8a02228146a..c269ad16824 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -220,7 +220,7 @@ OperationCode bone_target_opcode(ID *target,
const char *component_subdata,
RootPChanMap *root_map)
{
- /* Same armature. */
+ /* Same armature. */
if (target == id) {
/* Using "done" here breaks in-chain deps, while using
* "ready" here breaks most production rigs instead.
@@ -240,7 +240,7 @@ bool object_have_geometry_component(const Object *object)
} // namespace
-/* **** General purpose functions **** */
+/* **** General purpose functions **** */
DepsgraphRelationBuilder::DepsgraphRelationBuilder(Main *bmain,
Depsgraph *graph,
@@ -1148,7 +1148,7 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
/* Special case for camera tracking -- it doesn't use targets to
* define relations. */
/* TODO: we can now represent dependencies in a much richer manner,
- * so review how this is done. */
+ * so review how this is done. */
if (ELEM(cti->type,
CONSTRAINT_TYPE_FOLLOWTRACK,
CONSTRAINT_TYPE_CAMERASOLVER,
@@ -1911,7 +1911,7 @@ void DepsgraphRelationBuilder::build_particle_systems(Object *object)
/* Effectors. */
add_particle_forcefield_relations(
psys_key, object, psys, part->effector_weights, part->type == PART_HAIR, "Particle Field");
- /* Boids .*/
+ /* Boids. */
if (part->boids != nullptr) {
LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
@@ -1947,7 +1947,7 @@ void DepsgraphRelationBuilder::build_particle_systems(Object *object)
switch (part->ren_as) {
case PART_DRAW_OB:
if (part->instance_object != nullptr) {
- /* Make sure object's relations are all built. */
+ /* Make sure object's relations are all built. */
build_object(part->instance_object);
/* Build relation for the particle visualization. */
build_particle_system_visualization_object(object, psys, part->instance_object);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
index cab20dadc50..035d636b977 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
@@ -192,7 +192,7 @@ bool DepsgraphRelationBuilder::is_same_bone_dependency(const KeyFrom &key_from,
op_to->opcode == OperationCode::BONE_LOCAL)) {
return false;
}
- /* ... BUT, we also need to check if it's same bone. */
+ /* ... BUT, we also need to check if it's same bone. */
if (op_from->owner->name != op_to->owner->name) {
return false;
}
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 e4591e2e994..4754749e2e5 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -397,7 +397,7 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
add_relation(bone_local_key, constraints_key, "Local -> Constraints Stack");
/* Constraints -> ready/ */
/* TODO(sergey): When constraint stack is exploded, this step should
- * occur before the first IK solver. */
+ * occur before the first IK solver. */
add_relation(constraints_key, bone_ready_key, "Constraints -> Ready");
}
else {
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 78c5a0c7a13..b00cae87311 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -230,6 +230,7 @@ void depsgraph_tag_to_component_opcode(const ID *id,
case ID_RECALC_SOURCE:
*component_type = NodeType::PARAMETERS;
break;
+ case ID_RECALC_GEOMETRY_ALL_MODES:
case ID_RECALC_ALL:
case ID_RECALC_PSYS_ALL:
BLI_assert(!"Should not happen");
@@ -705,6 +706,8 @@ const char *DEG_update_tag_as_string(IDRecalcFlag flag)
return "TRANSFORM";
case ID_RECALC_GEOMETRY:
return "GEOMETRY";
+ case ID_RECALC_GEOMETRY_ALL_MODES:
+ return "GEOMETRY_ALL_MODES";
case ID_RECALC_ANIMATION:
return "ANIMATION";
case ID_RECALC_PSYS_REDO:
@@ -755,7 +758,7 @@ const char *DEG_update_tag_as_string(IDRecalcFlag flag)
return nullptr;
}
-/* Data-Based Tagging */
+/* Data-Based Tagging. */
/* Tag given ID for an update in all the dependency graphs. */
void DEG_id_tag_update(ID *id, int flag)
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.h b/source/blender/depsgraph/intern/depsgraph_tag.h
index 70504840fef..6a0b1826cd9 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.h
+++ b/source/blender/depsgraph/intern/depsgraph_tag.h
@@ -31,7 +31,7 @@ namespace deg {
struct Depsgraph;
-/* Get type of a node which corresponds to a ID_RECALC_GEOMETRY tag. */
+/* Get type of a node which corresponds to a ID_RECALC_GEOMETRY tag. */
NodeType geometry_tag_to_component(const ID *id);
/* Tag given ID for an update in all registered dependency graphs. */
diff --git a/source/blender/depsgraph/intern/node/deg_node.h b/source/blender/depsgraph/intern/node/deg_node.h
index 56bc0b41823..e1469b68b0e 100644
--- a/source/blender/depsgraph/intern/node/deg_node.h
+++ b/source/blender/depsgraph/intern/node/deg_node.h
@@ -100,7 +100,7 @@ enum class NodeType {
AUDIO,
ARMATURE,
/* Un-interesting data-block, which is a part of dependency graph, but does
- * not have very distinctive update procedure. */
+ * not have very distinctive update procedure. */
GENERIC_DATABLOCK,
/* **** Evaluation-Related Outer Types (with Subdata) **** */
diff --git a/source/blender/depsgraph/intern/node/deg_node_component.h b/source/blender/depsgraph/intern/node/deg_node_component.h
index 06582c88d8b..6e31ef268ed 100644
--- a/source/blender/depsgraph/intern/node/deg_node_component.h
+++ b/source/blender/depsgraph/intern/node/deg_node_component.h
@@ -23,12 +23,18 @@
#pragma once
+#include "intern/eval/deg_eval_copy_on_write.h"
#include "intern/node/deg_node.h"
+#include "intern/node/deg_node_id.h"
#include "intern/node/deg_node_operation.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
+#include "BKE_object.h"
+
+#include "DNA_object_types.h"
+
struct ID;
struct bPoseChannel;
@@ -156,6 +162,23 @@ struct ComponentNode : public Node {
DEG_COMPONENT_NODE_DECLARE; \
}
+/* When updating object data in edit-mode, don't request COW update since this will duplicate
+ * all object data which is unnecessary when the edit-mode data is used for calculating modifiers.
+ *
+ * TODO: Investigate modes besides edit-mode. */
+#define DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_OBDATA_IN_EDIT_MODE(name) \
+ struct name##ComponentNode : public ComponentNode { \
+ DEG_COMPONENT_NODE_DECLARE; \
+ virtual bool need_tag_cow_before_update() override \
+ { \
+ if (OB_DATA_SUPPORT_EDITMODE(owner->id_type) && \
+ BKE_object_data_is_in_editmode(owner->id_orig)) { \
+ return false; \
+ } \
+ return true; \
+ } \
+ }
+
#define DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(name) \
struct name##ComponentNode : public ComponentNode { \
DEG_COMPONENT_NODE_DECLARE; \
@@ -169,10 +192,9 @@ DEG_COMPONENT_NODE_DECLARE_GENERIC(Animation);
DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(BatchCache);
DEG_COMPONENT_NODE_DECLARE_GENERIC(Cache);
DEG_COMPONENT_NODE_DECLARE_GENERIC(CopyOnWrite);
-DEG_COMPONENT_NODE_DECLARE_GENERIC(Geometry);
+DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_OBDATA_IN_EDIT_MODE(Geometry);
DEG_COMPONENT_NODE_DECLARE_GENERIC(ImageAnimation);
DEG_COMPONENT_NODE_DECLARE_GENERIC(LayerCollections);
-DEG_COMPONENT_NODE_DECLARE_GENERIC(Parameters);
DEG_COMPONENT_NODE_DECLARE_GENERIC(Particles);
DEG_COMPONENT_NODE_DECLARE_GENERIC(ParticleSettings);
DEG_COMPONENT_NODE_DECLARE_GENERIC(Pose);
@@ -199,6 +221,22 @@ struct BoneComponentNode : public ComponentNode {
DEG_COMPONENT_NODE_DECLARE;
};
+/* Eventually we would not tag parameters in all cases.
+ * Support for this each ID needs to be added on an individual basis. */
+struct ParametersComponentNode : public ComponentNode {
+ virtual bool need_tag_cow_before_update() override
+ {
+ if (ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW(owner->id_type)) {
+ /* Disabled as this is not true for newly added objects, needs investigation. */
+ // BLI_assert(deg_copy_on_write_is_expanded(owner->id_cow));
+ return false;
+ }
+ return true;
+ }
+
+ DEG_COMPONENT_NODE_DECLARE;
+};
+
void deg_register_component_depsnodes();
} // namespace deg
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.h b/source/blender/depsgraph/intern/node/deg_node_operation.h
index 1d966cffd5d..a17186da941 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.h
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.h
@@ -79,7 +79,7 @@ enum class OperationCode {
TRANSFORM_PARENT,
/* Constraints */
TRANSFORM_CONSTRAINTS,
- /* Handle object-level updates, mainly proxies hacks and recalc flags. */
+ /* Handle object-level updates, mainly proxies hacks and recalc flags. */
TRANSFORM_EVAL,
/* Initializes transformation for simulation.
* For example, ensures point cache is properly reset before doing rigid
@@ -102,7 +102,7 @@ enum class OperationCode {
GEOMETRY_EVAL_INIT,
/* Evaluate the whole geometry, including modifiers. */
GEOMETRY_EVAL,
- /* Evaluation of geometry is completely done.. */
+ /* Evaluation of geometry is completely done. */
GEOMETRY_EVAL_DONE,
/* Evaluation of a shape key.
* NOTE: Currently only for object data data-blocks. */
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 4f68c3fdc7e..1227f4db8e4 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -61,6 +61,26 @@ set(SRC
intern/mesh_extractors/extract_mesh_ibo_lines.cc
intern/mesh_extractors/extract_mesh_ibo_points.cc
intern/mesh_extractors/extract_mesh_ibo_tris.cc
+ intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc
+ intern/mesh_extractors/extract_mesh_vbo_edit_data.cc
+ intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc
+ intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
+ intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc
+ intern/mesh_extractors/extract_mesh_vbo_fdots_edituv_data.cc
+ intern/mesh_extractors/extract_mesh_vbo_fdots_nor.cc
+ intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc
+ intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc
+ intern/mesh_extractors/extract_mesh_vbo_lnor.cc
+ intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc
+ intern/mesh_extractors/extract_mesh_vbo_orco.cc
+ intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc
+ intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc
+ intern/mesh_extractors/extract_mesh_vbo_select_idx.cc
+ intern/mesh_extractors/extract_mesh_vbo_skin_roots.cc
+ intern/mesh_extractors/extract_mesh_vbo_tan.cc
+ intern/mesh_extractors/extract_mesh_vbo_uv.cc
+ intern/mesh_extractors/extract_mesh_vbo_vcol.cc
+ intern/mesh_extractors/extract_mesh_vbo_weights.cc
intern/draw_cache_impl_curve.cc
intern/draw_cache_impl_displist.c
intern/draw_cache_impl_gpencil.c
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 7986d7a2810..4748323d6a7 100644
--- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c
+++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
@@ -234,7 +234,7 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata),
}
const float scale_camera = (is_ortho) ? 1.0 : 0.001f;
- /* we want radius here for the aperture number */
+ /* We want radius here for the aperture number. */
float aperture = 0.5f * scale_camera * focal_len / fstop;
float focal_len_scaled = scale_camera * focal_len;
float sensor_scaled = scale_camera * sensor;
@@ -352,7 +352,7 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata),
/**
* Create bokeh texture.
- **/
+ */
static void dof_bokeh_pass_init(EEVEE_FramebufferList *fbl,
EEVEE_PassList *psl,
EEVEE_EffectsInfo *fx)
@@ -392,7 +392,7 @@ static void dof_bokeh_pass_init(EEVEE_FramebufferList *fbl,
/**
* Outputs halfResColorBuffer and halfResCocBuffer.
- **/
+ */
static void dof_setup_pass_init(EEVEE_FramebufferList *fbl,
EEVEE_PassList *psl,
EEVEE_EffectsInfo *fx)
@@ -426,7 +426,7 @@ static void dof_setup_pass_init(EEVEE_FramebufferList *fbl,
/**
* Outputs min & max COC in each 8x8 half res pixel tiles (so 1/16th of full resolution).
- **/
+ */
static void dof_flatten_tiles_pass_init(EEVEE_FramebufferList *fbl,
EEVEE_PassList *psl,
EEVEE_EffectsInfo *fx)
@@ -459,7 +459,7 @@ static void dof_flatten_tiles_pass_init(EEVEE_FramebufferList *fbl,
* Dilates the min & max COCS to cover maximum COC values.
* Output format/dimensions should be the same as coc_flatten_pass as they are swapped for
* doing multiple dilation passes.
- **/
+ */
static void dof_dilate_tiles_pass_init(EEVEE_FramebufferList *fbl,
EEVEE_PassList *psl,
EEVEE_EffectsInfo *fx)
@@ -540,7 +540,7 @@ static void dof_dilate_tiles_pass_draw(EEVEE_FramebufferList *fbl,
/**
* Create mipmapped color & COC textures for gather passes.
- **/
+ */
static void dof_reduce_pass_init(EEVEE_FramebufferList *fbl,
EEVEE_PassList *psl,
EEVEE_TextureList *txl,
@@ -626,7 +626,7 @@ static void dof_reduce_pass_init(EEVEE_FramebufferList *fbl,
if (txl->dof_reduced_color) {
/* TODO(fclem) In the future, we need to check if mip_count did not change.
- * For now it's ok as we always define all mip level.*/
+ * For now it's ok as we always define all mip level. */
if (res[0] != GPU_texture_width(txl->dof_reduced_color) ||
res[1] != GPU_texture_width(txl->dof_reduced_color)) {
DRW_TEXTURE_FREE_SAFE(txl->dof_reduced_color);
@@ -666,7 +666,7 @@ static void dof_reduce_pass_init(EEVEE_FramebufferList *fbl,
/**
* Do the gather convolution. For each pixels we gather multiple pixels in its neighborhood
* depending on the min & max CoC tiles.
- **/
+ */
static void dof_gather_pass_init(EEVEE_FramebufferList *fbl,
EEVEE_PassList *psl,
EEVEE_TextureList *txl,
@@ -792,7 +792,7 @@ static void dof_gather_pass_init(EEVEE_FramebufferList *fbl,
* Filter an input buffer using a median filter to reduce noise.
* NOTE: We use the holefill texture as our input to reduce memory usage.
* Thus, the holefill pass cannot be filtered.
- **/
+ */
static void dof_filter_pass_init(EEVEE_FramebufferList *fbl,
EEVEE_PassList *psl,
EEVEE_EffectsInfo *fx)
@@ -825,7 +825,7 @@ static void dof_filter_pass_init(EEVEE_FramebufferList *fbl,
/**
* Do the Scatter convolution. A sprite is emitted for every 4 pixels but is only expanded if the
* pixels are bright enough to be scattered.
- **/
+ */
static void dof_scatter_pass_init(EEVEE_FramebufferList *fbl,
EEVEE_PassList *psl,
EEVEE_TextureList *txl,
@@ -896,7 +896,7 @@ static void dof_scatter_pass_init(EEVEE_FramebufferList *fbl,
/**
* Recombine the result of the foreground and background processing. Also perform a slight out of
* focus blur to improve geometric continuity.
- **/
+ */
static void dof_recombine_pass_init(EEVEE_FramebufferList *UNUSED(fbl),
EEVEE_PassList *psl,
EEVEE_EffectsInfo *fx)
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
index 37ecdb20651..cdd66759308 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -866,7 +866,7 @@ static void eevee_lightbake_delete_resources(EEVEE_LightBake *lbake)
}
/* XXX Free the resources contained in the viewlayer data
- * to be able to free the context before deleting the depsgraph. */
+ * to be able to free the context before deleting the depsgraph. */
if (lbake->sldata) {
EEVEE_view_layer_data_free(lbake->sldata);
}
@@ -1480,7 +1480,7 @@ void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float
eevee_lightbake_delete_resources(lbake);
- /* Free GPU smoke textures and the smoke domain list correctly: See also T73921.*/
+ /* Free GPU smoke textures and the smoke domain list correctly: See also T73921. */
EEVEE_volumes_free_smoke_textures();
}
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index d2e0c8308c5..7dd3449ad6e 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -172,7 +172,7 @@ static void eevee_init_util_texture(void)
}
texels_layer += 64 * 64;
- /* Copy blue noise in 3rd layer */
+ /* Copy blue noise in 3rd layer. */
for (int i = 0; i < 64 * 64; i++) {
texels_layer[i][0] = blue_noise[i][0];
texels_layer[i][1] = blue_noise[i][2];
@@ -181,7 +181,7 @@ static void eevee_init_util_texture(void)
}
texels_layer += 64 * 64;
- /* Copy ltc_disk_integral in 4th layer */
+ /* Copy ltc_disk_integral in 4th layer. */
for (int i = 0; i < 64 * 64; i++) {
texels_layer[i][0] = ltc_disk_integral[i];
texels_layer[i][1] = 0.0; /* UNUSED */
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index 0a79d9466e9..2e200c8e053 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -245,7 +245,7 @@ void EEVEE_motion_blur_hair_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata),
if (mb_data) {
int mb_step = effects->motion_blur_step;
- /* Store transform */
+ /* Store transform. */
DRW_hair_duplimat_get(ob, psys, md, mb_data->obmat[mb_step]);
EEVEE_HairMotionData *mb_hair = EEVEE_motion_blur_hair_data_get(&effects->motion_blur, ob);
@@ -323,7 +323,7 @@ void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata),
if (mb_data) {
int mb_step = effects->motion_blur_step;
- /* Store transform */
+ /* Store transform. */
copy_m4_m4(mb_data->obmat[mb_step], ob->obmat);
EEVEE_GeometryMotionData *mb_geom = EEVEE_motion_blur_geometry_data_get(&effects->motion_blur,
@@ -349,7 +349,7 @@ void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata),
}
/* Avoid drawing object that has no motions since object_moves is always true. */
- if (!mb_geom->use_deform && /* Object deformation can happen without transform. */
+ if (!mb_geom->use_deform && /* Object deformation can happen without transform. */
equals_m4m4(mb_data->obmat[MB_PREV], mb_data->obmat[MB_CURR]) &&
equals_m4m4(mb_data->obmat[MB_NEXT], mb_data->obmat[MB_CURR])) {
return;
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index bc04fe024fc..ab297620afe 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -565,7 +565,7 @@ typedef struct EEVEE_LightsInfo {
/* Update bitmap. */
BLI_bitmap sh_cube_update[BLI_BITMAP_SIZE(MAX_SHADOW_CUBE)];
/* Lights tracking */
- struct BoundSphere shadow_bounds[MAX_LIGHT]; /* Tightly packed light bounds */
+ struct BoundSphere shadow_bounds[MAX_LIGHT]; /* Tightly packed light bounds. */
/* List of bbox and update bitmap. Double buffered. */
struct EEVEE_ShadowCasterBuffer *shcaster_frontbuffer, *shcaster_backbuffer;
/* AABB of all shadow casters combined. */
diff --git a/source/blender/draw/engines/eevee/eevee_shaders.c b/source/blender/draw/engines/eevee/eevee_shaders.c
index 90b7eeb9293..a4e4352ac16 100644
--- a/source/blender/draw/engines/eevee/eevee_shaders.c
+++ b/source/blender/draw/engines/eevee/eevee_shaders.c
@@ -1274,7 +1274,7 @@ Material *EEVEE_material_default_error_get(void)
return e_data.error_mat;
}
-/* Configure a default nodetree with the given material. */
+/* Configure a default nodetree with the given material. */
struct bNodeTree *EEVEE_shader_default_surface_nodetree(Material *ma)
{
/* WARNING: This function is not threadsafe. Which is not a problem for the moment. */
@@ -1302,7 +1302,7 @@ struct bNodeTree *EEVEE_shader_default_surface_nodetree(Material *ma)
return e_data.surface.ntree;
}
-/* Configure a default nodetree with the given world. */
+/* Configure a default nodetree with the given world. */
struct bNodeTree *EEVEE_shader_default_world_nodetree(World *wo)
{
/* WARNING: This function is not threadsafe. Which is not a problem for the moment. */
diff --git a/source/blender/draw/engines/eevee/eevee_shadows.c b/source/blender/draw/engines/eevee/eevee_shadows.c
index 6a98c3316f3..5060c209b8b 100644
--- a/source/blender/draw/engines/eevee/eevee_shadows.c
+++ b/source/blender/draw/engines/eevee/eevee_shadows.c
@@ -247,7 +247,7 @@ void EEVEE_shadows_update(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
sldata->shadow_fb = GPU_framebuffer_create("shadow_fb");
}
- /* Gather all light own update bits. to avoid costly intersection check. */
+ /* Gather all light own update bits. to avoid costly intersection check. */
for (int j = 0; j < linfo->cube_len; j++) {
const EEVEE_Light *evli = linfo->light_data + linfo->shadow_cube_light_indices[j];
/* Setup shadow cube in UBO and tag for update if necessary. */
diff --git a/source/blender/draw/engines/eevee/eevee_subsurface.c b/source/blender/draw/engines/eevee/eevee_subsurface.c
index 7fd39007263..129822ed8a9 100644
--- a/source/blender/draw/engines/eevee/eevee_subsurface.c
+++ b/source/blender/draw/engines/eevee/eevee_subsurface.c
@@ -315,7 +315,7 @@ void EEVEE_subsurface_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
if (!DRW_pass_is_empty(psl->sss_translucency_ps)) {
/* We sample the shadow-maps using normal sampler. We need to disable Comparison mode.
- * TODO(fclem): avoid this by using sampler objects.*/
+ * TODO(fclem): avoid this by using sampler objects. */
GPU_texture_compare_mode(sldata->shadow_cube_pool, false);
GPU_texture_compare_mode(sldata->shadow_cascade_pool, false);
diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c
index eed36221fcb..56c5b367f7e 100644
--- a/source/blender/draw/engines/eevee/eevee_volumes.c
+++ b/source/blender/draw/engines/eevee/eevee_volumes.c
@@ -709,7 +709,7 @@ void EEVEE_volumes_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRW_stats_group_start("Volumetrics");
/* We sample the shadow-maps using shadow sampler. We need to enable Comparison mode.
- * TODO(fclem): avoid this by using sampler objects.*/
+ * TODO(fclem): avoid this by using sampler objects. */
GPU_texture_compare_mode(sldata->shadow_cube_pool, true);
GPU_texture_compare_mode(sldata->shadow_cascade_pool, true);
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 cdc453eed40..d4e3b879426 100644
--- a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
@@ -338,7 +338,7 @@ float diffuse_occlusion(
* radius2 : Second caps’ radius (in radians)
* dist : Distance between caps (radians between centers of caps)
* Note: Result is divided by pi to save one multiply.
- **/
+ */
float spherical_cap_intersection(float radius1, float radius2, float dist)
{
/* From "Ambient Aperture Lighting" by Chris Oat
@@ -407,7 +407,7 @@ OcclusionData occlusion_load(vec3 vP, float custom_occlusion)
data = unpack_occlusion_data(texelFetch(horizonBuffer, ivec2(gl_FragCoord.xy), 0));
}
#else
- /* For blended surfaces. */
+ /* For blended surfaces. */
data = occlusion_search(vP, maxzBuffer, aoDistance, 0.0, 8.0);
#endif
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 05496ad4ab0..4ee21cf8c2e 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -201,6 +201,6 @@ float cone_cosine(float r)
// return cos(2.0 * sqrt(2.0 / (gloss + 2)));
/* Uludag 2014 in GPUPro5 */
// return pow(0.244, 1 / (gloss + 1));
- /* Jimenez 2016 in Practical Realtime Strategies for Accurate Indirect Occlusion*/
+ /* Jimenez 2016 in Practical Realtime Strategies for Accurate Indirect Occlusion. */
return exp2(-3.32193 * r * r);
}
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
index 7ce95a4aff2..4fcfac36376 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
@@ -1,7 +1,7 @@
/**
* Sampling distribution routines for Monte-carlo integration.
- **/
+ */
#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
#pragma BLENDER_REQUIRE(bsdf_common_lib.glsl)
diff --git a/source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl b/source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl
index 2f1298e2707..c8c3fa548fc 100644
--- a/source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl
@@ -83,7 +83,7 @@ void main()
btdf_accum = 0.0;
}
- /* There is place to put multiscater result (which is a little bit different still)
- * and / or lobe fitting for better sampling of */
+ /* There is place to put multi-scatter result (which is a little bit different still)
+ * and / or lobe fitting for better sampling of. */
FragColor = vec4(btdf_accum, fresnel_accum, 0.0, 1.0);
}
diff --git a/source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl b/source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl
index 94dd1a439db..e5cbc487e93 100644
--- a/source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl
@@ -19,7 +19,7 @@
* CLOSURE_EVAL_FUNCTION_3(name, Diffuse, Glossy, Refraction);
* // Get the cl_out
* closure.radiance = out_Diffuse_0.radiance + out_Glossy_1.radiance + out_Refraction_2.radiance;
- **/
+ */
#define CLOSURE_VARS_DECLARE(t0, t1, t2, t3) \
ClosureInputCommon in_common = CLOSURE_INPUT_COMMON_DEFAULT; \
@@ -291,7 +291,7 @@ ClosurePlanarData closure_planar_eval_init(inout ClosureEvalCommon cl_common)
ClosurePlanarData planar;
planar.attenuation = 0.0;
- /* Find planar with the maximum weight. TODO(fclem) */
+ /* TODO(fclem): Find planar with the maximum weight. */
for (int i = 0; i < prbNumPlanar && i < MAX_PLANAR; i++) {
float attenuation = probe_attenuation_planar(planars_data[i], cl_common.P);
if (attenuation > planar.attenuation) {
diff --git a/source/blender/draw/engines/eevee/shaders/closure_type_lib.glsl b/source/blender/draw/engines/eevee/shaders/closure_type_lib.glsl
index 38ae3972aa7..f66f45635f4 100644
--- a/source/blender/draw/engines/eevee/shaders/closure_type_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/closure_type_lib.glsl
@@ -99,7 +99,7 @@ Closure closure_mix(Closure cl1, Closure cl2, float fac)
cl.flag = cl1.flag | cl2.flag;
cl.ssr_data = mix(cl1.ssr_data, cl2.ssr_data, fac);
bool use_cl1_ssr = FLAG_TEST(cl1.flag, CLOSURE_SSR_FLAG);
- /* When mixing SSR don't blend roughness and normals but only specular (ssr_data.xyz).*/
+ /* When mixing SSR don't blend roughness and normals but only specular (ssr_data.xyz). */
cl.ssr_data.w = (use_cl1_ssr) ? cl1.ssr_data.w : cl2.ssr_data.w;
cl.ssr_normal = (use_cl1_ssr) ? cl1.ssr_normal : cl2.ssr_normal;
@@ -122,7 +122,7 @@ Closure closure_add(Closure cl1, Closure cl2)
cl.flag = cl1.flag | cl2.flag;
cl.ssr_data = cl1.ssr_data + cl2.ssr_data;
bool use_cl1_ssr = FLAG_TEST(cl1.flag, CLOSURE_SSR_FLAG);
- /* When mixing SSR don't blend roughness and normals.*/
+ /* When mixing SSR don't blend roughness and normals. */
cl.ssr_data.w = (use_cl1_ssr) ? cl1.ssr_data.w : cl2.ssr_data.w;
cl.ssr_normal = (use_cl1_ssr) ? cl1.ssr_normal : cl2.ssr_normal;
diff --git a/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl b/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl
index d7996ab4bd1..c935eca6a39 100644
--- a/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl
@@ -37,7 +37,7 @@ layout(std140) uniform common_block
int prbIrradianceVisSize;
float prbIrradianceSmooth;
float prbLodCubeMax;
- /* Misc*/
+ /* Misc */
int rayType;
float rayDepth;
float alphaHashOffset;
diff --git a/source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl b/source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl
index 821859b3228..c3325ec4286 100644
--- a/source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl
@@ -27,7 +27,7 @@ const float lut_btdf_layer_count = 16.0;
* x : Uniformly distributed value [0..1] (noise 1).
* y : Uniformly distributed value [0..1] (noise 2).
* z,w : Uniformly distributed point on the unit circle [-1..1] (noise 3).
- **/
+ */
#define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
/* Return texture coordinates to sample Surface LUT. */
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl
index 40e4c5a313e..5fd00986adc 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl
@@ -5,7 +5,7 @@
* a perfect circle.
* We correct samples spacing for polygonal bokeh shapes. However, we do not for anamorphic bokeh
* as it is way more complex and expensive to do.
- **/
+ */
#pragma BLENDER_REQUIRE(effect_dof_lib.glsl)
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_dilate_tiles_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_dilate_tiles_frag.glsl
index 22e6f929f36..0cbf92466aa 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_dilate_tiles_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_dilate_tiles_frag.glsl
@@ -2,7 +2,7 @@
/**
* Tile dilate pass: Takes the 8x8 Tiles buffer and converts dilates the tiles with large CoC to
* their neighborhood. This pass is repeated multiple time until the maximum CoC can be covered.
- **/
+ */
#pragma BLENDER_REQUIRE(effect_dof_lib.glsl)
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_downsample_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_downsample_frag.glsl
index c477e0f6eb8..c33eda0acd2 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_downsample_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_downsample_frag.glsl
@@ -4,7 +4,7 @@
*
* Pretty much identical to the setup pass but get CoC from buffer. Also does not
* weight luma for the bilateral weights.
- **/
+ */
#pragma BLENDER_REQUIRE(effect_dof_lib.glsl)
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_filter_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_filter_frag.glsl
index 78c80438f60..aa72cda4fb7 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_filter_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_filter_frag.glsl
@@ -4,7 +4,7 @@
*
* This is a simple 3x3 median filter to avoid dilating highlights with a 3x3 max filter even if
* cheaper.
- **/
+ */
#pragma BLENDER_REQUIRE(effect_dof_lib.glsl)
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_flatten_tiles_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_flatten_tiles_frag.glsl
index bd81171c759..48195a1daea 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_flatten_tiles_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_flatten_tiles_frag.glsl
@@ -5,7 +5,7 @@
* Output min and max values for each tile and for both foreground & background.
* Also outputs min intersectable CoC for the background, which is the minimum CoC
* that comes from the background pixels.
- **/
+ */
#pragma BLENDER_REQUIRE(effect_dof_lib.glsl)
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl
index 8c2633084db..39a7e8fb931 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl
@@ -7,7 +7,7 @@
*
* We sample using an octaweb sampling pattern. We randomize the kernel center and each ring
* rotation to ensure maximum coverage.
- **/
+ */
#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
#pragma BLENDER_REQUIRE(effect_dof_lib.glsl)
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl
index dac53719149..da34b221104 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl
@@ -395,7 +395,7 @@ void dof_gather_accumulate_sample_pair(DofGatherData pair_data[2],
/**
* If a CoC is larger than bordering radius we accumulate it to the general accumulator.
* If not, we accumulate to the ring bucket. This is to have more consistent sample occlusion.
- **/
+ */
float accum_weight = dof_gather_accum_weight(pair_data[i].coc, bordering_radius, first_ring);
dof_gather_accumulate_sample(pair_data[i], weight * accum_weight, accum_data);
dof_gather_accumulate_sample(pair_data[i], weight * (1.0 - accum_weight), ring_data);
@@ -607,7 +607,7 @@ ivec2 dof_square_ring_sample_offset(int ring_distance, int sample_id)
* . . . . .
*
* Samples are expected to be mirrored to complete the pattern.
- **/
+ */
ivec2 offset;
if (sample_id < ring_distance) {
offset.x = ring_distance;
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_reduce_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_reduce_frag.glsl
index 51a139ad343..1b5b305dfc1 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_reduce_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_reduce_frag.glsl
@@ -2,14 +2,14 @@
/**
* Reduce pass: Downsample the color buffer to generate mipmaps.
* Also decide if a pixel is to be convolved by scattering or gathering during the first pass.
- **/
+ */
#pragma BLENDER_REQUIRE(effect_dof_lib.glsl)
/** Inputs:
* COPY_PASS: Is output of setup pass (halfres) and downsample pass (quarter res).
* REDUCE_PASS: Is previous Gather input miplvl (halfres >> miplvl).
- **/
+ */
uniform sampler2D colorBuffer;
uniform sampler2D cocBuffer;
uniform sampler2D downsampledBuffer;
@@ -23,7 +23,7 @@ uniform float colorNeighborClamping;
/** Outputs:
* COPY_PASS: Gather input mip0.
* REDUCE_PASS: Is next Gather input miplvl (halfres >> miplvl).
- **/
+ */
layout(location = 0) out vec4 outColor;
layout(location = 1) out float outCoc;
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_resolve_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_resolve_frag.glsl
index 32841b7749c..57027c71156 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_resolve_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_resolve_frag.glsl
@@ -34,7 +34,7 @@ out vec4 fragColor;
void dof_slight_focus_gather(float radius, out vec4 out_color, out float out_weight)
{
- /* offset coord to avoid correlation with sampling pattern. */
+ /* offset coord to avoid correlation with sampling pattern. */
vec4 noise = texelfetch_noise_tex(gl_FragCoord.xy + 7.0);
DofGatherData fg_accum = GATHER_DATA_INIT;
@@ -199,7 +199,7 @@ void main(void)
fragColor = fragColor * (1.0 - layer_weight) + layer_color;
}
- /* Fix float precision issue in alpha compositing. */
+ /* Fix float precision issue in alpha compositing. */
if (fragColor.a > 0.99) {
fragColor.a = 1.0;
}
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_scatter_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_scatter_frag.glsl
index 704bbf6d999..06dcbeaed66 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_scatter_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_scatter_frag.glsl
@@ -4,7 +4,7 @@
*
* We only scatter one triangle per sprite and one sprite per 4 pixels to reduce vertex shader
* invocations and overdraw.
- **/
+ */
#pragma BLENDER_REQUIRE(effect_dof_lib.glsl)
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_scatter_vert.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_scatter_vert.glsl
index 276ab119fab..f349806d37e 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_scatter_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_scatter_vert.glsl
@@ -25,7 +25,8 @@ flat out float spritesize;
/* Load 4 Circle of confusion values. texel_co is centered around the 4 taps. */
vec4 fetch_cocs(vec2 texel_co)
{
- /* TODO(fclem) The textureGather(sampler, co, comp) variant isn't here on some implementations.*/
+ /* TODO(fclem) The textureGather(sampler, co, comp) variant isn't here on some implementations.
+ */
#if 0 // GPU_ARB_texture_gather
vec2 uvs = texel_co / vec2(textureSize(cocBuffer, 0));
/* Reminder: Samples order is CW starting from top left. */
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_setup_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_setup_frag.glsl
index d1ecc0fc244..235145b221b 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_setup_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_setup_frag.glsl
@@ -4,7 +4,7 @@
*
* An addition to the downsample CoC, we output the maximum slight out of focus CoC to be
* sure we don't miss a pixel.
- **/
+ */
#pragma BLENDER_REQUIRE(effect_dof_lib.glsl)
diff --git a/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
index 356ed102928..97b31a972e3 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
@@ -49,7 +49,7 @@ float light_translucent_power_with_falloff(LightData ld, vec3 N, vec4 l_vector)
}
else if (ld.l_type == SUN) {
power = 1.0 / (1.0 + (ld.l_radius * ld.l_radius * 0.5));
- power *= ld.l_radius * ld.l_radius * M_PI; /* Removing area light power*/
+ power *= ld.l_radius * ld.l_radius * M_PI; /* Removing area light power. */
power *= M_2PI * 0.78; /* Matching cycles with point light. */
power *= 0.082; /* XXX ad hoc, empirical */
falloff = dot(N, -ld.l_forward);
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
index c9b5d0dea36..a648e7a8b26 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
@@ -208,7 +208,7 @@ vec3 probe_evaluate_planar(int id, PlanarData pd, vec3 P, vec3 N, vec3 V, float
/* TODO: If we support non-ssr planar reflection, we should blur them with gaussian
* and chose the right mip depending on the cone footprint after projection */
- /* NOTE: X is inverted here to compensate inverted drawing. */
+ /* NOTE: X is inverted here to compensate inverted drawing. */
vec3 radiance = textureLod(probePlanars, vec3(refco.xy * vec2(-0.5, 0.5) + 0.5, id), 0.0).rgb;
return radiance;
diff --git a/source/blender/draw/engines/eevee/shaders/random_lib.glsl b/source/blender/draw/engines/eevee/shaders/random_lib.glsl
index 25a3e0f56b4..3a4ae257bbe 100644
--- a/source/blender/draw/engines/eevee/shaders/random_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/random_lib.glsl
@@ -1,7 +1,7 @@
/**
* Random numbers and low discrepency sequences utilities.
- **/
+ */
#pragma BLENDER_REQUIRE(common_math_lib.glsl)
diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
index 1b2135646c9..f1476e4f2c4 100644
--- a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
@@ -90,7 +90,7 @@ ScreenSpaceRay raytrace_screenspace_ray_create(Ray ray, float thickness)
}
struct RayTraceParameters {
- /** ViewSpace thickness the objects */
+ /** ViewSpace thickness the objects. */
float thickness;
/** Jitter along the ray to avoid banding artifact when steps are too large. */
float jitter;
diff --git a/source/blender/draw/engines/eevee/shaders/surface_lib.glsl b/source/blender/draw/engines/eevee/shaders/surface_lib.glsl
index 0acb35b2399..0efa7b80b0b 100644
--- a/source/blender/draw/engines/eevee/shaders/surface_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/surface_lib.glsl
@@ -1,4 +1,4 @@
-/** This describe the entire interface of the shader. */
+/** This describe the entire interface of the shader. */
#define SURFACE_INTERFACE \
vec3 worldPosition; \
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
index 788e621c3c1..c48c3bffaef 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
@@ -70,7 +70,7 @@ vec3 light_volume(LightData ld, vec4 l_vector)
* Using "Point Light Attenuation Without Singularity" from Cem Yuksel
* http://www.cemyuksel.com/research/pointlightattenuation/pointlightattenuation.pdf
* http://www.cemyuksel.com/research/pointlightattenuation/
- **/
+ */
float d = l_vector.w;
float d_sqr = sqr(d);
float r_sqr = ld.l_volume_radius;
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index af8b029a08e..8a2aebc95ab 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -102,7 +102,7 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob)
transpose_m4(mat);
/* mat is now a "normal" matrix which will transform
- * BBox space normal to world space. */
+ * BBox space normal to world space. */
mul_mat3_m4_v3(mat, tgp_ob->plane_normal);
normalize_v3(tgp_ob->plane_normal);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 32884eb9e3f..1921055c3d7 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -320,7 +320,7 @@ void GPENCIL_cache_init(void *ved)
float focal_len = cam->lens;
const float scale_camera = 0.001f;
- /* we want radius here for the aperture number */
+ /* We want radius here for the aperture number. */
float aperture = 0.5f * scale_camera * focal_len / fstop;
float focal_len_scaled = scale_camera * focal_len;
float sensor_scaled = scale_camera * sensor;
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_antialiasing_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_antialiasing_frag.glsl
index b512b54e392..7758fdceb46 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_antialiasing_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_antialiasing_frag.glsl
@@ -17,7 +17,7 @@ out vec2 fragColor;
#elif SMAA_STAGE == 1
out vec4 fragColor;
#elif SMAA_STAGE == 2
-/* Reminder: Blending func is fragRevealage * DST + fragColor .*/
+/* Reminder: Blending func is `fragRevealage * DST + fragColor`. */
layout(location = 0, index = 0) out vec4 outColor;
layout(location = 0, index = 1) out vec4 outReveal;
#endif
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
index ac48b94fea9..b1368f90846 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
@@ -101,23 +101,23 @@ void blend_mode_output(
{
switch (blend_mode) {
case MODE_REGULAR:
- /* Reminder: Blending func is premult alpha blend (dst.rgba * (1 - src.a) + src.rgb).*/
+ /* Reminder: Blending func is premult alpha blend (dst.rgba * (1 - src.a) + src.rgb). */
color *= opacity;
frag_color = color;
frag_revealage = vec4(0.0, 0.0, 0.0, color.a);
break;
case MODE_MULTIPLY:
- /* Reminder: Blending func is multiply blend (dst.rgba * src.rgba).*/
+ /* Reminder: Blending func is multiply blend (dst.rgba * src.rgba). */
color.a *= opacity;
frag_revealage = frag_color = (1.0 - color.a) + color.a * color;
break;
case MODE_DIVIDE:
- /* Reminder: Blending func is multiply blend (dst.rgba * src.rgba).*/
+ /* Reminder: Blending func is multiply blend (dst.rgba * src.rgba). */
color.a *= opacity;
frag_revealage = frag_color = clamp(1.0 / max(vec4(1e-6), 1.0 - color * color.a), 0.0, 1e18);
break;
case MODE_HARDLIGHT:
- /* Reminder: Blending func is multiply blend (dst.rgba * src.rgba).*/
+ /* Reminder: Blending func is multiply blend (dst.rgba * src.rgba). */
/**
* We need to separate the overlay equation into 2 term (one mul and one add).
* This is the standard overlay equation (per channel):
@@ -135,14 +135,14 @@ void blend_mode_output(
frag_revealage = max(vec4(0.0), frag_revealage);
break;
case MODE_HARDLIGHT_SECOND_PASS:
- /* Reminder: Blending func is additive blend (dst.rgba + src.rgba).*/
+ /* Reminder: Blending func is additive blend (dst.rgba + src.rgba). */
color = mix(vec4(0.5), color, color.a * opacity);
frag_revealage = frag_color = (-1.0 + 2.0 * color) * step(-0.5, -color);
frag_revealage = max(vec4(0.0), frag_revealage);
break;
case MODE_SUB:
case MODE_ADD:
- /* Reminder: Blending func is additive / subtractive blend (dst.rgba +/- src.rgba).*/
+ /* Reminder: Blending func is additive / subtractive blend (dst.rgba +/- src.rgba). */
frag_color = color * color.a * opacity;
frag_revealage = vec4(0.0);
break;
@@ -238,7 +238,7 @@ in vec4 pos; /* Prev adj vert */
in vec4 pos1; /* Current edge */
in vec4 pos2; /* Current edge */
in vec4 pos3; /* Next adj vert */
-/* xy is UV for fills, z is U of stroke, w is strength. */
+/* xy is UV for fills, z is U of stroke, w is strength. */
in vec4 uv1;
in vec4 uv2;
in vec4 col1;
@@ -347,7 +347,7 @@ float stroke_thickness_modulate(float thickness)
float clamp_small_stroke_thickness(float thickness)
{
/* To avoid aliasing artifacts, we clamp the line thickness and
- * reduce its opacity in the fragment shader.*/
+ * reduce its opacity in the fragment shader. */
float min_thickness = gl_Position.w * 1.3;
thickness = max(min_thickness, thickness);
diff --git a/source/blender/draw/engines/image/shaders/engine_image_frag.glsl b/source/blender/draw/engines/image/shaders/engine_image_frag.glsl
index 2bccf0d99b5..55a2f2a72f1 100644
--- a/source/blender/draw/engines/image/shaders/engine_image_frag.glsl
+++ b/source/blender/draw/engines/image/shaders/engine_image_frag.glsl
@@ -28,7 +28,7 @@ in vec2 uvs;
out vec4 fragColor;
#ifdef TILED_IMAGE
-/* TODO(fclem): deduplicate code. */
+/* TODO(fclem): deduplicate code. */
bool node_tex_tile_lookup(inout vec3 co, sampler2DArray ima, sampler1DArray map)
{
vec2 tile_pos = floor(co.xy);
diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c
index e6c3248b6c4..0e350ea5a68 100644
--- a/source/blender/draw/engines/overlay/overlay_armature.c
+++ b/source/blender/draw/engines/overlay/overlay_armature.c
@@ -1889,7 +1889,7 @@ static void draw_bone_name(ArmatureDrawContext *ctx,
bool highlight = (pchan && (arm->flag & ARM_POSEMODE) && (boneflag & BONE_SELECTED)) ||
(eBone && (eBone->flag & BONE_SELECTED));
- /* Color Management: Exception here as texts are drawn in sRGB space directly. */
+ /* Color Management: Exception here as texts are drawn in sRGB space directly. */
UI_GetThemeColor4ubv(highlight ? TH_TEXT_HI : TH_TEXT, color);
float *head = pchan ? pchan->pose_head : eBone->head;
diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.c b/source/blender/draw/engines/overlay/overlay_edit_uv.c
index 9c58a2b574f..01ab47ac1de 100644
--- a/source/blender/draw/engines/overlay/overlay_edit_uv.c
+++ b/source/blender/draw/engines/overlay/overlay_edit_uv.c
@@ -325,7 +325,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata)
if (pd->edit_uv.do_tiled_image_overlay) {
struct DRWTextStore *dt = DRW_text_cache_ensure();
uchar color[4];
- /* Color Management: Exception here as texts are drawn in sRGB space directly. */
+ /* Color Management: Exception here as texts are drawn in sRGB space directly. */
UI_GetThemeColorShade4ubv(TH_BACK, 60, color);
char text[16];
LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) {
diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c
index 2e1c0165513..b70c71de188 100644
--- a/source/blender/draw/engines/overlay/overlay_extra.c
+++ b/source/blender/draw/engines/overlay/overlay_extra.c
@@ -887,7 +887,7 @@ static void camera_view3d_reconstruction(OVERLAY_ExtraCallBuffers *cb,
float *bundle_color_solid = G_draw.block.colorBundleSolid;
float *bundle_color_unselected = G_draw.block.colorWire;
uchar text_color_selected[4], text_color_unselected[4];
- /* Color Management: Exception here as texts are drawn in sRGB space directly. */
+ /* Color Management: Exception here as texts are drawn in sRGB space directly. */
UI_GetThemeColor4ubv(TH_SELECT, text_color_selected);
UI_GetThemeColor4ubv(TH_TEXT, text_color_unselected);
@@ -1544,7 +1544,7 @@ static void OVERLAY_object_name(Object *ob, int theme_id)
{
struct DRWTextStore *dt = DRW_text_cache_ensure();
uchar color[4];
- /* Color Management: Exception here as texts are drawn in sRGB space directly. */
+ /* Color Management: Exception here as texts are drawn in sRGB space directly. */
UI_GetThemeColor4ubv(theme_id, color);
DRW_text_cache_add(dt,
diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.c b/source/blender/draw/engines/overlay/overlay_motion_path.c
index a92f11aca38..e19d99dc597 100644
--- a/source/blender/draw/engines/overlay/overlay_motion_path.c
+++ b/source/blender/draw/engines/overlay/overlay_motion_path.c
@@ -177,7 +177,7 @@ static void motion_path_cache(OVERLAY_Data *vedata,
if (show_frame_no || (show_keyframes_no && show_keyframes)) {
int i;
uchar col[4], col_kf[4];
- /* Color Management: Exception here as texts are drawn in sRGB space directly. */
+ /* Color Management: Exception here as texts are drawn in sRGB space directly. */
UI_GetThemeColor3ubv(TH_TEXT_HI, col);
UI_GetThemeColor3ubv(TH_VERTEX_SELECT, col_kf);
col[3] = col_kf[3] = 255;
diff --git a/source/blender/draw/engines/overlay/overlay_outline.c b/source/blender/draw/engines/overlay/overlay_outline.c
index f1467ff9794..a2c3b5bf4aa 100644
--- a/source/blender/draw/engines/overlay/overlay_outline.c
+++ b/source/blender/draw/engines/overlay/overlay_outline.c
@@ -77,7 +77,7 @@ static void gpencil_depth_plane(Object *ob, float r_plane[4])
transpose_m4(mat);
/* mat is now a "normal" matrix which will transform
- * BBox space normal to world space. */
+ * BBox space normal to world space. */
mul_mat3_m4_v3(mat, r_plane);
normalize_v3(r_plane);
diff --git a/source/blender/draw/engines/overlay/overlay_particle.c b/source/blender/draw/engines/overlay/overlay_particle.c
index 5fa74a8c3a6..e51f7032288 100644
--- a/source/blender/draw/engines/overlay/overlay_particle.c
+++ b/source/blender/draw/engines/overlay/overlay_particle.c
@@ -174,7 +174,7 @@ void OVERLAY_particle_cache_populate(OVERLAY_Data *vedata, Object *ob)
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
if (part->type == PART_HAIR) {
- /* Hairs should have been rendered by the render engine.*/
+ /* Hairs should have been rendered by the render engine. */
continue;
}
diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h
index 969289a3219..a48b46a61fc 100644
--- a/source/blender/draw/engines/overlay/overlay_private.h
+++ b/source/blender/draw/engines/overlay/overlay_private.h
@@ -358,7 +358,7 @@ typedef struct OVERLAY_PrivateData {
bool select_vert;
bool select_face;
bool select_edge;
- int flag; /** Copy of v3d->overlay.edit_flag. */
+ int flag; /** Copy of #v3d->overlay.edit_flag. */
} edit_mesh;
struct {
bool use_weight;
diff --git a/source/blender/draw/engines/overlay/shaders/armature_shape_outline_geom.glsl b/source/blender/draw/engines/overlay/shaders/armature_shape_outline_geom.glsl
index 6398426952c..a2a478f400b 100644
--- a/source/blender/draw/engines/overlay/shaders/armature_shape_outline_geom.glsl
+++ b/source/blender/draw/engines/overlay/shaders/armature_shape_outline_geom.glsl
@@ -54,7 +54,7 @@ void main(void)
* (avoid problems with point behind near plane).
* If the chosen point is parallel to the edge in screen space,
* choose the other point anyway.
- * This fixes some issue with cubes in orthographic views.*/
+ * This fixes some issue with cubes in orthographic views. */
if (vPos[0].z < vPos[3].z) {
hidden_point = (abs(fac0) > 1e-5) ? ssPos[0] : ssPos[3];
}
diff --git a/source/blender/draw/engines/overlay/shaders/extra_vert.glsl b/source/blender/draw/engines/overlay/shaders/extra_vert.glsl
index 74854dc0f8d..59c9d0a665d 100644
--- a/source/blender/draw/engines/overlay/shaders/extra_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/extra_vert.glsl
@@ -162,13 +162,13 @@ void main()
int color_class = int(floor(color.r));
float color_intensity = fract(color.r);
switch (color_class) {
- case 0: /* No eye (convergence plane) */
+ case 0: /* No eye (convergence plane). */
finalColor = vec4(1.0, 1.0, 1.0, 1.0);
break;
- case 1: /* Left eye */
+ case 1: /* Left eye. */
finalColor = vec4(0.0, 1.0, 1.0, 1.0);
break;
- case 2: /* Right eye */
+ case 2: /* Right eye. */
finalColor = vec4(1.0, 0.0, 0.0, 1.0);
break;
}
@@ -207,7 +207,7 @@ void main()
vec3 n1 = normalize(cross(edge, world_pos - p1));
bool persp = (ProjectionMatrix[3][3] == 0.0);
vec3 V = (persp) ? normalize(ViewMatrixInverse[3].xyz - world_pos) : ViewMatrixInverse[2].xyz;
- /* Discard non-silhouete edges. */
+ /* Discard non-silhouette edges. */
bool facing0 = dot(n0, V) > 0.0;
bool facing1 = dot(n1, V) > 0.0;
if (facing0 == facing1) {
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
index 122c99ca536..8cbc8608f5b 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
@@ -59,7 +59,7 @@ void workbench_float_pair_decode(float data, out float v1, out float v2)
{
// const uint v1_mask = ~(0xFFFFFFFFu << ROUGHNESS_BITS);
// const uint v2_mask = ~(0xFFFFFFFFu << METALLIC_BITS);
- /* Same as above because some compiler are very dumb and think we use medium int. */
+ /* Same as above because some compiler are very dumb and think we use medium int. */
const int v1_mask = 0x1F;
const int v2_mask = 0x7;
int idata = int(data);
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
index a76a14fa750..2e229d4d83a 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
@@ -12,7 +12,7 @@ struct WorldData {
float shadow_shift;
float shadow_mul;
float shadow_add;
- /* - 16 bytes alignment- */
+ /* - 16 bytes alignment - */
LightData lights[4];
vec4 ambient_color;
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_image_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_image_lib.glsl
index 690ba1b92bc..57d648d3565 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_image_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_image_lib.glsl
@@ -1,5 +1,5 @@
-/* TODO(fclem): deduplicate code. */
+/* TODO(fclem): deduplicate code. */
bool node_tex_tile_lookup(inout vec3 co, sampler2DArray ima, sampler1DArray map)
{
vec2 tile_pos = floor(co.xy);
diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c
index a00453fe125..2261790226a 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c
@@ -157,7 +157,7 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata)
const float *full_size = DRW_viewport_size_get();
const int size[2] = {max_ii(1, (int)full_size[0] / 2), max_ii(1, (int)full_size[1] / 2)};
#if 0 /* TODO(fclem): finish COC min_max optimization. */
- /* NOTE: We Ceil here in order to not miss any edge texel if using a NPO2 texture. */
+ /* NOTE: We Ceil here in order to not miss any edge texel if using a NPO2 texture. */
int shrink_h_size[2] = {ceilf(size[0] / 8.0f), size[1]};
int shrink_w_size[2] = {shrink_h_size[0], ceilf(size[1] / 8.0f)};
#endif
@@ -218,9 +218,9 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata)
float focus_dist = BKE_camera_object_dof_distance(camera);
float focal_len = cam->lens;
- /* TODO(fclem): deduplicate with eevee */
+ /* TODO(fclem): de-duplicate with EEVEE. */
const float scale_camera = 0.001f;
- /* we want radius here for the aperture number */
+ /* We want radius here for the aperture number. */
float aperture = 0.5f * scale_camera * focal_len / fstop;
float focal_len_scaled = scale_camera * focal_len;
float sensor_scaled = scale_camera * sensor;
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index 6247436feea..453ef9c7f8e 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -381,13 +381,13 @@ typedef struct WORKBENCH_ObjectData {
} WORKBENCH_ObjectData;
typedef struct WORKBENCH_ViewLayerData {
- /** Depth of field sample location array.*/
+ /** Depth of field sample location array. */
struct GPUUniformBuf *dof_sample_ubo;
- /** All constant data used for a render loop.*/
+ /** All constant data used for a render loop. */
struct GPUUniformBuf *world_ubo;
- /** Cavity sample location array.*/
+ /** Cavity sample location array. */
struct GPUUniformBuf *cavity_sample_ubo;
- /** Blue noise texture used to randomize the sampling of some effects.*/
+ /** Blue noise texture used to randomize the sampling of some effects. */
struct GPUTexture *cavity_jitter_tx;
/** Materials UBO's allocated in a memblock for easy bookkeeping. */
struct BLI_memblock *material_ubo;
diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c
index ddda6d7b58e..daeadce3059 100644
--- a/source/blender/draw/engines/workbench/workbench_volume.c
+++ b/source/blender/draw/engines/workbench/workbench_volume.c
@@ -125,7 +125,7 @@ static void workbench_volume_modifier_cache_populate(WORKBENCH_Data *vedata,
fds->slice_axis - 1;
float dim[3];
BKE_object_dimensions_get(ob, dim);
- /* 0.05f to achieve somewhat the same opacity as the full view. */
+ /* 0.05f to achieve somewhat the same opacity as the full view. */
float step_length = max_ff(1e-16f, dim[axis] * 0.05f);
grp = DRW_shgroup_create(sh, vedata->psl->volume_ps);
@@ -266,7 +266,7 @@ static void workbench_volume_object_cache_populate(WORKBENCH_Data *vedata,
float dim[3];
BKE_object_dimensions_get(ob, dim);
- /* 0.05f to achieve somewhat the same opacity as the full view. */
+ /* 0.05f to achieve somewhat the same opacity as the full view. */
float step_length = max_ff(1e-16f, dim[axis] * 0.05f);
const float slice_position = volume->display.slice_depth;
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 5071658fd82..5d5a506c1e7 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -308,7 +308,7 @@ void DRW_shader_library_free(DRWShaderLibrary *lib);
* on the differences the minimum state changes can be invoked to setup the desired render state.
*
* The Write Stencil, Stencil test, Depth test and Blend state options are mutual exclusive
- * therefore they aren't ordered as a bit mask.*/
+ * therefore they aren't ordered as a bit mask. */
typedef enum {
/** Write mask */
DRW_STATE_WRITE_DEPTH = (1 << 0),
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index f902a95a19a..d55da3ed83b 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -2528,7 +2528,7 @@ GPUBatch *DRW_cache_bone_arrows_get(void)
for (int axis = 0; axis < 3; axis++) {
int flag = VCLASS_EMPTY_AXES | VCLASS_SCREENALIGNED;
/* Vertex layout is XY screen position and axis in Z.
- * Fractional part of Z is a positive offset at axis unit position.*/
+ * Fractional part of Z is a positive offset at axis unit position. */
float p[3] = {0.0f, 0.0f, axis};
/* center to axis line */
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.0f}, 0});
diff --git a/source/blender/draw/intern/draw_cache_extract.h b/source/blender/draw/intern/draw_cache_extract.h
index 5fc6629e804..be61b0a9baf 100644
--- a/source/blender/draw/intern/draw_cache_extract.h
+++ b/source/blender/draw/intern/draw_cache_extract.h
@@ -81,7 +81,7 @@ typedef enum eMRDataType {
MR_DATA_POLY_NOR = 1 << 1,
MR_DATA_LOOP_NOR = 1 << 2,
MR_DATA_LOOPTRI = 1 << 3,
- /** Force loop normals calculation. */
+ /** Force loop normals calculation. */
MR_DATA_TAN_LOOP_NOR = 1 << 4,
MR_DATA_MAT_OFFSETS = 1 << 5,
} eMRDataType;
@@ -263,8 +263,7 @@ typedef struct MeshBatchCache {
#define MBC_IBO_LEN (sizeof(((MeshBufferCache){0}).ibo) / sizeof(void *))
#define MBC_BATCH_INDEX(batch_name) \
- ((offsetof(MeshBatchCache, batch_name) - offsetof(MeshBatchCache, batch.surface)) / \
- sizeof(void *))
+ ((offsetof(MeshBatchCache, batch_name) - offsetof(MeshBatchCache, batch)) / sizeof(void *))
typedef enum DRWBatchFlag {
MBC_SURFACE = (1u << MBC_BATCH_INDEX(batch.surface)),
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc
index e577069f000..344150014ed 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.cc
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc
@@ -615,44 +615,54 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
/* Create an array containing all the extractors that needs to be executed. */
ExtractorRunDatas extractors;
-#define EXTRACT_ADD_REQUESTED(type, type_lowercase, name) \
+#define EXTRACT_ADD_REQUESTED(type, name) \
do { \
- if (DRW_##type_lowercase##_requested(mbc->type_lowercase.name)) { \
+ if (DRW_##type##_requested(mbc->type.name)) { \
const MeshExtract *extractor = mesh_extract_override_get( \
&extract_##name, do_hq_normals, override_single_mat); \
extractors.append(extractor); \
} \
} while (0)
- EXTRACT_ADD_REQUESTED(VBO, vbo, pos_nor);
- EXTRACT_ADD_REQUESTED(VBO, vbo, lnor);
- EXTRACT_ADD_REQUESTED(VBO, vbo, uv);
- EXTRACT_ADD_REQUESTED(VBO, vbo, tan);
- EXTRACT_ADD_REQUESTED(VBO, vbo, vcol);
- EXTRACT_ADD_REQUESTED(VBO, vbo, sculpt_data);
- EXTRACT_ADD_REQUESTED(VBO, vbo, orco);
- EXTRACT_ADD_REQUESTED(VBO, vbo, edge_fac);
- EXTRACT_ADD_REQUESTED(VBO, vbo, weights);
- EXTRACT_ADD_REQUESTED(VBO, vbo, edit_data);
- EXTRACT_ADD_REQUESTED(VBO, vbo, edituv_data);
- EXTRACT_ADD_REQUESTED(VBO, vbo, edituv_stretch_area);
- EXTRACT_ADD_REQUESTED(VBO, vbo, edituv_stretch_angle);
- EXTRACT_ADD_REQUESTED(VBO, vbo, mesh_analysis);
- EXTRACT_ADD_REQUESTED(VBO, vbo, fdots_pos);
- EXTRACT_ADD_REQUESTED(VBO, vbo, fdots_nor);
- EXTRACT_ADD_REQUESTED(VBO, vbo, fdots_uv);
- EXTRACT_ADD_REQUESTED(VBO, vbo, fdots_edituv_data);
- EXTRACT_ADD_REQUESTED(VBO, vbo, poly_idx);
- EXTRACT_ADD_REQUESTED(VBO, vbo, edge_idx);
- EXTRACT_ADD_REQUESTED(VBO, vbo, vert_idx);
- EXTRACT_ADD_REQUESTED(VBO, vbo, fdot_idx);
- EXTRACT_ADD_REQUESTED(VBO, vbo, skin_roots);
-
- EXTRACT_ADD_REQUESTED(IBO, ibo, tris);
- if (DRW_ibo_requested(mbc->ibo.lines)) {
+ EXTRACT_ADD_REQUESTED(vbo, pos_nor);
+ EXTRACT_ADD_REQUESTED(vbo, lnor);
+ EXTRACT_ADD_REQUESTED(vbo, uv);
+ EXTRACT_ADD_REQUESTED(vbo, tan);
+ EXTRACT_ADD_REQUESTED(vbo, vcol);
+ EXTRACT_ADD_REQUESTED(vbo, sculpt_data);
+ EXTRACT_ADD_REQUESTED(vbo, orco);
+ EXTRACT_ADD_REQUESTED(vbo, edge_fac);
+ EXTRACT_ADD_REQUESTED(vbo, weights);
+ EXTRACT_ADD_REQUESTED(vbo, edit_data);
+ EXTRACT_ADD_REQUESTED(vbo, edituv_data);
+ EXTRACT_ADD_REQUESTED(vbo, edituv_stretch_area);
+ EXTRACT_ADD_REQUESTED(vbo, edituv_stretch_angle);
+ EXTRACT_ADD_REQUESTED(vbo, mesh_analysis);
+ EXTRACT_ADD_REQUESTED(vbo, fdots_pos);
+ EXTRACT_ADD_REQUESTED(vbo, fdots_nor);
+ EXTRACT_ADD_REQUESTED(vbo, fdots_uv);
+ EXTRACT_ADD_REQUESTED(vbo, fdots_edituv_data);
+ EXTRACT_ADD_REQUESTED(vbo, poly_idx);
+ EXTRACT_ADD_REQUESTED(vbo, edge_idx);
+ EXTRACT_ADD_REQUESTED(vbo, vert_idx);
+ EXTRACT_ADD_REQUESTED(vbo, fdot_idx);
+ EXTRACT_ADD_REQUESTED(vbo, skin_roots);
+
+ EXTRACT_ADD_REQUESTED(ibo, tris);
+ if (DRW_ibo_requested(mbc->ibo.lines_loose)) {
+ /* `ibo.lines_loose` require the `ibo.lines` buffer. */
+ if (mbc->ibo.lines == nullptr) {
+ DRW_ibo_request(nullptr, &mbc->ibo.lines);
+ }
+ const MeshExtract *extractor = DRW_ibo_requested(mbc->ibo.lines) ?
+ &extract_lines_with_lines_loose :
+ &extract_lines_loose_only;
+ extractors.append(extractor);
+ }
+ else if (DRW_ibo_requested(mbc->ibo.lines)) {
const MeshExtract *extractor;
if (mbc->ibo.lines_loose != nullptr) {
- /* Update #lines_loose ibo. */
+ /* Update `ibo.lines_loose` as it depends on `ibo.lines`. */
extractor = &extract_lines_with_lines_loose;
}
else {
@@ -660,19 +670,14 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
}
extractors.append(extractor);
}
- else if (DRW_ibo_requested(mbc->ibo.lines_loose)) {
- /* Note: #ibo.lines must have been created first. */
- const MeshExtract *extractor = &extract_lines_loose_only;
- extractors.append(extractor);
- }
- EXTRACT_ADD_REQUESTED(IBO, ibo, points);
- EXTRACT_ADD_REQUESTED(IBO, ibo, fdots);
- EXTRACT_ADD_REQUESTED(IBO, ibo, lines_paint_mask);
- EXTRACT_ADD_REQUESTED(IBO, ibo, lines_adjacency);
- EXTRACT_ADD_REQUESTED(IBO, ibo, edituv_tris);
- EXTRACT_ADD_REQUESTED(IBO, ibo, edituv_lines);
- EXTRACT_ADD_REQUESTED(IBO, ibo, edituv_points);
- EXTRACT_ADD_REQUESTED(IBO, ibo, edituv_fdots);
+ EXTRACT_ADD_REQUESTED(ibo, points);
+ EXTRACT_ADD_REQUESTED(ibo, fdots);
+ EXTRACT_ADD_REQUESTED(ibo, lines_paint_mask);
+ EXTRACT_ADD_REQUESTED(ibo, lines_adjacency);
+ EXTRACT_ADD_REQUESTED(ibo, edituv_tris);
+ EXTRACT_ADD_REQUESTED(ibo, edituv_lines);
+ EXTRACT_ADD_REQUESTED(ibo, edituv_points);
+ EXTRACT_ADD_REQUESTED(ibo, edituv_fdots);
#undef EXTRACT_ADD_REQUESTED
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c b/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c
index 42cd571b089..e813f006351 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c
@@ -25,29 +25,10 @@
#include "MEM_guardedalloc.h"
-#include "atomic_ops.h"
-
#include "DNA_object_types.h"
-#include "BLI_edgehash.h"
-#include "BLI_jitter_2d.h"
-#include "BLI_kdopbvh.h"
-#include "BLI_string.h"
-
-#include "BKE_bvhutils.h"
-#include "BKE_deform.h"
-#include "BKE_editmesh.h"
-#include "BKE_editmesh_bvh.h"
-#include "BKE_editmesh_cache.h"
-#include "BKE_editmesh_tangent.h"
-#include "BKE_mesh.h"
-#include "BKE_mesh_tangent.h"
-#include "BKE_paint.h"
-
#include "ED_uvedit.h"
-#include "GPU_capabilities.h"
-
#include "draw_cache_extract_mesh_private.h"
#include "draw_cache_impl.h"
@@ -120,1577 +101,13 @@ const MeshExtract *mesh_extract_override_get(const MeshExtract *extractor,
/** \} */
/* ---------------------------------------------------------------------- */
-/** \name Extract Position and Vertex Normal
- * \{ */
-
-typedef struct PosNorLoop {
- float pos[3];
- GPUPackedNormal nor;
-} PosNorLoop;
-
-typedef struct MeshExtract_PosNor_Data {
- PosNorLoop *vbo_data;
- GPUNormal *normals;
-} MeshExtract_PosNor_Data;
-
-static void extract_pos_nor_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- /* WARNING Adjust #PosNorLoop struct accordingly. */
- GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I10, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
- GPU_vertformat_alias_add(&format, "vnor");
- }
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
-
- /* Pack normals per vert, reduce amount of computation. */
- MeshExtract_PosNor_Data *data = tls_data;
- data->vbo_data = (PosNorLoop *)GPU_vertbuf_get_data(vbo);
- data->normals = MEM_mallocN(sizeof(GPUNormal) * mr->vert_len, __func__);
-
- /* Quicker than doing it for each loop. */
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- BMIter iter;
- BMVert *eve;
- int v;
- BM_ITER_MESH_INDEX (eve, &iter, mr->bm, BM_VERTS_OF_MESH, v) {
- data->normals[v].low = GPU_normal_convert_i10_v3(bm_vert_no_get(mr, eve));
- }
- }
- else {
- const MVert *mv = mr->mvert;
- for (int v = 0; v < mr->vert_len; v++, mv++) {
- data->normals[v].low = GPU_normal_convert_i10_s3(mv->no);
- }
- }
-}
-
-static void extract_pos_nor_iter_poly_bm(const MeshRenderData *mr,
- const BMFace *f,
- const int UNUSED(f_index),
- void *_data)
-{
- MeshExtract_PosNor_Data *data = _data;
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
- PosNorLoop *vert = &data->vbo_data[l_index];
- copy_v3_v3(vert->pos, bm_vert_co_get(mr, l_iter->v));
- vert->nor = data->normals[BM_elem_index_get(l_iter->v)].low;
- vert->nor.w = BM_elem_flag_test(f, BM_ELEM_HIDDEN) ? -1 : 0;
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_pos_nor_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int UNUSED(mp_index),
- void *_data)
-{
- MeshExtract_PosNor_Data *data = _data;
-
- const MLoop *mloop = mr->mloop;
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
-
- PosNorLoop *vert = &data->vbo_data[ml_index];
- const MVert *mv = &mr->mvert[ml->v];
- copy_v3_v3(vert->pos, mv->co);
- vert->nor = data->normals[ml->v].low;
- /* Flag for paint mode overlay. */
- if (mp->flag & ME_HIDE || mv->flag & ME_HIDE ||
- ((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->v_origindex) &&
- (mr->v_origindex[ml->v] == ORIGINDEX_NONE))) {
- vert->nor.w = -1;
- }
- else if (mv->flag & SELECT) {
- vert->nor.w = 1;
- }
- else {
- vert->nor.w = 0;
- }
- }
-}
-
-static void extract_pos_nor_iter_ledge_bm(const MeshRenderData *mr,
- const BMEdge *eed,
- const int ledge_index,
- void *_data)
-{
- MeshExtract_PosNor_Data *data = _data;
-
- int l_index = mr->loop_len + ledge_index * 2;
- PosNorLoop *vert = &data->vbo_data[l_index];
- copy_v3_v3(vert[0].pos, bm_vert_co_get(mr, eed->v1));
- copy_v3_v3(vert[1].pos, bm_vert_co_get(mr, eed->v2));
- vert[0].nor = data->normals[BM_elem_index_get(eed->v1)].low;
- vert[1].nor = data->normals[BM_elem_index_get(eed->v2)].low;
-}
-
-static void extract_pos_nor_iter_ledge_mesh(const MeshRenderData *mr,
- const MEdge *med,
- const int ledge_index,
- void *_data)
-{
- MeshExtract_PosNor_Data *data = _data;
- const int ml_index = mr->loop_len + ledge_index * 2;
- PosNorLoop *vert = &data->vbo_data[ml_index];
- copy_v3_v3(vert[0].pos, mr->mvert[med->v1].co);
- copy_v3_v3(vert[1].pos, mr->mvert[med->v2].co);
- vert[0].nor = data->normals[med->v1].low;
- vert[1].nor = data->normals[med->v2].low;
-}
-
-static void extract_pos_nor_iter_lvert_bm(const MeshRenderData *mr,
- const BMVert *eve,
- const int lvert_index,
- void *_data)
-{
- MeshExtract_PosNor_Data *data = _data;
- const int offset = mr->loop_len + (mr->edge_loose_len * 2);
-
- const int l_index = offset + lvert_index;
- PosNorLoop *vert = &data->vbo_data[l_index];
- copy_v3_v3(vert->pos, bm_vert_co_get(mr, eve));
- vert->nor = data->normals[BM_elem_index_get(eve)].low;
-}
-
-static void extract_pos_nor_iter_lvert_mesh(const MeshRenderData *mr,
- const MVert *mv,
- const int lvert_index,
- void *_data)
-{
- MeshExtract_PosNor_Data *data = _data;
- const int offset = mr->loop_len + (mr->edge_loose_len * 2);
-
- const int ml_index = offset + lvert_index;
- const int v_index = mr->lverts[lvert_index];
- PosNorLoop *vert = &data->vbo_data[ml_index];
- copy_v3_v3(vert->pos, mv->co);
- vert->nor = data->normals[v_index].low;
-}
-
-static void extract_pos_nor_finish(const MeshRenderData *UNUSED(mr),
- struct MeshBatchCache *UNUSED(cache),
- void *UNUSED(buf),
- void *_data)
-{
- MeshExtract_PosNor_Data *data = _data;
- MEM_freeN(data->normals);
-}
-
-const MeshExtract extract_pos_nor = {
- .init = extract_pos_nor_init,
- .iter_poly_bm = extract_pos_nor_iter_poly_bm,
- .iter_poly_mesh = extract_pos_nor_iter_poly_mesh,
- .iter_ledge_bm = extract_pos_nor_iter_ledge_bm,
- .iter_ledge_mesh = extract_pos_nor_iter_ledge_mesh,
- .iter_lvert_bm = extract_pos_nor_iter_lvert_bm,
- .iter_lvert_mesh = extract_pos_nor_iter_lvert_mesh,
- .finish = extract_pos_nor_finish,
- .data_type = 0,
- .data_size = sizeof(MeshExtract_PosNor_Data),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.pos_nor),
-};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Position and High Quality Vertex Normal
- * \{ */
-
-typedef struct PosNorHQLoop {
- float pos[3];
- short nor[4];
-} PosNorHQLoop;
-
-typedef struct MeshExtract_PosNorHQ_Data {
- PosNorHQLoop *vbo_data;
- GPUNormal *normals;
-} MeshExtract_PosNorHQ_Data;
-
-static void extract_pos_nor_hq_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- /* WARNING Adjust #PosNorHQLoop struct accordingly. */
- GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
- GPU_vertformat_alias_add(&format, "vnor");
- }
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
-
- /* Pack normals per vert, reduce amount of computation. */
- MeshExtract_PosNorHQ_Data *data = tls_data;
- data->vbo_data = (PosNorHQLoop *)GPU_vertbuf_get_data(vbo);
- data->normals = MEM_mallocN(sizeof(GPUNormal) * mr->vert_len, __func__);
-
- /* Quicker than doing it for each loop. */
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- BMIter iter;
- BMVert *eve;
- int v;
- BM_ITER_MESH_INDEX (eve, &iter, mr->bm, BM_VERTS_OF_MESH, v) {
- normal_float_to_short_v3(data->normals[v].high, bm_vert_no_get(mr, eve));
- }
- }
- else {
- const MVert *mv = mr->mvert;
- for (int v = 0; v < mr->vert_len; v++, mv++) {
- copy_v3_v3_short(data->normals[v].high, mv->no);
- }
- }
-}
-
-static void extract_pos_nor_hq_iter_poly_bm(const MeshRenderData *mr,
- const BMFace *f,
- const int UNUSED(f_index),
- void *_data)
-{
- MeshExtract_PosNorHQ_Data *data = _data;
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
- PosNorHQLoop *vert = &data->vbo_data[l_index];
- copy_v3_v3(vert->pos, bm_vert_co_get(mr, l_iter->v));
- copy_v3_v3_short(vert->nor, data->normals[BM_elem_index_get(l_iter->v)].high);
-
- BMFace *efa = l_iter->f;
- vert->nor[3] = BM_elem_flag_test(efa, BM_ELEM_HIDDEN) ? -1 : 0;
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_pos_nor_hq_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int UNUSED(mp_index),
- void *_data)
-{
- MeshExtract_PosNorHQ_Data *data = _data;
- const MLoop *mloop = mr->mloop;
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
-
- PosNorHQLoop *vert = &data->vbo_data[ml_index];
- const MVert *mv = &mr->mvert[ml->v];
- copy_v3_v3(vert->pos, mv->co);
- copy_v3_v3_short(vert->nor, data->normals[ml->v].high);
-
- /* Flag for paint mode overlay. */
- if (mp->flag & ME_HIDE || mv->flag & ME_HIDE ||
- ((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->v_origindex) &&
- (mr->v_origindex[ml->v] == ORIGINDEX_NONE))) {
- vert->nor[3] = -1;
- }
- else if (mv->flag & SELECT) {
- vert->nor[3] = 1;
- }
- else {
- vert->nor[3] = 0;
- }
- }
-}
-
-static void extract_pos_nor_hq_iter_ledge_bm(const MeshRenderData *mr,
- const BMEdge *eed,
- const int ledge_index,
- void *_data)
-{
- MeshExtract_PosNorHQ_Data *data = _data;
- int l_index = mr->loop_len + ledge_index * 2;
- PosNorHQLoop *vert = &data->vbo_data[l_index];
- copy_v3_v3(vert[0].pos, bm_vert_co_get(mr, eed->v1));
- copy_v3_v3(vert[1].pos, bm_vert_co_get(mr, eed->v2));
- copy_v3_v3_short(vert[0].nor, data->normals[BM_elem_index_get(eed->v1)].high);
- vert[0].nor[3] = 0;
- copy_v3_v3_short(vert[1].nor, data->normals[BM_elem_index_get(eed->v2)].high);
- vert[1].nor[3] = 0;
-}
-
-static void extract_pos_nor_hq_iter_ledge_mesh(const MeshRenderData *mr,
- const MEdge *med,
- const int ledge_index,
- void *_data)
-{
- MeshExtract_PosNorHQ_Data *data = _data;
- const int ml_index = mr->loop_len + ledge_index * 2;
- PosNorHQLoop *vert = &data->vbo_data[ml_index];
- copy_v3_v3(vert[0].pos, mr->mvert[med->v1].co);
- copy_v3_v3(vert[1].pos, mr->mvert[med->v2].co);
- copy_v3_v3_short(vert[0].nor, data->normals[med->v1].high);
- vert[0].nor[3] = 0;
- copy_v3_v3_short(vert[1].nor, data->normals[med->v2].high);
- vert[1].nor[3] = 0;
-}
-
-static void extract_pos_nor_hq_iter_lvert_bm(const MeshRenderData *mr,
- const BMVert *eve,
- const int lvert_index,
- void *_data)
-{
- MeshExtract_PosNorHQ_Data *data = _data;
- const int offset = mr->loop_len + (mr->edge_loose_len * 2);
-
- const int l_index = offset + lvert_index;
- PosNorHQLoop *vert = &data->vbo_data[l_index];
- copy_v3_v3(vert->pos, bm_vert_co_get(mr, eve));
- copy_v3_v3_short(vert->nor, data->normals[BM_elem_index_get(eve)].high);
- vert->nor[3] = 0;
-}
-
-static void extract_pos_nor_hq_iter_lvert_mesh(const MeshRenderData *mr,
- const MVert *mv,
- const int lvert_index,
- void *_data)
-{
- MeshExtract_PosNorHQ_Data *data = _data;
- const int offset = mr->loop_len + (mr->edge_loose_len * 2);
-
- const int ml_index = offset + lvert_index;
- const int v_index = mr->lverts[lvert_index];
- PosNorHQLoop *vert = &data->vbo_data[ml_index];
- copy_v3_v3(vert->pos, mv->co);
- copy_v3_v3_short(vert->nor, data->normals[v_index].high);
- vert->nor[3] = 0;
-}
-
-static void extract_pos_nor_hq_finish(const MeshRenderData *UNUSED(mr),
- struct MeshBatchCache *UNUSED(cache),
- void *UNUSED(buf),
- void *_data)
-{
- MeshExtract_PosNorHQ_Data *data = _data;
- MEM_freeN(data->normals);
-}
-
-const MeshExtract extract_pos_nor_hq = {
- .init = extract_pos_nor_hq_init,
- .iter_poly_bm = extract_pos_nor_hq_iter_poly_bm,
- .iter_poly_mesh = extract_pos_nor_hq_iter_poly_mesh,
- .iter_ledge_bm = extract_pos_nor_hq_iter_ledge_bm,
- .iter_ledge_mesh = extract_pos_nor_hq_iter_ledge_mesh,
- .iter_lvert_bm = extract_pos_nor_hq_iter_lvert_bm,
- .iter_lvert_mesh = extract_pos_nor_hq_iter_lvert_mesh,
- .finish = extract_pos_nor_hq_finish,
- .data_type = 0,
- .data_size = sizeof(MeshExtract_PosNorHQ_Data),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.pos_nor)};
-
-/** \} */
-/* ---------------------------------------------------------------------- */
-/** \name Extract HQ Loop Normal
- * \{ */
-
-typedef struct gpuHQNor {
- short x, y, z, w;
-} gpuHQNor;
-
-static void extract_lnor_hq_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
- GPU_vertformat_alias_add(&format, "lnor");
- }
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len);
-
- *(gpuHQNor **)tls_data = GPU_vertbuf_get_data(vbo);
-}
-
-static void extract_lnor_hq_iter_poly_bm(const MeshRenderData *mr,
- const BMFace *f,
- const int UNUSED(f_index),
- void *data)
-{
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
- if (mr->loop_normals) {
- normal_float_to_short_v3(&(*(gpuHQNor **)data)[l_index].x, mr->loop_normals[l_index]);
- }
- else {
- if (BM_elem_flag_test(f, BM_ELEM_SMOOTH)) {
- normal_float_to_short_v3(&(*(gpuHQNor **)data)[l_index].x, bm_vert_no_get(mr, l_iter->v));
- }
- else {
- normal_float_to_short_v3(&(*(gpuHQNor **)data)[l_index].x, bm_face_no_get(mr, f));
- }
- }
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_lnor_hq_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int mp_index,
- void *data)
-{
- const MLoop *mloop = mr->mloop;
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
- gpuHQNor *lnor_data = &(*(gpuHQNor **)data)[ml_index];
- if (mr->loop_normals) {
- normal_float_to_short_v3(&lnor_data->x, mr->loop_normals[ml_index]);
- }
- else if (mp->flag & ME_SMOOTH) {
- copy_v3_v3_short(&lnor_data->x, mr->mvert[ml->v].no);
- }
- else {
- normal_float_to_short_v3(&lnor_data->x, mr->poly_normals[mp_index]);
- }
-
- /* Flag for paint mode overlay.
- * Only use #MR_EXTRACT_MAPPED in edit mode where it is used to display the edge-normals.
- * In paint mode it will use the un-mapped data to draw the wire-frame. */
- if (mp->flag & ME_HIDE || (mr->edit_bmesh && mr->extract_type == MR_EXTRACT_MAPPED &&
- (mr->v_origindex) && mr->v_origindex[ml->v] == ORIGINDEX_NONE)) {
- lnor_data->w = -1;
- }
- else if (mp->flag & ME_FACE_SEL) {
- lnor_data->w = 1;
- }
- else {
- lnor_data->w = 0;
- }
- }
-}
-
-const MeshExtract extract_lnor_hq = {
- .init = extract_lnor_hq_init,
- .iter_poly_bm = extract_lnor_hq_iter_poly_bm,
- .iter_poly_mesh = extract_lnor_hq_iter_poly_mesh,
- .data_type = MR_DATA_LOOP_NOR,
- .data_size = sizeof(gpuHQNor *),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.lnor),
-};
-
-/** \} */
-/* ---------------------------------------------------------------------- */
-/** \name Extract Loop Normal
- * \{ */
-
-static void extract_lnor_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I10, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
- GPU_vertformat_alias_add(&format, "lnor");
- }
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len);
-
- *(GPUPackedNormal **)tls_data = GPU_vertbuf_get_data(vbo);
-}
-
-static void extract_lnor_iter_poly_bm(const MeshRenderData *mr,
- const BMFace *f,
- const int UNUSED(f_index),
- void *data)
-{
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
- if (mr->loop_normals) {
- (*(GPUPackedNormal **)data)[l_index] = GPU_normal_convert_i10_v3(mr->loop_normals[l_index]);
- }
- else {
- if (BM_elem_flag_test(f, BM_ELEM_SMOOTH)) {
- (*(GPUPackedNormal **)data)[l_index] = GPU_normal_convert_i10_v3(
- bm_vert_no_get(mr, l_iter->v));
- }
- else {
- (*(GPUPackedNormal **)data)[l_index] = GPU_normal_convert_i10_v3(bm_face_no_get(mr, f));
- }
- }
- (*(GPUPackedNormal **)data)[l_index].w = BM_elem_flag_test(f, BM_ELEM_HIDDEN) ? -1 : 0;
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_lnor_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int mp_index,
- void *data)
-{
- const MLoop *mloop = mr->mloop;
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
- GPUPackedNormal *lnor_data = &(*(GPUPackedNormal **)data)[ml_index];
- if (mr->loop_normals) {
- *lnor_data = GPU_normal_convert_i10_v3(mr->loop_normals[ml_index]);
- }
- else if (mp->flag & ME_SMOOTH) {
- *lnor_data = GPU_normal_convert_i10_s3(mr->mvert[ml->v].no);
- }
- else {
- *lnor_data = GPU_normal_convert_i10_v3(mr->poly_normals[mp_index]);
- }
-
- /* Flag for paint mode overlay.
- * Only use MR_EXTRACT_MAPPED in edit mode where it is used to display the edge-normals.
- * In paint mode it will use the un-mapped data to draw the wire-frame. */
- if (mp->flag & ME_HIDE || (mr->edit_bmesh && mr->extract_type == MR_EXTRACT_MAPPED &&
- (mr->v_origindex) && mr->v_origindex[ml->v] == ORIGINDEX_NONE)) {
- lnor_data->w = -1;
- }
- else if (mp->flag & ME_FACE_SEL) {
- lnor_data->w = 1;
- }
- else {
- lnor_data->w = 0;
- }
- }
-}
-
-const MeshExtract extract_lnor = {
- .init = extract_lnor_init,
- .iter_poly_bm = extract_lnor_iter_poly_bm,
- .iter_poly_mesh = extract_lnor_iter_poly_mesh,
- .data_type = MR_DATA_LOOP_NOR,
- .data_size = sizeof(GPUPackedNormal *),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.lnor),
-};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract UV layers
- * \{ */
-
-static void extract_uv_init(const MeshRenderData *mr,
- struct MeshBatchCache *cache,
- void *buf,
- void *UNUSED(tls_data))
-{
- GPUVertBuf *vbo = buf;
- GPUVertFormat format = {0};
- GPU_vertformat_deinterleave(&format);
-
- CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
- uint32_t uv_layers = cache->cd_used.uv;
- /* HACK to fix T68857 */
- if (mr->extract_type == MR_EXTRACT_BMESH && cache->cd_used.edit_uv == 1) {
- int layer = CustomData_get_active_layer(cd_ldata, CD_MLOOPUV);
- if (layer != -1) {
- uv_layers |= (1 << layer);
- }
- }
-
- for (int i = 0; i < MAX_MTFACE; i++) {
- if (uv_layers & (1 << i)) {
- char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
- const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i);
-
- GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
- /* UV layer name. */
- BLI_snprintf(attr_name, sizeof(attr_name), "u%s", attr_safe_name);
- GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- /* Auto layer name. */
- BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name);
- GPU_vertformat_alias_add(&format, attr_name);
- /* Active render layer name. */
- if (i == CustomData_get_render_layer(cd_ldata, CD_MLOOPUV)) {
- GPU_vertformat_alias_add(&format, "u");
- }
- /* Active display layer name. */
- if (i == CustomData_get_active_layer(cd_ldata, CD_MLOOPUV)) {
- GPU_vertformat_alias_add(&format, "au");
- /* Alias to `pos` for edit uvs. */
- GPU_vertformat_alias_add(&format, "pos");
- }
- /* Stencil mask uv layer name. */
- if (i == CustomData_get_stencil_layer(cd_ldata, CD_MLOOPUV)) {
- GPU_vertformat_alias_add(&format, "mu");
- }
- }
- }
-
- int v_len = mr->loop_len;
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
- /* VBO will not be used, only allocate minimum of memory. */
- v_len = 1;
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, v_len);
-
- float(*uv_data)[2] = (float(*)[2])GPU_vertbuf_get_data(vbo);
- for (int i = 0; i < MAX_MTFACE; i++) {
- if (uv_layers & (1 << i)) {
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- int cd_ofs = CustomData_get_n_offset(cd_ldata, CD_MLOOPUV, i);
- BMIter f_iter;
- BMFace *efa;
- BM_ITER_MESH (efa, &f_iter, mr->bm, BM_FACES_OF_MESH) {
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
- do {
- MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l_iter, cd_ofs);
- memcpy(uv_data, luv->uv, sizeof(*uv_data));
- uv_data++;
- } while ((l_iter = l_iter->next) != l_first);
- }
- }
- else {
- MLoopUV *layer_data = CustomData_get_layer_n(cd_ldata, CD_MLOOPUV, i);
- for (int ml_index = 0; ml_index < mr->loop_len; ml_index++, uv_data++, layer_data++) {
- memcpy(uv_data, layer_data->uv, sizeof(*uv_data));
- }
- }
- }
- }
-}
-
-const MeshExtract extract_uv = {
- .init = extract_uv_init,
- .data_type = 0,
- .data_size = 0,
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.uv),
-};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Tangent layers
- * \{ */
-
-static void extract_tan_ex_init(const MeshRenderData *mr,
- struct MeshBatchCache *cache,
- GPUVertBuf *vbo,
- const bool do_hq)
-{
- GPUVertCompType comp_type = do_hq ? GPU_COMP_I16 : GPU_COMP_I10;
- GPUVertFetchMode fetch_mode = GPU_FETCH_INT_TO_FLOAT_UNIT;
-
- GPUVertFormat format = {0};
- GPU_vertformat_deinterleave(&format);
-
- CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
- CustomData *cd_vdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->vdata : &mr->me->vdata;
- uint32_t tan_layers = cache->cd_used.tan;
- float(*orco)[3] = CustomData_get_layer(cd_vdata, CD_ORCO);
- bool orco_allocated = false;
- const bool use_orco_tan = cache->cd_used.tan_orco != 0;
-
- int tan_len = 0;
- char tangent_names[MAX_MTFACE][MAX_CUSTOMDATA_LAYER_NAME];
-
- for (int i = 0; i < MAX_MTFACE; i++) {
- if (tan_layers & (1 << i)) {
- char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
- const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i);
- GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
- /* Tangent layer name. */
- BLI_snprintf(attr_name, sizeof(attr_name), "t%s", attr_safe_name);
- GPU_vertformat_attr_add(&format, attr_name, comp_type, 4, fetch_mode);
- /* Active render layer name. */
- if (i == CustomData_get_render_layer(cd_ldata, CD_MLOOPUV)) {
- GPU_vertformat_alias_add(&format, "t");
- }
- /* Active display layer name. */
- if (i == CustomData_get_active_layer(cd_ldata, CD_MLOOPUV)) {
- GPU_vertformat_alias_add(&format, "at");
- }
-
- BLI_strncpy(tangent_names[tan_len++], layer_name, MAX_CUSTOMDATA_LAYER_NAME);
- }
- }
- if (use_orco_tan && orco == NULL) {
- /* If `orco` is not available compute it ourselves */
- orco_allocated = true;
- orco = MEM_mallocN(sizeof(*orco) * mr->vert_len, __func__);
-
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- BMesh *bm = mr->bm;
- for (int v = 0; v < mr->vert_len; v++) {
- const BMVert *eve = BM_vert_at_index(bm, v);
- /* Exceptional case where #bm_vert_co_get can be avoided, as we want the original coords.
- * not the distorted ones. */
- copy_v3_v3(orco[v], eve->co);
- }
- }
- else {
- const MVert *mv = mr->mvert;
- for (int v = 0; v < mr->vert_len; v++, mv++) {
- copy_v3_v3(orco[v], mv->co);
- }
- }
- BKE_mesh_orco_verts_transform(mr->me, orco, mr->vert_len, 0);
- }
-
- /* Start Fresh */
- CustomData loop_data;
- CustomData_reset(&loop_data);
- if (tan_len != 0 || use_orco_tan) {
- short tangent_mask = 0;
- bool calc_active_tangent = false;
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- BKE_editmesh_loop_tangent_calc(mr->edit_bmesh,
- calc_active_tangent,
- tangent_names,
- tan_len,
- mr->poly_normals,
- mr->loop_normals,
- orco,
- &loop_data,
- mr->loop_len,
- &tangent_mask);
- }
- else {
- BKE_mesh_calc_loop_tangent_ex(mr->mvert,
- mr->mpoly,
- mr->poly_len,
- mr->mloop,
- mr->mlooptri,
- mr->tri_len,
- cd_ldata,
- calc_active_tangent,
- tangent_names,
- tan_len,
- mr->poly_normals,
- mr->loop_normals,
- orco,
- &loop_data,
- mr->loop_len,
- &tangent_mask);
- }
- }
-
- if (use_orco_tan) {
- char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
- const char *layer_name = CustomData_get_layer_name(&loop_data, CD_TANGENT, 0);
- GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
- BLI_snprintf(attr_name, sizeof(*attr_name), "t%s", attr_safe_name);
- GPU_vertformat_attr_add(&format, attr_name, comp_type, 4, fetch_mode);
- GPU_vertformat_alias_add(&format, "t");
- GPU_vertformat_alias_add(&format, "at");
- }
-
- if (orco_allocated) {
- MEM_SAFE_FREE(orco);
- }
-
- int v_len = mr->loop_len;
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
- /* VBO will not be used, only allocate minimum of memory. */
- v_len = 1;
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, v_len);
-
- if (do_hq) {
- short(*tan_data)[4] = (short(*)[4])GPU_vertbuf_get_data(vbo);
- for (int i = 0; i < tan_len; i++) {
- const char *name = tangent_names[i];
- float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_named(
- &loop_data, CD_TANGENT, name);
- for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) {
- normal_float_to_short_v3(*tan_data, layer_data[ml_index]);
- (*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? SHRT_MAX : SHRT_MIN;
- tan_data++;
- }
- }
- if (use_orco_tan) {
- float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_n(&loop_data, CD_TANGENT, 0);
- for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) {
- normal_float_to_short_v3(*tan_data, layer_data[ml_index]);
- (*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? SHRT_MAX : SHRT_MIN;
- tan_data++;
- }
- }
- }
- else {
- GPUPackedNormal *tan_data = (GPUPackedNormal *)GPU_vertbuf_get_data(vbo);
- for (int i = 0; i < tan_len; i++) {
- const char *name = tangent_names[i];
- float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_named(
- &loop_data, CD_TANGENT, name);
- for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) {
- *tan_data = GPU_normal_convert_i10_v3(layer_data[ml_index]);
- tan_data->w = (layer_data[ml_index][3] > 0.0f) ? 1 : -2;
- tan_data++;
- }
- }
- if (use_orco_tan) {
- float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_n(&loop_data, CD_TANGENT, 0);
- for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) {
- *tan_data = GPU_normal_convert_i10_v3(layer_data[ml_index]);
- tan_data->w = (layer_data[ml_index][3] > 0.0f) ? 1 : -2;
- tan_data++;
- }
- }
- }
-
- CustomData_free(&loop_data, mr->loop_len);
-}
-
-static void extract_tan_init(const MeshRenderData *mr,
- struct MeshBatchCache *cache,
- void *buf,
- void *UNUSED(tls_data))
-{
- extract_tan_ex_init(mr, cache, buf, false);
-}
-
-const MeshExtract extract_tan = {
- .init = extract_tan_init,
- .data_type = MR_DATA_POLY_NOR | MR_DATA_TAN_LOOP_NOR | MR_DATA_LOOPTRI,
- .data_size = 0,
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.tan),
-};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract HQ Tangent layers
- * \{ */
-
-static void extract_tan_hq_init(const MeshRenderData *mr,
- struct MeshBatchCache *cache,
- void *buf,
- void *UNUSED(tls_data))
-{
- extract_tan_ex_init(mr, cache, buf, true);
-}
-
-const MeshExtract extract_tan_hq = {
- .init = extract_tan_hq_init,
- .data_type = MR_DATA_POLY_NOR | MR_DATA_TAN_LOOP_NOR | MR_DATA_LOOPTRI,
- .data_size = 0,
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.tan),
-};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Sculpt Data
+/** \name Extract Edit Flag Utils
* \{ */
-static void extract_sculpt_data_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *UNUSED(tls_data))
-{
- GPUVertBuf *vbo = buf;
- GPUVertFormat format = {0};
-
- CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
- CustomData *cd_vdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->vdata : &mr->me->vdata;
- CustomData *cd_pdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->pdata : &mr->me->pdata;
-
- float *cd_mask = CustomData_get_layer(cd_vdata, CD_PAINT_MASK);
- int *cd_face_set = CustomData_get_layer(cd_pdata, CD_SCULPT_FACE_SETS);
-
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "fset", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
- GPU_vertformat_attr_add(&format, "msk", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len);
-
- typedef struct gpuSculptData {
- uint8_t face_set_color[4];
- float mask;
- } gpuSculptData;
-
- gpuSculptData *vbo_data = (gpuSculptData *)GPU_vertbuf_get_data(vbo);
- MLoop *loops = CustomData_get_layer(cd_ldata, CD_MLOOP);
-
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- int cd_mask_ofs = CustomData_get_offset(cd_vdata, CD_PAINT_MASK);
- int cd_face_set_ofs = CustomData_get_offset(cd_pdata, CD_SCULPT_FACE_SETS);
- BMIter f_iter;
- BMFace *efa;
- BM_ITER_MESH (efa, &f_iter, mr->bm, BM_FACES_OF_MESH) {
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
- do {
- float v_mask = 0.0f;
- if (cd_mask) {
- v_mask = BM_ELEM_CD_GET_FLOAT(l_iter->v, cd_mask_ofs);
- }
- vbo_data->mask = v_mask;
- uchar face_set_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
- if (cd_face_set) {
- const int face_set_id = BM_ELEM_CD_GET_INT(l_iter->f, cd_face_set_ofs);
- if (face_set_id != mr->me->face_sets_color_default) {
- BKE_paint_face_set_overlay_color_get(
- face_set_id, mr->me->face_sets_color_seed, face_set_color);
- }
- }
- copy_v3_v3_uchar(vbo_data->face_set_color, face_set_color);
- vbo_data++;
- } while ((l_iter = l_iter->next) != l_first);
- }
- }
- else {
- int mp_loop = 0;
- for (int mp_index = 0; mp_index < mr->poly_len; mp_index++) {
- const MPoly *p = &mr->mpoly[mp_index];
- for (int l = 0; l < p->totloop; l++) {
- float v_mask = 0.0f;
- if (cd_mask) {
- v_mask = cd_mask[loops[mp_loop].v];
- }
- vbo_data->mask = v_mask;
-
- uchar face_set_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
- if (cd_face_set) {
- const int face_set_id = cd_face_set[mp_index];
- /* Skip for the default color Face Set to render it white. */
- if (face_set_id != mr->me->face_sets_color_default) {
- BKE_paint_face_set_overlay_color_get(
- face_set_id, mr->me->face_sets_color_seed, face_set_color);
- }
- }
- copy_v3_v3_uchar(vbo_data->face_set_color, face_set_color);
- mp_loop++;
- vbo_data++;
- }
- }
- }
-}
-
-const MeshExtract extract_sculpt_data = {
- .init = extract_sculpt_data_init,
- .data_type = 0,
- .data_size = 0,
- /* TODO: enable threading. */
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.sculpt_data)};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract VCol
- * \{ */
-
-static void extract_vcol_init(const MeshRenderData *mr,
- struct MeshBatchCache *cache,
- void *buf,
- void *UNUSED(tls_data))
-{
- GPUVertBuf *vbo = buf;
- GPUVertFormat format = {0};
- GPU_vertformat_deinterleave(&format);
-
- CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
- CustomData *cd_vdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->vdata : &mr->me->vdata;
- uint32_t vcol_layers = cache->cd_used.vcol;
- uint32_t svcol_layers = cache->cd_used.sculpt_vcol;
-
- for (int i = 0; i < MAX_MCOL; i++) {
- if (vcol_layers & (1 << i)) {
- char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
- const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPCOL, i);
- GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
-
- BLI_snprintf(attr_name, sizeof(attr_name), "c%s", attr_safe_name);
- GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
-
- if (i == CustomData_get_render_layer(cd_ldata, CD_MLOOPCOL)) {
- GPU_vertformat_alias_add(&format, "c");
- }
- if (i == CustomData_get_active_layer(cd_ldata, CD_MLOOPCOL)) {
- GPU_vertformat_alias_add(&format, "ac");
- }
-
- /* Gather number of auto layers. */
- /* We only do `vcols` that are not overridden by `uvs` and sculpt vertex colors. */
- if (CustomData_get_named_layer_index(cd_ldata, CD_MLOOPUV, layer_name) == -1 &&
- CustomData_get_named_layer_index(cd_vdata, CD_PROP_COLOR, layer_name) == -1) {
- BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name);
- GPU_vertformat_alias_add(&format, attr_name);
- }
- }
- }
-
- /* Sculpt Vertex Colors */
- if (U.experimental.use_sculpt_vertex_colors) {
- for (int i = 0; i < 8; i++) {
- if (svcol_layers & (1 << i)) {
- char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
- const char *layer_name = CustomData_get_layer_name(cd_vdata, CD_PROP_COLOR, i);
- GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
-
- BLI_snprintf(attr_name, sizeof(attr_name), "c%s", attr_safe_name);
- GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
-
- if (i == CustomData_get_render_layer(cd_vdata, CD_PROP_COLOR)) {
- GPU_vertformat_alias_add(&format, "c");
- }
- if (i == CustomData_get_active_layer(cd_vdata, CD_PROP_COLOR)) {
- GPU_vertformat_alias_add(&format, "ac");
- }
- /* Gather number of auto layers. */
- /* We only do `vcols` that are not overridden by `uvs`. */
- if (CustomData_get_named_layer_index(cd_ldata, CD_MLOOPUV, layer_name) == -1) {
- BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name);
- GPU_vertformat_alias_add(&format, attr_name);
- }
- }
- }
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len);
-
- typedef struct gpuMeshVcol {
- ushort r, g, b, a;
- } gpuMeshVcol;
-
- gpuMeshVcol *vcol_data = (gpuMeshVcol *)GPU_vertbuf_get_data(vbo);
- MLoop *loops = CustomData_get_layer(cd_ldata, CD_MLOOP);
-
- for (int i = 0; i < MAX_MCOL; i++) {
- if (vcol_layers & (1 << i)) {
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- int cd_ofs = CustomData_get_n_offset(cd_ldata, CD_MLOOPCOL, i);
- BMIter f_iter;
- BMFace *efa;
- BM_ITER_MESH (efa, &f_iter, mr->bm, BM_FACES_OF_MESH) {
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
- do {
- const MLoopCol *mloopcol = BM_ELEM_CD_GET_VOID_P(l_iter, cd_ofs);
- vcol_data->r = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->r]);
- vcol_data->g = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->g]);
- vcol_data->b = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->b]);
- vcol_data->a = unit_float_to_ushort_clamp(mloopcol->a * (1.0f / 255.0f));
- vcol_data++;
- } while ((l_iter = l_iter->next) != l_first);
- }
- }
- else {
- const MLoopCol *mloopcol = (MLoopCol *)CustomData_get_layer_n(cd_ldata, CD_MLOOPCOL, i);
- for (int ml_index = 0; ml_index < mr->loop_len; ml_index++, mloopcol++, vcol_data++) {
- vcol_data->r = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->r]);
- vcol_data->g = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->g]);
- vcol_data->b = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->b]);
- vcol_data->a = unit_float_to_ushort_clamp(mloopcol->a * (1.0f / 255.0f));
- }
- }
- }
-
- if (svcol_layers & (1 << i) && U.experimental.use_sculpt_vertex_colors) {
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- int cd_ofs = CustomData_get_n_offset(cd_vdata, CD_PROP_COLOR, i);
- BMIter f_iter;
- BMFace *efa;
- BM_ITER_MESH (efa, &f_iter, mr->bm, BM_FACES_OF_MESH) {
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
- do {
- const MPropCol *prop_col = BM_ELEM_CD_GET_VOID_P(l_iter->v, cd_ofs);
- vcol_data->r = unit_float_to_ushort_clamp(prop_col->color[0]);
- vcol_data->g = unit_float_to_ushort_clamp(prop_col->color[1]);
- vcol_data->b = unit_float_to_ushort_clamp(prop_col->color[2]);
- vcol_data->a = unit_float_to_ushort_clamp(prop_col->color[3]);
- vcol_data++;
- } while ((l_iter = l_iter->next) != l_first);
- }
- }
- else {
- MPropCol *vcol = CustomData_get_layer_n(cd_vdata, CD_PROP_COLOR, i);
- for (int ml_index = 0; ml_index < mr->loop_len; ml_index++, vcol_data++) {
- vcol_data->r = unit_float_to_ushort_clamp(vcol[loops[ml_index].v].color[0]);
- vcol_data->g = unit_float_to_ushort_clamp(vcol[loops[ml_index].v].color[1]);
- vcol_data->b = unit_float_to_ushort_clamp(vcol[loops[ml_index].v].color[2]);
- vcol_data->a = unit_float_to_ushort_clamp(vcol[loops[ml_index].v].color[3]);
- }
- }
- }
- }
-}
-
-const MeshExtract extract_vcol = {
- .init = extract_vcol_init,
- .data_type = 0,
- .data_size = 0,
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.vcol),
-};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Orco
- * \{ */
-
-typedef struct MeshExtract_Orco_Data {
- float (*vbo_data)[4];
- float (*orco)[3];
-} MeshExtract_Orco_Data;
-
-static void extract_orco_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- /* FIXME(fclem): We use the last component as a way to differentiate from generic vertex
- * attributes. This is a substantial waste of video-ram and should be done another way.
- * Unfortunately, at the time of writing, I did not found any other "non disruptive"
- * alternative. */
- GPU_vertformat_attr_add(&format, "orco", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len);
-
- CustomData *cd_vdata = &mr->me->vdata;
-
- MeshExtract_Orco_Data *data = tls_data;
- data->vbo_data = (float(*)[4])GPU_vertbuf_get_data(vbo);
- data->orco = CustomData_get_layer(cd_vdata, CD_ORCO);
- /* Make sure `orco` layer was requested only if needed! */
- BLI_assert(data->orco);
-}
-
-static void extract_orco_iter_poly_bm(const MeshRenderData *UNUSED(mr),
- const BMFace *f,
- const int UNUSED(f_index),
- void *data)
-{
- MeshExtract_Orco_Data *orco_data = (MeshExtract_Orco_Data *)data;
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
- float *loop_orco = orco_data->vbo_data[l_index];
- copy_v3_v3(loop_orco, orco_data->orco[BM_elem_index_get(l_iter->v)]);
- loop_orco[3] = 0.0; /* Tag as not a generic attribute. */
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_orco_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int UNUSED(mp_index),
- void *data)
-{
- const MLoop *mloop = mr->mloop;
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
- MeshExtract_Orco_Data *orco_data = (MeshExtract_Orco_Data *)data;
- float *loop_orco = orco_data->vbo_data[ml_index];
- copy_v3_v3(loop_orco, orco_data->orco[ml->v]);
- loop_orco[3] = 0.0; /* Tag as not a generic attribute. */
- }
-}
-
-const MeshExtract extract_orco = {
- .init = extract_orco_init,
- .iter_poly_bm = extract_orco_iter_poly_bm,
- .iter_poly_mesh = extract_orco_iter_poly_mesh,
- .data_type = 0,
- .data_size = sizeof(MeshExtract_Orco_Data),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.orco),
-};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Edge Factor
- * Defines how much an edge is visible.
- * \{ */
-
-typedef struct MeshExtract_EdgeFac_Data {
- uchar *vbo_data;
- bool use_edge_render;
- /* Number of loop per edge. */
- uchar *edge_loop_count;
-} MeshExtract_EdgeFac_Data;
-
-static float loop_edge_factor_get(const float f_no[3],
- const float v_co[3],
- const float v_no[3],
- const float v_next_co[3])
-{
- float enor[3], evec[3];
- sub_v3_v3v3(evec, v_next_co, v_co);
- cross_v3_v3v3(enor, v_no, evec);
- normalize_v3(enor);
- float d = fabsf(dot_v3v3(enor, f_no));
- /* Re-scale to the slider range. */
- d *= (1.0f / 0.065f);
- CLAMP(d, 0.0f, 1.0f);
- return d;
-}
-
-static void extract_edge_fac_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "wd", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
-
- MeshExtract_EdgeFac_Data *data = tls_data;
-
- if (mr->extract_type == MR_EXTRACT_MESH) {
- data->edge_loop_count = MEM_callocN(sizeof(uint32_t) * mr->edge_len, __func__);
-
- /* HACK(fclem) Detecting the need for edge render.
- * We could have a flag in the mesh instead or check the modifier stack. */
- const MEdge *med = mr->medge;
- for (int e_index = 0; e_index < mr->edge_len; e_index++, med++) {
- if ((med->flag & ME_EDGERENDER) == 0) {
- data->use_edge_render = true;
- break;
- }
- }
- }
- else {
- /* HACK to bypass non-manifold check in mesh_edge_fac_finish(). */
- data->use_edge_render = true;
- }
-
- data->vbo_data = GPU_vertbuf_get_data(vbo);
-}
-
-static void extract_edge_fac_iter_poly_bm(const MeshRenderData *mr,
- const BMFace *f,
- const int UNUSED(f_index),
- void *_data)
-{
- MeshExtract_EdgeFac_Data *data = _data;
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
-
- if (BM_edge_is_manifold(l_iter->e)) {
- float ratio = loop_edge_factor_get(bm_face_no_get(mr, f),
- bm_vert_co_get(mr, l_iter->v),
- bm_vert_no_get(mr, l_iter->v),
- bm_vert_co_get(mr, l_iter->next->v));
- data->vbo_data[l_index] = ratio * 253 + 1;
- }
- else {
- data->vbo_data[l_index] = 255;
- }
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_edge_fac_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int mp_index,
- void *_data)
-{
- MeshExtract_EdgeFac_Data *data = (MeshExtract_EdgeFac_Data *)_data;
-
- const MLoop *mloop = mr->mloop;
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
-
- if (data->use_edge_render) {
- const MEdge *med = &mr->medge[ml->e];
- data->vbo_data[ml_index] = (med->flag & ME_EDGERENDER) ? 255 : 0;
- }
- else {
-
- /* Count loop per edge to detect non-manifold. */
- if (data->edge_loop_count[ml->e] < 3) {
- data->edge_loop_count[ml->e]++;
- }
- if (data->edge_loop_count[ml->e] == 2) {
- /* Manifold */
- const int ml_index_last = mp->totloop + mp->loopstart - 1;
- const int ml_index_other = (ml_index == ml_index_last) ? mp->loopstart : (ml_index + 1);
- const MLoop *ml_next = &mr->mloop[ml_index_other];
- const MVert *v1 = &mr->mvert[ml->v];
- const MVert *v2 = &mr->mvert[ml_next->v];
- float vnor_f[3];
- normal_short_to_float_v3(vnor_f, v1->no);
- float ratio = loop_edge_factor_get(mr->poly_normals[mp_index], v1->co, vnor_f, v2->co);
- data->vbo_data[ml_index] = ratio * 253 + 1;
- }
- else {
- /* Non-manifold */
- data->vbo_data[ml_index] = 255;
- }
- }
- }
-}
-
-static void extract_edge_fac_iter_ledge_bm(const MeshRenderData *mr,
- const BMEdge *UNUSED(eed),
- const int ledge_index,
- void *_data)
-{
- MeshExtract_EdgeFac_Data *data = _data;
- data->vbo_data[mr->loop_len + (ledge_index * 2) + 0] = 255;
- data->vbo_data[mr->loop_len + (ledge_index * 2) + 1] = 255;
-}
-
-static void extract_edge_fac_iter_ledge_mesh(const MeshRenderData *mr,
- const MEdge *UNUSED(med),
- const int ledge_index,
- void *_data)
-{
- MeshExtract_EdgeFac_Data *data = _data;
-
- data->vbo_data[mr->loop_len + ledge_index * 2 + 0] = 255;
- data->vbo_data[mr->loop_len + ledge_index * 2 + 1] = 255;
-}
-
-static void extract_edge_fac_finish(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *_data)
-{
- GPUVertBuf *vbo = buf;
- MeshExtract_EdgeFac_Data *data = _data;
-
- if (GPU_crappy_amd_driver()) {
- /* Some AMD drivers strangely crash with VBO's with a one byte format.
- * To workaround we reinitialize the VBO with another format and convert
- * all bytes to floats. */
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "wd", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
- }
- /* We keep the data reference in data->vbo_data. */
- data->vbo_data = GPU_vertbuf_steal_data(vbo);
- GPU_vertbuf_clear(vbo);
-
- int buf_len = mr->loop_len + mr->loop_loose_len;
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, buf_len);
-
- float *fdata = (float *)GPU_vertbuf_get_data(vbo);
- for (int ml_index = 0; ml_index < buf_len; ml_index++, fdata++) {
- *fdata = data->vbo_data[ml_index] / 255.0f;
- }
- /* Free old byte data. */
- MEM_freeN(data->vbo_data);
- }
- MEM_SAFE_FREE(data->edge_loop_count);
-}
-
-const MeshExtract extract_edge_fac = {
- .init = extract_edge_fac_init,
- .iter_poly_bm = extract_edge_fac_iter_poly_bm,
- .iter_poly_mesh = extract_edge_fac_iter_poly_mesh,
- .iter_ledge_bm = extract_edge_fac_iter_ledge_bm,
- .iter_ledge_mesh = extract_edge_fac_iter_ledge_mesh,
- .finish = extract_edge_fac_finish,
- .data_type = MR_DATA_POLY_NOR,
- .data_size = sizeof(MeshExtract_EdgeFac_Data),
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.edge_fac)};
-
-/** \} */
-/* ---------------------------------------------------------------------- */
-/** \name Extract Vertex Weight
- * \{ */
-
-typedef struct MeshExtract_Weight_Data {
- float *vbo_data;
- const DRW_MeshWeightState *wstate;
- const MDeformVert *dvert; /* For #Mesh. */
- int cd_ofs; /* For #BMesh. */
-} MeshExtract_Weight_Data;
-
-static float evaluate_vertex_weight(const MDeformVert *dvert, const DRW_MeshWeightState *wstate)
-{
- /* Error state. */
- if ((wstate->defgroup_active < 0) && (wstate->defgroup_len > 0)) {
- return -2.0f;
- }
- if (dvert == NULL) {
- return (wstate->alert_mode != OB_DRAW_GROUPUSER_NONE) ? -1.0f : 0.0f;
- }
-
- float input = 0.0f;
- if (wstate->flags & DRW_MESH_WEIGHT_STATE_MULTIPAINT) {
- /* Multi-Paint feature */
- bool is_normalized = (wstate->flags & (DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE |
- DRW_MESH_WEIGHT_STATE_LOCK_RELATIVE));
- input = BKE_defvert_multipaint_collective_weight(dvert,
- wstate->defgroup_len,
- wstate->defgroup_sel,
- wstate->defgroup_sel_count,
- is_normalized);
- /* make it black if the selected groups have no weight on a vertex */
- if (input == 0.0f) {
- return -1.0f;
- }
- }
- else {
- /* default, non tricky behavior */
- input = BKE_defvert_find_weight(dvert, wstate->defgroup_active);
-
- if (input == 0.0f) {
- switch (wstate->alert_mode) {
- case OB_DRAW_GROUPUSER_ACTIVE:
- return -1.0f;
- break;
- case OB_DRAW_GROUPUSER_ALL:
- if (BKE_defvert_is_weight_zero(dvert, wstate->defgroup_len)) {
- return -1.0f;
- }
- break;
- }
- }
- }
-
- /* Lock-Relative: display the fraction of current weight vs total unlocked weight. */
- if (wstate->flags & DRW_MESH_WEIGHT_STATE_LOCK_RELATIVE) {
- input = BKE_defvert_lock_relative_weight(
- input, dvert, wstate->defgroup_len, wstate->defgroup_locked, wstate->defgroup_unlocked);
- }
-
- CLAMP(input, 0.0f, 1.0f);
- return input;
-}
-
-static void extract_weights_init(const MeshRenderData *mr,
- struct MeshBatchCache *cache,
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "weight", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
- }
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
-
- MeshExtract_Weight_Data *data = tls_data;
- data->vbo_data = (float *)GPU_vertbuf_get_data(vbo);
- data->wstate = &cache->weight_state;
-
- if (data->wstate->defgroup_active == -1) {
- /* Nothing to show. */
- data->dvert = NULL;
- data->cd_ofs = -1;
- }
- else if (mr->extract_type == MR_EXTRACT_BMESH) {
- data->dvert = NULL;
- data->cd_ofs = CustomData_get_offset(&mr->bm->vdata, CD_MDEFORMVERT);
- }
- else {
- data->dvert = CustomData_get_layer(&mr->me->vdata, CD_MDEFORMVERT);
- data->cd_ofs = -1;
- }
-}
-
-static void extract_weights_iter_poly_bm(const MeshRenderData *UNUSED(mr),
- const BMFace *f,
- const int UNUSED(f_index),
- void *_data)
-{
- MeshExtract_Weight_Data *data = _data;
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
- if (data->cd_ofs != -1) {
- const MDeformVert *dvert = BM_ELEM_CD_GET_VOID_P(l_iter->v, data->cd_ofs);
- data->vbo_data[l_index] = evaluate_vertex_weight(dvert, data->wstate);
- }
- else {
- data->vbo_data[l_index] = evaluate_vertex_weight(NULL, data->wstate);
- }
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_weights_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int UNUSED(mp_index),
- void *_data)
-{
- MeshExtract_Weight_Data *data = _data;
- const MLoop *mloop = mr->mloop;
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
- if (data->dvert != NULL) {
- const MDeformVert *dvert = &data->dvert[ml->v];
- data->vbo_data[ml_index] = evaluate_vertex_weight(dvert, data->wstate);
- }
- else {
- const MDeformVert *dvert = NULL;
- data->vbo_data[ml_index] = evaluate_vertex_weight(dvert, data->wstate);
- }
- }
-}
-
-const MeshExtract extract_weights = {
- .init = extract_weights_init,
- .iter_poly_bm = extract_weights_iter_poly_bm,
- .iter_poly_mesh = extract_weights_iter_poly_mesh,
- .data_type = 0,
- .data_size = sizeof(MeshExtract_Weight_Data),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.weights),
-};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Edit Mode Data / Flags
- * \{ */
-
-typedef struct EditLoopData {
- uchar v_flag;
- uchar e_flag;
- uchar crease;
- uchar bweight;
-} EditLoopData;
-
-static void mesh_render_data_face_flag(const MeshRenderData *mr,
- const BMFace *efa,
- const int cd_ofs,
- EditLoopData *eattr)
+void mesh_render_data_face_flag(const MeshRenderData *mr,
+ const BMFace *efa,
+ const int cd_ofs,
+ EditLoopData *eattr)
{
if (efa == mr->efa_act) {
eattr->v_flag |= VFLAG_FACE_ACTIVE;
@@ -1708,7 +125,8 @@ static void mesh_render_data_face_flag(const MeshRenderData *mr,
#ifdef WITH_FREESTYLE
if (mr->freestyle_face_ofs != -1) {
- const FreestyleFace *ffa = BM_ELEM_CD_GET_VOID_P(efa, mr->freestyle_face_ofs);
+ const FreestyleFace *ffa = (const FreestyleFace *)BM_ELEM_CD_GET_VOID_P(
+ efa, mr->freestyle_face_ofs);
if (ffa->flag & FREESTYLE_FACE_MARK) {
eattr->v_flag |= VFLAG_FACE_FREESTYLE;
}
@@ -1716,78 +134,15 @@ static void mesh_render_data_face_flag(const MeshRenderData *mr,
#endif
}
-static void mesh_render_data_edge_flag(const MeshRenderData *mr,
- const BMEdge *eed,
- EditLoopData *eattr)
-{
- const ToolSettings *ts = mr->toolsettings;
- const bool is_vertex_select_mode = (ts != NULL) && (ts->selectmode & SCE_SELECT_VERTEX) != 0;
- const bool is_face_only_select_mode = (ts != NULL) && (ts->selectmode == SCE_SELECT_FACE);
-
- if (eed == mr->eed_act) {
- eattr->e_flag |= VFLAG_EDGE_ACTIVE;
- }
- if (!is_vertex_select_mode && BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
- eattr->e_flag |= VFLAG_EDGE_SELECTED;
- }
- if (is_vertex_select_mode && BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) &&
- BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) {
- eattr->e_flag |= VFLAG_EDGE_SELECTED;
- eattr->e_flag |= VFLAG_VERT_SELECTED;
- }
- if (BM_elem_flag_test(eed, BM_ELEM_SEAM)) {
- eattr->e_flag |= VFLAG_EDGE_SEAM;
- }
- if (!BM_elem_flag_test(eed, BM_ELEM_SMOOTH)) {
- eattr->e_flag |= VFLAG_EDGE_SHARP;
- }
-
- /* Use active edge color for active face edges because
- * specular highlights make it hard to see T55456#510873.
- *
- * This isn't ideal since it can't be used when mixing edge/face modes
- * but it's still better than not being able to see the active face. */
- if (is_face_only_select_mode) {
- if (mr->efa_act != NULL) {
- if (BM_edge_in_face(eed, mr->efa_act)) {
- eattr->e_flag |= VFLAG_EDGE_ACTIVE;
- }
- }
- }
-
- /* Use a byte for value range */
- if (mr->crease_ofs != -1) {
- float crease = BM_ELEM_CD_GET_FLOAT(eed, mr->crease_ofs);
- if (crease > 0) {
- eattr->crease = (uchar)(crease * 255.0f);
- }
- }
- /* Use a byte for value range */
- if (mr->bweight_ofs != -1) {
- float bweight = BM_ELEM_CD_GET_FLOAT(eed, mr->bweight_ofs);
- if (bweight > 0) {
- eattr->bweight = (uchar)(bweight * 255.0f);
- }
- }
-#ifdef WITH_FREESTYLE
- if (mr->freestyle_edge_ofs != -1) {
- const FreestyleEdge *fed = BM_ELEM_CD_GET_VOID_P(eed, mr->freestyle_edge_ofs);
- if (fed->flag & FREESTYLE_EDGE_MARK) {
- eattr->e_flag |= VFLAG_EDGE_FREESTYLE;
- }
- }
-#endif
-}
-
-static void mesh_render_data_loop_flag(const MeshRenderData *mr,
- BMLoop *l,
- const int cd_ofs,
- EditLoopData *eattr)
+void mesh_render_data_loop_flag(const MeshRenderData *mr,
+ BMLoop *l,
+ const int cd_ofs,
+ EditLoopData *eattr)
{
if (cd_ofs == -1) {
return;
}
- MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_ofs);
+ MLoopUV *luv = (MLoopUV *)BM_ELEM_CD_GET_VOID_P(l, cd_ofs);
if (luv != NULL && (luv->flag & MLOOPUV_PINNED)) {
eattr->v_flag |= VFLAG_VERT_UV_PINNED;
}
@@ -1796,10 +151,10 @@ static void mesh_render_data_loop_flag(const MeshRenderData *mr,
}
}
-static void mesh_render_data_loop_edge_flag(const MeshRenderData *mr,
- BMLoop *l,
- const int cd_ofs,
- EditLoopData *eattr)
+void mesh_render_data_loop_edge_flag(const MeshRenderData *mr,
+ BMLoop *l,
+ const int cd_ofs,
+ EditLoopData *eattr)
{
if (cd_ofs == -1) {
return;
@@ -1810,1879 +165,4 @@ static void mesh_render_data_loop_edge_flag(const MeshRenderData *mr,
}
}
-static void mesh_render_data_vert_flag(const MeshRenderData *mr,
- const BMVert *eve,
- EditLoopData *eattr)
-{
- if (eve == mr->eve_act) {
- eattr->e_flag |= VFLAG_VERT_ACTIVE;
- }
- if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- eattr->e_flag |= VFLAG_VERT_SELECTED;
- }
-}
-
-static void extract_edit_data_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- /* WARNING: Adjust #EditLoopData struct accordingly. */
- GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 4, GPU_FETCH_INT);
- GPU_vertformat_alias_add(&format, "flag");
- }
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
- EditLoopData *vbo_data = GPU_vertbuf_get_data(vbo);
- *(EditLoopData **)tls_data = vbo_data;
-}
-
-static void extract_edit_data_iter_poly_bm(const MeshRenderData *mr,
- const BMFace *f,
- const int UNUSED(f_index),
- void *_data)
-{
- EditLoopData *vbo_data = *(EditLoopData **)_data;
-
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
-
- EditLoopData *data = vbo_data + l_index;
- memset(data, 0x0, sizeof(*data));
- mesh_render_data_face_flag(mr, f, -1, data);
- mesh_render_data_edge_flag(mr, l_iter->e, data);
- mesh_render_data_vert_flag(mr, l_iter->v, data);
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_edit_data_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int mp_index,
- void *_data)
-{
- EditLoopData *vbo_data = *(EditLoopData **)_data;
-
- const MLoop *mloop = mr->mloop;
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
- EditLoopData *data = vbo_data + ml_index;
- memset(data, 0x0, sizeof(*data));
- BMFace *efa = bm_original_face_get(mr, mp_index);
- BMEdge *eed = bm_original_edge_get(mr, ml->e);
- BMVert *eve = bm_original_vert_get(mr, ml->v);
- if (efa) {
- mesh_render_data_face_flag(mr, efa, -1, data);
- }
- if (eed) {
- mesh_render_data_edge_flag(mr, eed, data);
- }
- if (eve) {
- mesh_render_data_vert_flag(mr, eve, data);
- }
- }
-}
-
-static void extract_edit_data_iter_ledge_bm(const MeshRenderData *mr,
- const BMEdge *eed,
- const int ledge_index,
- void *_data)
-{
- EditLoopData *vbo_data = *(EditLoopData **)_data;
- EditLoopData *data = vbo_data + mr->loop_len + (ledge_index * 2);
- memset(data, 0x0, sizeof(*data) * 2);
- mesh_render_data_edge_flag(mr, eed, &data[0]);
- data[1] = data[0];
- mesh_render_data_vert_flag(mr, eed->v1, &data[0]);
- mesh_render_data_vert_flag(mr, eed->v2, &data[1]);
-}
-
-static void extract_edit_data_iter_ledge_mesh(const MeshRenderData *mr,
- const MEdge *med,
- const int ledge_index,
- void *_data)
-{
- EditLoopData *vbo_data = *(EditLoopData **)_data;
- EditLoopData *data = vbo_data + mr->loop_len + ledge_index * 2;
- memset(data, 0x0, sizeof(*data) * 2);
- const int e_index = mr->ledges[ledge_index];
- BMEdge *eed = bm_original_edge_get(mr, e_index);
- BMVert *eve1 = bm_original_vert_get(mr, med->v1);
- BMVert *eve2 = bm_original_vert_get(mr, med->v2);
- if (eed) {
- mesh_render_data_edge_flag(mr, eed, &data[0]);
- data[1] = data[0];
- }
- if (eve1) {
- mesh_render_data_vert_flag(mr, eve1, &data[0]);
- }
- if (eve2) {
- mesh_render_data_vert_flag(mr, eve2, &data[1]);
- }
-}
-
-static void extract_edit_data_iter_lvert_bm(const MeshRenderData *mr,
- const BMVert *eve,
- const int lvert_index,
- void *_data)
-{
- EditLoopData *vbo_data = *(EditLoopData **)_data;
- const int offset = mr->loop_len + (mr->edge_loose_len * 2);
- EditLoopData *data = vbo_data + offset + lvert_index;
- memset(data, 0x0, sizeof(*data));
- mesh_render_data_vert_flag(mr, eve, data);
-}
-
-static void extract_edit_data_iter_lvert_mesh(const MeshRenderData *mr,
- const MVert *UNUSED(mv),
- const int lvert_index,
- void *_data)
-{
- EditLoopData *vbo_data = *(EditLoopData **)_data;
- const int offset = mr->loop_len + (mr->edge_loose_len * 2);
-
- EditLoopData *data = vbo_data + offset + lvert_index;
- memset(data, 0x0, sizeof(*data));
- const int v_index = mr->lverts[lvert_index];
- BMVert *eve = bm_original_vert_get(mr, v_index);
- if (eve) {
- mesh_render_data_vert_flag(mr, eve, data);
- }
-}
-
-const MeshExtract extract_edit_data = {
- .init = extract_edit_data_init,
- .iter_poly_bm = extract_edit_data_iter_poly_bm,
- .iter_poly_mesh = extract_edit_data_iter_poly_mesh,
- .iter_ledge_bm = extract_edit_data_iter_ledge_bm,
- .iter_ledge_mesh = extract_edit_data_iter_ledge_mesh,
- .iter_lvert_bm = extract_edit_data_iter_lvert_bm,
- .iter_lvert_mesh = extract_edit_data_iter_lvert_mesh,
- .data_type = 0,
- .data_size = sizeof(EditLoopData *),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.edit_data)};
-
/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Edit UV Data / Flags
- * \{ */
-
-typedef struct MeshExtract_EditUVData_Data {
- EditLoopData *vbo_data;
- int cd_ofs;
-} MeshExtract_EditUVData_Data;
-
-static void extract_edituv_data_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- /* WARNING: Adjust #EditLoopData struct accordingly. */
- GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 4, GPU_FETCH_INT);
- GPU_vertformat_alias_add(&format, "flag");
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len);
-
- CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
-
- MeshExtract_EditUVData_Data *data = tls_data;
- data->vbo_data = (EditLoopData *)GPU_vertbuf_get_data(vbo);
- data->cd_ofs = CustomData_get_offset(cd_ldata, CD_MLOOPUV);
-}
-
-static void extract_edituv_data_iter_poly_bm(const MeshRenderData *mr,
- const BMFace *f,
- const int UNUSED(f_index),
- void *_data)
-{
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
- MeshExtract_EditUVData_Data *data = _data;
- EditLoopData *eldata = &data->vbo_data[l_index];
- memset(eldata, 0x0, sizeof(*eldata));
- mesh_render_data_loop_flag(mr, l_iter, data->cd_ofs, eldata);
- mesh_render_data_face_flag(mr, f, data->cd_ofs, eldata);
- mesh_render_data_loop_edge_flag(mr, l_iter, data->cd_ofs, eldata);
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_edituv_data_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int mp_index,
- void *_data)
-{
- MeshExtract_EditUVData_Data *data = _data;
- const MLoop *mloop = mr->mloop;
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
-
- EditLoopData *eldata = &data->vbo_data[ml_index];
- memset(eldata, 0x0, sizeof(*eldata));
- BMFace *efa = bm_original_face_get(mr, mp_index);
- if (efa) {
- BMEdge *eed = bm_original_edge_get(mr, ml->e);
- BMVert *eve = bm_original_vert_get(mr, ml->v);
- if (eed && eve) {
- /* Loop on an edge endpoint. */
- BMLoop *l = BM_face_edge_share_loop(efa, eed);
- mesh_render_data_loop_flag(mr, l, data->cd_ofs, eldata);
- mesh_render_data_loop_edge_flag(mr, l, data->cd_ofs, eldata);
- }
- else {
- if (eed == NULL) {
- /* Find if the loop's vert is not part of an edit edge.
- * For this, we check if the previous loop was on an edge. */
- const int ml_index_last = mp->loopstart + mp->totloop - 1;
- const int l_prev = (ml_index == mp->loopstart) ? ml_index_last : (ml_index - 1);
- const MLoop *ml_prev = &mr->mloop[l_prev];
- eed = bm_original_edge_get(mr, ml_prev->e);
- }
- if (eed) {
- /* Mapped points on an edge between two edit verts. */
- BMLoop *l = BM_face_edge_share_loop(efa, eed);
- mesh_render_data_loop_edge_flag(mr, l, data->cd_ofs, eldata);
- }
- }
- }
- }
-}
-
-const MeshExtract extract_edituv_data = {
- .init = extract_edituv_data_init,
- .iter_poly_bm = extract_edituv_data_iter_poly_bm,
- .iter_poly_mesh = extract_edituv_data_iter_poly_mesh,
- .data_type = 0,
- .data_size = sizeof(MeshExtract_EditUVData_Data),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.edituv_data)};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Edit UV area stretch
- * \{ */
-
-static void extract_edituv_stretch_area_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *UNUSED(tls_data))
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "ratio", GPU_COMP_I16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len);
-}
-
-BLI_INLINE float area_ratio_get(float area, float uvarea)
-{
- if (area >= FLT_EPSILON && uvarea >= FLT_EPSILON) {
- /* Tag inversion by using the sign. */
- return (area > uvarea) ? (uvarea / area) : -(area / uvarea);
- }
- return 0.0f;
-}
-
-BLI_INLINE float area_ratio_to_stretch(float ratio, float tot_ratio, float inv_tot_ratio)
-{
- ratio *= (ratio > 0.0f) ? tot_ratio : -inv_tot_ratio;
- return (ratio > 1.0f) ? (1.0f / ratio) : ratio;
-}
-
-static void extract_edituv_stretch_area_finish(const MeshRenderData *mr,
- struct MeshBatchCache *cache,
- void *buf,
- void *UNUSED(data))
-{
- GPUVertBuf *vbo = buf;
- float tot_area = 0.0f, tot_uv_area = 0.0f;
- float *area_ratio = MEM_mallocN(sizeof(float) * mr->poly_len, __func__);
-
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- CustomData *cd_ldata = &mr->bm->ldata;
- int uv_ofs = CustomData_get_offset(cd_ldata, CD_MLOOPUV);
-
- BMFace *efa;
- BMIter f_iter;
- int f;
- BM_ITER_MESH_INDEX (efa, &f_iter, mr->bm, BM_FACES_OF_MESH, f) {
- float area = BM_face_calc_area(efa);
- float uvarea = BM_face_calc_area_uv(efa, uv_ofs);
- tot_area += area;
- tot_uv_area += uvarea;
- area_ratio[f] = area_ratio_get(area, uvarea);
- }
- }
- else {
- BLI_assert(ELEM(mr->extract_type, MR_EXTRACT_MAPPED, MR_EXTRACT_MESH));
- const MLoopUV *uv_data = CustomData_get_layer(&mr->me->ldata, CD_MLOOPUV);
- const MPoly *mp = mr->mpoly;
- for (int mp_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
- float area = BKE_mesh_calc_poly_area(mp, &mr->mloop[mp->loopstart], mr->mvert);
- float uvarea = BKE_mesh_calc_poly_uv_area(mp, uv_data);
- tot_area += area;
- tot_uv_area += uvarea;
- area_ratio[mp_index] = area_ratio_get(area, uvarea);
- }
- }
-
- cache->tot_area = tot_area;
- cache->tot_uv_area = tot_uv_area;
-
- /* Convert in place to avoid an extra allocation */
- uint16_t *poly_stretch = (uint16_t *)area_ratio;
- for (int mp_index = 0; mp_index < mr->poly_len; mp_index++) {
- poly_stretch[mp_index] = area_ratio[mp_index] * SHRT_MAX;
- }
-
- /* Copy face data for each loop. */
- uint16_t *loop_stretch = (uint16_t *)GPU_vertbuf_get_data(vbo);
-
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- BMFace *efa;
- BMIter f_iter;
- int f, l_index = 0;
- BM_ITER_MESH_INDEX (efa, &f_iter, mr->bm, BM_FACES_OF_MESH, f) {
- for (int i = 0; i < efa->len; i++, l_index++) {
- loop_stretch[l_index] = poly_stretch[f];
- }
- }
- }
- else {
- BLI_assert(ELEM(mr->extract_type, MR_EXTRACT_MAPPED, MR_EXTRACT_MESH));
- const MPoly *mp = mr->mpoly;
- for (int mp_index = 0, l_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
- for (int i = 0; i < mp->totloop; i++, l_index++) {
- loop_stretch[l_index] = poly_stretch[mp_index];
- }
- }
- }
-
- MEM_freeN(area_ratio);
-}
-
-const MeshExtract extract_edituv_stretch_area = {
- .init = extract_edituv_stretch_area_init,
- .finish = extract_edituv_stretch_area_finish,
- .data_type = 0,
- .data_size = 0,
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.edituv_stretch_area)};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Edit UV angle stretch
- * \{ */
-
-typedef struct UVStretchAngle {
- int16_t angle;
- int16_t uv_angles[2];
-} UVStretchAngle;
-
-typedef struct MeshExtract_StretchAngle_Data {
- UVStretchAngle *vbo_data;
- MLoopUV *luv;
- float auv[2][2], last_auv[2];
- float av[2][3], last_av[3];
- int cd_ofs;
-} MeshExtract_StretchAngle_Data;
-
-static void compute_normalize_edge_vectors(float auv[2][2],
- float av[2][3],
- const float uv[2],
- const float uv_prev[2],
- const float co[3],
- const float co_prev[3])
-{
- /* Move previous edge. */
- copy_v2_v2(auv[0], auv[1]);
- copy_v3_v3(av[0], av[1]);
- /* 2d edge */
- sub_v2_v2v2(auv[1], uv_prev, uv);
- normalize_v2(auv[1]);
- /* 3d edge */
- sub_v3_v3v3(av[1], co_prev, co);
- normalize_v3(av[1]);
-}
-
-static short v2_to_short_angle(const float v[2])
-{
- return atan2f(v[1], v[0]) * (float)M_1_PI * SHRT_MAX;
-}
-
-static void edituv_get_edituv_stretch_angle(float auv[2][2],
- const float av[2][3],
- UVStretchAngle *r_stretch)
-{
- /* Send UV's to the shader and let it compute the aspect corrected angle. */
- r_stretch->uv_angles[0] = v2_to_short_angle(auv[0]);
- r_stretch->uv_angles[1] = v2_to_short_angle(auv[1]);
- /* Compute 3D angle here. */
- r_stretch->angle = angle_normalized_v3v3(av[0], av[1]) * (float)M_1_PI * SHRT_MAX;
-
-#if 0 /* here for reference, this is done in shader now. */
- float uvang = angle_normalized_v2v2(auv0, auv1);
- float ang = angle_normalized_v3v3(av0, av1);
- float stretch = fabsf(uvang - ang) / (float)M_PI;
- return 1.0f - pow2f(1.0f - stretch);
-#endif
-}
-
-static void extract_edituv_stretch_angle_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- /* Waning: adjust #UVStretchAngle struct accordingly. */
- GPU_vertformat_attr_add(&format, "angle", GPU_COMP_I16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
- GPU_vertformat_attr_add(&format, "uv_angles", GPU_COMP_I16, 2, GPU_FETCH_INT_TO_FLOAT_UNIT);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len);
-
- MeshExtract_StretchAngle_Data *data = tls_data;
- data->vbo_data = (UVStretchAngle *)GPU_vertbuf_get_data(vbo);
-
- /* Special iterator needed to save about half of the computing cost. */
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- data->cd_ofs = CustomData_get_offset(&mr->bm->ldata, CD_MLOOPUV);
- }
- else {
- BLI_assert(ELEM(mr->extract_type, MR_EXTRACT_MAPPED, MR_EXTRACT_MESH));
- data->luv = CustomData_get_layer(&mr->me->ldata, CD_MLOOPUV);
- }
-}
-
-static void extract_edituv_stretch_angle_iter_poly_bm(const MeshRenderData *mr,
- const BMFace *f,
- const int UNUSED(f_index),
- void *_data)
-{
- MeshExtract_StretchAngle_Data *data = _data;
- float(*auv)[2] = data->auv, *last_auv = data->last_auv;
- float(*av)[3] = data->av, *last_av = data->last_av;
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
-
- const MLoopUV *luv, *luv_next;
- BMLoop *l_next = l_iter->next;
- if (l_iter == BM_FACE_FIRST_LOOP(f)) {
- /* First loop in face. */
- BMLoop *l_tmp = l_iter->prev;
- BMLoop *l_next_tmp = l_iter;
- luv = BM_ELEM_CD_GET_VOID_P(l_tmp, data->cd_ofs);
- luv_next = BM_ELEM_CD_GET_VOID_P(l_next_tmp, data->cd_ofs);
- compute_normalize_edge_vectors(auv,
- av,
- luv->uv,
- luv_next->uv,
- bm_vert_co_get(mr, l_tmp->v),
- bm_vert_co_get(mr, l_next_tmp->v));
- /* Save last edge. */
- copy_v2_v2(last_auv, auv[1]);
- copy_v3_v3(last_av, av[1]);
- }
- if (l_next == BM_FACE_FIRST_LOOP(f)) {
- /* Move previous edge. */
- copy_v2_v2(auv[0], auv[1]);
- copy_v3_v3(av[0], av[1]);
- /* Copy already calculated last edge. */
- copy_v2_v2(auv[1], last_auv);
- copy_v3_v3(av[1], last_av);
- }
- else {
- luv = BM_ELEM_CD_GET_VOID_P(l_iter, data->cd_ofs);
- luv_next = BM_ELEM_CD_GET_VOID_P(l_next, data->cd_ofs);
- compute_normalize_edge_vectors(auv,
- av,
- luv->uv,
- luv_next->uv,
- bm_vert_co_get(mr, l_iter->v),
- bm_vert_co_get(mr, l_next->v));
- }
- edituv_get_edituv_stretch_angle(auv, av, &data->vbo_data[l_index]);
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_edituv_stretch_angle_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int UNUSED(mp_index),
- void *_data)
-{
- MeshExtract_StretchAngle_Data *data = _data;
-
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- float(*auv)[2] = data->auv, *last_auv = data->last_auv;
- float(*av)[3] = data->av, *last_av = data->last_av;
- int l_next = ml_index + 1;
- const MVert *v, *v_next;
- if (ml_index == mp->loopstart) {
- /* First loop in face. */
- const int ml_index_last = ml_index_end - 1;
- const int l_next_tmp = mp->loopstart;
- v = &mr->mvert[mr->mloop[ml_index_last].v];
- v_next = &mr->mvert[mr->mloop[l_next_tmp].v];
- compute_normalize_edge_vectors(
- auv, av, data->luv[ml_index_last].uv, data->luv[l_next_tmp].uv, v->co, v_next->co);
- /* Save last edge. */
- copy_v2_v2(last_auv, auv[1]);
- copy_v3_v3(last_av, av[1]);
- }
- if (l_next == ml_index_end) {
- l_next = mp->loopstart;
- /* Move previous edge. */
- copy_v2_v2(auv[0], auv[1]);
- copy_v3_v3(av[0], av[1]);
- /* Copy already calculated last edge. */
- copy_v2_v2(auv[1], last_auv);
- copy_v3_v3(av[1], last_av);
- }
- else {
- v = &mr->mvert[mr->mloop[ml_index].v];
- v_next = &mr->mvert[mr->mloop[l_next].v];
- compute_normalize_edge_vectors(
- auv, av, data->luv[ml_index].uv, data->luv[l_next].uv, v->co, v_next->co);
- }
- edituv_get_edituv_stretch_angle(auv, av, &data->vbo_data[ml_index]);
- }
-}
-
-const MeshExtract extract_edituv_stretch_angle = {
- .init = extract_edituv_stretch_angle_init,
- .iter_poly_bm = extract_edituv_stretch_angle_iter_poly_bm,
- .iter_poly_mesh = extract_edituv_stretch_angle_iter_poly_mesh,
- .data_type = 0,
- .data_size = sizeof(MeshExtract_StretchAngle_Data),
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.edituv_stretch_angle)};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Edit Mesh Analysis Colors
- * \{ */
-
-static void extract_mesh_analysis_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *UNUSED(tls_data))
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "weight", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len);
-}
-
-static void axis_from_enum_v3(float v[3], const char axis)
-{
- zero_v3(v);
- if (axis < 3) {
- v[axis] = 1.0f;
- }
- else {
- v[axis - 3] = -1.0f;
- }
-}
-
-BLI_INLINE float overhang_remap(float fac, float min, float max, float minmax_irange)
-{
- if (fac < min) {
- fac = 1.0f;
- }
- else if (fac > max) {
- fac = -1.0f;
- }
- else {
- fac = (fac - min) * minmax_irange;
- fac = 1.0f - fac;
- CLAMP(fac, 0.0f, 1.0f);
- }
- return fac;
-}
-
-static void statvis_calc_overhang(const MeshRenderData *mr, float *r_overhang)
-{
- const MeshStatVis *statvis = &mr->toolsettings->statvis;
- const float min = statvis->overhang_min / (float)M_PI;
- const float max = statvis->overhang_max / (float)M_PI;
- const char axis = statvis->overhang_axis;
- BMEditMesh *em = mr->edit_bmesh;
- BMIter iter;
- BMesh *bm = em->bm;
- BMFace *f;
- float dir[3];
- const float minmax_irange = 1.0f / (max - min);
-
- BLI_assert(min <= max);
-
- axis_from_enum_v3(dir, axis);
-
- /* now convert into global space */
- mul_transposed_mat3_m4_v3(mr->obmat, dir);
- normalize_v3(dir);
-
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- int l_index = 0;
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- float fac = angle_normalized_v3v3(bm_face_no_get(mr, f), dir) / (float)M_PI;
- fac = overhang_remap(fac, min, max, minmax_irange);
- for (int i = 0; i < f->len; i++, l_index++) {
- r_overhang[l_index] = fac;
- }
- }
- }
- else {
- const MPoly *mp = mr->mpoly;
- for (int mp_index = 0, l_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
- float fac = angle_normalized_v3v3(mr->poly_normals[mp_index], dir) / (float)M_PI;
- fac = overhang_remap(fac, min, max, minmax_irange);
- for (int i = 0; i < mp->totloop; i++, l_index++) {
- r_overhang[l_index] = fac;
- }
- }
- }
-}
-
-/**
- * Needed so we can use jitter values for face interpolation.
- */
-static void uv_from_jitter_v2(float uv[2])
-{
- uv[0] += 0.5f;
- uv[1] += 0.5f;
- if (uv[0] + uv[1] > 1.0f) {
- uv[0] = 1.0f - uv[0];
- uv[1] = 1.0f - uv[1];
- }
-
- clamp_v2(uv, 0.0f, 1.0f);
-}
-
-BLI_INLINE float thickness_remap(float fac, float min, float max, float minmax_irange)
-{
- /* important not '<=' */
- if (fac < max) {
- fac = (fac - min) * minmax_irange;
- fac = 1.0f - fac;
- CLAMP(fac, 0.0f, 1.0f);
- }
- else {
- fac = -1.0f;
- }
- return fac;
-}
-
-static void statvis_calc_thickness(const MeshRenderData *mr, float *r_thickness)
-{
- const float eps_offset = 0.00002f; /* values <= 0.00001 give errors */
- /* cheating to avoid another allocation */
- float *face_dists = r_thickness + (mr->loop_len - mr->poly_len);
- BMEditMesh *em = mr->edit_bmesh;
- const float scale = 1.0f / mat4_to_scale(mr->obmat);
- const MeshStatVis *statvis = &mr->toolsettings->statvis;
- const float min = statvis->thickness_min * scale;
- const float max = statvis->thickness_max * scale;
- const float minmax_irange = 1.0f / (max - min);
- const int samples = statvis->thickness_samples;
- float jit_ofs[32][2];
- BLI_assert(samples <= 32);
- BLI_assert(min <= max);
-
- copy_vn_fl(face_dists, mr->poly_len, max);
-
- BLI_jitter_init(jit_ofs, samples);
- for (int j = 0; j < samples; j++) {
- uv_from_jitter_v2(jit_ofs[j]);
- }
-
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- BMesh *bm = em->bm;
- BM_mesh_elem_index_ensure(bm, BM_FACE);
-
- struct BMBVHTree *bmtree = BKE_bmbvh_new_from_editmesh(em, 0, NULL, false);
- struct BMLoop *(*looptris)[3] = em->looptris;
- for (int i = 0; i < mr->tri_len; i++) {
- BMLoop **ltri = looptris[i];
- const int index = BM_elem_index_get(ltri[0]->f);
- const float *cos[3] = {
- bm_vert_co_get(mr, ltri[0]->v),
- bm_vert_co_get(mr, ltri[1]->v),
- bm_vert_co_get(mr, ltri[2]->v),
- };
- float ray_co[3];
- float ray_no[3];
-
- normal_tri_v3(ray_no, cos[2], cos[1], cos[0]);
-
- for (int j = 0; j < samples; j++) {
- float dist = face_dists[index];
- interp_v3_v3v3v3_uv(ray_co, cos[0], cos[1], cos[2], jit_ofs[j]);
- madd_v3_v3fl(ray_co, ray_no, eps_offset);
-
- BMFace *f_hit = BKE_bmbvh_ray_cast(bmtree, ray_co, ray_no, 0.0f, &dist, NULL, NULL);
- if (f_hit && dist < face_dists[index]) {
- float angle_fac = fabsf(
- dot_v3v3(bm_face_no_get(mr, ltri[0]->f), bm_face_no_get(mr, f_hit)));
- angle_fac = 1.0f - angle_fac;
- angle_fac = angle_fac * angle_fac * angle_fac;
- angle_fac = 1.0f - angle_fac;
- dist /= angle_fac;
- if (dist < face_dists[index]) {
- face_dists[index] = dist;
- }
- }
- }
- }
- BKE_bmbvh_free(bmtree);
-
- BMIter iter;
- BMFace *f;
- int l_index = 0;
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- float fac = face_dists[BM_elem_index_get(f)];
- fac = thickness_remap(fac, min, max, minmax_irange);
- for (int i = 0; i < f->len; i++, l_index++) {
- r_thickness[l_index] = fac;
- }
- }
- }
- else {
- BVHTreeFromMesh treeData = {NULL};
-
- BVHTree *tree = BKE_bvhtree_from_mesh_get(&treeData, mr->me, BVHTREE_FROM_LOOPTRI, 4);
- const MLoopTri *mlooptri = mr->mlooptri;
- for (int i = 0; i < mr->tri_len; i++, mlooptri++) {
- const int index = mlooptri->poly;
- const float *cos[3] = {mr->mvert[mr->mloop[mlooptri->tri[0]].v].co,
- mr->mvert[mr->mloop[mlooptri->tri[1]].v].co,
- mr->mvert[mr->mloop[mlooptri->tri[2]].v].co};
- float ray_co[3];
- float ray_no[3];
-
- normal_tri_v3(ray_no, cos[2], cos[1], cos[0]);
-
- for (int j = 0; j < samples; j++) {
- interp_v3_v3v3v3_uv(ray_co, cos[0], cos[1], cos[2], jit_ofs[j]);
- madd_v3_v3fl(ray_co, ray_no, eps_offset);
-
- BVHTreeRayHit hit;
- hit.index = -1;
- hit.dist = face_dists[index];
- if ((BLI_bvhtree_ray_cast(
- tree, ray_co, ray_no, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) &&
- hit.dist < face_dists[index]) {
- float angle_fac = fabsf(dot_v3v3(mr->poly_normals[index], hit.no));
- angle_fac = 1.0f - angle_fac;
- angle_fac = angle_fac * angle_fac * angle_fac;
- angle_fac = 1.0f - angle_fac;
- hit.dist /= angle_fac;
- if (hit.dist < face_dists[index]) {
- face_dists[index] = hit.dist;
- }
- }
- }
- }
-
- const MPoly *mp = mr->mpoly;
- for (int mp_index = 0, l_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
- float fac = face_dists[mp_index];
- fac = thickness_remap(fac, min, max, minmax_irange);
- for (int i = 0; i < mp->totloop; i++, l_index++) {
- r_thickness[l_index] = fac;
- }
- }
- }
-}
-
-struct BVHTree_OverlapData {
- const Mesh *me;
- const MLoopTri *mlooptri;
- float epsilon;
-};
-
-static bool bvh_overlap_cb(void *userdata, int index_a, int index_b, int UNUSED(thread))
-{
- struct BVHTree_OverlapData *data = userdata;
- const Mesh *me = data->me;
-
- const MLoopTri *tri_a = &data->mlooptri[index_a];
- const MLoopTri *tri_b = &data->mlooptri[index_b];
-
- if (UNLIKELY(tri_a->poly == tri_b->poly)) {
- return false;
- }
-
- const float *tri_a_co[3] = {me->mvert[me->mloop[tri_a->tri[0]].v].co,
- me->mvert[me->mloop[tri_a->tri[1]].v].co,
- me->mvert[me->mloop[tri_a->tri[2]].v].co};
- const float *tri_b_co[3] = {me->mvert[me->mloop[tri_b->tri[0]].v].co,
- me->mvert[me->mloop[tri_b->tri[1]].v].co,
- me->mvert[me->mloop[tri_b->tri[2]].v].co};
- float ix_pair[2][3];
- int verts_shared = 0;
-
- verts_shared = (ELEM(tri_a_co[0], UNPACK3(tri_b_co)) + ELEM(tri_a_co[1], UNPACK3(tri_b_co)) +
- ELEM(tri_a_co[2], UNPACK3(tri_b_co)));
-
- /* if 2 points are shared, bail out */
- if (verts_shared >= 2) {
- return false;
- }
-
- return (isect_tri_tri_v3(UNPACK3(tri_a_co), UNPACK3(tri_b_co), ix_pair[0], ix_pair[1]) &&
- /* if we share a vertex, check the intersection isn't a 'point' */
- ((verts_shared == 0) || (len_squared_v3v3(ix_pair[0], ix_pair[1]) > data->epsilon)));
-}
-
-static void statvis_calc_intersect(const MeshRenderData *mr, float *r_intersect)
-{
- BMEditMesh *em = mr->edit_bmesh;
-
- for (int l_index = 0; l_index < mr->loop_len; l_index++) {
- r_intersect[l_index] = -1.0f;
- }
-
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- uint overlap_len;
- BMesh *bm = em->bm;
-
- BM_mesh_elem_index_ensure(bm, BM_FACE);
-
- struct BMBVHTree *bmtree = BKE_bmbvh_new_from_editmesh(em, 0, NULL, false);
- BVHTreeOverlap *overlap = BKE_bmbvh_overlap_self(bmtree, &overlap_len);
-
- if (overlap) {
- for (int i = 0; i < overlap_len; i++) {
- BMFace *f_hit_pair[2] = {
- em->looptris[overlap[i].indexA][0]->f,
- em->looptris[overlap[i].indexB][0]->f,
- };
- for (int j = 0; j < 2; j++) {
- BMFace *f_hit = f_hit_pair[j];
- BMLoop *l_first = BM_FACE_FIRST_LOOP(f_hit);
- int l_index = BM_elem_index_get(l_first);
- for (int k = 0; k < f_hit->len; k++, l_index++) {
- r_intersect[l_index] = 1.0f;
- }
- }
- }
- MEM_freeN(overlap);
- }
-
- BKE_bmbvh_free(bmtree);
- }
- else {
- uint overlap_len;
- BVHTreeFromMesh treeData = {NULL};
-
- BVHTree *tree = BKE_bvhtree_from_mesh_get(&treeData, mr->me, BVHTREE_FROM_LOOPTRI, 4);
-
- struct BVHTree_OverlapData data = {
- .me = mr->me, .mlooptri = mr->mlooptri, .epsilon = BLI_bvhtree_get_epsilon(tree)};
-
- BVHTreeOverlap *overlap = BLI_bvhtree_overlap(tree, tree, &overlap_len, bvh_overlap_cb, &data);
- if (overlap) {
- for (int i = 0; i < overlap_len; i++) {
- const MPoly *f_hit_pair[2] = {
- &mr->mpoly[mr->mlooptri[overlap[i].indexA].poly],
- &mr->mpoly[mr->mlooptri[overlap[i].indexB].poly],
- };
- for (int j = 0; j < 2; j++) {
- const MPoly *f_hit = f_hit_pair[j];
- int l_index = f_hit->loopstart;
- for (int k = 0; k < f_hit->totloop; k++, l_index++) {
- r_intersect[l_index] = 1.0f;
- }
- }
- }
- MEM_freeN(overlap);
- }
- }
-}
-
-BLI_INLINE float distort_remap(float fac, float min, float UNUSED(max), float minmax_irange)
-{
- if (fac >= min) {
- fac = (fac - min) * minmax_irange;
- CLAMP(fac, 0.0f, 1.0f);
- }
- else {
- /* fallback */
- fac = -1.0f;
- }
- return fac;
-}
-
-static void statvis_calc_distort(const MeshRenderData *mr, float *r_distort)
-{
- BMEditMesh *em = mr->edit_bmesh;
- const MeshStatVis *statvis = &mr->toolsettings->statvis;
- const float min = statvis->distort_min;
- const float max = statvis->distort_max;
- const float minmax_irange = 1.0f / (max - min);
-
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- BMIter iter;
- BMesh *bm = em->bm;
- BMFace *f;
-
- if (mr->bm_vert_coords != NULL) {
- BKE_editmesh_cache_ensure_poly_normals(em, mr->edit_data);
-
- /* Most likely this is already valid, ensure just in case.
- * Needed for #BM_loop_calc_face_normal_safe_vcos. */
- BM_mesh_elem_index_ensure(em->bm, BM_VERT);
- }
-
- int l_index = 0;
- int f_index = 0;
- BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, f_index) {
- float fac = -1.0f;
-
- if (f->len > 3) {
- BMLoop *l_iter, *l_first;
-
- fac = 0.0f;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const float *no_face;
- float no_corner[3];
- if (mr->bm_vert_coords != NULL) {
- no_face = mr->bm_poly_normals[f_index];
- BM_loop_calc_face_normal_safe_vcos(l_iter, no_face, mr->bm_vert_coords, no_corner);
- }
- else {
- no_face = f->no;
- BM_loop_calc_face_normal_safe(l_iter, no_corner);
- }
-
- /* simple way to detect (what is most likely) concave */
- if (dot_v3v3(no_face, no_corner) < 0.0f) {
- negate_v3(no_corner);
- }
- fac = max_ff(fac, angle_normalized_v3v3(no_face, no_corner));
-
- } while ((l_iter = l_iter->next) != l_first);
- fac *= 2.0f;
- }
-
- fac = distort_remap(fac, min, max, minmax_irange);
- for (int i = 0; i < f->len; i++, l_index++) {
- r_distort[l_index] = fac;
- }
- }
- }
- else {
- const MPoly *mp = mr->mpoly;
- for (int mp_index = 0, l_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
- float fac = -1.0f;
-
- if (mp->totloop > 3) {
- float *f_no = mr->poly_normals[mp_index];
- fac = 0.0f;
-
- for (int i = 1; i <= mp->totloop; i++) {
- const MLoop *l_prev = &mr->mloop[mp->loopstart + (i - 1) % mp->totloop];
- const MLoop *l_curr = &mr->mloop[mp->loopstart + (i + 0) % mp->totloop];
- const MLoop *l_next = &mr->mloop[mp->loopstart + (i + 1) % mp->totloop];
- float no_corner[3];
- normal_tri_v3(no_corner,
- mr->mvert[l_prev->v].co,
- mr->mvert[l_curr->v].co,
- mr->mvert[l_next->v].co);
- /* simple way to detect (what is most likely) concave */
- if (dot_v3v3(f_no, no_corner) < 0.0f) {
- negate_v3(no_corner);
- }
- fac = max_ff(fac, angle_normalized_v3v3(f_no, no_corner));
- }
- fac *= 2.0f;
- }
-
- fac = distort_remap(fac, min, max, minmax_irange);
- for (int i = 0; i < mp->totloop; i++, l_index++) {
- r_distort[l_index] = fac;
- }
- }
- }
-}
-
-BLI_INLINE float sharp_remap(float fac, float min, float UNUSED(max), float minmax_irange)
-{
- /* important not '>=' */
- if (fac > min) {
- fac = (fac - min) * minmax_irange;
- CLAMP(fac, 0.0f, 1.0f);
- }
- else {
- /* fallback */
- fac = -1.0f;
- }
- return fac;
-}
-
-static void statvis_calc_sharp(const MeshRenderData *mr, float *r_sharp)
-{
- BMEditMesh *em = mr->edit_bmesh;
- const MeshStatVis *statvis = &mr->toolsettings->statvis;
- const float min = statvis->sharp_min;
- const float max = statvis->sharp_max;
- const float minmax_irange = 1.0f / (max - min);
-
- /* Can we avoid this extra allocation? */
- float *vert_angles = MEM_mallocN(sizeof(float) * mr->vert_len, __func__);
- copy_vn_fl(vert_angles, mr->vert_len, -M_PI);
-
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- BMIter iter;
- BMesh *bm = em->bm;
- BMFace *efa;
- BMEdge *e;
- /* first assign float values to verts */
- BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- float angle = BM_edge_calc_face_angle_signed(e);
- float *col1 = &vert_angles[BM_elem_index_get(e->v1)];
- float *col2 = &vert_angles[BM_elem_index_get(e->v2)];
- *col1 = max_ff(*col1, angle);
- *col2 = max_ff(*col2, angle);
- }
- /* Copy vert value to loops. */
- BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
- do {
- int l_index = BM_elem_index_get(l_iter);
- int v_index = BM_elem_index_get(l_iter->v);
- r_sharp[l_index] = sharp_remap(vert_angles[v_index], min, max, minmax_irange);
- } while ((l_iter = l_iter->next) != l_first);
- }
- }
- else {
- /* first assign float values to verts */
- const MPoly *mp = mr->mpoly;
-
- EdgeHash *eh = BLI_edgehash_new_ex(__func__, mr->edge_len);
-
- for (int mp_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
- for (int i = 0; i < mp->totloop; i++) {
- const MLoop *l_curr = &mr->mloop[mp->loopstart + (i + 0) % mp->totloop];
- const MLoop *l_next = &mr->mloop[mp->loopstart + (i + 1) % mp->totloop];
- const MVert *v_curr = &mr->mvert[l_curr->v];
- const MVert *v_next = &mr->mvert[l_next->v];
- float angle;
- void **pval;
- bool value_is_init = BLI_edgehash_ensure_p(eh, l_curr->v, l_next->v, &pval);
- if (!value_is_init) {
- *pval = mr->poly_normals[mp_index];
- /* non-manifold edge, yet... */
- continue;
- }
- if (*pval != NULL) {
- const float *f1_no = mr->poly_normals[mp_index];
- const float *f2_no = *pval;
- angle = angle_normalized_v3v3(f1_no, f2_no);
- angle = is_edge_convex_v3(v_curr->co, v_next->co, f1_no, f2_no) ? angle : -angle;
- /* Tag as manifold. */
- *pval = NULL;
- }
- else {
- /* non-manifold edge */
- angle = DEG2RADF(90.0f);
- }
- float *col1 = &vert_angles[l_curr->v];
- float *col2 = &vert_angles[l_next->v];
- *col1 = max_ff(*col1, angle);
- *col2 = max_ff(*col2, angle);
- }
- }
- /* Remaining non manifold edges. */
- EdgeHashIterator *ehi = BLI_edgehashIterator_new(eh);
- for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
- if (BLI_edgehashIterator_getValue(ehi) != NULL) {
- uint v1, v2;
- const float angle = DEG2RADF(90.0f);
- BLI_edgehashIterator_getKey(ehi, &v1, &v2);
- float *col1 = &vert_angles[v1];
- float *col2 = &vert_angles[v2];
- *col1 = max_ff(*col1, angle);
- *col2 = max_ff(*col2, angle);
- }
- }
- BLI_edgehashIterator_free(ehi);
- BLI_edgehash_free(eh, NULL);
-
- const MLoop *ml = mr->mloop;
- for (int l_index = 0; l_index < mr->loop_len; l_index++, ml++) {
- r_sharp[l_index] = sharp_remap(vert_angles[ml->v], min, max, minmax_irange);
- }
- }
-
- MEM_freeN(vert_angles);
-}
-
-static void extract_analysis_iter_finish_mesh(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *UNUSED(data))
-{
- GPUVertBuf *vbo = buf;
- BLI_assert(mr->edit_bmesh);
-
- float *l_weight = (float *)GPU_vertbuf_get_data(vbo);
-
- switch (mr->toolsettings->statvis.type) {
- case SCE_STATVIS_OVERHANG:
- statvis_calc_overhang(mr, l_weight);
- break;
- case SCE_STATVIS_THICKNESS:
- statvis_calc_thickness(mr, l_weight);
- break;
- case SCE_STATVIS_INTERSECT:
- statvis_calc_intersect(mr, l_weight);
- break;
- case SCE_STATVIS_DISTORT:
- statvis_calc_distort(mr, l_weight);
- break;
- case SCE_STATVIS_SHARP:
- statvis_calc_sharp(mr, l_weight);
- break;
- }
-}
-
-const MeshExtract extract_mesh_analysis = {
- .init = extract_mesh_analysis_init,
- .finish = extract_analysis_iter_finish_mesh,
- /* This is not needed for all visualization types.
- * * Maybe split into different extract. */
- .data_type = MR_DATA_POLY_NOR | MR_DATA_LOOPTRI,
- .data_size = 0,
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.mesh_analysis)};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Face-dots positions
- * \{ */
-
-static void extract_fdots_pos_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->poly_len);
- *(float(**)[3])tls_data = GPU_vertbuf_get_data(vbo);
-}
-
-static void extract_fdots_pos_iter_poly_bm(const MeshRenderData *mr,
- const BMFace *f,
- const int f_index,
- void *data)
-{
- float(*center)[3] = *(float(**)[3])data;
-
- float *co = center[f_index];
- zero_v3(co);
-
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- add_v3_v3(co, bm_vert_co_get(mr, l_iter->v));
- } while ((l_iter = l_iter->next) != l_first);
- mul_v3_fl(co, 1.0f / (float)f->len);
-}
-
-static void extract_fdots_pos_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int mp_index,
- void *data)
-{
- float(*center)[3] = *(float(**)[3])data;
- float *co = center[mp_index];
- zero_v3(co);
-
- const MVert *mvert = mr->mvert;
- const MLoop *mloop = mr->mloop;
-
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
- if (mr->use_subsurf_fdots) {
- const MVert *mv = &mr->mvert[ml->v];
- if (mv->flag & ME_VERT_FACEDOT) {
- copy_v3_v3(center[mp_index], mv->co);
- break;
- }
- }
- else {
- const MVert *mv = &mvert[ml->v];
- add_v3_v3(center[mp_index], mv->co);
- }
- }
-
- if (!mr->use_subsurf_fdots) {
- mul_v3_fl(co, 1.0f / (float)mp->totloop);
- }
-}
-
-const MeshExtract extract_fdots_pos = {
- .init = extract_fdots_pos_init,
- .iter_poly_bm = extract_fdots_pos_iter_poly_bm,
- .iter_poly_mesh = extract_fdots_pos_iter_poly_mesh,
- .data_type = 0,
- .data_size = sizeof(float (*)[3]),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.fdots_pos)};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Face-dots Normal and edit flag
- * \{ */
-#define NOR_AND_FLAG_DEFAULT 0
-#define NOR_AND_FLAG_SELECT 1
-#define NOR_AND_FLAG_ACTIVE -1
-#define NOR_AND_FLAG_HIDDEN -2
-
-static void extract_fdots_nor_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *UNUSED(tls_data))
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "norAndFlag", GPU_COMP_I10, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->poly_len);
-}
-
-static void extract_fdots_nor_finish(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *UNUSED(data))
-{
- GPUVertBuf *vbo = buf;
- static float invalid_normal[3] = {0.0f, 0.0f, 0.0f};
- GPUPackedNormal *nor = (GPUPackedNormal *)GPU_vertbuf_get_data(vbo);
- BMFace *efa;
-
- /* Quicker than doing it for each loop. */
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- for (int f = 0; f < mr->poly_len; f++) {
- efa = BM_face_at_index(mr->bm, f);
- const bool is_face_hidden = BM_elem_flag_test(efa, BM_ELEM_HIDDEN);
- if (is_face_hidden || (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex &&
- mr->p_origindex[f] == ORIGINDEX_NONE)) {
- nor[f] = GPU_normal_convert_i10_v3(invalid_normal);
- nor[f].w = NOR_AND_FLAG_HIDDEN;
- }
- else {
- nor[f] = GPU_normal_convert_i10_v3(bm_face_no_get(mr, efa));
- /* Select / Active Flag. */
- nor[f].w = (BM_elem_flag_test(efa, BM_ELEM_SELECT) ?
- ((efa == mr->efa_act) ? NOR_AND_FLAG_ACTIVE : NOR_AND_FLAG_SELECT) :
- NOR_AND_FLAG_DEFAULT);
- }
- }
- }
- else {
- for (int f = 0; f < mr->poly_len; f++) {
- efa = bm_original_face_get(mr, f);
- const bool is_face_hidden = efa && BM_elem_flag_test(efa, BM_ELEM_HIDDEN);
- if (is_face_hidden || (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex &&
- mr->p_origindex[f] == ORIGINDEX_NONE)) {
- nor[f] = GPU_normal_convert_i10_v3(invalid_normal);
- nor[f].w = NOR_AND_FLAG_HIDDEN;
- }
- else {
- nor[f] = GPU_normal_convert_i10_v3(bm_face_no_get(mr, efa));
- /* Select / Active Flag. */
- nor[f].w = (BM_elem_flag_test(efa, BM_ELEM_SELECT) ?
- ((efa == mr->efa_act) ? NOR_AND_FLAG_ACTIVE : NOR_AND_FLAG_SELECT) :
- NOR_AND_FLAG_DEFAULT);
- }
- }
- }
-}
-
-const MeshExtract extract_fdots_nor = {
- .init = extract_fdots_nor_init,
- .finish = extract_fdots_nor_finish,
- .data_type = MR_DATA_POLY_NOR,
- .data_size = 0,
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.fdots_nor)};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Face-dots High Quality Normal and edit flag
- * \{ */
-static void extract_fdots_nor_hq_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *UNUSED(tls_data))
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "norAndFlag", GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->poly_len);
-}
-
-static void extract_fdots_nor_hq_finish(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *UNUSED(data))
-{
- GPUVertBuf *vbo = buf;
- static float invalid_normal[3] = {0.0f, 0.0f, 0.0f};
- short *nor = (short *)GPU_vertbuf_get_data(vbo);
- BMFace *efa;
-
- /* Quicker than doing it for each loop. */
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- for (int f = 0; f < mr->poly_len; f++) {
- efa = BM_face_at_index(mr->bm, f);
- const bool is_face_hidden = BM_elem_flag_test(efa, BM_ELEM_HIDDEN);
- if (is_face_hidden || (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex &&
- mr->p_origindex[f] == ORIGINDEX_NONE)) {
- normal_float_to_short_v3(&nor[f * 4], invalid_normal);
- nor[f * 4 + 3] = NOR_AND_FLAG_HIDDEN;
- }
- else {
- normal_float_to_short_v3(&nor[f * 4], bm_face_no_get(mr, efa));
- /* Select / Active Flag. */
- nor[f * 4 + 3] = (BM_elem_flag_test(efa, BM_ELEM_SELECT) ?
- ((efa == mr->efa_act) ? NOR_AND_FLAG_ACTIVE : NOR_AND_FLAG_SELECT) :
- NOR_AND_FLAG_DEFAULT);
- }
- }
- }
- else {
- for (int f = 0; f < mr->poly_len; f++) {
- efa = bm_original_face_get(mr, f);
- const bool is_face_hidden = efa && BM_elem_flag_test(efa, BM_ELEM_HIDDEN);
- if (is_face_hidden || (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex &&
- mr->p_origindex[f] == ORIGINDEX_NONE)) {
- normal_float_to_short_v3(&nor[f * 4], invalid_normal);
- nor[f * 4 + 3] = NOR_AND_FLAG_HIDDEN;
- }
- else {
- normal_float_to_short_v3(&nor[f * 4], bm_face_no_get(mr, efa));
- /* Select / Active Flag. */
- nor[f * 4 + 3] = (BM_elem_flag_test(efa, BM_ELEM_SELECT) ?
- ((efa == mr->efa_act) ? NOR_AND_FLAG_ACTIVE : NOR_AND_FLAG_SELECT) :
- NOR_AND_FLAG_DEFAULT);
- }
- }
- }
-}
-
-const MeshExtract extract_fdots_nor_hq = {
- .init = extract_fdots_nor_hq_init,
- .finish = extract_fdots_nor_hq_finish,
- .data_type = MR_DATA_POLY_NOR,
- .data_size = 0,
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.fdots_nor)};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Face-dots UV
- * \{ */
-
-typedef struct MeshExtract_FdotUV_Data {
- float (*vbo_data)[2];
- MLoopUV *uv_data;
- int cd_ofs;
-} MeshExtract_FdotUV_Data;
-
-static void extract_fdots_uv_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "u", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- GPU_vertformat_alias_add(&format, "au");
- GPU_vertformat_alias_add(&format, "pos");
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->poly_len);
-
- if (!mr->use_subsurf_fdots) {
- /* Clear so we can accumulate on it. */
- memset(GPU_vertbuf_get_data(vbo), 0x0, mr->poly_len * GPU_vertbuf_get_format(vbo)->stride);
- }
-
- MeshExtract_FdotUV_Data *data = tls_data;
- data->vbo_data = (float(*)[2])GPU_vertbuf_get_data(vbo);
-
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- data->cd_ofs = CustomData_get_offset(&mr->bm->ldata, CD_MLOOPUV);
- }
- else {
- data->uv_data = CustomData_get_layer(&mr->me->ldata, CD_MLOOPUV);
- }
-}
-
-static void extract_fdots_uv_iter_poly_bm(const MeshRenderData *UNUSED(mr),
- const BMFace *f,
- const int UNUSED(f_index),
- void *_data)
-{
- MeshExtract_FdotUV_Data *data = _data;
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- float w = 1.0f / (float)f->len;
- const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l_iter, data->cd_ofs);
- madd_v2_v2fl(data->vbo_data[BM_elem_index_get(f)], luv->uv, w);
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_fdots_uv_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int mp_index,
- void *_data)
-{
- MeshExtract_FdotUV_Data *data = _data;
- const MLoop *mloop = mr->mloop;
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
- if (mr->use_subsurf_fdots) {
- const MVert *mv = &mr->mvert[ml->v];
- if (mv->flag & ME_VERT_FACEDOT) {
- copy_v2_v2(data->vbo_data[mp_index], data->uv_data[ml_index].uv);
- }
- }
- else {
- float w = 1.0f / (float)mp->totloop;
- madd_v2_v2fl(data->vbo_data[mp_index], data->uv_data[ml_index].uv, w);
- }
- }
-}
-
-const MeshExtract extract_fdots_uv = {
- .init = extract_fdots_uv_init,
- .iter_poly_bm = extract_fdots_uv_iter_poly_bm,
- .iter_poly_mesh = extract_fdots_uv_iter_poly_mesh,
- .data_type = 0,
- .data_size = sizeof(MeshExtract_FdotUV_Data),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.fdots_uv)};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Face-dots Edit UV flag
- * \{ */
-
-typedef struct MeshExtract_EditUVFdotData_Data {
- EditLoopData *vbo_data;
- int cd_ofs;
-} MeshExtract_EditUVFdotData_Data;
-
-static void extract_fdots_edituv_data_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "flag", GPU_COMP_U8, 4, GPU_FETCH_INT);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->poly_len);
-
- MeshExtract_EditUVFdotData_Data *data = tls_data;
- data->vbo_data = (EditLoopData *)GPU_vertbuf_get_data(vbo);
- data->cd_ofs = CustomData_get_offset(&mr->bm->ldata, CD_MLOOPUV);
-}
-
-static void extract_fdots_edituv_data_iter_poly_bm(const MeshRenderData *mr,
- const BMFace *f,
- const int UNUSED(f_index),
- void *_data)
-{
- MeshExtract_EditUVFdotData_Data *data = _data;
- EditLoopData *eldata = &data->vbo_data[BM_elem_index_get(f)];
- memset(eldata, 0x0, sizeof(*eldata));
- mesh_render_data_face_flag(mr, f, data->cd_ofs, eldata);
-}
-
-static void extract_fdots_edituv_data_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *UNUSED(mp),
- const int mp_index,
- void *_data)
-{
- MeshExtract_EditUVFdotData_Data *data = _data;
- EditLoopData *eldata = &data->vbo_data[mp_index];
- memset(eldata, 0x0, sizeof(*eldata));
- BMFace *efa = bm_original_face_get(mr, mp_index);
- if (efa) {
- mesh_render_data_face_flag(mr, efa, data->cd_ofs, eldata);
- }
-}
-
-const MeshExtract extract_fdots_edituv_data = {
- .init = extract_fdots_edituv_data_init,
- .iter_poly_bm = extract_fdots_edituv_data_iter_poly_bm,
- .iter_poly_mesh = extract_fdots_edituv_data_iter_poly_mesh,
- .data_type = 0,
- .data_size = sizeof(MeshExtract_EditUVFdotData_Data),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.fdots_edituv_data)};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Skin Modifier Roots
- * \{ */
-
-typedef struct SkinRootData {
- float size;
- float local_pos[3];
-} SkinRootData;
-
-static void extract_skin_roots_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *UNUSED(tls_data))
-{
- GPUVertBuf *vbo = buf;
- /* Exclusively for edit mode. */
- BLI_assert(mr->bm);
-
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
- GPU_vertformat_attr_add(&format, "local_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->bm->totvert);
-
- SkinRootData *vbo_data = (SkinRootData *)GPU_vertbuf_get_data(vbo);
-
- int root_len = 0;
- int cd_ofs = CustomData_get_offset(&mr->bm->vdata, CD_MVERT_SKIN);
-
- BMIter iter;
- BMVert *eve;
- BM_ITER_MESH (eve, &iter, mr->bm, BM_VERTS_OF_MESH) {
- const MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(eve, cd_ofs);
- if (vs->flag & MVERT_SKIN_ROOT) {
- vbo_data->size = (vs->radius[0] + vs->radius[1]) * 0.5f;
- copy_v3_v3(vbo_data->local_pos, bm_vert_co_get(mr, eve));
- vbo_data++;
- root_len++;
- }
- }
-
- /* It's really unlikely that all verts will be roots. Resize to avoid losing VRAM. */
- GPU_vertbuf_data_len_set(vbo, root_len);
-}
-
-const MeshExtract extract_skin_roots = {
- .init = extract_skin_roots_init,
- .data_type = 0,
- .data_size = 0,
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.skin_roots)};
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Extract Selection Index
- * \{ */
-
-static void extract_select_idx_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- /* TODO rename "color" to something more descriptive. */
- GPU_vertformat_attr_add(&format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT);
- }
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
- *(uint32_t **)tls_data = GPU_vertbuf_get_data(vbo);
-}
-
-/* TODO Use #glVertexID to get loop index and use the data structure on the CPU to retrieve the
- * select element associated with this loop ID. This would remove the need for this separate
- * index VBO's. We could upload the p/e/v_origindex as a buffer texture and sample it inside the
- * shader to output original index. */
-
-static void extract_poly_idx_iter_poly_bm(const MeshRenderData *UNUSED(mr),
- const BMFace *f,
- const int f_index,
- void *data)
-{
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
- (*(uint32_t **)data)[l_index] = f_index;
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_edge_idx_iter_poly_bm(const MeshRenderData *UNUSED(mr),
- const BMFace *f,
- const int UNUSED(f_index),
- void *data)
-{
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
- (*(uint32_t **)data)[l_index] = BM_elem_index_get(l_iter->e);
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_vert_idx_iter_poly_bm(const MeshRenderData *UNUSED(mr),
- const BMFace *f,
- const int UNUSED(f_index),
- void *data)
-{
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- const int l_index = BM_elem_index_get(l_iter);
- (*(uint32_t **)data)[l_index] = BM_elem_index_get(l_iter->v);
- } while ((l_iter = l_iter->next) != l_first);
-}
-
-static void extract_edge_idx_iter_ledge_bm(const MeshRenderData *mr,
- const BMEdge *eed,
- const int ledge_index,
- void *data)
-{
- (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 0] = BM_elem_index_get(eed);
- (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 1] = BM_elem_index_get(eed);
-}
-
-static void extract_vert_idx_iter_ledge_bm(const MeshRenderData *mr,
- const BMEdge *eed,
- const int ledge_index,
- void *data)
-{
- (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 0] = BM_elem_index_get(eed->v1);
- (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 1] = BM_elem_index_get(eed->v2);
-}
-
-static void extract_vert_idx_iter_lvert_bm(const MeshRenderData *mr,
- const BMVert *eve,
- const int lvert_index,
- void *data)
-{
- const int offset = mr->loop_len + (mr->edge_loose_len * 2);
-
- (*(uint32_t **)data)[offset + lvert_index] = BM_elem_index_get(eve);
-}
-
-static void extract_poly_idx_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int mp_index,
- void *data)
-{
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- (*(uint32_t **)data)[ml_index] = (mr->p_origindex) ? mr->p_origindex[mp_index] : mp_index;
- }
-}
-
-static void extract_edge_idx_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int UNUSED(mp_index),
- void *data)
-{
- const MLoop *mloop = mr->mloop;
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
- (*(uint32_t **)data)[ml_index] = (mr->e_origindex) ? mr->e_origindex[ml->e] : ml->e;
- }
-}
-
-static void extract_vert_idx_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *mp,
- const int UNUSED(mp_index),
- void *data)
-{
- const MLoop *mloop = mr->mloop;
- const int ml_index_end = mp->loopstart + mp->totloop;
- for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
- const MLoop *ml = &mloop[ml_index];
- (*(uint32_t **)data)[ml_index] = (mr->v_origindex) ? mr->v_origindex[ml->v] : ml->v;
- }
-}
-
-static void extract_edge_idx_iter_ledge_mesh(const MeshRenderData *mr,
- const MEdge *UNUSED(med),
- const int ledge_index,
- void *data)
-{
- const int e_index = mr->ledges[ledge_index];
- const int e_orig = (mr->e_origindex) ? mr->e_origindex[e_index] : e_index;
- (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 0] = e_orig;
- (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 1] = e_orig;
-}
-
-static void extract_vert_idx_iter_ledge_mesh(const MeshRenderData *mr,
- const MEdge *med,
- const int ledge_index,
- void *data)
-{
- int v1_orig = (mr->v_origindex) ? mr->v_origindex[med->v1] : med->v1;
- int v2_orig = (mr->v_origindex) ? mr->v_origindex[med->v2] : med->v2;
- (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 0] = v1_orig;
- (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 1] = v2_orig;
-}
-
-static void extract_vert_idx_iter_lvert_mesh(const MeshRenderData *mr,
- const MVert *UNUSED(mv),
- const int lvert_index,
- void *data)
-{
- const int offset = mr->loop_len + (mr->edge_loose_len * 2);
-
- const int v_index = mr->lverts[lvert_index];
- const int v_orig = (mr->v_origindex) ? mr->v_origindex[v_index] : v_index;
- (*(uint32_t **)data)[offset + lvert_index] = v_orig;
-}
-
-const MeshExtract extract_poly_idx = {
- .init = extract_select_idx_init,
- .iter_poly_bm = extract_poly_idx_iter_poly_bm,
- .iter_poly_mesh = extract_poly_idx_iter_poly_mesh,
- .data_type = 0,
- .data_size = sizeof(uint32_t *),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.poly_idx)};
-
-const MeshExtract extract_edge_idx = {
- .init = extract_select_idx_init,
- .iter_poly_bm = extract_edge_idx_iter_poly_bm,
- .iter_poly_mesh = extract_edge_idx_iter_poly_mesh,
- .iter_ledge_bm = extract_edge_idx_iter_ledge_bm,
- .iter_ledge_mesh = extract_edge_idx_iter_ledge_mesh,
- .data_type = 0,
- .data_size = sizeof(uint32_t *),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.edge_idx)};
-
-const MeshExtract extract_vert_idx = {
- .init = extract_select_idx_init,
- .iter_poly_bm = extract_vert_idx_iter_poly_bm,
- .iter_poly_mesh = extract_vert_idx_iter_poly_mesh,
- .iter_ledge_bm = extract_vert_idx_iter_ledge_bm,
- .iter_ledge_mesh = extract_vert_idx_iter_ledge_mesh,
- .iter_lvert_bm = extract_vert_idx_iter_lvert_bm,
- .iter_lvert_mesh = extract_vert_idx_iter_lvert_mesh,
- .data_type = 0,
- .data_size = sizeof(uint32_t *),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.vert_idx)};
-
-static void extract_fdot_idx_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *buf,
- void *tls_data)
-{
- GPUVertBuf *vbo = buf;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- /* TODO rename "color" to something more descriptive. */
- GPU_vertformat_attr_add(&format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- GPU_vertbuf_data_alloc(vbo, mr->poly_len);
- *(uint32_t **)tls_data = GPU_vertbuf_get_data(vbo);
-}
-
-static void extract_fdot_idx_iter_poly_bm(const MeshRenderData *UNUSED(mr),
- const BMFace *UNUSED(f),
- const int f_index,
- void *data)
-{
- (*(uint32_t **)data)[f_index] = f_index;
-}
-
-static void extract_fdot_idx_iter_poly_mesh(const MeshRenderData *mr,
- const MPoly *UNUSED(mp),
- const int mp_index,
- void *data)
-{
- if (mr->p_origindex != NULL) {
- (*(uint32_t **)data)[mp_index] = mr->p_origindex[mp_index];
- }
- else {
- (*(uint32_t **)data)[mp_index] = mp_index;
- }
-}
-
-const MeshExtract extract_fdot_idx = {
- .init = extract_fdot_idx_init,
- .iter_poly_bm = extract_fdot_idx_iter_poly_bm,
- .iter_poly_mesh = extract_fdot_idx_iter_poly_mesh,
- .data_type = 0,
- .data_size = sizeof(uint32_t *),
- .use_threading = true,
- .mesh_buffer_offset = offsetof(MeshBufferCache, vbo.fdot_idx)};
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_private.h b/source/blender/draw/intern/draw_cache_extract_mesh_private.h
index a258967564b..2424b0f9fee 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh_private.h
+++ b/source/blender/draw/intern/draw_cache_extract_mesh_private.h
@@ -41,66 +41,6 @@ extern "C" {
#define MIN_RANGE_LEN 1024
/* ---------------------------------------------------------------------- */
-/** \name Dependencies between buffer and batch
- * \{ */
-#ifndef NDEBUG
-# define _MDEF_type(name) static DRWBatchFlag MDEP_assert_##name = 0, MDEP_##name
-#else
-# define _MDEF_type(name) static const DRWBatchFlag MDEP_##name
-#endif
-
-/* clang-format off */
-
-#define _MDEPS_CREATE1(b) (1u << MBC_BATCH_INDEX(b))
-#define _MDEPS_CREATE2(b1, b2) _MDEPS_CREATE1(b1) | _MDEPS_CREATE1(b2)
-#define _MDEPS_CREATE3(b1, b2, b3) _MDEPS_CREATE2(b1, b2) | _MDEPS_CREATE1(b3)
-#define _MDEPS_CREATE4(b1, b2, b3, b4) _MDEPS_CREATE3(b1, b2, b3) | _MDEPS_CREATE1(b4)
-#define _MDEPS_CREATE5(b1, b2, b3, b4, b5) _MDEPS_CREATE4(b1, b2, b3, b4) | _MDEPS_CREATE1(b5)
-#define _MDEPS_CREATE6(b1, b2, b3, b4, b5, b6) _MDEPS_CREATE5(b1, b2, b3, b4, b5) | _MDEPS_CREATE1(b6)
-#define _MDEPS_CREATE7(b1, b2, b3, b4, b5, b6, b7) _MDEPS_CREATE6(b1, b2, b3, b4, b5, b6) | _MDEPS_CREATE1(b7)
-#define _MDEPS_CREATE8(b1, b2, b3, b4, b5, b6, b7, b8) _MDEPS_CREATE7(b1, b2, b3, b4, b5, b6, b7) | _MDEPS_CREATE1(b8)
-#define _MDEPS_CREATE9(b1, b2, b3, b4, b5, b6, b7, b8, b9) _MDEPS_CREATE8(b1, b2, b3, b4, b5, b6, b7, b8) | _MDEPS_CREATE1(b9)
-#define _MDEPS_CREATE10(b1, b2, b3, b4, b5, b6, b7, b8, b9, b10) _MDEPS_CREATE9(b1, b2, b3, b4, b5, b6, b7, b8, b9) | _MDEPS_CREATE1(b10)
-#define _MDEPS_CREATE19(b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19) _MDEPS_CREATE10(b1, b2, b3, b4, b5, b6, b7, b8, b9, b10) | _MDEPS_CREATE9(b11, b12, b13, b14, b15, b16, b17, b18, b19)
-
-#define MDEPS_CREATE(name, ...) _MDEF_type(name) = VA_NARGS_CALL_OVERLOAD(_MDEPS_CREATE, __VA_ARGS__)
-
-#define _MDEPS_CREATE_MAP1(a) MDEP_##a
-#define _MDEPS_CREATE_MAP2(a, b) MDEP_##a | MDEP_##b
-#define _MDEPS_CREATE_MAP3(a, b, c) _MDEPS_CREATE_MAP2(a, b) | MDEP_##c
-#define _MDEPS_CREATE_MAP4(a, b, c, d) _MDEPS_CREATE_MAP3(a, b, c) | MDEP_##d
-#define _MDEPS_CREATE_MAP5(a, b, c, d, e) _MDEPS_CREATE_MAP4(a, b, c, d) | MDEP_##e
-#define _MDEPS_CREATE_MAP6(a, b, c, d, e, f) _MDEPS_CREATE_MAP5(a, b, c, d, e) | MDEP_##f
-#define _MDEPS_CREATE_MAP7(a, b, c, d, e, f, g) _MDEPS_CREATE_MAP6(a, b, c, d, e, f) | MDEP_##g
-#define _MDEPS_CREATE_MAP8(a, b, c, d, e, f, g, h) _MDEPS_CREATE_MAP7(a, b, c, d, e, f, g) | MDEP_##h
-#define _MDEPS_CREATE_MAP9(a, b, c, d, e, f, g, h, i) _MDEPS_CREATE_MAP8(a, b, c, d, e, f, g, h) | MDEP_##i
-#define _MDEPS_CREATE_MAP10(a, b, c, d, e, f, g, h, i, j) _MDEPS_CREATE_MAP9(a, b, c, d, e, f, g, h, i) | MDEP_##j
-
-#define MDEPS_CREATE_MAP(...) VA_NARGS_CALL_OVERLOAD(_MDEPS_CREATE_MAP, __VA_ARGS__)
-
-#ifndef NDEBUG
-# define _MDEPS_ASSERT2(b, name) \
- MDEP_assert_##name |= _MDEPS_CREATE1(b); \
- BLI_assert(MDEP_##name & _MDEPS_CREATE1(b))
-# define _MDEPS_ASSERT3(b, n1, n2) _MDEPS_ASSERT2(b, n1); _MDEPS_ASSERT2(b, n2)
-# define _MDEPS_ASSERT4(b, n1, n2, n3) _MDEPS_ASSERT3(b, n1, n2); _MDEPS_ASSERT2(b, n3)
-# define _MDEPS_ASSERT5(b, n1, n2, n3, n4) _MDEPS_ASSERT4(b, n1, n2, n3); _MDEPS_ASSERT2(b, n4)
-# define _MDEPS_ASSERT6(b, n1, n2, n3, n4, n5) _MDEPS_ASSERT5(b, n1, n2, n3, n4); _MDEPS_ASSERT2(b, n5)
-# define _MDEPS_ASSERT7(b, n1, n2, n3, n4, n5, n6) _MDEPS_ASSERT6(b, n1, n2, n3, n4, n5); _MDEPS_ASSERT2(b, n6)
-# define _MDEPS_ASSERT8(b, n1, n2, n3, n4, n5, n6, n7) _MDEPS_ASSERT7(b, n1, n2, n3, n4, n5, n6); _MDEPS_ASSERT2(b, n7)
-
-# define MDEPS_ASSERT(...) VA_NARGS_CALL_OVERLOAD(_MDEPS_ASSERT, __VA_ARGS__)
-# define MDEPS_ASSERT_MAP(name) BLI_assert(MDEP_assert_##name == MDEP_##name)
-#else
-# define MDEPS_ASSERT(...)
-# define MDEPS_ASSERT_MAP(name) UNUSED_VARS(MDEP_##name)
-#endif
-
-/* clang-format on */
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
/** \name Mesh Render Data
* \{ */
@@ -318,11 +258,30 @@ void mesh_render_data_update_looptris(MeshRenderData *mr,
const eMRDataType data_flag);
/* draw_cache_extract_mesh_extractors.c */
+typedef struct EditLoopData {
+ uchar v_flag;
+ uchar e_flag;
+ uchar crease;
+ uchar bweight;
+} EditLoopData;
+
void *mesh_extract_buffer_get(const MeshExtract *extractor, MeshBufferCache *mbc);
eMRIterType mesh_extract_iter_type(const MeshExtract *ext);
const MeshExtract *mesh_extract_override_get(const MeshExtract *extractor,
const bool do_hq_normals,
const bool do_single_mat);
+void mesh_render_data_face_flag(const MeshRenderData *mr,
+ const BMFace *efa,
+ const int cd_ofs,
+ EditLoopData *eattr);
+void mesh_render_data_loop_flag(const MeshRenderData *mr,
+ BMLoop *l,
+ const int cd_ofs,
+ EditLoopData *eattr);
+void mesh_render_data_loop_edge_flag(const MeshRenderData *mr,
+ BMLoop *l,
+ const int cd_ofs,
+ EditLoopData *eattr);
extern const MeshExtract extract_tris;
extern const MeshExtract extract_tris_single_mat;
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 5743f39f7da..220a7f37c3d 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -219,7 +219,7 @@ struct GPUVertBuf *DRW_mesh_batch_cache_pos_vertbuf_get(struct Mesh *me);
struct GPUVertBuf *DRW_curve_batch_cache_pos_vertbuf_get(struct Curve *cu);
struct GPUVertBuf *DRW_mball_batch_cache_pos_vertbuf_get(struct Object *ob);
-int DRW_mesh_material_count_get(struct Mesh *me);
+int DRW_mesh_material_count_get(const struct Mesh *me);
/* See 'common_globals_lib.glsl' for duplicate defines. */
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.cc b/source/blender/draw/intern/draw_cache_impl_curve.cc
index 9ca452cdacc..c4cd547ef43 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.cc
+++ b/source/blender/draw/intern/draw_cache_impl_curve.cc
@@ -94,7 +94,7 @@ static void curve_render_overlay_verts_edges_len_get(ListBase *lb,
LISTBASE_FOREACH (Nurb *, nu, lb) {
if (nu->bezt) {
vert_len += nu->pntsu * 3;
- /* 2x handles per point*/
+ /* 2x handles per point. */
edge_len += 2 * nu->pntsu;
}
else if (nu->bp) {
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c
index b59c4db8383..1d4f411c94d 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -861,7 +861,7 @@ void DRW_displist_indexbuf_create_edges_adjacency_lines(struct ListBase *lb,
}
BLI_edgehashIterator_getKey(ehi, &v1, &v2);
uint v0 = (uint)abs(v_data) - 1;
- if (v_data < 0) { /* inv_opposite */
+ if (v_data < 0) { /* inv_opposite */
SWAP(uint, v1, v2);
}
GPU_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0);
diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c
index e6c7341759b..eabef49fa22 100644
--- a/source/blender/draw/intern/draw_cache_impl_lattice.c
+++ b/source/blender/draw/intern/draw_cache_impl_lattice.c
@@ -165,7 +165,7 @@ static LatticeRenderData *lattice_render_data_create(Lattice *lt, const int type
}
if (types & (LR_DATATYPE_EDGE)) {
rdata->edge_len = lattice_render_edges_len_get(lt);
- /*no edge data */
+ /* No edge data. */
}
}
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 3b70490509d..2fcbce2440e 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -72,85 +72,150 @@
#include "draw_cache_impl.h" /* own include */
-MDEPS_CREATE(vbo_lnor, batch.surface, batch.wire_loops, batch.edit_lnor, surface_per_mat);
-MDEPS_CREATE(vbo_pos_nor,
- batch.surface,
- batch.surface_weights,
- batch.all_verts,
- batch.all_edges,
- batch.loose_edges,
- batch.edge_detection,
- batch.wire_loops,
- batch.wire_edges,
- batch.edit_vnor,
- batch.edit_lnor,
- batch.edit_vertices,
- batch.edit_edges,
- batch.edit_triangles,
- batch.edit_selection_verts,
- batch.edit_selection_edges,
- batch.edit_selection_faces,
- batch.edit_mesh_analysis,
- batch.sculpt_overlays,
- surface_per_mat);
-MDEPS_CREATE(vbo_uv,
- batch.surface,
- batch.wire_loops_uvs,
- batch.edituv_faces,
- batch.edituv_faces_stretch_area,
- batch.edituv_faces_stretch_angle,
- batch.edituv_edges,
- batch.edituv_verts,
- surface_per_mat);
-MDEPS_CREATE(vbo_vcol, batch.surface, surface_per_mat);
-MDEPS_CREATE(vbo_sculpt_data, batch.sculpt_overlays);
-MDEPS_CREATE(vbo_weights, batch.surface_weights);
-MDEPS_CREATE(vbo_edge_fac, batch.wire_edges);
-MDEPS_CREATE(vbo_mesh_analysis, batch.edit_mesh_analysis);
-MDEPS_CREATE(vbo_tan, surface_per_mat);
-MDEPS_CREATE(vbo_orco, surface_per_mat);
-MDEPS_CREATE(vbo_edit_data, batch.edit_triangles, batch.edit_edges, batch.edit_vertices);
-MDEPS_CREATE(vbo_fdots_pos, batch.edit_fdots, batch.edit_selection_fdots);
-MDEPS_CREATE(vbo_fdots_nor, batch.edit_fdots);
-MDEPS_CREATE(vbo_skin_roots, batch.edit_skin_roots);
-MDEPS_CREATE(vbo_vert_idx, batch.edit_selection_verts);
-MDEPS_CREATE(vbo_edge_idx, batch.edit_selection_edges);
-MDEPS_CREATE(vbo_poly_idx, batch.edit_selection_faces);
-MDEPS_CREATE(vbo_fdot_idx, batch.edit_selection_fdots);
-MDEPS_CREATE(vbo_edituv_data,
- batch.edituv_faces,
- batch.edituv_faces_stretch_area,
- batch.edituv_faces_stretch_angle,
- batch.edituv_edges,
- batch.edituv_verts);
-MDEPS_CREATE(vbo_edituv_stretch_area, batch.edituv_faces_stretch_area);
-MDEPS_CREATE(vbo_edituv_stretch_angle, batch.edituv_faces_stretch_angle);
-MDEPS_CREATE(vbo_fdots_uv, batch.edituv_fdots);
-MDEPS_CREATE(vbo_fdots_edituv_data, batch.edituv_fdots);
-
-MDEPS_CREATE(ibo_tris,
- batch.surface,
- batch.sculpt_overlays,
- batch.surface_weights,
- batch.edit_mesh_analysis,
- batch.edit_triangles,
- batch.edit_lnor,
- batch.edit_selection_faces);
-MDEPS_CREATE(
- ibo_lines, batch.all_edges, batch.wire_edges, batch.edit_edges, batch.edit_selection_edges);
-MDEPS_CREATE(ibo_lines_loose, batch.loose_edges);
-MDEPS_CREATE(ibo_lines_adjacency, batch.edge_detection);
-MDEPS_CREATE(ibo_lines_paint_mask, batch.wire_loops);
-MDEPS_CREATE(ibo_tris_per_mat, surface_per_mat);
-MDEPS_CREATE(ibo_points, batch.edit_vnor, batch.edit_selection_verts, batch.edit_vertices);
-MDEPS_CREATE(ibo_fdots, batch.edit_fdots, batch.edit_selection_fdots);
-MDEPS_CREATE(ibo_edituv_tris,
- batch.edituv_faces,
- batch.edituv_faces_stretch_area,
- batch.edituv_faces_stretch_angle);
-MDEPS_CREATE(ibo_edituv_lines, batch.edituv_edges, batch.wire_loops_uvs);
-MDEPS_CREATE(ibo_edituv_points, batch.edituv_verts);
-MDEPS_CREATE(ibo_edituv_fdots, batch.edituv_fdots);
+/* ---------------------------------------------------------------------- */
+/** \name Dependencies between buffer and batch
+ * \{ */
+
+/* clang-format off */
+
+#define _BUFFER_INDEX(buff_name) ((offsetof(MeshBufferCache, buff_name) - offsetof(MeshBufferCache, vbo)) / sizeof(void *))
+
+#define _MDEPS_CREATE1(b) (1u << MBC_BATCH_INDEX(b))
+#define _MDEPS_CREATE2(b1, b2) _MDEPS_CREATE1(b1) | _MDEPS_CREATE1(b2)
+#define _MDEPS_CREATE3(b1, b2, b3) _MDEPS_CREATE2(b1, b2) | _MDEPS_CREATE1(b3)
+#define _MDEPS_CREATE4(b1, b2, b3, b4) _MDEPS_CREATE3(b1, b2, b3) | _MDEPS_CREATE1(b4)
+#define _MDEPS_CREATE5(b1, b2, b3, b4, b5) _MDEPS_CREATE4(b1, b2, b3, b4) | _MDEPS_CREATE1(b5)
+#define _MDEPS_CREATE6(b1, b2, b3, b4, b5, b6) _MDEPS_CREATE5(b1, b2, b3, b4, b5) | _MDEPS_CREATE1(b6)
+#define _MDEPS_CREATE7(b1, b2, b3, b4, b5, b6, b7) _MDEPS_CREATE6(b1, b2, b3, b4, b5, b6) | _MDEPS_CREATE1(b7)
+#define _MDEPS_CREATE8(b1, b2, b3, b4, b5, b6, b7, b8) _MDEPS_CREATE7(b1, b2, b3, b4, b5, b6, b7) | _MDEPS_CREATE1(b8)
+#define _MDEPS_CREATE9(b1, b2, b3, b4, b5, b6, b7, b8, b9) _MDEPS_CREATE8(b1, b2, b3, b4, b5, b6, b7, b8) | _MDEPS_CREATE1(b9)
+#define _MDEPS_CREATE10(b1, b2, b3, b4, b5, b6, b7, b8, b9, b10) _MDEPS_CREATE9(b1, b2, b3, b4, b5, b6, b7, b8, b9) | _MDEPS_CREATE1(b10)
+#define _MDEPS_CREATE19(b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19) _MDEPS_CREATE10(b1, b2, b3, b4, b5, b6, b7, b8, b9, b10) | _MDEPS_CREATE9(b11, b12, b13, b14, b15, b16, b17, b18, b19)
+
+#define MDEPS_CREATE(buff_name, ...) [_BUFFER_INDEX(buff_name)] = VA_NARGS_CALL_OVERLOAD(_MDEPS_CREATE, __VA_ARGS__)
+
+#define _MDEPS_CREATE_MAP1(a) g_buffer_desps[_BUFFER_INDEX(a)]
+#define _MDEPS_CREATE_MAP2(a, b) _MDEPS_CREATE_MAP1(a) | _MDEPS_CREATE_MAP1(b)
+#define _MDEPS_CREATE_MAP3(a, b, c) _MDEPS_CREATE_MAP2(a, b) | _MDEPS_CREATE_MAP1(c)
+#define _MDEPS_CREATE_MAP4(a, b, c, d) _MDEPS_CREATE_MAP3(a, b, c) | _MDEPS_CREATE_MAP1(d)
+#define _MDEPS_CREATE_MAP5(a, b, c, d, e) _MDEPS_CREATE_MAP4(a, b, c, d) | _MDEPS_CREATE_MAP1(e)
+#define _MDEPS_CREATE_MAP6(a, b, c, d, e, f) _MDEPS_CREATE_MAP5(a, b, c, d, e) | _MDEPS_CREATE_MAP1(f)
+#define _MDEPS_CREATE_MAP7(a, b, c, d, e, f, g) _MDEPS_CREATE_MAP6(a, b, c, d, e, f) | _MDEPS_CREATE_MAP1(g)
+#define _MDEPS_CREATE_MAP8(a, b, c, d, e, f, g, h) _MDEPS_CREATE_MAP7(a, b, c, d, e, f, g) | _MDEPS_CREATE_MAP1(h)
+#define _MDEPS_CREATE_MAP9(a, b, c, d, e, f, g, h, i) _MDEPS_CREATE_MAP8(a, b, c, d, e, f, g, h) | _MDEPS_CREATE_MAP1(i)
+#define _MDEPS_CREATE_MAP10(a, b, c, d, e, f, g, h, i, j) _MDEPS_CREATE_MAP9(a, b, c, d, e, f, g, h, i) | _MDEPS_CREATE_MAP1(j)
+
+#define MDEPS_CREATE_MAP(...) VA_NARGS_CALL_OVERLOAD(_MDEPS_CREATE_MAP, __VA_ARGS__)
+
+#ifndef NDEBUG
+# define _MDEPS_ASSERT2(b, name) \
+ g_buffer_desps_d[_BUFFER_INDEX(name)] |= _MDEPS_CREATE1(b); \
+ BLI_assert(g_buffer_desps[_BUFFER_INDEX(name)] & _MDEPS_CREATE1(b))
+# define _MDEPS_ASSERT3(b, n1, n2) _MDEPS_ASSERT2(b, n1); _MDEPS_ASSERT2(b, n2)
+# define _MDEPS_ASSERT4(b, n1, n2, n3) _MDEPS_ASSERT3(b, n1, n2); _MDEPS_ASSERT2(b, n3)
+# define _MDEPS_ASSERT5(b, n1, n2, n3, n4) _MDEPS_ASSERT4(b, n1, n2, n3); _MDEPS_ASSERT2(b, n4)
+# define _MDEPS_ASSERT6(b, n1, n2, n3, n4, n5) _MDEPS_ASSERT5(b, n1, n2, n3, n4); _MDEPS_ASSERT2(b, n5)
+# define _MDEPS_ASSERT7(b, n1, n2, n3, n4, n5, n6) _MDEPS_ASSERT6(b, n1, n2, n3, n4, n5); _MDEPS_ASSERT2(b, n6)
+# define _MDEPS_ASSERT8(b, n1, n2, n3, n4, n5, n6, n7) _MDEPS_ASSERT7(b, n1, n2, n3, n4, n5, n6); _MDEPS_ASSERT2(b, n7)
+
+# define MDEPS_ASSERT(...) VA_NARGS_CALL_OVERLOAD(_MDEPS_ASSERT, __VA_ARGS__)
+# define MDEPS_ASSERT_MAP(name) BLI_assert(g_buffer_desps_d[_BUFFER_INDEX(name)] == g_buffer_desps[_BUFFER_INDEX(name)])
+#else
+# define MDEPS_ASSERT(...)
+# define MDEPS_ASSERT_MAP(name)
+#endif
+
+/* clang-format on */
+
+static const DRWBatchFlag g_buffer_desps[] = {
+ MDEPS_CREATE(vbo.pos_nor,
+ batch.surface,
+ batch.surface_weights,
+ batch.edit_triangles,
+ batch.edit_vertices,
+ batch.edit_edges,
+ batch.edit_vnor,
+ batch.edit_lnor,
+ batch.edit_mesh_analysis,
+ batch.edit_selection_verts,
+ batch.edit_selection_edges,
+ batch.edit_selection_faces,
+ batch.all_verts,
+ batch.all_edges,
+ batch.loose_edges,
+ batch.edge_detection,
+ batch.wire_edges,
+ batch.wire_loops,
+ batch.sculpt_overlays,
+ surface_per_mat),
+ MDEPS_CREATE(vbo.lnor, batch.surface, batch.edit_lnor, batch.wire_loops, surface_per_mat),
+ MDEPS_CREATE(vbo.edge_fac, batch.wire_edges),
+ MDEPS_CREATE(vbo.weights, batch.surface_weights),
+ MDEPS_CREATE(vbo.uv,
+ batch.surface,
+ batch.edituv_faces_stretch_area,
+ batch.edituv_faces_stretch_angle,
+ batch.edituv_faces,
+ batch.edituv_edges,
+ batch.edituv_verts,
+ batch.wire_loops_uvs,
+ surface_per_mat),
+ MDEPS_CREATE(vbo.tan, surface_per_mat),
+ MDEPS_CREATE(vbo.vcol, batch.surface, surface_per_mat),
+ MDEPS_CREATE(vbo.sculpt_data, batch.sculpt_overlays),
+ MDEPS_CREATE(vbo.orco, surface_per_mat),
+ MDEPS_CREATE(vbo.edit_data, batch.edit_triangles, batch.edit_edges, batch.edit_vertices),
+ MDEPS_CREATE(vbo.edituv_data,
+ batch.edituv_faces,
+ batch.edituv_faces_stretch_area,
+ batch.edituv_faces_stretch_angle,
+ batch.edituv_edges,
+ batch.edituv_verts),
+ MDEPS_CREATE(vbo.edituv_stretch_area, batch.edituv_faces_stretch_area),
+ MDEPS_CREATE(vbo.edituv_stretch_angle, batch.edituv_faces_stretch_angle),
+ MDEPS_CREATE(vbo.mesh_analysis, batch.edit_mesh_analysis),
+ MDEPS_CREATE(vbo.fdots_pos, batch.edit_fdots, batch.edit_selection_fdots),
+ MDEPS_CREATE(vbo.fdots_nor, batch.edit_fdots),
+ MDEPS_CREATE(vbo.fdots_uv, batch.edituv_fdots),
+ MDEPS_CREATE(vbo.fdots_edituv_data, batch.edituv_fdots),
+ MDEPS_CREATE(vbo.skin_roots, batch.edit_skin_roots),
+ MDEPS_CREATE(vbo.vert_idx, batch.edit_selection_verts),
+ MDEPS_CREATE(vbo.edge_idx, batch.edit_selection_edges),
+ MDEPS_CREATE(vbo.poly_idx, batch.edit_selection_faces),
+ MDEPS_CREATE(vbo.fdot_idx, batch.edit_selection_fdots),
+
+ MDEPS_CREATE(ibo.tris,
+ batch.surface,
+ batch.surface_weights,
+ batch.edit_triangles,
+ batch.edit_lnor,
+ batch.edit_mesh_analysis,
+ batch.edit_selection_faces,
+ batch.sculpt_overlays),
+ MDEPS_CREATE(ibo.lines,
+ batch.edit_edges,
+ batch.edit_selection_edges,
+ batch.all_edges,
+ batch.wire_edges),
+ MDEPS_CREATE(ibo.lines_loose, batch.loose_edges),
+ MDEPS_CREATE(ibo.points, batch.edit_vnor, batch.edit_vertices, batch.edit_selection_verts),
+ MDEPS_CREATE(ibo.fdots, batch.edit_fdots, batch.edit_selection_fdots),
+ MDEPS_CREATE(ibo.lines_paint_mask, batch.wire_loops),
+ MDEPS_CREATE(ibo.lines_adjacency, batch.edge_detection),
+ MDEPS_CREATE(ibo.edituv_tris,
+ batch.edituv_faces,
+ batch.edituv_faces_stretch_area,
+ batch.edituv_faces_stretch_angle),
+ MDEPS_CREATE(ibo.edituv_lines, batch.edituv_edges, batch.wire_loops_uvs),
+ MDEPS_CREATE(ibo.edituv_points, batch.edituv_verts),
+ MDEPS_CREATE(ibo.edituv_fdots, batch.edituv_fdots),
+
+ MDEPS_CREATE(tris_per_mat, surface_per_mat),
+};
+
+#ifndef NDEBUG
+static DRWBatchFlag g_buffer_desps_d[sizeof(g_buffer_desps)] = {0};
+#endif
static void mesh_batch_cache_discard_surface_batches(MeshBatchCache *cache);
static void mesh_batch_cache_clear(Mesh *me);
@@ -659,7 +724,7 @@ static void mesh_batch_cache_discard_shaded_tri(MeshBatchCache *cache)
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.vcol);
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.orco);
}
- DRWBatchFlag batch_map = MDEPS_CREATE_MAP(vbo_uv, vbo_tan, vbo_vcol, vbo_orco);
+ DRWBatchFlag batch_map = MDEPS_CREATE_MAP(vbo.uv, vbo.tan, vbo.vcol, vbo.orco);
mesh_batch_cache_discard_batch(cache, batch_map);
mesh_cd_layers_type_clear(&cache->cd_used);
}
@@ -678,16 +743,16 @@ static void mesh_batch_cache_discard_uvedit(MeshBatchCache *cache)
GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_points);
GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_fdots);
}
- DRWBatchFlag batch_map = MDEPS_CREATE_MAP(vbo_edituv_stretch_angle,
- vbo_edituv_stretch_area,
- vbo_uv,
- vbo_edituv_data,
- vbo_fdots_uv,
- vbo_fdots_edituv_data,
- ibo_edituv_tris,
- ibo_edituv_lines,
- ibo_edituv_points,
- ibo_edituv_fdots);
+ DRWBatchFlag batch_map = MDEPS_CREATE_MAP(vbo.edituv_stretch_angle,
+ vbo.edituv_stretch_area,
+ vbo.uv,
+ vbo.edituv_data,
+ vbo.fdots_uv,
+ vbo.fdots_edituv_data,
+ ibo.edituv_tris,
+ ibo.edituv_lines,
+ ibo.edituv_points,
+ ibo.edituv_fdots);
mesh_batch_cache_discard_batch(cache, batch_map);
cache->tot_area = 0.0f;
@@ -710,12 +775,12 @@ static void mesh_batch_cache_discard_uvedit_select(MeshBatchCache *cache)
GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_points);
GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_fdots);
}
- DRWBatchFlag batch_map = MDEPS_CREATE_MAP(vbo_edituv_data,
- vbo_fdots_edituv_data,
- ibo_edituv_tris,
- ibo_edituv_lines,
- ibo_edituv_points,
- ibo_edituv_fdots);
+ DRWBatchFlag batch_map = MDEPS_CREATE_MAP(vbo.edituv_data,
+ vbo.fdots_edituv_data,
+ ibo.edituv_tris,
+ ibo.edituv_lines,
+ ibo.edituv_points,
+ ibo.edituv_fdots);
mesh_batch_cache_discard_batch(cache, batch_map);
}
@@ -732,7 +797,7 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, eMeshBatchDirtyMode mode)
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.edit_data);
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_nor);
}
- batch_map = MDEPS_CREATE_MAP(vbo_edit_data, vbo_fdots_nor);
+ batch_map = MDEPS_CREATE_MAP(vbo.edit_data, vbo.fdots_nor);
mesh_batch_cache_discard_batch(cache, batch_map);
/* Because visible UVs depends on edit mode selection, discard topology. */
@@ -746,7 +811,7 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, eMeshBatchDirtyMode mode)
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.pos_nor);
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.lnor);
}
- batch_map = MDEPS_CREATE_MAP(ibo_lines_paint_mask, vbo_pos_nor, vbo_lnor);
+ batch_map = MDEPS_CREATE_MAP(ibo.lines_paint_mask, vbo.pos_nor, vbo.lnor);
mesh_batch_cache_discard_batch(cache, batch_map);
break;
case BKE_MESH_BATCH_DIRTY_ALL:
@@ -764,7 +829,7 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, eMeshBatchDirtyMode mode)
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.edituv_data);
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_edituv_data);
}
- batch_map = MDEPS_CREATE_MAP(vbo_edituv_data, vbo_fdots_edituv_data);
+ batch_map = MDEPS_CREATE_MAP(vbo.edituv_data, vbo.fdots_edituv_data);
mesh_batch_cache_discard_batch(cache, batch_map);
break;
default:
@@ -987,7 +1052,7 @@ GPUBatch *DRW_mesh_batch_cache_get_surface_sculpt(Mesh *me)
return cache->batch.surface;
}
-int DRW_mesh_material_count_get(Mesh *me)
+int DRW_mesh_material_count_get(const Mesh *me)
{
return mesh_render_mat_len_get(me);
}
@@ -1437,7 +1502,7 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
MeshBufferCache *mbufcache = &cache->final;
/* Initialize batches and request VBO's & IBO's. */
- MDEPS_ASSERT(batch.surface, ibo_tris, vbo_lnor, vbo_pos_nor, vbo_uv, vbo_vcol);
+ MDEPS_ASSERT(batch.surface, ibo.tris, vbo.lnor, vbo.pos_nor, vbo.uv, vbo.vcol);
if (DRW_batch_requested(cache->batch.surface, GPU_PRIM_TRIS)) {
DRW_ibo_request(cache->batch.surface, &mbufcache->ibo.tris);
/* Order matters. First ones override latest VBO's attributes. */
@@ -1450,52 +1515,52 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.vcol);
}
}
- MDEPS_ASSERT(batch.all_verts, vbo_pos_nor);
+ MDEPS_ASSERT(batch.all_verts, vbo.pos_nor);
if (DRW_batch_requested(cache->batch.all_verts, GPU_PRIM_POINTS)) {
DRW_vbo_request(cache->batch.all_verts, &mbufcache->vbo.pos_nor);
}
- MDEPS_ASSERT(batch.sculpt_overlays, ibo_tris, vbo_pos_nor, vbo_sculpt_data);
+ MDEPS_ASSERT(batch.sculpt_overlays, ibo.tris, vbo.pos_nor, vbo.sculpt_data);
if (DRW_batch_requested(cache->batch.sculpt_overlays, GPU_PRIM_TRIS)) {
DRW_ibo_request(cache->batch.sculpt_overlays, &mbufcache->ibo.tris);
DRW_vbo_request(cache->batch.sculpt_overlays, &mbufcache->vbo.pos_nor);
DRW_vbo_request(cache->batch.sculpt_overlays, &mbufcache->vbo.sculpt_data);
}
- MDEPS_ASSERT(batch.all_edges, ibo_lines, vbo_pos_nor);
+ MDEPS_ASSERT(batch.all_edges, ibo.lines, vbo.pos_nor);
if (DRW_batch_requested(cache->batch.all_edges, GPU_PRIM_LINES)) {
DRW_ibo_request(cache->batch.all_edges, &mbufcache->ibo.lines);
DRW_vbo_request(cache->batch.all_edges, &mbufcache->vbo.pos_nor);
}
- MDEPS_ASSERT(batch.loose_edges, ibo_lines_loose, vbo_pos_nor);
+ MDEPS_ASSERT(batch.loose_edges, ibo.lines_loose, vbo.pos_nor);
if (DRW_batch_requested(cache->batch.loose_edges, GPU_PRIM_LINES)) {
DRW_ibo_request(NULL, &mbufcache->ibo.lines);
DRW_ibo_request(cache->batch.loose_edges, &mbufcache->ibo.lines_loose);
DRW_vbo_request(cache->batch.loose_edges, &mbufcache->vbo.pos_nor);
}
- MDEPS_ASSERT(batch.edge_detection, ibo_lines_adjacency, vbo_pos_nor);
+ MDEPS_ASSERT(batch.edge_detection, ibo.lines_adjacency, vbo.pos_nor);
if (DRW_batch_requested(cache->batch.edge_detection, GPU_PRIM_LINES_ADJ)) {
DRW_ibo_request(cache->batch.edge_detection, &mbufcache->ibo.lines_adjacency);
DRW_vbo_request(cache->batch.edge_detection, &mbufcache->vbo.pos_nor);
}
- MDEPS_ASSERT(batch.surface_weights, ibo_tris, vbo_pos_nor, vbo_weights);
+ MDEPS_ASSERT(batch.surface_weights, ibo.tris, vbo.pos_nor, vbo.weights);
if (DRW_batch_requested(cache->batch.surface_weights, GPU_PRIM_TRIS)) {
DRW_ibo_request(cache->batch.surface_weights, &mbufcache->ibo.tris);
DRW_vbo_request(cache->batch.surface_weights, &mbufcache->vbo.pos_nor);
DRW_vbo_request(cache->batch.surface_weights, &mbufcache->vbo.weights);
}
- MDEPS_ASSERT(batch.wire_loops, ibo_lines_paint_mask, vbo_lnor, vbo_pos_nor);
+ MDEPS_ASSERT(batch.wire_loops, ibo.lines_paint_mask, vbo.lnor, vbo.pos_nor);
if (DRW_batch_requested(cache->batch.wire_loops, GPU_PRIM_LINES)) {
DRW_ibo_request(cache->batch.wire_loops, &mbufcache->ibo.lines_paint_mask);
/* Order matters. First ones override latest VBO's attributes. */
DRW_vbo_request(cache->batch.wire_loops, &mbufcache->vbo.lnor);
DRW_vbo_request(cache->batch.wire_loops, &mbufcache->vbo.pos_nor);
}
- MDEPS_ASSERT(batch.wire_edges, ibo_lines, vbo_pos_nor, vbo_edge_fac);
+ MDEPS_ASSERT(batch.wire_edges, ibo.lines, vbo.pos_nor, vbo.edge_fac);
if (DRW_batch_requested(cache->batch.wire_edges, GPU_PRIM_LINES)) {
DRW_ibo_request(cache->batch.wire_edges, &mbufcache->ibo.lines);
DRW_vbo_request(cache->batch.wire_edges, &mbufcache->vbo.pos_nor);
DRW_vbo_request(cache->batch.wire_edges, &mbufcache->vbo.edge_fac);
}
- MDEPS_ASSERT(batch.wire_loops_uvs, ibo_edituv_lines, vbo_uv);
+ MDEPS_ASSERT(batch.wire_loops_uvs, ibo.edituv_lines, vbo.uv);
if (DRW_batch_requested(cache->batch.wire_loops_uvs, GPU_PRIM_LINES)) {
DRW_ibo_request(cache->batch.wire_loops_uvs, &mbufcache->ibo.edituv_lines);
/* For paint overlay. Active layer should have been queried. */
@@ -1503,7 +1568,7 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
DRW_vbo_request(cache->batch.wire_loops_uvs, &mbufcache->vbo.uv);
}
}
- MDEPS_ASSERT(batch.edit_mesh_analysis, ibo_tris, vbo_pos_nor, vbo_mesh_analysis);
+ MDEPS_ASSERT(batch.edit_mesh_analysis, ibo.tris, vbo.pos_nor, vbo.mesh_analysis);
if (DRW_batch_requested(cache->batch.edit_mesh_analysis, GPU_PRIM_TRIS)) {
DRW_ibo_request(cache->batch.edit_mesh_analysis, &mbufcache->ibo.tris);
DRW_vbo_request(cache->batch.edit_mesh_analysis, &mbufcache->vbo.pos_nor);
@@ -1511,14 +1576,8 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
}
/* Per Material */
- MDEPS_ASSERT(surface_per_mat,
- ibo_tris_per_mat,
- vbo_lnor,
- vbo_pos_nor,
- vbo_uv,
- vbo_tan,
- vbo_vcol,
- vbo_orco);
+ MDEPS_ASSERT(
+ surface_per_mat, tris_per_mat, vbo.lnor, vbo.pos_nor, vbo.uv, vbo.tan, vbo.vcol, vbo.orco);
for (int i = 0; i < cache->mat_len; i++) {
if (DRW_batch_requested(cache->surface_per_mat[i], GPU_PRIM_TRIS)) {
DRW_ibo_request(cache->surface_per_mat[i], &mbufcache->tris_per_mat[i]);
@@ -1543,66 +1602,66 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
mbufcache = (do_cage) ? &cache->cage : &cache->final;
/* Edit Mesh */
- MDEPS_ASSERT(batch.edit_triangles, ibo_tris, vbo_pos_nor, vbo_edit_data);
+ MDEPS_ASSERT(batch.edit_triangles, ibo.tris, vbo.pos_nor, vbo.edit_data);
if (DRW_batch_requested(cache->batch.edit_triangles, GPU_PRIM_TRIS)) {
DRW_ibo_request(cache->batch.edit_triangles, &mbufcache->ibo.tris);
DRW_vbo_request(cache->batch.edit_triangles, &mbufcache->vbo.pos_nor);
DRW_vbo_request(cache->batch.edit_triangles, &mbufcache->vbo.edit_data);
}
- MDEPS_ASSERT(batch.edit_vertices, ibo_points, vbo_pos_nor, vbo_edit_data);
+ MDEPS_ASSERT(batch.edit_vertices, ibo.points, vbo.pos_nor, vbo.edit_data);
if (DRW_batch_requested(cache->batch.edit_vertices, GPU_PRIM_POINTS)) {
DRW_ibo_request(cache->batch.edit_vertices, &mbufcache->ibo.points);
DRW_vbo_request(cache->batch.edit_vertices, &mbufcache->vbo.pos_nor);
DRW_vbo_request(cache->batch.edit_vertices, &mbufcache->vbo.edit_data);
}
- MDEPS_ASSERT(batch.edit_edges, ibo_lines, vbo_pos_nor, vbo_edit_data);
+ MDEPS_ASSERT(batch.edit_edges, ibo.lines, vbo.pos_nor, vbo.edit_data);
if (DRW_batch_requested(cache->batch.edit_edges, GPU_PRIM_LINES)) {
DRW_ibo_request(cache->batch.edit_edges, &mbufcache->ibo.lines);
DRW_vbo_request(cache->batch.edit_edges, &mbufcache->vbo.pos_nor);
DRW_vbo_request(cache->batch.edit_edges, &mbufcache->vbo.edit_data);
}
- MDEPS_ASSERT(batch.edit_vnor, ibo_points, vbo_pos_nor);
+ MDEPS_ASSERT(batch.edit_vnor, ibo.points, vbo.pos_nor);
if (DRW_batch_requested(cache->batch.edit_vnor, GPU_PRIM_POINTS)) {
DRW_ibo_request(cache->batch.edit_vnor, &mbufcache->ibo.points);
DRW_vbo_request(cache->batch.edit_vnor, &mbufcache->vbo.pos_nor);
}
- MDEPS_ASSERT(batch.edit_lnor, ibo_tris, vbo_pos_nor, vbo_lnor);
+ MDEPS_ASSERT(batch.edit_lnor, ibo.tris, vbo.pos_nor, vbo.lnor);
if (DRW_batch_requested(cache->batch.edit_lnor, GPU_PRIM_POINTS)) {
DRW_ibo_request(cache->batch.edit_lnor, &mbufcache->ibo.tris);
DRW_vbo_request(cache->batch.edit_lnor, &mbufcache->vbo.pos_nor);
DRW_vbo_request(cache->batch.edit_lnor, &mbufcache->vbo.lnor);
}
- MDEPS_ASSERT(batch.edit_fdots, ibo_fdots, vbo_fdots_pos, vbo_fdots_nor);
+ MDEPS_ASSERT(batch.edit_fdots, ibo.fdots, vbo.fdots_pos, vbo.fdots_nor);
if (DRW_batch_requested(cache->batch.edit_fdots, GPU_PRIM_POINTS)) {
DRW_ibo_request(cache->batch.edit_fdots, &mbufcache->ibo.fdots);
DRW_vbo_request(cache->batch.edit_fdots, &mbufcache->vbo.fdots_pos);
DRW_vbo_request(cache->batch.edit_fdots, &mbufcache->vbo.fdots_nor);
}
- MDEPS_ASSERT(batch.edit_skin_roots, vbo_skin_roots);
+ MDEPS_ASSERT(batch.edit_skin_roots, vbo.skin_roots);
if (DRW_batch_requested(cache->batch.edit_skin_roots, GPU_PRIM_POINTS)) {
DRW_vbo_request(cache->batch.edit_skin_roots, &mbufcache->vbo.skin_roots);
}
/* Selection */
- MDEPS_ASSERT(batch.edit_selection_verts, ibo_points, vbo_pos_nor, vbo_vert_idx);
+ MDEPS_ASSERT(batch.edit_selection_verts, ibo.points, vbo.pos_nor, vbo.vert_idx);
if (DRW_batch_requested(cache->batch.edit_selection_verts, GPU_PRIM_POINTS)) {
DRW_ibo_request(cache->batch.edit_selection_verts, &mbufcache->ibo.points);
DRW_vbo_request(cache->batch.edit_selection_verts, &mbufcache->vbo.pos_nor);
DRW_vbo_request(cache->batch.edit_selection_verts, &mbufcache->vbo.vert_idx);
}
- MDEPS_ASSERT(batch.edit_selection_edges, ibo_lines, vbo_pos_nor, vbo_edge_idx);
+ MDEPS_ASSERT(batch.edit_selection_edges, ibo.lines, vbo.pos_nor, vbo.edge_idx);
if (DRW_batch_requested(cache->batch.edit_selection_edges, GPU_PRIM_LINES)) {
DRW_ibo_request(cache->batch.edit_selection_edges, &mbufcache->ibo.lines);
DRW_vbo_request(cache->batch.edit_selection_edges, &mbufcache->vbo.pos_nor);
DRW_vbo_request(cache->batch.edit_selection_edges, &mbufcache->vbo.edge_idx);
}
- MDEPS_ASSERT(batch.edit_selection_faces, ibo_tris, vbo_pos_nor, vbo_poly_idx);
+ MDEPS_ASSERT(batch.edit_selection_faces, ibo.tris, vbo.pos_nor, vbo.poly_idx);
if (DRW_batch_requested(cache->batch.edit_selection_faces, GPU_PRIM_TRIS)) {
DRW_ibo_request(cache->batch.edit_selection_faces, &mbufcache->ibo.tris);
DRW_vbo_request(cache->batch.edit_selection_faces, &mbufcache->vbo.pos_nor);
DRW_vbo_request(cache->batch.edit_selection_faces, &mbufcache->vbo.poly_idx);
}
- MDEPS_ASSERT(batch.edit_selection_fdots, ibo_fdots, vbo_fdots_pos, vbo_fdot_idx);
+ MDEPS_ASSERT(batch.edit_selection_fdots, ibo.fdots, vbo.fdots_pos, vbo.fdot_idx);
if (DRW_batch_requested(cache->batch.edit_selection_fdots, GPU_PRIM_POINTS)) {
DRW_ibo_request(cache->batch.edit_selection_fdots, &mbufcache->ibo.fdots);
DRW_vbo_request(cache->batch.edit_selection_fdots, &mbufcache->vbo.fdots_pos);
@@ -1617,17 +1676,17 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
mbufcache = (do_uvcage) ? &cache->uv_cage : &cache->final;
/* Edit UV */
- MDEPS_ASSERT(batch.edituv_faces, ibo_edituv_tris, vbo_uv, vbo_edituv_data);
+ MDEPS_ASSERT(batch.edituv_faces, ibo.edituv_tris, vbo.uv, vbo.edituv_data);
if (DRW_batch_requested(cache->batch.edituv_faces, GPU_PRIM_TRIS)) {
DRW_ibo_request(cache->batch.edituv_faces, &mbufcache->ibo.edituv_tris);
DRW_vbo_request(cache->batch.edituv_faces, &mbufcache->vbo.uv);
DRW_vbo_request(cache->batch.edituv_faces, &mbufcache->vbo.edituv_data);
}
MDEPS_ASSERT(batch.edituv_faces_stretch_area,
- ibo_edituv_tris,
- vbo_uv,
- vbo_edituv_data,
- vbo_edituv_stretch_area);
+ ibo.edituv_tris,
+ vbo.uv,
+ vbo.edituv_data,
+ vbo.edituv_stretch_area);
if (DRW_batch_requested(cache->batch.edituv_faces_stretch_area, GPU_PRIM_TRIS)) {
DRW_ibo_request(cache->batch.edituv_faces_stretch_area, &mbufcache->ibo.edituv_tris);
DRW_vbo_request(cache->batch.edituv_faces_stretch_area, &mbufcache->vbo.uv);
@@ -1635,71 +1694,72 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
DRW_vbo_request(cache->batch.edituv_faces_stretch_area, &mbufcache->vbo.edituv_stretch_area);
}
MDEPS_ASSERT(batch.edituv_faces_stretch_angle,
- ibo_edituv_tris,
- vbo_uv,
- vbo_edituv_data,
- vbo_edituv_stretch_angle);
+ ibo.edituv_tris,
+ vbo.uv,
+ vbo.edituv_data,
+ vbo.edituv_stretch_angle);
if (DRW_batch_requested(cache->batch.edituv_faces_stretch_angle, GPU_PRIM_TRIS)) {
DRW_ibo_request(cache->batch.edituv_faces_stretch_angle, &mbufcache->ibo.edituv_tris);
DRW_vbo_request(cache->batch.edituv_faces_stretch_angle, &mbufcache->vbo.uv);
DRW_vbo_request(cache->batch.edituv_faces_stretch_angle, &mbufcache->vbo.edituv_data);
DRW_vbo_request(cache->batch.edituv_faces_stretch_angle, &mbufcache->vbo.edituv_stretch_angle);
}
- MDEPS_ASSERT(batch.edituv_edges, ibo_edituv_lines, vbo_uv, vbo_edituv_data);
+ MDEPS_ASSERT(batch.edituv_edges, ibo.edituv_lines, vbo.uv, vbo.edituv_data);
if (DRW_batch_requested(cache->batch.edituv_edges, GPU_PRIM_LINES)) {
DRW_ibo_request(cache->batch.edituv_edges, &mbufcache->ibo.edituv_lines);
DRW_vbo_request(cache->batch.edituv_edges, &mbufcache->vbo.uv);
DRW_vbo_request(cache->batch.edituv_edges, &mbufcache->vbo.edituv_data);
}
- MDEPS_ASSERT(batch.edituv_verts, ibo_edituv_points, vbo_uv, vbo_edituv_data);
+ MDEPS_ASSERT(batch.edituv_verts, ibo.edituv_points, vbo.uv, vbo.edituv_data);
if (DRW_batch_requested(cache->batch.edituv_verts, GPU_PRIM_POINTS)) {
DRW_ibo_request(cache->batch.edituv_verts, &mbufcache->ibo.edituv_points);
DRW_vbo_request(cache->batch.edituv_verts, &mbufcache->vbo.uv);
DRW_vbo_request(cache->batch.edituv_verts, &mbufcache->vbo.edituv_data);
}
- MDEPS_ASSERT(batch.edituv_fdots, ibo_edituv_fdots, vbo_fdots_uv, vbo_fdots_edituv_data);
+ MDEPS_ASSERT(batch.edituv_fdots, ibo.edituv_fdots, vbo.fdots_uv, vbo.fdots_edituv_data);
if (DRW_batch_requested(cache->batch.edituv_fdots, GPU_PRIM_POINTS)) {
DRW_ibo_request(cache->batch.edituv_fdots, &mbufcache->ibo.edituv_fdots);
DRW_vbo_request(cache->batch.edituv_fdots, &mbufcache->vbo.fdots_uv);
DRW_vbo_request(cache->batch.edituv_fdots, &mbufcache->vbo.fdots_edituv_data);
}
- MDEPS_ASSERT_MAP(vbo_lnor);
- MDEPS_ASSERT_MAP(vbo_pos_nor);
- MDEPS_ASSERT_MAP(vbo_uv);
- MDEPS_ASSERT_MAP(vbo_vcol);
- MDEPS_ASSERT_MAP(vbo_sculpt_data);
- MDEPS_ASSERT_MAP(vbo_weights);
- MDEPS_ASSERT_MAP(vbo_edge_fac);
- MDEPS_ASSERT_MAP(vbo_mesh_analysis);
- MDEPS_ASSERT_MAP(vbo_tan);
- MDEPS_ASSERT_MAP(vbo_orco);
- MDEPS_ASSERT_MAP(vbo_edit_data);
- MDEPS_ASSERT_MAP(vbo_fdots_pos);
- MDEPS_ASSERT_MAP(vbo_fdots_nor);
- MDEPS_ASSERT_MAP(vbo_skin_roots);
- MDEPS_ASSERT_MAP(vbo_vert_idx);
- MDEPS_ASSERT_MAP(vbo_edge_idx);
- MDEPS_ASSERT_MAP(vbo_poly_idx);
- MDEPS_ASSERT_MAP(vbo_fdot_idx);
- MDEPS_ASSERT_MAP(vbo_edituv_data);
- MDEPS_ASSERT_MAP(vbo_edituv_stretch_area);
- MDEPS_ASSERT_MAP(vbo_edituv_stretch_angle);
- MDEPS_ASSERT_MAP(vbo_fdots_uv);
- MDEPS_ASSERT_MAP(vbo_fdots_edituv_data);
-
- MDEPS_ASSERT_MAP(ibo_tris);
- MDEPS_ASSERT_MAP(ibo_lines);
- MDEPS_ASSERT_MAP(ibo_lines_loose);
- MDEPS_ASSERT_MAP(ibo_lines_adjacency);
- MDEPS_ASSERT_MAP(ibo_lines_paint_mask);
- MDEPS_ASSERT_MAP(ibo_tris_per_mat);
- MDEPS_ASSERT_MAP(ibo_points);
- MDEPS_ASSERT_MAP(ibo_fdots);
- MDEPS_ASSERT_MAP(ibo_edituv_tris);
- MDEPS_ASSERT_MAP(ibo_edituv_lines);
- MDEPS_ASSERT_MAP(ibo_edituv_points);
- MDEPS_ASSERT_MAP(ibo_edituv_fdots);
+ MDEPS_ASSERT_MAP(vbo.lnor);
+ MDEPS_ASSERT_MAP(vbo.pos_nor);
+ MDEPS_ASSERT_MAP(vbo.uv);
+ MDEPS_ASSERT_MAP(vbo.vcol);
+ MDEPS_ASSERT_MAP(vbo.sculpt_data);
+ MDEPS_ASSERT_MAP(vbo.weights);
+ MDEPS_ASSERT_MAP(vbo.edge_fac);
+ MDEPS_ASSERT_MAP(vbo.mesh_analysis);
+ MDEPS_ASSERT_MAP(vbo.tan);
+ MDEPS_ASSERT_MAP(vbo.orco);
+ MDEPS_ASSERT_MAP(vbo.edit_data);
+ MDEPS_ASSERT_MAP(vbo.fdots_pos);
+ MDEPS_ASSERT_MAP(vbo.fdots_nor);
+ MDEPS_ASSERT_MAP(vbo.skin_roots);
+ MDEPS_ASSERT_MAP(vbo.vert_idx);
+ MDEPS_ASSERT_MAP(vbo.edge_idx);
+ MDEPS_ASSERT_MAP(vbo.poly_idx);
+ MDEPS_ASSERT_MAP(vbo.fdot_idx);
+ MDEPS_ASSERT_MAP(vbo.edituv_data);
+ MDEPS_ASSERT_MAP(vbo.edituv_stretch_area);
+ MDEPS_ASSERT_MAP(vbo.edituv_stretch_angle);
+ MDEPS_ASSERT_MAP(vbo.fdots_uv);
+ MDEPS_ASSERT_MAP(vbo.fdots_edituv_data);
+
+ MDEPS_ASSERT_MAP(ibo.tris);
+ MDEPS_ASSERT_MAP(ibo.lines);
+ MDEPS_ASSERT_MAP(ibo.lines_loose);
+ MDEPS_ASSERT_MAP(ibo.lines_adjacency);
+ MDEPS_ASSERT_MAP(ibo.lines_paint_mask);
+ MDEPS_ASSERT_MAP(ibo.points);
+ MDEPS_ASSERT_MAP(ibo.fdots);
+ MDEPS_ASSERT_MAP(ibo.edituv_tris);
+ MDEPS_ASSERT_MAP(ibo.edituv_lines);
+ MDEPS_ASSERT_MAP(ibo.edituv_points);
+ MDEPS_ASSERT_MAP(ibo.edituv_fdots);
+
+ MDEPS_ASSERT_MAP(tris_per_mat);
/* Meh loose Scene const correctness here. */
const bool use_subsurf_fdots = scene ? BKE_modifiers_uses_subsurf_facedots(scene, ob) : false;
diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
index 6e3a73a8314..7e6e1f03f8a 100644
--- a/source/blender/draw/intern/draw_common.h
+++ b/source/blender/draw/intern/draw_common.h
@@ -142,8 +142,8 @@ typedef struct GlobalsUboStorage {
float colorUVShadow[4];
/* NOTE! Put all color before UBO_LAST_COLOR */
- float screenVecs[2][4]; /* padded as vec4 */
- float sizeViewport[2], sizeViewportInv[2]; /* packed as vec4 in glsl */
+ float screenVecs[2][4]; /* Padded as vec4. */
+ float sizeViewport[2], sizeViewportInv[2]; /* Packed as vec4 in GLSL. */
/* Pack individual float at the end of the buffer to avoid alignment errors */
float sizePixel, pixelFac;
@@ -190,7 +190,7 @@ void DRW_hair_free(void);
/* draw_fluid.c */
-/* Fluid simulation. */
+/* Fluid simulation. */
void DRW_smoke_ensure(struct FluidModifierData *fmd, int highres);
void DRW_smoke_ensure_coba_field(struct FluidModifierData *fmd);
void DRW_smoke_ensure_velocity(struct FluidModifierData *fmd);
@@ -206,7 +206,7 @@ struct DRW_Global {
* Add needed theme colors / values to DRW_globals_update() and update UBO
* Not needed for constant color. */
GlobalsUboStorage block;
- /** Define "globalsBlock" uniform for 'block'. */
+ /** Define "globalsBlock" uniform for 'block'. */
struct GPUUniformBuf *block_ubo;
struct GPUTexture *ramp;
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 8a805409b27..db64c7deb63 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1776,7 +1776,7 @@ static void DRW_render_gpencil_to_image(RenderEngine *engine,
void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph)
{
- /* This function should only be called if there are are grease pencil objects,
+ /* This function should only be called if there are grease pencil objects,
* especially important to avoid failing in background renders without OpenGL context. */
BLI_assert(DRW_render_check_grease_pencil(depsgraph));
@@ -2090,7 +2090,7 @@ void DRW_draw_render_loop_2d_ex(struct Depsgraph *depsgraph,
drw_viewport_colormanagement_set();
/* TODO(jbakker): Only populate when editor needs to draw object.
- * for the image editor this is when showing UV's.*/
+ * for the image editor this is when showing UV's. */
const bool do_populate_loop = (DST.draw_ctx.space_data->spacetype == SPACE_IMAGE);
const bool do_annotations = drw_draw_show_annotation();
const bool do_draw_gizmos = (DST.draw_ctx.space_data->spacetype != SPACE_IMAGE);
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index d4e22c83798..373b51a67e0 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -172,9 +172,9 @@ typedef struct DRWObjectInfos {
float orcotexfac[2][4];
float ob_color[4];
float ob_index;
- float pad; /* UNUSED*/
+ float pad; /*UNUSED*/
float ob_random;
- float ob_flag; /* sign is negative scaling, */
+ float ob_flag; /* Sign is negative scaling. */
} DRWObjectInfos;
BLI_STATIC_ASSERT_ALIGN(DRWObjectMatrix, 16)
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 56909969dd7..5eedca4507e 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -2117,8 +2117,8 @@ void DRW_pass_sort_shgroup_z(DRWPass *pass)
}
}
}
- /* To be sorted a shgroup needs to have at least one draw command. */
- /* FIXME(fclem) In some case, we can still have empty shading group to sort. However their
+ /* To be sorted a shgroup needs to have at least one draw command. */
+ /* FIXME(fclem): In some case, we can still have empty shading group to sort. However their
* final order is not well defined.
* (see T76730 & D7729). */
// BLI_assert(handle != 0);
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc
index 35b60002c1f..43ad28c2618 100644
--- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc
@@ -153,7 +153,7 @@ static void extract_lines_adjacency_finish(const MeshRenderData *UNUSED(mr),
if (v_data != NO_EDGE) {
BLI_edgehashIterator_getKey(ehi, &v2, &v3);
l1 = (uint)abs(v_data) - 1;
- if (v_data < 0) { /* inv_opposite */
+ if (v_data < 0) { /* `inv_opposite`. */
SWAP(uint, v2, v3);
}
l2 = data->vert_to_loop[v2];
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc
new file mode 100644
index 00000000000..1bc4c7e330f
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc
@@ -0,0 +1,241 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "GPU_capabilities.h"
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Edge Factor
+ * Defines how much an edge is visible.
+ * \{ */
+
+struct MeshExtract_EdgeFac_Data {
+ uchar *vbo_data;
+ bool use_edge_render;
+ /* Number of loop per edge. */
+ uchar *edge_loop_count;
+};
+
+static float loop_edge_factor_get(const float f_no[3],
+ const float v_co[3],
+ const float v_no[3],
+ const float v_next_co[3])
+{
+ float enor[3], evec[3];
+ sub_v3_v3v3(evec, v_next_co, v_co);
+ cross_v3_v3v3(enor, v_no, evec);
+ normalize_v3(enor);
+ float d = fabsf(dot_v3v3(enor, f_no));
+ /* Re-scale to the slider range. */
+ d *= (1.0f / 0.065f);
+ CLAMP(d, 0.0f, 1.0f);
+ return d;
+}
+
+static void extract_edge_fac_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "wd", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
+
+ MeshExtract_EdgeFac_Data *data = static_cast<MeshExtract_EdgeFac_Data *>(tls_data);
+
+ if (mr->extract_type == MR_EXTRACT_MESH) {
+ data->edge_loop_count = static_cast<uchar *>(
+ MEM_callocN(sizeof(uint32_t) * mr->edge_len, __func__));
+
+ /* HACK(fclem) Detecting the need for edge render.
+ * We could have a flag in the mesh instead or check the modifier stack. */
+ const MEdge *med = mr->medge;
+ for (int e_index = 0; e_index < mr->edge_len; e_index++, med++) {
+ if ((med->flag & ME_EDGERENDER) == 0) {
+ data->use_edge_render = true;
+ break;
+ }
+ }
+ }
+ else {
+ /* HACK to bypass non-manifold check in mesh_edge_fac_finish(). */
+ data->use_edge_render = true;
+ }
+
+ data->vbo_data = static_cast<uchar *>(GPU_vertbuf_get_data(vbo));
+}
+
+static void extract_edge_fac_iter_poly_bm(const MeshRenderData *mr,
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *_data)
+{
+ MeshExtract_EdgeFac_Data *data = static_cast<MeshExtract_EdgeFac_Data *>(_data);
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+
+ if (BM_edge_is_manifold(l_iter->e)) {
+ float ratio = loop_edge_factor_get(bm_face_no_get(mr, f),
+ bm_vert_co_get(mr, l_iter->v),
+ bm_vert_no_get(mr, l_iter->v),
+ bm_vert_co_get(mr, l_iter->next->v));
+ data->vbo_data[l_index] = ratio * 253 + 1;
+ }
+ else {
+ data->vbo_data[l_index] = 255;
+ }
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_edge_fac_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int mp_index,
+ void *_data)
+{
+ MeshExtract_EdgeFac_Data *data = static_cast<MeshExtract_EdgeFac_Data *>(_data);
+
+ const MLoop *mloop = mr->mloop;
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+
+ if (data->use_edge_render) {
+ const MEdge *med = &mr->medge[ml->e];
+ data->vbo_data[ml_index] = (med->flag & ME_EDGERENDER) ? 255 : 0;
+ }
+ else {
+
+ /* Count loop per edge to detect non-manifold. */
+ if (data->edge_loop_count[ml->e] < 3) {
+ data->edge_loop_count[ml->e]++;
+ }
+ if (data->edge_loop_count[ml->e] == 2) {
+ /* Manifold */
+ const int ml_index_last = mp->totloop + mp->loopstart - 1;
+ const int ml_index_other = (ml_index == ml_index_last) ? mp->loopstart : (ml_index + 1);
+ const MLoop *ml_next = &mr->mloop[ml_index_other];
+ const MVert *v1 = &mr->mvert[ml->v];
+ const MVert *v2 = &mr->mvert[ml_next->v];
+ float vnor_f[3];
+ normal_short_to_float_v3(vnor_f, v1->no);
+ float ratio = loop_edge_factor_get(mr->poly_normals[mp_index], v1->co, vnor_f, v2->co);
+ data->vbo_data[ml_index] = ratio * 253 + 1;
+ }
+ else {
+ /* Non-manifold */
+ data->vbo_data[ml_index] = 255;
+ }
+ }
+ }
+}
+
+static void extract_edge_fac_iter_ledge_bm(const MeshRenderData *mr,
+ const BMEdge *UNUSED(eed),
+ const int ledge_index,
+ void *_data)
+{
+ MeshExtract_EdgeFac_Data *data = static_cast<MeshExtract_EdgeFac_Data *>(_data);
+ data->vbo_data[mr->loop_len + (ledge_index * 2) + 0] = 255;
+ data->vbo_data[mr->loop_len + (ledge_index * 2) + 1] = 255;
+}
+
+static void extract_edge_fac_iter_ledge_mesh(const MeshRenderData *mr,
+ const MEdge *UNUSED(med),
+ const int ledge_index,
+ void *_data)
+{
+ MeshExtract_EdgeFac_Data *data = static_cast<MeshExtract_EdgeFac_Data *>(_data);
+
+ data->vbo_data[mr->loop_len + ledge_index * 2 + 0] = 255;
+ data->vbo_data[mr->loop_len + ledge_index * 2 + 1] = 255;
+}
+
+static void extract_edge_fac_finish(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ MeshExtract_EdgeFac_Data *data = static_cast<MeshExtract_EdgeFac_Data *>(_data);
+
+ if (GPU_crappy_amd_driver()) {
+ /* Some AMD drivers strangely crash with VBO's with a one byte format.
+ * To workaround we reinitialize the VBO with another format and convert
+ * all bytes to floats. */
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "wd", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ }
+ /* We keep the data reference in data->vbo_data. */
+ data->vbo_data = static_cast<uchar *>(GPU_vertbuf_steal_data(vbo));
+ GPU_vertbuf_clear(vbo);
+
+ int buf_len = mr->loop_len + mr->loop_loose_len;
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, buf_len);
+
+ float *fdata = (float *)GPU_vertbuf_get_data(vbo);
+ for (int ml_index = 0; ml_index < buf_len; ml_index++, fdata++) {
+ *fdata = data->vbo_data[ml_index] / 255.0f;
+ }
+ /* Free old byte data. */
+ MEM_freeN(data->vbo_data);
+ }
+ MEM_SAFE_FREE(data->edge_loop_count);
+}
+
+constexpr MeshExtract create_extractor_edge_fac()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_edge_fac_init;
+ extractor.iter_poly_bm = extract_edge_fac_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_edge_fac_iter_poly_mesh;
+ extractor.iter_ledge_bm = extract_edge_fac_iter_ledge_bm;
+ extractor.iter_ledge_mesh = extract_edge_fac_iter_ledge_mesh;
+ extractor.finish = extract_edge_fac_finish;
+ extractor.data_type = MR_DATA_POLY_NOR;
+ extractor.data_size = sizeof(MeshExtract_EdgeFac_Data);
+ extractor.use_threading = false;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.edge_fac);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_edge_fac = blender::draw::create_extractor_edge_fac();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc
new file mode 100644
index 00000000000..ff250a30ec4
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc
@@ -0,0 +1,265 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "draw_cache_extract_mesh_private.h"
+#include "draw_cache_impl.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Edit Mode Data / Flags
+ * \{ */
+
+static void mesh_render_data_edge_flag(const MeshRenderData *mr,
+ const BMEdge *eed,
+ EditLoopData *eattr)
+{
+ const ToolSettings *ts = mr->toolsettings;
+ const bool is_vertex_select_mode = (ts != nullptr) && (ts->selectmode & SCE_SELECT_VERTEX) != 0;
+ const bool is_face_only_select_mode = (ts != nullptr) && (ts->selectmode == SCE_SELECT_FACE);
+
+ if (eed == mr->eed_act) {
+ eattr->e_flag |= VFLAG_EDGE_ACTIVE;
+ }
+ if (!is_vertex_select_mode && BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
+ eattr->e_flag |= VFLAG_EDGE_SELECTED;
+ }
+ if (is_vertex_select_mode && BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) &&
+ BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) {
+ eattr->e_flag |= VFLAG_EDGE_SELECTED;
+ eattr->e_flag |= VFLAG_VERT_SELECTED;
+ }
+ if (BM_elem_flag_test(eed, BM_ELEM_SEAM)) {
+ eattr->e_flag |= VFLAG_EDGE_SEAM;
+ }
+ if (!BM_elem_flag_test(eed, BM_ELEM_SMOOTH)) {
+ eattr->e_flag |= VFLAG_EDGE_SHARP;
+ }
+
+ /* Use active edge color for active face edges because
+ * specular highlights make it hard to see T55456#510873.
+ *
+ * This isn't ideal since it can't be used when mixing edge/face modes
+ * but it's still better than not being able to see the active face. */
+ if (is_face_only_select_mode) {
+ if (mr->efa_act != nullptr) {
+ if (BM_edge_in_face(eed, mr->efa_act)) {
+ eattr->e_flag |= VFLAG_EDGE_ACTIVE;
+ }
+ }
+ }
+
+ /* Use a byte for value range */
+ if (mr->crease_ofs != -1) {
+ float crease = BM_ELEM_CD_GET_FLOAT(eed, mr->crease_ofs);
+ if (crease > 0) {
+ eattr->crease = (uchar)(crease * 255.0f);
+ }
+ }
+ /* Use a byte for value range */
+ if (mr->bweight_ofs != -1) {
+ float bweight = BM_ELEM_CD_GET_FLOAT(eed, mr->bweight_ofs);
+ if (bweight > 0) {
+ eattr->bweight = (uchar)(bweight * 255.0f);
+ }
+ }
+#ifdef WITH_FREESTYLE
+ if (mr->freestyle_edge_ofs != -1) {
+ const FreestyleEdge *fed = (const FreestyleEdge *)BM_ELEM_CD_GET_VOID_P(
+ eed, mr->freestyle_edge_ofs);
+ if (fed->flag & FREESTYLE_EDGE_MARK) {
+ eattr->e_flag |= VFLAG_EDGE_FREESTYLE;
+ }
+ }
+#endif
+}
+
+static void mesh_render_data_vert_flag(const MeshRenderData *mr,
+ const BMVert *eve,
+ EditLoopData *eattr)
+{
+ if (eve == mr->eve_act) {
+ eattr->e_flag |= VFLAG_VERT_ACTIVE;
+ }
+ if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
+ eattr->e_flag |= VFLAG_VERT_SELECTED;
+ }
+}
+
+static void extract_edit_data_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ /* WARNING: Adjust #EditLoopData struct accordingly. */
+ GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 4, GPU_FETCH_INT);
+ GPU_vertformat_alias_add(&format, "flag");
+ }
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
+ EditLoopData *vbo_data = (EditLoopData *)GPU_vertbuf_get_data(vbo);
+ *(EditLoopData **)tls_data = vbo_data;
+}
+
+static void extract_edit_data_iter_poly_bm(const MeshRenderData *mr,
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *_data)
+{
+ EditLoopData *vbo_data = *(EditLoopData **)_data;
+
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+
+ EditLoopData *data = vbo_data + l_index;
+ memset(data, 0x0, sizeof(*data));
+ mesh_render_data_face_flag(mr, f, -1, data);
+ mesh_render_data_edge_flag(mr, l_iter->e, data);
+ mesh_render_data_vert_flag(mr, l_iter->v, data);
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_edit_data_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int mp_index,
+ void *_data)
+{
+ EditLoopData *vbo_data = *(EditLoopData **)_data;
+
+ const MLoop *mloop = mr->mloop;
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+ EditLoopData *data = vbo_data + ml_index;
+ memset(data, 0x0, sizeof(*data));
+ BMFace *efa = bm_original_face_get(mr, mp_index);
+ BMEdge *eed = bm_original_edge_get(mr, ml->e);
+ BMVert *eve = bm_original_vert_get(mr, ml->v);
+ if (efa) {
+ mesh_render_data_face_flag(mr, efa, -1, data);
+ }
+ if (eed) {
+ mesh_render_data_edge_flag(mr, eed, data);
+ }
+ if (eve) {
+ mesh_render_data_vert_flag(mr, eve, data);
+ }
+ }
+}
+
+static void extract_edit_data_iter_ledge_bm(const MeshRenderData *mr,
+ const BMEdge *eed,
+ const int ledge_index,
+ void *_data)
+{
+ EditLoopData *vbo_data = *(EditLoopData **)_data;
+ EditLoopData *data = vbo_data + mr->loop_len + (ledge_index * 2);
+ memset(data, 0x0, sizeof(*data) * 2);
+ mesh_render_data_edge_flag(mr, eed, &data[0]);
+ data[1] = data[0];
+ mesh_render_data_vert_flag(mr, eed->v1, &data[0]);
+ mesh_render_data_vert_flag(mr, eed->v2, &data[1]);
+}
+
+static void extract_edit_data_iter_ledge_mesh(const MeshRenderData *mr,
+ const MEdge *med,
+ const int ledge_index,
+ void *_data)
+{
+ EditLoopData *vbo_data = *(EditLoopData **)_data;
+ EditLoopData *data = vbo_data + mr->loop_len + ledge_index * 2;
+ memset(data, 0x0, sizeof(*data) * 2);
+ const int e_index = mr->ledges[ledge_index];
+ BMEdge *eed = bm_original_edge_get(mr, e_index);
+ BMVert *eve1 = bm_original_vert_get(mr, med->v1);
+ BMVert *eve2 = bm_original_vert_get(mr, med->v2);
+ if (eed) {
+ mesh_render_data_edge_flag(mr, eed, &data[0]);
+ data[1] = data[0];
+ }
+ if (eve1) {
+ mesh_render_data_vert_flag(mr, eve1, &data[0]);
+ }
+ if (eve2) {
+ mesh_render_data_vert_flag(mr, eve2, &data[1]);
+ }
+}
+
+static void extract_edit_data_iter_lvert_bm(const MeshRenderData *mr,
+ const BMVert *eve,
+ const int lvert_index,
+ void *_data)
+{
+ EditLoopData *vbo_data = *(EditLoopData **)_data;
+ const int offset = mr->loop_len + (mr->edge_loose_len * 2);
+ EditLoopData *data = vbo_data + offset + lvert_index;
+ memset(data, 0x0, sizeof(*data));
+ mesh_render_data_vert_flag(mr, eve, data);
+}
+
+static void extract_edit_data_iter_lvert_mesh(const MeshRenderData *mr,
+ const MVert *UNUSED(mv),
+ const int lvert_index,
+ void *_data)
+{
+ EditLoopData *vbo_data = *(EditLoopData **)_data;
+ const int offset = mr->loop_len + (mr->edge_loose_len * 2);
+
+ EditLoopData *data = vbo_data + offset + lvert_index;
+ memset(data, 0x0, sizeof(*data));
+ const int v_index = mr->lverts[lvert_index];
+ BMVert *eve = bm_original_vert_get(mr, v_index);
+ if (eve) {
+ mesh_render_data_vert_flag(mr, eve, data);
+ }
+}
+
+constexpr MeshExtract create_extractor_edit_data()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_edit_data_init;
+ extractor.iter_poly_bm = extract_edit_data_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_edit_data_iter_poly_mesh;
+ extractor.iter_ledge_bm = extract_edit_data_iter_ledge_bm;
+ extractor.iter_ledge_mesh = extract_edit_data_iter_ledge_mesh;
+ extractor.iter_lvert_bm = extract_edit_data_iter_lvert_bm;
+ extractor.iter_lvert_mesh = extract_edit_data_iter_lvert_mesh;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(EditLoopData *);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.edit_data);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_edit_data = blender::draw::create_extractor_edit_data();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc
new file mode 100644
index 00000000000..aa58266d56b
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc
@@ -0,0 +1,140 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "draw_cache_extract_mesh_private.h"
+#include "draw_cache_impl.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Edit UV Data / Flags
+ * \{ */
+
+struct MeshExtract_EditUVData_Data {
+ EditLoopData *vbo_data;
+ int cd_ofs;
+};
+
+static void extract_edituv_data_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ /* WARNING: Adjust #EditLoopData struct accordingly. */
+ GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 4, GPU_FETCH_INT);
+ GPU_vertformat_alias_add(&format, "flag");
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len);
+
+ CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
+
+ MeshExtract_EditUVData_Data *data = static_cast<MeshExtract_EditUVData_Data *>(tls_data);
+ data->vbo_data = (EditLoopData *)GPU_vertbuf_get_data(vbo);
+ data->cd_ofs = CustomData_get_offset(cd_ldata, CD_MLOOPUV);
+}
+
+static void extract_edituv_data_iter_poly_bm(const MeshRenderData *mr,
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *_data)
+{
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+ MeshExtract_EditUVData_Data *data = static_cast<MeshExtract_EditUVData_Data *>(_data);
+ EditLoopData *eldata = &data->vbo_data[l_index];
+ memset(eldata, 0x0, sizeof(*eldata));
+ mesh_render_data_loop_flag(mr, l_iter, data->cd_ofs, eldata);
+ mesh_render_data_face_flag(mr, f, data->cd_ofs, eldata);
+ mesh_render_data_loop_edge_flag(mr, l_iter, data->cd_ofs, eldata);
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_edituv_data_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int mp_index,
+ void *_data)
+{
+ MeshExtract_EditUVData_Data *data = static_cast<MeshExtract_EditUVData_Data *>(_data);
+ const MLoop *mloop = mr->mloop;
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+
+ EditLoopData *eldata = &data->vbo_data[ml_index];
+ memset(eldata, 0x0, sizeof(*eldata));
+ BMFace *efa = bm_original_face_get(mr, mp_index);
+ if (efa) {
+ BMEdge *eed = bm_original_edge_get(mr, ml->e);
+ BMVert *eve = bm_original_vert_get(mr, ml->v);
+ if (eed && eve) {
+ /* Loop on an edge endpoint. */
+ BMLoop *l = BM_face_edge_share_loop(efa, eed);
+ mesh_render_data_loop_flag(mr, l, data->cd_ofs, eldata);
+ mesh_render_data_loop_edge_flag(mr, l, data->cd_ofs, eldata);
+ }
+ else {
+ if (eed == nullptr) {
+ /* Find if the loop's vert is not part of an edit edge.
+ * For this, we check if the previous loop was on an edge. */
+ const int ml_index_last = mp->loopstart + mp->totloop - 1;
+ const int l_prev = (ml_index == mp->loopstart) ? ml_index_last : (ml_index - 1);
+ const MLoop *ml_prev = &mr->mloop[l_prev];
+ eed = bm_original_edge_get(mr, ml_prev->e);
+ }
+ if (eed) {
+ /* Mapped points on an edge between two edit verts. */
+ BMLoop *l = BM_face_edge_share_loop(efa, eed);
+ mesh_render_data_loop_edge_flag(mr, l, data->cd_ofs, eldata);
+ }
+ }
+ }
+ }
+}
+
+constexpr MeshExtract create_extractor_edituv_data()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_edituv_data_init;
+ extractor.iter_poly_bm = extract_edituv_data_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_edituv_data_iter_poly_mesh;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(MeshExtract_EditUVData_Data);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.edituv_data);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_edituv_data = blender::draw::create_extractor_edituv_data();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
new file mode 100644
index 00000000000..1d62637d172
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
@@ -0,0 +1,236 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_mesh.h"
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Edit UV angle stretch
+ * \{ */
+
+struct UVStretchAngle {
+ int16_t angle;
+ int16_t uv_angles[2];
+};
+
+struct MeshExtract_StretchAngle_Data {
+ UVStretchAngle *vbo_data;
+ MLoopUV *luv;
+ float auv[2][2], last_auv[2];
+ float av[2][3], last_av[3];
+ int cd_ofs;
+};
+
+static void compute_normalize_edge_vectors(float auv[2][2],
+ float av[2][3],
+ const float uv[2],
+ const float uv_prev[2],
+ const float co[3],
+ const float co_prev[3])
+{
+ /* Move previous edge. */
+ copy_v2_v2(auv[0], auv[1]);
+ copy_v3_v3(av[0], av[1]);
+ /* 2d edge */
+ sub_v2_v2v2(auv[1], uv_prev, uv);
+ normalize_v2(auv[1]);
+ /* 3d edge */
+ sub_v3_v3v3(av[1], co_prev, co);
+ normalize_v3(av[1]);
+}
+
+static short v2_to_short_angle(const float v[2])
+{
+ return atan2f(v[1], v[0]) * (float)M_1_PI * SHRT_MAX;
+}
+
+static void edituv_get_edituv_stretch_angle(float auv[2][2],
+ const float av[2][3],
+ UVStretchAngle *r_stretch)
+{
+ /* Send UV's to the shader and let it compute the aspect corrected angle. */
+ r_stretch->uv_angles[0] = v2_to_short_angle(auv[0]);
+ r_stretch->uv_angles[1] = v2_to_short_angle(auv[1]);
+ /* Compute 3D angle here. */
+ r_stretch->angle = angle_normalized_v3v3(av[0], av[1]) * (float)M_1_PI * SHRT_MAX;
+
+#if 0 /* here for reference, this is done in shader now. */
+ float uvang = angle_normalized_v2v2(auv0, auv1);
+ float ang = angle_normalized_v3v3(av0, av1);
+ float stretch = fabsf(uvang - ang) / (float)M_PI;
+ return 1.0f - pow2f(1.0f - stretch);
+#endif
+}
+
+static void extract_edituv_stretch_angle_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ /* Waning: adjust #UVStretchAngle struct accordingly. */
+ GPU_vertformat_attr_add(&format, "angle", GPU_COMP_I16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ GPU_vertformat_attr_add(&format, "uv_angles", GPU_COMP_I16, 2, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len);
+
+ MeshExtract_StretchAngle_Data *data = static_cast<MeshExtract_StretchAngle_Data *>(tls_data);
+ data->vbo_data = (UVStretchAngle *)GPU_vertbuf_get_data(vbo);
+
+ /* Special iterator needed to save about half of the computing cost. */
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ data->cd_ofs = CustomData_get_offset(&mr->bm->ldata, CD_MLOOPUV);
+ }
+ else {
+ BLI_assert(ELEM(mr->extract_type, MR_EXTRACT_MAPPED, MR_EXTRACT_MESH));
+ data->luv = (MLoopUV *)CustomData_get_layer(&mr->me->ldata, CD_MLOOPUV);
+ }
+}
+
+static void extract_edituv_stretch_angle_iter_poly_bm(const MeshRenderData *mr,
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *_data)
+{
+ MeshExtract_StretchAngle_Data *data = static_cast<MeshExtract_StretchAngle_Data *>(_data);
+ float(*auv)[2] = data->auv, *last_auv = data->last_auv;
+ float(*av)[3] = data->av, *last_av = data->last_av;
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+
+ const MLoopUV *luv, *luv_next;
+ BMLoop *l_next = l_iter->next;
+ if (l_iter == BM_FACE_FIRST_LOOP(f)) {
+ /* First loop in face. */
+ BMLoop *l_tmp = l_iter->prev;
+ BMLoop *l_next_tmp = l_iter;
+ luv = (const MLoopUV *)BM_ELEM_CD_GET_VOID_P(l_tmp, data->cd_ofs);
+ luv_next = (const MLoopUV *)BM_ELEM_CD_GET_VOID_P(l_next_tmp, data->cd_ofs);
+ compute_normalize_edge_vectors(auv,
+ av,
+ luv->uv,
+ luv_next->uv,
+ bm_vert_co_get(mr, l_tmp->v),
+ bm_vert_co_get(mr, l_next_tmp->v));
+ /* Save last edge. */
+ copy_v2_v2(last_auv, auv[1]);
+ copy_v3_v3(last_av, av[1]);
+ }
+ if (l_next == BM_FACE_FIRST_LOOP(f)) {
+ /* Move previous edge. */
+ copy_v2_v2(auv[0], auv[1]);
+ copy_v3_v3(av[0], av[1]);
+ /* Copy already calculated last edge. */
+ copy_v2_v2(auv[1], last_auv);
+ copy_v3_v3(av[1], last_av);
+ }
+ else {
+ luv = (const MLoopUV *)BM_ELEM_CD_GET_VOID_P(l_iter, data->cd_ofs);
+ luv_next = (const MLoopUV *)BM_ELEM_CD_GET_VOID_P(l_next, data->cd_ofs);
+ compute_normalize_edge_vectors(auv,
+ av,
+ luv->uv,
+ luv_next->uv,
+ bm_vert_co_get(mr, l_iter->v),
+ bm_vert_co_get(mr, l_next->v));
+ }
+ edituv_get_edituv_stretch_angle(auv, av, &data->vbo_data[l_index]);
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_edituv_stretch_angle_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int UNUSED(mp_index),
+ void *_data)
+{
+ MeshExtract_StretchAngle_Data *data = static_cast<MeshExtract_StretchAngle_Data *>(_data);
+
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ float(*auv)[2] = data->auv, *last_auv = data->last_auv;
+ float(*av)[3] = data->av, *last_av = data->last_av;
+ int l_next = ml_index + 1;
+ const MVert *v, *v_next;
+ if (ml_index == mp->loopstart) {
+ /* First loop in face. */
+ const int ml_index_last = ml_index_end - 1;
+ const int l_next_tmp = mp->loopstart;
+ v = &mr->mvert[mr->mloop[ml_index_last].v];
+ v_next = &mr->mvert[mr->mloop[l_next_tmp].v];
+ compute_normalize_edge_vectors(
+ auv, av, data->luv[ml_index_last].uv, data->luv[l_next_tmp].uv, v->co, v_next->co);
+ /* Save last edge. */
+ copy_v2_v2(last_auv, auv[1]);
+ copy_v3_v3(last_av, av[1]);
+ }
+ if (l_next == ml_index_end) {
+ l_next = mp->loopstart;
+ /* Move previous edge. */
+ copy_v2_v2(auv[0], auv[1]);
+ copy_v3_v3(av[0], av[1]);
+ /* Copy already calculated last edge. */
+ copy_v2_v2(auv[1], last_auv);
+ copy_v3_v3(av[1], last_av);
+ }
+ else {
+ v = &mr->mvert[mr->mloop[ml_index].v];
+ v_next = &mr->mvert[mr->mloop[l_next].v];
+ compute_normalize_edge_vectors(
+ auv, av, data->luv[ml_index].uv, data->luv[l_next].uv, v->co, v_next->co);
+ }
+ edituv_get_edituv_stretch_angle(auv, av, &data->vbo_data[ml_index]);
+ }
+}
+
+constexpr MeshExtract create_extractor_edituv_edituv_stretch_angle()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_edituv_stretch_angle_init;
+ extractor.iter_poly_bm = extract_edituv_stretch_angle_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_edituv_stretch_angle_iter_poly_mesh;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(MeshExtract_StretchAngle_Data);
+ extractor.use_threading = false;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.edituv_stretch_angle);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_edituv_stretch_angle =
+ blender::draw::create_extractor_edituv_edituv_stretch_angle();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc
new file mode 100644
index 00000000000..16814653408
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc
@@ -0,0 +1,157 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_mesh.h"
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Edit UV area stretch
+ * \{ */
+
+static void extract_edituv_stretch_area_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *UNUSED(tls_data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "ratio", GPU_COMP_I16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len);
+}
+
+BLI_INLINE float area_ratio_get(float area, float uvarea)
+{
+ if (area >= FLT_EPSILON && uvarea >= FLT_EPSILON) {
+ /* Tag inversion by using the sign. */
+ return (area > uvarea) ? (uvarea / area) : -(area / uvarea);
+ }
+ return 0.0f;
+}
+
+BLI_INLINE float area_ratio_to_stretch(float ratio, float tot_ratio, float inv_tot_ratio)
+{
+ ratio *= (ratio > 0.0f) ? tot_ratio : -inv_tot_ratio;
+ return (ratio > 1.0f) ? (1.0f / ratio) : ratio;
+}
+
+static void extract_edituv_stretch_area_finish(const MeshRenderData *mr,
+ struct MeshBatchCache *cache,
+ void *buf,
+ void *UNUSED(data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ float tot_area = 0.0f, tot_uv_area = 0.0f;
+ float *area_ratio = static_cast<float *>(MEM_mallocN(sizeof(float) * mr->poly_len, __func__));
+
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ CustomData *cd_ldata = &mr->bm->ldata;
+ int uv_ofs = CustomData_get_offset(cd_ldata, CD_MLOOPUV);
+
+ BMFace *efa;
+ BMIter f_iter;
+ int f;
+ BM_ITER_MESH_INDEX (efa, &f_iter, mr->bm, BM_FACES_OF_MESH, f) {
+ float area = BM_face_calc_area(efa);
+ float uvarea = BM_face_calc_area_uv(efa, uv_ofs);
+ tot_area += area;
+ tot_uv_area += uvarea;
+ area_ratio[f] = area_ratio_get(area, uvarea);
+ }
+ }
+ else {
+ BLI_assert(ELEM(mr->extract_type, MR_EXTRACT_MAPPED, MR_EXTRACT_MESH));
+ const MLoopUV *uv_data = (const MLoopUV *)CustomData_get_layer(&mr->me->ldata, CD_MLOOPUV);
+ const MPoly *mp = mr->mpoly;
+ for (int mp_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
+ float area = BKE_mesh_calc_poly_area(mp, &mr->mloop[mp->loopstart], mr->mvert);
+ float uvarea = BKE_mesh_calc_poly_uv_area(mp, uv_data);
+ tot_area += area;
+ tot_uv_area += uvarea;
+ area_ratio[mp_index] = area_ratio_get(area, uvarea);
+ }
+ }
+
+ cache->tot_area = tot_area;
+ cache->tot_uv_area = tot_uv_area;
+
+ /* Convert in place to avoid an extra allocation */
+ uint16_t *poly_stretch = (uint16_t *)area_ratio;
+ for (int mp_index = 0; mp_index < mr->poly_len; mp_index++) {
+ poly_stretch[mp_index] = area_ratio[mp_index] * SHRT_MAX;
+ }
+
+ /* Copy face data for each loop. */
+ uint16_t *loop_stretch = (uint16_t *)GPU_vertbuf_get_data(vbo);
+
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ BMFace *efa;
+ BMIter f_iter;
+ int f, l_index = 0;
+ BM_ITER_MESH_INDEX (efa, &f_iter, mr->bm, BM_FACES_OF_MESH, f) {
+ for (int i = 0; i < efa->len; i++, l_index++) {
+ loop_stretch[l_index] = poly_stretch[f];
+ }
+ }
+ }
+ else {
+ BLI_assert(ELEM(mr->extract_type, MR_EXTRACT_MAPPED, MR_EXTRACT_MESH));
+ const MPoly *mp = mr->mpoly;
+ for (int mp_index = 0, l_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
+ for (int i = 0; i < mp->totloop; i++, l_index++) {
+ loop_stretch[l_index] = poly_stretch[mp_index];
+ }
+ }
+ }
+
+ MEM_freeN(area_ratio);
+}
+
+constexpr MeshExtract create_extractor_edituv_stretch_area()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_edituv_stretch_area_init;
+ extractor.finish = extract_edituv_stretch_area_finish;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = 0;
+ extractor.use_threading = false;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.edituv_stretch_area);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_edituv_stretch_area =
+ blender::draw::create_extractor_edituv_stretch_area();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_edituv_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_edituv_data.cc
new file mode 100644
index 00000000000..5a988c73a7e
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_edituv_data.cc
@@ -0,0 +1,101 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "draw_cache_extract_mesh_private.h"
+#include "draw_cache_impl.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Face-dots Edit UV flag
+ * \{ */
+
+struct MeshExtract_EditUVFdotData_Data {
+ EditLoopData *vbo_data;
+ int cd_ofs;
+};
+
+static void extract_fdots_edituv_data_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "flag", GPU_COMP_U8, 4, GPU_FETCH_INT);
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->poly_len);
+
+ MeshExtract_EditUVFdotData_Data *data = static_cast<MeshExtract_EditUVFdotData_Data *>(tls_data);
+ data->vbo_data = (EditLoopData *)GPU_vertbuf_get_data(vbo);
+ data->cd_ofs = CustomData_get_offset(&mr->bm->ldata, CD_MLOOPUV);
+}
+
+static void extract_fdots_edituv_data_iter_poly_bm(const MeshRenderData *mr,
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *_data)
+{
+ MeshExtract_EditUVFdotData_Data *data = static_cast<MeshExtract_EditUVFdotData_Data *>(_data);
+ EditLoopData *eldata = &data->vbo_data[BM_elem_index_get(f)];
+ memset(eldata, 0x0, sizeof(*eldata));
+ mesh_render_data_face_flag(mr, f, data->cd_ofs, eldata);
+}
+
+static void extract_fdots_edituv_data_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *UNUSED(mp),
+ const int mp_index,
+ void *_data)
+{
+ MeshExtract_EditUVFdotData_Data *data = static_cast<MeshExtract_EditUVFdotData_Data *>(_data);
+ EditLoopData *eldata = &data->vbo_data[mp_index];
+ memset(eldata, 0x0, sizeof(*eldata));
+ BMFace *efa = bm_original_face_get(mr, mp_index);
+ if (efa) {
+ mesh_render_data_face_flag(mr, efa, data->cd_ofs, eldata);
+ }
+}
+
+constexpr MeshExtract create_extractor_fdots_edituv_data()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_fdots_edituv_data_init;
+ extractor.iter_poly_bm = extract_fdots_edituv_data_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_fdots_edituv_data_iter_poly_mesh;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(MeshExtract_EditUVFdotData_Data);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.fdots_edituv_data);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_fdots_edituv_data = blender::draw::create_extractor_fdots_edituv_data();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_nor.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_nor.cc
new file mode 100644
index 00000000000..fb9d34e7733
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_nor.cc
@@ -0,0 +1,200 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Face-dots Normal and edit flag
+ * \{ */
+#define NOR_AND_FLAG_DEFAULT 0
+#define NOR_AND_FLAG_SELECT 1
+#define NOR_AND_FLAG_ACTIVE -1
+#define NOR_AND_FLAG_HIDDEN -2
+
+static void extract_fdots_nor_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *UNUSED(tls_data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "norAndFlag", GPU_COMP_I10, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->poly_len);
+}
+
+static void extract_fdots_nor_finish(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *UNUSED(data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static float invalid_normal[3] = {0.0f, 0.0f, 0.0f};
+ GPUPackedNormal *nor = (GPUPackedNormal *)GPU_vertbuf_get_data(vbo);
+ BMFace *efa;
+
+ /* Quicker than doing it for each loop. */
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ for (int f = 0; f < mr->poly_len; f++) {
+ efa = BM_face_at_index(mr->bm, f);
+ const bool is_face_hidden = BM_elem_flag_test(efa, BM_ELEM_HIDDEN);
+ if (is_face_hidden || (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex &&
+ mr->p_origindex[f] == ORIGINDEX_NONE)) {
+ nor[f] = GPU_normal_convert_i10_v3(invalid_normal);
+ nor[f].w = NOR_AND_FLAG_HIDDEN;
+ }
+ else {
+ nor[f] = GPU_normal_convert_i10_v3(bm_face_no_get(mr, efa));
+ /* Select / Active Flag. */
+ nor[f].w = (BM_elem_flag_test(efa, BM_ELEM_SELECT) ?
+ ((efa == mr->efa_act) ? NOR_AND_FLAG_ACTIVE : NOR_AND_FLAG_SELECT) :
+ NOR_AND_FLAG_DEFAULT);
+ }
+ }
+ }
+ else {
+ for (int f = 0; f < mr->poly_len; f++) {
+ efa = bm_original_face_get(mr, f);
+ const bool is_face_hidden = efa && BM_elem_flag_test(efa, BM_ELEM_HIDDEN);
+ if (is_face_hidden || (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex &&
+ mr->p_origindex[f] == ORIGINDEX_NONE)) {
+ nor[f] = GPU_normal_convert_i10_v3(invalid_normal);
+ nor[f].w = NOR_AND_FLAG_HIDDEN;
+ }
+ else {
+ nor[f] = GPU_normal_convert_i10_v3(bm_face_no_get(mr, efa));
+ /* Select / Active Flag. */
+ nor[f].w = (BM_elem_flag_test(efa, BM_ELEM_SELECT) ?
+ ((efa == mr->efa_act) ? NOR_AND_FLAG_ACTIVE : NOR_AND_FLAG_SELECT) :
+ NOR_AND_FLAG_DEFAULT);
+ }
+ }
+ }
+}
+
+constexpr MeshExtract create_extractor_fdots_nor()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_fdots_nor_init;
+ extractor.finish = extract_fdots_nor_finish;
+ extractor.data_type = MR_DATA_LOOP_NOR;
+ extractor.data_size = 0;
+ extractor.use_threading = false;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.fdots_nor);
+ return extractor;
+}
+
+/** \} */
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Face-dots High Quality Normal and edit flag
+ * \{ */
+static void extract_fdots_nor_hq_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *UNUSED(tls_data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "norAndFlag", GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->poly_len);
+}
+
+static void extract_fdots_nor_hq_finish(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *UNUSED(data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static float invalid_normal[3] = {0.0f, 0.0f, 0.0f};
+ short *nor = (short *)GPU_vertbuf_get_data(vbo);
+ BMFace *efa;
+
+ /* Quicker than doing it for each loop. */
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ for (int f = 0; f < mr->poly_len; f++) {
+ efa = BM_face_at_index(mr->bm, f);
+ const bool is_face_hidden = BM_elem_flag_test(efa, BM_ELEM_HIDDEN);
+ if (is_face_hidden || (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex &&
+ mr->p_origindex[f] == ORIGINDEX_NONE)) {
+ normal_float_to_short_v3(&nor[f * 4], invalid_normal);
+ nor[f * 4 + 3] = NOR_AND_FLAG_HIDDEN;
+ }
+ else {
+ normal_float_to_short_v3(&nor[f * 4], bm_face_no_get(mr, efa));
+ /* Select / Active Flag. */
+ nor[f * 4 + 3] = (BM_elem_flag_test(efa, BM_ELEM_SELECT) ?
+ ((efa == mr->efa_act) ? NOR_AND_FLAG_ACTIVE : NOR_AND_FLAG_SELECT) :
+ NOR_AND_FLAG_DEFAULT);
+ }
+ }
+ }
+ else {
+ for (int f = 0; f < mr->poly_len; f++) {
+ efa = bm_original_face_get(mr, f);
+ const bool is_face_hidden = efa && BM_elem_flag_test(efa, BM_ELEM_HIDDEN);
+ if (is_face_hidden || (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex &&
+ mr->p_origindex[f] == ORIGINDEX_NONE)) {
+ normal_float_to_short_v3(&nor[f * 4], invalid_normal);
+ nor[f * 4 + 3] = NOR_AND_FLAG_HIDDEN;
+ }
+ else {
+ normal_float_to_short_v3(&nor[f * 4], bm_face_no_get(mr, efa));
+ /* Select / Active Flag. */
+ nor[f * 4 + 3] = (BM_elem_flag_test(efa, BM_ELEM_SELECT) ?
+ ((efa == mr->efa_act) ? NOR_AND_FLAG_ACTIVE : NOR_AND_FLAG_SELECT) :
+ NOR_AND_FLAG_DEFAULT);
+ }
+ }
+ }
+}
+
+constexpr MeshExtract create_extractor_fdots_nor_hq()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_fdots_nor_hq_init;
+ extractor.finish = extract_fdots_nor_hq_finish;
+ extractor.data_type = MR_DATA_LOOP_NOR;
+ extractor.data_size = 0;
+ extractor.use_threading = false;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.fdots_nor);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_fdots_nor = blender::draw::create_extractor_fdots_nor();
+const MeshExtract extract_fdots_nor_hq = blender::draw::create_extractor_fdots_nor_hq();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc
new file mode 100644
index 00000000000..c4706c412c6
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc
@@ -0,0 +1,119 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Face-dots positions
+ * \{ */
+
+static void extract_fdots_pos_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->poly_len);
+ void *vbo_data = GPU_vertbuf_get_data(vbo);
+ *(float(**)[3])tls_data = static_cast<float(*)[3]>(vbo_data);
+}
+
+static void extract_fdots_pos_iter_poly_bm(const MeshRenderData *mr,
+ const BMFace *f,
+ const int f_index,
+ void *data)
+{
+ float(*center)[3] = *static_cast<float(**)[3]>(data);
+
+ float *co = center[f_index];
+ zero_v3(co);
+
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ add_v3_v3(co, bm_vert_co_get(mr, l_iter->v));
+ } while ((l_iter = l_iter->next) != l_first);
+ mul_v3_fl(co, 1.0f / (float)f->len);
+}
+
+static void extract_fdots_pos_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int mp_index,
+ void *data)
+{
+ float(*center)[3] = *static_cast<float(**)[3]>(data);
+ float *co = center[mp_index];
+ zero_v3(co);
+
+ const MVert *mvert = mr->mvert;
+ const MLoop *mloop = mr->mloop;
+
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+ if (mr->use_subsurf_fdots) {
+ const MVert *mv = &mr->mvert[ml->v];
+ if (mv->flag & ME_VERT_FACEDOT) {
+ copy_v3_v3(center[mp_index], mv->co);
+ break;
+ }
+ }
+ else {
+ const MVert *mv = &mvert[ml->v];
+ add_v3_v3(center[mp_index], mv->co);
+ }
+ }
+
+ if (!mr->use_subsurf_fdots) {
+ mul_v3_fl(co, 1.0f / (float)mp->totloop);
+ }
+}
+
+constexpr MeshExtract create_extractor_fdots_pos()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_fdots_pos_init;
+ extractor.iter_poly_bm = extract_fdots_pos_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_fdots_pos_iter_poly_mesh;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(float(*)[3]);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.fdots_pos);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_fdots_pos = blender::draw::create_extractor_fdots_pos();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc
new file mode 100644
index 00000000000..0289fd63a30
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc
@@ -0,0 +1,127 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Face-dots UV
+ * \{ */
+
+struct MeshExtract_FdotUV_Data {
+ float (*vbo_data)[2];
+ MLoopUV *uv_data;
+ int cd_ofs;
+};
+
+static void extract_fdots_uv_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "u", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ GPU_vertformat_alias_add(&format, "au");
+ GPU_vertformat_alias_add(&format, "pos");
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->poly_len);
+
+ if (!mr->use_subsurf_fdots) {
+ /* Clear so we can accumulate on it. */
+ memset(GPU_vertbuf_get_data(vbo), 0x0, mr->poly_len * GPU_vertbuf_get_format(vbo)->stride);
+ }
+
+ MeshExtract_FdotUV_Data *data = static_cast<MeshExtract_FdotUV_Data *>(tls_data);
+ data->vbo_data = (float(*)[2])GPU_vertbuf_get_data(vbo);
+
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ data->cd_ofs = CustomData_get_offset(&mr->bm->ldata, CD_MLOOPUV);
+ }
+ else {
+ data->uv_data = (MLoopUV *)CustomData_get_layer(&mr->me->ldata, CD_MLOOPUV);
+ }
+}
+
+static void extract_fdots_uv_iter_poly_bm(const MeshRenderData *UNUSED(mr),
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *_data)
+{
+ MeshExtract_FdotUV_Data *data = static_cast<MeshExtract_FdotUV_Data *>(_data);
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ float w = 1.0f / (float)f->len;
+ const MLoopUV *luv = (const MLoopUV *)BM_ELEM_CD_GET_VOID_P(l_iter, data->cd_ofs);
+ madd_v2_v2fl(data->vbo_data[BM_elem_index_get(f)], luv->uv, w);
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_fdots_uv_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int mp_index,
+ void *_data)
+{
+ MeshExtract_FdotUV_Data *data = static_cast<MeshExtract_FdotUV_Data *>(_data);
+ const MLoop *mloop = mr->mloop;
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+ if (mr->use_subsurf_fdots) {
+ const MVert *mv = &mr->mvert[ml->v];
+ if (mv->flag & ME_VERT_FACEDOT) {
+ copy_v2_v2(data->vbo_data[mp_index], data->uv_data[ml_index].uv);
+ }
+ }
+ else {
+ float w = 1.0f / (float)mp->totloop;
+ madd_v2_v2fl(data->vbo_data[mp_index], data->uv_data[ml_index].uv, w);
+ }
+ }
+}
+
+constexpr MeshExtract create_extractor_fdots_uv()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_fdots_uv_init;
+ extractor.iter_poly_bm = extract_fdots_uv_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_fdots_uv_iter_poly_mesh;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(MeshExtract_FdotUV_Data);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.fdots_uv);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_fdots_uv = blender::draw::create_extractor_fdots_uv();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc
new file mode 100644
index 00000000000..b942068352b
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc
@@ -0,0 +1,228 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Loop Normal
+ * \{ */
+
+static void extract_lnor_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I10, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ GPU_vertformat_alias_add(&format, "lnor");
+ }
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len);
+
+ *(GPUPackedNormal **)tls_data = static_cast<GPUPackedNormal *>(GPU_vertbuf_get_data(vbo));
+}
+
+static void extract_lnor_iter_poly_bm(const MeshRenderData *mr,
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *data)
+{
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+ if (mr->loop_normals) {
+ (*(GPUPackedNormal **)data)[l_index] = GPU_normal_convert_i10_v3(mr->loop_normals[l_index]);
+ }
+ else {
+ if (BM_elem_flag_test(f, BM_ELEM_SMOOTH)) {
+ (*(GPUPackedNormal **)data)[l_index] = GPU_normal_convert_i10_v3(
+ bm_vert_no_get(mr, l_iter->v));
+ }
+ else {
+ (*(GPUPackedNormal **)data)[l_index] = GPU_normal_convert_i10_v3(bm_face_no_get(mr, f));
+ }
+ }
+ (*(GPUPackedNormal **)data)[l_index].w = BM_elem_flag_test(f, BM_ELEM_HIDDEN) ? -1 : 0;
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_lnor_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int mp_index,
+ void *data)
+{
+ const MLoop *mloop = mr->mloop;
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+ GPUPackedNormal *lnor_data = &(*(GPUPackedNormal **)data)[ml_index];
+ if (mr->loop_normals) {
+ *lnor_data = GPU_normal_convert_i10_v3(mr->loop_normals[ml_index]);
+ }
+ else if (mp->flag & ME_SMOOTH) {
+ *lnor_data = GPU_normal_convert_i10_s3(mr->mvert[ml->v].no);
+ }
+ else {
+ *lnor_data = GPU_normal_convert_i10_v3(mr->poly_normals[mp_index]);
+ }
+
+ /* Flag for paint mode overlay.
+ * Only use MR_EXTRACT_MAPPED in edit mode where it is used to display the edge-normals.
+ * In paint mode it will use the un-mapped data to draw the wire-frame. */
+ if (mp->flag & ME_HIDE || (mr->edit_bmesh && mr->extract_type == MR_EXTRACT_MAPPED &&
+ (mr->v_origindex) && mr->v_origindex[ml->v] == ORIGINDEX_NONE)) {
+ lnor_data->w = -1;
+ }
+ else if (mp->flag & ME_FACE_SEL) {
+ lnor_data->w = 1;
+ }
+ else {
+ lnor_data->w = 0;
+ }
+ }
+}
+
+constexpr MeshExtract create_extractor_lnor()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_lnor_init;
+ extractor.iter_poly_bm = extract_lnor_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_lnor_iter_poly_mesh;
+ extractor.data_type = MR_DATA_LOOP_NOR;
+ extractor.data_size = sizeof(GPUPackedNormal *);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.lnor);
+ return extractor;
+}
+
+/** \} */
+/* ---------------------------------------------------------------------- */
+/** \name Extract HQ Loop Normal
+ * \{ */
+
+struct gpuHQNor {
+ short x, y, z, w;
+};
+
+static void extract_lnor_hq_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ GPU_vertformat_alias_add(&format, "lnor");
+ }
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len);
+
+ *(gpuHQNor **)tls_data = static_cast<gpuHQNor *>(GPU_vertbuf_get_data(vbo));
+}
+
+static void extract_lnor_hq_iter_poly_bm(const MeshRenderData *mr,
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *data)
+{
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+ if (mr->loop_normals) {
+ normal_float_to_short_v3(&(*(gpuHQNor **)data)[l_index].x, mr->loop_normals[l_index]);
+ }
+ else {
+ if (BM_elem_flag_test(f, BM_ELEM_SMOOTH)) {
+ normal_float_to_short_v3(&(*(gpuHQNor **)data)[l_index].x, bm_vert_no_get(mr, l_iter->v));
+ }
+ else {
+ normal_float_to_short_v3(&(*(gpuHQNor **)data)[l_index].x, bm_face_no_get(mr, f));
+ }
+ }
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_lnor_hq_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int mp_index,
+ void *data)
+{
+ const MLoop *mloop = mr->mloop;
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+ gpuHQNor *lnor_data = &(*(gpuHQNor **)data)[ml_index];
+ if (mr->loop_normals) {
+ normal_float_to_short_v3(&lnor_data->x, mr->loop_normals[ml_index]);
+ }
+ else if (mp->flag & ME_SMOOTH) {
+ copy_v3_v3_short(&lnor_data->x, mr->mvert[ml->v].no);
+ }
+ else {
+ normal_float_to_short_v3(&lnor_data->x, mr->poly_normals[mp_index]);
+ }
+
+ /* Flag for paint mode overlay.
+ * Only use #MR_EXTRACT_MAPPED in edit mode where it is used to display the edge-normals.
+ * In paint mode it will use the un-mapped data to draw the wire-frame. */
+ if (mp->flag & ME_HIDE || (mr->edit_bmesh && mr->extract_type == MR_EXTRACT_MAPPED &&
+ (mr->v_origindex) && mr->v_origindex[ml->v] == ORIGINDEX_NONE)) {
+ lnor_data->w = -1;
+ }
+ else if (mp->flag & ME_FACE_SEL) {
+ lnor_data->w = 1;
+ }
+ else {
+ lnor_data->w = 0;
+ }
+ }
+}
+
+constexpr MeshExtract create_extractor_lnor_hq()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_lnor_hq_init;
+ extractor.iter_poly_bm = extract_lnor_hq_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_lnor_hq_iter_poly_mesh;
+ extractor.data_type = MR_DATA_LOOP_NOR;
+ extractor.data_size = sizeof(gpuHQNor *);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.lnor);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_lnor = blender::draw::create_extractor_lnor();
+const MeshExtract extract_lnor_hq = blender::draw::create_extractor_lnor_hq();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc
new file mode 100644
index 00000000000..b734061b76a
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc
@@ -0,0 +1,654 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_edgehash.h"
+#include "BLI_jitter_2d.h"
+
+#include "BKE_bvhutils.h"
+#include "BKE_editmesh_bvh.h"
+#include "BKE_editmesh_cache.h"
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Edit Mesh Analysis Colors
+ * \{ */
+
+static void extract_mesh_analysis_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *UNUSED(tls_data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "weight", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len);
+}
+
+static void axis_from_enum_v3(float v[3], const char axis)
+{
+ zero_v3(v);
+ if (axis < 3) {
+ v[axis] = 1.0f;
+ }
+ else {
+ v[axis - 3] = -1.0f;
+ }
+}
+
+BLI_INLINE float overhang_remap(float fac, float min, float max, float minmax_irange)
+{
+ if (fac < min) {
+ fac = 1.0f;
+ }
+ else if (fac > max) {
+ fac = -1.0f;
+ }
+ else {
+ fac = (fac - min) * minmax_irange;
+ fac = 1.0f - fac;
+ CLAMP(fac, 0.0f, 1.0f);
+ }
+ return fac;
+}
+
+static void statvis_calc_overhang(const MeshRenderData *mr, float *r_overhang)
+{
+ const MeshStatVis *statvis = &mr->toolsettings->statvis;
+ const float min = statvis->overhang_min / (float)M_PI;
+ const float max = statvis->overhang_max / (float)M_PI;
+ const char axis = statvis->overhang_axis;
+ BMEditMesh *em = mr->edit_bmesh;
+ BMIter iter;
+ BMesh *bm = em->bm;
+ BMFace *f;
+ float dir[3];
+ const float minmax_irange = 1.0f / (max - min);
+
+ BLI_assert(min <= max);
+
+ axis_from_enum_v3(dir, axis);
+
+ /* now convert into global space */
+ mul_transposed_mat3_m4_v3(mr->obmat, dir);
+ normalize_v3(dir);
+
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ int l_index = 0;
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ float fac = angle_normalized_v3v3(bm_face_no_get(mr, f), dir) / (float)M_PI;
+ fac = overhang_remap(fac, min, max, minmax_irange);
+ for (int i = 0; i < f->len; i++, l_index++) {
+ r_overhang[l_index] = fac;
+ }
+ }
+ }
+ else {
+ const MPoly *mp = mr->mpoly;
+ for (int mp_index = 0, l_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
+ float fac = angle_normalized_v3v3(mr->poly_normals[mp_index], dir) / (float)M_PI;
+ fac = overhang_remap(fac, min, max, minmax_irange);
+ for (int i = 0; i < mp->totloop; i++, l_index++) {
+ r_overhang[l_index] = fac;
+ }
+ }
+ }
+}
+
+/**
+ * Needed so we can use jitter values for face interpolation.
+ */
+static void uv_from_jitter_v2(float uv[2])
+{
+ uv[0] += 0.5f;
+ uv[1] += 0.5f;
+ if (uv[0] + uv[1] > 1.0f) {
+ uv[0] = 1.0f - uv[0];
+ uv[1] = 1.0f - uv[1];
+ }
+
+ clamp_v2(uv, 0.0f, 1.0f);
+}
+
+BLI_INLINE float thickness_remap(float fac, float min, float max, float minmax_irange)
+{
+ /* important not '<=' */
+ if (fac < max) {
+ fac = (fac - min) * minmax_irange;
+ fac = 1.0f - fac;
+ CLAMP(fac, 0.0f, 1.0f);
+ }
+ else {
+ fac = -1.0f;
+ }
+ return fac;
+}
+
+static void statvis_calc_thickness(const MeshRenderData *mr, float *r_thickness)
+{
+ const float eps_offset = 0.00002f; /* values <= 0.00001 give errors */
+ /* cheating to avoid another allocation */
+ float *face_dists = r_thickness + (mr->loop_len - mr->poly_len);
+ BMEditMesh *em = mr->edit_bmesh;
+ const float scale = 1.0f / mat4_to_scale(mr->obmat);
+ const MeshStatVis *statvis = &mr->toolsettings->statvis;
+ const float min = statvis->thickness_min * scale;
+ const float max = statvis->thickness_max * scale;
+ const float minmax_irange = 1.0f / (max - min);
+ const int samples = statvis->thickness_samples;
+ float jit_ofs[32][2];
+ BLI_assert(samples <= 32);
+ BLI_assert(min <= max);
+
+ copy_vn_fl(face_dists, mr->poly_len, max);
+
+ BLI_jitter_init(jit_ofs, samples);
+ for (int j = 0; j < samples; j++) {
+ uv_from_jitter_v2(jit_ofs[j]);
+ }
+
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ BMesh *bm = em->bm;
+ BM_mesh_elem_index_ensure(bm, BM_FACE);
+
+ struct BMBVHTree *bmtree = BKE_bmbvh_new_from_editmesh(em, 0, nullptr, false);
+ struct BMLoop *(*looptris)[3] = em->looptris;
+ for (int i = 0; i < mr->tri_len; i++) {
+ BMLoop **ltri = looptris[i];
+ const int index = BM_elem_index_get(ltri[0]->f);
+ const float *cos[3] = {
+ bm_vert_co_get(mr, ltri[0]->v),
+ bm_vert_co_get(mr, ltri[1]->v),
+ bm_vert_co_get(mr, ltri[2]->v),
+ };
+ float ray_co[3];
+ float ray_no[3];
+
+ normal_tri_v3(ray_no, cos[2], cos[1], cos[0]);
+
+ for (int j = 0; j < samples; j++) {
+ float dist = face_dists[index];
+ interp_v3_v3v3v3_uv(ray_co, cos[0], cos[1], cos[2], jit_ofs[j]);
+ madd_v3_v3fl(ray_co, ray_no, eps_offset);
+
+ BMFace *f_hit = BKE_bmbvh_ray_cast(bmtree, ray_co, ray_no, 0.0f, &dist, nullptr, nullptr);
+ if (f_hit && dist < face_dists[index]) {
+ float angle_fac = fabsf(
+ dot_v3v3(bm_face_no_get(mr, ltri[0]->f), bm_face_no_get(mr, f_hit)));
+ angle_fac = 1.0f - angle_fac;
+ angle_fac = angle_fac * angle_fac * angle_fac;
+ angle_fac = 1.0f - angle_fac;
+ dist /= angle_fac;
+ if (dist < face_dists[index]) {
+ face_dists[index] = dist;
+ }
+ }
+ }
+ }
+ BKE_bmbvh_free(bmtree);
+
+ BMIter iter;
+ BMFace *f;
+ int l_index = 0;
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ float fac = face_dists[BM_elem_index_get(f)];
+ fac = thickness_remap(fac, min, max, minmax_irange);
+ for (int i = 0; i < f->len; i++, l_index++) {
+ r_thickness[l_index] = fac;
+ }
+ }
+ }
+ else {
+ BVHTreeFromMesh treeData = {nullptr};
+
+ BVHTree *tree = BKE_bvhtree_from_mesh_get(&treeData, mr->me, BVHTREE_FROM_LOOPTRI, 4);
+ const MLoopTri *mlooptri = mr->mlooptri;
+ for (int i = 0; i < mr->tri_len; i++, mlooptri++) {
+ const int index = mlooptri->poly;
+ const float *cos[3] = {mr->mvert[mr->mloop[mlooptri->tri[0]].v].co,
+ mr->mvert[mr->mloop[mlooptri->tri[1]].v].co,
+ mr->mvert[mr->mloop[mlooptri->tri[2]].v].co};
+ float ray_co[3];
+ float ray_no[3];
+
+ normal_tri_v3(ray_no, cos[2], cos[1], cos[0]);
+
+ for (int j = 0; j < samples; j++) {
+ interp_v3_v3v3v3_uv(ray_co, cos[0], cos[1], cos[2], jit_ofs[j]);
+ madd_v3_v3fl(ray_co, ray_no, eps_offset);
+
+ BVHTreeRayHit hit;
+ hit.index = -1;
+ hit.dist = face_dists[index];
+ if ((BLI_bvhtree_ray_cast(
+ tree, ray_co, ray_no, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) &&
+ hit.dist < face_dists[index]) {
+ float angle_fac = fabsf(dot_v3v3(mr->poly_normals[index], hit.no));
+ angle_fac = 1.0f - angle_fac;
+ angle_fac = angle_fac * angle_fac * angle_fac;
+ angle_fac = 1.0f - angle_fac;
+ hit.dist /= angle_fac;
+ if (hit.dist < face_dists[index]) {
+ face_dists[index] = hit.dist;
+ }
+ }
+ }
+ }
+
+ const MPoly *mp = mr->mpoly;
+ for (int mp_index = 0, l_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
+ float fac = face_dists[mp_index];
+ fac = thickness_remap(fac, min, max, minmax_irange);
+ for (int i = 0; i < mp->totloop; i++, l_index++) {
+ r_thickness[l_index] = fac;
+ }
+ }
+ }
+}
+
+struct BVHTree_OverlapData {
+ const Mesh *me;
+ const MLoopTri *mlooptri;
+ float epsilon;
+};
+
+static bool bvh_overlap_cb(void *userdata, int index_a, int index_b, int UNUSED(thread))
+{
+ struct BVHTree_OverlapData *data = static_cast<struct BVHTree_OverlapData *>(userdata);
+ const Mesh *me = data->me;
+
+ const MLoopTri *tri_a = &data->mlooptri[index_a];
+ const MLoopTri *tri_b = &data->mlooptri[index_b];
+
+ if (UNLIKELY(tri_a->poly == tri_b->poly)) {
+ return false;
+ }
+
+ const float *tri_a_co[3] = {me->mvert[me->mloop[tri_a->tri[0]].v].co,
+ me->mvert[me->mloop[tri_a->tri[1]].v].co,
+ me->mvert[me->mloop[tri_a->tri[2]].v].co};
+ const float *tri_b_co[3] = {me->mvert[me->mloop[tri_b->tri[0]].v].co,
+ me->mvert[me->mloop[tri_b->tri[1]].v].co,
+ me->mvert[me->mloop[tri_b->tri[2]].v].co};
+ float ix_pair[2][3];
+ int verts_shared = 0;
+
+ verts_shared = (ELEM(tri_a_co[0], UNPACK3(tri_b_co)) + ELEM(tri_a_co[1], UNPACK3(tri_b_co)) +
+ ELEM(tri_a_co[2], UNPACK3(tri_b_co)));
+
+ /* if 2 points are shared, bail out */
+ if (verts_shared >= 2) {
+ return false;
+ }
+
+ return (isect_tri_tri_v3(UNPACK3(tri_a_co), UNPACK3(tri_b_co), ix_pair[0], ix_pair[1]) &&
+ /* if we share a vertex, check the intersection isn't a 'point' */
+ ((verts_shared == 0) || (len_squared_v3v3(ix_pair[0], ix_pair[1]) > data->epsilon)));
+}
+
+static void statvis_calc_intersect(const MeshRenderData *mr, float *r_intersect)
+{
+ BMEditMesh *em = mr->edit_bmesh;
+
+ for (int l_index = 0; l_index < mr->loop_len; l_index++) {
+ r_intersect[l_index] = -1.0f;
+ }
+
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ uint overlap_len;
+ BMesh *bm = em->bm;
+
+ BM_mesh_elem_index_ensure(bm, BM_FACE);
+
+ struct BMBVHTree *bmtree = BKE_bmbvh_new_from_editmesh(em, 0, nullptr, false);
+ BVHTreeOverlap *overlap = BKE_bmbvh_overlap_self(bmtree, &overlap_len);
+
+ if (overlap) {
+ for (int i = 0; i < overlap_len; i++) {
+ BMFace *f_hit_pair[2] = {
+ em->looptris[overlap[i].indexA][0]->f,
+ em->looptris[overlap[i].indexB][0]->f,
+ };
+ for (int j = 0; j < 2; j++) {
+ BMFace *f_hit = f_hit_pair[j];
+ BMLoop *l_first = BM_FACE_FIRST_LOOP(f_hit);
+ int l_index = BM_elem_index_get(l_first);
+ for (int k = 0; k < f_hit->len; k++, l_index++) {
+ r_intersect[l_index] = 1.0f;
+ }
+ }
+ }
+ MEM_freeN(overlap);
+ }
+
+ BKE_bmbvh_free(bmtree);
+ }
+ else {
+ uint overlap_len;
+ BVHTreeFromMesh treeData = {nullptr};
+
+ BVHTree *tree = BKE_bvhtree_from_mesh_get(&treeData, mr->me, BVHTREE_FROM_LOOPTRI, 4);
+
+ struct BVHTree_OverlapData data = {nullptr};
+ data.me = mr->me;
+ data.mlooptri = mr->mlooptri;
+ data.epsilon = BLI_bvhtree_get_epsilon(tree);
+
+ BVHTreeOverlap *overlap = BLI_bvhtree_overlap(tree, tree, &overlap_len, bvh_overlap_cb, &data);
+ if (overlap) {
+ for (int i = 0; i < overlap_len; i++) {
+ const MPoly *f_hit_pair[2] = {
+ &mr->mpoly[mr->mlooptri[overlap[i].indexA].poly],
+ &mr->mpoly[mr->mlooptri[overlap[i].indexB].poly],
+ };
+ for (int j = 0; j < 2; j++) {
+ const MPoly *f_hit = f_hit_pair[j];
+ int l_index = f_hit->loopstart;
+ for (int k = 0; k < f_hit->totloop; k++, l_index++) {
+ r_intersect[l_index] = 1.0f;
+ }
+ }
+ }
+ MEM_freeN(overlap);
+ }
+ }
+}
+
+BLI_INLINE float distort_remap(float fac, float min, float UNUSED(max), float minmax_irange)
+{
+ if (fac >= min) {
+ fac = (fac - min) * minmax_irange;
+ CLAMP(fac, 0.0f, 1.0f);
+ }
+ else {
+ /* fallback */
+ fac = -1.0f;
+ }
+ return fac;
+}
+
+static void statvis_calc_distort(const MeshRenderData *mr, float *r_distort)
+{
+ BMEditMesh *em = mr->edit_bmesh;
+ const MeshStatVis *statvis = &mr->toolsettings->statvis;
+ const float min = statvis->distort_min;
+ const float max = statvis->distort_max;
+ const float minmax_irange = 1.0f / (max - min);
+
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ BMIter iter;
+ BMesh *bm = em->bm;
+ BMFace *f;
+
+ if (mr->bm_vert_coords != nullptr) {
+ BKE_editmesh_cache_ensure_poly_normals(em, mr->edit_data);
+
+ /* Most likely this is already valid, ensure just in case.
+ * Needed for #BM_loop_calc_face_normal_safe_vcos. */
+ BM_mesh_elem_index_ensure(em->bm, BM_VERT);
+ }
+
+ int l_index = 0;
+ int f_index = 0;
+ BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, f_index) {
+ float fac = -1.0f;
+
+ if (f->len > 3) {
+ BMLoop *l_iter, *l_first;
+
+ fac = 0.0f;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const float *no_face;
+ float no_corner[3];
+ if (mr->bm_vert_coords != nullptr) {
+ no_face = mr->bm_poly_normals[f_index];
+ BM_loop_calc_face_normal_safe_vcos(l_iter, no_face, mr->bm_vert_coords, no_corner);
+ }
+ else {
+ no_face = f->no;
+ BM_loop_calc_face_normal_safe(l_iter, no_corner);
+ }
+
+ /* simple way to detect (what is most likely) concave */
+ if (dot_v3v3(no_face, no_corner) < 0.0f) {
+ negate_v3(no_corner);
+ }
+ fac = max_ff(fac, angle_normalized_v3v3(no_face, no_corner));
+
+ } while ((l_iter = l_iter->next) != l_first);
+ fac *= 2.0f;
+ }
+
+ fac = distort_remap(fac, min, max, minmax_irange);
+ for (int i = 0; i < f->len; i++, l_index++) {
+ r_distort[l_index] = fac;
+ }
+ }
+ }
+ else {
+ const MPoly *mp = mr->mpoly;
+ for (int mp_index = 0, l_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
+ float fac = -1.0f;
+
+ if (mp->totloop > 3) {
+ float *f_no = mr->poly_normals[mp_index];
+ fac = 0.0f;
+
+ for (int i = 1; i <= mp->totloop; i++) {
+ const MLoop *l_prev = &mr->mloop[mp->loopstart + (i - 1) % mp->totloop];
+ const MLoop *l_curr = &mr->mloop[mp->loopstart + (i + 0) % mp->totloop];
+ const MLoop *l_next = &mr->mloop[mp->loopstart + (i + 1) % mp->totloop];
+ float no_corner[3];
+ normal_tri_v3(no_corner,
+ mr->mvert[l_prev->v].co,
+ mr->mvert[l_curr->v].co,
+ mr->mvert[l_next->v].co);
+ /* simple way to detect (what is most likely) concave */
+ if (dot_v3v3(f_no, no_corner) < 0.0f) {
+ negate_v3(no_corner);
+ }
+ fac = max_ff(fac, angle_normalized_v3v3(f_no, no_corner));
+ }
+ fac *= 2.0f;
+ }
+
+ fac = distort_remap(fac, min, max, minmax_irange);
+ for (int i = 0; i < mp->totloop; i++, l_index++) {
+ r_distort[l_index] = fac;
+ }
+ }
+ }
+}
+
+BLI_INLINE float sharp_remap(float fac, float min, float UNUSED(max), float minmax_irange)
+{
+ /* important not '>=' */
+ if (fac > min) {
+ fac = (fac - min) * minmax_irange;
+ CLAMP(fac, 0.0f, 1.0f);
+ }
+ else {
+ /* fallback */
+ fac = -1.0f;
+ }
+ return fac;
+}
+
+static void statvis_calc_sharp(const MeshRenderData *mr, float *r_sharp)
+{
+ BMEditMesh *em = mr->edit_bmesh;
+ const MeshStatVis *statvis = &mr->toolsettings->statvis;
+ const float min = statvis->sharp_min;
+ const float max = statvis->sharp_max;
+ const float minmax_irange = 1.0f / (max - min);
+
+ /* Can we avoid this extra allocation? */
+ float *vert_angles = (float *)MEM_mallocN(sizeof(float) * mr->vert_len, __func__);
+ copy_vn_fl(vert_angles, mr->vert_len, -M_PI);
+
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ BMIter iter;
+ BMesh *bm = em->bm;
+ BMFace *efa;
+ BMEdge *e;
+ /* first assign float values to verts */
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ float angle = BM_edge_calc_face_angle_signed(e);
+ float *col1 = &vert_angles[BM_elem_index_get(e->v1)];
+ float *col2 = &vert_angles[BM_elem_index_get(e->v2)];
+ *col1 = max_ff(*col1, angle);
+ *col2 = max_ff(*col2, angle);
+ }
+ /* Copy vert value to loops. */
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
+ do {
+ int l_index = BM_elem_index_get(l_iter);
+ int v_index = BM_elem_index_get(l_iter->v);
+ r_sharp[l_index] = sharp_remap(vert_angles[v_index], min, max, minmax_irange);
+ } while ((l_iter = l_iter->next) != l_first);
+ }
+ }
+ else {
+ /* first assign float values to verts */
+ const MPoly *mp = mr->mpoly;
+
+ EdgeHash *eh = BLI_edgehash_new_ex(__func__, mr->edge_len);
+
+ for (int mp_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
+ for (int i = 0; i < mp->totloop; i++) {
+ const MLoop *l_curr = &mr->mloop[mp->loopstart + (i + 0) % mp->totloop];
+ const MLoop *l_next = &mr->mloop[mp->loopstart + (i + 1) % mp->totloop];
+ const MVert *v_curr = &mr->mvert[l_curr->v];
+ const MVert *v_next = &mr->mvert[l_next->v];
+ float angle;
+ void **pval;
+ bool value_is_init = BLI_edgehash_ensure_p(eh, l_curr->v, l_next->v, &pval);
+ if (!value_is_init) {
+ *pval = mr->poly_normals[mp_index];
+ /* non-manifold edge, yet... */
+ continue;
+ }
+ if (*pval != nullptr) {
+ const float *f1_no = mr->poly_normals[mp_index];
+ const float *f2_no = static_cast<const float *>(*pval);
+ angle = angle_normalized_v3v3(f1_no, f2_no);
+ angle = is_edge_convex_v3(v_curr->co, v_next->co, f1_no, f2_no) ? angle : -angle;
+ /* Tag as manifold. */
+ *pval = nullptr;
+ }
+ else {
+ /* non-manifold edge */
+ angle = DEG2RADF(90.0f);
+ }
+ float *col1 = &vert_angles[l_curr->v];
+ float *col2 = &vert_angles[l_next->v];
+ *col1 = max_ff(*col1, angle);
+ *col2 = max_ff(*col2, angle);
+ }
+ }
+ /* Remaining non manifold edges. */
+ EdgeHashIterator *ehi = BLI_edgehashIterator_new(eh);
+ for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
+ if (BLI_edgehashIterator_getValue(ehi) != nullptr) {
+ uint v1, v2;
+ const float angle = DEG2RADF(90.0f);
+ BLI_edgehashIterator_getKey(ehi, &v1, &v2);
+ float *col1 = &vert_angles[v1];
+ float *col2 = &vert_angles[v2];
+ *col1 = max_ff(*col1, angle);
+ *col2 = max_ff(*col2, angle);
+ }
+ }
+ BLI_edgehashIterator_free(ehi);
+ BLI_edgehash_free(eh, nullptr);
+
+ const MLoop *ml = mr->mloop;
+ for (int l_index = 0; l_index < mr->loop_len; l_index++, ml++) {
+ r_sharp[l_index] = sharp_remap(vert_angles[ml->v], min, max, minmax_irange);
+ }
+ }
+
+ MEM_freeN(vert_angles);
+}
+
+static void extract_analysis_iter_finish_mesh(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *UNUSED(data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ BLI_assert(mr->edit_bmesh);
+
+ float *l_weight = (float *)GPU_vertbuf_get_data(vbo);
+
+ switch (mr->toolsettings->statvis.type) {
+ case SCE_STATVIS_OVERHANG:
+ statvis_calc_overhang(mr, l_weight);
+ break;
+ case SCE_STATVIS_THICKNESS:
+ statvis_calc_thickness(mr, l_weight);
+ break;
+ case SCE_STATVIS_INTERSECT:
+ statvis_calc_intersect(mr, l_weight);
+ break;
+ case SCE_STATVIS_DISTORT:
+ statvis_calc_distort(mr, l_weight);
+ break;
+ case SCE_STATVIS_SHARP:
+ statvis_calc_sharp(mr, l_weight);
+ break;
+ }
+}
+
+constexpr MeshExtract create_extractor_mesh_analysis()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_mesh_analysis_init;
+ extractor.finish = extract_analysis_iter_finish_mesh;
+ /* This is not needed for all visualization types.
+ * Maybe split into different extract. */
+ extractor.data_type = MR_DATA_POLY_NOR | MR_DATA_LOOPTRI;
+ extractor.data_size = 0;
+ extractor.use_threading = false;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.mesh_analysis);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_mesh_analysis = blender::draw::create_extractor_mesh_analysis();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_orco.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_orco.cc
new file mode 100644
index 00000000000..80b73cac678
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_orco.cc
@@ -0,0 +1,115 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Orco
+ * \{ */
+
+struct MeshExtract_Orco_Data {
+ float (*vbo_data)[4];
+ float (*orco)[3];
+};
+
+static void extract_orco_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ /* FIXME(fclem): We use the last component as a way to differentiate from generic vertex
+ * attributes. This is a substantial waste of video-ram and should be done another way.
+ * Unfortunately, at the time of writing, I did not found any other "non disruptive"
+ * alternative. */
+ GPU_vertformat_attr_add(&format, "orco", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len);
+
+ CustomData *cd_vdata = &mr->me->vdata;
+
+ MeshExtract_Orco_Data *data = static_cast<MeshExtract_Orco_Data *>(tls_data);
+ data->vbo_data = (float(*)[4])GPU_vertbuf_get_data(vbo);
+ data->orco = static_cast<float(*)[3]>(CustomData_get_layer(cd_vdata, CD_ORCO));
+ /* Make sure `orco` layer was requested only if needed! */
+ BLI_assert(data->orco);
+}
+
+static void extract_orco_iter_poly_bm(const MeshRenderData *UNUSED(mr),
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *data)
+{
+ MeshExtract_Orco_Data *orco_data = (MeshExtract_Orco_Data *)data;
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+ float *loop_orco = orco_data->vbo_data[l_index];
+ copy_v3_v3(loop_orco, orco_data->orco[BM_elem_index_get(l_iter->v)]);
+ loop_orco[3] = 0.0; /* Tag as not a generic attribute. */
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_orco_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int UNUSED(mp_index),
+ void *data)
+{
+ const MLoop *mloop = mr->mloop;
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+ MeshExtract_Orco_Data *orco_data = (MeshExtract_Orco_Data *)data;
+ float *loop_orco = orco_data->vbo_data[ml_index];
+ copy_v3_v3(loop_orco, orco_data->orco[ml->v]);
+ loop_orco[3] = 0.0; /* Tag as not a generic attribute. */
+ }
+}
+
+constexpr MeshExtract create_extractor_orco()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_orco_init;
+ extractor.iter_poly_bm = extract_orco_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_orco_iter_poly_mesh;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(MeshExtract_Orco_Data);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.orco);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_orco = blender::draw::create_extractor_orco();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc
new file mode 100644
index 00000000000..2ac926dd257
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc
@@ -0,0 +1,415 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Position and Vertex Normal
+ * \{ */
+
+struct PosNorLoop {
+ float pos[3];
+ GPUPackedNormal nor;
+};
+
+struct MeshExtract_PosNor_Data {
+ PosNorLoop *vbo_data;
+ GPUNormal *normals;
+};
+
+static void extract_pos_nor_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ /* WARNING Adjust #PosNorLoop struct accordingly. */
+ GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I10, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ GPU_vertformat_alias_add(&format, "vnor");
+ }
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
+
+ /* Pack normals per vert, reduce amount of computation. */
+ MeshExtract_PosNor_Data *data = static_cast<MeshExtract_PosNor_Data *>(tls_data);
+ data->vbo_data = static_cast<PosNorLoop *>(GPU_vertbuf_get_data(vbo));
+ data->normals = (GPUNormal *)MEM_mallocN(sizeof(GPUNormal) * mr->vert_len, __func__);
+
+ /* Quicker than doing it for each loop. */
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ BMIter iter;
+ BMVert *eve;
+ int v;
+ BM_ITER_MESH_INDEX (eve, &iter, mr->bm, BM_VERTS_OF_MESH, v) {
+ data->normals[v].low = GPU_normal_convert_i10_v3(bm_vert_no_get(mr, eve));
+ }
+ }
+ else {
+ const MVert *mv = mr->mvert;
+ for (int v = 0; v < mr->vert_len; v++, mv++) {
+ data->normals[v].low = GPU_normal_convert_i10_s3(mv->no);
+ }
+ }
+}
+
+static void extract_pos_nor_iter_poly_bm(const MeshRenderData *mr,
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *_data)
+{
+ MeshExtract_PosNor_Data *data = static_cast<MeshExtract_PosNor_Data *>(_data);
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+ PosNorLoop *vert = &data->vbo_data[l_index];
+ copy_v3_v3(vert->pos, bm_vert_co_get(mr, l_iter->v));
+ vert->nor = data->normals[BM_elem_index_get(l_iter->v)].low;
+ vert->nor.w = BM_elem_flag_test(f, BM_ELEM_HIDDEN) ? -1 : 0;
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_pos_nor_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int UNUSED(mp_index),
+ void *_data)
+{
+ MeshExtract_PosNor_Data *data = static_cast<MeshExtract_PosNor_Data *>(_data);
+
+ const MLoop *mloop = mr->mloop;
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+
+ PosNorLoop *vert = &data->vbo_data[ml_index];
+ const MVert *mv = &mr->mvert[ml->v];
+ copy_v3_v3(vert->pos, mv->co);
+ vert->nor = data->normals[ml->v].low;
+ /* Flag for paint mode overlay. */
+ if (mp->flag & ME_HIDE || mv->flag & ME_HIDE ||
+ ((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->v_origindex) &&
+ (mr->v_origindex[ml->v] == ORIGINDEX_NONE))) {
+ vert->nor.w = -1;
+ }
+ else if (mv->flag & SELECT) {
+ vert->nor.w = 1;
+ }
+ else {
+ vert->nor.w = 0;
+ }
+ }
+}
+
+static void extract_pos_nor_iter_ledge_bm(const MeshRenderData *mr,
+ const BMEdge *eed,
+ const int ledge_index,
+ void *_data)
+{
+ MeshExtract_PosNor_Data *data = static_cast<MeshExtract_PosNor_Data *>(_data);
+
+ int l_index = mr->loop_len + ledge_index * 2;
+ PosNorLoop *vert = &data->vbo_data[l_index];
+ copy_v3_v3(vert[0].pos, bm_vert_co_get(mr, eed->v1));
+ copy_v3_v3(vert[1].pos, bm_vert_co_get(mr, eed->v2));
+ vert[0].nor = data->normals[BM_elem_index_get(eed->v1)].low;
+ vert[1].nor = data->normals[BM_elem_index_get(eed->v2)].low;
+}
+
+static void extract_pos_nor_iter_ledge_mesh(const MeshRenderData *mr,
+ const MEdge *med,
+ const int ledge_index,
+ void *_data)
+{
+ MeshExtract_PosNor_Data *data = static_cast<MeshExtract_PosNor_Data *>(_data);
+ const int ml_index = mr->loop_len + ledge_index * 2;
+ PosNorLoop *vert = &data->vbo_data[ml_index];
+ copy_v3_v3(vert[0].pos, mr->mvert[med->v1].co);
+ copy_v3_v3(vert[1].pos, mr->mvert[med->v2].co);
+ vert[0].nor = data->normals[med->v1].low;
+ vert[1].nor = data->normals[med->v2].low;
+}
+
+static void extract_pos_nor_iter_lvert_bm(const MeshRenderData *mr,
+ const BMVert *eve,
+ const int lvert_index,
+ void *_data)
+{
+ MeshExtract_PosNor_Data *data = static_cast<MeshExtract_PosNor_Data *>(_data);
+ const int offset = mr->loop_len + (mr->edge_loose_len * 2);
+
+ const int l_index = offset + lvert_index;
+ PosNorLoop *vert = &data->vbo_data[l_index];
+ copy_v3_v3(vert->pos, bm_vert_co_get(mr, eve));
+ vert->nor = data->normals[BM_elem_index_get(eve)].low;
+}
+
+static void extract_pos_nor_iter_lvert_mesh(const MeshRenderData *mr,
+ const MVert *mv,
+ const int lvert_index,
+ void *_data)
+{
+ MeshExtract_PosNor_Data *data = static_cast<MeshExtract_PosNor_Data *>(_data);
+ const int offset = mr->loop_len + (mr->edge_loose_len * 2);
+
+ const int ml_index = offset + lvert_index;
+ const int v_index = mr->lverts[lvert_index];
+ PosNorLoop *vert = &data->vbo_data[ml_index];
+ copy_v3_v3(vert->pos, mv->co);
+ vert->nor = data->normals[v_index].low;
+}
+
+static void extract_pos_nor_finish(const MeshRenderData *UNUSED(mr),
+ struct MeshBatchCache *UNUSED(cache),
+ void *UNUSED(buf),
+ void *_data)
+{
+ MeshExtract_PosNor_Data *data = static_cast<MeshExtract_PosNor_Data *>(_data);
+ MEM_freeN(data->normals);
+}
+
+constexpr MeshExtract create_extractor_pos_nor()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_pos_nor_init;
+ extractor.iter_poly_bm = extract_pos_nor_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_pos_nor_iter_poly_mesh;
+ extractor.iter_ledge_bm = extract_pos_nor_iter_ledge_bm;
+ extractor.iter_ledge_mesh = extract_pos_nor_iter_ledge_mesh;
+ extractor.iter_lvert_bm = extract_pos_nor_iter_lvert_bm;
+ extractor.iter_lvert_mesh = extract_pos_nor_iter_lvert_mesh;
+ extractor.finish = extract_pos_nor_finish;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(MeshExtract_PosNor_Data);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.pos_nor);
+ return extractor;
+}
+
+/** \} */
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Position and High Quality Vertex Normal
+ * \{ */
+
+struct PosNorHQLoop {
+ float pos[3];
+ short nor[4];
+};
+
+struct MeshExtract_PosNorHQ_Data {
+ PosNorHQLoop *vbo_data;
+ GPUNormal *normals;
+};
+
+static void extract_pos_nor_hq_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ /* WARNING Adjust #PosNorHQLoop struct accordingly. */
+ GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ GPU_vertformat_alias_add(&format, "vnor");
+ }
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
+
+ /* Pack normals per vert, reduce amount of computation. */
+ MeshExtract_PosNorHQ_Data *data = static_cast<MeshExtract_PosNorHQ_Data *>(tls_data);
+ data->vbo_data = static_cast<PosNorHQLoop *>(GPU_vertbuf_get_data(vbo));
+ data->normals = (GPUNormal *)MEM_mallocN(sizeof(GPUNormal) * mr->vert_len, __func__);
+
+ /* Quicker than doing it for each loop. */
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ BMIter iter;
+ BMVert *eve;
+ int v;
+ BM_ITER_MESH_INDEX (eve, &iter, mr->bm, BM_VERTS_OF_MESH, v) {
+ normal_float_to_short_v3(data->normals[v].high, bm_vert_no_get(mr, eve));
+ }
+ }
+ else {
+ const MVert *mv = mr->mvert;
+ for (int v = 0; v < mr->vert_len; v++, mv++) {
+ copy_v3_v3_short(data->normals[v].high, mv->no);
+ }
+ }
+}
+
+static void extract_pos_nor_hq_iter_poly_bm(const MeshRenderData *mr,
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *_data)
+{
+ MeshExtract_PosNorHQ_Data *data = static_cast<MeshExtract_PosNorHQ_Data *>(_data);
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+ PosNorHQLoop *vert = &data->vbo_data[l_index];
+ copy_v3_v3(vert->pos, bm_vert_co_get(mr, l_iter->v));
+ copy_v3_v3_short(vert->nor, data->normals[BM_elem_index_get(l_iter->v)].high);
+
+ vert->nor[3] = BM_elem_flag_test(f, BM_ELEM_HIDDEN) ? -1 : 0;
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_pos_nor_hq_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int UNUSED(mp_index),
+ void *_data)
+{
+ MeshExtract_PosNorHQ_Data *data = static_cast<MeshExtract_PosNorHQ_Data *>(_data);
+ const MLoop *mloop = mr->mloop;
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+
+ PosNorHQLoop *vert = &data->vbo_data[ml_index];
+ const MVert *mv = &mr->mvert[ml->v];
+ copy_v3_v3(vert->pos, mv->co);
+ copy_v3_v3_short(vert->nor, data->normals[ml->v].high);
+
+ /* Flag for paint mode overlay. */
+ if (mp->flag & ME_HIDE || mv->flag & ME_HIDE ||
+ ((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->v_origindex) &&
+ (mr->v_origindex[ml->v] == ORIGINDEX_NONE))) {
+ vert->nor[3] = -1;
+ }
+ else if (mv->flag & SELECT) {
+ vert->nor[3] = 1;
+ }
+ else {
+ vert->nor[3] = 0;
+ }
+ }
+}
+
+static void extract_pos_nor_hq_iter_ledge_bm(const MeshRenderData *mr,
+ const BMEdge *eed,
+ const int ledge_index,
+ void *_data)
+{
+ MeshExtract_PosNorHQ_Data *data = static_cast<MeshExtract_PosNorHQ_Data *>(_data);
+ int l_index = mr->loop_len + ledge_index * 2;
+ PosNorHQLoop *vert = &data->vbo_data[l_index];
+ copy_v3_v3(vert[0].pos, bm_vert_co_get(mr, eed->v1));
+ copy_v3_v3(vert[1].pos, bm_vert_co_get(mr, eed->v2));
+ copy_v3_v3_short(vert[0].nor, data->normals[BM_elem_index_get(eed->v1)].high);
+ vert[0].nor[3] = 0;
+ copy_v3_v3_short(vert[1].nor, data->normals[BM_elem_index_get(eed->v2)].high);
+ vert[1].nor[3] = 0;
+}
+
+static void extract_pos_nor_hq_iter_ledge_mesh(const MeshRenderData *mr,
+ const MEdge *med,
+ const int ledge_index,
+ void *_data)
+{
+ MeshExtract_PosNorHQ_Data *data = static_cast<MeshExtract_PosNorHQ_Data *>(_data);
+ const int ml_index = mr->loop_len + ledge_index * 2;
+ PosNorHQLoop *vert = &data->vbo_data[ml_index];
+ copy_v3_v3(vert[0].pos, mr->mvert[med->v1].co);
+ copy_v3_v3(vert[1].pos, mr->mvert[med->v2].co);
+ copy_v3_v3_short(vert[0].nor, data->normals[med->v1].high);
+ vert[0].nor[3] = 0;
+ copy_v3_v3_short(vert[1].nor, data->normals[med->v2].high);
+ vert[1].nor[3] = 0;
+}
+
+static void extract_pos_nor_hq_iter_lvert_bm(const MeshRenderData *mr,
+ const BMVert *eve,
+ const int lvert_index,
+ void *_data)
+{
+ MeshExtract_PosNorHQ_Data *data = static_cast<MeshExtract_PosNorHQ_Data *>(_data);
+ const int offset = mr->loop_len + (mr->edge_loose_len * 2);
+
+ const int l_index = offset + lvert_index;
+ PosNorHQLoop *vert = &data->vbo_data[l_index];
+ copy_v3_v3(vert->pos, bm_vert_co_get(mr, eve));
+ copy_v3_v3_short(vert->nor, data->normals[BM_elem_index_get(eve)].high);
+ vert->nor[3] = 0;
+}
+
+static void extract_pos_nor_hq_iter_lvert_mesh(const MeshRenderData *mr,
+ const MVert *mv,
+ const int lvert_index,
+ void *_data)
+{
+ MeshExtract_PosNorHQ_Data *data = static_cast<MeshExtract_PosNorHQ_Data *>(_data);
+ const int offset = mr->loop_len + (mr->edge_loose_len * 2);
+
+ const int ml_index = offset + lvert_index;
+ const int v_index = mr->lverts[lvert_index];
+ PosNorHQLoop *vert = &data->vbo_data[ml_index];
+ copy_v3_v3(vert->pos, mv->co);
+ copy_v3_v3_short(vert->nor, data->normals[v_index].high);
+ vert->nor[3] = 0;
+}
+
+static void extract_pos_nor_hq_finish(const MeshRenderData *UNUSED(mr),
+ struct MeshBatchCache *UNUSED(cache),
+ void *UNUSED(buf),
+ void *_data)
+{
+ MeshExtract_PosNorHQ_Data *data = static_cast<MeshExtract_PosNorHQ_Data *>(_data);
+ MEM_freeN(data->normals);
+}
+
+constexpr MeshExtract create_extractor_pos_nor_hq()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_pos_nor_hq_init;
+ extractor.iter_poly_bm = extract_pos_nor_hq_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_pos_nor_hq_iter_poly_mesh;
+ extractor.iter_ledge_bm = extract_pos_nor_hq_iter_ledge_bm;
+ extractor.iter_ledge_mesh = extract_pos_nor_hq_iter_ledge_mesh;
+ extractor.iter_lvert_bm = extract_pos_nor_hq_iter_lvert_bm;
+ extractor.iter_lvert_mesh = extract_pos_nor_hq_iter_lvert_mesh;
+ extractor.finish = extract_pos_nor_hq_finish;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(MeshExtract_PosNorHQ_Data);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.pos_nor);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_pos_nor = blender::draw::create_extractor_pos_nor();
+const MeshExtract extract_pos_nor_hq = blender::draw::create_extractor_pos_nor_hq();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc
new file mode 100644
index 00000000000..7b36a009419
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc
@@ -0,0 +1,141 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_string.h"
+
+#include "BKE_paint.h"
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Sculpt Data
+ * \{ */
+
+static void extract_sculpt_data_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *UNUSED(tls_data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ GPUVertFormat format = {0};
+
+ CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
+ CustomData *cd_vdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->vdata : &mr->me->vdata;
+ CustomData *cd_pdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->pdata : &mr->me->pdata;
+
+ float *cd_mask = (float *)CustomData_get_layer(cd_vdata, CD_PAINT_MASK);
+ int *cd_face_set = (int *)CustomData_get_layer(cd_pdata, CD_SCULPT_FACE_SETS);
+
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "fset", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ GPU_vertformat_attr_add(&format, "msk", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len);
+
+ struct gpuSculptData {
+ uint8_t face_set_color[4];
+ float mask;
+ };
+
+ gpuSculptData *vbo_data = (gpuSculptData *)GPU_vertbuf_get_data(vbo);
+ MLoop *loops = (MLoop *)CustomData_get_layer(cd_ldata, CD_MLOOP);
+
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ int cd_mask_ofs = CustomData_get_offset(cd_vdata, CD_PAINT_MASK);
+ int cd_face_set_ofs = CustomData_get_offset(cd_pdata, CD_SCULPT_FACE_SETS);
+ BMIter f_iter;
+ BMFace *efa;
+ BM_ITER_MESH (efa, &f_iter, mr->bm, BM_FACES_OF_MESH) {
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
+ do {
+ float v_mask = 0.0f;
+ if (cd_mask) {
+ v_mask = BM_ELEM_CD_GET_FLOAT(l_iter->v, cd_mask_ofs);
+ }
+ vbo_data->mask = v_mask;
+ uchar face_set_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
+ if (cd_face_set) {
+ const int face_set_id = BM_ELEM_CD_GET_INT(l_iter->f, cd_face_set_ofs);
+ if (face_set_id != mr->me->face_sets_color_default) {
+ BKE_paint_face_set_overlay_color_get(
+ face_set_id, mr->me->face_sets_color_seed, face_set_color);
+ }
+ }
+ copy_v3_v3_uchar(vbo_data->face_set_color, face_set_color);
+ vbo_data++;
+ } while ((l_iter = l_iter->next) != l_first);
+ }
+ }
+ else {
+ int mp_loop = 0;
+ for (int mp_index = 0; mp_index < mr->poly_len; mp_index++) {
+ const MPoly *p = &mr->mpoly[mp_index];
+ for (int l = 0; l < p->totloop; l++) {
+ float v_mask = 0.0f;
+ if (cd_mask) {
+ v_mask = cd_mask[loops[mp_loop].v];
+ }
+ vbo_data->mask = v_mask;
+
+ uchar face_set_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
+ if (cd_face_set) {
+ const int face_set_id = cd_face_set[mp_index];
+ /* Skip for the default color Face Set to render it white. */
+ if (face_set_id != mr->me->face_sets_color_default) {
+ BKE_paint_face_set_overlay_color_get(
+ face_set_id, mr->me->face_sets_color_seed, face_set_color);
+ }
+ }
+ copy_v3_v3_uchar(vbo_data->face_set_color, face_set_color);
+ mp_loop++;
+ vbo_data++;
+ }
+ }
+ }
+}
+
+constexpr MeshExtract create_extractor_sculpt_data()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_sculpt_data_init;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = 0;
+ extractor.use_threading = false;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.sculpt_data);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_sculpt_data = blender::draw::create_extractor_sculpt_data();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_select_idx.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_select_idx.cc
new file mode 100644
index 00000000000..5c78cc0b731
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_select_idx.cc
@@ -0,0 +1,295 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Selection Index
+ * \{ */
+
+static void extract_select_idx_init_impl(const MeshRenderData *UNUSED(mr),
+ const int len,
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ /* TODO rename "color" to something more descriptive. */
+ GPU_vertformat_attr_add(&format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT);
+ }
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, len);
+ *(uint32_t **)tls_data = (uint32_t *)GPU_vertbuf_get_data(vbo);
+}
+
+static void extract_select_idx_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ extract_select_idx_init_impl(mr, mr->loop_len + mr->loop_loose_len, buf, tls_data);
+}
+
+/* TODO Use #glVertexID to get loop index and use the data structure on the CPU to retrieve the
+ * select element associated with this loop ID. This would remove the need for this separate
+ * index VBO's. We could upload the p/e/v_origindex as a buffer texture and sample it inside the
+ * shader to output original index. */
+
+static void extract_poly_idx_iter_poly_bm(const MeshRenderData *UNUSED(mr),
+ const BMFace *f,
+ const int f_index,
+ void *data)
+{
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+ (*(uint32_t **)data)[l_index] = f_index;
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_edge_idx_iter_poly_bm(const MeshRenderData *UNUSED(mr),
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *data)
+{
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+ (*(uint32_t **)data)[l_index] = BM_elem_index_get(l_iter->e);
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_vert_idx_iter_poly_bm(const MeshRenderData *UNUSED(mr),
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *data)
+{
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+ (*(uint32_t **)data)[l_index] = BM_elem_index_get(l_iter->v);
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_edge_idx_iter_ledge_bm(const MeshRenderData *mr,
+ const BMEdge *eed,
+ const int ledge_index,
+ void *data)
+{
+ (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 0] = BM_elem_index_get(eed);
+ (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 1] = BM_elem_index_get(eed);
+}
+
+static void extract_vert_idx_iter_ledge_bm(const MeshRenderData *mr,
+ const BMEdge *eed,
+ const int ledge_index,
+ void *data)
+{
+ (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 0] = BM_elem_index_get(eed->v1);
+ (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 1] = BM_elem_index_get(eed->v2);
+}
+
+static void extract_vert_idx_iter_lvert_bm(const MeshRenderData *mr,
+ const BMVert *eve,
+ const int lvert_index,
+ void *data)
+{
+ const int offset = mr->loop_len + (mr->edge_loose_len * 2);
+
+ (*(uint32_t **)data)[offset + lvert_index] = BM_elem_index_get(eve);
+}
+
+static void extract_poly_idx_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int mp_index,
+ void *data)
+{
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ (*(uint32_t **)data)[ml_index] = (mr->p_origindex) ? mr->p_origindex[mp_index] : mp_index;
+ }
+}
+
+static void extract_edge_idx_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int UNUSED(mp_index),
+ void *data)
+{
+ const MLoop *mloop = mr->mloop;
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+ (*(uint32_t **)data)[ml_index] = (mr->e_origindex) ? mr->e_origindex[ml->e] : ml->e;
+ }
+}
+
+static void extract_vert_idx_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int UNUSED(mp_index),
+ void *data)
+{
+ const MLoop *mloop = mr->mloop;
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+ (*(uint32_t **)data)[ml_index] = (mr->v_origindex) ? mr->v_origindex[ml->v] : ml->v;
+ }
+}
+
+static void extract_edge_idx_iter_ledge_mesh(const MeshRenderData *mr,
+ const MEdge *UNUSED(med),
+ const int ledge_index,
+ void *data)
+{
+ const int e_index = mr->ledges[ledge_index];
+ const int e_orig = (mr->e_origindex) ? mr->e_origindex[e_index] : e_index;
+ (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 0] = e_orig;
+ (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 1] = e_orig;
+}
+
+static void extract_vert_idx_iter_ledge_mesh(const MeshRenderData *mr,
+ const MEdge *med,
+ const int ledge_index,
+ void *data)
+{
+ int v1_orig = (mr->v_origindex) ? mr->v_origindex[med->v1] : med->v1;
+ int v2_orig = (mr->v_origindex) ? mr->v_origindex[med->v2] : med->v2;
+ (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 0] = v1_orig;
+ (*(uint32_t **)data)[mr->loop_len + ledge_index * 2 + 1] = v2_orig;
+}
+
+static void extract_vert_idx_iter_lvert_mesh(const MeshRenderData *mr,
+ const MVert *UNUSED(mv),
+ const int lvert_index,
+ void *data)
+{
+ const int offset = mr->loop_len + (mr->edge_loose_len * 2);
+
+ const int v_index = mr->lverts[lvert_index];
+ const int v_orig = (mr->v_origindex) ? mr->v_origindex[v_index] : v_index;
+ (*(uint32_t **)data)[offset + lvert_index] = v_orig;
+}
+
+constexpr MeshExtract create_extractor_poly_idx()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_select_idx_init;
+ extractor.iter_poly_bm = extract_poly_idx_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_poly_idx_iter_poly_mesh;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(uint32_t *);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.poly_idx);
+ return extractor;
+}
+
+constexpr MeshExtract create_extractor_edge_idx()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_select_idx_init;
+ extractor.iter_poly_bm = extract_edge_idx_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_edge_idx_iter_poly_mesh;
+ extractor.iter_ledge_bm = extract_edge_idx_iter_ledge_bm;
+ extractor.iter_ledge_mesh = extract_edge_idx_iter_ledge_mesh;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(uint32_t *);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.edge_idx);
+ return extractor;
+}
+
+constexpr MeshExtract create_extractor_vert_idx()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_select_idx_init;
+ extractor.iter_poly_bm = extract_vert_idx_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_vert_idx_iter_poly_mesh;
+ extractor.iter_ledge_bm = extract_vert_idx_iter_ledge_bm;
+ extractor.iter_ledge_mesh = extract_vert_idx_iter_ledge_mesh;
+ extractor.iter_lvert_bm = extract_vert_idx_iter_lvert_bm;
+ extractor.iter_lvert_mesh = extract_vert_idx_iter_lvert_mesh;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(uint32_t *);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.vert_idx);
+ return extractor;
+}
+
+static void extract_fdot_idx_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *tls_data)
+{
+ extract_select_idx_init_impl(mr, mr->poly_len, buf, tls_data);
+}
+
+static void extract_fdot_idx_iter_poly_bm(const MeshRenderData *UNUSED(mr),
+ const BMFace *UNUSED(f),
+ const int f_index,
+ void *data)
+{
+ (*(uint32_t **)data)[f_index] = f_index;
+}
+
+static void extract_fdot_idx_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *UNUSED(mp),
+ const int mp_index,
+ void *data)
+{
+ if (mr->p_origindex != nullptr) {
+ (*(uint32_t **)data)[mp_index] = mr->p_origindex[mp_index];
+ }
+ else {
+ (*(uint32_t **)data)[mp_index] = mp_index;
+ }
+}
+
+constexpr MeshExtract create_extractor_fdot_idx()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_fdot_idx_init;
+ extractor.iter_poly_bm = extract_fdot_idx_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_fdot_idx_iter_poly_mesh;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(uint32_t *);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.fdot_idx);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_poly_idx = blender::draw::create_extractor_poly_idx();
+const MeshExtract extract_edge_idx = blender::draw::create_extractor_edge_idx();
+const MeshExtract extract_vert_idx = blender::draw::create_extractor_vert_idx();
+const MeshExtract extract_fdot_idx = blender::draw::create_extractor_fdot_idx();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_skin_roots.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_skin_roots.cc
new file mode 100644
index 00000000000..d7a01ee607f
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_skin_roots.cc
@@ -0,0 +1,93 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Skin Modifier Roots
+ * \{ */
+
+struct SkinRootData {
+ float size;
+ float local_pos[3];
+};
+
+static void extract_skin_roots_init(const MeshRenderData *mr,
+ struct MeshBatchCache *UNUSED(cache),
+ void *buf,
+ void *UNUSED(tls_data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ /* Exclusively for edit mode. */
+ BLI_assert(mr->bm);
+
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ GPU_vertformat_attr_add(&format, "local_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->bm->totvert);
+
+ SkinRootData *vbo_data = (SkinRootData *)GPU_vertbuf_get_data(vbo);
+
+ int root_len = 0;
+ int cd_ofs = CustomData_get_offset(&mr->bm->vdata, CD_MVERT_SKIN);
+
+ BMIter iter;
+ BMVert *eve;
+ BM_ITER_MESH (eve, &iter, mr->bm, BM_VERTS_OF_MESH) {
+ const MVertSkin *vs = (const MVertSkin *)BM_ELEM_CD_GET_VOID_P(eve, cd_ofs);
+ if (vs->flag & MVERT_SKIN_ROOT) {
+ vbo_data->size = (vs->radius[0] + vs->radius[1]) * 0.5f;
+ copy_v3_v3(vbo_data->local_pos, bm_vert_co_get(mr, eve));
+ vbo_data++;
+ root_len++;
+ }
+ }
+
+ /* It's really unlikely that all verts will be roots. Resize to avoid losing VRAM. */
+ GPU_vertbuf_data_len_set(vbo, root_len);
+}
+
+constexpr MeshExtract create_extractor_skin_roots()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_skin_roots_init;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = 0;
+ extractor.use_threading = false;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.skin_roots);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_skin_roots = blender::draw::create_extractor_skin_roots();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc
new file mode 100644
index 00000000000..f251141c442
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc
@@ -0,0 +1,266 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_string.h"
+
+#include "BKE_editmesh.h"
+#include "BKE_editmesh_tangent.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_tangent.h"
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Tangent layers
+ * \{ */
+
+static void extract_tan_ex_init(const MeshRenderData *mr,
+ struct MeshBatchCache *cache,
+ GPUVertBuf *vbo,
+ const bool do_hq)
+{
+ GPUVertCompType comp_type = do_hq ? GPU_COMP_I16 : GPU_COMP_I10;
+ GPUVertFetchMode fetch_mode = GPU_FETCH_INT_TO_FLOAT_UNIT;
+
+ GPUVertFormat format = {0};
+ GPU_vertformat_deinterleave(&format);
+
+ CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
+ CustomData *cd_vdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->vdata : &mr->me->vdata;
+ uint32_t tan_layers = cache->cd_used.tan;
+ float(*orco)[3] = (float(*)[3])CustomData_get_layer(cd_vdata, CD_ORCO);
+ bool orco_allocated = false;
+ const bool use_orco_tan = cache->cd_used.tan_orco != 0;
+
+ int tan_len = 0;
+ char tangent_names[MAX_MTFACE][MAX_CUSTOMDATA_LAYER_NAME];
+
+ for (int i = 0; i < MAX_MTFACE; i++) {
+ if (tan_layers & (1 << i)) {
+ char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
+ const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i);
+ GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
+ /* Tangent layer name. */
+ BLI_snprintf(attr_name, sizeof(attr_name), "t%s", attr_safe_name);
+ GPU_vertformat_attr_add(&format, attr_name, comp_type, 4, fetch_mode);
+ /* Active render layer name. */
+ if (i == CustomData_get_render_layer(cd_ldata, CD_MLOOPUV)) {
+ GPU_vertformat_alias_add(&format, "t");
+ }
+ /* Active display layer name. */
+ if (i == CustomData_get_active_layer(cd_ldata, CD_MLOOPUV)) {
+ GPU_vertformat_alias_add(&format, "at");
+ }
+
+ BLI_strncpy(tangent_names[tan_len++], layer_name, MAX_CUSTOMDATA_LAYER_NAME);
+ }
+ }
+ if (use_orco_tan && orco == nullptr) {
+ /* If `orco` is not available compute it ourselves */
+ orco_allocated = true;
+ orco = (float(*)[3])MEM_mallocN(sizeof(*orco) * mr->vert_len, __func__);
+
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ BMesh *bm = mr->bm;
+ for (int v = 0; v < mr->vert_len; v++) {
+ const BMVert *eve = BM_vert_at_index(bm, v);
+ /* Exceptional case where #bm_vert_co_get can be avoided, as we want the original coords.
+ * not the distorted ones. */
+ copy_v3_v3(orco[v], eve->co);
+ }
+ }
+ else {
+ const MVert *mv = mr->mvert;
+ for (int v = 0; v < mr->vert_len; v++, mv++) {
+ copy_v3_v3(orco[v], mv->co);
+ }
+ }
+ BKE_mesh_orco_verts_transform(mr->me, orco, mr->vert_len, 0);
+ }
+
+ /* Start Fresh */
+ CustomData loop_data;
+ CustomData_reset(&loop_data);
+ if (tan_len != 0 || use_orco_tan) {
+ short tangent_mask = 0;
+ bool calc_active_tangent = false;
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ BKE_editmesh_loop_tangent_calc(mr->edit_bmesh,
+ calc_active_tangent,
+ tangent_names,
+ tan_len,
+ mr->poly_normals,
+ mr->loop_normals,
+ orco,
+ &loop_data,
+ mr->loop_len,
+ &tangent_mask);
+ }
+ else {
+ BKE_mesh_calc_loop_tangent_ex(mr->mvert,
+ mr->mpoly,
+ mr->poly_len,
+ mr->mloop,
+ mr->mlooptri,
+ mr->tri_len,
+ cd_ldata,
+ calc_active_tangent,
+ tangent_names,
+ tan_len,
+ mr->poly_normals,
+ mr->loop_normals,
+ orco,
+ &loop_data,
+ mr->loop_len,
+ &tangent_mask);
+ }
+ }
+
+ if (use_orco_tan) {
+ char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
+ const char *layer_name = CustomData_get_layer_name(&loop_data, CD_TANGENT, 0);
+ GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
+ BLI_snprintf(attr_name, sizeof(*attr_name), "t%s", attr_safe_name);
+ GPU_vertformat_attr_add(&format, attr_name, comp_type, 4, fetch_mode);
+ GPU_vertformat_alias_add(&format, "t");
+ GPU_vertformat_alias_add(&format, "at");
+ }
+
+ if (orco_allocated) {
+ MEM_SAFE_FREE(orco);
+ }
+
+ int v_len = mr->loop_len;
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ /* VBO will not be used, only allocate minimum of memory. */
+ v_len = 1;
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, v_len);
+
+ if (do_hq) {
+ short(*tan_data)[4] = (short(*)[4])GPU_vertbuf_get_data(vbo);
+ for (int i = 0; i < tan_len; i++) {
+ const char *name = tangent_names[i];
+ float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_named(
+ &loop_data, CD_TANGENT, name);
+ for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) {
+ normal_float_to_short_v3(*tan_data, layer_data[ml_index]);
+ (*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? SHRT_MAX : SHRT_MIN;
+ tan_data++;
+ }
+ }
+ if (use_orco_tan) {
+ float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_n(&loop_data, CD_TANGENT, 0);
+ for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) {
+ normal_float_to_short_v3(*tan_data, layer_data[ml_index]);
+ (*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? SHRT_MAX : SHRT_MIN;
+ tan_data++;
+ }
+ }
+ }
+ else {
+ GPUPackedNormal *tan_data = (GPUPackedNormal *)GPU_vertbuf_get_data(vbo);
+ for (int i = 0; i < tan_len; i++) {
+ const char *name = tangent_names[i];
+ float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_named(
+ &loop_data, CD_TANGENT, name);
+ for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) {
+ *tan_data = GPU_normal_convert_i10_v3(layer_data[ml_index]);
+ tan_data->w = (layer_data[ml_index][3] > 0.0f) ? 1 : -2;
+ tan_data++;
+ }
+ }
+ if (use_orco_tan) {
+ float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_n(&loop_data, CD_TANGENT, 0);
+ for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) {
+ *tan_data = GPU_normal_convert_i10_v3(layer_data[ml_index]);
+ tan_data->w = (layer_data[ml_index][3] > 0.0f) ? 1 : -2;
+ tan_data++;
+ }
+ }
+ }
+
+ CustomData_free(&loop_data, mr->loop_len);
+}
+
+static void extract_tan_init(const MeshRenderData *mr,
+ struct MeshBatchCache *cache,
+ void *buf,
+ void *UNUSED(tls_data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ extract_tan_ex_init(mr, cache, vbo, false);
+}
+
+constexpr MeshExtract create_extractor_tan()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_tan_init;
+ extractor.data_type = MR_DATA_POLY_NOR | MR_DATA_TAN_LOOP_NOR | MR_DATA_LOOPTRI;
+ extractor.data_size = 0;
+ extractor.use_threading = false;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.tan);
+ return extractor;
+}
+
+/** \} */
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract HQ Tangent layers
+ * \{ */
+
+static void extract_tan_hq_init(const MeshRenderData *mr,
+ struct MeshBatchCache *cache,
+ void *buf,
+ void *UNUSED(tls_data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ extract_tan_ex_init(mr, cache, vbo, true);
+}
+
+constexpr MeshExtract create_extractor_tan_hq()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_tan_hq_init;
+ extractor.data_type = MR_DATA_POLY_NOR | MR_DATA_TAN_LOOP_NOR | MR_DATA_LOOPTRI;
+ extractor.data_size = 0;
+ extractor.use_threading = false;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.tan);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_tan = blender::draw::create_extractor_tan();
+const MeshExtract extract_tan_hq = blender::draw::create_extractor_tan_hq();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc
new file mode 100644
index 00000000000..0f3c2483296
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc
@@ -0,0 +1,136 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "BLI_string.h"
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract UV layers
+ * \{ */
+
+static void extract_uv_init(const MeshRenderData *mr,
+ struct MeshBatchCache *cache,
+ void *buf,
+ void *UNUSED(tls_data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ GPUVertFormat format = {0};
+ GPU_vertformat_deinterleave(&format);
+
+ CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
+ uint32_t uv_layers = cache->cd_used.uv;
+ /* HACK to fix T68857 */
+ if (mr->extract_type == MR_EXTRACT_BMESH && cache->cd_used.edit_uv == 1) {
+ int layer = CustomData_get_active_layer(cd_ldata, CD_MLOOPUV);
+ if (layer != -1) {
+ uv_layers |= (1 << layer);
+ }
+ }
+
+ for (int i = 0; i < MAX_MTFACE; i++) {
+ if (uv_layers & (1 << i)) {
+ char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
+ const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i);
+
+ GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
+ /* UV layer name. */
+ BLI_snprintf(attr_name, sizeof(attr_name), "u%s", attr_safe_name);
+ GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ /* Auto layer name. */
+ BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name);
+ GPU_vertformat_alias_add(&format, attr_name);
+ /* Active render layer name. */
+ if (i == CustomData_get_render_layer(cd_ldata, CD_MLOOPUV)) {
+ GPU_vertformat_alias_add(&format, "u");
+ }
+ /* Active display layer name. */
+ if (i == CustomData_get_active_layer(cd_ldata, CD_MLOOPUV)) {
+ GPU_vertformat_alias_add(&format, "au");
+ /* Alias to `pos` for edit uvs. */
+ GPU_vertformat_alias_add(&format, "pos");
+ }
+ /* Stencil mask uv layer name. */
+ if (i == CustomData_get_stencil_layer(cd_ldata, CD_MLOOPUV)) {
+ GPU_vertformat_alias_add(&format, "mu");
+ }
+ }
+ }
+
+ int v_len = mr->loop_len;
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ /* VBO will not be used, only allocate minimum of memory. */
+ v_len = 1;
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, v_len);
+
+ float(*uv_data)[2] = (float(*)[2])GPU_vertbuf_get_data(vbo);
+ for (int i = 0; i < MAX_MTFACE; i++) {
+ if (uv_layers & (1 << i)) {
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ int cd_ofs = CustomData_get_n_offset(cd_ldata, CD_MLOOPUV, i);
+ BMIter f_iter;
+ BMFace *efa;
+ BM_ITER_MESH (efa, &f_iter, mr->bm, BM_FACES_OF_MESH) {
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
+ do {
+ MLoopUV *luv = (MLoopUV *)BM_ELEM_CD_GET_VOID_P(l_iter, cd_ofs);
+ memcpy(uv_data, luv->uv, sizeof(*uv_data));
+ uv_data++;
+ } while ((l_iter = l_iter->next) != l_first);
+ }
+ }
+ else {
+ MLoopUV *layer_data = (MLoopUV *)CustomData_get_layer_n(cd_ldata, CD_MLOOPUV, i);
+ for (int ml_index = 0; ml_index < mr->loop_len; ml_index++, uv_data++, layer_data++) {
+ memcpy(uv_data, layer_data->uv, sizeof(*uv_data));
+ }
+ }
+ }
+ }
+}
+
+constexpr MeshExtract create_extractor_uv()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_uv_init;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = 0;
+ extractor.use_threading = false;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.uv);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_uv = blender::draw::create_extractor_uv();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc
new file mode 100644
index 00000000000..2f1cff08796
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc
@@ -0,0 +1,191 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_string.h"
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract VCol
+ * \{ */
+
+static void extract_vcol_init(const MeshRenderData *mr,
+ struct MeshBatchCache *cache,
+ void *buf,
+ void *UNUSED(tls_data))
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ GPUVertFormat format = {0};
+ GPU_vertformat_deinterleave(&format);
+
+ CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
+ CustomData *cd_vdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->vdata : &mr->me->vdata;
+ uint32_t vcol_layers = cache->cd_used.vcol;
+ uint32_t svcol_layers = cache->cd_used.sculpt_vcol;
+
+ for (int i = 0; i < MAX_MCOL; i++) {
+ if (vcol_layers & (1 << i)) {
+ char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
+ const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPCOL, i);
+ GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
+
+ BLI_snprintf(attr_name, sizeof(attr_name), "c%s", attr_safe_name);
+ GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+
+ if (i == CustomData_get_render_layer(cd_ldata, CD_MLOOPCOL)) {
+ GPU_vertformat_alias_add(&format, "c");
+ }
+ if (i == CustomData_get_active_layer(cd_ldata, CD_MLOOPCOL)) {
+ GPU_vertformat_alias_add(&format, "ac");
+ }
+
+ /* Gather number of auto layers. */
+ /* We only do `vcols` that are not overridden by `uvs` and sculpt vertex colors. */
+ if (CustomData_get_named_layer_index(cd_ldata, CD_MLOOPUV, layer_name) == -1 &&
+ CustomData_get_named_layer_index(cd_vdata, CD_PROP_COLOR, layer_name) == -1) {
+ BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name);
+ GPU_vertformat_alias_add(&format, attr_name);
+ }
+ }
+ }
+
+ /* Sculpt Vertex Colors */
+ if (U.experimental.use_sculpt_vertex_colors) {
+ for (int i = 0; i < 8; i++) {
+ if (svcol_layers & (1 << i)) {
+ char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
+ const char *layer_name = CustomData_get_layer_name(cd_vdata, CD_PROP_COLOR, i);
+ GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
+
+ BLI_snprintf(attr_name, sizeof(attr_name), "c%s", attr_safe_name);
+ GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+
+ if (i == CustomData_get_render_layer(cd_vdata, CD_PROP_COLOR)) {
+ GPU_vertformat_alias_add(&format, "c");
+ }
+ if (i == CustomData_get_active_layer(cd_vdata, CD_PROP_COLOR)) {
+ GPU_vertformat_alias_add(&format, "ac");
+ }
+ /* Gather number of auto layers. */
+ /* We only do `vcols` that are not overridden by `uvs`. */
+ if (CustomData_get_named_layer_index(cd_ldata, CD_MLOOPUV, layer_name) == -1) {
+ BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name);
+ GPU_vertformat_alias_add(&format, attr_name);
+ }
+ }
+ }
+ }
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len);
+
+ using gpuMeshVcol = struct gpuMeshVcol {
+ ushort r, g, b, a;
+ };
+
+ gpuMeshVcol *vcol_data = (gpuMeshVcol *)GPU_vertbuf_get_data(vbo);
+ MLoop *loops = (MLoop *)CustomData_get_layer(cd_ldata, CD_MLOOP);
+
+ for (int i = 0; i < MAX_MCOL; i++) {
+ if (vcol_layers & (1 << i)) {
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ int cd_ofs = CustomData_get_n_offset(cd_ldata, CD_MLOOPCOL, i);
+ BMIter f_iter;
+ BMFace *efa;
+ BM_ITER_MESH (efa, &f_iter, mr->bm, BM_FACES_OF_MESH) {
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
+ do {
+ const MLoopCol *mloopcol = (const MLoopCol *)BM_ELEM_CD_GET_VOID_P(l_iter, cd_ofs);
+ vcol_data->r = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->r]);
+ vcol_data->g = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->g]);
+ vcol_data->b = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->b]);
+ vcol_data->a = unit_float_to_ushort_clamp(mloopcol->a * (1.0f / 255.0f));
+ vcol_data++;
+ } while ((l_iter = l_iter->next) != l_first);
+ }
+ }
+ else {
+ const MLoopCol *mloopcol = (MLoopCol *)CustomData_get_layer_n(cd_ldata, CD_MLOOPCOL, i);
+ for (int ml_index = 0; ml_index < mr->loop_len; ml_index++, mloopcol++, vcol_data++) {
+ vcol_data->r = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->r]);
+ vcol_data->g = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->g]);
+ vcol_data->b = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->b]);
+ vcol_data->a = unit_float_to_ushort_clamp(mloopcol->a * (1.0f / 255.0f));
+ }
+ }
+ }
+
+ if (svcol_layers & (1 << i) && U.experimental.use_sculpt_vertex_colors) {
+ if (mr->extract_type == MR_EXTRACT_BMESH) {
+ int cd_ofs = CustomData_get_n_offset(cd_vdata, CD_PROP_COLOR, i);
+ BMIter f_iter;
+ BMFace *efa;
+ BM_ITER_MESH (efa, &f_iter, mr->bm, BM_FACES_OF_MESH) {
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
+ do {
+ const MPropCol *prop_col = (const MPropCol *)BM_ELEM_CD_GET_VOID_P(l_iter->v, cd_ofs);
+ vcol_data->r = unit_float_to_ushort_clamp(prop_col->color[0]);
+ vcol_data->g = unit_float_to_ushort_clamp(prop_col->color[1]);
+ vcol_data->b = unit_float_to_ushort_clamp(prop_col->color[2]);
+ vcol_data->a = unit_float_to_ushort_clamp(prop_col->color[3]);
+ vcol_data++;
+ } while ((l_iter = l_iter->next) != l_first);
+ }
+ }
+ else {
+ MPropCol *vcol = (MPropCol *)CustomData_get_layer_n(cd_vdata, CD_PROP_COLOR, i);
+ for (int ml_index = 0; ml_index < mr->loop_len; ml_index++, vcol_data++) {
+ vcol_data->r = unit_float_to_ushort_clamp(vcol[loops[ml_index].v].color[0]);
+ vcol_data->g = unit_float_to_ushort_clamp(vcol[loops[ml_index].v].color[1]);
+ vcol_data->b = unit_float_to_ushort_clamp(vcol[loops[ml_index].v].color[2]);
+ vcol_data->a = unit_float_to_ushort_clamp(vcol[loops[ml_index].v].color[3]);
+ }
+ }
+ }
+ }
+}
+
+constexpr MeshExtract create_extractor_vcol()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_vcol_init;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = 0;
+ extractor.use_threading = false;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.vcol);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_vcol = blender::draw::create_extractor_vcol();
+}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc
new file mode 100644
index 00000000000..aae266eadce
--- /dev/null
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc
@@ -0,0 +1,189 @@
+/*
+ * 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) 2021 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup draw
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_deform.h"
+
+#include "draw_cache_extract_mesh_private.h"
+
+namespace blender::draw {
+
+/* ---------------------------------------------------------------------- */
+/** \name Extract Vertex Weight
+ * \{ */
+
+struct MeshExtract_Weight_Data {
+ float *vbo_data;
+ const DRW_MeshWeightState *wstate;
+ const MDeformVert *dvert; /* For #Mesh. */
+ int cd_ofs; /* For #BMesh. */
+};
+
+static float evaluate_vertex_weight(const MDeformVert *dvert, const DRW_MeshWeightState *wstate)
+{
+ /* Error state. */
+ if ((wstate->defgroup_active < 0) && (wstate->defgroup_len > 0)) {
+ return -2.0f;
+ }
+ if (dvert == nullptr) {
+ return (wstate->alert_mode != OB_DRAW_GROUPUSER_NONE) ? -1.0f : 0.0f;
+ }
+
+ float input = 0.0f;
+ if (wstate->flags & DRW_MESH_WEIGHT_STATE_MULTIPAINT) {
+ /* Multi-Paint feature */
+ bool is_normalized = (wstate->flags & (DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE |
+ DRW_MESH_WEIGHT_STATE_LOCK_RELATIVE));
+ input = BKE_defvert_multipaint_collective_weight(dvert,
+ wstate->defgroup_len,
+ wstate->defgroup_sel,
+ wstate->defgroup_sel_count,
+ is_normalized);
+ /* make it black if the selected groups have no weight on a vertex */
+ if (input == 0.0f) {
+ return -1.0f;
+ }
+ }
+ else {
+ /* default, non tricky behavior */
+ input = BKE_defvert_find_weight(dvert, wstate->defgroup_active);
+
+ if (input == 0.0f) {
+ switch (wstate->alert_mode) {
+ case OB_DRAW_GROUPUSER_ACTIVE:
+ return -1.0f;
+ break;
+ case OB_DRAW_GROUPUSER_ALL:
+ if (BKE_defvert_is_weight_zero(dvert, wstate->defgroup_len)) {
+ return -1.0f;
+ }
+ break;
+ }
+ }
+ }
+
+ /* Lock-Relative: display the fraction of current weight vs total unlocked weight. */
+ if (wstate->flags & DRW_MESH_WEIGHT_STATE_LOCK_RELATIVE) {
+ input = BKE_defvert_lock_relative_weight(
+ input, dvert, wstate->defgroup_len, wstate->defgroup_locked, wstate->defgroup_unlocked);
+ }
+
+ CLAMP(input, 0.0f, 1.0f);
+ return input;
+}
+
+static void extract_weights_init(const MeshRenderData *mr,
+ struct MeshBatchCache *cache,
+ void *buf,
+ void *tls_data)
+{
+ GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "weight", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ }
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
+
+ MeshExtract_Weight_Data *data = static_cast<MeshExtract_Weight_Data *>(tls_data);
+ data->vbo_data = (float *)GPU_vertbuf_get_data(vbo);
+ data->wstate = &cache->weight_state;
+
+ if (data->wstate->defgroup_active == -1) {
+ /* Nothing to show. */
+ data->dvert = nullptr;
+ data->cd_ofs = -1;
+ }
+ else if (mr->extract_type == MR_EXTRACT_BMESH) {
+ data->dvert = nullptr;
+ data->cd_ofs = CustomData_get_offset(&mr->bm->vdata, CD_MDEFORMVERT);
+ }
+ else {
+ data->dvert = (const MDeformVert *)CustomData_get_layer(&mr->me->vdata, CD_MDEFORMVERT);
+ data->cd_ofs = -1;
+ }
+}
+
+static void extract_weights_iter_poly_bm(const MeshRenderData *UNUSED(mr),
+ const BMFace *f,
+ const int UNUSED(f_index),
+ void *_data)
+{
+ MeshExtract_Weight_Data *data = static_cast<MeshExtract_Weight_Data *>(_data);
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const int l_index = BM_elem_index_get(l_iter);
+ if (data->cd_ofs != -1) {
+ const MDeformVert *dvert = (const MDeformVert *)BM_ELEM_CD_GET_VOID_P(l_iter->v,
+ data->cd_ofs);
+ data->vbo_data[l_index] = evaluate_vertex_weight(dvert, data->wstate);
+ }
+ else {
+ data->vbo_data[l_index] = evaluate_vertex_weight(nullptr, data->wstate);
+ }
+ } while ((l_iter = l_iter->next) != l_first);
+}
+
+static void extract_weights_iter_poly_mesh(const MeshRenderData *mr,
+ const MPoly *mp,
+ const int UNUSED(mp_index),
+ void *_data)
+{
+ MeshExtract_Weight_Data *data = static_cast<MeshExtract_Weight_Data *>(_data);
+ const MLoop *mloop = mr->mloop;
+ const int ml_index_end = mp->loopstart + mp->totloop;
+ for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
+ const MLoop *ml = &mloop[ml_index];
+ if (data->dvert != nullptr) {
+ const MDeformVert *dvert = &data->dvert[ml->v];
+ data->vbo_data[ml_index] = evaluate_vertex_weight(dvert, data->wstate);
+ }
+ else {
+ const MDeformVert *dvert = nullptr;
+ data->vbo_data[ml_index] = evaluate_vertex_weight(dvert, data->wstate);
+ }
+ }
+}
+
+constexpr MeshExtract create_extractor_weights()
+{
+ MeshExtract extractor = {nullptr};
+ extractor.init = extract_weights_init;
+ extractor.iter_poly_bm = extract_weights_iter_poly_bm;
+ extractor.iter_poly_mesh = extract_weights_iter_poly_mesh;
+ extractor.data_type = MR_DATA_NONE;
+ extractor.data_size = sizeof(MeshExtract_Weight_Data);
+ extractor.use_threading = true;
+ extractor.mesh_buffer_offset = offsetof(MeshBufferCache, vbo.weights);
+ return extractor;
+}
+
+/** \} */
+
+} // namespace blender::draw
+
+extern "C" {
+const MeshExtract extract_weights = blender::draw::create_extractor_weights();
+}
diff --git a/source/blender/draw/tests/draw_testing.cc b/source/blender/draw/tests/draw_testing.cc
index 0104437e921..45a857e7577 100644
--- a/source/blender/draw/tests/draw_testing.cc
+++ b/source/blender/draw/tests/draw_testing.cc
@@ -9,9 +9,9 @@
namespace blender::draw {
/* Base class for draw test cases. It will setup and tear down the GPU part around each test. */
-void DrawTest::SetUp()
+void DrawOpenGLTest::SetUp()
{
- GPUTest::SetUp();
+ GPUOpenGLTest::SetUp();
DRW_draw_state_init_gtests(GPU_SHADER_CFG_DEFAULT);
}
diff --git a/source/blender/draw/tests/draw_testing.hh b/source/blender/draw/tests/draw_testing.hh
index ec0b15b611e..00f0ac5bab7 100644
--- a/source/blender/draw/tests/draw_testing.hh
+++ b/source/blender/draw/tests/draw_testing.hh
@@ -5,9 +5,15 @@
namespace blender::draw {
/* Base class for draw test cases. It will setup and tear down the GPU part around each test. */
-class DrawTest : public blender::gpu::GPUTest {
+class DrawOpenGLTest : public blender::gpu::GPUOpenGLTest {
public:
void SetUp() override;
};
+#define DRAW_TEST(test_name) \
+ TEST_F(DrawOpenGLTest, test_name) \
+ { \
+ test_##test_name(); \
+ }
+
} // namespace blender::draw
diff --git a/source/blender/draw/tests/shaders_test.cc b/source/blender/draw/tests/shaders_test.cc
index cce69714f5e..0c7cbd4dac8 100644
--- a/source/blender/draw/tests/shaders_test.cc
+++ b/source/blender/draw/tests/shaders_test.cc
@@ -22,7 +22,7 @@
namespace blender::draw {
-TEST_F(DrawTest, workbench_glsl_shaders)
+static void test_workbench_glsl_shaders()
{
workbench_shader_library_ensure();
@@ -155,8 +155,9 @@ TEST_F(DrawTest, workbench_glsl_shaders)
workbench_shader_free();
}
+DRAW_TEST(workbench_glsl_shaders)
-TEST_F(DrawTest, gpencil_glsl_shaders)
+static void test_gpencil_glsl_shaders()
{
EXPECT_NE(GPENCIL_shader_antialiasing(0), nullptr);
EXPECT_NE(GPENCIL_shader_antialiasing(1), nullptr);
@@ -177,8 +178,9 @@ TEST_F(DrawTest, gpencil_glsl_shaders)
GPENCIL_shader_free();
}
+DRAW_TEST(gpencil_glsl_shaders)
-TEST_F(DrawTest, image_glsl_shaders)
+static void test_image_glsl_shaders()
{
IMAGE_shader_library_ensure();
@@ -187,8 +189,9 @@ TEST_F(DrawTest, image_glsl_shaders)
IMAGE_shader_free();
}
+DRAW_TEST(image_glsl_shaders)
-TEST_F(DrawTest, overlay_glsl_shaders)
+static void test_overlay_glsl_shaders()
{
OVERLAY_shader_library_ensure();
@@ -280,8 +283,9 @@ TEST_F(DrawTest, overlay_glsl_shaders)
OVERLAY_shader_free();
}
+DRAW_TEST(overlay_glsl_shaders)
-TEST_F(DrawTest, eevee_glsl_shaders_static)
+static void test_eevee_glsl_shaders_static()
{
EEVEE_shaders_material_shaders_init();
@@ -370,6 +374,7 @@ TEST_F(DrawTest, eevee_glsl_shaders_static)
EXPECT_NE(EEVEE_shaders_effect_reflection_resolve_sh_get(), nullptr);
EEVEE_shaders_free();
}
+DRAW_TEST(eevee_glsl_shaders_static)
static void test_draw_shaders(eParticleRefineShaderType sh_type)
{
@@ -378,7 +383,7 @@ static void test_draw_shaders(eParticleRefineShaderType sh_type)
DRW_shaders_free();
}
-TEST_F(DrawTest, draw_glsl_shaders)
+static void test_draw_glsl_shaders()
{
#ifndef __APPLE__
test_draw_shaders(PART_REFINE_SHADER_TRANSFORM_FEEDBACK);
@@ -386,5 +391,6 @@ TEST_F(DrawTest, draw_glsl_shaders)
#endif
test_draw_shaders(PART_REFINE_SHADER_TRANSFORM_FEEDBACK_WORKAROUND);
}
+DRAW_TEST(draw_glsl_shaders)
} // namespace blender::draw
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 0b587191807..f69830fc015 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -502,7 +502,7 @@ static bool acf_summary_setting_valid(bAnimContext *UNUSED(ac),
return (setting == ACHANNEL_SETTING_EXPAND);
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_summary_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -595,7 +595,7 @@ static bool acf_scene_setting_valid(bAnimContext *ac,
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_scene_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -766,7 +766,7 @@ static bool acf_object_setting_valid(bAnimContext *ac,
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_object_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -949,7 +949,7 @@ static bool acf_group_setting_valid(bAnimContext *ac,
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_group_setting_flag(bAnimContext *ac, eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
@@ -1086,7 +1086,7 @@ static bool acf_fcurve_setting_valid(bAnimContext *ac,
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -1212,7 +1212,7 @@ static bool acf_nla_controls_setting_valid(bAnimContext *UNUSED(ac),
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_nla_controls_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -1330,7 +1330,7 @@ static bool acf_fillactd_setting_valid(bAnimContext *UNUSED(ac),
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -1425,7 +1425,7 @@ static bool acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac),
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -1489,7 +1489,7 @@ static int acf_dsmat_icon(bAnimListElem *UNUSED(ale))
return ICON_MATERIAL_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -1568,7 +1568,7 @@ static int acf_dslight_icon(bAnimListElem *UNUSED(ale))
return ICON_LIGHT_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dslight_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -1656,7 +1656,7 @@ static short acf_dstex_offset(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(al
return 14; /* XXX: simply include this in indention instead? */
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -1736,7 +1736,7 @@ static int acf_dscachefile_icon(bAnimListElem *ale)
return ICON_FILE;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dscachefile_setting_flag(bAnimContext *ac, eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
@@ -1818,7 +1818,7 @@ static int acf_dscam_icon(bAnimListElem *UNUSED(ale))
return ICON_CAMERA_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -1911,7 +1911,7 @@ static int acf_dscur_icon(bAnimListElem *ale)
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2009,7 +2009,7 @@ static bool acf_dsskey_setting_valid(bAnimContext *ac,
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2088,7 +2088,7 @@ static int acf_dswor_icon(bAnimListElem *UNUSED(ale))
return ICON_WORLD_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2167,7 +2167,7 @@ static int acf_dspart_icon(bAnimListElem *UNUSED(ale))
return ICON_PARTICLE_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2246,7 +2246,7 @@ static int acf_dsmball_icon(bAnimListElem *UNUSED(ale))
return ICON_META_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2327,7 +2327,7 @@ static int acf_dsarm_icon(bAnimListElem *UNUSED(ale))
return ICON_ARMATURE_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2417,7 +2417,7 @@ static short acf_dsntree_offset(bAnimContext *ac, bAnimListElem *ale)
return offset;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2498,7 +2498,7 @@ static int acf_dslinestyle_icon(bAnimListElem *UNUSED(ale))
return ICON_LINE_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2579,7 +2579,7 @@ static int acf_dsmesh_icon(bAnimListElem *UNUSED(ale))
return ICON_MESH_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2659,7 +2659,7 @@ static int acf_dslat_icon(bAnimListElem *UNUSED(ale))
return ICON_LATTICE_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2739,7 +2739,7 @@ static int acf_dsspk_icon(bAnimListElem *UNUSED(ale))
return ICON_SPEAKER;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2818,7 +2818,7 @@ static int acf_dshair_icon(bAnimListElem *UNUSED(ale))
return ICON_HAIR_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dshair_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2897,7 +2897,7 @@ static int acf_dspointcloud_icon(bAnimListElem *UNUSED(ale))
return ICON_POINTCLOUD_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dspointcloud_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -2978,7 +2978,7 @@ static int acf_dsvolume_icon(bAnimListElem *UNUSED(ale))
return ICON_VOLUME_DATA;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dsvolume_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -3137,7 +3137,7 @@ static int acf_dsgpencil_icon(bAnimListElem *UNUSED(ale))
return ICON_GREASEPENCIL;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dsgpencil_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -3218,7 +3218,7 @@ static int acf_dsmclip_icon(bAnimListElem *UNUSED(ale))
return ICON_SEQUENCE;
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_dsmclip_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -3343,7 +3343,7 @@ static bool acf_shapekey_setting_valid(bAnimContext *UNUSED(ac),
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -3437,7 +3437,7 @@ static bool acf_gpd_setting_valid(bAnimContext *UNUSED(ac),
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
@@ -3530,7 +3530,7 @@ static bool acf_gpl_setting_valid(bAnimContext *UNUSED(ac),
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
{
/* clear extra return data first */
@@ -3616,7 +3616,7 @@ static bool acf_mask_setting_valid(bAnimContext *UNUSED(ac),
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_mask_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -3713,7 +3713,7 @@ static bool acf_masklay_setting_valid(bAnimContext *UNUSED(ac),
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -3849,7 +3849,7 @@ static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac),
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_nlatrack_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -4038,7 +4038,7 @@ static bool acf_nlaaction_setting_valid(bAnimContext *UNUSED(ac),
}
}
-/* get the appropriate flag(s) for the setting when it is valid */
+/* Get the appropriate flag(s) for the setting when it is valid. */
static int acf_nlaaction_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
@@ -4415,7 +4415,7 @@ void ANIM_channel_draw(
/* set blending again, as may not be set in previous step */
GPU_blend(GPU_BLEND_ALPHA);
- /* step 1) draw backdrop ........................................... */
+ /* step 1) draw backdrop ........................................... */
if (acf->draw_backdrop) {
acf->draw_backdrop(ac, ale, yminc, ymaxc);
}
@@ -5096,7 +5096,7 @@ static void draw_setting_widget(bAnimContext *ac,
/* set call to send relevant notifiers and/or perform type-specific updates */
if (but) {
switch (setting) {
- /* settings needing flushing up/down hierarchy */
+ /* Settings needing flushing up/down hierarchy. */
case ACHANNEL_SETTING_VISIBLE: /* Graph Editor - 'visibility' toggles */
case ACHANNEL_SETTING_PROTECT: /* General - protection flags */
case ACHANNEL_SETTING_MUTE: /* General - muting flags */
@@ -5184,12 +5184,12 @@ void ANIM_channel_draw_widgets(const bContext *C,
if ((ac->spacetype == SPACE_GRAPH) &&
(acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE) ||
acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE))) {
- /* pin toggle */
+ /* Pin toggle. */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE)) {
draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_ALWAYS_VISIBLE);
offset += ICON_WIDTH;
}
- /* visibility toggle */
+ /* Visibility toggle. */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) {
/* For F-curves, add the extra space for the color bands. */
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 061fe0b07c5..136cdefd2ec 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -1685,7 +1685,7 @@ static void animchannels_group_channels(bAnimContext *ac,
agrp = action_groups_add_new(act, name);
BLI_assert(agrp != NULL);
- /* transfer selected F-Curves across to new group */
+ /* Transfer selected F-Curves across to new group. */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
bActionGroup *grp = fcu->grp;
@@ -1726,7 +1726,7 @@ static int animchannels_group_exec(bContext *C, wmOperator *op)
bAnimListElem *ale;
int filter;
- /* handle each animdata block separately, so that the regrouping doesn't flow into blocks */
+ /* Handle each animdata block separately, so that the regrouping doesn't flow into blocks. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
@@ -2434,6 +2434,7 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op))
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 31284e41b18..42fdb714127 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -93,9 +93,9 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
fcu = (ale->datatype == ALE_FCURVE) ? ale->key_data : NULL;
if (fcu && fcu->rna_path) {
- /* if we have an fcurve, call the update for the property we
+ /* If we have an fcurve, call the update for the property we
* are editing, this is then expected to do the proper redraws
- * and depsgraph updates */
+ * and depsgraph updates. */
PointerRNA id_ptr, ptr;
PropertyRNA *prop;
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index aca332ff0fe..745b869228a 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -168,7 +168,7 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d)
}
/* *************************************************** */
-/* NLA-MAPPING UTILITIES (required for drawing and also editing keyframes) */
+/* NLA-MAPPING UTILITIES (required for drawing and also editing keyframes). */
/**
* Obtain the AnimData block providing NLA-mapping for the given channel (if applicable).
@@ -413,7 +413,7 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo
else {
/* Calculate min/max using full fcurve evaluation.
* [slower than bezier forward differencing but evaluates Back/Elastic interpolation
- * as well].*/
+ * as well]. */
float step_size = (bezt->vec[1][0] - prev_bezt->vec[1][0]) / resol;
for (int j = 0; j <= resol; j++) {
float eval_time = prev_bezt->vec[1][0] + step_size * j;
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index a03f19d0111..f04fa556dad 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -1217,7 +1217,7 @@ static bool skip_fcurve_with_name(
*
* \return true if F-Curve has errors/is disabled
*/
-static bool fcurve_has_errors(FCurve *fcu)
+static bool fcurve_has_errors(const FCurve *fcu)
{
/* F-Curve disabled - path eval error */
if (fcu->flag & FCURVE_DISABLED) {
@@ -1226,7 +1226,7 @@ static bool fcurve_has_errors(FCurve *fcu)
/* driver? */
if (fcu->driver) {
- ChannelDriver *driver = fcu->driver;
+ const ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
/* error flag on driver usually means that there is an error
@@ -3132,7 +3132,7 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m
/* check selection and object type filters */
if ((ads->filterflag & ADS_FILTER_ONLYSEL) &&
- !((base->flag & BASE_SELECTED) /*|| (base == sce->basact)*/)) {
+ !((base->flag & BASE_SELECTED) /*|| (base == sce->basact) */)) {
/* only selected should be shown */
return false;
}
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 43d5efe9ea9..dae2138e481 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -568,7 +568,7 @@ bool ANIM_remove_driver(ReportList *UNUSED(reports),
FCurve *fcu_iter = adt->drivers.first;
while ((fcu = BKE_fcurve_iter_step(fcu_iter, rna_path)) != NULL) {
- /* store the next fcurve for looping */
+ /* Store the next fcurve for looping. */
fcu_iter = fcu->next;
/* remove F-Curve from driver stack, then free it */
@@ -1253,7 +1253,7 @@ static int copy_driver_button_exec(bContext *C, wmOperator *op)
}
}
- /* since we're just copying, we don't really need to do anything else...*/
+ /* Since we're just copying, we don't really need to do anything else. */
return (changed) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -1303,7 +1303,7 @@ static int paste_driver_button_exec(bContext *C, wmOperator *op)
}
}
- /* since we're just copying, we don't really need to do anything else...*/
+ /* Since we're just copying, we don't really need to do anything else. */
return (changed) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 653bd72b364..31552330071 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -246,7 +246,7 @@ static PanelType *fmodifier_subpanel_register(ARegionType *region_type,
#define B_REDR 1
#define B_FMODIFIER_REDRAW 20
-/* callback to remove the given modifier */
+/* Callback to remove the given modifier. */
typedef struct FModifierDeleteContext {
ID *owner_id;
ListBase *modifiers;
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index 636f0d3cbea..aeead9350e9 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -251,7 +251,7 @@ static short ob_keyframes_loop(KeyframeEditData *ked,
ANIM_animdata_freelist(&anim_data);
- /* return return code - defaults to zero if nothing happened */
+ /* Return the return code (defaults to zero if nothing happened). */
return ret;
}
@@ -300,7 +300,7 @@ static short scene_keyframes_loop(KeyframeEditData *ked,
ANIM_animdata_freelist(&anim_data);
- /* return return code - defaults to zero if nothing happened */
+ /* Return the return code (defaults to zero if nothing happened). */
return ret;
}
@@ -1109,7 +1109,7 @@ static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *b
return 0;
}
-/* Sets the selected bezier handles to type 'vector' */
+/* Sets the selected bezier handles to type 'vector'. */
static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
/* If the key is selected, always apply to both handles. */
@@ -1164,7 +1164,7 @@ static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
return 0;
}
-/* Sets selected bezier handles to type 'free' */
+/* Sets selected bezier handles to type 'free'. */
static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
/* If the key is selected, always apply to both handles. */
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index b2d74376102..aeddd03f3c1 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -193,7 +193,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
BezTriple *lastb;
int totCount, i;
- /* check if any points */
+ /* Check if any points. */
if ((fcu == NULL) || (fcu->bezt == NULL) || (fcu->totvert == 0) ||
(!cleardefault && fcu->totvert == 1)) {
return;
@@ -408,7 +408,7 @@ bool decimate_fcurve(bAnimListElem *ale, float remove_ratio, float error_sq_max)
{
FCurve *fcu = (FCurve *)ale->key_data;
- /* Check if the curve actually has any points */
+ /* Check if the curve actually has any points. */
if (fcu == NULL || fcu->bezt == NULL || fcu->totvert == 0) {
return true;
}
@@ -588,7 +588,7 @@ typedef struct TempFrameValCache {
float frame, val;
} TempFrameValCache;
-/* Evaluates the curves between each selected keyframe on each frame, and keys the value */
+/* Evaluates the curves between each selected keyframe on each frame, and keys the value. */
void sample_fcurve(FCurve *fcu)
{
BezTriple *bezt, *start = NULL, *end = NULL;
@@ -600,7 +600,7 @@ void sample_fcurve(FCurve *fcu)
return;
}
- /* find selected keyframes... once pair has been found, add keyframes */
+ /* Find selected keyframes... once pair has been found, add keyframes. */
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
/* check if selected, and which end this is */
if (BEZT_ISSEL_ANY(bezt)) {
@@ -693,7 +693,7 @@ typedef struct tAnimCopybufItem {
int totvert; /* number of keyframes stored for this channel */
BezTriple *bezt; /* keyframes in buffer */
- short id_type; /* Result of GS(id->name)*/
+ short id_type; /* Result of `GS(id->name)`. */
bool is_bone; /* special flag for armature bones */
} tAnimCopybufItem;
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index f229d48b4eb..9364be41543 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -952,7 +952,7 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
case CONSTRAINT_TYPE_KINEMATIC:
return true;
- /* single-transform constraints */
+ /* Single-transform constraints. */
case CONSTRAINT_TYPE_TRACKTO:
if (searchtype == VISUALKEY_ROT) {
return true;
@@ -2244,7 +2244,7 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
MEM_freeN(bone_name);
- /* delete if bone is selected*/
+ /* Delete if bone is selected. */
if ((pchan) && (pchan->bone)) {
if (pchan->bone->flag & BONE_SELECTED) {
can_delete = true;
@@ -2810,14 +2810,14 @@ bool autokeyframe_cfra_can_key(const Scene *scene, ID *id)
/* --------------- API/Per-Datablock Handling ------------------- */
/* Checks if some F-Curve has a keyframe for a given frame */
-bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
+bool fcurve_frame_has_keyframe(const FCurve *fcu, float frame, short filter)
{
/* quick sanity check */
if (ELEM(NULL, fcu, fcu->bezt)) {
return false;
}
- /* we either include all regardless of muting, or only non-muted */
+ /* We either include all regardless of muting, or only non-muted. */
if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED) == 0) {
bool replace;
int i = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, frame, fcu->totvert, &replace);
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index fda7b600c1c..0206aabd359 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -529,7 +529,7 @@ void ANIM_OT_keying_set_active_set(wmOperatorType *ot)
/* Keying Set Type Info declarations */
static ListBase keyingset_type_infos = {NULL, NULL};
-/* Built-In Keying Sets (referencing type infos)*/
+/* Built-In Keying Sets (referencing type information). */
ListBase builtin_keyingsets = {NULL, NULL};
/* --------------- */
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index 1d4936bdf5e..baa279dea11 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -438,17 +438,15 @@ static void updateDuplicateSubtarget(EditBone *dup_bone,
}
}
-static void updateDuplicateActionConstraintSettings(EditBone *dup_bone,
- EditBone *orig_bone,
- Object *ob,
- bConstraint *curcon)
+static void updateDuplicateActionConstraintSettings(
+ EditBone *dup_bone, EditBone *orig_bone, Object *ob, bPoseChannel *pchan, bConstraint *curcon)
{
bActionConstraint *act_con = (bActionConstraint *)curcon->data;
bAction *act = (bAction *)act_con->act;
float mat[4][4];
- bConstraintOb cob = {.depsgraph = NULL, .scene = NULL, .ob = ob, .pchan = NULL};
+ bConstraintOb cob = {.depsgraph = NULL, .scene = NULL, .ob = ob, .pchan = pchan};
BKE_constraint_custom_object_space_get(cob.space_obj_world_matrix, curcon);
unit_m4(mat);
@@ -832,7 +830,7 @@ static void updateDuplicateConstraintSettings(EditBone *dup_bone, EditBone *orig
for (curcon = conlist->first; curcon; curcon = curcon->next) {
switch (curcon->type) {
case CONSTRAINT_TYPE_ACTION:
- updateDuplicateActionConstraintSettings(dup_bone, orig_bone, ob, curcon);
+ updateDuplicateActionConstraintSettings(dup_bone, orig_bone, ob, pchan, curcon);
break;
case CONSTRAINT_TYPE_KINEMATIC:
updateDuplicateKinematicConstraintSettings(curcon);
@@ -1558,7 +1556,7 @@ void ARMATURE_OT_extrude(wmOperatorType *ot)
/* ********************** Bone Add *************************************/
-/*op makes a new bone and returns it with its tip selected */
+/* Op makes a new bone and returns it with its tip selected. */
static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
{
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 912aafbd6e3..48b487c29fd 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -1030,7 +1030,7 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot)
/** \name Align Operator
* \{ */
-/* helper to fix a ebone position if its parent has moved due to alignment*/
+/* Helper to fix a ebone position if its parent has moved due to alignment. */
static void fix_connected_bone(EditBone *ebone)
{
float diff[3];
@@ -1073,9 +1073,9 @@ static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actb
add_v3_v3v3(selbone->tail, selbone->head, actboneaxis);
selbone->roll = actbone->roll;
- /* if the bone being aligned has connected descendants they must be moved
+ /* If the bone being aligned has connected descendants they must be moved
* according to their parent new position, otherwise they would be left
- * in an inconsistent state: connected but away from the parent*/
+ * in an inconsistent state: connected but away from the parent. */
fix_editbone_connected_children(edbo, selbone);
}
@@ -1107,7 +1107,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
}
}
- /* if there is only 1 selected bone, we assume that that is the active bone,
+ /* if there is only 1 selected bone, we assume that it is the active bone,
* since a user will need to have clicked on a bone (thus selecting it) to make it active
*/
num_selected_bones = CTX_DATA_COUNT(C, selected_editable_bones);
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 66ca38ce218..c447138f00c 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -457,7 +457,7 @@ static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *n
bConstraint *con;
ListBase *opchans, *npchans;
- /* get reference to list of bones in original and new armatures */
+ /* Get reference to list of bones in original and new armatures. */
opchans = &origArm->pose->chanbase;
npchans = &newArm->pose->chanbase;
@@ -576,7 +576,7 @@ static void separate_armature_bones(Main *bmain, Object *ob, const bool is_selec
/* check if bone needs to be removed */
if (is_select == (EBONE_VISIBLE(arm, curbone) && (curbone->flag & BONE_SELECTED))) {
- /* clear the bone->parent var of any bone that had this as its parent */
+ /* Clear the bone->parent var of any bone that had this as its parent. */
LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) {
if (ebo->parent == curbone) {
ebo->parent = NULL;
@@ -838,7 +838,7 @@ 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,
+ /* If there is only 1 selected bone, we assume that it 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) {
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index ffcdb99c5a3..bc6d0687654 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -847,7 +847,7 @@ void ED_armature_to_edit(bArmature *arm)
}
/* *************************************************************** */
-/* Used by Undo for Armature EditMode*/
+/* Used by Undo for Armature EditMode. */
/* free's bones and their properties */
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index f5daa427149..f86cc1159d5 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -224,7 +224,7 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, ePosePathC
#endif
/* For a single frame update it's faster to re-use existing dependency graph and avoid overhead
- * of building all the relations and so on for a temporary one. */
+ * of building all the relations and so on for a temporary one. */
if (range == POSE_PATH_CALC_RANGE_CURRENT_FRAME) {
/* NOTE: Dependency graph will be evaluated at all the frames, but we first need to access some
* nested pointers, like animation data. */
@@ -455,7 +455,7 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected)
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
-/* operator callback - wrapper for the backend function */
+/* Operator callback - wrapper for the back-end function. */
static int pose_clear_paths_exec(bContext *C, wmOperator *op)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
@@ -663,7 +663,7 @@ static int pose_bone_rotmode_exec(bContext *C, wmOperator *op)
const int mode = RNA_enum_get(op->ptr, "type");
Object *prev_ob = NULL;
- /* set rotation mode of selected bones */
+ /* Set rotation mode of selected bones. */
CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
/* use API Method for conversions... */
BKE_rotMode_change_values(
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 21fcbf8886b..df3550d5db6 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -516,7 +516,7 @@ static int poselib_add_exec(bContext *C, wmOperator *op)
/* use Keying Set to determine what to store for the pose */
- /* this includes custom props :)*/
+ /* This includes custom props :). */
ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_SELECTED_ID);
ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame);
@@ -863,7 +863,7 @@ typedef struct tPoseLib_PreviewData {
/** active area. */
ScrArea *area;
- /** RNA-Pointer to Object 'ob' .*/
+ /** RNA-Pointer to Object 'ob'. */
PointerRNA rna_ptr;
/** object to work on. */
Object *ob;
@@ -1100,7 +1100,7 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
/* start tagging/keying */
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
- /* only for selected bones unless there aren't any selected, in which case all are included */
+ /* Only for selected bones unless there aren't any selected, in which case all are included. */
pchan = BKE_pose_channel_find_name(pose, agrp->name);
if (pchan) {
@@ -1462,7 +1462,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
pld->state = PL_PREVIEW_CONFIRM;
break;
- /* toggle between original pose and poselib pose*/
+ /* Toggle between original pose and poselib pose. */
case EVT_TABKEY:
pld->flag |= PL_PREVIEW_SHOWORIGINAL;
pld->redraw = PL_PREVIEW_REDRAWALL;
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index d32faf9a9ea..9b1de742332 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -444,7 +444,7 @@ static void pose_slide_draw_2d_slider(const struct bContext *UNUSED(C), ARegion
color_line);
/* Draw triangles at the ends of the line in overshoot mode to indicate direction of 0-100%
- * range.*/
+ * range. */
if (pso->overshoot) {
if (pso->factor > 1 + OVERSHOOT_RANGE_DELTA + 0.5) {
draw_overshoot_triangle(color_line, false, main_line_rect.xmin, line_y);
@@ -1468,7 +1468,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* Reset transforms back to original state. */
pose_slide_reset(pso);
- /* Depsgraph updates + redraws.*/
+ /* Depsgraph updates + redraws. */
pose_slide_refresh(C, pso);
/* Clean up temp data. */
@@ -1513,7 +1513,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
if (event->val == KM_PRESS) {
switch (event->type) {
- /* Transform Channel Limits */
+ /* Transform Channel Limits. */
/* XXX: Replace these hard-coded hotkeys with a modal-map that can be customized. */
case EVT_GKEY: /* Location */
{
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index 6466773daac..e597fd46106 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -1383,7 +1383,7 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
BKE_animsys_evaluate_animdata(
&workob.id, workob.adt, &anim_eval_context, ADT_RECALC_ANIM, false);
- /* copy back values, but on selected bones only */
+ /* Copy back values, but on selected bones only. */
for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) {
pose_bone_do_paste(ob, pchan, only_select, 0);
}
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index 8eae5288f7a..500b9663a6c 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -144,7 +144,9 @@ Object *poseAnim_object_get(Object *ob_)
return NULL;
}
-/* get sets of F-Curves providing transforms for the bones in the Pose */
+/**
+ * Get sets of F-Curves providing transforms for the bones in the Pose.
+ */
void poseAnim_mapping_get(bContext *C, ListBase *pfLinks)
{
/* for each Pose-Channel which gets affected, get the F-Curves for that channel
@@ -190,7 +192,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks)
}
}
-/* free F-Curve <-> PoseChannel links */
+/* Free F-Curve <-> PoseChannel links. */
void poseAnim_mapping_free(ListBase *pfLinks)
{
tPChanFCurveLink *pfl, *pfln = NULL;
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 2999ac784ba..58cd69781a7 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -3747,8 +3747,8 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
}
if (sel) { /* U ! */
- /* Inserting U points is sort of 'default' Flat curves only get */
- /* U points inserted in them. */
+ /* Inserting U points is sort of 'default' Flat curves only get
+ * U points inserted in them. */
bpn = bpnew = MEM_mallocN((sel + nu->pntsu) * nu->pntsv * sizeof(BPoint),
"subdivideNurb4");
bp = nu->bp;
@@ -3786,7 +3786,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
MEM_freeN(usel);
MEM_freeN(vsel);
- } /* End of 'if (nu->type == CU_NURBS)' */
+ } /* End of `if (nu->type == CU_NURBS)`. */
}
}
diff --git a/source/blender/editors/curve/editcurve_query.c b/source/blender/editors/curve/editcurve_query.c
index 56392aab5bf..a8fd3ea2803 100644
--- a/source/blender/editors/curve/editcurve_query.c
+++ b/source/blender/editors/curve/editcurve_query.c
@@ -168,8 +168,8 @@ bool ED_curve_pick_vert(ViewContext *vc,
void ED_curve_nurb_vert_selected_find(
Curve *cu, View3D *v3d, Nurb **r_nu, BezTriple **r_bezt, BPoint **r_bp)
{
- /* in nu and (bezt or bp) selected are written if there's 1 sel. */
- /* if more points selected in 1 spline: return only nu, bezt and bp are 0 */
+ /* In nu and (bezt or bp) selected are written if there's 1 sel. */
+ /* If more points selected in 1 spline: return only nu, bezt and bp are 0. */
ListBase *editnurb = &cu->editnurb->nurbs;
BezTriple *bezt1;
BPoint *bp1;
diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c
index 90cefef38ee..721aa7afecc 100644
--- a/source/blender/editors/curve/editcurve_select.c
+++ b/source/blender/editors/curve/editcurve_select.c
@@ -56,6 +56,10 @@
#include "DEG_depsgraph.h"
+/* -------------------------------------------------------------------- */
+/** \name Utilities
+ * \{ */
+
/* returns 1 in case (de)selection was successful */
bool select_beztriple(BezTriple *bezt, bool selstatus, uint8_t flag, eVisible_Types hidden)
{
@@ -107,10 +111,10 @@ static bool swap_selection_bpoint(BPoint *bp)
return select_bpoint(bp, SELECT, SELECT, VISIBLE);
}
-bool ED_curve_nurb_select_check(View3D *v3d, Nurb *nu)
+bool ED_curve_nurb_select_check(const View3D *v3d, const Nurb *nu)
{
if (nu->type == CU_BEZIER) {
- BezTriple *bezt;
+ const BezTriple *bezt;
int i;
for (i = nu->pntsu, bezt = nu->bezt; i--; bezt++) {
@@ -120,7 +124,7 @@ bool ED_curve_nurb_select_check(View3D *v3d, Nurb *nu)
}
}
else {
- BPoint *bp;
+ const BPoint *bp;
int i;
for (i = nu->pntsu * nu->pntsv, bp = nu->bp; i--; bp++) {
@@ -132,12 +136,12 @@ bool ED_curve_nurb_select_check(View3D *v3d, Nurb *nu)
return false;
}
-int ED_curve_nurb_select_count(View3D *v3d, Nurb *nu)
+int ED_curve_nurb_select_count(const View3D *v3d, const Nurb *nu)
{
int sel = 0;
if (nu->type == CU_BEZIER) {
- BezTriple *bezt;
+ const BezTriple *bezt;
int i;
for (i = nu->pntsu, bezt = nu->bezt; i--; bezt++) {
@@ -147,7 +151,7 @@ int ED_curve_nurb_select_count(View3D *v3d, Nurb *nu)
}
}
else {
- BPoint *bp;
+ const BPoint *bp;
int i;
for (i = nu->pntsu * nu->pntsv, bp = nu->bp; i--; bp++) {
@@ -223,7 +227,7 @@ bool ED_curve_nurb_deselect_all(const Nurb *nu)
return changed;
}
-int ED_curve_select_count(View3D *v3d, struct EditNurb *editnurb)
+int ED_curve_select_count(const View3D *v3d, const EditNurb *editnurb)
{
int sel = 0;
Nurb *nu;
@@ -235,9 +239,9 @@ int ED_curve_select_count(View3D *v3d, struct EditNurb *editnurb)
return sel;
}
-bool ED_curve_select_check(View3D *v3d, struct EditNurb *editnurb)
+bool ED_curve_select_check(const View3D *v3d, const EditNurb *editnurb)
{
- LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
+ LISTBASE_FOREACH (const Nurb *, nu, &editnurb->nurbs) {
if (ED_curve_nurb_select_check(v3d, nu)) {
return true;
}
@@ -398,12 +402,18 @@ static void select_adjacent_cp(ListBase *editnurb,
}
}
-/**************** select start/end operators **************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Start/End Operators
+ * \{ */
-/* (de)selects first or last of visible part of each Nurb depending on selFirst
- * selFirst: defines the end of which to select
- * doswap: defines if selection state of each first/last control point is swapped
- * selstatus: selection status in case doswap is false
+/**
+ * (De)selects first or last of visible part of each #Nurb depending on `selfirst`.
+ *
+ * \param selfirst: defines the end of which to select.
+ * \param doswap: defines if selection state of each first/last control point is swapped.
+ * \param selstatus: selection status in case `doswap` is false.
*/
static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap, bool selstatus)
{
@@ -543,6 +553,12 @@ void CURVE_OT_de_select_last(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select All Operator
+ * \{ */
+
static int de_select_all_exec(bContext *C, wmOperator *op)
{
int action = RNA_enum_get(op->ptr, "action");
@@ -612,7 +628,11 @@ void CURVE_OT_select_all(wmOperatorType *ot)
WM_operator_properties_select_all(ot);
}
-/***************** select linked operator ******************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Linked Operator
+ * \{ */
static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -668,7 +688,11 @@ void CURVE_OT_select_linked(wmOperatorType *ot)
/* properties */
}
-/***************** select linked pick operator ******************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Linked Pick Operator
+ * \{ */
static int select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
@@ -740,7 +764,11 @@ void CURVE_OT_select_linked_pick(wmOperatorType *ot)
"Deselect linked control points rather than selecting them");
}
-/***************** select row operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Row Operator
+ * \{ */
static int select_row_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -802,7 +830,11 @@ void CURVE_OT_select_row(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/***************** select next operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Next Operator
+ * \{ */
static int select_next_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -839,7 +871,11 @@ void CURVE_OT_select_next(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/***************** select previous operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Previous Operator
+ * \{ */
static int select_previous_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -876,7 +912,11 @@ void CURVE_OT_select_previous(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/***************** select more operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select More Operator
+ * \{ */
static void curve_select_more(Object *obedit)
{
@@ -885,10 +925,10 @@ static void curve_select_more(Object *obedit)
int a;
short sel = 0;
- /* note that NURBS surface is a special case because we mimic */
- /* the behavior of "select more" of mesh tools. */
- /* The algorithm is designed to work in planar cases so it */
- /* may not be optimal always (example: end of NURBS sphere) */
+ /* NOTE: NURBS surface is a special case because we mimic
+ * the behavior of "select more" of mesh tools.
+ * The algorithm is designed to work in planar cases so it
+ * may not be optimal always (example: end of NURBS sphere). */
if (obedit->type == OB_SURF) {
LISTBASE_FOREACH (Nurb *, nu, editnurb) {
BLI_bitmap *selbpoints;
@@ -984,7 +1024,11 @@ void CURVE_OT_select_more(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/******************** select less operator *****************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Less Operator
+ * \{ */
/* basic method: deselect if control point doesn't have all neighbors selected */
static void curve_select_less(Object *obedit)
@@ -1198,46 +1242,11 @@ void CURVE_OT_select_less(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/********************** select random *********************/
-
-static void curve_select_random(ListBase *editnurb, float randfac, int seed, bool select)
-{
- BezTriple *bezt;
- BPoint *bp;
- int a;
-
- RNG *rng = BLI_rng_new_srandom(seed);
-
- LISTBASE_FOREACH (Nurb *, nu, editnurb) {
- if (nu->type == CU_BEZIER) {
- bezt = nu->bezt;
- a = nu->pntsu;
- while (a--) {
- if (!bezt->hide) {
- if (BLI_rng_get_float(rng) < randfac) {
- select_beztriple(bezt, select, SELECT, VISIBLE);
- }
- }
- bezt++;
- }
- }
- else {
- bp = nu->bp;
- a = nu->pntsu * nu->pntsv;
-
- while (a--) {
- if (!bp->hide) {
- if (BLI_rng_get_float(rng) < randfac) {
- select_bpoint(bp, select, SELECT, VISIBLE);
- }
- }
- bp++;
- }
- }
- }
+/** \} */
- BLI_rng_free(rng);
-}
+/* -------------------------------------------------------------------- */
+/** \name Select Random Operator
+ * \{ */
static int curve_select_random_exec(bContext *C, wmOperator *op)
{
@@ -1260,9 +1269,71 @@ static int curve_select_random_exec(bContext *C, wmOperator *op)
seed_iter += BLI_ghashutil_strhash_p(obedit->id.name);
}
- curve_select_random(editnurb, randfac, seed_iter, select);
- BKE_curve_nurb_vert_active_validate(obedit->data);
+ int totvert = 0;
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
+ if (nu->type == CU_BEZIER) {
+ int a = nu->pntsu;
+ BezTriple *bezt = nu->bezt;
+ while (a--) {
+ if (!bezt->hide) {
+ totvert++;
+ }
+ bezt++;
+ }
+ }
+ else {
+ int a = nu->pntsu * nu->pntsv;
+ BPoint *bp = nu->bp;
+ while (a--) {
+ if (!bp->hide) {
+ totvert++;
+ }
+ bp++;
+ }
+ }
+ }
+
+ BLI_bitmap *verts_selection_mask = BLI_BITMAP_NEW(totvert, __func__);
+ const int count_select = totvert * randfac;
+ for (int i = 0; i < count_select; i++) {
+ BLI_BITMAP_SET(verts_selection_mask, i, true);
+ }
+ BLI_bitmap_randomize(verts_selection_mask, totvert, seed_iter);
+
+ int bit_index = 0;
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
+ if (nu->type == CU_BEZIER) {
+ int a = nu->pntsu;
+ BezTriple *bezt = nu->bezt;
+
+ while (a--) {
+ if (!bezt->hide) {
+ if (BLI_BITMAP_TEST(verts_selection_mask, bit_index)) {
+ select_beztriple(bezt, select, SELECT, VISIBLE);
+ }
+ bit_index++;
+ }
+ bezt++;
+ }
+ }
+ else {
+ int a = nu->pntsu * nu->pntsv;
+ BPoint *bp = nu->bp;
+ while (a--) {
+ if (!bp->hide) {
+ if (BLI_BITMAP_TEST(verts_selection_mask, bit_index)) {
+ select_bpoint(bp, select, SELECT, VISIBLE);
+ }
+ bit_index++;
+ }
+ bp++;
+ }
+ }
+ }
+
+ MEM_freeN(verts_selection_mask);
+ BKE_curve_nurb_vert_active_validate(obedit->data);
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -1289,7 +1360,11 @@ void CURVE_OT_select_random(wmOperatorType *ot)
WM_operator_properties_select_random(ot);
}
-/********************* every nth number of point *******************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Every Nth Number of Point Operator
+ * \{ */
static void select_nth_bezt(Nurb *nu, BezTriple *bezt, const struct CheckerIntervalParams *params)
{
@@ -1421,6 +1496,8 @@ void CURVE_OT_select_nth(wmOperatorType *ot)
WM_operator_properties_checker_interval(ot, false);
}
+/** \} */
+
/* -------------------------------------------------------------------- */
/** \name Select Similar Operator
* \{ */
diff --git a/source/blender/editors/curve/editcurve_undo.c b/source/blender/editors/curve/editcurve_undo.c
index b07c3c85f4a..88f6398567d 100644
--- a/source/blender/editors/curve/editcurve_undo.c
+++ b/source/blender/editors/curve/editcurve_undo.c
@@ -97,7 +97,7 @@ static void undocurve_to_editcurve(Main *bmain, UndoCurve *ucu, Curve *cu, short
BKE_fcurves_copy(&ad->drivers, &ucu->drivers);
}
- /* copy */
+ /* Copy. */
for (nu = undobase->first; nu; nu = nu->next) {
newnu = BKE_nurb_duplicate(nu);
@@ -139,7 +139,7 @@ static void undocurve_from_editcurve(UndoCurve *ucu, Curve *cu, const short shap
BKE_fcurves_copy(&ucu->drivers, &ad->drivers);
}
- /* copy */
+ /* Copy. */
for (nu = nubase->first; nu; nu = nu->next) {
newnu = BKE_nurb_duplicate(nu);
diff --git a/source/blender/editors/geometry/geometry_attributes.c b/source/blender/editors/geometry/geometry_attributes.c
index b2ecee90a57..9b034d82a51 100644
--- a/source/blender/editors/geometry/geometry_attributes.c
+++ b/source/blender/editors/geometry/geometry_attributes.c
@@ -109,14 +109,6 @@ void GEOMETRY_OT_attribute_add(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_enum(ot->srna,
- "data_type",
- rna_enum_attribute_type_items,
- CD_PROP_FLOAT,
- "Data Type",
- "Type of data stored in attribute");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-
- prop = RNA_def_enum(ot->srna,
"domain",
rna_enum_attribute_domain_items,
ATTR_DOMAIN_POINT,
@@ -124,6 +116,14 @@ void GEOMETRY_OT_attribute_add(wmOperatorType *ot)
"Type of element that attribute is stored on");
RNA_def_enum_funcs(prop, geometry_attribute_domain_itemf);
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
+ prop = RNA_def_enum(ot->srna,
+ "data_type",
+ rna_enum_attribute_type_items,
+ CD_PROP_FLOAT,
+ "Data Type",
+ "Type of data stored in attribute");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
static int geometry_attribute_remove_exec(bContext *C, wmOperator *op)
@@ -140,6 +140,11 @@ static int geometry_attribute_remove_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ int *active_index = BKE_id_attributes_active_index_p(id);
+ if (*active_index > 0) {
+ *active_index -= 1;
+ }
+
DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
diff --git a/source/blender/editors/gizmo_library/gizmo_library_utils.c b/source/blender/editors/gizmo_library/gizmo_library_utils.c
index 847f3e3916c..77c65cd1bb8 100644
--- a/source/blender/editors/gizmo_library/gizmo_library_utils.c
+++ b/source/blender/editors/gizmo_library/gizmo_library_utils.c
@@ -118,10 +118,10 @@ void gizmo_property_data_update(wmGizmo *gz,
const bool inverted)
{
if (gz_prop->custom_func.value_get_fn != NULL) {
- /* pass */
+ /* Pass. */
}
else if (gz_prop->prop != NULL) {
- /* pass */
+ /* Pass. */
}
else {
data->offset = 0.0f;
diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
index b2d3a2e1576..31ab5eca974 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
@@ -319,9 +319,9 @@ bool ED_gizmotypes_snap_3d_invert_snap_get(struct wmGizmo *gz)
#endif
}
-bool ED_gizmotypes_snap_3d_is_enabled(wmGizmo *gz)
+bool ED_gizmotypes_snap_3d_is_enabled(const wmGizmo *gz)
{
- SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
+ const SnapGizmo3D *snap_gizmo = (const SnapGizmo3D *)gz;
return snap_gizmo->is_enabled;
}
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index e3c6fd8f878..7b995c545ba 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -908,7 +908,7 @@ static void annotation_stroke_newfrombuffer(tGPsdata *p)
CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
pt->time = ptc->time;
- /** Create arrow strokes. **/
+ /** Create arrow strokes. */
/* End arrow stroke. */
if ((runtime.sbuffer_sflag & GP_STROKE_USE_ARROW_END) &&
(runtime.arrow_end_style != GP_STROKE_ARROWSTYLE_NONE)) {
@@ -1079,17 +1079,6 @@ static void annotation_free_stroke(bGPDframe *gpf, bGPDstroke *gps)
BLI_freelinkN(&gpf->strokes, gps);
}
-/**
- * Which which point is in front (result should only be used for comparison).
- */
-static float view3d_point_depth(const RegionView3D *rv3d, const float co[3])
-{
- if (rv3d->is_persp) {
- return ED_view3d_calc_zfac(rv3d, co, NULL);
- }
- return -dot_v3v3(rv3d->viewinv[2], co);
-}
-
/* only erase stroke points that are visible (3d view) */
static bool annotation_stroke_eraser_is_occluded(tGPsdata *p,
const bGPDspoint *pt,
@@ -1102,8 +1091,8 @@ static bool annotation_stroke_eraser_is_occluded(tGPsdata *p,
float mval_3d[3];
if (ED_view3d_autodist_simple(p->region, mval_i, mval_3d, 0, NULL)) {
- const float depth_mval = view3d_point_depth(rv3d, mval_3d);
- const float depth_pt = view3d_point_depth(rv3d, &pt->x);
+ const float depth_mval = ED_view3d_calc_depth_for_comparison(rv3d, mval_3d);
+ const float depth_pt = ED_view3d_calc_depth_for_comparison(rv3d, &pt->x);
if (depth_pt > depth_mval) {
return true;
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 751f8333aaa..2160aaf705f 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -323,7 +323,7 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw)
MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL;
if ((gp_style == NULL) || (gp_style->flag & GP_MATERIAL_HIDE) ||
- /* if onion and ghost flag do not draw*/
+ /* If onion and ghost flag do not draw. */
(tgpw->onion && (gp_style->flag & GP_MATERIAL_HIDE_ONIONSKIN))) {
continue;
}
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index 166111c582c..6e6d94a2909 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -107,7 +107,7 @@ void ED_gpencil_layer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, bool onlys
/* Selection Tools */
/* check if one of the frames in this layer is selected */
-bool ED_gpencil_layer_frame_select_check(bGPDlayer *gpl)
+bool ED_gpencil_layer_frame_select_check(const bGPDlayer *gpl)
{
/* error checking */
if (gpl == NULL) {
@@ -115,7 +115,7 @@ bool ED_gpencil_layer_frame_select_check(bGPDlayer *gpl)
}
/* stop at the first one found */
- LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
+ LISTBASE_FOREACH (const bGPDframe *, gpf, &gpl->frames) {
if (gpf->flag & GP_FRAME_SELECT) {
return true;
}
@@ -268,7 +268,7 @@ void ED_gpencil_layer_frames_duplicate(bGPDlayer *gpl)
return;
}
- /* duplicate selected frames */
+ /* Duplicate selected frames. */
LISTBASE_FOREACH_MUTABLE (bGPDframe *, gpf, &gpl->frames) {
/* duplicate this frame */
@@ -421,7 +421,7 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
return false;
}
- /* check if single channel in buffer (disregard names if so) */
+ /* Check if single channel in buffer (disregard names if so). */
if (gpencil_anim_copybuf.first == gpencil_anim_copybuf.last) {
no_name = true;
}
diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index 6d6f4bc4b40..24fb0873a86 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -425,7 +425,7 @@ static void gpencil_add_verts_to_dgroups(
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
diff --git a/source/blender/editors/gpencil/gpencil_bake_animation.c b/source/blender/editors/gpencil/gpencil_bake_animation.c
index 30ebc9189c5..1a5e2950e09 100644
--- a/source/blender/editors/gpencil/gpencil_bake_animation.c
+++ b/source/blender/editors/gpencil/gpencil_bake_animation.c
@@ -185,7 +185,7 @@ static void gpencil_bake_ob_list(bContext *C, Depsgraph *depsgraph, Scene *scene
if (ob == obact) {
continue;
}
- /* Add selected objects.*/
+ /* Add selected objects. */
if (ob->type == OB_GPENCIL) {
elem = MEM_callocN(sizeof(GpBakeOb), __func__);
elem->ob = ob;
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 8ab413e907c..9bea1868895 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -168,7 +168,7 @@ static void gpencil_strokepoint_convertcoords(bContext *C,
ARegion *region = CTX_wm_region(C);
/* TODO(sergey): This function might be called from a loop, but no tagging is happening in it,
* so it's not that expensive to ensure evaluated depsgraph here. However, ideally all the
- * parameters are to wrapped into a context style struct and queried from Context once.*/
+ * parameters are to wrapped into a context style struct and queried from Context once. */
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obact = CTX_data_active_object(C);
bGPDspoint mypt, *pt;
@@ -219,7 +219,7 @@ typedef struct tGpTimingData {
int frame_range; /* Number of frames evaluated for path animation */
int start_frame, end_frame;
bool realtime; /* Will overwrite end_frame in case of Original or CustomGap timing... */
- float gap_duration, gap_randomness; /* To be used with CustomGap mode*/
+ float gap_duration, gap_randomness; /* To be used with CustomGap mode. */
int seed;
/* Data set from points, used to compute final timing FCurve */
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index d9a807d17ab..e272f46d13d 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -828,7 +828,7 @@ static int gpencil_frame_clean_loose_exec(bContext *C, wmOperator *op)
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -871,20 +871,20 @@ void GPENCIL_OT_frame_clean_loose(wmOperatorType *ot)
}
/* ********************* Clean Duplicated Frames ************************** */
-static bool gpencil_frame_is_equal(bGPDframe *gpf_a, bGPDframe *gpf_b)
+static bool gpencil_frame_is_equal(const bGPDframe *gpf_a, const bGPDframe *gpf_b)
{
if ((gpf_a == NULL) || (gpf_b == NULL)) {
return false;
}
/* If the number of strokes is different, cannot be equal. */
- int totstrokes_a = BLI_listbase_count(&gpf_a->strokes);
- int totstrokes_b = BLI_listbase_count(&gpf_b->strokes);
+ const int totstrokes_a = BLI_listbase_count(&gpf_a->strokes);
+ const int totstrokes_b = BLI_listbase_count(&gpf_b->strokes);
if ((totstrokes_a == 0) || (totstrokes_b == 0) || (totstrokes_a != totstrokes_b)) {
return false;
}
/* Loop all strokes and check. */
- bGPDstroke *gps_a = gpf_a->strokes.first;
- bGPDstroke *gps_b = gpf_b->strokes.first;
+ const bGPDstroke *gps_a = gpf_a->strokes.first;
+ const bGPDstroke *gps_b = gpf_b->strokes.first;
for (int i = 0; i < totstrokes_a; i++) {
/* If the number of points is different, cannot be equal. */
if (gps_a->totpoints != gps_b->totpoints) {
@@ -924,8 +924,8 @@ static bool gpencil_frame_is_equal(bGPDframe *gpf_a, bGPDframe *gpf_b)
/* Loop points and check if equals or not. */
for (int p = 0; p < gps_a->totpoints; p++) {
- bGPDspoint *pt_a = &gps_a->points[p];
- bGPDspoint *pt_b = &gps_b->points[p];
+ const bGPDspoint *pt_a = &gps_a->points[p];
+ const bGPDspoint *pt_b = &gps_b->points[p];
if (!equals_v3v3(&pt_a->x, &pt_b->x)) {
return false;
}
@@ -1572,7 +1572,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
continue;
}
bool gpf_lock = false;
- /* some stroke is already at front*/
+ /* Some stroke is already at front. */
if (ELEM(direction, GP_STROKE_MOVE_TOP, GP_STROKE_MOVE_UP)) {
if (gps == gpf->strokes.last) {
gpf_lock = true;
@@ -1664,7 +1664,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
BLI_freelistN(&selected);
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -1772,7 +1772,7 @@ static int gpencil_stroke_change_color_exec(bContext *C, wmOperator *op)
}
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -2718,9 +2718,8 @@ static void gpencil_joined_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data)
fcu->rna_path = BKE_animsys_fix_rna_path_rename(
id, fcu->rna_path, "layers", old_name, new_name, 0, 0, false);
- /* we don't want to apply a second remapping on this F-Curve now,
- * so stop trying to fix names names
- */
+ /* We don't want to apply a second remapping on this F-Curve now,
+ * so stop trying to fix names. */
break;
}
}
@@ -2865,7 +2864,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
BKE_gpencil_object_material_ensure(bmain, ob_dst, tmp_ma);
}
- /* duplicate bGPDlayers */
+ /* Duplicate #bGPDlayers. */
tJoinGPencil_AdtFixData afd = {0};
afd.src_gpd = gpd_src;
afd.tar_gpd = gpd_dst;
@@ -3356,7 +3355,7 @@ static int gpencil_material_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- /* make all layers editable again*/
+ /* Make all layers editable again. */
MaterialGPencilStyle *gp_style = NULL;
for (short i = 0; i < *totcol; i++) {
@@ -3410,7 +3409,7 @@ static int gpencil_material_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* read all strokes and select*/
+ /* Read all strokes and select. */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
@@ -3452,7 +3451,7 @@ static int gpencil_material_select_exec(bContext *C, wmOperator *op)
}
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 21fa3ad3967..8d1f841da6c 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -3285,7 +3285,7 @@ static int gpencil_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -3555,7 +3555,7 @@ static int gpencil_stroke_join_exec(bContext *C, wmOperator *op)
BLI_assert(ELEM(type, GP_STROKE_JOIN, GP_STROKE_JOINCOPY));
int tot_strokes = 0;
- /** Alloc memory */
+ /** Alloc memory. */
tJoinStrokes *strokes_list = MEM_malloc_arrayN(sizeof(tJoinStrokes), max_join_strokes, __func__);
tJoinStrokes *elem = NULL;
/* Read all selected strokes to create a list. */
@@ -4478,7 +4478,7 @@ static int gpencil_stroke_trim_exec(bContext *C, wmOperator *op)
}
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -4619,6 +4619,8 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
if (gpl_dst == NULL) {
gpl_dst = BKE_gpencil_layer_addnew(gpd_dst, gpl->info, false, false);
BKE_gpencil_layer_copy_settings(gpl, gpl_dst);
+ /* Copy masks. */
+ BKE_gpencil_layer_mask_copy(gpl, gpl_dst);
}
/* add frame if not created before */
@@ -4679,7 +4681,7 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -4737,6 +4739,9 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
}
ob_dst->actcol = actcol;
+ /* Remove any invalid Mask relationship. */
+ BKE_gpencil_layer_mask_cleanup_all_layers(gpd_dst);
+
DEG_id_tag_update(&gpd_src->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
DEG_id_tag_update(&gpd_dst->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
@@ -4855,7 +4860,7 @@ static int gpencil_stroke_split_exec(bContext *C, wmOperator *op)
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -5082,7 +5087,7 @@ static int gpencil_cutter_lasso_select(bContext *C,
BKE_gpencil_stroke_select_index_reset(gps);
}
}
- /* if not multiedit, exit loop. */
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -5146,7 +5151,7 @@ static int gpencil_cutter_lasso_select(bContext *C,
}
}
}
- /* if not multiedit, exit loop. */
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -5165,7 +5170,7 @@ static int gpencil_cutter_lasso_select(bContext *C,
gpencil_cutter_dissolve(gpd, gpl, gps, flat_caps);
}
}
- /* if not multiedit, exit loop. */
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -5473,7 +5478,7 @@ static int gpencil_stroke_normalize_exec(bContext *C, wmOperator *op)
BKE_gpencil_stroke_geometry_update(gpd, gps);
}
}
- /* If not multiedit, exit loop. */
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 5c4e2de6aa8..4419833a99c 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -125,7 +125,7 @@ typedef struct tGPDfill {
struct bGPDframe *gpf;
/** Temp mouse position stroke. */
struct bGPDstroke *gps_mouse;
- /** Pointer to report messages. */
+ /** Pointer to report messages. */
struct ReportList *reports;
/** flags */
short flag;
@@ -810,7 +810,7 @@ static bool is_leak_narrow(ImBuf *ibuf, const int maxpixel, int limit, int index
}
}
else {
- /* edge of image*/
+ /* Edge of image. */
t_a = true;
}
/* pixels on bottom */
@@ -822,7 +822,7 @@ static bool is_leak_narrow(ImBuf *ibuf, const int maxpixel, int limit, int index
}
}
else {
- /* edge of image*/
+ /* Edge of image. */
t_b = true;
}
}
@@ -846,7 +846,7 @@ static bool is_leak_narrow(ImBuf *ibuf, const int maxpixel, int limit, int index
}
}
else {
- t_a = true; /* edge of image*/
+ t_a = true; /* Edge of image. */
}
/* pixels to left */
pt = index + extreme;
@@ -1869,7 +1869,7 @@ static int gpencil_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
DEG_id_tag_update(&tgpf->gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
- /* add a modal handler for this operator*/
+ /* Add a modal handler for this operator. */
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
@@ -2123,7 +2123,7 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
gpencil_stroke_convertcoords_tpoint(
tgpf->scene, tgpf->region, tgpf->ob, &point2D, NULL, &pt->x);
- /* Hash of selected frames.*/
+ /* Hash of selected frames. */
GHash *frame_list = BLI_ghash_int_new_ex(__func__, 64);
/* If not multiframe and there is no frame in CFRA for the active layer, create
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index 276e8c81e0f..d1a1e417d9e 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -549,51 +549,6 @@ void GPENCIL_OT_convert_old_files(struct wmOperatorType *ot);
void GPENCIL_OT_generate_weights(struct wmOperatorType *ot);
/* ****************************************************** */
-/* FILTERED ACTION DATA - TYPES ---> XXX DEPRECATED OLD ANIM SYSTEM CODE! */
-
-/* XXX - TODO: replace this with the modern bAnimListElem... */
-/* This struct defines a structure used for quick access */
-typedef struct bActListElem {
- struct bActListElem *next, *prev;
-
- void *data; /* source data this elem represents */
- int type; /* one of the ACTTYPE_* values */
- int flag; /* copy of elem's flags for quick access */
- int index; /* copy of adrcode where applicable */
-
- void *key_data; /* motion data - ipo or ipo-curve */
- short datatype; /* type of motion data to expect */
-
- struct bActionGroup *grp; /* action group that owns the channel */
-
- void *owner; /* will either be an action channel or fake IPO-channel (for keys) */
- short ownertype; /* type of owner */
-} bActListElem;
-
-/* ****************************************************** */
-/* FILTER ACTION DATA - METHODS/TYPES */
-
-/* filtering flags - under what circumstances should a channel be added */
-typedef enum ACTFILTER_FLAGS {
- ACTFILTER_VISIBLE = (1 << 0), /* should channels be visible */
- ACTFILTER_SEL = (1 << 1), /* should channels be selected */
- ACTFILTER_FOREDIT = (1 << 2), /* does editable status matter */
- ACTFILTER_CHANNELS = (1 << 3), /* do we only care that it is a channel */
- ACTFILTER_IPOKEYS = (1 << 4), /* only channels referencing IPO's */
- ACTFILTER_ONLYICU = (1 << 5), /* only reference ipo-curves */
- ACTFILTER_FORDRAWING = (1 << 6), /* make list for interface drawing */
- ACTFILTER_ACTGROUPED = (1 << 7), /* belongs to the active group */
-} ACTFILTER_FLAGS;
-
-/* Action Editor - Main Data types */
-typedef enum ACTCONT_TYPES {
- ACTCONT_NONE = 0,
- ACTCONT_ACTION,
- ACTCONT_SHAPEKEY,
- ACTCONT_GPENCIL,
-} ACTCONT_TYPES;
-
-/* ****************************************************** */
/* Stroke Iteration Utilities */
struct GP_EditableStrokes_Iter {
@@ -637,7 +592,7 @@ struct GP_EditableStrokes_Iter {
if (ED_gpencil_stroke_material_editable(obact_, gpl, gps) == false) { \
continue; \
} \
- /* ... Do Stuff With Strokes ... */
+ /* ... Do Stuff With Strokes ... */
#define GP_EDITABLE_STROKES_END(gpstroke_iter) \
} \
@@ -687,7 +642,7 @@ struct GP_EditableStrokes_Iter {
if (gps->editcurve == NULL) \
continue; \
bGPDcurve *gpc = gps->editcurve; \
- /* ... Do Stuff With Strokes ... */
+ /* ... Do Stuff With Strokes ... */
#define GP_EDITABLE_CURVES_END(gpstroke_iter) \
} \
@@ -738,7 +693,7 @@ struct GP_EditableStrokes_Iter {
if (ED_gpencil_stroke_material_editable(obact_, gpl, gps) == false) { \
continue; \
} \
- /* ... Do Stuff With Strokes ... */
+ /* ... Do Stuff With Strokes ... */
#define GP_EVALUATED_STROKES_END(gpstroke_iter) \
} \
diff --git a/source/blender/editors/gpencil/gpencil_mesh.c b/source/blender/editors/gpencil/gpencil_mesh.c
index 55468dffab0..1882285a230 100644
--- a/source/blender/editors/gpencil/gpencil_mesh.c
+++ b/source/blender/editors/gpencil/gpencil_mesh.c
@@ -159,7 +159,7 @@ static bool gpencil_bake_ob_list(bContext *C, Depsgraph *depsgraph, Scene *scene
if (ob == obact) {
continue;
}
- /* Add selected meshes.*/
+ /* Add selected meshes. */
if (ob->type == OB_MESH) {
elem = MEM_callocN(sizeof(GpBakeOb), __func__);
elem->ob = ob;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 638994bbc2a..409d10996d0 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1319,17 +1319,6 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
/* --- 'Eraser' for 'Paint' Tool ------ */
-/**
- * Which which point is in front (result should only be used for comparison).
- */
-static float view3d_point_depth(const RegionView3D *rv3d, const float co[3])
-{
- if (rv3d->is_persp) {
- return ED_view3d_calc_zfac(rv3d, co, NULL);
- }
- return -dot_v3v3(rv3d->viewinv[2], co);
-}
-
/* only erase stroke points that are visible */
static bool gpencil_stroke_eraser_is_occluded(
tGPsdata *p, bGPDlayer *gpl, bGPDspoint *pt, const int x, const int y)
@@ -1359,10 +1348,10 @@ static bool gpencil_stroke_eraser_is_occluded(
BKE_gpencil_layer_transform_matrix_get(p->depsgraph, obact, gpl, diff_mat);
if (ED_view3d_autodist_simple(p->region, mval_i, mval_3d, 0, NULL)) {
- const float depth_mval = view3d_point_depth(rv3d, mval_3d);
+ const float depth_mval = ED_view3d_calc_depth_for_comparison(rv3d, mval_3d);
mul_v3_m4v3(fpt, diff_mat, &pt->x);
- const float depth_pt = view3d_point_depth(rv3d, fpt);
+ const float depth_pt = ED_view3d_calc_depth_for_comparison(rv3d, fpt);
/* Checked occlusion flag. */
pt->flag |= GP_SPOINT_TEMP_TAG;
@@ -1433,7 +1422,7 @@ static void gpencil_stroke_soft_refine(bGPDstroke *gps)
bGPDspoint *pt2 = NULL;
int i;
- /* check if enough points*/
+ /* Check if enough points. */
if (gps->totpoints < 3) {
return;
}
@@ -1792,7 +1781,7 @@ static void gpencil_stroke_doeraser(tGPsdata *p)
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -3178,7 +3167,7 @@ static void gpencil_guide_event_handling(bContext *C,
guide->type = GP_GUIDE_CIRCULAR;
}
}
- /* Change line angle */
+ /* Change line angle. */
else if (ELEM(event->type, EVT_JKEY, EVT_KKEY) && (event->val == KM_RELEASE)) {
add_notifier = true;
float angle = guide->angle;
@@ -3460,7 +3449,7 @@ static void gpencil_add_arc_points(tGPsdata *p, const float mval[2], int segment
interp_v4_v4v4(
pt->vert_color, pt_before->vert_color, pt_prev->vert_color, stepcolor * (i + 1));
- /* Apply angle of stroke to brush size to interpolated points but slightly attenuated.. */
+ /* Apply angle of stroke to brush size to interpolated points but slightly attenuated. */
if (brush_settings->draw_angle_factor != 0.0f) {
gpencil_brush_angle_segment(p, pt_step, pt);
CLAMP(pt->pressure, pt_prev->pressure * 0.5f, 1.0f);
@@ -3771,7 +3760,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
else if (p->region) {
- /* Perform bounds check using */
+ /* Perform bounds check using. */
const rcti *region_rect = ED_region_visible_rect(p->region);
in_bounds = BLI_rcti_isect_pt_v(region_rect, event->mval);
}
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index 2b8800e5136..0226558b4a0 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -1381,7 +1381,7 @@ static float gpencil_sculpt_rotation_eval_get(tGP_BrushEditData *gso,
return 0.0f;
}
- GP_SpaceConversion *gsc = &gso->gsc;
+ const GP_SpaceConversion *gsc = &gso->gsc;
bGPDstroke *gps_orig = (gps_eval->runtime.gps_orig) ? gps_eval->runtime.gps_orig : gps_eval;
bGPDspoint *pt_orig = &gps_orig->points[pt_eval->runtime.idx_orig];
bGPDspoint *pt_prev_eval = NULL;
@@ -2020,7 +2020,7 @@ static int gpencil_sculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent
/* The operator can be in 2 states: Painting and Idling */
if (gso->is_painting) {
- /* Painting */
+ /* Painting. */
switch (event->type) {
/* Mouse Move = Apply somewhere else */
case MOUSEMOVE:
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 55521ac4d15..c33b43247fd 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -1374,7 +1374,7 @@ static bool gpencil_do_curve_circle_sel(bContext *C,
const bool handles_visible = (v3d->overlay.handle_display != CURVE_HANDLE_NONE) &&
(!only_selected || BEZT_ISSEL_ANY(bezt));
- /* if the handles are not visible only check ctrl point (vec[1])*/
+ /* If the handles are not visible only check control point (vec[1]). */
int from = (!handles_visible) ? 1 : 0;
int to = (!handles_visible) ? 2 : 3;
@@ -1719,7 +1719,7 @@ static bool gpencil_generic_curve_select(bContext *C,
}
}
}
- /* if the handles are not visible only check ctrl point (vec[1])*/
+ /* If the handles are not visible only check ctrl point (vec[1]). */
else {
const bool is_select = bezt->f2;
bool is_inside = is_inside_fn(region, gps_iter.diff_mat, bezt->vec[1], user_data);
@@ -2153,7 +2153,7 @@ static void gpencil_select_curve_point(bContext *C,
const bool handles_visible = (v3d->overlay.handle_display != CURVE_HANDLE_NONE) &&
(!only_selected || BEZT_ISSEL_ANY(bezt));
- /* if the handles are not visible only check ctrl point (vec[1])*/
+ /* If the handles are not visible only check control point (vec[1]). */
int from = (!handles_visible) ? 1 : 0;
int to = (!handles_visible) ? 2 : 3;
diff --git a/source/blender/editors/gpencil/gpencil_trace_utils.c b/source/blender/editors/gpencil/gpencil_trace_utils.c
index 12c38fb2744..970afc3ff6b 100644
--- a/source/blender/editors/gpencil/gpencil_trace_utils.c
+++ b/source/blender/editors/gpencil/gpencil_trace_utils.c
@@ -250,7 +250,7 @@ void ED_gpencil_trace_data_to_strokes(Main *bmain,
const int32_t thickness)
{
#define MAX_LENGTH 100.0f
- /* Find materials and create them if not found. */
+ /* Find materials and create them if not found. */
int32_t mat_fill_idx = BKE_gpencil_material_find_index_by_name_prefix(ob, "Stroke");
int32_t mat_mask_idx = BKE_gpencil_material_find_index_by_name_prefix(ob, "Holdout");
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 4da21bd05ee..54672743439 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -565,7 +565,7 @@ bool ED_gpencil_layer_has_selected_stroke(const bGPDlayer *gpl, const bool is_mu
return true;
}
}
- /* If not multiedit, exit loop. */
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -1640,7 +1640,7 @@ void ED_gpencil_vgroup_assign(bContext *C, Object *ob, float weight)
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -1693,7 +1693,7 @@ void ED_gpencil_vgroup_remove(bContext *C, Object *ob)
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -1748,7 +1748,7 @@ void ED_gpencil_vgroup_select(bContext *C, Object *ob)
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -1798,7 +1798,7 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob)
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -2215,7 +2215,7 @@ void ED_gpencil_tpoint_to_point(ARegion *region,
void ED_gpencil_update_color_uv(Main *bmain, Material *mat)
{
Material *gps_ma = NULL;
- /* read all strokes */
+ /* Read all strokes. */
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->type == OB_GPENCIL) {
bGPdata *gpd = ob->data;
@@ -2478,7 +2478,7 @@ int ED_gpencil_select_stroke_segment(bGPdata *gpd,
return 0;
}
- /* convert all gps points to 2d and save in a hash to avoid recalculation */
+ /* Convert all gps points to 2d and save in a hash to avoid recalculation. */
int direction = 0;
float(*points2d)[2] = MEM_mallocN(sizeof(*points2d) * gps->totpoints,
"GP Stroke temp 2d points");
@@ -3106,8 +3106,8 @@ void ED_gpencil_sbuffer_vertex_color_set(Depsgraph *depsgraph,
}
/* Get the bigger 2D bound box points. */
-void ED_gpencil_projected_2d_bound_box(GP_SpaceConversion *gsc,
- bGPDstroke *gps,
+void ED_gpencil_projected_2d_bound_box(const GP_SpaceConversion *gsc,
+ const bGPDstroke *gps,
const float diff_mat[4][4],
float r_min[2],
float r_max[2])
@@ -3140,7 +3140,7 @@ void ED_gpencil_projected_2d_bound_box(GP_SpaceConversion *gsc,
}
/* Check if the stroke collides with brush. */
-bool ED_gpencil_stroke_check_collision(GP_SpaceConversion *gsc,
+bool ED_gpencil_stroke_check_collision(const GP_SpaceConversion *gsc,
bGPDstroke *gps,
const float mouse[2],
const int radius,
@@ -3175,9 +3175,9 @@ bool ED_gpencil_stroke_check_collision(GP_SpaceConversion *gsc,
* \param diff_mat: View matrix.
* \return True if the point is inside.
*/
-bool ED_gpencil_stroke_point_is_inside(bGPDstroke *gps,
- GP_SpaceConversion *gsc,
- int mouse[2],
+bool ED_gpencil_stroke_point_is_inside(const bGPDstroke *gps,
+ const GP_SpaceConversion *gsc,
+ const int mouse[2],
const float diff_mat[4][4])
{
bool hit = false;
@@ -3190,7 +3190,7 @@ bool ED_gpencil_stroke_point_is_inside(bGPDstroke *gps,
mcoords = MEM_mallocN(sizeof(int[2]) * len, __func__);
/* Convert stroke to 2D array of points. */
- bGPDspoint *pt;
+ const bGPDspoint *pt;
int i;
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
bGPDspoint pt2;
@@ -3214,7 +3214,7 @@ bool ED_gpencil_stroke_point_is_inside(bGPDstroke *gps,
}
bGPDstroke *ED_gpencil_stroke_nearest_to_ends(bContext *C,
- GP_SpaceConversion *gsc,
+ const GP_SpaceConversion *gsc,
bGPDlayer *gpl,
bGPDframe *gpf,
bGPDstroke *gps,
@@ -3302,7 +3302,7 @@ bGPDstroke *ED_gpencil_stroke_nearest_to_ends(bContext *C,
return gps_rtn;
}
-/* Join two stroke using a contact point index and trimming the rest. */
+/* Join two stroke using a contact point index and trimming the rest. */
bGPDstroke *ED_gpencil_stroke_join_and_trim(
bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps, bGPDstroke *gps_dst, const int pt_index)
{
diff --git a/source/blender/editors/gpencil/gpencil_vertex_ops.c b/source/blender/editors/gpencil/gpencil_vertex_ops.c
index bf46fa2544f..402bccce2f7 100644
--- a/source/blender/editors/gpencil/gpencil_vertex_ops.c
+++ b/source/blender/editors/gpencil/gpencil_vertex_ops.c
@@ -99,7 +99,7 @@ static bool is_any_stroke_selected(bContext *C, const bool is_multiedit, const b
}
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -204,7 +204,7 @@ static int gpencil_vertexpaint_brightness_contrast_exec(bContext *C, wmOperator
}
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -325,7 +325,7 @@ static int gpencil_vertexpaint_hsv_exec(bContext *C, wmOperator *op)
}
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -419,7 +419,7 @@ static int gpencil_vertexpaint_invert_exec(bContext *C, wmOperator *op)
}
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -510,7 +510,7 @@ static int gpencil_vertexpaint_levels_exec(bContext *C, wmOperator *op)
}
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -605,7 +605,7 @@ static int gpencil_vertexpaint_set_exec(bContext *C, wmOperator *op)
}
}
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
@@ -1113,7 +1113,7 @@ static int gpencil_stroke_reset_vertex_color_exec(bContext *C, wmOperator *op)
changed = true;
}
- /* if not multiedit, exit loop*/
+ /* If not multi-edit, exit loop. */
if (!is_multiedit) {
break;
}
diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c b/source/blender/editors/gpencil/gpencil_vertex_paint.c
index a05cc3c4dbd..7ec64b2afd6 100644
--- a/source/blender/editors/gpencil/gpencil_vertex_paint.c
+++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c
@@ -1107,7 +1107,7 @@ static bool gpencil_vertexpaint_brush_do_frame(bContext *C,
break;
}
}
- /* Clear the selected array, but keep the memory allocation.*/
+ /* Clear the selected array, but keep the memory allocation. */
gso->pbuffer = gpencil_select_buffer_ensure(
gso->pbuffer, &gso->pbuffer_size, &gso->pbuffer_used, true);
@@ -1335,7 +1335,7 @@ static int gpencil_vertexpaint_brush_modal(bContext *C, wmOperator *op, const wm
/* The operator can be in 2 states: Painting and Idling */
if (gso->is_painting) {
- /* Painting */
+ /* Painting. */
switch (event->type) {
/* Mouse Move = Apply somewhere else */
case MOUSEMOVE:
diff --git a/source/blender/editors/gpencil/gpencil_weight_paint.c b/source/blender/editors/gpencil/gpencil_weight_paint.c
index a3e5ece5862..56eed187d87 100644
--- a/source/blender/editors/gpencil/gpencil_weight_paint.c
+++ b/source/blender/editors/gpencil/gpencil_weight_paint.c
@@ -555,7 +555,7 @@ static bool gpencil_weightpaint_brush_do_frame(bContext *C,
break;
}
}
- /* Clear the selected array, but keep the memory allocation.*/
+ /* Clear the selected array, but keep the memory allocation. */
gso->pbuffer = gpencil_select_buffer_ensure(
gso->pbuffer, &gso->pbuffer_size, &gso->pbuffer_used, true);
@@ -774,7 +774,7 @@ static int gpencil_weightpaint_brush_modal(bContext *C, wmOperator *op, const wm
/* The operator can be in 2 states: Painting and Idling */
if (gso->is_painting) {
- /* Painting */
+ /* Painting. */
switch (event->type) {
/* Mouse Move = Apply somewhere else */
case MOUSEMOVE:
diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h
index 8015a665970..44c5897d3a3 100644
--- a/source/blender/editors/include/ED_curve.h
+++ b/source/blender/editors/include/ED_curve.h
@@ -60,21 +60,21 @@ bool ED_curve_editnurb_select_pick(
struct Nurb *ED_curve_add_nurbs_primitive(
struct bContext *C, struct Object *obedit, float mat[4][4], int type, int newob);
-bool ED_curve_nurb_select_check(struct View3D *v3d, struct Nurb *nu);
-int ED_curve_nurb_select_count(struct View3D *v3d, struct Nurb *nu);
+bool ED_curve_nurb_select_check(const struct View3D *v3d, const struct Nurb *nu);
+int ED_curve_nurb_select_count(const struct View3D *v3d, const struct Nurb *nu);
bool ED_curve_nurb_select_all(const struct Nurb *nu);
bool ED_curve_nurb_deselect_all(const struct Nurb *nu);
int ED_curve_join_objects_exec(struct bContext *C, struct wmOperator *op);
/* editcurve_select.c */
-bool ED_curve_select_check(struct View3D *v3d, struct EditNurb *editnurb);
+bool ED_curve_select_check(const struct View3D *v3d, const struct EditNurb *editnurb);
bool ED_curve_deselect_all(struct EditNurb *editnurb);
bool ED_curve_deselect_all_multi_ex(struct Base **bases, int bases_len);
bool ED_curve_deselect_all_multi(struct bContext *C);
bool ED_curve_select_all(struct EditNurb *editnurb);
bool ED_curve_select_swap(struct EditNurb *editnurb, bool hide_handles);
-int ED_curve_select_count(struct View3D *v3d, struct EditNurb *editnurb);
+int ED_curve_select_count(const struct View3D *v3d, const struct EditNurb *editnurb);
/* editcurve_undo.c */
void ED_curve_undosys_type(struct UndoType *ut);
diff --git a/source/blender/editors/include/ED_datafiles.h b/source/blender/editors/include/ED_datafiles.h
index 40b0a8d96b1..59e0e014933 100644
--- a/source/blender/editors/include/ED_datafiles.h
+++ b/source/blender/editors/include/ED_datafiles.h
@@ -30,275 +30,275 @@ extern "C" {
/* Datafiles embedded in Blender */
extern int datatoc_startup_blend_size;
-extern char datatoc_startup_blend[];
+extern const char datatoc_startup_blend[];
extern int datatoc_preview_blend_size;
-extern char datatoc_preview_blend[];
+extern const char datatoc_preview_blend[];
extern int datatoc_preview_grease_pencil_blend_size;
-extern char datatoc_preview_grease_pencil_blend[];
+extern const char datatoc_preview_grease_pencil_blend[];
extern int datatoc_blender_icons16_png_size;
-extern char datatoc_blender_icons16_png[];
+extern const char datatoc_blender_icons16_png[];
extern int datatoc_blender_icons32_png_size;
-extern char datatoc_blender_icons32_png[];
+extern const char datatoc_blender_icons32_png[];
extern int datatoc_prvicons_png_size;
-extern char datatoc_prvicons_png[];
+extern const char datatoc_prvicons_png[];
extern int datatoc_alert_icons_png_size;
-extern char datatoc_alert_icons_png[];
+extern const char datatoc_alert_icons_png[];
extern int datatoc_blender_logo_png_size;
-extern char datatoc_blender_logo_png[];
+extern const char datatoc_blender_logo_png[];
extern int datatoc_splash_png_size;
-extern char datatoc_splash_png[];
+extern const char datatoc_splash_png[];
extern int datatoc_bfont_pfb_size;
-extern char datatoc_bfont_pfb[];
+extern const char datatoc_bfont_pfb[];
/* Brush icon datafiles */
/* TODO: this could be simplified by putting all
* the brush icons in one file */
extern int datatoc_add_png_size;
-extern char datatoc_add_png[];
+extern const char datatoc_add_png[];
extern int datatoc_blob_png_size;
-extern char datatoc_blob_png[];
+extern const char datatoc_blob_png[];
extern int datatoc_blur_png_size;
-extern char datatoc_blur_png[];
+extern const char datatoc_blur_png[];
extern int datatoc_clay_png_size;
-extern char datatoc_clay_png[];
+extern const char datatoc_clay_png[];
extern int datatoc_claystrips_png_size;
-extern char datatoc_claystrips_png[];
+extern const char datatoc_claystrips_png[];
extern int datatoc_clone_png_size;
-extern char datatoc_clone_png[];
+extern const char datatoc_clone_png[];
extern int datatoc_crease_png_size;
-extern char datatoc_crease_png[];
+extern const char datatoc_crease_png[];
extern int datatoc_darken_png_size;
-extern char datatoc_darken_png[];
+extern const char datatoc_darken_png[];
extern int datatoc_draw_png_size;
-extern char datatoc_draw_png[];
+extern const char datatoc_draw_png[];
extern int datatoc_fill_png_size;
-extern char datatoc_fill_png[];
+extern const char datatoc_fill_png[];
extern int datatoc_flatten_png_size;
-extern char datatoc_flatten_png[];
+extern const char datatoc_flatten_png[];
extern int datatoc_grab_png_size;
-extern char datatoc_grab_png[];
+extern const char datatoc_grab_png[];
extern int datatoc_inflate_png_size;
-extern char datatoc_inflate_png[];
+extern const char datatoc_inflate_png[];
extern int datatoc_layer_png_size;
-extern char datatoc_layer_png[];
+extern const char datatoc_layer_png[];
extern int datatoc_lighten_png_size;
-extern char datatoc_lighten_png[];
+extern const char datatoc_lighten_png[];
extern int datatoc_mask_png_size;
-extern char datatoc_mask_png[];
+extern const char datatoc_mask_png[];
extern int datatoc_mix_png_size;
-extern char datatoc_mix_png[];
+extern const char datatoc_mix_png[];
extern int datatoc_multiply_png_size;
-extern char datatoc_multiply_png[];
+extern const char datatoc_multiply_png[];
extern int datatoc_nudge_png_size;
-extern char datatoc_nudge_png[];
+extern const char datatoc_nudge_png[];
extern int datatoc_pinch_png_size;
-extern char datatoc_pinch_png[];
+extern const char datatoc_pinch_png[];
extern int datatoc_scrape_png_size;
-extern char datatoc_scrape_png[];
+extern const char datatoc_scrape_png[];
extern int datatoc_smear_png_size;
-extern char datatoc_smear_png[];
+extern const char datatoc_smear_png[];
extern int datatoc_smooth_png_size;
-extern char datatoc_smooth_png[];
+extern const char datatoc_smooth_png[];
extern int datatoc_snake_hook_png_size;
-extern char datatoc_snake_hook_png[];
+extern const char datatoc_snake_hook_png[];
extern int datatoc_soften_png_size;
-extern char datatoc_soften_png[];
+extern const char datatoc_soften_png[];
extern int datatoc_subtract_png_size;
-extern char datatoc_subtract_png[];
+extern const char datatoc_subtract_png[];
extern int datatoc_texdraw_png_size;
-extern char datatoc_texdraw_png[];
+extern const char datatoc_texdraw_png[];
extern int datatoc_texfill_png_size;
-extern char datatoc_texfill_png[];
+extern const char datatoc_texfill_png[];
extern int datatoc_texmask_png_size;
-extern char datatoc_texmask_png[];
+extern const char datatoc_texmask_png[];
extern int datatoc_thumb_png_size;
-extern char datatoc_thumb_png[];
+extern const char datatoc_thumb_png[];
extern int datatoc_twist_png_size;
-extern char datatoc_twist_png[];
+extern const char datatoc_twist_png[];
extern int datatoc_vertexdraw_png_size;
-extern char datatoc_vertexdraw_png[];
+extern const char datatoc_vertexdraw_png[];
/* Matcap files */
extern int datatoc_mc01_jpg_size;
-extern char datatoc_mc01_jpg[];
+extern const char datatoc_mc01_jpg[];
extern int datatoc_mc02_jpg_size;
-extern char datatoc_mc02_jpg[];
+extern const char datatoc_mc02_jpg[];
extern int datatoc_mc03_jpg_size;
-extern char datatoc_mc03_jpg[];
+extern const char datatoc_mc03_jpg[];
extern int datatoc_mc04_jpg_size;
-extern char datatoc_mc04_jpg[];
+extern const char datatoc_mc04_jpg[];
extern int datatoc_mc05_jpg_size;
-extern char datatoc_mc05_jpg[];
+extern const char datatoc_mc05_jpg[];
extern int datatoc_mc06_jpg_size;
-extern char datatoc_mc06_jpg[];
+extern const char datatoc_mc06_jpg[];
extern int datatoc_mc07_jpg_size;
-extern char datatoc_mc07_jpg[];
+extern const char datatoc_mc07_jpg[];
extern int datatoc_mc08_jpg_size;
-extern char datatoc_mc08_jpg[];
+extern const char datatoc_mc08_jpg[];
extern int datatoc_mc09_jpg_size;
-extern char datatoc_mc09_jpg[];
+extern const char datatoc_mc09_jpg[];
extern int datatoc_mc10_jpg_size;
-extern char datatoc_mc10_jpg[];
+extern const char datatoc_mc10_jpg[];
extern int datatoc_mc11_jpg_size;
-extern char datatoc_mc11_jpg[];
+extern const char datatoc_mc11_jpg[];
extern int datatoc_mc12_jpg_size;
-extern char datatoc_mc12_jpg[];
+extern const char datatoc_mc12_jpg[];
extern int datatoc_mc13_jpg_size;
-extern char datatoc_mc13_jpg[];
+extern const char datatoc_mc13_jpg[];
extern int datatoc_mc14_jpg_size;
-extern char datatoc_mc14_jpg[];
+extern const char datatoc_mc14_jpg[];
extern int datatoc_mc15_jpg_size;
-extern char datatoc_mc15_jpg[];
+extern const char datatoc_mc15_jpg[];
extern int datatoc_mc16_jpg_size;
-extern char datatoc_mc16_jpg[];
+extern const char datatoc_mc16_jpg[];
extern int datatoc_mc17_jpg_size;
-extern char datatoc_mc17_jpg[];
+extern const char datatoc_mc17_jpg[];
extern int datatoc_mc18_jpg_size;
-extern char datatoc_mc18_jpg[];
+extern const char datatoc_mc18_jpg[];
extern int datatoc_mc19_jpg_size;
-extern char datatoc_mc19_jpg[];
+extern const char datatoc_mc19_jpg[];
extern int datatoc_mc20_jpg_size;
-extern char datatoc_mc20_jpg[];
+extern const char datatoc_mc20_jpg[];
extern int datatoc_mc21_jpg_size;
-extern char datatoc_mc21_jpg[];
+extern const char datatoc_mc21_jpg[];
extern int datatoc_mc22_jpg_size;
-extern char datatoc_mc22_jpg[];
+extern const char datatoc_mc22_jpg[];
extern int datatoc_mc23_jpg_size;
-extern char datatoc_mc23_jpg[];
+extern const char datatoc_mc23_jpg[];
extern int datatoc_mc24_jpg_size;
-extern char datatoc_mc24_jpg[];
+extern const char datatoc_mc24_jpg[];
/* grease pencil sculpt brushes files */
extern int datatoc_gp_brush_smooth_png_size;
-extern char datatoc_gp_brush_smooth_png[];
+extern const char datatoc_gp_brush_smooth_png[];
extern int datatoc_gp_brush_thickness_png_size;
-extern char datatoc_gp_brush_thickness_png[];
+extern const char datatoc_gp_brush_thickness_png[];
extern int datatoc_gp_brush_strength_png_size;
-extern char datatoc_gp_brush_strength_png[];
+extern const char datatoc_gp_brush_strength_png[];
extern int datatoc_gp_brush_grab_png_size;
-extern char datatoc_gp_brush_grab_png[];
+extern const char datatoc_gp_brush_grab_png[];
extern int datatoc_gp_brush_push_png_size;
-extern char datatoc_gp_brush_push_png[];
+extern const char datatoc_gp_brush_push_png[];
extern int datatoc_gp_brush_twist_png_size;
-extern char datatoc_gp_brush_twist_png[];
+extern const char datatoc_gp_brush_twist_png[];
extern int datatoc_gp_brush_pinch_png_size;
-extern char datatoc_gp_brush_pinch_png[];
+extern const char datatoc_gp_brush_pinch_png[];
extern int datatoc_gp_brush_randomize_png_size;
-extern char datatoc_gp_brush_randomize_png[];
+extern const char datatoc_gp_brush_randomize_png[];
extern int datatoc_gp_brush_clone_png_size;
-extern char datatoc_gp_brush_clone_png[];
+extern const char datatoc_gp_brush_clone_png[];
extern int datatoc_gp_brush_weight_png_size;
-extern char datatoc_gp_brush_weight_png[];
+extern const char datatoc_gp_brush_weight_png[];
extern int datatoc_gp_brush_pencil_png_size;
-extern char datatoc_gp_brush_pencil_png[];
+extern const char datatoc_gp_brush_pencil_png[];
extern int datatoc_gp_brush_pen_png_size;
-extern char datatoc_gp_brush_pen_png[];
+extern const char datatoc_gp_brush_pen_png[];
extern int datatoc_gp_brush_ink_png_size;
-extern char datatoc_gp_brush_ink_png[];
+extern const char datatoc_gp_brush_ink_png[];
extern int datatoc_gp_brush_inknoise_png_size;
-extern char datatoc_gp_brush_inknoise_png[];
+extern const char datatoc_gp_brush_inknoise_png[];
extern int datatoc_gp_brush_block_png_size;
-extern char datatoc_gp_brush_block_png[];
+extern const char datatoc_gp_brush_block_png[];
extern int datatoc_gp_brush_marker_png_size;
-extern char datatoc_gp_brush_marker_png[];
+extern const char datatoc_gp_brush_marker_png[];
extern int datatoc_gp_brush_fill_png_size;
-extern char datatoc_gp_brush_fill_png[];
+extern const char datatoc_gp_brush_fill_png[];
extern int datatoc_gp_brush_airbrush_png_size;
-extern char datatoc_gp_brush_airbrush_png[];
+extern const char datatoc_gp_brush_airbrush_png[];
extern int datatoc_gp_brush_chisel_png_size;
-extern char datatoc_gp_brush_chisel_png[];
+extern const char datatoc_gp_brush_chisel_png[];
extern int datatoc_gp_brush_erase_soft_png_size;
-extern char datatoc_gp_brush_erase_soft_png[];
+extern const char datatoc_gp_brush_erase_soft_png[];
extern int datatoc_gp_brush_erase_hard_png_size;
-extern char datatoc_gp_brush_erase_hard_png[];
+extern const char datatoc_gp_brush_erase_hard_png[];
extern int datatoc_gp_brush_erase_stroke_png_size;
-extern char datatoc_gp_brush_erase_stroke_png[];
+extern const char datatoc_gp_brush_erase_stroke_png[];
#ifdef __cplusplus
}
diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h
index 8118e3c6c69..cff3a8dfa5f 100644
--- a/source/blender/editors/include/ED_fileselect.h
+++ b/source/blender/editors/include/ED_fileselect.h
@@ -136,13 +136,9 @@ void ED_fileselect_layout_tilepos(FileLayout *layout, int tile, int *x, int *y);
void ED_operatormacros_file(void);
-void ED_fileselect_clear(struct wmWindowManager *wm,
- struct Scene *owner_scene,
- struct SpaceFile *sfile);
+void ED_fileselect_clear(struct wmWindowManager *wm, struct SpaceFile *sfile);
-void ED_fileselect_exit(struct wmWindowManager *wm,
- struct Scene *owner_scene,
- struct SpaceFile *sfile);
+void ED_fileselect_exit(struct wmWindowManager *wm, struct SpaceFile *sfile);
bool ED_fileselect_is_asset_browser(const struct SpaceFile *sfile);
struct ID *ED_fileselect_active_asset_get(const struct SpaceFile *sfile);
@@ -166,7 +162,7 @@ int ED_file_icon(const struct FileDirEntry *file);
void ED_file_read_bookmarks(void);
-void ED_file_change_dir_ex(struct bContext *C, struct bScreen *screen, struct ScrArea *area);
+void ED_file_change_dir_ex(struct bContext *C, struct ScrArea *area);
void ED_file_change_dir(struct bContext *C);
void ED_file_path_button(struct bScreen *screen,
diff --git a/source/blender/editors/include/ED_gizmo_library.h b/source/blender/editors/include/ED_gizmo_library.h
index 571519e52f7..357d5e10fa7 100644
--- a/source/blender/editors/include/ED_gizmo_library.h
+++ b/source/blender/editors/include/ED_gizmo_library.h
@@ -275,7 +275,7 @@ void ED_gizmotypes_snap_3d_flag_clear(struct wmGizmo *gz, eSnapGizmo flag);
bool ED_gizmotypes_snap_3d_flag_test(struct wmGizmo *gz, eSnapGizmo flag);
bool ED_gizmotypes_snap_3d_invert_snap_get(struct wmGizmo *gz);
-bool ED_gizmotypes_snap_3d_is_enabled(struct wmGizmo *gz);
+bool ED_gizmotypes_snap_3d_is_enabled(const struct wmGizmo *gz);
short ED_gizmotypes_snap_3d_update(struct wmGizmo *gz,
struct Depsgraph *depsgraph,
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index bad080e1609..59b5a1abaa6 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -189,7 +189,7 @@ bool ED_gpencil_layer_frames_looper(struct bGPDlayer *gpl,
bool (*gpf_cb)(struct bGPDframe *, struct Scene *));
void ED_gpencil_layer_make_cfra_list(struct bGPDlayer *gpl, ListBase *elems, bool onlysel);
-bool ED_gpencil_layer_frame_select_check(struct bGPDlayer *gpl);
+bool ED_gpencil_layer_frame_select_check(const struct bGPDlayer *gpl);
void ED_gpencil_layer_frame_select_set(struct bGPDlayer *gpl, short mode);
void ED_gpencil_layer_frames_select_box(struct bGPDlayer *gpl,
float min,
@@ -364,23 +364,23 @@ void ED_gpencil_init_random_settings(struct Brush *brush,
const int mval[2],
struct GpRandomSettings *random_settings);
-bool ED_gpencil_stroke_check_collision(struct GP_SpaceConversion *gsc,
+bool ED_gpencil_stroke_check_collision(const struct GP_SpaceConversion *gsc,
struct bGPDstroke *gps,
const float mouse[2],
const int radius,
const float diff_mat[4][4]);
-bool ED_gpencil_stroke_point_is_inside(struct bGPDstroke *gps,
- struct GP_SpaceConversion *gsc,
- int mouse[2],
+bool ED_gpencil_stroke_point_is_inside(const struct bGPDstroke *gps,
+ const struct GP_SpaceConversion *gsc,
+ const int mouse[2],
const float diff_mat[4][4]);
-void ED_gpencil_projected_2d_bound_box(struct GP_SpaceConversion *gsc,
- struct bGPDstroke *gps,
+void ED_gpencil_projected_2d_bound_box(const struct GP_SpaceConversion *gsc,
+ const struct bGPDstroke *gps,
const float diff_mat[4][4],
float r_min[2],
float r_max[2]);
struct bGPDstroke *ED_gpencil_stroke_nearest_to_ends(struct bContext *C,
- struct GP_SpaceConversion *gsc,
+ const struct GP_SpaceConversion *gsc,
struct bGPDlayer *gpl,
struct bGPDframe *gpf,
struct bGPDstroke *gps,
diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h
index cf90a21f799..e29ff3ed890 100644
--- a/source/blender/editors/include/ED_keyframes_edit.h
+++ b/source/blender/editors/include/ED_keyframes_edit.h
@@ -160,7 +160,7 @@ typedef struct KeyframeEditData {
/* generic properties/data access */
/** temp list for storing custom list of data to check */
ListBase list;
- /** pointer to current scene - many tools need access to cfra/etc. */
+ /** pointer to current scene - many tools need access to cfra/etc. */
struct Scene *scene;
/** pointer to custom data - usually 'Object' but also 'rectf', but could be other types too */
void *data;
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 179c9d5b30d..0493832c06f 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -434,7 +434,7 @@ void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const ch
/* check if auto-keyframing is enabled (per scene takes precedence) */
#define IS_AUTOKEY_ON(scene) \
((scene) ? ((scene)->toolsettings->autokey_mode & AUTOKEY_ON) : (U.autokey_mode & AUTOKEY_ON))
-/* check the mode for auto-keyframing (per scene takes precedence) */
+/* Check the mode for auto-keyframing (per scene takes precedence). */
#define IS_AUTOKEY_MODE(scene, mode) \
((scene) ? ((scene)->toolsettings->autokey_mode == AUTOKEY_MODE_##mode) : \
(U.autokey_mode == AUTOKEY_MODE_##mode))
@@ -452,7 +452,7 @@ bool autokeyframe_cfra_can_key(const struct Scene *scene, struct ID *id);
/* Lesser Keyframe Checking API call:
* - Used for the buttons to check for keyframes...
*/
-bool fcurve_frame_has_keyframe(struct FCurve *fcu, float frame, short filter);
+bool fcurve_frame_has_keyframe(const struct FCurve *fcu, float frame, short filter);
/* Lesser Keyframe Checking API call:
* - Returns whether the current value of a given property differs from the interpolated value.
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h
index 247911bdc55..c2fdbc160de 100644
--- a/source/blender/editors/include/ED_mask.h
+++ b/source/blender/editors/include/ED_mask.h
@@ -100,7 +100,7 @@ bool ED_masklayer_frames_looper(struct MaskLayer *mask_layer,
struct Scene *));
void ED_masklayer_make_cfra_list(struct MaskLayer *mask_layer, ListBase *elems, bool onlysel);
-bool ED_masklayer_frame_select_check(struct MaskLayer *mask_layer);
+bool ED_masklayer_frame_select_check(const struct MaskLayer *mask_layer);
void ED_masklayer_frame_select_set(struct MaskLayer *mask_layer, short mode);
void ED_masklayer_frames_select_box(struct MaskLayer *mask_layer,
float min,
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 0e2be5eb568..7fcae2349db 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -91,7 +91,7 @@ void EDBM_mesh_load(struct Main *bmain, struct Object *ob);
/* flushes based on the current select mode. if in vertex select mode,
* verts select/deselect edges and faces, if in edge select mode,
* edges select/deselect faces and vertices, and in face select mode faces select/deselect
- * edges and vertices.*/
+ * edges and vertices. */
void EDBM_select_more(struct BMEditMesh *em, const bool use_face_step);
void EDBM_select_less(struct BMEditMesh *em, const bool use_face_step);
@@ -481,9 +481,8 @@ int ED_mesh_mirror_spatial_table_lookup(struct Object *ob,
void ED_mesh_mirror_topo_table_begin(struct Object *ob, struct Mesh *me_eval);
void ED_mesh_mirror_topo_table_end(struct Object *ob);
-/* retrieves mirrored cache vert, or NULL if there isn't one.
- * note: calling this without ensuring the mirror cache state
- * is bad.*/
+/* Retrieves mirrored cache vert, or NULL if there isn't one.
+ * NOTE: calling this without ensuring the mirror cache state is bad. */
int mesh_get_x_mirror_vert(struct Object *ob,
struct Mesh *me_eval,
int index,
diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h
index ba65840dc99..73a1548362c 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -110,7 +110,7 @@ bool ED_node_is_geometry(struct SpaceNode *snode);
void ED_node_shader_default(const struct bContext *C, struct ID *id);
void ED_node_composit_default(const struct bContext *C, struct Scene *scene);
void ED_node_texture_default(const struct bContext *C, struct Tex *tex);
-bool ED_node_select_check(ListBase *lb);
+bool ED_node_select_check(const ListBase *lb);
void ED_node_select_all(ListBase *lb, int action);
void ED_node_post_apply_transform(struct bContext *C, struct bNodeTree *ntree);
void ED_node_set_active(struct Main *bmain,
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 1738c383328..888dcd9d428 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -62,7 +62,8 @@ struct Object *ED_object_active_context(const struct bContext *C);
void ED_collection_hide_menu_draw(const struct bContext *C, struct uiLayout *layout);
Object **ED_object_array_in_mode_or_selected(struct bContext *C,
- bool (*filter_fn)(struct Object *ob, void *user_data),
+ bool (*filter_fn)(const struct Object *ob,
+ void *user_data),
void *filter_user_data,
uint *r_objects_len);
@@ -387,7 +388,7 @@ void ED_object_mode_generic_exit(struct Main *bmain,
struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
-bool ED_object_mode_generic_has_data(struct Depsgraph *depsgraph, struct Object *ob);
+bool ED_object_mode_generic_has_data(struct Depsgraph *depsgraph, const struct Object *ob);
void ED_object_posemode_set_for_weight_paint(struct bContext *C,
struct Main *bmain,
diff --git a/source/blender/editors/include/ED_spreadsheet.h b/source/blender/editors/include/ED_spreadsheet.h
index 3a07b1b9d4b..88bc4738c0b 100644
--- a/source/blender/editors/include/ED_spreadsheet.h
+++ b/source/blender/editors/include/ED_spreadsheet.h
@@ -30,9 +30,9 @@ struct SpreadsheetContext *ED_spreadsheet_context_new(int type);
void ED_spreadsheet_context_free(struct SpreadsheetContext *context);
void ED_spreadsheet_context_path_clear(struct SpaceSpreadsheet *sspreadsheet);
void ED_spreadsheet_context_path_update_tag(struct SpaceSpreadsheet *sspreadsheet);
-uint64_t ED_spreadsheet_context_path_hash(struct SpaceSpreadsheet *sspreadsheet);
+uint64_t ED_spreadsheet_context_path_hash(const struct SpaceSpreadsheet *sspreadsheet);
-struct ID *ED_spreadsheet_get_current_id(struct SpaceSpreadsheet *sspreadsheet);
+struct ID *ED_spreadsheet_get_current_id(const struct SpaceSpreadsheet *sspreadsheet);
void ED_spreadsheet_set_geometry_node_context(struct SpaceSpreadsheet *sspreadsheet,
struct SpaceNode *snode,
diff --git a/source/blender/editors/include/ED_undo.h b/source/blender/editors/include/ED_undo.h
index ed1ec96a13f..059277e1466 100644
--- a/source/blender/editors/include/ED_undo.h
+++ b/source/blender/editors/include/ED_undo.h
@@ -53,7 +53,7 @@ void ED_OT_undo_redo(struct wmOperatorType *ot);
void ED_OT_undo_history(struct wmOperatorType *ot);
int ED_undo_operator_repeat(struct bContext *C, struct wmOperator *op);
-/* convenience since UI callbacks use this mostly*/
+/* Convenience since UI callbacks use this mostly. */
void ED_undo_operator_repeat_cb(struct bContext *C, void *arg_op, void *arg_unused);
void ED_undo_operator_repeat_cb_evt(struct bContext *C, void *arg_op, int arg_unused);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 64883ed5f1d..2c958d282f9 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -210,7 +210,7 @@ typedef enum {
* \note Perspective views should enable #V3D_PROJ_TEST_CLIP_WIN along with
* #V3D_PROJ_TEST_CLIP_NEAR as the near-plane-clipped location of a point
* may become very large (even infinite) when projected into screen-space.
- * Unless the that point happens to coincide with the camera's point of view.
+ * Unless that point happens to coincide with the camera's point of view.
*
* Use #V3D_PROJ_TEST_CLIP_CONTENT_DEFAULT instead of #V3D_PROJ_TEST_CLIP_CONTENT,
* to avoid accidentally enabling near clipping without clipping by window bounds.
@@ -366,6 +366,8 @@ float ED_view3d_pixel_size(const struct RegionView3D *rv3d, const float co[3]);
float ED_view3d_pixel_size_no_ui_scale(const struct RegionView3D *rv3d, const float co[3]);
float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3], bool *r_flip);
+float ED_view3d_calc_depth_for_comparison(const struct RegionView3D *rv3d, const float co[3]);
+
bool ED_view3d_clip_segment(const struct RegionView3D *rv3d, float ray_start[3], float ray_end[3]);
bool ED_view3d_win_to_ray_clipped(struct Depsgraph *depsgraph,
const struct ARegion *region,
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index f0a4b3c462e..484e083c111 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -989,7 +989,7 @@ DEF_ICON_VECTOR(COLLECTION_COLOR_06)
DEF_ICON_VECTOR(COLLECTION_COLOR_07)
DEF_ICON_VECTOR(COLLECTION_COLOR_08)
-/* Events */
+/* Events. */
DEF_ICON_COLOR(EVENT_A)
DEF_ICON_COLOR(EVENT_B)
DEF_ICON_COLOR(EVENT_C)
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index df65c602fc4..47e3dc84503 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -318,8 +318,8 @@ typedef enum {
UI_BUT_POIN_SHORT = 64,
UI_BUT_POIN_INT = 96,
UI_BUT_POIN_FLOAT = 128,
- /* UI_BUT_POIN_FUNCTION = 192, */ /*UNUSED*/
- UI_BUT_POIN_BIT = 256, /* OR'd with a bit index*/
+ // UI_BUT_POIN_FUNCTION = 192, /* UNUSED */
+ UI_BUT_POIN_BIT = 256, /* OR'd with a bit index. */
} eButPointerType;
/* requires (but->poin != NULL) */
@@ -386,6 +386,7 @@ typedef enum {
/** Resize handle (resize uilist). */
UI_BTYPE_GRIP = 57 << 9,
UI_BTYPE_DECORATOR = 58 << 9,
+ UI_BTYPE_DATASETROW = 59 << 9,
} eButType;
#define BUTTYPE (63 << 9)
@@ -503,7 +504,6 @@ typedef void (*uiButSearchUpdateFn)(const struct bContext *C,
const char *str,
uiSearchItems *items,
const bool is_first);
-typedef void (*uiButSearchArgFreeFn)(void *arg);
typedef bool (*uiButSearchContextMenuFn)(struct bContext *C,
void *arg,
void *active,
@@ -516,7 +516,7 @@ typedef struct ARegion *(*uiButSearchTooltipFn)(struct bContext *C,
/* Must return allocated string. */
typedef char *(*uiButToolTipFunc)(struct bContext *C, void *argN, const char *tip);
-typedef int (*uiButPushedStateFunc)(struct bContext *C, void *arg);
+typedef int (*uiButPushedStateFunc)(struct uiBut *but, const void *arg);
typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event);
@@ -532,6 +532,8 @@ typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
*/
typedef bool (*uiMenuStepFunc)(struct bContext *C, int direction, void *arg1);
+typedef void (*uiFreeArgFunc)(void *arg);
+
/* interface_query.c */
bool UI_but_has_tooltip_label(const uiBut *but);
bool UI_but_is_tool(const uiBut *but);
@@ -618,11 +620,11 @@ typedef void (*uiBlockCancelFunc)(struct bContext *C, void *arg1);
void UI_popup_block_invoke(struct bContext *C,
uiBlockCreateFunc func,
void *arg,
- void (*arg_free)(void *arg));
+ uiFreeArgFunc arg_free);
void UI_popup_block_invoke_ex(struct bContext *C,
uiBlockCreateFunc func,
void *arg,
- void (*arg_free)(void *arg),
+ uiFreeArgFunc arg_free,
bool can_refresh);
void UI_popup_block_ex(struct bContext *C,
uiBlockCreateFunc func,
@@ -1598,7 +1600,7 @@ void UI_but_func_search_set(uiBut *but,
uiButSearchUpdateFn search_update_fn,
void *arg,
const bool free_arg,
- uiButSearchArgFreeFn search_arg_free_fn,
+ uiFreeArgFunc search_arg_free_fn,
uiButHandleFunc search_exec_fn,
void *active);
void UI_but_func_search_set_context_menu(uiBut *but, uiButSearchContextMenuFn context_menu_fn);
@@ -1612,6 +1614,13 @@ int UI_searchbox_size_x(void);
/* check if a string is in an existing search box */
int UI_search_items_find_index(uiSearchItems *items, const char *name);
+void UI_but_hint_drawstr_set(uiBut *but, const char *string);
+void UI_but_datasetrow_indentation_set(uiBut *but, int indentation);
+void UI_but_datasetrow_component_set(uiBut *but, uint8_t geometry_component_type);
+void UI_but_datasetrow_domain_set(uiBut *but, uint8_t attribute_domain);
+uint8_t UI_but_datasetrow_component_get(uiBut *but);
+uint8_t UI_but_datasetrow_domain_get(uiBut *but);
+
void UI_but_node_link_set(uiBut *but, struct bNodeSocket *socket, const float draw_color[4]);
void UI_but_number_step_size_set(uiBut *but, float step_size);
@@ -1636,7 +1645,7 @@ void UI_but_func_drawextra_set(
void UI_but_func_menu_step_set(uiBut *but, uiMenuStepFunc func);
-void UI_but_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *argN);
+void UI_but_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *arg, uiFreeArgFunc free_arg);
void UI_but_tooltip_refresh(struct bContext *C, uiBut *but);
void UI_but_tooltip_timer_remove(struct bContext *C, uiBut *but);
@@ -1650,7 +1659,7 @@ void UI_but_focus_on_enter_event(struct wmWindow *win, uiBut *but);
void UI_but_func_hold_set(uiBut *but, uiButHandleHoldFunc func, void *argN);
-void UI_but_func_pushed_state_set(uiBut *but, uiButPushedStateFunc func, void *arg);
+void UI_but_func_pushed_state_set(uiBut *but, uiButPushedStateFunc func, const void *arg);
struct PointerRNA *UI_but_extra_operator_icon_add(uiBut *but,
const char *opname,
@@ -2417,12 +2426,20 @@ void uiItemPopoverPanelFromGroup(uiLayout *layout,
void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg);
void uiItemMenuFN(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *argN);
-void uiItemMenuEnumO_ptr(uiLayout *layout,
+void uiItemMenuEnumFullO_ptr(uiLayout *layout,
+ struct bContext *C,
+ struct wmOperatorType *ot,
+ const char *propname,
+ const char *name,
+ int icon,
+ struct PointerRNA *r_opptr);
+void uiItemMenuEnumFullO(uiLayout *layout,
struct bContext *C,
- struct wmOperatorType *ot,
+ const char *opname,
const char *propname,
const char *name,
- int icon);
+ int icon,
+ struct PointerRNA *r_opptr);
void uiItemMenuEnumO(uiLayout *layout,
struct bContext *C,
const char *opname,
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 999f42efe65..16729873b4e 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -288,7 +288,7 @@ void UI_view2d_smooth_view(struct bContext *C,
/* Gizmo Types */
/* view2d_gizmo_navigate.c */
-/* Caller passes in own idname. */
+/* Caller passes in own idname. */
void VIEW2D_GGT_navigate_impl(struct wmGizmoGroupType *gzgt, const char *idname);
/* Edge pan */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index f5528638bec..6f341edf11b 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -811,7 +811,8 @@ static void ui_but_update_old_active_from_new(uiBut *oldbut, uiBut *but)
/* Move tooltip from new to old. */
SWAP(uiButToolTipFunc, oldbut->tip_func, but->tip_func);
- SWAP(void *, oldbut->tip_argN, but->tip_argN);
+ SWAP(void *, oldbut->tip_arg, but->tip_arg);
+ SWAP(uiFreeArgFunc, oldbut->tip_arg_free, but->tip_arg_free);
oldbut->flag = (oldbut->flag & ~flag_copy) | (but->flag & flag_copy);
oldbut->drawflag = (oldbut->drawflag & ~drawflag_copy) | (but->drawflag & drawflag_copy);
@@ -822,7 +823,7 @@ static void ui_but_update_old_active_from_new(uiBut *oldbut, uiBut *but)
if (oldbut->type == UI_BTYPE_SEARCH_MENU) {
uiButSearch *search_oldbut = (uiButSearch *)oldbut, *search_but = (uiButSearch *)but;
- SWAP(uiButSearchArgFreeFn, search_oldbut->arg_free_fn, search_but->arg_free_fn);
+ SWAP(uiFreeArgFunc, search_oldbut->arg_free_fn, search_but->arg_free_fn);
SWAP(void *, search_oldbut->arg, search_but->arg);
}
@@ -1198,7 +1199,7 @@ static bool ui_but_event_operator_string_from_menu(const bContext *C,
/* annoying, create a property */
const IDPropertyTemplate val = {0};
- IDProperty *prop_menu = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */
+ IDProperty *prop_menu = IDP_New(IDP_GROUP, &val, __func__); /* Dummy, name is unimportant. */
IDP_AddToGroup(prop_menu, IDP_NewString(mt->idname, "name", sizeof(mt->idname)));
if (WM_key_event_operator_string(
@@ -1223,7 +1224,7 @@ static bool ui_but_event_operator_string_from_panel(const bContext *C,
/* annoying, create a property */
const IDPropertyTemplate val = {0};
- IDProperty *prop_panel = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */
+ IDProperty *prop_panel = IDP_New(IDP_GROUP, &val, __func__); /* Dummy, name is unimportant. */
IDP_AddToGroup(prop_panel, IDP_NewString(pt->idname, "name", sizeof(pt->idname)));
IDP_AddToGroup(prop_panel,
IDP_New(IDP_INT,
@@ -1804,7 +1805,7 @@ void UI_block_update_from_old(const bContext *C, uiBlock *block)
static void ui_but_validate(const uiBut *but)
{
/* Number buttons must have a click-step,
- * assert instead of correcting the value to ensure the caller knows what they're doing. */
+ * assert instead of correcting the value to ensure the caller knows what they're doing. */
if (but->type == UI_BTYPE_NUM) {
uiButNumber *number_but = (uiButNumber *)but;
@@ -2105,6 +2106,9 @@ void UI_region_message_subscribe(ARegion *region, struct wmMsgBus *mbus)
int ui_but_is_pushed_ex(uiBut *but, double *value)
{
int is_push = 0;
+ if (but->pushed_state_func) {
+ return but->pushed_state_func(but, but->pushed_state_arg);
+ }
if (but->bit) {
const bool state = !ELEM(
@@ -2253,7 +2257,6 @@ void ui_but_v3_get(uiBut *but, float vec[3])
}
else if (but->pointype == UI_BUT_POIN_CHAR) {
const char *cp = (char *)but->poin;
-
vec[0] = ((float)cp[0]) / 255.0f;
vec[1] = ((float)cp[1]) / 255.0f;
vec[2] = ((float)cp[2]) / 255.0f;
@@ -3243,8 +3246,8 @@ void ui_but_range_set_soft(uiBut *but)
RNA_property_int_ui_range(&but->rnapoin, but->rnaprop, &imin, &imax, &istep);
softmin = (imin == INT_MIN) ? -1e4 : imin;
softmax = (imin == INT_MAX) ? 1e4 : imax;
- /*step = istep;*/ /*UNUSED*/
- /*precision = 1;*/ /*UNUSED*/
+ // step = istep; /* UNUSED */
+ // precision = 1; /* UNUSED */
if (is_array) {
int value_range[2];
@@ -3263,8 +3266,8 @@ void ui_but_range_set_soft(uiBut *but)
RNA_property_float_ui_range(&but->rnapoin, but->rnaprop, &fmin, &fmax, &fstep, &fprecision);
softmin = (fmin == -FLT_MAX) ? (float)-1e4 : fmin;
softmax = (fmax == FLT_MAX) ? (float)1e4 : fmax;
- /*step = fstep;*/ /*UNUSED*/
- /*precision = fprecision;*/ /*UNUSED*/
+ // step = fstep; /* UNUSED */
+ // precision = fprecision; /* UNUSED */
/* Use shared min/max for array values, except for color alpha. */
if (is_array && !(subtype == PROP_COLOR && but->rnaindex == 3)) {
@@ -3356,8 +3359,8 @@ static void ui_but_free(const bContext *C, uiBut *but)
MEM_freeN(but->func_argN);
}
- if (but->tip_argN) {
- MEM_freeN(but->tip_argN);
+ if (but->tip_arg_free) {
+ but->tip_arg_free(but->tip_arg);
}
if (but->hold_argN) {
@@ -3578,7 +3581,7 @@ static void ui_but_build_drawstr_float(uiBut *but, double value)
subtype = RNA_property_subtype(but->rnaprop);
}
- /* Change negative zero to regular zero, without altering anything else. */
+ /* Change negative zero to regular zero, without altering anything else. */
value += +0.0f;
if (value == (double)FLT_MAX) {
@@ -3903,6 +3906,10 @@ static void ui_but_alloc_info(const eButType type,
alloc_size = sizeof(uiButCurveProfile);
alloc_str = "uiButCurveProfile";
break;
+ case UI_BTYPE_DATASETROW:
+ alloc_size = sizeof(uiButDatasetRow);
+ alloc_str = "uiButDatasetRow";
+ break;
default:
alloc_size = sizeof(uiBut);
alloc_str = "uiBut";
@@ -4100,6 +4107,7 @@ static uiBut *ui_def_but(uiBlock *block,
UI_BTYPE_BUT_MENU,
UI_BTYPE_SEARCH_MENU,
UI_BTYPE_PROGRESS_BAR,
+ UI_BTYPE_DATASETROW,
UI_BTYPE_POPOVER)) {
but->drawflag |= (UI_BUT_TEXT_LEFT | UI_BUT_ICON_LEFT);
}
@@ -4146,7 +4154,7 @@ static uiBut *ui_def_but(uiBlock *block,
}
#ifdef WITH_PYTHON
- /* if the 'UI_OT_editsource' is running, extract the source info from the button */
+ /* If the 'UI_OT_editsource' is running, extract the source info from the button. */
if (UI_editsource_enable_check()) {
UI_editsource_active_but_test(but);
}
@@ -4184,7 +4192,7 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
uiPopupBlockHandle *handle = block->handle;
uiBut *but = (uiBut *)but_p;
- /* see comment in ui_item_enum_expand, re: uiname */
+ /* see comment in ui_item_enum_expand, re: `uiname`. */
const EnumPropertyItem *item_array;
UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT);
@@ -4589,7 +4597,7 @@ static uiBut *ui_def_but_rna(uiBlock *block,
if (proptype == PROP_POINTER) {
/* If the button shows an ID, automatically set it as focused in context so operators can
- * access it.*/
+ * access it. */
const PointerRNA pptr = RNA_property_pointer_get(ptr, prop);
if (pptr.data && RNA_struct_is_ID(pptr.type)) {
but->context = CTX_store_add(&block->contexts, "id", &pptr);
@@ -6327,19 +6335,21 @@ void UI_but_func_menu_step_set(uiBut *but, uiMenuStepFunc func)
but->menu_step_func = func;
}
-void UI_but_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *argN)
+void UI_but_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *arg, uiFreeArgFunc free_arg)
{
but->tip_func = func;
- if (but->tip_argN) {
- MEM_freeN(but->tip_argN);
+ if (but->tip_arg_free) {
+ but->tip_arg_free(but->tip_arg);
}
- but->tip_argN = argN;
+ but->tip_arg = arg;
+ but->tip_arg_free = free_arg;
}
-void UI_but_func_pushed_state_set(uiBut *but, uiButPushedStateFunc func, void *arg)
+void UI_but_func_pushed_state_set(uiBut *but, uiButPushedStateFunc func, const void *arg)
{
but->pushed_state_func = func;
but->pushed_state_arg = arg;
+ ui_but_update(but);
}
uiBut *uiDefBlockBut(uiBlock *block,
@@ -6622,7 +6632,7 @@ void UI_but_func_search_set(uiBut *but,
uiButSearchUpdateFn search_update_fn,
void *arg,
const bool free_arg,
- uiButSearchArgFreeFn search_arg_free_fn,
+ uiFreeArgFunc search_arg_free_fn,
uiButHandleFunc search_exec_fn,
void *active)
{
@@ -6824,6 +6834,55 @@ uiBut *uiDefSearchButO_ptr(uiBlock *block,
return but;
}
+void UI_but_datasetrow_indentation_set(uiBut *but, int indentation)
+{
+ uiButDatasetRow *but_dataset = (uiButDatasetRow *)but;
+ BLI_assert(but->type == UI_BTYPE_DATASETROW);
+
+ but_dataset->indentation = indentation;
+ BLI_assert(indentation >= 0);
+}
+
+/**
+ * Adds a hint to the button which draws right aligned, grayed out and never clipped.
+ */
+void UI_but_hint_drawstr_set(uiBut *but, const char *string)
+{
+ ui_but_add_shortcut(but, string, false);
+}
+
+void UI_but_datasetrow_component_set(uiBut *but, uint8_t geometry_component_type)
+{
+ uiButDatasetRow *but_dataset_row = (uiButDatasetRow *)but;
+ BLI_assert(but->type == UI_BTYPE_DATASETROW);
+
+ but_dataset_row->geometry_component_type = geometry_component_type;
+}
+
+void UI_but_datasetrow_domain_set(uiBut *but, uint8_t attribute_domain)
+{
+ uiButDatasetRow *but_dataset_row = (uiButDatasetRow *)but;
+ BLI_assert(but->type == UI_BTYPE_DATASETROW);
+
+ but_dataset_row->attribute_domain = attribute_domain;
+}
+
+uint8_t UI_but_datasetrow_component_get(uiBut *but)
+{
+ uiButDatasetRow *but_dataset_row = (uiButDatasetRow *)but;
+ BLI_assert(but->type == UI_BTYPE_DATASETROW);
+
+ return but_dataset_row->geometry_component_type;
+}
+
+uint8_t UI_but_datasetrow_domain_get(uiBut *but)
+{
+ uiButDatasetRow *but_dataset_row = (uiButDatasetRow *)but;
+ BLI_assert(but->type == UI_BTYPE_DATASETROW);
+
+ return but_dataset_row->attribute_domain;
+}
+
void UI_but_node_link_set(uiBut *but, bNodeSocket *socket, const float draw_color[4])
{
but->flag |= UI_BUT_NODE_LINK;
@@ -6908,7 +6967,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
}
else if (type == BUT_GET_TIP) {
if (but->tip_func) {
- tmp = but->tip_func(C, but->tip_argN, but->tip);
+ tmp = but->tip_func(C, but->tip_arg, but->tip);
}
else if (but->tip && but->tip[0]) {
tmp = BLI_strdup(but->tip);
diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c
index 1f9c736a5f3..dbfdfbf7950 100644
--- a/source/blender/editors/interface/interface_align.c
+++ b/source/blender/editors/interface/interface_align.c
@@ -590,7 +590,8 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
/* rows == 0: 1 row, cols == 0: 1 column */
- /* note; how it uses 'flag' in loop below (either set it, or OR it) is confusing */
+ /* NOTE: manipulation of 'flag' in the loop below is confusing.
+ * In some cases it's assigned, other times OR is used. */
for (but = first, prev = NULL; but && but->alignnr == nr; prev = but, but = but->next) {
next = but->next;
if (next && next->alignnr != nr) {
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 40cfcaea883..05b6fcdded1 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -69,8 +69,7 @@ static int roundboxtype = UI_CNR_ALL;
void UI_draw_roundbox_corner_set(int type)
{
/* Not sure the roundbox function is the best place to change this
- * if this is undone, it's not that big a deal, only makes curves edges
- * square for the */
+ * if this is undone, it's not that big a deal, only makes curves edges square. */
roundboxtype = type;
}
diff --git a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
index f2899fc0098..417807afff1 100644
--- a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
@@ -255,7 +255,7 @@ static void eyedropper_gpencil_color_set(bContext *C, const wmEvent *event, Eyed
copy_v3_v3(col_conv, eye->color);
}
- /* Add material or Palette color*/
+ /* Add material or Palette color. */
if (eye->mode == 0) {
eyedropper_add_material(C, col_conv, only_stroke, only_fill, both);
}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 1c55ce0f348..45609d96840 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -469,7 +469,7 @@ typedef struct uiAfterFunc {
PropertyRNA *rnaprop;
void *search_arg;
- uiButSearchArgFreeFn search_arg_free_fn;
+ uiFreeArgFunc search_arg_free_fn;
bContextStore *context;
@@ -1461,12 +1461,9 @@ static bool ui_drag_toggle_but_is_supported(const uiBut *but)
/* Button pushed state to compare if other buttons match. Can be more
* then just true or false for toggle buttons with more than 2 states. */
-static int ui_drag_toggle_but_pushed_state(bContext *C, uiBut *but)
+static int ui_drag_toggle_but_pushed_state(uiBut *but)
{
if (but->rnapoin.data == NULL && but->poin == NULL && but->icon) {
- if (but->pushed_state_func) {
- return but->pushed_state_func(C, but->pushed_state_arg);
- }
/* Assume icon identifies a unique state, for buttons that
* work through functions callbacks and don't have an boolean
* value that indicates the state. */
@@ -1513,7 +1510,7 @@ static bool ui_drag_toggle_set_xy_xy(
/* execute the button */
if (ui_drag_toggle_but_is_supported(but)) {
/* is it pressed? */
- const int pushed_state_but = ui_drag_toggle_but_pushed_state(C, but);
+ const int pushed_state_but = ui_drag_toggle_but_pushed_state(but);
if (pushed_state_but != pushed_state) {
UI_but_execute(C, region, but);
if (do_check) {
@@ -1943,7 +1940,7 @@ static bool ui_but_drag_init(bContext *C,
* typically 'button_activate_exit()' handles this */
ui_apply_but_autokey(C, but);
- drag_info->pushed_state = ui_drag_toggle_but_pushed_state(C, but);
+ drag_info->pushed_state = ui_drag_toggle_but_pushed_state(but);
drag_info->but_cent_start[0] = BLI_rctf_cent_x(&but->rect);
drag_info->but_cent_start[1] = BLI_rctf_cent_y(&but->rect);
copy_v2_v2_int(drag_info->xy_init, &event->x);
@@ -2187,6 +2184,9 @@ static void ui_apply_but(
case UI_BTYPE_LISTROW:
ui_apply_but_ROW(C, block, but, data);
break;
+ case UI_BTYPE_DATASETROW:
+ ui_apply_but_ROW(C, block, but, data);
+ break;
case UI_BTYPE_TAB:
ui_apply_but_TAB(C, but, data);
break;
@@ -3068,7 +3068,7 @@ static bool ui_textedit_insert_buf(uiBut *but,
if ((len + step >= data->maxlen) && (data->maxlen - (len + 1) > 0)) {
if (UI_but_is_utf8(but)) {
- /* shorten 'step' to a utf8 aligned size that fits */
+ /* Shorten 'step' to a utf8 aligned size that fits. */
BLI_strnlen_utf8_ex(buf, data->maxlen - (len + 1), &step);
}
else {
@@ -4552,7 +4552,7 @@ static int ui_do_but_TEX(
if (ELEM(event->type, EVT_PADENTER, EVT_RETKEY) && (!UI_but_is_utf8(but))) {
/* pass - allow filesel, enter to execute */
}
- else if (but->emboss == UI_EMBOSS_NONE && !event->ctrl) {
+ else if (ELEM(but->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS) && !event->ctrl) {
/* pass */
}
else {
@@ -4770,7 +4770,7 @@ static float ui_numedit_apply_snapf(
UnitSettings *unit = but->block->unit;
const int unit_type = UI_but_unit_type_get(but);
if ((unit_type == PROP_UNIT_ROTATION) && (unit->system_rotation != USER_UNIT_ROT_RADIANS)) {
- /* pass (degrees)*/
+ /* Pass (degrees). */
}
else {
softrange = 20.0f;
@@ -5883,7 +5883,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
* wouldn't lead to cancel changes made to this button, but changing state to EXIT also
* makes no button active for a while which leads to triggering operator when doing fast
* scrolling mouse wheel. using post activate stuff from button allows to make button be
- * active again after checking for all all that mouse leave and cancel stuff, so quick
+ * active again after checking for all that mouse leave and cancel stuff, so quick
* scroll wouldn't be an issue anymore. Same goes for scrolling wheel in another
* direction below (sergey).
*/
@@ -7827,6 +7827,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
case UI_BTYPE_CHECKBOX:
case UI_BTYPE_CHECKBOX_N:
case UI_BTYPE_ROW:
+ case UI_BTYPE_DATASETROW:
retval = ui_do_but_TOG(C, but, data, event);
break;
case UI_BTYPE_SCROLL:
@@ -7989,8 +7990,7 @@ static void ui_blocks_set_tooltips(ARegion *region, const bool enable)
return;
}
- /* we disabled buttons when when they were already shown, and
- * re-enable them on mouse move */
+ /* We disabled buttons when they were already shown, and re-enable them on mouse move. */
LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
block->tooltipdisabled = !enable;
}
@@ -8216,8 +8216,8 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
data->hold_action_timer = NULL;
}
- /* add a blocking ui handler at the window handler for blocking, modal states
- * but not for popups, because we already have a window level handler*/
+ /* Add a blocking ui handler at the window handler for blocking, modal states
+ * but not for popups, because we already have a window level handler. */
if (!(but->block->handle && but->block->handle->popup)) {
if (button_modal_state(state)) {
if (!button_modal_state(data->state)) {
@@ -10015,7 +10015,7 @@ static int ui_handle_menu_event(bContext *C,
}
if (!but) {
- /* wrap button or no active button*/
+ /* Wrap button or no active button. */
uiBut *but_wrap = NULL;
if (ELEM(scrolltype, MENU_SCROLL_UP, MENU_SCROLL_BOTTOM)) {
but_wrap = ui_but_last(block);
@@ -10359,7 +10359,7 @@ static int ui_handle_menu_event(bContext *C,
* anymore why it was there? but it meant enter didn't work
* for example when mouse was not over submenu */
if ((event->type == TIMER) ||
- (/*inside &&*/ (!menu->menuretval || (menu->menuretval & UI_RETURN_UPDATE)) &&
+ (/* inside && */ (!menu->menuretval || (menu->menuretval & UI_RETURN_UPDATE)) &&
retval == WM_UI_HANDLER_CONTINUE)) {
retval = ui_handle_menu_button(C, event, menu);
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 23856c41ceb..b9a44b5bce9 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -137,19 +137,19 @@ extern const short ui_radial_dir_to_angle[8];
/** #PieMenuData.flags */
enum {
- /** pie menu item collision is detected at 90 degrees */
+ /** Pie menu item collision is detected at 90 degrees. */
UI_PIE_DEGREES_RANGE_LARGE = (1 << 0),
- /** use initial center of pie menu to calculate direction */
+ /** Use initial center of pie menu to calculate direction. */
UI_PIE_INITIAL_DIRECTION = (1 << 1),
- /** pie menu is drag style */
+ /** Pie menu is drag style. */
UI_PIE_DRAG_STYLE = (1 << 2),
- /** mouse not far enough from center position */
+ /** Mouse not far enough from center position. */
UI_PIE_INVALID_DIR = (1 << 3),
- /** pie menu changed to click style, click to confirm */
+ /** Pie menu changed to click style, click to confirm. */
UI_PIE_CLICK_STYLE = (1 << 4),
- /** pie animation finished, do not calculate any more motion */
+ /** Pie animation finished, do not calculate any more motion. */
UI_PIE_ANIMATION_FINISHED = (1 << 5),
- /** pie gesture selection has been done, now wait for mouse motion to end */
+ /** Pie gesture selection has been done, now wait for mouse motion to end. */
UI_PIE_GESTURE_END_WAIT = (1 << 6),
};
@@ -221,7 +221,8 @@ struct uiBut {
const char *tip;
uiButToolTipFunc tip_func;
- void *tip_argN;
+ void *tip_arg;
+ uiFreeArgFunc tip_arg_free;
/** info on why button is disabled, displayed in tooltip */
const char *disabled_info;
@@ -279,7 +280,7 @@ struct uiBut {
float *editvec;
uiButPushedStateFunc pushed_state_func;
- void *pushed_state_arg;
+ const void *pushed_state_arg;
/* pointer back */
uiBlock *block;
@@ -316,7 +317,7 @@ typedef struct uiButSearch {
void *item_active;
void *arg;
- uiButSearchArgFreeFn arg_free_fn;
+ uiFreeArgFunc arg_free_fn;
uiButSearchContextMenuFn item_context_menu_fn;
uiButSearchTooltipFn item_tooltip_fn;
@@ -350,6 +351,15 @@ typedef struct uiButProgressbar {
float progress;
} uiButProgressbar;
+/** Derived struct for #UI_BTYPE_DATASETROW. */
+typedef struct uiButDatasetRow {
+ uiBut but;
+
+ uint8_t geometry_component_type;
+ uint8_t attribute_domain;
+ int indentation;
+} uiButDatasetRow;
+
/** Derived struct for #UI_BTYPE_HSVCUBE. */
typedef struct uiButHSVCube {
uiBut but;
@@ -695,7 +705,7 @@ struct uiPopupBlockCreate {
uiBlockCreateFunc create_func;
uiBlockHandleCreateFunc handle_create_func;
void *arg;
- void (*arg_free)(void *arg);
+ uiFreeArgFunc arg_free;
int event_xy[2];
@@ -819,7 +829,7 @@ uiPopupBlockHandle *ui_popup_block_create(struct bContext *C,
uiBlockCreateFunc create_func,
uiBlockHandleCreateFunc handle_create_func,
void *arg,
- void (*arg_free)(void *arg));
+ uiFreeArgFunc arg_free);
uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C,
struct ARegion *butregion,
uiBut *but,
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index c04432a2912..a17a527c868 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1191,7 +1191,7 @@ static uiBut *uiItemFullO_ptr_ex(uiLayout *layout,
const eUIEmbossType prev_emboss = layout->emboss;
if (flag & UI_ITEM_R_NO_BG) {
- layout->emboss = UI_EMBOSS_NONE;
+ layout->emboss = UI_EMBOSS_NONE_OR_STATUS;
}
/* create the button */
@@ -2122,7 +2122,7 @@ void uiItemFullR(uiLayout *layout,
const eUIEmbossType prev_emboss = layout->emboss;
if (no_bg) {
- layout->emboss = UI_EMBOSS_NONE;
+ layout->emboss = UI_EMBOSS_NONE_OR_STATUS;
}
uiBut *but = NULL;
@@ -2346,7 +2346,7 @@ void uiItemFullR(uiLayout *layout,
* In this case we want the ability not to have an icon.
*
* We could pass an argument not to set the icon to begin with however this is the one case
- * the functionality is needed. */
+ * the functionality is needed. */
if (but && no_icon) {
if ((icon == ICON_NONE) && (but->icon != ICON_NONE)) {
ui_def_but_icon_clear(but);
@@ -2355,7 +2355,7 @@ void uiItemFullR(uiLayout *layout,
/* Mark non-embossed textfields inside a listbox. */
if (but && (block->flag & UI_BLOCK_LIST_ITEM) && (but->type == UI_BTYPE_TEXT) &&
- (but->emboss & UI_EMBOSS_NONE)) {
+ ELEM(but->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS)) {
UI_but_flag_enable(but, UI_BUT_LIST_ITEM);
}
@@ -2860,7 +2860,7 @@ static uiBut *ui_item_menu(uiLayout *layout,
int w = ui_text_icon_width(layout, name, icon, 1);
const int h = UI_UNIT_Y;
- if (layout->root->type == UI_LAYOUT_HEADER) { /* ugly .. */
+ if (layout->root->type == UI_LAYOUT_HEADER) { /* Ugly! */
if (icon == ICON_NONE && force_menu) {
/* pass */
}
@@ -2893,7 +2893,7 @@ static uiBut *ui_item_menu(uiLayout *layout,
}
if (argN) {
- /* ugly .. */
+ /* ugly! */
if (arg != argN) {
but->poin = (char *)but;
}
@@ -3381,10 +3381,13 @@ typedef struct MenuItemLevel {
static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, void *arg)
{
- MenuItemLevel *lvl = (MenuItemLevel *)(((uiBut *)arg)->func_argN);
+ uiBut *but = arg;
+ MenuItemLevel *lvl = but->func_argN;
+ /* Use the operator properties from the button owning the menu. */
+ IDProperty *op_props = but->opptr ? but->opptr->data : NULL;
uiLayoutSetOperatorContext(layout, lvl->opcontext);
- uiItemsEnumO(layout, lvl->opname, lvl->propname);
+ uiItemsFullEnumO(layout, lvl->opname, lvl->propname, op_props, lvl->opcontext, 0);
layout->root->block->flag |= UI_BLOCK_IS_FLIP;
@@ -3392,12 +3395,13 @@ static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, vo
UI_block_direction_set(layout->root->block, UI_DIR_DOWN);
}
-void uiItemMenuEnumO_ptr(uiLayout *layout,
- bContext *C,
- wmOperatorType *ot,
- const char *propname,
- const char *name,
- int icon)
+void uiItemMenuEnumFullO_ptr(uiLayout *layout,
+ bContext *C,
+ wmOperatorType *ot,
+ const char *propname,
+ const char *name,
+ int icon,
+ PointerRNA *r_opptr)
{
/* Caller must check */
BLI_assert(ot->srna != NULL);
@@ -3416,6 +3420,15 @@ void uiItemMenuEnumO_ptr(uiLayout *layout,
lvl->opcontext = layout->root->opcontext;
uiBut *but = ui_item_menu(layout, name, icon, menu_item_enum_opname_menu, NULL, lvl, NULL, true);
+ /* Use the menu button as owner for the operator properties, which will then be passed to the
+ * individual menu items. */
+ if (r_opptr) {
+ but->opptr = MEM_callocN(sizeof(PointerRNA), "uiButOpPtr");
+ WM_operator_properties_create_ptr(but->opptr, ot);
+ BLI_assert(but->opptr->data == NULL);
+ WM_operator_properties_alloc(&but->opptr, (IDProperty **)&but->opptr->data, ot->idname);
+ *r_opptr = *but->opptr;
+ }
/* add hotkey here, lower UI code can't detect it */
if ((layout->root->block->flag & UI_BLOCK_LOOP) && (ot->prop && ot->invoke)) {
@@ -3427,12 +3440,13 @@ void uiItemMenuEnumO_ptr(uiLayout *layout,
}
}
-void uiItemMenuEnumO(uiLayout *layout,
- bContext *C,
- const char *opname,
- const char *propname,
- const char *name,
- int icon)
+void uiItemMenuEnumFullO(uiLayout *layout,
+ bContext *C,
+ const char *opname,
+ const char *propname,
+ const char *name,
+ int icon,
+ PointerRNA *r_opptr)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
@@ -3444,7 +3458,17 @@ void uiItemMenuEnumO(uiLayout *layout,
return;
}
- uiItemMenuEnumO_ptr(layout, C, ot, propname, name, icon);
+ uiItemMenuEnumFullO_ptr(layout, C, ot, propname, name, icon, r_opptr);
+}
+
+void uiItemMenuEnumO(uiLayout *layout,
+ bContext *C,
+ const char *opname,
+ const char *propname,
+ const char *name,
+ int icon)
+{
+ uiItemMenuEnumFullO(layout, C, opname, propname, name, icon, NULL);
}
static void menu_item_enum_rna_menu(bContext *UNUSED(C), uiLayout *layout, void *arg)
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 6694535e3af..dc0650af7a7 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1188,7 +1188,6 @@ static void panel_draw_aligned_widgets(const uiStyle *style,
/* Draw text label. */
if (panel->drawname[0] != '\0') {
- /* + 0.001f to avoid flirting with float inaccuracy .*/
const rcti title_rect = {
.xmin = widget_rect.xmin + (panel->labelofs / aspect) + scaled_unit * 1.1f,
.xmax = widget_rect.xmax,
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index aa10d092f5e..7d561aa1c71 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -67,7 +67,8 @@ bool ui_but_is_toggle(const uiBut *but)
UI_BTYPE_TOGGLE_N,
UI_BTYPE_CHECKBOX,
UI_BTYPE_CHECKBOX_N,
- UI_BTYPE_ROW);
+ UI_BTYPE_ROW,
+ UI_BTYPE_DATASETROW);
}
/**
@@ -90,7 +91,8 @@ bool ui_but_is_interactive(const uiBut *but, const bool labeledit)
if (but->flag & UI_SCROLLED) {
return false;
}
- if ((but->type == UI_BTYPE_TEXT) && (but->emboss == UI_EMBOSS_NONE) && !labeledit) {
+ if ((but->type == UI_BTYPE_TEXT) &&
+ (ELEM(but->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS)) && !labeledit) {
return false;
}
if ((but->type == UI_BTYPE_LISTROW) && labeledit) {
diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c
index 58a74a3473e..6e60ca79aaf 100644
--- a/source/blender/editors/interface/interface_region_menu_popup.c
+++ b/source/blender/editors/interface/interface_region_menu_popup.c
@@ -591,7 +591,7 @@ int UI_popup_menu_invoke(bContext *C, const char *idname, ReportList *reports)
* \{ */
void UI_popup_block_invoke_ex(
- bContext *C, uiBlockCreateFunc func, void *arg, void (*arg_free)(void *arg), bool can_refresh)
+ bContext *C, uiBlockCreateFunc func, void *arg, uiFreeArgFunc arg_free, bool can_refresh)
{
wmWindow *window = CTX_wm_window(C);
uiPopupBlockHandle *handle;
@@ -608,10 +608,7 @@ void UI_popup_block_invoke_ex(
WM_event_add_mousemove(window);
}
-void UI_popup_block_invoke(bContext *C,
- uiBlockCreateFunc func,
- void *arg,
- void (*arg_free)(void *arg))
+void UI_popup_block_invoke(bContext *C, uiBlockCreateFunc func, void *arg, uiFreeArgFunc arg_free)
{
UI_popup_block_invoke_ex(C, func, arg, arg_free, true);
}
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c
index 8135f5a203e..60e51244384 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.c
@@ -773,7 +773,7 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C,
uiBlockCreateFunc create_func,
uiBlockHandleCreateFunc handle_create_func,
void *arg,
- void (*arg_free)(void *arg))
+ uiFreeArgFunc arg_free)
{
wmWindow *window = CTX_wm_window(C);
uiBut *activebut = UI_context_active_but_get(C);
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index accfb78ab94..bf3425dd3eb 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -188,11 +188,11 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region
/* tone_fg = rgb_to_grayscale(main_color); */
/* mix the colors */
- rgb_tint(value_color, 0.0f, 0.0f, tone_bg, 0.2f); /* light gray */
- rgb_tint(active_color, 0.6f, 0.2f, tone_bg, 0.2f); /* light blue */
- rgb_tint(normal_color, 0.0f, 0.0f, tone_bg, 0.4f); /* gray */
- rgb_tint(python_color, 0.0f, 0.0f, tone_bg, 0.5f); /* dark gray */
- rgb_tint(alert_color, 0.0f, 0.8f, tone_bg, 0.1f); /* red */
+ rgb_tint(value_color, 0.0f, 0.0f, tone_bg, 0.2f); /* Light gray. */
+ rgb_tint(active_color, 0.6f, 0.2f, tone_bg, 0.2f); /* Light blue. */
+ rgb_tint(normal_color, 0.0f, 0.0f, tone_bg, 0.4f); /* Gray. */
+ rgb_tint(python_color, 0.0f, 0.0f, tone_bg, 0.5f); /* Dark gray. */
+ rgb_tint(alert_color, 0.0f, 0.8f, tone_bg, 0.1f); /* Red. */
/* draw text */
BLF_wordwrap(data->fstyle.uifont_id, data->wrap_width);
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index ad0c523a594..88ab6a377d0 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -245,7 +245,7 @@ void UI_fontstyle_draw_rotated(const uiFontStyle *fs,
/* ignore UI_STYLE, always aligned to top */
- /* rotate counter-clockwise for now (assumes left-to-right language)*/
+ /* Rotate counter-clockwise for now (assumes left-to-right language). */
xofs += height;
yofs = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX) + 5;
angle = M_PI_2;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 3990ad68c4d..5232d4310a3 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -344,7 +344,7 @@ typedef struct TemplateID {
float scale;
} TemplateID;
-/* Search browse menu, assign */
+/* Search browse menu, assign. */
static void template_ID_set_property_exec_fn(bContext *C, void *arg_template, void *item)
{
TemplateID *template_ui = (TemplateID *)arg_template;
@@ -674,7 +674,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
if (BKE_lib_id_make_local(bmain, id, false, 0)) {
BKE_main_id_newptr_and_tag_clear(bmain);
- /* reassign to get get proper updates/notifiers */
+ /* Reassign to get proper updates/notifiers. */
idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
undo_push_label = "Make Local";
}
@@ -687,8 +687,8 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
break;
case UI_ID_OVERRIDE:
if (id && ID_IS_OVERRIDE_LIBRARY(id)) {
- BKE_lib_override_library_free(&id->override_library, true);
- /* reassign to get get proper updates/notifiers */
+ BKE_lib_override_library_make_local(id);
+ /* Reassign to get proper updates/notifiers. */
idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL);
RNA_property_update(C, &template_ui->ptr, template_ui->prop);
@@ -3050,7 +3050,7 @@ static void colorband_flip_cb(bContext *C, ColorBand *coba)
coba->data[a] = data_tmp[a];
}
- /* may as well flip the cur*/
+ /* May as well flip the `cur`. */
coba->cur = coba->tot - (coba->cur + 1);
ED_undo_push(C, "Flip Color Ramp");
@@ -5883,7 +5883,7 @@ static void uilist_prepare(uiList *ui_list,
}
/* If list length changes or list is tagged to check this,
- * and active is out of view, scroll to it .*/
+ * and active is out of view, scroll to it. */
if (ui_list->list_last_len != len || ui_list->flag & UILST_SCROLL_TO_ACTIVE_ITEM) {
if (activei_row < ui_list->list_scroll) {
ui_list->list_scroll = activei_row;
@@ -6205,7 +6205,7 @@ void uiTemplateList(uiLayout *layout,
0,
TIP_("Double click to rename"));
if ((dyntip_data = uilist_item_use_dynamic_tooltip(itemptr, item_dyntip_propname))) {
- UI_but_func_tooltip_set(but, uilist_item_tooltip_func, dyntip_data);
+ UI_but_func_tooltip_set(but, uilist_item_tooltip_func, dyntip_data, MEM_freeN);
}
sub = uiLayoutRow(overlap, false);
@@ -6762,7 +6762,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
NULL);
but_progress->progress = progress;
- UI_but_func_tooltip_set(&but_progress->but, progress_tooltip_func, tip_arg);
+ UI_but_func_tooltip_set(&but_progress->but, progress_tooltip_func, tip_arg, MEM_freeN);
}
if (!wm->is_interface_locked) {
diff --git a/source/blender/editors/interface/interface_undo.c b/source/blender/editors/interface/interface_undo.c
index 304d2254a81..40f196d9b45 100644
--- a/source/blender/editors/interface/interface_undo.c
+++ b/source/blender/editors/interface/interface_undo.c
@@ -107,7 +107,7 @@ void ui_textedit_undo_push(uiUndoStack_Text *stack, const char *text, int cursor
}
}
- /* Create the new state */
+ /* Create the new state. */
const int text_size = strlen(text) + 1;
stack->current = MEM_mallocN(sizeof(uiUndoStack_Text_State) + text_size, __func__);
stack->current->cursor_index = cursor_index;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index ce1109ad9df..92dd41932f2 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -113,6 +113,7 @@ typedef enum {
UI_WTYPE_LISTITEM,
UI_WTYPE_PROGRESSBAR,
UI_WTYPE_NODESOCKET,
+ UI_WTYPE_DATASETROW,
} uiWidgetTypeEnum;
/* Button state argument shares bits with 'uiBut.flag'.
@@ -1531,14 +1532,14 @@ static void ui_text_clip_right_ex(const uiFontStyle *fstyle,
int l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth - sep_strwidth, NULL);
if (l_end > 0) {
- /* At least one character, so clip and add the ellipsis. */
+ /* At least one character, so clip and add the ellipsis. */
memcpy(str + l_end, sep, sep_len + 1); /* +1 for trailing '\0'. */
if (r_final_len) {
*r_final_len = (size_t)(l_end) + sep_len;
}
}
else {
- /* Otherwise fit as much as we can without adding an ellipsis. */
+ /* Otherwise fit as much as we can without adding an ellipsis. */
l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth, NULL);
str[l_end] = '\0';
if (r_final_len) {
@@ -3488,7 +3489,7 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
/**
* Draw menu buttons still with triangles when field is not embossed
*/
-static void widget_menubut_embossn(uiBut *UNUSED(but),
+static void widget_menubut_embossn(const uiBut *UNUSED(but),
uiWidgetColors *wcol,
rcti *rect,
int UNUSED(state),
@@ -3511,7 +3512,7 @@ static void widget_menubut_embossn(uiBut *UNUSED(but),
* Draw number buttons still with triangles when field is not embossed
*/
static void widget_numbut_embossn(
- uiBut *UNUSED(but), uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+ const uiBut *UNUSED(but), uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
widget_numbut_draw(wcol, rect, state, roundboxalign, true);
}
@@ -3697,6 +3698,28 @@ static void widget_progressbar(
rect->xmax += (BLI_rcti_size_x(&rect_prog) / 2);
}
+static void widget_datasetrow(
+ uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign))
+{
+ uiButDatasetRow *but_componentrow = (uiButDatasetRow *)but;
+ uiWidgetBase wtb;
+ widget_init(&wtb);
+
+ /* no outline */
+ wtb.draw_outline = false;
+ const float rad = wcol->roundness * U.widget_unit;
+ round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
+
+ if ((state & UI_ACTIVE) || (state & UI_SELECT)) {
+ widgetbase_draw(&wtb, wcol);
+ }
+
+ BLI_rcti_resize(rect,
+ BLI_rcti_size_x(rect) - UI_UNIT_X * but_componentrow->indentation,
+ BLI_rcti_size_y(rect));
+ BLI_rcti_translate(rect, 0.5f * UI_UNIT_X * but_componentrow->indentation, 0);
+}
+
static void widget_nodesocket(
uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
{
@@ -4469,6 +4492,10 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.custom = widget_progressbar;
break;
+ case UI_WTYPE_DATASETROW:
+ wt.custom = widget_datasetrow;
+ break;
+
case UI_WTYPE_NODESOCKET:
wt.custom = widget_nodesocket;
break;
@@ -4792,6 +4819,11 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
fstyle = &style->widgetlabel;
break;
+ case UI_BTYPE_DATASETROW:
+ wt = widget_type(UI_WTYPE_DATASETROW);
+ fstyle = &style->widgetlabel;
+ break;
+
case UI_BTYPE_SCROLL:
wt = widget_type(UI_WTYPE_SCROLL);
break;
@@ -4924,7 +4956,7 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
}
/**
- * Uses the widget base drawing and colors from from the box widget, but ensures an opaque
+ * Uses the widget base drawing and colors from the box widget, but ensures an opaque
* inner color.
*/
void ui_draw_box_opaque(rcti *rect, int roundboxalign)
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 224993555bf..5eb20ae601b 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -535,7 +535,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize)
curRatio = height / width;
winRatio = winy / winx;
- /* both sizes change (area/region maximized) */
+ /* Both sizes change (area/region maximized). */
if (do_x == do_y) {
if (do_x && do_y) {
/* here is 1,1 case, so all others must be 0,0 */
@@ -1738,15 +1738,15 @@ bool UI_view2d_view_to_region_clip(
void UI_view2d_view_to_region(
const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y)
{
- /* step 1: express given coordinates as proportional values */
+ /* Step 1: express given coordinates as proportional values. */
x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
- /* step 2: convert proportional distances to screen coordinates */
+ /* Step 2: convert proportional distances to screen coordinates. */
x = v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask));
y = v2d->mask.ymin + (y * BLI_rcti_size_y(&v2d->mask));
- /* although we don't clamp to lie within region bounds, we must avoid exceeding size of ints */
+ /* Although we don't clamp to lie within region bounds, we must avoid exceeding size of ints. */
*r_region_x = clamp_float_to_int(x);
*r_region_y = clamp_float_to_int(y);
}
@@ -1769,13 +1769,13 @@ void UI_view2d_view_to_region_rcti(const View2D *v2d, const rctf *rect_src, rcti
const float mask_size[2] = {BLI_rcti_size_x(&v2d->mask), BLI_rcti_size_y(&v2d->mask)};
rctf rect_tmp;
- /* step 1: express given coordinates as proportional values */
+ /* Step 1: express given coordinates as proportional values. */
rect_tmp.xmin = (rect_src->xmin - v2d->cur.xmin) / cur_size[0];
rect_tmp.xmax = (rect_src->xmax - v2d->cur.xmin) / cur_size[0];
rect_tmp.ymin = (rect_src->ymin - v2d->cur.ymin) / cur_size[1];
rect_tmp.ymax = (rect_src->ymax - v2d->cur.ymin) / cur_size[1];
- /* step 2: convert proportional distances to screen coordinates */
+ /* Step 2: convert proportional distances to screen coordinates. */
rect_tmp.xmin = v2d->mask.xmin + (rect_tmp.xmin * mask_size[0]);
rect_tmp.xmax = v2d->mask.xmin + (rect_tmp.xmax * mask_size[0]);
rect_tmp.ymin = v2d->mask.ymin + (rect_tmp.ymin * mask_size[1]);
@@ -1800,7 +1800,7 @@ bool UI_view2d_view_to_region_rcti_clip(const View2D *v2d, const rctf *rect_src,
BLI_assert(rect_src->xmin <= rect_src->xmax && rect_src->ymin <= rect_src->ymax);
- /* step 1: express given coordinates as proportional values */
+ /* Step 1: express given coordinates as proportional values. */
rect_tmp.xmin = (rect_src->xmin - v2d->cur.xmin) / cur_size[0];
rect_tmp.xmax = (rect_src->xmax - v2d->cur.xmin) / cur_size[0];
rect_tmp.ymin = (rect_src->ymin - v2d->cur.ymin) / cur_size[1];
@@ -1808,7 +1808,7 @@ bool UI_view2d_view_to_region_rcti_clip(const View2D *v2d, const rctf *rect_src,
if (((rect_tmp.xmax < 0.0f) || (rect_tmp.xmin > 1.0f) || (rect_tmp.ymax < 0.0f) ||
(rect_tmp.ymin > 1.0f)) == 0) {
- /* step 2: convert proportional distances to screen coordinates */
+ /* Step 2: convert proportional distances to screen coordinates. */
rect_tmp.xmin = v2d->mask.xmin + (rect_tmp.xmin * mask_size[0]);
rect_tmp.xmax = v2d->mask.ymin + (rect_tmp.xmax * mask_size[0]);
rect_tmp.ymin = v2d->mask.ymin + (rect_tmp.ymin * mask_size[1]);
diff --git a/source/blender/editors/interface/view2d_gizmo_navigate.c b/source/blender/editors/interface/view2d_gizmo_navigate.c
index 8d3f1beb947..30b4a7c097a 100644
--- a/source/blender/editors/interface/view2d_gizmo_navigate.c
+++ b/source/blender/editors/interface/view2d_gizmo_navigate.c
@@ -113,7 +113,7 @@ static struct NavigateGizmoInfo *navigate_params_from_space_type(short space_typ
case SPACE_CLIP:
return g_navigate_params_for_space_clip;
default:
- /* Used for sequencer. */
+ /* Used for sequencer. */
return g_navigate_params_for_view2d;
}
}
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 7ad28cd6069..69acfc657dc 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -187,7 +187,7 @@ static void view_pan_apply(bContext *C, wmOperator *op)
view_pan_apply_ex(C, vpd, RNA_int_get(op->ptr, "deltax"), RNA_int_get(op->ptr, "deltay"));
}
-/* cleanup temp customdata */
+/* Cleanup temp custom-data. */
static void view_pan_exit(wmOperator *op)
{
MEM_SAFE_FREE(op->customdata);
@@ -805,7 +805,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
/** \name View Zoom Operator (single step)
* \{ */
-/* cleanup temp customdata */
+/* Cleanup temp custom-data. */
static void view_zoomstep_exit(wmOperator *op)
{
UI_view2d_zoom_cache_reset();
@@ -1034,7 +1034,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
}
-/* cleanup temp customdata */
+/* Cleanup temp custom-data. */
static void view_zoomdrag_exit(bContext *C, wmOperator *op)
{
UI_view2d_zoom_cache_reset();
@@ -1914,7 +1914,7 @@ static void scroller_activate_init(bContext *C,
ED_region_tag_redraw_no_rebuild(region);
}
-/* cleanup temp customdata */
+/* Cleanup temp custom-data. */
static void scroller_activate_exit(bContext *C, wmOperator *op)
{
if (op->customdata) {
@@ -2056,7 +2056,7 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *e
return OPERATOR_FINISHED;
}
- /* otherwise, end the drag action */
+ /* Otherwise, end the drag action. */
if (vsm->lastx || vsm->lasty) {
scroller_activate_exit(C, op);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c
index cb3f9a89e62..8d8e1e9f06a 100644
--- a/source/blender/editors/lattice/editlattice_select.c
+++ b/source/blender/editors/lattice/editlattice_select.c
@@ -108,9 +108,9 @@ bool ED_lattice_deselect_all_multi(struct bContext *C)
static int lattice_select_random_exec(bContext *C, wmOperator *op)
{
+ const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
const float randfac = RNA_float_get(op->ptr, "ratio");
const int seed = WM_operator_properties_select_random_seed_increment_get(op);
- const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
@@ -119,29 +119,36 @@ static int lattice_select_random_exec(bContext *C, wmOperator *op)
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
+ int seed_iter = seed;
- RNG *rng = BLI_rng_new_srandom(seed);
+ /* This gives a consistent result regardless of object order. */
+ if (ob_index) {
+ seed_iter += BLI_ghashutil_strhash_p(obedit->id.name);
+ }
- int tot;
- BPoint *bp;
+ int a = lt->pntsu * lt->pntsv * lt->pntsw;
+ int elem_map_len = 0;
+ BPoint **elem_map = MEM_mallocN(sizeof(*elem_map) * a, __func__);
+ BPoint *bp = lt->def;
- tot = lt->pntsu * lt->pntsv * lt->pntsw;
- bp = lt->def;
- while (tot--) {
+ while (a--) {
if (!bp->hide) {
- if (BLI_rng_get_float(rng) < randfac) {
- bpoint_select_set(bp, select);
- }
+ elem_map[elem_map_len++] = bp;
}
bp++;
}
+ BLI_array_randomize(elem_map, sizeof(*elem_map), elem_map_len, seed_iter);
+ const int count_select = elem_map_len * randfac;
+ for (int i = 0; i < count_select; i++) {
+ bpoint_select_set(elem_map[i], select);
+ }
+ MEM_freeN(elem_map);
+
if (select == false) {
lt->actbp = LT_ACTBP_NONE;
}
- BLI_rng_free(rng);
-
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c
index 1792f0e13bc..d9efbef4b42 100644
--- a/source/blender/editors/mask/mask_editaction.c
+++ b/source/blender/editors/mask/mask_editaction.c
@@ -109,7 +109,7 @@ void ED_masklayer_make_cfra_list(MaskLayer *mask_layer, ListBase *elems, bool on
/* Selection Tools */
/* check if one of the frames in this layer is selected */
-bool ED_masklayer_frame_select_check(MaskLayer *mask_layer)
+bool ED_masklayer_frame_select_check(const MaskLayer *mask_layer)
{
MaskLayerShape *mask_layer_shape;
@@ -283,25 +283,25 @@ void ED_masklayer_frames_duplicate(MaskLayer *mask_layer)
{
MaskLayerShape *mask_layer_shape, *gpfn;
- /* error checking */
+ /* Error checking. */
if (mask_layer == NULL) {
return;
}
- /* duplicate selected frames */
+ /* Duplicate selected frames. */
for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
mask_layer_shape = gpfn) {
gpfn = mask_layer_shape->next;
- /* duplicate this frame */
+ /* Duplicate this frame. */
if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
MaskLayerShape *mask_shape_dupe;
- /* duplicate frame, and deselect self */
+ /* Duplicate frame, and deselect self. */
mask_shape_dupe = BKE_mask_layer_shape_duplicate(mask_layer_shape);
mask_layer_shape->flag &= ~MASK_SHAPE_SELECT;
- /* XXX - how to handle duplicate frames? */
+ /* XXX: how to handle duplicate frames? */
BLI_insertlinkafter(&mask_layer->splines_shapes, mask_layer_shape, mask_shape_dupe);
}
}
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 1a6ac8597ae..3476f1ca735 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -83,7 +83,9 @@ Mask *ED_mask_new(bContext *C, const char *name)
return mask;
}
-/* Get ative layer. Will create mask/layer to be sure there's an active layer. */
+/**
+ * Get active layer. Will create mask/layer to be sure there's an active layer.
+ */
MaskLayer *ED_mask_layer_ensure(bContext *C, bool *r_added_mask)
{
Mask *mask = CTX_data_edit_mask(C);
diff --git a/source/blender/editors/mask/mask_query.c b/source/blender/editors/mask/mask_query.c
index 401b6eac4f2..cd51026d20c 100644
--- a/source/blender/editors/mask/mask_query.c
+++ b/source/blender/editors/mask/mask_query.c
@@ -169,7 +169,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
}
if (r_u) {
- /* TODO(sergey): Projection fails in some weirdo cases.. */
+ /* TODO(sergey): Projection fails in some weirdo cases. */
if (use_project) {
u = BKE_mask_spline_project_co(point_spline, point, u, normal_co, MASK_PROJ_ANY);
}
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 5c369afc4cd..3bb05a27c54 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -92,7 +92,6 @@ bool ED_mask_select_check(const Mask *mask)
return false;
}
-/* 'sel' select */
void ED_mask_spline_select_set(MaskSpline *spline, const bool do_select)
{
if (do_select) {
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index e03390780f9..907881a44f3 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -509,7 +509,7 @@ static int edbm_extrude_context_exec(bContext *C, wmOperator *op)
edbm_extrude_mesh(obedit, em, op);
/* This normally happens when pushing undo but modal operators
- * like this one don't push undo data until after modal mode is done.*/
+ * like this one don't push undo data until after modal mode is done. */
EDBM_update(obedit->data,
&(const struct EDBMUpdate_Params){
.calc_looptri = true,
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 2ba1d30900a..0e2dd492e06 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -937,7 +937,7 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd,
static void knife_start_cut(KnifeTool_OpData *kcd)
{
kcd->prev = kcd->curr;
- kcd->curr.is_space = 0; /*TODO: why do we do this? */
+ kcd->curr.is_space = 0; /* TODO: why do we do this? */
if (kcd->prev.vert == NULL && kcd->prev.edge == NULL) {
float origin[3], origin_ofs[3];
@@ -952,7 +952,7 @@ static void knife_start_cut(KnifeTool_OpData *kcd)
zero_v3(kcd->prev.cage);
}
- copy_v3_v3(kcd->prev.co, kcd->prev.cage); /*TODO: do we need this? */
+ copy_v3_v3(kcd->prev.co, kcd->prev.cage); /* TODO: do we need this? */
copy_v3_v3(kcd->curr.cage, kcd->prev.cage);
copy_v3_v3(kcd->curr.co, kcd->prev.co);
}
@@ -1160,7 +1160,7 @@ static void knife_add_single_cut(KnifeTool_OpData *kcd,
}
else if (lh1->kfe) {
kfe->v1 = knife_split_edge(kcd, lh1->kfe, lh1->hit, lh1->cagehit, &kfe2);
- lh1->v = kfe->v1; /* record the KnifeVert for this hit */
+ lh1->v = kfe->v1; /* Record the #KnifeVert for this hit. */
}
else {
BLI_assert(lh1->f);
@@ -1168,7 +1168,7 @@ static void knife_add_single_cut(KnifeTool_OpData *kcd,
kfe->v1->is_cut = true;
kfe->v1->is_face = true;
knife_append_list(kcd, &kfe->v1->faces, lh1->f);
- lh1->v = kfe->v1; /* record the KnifeVert for this hit */
+ lh1->v = kfe->v1; /* Record the #KnifeVert for this hit. */
}
if (lh2->v) {
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c
index aa144dd3f3c..942fe143787 100644
--- a/source/blender/editors/mesh/editmesh_knife_project.c
+++ b/source/blender/editors/mesh/editmesh_knife_project.c
@@ -59,7 +59,7 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C,
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ARegion *region = CTX_wm_region(C);
- struct Mesh *me_eval;
+ const struct Mesh *me_eval;
bool me_eval_needs_free;
if (ob->type == OB_MESH || ob->runtime.data_eval) {
@@ -113,7 +113,7 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C,
BKE_nurbList_free(&nurbslist);
if (me_eval_needs_free) {
- BKE_mesh_free(me_eval);
+ BKE_mesh_free((struct Mesh *)me_eval);
}
}
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 615590c51c6..8626520ec37 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -270,7 +270,7 @@ static EdgeLoopPair *edbm_ripsel_looptag_helper(BMesh *bm)
break;
}
- /* initialize */
+ /* Initialize. */
e_first = e;
v_step = e_first->v1;
e_step = NULL; /* quiet warning, will never remain this value */
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index c600df503d8..49fd2a441f0 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -964,7 +964,7 @@ static bool unified_findnearest(ViewContext *vc,
}
}
- /* return only one of 3 pointers, for frontbuffer redraws */
+ /* Return only one of 3 pointers, for front-buffer redraws. */
if (hit.v.ele) {
hit.f.ele = NULL;
hit.e.ele = NULL;
@@ -1805,7 +1805,7 @@ static bool mouse_mesh_loop(
V3D_PROJ_RET_OK) {
tdist = len_squared_v2v2(mvalf, co);
if (tdist < best_dist) {
- /* printf("Best face: %p (%f)\n", f, tdist);*/
+ // printf("Best face: %p (%f)\n", f, tdist);
best_dist = tdist;
efa = f;
}
@@ -2983,7 +2983,7 @@ bool EDBM_select_interior_faces(BMEditMesh *em)
int i_b = BM_elem_index_get(l_pair[1]->f);
if (i_a != i_b) {
/* Only for predictable results that don't depend on the order of radial loops,
- * not essential. */
+ * not essential. */
if (i_a > i_b) {
SWAP(int, i_a, i_b);
}
@@ -3642,8 +3642,9 @@ static int edbm_select_linked_pick_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
- const int object_index = RNA_int_get(op->ptr, "object_index");
- const int index = RNA_int_get(op->ptr, "index");
+ /* Intentionally wrap negative values so the lookup fails. */
+ const uint object_index = (uint)RNA_int_get(op->ptr, "object_index");
+ const uint index = (uint)RNA_int_get(op->ptr, "index");
ele = EDBM_elem_from_index_any_multi(view_layer, object_index, index, &obedit);
}
@@ -4651,7 +4652,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op)
}
}
- BLI_array_randomize(elem_map, sizeof(*elem_map), elem_map_len, seed);
+ BLI_array_randomize(elem_map, sizeof(*elem_map), elem_map_len, seed_iter);
const int count_select = elem_map_len * randfac;
for (int i = 0; i < count_select; i++) {
BM_vert_select_set(em->bm, elem_map[i], select);
@@ -4667,7 +4668,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op)
elem_map[elem_map_len++] = eed;
}
}
- BLI_array_randomize(elem_map, sizeof(*elem_map), elem_map_len, seed);
+ BLI_array_randomize(elem_map, sizeof(*elem_map), elem_map_len, seed_iter);
const int count_select = elem_map_len * randfac;
for (int i = 0; i < count_select; i++) {
BM_edge_select_set(em->bm, elem_map[i], select);
@@ -4683,7 +4684,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op)
elem_map[elem_map_len++] = efa;
}
}
- BLI_array_randomize(elem_map, sizeof(*elem_map), elem_map_len, seed);
+ BLI_array_randomize(elem_map, sizeof(*elem_map), elem_map_len, seed_iter);
const int count_select = elem_map_len * randfac;
for (int i = 0; i < count_select; i++) {
BM_face_select_set(em->bm, elem_map[i], select);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index c09ce126b7f..fe9656d277e 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -2309,8 +2309,8 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op)
}
}
- /* ok, we don't have two adjacent faces, but we do have two selected ones.
- * that's an error condition.*/
+ /* OK, we don't have two adjacent faces, but we do have two selected ones.
+ * that's an error condition. */
if (tot == 0) {
continue;
}
@@ -3639,7 +3639,7 @@ void MESH_OT_remove_doubles(wmOperatorType *ot)
/** \name Shape Key Propagate Operator
* \{ */
-/* BMESH_TODO this should be properly encapsulated in a bmop. but later.*/
+/* BMESH_TODO this should be properly encapsulated in a bmop. but later. */
static bool shape_propagate(BMEditMesh *em)
{
BMIter iter;
@@ -3732,7 +3732,7 @@ void MESH_OT_shape_propagate_to_all(wmOperatorType *ot)
/** \name Blend from Shape Operator
* \{ */
-/* BMESH_TODO this should be properly encapsulated in a bmop. but later.*/
+/* BMESH_TODO this should be properly encapsulated in a bmop. but later. */
static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
{
Object *obedit_ref = CTX_data_edit_object(C);
@@ -4038,7 +4038,7 @@ static float bm_edge_seg_isect(const float sco_a[2],
b2 = ((x22 * y21) - (x21 * y22)) / xdiff2;
}
else {
- m2 = MAXSLOPE; /* Vertical slope */
+ m2 = MAXSLOPE; /* Vertical slope. */
b2 = x22;
}
@@ -4088,7 +4088,7 @@ static float bm_edge_seg_isect(const float sco_a[2],
/* Calculate the distance from point to line. */
if (m2 != MAXSLOPE) {
- /* sqrt(m2 * m2 + 1); Only looking for change in sign. Skip extra math .*/
+ /* `sqrt(m2 * m2 + 1);` Only looking for change in sign. Skip extra math. */
dist = (y12 - m2 * x12 - b2);
}
else {
@@ -4110,8 +4110,8 @@ static float bm_edge_seg_isect(const float sco_a[2],
m1 = MAXSLOPE;
b1 = x12;
}
- x2max = max_ff(x21, x22) + 0.001f; /* prevent missed edges */
- x2min = min_ff(x21, x22) - 0.001f; /* due to round off error */
+ x2max = max_ff(x21, x22) + 0.001f; /* Prevent missed edges. */
+ x2min = min_ff(x21, x22) - 0.001f; /* Due to round off error. */
y2max = max_ff(y21, y22) + 0.001f;
y2min = min_ff(y21, y22) - 0.001f;
@@ -4139,9 +4139,9 @@ static float bm_edge_seg_isect(const float sco_a[2],
yi = (b1 * m2 - m1 * b2) / (m2 - m1);
}
- /* Intersect inside bounding box of edge?*/
+ /* Intersect inside bounding box of edge? */
if ((xi >= x2min) && (xi <= x2max) && (yi <= y2max) && (yi >= y2min)) {
- /* test for vertex intersect that may be 'close enough'*/
+ /* Test for vertex intersect that may be 'close enough'. */
if (mode != KNIFE_MULTICUT) {
if (xi <= (x21 + threshold) && xi >= (x21 - threshold)) {
if (yi <= (y21 + threshold) && yi >= (y21 - threshold)) {
@@ -4244,7 +4244,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* store percentage of edge cut for KNIFE_EXACT here.*/
+ /* Store percentage of edge cut for KNIFE_EXACT here. */
BMOpSlot *slot_edge_percents = BMO_slot_get(bmop.slots_in, "edge_percents");
BM_ITER_MESH (be, &iter, bm, BM_EDGES_OF_MESH) {
bool is_cut = false;
@@ -4753,7 +4753,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
.calc_object_remap = true,
}));
- DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY_ALL_MODES);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
}
@@ -6958,9 +6958,9 @@ static void sort_bmelem_flag(bContext *C,
}
}
- /* printf("%d vertices: %d to be affected...\n", totelem[0], affected[0]);*/
- /* printf("%d edges: %d to be affected...\n", totelem[1], affected[1]);*/
- /* printf("%d faces: %d to be affected...\n", totelem[2], affected[2]);*/
+ // printf("%d vertices: %d to be affected...\n", totelem[0], affected[0]);
+ // printf("%d edges: %d to be affected...\n", totelem[1], affected[1]);
+ // printf("%d faces: %d to be affected...\n", totelem[2], affected[2]);
if (affected[0] == 0 && affected[1] == 0 && affected[2] == 0) {
for (j = 3; j--;) {
if (pblock[j]) {
@@ -7221,7 +7221,7 @@ static int edbm_bridge_tag_boundary_edges(BMesh *bm)
/* check if its only used by selected faces */
BM_ITER_ELEM (f, &fiter, e, BM_FACES_OF_EDGE) {
if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
- /* tag face for removal*/
+ /* Tag face for removal. */
if (!BM_elem_flag_test(f, BM_ELEM_TAG)) {
BM_elem_flag_enable(f, BM_ELEM_TAG);
totface_del++;
@@ -8219,7 +8219,7 @@ enum {
EDBM_CLNOR_MODAL_POINTTO_SET_USE_SELECTED = 114,
};
-/* called in transform_ops.c, on each regeneration of keymaps */
+/* Called in transform_ops.c, on each regeneration of key-maps. */
wmKeyMap *point_normals_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index f70d9b044ac..4beed6935d4 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -116,6 +116,45 @@ void EDBM_redo_state_free(BMBackup *backup, BMEditMesh *em, int recalctess)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Edit-Mesh Copy API (Internal)
+ * \{ */
+
+static void edbm_op_emcopy_incref_and_ensure(BMEditMesh *em, const BMOperator *UNUSED(bmop))
+{
+ if (em->emcopy == NULL) {
+ em->emcopy = BKE_editmesh_copy(em);
+ }
+ em->emcopyusers++;
+}
+
+static void edbm_op_emcopy_decref(BMEditMesh *em, const BMOperator *UNUSED(bmop))
+{
+ em->emcopyusers--;
+ if (em->emcopyusers < 0) {
+ printf("warning: em->emcopyusers was less than zero.\n");
+ }
+ if (em->emcopyusers <= 0) {
+ BKE_editmesh_free(em->emcopy);
+ MEM_freeN(em->emcopy);
+ em->emcopy = NULL;
+ }
+}
+
+static void edbm_op_emcopy_restore_and_clear(BMEditMesh *em, const BMOperator *UNUSED(bmop))
+{
+ BLI_assert(em->emcopy != NULL);
+ BMEditMesh *emcopy = em->emcopy;
+ EDBM_mesh_free(em);
+ *em = *emcopy;
+
+ MEM_freeN(emcopy);
+ em->emcopyusers = 0;
+ em->emcopy = NULL;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name BMesh Operator (BMO) API Wrapper
* \{ */
@@ -132,17 +171,18 @@ bool EDBM_op_init(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const char *
return false;
}
- if (!em->emcopy) {
- em->emcopy = BKE_editmesh_copy(em);
- }
- em->emcopyusers++;
+ edbm_op_emcopy_incref_and_ensure(em, bmop);
va_end(list);
return true;
}
-/* returns 0 on error, 1 on success. executes and finishes a bmesh operator */
+/**
+ * The return value:
+ * - False on error (the mesh must not be changed).
+ * - True on success, executes and finishes a #BMesh operator.
+ */
bool EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const bool do_report)
{
const char *errmsg;
@@ -150,18 +190,13 @@ bool EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const bool
BMO_op_finish(em->bm, bmop);
if (BMO_error_get(em->bm, &errmsg, NULL)) {
- BMEditMesh *emcopy = em->emcopy;
+ BLI_assert(em->emcopy != NULL);
if (do_report) {
BKE_report(op->reports, RPT_ERROR, errmsg);
}
- EDBM_mesh_free(em);
- *em = *emcopy;
-
- MEM_freeN(emcopy);
- em->emcopyusers = 0;
- em->emcopy = NULL;
+ edbm_op_emcopy_restore_and_clear(em, bmop);
/**
* Note, we could pass in the mesh, however this is an exceptional case, allow a slow lookup.
@@ -189,16 +224,7 @@ bool EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const bool
return false;
}
- em->emcopyusers--;
- if (em->emcopyusers < 0) {
- printf("warning: em->emcopyusers was less than zero.\n");
- }
-
- if (em->emcopyusers <= 0) {
- BKE_editmesh_free(em->emcopy);
- MEM_freeN(em->emcopy);
- em->emcopy = NULL;
- }
+ edbm_op_emcopy_decref(em, bmop);
return true;
}
@@ -217,10 +243,7 @@ bool EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt, ...)
return false;
}
- if (!em->emcopy) {
- em->emcopy = BKE_editmesh_copy(em);
- }
- em->emcopyusers++;
+ edbm_op_emcopy_incref_and_ensure(em, &bmop);
BMO_op_exec(bm, &bmop);
@@ -249,10 +272,7 @@ bool EDBM_op_call_and_selectf(BMEditMesh *em,
return false;
}
- if (!em->emcopy) {
- em->emcopy = BKE_editmesh_copy(em);
- }
- em->emcopyusers++;
+ edbm_op_emcopy_incref_and_ensure(em, &bmop);
BMO_op_exec(bm, &bmop);
@@ -284,10 +304,7 @@ bool EDBM_op_call_silentf(BMEditMesh *em, const char *fmt, ...)
return false;
}
- if (!em->emcopy) {
- em->emcopy = BKE_editmesh_copy(em);
- }
- em->emcopyusers++;
+ edbm_op_emcopy_incref_and_ensure(em, &bmop);
BMO_op_exec(bm, &bmop);
@@ -474,7 +491,7 @@ void EDBM_select_more(BMEditMesh *em, const bool use_face_step)
use_faces,
use_face_step);
BMO_op_exec(em->bm, &bmop);
- /* don't flush selection in edge/vertex mode */
+ /* Don't flush selection in edge/vertex mode. */
BMO_slot_buffer_hflag_enable(
em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, use_faces ? true : false);
BMO_op_finish(em->bm, &bmop);
@@ -496,7 +513,7 @@ void EDBM_select_less(BMEditMesh *em, const bool use_face_step)
use_faces,
use_face_step);
BMO_op_exec(em->bm, &bmop);
- /* don't flush selection in edge/vertex mode */
+ /* Don't flush selection in edge/vertex mode. */
BMO_slot_buffer_hflag_disable(
em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, use_faces ? true : false);
BMO_op_finish(em->bm, &bmop);
@@ -1011,7 +1028,7 @@ BMFace *EDBM_uv_active_face_get(BMEditMesh *em, const bool sloppy, const bool se
return NULL;
}
-/* can we edit UV's for this mesh?*/
+/* Can we edit UV's for this mesh? */
bool EDBM_uv_check(BMEditMesh *em)
{
/* some of these checks could be a touch overkill */
@@ -1222,12 +1239,12 @@ BMVert *EDBM_verts_mirror_get(BMEditMesh *em, BMVert *v)
BMEdge *EDBM_verts_mirror_get_edge(BMEditMesh *em, BMEdge *e)
{
- BMVert *v1_mirr = EDBM_verts_mirror_get(em, e->v1);
- if (v1_mirr) {
- BMVert *v2_mirr = EDBM_verts_mirror_get(em, e->v2);
- if (v2_mirr) {
- return BM_edge_exists(v1_mirr, v2_mirr);
- }
+ BMVert *v1_mirr, *v2_mirr;
+ if ((v1_mirr = EDBM_verts_mirror_get(em, e->v1)) &&
+ (v2_mirr = EDBM_verts_mirror_get(em, e->v2)) &&
+ /* While highly unlikely, a zero length central edges vertices can match, see T89342. */
+ LIKELY(v1_mirr != v2_mirr)) {
+ return BM_edge_exists(v1_mirr, v2_mirr);
}
return NULL;
@@ -1574,7 +1591,7 @@ int EDBM_elem_to_index_any(BMEditMesh *em, BMElem *ele)
return index;
}
-BMElem *EDBM_elem_from_index_any(BMEditMesh *em, int index)
+BMElem *EDBM_elem_from_index_any(BMEditMesh *em, uint index)
{
BMesh *bm = em->bm;
@@ -1615,14 +1632,14 @@ int EDBM_elem_to_index_any_multi(ViewLayer *view_layer,
}
BMElem *EDBM_elem_from_index_any_multi(ViewLayer *view_layer,
- int object_index,
- int elem_index,
+ uint object_index,
+ uint elem_index,
Object **r_obedit)
{
uint bases_len;
Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(view_layer, NULL, &bases_len);
*r_obedit = NULL;
- Object *obedit = ((uint)object_index < bases_len) ? bases[object_index]->object : NULL;
+ Object *obedit = (object_index < bases_len) ? bases[object_index]->object : NULL;
MEM_freeN(bases);
if (obedit != NULL) {
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -1689,8 +1706,8 @@ bool BMBVH_EdgeVisible(struct BMBVHTree *tree,
scale_point(co1, co2, 0.99);
scale_point(co3, co2, 0.99);
- /* ok, idea is to generate rays going from the camera origin to the
- * three points on the edge (v1, mid, v2)*/
+ /* OK, idea is to generate rays going from the camera origin to the
+ * three points on the edge (v1, mid, v2). */
sub_v3_v3v3(dir1, origin, co1);
sub_v3_v3v3(dir2, origin, co2);
sub_v3_v3v3(dir3, origin, co3);
@@ -1699,8 +1716,8 @@ bool BMBVH_EdgeVisible(struct BMBVHTree *tree,
normalize_v3_length(dir2, epsilon);
normalize_v3_length(dir3, epsilon);
- /* offset coordinates slightly along view vectors, to avoid
- * hitting the faces that own the edge.*/
+ /* Offset coordinates slightly along view vectors,
+ * to avoid hitting the faces that own the edge. */
add_v3_v3v3(co1, co1, dir1);
add_v3_v3v3(co2, co2, dir2);
add_v3_v3v3(co3, co3, dir3);
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 3a05cde7aa1..7c6dc6516ed 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -61,7 +61,6 @@ static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_t
BMesh *bm = (me->edit_mesh) ? me->edit_mesh->bm : NULL;
int tot;
- /* this */
switch (htype) {
case BM_VERT:
if (bm) {
@@ -167,7 +166,7 @@ static void mesh_uv_reset_array(float **fuv, const int len)
fuv[3][0] = 0.0;
fuv[3][1] = 1.0;
- /*make sure we ignore 2-sided faces*/
+ /* Make sure we ignore 2-sided faces. */
}
else if (len > 2) {
float fac = 0.0f, dfac = 1.0f / (float)len;
@@ -1097,7 +1096,7 @@ static void mesh_add_edges(Mesh *mesh, int len)
totedge = mesh->totedge + len;
- /* update customdata */
+ /* Update custom-data. */
CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index 763bdf04d83..f25317e8e85 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -51,7 +51,7 @@ bool EDBM_op_call_and_selectf(struct BMEditMesh *em,
const bool select_replace,
const char *fmt,
...);
-/* Same as above, but doesn't report errors.*/
+/* Same as above, but doesn't report errors. */
bool EDBM_op_call_silentf(struct BMEditMesh *em, const char *fmt, ...);
/* these next two functions are the split version of EDBM_op_callf, so you can
@@ -77,15 +77,15 @@ struct BMElem *EDBM_elem_from_selectmode(struct BMEditMesh *em,
struct BMFace *efa);
int EDBM_elem_to_index_any(struct BMEditMesh *em, struct BMElem *ele);
-struct BMElem *EDBM_elem_from_index_any(struct BMEditMesh *em, int index);
+struct BMElem *EDBM_elem_from_index_any(struct BMEditMesh *em, uint index);
int EDBM_elem_to_index_any_multi(struct ViewLayer *view_layer,
struct BMEditMesh *em,
struct BMElem *ele,
int *r_object_index);
struct BMElem *EDBM_elem_from_index_any_multi(struct ViewLayer *view_layer,
- int object_index,
- int elem_index,
+ uint object_index,
+ uint elem_index,
struct Object **r_obedit);
bool edbm_extrude_edges_indiv(struct BMEditMesh *em,
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 4efc653efe2..f6b65170d1b 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1851,7 +1851,7 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op)
/* hook them up */
BKE_nlatrack_add_strip(nlt, strip, is_liboverride);
- /* auto-name the strip, and give the track an interesting name */
+ /* Auto-name the strip, and give the track an interesting name. */
BLI_strncpy(nlt->name, DATA_("SoundTrack"), sizeof(nlt->name));
BKE_nlastrip_validate_name(adt, strip);
@@ -2572,7 +2572,7 @@ static void object_data_convert_ensure_curve_cache(Depsgraph *depsgraph, Scene *
if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
/* We need 'for render' ON here, to enable computing bevel dipslist if needed.
* Also makes sense anyway, we would not want e.g. to lose hidden parts etc. */
- BKE_displist_make_curveTypes(depsgraph, scene, ob, true, false);
+ BKE_displist_make_curveTypes(depsgraph, scene, ob, true);
}
else if (ob->type == OB_MBALL) {
BKE_displist_make_mball(depsgraph, scene, ob);
@@ -2600,8 +2600,8 @@ static void object_data_convert_curve_to_mesh(Main *bmain, Depsgraph *depsgraph,
/* Change objects which are using same curve.
* A bit annoying, but:
* - It's possible to have multiple curve objects selected which are sharing the same curve
- * datablock. We don't want mesh to be created for every of those objects.
- * - This is how conversion worked for a long long time. */
+ * data-block. We don't want mesh to be created for every of those objects.
+ * - This is how conversion worked for a long time. */
LISTBASE_FOREACH (Object *, other_object, &bmain->objects) {
if (other_object->data == curve) {
other_object->type = OB_MESH;
@@ -2791,11 +2791,11 @@ static int object_convert_exec(bContext *C, wmOperator *op)
basen = duplibase_for_convert(bmain, depsgraph, scene, view_layer, base, NULL);
newob = basen->object;
- /* decrement original mesh's usage count */
+ /* Decrement original mesh's usage count. */
Mesh *me = newob->data;
id_us_min(&me->id);
- /* make a new copy of the mesh */
+ /* Make a new copy of the mesh. */
newob->data = BKE_id_copy(bmain, &me->id);
}
else {
@@ -2865,11 +2865,11 @@ static int object_convert_exec(bContext *C, wmOperator *op)
basen = duplibase_for_convert(bmain, depsgraph, scene, view_layer, base, NULL);
newob = basen->object;
- /* decrement original mesh's usage count */
+ /* Decrement original mesh's usage count. */
Mesh *me = newob->data;
id_us_min(&me->id);
- /* make a new copy of the mesh */
+ /* Make a new copy of the mesh. */
newob->data = BKE_id_copy(bmain, &me->id);
}
else {
@@ -2890,11 +2890,11 @@ static int object_convert_exec(bContext *C, wmOperator *op)
basen = duplibase_for_convert(bmain, depsgraph, scene, view_layer, base, NULL);
newob = basen->object;
- /* decrement original mesh's usage count */
+ /* Decrement original mesh's usage count. */
Mesh *me = newob->data;
id_us_min(&me->id);
- /* make a new copy of the mesh */
+ /* Make a new copy of the mesh. */
newob->data = BKE_id_copy(bmain, &me->id);
}
else {
@@ -2923,10 +2923,10 @@ static int object_convert_exec(bContext *C, wmOperator *op)
basen = duplibase_for_convert(bmain, depsgraph, scene, view_layer, base, NULL);
newob = basen->object;
- /* decrement original curve's usage count */
+ /* Decrement original curve's usage count. */
id_us_min(&((Curve *)newob->data)->id);
- /* make a new copy of the curve */
+ /* Make a new copy of the curve. */
newob->data = BKE_id_copy(bmain, ob->data);
}
else {
@@ -3004,7 +3004,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
basen = duplibase_for_convert(bmain, depsgraph, scene, view_layer, base, NULL);
newob = basen->object;
- /* decrement original curve's usage count */
+ /* Decrement original curve's usage count. */
id_us_min(&((Curve *)newob->data)->id);
/* make a new copy of the curve */
@@ -3088,11 +3088,11 @@ static int object_convert_exec(bContext *C, wmOperator *op)
basen = duplibase_for_convert(bmain, depsgraph, scene, view_layer, base, NULL);
newob = basen->object;
- /* decrement original pointclouds's usage count */
+ /* Decrement original point-cloud's usage count. */
PointCloud *pointcloud = newob->data;
id_us_min(&pointcloud->id);
- /* make a new copy of the pointcloud */
+ /* Make a new copy of the point-cloud. */
newob->data = BKE_id_copy(bmain, &pointcloud->id);
}
else {
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 7f26d44a4ed..e941b27879b 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -1374,7 +1374,7 @@ static int bake(const BakeAPIRender *bkr,
* the cage is supposed to have interpolated normals
* between the faces unless the geometry is physically
* split. So we create a copy of the low poly mesh without
- * the eventual edge split.*/
+ * the eventual edge split. */
if (md->type == eModifierType_EdgeSplit) {
BLI_remlink(&ob_low_eval->modifiers, md);
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 06d6f2b94f3..a7aa6b4d6a4 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -547,7 +547,7 @@ static void test_constraint(
else {
Curve *cu = ct->tar->data;
- /* auto-set 'Path' setting on curve so this works */
+ /* auto-set 'Path' setting on curve so this works. */
cu->flag |= CU_PATH;
}
}
@@ -1977,7 +1977,7 @@ static bool get_new_constraint_target(
(!only_curve && !only_mesh)) {
/* Only use the object & bone if the bone is visible & selected
- * since we may have multiple objects in pose mode at once. */
+ * since we may have multiple objects in pose mode at once. */
bPoseChannel *pchan = BKE_pose_channel_active_or_first_selected(ob);
if (pchan != NULL) {
*tar_pchan = pchan;
@@ -2100,7 +2100,7 @@ static int constraint_add_exec(
}
}
- /* do type-specific tweaking to the constraint settings */
+ /* Do type-specific tweaking to the constraint settings. */
switch (type) {
case CONSTRAINT_TYPE_PYTHON: /* FIXME: this code is not really valid anymore */
{
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index 22c9d669ff3..7b7970fbfe5 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -611,23 +611,23 @@ void OBJECT_OT_data_transfer(wmOperatorType *ot)
{
PropertyRNA *prop;
- /* Identifiers.*/
+ /* Identifiers. */
ot->name = "Transfer Mesh Data";
ot->idname = "OBJECT_OT_data_transfer";
ot->description =
"Transfer data layer(s) (weights, edge sharp, etc.) from active to selected meshes";
- /* API callbacks.*/
+ /* API callbacks. */
ot->poll = data_transfer_poll;
ot->poll_property = data_transfer_poll_property;
ot->invoke = WM_menu_invoke;
ot->exec = data_transfer_exec;
ot->check = data_transfer_check;
- /* Flags.*/
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* Properties.*/
+ /* Properties. */
prop = RNA_def_boolean(ot->srna,
"use_reverse_transfer",
false,
@@ -886,7 +886,7 @@ void OBJECT_OT_datalayout_transfer(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* Properties.*/
+ /* Properties. */
edit_modifier_properties(ot);
/* Data type to transfer. */
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index c8923bb55c1..1ca967d9112 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -105,7 +105,7 @@
#include "CLG_log.h"
-/* for menu/popup icons etc etc*/
+/* For menu/popup icons etc etc. */
#include "UI_interface.h"
#include "UI_resources.h"
@@ -157,7 +157,7 @@ Object *ED_object_active_context(const bContext *C)
* (assuming they need to be modified).
*/
Object **ED_object_array_in_mode_or_selected(bContext *C,
- bool (*filter_fn)(Object *ob, void *user_data),
+ bool (*filter_fn)(const Object *ob, void *user_data),
void *filter_user_data,
uint *r_objects_len)
{
@@ -1152,7 +1152,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene, eObjectPathCalcRang
Depsgraph *depsgraph;
bool free_depsgraph = false;
/* For a single frame update it's faster to re-use existing dependency graph and avoid overhead
- * of building all the relations and so on for a temporary one. */
+ * of building all the relations and so on for a temporary one. */
if (range == OBJECT_PATH_CALC_RANGE_CURRENT_FRAME) {
/* NOTE: Dependency graph will be evaluated at all the frames, but we first need to access some
* nested pointers, like animation data. */
@@ -1990,7 +1990,7 @@ static int move_to_collection_invoke(bContext *C, wmOperator *op, const wmEvent
* Technically we could use #wmOperator.customdata. However there is no free callback
* called to an operator that exit with OPERATOR_INTERFACE to launch a menu.
*
- * So we are left with a memory that will necessarily leak. It's a small leak though.*/
+ * So we are left with a memory that will necessarily leak. It's a small leak though. */
if (master_collection_menu == NULL) {
master_collection_menu = MEM_callocN(sizeof(MoveToCollectionData),
"MoveToCollectionData menu - expected eventual memleak");
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 7122fd09892..fcee2818b22 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -772,7 +772,7 @@ void OBJECT_OT_hook_remove(wmOperatorType *ot)
/* flags */
/* this operator removes modifier which isn't stored in local undo stack,
- * so redoing it from redo panel gives totally weird results */
+ * so redoing it from redo panel gives totally weird results. */
ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO;
/* properties */
@@ -931,7 +931,7 @@ void OBJECT_OT_hook_assign(wmOperatorType *ot)
/* flags */
/* this operator changes data stored in modifier which doesn't get pushed to undo stack,
- * so redoing it from redo panel gives totally weird results */
+ * so redoing it from redo panel gives totally weird results. */
ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO;
/* properties */
diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c
index ed06cd2a217..36a4f002978 100644
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@ -401,9 +401,9 @@ void ED_object_mode_generic_exit(struct Main *bmain,
ed_object_mode_generic_exit_ex(bmain, depsgraph, scene, ob, false);
}
-bool ED_object_mode_generic_has_data(struct Depsgraph *depsgraph, struct Object *ob)
+bool ED_object_mode_generic_has_data(struct Depsgraph *depsgraph, const struct Object *ob)
{
- return ed_object_mode_generic_exit_ex(NULL, depsgraph, NULL, ob, true);
+ return ed_object_mode_generic_exit_ex(NULL, depsgraph, NULL, (Object *)ob, true);
}
/** \} */
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index e14e5cbd44b..620c58196dd 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -125,7 +125,7 @@ static void object_force_modifier_update_for_bind(Depsgraph *depsgraph, Object *
BKE_displist_make_mball(depsgraph, scene_eval, ob_eval);
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
- BKE_displist_make_curveTypes(depsgraph, scene_eval, ob_eval, false, false);
+ BKE_displist_make_curveTypes(depsgraph, scene_eval, ob_eval, false);
}
else if (ob->type == OB_GPENCIL) {
BKE_gpencil_modifiers_calc(depsgraph, scene_eval, ob_eval);
@@ -2147,7 +2147,7 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- /* XXX don't remove.. */
+ /* XXX don't remove. */
CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index b50fc3c88fd..00ef439c18a 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -322,7 +322,7 @@ void ED_keymap_object(wmKeyConfig *keyconf)
keymap = WM_keymap_ensure(keyconf, "Object Non-modal", 0, 0);
/* Object Mode ---------------------------------------------------------------- */
- /* Note: this keymap gets disabled in non-objectmode, */
+ /* Note: this keymap gets disabled in non-objectmode. */
keymap = WM_keymap_ensure(keyconf, "Object Mode", 0, 0);
keymap->poll = object_mode_poll;
}
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index cdf12bcb5df..15695c4c6f7 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -715,7 +715,7 @@ bool ED_object_parent_set(ReportList *reports,
cu->flag |= CU_PATH | CU_FOLLOW;
cu_eval->flag |= CU_PATH | CU_FOLLOW;
/* force creation of path data */
- BKE_displist_make_curveTypes(depsgraph, scene, par, false, false);
+ BKE_displist_make_curveTypes(depsgraph, scene, par, false);
}
else {
cu->flag |= CU_FOLLOW;
@@ -1931,7 +1931,7 @@ static void single_object_users(
}
/* not an especially efficient function, only added so the single user
- * button can be functional.*/
+ * button can be functional. */
void ED_object_single_user(Main *bmain, Scene *scene, Object *ob)
{
FOREACH_SCENE_OBJECT_BEGIN (scene, ob_iter) {
diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c
index 1ff576504ce..05f9980e0ab 100644
--- a/source/blender/editors/object/object_remesh.c
+++ b/source/blender/editors/object/object_remesh.c
@@ -139,6 +139,13 @@ static int voxel_remesh_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ if (mesh->totpoly == 0) {
+ return OPERATOR_CANCELLED;
+ }
+
+ /* Output mesh will be all smooth or all flat shading. */
+ const bool smooth_normals = mesh->mpoly[0].flag & ME_SMOOTH;
+
float isovalue = 0.0f;
if (mesh->flag & ME_REMESH_REPROJECT_VOLUME) {
isovalue = mesh->remesh_voxel_size * 0.3f;
@@ -185,7 +192,7 @@ static int voxel_remesh_exec(bContext *C, wmOperator *op)
BKE_mesh_nomain_to_mesh(new_mesh, mesh, ob, &CD_MASK_MESH, true);
- if (mesh->flag & ME_REMESH_SMOOTH_NORMALS) {
+ if (smooth_normals) {
BKE_mesh_smooth_flag_set(ob->data, true);
}
@@ -581,7 +588,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev
/* Write the text position into the matrix. */
copy_v3_v3(cd->text_mat[3], text_pos);
- /* Scale the text. */
+ /* Scale the text. */
float text_pos_word_space[3];
mul_v3_m4v3(text_pos_word_space, active_object->obmat, text_pos);
const float pixelsize = ED_view3d_pixel_size(rv3d, text_pos_word_space);
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 9160190764c..1a0c5a6a83f 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -26,6 +26,8 @@
#include <stdlib.h>
#include <string.h>
+#include "MEM_guardedalloc.h"
+
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_collection_types.h"
@@ -579,7 +581,7 @@ static bool object_select_all_by_particle(bContext *C, Object *ob)
CTX_DATA_BEGIN (C, Base *, base, visible_bases) {
if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) {
- /* loop through other particles*/
+ /* Loop through other particles. */
ParticleSystem *psys;
for (psys = base->object->particlesystem.first; psys; psys = psys->next) {
@@ -1454,20 +1456,28 @@ void OBJECT_OT_select_less(wmOperatorType *ot)
static int object_select_random_exec(bContext *C, wmOperator *op)
{
+ const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
const float randfac = RNA_float_get(op->ptr, "ratio");
const int seed = WM_operator_properties_select_random_seed_increment_get(op);
- const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
- RNG *rng = BLI_rng_new_srandom(seed);
+ ListBase ctx_data_list;
+ CTX_data_selectable_bases(C, &ctx_data_list);
+ const int tot = BLI_listbase_count(&ctx_data_list);
+ int elem_map_len = 0;
+ Base **elem_map = MEM_mallocN(sizeof(*elem_map) * tot, __func__);
- CTX_DATA_BEGIN (C, Base *, base, selectable_bases) {
- if (BLI_rng_get_float(rng) < randfac) {
- ED_object_base_select(base, select);
- }
+ CollectionPointerLink *ctx_link;
+ for (ctx_link = ctx_data_list.first; ctx_link; ctx_link = ctx_link->next) {
+ elem_map[elem_map_len++] = ctx_link->ptr.data;
}
- CTX_DATA_END;
+ BLI_freelistN(&ctx_data_list);
- BLI_rng_free(rng);
+ BLI_array_randomize(elem_map, sizeof(*elem_map), elem_map_len, seed);
+ const int count_select = elem_map_len * randfac;
+ for (int i = 0; i < count_select; i++) {
+ ED_object_base_select(elem_map[i], select);
+ }
+ MEM_freeN(elem_map);
Scene *scene = CTX_data_scene(C);
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 94b2f3fd566..d1e912b2f37 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -709,7 +709,7 @@ static int apply_objects_internal(bContext *C,
if (has_unparented_layers == false) {
BKE_reportf(reports,
RPT_ERROR,
- "Can't apply to a GP datablock where all layers are parented: Object "
+ "Can't apply to a GP data-block where all layers are parented: Object "
"\"%s\", %s \"%s\", aborting",
ob->id.name + 2,
BKE_idtype_idcode_to_name(ID_GD),
@@ -722,7 +722,7 @@ static int apply_objects_internal(bContext *C,
BKE_reportf(
reports,
RPT_ERROR,
- "Can't apply to GP datablock with no layers: Object \"%s\", %s \"%s\", aborting",
+ "Can't apply to GP data-block with no layers: Object \"%s\", %s \"%s\", aborting",
ob->id.name + 2,
BKE_idtype_idcode_to_name(ID_GD),
gpd->id.name + 2);
@@ -1255,16 +1255,16 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
}
else if (ob->type == OB_FONT) {
- /* get from bb */
+ /* Get from bounding-box. */
Curve *cu = ob->data;
if (ob->runtime.bb == NULL && (centermode != ORIGIN_TO_CURSOR)) {
- /* do nothing*/
+ /* Do nothing. */
}
else {
if (centermode == ORIGIN_TO_CURSOR) {
- /* done */
+ /* Done. */
}
else {
/* extra 0.5 is the height o above line */
@@ -1490,7 +1490,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
BKE_object_batch_cache_dirty_tag(tob);
DEG_id_tag_update(&tob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
- /* special support for dupligroups */
+ /* Special support for dupli-groups. */
else if (tob->instance_collection && tob->instance_collection->id.tag & LIB_TAG_DOIT) {
DEG_id_tag_update(&tob->id, ID_RECALC_TRANSFORM);
DEG_id_tag_update(&tob->instance_collection->id, ID_RECALC_COPY_ON_WRITE);
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 3f40d637188..e6cde60e9aa 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -83,7 +83,7 @@ static bool vertex_group_supported_poll_ex(bContext *C, const Object *ob);
/** \name Local Utility Functions
* \{ */
-static bool object_array_for_wpaint_filter(Object *ob, void *user_data)
+static bool object_array_for_wpaint_filter(const Object *ob, void *user_data)
{
bContext *C = user_data;
if (vertex_group_supported_poll_ex(C, ob)) {
@@ -516,14 +516,14 @@ static void mesh_defvert_mirror_update_internal(Object *ob,
const int def_nr)
{
if (def_nr == -1) {
- /* all vgroups, add groups where needed */
+ /* All vgroups, add groups where needed. */
int flip_map_len;
int *flip_map = BKE_object_defgroup_flip_map(ob, &flip_map_len, true);
BKE_defvert_sync_mapped(dvert_dst, dvert_src, flip_map, flip_map_len, true);
MEM_freeN(flip_map);
}
else {
- /* single vgroup */
+ /* Single vgroup. */
MDeformWeight *dw = BKE_defvert_ensure_index(dvert_dst,
BKE_object_defgroup_flip_index(ob, def_nr, 1));
if (dw) {
@@ -4068,7 +4068,7 @@ static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op)
bDeformGroup *def;
int defbase_tot = BLI_listbase_count(&ob->defbase);
- /* needs a dummy index at the start*/
+ /* Needs a dummy index at the start. */
int *sort_map_update = MEM_mallocN(sizeof(int) * (defbase_tot + 1), "sort vgroups");
int *sort_map = sort_map_update + 1;
@@ -4111,7 +4111,7 @@ static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op)
BKE_object_defgroup_array_get(ob->data, &dvert, &dvert_tot);
- /*create as necessary*/
+ /* Create as necessary. */
if (dvert) {
while (dvert_tot--) {
if (dvert->totweight) {
@@ -4186,10 +4186,10 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op)
int ret;
int sort_type = RNA_enum_get(op->ptr, "sort_type");
- /*init remapping*/
+ /* Init remapping. */
name_array = vgroup_init_remap(ob);
- /*sort vgroup names*/
+ /* Sort vgroup names. */
switch (sort_type) {
case SORT_TYPE_NAME:
BLI_listbase_sort(&ob->defbase, vgroup_sort_name);
@@ -4199,7 +4199,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op)
break;
}
- /*remap vgroup data to map to correct names*/
+ /* Remap vgroup data to map to correct names. */
ret = vgroup_do_remap(ob, name_array, op);
if (ret != OPERATOR_CANCELLED) {
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index a761701f60b..56f32ff603c 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -454,7 +454,7 @@ static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update
job->start = PIL_check_seconds_timer();
job->success = 1;
- G.is_break = false; /* reset BKE_blender_test_break*/
+ G.is_break = false;
/* XXX annoying hack: needed to prevent data corruption when changing
* scene frame in separate threads
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 2bf0f842623..ef39641b5f6 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -537,7 +537,7 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
static bool PE_create_shape_tree(PEData *data, Object *shapeob)
{
Object *shapeob_eval = DEG_get_evaluated_object(data->depsgraph, shapeob);
- Mesh *mesh = BKE_object_get_evaluated_mesh(shapeob_eval);
+ const Mesh *mesh = BKE_object_get_evaluated_mesh(shapeob_eval);
memset(&data->shape_bvh, 0, sizeof(data->shape_bvh));
@@ -1456,7 +1456,7 @@ void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), Part
BLI_kdtree_3d_free(edit->emitter_field);
totface = mesh->totface;
- /*totvert=dm->getNumVerts(dm);*/ /*UNUSED*/
+ // totvert = dm->getNumVerts(dm); /* UNUSED */
edit->emitter_cosnos = MEM_callocN(sizeof(float[6]) * totface, "emitter cosnos");
@@ -1564,7 +1564,7 @@ void update_world_cos(Object *ob, PTCacheEdit *edit)
}
static void update_velocities(PTCacheEdit *edit)
{
- /*TODO: get frs_sec properly */
+ /* TODO: get frs_sec properly. */
float vec1[3], vec2[3], frs_sec, dfra;
POINT_P;
KEY_K;
@@ -3003,7 +3003,7 @@ static void remove_tagged_keys(Depsgraph *depsgraph, Object *ob, ParticleSystem
LOOP_TAGGED_KEYS {
new_totkey--;
}
- /* we can't have elements with less than two keys*/
+ /* We can't have elements with less than two keys. */
if (new_totkey < 2) {
point->flag |= PEP_TAG;
}
@@ -3142,7 +3142,7 @@ static void subdivide_particle(PEData *data, int pa_index)
nkey++;
}
}
- /*tip still not copied*/
+ /* Tip still not copied. */
memcpy(nkey, key, sizeof(HairKey));
memcpy(nekey, ekey, sizeof(PTCacheEditKey));
@@ -3955,7 +3955,7 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
/* keep the same distance from the root or we get glitches T35406. */
dist_ensure_v3_v3fl(co, co_root, length_accum);
- /* re-use dco to compare before and after translation and add to the offset */
+ /* Re-use dco to compare before and after translation and add to the offset. */
copy_v3_v3(dco, key->co);
mul_v3_m4v3(key->co, imat, co);
@@ -3974,7 +3974,7 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
/* this is simple but looks bad, adds annoying kinks */
add_v3_v3(key->co, ofs);
#else
- /* translate (not rotate) the rest of the hair if its not selected */
+ /* Translate (not rotate) the rest of the hair if its not selected. */
{
/* NOLINTNEXTLINE: readability-redundant-preprocessor */
# if 0 /* kindof works but looks worse than what's below */
diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h
index 4dc3ded9bd7..ef07d73826a 100644
--- a/source/blender/editors/physics/physics_intern.h
+++ b/source/blender/editors/physics/physics_intern.h
@@ -147,7 +147,7 @@ void RIGIDBODY_OT_mass_calculate(struct wmOperatorType *ot);
void RIGIDBODY_OT_constraint_add(struct wmOperatorType *ot);
void RIGIDBODY_OT_constraint_remove(struct wmOperatorType *ot);
-/*rigidbody_world.c */
+/* rigidbody_world.c */
void RIGIDBODY_OT_world_add(struct wmOperatorType *ot);
void RIGIDBODY_OT_world_remove(struct wmOperatorType *ot);
void RIGIDBODY_OT_world_export(struct wmOperatorType *ot);
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 48f937fb4ec..17aaa5aa79d 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -141,7 +141,9 @@ typedef struct OGLRender {
wmWindowManager *wm;
wmWindow *win;
- wmTimer *timer; /* use to check if running modal or not (invoke'd or exec'd)*/
+ /** Use to check if running modal or not (invoke'd or exec'd). */
+ wmTimer *timer;
+
void **movie_ctx_arr;
TaskPool *task_pool;
@@ -461,7 +463,7 @@ static void screen_opengl_render_write(OGLRender *oglrender)
static void UNUSED_FUNCTION(addAlphaOverFloat)(float dest[4], const float source[4])
{
- /* d = s + (1-alpha_s)d*/
+ /* `d = s + (1-alpha_s)d` */
float mul;
mul = 1.0f - source[3];
@@ -544,7 +546,7 @@ static void gather_frames_to_render_for_adt(const OGLRender *oglrender, const An
continue;
}
- bool found = false; /* Not interesting, we just want a starting point for the for-loop.*/
+ bool found = false; /* Not interesting, we just want a starting point for the for-loop. */
int key_index = BKE_fcurve_bezt_binarysearch_index(
fcu->bezt, frame_start, fcu->totvert, &found);
for (; key_index < fcu->totvert; key_index++) {
@@ -645,7 +647,7 @@ static int gather_frames_to_render_for_id(LibraryIDLinkCallbackData *cb_data)
case ID_WM: /* WindowManager */
case ID_LS: /* FreestyleLineStyle */
case ID_PAL: /* Palette */
- case ID_PC: /* PaintCurve */
+ case ID_PC: /* PaintCurve */
case ID_CF: /* CacheFile */
case ID_WS: /* WorkSpace */
/* Only follow pointers to specific datablocks, to avoid ending up in
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 0b0009c2a2f..f36ce7408b5 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -955,7 +955,7 @@ static void shader_preview_texture(ShaderPreview *sp, Tex *tex, Scene *sce, Rend
for (int x = 0; x < width; x++) {
tex_coord[0] = ((float)x / (float)height) * 2.0f - 1.0f;
- /* Evaluate texture at tex_coord .*/
+ /* Evaluate texture at tex_coord. */
TexResult texres = {0};
BKE_texture_get_value_ex(sce, tex, tex_coord, &texres, img_pool, color_manage);
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index b4cac58db1f..ae9f80f746a 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -103,7 +103,7 @@ static bool object_materials_supported_poll_ex(bContext *C, const Object *ob);
/** \name Local Utilities
* \{ */
-static bool object_array_for_shading_edit_mode_enabled_filter(Object *ob, void *user_data)
+static bool object_array_for_shading_edit_mode_enabled_filter(const Object *ob, void *user_data)
{
bContext *C = user_data;
if (object_materials_supported_poll_ex(C, ob)) {
@@ -120,7 +120,7 @@ static Object **object_array_for_shading_edit_mode_enabled(bContext *C, uint *r_
C, object_array_for_shading_edit_mode_enabled_filter, C, r_objects_len);
}
-static bool object_array_for_shading_edit_mode_disabled_filter(Object *ob, void *user_data)
+static bool object_array_for_shading_edit_mode_disabled_filter(const Object *ob, void *user_data)
{
bContext *C = user_data;
if (object_materials_supported_poll_ex(C, ob)) {
@@ -227,7 +227,7 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* Removing material slots in edit mode screws things up, see bug T21822.*/
+ /* Removing material slots in edit mode screws things up, see bug T21822. */
if (ob == CTX_data_edit_object(C)) {
BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode");
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 3e8a1bda2f0..80b5623b9c3 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -216,7 +216,7 @@ void ED_render_view_layer_changed(Main *bmain, bScreen *screen)
/***************************** Updates ***********************************
* ED_render_id_flush_update gets called from DEG_id_tag_update, to do *
* editor level updates when the ID changes. when these ID blocks are in *
- * the dependency graph, we can get rid of the manual dependency checks */
+ * the dependency graph, we can get rid of the manual dependency checks. */
static void material_changed(Main *UNUSED(bmain), Material *ma)
{
diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c
index eb4a040e891..97ecb67d6cc 100644
--- a/source/blender/editors/render/render_view.c
+++ b/source/blender/editors/render/render_view.c
@@ -51,9 +51,11 @@
/*********************** utilities for finding areas *************************/
-/* returns biggest area that is not uv/image editor. Note that it uses buttons */
-/* window as the last possible alternative. */
-/* would use BKE_screen_find_big_area(...) but this is too specific */
+/**
+ * Returns biggest area that is not uv/image editor. Note that it uses buttons
+ * window as the last possible alternative.
+ * would use #BKE_screen_find_big_area(...) but this is too specific.
+ */
static ScrArea *biggest_non_image_area(bContext *C)
{
bScreen *screen = CTX_wm_screen(C);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 377cc60f9db..175efc5387b 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1461,7 +1461,7 @@ static void region_rect_recursive(
}
}
else if (ELEM(alignment, RGN_ALIGN_VSPLIT, RGN_ALIGN_HSPLIT)) {
- /* percentage subdiv*/
+ /* Percentage subdiv. */
region->winrct = *remainder;
if (alignment == RGN_ALIGN_HSPLIT) {
@@ -3325,10 +3325,10 @@ void ED_region_header_layout(const bContext *C, ARegion *region)
maxco += UI_HEADER_OFFSET;
}
- /* always as last */
+ /* Always as last. */
UI_view2d_totRect_set(&region->v2d, maxco, region->winy);
- /* restore view matrix */
+ /* Restore view matrix. */
UI_view2d_view_restore(C);
}
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 627a67358f2..45cf1775ccb 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -874,7 +874,7 @@ static eContextResult screen_ctx_editable_gpencil_strokes(const bContext *C,
}
}
}
- /* if not multiedit out of loop */
+ /* If not multi-edit out of loop. */
if (!is_multiedit) {
break;
}
diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c
index 2c45524ef94..dca464bbf22 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -244,7 +244,7 @@ void screen_draw_join_highlight(ScrArea *sa1, ScrArea *sa2)
return;
}
- /* Rect of the combined areas.*/
+ /* Rect of the combined areas. */
const bool vertical = SCREEN_DIR_IS_VERTICAL(dir);
const rctf combined = {
.xmin = vertical ? MAX2(sa1->totrct.xmin, sa2->totrct.xmin) :
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 21800536503..e2d95035ba8 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1564,6 +1564,14 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
BLI_assert(CTX_wm_screen(C) == screen);
BLI_assert(CTX_wm_area(C) == NULL); /* May have been freed. */
+ /* Setting the area is only needed for Python scripts that call
+ * operators in succession before returning to the main event loop.
+ * Without this, scripts can't run any operators that require
+ * an area after toggling full-screen for example (see: T89526).
+ * NOTE: an old comment stated this was "bad code",
+ * however it doesn't cause problems so leave as-is. */
+ CTX_wm_area_set(C, screen->areabase.first);
+
return screen->areabase.first;
}
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index f0e12ca60e9..159b649ec71 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -2117,16 +2117,16 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *area, ScrArea *sb)
ScrVert *sbv3 = sb->v3;
ScrVert *sbv4 = sb->v4;
- if (sav1 == sbv4 && sav2 == sbv3) { /* area to right of sb = W */
+ if (sav1 == sbv4 && sav2 == sbv3) { /* Area to right of sb = W. */
return BKE_screen_find_edge(screen, sav1, sav2);
}
- if (sav2 == sbv1 && sav3 == sbv4) { /* area to bottom of sb = N */
+ if (sav2 == sbv1 && sav3 == sbv4) { /* Area to bottom of sb = N. */
return BKE_screen_find_edge(screen, sav2, sav3);
}
- if (sav3 == sbv2 && sav4 == sbv1) { /* area to left of sb = E */
+ if (sav3 == sbv2 && sav4 == sbv1) { /* Area to left of sb = E. */
return BKE_screen_find_edge(screen, sav3, sav4);
}
- if (sav1 == sbv2 && sav4 == sbv3) { /* area on top of sb = S*/
+ if (sav1 == sbv2 && sav4 == sbv3) { /* Area on top of sb = S. */
return BKE_screen_find_edge(screen, sav1, sav4);
}
@@ -5598,13 +5598,13 @@ static void SCREEN_OT_workspace_cycle(wmOperatorType *ot)
/* called in spacetypes.c */
void ED_operatortypes_screen(void)
{
- /* generic UI stuff */
+ /* Generic UI stuff. */
WM_operatortype_append(SCREEN_OT_actionzone);
WM_operatortype_append(SCREEN_OT_repeat_last);
WM_operatortype_append(SCREEN_OT_repeat_history);
WM_operatortype_append(SCREEN_OT_redo_last);
- /* screen tools */
+ /* Screen tools. */
WM_operatortype_append(SCREEN_OT_area_move);
WM_operatortype_append(SCREEN_OT_area_split);
WM_operatortype_append(SCREEN_OT_area_join);
@@ -5631,7 +5631,7 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(SCREEN_OT_space_context_cycle);
WM_operatortype_append(SCREEN_OT_workspace_cycle);
- /*frame changes*/
+ /* Frame changes. */
WM_operatortype_append(SCREEN_OT_frame_offset);
WM_operatortype_append(SCREEN_OT_frame_jump);
WM_operatortype_append(SCREEN_OT_keyframe_jump);
@@ -5641,7 +5641,7 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(SCREEN_OT_animation_play);
WM_operatortype_append(SCREEN_OT_animation_cancel);
- /* new/delete */
+ /* New/delete. */
WM_operatortype_append(SCREEN_OT_new);
WM_operatortype_append(SCREEN_OT_delete);
}
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 7e111905883..ab2b2f4b16b 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -940,7 +940,7 @@ static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc)
int j;
PaintCurvePoint *cp_next = cp + 1;
float data[(PAINT_CURVE_NUM_SEGMENTS + 1) * 2];
- /* Use color coding to distinguish handles vs curve segments. */
+ /* Use color coding to distinguish handles vs curve segments. */
draw_bezier_handle_lines(pos, selec_col, &cp->bez);
draw_tri_point(pos, selec_col, pivot_col, &cp->bez.vec[1][0], 10.0f, cp->bez.f2);
draw_rect_point(
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index f0923cf3d28..392f39bbb94 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -745,7 +745,7 @@ static void brush_painter_2d_tex_mapping(ImagePaintState *s,
mapping->ymax = (ymax - ymin) / (float)diameter;
}
else if (mapmode == MTEX_MAP_MODE_3D) {
- /* 3D mapping, just mapping to canvas 0..1 */
+ /* 3D mapping, just mapping to canvas 0..1. */
mapping->xmin = 2.0f * (ipos[0] * invw - 0.5f);
mapping->ymin = 2.0f * (ipos[1] * invh - 0.5f);
mapping->xmax = 2.0f * invw;
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index c83e4de281a..2437e0d1939 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -391,7 +391,7 @@ typedef struct ProjPaintState {
float *cavities;
#ifndef PROJ_DEBUG_NOSEAMBLEED
- /** store info about faces, if they are initialized etc*/
+ /** Store info about faces, if they are initialized etc. */
ushort *faceSeamFlags;
/** save the winding of the face in uv space,
* helps as an extra validation step for seam detection. */
@@ -576,7 +576,9 @@ static Image *project_paint_face_clone_image(const ProjPaintState *ps, int tri_i
return slot ? slot->ima : ps->clone_ima;
}
-/* fast projection bucket array lookup, use the safe version for bound checking */
+/**
+ * Fast projection bucket array lookup, use the safe version for bound checking.
+ */
static int project_bucket_offset(const ProjPaintState *ps, const float projCoSS[2])
{
/* If we were not dealing with screen-space 2D coords we could simple do...
@@ -1071,7 +1073,7 @@ static bool pixel_bounds_uv(const float uv_quad[4][2],
bounds_px->xmax = (int)(ibuf_x * max_uv[0]) + 1;
bounds_px->ymax = (int)(ibuf_y * max_uv[1]) + 1;
- /*printf("%d %d %d %d\n", min_px[0], min_px[1], max_px[0], max_px[1]);*/
+ // printf("%d %d %d %d\n", min_px[0], min_px[1], max_px[0], max_px[1]);
/* face uses no UV area when quantized to pixels? */
return (bounds_px->xmin == bounds_px->xmax || bounds_px->ymin == bounds_px->ymax) ? false : true;
@@ -1101,7 +1103,7 @@ static bool pixel_bounds_array(
bounds_px->xmax = (int)(ibuf_x * max_uv[0]) + 1;
bounds_px->ymax = (int)(ibuf_y * max_uv[1]) + 1;
- /*printf("%d %d %d %d\n", min_px[0], min_px[1], max_px[0], max_px[1]);*/
+ // printf("%d %d %d %d\n", min_px[0], min_px[1], max_px[0], max_px[1]);
/* face uses no UV area when quantized to pixels? */
return (bounds_px->xmin == bounds_px->xmax || bounds_px->ymin == bounds_px->ymax) ? false : true;
@@ -1772,7 +1774,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps,
}
if (angle_cos <= ps->normal_angle__cos) {
- /* outsize the normal limit*/
+ /* Outsize the normal limit. */
return 0.0f;
}
if (angle_cos < ps->normal_angle_inner__cos) {
@@ -1876,7 +1878,7 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
int x_tile, y_tile;
int x_round, y_round;
int tile_offset;
- /* volatile is important here to ensure pending check is not optimized away by compiler*/
+ /* Volatile is important here to ensure pending check is not optimized away by compiler. */
volatile int tile_index;
ProjPaintImage *projima = tinf->pjima;
@@ -2061,7 +2063,7 @@ static bool line_clip_rect2f(const rctf *cliprect,
return false;
}
- /* this is a single point (or close to)*/
+ /* This is a single point (or close to). */
if (fabsf(l1[0] - l2[0]) < PROJ_PIXEL_TOLERANCE) {
if (BLI_rctf_isect_pt_v(rect, l1)) {
copy_v2_v2(l1_clip, l1);
@@ -2088,7 +2090,7 @@ static bool line_clip_rect2f(const rctf *cliprect,
return false;
}
- /* this is a single point (or close to)*/
+ /* This is a single point (or close to). */
if (fabsf(l1[1] - l2[1]) < PROJ_PIXEL_TOLERANCE) {
if (BLI_rctf_isect_pt_v(rect, l1)) {
copy_v2_v2(l1_clip, l1);
@@ -2600,8 +2602,8 @@ static void project_bucket_clip_face(const bool is_ortho,
return;
}
- /* get the UV space bounding box */
- /* use IsectPT2Df_limit here so we catch points are are touching the tri edge
+ /* Get the UV space bounding box. */
+ /* Use #IsectPT2Df_limit here so we catch points are touching the triangles edge
* (or a small fraction over) */
bucket_bounds_ss[0][0] = bucket_bounds->xmax;
bucket_bounds_ss[0][1] = bucket_bounds->ymin;
@@ -2676,7 +2678,7 @@ static void project_bucket_clip_face(const bool is_ortho,
/* calc center */
float cent[2] = {0.0f, 0.0f};
- /*float up[2] = {0.0f, 1.0f};*/
+ // float up[2] = {0.0f, 1.0f};
bool doubles;
(*tot) = 0;
@@ -2969,7 +2971,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
ImBuf *ibuf,
ImBuf **tmpibuf)
{
- /* Projection vars, to get the 3D locations into screen space */
+ /* Projection vars, to get the 3D locations into screen space. */
MemArena *arena = ps->arena_mt[thread_index];
LinkNode **bucketPixelNodes = ps->bucketRect + bucket_index;
LinkNode *bucketFaceNodes = ps->bucketFaces[bucket_index];
@@ -3011,7 +3013,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
rcti bounds_px;
/* Variables for getting UV-space bounds. */
- /* bucket bounds in UV space so we can init pixels only for this face, */
+ /* Bucket bounds in UV space so we can init pixels only for this face. */
float lt_uv_pxoffset[3][2];
float xhalfpx, yhalfpx;
const float ibuf_xf = (float)ibuf->x, ibuf_yf = (float)ibuf->y;
@@ -3063,7 +3065,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
v2coSS = ps->screenCoords[lt_vtri[1]];
v3coSS = ps->screenCoords[lt_vtri[2]];
- /* This function gives is a concave polyline in UV space from the clipped tri*/
+ /* This function gives is a concave polyline in UV space from the clipped tri. */
project_bucket_clip_face(is_ortho,
is_flip_object,
clip_rect,
@@ -4428,7 +4430,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
}
}
- /* build an array of images we use*/
+ /* Build an array of images we use. */
if (ps->is_shared_user == false) {
project_paint_build_proj_ima(ps, arena, &used_images);
}
@@ -4516,8 +4518,8 @@ static void project_paint_begin(const bContext *C,
reset_threads = true;
}
- /* really high values could cause problems since it has to allocate a few
- * (ps->buckets_x*ps->buckets_y) sized arrays */
+ /* Really high values could cause problems since it has to allocate a few
+ * `(ps->buckets_x * ps->buckets_y)` sized arrays. */
CLAMP(ps->buckets_x, PROJ_BUCKET_RECT_MIN, PROJ_BUCKET_RECT_MAX);
CLAMP(ps->buckets_y, PROJ_BUCKET_RECT_MIN, PROJ_BUCKET_RECT_MAX);
@@ -4768,7 +4770,7 @@ static bool project_bucket_iter_next(ProjPaintState *ps,
BLI_assert(bucket_y >= ps->bucketMin[1] && bucket_y < ps->bucketMax[1]);
if (bucket_x >= ps->bucketMin[0] && bucket_x < ps->bucketMax[0]) {
- /* use bucket_bounds for project_bucket_isect_circle and project_bucket_init*/
+ /* Use bucket_bounds for #project_bucket_isect_circle and #project_bucket_init. */
project_bucket_bounds(ps, bucket_x, bucket_y, bucket_bounds);
if ((ps->source != PROJ_SRC_VIEW) ||
@@ -5354,7 +5356,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v
dist_sq = len_squared_v2v2(projPixel->projCoSS, pos);
- /*if (dist < radius) {*/ /* correct but uses a sqrtf */
+ /* Faster alternative to `dist < radius` without a #sqrtf. */
if (dist_sq <= brush_radius_sq) {
dist = sqrtf(dist_sq);
@@ -5364,7 +5366,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v
float texrgb[3];
float mask;
- /* Extra mask for normal, layer stencil, .. */
+ /* Extra mask for normal, layer stencil, etc. */
float custom_mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
/* Mask texture. */
@@ -5447,7 +5449,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v
}
/* end copy */
- /* validate undo tile, since we will modify t*/
+ /* Validate undo tile, since we will modify it. */
*projPixel->valid = true;
last_partial_redraw_cell = last_projIma->partRedrawRect + projPixel->bb_cell_index;
@@ -5812,7 +5814,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
ps->is_maskbrush = (brush->mask_mtex.tex) ? true : false;
}
else {
- /* brush may be NULL*/
+ /* Brush may be NULL. */
ps->do_masking = false;
ps->is_texbrush = false;
ps->is_maskbrush = false;
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index fed89e02e8f..e2b21145c2d 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -62,7 +62,7 @@
/* Brush operators */
static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- /*int type = RNA_enum_get(op->ptr, "type");*/
+ // int type = RNA_enum_get(op->ptr, "type");
Paint *paint = BKE_paint_get_active_from_context(C);
Brush *br = BKE_paint_brush(paint);
Main *bmain = CTX_data_main(C);
@@ -97,7 +97,7 @@ static void BRUSH_OT_add(wmOperatorType *ot)
static int brush_add_gpencil_exec(bContext *C, wmOperator *UNUSED(op))
{
- /*int type = RNA_enum_get(op->ptr, "type");*/
+ // int type = RNA_enum_get(op->ptr, "type");
ToolSettings *ts = CTX_data_tool_settings(C);
Paint *paint = &ts->gp_paint->paint;
Brush *br = BKE_paint_brush(paint);
@@ -1385,7 +1385,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
keymap = WM_keymap_ensure(keyconf, "Weight Paint", 0, 0);
keymap->poll = weight_paint_mode_poll;
- /*Weight paint's Vertex Selection Mode */
+ /* Weight paint's Vertex Selection Mode. */
keymap = WM_keymap_ensure(keyconf, "Paint Vertex Selection (Weight, Vertex)", 0, 0);
keymap->poll = vert_paint_poll;
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 59a5ad63f0e..de01bc3a474 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -541,7 +541,7 @@ static void paint_brush_stroke_add_step(bContext *C,
* It's strange that only texpaint had these guards. */
#if 0
/* special exception here for too high pressure values on first touch in
- * windows for some tablets, then we just skip first touch .. */
+ * windows for some tablets, then we just skip first touch. */
if (tablet && (pressure >= 0.99f) &&
((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) ||
BKE_brush_use_alpha_pressure(pop->s.brush) ||
@@ -1115,7 +1115,7 @@ bool paint_supports_dynamic_tex_coords(Brush *br, ePaintMode mode)
#define PAINT_STROKE_MODAL_CANCEL 1
-/* called in paint_ops.c, on each regeneration of keymaps */
+/* Called in paint_ops.c, on each regeneration of key-maps. */
struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf)
{
static struct EnumPropertyItem modal_items[] = {
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 0a5f1975361..caf2bc46ad8 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -179,7 +179,7 @@ static MDeformVert *defweight_prev_init(MDeformVert *dvert_prev,
* (without evaluating modifiers) */
static bool vertex_paint_use_fast_update_check(Object *ob)
{
- Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
+ const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
if (me_eval != NULL) {
Mesh *me = BKE_mesh_from_object(ob);
@@ -2750,11 +2750,11 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
* if not we can skip face map trickiness */
if (vertex_paint_use_fast_update_check(ob)) {
vpd->use_fast_update = true;
- /* printf("Fast update!\n");*/
+ // printf("Fast update!\n");
}
else {
vpd->use_fast_update = false;
- /* printf("No fast update!\n");*/
+ // printf("No fast update!\n");
}
/* to keep tracked of modified loops for shared vertex color blending */
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 0fafd3589fe..7991987ae1f 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -791,7 +791,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
wpaint_prev_create(
&((WPGradient_vertStoreBase *)gesture->user_data.data)->wpp, me->dvert, me->totvert);
- /* on init only, convert face -> vert sel */
+ /* On initialization only, convert face -> vert sel. */
if (me->editflag & ME_EDIT_PAINT_FACE_SEL) {
BKE_mesh_flush_select_from_polys(me);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index d6d54a1985d..ab5c46f4bc5 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1146,10 +1146,9 @@ void SCULPT_floodfill_add_active(
v = SCULPT_active_vertex_get(ss);
}
else if (radius > 0.0f) {
- float radius_squared = (radius == FLT_MAX) ? FLT_MAX : radius * radius;
float location[3];
flip_v3_v3(location, SCULPT_active_vertex_co_get(ss), i);
- v = SCULPT_nearest_vertex_get(sd, ob, location, radius_squared, false);
+ v = SCULPT_nearest_vertex_get(sd, ob, location, radius, false);
}
if (v != -1) {
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index e2ee4c9fed3..43704c73faf 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -623,7 +623,7 @@ typedef struct SculptUndoNode {
SculptUndoType type;
- char idname[MAX_ID_NAME]; /* name instead of pointer*/
+ char idname[MAX_ID_NAME]; /* Name instead of pointer. */
void *node; /* only during push, not valid afterwards! */
float (*co)[3];
@@ -977,7 +977,7 @@ typedef struct StrokeCache {
/* Symmetry index between 0 and 7 bit combo 0 is Brush only;
* 1 is X mirror; 2 is Y mirror; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
int symmetry;
- int mirror_symmetry_pass; /* the symmetry pass we are currently on between 0 and 7*/
+ int mirror_symmetry_pass; /* The symmetry pass we are currently on between 0 and 7. */
float true_view_normal[3];
float view_normal[3];
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 219a8303674..771e0e1e47b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -92,7 +92,7 @@ typedef struct UVInitialStroke {
/* Initial Selection,for grab brushes for instance */
UVInitialStrokeElement *initialSelection;
- /* total initially selected UVs*/
+ /* Total initially selected UV's. */
int totalInitialSelected;
/* initial mouse coordinates */
@@ -101,9 +101,9 @@ typedef struct UVInitialStroke {
/* custom data for uv smoothing brush */
typedef struct UvSculptData {
- /* Contains the first of each set of coincident uvs.
+ /* Contains the first of each set of coincident UV's.
* These will be used to perform smoothing on and propagate the changes
- * to their coincident uvs */
+ * to their coincident UV's */
UvAdjacencyElement *uv;
/* ...Is what it says */
@@ -121,7 +121,7 @@ typedef struct UvSculptData {
/* timer to be used for airbrush-type brush */
wmTimer *timer;
- /* to determine quickly adjacent uvs */
+ /* to determine quickly adjacent UV's */
UvElementMap *elementMap;
/* uvsmooth Paint for fast reference */
@@ -505,7 +505,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
bool do_island_optimization = !(ts->uv_sculpt_settings & UV_SCULPT_ALL_ISLANDS);
int island_index = 0;
- /* Holds, for each UvElement in elementMap, a pointer to its unique uv.*/
+ /* 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 :
@@ -550,7 +550,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
island_index = element->island;
}
- /* Count 'unique' uvs */
+ /* Count 'unique' UV's */
for (i = 0; i < data->elementMap->totalUVs; i++) {
if (data->elementMap->buf[i].separate &&
(!do_island_optimization || data->elementMap->buf[i].island == island_index)) {
@@ -603,7 +603,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
data->uv[counter].flag = 0;
data->uv[counter].uv = luv->uv;
}
- /* pointer arithmetic to the rescue, as always :)*/
+ /* Pointer arithmetic to the rescue, as always :). */
uniqueUv[element - data->elementMap->buf] = counter;
}
}
@@ -627,8 +627,8 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
offset2 = uniqueUv[itmp2];
edges[counter].flag = 0;
- /* using an order policy, sort uvs according to address space. This avoids
- * Having two different UvEdges with the same uvs on different positions */
+ /* Using an order policy, sort UV's according to address space.
+ * This avoids having two different UvEdges with the same UV's on different positions. */
if (offset1 < offset2) {
edges[counter].uv1 = offset1;
edges[counter].uv2 = offset2;
@@ -674,7 +674,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
BLI_ghash_free(edgeHash, NULL, NULL);
MEM_freeN(edges);
- /* transfer boundary edge property to uvs */
+ /* transfer boundary edge property to UV's */
if (ts->uv_sculpt_settings & UV_SCULPT_LOCK_BORDERS) {
for (i = 0; i < data->totalUvEdges; i++) {
if (!data->uvedges[i].flag) {
diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c
index efa714e315d..9e69b0a72db 100644
--- a/source/blender/editors/space_action/action_data.c
+++ b/source/blender/editors/space_action/action_data.c
@@ -723,7 +723,7 @@ static NlaStrip *action_layer_get_nlastrip(ListBase *strips, float ctime)
return NULL;
}
-/* Switch NLA Strips/Actions */
+/* Switch NLA Strips/Actions. */
static void action_layer_switch_strip(
AnimData *adt, NlaTrack *old_track, NlaStrip *old_strip, NlaTrack *nlt, NlaStrip *strip)
{
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 5036f22fd0e..d305f7504f3 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -83,7 +83,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
/* 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->area, v2d, V2D_LOCK_COPY);
- /* loop through channels, and set up drawing depending on their type */
+ /* 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);
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index fea62f0d9c2..ae9d5445e1d 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -163,7 +163,7 @@ void ACTION_OT_markers_make_local(wmOperatorType *ot)
/* *************************** Calculate Range ************************** */
-/* Get the min/max keyframes*/
+/* Get the min/max keyframes. */
static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const short onlySel)
{
ListBase anim_data = {NULL, NULL};
@@ -1137,7 +1137,7 @@ void ACTION_OT_clean(wmOperatorType *ot)
/* ******************** Sample Keyframes Operator *********************** */
-/* Evaluates the curves between each selected keyframe on each frame, and keys the value */
+/* Evaluates the curves between each selected keyframe on each frame, and keys the value. */
static void sample_action_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
@@ -1149,7 +1149,7 @@ static void sample_action_keys(bAnimContext *ac)
ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- /* loop through filtered data and add keys between selected keyframes on every frame */
+ /* Loop through filtered data and add keys between selected keyframes on every frame. */
for (ale = anim_data.first; ale; ale = ale->next) {
sample_fcurve((FCurve *)ale->key_data);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index fea01ab5330..a51d9086dea 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -470,7 +470,7 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- /* get beztriple editing/validation funcs */
+ /* Get beztriple editing/validation funcs. */
sel_data.select_cb = ANIM_editkeyframes_select(selectmode);
if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) {
@@ -708,7 +708,7 @@ static void region_select_action_keys(
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- /* get beztriple editing/validation funcs */
+ /* Get beztriple editing/validation funcs. */
sel_data.select_cb = ANIM_editkeyframes_select(selectmode);
sel_data.ok_cb = ANIM_editkeyframes_ok(mode);
@@ -1497,7 +1497,7 @@ void ACTION_OT_select_leftright(wmOperatorType *ot)
ot->idname = "ACTION_OT_select_leftright";
ot->description = "Select keyframes to the left or the right of the current frame";
- /* api callbacks */
+ /* api callbacks */
ot->invoke = actkeys_select_leftright_invoke;
ot->exec = actkeys_select_leftright_exec;
ot->poll = ED_operator_action_active;
@@ -1840,7 +1840,7 @@ static int actkeys_clickselect_exec(bContext *C, wmOperator *op)
mval[0] = RNA_int_get(op->ptr, "mouse_x");
mval[1] = RNA_int_get(op->ptr, "mouse_y");
- /* select keyframe(s) based upon mouse position*/
+ /* Select keyframe(s) based upon mouse position. */
ret_value = mouse_action_keys(
&ac, mval, selectmode, deselect_all, column, channel, wait_to_deselect_others);
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index aeb2c04656e..a2d9235cfb2 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -154,7 +154,9 @@ static bool buttons_context_path_world(ButsContextPath *path)
return false;
}
-static bool buttons_context_path_collection(ButsContextPath *path, wmWindow *window)
+static bool buttons_context_path_collection(const bContext *C,
+ ButsContextPath *path,
+ wmWindow *window)
{
PointerRNA *ptr = &path->ptr[path->len - 1];
@@ -162,10 +164,19 @@ static bool buttons_context_path_collection(ButsContextPath *path, wmWindow *win
if (RNA_struct_is_a(ptr->type, &RNA_Collection)) {
return true;
}
+
+ Scene *scene = CTX_data_scene(C);
+
/* if we have a view layer, use the view layer's active collection */
if (buttons_context_path_view_layer(path, window)) {
ViewLayer *view_layer = path->ptr[path->len - 1].data;
Collection *c = view_layer->active_collection->collection;
+
+ /* Do not show collection tab for master collection. */
+ if (c == scene->master_collection) {
+ return false;
+ }
+
if (c) {
RNA_id_pointer_create(&c->id, &path->ptr[path->len]);
path->len++;
@@ -600,7 +611,7 @@ static bool buttons_context_path(
found = buttons_context_path_world(path);
break;
case BCONTEXT_COLLECTION: /* This is for Line Art collection flags */
- found = buttons_context_path_collection(path, window);
+ found = buttons_context_path_collection(C, path, window);
break;
case BCONTEXT_TOOL:
found = true;
@@ -1220,7 +1231,7 @@ static void buttons_panel_context_draw(const bContext *C, Panel *panel)
continue;
}
- /* Add icon and name .*/
+ /* Add icon and name. */
int icon = RNA_struct_ui_icon(ptr->type);
char namebuf[128];
char *name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL);
@@ -1273,7 +1284,7 @@ ID *buttons_context_id_path(const bContext *C)
for (int i = path->len - 1; i >= 0; i--) {
PointerRNA *ptr = &path->ptr[i];
- /* pin particle settings instead of system, since only settings are an idblock*/
+ /* Pin particle settings instead of system, since only settings are an idblock. */
if (sbuts->mainb == BCONTEXT_PARTICLE && sbuts->flag & SB_PIN_CONTEXT) {
if (ptr->type == &RNA_ParticleSystem && ptr->data) {
ParticleSystem *psys = ptr->data;
@@ -1281,7 +1292,7 @@ ID *buttons_context_id_path(const bContext *C)
}
}
- /* There is no valid image ID panel, Image Empty objects need this workaround.*/
+ /* There is no valid image ID panel, Image Empty objects need this workaround. */
if (sbuts->mainb == BCONTEXT_DATA && sbuts->flag & SB_PIN_CONTEXT) {
if (ptr->type == &RNA_Image && ptr->data) {
continue;
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 9db8f7efbb2..57a7fe894b0 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -202,11 +202,11 @@ int ED_buttons_tabs_list(SpaceProperties *sbuts, short *context_tabs_array)
context_tabs_array[length] = BCONTEXT_WORLD;
length++;
}
- if (length != 0) {
- context_tabs_array[length] = -1;
- length++;
- }
if (sbuts->pathflag & (1 << BCONTEXT_COLLECTION)) {
+ if (length != 0) {
+ context_tabs_array[length] = -1;
+ length++;
+ }
context_tabs_array[length] = BCONTEXT_COLLECTION;
length++;
}
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index dbf733413e5..7194e78e940 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -398,7 +398,7 @@ void clip_delete_plane_track(bContext *C, MovieClip *clip, MovieTrackingPlaneTra
DEG_id_tag_update(&clip->id, 0);
}
-/* Calculate space clip offset to be centered at the given point. */
+/* Calculate space clip offset to be centered at the given point. */
void clip_view_offset_for_center_to_point(
SpaceClip *sc, const float x, const float y, float *r_offset_x, float *r_offset_y)
{
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index 05595e0b393..9b4b020b276 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -747,7 +747,7 @@ static int console_clear_exec(bContext *C, wmOperator *op)
const bool scrollback = RNA_boolean_get(op->ptr, "scrollback");
const bool history = RNA_boolean_get(op->ptr, "history");
- /*ConsoleLine *ci = */ console_history_verify(C);
+ /* ConsoleLine *ci = */ console_history_verify(C);
if (scrollback) { /* Last item in history. */
while (sc->scrollback.first) {
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 5e09692b041..edef50c15a1 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -25,6 +25,8 @@
#include <math.h>
#include <string.h>
+#include "MEM_guardedalloc.h"
+
#include "BLI_alloca.h"
#include "BLI_blenlib.h"
#include "BLI_fileops_types.h"
@@ -165,7 +167,7 @@ static void file_draw_icon(const SpaceFile *sfile,
const float a2 = dimmed ? 0.3f : 0.0f;
but = uiDefIconBut(
block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, a1, a2, NULL);
- UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path));
+ UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path), MEM_freeN);
if (drag) {
/* TODO duplicated from file_draw_preview(). */
@@ -398,7 +400,7 @@ static void file_draw_preview(const SpaceFile *sfile,
imb->x,
imb->y,
GPU_RGBA8,
- false,
+ true,
imb->rect,
scale,
scale,
@@ -489,7 +491,8 @@ static void file_draw_preview(const SpaceFile *sfile,
UI_but_drag_set_id(but, id);
}
/* path is no more static, cannot give it directly to but... */
- else if (file->typeflag & FILE_TYPE_ASSET) {
+ else if (sfile->browse_mode == FILE_BROWSE_MODE_ASSETS &&
+ (file->typeflag & FILE_TYPE_ASSET) != 0) {
char blend_path[FILE_MAX_LIBEXTRA];
if (BLO_library_path_explode(path, blend_path, NULL, NULL)) {
@@ -549,7 +552,7 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname)
}
/* to make sure we show what is on disk */
- ED_fileselect_clear(wm, CTX_data_scene(C), sfile);
+ ED_fileselect_clear(wm, sfile);
}
ED_region_tag_redraw(region);
@@ -724,40 +727,45 @@ static void draw_columnheader_columns(const FileSelectParams *params,
/**
* Updates the stat string stored in file->entry if necessary.
*/
-static const char *filelist_get_details_column_string(FileAttributeColumnType column,
- const FileDirEntry *file,
- const bool small_size,
- const bool update_stat_strings)
+static const char *filelist_get_details_column_string(
+ FileAttributeColumnType column,
+ /* Generated string will be cached in the file, so non-const. */
+ FileDirEntry *file,
+ const bool small_size,
+ const bool update_stat_strings)
{
switch (column) {
case COLUMN_DATETIME:
if (!(file->typeflag & FILE_TYPE_BLENDERLIB) && !FILENAME_IS_CURRPAR(file->relpath)) {
- if ((file->entry->datetime_str[0] == '\0') || update_stat_strings) {
+ if ((file->draw_data.datetime_str[0] == '\0') || update_stat_strings) {
char date[FILELIST_DIRENTRY_DATE_LEN], time[FILELIST_DIRENTRY_TIME_LEN];
bool is_today, is_yesterday;
BLI_filelist_entry_datetime_to_string(
- NULL, file->entry->time, small_size, time, date, &is_today, &is_yesterday);
+ NULL, file->time, small_size, time, date, &is_today, &is_yesterday);
if (is_today || is_yesterday) {
BLI_strncpy(date, is_today ? N_("Today") : N_("Yesterday"), sizeof(date));
}
- BLI_snprintf(
- file->entry->datetime_str, sizeof(file->entry->datetime_str), "%s %s", date, time);
+ BLI_snprintf(file->draw_data.datetime_str,
+ sizeof(file->draw_data.datetime_str),
+ "%s %s",
+ date,
+ time);
}
- return file->entry->datetime_str;
+ return file->draw_data.datetime_str;
}
break;
case COLUMN_SIZE:
if ((file->typeflag & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) ||
!(file->typeflag & (FILE_TYPE_DIR | FILE_TYPE_BLENDERLIB))) {
- if ((file->entry->size_str[0] == '\0') || update_stat_strings) {
+ if ((file->draw_data.size_str[0] == '\0') || update_stat_strings) {
BLI_filelist_entry_size_to_string(
- NULL, file->entry->size, small_size, file->entry->size_str);
+ NULL, file->size, small_size, file->draw_data.size_str);
}
- return file->entry->size_str;
+ return file->draw_data.size_str;
}
break;
default:
@@ -769,7 +777,7 @@ static const char *filelist_get_details_column_string(FileAttributeColumnType co
static void draw_details_columns(const FileSelectParams *params,
const FileLayout *layout,
- const FileDirEntry *file,
+ FileDirEntry *file,
const int pos_x,
const int pos_y,
const uchar text_col[4])
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 0ac03c4c307..1ba1c1d6954 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -86,7 +86,7 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile,
BLI_rctf_rcti_copy(&rect_region_fl, rect_region);
- /* Okay, manipulating v2d rects here is hacky... */
+ /* Okay, manipulating v2d rects here is hacky... */
v2d->mask.ymax -= sfile->layout->offset_top;
v2d->cur.ymax -= sfile->layout->offset_top;
UI_view2d_region_to_view_rctf(v2d, &rect_region_fl, &rect_view_fl);
@@ -1882,7 +1882,7 @@ static int file_refresh_exec(bContext *C, wmOperator *UNUSED(unused))
SpaceFile *sfile = CTX_wm_space_file(C);
struct FSMenu *fsmenu = ED_fsmenu_get();
- ED_fileselect_clear(wm, CTX_data_scene(C), sfile);
+ ED_fileselect_clear(wm, sfile);
/* refresh system directory menu */
fsmenu_refresh_system_category(fsmenu);
@@ -2360,7 +2360,7 @@ static int file_directory_new_exec(bContext *C, wmOperator *op)
sfile->scroll_offset = 0;
/* reload dir to make sure we're seeing what's in the directory */
- ED_fileselect_clear(wm, CTX_data_scene(C), sfile);
+ ED_fileselect_clear(wm, sfile);
if (do_diropen) {
BLI_strncpy(params->dir, path, sizeof(params->dir));
@@ -2611,7 +2611,7 @@ static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused))
if (params) {
params->flag ^= FILE_HIDE_DOT;
- ED_fileselect_clear(wm, CTX_data_scene(C), sfile);
+ ED_fileselect_clear(wm, sfile);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
}
@@ -2908,7 +2908,7 @@ static int file_delete_exec(bContext *C, wmOperator *op)
}
}
- ED_fileselect_clear(wm, CTX_data_scene(C), sfile);
+ ED_fileselect_clear(wm, sfile);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index afa85d183d8..7032d55b331 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -72,7 +72,7 @@ static void file_panel_operator(const bContext *C, Panel *panel)
UI_block_func_set(uiLayoutGetBlock(panel->layout), file_draw_check_cb, NULL, NULL);
- /* Hack: temporary hide.*/
+ /* Hack: temporary hide. */
const char *hide[] = {"filepath", "files", "directory", "filename"};
for (int i = 0; i < ARRAY_SIZE(hide); i++) {
PropertyRNA *prop = RNA_struct_find_property(op->ptr, hide[i]);
@@ -84,7 +84,7 @@ static void file_panel_operator(const bContext *C, Panel *panel)
uiTemplateOperatorPropertyButs(
C, panel->layout, op, UI_BUT_LABEL_ALIGN_NONE, UI_TEMPLATE_OP_PROPS_SHOW_EMPTY);
- /* Hack: temporary hide.*/
+ /* Hack: temporary hide. */
for (int i = 0; i < ARRAY_SIZE(hide); i++) {
PropertyRNA *prop = RNA_struct_find_property(op->ptr, hide[i]);
if (prop) {
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 37a32164cfc..b81605d6379 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -263,8 +263,7 @@ ListBase folder_history_list_duplicate(ListBase *listbase)
typedef struct FileListInternEntry {
struct FileListInternEntry *next, *prev;
- /** ASSET_UUID_LENGTH */
- char uuid[16];
+ FileUID uid;
/** eFileSel_File_Types */
int typeflag;
@@ -306,7 +305,7 @@ typedef struct FileListIntern {
ListBase entries;
FileListInternEntry **filtered;
- char curr_uuid[16]; /* Used to generate uuid during internal listing. */
+ FileUID curr_uid; /* Used to generate UID during internal listing. */
} FileListIntern;
#define FILELIST_ENTRYCACHESIZE_DEFAULT 1024 /* Keep it a power of two! */
@@ -329,8 +328,8 @@ typedef struct FileListEntryCache {
int *misc_entries_indices;
GHash *misc_entries;
- /* Allows to quickly get a cached entry from its UUID. */
- GHash *uuids;
+ /* Allows to quickly get a cached entry from its UID. */
+ GHash *uids;
/* Previews handling. */
TaskPool *previews_pool;
@@ -785,12 +784,12 @@ static bool is_filtered_hidden(const char *filename,
const FileListInternEntry *file)
{
if ((filename[0] == '.') && (filename[1] == '\0')) {
- return true; /* Ignore . */
+ return true; /* Ignore. */
}
if (filter->flags & FLF_HIDE_PARENT) {
if (filename[0] == '.' && filename[1] == '.' && filename[2] == '\0') {
- return true; /* Ignore .. */
+ return true; /* Ignore. */
}
}
@@ -1191,7 +1190,7 @@ static int filelist_geticon_ex(const FileDirEntry *file,
if (FILENAME_IS_PARENT(file->relpath)) {
return is_main ? ICON_FILE_PARENT : ICON_NONE;
}
- if (typeflag & FILE_TYPE_APPLICATIONBUNDLE) {
+ if (typeflag & FILE_TYPE_BUNDLE) {
return ICON_UGLYPACKAGE;
}
if (typeflag & FILE_TYPE_BLENDER) {
@@ -1383,40 +1382,6 @@ static void filelist_entry_clear(FileDirEntry *entry)
BKE_icon_delete(entry->preview_icon_id);
entry->preview_icon_id = 0;
}
- /* For now, consider FileDirEntryRevision::poin as not owned here,
- * so no need to do anything about it */
-
- if (!BLI_listbase_is_empty(&entry->variants)) {
- FileDirEntryVariant *var;
-
- for (var = entry->variants.first; var; var = var->next) {
- if (var->name) {
- MEM_freeN(var->name);
- }
- if (var->description) {
- MEM_freeN(var->description);
- }
-
- if (!BLI_listbase_is_empty(&var->revisions)) {
- FileDirEntryRevision *rev;
-
- for (rev = var->revisions.first; rev; rev = rev->next) {
- if (rev->comment) {
- MEM_freeN(rev->comment);
- }
- }
-
- BLI_freelistN(&var->revisions);
- }
- }
-
- /* TODO: tags! */
-
- BLI_freelistN(&entry->variants);
- }
- else if (entry->entry) {
- MEM_freeN(entry->entry);
- }
}
static void filelist_entry_free(FileDirEntry *entry)
@@ -1662,9 +1627,8 @@ static void filelist_cache_init(FileListEntryCache *cache, size_t cache_size)
copy_vn_i(cache->misc_entries_indices, cache_size, -1);
cache->misc_cursor = 0;
- /* XXX This assumes uint is 32 bits and uuid is 128 bits (char[16]), be careful! */
- cache->uuids = BLI_ghash_new_ex(
- BLI_ghashutil_uinthash_v4_p, BLI_ghashutil_uinthash_v4_cmp, __func__, cache_size * 2);
+ cache->uids = BLI_ghash_new_ex(
+ BLI_ghashutil_inthash_p, BLI_ghashutil_intcmp, __func__, cache_size * 2);
cache->size = cache_size;
cache->flags = FLC_IS_INIT;
@@ -1688,7 +1652,7 @@ static void filelist_cache_free(FileListEntryCache *cache)
BLI_ghash_free(cache->misc_entries, NULL, NULL);
MEM_freeN(cache->misc_entries_indices);
- BLI_ghash_free(cache->uuids, NULL, NULL);
+ BLI_ghash_free(cache->uids, NULL, NULL);
for (entry = cache->cached_entries.first; entry; entry = entry_next) {
entry_next = entry->next;
@@ -1721,7 +1685,7 @@ static void filelist_cache_clear(FileListEntryCache *cache, size_t new_size)
}
copy_vn_i(cache->misc_entries_indices, new_size, -1);
- BLI_ghash_clear_ex(cache->uuids, NULL, NULL, new_size * 2);
+ BLI_ghash_clear_ex(cache->uids, NULL, NULL, new_size * 2);
cache->size = new_size;
@@ -1738,8 +1702,7 @@ FileList *filelist_new(short type)
filelist_cache_init(&p->filelist_cache, FILELIST_ENTRYCACHESIZE_DEFAULT);
- p->selection_state = BLI_ghash_new(
- BLI_ghashutil_uinthash_v4_p, BLI_ghashutil_uinthash_v4_cmp, __func__);
+ p->selection_state = BLI_ghash_new(BLI_ghashutil_inthash_p, BLI_ghashutil_intcmp, __func__);
p->filelist.nbr_entries = FILEDIR_NBR_ENTRIES_UNSET;
filelist_settype(p, type);
@@ -1798,7 +1761,7 @@ void filelist_clear_ex(struct FileList *filelist, const bool do_cache, const boo
filelist_direntryarr_free(&filelist->filelist);
if (do_selection && filelist->selection_state) {
- BLI_ghash_clear(filelist->selection_state, MEM_freeN, NULL);
+ BLI_ghash_clear(filelist->selection_state, NULL, NULL);
}
}
@@ -1819,7 +1782,7 @@ void filelist_free(struct FileList *filelist)
filelist_cache_free(&filelist->filelist_cache);
if (filelist->selection_state) {
- BLI_ghash_free(filelist->selection_state, MEM_freeN, NULL);
+ BLI_ghash_free(filelist->selection_state, NULL, NULL);
filelist->selection_state = NULL;
}
@@ -1957,16 +1920,12 @@ static FileDirEntry *filelist_file_create_entry(FileList *filelist, const int in
FileListInternEntry *entry = filelist->filelist_intern.filtered[index];
FileListEntryCache *cache = &filelist->filelist_cache;
FileDirEntry *ret;
- FileDirEntryRevision *rev;
ret = MEM_callocN(sizeof(*ret), __func__);
- rev = MEM_callocN(sizeof(*rev), __func__);
- rev->size = (uint64_t)entry->st.st_size;
+ ret->size = (uint64_t)entry->st.st_size;
+ ret->time = (int64_t)entry->st.st_mtime;
- rev->time = (int64_t)entry->st.st_mtime;
-
- ret->entry = rev;
ret->relpath = BLI_strdup(entry->relpath);
if (entry->free_name) {
ret->name = BLI_strdup(entry->name);
@@ -1976,7 +1935,7 @@ static FileDirEntry *filelist_file_create_entry(FileList *filelist, const int in
ret->name = entry->name;
}
ret->description = BLI_strdupcat(filelist->filelist.root, entry->relpath);
- memcpy(ret->uuid, entry->uuid, sizeof(ret->uuid));
+ ret->uid = entry->uid;
ret->blentype = entry->blentype;
ret->typeflag = entry->typeflag;
ret->attributes = entry->attributes;
@@ -2034,11 +1993,11 @@ FileDirEntry *filelist_file_ex(struct FileList *filelist, const int index, const
ret = filelist_file_create_entry(filelist, index);
old_index = cache->misc_entries_indices[cache->misc_cursor];
if ((old = BLI_ghash_popkey(cache->misc_entries, POINTER_FROM_INT(old_index), NULL))) {
- BLI_ghash_remove(cache->uuids, old->uuid, NULL, NULL);
+ BLI_ghash_remove(cache->uids, POINTER_FROM_UINT(old->uid), NULL, NULL);
filelist_file_release_entry(filelist, old);
}
BLI_ghash_insert(cache->misc_entries, POINTER_FROM_INT(index), ret);
- BLI_ghash_insert(cache->uuids, ret->uuid, ret);
+ BLI_ghash_insert(cache->uids, POINTER_FROM_UINT(ret->uid), ret);
cache->misc_entries_indices[cache->misc_cursor] = index;
cache->misc_cursor = (cache->misc_cursor + 1) % cache_size;
@@ -2087,33 +2046,31 @@ ID *filelist_file_get_id(const FileDirEntry *file)
return file->id;
}
-FileDirEntry *filelist_entry_find_uuid(struct FileList *filelist, const int uuid[4])
-{
- if (filelist->filelist.nbr_entries_filtered == FILEDIR_NBR_ENTRIES_UNSET) {
- return NULL;
- }
+#define FILE_UID_UNSET 0
- if (filelist->filelist_cache.uuids) {
- FileDirEntry *entry = BLI_ghash_lookup(filelist->filelist_cache.uuids, uuid);
- if (entry) {
- return entry;
- }
- }
-
- {
- int fidx;
+static FileUID filelist_uid_generate(FileList *filelist)
+{
+ /* Using an atomic operation to avoid having to lock thread...
+ * Note that we do not really need this here currently, since there is a single listing thread,
+ * but better remain consistent about threading! */
+ return atomic_add_and_fetch_uint32(&filelist->filelist_intern.curr_uid, 1);
+}
- for (fidx = 0; fidx < filelist->filelist.nbr_entries_filtered; fidx++) {
- FileListInternEntry *entry = filelist->filelist_intern.filtered[fidx];
- if (memcmp(entry->uuid, uuid, sizeof(entry->uuid)) == 0) {
- return filelist_file(filelist, fidx);
- }
- }
- }
+bool filelist_uid_is_set(const FileUID uid)
+{
+ FileUID unset_uid;
+ filelist_uid_unset(&unset_uid);
+ return unset_uid != uid;
+}
- return NULL;
+void filelist_uid_unset(FileUID *r_uid)
+{
+ *r_uid = FILE_UID_UNSET;
}
+/**
+ * \warning: The UID will only be valid for the current session. Use as runtime data only!
+ */
void filelist_file_cache_slidingwindow_set(FileList *filelist, size_t window_size)
{
/* Always keep it power of 2, in [256, 8192] range for now,
@@ -2147,7 +2104,7 @@ static bool filelist_file_cache_block_create(FileList *filelist,
/* That entry might have already been requested and stored in misc cache... */
if ((entry = BLI_ghash_popkey(cache->misc_entries, POINTER_FROM_INT(idx), NULL)) == NULL) {
entry = filelist_file_create_entry(filelist, idx);
- BLI_ghash_insert(cache->uuids, entry->uuid, entry);
+ BLI_ghash_insert(cache->uids, POINTER_FROM_UINT(entry->uid), entry);
}
cache->block_entries[cursor] = entry;
}
@@ -2173,7 +2130,7 @@ static void filelist_file_cache_block_release(struct FileList *filelist,
__func__,
cursor /*, cache->block_entries[cursor], cache->block_entries[cursor]->relpath*/);
#endif
- BLI_ghash_remove(cache->uuids, entry->uuid, NULL, NULL);
+ BLI_ghash_remove(cache->uids, POINTER_FROM_UINT(entry->uid), NULL, NULL);
filelist_file_release_entry(filelist, entry);
#ifndef NDEBUG
cache->block_entries[cursor] = NULL;
@@ -2519,9 +2476,16 @@ int ED_path_extension_type(const char *path)
if (file_is_blend_backup(path)) {
return FILE_TYPE_BLENDER_BACKUP;
}
- if (BLI_path_extension_check(path, ".app")) {
- return FILE_TYPE_APPLICATIONBUNDLE;
+#ifdef __APPLE__
+ if (BLI_path_extension_check_n(path,
+ /* Application bundle */
+ ".app",
+ /* Safari in-progress/paused download */
+ ".download",
+ NULL)) {
+ return FILE_TYPE_BUNDLE;
}
+#endif
if (BLI_path_extension_check(path, ".py")) {
return FILE_TYPE_PYSCRIPT;
}
@@ -2628,7 +2592,7 @@ uint filelist_entry_select_set(const FileList *filelist,
FileCheckType check)
{
/* Default NULL pointer if not found is fine here! */
- void **es_p = BLI_ghash_lookup_p(filelist->selection_state, entry->uuid);
+ void **es_p = BLI_ghash_lookup_p(filelist->selection_state, POINTER_FROM_UINT(entry->uid));
uint entry_flag = es_p ? POINTER_AS_UINT(*es_p) : 0;
const uint org_entry_flag = entry_flag;
@@ -2656,13 +2620,12 @@ uint filelist_entry_select_set(const FileList *filelist,
*es_p = POINTER_FROM_UINT(entry_flag);
}
else {
- BLI_ghash_remove(filelist->selection_state, entry->uuid, MEM_freeN, NULL);
+ BLI_ghash_remove(filelist->selection_state, POINTER_FROM_UINT(entry->uid), NULL, NULL);
}
}
else if (entry_flag) {
- void *key = MEM_mallocN(sizeof(entry->uuid), __func__);
- memcpy(key, entry->uuid, sizeof(entry->uuid));
- BLI_ghash_insert(filelist->selection_state, key, POINTER_FROM_UINT(entry_flag));
+ BLI_ghash_insert(
+ filelist->selection_state, POINTER_FROM_UINT(entry->uid), POINTER_FROM_UINT(entry_flag));
}
}
@@ -2700,7 +2663,8 @@ uint filelist_entry_select_get(FileList *filelist, FileDirEntry *entry, FileChec
if (((check == CHECK_ALL)) || ((check == CHECK_DIRS) && (entry->typeflag & FILE_TYPE_DIR)) ||
((check == CHECK_FILES) && !(entry->typeflag & FILE_TYPE_DIR))) {
/* Default NULL pointer if not found is fine here! */
- return POINTER_AS_UINT(BLI_ghash_lookup(filelist->selection_state, entry->uuid));
+ return POINTER_AS_UINT(
+ BLI_ghash_lookup(filelist->selection_state, POINTER_FROM_UINT(entry->uid)));
}
return 0;
@@ -2725,7 +2689,7 @@ bool filelist_entry_is_selected(FileList *filelist, const int index)
/* BLI_ghash_lookup returns NULL if not found, which gets mapped to 0, which gets mapped to
* "not selected". */
const uint selection_state = POINTER_AS_UINT(
- BLI_ghash_lookup(filelist->selection_state, intern_entry->uuid));
+ BLI_ghash_lookup(filelist->selection_state, POINTER_FROM_UINT(intern_entry->uid)));
return selection_state != 0;
}
@@ -2815,7 +2779,7 @@ static int filelist_readjob_list_dir(const char *root,
entry->attributes = BLI_file_attributes(full_path);
if (S_ISDIR(files[i].s.st_mode)
#ifdef __APPLE__
- && !(ED_path_extension_type(full_path) & FILE_TYPE_APPLICATIONBUNDLE)
+ && !(ED_path_extension_type(full_path) & FILE_TYPE_BUNDLE)
#endif
) {
entry->typeflag = FILE_TYPE_DIR;
@@ -2894,7 +2858,8 @@ static int filelist_readjob_list_lib(const char *root, ListBase *entries, const
}
/* there we go */
- libfiledata = BLO_blendhandle_from_file(dir, NULL);
+ BlendFileReadReport bf_reports = {.reports = NULL};
+ libfiledata = BLO_blendhandle_from_file(dir, &bf_reports);
if (libfiledata == NULL) {
return nbr_entries;
}
@@ -3194,14 +3159,7 @@ static void filelist_readjob_do(const bool do_lib,
for (entry = entries.first; entry; entry = entry->next) {
BLI_join_dirfile(dir, sizeof(dir), rel_subdir, entry->relpath);
- /* Generate our entry uuid. Abusing uuid as an uint32, shall be more than enough here,
- * things would crash way before we overflow that counter!
- * Using an atomic operation to avoid having to lock thread...
- * Note that we do not really need this here currently,
- * since there is a single listing thread, but better
- * remain consistent about threading! */
- *((uint32_t *)entry->uuid) = atomic_add_and_fetch_uint32(
- (uint32_t *)filelist->filelist_intern.curr_uuid, 1);
+ entry->uid = filelist_uid_generate(filelist);
/* Only thing we change in direntry here, so we need to free it first. */
MEM_freeN(entry->relpath);
@@ -3326,8 +3284,7 @@ static void filelist_readjob_main_assets(Main *current_main,
entry->free_name = false;
entry->typeflag |= FILE_TYPE_BLENDERLIB | FILE_TYPE_ASSET;
entry->blentype = GS(id_iter->name);
- *((uint32_t *)entry->uuid) = atomic_add_and_fetch_uint32(
- (uint32_t *)filelist->filelist_intern.curr_uuid, 1);
+ entry->uid = filelist_uid_generate(filelist);
entry->local_data.preview_image = BKE_asset_metadata_preview_get_from_id(id_iter->asset_data,
id_iter);
entry->local_data.id = id_iter;
@@ -3373,9 +3330,7 @@ static void filelist_readjob_startjob(void *flrjv, short *stop, short *do_update
flrj->tmp_filelist->filelist_intern.filtered = NULL;
BLI_listbase_clear(&flrj->tmp_filelist->filelist_intern.entries);
- memset(flrj->tmp_filelist->filelist_intern.curr_uuid,
- 0,
- sizeof(flrj->tmp_filelist->filelist_intern.curr_uuid));
+ filelist_uid_unset(&flrj->tmp_filelist->filelist_intern.curr_uid);
flrj->tmp_filelist->libfiledata = NULL;
memset(&flrj->tmp_filelist->filelist_cache, 0, sizeof(flrj->tmp_filelist->filelist_cache));
@@ -3415,7 +3370,7 @@ static void filelist_readjob_update(void *flrjv)
BLI_mutex_unlock(&flrj->lock);
if (new_nbr_entries) {
- /* Do not clear selection cache, we can assume already 'selected' uuids are still valid! */
+ /* Do not clear selection cache, we can assume already 'selected' UIDs are still valid! */
filelist_clear_ex(flrj->filelist, true, false);
flrj->filelist->flags |= (FL_NEED_SORTING | FL_NEED_FILTERING);
@@ -3497,7 +3452,7 @@ void filelist_readjob_start(FileList *filelist, const bContext *C)
/* setup job */
wm_job = WM_jobs_get(CTX_wm_manager(C),
CTX_wm_window(C),
- CTX_data_scene(C),
+ filelist,
"Listing Dirs...",
WM_JOB_PROGRESS,
WM_JOB_TYPE_FILESEL_READDIR);
@@ -3513,12 +3468,12 @@ void filelist_readjob_start(FileList *filelist, const bContext *C)
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
-void filelist_readjob_stop(wmWindowManager *wm, Scene *owner_scene)
+void filelist_readjob_stop(FileList *filelist, wmWindowManager *wm)
{
- WM_jobs_kill_type(wm, owner_scene, WM_JOB_TYPE_FILESEL_READDIR);
+ WM_jobs_kill_type(wm, filelist, WM_JOB_TYPE_FILESEL_READDIR);
}
-int filelist_readjob_running(wmWindowManager *wm, Scene *owner_scene)
+int filelist_readjob_running(FileList *filelist, wmWindowManager *wm)
{
- return WM_jobs_test(wm, owner_scene, WM_JOB_TYPE_FILESEL_READDIR);
+ return WM_jobs_test(wm, filelist, WM_JOB_TYPE_FILESEL_READDIR);
}
diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h
index 9eb70dd8437..e6c4b8e1a07 100644
--- a/source/blender/editors/space_file/filelist.h
+++ b/source/blender/editors/space_file/filelist.h
@@ -35,6 +35,8 @@ struct wmWindowManager;
struct FileDirEntry;
+typedef uint32_t FileUID;
+
typedef enum FileSelType {
FILE_SEL_REMOVE = 0,
FILE_SEL_ADD = 1,
@@ -97,7 +99,8 @@ FileDirEntry *filelist_file_ex(struct FileList *filelist, int index, bool use_re
int filelist_file_findpath(struct FileList *filelist, const char *file);
struct ID *filelist_file_get_id(const struct FileDirEntry *file);
-FileDirEntry *filelist_entry_find_uuid(struct FileList *filelist, const int uuid[4]);
+bool filelist_uid_is_set(const FileUID uid);
+void filelist_uid_unset(FileUID *r_uid);
void filelist_file_cache_slidingwindow_set(struct FileList *filelist, size_t window_size);
bool filelist_file_cache_block(struct FileList *filelist, const int index);
@@ -141,8 +144,8 @@ bool filelist_islibrary(struct FileList *filelist, char *dir, char **r_group);
void filelist_freelib(struct FileList *filelist);
void filelist_readjob_start(struct FileList *filelist, const struct bContext *C);
-void filelist_readjob_stop(struct wmWindowManager *wm, struct Scene *owner_scene);
-int filelist_readjob_running(struct wmWindowManager *wm, struct Scene *owner_scene);
+void filelist_readjob_stop(struct FileList *filelist, struct wmWindowManager *wm);
+int filelist_readjob_running(struct FileList *filelist, struct wmWindowManager *wm);
bool filelist_cache_previews_update(struct FileList *filelist);
void filelist_cache_previews_set(struct FileList *filelist, const bool use_previews);
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 8e3fc36aa71..aec42701f12 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -1047,7 +1047,7 @@ FileLayout *ED_fileselect_get_layout(struct SpaceFile *sfile, ARegion *region)
* Support updating the directory even when this isn't the active space
* needed so RNA properties update function isn't context sensitive, see T70255.
*/
-void ED_file_change_dir_ex(bContext *C, bScreen *screen, ScrArea *area)
+void ED_file_change_dir_ex(bContext *C, ScrArea *area)
{
/* May happen when manipulating non-active spaces. */
if (UNLIKELY(area->spacetype != SPACE_FILE)) {
@@ -1057,10 +1057,7 @@ void ED_file_change_dir_ex(bContext *C, bScreen *screen, ScrArea *area)
FileSelectParams *params = ED_fileselect_get_active_params(sfile);
if (params) {
wmWindowManager *wm = CTX_wm_manager(C);
- Scene *scene = WM_windows_scene_get_from_screen(wm, screen);
- if (LIKELY(scene != NULL)) {
- ED_fileselect_clear(wm, scene, sfile);
- }
+ ED_fileselect_clear(wm, sfile);
/* Clear search string, it is very rare to want to keep that filter while changing dir,
* and usually very annoying to keep it actually! */
@@ -1085,9 +1082,8 @@ void ED_file_change_dir_ex(bContext *C, bScreen *screen, ScrArea *area)
void ED_file_change_dir(bContext *C)
{
- bScreen *screen = CTX_wm_screen(C);
ScrArea *area = CTX_wm_area(C);
- ED_file_change_dir_ex(C, screen, area);
+ ED_file_change_dir_ex(C, area);
}
int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matched_file)
@@ -1183,11 +1179,11 @@ int autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v))
return match;
}
-void ED_fileselect_clear(wmWindowManager *wm, Scene *owner_scene, SpaceFile *sfile)
+void ED_fileselect_clear(wmWindowManager *wm, SpaceFile *sfile)
{
/* only NULL in rare cases - T29734. */
if (sfile->files) {
- filelist_readjob_stop(wm, owner_scene);
+ filelist_readjob_stop(sfile->files, wm);
filelist_freelib(sfile->files);
filelist_clear(sfile->files);
}
@@ -1197,7 +1193,7 @@ void ED_fileselect_clear(wmWindowManager *wm, Scene *owner_scene, SpaceFile *sfi
WM_main_add_notifier(NC_SPACE | ND_SPACE_FILE_LIST, NULL);
}
-void ED_fileselect_exit(wmWindowManager *wm, Scene *owner_scene, SpaceFile *sfile)
+void ED_fileselect_exit(wmWindowManager *wm, SpaceFile *sfile)
{
if (!sfile) {
return;
@@ -1224,7 +1220,7 @@ void ED_fileselect_exit(wmWindowManager *wm, Scene *owner_scene, SpaceFile *sfil
folder_history_list_free(sfile);
if (sfile->files) {
- ED_fileselect_clear(wm, owner_scene, sfile);
+ ED_fileselect_clear(wm, sfile);
filelist_free(sfile->files);
MEM_freeN(sfile->files);
sfile->files = NULL;
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 0418bb87768..717d28f93dc 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -206,7 +206,7 @@ static void file_exit(wmWindowManager *wm, ScrArea *area)
sfile->previews_timer = NULL;
}
- ED_fileselect_exit(wm, NULL, sfile);
+ ED_fileselect_exit(wm, sfile);
}
static SpaceLink *file_duplicate(SpaceLink *sl)
@@ -360,7 +360,7 @@ static void file_refresh(const bContext *C, ScrArea *area)
sfile->recentnr = fsmenu_get_active_indices(fsmenu, FS_CATEGORY_RECENT, params->dir);
if (filelist_needs_force_reset(sfile->files)) {
- filelist_readjob_stop(wm, CTX_data_scene(C));
+ filelist_readjob_stop(sfile->files, wm);
filelist_clear(sfile->files);
}
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index c5358cdfa5b..0d2a436902a 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -1251,7 +1251,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
float x = driver->curval;
float y = fcu->curval * unitfac;
- /* only draw indicators if the point is in range*/
+ /* Only draw indicators if the point is in range. */
if (x >= v2d->cur.xmin) {
float co[2];
@@ -1428,7 +1428,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
height = ACHANNEL_TOT_HEIGHT(ac, items);
v2d->tot.ymin = -height;
- /* loop through channels, and set up drawing depending on their type */
+ /* 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);
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index a2e812a4ed1..be577e9ab13 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -3007,7 +3007,7 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op)
WM_report(RPT_INFO, "No drivers deleted");
}
- /* Successful or not?*/
+ /* Successful or not? */
if (!ok) {
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 50d14d18be9..2f4e1c1abbe 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -597,7 +597,7 @@ static bool box_select_graphkeys(bAnimContext *ac,
initialize_box_select_key_editing_data(
sipo, incl_handles, mode, ac, data, &scaled_rectf, &ked, &mapping_flag);
- /* Get beztriple editing/validation funcs. */
+ /* Get beztriple editing/validation funcs. */
const KeyframeEditFunc select_cb = ANIM_editkeyframes_select(selectmode);
const KeyframeEditFunc ok_cb = ANIM_editkeyframes_ok(mode);
@@ -1611,7 +1611,7 @@ void GRAPH_OT_select_leftright(wmOperatorType *ot)
ot->idname = "GRAPH_OT_select_leftright";
ot->description = "Select keyframes to the left or the right of the current frame";
- /* api callbacks */
+ /* api callbacks */
ot->invoke = graphkeys_select_leftright_invoke;
ot->exec = graphkeys_select_leftright_exec;
ot->poll = graphop_visible_keyframes_poll;
@@ -1681,10 +1681,8 @@ static int mouse_graph_keys(bAnimContext *ac,
/* deselect all other keyframes (+ F-Curves too) */
deselect_graph_keys(ac, 0, SELECT_SUBTRACT, true);
- /* deselect other channels too, but only only do this if
- * selection of channel when the visibility of keyframes
- * doesn't depend on this
- */
+ /* Deselect other channels too, but only do this if selection of channel
+ * when the visibility of keyframes doesn't depend on this. */
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
}
diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c
index 4174e1c63ae..10629caa8b0 100644
--- a/source/blender/editors/space_graph/graph_slider_ops.c
+++ b/source/blender/editors/space_graph/graph_slider_ops.c
@@ -50,7 +50,7 @@
/* ******************** GRAPH SLIDER OPERATORS ************************* */
/* This file contains a collection of operators to modify keyframes in the graph editor. All
* operators are modal and use a slider that allows the user to define a percentage to modify the
- * operator.*/
+ * operator. */
/* ******************** Decimate Keyframes Operator ************************* */
@@ -91,7 +91,7 @@ typedef struct tDecimateGraphOp {
/** A 0-1 value for determining how much we should decimate. */
PropertyRNA *percentage_prop;
- /** The original bezt curve data (used for restoring fcurves).*/
+ /** The original bezt curve data (used for restoring fcurves). */
ListBase bezt_arr_list;
NumInput num;
@@ -318,7 +318,7 @@ static int graphkeys_decimate_modal(bContext *C, wmOperator *op, const wmEvent *
/* This assumes that we are in "DECIM_RATIO" mode. This is because the error margin is very hard
* and finicky to control with this modal mouse grab method. Therefore, it is expected that the
* error margin mode is not adjusted by the modal operator but instead tweaked via the redo
- * panel.*/
+ * panel. */
tDecimateGraphOp *dgo = op->customdata;
const bool has_numinput = hasNumInput(&dgo->num);
diff --git a/source/blender/editors/space_graph/graph_view.c b/source/blender/editors/space_graph/graph_view.c
index cde0dab3503..ca14f7c5942 100644
--- a/source/blender/editors/space_graph/graph_view.c
+++ b/source/blender/editors/space_graph/graph_view.c
@@ -137,7 +137,7 @@ void get_graph_keyframe_extents(bAnimContext *ac,
}
}
- /* Ensure that the extents are not too extreme that view implodes...*/
+ /* Ensure that the extents are not too extreme that view implodes. */
if (foundBounds) {
if ((xmin && xmax) && (fabsf(*xmax - *xmin) < 0.001f)) {
*xmin -= 0.0005f;
@@ -269,7 +269,7 @@ static int graphkeys_viewall(bContext *C,
BLI_rctf_scale(&cur_new, 1.1f);
/* Take regions into account, that could block the view.
- * Marker region is supposed to be larger than the scroll-bar, so prioritize it.*/
+ * Marker region is supposed to be larger than the scroll-bar, so prioritize it. */
float pad_top = UI_TIME_SCRUB_MARGIN_Y;
float pad_bottom = BLI_listbase_is_empty(ED_context_get_markers(C)) ? V2D_SCROLL_HANDLE_HEIGHT :
UI_MARKER_MARGIN_Y;
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 0c6d904de01..32496cb8f1f 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -588,7 +588,7 @@ static void graph_listener(const wmSpaceTypeListenerParams *params)
ED_area_tag_refresh(area);
break;
case ND_TRANSFORM:
- break; /*do nothing*/
+ break; /* Do nothing. */
default: /* just redrawing the view will do */
ED_area_tag_redraw(area);
@@ -759,7 +759,7 @@ static void graph_refresh(const bContext *C, ScrArea *area)
break;
}
- case SIPO_MODE_DRIVERS: /* drivers only */
+ case SIPO_MODE_DRIVERS: /* Drivers only. */
{
break;
}
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 9e2bd1448b2..193c35d10a2 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -3870,7 +3870,7 @@ static void tile_fill_init(PointerRNA *ptr, Image *ima, ImageTile *tile)
/* Acquire ibuf to get the default values.
* If the specified tile has no ibuf, try acquiring the main tile instead
- * (unless the specified tile already was the main tile).*/
+ * (unless the specified tile already was the main tile). */
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
if (ibuf == NULL && (tile != NULL) && (tile->tile_number != 1001)) {
ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
diff --git a/source/blender/editors/space_image/image_undo.c b/source/blender/editors/space_image/image_undo.c
index 09e30298e79..082f66b57af 100644
--- a/source/blender/editors/space_image/image_undo.c
+++ b/source/blender/editors/space_image/image_undo.c
@@ -1041,7 +1041,7 @@ ListBase *ED_image_paint_tile_list_get(void)
return &us->paint_tiles;
}
-/* restore painting image to previous state. Used for anchored and drag-dot style brushes*/
+/* Restore painting image to previous state. Used for anchored and drag-dot style brushes. */
void ED_image_undo_restore(UndoStep *us)
{
ListBase *paint_tiles = &((ImageUndoStep *)us)->paint_tiles;
diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c
index 7dd8382c8ef..a3da50709df 100644
--- a/source/blender/editors/space_info/info_report.c
+++ b/source/blender/editors/space_info/info_report.c
@@ -360,7 +360,7 @@ void INFO_OT_report_delete(wmOperatorType *ot)
ot->exec = report_delete_exec;
/* flags */
- /*ot->flag = OPTYPE_REGISTER;*/
+ // ot->flag = OPTYPE_REGISTER;
/* properties */
}
@@ -404,7 +404,7 @@ void INFO_OT_report_copy(wmOperatorType *ot)
ot->exec = report_copy_exec;
/* flags */
- /*ot->flag = OPTYPE_REGISTER;*/
+ // ot->flag = OPTYPE_REGISTER;
/* properties */
}
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index 50eb96824d7..706d52f43b2 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -96,7 +96,7 @@ typedef struct SceneStatsFmt {
char totgpstroke[MAX_INFO_NUM_LEN], totgppoint[MAX_INFO_NUM_LEN];
} SceneStatsFmt;
-static bool stats_mesheval(Mesh *me_eval, bool is_selected, SceneStats *stats)
+static bool stats_mesheval(const Mesh *me_eval, bool is_selected, SceneStats *stats)
{
if (me_eval == NULL) {
return false;
@@ -149,8 +149,8 @@ static void stats_object(Object *ob,
switch (ob->type) {
case OB_MESH: {
/* we assume evaluated mesh is already built, this strictly does stats now. */
- Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
- if (!BLI_gset_add(objects_gset, me_eval)) {
+ const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
+ if (!BLI_gset_add(objects_gset, (void *)me_eval)) {
break;
}
stats_mesheval(me_eval, is_selected, stats);
@@ -165,8 +165,8 @@ static void stats_object(Object *ob,
case OB_SURF:
case OB_CURVE:
case OB_FONT: {
- Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
- if ((me_eval != NULL) && !BLI_gset_add(objects_gset, me_eval)) {
+ const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
+ if ((me_eval != NULL) && !BLI_gset_add(objects_gset, (void *)me_eval)) {
break;
}
@@ -494,7 +494,7 @@ static bool format_stats(
/* Create stats if they don't already exist. */
SceneStats **stats_p = (v3d_local) ? &v3d_local->runtime.local_stats : &view_layer->stats;
if (*stats_p == NULL) {
- /* Do not not access dependency graph if interface is marked as locked. */
+ /* Don't access dependency graph if interface is marked as locked. */
wmWindowManager *wm = bmain->wm.first;
if (wm->is_interface_locked) {
return false;
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 7d4011e0812..0fd1a1318e8 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -734,7 +734,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region)
int height = NLACHANNEL_TOT_HEIGHT(ac, items);
v2d->tot.ymin = -height;
- /* loop through channels, and set up drawing depending on their type */
+ /* Loop through channels, and set up drawing depending on their type. */
float ymax = NLACHANNEL_FIRST_TOP(ac);
for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next, ymax -= NLACHANNEL_STEP(snla)) {
@@ -894,7 +894,7 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *region)
/* set blending again, as may not be set in previous step */
GPU_blend(GPU_BLEND_ALPHA);
- /* loop through channels, and set up drawing depending on their type */
+ /* Loop through channels, and set up drawing depending on their type. */
for (ale = anim_data.first; ale;
ale = ale->next, ymax -= NLACHANNEL_STEP(snla), channel_index++) {
float ymin = ymax - NLACHANNEL_HEIGHT(snla);
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index dd381cc92fb..3ca3aa15cd3 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -1397,7 +1397,7 @@ static void nlaedit_split_strip_actclip(
nstrip->start = splitframe;
if ((splitaframe > strip->actstart) && (splitaframe < strip->actend)) {
- /* only do this if we're splitting down the middle... */
+ /* only do this if we're splitting down the middle... */
strip->actend = splitaframe;
nstrip->actstart = splitaframe;
}
@@ -1412,7 +1412,7 @@ static void nlaedit_split_strip_actclip(
/* split a given Meta strip */
static void nlaedit_split_strip_meta(NlaTrack *nlt, NlaStrip *strip)
{
- /* simply ungroup it for now... */
+ /* simply ungroup it for now... */
BKE_nlastrips_clear_metastrip(&nlt->strips, strip);
}
@@ -1528,7 +1528,7 @@ static int nlaedit_toggle_mute_exec(bContext *C, wmOperator *UNUSED(op))
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
- /* for every selected strip, toggle muting */
+ /* For every selected strip, toggle muting. */
for (strip = nlt->strips.first; strip; strip = strip->next) {
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* just flip the mute flag for now */
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index 87ad09fe2f9..dc95a01a021 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -577,7 +577,7 @@ void NLA_OT_select_leftright(wmOperatorType *ot)
ot->idname = "NLA_OT_select_leftright";
ot->description = "Select strips to the left or the right of the current frame";
- /* api callbacks */
+ /* api callbacks */
ot->invoke = nlaedit_select_leftright_invoke;
ot->exec = nlaedit_select_leftright_exec;
ot->poll = ED_operator_nla_active;
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc
index 1d4c3b67387..1c7ee9e622f 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -135,7 +135,7 @@ static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA
static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
#if 0
- /* XXX no context access here .. */
+ /* XXX no context access here. */
bNode *node = (bNode*)ptr->data;
CurveMapping *cumap = node->storage;
@@ -217,7 +217,7 @@ static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA
uiItemR(layout, ptr, "texture", DEFAULT_FLAGS, "", ICON_NONE);
if (multi) {
- /* Number Drawing not optimal here, better have a list*/
+ /* Number Drawing not optimal here, better have a list. */
uiItemR(layout, ptr, "node_output", DEFAULT_FLAGS, "", ICON_NONE);
}
}
@@ -1833,9 +1833,11 @@ static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C
uiItemR(col, ptr, "threshold", DEFAULT_FLAGS, nullptr, ICON_NONE);
col = uiLayoutColumn(layout, true);
- /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); Removed for now */
+ /* Removed for now. */
+ // uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
uiItemR(col, ptr, "gain", DEFAULT_FLAGS | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
- /*uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); Removed for now*/
+ /* Removed for now. */
+ // uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
}
static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -3528,7 +3530,7 @@ static void std_node_socket_draw(
bNode *node = (bNode *)node_ptr->data;
bNodeSocket *sock = (bNodeSocket *)ptr->data;
int type = sock->typeinfo->type;
- /*int subtype = sock->typeinfo->subtype;*/
+ // int subtype = sock->typeinfo->subtype;
/* XXX not nice, eventually give this node its own socket type ... */
if (node->type == CMP_NODE_OUTPUT_FILE) {
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index 1dc8e1412af..c15cc4240a5 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -1285,7 +1285,7 @@ static void node_add_error_message_button(
0,
0,
nullptr);
- UI_but_func_tooltip_set(but, node_errors_tooltip_fn, storage_pointer_alloc);
+ UI_but_func_tooltip_set(but, node_errors_tooltip_fn, storage_pointer_alloc, MEM_freeN);
UI_block_emboss_set(node.block, UI_EMBOSS);
}
@@ -1766,7 +1766,7 @@ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node)
}
}
-static void count_mutli_input_socket_links(bNodeTree *ntree, SpaceNode *snode)
+static void count_multi_input_socket_links(bNodeTree *ntree, SpaceNode *snode)
{
Map<bNodeSocket *, int> counts;
LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
@@ -1800,7 +1800,7 @@ void node_update_nodetree(const bContext *C, bNodeTree *ntree)
SpaceNode *snode = CTX_wm_space_node(C);
ntreeTagUsedSockets(ntree);
- count_mutli_input_socket_links(ntree, snode);
+ count_multi_input_socket_links(ntree, snode);
/* Update nodes front to back, so children sizes get updated before parents. */
LISTBASE_FOREACH_BACKWARD (bNode *, node, &ntree->nodes) {
diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc
index b5ef250f5a9..0cf47ed35fa 100644
--- a/source/blender/editors/space_node/node_edit.cc
+++ b/source/blender/editors/space_node/node_edit.cc
@@ -1130,7 +1130,7 @@ static bool cursor_isect_multi_input_socket(const float cursor[2], const bNodeSo
{
const float node_socket_height = node_socket_calculate_height(socket);
rctf multi_socket_rect;
- /*.xmax = socket->locx + NODE_SOCKSIZE * 5.5f
+ /* `.xmax = socket->locx + NODE_SOCKSIZE * 5.5f`
* would be the same behavior as for regular sockets.
* But keep it smaller because for multi-input socket you
* sometimes want to drag the link to the other side, if you may
@@ -1357,9 +1357,9 @@ void NODE_OT_duplicate(wmOperatorType *ot)
ot->srna, "keep_inputs", false, "Keep Inputs", "Keep the input links to duplicated nodes");
}
-bool ED_node_select_check(ListBase *lb)
+bool ED_node_select_check(const ListBase *lb)
{
- LISTBASE_FOREACH (bNode *, node, lb) {
+ LISTBASE_FOREACH (const bNode *, node, lb) {
if (node->flag & NODE_SELECT) {
return true;
}
@@ -2310,7 +2310,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
sock = ntreeInsertSocketInterface(
ntree, in_out, active_sock->idname, active_sock->next, active_sock->name);
/* XXX this only works for actual sockets, not interface templates! */
- /*nodeSocketCopyValue(sock, &ntree_ptr, active_sock, &ntree_ptr);*/
+ // nodeSocketCopyValue(sock, &ntree_ptr, active_sock, &ntree_ptr);
}
else {
/* XXX TODO define default socket type for a tree! */
diff --git a/source/blender/editors/space_node/node_group.cc b/source/blender/editors/space_node/node_group.cc
index 851d386ad0d..d7541d8f512 100644
--- a/source/blender/editors/space_node/node_group.cc
+++ b/source/blender/editors/space_node/node_group.cc
@@ -926,7 +926,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
}
}
- /* expose all unlinked sockets too but only the visible ones*/
+ /* Expose all unlinked sockets too but only the visible ones. */
if (expose_visible) {
LISTBASE_FOREACH (bNode *, node, &ngroup->nodes) {
if (node_group_make_use_node(node, gnode)) {
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 328a787c768..69680f57d98 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1090,7 +1090,8 @@ static void outliner_draw_restrictbuts(uiBlock *block,
RestrictPropertiesActive props_active = props_active_parent;
if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) {
- if (tselem->type == TSE_R_LAYER && (space_outliner->outlinevis == SO_SCENES)) {
+ if (tselem->type == TSE_R_LAYER &&
+ ELEM(space_outliner->outlinevis, SO_SCENES, SO_VIEW_LAYER)) {
if (space_outliner->show_restrict_flags & SO_RESTRICT_RENDER) {
/* View layer render toggle. */
ViewLayer *layer = te->directdata;
@@ -2355,6 +2356,9 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
case eGpencilModifierType_Texture:
data.icon = ICON_TEXTURE;
break;
+ case eGpencilModifierType_Weight:
+ data.icon = ICON_MOD_VERTEX_WEIGHT;
+ break;
/* Default */
default:
@@ -3125,7 +3129,7 @@ static void outliner_draw_tree_element(bContext *C,
*te_edit = te;
}
- /* Icons can be ui buts, we don't want it to overlap with restrict .*/
+ /* Icons can be UI buts, we don't want it to overlap with restrict. */
if (restrict_column_width > 0) {
xmax -= restrict_column_width + UI_UNIT_X;
}
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 50f089f894a..b14a3cdb91d 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1816,7 +1816,7 @@ static TreeElement *outliner_find_rightmost_visible_child(SpaceOutliner *space_o
return te;
}
-/* Find previous visible element in the tree */
+/* Find previous visible element in the tree. */
static TreeElement *outliner_find_previous_element(SpaceOutliner *space_outliner, TreeElement *te)
{
if (te->prev) {
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index f809bb13b42..d59d04b6ac2 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -86,6 +86,8 @@
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "../../blender/blenloader/BLO_readfile.h"
+
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -930,8 +932,14 @@ static void id_override_library_resync_fn(bContext *C,
te->store_elem->id->tag |= LIB_TAG_DOIT;
}
- BKE_lib_override_library_resync(
- bmain, scene, CTX_data_view_layer(C), id_root, NULL, do_hierarchy_enforce, true, reports);
+ BKE_lib_override_library_resync(bmain,
+ scene,
+ CTX_data_view_layer(C),
+ id_root,
+ NULL,
+ do_hierarchy_enforce,
+ true,
+ &(struct BlendFileReadReport){.reports = reports});
WM_event_add_notifier(C, NC_WINDOW, NULL);
}
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 728be1ccaaf..a2032fa1dc0 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -331,6 +331,7 @@ static SpaceLink *outliner_create(const ScrArea *UNUSED(area), const Scene *UNUS
space_outliner->outlinevis = SO_VIEW_LAYER;
space_outliner->sync_select_dirty |= WM_OUTLINER_SYNC_SELECT_FROM_ALL;
space_outliner->flag = SO_SYNC_SELECT | SO_MODE_COLUMN;
+ space_outliner->filter = SO_FILTER_NO_VIEW_LAYERS;
/* header */
region = MEM_callocN(sizeof(ARegion), "header for outliner");
diff --git a/source/blender/editors/space_outliner/tree/tree_display_libraries.cc b/source/blender/editors/space_outliner/tree/tree_display_libraries.cc
index 91b690d35fa..c6b700318dd 100644
--- a/source/blender/editors/space_outliner/tree/tree_display_libraries.cc
+++ b/source/blender/editors/space_outliner/tree/tree_display_libraries.cc
@@ -138,8 +138,8 @@ TreeElement *TreeDisplayLibraries::add_library_contents(Main &mainvar,
}
}
- /* We always want to create an entry for libraries, even if/when we have no more IDs from
- * them. This invalid state is important to show to user as well.*/
+ /* We always want to create an entry for libraries, even if/when we have no more IDs from them.
+ * This invalid state is important to show to user as well. */
if (id != nullptr || is_library) {
if (!tenlib) {
/* Create library tree element on demand, depending if there are any data-blocks. */
diff --git a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
index f00cf3c34c0..402526bbe8d 100644
--- a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
+++ b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
@@ -71,33 +71,56 @@ ListBase TreeDisplayViewLayer::buildTree(const TreeSourceData &source_data)
{
ListBase tree = {nullptr};
- view_layer_ = source_data.view_layer;
+ Scene *scene = source_data.scene;
show_objects_ = !(space_outliner_.filter & SO_FILTER_NO_OBJECT);
const bool show_children = (space_outliner_.filter & SO_FILTER_NO_CHILDREN) == 0;
- if (space_outliner_.filter & SO_FILTER_NO_COLLECTION) {
- /* Show objects in the view layer. */
- for (Base *base : List<Base>(view_layer_->object_bases)) {
- TreeElement *te_object = outliner_add_element(
- &space_outliner_, &tree, base->object, nullptr, TSE_SOME_ID, 0);
- te_object->directdata = base;
+ for (auto *view_layer : ListBaseWrapper<ViewLayer>(scene->view_layers)) {
+ if (space_outliner_.filter & SO_FILTER_NO_VIEW_LAYERS) {
+ if (view_layer != source_data.view_layer) {
+ continue;
+ }
}
- if (show_children) {
- outliner_make_object_parent_hierarchy(&tree);
+ TreeElement &te_view_layer = *outliner_add_element(
+ &space_outliner_, &tree, scene, nullptr, TSE_R_LAYER, 0);
+ TREESTORE(&te_view_layer)->flag &= ~TSE_CLOSED;
+ te_view_layer.name = view_layer->name;
+ te_view_layer.directdata = view_layer;
+ view_layer_ = view_layer;
+
+ if (space_outliner_.filter & SO_FILTER_NO_COLLECTION) {
+ /* Show objects in the view layer. */
+ for (Base *base : List<Base>(view_layer_->object_bases)) {
+ TreeElement *te_object = outliner_add_element(&space_outliner_,
+ &te_view_layer.subtree,
+ base->object,
+ &te_view_layer,
+ TSE_SOME_ID,
+ 0);
+ te_object->directdata = base;
+ }
+
+ if (show_children) {
+ outliner_make_object_parent_hierarchy(&tree);
+ }
}
- }
- else {
- /* Show collections in the view layer. */
- TreeElement &ten = *outliner_add_element(
- &space_outliner_, &tree, source_data.scene, nullptr, TSE_VIEW_COLLECTION_BASE, 0);
- ten.name = IFACE_("Scene Collection");
- TREESTORE(&ten)->flag &= ~TSE_CLOSED;
-
- add_view_layer(ten.subtree, ten);
- if (show_children) {
- add_layer_collection_objects_children(ten);
+ else {
+ /* Show collections in the view layer. */
+ TreeElement &ten = *outliner_add_element(&space_outliner_,
+ &te_view_layer.subtree,
+ source_data.scene,
+ &te_view_layer,
+ TSE_VIEW_COLLECTION_BASE,
+ 0);
+ ten.name = IFACE_("Scene Collection");
+ TREESTORE(&ten)->flag &= ~TSE_CLOSED;
+
+ add_view_layer(ten.subtree, ten);
+ if (show_children) {
+ add_layer_collection_objects_children(ten);
+ }
}
}
@@ -149,8 +172,9 @@ void TreeDisplayViewLayer::add_layer_collections_recursive(ListBase &tree,
add_layer_collection_objects(ten->subtree, *lc, *ten);
}
- const bool lib_overrides_visible = !SUPPORT_FILTER_OUTLINER(&space_outliner_) ||
- ((space_outliner_.filter & SO_FILTER_NO_LIB_OVERRIDE) == 0);
+ const bool lib_overrides_visible = !exclude && (!SUPPORT_FILTER_OUTLINER(&space_outliner_) ||
+ ((space_outliner_.filter &
+ SO_FILTER_NO_LIB_OVERRIDE) == 0));
if (lib_overrides_visible && ID_IS_OVERRIDE_LIBRARY_REAL(&lc->collection->id)) {
outliner_add_element(
diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc
index c5d254242c6..731beb3956e 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc
@@ -94,9 +94,7 @@ void TreeElementOverridesBase::expand(SpaceOutliner &space_outliner) const
TreeElementOverridesProperty::TreeElementOverridesProperty(TreeElement &legacy_te,
TreeElementOverridesData &override_data)
- : AbstractTreeElement(legacy_te),
- id_(override_data.id),
- override_prop_(override_data.override_property)
+ : AbstractTreeElement(legacy_te), override_prop_(override_data.override_property)
{
BLI_assert(legacy_te.store_elem->type == TSE_LIBRARY_OVERRIDE);
diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.hh b/source/blender/editors/space_outliner/tree/tree_element_overrides.hh
index c3caab8e268..0067db6ea56 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_overrides.hh
+++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.hh
@@ -40,7 +40,6 @@ class TreeElementOverridesBase final : public AbstractTreeElement {
};
class TreeElementOverridesProperty final : public AbstractTreeElement {
- ID &id_;
IDOverrideLibraryProperty &override_prop_;
public:
diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c
index 4ce0e454df8..897af9ae931 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -81,7 +81,7 @@ static void script_free(SpaceLink *sl)
SpaceScript *sscript = (SpaceScript *)sl;
#ifdef WITH_PYTHON
- /*free buttons references*/
+ /* Free buttons references. */
if (sscript->but_refs) {
sscript->but_refs = NULL;
}
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index b6929f12cc0..dc1a49e347d 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -453,13 +453,13 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
GPU_blend(GPU_BLEND_NONE);
}
-/* Get handle width in pixels. */
+/* Get handle width in 2d-View space. */
float sequence_handle_size_get_clamped(Sequence *seq, const float pixelx)
{
const float maxhandle = (pixelx * SEQ_HANDLE_SIZE) * U.pixelsize;
- /* Ensure that handle is not wider, than half of strip. */
- return min_ff(maxhandle, ((float)(seq->enddisp - seq->startdisp) / 2.0f) / pixelx);
+ /* Ensure that handle is not wider, than quarter of strip. */
+ return min_ff(maxhandle, ((float)(seq->enddisp - seq->startdisp) / 4.0f));
}
/* Draw a handle, on left or right side of strip. */
@@ -1056,7 +1056,7 @@ static void draw_seq_fcurve_overlay(
continue;
}
- /* If some frames were skipped above, we need to close the shape. */
+ /* If some frames were skipped above, we need to close the shape. */
if (skip) {
fcurve_batch_add_verts(
vbo, y1, y2, y_height, timeline_frame - eval_step, prev_val, &vert_count);
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index e17beb228de..94572698727 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -1816,8 +1816,8 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
/* Remove seq so overlap tests don't conflict,
* see seq_free_sequence below for the real freeing. */
BLI_remlink(ed->seqbasep, seq);
- /* if (seq->ipo) id_us_min(&seq->ipo->id); */
- /* XXX, remove fcurve and assign to split image strips */
+ /* TODO: remove f-curve and assign to split image strips.
+ * The old animation system would remove the user of `seq->ipo`. */
start_ofs = timeline_frame = SEQ_transform_get_left_handle_frame(seq);
frame_end = SEQ_transform_get_right_handle_frame(seq);
@@ -2984,8 +2984,10 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ /* Only text strips that are not muted and don't end with negative frame. */
SEQ_ALL_BEGIN (ed, seq) {
- if (seq->type == SEQ_TYPE_TEXT) {
+ if ((seq->type == SEQ_TYPE_TEXT) && ((seq->flag & SEQ_MUTE) == 0) &&
+ (seq->enddisp > scene->r.sfra)) {
BLI_addtail(&text_seq, MEM_dupallocN(seq));
}
}
@@ -3006,16 +3008,17 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
char timecode_str_start[32];
char timecode_str_end[32];
+ /* Write time-code relative to start frame of scene. Don't allow negative time-codes. */
BLI_timecode_string_from_time(timecode_str_start,
sizeof(timecode_str_start),
-2,
- FRA2TIME(seq->startdisp),
+ FRA2TIME(max_ii(seq->startdisp - scene->r.sfra, 0)),
FPS,
USER_TIMECODE_SUBRIP);
BLI_timecode_string_from_time(timecode_str_end,
sizeof(timecode_str_end),
-2,
- FRA2TIME(seq->enddisp),
+ FRA2TIME(seq->enddisp - scene->r.sfra),
FPS,
USER_TIMECODE_SUBRIP);
diff --git a/source/blender/editors/space_spreadsheet/CMakeLists.txt b/source/blender/editors/space_spreadsheet/CMakeLists.txt
index 7e3f3db9bc8..1ea6593588a 100644
--- a/source/blender/editors/space_spreadsheet/CMakeLists.txt
+++ b/source/blender/editors/space_spreadsheet/CMakeLists.txt
@@ -38,6 +38,8 @@ set(SRC
spreadsheet_column.cc
spreadsheet_data_source.cc
spreadsheet_data_source_geometry.cc
+ spreadsheet_dataset_draw.cc
+ spreadsheet_dataset_layout.cc
spreadsheet_draw.cc
spreadsheet_layout.cc
spreadsheet_ops.cc
@@ -50,6 +52,8 @@ set(SRC
spreadsheet_column_values.hh
spreadsheet_data_source.hh
spreadsheet_data_source_geometry.hh
+ spreadsheet_dataset_draw.hh
+ spreadsheet_dataset_layout.hh
spreadsheet_draw.hh
spreadsheet_intern.hh
spreadsheet_layout.hh
diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
index 8c42f28b5f4..07517f9e60f 100644
--- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
+++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
@@ -47,6 +47,7 @@
#include "spreadsheet_context.hh"
#include "spreadsheet_data_source_geometry.hh"
+#include "spreadsheet_dataset_draw.hh"
#include "spreadsheet_intern.hh"
#include "spreadsheet_layout.hh"
#include "spreadsheet_row_filter.hh"
@@ -80,6 +81,15 @@ static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *U
}
{
+ /* Dataset Region */
+ ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet dataset region");
+ BLI_addtail(&spreadsheet_space->regionbase, region);
+ region->regiontype = RGN_TYPE_CHANNELS;
+ region->alignment = RGN_ALIGN_LEFT;
+ region->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+ }
+
+ {
/* Properties region. */
ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet right region");
BLI_addtail(&spreadsheet_space->regionbase, region);
@@ -195,7 +205,7 @@ static void spreadsheet_main_region_init(wmWindowManager *wm, ARegion *region)
}
}
-ID *ED_spreadsheet_get_current_id(struct SpaceSpreadsheet *sspreadsheet)
+ID *ED_spreadsheet_get_current_id(const struct SpaceSpreadsheet *sspreadsheet)
{
if (BLI_listbase_is_empty(&sspreadsheet->context_path)) {
return nullptr;
@@ -263,7 +273,7 @@ static void update_context_path_from_context(const bContext *C)
}
}
-static void update_context_path(const bContext *C)
+void spreadsheet_update_context_path(const bContext *C)
{
SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
if (sspreadsheet->flag & SPREADSHEET_FLAG_PINNED) {
@@ -274,28 +284,40 @@ static void update_context_path(const bContext *C)
}
}
-static std::unique_ptr<DataSource> get_data_source(const bContext *C)
+Object *spreadsheet_get_object_eval(const SpaceSpreadsheet *sspreadsheet,
+ const Depsgraph *depsgraph)
{
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
ID *used_id = ED_spreadsheet_get_current_id(sspreadsheet);
if (used_id == nullptr) {
- return {};
+ return nullptr;
}
const ID_Type id_type = GS(used_id->name);
if (id_type != ID_OB) {
- return {};
+ return nullptr;
}
Object *object_orig = (Object *)used_id;
if (!ELEM(object_orig->type, OB_MESH, OB_POINTCLOUD, OB_VOLUME)) {
- return {};
+ return nullptr;
}
+
Object *object_eval = DEG_get_evaluated_object(depsgraph, object_orig);
if (object_eval == nullptr) {
- return {};
+ return nullptr;
}
- return data_source_from_geometry(C, object_eval);
+ return object_eval;
+}
+
+static std::unique_ptr<DataSource> get_data_source(const bContext *C)
+{
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
+
+ Object *object_eval = spreadsheet_get_object_eval(sspreadsheet, depsgraph);
+ if (object_eval) {
+ return data_source_from_geometry(C, object_eval);
+ }
+ return {};
}
static float get_column_width(const ColumnValues &values)
@@ -358,7 +380,7 @@ static void update_visible_columns(ListBase &columns, DataSource &data_source)
static void spreadsheet_main_region_draw(const bContext *C, ARegion *region)
{
SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
- update_context_path(C);
+ spreadsheet_update_context_path(C);
std::unique_ptr<DataSource> data_source = get_data_source(C);
if (!data_source) {
@@ -442,7 +464,7 @@ static void spreadsheet_header_region_init(wmWindowManager *UNUSED(wm), ARegion
static void spreadsheet_header_region_draw(const bContext *C, ARegion *region)
{
- update_context_path(C);
+ spreadsheet_update_context_path(C);
ED_region_header(C, region);
}
@@ -534,6 +556,59 @@ static void spreadsheet_footer_region_listener(const wmRegionListenerParams *UNU
{
}
+static void spreadsheet_dataset_region_listener(const wmRegionListenerParams *params)
+{
+ ARegion *region = params->region;
+ wmNotifier *wmn = params->notifier;
+
+ switch (wmn->category) {
+ case NC_SCENE: {
+ switch (wmn->data) {
+ case ND_FRAME:
+ ED_region_tag_redraw(region);
+ break;
+ }
+ break;
+ }
+ case NC_TEXTURE:
+ ED_region_tag_redraw(region);
+ break;
+ }
+
+ spreadsheet_header_region_listener(params);
+}
+
+static void spreadsheet_dataset_region_init(wmWindowManager *wm, ARegion *region)
+{
+ region->v2d.scroll |= V2D_SCROLL_RIGHT;
+ region->v2d.scroll &= ~(V2D_SCROLL_LEFT | V2D_SCROLL_TOP | V2D_SCROLL_BOTTOM);
+ region->v2d.scroll |= V2D_SCROLL_HORIZONTAL_HIDE;
+ region->v2d.scroll |= V2D_SCROLL_VERTICAL_HIDE;
+
+ UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_LIST, region->winx, region->winy);
+
+ wmKeyMap *keymap = WM_keymap_ensure(
+ wm->defaultconf, "Spreadsheet Generic", SPACE_SPREADSHEET, 0);
+ WM_event_add_keymap_handler(&region->handlers, keymap);
+}
+
+static void spreadsheet_dataset_region_draw(const bContext *C, ARegion *region)
+{
+ spreadsheet_update_context_path(C);
+
+ View2D *v2d = &region->v2d;
+ UI_view2d_view_ortho(v2d);
+ UI_ThemeClearColor(TH_BACK);
+
+ draw_dataset_in_region(C, region);
+
+ /* reset view matrix */
+ UI_view2d_view_restore(C);
+
+ /* scrollers */
+ UI_view2d_scrollers_draw(v2d, nullptr);
+}
+
static void spreadsheet_sidebar_init(wmWindowManager *wm, ARegion *region)
{
UI_panel_category_active_set_default(region, "Filters");
@@ -619,5 +694,15 @@ void ED_spacetype_spreadsheet(void)
register_row_filter_panels(*art);
+ /* regions: channels */
+ art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spreadsheet dataset region");
+ art->regionid = RGN_TYPE_CHANNELS;
+ art->prefsizex = 200 + V2D_SCROLL_WIDTH;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
+ art->init = spreadsheet_dataset_region_init;
+ art->draw = spreadsheet_dataset_region_draw;
+ art->listener = spreadsheet_dataset_region_listener;
+ BLI_addhead(&st->regiontypes, art);
+
BKE_spacetype_register(st);
}
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_context.cc b/source/blender/editors/space_spreadsheet/spreadsheet_context.cc
index 3eb43338908..af6ab5d1b92 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_context.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_context.cc
@@ -255,11 +255,11 @@ void ED_spreadsheet_context_path_update_tag(SpaceSpreadsheet *sspreadsheet)
blender::ed::spreadsheet::spreadsheet_context_update_tag(sspreadsheet);
}
-uint64_t ED_spreadsheet_context_path_hash(SpaceSpreadsheet *sspreadsheet)
+uint64_t ED_spreadsheet_context_path_hash(const SpaceSpreadsheet *sspreadsheet)
{
BLI_HashMurmur2A mm2;
BLI_hash_mm2a_init(&mm2, 1234);
- LISTBASE_FOREACH (SpreadsheetContext *, context, &sspreadsheet->context_path) {
+ LISTBASE_FOREACH (const SpreadsheetContext *, context, &sspreadsheet->context_path) {
blender::ed::spreadsheet::spreadsheet_context_hash(context, &mm2);
}
return BLI_hash_mm2a_end(&mm2);
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
index 0c76c8b7a15..6d244a1bda6 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
@@ -385,9 +385,9 @@ int InstancesDataSource::tot_rows() const
return component_->instances_amount();
}
-static GeometrySet get_display_geometry_set(SpaceSpreadsheet *sspreadsheet,
- Object *object_eval,
- const GeometryComponentType used_component_type)
+GeometrySet spreadsheet_get_display_geometry_set(const SpaceSpreadsheet *sspreadsheet,
+ Object *object_eval,
+ const GeometryComponentType used_component_type)
{
GeometrySet geometry_set;
if (sspreadsheet->object_eval_state == SPREADSHEET_OBJECT_EVAL_STATE_ORIGINAL) {
@@ -470,7 +470,8 @@ std::unique_ptr<DataSource> data_source_from_geometry(const bContext *C, Object
SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
const AttributeDomain domain = (AttributeDomain)sspreadsheet->attribute_domain;
const GeometryComponentType component_type = get_display_component_type(C, object_eval);
- GeometrySet geometry_set = get_display_geometry_set(sspreadsheet, object_eval, component_type);
+ GeometrySet geometry_set = spreadsheet_get_display_geometry_set(
+ sspreadsheet, object_eval, component_type);
if (!geometry_set.has(component_type)) {
return {};
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc
new file mode 100644
index 00000000000..2b31ce7d03c
--- /dev/null
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc
@@ -0,0 +1,287 @@
+/*
+ * 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.
+ */
+
+#include <array>
+
+#include "DNA_space_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "BKE_context.h"
+
+#include "BLF_api.h"
+
+#include "BLI_rect.h"
+
+#include "RNA_access.h"
+
+#include "UI_interface.h"
+#include "UI_view2d.h"
+
+#include "WM_types.h"
+
+#include "spreadsheet_dataset_draw.hh"
+#include "spreadsheet_draw.hh"
+#include "spreadsheet_intern.hh"
+
+static int is_component_row_selected(struct uiBut *but, const void *arg)
+{
+ SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)arg;
+
+ GeometryComponentType component = (GeometryComponentType)UI_but_datasetrow_component_get(but);
+ AttributeDomain domain = (AttributeDomain)UI_but_datasetrow_domain_get(but);
+
+ const bool is_component_selected = (GeometryComponentType)
+ sspreadsheet->geometry_component_type == component;
+ const bool is_domain_selected = (AttributeDomain)sspreadsheet->attribute_domain == domain;
+ bool is_selected = is_component_selected && is_domain_selected;
+
+ if (component == GEO_COMPONENT_TYPE_INSTANCES) {
+ is_selected = is_component_selected;
+ }
+
+ return is_selected;
+}
+
+namespace blender::ed::spreadsheet {
+
+/* -------------------------------------------------------------------- */
+/* Draw Context */
+
+class DatasetDrawContext {
+ std::array<int, 2> mval_;
+
+ public:
+ const SpaceSpreadsheet *sspreadsheet;
+ Object *object_eval;
+ /* Current geometry set, changes per component. */
+ GeometrySet current_geometry_set;
+
+ DatasetDrawContext(const bContext *C);
+
+ GeometrySet geometry_set_from_component(GeometryComponentType component);
+ const std::array<int, 2> &cursor_mval() const;
+};
+
+DatasetDrawContext::DatasetDrawContext(const bContext *C)
+ : sspreadsheet(CTX_wm_space_spreadsheet(C)),
+ object_eval(spreadsheet_get_object_eval(sspreadsheet, CTX_data_depsgraph_pointer(C)))
+{
+ const wmWindow *win = CTX_wm_window(C);
+ const ARegion *region = CTX_wm_region(C);
+ mval_ = {win->eventstate->x - region->winrct.xmin, win->eventstate->y - region->winrct.ymin};
+}
+
+GeometrySet DatasetDrawContext::geometry_set_from_component(GeometryComponentType component)
+{
+ return spreadsheet_get_display_geometry_set(sspreadsheet, object_eval, component);
+}
+
+const std::array<int, 2> &DatasetDrawContext::cursor_mval() const
+{
+ return mval_;
+}
+
+/* -------------------------------------------------------------------- */
+/* Drawer */
+
+DatasetRegionDrawer::DatasetRegionDrawer(const ARegion *region,
+ uiBlock &block,
+ DatasetDrawContext &draw_context)
+ : row_height(UI_UNIT_Y),
+ xmin(region->v2d.cur.xmin),
+ xmax(region->v2d.cur.xmax),
+ block(block),
+ v2d(region->v2d),
+ draw_context(draw_context)
+{
+}
+
+void DatasetRegionDrawer::draw_hierarchy(const DatasetLayoutHierarchy &layout)
+{
+ for (const DatasetComponentLayoutInfo &component : layout.components) {
+ draw_context.current_geometry_set = draw_context.geometry_set_from_component(component.type);
+
+ draw_component_row(component);
+
+ /* Iterate attribute domains, skip unset ones (storage has to be in a enum-based, fixed size
+ * array so uses optionals to support skipping enum values that shouldn't be displayed for a
+ * component). */
+ for (const auto &optional_domain : component.attr_domains) {
+ if (!optional_domain) {
+ continue;
+ }
+
+ const DatasetAttrDomainLayoutInfo &domain_info = *optional_domain;
+ draw_attribute_domain_row(component, domain_info);
+ }
+ }
+}
+
+static int element_count_from_instances(const GeometrySet &geometry_set)
+{
+ if (geometry_set.has_instances()) {
+ const InstancesComponent *instances_component =
+ geometry_set.get_component_for_read<InstancesComponent>();
+ return instances_component->instances_amount();
+ }
+ return 0;
+}
+
+static int element_count_from_component_domain(const GeometrySet &geometry_set,
+ GeometryComponentType component,
+ AttributeDomain domain)
+{
+ if (geometry_set.has_mesh() && component == GEO_COMPONENT_TYPE_MESH) {
+ const MeshComponent *mesh_component = geometry_set.get_component_for_read<MeshComponent>();
+ return mesh_component->attribute_domain_size(domain);
+ }
+
+ if (geometry_set.has_pointcloud() && component == GEO_COMPONENT_TYPE_POINT_CLOUD) {
+ const PointCloudComponent *point_cloud_component =
+ geometry_set.get_component_for_read<PointCloudComponent>();
+ return point_cloud_component->attribute_domain_size(domain);
+ }
+
+ if (geometry_set.has_volume() && component == GEO_COMPONENT_TYPE_VOLUME) {
+ const VolumeComponent *volume_component =
+ geometry_set.get_component_for_read<VolumeComponent>();
+ return volume_component->attribute_domain_size(domain);
+ }
+
+ if (geometry_set.has_curve() && component == GEO_COMPONENT_TYPE_CURVE) {
+ const CurveComponent *curve_component = geometry_set.get_component_for_read<CurveComponent>();
+ return curve_component->attribute_domain_size(domain);
+ }
+
+ return 0;
+}
+
+void DatasetRegionDrawer::draw_dataset_row(const int indentation,
+ const GeometryComponentType component,
+ const std::optional<AttributeDomain> domain,
+ BIFIconID icon,
+ const char *label,
+ const bool is_active)
+{
+
+ const float row_height = UI_UNIT_Y;
+ const float padding_x = UI_UNIT_X * 0.25f;
+
+ const rctf rect = {float(xmin) + padding_x,
+ float(xmax) - V2D_SCROLL_HANDLE_WIDTH,
+ ymin_offset - row_height,
+ ymin_offset};
+
+ char element_count[7];
+ if (component == GEO_COMPONENT_TYPE_INSTANCES) {
+ BLI_str_format_attribute_domain_size(
+ element_count, element_count_from_instances(draw_context.current_geometry_set));
+ }
+ else {
+ BLI_str_format_attribute_domain_size(
+ element_count,
+ domain ? element_count_from_component_domain(
+ draw_context.current_geometry_set, component, *domain) :
+ 0);
+ }
+
+ std::string label_and_element_count = label;
+ label_and_element_count += UI_SEP_CHAR;
+ label_and_element_count += element_count;
+
+ uiBut *bt = uiDefIconTextButO(&block,
+ UI_BTYPE_DATASETROW,
+ "SPREADSHEET_OT_change_spreadsheet_data_source",
+ 0,
+ icon,
+ label,
+ rect.xmin,
+ rect.ymin,
+ BLI_rctf_size_x(&rect),
+ BLI_rctf_size_y(&rect),
+ nullptr);
+
+ UI_but_datasetrow_indentation_set(bt, indentation);
+
+ if (is_active) {
+ UI_but_hint_drawstr_set(bt, element_count);
+ UI_but_datasetrow_component_set(bt, component);
+ if (domain) {
+ UI_but_datasetrow_domain_set(bt, *domain);
+ }
+ UI_but_func_pushed_state_set(bt, &is_component_row_selected, draw_context.sspreadsheet);
+
+ PointerRNA *but_ptr = UI_but_operator_ptr_get((uiBut *)bt);
+ RNA_int_set(but_ptr, "component_type", component);
+ if (domain) {
+ RNA_int_set(but_ptr, "attribute_domain_type", *domain);
+ }
+ }
+
+ ymin_offset -= row_height;
+}
+
+void DatasetRegionDrawer::draw_component_row(const DatasetComponentLayoutInfo &component_info)
+{
+ if (component_info.type == GEO_COMPONENT_TYPE_INSTANCES) {
+ draw_dataset_row(
+ 0, component_info.type, std::nullopt, component_info.icon, component_info.label, true);
+ }
+ else {
+ draw_dataset_row(
+ 0, component_info.type, std::nullopt, component_info.icon, component_info.label, false);
+ }
+}
+
+void DatasetRegionDrawer::draw_attribute_domain_row(
+ const DatasetComponentLayoutInfo &component_info,
+ const DatasetAttrDomainLayoutInfo &domain_info)
+{
+ draw_dataset_row(
+ 1, component_info.type, domain_info.type, domain_info.icon, domain_info.label, true);
+}
+
+/* -------------------------------------------------------------------- */
+/* Drawer */
+
+void draw_dataset_in_region(const bContext *C, ARegion *region)
+{
+ DatasetDrawContext draw_context{C};
+ if (!draw_context.object_eval) {
+ /* No object means nothing to display. Keep the region empty. */
+ return;
+ }
+
+ uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
+
+ DatasetRegionDrawer drawer{region, *block, draw_context};
+
+ /* Start with an offset to align buttons to spreadsheet rows. Use spreadsheet drawing info for
+ * that. */
+ drawer.ymin_offset = -SpreadsheetDrawer().top_row_height + drawer.row_height;
+
+ const DatasetLayoutHierarchy hierarchy = dataset_layout_hierarchy();
+ drawer.draw_hierarchy(hierarchy);
+#ifndef NDEBUG
+ dataset_layout_hierarchy_sanity_check(hierarchy);
+#endif
+
+ UI_block_end(C, block);
+ UI_view2d_totRect_set(&region->v2d, region->winx, abs(drawer.ymin_offset));
+ UI_block_draw(C, block);
+}
+
+} // namespace blender::ed::spreadsheet
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.hh b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.hh
new file mode 100644
index 00000000000..d9e6d882c2a
--- /dev/null
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.hh
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <array>
+
+#include "BKE_geometry_set.hh"
+#include "UI_interface.h"
+#include "spreadsheet_dataset_layout.hh"
+
+struct ARegion;
+struct uiBlock;
+struct View2D;
+struct bContext;
+
+namespace blender::ed::spreadsheet {
+
+class DatasetDrawContext;
+
+class DatasetRegionDrawer {
+ public:
+ const int row_height;
+ float ymin_offset = 0;
+
+ int xmin;
+ int xmax;
+ uiBlock &block;
+ const View2D &v2d;
+ DatasetDrawContext &draw_context;
+
+ DatasetRegionDrawer(const ARegion *region, uiBlock &block, DatasetDrawContext &draw_context);
+
+ void draw_hierarchy(const DatasetLayoutHierarchy &layout);
+
+ void draw_attribute_domain_row(const DatasetComponentLayoutInfo &component,
+ const DatasetAttrDomainLayoutInfo &domain_info);
+ void draw_component_row(const DatasetComponentLayoutInfo &component_info);
+
+ private:
+ void draw_dataset_row(const int indentation,
+ const GeometryComponentType component,
+ const std::optional<AttributeDomain> domain,
+ const BIFIconID icon,
+ const char *label,
+ const bool is_active);
+};
+
+void draw_dataset_in_region(const bContext *C, ARegion *region);
+
+} // namespace blender::ed::spreadsheet
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_layout.cc b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_layout.cc
new file mode 100644
index 00000000000..5b5c5ed0b04
--- /dev/null
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_layout.cc
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+#include <optional>
+
+#include "BLI_span.hh"
+
+#include "BLT_translation.h"
+
+#include "spreadsheet_dataset_layout.hh"
+
+namespace blender::ed::spreadsheet {
+
+#define ATTR_INFO(type, label, icon) \
+ std::optional<DatasetAttrDomainLayoutInfo> \
+ { \
+ std::in_place, type, label, icon \
+ }
+#define ATTR_INFO_NONE(type) \
+ { \
+ std::nullopt \
+ }
+
+/**
+ * Definition for the component->attribute-domain hierarchy.
+ * Constructed at compile time.
+ *
+ * \warning: Order of attribute-domains matters! It __must__ match the #AttributeDomain definition
+ * and fill gaps with unset optionals (i.e. `std::nullopt`). Would be nice to use array
+ * designators for this (which C++ doesn't support).
+ */
+constexpr DatasetComponentLayoutInfo DATASET_layout_hierarchy[] = {
+ {
+ GEO_COMPONENT_TYPE_MESH,
+ N_("Mesh"),
+ ICON_MESH_DATA,
+ {
+ ATTR_INFO(ATTR_DOMAIN_POINT, N_("Vertex"), ICON_VERTEXSEL),
+ ATTR_INFO(ATTR_DOMAIN_EDGE, N_("Edge"), ICON_EDGESEL),
+ ATTR_INFO(ATTR_DOMAIN_FACE, N_("Face"), ICON_FACESEL),
+ ATTR_INFO(ATTR_DOMAIN_CORNER, N_("Face Corner"), ICON_NODE_CORNER),
+ },
+ },
+ {
+ GEO_COMPONENT_TYPE_CURVE,
+ N_("Curves"),
+ ICON_CURVE_DATA,
+ {
+ ATTR_INFO(ATTR_DOMAIN_POINT, N_("Control Point"), ICON_CURVE_BEZCIRCLE),
+ ATTR_INFO_NONE(ATTR_DOMAIN_EDGE),
+ ATTR_INFO_NONE(ATTR_DOMAIN_CORNER),
+ ATTR_INFO_NONE(ATTR_DOMAIN_FACE),
+ ATTR_INFO(ATTR_DOMAIN_CURVE, N_("Spline"), ICON_CURVE_PATH),
+ },
+ },
+ {
+ GEO_COMPONENT_TYPE_POINT_CLOUD,
+ N_("Point Cloud"),
+ ICON_POINTCLOUD_DATA,
+ {
+ ATTR_INFO(ATTR_DOMAIN_POINT, N_("Point"), ICON_PARTICLE_POINT),
+ },
+ },
+ {
+ GEO_COMPONENT_TYPE_INSTANCES,
+ N_("Instances"),
+ ICON_EMPTY_AXIS,
+ {},
+ },
+};
+
+#undef ATTR_INFO
+#undef ATTR_INFO_LABEL
+
+DatasetLayoutHierarchy dataset_layout_hierarchy()
+{
+ return DatasetLayoutHierarchy{
+ Span{DATASET_layout_hierarchy, ARRAY_SIZE(DATASET_layout_hierarchy)}};
+}
+
+#ifndef NDEBUG
+/**
+ * Debug-only sanity check for correct attribute domain initialization (order/indices must
+ * match AttributeDomain). This doesn't check for all possible missuses, but should catch the most
+ * likely mistakes.
+ */
+void dataset_layout_hierarchy_sanity_check(const DatasetLayoutHierarchy &hierarchy)
+{
+ for (const DatasetComponentLayoutInfo &component : hierarchy.components) {
+ for (uint i = 0; i < component.attr_domains.size(); i++) {
+ if (component.attr_domains[i]) {
+ BLI_assert(component.attr_domains[i]->type == static_cast<AttributeDomain>(i));
+ }
+ }
+ }
+}
+#endif
+
+} // namespace blender::ed::spreadsheet
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_layout.hh b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_layout.hh
new file mode 100644
index 00000000000..d463739a0fa
--- /dev/null
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_layout.hh
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <array>
+#include <optional>
+
+/* Enum definitions... */
+#include "BKE_attribute.h"
+#include "BKE_geometry_set.h"
+
+#include "BLI_span.hh"
+
+/* More enum definitions... */
+#include "UI_resources.h"
+
+#pragma once
+
+namespace blender::ed::spreadsheet {
+
+struct DatasetAttrDomainLayoutInfo {
+ AttributeDomain type;
+ const char *label;
+ BIFIconID icon;
+
+ constexpr DatasetAttrDomainLayoutInfo(AttributeDomain type, const char *label, BIFIconID icon)
+ : type(type), label(label), icon(icon)
+ {
+ }
+};
+
+struct DatasetComponentLayoutInfo {
+ GeometryComponentType type;
+ const char *label;
+ BIFIconID icon;
+ /** Array of attribute-domains. Has to be fixed size based on #AttributeDomain enum, but not all
+ * values need displaying for all parent components. Hence the optional use. */
+ using AttrDomainArray = std::array<std::optional<DatasetAttrDomainLayoutInfo>, ATTR_DOMAIN_NUM>;
+ const AttrDomainArray attr_domains;
+};
+
+struct DatasetLayoutHierarchy {
+ /** The components for display (with layout info like icon and label). Each component stores
+ * the attribute domains it wants to display (also with layout info like icon and label). */
+ const Span<DatasetComponentLayoutInfo> components;
+};
+
+DatasetLayoutHierarchy dataset_layout_hierarchy();
+
+#ifndef NDEBUG
+void dataset_layout_hierarchy_sanity_check(const DatasetLayoutHierarchy &hierarchy);
+#endif
+
+} // namespace blender::ed::spreadsheet
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_intern.hh b/source/blender/editors/space_spreadsheet/spreadsheet_intern.hh
index 7e3b79a6706..8be5283fd63 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_intern.hh
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_intern.hh
@@ -16,10 +16,23 @@
#pragma once
+#include "BKE_geometry_set.hh"
+
typedef struct SpaceSpreadsheet_Runtime {
int visible_rows;
int tot_rows;
int tot_columns;
} SpaceSpreadsheet_Runtime;
+struct bContext;
+
void spreadsheet_operatortypes(void);
+void spreadsheet_update_context_path(const bContext *C);
+Object *spreadsheet_get_object_eval(const SpaceSpreadsheet *sspreadsheet,
+ const Depsgraph *depsgraph);
+
+namespace blender::ed::spreadsheet {
+GeometrySet spreadsheet_get_display_geometry_set(const SpaceSpreadsheet *sspreadsheet,
+ Object *object_eval,
+ const GeometryComponentType used_component_type);
+}
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc b/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc
index fcbc37346e6..11ed88b7dc9 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc
@@ -13,6 +13,17 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "BKE_screen.h"
+
+#include "DNA_space_types.h"
+
+#include "ED_screen.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
#include "BLI_listbase.h"
@@ -89,8 +100,50 @@ static void SPREADSHEET_OT_remove_row_filter_rule(wmOperatorType *ot)
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX);
}
+static int select_component_domain_invoke(bContext *C,
+ wmOperator *op,
+ const wmEvent *UNUSED(event))
+{
+ GeometryComponentType component_type = static_cast<GeometryComponentType>(
+ RNA_int_get(op->ptr, "component_type"));
+ AttributeDomain attribute_domain = static_cast<AttributeDomain>(
+ RNA_int_get(op->ptr, "attribute_domain_type"));
+
+ SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
+ sspreadsheet->geometry_component_type = component_type;
+ sspreadsheet->attribute_domain = attribute_domain;
+
+ /* Refresh header and main region. */
+ WM_main_add_notifier(NC_SPACE | ND_SPACE_SPREADSHEET, nullptr);
+
+ return OPERATOR_FINISHED;
+}
+
+static void SPREADSHEET_OT_change_spreadsheet_data_source(wmOperatorType *ot)
+{
+ ot->name = "Change Visible Data Source";
+ ot->description = "Change visible data source in the spreadsheet";
+ ot->idname = "SPREADSHEET_OT_change_spreadsheet_data_source";
+
+ ot->invoke = select_component_domain_invoke;
+
+ RNA_def_int(ot->srna, "component_type", 0, 0, INT16_MAX, "Component Type", "", 0, INT16_MAX);
+ RNA_def_int(ot->srna,
+ "attribute_domain_type",
+ 0,
+ 0,
+ INT16_MAX,
+ "Attribute Domain Type",
+ "",
+ 0,
+ INT16_MAX);
+
+ ot->flag = OPTYPE_INTERNAL;
+}
+
void spreadsheet_operatortypes()
{
WM_operatortype_append(SPREADSHEET_OT_add_row_filter_rule);
WM_operatortype_append(SPREADSHEET_OT_remove_row_filter_rule);
+ WM_operatortype_append(SPREADSHEET_OT_change_spreadsheet_data_source);
}
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc
index dbd2ef157af..219d03c1dcd 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc
@@ -267,20 +267,20 @@ static void spreadsheet_row_filters_layout(const bContext *C, Panel *panel)
}
else {
/* Assuming there's only one group of instanced panels, update the custom data pointers. */
- Panel *panel = (Panel *)region->panels.first;
+ Panel *panel_iter = (Panel *)region->panels.first;
LISTBASE_FOREACH (SpreadsheetRowFilter *, row_filter, row_filters) {
/* Move to the next instanced panel corresponding to the next filter. */
- while ((panel->type == nullptr) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
- panel = panel->next;
- BLI_assert(panel != nullptr); /* There shouldn't be fewer panels than filters. */
+ while ((panel_iter->type == nullptr) || !(panel_iter->type->flag & PANEL_TYPE_INSTANCED)) {
+ panel_iter = panel_iter->next;
+ BLI_assert(panel_iter != nullptr); /* There shouldn't be fewer panels than filters. */
}
PointerRNA *filter_ptr = (PointerRNA *)MEM_mallocN(sizeof(PointerRNA), "panel customdata");
RNA_pointer_create(&screen->id, &RNA_SpreadsheetRowFilter, row_filter, filter_ptr);
- UI_panel_custom_data_set(panel, filter_ptr);
+ UI_panel_custom_data_set(panel_iter, filter_ptr);
- panel = panel->next;
+ panel_iter = panel_iter->next;
}
}
}
diff --git a/source/blender/editors/space_statusbar/space_statusbar.c b/source/blender/editors/space_statusbar/space_statusbar.c
index 0b4f483c114..bf2a5534e0b 100644
--- a/source/blender/editors/space_statusbar/space_statusbar.c
+++ b/source/blender/editors/space_statusbar/space_statusbar.c
@@ -39,7 +39,7 @@
#include "WM_message.h"
#include "WM_types.h"
-/* ******************** default callbacks for statusbar space ******************** */
+/* ******************** default callbacks for statusbar space ******************** */
static SpaceLink *statusbar_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 17831c95575..1d8bc427212 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -938,7 +938,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *scroll, rcti *b
hlstart = barstart + barheight;
}
else if (lhlend > st->top && lhlstart < st->top && hlstart > barstart) {
- /*fill out start */
+ /* Fill out start. */
hlstart = barstart;
}
diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c
index a68632c0d56..1200dda7533 100644
--- a/source/blender/editors/space_text/text_format_pov.c
+++ b/source/blender/editors/space_text/text_format_pov.c
@@ -644,7 +644,7 @@ static int txtfmt_pov_find_specialvar(const char *string)
} else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "open", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "ior", len)) { i = len;
- /* Light Types and options*/
+ /* Light Types and options. */
} else if (STR_LITERAL_STARTSWITH(string, "area_light", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "looks_like", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) { i = len;
@@ -654,7 +654,7 @@ static int txtfmt_pov_find_specialvar(const char *string)
} else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "radius", len)) { i = len;
- /* Camera Types and options*/
+ /* Camera Types and options. */
} else if (STR_LITERAL_STARTSWITH(string, "omni_directional_stereo", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "lambert_cylindrical", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "miller_cylindrical", len)) { i = len;
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 9ec759ce4ae..6ca89250cd7 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -2782,8 +2782,7 @@ void TEXT_OT_scroll(wmOperatorType *ot)
/* identifiers */
ot->name = "Scroll";
/* don't really see the difference between this and
- * scroll_bar. Both do basically the same thing (aside
- * from keymaps).*/
+ * scroll_bar. Both do basically the same thing (aside from key-maps). */
ot->idname = "TEXT_OT_scroll";
/* api callbacks */
@@ -2889,8 +2888,7 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot)
/* identifiers */
ot->name = "Scrollbar";
/* don't really see the difference between this and
- * scroll. Both do basically the same thing (aside
- * from keymaps).*/
+ * scroll. Both do basically the same thing (aside from key-maps). */
ot->idname = "TEXT_OT_scroll_bar";
/* api callbacks */
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index 9242fc15021..fe84a3b8ae9 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -46,7 +46,6 @@ set(SRC
view3d_camera_control.c
view3d_draw.c
view3d_edit.c
- view3d_fly.c
view3d_gizmo_armature.c
view3d_gizmo_camera.c
view3d_gizmo_empty.c
@@ -60,6 +59,8 @@ set(SRC
view3d_gizmo_tool_generic.c
view3d_header.c
view3d_iterators.c
+ view3d_navigate_fly.c
+ view3d_navigate_walk.c
view3d_ops.c
view3d_placement.c
view3d_project.c
@@ -67,7 +68,6 @@ set(SRC
view3d_snap.c
view3d_utils.c
view3d_view.c
- view3d_walk.c
view3d_intern.h
)
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 660ae9da506..6b9da431510 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -117,10 +117,10 @@ void ED_draw_object_facemap(Depsgraph *depsgraph,
return;
}
- Mesh *me = ob->data;
+ const Mesh *me = ob->data;
{
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
+ const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
if (me_eval != NULL) {
me = me_eval;
}
@@ -160,7 +160,7 @@ void ED_draw_object_facemap(Depsgraph *depsgraph,
const MPoly *mp;
int i;
if (me->runtime.looptris.array) {
- MLoopTri *mlt = me->runtime.looptris.array;
+ const MLoopTri *mlt = me->runtime.looptris.array;
for (mp = mpoly, i = 0; i < mpoly_len; i++, mp++) {
if (facemap_data[i] == facemap) {
for (int j = 2; j < mp->totloop; j++) {
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index c9f345b3123..6ce13f83cf3 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -1617,7 +1617,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
* This is ignored in the case the object is in any mode (besides object-mode),
* since the object's mode impacts the current tool, cursor, gizmos etc.
* If we didn't have this exception, changing visibility would need to perform
- * many of the the same updates as changing the objects mode.
+ * many of the same updates as changing the objects mode.
*
* Further, there are multiple ways to hide objects - by collection, by object type, etc.
* it's simplest if all these methods behave consistently - respecting the object-mode
diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c
index 0b232d525fa..638c8a49ffd 100644
--- a/source/blender/editors/space_view3d/view3d_camera_control.c
+++ b/source/blender/editors/space_view3d/view3d_camera_control.c
@@ -278,7 +278,7 @@ void ED_view3d_cameracontrol_update(View3DCameraControl *vctrl,
mul_m4_m4m4(parent_mat, diff_mat, vctrl->root_parent->obmat);
if (object_apply_mat4_with_protect(vctrl->root_parent, parent_mat, false, rv3d, view_mat)) {
- /* Calculate again since the view locking changes the matrix. */
+ /* Calculate again since the view locking changes the matrix. */
ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 53fc7eed43b..50e9a9fb805 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -611,7 +611,7 @@ enum {
VIEWROT_MODAL_SWITCH_ROTATE = 6,
};
-/* called in transform_ops.c, on each regeneration of keymaps */
+/* Called in transform_ops.c, on each regeneration of key-maps. */
void viewrotate_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
@@ -1686,7 +1686,7 @@ void VIEW3D_OT_ndof_all(struct wmOperatorType *ot)
/* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
-/* called in transform_ops.c, on each regeneration of keymaps */
+/* Called in transform_ops.c, on each regeneration of key-maps. */
void viewmove_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
@@ -1881,8 +1881,8 @@ void VIEW3D_OT_move(wmOperatorType *ot)
/** \name View Zoom Operator
* \{ */
-/* viewdolly_modal_keymap has an exact copy of this, apply fixes to both */
-/* called in transform_ops.c, on each regeneration of keymaps */
+/* #viewdolly_modal_keymap has an exact copy of this, apply fixes to both. */
+/* Called in transform_ops.c, on each regeneration of key-maps. */
void viewzoom_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
@@ -2445,8 +2445,8 @@ void VIEW3D_OT_zoom(wmOperatorType *ot)
* which avoids #RegionView3D.dist approaching zero.
* \{ */
-/* this is an exact copy of viewzoom_modal_keymap */
-/* called in transform_ops.c, on each regeneration of keymaps */
+/* This is an exact copy of #viewzoom_modal_keymap. */
+/* Called in transform_ops.c, on each regeneration of key-maps. */
void viewdolly_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 0964c2dcbcc..ab80928e0c1 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -111,11 +111,11 @@ void view3d_ndof_fly(const struct wmNDOFMotionData *ndof,
bool *r_has_rotate);
#endif /* WITH_INPUT_NDOF */
-/* view3d_fly.c */
+/* view3d_navigate_fly.c */
void view3d_keymap(struct wmKeyConfig *keyconf);
void VIEW3D_OT_fly(struct wmOperatorType *ot);
-/* view3d_walk.c */
+/* view3d_navigate_walk.c */
void VIEW3D_OT_walk(struct wmOperatorType *ot);
/* view3d_draw.c */
diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c
index 2a381bb96cb..c7a4030c402 100644
--- a/source/blender/editors/space_view3d/view3d_iterators.c
+++ b/source/blender/editors/space_view3d/view3d_iterators.c
@@ -242,7 +242,7 @@ typedef struct foreachScreenEdge_userData {
rctf win_rect; /* copy of: vc.region->winx/winy, use for faster tests, minx/y will always be 0 */
/**
- * Clip plans defined by the the view bounds,
+ * Clip plans defined by the view bounds,
* use when #V3D_PROJ_TEST_CLIP_CONTENT is enabled.
*/
float content_planes[6][4];
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_navigate_fly.c
index d42746c168c..e2fa0fdc6a5 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_navigate_fly.c
@@ -19,7 +19,7 @@
*
* Interactive fly navigation modal operator (flying around in space).
*
- * \note Similar logic to `view3d_walk.c` changes here may apply there too.
+ * \note Similar logic to `view3d_navigate_walk.c` changes here may apply there too.
*/
/* defines VIEW3D_OT_fly modal operator */
@@ -101,7 +101,7 @@ typedef enum eFlyPanState {
FLY_AXISLOCK_STATE_ACTIVE = 2,
} eFlyPanState;
-/* called in transform_ops.c, on each regeneration of keymaps */
+/* Called in transform_ops.c, on each regeneration of key-maps. */
void fly_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
@@ -189,7 +189,7 @@ typedef struct FlyInfo {
wmNDOFMotionData *ndof;
#endif
- /* fly state state */
+ /* Fly state. */
/** The speed the view is moving per redraw. */
float speed;
/** Axis index to move along by default Z to move along the view. */
@@ -610,8 +610,7 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event)
fly->pan_view = false;
break;
- /* implement WASD keys,
- * comments only for 'forward '*/
+ /* Implement WASD keys, comments only for 'forward'. */
case FLY_MODAL_DIR_FORWARD:
if (fly->axis == 2 && fly->speed < 0.0f) {
/* reverse direction stops, tap again to continue */
@@ -758,9 +757,6 @@ static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm)
#define FLY_ZUP_CORRECT_ACCEL 0.05f /* increase upright momentum each step */
#define FLY_SMOOTH_FAC 20.0f /* higher value less lag */
- /* fly mode - Shift+F
- * a fly loop where the user can move move the view as if they are flying
- */
RegionView3D *rv3d = fly->rv3d;
/* 3x3 copy of the view matrix so we can move along the view axis */
@@ -812,10 +808,10 @@ static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm)
moffset[1] = 0;
}
- /* scale the mouse movement by this value - scales mouse movement to the view size
- * moffset[0] / (region->winx-xmargin * 2) - window size minus margin (same for y)
+ /* Scale the mouse movement by this value - scales mouse movement to the view size
+ * `moffset[0] / (region->winx-xmargin * 2)` - window size minus margin (same for y)
*
- * the mouse moves isn't linear */
+ * the mouse moves isn't linear. */
if (moffset[0]) {
moffset[0] /= fly->width - (xmargin * 2);
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_navigate_walk.c
index ab4cf0c2135..33cb6aad400 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_navigate_walk.c
@@ -20,7 +20,7 @@
* Interactive walk navigation modal operator
* (similar to walking around in a first person game).
*
- * \note Similar logic to `view3d_fly.c` changes here may apply there too.
+ * \note Similar logic to `view3d_navigate_fly.c` changes here may apply there too.
*/
/* defines VIEW3D_OT_navigate - walk modal operator */
@@ -129,7 +129,7 @@ typedef enum eWalkGravityState {
WALK_GRAVITY_STATE_ON,
} eWalkGravityState;
-/* called in transform_ops.c, on each regeneration of keymaps */
+/* Called in transform_ops.c, on each regeneration of key-maps. */
void walk_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
@@ -234,7 +234,7 @@ typedef struct WalkInfo {
wmNDOFMotionData *ndof;
#endif
- /* walk state state */
+ /* Walk state. */
/** The base speed without run/slow down modifications. */
float base_speed;
/** The speed the view is moving per redraw. */
@@ -989,9 +989,6 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm)
#define WALK_MOVE_SPEED base_speed
#define WALK_BOOST_FACTOR ((void)0, walk->speed_factor)
- /* walk mode - Ctrl+Shift+F
- * a walk loop where the user can move move the view as if they are in a walk game
- */
RegionView3D *rv3d = walk->rv3d;
ARegion *region = walk->region;
diff --git a/source/blender/editors/space_view3d/view3d_placement.c b/source/blender/editors/space_view3d/view3d_placement.c
index 04f382de56b..1ea7993572d 100644
--- a/source/blender/editors/space_view3d/view3d_placement.c
+++ b/source/blender/editors/space_view3d/view3d_placement.c
@@ -584,7 +584,7 @@ static bool calc_bbox(struct InteractivePlaceData *ipd, BoundBox *bounds)
delta_a[x_axis] = 0.0f;
delta_b[y_axis] = 0.0f;
- /* Assign here in case secondary */
+ /* Assign here in case secondary. */
fixed_aspect_dimension = max_ff(fabsf(delta_a[y_axis]), fabsf(delta_b[x_axis]));
if (ipd->step[0].is_fixed_aspect) {
@@ -1196,7 +1196,7 @@ static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEv
}
else {
/* If the user runs this as an operator they should set the 'primitive_type',
- * however running from operator search will end up at this point. */
+ * however running from operator search will end up at this point. */
ipd->primitive_type = PLACE_PRIMITIVE_TYPE_CUBE;
ipd->use_tool = false;
}
@@ -1830,7 +1830,7 @@ static void gizmo_plane_update_cursor(const bContext *C,
/* This ensures the snap gizmo has settings from this tool.
* This function call could be moved a more appropriate place,
* responding to the setting being changed for example,
- * however setting the value isn't expensive, so do it here. */
+ * however setting the value isn't expensive, so do it here. */
idp_snap_gizmo_update_snap_elements(scene, snap_to, snap_gizmo);
view3d_interactive_add_calc_plane((bContext *)C,
@@ -1957,7 +1957,7 @@ struct PlacementCursor {
/**
* Enable this while the modal operator is running,
- * so the preview-plane doesn't show at the same time time as add-object preview shape
+ * so the preview-plane doesn't show at the same time as add-object preview shape
* since it's distracting & not helpful.
*/
bool do_draw;
diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c
index 49da1764660..8a900a4e898 100644
--- a/source/blender/editors/space_view3d/view3d_project.c
+++ b/source/blender/editors/space_view3d/view3d_project.c
@@ -330,6 +330,17 @@ float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3], bool *r_f
return zfac;
}
+/**
+ * Calculate a depth value from `co` (result should only be used for comparison).
+ */
+float ED_view3d_calc_depth_for_comparison(const RegionView3D *rv3d, const float co[3])
+{
+ if (rv3d->is_persp) {
+ return ED_view3d_calc_zfac(rv3d, co, NULL);
+ }
+ return -dot_v3v3(rv3d->viewinv[2], co);
+}
+
static void view3d_win_to_ray_segment(struct Depsgraph *depsgraph,
const ARegion *region,
const View3D *v3d,
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 02ed9f6d791..0e5df3a0cdd 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -1833,7 +1833,7 @@ static bool bone_mouse_select_menu(bContext *C,
continue;
}
/* We can hit a bone multiple times, so make sure we are not adding an already included bone
- * to the list.*/
+ * to the list. */
const bool is_duplicate_bone = BLI_gset_haskey(added_bones, bone_ptr);
if (!is_duplicate_bone) {
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 72c62321e88..6dec3cc818a 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -155,7 +155,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
/* Get location of grid point in pose space. */
BKE_armature_loc_pose_to_bone(pchan_eval, vec, vec);
- /* adjust location on the original pchan*/
+ /* Adjust location on the original pchan. */
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, pchan_eval->name);
if ((pchan->protectflag & OB_LOCK_LOCX) == 0) {
pchan->loc[0] = vec[0];
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index ea0b1f396c3..4f8b0fa4685 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -260,7 +260,7 @@ bool ED_view3d_context_activate(bContext *C)
return false;
}
- /* bad context switch .. */
+ /* Bad context switch. */
CTX_wm_area_set(C, area);
CTX_wm_region_set(C, region);
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 056b2507745..a2d50c43bd2 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -85,7 +85,7 @@ struct SmoothView3DState {
};
struct SmoothView3DStore {
- /* source*/
+ /* Source. */
struct SmoothView3DState src; /* source */
struct SmoothView3DState dst; /* destination */
struct SmoothView3DState org; /* original */
@@ -1261,7 +1261,7 @@ static bool view3d_localview_init(const Depsgraph *depsgraph,
if (local_view_bit == 0) {
/* TODO(dfelinto): We can kick one of the other 3D views out of local view
- * specially if it is not being used. */
+ * specially if it is not being used. */
BKE_report(reports, RPT_ERROR, "No more than 16 local views");
ok = false;
}
diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt
index b0bc5c6abda..ad0a330f0f4 100644
--- a/source/blender/editors/transform/CMakeLists.txt
+++ b/source/blender/editors/transform/CMakeLists.txt
@@ -102,6 +102,7 @@ set(SRC
transform_orientations.c
transform_snap.c
transform_snap_object.c
+ transform_snap_sequencer.c
transform.h
transform_constraints.h
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 17bfc23aea7..88f91d477b5 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -650,7 +650,7 @@ static bool transform_modal_item_poll(const wmOperator *op, int value)
return true;
}
-/* called in transform_ops.c, on each regeneration of keymaps */
+/* Called in transform_ops.c, on each regeneration of key-maps. */
wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
@@ -1697,31 +1697,11 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->draw_handle_cursor = WM_paint_cursor_activate(
SPACE_TYPE_ANY, RGN_TYPE_ANY, transform_draw_cursor_poll, transform_draw_cursor_draw, t);
}
- else if (t->spacetype == SPACE_IMAGE) {
- t->draw_handle_view = ED_region_draw_cb_activate(
- t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
- t->draw_handle_cursor = WM_paint_cursor_activate(
- SPACE_TYPE_ANY, RGN_TYPE_ANY, transform_draw_cursor_poll, transform_draw_cursor_draw, t);
- }
- else if (t->spacetype == SPACE_CLIP) {
- t->draw_handle_view = ED_region_draw_cb_activate(
- t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
- t->draw_handle_cursor = WM_paint_cursor_activate(
- SPACE_TYPE_ANY, RGN_TYPE_ANY, transform_draw_cursor_poll, transform_draw_cursor_draw, t);
- }
- else if (t->spacetype == SPACE_NODE) {
- t->draw_handle_view = ED_region_draw_cb_activate(
- t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
- t->draw_handle_cursor = WM_paint_cursor_activate(
- SPACE_TYPE_ANY, RGN_TYPE_ANY, transform_draw_cursor_poll, transform_draw_cursor_draw, t);
- }
- else if (t->spacetype == SPACE_GRAPH) {
+ else if (t->spacetype == SPACE_SEQ) {
t->draw_handle_view = ED_region_draw_cb_activate(
t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
- t->draw_handle_cursor = WM_paint_cursor_activate(
- SPACE_TYPE_ANY, RGN_TYPE_ANY, transform_draw_cursor_poll, transform_draw_cursor_draw, t);
}
- else if (t->spacetype == SPACE_ACTION) {
+ else if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP, SPACE_NODE, SPACE_GRAPH, SPACE_ACTION)) {
t->draw_handle_view = ED_region_draw_cb_activate(
t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
t->draw_handle_cursor = WM_paint_cursor_activate(
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 2b26ef3b3e4..bd0ee1a51c6 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -335,7 +335,10 @@ typedef struct TransSnap {
/**
* Re-usable snap context data.
*/
- struct SnapObjectContext *object_context;
+ union {
+ struct SnapObjectContext *object_context;
+ struct TransSeqSnapData *seq_context;
+ };
} TransSnap;
typedef struct TransCon {
@@ -356,22 +359,22 @@ typedef struct TransCon {
/** Apply function pointer for linear vectorial transformation
* The last three parameters are pointers to the in/out/printable vectors. */
- void (*applyVec)(struct TransInfo *t,
- struct TransDataContainer *tc,
+ void (*applyVec)(const struct TransInfo *t,
+ const struct TransDataContainer *tc,
struct TransData *td,
const float in[3],
- float out[3]);
+ float r_out[3]);
/** Apply function pointer for size transformation. */
- void (*applySize)(struct TransInfo *t,
- struct TransDataContainer *tc,
+ void (*applySize)(const struct TransInfo *t,
+ const struct TransDataContainer *tc,
struct TransData *td,
- float smat[3][3]);
+ float r_smat[3][3]);
/** Apply function pointer for rotation transformation */
- void (*applyRot)(struct TransInfo *t,
- struct TransDataContainer *tc,
+ void (*applyRot)(const struct TransInfo *t,
+ const struct TransDataContainer *tc,
struct TransData *td,
- float vec[3],
- float *angle);
+ float r_axis[3],
+ float *r_angle);
} TransCon;
typedef struct MouseInput {
@@ -423,7 +426,7 @@ typedef struct TransCenterData {
* (typically in transform_conversion.c).
*/
typedef struct TransCustomDataContainer {
- /** Owned by the mode (grab, scale, bend... ).*/
+ /** Owned by the mode (grab, scale, bend... ). */
union {
TransCustomData mode, first_elem;
};
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 8c74d5349ba..7135395ee2d 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -97,7 +97,7 @@ static void view_vector_calc(const TransInfo *t, const float focus[3], float r_v
/* ************************** CONSTRAINTS ************************* */
#define CONSTRAIN_EPSILON 0.0001f
-static void constraint_plane_calc(TransInfo *t, float r_plane[4])
+static void constraint_plane_calc(const TransInfo *t, float r_plane[4])
{
const float *constraint_vector[2];
int n = 0;
@@ -391,8 +391,11 @@ static void planeProjection(const TransInfo *t, const float in[3], float out[3])
* projected along the view vector.
* (in perspective mode, the view vector is relative to the position on screen)
*/
-static void applyAxisConstraintVec(
- TransInfo *t, TransDataContainer *UNUSED(tc), TransData *td, const float in[3], float out[3])
+static void applyAxisConstraintVec(const TransInfo *t,
+ const TransDataContainer *UNUSED(tc),
+ TransData *td,
+ const float in[3],
+ float out[3])
{
copy_v3_v3(out, in);
if (!td && t->con.mode & CON_APPLY) {
@@ -472,8 +475,11 @@ static void applyAxisConstraintVec(
*
* Further down, that vector is mapped to each data's space.
*/
-static void applyObjectConstraintVec(
- TransInfo *t, TransDataContainer *tc, TransData *td, const float in[3], float out[3])
+static void applyObjectConstraintVec(const TransInfo *t,
+ const TransDataContainer *tc,
+ TransData *td,
+ const float in[3],
+ float out[3])
{
if (!td) {
applyAxisConstraintVec(t, tc, td, in, out);
@@ -494,36 +500,36 @@ static void applyObjectConstraintVec(
/**
* Generic callback for constant spatial constraints applied to resize motion.
*/
-static void applyAxisConstraintSize(TransInfo *t,
- TransDataContainer *UNUSED(tc),
+static void applyAxisConstraintSize(const TransInfo *t,
+ const TransDataContainer *UNUSED(tc),
TransData *td,
- float smat[3][3])
+ float r_smat[3][3])
{
if (!td && t->con.mode & CON_APPLY) {
float tmat[3][3];
if (!(t->con.mode & CON_AXIS0)) {
- smat[0][0] = 1.0f;
+ r_smat[0][0] = 1.0f;
}
if (!(t->con.mode & CON_AXIS1)) {
- smat[1][1] = 1.0f;
+ r_smat[1][1] = 1.0f;
}
if (!(t->con.mode & CON_AXIS2)) {
- smat[2][2] = 1.0f;
+ r_smat[2][2] = 1.0f;
}
- mul_m3_m3m3(tmat, smat, t->spacemtx_inv);
- mul_m3_m3m3(smat, t->spacemtx, tmat);
+ mul_m3_m3m3(tmat, r_smat, t->spacemtx_inv);
+ mul_m3_m3m3(r_smat, t->spacemtx, tmat);
}
}
/**
* Callback for object based spatial constraints applied to resize motion.
*/
-static void applyObjectConstraintSize(TransInfo *t,
- TransDataContainer *tc,
+static void applyObjectConstraintSize(const TransInfo *t,
+ const TransDataContainer *tc,
TransData *td,
- float smat[3][3])
+ float r_smat[3][3])
{
if (td && t->con.mode & CON_APPLY) {
float tmat[3][3];
@@ -532,26 +538,26 @@ static void applyObjectConstraintSize(TransInfo *t,
invert_m3_m3(imat, td->axismtx);
if (!(t->con.mode & CON_AXIS0)) {
- smat[0][0] = 1.0f;
+ r_smat[0][0] = 1.0f;
}
if (!(t->con.mode & CON_AXIS1)) {
- smat[1][1] = 1.0f;
+ r_smat[1][1] = 1.0f;
}
if (!(t->con.mode & CON_AXIS2)) {
- smat[2][2] = 1.0f;
+ r_smat[2][2] = 1.0f;
}
- mul_m3_m3m3(tmat, smat, imat);
+ mul_m3_m3m3(tmat, r_smat, imat);
if (t->flag & T_EDIT) {
- mul_m3_m3m3(smat, tc->mat3_unit, smat);
+ mul_m3_m3m3(r_smat, tc->mat3_unit, r_smat);
}
- mul_m3_m3m3(smat, td->axismtx, tmat);
+ mul_m3_m3m3(r_smat, td->axismtx, tmat);
}
}
-static void constraints_rotation_impl(TransInfo *t,
+static void constraints_rotation_impl(const TransInfo *t,
const float axismtx[3][3],
- float r_vec[3],
+ float r_axis[3],
float *r_angle)
{
BLI_assert(t->con.mode & CON_APPLY);
@@ -560,15 +566,15 @@ static void constraints_rotation_impl(TransInfo *t,
switch (mode) {
case CON_AXIS0:
case (CON_AXIS1 | CON_AXIS2):
- copy_v3_v3(r_vec, axismtx[0]);
+ copy_v3_v3(r_axis, axismtx[0]);
break;
case CON_AXIS1:
case (CON_AXIS0 | CON_AXIS2):
- copy_v3_v3(r_vec, axismtx[1]);
+ copy_v3_v3(r_axis, axismtx[1]);
break;
case CON_AXIS2:
case (CON_AXIS0 | CON_AXIS1):
- copy_v3_v3(r_vec, axismtx[2]);
+ copy_v3_v3(r_axis, axismtx[2]);
break;
}
/* don't flip axis if asked to or if num input */
@@ -576,7 +582,7 @@ static void constraints_rotation_impl(TransInfo *t,
!((mode & CON_NOFLIP) || hasNumInput(&t->num) || (t->flag & T_INPUT_IS_VALUES_FINAL))) {
float view_vector[3];
view_vector_calc(t, t->center_global, view_vector);
- if (dot_v3v3(r_vec, view_vector) > 0.0f) {
+ if (dot_v3v3(r_axis, view_vector) > 0.0f) {
*r_angle = -(*r_angle);
}
}
@@ -595,11 +601,14 @@ static void constraints_rotation_impl(TransInfo *t,
* This insures that the rotation is always logically following the mouse.
* (ie: not doing counterclockwise rotations when the mouse moves clockwise).
*/
-static void applyAxisConstraintRot(
- TransInfo *t, TransDataContainer *UNUSED(tc), TransData *td, float vec[3], float *angle)
+static void applyAxisConstraintRot(const TransInfo *t,
+ const TransDataContainer *UNUSED(tc),
+ TransData *td,
+ float r_axis[3],
+ float *r_angle)
{
if (!td && t->con.mode & CON_APPLY) {
- constraints_rotation_impl(t, t->spacemtx, vec, angle);
+ constraints_rotation_impl(t, t->spacemtx, r_axis, r_angle);
}
}
@@ -616,8 +625,11 @@ static void applyAxisConstraintRot(
* This insures that the rotation is always logically following the mouse.
* (ie: not doing counterclockwise rotations when the mouse moves clockwise).
*/
-static void applyObjectConstraintRot(
- TransInfo *t, TransDataContainer *tc, TransData *td, float vec[3], float *angle)
+static void applyObjectConstraintRot(const TransInfo *t,
+ const TransDataContainer *tc,
+ TransData *td,
+ float r_axis[3],
+ float *r_angle)
{
if (t->con.mode & CON_APPLY) {
float tmp_axismtx[3][3];
@@ -638,7 +650,7 @@ static void applyObjectConstraintRot(
axismtx = td->axismtx;
}
- constraints_rotation_impl(t, axismtx, vec, angle);
+ constraints_rotation_impl(t, axismtx, r_axis, r_angle);
}
}
@@ -1138,7 +1150,7 @@ int constraintModeToIndex(const TransInfo *t)
}
}
-bool isLockConstraint(TransInfo *t)
+bool isLockConstraint(const TransInfo *t)
{
int mode = t->con.mode;
@@ -1164,7 +1176,7 @@ bool isLockConstraint(TransInfo *t)
* even if they aren't actually used in the callback function.
* (Which could happen for weird constraints not yet designed. Along a path for example.)
*/
-int getConstraintSpaceDimension(TransInfo *t)
+int getConstraintSpaceDimension(const TransInfo *t)
{
int n = 0;
diff --git a/source/blender/editors/transform/transform_constraints.h b/source/blender/editors/transform/transform_constraints.h
index ac62c057f9d..3632b352476 100644
--- a/source/blender/editors/transform/transform_constraints.h
+++ b/source/blender/editors/transform/transform_constraints.h
@@ -46,5 +46,5 @@ void postSelectConstraint(TransInfo *t);
void setNearestAxis(TransInfo *t);
int constraintModeToIndex(const TransInfo *t);
char constraintModeToChar(const TransInfo *t);
-bool isLockConstraint(TransInfo *t);
-int getConstraintSpaceDimension(TransInfo *t);
+bool isLockConstraint(const TransInfo *t);
+int getConstraintSpaceDimension(const TransInfo *t);
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index 9e285dd2d26..00fd008151d 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -816,7 +816,7 @@ bool constraints_list_needinv(TransInfo *t, ListBase *list)
/* only consider constraint if it is enabled, and has influence on result */
if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) {
/* (affirmative) returns for specific constraints here... */
- /* constraints that require this regardless */
+ /* constraints that require this regardless. */
if (ELEM(con->type,
CONSTRAINT_TYPE_FOLLOWPATH,
CONSTRAINT_TYPE_CLAMPTO,
@@ -849,10 +849,13 @@ bool constraints_list_needinv(TransInfo *t, ListBase *list)
/* Copy Transforms constraint only does this in the Before mode. */
bTransLikeConstraint *data = (bTransLikeConstraint *)con->data;
- if (ELEM(data->mix_mode, TRANSLIKE_MIX_BEFORE) &&
+ if (ELEM(data->mix_mode, TRANSLIKE_MIX_BEFORE, TRANSLIKE_MIX_BEFORE_FULL) &&
ELEM(t->mode, TFM_ROTATION, TFM_TRANSLATION)) {
return true;
}
+ if (ELEM(data->mix_mode, TRANSLIKE_MIX_BEFORE_SPLIT) && ELEM(t->mode, TFM_ROTATION)) {
+ return true;
+ }
}
else if (con->type == CONSTRAINT_TYPE_ACTION) {
/* The Action constraint only does this in the Before mode. */
diff --git a/source/blender/editors/transform/transform_convert.h b/source/blender/editors/transform/transform_convert.h
index 918ce0739ed..971c23b8c69 100644
--- a/source/blender/editors/transform/transform_convert.h
+++ b/source/blender/editors/transform/transform_convert.h
@@ -48,8 +48,8 @@ void clipUVData(TransInfo *t);
void transform_convert_mesh_customdatacorrect_init(TransInfo *t);
/* transform_convert_sequencer.c */
-int transform_convert_sequencer_get_snap_bound(TransInfo *t);
-void transform_convert_sequencer_channel_clamp(TransInfo *t);
+void transform_convert_sequencer_channel_clamp(TransInfo *t, float r_val[2]);
+
/********************* intern **********************/
/* transform_convert.c */
diff --git a/source/blender/editors/transform/transform_convert_action.c b/source/blender/editors/transform/transform_convert_action.c
index 8204264e105..cfa14e21d0d 100644
--- a/source/blender/editors/transform/transform_convert_action.c
+++ b/source/blender/editors/transform/transform_convert_action.c
@@ -191,7 +191,7 @@ static TransData *ActionFCurveToTransData(TransData *td,
td->flag |= TD_SELECTED;
}
- /*set flags to move handles as necessary*/
+ /* Set flags to move handles as necessary. */
td->flag |= TD_MOVEHANDLE1 | TD_MOVEHANDLE2;
td2d->h1 = bezt->vec[0];
td2d->h2 = bezt->vec[2];
@@ -210,12 +210,13 @@ static TransData *ActionFCurveToTransData(TransData *td,
return td;
}
-/* This function advances the address to which td points to, so it must return
+/**
+ * This function advances the address to which td points to, so it must return
* the new address so that the next time new transform data is added, it doesn't
- * overwrite the existing ones... i.e. td = GPLayerToTransData(td, ipo, ob, side, cfra);
+ * overwrite the existing ones: e.g. `td += GPLayerToTransData(td, ...);`
*
- * The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
- * on the named side are used.
+ * \param side: is needed for the extend mode. 'B' = both sides,
+ * 'R'/'L' mean only data on the named side are used.
*/
static int GPLayerToTransData(TransData *td,
tGPFtransdata *tfd,
@@ -242,7 +243,7 @@ static int GPLayerToTransData(TransData *td,
tfd->val = (float)gpf->framenum;
tfd->sdata = &gpf->framenum;
- /* advance td now */
+ /* Advance `td` now. */
td++;
tfd++;
count++;
@@ -339,7 +340,7 @@ void createTransActionData(bContext *C, TransInfo *t)
t->frame_side = 'B';
}
- /* loop 1: fully select ipo-keys and count how many BezTriples are selected */
+ /* loop 1: fully select F-curve keys and count how many BezTriples are selected */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
int adt_count = 0;
@@ -554,7 +555,7 @@ void createTransActionData(bContext *C, TransInfo *t)
/** \name Action Transform Flush
* \{ */
-/* This function helps flush transdata written to tempdata into the gp-frames */
+/* This function helps flush transdata written to tempdata into the gp-frames. */
static void flushTransIntFrameActionData(TransInfo *t)
{
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
diff --git a/source/blender/editors/transform/transform_convert_armature.c b/source/blender/editors/transform/transform_convert_armature.c
index f29f323558a..1f1b1f8db97 100644
--- a/source/blender/editors/transform/transform_convert_armature.c
+++ b/source/blender/editors/transform/transform_convert_armature.c
@@ -1610,10 +1610,10 @@ static short apply_targetless_ik(Object *ob)
Bone *bone;
float mat[4][4];
- /* pose_mat(b) = pose_mat(b-1) * offs_bone * channel * constraint * IK */
- /* we put in channel the entire result of mat = (channel * constraint * IK) */
- /* pose_mat(b) = pose_mat(b-1) * offs_bone * mat */
- /* mat = pose_mat(b) * inv(pose_mat(b-1) * offs_bone ) */
+ /* `pose_mat(b) = pose_mat(b-1) * offs_bone * channel * constraint * IK` */
+ /* We put in channel the entire result of: `mat = (channel * constraint * IK)` */
+ /* `pose_mat(b) = pose_mat(b-1) * offs_bone * mat` */
+ /* `mat = pose_mat(b) * inv(pose_mat(b-1) * offs_bone)` */
parchan = chanlist[segcount - 1];
bone = parchan->bone;
diff --git a/source/blender/editors/transform/transform_convert_curve.c b/source/blender/editors/transform/transform_convert_curve.c
index cc3091ae70e..575e0da21a4 100644
--- a/source/blender/editors/transform/transform_convert_curve.c
+++ b/source/blender/editors/transform/transform_convert_curve.c
@@ -278,7 +278,7 @@ void createTransCurveVerts(TransInfo *t)
td->ext = NULL;
/* TODO - make points scale */
- if (t->mode == TFM_CURVE_SHRINKFATTEN) { /* || t->mode==TFM_RESIZE) {*/
+ if (t->mode == TFM_CURVE_SHRINKFATTEN /* `|| t->mode == TFM_RESIZE` */) {
td->val = &(bezt->radius);
td->ival = bezt->radius;
}
diff --git a/source/blender/editors/transform/transform_convert_gpencil.c b/source/blender/editors/transform/transform_convert_gpencil.c
index 4932a5f8d23..f7b78b10868 100644
--- a/source/blender/editors/transform/transform_convert_gpencil.c
+++ b/source/blender/editors/transform/transform_convert_gpencil.c
@@ -176,7 +176,7 @@ static void createTransGPencil_curves(bContext *C,
}
}
- /* If not multiedit out of loop. */
+ /* If not multi-edit out of loop. */
if (!is_multiedit) {
break;
}
@@ -382,7 +382,7 @@ static void createTransGPencil_curves(bContext *C,
}
}
- /* If not multiedit out of loop. */
+ /* If not multi-edit out of loop. */
if (!is_multiedit) {
break;
}
@@ -470,7 +470,7 @@ static void createTransGPencil_strokes(bContext *C,
}
}
}
- /* If not multiedit out of loop. */
+ /* If not multi-edit out of loop. */
if (!is_multiedit) {
break;
}
@@ -674,7 +674,7 @@ static void createTransGPencil_strokes(bContext *C,
}
}
}
- /* if not multiedit out of loop */
+ /* If not multi-edit out of loop. */
if (!is_multiedit) {
break;
}
diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c
index 4c674136b6a..de2f96c0f97 100644
--- a/source/blender/editors/transform/transform_convert_mesh.c
+++ b/source/blender/editors/transform/transform_convert_mesh.c
@@ -27,6 +27,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_alloca.h"
+#include "BLI_bitmap.h"
#include "BLI_linklist_stack.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
@@ -59,16 +60,52 @@ static void tc_mesh_customdata_free_fn(struct TransInfo *t,
struct TransCustomDataLayer;
static void tc_mesh_customdatacorrect_free(struct TransCustomDataLayer *tcld);
+struct TransCustomData_PartialUpdate {
+ struct BMPartialUpdate *cache;
+
+ /** The size of proportional editing used for #BMPartialUpdate. */
+ float prop_size;
+ /** The size of proportional editing for the last update. */
+ float prop_size_prev;
+};
+
+/**
+ * \note It's important to order from least to greatest (which updates more data),
+ * since the larger values are used when values change between updates
+ * (which can happen when rotation is enabled with snapping).
+ */
+enum ePartialType {
+ PARTIAL_NONE = -1,
+ /**
+ * Update only faces between tagged and non-tagged faces (affine transformations).
+ * Use when transforming is guaranteed not to change the relative locations of vertices.
+ *
+ * This has the advantage that selecting the entire mesh or only isolated elements,
+ * can skip normal/tessellation updates entirely, so it's worth using when possible.
+ */
+ PARTIAL_TYPE_GROUP = 0,
+ /**
+ * Update for all tagged vertices (any kind of deformation).
+ * Use as a default since it can be used with any kind of deformation.
+ */
+ PARTIAL_TYPE_ALL = 1,
+};
+
+#define PARTIAL_TYPE_MAX 2
+
+/**
+ * Settings used for a single update,
+ * use for comparison with previous updates.
+ */
+struct PartialTypeState {
+ enum ePartialType for_looptri;
+ enum ePartialType for_normals;
+};
+
struct TransCustomDataMesh {
struct TransCustomDataLayer *cd_layer_correct;
- struct {
- struct BMPartialUpdate *cache;
-
- /** The size of proportional editing used for `partial_update_cache`. */
- float prop_size;
- /** The size of proportional editing for the last update. */
- float prop_size_prev;
- } partial_update;
+ struct TransCustomData_PartialUpdate partial_update[PARTIAL_TYPE_MAX];
+ struct PartialTypeState partial_update_state_prev;
};
static struct TransCustomDataMesh *tc_mesh_customdata_ensure(TransDataContainer *tc)
@@ -80,6 +117,8 @@ static struct TransCustomDataMesh *tc_mesh_customdata_ensure(TransDataContainer
tc->custom.type.data = MEM_callocN(sizeof(struct TransCustomDataMesh), __func__);
tc->custom.type.free_cb = tc_mesh_customdata_free_fn;
tcmd = tc->custom.type.data;
+ tcmd->partial_update_state_prev.for_looptri = PARTIAL_NONE;
+ tcmd->partial_update_state_prev.for_normals = PARTIAL_NONE;
}
return tcmd;
}
@@ -90,8 +129,10 @@ static void tc_mesh_customdata_free(struct TransCustomDataMesh *tcmd)
tc_mesh_customdatacorrect_free(tcmd->cd_layer_correct);
}
- if (tcmd->partial_update.cache != NULL) {
- BM_mesh_partial_destroy(tcmd->partial_update.cache);
+ for (int i = 0; i < ARRAY_SIZE(tcmd->partial_update); i++) {
+ if (tcmd->partial_update[i].cache != NULL) {
+ BM_mesh_partial_destroy(tcmd->partial_update[i].cache);
+ }
}
MEM_freeN(tcmd);
@@ -1676,19 +1717,18 @@ void createTransEditVerts(TransInfo *t)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Recalc Mesh Data
+/** \name Recalc Mesh Data (Partial Update)
* \{ */
-static bool bm_vert_tag_filter_fn(BMVert *v, void *UNUSED(user_data))
-{
- return BM_elem_flag_test(v, BM_ELEM_TAG);
-}
-
-static BMPartialUpdate *tc_mesh_ensure_partial_update(TransInfo *t, TransDataContainer *tc)
+static BMPartialUpdate *tc_mesh_partial_ensure(TransInfo *t,
+ TransDataContainer *tc,
+ enum ePartialType partial_type)
{
struct TransCustomDataMesh *tcmd = tc_mesh_customdata_ensure(tc);
- if (tcmd->partial_update.cache) {
+ struct TransCustomData_PartialUpdate *pupdate = &tcmd->partial_update[partial_type];
+
+ if (pupdate->cache) {
/* Recalculate partial update data when the proportional editing size changes.
*
@@ -1699,80 +1739,299 @@ static BMPartialUpdate *tc_mesh_ensure_partial_update(TransInfo *t, TransDataCon
* Extra logic is needed to account for this situation. */
bool recalc;
- if (tcmd->partial_update.prop_size_prev < t->prop_size) {
+ if (pupdate->prop_size_prev < t->prop_size) {
/* Size increase, simply recalculate. */
recalc = true;
}
- else if (tcmd->partial_update.prop_size_prev > t->prop_size) {
+ else if (pupdate->prop_size_prev > t->prop_size) {
/* Size decreased, first use this partial data since reducing the size will transform
* geometry which needs recalculating. */
- tcmd->partial_update.prop_size_prev = t->prop_size;
+ pupdate->prop_size_prev = t->prop_size;
recalc = false;
}
- else if (tcmd->partial_update.prop_size != t->prop_size) {
- BLI_assert(tcmd->partial_update.prop_size > tcmd->partial_update.prop_size_prev);
+ else if (pupdate->prop_size != t->prop_size) {
+ BLI_assert(pupdate->prop_size > pupdate->prop_size_prev);
recalc = true;
}
else {
- BLI_assert(t->prop_size == tcmd->partial_update.prop_size_prev);
+ BLI_assert(t->prop_size == pupdate->prop_size_prev);
recalc = false;
}
if (!recalc) {
- return tcmd->partial_update.cache;
+ return pupdate->cache;
}
- BM_mesh_partial_destroy(tcmd->partial_update.cache);
- tcmd->partial_update.cache = NULL;
+ BM_mesh_partial_destroy(pupdate->cache);
+ pupdate->cache = NULL;
}
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
- BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
+ BM_mesh_elem_index_ensure(em->bm, BM_VERT);
- int verts_len = 0;
- int i;
- TransData *td;
- for (i = 0, td = tc->data; i < tc->data_len; i++, td++) {
- if (td->factor != 0.0f) {
- BMVert *v = (BMVert *)td->extra;
- BM_elem_flag_enable(v, BM_ELEM_TAG);
- verts_len += 1;
+ /* Only use `verts_group` or `verts_mask`. */
+ int *verts_group = NULL;
+ int verts_group_count = 0; /* Number of non-zero elements in `verts_group`. */
+
+ BLI_bitmap *verts_mask = NULL;
+ int verts_mask_count = 0; /* Number of elements enabled in `verts_mask`. */
+
+ if ((partial_type == PARTIAL_TYPE_GROUP) &&
+ ((t->flag & T_PROP_EDIT) || tc->use_mirror_axis_any)) {
+ verts_group = MEM_callocN(sizeof(*verts_group) * em->bm->totvert, __func__);
+ int i;
+ TransData *td;
+ for (i = 0, td = tc->data; i < tc->data_len; i++, td++) {
+ if (td->factor == 0.0f) {
+ continue;
+ }
+ const BMVert *v = (BMVert *)td->extra;
+ const int v_index = BM_elem_index_get(v);
+ BLI_assert(verts_group[v_index] == 0);
+ if (td->factor < 1.0f) {
+ /* Don't use grouping logic with the factor is under 1.0. */
+ verts_group[v_index] = -1;
+ }
+ else {
+ BLI_assert(td->factor == 1.0f);
+ verts_group[v_index] = 1;
+ if (tc->use_mirror_axis_any) {
+ /* Use bits 2-4 for central alignment (don't overlap the first bit). */
+ const int flag = td->flag & (TD_MIRROR_EDGE_X | TD_MIRROR_EDGE_Y | TD_MIRROR_EDGE_Z);
+ verts_group[v_index] |= (flag >> TD_MIRROR_EDGE_AXIS_SHIFT) << 1;
+ }
+ }
+ verts_mask_count += 1;
}
- }
- TransDataMirror *td_mirror = tc->data_mirror;
- for (i = 0; i < tc->data_mirror_len; i++, td_mirror++) {
- BMVert *v_mirr = (BMVert *)POINTER_OFFSET(td_mirror->loc_src, -offsetof(BMVert, co));
+ TransDataMirror *td_mirror = tc->data_mirror;
+ for (i = 0; i < tc->data_mirror_len; i++, td_mirror++) {
+ BMVert *v_mirr = (BMVert *)POINTER_OFFSET(td_mirror->loc_src, -offsetof(BMVert, co));
+ /* The equality check is to account for the case when topology mirror moves
+ * the vertex from it's original location to match it's symmetrical position,
+ * with proportional editing enabled. */
+ const int v_mirr_index = BM_elem_index_get(v_mirr);
+ if (verts_group[v_mirr_index] == 0 && equals_v3v3(td_mirror->loc, td_mirror->iloc)) {
+ continue;
+ }
- /* The equality check is to account for the case when topology mirror moves
- * the vertex from it's original location to match it's symmetrical position,
- * with proportional editing enabled. */
- if (BM_elem_flag_test(v_mirr, BM_ELEM_TAG) || !equals_v3v3(td_mirror->loc, td_mirror->iloc)) {
BMVert *v_mirr_other = (BMVert *)td_mirror->extra;
/* This assert should never fail since there is no overlap
* between mirrored vertices and non-mirrored. */
- BLI_assert(!BM_elem_flag_test(v_mirr_other, BM_ELEM_TAG));
- BM_elem_flag_enable(v_mirr_other, BM_ELEM_TAG);
- verts_len += 1;
+ BLI_assert(verts_group[BM_elem_index_get(v_mirr_other)] == 0);
+ const int v_mirr_other_index = BM_elem_index_get(v_mirr_other);
+
+ if (verts_group[v_mirr_index] == -1) {
+ verts_group[v_mirr_other_index] = -1;
+ }
+ else {
+ /* Use bits 5-8 for mirror (don't overlap previous bits). */
+ const int flag = td_mirror->flag & (TD_MIRROR_X | TD_MIRROR_Y | TD_MIRROR_Z);
+ verts_group[v_mirr_other_index] |= (flag >> TD_MIRROR_EDGE_AXIS_SHIFT) << 4;
+ }
+ verts_mask_count += 1;
+ }
+ }
+ else {
+ /* See the body of the comments in the previous block for details. */
+ verts_mask = BLI_BITMAP_NEW(em->bm->totvert, __func__);
+ int i;
+ TransData *td;
+ for (i = 0, td = tc->data; i < tc->data_len; i++, td++) {
+ if (td->factor == 0.0f) {
+ continue;
+ }
+ const BMVert *v = (BMVert *)td->extra;
+ const int v_index = BM_elem_index_get(v);
+ BLI_assert(!BLI_BITMAP_TEST(verts_mask, v_index));
+ BLI_BITMAP_ENABLE(verts_mask, v_index);
+ verts_mask_count += 1;
+ }
+
+ TransDataMirror *td_mirror = tc->data_mirror;
+ for (i = 0; i < tc->data_mirror_len; i++, td_mirror++) {
+ BMVert *v_mirr = (BMVert *)POINTER_OFFSET(td_mirror->loc_src, -offsetof(BMVert, co));
+ if (!BLI_BITMAP_TEST(verts_mask, BM_elem_index_get(v_mirr)) &&
+ equals_v3v3(td_mirror->loc, td_mirror->iloc)) {
+ continue;
+ }
+
+ BMVert *v_mirr_other = (BMVert *)td_mirror->extra;
+ BLI_assert(!BLI_BITMAP_TEST(verts_mask, BM_elem_index_get(v_mirr_other)));
+ const int v_mirr_other_index = BM_elem_index_get(v_mirr_other);
+ BLI_BITMAP_ENABLE(verts_mask, v_mirr_other_index);
+ verts_mask_count += 1;
+ }
+ }
+
+ switch (partial_type) {
+ case PARTIAL_TYPE_ALL: {
+ pupdate->cache = BM_mesh_partial_create_from_verts(em->bm,
+ &(BMPartialUpdate_Params){
+ .do_tessellate = true,
+ .do_normals = true,
+ },
+ verts_mask,
+ verts_mask_count);
+ break;
+ }
+ case PARTIAL_TYPE_GROUP: {
+ pupdate->cache =
+ (verts_group ? BM_mesh_partial_create_from_verts_group_multi(em->bm,
+ &(BMPartialUpdate_Params){
+ .do_tessellate = true,
+ .do_normals = true,
+ },
+ verts_group,
+ verts_group_count) :
+ BM_mesh_partial_create_from_verts_group_single(em->bm,
+ &(BMPartialUpdate_Params){
+ .do_tessellate = true,
+ .do_normals = true,
+ },
+ verts_mask,
+ verts_mask_count));
+ break;
+ }
+ case PARTIAL_NONE: {
+ BLI_assert_unreachable();
+ }
+ }
+
+ if (verts_group) {
+ MEM_freeN(verts_group);
+ }
+ else {
+ MEM_freeN(verts_mask);
+ }
+
+ pupdate->prop_size_prev = t->prop_size;
+ pupdate->prop_size = t->prop_size;
+
+ return pupdate->cache;
+}
+
+static void tc_mesh_partial_types_calc(TransInfo *t, struct PartialTypeState *r_partial_state)
+{
+ /* Calculate the kind of partial updates which can be performed. */
+ enum ePartialType partial_for_normals = PARTIAL_NONE;
+ enum ePartialType partial_for_looptri = PARTIAL_NONE;
+
+ /* Note that operations such as #TFM_CREASE are not handled here
+ * (if they were, leaving as #PARTIAL_NONE would be appropriate). */
+ switch (t->mode) {
+ case TFM_TRANSLATION: {
+ partial_for_looptri = PARTIAL_TYPE_GROUP;
+ partial_for_normals = PARTIAL_TYPE_GROUP;
+ /* Translation can rotate when snapping to normal. */
+ if (activeSnap(t) && usingSnappingNormal(t) && validSnappingNormal(t)) {
+ partial_for_normals = PARTIAL_TYPE_ALL;
+ }
+ break;
+ }
+ case TFM_ROTATION: {
+ partial_for_looptri = PARTIAL_TYPE_GROUP;
+ partial_for_normals = PARTIAL_TYPE_ALL;
+ break;
+ }
+ case TFM_RESIZE: {
+ partial_for_looptri = PARTIAL_TYPE_GROUP;
+ partial_for_normals = PARTIAL_TYPE_GROUP;
+ /* Non-uniform scale needs to recalculate all normals
+ * since their relative locations change.
+ * Uniform negative scale can keep normals as-is since the faces are flipped,
+ * normals remain unchanged. */
+ if ((t->con.mode & CON_APPLY) ||
+ (t->values_final[0] != t->values_final[1] || t->values_final[0] != t->values_final[2])) {
+ partial_for_normals = PARTIAL_TYPE_ALL;
+ }
+ break;
+ }
+ default: {
+ partial_for_looptri = PARTIAL_TYPE_ALL;
+ partial_for_normals = PARTIAL_TYPE_ALL;
+ break;
+ }
+ }
+
+ /* With projection, transform isn't affine. */
+ if (activeSnap_with_project(t)) {
+ if (partial_for_looptri == PARTIAL_TYPE_GROUP) {
+ partial_for_looptri = PARTIAL_TYPE_ALL;
+ }
+ if (partial_for_normals == PARTIAL_TYPE_GROUP) {
+ partial_for_normals = PARTIAL_TYPE_ALL;
}
}
- tcmd->partial_update.cache = BM_mesh_partial_create_from_verts(em->bm,
- &(BMPartialUpdate_Params){
- .do_tessellate = true,
- .do_normals = true,
- },
- verts_len,
- bm_vert_tag_filter_fn,
- NULL);
+ r_partial_state->for_looptri = partial_for_looptri;
+ r_partial_state->for_normals = partial_for_normals;
+}
+
+static void tc_mesh_partial_update(TransInfo *t,
+ TransDataContainer *tc,
+ const struct PartialTypeState *partial_state)
+{
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
- tcmd->partial_update.prop_size_prev = t->prop_size;
- tcmd->partial_update.prop_size = t->prop_size;
+ struct TransCustomDataMesh *tcmd = tc_mesh_customdata_ensure(tc);
- return tcmd->partial_update.cache;
+ const struct PartialTypeState *partial_state_prev = &tcmd->partial_update_state_prev;
+
+ /* Promote the partial update types based on the previous state
+ * so the values that no longer modified are reset before being left as-is.
+ * Needed for translation which can toggle snap-to-normal during transform. */
+ const enum ePartialType partial_for_looptri = MAX2(partial_state->for_looptri,
+ partial_state_prev->for_looptri);
+ const enum ePartialType partial_for_normals = MAX2(partial_state->for_normals,
+ partial_state_prev->for_normals);
+
+ if ((partial_for_looptri == PARTIAL_TYPE_ALL) && (partial_for_normals == PARTIAL_TYPE_ALL) &&
+ (em->bm->totvert == em->bm->totvertsel)) {
+ /* The additional cost of generating the partial connectivity data isn't justified
+ * when all data needs to be updated.
+ *
+ * While proportional editing can cause all geometry to need updating with a partial
+ * selection. It's impractical to calculate this ahead of time. Further, the down side of
+ * using partial updates when their not needed is negligible. */
+ BKE_editmesh_looptri_and_normals_calc(em);
+ }
+ else {
+ if (partial_for_looptri != PARTIAL_NONE) {
+ BMPartialUpdate *bmpinfo = tc_mesh_partial_ensure(t, tc, partial_for_looptri);
+ BKE_editmesh_looptri_calc_with_partial_ex(em,
+ bmpinfo,
+ &(const struct BMeshCalcTessellation_Params){
+ .face_normals = true,
+ });
+ }
+
+ if (partial_for_normals != PARTIAL_NONE) {
+ BMPartialUpdate *bmpinfo = tc_mesh_partial_ensure(t, tc, partial_for_normals);
+ /* While not a large difference, take advantage of existing normals where possible. */
+ const bool face_normals = !((partial_for_looptri == PARTIAL_TYPE_ALL) ||
+ ((partial_for_looptri == PARTIAL_TYPE_GROUP) &&
+ (partial_for_normals == PARTIAL_TYPE_GROUP)));
+ BM_mesh_normals_update_with_partial_ex(em->bm,
+ bmpinfo,
+ &(const struct BMeshNormalsUpdate_Params){
+ .face_normals = face_normals,
+ });
+ }
+ }
+
+ /* Store the previous requested (not the previous used),
+ * since the values used may have been promoted based on the previous types. */
+ tcmd->partial_update_state_prev = *partial_state;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Recalc Mesh Data
+ * \{ */
+
static void tc_mesh_transdata_mirror_apply(TransDataContainer *tc)
{
if (tc->use_mirror_axis_any) {
@@ -1831,23 +2090,13 @@ void recalcData_mesh(TransInfo *t)
tc_mesh_customdatacorrect_restore(t);
}
+ struct PartialTypeState partial_state;
+ tc_mesh_partial_types_calc(t, &partial_state);
+
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
DEG_id_tag_update(tc->obedit->data, ID_RECALC_GEOMETRY);
- BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
- /* The additional cost of generating the partial connectivity data isn't justified
- * when all data needs to be updated.
- *
- * While proportional editing can cause all geometry to need updating with a partial selection.
- * It's impractical to calculate this ahead of time.
- * Further, the down side of using partial updates when their not needed is negligible. */
- if (em->bm->totvert == em->bm->totvertsel) {
- BKE_editmesh_looptri_and_normals_calc(em);
- }
- else {
- BMPartialUpdate *partial_update_cache = tc_mesh_ensure_partial_update(t, tc);
- BKE_editmesh_looptri_and_normals_calc_with_partial(em, partial_update_cache);
- }
+ tc_mesh_partial_update(t, tc, &partial_state);
}
}
/** \} */
diff --git a/source/blender/editors/transform/transform_convert_sequencer.c b/source/blender/editors/transform/transform_convert_sequencer.c
index a67d18db37b..a6f5aba5a1d 100644
--- a/source/blender/editors/transform/transform_convert_sequencer.c
+++ b/source/blender/editors/transform/transform_convert_sequencer.c
@@ -63,9 +63,6 @@ typedef struct TransDataSeq {
*/
typedef struct TransSeq {
TransDataSeq *tdseq;
- int min;
- int max;
- bool snap_left;
int selection_channel_range_min;
int selection_channel_range_max;
} TransSeq;
@@ -252,42 +249,6 @@ static int SeqToTransData_build(
return tot;
}
-static void SeqTransDataBounds(TransInfo *t, ListBase *seqbase, TransSeq *ts)
-{
- Sequence *seq;
- int count, flag;
- int max = INT32_MIN, min = INT32_MAX;
-
- for (seq = seqbase->first; seq; seq = seq->next) {
-
- /* just to get the flag since there are corner cases where this isn't totally obvious */
- SeqTransInfo(t, seq, &count, &flag);
-
- /* use 'flag' which is derived from seq->flag but modified for special cases */
- if (flag & SELECT) {
- if (flag & (SEQ_LEFTSEL | SEQ_RIGHTSEL)) {
- if (flag & SEQ_LEFTSEL) {
- min = min_ii(seq->startdisp, min);
- max = max_ii(seq->startdisp, max);
- }
- if (flag & SEQ_RIGHTSEL) {
- min = min_ii(seq->enddisp, min);
- max = max_ii(seq->enddisp, max);
- }
- }
- else {
- min = min_ii(seq->startdisp, min);
- max = max_ii(seq->enddisp, max);
- }
- }
- }
-
- if (ts) {
- ts->max = max;
- ts->min = min;
- }
-}
-
static void free_transform_custom_data(TransCustomData *custom_data)
{
if ((custom_data->data != NULL) && custom_data->use_free) {
@@ -320,7 +281,7 @@ static bool seq_transform_check_overlap(SeqCollection *transformed_strips)
static SeqCollection *extract_standalone_strips(SeqCollection *transformed_strips)
{
- SeqCollection *collection = SEQ_collection_create();
+ SeqCollection *collection = SEQ_collection_create(__func__);
Sequence *seq;
SEQ_ITERATOR_FOREACH (seq, transformed_strips) {
if ((seq->type & SEQ_TYPE_EFFECT) == 0 || seq->seq1 == NULL) {
@@ -341,7 +302,7 @@ static SeqCollection *query_right_side_strips(ListBase *seqbase, SeqCollection *
}
}
- SeqCollection *collection = SEQ_collection_create();
+ SeqCollection *collection = SEQ_collection_create(__func__);
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
if ((seq->flag & SELECT) == 0 && seq->startdisp >= minframe) {
SEQ_collection_append_strip(seq, collection);
@@ -446,7 +407,7 @@ static void seq_transform_handle_overlap(TransInfo *t, SeqCollection *transforme
static SeqCollection *seq_transform_collection_from_transdata(TransDataContainer *tc)
{
- SeqCollection *collection = SEQ_collection_create();
+ SeqCollection *collection = SEQ_collection_create(__func__);
TransData *td = tc->data;
for (int a = 0; a < tc->data_len; a++, td++) {
Sequence *seq = ((TransDataSeq *)td->extra)->seq;
@@ -465,8 +426,9 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
SeqCollection *transformed_strips = seq_transform_collection_from_transdata(tc);
- if ((t->state == TRANS_CANCEL)) {
+ if (t->state == TRANS_CANCEL) {
seq_transform_cancel(t, transformed_strips);
+ SEQ_collection_free(transformed_strips);
free_transform_custom_data(custom_data);
return;
}
@@ -544,15 +506,6 @@ void createTransSeqData(TransInfo *t)
/* loop 2: build transdata array */
SeqToTransData_build(t, ed->seqbasep, td, td2d, tdsq);
- SeqTransDataBounds(t, ed->seqbasep, ts);
-
- if (t->flag & T_MODAL) {
- /* set the snap mode based on how close the mouse is at the end/start points */
- int xmouse = (int)UI_view2d_region_to_view_x((View2D *)t->view, t->mouse.imval[0]);
- if (abs(xmouse - ts->max) > abs(xmouse - ts->min)) {
- ts->snap_left = true;
- }
- }
ts->selection_channel_range_min = MAXSEQ + 1;
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
@@ -599,7 +552,7 @@ static void flushTransSeq(TransInfo *t)
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
- /* flush to 2d vector from internally used 3d vector */
+ /* Flush to 2D vector from internally used 3D vector. */
for (a = 0, td = tc->data, td2d = tc->data_2d; a < tc->data_len; a++, td++, td2d++) {
tdsq = (TransDataSeq *)td->extra;
seq = tdsq->seq;
@@ -615,13 +568,13 @@ static void flushTransSeq(TransInfo *t)
CLAMP(seq->machine, 1, MAXSEQ);
break;
- case SEQ_LEFTSEL: /* no vertical transform */
+ case SEQ_LEFTSEL: /* No vertical transform. */
SEQ_transform_set_left_handle_frame(seq, new_frame);
SEQ_transform_handle_xlimits(seq, tdsq->flag & SEQ_LEFTSEL, tdsq->flag & SEQ_RIGHTSEL);
SEQ_transform_fix_single_image_seq_offsets(seq);
SEQ_time_update_sequence(t->scene, seq);
break;
- case SEQ_RIGHTSEL: /* no vertical transform */
+ case SEQ_RIGHTSEL: /* No vertical transform. */
SEQ_transform_set_right_handle_frame(seq, new_frame);
SEQ_transform_handle_xlimits(seq, tdsq->flag & SEQ_LEFTSEL, tdsq->flag & SEQ_RIGHTSEL);
SEQ_transform_fix_single_image_seq_offsets(seq);
@@ -719,25 +672,19 @@ void special_aftertrans_update__sequencer(bContext *UNUSED(C), TransInfo *t)
}
}
-void transform_convert_sequencer_channel_clamp(TransInfo *t)
+void transform_convert_sequencer_channel_clamp(TransInfo *t, float r_val[2])
{
const TransSeq *ts = (TransSeq *)TRANS_DATA_CONTAINER_FIRST_SINGLE(t)->custom.type.data;
- const int channel_offset = round_fl_to_int(t->values[1]);
+ const int channel_offset = round_fl_to_int(r_val[1]);
const int min_channel_after_transform = ts->selection_channel_range_min + channel_offset;
const int max_channel_after_transform = ts->selection_channel_range_max + channel_offset;
if (max_channel_after_transform > MAXSEQ) {
- t->values[1] -= max_channel_after_transform - MAXSEQ;
+ r_val[1] -= max_channel_after_transform - MAXSEQ;
}
if (min_channel_after_transform < 1) {
- t->values[1] -= min_channel_after_transform - 1;
+ r_val[1] -= min_channel_after_transform - 1;
}
}
-int transform_convert_sequencer_get_snap_bound(TransInfo *t)
-{
- TransSeq *ts = TRANS_DATA_CONTAINER_FIRST_SINGLE(t)->custom.type.data;
- return ts->snap_left ? ts->min : ts->max;
-}
-
/** \} */
diff --git a/source/blender/editors/transform/transform_data.h b/source/blender/editors/transform/transform_data.h
index 5b01433c96b..606453e356b 100644
--- a/source/blender/editors/transform/transform_data.h
+++ b/source/blender/editors/transform/transform_data.h
@@ -149,6 +149,8 @@ typedef struct TransData {
short protectflag;
} TransData;
+#define TRANSDATA_THREAD_LIMIT 1024
+
/** #TransData.flag */
enum {
TD_SELECTED = 1 << 0,
@@ -173,10 +175,12 @@ enum {
/** For Graph Editor - curves that can only have int-values
* need their keyframes tagged with this. */
TD_INTVALUES = 1 << 11,
+#define TD_MIRROR_AXIS_SHIFT 12
/** For editmode mirror. */
TD_MIRROR_X = 1 << 12,
TD_MIRROR_Y = 1 << 13,
TD_MIRROR_Z = 1 << 14,
+#define TD_MIRROR_EDGE_AXIS_SHIFT 12
/** For editmode mirror, clamp axis to 0 */
TD_MIRROR_EDGE_X = 1 << 12,
TD_MIRROR_EDGE_Y = 1 << 13,
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 71c91221fbb..9e048a0ca1d 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -353,13 +353,11 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->around = V3D_AROUND_CENTER_BOUNDS;
}
- BLI_assert(is_zero_v4(t->values_modal_offset));
-
bool t_values_set_is_array = false;
if (op && (prop = RNA_struct_find_property(op->ptr, "value")) &&
RNA_property_is_set(op->ptr, prop)) {
- float values[4] = {0}; /* in case value isn't length 4, avoid uninitialized memory */
+ float values[4] = {0}; /* in case value isn't length 4, avoid uninitialized memory. */
if (RNA_property_array_check(prop)) {
RNA_float_get_array(op->ptr, "value", values);
t_values_set_is_array = true;
@@ -368,7 +366,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
values[0] = RNA_float_get(op->ptr, "value");
}
- copy_v4_v4(t->values, values);
if (t->flag & T_MODAL) {
/* Run before init functions so 'values_modal_offset' can be applied on mouse input. */
copy_v4_v4(t->values_modal_offset, values);
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 7a780df0def..080a19cce1f 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -521,7 +521,7 @@ static void protectflag_to_drawflags_pchan(RegionView3D *rv3d,
}
}
-/* for editmode*/
+/* For editmode. */
static void protectflag_to_drawflags_ebone(RegionView3D *rv3d, const EditBone *ebo)
{
if (ebo->flag & BONE_EDITMODE_LOCKED) {
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 414199badd7..0b46d0b9a13 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -450,17 +450,6 @@ void applyMouseInput(TransInfo *t, MouseInput *mi, const int mval[2], float outp
mi->apply(t, mi, mval_db, output);
}
- if (!is_zero_v3(t->values_modal_offset)) {
- float values_ofs[3];
- if (t->con.mode & CON_APPLY) {
- mul_v3_m3v3(values_ofs, t->spacemtx, t->values_modal_offset);
- }
- else {
- copy_v3_v3(values_ofs, t->values_modal_offset);
- }
- add_v3_v3(t->values, values_ofs);
- }
-
if (mi->post) {
mi->post(t, output);
}
diff --git a/source/blender/editors/transform/transform_mode.c b/source/blender/editors/transform/transform_mode.c
index 6a946994e06..65a673940f8 100644
--- a/source/blender/editors/transform/transform_mode.c
+++ b/source/blender/editors/transform/transform_mode.c
@@ -68,7 +68,7 @@ int transform_mode_really_used(bContext *C, int mode)
return mode;
}
-bool transdata_check_local_center(TransInfo *t, short around)
+bool transdata_check_local_center(const TransInfo *t, short around)
{
return ((around == V3D_AROUND_LOCAL_ORIGINS) &&
((t->options & (CTX_OBJECT | CTX_POSE_BONE)) ||
@@ -248,7 +248,7 @@ void protectedSizeBits(short protectflag, float size[3])
/** \name Transform Limits
* \{ */
-void constraintTransLim(TransInfo *t, TransData *td)
+void constraintTransLim(const TransInfo *t, TransData *td)
{
if (td->con) {
const bConstraintTypeInfo *ctiLoc = BKE_constraint_typeinfo_from_type(
@@ -359,7 +359,7 @@ static void constraintob_from_transdata(bConstraintOb *cob, TransData *td)
}
}
-static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
+static void constraintRotLim(const TransInfo *UNUSED(t), TransData *td)
{
if (td->con) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_ROTLIMIT);
@@ -432,7 +432,7 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
}
}
-void constraintSizeLim(TransInfo *t, TransData *td)
+void constraintSizeLim(const TransInfo *t, TransData *td)
{
if (td->con && td->ext) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_SIZELIMIT);
@@ -557,8 +557,8 @@ void headerRotation(TransInfo *t, char *str, const int str_size, float final)
*
* Protected axis and other transform settings are taken into account.
*/
-void ElementRotation_ex(TransInfo *t,
- TransDataContainer *tc,
+void ElementRotation_ex(const TransInfo *t,
+ const TransDataContainer *tc,
TransData *td,
const float mat[3][3],
const float *center)
@@ -810,8 +810,11 @@ void ElementRotation_ex(TransInfo *t,
}
}
-void ElementRotation(
- TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3], const short around)
+void ElementRotation(const TransInfo *t,
+ const TransDataContainer *tc,
+ TransData *td,
+ const float mat[3][3],
+ const short around)
{
const float *center;
@@ -921,7 +924,10 @@ static void TransMat3ToSize(const float mat[3][3], const float smat[3][3], float
}
}
-void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3])
+void ElementResize(const TransInfo *t,
+ const TransDataContainer *tc,
+ TransData *td,
+ const float mat[3][3])
{
float tmat[3][3], smat[3][3], center[3];
float vec[3];
@@ -1014,17 +1020,31 @@ void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float ma
sub_v3_v3(vec, td->center);
}
- /* grease pencil falloff */
+ /* Grease pencil falloff.
+ *
+ * FIXME: This is bad on multiple levels!
+ *
+ * - #applyNumInput is not intended to be run for every element,
+ * this writes back into the number input in a way that doesn't make sense to run many times.
+ *
+ * - Writing into #TransInfo should be avoided since it means order of operations
+ * may impact the result and isn't thread-safe.
+ *
+ * Operating on copies as a temporary solution.
+ */
if (t->options & CTX_GPENCIL_STROKES) {
bGPDstroke *gps = (bGPDstroke *)td->extra;
mul_v3_fl(vec, td->factor * gps->runtime.multi_frame_falloff);
- /* scale stroke thickness */
+ /* Scale stroke thickness. */
if (td->val) {
- transform_snap_increment(t, t->values_final);
- applyNumInput(&t->num, t->values_final);
+ NumInput num_evil = t->num;
+ float values_final_evil[4];
+ copy_v4_v4(values_final_evil, t->values_final);
+ transform_snap_increment(t, values_final_evil);
+ applyNumInput(&num_evil, values_final_evil);
- float ratio = t->values_final[0];
+ float ratio = values_final_evil[0];
*td->val = td->ival * ratio * gps->runtime.multi_frame_falloff;
CLAMP_MIN(*td->val, 0.001f);
}
@@ -1044,6 +1064,7 @@ void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float ma
constraintTransLim(t, td);
}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/editors/transform/transform_mode.h b/source/blender/editors/transform/transform_mode.h
index a2b95eb3de4..027fb6b6982 100644
--- a/source/blender/editors/transform/transform_mode.h
+++ b/source/blender/editors/transform/transform_mode.h
@@ -41,22 +41,28 @@ typedef struct TransDataGenericSlideVert {
/* transform_mode.c */
int transform_mode_really_used(struct bContext *C, int mode);
-bool transdata_check_local_center(TransInfo *t, short around);
+bool transdata_check_local_center(const TransInfo *t, short around);
bool transform_mode_is_changeable(const int mode);
void protectedTransBits(short protectflag, float vec[3]);
void protectedSizeBits(short protectflag, float size[3]);
-void constraintTransLim(TransInfo *t, TransData *td);
-void constraintSizeLim(TransInfo *t, TransData *td);
+void constraintTransLim(const TransInfo *t, TransData *td);
+void constraintSizeLim(const TransInfo *t, TransData *td);
void headerRotation(TransInfo *t, char *str, int str_size, float final);
-void ElementRotation_ex(TransInfo *t,
- TransDataContainer *tc,
+void ElementRotation_ex(const TransInfo *t,
+ const TransDataContainer *tc,
TransData *td,
const float mat[3][3],
const float *center);
-void ElementRotation(
- TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3], const short around);
+void ElementRotation(const TransInfo *t,
+ const TransDataContainer *tc,
+ TransData *td,
+ const float mat[3][3],
+ const short around);
void headerResize(TransInfo *t, const float vec[3], char *str, int str_size);
-void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3]);
+void ElementResize(const TransInfo *t,
+ const TransDataContainer *tc,
+ TransData *td,
+ const float mat[3][3]);
short getAnimEdit_SnapMode(TransInfo *t);
void doAnimEdit_SnapFrame(
TransInfo *t, TransData *td, TransData2D *td2d, struct AnimData *adt, short autosnap);
diff --git a/source/blender/editors/transform/transform_mode_bend.c b/source/blender/editors/transform/transform_mode_bend.c
index b3b1860f9ec..850d26571cd 100644
--- a/source/blender/editors/transform/transform_mode_bend.c
+++ b/source/blender/editors/transform/transform_mode_bend.c
@@ -29,6 +29,7 @@
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_task.h"
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -47,9 +48,12 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/** \name Transform (Bend)
+/** \name Transform (Bend) Custom Data
* \{ */
+/**
+ * Custom data, stored in #TransInfo.custom.mode.data
+ */
struct BendCustomData {
/* All values are in global space. */
float warp_sta[3];
@@ -62,6 +66,122 @@ struct BendCustomData {
float warp_init_dist;
};
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Transform (Bend) Element
+ * \{ */
+
+/**
+ * \note Small arrays / data-structures should be copied for faster memory access.
+ */
+struct TransDataArgs_Bend {
+ const TransInfo *t;
+ const TransDataContainer *tc;
+
+ float angle;
+ struct BendCustomData bend_data;
+
+ const float warp_sta_local[3];
+ const float warp_end_local[3];
+ const float warp_end_radius_local[3];
+ const float pivot_local[3];
+ bool is_clamp;
+};
+
+static void transdata_elem_bend(const TransInfo *t,
+ const TransDataContainer *tc,
+ TransData *td,
+ float angle,
+ const struct BendCustomData *bend_data,
+ const float warp_sta_local[3],
+ const float UNUSED(warp_end_local[3]),
+ const float warp_end_radius_local[3],
+ const float pivot_local[3],
+
+ bool is_clamp)
+{
+ if (UNLIKELY(angle == 0.0f)) {
+ copy_v3_v3(td->loc, td->iloc);
+ return;
+ }
+
+ float vec[3];
+ float mat[3][3];
+ float delta[3];
+ float fac, fac_scaled;
+
+ copy_v3_v3(vec, td->iloc);
+ mul_m3_v3(td->mtx, vec);
+
+ fac = line_point_factor_v3(vec, warp_sta_local, warp_end_radius_local);
+ if (is_clamp) {
+ CLAMP(fac, 0.0f, 1.0f);
+ }
+
+ if (t->options & CTX_GPENCIL_STROKES) {
+ /* grease pencil multiframe falloff */
+ bGPDstroke *gps = (bGPDstroke *)td->extra;
+ if (gps != NULL) {
+ fac_scaled = fac * td->factor * gps->runtime.multi_frame_falloff;
+ }
+ else {
+ fac_scaled = fac * td->factor;
+ }
+ }
+ else {
+ fac_scaled = fac * td->factor;
+ }
+
+ axis_angle_normalized_to_mat3(mat, bend_data->warp_nor, angle * fac_scaled);
+ interp_v3_v3v3(delta, warp_sta_local, warp_end_radius_local, fac_scaled);
+ sub_v3_v3(delta, warp_sta_local);
+
+ /* delta is subtracted, rotation adds back this offset */
+ sub_v3_v3(vec, delta);
+
+ sub_v3_v3(vec, pivot_local);
+ mul_m3_v3(mat, vec);
+ add_v3_v3(vec, pivot_local);
+
+ mul_m3_v3(td->smtx, vec);
+
+ /* rotation */
+ if ((t->flag & T_POINTS) == 0) {
+ ElementRotation(t, tc, td, mat, V3D_AROUND_LOCAL_ORIGINS);
+ }
+
+ /* location */
+ copy_v3_v3(td->loc, vec);
+}
+
+static void transdata_elem_bend_fn(void *__restrict iter_data_v,
+ const int iter,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ struct TransDataArgs_Bend *data = iter_data_v;
+ TransData *td = &data->tc->data[iter];
+ if (td->flag & TD_SKIP) {
+ return;
+ }
+ transdata_elem_bend(data->t,
+ data->tc,
+ td,
+ data->angle,
+ &data->bend_data,
+ data->warp_sta_local,
+ data->warp_end_local,
+ data->warp_end_radius_local,
+ data->pivot_local,
+ data->is_clamp);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Transform (Bend)
+ * \{ */
+
static eRedrawFlag handleEventBend(TransInfo *UNUSED(t), const wmEvent *event)
{
eRedrawFlag status = TREDRAW_NOTHING;
@@ -75,12 +195,11 @@ static eRedrawFlag handleEventBend(TransInfo *UNUSED(t), const wmEvent *event)
static void Bend(TransInfo *t, const int UNUSED(mval[2]))
{
- float vec[3];
float pivot_global[3];
float warp_end_radius_global[3];
int i;
char str[UI_MAX_DRAW_STR];
- const struct BendCustomData *data = t->custom.mode.data;
+ const struct BendCustomData *bend_data = t->custom.mode.data;
const bool is_clamp = (t->flag & T_ALT_TRANSFORM) == 0;
union {
@@ -100,7 +219,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
* this isn't essential but nicer to give reasonable snapping values for radius. */
if (t->tsnap.mode & SCE_SNAP_MODE_INCREMENT) {
const float radius_snap = 0.1f;
- const float snap_hack = (t->snap[0] * data->warp_init_dist) / radius_snap;
+ const float snap_hack = (t->snap[0] * bend_data->warp_init_dist) / radius_snap;
values.scale *= snap_hack;
transform_snap_increment(t, values.vector);
values.scale /= snap_hack;
@@ -108,7 +227,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
#endif
if (applyNumInput(&t->num, values.vector)) {
- values.scale = values.scale / data->warp_init_dist;
+ values.scale = values.scale / bend_data->warp_init_dist;
}
copy_v2_v2(t->values_final, values.vector);
@@ -132,34 +251,33 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
sizeof(str),
TIP_("Bend Angle: %.3f Radius: %.4f, Alt, Clamp %s"),
RAD2DEGF(values.angle),
- values.scale * data->warp_init_dist,
+ values.scale * bend_data->warp_init_dist,
WM_bool_as_string(is_clamp));
}
values.angle *= -1.0f;
- values.scale *= data->warp_init_dist;
+ values.scale *= bend_data->warp_init_dist;
/* calc 'data->warp_end' from 'data->warp_end_init' */
- copy_v3_v3(warp_end_radius_global, data->warp_end);
- dist_ensure_v3_v3fl(warp_end_radius_global, data->warp_sta, values.scale);
+ copy_v3_v3(warp_end_radius_global, bend_data->warp_end);
+ dist_ensure_v3_v3fl(warp_end_radius_global, bend_data->warp_sta, values.scale);
/* done */
/* calculate pivot */
- copy_v3_v3(pivot_global, data->warp_sta);
+ copy_v3_v3(pivot_global, bend_data->warp_sta);
if (values.angle > 0.0f) {
madd_v3_v3fl(pivot_global,
- data->warp_tan,
+ bend_data->warp_tan,
-values.scale * shell_angle_to_dist((float)M_PI_2 - values.angle));
}
else {
madd_v3_v3fl(pivot_global,
- data->warp_tan,
+ bend_data->warp_tan,
+values.scale * shell_angle_to_dist((float)M_PI_2 + values.angle));
}
/* TODO(campbell): xform, compensate object center. */
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
float warp_sta_local[3];
float warp_end_local[3];
@@ -167,74 +285,52 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
float pivot_local[3];
if (tc->use_local_mat) {
- sub_v3_v3v3(warp_sta_local, data->warp_sta, tc->mat[3]);
- sub_v3_v3v3(warp_end_local, data->warp_end, tc->mat[3]);
+ sub_v3_v3v3(warp_sta_local, bend_data->warp_sta, tc->mat[3]);
+ sub_v3_v3v3(warp_end_local, bend_data->warp_end, tc->mat[3]);
sub_v3_v3v3(warp_end_radius_local, warp_end_radius_global, tc->mat[3]);
sub_v3_v3v3(pivot_local, pivot_global, tc->mat[3]);
}
else {
- copy_v3_v3(warp_sta_local, data->warp_sta);
- copy_v3_v3(warp_end_local, data->warp_end);
+ copy_v3_v3(warp_sta_local, bend_data->warp_sta);
+ copy_v3_v3(warp_end_local, bend_data->warp_end);
copy_v3_v3(warp_end_radius_local, warp_end_radius_global);
copy_v3_v3(pivot_local, pivot_global);
}
- for (i = 0; i < tc->data_len; i++, td++) {
- float mat[3][3];
- float delta[3];
- float fac, fac_scaled;
-
- if (td->flag & TD_SKIP) {
- continue;
- }
+ if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
+ TransData *td = tc->data;
- if (UNLIKELY(values.angle == 0.0f)) {
- copy_v3_v3(td->loc, td->iloc);
- continue;
- }
-
- copy_v3_v3(vec, td->iloc);
- mul_m3_v3(td->mtx, vec);
-
- fac = line_point_factor_v3(vec, warp_sta_local, warp_end_radius_local);
- if (is_clamp) {
- CLAMP(fac, 0.0f, 1.0f);
- }
-
- if (t->options & CTX_GPENCIL_STROKES) {
- /* grease pencil multiframe falloff */
- bGPDstroke *gps = (bGPDstroke *)td->extra;
- if (gps != NULL) {
- fac_scaled = fac * td->factor * gps->runtime.multi_frame_falloff;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SKIP) {
+ continue;
}
- else {
- fac_scaled = fac * td->factor;
- }
- }
- else {
- fac_scaled = fac * td->factor;
+ transdata_elem_bend(t,
+ tc,
+ td,
+ values.angle,
+ bend_data,
+ warp_sta_local,
+ warp_end_local,
+ warp_end_radius_local,
+ pivot_local,
+ is_clamp);
}
-
- axis_angle_normalized_to_mat3(mat, data->warp_nor, values.angle * fac_scaled);
- interp_v3_v3v3(delta, warp_sta_local, warp_end_radius_local, fac_scaled);
- sub_v3_v3(delta, warp_sta_local);
-
- /* delta is subtracted, rotation adds back this offset */
- sub_v3_v3(vec, delta);
-
- sub_v3_v3(vec, pivot_local);
- mul_m3_v3(mat, vec);
- add_v3_v3(vec, pivot_local);
-
- mul_m3_v3(td->smtx, vec);
-
- /* rotation */
- if ((t->flag & T_POINTS) == 0) {
- ElementRotation(t, tc, td, mat, V3D_AROUND_LOCAL_ORIGINS);
- }
-
- /* location */
- copy_v3_v3(td->loc, vec);
+ }
+ else {
+ struct TransDataArgs_Bend data = {
+ .t = t,
+ .tc = tc,
+ .angle = values.angle,
+ .bend_data = *bend_data,
+ .warp_sta_local = {UNPACK3(warp_sta_local)},
+ .warp_end_local = {UNPACK3(warp_end_local)},
+ .warp_end_radius_local = {UNPACK3(warp_end_radius_local)},
+ .pivot_local = {UNPACK3(pivot_local)},
+ .is_clamp = is_clamp,
+ };
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ BLI_task_parallel_range(0, tc->data_len, &data, transdata_elem_bend_fn, &settings);
}
}
diff --git a/source/blender/editors/transform/transform_mode_edge_bevelweight.c b/source/blender/editors/transform/transform_mode_edge_bevelweight.c
index 3ce52ed3296..425bfec241e 100644
--- a/source/blender/editors/transform/transform_mode_edge_bevelweight.c
+++ b/source/blender/editors/transform/transform_mode_edge_bevelweight.c
@@ -25,6 +25,7 @@
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_task.h"
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -40,6 +41,50 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
+/** \name Transform (Bevel Weight) Element
+ * \{ */
+
+/**
+ * \note Small arrays / data-structures should be stored copied for faster memory access.
+ */
+struct TransDataArgs_BevelWeight {
+ const TransInfo *t;
+ const TransDataContainer *tc;
+ float weight;
+};
+
+static void transdata_elem_bevel_weight(const TransInfo *UNUSED(t),
+ const TransDataContainer *UNUSED(tc),
+ TransData *td,
+ const float weight)
+{
+ if (td->val == NULL) {
+ return;
+ }
+ *td->val = td->ival + weight * td->factor;
+ if (*td->val < 0.0f) {
+ *td->val = 0.0f;
+ }
+ if (*td->val > 1.0f) {
+ *td->val = 1.0f;
+ }
+}
+
+static void transdata_elem_bevel_weight_fn(void *__restrict iter_data_v,
+ const int iter,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ struct TransDataArgs_BevelWeight *data = iter_data_v;
+ TransData *td = &data->tc->data[iter];
+ if (td->flag & TD_SKIP) {
+ return;
+ }
+ transdata_elem_bevel_weight(data->t, data->tc, td, data->weight);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (Bevel Weight)
* \{ */
@@ -83,18 +128,25 @@ static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2]))
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++) {
- if (td->val) {
- *td->val = td->ival + weight * td->factor;
- if (*td->val < 0.0f) {
- *td->val = 0.0f;
- }
- if (*td->val > 1.0f) {
- *td->val = 1.0f;
+ if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SKIP) {
+ continue;
}
+ transdata_elem_bevel_weight(t, tc, td, weight);
}
}
+ else {
+ struct TransDataArgs_BevelWeight data = {
+ .t = t,
+ .tc = tc,
+ .weight = weight,
+ };
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ BLI_task_parallel_range(0, tc->data_len, &data, transdata_elem_bevel_weight_fn, &settings);
+ }
}
recalcData(t);
diff --git a/source/blender/editors/transform/transform_mode_edge_crease.c b/source/blender/editors/transform/transform_mode_edge_crease.c
index 23fa20b68ff..91e2507e544 100644
--- a/source/blender/editors/transform/transform_mode_edge_crease.c
+++ b/source/blender/editors/transform/transform_mode_edge_crease.c
@@ -25,6 +25,7 @@
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_task.h"
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -40,6 +41,51 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
+/** \name Transform (Crease) Element
+ * \{ */
+
+/**
+ * \note Small arrays / data-structures should be stored copied for faster memory access.
+ */
+struct TransDataArgs_Crease {
+ const TransInfo *t;
+ const TransDataContainer *tc;
+ float crease;
+};
+
+static void transdata_elem_crease(const TransInfo *UNUSED(t),
+ const TransDataContainer *UNUSED(tc),
+ TransData *td,
+ const float crease)
+{
+ if (td->val == NULL) {
+ return;
+ }
+
+ *td->val = td->ival + crease * td->factor;
+ if (*td->val < 0.0f) {
+ *td->val = 0.0f;
+ }
+ if (*td->val > 1.0f) {
+ *td->val = 1.0f;
+ }
+}
+
+static void transdata_elem_crease_fn(void *__restrict iter_data_v,
+ const int iter,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ struct TransDataArgs_Crease *data = iter_data_v;
+ TransData *td = &data->tc->data[iter];
+ if (td->flag & TD_SKIP) {
+ return;
+ }
+ transdata_elem_crease(data->t, data->tc, td, data->crease);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (Crease)
* \{ */
@@ -83,22 +129,25 @@ static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_SKIP) {
- continue;
- }
-
- if (td->val) {
- *td->val = td->ival + crease * td->factor;
- if (*td->val < 0.0f) {
- *td->val = 0.0f;
- }
- if (*td->val > 1.0f) {
- *td->val = 1.0f;
+ if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SKIP) {
+ continue;
}
+ transdata_elem_crease(t, tc, td, crease);
}
}
+ else {
+ struct TransDataArgs_Crease data = {
+ .t = t,
+ .tc = tc,
+ .crease = crease,
+ };
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ BLI_task_parallel_range(0, tc->data_len, &data, transdata_elem_crease_fn, &settings);
+ }
}
recalcData(t);
@@ -124,4 +173,5 @@ void initCrease(TransInfo *t)
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
}
+
/** \} */
diff --git a/source/blender/editors/transform/transform_mode_edge_seq_slide.c b/source/blender/editors/transform/transform_mode_edge_seq_slide.c
index 7e7b79c9f90..fe853440c96 100644
--- a/source/blender/editors/transform/transform_mode_edge_seq_slide.c
+++ b/source/blender/editors/transform/transform_mode_edge_seq_slide.c
@@ -23,8 +23,10 @@
#include <stdlib.h>
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_string.h"
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -37,6 +39,10 @@
#include "UI_interface.h"
#include "UI_view2d.h"
+#include "SEQ_iterator.h"
+#include "SEQ_sequencer.h"
+#include "SEQ_time.h"
+
#include "BLT_translation.h"
#include "transform.h"
@@ -102,13 +108,11 @@ static void applySeqSlideValue(TransInfo *t, const float val[2])
}
}
-static void applySeqSlide(TransInfo *t, const int mval[2])
+static void applySeqSlide(TransInfo *t, const int UNUSED(mval[2]))
{
char str[UI_MAX_DRAW_STR];
float values_final[3] = {0.0f};
- snapSequenceBounds(t, mval);
- transform_convert_sequencer_channel_clamp(t);
if (applyNumInput(&t->num, values_final)) {
if (t->con.mode & CON_APPLY) {
if (t->con.mode & CON_AXIS0) {
@@ -119,11 +123,14 @@ static void applySeqSlide(TransInfo *t, const int mval[2])
}
}
}
- else if (t->con.mode & CON_APPLY) {
- t->con.applyVec(t, NULL, NULL, t->values, values_final);
- }
else {
copy_v2_v2(values_final, t->values);
+ applySnapping(t, values_final);
+ transform_convert_sequencer_channel_clamp(t, values_final);
+
+ if (t->con.mode & CON_APPLY) {
+ t->con.applyVec(t, NULL, NULL, t->values, values_final);
+ }
}
values_final[0] = floorf(values_final[0] + 0.5f);
@@ -142,6 +149,7 @@ void initSeqSlide(TransInfo *t)
{
t->transform = applySeqSlide;
t->handleEvent = seq_slide_handleEvent;
+ t->tsnap.applySnap = transform_snap_sequencer_apply_translate;
initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
@@ -164,4 +172,5 @@ void initSeqSlide(TransInfo *t)
t->custom.mode.data = (void *)WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_TRANSLATE);
}
}
+
/** \} */
diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c b/source/blender/editors/transform/transform_mode_edge_slide.c
index d255a7d5660..6134c8a98f5 100644
--- a/source/blender/editors/transform/transform_mode_edge_slide.c
+++ b/source/blender/editors/transform/transform_mode_edge_slide.c
@@ -375,8 +375,8 @@ static void calcEdgeSlide_mval_range(TransInfo *t,
UNUSED_VARS_NDEBUG(sv_table); /* silence warning */
BLI_assert(i == sv_table[BM_elem_index_get(v)]);
- /* search cross edges for visible edge to the mouse cursor,
- * then use the shared vertex to calculate screen vector*/
+ /* Search cross edges for visible edge to the mouse cursor,
+ * then use the shared vertex to calculate screen vector. */
BM_ITER_ELEM (e, &iter_other, v, BM_EDGES_OF_VERT) {
/* screen-space coords */
float sco_a[3], sco_b[3];
@@ -540,7 +540,7 @@ static EdgeSlideData *createEdgeSlideVerts_double_side(TransInfo *t, TransDataCo
sld->curr_sv_index = 0;
- /*ensure valid selection*/
+ /* Ensure valid selection. */
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
BMIter iter2;
@@ -548,7 +548,7 @@ static EdgeSlideData *createEdgeSlideVerts_double_side(TransInfo *t, TransDataCo
BM_ITER_ELEM (e, &iter2, v, BM_EDGES_OF_VERT) {
if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
/* BMESH_TODO: this is probably very evil,
- * set v->e to a selected edge*/
+ * set `v->e` to a selected edge. */
v->e = e;
numsel++;
@@ -640,10 +640,10 @@ static EdgeSlideData *createEdgeSlideVerts_double_side(TransInfo *t, TransDataCo
v_first = v;
- /*walk along the edge loop*/
+ /* Walk along the edge loop. */
e = v->e;
- /*first, rewind*/
+ /* First, rewind. */
do {
e = get_other_edge(v, e);
if (!e) {
@@ -709,7 +709,7 @@ static EdgeSlideData *createEdgeSlideVerts_double_side(TransInfo *t, TransDataCo
STACK_PUSH_RET_PTR(sv_array)) : \
(&sv_array[sv_table[BM_elem_index_get(v)]]))
- /*iterate over the loop*/
+ /* Iterate over the loop. */
v_first = v;
do {
bool l_a_ok_prev;
@@ -1220,7 +1220,7 @@ void drawEdgeSlide(TransInfo *t)
immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
immBegin(GPU_PRIM_LINES, sld->totsv * 2);
- /* TODO(campbell): Loop over all verts */
+ /* TODO(campbell): Loop over all verts. */
sv = sld->sv;
for (i = 0; i < sld->totsv; i++, sv++) {
float a[3], b[3];
diff --git a/source/blender/editors/transform/transform_mode_push_pull.c b/source/blender/editors/transform/transform_mode_push_pull.c
index b08e479a3d0..0492ec8df8c 100644
--- a/source/blender/editors/transform/transform_mode_push_pull.c
+++ b/source/blender/editors/transform/transform_mode_push_pull.c
@@ -25,6 +25,7 @@
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_task.h"
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -41,12 +42,82 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
+/** \name Transform (Push/Pull) Element
+ * \{ */
+
+/**
+ * \note Small arrays / data-structures should be stored copied for faster memory access.
+ */
+struct TransDataArgs_PushPull {
+ const TransInfo *t;
+ const TransDataContainer *tc;
+
+ float distance;
+ const float axis_global[3];
+ bool is_lock_constraint;
+ bool is_data_space;
+};
+
+static void transdata_elem_push_pull(const TransInfo *t,
+ const TransDataContainer *tc,
+ TransData *td,
+ const float distance,
+ const float axis_global[3],
+ const bool is_lock_constraint,
+ const bool is_data_space)
+{
+ float vec[3];
+ sub_v3_v3v3(vec, tc->center_local, td->center);
+ if (t->con.applyRot && t->con.mode & CON_APPLY) {
+ float axis[3];
+ copy_v3_v3(axis, axis_global);
+ t->con.applyRot(t, tc, td, axis, NULL);
+
+ mul_m3_v3(td->smtx, axis);
+ if (is_lock_constraint) {
+ float dvec[3];
+ project_v3_v3v3(dvec, vec, axis);
+ sub_v3_v3(vec, dvec);
+ }
+ else {
+ project_v3_v3v3(vec, vec, axis);
+ }
+ }
+ normalize_v3_length(vec, distance * td->factor);
+ if (is_data_space) {
+ mul_m3_v3(td->smtx, vec);
+ }
+
+ add_v3_v3v3(td->loc, td->iloc, vec);
+}
+
+static void transdata_elem_push_pull_fn(void *__restrict iter_data_v,
+ const int iter,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ struct TransDataArgs_PushPull *data = iter_data_v;
+ TransData *td = &data->tc->data[iter];
+ if (td->flag & TD_SKIP) {
+ return;
+ }
+ transdata_elem_push_pull(data->t,
+ data->tc,
+ td,
+ data->distance,
+ data->axis_global,
+ data->is_lock_constraint,
+ data->is_data_space);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (Push/Pull)
* \{ */
static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
{
- float vec[3], axis_global[3];
+ float axis_global[3];
float distance;
int i;
char str[UI_MAX_DRAW_STR];
@@ -77,37 +148,31 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
t->con.applyRot(t, NULL, NULL, axis_global, NULL);
}
+ const bool is_lock_constraint = isLockConstraint(t);
const bool is_data_space = (t->options & CTX_POSE_BONE) != 0;
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_SKIP) {
- continue;
- }
-
- sub_v3_v3v3(vec, tc->center_local, td->center);
- if (t->con.applyRot && t->con.mode & CON_APPLY) {
- float axis[3];
- copy_v3_v3(axis, axis_global);
- t->con.applyRot(t, tc, td, axis, NULL);
-
- mul_m3_v3(td->smtx, axis);
- if (isLockConstraint(t)) {
- float dvec[3];
- project_v3_v3v3(dvec, vec, axis);
- sub_v3_v3(vec, dvec);
- }
- else {
- project_v3_v3v3(vec, vec, axis);
+ if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SKIP) {
+ continue;
}
+ transdata_elem_push_pull(
+ t, tc, td, distance, axis_global, is_lock_constraint, is_data_space);
}
- normalize_v3_length(vec, distance * td->factor);
- if (is_data_space) {
- mul_m3_v3(td->smtx, vec);
- }
-
- add_v3_v3v3(td->loc, td->iloc, vec);
+ }
+ else {
+ struct TransDataArgs_PushPull data = {
+ .t = t,
+ .tc = tc,
+ .axis_global = {UNPACK3(axis_global)},
+ .is_lock_constraint = is_lock_constraint,
+ .is_data_space = is_data_space,
+ };
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ BLI_task_parallel_range(0, tc->data_len, &data, transdata_elem_push_pull_fn, &settings);
}
}
diff --git a/source/blender/editors/transform/transform_mode_resize.c b/source/blender/editors/transform/transform_mode_resize.c
index 1d7d1369f29..65f4623b3be 100644
--- a/source/blender/editors/transform/transform_mode_resize.c
+++ b/source/blender/editors/transform/transform_mode_resize.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include "BLI_math.h"
+#include "BLI_task.h"
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -39,6 +40,30 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
+/** \name Transform (Resize) Element
+ * \{ */
+
+struct ElemResizeData {
+ const TransInfo *t;
+ const TransDataContainer *tc;
+ float mat[3][3];
+};
+
+static void element_resize_fn(void *__restrict iter_data_v,
+ const int iter,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ struct ElemResizeData *data = iter_data_v;
+ TransData *td = &data->tc->data[iter];
+ if (td->flag & TD_SKIP) {
+ return;
+ }
+ ElementResize(data->t, data->tc, td, data->mat);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (Resize)
* \{ */
@@ -88,6 +113,7 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
float ratio = t->values[0];
copy_v3_fl(t->values_final, ratio);
+ add_v3_v3(t->values_final, t->values_modal_offset);
transform_snap_increment(t, t->values_final);
@@ -122,13 +148,27 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
copy_m3_m3(t->mat, mat); /* used in gizmo */
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_SKIP) {
- continue;
- }
- ElementResize(t, tc, td, mat);
+ if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SKIP) {
+ continue;
+ }
+
+ ElementResize(t, tc, td, mat);
+ }
+ }
+ else {
+ struct ElemResizeData data = {
+ .t = t,
+ .tc = tc,
+ };
+ copy_m3_m3(data.mat, mat);
+
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ BLI_task_parallel_range(0, tc->data_len, &data, element_resize_fn, &settings);
}
}
diff --git a/source/blender/editors/transform/transform_mode_rotate.c b/source/blender/editors/transform/transform_mode_rotate.c
index 8350e94e0e8..44a29cfac45 100644
--- a/source/blender/editors/transform/transform_mode_rotate.c
+++ b/source/blender/editors/transform/transform_mode_rotate.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include "BLI_math.h"
+#include "BLI_task.h"
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -37,6 +38,140 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
+/** \name Transform (Rotation) Matrix Cache
+ * \{ */
+
+struct RotateMatrixCache {
+ /**
+ * Counter for needed updates (when we need to update to non-default matrix,
+ * we also need another update on next iteration to go back to default matrix,
+ * hence the '2' value used here, instead of a mere boolean).
+ */
+ short do_update_matrix;
+ float mat[3][3];
+};
+
+static void rmat_cache_init(struct RotateMatrixCache *rmc, const float angle, const float axis[3])
+{
+ axis_angle_normalized_to_mat3(rmc->mat, axis, angle);
+ rmc->do_update_matrix = 0;
+}
+
+static void rmat_cache_reset(struct RotateMatrixCache *rmc)
+{
+ rmc->do_update_matrix = 2;
+}
+
+static void rmat_cache_update(struct RotateMatrixCache *rmc,
+ const float axis[3],
+ const float angle)
+{
+ if (rmc->do_update_matrix > 0) {
+ axis_angle_normalized_to_mat3(rmc->mat, axis, angle);
+ rmc->do_update_matrix--;
+ }
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Transform (Rotation) Element
+ * \{ */
+
+/**
+ * \note Small arrays / data-structures should be stored copied for faster memory access.
+ */
+struct TransDataArgs_Rotate {
+ const TransInfo *t;
+ const TransDataContainer *tc;
+ const float axis[3];
+ float angle;
+ float angle_step;
+ bool is_large_rotation;
+};
+
+struct TransDataArgs_RotateTLS {
+ struct RotateMatrixCache rmc;
+};
+
+static void transdata_elem_rotate(const TransInfo *t,
+ const TransDataContainer *tc,
+ TransData *td,
+ const float axis[3],
+ const float angle,
+ const float angle_step,
+ const bool is_large_rotation,
+ struct RotateMatrixCache *rmc)
+{
+ float axis_buffer[3];
+ const float *axis_final = axis;
+
+ float angle_final = angle;
+ if (t->con.applyRot) {
+ copy_v3_v3(axis_buffer, axis);
+ axis_final = axis_buffer;
+ t->con.applyRot(t, tc, td, axis_buffer, NULL);
+ angle_final = angle * td->factor;
+ /* Even though final angle might be identical to orig value,
+ * we have to update the rotation matrix in that case... */
+ rmat_cache_reset(rmc);
+ }
+ else if (t->flag & T_PROP_EDIT) {
+ angle_final = angle * td->factor;
+ }
+
+ /* Rotation is very likely to be above 180°, we need to do rotation by steps.
+ * Note that this is only needed when doing 'absolute' rotation
+ * (i.e. from initial rotation again, typically when using numinput).
+ * regular incremental rotation (from mouse/widget/...) will be called often enough,
+ * hence steps are small enough to be properly handled without that complicated trick.
+ * Note that we can only do that kind of stepped rotation if we have initial rotation values
+ * (and access to some actual rotation value storage).
+ * Otherwise, just assume it's useless (e.g. in case of mesh/UV/etc. editing).
+ * Also need to be in Euler rotation mode, the others never allow more than one turn anyway.
+ */
+ if (is_large_rotation && td->ext != NULL && td->ext->rotOrder == ROT_MODE_EUL) {
+ copy_v3_v3(td->ext->rot, td->ext->irot);
+ for (float angle_progress = angle_step; fabsf(angle_progress) < fabsf(angle_final);
+ angle_progress += angle_step) {
+ axis_angle_normalized_to_mat3(rmc->mat, axis_final, angle_progress);
+ ElementRotation(t, tc, td, rmc->mat, t->around);
+ }
+ rmat_cache_reset(rmc);
+ }
+ else if (angle_final != angle) {
+ rmat_cache_reset(rmc);
+ }
+
+ rmat_cache_update(rmc, axis_final, angle_final);
+
+ ElementRotation(t, tc, td, rmc->mat, t->around);
+}
+
+static void transdata_elem_rotate_fn(void *__restrict iter_data_v,
+ const int iter,
+ const TaskParallelTLS *__restrict tls)
+{
+ struct TransDataArgs_Rotate *data = iter_data_v;
+ struct TransDataArgs_RotateTLS *tls_data = tls->userdata_chunk;
+
+ TransData *td = &data->tc->data[iter];
+ if (td->flag & TD_SKIP) {
+ return;
+ }
+ transdata_elem_rotate(data->t,
+ data->tc,
+ td,
+ data->axis,
+ data->angle,
+ data->angle_step,
+ data->is_large_rotation,
+ &tls_data->rmc);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (Rotation)
* \{ */
@@ -115,12 +250,9 @@ static float large_rotation_limit(float angle)
static void applyRotationValue(TransInfo *t,
float angle,
- float axis[3],
+ const float axis[3],
const bool is_large_rotation)
{
- float mat[3][3];
- int i;
-
const float angle_sign = angle < 0.0f ? -1.0f : 1.0f;
/* We cannot use something too close to 180°, or 'continuous' rotation may fail
* due to computing error... */
@@ -132,60 +264,37 @@ static void applyRotationValue(TransInfo *t,
angle = large_rotation_limit(angle);
}
- axis_angle_normalized_to_mat3(mat, axis, angle);
- /* Counter for needed updates (when we need to update to non-default matrix,
- * we also need another update on next iteration to go back to default matrix,
- * hence the '2' value used here, instead of a mere boolean). */
- short do_update_matrix = 0;
+ struct RotateMatrixCache rmc = {0};
+ rmat_cache_init(&rmc, angle, axis);
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_SKIP) {
- continue;
- }
-
- float angle_final = angle;
- if (t->con.applyRot) {
- t->con.applyRot(t, tc, td, axis, NULL);
- angle_final = angle * td->factor;
- /* Even though final angle might be identical to orig value,
- * we have to update the rotation matrix in that case... */
- do_update_matrix = 2;
- }
- else if (t->flag & T_PROP_EDIT) {
- angle_final = angle * td->factor;
- }
-
- /* Rotation is very likely to be above 180°, we need to do rotation by steps.
- * Note that this is only needed when doing 'absolute' rotation
- * (i.e. from initial rotation again, typically when using numinput).
- * regular incremental rotation (from mouse/widget/...) will be called often enough,
- * hence steps are small enough to be properly handled without that complicated trick.
- * Note that we can only do that kind of stepped rotation if we have initial rotation values
- * (and access to some actual rotation value storage).
- * Otherwise, just assume it's useless (e.g. in case of mesh/UV/etc. editing).
- * Also need to be in Euler rotation mode, the others never allow more than one turn anyway.
- */
- if (is_large_rotation && td->ext != NULL && td->ext->rotOrder == ROT_MODE_EUL) {
- copy_v3_v3(td->ext->rot, td->ext->irot);
- for (float angle_progress = angle_step; fabsf(angle_progress) < fabsf(angle_final);
- angle_progress += angle_step) {
- axis_angle_normalized_to_mat3(mat, axis, angle_progress);
- ElementRotation(t, tc, td, mat, t->around);
+ if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
+ TransData *td = tc->data;
+ for (int i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SKIP) {
+ continue;
}
- do_update_matrix = 2;
+ transdata_elem_rotate(t, tc, td, axis, angle, angle_step, is_large_rotation, &rmc);
}
- else if (angle_final != angle) {
- do_update_matrix = 2;
- }
-
- if (do_update_matrix > 0) {
- axis_angle_normalized_to_mat3(mat, axis, angle_final);
- do_update_matrix--;
- }
-
- ElementRotation(t, tc, td, mat, t->around);
+ }
+ else {
+ struct TransDataArgs_Rotate data = {
+ .t = t,
+ .tc = tc,
+ .axis = {UNPACK3(axis)},
+ .angle = angle,
+ .angle_step = angle_step,
+ .is_large_rotation = is_large_rotation,
+ };
+ struct TransDataArgs_RotateTLS tls_data = {
+ .rmc = rmc,
+ };
+
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.userdata_chunk = &tls_data;
+ settings.userdata_chunk_size = sizeof(tls_data);
+ BLI_task_parallel_range(0, tc->data_len, &data, transdata_elem_rotate_fn, &settings);
}
}
}
@@ -194,7 +303,7 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
{
char str[UI_MAX_DRAW_STR];
float axis_final[3];
- float final = t->values[0];
+ float final = t->values[0] + t->values_modal_offset[0];
if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
t->con.applyRot(t, NULL, NULL, axis_final, &final);
diff --git a/source/blender/editors/transform/transform_mode_shear.c b/source/blender/editors/transform/transform_mode_shear.c
index 23ee55bf6c5..f5672887905 100644
--- a/source/blender/editors/transform/transform_mode_shear.c
+++ b/source/blender/editors/transform/transform_mode_shear.c
@@ -27,6 +27,7 @@
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_task.h"
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -44,6 +45,79 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
+/** \name Transform (Shear) Element
+ * \{ */
+
+/**
+ * \note Small arrays / data-structures should be stored copied for faster memory access.
+ */
+struct TransDataArgs_Shear {
+ const TransInfo *t;
+ const TransDataContainer *tc;
+ float mat_final[3][3];
+ bool is_local_center;
+};
+
+static void transdata_elem_shear(const TransInfo *t,
+ const TransDataContainer *tc,
+ TransData *td,
+ const float mat_final[3][3],
+ const bool is_local_center)
+{
+ float tmat[3][3];
+ const float *center;
+ if (t->flag & T_EDIT) {
+ mul_m3_series(tmat, td->smtx, mat_final, td->mtx);
+ }
+ else {
+ copy_m3_m3(tmat, mat_final);
+ }
+
+ if (is_local_center) {
+ center = td->center;
+ }
+ else {
+ center = tc->center_local;
+ }
+
+ float vec[3];
+ sub_v3_v3v3(vec, td->iloc, center);
+ mul_m3_v3(tmat, vec);
+ add_v3_v3(vec, center);
+ sub_v3_v3(vec, td->iloc);
+
+ if (t->options & CTX_GPENCIL_STROKES) {
+ /* Grease pencil multi-frame falloff. */
+ bGPDstroke *gps = (bGPDstroke *)td->extra;
+ if (gps != NULL) {
+ mul_v3_fl(vec, td->factor * gps->runtime.multi_frame_falloff);
+ }
+ else {
+ mul_v3_fl(vec, td->factor);
+ }
+ }
+ else {
+ mul_v3_fl(vec, td->factor);
+ }
+
+ add_v3_v3v3(td->loc, td->iloc, vec);
+}
+
+static void transdata_elem_shear_fn(void *__restrict iter_data_v,
+ const int iter,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ struct TransDataArgs_Shear *data = iter_data_v;
+ TransData *td = &data->tc->data[iter];
+ if (td->flag & TD_SKIP) {
+ return;
+ }
+ transdata_elem_shear(data->t, data->tc, td, data->mat_final, data->is_local_center);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (Shear)
* \{ */
@@ -117,8 +191,7 @@ static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event)
static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
{
- float vec[3];
- float smat[3][3], tmat[3][3], totmat[3][3], axismat[3][3], axismat_inv[3][3];
+ float smat[3][3], axismat[3][3], axismat_inv[3][3], mat_final[3][3];
float value;
int i;
char str[UI_MAX_DRAW_STR];
@@ -157,50 +230,29 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
cross_v3_v3v3(axismat_inv[1], axismat_inv[0], axismat_inv[2]);
invert_m3_m3(axismat, axismat_inv);
- mul_m3_series(totmat, axismat_inv, smat, axismat);
+ mul_m3_series(mat_final, axismat_inv, smat, axismat);
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++) {
- const float *center;
- if (td->flag & TD_SKIP) {
- continue;
- }
-
- if (t->flag & T_EDIT) {
- mul_m3_series(tmat, td->smtx, totmat, td->mtx);
- }
- else {
- copy_m3_m3(tmat, totmat);
- }
-
- if (is_local_center) {
- center = td->center;
- }
- else {
- center = tc->center_local;
- }
-
- sub_v3_v3v3(vec, td->iloc, center);
- mul_m3_v3(tmat, vec);
- add_v3_v3(vec, center);
- sub_v3_v3(vec, td->iloc);
-
- if (t->options & CTX_GPENCIL_STROKES) {
- /* grease pencil multiframe falloff */
- bGPDstroke *gps = (bGPDstroke *)td->extra;
- if (gps != NULL) {
- mul_v3_fl(vec, td->factor * gps->runtime.multi_frame_falloff);
- }
- else {
- mul_v3_fl(vec, td->factor);
+ if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SKIP) {
+ continue;
}
+ transdata_elem_shear(t, tc, td, mat_final, is_local_center);
}
- else {
- mul_v3_fl(vec, td->factor);
- }
-
- add_v3_v3v3(td->loc, td->iloc, vec);
+ }
+ else {
+ struct TransDataArgs_Shear data = {
+ .t = t,
+ .tc = tc,
+ .is_local_center = is_local_center,
+ };
+ copy_m3_m3(data.mat_final, mat_final);
+
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ BLI_task_parallel_range(0, tc->data_len, &data, transdata_elem_shear_fn, &settings);
}
}
diff --git a/source/blender/editors/transform/transform_mode_shrink_fatten.c b/source/blender/editors/transform/transform_mode_shrink_fatten.c
index d2d73a14396..4cdaab599b4 100644
--- a/source/blender/editors/transform/transform_mode_shrink_fatten.c
+++ b/source/blender/editors/transform/transform_mode_shrink_fatten.c
@@ -25,6 +25,7 @@
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_task.h"
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -43,6 +44,47 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
+/** \name Transform (Shrink-Fatten) Element
+ * \{ */
+
+/**
+ * \note Small arrays / data-structures should be stored copied for faster memory access.
+ */
+struct TransDataArgs_ShrinkFatten {
+ const TransInfo *t;
+ const TransDataContainer *tc;
+ float distance;
+};
+
+static void transdata_elem_shrink_fatten(const TransInfo *t,
+ const TransDataContainer *UNUSED(tc),
+ TransData *td,
+ const float distance)
+{
+ /* Get the final offset. */
+ float tdistance = distance * td->factor;
+ if (td->ext && (t->flag & T_ALT_TRANSFORM) != 0) {
+ tdistance *= td->ext->isize[0]; /* shell factor */
+ }
+
+ madd_v3_v3v3fl(td->loc, td->iloc, td->axismtx[2], tdistance);
+}
+
+static void transdata_elem_shrink_fatten_fn(void *__restrict iter_data_v,
+ const int iter,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ struct TransDataArgs_ShrinkFatten *data = iter_data_v;
+ TransData *td = &data->tc->data[iter];
+ if (td->flag & TD_SKIP) {
+ return;
+ }
+ transdata_elem_shrink_fatten(data->t, data->tc, td, data->distance);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (Shrink-Fatten)
* \{ */
@@ -114,20 +156,24 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
/* done with header string */
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++) {
- float tdistance; /* temp dist */
- if (td->flag & TD_SKIP) {
- continue;
+ if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SKIP) {
+ continue;
+ }
+ transdata_elem_shrink_fatten(t, tc, td, distance);
}
-
- /* get the final offset */
- tdistance = distance * td->factor;
- if (td->ext && (t->flag & T_ALT_TRANSFORM) != 0) {
- tdistance *= td->ext->isize[0]; /* shell factor */
- }
-
- madd_v3_v3v3fl(td->loc, td->iloc, td->axismtx[2], tdistance);
+ }
+ else {
+ struct TransDataArgs_ShrinkFatten data = {
+ .t = t,
+ .tc = tc,
+ .distance = distance,
+ };
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ BLI_task_parallel_range(0, tc->data_len, &data, transdata_elem_shrink_fatten_fn, &settings);
}
}
diff --git a/source/blender/editors/transform/transform_mode_skin_resize.c b/source/blender/editors/transform/transform_mode_skin_resize.c
index 75ad83b0787..0a7eea8a989 100644
--- a/source/blender/editors/transform/transform_mode_skin_resize.c
+++ b/source/blender/editors/transform/transform_mode_skin_resize.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include "BLI_math.h"
+#include "BLI_task.h"
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -38,12 +39,64 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
+/** \name Transform (Skin) Element
+ * \{ */
+
+/**
+ * \note Small arrays / data-structures should be stored copied for faster memory access.
+ */
+struct TransDataArgs_SkinResize {
+ const TransInfo *t;
+ const TransDataContainer *tc;
+ float mat_final[3][3];
+};
+
+static void transdata_elem_skin_resize(const TransInfo *t,
+ const TransDataContainer *UNUSED(tc),
+ TransData *td,
+ const float mat[3][3])
+{
+ float tmat[3][3], smat[3][3];
+ float fsize[3];
+
+ if (t->flag & T_EDIT) {
+ mul_m3_m3m3(smat, mat, td->mtx);
+ mul_m3_m3m3(tmat, td->smtx, smat);
+ }
+ else {
+ copy_m3_m3(tmat, mat);
+ }
+
+ if (t->con.applySize) {
+ t->con.applySize(t, NULL, NULL, tmat);
+ }
+
+ mat3_to_size(fsize, tmat);
+ td->loc[0] = td->iloc[0] * (1 + (fsize[0] - 1) * td->factor);
+ td->loc[1] = td->iloc[1] * (1 + (fsize[1] - 1) * td->factor);
+}
+
+static void transdata_elem_skin_resize_fn(void *__restrict iter_data_v,
+ const int iter,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ struct TransDataArgs_SkinResize *data = iter_data_v;
+ TransData *td = &data->tc->data[iter];
+ if (td->flag & TD_SKIP) {
+ return;
+ }
+ transdata_elem_skin_resize(data->t, data->tc, td, data->mat_final);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (Skin)
* \{ */
static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
{
- float mat[3][3];
+ float mat_final[3][3];
int i;
char str[UI_MAX_DRAW_STR];
@@ -62,34 +115,29 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
applySnapping(t, t->values_final);
}
- size_to_mat3(mat, t->values_final);
+ size_to_mat3(mat_final, t->values_final);
headerResize(t, t->values_final, str, sizeof(str));
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++) {
- float tmat[3][3], smat[3][3];
- float fsize[3];
- if (td->flag & TD_SKIP) {
- continue;
+ if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SKIP) {
+ continue;
+ }
+ transdata_elem_skin_resize(t, tc, td, mat_final);
}
-
- if (t->flag & T_EDIT) {
- mul_m3_m3m3(smat, mat, td->mtx);
- mul_m3_m3m3(tmat, td->smtx, smat);
- }
- else {
- copy_m3_m3(tmat, mat);
- }
-
- if (t->con.applySize) {
- t->con.applySize(t, NULL, NULL, tmat);
- }
-
- mat3_to_size(fsize, tmat);
- td->loc[0] = td->iloc[0] * (1 + (fsize[0] - 1) * td->factor);
- td->loc[1] = td->iloc[1] * (1 + (fsize[1] - 1) * td->factor);
+ }
+ else {
+ struct TransDataArgs_SkinResize data = {
+ .t = t,
+ .tc = tc,
+ };
+ copy_m3_m3(data.mat_final, mat_final);
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ BLI_task_parallel_range(0, tc->data_len, &data, transdata_elem_skin_resize_fn, &settings);
}
}
diff --git a/source/blender/editors/transform/transform_mode_tosphere.c b/source/blender/editors/transform/transform_mode_tosphere.c
index 9bca9b2e9e6..8587d5ae140 100644
--- a/source/blender/editors/transform/transform_mode_tosphere.c
+++ b/source/blender/editors/transform/transform_mode_tosphere.c
@@ -25,6 +25,7 @@
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_task.h"
#include "MEM_guardedalloc.h"
@@ -111,6 +112,74 @@ static void to_sphere_radius_update(TransInfo *t)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Transform (ToSphere) Element
+ * \{ */
+
+/**
+ * \note Small arrays / data-structures should be stored copied for faster memory access.
+ */
+struct TransDataArgs_ToSphere {
+ const TransInfo *t;
+ const TransDataContainer *tc;
+ float ratio;
+ const struct ToSphereInfo to_sphere_info;
+ bool is_local_center;
+ bool is_data_space;
+};
+
+static void transdata_elem_to_sphere(const TransInfo *UNUSED(t),
+ const TransDataContainer *tc,
+ TransData *td,
+ const float ratio,
+ const struct ToSphereInfo *to_sphere_info,
+ const bool is_local_center,
+ const bool is_data_space)
+{
+ float vec[3];
+ const float *center = is_local_center ? td->center : tc->center_local;
+ if (is_data_space) {
+ copy_v3_v3(vec, td->center);
+ }
+ else {
+ copy_v3_v3(vec, td->iloc);
+ }
+
+ sub_v3_v3(vec, center);
+ const float radius = normalize_v3(vec);
+ const float tratio = ratio * td->factor;
+ mul_v3_fl(vec, radius * (1.0f - tratio) + to_sphere_info->radius * tratio);
+ add_v3_v3(vec, center);
+
+ if (is_data_space) {
+ sub_v3_v3(vec, td->center);
+ mul_m3_v3(td->smtx, vec);
+ add_v3_v3(vec, td->iloc);
+ }
+
+ copy_v3_v3(td->loc, vec);
+}
+
+static void transdata_elem_to_sphere_fn(void *__restrict iter_data_v,
+ const int iter,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ struct TransDataArgs_ToSphere *data = iter_data_v;
+ TransData *td = &data->tc->data[iter];
+ if (td->flag & TD_SKIP) {
+ return;
+ }
+ transdata_elem_to_sphere(data->t,
+ data->tc,
+ td,
+ data->ratio,
+ &data->to_sphere_info,
+ data->is_local_center,
+ data->is_data_space);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (ToSphere)
* \{ */
@@ -119,8 +188,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
const bool is_local_center = transdata_check_local_center(t, t->around);
const bool is_data_space = (t->options & CTX_POSE_BONE) != 0;
- float vec[3];
- float ratio, radius;
+ float ratio;
int i;
char str[UI_MAX_DRAW_STR];
@@ -147,40 +215,33 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), TIP_("To Sphere: %.4f %s"), ratio, t->proptext);
}
- const struct ToSphereInfo *data = t->custom.mode.data;
- if (data->prop_size_prev != t->prop_size) {
+ const struct ToSphereInfo *to_sphere_info = t->custom.mode.data;
+ if (to_sphere_info->prop_size_prev != t->prop_size) {
to_sphere_radius_update(t);
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++) {
- float tratio;
- if (td->flag & TD_SKIP) {
- continue;
- }
-
- const float *center = is_local_center ? td->center : tc->center_local;
- if (is_data_space) {
- copy_v3_v3(vec, td->center);
- }
- else {
- copy_v3_v3(vec, td->iloc);
- }
-
- sub_v3_v3(vec, center);
- radius = normalize_v3(vec);
- tratio = ratio * td->factor;
- mul_v3_fl(vec, radius * (1.0f - tratio) + data->radius * tratio);
- add_v3_v3(vec, center);
-
- if (is_data_space) {
- sub_v3_v3(vec, td->center);
- mul_m3_v3(td->smtx, vec);
- add_v3_v3(vec, td->iloc);
+ if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SKIP) {
+ continue;
+ }
+ transdata_elem_to_sphere(t, tc, td, ratio, to_sphere_info, is_local_center, is_data_space);
}
-
- copy_v3_v3(td->loc, vec);
+ }
+ else {
+ struct TransDataArgs_ToSphere data = {
+ .t = t,
+ .tc = tc,
+ .ratio = ratio,
+ .to_sphere_info = *to_sphere_info,
+ .is_local_center = is_local_center,
+ .is_data_space = is_data_space,
+ };
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ BLI_task_parallel_range(0, tc->data_len, &data, transdata_elem_to_sphere_fn, &settings);
}
}
diff --git a/source/blender/editors/transform/transform_mode_trackball.c b/source/blender/editors/transform/transform_mode_trackball.c
index d05077ef1ef..68177c6becf 100644
--- a/source/blender/editors/transform/transform_mode_trackball.c
+++ b/source/blender/editors/transform/transform_mode_trackball.c
@@ -25,6 +25,7 @@
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_task.h"
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -40,6 +41,51 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
+/** \name Transform (Rotation - Trackball) Element
+ * \{ */
+
+/**
+ * \note Small arrays / data-structures should be stored copied for faster memory access.
+ */
+struct TransDataArgs_Trackball {
+ const TransInfo *t;
+ const TransDataContainer *tc;
+ const float axis[3];
+ const float angle;
+ float mat_final[3][3];
+};
+
+static void transdata_elem_trackball(const TransInfo *t,
+ const TransDataContainer *tc,
+ TransData *td,
+ const float axis[3],
+ const float angle,
+ const float mat_final[3][3])
+{
+ float mat_buf[3][3];
+ const float(*mat)[3] = mat_final;
+ if (t->flag & T_PROP_EDIT) {
+ axis_angle_normalized_to_mat3(mat_buf, axis, td->factor * angle);
+ mat = mat_buf;
+ }
+ ElementRotation(t, tc, td, mat, t->around);
+}
+
+static void transdata_elem_trackball_fn(void *__restrict iter_data_v,
+ const int iter,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ struct TransDataArgs_Trackball *data = iter_data_v;
+ TransData *td = &data->tc->data[iter];
+ if (td->flag & TD_SKIP) {
+ return;
+ }
+ transdata_elem_trackball(data->t, data->tc, td, data->axis, data->angle, data->mat_final);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (Rotation - Trackball)
* \{ */
@@ -48,7 +94,7 @@ static void applyTrackballValue(TransInfo *t,
const float axis2[3],
const float angles[2])
{
- float mat[3][3];
+ float mat_final[3][3];
float axis[3];
float angle;
int i;
@@ -56,20 +102,30 @@ static void applyTrackballValue(TransInfo *t,
mul_v3_v3fl(axis, axis1, angles[0]);
madd_v3_v3fl(axis, axis2, angles[1]);
angle = normalize_v3(axis);
- axis_angle_normalized_to_mat3(mat, axis, angle);
+ axis_angle_normalized_to_mat3(mat_final, axis, angle);
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_SKIP) {
- continue;
+ if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SKIP) {
+ continue;
+ }
+ transdata_elem_trackball(t, tc, td, axis, angle, mat_final);
}
-
- if (t->flag & T_PROP_EDIT) {
- axis_angle_normalized_to_mat3(mat, axis, td->factor * angle);
- }
-
- ElementRotation(t, tc, td, mat, t->around);
+ }
+ else {
+ struct TransDataArgs_Trackball data = {
+ .t = t,
+ .tc = tc,
+ .axis = {UNPACK3(axis)},
+ .angle = angle,
+ };
+ copy_m3_m3(data.mat_final, mat_final);
+
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ BLI_task_parallel_range(0, tc->data_len, &data, transdata_elem_trackball_fn, &settings);
}
}
}
diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c
index 0e734b3b74b..2cbf52b6100 100644
--- a/source/blender/editors/transform/transform_mode_translate.c
+++ b/source/blender/editors/transform/transform_mode_translate.c
@@ -29,6 +29,7 @@
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_task.h"
#include "BKE_context.h"
#include "BKE_report.h"
@@ -49,6 +50,141 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
+/** \name Transform (Translate) Custom Data
+ * \{ */
+
+/** Rotation may be enabled when snapping. */
+enum eTranslateRotateMode {
+ /** Don't rotate (default). */
+ TRANSLATE_ROTATE_OFF = 0,
+ /** Perform rotation (currently only snap to normal is used). */
+ TRANSLATE_ROTATE_ON,
+ /** Rotate, resetting back to the disabled state. */
+ TRANSLATE_ROTATE_RESET,
+};
+
+/**
+ * Custom data, stored in #TransInfo.custom.mode.data
+ */
+struct TranslateCustomData {
+ /** Settings used in the last call to #applyTranslation. */
+ struct {
+ enum eTranslateRotateMode rotate_mode;
+ } prev;
+};
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Transform (Translation) Element
+ * \{ */
+
+/**
+ * \note Small arrays / data-structures should be stored copied for faster memory access.
+ */
+struct TransDataArgs_Translate {
+ const TransInfo *t;
+ const TransDataContainer *tc;
+ const float pivot_local[3];
+ const float vec[3];
+ enum eTranslateRotateMode rotate_mode;
+};
+
+static void transdata_elem_translate(const TransInfo *t,
+ const TransDataContainer *tc,
+ TransData *td,
+ const float pivot_local[3],
+ const float vec[3],
+ enum eTranslateRotateMode rotate_mode)
+{
+ float rotate_offset[3] = {0};
+ bool use_rotate_offset = false;
+
+ /* Handle snapping rotation before doing the translation. */
+ if (rotate_mode != TRANSLATE_ROTATE_OFF) {
+ float mat[3][3];
+
+ if (rotate_mode == TRANSLATE_ROTATE_RESET) {
+ unit_m3(mat);
+ }
+ else {
+ BLI_assert(rotate_mode == TRANSLATE_ROTATE_ON);
+
+ const float *original_normal;
+
+ /* In pose mode, we want to align normals with Y axis of bones. */
+ if (t->options & CTX_POSE_BONE) {
+ original_normal = td->axismtx[1];
+ }
+ else {
+ original_normal = td->axismtx[2];
+ }
+
+ rotation_between_vecs_to_mat3(mat, original_normal, t->tsnap.snapNormal);
+ }
+
+ ElementRotation_ex(t, tc, td, mat, pivot_local);
+
+ if (td->loc) {
+ use_rotate_offset = true;
+ sub_v3_v3v3(rotate_offset, td->loc, td->iloc);
+ }
+ }
+
+ float tvec[3];
+
+ if (t->con.applyVec) {
+ t->con.applyVec(t, tc, td, vec, tvec);
+ }
+ else {
+ copy_v3_v3(tvec, vec);
+ }
+
+ mul_m3_v3(td->smtx, tvec);
+
+ if (use_rotate_offset) {
+ add_v3_v3(tvec, rotate_offset);
+ }
+
+ if (t->options & CTX_GPENCIL_STROKES) {
+ /* Grease pencil multi-frame falloff. */
+ bGPDstroke *gps = (bGPDstroke *)td->extra;
+ if (gps != NULL) {
+ mul_v3_fl(tvec, td->factor * gps->runtime.multi_frame_falloff);
+ }
+ else {
+ mul_v3_fl(tvec, td->factor);
+ }
+ }
+ else {
+ /* Proportional editing falloff. */
+ mul_v3_fl(tvec, td->factor);
+ }
+
+ protectedTransBits(td->protectflag, tvec);
+
+ if (td->loc) {
+ add_v3_v3v3(td->loc, td->iloc, tvec);
+ }
+
+ constraintTransLim(t, td);
+}
+
+static void transdata_elem_translate_fn(void *__restrict iter_data_v,
+ const int iter,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ struct TransDataArgs_Translate *data = iter_data_v;
+ TransData *td = &data->tc->data[iter];
+ if (td->flag & TD_SKIP) {
+ return;
+ }
+ transdata_elem_translate(data->t, data->tc, td, data->pivot_local, data->vec, data->rotate_mode);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (Translation)
* \{ */
@@ -115,6 +251,26 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_
translate_dist_to_str(dist_str, sizeof(dist_str), dist, unit);
+ if (t->flag & T_PROP_EDIT_ALL) {
+ char prop_str[NUM_STR_REP_LEN];
+ translate_dist_to_str(prop_str, sizeof(prop_str), t->prop_size, unit);
+
+ ofs += BLI_snprintf_rlen(str + ofs,
+ UI_MAX_DRAW_STR - ofs,
+ "%s %s: %s ",
+ TIP_("Proportional Size"),
+ t->proptext,
+ prop_str);
+ }
+
+ if (t->flag & T_AUTOIK) {
+ short chainlen = t->settings->autoik_chainlen;
+ if (chainlen) {
+ ofs += BLI_snprintf_rlen(str + ofs, UI_MAX_DRAW_STR - ofs, TIP_("AutoIK-Len: %d"), chainlen);
+ ofs += BLI_strncpy_rlen(str + ofs, " ", UI_MAX_DRAW_STR - ofs);
+ }
+ }
+
if (t->con.mode & CON_APPLY) {
switch (t->num.idx_max) {
case 0:
@@ -133,7 +289,7 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_
case 2:
ofs += BLI_snprintf_rlen(str + ofs,
UI_MAX_DRAW_STR - ofs,
- "D: %s D: %s D: %s (%s)%s",
+ "D: %s D: %s D: %s (%s)%s",
dvec_str[0],
dvec_str[1],
dvec_str[2],
@@ -155,7 +311,7 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_
else {
ofs += BLI_snprintf_rlen(str + ofs,
UI_MAX_DRAW_STR - ofs,
- "Dx: %s Dy: %s Dz: %s (%s)%s",
+ "Dx: %s Dy: %s Dz: %s (%s)%s",
dvec_str[0],
dvec_str[1],
dvec_str[2],
@@ -164,26 +320,6 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_
}
}
- if (t->flag & T_PROP_EDIT_ALL) {
- char prop_str[NUM_STR_REP_LEN];
- translate_dist_to_str(prop_str, sizeof(prop_str), t->prop_size, unit);
-
- ofs += BLI_snprintf_rlen(str + ofs,
- UI_MAX_DRAW_STR - ofs,
- " %s %s: %s",
- TIP_("Proportional Size"),
- t->proptext,
- prop_str);
- }
-
- if (t->flag & T_AUTOIK) {
- short chainlen = t->settings->autoik_chainlen;
- if (chainlen) {
- ofs += BLI_strncpy_rlen(str + ofs, " ", UI_MAX_DRAW_STR - ofs);
- ofs += BLI_snprintf_rlen(str + ofs, UI_MAX_DRAW_STR - ofs, TIP_("AutoIK-Len: %d"), chainlen);
- }
- }
-
if (t->spacetype == SPACE_NODE) {
SpaceNode *snode = (SpaceNode *)t->area->spacedata.first;
@@ -222,6 +358,9 @@ static void ApplySnapTranslation(TransInfo *t, float vec[3])
vec[1] = point[1] - t->tsnap.snapTarget[1];
}
}
+ else if (t->spacetype == SPACE_SEQ) {
+ transform_snap_sequencer_apply_translate(t, vec);
+ }
else {
if (t->spacetype == SPACE_VIEW3D) {
if (t->options & CTX_PAINT_CURVE) {
@@ -238,99 +377,65 @@ static void ApplySnapTranslation(TransInfo *t, float vec[3])
static void applyTranslationValue(TransInfo *t, const float vec[3])
{
- const bool apply_snap_align_rotation = usingSnappingNormal(
- t); // && (t->tsnap.status & POINT_INIT);
- float tvec[3];
-
- /* The ideal would be "apply_snap_align_rotation" only when a snap point is found
- * so, maybe inside this function is not the best place to apply this rotation.
- * but you need "handle snapping rotation before doing the translation" (really?) */
- FOREACH_TRANS_DATA_CONTAINER (t, tc) {
-
- float pivot[3];
- if (apply_snap_align_rotation) {
- copy_v3_v3(pivot, t->tsnap.snapTarget);
- /* The pivot has to be in local-space (see T49494) */
- if (tc->use_local_mat) {
- mul_m4_v3(tc->imat, pivot);
- }
- }
-
- TransData *td = tc->data;
- for (int i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_SKIP) {
- continue;
- }
+ struct TranslateCustomData *custom_data = t->custom.mode.data;
- float rotate_offset[3] = {0};
- bool use_rotate_offset = false;
+ enum eTranslateRotateMode rotate_mode = TRANSLATE_ROTATE_OFF;
- /* handle snapping rotation before doing the translation */
- if (apply_snap_align_rotation) {
- float mat[3][3];
-
- if (validSnappingNormal(t)) {
- const float *original_normal;
-
- /* In pose mode, we want to align normals with Y axis of bones... */
- if (t->options & CTX_POSE_BONE) {
- original_normal = td->axismtx[1];
- }
- else {
- original_normal = td->axismtx[2];
- }
-
- rotation_between_vecs_to_mat3(mat, original_normal, t->tsnap.snapNormal);
- }
- else {
- unit_m3(mat);
- }
-
- ElementRotation_ex(t, tc, td, mat, pivot);
-
- if (td->loc) {
- use_rotate_offset = true;
- sub_v3_v3v3(rotate_offset, td->loc, td->iloc);
- }
- }
+ if (activeSnap(t) && usingSnappingNormal(t) && validSnappingNormal(t)) {
+ rotate_mode = TRANSLATE_ROTATE_ON;
+ }
- if (t->con.applyVec) {
- t->con.applyVec(t, tc, td, vec, tvec);
- }
- else {
- copy_v3_v3(tvec, vec);
+ /* Check to see if this needs to be re-enabled. */
+ if (rotate_mode == TRANSLATE_ROTATE_OFF) {
+ if (t->flag & T_POINTS) {
+ /* When transforming points, only use rotation when snapping is enabled
+ * since re-applying translation without rotation removes rotation. */
+ }
+ else {
+ /* When transforming data that it's self stores rotation (objects, bones etc),
+ * apply rotation if it was applied (with the snap normal) previously.
+ * This is needed because failing to rotate will leave the rotation at the last
+ * value used before snapping was disabled. */
+ if (custom_data->prev.rotate_mode == TRANSLATE_ROTATE_ON) {
+ rotate_mode = TRANSLATE_ROTATE_RESET;
}
+ }
+ }
- mul_m3_v3(td->smtx, tvec);
-
- if (use_rotate_offset) {
- add_v3_v3(tvec, rotate_offset);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ float pivot_local[3];
+ if (rotate_mode != TRANSLATE_ROTATE_OFF) {
+ copy_v3_v3(pivot_local, t->tsnap.snapTarget);
+ /* The pivot has to be in local-space (see T49494) */
+ if (tc->use_local_mat) {
+ mul_m4_v3(tc->imat, pivot_local);
}
+ }
- if (t->options & CTX_GPENCIL_STROKES) {
- /* grease pencil multiframe falloff */
- bGPDstroke *gps = (bGPDstroke *)td->extra;
- if (gps != NULL) {
- mul_v3_fl(tvec, td->factor * gps->runtime.multi_frame_falloff);
+ if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
+ TransData *td = tc->data;
+ for (int i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SKIP) {
+ continue;
}
- else {
- mul_v3_fl(tvec, td->factor);
- }
- }
- else {
- /* proportional editing falloff */
- mul_v3_fl(tvec, td->factor);
- }
-
- protectedTransBits(td->protectflag, tvec);
-
- if (td->loc) {
- add_v3_v3v3(td->loc, td->iloc, tvec);
+ transdata_elem_translate(t, tc, td, pivot_local, vec, rotate_mode);
}
-
- constraintTransLim(t, td);
+ }
+ else {
+ struct TransDataArgs_Translate data = {
+ .t = t,
+ .tc = tc,
+ .pivot_local = {UNPACK3(pivot_local)},
+ .vec = {UNPACK3(vec)},
+ .rotate_mode = rotate_mode,
+ };
+ TaskParallelSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ BLI_task_parallel_range(0, tc->data_len, &data, transdata_elem_translate_fn, &settings);
}
}
+
+ custom_data->prev.rotate_mode = rotate_mode;
}
static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
@@ -362,6 +467,11 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
}
else {
copy_v3_v3(global_dir, t->values);
+ if (!is_zero_v3(t->values_modal_offset)) {
+ float values_ofs[3];
+ mul_v3_m3v3(values_ofs, t->spacemtx, t->values_modal_offset);
+ add_v3_v3(global_dir, values_ofs);
+ }
t->tsnap.snapElem = 0;
applySnapping(t, global_dir);
@@ -452,5 +562,10 @@ void initTranslation(TransInfo *t)
transform_mode_default_modal_orientation_set(
t, (t->options & CTX_CAMERA) ? V3D_ORIENT_VIEW : V3D_ORIENT_GLOBAL);
+
+ struct TranslateCustomData *custom_data = MEM_callocN(sizeof(*custom_data), __func__);
+ custom_data->prev.rotate_mode = TRANSLATE_ROTATE_OFF;
+ t->custom.mode.data = custom_data;
+ t->custom.mode.use_free = true;
}
/** \} */
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index bebef049718..05dcc612aae 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -41,9 +41,6 @@
#include "RNA_access.h"
-#include "SEQ_sequencer.h"
-#include "SEQ_time.h"
-
#include "WM_types.h"
#include "ED_gizmo_library.h"
@@ -55,12 +52,18 @@
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "SEQ_iterator.h"
+#include "SEQ_sequencer.h"
+#include "SEQ_time.h"
+
#include "MEM_guardedalloc.h"
#include "transform.h"
#include "transform_convert.h"
#include "transform_snap.h"
+static bool doForceIncrementSnap(const TransInfo *t);
+
/* this should be passed as an arg for use in snap functions */
#undef BASACT
@@ -73,7 +76,10 @@
static void setSnappingCallback(TransInfo *t);
/* static void CalcSnapGrid(TransInfo *t, float *vec); */
-static void CalcSnapGeometry(TransInfo *t, float *vec);
+static void snap_calc_view3d_fn(TransInfo *t, float *vec);
+static void snap_calc_uv_fn(TransInfo *t, float *vec);
+static void snap_calc_node_fn(TransInfo *t, float *vec);
+static void snap_calc_sequencer_fn(TransInfo *t, float *vec);
static void TargetSnapMedian(TransInfo *t);
static void TargetSnapCenter(TransInfo *t);
@@ -133,6 +139,23 @@ bool activeSnap(const TransInfo *t)
((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT);
}
+bool activeSnap_with_project(const TransInfo *t)
+{
+ if (!t->tsnap.project) {
+ return false;
+ }
+
+ if (!activeSnap(t) || (t->flag & T_NO_PROJECT)) {
+ return false;
+ }
+
+ if (doForceIncrementSnap(t)) {
+ return false;
+ }
+
+ return true;
+}
+
bool transformModeUseSnap(const TransInfo *t)
{
ToolSettings *ts = t->settings;
@@ -145,10 +168,7 @@ bool transformModeUseSnap(const TransInfo *t)
if (t->mode == TFM_RESIZE) {
return (ts->snap_transform_mode_flag & SCE_SNAP_TRANSFORM_MODE_SCALE) != 0;
}
- if (t->mode == TFM_VERT_SLIDE) {
- return true;
- }
- if (t->mode == TFM_EDGE_SLIDE) {
+ if (ELEM(t->mode, TFM_VERT_SLIDE, TFM_EDGE_SLIDE, TFM_SEQ_SLIDE)) {
return true;
}
@@ -276,6 +296,26 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
GPU_blend(GPU_BLEND_NONE);
}
}
+ else if (t->spacetype == SPACE_SEQ) {
+ if (validSnap(t)) {
+ const ARegion *region = CTX_wm_region(C);
+ GPU_blend(GPU_BLEND_ALPHA);
+ uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ UI_GetThemeColor3ubv(TH_SEQ_ACTIVE, col);
+ col[3] = 128;
+ immUniformColor4ubv(col);
+ float pixelx = BLI_rctf_size_x(&region->v2d.cur) / BLI_rcti_size_x(&region->v2d.mask);
+ immRectf(pos,
+ t->tsnap.snapPoint[0] - pixelx,
+ region->v2d.cur.ymax,
+ t->tsnap.snapPoint[0] + pixelx,
+ region->v2d.cur.ymin);
+ immUnbindProgram();
+ GPU_blend(GPU_BLEND_NONE);
+ }
+ }
}
eRedrawFlag handleSnapping(TransInfo *t, const wmEvent *event)
@@ -299,15 +339,7 @@ eRedrawFlag handleSnapping(TransInfo *t, const wmEvent *event)
void applyProject(TransInfo *t)
{
- if (!t->tsnap.project) {
- return;
- }
-
- if (!activeSnap(t) || (t->flag & T_NO_PROJECT)) {
- return;
- }
-
- if (doForceIncrementSnap(t)) {
+ if (!activeSnap_with_project(t)) {
return;
}
@@ -465,10 +497,13 @@ void applySnapping(TransInfo *t, float *vec)
/* TODO: add exception for object mode, no need to slow it down then. */
if (current - t->tsnap.last >= 0.01) {
t->tsnap.calcSnap(t, vec);
- t->tsnap.targetSnap(t);
-
- t->tsnap.last = current;
+ if (t->tsnap.targetSnap) {
+ t->tsnap.targetSnap(t);
+ }
}
+
+ t->tsnap.last = current;
+
if (validSnap(t)) {
t->tsnap.applySnap(t, vec);
}
@@ -556,6 +591,9 @@ static void initSnappingMode(TransInfo *t)
t->tsnap.mode = ts->snap_uv_mode;
}
+ else if (t->spacetype == SPACE_SEQ) {
+ t->tsnap.mode = SEQ_tool_settings_snap_mode_get(t->scene);
+ }
else {
/* force project off when not supported */
if ((ts->snap_mode & SCE_SNAP_MODE_FACE) == 0) {
@@ -615,16 +653,12 @@ static void initSnappingMode(TransInfo *t)
t->tsnap.mode = SCE_SNAP_MODE_INCREMENT;
}
}
- else if (t->spacetype == SPACE_NODE) {
+ else if (ELEM(t->spacetype, SPACE_NODE, SPACE_SEQ)) {
setSnappingCallback(t);
t->tsnap.modeSelect = SNAP_NOT_SELECTED;
}
- else if (t->spacetype == SPACE_SEQ) {
- /* We do our own snapping currently, so nothing here */
- t->tsnap.mode = SCE_SNAP_MODE_GRID; /* Dummy, should we rather add a NOP mode? */
- }
else {
- /* Always increment outside of 3D view */
+ /* Fallback. */
t->tsnap.mode = SCE_SNAP_MODE_INCREMENT;
}
@@ -645,6 +679,11 @@ static void initSnappingMode(TransInfo *t)
}
}
}
+ else if (t->spacetype == SPACE_SEQ) {
+ if (t->tsnap.seq_context == NULL) {
+ t->tsnap.seq_context = transform_snap_sequencer_data_alloc(t);
+ }
+ }
}
void initSnapping(TransInfo *t, wmOperator *op)
@@ -697,6 +736,9 @@ void initSnapping(TransInfo *t, wmOperator *op)
t->tsnap.snap_self = !((t->settings->snap_flag & SCE_SNAP_NO_SELF) != 0);
t->tsnap.peel = ((t->settings->snap_flag & SCE_SNAP_PROJECT) != 0);
}
+ else if ((t->spacetype == SPACE_SEQ) && (ts->snap_flag & SCE_SNAP_SEQ)) {
+ t->modifiers |= MOD_SNAP;
+ }
}
t->tsnap.target = snap_target;
@@ -706,7 +748,11 @@ void initSnapping(TransInfo *t, wmOperator *op)
void freeSnapping(TransInfo *t)
{
- if (t->tsnap.object_context) {
+ if ((t->spacetype == SPACE_SEQ) && t->tsnap.seq_context) {
+ transform_snap_sequencer_data_free(t->tsnap.seq_context);
+ t->tsnap.seq_context = NULL;
+ }
+ else if (t->tsnap.object_context) {
ED_transform_snap_object_context_destroy(t->tsnap.object_context);
t->tsnap.object_context = NULL;
}
@@ -714,7 +760,20 @@ void freeSnapping(TransInfo *t)
static void setSnappingCallback(TransInfo *t)
{
- t->tsnap.calcSnap = CalcSnapGeometry;
+ if (t->spacetype == SPACE_VIEW3D) {
+ t->tsnap.calcSnap = snap_calc_view3d_fn;
+ }
+ else if (t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH) {
+ t->tsnap.calcSnap = snap_calc_uv_fn;
+ }
+ else if (t->spacetype == SPACE_NODE) {
+ t->tsnap.calcSnap = snap_calc_node_fn;
+ }
+ else if (t->spacetype == SPACE_SEQ) {
+ t->tsnap.calcSnap = snap_calc_sequencer_fn;
+ /* The target is calculated along with the snap point. */
+ return;
+ }
switch (t->tsnap.target) {
case SCE_SNAP_TARGET_CLOSEST:
@@ -835,89 +894,105 @@ void getSnapPoint(const TransInfo *t, float vec[3])
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Calc Snap (Generic)
+/** \name Calc Snap
* \{ */
-static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
+static void snap_calc_view3d_fn(TransInfo *t, float *UNUSED(vec))
{
- if (t->spacetype == SPACE_VIEW3D) {
- float loc[3];
- float no[3];
- float mval[2];
- bool found = false;
- short snap_elem = 0;
- float dist_px = SNAP_MIN_DISTANCE; /* Use a user defined value here. */
+ BLI_assert(t->spacetype == SPACE_VIEW3D);
+ float loc[3];
+ float no[3];
+ float mval[2];
+ bool found = false;
+ short snap_elem = 0;
+ float dist_px = SNAP_MIN_DISTANCE; /* Use a user defined value here. */
+
+ mval[0] = t->mval[0];
+ mval[1] = t->mval[1];
+
+ if (t->tsnap.mode & (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE |
+ SCE_SNAP_MODE_EDGE_MIDPOINT | SCE_SNAP_MODE_EDGE_PERPENDICULAR)) {
+ zero_v3(no); /* objects won't set this */
+ snap_elem = snapObjectsTransform(t, mval, &dist_px, loc, no);
+ found = snap_elem != 0;
+ }
+ if ((found == false) && (t->tsnap.mode & SCE_SNAP_MODE_VOLUME)) {
+ found = peelObjectsTransform(
+ t, mval, (t->settings->snap_flag & SCE_SNAP_PEEL_OBJECT) != 0, loc, no, NULL);
+
+ if (found) {
+ snap_elem = SCE_SNAP_MODE_VOLUME;
+ }
+ }
- mval[0] = t->mval[0];
- mval[1] = t->mval[1];
+ if (found == true) {
+ copy_v3_v3(t->tsnap.snapPoint, loc);
+ copy_v3_v3(t->tsnap.snapNormal, no);
- if (t->tsnap.mode & (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE |
- SCE_SNAP_MODE_EDGE_MIDPOINT | SCE_SNAP_MODE_EDGE_PERPENDICULAR)) {
- zero_v3(no); /* objects won't set this */
- snap_elem = snapObjectsTransform(t, mval, &dist_px, loc, no);
- found = snap_elem != 0;
- }
- if ((found == false) && (t->tsnap.mode & SCE_SNAP_MODE_VOLUME)) {
- found = peelObjectsTransform(
- t, mval, (t->settings->snap_flag & SCE_SNAP_PEEL_OBJECT) != 0, loc, no, NULL);
+ t->tsnap.status |= POINT_INIT;
+ }
+ else {
+ t->tsnap.status &= ~POINT_INIT;
+ }
- if (found) {
- snap_elem = SCE_SNAP_MODE_VOLUME;
- }
- }
+ t->tsnap.snapElem = (char)snap_elem;
+}
- if (found == true) {
- copy_v3_v3(t->tsnap.snapPoint, loc);
- copy_v3_v3(t->tsnap.snapNormal, no);
+static void snap_calc_uv_fn(TransInfo *t, float *UNUSED(vec))
+{
+ BLI_assert(t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH);
+ if (t->tsnap.mode & SCE_SNAP_MODE_VERTEX) {
+ float co[2];
+
+ UI_view2d_region_to_view(&t->region->v2d, t->mval[0], t->mval[1], &co[0], &co[1]);
+
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
+ t->view_layer, NULL, &objects_len);
+
+ float dist_sq = FLT_MAX;
+ if (ED_uvedit_nearest_uv_multi(
+ t->scene, objects, objects_len, co, &dist_sq, t->tsnap.snapPoint)) {
+ t->tsnap.snapPoint[0] *= t->aspect[0];
+ t->tsnap.snapPoint[1] *= t->aspect[1];
t->tsnap.status |= POINT_INIT;
}
else {
t->tsnap.status &= ~POINT_INIT;
}
-
- t->tsnap.snapElem = (char)snap_elem;
+ MEM_freeN(objects);
}
- else if (t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH) {
- if (t->tsnap.mode & SCE_SNAP_MODE_VERTEX) {
- float co[2];
-
- UI_view2d_region_to_view(&t->region->v2d, t->mval[0], t->mval[1], &co[0], &co[1]);
+}
- uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
- t->view_layer, NULL, &objects_len);
+static void snap_calc_node_fn(TransInfo *t, float *UNUSED(vec))
+{
+ BLI_assert(t->spacetype == SPACE_NODE);
+ if (t->tsnap.mode & (SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y)) {
+ float loc[2];
+ float dist_px = SNAP_MIN_DISTANCE; /* Use a user defined value here. */
+ char node_border;
- float dist_sq = FLT_MAX;
- if (ED_uvedit_nearest_uv_multi(
- t->scene, objects, objects_len, co, &dist_sq, t->tsnap.snapPoint)) {
- t->tsnap.snapPoint[0] *= t->aspect[0];
- t->tsnap.snapPoint[1] *= t->aspect[1];
+ if (snapNodesTransform(t, t->mval, loc, &dist_px, &node_border)) {
+ copy_v2_v2(t->tsnap.snapPoint, loc);
+ t->tsnap.snapNodeBorder = node_border;
- t->tsnap.status |= POINT_INIT;
- }
- else {
- t->tsnap.status &= ~POINT_INIT;
- }
- MEM_freeN(objects);
+ t->tsnap.status |= POINT_INIT;
+ }
+ else {
+ t->tsnap.status &= ~POINT_INIT;
}
}
- else if (t->spacetype == SPACE_NODE) {
- if (t->tsnap.mode & (SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y)) {
- float loc[2];
- float dist_px = SNAP_MIN_DISTANCE; /* Use a user defined value here. */
- char node_border;
-
- if (snapNodesTransform(t, t->mval, loc, &dist_px, &node_border)) {
- copy_v2_v2(t->tsnap.snapPoint, loc);
- t->tsnap.snapNodeBorder = node_border;
+}
- t->tsnap.status |= POINT_INIT;
- }
- else {
- t->tsnap.status &= ~POINT_INIT;
- }
- }
+static void snap_calc_sequencer_fn(TransInfo *t, float *UNUSED(vec))
+{
+ BLI_assert(t->spacetype == SPACE_SEQ);
+ if (transform_snap_sequencer_calc(t)) {
+ t->tsnap.status |= (POINT_INIT | TARGET_INIT);
+ }
+ else {
+ t->tsnap.status &= ~(POINT_INIT | TARGET_INIT);
}
}
@@ -1430,28 +1505,6 @@ void snapFrameTransform(TransInfo *t,
*r_val = (float)val;
}
-/*================================================================*/
-
-void snapSequenceBounds(TransInfo *t, const int mval[2])
-{
- /* Reuse increment, strictly speaking could be another snap mode, but leave as is. */
- if (!(t->modifiers & MOD_SNAP_INVERT)) {
- return;
- }
-
- /* Convert to frame range. */
- float xmouse, ymouse;
- UI_view2d_region_to_view(&t->region->v2d, mval[0], mval[1], &xmouse, &ymouse);
- const int frame_curr = round_fl_to_int(xmouse);
-
- /* Now find the closest sequence. */
- const int frame_near = SEQ_time_find_next_prev_edit(
- t->scene, frame_curr, SEQ_SIDE_BOTH, true, false, true);
-
- const int frame_snap = transform_convert_sequencer_get_snap_bound(t);
- t->values[0] = frame_near - frame_snap;
-}
-
static void snap_grid_apply(
TransInfo *t, const int max_index, const float grid_dist, const float loc[3], float r_out[3])
{
@@ -1506,7 +1559,7 @@ bool transform_snap_grid(TransInfo *t, float *val)
return true;
}
-static void snap_increment_apply_ex(TransInfo *UNUSED(t),
+static void snap_increment_apply_ex(const TransInfo *UNUSED(t),
const int max_index,
const float increment_val,
const float aspect[3],
@@ -1520,8 +1573,8 @@ static void snap_increment_apply_ex(TransInfo *UNUSED(t),
}
}
-static void snap_increment_apply(TransInfo *t,
- int max_index,
+static void snap_increment_apply(const TransInfo *t,
+ const int max_index,
const float increment_dist,
float *r_val)
{
@@ -1553,7 +1606,7 @@ static void snap_increment_apply(TransInfo *t,
snap_increment_apply_ex(t, max_index, increment_dist, asp, r_val, r_val);
}
-bool transform_snap_increment_ex(TransInfo *t, bool use_local_space, float *r_val)
+bool transform_snap_increment_ex(const TransInfo *t, bool use_local_space, float *r_val)
{
if (!activeSnap(t)) {
return false;
@@ -1584,7 +1637,7 @@ bool transform_snap_increment_ex(TransInfo *t, bool use_local_space, float *r_va
return true;
}
-bool transform_snap_increment(TransInfo *t, float *r_val)
+bool transform_snap_increment(const TransInfo *t, float *r_val)
{
return transform_snap_increment_ex(t, false, r_val);
}
diff --git a/source/blender/editors/transform/transform_snap.h b/source/blender/editors/transform/transform_snap.h
index c557368ed17..6dfaeab93e6 100644
--- a/source/blender/editors/transform/transform_snap.h
+++ b/source/blender/editors/transform/transform_snap.h
@@ -54,13 +54,13 @@ void snapFrameTransform(struct TransInfo *t,
bool transformModeUseSnap(const TransInfo *t);
-bool transform_snap_increment_ex(TransInfo *t, bool use_local_space, float *r_val);
-bool transform_snap_increment(TransInfo *t, float *val);
+bool transform_snap_increment_ex(const TransInfo *t, bool use_local_space, float *r_val);
+bool transform_snap_increment(const TransInfo *t, float *val);
bool transform_snap_grid(TransInfo *t, float *val);
-void snapSequenceBounds(TransInfo *t, const int mval[2]);
-
bool activeSnap(const TransInfo *t);
+bool activeSnap_with_project(const TransInfo *t);
+
bool validSnap(const TransInfo *t);
void initSnapping(struct TransInfo *t, struct wmOperator *op);
@@ -80,3 +80,9 @@ eRedrawFlag updateSelectedSnapPoint(TransInfo *t);
void removeSnapPoint(TransInfo *t);
float transform_snap_distance_len_squared_fn(TransInfo *t, const float p1[3], const float p2[3]);
+
+/* transform_snap_sequencer.c */
+struct TransSeqSnapData *transform_snap_sequencer_data_alloc(const TransInfo *t);
+void transform_snap_sequencer_data_free(struct TransSeqSnapData *data);
+bool transform_snap_sequencer_calc(struct TransInfo *t);
+void transform_snap_sequencer_apply_translate(TransInfo *t, float *vec);
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 512f912a532..8a4c8f410c0 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -255,7 +255,7 @@ static SnapObjectData *snap_object_data_lookup(SnapObjectContext *sctx, Object *
static SnapObjectData *snap_object_data_mesh_get(SnapObjectContext *sctx,
Object *ob_eval,
- Mesh *me_eval,
+ const Mesh *me_eval,
bool use_hide)
{
SnapObjectData *sod;
@@ -687,7 +687,7 @@ static bool raycastMesh(SnapObjectContext *sctx,
const float ray_start[3],
const float ray_dir[3],
Object *ob_eval,
- Mesh *me_eval,
+ const Mesh *me_eval,
const float obmat[4][4],
const uint ob_index,
bool use_hide,
@@ -1088,7 +1088,7 @@ static void raycast_obj_fn(SnapObjectContext *sctx,
case OB_SURF:
case OB_FONT: {
if (!is_object_active) {
- Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob_eval);
+ const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob_eval);
if (mesh_eval) {
retval = raycastMesh(sctx,
dt->ray_start,
@@ -1142,7 +1142,7 @@ static void raycast_obj_fn(SnapObjectContext *sctx,
* \param r_loc: Hit location.
* \param r_no: Hit normal (optional).
* \param r_index: Hit index or -1 when no valid index is found.
- * (currently only set to the polygon index when when using ``snap_to == SCE_SNAP_MODE_FACE``).
+ * (currently only set to the polygon index when using ``snap_to == SCE_SNAP_MODE_FACE``).
* \param r_ob: Hit object.
* \param r_obmat: Object matrix (may not be #Object.obmat with dupli-instances).
* \param r_hit_list: List of #SnapObjectHitDepth (caller must free).
@@ -2777,7 +2777,7 @@ static void snap_obj_fn(SnapObjectContext *sctx,
* \param r_loc: Hit location.
* \param r_no: Hit normal (optional).
* \param r_index: Hit index or -1 when no valid index is found.
- * (currently only set to the polygon index when when using ``snap_to == SCE_SNAP_MODE_FACE``).
+ * (currently only set to the polygon index when using ``snap_to == SCE_SNAP_MODE_FACE``).
* \param r_ob: Hit object.
* \param r_obmat: Object matrix (may not be #Object.obmat with dupli-instances).
*/
diff --git a/source/blender/editors/transform/transform_snap_sequencer.c b/source/blender/editors/transform/transform_snap_sequencer.c
new file mode 100644
index 00000000000..d9395e5e960
--- /dev/null
+++ b/source/blender/editors/transform/transform_snap_sequencer.c
@@ -0,0 +1,270 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edtransform
+ */
+
+#include <stdlib.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+
+#include "BKE_context.h"
+
+#include "ED_screen.h"
+
+#include "UI_view2d.h"
+
+#include "SEQ_iterator.h"
+#include "SEQ_sequencer.h"
+
+#include "transform.h"
+#include "transform_snap.h"
+
+typedef struct TransSeqSnapData {
+ int *source_snap_points;
+ int *target_snap_points;
+ int source_snap_point_count;
+ int target_snap_point_count;
+ int final_snap_frame;
+} TransSeqSnapData;
+
+/* -------------------------------------------------------------------- */
+/** \name Snap sources
+ * \{ */
+
+static int seq_get_snap_source_points_len(SeqCollection *snap_sources)
+{
+ return SEQ_collection_len(snap_sources) * 2;
+}
+
+static void seq_snap_source_points_alloc(TransSeqSnapData *snap_data, SeqCollection *snap_sources)
+{
+ const size_t point_count = seq_get_snap_source_points_len(snap_sources);
+ snap_data->source_snap_points = MEM_callocN(sizeof(int) * point_count, __func__);
+ memset(snap_data->source_snap_points, 0, sizeof(int));
+ snap_data->source_snap_point_count = point_count;
+}
+
+static int cmp_fn(const void *a, const void *b)
+{
+ return (*(int *)a - *(int *)b);
+}
+
+static void seq_snap_source_points_build(const TransInfo *UNUSED(t),
+ TransSeqSnapData *snap_data,
+ SeqCollection *snap_sources)
+{
+ int i = 0;
+ Sequence *seq;
+ SEQ_ITERATOR_FOREACH (seq, snap_sources) {
+ int left = 0, right = 0;
+ if (seq->flag & SEQ_LEFTSEL) {
+ left = right = seq->startdisp;
+ }
+ else if (seq->flag & SEQ_RIGHTSEL) {
+ left = right = seq->enddisp;
+ }
+ else {
+ left = seq->startdisp;
+ right = seq->enddisp;
+ }
+
+ snap_data->source_snap_points[i] = left;
+ snap_data->source_snap_points[i + 1] = right;
+ i += 2;
+ BLI_assert(i <= snap_data->source_snap_point_count);
+ }
+
+ qsort(snap_data->source_snap_points, snap_data->source_snap_point_count, sizeof(int), cmp_fn);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Snap targets
+ * \{ */
+
+static SeqCollection *query_snap_targets(const TransInfo *t)
+{
+ const ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(t->scene, false));
+ const short snap_flag = SEQ_tool_settings_snap_flag_get(t->scene);
+ SeqCollection *collection = SEQ_collection_create(__func__);
+ LISTBASE_FOREACH (Sequence *, seq, seqbase) {
+ if ((seq->flag & SELECT)) {
+ continue; /* Selected are being transformed. */
+ }
+ if ((seq->flag & SEQ_MUTE) && (snap_flag & SEQ_SNAP_IGNORE_MUTED)) {
+ continue;
+ }
+ if (seq->type == SEQ_TYPE_SOUND_RAM && (snap_flag & SEQ_SNAP_IGNORE_SOUND)) {
+ continue;
+ }
+ SEQ_collection_append_strip(seq, collection);
+ }
+ return collection;
+}
+
+static int seq_get_snap_target_points_count(const TransInfo *t,
+ TransSeqSnapData *UNUSED(snap_data),
+ SeqCollection *snap_targets)
+{
+ const short snap_mode = t->tsnap.mode;
+
+ int count = 2; /* Strip start and end are always used. */
+
+ if (snap_mode & SEQ_SNAP_TO_STRIP_HOLD) {
+ count += 2;
+ }
+
+ count *= SEQ_collection_len(snap_targets);
+
+ if (snap_mode & SEQ_SNAP_TO_CURRENT_FRAME) {
+ count++;
+ }
+
+ return count;
+}
+
+static void seq_snap_target_points_alloc(const TransInfo *t,
+ TransSeqSnapData *snap_data,
+ SeqCollection *snap_targets)
+{
+ const size_t point_count = seq_get_snap_target_points_count(t, snap_data, snap_targets);
+ snap_data->target_snap_points = MEM_callocN(sizeof(int) * point_count, __func__);
+ memset(snap_data->target_snap_points, 0, sizeof(int));
+ snap_data->target_snap_point_count = point_count;
+}
+
+static void seq_snap_target_points_build(const TransInfo *t,
+ TransSeqSnapData *snap_data,
+ SeqCollection *snap_targets)
+{
+ const Scene *scene = t->scene;
+ const short snap_mode = t->tsnap.mode;
+
+ int i = 0;
+
+ if (snap_mode & SEQ_SNAP_TO_CURRENT_FRAME) {
+ snap_data->target_snap_points[i] = CFRA;
+ i++;
+ }
+
+ Sequence *seq;
+ SEQ_ITERATOR_FOREACH (seq, snap_targets) {
+ snap_data->target_snap_points[i] = seq->startdisp;
+ snap_data->target_snap_points[i + 1] = seq->enddisp;
+ i += 2;
+
+ if (snap_mode & SEQ_SNAP_TO_STRIP_HOLD) {
+ int content_start = min_ii(seq->enddisp, seq->start);
+ int content_end = max_ii(seq->startdisp, seq->start + seq->len);
+ if (seq->anim_startofs == 0) {
+ content_start = seq->startdisp;
+ }
+ if (seq->anim_endofs == 0) {
+ content_end = seq->enddisp;
+ }
+ snap_data->target_snap_points[i] = content_start;
+ snap_data->target_snap_points[i + 1] = content_end;
+ i += 2;
+ }
+ }
+ BLI_assert(i <= snap_data->target_snap_point_count);
+ qsort(snap_data->target_snap_points, snap_data->target_snap_point_count, sizeof(int), cmp_fn);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Snap utilities
+ * \{ */
+
+static int seq_snap_threshold_get_frame_distance(const TransInfo *t)
+{
+ const int snap_distance = SEQ_tool_settings_snap_distance_get(t->scene);
+ const struct View2D *v2d = &t->region->v2d;
+ return round_fl_to_int(UI_view2d_region_to_view_x(v2d, snap_distance) -
+ UI_view2d_region_to_view_x(v2d, 0));
+}
+
+/** \} */
+
+TransSeqSnapData *transform_snap_sequencer_data_alloc(const TransInfo *t)
+{
+ TransSeqSnapData *snap_data = MEM_callocN(sizeof(TransSeqSnapData), __func__);
+ ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(t->scene, false));
+
+ /* Build arrays of snap points. */
+ SeqCollection *snap_sources = SEQ_query_selected_strips(seqbase);
+ seq_snap_source_points_alloc(snap_data, snap_sources);
+ seq_snap_source_points_build(t, snap_data, snap_sources);
+ SEQ_collection_free(snap_sources);
+
+ SeqCollection *snap_targets = query_snap_targets(t);
+ seq_snap_target_points_alloc(t, snap_data, snap_targets);
+ seq_snap_target_points_build(t, snap_data, snap_targets);
+ SEQ_collection_free(snap_targets);
+ return snap_data;
+}
+
+void transform_snap_sequencer_data_free(TransSeqSnapData *data)
+{
+ MEM_freeN(data->source_snap_points);
+ MEM_freeN(data->target_snap_points);
+ MEM_freeN(data);
+}
+
+bool transform_snap_sequencer_calc(TransInfo *t)
+{
+ const TransSeqSnapData *snap_data = t->tsnap.seq_context;
+ int best_dist = MAXFRAME, best_target_frame = 0, best_source_frame = 0;
+
+ for (int i = 0; i < snap_data->source_snap_point_count; i++) {
+ int snap_source_frame = snap_data->source_snap_points[i] + round_fl_to_int(t->values[0]);
+ for (int j = 0; j < snap_data->target_snap_point_count; j++) {
+ int snap_target_frame = snap_data->target_snap_points[j];
+
+ int dist = abs(snap_target_frame - snap_source_frame);
+ if (dist > best_dist) {
+ continue;
+ }
+
+ best_dist = dist;
+ best_target_frame = snap_target_frame;
+ best_source_frame = snap_source_frame;
+ }
+ }
+
+ if (best_dist > seq_snap_threshold_get_frame_distance(t)) {
+ return false;
+ }
+
+ t->tsnap.snapPoint[0] = best_target_frame;
+ t->tsnap.snapTarget[0] = best_source_frame;
+ return true;
+}
+
+void transform_snap_sequencer_apply_translate(TransInfo *t, float *vec)
+{
+ *vec += t->tsnap.snapPoint[0] - t->tsnap.snapTarget[0];
+}
diff --git a/source/blender/editors/undo/memfile_undo.c b/source/blender/editors/undo/memfile_undo.c
index 9189adaf4d1..7c6ce56eab0 100644
--- a/source/blender/editors/undo/memfile_undo.c
+++ b/source/blender/editors/undo/memfile_undo.c
@@ -224,9 +224,21 @@ static void memfile_undosys_step_decode(struct bContext *C,
/* Tag depsgraph to update data-block for changes that happened between the
* current and the target state, see direct_link_id_restore_recalc(). */
- if (id->recalc) {
+ if (id->recalc != 0) {
DEG_id_tag_update_ex(bmain, id, id->recalc);
}
+
+ bNodeTree *nodetree = ntreeFromID(id);
+ if (nodetree != NULL && nodetree->id.recalc != 0) {
+ DEG_id_tag_update_ex(bmain, &nodetree->id, nodetree->id.recalc);
+ }
+ if (GS(id->name) == ID_SCE) {
+ Scene *scene = (Scene *)id;
+ if (scene->master_collection != NULL && scene->master_collection->id.recalc != 0) {
+ DEG_id_tag_update_ex(
+ bmain, &scene->master_collection->id, scene->master_collection->id.recalc);
+ }
+ }
}
FOREACH_MAIN_ID_END;
diff --git a/source/blender/editors/util/ed_transverts.c b/source/blender/editors/util/ed_transverts.c
index c1d0dcdb095..b4a93eb996c 100644
--- a/source/blender/editors/util/ed_transverts.c
+++ b/source/blender/editors/util/ed_transverts.c
@@ -182,8 +182,8 @@ static void set_mapped_co(void *vuserdata,
if (BM_elem_index_get(eve) != TM_INDEX_SKIP) {
tv = &tv[BM_elem_index_get(eve)];
- /* be clever, get the closest vertex to the original,
- * behaves most logically when the mirror modifier is used for eg T33051*/
+ /* Be clever, get the closest vertex to the original,
+ * behaves most logically when the mirror modifier is used for eg T33051. */
if ((tv->flag & TX_VERT_USE_MAPLOC) == 0) {
/* first time */
copy_v3_v3(tv->maploc, co);
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index b80782b51be..7bbdc58474f 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -295,8 +295,11 @@ bool ED_editors_flush_edits(Main *bmain)
/* ***** XXX: functions are using old blender names, cleanup later ***** */
-/* now only used in 2d spaces, like time, ipo, nla, sima... */
-/* XXX shift/ctrl not configurable */
+/**
+ * Now only used in 2D spaces, like time, f-curve, NLA, image, etc.
+ *
+ * \note Shift/Control are not configurable key-bindings.
+ */
void apply_keyb_grid(
int shift, int ctrl, float *val, float fac1, float fac2, float fac3, int invert)
{
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 7b034af1438..2f88e50492f 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -608,7 +608,7 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
/* Projection of point (x, y) over line (x1, y1, x2, y2) along X axis:
* new_y = (y2 - y1) / (x2 - x1) * (x - x1) + y1
* Maybe this should be a BLI func? Or is it already existing?
- * Could use interp_v2_v2v2, but not sure it's worth it here...*/
+ * Could use interp_v2_v2v2, but not sure it's worth it here. */
if (tool_local == UV_STRAIGHTEN_X) {
luv->uv[0] = a * (luv->uv[1] - uv_start[1]) + uv_start[0];
}
@@ -624,7 +624,7 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
}
}
else {
- /* error - not a line, needs 3+ points */
+ /* error - not a line, needs 3+ points. */
}
if (eve_line) {
@@ -632,7 +632,7 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
}
}
else {
- /* error - can't find an endpoint */
+ /* error - can't find an endpoint. */
}
}
@@ -1187,15 +1187,15 @@ static bool uv_snap_uvs_to_adjacent_unselected(Scene *scene, Object *obedit)
}
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(f, BM_ELEM_TAG)) { /* face: visible */
+ if (BM_elem_flag_test(f, BM_ELEM_TAG)) { /* Face: visible. */
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- if (BM_elem_flag_test(l, BM_ELEM_TAG)) { /* loop: selected*/
+ if (BM_elem_flag_test(l, BM_ELEM_TAG)) { /* Loop: selected. */
float uv[2] = {0.0f, 0.0f};
int uv_tot = 0;
BM_ITER_ELEM (lsub, &lsubiter, l->v, BM_LOOPS_OF_VERT) {
- if (BM_elem_flag_test(lsub->f, BM_ELEM_TAG) && /* face: visible */
- !BM_elem_flag_test(lsub, BM_ELEM_TAG)) /* loop: unselected */
+ if (BM_elem_flag_test(lsub->f, BM_ELEM_TAG) && /* Face: visible. */
+ !BM_elem_flag_test(lsub, BM_ELEM_TAG)) /* Loop: unselected. */
{
luv = BM_ELEM_CD_GET_VOID_P(lsub, cd_loop_uv_offset);
add_v2_v2(uv, luv->uv);
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 7d82884760c..eb4ca2e13b2 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -82,10 +82,10 @@ typedef struct PVert {
struct PVert *nextlink;
union PVertUnion {
- PHashKey key; /* construct */
- int id; /* abf/lscm matrix index */
- float distortion; /* area smoothing */
- HeapNode *heaplink; /* edge collapsing */
+ PHashKey key; /* Construct. */
+ int id; /* ABF/LSCM matrix index. */
+ float distortion; /* Area smoothing. */
+ HeapNode *heaplink; /* Edge collapsing. */
} u;
struct PEdge *edge;
@@ -99,10 +99,10 @@ typedef struct PEdge {
struct PEdge *nextlink;
union PEdgeUnion {
- PHashKey key; /* construct */
- int id; /* abf matrix index */
- HeapNode *heaplink; /* fill holes */
- struct PEdge *nextcollapse; /* simplification */
+ PHashKey key; /* Construct. */
+ int id; /* ABF matrix index. */
+ HeapNode *heaplink; /* Fill holes. */
+ struct PEdge *nextcollapse; /* Simplification. */
} u;
struct PVert *vert;
@@ -118,10 +118,10 @@ typedef struct PFace {
struct PFace *nextlink;
union PFaceUnion {
- PHashKey key; /* construct */
- int chart; /* construct splitting*/
- float area3d; /* stretch */
- int id; /* abf matrix index */
+ PHashKey key; /* Construct. */
+ int chart; /* Construct splitting. */
+ float area3d; /* Stretch. */
+ int id; /* ABF matrix index. */
} u;
struct PEdge *edge;
diff --git a/source/blender/editors/uvedit/uvedit_rip.c b/source/blender/editors/uvedit/uvedit_rip.c
index f8b53879ac4..631b831411f 100644
--- a/source/blender/editors/uvedit/uvedit_rip.c
+++ b/source/blender/editors/uvedit/uvedit_rip.c
@@ -907,7 +907,7 @@ static int uv_rip_exec(bContext *C, wmOperator *op)
float aspx, aspy;
{
- /* Note that we only want to run this on the */
+ /* Note that we only want to run this on the. */
Object *obedit = CTX_data_edit_object(C);
ED_uvedit_get_aspect(obedit, &aspx, &aspy);
}
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index 8ebf000baaa..71656784947 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -76,7 +76,7 @@ typedef struct StitchPreviewer {
float *preview_polys;
/* uvs per polygon. */
uint *uvs_per_polygon;
- /*number of preview polygons */
+ /* Number of preview polygons. */
uint num_polys;
/* preview data. These will be either the previewed vertices or edges
* depending on stitch mode settings */
@@ -1069,8 +1069,7 @@ static int stitch_process_data(StitchStateContainer *ssc,
}
}
- /* remember stitchable candidates as places the 'I' button */
- /* will stop at. */
+ /* Remember stitchable candidates as places the 'I' button will stop at. */
for (int island_idx = 0; island_idx < state->element_map->totalIslands; island_idx++) {
state->island_is_stitchable[island_idx] = island_stitch_data[island_idx].stitchableCandidate ?
true :
@@ -1818,7 +1817,7 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), void
/* Closing line */
GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]);
- /* j = uvs_per_polygon[i] - 1*/
+ /* `j = uvs_per_polygon[i] - 1` */
GPU_vertbuf_attr_set(
vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + j * 2]);
@@ -1980,7 +1979,7 @@ static StitchState *stitch_init(bContext *C,
counter++;
state->uvs[counter] = element;
}
- /* pointer arithmetic to the rescue, as always :)*/
+ /* Pointer arithmetic to the rescue, as always :). */
map[element - state->element_map->buf] = counter;
}
}
@@ -2007,8 +2006,8 @@ static StitchState *stitch_init(bContext *C,
all_edges[counter].first = NULL;
all_edges[counter].flag = 0;
all_edges[counter].element = element;
- /* using an order policy, sort uvs according to address space. This avoids
- * Having two different UvEdges with the same uvs on different positions */
+ /* Using an order policy, sort UV's according to address space.
+ * This avoids having two different UvEdges with the same UV's on different positions. */
if (offset1 < offset2) {
all_edges[counter].uv1 = offset1;
all_edges[counter].uv2 = offset2;
@@ -2381,9 +2380,9 @@ static int stitch_init_all(bContext *C, wmOperator *op)
StitchState *state = ssc->states[ssc->active_object_index];
ssc->static_island %= state->element_map->totalIslands;
- /* If the initial active object doesn't have any stitchable islands */
- /* then no active island will be seen in the UI. Make sure we're on */
- /* a stitchable object and island. */
+ /* If the initial active object doesn't have any stitchable islands
+ * then no active island will be seen in the UI.
+ * Make sure we're on a stitchable object and island. */
if (!state->island_is_stitchable[ssc->static_island]) {
goto_next_island(ssc);
state = ssc->states[ssc->active_object_index];
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 87ae112a237..ae02097707c 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -498,7 +498,7 @@ static ParamHandle *construct_param_handle_subsurfed(const Scene *scene,
/* pointers to modifier data for unwrap control */
ModifierData *md;
SubsurfModifierData *smd_real;
- /* modifier initialization data, will control what type of subdivision will happen*/
+ /* Modifier initialization data, will control what type of subdivision will happen. */
SubsurfModifierData smd = {{NULL}};
/* Used to hold subsurfed Mesh */
DerivedMesh *derivedMesh, *initialDerived;
@@ -509,7 +509,7 @@ static ParamHandle *construct_param_handle_subsurfed(const Scene *scene,
MEdge *subsurfedEdges;
MPoly *subsurfedPolys;
MLoop *subsurfedLoops;
- /* number of vertices and faces for subsurfed mesh*/
+ /* Number of vertices and faces for subsurfed mesh. */
int numOfEdges, numOfFaces;
/* holds a map to editfaces for every subsurfed MFace.
@@ -1367,7 +1367,7 @@ static void uv_map_rotation_matrix_ex(float result[4][4],
rotup[2][2] = cosf(upangle) / radius;
rotup[0][0] = 1.0f / radius;
- /* calculate transforms*/
+ /* Calculate transforms. */
mul_m4_series(result, rotup, rotside, viewmatrix, rotobj);
}
@@ -2905,7 +2905,7 @@ void ED_uvedit_add_simple_uvs(Main *bmain, const Scene *scene, Object *ob)
/* select all uv loops first - pack parameters needs this to make sure charts are registered */
ED_uvedit_select_all(bm);
uvedit_unwrap_cube_project(bm, 1.0, false, NULL);
- /* set the margin really quickly before the packing operation*/
+ /* Set the margin really quickly before the packing operation. */
scene->toolsettings->uvcalc_margin = 0.001f;
uvedit_pack_islands(scene, ob, bm);
BM_mesh_bm_to_me(bmain, bm, me, (&(struct BMeshToMeshParams){0}));
diff --git a/source/blender/freestyle/intern/application/AppCanvas.h b/source/blender/freestyle/intern/application/AppCanvas.h
index 1ff7e781ce6..8329192e6d6 100644
--- a/source/blender/freestyle/intern/application/AppCanvas.h
+++ b/source/blender/freestyle/intern/application/AppCanvas.h
@@ -32,21 +32,21 @@ class AppCanvas : public Canvas {
AppCanvas(const AppCanvas &iBrother);
virtual ~AppCanvas();
- /*! operations that need to be done before a draw */
+ /** operations that need to be done before a draw */
virtual void preDraw();
- /*! operations that need to be done after a draw */
+ /** operations that need to be done after a draw */
virtual void postDraw();
- /*! Erases the layers and clears the canvas */
+ /** Erases the layers and clears the canvas */
virtual void Erase();
/* init the canvas */
virtual void init();
- /*! Reads a pixel area from the canvas */
+ /** Reads a pixel area from the canvas */
virtual void readColorPixels(int x, int y, int w, int h, RGBImage &oImage) const;
- /*! Reads a depth pixel area from the canvas */
+ /** Reads a depth pixel area from the canvas */
virtual void readDepthPixels(int x, int y, int w, int h, GrayImage &oImage) const;
virtual BBox<Vec3r> scene3DBBox() const;
@@ -55,7 +55,7 @@ class AppCanvas : public Canvas {
virtual void RenderStroke(Stroke *);
virtual void update();
- /*! accessors */
+ /** accessors */
virtual int width() const;
virtual int height() const;
virtual BBox<Vec2i> border() const;
@@ -67,7 +67,7 @@ class AppCanvas : public Canvas {
return _pViewer;
}
- /*! modifiers */
+ /** modifiers */
void setViewer(AppView *iViewer);
/* soc */
diff --git a/source/blender/freestyle/intern/application/AppView.h b/source/blender/freestyle/intern/application/AppView.h
index 3f07d2794c4..ccb2c61fef5 100644
--- a/source/blender/freestyle/intern/application/AppView.h
+++ b/source/blender/freestyle/intern/application/AppView.h
@@ -83,7 +83,7 @@ class AppView {
float _thickness;
public:
- /*! Sets the model to draw in the viewer
+ /** Sets the model to draw in the viewer
* iModel
* The Root Node of the model
*/
@@ -97,7 +97,7 @@ class AppView {
AddModel(iModel);
}
- /*! Adds a model for displaying in the viewer */
+ /** Adds a model for displaying in the viewer */
inline void AddModel(NodeGroup *iModel)
{
_ModelRootNode->AddChild(iModel);
@@ -226,14 +226,14 @@ class AppView {
real zfar();
public:
- /*! Core scene drawing */
+ /** Core scene drawing */
void DrawScene(SceneVisitor *iRenderer);
- /*! 2D Scene Drawing */
+ /** 2D Scene Drawing */
void Draw2DScene(SceneVisitor *iRenderer);
protected:
- /*! fabs or abs */
+ /** fabs or abs */
inline int rabs(int x)
{
return abs(x);
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
index 1be2fc3bc99..8fbda2b55f4 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
@@ -80,28 +80,28 @@ struct LoaderState {
class BlenderFileLoader {
public:
- /*! Builds a MaxFileLoader */
+ /** Builds a MaxFileLoader */
BlenderFileLoader(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph);
virtual ~BlenderFileLoader();
- /*! Loads the 3D scene and returns a pointer to the scene root node */
+ /** Loads the 3D scene and returns a pointer to the scene root node */
NodeGroup *Load();
- /*! Gets the number of read faces */
+ /** Gets the number of read faces */
inline unsigned int numFacesRead()
{
return _numFacesRead;
}
#if 0
- /*! Gets the smallest edge size read */
+ /** Gets the smallest edge size read */
inline real minEdgeSize()
{
return _minEdgeSize;
}
#endif
- /*! Modifiers */
+ /** Modifiers */
inline void setRenderMonitor(RenderMonitor *iRenderMonitor)
{
_pRenderMonitor = iRenderMonitor;
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
index 1b2e57529d6..beee7453b4c 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
@@ -44,7 +44,7 @@ class BlenderStrokeRenderer : public StrokeRenderer {
BlenderStrokeRenderer(Render *re, int render_count);
virtual ~BlenderStrokeRenderer();
- /*! Renders a stroke rep */
+ /** Renders a stroke rep */
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const;
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const;
diff --git a/source/blender/freestyle/intern/geometry/FastGrid.h b/source/blender/freestyle/intern/geometry/FastGrid.h
index ec47f36d644..524725d5464 100644
--- a/source/blender/freestyle/intern/geometry/FastGrid.h
+++ b/source/blender/freestyle/intern/geometry/FastGrid.h
@@ -25,7 +25,7 @@
namespace Freestyle {
-/*! Class to define a regular grid used for ray casting computations
+/** 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).
@@ -43,13 +43,13 @@ class FastGrid : public Grid {
clear();
}
- /*!
+ /**
* clears the grid
* Deletes all the cells, clears the hashtable, resets size, size of cell, number of cells.
*/
virtual void clear();
- /*! Sets the different parameters of the grid
+ /** Sets the different parameters of the grid
* orig
* The grid origin
* size
@@ -59,10 +59,10 @@ class FastGrid : public Grid {
*/
virtual void configure(const Vec3r &orig, const Vec3r &size, unsigned nb);
- /*! returns the cell whose coordinates are passed as argument */
+ /** returns the cell whose coordinates are passed as argument */
Cell *getCell(const Vec3u &p);
- /*! Fills the case p with the cell iCell */
+ /** Fills the case p with the cell iCell */
virtual void fillCell(const Vec3u &p, Cell &cell);
protected:
diff --git a/source/blender/freestyle/intern/geometry/FitCurve.h b/source/blender/freestyle/intern/geometry/FitCurve.h
index dc60d67b943..3e99893d66f 100644
--- a/source/blender/freestyle/intern/geometry/FitCurve.h
+++ b/source/blender/freestyle/intern/geometry/FitCurve.h
@@ -72,7 +72,7 @@ class FitCurveWrapper {
public:
~FitCurveWrapper();
- /*! Fits a set of 2D data points to a set of Bezier Curve segments
+ /** Fits a set of 2D data points to a set of Bezier Curve segments
* data
* Input data points
* oCurve
@@ -90,7 +90,7 @@ class FitCurveWrapper {
*/
void FitCurve(Vector2 *d, int nPts, double error);
- /*! Draws a Bezier curve segment
+ /** Draws a Bezier curve segment
* n
* degree of curve (=3)
* curve
diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp
index 7ec18fb2801..349347c1862 100644
--- a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp
+++ b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp
@@ -180,7 +180,7 @@ void GeomCleaner::SortAndCompressIndexedVertexArray(const float *iVertices,
delete[] tmpIndices;
}
-/*! Defines a hash table used for searching the Cells */
+/** Defines a hash table used for searching the Cells */
struct GeomCleanerHasher {
#define _MUL 950706376UL
#define _MOD 2147483647UL
diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.h b/source/blender/freestyle/intern/geometry/GeomCleaner.h
index 7abbf881548..6ad1f040972 100644
--- a/source/blender/freestyle/intern/geometry/GeomCleaner.h
+++ b/source/blender/freestyle/intern/geometry/GeomCleaner.h
@@ -42,7 +42,7 @@ class GeomCleaner {
{
}
- /*! Sorts an array of Indexed vertices
+ /** Sorts an array of Indexed vertices
* iVertices
* Array of vertices to sort.
* It is organized as a float series of vertex coordinates: XYZXYZXYZ...
@@ -70,7 +70,7 @@ class GeomCleaner {
float **oVertices,
unsigned **oIndices);
- /*! Compress a SORTED indexed vertex array by eliminating multiple
+ /** Compress a SORTED indexed vertex array by eliminating multiple
* appearing occurrences of a single vertex.
* iVertices
* The SORTED vertex array to compress.
@@ -99,7 +99,7 @@ class GeomCleaner {
unsigned *oVSize,
unsigned **oIndices);
- /*! Sorts and compress an array of indexed vertices.
+ /** Sorts and compress an array of indexed vertices.
* iVertices
* The vertex array to sort then compress. It is organized as a float series of
* vertex coordinates: XYZXYZXYZ...
@@ -127,7 +127,7 @@ class GeomCleaner {
unsigned *oVSize,
unsigned **oIndices);
- /*! Cleans an indexed vertex 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
@@ -161,10 +161,10 @@ class GeomCleaner {
#endif
};
-/*! Binary operators */
+/** Binary operators */
// inline bool operator<(const IndexedVertex& iv1, const IndexedVertex& iv2);
-/*! Class Indexed Vertex. Used to represent an indexed vertex by storing the vertex coordinates as
+/** Class Indexed Vertex. Used to represent an indexed vertex by storing the vertex coordinates as
* well as its index */
class IndexedVertex {
private:
@@ -182,7 +182,7 @@ class IndexedVertex {
_index = iIndex;
}
- /*! accessors */
+ /** accessors */
inline const Vec3f &vector() const
{
return _Vector;
@@ -208,7 +208,7 @@ class IndexedVertex {
return _Vector[2];
}
- /*! modifiers */
+ /** modifiers */
inline void setVector(const Vec3f &iVector)
{
_Vector = iVector;
@@ -219,7 +219,7 @@ class IndexedVertex {
_index = iIndex;
}
- /*! operators */
+ /** operators */
IndexedVertex &operator=(const IndexedVertex &iv)
{
_Vector = iv._Vector;
diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.h b/source/blender/freestyle/intern/geometry/GeomUtils.h
index 62d57f01264..a3ef88115f2 100644
--- a/source/blender/freestyle/intern/geometry/GeomUtils.h
+++ b/source/blender/freestyle/intern/geometry/GeomUtils.h
@@ -40,7 +40,7 @@ namespace GeomUtils {
//
/////////////////////////////////////////////////////////////////////////////
-/*! Computes the distance from a point P to a segment AB */
+/** Computes the distance from a point P to a segment AB */
template<class T> real distPointSegment(const T &P, const T &A, const T &B)
{
T AB, AP, BP;
@@ -97,16 +97,16 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
real &u, // I = P3 + u * P3P4
real epsilon = M_EPSILON);
-/*! check whether a 2D segment intersect a 2D region or not */
+/** check whether a 2D segment intersect a 2D region or not */
bool intersect2dSeg2dArea(const Vec2r &min, const Vec2r &max, const Vec2r &A, const Vec2r &B);
-/*! check whether a 2D segment is included in a 2D region or not */
+/** check whether a 2D segment is included in a 2D region or not */
bool include2dSeg2dArea(const Vec2r &min, const Vec2r &max, const Vec2r &A, const Vec2r &B);
-/*! Box-triangle overlap test, adapted from Tomas Akenine-Möller code */
+/** 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
+/** Fast, Minimum Storage Ray-Triangle Intersection, adapted from Tomas Möller and Ben Trumbore
* code. */
bool intersectRayTriangle(const Vec3r &orig,
const Vec3r &dir,
@@ -118,7 +118,7 @@ bool intersectRayTriangle(const Vec3r &orig,
real &v, // I = (1 - u - v) * v0 + u * v1 + v * v2
const real epsilon = M_EPSILON); // the epsilon to use
-/*! Intersection between plane and ray adapted from Graphics Gems, Didier Badouel */
+/** Intersection between plane and ray adapted from Graphics Gems, Didier Badouel */
intersection_test intersectRayPlane(const Vec3r &orig,
const Vec3r &dir, // ray origin and direction
// plane's normal and offset (plane = { P / P.N + d = 0 })
@@ -127,7 +127,7 @@ intersection_test intersectRayPlane(const Vec3r &orig,
real &t, // I = orig + t * dir
const real epsilon = M_EPSILON); // the epsilon to use
-/*! Intersection Ray-Bounding box (axis aligned).
+/** 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.
*/
@@ -142,7 +142,7 @@ bool intersectRayBBox(const Vec3r &orig,
real &tmax, // Imax = orig + tmax * dir is the second intersection
real epsilon = M_EPSILON); // the epsilon to use
-/*! Checks whether 3D point P lies inside or outside of the triangle ABC */
+/** Checks whether 3D point P lies inside or outside of the triangle ABC */
bool includePointTriangle(const Vec3r &P, const Vec3r &A, const Vec3r &B, const Vec3r &C);
void transformVertex(const Vec3r &vert, const Matrix44r &matrix, Vec3r &res);
@@ -156,7 +156,7 @@ Vec3r rotateVector(const Matrix44r &mat, const Vec3r &v);
//
/////////////////////////////////////////////////////////////////////////////
-/*! From world to image
+/** From world to image
* p
* point's coordinates expressed in world coordinates system
* q
@@ -176,7 +176,7 @@ void fromWorldToImage(const Vec3r &p,
const real projection_matrix[4][4],
const int viewport[4]);
-/*! From world to image
+/** From world to image
* p
* point's coordinates expressed in world coordinates system
* q
@@ -189,7 +189,7 @@ void fromWorldToImage(const Vec3r &p,
*/
void fromWorldToImage(const Vec3r &p, Vec3r &q, const real transform[4][4], const int viewport[4]);
-/*! Projects from world coordinates to camera coordinates
+/** Projects from world coordinates to camera coordinates
* Returns the point's coordinates expressed in the camera's
* coordinates system.
* p
@@ -202,7 +202,7 @@ void fromWorldToImage(const Vec3r &p, Vec3r &q, const real transform[4][4], cons
*/
void fromWorldToCamera(const Vec3r &p, Vec3r &q, const real model_view_matrix[4][4]);
-/*! Projects from World Coordinates to retina coordinates
+/** Projects from World Coordinates to retina coordinates
* Returns the point's coordinates expressed in Retina system.
* p
* point's coordinates expressed in camera system
@@ -214,7 +214,7 @@ void fromWorldToCamera(const Vec3r &p, Vec3r &q, const real model_view_matrix[4]
*/
void fromCameraToRetina(const Vec3r &p, Vec3r &q, const real projection_matrix[4][4]);
-/*! From retina to image.
+/** From retina to image.
* Returns the coordinates expressed in Image coordinates system.
* p
* point's coordinates expressed in retina system
@@ -225,7 +225,7 @@ void fromCameraToRetina(const Vec3r &p, Vec3r &q, const real projection_matrix[4
*/
void fromRetinaToImage(const Vec3r &p, Vec3r &q, const int viewport[4]);
-/*! From image to retina
+/** From image to retina
* p
* point's coordinates expressed in image system
* q
@@ -235,7 +235,7 @@ void fromRetinaToImage(const Vec3r &p, Vec3r &q, const int viewport[4]);
*/
void fromImageToRetina(const Vec3r &p, Vec3r &q, const int viewport[4]);
-/*! computes the coordinates of q in the camera coordinates system,
+/** computes the coordinates of q in the camera coordinates system,
* using the known z coordinates of the 3D point.
* That means that this method does not inverse any matrices,
* it only computes X and Y from x,y and Z)
@@ -249,7 +249,7 @@ void fromImageToRetina(const Vec3r &p, Vec3r &q, const int viewport[4]);
*/
void fromRetinaToCamera(const Vec3r &p, Vec3r &q, real focal, const real projection_matrix[4][4]);
-/*! Projects from camera coordinates to world coordinates
+/** Projects from camera coordinates to world coordinates
* Returns the point's coordinates expressed in the world's
* coordinates system.
* p
diff --git a/source/blender/freestyle/intern/geometry/Grid.h b/source/blender/freestyle/intern/geometry/Grid.h
index d0d92b62516..e6301063564 100644
--- a/source/blender/freestyle/intern/geometry/Grid.h
+++ b/source/blender/freestyle/intern/geometry/Grid.h
@@ -114,7 +114,7 @@ class GridVisitor {
#endif
};
-/*! Gathers all the occluders belonging to the cells traversed by the ray */
+/** Gathers all the occluders belonging to the cells traversed by the ray */
class allOccludersGridVisitor : public GridVisitor {
public:
allOccludersGridVisitor(OccludersSet &occluders) : GridVisitor(), occluders_(occluders)
@@ -137,7 +137,7 @@ class allOccludersGridVisitor : public GridVisitor {
OccludersSet &occluders_;
};
-/*! Finds the first intersection and breaks.
+/** Finds the first intersection and breaks.
* The occluder and the intersection information are stored and accessible.
*/
class firstIntersectionGridVisitor : public GridVisitor {
@@ -190,7 +190,7 @@ class firstIntersectionGridVisitor : public GridVisitor {
class Grid {
public:
- /*! Builds a Grid. Must be followed by a call to configure() */
+ /** Builds a Grid. Must be followed by a call to configure() */
Grid()
{
}
@@ -200,12 +200,12 @@ class Grid {
clear();
}
- /*! clears the grid
+ /** clears the grid
* Deletes all the cells, clears the hashtable, resets size, size of cell, number of cells.
*/
virtual void clear();
- /*! Sets the different parameters of the grid
+ /** Sets the different parameters of the grid
* orig
* The grid origin
* size
@@ -215,7 +215,7 @@ 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
+ /** 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
@@ -237,13 +237,13 @@ class Grid {
}
}
- /*! Fills the case corresponding to coord with the cell */
+ /** Fills the case corresponding to coord with the cell */
virtual void fillCell(const Vec3u &coord, Cell &cell) = 0;
- /*! returns the cell whose coordinates are passed as argument */
+ /** returns the cell whose coordinates are passed as argument */
virtual Cell *getCell(const Vec3u &coord) = 0;
- /*! returns the cell containing the point passed as argument.
+ /** 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
@@ -255,7 +255,7 @@ class Grid {
return getCell(coord);
}
- /*! Retrieves the x,y,z coordinates of the origin of the cell whose coordinates (i,j,k)
+ /** 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
@@ -269,7 +269,7 @@ class Grid {
}
}
- /*! 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
@@ -283,19 +283,19 @@ class Grid {
max_out = min_out + _cell_size;
}
- /*! inserts a convex polygon occluder
+ /** 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
*/
void insertOccluder(Polygon3r *occluder);
- /*! Adds an occluder to the list of occluders */
+ /** Adds an occluder to the list of occluders */
void addOccluder(Polygon3r *occluder)
{
_occluders.push_back(occluder);
}
- /*! Casts a ray between a starting point and an ending point
+ /** Casts a ray between a starting point and an ending point
* Returns the list of occluders contained in the cells intersected by this ray
* Starts with a call to InitRay.
*/
@@ -304,7 +304,7 @@ 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
+ /** 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.
*/
@@ -316,22 +316,22 @@ 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
+ /** 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);
- /*! Init all structures and values for computing the cells intersected by this new ray */
+ /** Init all structures and values for computing the cells intersected by this new ray */
void initRay(const Vec3r &orig, const Vec3r &end, unsigned timestamp);
- /*! Init all structures and values for computing the cells intersected by this infinite ray.
+ /** Init all structures and values for computing the cells intersected by this infinite ray.
* Returns false if the ray doesn't intersect the grid.
*/
bool initInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timestamp);
- /*! Accessors */
+ /** Accessors */
inline const Vec3r &getOrigin() const
{
return _orig;
@@ -362,7 +362,7 @@ class Grid {
}
protected:
- /*! Core of castRay and castInfiniteRay, find occluders along the given ray */
+ /** Core of castRay and castInfiniteRay, find occluders along the given ray */
inline void castRayInternal(GridVisitor &visitor)
{
Cell *current_cell = NULL;
@@ -383,7 +383,7 @@ class Grid {
} while ((!visitor.stop()) && (nextRayCell(_current_cell, _current_cell)));
}
- /*! returns the cell next to the cell passed as argument. */
+ /** returns the cell next to the cell passed as argument. */
bool nextRayCell(Vec3u &current_cell, Vec3u &next_cell);
unsigned int _timestamp;
diff --git a/source/blender/freestyle/intern/geometry/GridHelpers.h b/source/blender/freestyle/intern/geometry/GridHelpers.h
index 077688164b4..1eab92be889 100644
--- a/source/blender/freestyle/intern/geometry/GridHelpers.h
+++ b/source/blender/freestyle/intern/geometry/GridHelpers.h
@@ -38,7 +38,7 @@ namespace Freestyle {
namespace GridHelpers {
-/*! Computes the distance from a point P to a segment AB */
+/** Computes the distance from a point P to a segment AB */
template<class T> T closestPointToSegment(const T &P, const T &A, const T &B, real &distance)
{
T AB, AP, BP;
diff --git a/source/blender/freestyle/intern/geometry/HashGrid.h b/source/blender/freestyle/intern/geometry/HashGrid.h
index 6fb7f2b9cbe..74df4a355d1 100644
--- a/source/blender/freestyle/intern/geometry/HashGrid.h
+++ b/source/blender/freestyle/intern/geometry/HashGrid.h
@@ -37,7 +37,7 @@
namespace Freestyle {
-/*! Defines a hash table used for searching the Cells */
+/** Defines a hash table used for searching the Cells */
struct GridHasher {
#define _MUL 950706376UL
#define _MOD 2147483647UL
@@ -51,7 +51,7 @@ struct GridHasher {
#undef _MOD
};
-/*! Class to define a regular grid used for ray casting computations */
+/** Class to define a regular grid used for ray casting computations */
class HashGrid : public Grid {
public:
typedef map<Vec3u, Cell *> GridHashTable;
@@ -65,12 +65,12 @@ class HashGrid : public Grid {
clear();
}
- /*! clears the grid
+ /** clears the grid
* Deletes all the cells, clears the hashtable, resets size, size of cell, number of cells.
*/
virtual void clear();
- /*! Sets the different parameters of the grid
+ /** Sets the different parameters of the grid
* orig
* The grid origin
* size
@@ -80,7 +80,7 @@ class HashGrid : public Grid {
*/
virtual void configure(const Vec3r &orig, const Vec3r &size, unsigned nb);
- /*! returns the cell whose coordinates are passed as argument */
+ /** returns the cell whose coordinates are passed as argument */
virtual Cell *getCell(const Vec3u &p)
{
Cell *found_cell = NULL;
@@ -92,7 +92,7 @@ class HashGrid : public Grid {
return found_cell;
}
- /*! Fills the case p with the cell iCell */
+ /** Fills the case p with the cell iCell */
virtual void fillCell(const Vec3u &p, Cell &cell)
{
_cells[p] = &cell;
diff --git a/source/blender/freestyle/intern/geometry/Noise.h b/source/blender/freestyle/intern/geometry/Noise.h
index 27a91ded9e2..278444712df 100644
--- a/source/blender/freestyle/intern/geometry/Noise.h
+++ b/source/blender/freestyle/intern/geometry/Noise.h
@@ -37,33 +37,33 @@ namespace Freestyle {
using namespace Geometry;
-/*! Class to provide Perlin Noise functionalities */
+/** Class to provide Perlin Noise functionalities */
class Noise {
public:
- /*! Builds a Noise object */
+ /** Builds a Noise object */
Noise(long seed = -1);
- /*! Destructor */
+ /** Destructor */
~Noise()
{
}
- /*! Returns a noise value for a 1D element */
+ /** Returns a noise value for a 1D element */
float turbulence1(float arg, float freq, float amp, unsigned oct = 4);
- /*! Returns a noise value for a 2D element */
+ /** Returns a noise value for a 2D element */
float turbulence2(Vec2f &v, float freq, float amp, unsigned oct = 4);
- /*! Returns a noise value for a 3D element */
+ /** Returns a noise value for a 3D element */
float turbulence3(Vec3f &v, float freq, float amp, unsigned oct = 4);
- /*! Returns a smooth noise value for a 1D element */
+ /** Returns a smooth noise value for a 1D element */
float smoothNoise1(float arg);
- /*! Returns a smooth noise value for a 2D element */
+ /** Returns a smooth noise value for a 2D element */
float smoothNoise2(Vec2f &vec);
- /*! Returns a smooth noise value for a 3D element */
+ /** Returns a smooth noise value for a 3D element */
float smoothNoise3(Vec3f &vec);
private:
diff --git a/source/blender/freestyle/intern/geometry/Polygon.h b/source/blender/freestyle/intern/geometry/Polygon.h
index f6f827fd0f2..34511bf4e34 100644
--- a/source/blender/freestyle/intern/geometry/Polygon.h
+++ b/source/blender/freestyle/intern/geometry/Polygon.h
@@ -205,7 +205,7 @@ class Polygon3r : public Polygon<Vec3r> {
return _normal;
}
- /*! Check whether the Polygon intersects with the ray or not */
+ /** Check whether the Polygon intersects with the ray or not */
inline bool rayIntersect(const Vec3r &orig,
const Vec3r &dir,
real &t,
diff --git a/source/blender/freestyle/intern/geometry/SweepLine.h b/source/blender/freestyle/intern/geometry/SweepLine.h
index d7d379d82f2..1beae73b68a 100644
--- a/source/blender/freestyle/intern/geometry/SweepLine.h
+++ b/source/blender/freestyle/intern/geometry/SweepLine.h
@@ -30,7 +30,7 @@
namespace Freestyle {
-/*! Class to define the intersection between two segments*/
+/** Class to define the intersection between two segments. */
template<class Edge> class Intersection {
public:
template<class EdgeClass> Intersection(EdgeClass *eA, real ta, EdgeClass *eB, real tb)
@@ -51,7 +51,7 @@ template<class Edge> class Intersection {
userdata = 0;
}
- /*! returns the parameter giving the intersection, for the edge iEdge */
+ /** returns the parameter giving the intersection, for the edge iEdge */
real getParameter(Edge *iEdge)
{
if (iEdge == EdgeA) {
@@ -144,7 +144,7 @@ template<class T, class Point> class Segment {
_Intersections.push_back(i);
}
- /*! Checks for a common vertex with another edge */
+ /** Checks for a common vertex with another edge */
inline bool CommonVertex(const Segment<T, Point> &S, Point &CP)
{
if ((A == S[0]) || (A == S[1])) {
@@ -190,7 +190,7 @@ 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
+/** 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 {
diff --git a/source/blender/freestyle/intern/image/GaussianFilter.h b/source/blender/freestyle/intern/image/GaussianFilter.h
index ff765e619a8..2cb3e7d7ac5 100644
--- a/source/blender/freestyle/intern/image/GaussianFilter.h
+++ b/source/blender/freestyle/intern/image/GaussianFilter.h
@@ -54,7 +54,7 @@ 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
+ /** 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:
@@ -70,12 +70,12 @@ class GaussianFilter {
*/
template<class Map> float getSmoothedPixel(Map *map, int x, int y);
- /*! Compute the mask size and returns the REAL mask size ((2*_maskSize)-1)
+ /** Compute the mask size and returns the REAL mask size ((2*_maskSize)-1)
* This method is provided for convenience.
*/
static int computeMaskSize(float sigma);
- /*! accessors */
+ /** accessors */
inline float sigma() const
{
return _sigma;
@@ -91,7 +91,7 @@ class GaussianFilter {
return _bound;
}
- /*! modifiers */
+ /** modifiers */
void setSigma(float sigma);
#if 0
void SetMaskSize(int size)
diff --git a/source/blender/freestyle/intern/image/Image.h b/source/blender/freestyle/intern/image/Image.h
index 385e243a1a2..21cb435b13a 100644
--- a/source/blender/freestyle/intern/image/Image.h
+++ b/source/blender/freestyle/intern/image/Image.h
@@ -34,14 +34,14 @@ namespace Freestyle {
//
///////////////////////////////////////////////////////////////////////////////
-/*! This class allows the storing of part of an image, while allowing a normal access to its pixel
+/** 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:
- /*! Default constructor */
+ /** Default constructor */
FrsImage()
{
_storedWidth = 0;
@@ -52,7 +52,7 @@ class FrsImage {
_Oy = 0;
}
- /*! Copy constructor */
+ /** Copy constructor */
FrsImage(const FrsImage &brother)
{
_storedWidth = brother._storedWidth;
@@ -63,7 +63,7 @@ class FrsImage {
_Oy = brother._Oy;
}
- /*! Builds an FrsImage from its width and height.
+ /** Builds an FrsImage from its width and height.
* The memory is allocated consequently.
*/
FrsImage(unsigned w, unsigned h)
@@ -76,7 +76,7 @@ class FrsImage {
_Oy = 0;
}
- /*! Builds a partial-storing image.
+ /** Builds a partial-storing image.
* \param w:
* The width of the complete image
* \param h:
@@ -100,7 +100,7 @@ class FrsImage {
_Oy = oy;
}
- /*! Operator= */
+ /** Operator= */
FrsImage &operator=(const FrsImage &brother)
{
_width = brother._width;
@@ -112,27 +112,27 @@ class FrsImage {
return *this;
}
- /*! Destructor */
+ /** Destructor */
virtual ~FrsImage()
{
}
- /*! Returns the width of the complete image */
+ /** Returns the width of the complete image */
inline unsigned width() const
{
return _width;
}
- /*! Returns the height of the complete image */
+ /** Returns the height of the complete image */
inline unsigned height() const
{
return _height;
}
- /*! Returns the gray value for pixel x,y */
+ /** Returns the gray value for pixel x,y */
virtual float pixel(unsigned x, unsigned y) const = 0;
- /*! Sets the array.
+ /** Sets the array.
* \param array:
* The array containing the values we wish to store.
* Its size is sw*sh.
@@ -160,7 +160,7 @@ class FrsImage {
unsigned y,
bool copy = true) = 0;
- /*! Returns the array containing the pixels values.
+ /** Returns the array containing the pixels values.
* Its size is sw*sh, i.e. potentially a smaller rectangular part of the complete image.
*/
virtual float *getArray() = 0;
@@ -206,7 +206,7 @@ class RGBImage : public FrsImage {
memcpy(_rgb, rgb, 3 * _width * _height * sizeof(float));
}
- /*! Builds an RGB partial image from the useful part buffer.
+ /** 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
@@ -279,7 +279,7 @@ class RGBImage : public FrsImage {
return res / 32.0f;
}
- /*! Sets the RGB array.
+ /** Sets the RGB array.
* copy
* If true, the array is copied, otherwise the pointer is copied
*/
@@ -333,7 +333,7 @@ class GrayImage : public FrsImage {
memcpy(_lvl, brother._lvl, _storedWidth * _storedHeight * sizeof(*_lvl));
}
- /*! Builds an empty gray image */
+ /** Builds an empty gray image */
GrayImage(unsigned w, unsigned h) : FrsImage(w, h)
{
_lvl = new float[_width * _height];
@@ -345,7 +345,7 @@ class GrayImage : public FrsImage {
memcpy(_lvl, lvl, _width * _height * sizeof(*_lvl));
}
- /*! Builds a partial image from the useful part buffer.
+ /** 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
@@ -391,7 +391,7 @@ class GrayImage : public FrsImage {
return _lvl[(y - _Oy) * _storedWidth + (x - _Ox)];
}
- /*! Sets the array.
+ /** Sets the array.
* copy
* If true, the array is copied, otherwise the pounsigneder is copied
*/
@@ -418,7 +418,7 @@ class GrayImage : public FrsImage {
memcpy(_lvl, lvl, _storedWidth * _storedHeight * sizeof(float));
}
- /*! Returns the array containing the gray values. */
+ /** Returns the array containing the gray values. */
virtual float *getArray()
{
return _lvl;
diff --git a/source/blender/freestyle/intern/image/ImagePyramid.h b/source/blender/freestyle/intern/image/ImagePyramid.h
index 3b4e5eda52a..66df1ec728a 100644
--- a/source/blender/freestyle/intern/image/ImagePyramid.h
+++ b/source/blender/freestyle/intern/image/ImagePyramid.h
@@ -45,17 +45,17 @@ class ImagePyramid {
// ImagePyramid(const GrayImage& level0, unsigned nbLevels);
virtual ~ImagePyramid();
- /*! Builds the pyramid.
+ /** Builds the pyramid.
* must be overloaded by inherited classes.
* if nbLevels==0, the complete pyramid is built
*/
virtual void BuildPyramid(const GrayImage &level0, unsigned nbLevels) = 0;
- /*! Builds a pyramid without copying the base level */
+ /** Builds a pyramid without copying the base level */
virtual void BuildPyramid(GrayImage *level0, unsigned nbLevels) = 0;
virtual GrayImage *getLevel(int l);
- /*! Returns the pixel x,y using bilinear interpolation.
+ /** Returns the pixel x,y using bilinear interpolation.
* \param x:
* the abscissa specified in the finest level coordinate system
* \param y:
@@ -65,13 +65,13 @@ class ImagePyramid {
*/
virtual float pixel(int x, int y, int level = 0);
- /*! Returns the width of the level-th level image */
+ /** Returns the width of the level-th level image */
virtual int width(int level = 0);
- /*! Returns the height of the level-th level image */
+ /** Returns the height of the level-th level image */
virtual int height(int level = 0);
- /*! Returns the number of levels in the pyramid */
+ /** Returns the number of levels in the pyramid */
inline int getNumberOfLevels() const
{
return _levels.size();
diff --git a/source/blender/freestyle/intern/python/BPy_BBox.cpp b/source/blender/freestyle/intern/python/BPy_BBox.cpp
index 78431aa6728..509be04ee3f 100644
--- a/source/blender/freestyle/intern/python/BPy_BBox.cpp
+++ b/source/blender/freestyle/intern/python/BPy_BBox.cpp
@@ -91,7 +91,7 @@ PyTypeObject BBox_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_BBox.h b/source/blender/freestyle/intern/python/BPy_BBox.h
index 889dbc62a41..9d81a62bbcc 100644
--- a/source/blender/freestyle/intern/python/BPy_BBox.h
+++ b/source/blender/freestyle/intern/python/BPy_BBox.h
@@ -39,7 +39,8 @@ extern PyTypeObject BBox_Type;
/*---------------------------Python BPy_BBox structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::BBox<Freestyle::Geometry::Vec3r> *bb;
+ PyObject_HEAD
+ Freestyle::BBox<Freestyle::Geometry::Vec3r> *bb;
} BPy_BBox;
/*---------------------------Python BPy_BBox visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
index 652b576852d..6431fd3bcd9 100644
--- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
@@ -163,7 +163,7 @@ PyTypeObject BinaryPredicate0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)BinaryPredicate0D___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h
index a368d4cd47e..0d494092388 100644
--- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h
+++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h
@@ -39,7 +39,8 @@ extern PyTypeObject BinaryPredicate0D_Type;
/*---------------------------Python BPy_BinaryPredicate0D structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::BinaryPredicate0D *bp0D;
+ PyObject_HEAD
+ Freestyle::BinaryPredicate0D *bp0D;
} BPy_BinaryPredicate0D;
/*---------------------------Python BPy_BinaryPredicate0D visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
index 37762f1b8b3..a623d359189 100644
--- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
@@ -197,7 +197,7 @@ PyTypeObject BinaryPredicate1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)BinaryPredicate1D___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h
index b34fad9e213..3e5ff76b5f9 100644
--- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h
+++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h
@@ -39,7 +39,8 @@ extern PyTypeObject BinaryPredicate1D_Type;
/*---------------------------Python BPy_BinaryPredicate1D structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::BinaryPredicate1D *bp1D;
+ PyObject_HEAD
+ Freestyle::BinaryPredicate1D *bp1D;
} BPy_BinaryPredicate1D;
/*---------------------------Python BPy_BinaryPredicate1D visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
index 48b2ad767d2..deec1fb681d 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
+++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
@@ -548,7 +548,7 @@ PyTypeObject FrsMaterial_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- (hashfunc)FrsMaterial_hash, /* tp_hash */
+ (hashfunc)FrsMaterial_hash, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h
index 084fcef9a62..1104e2d5d77 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h
+++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h
@@ -39,7 +39,8 @@ extern PyTypeObject FrsMaterial_Type;
/*---------------------------Python BPy_FrsMaterial structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::FrsMaterial *m;
+ PyObject_HEAD
+ Freestyle::FrsMaterial *m;
} BPy_FrsMaterial;
/*---------------------------Python BPy_FrsMaterial visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
index 40127064875..4c339a54bb3 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
+++ b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
@@ -340,7 +340,7 @@ PyTypeObject FrsNoise_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_FrsNoise.h b/source/blender/freestyle/intern/python/BPy_FrsNoise.h
index 0f8f2d3242c..ac53282eb2a 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsNoise.h
+++ b/source/blender/freestyle/intern/python/BPy_FrsNoise.h
@@ -39,7 +39,8 @@ extern PyTypeObject FrsNoise_Type;
/*---------------------------Python BPy_FrsNoise structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::Noise *n;
+ PyObject_HEAD
+ Freestyle::Noise *n;
Freestyle::PseudoNoise *pn;
} BPy_FrsNoise;
diff --git a/source/blender/freestyle/intern/python/BPy_Id.cpp b/source/blender/freestyle/intern/python/BPy_Id.cpp
index 752bea16fb1..4b1d7c64fc4 100644
--- a/source/blender/freestyle/intern/python/BPy_Id.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Id.cpp
@@ -181,7 +181,7 @@ PyTypeObject Id_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_Id.h b/source/blender/freestyle/intern/python/BPy_Id.h
index 51a70a391b1..e3c211381ca 100644
--- a/source/blender/freestyle/intern/python/BPy_Id.h
+++ b/source/blender/freestyle/intern/python/BPy_Id.h
@@ -40,7 +40,8 @@ extern PyTypeObject Id_Type;
/*---------------------------Python BPy_Id structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::Id *id;
+ PyObject_HEAD
+ Freestyle::Id *id;
} BPy_Id;
/*---------------------------Python BPy_Id visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
index 2af019e8fe2..92a03a017c5 100644
--- a/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
+++ b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
@@ -163,7 +163,7 @@ PyTypeObject IntegrationType_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
index 9a86e61e623..2f2ba070932 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
@@ -323,7 +323,7 @@ PyTypeObject Interface0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.h b/source/blender/freestyle/intern/python/BPy_Interface0D.h
index 9734378f446..75a7e42e316 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface0D.h
+++ b/source/blender/freestyle/intern/python/BPy_Interface0D.h
@@ -39,7 +39,8 @@ extern PyTypeObject Interface0D_Type;
/*---------------------------Python BPy_Interface0D structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::Interface0D *if0D;
+ PyObject_HEAD
+ Freestyle::Interface0D *if0D;
bool borrowed; /* true if *if0D is a borrowed object */
} BPy_Interface0D;
diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
index 61884ee63e5..10deca97273 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
@@ -351,7 +351,7 @@ PyTypeObject Interface1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.h b/source/blender/freestyle/intern/python/BPy_Interface1D.h
index 4ed562c24f7..ad6bb5aebec 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface1D.h
+++ b/source/blender/freestyle/intern/python/BPy_Interface1D.h
@@ -39,7 +39,8 @@ extern PyTypeObject Interface1D_Type;
/*---------------------------Python BPy_Interface1D structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::Interface1D *if1D;
+ PyObject_HEAD
+ Freestyle::Interface1D *if1D;
bool borrowed; /* true if *if1D is a borrowed object */
} BPy_Interface1D;
diff --git a/source/blender/freestyle/intern/python/BPy_Iterator.cpp b/source/blender/freestyle/intern/python/BPy_Iterator.cpp
index bc6d8032ea2..2f69b8c3256 100644
--- a/source/blender/freestyle/intern/python/BPy_Iterator.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Iterator.cpp
@@ -238,7 +238,7 @@ PyTypeObject Iterator_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_Iterator.h b/source/blender/freestyle/intern/python/BPy_Iterator.h
index 7094384140f..c7f64c3844e 100644
--- a/source/blender/freestyle/intern/python/BPy_Iterator.h
+++ b/source/blender/freestyle/intern/python/BPy_Iterator.h
@@ -38,7 +38,8 @@ extern PyTypeObject Iterator_Type;
/*---------------------------Python BPy_Iterator structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::Iterator *it;
+ PyObject_HEAD
+ Freestyle::Iterator *it;
} BPy_Iterator;
/*---------------------------Python BPy_Iterator visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_MediumType.cpp b/source/blender/freestyle/intern/python/BPy_MediumType.cpp
index d9d5e683c4f..eeb16433bff 100644
--- a/source/blender/freestyle/intern/python/BPy_MediumType.cpp
+++ b/source/blender/freestyle/intern/python/BPy_MediumType.cpp
@@ -55,7 +55,7 @@ PyTypeObject MediumType_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_Nature.cpp b/source/blender/freestyle/intern/python/BPy_Nature.cpp
index 45335f27619..6fe4789b09b 100644
--- a/source/blender/freestyle/intern/python/BPy_Nature.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Nature.cpp
@@ -117,7 +117,7 @@ PyTypeObject Nature_Type = {
&nature_as_number, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_Operators.cpp b/source/blender/freestyle/intern/python/BPy_Operators.cpp
index 004fa118cf6..caf11bb5072 100644
--- a/source/blender/freestyle/intern/python/BPy_Operators.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Operators.cpp
@@ -780,7 +780,7 @@ PyTypeObject Operators_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp
index 0ea02d8a3f6..9ab3e634152 100644
--- a/source/blender/freestyle/intern/python/BPy_SShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp
@@ -291,7 +291,7 @@ PyTypeObject SShape_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_SShape.h b/source/blender/freestyle/intern/python/BPy_SShape.h
index a6fb090a537..404d0ebc602 100644
--- a/source/blender/freestyle/intern/python/BPy_SShape.h
+++ b/source/blender/freestyle/intern/python/BPy_SShape.h
@@ -38,7 +38,8 @@ extern PyTypeObject SShape_Type;
/*---------------------------Python BPy_SShape structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::SShape *ss;
+ PyObject_HEAD
+ Freestyle::SShape *ss;
bool borrowed; /* true if *ss is a borrowed object */
} BPy_SShape;
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
index 256fa5be290..54117115b95 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
@@ -687,7 +687,7 @@ PyTypeObject StrokeAttribute_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
index 9c0a7368dcb..b3280095e1e 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
@@ -39,7 +39,8 @@ extern PyTypeObject StrokeAttribute_Type;
/*---------------------------Python BPy_StrokeAttribute structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::StrokeAttribute *sa;
+ PyObject_HEAD
+ Freestyle::StrokeAttribute *sa;
bool borrowed; /* true if *sa is a borrowed reference */
} BPy_StrokeAttribute;
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
index 9ce91b8a486..69795df9552 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
@@ -292,7 +292,7 @@ PyTypeObject StrokeShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.h b/source/blender/freestyle/intern/python/BPy_StrokeShader.h
index 74c5df52312..0881c07caf1 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeShader.h
+++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.h
@@ -41,7 +41,8 @@ extern PyTypeObject StrokeShader_Type;
/*---------------------------Python BPy_StrokeShader structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::StrokeShader *ss;
+ PyObject_HEAD
+ Freestyle::StrokeShader *ss;
} BPy_StrokeShader;
/*---------------------------Python BPy_StrokeShader visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp
index 1bc569860aa..8b5a51ed3fb 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp
@@ -134,7 +134,7 @@ PyTypeObject UnaryFunction0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
index ef3021faf48..86fd6b39ab8 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
@@ -39,7 +39,8 @@ extern PyTypeObject UnaryFunction0D_Type;
/*---------------------------Python BPy_UnaryFunction0D structure definition----------*/
typedef struct {
- PyObject_HEAD PyObject *py_uf0D;
+ PyObject_HEAD
+ PyObject *py_uf0D;
} BPy_UnaryFunction0D;
/*---------------------------Python BPy_UnaryFunction0D visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp
index c11640aa136..2464b852f52 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp
@@ -128,7 +128,7 @@ PyTypeObject UnaryFunction1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
index 4613d58c2b7..12159c79885 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
@@ -39,7 +39,8 @@ extern PyTypeObject UnaryFunction1D_Type;
/*---------------------------Python BPy_UnaryFunction1D structure definition----------*/
typedef struct {
- PyObject_HEAD PyObject *py_uf1D;
+ PyObject_HEAD
+ PyObject *py_uf1D;
} BPy_UnaryFunction1D;
/*---------------------------Python BPy_UnaryFunction1D visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
index cc9f666fbdd..e8aaf3d7ef3 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
@@ -177,7 +177,7 @@ PyTypeObject UnaryPredicate0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryPredicate0D___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h
index 3d45c2fc701..027994568b4 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h
@@ -39,7 +39,8 @@ extern PyTypeObject UnaryPredicate0D_Type;
/*---------------------------Python BPy_UnaryPredicate0D structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::UnaryPredicate0D *up0D;
+ PyObject_HEAD
+ Freestyle::UnaryPredicate0D *up0D;
} BPy_UnaryPredicate0D;
/*---------------------------Python BPy_UnaryPredicate0D visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
index 41c0acc088c..82b1a04523e 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
@@ -235,7 +235,7 @@ PyTypeObject UnaryPredicate1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryPredicate1D___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h
index 0139ed8af77..0f8b00f7f3c 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h
@@ -39,7 +39,8 @@ extern PyTypeObject UnaryPredicate1D_Type;
/*---------------------------Python BPy_UnaryPredicate1D structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::UnaryPredicate1D *up1D;
+ PyObject_HEAD
+ Freestyle::UnaryPredicate1D *up1D;
} BPy_UnaryPredicate1D;
/*---------------------------Python BPy_UnaryPredicate1D visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp
index 269959a19c3..cf144b05d0e 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp
@@ -194,7 +194,7 @@ PyTypeObject ViewMap_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_ViewMap.h b/source/blender/freestyle/intern/python/BPy_ViewMap.h
index 2222b327dc2..ac607957726 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewMap.h
+++ b/source/blender/freestyle/intern/python/BPy_ViewMap.h
@@ -38,7 +38,8 @@ extern PyTypeObject ViewMap_Type;
/*---------------------------Python BPy_ViewMap structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::ViewMap *vm;
+ PyObject_HEAD
+ Freestyle::ViewMap *vm;
} BPy_ViewMap;
/*---------------------------Python BPy_ViewMap visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
index dd9d169dac2..6153dde26bd 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
@@ -362,7 +362,7 @@ PyTypeObject ViewShape_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.h b/source/blender/freestyle/intern/python/BPy_ViewShape.h
index 8401c4378f0..542e6d179a5 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewShape.h
+++ b/source/blender/freestyle/intern/python/BPy_ViewShape.h
@@ -40,7 +40,8 @@ extern PyTypeObject ViewShape_Type;
/*---------------------------Python BPy_ViewShape structure definition----------*/
typedef struct {
- PyObject_HEAD Freestyle::ViewShape *vs;
+ PyObject_HEAD
+ Freestyle::ViewShape *vs;
bool borrowed; /* true if *vs a borrowed object */
BPy_SShape *py_ss;
} BPy_ViewShape;
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp
index ed09025a45e..c66ca1e9f43 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp
@@ -69,7 +69,7 @@ PyTypeObject FalseBP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp
index 9d4f0693af9..6d52e435d3b 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp
@@ -71,7 +71,7 @@ PyTypeObject Length2DBP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp
index 372d250c628..93ae6a59ee0 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp
@@ -70,7 +70,7 @@ PyTypeObject SameShapeIdBP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp
index 04bd36738d1..30c3d9f2489 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp
@@ -70,7 +70,7 @@ PyTypeObject TrueBP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
index 337d0fa3020..7b3b291bb61 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
@@ -100,7 +100,7 @@ PyTypeObject ViewMapGradientNormBP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
index 2367c3f9cb5..945215d3eea 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
@@ -252,7 +252,7 @@ PyTypeObject CurvePoint_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
index 4f1b57915b2..7d2874e5d85 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
@@ -465,7 +465,7 @@ PyTypeObject SVertex_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
index 600ee37aa55..cd831417577 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
@@ -174,7 +174,7 @@ PyTypeObject ViewVertex_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
index 79e537d48c0..6104005464c 100644
--- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
@@ -371,7 +371,7 @@ PyTypeObject StrokeVertex_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp
index 7b782b513b6..3c0ee9fd9a3 100644
--- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp
@@ -119,7 +119,7 @@ PyTypeObject NonTVertex_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp
index eecede4f1f3..9fe39b3e359 100644
--- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp
@@ -229,7 +229,7 @@ PyTypeObject TVertex_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
index e8f80f515df..be529953815 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
@@ -368,7 +368,7 @@ PyTypeObject FEdge_Type = {
nullptr, /* tp_as_number */
&BPy_FEdge_as_sequence, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
index bf7feb7be27..fe25051b924 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
@@ -200,7 +200,7 @@ PyTypeObject FrsCurve_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
index 8df40087f9b..62641499740 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
@@ -511,7 +511,7 @@ PyTypeObject Stroke_Type = {
nullptr, /* tp_as_number */
&BPy_Stroke_as_sequence, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
index eee5dc095a6..dee587407a7 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
@@ -396,7 +396,7 @@ PyTypeObject ViewEdge_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
index 5de2f435469..a1cf5c5146b 100644
--- a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
@@ -160,7 +160,7 @@ PyTypeObject Chain_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
index 538e5d3bf85..93958b626bf 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
@@ -418,7 +418,7 @@ PyTypeObject FEdgeSharp_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
index 8f244fb203d..b4651345297 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
@@ -263,7 +263,7 @@ PyTypeObject FEdgeSmooth_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
index 6945e3f2b51..a7406b080dd 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
@@ -196,7 +196,7 @@ PyTypeObject AdjacencyIterator_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
index 94d8952ef42..7c64420a058 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
@@ -177,7 +177,7 @@ PyTypeObject ChainPredicateIterator_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
index 36c251bb916..594d4c4fd5e 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
@@ -131,7 +131,7 @@ PyTypeObject ChainSilhouetteIterator_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
index 10b3ccdc496..907a411788f 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
@@ -265,7 +265,7 @@ PyTypeObject ChainingIterator_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
index 4c93b8337cf..57172a9006d 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
@@ -145,7 +145,7 @@ PyTypeObject CurvePointIterator_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
index 2ac3857375a..2201da36b8a 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
@@ -220,7 +220,7 @@ PyTypeObject Interface0DIterator_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
index ffb90281442..6666d742415 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
@@ -172,7 +172,7 @@ PyTypeObject SVertexIterator_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
index f94ab4d3b8f..2d0ce0d54c6 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
@@ -303,7 +303,7 @@ PyTypeObject StrokeVertexIterator_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
index c878178f9ca..391ebae4cdd 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
@@ -250,7 +250,7 @@ PyTypeObject ViewEdgeIterator_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
index 5da124ce40a..e33f2c3fd88 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
@@ -154,7 +154,7 @@ PyTypeObject orientedViewEdgeIterator_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
index 2171b7bb2b9..ff0fed08e0f 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
@@ -81,7 +81,7 @@ PyTypeObject BackboneStretcherShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp
index 69f1814e38e..2a610e375ee 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp
@@ -81,7 +81,7 @@ PyTypeObject BezierCurveShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
index 06785ca5617..fcf415a82fd 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
@@ -101,7 +101,7 @@ PyTypeObject BlenderTextureShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp
index a5aa5e188ff..ab9aa2ffa94 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp
@@ -99,7 +99,7 @@ PyTypeObject CalligraphicShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp
index 2642f109acf..05a98c20f52 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp
@@ -80,7 +80,7 @@ PyTypeObject ColorNoiseShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp
index a1e20542acf..6b19590a169 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp
@@ -86,7 +86,7 @@ PyTypeObject ConstantColorShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
index 6e338a5f6be..795ec2fb87e 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
@@ -80,7 +80,7 @@ PyTypeObject ConstantThicknessShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
index db4b6df6cb4..780f9255b4a 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
@@ -86,7 +86,7 @@ PyTypeObject ConstrainedIncreasingThicknessShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp
index 7365c369fb3..3fc16d9d0ea 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp
@@ -88,7 +88,7 @@ PyTypeObject GuidingLinesShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp
index d6f33c3a295..f6ae0330b48 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp
@@ -108,7 +108,7 @@ PyTypeObject IncreasingColorShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
index 296d3fb0713..fa60aba34e4 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
@@ -86,7 +86,7 @@ PyTypeObject IncreasingThicknessShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
index 68c14e1151c..2ba49289607 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
@@ -87,7 +87,7 @@ PyTypeObject PolygonalizationShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp
index e4aeb612cc4..fc50c9f1e02 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp
@@ -78,7 +78,7 @@ PyTypeObject SamplingShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
index 55aee8b8a56..ab39b9ad883 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
@@ -110,7 +110,7 @@ PyTypeObject SmoothingShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp
index 85e49b51f47..dabf7b3b9f4 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp
@@ -104,7 +104,7 @@ PyTypeObject SpatialNoiseShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
index d914b180f6f..7961944af45 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
@@ -80,7 +80,7 @@ PyTypeObject StrokeTextureStepShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp
index db1e634f91e..1a52f76e9dc 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp
@@ -82,7 +82,7 @@ PyTypeObject ThicknessNoiseShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp
index ee1ac7697db..6f0146cb07f 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp
@@ -79,7 +79,7 @@ PyTypeObject TipRemoverShader_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
index d2f138dc176..1a3a8a09488 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
@@ -197,7 +197,7 @@ PyTypeObject UnaryFunction0DDouble_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction0DDouble___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
index 6e55b7d9bcc..6d203b81aec 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
@@ -136,7 +136,7 @@ PyTypeObject UnaryFunction0DEdgeNature_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction0DEdgeNature___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp
index 23aece94c39..81363f78151 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp
@@ -173,7 +173,7 @@ PyTypeObject UnaryFunction0DFloat_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction0DFloat___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp
index 6f904898458..98b21230dfe 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp
@@ -132,7 +132,7 @@ PyTypeObject UnaryFunction0DId_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction0DId___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
index 92dc5901b5c..db606ee089d 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
@@ -135,7 +135,7 @@ PyTypeObject UnaryFunction0DMaterial_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction0DMaterial___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
index 829c9d0b7c1..dc0a92488ae 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
@@ -136,7 +136,7 @@ PyTypeObject UnaryFunction0DUnsigned_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction0DUnsigned___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp
index a7248eebae2..6c5334a1cc2 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp
@@ -141,7 +141,7 @@ PyTypeObject UnaryFunction0DVec2f_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction0DVec2f___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
index 1810648b0b0..67be2f8e09a 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
@@ -134,7 +134,7 @@ PyTypeObject UnaryFunction0DVec3f_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction0DVec3f___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
index 4c015cec410..1f3986fd4e0 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
@@ -145,7 +145,7 @@ PyTypeObject UnaryFunction0DVectorViewShape_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction0DVectorViewShape___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
index c2f0df9798c..9f2caedde78 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
@@ -143,7 +143,7 @@ PyTypeObject UnaryFunction0DViewShape_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction0DViewShape___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp
index 4aed82a14d3..a15cbe08385 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp
@@ -84,7 +84,7 @@ PyTypeObject ShapeIdF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp
index 6b6e06d6efd..d9ba37ff306 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp
@@ -87,7 +87,7 @@ PyTypeObject MaterialF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp
index c6fb66270f7..df05ce055de 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp
@@ -78,7 +78,7 @@ PyTypeObject CurveNatureF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp
index 66c0243727d..0f32a7f6dda 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp
@@ -80,7 +80,7 @@ PyTypeObject Normal2DF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 4ade0e2e995..fe3890a0546 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
@@ -82,7 +82,7 @@ PyTypeObject VertexOrientation2DF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 f634eaa0327..0e2f9d38e2b 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
@@ -82,7 +82,7 @@ PyTypeObject VertexOrientation3DF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp
index c624e3eb136..3629ac50708 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp
@@ -77,7 +77,7 @@ PyTypeObject GetOccludeeF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp
index 8234e7f4351..c1f34befc8b 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp
@@ -77,7 +77,7 @@ PyTypeObject GetShapeF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp
index 217fe1cb55a..92702c194a7 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp
@@ -82,7 +82,7 @@ PyTypeObject Curvature2DAngleF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp
index b0777adb311..08b17ff3194 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp
@@ -87,7 +87,7 @@ PyTypeObject DensityF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp
index 6c230a1207d..2b2b1c616f0 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp
@@ -77,7 +77,7 @@ PyTypeObject GetProjectedXF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp
index 43913316567..1dc6b43a794 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp
@@ -77,7 +77,7 @@ PyTypeObject GetProjectedYF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp
index a7d1d05c3ca..a3f7d60fc04 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp
@@ -77,7 +77,7 @@ PyTypeObject GetProjectedZF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp
index 94abd089db1..8c53c1a412e 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp
@@ -77,7 +77,7 @@ PyTypeObject GetXF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp
index fc4edb9eb1a..7db4d5ed8b2 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp
@@ -77,7 +77,7 @@ PyTypeObject GetYF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp
index 3729f7bcb66..4e7808af2c2 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp
@@ -77,7 +77,7 @@ PyTypeObject GetZF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp
index 64f86653922..fa70590f775 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp
@@ -85,7 +85,7 @@ PyTypeObject LocalAverageDepthF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp
index 2b2dba80f04..21874ff6516 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp
@@ -82,7 +82,7 @@ PyTypeObject ZDiscontinuityF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 092f78c584c..7d68928461e 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
@@ -80,7 +80,7 @@ PyTypeObject GetCurvilinearAbscissaF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp
index 28be409b8fb..43eb89e2583 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp
@@ -76,7 +76,7 @@ PyTypeObject GetParameterF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 3f6667af843..8d89d33c230 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
@@ -85,7 +85,7 @@ PyTypeObject GetViewMapGradientNormF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 98cd37f5fea..4ddfc3f386b 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
@@ -83,7 +83,7 @@ PyTypeObject ReadCompleteViewMapPixelF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp
index 07bbcfed102..383970d110f 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp
@@ -84,7 +84,7 @@ PyTypeObject ReadMapPixelF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 4d2da133b5f..9fa3666df01 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
@@ -87,7 +87,7 @@ PyTypeObject ReadSteerableViewMapPixelF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 30e5ea4a1f8..1ed7311904e 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
@@ -85,7 +85,7 @@ PyTypeObject QuantitativeInvisibilityF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp
index a8461e006b0..be68df3e276 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp
@@ -78,7 +78,7 @@ PyTypeObject GetOccludersF0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp
index 0ce6e099ed3..b14a208624f 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp
@@ -278,7 +278,7 @@ PyTypeObject UnaryFunction1DDouble_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction1DDouble___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
index 83a502de548..6ef5b79c121 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
@@ -185,7 +185,7 @@ PyTypeObject UnaryFunction1DEdgeNature_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction1DEdgeNature___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp
index 7ba80c58256..461eff54d2d 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp
@@ -174,7 +174,7 @@ PyTypeObject UnaryFunction1DFloat_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction1DFloat___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
index ed8790fcd89..5a84bfbc776 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
@@ -185,7 +185,7 @@ PyTypeObject UnaryFunction1DUnsigned_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction1DUnsigned___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp
index 0f288faea4e..e175a3bf2a7 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp
@@ -189,7 +189,7 @@ PyTypeObject UnaryFunction1DVec2f_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction1DVec2f___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp
index fbdefd891be..822ac477420 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp
@@ -182,7 +182,7 @@ PyTypeObject UnaryFunction1DVec3f_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction1DVec3f___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
index 09b9e303fa0..13ce8e6fecf 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
@@ -210,7 +210,7 @@ PyTypeObject UnaryFunction1DVectorViewShape_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction1DVectorViewShape___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp
index 9ab3de8bf79..05d21fc44c9 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp
@@ -197,7 +197,7 @@ PyTypeObject UnaryFunction1DVoid_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
(ternaryfunc)UnaryFunction1DVoid___call__, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp
index 141758bfe48..c2d1370301d 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp
@@ -90,7 +90,7 @@ PyTypeObject CurveNatureF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp
index 7fa596d4bbe..6e8b8b3f54d 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp
@@ -84,7 +84,7 @@ PyTypeObject Normal2DF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp
index 69ab07a2829..3fa63188542 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp
@@ -84,7 +84,7 @@ PyTypeObject Orientation2DF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp
index 9866968e068..af431a9b905 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp
@@ -84,7 +84,7 @@ PyTypeObject Orientation3DF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp
index 3bd9bf8abce..b9028509c40 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp
@@ -85,7 +85,7 @@ PyTypeObject Curvature2DAngleF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp
index 12237f6a5e5..a0df70e0324 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp
@@ -98,7 +98,7 @@ PyTypeObject DensityF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 49f7c019222..d52714c77c6 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
@@ -102,7 +102,7 @@ PyTypeObject GetCompleteViewMapDensityF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 240e632b433..eeb55878f67 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
@@ -109,7 +109,7 @@ PyTypeObject GetDirectionalViewMapDensityF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp
index ce111f81c9d..062da8a3816 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp
@@ -84,7 +84,7 @@ PyTypeObject GetProjectedXF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp
index 31dc72f8d0d..5bda5c275c1 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp
@@ -84,7 +84,7 @@ PyTypeObject GetProjectedYF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp
index e16a0c01942..9b9d81168f4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp
@@ -84,7 +84,7 @@ PyTypeObject GetProjectedZF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 78d74bf3399..29251df924f 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
@@ -99,7 +99,7 @@ PyTypeObject GetSteerableViewMapDensityF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 a158969c00c..c3b2b23fe28 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
@@ -99,7 +99,7 @@ PyTypeObject GetViewMapGradientNormF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp
index 9dfb5aa8793..2260dc9ea85 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp
@@ -84,7 +84,7 @@ PyTypeObject GetXF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp
index 239079e8472..7c19c3101ef 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp
@@ -83,7 +83,7 @@ PyTypeObject GetYF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp
index 8f973adc3f0..43a6632c017 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp
@@ -84,7 +84,7 @@ PyTypeObject GetZF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp
index 53eaf9b9596..15a2e7b7643 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp
@@ -94,7 +94,7 @@ PyTypeObject LocalAverageDepthF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp
index 8d1d43bc4de..ed7a3212f59 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp
@@ -88,7 +88,7 @@ PyTypeObject ZDiscontinuityF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 da5140c4459..34c3fa14453 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
@@ -90,7 +90,7 @@ PyTypeObject QuantitativeInvisibilityF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp
index 57dc15d4a55..74e0b6ea228 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp
@@ -77,7 +77,7 @@ PyTypeObject GetOccludeeF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp
index ec8556eee96..e32bc4b8f57 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp
@@ -77,7 +77,7 @@ PyTypeObject GetOccludersF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp
index 95e7afe66fe..4a84d70c001 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp
@@ -77,7 +77,7 @@ PyTypeObject GetShapeF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp
index 906b23d03d2..70411d61cb7 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp
@@ -77,7 +77,7 @@ PyTypeObject ChainingTimeStampF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
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 487af7dca70..8e684870225 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
@@ -77,7 +77,7 @@ PyTypeObject IncrementChainingTimeStampF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp
index ba21c98b0b0..0e134407ede 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp
@@ -75,7 +75,7 @@ PyTypeObject TimeStampF1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp
index 300a9d66f07..67952df1f3e 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp
@@ -68,7 +68,7 @@ PyTypeObject FalseUP0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp
index 6ff6ad03c1e..51697862d71 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp
@@ -68,7 +68,7 @@ PyTypeObject TrueUP0D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp
index b42573c1fbe..ebe62bc2bfd 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp
@@ -69,7 +69,7 @@ PyTypeObject ContourUP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp
index bcea039087c..daf6841d66f 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp
@@ -85,7 +85,7 @@ PyTypeObject DensityLowerThanUP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
index 7ac09d4a644..e40d9703f25 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
@@ -80,7 +80,7 @@ PyTypeObject EqualToChainingTimeStampUP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp
index af98a277bad..6eddd7ea7b2 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp
@@ -79,7 +79,7 @@ PyTypeObject EqualToTimeStampUP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp
index 4c21d1ea54e..dc552b4d7bb 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp
@@ -73,7 +73,7 @@ PyTypeObject ExternalContourUP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp
index 87c1ea918d0..5ce0a269db4 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp
@@ -68,7 +68,7 @@ PyTypeObject FalseUP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
index 7fa00295887..728e6b938ab 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
@@ -84,7 +84,7 @@ PyTypeObject QuantitativeInvisibilityUP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp
index 2f097c5a6fe..e51d946a3b9 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp
@@ -80,7 +80,7 @@ PyTypeObject ShapeUP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp
index d589f621a4d..af1371e0afc 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp
@@ -68,7 +68,7 @@ PyTypeObject TrueUP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp
index 32882ac3c20..8dd5f93bb01 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp
@@ -81,7 +81,7 @@ PyTypeObject WithinImageBoundaryUP1D_Type = {
nullptr, /* tp_as_number */
nullptr, /* tp_as_sequence */
nullptr, /* tp_as_mapping */
- nullptr, /* tp_hash */
+ nullptr, /* tp_hash */
nullptr, /* tp_call */
nullptr, /* tp_str */
nullptr, /* tp_getattro */
diff --git a/source/blender/freestyle/intern/scene_graph/DrawingStyle.h b/source/blender/freestyle/intern/scene_graph/DrawingStyle.h
index ca1e2351868..1d96812f3f7 100644
--- a/source/blender/freestyle/intern/scene_graph/DrawingStyle.h
+++ b/source/blender/freestyle/intern/scene_graph/DrawingStyle.h
@@ -50,7 +50,7 @@ class DrawingStyle {
{
}
- /*! operators */
+ /** operators */
inline DrawingStyle &operator=(const DrawingStyle &ds);
inline void setStyle(const STYLE iStyle)
diff --git a/source/blender/freestyle/intern/scene_graph/FrsMaterial.h b/source/blender/freestyle/intern/scene_graph/FrsMaterial.h
index 18d3c8839dd..ecdba75b864 100644
--- a/source/blender/freestyle/intern/scene_graph/FrsMaterial.h
+++ b/source/blender/freestyle/intern/scene_graph/FrsMaterial.h
@@ -29,13 +29,13 @@
namespace Freestyle {
-/*! Class defining a material */
+/** Class defining a material */
class FrsMaterial {
public:
- /*! Default constructor */
+ /** Default constructor */
inline FrsMaterial();
- /*! Builds a Material from its line, diffuse, ambient, specular, emissive
+ /** Builds a Material from its line, diffuse, ambient, specular, emissive
* colors, a shininess coefficient and line color priority.
* \param iLine:
* A 4 element float-array containing the line color.
@@ -60,177 +60,177 @@ class FrsMaterial {
const float iShininess,
const int iPriority);
- /*! Copy constructor */
+ /** Copy constructor */
inline FrsMaterial(const FrsMaterial &m);
- /*! Destructor */
+ /** Destructor */
virtual ~FrsMaterial()
{
}
- /*! Returns the line color as a 4 float array */
+ /** Returns the line color as a 4 float array */
inline const float *line() const
{
return Line;
}
- /*! Returns the red component of the line color */
+ /** Returns the red component of the line color */
inline const float lineR() const
{
return Line[0];
}
- /*! Returns the green component of the line color */
+ /** Returns the green component of the line color */
inline const float lineG() const
{
return Line[1];
}
- /*! Returns the blue component of the line color */
+ /** Returns the blue component of the line color */
inline const float lineB() const
{
return Line[2];
}
- /*! Returns the alpha component of the line color */
+ /** Returns the alpha component of the line color */
inline const float lineA() const
{
return Line[3];
}
- /*! Returns the diffuse color as a 4 float array */
+ /** Returns the diffuse color as a 4 float array */
inline const float *diffuse() const
{
return Diffuse;
}
- /*! Returns the red component of the diffuse color */
+ /** Returns the red component of the diffuse color */
inline const float diffuseR() const
{
return Diffuse[0];
}
- /*! Returns the green component of the diffuse color */
+ /** Returns the green component of the diffuse color */
inline const float diffuseG() const
{
return Diffuse[1];
}
- /*! Returns the blue component of the diffuse color */
+ /** Returns the blue component of the diffuse color */
inline const float diffuseB() const
{
return Diffuse[2];
}
- /*! Returns the alpha component of the diffuse color */
+ /** Returns the alpha component of the diffuse color */
inline const float diffuseA() const
{
return Diffuse[3];
}
- /*! Returns the specular color as a 4 float array */
+ /** Returns the specular color as a 4 float array */
inline const float *specular() const
{
return Specular;
}
- /*! Returns the red component of the specular color */
+ /** Returns the red component of the specular color */
inline const float specularR() const
{
return Specular[0];
}
- /*! Returns the green component of the specular color */
+ /** Returns the green component of the specular color */
inline const float specularG() const
{
return Specular[1];
}
- /*! Returns the blue component of the specular color */
+ /** Returns the blue component of the specular color */
inline const float specularB() const
{
return Specular[2];
}
- /*! Returns the alpha component of the specular color */
+ /** Returns the alpha component of the specular color */
inline const float specularA() const
{
return Specular[3];
}
- /*! Returns the ambient color as a 4 float array */
+ /** Returns the ambient color as a 4 float array */
inline const float *ambient() const
{
return Ambient;
}
- /*! Returns the red component of the ambient color */
+ /** Returns the red component of the ambient color */
inline const float ambientR() const
{
return Ambient[0];
}
- /*! Returns the green component of the ambient color */
+ /** Returns the green component of the ambient color */
inline const float ambientG() const
{
return Ambient[1];
}
- /*! Returns the blue component of the ambient color */
+ /** Returns the blue component of the ambient color */
inline const float ambientB() const
{
return Ambient[2];
}
- /*! Returns the alpha component of the ambient color */
+ /** Returns the alpha component of the ambient color */
inline const float ambientA() const
{
return Ambient[3];
}
- /*! Returns the emissive color as a 4 float array */
+ /** Returns the emissive color as a 4 float array */
inline const float *emission() const
{
return Emission;
}
- /*! Returns the red component of the emissive color */
+ /** Returns the red component of the emissive color */
inline const float emissionR() const
{
return Emission[0];
}
- /*! Returns the green component of the emissive color */
+ /** Returns the green component of the emissive color */
inline const float emissionG() const
{
return Emission[1];
}
- /*! Returns the blue component of the emissive color */
+ /** Returns the blue component of the emissive color */
inline const float emissionB() const
{
return Emission[2];
}
- /*! Returns the alpha component of the emissive color */
+ /** Returns the alpha component of the emissive color */
inline const float emissionA() const
{
return Emission[3];
}
- /*! Returns the shininess coefficient */
+ /** Returns the shininess coefficient */
inline const float shininess() const
{
return Shininess;
}
- /*! Returns the line color priority */
+ /** Returns the line color priority */
inline const int priority() const
{
return Priority;
}
- /*! Sets the line color.
+ /** Sets the line color.
* \param r:
* Red component
* \param g:
@@ -242,7 +242,7 @@ class FrsMaterial {
*/
inline void setLine(const float r, const float g, const float b, const float a);
- /*! Sets the diffuse color.
+ /** Sets the diffuse color.
* \param r:
* Red component
* \param g:
@@ -254,7 +254,7 @@ class FrsMaterial {
*/
inline void setDiffuse(const float r, const float g, const float b, const float a);
- /*! Sets the specular color.
+ /** Sets the specular color.
* \param r:
* Red component
* \param g:
@@ -266,7 +266,7 @@ class FrsMaterial {
*/
inline void setSpecular(const float r, const float g, const float b, const float a);
- /*! Sets the ambient color.
+ /** Sets the ambient color.
* \param r:
* Red component
* \param g:
@@ -278,7 +278,7 @@ class FrsMaterial {
*/
inline void setAmbient(const float r, const float g, const float b, const float a);
- /*! Sets the emissive color.
+ /** Sets the emissive color.
* \param r:
* Red component
* \param g:
@@ -290,13 +290,13 @@ class FrsMaterial {
*/
inline void setEmission(const float r, const float g, const float b, const float a);
- /*! Sets the shininess.
+ /** Sets the shininess.
* \param s:
* Shininess
*/
inline void setShininess(const float s);
- /*! Sets the line color priority.
+ /** Sets the line color priority.
* \param priority:
* Priority
*/
@@ -308,7 +308,7 @@ class FrsMaterial {
inline bool operator==(const FrsMaterial &m) const;
private:
- /*! Material properties */
+ /** Material properties */
float Line[4];
float Diffuse[4];
float Specular[4];
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
index 9d1fc009e37..17f922de467 100644
--- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
@@ -33,14 +33,14 @@ namespace Freestyle {
class IndexedFaceSet : public Rep {
public:
- /*! Triangles description style:*/
+ /** Triangles description style: */
enum TRIANGLES_STYLE {
TRIANGLE_STRIP,
TRIANGLE_FAN,
TRIANGLES,
};
- /*! User-specified face and edge marks for feature edge detection */
+ /** User-specified face and edge marks for feature edge detection */
/* XXX Why in hell not use an enum here too? */
typedef unsigned char FaceEdgeMark;
static const FaceEdgeMark FACE_MARK = 1 << 0;
@@ -48,10 +48,10 @@ class IndexedFaceSet : public Rep {
static const FaceEdgeMark EDGE_MARK_V2V3 = 1 << 2;
static const FaceEdgeMark EDGE_MARK_V3V1 = 1 << 3;
- /*! Builds an empty indexed face set */
+ /** Builds an empty indexed face set. */
IndexedFaceSet();
- /*! Builds an indexed face set
+ /** Builds an indexed face set
* iVertices
* The array of object vertices 3D coordinates (for all faces).
* If iCopy != 0, the array is copied; you must deallocate iVertices. Else you must not.
@@ -126,7 +126,7 @@ class IndexedFaceSet : public Rep {
unsigned iTISize,
unsigned iCopy = 1);
- /*! Builds an indexed face set from an other indexed face set */
+ /** Builds an indexed face set from an other indexed face set */
IndexedFaceSet(const IndexedFaceSet &iBrother);
void swap(IndexedFaceSet &ioOther)
@@ -166,18 +166,18 @@ class IndexedFaceSet : public Rep {
return *this;
}
- /*! Destructor
+ /** Destructor
* deallocates all the resources
*/
virtual ~IndexedFaceSet();
- /*! Accept the corresponding visitor */
+ /** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v);
- /*! Compute the Bounding Box */
+ /** Compute the Bounding Box */
virtual void ComputeBBox();
- /*! Accessors */
+ /** Accessors */
virtual const float *vertices() const
{
return _Vertices;
diff --git a/source/blender/freestyle/intern/scene_graph/LineRep.h b/source/blender/freestyle/intern/scene_graph/LineRep.h
index 43fd736570f..02725102001 100644
--- a/source/blender/freestyle/intern/scene_graph/LineRep.h
+++ b/source/blender/freestyle/intern/scene_graph/LineRep.h
@@ -32,10 +32,10 @@ using namespace std;
namespace Freestyle {
-/*! Base class for all lines objects */
+/** Base class for all lines objects */
class LineRep : public Rep {
public:
- /*! Line description style */
+ /** Line description style */
enum LINES_STYLE {
LINES,
LINE_STRIP,
@@ -47,7 +47,7 @@ class LineRep : public Rep {
_width = 0.0f;
}
- /*! Builds a single line from 2 vertices
+ /** Builds a single line from 2 vertices
* v1
* first vertex
* v2
@@ -61,7 +61,7 @@ class LineRep : public Rep {
_width = 0.0f;
}
- /*! Builds a line rep from a vertex chain */
+ /** Builds a line rep from a vertex chain */
inline LineRep(const vector<Vec3r> &vertices) : Rep()
{
_vertices = vertices;
@@ -69,7 +69,7 @@ class LineRep : public Rep {
_width = 0.0f;
}
- /*! Builds a line rep from a vertex chain */
+ /** Builds a line rep from a vertex chain */
inline LineRep(const list<Vec3r> &vertices) : Rep()
{
for (list<Vec3r>::const_iterator v = vertices.begin(), end = vertices.end(); v != end; ++v) {
@@ -84,7 +84,7 @@ class LineRep : public Rep {
_vertices.clear();
}
- /*! accessors */
+ /** accessors */
inline const LINES_STYLE style() const
{
return _Style;
@@ -100,7 +100,7 @@ class LineRep : public Rep {
return _width;
}
- /*! modifiers */
+ /** modifiers */
inline void setStyle(const LINES_STYLE iStyle)
{
_Style = iStyle;
@@ -127,14 +127,14 @@ class LineRep : public Rep {
_width = iWidth;
}
- /*! Accept the corresponding visitor */
+ /** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v)
{
Rep::accept(v);
v.visitLineRep(*this);
}
- /*! Computes the line bounding box.*/
+ /** Computes the line bounding box. */
virtual void ComputeBBox();
private:
diff --git a/source/blender/freestyle/intern/scene_graph/Node.h b/source/blender/freestyle/intern/scene_graph/Node.h
index 07bf186ea39..2907580492d 100644
--- a/source/blender/freestyle/intern/scene_graph/Node.h
+++ b/source/blender/freestyle/intern/scene_graph/Node.h
@@ -52,7 +52,7 @@ class Node : public BaseObject {
{
}
- /*! Accept the corresponding visitor
+ /** Accept the corresponding visitor
* Each inherited node must overload this method
*/
virtual void accept(SceneVisitor &v)
@@ -60,8 +60,8 @@ class Node : public BaseObject {
v.visitNode(*this);
}
- /*! bounding box management */
- /*! Returns the node bounding box
+ /** bounding box management */
+ /** Returns the node bounding box
* If no bounding box exists, an empty bbox is returned
*/
virtual const BBox<Vec3r> &bbox() const
@@ -69,13 +69,13 @@ class Node : public BaseObject {
return _BBox;
}
- /*! Sets the Node bounding box */
+ /** Sets the Node bounding box */
virtual void setBBox(const BBox<Vec3r> &iBox)
{
_BBox = iBox;
}
- /*! Makes the union of _BBox and iBox */
+ /** Makes the union of _BBox and iBox */
virtual void AddBBox(const BBox<Vec3r> &iBox)
{
if (iBox.empty()) {
@@ -90,13 +90,13 @@ class Node : public BaseObject {
}
}
- /*! Updates the BBox */
+ /** Updates the BBox */
virtual const BBox<Vec3r> &UpdateBBox()
{
return _BBox;
}
- /*! Clears the bounding box */
+ /** Clears the bounding box */
virtual void clearBBox()
{
_BBox.clear();
diff --git a/source/blender/freestyle/intern/scene_graph/NodeCamera.h b/source/blender/freestyle/intern/scene_graph/NodeCamera.h
index 9e3f9046e39..0135a30f97c 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeCamera.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeCamera.h
@@ -43,7 +43,7 @@ class NodeCamera : public Node {
GENERIC,
} CameraType;
- /*! Default matrices: Identity for both projection and modelview. */
+ /** Default matrices: Identity for both projection and modelview. */
NodeCamera(CameraType camera_type = GENERIC);
#if 0 /* UNUSED, gives warning in gcc */
NodeCamera(const NodeCamera &iBrother);
@@ -53,13 +53,13 @@ class NodeCamera : public Node {
{
}
- /*! Accept the corresponding visitor */
+ /** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v);
- /*! Matrix is copied */
+ /** Matrix is copied */
void setModelViewMatrix(double modelview_matrix[16]);
- /*! Matrix is copied */
+ /** Matrix is copied */
void setProjectionMatrix(double projection_matrix[16]);
double *modelViewMatrix()
@@ -89,7 +89,7 @@ class NodeOrthographicCamera : public NodeCamera {
public:
NodeOrthographicCamera();
- /*! Builds a parallel projection matrix a la glOrtho.
+ /** Builds a parallel projection matrix a la glOrtho.
* A 0 0 tx
* 0 B 0 ty
* 0 0 C tz
@@ -155,7 +155,7 @@ class NodePerspectiveCamera : public NodeCamera {
public:
NodePerspectiveCamera();
- /*! Builds a perspective projection matrix a la gluPerspective.
+ /** Builds a perspective projection matrix a la gluPerspective.
* Given f defined as follows:
* fovy
* f = cotangent(____)
@@ -177,7 +177,7 @@ class NodePerspectiveCamera : public NodeCamera {
*/
NodePerspectiveCamera(double fovy, double aspect, double zNear, double zFar);
- /*! Builds a perspective projection matrix a la glFrustum.
+ /** Builds a perspective projection matrix a la glFrustum.
* ( 2*zNear )
* | __________ 0 A 0 |
* | right-left |
diff --git a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
index 8bbdaf30bad..38b84c7be3a 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
@@ -48,34 +48,34 @@ class NodeDrawingStyle : public NodeGroup {
_DrawingStyle = iDrawingStyle;
}
- /*! Sets the style. Must be one of FILLED, LINES, POINTS, INVISIBLE. */
+ /** Sets the style. Must be one of FILLED, LINES, POINTS, INVISIBLE. */
inline void setStyle(const DrawingStyle::STYLE iStyle)
{
_DrawingStyle.setStyle(iStyle);
}
- /*! Sets the line width in the LINES style case */
+ /** Sets the line width in the LINES style case */
inline void setLineWidth(const float iLineWidth)
{
_DrawingStyle.setLineWidth(iLineWidth);
}
- /*! Sets the Point size in the POINTS style case */
+ /** Sets the Point size in the POINTS style case */
inline void setPointSize(const float iPointSize)
{
_DrawingStyle.setPointSize(iPointSize);
}
- /*! Enables or disables the lighting. true = enable */
+ /** Enables or disables the lighting. true = enable */
inline void setLightingEnabled(const bool iEnableLighting)
{
_DrawingStyle.setLightingEnabled(iEnableLighting);
}
- /*! Accept the corresponding visitor */
+ /** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v);
- /*! accessors */
+ /** accessors */
inline DrawingStyle::STYLE style() const
{
return _DrawingStyle.style();
diff --git a/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp b/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
index 69c33ea02a1..12082ba69a8 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
@@ -37,7 +37,7 @@ void NodeGroup::AddChild(Node *iChild)
int NodeGroup::destroy()
{
- /*! Node::destroy makes a release on the object and then returns the reference counter.
+ /** 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();
diff --git a/source/blender/freestyle/intern/scene_graph/NodeGroup.h b/source/blender/freestyle/intern/scene_graph/NodeGroup.h
index 0558e22bed1..f33687d43a3 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeGroup.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeGroup.h
@@ -42,33 +42,33 @@ class NodeGroup : public Node {
{
}
- /*! Adds a child. Makes a addRef on the iChild reference counter */
+ /** Adds a child. Makes a addRef on the iChild reference counter */
virtual void AddChild(Node *iChild);
- /*! destroys all the underlying nodes
+ /** destroys all the underlying nodes
* Returns the reference counter after having done a release()
*/
virtual int destroy();
- /*! Detaches all the children */
+ /** Detaches all the children */
virtual void DetachChildren();
- /*! Detached the specified child */
+ /** Detached the specified child */
virtual void DetachChild(Node *iChild);
- /*! Retrieve children */
+ /** Retrieve children */
virtual void RetrieveChildren(vector<Node *> &oNodes);
- /*! Renders every children */
+ /** Renders every children */
// virtual void Render(Renderer *iRenderer);
- /*! Accept the corresponding visitor */
+ /** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v);
- /*! Updates the BBox */
+ /** Updates the BBox */
virtual const BBox<Vec3r> &UpdateBBox();
- /*! Returns the number of children */
+ /** Returns the number of children */
virtual int numberOfChildren()
{
return _Children.size();
diff --git a/source/blender/freestyle/intern/scene_graph/NodeLight.h b/source/blender/freestyle/intern/scene_graph/NodeLight.h
index bf8389441b6..1d92a96100c 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeLight.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeLight.h
@@ -40,10 +40,10 @@ class NodeLight : public Node {
{
}
- /*! Accept the corresponding visitor */
+ /** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v);
- /*! Accessors for the light properties */
+ /** Accessors for the light properties */
inline const float *ambient() const
{
return Ambient;
@@ -78,24 +78,24 @@ class NodeLight : public Node {
// Data members
// ============
- /*! on=true, the light is on */
+ /** on=true, the light is on */
bool on;
- /*! The color definition */
+ /** The color definition */
float Ambient[4];
float Diffuse[4];
float Specular[4];
- /*! Light position. if w = 0, the light is placed at infinite. */
+ /** Light position. if w = 0, the light is placed at infinite. */
float Position[4];
- /*! used to manage the number of lights */
- /*! numberOfLights
+ /** used to manage the number of lights */
+ /** numberOfLights
* the number of lights in the scene.
* Initially, 0.
*/
static int numberOfLights;
- /*! The current lignt number */
+ /** The current lignt number */
int _number;
};
diff --git a/source/blender/freestyle/intern/scene_graph/NodeShape.h b/source/blender/freestyle/intern/scene_graph/NodeShape.h
index 5f7a24b85d5..59b759dbae0 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeShape.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeShape.h
@@ -46,7 +46,7 @@ class NodeShape : public Node {
virtual ~NodeShape();
- /*! Adds a Rep to the _Shapes list
+ /** Adds a Rep to the _Shapes list
* The delete of the rep is done when it is not used any more by the Scene Manager.
* So, it must not be deleted by the caller
*/
@@ -62,17 +62,17 @@ class NodeShape : public Node {
AddBBox(iRep->bbox());
}
- /*! Accept the corresponding visitor */
+ /** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v);
- /*! Sets the shape material */
+ /** Sets the shape material */
inline void setFrsMaterial(const FrsMaterial &iMaterial)
{
_FrsMaterial = iMaterial;
}
- /*! accessors */
- /*! returns the shape's material */
+ /** accessors */
+ /** returns the shape's material */
inline FrsMaterial &frs_material()
{
return _FrsMaterial;
@@ -84,10 +84,10 @@ class NodeShape : public Node {
}
private:
- /*! list of shapes */
+ /** list of shapes */
vector<Rep *> _Shapes;
- /*! Shape Material */
+ /** Shape Material */
FrsMaterial _FrsMaterial;
};
diff --git a/source/blender/freestyle/intern/scene_graph/NodeTransform.h b/source/blender/freestyle/intern/scene_graph/NodeTransform.h
index 9d55046a515..3bb14ef842b 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeTransform.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeTransform.h
@@ -44,10 +44,10 @@ class NodeTransform : public NodeGroup {
{
}
- /*! multiplies the current matrix by the x, y, z translation matrix. */
+ /** multiplies the current matrix by the x, y, z translation matrix. */
void Translate(real x, real y, real z);
- /*! multiplies the current matrix by a rotation matrix
+ /** multiplies the current matrix by a rotation matrix
* iAngle
* The rotation angle
* x, y, z
@@ -55,32 +55,32 @@ class NodeTransform : public NodeGroup {
*/
void Rotate(real iAngle, real x, real y, real z);
- /*! multiplies the current matrix by a scaling matrix.
+ /** multiplies the current matrix by a scaling matrix.
* x, y, z
* The scaling coefficients with respect to the x,y,z axis
*/
void Scale(real x, real y, real z);
- /*! Multiplies the current matrix by iMatrix */
+ /** Multiplies the current matrix by iMatrix */
void MultiplyMatrix(const Matrix44r &iMatrix);
- /*! Sets the current matrix to iMatrix */
+ /** Sets the current matrix to iMatrix */
void setMatrix(const Matrix44r &iMatrix);
- /*! Accept the corresponding visitor */
+ /** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v);
- /*! Overloads the Node::AddBBox in order to take care about the transformation */
+ /** Overloads the Node::AddBBox in order to take care about the transformation */
virtual void AddBBox(const BBox<Vec3r> &iBBox);
- /*! Checks whether a matrix contains a scale factor or not.
+ /** Checks whether a matrix contains a scale factor or not.
* Returns true if yes.
* M
* The matrix to check
*/
bool isScaled(const Matrix44r &M);
- /*! accessors */
+ /** accessors */
inline const Matrix44r &matrix() const
{
return _Matrix;
diff --git a/source/blender/freestyle/intern/scene_graph/NodeViewLayer.h b/source/blender/freestyle/intern/scene_graph/NodeViewLayer.h
index d52155eb216..75f35eea411 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeViewLayer.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeViewLayer.h
@@ -49,7 +49,7 @@ class NodeViewLayer : public Node {
return _ViewLayer;
}
- /*! Accept the corresponding visitor */
+ /** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v);
protected:
diff --git a/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h
index c33fd529c69..6aaba1d30d2 100644
--- a/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h
+++ b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h
@@ -32,7 +32,7 @@ class OrientedLineRep : public LineRep {
OrientedLineRep() : LineRep()
{
}
- /*! Builds a single line from 2 vertices
+ /** Builds a single line from 2 vertices
* v1
* first vertex
* v2
@@ -42,12 +42,12 @@ class OrientedLineRep : public LineRep {
{
}
- /*! Builds a line rep from a vertex chain */
+ /** Builds a line rep from a vertex chain */
inline OrientedLineRep(const vector<Vec3r> &vertices) : LineRep(vertices)
{
}
- /*! Builds a line rep from a vertex chain */
+ /** Builds a line rep from a vertex chain */
inline OrientedLineRep(const list<Vec3r> &vertices) : LineRep(vertices)
{
}
@@ -56,7 +56,7 @@ class OrientedLineRep : public LineRep {
{
}
- /*! Accept the corresponding visitor */
+ /** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v);
};
diff --git a/source/blender/freestyle/intern/scene_graph/Rep.h b/source/blender/freestyle/intern/scene_graph/Rep.h
index dae5272beed..1401e69886a 100644
--- a/source/blender/freestyle/intern/scene_graph/Rep.h
+++ b/source/blender/freestyle/intern/scene_graph/Rep.h
@@ -102,7 +102,7 @@ class Rep : public BaseObject {
}
}
- /*! Accept the corresponding visitor
+ /** Accept the corresponding visitor
* Must be overload by inherited classes
*/
virtual void accept(SceneVisitor &v)
@@ -113,13 +113,13 @@ class Rep : public BaseObject {
v.visitRep(*this);
}
- /*! Computes the rep bounding box.
+ /** 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
*/
virtual void ComputeBBox() = 0;
- /*! Returns the rep bounding box */
+ /** Returns the rep bounding box */
virtual const BBox<Vec3f> &bbox() const
{
return _BBox;
@@ -145,7 +145,7 @@ class Rep : public BaseObject {
return _FrsMaterial;
}
- /*! Sets the Rep bounding box */
+ /** Sets the Rep bounding box */
virtual void setBBox(const BBox<Vec3f> &iBox)
{
_BBox = iBox;
diff --git a/source/blender/freestyle/intern/scene_graph/TriangleRep.h b/source/blender/freestyle/intern/scene_graph/TriangleRep.h
index 4461b38d68b..e3f221567b0 100644
--- a/source/blender/freestyle/intern/scene_graph/TriangleRep.h
+++ b/source/blender/freestyle/intern/scene_graph/TriangleRep.h
@@ -26,10 +26,10 @@
namespace Freestyle {
-/*! Base class for all lines objects */
+/** Base class for all lines objects */
class TriangleRep : public Rep {
public:
- /*! Line description style */
+ /** Line description style */
enum TRIANGLE_STYLE {
FILL,
LINES,
@@ -46,7 +46,7 @@ class TriangleRep : public Rep {
_Style = FILL;
}
- /*! Builds a triangle from 3 vertices
+ /** Builds a triangle from 3 vertices
* v0
* first vertex
* v1
@@ -83,7 +83,7 @@ class TriangleRep : public Rep {
{
}
- /*! accessors */
+ /** accessors */
inline const TRIANGLE_STYLE style() const
{
return _Style;
@@ -99,7 +99,7 @@ class TriangleRep : public Rep {
return _colors[index];
}
- /*! modifiers */
+ /** modifiers */
inline void setStyle(const TRIANGLE_STYLE iStyle)
{
_Style = iStyle;
@@ -129,14 +129,14 @@ class TriangleRep : public Rep {
_colors[2] = c2;
}
- /*! Accept the corresponding visitor */
+ /** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v)
{
Rep::accept(v);
v.visitTriangleRep(*this);
}
- /*! Computes the triangle bounding box.*/
+ /** Computes the triangle bounding box. */
virtual void ComputeBBox();
};
diff --git a/source/blender/freestyle/intern/scene_graph/VertexRep.h b/source/blender/freestyle/intern/scene_graph/VertexRep.h
index 278cfa694f7..edcb3405e4e 100644
--- a/source/blender/freestyle/intern/scene_graph/VertexRep.h
+++ b/source/blender/freestyle/intern/scene_graph/VertexRep.h
@@ -47,17 +47,17 @@ class VertexRep : public Rep {
{
}
- /*! Accept the corresponding visitor */
+ /** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v)
{
Rep::accept(v);
v.visitVertexRep(*this);
}
- /*! Computes the rep bounding box. */
+ /** Computes the rep bounding box. */
virtual void ComputeBBox();
- /*! accessors */
+ /** accessors */
inline const int vid() const
{
return _vid;
@@ -88,7 +88,7 @@ class VertexRep : public Rep {
return _PointSize;
}
- /*! modifiers */
+ /** modifiers */
inline void setVid(int id)
{
_vid = id;
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
index 17e419bed54..212187e598c 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
@@ -36,13 +36,13 @@ namespace Freestyle {
namespace Functions0D {
// DensityF0D
-/*! Returns the density of the (result) image evaluated at an Interface0D.
+/** 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.
*/
class DensityF0D : public UnaryFunction0D<double> {
public:
- /*! Builds the functor from the gaussian sigma value.
+ /** 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)
@@ -52,13 +52,13 @@ class DensityF0D : public UnaryFunction0D<double> {
_filter.setSigma((float)sigma);
}
- /*! Returns the string "DensityF0D" */
+ /** Returns the string "DensityF0D" */
string getName() const
{
return "DensityF0D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface0DIterator &iter);
private:
@@ -66,7 +66,7 @@ class DensityF0D : public UnaryFunction0D<double> {
};
// LocalAverageDepthF0D
-/*! Returns the average depth around a point.
+/** Returns the average depth around a point.
* The result is obtained by querying the depth buffer on a window around that point.
*/
class LocalAverageDepthF0D : public UnaryFunction0D<double> {
@@ -74,31 +74,31 @@ class LocalAverageDepthF0D : public UnaryFunction0D<double> {
GaussianFilter _filter;
public:
- /*! Builds the functor from the size of the mask that will be used. */
+ /** Builds the functor from the size of the mask that will be used. */
LocalAverageDepthF0D(real maskSize = 5.0f) : UnaryFunction0D<double>()
{
_filter.setSigma((float)maskSize / 2.0f);
}
- /*! Returns the string "LocalAverageDepthF0D" */
+ /** Returns the string "LocalAverageDepthF0D" */
string getName() const
{
return "LocalAverageDepthF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// ReadMapPixel
-/*! Reads a pixel in a map. */
+/** Reads a pixel in a map. */
class ReadMapPixelF0D : public UnaryFunction0D<float> {
private:
const char *_mapName;
int _level;
public:
- /*! Builds the functor from name of the
+ /** Builds the functor from name of the
* Map that must be read.
* \param iMapName:
* The name of the map.
@@ -111,25 +111,25 @@ class ReadMapPixelF0D : public UnaryFunction0D<float> {
_level = level;
}
- /*! Returns the string "ReadMapPixelF0D" */
+ /** Returns the string "ReadMapPixelF0D" */
string getName() const
{
return "ReadMapPixelF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// ReadSteerableViewMapPixel
-/*! Reads a pixel in one of the level of one of the steerable viewmaps. */
+/** Reads a pixel in one of the level of one of the steerable viewmaps. */
class ReadSteerableViewMapPixelF0D : public UnaryFunction0D<float> {
private:
unsigned _orientation;
int _level;
public:
- /*! Builds the functor
+ /** Builds the functor
* \param nOrientation:
* The integer belonging to [0,4] indicating the orientation (E,NE,N,NW) we are interested in.
* \param level:
@@ -141,24 +141,24 @@ class ReadSteerableViewMapPixelF0D : public UnaryFunction0D<float> {
_level = level;
}
- /*! Returns the string "ReadSteerableViewMapPixelF0D" */
+ /** Returns the string "ReadSteerableViewMapPixelF0D" */
string getName() const
{
return "ReadSteerableViewMapPixelF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// ReadCompleteViewMapPixel
-/*! Reads a pixel in one of the level of the complete viewmap. */
+/** Reads a pixel in one of the level of the complete viewmap. */
class ReadCompleteViewMapPixelF0D : public UnaryFunction0D<float> {
private:
int _level;
public:
- /*! Builds the functor
+ /** Builds the functor
* \param level:
* The level of the pyramid from which the pixel must be read.
*/
@@ -167,25 +167,25 @@ class ReadCompleteViewMapPixelF0D : public UnaryFunction0D<float> {
_level = level;
}
- /*! Returns the string "ReadCompleteViewMapPixelF0D" */
+ /** Returns the string "ReadCompleteViewMapPixelF0D" */
string getName() const
{
return "ReadCompleteViewMapPixelF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// GetViewMapGradientNormF0D
-/*! Returns the norm of the gradient of the global viewmap density image. */
+/** Returns the norm of the gradient of the global viewmap density image. */
class GetViewMapGradientNormF0D : public UnaryFunction0D<float> {
private:
int _level;
float _step;
public:
- /*! Builds the functor
+ /** Builds the functor
* \param level:
* The level of the pyramid from which the pixel must be read.
*/
@@ -195,13 +195,13 @@ class GetViewMapGradientNormF0D : public UnaryFunction0D<float> {
_step = (float)pow(2.0, _level);
}
- /*! Returns the string "GetOccludeeF0D" */
+ /** Returns the string "GetOccludeeF0D" */
string getName() const
{
return "GetViewMapGradientNormF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp
index 7a516470e6b..84f517e7535 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp
@@ -112,7 +112,7 @@ int GetDirectionalViewMapDensityF1D::operator()(Interface1D &inter)
int GetCompleteViewMapDensityF1D::operator()(Interface1D &inter)
{
// soc unsigned size;
- /* Id id = inter.getId(); */ /* UNUSED */
+ // 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 349db393e17..486e0fffcdd 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
@@ -35,7 +35,7 @@ namespace Freestyle {
namespace Functions1D {
// DensityF1D
-/*! Returns the density evaluated for an Interface1D.
+/** 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.
@@ -45,7 +45,7 @@ class DensityF1D : public UnaryFunction1D<double> {
float _sampling;
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param sigma:
* Thesigma used in DensityF0D and determining the window size used in each density query.
* \param iType:
@@ -61,18 +61,18 @@ class DensityF1D : public UnaryFunction1D<double> {
_sampling = sampling;
}
- /*! Destructor */
+ /** Destructor */
virtual ~DensityF1D()
{
}
- /*! Returns the string "DensityF1D"*/
+ /** Returns the string "DensityF1D". */
string getName() const
{
return "DensityF1D";
}
- /*! the () operator.*/
+ /** the () operator. */
int operator()(Interface1D &inter)
{
result = integrate(
@@ -85,14 +85,14 @@ class DensityF1D : public UnaryFunction1D<double> {
};
// LocalAverageDepthF1D
-/*! Returns the average depth evaluated for an Interface1D.
+/** 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.
*/
class LocalAverageDepthF1D : public UnaryFunction1D<double> {
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param sigma:
* The sigma used in DensityF0D and determining the window size used in each density query.
* \param iType:
@@ -103,13 +103,13 @@ class LocalAverageDepthF1D : public UnaryFunction1D<double> {
{
}
- /*! Returns the string "LocalAverageDepthF1D" */
+ /** Returns the string "LocalAverageDepthF1D" */
string getName() const
{
return "LocalAverageDepthF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter)
{
result = integrate(_fun, inter.verticesBegin(), inter.verticesEnd(), _integration);
@@ -121,14 +121,14 @@ class LocalAverageDepthF1D : public UnaryFunction1D<double> {
};
// GetCompleteViewMapDensity
-/*! Returns the density evaluated for an Interface1D in the complete viewmap image.
+/** 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.
*/
class GetCompleteViewMapDensityF1D : public UnaryFunction1D<double> {
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param level:
* The level of the pyramid from which
* the pixel must be read.
@@ -147,13 +147,13 @@ class GetCompleteViewMapDensityF1D : public UnaryFunction1D<double> {
_sampling = sampling;
}
- /*! Returns the string "GetCompleteViewMapDensityF1D" */
+ /** Returns the string "GetCompleteViewMapDensityF1D" */
string getName() const
{
return "GetCompleteViewMapDensityF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
private:
@@ -162,7 +162,7 @@ class GetCompleteViewMapDensityF1D : public UnaryFunction1D<double> {
};
// GetDirectionalViewMapDensity
-/*! Returns the density evaluated for an Interface1D in of the steerable viewmaps image.
+/** 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)
@@ -170,7 +170,7 @@ class GetCompleteViewMapDensityF1D : public UnaryFunction1D<double> {
*/
class GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double> {
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iOrientation:
* The number of the directional map we must work with.
* \param level:
@@ -191,13 +191,13 @@ class GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double> {
_sampling = sampling;
}
- /*! Returns the string "GetDirectionalViewMapDensityF1D" */
+ /** Returns the string "GetDirectionalViewMapDensityF1D" */
string getName() const
{
return "GetDirectionalViewMapDensityF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
private:
@@ -206,7 +206,7 @@ class GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double> {
};
// GetSteerableViewMapDensityF1D
-/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is
+/** 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 orientation.
*/
class GetSteerableViewMapDensityF1D : public UnaryFunction1D<double> {
@@ -215,7 +215,7 @@ class GetSteerableViewMapDensityF1D : public UnaryFunction1D<double> {
float _sampling;
public:
- /*! Builds the functor from the level of the pyramid from which the pixel must be read.
+ /** Builds the functor from the level of the pyramid from which the pixel must be read.
* \param level:
* The level of the pyramid from which the pixel must be read.
* \param iType:
@@ -232,23 +232,23 @@ class GetSteerableViewMapDensityF1D : public UnaryFunction1D<double> {
_sampling = sampling;
}
- /*! Destructor */
+ /** Destructor */
virtual ~GetSteerableViewMapDensityF1D()
{
}
- /*! Returns the string "GetSteerableViewMapDensityF1D" */
+ /** Returns the string "GetSteerableViewMapDensityF1D" */
string getName() const
{
return "GetSteerableViewMapDensityF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// GetViewMapGradientNormF1D
-/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is
+/** 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 orientation.
*/
class GetViewMapGradientNormF1D : public UnaryFunction1D<double> {
@@ -258,7 +258,7 @@ class GetViewMapGradientNormF1D : public UnaryFunction1D<double> {
Functions0D::GetViewMapGradientNormF0D _func;
public:
- /*! Builds the functor from the level of the pyramid from which the pixel must be read.
+ /** Builds the functor from the level of the pyramid from which the pixel must be read.
* \param level:
* The level of the pyramid from which the pixel must be read.
* \param iType:
@@ -275,13 +275,13 @@ class GetViewMapGradientNormF1D : public UnaryFunction1D<double> {
_sampling = sampling;
}
- /*! Returns the string "GetSteerableViewMapDensityF1D" */
+ /** Returns the string "GetSteerableViewMapDensityF1D" */
string getName() const
{
return "GetViewMapGradientNormF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
diff --git a/source/blender/freestyle/intern/stroke/AdvancedPredicates1D.h b/source/blender/freestyle/intern/stroke/AdvancedPredicates1D.h
index 25a5efcce34..d7c501e97ad 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedPredicates1D.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedPredicates1D.h
@@ -38,12 +38,12 @@ namespace Freestyle {
namespace Predicates1D {
// DensityLowerThanUP1D
-/*! Returns true if the density evaluated for the
+/** Returns true if the density evaluated for the
* Interface1D is less than a user-defined density value.
*/
class DensityLowerThanUP1D : public UnaryPredicate1D {
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param threshold:
* The value of the threshold density.
* Any Interface1D having a density lower than this threshold will match.
@@ -56,13 +56,13 @@ class DensityLowerThanUP1D : public UnaryPredicate1D {
_sigma = sigma;
}
- /*! Returns the string "DensityLowerThanUP1D" */
+ /** Returns the string "DensityLowerThanUP1D" */
string getName() const
{
return "DensityLowerThanUP1D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface1D &inter)
{
Functions1D::DensityF1D fun(_sigma);
diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
index 63c7d451599..52cd037a73a 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
@@ -25,14 +25,14 @@
namespace Freestyle {
-/*! [ Thickness Shader ].
+/** [ 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 thinnest in the
* direction perpendicular to this one, and an interpolation in between.
*/
class CalligraphicShader : public StrokeShader {
public:
- /*! Builds the shader.
+ /** Builds the shader.
* \param iMinThickness:
* The minimum thickness in the direction perpendicular to the main direction.
* \param iMaxThickness:
@@ -47,12 +47,12 @@ class CalligraphicShader : public StrokeShader {
const Vec2f &iOrientation,
bool clamp);
- /*! Destructor. */
+ /** Destructor. */
virtual ~CalligraphicShader()
{
}
- /*! The shading method */
+ /** The shading method */
virtual int shade(Stroke &ioStroke) const;
protected:
@@ -62,14 +62,14 @@ class CalligraphicShader : public StrokeShader {
bool _clamp;
};
-/*! [ Geometry Shader ].
+/** [ Geometry Shader ].
* Spatial Noise stroke shader.
* Moves the vertices to make the stroke more noisy.
* \see \htmlonly <a href=noise/noise.html>noise/noise.html</a> \endhtmlonly
*/
class SpatialNoiseShader : public StrokeShader {
public:
- /*! Builds the shader.
+ /** Builds the shader.
* \param iAmount:
* The amplitude of the noise.
* \param ixScale:
@@ -83,12 +83,12 @@ class SpatialNoiseShader : public StrokeShader {
*/
SpatialNoiseShader(float iAmount, float ixScale, int nbOctave, bool smooth, bool pureRandom);
- /*! Destructor. */
+ /** Destructor. */
virtual ~SpatialNoiseShader()
{
}
- /*! The shading method. */
+ /** The shading method. */
virtual int shade(Stroke &ioStroke) const;
protected:
@@ -99,7 +99,7 @@ class SpatialNoiseShader : public StrokeShader {
bool _pureRandom;
};
-/*! [ Geometry Shader ].
+/** [ Geometry Shader ].
* Smooths 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
@@ -108,7 +108,7 @@ class SpatialNoiseShader : public StrokeShader {
*/
class SmoothingShader : public StrokeShader {
public:
- /*! Builds the shader.
+ /** Builds the shader.
* \param iNbIteration:
* The number of iterations. (400)
* \param iFactorPoint:
@@ -135,12 +135,12 @@ class SmoothingShader : public StrokeShader {
real iAnisoCurvature,
real icarricatureFactor);
- /*! Destructor. */
+ /** Destructor. */
virtual ~SmoothingShader()
{
}
- /*! The shading method. */
+ /** The shading method. */
virtual int shade(Stroke &ioStroke) const;
protected:
@@ -213,7 +213,7 @@ class Omitter : public Smoother {
real _lengthFlat;
};
-/*! Omission shader */
+/** Omission shader */
class OmissionShader : public StrokeShader {
public:
OmissionShader(real sizeWindow, real thrVari, real thrFlat, real lFlat);
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
index 0ac0aa09cf9..2b578dd963a 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
@@ -47,12 +47,12 @@ namespace StrokeShaders {
//
//////////////////////////////////////////////////////
-/*! [ Thickness Shader ].
+/** [ Thickness Shader ].
* Assigns an absolute constant thickness to every vertices of the Stroke.
*/
class ConstantThicknessShader : public StrokeShader {
public:
- /*! Builds the shader.
+ /** Builds the shader.
* \param thickness:
* The thickness that must be assigned to the stroke.
*/
@@ -61,18 +61,18 @@ class ConstantThicknessShader : public StrokeShader {
_thickness = thickness;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~ConstantThicknessShader()
{
}
- /*! Returns the string "ConstantThicknessShader".*/
+ /** Returns the string "ConstantThicknessShader". */
virtual string getName() const
{
return "ConstantThicknessShader";
}
- /*! The shading method. */
+ /** The shading method. */
virtual int shade(Stroke &stroke) const;
private:
@@ -106,7 +106,7 @@ class ConstantExternThicknessShader : public StrokeShader {
float _thickness;
};
-/*! [ Thickness Shader ].
+/** [ 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
@@ -114,7 +114,7 @@ class ConstantExternThicknessShader : public StrokeShader {
*/
class IncreasingThicknessShader : public StrokeShader {
public:
- /*! Builds the shader.
+ /** Builds the shader.
* \param iThicknessMin:
* The first thickness value.
* \param iThicknessMax:
@@ -126,7 +126,7 @@ class IncreasingThicknessShader : public StrokeShader {
_ThicknessMax = iThicknessMax;
}
- /*! Destructor.*/
+ /** Destructor. */
virtual ~IncreasingThicknessShader()
{
}
@@ -136,7 +136,7 @@ class IncreasingThicknessShader : public StrokeShader {
return "IncreasingThicknessShader";
}
- /*! The shading method. */
+ /** The shading method. */
virtual int shade(Stroke &stroke) const;
private:
@@ -144,7 +144,7 @@ class IncreasingThicknessShader : public StrokeShader {
float _ThicknessMax;
};
-/*! [ Thickness shader ].
+/** [ 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
*/
@@ -155,7 +155,7 @@ class ConstrainedIncreasingThicknessShader : public StrokeShader {
float _ratio;
public:
- /*! Builds the shader.
+ /** Builds the shader.
* \param iThicknessMin:
* The first thickness value.
* \param iThicknessMax:
@@ -171,7 +171,7 @@ class ConstrainedIncreasingThicknessShader : public StrokeShader {
_ratio = iRatio;
}
- /*! Destructor.*/
+ /** Destructor. */
virtual ~ConstrainedIncreasingThicknessShader()
{
}
@@ -181,7 +181,7 @@ class ConstrainedIncreasingThicknessShader : public StrokeShader {
return "ConstrainedIncreasingThicknessShader";
}
- /*! The shading method. */
+ /** The shading method. */
virtual int shade(Stroke &stroke) const;
};
@@ -217,7 +217,7 @@ class LengthDependingThicknessShader : public StrokeShader {
virtual int shade(Stroke &stroke) const;
};
-/*! [ Thickness Shader ].
+/** [ Thickness Shader ].
* Adds some noise to the stroke thickness.
* \see \htmlonly <a href=noise/noise.html>noise/noise.html</a>\endhtmlonly
*/
@@ -229,7 +229,7 @@ class ThicknessNoiseShader : public StrokeShader {
public:
ThicknessNoiseShader();
- /*! Builds a Thickness Noise Shader
+ /** Builds a Thickness Noise Shader
* \param iAmplitude:
* The amplitude of the noise signal
* \param iPeriod:
@@ -242,7 +242,7 @@ class ThicknessNoiseShader : public StrokeShader {
return "ThicknessNoiseShader";
}
- /*! The shading method. */
+ /** The shading method. */
virtual int shade(Stroke &stroke) const;
};
@@ -250,12 +250,12 @@ class ThicknessNoiseShader : public StrokeShader {
// Color shaders
//
/////////////////////////////////////////////////////////
-/*! [ Color Shader ].
+/** [ Color Shader ].
* Assigns a constant color to every vertices of the Stroke.
*/
class ConstantColorShader : public StrokeShader {
public:
- /*! Builds the shader from a user-specified color.
+ /** Builds the shader from a user-specified color.
* \param iR:
* The red component
* \param iG:
@@ -278,14 +278,14 @@ class ConstantColorShader : public StrokeShader {
return "ConstantColorShader";
}
- /*! The shading method. */
+ /** The shading method. */
virtual int shade(Stroke &stroke) const;
private:
float _color[4];
};
-/*! [ Color Shader ].
+/** [ 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.
@@ -296,7 +296,7 @@ class IncreasingColorShader : public StrokeShader {
float _colorMax[4];
public:
- /*! Builds the shader from 2 user-specified colors.
+ /** Builds the shader from 2 user-specified colors.
* \param iRm:
* The first color red component
* \param iGm:
@@ -340,7 +340,7 @@ class IncreasingColorShader : public StrokeShader {
return "IncreasingColorShader";
}
- /*! The shading method. */
+ /** The shading method. */
virtual int shade(Stroke &stroke) const;
};
@@ -366,7 +366,7 @@ class MaterialColorShader : public StrokeShader {
virtual int shade(Stroke &stroke) const;
};
-/*! [ Color Shader ].
+/** [ Color Shader ].
* Shader to add noise to the stroke colors.
*/
class ColorNoiseShader : public StrokeShader {
@@ -377,7 +377,7 @@ class ColorNoiseShader : public StrokeShader {
public:
ColorNoiseShader();
- /*! Builds a Color Noise Shader
+ /** Builds a Color Noise Shader
* \param iAmplitude:
* The amplitude of the noise signal
* \param iPeriod:
@@ -390,7 +390,7 @@ class ColorNoiseShader : public StrokeShader {
return "ColorNoiseShader";
}
- /*! The shading method. */
+ /** The shading method. */
virtual int shade(Stroke &stroke) const;
};
@@ -398,7 +398,7 @@ class ColorNoiseShader : public StrokeShader {
// Geometry Shaders
//
///////////////////////////////////////////////////////////////////////////////
-/*! [ Geometry Shader ].
+/** [ Geometry Shader ].
* Stretches the stroke at its two extremities and following the respective directions: v(1)v(0)
* and v(n-1)v(n).
*/
@@ -407,7 +407,7 @@ class BackboneStretcherShader : public StrokeShader {
float _amount;
public:
- /*! Builds the shader.
+ /** Builds the shader.
* \param iAmount:
* The stretching amount value.
*/
@@ -421,11 +421,11 @@ class BackboneStretcherShader : public StrokeShader {
return "BackboneStretcherShader";
}
- /*! The shading method */
+ /** The shading method */
virtual int shade(Stroke &stroke) const;
};
-/*! [ Geometry Shader. ]
+/** [ Geometry Shader. ]
* Resamples the stroke.
* \see Stroke::Resample(float).
*/
@@ -434,7 +434,7 @@ class SamplingShader : public StrokeShader {
float _sampling;
public:
- /*! Builds the shader.
+ /** Builds the shader.
* \param sampling:
* The sampling to use for the stroke resampling
*/
@@ -448,7 +448,7 @@ class SamplingShader : public StrokeShader {
return "SamplingShader";
}
- /*! The shading method */
+ /** The shading method */
virtual int shade(Stroke &stroke) const;
};
@@ -471,7 +471,7 @@ class ExternalContourStretcherShader : public StrokeShader {
};
// Bezier curve stroke shader
-/*! [ Geometry 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
@@ -481,7 +481,7 @@ class BezierCurveShader : public StrokeShader {
float _error;
public:
- /*! Builds the shader.
+ /** Builds the shader.
* \param error:
* The error we're allowing for the approximation.
* This error is the max distance allowed between the new curve and the original geometry.
@@ -496,11 +496,11 @@ class BezierCurveShader : public StrokeShader {
return "BezierCurveShader";
}
- /*! The shading method */
+ /** The shading method */
virtual int shade(Stroke &stroke) const;
};
-/*! [ Geometry Shader ].
+/** [ 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
@@ -511,7 +511,7 @@ class PolygonalizationShader : public StrokeShader {
float _error;
public:
- /*! Builds the shader.
+ /** 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 original one.
@@ -527,11 +527,11 @@ class PolygonalizationShader : public StrokeShader {
return "PolygonalizationShader";
}
- /*! The shading method */
+ /** The shading method */
virtual int shade(Stroke &stroke) const;
};
-/*! [ Geometry Shader ].
+/** [ Geometry Shader ].
* Shader to modify the Stroke geometry so that it corresponds to its main direction line.
* This shader must be used together with the splitting operator using the curvature criterion.
* Indeed, the precision of the approximation will depend on the size of the stroke's pieces.
@@ -542,7 +542,7 @@ class GuidingLinesShader : public StrokeShader {
float _offset;
public:
- /*! Builds a Guiding Lines shader
+ /** 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
@@ -558,27 +558,27 @@ class GuidingLinesShader : public StrokeShader {
return "GuidingLinesShader";
}
- /*! The shading method */
+ /** The shading method */
virtual int shade(Stroke &stroke) const;
};
-/*! [ Geometry Shader ].
+/** [ Geometry Shader ].
* Removes the stroke's extremities.
*/
class TipRemoverShader : public StrokeShader {
public:
- /*! Builds the shader.
+ /** Builds the shader.
* \param tipLength:
* The length of the piece of stroke we want to remove at each extremity.
*/
TipRemoverShader(real tipLength);
- /*! Destructor. */
+ /** Destructor. */
virtual ~TipRemoverShader()
{
}
- /*! The shading method */
+ /** The shading method */
virtual string getName() const
{
return "TipRemoverShader";
@@ -590,7 +590,7 @@ class TipRemoverShader : public StrokeShader {
real _tipLength;
};
-/*! [ Texture Shader ].
+/** [ Texture Shader ].
* Shader to assign texture to the Stroke material.
*/
@@ -600,7 +600,7 @@ class BlenderTextureShader : public StrokeShader {
bNodeTree *_nodeTree;
public:
- /*! Builds the shader.
+ /** Builds the shader.
* \param mtex:
* The blender texture to use.
*/
@@ -610,7 +610,7 @@ class BlenderTextureShader : public StrokeShader {
_nodeTree = NULL;
}
- /*! Builds the shader.
+ /** Builds the shader.
* \param nodetree:
* A node tree (of new shading nodes) to define textures.
*/
@@ -625,11 +625,11 @@ class BlenderTextureShader : public StrokeShader {
return "BlenderTextureShader";
}
- /*! The shading method */
+ /** The shading method */
virtual int shade(Stroke &stroke) const;
};
-/*! [ Texture Shader ].
+/** [ Texture Shader ].
* Shader to assign texture to the Stroke material.
*/
@@ -638,7 +638,7 @@ class StrokeTextureStepShader : public StrokeShader {
float _step;
public:
- /*! Builds the shader.
+ /** Builds the shader.
* \param id:
* The number of the preset to use.
*/
@@ -652,7 +652,7 @@ class StrokeTextureStepShader : public StrokeShader {
return "StrokeTextureStepShader";
}
- /*! The shading method */
+ /** The shading method */
virtual int shade(Stroke &stroke) const;
};
diff --git a/source/blender/freestyle/intern/stroke/Canvas.h b/source/blender/freestyle/intern/stroke/Canvas.h
index 91676946b5d..8d71cd534ec 100644
--- a/source/blender/freestyle/intern/stroke/Canvas.h
+++ b/source/blender/freestyle/intern/stroke/Canvas.h
@@ -60,12 +60,12 @@ class ImagePyramid;
class SteerableViewMap;
class StyleModule;
-/*! Class to define the canvas on which strokes are drawn.
+/** Class to define the canvas on which strokes are drawn.
* It's used to store state information about the drawing.
*/
class Canvas {
public:
- /*! Returns a pointer on the Canvas instance */
+ /** Returns a pointer on the Canvas instance */
static Canvas *getInstance()
{
return _pInstance;
@@ -136,7 +136,7 @@ class Canvas {
}
/* Maps management */
- /*! Loads an image map. The map will be scaled
+ /** 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:
@@ -152,7 +152,7 @@ class Canvas {
unsigned iNbLevels = 4,
float iSigma = 1.0f);
- /*! Reads a pixel value in a map.
+ /** Reads a pixel value in a map.
* Returns a value between 0 and 1.
* \param iMapName:
* The name of the map
@@ -167,19 +167,19 @@ class Canvas {
*/
float readMapPixel(const char *iMapName, int level, int x, int y);
- /*! Sets the steerable viewmap */
+ /** Sets the steerable viewmap */
void loadSteerableViewMap(SteerableViewMap *iSVM)
{
_steerableViewMap = iSVM;
}
- /*! Returns the steerable VM */
+ /** Returns the steerable VM */
SteerableViewMap *getSteerableViewMap()
{
return _steerableViewMap;
}
- /*! accessors */
+ /** accessors */
inline const FEdge *selectedFEdge() const
{
return _SelectedFEdge;
@@ -215,13 +215,13 @@ class Canvas {
return stroke_count;
}
- /*! modifiers */
+ /** modifiers */
inline void setSelectedFEdge(FEdge *iFEdge)
{
_SelectedFEdge = iFEdge;
}
- /*! inserts a shader at pos index+1 */
+ /** inserts a shader at pos index+1 */
void PushBackStyleModule(StyleModule *iStyleModule);
void InsertStyleModule(unsigned index, StyleModule *iStyleModule);
void RemoveStyleModule(unsigned index);
diff --git a/source/blender/freestyle/intern/stroke/Chain.h b/source/blender/freestyle/intern/stroke/Chain.h
index d5dae5c35ba..bcc6957b714 100644
--- a/source/blender/freestyle/intern/stroke/Chain.h
+++ b/source/blender/freestyle/intern/stroke/Chain.h
@@ -27,7 +27,7 @@
namespace Freestyle {
-/*! Class to represent a 1D elements issued from the chaining process.
+/** Class to represent a 1D elements issued from the chaining process.
* A Chain is the last step before the Stroke and is used in the Splitting and Creation processes.
*/
class Chain : public Curve {
@@ -38,28 +38,28 @@ class Chain : public Curve {
_fedgeB; // the last FEdge of the ViewEdge passed to the last call for push_viewedge_back().
public:
- /*! Default constructor. */
+ /** Default constructor. */
Chain() : Curve()
{
_splittingId = 0;
_fedgeB = 0;
}
- /*! Builds a chain from its Id. */
+ /** Builds a chain from its Id. */
Chain(const Id &id) : Curve(id)
{
_splittingId = 0;
_fedgeB = 0;
}
- /*! Copy Constructor */
+ /** Copy Constructor */
Chain(const Chain &iBrother) : Curve(iBrother)
{
_splittingId = iBrother._splittingId;
_fedgeB = iBrother._fedgeB;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~Chain()
{
// only the last splitted deletes this id
@@ -70,13 +70,13 @@ class Chain : public Curve {
}
}
- /*! Returns the string "Chain" */
+ /** Returns the string "Chain" */
virtual string getExactTypeName() const
{
return "Chain";
}
- /*! Adds a ViewEdge at the end of the chain
+ /** Adds a ViewEdge at the end of the chain
* \param iViewEdge:
* The ViewEdge that must be added.
* \param orientation:
@@ -84,7 +84,7 @@ class Chain : public Curve {
*/
void push_viewedge_back(ViewEdge *iViewEdge, bool orientation);
- /*! Adds a ViewEdge at the beginning of the chain
+ /** Adds a ViewEdge at the beginning of the chain
* \param iViewEdge:
* The ViewEdge that must be added.
* \param orientation:
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.h b/source/blender/freestyle/intern/stroke/ChainingIterators.h
index 0a9e7114ecb..93aba258358 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.h
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.h
@@ -98,11 +98,11 @@ class AdjacencyIterator : public Iterator {
return _internalIterator.isBegin();
}
- /*! Returns true if the current ViewEdge is coming towards the iteration vertex.
+ /** Returns true if the current ViewEdge is coming towards the iteration vertex.
* False otherwise. */
bool isIncoming() const;
- /*! Returns a *pointer* to the pointed ViewEdge. */
+ /** Returns a *pointer* to the pointed ViewEdge. */
virtual ViewEdge *operator*();
virtual ViewEdge *operator->()
@@ -140,7 +140,7 @@ class AdjacencyIterator : public Iterator {
//
///////////////////////////////////////////////////////////
-/*! Base class for chaining iterators.
+/** Base class for chaining iterators.
* This class is designed to be overloaded in order to describe chaining rules.
* It makes the works of chaining rules description easier.
* The two main methods that need to overloaded are traverse() and init().
@@ -159,7 +159,7 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
ViewEdge *result;
void *py_c_it;
- /*! Builds a Chaining Iterator from the first ViewEdge used for iteration and its orientation.
+ /** 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.
@@ -183,7 +183,7 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
py_c_it = NULL;
}
- /*! Copy constructor */
+ /** Copy constructor */
ChainingIterator(const ChainingIterator &brother) : ViewEdgeIterator(brother)
{
_restrictToSelection = brother._restrictToSelection;
@@ -192,19 +192,19 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
py_c_it = brother.py_c_it;
}
- /*! Returns the string "ChainingIterator" */
+ /** Returns the string "ChainingIterator" */
virtual string getExactTypeName() const
{
return "ChainingIterator";
}
- /*! Inits the iterator context.
+ /** Inits the iterator context.
* This method is called each time a new chain is started.
* It can be used to reset some history information that you might want to keep.
*/
virtual int init();
- /*! This method iterates over the potential next ViewEdges and returns the one that will be
+ /** 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.
@@ -214,11 +214,11 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
virtual int traverse(const AdjacencyIterator &it);
/* accessors */
- /*! Returns true if the orientation of the current ViewEdge corresponds to its natural
+ /** 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 */
+ /** Returns the vertex which is the next crossing */
inline ViewVertex *getVertex()
{
if (_increment) {
@@ -239,13 +239,13 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
}
}
- /*! Returns true if the current iteration is an incrementation */
+ /** Returns true if the current iteration is an incrementation */
inline bool isIncrementing() const
{
return _increment;
}
- /* increments.*/
+ /* Increments. */
virtual int increment();
virtual int decrement();
};
@@ -255,7 +255,7 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
//
///////////////////////////////////////////////////////////
-/*! A ViewEdge Iterator used to follow ViewEdges the most naturally.
+/** 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
@@ -263,7 +263,7 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
*/
class ChainSilhouetteIterator : public ChainingIterator {
public:
- /*! Builds a ChainSilhouetteIterator from the first ViewEdge used for iteration and its
+ /** 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
@@ -282,24 +282,24 @@ class ChainSilhouetteIterator : public ChainingIterator {
{
}
- /*! Copy constructor */
+ /** Copy constructor */
ChainSilhouetteIterator(const ChainSilhouetteIterator &brother) : ChainingIterator(brother)
{
}
- /*! Returns the string "ChainSilhouetteIterator" */
+ /** Returns the string "ChainSilhouetteIterator" */
virtual string getExactTypeName() const
{
return "ChainSilhouetteIterator";
}
- /*! This method iterates over the potential next ViewEdges and returns the one that will be
+ /** 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);
- /*! Inits the iterator context */
+ /** Inits the iterator context */
virtual int init()
{
return 0;
@@ -311,7 +311,7 @@ class ChainSilhouetteIterator : public ChainingIterator {
//
///////////////////////////////////////////////////////////
-/*! A "generic" user-controlled ViewEdge iterator. This iterator is in particular built from a
+/** 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.
@@ -327,7 +327,7 @@ class ChainPredicateIterator : public ChainingIterator {
UnaryPredicate1D *_unary_predicate; // the caller is responsible for the deletion of this object
public:
- /*! Builds a ChainPredicateIterator from a starting ViewEdge and its orientation.
+ /** 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.
@@ -350,7 +350,7 @@ class ChainPredicateIterator : public ChainingIterator {
_unary_predicate = 0;
}
- /*! Builds a ChainPredicateIterator from a unary predicate, a binary predicate, a starting
+ /** 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
@@ -381,32 +381,32 @@ class ChainPredicateIterator : public ChainingIterator {
_binary_predicate = &bpred;
}
- /*! Copy constructor */
+ /** Copy constructor */
ChainPredicateIterator(const ChainPredicateIterator &brother) : ChainingIterator(brother)
{
_unary_predicate = brother._unary_predicate;
_binary_predicate = brother._binary_predicate;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~ChainPredicateIterator()
{
_unary_predicate = 0;
_binary_predicate = 0;
}
- /*! Returns the string "ChainPredicateIterator" */
+ /** Returns the string "ChainPredicateIterator" */
virtual string getExactTypeName() const
{
return "ChainPredicateIterator";
}
- /*! This method iterates over the potential next ViewEdges and returns the one that will be
+ /** 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);
- /*! Inits the iterator context */
+ /** Inits the iterator context */
virtual int init()
{
return 0;
diff --git a/source/blender/freestyle/intern/stroke/ContextFunctions.h b/source/blender/freestyle/intern/stroke/ContextFunctions.h
index 334bdd657c1..4878d2a6c54 100644
--- a/source/blender/freestyle/intern/stroke/ContextFunctions.h
+++ b/source/blender/freestyle/intern/stroke/ContextFunctions.h
@@ -33,34 +33,34 @@ namespace Freestyle {
// Context Functions definitions
//
///////////////////////////////////////////////////////////
-/*! namespace containing all the Context related functions */
+/** namespace containing all the Context related functions */
namespace ContextFunctions {
// GetTimeStamp
-/*! Returns the system time stamp */
+/** Returns the system time stamp */
unsigned GetTimeStampCF();
// GetCanvasWidth
-/*! Returns the canvas width */
+/** Returns the canvas width */
unsigned GetCanvasWidthCF();
// GetCanvasHeight
-/*! Returns the canvas height */
+/** Returns the canvas height */
unsigned GetCanvasHeightCF();
// GetBorder
-/*! Returns the border */
+/** Returns the border */
BBox<Vec2i> GetBorderCF();
// Load map
-/*! Loads an image map for further reading */
+/** Loads an image map for further reading */
void LoadMapCF(const char *iFileName,
const char *iMapName,
unsigned iNbLevels = 4,
float iSigma = 1.0f);
// ReadMapPixel
-/*! Reads a pixel in a user-defined map
+/** Reads a pixel in a user-defined map
* \return the floating value stored for that pixel
* \param iMapName:
* The name of the map
@@ -74,7 +74,7 @@ void LoadMapCF(const char *iFileName,
float ReadMapPixelCF(const char *iMapName, int level, unsigned x, unsigned y);
// ReadCompleteViewMapPixel
-/*! Reads a pixel in the complete view map
+/** Reads a pixel in the complete view map
* \return the floating value stored for that pixel
* \param level:
* The level of the pyramid in which we wish to read the pixel
@@ -86,7 +86,7 @@ float ReadMapPixelCF(const char *iMapName, int level, unsigned x, unsigned y);
float ReadCompleteViewMapPixelCF(int level, unsigned x, unsigned y);
// ReadOrientedViewMapPixel
-/*! Reads a pixel in one of the oriented view map images
+/** Reads a pixel in one of the oriented view map images
* \return the floating value stored for that pixel
* \param iOrientation:
* The number telling which orientation we want to check
diff --git a/source/blender/freestyle/intern/stroke/Curve.cpp b/source/blender/freestyle/intern/stroke/Curve.cpp
index 768e9efa15d..08d7a0b792a 100644
--- a/source/blender/freestyle/intern/stroke/Curve.cpp
+++ b/source/blender/freestyle/intern/stroke/Curve.cpp
@@ -573,7 +573,7 @@ Curve::~Curve()
}
}
-/*! iterators access */
+/** iterators access */
Curve::point_iterator Curve::points_begin(float step)
{
vertex_container::iterator second = _Vertices.begin();
diff --git a/source/blender/freestyle/intern/stroke/Curve.h b/source/blender/freestyle/intern/stroke/Curve.h
index f0db45150a9..9a05fcd380b 100644
--- a/source/blender/freestyle/intern/stroke/Curve.h
+++ b/source/blender/freestyle/intern/stroke/Curve.h
@@ -52,7 +52,7 @@ using namespace Geometry;
/* */
/**********************************/
-/*! Class to represent a point of a curve.
+/** 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 linearly
@@ -61,56 +61,56 @@ using namespace Geometry;
*/
class CurvePoint : public Interface0D {
public: // Implementation of Interface0D
- /*! Returns the string "CurvePoint"*/
+ /** Returns the string "CurvePoint". */
virtual string getExactTypeName() const
{
return "CurvePoint";
}
// Data access methods
- /*! Returns the 3D X coordinate of the point */
+ /** Returns the 3D X coordinate of the point */
virtual real getX() const
{
return _Point3d.x();
}
- /*! Returns the 3D Y coordinate of the point */
+ /** Returns the 3D Y coordinate of the point */
virtual real getY() const
{
return _Point3d.y();
}
- /*! Returns the 3D Z coordinate of the point */
+ /** Returns the 3D Z coordinate of the point */
virtual real getZ() const
{
return _Point3d.z();
}
- /*! Returns the 3D point. */
+ /** Returns the 3D point. */
virtual Vec3r getPoint3D() const
{
return _Point3d;
}
- /*! Returns the projected 3D X coordinate of the point */
+ /** Returns the projected 3D X coordinate of the point */
virtual real getProjectedX() const
{
return _Point2d.x();
}
- /*! Returns the projected 3D Y coordinate of the point */
+ /** Returns the projected 3D Y coordinate of the point */
virtual real getProjectedY() const
{
return _Point2d.y();
}
- /*! Returns the projected 3D Z coordinate of the point */
+ /** Returns the projected 3D Z coordinate of the point */
virtual real getProjectedZ() const
{
return _Point2d.z();
}
- /*! Returns the 2D point. */
+ /** Returns the 2D point. */
virtual Vec2r getPoint2D() const
{
return Vec2r(_Point2d.x(), _Point2d.y());
@@ -118,7 +118,7 @@ class CurvePoint : public Interface0D {
virtual FEdge *getFEdge(Interface0D &inter);
- /*! Returns the CurvePoint's Id */
+ /** Returns the CurvePoint's Id */
virtual Id getId() const
{
Id id;
@@ -131,7 +131,7 @@ class CurvePoint : public Interface0D {
return id;
}
- /*! Returns the CurvePoint's Nature */
+ /** Returns the CurvePoint's Nature */
virtual Nature::VertexNature getNature() const
{
Nature::VertexNature nature = Nature::POINT;
@@ -144,7 +144,7 @@ class CurvePoint : public Interface0D {
return nature;
}
- /*! Cast the Interface0D in SVertex if it can be. */
+ /** Cast the Interface0D in SVertex if it can be. */
virtual SVertex *castToSVertex()
{
if (_t2d == 0) {
@@ -156,7 +156,7 @@ class CurvePoint : public Interface0D {
return Interface0D::castToSVertex();
}
- /*! Cast the Interface0D in ViewVertex if it can be. */
+ /** Cast the Interface0D in ViewVertex if it can be. */
virtual ViewVertex *castToViewVertex()
{
if (_t2d == 0) {
@@ -168,7 +168,7 @@ class CurvePoint : public Interface0D {
return Interface0D::castToViewVertex();
}
- /*! Cast the Interface0D in NonTVertex if it can be. */
+ /** Cast the Interface0D in NonTVertex if it can be. */
virtual NonTVertex *castToNonTVertex()
{
if (_t2d == 0) {
@@ -180,7 +180,7 @@ class CurvePoint : public Interface0D {
return Interface0D::castToNonTVertex();
}
- /*! Cast the Interface0D in TVertex if it can be. */
+ /** Cast the Interface0D in TVertex if it can be. */
virtual TVertex *castToTVertex()
{
if (_t2d == 0) {
@@ -204,10 +204,10 @@ class CurvePoint : public Interface0D {
Vec3r _Point3d;
public:
- /*! Default Constructor. */
+ /** Default Constructor. */
CurvePoint();
- /*! Builds a CurvePoint from two SVertex and an interpolation parameter.
+ /** Builds a CurvePoint from two SVertex and an interpolation parameter.
* \param iA:
* The first SVertex
* \param iB:
@@ -217,7 +217,7 @@ class CurvePoint : public Interface0D {
*/
CurvePoint(SVertex *iA, SVertex *iB, float t);
- /*! Builds a CurvePoint from two CurvePoint and an interpolation parameter.
+ /** Builds a CurvePoint from two CurvePoint and an interpolation parameter.
* \param iA:
* The first CurvePoint
* \param iB:
@@ -229,35 +229,35 @@ class CurvePoint : public Interface0D {
// CurvePoint(SVertex *iA, SVertex *iB, float t2d, float t3d);
- /*! Copy Constructor. */
+ /** Copy Constructor. */
CurvePoint(const CurvePoint &iBrother);
- /*! Operator = */
+ /** Operator = */
CurvePoint &operator=(const CurvePoint &iBrother);
- /*! Destructor */
+ /** Destructor */
virtual ~CurvePoint() = default;
- /*! Operator == */
+ /** Operator == */
bool operator==(const CurvePoint &b)
{
return ((__A == b.__A) && (__B == b.__B) && (_t2d == b._t2d));
}
/* accessors */
- /*! Returns the first SVertex upon which the CurvePoint is built. */
+ /** Returns the first SVertex upon which the CurvePoint is built. */
inline SVertex *A()
{
return __A;
}
- /*! Returns the second SVertex upon which the CurvePoint is built. */
+ /** Returns the second SVertex upon which the CurvePoint is built. */
inline SVertex *B()
{
return __B;
}
- /*! Returns the interpolation parameter. */
+ /** Returns the interpolation parameter. */
inline float t2d() const
{
return _t2d;
@@ -271,19 +271,19 @@ class CurvePoint : public Interface0D {
#endif
/* modifiers */
- /*! Sets the first SVertex upon which to build the CurvePoint. */
+ /** Sets the first SVertex upon which to build the CurvePoint. */
inline void setA(SVertex *iA)
{
__A = iA;
}
- /*! Sets the second SVertex upon which to build the CurvePoint. */
+ /** Sets the second SVertex upon which to build the CurvePoint. */
inline void setB(SVertex *iB)
{
__B = iB;
}
- /*! Sets the 2D interpolation parameter to use. */
+ /** Sets the 2D interpolation parameter to use. */
inline void setT2d(float t)
{
_t2d = t;
@@ -339,7 +339,7 @@ class CurvePoint : public Interface0D {
}
Vec3r curvature2d_as_vector() const;
- /*! angle in radians */
+ /** angle in radians */
real curvature2d_as_angle() const;
real curvatureFredo() const;
@@ -368,7 +368,7 @@ class CurvePointIterator;
} // end of namespace CurveInternal
-/*! Base class for curves made of CurvePoints.
+/** Base class for curves made of CurvePoints.
* SVertex is the type of the initial curve vertices.
* A Chain is a specialization of a Curve.
*/
@@ -396,7 +396,7 @@ class Curve : public Interface1D {
unsigned _nSegments; // number of segments
public:
- /*! Default Constructor. */
+ /** Default Constructor. */
Curve()
{
_Length = 0;
@@ -404,7 +404,7 @@ class Curve : public Interface1D {
_nSegments = 0;
}
- /*! Builds a Curve from its id */
+ /** Builds a Curve from its id */
Curve(const Id &id)
{
_Length = 0;
@@ -412,7 +412,7 @@ class Curve : public Interface1D {
_nSegments = 0;
}
- /*! Copy Constructor. */
+ /** Copy Constructor. */
Curve(const Curve &iBrother)
{
_Length = iBrother._Length;
@@ -421,10 +421,10 @@ class Curve : public Interface1D {
_nSegments = 0;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~Curve();
- /*! Returns the string "Curve" */
+ /** Returns the string "Curve" */
virtual string getExactTypeName() const
{
return "Curve";
@@ -435,7 +435,7 @@ class Curve : public Interface1D {
void computeCurvatureAndOrientation();
#endif
- /*! Adds a single vertex (CurvePoint) at the end of the Curve */
+ /** Adds a single vertex (CurvePoint) at the end of the Curve */
inline void push_vertex_back(Vertex *iVertex)
{
if (!_Vertices.empty()) {
@@ -447,7 +447,7 @@ class Curve : public Interface1D {
_Vertices.push_back(new_vertex);
}
- /*! Adds a single vertex (SVertex) at the end of the Curve */
+ /** Adds a single vertex (SVertex) at the end of the Curve */
inline void push_vertex_back(SVertex *iVertex)
{
if (!_Vertices.empty()) {
@@ -459,7 +459,7 @@ class Curve : public Interface1D {
_Vertices.push_back(new_vertex);
}
- /*! Adds a single vertex (CurvePoint) at the front of the Curve */
+ /** Adds a single vertex (CurvePoint) at the front of the Curve */
inline void push_vertex_front(Vertex *iVertex)
{
if (!_Vertices.empty()) {
@@ -471,7 +471,7 @@ class Curve : public Interface1D {
_Vertices.push_front(new_vertex);
}
- /*! Adds a single vertex (SVertex) at the front of the Curve */
+ /** Adds a single vertex (SVertex) at the front of the Curve */
inline void push_vertex_front(SVertex *iVertex)
{
if (!_Vertices.empty()) {
@@ -483,25 +483,25 @@ class Curve : public Interface1D {
_Vertices.push_front(new_vertex);
}
- /*! Returns true is the Curve doesn't have any Vertex yet. */
+ /** Returns true is the Curve doesn't have any Vertex yet. */
inline bool empty() const
{
return _Vertices.empty();
}
- /*! Returns the 2D length of the Curve. */
+ /** Returns the 2D length of the Curve. */
inline real getLength2D() const
{
return _Length;
}
- /*! Returns the Id of the 1D element. */
+ /** Returns the Id of the 1D element. */
virtual Id getId() const
{
return _Id;
}
- /*! Returns the number of segments in the polyline constituting the Curve. */
+ /** Returns the number of segments in the polyline constituting the Curve. */
inline unsigned int nSegments() const
{
return _nSegments;
@@ -549,7 +549,7 @@ class Curve : public Interface1D {
float local_depth_variance(int iCombination = 0) const;
real local_average_density(float sigma = 2.3f, int iCombination = 0) const;
Vec3r curvature2d_as_vector(int iCombination = 0) const;
- /*! angle in radians */
+ /** angle in radians */
real curvature2d_as_angle(int iCombination = 0) const;
#endif
@@ -573,23 +573,23 @@ class Curve : public Interface1D {
CurveInternal::CurvePointIterator curveVerticesEnd();
// Iterators access
- /*! Returns an Interface0DIterator pointing onto the first vertex of the Curve and that can
+ /** 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
+ /** 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
+ /** 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
+ /** 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.
*/
diff --git a/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h b/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
index 1896a674477..5cb5ab69711 100644
--- a/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
+++ b/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
@@ -50,7 +50,7 @@ class CurvePoint_nonconst_traits : public Nonconst_traits<CurvePoint *> {
/* */
/**********************************/
-/*! iterator on a curve. Allows an iterating outside initial vertices. A CurvePoint is
+/** iterator on a curve. Allows an iterating outside initial vertices. A CurvePoint is
* instantiated and returned when the iterator is dereferenced.
*/
template<class Traits>
diff --git a/source/blender/freestyle/intern/stroke/CurveIterators.h b/source/blender/freestyle/intern/stroke/CurveIterators.h
index 9d1cf33ed80..abbde02979d 100644
--- a/source/blender/freestyle/intern/stroke/CurveIterators.h
+++ b/source/blender/freestyle/intern/stroke/CurveIterators.h
@@ -28,7 +28,7 @@ namespace Freestyle {
namespace CurveInternal {
-/*! iterator on a curve. Allows an iterating outside
+/** iterator on a curve. Allows an iterating outside
* initial vertices. A CurvePoint is instantiated an returned
* when the iterator is dereferenced.
*/
diff --git a/source/blender/freestyle/intern/stroke/Modifiers.h b/source/blender/freestyle/intern/stroke/Modifiers.h
index 0aac6f58658..1952659dab7 100644
--- a/source/blender/freestyle/intern/stroke/Modifiers.h
+++ b/source/blender/freestyle/intern/stroke/Modifiers.h
@@ -35,16 +35,16 @@ namespace Freestyle {
* *
* ----------------------------------------- */
-/*! Base class for modifiers.
+/** Base class for modifiers.
* Modifiers are used in the Operators in order to "mark" the processed Interface1D.
*/
template<class Edge> struct EdgeModifier : public unary_function<Edge, void> {
- /*! Default construction */
+ /** Default construction */
EdgeModifier() : unary_function<Edge, void>()
{
}
- /*! the () operator */
+ /** the () operator */
virtual void operator()(Edge &iEdge)
{
}
@@ -54,14 +54,14 @@ template<class Edge> struct EdgeModifier : public unary_function<Edge, void> {
#endif
};
-/*! Modifier that sets the time stamp of an Interface1D to the time stamp of the system. */
+/** Modifier that sets the time stamp of an Interface1D to the time stamp of the system. */
template<class Edge> struct TimestampModifier : public EdgeModifier<Edge> {
- /*! Default constructor */
+ /** Default constructor */
TimestampModifier() : EdgeModifier<Edge>()
{
}
- /*! The () operator. */
+ /** The () operator. */
virtual void operator()(Edge &iEdge)
{
TimeStamp *timestamp = TimeStamp::instance();
diff --git a/source/blender/freestyle/intern/stroke/Operators.h b/source/blender/freestyle/intern/stroke/Operators.h
index e721e9fb837..4de331993f7 100644
--- a/source/blender/freestyle/intern/stroke/Operators.h
+++ b/source/blender/freestyle/intern/stroke/Operators.h
@@ -41,7 +41,7 @@
namespace Freestyle {
-/*! Class defining the operators used in a style module.
+/** 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.
@@ -57,12 +57,12 @@ class Operators {
//
////////////////////////////////////////////////
- /*! Selects the ViewEdges of the ViewMap verifying a specified condition.
+ /** Selects the ViewEdges of the ViewMap verifying a specified condition.
* \param pred: The predicate expressing this condition
*/
static int select(UnaryPredicate1D &pred);
- /*! Builds a set of chains from the current set of ViewEdges.
+ /** 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
* of the ViewMap using the user specified iterator.
@@ -80,7 +80,7 @@ class Operators {
UnaryPredicate1D &pred,
UnaryFunction1D_void &modifier);
- /*! Builds a set of chains from the current set of ViewEdges.
+ /** 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
* of the ViewMap using the user specified iterator.
@@ -95,7 +95,7 @@ class Operators {
*/
static int chain(ViewEdgeInternal::ViewEdgeIterator &it, UnaryPredicate1D &pred);
- /*! Builds a set of chains from the current set of ViewEdges.
+ /** 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
@@ -111,7 +111,7 @@ 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
+ /** 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
@@ -127,7 +127,7 @@ class Operators {
*/
static int bidirectionalChain(ChainingIterator &it);
- /*! Splits each chain of the current set of chains in a sequential way.
+ /** 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.
@@ -147,7 +147,7 @@ class Operators {
UnaryPredicate0D &stoppingPred,
float sampling = 0.0f);
- /*! Splits each chain of the current set of chains in a sequential way.
+ /** 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 resulting set of chains is a partition of the initial chain
@@ -160,7 +160,7 @@ class Operators {
*/
static int sequentialSplit(UnaryPredicate0D &pred, float sampling = 0.0f);
- /*! Splits the current set of chains in a recursive way.
+ /** 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
@@ -181,7 +181,7 @@ class Operators {
UnaryPredicate1D &pred,
float sampling = 0);
- /*! Splits the current set of chains in a recursive way.
+ /** 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
@@ -210,14 +210,14 @@ class Operators {
UnaryPredicate1D &pred,
float sampling = 0.0f);
- /*! Sorts the current set of chains (or viewedges)
+ /** 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
*/
static int sort(BinaryPredicate1D &pred);
- /*! Creates and shades the strokes from the current set of chains.
+ /** Creates and shades the strokes from the current set of chains.
* A predicate can be specified to make a selection pass on the chains.
* \param pred:
* The predicate that a chain must verify in order to be transform as a stroke
diff --git a/source/blender/freestyle/intern/stroke/PSStrokeRenderer.h b/source/blender/freestyle/intern/stroke/PSStrokeRenderer.h
index 46bb46ad8b2..349392a4c0e 100644
--- a/source/blender/freestyle/intern/stroke/PSStrokeRenderer.h
+++ b/source/blender/freestyle/intern/stroke/PSStrokeRenderer.h
@@ -41,7 +41,7 @@ class PSStrokeRenderer : public StrokeRenderer {
public:
PSStrokeRenderer(const char *iFileName = NULL);
- /*! Renders a stroke rep */
+ /** Renders a stroke rep */
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const;
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const;
diff --git a/source/blender/freestyle/intern/stroke/Predicates0D.h b/source/blender/freestyle/intern/stroke/Predicates0D.h
index 89dbaeb339d..11cbfb1b831 100644
--- a/source/blender/freestyle/intern/stroke/Predicates0D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates0D.h
@@ -34,7 +34,7 @@ namespace Freestyle {
//
///////////////////////////////////////////////////////////
-/*! Base class for Unary Predicates that work on Interface0DIterator.
+/** Base class for Unary Predicates that work on Interface0DIterator.
* A UnaryPredicate0D is a functor that evaluates a condition on a Interface0DIterator and returns
* true or false depending on whether this condition is satisfied or not.
* The UnaryPredicate0D is used by calling its () operator.
@@ -45,24 +45,24 @@ class UnaryPredicate0D {
bool result;
void *py_up0D;
- /*! Default constructor. */
+ /** Default constructor. */
UnaryPredicate0D()
{
py_up0D = 0;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~UnaryPredicate0D()
{
}
- /*! Returns the string of the name of the UnaryPredicate0D. */
+ /** Returns the string of the name of the UnaryPredicate0D. */
virtual string getName() const
{
return "UnaryPredicate0D";
}
- /*! The () operator. Must be overload by inherited classes.
+ /** 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.
@@ -79,7 +79,7 @@ class UnaryPredicate0D {
//
///////////////////////////////////////////////////////////
-/*! Base class for Binary Predicates working on Interface0D.
+/** Base class for Binary Predicates working on Interface0D.
* A BinaryPredicate0D is typically an ordering relation between two Interface0D.
* It evaluates a relation between 2 Interface0D and returns true or false.
* It is used by calling the () operator.
@@ -89,24 +89,24 @@ class BinaryPredicate0D {
bool result;
void *py_bp0D;
- /*! Default constructor. */
+ /** Default constructor. */
BinaryPredicate0D()
{
py_bp0D = 0;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~BinaryPredicate0D()
{
}
- /*! Returns the string of the name of the binary predicate. */
+ /** Returns the string of the name of the binary predicate. */
virtual string getName() const
{
return "BinaryPredicate0D";
}
- /*! The () operator. Must be overload by inherited classes.
+ /** The () operator. Must be overload by inherited classes.
* It evaluates a relation between 2 Interface0D.
* \param inter1:
* The first Interface0D.
@@ -129,21 +129,21 @@ class BinaryPredicate0D {
namespace Predicates0D {
// TrueUP0D
-/*! Returns true any time */
+/** Returns true any time */
class TrueUP0D : public UnaryPredicate0D {
public:
- /*! Default constructor. */
+ /** Default constructor. */
TrueUP0D()
{
}
- /*! Returns the string "TrueUP0D"*/
+ /** Returns the string "TrueUP0D". */
string getName() const
{
return "TrueUP0D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface0DIterator &)
{
result = true;
@@ -152,21 +152,21 @@ class TrueUP0D : public UnaryPredicate0D {
};
// FalseUP0D
-/*! Returns false any time */
+/** Returns false any time */
class FalseUP0D : public UnaryPredicate0D {
public:
- /*! Default constructor. */
+ /** Default constructor. */
FalseUP0D()
{
}
- /*! Returns the string "FalseUP0D"*/
+ /** Returns the string "FalseUP0D". */
string getName() const
{
return "FalseUP0D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface0DIterator &)
{
result = false;
diff --git a/source/blender/freestyle/intern/stroke/Predicates1D.h b/source/blender/freestyle/intern/stroke/Predicates1D.h
index c174162b214..e7be9d863dc 100644
--- a/source/blender/freestyle/intern/stroke/Predicates1D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates1D.h
@@ -41,7 +41,7 @@ namespace Freestyle {
//
///////////////////////////////////////////////////////////
-/*! Base class for Unary Predicates that work on Interface1D.
+/** Base class for Unary Predicates that work on Interface1D.
* A UnaryPredicate1D is a functor that evaluates a condition on a Interface1D and returns
* true or false depending on whether this condition is satisfied or not.
* The UnaryPredicate1D is used by calling its () operator.
@@ -52,24 +52,24 @@ class UnaryPredicate1D {
bool result;
void *py_up1D;
- /*! Default constructor. */
+ /** Default constructor. */
UnaryPredicate1D()
{
py_up1D = NULL;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~UnaryPredicate1D()
{
}
- /*! Returns the string of the name of the UnaryPredicate1D. */
+ /** Returns the string of the name of the UnaryPredicate1D. */
virtual string getName() const
{
return "UnaryPredicate1D";
}
- /*! The () operator. Must be overload by inherited classes.
+ /** The () operator. Must be overload by inherited classes.
* \param inter:
* The Interface1D on which we wish to evaluate the predicate.
* \return true if the condition is satisfied, false otherwise.
@@ -86,7 +86,7 @@ class UnaryPredicate1D {
//
///////////////////////////////////////////////////////////
-/*! Base class for Binary Predicates working on Interface1D.
+/** Base class for Binary Predicates working on Interface1D.
* A BinaryPredicate1D is typically an ordering relation between two Interface1D.
* It evaluates a relation between 2 Interface1D and returns true or false.
* It is used by calling the () operator.
@@ -96,24 +96,24 @@ class BinaryPredicate1D {
bool result;
void *py_bp1D;
- /*! Default constructor. */
+ /** Default constructor. */
BinaryPredicate1D()
{
py_bp1D = NULL;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~BinaryPredicate1D()
{
}
- /*! Returns the string of the name of the binary predicate. */
+ /** Returns the string of the name of the binary predicate. */
virtual string getName() const
{
return "BinaryPredicate1D";
}
- /*! The () operator. Must be overload by inherited classes.
+ /** The () operator. Must be overload by inherited classes.
* It evaluates a relation between 2 Interface1D.
* \param inter1:
* The first Interface1D.
@@ -136,21 +136,21 @@ class BinaryPredicate1D {
namespace Predicates1D {
// TrueUP1D
-/*! Returns true */
+/** Returns true */
class TrueUP1D : public UnaryPredicate1D {
public:
- /*! Constructor */
+ /** Constructor */
TrueUP1D()
{
}
- /*! Returns the string "TrueUP1D"*/
+ /** Returns the string "TrueUP1D". */
string getName() const
{
return "TrueUP1D";
}
- /*! the () operator */
+ /** the () operator */
int operator()(Interface1D &)
{
result = true;
@@ -159,21 +159,21 @@ class TrueUP1D : public UnaryPredicate1D {
};
// FalseUP1D
-/*! Returns false */
+/** Returns false */
class FalseUP1D : public UnaryPredicate1D {
public:
- /*! Constructor */
+ /** Constructor */
FalseUP1D()
{
}
- /*! Returns the string "FalseUP1D"*/
+ /** Returns the string "FalseUP1D". */
string getName() const
{
return "FalseUP1D";
}
- /*! the () operator */
+ /** the () operator */
int operator()(Interface1D &)
{
result = false;
@@ -182,12 +182,12 @@ class FalseUP1D : public UnaryPredicate1D {
};
// QuantitativeInvisibilityUP1D
-/*! Returns true if the Quantitative Invisibility evaluated at an Interface1D, using the
+/** 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:
- /*! Builds the Predicate.
+ /** Builds the Predicate.
* \param qi:
* The Quantitative Invisibility you want the Interface1D to have
*/
@@ -195,13 +195,13 @@ class QuantitativeInvisibilityUP1D : public UnaryPredicate1D {
{
}
- /*! Returns the string "QuantitativeInvisibilityUP1D" */
+ /** Returns the string "QuantitativeInvisibilityUP1D" */
string getName() const
{
return "QuantitativeInvisibilityUP1D";
}
- /*! the () operator */
+ /** the () operator */
int operator()(Interface1D &inter)
{
Functions1D::QuantitativeInvisibilityF1D func;
@@ -217,7 +217,7 @@ class QuantitativeInvisibilityUP1D : public UnaryPredicate1D {
};
// ContourUP1D
-/*! Returns true if the Interface1D is a contour.
+/** Returns true if the Interface1D is a contour.
* An Interface1D is a contour if it is bordered by a different shape on each of its sides.
*/
class ContourUP1D : public UnaryPredicate1D {
@@ -225,13 +225,13 @@ class ContourUP1D : public UnaryPredicate1D {
Functions1D::CurveNatureF1D _getNature;
public:
- /*! Returns the string "ContourUP1D"*/
+ /** Returns the string "ContourUP1D". */
string getName() const
{
return "ContourUP1D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface1D &inter)
{
if (_getNature(inter) < 0) {
@@ -252,7 +252,7 @@ class ContourUP1D : public UnaryPredicate1D {
};
// ExternalContourUP1D
-/*! Returns true if the Interface1D is an external contour.
+/** Returns true if the Interface1D is an external contour.
* An Interface1D is an external contour if it is bordered by no shape on one of its sides.
*/
class ExternalContourUP1D : public UnaryPredicate1D {
@@ -260,13 +260,13 @@ class ExternalContourUP1D : public UnaryPredicate1D {
Functions1D::CurveNatureF1D _getNature;
public:
- /*! Returns the string "ExternalContourUP1D" */
+ /** Returns the string "ExternalContourUP1D" */
string getName() const
{
return "ExternalContourUP1D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface1D &inter)
{
if (_getNature(inter) < 0) {
@@ -289,7 +289,7 @@ class ExternalContourUP1D : public UnaryPredicate1D {
};
// EqualToTimeStampUP1D
-/*! Returns true if the Interface1D's time stamp is equal to a certain user-defined value. */
+/** Returns true if the Interface1D's time stamp is equal to a certain user-defined value. */
class EqualToTimeStampUP1D : public UnaryPredicate1D {
protected:
unsigned _timeStamp;
@@ -300,13 +300,13 @@ class EqualToTimeStampUP1D : public UnaryPredicate1D {
_timeStamp = ts;
}
- /*! Returns the string "EqualToTimeStampUP1D"*/
+ /** Returns the string "EqualToTimeStampUP1D". */
string getName() const
{
return "EqualToTimeStampUP1D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface1D &inter)
{
result = (inter.getTimeStamp() == _timeStamp);
@@ -315,7 +315,7 @@ class EqualToTimeStampUP1D : public UnaryPredicate1D {
};
// EqualToChainingTimeStampUP1D
-/*! Returns true if the Interface1D's time stamp is equal to a certain user-defined value. */
+/** Returns true if the Interface1D's time stamp is equal to a certain user-defined value. */
class EqualToChainingTimeStampUP1D : public UnaryPredicate1D {
protected:
unsigned _timeStamp;
@@ -326,13 +326,13 @@ class EqualToChainingTimeStampUP1D : public UnaryPredicate1D {
_timeStamp = ts;
}
- /*! Returns the string "EqualToChainingTimeStampUP1D"*/
+ /** Returns the string "EqualToChainingTimeStampUP1D". */
string getName() const
{
return "EqualToChainingTimeStampUP1D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface1D &inter)
{
ViewEdge *edge = dynamic_cast<ViewEdge *>(&inter);
@@ -346,14 +346,14 @@ class EqualToChainingTimeStampUP1D : public UnaryPredicate1D {
};
// ShapeUP1D
-/*! Returns true if the shape to which the Interface1D belongs to has the same Id as the one
+/** 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;
public:
- /*! Builds the Predicate.
+ /** Builds the Predicate.
* \param idFirst:
* The first Id component.
* \param idSecond:
@@ -364,13 +364,13 @@ class ShapeUP1D : public UnaryPredicate1D {
_id = Id(idFirst, idSecond);
}
- /*! Returns the string "ShapeUP1D"*/
+ /** Returns the string "ShapeUP1D". */
string getName() const
{
return "ShapeUP1D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface1D &inter)
{
set<ViewShape *> shapes;
@@ -387,13 +387,13 @@ class ShapeUP1D : public UnaryPredicate1D {
};
// WithinImageBoundaryUP1D
-/*! Returns true if the Interface1D is (partly) within the image boundary. */
+/** Returns true if the Interface1D is (partly) within the image boundary. */
class WithinImageBoundaryUP1D : public UnaryPredicate1D {
private:
real _xmin, _ymin, _xmax, _ymax;
public:
- /*! Builds the Predicate.
+ /** Builds the Predicate.
* \param xmin:
* The X lower bound of the image boundary.
* \param ymin:
@@ -408,13 +408,13 @@ class WithinImageBoundaryUP1D : public UnaryPredicate1D {
{
}
- /*! Returns the string "WithinImageBoundaryUP1D" */
+ /** Returns the string "WithinImageBoundaryUP1D" */
string getName() const
{
return "WithinImageBoundaryUP1D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface1D &inter)
{
// 1st pass: check if a point is within the image boundary.
@@ -454,16 +454,16 @@ class WithinImageBoundaryUP1D : public UnaryPredicate1D {
///////////////////////////////////////////////////////////
// TrueBP1D
-/*! Returns true. */
+/** Returns true. */
class TrueBP1D : public BinaryPredicate1D {
public:
- /*! Returns the string "TrueBP1D" */
+ /** Returns the string "TrueBP1D" */
string getName() const
{
return "TrueBP1D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface1D & /*i1*/, Interface1D & /*i2*/)
{
result = true;
@@ -472,16 +472,16 @@ class TrueBP1D : public BinaryPredicate1D {
};
// FalseBP1D
-/*! Returns false. */
+/** Returns false. */
class FalseBP1D : public BinaryPredicate1D {
public:
- /*! Returns the string "FalseBP1D" */
+ /** Returns the string "FalseBP1D" */
string getName() const
{
return "FalseBP1D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface1D & /*i1*/, Interface1D & /*i2*/)
{
result = false;
@@ -490,17 +490,17 @@ class FalseBP1D : public BinaryPredicate1D {
};
// Length2DBP1D
-/*! Returns true if the 2D length of the Interface1D i1 is less than the 2D length of the
+/** 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" */
+ /** Returns the string "Length2DBP1D" */
string getName() const
{
return "Length2DBP1D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface1D &i1, Interface1D &i2)
{
result = (i1.getLength2D() > i2.getLength2D());
@@ -509,16 +509,16 @@ class Length2DBP1D : public BinaryPredicate1D {
};
// SameShapeIdBP1D
-/*! Returns true if the Interface1D i1 and i2 belong to the same shape. */
+/** Returns true if the Interface1D i1 and i2 belong to the same shape. */
class SameShapeIdBP1D : public BinaryPredicate1D {
public:
- /*! Returns the string "SameShapeIdBP1D" */
+ /** Returns the string "SameShapeIdBP1D" */
string getName() const
{
return "SameShapeIdBP1D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface1D &i1, Interface1D &i2)
{
set<ViewShape *> shapes1;
@@ -542,7 +542,7 @@ class SameShapeIdBP1D : public BinaryPredicate1D {
};
// ViewMapGradientNormBP1D
-/*! Returns true if the evaluation of the Gradient norm Function is higher for Interface1D i1 than
+/** Returns true if the evaluation of the Gradient norm Function is higher for Interface1D i1 than
* for i2. */
class ViewMapGradientNormBP1D : public BinaryPredicate1D {
private:
@@ -554,13 +554,13 @@ class ViewMapGradientNormBP1D : public BinaryPredicate1D {
{
}
- /*! Returns the string "ViewMapGradientNormBP1D" */
+ /** Returns the string "ViewMapGradientNormBP1D" */
string getName() const
{
return "ViewMapGradientNormBP1D";
}
- /*! The () operator. */
+ /** The () operator. */
int operator()(Interface1D &i1, Interface1D &i2)
{
if (_func(i1) < 0) {
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp
index 0de3e03d44a..956ba2743d7 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.cpp
+++ b/source/blender/freestyle/intern/stroke/Stroke.cpp
@@ -625,7 +625,7 @@ int Stroke::Resample(int iNPoints)
// add last:
++it;
++next;
- if ((it != itend) && (next == itend) /* && (t == 0.0f)*/) {
+ if ((it != itend) && (next == itend) /* && (t == 0.0f) */) {
newVertices.push_back(&(*it));
}
@@ -687,7 +687,7 @@ int Stroke::Resample(float iSampling)
++next;
}
// add last:
- if ((it != itend) && (next == itend) /* && (t == 0.0f)*/) {
+ if ((it != itend) && (next == itend) /* && (t == 0.0f) */) {
newVertices.push_back(&(*it));
}
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index 4a9ed7288c5..209ec86edef 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -52,18 +52,18 @@ namespace Freestyle {
//
////////////////////////////////////////////////////////
-/*! Class to define an attribute associated to a Stroke Vertex.
+/** Class to define an attribute associated to a Stroke Vertex.
* This attribute stores the color, alpha and thickness values for a Stroke Vertex.
*/
class StrokeAttribute {
public:
- /*! default constructor */
+ /** default constructor */
StrokeAttribute();
- /*! Copy constructor */
+ /** Copy constructor */
StrokeAttribute(const StrokeAttribute &iBrother);
- /*! Builds a stroke vertex attribute from a set of parameters.
+ /** Builds a stroke vertex attribute from a set of parameters.
* \param iRColor:
* The Red Component value.
* \param iGColor:
@@ -84,7 +84,7 @@ class StrokeAttribute {
float iRThickness,
float iLThickness);
- /*! Interpolation constructor.
+ /** Interpolation constructor.
* Builds a StrokeAttribute from two StrokeAttributes and an interpolation parameter.
* \param a1:
* The first Attribute.
@@ -95,15 +95,15 @@ class StrokeAttribute {
*/
StrokeAttribute(const StrokeAttribute &a1, const StrokeAttribute &a2, float t);
- /*! destructor */
+ /** destructor */
virtual ~StrokeAttribute();
/* operators */
- /*! operator = */
+ /** operator = */
StrokeAttribute &operator=(const StrokeAttribute &iBrother);
/* accessors */
- /*! Returns the attribute's color.
+ /** Returns the attribute's color.
* \return The array of 3 floats containing the R,G,B values of the attribute's color.
*/
inline const float *getColor() const
@@ -111,37 +111,37 @@ class StrokeAttribute {
return _color;
}
- /*! Returns the R color component. */
+ /** Returns the R color component. */
inline const float getColorR() const
{
return _color[0];
}
- /*! Returns the G color component. */
+ /** Returns the G color component. */
inline const float getColorG() const
{
return _color[1];
}
- /*! Returns the B color component. */
+ /** Returns the B color component. */
inline const float getColorB() const
{
return _color[2];
}
- /*! Returns the RGB color components. */
+ /** Returns the RGB color components. */
inline Vec3f getColorRGB() const
{
return Vec3f(_color[0], _color[1], _color[2]);
}
- /*! Returns the alpha color component. */
+ /** Returns the alpha color component. */
inline float getAlpha() const
{
return _alpha;
}
- /*! Returns the attribute's thickness.
+ /** 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.
*/
@@ -150,60 +150,60 @@ class StrokeAttribute {
return _thickness;
}
- /*! Returns the thickness on the right of the vertex when following the stroke. */
+ /** Returns the thickness on the right of the vertex when following the stroke. */
inline const float getThicknessR() const
{
return _thickness[0];
}
- /*! Returns the thickness on the left of the vertex when following the stroke. */
+ /** Returns the thickness on the left of the vertex when following the stroke. */
inline const float getThicknessL() const
{
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]);
}
- /*! Returns true if the strokevertex is visible, false otherwise */
+ /** Returns true if the strokevertex is visible, false otherwise */
inline bool isVisible() const
{
return _visible;
}
- /*! Returns an attribute of type real
+ /** Returns an attribute of type real
* \param iName:
* The name of the attribute
*/
float getAttributeReal(const char *iName) const;
- /*! Returns an attribute of type Vec2f
+ /** Returns an attribute of type Vec2f
* \param iName:
* The name of the attribute
*/
Vec2f getAttributeVec2f(const char *iName) const;
- /*! Returns an attribute of type Vec3f
+ /** Returns an attribute of type Vec3f
* \param iName:
* The name of the attribute
*/
Vec3f getAttributeVec3f(const char *iName) const;
- /*! Checks whether the attribute iName is available */
+ /** Checks whether the attribute iName is available */
bool isAttributeAvailableReal(const char *iName) const;
- /*! Checks whether the attribute iName is available */
+ /** Checks whether the attribute iName is available */
bool isAttributeAvailableVec2f(const char *iName) const;
- /*! Checks whether the attribute iName is available */
+ /** Checks whether the attribute iName is available */
bool isAttributeAvailableVec3f(const char *iName) const;
/* modifiers */
- /*! sets the attribute's color.
+ /** sets the attribute's color.
* \param r:
* The new R value.
* \param g:
@@ -218,7 +218,7 @@ class StrokeAttribute {
_color[2] = b;
}
- /*! sets the attribute's color.
+ /** sets the attribute's color.
* \param iRGB:
* The new RGB values.
*/
@@ -229,7 +229,7 @@ class StrokeAttribute {
_color[2] = iRGB[2];
}
- /*! sets the attribute's alpha value.
+ /** sets the attribute's alpha value.
* \param alpha:
* The new alpha value.
*/
@@ -238,7 +238,7 @@ class StrokeAttribute {
_alpha = alpha;
}
- /*! sets the attribute's thickness.
+ /** sets the attribute's thickness.
* \param tr:
* The thickness on the right of the vertex when following the stroke.
* \param tl:
@@ -250,7 +250,7 @@ class StrokeAttribute {
_thickness[1] = tl;
}
- /*! sets the attribute's thickness.
+ /** sets the attribute's thickness.
* \param tRL:
* The thickness on the right and on the left of the vertex when following the stroke.
*/
@@ -260,13 +260,13 @@ class StrokeAttribute {
_thickness[1] = tRL[1];
}
- /*! sets the visible flag. True means visible. */
+ /** sets the visible flag. True means visible. */
inline void setVisible(bool iVisible)
{
_visible = iVisible;
}
- /*! Adds a user defined attribute of type real
+ /** Adds a user defined attribute of type real
* If there is no attribute of name iName, it is added.
* Otherwise, the new value replaces the old one.
* \param iName:
@@ -276,7 +276,7 @@ class StrokeAttribute {
*/
void setAttributeReal(const char *iName, float att);
- /*! Adds a user defined attribute of type Vec2f
+ /** Adds a user defined attribute of type Vec2f
* If there is no attribute of name iName, it is added.
* Otherwise, the new value replaces the old one.
* \param iName:
@@ -286,7 +286,7 @@ class StrokeAttribute {
*/
void setAttributeVec2f(const char *iName, const Vec2f &att);
- /*! Adds a user defined attribute of type Vec3f
+ /** Adds a user defined attribute of type Vec3f
* If there is no attribute of name iName, it is added.
* Otherwise, the new value replaces the old one.
* \param iName:
@@ -322,10 +322,10 @@ class StrokeAttribute {
//
////////////////////////////////////////////////////////
-/*! Class to define a stroke vertex. */
+/** Class to define a stroke vertex. */
class StrokeVertex : public CurvePoint {
public: // Implementation of Interface0D
- /*! Returns the string "StrokeVertex" */
+ /** Returns the string "StrokeVertex" */
virtual string getExactTypeName() const
{
return "StrokeVertex";
@@ -337,129 +337,129 @@ class StrokeVertex : public CurvePoint {
float _StrokeLength; // stroke length
public:
- /*! default constructor */
+ /** default constructor */
StrokeVertex();
- /*! Copy constructor */
+ /** Copy constructor */
StrokeVertex(const StrokeVertex &iBrother);
- /*! Builds a stroke vertex from a SVertex */
+ /** Builds a stroke vertex from a SVertex */
StrokeVertex(SVertex *iSVertex);
- /*! Builds a stroke vertex from a CurvePoint */
+ /** Builds a stroke vertex from a CurvePoint */
StrokeVertex(CurvePoint *iPoint);
- /*! Builds Stroke Vertex from 2 stroke vertices and an interpolation parameter*/
+ /** Builds Stroke Vertex from 2 stroke vertices and an interpolation parameter. */
StrokeVertex(StrokeVertex *iA, StrokeVertex *iB, float t3);
- /*! Builds a stroke from a view vertex and an attribute */
+ /** Builds a stroke from a view vertex and an attribute */
StrokeVertex(SVertex *iSVertex, const StrokeAttribute &iAttribute);
/* operators */
- /*! operator = */
+ /** operator = */
StrokeVertex &operator=(const StrokeVertex &iBrother);
/* accessors */
- /*! Returns the 2D point x coordinate */
+ /** Returns the 2D point x coordinate */
inline real x() const
{
return _Point2d[0];
}
- /*! Returns the 2D point y coordinate */
+ /** Returns the 2D point y coordinate */
inline real y() const
{
return _Point2d[1];
}
- /*! Returns the 2D point coordinates as a Vec2r */
+ /** Returns the 2D point coordinates as a Vec2r */
inline Vec2r getPoint() const
{
return getPoint2D();
}
- /*! Returns the ith 2D point coordinate (i=0 or 1)*/
+ /** Returns the ith 2D point coordinate (i=0 or 1). */
inline real operator[](const int i) const
{
return _Point2d[i];
}
- /*! Returns the StrokeAttribute for this StrokeVertex */
+ /** Returns the StrokeAttribute for this StrokeVertex */
inline const StrokeAttribute &attribute() const
{
return _Attribute;
}
- /*! Returns a non-const reference to the StrokeAttribute of this StrokeVertex */
+ /** Returns a non-const reference to the StrokeAttribute of this StrokeVertex */
inline StrokeAttribute &attribute()
{
return _Attribute;
}
- /*! Returns the curvilinear abscissa */
+ /** Returns the curvilinear abscissa */
inline float curvilinearAbscissa() const
{
return _CurvilignAbscissa;
}
- /*! Returns the length of the Stroke to which this StrokeVertex belongs */
+ /** Returns the length of the Stroke to which this StrokeVertex belongs */
inline float strokeLength() const
{
return _StrokeLength;
}
- /*! Returns the curvilinear abscissa of this StrokeVertex in the Stroke */
+ /** Returns the curvilinear abscissa of this StrokeVertex in the Stroke */
inline float u() const
{
return _CurvilignAbscissa / _StrokeLength;
}
/* modifiers */
- /*! sets the 2D x value */
+ /** sets the 2D x value */
inline void setX(real x)
{
_Point2d[0] = x;
}
- /*! sets the 2D y value */
+ /** sets the 2D y value */
inline void setY(real y)
{
_Point2d[1] = y;
}
- /*! sets the 2D x and y values */
+ /** sets the 2D x and y values */
inline void setPoint(real x, real y)
{
_Point2d[0] = x;
_Point2d[1] = y;
}
- /*! sets the 2D x and y values */
+ /** sets the 2D x and y values */
inline void setPoint(const Vec2r &p)
{
_Point2d[0] = p[0];
_Point2d[1] = p[1];
}
- /*! Returns a reference to the ith 2D point coordinate (i=0 or 1) */
+ /** Returns a reference to the ith 2D point coordinate (i=0 or 1) */
inline real &operator[](const int i)
{
return _Point2d[i];
}
- /*! sets the attribute. */
+ /** sets the attribute. */
inline void setAttribute(const StrokeAttribute &iAttribute)
{
_Attribute = iAttribute;
}
- /*! sets the curvilinear abscissa of this StrokeVertex in the Stroke */
+ /** sets the curvilinear abscissa of this StrokeVertex in the Stroke */
inline void setCurvilinearAbscissa(float iAbscissa)
{
_CurvilignAbscissa = iAbscissa;
}
- /*! sets the Stroke's length (it's only a value stored by the Stroke Vertex, it won't change the
+ /** 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)
@@ -492,7 +492,7 @@ class StrokeVertexIterator;
} // end of namespace StrokeInternal
-/*! Class to define a stroke.
+/** 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
@@ -500,7 +500,7 @@ class StrokeVertexIterator;
*/
class Stroke : public Interface1D {
public: // Implementation of Interface1D
- /*! Returns the string "Stroke" */
+ /** Returns the string "Stroke" */
virtual string getExactTypeName() const
{
return "Stroke";
@@ -508,17 +508,17 @@ class Stroke : public Interface1D {
// Data access methods
- /*! Returns the Id of the Stroke */
+ /** Returns the Id of the Stroke */
virtual Id getId() const
{
return _id;
}
- /*! The different blending modes available to similate the interaction media-medium. */
+ /** The different blending modes available to similate the interaction media-medium. */
typedef enum {
- DRY_MEDIUM, /*!< To simulate a dry medium such as Pencil or Charcoal.*/
- HUMID_MEDIUM, /*!< To simulate ink painting (color subtraction blending).*/
- OPAQUE_MEDIUM, /*!< To simulate an opaque medium (oil, spray...).*/
+ DRY_MEDIUM, /**< To simulate a dry medium such as Pencil or Charcoal. */
+ HUMID_MEDIUM, /**< To simulate ink painting (color subtraction blending). */
+ OPAQUE_MEDIUM, /**< To simulate an opaque medium (oil, spray...). */
} MediumType;
public:
@@ -549,13 +549,13 @@ class Stroke : public Interface1D {
Vec2r _extremityOrientations[2]; // the orientations of the first and last extermity
public:
- /*! default constructor */
+ /** default constructor */
Stroke();
- /*! copy constructor */
+ /** copy constructor */
Stroke(const Stroke &iBrother);
- /*! Builds a stroke from a set of StrokeVertex.
+ /** Builds a stroke from a set of StrokeVertex.
* This constructor is templated by an iterator type.
* This iterator type must allow the vertices parsing using the ++ operator.
* \param iBegin:
@@ -565,14 +565,14 @@ class Stroke : public Interface1D {
*/
template<class InputVertexIterator> Stroke(InputVertexIterator iBegin, InputVertexIterator iEnd);
- /*! Destructor */
+ /** Destructor */
virtual ~Stroke();
/* operators */
- /*! operator = */
+ /** operator = */
Stroke &operator=(const Stroke &iBrother);
- /*! Compute the sampling needed to get iNVertices vertices.
+ /** 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).
* \param iNVertices:
@@ -583,7 +583,7 @@ class Stroke : public Interface1D {
*/
float ComputeSampling(int iNVertices);
- /*! Resampling method.
+ /** 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.
@@ -592,7 +592,7 @@ class Stroke : public Interface1D {
*/
int Resample(int iNPoints);
- /*! Resampling method.
+ /** Resampling method.
* Resamples the curve with a given sampling.
* If this sampling is < to the actual sampling value, no resampling is done.
* \param iSampling:
@@ -600,18 +600,18 @@ class Stroke : public Interface1D {
*/
int Resample(float iSampling);
- /*! Removes all vertices from the Stroke.
+ /** Removes all vertices from the Stroke.
*/
void RemoveAllVertices();
- /*! Removes the stroke vertex iVertex
+ /** Removes the stroke vertex iVertex
* from the stroke.
* The length and curvilinear abscissa are updated
* consequently.
*/
void RemoveVertex(StrokeVertex *iVertex);
- /*! Inserts the stroke vertex iVertex in the stroke before next.
+ /** Inserts the stroke vertex iVertex in the stroke before next.
* The length, curvilinear abscissa are updated consequently.
* \param iVertex:
* The StrokeVertex to insert in the Stroke.
@@ -620,7 +620,7 @@ class Stroke : public Interface1D {
*/
void InsertVertex(StrokeVertex *iVertex, StrokeInternal::StrokeVertexIterator next);
- /*! Updates the 2D length of the Stroke */
+ /** Updates the 2D length of the Stroke */
void UpdateLength();
/* Render method */
@@ -631,50 +631,50 @@ class Stroke : public Interface1D {
/* Iterator definition */
/* accessors */
- /*! Returns the 2D length of the Stroke */
+ /** Returns the 2D length of the Stroke */
inline real getLength2D() const
{
return _Length;
}
- /*! Returns a reference to the time stamp value of the stroke. */
- /*! Returns the MediumType used for this Stroke. */
+ /** Returns a reference to the time stamp value of the stroke. */
+ /** Returns the MediumType used for this Stroke. */
inline MediumType getMediumType() const
{
return _mediumType;
}
- /*! Returns the id of the texture used to simulate th marks system for this Stroke */
+ /** Returns the id of the texture used to simulate th marks system for this Stroke */
inline unsigned int getTextureId()
{
return _textureId;
}
- /*! Returns the spacing of texture coordinates along the stroke length */
+ /** Returns the spacing of texture coordinates along the stroke length */
inline float getTextureStep()
{
return _textureStep;
}
- /*! Returns the texture used at given index to simulate the marks system for this Stroke */
+ /** Returns the texture used at given index to simulate the marks system for this Stroke */
inline MTex *getMTex(int idx)
{
return _mtex[idx];
}
- /*! Return the shader node tree to define textures. */
+ /** Return the shader node tree to define textures. */
inline bNodeTree *getNodeTree()
{
return _nodeTree;
}
- /*! Returns true if this Stroke has textures assigned, false otherwise. */
+ /** Returns true if this Stroke has textures assigned, false otherwise. */
inline bool hasTex() const
{
return (_mtex[0] != NULL) || _nodeTree;
}
- /*! Returns true if this Stroke uses a texture with tips, false otherwise. */
+ /** Returns true if this Stroke uses a texture with tips, false otherwise. */
inline bool hasTips() const
{
return _tips;
@@ -742,34 +742,34 @@ class Stroke : public Interface1D {
}
/* modifiers */
- /*! sets the Id of the Stroke. */
+ /** sets the Id of the Stroke. */
inline void setId(const Id &id)
{
_id = id;
}
- /*! sets the 2D length of the Stroke. */
+ /** sets the 2D length of the Stroke. */
void setLength(float iLength);
- /*! sets the medium type that must be used for this Stroke. */
+ /** sets the medium type that must be used for this Stroke. */
inline void setMediumType(MediumType iType)
{
_mediumType = iType;
}
- /*! sets the texture id to be used to simulate the marks system for this Stroke. */
+ /** sets the texture id to be used to simulate the marks system for this Stroke. */
inline void setTextureId(unsigned int id)
{
_textureId = id;
}
- /*! sets the spacing of texture coordinates along the stroke length. */
+ /** sets the spacing of texture coordinates along the stroke length. */
inline void setTextureStep(float step)
{
_textureStep = step;
}
- /*! assigns a blender texture to the first available slot. */
+ /** assigns a blender texture to the first available slot. */
inline int setMTex(MTex *mtex)
{
for (int a = 0; a < MAX_MTEX; a++) {
@@ -781,13 +781,13 @@ class Stroke : public Interface1D {
return -1; /* no free slots */
}
- /*! assigns a node tree (of new shading nodes) to define textures. */
+ /** assigns a node tree (of new shading nodes) to define textures. */
inline void setNodeTree(bNodeTree *iNodeTree)
{
_nodeTree = iNodeTree;
}
- /*! sets the flag telling whether this stroke is using a texture with tips or not. */
+ /** sets the flag telling whether this stroke is using a texture with tips or not. */
inline void setTips(bool iTips)
{
_tips = iTips;
@@ -836,7 +836,7 @@ 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
+ /** Returns a StrokeVertexIterator pointing on the first StrokeVertex of the Stroke. One can
* specify a sampling value to re-sample the Stroke on the fly if needed.
*
* \param t: The resampling value with which we want our Stroke to be resampled.
@@ -844,26 +844,26 @@ class Stroke : public Interface1D {
*/
StrokeInternal::StrokeVertexIterator strokeVerticesBegin(float t = 0.0f);
- /*! Returns a StrokeVertexIterator pointing after the last StrokeVertex of the Stroke. */
+ /** Returns a StrokeVertexIterator pointing after the last StrokeVertex of the Stroke. */
StrokeInternal::StrokeVertexIterator strokeVerticesEnd();
- /*! Returns the number of StrokeVertex constituting the Stroke. */
+ /** Returns the number of StrokeVertex constituting the Stroke. */
inline unsigned int strokeVerticesSize() const
{
return _Vertices.size();
}
- /*! Returns the i-th StrokeVertex constituting the Stroke. */
+ /** Returns the i-th StrokeVertex constituting the Stroke. */
inline StrokeVertex &strokeVerticeAt(unsigned int i)
{
return *(_Vertices.at(i));
}
// Iterator access (Interface1D)
- /*! Returns an Interface0DIterator pointing on the first StrokeVertex of the Stroke. */
+ /** Returns an Interface0DIterator pointing on the first StrokeVertex of the Stroke. */
virtual Interface0DIterator verticesBegin();
- /*! Returns an Interface0DIterator pointing after the last StrokeVertex of the Stroke. */
+ /** Returns an Interface0DIterator pointing after the last StrokeVertex of the Stroke. */
virtual Interface0DIterator verticesEnd();
virtual Interface0DIterator pointsBegin(float t = 0.0f);
diff --git a/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h b/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h
index 4256cdebe86..0fbf94f609e 100644
--- a/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h
+++ b/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h
@@ -158,7 +158,7 @@ class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTa
return &(operator*());
}
- /*! accessors */
+ /** accessors */
inline vertex_container_iterator it() const
{
return _it;
diff --git a/source/blender/freestyle/intern/stroke/StrokeIterators.h b/source/blender/freestyle/intern/stroke/StrokeIterators.h
index d4cbffd535e..20c29b21c22 100644
--- a/source/blender/freestyle/intern/stroke/StrokeIterators.h
+++ b/source/blender/freestyle/intern/stroke/StrokeIterators.h
@@ -32,7 +32,7 @@ namespace StrokeInternal {
//
/////////////////////////////////////////////////
-/*! Class defining an iterator designed to iterate over the StrokeVertex of a Stroke.
+/** 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
@@ -46,12 +46,12 @@ namespace StrokeInternal {
*/
class StrokeVertexIterator : public Interface0DIteratorNested {
public:
- /*! Default constructor. */
+ /** Default constructor. */
StrokeVertexIterator()
{
}
- /*! Copy constructor. */
+ /** Copy constructor. */
StrokeVertexIterator(const StrokeVertexIterator &vi)
{
_it = vi._it;
@@ -72,7 +72,7 @@ class StrokeVertexIterator : public Interface0DIteratorNested {
{
}
- /*! Casts this StrokeVertexIterator into an Interface0DIterator.
+ /** Casts this StrokeVertexIterator into an Interface0DIterator.
* Useful for any call to a function of the type UnaryFunction0D.
*/
inline Interface0DIterator castToInterface0DIterator() const
@@ -81,7 +81,7 @@ class StrokeVertexIterator : public Interface0DIteratorNested {
return ret;
}
- /*! operator=
+ /** 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.
@@ -94,13 +94,13 @@ class StrokeVertexIterator : public Interface0DIteratorNested {
return *this;
}
- /*! Returns the string "StrokeVertexIterator". */
+ /** Returns the string "StrokeVertexIterator". */
virtual string getExactTypeName() const
{
return "StrokeVertexIterator";
}
- /*! Returns a reference to the pointed StrokeVertex.
+ /** Returns a reference to the pointed StrokeVertex.
* In the scripting language, you must call "getObject()"instead.
*/
virtual StrokeVertex &operator*()
@@ -108,7 +108,7 @@ class StrokeVertexIterator : public Interface0DIteratorNested {
return **_it;
}
- /*! Returns a pointer to the pointed StrokeVertex.
+ /** Returns a pointer to the pointed StrokeVertex.
* Can't be called in the scripting language.
*/
virtual StrokeVertex *operator->()
@@ -116,14 +116,14 @@ class StrokeVertexIterator : public Interface0DIteratorNested {
return &(operator*());
}
- /*! Increments. In the scripting language, call "increment()". */
+ /** Increments. In the scripting language, call "increment()". */
virtual StrokeVertexIterator &operator++()
{
increment();
return *this;
}
- /*! Increments. In the scripting language, call "increment()". */
+ /** Increments. In the scripting language, call "increment()". */
virtual StrokeVertexIterator operator++(int)
{
StrokeVertexIterator ret(*this);
@@ -131,14 +131,14 @@ class StrokeVertexIterator : public Interface0DIteratorNested {
return ret;
}
- /*! Decrements. In the scripting language, call "decrement()". */
+ /** Decrements. In the scripting language, call "decrement()". */
virtual StrokeVertexIterator &operator--()
{
decrement();
return *this;
}
- /*! Decrements. In the scripting language, call "decrement()". */
+ /** Decrements. In the scripting language, call "decrement()". */
virtual StrokeVertexIterator operator--(int)
{
StrokeVertexIterator ret(*this);
@@ -146,27 +146,27 @@ class StrokeVertexIterator : public Interface0DIteratorNested {
return ret;
}
- /*! Increments. */
+ /** Increments. */
virtual int increment()
{
++_it;
return 0;
}
- /*! Decrements. */
+ /** Decrements. */
virtual int decrement()
{
--_it;
return 0;
}
- /*! Returns true if the pointed StrokeVertex is the first of the Stroke. */
+ /** Returns true if the pointed StrokeVertex is the first of the Stroke. */
bool isBegin() const
{
return _it == _begin;
}
- /*! Returns true if the pointed StrokeVertex is the final valid StrokeVertex of the Stroke. */
+ /** Returns true if the pointed StrokeVertex is the final valid StrokeVertex of the Stroke. */
bool atLast()
{
if (_it == _end) {
@@ -179,13 +179,13 @@ class StrokeVertexIterator : public Interface0DIteratorNested {
return result;
}
- /*! Returns true if the pointed StrokeVertex is after the last StrokeVertex of the Stroke. */
+ /** Returns true if the pointed StrokeVertex is after the last StrokeVertex of the Stroke. */
bool isEnd() const
{
return _it == _end;
}
- /*! operator == */
+ /** operator == */
virtual bool operator==(const Interface0DIteratorNested &it) const
{
const StrokeVertexIterator *it_exact = dynamic_cast<const StrokeVertexIterator *>(&it);
@@ -195,19 +195,19 @@ class StrokeVertexIterator : public Interface0DIteratorNested {
return (_it == it_exact->_it);
}
- /*! Returns the curvilinear abscissa of the current point */
+ /** Returns the curvilinear abscissa of the current point */
virtual float t() const
{
return (*_it)->curvilinearAbscissa();
}
- /*! Returns the point's parameter in the stroke */
+ /** Returns the point's parameter in the stroke */
virtual float u() const
{
return (*_it)->u();
}
- /*! Cloning method */
+ /** Cloning method */
virtual StrokeVertexIterator *copy() const
{
return new StrokeVertexIterator(*this);
diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.h b/source/blender/freestyle/intern/stroke/StrokeLayer.h
index 2101e7732ce..3bcd675d295 100644
--- a/source/blender/freestyle/intern/stroke/StrokeLayer.h
+++ b/source/blender/freestyle/intern/stroke/StrokeLayer.h
@@ -55,15 +55,15 @@ class StrokeLayer {
virtual ~StrokeLayer();
- /*! Render method */
+ /** Render method */
void ScaleThickness(float iFactor);
void Render(const StrokeRenderer *iRenderer);
void RenderBasic(const StrokeRenderer *iRenderer);
- /*! clears the layer */
+ /** clears the layer */
void clear();
- /*! accessors */
+ /** accessors */
inline stroke_container::iterator strokes_begin()
{
return _strokes.begin();
@@ -84,7 +84,7 @@ class StrokeLayer {
return _strokes.empty();
}
- /*! modifiers */
+ /** modifiers */
inline void setStrokes(stroke_container &iStrokes)
{
_strokes = iStrokes;
diff --git a/source/blender/freestyle/intern/stroke/StrokeRenderer.h b/source/blender/freestyle/intern/stroke/StrokeRenderer.h
index d3ed8bde8a3..61b530b9643 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRenderer.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRenderer.h
@@ -46,7 +46,7 @@ namespace Freestyle {
/* */
/**********************************/
-/*! Class to load textures */
+/** Class to load textures */
class TextureManager {
public:
TextureManager();
@@ -117,13 +117,13 @@ class TextureManager {
/* */
/**********************************/
-/*! Class to render a stroke. Creates a triangle strip and stores it strip is lazily created at the
+/** Class to render a stroke. Creates a triangle strip and stores it strip is lazily created at the
* first rendering */
class StrokeRenderer {
public:
virtual ~StrokeRenderer();
- /*! Renders a stroke rep */
+ /** Renders a stroke rep */
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const = 0;
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const = 0;
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.h b/source/blender/freestyle/intern/stroke/StrokeRep.h
index 09048b8e147..cc889aac364 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.h
@@ -197,13 +197,13 @@ class StrokeRep {
StrokeRep(Stroke *iStroke);
virtual ~StrokeRep();
- /*! Creates the strips */
+ /** Creates the strips */
virtual void create();
- /*! Renders the stroke using a Renderer */
+ /** Renders the stroke using a Renderer */
virtual void Render(const StrokeRenderer *iRenderer);
- /*! accessors */
+ /** accessors */
inline Stroke::MediumType getMediumType() const
{
return _strokeType;
@@ -249,7 +249,7 @@ class StrokeRep {
return _stroke;
}
- /*! modifiers */
+ /** modifiers */
inline void setMediumType(Stroke::MediumType itype)
{
_strokeType = itype;
diff --git a/source/blender/freestyle/intern/stroke/StrokeShader.h b/source/blender/freestyle/intern/stroke/StrokeShader.h
index f4984136747..e4a8412d52a 100644
--- a/source/blender/freestyle/intern/stroke/StrokeShader.h
+++ b/source/blender/freestyle/intern/stroke/StrokeShader.h
@@ -39,7 +39,7 @@ namespace Freestyle {
class Stroke;
-/*! Base class for Stroke Shaders.
+/** Base class for Stroke Shaders.
* 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...
@@ -65,24 +65,24 @@ class StrokeShader {
public:
void *py_ss;
- /*! Default constructor. */
+ /** Default constructor. */
StrokeShader()
{
py_ss = 0;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~StrokeShader()
{
}
- /*! Returns the string corresponding to the shader's name. */
+ /** Returns the string corresponding to the shader's name. */
virtual string getName() const
{
return "StrokeShader";
}
- /*! The shading method. This method must be overloaded by inherited classes.
+ /** The shading method. This method must be overloaded by inherited classes.
* \param ioStroke:
* The stroke we wish to shade. this Stroke is modified by the Shader (which typically
* modifies the Stroke's attribute's values such as Color, Thickness, Geometry...)
diff --git a/source/blender/freestyle/intern/stroke/StrokeTesselator.h b/source/blender/freestyle/intern/stroke/StrokeTesselator.h
index 0c1efb873bc..b03db823d18 100644
--- a/source/blender/freestyle/intern/stroke/StrokeTesselator.h
+++ b/source/blender/freestyle/intern/stroke/StrokeTesselator.h
@@ -43,10 +43,10 @@ class StrokeTesselator {
{
}
- /*! Builds a line rep contained from a Stroke */
+ /** Builds a line rep contained from a Stroke */
LineRep *Tesselate(Stroke *iStroke);
- /*! Builds a set of lines rep contained under a a NodeShape, itself contained under a NodeGroup
+ /** Builds a set of lines rep contained under a a NodeShape, itself contained under a NodeGroup
* from a set of strokes.
*/
template<class StrokeIterator> NodeGroup *Tesselate(StrokeIterator begin, StrokeIterator end);
diff --git a/source/blender/freestyle/intern/stroke/TextStrokeRenderer.h b/source/blender/freestyle/intern/stroke/TextStrokeRenderer.h
index bbc3b5058a3..09c597791a2 100644
--- a/source/blender/freestyle/intern/stroke/TextStrokeRenderer.h
+++ b/source/blender/freestyle/intern/stroke/TextStrokeRenderer.h
@@ -54,7 +54,7 @@ class TextStrokeRenderer : public StrokeRenderer {
public:
TextStrokeRenderer(const char *iFileName = NULL);
- /*! Renders a stroke rep */
+ /** Renders a stroke rep */
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const;
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const;
diff --git a/source/blender/freestyle/intern/system/BaseObject.h b/source/blender/freestyle/intern/system/BaseObject.h
index 76d30aa74e2..8a19100a5c6 100644
--- a/source/blender/freestyle/intern/system/BaseObject.h
+++ b/source/blender/freestyle/intern/system/BaseObject.h
@@ -39,7 +39,7 @@ class BaseObject {
{
}
- /*! At least makes a release on this.
+ /** At least makes a release on this.
* The BaseObject::destroy method must be explicitly called at the end of any overloaded destroy
*/
virtual int destroy()
@@ -47,13 +47,13 @@ class BaseObject {
return release();
}
- /*! Increments the reference counter */
+ /** Increments the reference counter */
inline int addRef()
{
return ++_ref_counter;
}
- /*! Decrements the reference counter */
+ /** Decrements the reference counter */
inline int release()
{
if (_ref_counter) {
diff --git a/source/blender/freestyle/intern/system/Id.h b/source/blender/freestyle/intern/system/Id.h
index f94e044de29..92ce5f28fb1 100644
--- a/source/blender/freestyle/intern/system/Id.h
+++ b/source/blender/freestyle/intern/system/Id.h
@@ -27,21 +27,21 @@
namespace Freestyle {
-/*! Class used to tag any object by an id.
+/** Class used to tag any object by an id.
* It is made of two unsigned integers.
*/
class Id {
public:
typedef unsigned id_type;
- /*! Default constructor */
+ /** Default constructor */
Id()
{
_first = 0;
_second = 0;
}
- /*! Builds an Id from an integer.
+ /** Builds an Id from an integer.
* The second number is set to 0.
*/
Id(id_type id)
@@ -50,21 +50,21 @@ class Id {
_second = 0;
}
- /*! Builds the Id from the two numbers */
+ /** Builds the Id from the two numbers */
Id(id_type ifirst, id_type isecond)
{
_first = ifirst;
_second = isecond;
}
- /*! Copy constructor */
+ /** Copy constructor */
Id(const Id &iBrother)
{
_first = iBrother._first;
_second = iBrother._second;
}
- /*! Operator= */
+ /** Operator= */
Id &operator=(const Id &iBrother)
{
_first = iBrother._first;
@@ -72,43 +72,43 @@ class Id {
return *this;
}
- /*! Returns the first Id number */
+ /** Returns the first Id number */
id_type getFirst() const
{
return _first;
}
- /*! Returns the second Id number */
+ /** Returns the second Id number */
id_type getSecond() const
{
return _second;
}
- /*! Sets the first number constituting the Id */
+ /** Sets the first number constituting the Id */
void setFirst(id_type first)
{
_first = first;
}
- /*! Sets the second number constituting the Id */
+ /** Sets the second number constituting the Id */
void setSecond(id_type second)
{
_second = second;
}
- /*! Operator== */
+ /** Operator== */
bool operator==(const Id &id) const
{
return ((_first == id._first) && (_second == id._second));
}
- /*! Operator!= */
+ /** Operator!= */
bool operator!=(const Id &id) const
{
return !((*this) == id);
}
- /*! Operator< */
+ /** Operator< */
bool operator<(const Id &id) const
{
if (_first < id._first) {
diff --git a/source/blender/freestyle/intern/system/ProgressBar.h b/source/blender/freestyle/intern/system/ProgressBar.h
index d7b02c48359..6919c624545 100644
--- a/source/blender/freestyle/intern/system/ProgressBar.h
+++ b/source/blender/freestyle/intern/system/ProgressBar.h
@@ -64,7 +64,7 @@ class ProgressBar {
_label = s;
}
- /*! accessors */
+ /** accessors */
inline unsigned int getTotalSteps() const
{
return _numtotalsteps;
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
index 2373451f47c..1a96cf3deea 100644
--- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
+++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
@@ -42,7 +42,7 @@ namespace Freestyle {
using namespace Geometry;
-/*! This class takes as input a WXEdge structure and fills it */
+/** This class takes as input a WXEdge structure and fills it */
class FEdgeXDetector {
public:
FEdgeXDetector()
@@ -69,7 +69,7 @@ class FEdgeXDetector {
{
}
- /*! Process shapes from a WingedEdge containing a list of WShapes */
+ /** Process shapes from a WingedEdge containing a list of WShapes */
virtual void processShapes(WingedEdge &);
// GENERAL STUFF
@@ -86,7 +86,7 @@ class FEdgeXDetector {
virtual void processCreaseShape(WXShape *iWShape);
virtual void ProcessCreaseEdge(WXEdge *iEdge);
- /*! Sets the minimum angle for detecting crease edges
+ /** 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
@@ -121,7 +121,7 @@ class FEdgeXDetector {
virtual void ProcessSuggestiveContourFace(WXFace *iFace);
virtual void postProcessSuggestiveContourShape(WXShape *iShape);
virtual void postProcessSuggestiveContourFace(WXFace *iFace);
- /*! Sets the minimal derivative of the radial curvature for suggestive contours
+ /** Sets the minimal derivative of the radial curvature for suggestive contours
* \param dkr:
* The minimal derivative of the radial curvature
*/
@@ -144,7 +144,7 @@ class FEdgeXDetector {
// EVERYBODY
virtual void buildSmoothEdges(WXShape *iShape);
- /*! Sets the current viewpoint */
+ /** Sets the current viewpoint */
inline void setViewpoint(const Vec3f &ivp)
{
_Viewpoint = ivp;
@@ -186,7 +186,7 @@ class FEdgeXDetector {
}
}
- /*! Sets the radius of the geodesic sphere around each vertex (for the curvature computation)
+ /** Sets the radius of the geodesic sphere around each vertex (for the curvature computation)
* \param r:
* The radius of the sphere expressed as a ratio of the mean edge size
*/
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.h b/source/blender/freestyle/intern/view_map/Functions0D.h
index 0364069b631..7409e1737a4 100644
--- a/source/blender/freestyle/intern/view_map/Functions0D.h
+++ b/source/blender/freestyle/intern/view_map/Functions0D.h
@@ -52,7 +52,7 @@ using namespace Geometry;
//
///////////////////////////////////////////////////////////
-/*! Base class for Unary Functions (functors) working on Interface0DIterator.
+/** 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
@@ -74,27 +74,27 @@ template<class T> class UnaryFunction0D {
T result;
void *py_uf0D;
- /*! The type of the value returned by the functor. */
+ /** The type of the value returned by the functor. */
typedef T ReturnedValueType;
- /*! Default constructor. */
+ /** Default constructor. */
UnaryFunction0D()
{
py_uf0D = NULL;
}
- /*! Destructor; */
+ /** Destructor; */
virtual ~UnaryFunction0D()
{
}
- /*! Returns the string "UnaryFunction0D" */
+ /** Returns the string "UnaryFunction0D" */
virtual string getName() const
{
return "UnaryFunction0D";
}
- /*! The operator ().
+ /** The operator ().
* \param iter:
* An Interface0DIterator pointing onto the point at which we wish to evaluate the function.
* \return the result of the function of type T.
@@ -139,16 +139,16 @@ class ViewShape;
namespace Functions0D {
// GetXF0D
-/*! Returns the X 3D coordinate of an Interface0D. */
+/** Returns the X 3D coordinate of an Interface0D. */
class GetXF0D : public UnaryFunction0D<double> {
public:
- /*! Returns the string "GetXF0D" */
+ /** Returns the string "GetXF0D" */
string getName() const
{
return "GetXF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter)
{
result = iter->getX();
@@ -157,16 +157,16 @@ class GetXF0D : public UnaryFunction0D<double> {
};
// GetYF0D
-/*! Returns the Y 3D coordinate of an Interface0D. */
+/** Returns the Y 3D coordinate of an Interface0D. */
class GetYF0D : public UnaryFunction0D<double> {
public:
- /*! Returns the string "GetYF0D" */
+ /** Returns the string "GetYF0D" */
string getName() const
{
return "GetYF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter)
{
result = iter->getY();
@@ -175,16 +175,16 @@ class GetYF0D : public UnaryFunction0D<double> {
};
// GetZF0D
-/*! Returns the Z 3D coordinate of an Interface0D. */
+/** Returns the Z 3D coordinate of an Interface0D. */
class GetZF0D : public UnaryFunction0D<double> {
public:
- /*! Returns the string "GetZF0D" */
+ /** Returns the string "GetZF0D" */
string getName() const
{
return "GetZF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter)
{
result = iter->getZ();
@@ -193,16 +193,16 @@ class GetZF0D : public UnaryFunction0D<double> {
};
// GetProjectedXF0D
-/*! Returns the X 3D projected coordinate of an Interface0D. */
+/** Returns the X 3D projected coordinate of an Interface0D. */
class GetProjectedXF0D : public UnaryFunction0D<double> {
public:
- /*! Returns the string "GetProjectedXF0D" */
+ /** Returns the string "GetProjectedXF0D" */
string getName() const
{
return "GetProjectedXF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter)
{
result = iter->getProjectedX();
@@ -211,16 +211,16 @@ class GetProjectedXF0D : public UnaryFunction0D<double> {
};
// GetProjectedYF0D
-/*! Returns the Y projected 3D coordinate of an Interface0D. */
+/** Returns the Y projected 3D coordinate of an Interface0D. */
class GetProjectedYF0D : public UnaryFunction0D<double> {
public:
- /*! Returns the string "GetProjectedYF0D" */
+ /** Returns the string "GetProjectedYF0D" */
string getName() const
{
return "GetProjectedYF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter)
{
result = iter->getProjectedY();
@@ -229,16 +229,16 @@ class GetProjectedYF0D : public UnaryFunction0D<double> {
};
// GetProjectedZF0D
-/*! Returns the Z projected 3D coordinate of an Interface0D. */
+/** Returns the Z projected 3D coordinate of an Interface0D. */
class GetProjectedZF0D : public UnaryFunction0D<double> {
public:
- /*! Returns the string "GetProjectedZF0D" */
+ /** Returns the string "GetProjectedZF0D" */
string getName() const
{
return "GetProjectedZF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter)
{
result = iter->getProjectedZ();
@@ -247,16 +247,16 @@ class GetProjectedZF0D : public UnaryFunction0D<double> {
};
// GetCurvilinearAbscissaF0D
-/*! Returns the curvilinear abscissa of an Interface0D in the context of its 1D element. */
+/** Returns the curvilinear abscissa of an Interface0D in the context of its 1D element. */
class GetCurvilinearAbscissaF0D : public UnaryFunction0D<float> {
public:
- /*! Returns the string "GetCurvilinearAbscissaF0D" */
+ /** Returns the string "GetCurvilinearAbscissaF0D" */
string getName() const
{
return "GetCurvilinearAbscissaF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter)
{
result = iter.t();
@@ -265,16 +265,16 @@ class GetCurvilinearAbscissaF0D : public UnaryFunction0D<float> {
};
// GetParameterF0D
-/*! Returns the parameter of an Interface0D in the context of its 1D element. */
+/** Returns the parameter of an Interface0D in the context of its 1D element. */
class GetParameterF0D : public UnaryFunction0D<float> {
public:
- /*! Returns the string "GetCurvilinearAbscissaF0D" */
+ /** Returns the string "GetCurvilinearAbscissaF0D" */
string getName() const
{
return "GetParameterF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter)
{
result = iter.u();
@@ -283,93 +283,93 @@ class GetParameterF0D : public UnaryFunction0D<float> {
};
// VertexOrientation2DF0D
-/*! Returns a Vec2r giving the 2D oriented tangent to the 1D element to which the
+/** 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:
- /*! Returns the string "VertexOrientation2DF0D" */
+ /** Returns the string "VertexOrientation2DF0D" */
string getName() const
{
return "VertexOrientation2DF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// VertexOrientation3DF0D
-/*! Returns a Vec3r giving the 3D oriented tangent to the 1D element to which the
+/** 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:
- /*! Returns the string "VertexOrientation3DF0D" */
+ /** Returns the string "VertexOrientation3DF0D" */
string getName() const
{
return "VertexOrientation3DF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// Curvature2DAngleF0D
-/*! Returns a real giving the 2D curvature (as an angle) of the 1D element to which the
+/** 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:
- /*! Returns the string "Curvature2DAngleF0D" */
+ /** Returns the string "Curvature2DAngleF0D" */
string getName() const
{
return "Curvature2DAngleF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// ZDiscontinuity
-/*! Returns a real giving the distance between and Interface0D and the shape that lies behind
+/** 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:
- /*! Returns the string "ZDiscontinuityF0D" */
+ /** Returns the string "ZDiscontinuityF0D" */
string getName() const
{
return "ZDiscontinuityF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// Normal2DF0D
-/*! Returns a Vec2f giving the normalized 2D normal to the 1D element to which the
+/** 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:
- /*! Returns the string "Normal2DF0D" */
+ /** Returns the string "Normal2DF0D" */
string getName() const
{
return "Normal2DF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// MaterialF0D
-/*! Returns the material of the object evaluated at the Interface0D.
+/** 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
@@ -379,18 +379,18 @@ class Normal2DF0D : public UnaryFunction0D<Vec2f> {
*/
class MaterialF0D : public UnaryFunction0D<FrsMaterial> {
public:
- /*! Returns the string "MaterialF0D" */
+ /** Returns the string "MaterialF0D" */
string getName() const
{
return "MaterialF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// ShapeIdF0D
-/*! Returns the Id of the Shape the Interface0D belongs to.
+/** 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
@@ -399,18 +399,18 @@ class MaterialF0D : public UnaryFunction0D<FrsMaterial> {
*/
class ShapeIdF0D : public UnaryFunction0D<Id> {
public:
- /*! Returns the string "ShapeIdF0D" */
+ /** Returns the string "ShapeIdF0D" */
string getName() const
{
return "ShapeIdF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// QiF0D
-/*! Returns the quantitative invisibility of this Interface0D.
+/** 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
@@ -419,69 +419,69 @@ class ShapeIdF0D : public UnaryFunction0D<Id> {
*/
class QuantitativeInvisibilityF0D : public UnaryFunction0D<unsigned int> {
public:
- /*! Returns the string "QuantitativeInvisibilityF0D" */
+ /** Returns the string "QuantitativeInvisibilityF0D" */
string getName() const
{
return "QuantitativeInvisibilityF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// CurveNatureF0D
-/*! Returns the Nature::EdgeNature of the 1D element the Interface0DIterator& belongs to. */
+/** Returns the Nature::EdgeNature of the 1D element the Interface0DIterator& belongs to. */
class CurveNatureF0D : public UnaryFunction0D<Nature::EdgeNature> {
public:
- /*! Returns the string "QuantitativeInvisibilityF0D" */
+ /** Returns the string "QuantitativeInvisibilityF0D" */
string getName() const
{
return "CurveNatureF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// GetShapeF0D
-/*! Returns the ViewShape* containing the Interface0D */
+/** Returns the ViewShape* containing the Interface0D */
class GetShapeF0D : public UnaryFunction0D<ViewShape *> {
public:
- /*! Returns the string "GetShapeF0D" */
+ /** Returns the string "GetShapeF0D" */
string getName() const
{
return "GetShapeF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// GetOccludersF0D
-/*! Returns a vector containing the ViewShape* occluding the Interface0D */
+/** Returns a vector containing the ViewShape* occluding the Interface0D */
class GetOccludersF0D : public UnaryFunction0D<std::vector<ViewShape *>> {
public:
- /*! Returns the string "GetOccludersF0D" */
+ /** Returns the string "GetOccludersF0D" */
string getName() const
{
return "GetOccludersF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
// GetOccludeeF0D
-/*! Returns the ViewShape* "occluded" by the Interface0D */
+/** Returns the ViewShape* "occluded" by the Interface0D */
class GetOccludeeF0D : public UnaryFunction0D<ViewShape *> {
public:
- /*! Returns the string "GetOccludeeF0D" */
+ /** Returns the string "GetOccludeeF0D" */
string getName() const
{
return "GetOccludeeF0D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface0DIterator &iter);
};
diff --git a/source/blender/freestyle/intern/view_map/Functions1D.h b/source/blender/freestyle/intern/view_map/Functions1D.h
index 9cf5527ee19..e45bc459bf0 100644
--- a/source/blender/freestyle/intern/view_map/Functions1D.h
+++ b/source/blender/freestyle/intern/view_map/Functions1D.h
@@ -42,7 +42,7 @@ namespace Freestyle {
//
///////////////////////////////////////////////////////////
-/*! Base class for Unary Functions (functors) working on Interface1D.
+/** 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
@@ -61,16 +61,16 @@ template<class T> class UnaryFunction1D {
T result;
void *py_uf1D;
- /*! The type of the value returned by the functor. */
+ /** The type of the value returned by the functor. */
typedef T ReturnedValueType;
- /*! Default constructor */
+ /** Default constructor */
UnaryFunction1D()
{
_integration = MEAN;
}
- /*! Builds a UnaryFunction1D from an integration type.
+ /** 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.
@@ -81,18 +81,18 @@ template<class T> class UnaryFunction1D {
_integration = iType;
}
- /*! destructor. */
+ /** destructor. */
virtual ~UnaryFunction1D()
{
}
- /*! returns the string "UnaryFunction1D". */
+ /** returns the string "UnaryFunction1D". */
virtual string getName() const
{
return "UnaryFunction1D";
}
- /*! The operator ().
+ /** The operator ().
* \param inter:
* The Interface1D on which we wish to evaluate the function.
* \return the result of the function of type T.
@@ -103,13 +103,13 @@ template<class T> class UnaryFunction1D {
return Director_BPy_UnaryFunction1D___call__(this, py_uf1D, inter);
}
- /*! Sets the integration method */
+ /** Sets the integration method */
void setIntegrationType(IntegrationType integration)
{
_integration = integration;
}
- /*! Returns the integration method. */
+ /** Returns the integration method. */
IntegrationType getIntegrationType() const
{
return _integration;
@@ -178,13 +178,13 @@ class UnaryFunction1D_void {
namespace Functions1D {
// GetXF1D
-/*! Returns the X 3D coordinate of an Interface1D. */
+/** Returns the X 3D coordinate of an Interface1D. */
class GetXF1D : public UnaryFunction1D<double> {
private:
Functions0D::GetXF0D _func;
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -192,24 +192,24 @@ class GetXF1D : public UnaryFunction1D<double> {
{
}
- /*! Returns the string "GetXF1D" */
+ /** Returns the string "GetXF1D" */
string getName() const
{
return "GetXF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// GetYF1D
-/*! Returns the Y 3D coordinate of an Interface1D. */
+/** Returns the Y 3D coordinate of an Interface1D. */
class GetYF1D : public UnaryFunction1D<double> {
private:
Functions0D::GetYF0D _func;
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -217,24 +217,24 @@ class GetYF1D : public UnaryFunction1D<double> {
{
}
- /*! Returns the string "GetYF1D" */
+ /** Returns the string "GetYF1D" */
string getName() const
{
return "GetYF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// GetZF1D
-/*! Returns the Z 3D coordinate of an Interface1D. */
+/** Returns the Z 3D coordinate of an Interface1D. */
class GetZF1D : public UnaryFunction1D<double> {
private:
Functions0D::GetZF0D _func;
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -242,24 +242,24 @@ class GetZF1D : public UnaryFunction1D<double> {
{
}
- /*! Returns the string "GetZF1D" */
+ /** Returns the string "GetZF1D" */
string getName() const
{
return "GetZF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// GetProjectedXF1D
-/*! Returns the projected X 3D coordinate of an Interface1D. */
+/** Returns the projected X 3D coordinate of an Interface1D. */
class GetProjectedXF1D : public UnaryFunction1D<double> {
private:
Functions0D::GetProjectedXF0D _func;
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -267,24 +267,24 @@ class GetProjectedXF1D : public UnaryFunction1D<double> {
{
}
- /*! Returns the string "GetProjectedXF1D" */
+ /** Returns the string "GetProjectedXF1D" */
string getName() const
{
return "GetProjectedXF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// GetProjectedYF1D
-/*! Returns the projected Y 3D coordinate of an Interface1D. */
+/** Returns the projected Y 3D coordinate of an Interface1D. */
class GetProjectedYF1D : public UnaryFunction1D<double> {
private:
Functions0D::GetProjectedYF0D _func;
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -292,24 +292,24 @@ class GetProjectedYF1D : public UnaryFunction1D<double> {
{
}
- /*! Returns the string "GetProjectedYF1D" */
+ /** Returns the string "GetProjectedYF1D" */
string getName() const
{
return "GetProjectedYF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// GetProjectedZF1D
-/*! Returns the projected Z 3D coordinate of an Interface1D. */
+/** Returns the projected Z 3D coordinate of an Interface1D. */
class GetProjectedZF1D : public UnaryFunction1D<double> {
private:
Functions0D::GetProjectedZF0D _func;
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -317,24 +317,24 @@ class GetProjectedZF1D : public UnaryFunction1D<double> {
{
}
- /*! Returns the string "GetProjectedZF1D" */
+ /** Returns the string "GetProjectedZF1D" */
string getName() const
{
return "GetProjectedZF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// Orientation2DF1D
-/*! Returns the 2D orientation as a Vec2f*/
+/** Returns the 2D orientation as a #Vec2f. */
class Orientation2DF1D : public UnaryFunction1D<Vec2f> {
private:
Functions0D::VertexOrientation2DF0D _func;
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -342,24 +342,24 @@ class Orientation2DF1D : public UnaryFunction1D<Vec2f> {
{
}
- /*! Returns the string "Orientation2DF1D" */
+ /** Returns the string "Orientation2DF1D" */
string getName() const
{
return "Orientation2DF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// Orientation3DF1D
-/*! Returns the 3D orientation as a Vec3f. */
+/** Returns the 3D orientation as a Vec3f. */
class Orientation3DF1D : public UnaryFunction1D<Vec3f> {
private:
Functions0D::VertexOrientation3DF0D _func;
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -367,18 +367,18 @@ class Orientation3DF1D : public UnaryFunction1D<Vec3f> {
{
}
- /*! Returns the string "Orientation3DF1D" */
+ /** Returns the string "Orientation3DF1D" */
string getName() const
{
return "Orientation3DF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// ZDiscontinuityF1D
-/*! Returns a real giving the distance between and Interface1D and the shape that lies behind
+/** 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.
@@ -388,7 +388,7 @@ class ZDiscontinuityF1D : public UnaryFunction1D<double> {
Functions0D::ZDiscontinuityF0D _func;
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -396,18 +396,18 @@ class ZDiscontinuityF1D : public UnaryFunction1D<double> {
{
}
- /*! Returns the string "ZDiscontinuityF1D" */
+ /** Returns the string "ZDiscontinuityF1D" */
string getName() const
{
return "ZDiscontinuityF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// QuantitativeInvisibilityF1D
-/*! Returns the Quantitative Invisibility of an Interface1D element.
+/** 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.
@@ -417,7 +417,7 @@ class QuantitativeInvisibilityF1D : public UnaryFunction1D<unsigned> {
Functions0D::QuantitativeInvisibilityF0D _func;
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -425,18 +425,18 @@ class QuantitativeInvisibilityF1D : public UnaryFunction1D<unsigned> {
{
}
- /*! Returns the string "QuantitativeInvisibilityF1D" */
+ /** Returns the string "QuantitativeInvisibilityF1D" */
string getName() const
{
return "QuantitativeInvisibilityF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// CurveNatureF1D
-/*! Returns the nature of the Interface1D (silhouette, ridge, crease...).
+/** 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,
@@ -447,7 +447,7 @@ class CurveNatureF1D : public UnaryFunction1D<Nature::EdgeNature> {
Functions0D::CurveNatureF0D _func;
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -455,63 +455,63 @@ class CurveNatureF1D : public UnaryFunction1D<Nature::EdgeNature> {
{
}
- /*! Returns the string "CurveNatureF1D" */
+ /** Returns the string "CurveNatureF1D" */
string getName() const
{
return "CurveNatureF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// TimeStampF1D
-/*! Returns the time stamp of the Interface1D. */
+/** Returns the time stamp of the Interface1D. */
class TimeStampF1D : public UnaryFunction1D_void {
public:
- /*! Returns the string "TimeStampF1D" */
+ /** Returns the string "TimeStampF1D" */
string getName() const
{
return "TimeStampF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// IncrementChainingTimeStampF1D
-/*! Increments the chaining time stamp of the Interface1D. */
+/** Increments the chaining time stamp of the Interface1D. */
class IncrementChainingTimeStampF1D : public UnaryFunction1D_void {
public:
- /*! Returns the string "IncrementChainingTimeStampF1D" */
+ /** Returns the string "IncrementChainingTimeStampF1D" */
string getName() const
{
return "IncrementChainingTimeStampF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// ChainingTimeStampF1D
-/*! Sets the chaining time stamp of the Interface1D. */
+/** Sets the chaining time stamp of the Interface1D. */
class ChainingTimeStampF1D : public UnaryFunction1D_void {
public:
- /*! Returns the string "ChainingTimeStampF1D" */
+ /** Returns the string "ChainingTimeStampF1D" */
string getName() const
{
return "ChainingTimeStampF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// Curvature2DAngleF1D
-/*! Returns the 2D curvature as an angle for an Interface1D. */
+/** Returns the 2D curvature as an angle for an Interface1D. */
class Curvature2DAngleF1D : public UnaryFunction1D<double> {
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -519,13 +519,13 @@ class Curvature2DAngleF1D : public UnaryFunction1D<double> {
{
}
- /*! Returns the string "Curvature2DAngleF1D" */
+ /** Returns the string "Curvature2DAngleF1D" */
string getName() const
{
return "Curvature2DAngleF1D";
}
- /*! the () operator.*/
+ /** the () operator. */
int operator()(Interface1D &inter)
{
result = integrate(_fun, inter.verticesBegin(), inter.verticesEnd(), _integration);
@@ -537,10 +537,10 @@ class Curvature2DAngleF1D : public UnaryFunction1D<double> {
};
// Normal2DF1D
-/*! Returns the 2D normal for an interface 1D. */
+/** Returns the 2D normal for an interface 1D. */
class Normal2DF1D : public UnaryFunction1D<Vec2f> {
public:
- /*! Builds the functor.
+ /** Builds the functor.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
@@ -548,13 +548,13 @@ class Normal2DF1D : public UnaryFunction1D<Vec2f> {
{
}
- /*! Returns the string "Normal2DF1D" */
+ /** Returns the string "Normal2DF1D" */
string getName() const
{
return "Normal2DF1D";
}
- /*! the () operator.*/
+ /** the () operator. */
int operator()(Interface1D &inter)
{
result = integrate(_fun, inter.verticesBegin(), inter.verticesEnd(), _integration);
@@ -566,59 +566,59 @@ class Normal2DF1D : public UnaryFunction1D<Vec2f> {
};
// GetShapeF1D
-/*! Returns list of shapes covered by this Interface1D. */
+/** Returns list of shapes covered by this Interface1D. */
class GetShapeF1D : public UnaryFunction1D<std::vector<ViewShape *>> {
public:
- /*! Builds the functor. */
+ /** Builds the functor. */
GetShapeF1D() : UnaryFunction1D<std::vector<ViewShape *>>()
{
}
- /*! Returns the string "GetShapeF1D" */
+ /** Returns the string "GetShapeF1D" */
string getName() const
{
return "GetShapeF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// GetOccludersF1D
-/*! Returns list of occluding shapes covered by this Interface1D. */
+/** Returns list of occluding shapes covered by this Interface1D. */
class GetOccludersF1D : public UnaryFunction1D<std::vector<ViewShape *>> {
public:
- /*! Builds the functor. */
+ /** Builds the functor. */
GetOccludersF1D() : UnaryFunction1D<std::vector<ViewShape *>>()
{
}
- /*! Returns the string "GetOccludersF1D" */
+ /** Returns the string "GetOccludersF1D" */
string getName() const
{
return "GetOccludersF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
// GetOccludeeF1D
-/*! Returns list of occluded shapes covered by this Interface1D. */
+/** Returns list of occluded shapes covered by this Interface1D. */
class GetOccludeeF1D : public UnaryFunction1D<std::vector<ViewShape *>> {
public:
- /*! Builds the functor. */
+ /** Builds the functor. */
GetOccludeeF1D() : UnaryFunction1D<std::vector<ViewShape *>>()
{
}
- /*! Returns the string "GetOccludeeF1D" */
+ /** Returns the string "GetOccludeeF1D" */
string getName() const
{
return "GetOccludeeF1D";
}
- /*! the () operator. */
+ /** the () operator. */
int operator()(Interface1D &inter);
};
diff --git a/source/blender/freestyle/intern/view_map/Interface0D.h b/source/blender/freestyle/intern/view_map/Interface0D.h
index 6b4682cc862..065319578e5 100644
--- a/source/blender/freestyle/intern/view_map/Interface0D.h
+++ b/source/blender/freestyle/intern/view_map/Interface0D.h
@@ -51,18 +51,18 @@ class ViewVertex;
class NonTVertex;
class TVertex;
-/*! Base class for any 0D element. */
+/** Base class for any 0D element. */
class Interface0D {
public:
- /*! Default constructor */
+ /** Default constructor */
Interface0D()
{
}
- /*! Destructor */
+ /** Destructor */
virtual ~Interface0D(){};
- /*! Returns the string "Interface0D". */
+ /** Returns the string "Interface0D". */
virtual string getExactTypeName() const
{
return "Interface0D";
@@ -70,50 +70,50 @@ class Interface0D {
// Data access methods
- /*! Returns the 3D x coordinate of the point. */
+ /** Returns the 3D x coordinate of the point. */
virtual real getX() const;
- /*! Returns the 3D y coordinate of the point. */
+ /** Returns the 3D y coordinate of the point. */
virtual real getY() const;
- /*! Returns the 3D z coordinate of the point. */
+ /** Returns the 3D z coordinate of the point. */
virtual real getZ() const;
- /*! Returns the 3D point. */
+ /** Returns the 3D point. */
virtual Geometry::Vec3r getPoint3D() const;
- /*! Returns the 2D x coordinate of the point. */
+ /** Returns the 2D x coordinate of the point. */
virtual real getProjectedX() const;
- /*! Returns the 2D y coordinate of the point. */
+ /** Returns the 2D y coordinate of the point. */
virtual real getProjectedY() const;
- /*! Returns the 2D z coordinate of the point. */
+ /** Returns the 2D z coordinate of the point. */
virtual real getProjectedZ() const;
- /*! Returns the 2D point. */
+ /** 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. */
+ /** Returns the Id of the point. */
virtual Id getId() const;
- /*! Returns the nature of the point. */
+ /** Returns the nature of the point. */
virtual Nature::VertexNature getNature() const;
- /*! Cast the Interface0D in SVertex if it can be. */
+ /** Cast the Interface0D in SVertex if it can be. */
virtual SVertex *castToSVertex();
- /*! Cast the Interface0D in ViewVertex if it can be. */
+ /** Cast the Interface0D in ViewVertex if it can be. */
virtual ViewVertex *castToViewVertex();
- /*! Cast the Interface0D in NonTVertex if it can be. */
+ /** Cast the Interface0D in NonTVertex if it can be. */
virtual NonTVertex *castToNonTVertex();
- /*! Cast the Interface0D in TVertex if it can be. */
+ /** Cast the Interface0D in TVertex if it can be. */
virtual TVertex *castToTVertex();
#ifdef WITH_CXX_GUARDEDALLOC
@@ -159,10 +159,10 @@ class Interface0DIteratorNested : public Iterator {
return !(*this == it);
}
- /*! Returns the curvilinear abscissa */
+ /** Returns the curvilinear abscissa */
virtual float t() const = 0;
- /*! Returns the point parameter 0<u<1 */
+ /** Returns the point parameter 0<u<1 */
virtual float u() const = 0;
virtual Interface0DIteratorNested *copy() const = 0;
@@ -173,7 +173,7 @@ class Interface0DIteratorNested : public Iterator {
//
//////////////////////////////////////////////////
-/*! Class defining an iterator over Interface0D elements.
+/** 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.
@@ -186,13 +186,13 @@ class Interface0DIterator : public Iterator {
_iterator = it;
}
- /*! Copy constructor */
+ /** Copy constructor */
Interface0DIterator(const Interface0DIterator &it)
{
_iterator = it._iterator->copy();
}
- /*! Destructor */
+ /** Destructor */
virtual ~Interface0DIterator()
{
if (_iterator) {
@@ -200,7 +200,7 @@ class Interface0DIterator : public Iterator {
}
}
- /*! Operator =
+ /** 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.
@@ -214,7 +214,7 @@ class Interface0DIterator : public Iterator {
return *this;
}
- /*! Returns the string "Interface0DIterator". */
+ /** Returns the string "Interface0DIterator". */
virtual string getExactTypeName() const
{
if (!_iterator) {
@@ -225,7 +225,7 @@ class Interface0DIterator : public Iterator {
// FIXME test it != 0 (exceptions ?)
- /*! Returns a reference to the pointed Interface0D.
+ /** Returns a reference to the pointed Interface0D.
* In the scripting language, you must call "getObject()" instead using this operator.
*/
Interface0D &operator*()
@@ -233,7 +233,7 @@ class Interface0DIterator : public Iterator {
return _iterator->operator*();
}
- /*! Returns a pointer to the pointed Interface0D.
+ /** Returns a pointer to the pointed Interface0D.
* Can't be called in the scripting language.
*/
Interface0D *operator->()
@@ -241,14 +241,14 @@ class Interface0DIterator : public Iterator {
return &(operator*());
}
- /*! Increments. In the scripting language, call "increment()". */
+ /** Increments. In the scripting language, call "increment()". */
Interface0DIterator &operator++()
{
_iterator->increment();
return *this;
}
- /*! Increments. In the scripting language, call "increment()". */
+ /** Increments. In the scripting language, call "increment()". */
Interface0DIterator operator++(int)
{
Interface0DIterator ret(*this);
@@ -256,14 +256,14 @@ class Interface0DIterator : public Iterator {
return ret;
}
- /*! Decrements. In the scripting language, call "decrement()". */
+ /** Decrements. In the scripting language, call "decrement()". */
Interface0DIterator &operator--()
{
_iterator->decrement();
return *this;
}
- /*! Decrements. In the scripting language, call "decrement()". */
+ /** Decrements. In the scripting language, call "decrement()". */
Interface0DIterator operator--(int)
{
Interface0DIterator ret(*this);
@@ -271,19 +271,19 @@ class Interface0DIterator : public Iterator {
return ret;
}
- /*! Increments. */
+ /** Increments. */
virtual int increment()
{
return _iterator->increment();
}
- /*! Decrements. */
+ /** Decrements. */
virtual int decrement()
{
return _iterator->decrement();
}
- /*! Returns true if the pointed Interface0D is the first of the 1D element containing the points
+ /** 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
@@ -291,14 +291,14 @@ class Interface0DIterator : public Iterator {
return _iterator->isBegin();
}
- /*! Returns true if the pointed Interface0D is after the after the last point of the 1D element
+ /** 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();
}
- /*! Returns true when the iterator is pointing to the final valid element. */
+ /** Returns true when the iterator is pointing to the final valid element. */
virtual bool atLast() const
{
if (_iterator->isEnd()) {
@@ -311,25 +311,25 @@ class Interface0DIterator : public Iterator {
return result;
}
- /*! operator == . */
+ /** operator == . */
bool operator==(const Interface0DIterator &it) const
{
return _iterator->operator==(*(it._iterator));
}
- /*! operator != . */
+ /** operator != . */
bool operator!=(const Interface0DIterator &it) const
{
return !(*this == it);
}
- /*! Returns the curvilinear abscissa. */
+ /** Returns the curvilinear abscissa. */
inline float t() const
{
return _iterator->t();
}
- /*! Returns the point parameter in the curve 0<=u<=1. */
+ /** Returns the point parameter in the curve 0<=u<=1. */
inline float u() const
{
return _iterator->u();
diff --git a/source/blender/freestyle/intern/view_map/Interface1D.h b/source/blender/freestyle/intern/view_map/Interface1D.h
index 778deb20a60..75ad71a373d 100644
--- a/source/blender/freestyle/intern/view_map/Interface1D.h
+++ b/source/blender/freestyle/intern/view_map/Interface1D.h
@@ -41,23 +41,23 @@ using namespace std;
namespace Freestyle {
// Integration method
-/*! The different integration methods that can be invoked to integrate into a single value the set
+/** 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.
+/** 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:
@@ -127,19 +127,19 @@ T integrate(UnaryFunction0D<T> &fun,
//
//////////////////////////////////////////////////
-/*! Base class for any 1D element. */
+/** Base class for any 1D element. */
class Interface1D {
public:
- /*! Default constructor */
+ /** Default constructor */
Interface1D()
{
_timeStamp = 0;
}
- /*! Destructor */
+ /** Destructor */
virtual ~Interface1D(){};
- /*! Returns the string "Interface1D". */
+ /** Returns the string "Interface1D". */
virtual string getExactTypeName() const
{
return "Interface1D";
@@ -147,13 +147,13 @@ class Interface1D {
// Iterator access
- /*! Returns an iterator over the Interface1D vertices, pointing to the first vertex. */
+ /** Returns an iterator over the Interface1D vertices, pointing to the first vertex. */
virtual Interface0DIterator verticesBegin();
- /*! Returns an iterator over the Interface1D vertices, pointing after the last vertex. */
+ /** 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
+ /** 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.
*
@@ -161,7 +161,7 @@ class Interface1D {
*/
virtual Interface0DIterator pointsBegin(float t = 0.0f);
- /*! Returns an iterator over the Interface1D points, pointing after the last point. The
+ /** 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.
*
@@ -171,23 +171,23 @@ class Interface1D {
// Data access methods
- /*! Returns the 2D length of the 1D element. */
+ /** Returns the 2D length of the 1D element. */
virtual real getLength2D() const;
- /*! Returns the Id of the 1D element. */
+ /** Returns the Id of the 1D element. */
virtual Id getId() const;
// FIXME: ce truc n'a rien a faire la...(c une requete complexe qui doit etre ds les Function1D)
- /*! Returns the nature of the 1D element. */
+ /** Returns the nature of the 1D element. */
virtual Nature::EdgeNature getNature() const;
- /*! Returns the time stamp of the 1D element. Mainly used for selection. */
+ /** Returns the time stamp of the 1D element. Mainly used for selection. */
virtual unsigned getTimeStamp() const
{
return _timeStamp;
}
- /*! Sets the time stamp for the 1D element. */
+ /** Sets the time stamp for the 1D element. */
inline void setTimeStamp(unsigned iTimeStamp)
{
_timeStamp = iTimeStamp;
diff --git a/source/blender/freestyle/intern/view_map/Silhouette.h b/source/blender/freestyle/intern/view_map/Silhouette.h
index 5a59f488b51..0ec9144595c 100644
--- a/source/blender/freestyle/intern/view_map/Silhouette.h
+++ b/source/blender/freestyle/intern/view_map/Silhouette.h
@@ -66,86 +66,86 @@ class FEdge;
class ViewVertex;
class SShape;
-/*! Class to define a vertex of the embedding. */
+/** Class to define a vertex of the embedding. */
class SVertex : public Interface0D {
public: // Implementation of Interface0D
- /*! Returns the string "SVertex" .*/
+ /** Returns the string "SVertex". */
virtual string getExactTypeName() const
{
return "SVertex";
}
// Data access methods
- /*! Returns the 3D x coordinate of the vertex .*/
+ /** Returns the 3D x coordinate of the vertex. */
virtual real getX() const
{
return _Point3D.x();
}
- /*! Returns the 3D y coordinate of the vertex .*/
+ /** Returns the 3D y coordinate of the vertex. */
virtual real getY() const
{
return _Point3D.y();
}
- /*! Returns the 3D z coordinate of the vertex .*/
+ /** Returns the 3D z coordinate of the vertex. */
virtual real getZ() const
{
return _Point3D.z();
}
- /*! Returns the 3D point. */
+ /** Returns the 3D point. */
virtual Vec3r getPoint3D() const
{
return _Point3D;
}
- /*! Returns the projected 3D x coordinate of the vertex .*/
+ /** Returns the projected 3D x coordinate of the vertex. */
virtual real getProjectedX() const
{
return _Point2D.x();
}
- /*! Returns the projected 3D y coordinate of the vertex .*/
+ /** Returns the projected 3D y coordinate of the vertex. */
virtual real getProjectedY() const
{
return _Point2D.y();
}
- /*! Returns the projected 3D z coordinate of the vertex .*/
+ /** Returns the projected 3D z coordinate of the vertex. */
virtual real getProjectedZ() const
{
return _Point2D.z();
}
- /*! Returns the 2D point. */
+ /** Returns the 2D point. */
virtual Vec2r getPoint2D() const
{
return Vec2r(_Point2D.x(), _Point2D.y());
}
- /*! Returns the FEdge that lies between this Svertex and the Interface0D given as argument. */
+ /** Returns the FEdge that lies between this Svertex and the Interface0D given as argument. */
virtual FEdge *getFEdge(Interface0D &);
- /*! Returns the Id of the vertex .*/
+ /** Returns the Id of the vertex. */
virtual Id getId() const
{
return _Id;
}
- /*! Returns the nature of the vertex .*/
+ /** Returns the nature of the vertex. */
virtual Nature::VertexNature getNature() const;
- /*! Cast the Interface0D in SVertex if it can be. */
+ /** Cast the Interface0D in SVertex if it can be. */
virtual SVertex *castToSVertex();
- /*! Cast the Interface0D in ViewVertex if it can be. */
+ /** Cast the Interface0D in ViewVertex if it can be. */
virtual ViewVertex *castToViewVertex();
- /*! Cast the Interface0D in NonTVertex if it can be. */
+ /** Cast the Interface0D in NonTVertex if it can be. */
virtual NonTVertex *castToNonTVertex();
- /*! Cast the Interface0D in TVertex if it can be. */
+ /** Cast the Interface0D in TVertex if it can be. */
virtual TVertex *castToTVertex();
public:
@@ -166,12 +166,12 @@ class SVertex : public Interface0D {
CurvatureInfo *_curvature_info;
public:
- /*! A field that can be used by the user to store any data.
+ /** A field that can be used by the user to store any data.
* This field must be reset afterwards using ResetUserData().
*/
void *userdata;
- /*! Default constructor.*/
+ /** Default constructor. */
inline SVertex()
{
_Id = 0;
@@ -181,7 +181,7 @@ class SVertex : public Interface0D {
_curvature_info = 0;
}
- /*! Builds a SVertex from 3D coordinates and an Id. */
+ /** Builds a SVertex from 3D coordinates and an Id. */
inline SVertex(const Vec3r &iPoint3D, const Id &id)
{
_Point3D = iPoint3D;
@@ -192,7 +192,7 @@ class SVertex : public Interface0D {
_curvature_info = 0;
}
- /*! Copy constructor. */
+ /** Copy constructor. */
inline SVertex(SVertex &iBrother)
{
_Id = iBrother._Id;
@@ -212,7 +212,7 @@ class SVertex : public Interface0D {
userdata = 0;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~SVertex()
{
if (_curvature_info) {
@@ -220,14 +220,14 @@ class SVertex : public Interface0D {
}
}
- /*! Cloning method. */
+ /** Cloning method. */
virtual SVertex *duplicate()
{
SVertex *clone = new SVertex(*this);
return clone;
}
- /*! operator == */
+ /** operator == */
virtual bool operator==(const SVertex &iBrother)
{
return ((_Point2D == iBrother._Point2D) && (_Point3D == iBrother._Point3D));
@@ -244,7 +244,7 @@ class SVertex : public Interface0D {
return _Point2D;
}
- /*! Returns the set of normals for this Vertex.
+ /** Returns the set of normals for this Vertex.
* In a smooth surface, a vertex has exactly one normal.
* In a sharp surface, a vertex can have any number of normals.
*/
@@ -253,7 +253,7 @@ class SVertex : public Interface0D {
return _Normals;
}
- /*! Returns the number of different normals for this vertex. */
+ /** Returns the number of different normals for this vertex. */
inline unsigned normalsSize() const
{
return _Normals.size();
@@ -284,7 +284,7 @@ class SVertex : public Interface0D {
return _Point2D[2];
}
- /*! If this SVertex is also a ViewVertex, this method returns a pointer onto this ViewVertex.
+ /** If this SVertex is also a ViewVertex, this method returns a pointer onto this ViewVertex.
* 0 is returned otherwise.
*/
inline ViewVertex *viewvertex()
@@ -292,20 +292,20 @@ class SVertex : public Interface0D {
return _pViewVertex;
}
- /*! modifiers */
- /*! Sets the 3D coordinates of the SVertex. */
+ /** modifiers */
+ /** Sets the 3D coordinates of the SVertex. */
inline void setPoint3D(const Vec3r &iPoint3D)
{
_Point3D = iPoint3D;
}
- /*! Sets the 3D projected coordinates of the SVertex. */
+ /** Sets the 3D projected coordinates of the SVertex. */
inline void setPoint2D(const Vec3r &iPoint2D)
{
_Point2D = iPoint2D;
}
- /*! Adds a normal to the Svertex's set of normals. If the same normal is already in the set,
+ /** 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)
{
@@ -326,7 +326,7 @@ class SVertex : public Interface0D {
}
#if 0
- /* Fredo's normal and curvature*/
+ /* Fredo's normal and curvature. */
void setCurvatureFredo(real c)
{
_curvatureFredo = c;
@@ -348,7 +348,7 @@ class SVertex : public Interface0D {
}
#endif
- /*! Sets the Id */
+ /** Sets the Id */
inline void setId(const Id &id)
{
_Id = id;
@@ -369,13 +369,13 @@ class SVertex : public Interface0D {
_pViewVertex = iViewVertex;
}
- /*! Add an FEdge to the list of edges emanating from this SVertex. */
+ /** Add an FEdge to the list of edges emanating from this SVertex. */
inline void AddFEdge(FEdge *iFEdge)
{
_FEdges.push_back(iFEdge);
}
- /*! Remove an FEdge from the list of edges emanating from this SVertex. */
+ /** Remove an FEdge from the list of edges emanating from this SVertex. */
inline void RemoveFEdge(FEdge *iFEdge)
{
for (vector<FEdge *>::iterator fe = _FEdges.begin(), fend = _FEdges.end(); fe != fend; fe++) {
@@ -447,7 +447,7 @@ class SVertex : public Interface0D {
inline Vec3r orientation2d() const;
inline Vec3r orientation3d() const;
inline Vec3r curvature2d_as_vector() const;
- /*! angle in radians */
+ /** angle in radians */
inline real curvature2d_as_angle() const;
#endif
@@ -466,7 +466,7 @@ class SVertex : public Interface0D {
class ViewEdge;
-/*! Base Class for feature edges.
+/** 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
@@ -476,7 +476,7 @@ class ViewEdge;
*/
class FEdge : public Interface1D {
public: // Implementation of Interface0D
- /*! Returns the string "FEdge". */
+ /** Returns the string "FEdge". */
virtual string getExactTypeName() const
{
return "FEdge";
@@ -484,7 +484,7 @@ class FEdge : public Interface1D {
// Data access methods
- /*! Returns the 2D length of the FEdge. */
+ /** Returns the 2D length of the FEdge. */
virtual real getLength2D() const
{
if (!_VertexA || !_VertexB) {
@@ -493,7 +493,7 @@ class FEdge : public Interface1D {
return (_VertexB->getPoint2D() - _VertexA->getPoint2D()).norm();
}
- /*! Returns the Id of the FEdge. */
+ /** Returns the Id of the FEdge. */
virtual Id getId() const
{
return _Id;
@@ -533,12 +533,12 @@ class FEdge : public Interface1D {
bool _isTemporary;
public:
- /*! A field that can be used by the user to store any data.
+ /** A field that can be used by the user to store any data.
* This field must be reset afterwards using ResetUserData().
*/
void *userdata;
- /*! Default constructor */
+ /** Default constructor */
inline FEdge()
{
userdata = NULL;
@@ -555,7 +555,7 @@ class FEdge : public Interface1D {
_isTemporary = false;
}
- /*! Builds an FEdge going from vA to vB. */
+ /** Builds an FEdge going from vA to vB. */
inline FEdge(SVertex *vA, SVertex *vB)
{
userdata = NULL;
@@ -572,7 +572,7 @@ class FEdge : public Interface1D {
_isTemporary = false;
}
- /*! Copy constructor */
+ /** Copy constructor */
inline FEdge(FEdge &iBrother)
{
_VertexA = iBrother.vertexA();
@@ -594,12 +594,12 @@ class FEdge : public Interface1D {
userdata = 0;
}
- /*! Destructor */
+ /** Destructor */
virtual ~FEdge()
{
}
- /*! Cloning method. */
+ /** Cloning method. */
virtual FEdge *duplicate()
{
FEdge *clone = new FEdge(*this);
@@ -607,31 +607,31 @@ class FEdge : public Interface1D {
}
/* accessors */
- /*! Returns the first SVertex. */
+ /** Returns the first SVertex. */
inline SVertex *vertexA()
{
return _VertexA;
}
- /*! Returns the second SVertex. */
+ /** Returns the second SVertex. */
inline SVertex *vertexB()
{
return _VertexB;
}
- /*! Returns the first SVertex if i=0, the second SVertex if i=1. */
+ /** Returns the first SVertex if i=0, the second SVertex if i=1. */
inline SVertex *operator[](const unsigned short int &i) const
{
return (i % 2 == 0) ? _VertexA : _VertexB;
}
- /*! Returns the nature of the FEdge. */
+ /** Returns the nature of the FEdge. */
inline Nature::EdgeNature getNature() const
{
return _Nature;
}
- /*! Returns the FEdge following this one in the ViewEdge.
+ /** Returns the FEdge following this one in the ViewEdge.
* If this FEdge is the last of the ViewEdge, 0 is returned.
*/
inline FEdge *nextEdge()
@@ -639,7 +639,7 @@ class FEdge : public Interface1D {
return _NextEdge;
}
- /*! Returns the Edge preceding this one in the ViewEdge.
+ /** Returns the Edge preceding this one in the ViewEdge.
* If this FEdge is the first one of the ViewEdge, 0 is returned.
*/
inline FEdge *previousEdge()
@@ -668,7 +668,7 @@ class FEdge : public Interface1D {
}
#endif
- /*! Returns a pointer to the ViewEdge to which this FEdge belongs to. */
+ /** Returns a pointer to the ViewEdge to which this FEdge belongs to. */
inline ViewEdge *viewedge() const
{
return _ViewEdge;
@@ -716,7 +716,7 @@ class FEdge : public Interface1D {
return _occludeeEmpty;
}
- /*! Returns true if this FEdge is a smooth FEdge. */
+ /** Returns true if this FEdge is a smooth FEdge. */
inline bool isSmooth() const
{
return _isSmooth;
@@ -733,37 +733,37 @@ class FEdge : public Interface1D {
}
/* modifiers */
- /*! Sets the first SVertex. */
+ /** Sets the first SVertex. */
inline void setVertexA(SVertex *vA)
{
_VertexA = vA;
}
- /*! Sets the second SVertex. */
+ /** Sets the second SVertex. */
inline void setVertexB(SVertex *vB)
{
_VertexB = vB;
}
- /*! Sets the FEdge Id . */
+ /** Sets the FEdge Id . */
inline void setId(const Id &id)
{
_Id = id;
}
- /*! Sets the pointer to the next FEdge. */
+ /** Sets the pointer to the next FEdge. */
inline void setNextEdge(FEdge *iEdge)
{
_NextEdge = iEdge;
}
- /*! Sets the pointer to the previous FEdge. */
+ /** Sets the pointer to the previous FEdge. */
inline void setPreviousEdge(FEdge *iEdge)
{
_PreviousEdge = iEdge;
}
- /*! Sets the nature of this FEdge. */
+ /** Sets the nature of this FEdge. */
inline void setNature(Nature::EdgeNature iNature)
{
_Nature = iNature;
@@ -776,7 +776,7 @@ class FEdge : public Interface1D {
}
#endif
- /*! Sets the ViewEdge to which this FEdge belongs to. */
+ /** Sets the ViewEdge to which this FEdge belongs to. */
inline void setViewEdge(ViewEdge *iViewEdge)
{
_ViewEdge = iViewEdge;
@@ -814,7 +814,7 @@ class FEdge : public Interface1D {
_occludeeEmpty = iempty;
}
- /*! Sets the flag telling whether this FEdge is smooth or sharp.
+ /** Sets the flag telling whether this FEdge is smooth or sharp.
* true for Smooth, false for Sharp.
*/
inline void setSmooth(bool iFlag)
@@ -941,18 +941,18 @@ class FEdge : public Interface1D {
inline Vec3r curvature2d_as_vector(int iCombination = 0) const;
- /* angle in degrees*/
+ /* Angle in degrees. */
inline real curvature2d_as_angle(int iCombination = 0) const;
#endif
// Iterator access (Interface1D)
- /*! Returns an iterator over the 2 (!) SVertex pointing to the first SVertex. */
+ /** Returns an iterator over the 2 (!) SVertex pointing to the first SVertex. */
virtual inline Interface0DIterator verticesBegin();
- /*! Returns an iterator over the 2 (!) SVertex pointing after the last SVertex. */
+ /** 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
+ /** 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:
@@ -960,7 +960,7 @@ class FEdge : public Interface1D {
*/
virtual inline Interface0DIterator pointsBegin(float t = 0.0f);
- /*! Returns an iterator over the FEdge points, pointing after the last point. The difference with
+ /** 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:
@@ -1138,7 +1138,7 @@ Interface0DIterator FEdge::pointsEnd(float /*t*/)
return verticesEnd();
}
-/*! Class defining a sharp FEdge. A Sharp FEdge corresponds to an initial edge of the input mesh.
+/** Class defining a sharp FEdge. A Sharp FEdge corresponds to an initial edge of the input mesh.
* It can be a silhouette, a crease or a border. If it is a crease edge, then it is bordered
* by two faces of the mesh. Face a lies on its right whereas Face b lies on its left.
* If it is a border edge, then it doesn't have any face on its right, and thus Face a = 0.
@@ -1153,27 +1153,27 @@ class FEdgeSharp : public FEdge {
bool _bFaceMark;
public:
- /*! Returns the string "FEdgeSharp" . */
+ /** Returns the string "FEdgeSharp" . */
virtual string getExactTypeName() const
{
return "FEdgeSharp";
}
- /*! Default constructor. */
+ /** Default constructor. */
inline FEdgeSharp() : FEdge()
{
_aFrsMaterialIndex = _bFrsMaterialIndex = 0;
_aFaceMark = _bFaceMark = false;
}
- /*! Builds an FEdgeSharp going from vA to vB. */
+ /** Builds an FEdgeSharp going from vA to vB. */
inline FEdgeSharp(SVertex *vA, SVertex *vB) : FEdge(vA, vB)
{
_aFrsMaterialIndex = _bFrsMaterialIndex = 0;
_aFaceMark = _bFaceMark = false;
}
- /*! Copy constructor. */
+ /** Copy constructor. */
inline FEdgeSharp(FEdgeSharp &iBrother) : FEdge(iBrother)
{
_aNormal = iBrother._aNormal;
@@ -1184,19 +1184,19 @@ class FEdgeSharp : public FEdge {
_bFaceMark = iBrother._bFaceMark;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~FEdgeSharp()
{
}
- /*! Cloning method. */
+ /** Cloning method. */
virtual FEdge *duplicate()
{
FEdge *clone = new FEdgeSharp(*this);
return clone;
}
- /*! Returns the normal to the face lying on the right of the FEdge. If this FEdge is a border,
+ /** Returns the normal to the face lying on the right of the FEdge. If this FEdge is a border,
* it has no Face on its right and therefore, no normal.
*/
inline const Vec3r &normalA()
@@ -1204,13 +1204,13 @@ class FEdgeSharp : public FEdge {
return _aNormal;
}
- /*! Returns the normal to the face lying on the left of the FEdge. */
+ /** Returns the normal to the face lying on the left of the FEdge. */
inline const Vec3r &normalB()
{
return _bNormal;
}
- /*! Returns the index of the material of the face lying on the
+ /** Returns the index of the material of the face lying on the
* right of the FEdge. If this FEdge is a border,
* it has no Face on its right and therefore, no material.
*/
@@ -1219,21 +1219,21 @@ class FEdgeSharp : public FEdge {
return _aFrsMaterialIndex;
}
- /*! Returns the material of the face lying on the right of the FEdge. If this FEdge is a border,
+ /** Returns the material of the face lying on the right of the FEdge. If this FEdge is a border,
* it has no Face on its right and therefore, no material.
*/
const FrsMaterial &aFrsMaterial() const;
- /*! Returns the index of the material of the face lying on the left of the FEdge. */
+ /** Returns the index of the material of the face lying on the left of the FEdge. */
inline unsigned bFrsMaterialIndex() const
{
return _bFrsMaterialIndex;
}
- /*! Returns the material of the face lying on the left of the FEdge. */
+ /** Returns the material of the face lying on the left of the FEdge. */
const FrsMaterial &bFrsMaterial() const;
- /*! Returns the face mark of the face lying on the right of the FEdge.
+ /** Returns the face mark of the face lying on the right of the FEdge.
* If this FEdge is a border, it has no Face on its right and thus false is returned.
*/
inline bool aFaceMark() const
@@ -1241,43 +1241,43 @@ class FEdgeSharp : public FEdge {
return _aFaceMark;
}
- /*! Returns the face mark of the face lying on the left of the FEdge. */
+ /** Returns the face mark of the face lying on the left of the FEdge. */
inline bool bFaceMark() const
{
return _bFaceMark;
}
- /*! Sets the normal to the face lying on the right of the FEdge. */
+ /** Sets the normal to the face lying on the right of the FEdge. */
inline void setNormalA(const Vec3r &iNormal)
{
_aNormal = iNormal;
}
- /*! Sets the normal to the face lying on the left of the FEdge. */
+ /** Sets the normal to the face lying on the left of the FEdge. */
inline void setNormalB(const Vec3r &iNormal)
{
_bNormal = iNormal;
}
- /*! Sets the index of the material lying on the right of the FEdge.*/
+ /** Sets the index of the material lying on the right of the FEdge. */
inline void setaFrsMaterialIndex(unsigned i)
{
_aFrsMaterialIndex = i;
}
- /*! Sets the index of the material lying on the left of the FEdge.*/
+ /** Sets the index of the material lying on the left of the FEdge. */
inline void setbFrsMaterialIndex(unsigned i)
{
_bFrsMaterialIndex = i;
}
- /*! Sets the face mark of the face lying on the right of the FEdge. */
+ /** Sets the face mark of the face lying on the right of the FEdge. */
inline void setaFaceMark(bool iFaceMark)
{
_aFaceMark = iFaceMark;
}
- /*! Sets the face mark of the face lying on the left of the FEdge. */
+ /** Sets the face mark of the face lying on the left of the FEdge. */
inline void setbFaceMark(bool iFaceMark)
{
_bFaceMark = iFaceMark;
@@ -1288,7 +1288,7 @@ class FEdgeSharp : public FEdge {
#endif
};
-/*! Class defining a smooth edge. This kind of edge typically runs across a face of the input mesh.
+/** 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 {
@@ -1305,13 +1305,13 @@ class FEdgeSmooth : public FEdge {
bool _FaceMark;
public:
- /*! Returns the string "FEdgeSmooth" . */
+ /** Returns the string "FEdgeSmooth" . */
virtual string getExactTypeName() const
{
return "FEdgeSmooth";
}
- /*! Default constructor. */
+ /** Default constructor. */
inline FEdgeSmooth() : FEdge()
{
_Face = NULL;
@@ -1320,7 +1320,7 @@ class FEdgeSmooth : public FEdge {
_isSmooth = true;
}
- /*! Builds an FEdgeSmooth going from vA to vB. */
+ /** Builds an FEdgeSmooth going from vA to vB. */
inline FEdgeSmooth(SVertex *vA, SVertex *vB) : FEdge(vA, vB)
{
_Face = NULL;
@@ -1329,7 +1329,7 @@ class FEdgeSmooth : public FEdge {
_isSmooth = true;
}
- /*! Copy constructor. */
+ /** Copy constructor. */
inline FEdgeSmooth(FEdgeSmooth &iBrother) : FEdge(iBrother)
{
_Normal = iBrother._Normal;
@@ -1339,12 +1339,12 @@ class FEdgeSmooth : public FEdge {
_isSmooth = true;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~FEdgeSmooth()
{
}
- /*! Cloning method. */
+ /** Cloning method. */
virtual FEdge *duplicate()
{
FEdge *clone = new FEdgeSmooth(*this);
@@ -1356,25 +1356,25 @@ class FEdgeSmooth : public FEdge {
return _Face;
}
- /*! Returns the face mark of the face it is running across. */
+ /** Returns the face mark of the face it is running across. */
inline bool faceMark() const
{
return _FaceMark;
}
- /*! Returns the normal to the Face it is running across. */
+ /** Returns the normal to the Face it is running across. */
inline const Vec3r &normal()
{
return _Normal;
}
- /*! Returns the index of the material of the face it is running across. */
+ /** Returns the index of the material of the face it is running across. */
inline unsigned frs_materialIndex() const
{
return _FrsMaterialIndex;
}
- /*! Returns the material of the face it is running across. */
+ /** Returns the material of the face it is running across. */
const FrsMaterial &frs_material() const;
inline void setFace(void *iFace)
@@ -1382,19 +1382,19 @@ class FEdgeSmooth : public FEdge {
_Face = iFace;
}
- /*! Sets the face mark of the face it is running across. */
+ /** Sets the face mark of the face it is running across. */
inline void setFaceMark(bool iFaceMark)
{
_FaceMark = iFaceMark;
}
- /*! Sets the normal to the Face it is running across. */
+ /** Sets the normal to the Face it is running across. */
inline void setNormal(const Vec3r &iNormal)
{
_Normal = iNormal;
}
- /*! Sets the index of the material of the face it is running across. */
+ /** Sets the index of the material of the face it is running across. */
inline void setFrsMaterialIndex(unsigned i)
{
_FrsMaterialIndex = i;
@@ -1413,7 +1413,7 @@ class FEdgeSmooth : public FEdge {
/* */
/**********************************/
-/*! Class to define a feature shape. It is the gathering of feature elements from an identified
+/** Class to define a feature shape. It is the gathering of feature elements from an identified
* input shape */
class SShape {
private:
@@ -1431,12 +1431,12 @@ class SShape {
ViewShape *_ViewShape;
public:
- /*! A field that can be used by the user to store any data.
+ /** A field that can be used by the user to store any data.
* This field must be reset afterwards using ResetUserData().
*/
void *userdata; // added by E.T.
- /*! Default constructor */
+ /** Default constructor */
inline SShape()
{
userdata = NULL;
@@ -1444,7 +1444,7 @@ class SShape {
_ViewShape = NULL;
}
- /*! Copy constructor */
+ /** Copy constructor */
inline SShape(SShape &iBrother)
{
userdata = NULL;
@@ -1528,14 +1528,14 @@ class SShape {
}
}
- /*! Cloning method. */
+ /** Cloning method. */
virtual SShape *duplicate()
{
SShape *clone = new SShape(*this);
return clone;
}
- /*! Destructor. */
+ /** Destructor. */
virtual inline ~SShape()
{
vector<SVertex *>::iterator sv, svend;
@@ -1561,13 +1561,13 @@ class SShape {
}
}
- /*! Adds a FEdge to the list of FEdges. */
+ /** Adds a FEdge to the list of FEdges. */
inline void AddEdge(FEdge *iEdge)
{
_edgesList.push_back(iEdge);
}
- /*! Adds a SVertex to the list of SVertex of this Shape.
+ /** Adds a SVertex to the list of SVertex of this Shape.
* The SShape attribute of the SVertex is also set to 'this'.
*/
inline void AddNewVertex(SVertex *iv)
@@ -1589,7 +1589,7 @@ class SShape {
return Ia;
}
- /*! Splits an edge into several edges.
+ /** 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 split in the same time. The processed edges are flagged as
* done (using the user-data flag).One single new vertex is created whereas several split edges
@@ -1773,13 +1773,13 @@ class SShape {
return newEdge;
}
- /*! Sets the Bounding Box of the Shape */
+ /** Sets the Bounding Box of the Shape */
inline void setBBox(const BBox<Vec3r> &iBBox)
{
_BBox = iBBox;
}
- /*! Compute the bbox of the sshape */
+ /** Compute the bbox of the sshape */
inline void ComputeBBox()
{
if (0 == _verticesList.size()) {
@@ -1853,13 +1853,13 @@ class SShape {
}
/* accessors */
- /*! Returns the list of SVertex of the Shape. */
+ /** Returns the list of SVertex of the Shape. */
inline vector<SVertex *> &getVertexList()
{
return _verticesList;
}
- /*! Returns the list of FEdges of the Shape. */
+ /** Returns the list of FEdges of the Shape. */
inline vector<FEdge *> &getEdgeList()
{
return _edgesList;
@@ -1870,19 +1870,19 @@ class SShape {
return _chains;
}
- /*! Returns the bounding box of the shape. */
+ /** Returns the bounding box of the shape. */
inline const BBox<Vec3r> &bbox()
{
return _BBox;
}
- /*! Returns the ith material of the shape. */
+ /** Returns the ith material of the shape. */
inline const FrsMaterial &frs_material(unsigned i) const
{
return _FrsMaterials[i];
}
- /*! Returns the list of materials of the Shape. */
+ /** Returns the list of materials of the Shape. */
inline const vector<FrsMaterial> &frs_materials() const
{
return _FrsMaterials;
@@ -1898,44 +1898,44 @@ class SShape {
return _importance;
}
- /*! Returns the Id of the Shape. */
+ /** Returns the Id of the Shape. */
inline Id getId() const
{
return _Id;
}
- /*! Returns the name of the Shape. */
+ /** Returns the name of the Shape. */
inline const string &getName() const
{
return _Name;
}
- /*! Returns the library path of the Shape. */
+ /** Returns the library path of the Shape. */
inline const string &getLibraryPath() const
{
return _LibraryPath;
}
/* Modififers */
- /*! Sets the Id of the shape.*/
+ /** Sets the Id of the shape. */
inline void setId(Id id)
{
_Id = id;
}
- /*! Sets the name of the shape.*/
+ /** Sets the name of the shape. */
inline void setName(const string &name)
{
_Name = name;
}
- /*! Sets the library path of the shape.*/
+ /** Sets the library path of the shape. */
inline void setLibraryPath(const string &path)
{
_LibraryPath = path;
}
- /*! Sets the list of materials for the shape */
+ /** Sets the list of materials for the shape */
inline void setFrsMaterials(const vector<FrsMaterial> &iMaterials)
{
_FrsMaterials = iMaterials;
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
index 124ef35e5b9..25b2eacd507 100644
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
@@ -68,7 +68,7 @@ class SilhouetteGeomEngine {
static SilhouetteGeomEngine *_pInstance;
public:
- /*! retrieves an instance on the singleton */
+ /** retrieves an instance on the singleton */
static SilhouetteGeomEngine *getInstance()
{
if (_pInstance == NULL) {
@@ -77,13 +77,13 @@ class SilhouetteGeomEngine {
return _pInstance;
}
- /*! Sets the current viewpoint */
+ /** Sets the current viewpoint */
static inline void setViewpoint(const Vec3r &ivp)
{
_Viewpoint = ivp;
}
- /*! Sets the current transformation
+ /** Sets the current transformation
* iModelViewMatrix
* The 4x4 model view matrix, in column major order (openGL like).
* iProjection matrix
@@ -98,13 +98,13 @@ class SilhouetteGeomEngine {
const int iViewport[4],
real iFocal);
- /*! Sets the current znear and zfar */
+ /** Sets the current znear and zfar */
static void setFrustum(real iZNear, real iZFar);
/* accessors */
static void retrieveViewport(int viewport[4]);
- /*! Projects the silhouette in camera coordinates
+ /** Projects the silhouette in camera coordinates
* This method modifies the ioEdges passed as argument.
* ioVertices
* The vertices to project. It is modified during the operation.
@@ -112,7 +112,7 @@ class SilhouetteGeomEngine {
static void ProjectSilhouette(std::vector<SVertex *> &ioVertices);
static void ProjectSilhouette(SVertex *ioVertex);
- /*! transforms the parameter t defining a 2D intersection for edge fe in order to obtain
+ /** transforms the parameter t defining a 2D intersection for edge fe in order to obtain
* the parameter giving the corresponding 3D intersection.
* Returns the 3D parameter
* fe
@@ -122,10 +122,10 @@ class SilhouetteGeomEngine {
*/
static real ImageToWorldParameter(FEdge *fe, real t);
- /*! From world to image */
+ /** From world to image */
static Vec3r WorldToImage(const Vec3r &M);
- /*! From camera to image */
+ /** From camera to image */
static Vec3r CameraToImage(const Vec3r &M);
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.h b/source/blender/freestyle/intern/view_map/SphericalGrid.h
index efa3530cb2a..ae052ff3e12 100644
--- a/source/blender/freestyle/intern/view_map/SphericalGrid.h
+++ b/source/blender/freestyle/intern/view_map/SphericalGrid.h
@@ -87,7 +87,7 @@ class SphericalGrid {
};
public:
- /*! Iterator needs to allow the user to avoid full 3D comparison in two cases:
+ /** 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.
diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.h b/source/blender/freestyle/intern/view_map/SteerableViewMap.h
index e03400dbbc0..d007a08c3fd 100644
--- a/source/blender/freestyle/intern/view_map/SteerableViewMap.h
+++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.h
@@ -42,7 +42,7 @@ class FEdge;
class ImagePyramid;
class GrayImage;
-/*! This class checks for every FEdge in which steerable it belongs and stores the mapping
+/** 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 {
@@ -62,31 +62,31 @@ class SteerableViewMap {
SteerableViewMap(const SteerableViewMap &iBrother);
virtual ~SteerableViewMap();
- /*! Resets everything */
+ /** Resets everything */
virtual void Reset();
- /*! Adds a FEdge to steerable VM.
+ /** Adds a FEdge to steerable VM.
* Returns the nbOrientations weights corresponding to the FEdge contributions to the
* nbOrientations directional maps.
*/
double *AddFEdge(FEdge *iFEdge);
- /*! Compute the weight of direction dir for orientation iNOrientation */
+ /** Compute the weight of direction dir for orientation iNOrientation */
double ComputeWeight(const Vec2d &dir, unsigned iNOrientation);
- /*! Returns the number of the SVM to which a direction belongs to.
+ /** Returns the number of the SVM to which a direction belongs to.
* \param dir:
* The direction
*/
unsigned getSVMNumber(Vec2f dir);
- /*! Returns the number of the SVM to which a FEdge belongs most.
+ /** Returns the number of the SVM to which a FEdge belongs most.
* \param id:
* The First element of the Id struct of the FEdge we're interested in.
*/
unsigned getSVMNumber(unsigned id);
- /*! Builds _nbOrientations+1 pyramids of images from the _nbOrientations+1 base images of the
+ /** 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.
@@ -105,7 +105,7 @@ class SteerableViewMap {
unsigned iNbLevels = 4,
float iSigma = 1.0f);
- /*! Reads a pixel value in one of the VewMap density steerable pyramids.
+ /** Reads a pixel value in one of the VewMap density steerable pyramids.
* Returns a value between 0 and 1.
* \param iOrientation:
* the number telling which orientation we need to check.
@@ -126,23 +126,23 @@ class SteerableViewMap {
*/
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
+ /** 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)
*/
float readCompleteViewMapPixel(int iLevel, int x, int y);
- /*! Returns the number of levels in the pyramids */
+ /** Returns the number of levels in the pyramids */
unsigned int getNumberOfPyramidLevels() const;
- /*! Returns the number of orientations */
+ /** Returns the number of orientations */
unsigned int getNumberOfOrientations() const
{
return _nbOrientations;
}
- /*! for debug purposes */
+ /** for debug purposes */
void saveSteerableViewMap() const;
protected:
diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
index 8d5955fc0ae..24c56572803 100644
--- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
@@ -601,7 +601,7 @@ OWXEdge ViewEdgeXBuilder::FindNextWEdge(const OWXEdge &iEdge)
}
if (((WXVertex *)v)->isFeature()) {
- return nullptr; /* XXX eeek? NULL? OWXEdge(NULL, true/false)?*/
+ return nullptr; /* XXX eeek? NULL? OWXEdge(NULL, true/false)? */
}
int faceMarks = retrieveFaceMarks(iEdge.e);
diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
index 1fce4f4a965..d181348b3da 100644
--- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
+++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
@@ -53,7 +53,7 @@ using namespace Geometry;
class SVertex;
-/*! Defines a hash table used for searching the SVertex */
+/** Defines a hash table used for searching the SVertex */
struct SVertexHasher {
#define _MUL 950706376UL
#define _MOD 2147483647UL
@@ -81,7 +81,7 @@ typedef map<Vec3r, SVertex *> SVertexMap;
class WXFaceLayer;
-/*! class to describe an oriented smooth edge */
+/** class to describe an oriented smooth edge */
class OWXFaceLayer {
public:
WXFaceLayer *fl;
@@ -123,7 +123,7 @@ class OWXFaceLayer {
class WXEdge;
-/*! class to describe an oriented sharp edge */
+/** class to describe an oriented sharp edge */
class OWXEdge {
public:
WXEdge *e;
@@ -190,7 +190,7 @@ class ViewEdgeXBuilder {
{
}
- /*! Builds a view shape from a WXShape in which the feature edges are flagged
+ /** Builds a view shape from a WXShape in which the feature edges are flagged
* Builds chains of feature edges (so ViewEdges) from a WXShape
* iWShape
* The Winged Edge structure in which all silhouette edges and vertices are flagged.
@@ -212,14 +212,14 @@ class ViewEdgeXBuilder {
std::vector<FEdge *> &ioFEdges,
std::vector<SVertex *> &ioSVertices);
- /*! Builds a smooth view edge, starting the face iFace. */
+ /** Builds a smooth view edge, starting the face iFace. */
ViewEdge *BuildSmoothViewEdge(const OWXFaceLayer &iFaceLayer);
- /*! Makes a sharp viewedge */
+ /** Makes a sharp viewedge. */
ViewEdge *BuildSharpViewEdge(const OWXEdge &iWEdge);
public:
- /*! accessors */
+ /** accessors */
inline int currentViewId() const
{
return _currentViewId;
@@ -235,7 +235,7 @@ class ViewEdgeXBuilder {
return _currentSVertexId;
}
- /*! modifiers */
+ /** modifiers */
inline void setCurrentViewId(int id)
{
_currentViewId = id;
@@ -252,18 +252,18 @@ class ViewEdgeXBuilder {
}
protected:
- /*! Init the view edges building */
+ /** Init the view edges building */
virtual void Init(ViewShape *oVShape);
// SMOOTH //
- /*! checks whether a face has already been processed or not */
+ /** checks whether a face has already been processed or not */
bool stopSmoothViewEdge(WXFaceLayer *iFaceLayer);
OWXFaceLayer FindNextFaceLayer(const OWXFaceLayer &iFaceLayer);
OWXFaceLayer FindPreviousFaceLayer(const OWXFaceLayer &iFaceLayer);
FEdge *BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer &ifl);
// SHARP //
- /*! checks whether a WEdge has already been processed or not */
+ /** checks whether a WEdge has already been processed or not */
bool stopSharpViewEdge(WXEdge *iEdge);
int retrieveFaceMarks(WXEdge *iEdge);
OWXEdge FindNextWEdge(const OWXEdge &iEdge);
@@ -271,11 +271,11 @@ class ViewEdgeXBuilder {
FEdge *BuildSharpFEdge(FEdge *feprevious, const OWXEdge &iwe);
// GENERAL //
- /*! Instantiate a SVertex */
+ /** Instantiate a SVertex */
SVertex *MakeSVertex(Vec3r &iPoint);
- /*! Instantiate a SVertex if it hasn't been already created */
+ /** Instantiate a SVertex if it hasn't been already created */
SVertex *MakeSVertex(Vec3r &iPoint, bool shared);
- /*! instantiate a ViewVertex from a SVertex, if it doesn't exist yet */
+ /** instantiate a ViewVertex from a SVertex, if it doesn't exist yet */
ViewVertex *MakeViewVertex(SVertex *iSVertex);
// oldtmp values
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.cpp b/source/blender/freestyle/intern/view_map/ViewMap.cpp
index 13ee2851c6c..f1b00724793 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMap.cpp
@@ -432,7 +432,7 @@ void TVertex::Replace(ViewEdge *iOld, ViewEdge *iNew)
}
}
-/*! iterators access */
+/** iterators access */
ViewVertex::edge_iterator TVertex::edges_begin()
{
// return edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, _FrontEdgeA);
@@ -584,7 +584,7 @@ void NonTVertex::AddIncomingViewEdge(ViewEdge *iVEdge)
}
}
-/*! iterators access */
+/** iterators access */
ViewVertex::edge_iterator NonTVertex::edges_begin()
{
return edge_iterator(_ViewEdges.begin(), _ViewEdges.end(), _ViewEdges.begin());
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h
index 47a2e98418a..bd7edad7642 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.h
+++ b/source/blender/freestyle/intern/view_map/ViewMap.h
@@ -56,7 +56,7 @@ class ViewEdge;
class ViewShape;
class TVertex;
-/*! Class defining the ViewMap.*/
+/** Class defining the ViewMap. */
class ViewMap {
public:
typedef vector<ViewEdge *> viewedges_container;
@@ -79,29 +79,29 @@ class ViewMap {
id_to_index_map _shapeIdToIndex;
public:
- /*! A field that can be used by the user to store any data.
+ /** A field that can be used by the user to store any data.
* This field must be reset afterwards using ResetUserData().
*/
void *userdata;
- /*! Default constructor. */
+ /** Default constructor. */
ViewMap()
{
_pInstance = this;
userdata = NULL;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~ViewMap();
- /*! Gets the viewedge the nearest to the 2D position specified as argument */
+ /** Gets the viewedge the nearest to the 2D position specified as argument */
const ViewEdge *getClosestViewEdge(real x, real y) const;
- /*! Gets the Fedge the nearest to the 2D position specified as argument */
+ /** Gets the Fedge the nearest to the 2D position specified as argument */
const FEdge *getClosestFEdge(real x, real y) const;
/* accessors */
- /*! The ViewMap is a singleton class. This static method returns the instance of the ViewMap. */
+ /** The ViewMap is a singleton class. This static method returns the instance of the ViewMap. */
static inline ViewMap *getInstance()
{
return _pInstance;
@@ -160,7 +160,7 @@ class ViewMap {
return _shapeIdToIndex;
}
- /*! Returns the scene 3D bounding box. */
+ /** Returns the scene 3D bounding box. */
inline BBox<Vec3r> getScene3dBBox() const
{
return _scene3DBBox;
@@ -189,7 +189,7 @@ class ViewMap {
_SVertices.push_back(iSVertex);
}
- /*! Sets the scene 3D bounding box. */
+ /** Sets the scene 3D bounding box. */
inline void setScene3dBBox(const BBox<Vec3r> &bbox)
{
_scene3DBBox = bbox;
@@ -259,7 +259,7 @@ class orientedViewEdgeIterator;
} // namespace ViewVertexInternal
-/*! Class to define a view vertex.
+/** 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
@@ -269,7 +269,7 @@ class orientedViewEdgeIterator;
*/
class ViewVertex : public Interface0D {
public: // Implementation of Interface0D
- /*! Returns the string "ViewVertex". */
+ /** Returns the string "ViewVertex". */
virtual string getExactTypeName() const
{
return "ViewVertex";
@@ -290,12 +290,12 @@ class ViewVertex : public Interface0D {
Nature::VertexNature _Nature;
public:
- /*! A field that can be used by the user to store any data.
+ /** A field that can be used by the user to store any data.
* This field must be reset afterwards using ResetUserData().
*/
void *userdata;
- /*! Default constructor.*/
+ /** Default constructor. */
inline ViewVertex()
{
userdata = NULL;
@@ -309,7 +309,7 @@ class ViewVertex : public Interface0D {
}
protected:
- /*! Copy constructor. */
+ /** Copy constructor. */
inline ViewVertex(ViewVertex &iBrother)
{
_Nature = iBrother._Nature;
@@ -317,24 +317,24 @@ class ViewVertex : public Interface0D {
userdata = NULL;
}
- /*! Cloning method. */
+ /** Cloning method. */
virtual ViewVertex *duplicate() = 0;
public:
- /*! Destructor. */
+ /** Destructor. */
virtual ~ViewVertex()
{
}
/* accessors */
- /*! Returns the nature of the vertex .*/
+ /** Returns the nature of the vertex. */
virtual Nature::VertexNature getNature() const
{
return _Nature;
}
/* modifiers */
- /*! Sets the nature of the vertex. */
+ /** Sets the nature of the vertex. */
inline void setNature(Nature::VertexNature iNature)
{
_Nature = iNature;
@@ -357,18 +357,18 @@ 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
+ /** 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
+ /** Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after
* the last ViewEdge.
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesEnd() = 0;
- /*! Returns an orientedViewEdgeIterator pointing to the ViewEdge given as argument. */
+ /** Returns an orientedViewEdgeIterator pointing to the ViewEdge given as argument. */
virtual ViewVertexInternal::orientedViewEdgeIterator edgesIterator(ViewEdge *iEdge) = 0;
#ifdef WITH_CXX_GUARDEDALLOC
@@ -384,7 +384,7 @@ class ViewVertex : public Interface0D {
/* */
/**********************************/
-/*! class to define a T vertex, i.e. an intersection between two edges.
+/** class to define a T vertex, i.e. an intersection between two edges.
* It points towards 2 SVertex and 4 View edges.
* Among these ViewEdges, 2 are front and 2 are back.
* Basically the front edge hides part of the back edge.
@@ -395,7 +395,7 @@ class TVertex : public ViewVertex {
typedef vector<directedViewEdge *> edge_pointers_container;
public: // Implementation of Interface0D
- /*! Returns the string "TVertex". */
+ /** Returns the string "TVertex". */
virtual string getExactTypeName() const
{
return "TVertex";
@@ -421,20 +421,20 @@ class TVertex : public ViewVertex {
return _FrontSVertex->point3D().z();
}
- /*! Returns the 3D point. */
+ /** Returns the 3D point. */
virtual Vec3r getPoint3D() const
{
cerr << "Warning: getPoint3D() undefined for this point" << endl;
return _FrontSVertex->getPoint3D();
}
- /*! Returns the projected 3D x coordinate of the vertex. */
+ /** Returns the projected 3D x coordinate of the vertex. */
virtual real getProjectedX() const
{
return _FrontSVertex->point2D().x();
}
- /*! Returns the projected 3D y coordinate of the vertex. */
+ /** Returns the projected 3D y coordinate of the vertex. */
virtual real getProjectedY() const
{
return _FrontSVertex->point2D().y();
@@ -445,26 +445,26 @@ class TVertex : public ViewVertex {
return _FrontSVertex->point2D().z();
}
- /*! Returns the 2D point. */
+ /** Returns the 2D point. */
virtual Vec2r getPoint2D() const
{
return _FrontSVertex->getPoint2D();
}
- /*! Returns the Id of the TVertex. */
+ /** Returns the Id of the TVertex. */
virtual Id getId() const
{
return _Id;
}
- /*! Cast the Interface0D in SVertex if it can be. */
+ /** Cast the Interface0D in SVertex if it can be. */
// it can't
virtual ViewVertex *castToViewVertex()
{
return this;
}
- /*! Cast the Interface0D in TVertex if it can be. */
+ /** Cast the Interface0D in TVertex if it can be. */
virtual TVertex *castToTVertex()
{
return this;
@@ -483,7 +483,7 @@ class TVertex : public ViewVertex {
_sortedEdges; // the list of the four ViewEdges, ordered in CCW order (in the image plan)
public:
- /*! Default constructor.*/
+ /** Default constructor. */
inline TVertex() : ViewVertex(Nature::T_VERTEX)
{
_FrontSVertex = NULL;
@@ -507,7 +507,7 @@ class TVertex : public ViewVertex {
}
protected:
- /*! Copy constructor. */
+ /** Copy constructor. */
inline TVertex(TVertex &iBrother) : ViewVertex(iBrother)
{
_FrontSVertex = iBrother._FrontSVertex;
@@ -519,7 +519,7 @@ class TVertex : public ViewVertex {
_sortedEdges = iBrother._sortedEdges;
}
- /*! Cloning method. */
+ /** Cloning method. */
virtual ViewVertex *duplicate()
{
TVertex *clone = new TVertex(*this);
@@ -528,13 +528,13 @@ class TVertex : public ViewVertex {
public:
/* accessors */
- /*! Returns the SVertex that is closer to the viewpoint. */
+ /** Returns the SVertex that is closer to the viewpoint. */
inline SVertex *frontSVertex()
{
return _FrontSVertex;
}
- /*! Returns the SVertex that is further away from the viewpoint. */
+ /** Returns the SVertex that is further away from the viewpoint. */
inline SVertex *backSVertex()
{
return _BackSVertex;
@@ -561,14 +561,14 @@ class TVertex : public ViewVertex {
}
/* modifiers */
- /*! Sets the SVertex that is closer to the viewpoint. */
+ /** Sets the SVertex that is closer to the viewpoint. */
inline void setFrontSVertex(SVertex *iFrontSVertex)
{
_FrontSVertex = iFrontSVertex;
_FrontSVertex->setViewVertex(this);
}
- /*! Sets the SVertex that is further away from the viewpoint. */
+ /** Sets the SVertex that is further away from the viewpoint. */
inline void setBackSVertex(SVertex *iBackSVertex)
{
_BackSVertex = iBackSVertex;
@@ -580,13 +580,13 @@ class TVertex : public ViewVertex {
void setBackEdgeA(ViewEdge *iBackEdgeA, bool incoming = true);
void setBackEdgeB(ViewEdge *iBackEdgeB, bool incoming = true);
- /*! Sets the Id. */
+ /** Sets the Id. */
inline void setId(const Id &iId)
{
_Id = iId;
}
- /*! Returns the SVertex (among the 2) belonging to the FEdge iFEdge */
+ /** Returns the SVertex (among the 2) belonging to the FEdge iFEdge */
inline SVertex *getSVertex(FEdge *iFEdge)
{
const vector<FEdge *> &vfEdges = _FrontSVertex->fedges();
@@ -608,7 +608,7 @@ class TVertex : public ViewVertex {
virtual void Replace(ViewEdge *iOld, ViewEdge *iNew);
- /*! returns the mate edge of iEdgeA.
+ /** 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
*/
@@ -637,18 +637,18 @@ 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
+ /** 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
+ /** Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after
* the last ViewEdge.
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesEnd();
- /*! Returns an orientedViewEdgeIterator pointing to the ViewEdge given as argument. */
+ /** Returns an orientedViewEdgeIterator pointing to the ViewEdge given as argument. */
virtual ViewVertexInternal::orientedViewEdgeIterator edgesIterator(ViewEdge *iEdge);
#ifdef WITH_CXX_GUARDEDALLOC
@@ -665,7 +665,7 @@ class TVertex : public ViewVertex {
/**********************************/
// (non T vertex)
-/*! View vertex for corners, cusps, etc...
+/** View vertex for corners, cusps, etc...
* Associated to a single SVertex.
* Can be associated to 2 or several view edges
*/
@@ -674,80 +674,80 @@ class NonTVertex : public ViewVertex {
typedef vector<directedViewEdge> edges_container;
public: // Implementation of Interface0D
- /*! Returns the string "ViewVertex". */
+ /** Returns the string "ViewVertex". */
virtual string getExactTypeName() const
{
return "NonTVertex";
}
// Data access methods
- /*! Returns the 3D x coordinate of the vertex. */
+ /** Returns the 3D x coordinate of the vertex. */
virtual real getX() const
{
return _SVertex->point3D().x();
}
- /*! Returns the 3D y coordinate of the vertex. */
+ /** Returns the 3D y coordinate of the vertex. */
virtual real getY() const
{
return _SVertex->point3D().y();
}
- /*! Returns the 3D z coordinate of the vertex. */
+ /** Returns the 3D z coordinate of the vertex. */
virtual real getZ() const
{
return _SVertex->point3D().z();
}
- /*! Returns the 3D point. */
+ /** Returns the 3D point. */
virtual Vec3r getPoint3D() const
{
return _SVertex->getPoint3D();
}
- /*! Returns the projected 3D x coordinate of the vertex. */
+ /** Returns the projected 3D x coordinate of the vertex. */
virtual real getProjectedX() const
{
return _SVertex->point2D().x();
}
- /*! Returns the projected 3D y coordinate of the vertex. */
+ /** Returns the projected 3D y coordinate of the vertex. */
virtual real getProjectedY() const
{
return _SVertex->point2D().y();
}
- /*! Returns the projected 3D z coordinate of the vertex. */
+ /** Returns the projected 3D z coordinate of the vertex. */
virtual real getProjectedZ() const
{
return _SVertex->point2D().z();
}
- /*! Returns the 2D point. */
+ /** Returns the 2D point. */
virtual Vec2r getPoint2D() const
{
return _SVertex->getPoint2D();
}
- /*! Returns the Id of the vertex. */
+ /** Returns the Id of the vertex. */
virtual Id getId() const
{
return _SVertex->getId();
}
- /*! Cast the Interface0D in SVertex if it can be. */
+ /** Cast the Interface0D in SVertex if it can be. */
virtual SVertex *castToSVertex()
{
return _SVertex;
}
- /*! Cast the Interface0D in ViewVertex if it can be. */
+ /** Cast the Interface0D in ViewVertex if it can be. */
virtual ViewVertex *castToViewVertex()
{
return this;
}
- /*! Cast the Interface0D in NonTVertex if it can be. */
+ /** Cast the Interface0D in NonTVertex if it can be. */
virtual NonTVertex *castToNonTVertex()
{
return this;
@@ -758,13 +758,13 @@ class NonTVertex : public ViewVertex {
edges_container _ViewEdges;
public:
- /*! Default constructor.*/
+ /** Default constructor. */
inline NonTVertex() : ViewVertex(Nature::NON_T_VERTEX)
{
_SVertex = NULL;
}
- /*! Builds a NonTVertex from a SVertex. */
+ /** Builds a NonTVertex from a SVertex. */
inline NonTVertex(SVertex *iSVertex) : ViewVertex(Nature::NON_T_VERTEX)
{
_SVertex = iSVertex;
@@ -772,7 +772,7 @@ class NonTVertex : public ViewVertex {
}
protected:
- /*! Copy constructor. */
+ /** Copy constructor. */
inline NonTVertex(NonTVertex &iBrother) : ViewVertex(iBrother)
{
_SVertex = iBrother._SVertex;
@@ -780,7 +780,7 @@ class NonTVertex : public ViewVertex {
_ViewEdges = iBrother._ViewEdges;
}
- /*! Cloning method. */
+ /** Cloning method. */
virtual ViewVertex *duplicate()
{
NonTVertex *clone = new NonTVertex(*this);
@@ -788,13 +788,13 @@ class NonTVertex : public ViewVertex {
}
public:
- /*! destructor. */
+ /** destructor. */
virtual ~NonTVertex()
{
}
/* accessors */
- /*! Returns the SVertex on top of which this NonTVertex is built. */
+ /** Returns the SVertex on top of which this NonTVertex is built. */
inline SVertex *svertex()
{
return _SVertex;
@@ -806,7 +806,7 @@ class NonTVertex : public ViewVertex {
}
/* modifiers */
- /*! Sets the SVertex on top of which this NonTVertex is built. */
+ /** Sets the SVertex on top of which this NonTVertex is built. */
inline void setSVertex(SVertex *iSVertex)
{
_SVertex = iSVertex;
@@ -857,18 +857,18 @@ 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
+ /** 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
+ /** Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after
* the last ViewEdge.
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesEnd();
- /*! Returns an orientedViewEdgeIterator pointing to the ViewEdge given as argument. */
+ /** Returns an orientedViewEdgeIterator pointing to the ViewEdge given as argument. */
virtual ViewVertexInternal::orientedViewEdgeIterator edgesIterator(ViewEdge *iEdge);
#ifdef WITH_CXX_GUARDEDALLOC
@@ -902,25 +902,25 @@ 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
+/** 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
- /*! Returns the string "ViewEdge". */
+ /** Returns the string "ViewEdge". */
virtual string getExactTypeName() const
{
return "ViewEdge";
}
// Data access methods
- /*! Returns the Id of the vertex. */
+ /** Returns the Id of the vertex. */
virtual Id getId() const
{
return _Id;
}
- /*! Returns the nature of the ViewEdge. */
+ /** Returns the nature of the ViewEdge. */
virtual Nature::EdgeNature getNature() const
{
return _Nature;
@@ -960,12 +960,12 @@ class ViewEdge : public Interface1D {
Id *_splittingId;
public:
- /*! A field that can be used by the user to store any data.
+ /** A field that can be used by the user to store any data.
* This field must be reset afterwards using ResetUserData().
*/
void *userdata;
- /*! Default constructor. */
+ /** Default constructor. */
inline ViewEdge()
{
__A = NULL;
@@ -1028,7 +1028,7 @@ class ViewEdge : public Interface1D {
}
// soc protected:
- /*! Copy constructor. */
+ /** Copy constructor. */
inline ViewEdge(ViewEdge &iBrother)
{
__A = iBrother.__A;
@@ -1047,7 +1047,7 @@ class ViewEdge : public Interface1D {
userdata = NULL;
}
- /*! Cloning method. */
+ /** Cloning method. */
virtual ViewEdge *duplicate()
{
ViewEdge *clone = new ViewEdge(*this);
@@ -1055,7 +1055,7 @@ class ViewEdge : public Interface1D {
}
public:
- /*! Destructor. */
+ /** Destructor. */
virtual ~ViewEdge()
{
#if 0
@@ -1073,37 +1073,37 @@ class ViewEdge : public Interface1D {
}
/* accessors */
- /*! Returns the first ViewVertex. */
+ /** Returns the first ViewVertex. */
inline ViewVertex *A()
{
return __A;
}
- /*! Returns the second ViewVertex. */
+ /** Returns the second ViewVertex. */
inline ViewVertex *B()
{
return __B;
}
- /*! Returns the first FEdge that constitutes this ViewEdge. */
+ /** Returns the first FEdge that constitutes this ViewEdge. */
inline FEdge *fedgeA()
{
return _FEdgeA;
}
- /*! Returns the last FEdge that constitutes this ViewEdge. */
+ /** Returns the last FEdge that constitutes this ViewEdge. */
inline FEdge *fedgeB()
{
return _FEdgeB;
}
- /*! Returns the ViewShape to which this ViewEdge belongs to .*/
+ /** Returns the ViewShape to which this ViewEdge belongs to. */
inline ViewShape *viewShape()
{
return _Shape;
}
- /*! Returns the shape that is occluded by the ViewShape to which this ViewEdge belongs to. If no
+ /** 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()
@@ -1111,7 +1111,7 @@ class ViewEdge : public Interface1D {
return _aShape;
}
- /*! Tells whether this ViewEdge forms a closed loop or not. */
+ /** Tells whether this ViewEdge forms a closed loop or not. */
inline bool isClosed()
{
if (!__B) {
@@ -1120,7 +1120,7 @@ class ViewEdge : public Interface1D {
return false;
}
- /*! Returns the time stamp of this ViewEdge. */
+ /** Returns the time stamp of this ViewEdge. */
inline unsigned getChainingTimeStamp()
{
return _ChainingTimeStamp;
@@ -1152,64 +1152,64 @@ class ViewEdge : public Interface1D {
}
/* modifiers */
- /*! Sets the first ViewVertex of the ViewEdge. */
+ /** Sets the first ViewVertex of the ViewEdge. */
inline void setA(ViewVertex *iA)
{
__A = iA;
}
- /*! Sets the last ViewVertex of the ViewEdge. */
+ /** Sets the last ViewVertex of the ViewEdge. */
inline void setB(ViewVertex *iB)
{
__B = iB;
}
- /*! Sets the nature of the ViewEdge. */
+ /** Sets the nature of the ViewEdge. */
inline void setNature(Nature::EdgeNature iNature)
{
_Nature = iNature;
}
- /*! Sets the first FEdge of the ViewEdge. */
+ /** Sets the first FEdge of the ViewEdge. */
inline void setFEdgeA(FEdge *iFEdge)
{
_FEdgeA = iFEdge;
}
- /*! Sets the last FEdge of the ViewEdge. */
+ /** Sets the last FEdge of the ViewEdge. */
inline void setFEdgeB(FEdge *iFEdge)
{
_FEdgeB = iFEdge;
}
- /*! Sets the ViewShape to which this ViewEdge belongs to.*/
+ /** Sets the ViewShape to which this ViewEdge belongs to. */
inline void setShape(ViewShape *iVShape)
{
_Shape = iVShape;
}
- /*! Sets the ViewEdge id. */
+ /** Sets the ViewEdge id. */
inline void setId(const Id &id)
{
_Id = id;
}
- /*! Sets Viewedge to this for all embedded fedges */
+ /** Sets Viewedge to this for all embedded fedges */
void UpdateFEdges();
- /*! Sets the occluded ViewShape */
+ /** Sets the occluded ViewShape */
inline void setaShape(ViewShape *iShape)
{
_aShape = iShape;
}
- /*! Sets the quantitative invisibility value. */
+ /** Sets the quantitative invisibility value. */
inline void setQI(int qi)
{
_qi = qi;
}
- /*! Sets the time stamp value. */
+ /** Sets the time stamp value. */
inline void setChainingTimeStamp(unsigned ts)
{
_ChainingTimeStamp = ts;
@@ -1279,7 +1279,7 @@ class ViewEdge : public Interface1D {
float viewedge_length() const;
#endif
- /*! Returns the 2D length of the Viewedge. */
+ /** Returns the 2D length of the Viewedge. */
real getLength2D() const;
#if 0
@@ -1366,24 +1366,24 @@ class ViewEdge : public Interface1D {
vertex_iterator vertices_end();
// Iterator access (Interface1D)
- /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this
+ /** 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
+ /** 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
+ /** 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
+ /** 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.
@@ -1403,7 +1403,7 @@ class ViewEdge : public Interface1D {
/* */
/**********************************/
-/*! Class gathering the elements of the ViewMap (ViewVertex, ViewEdge) that are issued from the
+/** Class gathering the elements of the ViewMap (ViewVertex, ViewEdge) that are issued from the
* same input shape. */
class ViewShape {
private:
@@ -1412,19 +1412,19 @@ class ViewShape {
SShape *_SShape;
public:
- /*! A field that can be used by the user to store any data.
+ /** A field that can be used by the user to store any data.
* This field must be reset afterwards using ResetUserData().
*/
void *userdata;
- /*! Default constructor.*/
+ /** Default constructor. */
inline ViewShape()
{
userdata = NULL;
_SShape = NULL;
}
- /*! Builds a ViewShape from a SShape. */
+ /** Builds a ViewShape from a SShape. */
inline ViewShape(SShape *iSShape)
{
userdata = NULL;
@@ -1432,7 +1432,7 @@ class ViewShape {
//_SShape->setViewShape(this);
}
- /*! Copy constructor. */
+ /** Copy constructor. */
inline ViewShape(ViewShape &iBrother)
{
userdata = NULL;
@@ -1519,14 +1519,14 @@ class ViewShape {
}
}
- /*! Cloning method. */
+ /** Cloning method. */
virtual ViewShape *duplicate()
{
ViewShape *clone = new ViewShape(*this);
return clone;
}
- /*! Destructor. */
+ /** Destructor. */
virtual ~ViewShape();
/* splits a view edge into several view edges.
@@ -1545,75 +1545,75 @@ class ViewShape {
vector<ViewEdge *> &ioNewViewEdges);
/* accessors */
- /*! Returns the SShape on top of which this ViewShape is built. */
+ /** Returns the SShape on top of which this ViewShape is built. */
inline SShape *sshape()
{
return _SShape;
}
- /*! Returns the SShape on top of which this ViewShape is built. */
+ /** Returns the SShape on top of which this ViewShape is built. */
inline const SShape *sshape() const
{
return _SShape;
}
- /*! Returns the list of ViewVertex contained in this ViewShape. */
+ /** Returns the list of ViewVertex contained in this ViewShape. */
inline vector<ViewVertex *> &vertices()
{
return _Vertices;
}
- /*! Returns the list of ViewEdge contained in this ViewShape. */
+ /** Returns the list of ViewEdge contained in this ViewShape. */
inline vector<ViewEdge *> &edges()
{
return _Edges;
}
- /*! Returns the ViewShape id. */
+ /** Returns the ViewShape id. */
inline Id getId() const
{
return _SShape->getId();
}
- /*! Returns the ViewShape name. */
+ /** Returns the ViewShape name. */
inline const string &getName() const
{
return _SShape->getName();
}
- /*! Returns the ViewShape library path. */
+ /** Returns the ViewShape library path. */
inline const string &getLibraryPath() const
{
return _SShape->getLibraryPath();
}
/* modifiers */
- /*! Sets the SShape on top of which the ViewShape is built. */
+ /** Sets the SShape on top of which the ViewShape is built. */
inline void setSShape(SShape *iSShape)
{
_SShape = iSShape;
}
- /*! Sets the list of ViewVertex contained in this ViewShape. */
+ /** Sets the list of ViewVertex contained in this ViewShape. */
inline void setVertices(const vector<ViewVertex *> &iVertices)
{
_Vertices = iVertices;
}
- /*! Sets the list of ViewEdge contained in this ViewShape. */
+ /** Sets the list of ViewEdge contained in this ViewShape. */
inline void setEdges(const vector<ViewEdge *> &iEdges)
{
_Edges = iEdges;
}
- /*! Adds a ViewVertex to the list. */
+ /** Adds a ViewVertex to the list. */
inline void AddVertex(ViewVertex *iVertex)
{
_Vertices.push_back(iVertex);
//_SShape->AddNewVertex(iVertex->svertex());
}
- /*! Adds a ViewEdge to the list */
+ /** Adds a ViewEdge to the list */
inline void AddEdge(ViewEdge *iEdge)
{
_Edges.push_back(iEdge);
diff --git a/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h b/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
index 5cb52b6a0f3..b33bc4f281f 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
@@ -363,9 +363,9 @@ class edge_iterator_base : public IteratorBase<Traits, InputIteratorTag_Traits>
namespace ViewEdgeInternal {
-/*!----------------------*/
-/*! Iterators definition */
-/*!----------------------*/
+/**----------------------*/
+/** Iterators definition */
+/**----------------------*/
template<class Traits>
class edge_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag_Traits> {
public:
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.h b/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
index 6d919f5561a..4f26ec82eb6 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
@@ -107,28 +107,28 @@ class ViewMapBuilder {
}
/* Build Grid for ray casting */
- /*! Build non-culled Grid in camera space for ray casting */
+ /** Build non-culled Grid in camera space for ray casting */
void BuildGrid(WingedEdge &we, const BBox<Vec3r> &bbox, unsigned int sceneNumFaces);
- /*! Compute Shapes from a WingedEdge containing a list of WShapes */
+ /** Compute Shapes from a WingedEdge containing a list of WShapes */
void computeInitialViewEdges(WingedEdge &);
- /*! Compute Cusps */
+ /** Compute Cusps */
void computeCusps(ViewMap *ioViewMap);
- /*! Detects cusps (for a single ViewEdge) among SVertices and builds a ViewVertex on top of each
+ /** 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);
- /*! Sets the current viewpoint */
+ /** Sets the current viewpoint */
inline void setViewpoint(const Vec3r &ivp)
{
_viewpoint = ivp;
SilhouetteGeomEngine::setViewpoint(ivp);
}
- /*! Sets the current transformation
+ /** Sets the current transformation
* iModelViewMatrix
* The 4x4 model view matrix, in column major order (openGL like).
* iProjection matrix
@@ -153,7 +153,7 @@ class ViewMapBuilder {
SilhouetteGeomEngine::setFrustum(iZnear, iZfar);
}
- /*! Builds the scene view map returns the list the view map
+ /** Builds the scene view map returns the list the view map
* it is up to the caller to delete this ViewMap
* iWRoot
* The root group node containing the WEdge structured scene
@@ -169,7 +169,7 @@ class ViewMapBuilder {
real occluderProscenium[4],
bool extensiveFEdgeSearch = true);
- /*! computes the intersection between all 2D feature edges of the scene.
+ /** computes the intersection between all 2D feature edges of the scene.
* ioViewMap
* The view map. It is modified by the method.
* The list of all features edges of the scene.
@@ -181,7 +181,7 @@ class ViewMapBuilder {
intersection_algo iAlgo = sweep_line,
real epsilon = 1.0e-06);
- /*! Computes the 2D scene silhouette edges visibility
+ /** Computes the 2D scene silhouette edges visibility
* iGrid
* For the Ray Casting algorithm.
*/
@@ -197,9 +197,9 @@ class ViewMapBuilder {
_Grid = iGrid;
}
- /*! accessors */
+ /** accessors */
- /*! Modifiers */
+ /** Modifiers */
inline void setProgressBar(ProgressBar *iProgressBar)
{
_pProgressBar = iProgressBar;
@@ -216,10 +216,10 @@ class ViewMapBuilder {
}
protected:
- /*! Computes intersections on all edges of the scene using a sweep line algorithm */
+ /** 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
+ /** 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
@@ -242,7 +242,7 @@ class ViewMapBuilder {
bool cull,
GridDensityProviderFactory &factory);
- /*! Compute the visibility for the FEdge fe.
+ /** Compute the visibility for the FEdge fe.
* The occluders are added to fe occluders list.
* fe
* The FEdge
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIterators.h b/source/blender/freestyle/intern/view_map/ViewMapIterators.h
index 9956d47469d..1df78e71d9d 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapIterators.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapIterators.h
@@ -45,7 +45,7 @@ namespace Freestyle {
namespace ViewVertexInternal {
-/*! Class representing an iterator over oriented ViewEdges around a ViewVertex. This iterator
+/** 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().
*/
@@ -73,7 +73,7 @@ class orientedViewEdgeIterator : public Iterator {
edges_container::iterator _nontvertex_iter;
public:
- /*! Default constructor */
+ /** Default constructor */
inline orientedViewEdgeIterator()
{
}
@@ -83,7 +83,7 @@ class orientedViewEdgeIterator : public Iterator {
_Nature = iNature;
}
- /*! Copy constructor */
+ /** Copy constructor */
orientedViewEdgeIterator(const orientedViewEdgeIterator &iBrother)
{
_Nature = iBrother._Nature;
@@ -125,7 +125,7 @@ class orientedViewEdgeIterator : public Iterator {
}
public:
- /*! Tells whether the ViewEdge pointed by this iterator is the first one of the iteration list or
+ /** Tells whether the ViewEdge pointed by this iterator is the first one of the iteration list or
* not. */
virtual bool isBegin() const
{
@@ -137,7 +137,7 @@ class orientedViewEdgeIterator : public Iterator {
}
}
- /*! Tells whether the ViewEdge pointed by this iterator is after the last one of the iteration
+ /** Tells whether the ViewEdge pointed by this iterator is after the last one of the iteration
* list or not. */
virtual bool isEnd() const
{
@@ -150,7 +150,7 @@ class orientedViewEdgeIterator : public Iterator {
}
// operators
- /*! Increments. In the scripting language, call "increment()". */
+ /** Increments. In the scripting language, call "increment()". */
// operator corresponding to ++i
virtual orientedViewEdgeIterator &operator++()
{
@@ -168,7 +168,7 @@ class orientedViewEdgeIterator : public Iterator {
}
// comparibility
- /*! operator != */
+ /** operator != */
virtual bool operator!=(const orientedViewEdgeIterator &b) const
{
if (_Nature & Nature::T_VERTEX) {
@@ -179,14 +179,14 @@ class orientedViewEdgeIterator : public Iterator {
}
}
- /*! operator == */
+ /** operator == */
virtual bool operator==(const orientedViewEdgeIterator &b) const
{
return !(*this != b);
}
// dereferencing
- /*! Returns a reference to the pointed orientedViewEdge.
+ /** Returns a reference to the pointed orientedViewEdge.
* In the scripting language, you must call "getObject()" instead.
*/
virtual ViewVertex::directedViewEdge &operator*() const
@@ -199,7 +199,7 @@ class orientedViewEdgeIterator : public Iterator {
return (*_nontvertex_iter);
}
}
- /*! Returns a pointer to the pointed orientedViewEdge.
+ /** Returns a pointer to the pointed orientedViewEdge.
* Can't be called in the scripting language.
*/
virtual ViewVertex::directedViewEdge *operator->() const
@@ -208,7 +208,7 @@ class orientedViewEdgeIterator : public Iterator {
}
public:
- /*! increments.*/
+ /** increments. */
virtual inline int increment()
{
if (_Nature & Nature::T_VERTEX) {
@@ -415,14 +415,14 @@ class SVertexIterator : public Interface0DIteratorNested {
//
///////////////////////////////////////////////////////////
-/*! Base class for iterators over ViewEdges of the ViewMap Graph.
+/** 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.
* ::Caution::: the dereferencing operator returns a *pointer* to the pointed ViewEdge.
*/
class ViewEdgeIterator : public Iterator {
public:
- /*! Builds a ViewEdgeIterator from a starting ViewEdge and its orientation.
+ /** Builds a ViewEdgeIterator from a starting ViewEdge and its orientation.
* \param begin:
* The ViewEdge from where to start the iteration.
* \param orientation:
@@ -437,7 +437,7 @@ class ViewEdgeIterator : public Iterator {
_begin = begin;
}
- /*! Copy constructor */
+ /** Copy constructor */
ViewEdgeIterator(const ViewEdgeIterator &it)
{
_orientation = it._orientation;
@@ -449,55 +449,55 @@ class ViewEdgeIterator : public Iterator {
{
}
- /*! Returns the string "ViewEdgeIterator" */
+ /** Returns the string "ViewEdgeIterator" */
virtual string getExactTypeName() const
{
return "ViewEdgeIterator";
}
- /*! Returns the current pointed ViewEdge. */
+ /** Returns the current pointed ViewEdge. */
ViewEdge *getCurrentEdge()
{
return _edge;
}
- /*! Sets the current pointed ViewEdge. */
+ /** Sets the current pointed ViewEdge. */
void setCurrentEdge(ViewEdge *edge)
{
_edge = edge;
}
- /*! Returns the first ViewEdge used for the iteration. */
+ /** Returns the first ViewEdge used for the iteration. */
ViewEdge *getBegin()
{
return _begin;
}
- /*! Sets the first ViewEdge used for the iteration. */
+ /** Sets the first ViewEdge used for the iteration. */
void setBegin(ViewEdge *begin)
{
_begin = begin;
}
- /*! Gets the orientation of the pointed ViewEdge in the iteration. */
+ /** Gets the orientation of the pointed ViewEdge in the iteration. */
bool getOrientation() const
{
return _orientation;
}
- /*! Sets the orientation of the pointed ViewEdge in the iteration. */
+ /** Sets the orientation of the pointed ViewEdge in the iteration. */
void setOrientation(bool orientation)
{
_orientation = orientation;
}
- /*! Changes the current orientation. */
+ /** Changes the current orientation. */
void changeOrientation()
{
_orientation = !_orientation;
}
- /*! Returns a *pointer* to the pointed ViewEdge. */
+ /** Returns a *pointer* to the pointed ViewEdge. */
virtual ViewEdge *operator*()
{
return _edge;
@@ -508,14 +508,14 @@ class ViewEdgeIterator : public Iterator {
return operator*();
}
- /*! Increments. In the scripting language, call "increment()". */
+ /** Increments. In the scripting language, call "increment()". */
virtual ViewEdgeIterator &operator++()
{
increment();
return *this;
}
- /*! Increments. In the scripting language, call "increment()". */
+ /** Increments. In the scripting language, call "increment()". */
virtual ViewEdgeIterator operator++(int)
{
ViewEdgeIterator tmp(*this);
@@ -523,21 +523,21 @@ class ViewEdgeIterator : public Iterator {
return tmp;
}
- /*! increments. */
+ /** increments. */
virtual int increment()
{
cerr << "Warning: method increment() not implemented" << endl;
return 0;
}
- /*! Decrements. In the scripting language, call "decrement()". */
+ /** Decrements. In the scripting language, call "decrement()". */
virtual ViewEdgeIterator &operator--()
{
decrement();
return *this;
}
- /*! Decrements. In the scripting language, call "decrement()". */
+ /** Decrements. In the scripting language, call "decrement()". */
virtual ViewEdgeIterator operator--(int)
{
ViewEdgeIterator tmp(*this);
@@ -545,32 +545,32 @@ class ViewEdgeIterator : public Iterator {
return tmp;
}
- /*! decrements. */
+ /** decrements. */
virtual int decrement()
{
cerr << "Warning: method decrement() not implemented" << endl;
return 0;
}
- /*! Returns true if the pointed ViewEdge is the first one used for the iteration. */
+ /** Returns true if the pointed ViewEdge is the first one used for the iteration. */
virtual bool isBegin() const
{
return _edge == _begin;
}
- /*! Returns true if the pointed ViewEdge* equals 0. */
+ /** Returns true if the pointed ViewEdge* equals 0. */
virtual bool isEnd() const
{
return !_edge;
}
- /*! operator == */
+ /** operator == */
virtual bool operator==(ViewEdgeIterator &it) const
{
return _edge == it._edge;
}
- /*! operator != */
+ /** operator != */
virtual bool operator!=(ViewEdgeIterator &it) const
{
return !(*this == it);
diff --git a/source/blender/freestyle/intern/view_map/ViewMapTesselator.h b/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
index c6690b1d9dc..ff709879e74 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
@@ -56,17 +56,17 @@ class ViewMapTesselator {
{
}
- /*! Builds a set of lines rep contained under a a NodeShape, itself contained under a NodeGroup
+ /** 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
+ /** 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);
- /*! Builds a set of lines rep contained among a NodeShape, from a WShape */
+ /** Builds a set of lines rep contained among a NodeShape, from a WShape */
NodeGroup *Tesselate(WShape *iWShape);
inline void setNature(Nature::EdgeNature iNature)
@@ -103,7 +103,7 @@ class ViewMapTesselator {
#endif
};
-/*! Class to tesselate the 2D projected silhouette */
+/** Class to tesselate the 2D projected silhouette */
class ViewMapTesselator2D : public ViewMapTesselator {
public:
inline ViewMapTesselator2D() : ViewMapTesselator()
@@ -124,7 +124,7 @@ class ViewMapTesselator2D : public ViewMapTesselator {
#endif
};
-/*! Class to tesselate the 3D silhouette */
+/** Class to tesselate the 3D silhouette */
class ViewMapTesselator3D : public ViewMapTesselator {
public:
inline ViewMapTesselator3D() : ViewMapTesselator()
diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.cpp b/source/blender/freestyle/intern/winged_edge/Curvature.cpp
index 1984aceb51c..62d767fd2a1 100644
--- a/source/blender/freestyle/intern/winged_edge/Curvature.cpp
+++ b/source/blender/freestyle/intern/winged_edge/Curvature.cpp
@@ -104,7 +104,7 @@ static real angle_from_cotan(WVertex *vo, WVertex *v1, WVertex *v2)
return (fabs(atan2(denom, udotv)));
}
-/*! gts_vertex_mean_curvature_normal:
+/** gts_vertex_mean_curvature_normal:
* \param v: a #WVertex.
* \param s: a #GtsSurface.
* \param Kh: the Mean Curvature Normal at \a v.
@@ -175,7 +175,7 @@ bool gts_vertex_mean_curvature_normal(WVertex *v, Vec3r &Kh)
return true;
}
-/*! gts_vertex_gaussian_curvature:
+/** gts_vertex_gaussian_curvature:
* \param v: a #WVertex.
* \param s: a #GtsSurface.
* \param Kg: the Discrete Gaussian Curvature approximation at \a v.
@@ -226,7 +226,7 @@ bool gts_vertex_gaussian_curvature(WVertex *v, real *Kg)
return true;
}
-/*! gts_vertex_principal_curvatures:
+/** gts_vertex_principal_curvatures:
* @Kh: mean curvature.
* @Kg: Gaussian curvature.
* @K1: first principal curvature.
@@ -279,7 +279,7 @@ static void eigenvector(real a, real b, real c, Vec3r e)
e[2] = 0.0;
}
-/*! gts_vertex_principal_directions:
+/** gts_vertex_principal_directions:
* \param v: a #WVertex.
* \param s: a #GtsSurface.
* \param Kh: mean curvature normal (a #Vec3r).
diff --git a/source/blender/freestyle/intern/winged_edge/Nature.h b/source/blender/freestyle/intern/winged_edge/Nature.h
index 68323d7122c..996161abee2 100644
--- a/source/blender/freestyle/intern/winged_edge/Nature.h
+++ b/source/blender/freestyle/intern/winged_edge/Nature.h
@@ -23,44 +23,44 @@
namespace Freestyle {
-/*! Namespace gathering the different possible natures of 0D and 1D elements of the ViewMap */
+/** Namespace gathering the different possible natures of 0D and 1D elements of the ViewMap */
namespace Nature {
/* XXX Why not using enums??? */
/* In order to optimize for space (enum is int) - T.K. */
typedef unsigned short VertexNature;
-/*! true for any 0D element */
+/** true for any 0D element */
static const VertexNature POINT = 0; // 0
-/*! true for SVertex */
+/** true for SVertex */
static const VertexNature S_VERTEX = (1 << 0); // 1
-/*! true for ViewVertex */
+/** true for ViewVertex */
static const VertexNature VIEW_VERTEX = (1 << 1); // 2
-/*! true for NonTVertex */
+/** true for NonTVertex */
static const VertexNature NON_T_VERTEX = (1 << 2); // 4
-/*! true for TVertex */
+/** true for TVertex */
static const VertexNature T_VERTEX = (1 << 3); // 8
-/*! true for CUSP */
+/** true for CUSP */
static const VertexNature CUSP = (1 << 4); // 16
typedef unsigned short EdgeNature;
-/*! true for non feature edges (always false for 1D elements of the ViewMap) */
+/** true for non feature edges (always false for 1D elements of the ViewMap) */
static const EdgeNature NO_FEATURE = 0; // 0
-/*! true for silhouettes */
+/** true for silhouettes */
static const EdgeNature SILHOUETTE = (1 << 0); // 1
-/*! true for borders */
+/** true for borders */
static const EdgeNature BORDER = (1 << 1); // 2
-/*! true for creases */
+/** true for creases */
static const EdgeNature CREASE = (1 << 2); // 4
-/*! true for ridges */
+/** true for ridges */
static const EdgeNature RIDGE = (1 << 3); // 8
-/*! true for valleys */
+/** true for valleys */
static const EdgeNature VALLEY = (1 << 4); // 16
-/*! true for suggestive contours */
+/** true for suggestive contours */
static const EdgeNature SUGGESTIVE_CONTOUR = (1 << 5); // 32
-/*! true for material boundaries */
+/** true for material boundaries */
static const EdgeNature MATERIAL_BOUNDARY = (1 << 6); // 64
-/*! true for user-defined edge marks */
+/** true for user-defined edge marks */
static const EdgeNature EDGE_MARK = (1 << 7); // 128
} // end of namespace Nature
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.cpp b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
index 0811fe336b7..356b641a254 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
@@ -25,7 +25,7 @@
namespace Freestyle {
-/*! Temporary structures */
+/** Temporary structures */
class vertexdata {
public:
WVertex *_copy;
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.h b/source/blender/freestyle/intern/winged_edge/WEdge.h
index 42a8e62990f..adc08f60ddf 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.h
@@ -76,14 +76,14 @@ class WVertex {
_Border = -1;
}
- /*! Copy constructor */
+ /** Copy constructor */
WVertex(WVertex &iBrother);
virtual WVertex *duplicate();
virtual ~WVertex()
{
}
- /*! accessors */
+ /** accessors */
inline Vec3f &GetVertex()
{
return _Vertex;
@@ -111,7 +111,7 @@ class WVertex {
bool isBoundary();
- /*! modifiers */
+ /** modifiers */
inline void setVertex(const Vec3f &v)
{
_Vertex = v;
@@ -147,7 +147,7 @@ class WVertex {
}
}
- /*! Adds an edge to the edges list */
+ /** Adds an edge to the edges list */
void AddEdge(WEdge *iEdge);
virtual void ResetUserData()
@@ -156,7 +156,7 @@ class WVertex {
}
public:
- /*! Iterator to iterate over a vertex incoming edges in the CCW order*/
+ /** Iterator to iterate over a vertex incoming edges in the CCW order. */
#if defined(__GNUC__) && (__GNUC__ < 3)
class incoming_edge_iterator : public input_iterator<WOEdge *, ptrdiff_t>
#else
@@ -247,7 +247,7 @@ class WVertex {
#endif
};
- /*! Iterator to iterate over a vertex faces in the CCW order */
+ /** Iterator to iterate over a vertex faces in the CCW order */
#if defined(__GNUC__) && (__GNUC__ < 3)
class face_iterator : public input_iterator<WFace *, ptrdiff_t>
#else
@@ -336,7 +336,7 @@ class WVertex {
};
public:
- /*! iterators access */
+ /** iterators access */
virtual incoming_edge_iterator incoming_edges_begin();
virtual incoming_edge_iterator incoming_edges_end();
@@ -404,11 +404,11 @@ class WOEdge {
virtual ~WOEdge(){}; // soc
- /*! copy constructor */
+ /** copy constructor */
WOEdge(WOEdge &iBrother);
virtual WOEdge *duplicate();
- /*! accessors */
+ /** accessors */
#if 0
inline WOEdge *GetaCWEdge()
{
@@ -466,7 +466,7 @@ class WOEdge {
return _angle;
}
- /*! modifiers */
+ /** modifiers */
#if 0
inline void SetaCWEdge(WOEdge *pe)
{
@@ -520,7 +520,7 @@ class WOEdge {
_pOwner = pe;
}
- /*! Retrieves the list of edges in CW order */
+ /** Retrieves the list of edges in CW order */
inline void RetrieveCWOrderedEdges(vector<WEdge *> &oEdges);
WOEdge *twin();
@@ -579,7 +579,7 @@ class WEdge {
userdata = NULL;
}
- /*! Copy constructor */
+ /** Copy constructor */
WEdge(WEdge &iBrother);
virtual WEdge *duplicate();
@@ -596,7 +596,7 @@ class WEdge {
}
}
- /*! checks whether two WEdge have a common vertex.
+ /** checks whether two WEdge have a common vertex.
* Returns a pointer on the common vertex if it exists, NULL otherwise.
*/
static inline WVertex *CommonVertex(WEdge *iEdge1, WEdge *iEdge2)
@@ -619,7 +619,7 @@ class WEdge {
return NULL;
}
- /*! accessors */
+ /** accessors */
inline WOEdge *GetaOEdge()
{
return _paOEdge;
@@ -675,7 +675,7 @@ class WEdge {
}
}
- /*! modifiers */
+ /** modifiers */
inline void setaOEdge(WOEdge *iEdge)
{
_paOEdge = iEdge;
@@ -754,14 +754,14 @@ class WFace {
_FrsMaterialIndex = 0;
}
- /*! copy constructor */
+ /** copy constructor */
WFace(WFace &iBrother);
virtual WFace *duplicate();
virtual ~WFace()
{
}
- /*! accessors */
+ /** accessors */
inline const vector<WOEdge *> &getEdgeList()
{
return _OEdgeList;
@@ -794,7 +794,7 @@ class WFace {
const FrsMaterial &frs_material();
- /*! The vertex of index i corresponds to the a vertex of the edge of index i */
+ /** The vertex of index i corresponds to the a vertex of the edge of index i */
inline WVertex *GetVertex(unsigned int index)
{
#if 0
@@ -805,7 +805,7 @@ class WFace {
return _OEdgeList[index]->GetaVertex();
}
- /*! returns the index at which iVertex is stored in the array.
+ /** returns the index at which iVertex is stored in the array.
* returns -1 if iVertex doesn't belong to the face.
*/
inline int GetIndex(WVertex *iVertex)
@@ -868,19 +868,19 @@ class WFace {
return _VerticesTexCoords;
}
- /*! Returns the normal of the vertex of index index */
+ /** Returns the normal of the vertex of `index`. */
inline Vec3f &GetVertexNormal(int index)
{
return _VerticesNormals[index];
}
- /*! Returns the tex coords of the vertex of index index */
+ /** Returns the tex coords of the vertex of `index`. */
inline Vec2f &GetVertexTexCoords(int index)
{
return _VerticesTexCoords[index];
}
- /*! Returns the normal of the vertex iVertex for that face */
+ /** Returns the normal of the vertex iVertex for that face */
inline Vec3f &GetVertexNormal(WVertex *iVertex)
{
int i = 0;
@@ -933,7 +933,7 @@ class WFace {
return _OEdgeList.size();
}
- /*! Returns true if the face has one ot its edge which is a border edge */
+ /** Returns true if the face has one ot its edge which is a border edge */
inline bool isBorder() const
{
for (vector<WOEdge *>::const_iterator woe = _OEdgeList.begin(), woeend = _OEdgeList.end();
@@ -946,7 +946,7 @@ class WFace {
return false;
}
- /*! modifiers */
+ /** modifiers */
inline void setEdgeList(const vector<WOEdge *> &iEdgeList)
{
_OEdgeList = iEdgeList;
@@ -982,13 +982,13 @@ class WFace {
_Mark = iMark;
}
- /*! designed to build a specialized WEdge for use in MakeEdge */
+ /** designed to build a specialized WEdge for use in MakeEdge */
virtual WEdge *instanciateEdge() const
{
return new WEdge;
}
- /*! Builds an oriented edge
+ /** Builds an oriented edge
* Returns the built edge.
* v1, v2
* Vertices at the edge's extremities
@@ -996,18 +996,18 @@ class WFace {
*/
virtual WOEdge *MakeEdge(WVertex *v1, WVertex *v2);
- /*! Adds an edge to the edges list */
+ /** Adds an edge to the edges list */
inline void AddEdge(WOEdge *iEdge)
{
_OEdgeList.push_back(iEdge);
}
- /*! For triangles, returns the edge opposite to the vertex in e.
+ /** For triangles, returns the edge opposite to the vertex in e.
* returns false if the face is not a triangle or if the vertex is not found
*/
bool getOppositeEdge(const WVertex *v, WOEdge *&e);
- /*! compute the area of the face */
+ /** compute the area of the face */
float getArea();
WShape *getShape();
@@ -1057,7 +1057,7 @@ class WShape {
_SceneCurrentId++;
}
- /*! copy constructor */
+ /** copy constructor */
WShape(WShape &iBrother);
virtual WShape *duplicate();
@@ -1088,7 +1088,7 @@ class WShape {
}
}
- /*! accessors */
+ /** accessors */
inline vector<WEdge *> &getEdgeList()
{
return _EdgeList;
@@ -1144,7 +1144,7 @@ class WShape {
return _LibraryPath;
}
- /*! modifiers */
+ /** modifiers */
static inline void setCurrentId(const unsigned id)
{
_SceneCurrentId = id;
@@ -1198,13 +1198,13 @@ class WShape {
_LibraryPath = path;
}
- /*! designed to build a specialized WFace for use in MakeFace */
+ /** designed to build a specialized WFace for use in MakeFace */
virtual WFace *instanciateFace() const
{
return new WFace;
}
- /*! adds a new face to the shape
+ /** 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
@@ -1217,7 +1217,7 @@ 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
+ /** 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
@@ -1309,7 +1309,7 @@ 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;
diff --git a/source/blender/freestyle/intern/winged_edge/WFillGrid.h b/source/blender/freestyle/intern/winged_edge/WFillGrid.h
index 095a58675c0..9398a63333f 100644
--- a/source/blender/freestyle/intern/winged_edge/WFillGrid.h
+++ b/source/blender/freestyle/intern/winged_edge/WFillGrid.h
@@ -47,7 +47,7 @@ class WFillGrid {
void fillGrid();
- /*! Accessors */
+ /** Accessors */
WingedEdge *getWingedEdge()
{
return _winged_edge;
@@ -58,7 +58,7 @@ class WFillGrid {
return _grid;
}
- /*! Modifiers */
+ /** Modifiers */
void setWingedEdge(WingedEdge *winged_edge)
{
if (winged_edge) {
diff --git a/source/blender/freestyle/intern/winged_edge/WSFillGrid.h b/source/blender/freestyle/intern/winged_edge/WSFillGrid.h
index 5393f57d2cd..d4e7f3ca76b 100644
--- a/source/blender/freestyle/intern/winged_edge/WSFillGrid.h
+++ b/source/blender/freestyle/intern/winged_edge/WSFillGrid.h
@@ -43,7 +43,7 @@ class WSFillGrid {
void fillGrid();
- /*! Accessors */
+ /** Accessors */
WingedEdge *getWingedEdge()
{
return _winged_edge;
@@ -54,7 +54,7 @@ class WSFillGrid {
return _grid;
}
- /*! Modifiers */
+ /** Modifiers */
void setWingedEdge(WingedEdge *winged_edge)
{
if (winged_edge) {
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.h b/source/blender/freestyle/intern/winged_edge/WXEdge.h
index 8fe99f9bb93..f95913c23f3 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.h
@@ -52,7 +52,7 @@ class WXVertex : public WVertex {
_curvatures = NULL;
}
- /*! Copy constructor */
+ /** Copy constructor */
WXVertex(WXVertex &iBrother) : WVertex(iBrother)
{
_curvatures = new CurvatureInfo(*iBrother._curvatures);
@@ -135,7 +135,7 @@ class WXEdge : public WEdge {
_order = 0;
}
- /*! Copy constructor */
+ /** Copy constructor */
inline WXEdge(WXEdge &iBrother) : WEdge(iBrother)
{
_nature = iBrother.nature();
@@ -159,7 +159,7 @@ class WXEdge : public WEdge {
_nature = _nature & ~Nature::SUGGESTIVE_CONTOUR;
}
- /*! accessors */
+ /** accessors */
inline WXNature nature()
{
return _nature;
@@ -175,7 +175,7 @@ class WXEdge : public WEdge {
return _order;
}
- /*! modifiers */
+ /** modifiers */
inline void setFront(bool iFront)
{
_front = iFront;
@@ -209,7 +209,7 @@ class WXEdge : public WEdge {
* *
**********************************/
-/*! Class to store a smooth edge (i.e Hertzman & Zorin smooth silhouette edges) */
+/** Class to store a smooth edge (i.e Hertzman & Zorin smooth silhouette edges) */
class WXSmoothEdge {
public:
typedef unsigned short Configuration;
@@ -278,7 +278,7 @@ class WXSmoothEdge {
return _config;
}
- /*! modifiers */
+ /** modifiers */
inline void setWOeA(WOEdge *iwoea)
{
_woea = iwoea;
@@ -439,15 +439,15 @@ class WXFaceLayer {
}
}
- /*! If one of the face layer vertex has a DotP equal to 0, this method returns the vertex where
+ /** 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
+ /** 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
+ /** 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 extremity
*/
void RetrieveCuspEdgesIndices(vector<int> &oCuspEdges);
@@ -512,7 +512,7 @@ class WXFace : public WFace {
_front = false;
}
- /*! Copy constructor */
+ /** Copy constructor */
WXFace(WXFace &iBrother) : WFace(iBrother)
{
_center = iBrother.center();
@@ -545,13 +545,13 @@ class WXFace : public WFace {
}
}
- /*! designed to build a specialized WEdge for use in MakeEdge */
+ /** designed to build a specialized WEdge for use in MakeEdge */
virtual WEdge *instanciateEdge() const
{
return new WXEdge;
}
- /*! accessors */
+ /** accessors */
inline Vec3f &center()
{
return _center;
@@ -590,7 +590,7 @@ class WXFace : public WFace {
return _SmoothLayers;
}
- /*! retrieve the smooth edges that match the Nature given as argument */
+ /** retrieve the smooth edges that match the Nature given as argument */
void retrieveSmoothEdges(WXNature iNature, vector<WXSmoothEdge *> &oSmoothEdges)
{
for (vector<WXFaceLayer *>::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end();
@@ -624,7 +624,7 @@ class WXFace : public WFace {
}
}
- /*! modifiers */
+ /** modifiers */
inline void setCenter(const Vec3f &iCenter)
{
_center = iCenter;
@@ -674,7 +674,7 @@ class WXFace : public WFace {
_SmoothLayers = layersToKeep;
}
- /*! Clears everything */
+ /** Clears everything */
inline void Clear()
{
for (vector<WXFaceLayer *>::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end();
@@ -724,7 +724,7 @@ class WXShape : public WShape {
_computeViewIndependent = true;
}
- /*! copy constructor */
+ /** copy constructor */
inline WXShape(WXShape &iBrother) : WShape(iBrother)
{
_computeViewIndependent = iBrother._computeViewIndependent;
@@ -750,13 +750,13 @@ class WXShape : public WShape {
_computeViewIndependent = iFlag;
}
- /*! designed to build a specialized WFace for use in MakeFace */
+ /** designed to build a specialized WFace for use in MakeFace */
virtual WFace *instanciateFace() const
{
return new WXFace;
}
- /*!
+ /**
* Adds a new face to the shape returns the built face.
* - iVertexList
* List of face's vertices.
@@ -768,7 +768,7 @@ class WXShape : public 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.
@@ -792,7 +792,7 @@ class WXShape : public WShape {
vector<bool> &iFaceEdgeMarksList,
unsigned iMaterialIndex);
- /*! Reset all edges and vertices flags (which might have been set up on a previous pass) */
+ /** Reset all edges and vertices flags (which might have been set up on a previous pass) */
virtual void Reset()
{
// Reset Edges
@@ -807,7 +807,7 @@ class WXShape : public WShape {
((WXFace *)(*wf))->Reset();
}
}
- /*! accessors */
+ /** accessors */
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:WXShape")
diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh
index 14eab2704e9..4de0533a46d 100644
--- a/source/blender/functions/FN_cpp_type.hh
+++ b/source/blender/functions/FN_cpp_type.hh
@@ -19,10 +19,9 @@
/** \file
* \ingroup fn
*
- * The CPPType class is the core of the runtime-type-system used by the functions system. It can
- * represent C++ types that are default-constructible, destructible, movable, copyable,
- * equality comparable and hashable. In the future we might want to make some of these properties
- * optional.
+ * The `CPPType` class is the core of a runtime-type-system. It allows working with arbitrary C++
+ * types in a generic way. An instance of `CPPType` wraps exactly one type like `int` or
+ * `std::string`.
*
* Every type has a size and an alignment. Every function dealing with C++ types in a generic way,
* has to make sure that alignment rules are followed. The methods provided by a CPPType instance
@@ -35,11 +34,11 @@
*
* A CPPType instance comes with many methods that allow dealing with types in a generic way. Most
* methods come in three variants. Using the construct-default methods as example:
- * - construct_default(void *ptr):
+ * - default_construct(void *ptr):
* Constructs a single instance of that type at the given pointer.
- * - construct_default_n(void *ptr, int64_t n):
+ * - default_construct_n(void *ptr, int64_t n):
* Constructs n instances of that type in an array that starts at the given pointer.
- * - construct_default_indices(void *ptr, IndexMask mask):
+ * - default_construct_indices(void *ptr, IndexMask mask):
* Constructs multiple instances of that type in an array that starts at the given pointer.
* Only the indices referenced by `mask` will by constructed.
*
@@ -58,7 +57,7 @@
* used now with explicit function pointers to work better. Here are some reasons:
* - If CPPType would be inherited once for every used C++ type, we would get a lot of classes
* that would only be instanced once each.
- * - Methods like `construct_default` that operate on a single instance have to be fast. Even this
+ * - Methods like `default_construct` that operate on a single instance have to be fast. Even this
* one necessary indirection using function pointers adds a lot of overhead. If all methods were
* virtual, there would be a second level of indirection that increases the overhead even more.
* - If it becomes necessary, we could pass the function pointers to C functions more easily than
@@ -73,177 +72,61 @@
namespace blender::fn {
-class CPPType : NonCopyable, NonMovable {
- public:
- using ConstructDefaultF = void (*)(void *ptr);
- using ConstructDefaultNF = void (*)(void *ptr, int64_t n);
- using ConstructDefaultIndicesF = void (*)(void *ptr, IndexMask mask);
-
- using DestructF = void (*)(void *ptr);
- using DestructNF = void (*)(void *ptr, int64_t n);
- using DestructIndicesF = void (*)(void *ptr, IndexMask mask);
-
- using CopyToInitializedF = void (*)(const void *src, void *dst);
- using CopyToInitializedNF = void (*)(const void *src, void *dst, int64_t n);
- using CopyToInitializedIndicesF = void (*)(const void *src, void *dst, IndexMask mask);
-
- using CopyToUninitializedF = void (*)(const void *src, void *dst);
- using CopyToUninitializedNF = void (*)(const void *src, void *dst, int64_t n);
- using CopyToUninitializedIndicesF = void (*)(const void *src, void *dst, IndexMask mask);
+struct CPPTypeMembers {
+ int64_t size = 0;
+ int64_t alignment = 0;
+ uintptr_t alignment_mask = 0;
+ bool is_trivially_destructible = false;
+ bool has_special_member_functions = false;
- using MoveToInitializedF = void (*)(void *src, void *dst);
- using MoveToInitializedNF = void (*)(void *src, void *dst, int64_t n);
- using MoveToInitializedIndicesF = void (*)(void *src, void *dst, IndexMask mask);
+ void (*default_construct)(void *ptr) = nullptr;
+ void (*default_construct_indices)(void *ptr, IndexMask mask) = nullptr;
- using MoveToUninitializedF = void (*)(void *src, void *dst);
- using MoveToUninitializedNF = void (*)(void *src, void *dst, int64_t n);
- using MoveToUninitializedIndicesF = void (*)(void *src, void *dst, IndexMask mask);
+ void (*destruct)(void *ptr) = nullptr;
+ void (*destruct_indices)(void *ptr, IndexMask mask) = nullptr;
- using RelocateToInitializedF = void (*)(void *src, void *dst);
- using RelocateToInitializedNF = void (*)(void *src, void *dst, int64_t n);
- using RelocateToInitializedIndicesF = void (*)(void *src, void *dst, IndexMask mask);
+ void (*copy_assign)(const void *src, void *dst) = nullptr;
+ void (*copy_assign_indices)(const void *src, void *dst, IndexMask mask) = nullptr;
- using RelocateToUninitializedF = void (*)(void *src, void *dst);
- using RelocateToUninitializedNF = void (*)(void *src, void *dst, int64_t n);
- using RelocateToUninitializedIndicesF = void (*)(void *src, void *dst, IndexMask mask);
-
- using FillInitializedF = void (*)(const void *value, void *dst, int64_t n);
- using FillInitializedIndicesF = void (*)(const void *value, void *dst, IndexMask mask);
-
- using FillUninitializedF = void (*)(const void *value, void *dst, int64_t n);
- using FillUninitializedIndicesF = void (*)(const void *value, void *dst, IndexMask mask);
-
- using DebugPrintF = void (*)(const void *value, std::stringstream &ss);
- using IsEqualF = bool (*)(const void *a, const void *b);
- using HashF = uint64_t (*)(const void *value);
-
- private:
- int64_t size_;
- int64_t alignment_;
- uintptr_t alignment_mask_;
- bool is_trivially_destructible_;
+ void (*copy_construct)(const void *src, void *dst) = nullptr;
+ void (*copy_construct_indices)(const void *src, void *dst, IndexMask mask) = nullptr;
- ConstructDefaultF construct_default_;
- ConstructDefaultNF construct_default_n_;
- ConstructDefaultIndicesF construct_default_indices_;
+ void (*move_assign)(void *src, void *dst) = nullptr;
+ void (*move_assign_indices)(void *src, void *dst, IndexMask mask) = nullptr;
- DestructF destruct_;
- DestructNF destruct_n_;
- DestructIndicesF destruct_indices_;
+ void (*move_construct)(void *src, void *dst) = nullptr;
+ void (*move_construct_indices)(void *src, void *dst, IndexMask mask) = nullptr;
- CopyToInitializedF copy_to_initialized_;
- CopyToInitializedNF copy_to_initialized_n_;
- CopyToInitializedIndicesF copy_to_initialized_indices_;
+ void (*relocate_assign)(void *src, void *dst) = nullptr;
+ void (*relocate_assign_indices)(void *src, void *dst, IndexMask mask) = nullptr;
- CopyToUninitializedF copy_to_uninitialized_;
- CopyToUninitializedNF copy_to_uninitialized_n_;
- CopyToUninitializedIndicesF copy_to_uninitialized_indices_;
+ void (*relocate_construct)(void *src, void *dst) = nullptr;
+ void (*relocate_construct_indices)(void *src, void *dst, IndexMask mask) = nullptr;
- MoveToInitializedF move_to_initialized_;
- MoveToInitializedNF move_to_initialized_n_;
- MoveToInitializedIndicesF move_to_initialized_indices_;
+ void (*fill_assign_indices)(const void *value, void *dst, IndexMask mask) = nullptr;
- MoveToUninitializedF move_to_uninitialized_;
- MoveToUninitializedNF move_to_uninitialized_n_;
- MoveToUninitializedIndicesF move_to_uninitialized_indices_;
+ void (*fill_construct_indices)(const void *value, void *dst, IndexMask mask) = nullptr;
- RelocateToInitializedF relocate_to_initialized_;
- RelocateToInitializedNF relocate_to_initialized_n_;
- RelocateToInitializedIndicesF relocate_to_initialized_indices_;
+ void (*print)(const void *value, std::stringstream &ss) = nullptr;
+ bool (*is_equal)(const void *a, const void *b) = nullptr;
+ uint64_t (*hash)(const void *value) = nullptr;
- RelocateToUninitializedF relocate_to_uninitialized_;
- RelocateToUninitializedNF relocate_to_uninitialized_n_;
- RelocateToUninitializedIndicesF relocate_to_uninitialized_indices_;
-
- FillInitializedF fill_initialized_;
- FillInitializedIndicesF fill_initialized_indices_;
-
- FillUninitializedF fill_uninitialized_;
- FillUninitializedIndicesF fill_uninitialized_indices_;
-
- DebugPrintF debug_print_;
- IsEqualF is_equal_;
- HashF hash_;
+ const void *default_value = nullptr;
+ std::string name;
+};
- const void *default_value_;
- std::string name_;
+class CPPType : NonCopyable, NonMovable {
+ private:
+ CPPTypeMembers m_;
public:
- CPPType(std::string name,
- int64_t size,
- int64_t alignment,
- bool is_trivially_destructible,
- ConstructDefaultF construct_default,
- ConstructDefaultNF construct_default_n,
- ConstructDefaultIndicesF construct_default_indices,
- DestructF destruct,
- DestructNF destruct_n,
- DestructIndicesF destruct_indices,
- CopyToInitializedF copy_to_initialized,
- CopyToInitializedNF copy_to_initialized_n,
- CopyToInitializedIndicesF copy_to_initialized_indices,
- CopyToUninitializedF copy_to_uninitialized,
- CopyToUninitializedNF copy_to_uninitialized_n,
- CopyToUninitializedIndicesF copy_to_uninitialized_indices,
- MoveToInitializedF move_to_initialized,
- MoveToInitializedNF move_to_initialized_n,
- MoveToInitializedIndicesF move_to_initialized_indices,
- MoveToUninitializedF move_to_uninitialized,
- MoveToUninitializedNF move_to_uninitialized_n,
- MoveToUninitializedIndicesF move_to_uninitialized_indices,
- RelocateToInitializedF relocate_to_initialized,
- RelocateToInitializedNF relocate_to_initialized_n,
- RelocateToInitializedIndicesF relocate_to_initialized_indices,
- RelocateToUninitializedF relocate_to_uninitialized,
- RelocateToUninitializedNF relocate_to_uninitialized_n,
- RelocateToUninitializedIndicesF relocate_to_uninitialized_indices,
- FillInitializedF fill_initialized,
- FillInitializedIndicesF fill_initialized_indices,
- FillUninitializedF fill_uninitialized,
- FillUninitializedIndicesF fill_uninitialized_indices,
- DebugPrintF debug_print,
- IsEqualF is_equal,
- HashF hash,
- const void *default_value)
- : size_(size),
- alignment_(alignment),
- is_trivially_destructible_(is_trivially_destructible),
- construct_default_(construct_default),
- construct_default_n_(construct_default_n),
- construct_default_indices_(construct_default_indices),
- destruct_(destruct),
- destruct_n_(destruct_n),
- destruct_indices_(destruct_indices),
- copy_to_initialized_(copy_to_initialized),
- copy_to_initialized_n_(copy_to_initialized_n),
- copy_to_initialized_indices_(copy_to_initialized_indices),
- copy_to_uninitialized_(copy_to_uninitialized),
- copy_to_uninitialized_n_(copy_to_uninitialized_n),
- copy_to_uninitialized_indices_(copy_to_uninitialized_indices),
- move_to_initialized_(move_to_initialized),
- move_to_initialized_n_(move_to_initialized_n),
- move_to_initialized_indices_(move_to_initialized_indices),
- move_to_uninitialized_(move_to_uninitialized),
- move_to_uninitialized_n_(move_to_uninitialized_n),
- move_to_uninitialized_indices_(move_to_uninitialized_indices),
- relocate_to_initialized_(relocate_to_initialized),
- relocate_to_initialized_n_(relocate_to_initialized_n),
- relocate_to_initialized_indices_(relocate_to_initialized_indices),
- relocate_to_uninitialized_(relocate_to_uninitialized),
- relocate_to_uninitialized_n_(relocate_to_uninitialized_n),
- relocate_to_uninitialized_indices_(relocate_to_uninitialized_indices),
- fill_initialized_(fill_initialized),
- fill_initialized_indices_(fill_initialized_indices),
- fill_uninitialized_(fill_uninitialized),
- fill_uninitialized_indices_(fill_uninitialized_indices),
- debug_print_(debug_print),
- is_equal_(is_equal),
- hash_(hash),
- default_value_(default_value),
- name_(name)
- {
- BLI_assert(is_power_of_2_i(alignment_));
- alignment_mask_ = (uintptr_t)alignment_ - (uintptr_t)1;
+ CPPType(CPPTypeMembers members) : m_(std::move(members))
+ {
+ BLI_assert(is_power_of_2_i(m_.alignment));
+ m_.alignment_mask = (uintptr_t)members.alignment - (uintptr_t)1;
+ m_.has_special_member_functions = (m_.default_construct && m_.copy_construct &&
+ m_.copy_assign && m_.move_construct && m_.move_assign &&
+ m_.destruct);
}
/**
@@ -273,7 +156,7 @@ class CPPType : NonCopyable, NonMovable {
*/
StringRefNull name() const
{
- return name_;
+ return m_.name;
}
/**
@@ -284,7 +167,7 @@ class CPPType : NonCopyable, NonMovable {
*/
int64_t size() const
{
- return size_;
+ return m_.size;
}
/**
@@ -295,7 +178,7 @@ class CPPType : NonCopyable, NonMovable {
*/
int64_t alignment() const
{
- return alignment_;
+ return m_.alignment;
}
/**
@@ -307,7 +190,66 @@ class CPPType : NonCopyable, NonMovable {
*/
bool is_trivially_destructible() const
{
- return is_trivially_destructible_;
+ return m_.is_trivially_destructible;
+ }
+
+ bool is_default_constructible() const
+ {
+ return m_.default_construct != nullptr;
+ }
+
+ bool is_copy_constructible() const
+ {
+ return m_.copy_assign != nullptr;
+ }
+
+ bool is_move_constructible() const
+ {
+ return m_.move_assign != nullptr;
+ }
+
+ bool is_destructible() const
+ {
+ return m_.destruct != nullptr;
+ }
+
+ bool is_copy_assignable() const
+ {
+ return m_.copy_assign != nullptr;
+ }
+
+ bool is_move_assignable() const
+ {
+ return m_.copy_construct != nullptr;
+ }
+
+ bool is_printable() const
+ {
+ return m_.print != nullptr;
+ }
+
+ bool is_equality_comparable() const
+ {
+ return m_.is_equal != nullptr;
+ }
+
+ bool is_hashable() const
+ {
+ return m_.hash != nullptr;
+ }
+
+ /**
+ * Returns true, when the type has the following functions:
+ * - Default constructor.
+ * - Copy constructor.
+ * - Move constructor.
+ * - Copy assignment operator.
+ * - Move assignment operator.
+ * - Destructor.
+ */
+ bool has_special_member_functions() const
+ {
+ return m_.has_special_member_functions;
}
/**
@@ -315,7 +257,7 @@ class CPPType : NonCopyable, NonMovable {
*/
bool pointer_has_valid_alignment(const void *ptr) const
{
- return ((uintptr_t)ptr & alignment_mask_) == 0;
+ return ((uintptr_t)ptr & m_.alignment_mask) == 0;
}
bool pointer_can_point_to_instance(const void *ptr) const
@@ -331,25 +273,23 @@ class CPPType : NonCopyable, NonMovable {
* C++ equivalent:
* new (ptr) T;
*/
- void construct_default(void *ptr) const
+ void default_construct(void *ptr) const
{
BLI_assert(this->pointer_can_point_to_instance(ptr));
- construct_default_(ptr);
+ m_.default_construct(ptr);
}
- void construct_default_n(void *ptr, int64_t n) const
+ void default_construct_n(void *ptr, int64_t n) const
{
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(ptr));
-
- construct_default_n_(ptr, n);
+ this->default_construct_indices(ptr, IndexMask(n));
}
- void construct_default_indices(void *ptr, IndexMask mask) const
+ void default_construct_indices(void *ptr, IndexMask mask) const
{
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(ptr));
- construct_default_indices_(ptr, mask);
+ m_.default_construct_indices(ptr, mask);
}
/**
@@ -364,26 +304,19 @@ class CPPType : NonCopyable, NonMovable {
{
BLI_assert(this->pointer_can_point_to_instance(ptr));
- destruct_(ptr);
+ m_.destruct(ptr);
}
void destruct_n(void *ptr, int64_t n) const
{
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(ptr));
-
- destruct_n_(ptr, n);
+ this->destruct_indices(ptr, IndexMask(n));
}
void destruct_indices(void *ptr, IndexMask mask) const
{
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(ptr));
- destruct_indices_(ptr, mask);
- }
-
- DestructF destruct_cb() const
- {
- return destruct_;
+ m_.destruct_indices(ptr, mask);
}
/**
@@ -392,31 +325,27 @@ class CPPType : NonCopyable, NonMovable {
* C++ equivalent:
* dst = src;
*/
- void copy_to_initialized(const void *src, void *dst) const
+ void copy_assign(const void *src, void *dst) const
{
BLI_assert(src != dst);
BLI_assert(this->pointer_can_point_to_instance(src));
BLI_assert(this->pointer_can_point_to_instance(dst));
- copy_to_initialized_(src, dst);
+ m_.copy_assign(src, dst);
}
- void copy_to_initialized_n(const void *src, void *dst, int64_t n) const
+ void copy_assign_n(const void *src, void *dst, int64_t n) const
{
- BLI_assert(n == 0 || src != dst);
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(src));
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst));
-
- copy_to_initialized_n_(src, dst, n);
+ this->copy_assign_indices(src, dst, IndexMask(n));
}
- void copy_to_initialized_indices(const void *src, void *dst, IndexMask mask) const
+ void copy_assign_indices(const void *src, void *dst, IndexMask mask) const
{
BLI_assert(mask.size() == 0 || src != dst);
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src));
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst));
- copy_to_initialized_indices_(src, dst, mask);
+ m_.copy_assign_indices(src, dst, mask);
}
/**
@@ -427,31 +356,27 @@ class CPPType : NonCopyable, NonMovable {
* C++ equivalent:
* new (dst) T(src);
*/
- void copy_to_uninitialized(const void *src, void *dst) const
+ void copy_construct(const void *src, void *dst) const
{
BLI_assert(src != dst);
BLI_assert(this->pointer_can_point_to_instance(src));
BLI_assert(this->pointer_can_point_to_instance(dst));
- copy_to_uninitialized_(src, dst);
+ m_.copy_construct(src, dst);
}
- void copy_to_uninitialized_n(const void *src, void *dst, int64_t n) const
+ void copy_construct_n(const void *src, void *dst, int64_t n) const
{
- BLI_assert(n == 0 || src != dst);
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(src));
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst));
-
- copy_to_uninitialized_n_(src, dst, n);
+ this->copy_construct_indices(src, dst, IndexMask(n));
}
- void copy_to_uninitialized_indices(const void *src, void *dst, IndexMask mask) const
+ void copy_construct_indices(const void *src, void *dst, IndexMask mask) const
{
BLI_assert(mask.size() == 0 || src != dst);
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src));
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst));
- copy_to_uninitialized_indices_(src, dst, mask);
+ m_.copy_construct_indices(src, dst, mask);
}
/**
@@ -462,31 +387,27 @@ class CPPType : NonCopyable, NonMovable {
* C++ equivalent:
* dst = std::move(src);
*/
- void move_to_initialized(void *src, void *dst) const
+ void move_assign(void *src, void *dst) const
{
BLI_assert(src != dst);
BLI_assert(this->pointer_can_point_to_instance(src));
BLI_assert(this->pointer_can_point_to_instance(dst));
- move_to_initialized_(src, dst);
+ m_.move_assign(src, dst);
}
- void move_to_initialized_n(void *src, void *dst, int64_t n) const
+ void move_assign_n(void *src, void *dst, int64_t n) const
{
- BLI_assert(n == 0 || src != dst);
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(src));
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst));
-
- move_to_initialized_n_(src, dst, n);
+ this->move_assign_indices(src, dst, IndexMask(n));
}
- void move_to_initialized_indices(void *src, void *dst, IndexMask mask) const
+ void move_assign_indices(void *src, void *dst, IndexMask mask) const
{
BLI_assert(mask.size() == 0 || src != dst);
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src));
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst));
- move_to_initialized_indices_(src, dst, mask);
+ m_.move_assign_indices(src, dst, mask);
}
/**
@@ -497,31 +418,27 @@ class CPPType : NonCopyable, NonMovable {
* C++ equivalent:
* new (dst) T(std::move(src));
*/
- void move_to_uninitialized(void *src, void *dst) const
+ void move_construct(void *src, void *dst) const
{
BLI_assert(src != dst);
BLI_assert(this->pointer_can_point_to_instance(src));
BLI_assert(this->pointer_can_point_to_instance(dst));
- move_to_uninitialized_(src, dst);
+ m_.move_construct(src, dst);
}
- void move_to_uninitialized_n(void *src, void *dst, int64_t n) const
+ void move_construct_n(void *src, void *dst, int64_t n) const
{
- BLI_assert(n == 0 || src != dst);
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(src));
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst));
-
- move_to_uninitialized_n_(src, dst, n);
+ this->move_construct_indices(src, dst, IndexMask(n));
}
- void move_to_uninitialized_indices(void *src, void *dst, IndexMask mask) const
+ void move_construct_indices(void *src, void *dst, IndexMask mask) const
{
BLI_assert(mask.size() == 0 || src != dst);
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src));
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst));
- move_to_uninitialized_indices_(src, dst, mask);
+ m_.move_construct_indices(src, dst, mask);
}
/**
@@ -532,31 +449,27 @@ class CPPType : NonCopyable, NonMovable {
* dst = std::move(src);
* src->~T();
*/
- void relocate_to_initialized(void *src, void *dst) const
+ void relocate_assign(void *src, void *dst) const
{
BLI_assert(src != dst);
BLI_assert(this->pointer_can_point_to_instance(src));
BLI_assert(this->pointer_can_point_to_instance(dst));
- relocate_to_initialized_(src, dst);
+ m_.relocate_assign(src, dst);
}
- void relocate_to_initialized_n(void *src, void *dst, int64_t n) const
+ void relocate_assign_n(void *src, void *dst, int64_t n) const
{
- BLI_assert(n == 0 || src != dst);
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(src));
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst));
-
- relocate_to_initialized_n_(src, dst, n);
+ this->relocate_assign_indices(src, dst, IndexMask(n));
}
- void relocate_to_initialized_indices(void *src, void *dst, IndexMask mask) const
+ void relocate_assign_indices(void *src, void *dst, IndexMask mask) const
{
BLI_assert(mask.size() == 0 || src != dst);
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src));
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst));
- relocate_to_initialized_indices_(src, dst, mask);
+ m_.relocate_assign_indices(src, dst, mask);
}
/**
@@ -567,31 +480,27 @@ class CPPType : NonCopyable, NonMovable {
* new (dst) T(std::move(src))
* src->~T();
*/
- void relocate_to_uninitialized(void *src, void *dst) const
+ void relocate_construct(void *src, void *dst) const
{
BLI_assert(src != dst);
BLI_assert(this->pointer_can_point_to_instance(src));
BLI_assert(this->pointer_can_point_to_instance(dst));
- relocate_to_uninitialized_(src, dst);
+ m_.relocate_construct(src, dst);
}
- void relocate_to_uninitialized_n(void *src, void *dst, int64_t n) const
+ void relocate_construct_n(void *src, void *dst, int64_t n) const
{
- BLI_assert(n == 0 || src != dst);
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(src));
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst));
-
- relocate_to_uninitialized_n_(src, dst, n);
+ this->relocate_construct_indices(src, dst, IndexMask(n));
}
- void relocate_to_uninitialized_indices(void *src, void *dst, IndexMask mask) const
+ void relocate_construct_indices(void *src, void *dst, IndexMask mask) const
{
BLI_assert(mask.size() == 0 || src != dst);
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src));
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst));
- relocate_to_uninitialized_indices_(src, dst, mask);
+ m_.relocate_construct_indices(src, dst, mask);
}
/**
@@ -599,20 +508,17 @@ class CPPType : NonCopyable, NonMovable {
*
* Other instances of the same type should live in the array before this method is called.
*/
- void fill_initialized(const void *value, void *dst, int64_t n) const
+ void fill_assign_n(const void *value, void *dst, int64_t n) const
{
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(value));
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst));
-
- fill_initialized_(value, dst, n);
+ this->fill_assign_indices(value, dst, IndexMask(n));
}
- void fill_initialized_indices(const void *value, void *dst, IndexMask mask) const
+ void fill_assign_indices(const void *value, void *dst, IndexMask mask) const
{
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(value));
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst));
- fill_initialized_indices_(value, dst, mask);
+ m_.fill_assign_indices(value, dst, mask);
}
/**
@@ -620,39 +526,62 @@ class CPPType : NonCopyable, NonMovable {
*
* The array should be uninitialized before this method is called.
*/
- void fill_uninitialized(const void *value, void *dst, int64_t n) const
+ void fill_construct_n(const void *value, void *dst, int64_t n) const
{
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(value));
- BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst));
-
- fill_uninitialized_(value, dst, n);
+ this->fill_construct_indices(value, dst, IndexMask(n));
}
- void fill_uninitialized_indices(const void *value, void *dst, IndexMask mask) const
+ void fill_construct_indices(const void *value, void *dst, IndexMask mask) const
{
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(value));
BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst));
- fill_uninitialized_indices_(value, dst, mask);
+ m_.fill_construct_indices(value, dst, mask);
}
- void debug_print(const void *value, std::stringstream &ss) const
+ void print(const void *value, std::stringstream &ss) const
{
BLI_assert(this->pointer_can_point_to_instance(value));
- debug_print_(value, ss);
+ m_.print(value, ss);
+ }
+
+ void print_or_default(const void *value, std::stringstream &ss, StringRef default_value) const
+ {
+ if (this->is_printable()) {
+ this->print(value, ss);
+ }
+ else {
+ ss << default_value;
+ }
}
bool is_equal(const void *a, const void *b) const
{
BLI_assert(this->pointer_can_point_to_instance(a));
BLI_assert(this->pointer_can_point_to_instance(b));
- return is_equal_(a, b);
+ return m_.is_equal(a, b);
+ }
+
+ bool is_equal_or_false(const void *a, const void *b) const
+ {
+ if (this->is_equality_comparable()) {
+ return this->is_equal(a, b);
+ }
+ return false;
}
uint64_t hash(const void *value) const
{
BLI_assert(this->pointer_can_point_to_instance(value));
- return hash_(value);
+ return m_.hash(value);
+ }
+
+ uint64_t hash_or_fallback(const void *value, uint64_t fallback_hash) const
+ {
+ if (this->is_hashable()) {
+ return this->hash(value);
+ }
+ return fallback_hash;
}
/**
@@ -661,7 +590,7 @@ class CPPType : NonCopyable, NonMovable {
*/
const void *default_value() const
{
- return default_value_;
+ return m_.default_value;
}
uint64_t hash() const
@@ -669,6 +598,14 @@ class CPPType : NonCopyable, NonMovable {
return get_default_hash(this);
}
+ /**
+ * Low level access to the callbacks for this CPPType.
+ */
+ const CPPTypeMembers &members() const
+ {
+ return m_;
+ }
+
template<typename T> bool is() const
{
return this == &CPPType::get<std::decay_t<T>>();
diff --git a/source/blender/functions/FN_cpp_type_make.hh b/source/blender/functions/FN_cpp_type_make.hh
index cd14fe8c078..b8e5373ccf7 100644
--- a/source/blender/functions/FN_cpp_type_make.hh
+++ b/source/blender/functions/FN_cpp_type_make.hh
@@ -20,19 +20,16 @@
* \ingroup fn
*/
+#include "BLI_utildefines.h"
#include "FN_cpp_type.hh"
namespace blender::fn::cpp_type_util {
-template<typename T> void construct_default_cb(void *ptr)
+template<typename T> void default_construct_cb(void *ptr)
{
new (ptr) T;
}
-template<typename T> void construct_default_n_cb(void *ptr, int64_t n)
-{
- blender::default_construct_n(static_cast<T *>(ptr), n);
-}
-template<typename T> void construct_default_indices_cb(void *ptr, IndexMask mask)
+template<typename T> void default_construct_indices_cb(void *ptr, IndexMask mask)
{
mask.foreach_index([&](int64_t i) { new (static_cast<T *>(ptr) + i) T; });
}
@@ -41,31 +38,17 @@ template<typename T> void destruct_cb(void *ptr)
{
(static_cast<T *>(ptr))->~T();
}
-template<typename T> void destruct_n_cb(void *ptr, int64_t n)
-{
- blender::destruct_n(static_cast<T *>(ptr), n);
-}
template<typename T> void destruct_indices_cb(void *ptr, IndexMask mask)
{
T *ptr_ = static_cast<T *>(ptr);
mask.foreach_index([&](int64_t i) { ptr_[i].~T(); });
}
-template<typename T> void copy_to_initialized_cb(const void *src, void *dst)
+template<typename T> void copy_assign_cb(const void *src, void *dst)
{
*static_cast<T *>(dst) = *static_cast<const T *>(src);
}
-template<typename T> void copy_to_initialized_n_cb(const void *src, void *dst, int64_t n)
-{
- const T *src_ = static_cast<const T *>(src);
- T *dst_ = static_cast<T *>(dst);
-
- for (int64_t i = 0; i < n; i++) {
- dst_[i] = src_[i];
- }
-}
-template<typename T>
-void copy_to_initialized_indices_cb(const void *src, void *dst, IndexMask mask)
+template<typename T> void copy_assign_indices_cb(const void *src, void *dst, IndexMask mask)
{
const T *src_ = static_cast<const T *>(src);
T *dst_ = static_cast<T *>(dst);
@@ -73,16 +56,11 @@ void copy_to_initialized_indices_cb(const void *src, void *dst, IndexMask mask)
mask.foreach_index([&](int64_t i) { dst_[i] = src_[i]; });
}
-template<typename T> void copy_to_uninitialized_cb(const void *src, void *dst)
+template<typename T> void copy_construct_cb(const void *src, void *dst)
{
blender::uninitialized_copy_n(static_cast<const T *>(src), 1, static_cast<T *>(dst));
}
-template<typename T> void copy_to_uninitialized_n_cb(const void *src, void *dst, int64_t n)
-{
- blender::uninitialized_copy_n(static_cast<const T *>(src), n, static_cast<T *>(dst));
-}
-template<typename T>
-void copy_to_uninitialized_indices_cb(const void *src, void *dst, IndexMask mask)
+template<typename T> void copy_construct_indices_cb(const void *src, void *dst, IndexMask mask)
{
const T *src_ = static_cast<const T *>(src);
T *dst_ = static_cast<T *>(dst);
@@ -90,15 +68,11 @@ void copy_to_uninitialized_indices_cb(const void *src, void *dst, IndexMask mask
mask.foreach_index([&](int64_t i) { new (dst_ + i) T(src_[i]); });
}
-template<typename T> void move_to_initialized_cb(void *src, void *dst)
+template<typename T> void move_assign_cb(void *src, void *dst)
{
blender::initialized_move_n(static_cast<T *>(src), 1, static_cast<T *>(dst));
}
-template<typename T> void move_to_initialized_n_cb(void *src, void *dst, int64_t n)
-{
- blender::initialized_move_n(static_cast<T *>(src), n, static_cast<T *>(dst));
-}
-template<typename T> void move_to_initialized_indices_cb(void *src, void *dst, IndexMask mask)
+template<typename T> void move_assign_indices_cb(void *src, void *dst, IndexMask mask)
{
T *src_ = static_cast<T *>(src);
T *dst_ = static_cast<T *>(dst);
@@ -106,15 +80,11 @@ template<typename T> void move_to_initialized_indices_cb(void *src, void *dst, I
mask.foreach_index([&](int64_t i) { dst_[i] = std::move(src_[i]); });
}
-template<typename T> void move_to_uninitialized_cb(void *src, void *dst)
+template<typename T> void move_construct_cb(void *src, void *dst)
{
blender::uninitialized_move_n(static_cast<T *>(src), 1, static_cast<T *>(dst));
}
-template<typename T> void move_to_uninitialized_n_cb(void *src, void *dst, int64_t n)
-{
- blender::uninitialized_move_n(static_cast<T *>(src), n, static_cast<T *>(dst));
-}
-template<typename T> void move_to_uninitialized_indices_cb(void *src, void *dst, IndexMask mask)
+template<typename T> void move_construct_indices_cb(void *src, void *dst, IndexMask mask)
{
T *src_ = static_cast<T *>(src);
T *dst_ = static_cast<T *>(dst);
@@ -122,7 +92,7 @@ template<typename T> void move_to_uninitialized_indices_cb(void *src, void *dst,
mask.foreach_index([&](int64_t i) { new (dst_ + i) T(std::move(src_[i])); });
}
-template<typename T> void relocate_to_initialized_cb(void *src, void *dst)
+template<typename T> void relocate_assign_cb(void *src, void *dst)
{
T *src_ = static_cast<T *>(src);
T *dst_ = static_cast<T *>(dst);
@@ -130,11 +100,7 @@ template<typename T> void relocate_to_initialized_cb(void *src, void *dst)
*dst_ = std::move(*src_);
src_->~T();
}
-template<typename T> void relocate_to_initialized_n_cb(void *src, void *dst, int64_t n)
-{
- blender::initialized_relocate_n(static_cast<T *>(src), n, static_cast<T *>(dst));
-}
-template<typename T> void relocate_to_initialized_indices_cb(void *src, void *dst, IndexMask mask)
+template<typename T> void relocate_assign_indices_cb(void *src, void *dst, IndexMask mask)
{
T *src_ = static_cast<T *>(src);
T *dst_ = static_cast<T *>(dst);
@@ -145,7 +111,7 @@ template<typename T> void relocate_to_initialized_indices_cb(void *src, void *ds
});
}
-template<typename T> void relocate_to_uninitialized_cb(void *src, void *dst)
+template<typename T> void relocate_construct_cb(void *src, void *dst)
{
T *src_ = static_cast<T *>(src);
T *dst_ = static_cast<T *>(dst);
@@ -153,12 +119,7 @@ template<typename T> void relocate_to_uninitialized_cb(void *src, void *dst)
new (dst_) T(std::move(*src_));
src_->~T();
}
-template<typename T> void relocate_to_uninitialized_n_cb(void *src, void *dst, int64_t n)
-{
- blender::uninitialized_relocate_n(static_cast<T *>(src), n, static_cast<T *>(dst));
-}
-template<typename T>
-void relocate_to_uninitialized_indices_cb(void *src, void *dst, IndexMask mask)
+template<typename T> void relocate_construct_indices_cb(void *src, void *dst, IndexMask mask)
{
T *src_ = static_cast<T *>(src);
T *dst_ = static_cast<T *>(dst);
@@ -169,7 +130,7 @@ void relocate_to_uninitialized_indices_cb(void *src, void *dst, IndexMask mask)
});
}
-template<typename T> void fill_initialized_cb(const void *value, void *dst, int64_t n)
+template<typename T> void fill_assign_cb(const void *value, void *dst, int64_t n)
{
const T &value_ = *static_cast<const T *>(value);
T *dst_ = static_cast<T *>(dst);
@@ -178,7 +139,7 @@ template<typename T> void fill_initialized_cb(const void *value, void *dst, int6
dst_[i] = value_;
}
}
-template<typename T> void fill_initialized_indices_cb(const void *value, void *dst, IndexMask mask)
+template<typename T> void fill_assign_indices_cb(const void *value, void *dst, IndexMask mask)
{
const T &value_ = *static_cast<const T *>(value);
T *dst_ = static_cast<T *>(dst);
@@ -186,7 +147,7 @@ template<typename T> void fill_initialized_indices_cb(const void *value, void *d
mask.foreach_index([&](int64_t i) { dst_[i] = value_; });
}
-template<typename T> void fill_uninitialized_cb(const void *value, void *dst, int64_t n)
+template<typename T> void fill_construct_cb(const void *value, void *dst, int64_t n)
{
const T &value_ = *static_cast<const T *>(value);
T *dst_ = static_cast<T *>(dst);
@@ -195,8 +156,7 @@ template<typename T> void fill_uninitialized_cb(const void *value, void *dst, in
new (dst_ + i) T(value_);
}
}
-template<typename T>
-void fill_uninitialized_indices_cb(const void *value, void *dst, IndexMask mask)
+template<typename T> void fill_construct_indices_cb(const void *value, void *dst, IndexMask mask)
{
const T &value_ = *static_cast<const T *>(value);
T *dst_ = static_cast<T *>(dst);
@@ -204,7 +164,7 @@ void fill_uninitialized_indices_cb(const void *value, void *dst, IndexMask mask)
mask.foreach_index([&](int64_t i) { new (dst_ + i) T(value_); });
}
-template<typename T> void debug_print_cb(const void *value, std::stringstream &ss)
+template<typename T> void print_cb(const void *value, std::stringstream &ss)
{
const T &value_ = *static_cast<const T *>(value);
ss << value_;
@@ -225,59 +185,96 @@ template<typename T> uint64_t hash_cb(const void *value)
} // namespace blender::fn::cpp_type_util
+/**
+ * Different types support different features. Features like copy constructability can be detected
+ * automatically easily. For some features this is harder as of C++17. Those have flags in this
+ * enum and need to be determined by the programmer.
+ */
+enum class CPPTypeFlags {
+ None = 0,
+ Hashable = 1 << 0,
+ Printable = 1 << 1,
+ EqualityComparable = 1 << 2,
+
+ BasicType = Hashable | Printable | EqualityComparable,
+};
+ENUM_OPERATORS(CPPTypeFlags, CPPTypeFlags::EqualityComparable)
+
namespace blender::fn {
-template<typename T>
-inline std::unique_ptr<const CPPType> create_cpp_type(StringRef name, const T &default_value)
+template<typename T, CPPTypeFlags flags>
+inline std::unique_ptr<const CPPType> create_cpp_type(StringRef name)
{
using namespace cpp_type_util;
- const CPPType *type = new CPPType(name,
- sizeof(T),
- alignof(T),
- std::is_trivially_destructible_v<T>,
- construct_default_cb<T>,
- construct_default_n_cb<T>,
- construct_default_indices_cb<T>,
- destruct_cb<T>,
- destruct_n_cb<T>,
- destruct_indices_cb<T>,
- copy_to_initialized_cb<T>,
- copy_to_initialized_n_cb<T>,
- copy_to_initialized_indices_cb<T>,
- copy_to_uninitialized_cb<T>,
- copy_to_uninitialized_n_cb<T>,
- copy_to_uninitialized_indices_cb<T>,
- move_to_initialized_cb<T>,
- move_to_initialized_n_cb<T>,
- move_to_initialized_indices_cb<T>,
- move_to_uninitialized_cb<T>,
- move_to_uninitialized_n_cb<T>,
- move_to_uninitialized_indices_cb<T>,
- relocate_to_initialized_cb<T>,
- relocate_to_initialized_n_cb<T>,
- relocate_to_initialized_indices_cb<T>,
- relocate_to_uninitialized_cb<T>,
- relocate_to_uninitialized_n_cb<T>,
- relocate_to_uninitialized_indices_cb<T>,
- fill_initialized_cb<T>,
- fill_initialized_indices_cb<T>,
- fill_uninitialized_cb<T>,
- fill_uninitialized_indices_cb<T>,
- debug_print_cb<T>,
- is_equal_cb<T>,
- hash_cb<T>,
- static_cast<const void *>(&default_value));
+
+ CPPTypeMembers m;
+ m.name = name;
+ m.size = (int64_t)sizeof(T);
+ m.alignment = (int64_t)alignof(T);
+ m.is_trivially_destructible = std::is_trivially_destructible_v<T>;
+ if constexpr (std::is_default_constructible_v<T>) {
+ m.default_construct = default_construct_cb<T>;
+ m.default_construct_indices = default_construct_indices_cb<T>;
+ static T default_value;
+ m.default_value = (void *)&default_value;
+ }
+ if constexpr (std::is_destructible_v<T>) {
+ m.destruct = destruct_cb<T>;
+ m.destruct_indices = destruct_indices_cb<T>;
+ }
+ if constexpr (std::is_copy_assignable_v<T>) {
+ m.copy_assign = copy_assign_cb<T>;
+ m.copy_assign_indices = copy_assign_indices_cb<T>;
+ }
+ if constexpr (std::is_copy_constructible_v<T>) {
+ m.copy_construct = copy_construct_cb<T>;
+ m.copy_construct_indices = copy_construct_indices_cb<T>;
+ }
+ if constexpr (std::is_move_assignable_v<T>) {
+ m.move_assign = move_assign_cb<T>;
+ m.move_assign_indices = move_assign_indices_cb<T>;
+ }
+ if constexpr (std::is_move_constructible_v<T>) {
+ m.move_construct = move_construct_cb<T>;
+ m.move_construct_indices = move_construct_indices_cb<T>;
+ }
+ if constexpr (std::is_destructible_v<T>) {
+ if constexpr (std::is_move_assignable_v<T>) {
+ m.relocate_assign = relocate_assign_cb<T>;
+ m.relocate_assign_indices = relocate_assign_indices_cb<T>;
+ }
+ if constexpr (std::is_move_constructible_v<T>) {
+ m.relocate_construct = relocate_construct_cb<T>;
+ m.relocate_construct_indices = relocate_construct_indices_cb<T>;
+ }
+ }
+ if constexpr (std::is_copy_assignable_v<T>) {
+ m.fill_assign_indices = fill_assign_indices_cb<T>;
+ }
+ if constexpr (std::is_copy_constructible_v<T>) {
+ m.fill_construct_indices = fill_construct_indices_cb<T>;
+ }
+ if constexpr ((bool)(flags & CPPTypeFlags::Hashable)) {
+ m.hash = hash_cb<T>;
+ }
+ if constexpr ((bool)(flags & CPPTypeFlags::Printable)) {
+ m.print = print_cb<T>;
+ }
+ if constexpr ((bool)(flags & CPPTypeFlags::EqualityComparable)) {
+ m.is_equal = is_equal_cb<T>;
+ }
+
+ const CPPType *type = new CPPType(std::move(m));
return std::unique_ptr<const CPPType>(type);
}
} // namespace blender::fn
-#define MAKE_CPP_TYPE(IDENTIFIER, TYPE_NAME) \
+#define MAKE_CPP_TYPE(IDENTIFIER, TYPE_NAME, FLAGS) \
template<> const blender::fn::CPPType &blender::fn::CPPType::get<TYPE_NAME>() \
{ \
- static TYPE_NAME default_value; \
- static std::unique_ptr<const CPPType> cpp_type = blender::fn::create_cpp_type<TYPE_NAME>( \
- STRINGIFY(IDENTIFIER), default_value); \
+ static std::unique_ptr<const CPPType> cpp_type = \
+ blender::fn::create_cpp_type<TYPE_NAME, FLAGS>(STRINGIFY(IDENTIFIER)); \
return *cpp_type; \
} \
/* Support using `CPPType::get<const T>()`. Otherwise the caller would have to remove const. */ \
diff --git a/source/blender/functions/FN_generic_pointer.hh b/source/blender/functions/FN_generic_pointer.hh
index f88ff09f916..c65c42f26c9 100644
--- a/source/blender/functions/FN_generic_pointer.hh
+++ b/source/blender/functions/FN_generic_pointer.hh
@@ -70,7 +70,7 @@ class GMutablePointer {
{
BLI_assert(this->is_type<T>());
T value;
- type_->relocate_to_initialized(data_, &value);
+ type_->relocate_assign(data_, &value);
data_ = nullptr;
type_ = nullptr;
return value;
diff --git a/source/blender/functions/FN_generic_value_map.hh b/source/blender/functions/FN_generic_value_map.hh
index 4e7fe298874..33b827bf073 100644
--- a/source/blender/functions/FN_generic_value_map.hh
+++ b/source/blender/functions/FN_generic_value_map.hh
@@ -60,7 +60,7 @@ template<typename Key> class GValueMap {
{
const CPPType &type = *value.type();
void *buffer = allocator_.allocate(type.size(), type.alignment());
- type.move_to_uninitialized(value.get(), buffer);
+ type.move_construct(value.get(), buffer);
values_.add_new_as(std::forward<ForwardKey>(key), GMutablePointer{type, buffer});
}
@@ -70,7 +70,7 @@ template<typename Key> class GValueMap {
{
const CPPType &type = *value.type();
void *buffer = allocator_.allocate(type.size(), type.alignment());
- type.copy_to_uninitialized(value.get(), buffer);
+ type.copy_construct(value.get(), buffer);
values_.add_new_as(std::forward<ForwardKey>(key), GMutablePointer{type, buffer});
}
@@ -105,7 +105,7 @@ template<typename Key> class GValueMap {
const CPPType &type = *value.type();
BLI_assert(type.is<T>());
T return_value;
- type.relocate_to_initialized(value.get(), &return_value);
+ type.relocate_assign(value.get(), &return_value);
return return_value;
}
diff --git a/source/blender/functions/FN_generic_vector_array.hh b/source/blender/functions/FN_generic_vector_array.hh
index b02ed471875..eeba0c9dba2 100644
--- a/source/blender/functions/FN_generic_vector_array.hh
+++ b/source/blender/functions/FN_generic_vector_array.hh
@@ -154,7 +154,7 @@ class GVVectorArray_For_GVectorArray : public GVVectorArray {
const int64_t index_in_vector,
void *r_value) const override
{
- type_->copy_to_initialized(vector_array_[index][index_in_vector], r_value);
+ type_->copy_assign(vector_array_[index][index_in_vector], r_value);
}
};
diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh
index 5fdc7c3f337..40dc585b39b 100644
--- a/source/blender/functions/FN_generic_virtual_array.hh
+++ b/source/blender/functions/FN_generic_virtual_array.hh
@@ -131,7 +131,7 @@ class GVArray {
/* Same as `get_internal_single`, but `r_value` points to initialized memory. */
void get_single_to_uninitialized(void *r_value) const
{
- type_->construct_default(r_value);
+ type_->default_construct(r_value);
this->get_internal_single(r_value);
}
@@ -832,7 +832,7 @@ template<typename T> class GVArray_Typed {
}
/* Support implicit cast to the typed virtual array for convenience when `varray->typed<T>()` is
- * used within an expression. */
+ * used within an expression. */
operator const VArray<T> &() const
{
return *varray_;
diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh
index 691abeb18c0..7a526bb640b 100644
--- a/source/blender/functions/FN_multi_function_builder.hh
+++ b/source/blender/functions/FN_multi_function_builder.hh
@@ -398,7 +398,7 @@ template<typename T> class CustomMF_Constant : public MultiFunction {
if (other2 != nullptr) {
const CPPType &type = CPPType::get<T>();
if (type == other2->type_) {
- return type.is_equal(static_cast<const void *>(&value_), other2->value_);
+ return type.is_equal_or_false(static_cast<const void *>(&value_), other2->value_);
}
}
return false;
diff --git a/source/blender/functions/intern/cpp_types.cc b/source/blender/functions/intern/cpp_types.cc
index 9c2c1621e23..7be34d2a1bf 100644
--- a/source/blender/functions/intern/cpp_types.cc
+++ b/source/blender/functions/intern/cpp_types.cc
@@ -23,20 +23,20 @@
namespace blender::fn {
-MAKE_CPP_TYPE(bool, bool)
+MAKE_CPP_TYPE(bool, bool, CPPTypeFlags::BasicType)
-MAKE_CPP_TYPE(float, float)
-MAKE_CPP_TYPE(float2, blender::float2)
-MAKE_CPP_TYPE(float3, blender::float3)
-MAKE_CPP_TYPE(float4x4, blender::float4x4)
+MAKE_CPP_TYPE(float, float, CPPTypeFlags::BasicType)
+MAKE_CPP_TYPE(float2, blender::float2, CPPTypeFlags::BasicType)
+MAKE_CPP_TYPE(float3, blender::float3, CPPTypeFlags::BasicType)
+MAKE_CPP_TYPE(float4x4, blender::float4x4, CPPTypeFlags::BasicType)
-MAKE_CPP_TYPE(int32, int32_t)
-MAKE_CPP_TYPE(uint32, uint32_t)
-MAKE_CPP_TYPE(uint8, uint8_t)
+MAKE_CPP_TYPE(int32, int32_t, CPPTypeFlags::BasicType)
+MAKE_CPP_TYPE(uint32, uint32_t, CPPTypeFlags::BasicType)
+MAKE_CPP_TYPE(uint8, uint8_t, CPPTypeFlags::BasicType)
-MAKE_CPP_TYPE(ColorGeometry4f, blender::ColorGeometry4f)
-MAKE_CPP_TYPE(ColorGeometry4b, blender::ColorGeometry4b)
+MAKE_CPP_TYPE(ColorGeometry4f, blender::ColorGeometry4f, CPPTypeFlags::BasicType)
+MAKE_CPP_TYPE(ColorGeometry4b, blender::ColorGeometry4b, CPPTypeFlags::BasicType)
-MAKE_CPP_TYPE(string, std::string)
+MAKE_CPP_TYPE(string, std::string, CPPTypeFlags::BasicType)
} // namespace blender::fn
diff --git a/source/blender/functions/intern/generic_vector_array.cc b/source/blender/functions/intern/generic_vector_array.cc
index 3335b07e559..9556d24218e 100644
--- a/source/blender/functions/intern/generic_vector_array.cc
+++ b/source/blender/functions/intern/generic_vector_array.cc
@@ -43,7 +43,7 @@ void GVectorArray::append(const int64_t index, const void *value)
}
void *dst = POINTER_OFFSET(item.start, element_size_ * item.length);
- type_.copy_to_uninitialized(value, dst);
+ type_.copy_construct(value, dst);
item.length++;
}
@@ -95,7 +95,7 @@ void GVectorArray::realloc_to_at_least(Item &item, int64_t min_capacity)
const int64_t new_capacity = std::max(min_capacity, item.length * 2);
void *new_buffer = allocator_.allocate(element_size_ * new_capacity, type_.alignment());
- type_.relocate_to_initialized_n(item.start, new_buffer, item.length);
+ type_.relocate_assign_n(item.start, new_buffer, item.length);
item.start = new_buffer;
item.capacity = new_capacity;
diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc
index 87dae06ccdc..bd033a429de 100644
--- a/source/blender/functions/intern/generic_virtual_array.cc
+++ b/source/blender/functions/intern/generic_virtual_array.cc
@@ -149,7 +149,7 @@ GVArrayPtr GVArray::shallow_copy() const
void GVMutableArray::set_by_copy_impl(const int64_t index, const void *value)
{
BUFFER_FOR_CPP_TYPE_VALUE(*type_, buffer);
- type_->copy_to_uninitialized(value, buffer);
+ type_->copy_construct(value, buffer);
this->set_by_move_impl(index, buffer);
type_->destruct(buffer);
}
@@ -164,7 +164,7 @@ void GVMutableArray::set_all_impl(const void *src)
{
if (this->is_span()) {
const GMutableSpan span = this->get_internal_span();
- type_->copy_to_initialized_n(src, span.data(), size_);
+ type_->copy_assign_n(src, span.data(), size_);
}
else {
for (int64_t i : IndexRange(size_)) {
@@ -182,7 +182,7 @@ void GVMutableArray::fill(const void *value)
{
if (this->is_span()) {
const GMutableSpan span = this->get_internal_span();
- type_->fill_initialized(value, span.data(), size_);
+ type_->fill_assign_n(value, span.data(), size_);
}
else {
for (int64_t i : IndexRange(size_)) {
@@ -197,12 +197,12 @@ void GVMutableArray::fill(const void *value)
void GVArray_For_GSpan::get_impl(const int64_t index, void *r_value) const
{
- type_->copy_to_initialized(POINTER_OFFSET(data_, element_size_ * index), r_value);
+ type_->copy_assign(POINTER_OFFSET(data_, element_size_ * index), r_value);
}
void GVArray_For_GSpan::get_to_uninitialized_impl(const int64_t index, void *r_value) const
{
- type_->copy_to_uninitialized(POINTER_OFFSET(data_, element_size_ * index), r_value);
+ type_->copy_construct(POINTER_OFFSET(data_, element_size_ * index), r_value);
}
bool GVArray_For_GSpan::is_span_impl() const
@@ -221,28 +221,28 @@ GSpan GVArray_For_GSpan::get_internal_span_impl() const
void GVMutableArray_For_GMutableSpan::get_impl(const int64_t index, void *r_value) const
{
- type_->copy_to_initialized(POINTER_OFFSET(data_, element_size_ * index), r_value);
+ type_->copy_assign(POINTER_OFFSET(data_, element_size_ * index), r_value);
}
void GVMutableArray_For_GMutableSpan::get_to_uninitialized_impl(const int64_t index,
void *r_value) const
{
- type_->copy_to_uninitialized(POINTER_OFFSET(data_, element_size_ * index), r_value);
+ type_->copy_construct(POINTER_OFFSET(data_, element_size_ * index), r_value);
}
void GVMutableArray_For_GMutableSpan::set_by_copy_impl(const int64_t index, const void *value)
{
- type_->copy_to_initialized(value, POINTER_OFFSET(data_, element_size_ * index));
+ type_->copy_assign(value, POINTER_OFFSET(data_, element_size_ * index));
}
void GVMutableArray_For_GMutableSpan::set_by_move_impl(const int64_t index, void *value)
{
- type_->move_to_initialized(value, POINTER_OFFSET(data_, element_size_ * index));
+ type_->move_construct(value, POINTER_OFFSET(data_, element_size_ * index));
}
void GVMutableArray_For_GMutableSpan::set_by_relocate_impl(const int64_t index, void *value)
{
- type_->relocate_to_initialized(value, POINTER_OFFSET(data_, element_size_ * index));
+ type_->relocate_assign(value, POINTER_OFFSET(data_, element_size_ * index));
}
bool GVMutableArray_For_GMutableSpan::is_span_impl() const
@@ -261,13 +261,13 @@ GSpan GVMutableArray_For_GMutableSpan::get_internal_span_impl() const
void GVArray_For_SingleValueRef::get_impl(const int64_t UNUSED(index), void *r_value) const
{
- type_->copy_to_initialized(value_, r_value);
+ type_->copy_assign(value_, r_value);
}
void GVArray_For_SingleValueRef::get_to_uninitialized_impl(const int64_t UNUSED(index),
void *r_value) const
{
- type_->copy_to_uninitialized(value_, r_value);
+ type_->copy_construct(value_, r_value);
}
bool GVArray_For_SingleValueRef::is_span_impl() const
@@ -287,7 +287,7 @@ bool GVArray_For_SingleValueRef::is_single_impl() const
void GVArray_For_SingleValueRef::get_internal_single_impl(void *r_value) const
{
- type_->copy_to_initialized(value_, r_value);
+ type_->copy_assign(value_, r_value);
}
/* --------------------------------------------------------------------
@@ -300,7 +300,7 @@ GVArray_For_SingleValue::GVArray_For_SingleValue(const CPPType &type,
: GVArray_For_SingleValueRef(type, size)
{
value_ = MEM_mallocN_aligned(type.size(), type.alignment(), __func__);
- type.copy_to_uninitialized(value, (void *)value_);
+ type.copy_construct(value, (void *)value_);
}
GVArray_For_SingleValue::~GVArray_For_SingleValue()
@@ -351,7 +351,7 @@ GVMutableArray_GSpan::GVMutableArray_GSpan(GVMutableArray &varray, const bool co
varray_.materialize_to_uninitialized(IndexRange(size_), owned_data_);
}
else {
- type_->construct_default_n(owned_data_, size_);
+ type_->default_construct_n(owned_data_, size_);
}
data_ = owned_data_;
}
diff --git a/source/blender/functions/intern/generic_virtual_vector_array.cc b/source/blender/functions/intern/generic_virtual_vector_array.cc
index aa3d90883c6..6b90ce993ae 100644
--- a/source/blender/functions/intern/generic_virtual_vector_array.cc
+++ b/source/blender/functions/intern/generic_virtual_vector_array.cc
@@ -26,7 +26,7 @@ void GVArray_For_GVVectorArrayIndex::get_impl(const int64_t index_in_vector, voi
void GVArray_For_GVVectorArrayIndex::get_to_uninitialized_impl(const int64_t index_in_vector,
void *r_value) const
{
- type_->construct_default(r_value);
+ type_->default_construct(r_value);
vector_array_.get_vector_element(index_, index_in_vector, r_value);
}
@@ -56,7 +56,7 @@ void GVVectorArray_For_SingleGSpan::get_vector_element_impl(const int64_t UNUSED
const int64_t index_in_vector,
void *r_value) const
{
- type_->copy_to_initialized(span_[index_in_vector], r_value);
+ type_->copy_assign(span_[index_in_vector], r_value);
}
bool GVVectorArray_For_SingleGSpan::is_single_vector_impl() const
diff --git a/source/blender/functions/intern/multi_function_builder.cc b/source/blender/functions/intern/multi_function_builder.cc
index 3567f4f9167..c6b3b808130 100644
--- a/source/blender/functions/intern/multi_function_builder.cc
+++ b/source/blender/functions/intern/multi_function_builder.cc
@@ -25,7 +25,7 @@ CustomMF_GenericConstant::CustomMF_GenericConstant(const CPPType &type, const vo
{
MFSignatureBuilder signature{"Constant " + type.name()};
std::stringstream ss;
- type.debug_print(value, ss);
+ type.print_or_default(value, ss, type.name());
signature.single_output(ss.str(), type);
signature_ = signature.build();
this->set_signature(&signature_);
@@ -36,12 +36,12 @@ void CustomMF_GenericConstant::call(IndexMask mask,
MFContext UNUSED(context)) const
{
GMutableSpan output = params.uninitialized_single_output(0);
- type_.fill_uninitialized_indices(value_, output.data(), mask);
+ type_.fill_construct_indices(value_, output.data(), mask);
}
uint64_t CustomMF_GenericConstant::hash() const
{
- return type_.hash(value_);
+ return type_.hash_or_fallback(value_, (uintptr_t)this);
}
bool CustomMF_GenericConstant::equals(const MultiFunction &other) const
@@ -58,11 +58,12 @@ bool CustomMF_GenericConstant::equals(const MultiFunction &other) const
static std::string gspan_to_string(GSpan array)
{
+ const CPPType &type = array.type();
std::stringstream ss;
ss << "[";
const int64_t max_amount = 5;
for (int64_t i : IndexRange(std::min(max_amount, array.size()))) {
- array.type().debug_print(array[i], ss);
+ type.print_or_default(array[i], ss, type.name());
ss << ", ";
}
if (max_amount < array.size()) {
@@ -117,7 +118,7 @@ void CustomMF_DefaultOutput::call(IndexMask mask, MFParams params, MFContext UNU
if (param_type.data_type().is_single()) {
GMutableSpan span = params.uninitialized_single_output(param_index);
const CPPType &type = span.type();
- type.fill_uninitialized_indices(type.default_value(), span.data(), mask);
+ type.fill_construct_indices(type.default_value(), span.data(), mask);
}
}
}
diff --git a/source/blender/functions/intern/multi_function_network_optimization.cc b/source/blender/functions/intern/multi_function_network_optimization.cc
index 4b6b3e81393..0f65d320f62 100644
--- a/source/blender/functions/intern/multi_function_network_optimization.cc
+++ b/source/blender/functions/intern/multi_function_network_optimization.cc
@@ -263,7 +263,7 @@ static Array<MFOutputSocket *> add_constant_folded_sockets(const MultiFunction &
const CPPType &cpp_type = data_type.single_type();
GMutableSpan array = params.computed_array(param_index);
void *buffer = array.data();
- scope.add(buffer, array.type().destruct_cb(), AT);
+ scope.add(buffer, array.type().members().destruct, AT);
constant_fn = &scope.construct<CustomMF_GenericConstant>(AT, cpp_type, buffer);
break;
diff --git a/source/blender/functions/tests/FN_cpp_type_test.cc b/source/blender/functions/tests/FN_cpp_type_test.cc
index 3f92d2e1ac6..ffa3050f5a4 100644
--- a/source/blender/functions/tests/FN_cpp_type_test.cc
+++ b/source/blender/functions/tests/FN_cpp_type_test.cc
@@ -76,7 +76,7 @@ struct TestType {
} // namespace blender::fn::tests
-MAKE_CPP_TYPE(TestType, blender::fn::tests::TestType)
+MAKE_CPP_TYPE(TestType, blender::fn::tests::TestType, CPPTypeFlags::BasicType)
namespace blender::fn::tests {
@@ -101,15 +101,15 @@ TEST(cpp_type, Is)
TEST(cpp_type, DefaultConstruction)
{
int buffer[10] = {0};
- CPPType_TestType.construct_default((void *)buffer);
+ CPPType_TestType.default_construct((void *)buffer);
EXPECT_EQ(buffer[0], default_constructed_value);
EXPECT_EQ(buffer[1], 0);
- CPPType_TestType.construct_default_n((void *)buffer, 3);
+ CPPType_TestType.default_construct_n((void *)buffer, 3);
EXPECT_EQ(buffer[0], default_constructed_value);
EXPECT_EQ(buffer[1], default_constructed_value);
EXPECT_EQ(buffer[2], default_constructed_value);
EXPECT_EQ(buffer[3], 0);
- CPPType_TestType.construct_default_indices((void *)buffer, {2, 5, 7});
+ CPPType_TestType.default_construct_indices((void *)buffer, {2, 5, 7});
EXPECT_EQ(buffer[2], default_constructed_value);
EXPECT_EQ(buffer[4], 0);
EXPECT_EQ(buffer[5], default_constructed_value);
@@ -142,10 +142,10 @@ TEST(cpp_type, CopyToUninitialized)
{
int buffer1[10] = {0};
int buffer2[10] = {0};
- CPPType_TestType.copy_to_uninitialized((void *)buffer1, (void *)buffer2);
+ CPPType_TestType.copy_construct((void *)buffer1, (void *)buffer2);
EXPECT_EQ(buffer1[0], copy_constructed_from_value);
EXPECT_EQ(buffer2[0], copy_constructed_value);
- CPPType_TestType.copy_to_uninitialized_n((void *)buffer1, (void *)buffer2, 3);
+ CPPType_TestType.copy_construct_n((void *)buffer1, (void *)buffer2, 3);
EXPECT_EQ(buffer1[0], copy_constructed_from_value);
EXPECT_EQ(buffer2[0], copy_constructed_value);
EXPECT_EQ(buffer1[1], copy_constructed_from_value);
@@ -154,7 +154,7 @@ TEST(cpp_type, CopyToUninitialized)
EXPECT_EQ(buffer2[2], copy_constructed_value);
EXPECT_EQ(buffer1[3], 0);
EXPECT_EQ(buffer2[3], 0);
- CPPType_TestType.copy_to_uninitialized_indices((void *)buffer1, (void *)buffer2, {2, 5, 7});
+ CPPType_TestType.copy_construct_indices((void *)buffer1, (void *)buffer2, {2, 5, 7});
EXPECT_EQ(buffer1[2], copy_constructed_from_value);
EXPECT_EQ(buffer2[2], copy_constructed_value);
EXPECT_EQ(buffer1[4], 0);
@@ -173,10 +173,10 @@ TEST(cpp_type, CopyToInitialized)
{
int buffer1[10] = {0};
int buffer2[10] = {0};
- CPPType_TestType.copy_to_initialized((void *)buffer1, (void *)buffer2);
+ CPPType_TestType.copy_assign((void *)buffer1, (void *)buffer2);
EXPECT_EQ(buffer1[0], copy_assigned_from_value);
EXPECT_EQ(buffer2[0], copy_assigned_value);
- CPPType_TestType.copy_to_initialized_n((void *)buffer1, (void *)buffer2, 3);
+ CPPType_TestType.copy_assign_n((void *)buffer1, (void *)buffer2, 3);
EXPECT_EQ(buffer1[0], copy_assigned_from_value);
EXPECT_EQ(buffer2[0], copy_assigned_value);
EXPECT_EQ(buffer1[1], copy_assigned_from_value);
@@ -185,7 +185,7 @@ TEST(cpp_type, CopyToInitialized)
EXPECT_EQ(buffer2[2], copy_assigned_value);
EXPECT_EQ(buffer1[3], 0);
EXPECT_EQ(buffer2[3], 0);
- CPPType_TestType.copy_to_initialized_indices((void *)buffer1, (void *)buffer2, {2, 5, 7});
+ CPPType_TestType.copy_assign_indices((void *)buffer1, (void *)buffer2, {2, 5, 7});
EXPECT_EQ(buffer1[2], copy_assigned_from_value);
EXPECT_EQ(buffer2[2], copy_assigned_value);
EXPECT_EQ(buffer1[4], 0);
@@ -204,10 +204,10 @@ TEST(cpp_type, RelocateToUninitialized)
{
int buffer1[10] = {0};
int buffer2[10] = {0};
- CPPType_TestType.relocate_to_uninitialized((void *)buffer1, (void *)buffer2);
+ CPPType_TestType.relocate_construct((void *)buffer1, (void *)buffer2);
EXPECT_EQ(buffer1[0], destructed_value);
EXPECT_EQ(buffer2[0], move_constructed_value);
- CPPType_TestType.relocate_to_uninitialized_n((void *)buffer1, (void *)buffer2, 3);
+ CPPType_TestType.relocate_construct_n((void *)buffer1, (void *)buffer2, 3);
EXPECT_EQ(buffer1[0], destructed_value);
EXPECT_EQ(buffer2[0], move_constructed_value);
EXPECT_EQ(buffer1[1], destructed_value);
@@ -216,7 +216,7 @@ TEST(cpp_type, RelocateToUninitialized)
EXPECT_EQ(buffer2[2], move_constructed_value);
EXPECT_EQ(buffer1[3], 0);
EXPECT_EQ(buffer2[3], 0);
- CPPType_TestType.relocate_to_uninitialized_indices((void *)buffer1, (void *)buffer2, {2, 5, 7});
+ CPPType_TestType.relocate_construct_indices((void *)buffer1, (void *)buffer2, {2, 5, 7});
EXPECT_EQ(buffer1[2], destructed_value);
EXPECT_EQ(buffer2[2], move_constructed_value);
EXPECT_EQ(buffer1[4], 0);
@@ -235,10 +235,10 @@ TEST(cpp_type, RelocateToInitialized)
{
int buffer1[10] = {0};
int buffer2[10] = {0};
- CPPType_TestType.relocate_to_initialized((void *)buffer1, (void *)buffer2);
+ CPPType_TestType.relocate_assign((void *)buffer1, (void *)buffer2);
EXPECT_EQ(buffer1[0], destructed_value);
EXPECT_EQ(buffer2[0], move_assigned_value);
- CPPType_TestType.relocate_to_initialized_n((void *)buffer1, (void *)buffer2, 3);
+ CPPType_TestType.relocate_assign_n((void *)buffer1, (void *)buffer2, 3);
EXPECT_EQ(buffer1[0], destructed_value);
EXPECT_EQ(buffer2[0], move_assigned_value);
EXPECT_EQ(buffer1[1], destructed_value);
@@ -247,7 +247,7 @@ TEST(cpp_type, RelocateToInitialized)
EXPECT_EQ(buffer2[2], move_assigned_value);
EXPECT_EQ(buffer1[3], 0);
EXPECT_EQ(buffer2[3], 0);
- CPPType_TestType.relocate_to_initialized_indices((void *)buffer1, (void *)buffer2, {2, 5, 7});
+ CPPType_TestType.relocate_assign_indices((void *)buffer1, (void *)buffer2, {2, 5, 7});
EXPECT_EQ(buffer1[2], destructed_value);
EXPECT_EQ(buffer2[2], move_assigned_value);
EXPECT_EQ(buffer1[4], 0);
@@ -266,7 +266,7 @@ TEST(cpp_type, FillInitialized)
{
int buffer1 = 0;
int buffer2[10] = {0};
- CPPType_TestType.fill_initialized((void *)&buffer1, (void *)buffer2, 3);
+ CPPType_TestType.fill_assign_n((void *)&buffer1, (void *)buffer2, 3);
EXPECT_EQ(buffer1, copy_assigned_from_value);
EXPECT_EQ(buffer2[0], copy_assigned_value);
EXPECT_EQ(buffer2[1], copy_assigned_value);
@@ -274,7 +274,7 @@ TEST(cpp_type, FillInitialized)
EXPECT_EQ(buffer2[3], 0);
buffer1 = 0;
- CPPType_TestType.fill_initialized_indices((void *)&buffer1, (void *)buffer2, {1, 6, 8});
+ CPPType_TestType.fill_assign_indices((void *)&buffer1, (void *)buffer2, {1, 6, 8});
EXPECT_EQ(buffer1, copy_assigned_from_value);
EXPECT_EQ(buffer2[0], copy_assigned_value);
EXPECT_EQ(buffer2[1], copy_assigned_value);
@@ -292,7 +292,7 @@ TEST(cpp_type, FillUninitialized)
{
int buffer1 = 0;
int buffer2[10] = {0};
- CPPType_TestType.fill_uninitialized((void *)&buffer1, (void *)buffer2, 3);
+ CPPType_TestType.fill_construct_n((void *)&buffer1, (void *)buffer2, 3);
EXPECT_EQ(buffer1, copy_constructed_from_value);
EXPECT_EQ(buffer2[0], copy_constructed_value);
EXPECT_EQ(buffer2[1], copy_constructed_value);
@@ -300,7 +300,7 @@ TEST(cpp_type, FillUninitialized)
EXPECT_EQ(buffer2[3], 0);
buffer1 = 0;
- CPPType_TestType.fill_uninitialized_indices((void *)&buffer1, (void *)buffer2, {1, 6, 8});
+ CPPType_TestType.fill_construct_indices((void *)&buffer1, (void *)buffer2, {1, 6, 8});
EXPECT_EQ(buffer1, copy_constructed_from_value);
EXPECT_EQ(buffer2[0], copy_constructed_value);
EXPECT_EQ(buffer2[1], copy_constructed_value);
@@ -318,7 +318,7 @@ TEST(cpp_type, DebugPrint)
{
int value = 42;
std::stringstream ss;
- CPPType::get<int32_t>().debug_print((void *)&value, ss);
+ CPPType::get<int32_t>().print((void *)&value, ss);
std::string text = ss.str();
EXPECT_EQ(text, "42");
}
diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt
index f39306ac9d0..ec965c9a29f 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -68,6 +68,7 @@ set(SRC
intern/MOD_gpencilthick.c
intern/MOD_gpenciltime.c
intern/MOD_gpenciltint.c
+ intern/MOD_gpencilweight.c
MOD_gpencil_lineart.h
MOD_gpencil_modifiertypes.h
diff --git a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
index f8a28f2e5cb..18310bd5dff 100644
--- a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
+++ b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
@@ -44,6 +44,7 @@ extern GpencilModifierTypeInfo modifierType_Gpencil_Armature;
extern GpencilModifierTypeInfo modifierType_Gpencil_Time;
extern GpencilModifierTypeInfo modifierType_Gpencil_Multiply;
extern GpencilModifierTypeInfo modifierType_Gpencil_Texture;
+extern GpencilModifierTypeInfo modifierType_Gpencil_Weight;
extern GpencilModifierTypeInfo modifierType_Gpencil_Lineart;
/* MOD_gpencil_util.c */
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
index 94285b5032e..a156fca5b7b 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
@@ -203,20 +203,6 @@ void gpencil_modifier_curve_panel_draw(const bContext *UNUSED(C), Panel *panel)
uiTemplateCurveMapping(layout, ptr, "curve", 0, false, false, false, false);
}
-void gpencil_modifier_fading_draw(const bContext *UNUSED(C), Panel *panel)
-{
- PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
-
- uiLayout *layout = panel->layout;
- uiLayoutSetPropSep(layout, true);
-
- uiItemR(layout, ptr, "object", 0, NULL, ICON_CUBE);
- uiLayout *sub = uiLayoutColumn(layout, true);
- uiItemR(sub, ptr, "fading_start", 0, NULL, ICON_NONE);
- uiItemR(sub, ptr, "fading_end", 0, IFACE_("End"), ICON_NONE);
- uiItemR(layout, ptr, "fading_end_factor", 0, NULL, ICON_NONE);
-}
-
/**
* Draw modifier error message.
*/
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h
index 75907aaa781..782b36d47ed 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h
@@ -37,8 +37,6 @@ void gpencil_modifier_masking_panel_draw(Panel *panel, bool use_material, bool u
void gpencil_modifier_curve_header_draw(const bContext *C, Panel *panel);
void gpencil_modifier_curve_panel_draw(const bContext *C, Panel *panel);
-void gpencil_modifier_fading_draw(const bContext *UNUSED(C), Panel *panel);
-
void gpencil_modifier_panel_end(struct uiLayout *layout, PointerRNA *ptr);
struct PointerRNA *gpencil_modifier_panel_get_property_pointers(struct Panel *panel,
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
index b28a44a0521..6409c86b6e3 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -63,6 +63,7 @@ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[])
INIT_GP_TYPE(Time);
INIT_GP_TYPE(Multiply);
INIT_GP_TYPE(Texture);
+ INIT_GP_TYPE(Weight);
INIT_GP_TYPE(Lineart);
#undef INIT_GP_TYPE
}
@@ -152,16 +153,16 @@ float get_modifier_point_weight(MDeformVert *dvert, bool inverse, int def_nr)
if ((dvert != NULL) && (def_nr != -1)) {
MDeformWeight *dw = BKE_defvert_find_index(dvert, def_nr);
weight = dw ? dw->weight : -1.0f;
- if ((weight >= 0.0f) && (inverse == 1)) {
+ if ((weight >= 0.0f) && (inverse)) {
return -1.0f;
}
- if ((weight < 0.0f) && (inverse == 0)) {
+ if ((weight < 0.0f) && (!inverse)) {
return -1.0f;
}
/* if inverse, weight is always 1 */
- if ((weight < 0.0f) && (inverse == 1)) {
+ if ((weight < 0.0f) && (inverse)) {
return 1.0f;
}
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index ba5b1a5cb31..f58de44b04c 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -103,7 +103,7 @@ static void generate_strokes_actual(
lmd->target_material ? BKE_gpencil_object_material_index_get(ob, lmd->target_material) : 0,
lmd->edge_types,
lmd->mask_switches,
- lmd->transparency_mask,
+ lmd->material_mask_bits,
lmd->intersection_mask,
lmd->thickness,
lmd->opacity,
@@ -258,18 +258,11 @@ static void updateDepsgraph(GpencilModifierData *md,
else {
add_this_collection(ctx->scene->master_collection, ctx, mode);
}
- if (lmd->calculation_flags & LRT_USE_CUSTOM_CAMERA) {
- DEG_add_object_relation(
- ctx->node, lmd->source_camera, DEG_OB_COMP_TRANSFORM, "Line Art Modifier");
- DEG_add_object_relation(
- ctx->node, lmd->source_camera, DEG_OB_COMP_PARAMETERS, "Line Art Modifier");
- }
- else {
- DEG_add_object_relation(
- ctx->node, ctx->scene->camera, DEG_OB_COMP_TRANSFORM, "Line Art Modifier");
- DEG_add_object_relation(
- ctx->node, ctx->scene->camera, DEG_OB_COMP_PARAMETERS, "Line Art Modifier");
- }
+
+ DEG_add_object_relation(
+ ctx->node, ctx->scene->camera, DEG_OB_COMP_TRANSFORM, "Line Art Modifier");
+ DEG_add_object_relation(
+ ctx->node, ctx->scene->camera, DEG_OB_COMP_PARAMETERS, "Line Art Modifier");
}
static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
@@ -295,8 +288,6 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
const int source_type = RNA_enum_get(ptr, "source_type");
const bool is_baked = RNA_boolean_get(ptr, "is_baked");
- const bool use_cache = RNA_boolean_get(ptr, "use_cache");
- const bool is_first = BKE_gpencil_is_first_lineart_in_stack(ob_ptr.data, ptr->data);
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, !is_baked);
@@ -316,26 +307,6 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
else {
/* Source is Scene. */
}
-
- uiLayout *col = uiLayoutColumnWithHeading(layout, true, IFACE_("Edge Types"));
-
- uiItemR(col, ptr, "use_contour", 0, IFACE_("Contour"), ICON_NONE);
- uiItemR(col, ptr, "use_floating", 0, IFACE_("Floating"), ICON_NONE);
- uiItemR(col, ptr, "use_material", 0, IFACE_("Material Borders"), ICON_NONE);
- uiItemR(col, ptr, "use_edge_mark", 0, IFACE_("Edge Marks"), ICON_NONE);
- uiItemR(col, ptr, "use_intersection", 0, IFACE_("Intersections"), ICON_NONE);
-
- uiLayout *sub = uiLayoutRowWithHeading(col, false, IFACE_("Crease"));
- uiItemR(sub, ptr, "use_crease", 0, "", ICON_NONE);
- uiLayout *entry = uiLayoutRow(sub, false);
- uiLayoutSetActive(entry, RNA_boolean_get(ptr, "use_crease") || is_first);
- if (use_cache && !is_first) {
- uiItemL(entry, IFACE_("Angle Cached"), ICON_INFO);
- }
- else {
- uiItemR(entry, ptr, "crease_threshold", UI_ITEM_R_SLIDER, " ", ICON_NONE);
- }
-
uiItemPointerR(layout, ptr, "target_layer", &obj_data_ptr, "layers", NULL, ICON_GREASEPENCIL);
/* Material has to be used by grease pencil object already, it was possible to assign materials
@@ -360,6 +331,42 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
gpencil_modifier_panel_end(layout, ptr);
}
+static void edge_types_panel_draw(const bContext *UNUSED(C), Panel *panel)
+{
+ uiLayout *layout = panel->layout;
+ PointerRNA ob_ptr;
+ PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, &ob_ptr);
+
+ const bool is_baked = RNA_boolean_get(ptr, "is_baked");
+ const bool use_cache = RNA_boolean_get(ptr, "use_cached_result");
+ const bool is_first = BKE_gpencil_is_first_lineart_in_stack(ob_ptr.data, ptr->data);
+
+ uiLayoutSetEnabled(layout, !is_baked);
+
+ uiLayoutSetPropSep(layout, true);
+
+ uiLayout *col = uiLayoutColumn(layout, true);
+
+ uiItemR(col, ptr, "use_contour", 0, IFACE_("Contour"), ICON_NONE);
+ uiItemR(col, ptr, "use_loose", 0, IFACE_("Loose"), ICON_NONE);
+ uiItemR(col, ptr, "use_material", 0, IFACE_("Material Borders"), ICON_NONE);
+ uiItemR(col, ptr, "use_edge_mark", 0, IFACE_("Edge Marks"), ICON_NONE);
+ uiItemR(col, ptr, "use_intersection", 0, IFACE_("Intersections"), ICON_NONE);
+
+ uiLayout *sub = uiLayoutRowWithHeading(col, false, IFACE_("Crease"));
+ uiItemR(sub, ptr, "use_crease", 0, "", ICON_NONE);
+ uiLayout *entry = uiLayoutRow(sub, false);
+ uiLayoutSetEnabled(entry, RNA_boolean_get(ptr, "use_crease") || is_first);
+ if (use_cache && !is_first) {
+ uiItemL(entry, IFACE_("Angle Cached"), ICON_INFO);
+ }
+ else {
+ uiItemR(entry, ptr, "crease_threshold", UI_ITEM_R_SLIDER, " ", ICON_NONE);
+ }
+
+ uiItemR(layout, ptr, "use_overlap_edge_type_support", 0, IFACE_("Allow Overlap"), ICON_NONE);
+}
+
static void options_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *layout = panel->layout;
@@ -434,46 +441,46 @@ static void occlusion_panel_draw(const bContext *UNUSED(C), Panel *panel)
}
}
-static void transparency_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
+static void material_mask_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *layout = panel->layout;
- PointerRNA ob_ptr;
- PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, &ob_ptr);
+ PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
const bool is_baked = RNA_boolean_get(ptr, "is_baked");
- const bool show_in_front = RNA_boolean_get(&ob_ptr, "show_in_front");
-
uiLayoutSetEnabled(layout, !is_baked);
- uiLayoutSetActive(layout, show_in_front);
- uiItemR(layout, ptr, "use_transparency", 0, IFACE_("Transparency"), ICON_NONE);
+ uiItemR(layout, ptr, "use_material_mask", 0, IFACE_("Material Mask"), ICON_NONE);
}
-static void transparency_panel_draw(const bContext *UNUSED(C), Panel *panel)
+static void material_mask_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *layout = panel->layout;
- PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
+ PointerRNA ob_ptr;
+ PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, &ob_ptr);
const bool is_baked = RNA_boolean_get(ptr, "is_baked");
+ const bool show_in_front = RNA_boolean_get(&ob_ptr, "show_in_front");
+
uiLayoutSetEnabled(layout, !is_baked);
+ uiLayoutSetActive(layout, show_in_front);
uiLayoutSetPropSep(layout, true);
- uiLayoutSetActive(layout, RNA_boolean_get(ptr, "use_transparency"));
+ uiLayoutSetEnabled(layout, RNA_boolean_get(ptr, "use_material_mask"));
uiLayout *row = uiLayoutRow(layout, true);
uiLayoutSetPropDecorate(row, false);
uiLayout *sub = uiLayoutRowWithHeading(row, true, IFACE_("Masks"));
char text[2] = "0";
- PropertyRNA *prop = RNA_struct_find_property(ptr, "use_transparency_mask");
- for (int i = 0; i < 6; i++, text[0]++) {
+ PropertyRNA *prop = RNA_struct_find_property(ptr, "use_material_mask_bits");
+ for (int i = 0; i < 8; i++, text[0]++) {
uiItemFullR(sub, ptr, prop, i, 0, UI_ITEM_R_TOGGLE, text, ICON_NONE);
}
uiItemL(row, "", ICON_BLANK1); /* Space for decorator. */
uiLayout *col = uiLayoutColumn(layout, true);
- uiItemR(col, ptr, "use_transparency_match", 0, IFACE_("Match All Masks"), ICON_NONE);
+ uiItemR(col, ptr, "use_material_mask_match", 0, IFACE_("Match All Masks"), ICON_NONE);
}
static void intersection_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
@@ -567,6 +574,7 @@ static void chaining_panel_draw(const bContext *UNUSED(C), Panel *panel)
const bool is_baked = RNA_boolean_get(ptr, "is_baked");
const bool use_cache = RNA_boolean_get(ptr, "use_cached_result");
const bool is_first = BKE_gpencil_is_first_lineart_in_stack(ob_ptr.data, ptr->data);
+ const bool is_geom = RNA_boolean_get(ptr, "use_geometry_space_chain");
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, !is_baked);
@@ -579,10 +587,16 @@ static void chaining_panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayout *col = uiLayoutColumnWithHeading(layout, true, IFACE_("Chain"));
uiItemR(col, ptr, "use_fuzzy_intersections", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "use_fuzzy_all", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "chain_floating_edges", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "chain_geometry_space", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "use_loose_edge_chain", 0, IFACE_("Loose Edges"), ICON_NONE);
+ uiItemR(col, ptr, "use_loose_as_contour", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "use_geometry_space_chain", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "chaining_image_threshold", 0, NULL, ICON_NONE);
+ uiItemR(layout,
+ ptr,
+ "chaining_image_threshold",
+ 0,
+ is_geom ? IFACE_("Geometry Threshold") : NULL,
+ ICON_NONE);
uiItemR(layout, ptr, "smooth_tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(layout, ptr, "split_angle", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
@@ -681,16 +695,18 @@ static void panelRegister(ARegionType *region_type)
region_type, eGpencilModifierType_Lineart, panel_draw);
gpencil_modifier_subpanel_register(
+ region_type, "edge_types", "Edge Types", NULL, edge_types_panel_draw, panel_type);
+ gpencil_modifier_subpanel_register(
region_type, "geometry", "Geometry Processing", NULL, options_panel_draw, panel_type);
gpencil_modifier_subpanel_register(
region_type, "style", "Style", NULL, style_panel_draw, panel_type);
PanelType *occlusion_panel = gpencil_modifier_subpanel_register(
region_type, "occlusion", "Occlusion", NULL, occlusion_panel_draw, panel_type);
gpencil_modifier_subpanel_register(region_type,
- "transparency",
+ "material_mask",
"",
- transparency_panel_draw_header,
- transparency_panel_draw,
+ material_mask_panel_draw_header,
+ material_mask_panel_draw,
occlusion_panel);
gpencil_modifier_subpanel_register(region_type,
"intersection",
@@ -701,6 +717,10 @@ static void panelRegister(ARegionType *region_type)
gpencil_modifier_subpanel_register(
region_type, "face_mark", "", face_mark_panel_draw_header, face_mark_panel_draw, panel_type);
gpencil_modifier_subpanel_register(
+ region_type, "intersection", "Intersection", NULL, intersection_panel_draw, panel_type);
+ gpencil_modifier_subpanel_register(
+ region_type, "face_mark", "", face_mark_panel_draw_header, face_mark_panel_draw, panel_type);
+ gpencil_modifier_subpanel_register(
region_type, "chaining", "Chaining", NULL, chaining_panel_draw, panel_type);
gpencil_modifier_subpanel_register(
region_type, "vgroup", "Vertex Weight Transfer", NULL, vgroup_panel_draw, panel_type);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
index e8122bf5823..9e9eba3d61e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
@@ -313,7 +313,7 @@ static void random_header_draw(const bContext *UNUSED(C), Panel *panel)
PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
- uiItemR(layout, ptr, "random", 0, IFACE_("Randomize"), ICON_NONE);
+ uiItemR(layout, ptr, "use_random", 0, IFACE_("Randomize"), ICON_NONE);
}
static void random_panel_draw(const bContext *UNUSED(C), Panel *panel)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
index 9f03e493ea8..fb75b1e99ac 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
@@ -47,8 +47,6 @@
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
-#include "DEG_depsgraph_build.h"
-#include "DEG_depsgraph_query.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -86,39 +84,6 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
tgmd->curve_intensity = BKE_curvemapping_copy(gmd->curve_intensity);
}
-static float give_opacity_fading_factor(OpacityGpencilModifierData *mmd,
- Object *ob_this,
- float *pos,
- bool apply_obmat)
-{
- float factor_depth = 1.0f;
-
- if (((mmd->flag & GP_OPACITY_FADING) == 0) || ((mmd->object) == NULL)) {
- return factor_depth;
- }
-
- float gvert[3];
- if (apply_obmat) {
- mul_v3_m4v3(gvert, ob_this->obmat, pos);
- }
- float dist = len_v3v3(mmd->object->obmat[3], gvert);
- float fading_max = MAX2(mmd->fading_start, mmd->fading_end);
- float fading_min = MIN2(mmd->fading_start, mmd->fading_end);
-
- /* Better with ratiof() function from line art. */
- if (dist > fading_max) {
- factor_depth = 0.0f;
- }
- else if (dist <= fading_max && dist > fading_min) {
- factor_depth = (fading_max - dist) / (fading_max - fading_min);
- }
- else {
- factor_depth = 1.0f;
- }
-
- return factor_depth;
-}
-
/* opacity strokes */
static void deformStroke(GpencilModifierData *md,
Depsgraph *UNUSED(depsgraph),
@@ -130,6 +95,9 @@ static void deformStroke(GpencilModifierData *md,
OpacityGpencilModifierData *mmd = (OpacityGpencilModifierData *)md;
const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname);
const bool use_curve = (mmd->flag & GP_OPACITY_CUSTOM_CURVE) != 0 && mmd->curve_intensity;
+ const bool is_normalized = (mmd->flag & GP_OPACITY_NORMALIZE);
+ bool is_inverted = ((mmd->flag & GP_OPACITY_WEIGHT_FACTOR) == 0) &&
+ ((mmd->flag & GP_OPACITY_INVERT_VGROUP) != 0);
if (!is_stroke_affected_by_modifier(ob,
mmd->layername,
@@ -161,11 +129,17 @@ static void deformStroke(GpencilModifierData *md,
/* Stroke using strength. */
if (mmd->modify_color != GP_MODIFY_COLOR_FILL) {
/* verify vertex group */
- float weight = get_modifier_point_weight(
- dvert, (mmd->flag & GP_OPACITY_INVERT_VGROUP) != 0, def_nr);
+ float weight = get_modifier_point_weight(dvert, is_inverted, def_nr);
if (weight < 0.0f) {
continue;
}
+
+ /* Apply weight directly. */
+ if ((mmd->flag & GP_OPACITY_WEIGHT_FACTOR) && (!is_normalized)) {
+ pt->strength *= ((mmd->flag & GP_OPACITY_INVERT_VGROUP) ? 1.0f - weight : weight);
+ continue;
+ }
+
/* Custom curve to modulate value. */
float factor_curve = mmd->factor;
if (use_curve) {
@@ -173,9 +147,6 @@ static void deformStroke(GpencilModifierData *md,
factor_curve *= BKE_curvemapping_evaluateF(mmd->curve_intensity, 0, value);
}
- float factor_depth = give_opacity_fading_factor(mmd, ob, &pt->x, true);
- factor_curve = interpf(factor_curve, mmd->fading_end_factor, factor_depth);
-
if (def_nr < 0) {
if (mmd->flag & GP_OPACITY_NORMALIZE) {
pt->strength = factor_curve;
@@ -204,9 +175,19 @@ static void deformStroke(GpencilModifierData *md,
/* Fill using opacity factor. */
if (mmd->modify_color != GP_MODIFY_COLOR_STROKE) {
- float factor_depth = give_opacity_fading_factor(mmd, ob, ob->obmat[3], true);
- gps->fill_opacity_fac = interpf(mmd->factor, mmd->fading_end_factor, factor_depth);
+ float fill_factor = mmd->factor;
+ if ((mmd->flag & GP_OPACITY_WEIGHT_FACTOR) && (!is_normalized)) {
+ /* Use first point for weight. */
+ MDeformVert *dvert = (gps->dvert != NULL) ? &gps->dvert[0] : NULL;
+ float weight = get_modifier_point_weight(
+ dvert, (mmd->flag & GP_OPACITY_INVERT_VGROUP) != 0, def_nr);
+ if (weight >= 0.0f) {
+ fill_factor = ((mmd->flag & GP_OPACITY_INVERT_VGROUP) ? 1.0f - weight : weight);
+ }
+ }
+
+ gps->fill_opacity_fac = fill_factor;
CLAMP(gps->fill_opacity_fac, 0.0f, 1.0f);
}
}
@@ -241,18 +222,6 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
OpacityGpencilModifierData *mmd = (OpacityGpencilModifierData *)md;
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
- walk(userData, ob, (ID **)&mmd->object, IDWALK_CB_NOP);
-}
-
-static void updateDepsgraph(GpencilModifierData *md,
- const ModifierUpdateDepsgraphContext *ctx,
- const int UNUSED(mode))
-{
- OpacityGpencilModifierData *mmd = (OpacityGpencilModifierData *)md;
- if (mmd->object != NULL) {
- DEG_add_object_relation(ctx->node, mmd->object, DEG_OB_COMP_TRANSFORM, "Opacity Modifier");
- }
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Opacity Modifier");
}
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
@@ -271,29 +240,25 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
uiItemR(layout, ptr, "hardness", 0, NULL, ICON_NONE);
}
else {
+ const bool is_normalized = RNA_boolean_get(ptr, "normalize_opacity");
+ const bool is_weighted = RNA_boolean_get(ptr, "use_weight_factor");
+
uiItemR(layout, ptr, "normalize_opacity", 0, NULL, ICON_NONE);
- const char *text = (RNA_boolean_get(ptr, "normalize_opacity")) ? IFACE_("Strength") :
- IFACE_("Opacity Factor");
- uiItemR(layout, ptr, "factor", 0, text, ICON_NONE);
+ const char *text = (is_normalized) ? IFACE_("Strength") : IFACE_("Opacity Factor");
+
+ uiLayout *row = uiLayoutRow(layout, true);
+ uiLayoutSetActive(row, !is_weighted || is_normalized);
+ uiItemR(row, ptr, "factor", 0, text, ICON_NONE);
+ if (!is_normalized) {
+ uiLayout *sub = uiLayoutRow(row, true);
+ uiLayoutSetActive(sub, true);
+ uiItemR(row, ptr, "use_weight_factor", 0, "", ICON_MOD_VERTEX_WEIGHT);
+ }
}
gpencil_modifier_panel_end(layout, ptr);
}
-static void fading_header_draw(const bContext *UNUSED(C), Panel *panel)
-{
- uiLayout *layout = panel->layout;
-
- PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
-
- uiItemR(layout, ptr, "use_fading", 0, NULL, ICON_NONE);
-}
-
-static void fading_panel_draw(const bContext *C, Panel *panel)
-{
- gpencil_modifier_fading_draw(C, panel);
-}
-
static void mask_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
@@ -333,8 +298,6 @@ static void panelRegister(ARegionType *region_type)
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Opacity, panel_draw);
- gpencil_modifier_subpanel_register(
- region_type, "fading", "", fading_header_draw, fading_panel_draw, panel_type);
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
gpencil_modifier_subpanel_register(
@@ -358,7 +321,7 @@ GpencilModifierTypeInfo modifierType_Gpencil_Opacity = {
/* initData */ initData,
/* freeData */ freeData,
/* isDisabled */ NULL,
- /* updateDepsgraph */ updateDepsgraph,
+ /* updateDepsgraph */ NULL,
/* dependsOnTime */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
index 126949cd659..cac700e15f4 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
@@ -43,8 +43,6 @@
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
-#include "DEG_depsgraph_build.h"
-#include "DEG_depsgraph_query.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -118,42 +116,28 @@ static void deformStroke(GpencilModifierData *md,
}
float stroke_thickness_inv = 1.0f / max_ii(gps->thickness, 1);
+ const bool is_normalized = (mmd->flag & GP_THICK_NORMALIZE);
+ bool is_inverted = ((mmd->flag & GP_THICK_WEIGHT_FACTOR) == 0) &&
+ ((mmd->flag & GP_THICK_INVERT_VGROUP) != 0);
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
MDeformVert *dvert = gps->dvert != NULL ? &gps->dvert[i] : NULL;
/* Verify point is part of vertex group. */
- float weight = get_modifier_point_weight(
- dvert, (mmd->flag & GP_THICK_INVERT_VGROUP) != 0, def_nr);
+ float weight = get_modifier_point_weight(dvert, is_inverted, def_nr);
if (weight < 0.0f) {
continue;
}
- float curvef = 1.0f;
-
- float factor_depth = 1.0f;
-
- if (mmd->flag & GP_THICK_FADING) {
- if (mmd->object) {
- float gvert[3];
- mul_v3_m4v3(gvert, ob->obmat, &pt->x);
- float dist = len_v3v3(mmd->object->obmat[3], gvert);
- float fading_max = MAX2(mmd->fading_start, mmd->fading_end);
- float fading_min = MIN2(mmd->fading_start, mmd->fading_end);
-
- /* Better with ratiof() function from line art. */
- if (dist > fading_max) {
- factor_depth = 0.0f;
- }
- else if (dist <= fading_max && dist > fading_min) {
- factor_depth = (fading_max - dist) / (fading_max - fading_min);
- }
- else {
- factor_depth = 1.0f;
- }
- }
+ /* Apply weight directly. */
+ if ((!is_normalized) && (mmd->flag & GP_THICK_WEIGHT_FACTOR)) {
+ pt->pressure *= ((mmd->flag & GP_THICK_INVERT_VGROUP) ? 1.0f - weight : weight);
+ CLAMP_MIN(pt->pressure, 0.0f);
+ continue;
}
+ float curvef = 1.0f;
+
if ((mmd->flag & GP_THICK_CUSTOM_CURVE) && (mmd->curve_thickness)) {
/* Normalize value to evaluate curve. */
float value = (float)i / (gps->totpoints - 1);
@@ -161,7 +145,7 @@ static void deformStroke(GpencilModifierData *md,
}
float target;
- if (mmd->flag & GP_THICK_NORMALIZE) {
+ if (is_normalized) {
target = mmd->thickness * stroke_thickness_inv;
target *= curvef;
}
@@ -170,11 +154,6 @@ static void deformStroke(GpencilModifierData *md,
weight *= curvef;
}
- /* Apply distance fading. */
- if (mmd->flag & GP_THICK_FADING) {
- target = interpf(target, mmd->fading_end_factor, factor_depth);
- }
-
pt->pressure = interpf(target, pt->pressure, weight);
CLAMP_MIN(pt->pressure, 0.0f);
@@ -202,32 +181,6 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
ThickGpencilModifierData *mmd = (ThickGpencilModifierData *)md;
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
- walk(userData, ob, (ID **)&mmd->object, IDWALK_CB_NOP);
-}
-
-static void updateDepsgraph(GpencilModifierData *md,
- const ModifierUpdateDepsgraphContext *ctx,
- const int UNUSED(mode))
-{
- ThickGpencilModifierData *mmd = (ThickGpencilModifierData *)md;
- if (mmd->object != NULL) {
- DEG_add_object_relation(ctx->node, mmd->object, DEG_OB_COMP_TRANSFORM, "Thickness Modifier");
- }
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Thickness Modifier");
-}
-
-static void fading_header_draw(const bContext *UNUSED(C), Panel *panel)
-{
- uiLayout *layout = panel->layout;
-
- PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
-
- uiItemR(layout, ptr, "use_fading", 0, NULL, ICON_NONE);
-}
-
-static void fading_panel_draw(const bContext *C, Panel *panel)
-{
- gpencil_modifier_fading_draw(C, panel);
}
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
@@ -239,12 +192,17 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayoutSetPropSep(layout, true);
uiItemR(layout, ptr, "normalize_thickness", 0, NULL, ICON_NONE);
-
if (RNA_boolean_get(ptr, "normalize_thickness")) {
uiItemR(layout, ptr, "thickness", 0, NULL, ICON_NONE);
}
else {
- uiItemR(layout, ptr, "thickness_factor", 0, NULL, ICON_NONE);
+ const bool is_weighted = !RNA_boolean_get(ptr, "use_weight_factor");
+ uiLayout *row = uiLayoutRow(layout, true);
+ uiLayoutSetActive(row, is_weighted);
+ uiItemR(row, ptr, "thickness_factor", 0, NULL, ICON_NONE);
+ uiLayout *sub = uiLayoutRow(row, true);
+ uiLayoutSetActive(sub, true);
+ uiItemR(row, ptr, "use_weight_factor", 0, "", ICON_MOD_VERTEX_WEIGHT);
}
gpencil_modifier_panel_end(layout, ptr);
@@ -259,8 +217,6 @@ static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Thick, panel_draw);
- gpencil_modifier_subpanel_register(
- region_type, "fading", "", fading_header_draw, fading_panel_draw, panel_type);
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
gpencil_modifier_subpanel_register(region_type,
@@ -288,7 +244,7 @@ GpencilModifierTypeInfo modifierType_Gpencil_Thick = {
/* initData */ initData,
/* freeData */ freeData,
/* isDisabled */ NULL,
- /* updateDepsgraph */ updateDepsgraph,
+ /* updateDepsgraph */ NULL,
/* dependsOnTime */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
index 4a6e3df59c7..63546c26068 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
@@ -127,6 +127,8 @@ static void deformStroke(GpencilModifierData *md,
const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname);
const bool use_curve = (mmd->flag & GP_TINT_CUSTOM_CURVE) != 0 && mmd->curve_intensity;
+ bool is_inverted = ((mmd->flag & GP_TINT_WEIGHT_FACTOR) == 0) &&
+ ((mmd->flag & GP_TINT_INVERT_VGROUP) != 0);
if (!is_stroke_affected_by_modifier(ob,
mmd->layername,
@@ -169,6 +171,17 @@ static void deformStroke(GpencilModifierData *md,
if (!fill_done) {
/* Apply to fill. */
if (mmd->mode != GPPAINT_MODE_STROKE) {
+ float fill_factor = mmd->factor;
+
+ /* Use weightened factor. */
+ if (mmd->flag & GP_TINT_WEIGHT_FACTOR) {
+ /* Use first point for weight. */
+ MDeformVert *dvert_fill = (gps->dvert != NULL) ? &gps->dvert[0] : NULL;
+ float weight = get_modifier_point_weight(dvert_fill, is_inverted, def_nr);
+ if (weight >= 0.0f) {
+ fill_factor = ((mmd->flag & GP_TINT_INVERT_VGROUP) ? 1.0f - weight : weight);
+ }
+ }
/* If not using Vertex Color, use the material color. */
if ((gp_style != NULL) && (gps->vert_color_fill[3] == 0.0f) &&
@@ -188,13 +201,13 @@ static void deformStroke(GpencilModifierData *md,
BKE_colorband_evaluate(mmd->colorband, mix_factor, coba_res);
interp_v3_v3v3(gps->vert_color_fill, gps->vert_color_fill, coba_res, mmd->factor);
- gps->vert_color_fill[3] = clamp_f(mmd->factor, 0.0f, 1.0f);
+ gps->vert_color_fill[3] = clamp_f(fill_factor, 0.0f, 1.0f);
}
else {
interp_v3_v3v3(gps->vert_color_fill,
gps->vert_color_fill,
mmd->rgb,
- clamp_f(mmd->factor, 0.0f, 1.0f));
+ clamp_f(fill_factor, 0.0f, 1.0f));
}
/* If no stroke, cancel loop. */
if (mmd->mode != GPPAINT_MODE_BOTH) {
@@ -207,11 +220,13 @@ static void deformStroke(GpencilModifierData *md,
/* Verify vertex group. */
if (mmd->mode != GPPAINT_MODE_FILL) {
- float weight = get_modifier_point_weight(
- dvert, (mmd->flag & GP_TINT_INVERT_VGROUP) != 0, def_nr);
+ float weight = get_modifier_point_weight(dvert, is_inverted, def_nr);
if (weight < 0.0f) {
continue;
}
+
+ float factor = mmd->factor;
+
/* Custom curve to modulate value. */
if (use_curve) {
float value = (float)i / (gps->totpoints - 1);
@@ -224,6 +239,12 @@ static void deformStroke(GpencilModifierData *md,
pt->vert_color[3] = 1.0f;
}
+ /* Apply weight directly. */
+ if (mmd->flag & GP_TINT_WEIGHT_FACTOR) {
+ factor = ((mmd->flag & GP_TINT_INVERT_VGROUP) ? 1.0f - weight : weight);
+ weight = 1.0f;
+ }
+
if (is_gradient) {
/* Calc world position of point. */
float pt_loc[3];
@@ -237,11 +258,11 @@ static void deformStroke(GpencilModifierData *md,
interp_v3_v3v3(pt->vert_color,
pt->vert_color,
coba_res,
- clamp_f(mmd->factor, 0.0f, 1.0f) * weight * coba_res[3]);
+ clamp_f(factor, 0.0f, 1.0f) * weight * coba_res[3]);
}
else {
interp_v3_v3v3(
- pt->vert_color, pt->vert_color, mmd->rgb, clamp_f(mmd->factor * weight, 0.0, 1.0f));
+ pt->vert_color, pt->vert_color, mmd->rgb, clamp_f(factor * weight, 0.0, 1.0f));
}
}
}
@@ -338,7 +359,15 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayoutSetPropSep(layout, true);
uiItemR(layout, ptr, "vertex_mode", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "factor", 0, NULL, ICON_NONE);
+
+ const bool is_weighted = !RNA_boolean_get(ptr, "use_weight_factor");
+ uiLayout *row = uiLayoutRow(layout, true);
+ uiLayoutSetActive(row, is_weighted);
+ uiItemR(row, ptr, "factor", 0, NULL, ICON_NONE);
+ uiLayout *sub = uiLayoutRow(row, true);
+ uiLayoutSetActive(sub, true);
+ uiItemR(row, ptr, "use_weight_factor", 0, "", ICON_MOD_VERTEX_WEIGHT);
+
uiItemR(layout, ptr, "tint_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
if (tint_type == GP_TINT_UNIFORM) {
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilweight.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilweight.c
new file mode 100644
index 00000000000..c7fe20edef7
--- /dev/null
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilweight.c
@@ -0,0 +1,335 @@
+/*
+ * 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) 2021, Blender Foundation
+ * This is a new part of Blender
+ */
+
+/** \file
+ * \ingroup modifiers
+ */
+
+#include <stdio.h>
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "DNA_defaults.h"
+#include "DNA_gpencil_modifier_types.h"
+#include "DNA_gpencil_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+#include "DNA_screen_types.h"
+
+#include "BKE_colortools.h"
+#include "BKE_context.h"
+#include "BKE_deform.h"
+#include "BKE_gpencil.h"
+#include "BKE_gpencil_modifier.h"
+#include "BKE_lib_query.h"
+#include "BKE_modifier.h"
+#include "BKE_screen.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "RNA_access.h"
+
+#include "MOD_gpencil_modifiertypes.h"
+#include "MOD_gpencil_ui_common.h"
+#include "MOD_gpencil_util.h"
+
+static void initData(GpencilModifierData *md)
+{
+ WeightGpencilModifierData *gpmd = (WeightGpencilModifierData *)md;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(WeightGpencilModifierData), modifier);
+}
+
+static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
+{
+ BKE_gpencil_modifier_copydata_generic(md, target);
+}
+
+/* Calc distance between point and target object. */
+static float calc_point_weight_by_distance(Object *ob,
+ WeightGpencilModifierData *mmd,
+ const float dist_max,
+ const float dist_min,
+ bGPDspoint *pt)
+{
+ float weight;
+ float gvert[3];
+ mul_v3_m4v3(gvert, ob->obmat, &pt->x);
+ float dist = len_v3v3(mmd->object->obmat[3], gvert);
+
+ if (dist > dist_max) {
+ weight = 0.0f;
+ }
+ else if (dist <= dist_max && dist > dist_min) {
+ weight = (dist_max - dist) / max_ff((dist_max - dist_min), 0.0001f);
+ }
+ else {
+ weight = 1.0f;
+ }
+
+ return weight;
+}
+
+/* change stroke thickness */
+static void deformStroke(GpencilModifierData *md,
+ Depsgraph *UNUSED(depsgraph),
+ Object *ob,
+ bGPDlayer *gpl,
+ bGPDframe *UNUSED(gpf),
+ bGPDstroke *gps)
+{
+ WeightGpencilModifierData *mmd = (WeightGpencilModifierData *)md;
+ const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname);
+ const eWeightGpencilModifierMode mode = mmd->mode;
+
+ if (!is_stroke_affected_by_modifier(ob,
+ mmd->layername,
+ mmd->material,
+ mmd->pass_index,
+ mmd->layer_pass,
+ 1,
+ gpl,
+ gps,
+ mmd->flag & GP_WEIGHT_INVERT_LAYER,
+ mmd->flag & GP_WEIGHT_INVERT_PASS,
+ mmd->flag & GP_WEIGHT_INVERT_LAYERPASS,
+ mmd->flag & GP_WEIGHT_INVERT_MATERIAL)) {
+ return;
+ }
+
+ const float dist_max = MAX2(mmd->dist_start, mmd->dist_end);
+ const float dist_min = MIN2(mmd->dist_start, mmd->dist_end);
+ const int target_def_nr = BKE_object_defgroup_name_index(ob, mmd->target_vgname);
+
+ if (target_def_nr == -1) {
+ return;
+ }
+
+ /* Use default Z up. */
+ float vec_axis[3] = {0.0f, 0.0f, 1.0f};
+ float axis[3] = {0.0f, 0.0f, 0.0f};
+ axis[mmd->axis] = 1.0f;
+ float vec_ref[3];
+ /* Apply modifier rotation (sub 90 degrees for Y axis due Z-Up vector). */
+ float rot_angle = mmd->angle - ((mmd->axis == 1) ? M_PI_2 : 0.0f);
+ rotate_normalized_v3_v3v3fl(vec_ref, vec_axis, axis, rot_angle);
+
+ /* Apply the rotation of the object. */
+ if (mmd->space == GP_SPACE_LOCAL) {
+ mul_mat3_m4_v3(ob->obmat, vec_ref);
+ }
+
+ /* Ensure there is a vertex group. */
+ BKE_gpencil_dvert_ensure(gps);
+
+ float weight_pt = 1.0f;
+ for (int i = 0; i < gps->totpoints; i++) {
+ MDeformVert *dvert = gps->dvert != NULL ? &gps->dvert[i] : NULL;
+ /* Verify point is part of vertex group. */
+ float weight = get_modifier_point_weight(
+ dvert, (mmd->flag & GP_WEIGHT_INVERT_VGROUP) != 0, def_nr);
+ if (weight < 0.0f) {
+ continue;
+ }
+
+ switch (mode) {
+ case GP_WEIGHT_MODE_DISTANCE: {
+ if (mmd->object) {
+ bGPDspoint *pt = &gps->points[i];
+ weight_pt = calc_point_weight_by_distance(ob, mmd, dist_max, dist_min, pt);
+ }
+ break;
+ }
+ case GP_WEIGHT_MODE_ANGLE: {
+ /* Special case for single points. */
+ if (gps->totpoints == 1) {
+ weight_pt = 1.0f;
+ break;
+ }
+
+ bGPDspoint *pt1 = (i > 0) ? &gps->points[i] : &gps->points[i + 1];
+ bGPDspoint *pt2 = (i > 0) ? &gps->points[i - 1] : &gps->points[i];
+ float fpt1[3], fpt2[3];
+ mul_v3_m4v3(fpt1, ob->obmat, &pt1->x);
+ mul_v3_m4v3(fpt2, ob->obmat, &pt2->x);
+
+ float vec[3];
+ sub_v3_v3v3(vec, fpt1, fpt2);
+ float angle = angle_on_axis_v3v3_v3(vec_ref, vec, axis);
+ /* Use sin to get a value between 0 and 1. */
+ weight_pt = 1.0f - sin(angle);
+ break;
+ }
+ default:
+ break;
+ }
+
+ /* Invert weight if required. */
+ if (mmd->flag & GP_WEIGHT_INVERT_OUTPUT) {
+ weight_pt = 1.0f - weight_pt;
+ }
+ /* Assign weight. */
+ dvert = gps->dvert != NULL ? &gps->dvert[i] : NULL;
+ if (dvert != NULL) {
+ MDeformWeight *dw = BKE_defvert_ensure_index(dvert, target_def_nr);
+ if (dw) {
+ dw->weight = (mmd->flag & GP_WEIGHT_BLEND_DATA) ? dw->weight * weight_pt : weight_pt;
+ CLAMP(dw->weight, mmd->min_weight, 1.0f);
+ }
+ }
+ }
+}
+
+static void bakeModifier(struct Main *UNUSED(bmain),
+ Depsgraph *depsgraph,
+ GpencilModifierData *md,
+ Object *ob)
+{
+ bGPdata *gpd = ob->data;
+
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ deformStroke(md, depsgraph, ob, gpl, gpf, gps);
+ }
+ }
+ }
+}
+
+static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
+{
+ WeightGpencilModifierData *mmd = (WeightGpencilModifierData *)md;
+
+ walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
+ walk(userData, ob, (ID **)&mmd->object, IDWALK_CB_NOP);
+}
+
+static void updateDepsgraph(GpencilModifierData *md,
+ const ModifierUpdateDepsgraphContext *ctx,
+ const int UNUSED(mode))
+{
+ WeightGpencilModifierData *mmd = (WeightGpencilModifierData *)md;
+ if (mmd->object != NULL) {
+ DEG_add_object_relation(
+ ctx->node, mmd->object, DEG_OB_COMP_TRANSFORM, "GPencil Weight Modifier");
+ }
+ DEG_add_object_relation(
+ ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "GPencil Weight Modifier");
+}
+
+static bool isDisabled(GpencilModifierData *md, int UNUSED(userRenderParams))
+{
+ WeightGpencilModifierData *mmd = (WeightGpencilModifierData *)md;
+
+ return !(mmd->target_vgname && mmd->target_vgname[0] != '\0');
+}
+
+static void distance_panel_draw(const bContext *UNUSED(C), Panel *panel)
+{
+ PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
+
+ uiLayout *layout = panel->layout;
+ uiLayoutSetPropSep(layout, true);
+
+ uiItemR(layout, ptr, "object", 0, NULL, ICON_CUBE);
+ uiLayout *sub = uiLayoutColumn(layout, true);
+ uiItemR(sub, ptr, "distance_start", 0, NULL, ICON_NONE);
+ uiItemR(sub, ptr, "distance_end", 0, "End", ICON_NONE);
+}
+
+static void panel_draw(const bContext *C, Panel *panel)
+{
+ uiLayout *layout = panel->layout;
+
+ PointerRNA ob_ptr;
+ PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, &ob_ptr);
+
+ uiLayoutSetPropSep(layout, true);
+ uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
+
+ const eWeightGpencilModifierMode mode = RNA_enum_get(ptr, "mode");
+
+ uiItemPointerR(layout, ptr, "target_vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE);
+
+ uiItemR(layout, ptr, "minimum_weight", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "use_invert_output", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "use_blend", 0, NULL, ICON_NONE);
+
+ switch (mode) {
+ case GP_WEIGHT_MODE_DISTANCE:
+ distance_panel_draw(C, panel);
+ break;
+ case GP_WEIGHT_MODE_ANGLE:
+ uiItemR(layout, ptr, "angle", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "axis", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "space", 0, NULL, ICON_NONE);
+ break;
+ default:
+ break;
+ }
+
+ gpencil_modifier_panel_end(layout, ptr);
+}
+
+static void mask_panel_draw(const bContext *UNUSED(C), Panel *panel)
+{
+ gpencil_modifier_masking_panel_draw(panel, true, true);
+}
+
+static void panelRegister(ARegionType *region_type)
+{
+ PanelType *panel_type = gpencil_modifier_panel_register(
+ region_type, eGpencilModifierType_Weight, panel_draw);
+
+ gpencil_modifier_subpanel_register(
+ region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
+}
+
+GpencilModifierTypeInfo modifierType_Gpencil_Weight = {
+ /* name */ "Vertex Weight",
+ /* structName */ "WeightGpencilModifierData",
+ /* structSize */ sizeof(WeightGpencilModifierData),
+ /* type */ eGpencilModifierTypeType_Gpencil,
+ /* flags */ 0,
+
+ /* copyData */ copyData,
+
+ /* deformStroke */ deformStroke,
+ /* generateStrokes */ NULL,
+ /* bakeModifier */ bakeModifier,
+ /* remapTime */ NULL,
+
+ /* initData */ initData,
+ /* freeData */ NULL,
+ /* isDisabled */ isDisabled,
+ /* updateDepsgraph */ updateDepsgraph,
+ /* dependsOnTime */ NULL,
+ /* foreachIDLink */ foreachIDLink,
+ /* foreachTexLink */ NULL,
+ /* panelRegister */ panelRegister,
+};
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index 18bd524ed2b..d77e0900535 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -52,8 +52,9 @@ typedef struct LineartTriangle {
/* first culled in line list to use adjacent triangle info, then go through triangle list. */
double gn[3];
- unsigned char transparency_mask;
+ unsigned char material_mask_bits;
unsigned char intersection_mask;
+ unsigned char mat_occlusion;
unsigned char flags; /* #eLineartTriangleFlags */
/**
@@ -101,12 +102,8 @@ typedef struct LineartEdgeSegment {
/** Occlusion level after "at" point */
unsigned char occlusion;
- /**
- * For determining lines behind a glass window material.
- * allows 6 materials for "transparent mask", from bits 1<<2 to 1<<7.
- * bits 1<<0 and 1<<1 are for occlusion effectiveness value.
- */
- unsigned char transparency_mask;
+ /* Used to filter line art occlusion edges */
+ unsigned char material_mask_bits;
} LineartEdgeSegment;
typedef struct LineartVert {
@@ -151,8 +148,8 @@ typedef struct LineartEdge {
char min_occ;
/** Also for line type determination on chaining. */
- uint16_t flags;
- uint8_t intersection_mask;
+ unsigned char flags;
+ unsigned char intersection_mask;
/**
* Still need this entry because culled lines will not add to object
@@ -177,7 +174,7 @@ typedef struct LineartEdgeChain {
/** Chain now only contains one type of segments */
int type;
- unsigned char transparency_mask;
+ unsigned char material_mask_bits;
unsigned char intersection_mask;
struct Object *object_ref;
@@ -192,7 +189,8 @@ typedef struct LineartEdgeChainItem {
float normal[3];
unsigned char line_type;
char occlusion;
- unsigned char transparency_mask;
+ unsigned char material_mask_bits;
+ unsigned char intersection_mask;
size_t index;
} LineartEdgeChainItem;
@@ -286,7 +284,6 @@ typedef struct LineartRenderBuffer {
ListBase material;
ListBase edge_mark;
ListBase floating;
- ListBase light_contour;
ListBase chains;
@@ -307,7 +304,7 @@ typedef struct LineartRenderBuffer {
bool use_material;
bool use_edge_marks;
bool use_intersections;
- bool use_floating;
+ bool use_loose;
bool use_light_contour;
bool fuzzy_intersections;
bool fuzzy_everything;
@@ -315,9 +312,9 @@ typedef struct LineartRenderBuffer {
bool allow_overlapping_edges;
bool allow_duplicated_types;
bool remove_doubles;
- bool floating_as_contour;
- bool chain_floating_edges;
- bool chain_geometry_space;
+ bool use_loose_as_contour;
+ bool use_loose_edge_chain;
+ bool use_geometry_space_chain;
bool filter_face_mark;
bool filter_face_mark_invert;
@@ -401,8 +398,6 @@ typedef struct LineartRenderTaskInfo {
} LineartRenderTaskInfo;
-struct BMesh;
-
typedef struct LineartObjectInfo {
struct LineartObjectInfo *next;
struct Object *original_ob;
@@ -410,15 +405,15 @@ typedef struct LineartObjectInfo {
double model_view_proj[4][4];
double model_view[4][4];
double normal[4][4];
- LineartElementLinkNode *eln;
+ LineartElementLinkNode *v_eln;
int usage;
- unsigned char override_intersection_mask;
+ uint8_t override_intersection_mask;
int global_i_offset;
bool free_use_mesh;
/* Threads will add lines inside here, when all threads are done, we combine those into the
- * ones in LineartRenderBuffer. */
+ * ones in LineartRenderBuffer. */
ListBase contour;
ListBase intersection;
ListBase crease;
@@ -655,7 +650,7 @@ void MOD_lineart_gpencil_generate(LineartCache *cache,
int mat_nr,
short edge_types,
unsigned char mask_switches,
- unsigned char transparency_mask,
+ unsigned char material_mask_bits,
unsigned char intersection_mask,
short thickness,
float opacity,
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
index e143239991a..1471210d18b 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
@@ -108,7 +108,7 @@ static LineartEdgeChainItem *lineart_chain_append_point(LineartRenderBuffer *rb,
float *normal,
char type,
int level,
- unsigned char transparency_mask,
+ unsigned char material_mask_bits,
size_t index)
{
LineartEdgeChainItem *eci;
@@ -120,7 +120,7 @@ static LineartEdgeChainItem *lineart_chain_append_point(LineartRenderBuffer *rb,
LineartEdgeChainItem *old_eci = ec->chain.last;
old_eci->line_type = type;
old_eci->occlusion = level;
- old_eci->transparency_mask = transparency_mask;
+ old_eci->material_mask_bits = material_mask_bits;
return old_eci;
}
@@ -132,7 +132,7 @@ static LineartEdgeChainItem *lineart_chain_append_point(LineartRenderBuffer *rb,
copy_v3_v3(eci->normal, normal);
eci->line_type = type & LRT_EDGE_FLAG_ALL_TYPE;
eci->occlusion = level;
- eci->transparency_mask = transparency_mask;
+ eci->material_mask_bits = material_mask_bits;
BLI_addtail(&ec->chain, eci);
return eci;
@@ -145,7 +145,7 @@ static LineartEdgeChainItem *lineart_chain_prepend_point(LineartRenderBuffer *rb
float *normal,
char type,
int level,
- unsigned char transparency_mask,
+ unsigned char material_mask_bits,
size_t index)
{
LineartEdgeChainItem *eci;
@@ -162,7 +162,7 @@ static LineartEdgeChainItem *lineart_chain_prepend_point(LineartRenderBuffer *rb
copy_v3_v3(eci->normal, normal);
eci->line_type = type & LRT_EDGE_FLAG_ALL_TYPE;
eci->occlusion = level;
- eci->transparency_mask = transparency_mask;
+ eci->material_mask_bits = material_mask_bits;
BLI_addhead(&ec->chain, eci);
return eci;
@@ -234,10 +234,10 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
N,
e->flags,
es->occlusion,
- es->transparency_mask,
+ es->material_mask_bits,
e->v1_obindex);
while (ba && (new_e = lineart_line_get_connected(
- ba, new_vt, &new_vt, e->flags, ec->intersection_mask))) {
+ ba, new_vt, &new_vt, e->flags, e->intersection_mask))) {
new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
if (new_e->t1 || new_e->t2) {
@@ -270,16 +270,16 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
N,
new_e->flags,
es->occlusion,
- es->transparency_mask,
+ es->material_mask_bits,
new_e->v1_obindex);
last_occlusion = es->occlusion;
- last_transparency = es->transparency_mask;
+ last_transparency = es->material_mask_bits;
}
}
else if (new_vt == new_e->v2) {
es = new_e->segments.first;
last_occlusion = es->occlusion;
- last_transparency = es->transparency_mask;
+ last_transparency = es->material_mask_bits;
es = es->next;
for (; es; es = es->next) {
double gpos[3], lpos[3];
@@ -298,7 +298,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
last_transparency,
new_e->v2_obindex);
last_occlusion = es->occlusion;
- last_transparency = es->transparency_mask;
+ last_transparency = es->material_mask_bits;
}
VERT_COORD_TO_FLOAT(new_e->v2);
lineart_chain_prepend_point(rb,
@@ -333,7 +333,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
* of the line. */
es = e->segments.first;
last_occlusion = ((LineartEdgeSegment *)es)->occlusion;
- last_transparency = ((LineartEdgeSegment *)es)->transparency_mask;
+ last_transparency = ((LineartEdgeSegment *)es)->material_mask_bits;
for (es = es->next; es; es = es->next) {
double gpos[3], lpos[3];
double *lfb = e->v1->fbcoord, *rfb = e->v2->fbcoord;
@@ -348,10 +348,10 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
N,
e->flags,
es->occlusion,
- es->transparency_mask,
+ es->material_mask_bits,
e->v1_obindex);
last_occlusion = es->occlusion;
- last_transparency = es->transparency_mask;
+ last_transparency = es->material_mask_bits;
}
VERT_COORD_TO_FLOAT(e->v2)
lineart_chain_append_point(rb,
@@ -368,7 +368,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
ba = MOD_lineart_get_bounding_area(rb, e->v2->fbcoord[0], e->v2->fbcoord[1]);
new_vt = e->v2;
while (ba && (new_e = lineart_line_get_connected(
- ba, new_vt, &new_vt, e->flags, ec->intersection_mask))) {
+ ba, new_vt, &new_vt, e->flags, e->intersection_mask))) {
new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
if (new_e->t1 || new_e->t2) {
@@ -393,10 +393,10 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
if (new_vt == new_e->v1) {
es = new_e->segments.last;
last_occlusion = es->occlusion;
- last_transparency = es->transparency_mask;
+ last_transparency = es->material_mask_bits;
/* Fix leading vertex occlusion. */
eci->occlusion = last_occlusion;
- eci->transparency_mask = last_transparency;
+ eci->material_mask_bits = last_transparency;
for (es = new_e->segments.last; es; es = es->prev) {
double gpos[3], lpos[3];
double *lfb = new_e->v1->fbcoord, *rfb = new_e->v2->fbcoord;
@@ -404,7 +404,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
interp_v3_v3v3_db(lpos, new_e->v1->fbcoord, new_e->v2->fbcoord, es->at);
interp_v3_v3v3_db(gpos, new_e->v1->gloc, new_e->v2->gloc, global_at);
last_occlusion = es->prev ? es->prev->occlusion : last_occlusion;
- last_transparency = es->prev ? es->prev->transparency_mask : last_transparency;
+ last_transparency = es->prev ? es->prev->material_mask_bits : last_transparency;
POS_TO_FLOAT(lpos, gpos)
lineart_chain_append_point(rb,
ec,
@@ -420,9 +420,9 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
else if (new_vt == new_e->v2) {
es = new_e->segments.first;
last_occlusion = es->occlusion;
- last_transparency = es->transparency_mask;
+ last_transparency = es->material_mask_bits;
eci->occlusion = last_occlusion;
- eci->transparency_mask = last_transparency;
+ eci->material_mask_bits = last_transparency;
es = es->next;
for (; es; es = es->next) {
double gpos[3], lpos[3];
@@ -438,10 +438,10 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
N,
new_e->flags,
es->occlusion,
- es->transparency_mask,
+ es->material_mask_bits,
new_e->v2_obindex);
last_occlusion = es->occlusion;
- last_transparency = es->transparency_mask;
+ last_transparency = es->material_mask_bits;
}
VERT_COORD_TO_FLOAT(new_e->v2)
lineart_chain_append_point(rb,
@@ -582,12 +582,12 @@ void MOD_lineart_chain_split_for_fixed_occlusion(LineartRenderBuffer *rb)
BLI_addtail(&rb->chains, ec);
LineartEdgeChainItem *first_eci = (LineartEdgeChainItem *)ec->chain.first;
int fixed_occ = first_eci->occlusion;
- unsigned char fixed_trans_mask = first_eci->transparency_mask;
+ unsigned char fixed_mask = first_eci->material_mask_bits;
ec->level = fixed_occ;
- ec->transparency_mask = fixed_trans_mask;
+ ec->material_mask_bits = fixed_mask;
for (eci = first_eci->next; eci; eci = next_eci) {
next_eci = eci->next;
- if (eci->occlusion != fixed_occ || eci->transparency_mask != fixed_trans_mask) {
+ if (eci->occlusion != fixed_occ || eci->material_mask_bits != fixed_mask) {
if (next_eci) {
if (lineart_point_overlapping(next_eci, eci->pos[0], eci->pos[1], 1e-5)) {
continue;
@@ -595,9 +595,9 @@ void MOD_lineart_chain_split_for_fixed_occlusion(LineartRenderBuffer *rb)
}
else {
/* Set the same occlusion level for the end vertex, so when further connection is needed
- * the backwards occlusion info is also correct. */
+ * the backwards occlusion info is also correct. */
eci->occlusion = fixed_occ;
- eci->transparency_mask = fixed_trans_mask;
+ eci->material_mask_bits = fixed_mask;
/* No need to split at the last point anyway. */
break;
}
@@ -616,16 +616,16 @@ void MOD_lineart_chain_split_for_fixed_occlusion(LineartRenderBuffer *rb)
eci->normal,
eci->line_type,
fixed_occ,
- fixed_trans_mask,
+ fixed_mask,
eci->index);
new_ec->object_ref = ec->object_ref;
new_ec->type = ec->type;
new_ec->intersection_mask = ec->intersection_mask;
ec = new_ec;
fixed_occ = eci->occlusion;
- fixed_trans_mask = eci->transparency_mask;
+ fixed_mask = eci->material_mask_bits;
ec->level = fixed_occ;
- ec->transparency_mask = fixed_trans_mask;
+ ec->material_mask_bits = fixed_mask;
}
}
}
@@ -692,7 +692,7 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
LineartEdgeChain *ec,
LineartEdgeChainItem *eci,
int occlusion,
- unsigned char trans_mask,
+ unsigned char material_mask_bits,
unsigned char isec_mask,
float dist,
float *result_new_len,
@@ -722,7 +722,8 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
continue;
}
if (cre->ec == ec || (!cre->ec->chain.first) || (cre->ec->level != occlusion) ||
- (cre->ec->transparency_mask != trans_mask) || (cre->ec->intersection_mask != isec_mask)) {
+ (cre->ec->material_mask_bits != material_mask_bits) ||
+ (cre->ec->intersection_mask != isec_mask)) {
continue;
}
if (!rb->fuzzy_everything) {
@@ -739,8 +740,8 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
}
}
- float new_len = rb->chain_geometry_space ? len_v3v3(cre->eci->gpos, eci->gpos) :
- len_v2v2(cre->eci->pos, eci->pos);
+ float new_len = rb->use_geometry_space_chain ? len_v3v3(cre->eci->gpos, eci->gpos) :
+ len_v2v2(cre->eci->pos, eci->pos);
if (new_len < dist) {
closest_cre = cre;
dist = new_len;
@@ -758,8 +759,16 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
if (dist_to < dist && dist_to > 0) { \
LISTBASE_FOREACH (LinkData *, ld, list) { \
LineartBoundingArea *sba = (LineartBoundingArea *)ld->data; \
- adjacent_closest = lineart_chain_get_closest_cre( \
- rb, sba, ec, eci, occlusion, trans_mask, isec_mask, dist, &adjacent_new_len, ba); \
+ adjacent_closest = lineart_chain_get_closest_cre(rb, \
+ sba, \
+ ec, \
+ eci, \
+ occlusion, \
+ material_mask_bits, \
+ isec_mask, \
+ dist, \
+ &adjacent_new_len, \
+ ba); \
if (adjacent_new_len < dist) { \
dist = adjacent_new_len; \
closest_cre = adjacent_closest; \
@@ -792,7 +801,7 @@ void MOD_lineart_chain_connect(LineartRenderBuffer *rb)
float dist = rb->chaining_image_threshold;
float dist_l, dist_r;
int occlusion, reverse_main;
- unsigned char trans_mask, isec_mask;
+ unsigned char material_mask_bits, isec_mask;
ListBase swap = {0};
if (rb->chaining_image_threshold < 0.0001) {
@@ -811,12 +820,12 @@ void MOD_lineart_chain_connect(LineartRenderBuffer *rb)
}
BLI_addtail(&rb->chains, ec);
- if (ec->type == LRT_EDGE_FLAG_FLOATING && (!rb->chain_floating_edges)) {
+ if (ec->type == LRT_EDGE_FLAG_LOOSE && (!rb->use_loose_edge_chain)) {
continue;
}
occlusion = ec->level;
- trans_mask = ec->transparency_mask;
+ material_mask_bits = ec->material_mask_bits;
isec_mask = ec->intersection_mask;
eci_l = ec->chain.first;
@@ -824,9 +833,9 @@ void MOD_lineart_chain_connect(LineartRenderBuffer *rb)
while ((ba_l = lineart_bounding_area_get_end_point(rb, eci_l)) &&
(ba_r = lineart_bounding_area_get_end_point(rb, eci_r))) {
closest_cre_l = lineart_chain_get_closest_cre(
- rb, ba_l, ec, eci_l, occlusion, trans_mask, isec_mask, dist, &dist_l, NULL);
+ rb, ba_l, ec, eci_l, occlusion, material_mask_bits, isec_mask, dist, &dist_l, NULL);
closest_cre_r = lineart_chain_get_closest_cre(
- rb, ba_r, ec, eci_r, occlusion, trans_mask, isec_mask, dist, &dist_r, NULL);
+ rb, ba_r, ec, eci_r, occlusion, material_mask_bits, isec_mask, dist, &dist_r, NULL);
if (closest_cre_l && closest_cre_r) {
if (dist_l < dist_r) {
closest_cre = closest_cre_l;
@@ -970,7 +979,7 @@ void MOD_lineart_chain_split_angle(LineartRenderBuffer *rb, float angle_threshol
angle = angle_v2v2v2(prev_eci->pos, eci->pos, next_eci->pos);
}
else {
- break; /* No need to split at the last point anyway.*/
+ break; /* No need to split at the last point anyway. */
}
if (angle < angle_threshold_rad) {
new_ec = lineart_chain_create(rb);
@@ -988,12 +997,12 @@ void MOD_lineart_chain_split_angle(LineartRenderBuffer *rb, float angle_threshol
eci->normal,
eci->line_type,
ec->level,
- eci->transparency_mask,
+ eci->material_mask_bits,
eci->index);
new_ec->object_ref = ec->object_ref;
new_ec->type = ec->type;
new_ec->level = ec->level;
- new_ec->transparency_mask = ec->transparency_mask;
+ new_ec->material_mask_bits = ec->material_mask_bits;
ec = new_ec;
}
}
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 9a08a093f37..9ef3cb895ac 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -152,8 +152,12 @@ static LineartEdgeSegment *lineart_give_segment(LineartRenderBuffer *rb)
/**
* Cuts the edge in image space and mark occlusion level for each segment.
*/
-static void lineart_edge_cut(
- LineartRenderBuffer *rb, LineartEdge *e, double start, double end, uchar transparency_mask)
+static void lineart_edge_cut(LineartRenderBuffer *rb,
+ LineartEdge *e,
+ double start,
+ double end,
+ uchar material_mask_bits,
+ uchar mat_occlusion)
{
LineartEdgeSegment *es, *ies, *next_es, *prev_es;
LineartEdgeSegment *cut_start_before = 0, *cut_end_before = 0;
@@ -246,7 +250,7 @@ static void lineart_edge_cut(
/* Insert cutting points for when a new cut is needed. */
ies = cut_start_before->prev ? cut_start_before->prev : NULL;
ns->occlusion = ies ? ies->occlusion : 0;
- ns->transparency_mask = ies->transparency_mask;
+ ns->material_mask_bits = ies->material_mask_bits;
BLI_insertlinkbefore(&e->segments, cut_start_before, ns);
}
/* Otherwise we already found a existing cutting point, no need to insert a new one. */
@@ -256,7 +260,7 @@ static void lineart_edge_cut(
* append the new cut to the end. */
ies = e->segments.last;
ns->occlusion = ies->occlusion;
- ns->transparency_mask = ies->transparency_mask;
+ ns->material_mask_bits = ies->material_mask_bits;
BLI_addtail(&e->segments, ns);
}
if (cut_end_before) {
@@ -264,14 +268,14 @@ static void lineart_edge_cut(
if (cut_end_before != ns2) {
ies = cut_end_before->prev ? cut_end_before->prev : NULL;
ns2->occlusion = ies ? ies->occlusion : 0;
- ns2->transparency_mask = ies ? ies->transparency_mask : 0;
+ ns2->material_mask_bits = ies ? ies->material_mask_bits : 0;
BLI_insertlinkbefore(&e->segments, cut_end_before, ns2);
}
}
else {
ies = e->segments.last;
ns2->occlusion = ies->occlusion;
- ns2->transparency_mask = ies->transparency_mask;
+ ns2->material_mask_bits = ies->material_mask_bits;
BLI_addtail(&e->segments, ns2);
}
@@ -288,8 +292,8 @@ static void lineart_edge_cut(
/* Register 1 level of occlusion for all touched segments. */
for (es = ns; es && es != ns2; es = es->next) {
- es->occlusion += (transparency_mask & LRT_OCCLUSION_EFFECTIVE_BITS);
- es->transparency_mask |= (transparency_mask & LRT_TRANSPARENCY_BITS);
+ es->occlusion += mat_occlusion;
+ es->material_mask_bits |= material_mask_bits;
}
/* Reduce adjacent cutting points of the same level, which saves memory. */
@@ -299,7 +303,7 @@ static void lineart_edge_cut(
next_es = es->next;
if (prev_es && prev_es->occlusion == es->occlusion &&
- prev_es->transparency_mask == es->transparency_mask) {
+ prev_es->material_mask_bits == es->material_mask_bits) {
BLI_remlink(&e->segments, es);
/* This puts the node back to the render buffer, if more cut happens, these unused nodes get
* picked first. */
@@ -382,8 +386,8 @@ static void lineart_occlusion_single_line(LineartRenderBuffer *rb, LineartEdge *
/* Ignore this triangle if an intersection line directly comes from it, */
lineart_occlusion_is_adjacent_intersection(e, (LineartTriangle *)tri) ||
/* Or if this triangle isn't effectively occluding anything nor it's providing a
- transparency flag. */
- (!tri->base.transparency_mask)) {
+ material flag. */
+ ((!tri->base.mat_occlusion) && (!tri->base.material_mask_bits))) {
continue;
}
tri->testing_e[thread_id] = e;
@@ -399,7 +403,7 @@ static void lineart_occlusion_single_line(LineartRenderBuffer *rb, LineartEdge *
rb->shift_y,
&l,
&r)) {
- lineart_edge_cut(rb, e, l, r, tri->base.transparency_mask);
+ lineart_edge_cut(rb, e, l, r, tri->base.material_mask_bits, tri->base.mat_occlusion);
if (e->min_occ > rb->max_occlusion_level) {
/* No need to calculate any longer on this line because no level more than set value is
* going to show up in the rendered result. */
@@ -441,7 +445,6 @@ static int lineart_occlusion_make_task_info(LineartRenderBuffer *rb, LineartRend
LRT_ASSIGN_OCCLUSION_TASK(material);
LRT_ASSIGN_OCCLUSION_TASK(edge_mark);
LRT_ASSIGN_OCCLUSION_TASK(floating);
- LRT_ASSIGN_OCCLUSION_TASK(light_contour);
#undef LRT_ASSIGN_OCCLUSION_TASK
@@ -480,10 +483,6 @@ static void lineart_occlusion_worker(TaskPool *__restrict UNUSED(pool), LineartR
for (eip = rti->floating.first; eip && eip != rti->floating.last; eip = eip->next) {
lineart_occlusion_single_line(rb, eip, rti->thread_id);
}
-
- for (eip = rti->light_contour.first; eip && eip != rti->light_contour.last; eip = eip->next) {
- lineart_occlusion_single_line(rb, eip, rti->thread_id);
- }
}
}
@@ -507,7 +506,6 @@ static void lineart_main_occlusion_begin(LineartRenderBuffer *rb)
rb->material.last = rb->material.first;
rb->edge_mark.last = rb->edge_mark.first;
rb->floating.last = rb->floating.first;
- rb->light_contour.last = rb->light_contour.first;
TaskPool *tp = BLI_task_pool_create(NULL, TASK_PRIORITY_HIGH);
@@ -742,8 +740,7 @@ static void lineart_triangle_post(LineartTriangle *tri, LineartTriangle *orig)
/* Just re-assign normal and set cull flag. */
copy_v3_v3_db(tri->gn, orig->gn);
tri->flags = LRT_CULL_GENERATED;
- tri->intersection_mask = orig->intersection_mask;
- tri->transparency_mask = orig->transparency_mask;
+ tri->material_mask_bits = orig->material_mask_bits;
}
static void lineart_triangle_set_cull_flag(LineartTriangle *tri, uchar flag)
@@ -884,7 +881,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
* (!in0) means "when point 0 is visible".
* conditions for point 1, 2 are the same idea.
*
- * \code{.txt}
+ * \code{.txt}identify
* 1-----|-------0
* | | ---
* | |---
@@ -1290,7 +1287,7 @@ static void lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
}
#define LRT_CULL_DECIDE_INSIDE \
- /* These three represents points that are in the clipping range or not*/ \
+ /* These three represents points that are in the clipping range or not. */ \
in0 = 0, in1 = 0, in2 = 0; \
if (clip_far) { \
/* Point outside far plane. */ \
@@ -1475,19 +1472,12 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb,
}
if (!ll && !lr) {
- if (!rb->floating_as_contour) {
- if (use_freestyle_face && rb->filter_face_mark) {
- if (rb->filter_face_mark_invert) {
- return LRT_EDGE_FLAG_FLOATING;
- }
- return 0;
- }
- return LRT_EDGE_FLAG_FLOATING;
- }
+ return LRT_EDGE_FLAG_LOOSE;
}
FreestyleEdge *fel, *fer;
bool face_mark_filtered = false;
+ uint16_t edge_flag_result = 0;
if (use_freestyle_face && rb->filter_face_mark) {
fel = CustomData_bmesh_get(&bm_if_freestyle->pdata, ll->f->head.data, CD_FREESTYLE_FACE);
@@ -1495,7 +1485,7 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb,
fer = CustomData_bmesh_get(&bm_if_freestyle->pdata, lr->f->head.data, CD_FREESTYLE_FACE);
}
else {
- /* Hanles mesh boundary case */
+ /* Handles mesh boundary case */
fer = fel;
}
if (rb->filter_face_mark_boundaries ^ rb->filter_face_mark_invert) {
@@ -1518,7 +1508,7 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb,
/* Mesh boundary */
if (!lr || ll == lr) {
- return LRT_EDGE_FLAG_CONTOUR;
+ return (edge_flag_result | LRT_EDGE_FLAG_CONTOUR);
}
LineartTriangle *tri1, *tri2;
@@ -1534,7 +1524,6 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb,
double *view_vector = vv;
double dot_1 = 0, dot_2 = 0;
double result;
- uint16_t edge_flag_result = 0;
if (rb->cam_is_persp) {
sub_v3_v3v3_db(view_vector, l->gloc, rb->camera_pos);
@@ -1550,30 +1539,15 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb,
edge_flag_result |= LRT_EDGE_FLAG_CONTOUR;
}
- if (rb->light_is_sun) {
- view_vector = rb->light_vector;
- }
- else {
- view_vector = vv;
- sub_v3_v3v3_db(view_vector, l->gloc, rb->light_vector);
- }
-
- dot_1 = dot_v3v3_db(view_vector, tri1->gn);
- dot_2 = dot_v3v3_db(view_vector, tri2->gn);
-
- if ((result = dot_1 * dot_2) <= 0 && (dot_1 + dot_2)) {
- edge_flag_result |= LRT_EDGE_FLAG_LIGHT_CONTOUR;
- }
-
if (rb->use_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < crease_threshold)) {
if (!no_crease) {
edge_flag_result |= LRT_EDGE_FLAG_CREASE;
}
}
- else if (rb->use_material && (ll->f->mat_nr != lr->f->mat_nr)) {
+ if (rb->use_material && (ll->f->mat_nr != lr->f->mat_nr)) {
edge_flag_result |= LRT_EDGE_FLAG_MATERIAL;
}
- else if (use_freestyle_edge && rb->use_edge_marks) {
+ if (use_freestyle_edge && rb->use_edge_marks) {
FreestyleEdge *fe;
fe = CustomData_bmesh_get(&bm_if_freestyle->edata, e->head.data, CD_FREESTYLE_EDGE);
if (fe->flag & FREESTYLE_EDGE_MARK) {
@@ -1601,12 +1575,9 @@ static void lineart_add_edge_to_list(LineartRenderBuffer *rb, LineartEdge *e)
case LRT_EDGE_FLAG_INTERSECTION:
lineart_prepend_edge_direct(&rb->intersection.first, e);
break;
- case LRT_EDGE_FLAG_FLOATING:
+ case LRT_EDGE_FLAG_LOOSE:
lineart_prepend_edge_direct(&rb->floating.first, e);
break;
- case LRT_EDGE_FLAG_LIGHT_CONTOUR:
- lineart_prepend_edge_direct(&rb->light_contour.first, e);
- break;
}
}
@@ -1634,12 +1605,9 @@ static void lineart_add_edge_to_list_thread(LineartObjectInfo *obi, LineartEdge
case LRT_EDGE_FLAG_INTERSECTION:
LRT_ASSIGN_EDGE(intersection);
break;
- case LRT_EDGE_FLAG_FLOATING:
+ case LRT_EDGE_FLAG_LOOSE:
LRT_ASSIGN_EDGE(floating);
break;
- case LRT_EDGE_FLAG_LIGHT_CONTOUR:
- LRT_ASSIGN_EDGE(light_contour);
- break;
}
#undef LRT_ASSIGN_EDGE
}
@@ -1657,7 +1625,6 @@ static void lineart_finalize_object_edge_list(LineartRenderBuffer *rb, LineartOb
LRT_OBI_TO_RB(edge_mark);
LRT_OBI_TO_RB(intersection);
LRT_OBI_TO_RB(floating);
- LRT_OBI_TO_RB(light_contour);
#undef LRT_OBI_TO_RB
}
@@ -1764,14 +1731,15 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
BM_mesh_elem_index_ensure(bm, BM_VERT | BM_EDGE | BM_FACE);
if (CustomData_has_layer(&bm->edata, CD_FREESTYLE_EDGE)) {
- can_find_freestyle_edge = true;
+ can_find_freestyle_edge = 1;
}
if (CustomData_has_layer(&bm->pdata, CD_FREESTYLE_FACE)) {
can_find_freestyle_face = true;
}
- /* Only allocate memory for verts and tris as we don't know how many lines we will generate
- * yet. */
+ /* If we allow duplicated edges, one edge should get added multiple times if is has been
+ * classified as more than one edge type. This is so we can create multiple different line type
+ * chains containing the same edge. */
orv = lineart_mem_acquire_thread(&rb->render_data_pool, sizeof(LineartVert) * bm->totvert);
ort = lineart_mem_acquire_thread(&rb->render_data_pool, bm->totface * rb->triangle_size);
@@ -1784,7 +1752,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
eln->element_count = bm->totvert;
eln->object_ref = orig_ob;
- obi->eln = eln;
+ obi->v_eln = eln;
if (orig_ob->lineart.flags & OBJECT_LRT_OWN_CREASE) {
use_crease = cosf(M_PI - orig_ob->lineart.crease_threshold);
@@ -1838,16 +1806,15 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
loop = loop->next;
tri->v[2] = &orv[BM_elem_index_get(loop->v)];
- /* Transparency bits and occlusion effectiveness assignment, */
- /* bits are shifted to higher 6 bits. See MaterialLineArt::transparency_mask for details. */
+ /* Material mask bits and occlusion effectiveness assignment. */
Material *mat = BKE_object_material_get(orig_ob, f->mat_nr + 1);
- tri->transparency_mask |= ((mat && (mat->lineart.flags & LRT_MATERIAL_TRANSPARENCY_ENABLED)) ?
- (mat->lineart.transparency_mask << 2) :
- 0);
- tri->transparency_mask |=
- ((mat && (mat->lineart.flags & LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS)) ?
- mat->lineart.occlusion_effectiveness & LRT_OCCLUSION_EFFECTIVE_BITS :
- 1);
+ tri->material_mask_bits |= ((mat && (mat->lineart.flags & LRT_MATERIAL_MASK_ENABLED)) ?
+ mat->lineart.material_mask_bits :
+ 0);
+ tri->mat_occlusion |= ((mat &&
+ (mat->lineart.flags & LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS)) ?
+ mat->lineart.mat_occlusion :
+ 1);
tri->intersection_mask = obi->override_intersection_mask;
@@ -1876,15 +1843,15 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
e = BM_edge_at_index(bm, i);
/* Because e->head.hflag is char, so line type flags should not exceed positive 7 bits. */
- uint16_t eflag = lineart_identify_feature_line(rb,
- e,
- ort,
- orv,
- use_crease,
- orig_ob->type == OB_FONT,
- can_find_freestyle_edge,
- can_find_freestyle_face,
- bm);
+ char eflag = lineart_identify_feature_line(rb,
+ e,
+ ort,
+ orv,
+ use_crease,
+ orig_ob->type == OB_FONT,
+ can_find_freestyle_edge,
+ can_find_freestyle_face,
+ bm);
if (eflag) {
/* Only allocate for feature lines (instead of all lines) to save memory.
* If allow duplicated edges, one edge gets added multiple times if it has multiple types. */
@@ -1920,8 +1887,8 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
bool edge_added = false;
/* See eLineartEdgeFlag for details. */
- for (int flag_bit = 0; flag_bit < LRT_EDGE_FLAG_TYPE_MAX_BITS; flag_bit++) {
- uint8_t use_type = 1 << flag_bit;
+ for (int flag_bit = 0; flag_bit < 6; flag_bit++) {
+ char use_type = 1 << flag_bit;
if (!(use_type & e->head.hflag)) {
continue;
}
@@ -1970,27 +1937,11 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
static void lineart_object_load_worker(TaskPool *__restrict UNUSED(pool),
LineartObjectLoadTaskInfo *olti)
{
- LineartRenderBuffer *rb = olti->rb;
for (LineartObjectInfo *obi = olti->pending; obi; obi = obi->next) {
- lineart_geometry_object_load(obi, rb);
+ lineart_geometry_object_load(obi, olti->rb);
}
}
-static bool _lineart_object_not_in_source_collection(Collection *source, Object *ob)
-{
- CollectionChild *cc;
- Collection *c = source->id.orig_id ? (Collection *)source->id.orig_id : source;
- if (BKE_collection_has_object_recursive_instanced(c, (Object *)(ob->id.orig_id))) {
- return false;
- }
- for (cc = source->children.first; cc; cc = cc->next) {
- if (!_lineart_object_not_in_source_collection(cc->collection, ob)) {
- return false;
- }
- }
- return true;
-}
-
static uchar lineart_intersection_mask_check(Collection *c, Object *ob)
{
LISTBASE_FOREACH (CollectionChild *, cc, &c->children) {
@@ -2091,7 +2042,7 @@ static bool lineart_geometry_check_visible(double (*model_view_proj)[4], Object
}
bool cond[6] = {true, true, true, true, true, true};
- /* Beause for a point to be inside clip space, it must satisfy -Wc <= XYCc <= Wc, here if all
+ /* Because for a point to be inside clip space, it must satisfy `-Wc <= XYCc <= Wc`, here if all
* verts falls to the same side of the clip space border, we know it's outside view. */
for (int i = 0; i < 8; i++) {
cond[0] &= (co[i][0] < -co[i][3]);
@@ -2118,7 +2069,6 @@ static void lineart_main_load_geometries(
{
double proj[4][4], view[4][4], result[4][4];
float inv[4][4];
-
Camera *cam = camera->data;
float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
int fit = BKE_camera_sensor_fit(cam->sensor_fit, rb->w, rb->h);
@@ -2178,13 +2128,13 @@ static void lineart_main_load_geometries(
obi->usage = lineart_usage_check(scene->master_collection, ob);
obi->override_intersection_mask = lineart_intersection_mask_check(scene->master_collection,
ob);
- Object *use_ob = DEG_get_evaluated_object(depsgraph, ob);
Mesh *use_mesh;
if (obi->usage == OBJECT_LRT_EXCLUDE) {
continue;
}
+ Object *use_ob = DEG_get_evaluated_object(depsgraph, ob);
/* Prepare the matrix used for transforming this specific object (instance). This has to be
* done before mesh boundbox check because the function needs that. */
mul_m4db_m4db_m4fl_uniq(obi->model_view_proj, rb->view_projection, ob->obmat);
@@ -2245,11 +2195,11 @@ static void lineart_main_load_geometries(
for (int i = 0; i < thread_count; i++) {
for (LineartObjectInfo *obi = olti[i].pending; obi; obi = obi->next) {
- if (!obi->eln) {
+ if (!obi->v_eln) {
continue;
}
- LineartVert *v = (LineartVert *)obi->eln->pointer;
- int v_count = obi->eln->element_count;
+ LineartVert *v = (LineartVert *)obi->v_eln->pointer;
+ int v_count = obi->v_eln->element_count;
for (int vi = 0; vi < v_count; vi++) {
v[vi].index += global_i;
}
@@ -2339,7 +2289,7 @@ static bool lineart_edge_from_triangle(const LineartTriangle *tri,
}
/* Sorting three intersection points from min to max,
- * the order for each intersection is set in lst[0] to lst[2].*/
+ * the order for each intersection is set in `lst[0]` to `lst[2]`. */
#define INTERSECT_SORT_MIN_TO_MAX_3(ia, ib, ic, lst) \
{ \
lst[0] = LRT_MIN3_INDEX(ia, ib, ic); \
@@ -2411,7 +2361,7 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
return false;
}
- /* If the the line is one of the edge in the triangle, then it's not occluded. */
+ /* If the line is one of the edge in the triangle, then it's not occluded. */
if (lineart_edge_from_triangle(tri, e, allow_overlapping_edges)) {
return false;
}
@@ -2938,7 +2888,7 @@ static void lineart_triangle_intersect_in_bounding_area(LineartRenderBuffer *rb,
double *G0 = tri->v[0]->gloc, *G1 = tri->v[1]->gloc, *G2 = tri->v[2]->gloc;
- /* If this is not the smallest subdiv bounding area.*/
+ /* If this is not the smallest subdiv bounding area. */
if (ba->child) {
lineart_triangle_intersect_in_bounding_area(rb, tri, &ba->child[0]);
lineart_triangle_intersect_in_bounding_area(rb, tri, &ba->child[1]);
@@ -3018,7 +2968,6 @@ static void lineart_destroy_render_data(LineartRenderBuffer *rb)
memset(&rb->edge_mark, 0, sizeof(ListBase));
memset(&rb->material, 0, sizeof(ListBase));
memset(&rb->floating, 0, sizeof(ListBase));
- memset(&rb->light_contour, 0, sizeof(ListBase));
BLI_listbase_clear(&rb->chains);
BLI_listbase_clear(&rb->wasted_cuts);
@@ -3133,19 +3082,20 @@ static LineartRenderBuffer *lineart_create_render_buffer(Scene *scene,
rb->crease_threshold = cos(M_PI - lmd->crease_threshold);
rb->chaining_image_threshold = lmd->chaining_image_threshold;
rb->angle_splitting_threshold = lmd->angle_splitting_threshold;
- rb->chain_smooth_tolerance = lmd->chain_smooth_tolerance;
rb->fuzzy_intersections = (lmd->calculation_flags & LRT_INTERSECTION_AS_CONTOUR) != 0;
rb->fuzzy_everything = (lmd->calculation_flags & LRT_EVERYTHING_AS_CONTOUR) != 0;
rb->allow_boundaries = (lmd->calculation_flags & LRT_ALLOW_CLIPPING_BOUNDARIES) != 0;
rb->remove_doubles = (lmd->calculation_flags & LRT_REMOVE_DOUBLES) != 0;
- rb->floating_as_contour = (lmd->calculation_flags & LRT_FLOATING_AS_CONTOUR) != 0;
- rb->chain_floating_edges = (lmd->calculation_flags & LRT_CHAIN_FLOATING_EDGES) != 0;
- rb->chain_geometry_space = (lmd->calculation_flags & LRT_CHAIN_GEOMETRY_SPACE) != 0;
+ rb->use_loose_as_contour = (lmd->calculation_flags & LRT_LOOSE_AS_CONTOUR) != 0;
+ rb->use_loose_edge_chain = (lmd->calculation_flags & LRT_CHAIN_LOOSE_EDGES) != 0;
+ rb->use_geometry_space_chain = (lmd->calculation_flags & LRT_CHAIN_GEOMETRY_SPACE) != 0;
/* See lineart_edge_from_triangle() for how this option may impact performance. */
rb->allow_overlapping_edges = (lmd->calculation_flags & LRT_ALLOW_OVERLAPPING_EDGES) != 0;
+ rb->allow_duplicated_types = (lmd->calculation_flags & LRT_ALLOW_OVERLAP_EDGE_TYPES) != 0;
+
int16_t edge_types = lmd->edge_types_override;
rb->use_contour = (edge_types & LRT_EDGE_FLAG_CONTOUR) != 0;
@@ -3153,6 +3103,12 @@ static LineartRenderBuffer *lineart_create_render_buffer(Scene *scene,
rb->use_material = (edge_types & LRT_EDGE_FLAG_MATERIAL) != 0;
rb->use_edge_marks = (edge_types & LRT_EDGE_FLAG_EDGE_MARK) != 0;
rb->use_intersections = (edge_types & LRT_EDGE_FLAG_INTERSECTION) != 0;
+ rb->use_loose = (edge_types & LRT_EDGE_FLAG_LOOSE) != 0;
+
+ rb->filter_face_mark_invert = (lmd->calculation_flags & LRT_FILTER_FACE_MARK_INVERT) != 0;
+ rb->filter_face_mark = (lmd->calculation_flags & LRT_FILTER_FACE_MARK) != 0;
+ rb->filter_face_mark_boundaries = (lmd->calculation_flags & LRT_FILTER_FACE_MARK_BOUNDARIES) !=
+ 0;
rb->chain_data_pool = &lc->chain_data_pool;
@@ -4554,22 +4510,12 @@ bool MOD_lineart_compute_feature_lines(Depsgraph *depsgraph,
t_start = PIL_check_seconds_timer();
}
- if (lmd->calculation_flags & LRT_USE_CUSTOM_CAMERA) {
- if (!lmd->source_camera ||
- (use_camera = DEG_get_evaluated_object(depsgraph, lmd->source_camera))->type !=
- OB_CAMERA) {
- return false;
- }
- }
- else {
-
- BKE_scene_camera_switch_update(scene);
+ BKE_scene_camera_switch_update(scene);
- if (!scene->camera) {
- return false;
- }
- use_camera = scene->camera;
+ if (!scene->camera) {
+ return false;
}
+ use_camera = scene->camera;
LineartCache *lc = lineart_init_cache();
(*cached_result) = lc;
@@ -4637,7 +4583,7 @@ bool MOD_lineart_compute_feature_lines(Depsgraph *depsgraph,
/* "intersection_only" is preserved for being called in a standalone fashion.
* If so the data will already be available at the stage. Otherwise we do the occlusion and
- * chaining etc.*/
+ * chaining etc. */
if (!intersections_only) {
@@ -4702,8 +4648,7 @@ static int UNUSED_FUNCTION(lineart_rb_edge_types)(LineartRenderBuffer *rb)
types |= rb->use_material ? LRT_EDGE_FLAG_MATERIAL : 0;
types |= rb->use_edge_marks ? LRT_EDGE_FLAG_EDGE_MARK : 0;
types |= rb->use_intersections ? LRT_EDGE_FLAG_INTERSECTION : 0;
- types |= rb->use_floating ? LRT_EDGE_FLAG_FLOATING : 0;
- types |= rb->use_light_contour ? LRT_EDGE_FLAG_LIGHT_CONTOUR : 0;
+ types |= rb->use_loose ? LRT_EDGE_FLAG_LOOSE : 0;
return types;
}
@@ -4720,7 +4665,7 @@ static void lineart_gpencil_generate(LineartCache *cache,
Collection *source_collection,
int types,
uchar mask_switches,
- uchar transparency_mask,
+ uchar material_mask_bits,
uchar intersection_mask,
short thickness,
float opacity,
@@ -4758,9 +4703,6 @@ static void lineart_gpencil_generate(LineartCache *cache,
bool invert_input = modifier_flags & LRT_GPENCIL_INVERT_SOURCE_VGROUP;
bool match_output = modifier_flags & LRT_GPENCIL_MATCH_OUTPUT_VGROUP;
- /* Bits are shifted to higher 6 bits. See MaterialLineArt::transparency_mask for details. */
- transparency_mask <<= 2;
-
LISTBASE_FOREACH (LineartEdgeChain *, ec, &cache->chains) {
if (ec->picked) {
@@ -4780,14 +4722,26 @@ static void lineart_gpencil_generate(LineartCache *cache,
continue;
}
}
- if (mask_switches & LRT_GPENCIL_TRANSPARENCY_ENABLE) {
- if (mask_switches & LRT_GPENCIL_TRANSPARENCY_MATCH) {
- if (ec->transparency_mask != transparency_mask) {
+ if (mask_switches & LRT_GPENCIL_MATERIAL_MASK_ENABLE) {
+ if (mask_switches & LRT_GPENCIL_MATERIAL_MASK_MATCH) {
+ if (ec->material_mask_bits != material_mask_bits) {
+ continue;
+ }
+ }
+ else {
+ if (!(ec->material_mask_bits & material_mask_bits)) {
+ continue;
+ }
+ }
+ }
+ if (types & LRT_EDGE_FLAG_INTERSECTION) {
+ if (mask_switches & LRT_GPENCIL_INTERSECTION_MATCH) {
+ if (ec->intersection_mask != intersection_mask) {
continue;
}
}
else {
- if (!(ec->transparency_mask & transparency_mask)) {
+ if ((intersection_mask) && !(ec->intersection_mask & intersection_mask)) {
continue;
}
}
@@ -4900,7 +4854,7 @@ void MOD_lineart_gpencil_generate(LineartCache *cache,
int mat_nr,
short edge_types,
uchar mask_switches,
- uchar transparency_mask,
+ uchar material_mask_bits,
uchar intersection_mask,
short thickness,
float opacity,
@@ -4944,7 +4898,7 @@ void MOD_lineart_gpencil_generate(LineartCache *cache,
source_collection,
use_types,
mask_switches,
- transparency_mask,
+ material_mask_bits,
intersection_mask,
thickness,
opacity,
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h b/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h
index c25a5f90059..c862c488cf5 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h
@@ -103,9 +103,6 @@ void lineart_count_and_print_render_buffer_memory(struct LineartRenderBuffer *rb
if (!e) { \
e = rb->floating.first; \
} \
- if (!e) { \
- e = rb->light_contour.first; \
- } \
for (current_head = &rb->contour.first; e; e = next_e) { \
next_e = e->next;
@@ -126,9 +123,6 @@ void lineart_count_and_print_render_buffer_memory(struct LineartRenderBuffer *rb
else if (current_head == &rb->intersection.first) { \
current_head = &rb->floating.first; \
} \
- else if (current_head == &rb->floating.first) { \
- current_head = &rb->light_contour.first; \
- } \
else { \
break; \
} \
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
index 392cc8e859a..b74499daf6b 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
@@ -144,7 +144,7 @@ static bool bake_strokes(Object *ob,
lmd->target_material ? BKE_gpencil_object_material_index_get(ob, lmd->target_material) : 0,
lmd->edge_types,
lmd->mask_switches,
- lmd->transparency_mask,
+ lmd->material_mask_bits,
lmd->intersection_mask,
lmd->thickness,
lmd->opacity,
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 8468985309f..abb7330d292 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -82,6 +82,7 @@ set(SRC
intern/gpu_select_sample_query.cc
intern/gpu_shader.cc
intern/gpu_shader_builtin.c
+ intern/gpu_shader_log.cc
intern/gpu_shader_interface.cc
intern/gpu_state.cc
intern/gpu_texture.cc
@@ -102,6 +103,7 @@ set(SRC
opengl/gl_index_buffer.cc
opengl/gl_query.cc
opengl/gl_shader.cc
+ opengl/gl_shader_log.cc
opengl/gl_shader_interface.cc
opengl/gl_state.cc
opengl/gl_texture.cc
@@ -396,6 +398,7 @@ if(WITH_GTESTS)
tests/gpu_testing.cc
tests/gpu_index_buffer_test.cc
+ tests/gpu_shader_builtin_test.cc
tests/gpu_shader_test.cc
tests/gpu_testing.hh
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index 3923c920c9e..f834ee5b234 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -366,7 +366,6 @@ typedef enum eGPUBuiltinShader {
GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE, /* Uniformly scaled */
/* grease pencil drawing */
GPU_SHADER_GPENCIL_STROKE,
- GPU_SHADER_GPENCIL_FILL,
/* specialized for widget drawing */
GPU_SHADER_2D_AREA_EDGES,
GPU_SHADER_2D_WIDGET_BASE,
diff --git a/source/blender/gpu/GPU_viewport.h b/source/blender/gpu/GPU_viewport.h
index 095e17f344e..8b2a14a1a96 100644
--- a/source/blender/gpu/GPU_viewport.h
+++ b/source/blender/gpu/GPU_viewport.h
@@ -43,7 +43,7 @@ typedef struct GPUViewport GPUViewport;
struct GPUFrameBuffer;
-/* Contains memory pools information */
+/* Contains memory pools information. */
typedef struct ViewportMemoryPool {
struct BLI_memblock *commands;
struct BLI_memblock *commands_small;
@@ -62,21 +62,21 @@ typedef struct ViewportMemoryPool {
uint ubo_len;
} ViewportMemoryPool;
-/* All FramebufferLists are just the same pointers with different names */
+/* All FramebufferLists are just the same pointers with different names. */
typedef struct FramebufferList {
- struct GPUFrameBuffer *framebuffers[0];
+ struct GPUFrameBuffer *framebuffers[1];
} FramebufferList;
typedef struct TextureList {
- struct GPUTexture *textures[0];
+ struct GPUTexture *textures[1];
} TextureList;
typedef struct PassList {
- struct DRWPass *passes[0];
+ struct DRWPass *passes[1];
} PassList;
typedef struct StorageList {
- void *storage[0]; /* custom structs from the engine */
+ void *storage[1]; /* Custom structs from the engine. */
} StorageList;
typedef struct ViewportEngineData {
@@ -90,10 +90,10 @@ typedef struct ViewportEngineData {
TextureList *txl_stereo;
StorageList *stl_stereo;
- /* we may want to put this elsewhere */
+ /* We may want to put this elsewhere. */
struct DRWTextStore *text_draw_cache;
- /* Profiling data */
+ /* Profiling data. */
double init_time;
double render_time;
double background_time;
@@ -141,7 +141,7 @@ void GPU_viewport_size_get(const GPUViewport *viewport, int size[2]);
void GPU_viewport_size_set(GPUViewport *viewport, const int size[2]);
void GPU_viewport_active_view_set(GPUViewport *viewport, int view);
-/* Profiling */
+/* Profiling. */
double *GPU_viewport_cache_time_get(GPUViewport *viewport);
void GPU_viewport_tag_update(GPUViewport *viewport);
@@ -149,7 +149,7 @@ bool GPU_viewport_do_update(GPUViewport *viewport);
GPUTexture *GPU_viewport_color_texture(GPUViewport *viewport, int view);
-/* Texture pool */
+/* Texture pool. */
GPUTexture *GPU_viewport_texture_pool_query(
GPUViewport *viewport, void *engine, int width, int height, int format);
diff --git a/source/blender/gpu/intern/gpu_index_buffer_private.hh b/source/blender/gpu/intern/gpu_index_buffer_private.hh
index e8a47417604..ed7dd830c8c 100644
--- a/source/blender/gpu/intern/gpu_index_buffer_private.hh
+++ b/source/blender/gpu/intern/gpu_index_buffer_private.hh
@@ -51,7 +51,7 @@ class IndexBuf {
protected:
/** Type of indices used inside this buffer. */
GPUIndexBufType index_type_ = GPU_INDEX_U32;
- /** Offset in this buffer to the first index to render. Is 0 if not a subrange. */
+ /** Offset in this buffer to the first index to render. Is 0 if not a subrange. */
uint32_t index_start_ = 0;
/** Number of indices to render. */
uint32_t index_len_ = 0;
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index 89c94fd3ba5..7fb704c29dd 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -55,7 +55,7 @@
* SubRectStride
*/
-/* For looping over a sub-region of a rect, could be moved into 'rct.c'*/
+/* For looping over a sub-region of a rect, could be moved into 'rct.c'. */
typedef struct SubRectStride {
uint start; /* start here */
uint span; /* read these */
@@ -230,7 +230,7 @@ typedef struct GPUPickState {
/* cache on initialization */
uint (*buffer)[4];
- /* buffer size (stores number of integers, for actual size multiply by sizeof integer)*/
+ /* Buffer size (stores number of integers, for actual size multiply by sizeof integer). */
uint bufsize;
/* mode of operation */
char mode;
@@ -484,7 +484,7 @@ bool gpu_select_pick_load_id(uint id, bool end)
GPUFrameBuffer *fb = GPU_framebuffer_active_get();
GPU_framebuffer_read_depth(
fb, UNPACK4(ps->gl.clip_readpixels), GPU_DATA_UINT, ps->gl.rect_depth_test->buf);
- /* perform initial check since most cases the array remains unchanged */
+ /* Perform initial check since most cases the array remains unchanged. */
bool do_pass = false;
if (g_pick_state.mode == GPU_SELECT_PICK_ALL) {
diff --git a/source/blender/gpu/intern/gpu_select_sample_query.cc b/source/blender/gpu/intern/gpu_select_sample_query.cc
index 5d8689c0d6a..fc755568687 100644
--- a/source/blender/gpu/intern/gpu_select_sample_query.cc
+++ b/source/blender/gpu/intern/gpu_select_sample_query.cc
@@ -48,17 +48,17 @@ using namespace blender;
using namespace blender::gpu;
struct GPUSelectQueryState {
- /* Tracks whether a query has been issued so that gpu_load_id can end the previous one */
+ /* Tracks whether a query has been issued so that gpu_load_id can end the previous one. */
bool query_issued;
/* GPU queries abstraction. Contains an array of queries. */
QueryPool *queries;
/* Array holding the id corresponding id to each query. */
Vector<uint> *ids;
- /* cache on initialization */
+ /* Cache on initialization. */
uint (*buffer)[4];
- /* buffer size (stores number of integers, for actual size multiply by sizeof integer)*/
+ /* Buffer size (stores number of integers, for actual size multiply by sizeof integer). */
uint bufsize;
- /* mode of operation */
+ /* Mode of operation. */
char mode;
uint index;
int oldhits;
diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc
index e2eb8953292..c754a649924 100644
--- a/source/blender/gpu/intern/gpu_shader.cc
+++ b/source/blender/gpu/intern/gpu_shader.cc
@@ -23,226 +23,24 @@
#include "MEM_guardedalloc.h"
-#include "BLI_dynstr.h"
-#include "BLI_math_base.h"
-#include "BLI_math_vector.h"
-#include "BLI_path_util.h"
-#include "BLI_string.h"
#include "BLI_string_utils.h"
-#include "BLI_utildefines.h"
-#include "BLI_vector.hh"
-
-#include "BKE_appdir.h"
-#include "BKE_global.h"
-
-#include "DNA_space_types.h"
#include "GPU_capabilities.h"
#include "GPU_matrix.h"
#include "GPU_platform.h"
-#include "GPU_shader.h"
-#include "GPU_texture.h"
-#include "GPU_uniform_buffer.h"
#include "gpu_backend.hh"
#include "gpu_context_private.hh"
#include "gpu_shader_private.hh"
-#include "CLG_log.h"
-
extern "C" char datatoc_gpu_shader_colorspace_lib_glsl[];
-static CLG_LogRef LOG = {"gpu.shader"};
-
using namespace blender;
using namespace blender::gpu;
static bool gpu_shader_srgb_uniform_dirty_get();
/* -------------------------------------------------------------------- */
-/** \name Debug functions
- * \{ */
-
-void Shader::print_log(Span<const char *> sources, char *log, const char *stage, const bool error)
-{
- const char line_prefix[] = " | ";
- char err_col[] = "\033[31;1m";
- char warn_col[] = "\033[33;1m";
- char info_col[] = "\033[0;2m";
- char reset_col[] = "\033[0;0m";
- char *sources_combined = BLI_string_join_arrayN((const char **)sources.data(), sources.size());
- DynStr *dynstr = BLI_dynstr_new();
-
- if (!CLG_color_support_get(&LOG)) {
- err_col[0] = warn_col[0] = info_col[0] = reset_col[0] = '\0';
- }
-
- BLI_dynstr_appendf(dynstr, "\n");
-
- char *log_line = log, *line_end;
- char *error_line_number_end;
- int error_line, error_char, last_error_line = -2, last_error_char = -1;
- bool found_line_id = false;
- while ((line_end = strchr(log_line, '\n'))) {
- /* Skip empty lines. */
- if (line_end == log_line) {
- log_line++;
- continue;
- }
- /* 0 = error, 1 = warning. */
- int type = -1;
- /* Skip ERROR: or WARNING:. */
- const char *prefix[] = {"ERROR", "WARNING"};
- for (int i = 0; i < ARRAY_SIZE(prefix); i++) {
- if (STREQLEN(log_line, prefix[i], strlen(prefix[i]))) {
- log_line += strlen(prefix[i]);
- type = i;
- break;
- }
- }
- /* Skip whitespaces and separators. */
- while (ELEM(log_line[0], ':', '(', ' ')) {
- log_line++;
- }
- /* Parse error line & char numbers. */
- error_line = error_char = -1;
- if (log_line[0] >= '0' && log_line[0] <= '9') {
- error_line = (int)strtol(log_line, &error_line_number_end, 10);
- /* Try to fetch the error character (not always available). */
- if (ELEM(error_line_number_end[0], '(', ':') && error_line_number_end[1] != ' ') {
- error_char = (int)strtol(error_line_number_end + 1, &log_line, 10);
- }
- else {
- log_line = error_line_number_end;
- }
- /* There can be a 3rd number (case of mesa driver). */
- if (ELEM(log_line[0], '(', ':') && log_line[1] >= '0' && log_line[1] <= '9') {
- error_line = error_char;
- error_char = (int)strtol(log_line + 1, &error_line_number_end, 10);
- log_line = error_line_number_end;
- }
- }
- /* Skip whitespaces and separators. */
- while (ELEM(log_line[0], ':', ')', ' ')) {
- log_line++;
- }
- if (error_line == -1) {
- found_line_id = false;
- }
- const char *src_line = sources_combined;
- if ((error_line != -1) && (error_char != -1)) {
- if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OFFICIAL)) {
- /* source:line */
- int error_source = error_line;
- if (error_source < sources.size()) {
- src_line = sources[error_source];
- error_line = error_char;
- error_char = -1;
- }
- }
- else if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_OFFICIAL) ||
- GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) {
- /* 0:line */
- error_line = error_char;
- error_char = -1;
- }
- else {
- /* line:char */
- }
- }
- /* Separate from previous block. */
- if (last_error_line != error_line) {
- BLI_dynstr_appendf(dynstr, "%s%s%s\n", info_col, line_prefix, reset_col);
- }
- else if (error_char != last_error_char) {
- BLI_dynstr_appendf(dynstr, "%s\n", line_prefix);
- }
- /* Print line from the source file that is producing the error. */
- if ((error_line != -1) && (error_line != last_error_line || error_char != last_error_char)) {
- const char *src_line_end;
- found_line_id = false;
- /* error_line is 1 based in this case. */
- int src_line_index = 1;
- while ((src_line_end = strchr(src_line, '\n'))) {
- if (src_line_index == error_line) {
- found_line_id = true;
- break;
- }
-/* TODO(fclem) Make this an option to display N lines before error. */
-#if 0 /* Uncomment to print shader file up to the error line to have more context. */
- BLI_dynstr_appendf(dynstr, "%5d | ", src_line_index);
- BLI_dynstr_nappend(dynstr, src_line, (src_line_end + 1) - src_line);
-#endif
- /* Continue to next line. */
- src_line = src_line_end + 1;
- src_line_index++;
- }
- /* Print error source. */
- if (found_line_id) {
- if (error_line != last_error_line) {
- BLI_dynstr_appendf(dynstr, "%5d | ", src_line_index);
- }
- else {
- BLI_dynstr_appendf(dynstr, line_prefix);
- }
- BLI_dynstr_nappend(dynstr, src_line, (src_line_end + 1) - src_line);
- /* Print char offset. */
- BLI_dynstr_appendf(dynstr, line_prefix);
- if (error_char != -1) {
- for (int i = 0; i < error_char; i++) {
- BLI_dynstr_appendf(dynstr, " ");
- }
- BLI_dynstr_appendf(dynstr, "^");
- }
- BLI_dynstr_appendf(dynstr, "\n");
- }
- }
- BLI_dynstr_appendf(dynstr, line_prefix);
- /* Skip to message. Avoid redundant info. */
- const char *keywords[] = {"error", "warning"};
- for (int i = 0; i < ARRAY_SIZE(prefix); i++) {
- if (STREQLEN(log_line, keywords[i], strlen(keywords[i]))) {
- log_line += strlen(keywords[i]);
- type = i;
- break;
- }
- }
- /* Skip and separators. */
- while (ELEM(log_line[0], ':', ')')) {
- log_line++;
- }
- if (type == 0) {
- BLI_dynstr_appendf(dynstr, "%s%s%s: ", err_col, "Error", info_col);
- }
- else if (type == 1) {
- BLI_dynstr_appendf(dynstr, "%s%s%s: ", warn_col, "Warning", info_col);
- }
- /* Print the error itself. */
- BLI_dynstr_append(dynstr, info_col);
- BLI_dynstr_nappend(dynstr, log_line, (line_end + 1) - log_line);
- BLI_dynstr_append(dynstr, reset_col);
- /* Continue to next line. */
- log_line = line_end + 1;
- last_error_line = error_line;
- last_error_char = error_char;
- }
- MEM_freeN(sources_combined);
-
- CLG_Severity severity = error ? CLG_SEVERITY_ERROR : CLG_SEVERITY_WARN;
-
- if (((LOG.type->flag & CLG_FLAG_USE) && (LOG.type->level >= 0)) ||
- (severity >= CLG_SEVERITY_WARN)) {
- const char *_str = BLI_dynstr_get_cstring(dynstr);
- CLG_log_str(LOG.type, severity, this->name, stage, _str);
- MEM_freeN((void *)_str);
- }
-
- BLI_dynstr_free(dynstr);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Creation / Destruction
* \{ */
diff --git a/source/blender/gpu/intern/gpu_shader_log.cc b/source/blender/gpu/intern/gpu_shader_log.cc
new file mode 100644
index 00000000000..12459b4b721
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_shader_log.cc
@@ -0,0 +1,217 @@
+/*
+ * 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) 2021 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup gpu
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_dynstr.h"
+#include "BLI_string.h"
+#include "BLI_string_utils.h"
+
+#include "gpu_shader_private.hh"
+
+#include "GPU_platform.h"
+
+#include "CLG_log.h"
+
+static CLG_LogRef LOG = {"gpu.shader"};
+
+namespace blender::gpu {
+
+/* -------------------------------------------------------------------- */
+/** \name Debug functions
+ * \{ */
+
+void Shader::print_log(Span<const char *> sources,
+ char *log,
+ const char *stage,
+ const bool error,
+ GPULogParser *parser)
+{
+ const char line_prefix[] = " | ";
+ char err_col[] = "\033[31;1m";
+ char warn_col[] = "\033[33;1m";
+ char info_col[] = "\033[0;2m";
+ char reset_col[] = "\033[0;0m";
+ char *sources_combined = BLI_string_join_arrayN((const char **)sources.data(), sources.size());
+ DynStr *dynstr = BLI_dynstr_new();
+
+ if (!CLG_color_support_get(&LOG)) {
+ err_col[0] = warn_col[0] = info_col[0] = reset_col[0] = '\0';
+ }
+
+ BLI_dynstr_appendf(dynstr, "\n");
+
+ char *log_line = log, *line_end;
+
+ LogCursor previous_location;
+
+ bool found_line_id = false;
+ while ((line_end = strchr(log_line, '\n'))) {
+ /* Skip empty lines. */
+ if (line_end == log_line) {
+ log_line++;
+ continue;
+ }
+
+ GPULogItem log_item;
+ log_line = parser->parse_line(log_line, log_item);
+
+ if (log_item.cursor.row == -1) {
+ found_line_id = false;
+ }
+
+ const char *src_line = sources_combined;
+
+ /* Separate from previous block. */
+ if (previous_location.source != log_item.cursor.source ||
+ previous_location.row != log_item.cursor.row) {
+ BLI_dynstr_appendf(dynstr, "%s%s%s\n", info_col, line_prefix, reset_col);
+ }
+ else if (log_item.cursor.column != previous_location.column) {
+ BLI_dynstr_appendf(dynstr, "%s\n", line_prefix);
+ }
+ /* Print line from the source file that is producing the error. */
+ if ((log_item.cursor.row != -1) && (log_item.cursor.row != previous_location.row ||
+ log_item.cursor.column != previous_location.column)) {
+ const char *src_line_end;
+ found_line_id = false;
+ /* error_line is 1 based in this case. */
+ int src_line_index = 1;
+ while ((src_line_end = strchr(src_line, '\n'))) {
+ if (src_line_index == log_item.cursor.row) {
+ found_line_id = true;
+ break;
+ }
+/* TODO(fclem) Make this an option to display N lines before error. */
+#if 0 /* Uncomment to print shader file up to the error line to have more context. */
+ BLI_dynstr_appendf(dynstr, "%5d | ", src_line_index);
+ BLI_dynstr_nappend(dynstr, src_line, (src_line_end + 1) - src_line);
+#endif
+ /* Continue to next line. */
+ src_line = src_line_end + 1;
+ src_line_index++;
+ }
+ /* Print error source. */
+ if (found_line_id) {
+ if (log_item.cursor.row != previous_location.row) {
+ BLI_dynstr_appendf(dynstr, "%5d | ", src_line_index);
+ }
+ else {
+ BLI_dynstr_appendf(dynstr, line_prefix);
+ }
+ BLI_dynstr_nappend(dynstr, src_line, (src_line_end + 1) - src_line);
+ /* Print char offset. */
+ BLI_dynstr_appendf(dynstr, line_prefix);
+ if (log_item.cursor.column != -1) {
+ for (int i = 0; i < log_item.cursor.column; i++) {
+ BLI_dynstr_appendf(dynstr, " ");
+ }
+ BLI_dynstr_appendf(dynstr, "^");
+ }
+ BLI_dynstr_appendf(dynstr, "\n");
+ }
+ }
+ BLI_dynstr_appendf(dynstr, line_prefix);
+
+ if (log_item.severity == Severity::Error) {
+ BLI_dynstr_appendf(dynstr, "%s%s%s: ", err_col, "Error", info_col);
+ }
+ else if (log_item.severity == Severity::Error) {
+ BLI_dynstr_appendf(dynstr, "%s%s%s: ", warn_col, "Warning", info_col);
+ }
+ /* Print the error itself. */
+ BLI_dynstr_append(dynstr, info_col);
+ BLI_dynstr_nappend(dynstr, log_line, (line_end + 1) - log_line);
+ BLI_dynstr_append(dynstr, reset_col);
+ /* Continue to next line. */
+ log_line = line_end + 1;
+ previous_location = log_item.cursor;
+ }
+ MEM_freeN(sources_combined);
+
+ CLG_Severity severity = error ? CLG_SEVERITY_ERROR : CLG_SEVERITY_WARN;
+
+ if (((LOG.type->flag & CLG_FLAG_USE) && (LOG.type->level >= 0)) ||
+ (severity >= CLG_SEVERITY_WARN)) {
+ const char *_str = BLI_dynstr_get_cstring(dynstr);
+ CLG_log_str(LOG.type, severity, this->name, stage, _str);
+ MEM_freeN((void *)_str);
+ }
+
+ BLI_dynstr_free(dynstr);
+}
+
+char *GPULogParser::skip_severity(char *log_line,
+ GPULogItem &log_item,
+ const char *error_msg,
+ const char *warning_msg) const
+{
+ if (STREQLEN(log_line, error_msg, strlen(error_msg))) {
+ log_line += strlen(error_msg);
+ log_item.severity = Severity::Error;
+ }
+ else if (STREQLEN(log_line, warning_msg, strlen(warning_msg))) {
+ log_line += strlen(warning_msg);
+ log_item.severity = Severity::Warning;
+ }
+ return log_line;
+}
+
+char *GPULogParser::skip_separators(char *log_line, const StringRef separators) const
+{
+ while (at_any(log_line, separators)) {
+ log_line++;
+ }
+ return log_line;
+}
+
+char *GPULogParser::skip_until(char *log_line, char stop_char) const
+{
+ char *cursor = log_line;
+ while (!ELEM(cursor[0], '\n', '\0')) {
+ if (cursor[0] == stop_char) {
+ return cursor;
+ }
+ cursor++;
+ }
+ return log_line;
+}
+
+bool GPULogParser::at_number(const char *log_line) const
+{
+ return log_line[0] >= '0' && log_line[0] <= '9';
+}
+
+bool GPULogParser::at_any(const char *log_line, const StringRef chars) const
+{
+ return chars.find(log_line[0]) != StringRef::not_found;
+}
+
+int GPULogParser::parse_number(const char *log_line, char **r_new_position) const
+{
+ return (int)strtol(log_line, r_new_position, 10);
+}
+
+/** \} */
+
+} // namespace blender::gpu
diff --git a/source/blender/gpu/intern/gpu_shader_private.hh b/source/blender/gpu/intern/gpu_shader_private.hh
index 281f01dbc22..65720e457d8 100644
--- a/source/blender/gpu/intern/gpu_shader_private.hh
+++ b/source/blender/gpu/intern/gpu_shader_private.hh
@@ -21,6 +21,7 @@
#pragma once
#include "BLI_span.hh"
+#include "BLI_string_ref.hh"
#include "GPU_shader.h"
#include "gpu_shader_interface.hh"
@@ -29,6 +30,8 @@
namespace blender {
namespace gpu {
+class GPULogParser;
+
/**
* Implementation of shader compilation and uniforms handling.
* Base class which is then specialized for each implementation (GL, VK, ...).
@@ -74,7 +77,11 @@ class Shader {
};
protected:
- void print_log(Span<const char *> sources, char *log, const char *stage, const bool error);
+ void print_log(Span<const char *> sources,
+ char *log,
+ const char *stage,
+ const bool error,
+ GPULogParser *parser);
};
/* Syntactic sugar. */
@@ -91,6 +98,41 @@ static inline const Shader *unwrap(const GPUShader *vert)
return reinterpret_cast<const Shader *>(vert);
}
+enum class Severity {
+ Unknown,
+ Warning,
+ Error,
+};
+
+struct LogCursor {
+ int source = -1;
+ int row = -1;
+ int column = -1;
+};
+
+struct GPULogItem {
+ LogCursor cursor;
+ Severity severity = Severity::Unknown;
+};
+
+class GPULogParser {
+ public:
+ virtual char *parse_line(char *log_line, GPULogItem &log_item) = 0;
+
+ protected:
+ char *skip_severity(char *log_line,
+ GPULogItem &log_item,
+ const char *error_msg,
+ const char *warning_msg) const;
+ char *skip_separators(char *log_line, const StringRef separators) const;
+ char *skip_until(char *log_line, char stop_char) const;
+ bool at_number(const char *log_line) const;
+ bool at_any(const char *log_line, const StringRef chars) const;
+ int parse_number(const char *log_line, char **r_new_position) const;
+
+ MEM_CXX_CLASS_ALLOC_FUNCS("GPULogParser");
+};
+
} // namespace gpu
} // namespace blender
diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc
index 997064e82a2..de5a9f95b65 100644
--- a/source/blender/gpu/intern/gpu_texture.cc
+++ b/source/blender/gpu/intern/gpu_texture.cc
@@ -400,7 +400,7 @@ void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void
}
/* Makes data interpretation aware of the source layout.
- * Skipping pixels correctly when changing rows when doing partial update.*/
+ * Skipping pixels correctly when changing rows when doing partial update. */
void GPU_unpack_row_length_set(uint len)
{
Context::get()->state_manager->texture_unpack_row_length_set(len);
diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.cc b/source/blender/gpu/intern/gpu_vertex_buffer.cc
index 3ecbb740a0c..2c21d2bf9af 100644
--- a/source/blender/gpu/intern/gpu_vertex_buffer.cc
+++ b/source/blender/gpu/intern/gpu_vertex_buffer.cc
@@ -229,7 +229,7 @@ void GPU_vertbuf_attr_fill(GPUVertBuf *verts_, uint a_idx, const void *data)
GPU_vertbuf_attr_fill_stride(verts_, a_idx, stride, data);
}
-/** Fills a whole vertex (all attributes). Data must match packed layout. */
+/** Fills a whole vertex (all attributes). Data must match packed layout. */
void GPU_vertbuf_vert_set(GPUVertBuf *verts_, uint v_idx, const void *data)
{
VertBuf *verts = unwrap(verts_);
diff --git a/source/blender/gpu/intern/gpu_vertex_format.cc b/source/blender/gpu/intern/gpu_vertex_format.cc
index 8498da11507..78a119bcec8 100644
--- a/source/blender/gpu/intern/gpu_vertex_format.cc
+++ b/source/blender/gpu/intern/gpu_vertex_format.cc
@@ -284,7 +284,7 @@ void GPU_vertformat_safe_attr_name(const char *attr_name, char *r_safe_name, uin
data[i] = attr_name[i];
}
/* We use a hash to identify each data layer based on its name.
- * NOTE: This is still prone to hash collision but the risks are very low.*/
+ * NOTE: This is still prone to hash collision but the risks are very low. */
/* Start hashing after the first 2 chars. */
*(uint *)&data[4] = BLI_ghashutil_strhash_p_murmur(attr_name + 4);
}
@@ -306,7 +306,8 @@ void GPU_vertformat_safe_attr_name(const char *attr_name, char *r_safe_name, uin
#endif
}
-/* Make attribute layout non-interleaved.
+/**
+ * Make attribute layout non-interleaved.
* Warning! This does not change data layout!
* Use direct buffer access to fill the data.
* This is for advanced usage.
@@ -314,11 +315,11 @@ void GPU_vertformat_safe_attr_name(const char *attr_name, char *r_safe_name, uin
* De-interleaved data means all attribute data for each attribute
* is stored continuously like this:
* 000011112222
- * instead of :
+ * instead of:
* 012012012012
*
- * Note this is per attribute de-interleaving, NOT per component.
- * */
+ * \note This is per attribute de-interleaving, NOT per component.
+ */
void GPU_vertformat_deinterleave(GPUVertFormat *format)
{
/* Ideally we should change the stride and offset here. This would allow
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index c118145ebd6..ddf31b6ffa7 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -284,7 +284,7 @@ static void gpu_viewport_engines_data_free(GPUViewport *viewport)
MEM_freeN(data);
- /* Mark as unused*/
+ /* Mark as unused. */
viewport->engine_data[i].handle = NULL;
}
diff --git a/source/blender/gpu/opengl/gl_backend.cc b/source/blender/gpu/opengl/gl_backend.cc
index d85f9f7684d..1ae68d6813c 100644
--- a/source/blender/gpu/opengl/gl_backend.cc
+++ b/source/blender/gpu/opengl/gl_backend.cc
@@ -38,6 +38,17 @@ namespace blender::gpu {
/** \name Platform
* \{ */
+static bool match_renderer(StringRef renderer, const Vector<std::string> &items)
+{
+ for (const std::string &item : items) {
+ const std::string wrapped = " " + item + " ";
+ if (renderer.endswith(item) || renderer.find(wrapped) != StringRef::not_found) {
+ return true;
+ }
+ }
+ return false;
+}
+
void GLBackend::platform_init()
{
BLI_assert(!GPG.initialized);
@@ -288,14 +299,25 @@ static void detect_workarounds()
* The work around uses `GPU_RGBA16I`.
*/
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_OFFICIAL)) {
- if (strstr(renderer, " RX 460 ") || strstr(renderer, " RX 470 ") ||
- strstr(renderer, " RX 480 ") || strstr(renderer, " RX 490 ") ||
- strstr(renderer, " RX 560 ") || strstr(renderer, " RX 560X ") ||
- strstr(renderer, " RX 570 ") || strstr(renderer, " RX 580 ") ||
- strstr(renderer, " RX 580X ") || strstr(renderer, " RX 590 ") ||
- strstr(renderer, " RX550/550 ") || strstr(renderer, "(TM) 520 ") ||
- strstr(renderer, "(TM) 530 ") || strstr(renderer, "(TM) 535 ") ||
- strstr(renderer, " R5 ") || strstr(renderer, " R7 ") || strstr(renderer, " R9 ")) {
+ const Vector<std::string> matches = {"RX 460",
+ "RX 470",
+ "RX 480",
+ "RX 490",
+ "RX 560",
+ "RX 560X",
+ "RX 570",
+ "RX 580",
+ "RX 580X",
+ "RX 590",
+ "RX550/550",
+ "(TM) 520",
+ "(TM) 530",
+ "(TM) 535",
+ "R5",
+ "R7",
+ "R9"};
+
+ if (match_renderer(renderer, matches)) {
GCaps.use_hq_normals_workaround = true;
}
}
diff --git a/source/blender/gpu/opengl/gl_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc
index 920dac407d7..e87b22985bd 100644
--- a/source/blender/gpu/opengl/gl_framebuffer.cc
+++ b/source/blender/gpu/opengl/gl_framebuffer.cc
@@ -86,7 +86,7 @@ GLFrameBuffer::~GLFrameBuffer()
/* Restore default frame-buffer if this frame-buffer was bound. */
if (context_->active_fb == this && context_->back_left != this) {
/* If this assert triggers it means the frame-buffer is being freed while in use by another
- * context which, by the way, is TOTALLY UNSAFE!!! */
+ * context which, by the way, is TOTALLY UNSAFE! */
BLI_assert(context_ == Context::get());
GPU_framebuffer_restore();
}
diff --git a/source/blender/gpu/opengl/gl_immediate.cc b/source/blender/gpu/opengl/gl_immediate.cc
index 63e3162944d..2f7fa5a78fc 100644
--- a/source/blender/gpu/opengl/gl_immediate.cc
+++ b/source/blender/gpu/opengl/gl_immediate.cc
@@ -155,7 +155,7 @@ void GLImmediate::end()
GLContext::get()->state_manager->apply_state();
/* We convert the offset in vertex offset from the buffer's start.
- * This works because we added some padding to align the first vertex vertex. */
+ * This works because we added some padding to align the first vertex vertex. */
uint v_first = buffer_offset() / vertex_format.stride;
GLVertArray::update_bindings(
vao_id_, v_first, &vertex_format, reinterpret_cast<Shader *>(shader)->interface);
diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc
index e77347d99eb..66a1bd5ceb7 100644
--- a/source/blender/gpu/opengl/gl_shader.cc
+++ b/source/blender/gpu/opengl/gl_shader.cc
@@ -158,18 +158,19 @@ GLuint GLShader::create_shader_stage(GLenum gl_stage, MutableSpan<const char *>
char log[5000] = "";
glGetShaderInfoLog(shader, sizeof(log), nullptr, log);
if (log[0] != '\0') {
+ GLLogParser parser;
switch (gl_stage) {
case GL_VERTEX_SHADER:
- this->print_log(sources, log, "VertShader", !status);
+ this->print_log(sources, log, "VertShader", !status, &parser);
break;
case GL_GEOMETRY_SHADER:
- this->print_log(sources, log, "GeomShader", !status);
+ this->print_log(sources, log, "GeomShader", !status, &parser);
break;
case GL_FRAGMENT_SHADER:
- this->print_log(sources, log, "FragShader", !status);
+ this->print_log(sources, log, "FragShader", !status, &parser);
break;
case GL_COMPUTE_SHADER:
- this->print_log(sources, log, "ComputeShader", !status);
+ this->print_log(sources, log, "ComputeShader", !status, &parser);
break;
}
}
@@ -220,7 +221,8 @@ bool GLShader::finalize()
char log[5000];
glGetProgramInfoLog(shader_program_, sizeof(log), nullptr, log);
Span<const char *> sources;
- this->print_log(sources, log, "Linking", true);
+ GLLogParser parser;
+ this->print_log(sources, log, "Linking", true, &parser);
return false;
}
diff --git a/source/blender/gpu/opengl/gl_shader.hh b/source/blender/gpu/opengl/gl_shader.hh
index 48aaaf2283d..770bc29747e 100644
--- a/source/blender/gpu/opengl/gl_shader.hh
+++ b/source/blender/gpu/opengl/gl_shader.hh
@@ -84,5 +84,16 @@ class GLShader : public Shader {
MEM_CXX_CLASS_ALLOC_FUNCS("GLShader");
};
+class GLLogParser : public GPULogParser {
+ public:
+ char *parse_line(char *log_line, GPULogItem &log_item) override;
+
+ protected:
+ char *skip_severity_prefix(char *log_line, GPULogItem &log_item);
+ char *skip_severity_keyword(char *log_line, GPULogItem &log_item);
+
+ MEM_CXX_CLASS_ALLOC_FUNCS("GLLogParser");
+};
+
} // namespace gpu
} // namespace blender
diff --git a/source/blender/gpu/opengl/gl_shader_log.cc b/source/blender/gpu/opengl/gl_shader_log.cc
new file mode 100644
index 00000000000..174cc63ad81
--- /dev/null
+++ b/source/blender/gpu/opengl/gl_shader_log.cc
@@ -0,0 +1,87 @@
+/*
+ * 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) 2021 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup gpu
+ */
+
+#include "gl_shader.hh"
+
+#include "GPU_platform.h"
+
+namespace blender::gpu {
+
+char *GLLogParser::parse_line(char *log_line, GPULogItem &log_item)
+{
+ /* Skip ERROR: or WARNING:. */
+ log_line = skip_severity_prefix(log_line, log_item);
+ log_line = skip_separators(log_line, "(: ");
+
+ /* Parse error line & char numbers. */
+ if (at_number(log_line)) {
+ char *error_line_number_end;
+ log_item.cursor.row = parse_number(log_line, &error_line_number_end);
+ /* Try to fetch the error character (not always available). */
+ if (at_any(error_line_number_end, "(:") && at_number(&error_line_number_end[1])) {
+ log_item.cursor.column = parse_number(error_line_number_end + 1, &log_line);
+ }
+ else {
+ log_line = error_line_number_end;
+ }
+ /* There can be a 3rd number (case of mesa driver). */
+ if (at_any(log_line, "(:") && at_number(&log_line[1])) {
+ log_item.cursor.source = log_item.cursor.row;
+ log_item.cursor.row = log_item.cursor.column;
+ log_item.cursor.column = parse_number(log_line + 1, &error_line_number_end);
+ log_line = error_line_number_end;
+ }
+ }
+
+ if ((log_item.cursor.row != -1) && (log_item.cursor.column != -1)) {
+ if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_OFFICIAL) ||
+ GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) {
+ /* 0:line */
+ log_item.cursor.row = log_item.cursor.column;
+ log_item.cursor.column = -1;
+ }
+ else {
+ /* line:char */
+ }
+ }
+
+ log_line = skip_separators(log_line, ":) ");
+
+ /* Skip to message. Avoid redundant info. */
+ log_line = skip_severity_keyword(log_line, log_item);
+ log_line = skip_separators(log_line, ":) ");
+
+ return log_line;
+}
+
+char *GLLogParser::skip_severity_prefix(char *log_line, GPULogItem &log_item)
+{
+ return skip_severity(log_line, log_item, "ERROR", "WARNING");
+}
+
+char *GLLogParser::skip_severity_keyword(char *log_line, GPULogItem &log_item)
+{
+ return skip_severity(log_line, log_item, "error", "warning");
+}
+
+} // namespace blender::gpu
diff --git a/source/blender/gpu/opengl/gl_texture.cc b/source/blender/gpu/opengl/gl_texture.cc
index e2478a9976c..ddc45a6a904 100644
--- a/source/blender/gpu/opengl/gl_texture.cc
+++ b/source/blender/gpu/opengl/gl_texture.cc
@@ -79,7 +79,7 @@ bool GLTexture::init_internal()
target_ = to_gl_target(type_);
- /* We need to bind once to define the texture type. */
+ /* We need to bind once to define the texture type. */
GLContext::state_manager_active_get()->texture_bind_temp(this);
if (!this->proxy_check(0)) {
@@ -106,7 +106,7 @@ bool GLTexture::init_internal(GPUVertBuf *vbo)
GLVertBuf *gl_vbo = static_cast<GLVertBuf *>(unwrap(vbo));
target_ = to_gl_target(type_);
- /* We need to bind once to define the texture type. */
+ /* We need to bind once to define the texture type. */
GLContext::state_manager_active_get()->texture_bind_temp(this);
GLenum internal_format = to_gl_internal_format(format_);
diff --git a/source/blender/gpu/opengl/gl_texture.hh b/source/blender/gpu/opengl/gl_texture.hh
index 9da27056269..dc048ea05c0 100644
--- a/source/blender/gpu/opengl/gl_texture.hh
+++ b/source/blender/gpu/opengl/gl_texture.hh
@@ -44,7 +44,7 @@ class GLTexture : public Texture {
/** All samplers states. */
static GLuint samplers_[GPU_SAMPLER_MAX];
- /** Target to bind the texture to (GL_TEXTURE_1D, GL_TEXTURE_2D, etc...)*/
+ /** Target to bind the texture to (#GL_TEXTURE_1D, #GL_TEXTURE_2D, etc...). */
GLenum target_ = -1;
/** opengl identifier for texture. */
GLuint tex_id_ = 0;
diff --git a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
index da6e6502e62..b937323f62a 100644
--- a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
@@ -170,7 +170,7 @@ void main(void)
length_b = finalThickness[2];
}
- /* generate the start endcap (alpha < 0 used as endcap flag)*/
+ /* Generate the start end-cap (alpha < 0 used as end-cap flag). */
float extend = (fill_stroke > 0) ? 2 : 1;
if ((caps_start != GPENCIL_FLATCAP) && is_equal(P0, P2)) {
mTexCoord = vec2(1, 0.5);
@@ -211,7 +211,7 @@ void main(void)
gl_Position = vec4((sp2 - length_b * miter_b) / Viewport, getZdepth(P2), 1.0);
EmitVertex();
- /* generate the end endcap (alpha < 0 used as endcap flag)*/
+ /* Generate the end end-cap (alpha < 0 used as end-cap flag). */
if ((caps_end != GPENCIL_FLATCAP) && is_equal(P1, P3)) {
mTexCoord = vec2(0, 1);
mColor = vec4(finalColor[2].rgb, finalColor[2].a * -1.0);
diff --git a/source/blender/gpu/tests/gpu_index_buffer_test.cc b/source/blender/gpu/tests/gpu_index_buffer_test.cc
index 78e351af7f1..9d767b58a7b 100644
--- a/source/blender/gpu/tests/gpu_index_buffer_test.cc
+++ b/source/blender/gpu/tests/gpu_index_buffer_test.cc
@@ -10,7 +10,7 @@
namespace blender::gpu::tests {
-TEST_F(GPUTest, gpu_index_buffer_subbuilders)
+static void test_gpu_index_buffer_subbuilders()
{
const uint num_subbuilders = 10;
const uint verts_per_subbuilders = 100;
@@ -44,4 +44,6 @@ TEST_F(GPUTest, gpu_index_buffer_subbuilders)
GPU_INDEXBUF_DISCARD_SAFE(index_buffer);
}
+GPU_TEST(gpu_index_buffer_subbuilders)
+
} // namespace blender::gpu::tests
diff --git a/source/blender/gpu/tests/gpu_shader_builtin_test.cc b/source/blender/gpu/tests/gpu_shader_builtin_test.cc
new file mode 100644
index 00000000000..f0061a6bf5c
--- /dev/null
+++ b/source/blender/gpu/tests/gpu_shader_builtin_test.cc
@@ -0,0 +1,94 @@
+/* Apache License, Version 2.0 */
+
+#include "gpu_testing.hh"
+
+#include "GPU_shader.h"
+
+namespace blender::gpu::tests {
+
+static void test_compile_builtin_shader(eGPUBuiltinShader shader_type, eGPUShaderConfig sh_cfg)
+{
+ GPUShader *sh = GPU_shader_get_builtin_shader_with_config(shader_type, sh_cfg);
+ EXPECT_NE(sh, nullptr);
+}
+
+static void test_compile_builtin_shader(eGPUBuiltinShader shader_type)
+{
+ test_compile_builtin_shader(shader_type, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(shader_type, GPU_SHADER_CFG_CLIPPED);
+}
+
+static void test_shader_builtin()
+{
+ GPU_shader_free_builtin_shaders();
+
+ test_compile_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
+ test_compile_builtin_shader(GPU_SHADER_3D_SMOOTH_COLOR);
+ test_compile_builtin_shader(GPU_SHADER_3D_DEPTH_ONLY);
+ test_compile_builtin_shader(GPU_SHADER_3D_FLAT_COLOR);
+ test_compile_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE);
+ test_compile_builtin_shader(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
+ test_compile_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
+ test_compile_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA);
+
+ test_compile_builtin_shader(GPU_SHADER_TEXT, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_KEYFRAME_DIAMOND, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_SIMPLE_LIGHTING, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_UNIFORM_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_FLAT_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_SMOOTH_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_IMAGE, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_DESATURATE_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_CHECKER, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_DIAG_STRIPES, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR,
+ GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_3D_POLYLINE_FLAT_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_POINT_FIXED_SIZE_UNIFORM_COLOR,
+ GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_POINT_UNIFORM_SIZE_VARYING_COLOR_OUTLINE_AA,
+ GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR,
+ GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR,
+ GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA,
+ GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA,
+ GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR,
+ GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR,
+ GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR,
+ GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_GPENCIL_STROKE, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_AREA_EDGES, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_WIDGET_BASE, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_WIDGET_BASE_INST, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_WIDGET_SHADOW, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_NODELINK, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_NODELINK_INST, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_UV_UNIFORM_COLOR, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_UV_VERTS, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_UV_FACEDOTS, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_UV_EDGES, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_UV_EDGES_SMOOTH, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_UV_FACES, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_UV_FACES_STRETCH_AREA, GPU_SHADER_CFG_DEFAULT);
+ test_compile_builtin_shader(GPU_SHADER_2D_UV_FACES_STRETCH_ANGLE, GPU_SHADER_CFG_DEFAULT);
+}
+
+GPU_TEST(shader_builtin)
+
+} // namespace blender::gpu::tests
diff --git a/source/blender/gpu/tests/gpu_shader_test.cc b/source/blender/gpu/tests/gpu_shader_test.cc
index e8645b89e41..43ff86ebbd8 100644
--- a/source/blender/gpu/tests/gpu_shader_test.cc
+++ b/source/blender/gpu/tests/gpu_shader_test.cc
@@ -18,7 +18,7 @@
namespace blender::gpu::tests {
-TEST_F(GPUTest, gpu_shader_compute_2d)
+static void test_gpu_shader_compute_2d()
{
if (!GPU_compute_shader_support()) {
@@ -75,8 +75,9 @@ void main() {
GPU_texture_free(texture);
GPU_shader_free(shader);
}
+GPU_TEST(gpu_shader_compute_2d)
-TEST_F(GPUTest, gpu_shader_compute_1d)
+static void test_gpu_shader_compute_1d()
{
if (!GPU_compute_shader_support()) {
@@ -137,8 +138,9 @@ void main() {
GPU_texture_free(texture);
GPU_shader_free(shader);
}
+GPU_TEST(gpu_shader_compute_1d)
-TEST_F(GPUTest, gpu_shader_compute_vbo)
+static void test_gpu_shader_compute_vbo()
{
if (!GPU_compute_shader_support()) {
@@ -201,8 +203,9 @@ void main() {
GPU_vertbuf_discard(vbo);
GPU_shader_free(shader);
}
+GPU_TEST(gpu_shader_compute_vbo)
-TEST_F(GPUTest, gpu_shader_compute_ibo)
+static void test_gpu_shader_compute_ibo()
{
if (!GPU_compute_shader_support()) {
@@ -258,8 +261,9 @@ void main() {
GPU_indexbuf_discard(ibo);
GPU_shader_free(shader);
}
+GPU_TEST(gpu_shader_compute_ibo)
-TEST_F(GPUTest, gpu_shader_ssbo_binding)
+static void test_gpu_shader_ssbo_binding()
{
if (!GPU_compute_shader_support()) {
/* We can't test as a the platform does not support compute shaders. */
@@ -297,5 +301,6 @@ void main() {
GPU_shader_unbind();
GPU_shader_free(shader);
}
+GPU_TEST(gpu_shader_ssbo_binding)
} // namespace blender::gpu::tests
diff --git a/source/blender/gpu/tests/gpu_testing.hh b/source/blender/gpu/tests/gpu_testing.hh
index cf902a91264..c45770cb94e 100644
--- a/source/blender/gpu/tests/gpu_testing.hh
+++ b/source/blender/gpu/tests/gpu_testing.hh
@@ -15,13 +15,31 @@ namespace blender::gpu {
*/
class GPUTest : public ::testing::Test {
private:
+ GHOST_TDrawingContextType draw_context_type = GHOST_kDrawingContextTypeNone;
GHOST_SystemHandle ghost_system;
GHOST_ContextHandle ghost_context;
struct GPUContext *context;
protected:
+ GPUTest(GHOST_TDrawingContextType draw_context_type) : draw_context_type(draw_context_type)
+ {
+ }
+
void SetUp() override;
void TearDown() override;
};
+class GPUOpenGLTest : public GPUTest {
+ public:
+ GPUOpenGLTest() : GPUTest(GHOST_kDrawingContextTypeOpenGL)
+ {
+ }
+};
+
+#define GPU_TEST(test_name) \
+ TEST_F(GPUOpenGLTest, test_name) \
+ { \
+ test_##test_name(); \
+ }
+
} // namespace blender::gpu
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index f569634defc..051bc193a42 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -149,7 +149,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
tree->iterations = MAX2(data->iterations, tree->iterations);
tree->stretch = tree->stretch && !(data->flag & CONSTRAINT_IK_STRETCH);
- /* skip common pose channels and add remaining*/
+ /* Skip common pose channels and add remaining. */
size = MIN2(segcount, tree->totchannel);
a = t = 0;
while (a < size && t < tree->totchannel) {
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index eb31b0e9f87..b9411f6dd2d 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -315,7 +315,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
tree->iterations = MAX2(data->iterations, tree->iterations);
tree->stretch = tree->stretch && !(data->flag & CONSTRAINT_IK_STRETCH);
- /* skip common pose channels and add remaining*/
+ /* Skip common pose channels and add remaining. */
size = MIN2(segcount, tree->totchannel);
a = t = 0;
while (a < size && t < tree->totchannel) {
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 69a80d6e0d3..2cfce7b1ba0 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -299,17 +299,22 @@ void IMB_rectblend_threaded(struct ImBuf *dbuf,
typedef enum IMB_Timecode_Type {
/** Don't use time-code files at all. */
IMB_TC_NONE = 0,
- /** use images in the order as they are recorded
+ /**
+ * Use images in the order as they are recorded
* (currently, this is the only one implemented
- * and is a sane default) */
+ * and is a sane default).
+ */
IMB_TC_RECORD_RUN = 1,
- /** Use global timestamp written by recording
- * device (prosumer camcorders e.g. can do that). */
+ /**
+ * Use global timestamp written by recording
+ * device (prosumer camcorders e.g. can do that).
+ */
IMB_TC_FREE_RUN = 2,
- /** Interpolate a global timestamp using the
+ /**
+ * Interpolate a global timestamp using the
* record date and time written by recording
- * device (*every* consumer camcorder can do
- * that :) )*/
+ * device (*every* consumer camcorder can do that).
+ */
IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN = 4,
IMB_TC_RECORD_RUN_NO_GAPS = 8,
IMB_TC_MAX_SLOT = 4,
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 450c76630a8..47514308ae4 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -1187,7 +1187,7 @@ static int ffmpeg_generic_seek_workaround(struct anim *anim,
/* If this packet contains an I-frame, this could be the frame that we need. */
bool is_key_frame = read_packet->flags & AV_PKT_FLAG_KEY;
- /* We need to check the packet timestamp as the key frame could be for a GOP forward in the the
+ /* We need to check the packet timestamp as the key frame could be for a GOP forward in the
* video stream. So if it has a larger timestamp than the frame we want, ignore it.
*/
cur_pts = timestamp_from_pts_or_dts(read_packet->pts, read_packet->dts);
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c
index 2d42609fdf5..73bcb8d7ebc 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.c
+++ b/source/blender/imbuf/intern/cineon/logImageCore.c
@@ -486,7 +486,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
}
}
- /* only one element, easy case, no need to do anything */
+ /* Only one element, easy case, no need to do anything. */
if (logImage->numElements == 1) {
returnValue = convertLogElementToRGBA(
elementData[0], data, logImage, logImage->element[0], dataIsLinearRGB);
diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp
index 1a67975b5f0..6974e0bf99d 100644
--- a/source/blender/imbuf/intern/dds/ColorBlock.cpp
+++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp
@@ -154,7 +154,7 @@ void ColorBlock::swizzle(uint x, uint y, uint z, uint w)
}
/** Returns true if the block has a single color. */
-bool ColorBlock::isSingleColor(Color32 mask /*= Color32(0xFF, 0xFF, 0xFF, 0x00)*/) const
+bool ColorBlock::isSingleColor(Color32 mask /*= Color32(0xFF, 0xFF, 0xFF, 0x00) */) const
{
uint u = m_color[0].u & mask.u;
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.h b/source/blender/imbuf/intern/dds/DirectDrawSurface.h
index b63d705dadf..381fa51f75c 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.h
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.h
@@ -120,7 +120,7 @@ struct DDSHeader {
void setHasAlphaFlag(bool b);
void setUserVersion(int version);
- /*void swapBytes();*/
+ // void swapBytes();
bool hasDX10Header() const;
uint signature() const;
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 47712456014..e6f42da1597 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -366,7 +366,7 @@ void IMB_buffer_byte_from_float_mask(uchar *rect_to,
}
}
-/* byte to float pixels, input and output 4-channel RGBA */
+/* Byte to float pixels, input and output 4-channel RGBA. */
void IMB_buffer_float_from_byte(float *rect_to,
const uchar *rect_from,
int profile_to,
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index e2d469ab5a3..804c9c3eb89 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -181,7 +181,7 @@ void bilinear_interpolation_color_wrap(
return;
}
- /* wrap interpolation pixels - main difference from bilinear_interpolation_color */
+ /* Wrap interpolation pixels - main difference from #bilinear_interpolation_color. */
if (x1 < 0) {
x1 = in->x + x1;
}
@@ -324,7 +324,7 @@ void nearest_interpolation_color_wrap(
x = x % in->x;
y = y % in->y;
- /* wrap interpolation pixels - main difference from nearest_interpolation_color */
+ /* Wrap interpolation pixels - main difference from #nearest_interpolation_color. */
if (x < 0) {
x += in->x;
}
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index a530acb15b0..71137a408d2 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -1118,7 +1118,7 @@ static AviMovie *alloc_proxy_output_avi(
AviFormat format;
double framerate;
AviMovie *avi;
- /* it doesn't really matter for proxies, but sane defaults help anyways...*/
+ /* It doesn't really matter for proxies, but sane defaults help anyways. */
short frs_sec = 25;
float frs_sec_base = 1.0;
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index 547af472d73..e62473fb8c7 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -237,10 +237,10 @@ static void test_endian_zbuf(struct ImBuf *ibuf)
}
}
-/* from misc_util: flip the bytes from x */
+/* From misc_util: flip the bytes from x. */
#define GS(x) (((uchar *)(x))[0] << 8 | ((uchar *)(x))[1])
-/* this one is only def-ed once, strangely... */
+/* This one is only def-ed once, strangely... */
#define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0])
bool imb_is_a_iris(const uchar *mem, size_t size)
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index cf27557d043..117e0d97b2e 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -41,15 +41,15 @@ static const char J2K_HEAD[] = {0xFF, 0x4F, 0xFF, 0x51, 0x00};
/* We only need this because of how the presets are set */
/* this typedef is copied from 'openjpeg-1.5.0/applications/codec/image_to_j2k.c' */
typedef struct img_folder {
- /** The directory path of the folder containing input images*/
+ /** The directory path of the folder containing input images. */
char *imgdirpath;
- /** Output format*/
+ /** Output format. */
char *out_format;
- /** Enable option*/
+ /** Enable option. */
char set_imgdir;
- /** Enable Cod Format for output*/
+ /** Enable Cod Format for output. */
char set_out_format;
- /** User specified rate stored in case of cinema option*/
+ /** User specified rate stored in case of cinema option. */
float *rates;
} img_fol_t;
@@ -647,10 +647,10 @@ BLI_INLINE int DOWNSAMPLE_FLOAT_TO_16BIT(const float _val)
/* ****************************** COPIED FROM image_to_j2k.c */
/* ----------------------------------------------------------------------- */
-#define CINEMA_24_CS 1302083 /*Codestream length for 24fps*/
-#define CINEMA_48_CS 651041 /*Codestream length for 48fps*/
-#define COMP_24_CS 1041666 /*Maximum size per color component for 2K & 4K @ 24fps*/
-#define COMP_48_CS 520833 /*Maximum size per color component for 2K @ 48fps*/
+#define CINEMA_24_CS 1302083 /* Codestream length for 24fps. */
+#define CINEMA_48_CS 651041 /* Codestream length for 48fps. */
+#define COMP_24_CS 1041666 /* Maximum size per color component for 2K & 4K @ 24fps. */
+#define COMP_48_CS 520833 /* Maximum size per color component for 2K @ 48fps. */
static int init_4K_poc(opj_poc_t *POC, int numres)
{
@@ -677,22 +677,22 @@ static void cinema_parameters(opj_cparameters_t *parameters)
parameters->cp_tdx = 1;
parameters->cp_tdy = 1;
- /*Tile part*/
+ /* Tile part. */
parameters->tp_flag = 'C';
parameters->tp_on = 1;
- /*Tile and Image shall be at (0, 0)*/
+ /* Tile and Image shall be at (0, 0). */
parameters->cp_tx0 = 0;
parameters->cp_ty0 = 0;
parameters->image_offset_x0 = 0;
parameters->image_offset_y0 = 0;
- /*Codeblock size = 32 * 32*/
+ /* Codeblock size = 32 * 32. */
parameters->cblockw_init = 32;
parameters->cblockh_init = 32;
parameters->csty |= 0x01;
- /*The progression order shall be CPRL*/
+ /* The progression order shall be CPRL. */
parameters->prog_order = OPJ_CPRL;
/* No ROI */
@@ -1118,7 +1118,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
}
}
else {
- /* just use rect*/
+ /* Just use rect. */
switch (prec) {
case 8:
if (numcomps == 4) {
@@ -1223,7 +1223,7 @@ bool imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, int UNUSED(fl
/* compression ratio */
/* invert range, from 10-100, 100-1
- * where jpeg see's 1 and highest quality (lossless) and 100 is very low quality*/
+ * Where jpeg see's 1 and highest quality (lossless) and 100 is very low quality. */
parameters.tcp_rates[0] = ((100 - quality) / 90.0f * 99.0f) + 1;
parameters.tcp_numlayers = 1; /* only one resolution */
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 382d86f2645..ab578e25b94 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -930,7 +930,7 @@ void IMB_exrtile_begin_write(
exr_printf("%s %-6s %-22s \"%s\"\n", "p", "view", "name", "internal_name");
exr_printf("---------------------------------------------------------------\n");
- /* assign channels */
+ /* Assign channels. */
for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
/* Tiles are expected to be saved with full float currently. */
BLI_assert(echan->use_half_float == 0);
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c
index d7cefbbd077..2a7a189dd2b 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -427,7 +427,7 @@ static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect)
printf("decodetarga: incomplete file, %.1f%% missing\n",
100 * ((float)size / (ibuf->x * ibuf->y)));
- /* not essential but makes displaying partially rendered TGA's less ugly */
+ /* Not essential but makes displaying partially rendered TGA's less ugly. */
memset(rect, 0, size);
}
else {
@@ -465,7 +465,7 @@ static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem
}
if (count >= 128) {
- /*if (count == 128) printf("TARGA: 128 in file !\n");*/
+ // if (count == 128) printf("TARGA: 128 in file !\n");
count -= 127;
if (psize & 2) {
@@ -475,14 +475,14 @@ static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem
cp[1] = mem[0];
cp[2] = mem[1];
cp[3] = mem[2];
- /*col = (mem[3] << 24) + (mem[0] << 16) + (mem[1] << 8) + mem[2];*/
+ // col = (mem[3] << 24) + (mem[0] << 16) + (mem[1] << 8) + mem[2];
mem += 4;
}
else {
cp[1] = mem[0];
cp[2] = mem[1];
cp[3] = mem[2];
- /*col = 0xff000000 + (mem[0] << 16) + (mem[1] << 8) + mem[2];*/
+ // col = 0xff000000 + (mem[0] << 16) + (mem[1] << 8) + mem[2];
mem += 3;
}
}
@@ -517,14 +517,14 @@ static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem
cp[1] = mem[0];
cp[2] = mem[1];
cp[3] = mem[2];
- /*col = (mem[3] << 24) + (mem[0] << 16) + (mem[1] << 8) + mem[2];*/
+ // col = (mem[3] << 24) + (mem[0] << 16) + (mem[1] << 8) + mem[2];
mem += 4;
}
else {
cp[1] = mem[0];
cp[2] = mem[1];
cp[3] = mem[2];
- /*col = 0xff000000 + (mem[0] << 16) + (mem[1] << 8) + mem[2];*/
+ // col = 0xff000000 + (mem[0] << 16) + (mem[1] << 8) + mem[2];
mem += 3;
}
}
@@ -594,7 +594,7 @@ static void ldtarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_siz
cp[1] = mem[0];
cp[2] = mem[1];
cp[3] = mem[2];
- /*col = (mem[3] << 24) + (mem[0] << 16) + (mem[1] << 8) + mem[2];*/
+ // col = (mem[3] << 24) + (mem[0] << 16) + (mem[1] << 8) + mem[2];
mem += 4;
}
else {
@@ -602,7 +602,7 @@ static void ldtarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_siz
cp[1] = mem[0];
cp[2] = mem[1];
cp[3] = mem[2];
- /*col = 0xff000000 + (mem[0] << 16) + (mem[1] << 8) + mem[2];*/
+ // col = 0xff000000 + (mem[0] << 16) + (mem[1] << 8) + mem[2];
mem += 3;
}
}
@@ -663,8 +663,8 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
cp[1] = cp[2] = 0;
if (tga.mapsize) {
- /* load color map */
- /*mincol = tga.maporig;*/ /*UNUSED*/
+ /* Load color map. */
+ // mincol = tga.maporig; /* UNUSED */
cmap_max = tga.mapsize;
cmap = MEM_callocN(sizeof(unsigned int) * cmap_max, "targa cmap");
@@ -701,7 +701,7 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
}
ibuf->planes = size;
- if (tga.mapbits != 32) { /* set alpha bits */
+ if (tga.mapbits != 32) { /* Set alpha bits. */
cmap[0] &= BIG_LONG(0x00ffffffl);
}
}
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index 7b4bf704096..db80d168e53 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -88,7 +88,7 @@ static bool get_thumb_dir(char *dir, ThumbSize size)
const char *subdir;
#ifdef WIN32
wchar_t dir_16[MAX_PATH];
- /* yes, applications shouldn't store data there, but so does GIMP :)*/
+ /* Yes, applications shouldn't store data there, but so does GIMP :). */
SHGetSpecialFolderPathW(0, dir_16, CSIDL_PROFILE, 0);
conv_utf_16_to_8(dir_16, dir, FILE_MAX);
s += strlen(dir);
@@ -144,8 +144,8 @@ static bool get_thumb_dir(char *dir, ThumbSize size)
* \{ */
typedef enum {
- UNSAFE_ALL = 0x1, /* Escape all unsafe characters */
- UNSAFE_ALLOW_PLUS = 0x2, /* Allows '+' */
+ UNSAFE_ALL = 0x1, /* Escape all unsafe characters. */
+ UNSAFE_ALLOW_PLUS = 0x2, /* Allows '+' */
UNSAFE_PATH = 0x8, /* Allows '/', '&', '=', ':', '@', '+', '$' and ',' */
UNSAFE_HOST = 0x10, /* Allows '/' and ':' and '@' */
UNSAFE_SLASHES = 0x20, /* Allows all characters except for '/' and '%' */
diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c
index b7b31b3e56a..eb518828913 100644
--- a/source/blender/imbuf/intern/thumbs_blend.c
+++ b/source/blender/imbuf/intern/thumbs_blend.c
@@ -47,7 +47,8 @@ ImBuf *IMB_thumb_load_blend(const char *blen_path, const char *blen_group, const
if (blen_group && blen_id) {
LinkNode *ln, *names, *lp, *previews = NULL;
- struct BlendHandle *libfiledata = BLO_blendhandle_from_file(blen_path, NULL);
+ BlendFileReadReport bf_reports = {.reports = NULL};
+ struct BlendHandle *libfiledata = BLO_blendhandle_from_file(blen_path, &bf_reports);
int idcode = BKE_idtype_idcode_from_name(blen_group);
int i, nprevs, nnames;
diff --git a/source/blender/io/alembic/intern/abc_reader_object.cc b/source/blender/io/alembic/intern/abc_reader_object.cc
index d428d98fdb9..00b73d29c5c 100644
--- a/source/blender/io/alembic/intern/abc_reader_object.cc
+++ b/source/blender/io/alembic/intern/abc_reader_object.cc
@@ -210,7 +210,7 @@ void AbcObjectReader::setupObjectTransform(const float time)
Alembic::AbcGeom::IXform AbcObjectReader::xform()
{
- /* Check that we have an empty object (locator, bone head/tail...). */
+ /* Check that we have an empty object (locator, bone head/tail...). */
if (IXform::matches(m_iobject.getMetaData())) {
try {
return IXform(m_iobject, Alembic::AbcGeom::kWrapExisting);
diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc
index ad5a258f80c..e8d70bf3edb 100644
--- a/source/blender/io/alembic/intern/alembic_capi.cc
+++ b/source/blender/io/alembic/intern/alembic_capi.cc
@@ -737,7 +737,7 @@ void ABC_get_transform(CacheReader *reader, float r_mat_world[4][4], float time,
/* Convert from the local matrix we obtain from Alembic to world coordinates
* for Blender. This conversion is done here rather than by Blender due to
* work around the non-standard interpretation of CONSTRAINT_SPACE_LOCAL in
- * BKE_constraint_mat_convertspace(). */
+ * BKE_constraint_mat_convertspace(). */
Object *object = abc_reader->object();
if (object->parent == nullptr) {
/* No parent, so local space is the same as world space. */
diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp
index 5c3d6be589a..f36b9aacd8b 100644
--- a/source/blender/io/collada/ArmatureImporter.cpp
+++ b/source/blender/io/collada/ArmatureImporter.cpp
@@ -325,7 +325,7 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature,
BoneExtended *pbe = extended_bones[parentbone->name];
if (dominant_child != nullptr) {
- /* Found a valid chain. Now connect current bone with that chain.*/
+ /* Found a valid chain. Now connect current bone with that chain. */
EditBone *pebone = bc_get_edit_bone(armature, parentbone->name);
EditBone *cebone = bc_get_edit_bone(armature, dominant_child->get_name());
if (pebone && !(cebone->flag & BONE_CONNECTED)) {
@@ -341,7 +341,7 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature,
if (len_squared_v3(vec) > MINIMUM_BONE_LENGTH) {
copy_v3_v3(pebone->tail, cebone->head);
- pbe->set_tail(pebone->tail); /* to make fix_leafbone happy ...*/
+ pbe->set_tail(pebone->tail); /* To make fix_leafbone happy. */
if (pbe && pbe->get_chain_length() >= this->import_settings->min_chain_length) {
BoneExtended *cbe = extended_bones[cebone->name];
diff --git a/source/blender/io/collada/BCAnimationCurve.cpp b/source/blender/io/collada/BCAnimationCurve.cpp
index 5065accf554..0e31e522ec4 100644
--- a/source/blender/io/collada/BCAnimationCurve.cpp
+++ b/source/blender/io/collada/BCAnimationCurve.cpp
@@ -314,7 +314,7 @@ void BCAnimationCurve::clean_handles()
fcurve = get_edit_fcurve();
}
- /* Keep old bezt data for copy)*/
+ /* Keep old bezt data for copy). */
BezTriple *old_bezts = fcurve->bezt;
int totvert = fcurve->totvert;
fcurve->bezt = nullptr;
diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp
index b2a9027380e..02a4e1f3167 100644
--- a/source/blender/io/collada/BCAnimationSampler.cpp
+++ b/source/blender/io/collada/BCAnimationSampler.cpp
@@ -488,7 +488,7 @@ void BCAnimationSampler::initialize_curves(BCAnimationCurveMap &curves, Object *
}
}
- /* Add curves on Object->material actions*/
+ /* Add curves on Object->material actions. */
object_type = BC_ANIMATION_TYPE_MATERIAL;
for (int a = 0; a < ob->totcol; a++) {
/* Export Material parameter animations. */
@@ -574,7 +574,7 @@ BCSample &BCSampleFrameContainer::add(Object *ob, int frame_index)
/* Below are the getters which we need to export the data */
/* ====================================================== */
-/* Return either the BCSampleFrame or NULL if frame does not exist*/
+/* Return either the BCSampleFrame or NULL if frame does not exist. */
BCSampleFrame *BCSampleFrameContainer::get_frame(int frame_index)
{
BCSampleFrameMap::iterator it = sample_frames.find(frame_index);
diff --git a/source/blender/io/collada/BCAnimationSampler.h b/source/blender/io/collada/BCAnimationSampler.h
index 52c0c8aa29e..19b1bc35264 100644
--- a/source/blender/io/collada/BCAnimationSampler.h
+++ b/source/blender/io/collada/BCAnimationSampler.h
@@ -88,7 +88,7 @@ class BCSampleFrame {
BCSample &add(Object *ob);
- /* Following methods return NULL if object is not in the sampleMap*/
+ /* Following methods return NULL if object is not in the sampleMap. */
const BCSample *get_sample(Object *ob) const;
const BCMatrix *get_sample_matrix(Object *ob) const;
const BCMatrix *get_sample_matrix(Object *ob, Bone *bone) const;
diff --git a/source/blender/io/collada/DocumentImporter.h b/source/blender/io/collada/DocumentImporter.h
index a6ed014a33c..8e553f1ce7a 100644
--- a/source/blender/io/collada/DocumentImporter.h
+++ b/source/blender/io/collada/DocumentImporter.h
@@ -77,11 +77,13 @@ class DocumentImporter : COLLADAFW::IWriter {
*/
void cancel(const COLLADAFW::String &errorMessage);
- /** This is the method called. The writer hast to prepare to receive data.*/
+ /** 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/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp
index def7caabf32..382bb8a6e36 100644
--- a/source/blender/io/collada/GeometryExporter.cpp
+++ b/source/blender/io/collada/GeometryExporter.cpp
@@ -589,7 +589,7 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
bool operator<(const Normal &a, const Normal &b)
{
- /* only needed to sort normal vectors and find() them later in a map.*/
+ /* Only needed to sort normal vectors and find() them later in a map. */
return a.x < b.x || (a.x == b.x && (a.y < b.y || (a.y == b.y && a.z < b.z)));
}
diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp
index 172f9a468b4..a33256f9a59 100644
--- a/source/blender/io/collada/MeshImporter.cpp
+++ b/source/blender/io/collada/MeshImporter.cpp
@@ -573,7 +573,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
totedge = mesh->totedge + len;
- /* update customdata */
+ /* Update custom-data. */
CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
diff --git a/source/blender/io/collada/SkinInfo.cpp b/source/blender/io/collada/SkinInfo.cpp
index 12dee388a58..c2f17174d75 100644
--- a/source/blender/io/collada/SkinInfo.cpp
+++ b/source/blender/io/collada/SkinInfo.cpp
@@ -231,7 +231,7 @@ void SkinInfo::link_armature(bContext *C,
amd->object = ob_arm;
#if 1
- /* XXX Why do we enforce objects to be children of Armatures if they weren't so before ?*/
+ /* XXX Why do we enforce objects to be children of Armatures if they weren't so before? */
if (!BKE_object_is_child_recursive(ob_arm, ob)) {
bc_set_parent(ob, ob_arm, C);
}
diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp
index bba50064879..d7855d69d99 100644
--- a/source/blender/io/collada/collada_utils.cpp
+++ b/source/blender/io/collada/collada_utils.cpp
@@ -636,7 +636,7 @@ void BoneExtended::set_bone_layers(std::string layerString, std::vector<std::str
while (ss >> layer) {
- /* Blender uses numbers to specify layers*/
+ /* Blender uses numbers to specify layers. */
if (isInteger(layer)) {
pos = atoi(layer.c_str());
if (pos >= 0 && pos < 32) {
@@ -645,10 +645,10 @@ void BoneExtended::set_bone_layers(std::string layerString, std::vector<std::str
}
}
- /* layer uses labels (not supported by blender). Map to layer numbers:*/
+ /* Layer uses labels (not supported by blender). Map to layer numbers: */
pos = find(layer_labels.begin(), layer_labels.end(), layer) - layer_labels.begin();
if (pos >= layer_labels.size()) {
- layer_labels.push_back(layer); /* remember layer number for future usage*/
+ layer_labels.push_back(layer); /* Remember layer number for future usage. */
}
if (pos > 31) {
diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.cc b/source/blender/io/gpencil/intern/gpencil_io_base.cc
index a2c1b8f5af6..6c369382e0d 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc
@@ -91,7 +91,7 @@ void GpencilIO::prepare_camera_params(Scene *scene, const GpencilIOParams *ipara
BKE_camera_params_init(&params);
BKE_camera_params_from_object(&params, cam_ob);
- /* Compute matrix, viewplane, .. */
+ /* Compute matrix, view-plane, etc. */
RenderData *rd = &scene_->r;
BKE_camera_params_compute_viewplane(&params, rd->xsch, rd->ysch, rd->xasp, rd->yasp);
BKE_camera_params_compute_matrix(&params);
diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
index 438263167ca..a9745415d40 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
@@ -295,7 +295,7 @@ void GpencilExporterSVG::export_stroke_to_path(bGPDlayer *gpl,
const float2 screen_co = gpencil_3D_point_to_2D(&pt.x);
txt.append(std::to_string(screen_co.x) + "," + std::to_string(screen_co.y));
}
- /* Close patch (cyclic)*/
+ /* Close patch (cyclic). */
if (gps->flag & GP_STROKE_CYCLIC) {
txt.append("z");
}
diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_svg.hh b/source/blender/io/gpencil/intern/gpencil_io_export_svg.hh
index 3bff31f20bf..6d8a0c2f6ac 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.hh
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.hh
@@ -62,7 +62,7 @@ class GpencilExporterSVG : public GpencilExporter {
pugi::xml_document main_doc_;
/* Main document node. */
pugi::xml_node main_node_;
- /** Frame node */
+ /** Frame node. */
pugi::xml_node frame_node_;
void create_document_header();
void export_gpencil_layers();
diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc
index 17c41e0edc1..54316e56867 100644
--- a/source/blender/io/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/io/usd/intern/usd_writer_mesh.cc
@@ -165,7 +165,7 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext &context, Mesh *mesh)
/* The material path will be of the form </_materials/{material name}>, which is outside the
* sub-tree pointed to by ref_path. As a result, the referenced data is not allowed to point
* out of its own sub-tree. It does work when we override the material with exactly the same
- * path, though.*/
+ * path, though. */
if (usd_export_context_.export_params.export_materials) {
assign_materials(context, usd_mesh, usd_mesh_data.face_groups);
}
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index dd262f78f6b..15a4f8817fd 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -79,8 +79,8 @@ typedef struct IDProperty {
/** Note, alignment for 64 bits. */
IDPropertyData data;
- /* array length, also (this is important!) string length + 1.
- * the idea is to be able to reuse array realloc functions on strings.*/
+ /* Array length, also (this is important!) string length + 1.
+ * the idea is to be able to reuse array realloc functions on strings. */
int len;
/* Strings and arrays are both buffered, though the buffer isn't saved. */
@@ -141,7 +141,7 @@ enum {
IDP_FLAG_GHOST = 1 << 7,
};
-/* add any future new id property types here.*/
+/* add any future new id property types here. */
/* Static ID override structs. */
@@ -454,6 +454,10 @@ typedef struct PreviewImage {
#define ID_TYPE_IS_COW(_id_type) \
(!ELEM(_id_type, ID_LI, ID_IP, ID_SCR, ID_VF, ID_BR, ID_WM, ID_PAL, ID_PC, ID_WS, ID_IM))
+/* Check whether data-block type requires copy-on-write from #ID_RECALC_PARAMETERS.
+ * Keep in sync with #BKE_id_eval_properties_copy. */
+#define ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW(id_type) ELEM(id_type, ID_ME)
+
#ifdef GS
# undef GS
#endif
@@ -602,10 +606,18 @@ typedef enum IDRecalcFlag {
*
* When object of armature type gets tagged with this flag, its pose is
* re-evaluated.
+ *
* When object of other type is tagged with this flag it makes the modifier
* stack to be re-evaluated.
+ *
* When object data type (mesh, curve, ...) gets tagged with this flag it
* makes all objects which shares this data-block to be updated.
+ *
+ * Note that the evaluation depends on the object-mode.
+ * So edit-mesh data for example only reevaluate with the updated edit-mesh.
+ * When geometry in the original ID has been modified #ID_RECALC_GEOMETRY_ALL_MODES
+ * must be used instead.
+ *
* When a collection gets tagged with this flag, all objects depending on the geometry and
* transforms on any of the objects in the collection are updated. */
ID_RECALC_GEOMETRY = (1 << 1),
@@ -665,6 +677,10 @@ typedef enum IDRecalcFlag {
ID_RECALC_AUDIO = (1 << 20),
+ /* NOTE: This triggers copy on write for types that require it.
+ * Exceptions to this can be added using #ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW,
+ * this has the advantage that large arrays stored in the idea data don't
+ * have to be copied on every update. */
ID_RECALC_PARAMETERS = (1 << 21),
/* Input has changed and datablock is to be reload from disk.
@@ -689,6 +705,11 @@ typedef enum IDRecalcFlag {
* all dependent objects. */
ID_RECALC_ANIMATION_NO_FLUSH = ID_RECALC_COPY_ON_WRITE,
+ /* Ensure geometry of object and edit modes are both up-to-date in the evaluated data-block.
+ * Example usage is when mesh validation modifies the non-edit-mode data,
+ * which we want to be copied over to the evaluated data-block. */
+ ID_RECALC_GEOMETRY_ALL_MODES = ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE,
+
/***************************************************************************
* Aggregate flags, use only for checks on runtime.
* Do NOT use those for tagging. */
diff --git a/source/blender/makesdna/DNA_ID_enums.h b/source/blender/makesdna/DNA_ID_enums.h
index 04cbf51dd62..45faf9e7f57 100644
--- a/source/blender/makesdna/DNA_ID_enums.h
+++ b/source/blender/makesdna/DNA_ID_enums.h
@@ -43,7 +43,7 @@ enum eIconSizes {
/* big endian */
# define MAKE_ID2(c, d) ((c) << 8 | (d))
#else
-/* little endian */
+/* little endian */
# define MAKE_ID2(c, d) ((d) << 8 | (c))
#endif
@@ -86,7 +86,7 @@ typedef enum ID_Type {
ID_MSK = MAKE_ID2('M', 'S'), /* Mask */
ID_LS = MAKE_ID2('L', 'S'), /* FreestyleLineStyle */
ID_PAL = MAKE_ID2('P', 'L'), /* Palette */
- ID_PC = MAKE_ID2('P', 'C'), /* PaintCurve */
+ ID_PC = MAKE_ID2('P', 'C'), /* PaintCurve */
ID_CF = MAKE_ID2('C', 'F'), /* CacheFile */
ID_WS = MAKE_ID2('W', 'S'), /* WorkSpace */
ID_LP = MAKE_ID2('L', 'P'), /* LightProbe */
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index a5ed870ee78..b6ffefb55e0 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -861,7 +861,7 @@ typedef enum eSAction_Flag {
SACTION_NOTRANSKEYCULL = (1 << 4),
/* don't include keyframes that are out of view */
// SACTION_HORIZOPTIMISEON = (1 << 5), // XXX deprecated... old irrelevant trick
- /* show pose-markers (local to action) in Action Editor mode */
+ /* 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) */
/* SACTION_NODRAWGCOLORS = (1 << 7), DEPRECATED */
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index dffb3588de4..c02035be4ac 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -324,7 +324,7 @@ typedef struct DriverTarget {
* (for vars where DTAR_FLAG_STRUCT_REF is used) - MAX_ID_NAME-2.
*/
char pchan_name[64];
- /** Transform channel index (for DVAR_TYPE_TRANSFORM_CHAN.)*/
+ /** Transform channel index (for #DVAR_TYPE_TRANSFORM_CHAN). */
short transChan;
/** Rotation channel calculation type. */
@@ -543,7 +543,7 @@ typedef enum eDriver_Types {
/** Driver flags. */
typedef enum eDriver_Flags {
- /** Driver has invalid settings (internal flag) */
+ /** Driver has invalid settings (internal flag). */
DRIVER_FLAG_INVALID = (1 << 0),
DRIVER_FLAG_DEPRECATED = (1 << 1),
/** Driver does replace value, but overrides (for layering of animation over driver) */
@@ -647,15 +647,15 @@ typedef struct FCurve {
/* user-editable flags/settings */
typedef enum eFCurve_Flags {
- /** curve/keyframes are visible in editor */
+ /** Curve/keyframes are visible in editor */
FCURVE_VISIBLE = (1 << 0),
- /** curve is selected for editing */
+ /** Curve is selected for editing. */
FCURVE_SELECTED = (1 << 1),
- /** curve is active one */
+ /** Curve is active one. */
FCURVE_ACTIVE = (1 << 2),
- /** keyframes (beztriples) cannot be edited */
+ /** Keyframes (beztriples) cannot be edited. */
FCURVE_PROTECTED = (1 << 3),
- /** fcurve will not be evaluated for the next round */
+ /** FCurve will not be evaluated for the next round. */
FCURVE_MUTED = (1 << 4),
/** fcurve uses 'auto-handles', which stay horizontal... */
@@ -677,9 +677,9 @@ typedef enum eFCurve_Flags {
/* extrapolation modes (only simple value 'extending') */
typedef enum eFCurve_Extend {
- /** just extend min/max keyframe value */
+ /** Just extend min/max keyframe value. */
FCURVE_EXTRAPOLATE_CONSTANT = 0,
- /** just extend gradient of segment between first segment keyframes */
+ /** Just extend gradient of segment between first segment keyframes. */
FCURVE_EXTRAPOLATE_LINEAR,
} eFCurve_Extend;
diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h
index 3d83d0d2f6f..f397b7f27b4 100644
--- a/source/blender/makesdna/DNA_armature_types.h
+++ b/source/blender/makesdna/DNA_armature_types.h
@@ -170,15 +170,15 @@ typedef enum eArmature_Flag {
ARM_FLAG_UNUSED_7 = (1 << 7),
ARM_MIRROR_EDIT = (1 << 8),
ARM_FLAG_UNUSED_9 = (1 << 9),
- /** made option negative, for backwards compat */
+ /** Made option negative, for backwards compatibility. */
ARM_NO_CUSTOM = (1 << 10),
- /** draw custom colors */
+ /** Draw custom colors. */
ARM_COL_CUSTOM = (1 << 11),
- /** when ghosting, only show selected bones (this should belong to ghostflag instead) */
+ /** When ghosting, only show selected bones (this should belong to ghostflag instead). */
ARM_FLAG_UNUSED_12 = (1 << 12), /* cleared */
- /** dopesheet channel is expanded */
+ /** Dope-sheet channel is expanded */
ARM_DS_EXPAND = (1 << 13),
- /** other objects are used for visualizing various states (hack for efficient updates) */
+ /** Other objects are used for visualizing various states (hack for efficient updates). */
ARM_HAS_VIZ_DEPS = (1 << 14),
} eArmature_Flag;
@@ -221,7 +221,7 @@ typedef enum eBone_Flag {
BONE_TIPSEL = (1 << 2),
/** Used instead of BONE_SELECTED during transform (clear before use) */
BONE_TRANSFORM = (1 << 3),
- /** when bone has a parent, connect head of bone to parent's tail*/
+ /** When bone has a parent, connect head of bone to parent's tail. */
BONE_CONNECTED = (1 << 4),
/* 32 used to be quatrot, was always set in files, do not reuse unless you clear it always */
/** hidden Bones when drawing PoseChannels */
diff --git a/source/blender/makesdna/DNA_boid_types.h b/source/blender/makesdna/DNA_boid_types.h
index 540446ccd9d..02a4d87498a 100644
--- a/source/blender/makesdna/DNA_boid_types.h
+++ b/source/blender/makesdna/DNA_boid_types.h
@@ -43,7 +43,7 @@ typedef enum eBoidRuleType {
eBoidRuleType_Flock = 5,
/** follow a boid or assigned object */
eBoidRuleType_FollowLeader = 6,
- /** maintain speed, flight level or wander*/
+ /** Maintain speed, flight level or wander. */
eBoidRuleType_AverageSpeed = 7,
/** go to closest enemy and attack when in range */
eBoidRuleType_Fight = 8,
diff --git a/source/blender/makesdna/DNA_brush_defaults.h b/source/blender/makesdna/DNA_brush_defaults.h
index fb726e24929..c3f171977a9 100644
--- a/source/blender/makesdna/DNA_brush_defaults.h
+++ b/source/blender/makesdna/DNA_brush_defaults.h
@@ -88,7 +88,7 @@
.cursor_overlay_alpha = 33, \
.overlay_flags = 0, \
\
- /* brush appearance */ \
+ /* Brush appearance. */ \
\
/* add mode color is light red */ \
.add_col = {1.0, 0.39, 0.39, 0.9}, \
diff --git a/source/blender/makesdna/DNA_brush_enums.h b/source/blender/makesdna/DNA_brush_enums.h
index 093a1a00ece..6563afd2b4a 100644
--- a/source/blender/makesdna/DNA_brush_enums.h
+++ b/source/blender/makesdna/DNA_brush_enums.h
@@ -25,7 +25,7 @@ extern "C" {
#endif
/* BrushGpencilSettings->preset_type.
- * Use a range for each group and not continuous values.*/
+ * Use a range for each group and not continuous values. */
typedef enum eGPBrush_Presets {
GP_BRUSH_PRESET_UNKNOWN = 0,
diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h
index 73a55edf05f..32ebcade76d 100644
--- a/source/blender/makesdna/DNA_camera_types.h
+++ b/source/blender/makesdna/DNA_camera_types.h
@@ -202,8 +202,10 @@ enum {
CAM_BGIMG_FLAG_FOREGROUND = (1 << 4),
/* Camera framing options */
- CAM_BGIMG_FLAG_CAMERA_ASPECT = (1 << 5), /* don't stretch to fit the camera view */
- CAM_BGIMG_FLAG_CAMERA_CROP = (1 << 6), /* crop out the image */
+ /** Don't stretch to fit the camera view. */
+ CAM_BGIMG_FLAG_CAMERA_ASPECT = (1 << 5),
+ /** Crop out the image. */
+ CAM_BGIMG_FLAG_CAMERA_CROP = (1 << 6),
/* Axis flip options */
CAM_BGIMG_FLAG_FLIP_X = (1 << 7),
@@ -211,7 +213,7 @@ enum {
};
/* CameraBGImage->source */
-/* may want to use 1 for select ?*/
+/* may want to use 1 for select? */
enum {
CAM_BGIMG_SOURCE_IMAGE = 0,
CAM_BGIMG_SOURCE_MOVIE = 1,
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index aae29e5fddc..e2eea5e5422 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -141,7 +141,7 @@ typedef struct ClothSimSettings {
short solver_type;
/** Vertex group for scaling bending stiffness. */
short vgroup_bend;
- /** Optional vertexgroup name for assigning weight..*/
+ /** Optional vertexgroup name for assigning weight. */
short vgroup_mass;
/** Vertex group for scaling structural stiffness. */
short vgroup_struct;
@@ -184,7 +184,7 @@ typedef struct ClothSimSettings {
} ClothSimSettings;
-/* SIMULATION FLAGS: goal flags,.. */
+/* SIMULATION FLAGS: goal flags, etc. */
/* These are the bits used in SimSettings.flags. */
typedef enum {
/** Object is only collision object, no cloth simulation is done. */
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index a94bc4625df..6531933af23 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -51,9 +51,9 @@ typedef struct bConstraint {
/** Constraint data (a valid constraint type). */
void *data;
- /** Constraint type. */
+ /** Constraint type. */
short type;
- /** Flag - General Settings. */
+ /** Flag - General Settings. */
short flag;
/** Space that owner should be evaluated in. */
@@ -89,7 +89,7 @@ typedef struct bConstraint {
float rot_error;
} bConstraint;
-/* Multiple-target constraints --------------------- */
+/* Multiple-target constraints --------------------- */
/* This struct defines a constraint target.
* It is used during constraint solving regardless of how many targets the
@@ -257,7 +257,7 @@ typedef struct bArmatureConstraint {
ListBase targets;
} bArmatureConstraint;
-/* Single-target subobject constraints --------------------- */
+/* Single-target subobject constraints --------------------- */
/* Track To Constraint */
typedef struct bTrackToConstraint {
@@ -316,8 +316,9 @@ typedef struct bSameVolumeConstraint {
/* Copy Transform Constraint */
typedef struct bTransLikeConstraint {
struct Object *tar;
+ int flag;
char mix_mode;
- char _pad[7];
+ char _pad[3];
/** MAX_ID_NAME-2. */
char subtarget[64];
} bTransLikeConstraint;
@@ -517,7 +518,7 @@ typedef struct bPivotConstraint {
short flag;
} bPivotConstraint;
-/* transform limiting constraints - zero target ---------------------------- */
+/* transform limiting constraints - zero target ---------------------------- */
/* Limit Location Constraint */
typedef struct bLocLimitConstraint {
float xmin, xmax;
@@ -721,7 +722,7 @@ typedef enum eBConstraint_Flags {
CONSTRAINT_BBONE_SHAPE = (1 << 10),
/* That constraint has been inserted in local override (i.e. it can be fully edited!). */
CONSTRAINT_OVERRIDE_LIBRARY_LOCAL = (1 << 11),
- /* use full transformation (not just segment locations) - only set at runtime */
+ /* use full transformation (not just segment locations) - only set at runtime. */
CONSTRAINT_BBONE_SHAPE_FULL = (1 << 12),
} eBConstraint_Flags;
@@ -740,6 +741,8 @@ typedef enum eBConstraint_SpaceTypes {
CONSTRAINT_SPACE_POSE = 2,
/** For posechannels - local with parent. */
CONSTRAINT_SPACE_PARLOCAL = 3,
+ /** For posechannels - local converted to the owner bone orientation. */
+ CONSTRAINT_SPACE_OWNLOCAL = 6,
/** For files from between 2.43-2.46 (should have been parlocal). */
CONSTRAINT_SPACE_INVALID = 4, /* do not exchange for anything! */
} eBConstraint_SpaceTypes;
@@ -810,6 +813,12 @@ typedef enum eCopyScale_Flags {
SIZELIKE_UNIFORM = (1 << 5),
} eCopyScale_Flags;
+/* bTransLikeConstraint.flag */
+typedef enum eCopyTransforms_Flags {
+ /* Remove shear from the target matrix. */
+ TRANSLIKE_REMOVE_TARGET_SHEAR = (1 << 0),
+} eCopyTransforms_Flags;
+
/* bTransLikeConstraint.mix_mode */
typedef enum eCopyTransforms_MixMode {
/* Replace rotation channel values. */
@@ -818,6 +827,14 @@ typedef enum eCopyTransforms_MixMode {
TRANSLIKE_MIX_BEFORE = 1,
/* Multiply the copied transformation on the right, with anti-shear scale handling. */
TRANSLIKE_MIX_AFTER = 2,
+ /* Multiply the copied transformation on the left, handling loc/rot/scale separately. */
+ TRANSLIKE_MIX_BEFORE_SPLIT = 3,
+ /* Multiply the copied transformation on the right, handling loc/rot/scale separately. */
+ TRANSLIKE_MIX_AFTER_SPLIT = 4,
+ /* Multiply the copied transformation on the left, using simple matrix multiplication. */
+ TRANSLIKE_MIX_BEFORE_FULL = 5,
+ /* Multiply the copied transformation on the right, using simple matrix multiplication. */
+ TRANSLIKE_MIX_AFTER_FULL = 6,
} eCopyTransforms_MixMode;
/* bTransformConstraint.to/from */
@@ -1065,7 +1082,7 @@ typedef enum eTransformLimits_Flags2 {
LIMIT_TRANSFORM = (1 << 1),
} eTransformLimits_Flags2;
-/* transform limiting constraints -> flag (own flags) */
+/* transform limiting constraints -> flag (own flags). */
typedef enum eTransformLimits_Flags {
LIMIT_XMIN = (1 << 0),
LIMIT_XMAX = (1 << 1),
@@ -1075,7 +1092,7 @@ typedef enum eTransformLimits_Flags {
LIMIT_ZMAX = (1 << 5),
} eTransformLimits_Flags;
-/* limit rotation constraint -> flag (own flags) */
+/* limit rotation constraint -> flag (own flags). */
typedef enum eRotLimit_Flags {
LIMIT_XROT = (1 << 0),
LIMIT_YROT = (1 << 1),
diff --git a/source/blender/makesdna/DNA_curveprofile_types.h b/source/blender/makesdna/DNA_curveprofile_types.h
index 450155a32e1..7c76251adc3 100644
--- a/source/blender/makesdna/DNA_curveprofile_types.h
+++ b/source/blender/makesdna/DNA_curveprofile_types.h
@@ -72,7 +72,7 @@ typedef struct CurveProfile {
short segments_len;
/** Preset to use when reset. */
int preset;
- /** Sequence of points defining the shape of the curve. */
+ /** Sequence of points defining the shape of the curve. */
CurveProfilePoint *path;
/** Display and evaluation table at higher resolution for curves. */
CurveProfilePoint *table;
diff --git a/source/blender/makesdna/DNA_effect_types.h b/source/blender/makesdna/DNA_effect_types.h
index 307a212a139..3de13169616 100644
--- a/source/blender/makesdna/DNA_effect_types.h
+++ b/source/blender/makesdna/DNA_effect_types.h
@@ -27,30 +27,30 @@
extern "C" {
#endif
-/* don't forget, new effects also in writefile.c for dna!!! */
+/* Don't forget, new effects also in writefile.c for DNA! */
#define PAF_MAXMULT 4
-/* paf->flag (keep bit 0 free for compatibility) */
+/* paf->flag (keep bit 0 free for compatibility). */
#define PAF_BSPLINE 2
#define PAF_STATIC 4
#define PAF_FACE 8
#define PAF_ANIMATED 16
-/* show particles before they're emitted*/
+/* show particles before they're emitted. */
#define PAF_UNBORN 32
-/* emit only from faces*/
+/* Emit only from faces. */
#define PAF_OFACE 64
-/* show emitter (don't hide actual mesh)*/
+/* show emitter (don't hide actual mesh). */
#define PAF_SHOWE 128
-/* true random emit from faces (not just ordered jitter)*/
+/* true random emit from faces (not just ordered jitter). */
#define PAF_TRAND 256
-/* even distribution in face emission based on face areas*/
+/* even distribution in face emission based on face areas. */
#define PAF_EDISTR 512
-/*show particles after they've died*/
+/* Show particles after they've died. */
#define PAF_DIED 2048
-/*paf->flag2 for pos/neg paf->flag2neg*/
-#define PAF_TEXTIME 1 /*texture timing*/
+/* `paf->flag2` for pos/neg `paf->flag2neg`. */
+#define PAF_TEXTIME 1 /* Texture timing. */
/* eff->type */
#define EFF_BUILD 0
diff --git a/source/blender/makesdna/DNA_fluid_types.h b/source/blender/makesdna/DNA_fluid_types.h
index e787b44e557..5e36c5673a4 100644
--- a/source/blender/makesdna/DNA_fluid_types.h
+++ b/source/blender/makesdna/DNA_fluid_types.h
@@ -289,7 +289,7 @@ enum {
#define FLUID_NAME_PARTICLES "fluid_particles"
#define FLUID_NAME_GUIDING "fluid_guiding"
-/* Fluid object names.*/
+/* Fluid object names. */
#define FLUID_NAME_FLAGS "flags" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_VELOCITY "velocity" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_VEL "vel"
@@ -813,8 +813,8 @@ typedef struct FluidFlowSettings {
char uvlayer_name[64];
short vgroup_density;
- short type; /* Smoke, flames, both, outflow, liquid. */
- short behavior; /* Inflow, outflow, static. */
+ short type; /* Smoke, flames, both, outflow, liquid. */
+ short behavior; /* Inflow, outflow, static. */
short source;
short texture_type;
short _pad3[3];
diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h
index 74d668a1081..fda1cbaeae6 100644
--- a/source/blender/makesdna/DNA_genfile.h
+++ b/source/blender/makesdna/DNA_genfile.h
@@ -44,7 +44,7 @@ extern const int DNAlen;
/**
* Primitive (non-struct, non-pointer/function/array) types,
* \warning Don't change these values!
- * Currently changes here here will work on native endianness,
+ * Currently changes here will work on native endianness,
* however #DNA_struct_switch_endian currently checks these
* hard-coded values against those from old files.
*/
@@ -90,7 +90,7 @@ struct SDNA *DNA_sdna_from_data(const void *data,
const char **r_error_message);
void DNA_sdna_free(struct SDNA *sdna);
-/* Access for current Blender versions SDNA*/
+/* Access for current Blender versions SDNA. */
void DNA_sdna_current_init(void);
/* borrowed reference */
const struct SDNA *DNA_sdna_current_get(void);
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
index 52a5df3b49a..1bd2a2a56c6 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
@@ -184,8 +184,6 @@
.layer_pass = 0, \
.hardeness = 1.0f, \
.curve_intensity = NULL, \
- .fading_end = 10.0f, \
- .fading_end_factor = 0.2f, \
}
#define _DNA_DEFAULT_SimplifyGpencilModifierData \
@@ -253,8 +251,6 @@
.thickness_fac = 1.0f, \
.thickness = 30, \
.layer_pass = 0, \
- .fading_end = 10.0f, \
- .fading_end_factor = 0.2f, \
}
#define _DNA_DEFAULT_TimeGpencilModifierData \
@@ -287,6 +283,20 @@
.colorband = NULL, \
}
+#define _DNA_DEFAULT_WeightGpencilModifierData \
+ { \
+ .target_vgname = "", \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .axis = 1, \
+ .layer_pass = 0, \
+ .dist_start = 0.0f, \
+ .dist_end = 20.0f, \
+ }
+
#define _DNA_DEFAULT_LineartGpencilModifierData \
{ \
.edge_types = LRT_EDGE_FLAG_ALL_TYPE, \
@@ -298,7 +308,6 @@
.angle_splitting_threshold = DEG2RAD(60.0f), \
.chaining_image_threshold = 0.001f, \
.stroke_offset = 0.05,\
- .chain_smooth_tolerance = 0.0f,\
.overscan = 0.1f,\
}
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index a871921abd2..378599015e8 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -55,6 +55,7 @@ typedef enum GpencilModifierType {
eGpencilModifierType_Texture = 18,
eGpencilModifierType_Lineart = 19,
eGpencilModifierType_Length = 20,
+ eGpencilModifierType_Weight = 21,
/* Keep last. */
NUM_GREASEPENCIL_MODIFIER_TYPES,
} GpencilModifierType;
@@ -188,12 +189,7 @@ typedef struct ThickGpencilModifierData {
int thickness;
/** Custom index for passes. */
int layer_pass;
- /** Start/end distances of the fading effect. */
- float fading_start;
- float fading_end;
- float fading_end_factor;
- /** Fading reference object */
- struct Object *object;
+ char _pad[4];
struct CurveMapping *curve_thickness;
} ThickGpencilModifierData;
@@ -205,7 +201,7 @@ typedef enum eThickGpencil_Flag {
GP_THICK_NORMALIZE = (1 << 4),
GP_THICK_INVERT_LAYERPASS = (1 << 5),
GP_THICK_INVERT_MATERIAL = (1 << 6),
- GP_THICK_FADING = (1 << 7),
+ GP_THICK_WEIGHT_FACTOR = (1 << 7),
} eThickGpencil_Flag;
typedef struct TimeGpencilModifierData {
@@ -298,16 +294,9 @@ typedef struct OpacityGpencilModifierData {
int flag;
/** Main Opacity factor. */
float factor;
- /** Fading controlling object */
- int _pad0;
- struct Object *object;
- /** Start/end distances of the fading effect. */
- float fading_start;
- float fading_end;
- float fading_end_factor;
/** Modify stroke, fill or both. */
char modify_color;
- char _pad1[3];
+ char _pad[3];
/** Custom index for passes. */
int layer_pass;
@@ -323,7 +312,7 @@ typedef enum eOpacityGpencil_Flag {
GP_OPACITY_INVERT_MATERIAL = (1 << 5),
GP_OPACITY_CUSTOM_CURVE = (1 << 6),
GP_OPACITY_NORMALIZE = (1 << 7),
- GP_OPACITY_FADING = (1 << 8),
+ GP_OPACITY_WEIGHT_FACTOR = (1 << 8),
} eOpacityGpencil_Flag;
typedef struct ArrayGpencilModifierData {
@@ -814,6 +803,7 @@ typedef enum eTintGpencil_Flag {
GP_TINT_INVERT_LAYERPASS = (1 << 4),
GP_TINT_INVERT_MATERIAL = (1 << 5),
GP_TINT_CUSTOM_CURVE = (1 << 6),
+ GP_TINT_WEIGHT_FACTOR = (1 << 7),
} eTintGpencil_Flag;
typedef struct TextureGpencilModifierData {
@@ -867,16 +857,72 @@ typedef enum eTextureGpencil_Mode {
STROKE_AND_FILL = 2,
} eTextureGpencil_Mode;
+typedef struct WeightGpencilModifierData {
+ GpencilModifierData modifier;
+ /** Target vertexgroup name, MAX_VGROUP_NAME. */
+ char target_vgname[64];
+ /** Material for filtering. */
+ struct Material *material;
+ /** Layer name. */
+ char layername[64];
+ /** Optional vertexgroup filter name, MAX_VGROUP_NAME. */
+ char vgname[64];
+ /** Custom index for passes. */
+ int pass_index;
+ /** Flags. */
+ int flag;
+ /** Minimum valid weight (clamp value). */
+ float min_weight;
+ /** Custom index for passes. */
+ int layer_pass;
+ /** Calculation Mode. */
+ short mode;
+ /** Axis. */
+ short axis;
+ /** Angle */
+ float angle;
+ /** Start/end distances. */
+ float dist_start;
+ float dist_end;
+ /** Space (Local/World). */
+ short space;
+ char _pad[6];
+
+ /** Reference object */
+ struct Object *object;
+} WeightGpencilModifierData;
+
+typedef enum eWeightGpencil_Flag {
+ GP_WEIGHT_INVERT_LAYER = (1 << 0),
+ GP_WEIGHT_INVERT_PASS = (1 << 1),
+ GP_WEIGHT_INVERT_VGROUP = (1 << 2),
+ GP_WEIGHT_INVERT_LAYERPASS = (1 << 3),
+ GP_WEIGHT_INVERT_MATERIAL = (1 << 4),
+ GP_WEIGHT_BLEND_DATA = (1 << 5),
+ GP_WEIGHT_INVERT_OUTPUT = (1 << 6),
+} eWeightGpencil_Flag;
+
+typedef enum eWeightGpencilModifierMode {
+ GP_WEIGHT_MODE_DISTANCE = 0,
+ GP_WEIGHT_MODE_ANGLE = 1,
+} eWeightGpencilModifierMode;
+
+typedef enum eGpencilModifierSpace {
+ GP_SPACE_LOCAL = 0,
+ GP_SPACE_WORLD = 1,
+} eGpencilModifierSpace;
+
typedef enum eLineartGpencilModifierSource {
LRT_SOURCE_COLLECTION = 0,
LRT_SOURCE_OBJECT = 1,
LRT_SOURCE_SCENE = 2,
} eLineartGpencilModifierSource;
-/* This enumis for modifier internal state only. */
+/* This enum is for modifier internal state only. */
typedef enum eLineArtGPencilModifierFlags {
- /* LRT_GPENCIL_INVERT_SOURCE_VGROUP = (1 << 0), Moved to eLineartMainFlags */
- /* LRT_GPENCIL_MATCH_OUTPUT_VGROUP = (1 << 1), Moved to eLineartMainFlags */
+ /* These two moved to #eLineartMainFlags to keep consistent with flag variable purpose. */
+ /* LRT_GPENCIL_INVERT_SOURCE_VGROUP = (1 << 0), */
+ /* LRT_GPENCIL_MATCH_OUTPUT_VGROUP = (1 << 1), */
LRT_GPENCIL_BINARY_WEIGHTS = (1 << 2) /* Deprecated, this is removed for lack of use case. */,
LRT_GPENCIL_IS_BAKED = (1 << 3),
LRT_GPENCIL_USE_CACHE = (1 << 4),
@@ -884,9 +930,9 @@ typedef enum eLineArtGPencilModifierFlags {
} eLineArtGPencilModifierFlags;
typedef enum eLineartGpencilMaskSwitches {
- LRT_GPENCIL_TRANSPARENCY_ENABLE = (1 << 0),
+ LRT_GPENCIL_MATERIAL_MASK_ENABLE = (1 << 0),
/** Set to true means using "and" instead of "or" logic on mask bits. */
- LRT_GPENCIL_TRANSPARENCY_MATCH = (1 << 1),
+ LRT_GPENCIL_MATERIAL_MASK_MATCH = (1 << 1),
LRT_GPENCIL_INTERSECTION_FILTER = (1 << 2),
LRT_GPENCIL_INTERSECTION_MATCH = (1 << 3),
} eLineartGpencilMaskSwitches;
@@ -932,10 +978,10 @@ typedef struct LineartGpencilModifierData {
short thickness;
unsigned char mask_switches; /* eLineartGpencilMaskSwitches */
- unsigned char transparency_mask;
+ unsigned char material_mask_bits;
unsigned char intersection_mask;
- char _pad[3];
+ char _pad[7];
/** `0..1` range for cosine angle */
float crease_threshold;
@@ -943,10 +989,7 @@ typedef struct LineartGpencilModifierData {
/** `0..PI` angle, for splitting strokes at sharp points. */
float angle_splitting_threshold;
- /** Strength for smoothing jagged chains */
- float chain_smooth_tolerance;
-
- /* CPU mode */
+ /* Doubles as geometry threshold when geometry space chaining is enabled */
float chaining_image_threshold;
/* Ported from SceneLineArt flags. */
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 6b7b89e91fa..d0ae50d09ef 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -309,7 +309,7 @@ typedef struct bGPDstroke {
float uv_translation[2];
float uv_scale;
- /** Stroke selection index.*/
+ /** Stroke selection index. */
int select_index;
char _pad4[4];
@@ -557,7 +557,7 @@ typedef enum eGPDlayer_Flag {
/* Unlock color */
GP_LAYER_UNLOCK_COLOR = (1 << 12),
/* Mask Layer */
- GP_LAYER_USE_MASK = (1 << 13), /*TODO: DEPRECATED */
+ GP_LAYER_USE_MASK = (1 << 13), /* TODO: DEPRECATED */
/* Ruler Layer */
GP_LAYER_IS_RULER = (1 << 14),
/* Disable masks in viewlayer render */
@@ -614,7 +614,7 @@ typedef struct bGPdata_Runtime {
/** Vertex Color applied to Fill (while drawing). */
float vert_color_fill[4];
- /** Arrow points for stroke corners **/
+ /** Arrow points for stroke corners. */
float arrow_start[8];
float arrow_end[8];
/* Arrow style for each corner */
diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h
index c5e207c4e20..0552c449819 100644
--- a/source/blender/makesdna/DNA_ipo_types.h
+++ b/source/blender/makesdna/DNA_ipo_types.h
@@ -432,10 +432,10 @@ typedef struct Ipo {
#define PART_TOTNAM 25
#define PART_EMIT_FREQ 1
-/* #define PART_EMIT_LIFE 2 */ /*UNUSED*/
+// #define PART_EMIT_LIFE 2 /* UNUSED */
#define PART_EMIT_VEL 3
#define PART_EMIT_AVE 4
-/* #define PART_EMIT_SIZE 5 */ /*UNUSED*/
+// #define PART_EMIT_SIZE 5 /* UNUSED */
#define PART_AVE 6
#define PART_SIZE 7
@@ -511,7 +511,7 @@ typedef struct Ipo {
/* ---------- IPO Drivers ----------- */
-/* offset in driver->name for finding second posechannel for rot-diff */
+/* Offset in driver->name for finding second posechannel for rot-diff. */
#define DRIVER_NAME_OFFS 32
/* driver->type */
diff --git a/source/blender/makesdna/DNA_key_types.h b/source/blender/makesdna/DNA_key_types.h
index 9789d0d3520..228a1024721 100644
--- a/source/blender/makesdna/DNA_key_types.h
+++ b/source/blender/makesdna/DNA_key_types.h
@@ -46,10 +46,10 @@ typedef struct KeyBlock {
* so this value increments by 0.1f per frame.
*/
float pos;
- /** influence (typically [0 - 1] but can be more), (Key->type == KEY_RELATIVE) only.*/
+ /** influence (typically [0 - 1] but can be more), `(Key->type == KEY_RELATIVE)` only. */
float curval;
- /** interpolation type (Key->type == KEY_NORMAL) only. */
+ /** Interpolation type `(Key->type == KEY_NORMAL)` only. */
short type;
char _pad1[2];
@@ -62,7 +62,7 @@ typedef struct KeyBlock {
/** for meshes only, match the unique number with the customdata layer */
int uid;
- /** array of shape key values, size is (Key->elemsize * KeyBlock->totelem) */
+ /** array of shape key values, size is `(Key->elemsize * KeyBlock->totelem)` */
void *data;
/** MAX_NAME (unique name, user assigned) */
char name[64];
@@ -81,7 +81,7 @@ typedef struct Key {
struct AnimData *adt;
/**
- * commonly called 'Basis', (Key->type == KEY_RELATIVE) only.
+ * commonly called 'Basis', `(Key->type == KEY_RELATIVE)` only.
* Looks like this is _always_ 'key->block.first',
* perhaps later on it could be defined as some other KeyBlock - campbell
*/
diff --git a/source/blender/makesdna/DNA_lightprobe_types.h b/source/blender/makesdna/DNA_lightprobe_types.h
index 48e3c44e2c9..038de8e49cc 100644
--- a/source/blender/makesdna/DNA_lightprobe_types.h
+++ b/source/blender/makesdna/DNA_lightprobe_types.h
@@ -106,7 +106,7 @@ enum {
LIGHTPROBE_DISP_REFLECTIVE = 3,
};
-/* Probe->parallax && Probe->attenuation_type*/
+/* Probe->parallax && Probe->attenuation_type. */
enum {
LIGHTPROBE_SHAPE_ELIPSOID = 0,
LIGHTPROBE_SHAPE_BOX = 1,
diff --git a/source/blender/makesdna/DNA_lineart_types.h b/source/blender/makesdna/DNA_lineart_types.h
index 576bcc37f3d..58473313ebc 100644
--- a/source/blender/makesdna/DNA_lineart_types.h
+++ b/source/blender/makesdna/DNA_lineart_types.h
@@ -47,16 +47,15 @@ typedef enum eLineartMainFlags {
LRT_ALLOW_OVERLAPPING_EDGES = (1 << 3),
LRT_ALLOW_CLIPPING_BOUNDARIES = (1 << 4),
LRT_REMOVE_DOUBLES = (1 << 5),
- LRT_FLOATING_AS_CONTOUR = (1 << 6),
+ LRT_LOOSE_AS_CONTOUR = (1 << 6),
LRT_GPENCIL_INVERT_SOURCE_VGROUP = (1 << 7),
LRT_GPENCIL_MATCH_OUTPUT_VGROUP = (1 << 8),
LRT_FILTER_FACE_MARK = (1 << 9),
LRT_FILTER_FACE_MARK_INVERT = (1 << 10),
LRT_FILTER_FACE_MARK_BOUNDARIES = (1 << 11),
- LRT_CHAIN_FLOATING_EDGES = (1 << 11),
- LRT_CHAIN_GEOMETRY_SPACE = (1 << 12),
- LRT_ALLOW_MULTIPLE_EDGE_TYPES = (1 << 13),
- LRT_USE_CUSTOM_CAMERA = (1 << 14),
+ LRT_CHAIN_LOOSE_EDGES = (1 << 12),
+ LRT_CHAIN_GEOMETRY_SPACE = (1 << 13),
+ LRT_ALLOW_OVERLAP_EDGE_TYPES = (1 << 14),
} eLineartMainFlags;
typedef enum eLineartEdgeFlag {
@@ -65,15 +64,10 @@ typedef enum eLineartEdgeFlag {
LRT_EDGE_FLAG_CREASE = (1 << 2),
LRT_EDGE_FLAG_MATERIAL = (1 << 3),
LRT_EDGE_FLAG_INTERSECTION = (1 << 4),
- LRT_EDGE_FLAG_FLOATING = (1 << 5),
- LRT_EDGE_FLAG_LIGHT_CONTOUR = (1 << 6),
- /* LRT_EDGE_FLAG_FOR_FUTURE = (1 << 7), */
- /* Limited to 8 bits for edge type flag, don't add anymore because BMEdge->head.eflag only has 8
- bits. So unless we changed this into a non-single-bit flag thing, we keep it this way. */
- /** Also used as discarded line mark. */
- LRT_EDGE_FLAG_CHAIN_PICKED = (1 << 8),
- LRT_EDGE_FLAG_CLIPPED = (1 << 9),
- /** Limited to 16 bits for the entire thing. */
+ LRT_EDGE_FLAG_LOOSE = (1 << 5),
+ LRT_EDGE_FLAG_CHAIN_PICKED = (1 << 6),
+ LRT_EDGE_FLAG_CLIPPED = (1 << 7),
+ /** Limited to 8 bits, DON'T ADD ANYMORE until improvements on the data structure. */
} eLineartEdgeFlag;
#define LRT_EDGE_FLAG_ALL_TYPE 0x7f
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index f33d16ea693..ac18116cc84 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -40,7 +40,7 @@ struct Image;
struct Ipo;
struct bNodeTree;
-/* WATCH IT: change type? also make changes in ipo.h */
+/* WATCH IT: change type? also make changes in ipo.h */
typedef struct TexPaintSlot {
/** Image to be painted on. */
@@ -149,22 +149,17 @@ typedef struct MaterialLineArt {
/* eMaterialLineArtFlags */
int flags;
- /** transparency_mask is for determining lines behind a glass window material. Only the lower 6
- * bits are used in this variable which allows 6 materials for "transparent mask", because the
- * other two bits when running line art is used to register occlusion effectiveness value so we
- * save 1 byte for each triangle during run time. When loading line art, these bits were shifted
- * to higher 6 bits and reserved 2 bits of space for occlusion_effectiveness.
- */
- unsigned char transparency_mask;
+ /* Used to filter line art occlusion edges */
+ unsigned char material_mask_bits;
- /** bits 1<<0 and 1<<1 are for occlusion effectiveness value (which means 0-3 layers). */
- unsigned char occlusion_effectiveness;
+ /** Maximum 255 levels of equivalent occlusion. */
+ unsigned char mat_occlusion;
unsigned char _pad[2];
} MaterialLineArt;
typedef enum eMaterialLineArtFlags {
- LRT_MATERIAL_TRANSPARENCY_ENABLED = (1 << 0),
+ LRT_MATERIAL_MASK_ENABLED = (1 << 0),
LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS = (1 << 1),
} eMaterialLineArtFlags;
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index 2b9fcaf7603..144e4594c98 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -141,7 +141,7 @@ typedef struct Mesh {
struct MSelect *mselect;
/* BMESH ONLY */
- /*new face structures*/
+ /* New face structures. */
struct MPoly *mpoly;
struct MLoop *mloop;
struct MLoopUV *mloopuv;
@@ -296,7 +296,7 @@ enum {
ME_REMESH_REPROJECT_VERTEX_COLORS = 1 << 8,
ME_DS_EXPAND = 1 << 9,
ME_SCULPT_DYNAMIC_TOPOLOGY = 1 << 10,
- ME_REMESH_SMOOTH_NORMALS = 1 << 11,
+ ME_FLAG_UNUSED_8 = 1 << 11, /* cleared */
ME_REMESH_REPROJECT_PAINT_MASK = 1 << 12,
ME_REMESH_FIX_POLES = 1 << 13,
ME_REMESH_REPROJECT_VOLUME = 1 << 14,
diff --git a/source/blender/makesdna/DNA_meta_types.h b/source/blender/makesdna/DNA_meta_types.h
index a991f654b09..d257363b6ef 100644
--- a/source/blender/makesdna/DNA_meta_types.h
+++ b/source/blender/makesdna/DNA_meta_types.h
@@ -106,7 +106,7 @@ typedef struct MetaBall {
float thresh;
/* used in editmode */
- /*ListBase edit_elems;*/
+ // ListBase edit_elems;
MetaElem *lastelem;
void *batch_cache;
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index c61e940190f..dfe49452636 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -217,7 +217,7 @@ typedef struct LatticeModifierData {
char _pad[2];
} LatticeModifierData;
-/*Lattice modifier flags */
+/* Lattice modifier flags. */
enum {
MOD_LATTICE_INVERT_VGROUP = (1 << 0),
};
@@ -299,13 +299,13 @@ enum {
typedef struct ArrayModifierData {
ModifierData modifier;
- /* the object with which to cap the start of the array */
+ /* the object with which to cap the start of the array. */
struct Object *start_cap;
- /* the object with which to cap the end of the array */
+ /* the object with which to cap the end of the array. */
struct Object *end_cap;
- /* the curve object to use for MOD_ARR_FITCURVE */
+ /* the curve object to use for MOD_ARR_FITCURVE. */
struct Object *curve_ob;
- /* the object to use for object offset */
+ /* the object to use for object offset. */
struct Object *offset_ob;
/* a constant duplicate offset;
* 1 means the duplicates are 1 unit apart
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 12625d3408d..a6de85dd6af 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1357,6 +1357,16 @@ typedef struct NodeSwitch {
uint8_t input_type;
} NodeSwitch;
+typedef struct NodeGeometryCurvePrimitiveBezierSegment {
+ /* GeometryNodeCurvePrimitiveBezierSegmentMode. */
+ uint8_t mode;
+} NodeGeometryCurvePrimitiveBezierSegment;
+
+typedef struct NodeGeometryCurvePrimitiveCircle {
+ /* GeometryNodeCurvePrimitiveMode. */
+ uint8_t mode;
+} NodeGeometryCurvePrimitiveCircle;
+
typedef struct NodeGeometryCurveResample {
/* GeometryNodeCurveSampleMode. */
uint8_t mode;
@@ -1790,6 +1800,11 @@ typedef enum GeometryNodeBooleanOperation {
GEO_NODE_BOOLEAN_DIFFERENCE = 2,
} GeometryNodeBooleanOperation;
+typedef enum GeometryNodeCurvePrimitiveCircleMode {
+ GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS = 0,
+ GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_RADIUS = 1
+} GeometryNodeCurvePrimitiveCircleMode;
+
typedef enum GeometryNodeTriangulateNGons {
GEO_NODE_TRIANGULATE_NGON_BEAUTY = 0,
GEO_NODE_TRIANGULATE_NGON_EARCLIP = 1,
@@ -1889,6 +1904,11 @@ typedef enum GeometryNodeMeshLineCountMode {
GEO_NODE_MESH_LINE_COUNT_RESOLUTION = 1,
} GeometryNodeMeshLineCountMode;
+typedef enum GeometryNodeCurvePrimitiveBezierSegmentMode {
+ GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT_POSITION = 0,
+ GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT_OFFSET = 1,
+} GeometryNodeCurvePrimitiveBezierSegmentMode;
+
typedef enum GeometryNodeCurveSampleMode {
GEO_NODE_CURVE_SAMPLE_COUNT = 0,
GEO_NODE_CURVE_SAMPLE_LENGTH = 1,
diff --git a/source/blender/makesdna/DNA_object_fluidsim_types.h b/source/blender/makesdna/DNA_object_fluidsim_types.h
index b8848ccc458..1198983c898 100644
--- a/source/blender/makesdna/DNA_object_fluidsim_types.h
+++ b/source/blender/makesdna/DNA_object_fluidsim_types.h
@@ -44,7 +44,7 @@ typedef struct FluidsimSettings {
char _pad1[4];
/* domain, fluid or obstacle */
short type;
- /* display advanced options in fluid sim tab (on=1, off=0)*/
+ /* Display advanced options in fluid sim tab (on=1, off=0). */
short show_advancedoptions;
/* domain object settings */
diff --git a/source/blender/makesdna/DNA_object_force_types.h b/source/blender/makesdna/DNA_object_force_types.h
index 3d8418fb734..fcaac4ded76 100644
--- a/source/blender/makesdna/DNA_object_force_types.h
+++ b/source/blender/makesdna/DNA_object_force_types.h
@@ -279,7 +279,7 @@ typedef struct SoftBody {
/* ---------------------------------------------------- */
float secondspring;
- /* self collision*/
+ /* Self collision. */
/** Fixed collision ball size if > 0. */
float colball;
/** Cooling down collision response. */
@@ -319,7 +319,7 @@ typedef struct SoftBody {
/* pd->flag: various settings */
#define PFIELD_USEMAX (1 << 0)
-/*#define PDEFLE_DEFORM (1 << 1)*/ /*UNUSED*/
+// #define PDEFLE_DEFORM (1 << 1) /* UNUSED */
/** TODO: do_versions for below */
#define PFIELD_GUIDE_PATH_ADD (1 << 2)
/** used for do_versions */
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 9951bdefbbb..26a1bea4b3a 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -66,7 +66,7 @@ typedef struct bDeformGroup {
char flag, _pad0[7];
} bDeformGroup;
-/* Face Maps*/
+/* Face Maps. */
typedef struct bFaceMap {
struct bFaceMap *next, *prev;
/** MAX_VGROUP_NAME. */
@@ -335,12 +335,6 @@ typedef struct Object {
*/
float imat[4][4];
- /* Previously 'imat' was used at render time, but as other places use it too
- * the interactive ui of 2.5 creates problems. So now only 'imat_ren' should
- * be used when ever the inverse of ob->obmat * re->viewmat is needed! - jahka
- */
- float imat_ren[4][4];
-
/** Copy of Base's layer in the scene. */
unsigned int lay DNA_DEPRECATED;
@@ -476,7 +470,7 @@ typedef struct ObHook {
/* **************** OBJECT ********************* */
-/* used many places... should be specialized */
+/* used many places, should be specialized. */
#define SELECT 1
#define OBJECT_ACTIVE_MODIFIER_NONE -1
@@ -608,9 +602,9 @@ enum {
/* OB_DRAWIMAGE = 1 << 4, */ /* UNUSED */
/* for solid+wire display */
OB_DRAWWIRE = 1 << 5,
- /* for overdraw s*/
+ /* For overdrawing. */
OB_DRAW_IN_FRONT = 1 << 6,
- /* enable transparent draw */
+ /* Enable transparent draw. */
OB_DRAWTRANSP = 1 << 7,
OB_DRAW_ALL_EDGES = 1 << 8, /* only for meshes currently */
OB_DRAW_NO_SHADOW_CAST = 1 << 9,
@@ -646,9 +640,9 @@ enum {
OB_BOUND_SPHERE = 1,
OB_BOUND_CYLINDER = 2,
OB_BOUND_CONE = 3,
- /* OB_BOUND_TRIANGLE_MESH = 4, */ /* UNUSED */
- /* OB_BOUND_CONVEX_HULL = 5, */ /* UNUSED */
- /* OB_BOUND_DYN_MESH = 6, */ /*UNUSED*/
+ // OB_BOUND_TRIANGLE_MESH = 4, /* UNUSED */
+ // OB_BOUND_CONVEX_HULL = 5, /* UNUSED */
+ // OB_BOUND_DYN_MESH = 6, /* UNUSED */
OB_BOUND_CAPSULE = 7,
};
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 30b1fbe09d3..0253de9f9d1 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -157,7 +157,7 @@ typedef struct ParticleData {
} ParticleData;
typedef struct SPHFluidSettings {
- /*Particle Fluid*/
+ /* Particle Fluid. */
float radius, spring_k, rest_length;
float plasticity_constant, yield_ratio;
float plasticity_balance, yield_balance;
@@ -479,8 +479,8 @@ enum {
#define PART_HAIR_REGROW 16 /* regrow hair for each frame */
-#define PART_UNBORN 32 /*show unborn particles*/
-#define PART_DIED 64 /*show died particles*/
+#define PART_UNBORN 32 /* Show unborn particles. */
+#define PART_DIED 64 /* Show died particles. */
#define PART_TRAND 128
#define PART_EDISTR 256 /* particle/face from face areas */
@@ -508,7 +508,7 @@ enum {
#define PART_CHILD_EFFECT (1 << 27)
#define PART_CHILD_LONG_HAIR (1 << 28)
-/* #define PART_CHILD_RENDER (1 << 29) */ /*UNUSED*/
+// #define PART_CHILD_RENDER (1 << 29) /* UNUSED */
#define PART_CHILD_GUIDE (1 << 30)
#define PART_SELF_EFFECT (1 << 22)
@@ -565,7 +565,7 @@ typedef enum eParticleShapeFlag {
#define PART_TIME_AUTOSF 1 /* Automatic subframes */
/* part->draw_as */
-/* part->ren_as*/
+/* part->ren_as */
#define PART_DRAW_NOT 0
#define PART_DRAW_DOT 1
#define PART_DRAW_HALO 1
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 0b07b8271a5..d40de4184b6 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -241,7 +241,8 @@ typedef struct SceneRenderLayer {
#define SCE_LAY_FRS (1 << 6)
#define SCE_LAY_AO (1 << 7)
#define SCE_LAY_VOLUMES (1 << 8)
-/* flags between (1 << 8) and (1 << 15) are set to 1 already, for future options */
+#define SCE_LAY_MOTION_BLUR (1 << 9)
+/* flags between (1 << 9) and (1 << 15) are set to 1 already, for future options */
#define SCE_LAY_ALL_Z (1 << 15)
/* #define SCE_LAY_XOR (1 << 16) */ /* UNUSED */
@@ -699,7 +700,8 @@ typedef struct RenderData {
float frs_sec_base;
/**
- * Value used to define filter size for all filter options */
+ * Value used to define filter size for all filter options.
+ */
float gauss;
/* color management settings - color profiles, gamma correction, etc */
@@ -1334,6 +1336,12 @@ typedef struct MeshStatVis {
typedef struct SequencerToolSettings {
/* eSeqImageFitMethod */
int fit_method;
+ short snap_mode;
+ short snap_flag;
+ int _pad0;
+ /** When there are many snap points, 0-1 range corresponds to resolution from boundbox to all
+ * possible snap points. */
+ int snap_distance;
} SequencerToolSettings;
typedef enum eSeqImageFitMethod {
@@ -2037,6 +2045,7 @@ enum {
#define SCE_SNAP_NO_SELF (1 << 4)
#define SCE_SNAP_ABS_GRID (1 << 5)
#define SCE_SNAP_BACKFACE_CULLING (1 << 6)
+#define SCE_SNAP_SEQ (1 << 7)
/** #ToolSettings.snap_target */
#define SCE_SNAP_TARGET_CLOSEST 0
@@ -2049,15 +2058,26 @@ enum {
#define SCE_SNAP_MODE_EDGE (1 << 1)
#define SCE_SNAP_MODE_FACE (1 << 2)
#define SCE_SNAP_MODE_VOLUME (1 << 3)
-#define SCE_SNAP_MODE_INCREMENT (1 << 4)
-#define SCE_SNAP_MODE_EDGE_MIDPOINT (1 << 5)
-#define SCE_SNAP_MODE_EDGE_PERPENDICULAR (1 << 6)
+#define SCE_SNAP_MODE_EDGE_MIDPOINT (1 << 4)
+#define SCE_SNAP_MODE_EDGE_PERPENDICULAR (1 << 5)
+
+/** #SequencerToolSettings.snap_mode */
+#define SEQ_SNAP_TO_STRIPS (1 << 0)
+#define SEQ_SNAP_TO_CURRENT_FRAME (1 << 1)
+#define SEQ_SNAP_TO_STRIP_HOLD (1 << 2)
+
+/** #SequencerToolSettings.snap_flag */
+#define SEQ_SNAP_IGNORE_MUTED (1 << 0)
+#define SEQ_SNAP_IGNORE_SOUND (1 << 1)
/** #ToolSettings.snap_node_mode */
-#define SCE_SNAP_MODE_NODE_X (1 << 5)
-#define SCE_SNAP_MODE_NODE_Y (1 << 6)
+#define SCE_SNAP_MODE_NODE_X (1 << 0)
+#define SCE_SNAP_MODE_NODE_Y (1 << 1)
-/** #ToolSettings.snap_mode and #ToolSettings.snap_node_mode */
+/**
+ * #ToolSettings.snap_mode and #ToolSettings.snap_node_mode
+ */
+#define SCE_SNAP_MODE_INCREMENT (1 << 6)
#define SCE_SNAP_MODE_GRID (1 << 7)
/** #ToolSettings.snap_transform_mode_flag */
@@ -2256,7 +2276,7 @@ enum {
#define UVCALC_NO_ASPECT_CORRECT (1 << 1)
/** Adjust UV's while transforming with Vert or Edge Slide. */
#define UVCALC_TRANSFORM_CORRECT_SLIDE (1 << 2)
-/** Use mesh data after subsurf to compute UVs*/
+/** Use mesh data after subsurf to compute UV's. */
#define UVCALC_USESUBSURF (1 << 3)
/** adjust UV's while transforming to avoid distortion */
#define UVCALC_TRANSFORM_CORRECT (1 << 4)
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 8d3ac3a7814..ce25f8e40b7 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -567,8 +567,8 @@ enum {
PNL_SELECT = (1 << 0),
PNL_UNUSED_1 = (1 << 1), /* Cleared */
PNL_CLOSED = (1 << 2),
- /* PNL_TABBED = (1 << 3), */ /*UNUSED*/
- /* PNL_OVERLAP = (1 << 4), */ /*UNUSED*/
+ // PNL_TABBED = (1 << 3), /* UNUSED */
+ // PNL_OVERLAP = (1 << 4), /* UNUSED */
PNL_PIN = (1 << 5),
PNL_POPOVER = (1 << 6),
/** The panel has been drag-drop reordered and the instanced panel list needs to be rebuilt. */
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 59b153397c1..1bd4c9233e3 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -545,8 +545,8 @@ enum {
/* convenience define for all selection flags */
#define SEQ_ALLSEL (SELECT + SEQ_LEFTSEL + SEQ_RIGHTSEL)
-/* deprecated, don't use a flag anymore*/
-/*#define SEQ_ACTIVE 1048576*/
+/* Deprecated, don't use a flag anymore. */
+// #define SEQ_ACTIVE 1048576
#define SEQ_COLOR_BALANCE_INVERSE_GAIN 1
#define SEQ_COLOR_BALANCE_INVERSE_GAMMA 2
diff --git a/source/blender/makesdna/DNA_shader_fx_types.h b/source/blender/makesdna/DNA_shader_fx_types.h
index 84b80310918..01e3b3a5230 100644
--- a/source/blender/makesdna/DNA_shader_fx_types.h
+++ b/source/blender/makesdna/DNA_shader_fx_types.h
@@ -93,7 +93,7 @@ typedef struct BlurShaderFxData {
int flag;
/** Number of samples. */
int samples;
- /** Rotation of blur effect. */
+ /** Rotation of blur effect. */
float rotation;
char _pad[4];
@@ -149,7 +149,7 @@ typedef struct GlowShaderFxData {
int mode;
float blur[2];
int samples;
- /** Rotation of effect. */
+ /** Rotation of effect. */
float rotation;
/** Blend modes. */
int blend_mode;
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 7804ece9769..5ee96497bd5 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -338,8 +338,9 @@ typedef enum eSpaceOutliner_Filter {
SO_FILTER_OB_STATE_SELECTED = (1 << 15), /* Not set via DNA. */
SO_FILTER_OB_STATE_ACTIVE = (1 << 16), /* Not set via DNA. */
SO_FILTER_NO_COLLECTION = (1 << 17),
+ SO_FILTER_NO_VIEW_LAYERS = (1 << 18),
- SO_FILTER_ID_TYPE = (1 << 18),
+ SO_FILTER_ID_TYPE = (1 << 19),
} eSpaceOutliner_Filter;
#define SO_FILTER_OB_TYPE \
@@ -352,7 +353,7 @@ typedef enum eSpaceOutliner_Filter {
#define SO_FILTER_ANY \
(SO_FILTER_NO_OB_CONTENT | SO_FILTER_NO_CHILDREN | SO_FILTER_OB_TYPE | SO_FILTER_OB_STATE | \
- SO_FILTER_NO_COLLECTION | SO_FILTER_NO_LIB_OVERRIDE)
+ SO_FILTER_NO_COLLECTION | SO_FILTER_NO_VIEW_LAYERS | SO_FILTER_NO_LIB_OVERRIDE)
/* SpaceOutliner.filter_state */
typedef enum eSpaceOutliner_StateFilter {
@@ -1019,7 +1020,7 @@ typedef enum eFileSel_File_Types {
FILE_TYPE_COLLADA = (1 << 13),
/** from filter_glob operator property */
FILE_TYPE_OPERATOR = (1 << 14),
- FILE_TYPE_APPLICATIONBUNDLE = (1 << 15),
+ FILE_TYPE_BUNDLE = (1 << 15),
FILE_TYPE_ALEMBIC = (1 << 16),
/** For all kinds of recognized import/export formats. No need for specialized types. */
FILE_TYPE_OBJECT_IO = (1 << 17),
@@ -1042,82 +1043,25 @@ typedef enum eDirEntry_SelectFlag {
/* ***** Related to file browser, but never saved in DNA, only here to help with RNA. ***** */
-/**
- * About Unique identifier.
- *
- * Stored in a CustomProps once imported.
- * Each engine is free to use it as it likes - it will be the only thing passed to it by blender to
- * identify asset/variant/version (concatenating the three into a single 48 bytes one).
- * Assumed to be 128bits, handled as four integers due to lack of real bytes proptype in RNA :|.
- */
-#define ASSET_UUID_LENGTH 16
-
-/* Used to communicate with asset engines outside of 'import' context. */
-#
-#
-typedef struct AssetUUID {
- int uuid_asset[4];
- int uuid_variant[4];
- int uuid_revision[4];
-} AssetUUID;
-
-#
-#
-typedef struct AssetUUIDList {
- AssetUUID *uuids;
- int nbr_uuids;
- char _pad[4];
-} AssetUUIDList;
-
-/* Container for a revision, only relevant in asset context. */
-#
-#
-typedef struct FileDirEntryRevision {
- struct FileDirEntryRevision *next, *prev;
-
- char *comment;
- void *_pad;
-
- int uuid[4];
-
- uint64_t size;
- int64_t time;
- /* Temp caching of UI-generated strings... */
- char size_str[16];
- char datetime_str[16 + 8];
-} FileDirEntryRevision;
-
-/* Container for a variant, only relevant in asset context.
- * In case there are no variants, a single one shall exist, with NULL name/description. */
-#
-#
-typedef struct FileDirEntryVariant {
- struct FileDirEntryVariant *next, *prev;
-
- int uuid[4];
- char *name;
- char *description;
-
- ListBase revisions;
- int nbr_revisions;
- int act_revision;
-} FileDirEntryVariant;
-
-/* Container for mere direntry, with additional asset-related data. */
#
#
typedef struct FileDirEntry {
struct FileDirEntry *next, *prev;
- int uuid[4];
+ uint32_t uid; /* FileUID */
/* Name needs freeing if FILE_ENTRY_NAME_FREE is set. Otherwise this is a direct pointer to a
* name buffer. */
char *name;
char *description;
- /* Either point to active variant/revision if available, or own entry
- * (in mere filebrowser case). */
- FileDirEntryRevision *entry;
+ uint64_t size;
+ int64_t time;
+
+ struct {
+ /* Temp caching of UI-generated strings. */
+ char size_str[16];
+ char datetime_str[16 + 8];
+ } draw_data;
/** #eFileSel_File_Types. */
int typeflag;
@@ -1140,32 +1084,16 @@ typedef struct FileDirEntry {
/* The icon_id for the preview image. */
int preview_icon_id;
- /* Tags are for info only, most of filtering is done in asset engine. */
- char **tags;
- int nbr_tags;
-
- short status;
short flags;
/* eFileAttributes defined in BLI_fileops.h */
int attributes;
-
- ListBase variants;
- int nbr_variants;
- int act_variant;
} FileDirEntry;
/**
- * Array of direntries.
- *
- * This struct is used in various, different contexts.
- *
- * In Filebrowser UI, it stores the total number of available entries, the number of visible
- * (filtered) entries, and a subset of those in 'entries' ListBase, from idx_start (included)
- * to idx_end (excluded).
+ * Array of directory entries.
*
- * In AssetEngine context (i.e. outside of 'browsing' context), entries contain all needed data,
- * there is no filtering, so nbr_entries_filtered, entry_idx_start and entry_idx_end
- * should all be set to -1.
+ * Stores the total number of available entries, the number of visible (filtered) entries, and a
+ * subset of those in 'entries' ListBase, from idx_start (included) to idx_end (excluded).
*/
#
#
@@ -1179,14 +1107,6 @@ typedef struct FileDirEntryArr {
char root[1024];
} FileDirEntryArr;
-#if 0 /* UNUSED */
-/* FileDirEntry.status */
-enum {
- ASSET_STATUS_LOCAL = 1 << 0, /* If active uuid is available locally/immediately. */
- ASSET_STATUS_LATEST = 1 << 1, /* If active uuid is latest available version. */
-};
-#endif
-
/* FileDirEntry.flags */
enum {
FILE_ENTRY_INVALID_PREVIEW = 1 << 0, /* The preview for this entry could not be generated. */
@@ -1806,8 +1726,8 @@ typedef enum eSpaceClip_Flag {
/* SpaceClip.mode */
typedef enum eSpaceClip_Mode {
SC_MODE_TRACKING = 0,
- /*SC_MODE_RECONSTRUCTION = 1,*/ /* DEPRECATED */
- /*SC_MODE_DISTORTION = 2,*/ /* DEPRECATED */
+ // SC_MODE_RECONSTRUCTION = 1, /* DEPRECATED */
+ // SC_MODE_DISTORTION = 2, /* DEPRECATED */
SC_MODE_MASKEDIT = 3,
} eSpaceClip_Mode;
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index 0e673aaec66..fb2d985d353 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -78,9 +78,9 @@ typedef struct MovieTrackingCamera {
float nuke_k1, nuke_k2;
/* Brown-Conrady distortion model coefficients */
- /** Brown-Conrady radial distortion **/
+ /** Brown-Conrady radial distortion. */
float brown_k1, brown_k2, brown_k3, brown_k4;
- /** Brown-Conrady tangential distortion **/
+ /** Brown-Conrady tangential distortion. */
float brown_p1, brown_p2;
} MovieTrackingCamera;
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 61d2c04d98b..7abd960c467 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -496,7 +496,7 @@ typedef struct bTheme {
/* 20 sets of bone colors for this theme */
ThemeWireColor tarm[20];
- /*ThemeWireColor tobj[20];*/
+ // ThemeWireColor tobj[20];
/* See COLLECTION_COLOR_TOT for the number of collection colors. */
ThemeCollectionColor collection_color[8];
@@ -1146,8 +1146,10 @@ typedef enum eAutokey_Mode {
/* AUTOKEY_ON is a bitflag */
AUTOKEY_ON = 1,
- /** AUTOKEY_ON + 2**n... (i.e. AUTOKEY_MODE_NORMAL = AUTOKEY_ON + 2)
- * to preserve setting, even when autokey turned off */
+ /**
+ * AUTOKEY_ON + 2**n... (i.e. AUTOKEY_MODE_NORMAL = AUTOKEY_ON + 2)
+ * to preserve setting, even when auto-key turned off.
+ */
AUTOKEY_MODE_NORMAL = 3,
AUTOKEY_MODE_EDITKEYS = 5,
} eAutokey_Mode;
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 3b35b527584..80de5ae3b7c 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -548,7 +548,7 @@ enum {
V3D_OVERLAY_EDIT_INDICES = (1 << 19),
/* Deprecated. */
- /* V3D_OVERLAY_EDIT_CU_HANDLES = (1 << 20), */
+ // V3D_OVERLAY_EDIT_CU_HANDLES = (1 << 20),
V3D_OVERLAY_EDIT_CU_NORMALS = (1 << 21),
};
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 59091fec4b8..e4df420fb34 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -366,7 +366,7 @@ typedef struct wmKeyMapItem {
short type;
/** KM_ANY, KM_PRESS, KM_NOTHING etc. */
short val;
- /** Oskey is apple or windowskey, value denotes order of pressed. */
+ /** `oskey` also known as apple, windows-key or super, value denotes order of pressed. */
short shift, ctrl, alt, oskey;
/** Raw-key modifier. */
short keymodifier;
diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c
index 2d55ea05867..03f7dbf6489 100644
--- a/source/blender/makesdna/intern/dna_defaults.c
+++ b/source/blender/makesdna/intern/dna_defaults.c
@@ -315,6 +315,7 @@ SDNA_DEFAULT_DECL_STRUCT(TextureGpencilModifierData);
SDNA_DEFAULT_DECL_STRUCT(ThickGpencilModifierData);
SDNA_DEFAULT_DECL_STRUCT(TimeGpencilModifierData);
SDNA_DEFAULT_DECL_STRUCT(TintGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(WeightGpencilModifierData);
SDNA_DEFAULT_DECL_STRUCT(LineartGpencilModifierData);
SDNA_DEFAULT_DECL_STRUCT(LengthGpencilModifierData);
@@ -541,6 +542,7 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
SDNA_DEFAULT_DECL(ThickGpencilModifierData),
SDNA_DEFAULT_DECL(TimeGpencilModifierData),
SDNA_DEFAULT_DECL(TintGpencilModifierData),
+ SDNA_DEFAULT_DECL(WeightGpencilModifierData),
SDNA_DEFAULT_DECL(LineartGpencilModifierData),
SDNA_DEFAULT_DECL(LengthGpencilModifierData),
};
diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h
index 84120a54da4..735be0c10bf 100644
--- a/source/blender/makesdna/intern/dna_rename_defs.h
+++ b/source/blender/makesdna/intern/dna_rename_defs.h
@@ -134,3 +134,6 @@ DNA_STRUCT_RENAME_ELEM(RigidBodyWorld, steps_per_second, substeps_per_frame)
* global_areas. See D9442. */
DNA_STRUCT_RENAME_ELEM(wmWindow, global_area_map, global_areas)
DNA_STRUCT_RENAME_ELEM(LineartGpencilModifierData, line_types, edge_types)
+DNA_STRUCT_RENAME_ELEM(LineartGpencilModifierData, transparency_flags, mask_switches)
+DNA_STRUCT_RENAME_ELEM(LineartGpencilModifierData, transparency_mask, material_mask_bits)
+DNA_STRUCT_RENAME_ELEM(MaterialLineArt, transparency_mask, material_mask_bits)
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index e6b4ae97355..24cfc1d84f6 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -60,8 +60,8 @@
#define SDNA_MAX_FILENAME_LENGTH 255
-/* Included the path relative from /source/blender/ here, so we can move */
-/* headers around with more freedom. */
+/* Included the path relative from /source/blender/ here,
+ * so we can move headers around with more freedom. */
static const char *includefiles[] = {
/* if you add files here, please add them at the end
* of makesdna.c (this file) as well */
@@ -506,7 +506,7 @@ static int add_name(const char *str)
buf[i + 2] = ')';
buf[i + 3] = 0;
}
- /* now proceed with buf*/
+ /* Now proceed with buf. */
DEBUG_PRINTF(3, "\t\t\t\t\tProposing fp name %s\n", buf);
name = buf;
}
@@ -1212,8 +1212,8 @@ static int make_structDNA(const char *base_directory,
add_type("ushort", 2); /* SDNA_TYPE_USHORT */
add_type("int", 4); /* SDNA_TYPE_INT */
- /* note, long isn't supported,
- * these are place-holders to maintain alignment with eSDNA_Type*/
+ /* NOTE: long isn't supported,
+ * these are place-holders to maintain alignment with #eSDNA_Type. */
add_type("long", 4); /* SDNA_TYPE_LONG */
add_type("ulong", 4); /* SDNA_TYPE_ULONG */
@@ -1227,17 +1227,17 @@ static int make_structDNA(const char *base_directory,
/* the defines above shouldn't be output in the padding file... */
const int firststruct = types_len;
- /* add all include files defined in the global array */
- /* Since the internal file+path name buffer has limited length, I do a */
- /* little test first... */
- /* Mind the breaking condition here! */
+ /* Add all include files defined in the global array.
+ * Since the internal file+path name buffer has limited length,
+ * I do a little test first...
+ * Mind the breaking condition here! */
DEBUG_PRINTF(0, "\tStart of header scan:\n");
int header_count = 0;
for (int i = 0; *(includefiles[i]) != '\0'; i++) {
header_count++;
- /* str contains filenames. Since we now include paths, I stretched */
- /* it a bit. Hope this is enough :) -nzc- */
+ /* NOTE(nzc): `str` contains filenames.
+ * Since we now include paths, I stretched it a bit. Hope this is enough :). */
char str[SDNA_MAX_FILENAME_LENGTH];
sprintf(str, "%s%s", base_directory, includefiles[i]);
DEBUG_PRINTF(0, "\t|-- Converting %s\n", str);
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index c691eb3b534..876229411e0 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -1358,9 +1358,9 @@ int RNA_parameter_flag(PropertyRNA *prop);
ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *ptr, FunctionRNA *func);
void RNA_parameter_list_free(ParameterList *parms);
-int RNA_parameter_list_size(ParameterList *parms);
-int RNA_parameter_list_arg_count(ParameterList *parms);
-int RNA_parameter_list_ret_count(ParameterList *parms);
+int RNA_parameter_list_size(const ParameterList *parms);
+int RNA_parameter_list_arg_count(const ParameterList *parms);
+int RNA_parameter_list_ret_count(const ParameterList *parms);
void RNA_parameter_list_begin(ParameterList *parms, ParameterIterator *iter);
void RNA_parameter_list_next(ParameterIterator *iter);
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 17396a6a000..96604b8a5fe 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -555,7 +555,7 @@ typedef struct ParameterList {
typedef struct ParameterIterator {
struct ParameterList *parms;
- /* PointerRNA funcptr; */ /*UNUSED*/
+ // PointerRNA funcptr; /* UNUSED */
void *data;
int size, offset;
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index a75921859cb..5bf16baa1e8 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -114,7 +114,7 @@ static void rna_generate_static_parameter_prototypes(FILE *f,
static int replace_if_different(const char *tmpfile, const char *dep_files[])
{
- /* return 0; */ /* use for testing had edited rna */
+ /* return 0; */ /* use for testing had edited rna */
#define REN_IF_DIFF \
{ \
@@ -641,7 +641,7 @@ static char *rna_def_property_get_func(
return NULL;
}
- /* typecheck, */
+ /* Type check. */
if (dp->dnatype && *dp->dnatype) {
if (prop->type == PROP_FLOAT) {
@@ -3083,7 +3083,7 @@ static void rna_auto_types(void)
PropertyDefRNA *dp;
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
- /* DNA name for Screen is patched in 2.5, we do the reverse here .. */
+ /* DNA name for Screen is patched in 2.5, we do the reverse here. */
if (ds->dnaname) {
if (STREQ(ds->dnaname, "Screen")) {
ds->dnaname = "bScreen";
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index edcfcd130f7..840da76403a 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -3681,7 +3681,7 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
}
if (prop->flag & PROP_IDPROPERTY) {
/* XXX temporary hack to add it automatically, reading should
- * never do any write ops, to ensure thread safety etc .. */
+ * never do any write ops, to ensure thread safety etc. */
RNA_property_pointer_add(ptr, prop);
return RNA_property_pointer_get(ptr, prop);
}
@@ -3766,16 +3766,16 @@ void RNA_property_pointer_set(PointerRNA *ptr,
PointerRNA RNA_property_pointer_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop))
{
- /*PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop; */
+ // PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
- /* BLI_assert(RNA_property_type(prop) == PROP_POINTER); */
+ // BLI_assert(RNA_property_type(prop) == PROP_POINTER);
return PointerRNA_NULL; /* FIXME: there has to be a way... */
}
void RNA_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop)
{
- /*IDProperty *idprop;*/
+ // IDProperty *idprop;
BLI_assert(RNA_property_type(prop) == PROP_POINTER);
@@ -3960,7 +3960,7 @@ static bool property_collection_liboverride_editable(PointerRNA *ptr,
if (!is_liboverride) {
/* We return True also for linked data, as it allows tricks like py scripts 'overriding' data
- * of those.*/
+ * of those. */
return true;
}
@@ -4005,7 +4005,7 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA
item->flag |= IDP_FLAG_OVERRIDELIBRARY_LOCAL;
}
IDP_AppendArray(idprop, item);
- /* IDP_AppendArray does a shallow copy (memcpy), only free memory */
+ /* IDP_AppendArray does a shallow copy (memcpy), only free memory. */
/* IDP_FreePropertyContent(item); */
MEM_freeN(item);
rna_idproperty_touch(idprop);
@@ -4565,8 +4565,8 @@ static int rna_raw_access(ReportList *reports,
return 1;
}
- /* could also be faster with non-matching types,
- * for now we just do slower loop .. */
+ /* Could also be faster with non-matching types,
+ * for now we just do slower loop. */
}
}
@@ -5184,7 +5184,7 @@ static bool rna_path_parse_array_index(const char **path,
/* location.x || scale.X, single dimension arrays only */
token = rna_path_token(path, fixedbuf, sizeof(fixedbuf), 0);
if (token == NULL) {
- /* invalid syntax blah.. */
+ /* invalid syntax blah. */
return false;
}
temp_index = RNA_property_array_item_index(prop, *token);
@@ -7357,17 +7357,17 @@ void RNA_parameter_list_free(ParameterList *parms)
parms->func = NULL;
}
-int RNA_parameter_list_size(ParameterList *parms)
+int RNA_parameter_list_size(const ParameterList *parms)
{
return parms->alloc_size;
}
-int RNA_parameter_list_arg_count(ParameterList *parms)
+int RNA_parameter_list_arg_count(const ParameterList *parms)
{
return parms->arg_count;
}
-int RNA_parameter_list_ret_count(ParameterList *parms)
+int RNA_parameter_list_ret_count(const ParameterList *parms)
{
return parms->ret_count;
}
@@ -7375,7 +7375,7 @@ int RNA_parameter_list_ret_count(ParameterList *parms)
void RNA_parameter_list_begin(ParameterList *parms, ParameterIterator *iter)
{
/* may be useful but unused now */
- /* RNA_pointer_create(NULL, &RNA_Function, parms->func, &iter->funcptr); */ /*UNUSED*/
+ // RNA_pointer_create(NULL, &RNA_Function, parms->func, &iter->funcptr); /* UNUSED */
iter->parms = parms;
iter->parm = parms->func->cont.properties.first;
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index 39e7774e5a4..c84ef1a6587 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -748,7 +748,7 @@ bool RNA_struct_override_matches(Main *bmain,
const char *prop_name = prop_local.identifier;
const size_t prop_name_len = strlen(prop_name);
- /* Inlined building, much much more efficient. */
+ /* Inlined building (significantly more efficient). */
if (!prop_local.is_idprop) {
rna_path_len = root_path_len + 1 + prop_name_len;
if (rna_path_len >= RNA_PATH_BUFFSIZE) {
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index fb9f5e0292e..2aa09a30c75 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -89,7 +89,7 @@ static void rna_Action_groups_remove(bAction *act, ReportList *reports, PointerR
return;
}
- /* move every one one of the group's F-Curves out into the Action again */
+ /* Move every one of the group's F-Curves out into the Action again. */
for (fcu = agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu = fcn) {
fcn = fcu->next;
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 10f86fe2671..52c25bae45a 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -337,7 +337,7 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain,
RNA_struct_blender_type_set(ksi->rna_ext.srna, ksi);
/* set callbacks */
- /* NOTE: we really should have all of these... */
+ /* NOTE: we really should have all of these... */
ksi->poll = (have_function[0]) ? RKS_POLL_rna_internal : NULL;
ksi->iter = (have_function[1]) ? RKS_ITER_rna_internal : NULL;
ksi->generate = (have_function[2]) ? RKS_GEN_rna_internal : NULL;
@@ -1146,7 +1146,7 @@ static void rna_def_keyingset(BlenderRNA *brna)
RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
RNA_def_property_ui_text(prop, "Description", "A short description of the keying set");
- /* KeyingSetInfo (Type Info) for Builtin Sets only */
+ /* KeyingSetInfo (Type Info) for Builtin Sets only. */
prop = RNA_def_property(srna, "type_info", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "KeyingSetInfo");
RNA_def_property_pointer_funcs(prop, "rna_KeyingSet_typeinfo_get", NULL, NULL, NULL);
diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c
index 95b89e7efe4..fba523c9f89 100644
--- a/source/blender/makesrna/intern/rna_animation_api.c
+++ b/source/blender/makesrna/intern/rna_animation_api.c
@@ -70,7 +70,7 @@ static float rna_AnimData_nla_tweak_strip_time_to_scene(AnimData *adt, float fra
void RNA_api_keyingset(StructRNA *srna)
{
FunctionRNA *func;
- /*PropertyRNA *parm; */
+ // PropertyRNA *parm;
/* validate relative Keying Set (used to ensure paths are ok for context) */
func = RNA_def_function(srna, "refresh", "rna_KeyingSet_context_refresh");
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index f07aae0bb15..b3b0d7d13f7 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -1358,7 +1358,7 @@ static void rna_def_edit_bone(BlenderRNA *brna)
/* calculated and read only, not actual data access */
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_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_flag(prop, PROP_THICK_WRAP); /* no reference to original data */
@@ -1438,7 +1438,7 @@ static void rna_def_armature_edit_bones(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "remove", "rna_Armature_edit_bone_remove");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove an existing bone from the armature");
- /* target to remove*/
+ /* Target to remove. */
parm = RNA_def_pointer(func, "bone", "EditBone", "", "EditBone to remove");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c
index a256002ffc1..b4ea70c33ab 100644
--- a/source/blender/makesrna/intern/rna_attribute.c
+++ b/source/blender/makesrna/intern/rna_attribute.c
@@ -162,6 +162,9 @@ const EnumPropertyItem *rna_enum_attribute_domain_itemf(ID *id, bool *r_free)
const ID_Type id_type = GS(id->name);
int totitem = 0, a;
+ static EnumPropertyItem mesh_vertex_domain_item = {
+ ATTR_DOMAIN_POINT, "POINT", 0, "Vertex", "Attribute per point/vertex"};
+
for (a = 0; rna_enum_attribute_domain_items[a].identifier; a++) {
domain_item = &rna_enum_attribute_domain_items[a];
@@ -175,7 +178,12 @@ const EnumPropertyItem *rna_enum_attribute_domain_itemf(ID *id, bool *r_free)
continue;
}
- RNA_enum_item_add(&item, &totitem, domain_item);
+ if (domain_item->value == ATTR_DOMAIN_POINT && id_type == ID_ME) {
+ RNA_enum_item_add(&item, &totitem, &mesh_vertex_domain_item);
+ }
+ else {
+ RNA_enum_item_add(&item, &totitem, domain_item);
+ }
}
RNA_enum_item_end(&item, &totitem);
diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c
index 3e3452af713..40a64ffccd1 100644
--- a/source/blender/makesrna/intern/rna_boid.c
+++ b/source/blender/makesrna/intern/rna_boid.c
@@ -491,10 +491,12 @@ static void rna_def_boidrule(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "On Land", "Use rule when boid is on land");
RNA_def_property_update(prop, 0, "rna_Boids_reset");
- /*prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); */
- /*RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);*/
- /*RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Expanded); */
- /*RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface"); */
+# if 0
+ prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Expanded);
+ RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface");
+# endif
/* types */
rna_def_boidrule_goal(brna);
diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c
index f48a781cfab..d218f92e639 100644
--- a/source/blender/makesrna/intern/rna_camera.c
+++ b/source/blender/makesrna/intern/rna_camera.c
@@ -758,7 +758,7 @@ void RNA_def_camera(BlenderRNA *brna)
rna_def_camera_background_image(brna);
rna_def_camera_background_images(brna, prop);
- /* Nested Data */
+ /* Nested Data. */
RNA_define_animate_sdna(true);
/* *** Animated *** */
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 54f9a93d90a..39a44d7568a 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -1206,7 +1206,7 @@ static void rna_def_colormanage(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
- /* ** Display Settings ** */
+ /* ** Display Settings ** */
srna = RNA_def_struct(brna, "ColorManagedDisplaySettings", NULL);
RNA_def_struct_path_func(srna, "rna_ColorManagedDisplaySettings_path");
RNA_def_struct_ui_text(
@@ -1222,7 +1222,7 @@ static void rna_def_colormanage(BlenderRNA *brna)
RNA_def_property_update(
prop, NC_WINDOW, "rna_ColorManagedDisplaySettings_display_device_update");
- /* ** View Settings ** */
+ /* ** View Settings ** */
srna = RNA_def_struct(brna, "ColorManagedViewSettings", NULL);
RNA_def_struct_path_func(srna, "rna_ColorManagedViewSettings_path");
RNA_def_struct_ui_text(srna,
@@ -1276,7 +1276,7 @@ static void rna_def_colormanage(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Use Curves", "Use RGB curved for pre-display transformation");
RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
- /* ** Colorspace ** */
+ /* ** Colorspace ** */
srna = RNA_def_struct(brna, "ColorManagedInputColorspaceSettings", NULL);
RNA_def_struct_path_func(srna, "rna_ColorManagedInputColorspaceSettings_path");
RNA_def_struct_ui_text(
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index b363dcd4ba9..28aef635688 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -206,6 +206,7 @@ static const EnumPropertyItem target_space_pchan_items[] = {
"Custom Space",
"The transformation of the target is evaluated relative to a custom object/bone/vertex "
"group"},
+ {0, "", 0, NULL, NULL},
{CONSTRAINT_SPACE_POSE,
"POSE",
0,
@@ -224,6 +225,14 @@ static const EnumPropertyItem target_space_pchan_items[] = {
"Local Space",
"The transformation of the target is evaluated relative to its local "
"coordinate system"},
+ {CONSTRAINT_SPACE_OWNLOCAL,
+ "LOCAL_OWNER_ORIENT",
+ 0,
+ "Local Space (Owner Orientation)",
+ "The transformation of the target bone is evaluated relative to its local coordinate "
+ "system, followed by a correction for the difference in target and owner rest pose "
+ "orientations. When applied as local transform to the owner produces the same global "
+ "motion as the target if the parents are still in rest pose"},
{0, NULL, 0, NULL, NULL},
};
@@ -238,6 +247,7 @@ static const EnumPropertyItem owner_space_pchan_items[] = {
0,
"Custom Space",
"The constraint is applied in local space of a custom object/bone/vertex group"},
+ {0, "", 0, NULL, NULL},
{CONSTRAINT_SPACE_POSE,
"POSE",
0,
@@ -914,7 +924,7 @@ static void rna_def_constrainttarget(BlenderRNA *brna)
RNA_def_property_update(
prop, NC_OBJECT | ND_CONSTRAINT, "rna_ConstraintTarget_dependency_update");
- /* space, flag and type still to do */
+ /* space, flag and type still to do. */
RNA_define_lib_overridable(false);
}
@@ -1624,18 +1634,48 @@ static void rna_def_constraint_transform_like(BlenderRNA *brna)
0,
"Replace",
"Replace the original transformation with copied"},
+ {0, "", 0, NULL, NULL},
+ {TRANSLIKE_MIX_BEFORE_FULL,
+ "BEFORE_FULL",
+ 0,
+ "Before Original (Full)",
+ "Apply copied transformation before original, using simple matrix multiplication as if "
+ "the constraint target is a parent in Full Inherit Scale mode. "
+ "Will create shear when combining rotation and non-uniform scale"},
{TRANSLIKE_MIX_BEFORE,
"BEFORE",
0,
- "Before Original",
- "Apply copied transformation before original, as if the constraint target is a parent. "
- "Scale is handled specially to avoid creating shear"},
+ "Before Original (Aligned)",
+ "Apply copied transformation before original, as if the constraint target is a parent in "
+ "Aligned Inherit Scale mode. This effectively uses Full for location and Split Channels "
+ "for rotation and scale"},
+ {TRANSLIKE_MIX_BEFORE_SPLIT,
+ "BEFORE_SPLIT",
+ 0,
+ "Before Original (Split Channels)",
+ "Apply copied transformation before original, handling location, rotation and scale "
+ "separately, similar to a sequence of three Copy constraints"},
+ {0, "", 0, NULL, NULL},
+ {TRANSLIKE_MIX_AFTER_FULL,
+ "AFTER_FULL",
+ 0,
+ "After Original (Full)",
+ "Apply copied transformation after original, using simple matrix multiplication as if "
+ "the constraint target is a child in Full Inherit Scale mode. "
+ "Will create shear when combining rotation and non-uniform scale"},
{TRANSLIKE_MIX_AFTER,
"AFTER",
0,
- "After Original",
- "Apply copied transformation after original, as if the constraint target is a child. "
- "Scale is handled specially to avoid creating shear"},
+ "After Original (Aligned)",
+ "Apply copied transformation after original, as if the constraint target is a child in "
+ "Aligned Inherit Scale mode. This effectively uses Full for location and Split Channels "
+ "for rotation and scale"},
+ {TRANSLIKE_MIX_AFTER_SPLIT,
+ "AFTER_SPLIT",
+ 0,
+ "After Original (Split Channels)",
+ "Apply copied transformation after original, handling location, rotation and scale "
+ "separately, similar to a sequence of three Copy constraints"},
{0, NULL, 0, NULL, NULL},
};
@@ -1653,6 +1693,12 @@ static void rna_def_constraint_transform_like(BlenderRNA *brna)
RNA_define_lib_overridable(true);
+ prop = RNA_def_property(srna, "remove_target_shear", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", TRANSLIKE_REMOVE_TARGET_SHEAR);
+ RNA_def_property_ui_text(
+ prop, "Remove Target Shear", "Remove shear from the target transformation before combining");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
prop = RNA_def_property(srna, "mix_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mix_mode");
RNA_def_property_enum_items(prop, mix_mode_items);
@@ -2975,7 +3021,7 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
/* direct access to bindings */
/* NOTE: only to be used by experienced users */
prop = RNA_def_property(srna, "joint_bindings", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_array(prop, 32); /* XXX this is the maximum value allowed - why? */
+ RNA_def_property_array(prop, 32); /* XXX this is the maximum value allowed - why? */
RNA_def_property_flag(prop, PROP_DYNAMIC);
RNA_def_property_dynamic_array_funcs(prop, "rna_SplineIKConstraint_joint_bindings_get_length");
RNA_def_property_float_funcs(prop,
diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c
index e6dceb5af72..4079406e64b 100644
--- a/source/blender/makesrna/intern/rna_context.c
+++ b/source/blender/makesrna/intern/rna_context.c
@@ -36,7 +36,7 @@ const EnumPropertyItem rna_enum_context_mode_items[] = {
{CTX_MODE_EDIT_MESH, "EDIT_MESH", 0, "Mesh Edit", ""},
{CTX_MODE_EDIT_CURVE, "EDIT_CURVE", 0, "Curve Edit", ""},
{CTX_MODE_EDIT_SURFACE, "EDIT_SURFACE", 0, "Surface Edit", ""},
- {CTX_MODE_EDIT_TEXT, "EDIT_TEXT", 0, "Edit Edit", ""},
+ {CTX_MODE_EDIT_TEXT, "EDIT_TEXT", 0, "Text Edit", ""},
/* PARSKEL reuse will give issues */
{CTX_MODE_EDIT_ARMATURE, "EDIT_ARMATURE", 0, "Armature Edit", ""},
{CTX_MODE_EDIT_METABALL, "EDIT_METABALL", 0, "Metaball Edit", ""},
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 2a4cd1d934a..299cd2504a8 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -1418,7 +1418,7 @@ static void rna_def_text(BlenderRNA *brna)
static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
- /*PropertyRNA *prop; */
+ // PropertyRNA *prop;
FunctionRNA *func;
PropertyRNA *parm;
@@ -1448,7 +1448,7 @@ static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_curve_spline_bezpoints(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
- /*PropertyRNA *prop; */
+ // PropertyRNA *prop;
FunctionRNA *func;
PropertyRNA *parm;
@@ -1954,14 +1954,14 @@ static void rna_def_curve_nurb(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop = RNA_def_property(srna, "point_count_u", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* Editing this needs knot recalc. */
RNA_def_property_int_sdna(prop, NULL, "pntsu");
RNA_def_property_ui_text(
prop, "Points U", "Total number points for the curve or surface in the U direction");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop = RNA_def_property(srna, "point_count_v", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* Editing this needs knot recalc. */
RNA_def_property_int_sdna(prop, NULL, "pntsv");
RNA_def_property_ui_text(
prop, "Points V", "Total number points for the surface on the V direction");
@@ -2074,7 +2074,7 @@ static void rna_def_curve_nurb(BlenderRNA *brna)
prop = RNA_def_property(srna, "character_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "charidx");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* Editing this needs knot recalc. */
RNA_def_property_ui_text(prop,
"Character Index",
"Location of this character in the text data (only for text curves)");
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 6b0a2b324c3..0c6c3fd9b0a 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -1281,7 +1281,7 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_,
int type,
int subtype)
{
- /*StructRNA *srna = DefRNA.laststruct;*/ /* invalid for python defined props */
+ // StructRNA *srna = DefRNA.laststruct; /* Invalid for Python defined props. */
ContainerRNA *cont = cont_;
ContainerDefRNA *dcont;
PropertyDefRNA *dprop = NULL;
@@ -1351,7 +1351,7 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_,
iprop->hardmin = (subtype == PROP_UNSIGNED) ? 0 : INT_MIN;
iprop->hardmax = INT_MAX;
- iprop->softmin = (subtype == PROP_UNSIGNED) ? 0 : -10000; /* rather arbitrary .. */
+ iprop->softmin = (subtype == PROP_UNSIGNED) ? 0 : -10000; /* rather arbitrary. */
iprop->softmax = 10000;
iprop->step = 1;
break;
@@ -1371,7 +1371,7 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_,
fprop->softmax = fprop->hardmax = 1.0f;
}
else {
- fprop->softmin = (subtype == PROP_UNSIGNED) ? 0.0f : -10000.0f; /* rather arbitrary .. */
+ fprop->softmin = (subtype == PROP_UNSIGNED) ? 0.0f : -10000.0f; /* rather arbitrary. */
fprop->softmax = 10000.0f;
}
fprop->step = 10;
@@ -1670,7 +1670,7 @@ void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int le
memset(prop->arraylength, 0, sizeof(prop->arraylength));
}
- /* TODO make sure arraylength values are sane */
+ /* TODO: make sure `arraylength` values are sane. */
}
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
@@ -2416,7 +2416,7 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const
}
}
- /* SDNA doesn't pass us unsigned unfortunately .. */
+ /* SDNA doesn't pass us unsigned unfortunately. */
if (dp->dnatype && STREQ(dp->dnatype, "char")) {
iprop->hardmin = iprop->softmin = CHAR_MIN;
iprop->hardmax = iprop->softmax = CHAR_MAX;
@@ -2429,7 +2429,7 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const
iprop->hardmin = INT_MIN;
iprop->hardmax = INT_MAX;
- iprop->softmin = -10000; /* rather arbitrary .. */
+ iprop->softmin = -10000; /* rather arbitrary. */
iprop->softmax = 10000;
}
else if (dp->dnatype && STREQ(dp->dnatype, "int8_t")) {
diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c
index 83df997b3d4..0dfd7d74c25 100644
--- a/source/blender/makesrna/intern/rna_dynamicpaint.c
+++ b/source/blender/makesrna/intern/rna_dynamicpaint.c
@@ -226,7 +226,7 @@ static bool rna_DynamicPaint_is_cache_user_get(PointerRNA *ptr)
return (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ) ? 1 : 0;
}
-/* does output layer exist*/
+/* Does output layer exist. */
static bool rna_DynamicPaint_is_output_exists(DynamicPaintSurface *surface, Object *ob, int index)
{
return dynamicPaint_outputLayerExists(surface, ob, index);
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 399f45a2382..f81a806b009 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -61,8 +61,8 @@ const EnumPropertyItem rna_enum_fmodifier_type_items[] = {
"Reshape F-Curve values, e.g. change amplitude of movements"},
{FMODIFIER_TYPE_CYCLES, "CYCLES", 0, "Cycles", "Cyclic extend/repeat keyframe sequence"},
{FMODIFIER_TYPE_NOISE, "NOISE", 0, "Noise", "Add pseudo-random noise on top of F-Curves"},
- /*{FMODIFIER_TYPE_FILTER, "FILTER", 0, "Filter", ""},*/ /* FIXME: not implemented yet! */
- /*{FMODIFIER_TYPE_PYTHON, "PYTHON", 0, "Python", ""},*/ /* FIXME: not implemented yet! */
+ // {FMODIFIER_TYPE_FILTER, "FILTER", 0, "Filter", ""}, /* FIXME: not implemented yet! */
+ // {FMODIFIER_TYPE_PYTHON, "PYTHON", 0, "Python", ""}, /* FIXME: not implemented yet! */
{FMODIFIER_TYPE_LIMITS,
"LIMITS",
0,
@@ -263,8 +263,8 @@ static void rna_DriverTarget_update_data(Main *bmain, Scene *scene, PointerRNA *
fcu->flag &= ~FCURVE_DISABLED;
if (driver) {
- /* FIXME: need to be able to search targets for required one... */
- /*BLI_findindex(&driver->targets, ptr->data) != -1) */
+ /* FIXME: need to be able to search targets for required one. */
+ // BLI_findindex(&driver->targets, ptr->data) != -1)
RNA_pointer_create(ptr->owner_id, &RNA_Driver, driver, &driverptr);
rna_ChannelDriver_update_data(bmain, scene, &driverptr);
}
@@ -584,7 +584,7 @@ static void rna_FCurve_group_set(PointerRNA *ptr,
action_groups_remove_channel(act, fcu);
/* add the F-Curve back to the action now in the right place */
- /* TODO: make the api function handle the case where there isn't any group to assign to */
+ /* TODO: make the api function handle the case where there isn't any group to assign to. */
if (value.data) {
/* add to its group using API function, which makes sure everything goes ok */
action_groups_add_channel(act, value.data, fcu);
@@ -1449,7 +1449,7 @@ static void rna_def_fmodifier_cycles(BlenderRNA *brna)
static void rna_def_fmodifier_python(BlenderRNA *brna)
{
StructRNA *srna;
- /*PropertyRNA *prop; */
+ // PropertyRNA *prop;
srna = RNA_def_struct(brna, "FModifierPython", "FModifier");
RNA_def_struct_ui_text(
@@ -2432,7 +2432,7 @@ static void rna_def_fcurve(BlenderRNA *brna)
prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_MUTED);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
- RNA_def_property_ui_text(prop, "Muted", "Disable F-Curve Modifier evaluation");
+ RNA_def_property_ui_text(prop, "Muted", "Disable F-Curve evaluation");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, "rna_FCurve_update_eval");
prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c
index dab76c84e6a..decdc728bbe 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -1986,7 +1986,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
"e.g. 5*10^-6)");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
- /* mesh options options */
+ /* Mesh options. */
prop = RNA_def_property(srna, "mesh_concave_upper", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, 10.0);
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 19ed5f960cf..21e905cfd2a 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1995,7 +1995,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Opacity", "Layer Opacity");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
- /* layer channel color (grease pencil) */
+ /* Layer channel color (grease pencil). */
prop = RNA_def_property(srna, "channel_color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "color");
RNA_def_property_array(prop, 3);
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 60b2b6cbd20..5b3b06fb3a8 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -93,6 +93,11 @@ const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = {
ICON_MOD_SUBSURF,
"Subdivide",
"Subdivide stroke adding more control points"},
+ {eGpencilModifierType_Weight,
+ "GP_WEIGHT",
+ ICON_MOD_VERTEX_WEIGHT,
+ "Vertex Weight",
+ "Generate Vertex Weights"},
{0, "", 0, N_("Deform"), ""},
{eGpencilModifierType_Armature,
"GP_ARMATURE",
@@ -233,6 +238,8 @@ static StructRNA *rna_GpencilModifier_refine(struct PointerRNA *ptr)
return &RNA_TintGpencilModifier;
case eGpencilModifierType_Time:
return &RNA_TimeGpencilModifier;
+ case eGpencilModifierType_Weight:
+ return &RNA_WeightGpencilModifier;
case eGpencilModifierType_Color:
return &RNA_ColorGpencilModifier;
case eGpencilModifierType_Array:
@@ -331,6 +338,8 @@ RNA_GP_MOD_VGROUP_NAME_SET(Offset, vgname);
RNA_GP_MOD_VGROUP_NAME_SET(Armature, vgname);
RNA_GP_MOD_VGROUP_NAME_SET(Texture, vgname);
RNA_GP_MOD_VGROUP_NAME_SET(Tint, vgname);
+RNA_GP_MOD_VGROUP_NAME_SET(Weight, target_vgname);
+RNA_GP_MOD_VGROUP_NAME_SET(Weight, vgname);
RNA_GP_MOD_VGROUP_NAME_SET(Lineart, vgname);
# undef RNA_GP_MOD_VGROUP_NAME_SET
@@ -363,8 +372,7 @@ static void greasepencil_modifier_object_set(Object *self,
RNA_GP_MOD_OBJECT_SET(Armature, object, OB_ARMATURE);
RNA_GP_MOD_OBJECT_SET(Lattice, object, OB_LATTICE);
RNA_GP_MOD_OBJECT_SET(Mirror, object, OB_EMPTY);
-RNA_GP_MOD_OBJECT_SET(Opacity, object, OB_EMPTY);
-RNA_GP_MOD_OBJECT_SET(Thick, object, OB_EMPTY);
+RNA_GP_MOD_OBJECT_SET(Weight, object, OB_EMPTY);
# undef RNA_GP_MOD_OBJECT_SET
@@ -538,6 +546,16 @@ static void rna_ThickGpencilModifier_material_set(PointerRNA *ptr,
rna_GpencilModifier_material_set(ptr, value, ma_target, reports);
}
+static void rna_WeightGpencilModifier_material_set(PointerRNA *ptr,
+ PointerRNA value,
+ struct ReportList *reports)
+{
+ WeightGpencilModifierData *tmd = (WeightGpencilModifierData *)ptr->data;
+ Material **ma_target = &tmd->material;
+
+ rna_GpencilModifier_material_set(ptr, value, ma_target, reports);
+}
+
static void rna_OffsetGpencilModifier_material_set(PointerRNA *ptr,
PointerRNA value,
struct ReportList *reports)
@@ -701,7 +719,7 @@ static void rna_def_modifier_gpencilnoise(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "UV Factor", "Amount of noise to apply uv rotation");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "random", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_random", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_USE_RANDOM);
RNA_def_property_ui_text(prop, "Random", "Use random values over time");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -1143,35 +1161,9 @@ static void rna_def_modifier_gpencilthick(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Thickness Factor", "Factor to multiply the thickness with");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "use_fading", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_THICK_FADING);
- RNA_def_property_ui_text(prop, "Fading", "Fading effect");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- /* Distance reference object */
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_ui_text(prop, "Object", "Object used as distance reference");
- RNA_def_property_pointer_funcs(prop, NULL, "rna_ThickGpencilModifier_object_set", NULL, NULL);
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
-
- prop = RNA_def_property(srna, "fading_start", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "fading_start");
- RNA_def_property_ui_range(prop, 0, 1000.0, 1.0, 2);
- RNA_def_property_ui_text(prop, "Fading Start", "Start distance of fading effect");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "fading_end", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "fading_end");
- RNA_def_property_ui_range(prop, 0, 1000.0, 1.0, 2);
- RNA_def_property_ui_text(prop, "Fading End", "End distance of fading effect");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "fading_end_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "fading_end_factor");
- RNA_def_property_range(prop, 0.0, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.0, 10.0, 0.1, 3);
- RNA_def_property_ui_text(prop, "End Factor", "Fading end thickness factor");
+ prop = RNA_def_property(srna, "use_weight_factor", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_THICK_WEIGHT_FACTOR);
+ RNA_def_property_ui_text(prop, "Weighted", "Use weight to modulate effect");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE);
@@ -1440,6 +1432,11 @@ static void rna_def_modifier_gpenciltint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Strength", "Factor for tinting");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+ prop = RNA_def_property(srna, "use_weight_factor", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TINT_WEIGHT_FACTOR);
+ RNA_def_property_ui_text(prop, "Weighted", "Use weight to modulate effect");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "radius");
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
@@ -1726,35 +1723,9 @@ static void rna_def_modifier_gpencilopacity(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Hardness", "Factor of stroke hardness");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "use_fading", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OPACITY_FADING);
- RNA_def_property_ui_text(prop, "Fading", "Fading effect");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- /* Distance reference object */
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_ui_text(prop, "Object", "Object used as distance reference");
- RNA_def_property_pointer_funcs(prop, NULL, "rna_OpacityGpencilModifier_object_set", NULL, NULL);
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
-
- prop = RNA_def_property(srna, "fading_start", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "fading_start");
- RNA_def_property_ui_range(prop, 0, 1000.0, 1.0, 2);
- RNA_def_property_ui_text(prop, "Fading Start", "Start distance of fading effect");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "fading_end", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "fading_end");
- RNA_def_property_ui_range(prop, 0, 1000.0, 1.0, 2);
- RNA_def_property_ui_text(prop, "Fading End", "End distance of fading effect");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "fading_end_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "fading_end_factor");
- RNA_def_property_range(prop, 0.0, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.0, 10.0, 0.1, 3);
- RNA_def_property_ui_text(prop, "End Factor", "Fading end thickness factor");
+ prop = RNA_def_property(srna, "use_weight_factor", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OPACITY_WEIGHT_FACTOR);
+ RNA_def_property_ui_text(prop, "Weighted", "Use weight to modulate effect");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE);
@@ -2733,6 +2704,170 @@ static void rna_def_modifier_gpenciltexture(BlenderRNA *brna)
RNA_define_lib_overridable(false);
}
+static void rna_def_modifier_gpencilweight(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ static const EnumPropertyItem mode_items[] = {
+ {GP_WEIGHT_MODE_DISTANCE,
+ "DISTANCE",
+ 0,
+ "Distance",
+ "Calculate weights depending on the distance to the target object"},
+ {GP_WEIGHT_MODE_ANGLE,
+ "ANGLE",
+ 0,
+ "Angle",
+ "Calculate weights depending on the stroke orientation"},
+ {0, NULL, 0, NULL, NULL},
+ };
+ static const EnumPropertyItem axis_items[] = {
+ {0, "X", 0, "X", ""},
+ {1, "Y", 0, "Y", ""},
+ {2, "Z", 0, "Z", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ static const EnumPropertyItem space_items[] = {
+ {GP_SPACE_LOCAL, "LOCAL", 0, "Local Space", ""},
+ {GP_SPACE_WORLD, "WORLD", 0, "World Space", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ srna = RNA_def_struct(brna, "WeightGpencilModifier", "GpencilModifier");
+ RNA_def_struct_ui_text(srna, "Weight Modifier", "Calculate Vertex Weight dynamically");
+ RNA_def_struct_sdna(srna, "WeightGpencilModifierData");
+ RNA_def_struct_ui_icon(srna, ICON_MOD_VERTEX_WEIGHT);
+
+ RNA_define_lib_overridable(true);
+
+ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "mode");
+ RNA_def_property_enum_items(prop, mode_items);
+ RNA_def_property_ui_text(prop, "Mode", "");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "target_vertex_group", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "target_vgname");
+ RNA_def_property_ui_text(prop, "Output", "Output Vertex group");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeightGpencilModifier_target_vgname_set");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "use_blend", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_WEIGHT_BLEND_DATA);
+ RNA_def_property_ui_text(
+ prop, "Blend", "Blend results with existing weights in output weight group");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "use_invert_output", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_WEIGHT_INVERT_OUTPUT);
+ RNA_def_property_ui_text(prop, "Invert", "Invert weight values");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "angle");
+ RNA_def_property_ui_text(prop, "Angle", "Angle");
+ RNA_def_property_range(prop, 0.0f, DEG2RAD(180.0f));
+ RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "axis");
+ RNA_def_property_enum_items(prop, axis_items);
+ RNA_def_property_ui_text(prop, "Axis", "");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "space");
+ RNA_def_property_enum_items(prop, space_items);
+ RNA_def_property_ui_text(prop, "Space", "Coordinates space");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "layername");
+ RNA_def_property_ui_text(prop, "Layer", "Layer name");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_pointer_funcs(prop,
+ NULL,
+ "rna_WeightGpencilModifier_material_set",
+ NULL,
+ "rna_GpencilModifier_material_poll");
+ RNA_def_property_ui_text(prop, "Material", "Material used for filtering effect");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "vgname");
+ RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the deform");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeightGpencilModifier_vgname_set");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ /* Distance reference object */
+ prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Object", "Object used as distance reference");
+ RNA_def_property_pointer_funcs(prop, NULL, "rna_WeightGpencilModifier_object_set", NULL, NULL);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
+
+ prop = RNA_def_property(srna, "distance_start", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "dist_start");
+ RNA_def_property_ui_range(prop, 0, 1000.0, 1.0, 2);
+ RNA_def_property_ui_text(prop, "Distance Start", "Start value for distance calculation");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "minimum_weight", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "min_weight");
+ RNA_def_property_ui_text(prop, "Minimum", "Minimum value for vertex weight");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "distance_end", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "dist_end");
+ RNA_def_property_ui_range(prop, 0, 1000.0, 1.0, 2);
+ RNA_def_property_ui_text(prop, "Distance End", "End value for distance calculation");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "pass_index");
+ RNA_def_property_range(prop, 0, 100);
+ RNA_def_property_ui_text(prop, "Pass", "Pass index");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_WEIGHT_INVERT_LAYER);
+ RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "invert_materials", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_WEIGHT_INVERT_MATERIAL);
+ RNA_def_property_ui_text(prop, "Inverse Materials", "Inverse filter");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_WEIGHT_INVERT_PASS);
+ RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "invert_vertex", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_WEIGHT_INVERT_VGROUP);
+ RNA_def_property_ui_text(prop, "Inverse VertexGroup", "Inverse filter");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "layer_pass");
+ RNA_def_property_range(prop, 0, 100);
+ RNA_def_property_ui_text(prop, "Pass", "Layer pass index");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_WEIGHT_INVERT_LAYERPASS);
+ RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ RNA_define_lib_overridable(false);
+}
+
static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2752,12 +2887,6 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_MOD_EDGESPLIT);
RNA_define_lib_overridable(true);
- prop = RNA_def_property(srna, "use_custom_camera", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_USE_CUSTOM_CAMERA);
- RNA_def_property_ui_text(
- prop, "Use Custom Camera", "Use custom camera instead of the active camera");
- RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
-
prop = RNA_def_property(srna, "use_fuzzy_intersections", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_INTERSECTION_AS_CONTOUR);
RNA_def_property_ui_text(prop,
@@ -2806,28 +2935,20 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "angle_splitting_threshold");
RNA_def_property_ui_text(
prop, "Angle Splitting", "Angle in screen space below which a stroke is split in two");
- /* Don't allow value very close to PI, or we get a lot of small segments.*/
+ /* Don't allow value very close to PI, or we get a lot of small segments. */
RNA_def_property_ui_range(prop, 0.0f, DEG2RAD(179.5f), 0.01f, 1);
RNA_def_property_range(prop, 0.0f, DEG2RAD(180.0f));
RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "smooth_tolerance", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "chain_smooth_tolerance");
- RNA_def_property_ui_text(
- prop, "Smooth Tolerance", "Strength of smoothing applied on jagged chains");
- RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.05f, 4);
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
-
prop = RNA_def_property(srna, "use_remove_doubles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_REMOVE_DOUBLES);
RNA_def_property_ui_text(
prop, "Remove Doubles", "Remove doubles from the source geometry before generating stokes");
RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "floating_as_contour", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_FLOATING_AS_CONTOUR);
- RNA_def_property_ui_text(prop, "Floating As Contour", "Floating edges will have contour type");
+ prop = RNA_def_property(srna, "use_loose_as_contour", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_LOOSE_AS_CONTOUR);
+ RNA_def_property_ui_text(prop, "Loose As Contour", "Loose edges will have contour type");
RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "invert_source_vertex_group", PROP_BOOLEAN, PROP_NONE);
@@ -2843,7 +2964,7 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_face_mark", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_FILTER_FACE_MARK);
RNA_def_property_ui_text(
- prop, "Filter Face Mark", "Filter feature lines using freestyle face mark");
+ prop, "Filter Face Marks", "Filter feature lines using freestyle face marks");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "use_face_mark_invert", PROP_BOOLEAN, PROP_NONE);
@@ -2854,7 +2975,7 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_face_mark_boundaries", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_FILTER_FACE_MARK_BOUNDARIES);
RNA_def_property_ui_text(
- prop, "Boundaries", "Filtering feature lines on face mark boundaries as well");
+ prop, "Boundaries", "Filter feature lines based on face mark boundaries");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "chaining_image_threshold", PROP_FLOAT, PROP_DISTANCE);
@@ -2866,56 +2987,25 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 0.3f);
RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "chain_floating_edges", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_CHAIN_FLOATING_EDGES);
- RNA_def_property_ui_text(
- prop, "Chain Floating Edges", "Allow floating edges to be chained together");
+ prop = RNA_def_property(srna, "use_loose_edge_chain", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_CHAIN_LOOSE_EDGES);
+ RNA_def_property_ui_text(prop, "Chain Loose Edges", "Allow loose edges to be chained together");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "chain_geometry_space", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_geometry_space_chain", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_CHAIN_GEOMETRY_SPACE);
RNA_def_property_ui_text(
prop, "Use Geometry Space", "Use geometry distance for chaining instead of image space");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "use_multiple_edge_types", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_ALLOW_MULTIPLE_EDGE_TYPES);
- RNA_def_property_ui_text(
- prop, "Multiple Edge Types", "Allow edges with muliple types be added for every type");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "offset_towards_custom_camera", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_GPENCIL_OFFSET_TOWARDS_CUSTOM_CAMERA);
+ prop = RNA_def_property(srna, "use_overlap_edge_type_support", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_ALLOW_OVERLAP_EDGE_TYPES);
RNA_def_property_ui_text(prop,
- "Offset Towards Custom Camera",
- "Offset strokes towards selected camera instead of the active camera");
+ "Overlapping Edge Types",
+ "Allow an edge to have multiple overlapping types. This will create a "
+ "separate stroke for each overlapping type");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "stroke_offset", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_ui_text(prop,
- "Stroke Offset",
- "Move strokes slightly towards the camera to avoid clipping while "
- "preserve depth for the viewport");
- RNA_def_property_ui_range(prop, 0.0f, 0.5f, 0.001f, 4);
- RNA_def_property_range(prop, 0.0f, 0.5f);
- RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "source_camera", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
- RNA_def_property_ui_text(
- prop, "Camera Object", "Use specified camera object for generating line art");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
-
- prop = RNA_def_property(srna, "light_contour_object", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
- RNA_def_property_ui_text(
- prop, "Light Object", "Use this light object to generate light contour");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
-
prop = RNA_def_property(srna, "source_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, modifier_lineart_source_type);
RNA_def_property_ui_text(prop, "Source Type", "Line art stroke source type");
@@ -2941,9 +3031,9 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Use Contour", "Generate strokes from contours lines");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "use_floating", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "edge_types", LRT_EDGE_FLAG_FLOATING);
- RNA_def_property_ui_text(prop, "Use Floating", "Generate strokes from floating edges");
+ prop = RNA_def_property(srna, "use_loose", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "edge_types", LRT_EDGE_FLAG_LOOSE);
+ RNA_def_property_ui_text(prop, "Use Loose", "Generate strokes from loose edges");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "use_crease", PROP_BOOLEAN, PROP_NONE);
@@ -2967,13 +3057,6 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Use Intersection", "Generate strokes from intersections");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "use_light_contour", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "edge_types", LRT_EDGE_FLAG_LIGHT_CONTOUR);
- RNA_def_property_ui_text(prop,
- "Use Light Contour",
- "Generate light/shadow separation lines from a reference light object");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
prop = RNA_def_property(srna, "use_multiple_levels", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_multiple_levels", 0);
RNA_def_property_ui_text(
@@ -3047,28 +3130,22 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "use_transparency", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mask_switches", LRT_GPENCIL_TRANSPARENCY_ENABLE);
+ prop = RNA_def_property(srna, "use_material_mask", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mask_switches", LRT_GPENCIL_MATERIAL_MASK_ENABLE);
RNA_def_property_ui_text(
- prop, "Use Transparency", "Use transparency mask from this material in line art");
+ prop, "Use Material Mask", "Use material masks to filter out occluded strokes");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "use_transparency_match", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mask_switches", LRT_GPENCIL_TRANSPARENCY_MATCH);
+ prop = RNA_def_property(srna, "use_material_mask_match", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mask_switches", LRT_GPENCIL_MATERIAL_MASK_MATCH);
RNA_def_property_ui_text(
- prop, "Match Transparency", "Require matching all transparency masks instead of just one");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "use_transparency_mask", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1);
- RNA_def_property_array(prop, 6);
- RNA_def_property_ui_text(prop, "Masks", "");
+ prop, "Match Masks", "Require matching all material masks instead of just one");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "use_intersection_filter", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mask_switches", LRT_GPENCIL_INTERSECTION_FILTER);
- RNA_def_property_ui_text(
- prop, "Flter Intersection", "Filter intersection lines using mask bits");
+ prop = RNA_def_property(srna, "use_material_mask_bits", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "material_mask_bits", 1);
+ RNA_def_property_array(prop, 8);
+ RNA_def_property_ui_text(prop, "Masks", "Mask bits to match from Material Line Art settings");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "use_intersection_match", PROP_BOOLEAN, PROP_NONE);
@@ -3080,7 +3157,7 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_intersection_mask", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "intersection_mask", 1);
RNA_def_property_array(prop, 8);
- RNA_def_property_ui_text(prop, "Masks", "");
+ RNA_def_property_ui_text(prop, "Masks", "Mask bits to match from Collection Line Art settings");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
RNA_define_lib_overridable(false);
@@ -3244,6 +3321,7 @@ void RNA_def_greasepencil_modifier(BlenderRNA *brna)
rna_def_modifier_gpencilarmature(brna);
rna_def_modifier_gpencilmultiply(brna);
rna_def_modifier_gpenciltexture(brna);
+ rna_def_modifier_gpencilweight(brna);
rna_def_modifier_gpencillineart(brna);
rna_def_modifier_gpencillength(brna);
}
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index 245730919b0..0bb452dfb07 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -320,7 +320,7 @@ struct PropertyRNA {
PropArrayLengthGetFunc getlength;
/* dimension of array */
unsigned int arraydimension;
- /* array lengths lengths for all dimensions (when arraydimension > 0) */
+ /* Array lengths for all dimensions (when `arraydimension > 0`). */
unsigned int arraylength[RNA_MAX_ARRAY_DIMENSION];
unsigned int totarraylength;
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index 7fce9b1f908..b4253ab9236 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -604,7 +604,7 @@ void RNA_def_view_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Dependency Graph", "Dependencies in the scene data");
RNA_def_property_pointer_funcs(prop, "rna_ViewLayer_depsgraph_get", NULL, NULL, NULL);
- /* Nested Data */
+ /* Nested Data. */
/* *** Non-Animated *** */
RNA_define_animate_sdna(false);
rna_def_layer_collection(brna);
diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c
index db3e5195c79..24bc5504a58 100644
--- a/source/blender/makesrna/intern/rna_mask.c
+++ b/source/blender/makesrna/intern/rna_mask.c
@@ -396,7 +396,7 @@ static void rna_MaskSplinePoint_handle_right_type_set(PointerRNA *ptr, int value
BKE_mask_calc_handle_point(spline, point);
}
-/* ** API ** */
+/* ** API ** */
static MaskLayer *rna_Mask_layers_new(Mask *mask, const char *name)
{
@@ -1008,7 +1008,7 @@ static void rna_def_mask_layer(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1);
RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL);
- /* select (for dopesheet)*/
+ /* Select (for dope-sheet). */
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MASK_LAYERFLAG_SELECT);
RNA_def_property_ui_text(prop, "Select", "Layer is selected for editing in the Dope Sheet");
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index c0a9b7ba9d8..b662f54ed4c 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -688,21 +688,21 @@ static void rna_def_material_lineart(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "MaterialLineArt");
RNA_def_struct_ui_text(srna, "Material Line Art", "");
- prop = RNA_def_property(srna, "use_transparency", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_material_mask", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_default(prop, 0);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_MATERIAL_TRANSPARENCY_ENABLED);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_MATERIAL_MASK_ENABLED);
RNA_def_property_ui_text(
- prop, "Use Transparency", "Use transparency mask from this material in line art");
+ prop, "Use Material Mask", "Use material masks to filter out occluded strokes");
RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
- prop = RNA_def_property(srna, "use_transparency_mask", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_material_mask_bits", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_default(prop, 0);
- RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1);
- RNA_def_property_array(prop, 6);
+ RNA_def_property_boolean_sdna(prop, NULL, "material_mask_bits", 1);
+ RNA_def_property_array(prop, 8);
RNA_def_property_ui_text(prop, "Mask", "");
RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
- prop = RNA_def_property(srna, "use_occlusion_effectiveness", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_mat_occlusion", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS);
RNA_def_property_ui_text(prop,
@@ -710,9 +710,9 @@ static void rna_def_material_lineart(BlenderRNA *brna)
"Use custom occlusion effectiveness for this material");
RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
- prop = RNA_def_property(srna, "occlusion_effectiveness", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "mat_occlusion", PROP_INT, PROP_NONE);
RNA_def_property_int_default(prop, 1);
- RNA_def_property_range(prop, 0.0f, 3.0f);
+ RNA_def_property_ui_range(prop, 0.0f, 5.0f, 1.0f, 1);
RNA_def_property_ui_text(
prop,
"Effectiveness",
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 50a5a196a98..81cf1447604 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -16,7 +16,7 @@
/* note: the original vertex color stuff is now just used for
* getting info on the layers themselves, accessing the data is
- * done through the (not yet written) mpoly interfaces.*/
+ * done through the (not yet written) mpoly interfaces. */
/** \file
* \ingroup RNA
@@ -239,6 +239,19 @@ static void rna_Mesh_update_data_legacy_deg_tag_all(Main *UNUSED(bmain),
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
}
+static void rna_Mesh_update_geom_and_params(Main *UNUSED(bmain),
+ Scene *UNUSED(scene),
+ PointerRNA *ptr)
+{
+ ID *id = ptr->owner_id;
+ if (id->us <= 0) { /* See note in section heading. */
+ return;
+ }
+
+ DEG_id_tag_update(id, ID_RECALC_GEOMETRY | ID_RECALC_PARAMETERS);
+ WM_main_add_notifier(NC_GEOM | ND_DATA, id);
+}
+
static void rna_Mesh_update_data_edit_weight(Main *bmain, Scene *scene, PointerRNA *ptr)
{
BKE_mesh_batch_cache_dirty_tag(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_ALL);
@@ -2450,7 +2463,7 @@ static void rna_def_mesh_loops(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
- /*PropertyRNA *prop;*/
+ // PropertyRNA *prop;
FunctionRNA *func;
PropertyRNA *parm;
@@ -3260,11 +3273,6 @@ static void rna_def_mesh(BlenderRNA *brna)
"generating triangles. A value greater than 0 disables Fix Poles");
RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
- prop = RNA_def_property(srna, "use_remesh_smooth_normals", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_REMESH_SMOOTH_NORMALS);
- RNA_def_property_ui_text(prop, "Smooth Normals", "Smooth the normals of the remesher result");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
-
prop = RNA_def_property(srna, "use_remesh_fix_poles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_REMESH_FIX_POLES);
RNA_def_property_ui_text(prop, "Fix Poles", "Produces less poles and a better topology flow");
@@ -3338,7 +3346,7 @@ static void rna_def_mesh(BlenderRNA *brna)
"Auto Smooth",
"Auto smooth (based on smooth/sharp faces/edges and angle between faces), "
"or use custom split normals data if available");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_geom_and_params");
prop = RNA_def_property(srna, "auto_smooth_angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "smoothresh");
@@ -3347,7 +3355,7 @@ static void rna_def_mesh(BlenderRNA *brna)
"Auto Smooth Angle",
"Maximum angle between face normals that will be considered as smooth "
"(unused if custom split normals data are available)");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_geom_and_params");
RNA_define_verify_sdna(false);
prop = RNA_def_property(srna, "has_custom_normals", PROP_BOOLEAN, PROP_NONE);
@@ -3378,7 +3386,7 @@ static void rna_def_mesh(BlenderRNA *brna)
prop,
"Auto Texture Space",
"Adjust active object's texture space automatically when transforming object");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_geom_and_params");
# if 0
prop = RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION);
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c
index 2b0582cae9a..8128bdb83a0 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -208,7 +208,7 @@ static void rna_Mesh_clear_geometry(Mesh *mesh)
{
BKE_mesh_clear_geometry(mesh);
- DEG_id_tag_update(&mesh->id, ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&mesh->id, ID_RECALC_GEOMETRY_ALL_MODES);
WM_main_add_notifier(NC_GEOM | ND_DATA, mesh);
}
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 674e5845ccb..9a895a0c75a 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -544,7 +544,7 @@ const EnumPropertyItem rna_enum_dt_mix_mode_items[] = {
0,
"Multiply",
"Multiply source value to destination one, using given threshold as factor"},
- /* etc. etc. */
+ /* Etc. */
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index c26e9e883d6..c927c7df6bd 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -374,7 +374,7 @@ const EnumPropertyItem rna_enum_node_clamp_items[] = {
static const EnumPropertyItem rna_enum_node_tex_dimensions_items[] = {
{1, "1D", 0, "1D", "Use the scalar value W as input"},
{2, "2D", 0, "2D", "Use the 2D vector (x, y) as input. The z component is ignored"},
- {3, "3D", 0, "3D", "Use the 3D vector Vector as input"},
+ {3, "3D", 0, "3D", "Use the 3D vector (x, y, z) as input"},
{4, "4D", 0, "4D", "Use the 4D vector (x, y, z, w) as input"},
{0, NULL, 0, NULL, NULL},
};
@@ -8967,6 +8967,33 @@ static void def_geo_boolean(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
}
+static void def_geo_curve_primitive_bezier_segment(StructRNA *srna)
+{
+ static const EnumPropertyItem mode_items[] = {
+
+ {GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT_POSITION,
+ "POSITION",
+ ICON_NONE,
+ "Position",
+ "The start and end handles are fixed positions"},
+ {GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT_OFFSET,
+ "OFFSET",
+ ICON_NONE,
+ "Offset",
+ "The start and end handles are offsets from the spline's control points"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ PropertyRNA *prop;
+
+ RNA_def_struct_sdna_from(srna, "NodeGeometryCurvePrimitiveBezierSegment", "storage");
+
+ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, mode_items);
+ RNA_def_property_ui_text(prop, "Mode", "Method used to determine control handles");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
+}
+
static void def_geo_triangulate(StructRNA *srna)
{
PropertyRNA *prop;
@@ -9398,6 +9425,32 @@ static void def_geo_attribute_vector_rotate(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
}
+static void def_geo_curve_primitive_circle(StructRNA *srna)
+{
+ static const EnumPropertyItem mode_items[] = {
+ {GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS,
+ "POINTS",
+ ICON_NONE,
+ "Points",
+ "Define the radius and location with three points"},
+ {GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_RADIUS,
+ "RADIUS",
+ ICON_NONE,
+ "Radius",
+ "Define the radius with a float"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ PropertyRNA *prop;
+
+ RNA_def_struct_sdna_from(srna, "NodeGeometryCurvePrimitiveCircle", "storage");
+
+ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, mode_items);
+ RNA_def_property_ui_text(prop, "Mode", "Method used to determine radius and placement");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
+}
+
static void def_geo_point_rotate(StructRNA *srna)
{
static const EnumPropertyItem type_items[] = {
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 3d3faf0c56f..a208e520d02 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -1882,7 +1882,7 @@ bool rna_Object_greasepencil_modifiers_override_apply(Main *bmain,
GpencilModifierData *mod_dst = ED_object_gpencil_modifier_add(
NULL, bmain, NULL, ob_dst, mod_src->name, mod_src->type);
- BLI_remlink(&ob_dst->modifiers, mod_dst);
+ BLI_remlink(&ob_dst->greasepencil_modifiers, mod_dst);
/* This handles NULL anchor as expected by adding at head of list. */
BLI_insertlinkafter(&ob_dst->greasepencil_modifiers, mod_anchor, mod_dst);
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index d08504dd6fe..10ba2b9acb1 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -303,6 +303,9 @@ static void rna_Object_mat_convert_space(Object *ob,
{
copy_m4_m4((float(*)[4])mat_ret, (float(*)[4])mat);
+ BLI_assert(!ELEM(from, CONSTRAINT_SPACE_OWNLOCAL));
+ BLI_assert(!ELEM(to, CONSTRAINT_SPACE_OWNLOCAL));
+
/* Error in case of invalid from/to values when pchan is NULL */
if (pchan == NULL) {
if (ELEM(from, CONSTRAINT_SPACE_POSE, CONSTRAINT_SPACE_PARLOCAL)) {
@@ -362,7 +365,7 @@ static void rna_Object_calc_matrix_camera(Object *ob,
BKE_camera_params_init(&params);
BKE_camera_params_from_object(&params, ob_eval);
- /* compute matrix, viewplane, .. */
+ /* Compute matrix, view-plane, etc. */
BKE_camera_params_compute_viewplane(&params, width, height, scalex, scaley);
BKE_camera_params_compute_matrix(&params);
@@ -508,7 +511,7 @@ static void rna_Mesh_assign_verts_to_group(
create_dverts(&me->id);
}
- /* loop list adding verts to group */
+ /* Loop list adding verts to group. */
for (i = 0; i < totindex; i++) {
if (i < 0 || i >= me->totvert) {
BKE_report(reports, RPT_ERROR, "Bad vertex index in list");
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index eb7da0d0ce2..30baf01e952 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -287,7 +287,7 @@ static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), P
pid2 = pid;
}
else if (cache->name[0] != '\0' && STREQ(cache->name, pid->cache->name)) {
- /*TODO: report "name exists" to user */
+ /* TODO: report "name exists" to user. */
BLI_strncpy(cache->name, cache->prev_name, sizeof(cache->name));
use_new_name = false;
}
@@ -2047,10 +2047,10 @@ static void rna_def_softbody(BlenderRNA *brna)
prop, "Estimate Transforms", "Store the estimated transforms in the soft body settings");
/***********************************************************************************/
- /* these are not exactly settings, but reading calculated results*/
- /* but i did not want to start a new property struct */
- /* so rather rename this from SoftBodySettings to SoftBody */
- /* translation */
+ /* These are not exactly settings, but reading calculated results
+ * but i did not want to start a new property struct
+ * so rather rename this from SoftBodySettings to SoftBody
+ * translation. */
prop = RNA_def_property(srna, "location_mass_center", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "lcom");
RNA_def_property_ui_text(prop, "Center of Mass", "Location of center of mass");
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 7ff2a82a465..9ab685fa462 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -970,9 +970,11 @@ static void rna_PartSettings_start_set(struct PointerRNA *ptr, float value)
settings->end = value;
}
- /*if (settings->type==PART_REACTOR && value < 1.0) */
- /* value = 1.0; */
- /*else */
+# if 0
+ if (settings->type==PART_REACTOR && value < 1.0)
+ value = 1.0;
+ else
+# endif
if (value < MINAFRAMEF) {
value = MINAFRAMEF;
}
@@ -1359,9 +1361,11 @@ static const EnumPropertyItem *rna_Particle_from_itemf(bContext *UNUSED(C),
PropertyRNA *UNUSED(prop),
bool *UNUSED(r_free))
{
- /*if (part->type==PART_REACTOR) */
- /* return part_reactor_from_items; */
- /*else */
+# if 0
+ if (part->type == PART_REACTOR) {
+ return part_reactor_from_items;
+ }
+# endif
return part_from_items;
}
@@ -1760,17 +1764,17 @@ static void rna_def_particle_key(BlenderRNA *brna)
static void rna_def_child_particle(BlenderRNA *brna)
{
StructRNA *srna;
- /*PropertyRNA *prop; */
+ // PropertyRNA *prop;
srna = RNA_def_struct(brna, "ChildParticle", NULL);
RNA_def_struct_ui_text(
srna, "Child Particle", "Child particle interpolated from simulated or edited particles");
- /* int num, parent; */ /* num is face index on the final derived mesh */
+ /* int num, parent; */ /* num is face index on the final derived mesh */
- /* int pa[4]; */ /* nearest particles to the child, used for the interpolation */
- /* float w[4]; */ /* interpolation weights for the above particles */
- /* float fuv[4], foffset; */ /* face vertex weights and offset */
+ /* int pa[4]; */ /* nearest particles to the child, used for the interpolation */
+ /* float w[4]; */ /* interpolation weights for the above particles */
+ /* float fuv[4], foffset; */ /* face vertex weights and offset */
/* float rand[3]; */
}
@@ -1840,8 +1844,8 @@ static void rna_def_particle(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "ParticleKey");
RNA_def_property_ui_text(prop, "Keyed States", "");
/* */
- /* float fuv[4], foffset; */ /* coordinates on face/edge number "num" and depth along*/
- /* */ /* face normal for volume emission */
+ /* float fuv[4], foffset; */ /* Coordinates on face/edge number "num" and depth along. */
+ /* Face normal for volume emission. */
prop = RNA_def_property(srna, "birth_time", PROP_FLOAT, PROP_TIME);
RNA_def_property_float_sdna(prop, NULL, "time");
@@ -2426,7 +2430,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
- /*TODO: names, tooltips */
+ /* TODO: names, tool-tips. */
static const EnumPropertyItem integrator_type_items[] = {
{PART_INT_EULER, "EULER", 0, "Euler", ""},
{PART_INT_VERLET, "VERLET", 0, "Verlet", ""},
@@ -2659,7 +2663,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "React On", "The event of target particles to react on");
RNA_def_property_update(prop, 0, "rna_Particle_reset");
- /*draw flag*/
+ /* Draw flag. */
prop = RNA_def_property(srna, "show_guide_hairs", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_GUIDE_HAIRS);
RNA_def_property_ui_text(prop, "Guide Hairs", "Show guide hairs");
@@ -2806,9 +2810,9 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Random Bending Stiffness", "Random stiffness of hairs");
RNA_def_property_update(prop, 0, "rna_Particle_cloth_update");
- /*TODO: not found in UI, readonly? */
+ /* TODO: not found in UI, read-only? */
prop = RNA_def_property(srna, "keys_step", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 0, SHRT_MAX); /*TODO:min,max */
+ RNA_def_property_range(prop, 0, SHRT_MAX); /* TODO: min,max. */
RNA_def_property_ui_text(prop, "Keys Step", "");
/* adaptive path rendering */
@@ -2870,7 +2874,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
/* general values */
prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_TIME);
- RNA_def_property_float_sdna(prop, NULL, "sta"); /*optional if prop names are the same */
+ RNA_def_property_float_sdna(prop, NULL, "sta"); /* Optional if prop names are the same. */
RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_float_funcs(prop, NULL, "rna_PartSettings_start_set", NULL);
@@ -2959,7 +2963,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Particle_reset");
prop = RNA_def_property(
- srna, "userjit", PROP_INT, PROP_UNSIGNED); /*TODO: can we get a better name for userjit? */
+ srna, "userjit", PROP_INT, PROP_UNSIGNED); /* TODO: can we get a better name for userjit? */
RNA_def_property_int_sdna(prop, NULL, "userjit");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0, 1000);
@@ -2992,7 +2996,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
/* initial velocity factors */
prop = RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_VELOCITY);
- RNA_def_property_float_sdna(prop, NULL, "normfac"); /*optional if prop names are the same */
+ RNA_def_property_float_sdna(prop, NULL, "normfac"); /* Optional if prop names are the same. */
RNA_def_property_range(prop, -1000.0f, 1000.0f);
RNA_def_property_ui_range(prop, 0, 100, 1, 3);
RNA_def_property_ui_text(
@@ -3008,7 +3012,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Particle_reset");
prop = RNA_def_property(srna, "factor_random", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "randfac"); /*optional if prop names are the same */
+ RNA_def_property_float_sdna(prop, NULL, "randfac"); /* Optional if prop names are the same. */
RNA_def_property_range(prop, 0.0f, 200.0f);
RNA_def_property_ui_range(prop, 0, 100, 1, 3);
RNA_def_property_ui_text(prop, "Random", "Give the starting velocity a random variation");
@@ -3149,7 +3153,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
/* children */
prop = RNA_def_property(srna, "child_nbr", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "child_nbr"); /*optional if prop names are the same */
+ RNA_def_property_int_sdna(prop, NULL, "child_nbr"); /* Optional if prop names are the same. */
RNA_def_property_range(prop, 0, 100000);
RNA_def_property_ui_range(prop, 0, 1000, 1, -1);
RNA_def_property_ui_text(prop, "Children Per Parent", "Number of children per parent");
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index f736885df77..bb4939a010b 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -932,7 +932,7 @@ static void rna_def_bone_group(BlenderRNA *brna)
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_BoneGroup_name_set");
RNA_def_struct_name_property(srna, prop);
- /* TODO: add some runtime-collections stuff to access grouped bones */
+ /* TODO: add some runtime-collections stuff to access grouped bones. */
/* color set */
rna_def_actionbone_group_common(srna, NC_OBJECT | ND_POSE, "rna_Pose_update");
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index 6715941ae2a..4fe61df9387 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -858,6 +858,7 @@ static void rna_def_render_engine(BlenderRNA *brna)
prop = RNA_def_property(srna, "bl_use_image_save", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "type->flag", RE_USE_NO_IMAGE_SAVE);
+ RNA_def_property_boolean_default(prop, true);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
RNA_def_property_ui_text(
prop,
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index 9e7d0f99dfa..899c3397361 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -36,7 +36,7 @@
/** \name Generic Enum's
* \{ */
-/* Reuse for dynamic types */
+/* Reuse for dynamic types. */
const EnumPropertyItem DummyRNA_NULL_items[] = {
{0, NULL, 0, NULL, NULL},
};
@@ -951,7 +951,7 @@ static int rna_enum_check_separator(CollectionPropertyIterator *UNUSED(iter), vo
static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
- /* EnumPropertyRNA *eprop; */ /* UNUSED */
+ /* EnumPropertyRNA *eprop; */ /* UNUSED */
const EnumPropertyItem *item = NULL;
int totitem;
bool free;
@@ -2966,7 +2966,7 @@ static void rna_def_function(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Description", "Description of the Function's purpose");
prop = RNA_def_property(srna, "parameters", PROP_COLLECTION, PROP_NONE);
- /*RNA_def_property_clear_flag(prop, PROP_EDITABLE);*/
+ // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "Property");
RNA_def_property_collection_funcs(prop,
"rna_Function_parameters_begin",
@@ -3270,7 +3270,7 @@ void RNA_def_rna(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- /* Struct*/
+ /* Struct */
rna_def_struct(brna);
/* Property */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 7f23d9bc754..0ce4271c3c2 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -3111,6 +3111,12 @@ static void rna_def_tool_settings(BlenderRNA *brna)
"Absolute grid alignment while translating (based on the pivot center)");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
+ prop = RNA_def_property(srna, "use_snap_sequencer", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_SEQ);
+ RNA_def_property_ui_text(prop, "Use Snapping", "Snap to strip edges or current frame");
+ RNA_def_property_ui_icon(prop, ICON_SNAP_OFF, 1);
+ RNA_def_property_boolean_default(prop, true);
+
prop = RNA_def_property(srna, "snap_elements", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_mode");
RNA_def_property_enum_items(prop, rna_enum_snap_element_items);
@@ -3351,7 +3357,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Annotations - 3D View Stroke Placement */
- /* XXX: Do we need to decouple the stroke_endpoints setting too? */
+ /* XXX: Do we need to decouple the stroke_endpoints setting too? */
prop = RNA_def_property(srna, "annotation_stroke_placement_view3d", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "annotate_v3d_align");
RNA_def_property_enum_items(prop, annotation_stroke_placement_items);
@@ -3505,9 +3511,35 @@ static void rna_def_sequencer_tool_settings(BlenderRNA *brna)
RNA_def_struct_path_func(srna, "rna_SequencerToolSettings_path");
RNA_def_struct_ui_text(srna, "Sequencer Tool Settings", "");
+ /* Add strip settings. */
prop = RNA_def_property(srna, "fit_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, scale_fit_methods);
RNA_def_property_ui_text(prop, "Fit Method", "Scale fit method");
+
+ /* Transform snapping. */
+ prop = RNA_def_property(srna, "snap_to_current_frame", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "snap_mode", SEQ_SNAP_TO_CURRENT_FRAME);
+ RNA_def_property_ui_text(prop, "Current Frame", "Snap to current frame");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
+
+ prop = RNA_def_property(srna, "snap_to_hold_offset", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "snap_mode", SEQ_SNAP_TO_STRIP_HOLD);
+ RNA_def_property_ui_text(prop, "Hold Offset", "Snap to strip hold offsets");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
+
+ prop = RNA_def_property(srna, "snap_ignore_muted", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SEQ_SNAP_IGNORE_MUTED);
+ RNA_def_property_ui_text(prop, "Ignore Muted Strips", "Don't snap to hidden strips");
+
+ prop = RNA_def_property(srna, "snap_ignore_sound", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SEQ_SNAP_IGNORE_SOUND);
+ RNA_def_property_ui_text(prop, "Ignore Sound Strips", "Don't snap to sound strips");
+
+ prop = RNA_def_property(srna, "snap_distance", PROP_INT, PROP_PIXEL);
+ RNA_def_property_int_sdna(prop, NULL, "snap_distance");
+ RNA_def_property_int_default(prop, 15);
+ RNA_def_property_ui_range(prop, 0, 50, 1, 1);
+ RNA_def_property_ui_text(prop, "Snapping Distance", "Maximum distance for snapping in pixels");
}
static void rna_def_unified_paint_settings(BlenderRNA *brna)
@@ -4204,6 +4236,17 @@ void rna_def_view_layer_common(BlenderRNA *brna, StructRNA *srna, const bool sce
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
}
+ prop = RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_MOTION_BLUR);
+ RNA_def_property_ui_text(
+ prop, "Motion Blur", "Render motion blur in this Layer, if enabled in the scene");
+ if (scene) {
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+ }
+ else {
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
+
/* passes */
prop = RNA_def_property(srna, "use_pass_combined", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_COMBINED);
@@ -5762,7 +5805,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Lossless Output", "Use lossless output for video streams");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- /* FFMPEG Audio*/
+ /* FFMPEG Audio. */
prop = RNA_def_property(srna, "audio_codec", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "audio_codec");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -6624,7 +6667,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "BakeSettings");
RNA_def_property_ui_text(prop, "Bake Data", "");
- /* Nestled Data */
+ /* Nestled Data. */
/* *** Non-Animated *** */
RNA_define_animate_sdna(false);
rna_def_bake_data(brna);
@@ -7940,7 +7983,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "SceneGpencil");
RNA_def_property_ui_text(prop, "Grease Pencil", "Grease Pencil settings for the scene");
- /* Nestled Data */
+ /* Nestled Data. */
/* *** Non-Animated *** */
RNA_define_animate_sdna(false);
rna_def_tool_settings(brna);
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index 25f29a3efe0..90029bd14a1 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -234,7 +234,7 @@ static int rna_Area_ui_type_get(PointerRNA *ptr)
* the area type is changing.
* So manually do the lookup in those cases, but do not actually change area->type
* since that prevents a proper exit when the area type is changing.
- * Logic copied from `ED_area_init()`.*/
+ * Logic copied from `ED_area_init()`. */
SpaceType *type = area->type;
if (type == NULL || area_changing) {
type = BKE_spacetype_from_id(area_type);
diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c
index c5a53d4522d..9dc64fc950c 100644
--- a/source/blender/makesrna/intern/rna_sound.c
+++ b/source/blender/makesrna/intern/rna_sound.c
@@ -60,7 +60,7 @@ static void rna_def_sound(BlenderRNA *brna)
srna, "Sound", "Sound data-block referencing an external or packed sound file");
RNA_def_struct_ui_icon(srna, ICON_SOUND);
- /*rna_def_ipo_common(srna); */
+ // rna_def_ipo_common(srna);
prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
RNA_def_property_string_sdna(prop, NULL, "filepath");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index f3871e625de..c8a779f890d 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -776,6 +776,20 @@ static void rna_Space_show_region_toolbar_update(bContext *C, PointerRNA *ptr)
rna_Space_bool_from_region_flag_update_by_type(C, ptr, RGN_TYPE_TOOLS, RGN_FLAG_HIDDEN);
}
+/* Channels Region. */
+static bool rna_Space_show_region_channels_get(PointerRNA *ptr)
+{
+ return !rna_Space_bool_from_region_flag_get_by_type(ptr, RGN_TYPE_CHANNELS, RGN_FLAG_HIDDEN);
+}
+static void rna_Space_show_region_channels_set(PointerRNA *ptr, bool value)
+{
+ rna_Space_bool_from_region_flag_set_by_type(ptr, RGN_TYPE_CHANNELS, RGN_FLAG_HIDDEN, !value);
+}
+static void rna_Space_show_region_channels_update(bContext *C, PointerRNA *ptr)
+{
+ rna_Space_bool_from_region_flag_update_by_type(C, ptr, RGN_TYPE_CHANNELS, RGN_FLAG_HIDDEN);
+}
+
/* UI Region */
static bool rna_Space_show_region_ui_get(PointerRNA *ptr)
{
@@ -924,7 +938,7 @@ static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr)
void *regiondata = NULL;
if (area) {
ListBase *regionbase = (area->spacedata.first == v3d) ? &area->regionbase : &v3d->regionbase;
- ARegion *region = regionbase->last; /* always last in list, weak .. */
+ ARegion *region = regionbase->last; /* always last in list, weak. */
regiondata = region->regiondata;
}
@@ -2966,7 +2980,7 @@ static void rna_FileBrowser_FSMenu_active_range(PointerRNA *UNUSED(ptr),
static void rna_FileBrowser_FSMenu_active_update(struct bContext *C, PointerRNA *ptr)
{
ScrArea *area = rna_area_from_space(ptr);
- ED_file_change_dir_ex(C, (bScreen *)ptr->owner_id, area);
+ ED_file_change_dir_ex(C, area);
}
static int rna_FileBrowser_FSMenuSystem_active_get(PointerRNA *ptr)
@@ -3214,6 +3228,10 @@ static void rna_def_space_generic_show_region_toggles(StructRNA *srna, int regio
region_type_mask &= ~(1 << RGN_TYPE_TOOLS);
DEF_SHOW_REGION_PROPERTY(show_region_toolbar, "Toolbar", "");
}
+ if (region_type_mask & (1 << RGN_TYPE_CHANNELS)) {
+ region_type_mask &= ~(1 << RGN_TYPE_CHANNELS);
+ DEF_SHOW_REGION_PROPERTY(show_region_channels, "Channels", "");
+ }
if (region_type_mask & (1 << RGN_TYPE_UI)) {
region_type_mask &= ~(1 << RGN_TYPE_UI);
DEF_SHOW_REGION_PROPERTY(show_region_ui, "Sidebar", "");
@@ -3606,6 +3624,11 @@ static void rna_def_space_outliner(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Collections", "Show collections");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL);
+ prop = RNA_def_property(srna, "use_filter_view_layers", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_VIEW_LAYERS);
+ RNA_def_property_ui_text(prop, "Show All View Layers", "Show all the view layers");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL);
+
/* Filters object state. */
prop = RNA_def_property(srna, "filter_state", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "filter_state");
@@ -7560,6 +7583,9 @@ static void rna_def_space_spreadsheet_context(BlenderRNA *brna)
RNA_def_property_enum_items(prop, spreadsheet_context_type_items);
RNA_def_property_ui_text(prop, "Type", "Type of the context");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ rna_def_space_generic_show_region_toggles(srna,
+ (1 << RGN_TYPE_CHANNELS) | (1 << RGN_TYPE_FOOTER));
}
static void rna_def_space_spreadsheet_context_object(BlenderRNA *brna)
@@ -7674,7 +7700,8 @@ static void rna_def_space_spreadsheet(BlenderRNA *brna)
srna = RNA_def_struct(brna, "SpaceSpreadsheet", "Space");
RNA_def_struct_ui_text(srna, "Space Spreadsheet", "Spreadsheet space data");
- rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_UI) | (1 << RGN_TYPE_FOOTER));
+ rna_def_space_generic_show_region_toggles(
+ srna, (1 << RGN_TYPE_UI) | (1 << RGN_TYPE_CHANNELS) | (1 << RGN_TYPE_FOOTER));
prop = RNA_def_property(srna, "is_pinned", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SPREADSHEET_FLAG_PINNED);
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index d8a8d64e639..128f1cb1e21 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -1659,7 +1659,7 @@ static void rna_def_texture(BlenderRNA *brna)
rna_def_texture_musgrave(brna);
rna_def_texture_voronoi(brna);
rna_def_texture_distorted_noise(brna);
- /* XXX add more types here .. */
+ /* XXX add more types here. */
RNA_api_texture(srna);
}
diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c
index 13b561f9dd6..42b3e4420c1 100644
--- a/source/blender/makesrna/intern/rna_texture_api.c
+++ b/source/blender/makesrna/intern/rna_texture_api.c
@@ -42,7 +42,7 @@ static void texture_evaluate(struct Tex *tex, float value[3], float r_color[4])
{
TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
- /* TODO(sergey): always use color management now. */
+ /* TODO(sergey): always use color management now. */
multitex_ext(tex, value, NULL, NULL, 1, &texres, 0, NULL, true, false);
r_color[0] = texres.tr;
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index 8f596ec6a5c..acf580e3ddf 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -1231,7 +1231,7 @@ static void rna_def_ui_layout(BlenderRNA *brna)
{UI_EMBOSS_PULLDOWN, "PULLDOWN_MENU", 0, "Pulldown Menu", "Draw pulldown menu style"},
{UI_EMBOSS_RADIAL, "RADIAL_MENU", 0, "Radial Menu", "Draw radial menu style"},
{UI_EMBOSS_NONE_OR_STATUS,
- "UI_EMBOSS_NONE_OR_STATUS",
+ "NONE_OR_STATUS",
0,
"None or Status",
"Draw with no emboss unless the button has a coloring status like an animation state"},
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index dc973a9c75c..aa235b599b7 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -384,26 +384,28 @@ static void rna_uiItemsEnumO(uiLayout *layout,
uiItemsFullEnumO(layout, opname, propname, NULL, uiLayoutGetOperatorContext(layout), flag);
}
-static void rna_uiItemMenuEnumO(uiLayout *layout,
- bContext *C,
- const char *opname,
- const char *propname,
- const char *name,
- const char *text_ctxt,
- bool translate,
- int icon)
+static PointerRNA rna_uiItemMenuEnumO(uiLayout *layout,
+ bContext *C,
+ const char *opname,
+ const char *propname,
+ const char *name,
+ const char *text_ctxt,
+ bool translate,
+ int icon)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
if (!ot || !ot->srna) {
RNA_warning("%s '%s'", ot ? "unknown operator" : "operator missing srna", opname);
- return;
+ return PointerRNA_NULL;
}
/* Get translated name (label). */
name = rna_translate_ui_text(name, text_ctxt, ot->srna, NULL, translate);
- uiItemMenuEnumO_ptr(layout, C, ot, propname, name, icon);
+ PointerRNA opptr;
+ uiItemMenuEnumFullO_ptr(layout, C, ot, propname, name, icon, &opptr);
+ return opptr;
}
static void rna_uiItemL(uiLayout *layout,
@@ -912,7 +914,12 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_boolean(func, "event", false, "", "Use button to input key events");
RNA_def_boolean(
func, "full_event", false, "", "Use button to input full events including modifiers");
- RNA_def_boolean(func, "emboss", true, "", "Draw the button itself, not just the icon/text");
+ RNA_def_boolean(func,
+ "emboss",
+ true,
+ "",
+ "Draw the button itself, not just the icon/text. When false, corresponds to the "
+ "'NONE_OR_STATUS' layout emboss type");
RNA_def_int(func,
"index",
/* RNA_NO_INDEX == -1 */
@@ -1023,6 +1030,10 @@ void RNA_api_ui_layout(StructRNA *srna)
parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in operator");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
api_ui_item_common(func);
+ parm = RNA_def_pointer(
+ func, "properties", "OperatorProperties", "", "Operator properties to fill in");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR);
+ RNA_def_function_return(func, parm);
/* useful in C but not in python */
# if 0
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 4d45d1d6d63..3b7af07479c 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -826,7 +826,7 @@ static PointerRNA rna_Addon_preferences_get(PointerRNA *ptr)
if (apt) {
if (addon->prop == NULL) {
IDPropertyTemplate val = {0};
- addon->prop = IDP_New(IDP_GROUP, &val, addon->module); /* name is unimportant */
+ addon->prop = IDP_New(IDP_GROUP, &val, addon->module); /* name is unimportant. */
}
return rna_pointer_inherit_refine(ptr, apt->rna_ext.srna, addon->prop);
}
@@ -2275,7 +2275,7 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
rna_def_userdef_theme_spaces_edge(srna);
rna_def_userdef_theme_spaces_face(srna);
- /* Mesh Object specific curves*/
+ /* Mesh Object specific curves. */
rna_def_userdef_theme_spaces_curves(srna, true, true, true, false);
@@ -2320,7 +2320,7 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Split Normal", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
- /* Armature Object specific */
+ /* Armature Object specific. */
prop = RNA_def_property(srna, "bone_pose", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
@@ -2486,7 +2486,7 @@ static void rna_def_userdef_theme_space_file(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- /* space_file */
+ /* space_file */
srna = RNA_def_struct(brna, "ThemeFileBrowser", NULL);
RNA_def_struct_sdna(srna, "ThemeSpace");
@@ -3864,6 +3864,7 @@ static void rna_def_userdef_theme_space_spreadsheet(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
rna_def_userdef_theme_spaces_main(srna);
+ rna_def_userdef_theme_spaces_list_main(srna);
}
static void rna_def_userdef_themes(BlenderRNA *brna)
@@ -4509,7 +4510,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "View & Controls", "Preferences related to viewing data");
- /* View */
+ /* View. */
prop = RNA_def_property(srna, "ui_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(
prop, "UI Scale", "Changes the size of the fonts and widgets in the interface");
@@ -6135,7 +6136,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
"Tabs as Spaces",
"Automatically convert all new tabs into spaces for new and loaded text files");
- /* Directories */
+ /* Directories. */
prop = RNA_def_property(srna, "font_directory", PROP_STRING, PROP_DIRPATH);
RNA_def_property_string_sdna(prop, NULL, "fontdir");
@@ -6199,7 +6200,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Animation Player Preset", "Preset configs for external animation players");
- /* Autosave */
+ /* Autosave. */
prop = RNA_def_property(srna, "save_version", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "versions");
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 2b1a5f7fde1..a563541b968 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -751,7 +751,7 @@ static void rna_Window_scene_update(bContext *C, PointerRNA *ptr)
Main *bmain = CTX_data_main(C);
wmWindow *win = ptr->data;
- /* exception: must use context so notifier gets to the right window */
+ /* Exception: must use context so notifier gets to the right window. */
if (win->new_scene) {
# ifdef WITH_PYTHON
BPy_BEGIN_ALLOW_THREADS;
@@ -892,7 +892,7 @@ static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
return *(kmi->ptr);
}
- /*return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties); */
+ // return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties);
return PointerRNA_NULL;
}
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 93a9e76ffe4..c5e3833aa4a 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -121,7 +121,7 @@ BLI_INLINE float sum_v3(const float v[3])
typedef struct SortVertsElem {
int vertex_num; /* The original index of the vertex, prior to sorting */
float co[3]; /* Its coordinates */
- float sum_co; /* sum_v3(co), just so we don't do the sum many times. */
+ float sum_co; /* `sum_v3(co)`: just so we don't do the sum many times. */
} SortVertsElem;
static int svert_sum_cmp(const void *e1, const void *e2)
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index 2874bebe13a..82a6e169a7a 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -89,7 +89,7 @@ Mesh *doEdgeSplit(const Mesh *mesh, EdgeSplitModifierData *emd)
UNLIKELY(l1 != l2->radial_next) ||
/* O° angle setting, we want to split on all edges. */
do_split_all ||
- /* 2 face edge - check angle*/
+ /* 2 face edge - check angle. */
(dot_v3v3(l1->f->no, l2->f->no) < threshold)) {
BM_elem_flag_enable(e, BM_ELEM_TAG);
}
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index 28fe4376d2c..4e53243d820 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -1048,7 +1048,7 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
}
BLI_edgehashIterator_free(ehi);
- /*map new vertices to faces*/
+ /* Map new vertices to faces. */
for (i = 0, u = 0; i < totface; i++) {
MFace source;
int orig_v4;
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index 78e0bf3fa8f..63495c4104e 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -57,18 +57,18 @@
struct BLaplacianSystem {
float *eweights; /* Length weights per Edge */
float (*fweights)[3]; /* Cotangent weights per face */
- float *ring_areas; /* Total area per ring*/
- float *vlengths; /* Total sum of lengths(edges) per vertice*/
- float *vweights; /* Total sum of weights per vertice*/
- int numEdges; /* Number of edges*/
- int numLoops; /* Number of edges*/
- int numPolys; /* Number of faces*/
- int numVerts; /* Number of verts*/
- short *numNeFa; /* Number of neighbors faces around vertice*/
- short *numNeEd; /* Number of neighbors Edges around vertice*/
- short *zerola; /* Is zero area or length*/
-
- /* Pointers to data*/
+ float *ring_areas; /* Total area per ring. */
+ float *vlengths; /* Total sum of lengths(edges) per vertex. */
+ float *vweights; /* Total sum of weights per vertex. */
+ int numEdges; /* Number of edges. */
+ int numLoops; /* Number of edges. */
+ int numPolys; /* Number of faces. */
+ int numVerts; /* Number of verts. */
+ short *numNeFa; /* Number of neighbors faces around vertice. */
+ short *numNeEd; /* Number of neighbors Edges around vertice. */
+ short *zerola; /* Is zero area or length. */
+
+ /* Pointers to data. */
float (*vertexCos)[3];
const MPoly *mpoly;
const MLoop *mloop;
@@ -299,7 +299,7 @@ static void fill_laplacian_matrix(LaplacianSystem *sys)
for (; l_next != l_term; l_prev = l_curr, l_curr = l_next, l_next++) {
const uint l_curr_index = l_curr - sys->mloop;
- /* Is ring if number of faces == number of edges around vertice*/
+ /* Is ring if number of faces == number of edges around vertice. */
if (sys->numNeEd[l_curr->v] == sys->numNeFa[l_curr->v] && sys->zerola[l_curr->v] == 0) {
EIG_linear_solver_matrix_add(sys->context,
l_curr->v,
diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c
index 361454120ca..6ec3277ee7a 100644
--- a/source/blender/modifiers/intern/MOD_meshcache.c
+++ b/source/blender/modifiers/intern/MOD_meshcache.c
@@ -198,11 +198,11 @@ static void meshcache_do(MeshCacheModifierData *mcmd,
me->mloop,
me->totvert,
- (const float(*)[3])vertexCos_Source, /* from the original Mesh*/
+ (const float(*)[3])vertexCos_Source, /* From the original Mesh. */
(const float(*)[3])vertexCos_Real, /* the input we've been given (shape keys!) */
- (const float(*)[3])vertexCos, /* the result of this modifier */
- vertexCos_New /* the result of this function */
+ (const float(*)[3])vertexCos, /* The result of this modifier. */
+ vertexCos_New /* The result of this function. */
);
/* write the corrected locations back into the result */
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index 8e1e03570b5..c997cd7377f 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -383,7 +383,7 @@ static void meshdeformModifier_do(ModifierData *md,
/* bind weights if needed */
if (!mmd->bindcagecos) {
- /* progress bar redraw can make this recursive .. */
+ /* progress bar redraw can make this recursive. */
if (!DEG_is_active(ctx->depsgraph)) {
BKE_modifier_set_error(ob, md, "Attempt to bind from inactive dependency graph");
goto finally;
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 8fa80025790..f7f7c7b0276 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -584,7 +584,7 @@ static const SocketPropertyType *get_socket_property_type(const bNodeSocket &bso
return &collection_type;
}
case SOCK_TEXTURE: {
- static const SocketPropertyType collection_type = {
+ static const SocketPropertyType texture_type = {
[](const bNodeSocket &socket, const char *name) {
bNodeSocketValueTexture *value = (bNodeSocketValueTexture *)socket.default_value;
IDPropertyTemplate idprop = {0};
@@ -602,10 +602,10 @@ static const SocketPropertyType *get_socket_property_type(const bNodeSocket &bso
*(Tex **)r_value = texture;
},
};
- return &collection_type;
+ return &texture_type;
}
case SOCK_MATERIAL: {
- static const SocketPropertyType collection_type = {
+ static const SocketPropertyType material_type = {
[](const bNodeSocket &socket, const char *name) {
bNodeSocketValueMaterial *value = (bNodeSocketValueMaterial *)socket.default_value;
IDPropertyTemplate idprop = {0};
@@ -623,7 +623,7 @@ static const SocketPropertyType *get_socket_property_type(const bNodeSocket &bso
*(Material **)r_value = material;
},
};
- return &collection_type;
+ return &material_type;
}
default: {
return nullptr;
@@ -714,7 +714,7 @@ static void initialize_group_input(NodesModifierData &nmd,
{
const SocketPropertyType *property_type = get_socket_property_type(socket);
if (property_type == nullptr) {
- cpp_type.copy_to_uninitialized(cpp_type.default_value(), r_value);
+ cpp_type.copy_construct(cpp_type.default_value(), r_value);
return;
}
if (nmd.settings.properties == nullptr) {
@@ -1106,7 +1106,7 @@ static void modifyGeometrySet(ModifierData *md,
/* Drawing the properties manually with #uiItemR instead of #uiDefAutoButsRNA allows using
* the node socket identifier for the property names, since they are unique, but also having
- * the correct label displayed in the UI. */
+ * the correct label displayed in the UI. */
static void draw_property_for_socket(uiLayout *layout,
PointerRNA *bmain_ptr,
PointerRNA *md_ptr,
diff --git a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
index e8677c7ce1a..8314a443ba6 100644
--- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
+++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
@@ -292,14 +292,22 @@ class LockedNode : NonCopyable, NonMovable {
}
};
-static const CPPType *get_socket_cpp_type(const DSocket socket)
+static const CPPType *get_socket_cpp_type(const SocketRef &socket)
{
- return nodes::socket_cpp_type_get(*socket->typeinfo());
+ const CPPType *type = nodes::socket_cpp_type_get(*socket.typeinfo());
+ if (type == nullptr) {
+ return nullptr;
+ }
+ /* The evaluator only supports types that have special member functions. */
+ if (!type->has_special_member_functions()) {
+ return nullptr;
+ }
+ return type;
}
-static const CPPType *get_socket_cpp_type(const SocketRef &socket)
+static const CPPType *get_socket_cpp_type(const DSocket socket)
{
- return nodes::socket_cpp_type_get(*socket.typeinfo());
+ return get_socket_cpp_type(*socket.socket_ref());
}
static bool node_supports_laziness(const DNode node)
@@ -888,7 +896,7 @@ class GeometryNodesEvaluator {
OutputState &output_state = node_state.outputs[socket->index()];
output_state.has_been_computed = true;
void *buffer = allocator.allocate(type->size(), type->alignment());
- type->copy_to_uninitialized(type->default_value(), buffer);
+ type->copy_construct(type->default_value(), buffer);
this->forward_output({node.context(), socket}, {*type, buffer});
}
}
@@ -967,7 +975,7 @@ class GeometryNodesEvaluator {
/* Move value into memory owned by the outer allocator. */
const CPPType &type = *input_state.type;
void *buffer = outer_allocator_.allocate(type.size(), type.alignment());
- type.move_to_uninitialized(value, buffer);
+ type.move_construct(value, buffer);
params_.r_output_values.append({type, buffer});
}
@@ -1204,7 +1212,7 @@ class GeometryNodesEvaluator {
}
else {
/* Cannot convert, use default value instead. */
- to_type.copy_to_uninitialized(to_type.default_value(), buffer);
+ to_type.copy_construct(to_type.default_value(), buffer);
}
this->add_value_to_input_socket(to_socket, from_socket, {to_type, buffer});
}
@@ -1230,7 +1238,7 @@ class GeometryNodesEvaluator {
const CPPType &type = *value_to_forward.type();
for (const DInputSocket &to_socket : to_sockets.drop_front(1)) {
void *buffer = allocator.allocate(type.size(), type.alignment());
- type.copy_to_uninitialized(value_to_forward.get(), buffer);
+ type.copy_construct(value_to_forward.get(), buffer);
this->add_value_to_input_socket(to_socket, from_socket, {type, buffer});
}
/* Forward the original value to one of the targets. */
@@ -1331,7 +1339,7 @@ class GeometryNodesEvaluator {
}
/* Use a default fallback value when the loaded type is not compatible. */
void *default_buffer = allocator.allocate(required_type.size(), required_type.alignment());
- required_type.copy_to_uninitialized(required_type.default_value(), default_buffer);
+ required_type.copy_construct(required_type.default_value(), default_buffer);
return {required_type, default_buffer};
}
@@ -1456,9 +1464,11 @@ Vector<GMutablePointer> NodeParamsProvider::extract_multi_input(StringRef identi
Vector<GMutablePointer> ret_values;
socket.foreach_origin_socket([&](DSocket origin) {
- for (const MultiInputValueItem &item : multi_value.items) {
- if (item.origin == origin) {
+ for (MultiInputValueItem &item : multi_value.items) {
+ if (item.origin == origin && item.value != nullptr) {
ret_values.append({*input_state.type, item.value});
+ /* Make sure we do not use the same value again if two values have the same origin. */
+ item.value = nullptr;
return;
}
}
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index 60c5667472e..62ac9d4452d 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -383,7 +383,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
vert_part_value[vindex] = p_random;
}
- /*change orientation based on object trackflag*/
+ /* Change orientation based on object trackflag. */
copy_v3_v3(temp_co, mv->co);
mv->co[axis] = temp_co[track];
mv->co[(axis + 1) % 3] = temp_co[(track + 1) % 3];
@@ -490,7 +490,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
mul_m4_v3(spacemat, mv->co);
}
- /* create edges and adjust edge vertex indices*/
+ /* Create edges and adjust edge vertex indices. */
CustomData_copy_data(&mesh->edata, &result->edata, 0, p_skip * totedge, totedge);
MEdge *me = &result->medge[p_skip * totedge];
for (k = 0; k < totedge; k++, me++) {
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index b236e0896b7..b90bf91dcb8 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -341,7 +341,6 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
#endif
}
else {
- /* exis char is used by i_rotate*/
axis_char = (char)(axis_char + ltmd->axis); /* 'X' + axis */
/* useful to be able to use the axis vec in some cases still */
@@ -518,7 +517,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
}
else {
- /*printf("\n\n\n\n\nStarting Modifier\n");*/
+ // printf("\n\n\n\n\nStarting Modifier\n");
/* set edge users */
med_new = medge_new;
mv_new = mvert_new;
@@ -539,7 +538,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
vc->co[other_axis_2] * vc->co[other_axis_2];
- /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/
+ // printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);
}
}
else {
@@ -556,7 +555,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] +
vc->co[other_axis_2] * vc->co[other_axis_2];
- /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/
+ // printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);
}
}
@@ -606,43 +605,43 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* compiler complains if not initialized, but it should be initialized below */
bool ed_loop_flip = false;
- /*printf("Loop on connected vert: %i\n", i);*/
+ // printf("Loop on connected vert: %i\n", i);
for (j = 0; j < 2; j++) {
- /*printf("\tSide: %i\n", j);*/
+ // printf("\tSide: %i\n", j);
screwvert_iter_init(&lt_iter, vert_connect, i, j);
if (j == 1) {
screwvert_iter_step(&lt_iter);
}
while (lt_iter.v_poin) {
- /*printf("\t\tVERT: %i\n", lt_iter.v);*/
+ // printf("\t\tVERT: %i\n", lt_iter.v);
if (lt_iter.v_poin->flag) {
- /*printf("\t\t\tBreaking Found end\n");*/
+ // printf("\t\t\tBreaking Found end\n");
// endpoints[0] = endpoints[1] = SV_UNUSED;
ed_loop_closed = 1; /* circle */
break;
}
lt_iter.v_poin->flag = 1;
vc_tot_linked++;
- /*printf("Testing 2 floats %f : %f\n", fl, lt_iter.v_poin->dist);*/
+ // printf("Testing 2 floats %f : %f\n", fl, lt_iter.v_poin->dist);
if (fl <= lt_iter.v_poin->dist) {
fl = lt_iter.v_poin->dist;
v_best = lt_iter.v;
- /*printf("\t\t\tVERT BEST: %i\n", v_best);*/
+ // printf("\t\t\tVERT BEST: %i\n", v_best);
}
screwvert_iter_step(&lt_iter);
if (!lt_iter.v_poin) {
- /*printf("\t\t\tFound End Also Num %i\n", j);*/
- /*endpoints[j] = lt_iter.v_other;*/ /* other is still valid */
+ // printf("\t\t\tFound End Also Num %i\n", j);
+ // endpoints[j] = lt_iter.v_other; /* other is still valid */
break;
}
}
}
- /* now we have a collection of used edges. flip their edges the right way*/
- /*if (v_best != SV_UNUSED) - */
+ /* Now we have a collection of used edges. flip their edges the right way. */
+ /* if (v_best != SV_UNUSED) - */
- /*printf("Done Looking - vc_tot_linked: %i\n", vc_tot_linked);*/
+ // printf("Done Looking - vc_tot_linked: %i\n", vc_tot_linked);
if (vc_tot_linked > 1) {
float vf_1, vf_2, vf_best;
@@ -654,8 +653,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* edge connects on each side! */
if (SV_IS_VALID(vc_tmp->v[0]) && SV_IS_VALID(vc_tmp->v[1])) {
- /*printf("Verts on each side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/
- /* find out which is higher */
+ // printf("Verts on each side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);
+ /* Find out which is higher. */
vf_1 = tmpf1[ltmd->axis];
vf_2 = tmpf2[ltmd->axis];
@@ -682,8 +681,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
}
}
- else if (SV_IS_VALID(vc_tmp->v[0])) { /*vertex only connected on 1 side */
- /*printf("Verts on ONE side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/
+ else if (SV_IS_VALID(vc_tmp->v[0])) { /* Vertex only connected on 1 side. */
+ // printf("Verts on ONE side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);
if (tmpf1[ltmd->axis] < vc_tmp->co[ltmd->axis]) { /* best is above */
ed_loop_flip = 1;
}
@@ -697,7 +696,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
#endif
- /*printf("flip direction %i\n", ed_loop_flip);*/
+ // printf("flip direction %i\n", ed_loop_flip);
/* Switch the flip option if set
* NOTE: flip is now done at face level so copying group slices is easier. */
@@ -713,10 +712,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* if its closed, we only need 1 loop */
for (j = ed_loop_closed; j < 2; j++) {
- /*printf("Ordering Side J %i\n", j);*/
+ // printf("Ordering Side J %i\n", j);
screwvert_iter_init(&lt_iter, vert_connect, v_best, j);
- /*printf("\n\nStarting - Loop\n");*/
+ // printf("\n\nStarting - Loop\n");
lt_iter.v_poin->flag = 1; /* so a non loop will traverse the other side */
/* If this is the vert off the best vert and
@@ -727,13 +726,13 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
while (lt_iter.v_poin && lt_iter.v_poin->flag != 2) {
- /*printf("\tOrdering Vert V %i\n", lt_iter.v);*/
+ // printf("\tOrdering Vert V %i\n", lt_iter.v);
lt_iter.v_poin->flag = 2;
if (lt_iter.e) {
if (lt_iter.v == lt_iter.e->v1) {
if (ed_loop_flip == 0) {
- /*printf("\t\t\tFlipping 0\n");*/
+ // printf("\t\t\tFlipping 0\n");
SWAP(uint, lt_iter.e->v1, lt_iter.e->v2);
}
#if 0
@@ -744,7 +743,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
else if (lt_iter.v == lt_iter.e->v2) {
if (ed_loop_flip == 1) {
- /*printf("\t\t\tFlipping 1\n");*/
+ // printf("\t\t\tFlipping 1\n");
SWAP(uint, lt_iter.e->v1, lt_iter.e->v2);
}
#if 0
diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c b/source/blender/modifiers/intern/MOD_solidify_extrude.c
index a77a6e595ad..95fb87bb54c 100644
--- a/source/blender/modifiers/intern/MOD_solidify_extrude.c
+++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c
@@ -199,7 +199,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
const uint numLoops = (uint)mesh->totloop;
uint newLoops = 0, newPolys = 0, newEdges = 0, newVerts = 0, rimVerts = 0;
- /* only use material offsets if we have 2 or more materials */
+ /* Only use material offsets if we have 2 or more materials. */
const short mat_nr_max = ctx->object->totcol > 1 ? ctx->object->totcol - 1 : 0;
const short mat_ofs = mat_nr_max ? smd->mat_ofs : 0;
const short mat_ofs_rim = mat_nr_max ? smd->mat_ofs_rim : 0;
@@ -424,7 +424,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)numPolys);
}
- /* initializes: (i_end, do_shell_align, mv) */
+ /* initializes: (i_end, do_shell_align, mv). */
#define INIT_VERT_ARRAY_OFFSETS(test) \
if (((ofs_new >= ofs_orig) == do_flip) == test) { \
i_end = numVerts; \
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index 4dc45ad0324..ce427281db3 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -351,7 +351,7 @@ static bool get_show_adaptive_options(const bContext *C, Panel *panel)
return false;
}
- /* Don't show adaptive options if regular subdivision used*/
+ /* Don't show adaptive options if regular subdivision used. */
if (!RNA_boolean_get(ptr, "use_limit_surface")) {
return false;
}
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 0cc68c2c4a3..dd011a293ee 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -675,7 +675,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
inf_weight_flags |= MOD_SDEF_INFINITE_WEIGHT_DIST_PROJ;
}
else {
- /* Compute angles between the point and the edge mid vectors. */
+ /* Compute angles between the point and the edge mid vectors. */
float cent_point_vec[2], point_angles[2];
sub_v2_v2v2(cent_point_vec, bpoly->point_v2, bpoly->centroid_v2);
diff --git a/source/blender/modifiers/intern/MOD_ui_common.c b/source/blender/modifiers/intern/MOD_ui_common.c
index 09fa7e9c8ac..9245afdb096 100644
--- a/source/blender/modifiers/intern/MOD_ui_common.c
+++ b/source/blender/modifiers/intern/MOD_ui_common.c
@@ -163,7 +163,7 @@ void modifier_vgroup_ui(uiLayout *layout,
* Check whether Modifier is a simulation or not. Used for switching to the
* physics/particles context tab.
*/
-static int modifier_is_simulation(ModifierData *md)
+static int modifier_is_simulation(const ModifierData *md)
{
/* Physic Tab */
if (ELEM(md->type,
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 724d1370a47..9f86727ce0a 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -169,7 +169,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
BKE_camera_params_init(&params);
BKE_camera_params_from_object(&params, projectors[i].ob);
- /* compute matrix, viewplane, .. */
+ /* Compute matrix, view-plane, etc. */
BKE_camera_params_compute_viewplane(&params, 1, 1, aspx, aspy);
/* scale the view-plane */
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index c6bab89247e..cf4c195c66d 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -271,7 +271,7 @@ static void waveModifier_do(WaveModifierData *md,
amplit = amplit * wmd->narrow;
amplit = (float)(1.0f / expf(amplit * amplit) - minfac);
- /*apply texture*/
+ /* Apply texture. */
if (tex_co) {
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
TexResult texres;
@@ -280,7 +280,7 @@ static void waveModifier_do(WaveModifierData *md,
amplit *= texres.tin;
}
- /*apply weight & falloff */
+ /* Apply weight & falloff. */
amplit *= def_weight * falloff_fac;
if (mvert) {
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index cd03175f16c..b0d2f52f78c 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -174,7 +174,7 @@ static void get_vert2geom_distance(int numVerts,
BVHTreeFromMesh treeData_f = {NULL};
if (dist_v) {
- /* Create a bvh-tree of the given target's verts. */
+ /* Create a BVH-tree of the given target's verts. */
BKE_bvhtree_from_mesh_get(&treeData_v, target, BVHTREE_FROM_VERTS, 2);
if (treeData_v.tree == NULL) {
OUT_OF_MEMORY();
@@ -182,7 +182,7 @@ static void get_vert2geom_distance(int numVerts,
}
}
if (dist_e) {
- /* Create a bvh-tree of the given target's edges. */
+ /* Create a BVH-tree of the given target's edges. */
BKE_bvhtree_from_mesh_get(&treeData_e, target, BVHTREE_FROM_EDGES, 2);
if (treeData_e.tree == NULL) {
OUT_OF_MEMORY();
@@ -190,7 +190,7 @@ static void get_vert2geom_distance(int numVerts,
}
}
if (dist_f) {
- /* Create a bvh-tree of the given target's faces. */
+ /* Create a BVH-tree of the given target's faces. */
BKE_bvhtree_from_mesh_get(&treeData_f, target, BVHTREE_FROM_LOOPTRI, 2);
if (treeData_f.tree == NULL) {
OUT_OF_MEMORY();
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 39f26737620..77d2f043b64 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -164,6 +164,11 @@ set(SRC
geometry/nodes/node_geo_common.cc
geometry/nodes/node_geo_convex_hull.cc
geometry/nodes/node_geo_curve_length.cc
+ geometry/nodes/node_geo_curve_primitive_bezier_segment.cc
+ geometry/nodes/node_geo_curve_primitive_circle.cc
+ geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc
+ geometry/nodes/node_geo_curve_primitive_spiral.cc
+ geometry/nodes/node_geo_curve_primitive_star.cc
geometry/nodes/node_geo_curve_to_mesh.cc
geometry/nodes/node_geo_curve_to_points.cc
geometry/nodes/node_geo_curve_resample.cc
diff --git a/source/blender/nodes/NOD_derived_node_tree.hh b/source/blender/nodes/NOD_derived_node_tree.hh
index de9e4c8c812..60d84463a82 100644
--- a/source/blender/nodes/NOD_derived_node_tree.hh
+++ b/source/blender/nodes/NOD_derived_node_tree.hh
@@ -104,7 +104,7 @@ class DNode {
* nested node group hierarchy. This type is small and can be passed around by value.
*
* A #DSocket can represent an input or an output socket. If the type of a socket is known at
- * compile time is is preferable to use #DInputSocket or #DOutputSocket instead. */
+ * compile time is preferable to use #DInputSocket or #DOutputSocket instead. */
class DSocket {
protected:
const DTreeContext *context_ = nullptr;
diff --git a/source/blender/nodes/NOD_geometry.h b/source/blender/nodes/NOD_geometry.h
index fddaaf6e640..3e41c37ca75 100644
--- a/source/blender/nodes/NOD_geometry.h
+++ b/source/blender/nodes/NOD_geometry.h
@@ -52,6 +52,11 @@ void register_node_type_geo_bounding_box(void);
void register_node_type_geo_collection_info(void);
void register_node_type_geo_convex_hull(void);
void register_node_type_geo_curve_length(void);
+void register_node_type_geo_curve_primitive_bezier_segment(void);
+void register_node_type_geo_curve_primitive_circle(void);
+void register_node_type_geo_curve_primitive_quadratic_bezier(void);
+void register_node_type_geo_curve_primitive_spiral(void);
+void register_node_type_geo_curve_primitive_star(void);
void register_node_type_geo_curve_to_mesh(void);
void register_node_type_geo_curve_to_points(void);
void register_node_type_geo_curve_resample(void);
diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh
index 7b176b2f395..23474201daa 100644
--- a/source/blender/nodes/NOD_geometry_exec.hh
+++ b/source/blender/nodes/NOD_geometry_exec.hh
@@ -294,7 +294,7 @@ class GeoNodeExecParams {
void check_input_access(StringRef identifier, const CPPType *requested_type = nullptr) const;
void check_output_access(StringRef identifier, const CPPType &value_type) const;
- /* Find the active socket socket with the input name (not the identifier). */
+ /* Find the active socket with the input name (not the identifier). */
const bNodeSocket *find_available_socket(const StringRef name) const;
};
diff --git a/source/blender/nodes/NOD_node_tree_ref.hh b/source/blender/nodes/NOD_node_tree_ref.hh
index b028fc28bbc..4f2565cbbaf 100644
--- a/source/blender/nodes/NOD_node_tree_ref.hh
+++ b/source/blender/nodes/NOD_node_tree_ref.hh
@@ -146,7 +146,7 @@ class InputSocketRef final : public SocketRef {
void foreach_logical_origin(FunctionRef<void(const OutputSocketRef &)> origin_fn,
FunctionRef<void(const SocketRef &)> skipped_fn,
bool only_follow_first_input_link,
- Vector<const InputSocketRef *> &handled_sockets) const;
+ Vector<const InputSocketRef *> &seen_sockets_stack) const;
};
class OutputSocketRef final : public SocketRef {
@@ -159,7 +159,7 @@ class OutputSocketRef final : public SocketRef {
private:
void foreach_logical_target(FunctionRef<void(const InputSocketRef &)> target_fn,
FunctionRef<void(const SocketRef &)> skipped_fn,
- Vector<const OutputSocketRef *> &handled_sockets) const;
+ Vector<const OutputSocketRef *> &seen_sockets_stack) const;
};
class NodeRef : NonCopyable, NonMovable {
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index d79fa7bffb3..f6063039bfc 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -291,6 +291,11 @@ DefNode(GeometryNode, GEO_NODE_BOUNDING_BOX, 0, "BOUNDING_BOX", BoundBox, "Bound
DefNode(GeometryNode, GEO_NODE_COLLECTION_INFO, def_geo_collection_info, "COLLECTION_INFO", CollectionInfo, "Collection Info", "")
DefNode(GeometryNode, GEO_NODE_CONVEX_HULL, 0, "CONVEX_HULL", ConvexHull, "Convex Hull", "")
DefNode(GeometryNode, GEO_NODE_CURVE_LENGTH, 0, "CURVE_LENGTH", CurveLength, "Curve Length", "")
+DefNode(GeometryNode, GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT, def_geo_curve_primitive_bezier_segment, "CURVE_PRIMITIVE_BEZIER_SEGMENT", CurvePrimitiveBezierSegment, "Bezier Segment", "")
+DefNode(GeometryNode, GEO_NODE_CURVE_PRIMITIVE_CIRCLE, def_geo_curve_primitive_circle, "CURVE_PRIMITIVE_CIRCLE", CurvePrimitiveCircle, "Circle", "")
+DefNode(GeometryNode, GEO_NODE_CURVE_PRIMITIVE_QUADRATIC_BEZIER, 0, "CURVE_PRIMITIVE_QUADRATIC_BEZIER", CurveQuadraticBezier, "Quadratic Bezier", "")
+DefNode(GeometryNode, GEO_NODE_CURVE_PRIMITIVE_STAR, 0, "CURVE_PRIMITIVE_STAR", CurveStar, "Star", "")
+DefNode(GeometryNode, GEO_NODE_CURVE_PRIMITIVE_SPIRAL, 0, "CURVE_PRIMITIVE_SPIRAL", CurveSpiral, "Curve Spiral", "")
DefNode(GeometryNode, GEO_NODE_CURVE_RESAMPLE, def_geo_curve_resample, "CURVE_RESAMPLE", CurveResample, "Resample Curve", "")
DefNode(GeometryNode, GEO_NODE_CURVE_SUBDIVIDE, def_geo_curve_subdivide, "CURVE_SUBDIVIDE", CurveSubdivide, "Curve Subdivide", "")
DefNode(GeometryNode, GEO_NODE_CURVE_TO_MESH, 0, "CURVE_TO_MESH", CurveToMesh, "Curve to Mesh", "")
diff --git a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c
index 29d6335e685..9912c10b368 100644
--- a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c
@@ -44,10 +44,10 @@ static void node_composit_init_channel_matte(bNodeTree *UNUSED(ntree), bNode *no
c->t3 = 0.0f;
c->fsize = 0.0f;
c->fstrength = 0.0f;
- c->algorithm = 1; /*max channel limiting */
- c->channel = 1; /* limit by red */
- node->custom1 = 1; /* RGB channel */
- node->custom2 = 2; /* Green Channel */
+ c->algorithm = 1; /* Max channel limiting. */
+ c->channel = 1; /* Limit by red. */
+ node->custom1 = 1; /* RGB channel. */
+ node->custom2 = 2; /* Green Channel. */
}
void register_node_type_cmp_channel_matte(void)
diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c
index 5e7a61377fb..7c70ccf412a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_levels.c
+++ b/source/blender/nodes/composite/nodes/node_composite_levels.c
@@ -37,7 +37,7 @@ static bNodeSocketTemplate cmp_node_view_levels_out[] = {
static void node_composit_init_view_levels(bNodeTree *UNUSED(ntree), bNode *node)
{
- node->custom1 = 1; /*All channels*/
+ node->custom1 = 1; /* All channels. */
}
void register_node_type_cmp_view_levels(void)
diff --git a/source/blender/nodes/composite/nodes/node_composite_rotate.c b/source/blender/nodes/composite/nodes/node_composite_rotate.c
index b1ed09966c0..7dd39d5eaa1 100644
--- a/source/blender/nodes/composite/nodes/node_composite_rotate.c
+++ b/source/blender/nodes/composite/nodes/node_composite_rotate.c
@@ -37,7 +37,7 @@ static bNodeSocketTemplate cmp_node_rotate_out[] = {
static void node_composit_init_rotate(bNodeTree *UNUSED(ntree), bNode *node)
{
- node->custom1 = 1; /* Bilinear Filter*/
+ node->custom1 = 1; /* Bilinear Filter. */
}
void register_node_type_cmp_rotate(void)
diff --git a/source/blender/nodes/geometry/node_geometry_exec.cc b/source/blender/nodes/geometry/node_geometry_exec.cc
index a24a6d7ad21..8bf7680c835 100644
--- a/source/blender/nodes/geometry/node_geometry_exec.cc
+++ b/source/blender/nodes/geometry/node_geometry_exec.cc
@@ -17,7 +17,7 @@
#include "FN_cpp_type_make.hh"
#include "NOD_geometry_exec.hh"
-MAKE_CPP_TYPE(GeometrySet, GeometrySet);
+MAKE_CPP_TYPE(GeometrySet, GeometrySet, CPPTypeFlags::Printable);
namespace blender::nodes {
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc
index 7b40456b180..60b5b91db19 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc
@@ -130,7 +130,7 @@ static void attribute_convert_calc(GeometryComponent &component,
const CPPType *cpp_type = bke::custom_data_type_to_cpp_type(result_type);
BLI_assert(cpp_type != nullptr);
- cpp_type->copy_to_initialized_n(source_span.data(), result_span.data(), result_span.size());
+ cpp_type->copy_assign_n(source_span.data(), result_span.data(), result_span.size());
result_attribute.save();
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc
index 06a4327a6c5..3b951bda95e 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc
@@ -108,15 +108,14 @@ static AttributeDomain get_result_domain(const GeometryComponent &component,
StringRef result_name)
{
/* Use the domain of the result attribute if it already exists. */
- ReadAttributeLookup result_attribute = component.attribute_try_get_for_read(result_name);
- if (result_attribute) {
- return result_attribute.domain;
+ std::optional<AttributeMetaData> result_info = component.attribute_get_meta_data(result_name);
+ if (result_info) {
+ return result_info->domain;
}
-
/* Otherwise use the input attribute's domain if it exists. */
- ReadAttributeLookup input_attribute = component.attribute_try_get_for_read(input_name);
- if (input_attribute) {
- return input_attribute.domain;
+ std::optional<AttributeMetaData> input_info = component.attribute_get_meta_data(input_name);
+ if (input_info) {
+ return input_info->domain;
}
return ATTR_DOMAIN_POINT;
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc
index b7863d38fc2..d71cb09f1bd 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc
@@ -143,8 +143,7 @@ static bool bvh_from_mesh(const Mesh *target_mesh,
break;
}
- /* This only updates a cache and can be considered to be logically const. */
- BKE_bvhtree_from_mesh_get(&r_tree_data_mesh, const_cast<Mesh *>(target_mesh), bvh_type, 2);
+ BKE_bvhtree_from_mesh_get(&r_tree_data_mesh, target_mesh, bvh_type, 2);
if (r_tree_data_mesh.tree == nullptr) {
return false;
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc
index eeb77abd624..15d419a003a 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc
@@ -189,6 +189,7 @@ Array<uint32_t> get_geometry_element_ids_as_uints(const GeometryComponent &compo
if (hash_attribute) {
BLI_assert(hashes.size() == hash_attribute->size());
const CPPType &cpp_type = hash_attribute->type();
+ BLI_assert(cpp_type.is_hashable());
GVArray_GSpan items{*hash_attribute};
threading::parallel_for(hashes.index_range(), 512, [&](IndexRange range) {
for (const int i : range) {
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_transfer.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_transfer.cc
index d1114713672..756f93f154f 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_transfer.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_transfer.cc
@@ -162,7 +162,7 @@ static void get_closest_mesh_points(const Mesh &mesh,
{
BLI_assert(mesh.totvert > 0);
BVHTreeFromMesh tree_data;
- BKE_bvhtree_from_mesh_get(&tree_data, const_cast<Mesh *>(&mesh), BVHTREE_FROM_VERTS, 2);
+ BKE_bvhtree_from_mesh_get(&tree_data, &mesh, BVHTREE_FROM_VERTS, 2);
get_closest_in_bvhtree(tree_data, positions, r_point_indices, r_distances_sq, r_positions);
free_bvhtree_from_mesh(&tree_data);
}
@@ -175,7 +175,7 @@ static void get_closest_mesh_edges(const Mesh &mesh,
{
BLI_assert(mesh.totedge > 0);
BVHTreeFromMesh tree_data;
- BKE_bvhtree_from_mesh_get(&tree_data, const_cast<Mesh *>(&mesh), BVHTREE_FROM_EDGES, 2);
+ BKE_bvhtree_from_mesh_get(&tree_data, &mesh, BVHTREE_FROM_EDGES, 2);
get_closest_in_bvhtree(tree_data, positions, r_edge_indices, r_distances_sq, r_positions);
free_bvhtree_from_mesh(&tree_data);
}
@@ -188,7 +188,7 @@ static void get_closest_mesh_looptris(const Mesh &mesh,
{
BLI_assert(mesh.totpoly > 0);
BVHTreeFromMesh tree_data;
- BKE_bvhtree_from_mesh_get(&tree_data, const_cast<Mesh *>(&mesh), BVHTREE_FROM_LOOPTRI, 2);
+ BKE_bvhtree_from_mesh_get(&tree_data, &mesh, BVHTREE_FROM_LOOPTRI, 2);
get_closest_in_bvhtree(tree_data, positions, r_looptri_indices, r_distances_sq, r_positions);
free_bvhtree_from_mesh(&tree_data);
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
index e2cf6e8b480..e017786ae89 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
@@ -389,9 +389,9 @@ static AttributeDomain get_result_domain(const GeometryComponent &component,
StringRef result_name)
{
/* Use the domain of the result attribute if it already exists. */
- ReadAttributeLookup result_attribute = component.attribute_try_get_for_read(result_name);
- if (result_attribute) {
- return result_attribute.domain;
+ std::optional<AttributeMetaData> result_info = component.attribute_get_meta_data(result_name);
+ if (result_info) {
+ return result_info->domain;
}
/* Otherwise use the highest priority domain from existing input attributes, or the default. */
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc
new file mode 100644
index 00000000000..e167219ea6b
--- /dev/null
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc
@@ -0,0 +1,149 @@
+/*
+ * 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.
+ */
+
+#include "BKE_spline.hh"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "node_geometry_util.hh"
+
+static bNodeSocketTemplate geo_node_curve_primitive_bezier_segment_in[] = {
+ {SOCK_INT, N_("Resolution"), 16.0f, 0.0f, 0.0f, 0.0f, 1, 256, PROP_UNSIGNED},
+ {SOCK_VECTOR, N_("Start"), -1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
+ {SOCK_VECTOR,
+ N_("Start Handle"),
+ -0.5f,
+ 0.5f,
+ 0.0f,
+ 0.0f,
+ -FLT_MAX,
+ FLT_MAX,
+ PROP_TRANSLATION},
+ {SOCK_VECTOR, N_("End Handle"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
+ {SOCK_VECTOR, N_("End"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
+ {-1, ""},
+};
+
+static bNodeSocketTemplate geo_node_curve_primitive_bezier_segment_out[] = {
+ {SOCK_GEOMETRY, N_("Curve")},
+ {-1, ""},
+};
+static void geo_node_curve_primitive_bezier_segment_layout(uiLayout *layout,
+ bContext *UNUSED(C),
+ PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
+}
+
+namespace blender::nodes {
+
+static void geo_node_curve_primitive_bezier_segment_init(bNodeTree *UNUSED(tree), bNode *node)
+{
+ NodeGeometryCurvePrimitiveBezierSegment *data = (NodeGeometryCurvePrimitiveBezierSegment *)
+ MEM_callocN(sizeof(NodeGeometryCurvePrimitiveBezierSegment), __func__);
+
+ data->mode = GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT_POSITION;
+ node->storage = data;
+}
+
+static std::unique_ptr<CurveEval> create_bezier_segment_curve(
+ const float3 start,
+ const float3 start_handle_right,
+ const float3 end,
+ const float3 end_handle_left,
+ const int resolution,
+ const GeometryNodeCurvePrimitiveBezierSegmentMode mode)
+{
+ std::unique_ptr<CurveEval> curve = std::make_unique<CurveEval>();
+ std::unique_ptr<BezierSpline> spline = std::make_unique<BezierSpline>();
+
+ if (mode == GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT_POSITION) {
+ spline->add_point(start,
+ BezierSpline::HandleType::Align,
+ start - (start_handle_right - start) * -1.0f,
+ BezierSpline::HandleType::Align,
+ start_handle_right,
+ 1.0f,
+ 0.0f);
+ spline->add_point(end,
+ BezierSpline::HandleType::Align,
+ end_handle_left,
+ BezierSpline::HandleType::Align,
+ end - (end_handle_left - end) * -1.0f,
+ 1.0f,
+ 0.0f);
+ }
+ else {
+ spline->add_point(start,
+ BezierSpline::HandleType::Align,
+ start - start_handle_right,
+ BezierSpline::HandleType::Align,
+ start + start_handle_right,
+ 1.0f,
+ 0.0f);
+ spline->add_point(end,
+ BezierSpline::HandleType::Align,
+ end + end_handle_left,
+ BezierSpline::HandleType::Align,
+ end - end_handle_left,
+ 1.0f,
+ 0.0f);
+ }
+
+ spline->set_resolution(resolution);
+ spline->attributes.reallocate(spline->size());
+ curve->add_spline(std::move(spline));
+ curve->attributes.reallocate(curve->splines().size());
+ return curve;
+}
+
+static void geo_node_curve_primitive_bezier_segment_exec(GeoNodeExecParams params)
+{
+ const NodeGeometryCurvePrimitiveBezierSegment *node_storage =
+ (NodeGeometryCurvePrimitiveBezierSegment *)params.node().storage;
+ const GeometryNodeCurvePrimitiveBezierSegmentMode mode =
+ (const GeometryNodeCurvePrimitiveBezierSegmentMode)node_storage->mode;
+
+ std::unique_ptr<CurveEval> curve = create_bezier_segment_curve(
+ params.extract_input<float3>("Start"),
+ params.extract_input<float3>("Start Handle"),
+ params.extract_input<float3>("End"),
+ params.extract_input<float3>("End Handle"),
+ std::max(params.extract_input<int>("Resolution"), 1),
+ mode);
+ params.set_output("Curve", GeometrySet::create_with_curve(curve.release()));
+}
+
+} // namespace blender::nodes
+
+void register_node_type_geo_curve_primitive_bezier_segment()
+{
+ static bNodeType ntype;
+ geo_node_type_base(
+ &ntype, GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT, "Bezier Segment", NODE_CLASS_GEOMETRY, 0);
+ node_type_socket_templates(&ntype,
+ geo_node_curve_primitive_bezier_segment_in,
+ geo_node_curve_primitive_bezier_segment_out);
+ node_type_init(&ntype, blender::nodes::geo_node_curve_primitive_bezier_segment_init);
+ node_type_storage(&ntype,
+ "NodeGeometryCurvePrimitiveBezierSegment",
+ node_free_standard_storage,
+ node_copy_standard_storage);
+ ntype.draw_buttons = geo_node_curve_primitive_bezier_segment_layout;
+ ntype.geometry_node_execute = blender::nodes::geo_node_curve_primitive_bezier_segment_exec;
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc
new file mode 100644
index 00000000000..963c48b7536
--- /dev/null
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc
@@ -0,0 +1,227 @@
+/*
+ * 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.
+ */
+
+#include "BKE_spline.hh"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "node_geometry_util.hh"
+
+static bNodeSocketTemplate geo_node_curve_primitive_circle_in[] = {
+ {SOCK_INT, N_("Resolution"), 32.0f, 0.0f, 0.0f, 0.0f, 3.0f, 512.0f},
+ {SOCK_VECTOR, N_("Point 1"), -1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
+ {SOCK_VECTOR, N_("Point 2"), 0.0f, 1.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
+ {SOCK_VECTOR, N_("Point 3"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
+ {SOCK_FLOAT, N_("Radius"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE},
+ {-1, ""},
+};
+
+static bNodeSocketTemplate geo_node_curve_primitive_circle_out[] = {
+ {SOCK_GEOMETRY, N_("Curve")},
+ {SOCK_VECTOR, N_("Center")},
+ {-1, ""},
+};
+
+static void geo_node_curve_primitive_circle_layout(uiLayout *layout,
+ bContext *UNUSED(C),
+ PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
+}
+
+namespace blender::nodes {
+
+static void geo_node_curve_primitive_circle_init(bNodeTree *UNUSED(tree), bNode *node)
+{
+ NodeGeometryCurvePrimitiveCircle *data = (NodeGeometryCurvePrimitiveCircle *)MEM_callocN(
+ sizeof(NodeGeometryCurvePrimitiveCircle), __func__);
+
+ data->mode = GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_RADIUS;
+ node->storage = data;
+}
+
+static void geo_node_curve_primitive_circle_update(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ const NodeGeometryCurvePrimitiveCircle *node_storage = (NodeGeometryCurvePrimitiveCircle *)
+ node->storage;
+ const GeometryNodeCurvePrimitiveCircleMode mode = (const GeometryNodeCurvePrimitiveCircleMode)
+ node_storage->mode;
+
+ bNodeSocket *start_socket = ((bNodeSocket *)node->inputs.first)->next;
+ bNodeSocket *middle_socket = start_socket->next;
+ bNodeSocket *end_socket = middle_socket->next;
+ bNodeSocket *radius_socket = end_socket->next;
+
+ bNodeSocket *center_socket = ((bNodeSocket *)node->outputs.first)->next;
+
+ nodeSetSocketAvailability(start_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS);
+ nodeSetSocketAvailability(middle_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS);
+ nodeSetSocketAvailability(end_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS);
+ nodeSetSocketAvailability(center_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS);
+ nodeSetSocketAvailability(radius_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_RADIUS);
+}
+
+static bool colinear_f3_f3_f3(const float3 p1, const float3 p2, const float3 p3)
+{
+ const float3 a = (p2 - p1).normalized();
+ const float3 b = (p3 - p1).normalized();
+ return (a == b || a == b * -1.0f);
+}
+
+static std::unique_ptr<CurveEval> create_point_circle_curve(
+ const float3 p1, const float3 p2, const float3 p3, const int resolution, float center_out[3])
+{
+ if (colinear_f3_f3_f3(p1, p2, p3)) {
+ return nullptr;
+ }
+
+ std::unique_ptr<CurveEval> curve = std::make_unique<CurveEval>();
+ std::unique_ptr<PolySpline> spline = std::make_unique<PolySpline>();
+
+ spline->resize(resolution);
+ MutableSpan<float3> positions = spline->positions();
+
+ float3 center;
+ /* Midpoints of `P1->P2` and `P2->P3`. */
+ const float3 q1 = float3::interpolate(p1, p2, 0.5f);
+ const float3 q2 = float3::interpolate(p2, p3, 0.5f);
+
+ /* Normal Vectors of `P1->P2` and `P2->P3` */
+ const float3 v1 = (p2 - p1).normalized();
+ const float3 v2 = (p3 - p2).normalized();
+
+ /* Normal of plane of main 2 segments P1->P2 and `P2->P3`. */
+ const float3 v3 = float3::cross(v1, v2).normalized();
+
+ /* Normal of plane of first perpendicular bisector and `P1->P2`. */
+ const float3 v4 = float3::cross(v3, v1).normalized();
+
+ /* Determine Center-point from the intersection of 3 planes. */
+ float plane_1[4], plane_2[4], plane_3[4];
+ plane_from_point_normal_v3(plane_1, q1, v3);
+ plane_from_point_normal_v3(plane_2, q1, v1);
+ plane_from_point_normal_v3(plane_3, q2, v2);
+
+ /* If the 3 planes do not intersect at one point, just return empty geometry. */
+ if (!isect_plane_plane_plane_v3(plane_1, plane_2, plane_3, center)) {
+ return nullptr;
+ }
+
+ /* Get the radius from the center-point to p1. */
+ const float r = float3::distance(p1, center);
+ const float theta_step = ((2 * M_PI) / (float)resolution);
+ for (const int i : IndexRange(resolution)) {
+
+ /* Formula for a circle around a point and 2 unit vectors perpendicular.
+ * to each other and the axis of the circle from:
+ * https://math.stackexchange.com/questions/73237/parametric-equation-of-a-circle-in-3d-space
+ */
+
+ const float theta = theta_step * i;
+ positions[i] = center + r * cos(theta) * v1 + r * sin(theta) * v4;
+ }
+
+ spline->radii().fill(1.0f);
+ spline->tilts().fill(0.0f);
+ spline->set_cyclic(true);
+ curve->add_spline(std::move(spline));
+ curve->attributes.reallocate(curve->splines().size());
+
+ copy_v3_v3(center_out, center);
+ return curve;
+}
+
+static std::unique_ptr<CurveEval> create_radius_circle_curve(const int resolution,
+ const float radius)
+{
+ std::unique_ptr<CurveEval> curve = std::make_unique<CurveEval>();
+ std::unique_ptr<PolySpline> spline = std::make_unique<PolySpline>();
+
+ spline->resize(resolution);
+ MutableSpan<float3> positions = spline->positions();
+
+ const float theta_step = (2.0f * M_PI) / float(resolution);
+ for (int i : IndexRange(resolution)) {
+ const float theta = theta_step * i;
+ const float x = radius * cos(theta);
+ const float y = radius * sin(theta);
+ positions[i] = float3(x, y, 0.0f);
+ }
+ spline->radii().fill(1.0f);
+ spline->tilts().fill(0.0f);
+ spline->set_cyclic(true);
+ curve->add_spline(std::move(spline));
+ curve->attributes.reallocate(curve->splines().size());
+ return curve;
+}
+
+static void geo_node_curve_primitive_circle_exec(GeoNodeExecParams params)
+{
+ const NodeGeometryCurvePrimitiveCircle *node_storage =
+ (NodeGeometryCurvePrimitiveCircle *)params.node().storage;
+
+ const GeometryNodeCurvePrimitiveCircleMode mode = (GeometryNodeCurvePrimitiveCircleMode)
+ node_storage->mode;
+
+ std::unique_ptr<CurveEval> curve;
+ if (mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS) {
+ float center_point[3];
+ curve = create_point_circle_curve(params.extract_input<float3>("Point 1"),
+ params.extract_input<float3>("Point 2"),
+ params.extract_input<float3>("Point 3"),
+ std::max(params.extract_input<int>("Resolution"), 3),
+ center_point);
+ if (curve) {
+ params.set_output("Center", float3(center_point));
+ }
+ else {
+ params.set_output("Center", float3(0, 0, 0));
+ }
+ }
+ else if (mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_RADIUS) {
+ curve = create_radius_circle_curve(std::max(params.extract_input<int>("Resolution"), 3),
+ params.extract_input<float>("Radius"));
+ }
+
+ if (curve) {
+ params.set_output("Curve", GeometrySet::create_with_curve(curve.release()));
+ }
+ else {
+ params.set_output("Curve", GeometrySet());
+ }
+}
+
+} // namespace blender::nodes
+
+void register_node_type_geo_curve_primitive_circle()
+{
+ static bNodeType ntype;
+ geo_node_type_base(&ntype, GEO_NODE_CURVE_PRIMITIVE_CIRCLE, "Circle", NODE_CLASS_GEOMETRY, 0);
+ node_type_socket_templates(
+ &ntype, geo_node_curve_primitive_circle_in, geo_node_curve_primitive_circle_out);
+
+ node_type_init(&ntype, blender::nodes::geo_node_curve_primitive_circle_init);
+ node_type_update(&ntype, blender::nodes::geo_node_curve_primitive_circle_update);
+ node_type_storage(&ntype,
+ "NodeGeometryCurvePrimitiveCircle",
+ node_free_standard_storage,
+ node_copy_standard_storage);
+
+ ntype.geometry_node_execute = blender::nodes::geo_node_curve_primitive_circle_exec;
+ ntype.draw_buttons = geo_node_curve_primitive_circle_layout;
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc
new file mode 100644
index 00000000000..10211cb2287
--- /dev/null
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+#include "BKE_spline.hh"
+#include "node_geometry_util.hh"
+
+static bNodeSocketTemplate geo_node_curve_primitive_quadratic_bezier_in[] = {
+ {SOCK_INT, N_("Resolution"), 16.0f, 0.0f, 0.0f, 0.0f, 3, 256, PROP_UNSIGNED},
+ {SOCK_VECTOR, N_("Start"), -1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
+ {SOCK_VECTOR, N_("Middle"), 0.0f, 2.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
+ {SOCK_VECTOR, N_("End"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
+ {-1, ""},
+};
+
+static bNodeSocketTemplate geo_node_curve_primitive_quadratic_bezier_out[] = {
+ {SOCK_GEOMETRY, N_("Curve")},
+ {-1, ""},
+};
+
+namespace blender::nodes {
+
+static std::unique_ptr<CurveEval> create_quadratic_bezier_curve(const float3 p1,
+ const float3 p2,
+ const float3 p3,
+ const int resolution)
+{
+ std::unique_ptr<CurveEval> curve = std::make_unique<CurveEval>();
+ std::unique_ptr<PolySpline> spline = std::make_unique<PolySpline>();
+
+ const float step = 1.0f / resolution;
+ for (int i : IndexRange(resolution + 1)) {
+ const float factor = step * i;
+ const float3 q1 = float3::interpolate(p1, p2, factor);
+ const float3 q2 = float3::interpolate(p2, p3, factor);
+ const float3 out = float3::interpolate(q1, q2, factor);
+ spline->add_point(out, 1.0f, 0.0f);
+ }
+ spline->attributes.reallocate(spline->size());
+ curve->add_spline(std::move(spline));
+ curve->attributes.reallocate(curve->splines().size());
+ return curve;
+}
+
+static void geo_node_curve_primitive_quadratic_bezier_exec(GeoNodeExecParams params)
+{
+ std::unique_ptr<CurveEval> curve = create_quadratic_bezier_curve(
+ params.extract_input<float3>("Start"),
+ params.extract_input<float3>("Middle"),
+ params.extract_input<float3>("End"),
+ std::max(params.extract_input<int>("Resolution"), 3));
+ params.set_output("Curve", GeometrySet::create_with_curve(curve.release()));
+}
+
+} // namespace blender::nodes
+
+void register_node_type_geo_curve_primitive_quadratic_bezier()
+{
+ static bNodeType ntype;
+ geo_node_type_base(&ntype,
+ GEO_NODE_CURVE_PRIMITIVE_QUADRATIC_BEZIER,
+ "Quadratic Bezier",
+ NODE_CLASS_GEOMETRY,
+ 0);
+ node_type_socket_templates(&ntype,
+ geo_node_curve_primitive_quadratic_bezier_in,
+ geo_node_curve_primitive_quadratic_bezier_out);
+ ntype.geometry_node_execute = blender::nodes::geo_node_curve_primitive_quadratic_bezier_exec;
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc
new file mode 100644
index 00000000000..8e25fb7f403
--- /dev/null
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+
+#include "BKE_spline.hh"
+
+#include "node_geometry_util.hh"
+
+static bNodeSocketTemplate geo_node_curve_primitive_spiral_in[] = {
+ {SOCK_INT, N_("Resolution"), 32.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1024.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, N_("Rotations"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_FLOAT},
+ {SOCK_FLOAT, N_("Start Radius"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE},
+ {SOCK_FLOAT, N_("End Radius"), 2.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE},
+ {SOCK_FLOAT, N_("Height"), 2.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE},
+ {SOCK_BOOLEAN, N_("Reverse")},
+ {-1, ""},
+};
+
+static bNodeSocketTemplate geo_node_curve_primitive_spiral_out[] = {
+ {SOCK_GEOMETRY, N_("Curve")},
+ {-1, ""},
+};
+
+namespace blender::nodes {
+
+static std::unique_ptr<CurveEval> create_spiral_curve(const float rotations,
+ const int resolution,
+ const float start_radius,
+ const float end_radius,
+ const float height,
+ const bool direction)
+{
+ std::unique_ptr<CurveEval> curve = std::make_unique<CurveEval>();
+ std::unique_ptr<PolySpline> spline = std::make_unique<PolySpline>();
+
+ const int totalpoints = resolution * rotations;
+ const float delta_radius = (end_radius - start_radius) / (float)totalpoints;
+ float radius = start_radius;
+ const float delta_height = height / (float)totalpoints;
+ const float delta_theta = (M_PI * 2 * rotations) / (float)totalpoints;
+ float theta = 0.0f;
+
+ for (const int i : IndexRange(totalpoints + 1)) {
+ const float x = radius * cos(theta);
+ const float y = radius * sin(theta);
+ const float z = delta_height * i;
+
+ spline->add_point(float3(x, y, z), 1.0f, 0.0f);
+
+ radius += delta_radius;
+
+ if (direction) {
+ theta += delta_theta;
+ }
+ else {
+ theta -= delta_theta;
+ }
+ }
+
+ spline->attributes.reallocate(spline->size());
+ curve->add_spline(std::move(spline));
+ curve->attributes.reallocate(curve->splines().size());
+ return curve;
+}
+
+static void geo_node_curve_primitive_spiral_exec(GeoNodeExecParams params)
+{
+ const float rotations = std::max(params.extract_input<float>("Rotations"), 0.0f);
+ if (rotations == 0.0f) {
+ params.set_output("Curve", GeometrySet());
+ return;
+ }
+
+ std::unique_ptr<CurveEval> curve = create_spiral_curve(
+ rotations,
+ std::max(params.extract_input<int>("Resolution"), 1),
+ params.extract_input<float>("Start Radius"),
+ params.extract_input<float>("End Radius"),
+ params.extract_input<float>("Height"),
+ params.extract_input<bool>("Reverse"));
+ params.set_output("Curve", GeometrySet::create_with_curve(curve.release()));
+}
+
+} // namespace blender::nodes
+
+void register_node_type_geo_curve_primitive_spiral()
+{
+ static bNodeType ntype;
+
+ geo_node_type_base(&ntype, GEO_NODE_CURVE_PRIMITIVE_SPIRAL, "Spiral", NODE_CLASS_GEOMETRY, 0);
+ node_type_socket_templates(
+ &ntype, geo_node_curve_primitive_spiral_in, geo_node_curve_primitive_spiral_out);
+ ntype.geometry_node_execute = blender::nodes::geo_node_curve_primitive_spiral_exec;
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc
new file mode 100644
index 00000000000..367da3bc3c2
--- /dev/null
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+#include "BKE_spline.hh"
+
+#include "node_geometry_util.hh"
+
+static bNodeSocketTemplate geo_node_curve_primitive_star_in[] = {
+ {SOCK_INT, N_("Points"), 8.0f, 0.0f, 0.0f, 0.0f, 4, 256, PROP_UNSIGNED},
+ {SOCK_FLOAT, N_("Inner Radius"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE},
+ {SOCK_FLOAT, N_("Outer Radius"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE},
+ {SOCK_FLOAT, N_("Twist"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_ANGLE},
+ {-1, ""},
+};
+
+static bNodeSocketTemplate geo_node_curve_primitive_star_out[] = {
+ {SOCK_GEOMETRY, N_("Curve")},
+ {-1, ""},
+};
+
+namespace blender::nodes {
+
+static std::unique_ptr<CurveEval> create_star_curve(const float inner_radius,
+ const float outer_radius,
+ const float twist,
+ const int points)
+{
+ std::unique_ptr<CurveEval> curve = std::make_unique<CurveEval>();
+ std::unique_ptr<PolySpline> spline = std::make_unique<PolySpline>();
+
+ const float theta_step = (2.0f * M_PI) / float(points);
+ for (int i : IndexRange(points)) {
+ const float x = outer_radius * cos(theta_step * i);
+ const float y = outer_radius * sin(theta_step * i);
+ spline->add_point(float3(x, y, 0.0f), 1.0f, 0.0f);
+
+ const float inner_x = inner_radius * cos(theta_step * i + theta_step * 0.5f + twist);
+ const float inner_y = inner_radius * sin(theta_step * i + theta_step * 0.5f + twist);
+ spline->add_point(float3(inner_x, inner_y, 0.0f), 1.0f, 0.0f);
+ }
+ spline->set_cyclic(true);
+ spline->attributes.reallocate(spline->size());
+ curve->add_spline(std::move(spline));
+ curve->attributes.reallocate(curve->splines().size());
+ return curve;
+}
+
+static void geo_node_curve_primitive_star_exec(GeoNodeExecParams params)
+{
+ std::unique_ptr<CurveEval> curve = create_star_curve(
+ std::max(params.extract_input<float>("Inner Radius"), 0.0f),
+ std::max(params.extract_input<float>("Outer Radius"), 0.0f),
+ params.extract_input<float>("Twist"),
+ std::max(params.extract_input<int>("Points"), 4));
+ params.set_output("Curve", GeometrySet::create_with_curve(curve.release()));
+}
+
+} // namespace blender::nodes
+
+void register_node_type_geo_curve_primitive_star()
+{
+ static bNodeType ntype;
+ geo_node_type_base(&ntype, GEO_NODE_CURVE_PRIMITIVE_STAR, "Star", NODE_CLASS_GEOMETRY, 0);
+ node_type_socket_templates(
+ &ntype, geo_node_curve_primitive_star_in, geo_node_curve_primitive_star_out);
+ ntype.geometry_node_execute = blender::nodes::geo_node_curve_primitive_star_exec;
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc
index c0d817385e2..159c4fffb57 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc
@@ -337,7 +337,17 @@ static void geo_node_curve_to_mesh_exec(GeoNodeExecParams params)
curve_set = bke::geometry_set_realize_instances(curve_set);
profile_set = bke::geometry_set_realize_instances(profile_set);
+ /* Note: Theoretically an "is empty" check would be more correct for errors. */
+ if (profile_set.has_mesh() && !profile_set.has_curve()) {
+ params.error_message_add(NodeWarningType::Warning,
+ TIP_("No curve data available in profile input"));
+ }
+
if (!curve_set.has_curve()) {
+ if (curve_set.has_mesh()) {
+ params.error_message_add(NodeWarningType::Warning,
+ TIP_("No curve data available in curve input"));
+ }
params.set_output("Mesh", GeometrySet());
return;
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
index 2725c625913..e37822bd262 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
@@ -298,7 +298,7 @@ static void copy_spline_domain_attributes(const CurveComponent &curve_component,
if (size != 0) {
BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
spline_attribute->get(i, buffer);
- type.fill_initialized(buffer, result[offset], size);
+ type.fill_assign_n(buffer, result[offset], size);
}
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
index bc758b59987..730cf08feaa 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
@@ -208,7 +208,7 @@ static void fill_new_attribute(Span<const GeometryComponent *> src_components,
GVArray_GSpan src_span{*read_attribute};
const void *src_buffer = src_span.data();
void *dst_buffer = dst_span[offset];
- cpp_type->copy_to_initialized_n(src_buffer, dst_buffer, domain_size);
+ cpp_type->copy_assign_n(src_buffer, dst_buffer, domain_size);
offset += domain_size;
}
@@ -353,7 +353,7 @@ static void ensure_control_point_attribute(const StringRef name,
BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
current_curve_attribute->get(spline_index_in_component, buffer);
- type.fill_initialized(buffer, new_attribute->data(), new_attribute->size());
+ type.fill_assign_n(buffer, new_attribute->data(), new_attribute->size());
}
}
@@ -392,7 +392,7 @@ static void ensure_spline_attribute(const StringRef name,
GVArray_GSpan src_span{*read_attribute};
const void *src_buffer = src_span.data();
- type.copy_to_initialized_n(src_buffer, result_attribute[offset], size);
+ type.copy_assign_n(src_buffer, result_attribute[offset], size);
offset += size;
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
index 772bd8a1080..d456c72744f 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
@@ -83,8 +83,7 @@ static float3 normal_to_euler_rotation(const float3 normal)
static Span<MLoopTri> get_mesh_looptris(const Mesh &mesh)
{
- /* This only updates a cache and can be considered to be logically const. */
- const MLoopTri *looptris = BKE_mesh_runtime_looptri_ensure(const_cast<Mesh *>(&mesh));
+ const MLoopTri *looptris = BKE_mesh_runtime_looptri_ensure(&mesh);
const int looptris_len = BKE_mesh_runtime_looptri_len(&mesh);
return {looptris, looptris_len};
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc
index bfd6027e0fc..0c1d8645411 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc
@@ -95,7 +95,7 @@ static void raycast_to_mesh(const Mesh *mesh,
BLI_assert(ray_origins.size() == r_hit_distances.size() || r_hit_distances.is_empty());
BVHTreeFromMesh tree_data;
- BKE_bvhtree_from_mesh_get(&tree_data, const_cast<Mesh *>(mesh), BVHTREE_FROM_LOOPTRI, 4);
+ BKE_bvhtree_from_mesh_get(&tree_data, mesh, BVHTREE_FROM_LOOPTRI, 4);
if (tree_data.tree != nullptr) {
for (const int i : ray_origins.index_range()) {
diff --git a/source/blender/nodes/intern/derived_node_tree.cc b/source/blender/nodes/intern/derived_node_tree.cc
index 9a3eb574bcd..3d5557d4049 100644
--- a/source/blender/nodes/intern/derived_node_tree.cc
+++ b/source/blender/nodes/intern/derived_node_tree.cc
@@ -230,7 +230,7 @@ void DInputSocket::foreach_origin_socket(FunctionRef<void(DSocket)> origin_fn) c
/* Calls `target_fn` for every "real" target socket. "Real" means that reroutes, muted nodes
* and node groups are handled by this function. Target sockets are on the nodes that use the value
* from this socket. The `skipped_fn` function is called for sockets that have been skipped during
- * the search for target sockets (e.g. reroutes). */
+ * the search for target sockets (e.g. reroutes). */
void DOutputSocket::foreach_target_socket(FunctionRef<void(DInputSocket)> target_fn,
FunctionRef<void(DSocket)> skipped_fn) const
{
diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc
index d00bf636e15..9f0a145ace2 100644
--- a/source/blender/nodes/intern/node_socket.cc
+++ b/source/blender/nodes/intern/node_socket.cc
@@ -662,10 +662,10 @@ static bNodeSocketType *make_socket_type_string()
return socktype;
}
-MAKE_CPP_TYPE(Object, Object *)
-MAKE_CPP_TYPE(Collection, Collection *)
-MAKE_CPP_TYPE(Texture, Tex *)
-MAKE_CPP_TYPE(Material, Material *)
+MAKE_CPP_TYPE(Object, Object *, CPPTypeFlags::BasicType)
+MAKE_CPP_TYPE(Collection, Collection *, CPPTypeFlags::BasicType)
+MAKE_CPP_TYPE(Texture, Tex *, CPPTypeFlags::BasicType)
+MAKE_CPP_TYPE(Material, Material *, CPPTypeFlags::BasicType)
static bNodeSocketType *make_socket_type_object()
{
diff --git a/source/blender/nodes/intern/node_tree_ref.cc b/source/blender/nodes/intern/node_tree_ref.cc
index 154ee716153..bed4d60382d 100644
--- a/source/blender/nodes/intern/node_tree_ref.cc
+++ b/source/blender/nodes/intern/node_tree_ref.cc
@@ -176,12 +176,12 @@ void NodeTreeRef::create_linked_socket_caches()
/* Find logically linked sockets. */
Vector<const SocketRef *> logically_linked_sockets;
Vector<const SocketRef *> logically_linked_skipped_sockets;
- Vector<const InputSocketRef *> handled_sockets;
+ Vector<const InputSocketRef *> seen_sockets_stack;
socket->foreach_logical_origin(
[&](const OutputSocketRef &origin) { logically_linked_sockets.append(&origin); },
[&](const SocketRef &socket) { logically_linked_skipped_sockets.append(&socket); },
false,
- handled_sockets);
+ seen_sockets_stack);
if (logically_linked_sockets == directly_linked_sockets) {
socket->logically_linked_sockets_ = socket->directly_linked_sockets_;
}
@@ -222,16 +222,17 @@ void NodeTreeRef::create_linked_socket_caches()
}
}
-void InputSocketRef::foreach_logical_origin(FunctionRef<void(const OutputSocketRef &)> origin_fn,
- FunctionRef<void(const SocketRef &)> skipped_fn,
- bool only_follow_first_input_link,
- Vector<const InputSocketRef *> &handled_sockets) const
+void InputSocketRef::foreach_logical_origin(
+ FunctionRef<void(const OutputSocketRef &)> origin_fn,
+ FunctionRef<void(const SocketRef &)> skipped_fn,
+ bool only_follow_first_input_link,
+ Vector<const InputSocketRef *> &seen_sockets_stack) const
{
/* Protect against loops. */
- if (handled_sockets.contains(this)) {
+ if (seen_sockets_stack.contains(this)) {
return;
}
- handled_sockets.append(this);
+ seen_sockets_stack.append(this);
Span<const LinkRef *> links_to_check = this->directly_linked_links();
if (only_follow_first_input_link) {
@@ -251,7 +252,7 @@ void InputSocketRef::foreach_logical_origin(FunctionRef<void(const OutputSocketR
const OutputSocketRef &reroute_output = origin_node.output(0);
skipped_fn.call_safe(reroute_input);
skipped_fn.call_safe(reroute_output);
- reroute_input.foreach_logical_origin(origin_fn, skipped_fn, false, handled_sockets);
+ reroute_input.foreach_logical_origin(origin_fn, skipped_fn, false, seen_sockets_stack);
}
else if (origin_node.is_muted()) {
for (const InternalLinkRef *internal_link : origin_node.internal_links()) {
@@ -259,7 +260,7 @@ void InputSocketRef::foreach_logical_origin(FunctionRef<void(const OutputSocketR
const InputSocketRef &mute_input = internal_link->from();
skipped_fn.call_safe(origin);
skipped_fn.call_safe(mute_input);
- mute_input.foreach_logical_origin(origin_fn, skipped_fn, true, handled_sockets);
+ mute_input.foreach_logical_origin(origin_fn, skipped_fn, true, seen_sockets_stack);
break;
}
}
@@ -268,18 +269,20 @@ void InputSocketRef::foreach_logical_origin(FunctionRef<void(const OutputSocketR
origin_fn(origin);
}
}
+
+ seen_sockets_stack.pop_last();
}
void OutputSocketRef::foreach_logical_target(
FunctionRef<void(const InputSocketRef &)> target_fn,
FunctionRef<void(const SocketRef &)> skipped_fn,
- Vector<const OutputSocketRef *> &handled_sockets) const
+ Vector<const OutputSocketRef *> &seen_sockets_stack) const
{
/* Protect against loops. */
- if (handled_sockets.contains(this)) {
+ if (seen_sockets_stack.contains(this)) {
return;
}
- handled_sockets.append(this);
+ seen_sockets_stack.append(this);
for (const LinkRef *link : this->directly_linked_links()) {
if (link->is_muted()) {
@@ -294,7 +297,7 @@ void OutputSocketRef::foreach_logical_target(
const OutputSocketRef &reroute_output = target_node.output(0);
skipped_fn.call_safe(target);
skipped_fn.call_safe(reroute_output);
- reroute_output.foreach_logical_target(target_fn, skipped_fn, handled_sockets);
+ reroute_output.foreach_logical_target(target_fn, skipped_fn, seen_sockets_stack);
}
else if (target_node.is_muted()) {
skipped_fn.call_safe(target);
@@ -309,7 +312,7 @@ void OutputSocketRef::foreach_logical_target(
const OutputSocketRef &mute_output = internal_link->to();
skipped_fn.call_safe(target);
skipped_fn.call_safe(mute_output);
- mute_output.foreach_logical_target(target_fn, skipped_fn, handled_sockets);
+ mute_output.foreach_logical_target(target_fn, skipped_fn, seen_sockets_stack);
}
}
}
@@ -317,6 +320,8 @@ void OutputSocketRef::foreach_logical_target(
target_fn(target);
}
}
+
+ seen_sockets_stack.pop_last();
}
namespace {
@@ -336,7 +341,7 @@ static std::unique_ptr<SocketIndexByIdentifierMap> create_identifier_map(const L
return map;
}
-/* This function is not threadsafe. */
+/* This function is not threadsafe. */
static SocketByIdentifierMap get_or_create_identifier_map(
const bNode &node, const ListBase &sockets, const bNodeSocketTemplate *sockets_template)
{
diff --git a/source/blender/nodes/intern/type_conversions.cc b/source/blender/nodes/intern/type_conversions.cc
index 220e5ea9046..1a71a3418a5 100644
--- a/source/blender/nodes/intern/type_conversions.cc
+++ b/source/blender/nodes/intern/type_conversions.cc
@@ -231,7 +231,7 @@ void DataTypeConversions::convert_to_uninitialized(const CPPType &from_type,
void *to_value) const
{
if (from_type == to_type) {
- from_type.copy_to_uninitialized(from_value, to_value);
+ from_type.copy_construct(from_value, to_value);
return;
}
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index 5ec982c4e7f..e23e2ac3b9d 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -398,7 +398,7 @@ static void ntree_shader_groups_expand_inputs(bNodeTree *localtree)
if (socket->link != NULL && !(socket->link->flag & NODE_LINK_MUTED)) {
bNodeLink *link = socket->link;
/* Fix the case where the socket is actually converting the data. (see T71374)
- * We only do the case of lossy conversion to float.*/
+ * We only do the case of lossy conversion to float. */
if ((socket->type == SOCK_FLOAT) && (link->fromsock->type != link->tosock->type)) {
if (link->fromsock->type == SOCK_RGBA) {
bNode *tmp = nodeAddStaticNode(NULL, localtree, SH_NODE_RGBTOBW);
diff --git a/source/blender/nodes/shader/nodes/node_shader_hair_info.c b/source/blender/nodes/shader/nodes/node_shader_hair_info.c
index fe1361e0d78..843185befb6 100644
--- a/source/blender/nodes/shader/nodes/node_shader_hair_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_hair_info.c
@@ -24,7 +24,7 @@ static bNodeSocketTemplate outputs[] = {
{SOCK_FLOAT, N_("Intercept"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{SOCK_FLOAT, N_("Thickness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{SOCK_VECTOR, N_("Tangent Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- /*{ SOCK_FLOAT, 0, N_("Fade"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},*/
+ // { SOCK_FLOAT, 0, N_("Fade"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{SOCK_FLOAT, N_("Random")},
{-1, ""},
};
diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c
index b23891ca1fe..01914992f3e 100644
--- a/source/blender/python/bmesh/bmesh_py_ops.c
+++ b/source/blender/python/bmesh/bmesh_py_ops.c
@@ -228,12 +228,12 @@ static PyTypeObject bmesh_op_Type = {
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c
index 28daf08507d..d198c6ca559 100644
--- a/source/blender/python/bmesh/bmesh_py_ops_call.c
+++ b/source/blender/python/bmesh/bmesh_py_ops_call.c
@@ -252,7 +252,7 @@ static int bpy_slot_from_py(BMesh *bm,
const ushort size = pymat->num_col;
if ((size != pymat->num_row) || (!ELEM(size, 3, 4))) {
PyErr_Format(PyExc_TypeError,
- "%.200s: keyword \"%.200s\" expected a 3x3 or 4x4 matrix Matrix",
+ "%.200s: keyword \"%.200s\" expected a 3x3 or 4x4 matrix",
opname,
slot_name);
return -1;
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.h b/source/blender/python/bmesh/bmesh_py_ops_call.h
index 6d9ceec73f6..1c7a35788d2 100644
--- a/source/blender/python/bmesh/bmesh_py_ops_call.h
+++ b/source/blender/python/bmesh/bmesh_py_ops_call.h
@@ -24,8 +24,8 @@
#pragma once
typedef struct {
- PyObject_HEAD /* required python macro */
- const char *opname;
+ PyObject_HEAD /* Required Python macro. */
+ const char *opname;
} BPy_BMeshOpFunc;
PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw);
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 323661e7ca9..9334e9893b0 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -1060,7 +1060,7 @@ static PyObject *bpy_bmesh_to_mesh(BPy_BMesh *self, PyObject *args)
/* we could have the user do this but if they forget blender can easy crash
* since the references arrays for the objects derived meshes are now invalid */
- DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY_ALL_MODES);
Py_RETURN_NONE;
}
@@ -3354,7 +3354,7 @@ static void bpy_bmesh_dealloc(BPy_BMesh *self)
{
BMesh *bm = self->bm;
- /* have have been freed by bmesh */
+ /* The mesh has not been freed by #BMesh. */
if (bm) {
bm_dealloc_editmode_warn(self);
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index 78c43d18609..ff06cf43026 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -78,7 +78,7 @@ static CustomDataLayer *bpy_bmlayeritem_get(BPy_BMLayerItem *self)
/* getseters
* ========= */
-/* used for many different types */
+/* used for many different types. */
PyDoc_STRVAR(bpy_bmlayeraccess_collection__float_doc,
"Generic float custom-data layer.\n\ntype: :class:`BMLayerCollection`");
diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
index 84267a83a44..d9a82f52be0 100644
--- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
@@ -97,7 +97,7 @@ static int bpy_bmloopuv_flag_set(BPy_BMLoopUV *self, PyObject *value, void *flag
}
static PyGetSetDef bpy_bmloopuv_getseters[] = {
- /* attributes match rna_def_mloopuv */
+ /* attributes match rna_def_mloopuv. */
{"uv", (getter)bpy_bmloopuv_uv_get, (setter)bpy_bmloopuv_uv_set, bpy_bmloopuv_uv_doc, NULL},
{"pin_uv",
(getter)bpy_bmloopuv_flag_get,
@@ -207,7 +207,7 @@ static int bpy_bmvertskin_flag_set(BPy_BMVertSkin *self, PyObject *value, void *
}
static PyGetSetDef bpy_bmvertskin_getseters[] = {
- /* attributes match rna_mesh_gen */
+ /* attributes match rna_mesh_gen. */
{"radius",
(getter)bpy_bmvertskin_radius_get,
(setter)bpy_bmvertskin_radius_set,
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index e9a58288c5e..e416727fa70 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -41,7 +41,7 @@
/** \name Local utility defines for wrapping OpenGL
* \{ */
-/*@ By golly George! It looks like fancy pants macro time!!! */
+/* By golly George! It looks like fancy pants macro time! */
/* TYPE_str is the string to pass to Py_ArgParse (for the format) */
/* TYPE_var is the name to pass to the GL function */
@@ -161,7 +161,7 @@ typedef struct BufferOrOffset {
# define buffer_def(number) Buffer *bgl_buffer##number
#endif
-/*@The standard GL typedefs are used as prototypes, we can't
+/* The standard GL typedefs are used as prototypes, we can't
* use the GL type directly because Py_ArgParse expects normal
* C types.
*
@@ -505,13 +505,13 @@ static bool compare_dimensions(int ndim, const int *dim1, const Py_ssize_t *dim2
* \{ */
static PySequenceMethods Buffer_SeqMethods = {
- (lenfunc)Buffer_len, /*sq_length */
- (binaryfunc)NULL, /*sq_concat */
- (ssizeargfunc)NULL, /*sq_repeat */
- (ssizeargfunc)Buffer_item, /*sq_item */
- (ssizessizeargfunc)NULL, /*sq_slice, deprecated, handled in Buffer_item */
- (ssizeobjargproc)Buffer_ass_item, /*sq_ass_item */
- (ssizessizeobjargproc)NULL, /*sq_ass_slice, deprecated handled in Buffer_ass_item */
+ (lenfunc)Buffer_len, /* sq_length */
+ (binaryfunc)NULL, /* sq_concat */
+ (ssizeargfunc)NULL, /* sq_repeat */
+ (ssizeargfunc)Buffer_item, /* sq_item */
+ (ssizessizeargfunc)NULL, /* sq_slice, deprecated, handled in Buffer_item */
+ (ssizeobjargproc)Buffer_ass_item, /* sq_ass_item */
+ (ssizessizeobjargproc)NULL, /* sq_ass_slice, deprecated handled in Buffer_ass_item */
(objobjproc)NULL, /* sq_contains */
(binaryfunc)NULL, /* sq_inplace_concat */
(ssizeargfunc)NULL, /* sq_inplace_repeat */
@@ -582,17 +582,17 @@ static PyGetSetDef Buffer_getseters[] = {
};
PyTypeObject BGL_bufferType = {
- PyVarObject_HEAD_INIT(NULL, 0) "bgl.Buffer", /*tp_name */
- sizeof(Buffer), /*tp_basicsize */
- 0, /*tp_itemsize */
- (destructor)Buffer_dealloc, /*tp_dealloc */
- (printfunc)NULL, /*tp_print */
- NULL, /*tp_getattr */
- NULL, /*tp_setattr */
- NULL, /*tp_compare */
- (reprfunc)Buffer_repr, /*tp_repr */
- NULL, /*tp_as_number */
- &Buffer_SeqMethods, /*tp_as_sequence */
+ PyVarObject_HEAD_INIT(NULL, 0) "bgl.Buffer", /* tp_name */
+ sizeof(Buffer), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)Buffer_dealloc, /* tp_dealloc */
+ (printfunc)NULL, /* tp_print */
+ NULL, /* tp_getattr */
+ NULL, /* tp_setattr */
+ NULL, /* tp_compare */
+ (reprfunc)Buffer_repr, /* tp_repr */
+ NULL, /* tp_as_number */
+ &Buffer_SeqMethods, /* tp_as_sequence */
&Buffer_AsMapping, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
@@ -683,7 +683,7 @@ Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuf
size *= dimensions[i];
}
- buf = MEM_mallocN(size, "Buffer buffer");
+ buf = MEM_mallocN(size, __func__);
buffer = BGL_MakeBuffer_FromData(NULL, type, ndimensions, dimensions, buf);
@@ -790,7 +790,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
}
else {
PyErr_Format(PyExc_TypeError,
- "invalid second argument argument expected a sequence "
+ "invalid second argument expected a sequence "
"or an int, not a %.200s",
Py_TYPE(length_ob)->tp_name);
return NULL;
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index cebc72d99d1..c6afb694413 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -611,8 +611,8 @@ static IDProperty *idp_from_PyMapping(const char *name, PyObject *ob)
keys = PyMapping_Keys(ob);
vals = PyMapping_Values(ob);
- /* we allocate the group first; if we hit any invalid data,
- * we can delete it easily enough.*/
+ /* We allocate the group first; if we hit any invalid data,
+ * we can delete it easily enough. */
prop = IDP_New(IDP_GROUP, &val, name);
len = PyMapping_Length(ob);
for (i = 0; i < len; i++) {
@@ -1051,7 +1051,7 @@ static PyObject *BPy_IDGroup_IterItems_CreatePyObject(BPy_IDProperty *group, con
/** \name ID-Property Group View Types (Keys/Values/Items)
*
* This view types is a thin wrapper on keys/values/items, this matches Python's `dict_view` type.
- * The is returned by `property.keys()` and is separate from the iterator that loops over keys.
+ * This is returned by `property.keys()` and is separate from the iterator that loops over keys.
*
* There are some less common features this type could support (matching Python's `dict_view`)
*
@@ -1284,8 +1284,8 @@ static PyObject *BPy_IDGroup_pop(BPy_IDProperty *self, PyObject *args)
pyform = BPy_IDGroup_MapDataToPy(idprop);
if (pyform == NULL) {
/* ok something bad happened with the #PyObject,
- * so don't remove the prop from the group. if pyform is
- * NULL, then it already should have raised an exception.*/
+ * so don't remove the prop from the group. if `pyform is
+ * NULL, then it already should have raised an exception. */
return NULL;
}
@@ -1305,7 +1305,7 @@ static void BPy_IDGroup_CorrectListLen(IDProperty *prop, PyObject *seq, int len,
PyList_SET_ITEM(seq, j, Py_INCREF_RET(Py_None));
}
- /*set correct group length*/
+ /* Set correct group length. */
prop->len = len;
}
@@ -1326,8 +1326,8 @@ PyObject *BPy_Wrap_GetKeys(IDProperty *prop)
if (i != prop->len) { /* if the loop didn't finish, we know the length is wrong */
BPy_IDGroup_CorrectListLen(prop, list, i, __func__);
- Py_DECREF(list); /*free the list*/
- /*call self again*/
+ Py_DECREF(list); /* Free the list. */
+ /* Call self again. */
return BPy_Wrap_GetKeys(prop);
}
@@ -1346,8 +1346,8 @@ PyObject *BPy_Wrap_GetValues(ID *id, IDProperty *prop)
if (i != prop->len) {
BPy_IDGroup_CorrectListLen(prop, list, i, __func__);
- Py_DECREF(list); /*free the list*/
- /*call self again*/
+ Py_DECREF(list); /* Free the list. */
+ /* Call self again. */
return BPy_Wrap_GetValues(id, prop);
}
@@ -1369,8 +1369,8 @@ PyObject *BPy_Wrap_GetItems(ID *id, IDProperty *prop)
if (i != prop->len) {
BPy_IDGroup_CorrectListLen(prop, seq, i, __func__);
- Py_DECREF(seq); /*free the list*/
- /*call self again*/
+ Py_DECREF(seq); /* Free the list. */
+ /* Call self again. */
return BPy_Wrap_GetItems(id, prop);
}
@@ -1557,9 +1557,9 @@ static PySequenceMethods BPy_IDGroup_Seq = {
};
static PyMappingMethods BPy_IDGroup_Mapping = {
- (lenfunc)BPy_IDGroup_Map_Len, /*inquiry mp_length */
- (binaryfunc)BPy_IDGroup_Map_GetItem, /*binaryfunc mp_subscript */
- (objobjargproc)BPy_IDGroup_Map_SetItem, /*objobjargproc mp_ass_subscript */
+ (lenfunc)BPy_IDGroup_Map_Len, /* inquiry mp_length */
+ (binaryfunc)BPy_IDGroup_Map_GetItem, /* binaryfunc mp_subscript */
+ (objobjargproc)BPy_IDGroup_Map_SetItem, /* objobjargproc mp_ass_subscript */
};
PyTypeObject BPy_IDGroup_Type = {
@@ -2040,12 +2040,12 @@ PyTypeObject BPy_IDArray_Type = {
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
diff --git a/source/blender/python/generic/imbuf_py_api.c b/source/blender/python/generic/imbuf_py_api.c
index 793b980295c..57e148b56c8 100644
--- a/source/blender/python/generic/imbuf_py_api.c
+++ b/source/blender/python/generic/imbuf_py_api.c
@@ -178,7 +178,7 @@ static PyObject *py_imbuf_copy(Py_ImBuf *self)
if (UNLIKELY(ibuf_copy == NULL)) {
PyErr_SetString(PyExc_MemoryError,
"ImBuf.copy(): "
- "failed to allocate memory memory");
+ "failed to allocate memory");
return NULL;
}
return Py_ImBuf_CreatePyObject(ibuf_copy);
diff --git a/source/blender/python/gpu/gpu_py_buffer.c b/source/blender/python/gpu/gpu_py_buffer.c
index e36e3b42617..5c004459b44 100644
--- a/source/blender/python/gpu/gpu_py_buffer.c
+++ b/source/blender/python/gpu/gpu_py_buffer.c
@@ -577,12 +577,12 @@ static PyGetSetDef pygpu_buffer_getseters[] = {
};
static PySequenceMethods pygpu_buffer__tp_as_sequence = {
- (lenfunc)pygpu_buffer__sq_length, /*sq_length */
- (binaryfunc)NULL, /*sq_concat */
- (ssizeargfunc)NULL, /*sq_repeat */
- (ssizeargfunc)pygpu_buffer__sq_item, /*sq_item */
- (ssizessizeargfunc)NULL, /*sq_slice, deprecated, handled in pygpu_buffer__sq_item */
- (ssizeobjargproc)pygpu_buffer__sq_ass_item, /*sq_ass_item */
+ (lenfunc)pygpu_buffer__sq_length, /* sq_length */
+ (binaryfunc)NULL, /* sq_concat */
+ (ssizeargfunc)NULL, /* sq_repeat */
+ (ssizeargfunc)pygpu_buffer__sq_item, /* sq_item */
+ (ssizessizeargfunc)NULL, /* sq_slice, deprecated, handled in pygpu_buffer__sq_item */
+ (ssizeobjargproc)pygpu_buffer__sq_ass_item, /* sq_ass_item */
(ssizessizeobjargproc)NULL, /* sq_ass_slice, deprecated handled in pygpu_buffer__sq_ass_item */
(objobjproc)NULL, /* sq_contains */
(binaryfunc)NULL, /* sq_inplace_concat */
diff --git a/source/blender/python/gpu/gpu_py_framebuffer.c b/source/blender/python/gpu/gpu_py_framebuffer.c
index 0efc0713538..2f081fcfd8c 100644
--- a/source/blender/python/gpu/gpu_py_framebuffer.c
+++ b/source/blender/python/gpu/gpu_py_framebuffer.c
@@ -130,8 +130,8 @@ static bool pygpu_framebuffer_stack_pop_and_restore_or_error(GPUFrameBuffer *fb)
* \{ */
typedef struct {
- PyObject_HEAD /* required python macro */
- BPyGPUFrameBuffer *py_fb;
+ PyObject_HEAD /* Required Python macro. */
+ BPyGPUFrameBuffer *py_fb;
int level;
} PyFrameBufferStackContext;
diff --git a/source/blender/python/gpu/gpu_py_framebuffer.h b/source/blender/python/gpu/gpu_py_framebuffer.h
index 6727328518c..4b44436f5cf 100644
--- a/source/blender/python/gpu/gpu_py_framebuffer.h
+++ b/source/blender/python/gpu/gpu_py_framebuffer.h
@@ -27,7 +27,8 @@ extern PyTypeObject BPyGPUFrameBuffer_Type;
#define BPyGPUFrameBuffer_Check(v) (Py_TYPE(v) == &BPyGPUFrameBuffer_Type)
typedef struct BPyGPUFrameBuffer {
- PyObject_HEAD struct GPUFrameBuffer *fb;
+ PyObject_HEAD
+ struct GPUFrameBuffer *fb;
#ifndef GPU_NO_USE_PY_REFERENCES
bool shared_reference;
diff --git a/source/blender/python/gpu/gpu_py_matrix.c b/source/blender/python/gpu/gpu_py_matrix.c
index b00a13d5be8..b379600d33c 100644
--- a/source/blender/python/gpu/gpu_py_matrix.c
+++ b/source/blender/python/gpu/gpu_py_matrix.c
@@ -152,8 +152,8 @@ static PyObject *pygpu_matrix_pop_projection(PyObject *UNUSED(self))
* \{ */
typedef struct {
- PyObject_HEAD /* required python macro */
- int type;
+ PyObject_HEAD /* Required Python macro. */
+ int type;
int level;
} BPyGPU_MatrixStackContext;
diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c
index 0d29bc98a31..0a8b294ea41 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.c
+++ b/source/blender/python/gpu/gpu_py_offscreen.c
@@ -97,8 +97,8 @@ static int pygpu_offscreen_valid_check(BPyGPUOffScreen *py_ofs)
* \{ */
typedef struct {
- PyObject_HEAD /* required python macro */
- BPyGPUOffScreen *py_offscreen;
+ PyObject_HEAD /* Required Python macro. */
+ BPyGPUOffScreen *py_offscreen;
int level;
bool is_explicitly_bound; /* Bound by "bind" method. */
} OffScreenStackContext;
diff --git a/source/blender/python/gpu/gpu_py_offscreen.h b/source/blender/python/gpu/gpu_py_offscreen.h
index f551730cf54..309735a6202 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.h
+++ b/source/blender/python/gpu/gpu_py_offscreen.h
@@ -27,7 +27,8 @@ extern PyTypeObject BPyGPUOffScreen_Type;
#define BPyGPUOffScreen_Check(v) (Py_TYPE(v) == &BPyGPUOffScreen_Type)
typedef struct BPyGPUOffScreen {
- PyObject_HEAD struct GPUOffScreen *ofs;
+ PyObject_HEAD
+ struct GPUOffScreen *ofs;
} BPyGPUOffScreen;
PyObject *BPyGPUOffScreen_CreatePyObject(struct GPUOffScreen *ofs) ATTR_NONNULL(1);
diff --git a/source/blender/python/gpu/gpu_py_texture.h b/source/blender/python/gpu/gpu_py_texture.h
index 3eaaa3411bd..8423d0e6804 100644
--- a/source/blender/python/gpu/gpu_py_texture.h
+++ b/source/blender/python/gpu/gpu_py_texture.h
@@ -27,7 +27,8 @@ extern PyTypeObject BPyGPUTexture_Type;
#define BPyGPUTexture_Check(v) (Py_TYPE(v) == &BPyGPUTexture_Type)
typedef struct BPyGPUTexture {
- PyObject_HEAD struct GPUTexture *tex;
+ PyObject_HEAD
+ struct GPUTexture *tex;
} BPyGPUTexture;
int bpygpu_ParseTexture(PyObject *o, void *p);
diff --git a/source/blender/python/gpu/gpu_py_uniformbuffer.h b/source/blender/python/gpu/gpu_py_uniformbuffer.h
index a13c33ae78a..75d6d5e2160 100644
--- a/source/blender/python/gpu/gpu_py_uniformbuffer.h
+++ b/source/blender/python/gpu/gpu_py_uniformbuffer.h
@@ -27,7 +27,8 @@ extern PyTypeObject BPyGPUUniformBuf_Type;
#define BPyGPUUniformBuf_Check(v) (Py_TYPE(v) == &BPyGPUUniformBuf_Type)
typedef struct BPyGPUUniformBuf {
- PyObject_HEAD struct GPUUniformBuf *ubo;
+ PyObject_HEAD
+ struct GPUUniformBuf *ubo;
} BPyGPUUniformBuf;
PyObject *BPyGPUUniformBuf_CreatePyObject(struct GPUUniformBuf *ubo) ATTR_NONNULL(1);
diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c
index d00f205ddc0..478ae61aecd 100644
--- a/source/blender/python/intern/bpy_app_translations.c
+++ b/source/blender/python/intern/bpy_app_translations.c
@@ -51,8 +51,8 @@
typedef struct {
PyObject_HEAD
- /** The string used to separate context from actual message in PY_TRANSLATE RNA props. */
- const char *context_separator;
+ /** 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. */
PyObject *contexts;
/** A readonly mapping {C context id: python id} (actually, a MappingProxy). */
@@ -855,12 +855,12 @@ static PyTypeObject BlenderAppTranslationsType = {
/* newfunc tp_new; */
(newfunc)app_translations_new,
/* Low-level free-memory routine */
- app_translations_free, /* freefunc tp_free; */
+ app_translations_free, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index 5102aa17250..a7b99f211c2 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -86,7 +86,7 @@ int bpy_pydriver_create_dict(void)
bpy_pydriver_Dict = d;
- /* import some modules: builtins, bpy, math, (Blender.noise)*/
+ /* Import some modules: builtins, bpy, math, `Blender.noise`. */
PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins());
mod = PyImport_ImportModule("math");
@@ -654,7 +654,7 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
}
#endif
- /* decref the driver vars first... */
+ /* decref the driver vars first. */
Py_DECREF(driver_vars);
/* process the result */
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 8796877e9aa..832af9e8460 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -338,7 +338,7 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
{
#ifndef WITH_PYTHON_MODULE
- /* #PyPreConfig (early-configuration). */
+ /* #PyPreConfig (early-configuration). */
{
PyPreConfig preconfig;
PyStatus status;
@@ -785,8 +785,8 @@ static struct PyModuleDef bpy_proxy_def = {
typedef struct {
PyObject_HEAD
- /* Type-specific fields go here. */
- PyObject *mod;
+ /* Type-specific fields go here. */
+ PyObject *mod;
} dealloc_obj;
/* call once __file__ is set */
diff --git a/source/blender/python/intern/bpy_interface_run.c b/source/blender/python/intern/bpy_interface_run.c
index f7272a87a17..f7d6a33c904 100644
--- a/source/blender/python/intern/bpy_interface_run.c
+++ b/source/blender/python/intern/bpy_interface_run.c
@@ -74,7 +74,8 @@ static void bpy_text_filename_get(char *fn, const Main *bmain, size_t fn_len, co
/* bad!, we should never do this, but currently only safe way I could find to keep namespace.
* from being cleared. - campbell */
typedef struct {
- PyObject_HEAD PyObject *md_dict;
+ PyObject_HEAD
+ PyObject *md_dict;
/* omit other values, we only want the dict. */
} PyModuleObject;
#endif
diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c
index 7a688b8c77d..28a97c3fa3b 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -61,9 +61,9 @@
#endif
typedef struct {
- PyObject_HEAD /* required python macro */
- /* collection iterator specific parts */
- char relpath[FILE_MAX];
+ PyObject_HEAD /* Required Python macro. */
+ /* Collection iterator specific parts. */
+ char relpath[FILE_MAX];
char abspath[FILE_MAX]; /* absolute path */
BlendHandle *blo_handle;
int flag;
@@ -159,12 +159,12 @@ static PyTypeObject bpy_lib_Type = {
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
@@ -257,8 +257,9 @@ static PyObject *bpy_lib_enter(BPy_Library *self)
ReportList reports;
BKE_reports_init(&reports, RPT_STORE);
+ BlendFileReadReport bf_reports = {.reports = &reports};
- self->blo_handle = BLO_blendhandle_from_file(self->abspath, &reports);
+ self->blo_handle = BLO_blendhandle_from_file(self->abspath, &bf_reports);
if (self->blo_handle == NULL) {
if (BPy_reports_to_error(&reports, PyExc_IOError, true) != -1) {
diff --git a/source/blender/python/intern/bpy_operator.h b/source/blender/python/intern/bpy_operator.h
index 3cb335d5d9a..453b3c3d6d4 100644
--- a/source/blender/python/intern/bpy_operator.h
+++ b/source/blender/python/intern/bpy_operator.h
@@ -29,7 +29,7 @@ extern PyTypeObject pyop_base_Type;
#define BPy_OperatorBase_Check(v) (PyObject_TypeCheck(v, &pyop_base_Type))
typedef struct {
- PyObject_HEAD /* required python macro */
+ PyObject_HEAD /* Required Python macro. */
} BPy_OperatorBase;
PyObject *BPY_operator_module(void);
diff --git a/source/blender/python/intern/bpy_props.h b/source/blender/python/intern/bpy_props.h
index d467166f354..bc7f0cfe416 100644
--- a/source/blender/python/intern/bpy_props.h
+++ b/source/blender/python/intern/bpy_props.h
@@ -33,8 +33,8 @@ StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix);
typedef struct {
PyObject_HEAD
- /* This isn't GC tracked, it's a function from `bpy.props` so it's not going away. */
- void *fn;
+ /* This isn't GC tracked, it's a function from `bpy.props` so it's not going away. */
+ void *fn;
PyObject *kw;
} BPy_PropDeferred;
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 89fe907e57b..a3c5d4e9d66 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -6459,11 +6459,11 @@ PyTypeObject pyrna_struct_meta_idprop_Type = {
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
- NULL, /* hashfunc tp_hash; */
- NULL, /* ternaryfunc tp_call; */
- NULL, /* reprfunc tp_str; */
- NULL /*(getattrofunc) pyrna_struct_meta_idprop_getattro*/, /* getattrofunc tp_getattro; */
- (setattrofunc)pyrna_struct_meta_idprop_setattro, /* setattrofunc tp_setattro; */
+ NULL, /* hashfunc tp_hash; */
+ NULL, /* ternaryfunc tp_call; */
+ NULL, /* reprfunc tp_str; */
+ NULL /* (getattrofunc) pyrna_struct_meta_idprop_getattro */, /* getattrofunc tp_getattro; */
+ (setattrofunc)pyrna_struct_meta_idprop_setattro, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
@@ -6508,12 +6508,12 @@ PyTypeObject pyrna_struct_meta_idprop_Type = {
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
@@ -6601,12 +6601,12 @@ PyTypeObject pyrna_struct_Type = {
NULL, /* allocfunc tp_alloc; */
pyrna_struct_new, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
@@ -6686,12 +6686,12 @@ PyTypeObject pyrna_prop_Type = {
NULL, /* allocfunc tp_alloc; */
pyrna_prop_new, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
@@ -6769,12 +6769,12 @@ PyTypeObject pyrna_prop_array_Type = {
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
@@ -6854,12 +6854,12 @@ PyTypeObject pyrna_prop_collection_Type = {
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
@@ -6940,12 +6940,12 @@ static PyTypeObject pyrna_prop_collection_idprop_Type = {
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
@@ -7025,12 +7025,12 @@ PyTypeObject pyrna_func_Type = {
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
@@ -7121,12 +7121,12 @@ static PyTypeObject pyrna_prop_collection_iter_Type = {
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
@@ -7165,8 +7165,8 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA *
if (pyrna) { /* Unlikely, but may fail. */
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
+ * 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 */
pyrna_struct_reference_set(pyrna, (PyObject *)self);
}
@@ -7884,9 +7884,11 @@ StructRNA *pyrna_struct_as_srna(PyObject *self, const bool parent, const char *e
}
/* Orphan functions, not sure where they should go. */
-/* Get the srna for methods attached to types. */
-/*
- * Caller needs to raise error.*/
+/**
+ * Get the SRNA for methods attached to types.
+ *
+ * Caller needs to raise error.
+ */
StructRNA *srna_from_self(PyObject *self, const char *error_prefix)
{
@@ -8256,9 +8258,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
if (func_arg_count >= 0) { /* -1 if we don't care. */
arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
- /* note, the number of args we check for and the number of args we give to
+ /* NOTE: the number of args we check for and the number of args we give to
* '@staticmethods' are different (quirk of Python),
- * this is why rna_function_arg_count() doesn't return the value -1*/
+ * this is why rna_function_arg_count() doesn't return the value -1. */
if (is_staticmethod) {
func_arg_count++;
func_arg_min_count++;
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index e891f5c1fc1..75534c05d6c 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -110,17 +110,17 @@ extern PyTypeObject pyrna_func_Type;
/* 'in_weakreflist' MUST be aligned */
typedef struct {
- PyObject_HEAD /* required python macro */
+ PyObject_HEAD /* Required Python macro. */
#ifdef USE_WEAKREFS
- PyObject *in_weakreflist;
+ PyObject *in_weakreflist;
#endif
PointerRNA ptr;
} BPy_DummyPointerRNA;
typedef struct {
- PyObject_HEAD /* required python macro */
+ PyObject_HEAD /* Required Python macro. */
#ifdef USE_WEAKREFS
- PyObject *in_weakreflist;
+ PyObject *in_weakreflist;
#endif
PointerRNA ptr;
#ifdef USE_PYRNA_STRUCT_REFERENCE
@@ -135,18 +135,18 @@ typedef struct {
} BPy_StructRNA;
typedef struct {
- PyObject_HEAD /* required python macro */
+ PyObject_HEAD /* Required Python macro. */
#ifdef USE_WEAKREFS
- PyObject *in_weakreflist;
+ PyObject *in_weakreflist;
#endif
PointerRNA ptr;
PropertyRNA *prop;
} BPy_PropertyRNA;
typedef struct {
- PyObject_HEAD /* required python macro */
+ PyObject_HEAD /* Required Python macro. */
#ifdef USE_WEAKREFS
- PyObject *in_weakreflist;
+ PyObject *in_weakreflist;
#endif
PointerRNA ptr;
PropertyRNA *prop;
@@ -159,9 +159,9 @@ typedef struct {
} BPy_PropertyArrayRNA;
typedef struct {
- PyObject_HEAD /* required python macro */
+ PyObject_HEAD /* Required Python macro. */
#ifdef USE_WEAKREFS
- PyObject *in_weakreflist;
+ PyObject *in_weakreflist;
#endif
/* collection iterator specific parts */
@@ -169,9 +169,9 @@ typedef struct {
} BPy_PropertyCollectionIterRNA;
typedef struct {
- PyObject_HEAD /* required python macro */
+ PyObject_HEAD /* Required Python macro. */
#ifdef USE_WEAKREFS
- PyObject *in_weakreflist;
+ PyObject *in_weakreflist;
#endif
PointerRNA ptr;
FunctionRNA *func;
@@ -183,7 +183,7 @@ StructRNA *pyrna_struct_as_srna(PyObject *self, const bool parent, const char *e
void BPY_rna_init(void);
PyObject *BPY_rna_module(void);
void BPY_update_rna_module(void);
-/*PyObject *BPY_rna_doc(void);*/
+// PyObject *BPY_rna_doc(void);
PyObject *BPY_rna_types(void);
PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr);
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index cb3fe9cb600..aafc787b6fc 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -536,11 +536,11 @@ static int py_to_array(PyObject *seq,
RNA_SetArrayFunc rna_set_array,
const char *error_prefix)
{
- /*int totdim, dim_size[MAX_ARRAY_DIMENSION];*/
+ // int totdim, dim_size[MAX_ARRAY_DIMENSION];
int totitem;
char *data = NULL;
- /*totdim = RNA_property_array_dimension(ptr, prop, dim_size);*/ /*UNUSED*/
+ // totdim = RNA_property_array_dimension(ptr, prop, dim_size); /* UNUSED */
if (validate_array(seq, ptr, prop, 0, check_item_type, item_type_str, &totitem, error_prefix) ==
-1) {
diff --git a/source/blender/python/intern/bpy_rna_data.c b/source/blender/python/intern/bpy_rna_data.c
index daab1631e8e..639999b69d4 100644
--- a/source/blender/python/intern/bpy_rna_data.c
+++ b/source/blender/python/intern/bpy_rna_data.c
@@ -40,8 +40,8 @@
#include "bpy_rna_data.h"
typedef struct {
- PyObject_HEAD /* required python macro */
- BPy_StructRNA *data_rna;
+ PyObject_HEAD /* Required Python macro. */
+ BPy_StructRNA *data_rna;
char filepath[1024];
} BPy_DataContext;
@@ -141,12 +141,12 @@ static PyTypeObject bpy_rna_data_context_Type = {
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
diff --git a/source/blender/python/mathutils/mathutils_Color.h b/source/blender/python/mathutils/mathutils_Color.h
index c966bf1e3b2..40de26f01ea 100644
--- a/source/blender/python/mathutils/mathutils_Color.h
+++ b/source/blender/python/mathutils/mathutils_Color.h
@@ -31,7 +31,7 @@ typedef struct {
/* struct data contains a pointer to the actual data that the
* object uses. It can use either PyMem allocated data (which will
* be stored in py_data) or be a wrapper for data allocated through
- * blender (stored in blend_data). This is an either/or struct not both*/
+ * Blender (stored in blend_data). This is an either/or struct not both. */
/* prototypes */
PyObject *Color_CreatePyObject(const float col[3],
diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c
index b6a0183d04e..4e1b31b6371 100644
--- a/source/blender/python/mathutils/mathutils_Euler.c
+++ b/source/blender/python/mathutils/mathutils_Euler.c
@@ -619,9 +619,9 @@ static PySequenceMethods Euler_SeqMethods = {
(binaryfunc)NULL, /* sq_concat */
(ssizeargfunc)NULL, /* sq_repeat */
(ssizeargfunc)Euler_item, /* sq_item */
- (ssizessizeargfunc)NULL, /* sq_slice, deprecated */
+ (ssizessizeargfunc)NULL, /* sq_slice (deprecated) */
(ssizeobjargproc)Euler_ass_item, /* sq_ass_item */
- (ssizessizeobjargproc)NULL, /* sq_ass_slice, deprecated */
+ (ssizessizeobjargproc)NULL, /* sq_ass_slice (deprecated) */
(objobjproc)NULL, /* sq_contains */
(binaryfunc)NULL, /* sq_inplace_concat */
(ssizeargfunc)NULL, /* sq_inplace_repeat */
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 5d38a3692c3..3dde0177648 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -340,7 +340,7 @@ Mathutils_Callback mathutils_matrix_translation_cb = {
mathutils_matrix_translation_set_index,
};
-/* matrix column callbacks, this is so you can do matrix.translation = Vector() */
+/* matrix column callbacks, this is so you can do `matrix.translation = Vector()`. */
/* ----------------------------------mathutils.Matrix() ----------------- */
/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */
@@ -373,7 +373,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_XDECREF(item);
if (num_col >= 2 && num_col <= 4) {
- /* sane row & col size, new matrix and assign as slice */
+ /* Sane row & col size, new matrix and assign as slice. */
PyObject *matrix = Matrix_CreatePyObject(NULL, num_col, num_row, type);
if (Matrix_ass_slice((MatrixObject *)matrix, 0, INT_MAX, arg) == 0) {
return matrix;
@@ -1339,7 +1339,7 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
copy_v3_v3(eul_compatf, eul_compat->eul);
}
- /*must be 3-4 cols, 3-4 rows, square matrix */
+ /* Must be 3-4 cols, 3-4 rows, square matrix. */
if (self->num_row == 3 && self->num_col == 3) {
copy_m3_m3(mat, (const float(*)[3])self->matrix);
}
@@ -1539,7 +1539,7 @@ static PyObject *Matrix_to_scale(MatrixObject *self)
return NULL;
}
- /*must be 3-4 cols, 3-4 rows, square matrix */
+ /* Must be 3-4 cols, 3-4 rows, square matrix. */
if ((self->num_row < 3) || (self->num_col < 3)) {
PyErr_SetString(PyExc_ValueError,
"Matrix.to_scale(): "
@@ -2430,7 +2430,7 @@ static int Matrix_ass_item_col(MatrixObject *self, int col, PyObject *value)
}
/*----------------------------object[z:y]------------------------
- * sequence slice (get)*/
+ * Sequence slice (get). */
static PyObject *Matrix_slice(MatrixObject *self, int begin, int end)
{
@@ -2456,7 +2456,7 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end)
return tuple;
}
/*----------------------------object[z:y]------------------------
- * sequence slice (set)*/
+ * Sequence slice (set). */
static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *value)
{
PyObject *value_fast;
@@ -2510,7 +2510,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va
Py_DECREF(value_fast);
- /*parsed well - now set in matrix*/
+ /* Parsed well - now set in matrix. */
memcpy(self->matrix, mat, self->num_col * self->num_row * sizeof(float));
(void)BaseMath_WriteCallback(self);
@@ -2628,7 +2628,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
return Matrix_CreatePyObject(mat, mat2->num_col, mat1->num_row, Py_TYPE(mat1));
}
if (mat2) {
- /*FLOAT/INT * MATRIX */
+ /* FLOAT/INT * MATRIX */
if (((scalar = PyFloat_AsDouble(m1)) == -1.0f && PyErr_Occurred()) == 0) {
return matrix_mul_float(mat2, scalar);
}
@@ -2968,7 +2968,7 @@ static PyObject *Matrix_translation_get(MatrixObject *self, void *UNUSED(closure
return NULL;
}
- /*must be 4x4 square matrix*/
+ /* Must be 4x4 square matrix. */
if (self->num_row != 4 || self->num_col != 4) {
PyErr_SetString(PyExc_AttributeError,
"Matrix.translation: "
@@ -2990,7 +2990,7 @@ static int Matrix_translation_set(MatrixObject *self, PyObject *value, void *UNU
return -1;
}
- /*must be 4x4 square matrix*/
+ /* Must be 4x4 square matrix. */
if (self->num_row != 4 || self->num_col != 4) {
PyErr_SetString(PyExc_AttributeError,
"Matrix.translation: "
@@ -3034,7 +3034,7 @@ static PyObject *Matrix_median_scale_get(MatrixObject *self, void *UNUSED(closur
return NULL;
}
- /*must be 3-4 cols, 3-4 rows, square matrix*/
+ /* Must be 3-4 cols, 3-4 rows, square matrix. */
if ((self->num_row < 3) || (self->num_col < 3)) {
PyErr_SetString(PyExc_AttributeError,
"Matrix.median_scale: "
@@ -3056,7 +3056,7 @@ static PyObject *Matrix_is_negative_get(MatrixObject *self, void *UNUSED(closure
return NULL;
}
- /*must be 3-4 cols, 3-4 rows, square matrix*/
+ /* Must be 3-4 cols, 3-4 rows, square matrix. */
if (self->num_row == 4 && self->num_col == 4) {
return PyBool_FromLong(is_negative_m4((const float(*)[4])self->matrix));
}
@@ -3078,7 +3078,7 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu
return NULL;
}
- /*must be 3-4 cols, 3-4 rows, square matrix*/
+ /* Must be 3-4 cols, 3-4 rows, square matrix. */
if (self->num_row == 4 && self->num_col == 4) {
return PyBool_FromLong(is_orthonormal_m4((const float(*)[4])self->matrix));
}
@@ -3101,7 +3101,7 @@ static PyObject *Matrix_is_orthogonal_axis_vectors_get(MatrixObject *self, void
return NULL;
}
- /*must be 3-4 cols, 3-4 rows, square matrix*/
+ /* Must be 3-4 cols, 3-4 rows, square matrix. */
if (self->num_row == 4 && self->num_col == 4) {
return PyBool_FromLong(is_orthogonal_m4((const float(*)[4])self->matrix));
}
@@ -3154,15 +3154,15 @@ static PyGetSetDef Matrix_getseters[] = {
/*-----------------------METHOD DEFINITIONS ----------------------*/
static struct PyMethodDef Matrix_methods[] = {
- /* derived values */
+ /* Derived values. */
{"determinant", (PyCFunction)Matrix_determinant, METH_NOARGS, Matrix_determinant_doc},
{"decompose", (PyCFunction)Matrix_decompose, METH_NOARGS, Matrix_decompose_doc},
- /* in place only */
+ /* In place only. */
{"zero", (PyCFunction)Matrix_zero, METH_NOARGS, Matrix_zero_doc},
{"identity", (PyCFunction)Matrix_identity, METH_NOARGS, Matrix_identity_doc},
- /* operate on original or copy */
+ /* Operate on original or copy. */
{"transpose", (PyCFunction)Matrix_transpose, METH_NOARGS, Matrix_transpose_doc},
{"transposed", (PyCFunction)Matrix_transposed, METH_NOARGS, Matrix_transposed_doc},
{"normalize", (PyCFunction)Matrix_normalize, METH_NOARGS, Matrix_normalize_doc},
@@ -3176,26 +3176,26 @@ static struct PyMethodDef Matrix_methods[] = {
{"to_2x2", (PyCFunction)Matrix_to_2x2, METH_NOARGS, Matrix_to_2x2_doc},
{"to_3x3", (PyCFunction)Matrix_to_3x3, METH_NOARGS, Matrix_to_3x3_doc},
{"to_4x4", (PyCFunction)Matrix_to_4x4, METH_NOARGS, Matrix_to_4x4_doc},
- /* TODO. {"resize_3x3", (PyCFunction) Matrix_resize3x3, METH_NOARGS, Matrix_resize3x3_doc}, */
+ /* TODO: {"resize_3x3", (PyCFunction) Matrix_resize3x3, METH_NOARGS, Matrix_resize3x3_doc}, */
{"resize_4x4", (PyCFunction)Matrix_resize_4x4, METH_NOARGS, Matrix_resize_4x4_doc},
{"rotate", (PyCFunction)Matrix_rotate, METH_O, Matrix_rotate_doc},
- /* return converted representation */
+ /* Return converted representation. */
{"to_euler", (PyCFunction)Matrix_to_euler, METH_VARARGS, Matrix_to_euler_doc},
{"to_quaternion", (PyCFunction)Matrix_to_quaternion, METH_NOARGS, Matrix_to_quaternion_doc},
{"to_scale", (PyCFunction)Matrix_to_scale, METH_NOARGS, Matrix_to_scale_doc},
{"to_translation", (PyCFunction)Matrix_to_translation, METH_NOARGS, Matrix_to_translation_doc},
- /* operation between 2 or more types */
+ /* Operation between 2 or more types. */
{"lerp", (PyCFunction)Matrix_lerp, METH_VARARGS, Matrix_lerp_doc},
{"copy", (PyCFunction)Matrix_copy, METH_NOARGS, Matrix_copy_doc},
{"__copy__", (PyCFunction)Matrix_copy, METH_NOARGS, Matrix_copy_doc},
{"__deepcopy__", (PyCFunction)Matrix_deepcopy, METH_VARARGS, Matrix_copy_doc},
- /* base-math methods */
+ /* Base-math methods. */
{"freeze", (PyCFunction)BaseMathObject_freeze, METH_NOARGS, BaseMathObject_freeze_doc},
- /* class methods */
+ /* Class methods. */
{"Identity", (PyCFunction)C_Matrix_Identity, METH_VARARGS | METH_CLASS, C_Matrix_Identity_doc},
{"Rotation", (PyCFunction)C_Matrix_Rotation, METH_VARARGS | METH_CLASS, C_Matrix_Rotation_doc},
{"Scale", (PyCFunction)C_Matrix_Scale, METH_VARARGS | METH_CLASS, C_Matrix_Scale_doc},
@@ -3313,7 +3313,7 @@ PyObject *Matrix_CreatePyObject(const float *mat,
self->cb_user = NULL;
self->cb_type = self->cb_subtype = 0;
- if (mat) { /*if a float array passed*/
+ if (mat) { /* If a float array passed. */
memcpy(self->matrix, mat, num_col * num_row * sizeof(float));
}
else if (num_col == num_row) {
@@ -3478,8 +3478,8 @@ int Matrix_Parse4x4(PyObject *o, void *p)
* special type for alternate access */
typedef struct {
- PyObject_HEAD /* required python macro */
- MatrixObject *matrix_user;
+ PyObject_HEAD /* Required Python macro. */
+ MatrixObject *matrix_user;
eMatrixAccess_t type;
} MatrixAccessObject;
@@ -3655,7 +3655,7 @@ PyTypeObject matrix_access_Type = {
NULL, /*tp_compare*/
NULL, /*tp_repr*/
NULL, /*tp_as_number*/
- NULL /*&MatrixAccess_SeqMethods*/ /* TODO */, /*tp_as_sequence*/
+ NULL /* &MatrixAccess_SeqMethods */ /* TODO */, /*tp_as_sequence*/
&MatrixAccess_AsMapping, /*tp_as_mapping*/
NULL, /*tp_hash*/
NULL, /*tp_call*/
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c
index 3bc60190d56..88aa1f146e2 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -1113,7 +1113,7 @@ static PyObject *Quaternion_imatmul(PyObject *q1, PyObject *q2)
}
/* -obj
- * returns the negative of this object*/
+ * Returns the negative of this object. */
static PyObject *Quaternion_neg(QuaternionObject *self)
{
float tquat[QUAT_SIZE];
@@ -1407,11 +1407,11 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle)
/* -----------------------METHOD DEFINITIONS ---------------------- */
static struct PyMethodDef Quaternion_methods[] = {
- /* in place only */
+ /* In place only. */
{"identity", (PyCFunction)Quaternion_identity, METH_NOARGS, Quaternion_identity_doc},
{"negate", (PyCFunction)Quaternion_negate, METH_NOARGS, Quaternion_negate_doc},
- /* operate on original or copy */
+ /* Operate on original or copy. */
{"conjugate", (PyCFunction)Quaternion_conjugate, METH_NOARGS, Quaternion_conjugate_doc},
{"conjugated", (PyCFunction)Quaternion_conjugated, METH_NOARGS, Quaternion_conjugated_doc},
@@ -1421,7 +1421,7 @@ static struct PyMethodDef Quaternion_methods[] = {
{"normalize", (PyCFunction)Quaternion_normalize, METH_NOARGS, Quaternion_normalize_doc},
{"normalized", (PyCFunction)Quaternion_normalized, METH_NOARGS, Quaternion_normalized_doc},
- /* return converted representation */
+ /* Return converted representation. */
{"to_euler", (PyCFunction)Quaternion_to_euler, METH_VARARGS, Quaternion_to_euler_doc},
{"to_matrix", (PyCFunction)Quaternion_to_matrix, METH_NOARGS, Quaternion_to_matrix_doc},
{"to_axis_angle",
@@ -1437,7 +1437,7 @@ static struct PyMethodDef Quaternion_methods[] = {
METH_NOARGS,
Quaternion_to_exponential_map_doc},
- /* operation between 2 or more types */
+ /* Operation between 2 or more types. */
{"cross", (PyCFunction)Quaternion_cross, METH_O, Quaternion_cross_doc},
{"dot", (PyCFunction)Quaternion_dot, METH_O, Quaternion_dot_doc},
{"rotation_difference",
@@ -1451,7 +1451,7 @@ static struct PyMethodDef Quaternion_methods[] = {
METH_O,
Quaternion_make_compatible_doc},
- /* base-math methods */
+ /* Base-math methods. */
{"freeze", (PyCFunction)BaseMathObject_freeze, METH_NOARGS, BaseMathObject_freeze_doc},
{"copy", (PyCFunction)Quaternion_copy, METH_NOARGS, Quaternion_copy_doc},
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index c6d801aa733..a9cb125f715 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -1509,7 +1509,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se
return -1;
}
- /*parsed well - now set in vector*/
+ /* Parsed well - now set in vector. */
memcpy(self->vec + begin, vec, size * sizeof(float));
PyMem_Free(vec);
@@ -1543,7 +1543,7 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2)
return NULL;
}
- /*VECTOR + VECTOR*/
+ /* VECTOR + VECTOR. */
if (vec1->size != vec2->size) {
PyErr_SetString(PyExc_AttributeError,
"Vector addition: "
@@ -1882,7 +1882,7 @@ static PyObject *Vector_matmul(PyObject *v1, PyObject *v2)
return NULL;
}
- /*dot product*/
+ /* Dot product. */
return PyFloat_FromDouble(dot_vn_vn(vec1->vec, vec2->vec, vec1->size));
}
if (vec1) {
@@ -2007,7 +2007,7 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2)
}
/* -obj
- * returns the negative of this object*/
+ * Returns the negative of this object. */
static PyObject *Vector_neg(VectorObject *self)
{
float *tvec;
@@ -2974,11 +2974,11 @@ static struct PyMethodDef Vector_methods[] = {
{"Linspace", (PyCFunction)C_Vector_Linspace, METH_VARARGS | METH_CLASS, C_Vector_Linspace_doc},
{"Repeat", (PyCFunction)C_Vector_Repeat, METH_VARARGS | METH_CLASS, C_Vector_Repeat_doc},
- /* in place only */
+ /* In place only. */
{"zero", (PyCFunction)Vector_zero, METH_NOARGS, Vector_zero_doc},
{"negate", (PyCFunction)Vector_negate, METH_NOARGS, Vector_negate_doc},
- /* operate on original or copy */
+ /* Operate on original or copy. */
{"normalize", (PyCFunction)Vector_normalize, METH_NOARGS, Vector_normalize_doc},
{"normalized", (PyCFunction)Vector_normalized, METH_NOARGS, Vector_normalized_doc},
@@ -2994,7 +2994,7 @@ static struct PyMethodDef Vector_methods[] = {
{"to_track_quat", (PyCFunction)Vector_to_track_quat, METH_VARARGS, Vector_to_track_quat_doc},
{"orthogonal", (PyCFunction)Vector_orthogonal, METH_NOARGS, Vector_orthogonal_doc},
- /* operation between 2 or more types */
+ /* Operation between 2 or more types. */
{"reflect", (PyCFunction)Vector_reflect, METH_O, Vector_reflect_doc},
{"cross", (PyCFunction)Vector_cross, METH_O, Vector_cross_doc},
{"dot", (PyCFunction)Vector_dot, METH_O, Vector_dot_doc},
@@ -3009,7 +3009,7 @@ static struct PyMethodDef Vector_methods[] = {
{"slerp", (PyCFunction)Vector_slerp, METH_VARARGS, Vector_slerp_doc},
{"rotate", (PyCFunction)Vector_rotate, METH_O, Vector_rotate_doc},
- /* base-math methods */
+ /* Base-math methods. */
{"freeze", (PyCFunction)BaseMathObject_freeze, METH_NOARGS, BaseMathObject_freeze_doc},
{"copy", (PyCFunction)Vector_copy, METH_NOARGS, Vector_copy_doc},
@@ -3105,12 +3105,12 @@ PyTypeObject vector_Type = {
NULL, /* allocfunc tp_alloc; */
Vector_new, /* newfunc tp_new; */
/* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
+ NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
+ NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
- NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c
index b00dbacad15..80919e014d5 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -93,7 +93,8 @@ static const char PY_BVH_TREE_TYPE_DEFAULT = 4;
static const char PY_BVH_AXIS_DEFAULT = 6;
typedef struct {
- PyObject_HEAD BVHTree *tree;
+ PyObject_HEAD
+ BVHTree *tree;
float epsilon;
float (*coords)[3];
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 1304447be65..3b1a6524ed9 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -1213,7 +1213,7 @@ PyDoc_STRVAR(M_Geometry_tessellate_polygon_doc,
/* PolyFill function, uses Blenders scanfill to fill multiple poly lines */
static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject *polyLineSeq)
{
- PyObject *tri_list; /*return this list of tri's */
+ PyObject *tri_list; /* Return this list of tri's */
PyObject *polyLine, *polyVec;
int i, len_polylines, len_polypoints;
bool list_parse_error = false;
@@ -1222,7 +1222,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject
/* Display #ListBase. */
ListBase dispbase = {NULL, NULL};
DispList *dl;
- float *fp; /*pointer to the array of malloced dl->verts to set the points from the vectors */
+ float *fp; /* Pointer to the array of malloced dl->verts to set the points from the vectors. */
int totpoints = 0;
if (!PySequence_Check(polyLineSeq)) {
diff --git a/source/blender/python/mathutils/mathutils_kdtree.c b/source/blender/python/mathutils/mathutils_kdtree.c
index 1ff574fefa8..95a3b6dc20b 100644
--- a/source/blender/python/mathutils/mathutils_kdtree.c
+++ b/source/blender/python/mathutils/mathutils_kdtree.c
@@ -37,7 +37,8 @@
#include "BLI_strict_flags.h"
typedef struct {
- PyObject_HEAD KDTree_3d *obj;
+ PyObject_HEAD
+ KDTree_3d *obj;
uint maxsize;
uint count;
uint count_balance; /* size when we last balanced */
diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c
index c24960f2d04..707fd40e9d0 100644
--- a/source/blender/python/mathutils/mathutils_noise.c
+++ b/source/blender/python/mathutils/mathutils_noise.c
@@ -93,7 +93,7 @@
#define MIXBITS(u, v) (((u)&UMASK) | ((v)&LMASK))
#define TWIST(u, v) ((MIXBITS(u, v) >> 1) ^ ((v)&1UL ? MATRIX_A : 0UL))
-static ulong state[N]; /* the array for the state vector */
+static ulong state[N]; /* The array for the state vector. */
static int left = 1;
static int initf = 0;
static ulong *next;
@@ -106,10 +106,10 @@ static void init_genrand(ulong s)
state[0] = s & 0xffffffffUL;
for (j = 1; j < N; j++) {
state[j] = (1812433253UL * (state[j - 1] ^ (state[j - 1] >> 30)) + j);
- /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
- /* In the previous versions, MSBs of the seed affect */
- /* only MSBs of the array state[]. */
- /* 2002/01/09 modified by Makoto Matsumoto */
+ /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier.
+ * In the previous versions, MSBs of the seed affect
+ * only MSBs of the array state[].
+ * 2002/01/09 modified by Makoto Matsumoto. */
state[j] &= 0xffffffffUL; /* for >32 bit machines */
}
left = 1;
@@ -230,7 +230,7 @@ static PyC_FlagSet bpy_noise_metrics[] = {
{0, NULL},
};
-/* Fills an array of length size with random numbers in the range (-1, 1)*/
+/* Fills an array of length size with random numbers in the range (-1, 1). */
static void rand_vn(float *array_tar, const int size)
{
float *array_pt = array_tar + (size - 1);
diff --git a/source/blender/render/RE_bake.h b/source/blender/render/RE_bake.h
index bb30b524b61..47a15199701 100644
--- a/source/blender/render/RE_bake.h
+++ b/source/blender/render/RE_bake.h
@@ -76,7 +76,7 @@ typedef struct BakeHighPolyData {
} BakeHighPolyData;
/* external_engine.c */
-bool RE_bake_has_engine(struct Render *re);
+bool RE_bake_has_engine(const struct Render *re);
bool RE_bake_engine(struct Render *re,
struct Depsgraph *depsgraph,
diff --git a/source/blender/render/intern/bake.c b/source/blender/render/intern/bake.c
index 011bdb056d8..340a35eac15 100644
--- a/source/blender/render/intern/bake.c
+++ b/source/blender/render/intern/bake.c
@@ -924,7 +924,7 @@ void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[],
sign = (signs[0] * u + signs[1] * v + signs[2] * w) < 0 ? (-1.0f) : 1.0f;
/* binormal */
- /* B = sign * cross(N, T) */
+ /* `B = sign * cross(N, T)` */
cross_v3_v3v3(binormal, normal, tangent);
mul_v3_fl(binormal, sign);
diff --git a/source/blender/render/intern/engine.c b/source/blender/render/intern/engine.c
index 306d144f79d..db2458a636b 100644
--- a/source/blender/render/intern/engine.c
+++ b/source/blender/render/intern/engine.c
@@ -735,9 +735,9 @@ void RE_bake_engine_set_engine_parameters(Render *re, Main *bmain, Scene *scene)
render_copy_renderdata(&re->r, &scene->r);
}
-bool RE_bake_has_engine(Render *re)
+bool RE_bake_has_engine(const Render *re)
{
- RenderEngineType *type = RE_engines_find(re->r.engine);
+ const RenderEngineType *type = RE_engines_find(re->r.engine);
return (type->bake != NULL);
}
@@ -812,7 +812,7 @@ bool RE_bake_engine(Render *re,
engine->flag &= ~RE_ENGINE_RENDERING;
/* Free depsgraph outside of parts mutex lock, since this locks OpenGL context
- * while the the UI drawing might also lock the OpenGL context and parts mutex. */
+ * while the UI drawing might also lock the OpenGL context and parts mutex. */
engine_depsgraph_free(engine);
BLI_rw_mutex_lock(&re->partsmutex, THREAD_LOCK_WRITE);
@@ -1037,7 +1037,7 @@ bool RE_engine_render(Render *re, bool do_all)
/* re->engine becomes zero if user changed active render engine during render */
if (!engine_keep_depsgraph(engine) || !re->engine) {
/* Free depsgraph outside of parts mutex lock, since this locks OpenGL context
- * while the the UI drawing might also lock the OpenGL context and parts mutex. */
+ * while the UI drawing might also lock the OpenGL context and parts mutex. */
BLI_rw_mutex_unlock(&re->partsmutex);
engine_depsgraph_free(engine);
BLI_rw_mutex_lock(&re->partsmutex, THREAD_LOCK_WRITE);
diff --git a/source/blender/render/intern/initrender.c b/source/blender/render/intern/initrender.c
index 3494aa06833..3148625c866 100644
--- a/source/blender/render/intern/initrender.c
+++ b/source/blender/render/intern/initrender.c
@@ -191,7 +191,7 @@ void RE_SetCamera(Render *re, Object *cam_ob)
BKE_camera_params_from_object(&params, cam_ob);
BKE_camera_multiview_params(&re->r, &params, cam_ob, re->viewname);
- /* compute matrix, viewplane, .. */
+ /* Compute matrix, view-plane, etc. */
BKE_camera_params_compute_viewplane(&params, re->winx, re->winy, re->r.xasp, re->r.yasp);
BKE_camera_params_compute_matrix(&params);
@@ -272,7 +272,7 @@ void RE_parts_init(Render *re)
re->parts = BLI_ghash_new(
BLI_ghashutil_inthash_v4_p, BLI_ghashutil_inthash_v4_cmp, "render parts");
- /* just for readable code.. */
+ /* Just for readable code. */
xminb = re->disprect.xmin;
yminb = re->disprect.ymin;
xmaxb = re->disprect.xmax;
diff --git a/source/blender/render/intern/multires_bake.c b/source/blender/render/intern/multires_bake.c
index cba4628b63a..0452be68822 100644
--- a/source/blender/render/intern/multires_bake.c
+++ b/source/blender/render/intern/multires_bake.c
@@ -200,7 +200,7 @@ static void flush_pixel(const MResolvePixelData *data, const int x, const int y)
from_tang[2][r] = no0[r] * u + no1[r] * v + no2[r] * w;
}
- cross_v3_v3v3(from_tang[1], from_tang[2], from_tang[0]); /* B = sign * cross(N, T) */
+ cross_v3_v3v3(from_tang[1], from_tang[2], from_tang[0]); /* `B = sign * cross(N, T)` */
mul_v3_fl(from_tang[1], sign);
invert_m3_m3(to_tang, from_tang);
}
@@ -328,7 +328,7 @@ static void bake_rasterize(const MBakeRast *bake_rast,
yhi_beg = (int)ceilf(tmi);
yhi = (int)ceilf(thi);
- /*if (fTmi>ceilf(fTlo))*/
+ // if (fTmi>ceilf(fTlo))
rasterize_half(bake_rast, slo, tlo, smi, tmi, slo, tlo, shi, thi, ylo, yhi_beg, is_mid_right);
rasterize_half(bake_rast, smi, tmi, shi, thi, slo, tlo, shi, thi, yhi_beg, yhi, is_mid_right);
}
diff --git a/source/blender/render/intern/pipeline.c b/source/blender/render/intern/pipeline.c
index 20f868ca86f..d3ea27c6bb0 100644
--- a/source/blender/render/intern/pipeline.c
+++ b/source/blender/render/intern/pipeline.c
@@ -2840,7 +2840,7 @@ RenderPass *RE_create_gp_pass(RenderResult *rr, const char *layername, const cha
rl->recty = rr->recty;
}
- /* clear previous pass if exist or the new image will be over previous one*/
+ /* Clear previous pass if exist or the new image will be over previous one. */
RenderPass *rp = RE_pass_find_by_name(rl, RE_PASSNAME_COMBINED, viewname);
if (rp) {
if (rp->rect) {
diff --git a/source/blender/render/intern/render_result.c b/source/blender/render/intern/render_result.c
index 74c96392d48..70bd4f92512 100644
--- a/source/blender/render/intern/render_result.c
+++ b/source/blender/render/intern/render_result.c
@@ -363,7 +363,7 @@ RenderResult *render_result_new(
} \
} while (false)
- /* a renderlayer should always have a Combined pass*/
+ /* A renderlayer should always have a Combined pass. */
render_layer_add_pass(rr, rl, 4, "Combined", view, "RGBA");
if (view_layer->passflag & SCE_PASS_Z) {
@@ -804,9 +804,9 @@ void render_result_views_new(RenderResult *rr, const RenderData *rd)
}
}
-bool render_result_has_views(RenderResult *rr)
+bool render_result_has_views(const RenderResult *rr)
{
- RenderView *rv = rr->views.first;
+ const RenderView *rv = rr->views.first;
return (rv && (rv->next || rv->name[0]));
}
diff --git a/source/blender/render/intern/render_result.h b/source/blender/render/intern/render_result.h
index 67edd075e24..7732c113700 100644
--- a/source/blender/render/intern/render_result.h
+++ b/source/blender/render/intern/render_result.h
@@ -127,7 +127,7 @@ void render_result_rect_get_pixels(struct RenderResult *rr,
void render_result_views_shallowcopy(struct RenderResult *dst, struct RenderResult *src);
void render_result_views_shallowdelete(struct RenderResult *rr);
-bool render_result_has_views(struct RenderResult *rr);
+bool render_result_has_views(const struct RenderResult *rr);
#define FOREACH_VIEW_LAYER_TO_RENDER_BEGIN(re_, iter_) \
{ \
diff --git a/source/blender/render/intern/texture_image.c b/source/blender/render/intern/texture_image.c
index 0299315beaf..9f6980a5b0a 100644
--- a/source/blender/render/intern/texture_image.c
+++ b/source/blender/render/intern/texture_image.c
@@ -930,7 +930,7 @@ static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata
#else
const float wt = EWA_WTS[(int)(n * n * D)];
#endif
- /*const int out =*/ibuf_get_color_clip_bilerp(
+ /* `const int out =` */ ibuf_get_color_clip_bilerp(
tc, ibuf, ibuf->x * u, ibuf->y * v, AFD->intpol, AFD->extflag);
/* TXF alpha: clip |= out;
* TXF alpha: cw += out ? 0.0f : wt; */
@@ -945,8 +945,8 @@ static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata
texr->tr *= d;
texr->tg *= d;
texr->tb *= d;
- /* clipping can be ignored if alpha used, texr->ta already includes filtered edge */
- texr->ta = texr->talpha ? texr->ta * d : 1.0f; // TXF alpha: (clip ? cw*d : 1.0f);
+ /* Clipping can be ignored if alpha used, `texr->ta` already includes filtered edge */
+ texr->ta = texr->talpha ? texr->ta * d : 1.0f; /* TXF alpha: `(clip ? cw*d : 1.0f);` */
}
#undef EWA_MAXIDX
@@ -957,7 +957,7 @@ static void alpha_clip_aniso(
rctf rf;
/* TXF alpha: we're doing the same alpha-clip here as box-sample, but I'm doubting
- * if this is actually correct for the all the filtering algorithms .. */
+ * if this is actually correct for the all the filtering algorithms. */
if (!(extflag == TXC_REPT || extflag == TXC_EXTD)) {
rf.xmin = minx * (ibuf->x);
@@ -1744,7 +1744,7 @@ int imagewraposa(Tex *tex,
}
}
- /* choice: */
+ /* Choice: */
if (tex->imaflag & TEX_MIPMAP) {
ImBuf *previbuf, *curibuf;
float bumpscale;
diff --git a/source/blender/render/intern/texture_pointdensity.c b/source/blender/render/intern/texture_pointdensity.c
index 4254f6b0aa6..c0ff00d4f59 100644
--- a/source/blender/render/intern/texture_pointdensity.c
+++ b/source/blender/render/intern/texture_pointdensity.c
@@ -170,7 +170,7 @@ static void pointdensity_cache_psys(
ParticleSimulationData sim = {NULL};
ParticleData *pa = NULL;
float cfra = BKE_scene_frame_get(scene);
- int i /*, childexists*/ /* UNUSED */;
+ int i /*, Childexists*/ /* UNUSED */;
int total_particles;
int data_used;
float *data_vel, *data_life;
diff --git a/source/blender/sequencer/SEQ_iterator.h b/source/blender/sequencer/SEQ_iterator.h
index c7c2dc275ee..aa2e182e1c0 100644
--- a/source/blender/sequencer/SEQ_iterator.h
+++ b/source/blender/sequencer/SEQ_iterator.h
@@ -70,7 +70,8 @@ bool SEQ_iterator_ensure(SeqCollection *collection,
struct Sequence **r_seq);
struct Sequence *SEQ_iterator_yield(SeqIterator *iterator);
-SeqCollection *SEQ_collection_create(void);
+SeqCollection *SEQ_collection_create(const char *name);
+uint SEQ_collection_len(const SeqCollection *collection);
bool SEQ_collection_append_strip(struct Sequence *seq, SeqCollection *data);
bool SEQ_collection_remove_strip(struct Sequence *seq, SeqCollection *data);
void SEQ_collection_free(SeqCollection *collection);
diff --git a/source/blender/sequencer/SEQ_sequencer.h b/source/blender/sequencer/SEQ_sequencer.h
index fd4181a5a54..706f4064bf3 100644
--- a/source/blender/sequencer/SEQ_sequencer.h
+++ b/source/blender/sequencer/SEQ_sequencer.h
@@ -55,6 +55,9 @@ struct SequencerToolSettings *SEQ_tool_settings_ensure(struct Scene *scene);
void SEQ_tool_settings_free(struct SequencerToolSettings *tool_settings);
eSeqImageFitMethod SEQ_tool_settings_fit_method_get(struct Scene *scene);
void SEQ_tool_settings_fit_method_set(struct Scene *scene, eSeqImageFitMethod fit_method);
+short SEQ_tool_settings_snap_flag_get(struct Scene *scene);
+short SEQ_tool_settings_snap_mode_get(struct Scene *scene);
+int SEQ_tool_settings_snap_distance_get(struct Scene *scene);
struct SequencerToolSettings *SEQ_tool_settings_copy(struct SequencerToolSettings *tool_settings);
struct Editing *SEQ_editing_get(struct Scene *scene, bool alloc);
struct Editing *SEQ_editing_ensure(struct Scene *scene);
diff --git a/source/blender/sequencer/SEQ_utils.h b/source/blender/sequencer/SEQ_utils.h
index 432e8fdd0c0..99603dc8a3e 100644
--- a/source/blender/sequencer/SEQ_utils.h
+++ b/source/blender/sequencer/SEQ_utils.h
@@ -49,7 +49,7 @@ struct Sequence *SEQ_get_sequence_by_name(struct ListBase *seqbase,
bool recursive);
struct Mask *SEQ_active_mask_get(struct Scene *scene);
void SEQ_alpha_mode_from_file_extension(struct Sequence *seq);
-bool SEQ_sequence_has_source(struct Sequence *seq);
+bool SEQ_sequence_has_source(const struct Sequence *seq);
void SEQ_set_scale_to_fit(const struct Sequence *seq,
const int image_width,
const int image_height,
diff --git a/source/blender/sequencer/intern/clipboard.c b/source/blender/sequencer/intern/clipboard.c
index 29cb749bc99..e3f82dd4bb0 100644
--- a/source/blender/sequencer/intern/clipboard.c
+++ b/source/blender/sequencer/intern/clipboard.c
@@ -100,7 +100,7 @@ static void seqclipboard_ptr_restore(Main *bmain, ID **id_pt)
id_restore = (ID_PT)->newid;
}
else {
- /* the pointer of the same name still exists */
+ /* The pointer of the same name still exists. */
id_restore = BLI_findstring(lb, (ID_PT)->name + 2, offsetof(ID, name) + 2);
}
diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c
index d41a2c19d55..1f518a69395 100644
--- a/source/blender/sequencer/intern/effects.c
+++ b/source/blender/sequencer/intern/effects.c
@@ -2414,19 +2414,19 @@ static void transform_image(int x,
for (int yi = start_line; yi < start_line + total_lines; yi++) {
for (int xi = 0; xi < x; xi++) {
- /* translate point */
+ /* Translate point. */
float xt = xi - translate_x;
float yt = yi - translate_y;
- /* rotate point with center ref */
+ /* Rotate point with center ref. */
float xr = c * xt + s * yt;
float yr = -s * xt + c * yt;
- /* scale point with center ref */
+ /* Scale point with center ref. */
xt = xr / scale_x;
yt = yr / scale_y;
- /* undo reference center point */
+ /* Undo reference center point. */
xt += (x / 2.0f);
yt += (y / 2.0f);
@@ -2651,7 +2651,7 @@ static void RVBlurBitmap2_float(float *map, int width, int height, float blur, i
swap = temp;
temp = map; /* map = swap; */ /* UNUSED */
- /* Tidy up */
+ /* Tidy up. */
MEM_freeN(filter);
MEM_freeN(temp);
}
@@ -3214,7 +3214,7 @@ void seq_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool force)
else {
/* if there is no fcurve, use value as simple multiplier */
if (!fcu) {
- fallback_fac = seq->speed_fader; /* same as speed_factor in rna*/
+ fallback_fac = seq->speed_fader; /* Same as speed_factor in RNA. */
}
}
diff --git a/source/blender/sequencer/intern/iterator.c b/source/blender/sequencer/intern/iterator.c
index 9bbc5362f18..20a2ee3b183 100644
--- a/source/blender/sequencer/intern/iterator.c
+++ b/source/blender/sequencer/intern/iterator.c
@@ -106,15 +106,23 @@ void SEQ_collection_free(SeqCollection *collection)
*
* \return empty strip collection.
*/
-SeqCollection *SEQ_collection_create(void)
+SeqCollection *SEQ_collection_create(const char *name)
{
- SeqCollection *collection = MEM_callocN(sizeof(SeqCollection), "SeqCollection");
+ SeqCollection *collection = MEM_callocN(sizeof(SeqCollection), name);
collection->set = BLI_gset_new(
BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "SeqCollection GSet");
return collection;
}
/**
+ * Return number of items in collection.
+ */
+uint SEQ_collection_len(const SeqCollection *collection)
+{
+ return BLI_gset_len(collection->set);
+}
+
+/**
* Query strips from seqbase. seq_reference is used by query function as filter condition.
*
* \param seq_reference: reference strip for query function
@@ -128,7 +136,7 @@ SeqCollection *SEQ_query_by_reference(Sequence *seq_reference,
ListBase *seqbase,
SeqCollection *collection))
{
- SeqCollection *collection = SEQ_collection_create();
+ SeqCollection *collection = SEQ_collection_create(__func__);
seq_query_func(seq_reference, seqbase, collection);
return collection;
}
@@ -215,7 +223,7 @@ void SEQ_collection_expand(ListBase *seqbase,
*/
SeqCollection *SEQ_query_all_strips_recursive(ListBase *seqbase)
{
- SeqCollection *collection = SEQ_collection_create();
+ SeqCollection *collection = SEQ_collection_create(__func__);
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
if (seq->type == SEQ_TYPE_META) {
SEQ_collection_merge(collection, SEQ_query_all_strips_recursive(&seq->seqbase));
@@ -233,7 +241,7 @@ SeqCollection *SEQ_query_all_strips_recursive(ListBase *seqbase)
*/
SeqCollection *SEQ_query_all_strips(ListBase *seqbase)
{
- SeqCollection *collection = SEQ_collection_create();
+ SeqCollection *collection = SEQ_collection_create(__func__);
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
SEQ_collection_append_strip(seq, collection);
}
@@ -248,7 +256,7 @@ SeqCollection *SEQ_query_all_strips(ListBase *seqbase)
*/
SeqCollection *SEQ_query_selected_strips(ListBase *seqbase)
{
- SeqCollection *collection = SEQ_collection_create();
+ SeqCollection *collection = SEQ_collection_create(__func__);
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
if ((seq->flag & SELECT) == 0) {
continue;
diff --git a/source/blender/sequencer/intern/modifier.c b/source/blender/sequencer/intern/modifier.c
index b6f56025e6b..75c7d599be5 100644
--- a/source/blender/sequencer/intern/modifier.c
+++ b/source/blender/sequencer/intern/modifier.c
@@ -1438,7 +1438,7 @@ ImBuf *SEQ_modifier_apply_stack(const SeqRenderData *context,
if (smd->mask_time == SEQUENCE_MASK_TIME_RELATIVE) {
frame_offset = seq->start;
}
- else /*if (smd->mask_time == SEQUENCE_MASK_TIME_ABSOLUTE)*/ {
+ else /* if (smd->mask_time == SEQUENCE_MASK_TIME_ABSOLUTE) */ {
frame_offset = smd->mask_id ? ((Mask *)smd->mask_id)->sfra : 0;
}
diff --git a/source/blender/sequencer/intern/prefetch.c b/source/blender/sequencer/intern/prefetch.c
index 4317fa3a850..15609a76f5c 100644
--- a/source/blender/sequencer/intern/prefetch.c
+++ b/source/blender/sequencer/intern/prefetch.c
@@ -91,7 +91,7 @@ typedef struct PrefetchJob {
bool stop;
} PrefetchJob;
-static bool seq_prefetch_is_playing(Main *bmain)
+static bool seq_prefetch_is_playing(const Main *bmain)
{
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
if (screen->animtimer) {
@@ -101,7 +101,7 @@ static bool seq_prefetch_is_playing(Main *bmain)
return false;
}
-static bool seq_prefetch_is_scrubbing(Main *bmain)
+static bool seq_prefetch_is_scrubbing(const Main *bmain)
{
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
@@ -260,7 +260,7 @@ static void seq_prefetch_update_area(PrefetchJob *pfjob)
void SEQ_prefetch_stop_all(void)
{
- /*TODO(Richard): Use wm_jobs for prefetch, or pass main. */
+ /* TODO(Richard): Use wm_jobs for prefetch, or pass main. */
for (Scene *scene = G.main->scenes.first; scene; scene = scene->id.next) {
SEQ_prefetch_stop(scene);
}
@@ -533,7 +533,7 @@ static PrefetchJob *seq_prefetch_start_ex(const SeqRenderData *context, float cf
return pfjob;
}
-/* Start or resume prefetching*/
+/* Start or resume prefetching. */
void seq_prefetch_start(const SeqRenderData *context, float timeline_frame)
{
Scene *scene = context->scene;
diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c
index 16adc392b3b..2f6f0180835 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -298,7 +298,7 @@ static bool must_render_strip(const Sequence *seq, SeqCollection *strips_at_time
return true;
}
- /* If strip has effects in stack, and all effects are above this strip, it it not rendered. */
+ /* If strip has effects in stack, and all effects are above this strip, it is not rendered. */
if (seq_have_effect_in_stack) {
return false;
}
@@ -308,7 +308,7 @@ static bool must_render_strip(const Sequence *seq, SeqCollection *strips_at_time
static SeqCollection *query_strips_at_frame(ListBase *seqbase, const int timeline_frame)
{
- SeqCollection *collection = SEQ_collection_create();
+ SeqCollection *collection = SEQ_collection_create(__func__);
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
if (SEQ_time_strip_intersects_frame(seq, timeline_frame)) {
diff --git a/source/blender/sequencer/intern/sequence_lookup.c b/source/blender/sequencer/intern/sequence_lookup.c
index 72567dc394e..25b42957d99 100644
--- a/source/blender/sequencer/intern/sequence_lookup.c
+++ b/source/blender/sequencer/intern/sequence_lookup.c
@@ -87,7 +87,7 @@ static void seq_sequence_lookup_rebuild(const struct Scene *scene, struct Sequen
seq_sequence_lookup_build(scene, *lookup);
}
-static bool seq_sequence_lookup_is_valid(struct SequenceLookup *lookup)
+static bool seq_sequence_lookup_is_valid(const struct SequenceLookup *lookup)
{
return (lookup->tag & SEQ_LOOKUP_TAG_INVALID) == 0;
}
diff --git a/source/blender/sequencer/intern/sequencer.c b/source/blender/sequencer/intern/sequencer.c
index 8cd67195c30..7907b11989c 100644
--- a/source/blender/sequencer/intern/sequencer.c
+++ b/source/blender/sequencer/intern/sequencer.c
@@ -311,6 +311,9 @@ SequencerToolSettings *SEQ_tool_settings_init(void)
SequencerToolSettings *tool_settings = MEM_callocN(sizeof(SequencerToolSettings),
"Sequencer tool settings");
tool_settings->fit_method = SEQ_SCALE_TO_FIT;
+ tool_settings->snap_mode = SEQ_SNAP_TO_STRIPS | SEQ_SNAP_TO_CURRENT_FRAME |
+ SEQ_SNAP_TO_STRIP_HOLD;
+ tool_settings->snap_distance = 15;
return tool_settings;
}
@@ -336,6 +339,24 @@ eSeqImageFitMethod SEQ_tool_settings_fit_method_get(Scene *scene)
return tool_settings->fit_method;
}
+short SEQ_tool_settings_snap_mode_get(Scene *scene)
+{
+ const SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene);
+ return tool_settings->snap_mode;
+}
+
+short SEQ_tool_settings_snap_flag_get(Scene *scene)
+{
+ const SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene);
+ return tool_settings->snap_flag;
+}
+
+int SEQ_tool_settings_snap_distance_get(Scene *scene)
+{
+ const SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene);
+ return tool_settings->snap_distance;
+}
+
void SEQ_tool_settings_fit_method_set(Scene *scene, eSeqImageFitMethod fit_method)
{
SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene);
diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c
index 3e6eb74fcb3..b9278b9f971 100644
--- a/source/blender/sequencer/intern/strip_edit.c
+++ b/source/blender/sequencer/intern/strip_edit.c
@@ -255,7 +255,7 @@ bool SEQ_edit_move_strip_to_meta(Scene *scene,
return false;
}
- SeqCollection *collection = SEQ_collection_create();
+ SeqCollection *collection = SEQ_collection_create(__func__);
SEQ_collection_append_strip(src_seq, collection);
SEQ_collection_expand(seqbase, collection, SEQ_query_strip_effect_chain);
@@ -396,7 +396,7 @@ Sequence *SEQ_edit_strip_split(Main *bmain,
return NULL;
}
- SeqCollection *collection = SEQ_collection_create();
+ SeqCollection *collection = SEQ_collection_create(__func__);
SEQ_collection_append_strip(seq, collection);
SEQ_collection_expand(seqbase, collection, SEQ_query_strip_effect_chain);
diff --git a/source/blender/sequencer/intern/strip_time.c b/source/blender/sequencer/intern/strip_time.c
index ecec317ed25..e5eb0b3f00f 100644
--- a/source/blender/sequencer/intern/strip_time.c
+++ b/source/blender/sequencer/intern/strip_time.c
@@ -60,7 +60,7 @@ float seq_give_frame_index(Sequence *seq, float timeline_frame)
}
if (seq->flag & SEQ_REVERSE_FRAMES) {
- /*reverse frame in this sequence */
+ /* Reverse frame in this sequence. */
if (timeline_frame <= sta) {
frame_index = end - sta;
}
diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c
index a287466dfb2..98640ea8a5c 100644
--- a/source/blender/sequencer/intern/utils.c
+++ b/source/blender/sequencer/intern/utils.c
@@ -530,7 +530,7 @@ void SEQ_alpha_mode_from_file_extension(Sequence *seq)
/* called on draw, needs to be fast,
* we could cache and use a flag if we want to make checks for file paths resolving for eg. */
-bool SEQ_sequence_has_source(Sequence *seq)
+bool SEQ_sequence_has_source(const Sequence *seq)
{
switch (seq->type) {
case SEQ_TYPE_MASK:
diff --git a/source/blender/simulation/intern/SIM_mass_spring.cpp b/source/blender/simulation/intern/SIM_mass_spring.cpp
index ce626498e8e..cf654ebff07 100644
--- a/source/blender/simulation/intern/SIM_mass_spring.cpp
+++ b/source/blender/simulation/intern/SIM_mass_spring.cpp
@@ -277,10 +277,12 @@ static void cloth_setup_constraints(ClothModifierData *clmd)
}
}
-/* computes where the cloth would be if it were subject to perfectly stiff edges
+/**
+ * Computes where the cloth would be if it were subject to perfectly stiff edges
* (edge distance constraints) in a lagrangian solver. then add forces to help
* guide the implicit solver to that state. this function is called after
- * collisions*/
+ * collisions.
+ */
static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob),
ClothModifierData *clmd,
float (*initial_cos)[3],
@@ -352,7 +354,7 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob),
for (i = 0; i < cloth->mvert_num; i++, cv++) {
float vec[3];
- /*compute forces*/
+ /* Compute forces. */
sub_v3_v3v3(vec, cos[i], cv->tx);
mul_v3_fl(vec, cv->mass * dt * 20.0f);
add_v3_v3(cv->tv, vec);
@@ -625,7 +627,7 @@ static void cloth_calc_force(
#endif
/* handle pressure forces (making sure that this never gets computed for hair). */
if ((parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE) && (clmd->hairdata == nullptr)) {
- /* The difference in pressure between the inside and outside of the mesh.*/
+ /* The difference in pressure between the inside and outside of the mesh. */
float pressure_difference = 0.0f;
float volume_factor = 1.0f;
diff --git a/source/blender/simulation/intern/hair_volume.cpp b/source/blender/simulation/intern/hair_volume.cpp
index 08af2344bc4..d954d9b5fff 100644
--- a/source/blender/simulation/intern/hair_volume.cpp
+++ b/source/blender/simulation/intern/hair_volume.cpp
@@ -722,7 +722,7 @@ bool SIM_hair_volume_solve_divergence(HairGrid *grid,
const float flowfac = grid->cellsize;
const float inv_flowfac = 1.0f / grid->cellsize;
- /*const int num_cells = hair_grid_size(grid->res);*/
+ // const int num_cells = hair_grid_size(grid->res);
const int res[3] = {grid->res[0], grid->res[1], grid->res[2]};
const int resA[3] = {grid->res[0] + 2, grid->res[1] + 2, grid->res[2] + 2};
@@ -891,7 +891,7 @@ bool SIM_hair_volume_solve_divergence(HairGrid *grid,
neighbor_hi_index[neighbors_hi++] = u + strideA2;
}
- /*int liquid_neighbors = neighbors_lo + neighbors_hi;*/
+ // int liquid_neighbors = neighbors_lo + neighbors_hi;
non_solid_neighbors = 6;
for (n = 0; n < neighbors_lo; n++) {
diff --git a/source/blender/simulation/intern/implicit_blender.c b/source/blender/simulation/intern/implicit_blender.c
index cf092d7716a..4c01fd3aee0 100644
--- a/source/blender/simulation/intern/implicit_blender.c
+++ b/source/blender/simulation/intern/implicit_blender.c
@@ -168,7 +168,7 @@ DO_INLINE void zero_lfvector(float (*to)[3], unsigned int verts)
{
memset(to, 0.0f, verts * sizeof(lfVector));
}
-/* multiply long vector with scalar*/
+/* Multiply long vector with scalar. */
DO_INLINE void mul_lfvectorS(float (*to)[3],
float (*fLongVector)[3],
float scalar,
@@ -180,7 +180,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3],
mul_fvector_S(to[i], fLongVector[i], scalar);
}
}
-/* multiply long vector with scalar*/
+/* Multiply long vector with scalar. */
/* A -= B * float */
DO_INLINE void submul_lfvectorS(float (*to)[3],
float (*fLongVector)[3],
@@ -613,7 +613,7 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
}
}
-/* SPARSE SYMMETRIC multiply big matrix with long vector*/
+/* SPARSE SYMMETRIC multiply big matrix with long vector. */
/* STATUS: verified */
DO_INLINE void mul_bfmatrix_lfvector(float (*to)[3], fmatrix3x3 *from, lfVector *fLongVector)
{
@@ -644,7 +644,7 @@ DO_INLINE void mul_bfmatrix_lfvector(float (*to)[3], fmatrix3x3 *from, lfVector
del_lfvector(temp);
}
-/* SPARSE SYMMETRIC sub big matrix with big matrix*/
+/* SPARSE SYMMETRIC sub big matrix with big matrix. */
/* A -= B * float + C * float --> for big matrix */
/* VERIFIED */
DO_INLINE void subadd_bfmatrixS_bfmatrixS(
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index f3c4cb93e7d..319683c8d8e 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -775,20 +775,20 @@ enum {
struct wmJob *WM_jobs_get(struct wmWindowManager *wm,
struct wmWindow *win,
- void *owner,
+ const void *owner,
const char *name,
int flag,
int job_type);
-bool WM_jobs_test(struct wmWindowManager *wm, void *owner, int job_type);
-float WM_jobs_progress(struct wmWindowManager *wm, void *owner);
-char *WM_jobs_name(struct wmWindowManager *wm, void *owner);
-double WM_jobs_starttime(struct wmWindowManager *wm, void *owner);
-void *WM_jobs_customdata(struct wmWindowManager *wm, void *owner);
+bool WM_jobs_test(const struct wmWindowManager *wm, const void *owner, int job_type);
+float WM_jobs_progress(const struct wmWindowManager *wm, const void *owner);
+const char *WM_jobs_name(const struct wmWindowManager *wm, const void *owner);
+double WM_jobs_starttime(const struct wmWindowManager *wm, const void *owner);
+void *WM_jobs_customdata(struct wmWindowManager *wm, const void *owner);
void *WM_jobs_customdata_from_type(struct wmWindowManager *wm, int job_type);
-bool WM_jobs_is_running(struct wmJob *);
-bool WM_jobs_is_stopped(wmWindowManager *wm, void *owner);
+bool WM_jobs_is_running(const struct wmJob *wm_job);
+bool WM_jobs_is_stopped(const wmWindowManager *wm, const void *owner);
void *WM_jobs_customdata_get(struct wmJob *);
void WM_jobs_customdata_set(struct wmJob *, void *customdata, void (*free)(void *));
void WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned int endnote);
@@ -805,15 +805,15 @@ void WM_jobs_callbacks(struct wmJob *,
void (*endjob)(void *));
void WM_jobs_start(struct wmWindowManager *wm, struct wmJob *);
-void WM_jobs_stop(struct wmWindowManager *wm, void *owner, void *startjob);
+void WM_jobs_stop(struct wmWindowManager *wm, const void *owner, void *startjob);
void WM_jobs_kill(struct wmWindowManager *wm,
void *owner,
void (*)(void *, short int *, short int *, float *));
void WM_jobs_kill_all(struct wmWindowManager *wm);
-void WM_jobs_kill_all_except(struct wmWindowManager *wm, void *owner);
-void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type);
+void WM_jobs_kill_all_except(struct wmWindowManager *wm, const void *owner);
+void WM_jobs_kill_type(struct wmWindowManager *wm, const void *owner, int job_type);
-bool WM_jobs_has_running(struct wmWindowManager *wm);
+bool WM_jobs_has_running(const struct wmWindowManager *wm);
void WM_job_main_thread_lock_acquire(struct wmJob *job);
void WM_job_main_thread_lock_release(struct wmJob *job);
diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h
index d2e2b9c8f3b..018165634f2 100644
--- a/source/blender/windowmanager/WM_toolsystem.h
+++ b/source/blender/windowmanager/WM_toolsystem.h
@@ -38,7 +38,7 @@ struct wmMsgSubscribeKey;
struct wmMsgSubscribeValue;
struct wmOperatorType;
-/* wm_toolsystem.c */
+/* wm_toolsystem.c */
#define WM_TOOLSYSTEM_SPACE_MASK \
((1 << SPACE_IMAGE) | (1 << SPACE_NODE) | (1 << SPACE_VIEW3D) | (1 << SPACE_SEQ))
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 0b26f3c54ae..e83e36d7a9b 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -232,7 +232,7 @@ typedef enum eOperatorPropTags {
#define KM_ALT2 64
#define KM_OSKEY2 128
-/* KM_MOD_ flags for wmKeyMapItem and wmEvent.alt/shift/oskey/ctrl */
+/* KM_MOD_ flags for `wmKeyMapItem` and `wmEvent.alt/shift/oskey/ctrl`. */
/* note that KM_ANY and KM_NOTHING are used with these defines too */
#define KM_MOD_FIRST 1
#define KM_MOD_SECOND 2
@@ -326,7 +326,7 @@ typedef struct wmNotifier {
#define ND_LAYOUTDELETE (2 << 16)
#define ND_ANIMPLAY (4 << 16)
#define ND_GPENCIL (5 << 16)
-#define ND_EDITOR_CHANGED (6 << 16) /*sent to new editors after switching to them*/
+#define ND_EDITOR_CHANGED (6 << 16) /* Sent to new editors after switching to them. */
#define ND_LAYOUTSET (7 << 16)
#define ND_SKETCH (8 << 16)
#define ND_WORKSPACE_SET (9 << 16)
@@ -407,7 +407,7 @@ typedef struct wmNotifier {
#define ND_GPENCIL_EDITMODE (85 << 16)
/* NC_GEOM Geometry */
-/* Mesh, Curve, MetaBall, Armature, .. */
+/* Mesh, Curve, MetaBall, Armature, etc. */
#define ND_SELECT (90 << 16)
#define ND_DATA (91 << 16)
#define ND_VERTEX_GROUP (92 << 16)
@@ -433,7 +433,8 @@ typedef struct wmNotifier {
#define ND_SPACE_NLA (16 << 16)
#define ND_SPACE_SEQUENCER (17 << 16)
#define ND_SPACE_NODE_VIEW (18 << 16)
-#define ND_SPACE_CHANGED (19 << 16) /*sent to a new editor type after it's replaced an old one*/
+/* Sent to a new editor type after it's replaced an old one. */
+#define ND_SPACE_CHANGED (19 << 16)
#define ND_SPACE_CLIP (20 << 16)
#define ND_SPACE_FILE_PREVIEW (21 << 16)
#define ND_SPACE_SPREADSHEET (22 << 16)
diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h
index db18ceb0e7f..9a993e1f8d7 100644
--- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h
+++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h
@@ -191,7 +191,7 @@ typedef enum eWM_GizmoFlagMapTypeUpdateFlag {
typedef enum {
/* Drag with extra precision (Shift). */
WM_GIZMO_TWEAK_PRECISE = (1 << 0),
- /* Drag with snap enabled (Ctrl). */
+ /* Drag with snap enabled (Ctrl). */
WM_GIZMO_TWEAK_SNAP = (1 << 1),
} eWM_GizmoFlagTweak;
@@ -301,7 +301,7 @@ typedef struct wmGizmoProperty {
PropertyRNA *prop;
int index;
- /* Optional functions for converting to/from RNA */
+ /* Optional functions for converting to/from RNA. */
struct {
wmGizmoPropertyFnGet value_get_fn;
wmGizmoPropertyFnSet value_set_fn;
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 46e47ae95c4..6dd3e4186c4 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -153,7 +153,7 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id)
if (win->workspace_hook != NULL) {
/* We need to restore a pointer to this later when reading workspaces,
* so store in global oldnew-map.
- * Note that this is only needed for versioning of older .blend files now.. */
+ * Note that this is only needed for versioning of older .blend files now. */
BLO_read_data_globmap_add(reader, hook, win->workspace_hook);
/* Cleanup pointers to data outside of this data-block scope. */
win->workspace_hook->act_layout = NULL;
diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c
index 0050c834a56..905b0f7b128 100644
--- a/source/blender/windowmanager/intern/wm_event_query.c
+++ b/source/blender/windowmanager/intern/wm_event_query.c
@@ -218,7 +218,7 @@ bool WM_event_type_mask_test(const int event_type, const enum eEventType_Mask ma
/** \name Event Motion Queries
* \{ */
-/* for modal callbacks, check configuration for how to interpret exit with tweaks */
+/* for modal callbacks, check configuration for how to interpret exit with tweaks. */
bool WM_event_is_modal_tweak_exit(const wmEvent *event, int tweak_event)
{
/* if the release-confirm userpref setting is enabled,
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 750b4e5e60d..b82b3c1ff5d 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -96,7 +96,7 @@
*
* Without tools using press events which would prevent click/drag events getting to the gizmos.
*
- * This is not a fool proof solution since since it's possible the gizmo operators would pass
+ * This is not a fool proof solution since it's possible the gizmo operators would pass
* through these events when called, see: T65479.
*/
#define USE_GIZMO_MOUSE_PRIORITY_HACK
@@ -2084,7 +2084,7 @@ static int wm_handler_operator_call(bContext *C,
wm->op_undo_depth--;
}
- /* When the window changes the the modal modifier may have loaded a new blend file
+ /* When the window changes the modal modifier may have loaded a new blend file
* (the `system_demo_mode` add-on does this), so we have to assume the event,
* operator, area, region etc have all been freed. */
if ((CTX_wm_window(C) == win)) {
@@ -3493,7 +3493,7 @@ void wm_event_do_handlers(bContext *C)
}
/* If press was handled, we don't want to do click. This way
- * press in tool keymap can override click in editor keymap.*/
+ * press in tool key-map can override click in editor key-map. */
if (ISMOUSE_BUTTON(event->type) && event->val == KM_PRESS &&
!wm_action_not_handled(action)) {
win->event_queue_check_click = false;
@@ -4753,8 +4753,8 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
event.val = KM_DBL_CLICK;
}
- /* This case happens on holding a key pressed, it should not generate
- * press events events with the same key as modifier. */
+ /* This case happens on holding a key pressed,
+ * it should not generate press events with the same key as modifier. */
if (event.keymodifier == event.type) {
event.keymodifier = 0;
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 93a62bb5831..6230b240d11 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -52,12 +52,15 @@
#include "BLI_blenlib.h"
#include "BLI_fileops_types.h"
#include "BLI_linklist.h"
+#include "BLI_math.h"
#include "BLI_system.h"
#include "BLI_threads.h"
#include "BLI_timer.h"
#include "BLI_utildefines.h"
#include BLI_SYSTEM_PID_H
+#include "PIL_time.h"
+
#include "BLT_translation.h"
#include "BLF_api.h"
@@ -733,6 +736,97 @@ static void wm_file_read_post(bContext *C,
/** \name Read Main Blend-File API
* \{ */
+static void file_read_reports_finalize(BlendFileReadReport *bf_reports)
+{
+ double duration_whole_minutes, duration_whole_seconds;
+ double duration_libraries_minutes, duration_libraries_seconds;
+ double duration_lib_override_minutes, duration_lib_override_seconds;
+ double duration_lib_override_resync_minutes, duration_lib_override_resync_seconds;
+ double duration_lib_override_recursive_resync_minutes,
+ duration_lib_override_recursive_resync_seconds;
+
+ BLI_math_time_seconds_decompose(bf_reports->duration.whole,
+ NULL,
+ NULL,
+ &duration_whole_minutes,
+ &duration_whole_seconds,
+ NULL);
+ BLI_math_time_seconds_decompose(bf_reports->duration.libraries,
+ NULL,
+ NULL,
+ &duration_libraries_minutes,
+ &duration_libraries_seconds,
+ NULL);
+ BLI_math_time_seconds_decompose(bf_reports->duration.lib_overrides,
+ NULL,
+ NULL,
+ &duration_lib_override_minutes,
+ &duration_lib_override_seconds,
+ NULL);
+ BLI_math_time_seconds_decompose(bf_reports->duration.lib_overrides_resync,
+ NULL,
+ NULL,
+ &duration_lib_override_resync_minutes,
+ &duration_lib_override_resync_seconds,
+ NULL);
+ BLI_math_time_seconds_decompose(bf_reports->duration.lib_overrides_recursive_resync,
+ NULL,
+ NULL,
+ &duration_lib_override_recursive_resync_minutes,
+ &duration_lib_override_recursive_resync_seconds,
+ NULL);
+
+ CLOG_INFO(
+ &LOG, 0, "Blender file read in %.0fm%.2fs", duration_whole_minutes, duration_whole_seconds);
+ CLOG_INFO(&LOG,
+ 0,
+ " * Loading libraries: %.0fm%.2fs",
+ duration_libraries_minutes,
+ duration_libraries_seconds);
+ CLOG_INFO(&LOG,
+ 0,
+ " * Applying overrides: %.0fm%.2fs",
+ duration_lib_override_minutes,
+ duration_lib_override_seconds);
+ CLOG_INFO(&LOG,
+ 0,
+ " * Resyncing overrides: %.0fm%.2fs (%d root overrides), including recursive "
+ "resyncs: %.0fm%.2fs)",
+ duration_lib_override_resync_minutes,
+ duration_lib_override_resync_seconds,
+ bf_reports->count.resynced_lib_overrides,
+ duration_lib_override_recursive_resync_minutes,
+ duration_lib_override_recursive_resync_seconds);
+ if (bf_reports->resynced_lib_overrides_libraries_count != 0) {
+ for (LinkNode *node_lib = bf_reports->resynced_lib_overrides_libraries; node_lib != NULL;
+ node_lib = node_lib->next) {
+ Library *library = node_lib->link;
+ BKE_reportf(
+ bf_reports->reports, RPT_INFO, "Library %s needs overrides resync.", library->filepath);
+ }
+ }
+ if (bf_reports->count.missing_libraries != 0 || bf_reports->count.missing_linked_id != 0) {
+ BKE_reportf(bf_reports->reports,
+ RPT_WARNING,
+ "%d libraries and %d linked data-blocks are missing, please check the "
+ "Info and Outliner editors for details",
+ bf_reports->count.missing_libraries,
+ bf_reports->count.missing_linked_id);
+ }
+ if (bf_reports->resynced_lib_overrides_libraries_count != 0) {
+ BKE_reportf(bf_reports->reports,
+ RPT_WARNING,
+ "%d libraries have overrides needing resync (auto resynced in %.0fm%.2fs), "
+ "please check the Info editor for details",
+ bf_reports->resynced_lib_overrides_libraries_count,
+ duration_lib_override_recursive_resync_minutes,
+ duration_lib_override_recursive_resync_seconds);
+ }
+
+ BLI_linklist_free(bf_reports->resynced_lib_overrides_libraries, NULL);
+ bf_reports->resynced_lib_overrides_libraries = NULL;
+}
+
bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
{
/* assume automated tasks with background, don't write recent file list */
@@ -763,7 +857,9 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
.skip_flags = BLO_READ_SKIP_USERDEF,
};
- struct BlendFileData *bfd = BKE_blendfile_read(filepath, &params, reports);
+ BlendFileReadReport bf_reports = {.reports = reports,
+ .duration.whole = PIL_check_seconds_timer()};
+ struct BlendFileData *bfd = BKE_blendfile_read(filepath, &params, &bf_reports);
if (bfd != NULL) {
wm_file_read_pre(C, use_data, use_userdef);
@@ -776,7 +872,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
* need to re-enable it here else drivers and registered scripts won't work. */
const int G_f_orig = G.f;
- BKE_blendfile_read_setup(C, bfd, &params, reports);
+ BKE_blendfile_read_setup(C, bfd, &params, &bf_reports);
if (G.f != G_f_orig) {
const int flags_keep = G_FLAG_ALL_RUNTIME;
@@ -807,6 +903,9 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
wm_file_read_post(C, false, false, use_data, use_userdef, false);
+ bf_reports.duration.whole = PIL_check_seconds_timer() - bf_reports.duration.whole;
+ file_read_reports_finalize(&bf_reports);
+
success = true;
}
}
@@ -1086,11 +1185,12 @@ void wm_homefile_read(bContext *C,
.is_startup = true,
.skip_flags = skip_flags | BLO_READ_SKIP_USERDEF,
};
+ BlendFileReadReport bf_reports = {.reports = reports};
+ struct BlendFileData *bfd = BKE_blendfile_read(filepath_startup, &params, &bf_reports);
- struct BlendFileData *bfd = BKE_blendfile_read(filepath_startup, &params, NULL);
if (bfd != NULL) {
BKE_blendfile_read_setup_ex(
- C, bfd, &params, NULL, update_defaults && use_data, app_template);
+ C, bfd, &params, &bf_reports, update_defaults && use_data, app_template);
success = true;
}
}
@@ -1120,7 +1220,7 @@ void wm_homefile_read(bContext *C,
struct BlendFileData *bfd = BKE_blendfile_read_from_memory(
datatoc_startup_blend, datatoc_startup_blend_size, &params, NULL);
if (bfd != NULL) {
- BKE_blendfile_read_setup_ex(C, bfd, &params, NULL, true, NULL);
+ BKE_blendfile_read_setup_ex(C, bfd, &params, &(BlendFileReadReport){NULL}, true, NULL);
success = true;
}
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index c1c5eac8382..fec5a516688 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -239,12 +239,14 @@ static void wm_link_do(WMLinkAppendData *lapp_data,
for (lib_idx = 0, liblink = lapp_data->libraries.list; liblink;
lib_idx++, liblink = liblink->next) {
char *libname = liblink->link;
+ BlendFileReadReport bf_reports = {.reports = reports};
if (STREQ(libname, BLO_EMBEDDED_STARTUP_BLEND)) {
- bh = BLO_blendhandle_from_memory(datatoc_startup_blend, datatoc_startup_blend_size);
+ bh = BLO_blendhandle_from_memory(
+ datatoc_startup_blend, datatoc_startup_blend_size, &bf_reports);
}
else {
- bh = BLO_blendhandle_from_file(libname, reports);
+ bh = BLO_blendhandle_from_file(libname, &bf_reports);
}
if (bh == NULL) {
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 1cddc019ff8..6494c337c10 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -113,7 +113,7 @@ struct wmJob {
unsigned int note, endnote;
/* internal */
- void *owner;
+ const void *owner;
int flag;
short suspended, running, ready, do_update, stop, job_type;
float progress;
@@ -158,7 +158,7 @@ static void wm_job_main_thread_yield(wmJob *wm_job)
/**
* Finds if type or owner, compare for it, otherwise any matching job.
*/
-static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
+static wmJob *wm_job_find(const wmWindowManager *wm, const void *owner, const int job_type)
{
if (owner && job_type) {
LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
@@ -193,8 +193,12 @@ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
* \note every owner only gets a single job,
* adding a new one will stop running job and when stopped it starts the new one.
*/
-wmJob *WM_jobs_get(
- wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type)
+wmJob *WM_jobs_get(wmWindowManager *wm,
+ wmWindow *win,
+ const void *owner,
+ const char *name,
+ int flag,
+ int job_type)
{
wmJob *wm_job = wm_job_find(wm, owner, job_type);
@@ -220,7 +224,7 @@ wmJob *WM_jobs_get(
}
/* returns true if job runs, for UI (progress) indicators */
-bool WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
+bool WM_jobs_test(const wmWindowManager *wm, const void *owner, int job_type)
{
/* job can be running or about to run (suspended) */
LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
@@ -236,9 +240,9 @@ bool WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
return false;
}
-float WM_jobs_progress(wmWindowManager *wm, void *owner)
+float WM_jobs_progress(const wmWindowManager *wm, const void *owner)
{
- wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
+ const wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
if (wm_job && wm_job->flag & WM_JOB_PROGRESS) {
return wm_job->progress;
@@ -278,9 +282,9 @@ static void wm_jobs_update_progress_bars(wmWindowManager *wm)
}
/* time that job started */
-double WM_jobs_starttime(wmWindowManager *wm, void *owner)
+double WM_jobs_starttime(const wmWindowManager *wm, const void *owner)
{
- wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
+ const wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
if (wm_job && wm_job->flag & WM_JOB_PROGRESS) {
return wm_job->start_time;
@@ -289,7 +293,7 @@ double WM_jobs_starttime(wmWindowManager *wm, void *owner)
return 0;
}
-char *WM_jobs_name(wmWindowManager *wm, void *owner)
+const char *WM_jobs_name(const wmWindowManager *wm, const void *owner)
{
wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
@@ -300,7 +304,7 @@ char *WM_jobs_name(wmWindowManager *wm, void *owner)
return NULL;
}
-void *WM_jobs_customdata(wmWindowManager *wm, void *owner)
+void *WM_jobs_customdata(wmWindowManager *wm, const void *owner)
{
wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
@@ -322,12 +326,12 @@ void *WM_jobs_customdata_from_type(wmWindowManager *wm, int job_type)
return NULL;
}
-bool WM_jobs_is_running(wmJob *wm_job)
+bool WM_jobs_is_running(const wmJob *wm_job)
{
return wm_job->running;
}
-bool WM_jobs_is_stopped(wmWindowManager *wm, void *owner)
+bool WM_jobs_is_stopped(const wmWindowManager *wm, const void *owner)
{
wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
return wm_job ? wm_job->stop : true; /* XXX to be redesigned properly. */
@@ -560,7 +564,7 @@ void WM_jobs_kill_all(wmWindowManager *wm)
}
/* wait until every job ended, except for one owner (used in undo to keep screen job alive) */
-void WM_jobs_kill_all_except(wmWindowManager *wm, void *owner)
+void WM_jobs_kill_all_except(wmWindowManager *wm, const void *owner)
{
LISTBASE_FOREACH_MUTABLE (wmJob *, wm_job, &wm->jobs) {
if (wm_job->owner != owner) {
@@ -569,7 +573,7 @@ void WM_jobs_kill_all_except(wmWindowManager *wm, void *owner)
}
}
-void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type)
+void WM_jobs_kill_type(struct wmWindowManager *wm, const void *owner, int job_type)
{
LISTBASE_FOREACH_MUTABLE (wmJob *, wm_job, &wm->jobs) {
if (!owner || wm_job->owner == owner) {
@@ -581,7 +585,7 @@ void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type)
}
/* signal job(s) from this owner or callback to stop, timer is required to get handled */
-void WM_jobs_stop(wmWindowManager *wm, void *owner, void *startjob)
+void WM_jobs_stop(wmWindowManager *wm, const void *owner, void *startjob)
{
LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
if (wm_job->owner == owner || wm_job->startjob == startjob) {
@@ -702,9 +706,9 @@ void wm_jobs_timer(wmWindowManager *wm, wmTimer *wt)
wm_jobs_update_progress_bars(wm);
}
-bool WM_jobs_has_running(wmWindowManager *wm)
+bool WM_jobs_has_running(const wmWindowManager *wm)
{
- LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
+ LISTBASE_FOREACH (const wmJob *, wm_job, &wm->jobs) {
if (wm_job->running) {
return true;
}
diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c
index 865889e7e64..b0b4f0f5904 100644
--- a/source/blender/windowmanager/intern/wm_keymap_utils.c
+++ b/source/blender/windowmanager/intern/wm_keymap_utils.c
@@ -247,7 +247,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
else if (STRPREFIX(opname, "MARKER_OT")) {
km = WM_keymap_find_all(wm, "Markers", 0, 0);
}
- /* Import/Export*/
+ /* Import/Export */
else if (STRPREFIX(opname, "IMPORT_") || STRPREFIX(opname, "EXPORT_")) {
km = WM_keymap_find_all(wm, "Window", 0, 0);
}
diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c
index 1f3574f9032..e17d5a9ae70 100644
--- a/source/blender/windowmanager/intern/wm_operator_type.c
+++ b/source/blender/windowmanager/intern/wm_operator_type.c
@@ -229,7 +229,7 @@ void wm_operatortype_free(void)
void WM_operatortype_props_advanced_begin(wmOperatorType *ot)
{
if (ot_prop_basic_count == -1) {
- /* Don't do anything if _begin was called before, but not _end */
+ /* Don't do anything if _begin was called before, but not _end. */
ot_prop_basic_count = RNA_struct_count_properties(ot->srna);
}
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 32b0ca66a33..a2d783afc32 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -53,7 +53,7 @@
#include "BLI_blenlib.h"
#include "BLI_dial_2d.h"
-#include "BLI_dynstr.h" /*for WM_operator_pystring */
+#include "BLI_dynstr.h" /* For #WM_operator_pystring. */
#include "BLI_math.h"
#include "BLI_utildefines.h"
@@ -323,16 +323,16 @@ bool WM_operator_pystring_abbreviate(char *str, int str_len_max)
if (parens_len > str_len_max) {
const char *comma_first = strchr(parens_start, ',');
- /* truncate after the first comma */
+ /* Truncate after the first comma. */
if (comma_first) {
const char end_str[] = " ... )";
const int end_str_len = sizeof(end_str) - 1;
- /* leave a place for the first argument*/
+ /* Leave a place for the first argument. */
const int new_str_len = (comma_first - parens_start) + 1;
if (str_len >= new_str_len + parens_start_pos + end_str_len + 1) {
- /* append " ... )" to the string after the comma */
+ /* Append " ... )" to the string after the comma. */
memcpy(str + new_str_len + parens_start_pos, end_str, end_str_len + 1);
return true;
@@ -2885,7 +2885,7 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even
}
}
- /* calculate new value and apply snapping */
+ /* Calculate new value and apply snapping. */
switch (rc->subtype) {
case PROP_NONE:
case PROP_DISTANCE:
diff --git a/source/blender/windowmanager/intern/wm_platform_support.c b/source/blender/windowmanager/intern/wm_platform_support.c
index 45618e9d6d3..54fc454ee65 100644
--- a/source/blender/windowmanager/intern/wm_platform_support.c
+++ b/source/blender/windowmanager/intern/wm_platform_support.c
@@ -123,7 +123,7 @@ bool WM_platform_support_perform_checks()
const char *platform_key = GPU_platform_support_level_key();
/* Check if previous check matches the current check. Don't update the approval when running in
- * `background`. this could have been triggered by installing add-ons via installers. */
+ * `background`. this could have been triggered by installing add-ons via installers. */
if (support_level != GPU_SUPPORT_LEVEL_UNSUPPORTED && !G.factory_startup &&
wm_platform_support_check_approval(platform_key, !G.background)) {
/* If it matches the user has confirmed and wishes to use it. */
diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c
index a620accab72..a7cdc0602bc 100644
--- a/source/blender/windowmanager/intern/wm_stereo.c
+++ b/source/blender/windowmanager/intern/wm_stereo.c
@@ -353,7 +353,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- /* without this, the popup won't be freed freed properly T44688 */
+ /* Without this, the popup won't be freed properly, see T44688. */
CTX_wm_window_set(C, win_src);
win_src->stereo3d_format->display_mode = prev_display_mode;
return OPERATOR_CANCELLED;
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index ae5a2c81582..8f8577e2616 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -136,7 +136,7 @@ static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool acti
static bool wm_window_timer(const bContext *C);
/* XXX this one should correctly check for apple top header...
- * done for Cocoa : returns window contents (and not frame) max size*/
+ * done for Cocoa : returns window contents (and not frame) max size. */
void wm_get_screensize(int *r_width, int *r_height)
{
unsigned int uiwidth;
@@ -188,7 +188,7 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
GHOST_ActivateWindowDrawingContext(win->ghostwin);
GPU_context_active_set(win->gpuctx);
- /* Delete local gpu context. */
+ /* Delete local GPU context. */
GPU_context_discard(win->gpuctx);
GHOST_DisposeWindow(g_system, win->ghostwin);
@@ -440,8 +440,8 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
void wm_window_title(wmWindowManager *wm, wmWindow *win)
{
if (WM_window_is_temp_screen(win)) {
- /* nothing to do for 'temp' windows,
- * because WM_window_open always sets window title */
+ /* Nothing to do for 'temp' windows,
+ * because #WM_window_open always sets window title. */
}
else if (win->ghostwin) {
/* this is set to 1 if you don't have startup.blend open */
@@ -827,14 +827,13 @@ wmWindow *WM_window_open(bContext *C,
win = wm_window_new(bmain, wm, toplevel ? NULL : win_prev, dialog);
win->posx = rect.xmin;
win->posy = rect.ymin;
+ win->sizex = BLI_rcti_size_x(&rect);
+ win->sizey = BLI_rcti_size_y(&rect);
*win->stereo3d_format = *win_prev->stereo3d_format;
}
bScreen *screen = WM_window_get_active_screen(win);
- win->sizex = BLI_rcti_size_x(&rect);
- win->sizey = BLI_rcti_size_y(&rect);
-
if (WM_window_get_active_workspace(win) == NULL) {
WorkSpace *workspace = WM_window_get_active_workspace(win_prev);
BKE_workspace_active_set(win->workspace_hook, workspace);
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index 223f6cf543d..ccb6e47e7e3 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -395,7 +395,7 @@ enum {
((ISKEYBOARD(event_type) || ISMOUSE(event_type) || ISNDOF(event_type)) && \
(ISKEYMODIFIER(event_type) == false))
-/* internal helpers*/
+/* Internal helpers. */
#define _VA_IS_EVENT_MOD2(v, a) (CHECK_TYPE_INLINE(v, wmEvent *), ((v)->a))
#define _VA_IS_EVENT_MOD3(v, a, b) (_VA_IS_EVENT_MOD2(v, a) || ((v)->b))
#define _VA_IS_EVENT_MOD4(v, a, b, c) (_VA_IS_EVENT_MOD3(v, a, b) || ((v)->c))
diff --git a/tests/python/bl_constraints.py b/tests/python/bl_constraints.py
index 279c896c6af..a2690fa4e11 100644
--- a/tests/python/bl_constraints.py
+++ b/tests/python/bl_constraints.py
@@ -375,6 +375,70 @@ class CustomSpaceTest(AbstractConstraintTests):
)))
+class CopyTransformsTest(AbstractConstraintTests):
+ layer_collection = 'Copy Transforms'
+
+ def test_mix_mode_object(self):
+ """Copy Transforms: all mix modes for objects"""
+ constraint = bpy.data.objects["Copy Transforms.object.owner"].constraints["Copy Transforms"]
+
+ constraint.mix_mode = 'REPLACE'
+ self.matrix_test('Copy Transforms.object.owner', Matrix((
+ (-0.7818737626075745, 0.14389121532440186, 0.4845699667930603, -0.017531070858240128),
+ (-0.2741589844226837, -0.591389000415802, -1.2397242784500122, -0.08039521425962448),
+ (0.04909384995698929, -1.0109175443649292, 0.7942137122154236, 0.1584688276052475),
+ (0.0, 0.0, 0.0, 1.0)
+ )))
+
+ constraint.mix_mode = 'BEFORE_FULL'
+ self.matrix_test('Copy Transforms.object.owner', Matrix((
+ (-1.0791258811950684, -0.021011866629123688, 0.3120136260986328, 0.9082338809967041),
+ (0.2128538191318512, -0.3411901891231537, -1.7376484870910645, -0.39762523770332336),
+ (-0.03584420680999756, -1.0162957906723022, 0.8004404306411743, -0.9015425443649292),
+ (0.0, 0.0, 0.0, 1.0)
+ )))
+
+ constraint.mix_mode = 'BEFORE'
+ self.matrix_test('Copy Transforms.object.owner', Matrix((
+ (-0.9952367544174194, -0.03077685832977295, 0.05301344022154808, 0.9082338809967041),
+ (-0.013416174799203873, -0.39984768629074097, -1.8665285110473633, -0.39762523770332336),
+ (0.03660336509346962, -0.9833710193634033, 0.75728839635849, -0.9015425443649292),
+ (0.0, 0.0, 0.0, 1.0)
+ )))
+
+ constraint.mix_mode = 'BEFORE_SPLIT'
+ self.matrix_test('Copy Transforms.object.owner', Matrix((
+ (-0.9952367544174194, -0.03077685832977295, 0.05301344022154808, -1.0175310373306274),
+ (-0.013416174799203873, -0.39984768629074097, -1.8665285110473633, 0.9196047782897949),
+ (0.03660336509346962, -0.9833710193634033, 0.75728839635849, 0.1584688276052475),
+ (0.0, 0.0, 0.0, 1.0)
+ )))
+
+ constraint.mix_mode = 'AFTER_FULL'
+ self.matrix_test('Copy Transforms.object.owner', Matrix((
+ (-0.8939255475997925, -0.2866469621658325, 0.7563635110855103, -0.964445173740387),
+ (-0.09460853785276413, -0.73727947473526, -1.0267245769500732, 0.9622588753700256),
+ (0.37042146921157837, -1.1893107891082764, 1.0113294124603271, 0.21314144134521484),
+ (0.0, 0.0, 0.0, 1.0)
+ )))
+
+ constraint.mix_mode = 'AFTER'
+ self.matrix_test('Copy Transforms.object.owner', Matrix((
+ (-0.9033845067024231, -0.2048732340335846, 0.7542480826377869, -0.964445173740387),
+ (-0.1757974475622177, -0.6721230745315552, -1.5190268754959106, 0.9622588753700256),
+ (0.38079890608787537, -0.7963172793388367, 1.0880682468414307, 0.21314144134521484),
+ (0.0, 0.0, 0.0, 1.0)
+ )))
+
+ constraint.mix_mode = 'AFTER_SPLIT'
+ self.matrix_test('Copy Transforms.object.owner', Matrix((
+ (-0.9033845067024231, -0.2048732340335846, 0.7542480826377869, -1.0175310373306274),
+ (-0.1757974475622177, -0.6721230745315552, -1.5190268754959106, 0.9196047782897949),
+ (0.38079890608787537, -0.7963172793388367, 1.0880682468414307, 0.1584688276052475),
+ (0.0, 0.0, 0.0, 1.0)
+ )))
+
+
def main():
global args
import argparse