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:
authorJacques Lucke <jacques@blender.org>2020-04-06 12:10:19 +0300
committerJacques Lucke <jacques@blender.org>2020-04-06 12:10:19 +0300
commit43f895a59247ea4058cb3f019cd4dabd9ad9b0e4 (patch)
tree51469fde8affa6b20f67d12a4602c5f109c1a204 /source/blender/editors
parent52606afaa60462db45e783607255f56c06fd8d73 (diff)
parent480ff89bf7cfb1f9ffd5ce66fbd5c65288ef04c0 (diff)
Merge branch 'master' into functions
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c5
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c34
-rw-r--r--source/blender/editors/animation/anim_deps.c2
-rw-r--r--source/blender/editors/animation/anim_draw.c2
-rw-r--r--source/blender/editors/animation/anim_filter.c12
-rw-r--r--source/blender/editors/animation/anim_ipo_utils.c2
-rw-r--r--source/blender/editors/animation/anim_markers.c46
-rw-r--r--source/blender/editors/animation/anim_motion_paths.c10
-rw-r--r--source/blender/editors/animation/anim_ops.c25
-rw-r--r--source/blender/editors/animation/drivers.c1
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c5
-rw-r--r--source/blender/editors/animation/keyframes_draw.c31
-rw-r--r--source/blender/editors/animation/keyframes_edit.c2
-rw-r--r--source/blender/editors/animation/keyframes_general.c2
-rw-r--r--source/blender/editors/animation/keyframing.c7
-rw-r--r--source/blender/editors/animation/keyingsets.c4
-rw-r--r--source/blender/editors/animation/time_scrub_ui.c2
-rw-r--r--source/blender/editors/armature/armature_add.c4
-rw-r--r--source/blender/editors/armature/armature_edit.c12
-rw-r--r--source/blender/editors/armature/armature_intern.h40
-rw-r--r--source/blender/editors/armature/armature_naming.c64
-rw-r--r--source/blender/editors/armature/armature_relations.c15
-rw-r--r--source/blender/editors/armature/armature_select.c238
-rw-r--r--source/blender/editors/armature/armature_skinning.c2
-rw-r--r--source/blender/editors/armature/armature_utils.c29
-rw-r--r--source/blender/editors/armature/editarmature_undo.c3
-rw-r--r--source/blender/editors/armature/pose_edit.c6
-rw-r--r--source/blender/editors/armature/pose_lib.c24
-rw-r--r--source/blender/editors/armature/pose_select.c12
-rw-r--r--source/blender/editors/armature/pose_slide.c10
-rw-r--r--source/blender/editors/armature/pose_transform.c21
-rw-r--r--source/blender/editors/armature/pose_utils.c2
-rw-r--r--source/blender/editors/curve/CMakeLists.txt1
-rw-r--r--source/blender/editors/curve/curve_intern.h19
-rw-r--r--source/blender/editors/curve/editcurve.c786
-rw-r--r--source/blender/editors/curve/editcurve_paint.c20
-rw-r--r--source/blender/editors/curve/editcurve_query.c244
-rw-r--r--source/blender/editors/curve/editcurve_select.c7
-rw-r--r--source/blender/editors/curve/editcurve_undo.c2
-rw-r--r--source/blender/editors/curve/editfont.c2
-rw-r--r--source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c2
-rw-r--r--source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c2
-rw-r--r--source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c2
-rw-r--r--source/blender/editors/gizmo_library/gizmo_draw_utils.c2
-rw-r--r--source/blender/editors/gizmo_library/gizmo_geometry.h4
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c6
-rw-r--r--source/blender/editors/gpencil/annotate_draw.c16
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c59
-rw-r--r--source/blender/editors/gpencil/gpencil_armature.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c34
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c34
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h6
-rw-r--r--source/blender/editors/gpencil/gpencil_interpolate.c14
-rw-r--r--source/blender/editors/gpencil/gpencil_merge.c14
-rw-r--r--source/blender/editors/gpencil/gpencil_ops.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_ops_versioning.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c55
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_sculpt_paint.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c12
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c73
-rw-r--r--source/blender/editors/gpencil/gpencil_uv.c12
-rw-r--r--source/blender/editors/include/ED_anim_api.h25
-rw-r--r--source/blender/editors/include/ED_armature.h6
-rw-r--r--source/blender/editors/include/ED_gpencil.h10
-rw-r--r--source/blender/editors/include/ED_keyframing.h8
-rw-r--r--source/blender/editors/include/ED_mask.h19
-rw-r--r--source/blender/editors/include/ED_mesh.h16
-rw-r--r--source/blender/editors/include/ED_node.h4
-rw-r--r--source/blender/editors/include/ED_render.h4
-rw-r--r--source/blender/editors/include/ED_screen.h64
-rw-r--r--source/blender/editors/include/ED_util.h2
-rw-r--r--source/blender/editors/include/ED_view3d.h10
-rw-r--r--source/blender/editors/include/UI_interface.h10
-rw-r--r--source/blender/editors/include/UI_view2d.h2
-rw-r--r--source/blender/editors/interface/interface.c31
-rw-r--r--source/blender/editors/interface/interface_context_menu.c8
-rw-r--r--source/blender/editors/interface/interface_eyedropper.c4
-rw-r--r--source/blender/editors/interface/interface_eyedropper_color.c22
-rw-r--r--source/blender/editors/interface/interface_eyedropper_datablock.c26
-rw-r--r--source/blender/editors/interface/interface_eyedropper_depth.c16
-rw-r--r--source/blender/editors/interface/interface_eyedropper_gpencil_color.c3
-rw-r--r--source/blender/editors/interface/interface_handlers.c64
-rw-r--r--source/blender/editors/interface/interface_icons.c22
-rw-r--r--source/blender/editors/interface/interface_intern.h4
-rw-r--r--source/blender/editors/interface/interface_layout.c64
-rw-r--r--source/blender/editors/interface/interface_ops.c20
-rw-r--r--source/blender/editors/interface/interface_panel.c526
-rw-r--r--source/blender/editors/interface/interface_query.c19
-rw-r--r--source/blender/editors/interface/interface_region_color_picker.c2
-rw-r--r--source/blender/editors/interface/interface_region_hud.c80
-rw-r--r--source/blender/editors/interface/interface_region_menu_popup.c14
-rw-r--r--source/blender/editors/interface/interface_region_popover.c8
-rw-r--r--source/blender/editors/interface/interface_region_popup.c34
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c15
-rw-r--r--source/blender/editors/interface/interface_regions.c10
-rw-r--r--source/blender/editors/interface/interface_regions_intern.h4
-rw-r--r--source/blender/editors/interface/interface_templates.c44
-rw-r--r--source/blender/editors/interface/resources.c2
-rw-r--r--source/blender/editors/interface/view2d.c13
-rw-r--r--source/blender/editors/interface/view2d_ops.c26
-rw-r--r--source/blender/editors/mask/mask_add.c22
-rw-r--r--source/blender/editors/mask/mask_draw.c56
-rw-r--r--source/blender/editors/mask/mask_edit.c12
-rw-r--r--source/blender/editors/mask/mask_ops.c54
-rw-r--r--source/blender/editors/mask/mask_query.c102
-rw-r--r--source/blender/editors/mask/mask_relationships.c9
-rw-r--r--source/blender/editors/mask/mask_select.c62
-rw-r--r--source/blender/editors/mask/mask_shapekey.c16
-rw-r--r--source/blender/editors/mesh/editface.c6
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c6
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c3
-rw-r--r--source/blender/editors/mesh/editmesh_inset.c12
-rw-r--r--source/blender/editors/mesh/editmesh_intersect.c6
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c4
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c6
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c16
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c19
-rw-r--r--source/blender/editors/mesh/mesh_mirror.c108
-rw-r--r--source/blender/editors/mesh/meshtools.c111
-rw-r--r--source/blender/editors/metaball/mball_edit.c6
-rw-r--r--source/blender/editors/object/CMakeLists.txt1
-rw-r--r--source/blender/editors/object/object_add.c16
-rw-r--r--source/blender/editors/object/object_bake_api.c30
-rw-r--r--source/blender/editors/object/object_data_transform.c4
-rw-r--r--source/blender/editors/object/object_edit.c16
-rw-r--r--source/blender/editors/object/object_intern.h1
-rw-r--r--source/blender/editors/object/object_modifier.c2
-rw-r--r--source/blender/editors/object/object_ops.c2
-rw-r--r--source/blender/editors/object/object_random.c4
-rw-r--r--source/blender/editors/object/object_relations.c12
-rw-r--r--source/blender/editors/object/object_remesh.c434
-rw-r--r--source/blender/editors/object/object_select.c4
-rw-r--r--source/blender/editors/object/object_shapekey.c4
-rw-r--r--source/blender/editors/object/object_transform.c3
-rw-r--r--source/blender/editors/object/object_utils.c5
-rw-r--r--source/blender/editors/object/object_volume.c2
-rw-r--r--source/blender/editors/physics/particle_edit.c4
-rw-r--r--source/blender/editors/render/render_internal.c54
-rw-r--r--source/blender/editors/render/render_opengl.c15
-rw-r--r--source/blender/editors/render/render_preview.c56
-rw-r--r--source/blender/editors/render/render_shading.c17
-rw-r--r--source/blender/editors/render/render_update.c36
-rw-r--r--source/blender/editors/render/render_view.c122
-rw-r--r--source/blender/editors/scene/scene_edit.c4
-rw-r--r--source/blender/editors/screen/area.c474
-rw-r--r--source/blender/editors/screen/area_query.c14
-rw-r--r--source/blender/editors/screen/area_utils.c2
-rw-r--r--source/blender/editors/screen/glutil.c8
-rw-r--r--source/blender/editors/screen/screen_context.c65
-rw-r--r--source/blender/editors/screen/screen_draw.c178
-rw-r--r--source/blender/editors/screen/screen_edit.c547
-rw-r--r--source/blender/editors/screen/screen_geometry.c87
-rw-r--r--source/blender/editors/screen/screen_intern.h21
-rw-r--r--source/blender/editors/screen/screen_ops.c508
-rw-r--r--source/blender/editors/screen/screen_user_menu.c8
-rw-r--r--source/blender/editors/screen/screendump.c8
-rw-r--r--source/blender/editors/screen/workspace_edit.c9
-rw-r--r--source/blender/editors/screen/workspace_layout_edit.c10
-rw-r--r--source/blender/editors/sculpt_paint/CMakeLists.txt9
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c18
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c28
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c107
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c80
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c7
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c27
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c14
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_ops.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c4431
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_automasking.c304
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_detail.c428
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_dyntopo.c443
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_face_set.c974
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_filter_mask.c502
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_filter_mesh.c571
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h220
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_mask_expand.c526
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_smooth.c598
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_transform.c381
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c323
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c10
-rw-r--r--source/blender/editors/sound/sound_ops.c4
-rw-r--r--source/blender/editors/space_action/action_data.c13
-rw-r--r--source/blender/editors/space_action/action_draw.c23
-rw-r--r--source/blender/editors/space_action/action_select.c4
-rw-r--r--source/blender/editors/space_action/space_action.c96
-rw-r--r--source/blender/editors/space_api/spacetypes.c4
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c104
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c8
-rw-r--r--source/blender/editors/space_clip/clip_draw.c15
-rw-r--r--source/blender/editors/space_clip/clip_editor.c29
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c6
-rw-r--r--source/blender/editors/space_clip/clip_intern.h2
-rw-r--r--source/blender/editors/space_clip/clip_ops.c16
-rw-r--r--source/blender/editors/space_clip/clip_toolbar.c8
-rw-r--r--source/blender/editors/space_clip/space_clip.c246
-rw-r--r--source/blender/editors/space_console/console_ops.c8
-rw-r--r--source/blender/editors/space_console/space_console.c10
-rw-r--r--source/blender/editors/space_file/file_draw.c8
-rw-r--r--source/blender/editors/space_file/file_ops.c58
-rw-r--r--source/blender/editors/space_file/file_panels.c18
-rw-r--r--source/blender/editors/space_file/filelist.c42
-rw-r--r--source/blender/editors/space_file/space_file.c80
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c50
-rw-r--r--source/blender/editors/space_graph/graph_edit.c18
-rw-r--r--source/blender/editors/space_graph/graph_utils.c46
-rw-r--r--source/blender/editors/space_graph/space_graph.c56
-rw-r--r--source/blender/editors/space_image/image_ops.c32
-rw-r--r--source/blender/editors/space_image/image_sequence.c6
-rw-r--r--source/blender/editors/space_image/image_undo.c28
-rw-r--r--source/blender/editors/space_image/space_image.c98
-rw-r--r--source/blender/editors/space_info/info_report.c4
-rw-r--r--source/blender/editors/space_info/info_stats.c5
-rw-r--r--source/blender/editors/space_info/space_info.c10
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c40
-rw-r--r--source/blender/editors/space_nla/nla_channels.c4
-rw-r--r--source/blender/editors/space_nla/nla_draw.c12
-rw-r--r--source/blender/editors/space_nla/nla_edit.c28
-rw-r--r--source/blender/editors/space_nla/nla_select.c2
-rw-r--r--source/blender/editors/space_nla/space_nla.c41
-rw-r--r--source/blender/editors/space_node/drawnode.c2
-rw-r--r--source/blender/editors/space_node/node_buttons.c8
-rw-r--r--source/blender/editors/space_node/node_edit.c18
-rw-r--r--source/blender/editors/space_node/node_relationships.c21
-rw-r--r--source/blender/editors/space_node/node_select.c5
-rw-r--r--source/blender/editors/space_node/node_view.c10
-rw-r--r--source/blender/editors/space_node/space_node.c80
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_dragdrop.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c33
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c16
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h3
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_sync.c9
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c3
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c19
-rw-r--r--source/blender/editors/space_outliner/outliner_utils.c11
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c18
-rw-r--r--source/blender/editors/space_script/script_edit.c2
-rw-r--r--source/blender/editors/space_script/space_script.c4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c246
-rw-r--r--source/blender/editors/space_sequencer/sequencer_buttons.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c369
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c709
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h20
-rw-r--r--source/blender/editors/space_sequencer/sequencer_modifier.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_ops.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_preview.c16
-rw-r--r--source/blender/editors/space_sequencer/sequencer_scopes.c131
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c142
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c18
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c233
-rw-r--r--source/blender/editors/space_statusbar/space_statusbar.c6
-rw-r--r--source/blender/editors/space_text/space_text.c30
-rw-r--r--source/blender/editors/space_text/text_autocomplete.c6
-rw-r--r--source/blender/editors/space_text/text_draw.c8
-rw-r--r--source/blender/editors/space_text/text_format.c2
-rw-r--r--source/blender/editors/space_text/text_header.c12
-rw-r--r--source/blender/editors/space_text/text_intern.h6
-rw-r--r--source/blender/editors/space_text/text_ops.c2
-rw-r--r--source/blender/editors/space_topbar/space_topbar.c8
-rw-r--r--source/blender/editors/space_userpref/space_userpref.c10
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c89
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c14
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c76
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_navigate.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_ruler.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h6
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c20
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c48
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c73
-rw-r--r--source/blender/editors/transform/transform.c46
-rw-r--r--source/blender/editors/transform/transform.h10
-rw-r--r--source/blender/editors/transform/transform_constraints.c2
-rw-r--r--source/blender/editors/transform/transform_convert.c46
-rw-r--r--source/blender/editors/transform/transform_convert_armature.c10
-rw-r--r--source/blender/editors/transform/transform_convert_cursor.c2
-rw-r--r--source/blender/editors/transform/transform_convert_curve.c5
-rw-r--r--source/blender/editors/transform/transform_convert_graph.c6
-rw-r--r--source/blender/editors/transform/transform_convert_mask.c6
-rw-r--r--source/blender/editors/transform/transform_convert_mesh.c137
-rw-r--r--source/blender/editors/transform/transform_convert_node.c4
-rw-r--r--source/blender/editors/transform/transform_convert_object.c18
-rw-r--r--source/blender/editors/transform/transform_convert_sequencer.c2
-rw-r--r--source/blender/editors/transform/transform_convert_tracking.c2
-rw-r--r--source/blender/editors/transform/transform_draw_cursors.c2
-rw-r--r--source/blender/editors/transform/transform_generics.c60
-rw-r--r--source/blender/editors/transform/transform_gizmo_2d.c36
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c50
-rw-r--r--source/blender/editors/transform/transform_mode.c6
-rw-r--r--source/blender/editors/transform/transform_mode_align.c2
-rw-r--r--source/blender/editors/transform/transform_mode_baketime.c2
-rw-r--r--source/blender/editors/transform/transform_mode_bbone_resize.c2
-rw-r--r--source/blender/editors/transform/transform_mode_bend.c5
-rw-r--r--source/blender/editors/transform/transform_mode_boneenvelope.c2
-rw-r--r--source/blender/editors/transform/transform_mode_boneroll.c2
-rw-r--r--source/blender/editors/transform/transform_mode_curveshrinkfatten.c2
-rw-r--r--source/blender/editors/transform/transform_mode_edge_bevelweight.c2
-rw-r--r--source/blender/editors/transform/transform_mode_edge_crease.c2
-rw-r--r--source/blender/editors/transform/transform_mode_edge_rotate_normal.c2
-rw-r--r--source/blender/editors/transform/transform_mode_edge_seq_slide.c2
-rw-r--r--source/blender/editors/transform/transform_mode_edge_slide.c10
-rw-r--r--source/blender/editors/transform/transform_mode_gpopacity.c2
-rw-r--r--source/blender/editors/transform/transform_mode_gpshrinkfatten.c2
-rw-r--r--source/blender/editors/transform/transform_mode_maskshrinkfatten.c2
-rw-r--r--source/blender/editors/transform/transform_mode_mirror.c6
-rw-r--r--source/blender/editors/transform/transform_mode_push_pull.c2
-rw-r--r--source/blender/editors/transform/transform_mode_resize.c2
-rw-r--r--source/blender/editors/transform/transform_mode_rotate.c2
-rw-r--r--source/blender/editors/transform/transform_mode_shear.c2
-rw-r--r--source/blender/editors/transform/transform_mode_shrink_fatten.c2
-rw-r--r--source/blender/editors/transform/transform_mode_skin_resize.c2
-rw-r--r--source/blender/editors/transform/transform_mode_tilt.c2
-rw-r--r--source/blender/editors/transform/transform_mode_timescale.c2
-rw-r--r--source/blender/editors/transform/transform_mode_timeslide.c6
-rw-r--r--source/blender/editors/transform/transform_mode_timetranslate.c2
-rw-r--r--source/blender/editors/transform/transform_mode_tosphere.c2
-rw-r--r--source/blender/editors/transform/transform_mode_trackball.c2
-rw-r--r--source/blender/editors/transform/transform_mode_translate.c4
-rw-r--r--source/blender/editors/transform/transform_mode_vert_slide.c2
-rw-r--r--source/blender/editors/transform/transform_ops.c4
-rw-r--r--source/blender/editors/transform/transform_orientations.c12
-rw-r--r--source/blender/editors/transform/transform_snap.c10
-rw-r--r--source/blender/editors/transform/transform_snap_object.c26
-rw-r--r--source/blender/editors/undo/ed_undo.c30
-rw-r--r--source/blender/editors/util/ed_util.c11
-rw-r--r--source/blender/editors/util/gizmo_utils.c4
-rw-r--r--source/blender/editors/uvedit/uvedit_buttons.c4
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c10
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c26
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c42
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c10
337 files changed, 11588 insertions, 9873 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 67e899382bb..b569f909d7a 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -58,6 +58,7 @@
#include "RNA_access.h"
+#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_curve.h"
@@ -856,7 +857,7 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[
bool showGroupColors = acf_show_channel_colors(ac);
if (showGroupColors && agrp->customCol) {
- unsigned char cp[3];
+ uchar cp[3];
/* highlight only for active */
if (ale->flag & AGRP_ACTIVE) {
@@ -4395,7 +4396,7 @@ void ANIM_channel_draw(
if (acf->name && !achannel_is_being_renamed(ac, acf, channel_index)) {
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */
- unsigned char col[4];
+ uchar col[4];
/* set text color */
/* XXX: if active, highlight differently? */
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index f47ed85f5bf..a1b1c7815d8 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -42,7 +42,7 @@
#include "RNA_define.h"
#include "BKE_action.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_context.h"
#include "BKE_fcurve.h"
#include "BKE_global.h"
@@ -695,15 +695,15 @@ bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt)
/* poll callback for being in an Animation Editor channels list region */
static bool animedit_poll_channels_active(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C))) {
+ if (ELEM(NULL, area, CTX_wm_region(C))) {
return 0;
}
/* animation editor test */
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) {
+ if (ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) {
return 0;
}
@@ -713,21 +713,21 @@ static bool animedit_poll_channels_active(bContext *C)
/* poll callback for Animation Editor channels list region + not in NLA-tweakmode for NLA */
static bool animedit_poll_channels_nla_tweakmode_off(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Scene *scene = CTX_data_scene(C);
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C))) {
+ if (ELEM(NULL, area, CTX_wm_region(C))) {
return 0;
}
/* animation editor test */
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) {
+ if (ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) {
return 0;
}
/* NLA TweakMode test */
- if (sa->spacetype == SPACE_NLA) {
+ if (area->spacetype == SPACE_NLA) {
if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) {
return 0;
}
@@ -1518,19 +1518,19 @@ static void ANIM_OT_channels_move(wmOperatorType *ot)
static bool animchannels_grouping_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceLink *sl;
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C))) {
+ if (ELEM(NULL, area, CTX_wm_region(C))) {
return 0;
}
/* animation editor test - must be suitable modes only */
sl = CTX_wm_space_data(C);
- switch (sa->spacetype) {
+ switch (area->spacetype) {
/* supported... */
case SPACE_ACTION: {
SpaceAction *saction = (SpaceAction *)sl;
@@ -2353,16 +2353,16 @@ static void ANIM_OT_channels_clean_empty(wmOperatorType *ot)
static bool animchannels_enable_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C))) {
+ if (ELEM(NULL, area, CTX_wm_region(C))) {
return 0;
}
/* animation editor test - Action/Dopesheet/etc. and Graph only */
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH) == 0) {
+ if (ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH) == 0) {
return 0;
}
@@ -2431,14 +2431,14 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot)
/* XXX: make this generic? */
static bool animchannels_find_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
- if (sa == NULL) {
+ if (area == NULL) {
return 0;
}
/* animation editor with dopesheet */
- return ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA);
+ return ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA);
}
/* find_invoke() - Get initial channels */
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 6f7770d97f1..4fb68b614ff 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -38,7 +38,7 @@
#include "BLI_utildefines.h"
#include "BKE_action.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_context.h"
#include "BKE_fcurve.h"
#include "BKE_gpencil.h"
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 96fd2e94a5e..4203c2677b7 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -71,7 +71,7 @@ void ANIM_draw_cfra_number(const bContext *C, View2D *v2d, short flag)
const bool show_time = (flag & DRAWCFRA_UNIT_SECONDS) != 0;
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
- unsigned char col[4];
+ uchar col[4];
float color[4];
float xscale, x, y;
char numstr[32] = " t "; /* t is the character to start replacing from */
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index a09db0380e6..38a19e85661 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -82,7 +82,7 @@
#include "BLI_utildefines.h"
#include "BKE_action.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_collection.h"
#include "BKE_context.h"
#include "BKE_fcurve.h"
@@ -399,7 +399,7 @@ bool ANIM_animdata_context_getdata(bAnimContext *ac)
bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
{
Main *bmain = CTX_data_main(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
SpaceLink *sl = CTX_wm_space_data(C);
Scene *scene = CTX_data_scene(C);
@@ -418,10 +418,10 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
}
ac->view_layer = CTX_data_view_layer(C);
ac->obact = (ac->view_layer->basact) ? ac->view_layer->basact->object : NULL;
- ac->sa = sa;
+ ac->area = area;
ac->region = region;
ac->sl = sl;
- ac->spacetype = (sa) ? sa->spacetype : 0;
+ ac->spacetype = (area) ? area->spacetype : 0;
ac->regiontype = (region) ? region->regiontype : 0;
/* initialise default y-scale factor */
@@ -3139,7 +3139,7 @@ static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads,
size_t num_bases = 0;
Base **sorted_bases = MEM_mallocN(sizeof(Base *) * tot_bases, "Dopesheet Usable Sorted Bases");
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (animdata_filter_base_is_ok(ads, base, filter_mode)) {
sorted_bases[num_bases++] = base;
}
@@ -3233,7 +3233,7 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac,
/* Filter and add contents of each base (i.e. object) without them sorting first
* NOTE: This saves performance in cases where order doesn't matter
*/
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (animdata_filter_base_is_ok(ads, base, filter_mode)) {
/* since we're still here, this object should be usable */
items += animdata_filter_dopesheet_ob(ac, anim_data, ads, base, filter_mode);
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c
index f631d08f3e4..3613ca9eeda 100644
--- a/source/blender/editors/animation/anim_ipo_utils.c
+++ b/source/blender/editors/animation/anim_ipo_utils.c
@@ -203,7 +203,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
#define HSV_BANDWIDTH 0.3f
/* used to determine the color of F-Curves with FCURVE_COLOR_AUTO_RAINBOW set */
-// void fcurve_rainbow(unsigned int cur, unsigned int tot, float *out)
+// void fcurve_rainbow(uint cur, uint tot, float *out)
void getcolor_fcurve_rainbow(int cur, int tot, float out[3])
{
float hsv[3], fac;
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 8b0e9b22ce8..46566feea91 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -74,12 +74,12 @@
/* ************* Marker API **************** */
/* helper function for getting the list of markers to work on */
-static ListBase *context_get_markers(Scene *scene, ScrArea *sa)
+static ListBase *context_get_markers(Scene *scene, ScrArea *area)
{
/* local marker sets... */
- if (sa) {
- if (sa->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
+ if (area) {
+ if (area->spacetype == SPACE_ACTION) {
+ SpaceAction *saction = (SpaceAction *)area->spacedata.first;
/* local markers can only be shown when there's only a single active action to grab them from
* - flag only takes effect when there's an action, otherwise it can get too confusing?
@@ -108,7 +108,7 @@ ListBase *ED_context_get_markers(const bContext *C)
ListBase *ED_animcontext_get_markers(const bAnimContext *ac)
{
if (ac) {
- return context_get_markers(ac->scene, ac->sa);
+ return context_get_markers(ac->scene, ac->area);
}
else {
return NULL;
@@ -234,35 +234,35 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *r_first, float *
*/
static bool ED_operator_markers_region_active(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- if (sa == NULL) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area == NULL) {
return false;
}
- switch (sa->spacetype) {
+ switch (area->spacetype) {
case SPACE_ACTION: {
- SpaceAction *saction = sa->spacedata.first;
+ SpaceAction *saction = area->spacedata.first;
if (saction->flag & SACTION_SHOW_MARKERS) {
return true;
}
break;
}
case SPACE_GRAPH: {
- SpaceGraph *sipo = sa->spacedata.first;
+ SpaceGraph *sipo = area->spacedata.first;
if (sipo->mode != SIPO_MODE_DRIVERS && sipo->flag & SIPO_SHOW_MARKERS) {
return true;
}
break;
}
case SPACE_NLA: {
- SpaceNla *snla = sa->spacedata.first;
+ SpaceNla *snla = area->spacedata.first;
if (snla->flag & SNLA_SHOW_MARKERS) {
return true;
}
break;
}
case SPACE_SEQ: {
- SpaceSeq *seq = sa->spacedata.first;
+ SpaceSeq *seq = area->spacedata.first;
if (seq->flag & SEQ_SHOW_MARKERS) {
return true;
}
@@ -358,7 +358,7 @@ void ED_markers_deselect_all(ListBase *markers, int action)
action = ED_markers_get_first_selected(markers) ? SEL_DESELECT : SEL_SELECT;
}
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (action == SEL_SELECT) {
marker->flag |= SELECT;
}
@@ -528,7 +528,7 @@ static void draw_markers_background(rctf *rect)
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- unsigned char shade[4];
+ uchar shade[4];
UI_GetThemeColor4ubv(TH_TIME_SCRUB_BACKGROUND, shade);
immUniformColor4ubv(shade);
@@ -599,14 +599,14 @@ void ED_markers_draw(const bContext *C, int flag)
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
/* Separate loops in order to draw selected markers on top */
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if ((marker->flag & SELECT) == 0) {
if (marker_is_in_frame_range(marker, clip_frame_range)) {
draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, region->winy);
}
}
}
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (marker->flag & SELECT) {
if (marker_is_in_frame_range(marker, clip_frame_range)) {
draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, region->winy);
@@ -906,7 +906,7 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *eve
static void ed_marker_move_apply(bContext *C, wmOperator *op)
{
#ifdef DURIAN_CAMERA_SWITCH
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
Object *camera = scene->camera;
#endif
@@ -930,7 +930,7 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op)
BKE_scene_camera_switch_update(scene);
if (camera != scene->camera) {
- BKE_screen_view3d_scene_sync(sc, scene);
+ BKE_screen_view3d_scene_sync(screen, scene);
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
}
#endif
@@ -1156,7 +1156,7 @@ static void MARKER_OT_duplicate(wmOperatorType *ot)
static void deselect_markers(ListBase *markers)
{
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, markers) {
marker->flag &= ~SELECT;
}
}
@@ -1373,7 +1373,7 @@ static int ed_marker_box_select_exec(bContext *C, wmOperator *op)
ED_markers_deselect_all(markers, SEL_DESELECT);
}
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (BLI_rctf_isect_x(&rect, marker->frame)) {
SET_FLAG_FROM_TEST(marker->flag, select, SELECT);
}
@@ -1621,7 +1621,7 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot)
static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op)
{
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
ListBase *markers = ED_context_get_markers(C);
@@ -1646,7 +1646,7 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op)
BLI_addtail(markers, marker);
/* deselect all others, so that the user can then move it without problems */
- for (TimeMarker *m = markers->first; m; m = m->next) {
+ LISTBASE_FOREACH (TimeMarker *, m, markers) {
if (m != marker) {
m->flag &= ~SELECT;
}
@@ -1658,7 +1658,7 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op)
/* camera may have changes */
BKE_scene_camera_switch_update(scene);
- BKE_screen_view3d_scene_sync(sc, scene);
+ BKE_screen_view3d_scene_sync(screen, scene);
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c
index 7e36799ff1b..4c10c66dfa6 100644
--- a/source/blender/editors/animation/anim_motion_paths.c
+++ b/source/blender/editors/animation/anim_motion_paths.c
@@ -31,7 +31,7 @@
#include "DNA_scene_types.h"
#include "BKE_action.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_main.h"
#include "BKE_scene.h"
@@ -228,7 +228,7 @@ static void motionpath_get_global_framerange(ListBase *targets, int *r_sfra, int
{
*r_sfra = INT_MAX;
*r_efra = INT_MIN;
- for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) {
+ LISTBASE_FOREACH (MPathTarget *, mpt, targets) {
*r_sfra = min_ii(*r_sfra, mpt->mpath->start_frame);
*r_efra = max_ii(*r_efra, mpt->mpath->end_frame);
}
@@ -348,7 +348,7 @@ static void motionpath_calculate_update_range(MPathTarget *mpt,
static void motionpath_free_free_tree_data(ListBase *targets)
{
- for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) {
+ LISTBASE_FOREACH (MPathTarget *, mpt, targets) {
BLI_dlrbTree_free(&mpt->keys);
}
}
@@ -412,7 +412,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
DEG_make_inactive(depsgraph);
}
- for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) {
+ LISTBASE_FOREACH (MPathTarget *, mpt, targets) {
mpt->ob_eval = DEG_get_evaluated_object(depsgraph, mpt->ob);
AnimData *adt = BKE_animdata_from_id(&mpt->ob_eval->id);
@@ -492,7 +492,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
}
/* clear recalc flags from targets */
- for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) {
+ LISTBASE_FOREACH (MPathTarget *, mpt, targets) {
bMotionPath *mpath = mpt->mpath;
/* get pointer to animviz settings for each target */
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 6b0d11802f4..2db381dfc69 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -49,6 +49,7 @@
#include "ED_anim_api.h"
#include "ED_screen.h"
#include "ED_sequencer.h"
+#include "ED_time_scrub_ui.h"
#include "ED_util.h"
#include "DEG_depsgraph.h"
@@ -61,7 +62,7 @@
/* Check if the operator can be run from the current context */
static bool change_frame_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* XXX temp? prevent changes during render */
if (G.is_rendering) {
@@ -71,11 +72,11 @@ static bool change_frame_poll(bContext *C)
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
*/
- if (sa) {
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
+ if (area) {
+ if (ELEM(area->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
return true;
}
- else if (sa->spacetype == SPACE_GRAPH) {
+ else if (area->spacetype == SPACE_GRAPH) {
/* NOTE: Graph Editor has special version which does some extra stuff.
* No need to show the generic error message for that case though!
*/
@@ -151,11 +152,13 @@ static float frame_from_event(bContext *C, const wmEvent *event)
static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
bScreen *screen = CTX_wm_screen(C);
- if (sa && sa->spacetype == SPACE_SEQ) {
- SpaceSeq *sseq = sa->spacedata.first;
- if (ED_space_sequencer_check_show_strip(sseq)) {
+ if (area && area->spacetype == SPACE_SEQ) {
+ SpaceSeq *sseq = area->spacedata.first;
+ ARegion *region = CTX_wm_region(C);
+ if (ED_space_sequencer_check_show_strip(sseq) &&
+ !ED_time_scrub_event_in_region(region, event)) {
ED_sequencer_special_preview_set(C, event->mval);
}
}
@@ -282,7 +285,7 @@ static void ANIM_OT_change_frame(wmOperatorType *ot)
static bool anim_set_end_frames_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* XXX temp? prevent changes during render */
if (G.is_rendering) {
@@ -292,8 +295,8 @@ static bool anim_set_end_frames_poll(bContext *C)
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
*/
- if (sa) {
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
+ if (area) {
+ if (ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
return true;
}
}
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index ee0f403a155..3ae4e3bf998 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -36,6 +36,7 @@
#include "DNA_space_types.h"
#include "DNA_texture_types.h"
+#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_fcurve.h"
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 9bdfd9cfe33..e795cb6e3ef 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -42,7 +42,6 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_fcurve.h"
@@ -178,7 +177,7 @@ static void draw_modifier__generator(uiLayout *layout,
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
float *cp = NULL;
char xval[32];
- unsigned int i;
+ uint i;
int maxXWidth;
/* draw polynomial order selector */
@@ -317,7 +316,7 @@ static void draw_modifier__generator(uiLayout *layout,
case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* Factorized polynomial expression */
{
float *cp = NULL;
- unsigned int i;
+ uint i;
/* draw polynomial order selector */
row = uiLayoutRow(layout, false);
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 4b3b730d0fe..b921ba039be 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -31,6 +31,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_dlrbTree.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
@@ -505,14 +506,14 @@ static void update_keyblocks(DLRBT_Tree *keys, BezTriple *bezt, int bezt_len)
/* Find the curve count */
int max_curve = 0;
- for (ActKeyColumn *col = keys->first; col; col = col->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, col, keys) {
max_curve = MAX2(max_curve, col->totcurve);
}
/* Propagate blocks to inserted keys */
ActKeyColumn *prev_ready = NULL;
- for (ActKeyColumn *col = keys->first; col; col = col->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, col, keys) {
/* Pre-existing column. */
if (col->totcurve > 0) {
prev_ready = col;
@@ -558,11 +559,11 @@ void draw_keyframe_shape(float x,
short key_type,
short mode,
float alpha,
- unsigned int pos_id,
- unsigned int size_id,
- unsigned int color_id,
- unsigned int outline_color_id,
- unsigned int flags_id,
+ uint pos_id,
+ uint size_id,
+ uint color_id,
+ uint outline_color_id,
+ uint flags_id,
short handle_type,
short extreme_type)
{
@@ -595,9 +596,9 @@ void draw_keyframe_shape(float x,
size -= 0.8f * key_type;
}
- unsigned char fill_col[4];
- unsigned char outline_col[4];
- unsigned int flags = 0;
+ uchar fill_col[4];
+ uchar outline_col[4];
+ uint flags = 0;
/* draw! */
if (draw_fill) {
@@ -730,7 +731,7 @@ static void draw_keylist(View2D *v2d,
ipo_color_mix[3] *= 0.5f;
uint block_len = 0;
- for (ActKeyColumn *ab = keys->first; ab; ab = ab->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, ab, keys) {
if (actkeyblock_get_valid_hold(ab)) {
block_len++;
}
@@ -746,7 +747,7 @@ static void draw_keylist(View2D *v2d,
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
immBegin(GPU_PRIM_TRIS, 6 * block_len);
- for (ActKeyColumn *ab = keys->first; ab; ab = ab->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, ab, keys) {
int valid_hold = actkeyblock_get_valid_hold(ab);
if (valid_hold != 0) {
if ((valid_hold & ACTKEYBLOCK_FLAG_STATIC_HOLD) == 0) {
@@ -791,7 +792,7 @@ static void draw_keylist(View2D *v2d,
if (keys) {
/* count keys */
uint key_len = 0;
- for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, ak, keys) {
/* Optimization: if keyframe doesn't appear within 5 units (screenspace)
* in visible area, don't draw.
* This might give some improvements,
@@ -822,7 +823,7 @@ static void draw_keylist(View2D *v2d,
short handle_type = KEYFRAME_HANDLE_NONE, extreme_type = KEYFRAME_EXTREME_NONE;
- for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, ak, keys) {
if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) {
if (show_ipo) {
handle_type = ak->handle_type;
@@ -1153,7 +1154,7 @@ void cachefile_to_keylist(bDopeSheet *ads,
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* loop through each F-Curve, grabbing the keyframes */
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
fcurve_to_keylist(ale->adt, ale->data, keys, saction_flag);
}
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index 61488e7f63a..e22fddc6d67 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -79,7 +79,7 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
{
BezTriple *bezt;
short ok = 0;
- unsigned int i;
+ uint i;
/* sanity check */
if (ELEM(NULL, fcu, fcu->bezt)) {
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index c526c185383..fc9ec870496 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -1189,7 +1189,7 @@ short paste_animedit_keys(bAnimContext *ac,
* one F-Curve has been pasted into.
*/
for (pass = 0; pass < 3; pass++) {
- unsigned int totmatch = 0;
+ uint totmatch = 0;
for (ale = anim_data->first; ale; ale = ale->next) {
/* Find buffer item to paste from:
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index e66ebb1928c..49e936d22aa 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -45,6 +45,7 @@
#include "DNA_scene_types.h"
#include "BKE_action.h"
+#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_armature.h"
#include "BKE_context.h"
@@ -494,7 +495,7 @@ int insert_vert_fcurve(
FCurve *fcu, float x, float y, eBezTriple_KeyframeType keyframe_type, eInsertKeyFlags flag)
{
BezTriple beztr = {{{0}}};
- unsigned int oldTot = fcu->totvert;
+ uint oldTot = fcu->totvert;
int a;
/* set all three points, for nicer start position
@@ -1793,11 +1794,11 @@ enum {
*/
static bool modify_key_op_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Scene *scene = CTX_data_scene(C);
/* if no area or active scene */
- if (ELEM(NULL, sa, scene)) {
+ if (ELEM(NULL, area, scene)) {
return false;
}
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index d30d03a1c73..89c7860982b 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -646,8 +646,8 @@ void ANIM_keyingset_infos_exit(void)
next = ksi->next;
/* free extra RNA data, and remove from list */
- if (ksi->ext.free) {
- ksi->ext.free(ksi->ext.data);
+ if (ksi->rna_ext.free) {
+ ksi->rna_ext.free(ksi->rna_ext.data);
}
BLI_freelinkN(&keyingset_type_infos, ksi);
}
diff --git a/source/blender/editors/animation/time_scrub_ui.c b/source/blender/editors/animation/time_scrub_ui.c
index 25b8e78de92..7679995d9a4 100644
--- a/source/blender/editors/animation/time_scrub_ui.c
+++ b/source/blender/editors/animation/time_scrub_ui.c
@@ -95,7 +95,7 @@ static void draw_current_frame(const Scene *scene,
int current_frame)
{
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
- const unsigned char color[] = {255, 255, 255, 255};
+ const uchar color[] = {255, 255, 255, 255};
int frame_x = UI_view2d_view_to_region_x(v2d, current_frame);
char frame_str[64];
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index 1105633f47e..f6875a6e158 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -341,7 +341,7 @@ void postEditBoneDuplicate(struct ListBase *editbones, Object *ob)
GHash *name_map = BLI_ghash_str_new(__func__);
- for (EditBone *ebone_src = editbones->first; ebone_src; ebone_src = ebone_src->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_src, editbones) {
EditBone *ebone_dst = ebone_src->temp.ebone;
if (!ebone_dst) {
ebone_dst = ED_armature_ebone_get_mirrored(editbones, ebone_src);
@@ -351,7 +351,7 @@ void postEditBoneDuplicate(struct ListBase *editbones, Object *ob)
}
}
- for (EditBone *ebone_src = editbones->first; ebone_src; ebone_src = ebone_src->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_src, editbones) {
EditBone *ebone_dst = ebone_src->temp.ebone;
if (ebone_dst) {
bPoseChannel *pchan_src = BKE_pose_channel_find_name(ob->pose, ebone_src->name);
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 9a640952253..8a7afe13a2f 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -499,7 +499,7 @@ static int armature_roll_clear_exec(bContext *C, wmOperator *op)
bArmature *arm = ob->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
/* Roll func is a callback which assumes that all is well. */
ebone->roll = roll;
@@ -508,7 +508,7 @@ static int armature_roll_clear_exec(bContext *C, wmOperator *op)
}
if (arm->flag & ARM_MIRROR_EDIT) {
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) {
EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) {
@@ -1189,13 +1189,13 @@ static int armature_split_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
- for (EditBone *bone = arm->edbo->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (EditBone *, bone, arm->edbo) {
if (bone->parent && (bone->flag & BONE_SELECTED) != (bone->parent->flag & BONE_SELECTED)) {
bone->parent = NULL;
bone->flag &= ~BONE_CONNECTED;
}
}
- for (EditBone *bone = arm->edbo->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (EditBone *, bone, arm->edbo) {
ED_armature_ebone_select_set(bone, (bone->flag & BONE_SELECTED) != 0);
}
@@ -1508,7 +1508,7 @@ static int armature_hide_exec(bContext *C, wmOperator *op)
bArmature *arm = obedit->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone)) {
if ((ebone->flag & BONE_SELECTED) != invert) {
ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
@@ -1567,7 +1567,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *op)
bArmature *arm = obedit->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (arm->layer & ebone->layer) {
if (ebone->flag & BONE_HIDDEN_A) {
if (!(ebone->flag & BONE_UNSELECTABLE)) {
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 37f0c7197a9..a454461b144 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -258,16 +258,40 @@ void armature_select_mirrored_ex(struct bArmature *arm, const int flag);
void armature_select_mirrored(struct bArmature *arm);
void armature_tag_unselect(struct bArmature *arm);
-void *get_nearest_bone(struct bContext *C, const int xy[2], bool findunsel, struct Base **r_base);
-
-void *get_bone_from_selectbuffer(struct Base **bases,
- uint bases_len,
- bool is_editmode,
- const unsigned int *buffer,
- short hits,
+EditBone *ED_armature_pick_ebone(struct bContext *C,
+ const int xy[2],
bool findunsel,
- bool do_nearest,
struct Base **r_base);
+struct bPoseChannel *ED_armature_pick_pchan(struct bContext *C,
+ const int xy[2],
+ bool findunsel,
+ struct Base **r_base);
+struct Bone *ED_armature_pick_bone(struct bContext *C,
+ const int xy[2],
+ bool findunsel,
+ struct Base **r_base);
+
+struct EditBone *ED_armature_pick_ebone_from_selectbuffer(struct Base **bases,
+ uint bases_len,
+ const uint *buffer,
+ short hits,
+ bool findunsel,
+ bool do_nearest,
+ struct Base **r_base);
+struct bPoseChannel *ED_armature_pick_pchan_from_selectbuffer(struct Base **bases,
+ uint bases_len,
+ const uint *buffer,
+ short hits,
+ bool findunsel,
+ bool do_nearest,
+ struct Base **r_base);
+struct Bone *ED_armature_pick_bone_from_selectbuffer(struct Base **bases,
+ uint bases_len,
+ const uint *buffer,
+ short hits,
+ bool findunsel,
+ bool do_nearest,
+ struct Base **r_base);
int bone_looper(struct Object *ob,
struct Bone *bone,
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index 13660244547..aa1bceb2674 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -20,6 +20,8 @@
/** \file
* \ingroup edarmature
+ *
+ * This file contains functions/API's for renaming bones and/or working with them.
*/
#include <string.h>
@@ -63,12 +65,11 @@
#include "armature_intern.h"
-/* This file contains functions/API's for renaming bones and/or working with them */
-
-/* ************************************************** */
-/* EditBone Names */
+/* -------------------------------------------------------------------- */
+/** \name Unique Bone Name Utility (Edit Mode)
+ * \{ */
-/* note: there's a unique_bone_name() too! */
+/* note: there's a ed_armature_bone_unique_name() too! */
static bool editbone_unique_check(void *arg, const char *name)
{
struct {
@@ -92,20 +93,29 @@ void ED_armature_ebone_unique_name(ListBase *edbo, char *name, EditBone *bone)
BLI_uniquename_cb(editbone_unique_check, &data, DATA_("Bone"), '.', name, sizeof(bone->name));
}
-/* ************************************************** */
-/* Bone Renaming - API */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Unique Bone Name Utility (Object Mode)
+ * \{ */
static bool bone_unique_check(void *arg, const char *name)
{
return BKE_armature_find_bone_name((bArmature *)arg, name) != NULL;
}
-static void unique_bone_name(bArmature *arm, char *name)
+static void ed_armature_bone_unique_name(bArmature *arm, char *name)
{
BLI_uniquename_cb(
bone_unique_check, (void *)arm, DATA_("Bone"), '.', name, sizeof(((Bone *)NULL)->name));
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Bone Renaming (Object & Edit Mode API)
+ * \{ */
+
/* helper call for armature_bone_rename */
static void constraint_bone_name_fix(Object *ob,
ListBase *conlist,
@@ -180,7 +190,7 @@ void ED_armature_bone_rename(Main *bmain,
Bone *bone = BKE_armature_find_bone_name(arm, oldname);
if (bone) {
- unique_bone_name(arm, newname);
+ ed_armature_bone_unique_name(arm, newname);
if (arm->bonehash) {
BLI_assert(BLI_ghash_haskey(arm->bonehash, bone->name));
@@ -307,8 +317,7 @@ void ED_armature_bone_rename(Main *bmain,
}
}
- for (GpencilModifierData *gp_md = ob->greasepencil_modifiers.first; gp_md;
- gp_md = gp_md->next) {
+ LISTBASE_FOREACH (GpencilModifierData *, gp_md, &ob->greasepencil_modifiers) {
switch (gp_md->type) {
case eGpencilModifierType_Armature: {
ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)gp_md;
@@ -352,11 +361,11 @@ void ED_armature_bone_rename(Main *bmain,
{
bScreen *screen;
for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- ScrArea *sa;
+ ScrArea *area;
/* add regions */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ for (area = screen->areabase.first; area; area = area->next) {
SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ for (sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
if (v3d->ob_center && v3d->ob_center->data == arm) {
@@ -372,6 +381,12 @@ void ED_armature_bone_rename(Main *bmain,
}
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Bone Flipping (Object & Edit Mode API)
+ * \{ */
+
typedef struct BoneFlipNameData {
struct BoneFlipNameData *next, *prev;
char *name;
@@ -399,7 +414,7 @@ void ED_armature_bones_flip_names(Main *bmain,
/* First pass: generate flip names, and blindly rename.
* If rename did not yield expected result,
* store both bone's name and expected flipped one into temp list for second pass. */
- for (LinkData *link = bones_names->first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, bones_names) {
char name_flip[MAXBONENAME];
char *name = link->data;
@@ -426,8 +441,11 @@ void ED_armature_bones_flip_names(Main *bmain,
}
}
-/* ************************************************** */
-/* Bone Renaming - EditMode */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Flip Bone Names (Edit Mode Operator)
+ * \{ */
static int armature_flip_names_exec(bContext *C, wmOperator *op)
{
@@ -451,7 +469,7 @@ static int armature_flip_names_exec(bContext *C, wmOperator *op)
ListBase bones_names = {NULL};
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & BONE_SELECTED) {
BLI_addtail(&bones_names, BLI_genericNodeN(ebone->name));
@@ -511,6 +529,12 @@ void ARMATURE_OT_flip_names(wmOperatorType *ot)
"(WARNING: may result in incoherent naming in some cases)");
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Bone Auto Side Names (Edit Mode Operator)
+ * \{ */
+
static int armature_autoside_names_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -532,7 +556,7 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op)
continue;
}
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_EDITABLE(ebone)) {
/* We first need to do the flipped bone, then the original one.
@@ -599,3 +623,5 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot)
/* settings */
ot->prop = RNA_def_enum(ot->srna, "type", axis_items, 0, "Axis", "Axis tag names with");
}
+
+/** \} */
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 4580d2c30ae..644e466e904 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -37,6 +37,7 @@
#include "BLT_translation.h"
#include "BKE_action.h"
+#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_armature.h"
#include "BKE_constraint.h"
@@ -568,7 +569,7 @@ static void separate_armature_bones(Main *bmain, Object *ob, const bool is_selec
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 */
- for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) {
+ LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) {
if (ebo->parent == curbone) {
ebo->parent = NULL;
/* this is needed to prevent random crashes with in ED_armature_from_edit */
@@ -578,7 +579,7 @@ static void separate_armature_bones(Main *bmain, Object *ob, const bool is_selec
}
/* clear the pchan->parent var of any pchan that had this as its parent */
- for (bPoseChannel *pchn = ob->pose->chanbase.first; pchn; pchn = pchn->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchn, &ob->pose->chanbase) {
if (pchn->parent == pchan) {
pchn->parent = NULL;
}
@@ -629,7 +630,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
bArmature *arm_old = ob_old->data;
bool has_selected_bone = false;
bool has_selected_any = false;
- for (EditBone *ebone = arm_old->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm_old->edbo) {
if (EBONE_VISIBLE(arm_old, ebone)) {
if (ebone->flag & BONE_SELECTED) {
has_selected_bone = true;
@@ -835,7 +836,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
bool is_active_only_selected = false;
if (actbone->flag & BONE_SELECTED) {
is_active_only_selected = true;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) {
if (ebone != actbone) {
is_active_only_selected = false;
@@ -867,7 +868,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
*/
/* Parent selected bones to the active one. */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) {
if (ebone != actbone) {
bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
@@ -901,7 +902,7 @@ static int armature_parent_set_invoke(bContext *C,
Object *ob = CTX_data_edit_object(C);
bArmature *arm = ob->data;
EditBone *actbone = arm->act_edbone;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) {
if (ebone != actbone) {
if (ebone->parent != actbone) {
@@ -983,7 +984,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op)
bArmature *arm = ob->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_EDITABLE(ebone)) {
changed = true;
break;
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 99dcd5bb42b..4b938fb0072 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -30,6 +30,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
+#include "BLI_rect.h"
#include "BLI_string_utils.h"
#include "BKE_action.h"
@@ -111,14 +112,14 @@ Object *ED_armature_object_and_ebone_from_select_buffer(Object **objects,
return ob;
}
-Base *ED_armature_base_and_bone_from_select_buffer(Base **bases,
- uint bases_len,
- int hit,
- Bone **r_bone)
+Base *ED_armature_base_and_pchan_from_select_buffer(Base **bases,
+ uint bases_len,
+ int hit,
+ bPoseChannel **r_pchan)
{
const uint hit_object = hit & 0xFFFF;
Base *base = NULL;
- Bone *bone = NULL;
+ bPoseChannel *pchan = NULL;
/* TODO(campbell): optimize, eg: sort & binary search. */
for (uint base_index = 0; base_index < bases_len; base_index++) {
if (bases[base_index]->object->runtime.select_id == hit_object) {
@@ -129,30 +130,53 @@ Base *ED_armature_base_and_bone_from_select_buffer(Base **bases,
if (base != NULL) {
if (base->object->pose != NULL) {
const uint hit_bone = (hit & ~BONESEL_ANY) >> 16;
- bPoseChannel *pchan = BLI_findlink(&base->object->pose->chanbase, hit_bone);
- bone = pchan ? pchan->bone : NULL;
+ /* pchan may be NULL. */
+ pchan = BLI_findlink(&base->object->pose->chanbase, hit_bone);
}
}
- *r_bone = bone;
+ *r_pchan = pchan;
+ return base;
+}
+
+/* For callers that don't need the pose channel. */
+Base *ED_armature_base_and_bone_from_select_buffer(Base **bases,
+ uint bases_len,
+ int hit,
+ Bone **r_bone)
+{
+ bPoseChannel *pchan = NULL;
+ Base *base = ED_armature_base_and_pchan_from_select_buffer(bases, bases_len, hit, &pchan);
+ *r_bone = pchan ? pchan->bone : NULL;
return base;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Cursor Pick from Select Buffer API
+ *
+ * Internal #ed_armature_pick_bone_from_selectbuffer_impl is exposed as:
+ * - #ED_armature_pick_ebone_from_selectbuffer
+ * - #ED_armature_pick_pchan_from_selectbuffer
+ * - #ED_armature_pick_bone_from_selectbuffer
+ * \{ */
+
/* See if there are any selected bones in this buffer */
/* only bones from base are checked on */
-void *get_bone_from_selectbuffer(Base **bases,
- uint bases_len,
- bool is_editmode,
- const unsigned int *buffer,
- short hits,
- bool findunsel,
- bool do_nearest,
- Base **r_base)
+static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode,
+ Base **bases,
+ uint bases_len,
+ const uint *buffer,
+ short hits,
+ bool findunsel,
+ bool do_nearest,
+ Base **r_base)
{
- Bone *bone;
+ bPoseChannel *pchan;
EditBone *ebone;
void *firstunSel = NULL, *firstSel = NULL, *data;
Base *firstunSel_base = NULL, *firstSel_base = NULL;
- unsigned int hitresult;
+ uint hitresult;
short i;
bool takeNext = false;
int minsel = 0xffffffff, minunsel = 0xffffffff;
@@ -168,16 +192,17 @@ void *get_bone_from_selectbuffer(Base **bases,
hitresult &= ~(BONESEL_ANY);
/* Determine what the current bone is */
if (is_editmode == false) {
- base = ED_armature_base_and_bone_from_select_buffer(bases, bases_len, hitresult, &bone);
- if (bone != NULL) {
+ base = ED_armature_base_and_pchan_from_select_buffer(
+ bases, bases_len, hitresult, &pchan);
+ if (pchan != NULL) {
if (findunsel) {
- sel = (bone->flag & BONE_SELECTED);
+ sel = (pchan->bone->flag & BONE_SELECTED);
}
else {
- sel = !(bone->flag & BONE_SELECTED);
+ sel = !(pchan->bone->flag & BONE_SELECTED);
}
- data = bone;
+ data = pchan;
}
else {
data = NULL;
@@ -248,22 +273,74 @@ void *get_bone_from_selectbuffer(Base **bases,
}
}
-/* used by posemode as well editmode */
-/* only checks scene->basact! */
-/* x and y are mouse coords (area space) */
-void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel, Base **r_base)
+EditBone *ED_armature_pick_ebone_from_selectbuffer(Base **bases,
+ uint bases_len,
+ const uint *buffer,
+ short hits,
+ bool findunsel,
+ bool do_nearest,
+ Base **r_base)
+{
+ const bool is_editmode = true;
+ return ed_armature_pick_bone_from_selectbuffer_impl(
+ is_editmode, bases, bases_len, buffer, hits, findunsel, do_nearest, r_base);
+}
+
+bPoseChannel *ED_armature_pick_pchan_from_selectbuffer(Base **bases,
+ uint bases_len,
+ const uint *buffer,
+ short hits,
+ bool findunsel,
+ bool do_nearest,
+ Base **r_base)
+{
+ const bool is_editmode = false;
+ return ed_armature_pick_bone_from_selectbuffer_impl(
+ is_editmode, bases, bases_len, buffer, hits, findunsel, do_nearest, r_base);
+}
+
+Bone *ED_armature_pick_bone_from_selectbuffer(Base **bases,
+ uint bases_len,
+ const uint *buffer,
+ short hits,
+ bool findunsel,
+ bool do_nearest,
+ Base **r_base)
+{
+ bPoseChannel *pchan = ED_armature_pick_pchan_from_selectbuffer(
+ bases, bases_len, buffer, hits, findunsel, do_nearest, r_base);
+ return pchan ? pchan->bone : NULL;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Cursor Pick API
+ *
+ * Internal #ed_armature_pick_bone_impl is exposed as:
+ * - #ED_armature_pick_ebone
+ * - #ED_armature_pick_pchan
+ * - #ED_armature_pick_bone
+ * \{ */
+
+/**
+ * \param xy: Cursor coordinates (area space).
+ * \return An #EditBone when is_editmode, otherwise a #bPoseChannel.
+ * \note Only checks objects in the current mode (edit-mode or pose-mode).
+ */
+static void *ed_armature_pick_bone_impl(
+ const bool is_editmode, bContext *C, const int xy[2], bool findunsel, Base **r_base)
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewContext vc;
rcti rect;
- unsigned int buffer[MAXPICKBUF];
+ uint buffer[MAXPICKBUF];
short hits;
ED_view3d_viewcontext_init(C, &vc, depsgraph);
+ BLI_assert((vc.obedit != NULL) == is_editmode);
- // rect.xmin = ... mouseco!
- rect.xmin = rect.xmax = xy[0];
- rect.ymin = rect.ymax = xy[1];
+ BLI_rcti_init_pt_radius(&rect, xy, 0);
hits = view3d_opengl_select(
&vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST, VIEW3D_SELECT_FILTER_NOP);
@@ -286,15 +363,34 @@ void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel, Base **r_ba
bases = BKE_object_pose_base_array_get(vc.view_layer, vc.v3d, &bases_len);
}
- void *bone = get_bone_from_selectbuffer(
- bases, bases_len, vc.obedit != NULL, buffer, hits, findunsel, true, r_base);
+ void *bone = ed_armature_pick_bone_from_selectbuffer_impl(
+ is_editmode, bases, bases_len, buffer, hits, findunsel, true, r_base);
MEM_freeN(bases);
+
return bone;
}
return NULL;
}
+EditBone *ED_armature_pick_ebone(bContext *C, const int xy[2], bool findunsel, Base **r_base)
+{
+ const bool is_editmode = true;
+ return ed_armature_pick_bone_impl(is_editmode, C, xy, findunsel, r_base);
+}
+
+bPoseChannel *ED_armature_pick_pchan(bContext *C, const int xy[2], bool findunsel, Base **r_base)
+{
+ const bool is_editmode = false;
+ return ed_armature_pick_bone_impl(is_editmode, C, xy, findunsel, r_base);
+}
+
+Bone *ED_armature_pick_bone(bContext *C, const int xy[2], bool findunsel, Base **r_base)
+{
+ bPoseChannel *pchan = ED_armature_pick_pchan(C, xy, findunsel, r_base);
+ return pchan ? pchan->bone : NULL;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -330,12 +426,12 @@ static bool armature_select_linked_impl(Object *ob, const bool select, const boo
(((ebone)->flag & BONE_CONNECTED) && \
((ebone)->parent ? EBONE_SELECTABLE(arm, (ebone)->parent) : false))
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
ebone->temp.i = 0;
}
/* Select parents. */
- for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
if (ebone_iter->temp.i & TOUCH) {
continue;
}
@@ -364,7 +460,7 @@ static bool armature_select_linked_impl(Object *ob, const bool select, const boo
}
/* Select children. */
- for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
/* No need to 'touch' this bone as it won't be walked over when scanning up the chain. */
if (!CHECK_PARENT(ebone_iter)) {
continue;
@@ -425,7 +521,7 @@ static int armature_select_linked_exec(bContext *C, wmOperator *op)
bArmature *arm = ob->data;
bool found = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone) &&
(ebone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL))) {
ebone->flag |= BONE_DONE;
@@ -483,15 +579,19 @@ static int armature_select_linked_pick_invoke(bContext *C, wmOperator *op, const
BKE_object_update_select_id(CTX_data_main(C));
Base *base = NULL;
- EditBone *ebone_active = get_nearest_bone(C, event->mval, true, &base);
- bArmature *arm = base->object->data;
+ EditBone *ebone_active = ED_armature_pick_ebone(C, event->mval, true, &base);
+
+ if (ebone_active == NULL) {
+ return OPERATOR_CANCELLED;
+ }
- if (ebone_active == NULL || !EBONE_SELECTABLE(arm, ebone_active)) {
+ bArmature *arm = base->object->data;
+ if (!EBONE_SELECTABLE(arm, ebone_active)) {
return OPERATOR_CANCELLED;
}
/* Initialize flags. */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
ebone->flag &= ~BONE_DONE;
}
ebone_active->flag |= BONE_DONE;
@@ -535,15 +635,15 @@ void ARMATURE_OT_select_linked_pick(wmOperatorType *ot)
* \{ */
/* utility function for get_nearest_editbonepoint */
-static int selectbuffer_ret_hits_12(unsigned int *UNUSED(buffer), const int hits12)
+static int selectbuffer_ret_hits_12(uint *UNUSED(buffer), const int hits12)
{
return hits12;
}
-static int selectbuffer_ret_hits_5(unsigned int *buffer, const int hits12, const int hits5)
+static int selectbuffer_ret_hits_5(uint *buffer, const int hits12, const int hits5)
{
const int offs = 4 * hits12;
- memcpy(buffer, buffer + offs, 4 * hits5 * sizeof(unsigned int));
+ memcpy(buffer, buffer + offs, 4 * hits5 * sizeof(uint));
return hits5;
}
@@ -748,7 +848,7 @@ bool ED_armature_edit_deselect_all(Object *obedit)
{
bArmature *arm = obedit->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) {
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
changed = true;
@@ -761,7 +861,7 @@ bool ED_armature_edit_deselect_all_visible(Object *obedit)
{
bArmature *arm = obedit->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
/* first and foremost, bone must be visible and selected */
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) {
@@ -813,21 +913,9 @@ bool ED_armature_edit_deselect_all_visible_multi(bContext *C)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Cursor Picking API
+/** \name Select Cursor Pick API
* \{ */
-/* accounts for connected parents */
-static int ebone_select_flag(EditBone *ebone)
-{
- if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
- return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) |
- (ebone->flag & (BONE_SELECTED | BONE_TIPSEL));
- }
- else {
- return ebone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
- }
-}
-
/* context: editmode armature in view3d */
bool ED_armature_edit_select_pick(
bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
@@ -939,7 +1027,7 @@ bool ED_armature_edit_select_pick(
ED_armature_edit_sync_selection(arm->edbo);
/* then now check for active status */
- if (ebone_select_flag(nearBone)) {
+ if (ED_armature_ebone_selectflag_get(nearBone)) {
arm->act_edbone = nearBone;
}
@@ -1050,7 +1138,7 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op)
/* Initialize flags. */
{
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
/* Flush the parent flag to this bone
* so we don't need to check the parent when adjusting the selection. */
@@ -1072,7 +1160,7 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op)
}
/* Apply selection from bone selection flags. */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->temp.i != 0) {
int is_ignore_flag = ((ebone->temp.i << 16) & (BONESEL_ROOT | BONESEL_TIP));
int is_inside_flag = (ebone->temp.i & (BONESEL_ROOT | BONESEL_TIP | BONESEL_BONE));
@@ -1092,7 +1180,7 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op)
if (changed) {
/* Cleanup flags. */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->flag & BONE_DONE) {
SWAP(int, ebone->temp.i, ebone->flag);
ebone->flag |= BONE_DONE;
@@ -1105,7 +1193,7 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op)
}
}
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->flag & BONE_DONE) {
if ((ebone->flag & BONE_CONNECTED) && ebone->parent) {
bool is_parent_tip_changed = (ebone->parent->flag & BONE_TIPSEL) !=
@@ -1451,7 +1539,7 @@ static void select_similar_length(bContext *C, const float thresh)
bArmature *arm = ob->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
const float len_iter = bone_length_squared_worldspace_get(ob, ebone);
if ((len_iter > len_min) && (len_iter < len_max)) {
@@ -1499,7 +1587,7 @@ static void select_similar_direction(bContext *C, const float thresh)
bArmature *arm = ob->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
float dir[3];
bone_direction_worldspace_get(ob, ebone, dir);
@@ -1533,7 +1621,7 @@ static void select_similar_layer(bContext *C)
bArmature *arm = ob->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
if (ebone->layer & ebone_act->layer) {
ED_armature_ebone_select_set(ebone, true);
@@ -1573,7 +1661,7 @@ static void select_similar_prefix(bContext *C)
bool changed = false;
/* Find matches */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
char prefix_other[MAXBONENAME];
BLI_string_split_prefix(ebone->name, prefix_other, body_tmp, sizeof(ebone->name));
@@ -1615,7 +1703,7 @@ static void select_similar_suffix(bContext *C)
bool changed = false;
/* Find matches */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
char suffix_other[MAXBONENAME];
BLI_string_split_suffix(ebone->name, body_tmp, suffix_other, sizeof(ebone->name));
@@ -1650,7 +1738,7 @@ static void select_similar_data_pchan(bContext *C, const size_t bytes_size, cons
}
const char *data_active = (const char *)POINTER_OFFSET(pchan_active, offset);
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
const bPoseChannel *pchan = BKE_pose_channel_find_name(obedit->pose, ebone->name);
if (pchan) {
@@ -1685,11 +1773,11 @@ static void select_similar_children(bContext *C)
bArmature *arm = obedit->data;
EditBone *ebone_act = CTX_data_active_bone(C);
- for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
ebone_iter->temp.ebone = ebone_iter->parent;
}
- for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
is_ancestor(ebone_iter, ebone_act);
if (ebone_iter->temp.ebone == ebone_act && EBONE_SELECTABLE(arm, ebone_iter)) {
@@ -1707,7 +1795,7 @@ static void select_similar_children_immediate(bContext *C)
bArmature *arm = obedit->data;
EditBone *ebone_act = CTX_data_active_bone(C);
- for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
if (ebone_iter->parent == ebone_act && EBONE_SELECTABLE(arm, ebone_iter)) {
ED_armature_ebone_select_set(ebone_iter, true);
}
@@ -1727,7 +1815,7 @@ static void select_similar_siblings(bContext *C)
return;
}
- for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
if (ebone_iter->parent == ebone_act->parent && EBONE_SELECTABLE(arm, ebone_iter)) {
ED_armature_ebone_select_set(ebone_iter, true);
}
@@ -2059,7 +2147,7 @@ static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const
BKE_object_update_select_id(CTX_data_main(C));
ebone_src = arm->act_edbone;
- ebone_dst = get_nearest_bone(C, event->mval, false, &base_dst);
+ ebone_dst = ED_armature_pick_ebone(C, event->mval, false, &base_dst);
/* fallback to object selection */
if (ELEM(NULL, ebone_src, ebone_dst) || (ebone_src == ebone_dst)) {
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index 87f980db7b9..b637a57f7c0 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -459,7 +459,7 @@ static void add_verts_to_dgroups(ReportList *reports,
}
/* only generated in some cases but can call anyway */
- ED_mesh_mirror_spatial_table(ob, NULL, NULL, NULL, 'e');
+ ED_mesh_mirror_spatial_table_end(ob);
/* free the memory allocated */
MEM_freeN(bonelist);
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index 58ceef5b7db..cf7f6699e5e 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -92,7 +92,7 @@ void ED_armature_edit_validate_active(struct bArmature *arm)
void ED_armature_edit_refresh_layer_used(bArmature *arm)
{
arm->layer_used = 0;
- for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) {
+ LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) {
arm->layer_used |= ebo->layer;
}
}
@@ -142,7 +142,7 @@ void bone_free(bArmature *arm, EditBone *bone)
}
/* Clear references from other edit bones. */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->bbone_next == bone) {
ebone->bbone_next = NULL;
}
@@ -196,13 +196,12 @@ bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebon
* \param ebone_child_tot: Size of the ebone_child array
* \return The shared parent or NULL.
*/
-EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[],
- const unsigned int ebone_child_tot)
+EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], const uint ebone_child_tot)
{
- unsigned int i;
+ uint i;
EditBone *ebone_iter;
-#define EBONE_TEMP_UINT(ebone) (*((unsigned int *)(&((ebone)->temp))))
+#define EBONE_TEMP_UINT(ebone) (*((uint *)(&((ebone)->temp))))
/* clear all */
for (i = 0; i < ebone_child_tot; i++) {
@@ -473,7 +472,7 @@ void ED_armature_ebone_transform_mirror_update(bArmature *arm, EditBone *ebo, bo
void ED_armature_edit_transform_mirror_update(Object *obedit)
{
bArmature *arm = obedit->data;
- for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) {
+ LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) {
ED_armature_ebone_transform_mirror_update(arm, ebo, true);
}
}
@@ -482,10 +481,10 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
/* Armature EditMode Conversions */
/* converts Bones to EditBone list, used for tools as well */
-static EditBone *make_boneList_rec(ListBase *edbo,
- ListBase *bones,
- EditBone *parent,
- Bone *actBone)
+static EditBone *make_boneList_recursive(ListBase *edbo,
+ ListBase *bones,
+ EditBone *parent,
+ Bone *actBone)
{
EditBone *eBone;
EditBone *eBoneAct = NULL;
@@ -564,7 +563,7 @@ static EditBone *make_boneList_rec(ListBase *edbo,
/* Add children if necessary. */
if (curBone->childbase.first) {
- eBoneTest = make_boneList_rec(edbo, &curBone->childbase, eBone, actBone);
+ eBoneTest = make_boneList_recursive(edbo, &curBone->childbase, eBone, actBone);
if (eBoneTest) {
eBoneAct = eBoneTest;
}
@@ -581,7 +580,7 @@ static EditBone *make_boneList_rec(ListBase *edbo,
static EditBone *find_ebone_link(ListBase *edbo, Bone *link)
{
if (link != NULL) {
- for (EditBone *ebone = edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, edbo) {
if (ebone->temp.bone == link) {
return ebone;
}
@@ -595,9 +594,9 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, struct Bone *actBone)
{
BLI_assert(!edbo->first && !edbo->last);
- EditBone *active = make_boneList_rec(edbo, bones, NULL, actBone);
+ EditBone *active = make_boneList_recursive(edbo, bones, NULL, actBone);
- for (EditBone *ebone = edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, edbo) {
Bone *bone = ebone->temp.bone;
/* Convert custom B-Bone handle links. */
diff --git a/source/blender/editors/armature/editarmature_undo.c b/source/blender/editors/armature/editarmature_undo.c
index c73f8f69fdd..a3a73f8d509 100644
--- a/source/blender/editors/armature/editarmature_undo.c
+++ b/source/blender/editors/armature/editarmature_undo.c
@@ -29,6 +29,7 @@
#include "DNA_object_types.h"
#include "BLI_array_utils.h"
+#include "BLI_listbase.h"
#include "BKE_context.h"
#include "BKE_layer.h"
@@ -94,7 +95,7 @@ static void *undoarm_from_editarm(UndoArmature *uarm, bArmature *arm)
ED_armature_ebone_listbase_temp_clear(&uarm->lb);
- for (EditBone *ebone = uarm->lb.first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, &uarm->lb) {
uarm->undo_size += sizeof(EditBone);
}
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 09b6cd9c8cc..b86da6374be 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -33,7 +33,7 @@
#include "DNA_scene_types.h"
#include "BKE_action.h"
-#include "BKE_anim.h"
+#include "BKE_anim_visualization.h"
#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_deform.h"
@@ -75,12 +75,12 @@
/* matches logic with ED_operator_posemode_context() */
Object *ED_pose_object_from_context(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Object *ob;
/* Since this call may also be used from the buttons window,
* we need to check for where to get the object. */
- if (sa && sa->spacetype == SPACE_PROPERTIES) {
+ if (area && area->spacetype == SPACE_PROPERTIES) {
ob = ED_object_context(C);
}
else {
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index f759808d08e..aa57fb5844d 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -161,16 +161,16 @@ static TimeMarker *poselib_get_active_pose(bAction *act)
/* XXX C can be zero */
static Object *get_poselib_object(bContext *C)
{
- ScrArea *sa;
+ ScrArea *area;
/* sanity check */
if (C == NULL) {
return NULL;
}
- sa = CTX_wm_area(C);
+ area = CTX_wm_area(C);
- if (sa && (sa->spacetype == SPACE_PROPERTIES)) {
+ if (area && (area->spacetype == SPACE_PROPERTIES)) {
return ED_object_context(C);
}
else {
@@ -626,7 +626,7 @@ static int poselib_remove_exec(bContext *C, wmOperator *op)
/* remove relevant keyframes */
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
BezTriple *bezt;
- unsigned int i;
+ uint i;
if (fcu->bezt) {
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
@@ -870,7 +870,7 @@ typedef struct tPoseLib_PreviewData {
/** active scene. */
Scene *scene;
/** active area. */
- ScrArea *sa;
+ ScrArea *area;
/** RNA-Pointer to Object 'ob' .*/
PointerRNA rna_ptr;
@@ -1171,7 +1171,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
/* do header print - if interactively previewing */
if (pld->state == PL_PREVIEW_RUNNING) {
if (pld->flag & PL_PREVIEW_SHOWORIGINAL) {
- ED_area_status_text(pld->sa, TIP_("PoseLib Previewing Pose: [Showing Original Pose]"));
+ ED_area_status_text(pld->area, TIP_("PoseLib Previewing Pose: [Showing Original Pose]"));
ED_workspace_status_text(C, TIP_("Use Tab to start previewing poses again"));
}
else if (pld->searchstr[0]) {
@@ -1200,7 +1200,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
"Current Pose - \"%s\""),
tempstr,
markern);
- ED_area_status_text(pld->sa, pld->headerstr);
+ ED_area_status_text(pld->area, pld->headerstr);
ED_workspace_status_text(C, TIP_("Use ScrollWheel or PageUp/Down to change pose"));
}
else {
@@ -1208,7 +1208,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
sizeof(pld->headerstr),
TIP_("PoseLib Previewing Pose: \"%s\""),
pld->marker->name);
- ED_area_status_text(pld->sa, pld->headerstr);
+ ED_area_status_text(pld->area, pld->headerstr);
ED_workspace_status_text(C, NULL);
}
}
@@ -1323,9 +1323,7 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
}
/* specially handle events for searching */
-static void poselib_preview_handle_search(tPoseLib_PreviewData *pld,
- unsigned short event,
- char ascii)
+static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, ushort event, char ascii)
{
/* try doing some form of string manipulation first */
switch (event) {
@@ -1633,7 +1631,7 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
pld->act = (ob) ? (ob->poselib) : NULL;
pld->scene = CTX_data_scene(C);
- pld->sa = CTX_wm_area(C);
+ pld->area = CTX_wm_area(C);
/* get starting pose based on RNA-props for this operator */
if (pose_index == -1) {
@@ -1704,7 +1702,7 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
TimeMarker *marker = pld->marker;
/* redraw the header so that it doesn't show any of our stuff anymore */
- ED_area_status_text(pld->sa, NULL);
+ ED_area_status_text(pld->area, NULL);
ED_workspace_status_text(C, NULL);
/* this signal does one recalc on pose, then unlocks, so ESC or edit will work */
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index 475640fa37c..8df4f6b7dfc 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -141,7 +141,7 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
bool ED_armature_pose_select_pick_with_buffer(ViewLayer *view_layer,
View3D *v3d,
Base *base,
- const unsigned int *buffer,
+ const uint *buffer,
short hits,
bool extend,
bool deselect,
@@ -156,12 +156,12 @@ bool ED_armature_pose_select_pick_with_buffer(ViewLayer *view_layer,
}
Object *ob_act = OBACT(view_layer);
- Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
+ BLI_assert(OBEDIT_FROM_VIEW_LAYER(view_layer) == NULL);
/* Callers happen to already get the active base */
Base *base_dummy = NULL;
- nearBone = get_bone_from_selectbuffer(
- &base, 1, obedit != NULL, buffer, hits, 1, do_nearest, &base_dummy);
+ nearBone = ED_armature_pick_bone_from_selectbuffer(
+ &base, 1, buffer, hits, 1, do_nearest, &base_dummy);
/* if the bone cannot be affected, don't do anything */
if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) {
@@ -323,7 +323,7 @@ bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil
static bool ed_pose_is_any_selected(Object *ob, bool ignore_visibility)
{
bArmature *arm = ob->data;
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (ignore_visibility || PBONE_VISIBLE(arm, pchan->bone)) {
if (pchan->bone->flag & BONE_SELECTED) {
return true;
@@ -413,7 +413,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
view3d_operator_needs_opengl(C);
Base *base = NULL;
- bone = get_nearest_bone(C, event->mval, !extend, &base);
+ bone = ED_armature_pick_bone(C, event->mval, !extend, &base);
if (!bone) {
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 336d09f71b5..ae08aee3c47 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -86,7 +86,7 @@ typedef struct tPoseSlideOp {
/** current scene */
Scene *scene;
/** area that we're operating in (needed for modal()) */
- ScrArea *sa;
+ ScrArea *area;
/** region that we're operating in (needed for modal()) */
ARegion *region;
/** len of the PoseSlideObject array. */
@@ -197,7 +197,7 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode)
/* get info from context */
pso->scene = CTX_data_scene(C);
- pso->sa = CTX_wm_area(C); /* only really needed when doing modal() */
+ pso->area = CTX_wm_area(C); /* only really needed when doing modal() */
pso->region = CTX_wm_region(C); /* only really needed when doing modal() */
pso->cframe = pso->scene->r.cfra;
@@ -904,7 +904,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
limits_str);
}
- ED_area_status_text(pso->sa, status_str);
+ ED_area_status_text(pso->area, status_str);
}
/* common code for invoke() methods */
@@ -1071,7 +1071,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
case EVT_PADENTER: {
if (event->val == KM_PRESS) {
/* return to normal cursor and header status */
- ED_area_status_text(pso->sa, NULL);
+ ED_area_status_text(pso->area, NULL);
WM_cursor_modal_restore(win);
/* insert keyframes as required... */
@@ -1088,7 +1088,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
case RIGHTMOUSE: {
if (event->val == KM_PRESS) {
/* return to normal cursor and header status */
- ED_area_status_text(pso->sa, NULL);
+ ED_area_status_text(pso->area, NULL);
WM_cursor_modal_restore(win);
/* reset transforms back to original state */
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index fe79894a351..31c89ca9f43 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -207,12 +207,12 @@ typedef struct ApplyArmature_ParentState {
} ApplyArmature_ParentState;
/* Recursive walk for Apply To Selected mode; pstate NULL unless child of an applied bone. */
-static void applyarmature_process_selected_rec(bArmature *arm,
- bPose *pose,
- bPose *pose_eval,
- Bone *bone,
- ListBase *selected,
- ApplyArmature_ParentState *pstate)
+static void applyarmature_process_selected_recursive(bArmature *arm,
+ bPose *pose,
+ bPose *pose_eval,
+ Bone *bone,
+ ListBase *selected,
+ ApplyArmature_ParentState *pstate)
{
bPoseChannel *pchan = BKE_pose_channel_find_name(pose, bone->name);
const bPoseChannel *pchan_eval = BKE_pose_channel_find_name(pose_eval, bone->name);
@@ -333,8 +333,8 @@ static void applyarmature_process_selected_rec(bArmature *arm,
pstate = &new_pstate;
}
- for (Bone *child = bone->childbase.first; child; child = child->next) {
- applyarmature_process_selected_rec(arm, pose, pose_eval, child, selected, pstate);
+ LISTBASE_FOREACH (Bone *, child, &bone->childbase) {
+ applyarmature_process_selected_recursive(arm, pose, pose_eval, child, selected, pstate);
}
}
@@ -389,8 +389,9 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
if (use_selected) {
/* The selected only mode requires a recursive walk to handle parent-child relations. */
- for (Bone *bone = arm->bonebase.first; bone; bone = bone->next) {
- applyarmature_process_selected_rec(arm, pose, ob_eval->pose, bone, &selected_bones, NULL);
+ LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) {
+ applyarmature_process_selected_recursive(
+ arm, pose, ob_eval->pose, bone, &selected_bones, NULL);
}
BLI_freelistN(&selected_bones);
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index efb568178d9..e2038bdd2a3 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -32,7 +32,7 @@
#include "DNA_scene_types.h"
#include "BKE_action.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_armature.h"
#include "BKE_idprop.h"
#include "BKE_layer.h"
diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt
index 8c9309055c8..ff80c47baa8 100644
--- a/source/blender/editors/curve/CMakeLists.txt
+++ b/source/blender/editors/curve/CMakeLists.txt
@@ -40,6 +40,7 @@ set(SRC
editcurve.c
editcurve_add.c
editcurve_paint.c
+ editcurve_query.c
editcurve_select.c
editcurve_undo.c
editfont.c
diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h
index 201ba2560dc..7d0a2e5edbc 100644
--- a/source/blender/editors/curve/curve_intern.h
+++ b/source/blender/editors/curve/curve_intern.h
@@ -142,14 +142,6 @@ void CURVE_OT_match_texture_space(struct wmOperatorType *ot);
struct GHash *ED_curve_keyindex_hash_duplicate(struct GHash *keyindex);
void ED_curve_keyindex_update_nurb(struct EditNurb *editnurb, struct Nurb *nu, struct Nurb *newnu);
-bool ED_curve_pick_vert(struct ViewContext *vc,
- short sel,
- struct Nurb **r_nurb,
- struct BezTriple **r_bezt,
- struct BPoint **r_bp,
- short *r_handle,
- struct Base **r_base);
-
/* helper functions */
void ed_editnurb_translate_flag(struct ListBase *editnurb, short flag, const float vec[3]);
bool ed_editnurb_extrude_flag(struct EditNurb *editnurb, const short flag);
@@ -189,6 +181,17 @@ void SURFACE_OT_primitive_nurbs_surface_cylinder_add(struct wmOperatorType *ot);
void SURFACE_OT_primitive_nurbs_surface_sphere_add(struct wmOperatorType *ot);
void SURFACE_OT_primitive_nurbs_surface_torus_add(struct wmOperatorType *ot);
+/* editcurve_query.c */
+bool ED_curve_pick_vert(struct ViewContext *vc,
+ short sel,
+ struct Nurb **r_nurb,
+ struct BezTriple **r_bezt,
+ struct BPoint **r_bp,
+ short *r_handle,
+ struct Base **r_base);
+void ED_curve_nurb_vert_selected_find(
+ Curve *cu, View3D *v3d, Nurb **r_nu, BezTriple **r_bezt, BPoint **r_bp);
+
/* editcurve_paint.c */
void CURVE_OT_draw(struct wmOperatorType *ot);
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 2911611c516..8984c090a0e 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -36,7 +36,7 @@
#include "BLT_translation.h"
#include "BKE_action.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_displist.h"
@@ -81,6 +81,10 @@ static void adduplicateflagNurb(
static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split);
static bool curve_delete_vertices(Object *obedit, View3D *v3d);
+/* -------------------------------------------------------------------- */
+/** \name Utility Functions
+ * \{ */
+
ListBase *object_editcurve_get(Object *ob)
{
if (ob && ELEM(ob->type, OB_CURVE, OB_SURF)) {
@@ -90,7 +94,11 @@ ListBase *object_editcurve_get(Object *ob)
return NULL;
}
-/* ******************* PRINTS ********************* */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Debug Printing
+ * \{ */
#if 0
void printknots(Object *obedit)
@@ -118,7 +126,11 @@ void printknots(Object *obedit)
}
#endif
-/* ********************* Shape keys *************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Shape keys
+ * \{ */
static CVKeyIndex *init_cvKeyIndex(
void *cv, int key_index, int nu_index, int pt_index, int vertex_index)
@@ -897,7 +909,11 @@ static void calc_shapeKeys(Object *obedit, ListBase *newnurbs)
}
}
-/* ********************* Amimation data *************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Animation Data
+ * \{ */
static bool curve_is_animated(Curve *cu)
{
@@ -1114,7 +1130,11 @@ int ED_curve_updateAnimPaths(Main *bmain, Curve *cu)
return 1;
}
-/* ********************* LOAD and MAKE *************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Edit Mode Conversion (Make & Load)
+ * \{ */
static int *initialize_index_map(Object *obedit, int *r_old_totvert)
{
@@ -1354,7 +1374,11 @@ void ED_curve_editnurb_free(Object *obedit)
BKE_curve_editNurb_free(cu);
}
-/******************** separate operator ***********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Separate Operator
+ * \{ */
static int separate_exec(bContext *C, wmOperator *op)
{
@@ -1495,7 +1519,11 @@ void CURVE_OT_separate(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/******************** split operator ***********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Split Operator
+ * \{ */
static int curve_split_exec(bContext *C, wmOperator *op)
{
@@ -1563,7 +1591,11 @@ void CURVE_OT_split(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* ******************* FLAGS ********************* */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Flag Utility Functions
+ * \{ */
static bool isNurbselUV(const Nurb *nu, int flag, int *r_u, int *r_v)
{
@@ -2532,7 +2564,11 @@ static void adduplicateflagNurb(
}
}
-/**************** switch direction operator ***************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Switch Direction Operator
+ * \{ */
static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -2591,7 +2627,11 @@ void CURVE_OT_switch_direction(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/****************** set weight operator *******************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Set Weight Operator
+ * \{ */
static int set_goal_weight_exec(bContext *C, wmOperator *op)
{
@@ -2654,7 +2694,11 @@ void CURVE_OT_spline_weight_set(wmOperatorType *ot)
RNA_def_float_factor(ot->srna, "weight", 1.0f, 0.0f, 1.0f, "Weight", "", 0.0f, 1.0f);
}
-/******************* set radius operator ******************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Set Radius Operator
+ * \{ */
static int set_radius_exec(bContext *C, wmOperator *op)
{
@@ -2718,7 +2762,11 @@ void CURVE_OT_radius_set(wmOperatorType *ot)
ot->srna, "radius", 1.0f, 0.0f, OBJECT_ADD_SIZE_MAXF, "Radius", "", 0.0001f, 10.0f);
}
-/********************* smooth operator ********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Smooth Vertices Operator
+ * \{ */
static void smooth_single_bezt(BezTriple *bezt,
const BezTriple *bezt_orig_prev,
@@ -2875,12 +2923,15 @@ void CURVE_OT_smooth(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+/** \} */
+
/* -------------------------------------------------------------------- */
-/* Smooth radius/weight/tilt
+/** \name Smooth Operator (Radius/Weight/Tilt) Utilities
*
- * TODO: make smoothing distance based
- * TODO: support cyclic curves
- */
+ * To do:
+ * - Make smoothing distance based.
+ * - Support cyclic curves.
+ * \{ */
static void curve_smooth_value(ListBase *editnurb, const int bezt_offsetof, const int bp_offset)
{
@@ -3059,6 +3110,12 @@ static void curve_smooth_value(ListBase *editnurb, const int bezt_offsetof, cons
}
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Smooth Weight Operator
+ * \{ */
+
static int curve_smooth_weight_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -3096,6 +3153,12 @@ void CURVE_OT_smooth_weight(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Smooth Radius Operator
+ * \{ */
+
static int curve_smooth_radius_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -3133,6 +3196,12 @@ void CURVE_OT_smooth_radius(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Smooth Tilt Operator
+ * \{ */
+
static int curve_smooth_tilt_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -3170,7 +3239,11 @@ void CURVE_OT_smooth_tilt(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/********************** hide operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Hide Operator
+ * \{ */
static int hide_exec(bContext *C, wmOperator *op)
{
@@ -3269,7 +3342,11 @@ void CURVE_OT_hide(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected");
}
-/********************** reveal operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Reveal Operator
+ * \{ */
static int reveal_exec(bContext *C, wmOperator *op)
{
@@ -3345,7 +3422,11 @@ void CURVE_OT_reveal(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "select", true, "Select", "");
}
-/********************** subdivide operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Subdivide Operator
+ * \{ */
/**
* Divide the line segments associated with the currently selected
@@ -3800,179 +3881,11 @@ void CURVE_OT_subdivide(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
-/******************** find nearest ************************/
-
-static void ED_curve_pick_vert__doClosest(
- void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2])
-{
- struct {
- BPoint *bp;
- BezTriple *bezt;
- Nurb *nurb;
- float dist;
- int hpoint, select;
- float mval_fl[2];
- bool is_changed;
- } *data = userData;
-
- short flag;
- float dist_test;
-
- if (bp) {
- flag = bp->f1;
- }
- else {
- if (beztindex == 0) {
- flag = bezt->f1;
- }
- else if (beztindex == 1) {
- flag = bezt->f2;
- }
- else {
- flag = bezt->f3;
- }
- }
-
- dist_test = len_manhattan_v2v2(data->mval_fl, screen_co);
- if ((flag & SELECT) == data->select) {
- dist_test += 5.0f;
- }
- if (bezt && beztindex == 1) {
- dist_test += 3.0f; /* middle points get a small disadvantage */
- }
-
- if (dist_test < data->dist) {
- data->dist = dist_test;
-
- data->bp = bp;
- data->bezt = bezt;
- data->nurb = nu;
- data->hpoint = bezt ? beztindex : 0;
- data->is_changed = true;
- }
-}
+/** \} */
-bool ED_curve_pick_vert(ViewContext *vc,
- short sel,
- Nurb **r_nurb,
- BezTriple **r_bezt,
- BPoint **r_bp,
- short *r_handle,
- Base **r_base)
-{
- /* (sel == 1): selected gets a disadvantage */
- /* in nurb and bezt or bp the nearest is written */
- /* return 0 1 2: handlepunt */
- struct {
- BPoint *bp;
- BezTriple *bezt;
- Nurb *nurb;
- float dist;
- int hpoint, select;
- float mval_fl[2];
- bool is_changed;
- } data = {NULL};
-
- data.dist = ED_view3d_select_dist_px();
- data.hpoint = 0;
- data.select = sel;
- data.mval_fl[0] = vc->mval[0];
- data.mval_fl[1] = vc->mval[1];
-
- uint bases_len;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(
- vc->view_layer, vc->v3d, &bases_len);
- for (uint base_index = 0; base_index < bases_len; base_index++) {
- Base *base = bases[base_index];
- data.is_changed = false;
-
- ED_view3d_viewcontext_init_object(vc, base->object);
- ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- nurbs_foreachScreenVert(vc, ED_curve_pick_vert__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
-
- if (r_base && data.is_changed) {
- *r_base = base;
- }
- }
- MEM_freeN(bases);
-
- *r_nurb = data.nurb;
- *r_bezt = data.bezt;
- *r_bp = data.bp;
-
- if (r_handle) {
- *r_handle = data.hpoint;
- }
-
- return (data.bezt || data.bp);
-}
-
-static void findselectedNurbvert(
- 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 */
- ListBase *editnurb = &cu->editnurb->nurbs;
- Nurb *nu1;
- BezTriple *bezt1;
- BPoint *bp1;
- int a;
-
- *r_nu = NULL;
- *r_bezt = NULL;
- *r_bp = NULL;
-
- for (nu1 = editnurb->first; nu1; nu1 = nu1->next) {
- if (nu1->type == CU_BEZIER) {
- bezt1 = nu1->bezt;
- a = nu1->pntsu;
- while (a--) {
- if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt1)) {
- if (*r_nu != NULL && *r_nu != nu1) {
- *r_nu = NULL;
- *r_bp = NULL;
- *r_bezt = NULL;
- return;
- }
- else if (*r_bezt || *r_bp) {
- *r_bp = NULL;
- *r_bezt = NULL;
- }
- else {
- *r_bezt = bezt1;
- *r_nu = nu1;
- }
- }
- bezt1++;
- }
- }
- else {
- bp1 = nu1->bp;
- a = nu1->pntsu * nu1->pntsv;
- while (a--) {
- if (bp1->f1 & SELECT) {
- if (*r_nu != NULL && *r_nu != nu1) {
- *r_bp = NULL;
- *r_bezt = NULL;
- *r_nu = NULL;
- return;
- }
- else if (*r_bezt || *r_bp) {
- *r_bp = NULL;
- *r_bezt = NULL;
- }
- else {
- *r_bp = bp1;
- *r_nu = nu1;
- }
- }
- bp1++;
- }
- }
- }
-}
-
-/***************** set spline type operator *******************/
+/* -------------------------------------------------------------------- */
+/** \name Set Spline Type Operator
+ * \{ */
static int set_spline_type_exec(bContext *C, wmOperator *op)
{
@@ -4069,7 +3982,11 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot)
"Use handles when converting bezier curves into polygons");
}
-/***************** set handle type operator *******************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Set Handle Type Operator
+ * \{ */
static int set_handle_type_exec(bContext *C, wmOperator *op)
{
@@ -4127,7 +4044,11 @@ void CURVE_OT_handle_type_set(wmOperatorType *ot)
ot->prop = RNA_def_enum(ot->srna, "type", editcurve_handle_type_items, 1, "Type", "Spline type");
}
-/***************** recalculate handles operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Recalculate Handles Operator
+ * \{ */
static int curve_normals_make_consistent_exec(bContext *C, wmOperator *op)
{
@@ -4175,9 +4096,13 @@ void CURVE_OT_normals_make_consistent(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "calc_length", false, "Length", "Recalculate handle length");
}
-/***************** make segment operator **********************/
+/** \} */
-/* ******************** SKINNING LOFTING!!! ******************** */
+/* -------------------------------------------------------------------- */
+/** \name Make Segment Operator
+ *
+ * Also handles skinning & lofting.
+ * \{ */
static void switchdirection_knots(float *base, int tot)
{
@@ -4271,10 +4196,7 @@ typedef struct NurbSort {
float vec[3];
} NurbSort;
-static ListBase nsortbase = {NULL, NULL};
-/* static NurbSort *nusmain; */ /* this var seems to go unused... at least in this file */
-
-static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb)
+static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb, ListBase *nsortbase)
{
ListBase nbase = {NULL, NULL};
NurbSort *nus, *nustest, *headdo, *taildo;
@@ -4303,7 +4225,7 @@ static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb)
/* just add the first one */
nus = nbase.first;
BLI_remlink(&nbase, nus);
- BLI_addtail(&nsortbase, nus);
+ BLI_addtail(nsortbase, nus);
/* now add, either at head or tail, the closest one */
while (nbase.first) {
@@ -4313,13 +4235,13 @@ static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb)
nustest = nbase.first;
while (nustest) {
- dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase.first)->vec);
+ dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase->first)->vec);
if (dist < headdist) {
headdist = dist;
headdo = nustest;
}
- dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase.last)->vec);
+ dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase->last)->vec);
if (dist < taildist) {
taildist = dist;
@@ -4330,11 +4252,11 @@ static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb)
if (headdist < taildist) {
BLI_remlink(&nbase, headdo);
- BLI_addhead(&nsortbase, headdo);
+ BLI_addhead(nsortbase, headdo);
}
else {
BLI_remlink(&nbase, taildo);
- BLI_addtail(&nsortbase, taildo);
+ BLI_addtail(nsortbase, taildo);
}
}
}
@@ -4511,8 +4433,9 @@ static int merge_nurb(View3D *v3d, Object *obedit)
ListBase *editnurb = object_editcurve_get(obedit);
NurbSort *nus1, *nus2;
bool ok = true;
+ ListBase nsortbase = {NULL, NULL};
- make_selection_list_nurb(v3d, editnurb);
+ make_selection_list_nurb(v3d, editnurb, &nsortbase);
if (nsortbase.first == nsortbase.last) {
BLI_freelistN(&nsortbase);
@@ -4877,7 +4800,11 @@ void CURVE_OT_make_segment(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/***************** pick select from 3d view **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Pick Select from 3D View
+ * \{ */
bool ED_curve_editnurb_select_pick(
bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
@@ -5033,7 +4960,11 @@ bool ED_curve_editnurb_select_pick(
return false;
}
-/******************** spin operator ***********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Spin Operator
+ * \{ */
/* 'cent' is in object space and 'dvec' in worldspace.
*/
@@ -5213,13 +5144,14 @@ void CURVE_OT_spin(wmOperatorType *ot)
ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f);
}
-/***************** extrude vertex operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Extrude Vertex Operator
+ * \{ */
static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d)
{
- Nurb *nu = NULL;
- Nurb *nu_last = NULL;
-
bool changed = false;
Nurb *cu_actnu;
@@ -5234,216 +5166,183 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d)
}
BKE_curve_nurb_vert_active_get(cu, &cu_actnu, &cu_actvert.p);
- BKE_curve_nurb_vert_active_set(cu, NULL, NULL);
-
- /* first pass (endpoints) */
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
-
- if ((nu->flagu & CU_NURB_CYCLIC) && (nu->pntsu > 1)) {
- continue;
- }
+ int act_offset = 0;
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
+ BLI_assert(nu->pntsu > 0);
+ int i;
+ int pnt_len = nu->pntsu;
+ int new_points = 0;
+ int offset = 0;
+ bool is_prev_selected = false;
if (nu->type == CU_BEZIER) {
-
- /* Check to see if the first bezier point is selected */
- if (nu->pntsu > 0 && nu->bezt != NULL) {
- BezTriple *nu_bezt_old = nu->bezt;
- BezTriple *bezt = nu->bezt;
-
- if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
- BezTriple *bezt_new;
- BEZT_DESEL_ALL(bezt);
-
- bezt_new = MEM_mallocN((nu->pntsu + 1) * sizeof(BezTriple), __func__);
- ED_curve_beztcpy(editnurb, bezt_new + 1, bezt, nu->pntsu);
- *bezt_new = *bezt;
-
- MEM_freeN(nu->bezt);
- nu->bezt = bezt_new;
-
- nu->pntsu += 1;
-
- if (ARRAY_HAS_ITEM(cu_actvert.bezt, nu_bezt_old, nu->pntsu - 1)) {
- cu_actvert.bezt = (cu_actvert.bezt == bezt) ?
- bezt_new :
- &nu->bezt[(cu_actvert.bezt - nu_bezt_old) + 1];
- BKE_curve_nurb_vert_active_set(cu, nu, cu_actvert.bezt);
- }
-
- BEZT_SEL_ALL(bezt_new);
- changed = true;
+ BezTriple *bezt, *bezt_prev = NULL;
+ bool is_cyclic = false;
+ if (pnt_len == 1) {
+ /* Single point extrusion.
+ * Keep `is_prev_selected` false to force extrude. */
+ bezt_prev = &nu->bezt[0];
+ }
+ else if (nu->flagu & CU_NURB_CYCLIC) {
+ is_cyclic = true;
+ bezt_prev = &nu->bezt[pnt_len - 1];
+ is_prev_selected = BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt_prev);
+ }
+ i = pnt_len;
+ for (bezt = &nu->bezt[0]; i--; bezt++) {
+ bool is_selected = BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt);
+ if (bezt_prev && is_prev_selected != is_selected) {
+ new_points++;
+ }
+ if (bezt == cu_actvert.bezt) {
+ act_offset = new_points;
+ }
+ bezt_prev = bezt;
+ is_prev_selected = is_selected;
+ }
+
+ if (new_points) {
+ if (pnt_len == 1) {
+ /* Single point extrusion.
+ * Set `is_prev_selected` as false to force extrude. */
+ BLI_assert(bezt_prev == &nu->bezt[0]);
+ is_prev_selected = false;
+ }
+ else if (is_cyclic) {
+ BLI_assert(bezt_prev == &nu->bezt[pnt_len - 1]);
+ BLI_assert(is_prev_selected == BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt_prev));
}
- }
-
- /* Check to see if the last bezier point is selected */
- if (nu->pntsu > 1) {
- BezTriple *nu_bezt_old = nu->bezt;
- BezTriple *bezt = &nu->bezt[nu->pntsu - 1];
-
- if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
- BezTriple *bezt_new;
- BEZT_DESEL_ALL(bezt);
-
- bezt_new = MEM_mallocN((nu->pntsu + 1) * sizeof(BezTriple), __func__);
- ED_curve_beztcpy(editnurb, bezt_new, nu->bezt, nu->pntsu);
- bezt_new[nu->pntsu] = *bezt;
-
- MEM_freeN(nu->bezt);
- nu->bezt = bezt_new;
-
- bezt_new += nu->pntsu;
- nu->pntsu += 1;
+ else {
+ bezt_prev = NULL;
+ }
+ BezTriple *bezt_src, *bezt_dst, *bezt_src_iter, *bezt_dst_iter;
+ bezt_src = nu->bezt;
+ bezt_dst = MEM_mallocN((pnt_len + new_points) * sizeof(BezTriple), __func__);
+ bezt_src_iter = &bezt_src[0];
+ bezt_dst_iter = &bezt_dst[0];
+ i = 0;
+ for (bezt = &nu->bezt[0]; i < pnt_len; i++, bezt++) {
+ bool is_selected = BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt);
+ /* While this gets de-selected, selecting here ensures newly created verts are selected.
+ * without this, the vertices are copied but only the handles are transformed.
+ * which seems buggy from a user perspective. */
+ if (is_selected) {
+ bezt->f2 |= SELECT;
+ }
+ if (bezt_prev && is_prev_selected != is_selected) {
+ int count = i - offset + 1;
+ if (is_prev_selected) {
+ ED_curve_beztcpy(editnurb, bezt_dst_iter, bezt_src_iter, count - 1);
+ ED_curve_beztcpy(editnurb, &bezt_dst_iter[count - 1], bezt_prev, 1);
+ }
+ else {
+ ED_curve_beztcpy(editnurb, bezt_dst_iter, bezt_src_iter, count);
+ }
+ ED_curve_beztcpy(editnurb, &bezt_dst_iter[count], bezt, 1);
+ BEZT_DESEL_ALL(&bezt_dst_iter[count - 1]);
- if (ARRAY_HAS_ITEM(cu_actvert.bezt, nu_bezt_old, nu->pntsu - 1)) {
- cu_actvert.bezt = (cu_actvert.bezt == bezt) ? bezt_new :
- &nu->bezt[cu_actvert.bezt - nu_bezt_old];
- BKE_curve_nurb_vert_active_set(cu, nu, cu_actvert.bezt);
+ bezt_dst_iter += count + 1;
+ bezt_src_iter += count;
+ offset = i + 1;
}
+ bezt_prev = bezt;
+ is_prev_selected = is_selected;
+ }
- BEZT_SEL_ALL(bezt_new);
- changed = true;
+ int remain = pnt_len - offset;
+ if (remain) {
+ ED_curve_beztcpy(editnurb, bezt_dst_iter, bezt_src_iter, pnt_len - offset);
}
+
+ MEM_freeN(nu->bezt);
+ nu->bezt = bezt_dst;
+ nu->pntsu += new_points;
+ changed = true;
}
}
else {
-
- /* Check to see if the first bpoint is selected */
- if (nu->pntsu > 0 && nu->bp != NULL) {
- BPoint *nu_bp_old = nu->bp;
- BPoint *bp = nu->bp;
-
- if (bp->f1 & SELECT) {
- BPoint *bp_new;
- bp->f1 &= ~SELECT;
-
- bp_new = MEM_mallocN((nu->pntsu + 1) * sizeof(BPoint), __func__);
- ED_curve_bpcpy(editnurb, bp_new + 1, bp, nu->pntsu);
- *bp_new = *bp;
-
- MEM_freeN(nu->bp);
- nu->bp = bp_new;
-
- nu->pntsu += 1;
- BKE_nurb_knot_calc_u(nu);
-
- if (ARRAY_HAS_ITEM(cu_actvert.bp, nu_bp_old, nu->pntsu - 1)) {
- cu_actvert.bp = (cu_actvert.bp == bp) ? bp_new :
- &nu->bp[(cu_actvert.bp - nu_bp_old) + 1];
- BKE_curve_nurb_vert_active_set(cu, nu, cu_actvert.bp);
- }
-
- bp_new->f1 |= SELECT;
- changed = true;
- }
+ BPoint *bp, *bp_prev = NULL;
+ if (pnt_len == 1) {
+ /* Single point extrusion.
+ * Reference a `prev_bp` to force extrude. */
+ bp_prev = &nu->bp[0];
}
-
- /* Check to see if the last bpoint is selected */
- if (nu->pntsu > 1) {
- BPoint *nu_bp_old = nu->bp;
- BPoint *bp = &nu->bp[nu->pntsu - 1];
-
- if (bp->f1 & SELECT) {
- BPoint *bp_new;
- bp->f1 &= ~SELECT;
-
- bp_new = MEM_mallocN((nu->pntsu + 1) * sizeof(BPoint), __func__);
- ED_curve_bpcpy(editnurb, bp_new, nu->bp, nu->pntsu);
- bp_new[nu->pntsu] = *bp;
-
- MEM_freeN(nu->bp);
- nu->bp = bp_new;
-
- bp_new += nu->pntsu;
- nu->pntsu += 1;
-
- if (ARRAY_HAS_ITEM(cu_actvert.bp, nu_bp_old, nu->pntsu - 1)) {
- cu_actvert.bp = (cu_actvert.bp == bp) ? bp_new : &nu->bp[cu_actvert.bp - nu_bp_old];
- BKE_curve_nurb_vert_active_set(cu, nu, cu_actvert.bp);
- }
-
- BKE_nurb_knot_calc_u(nu);
-
- bp_new->f1 |= SELECT;
- changed = true;
+ i = pnt_len;
+ for (bp = &nu->bp[0]; i--; bp++) {
+ bool is_selected = (bp->f1 & SELECT) != 0;
+ if (bp_prev && is_prev_selected != is_selected) {
+ new_points++;
}
+ if (bp == cu_actvert.bp) {
+ act_offset = new_points;
+ }
+ bp_prev = bp;
+ is_prev_selected = is_selected;
}
- }
- }
-
- /* second pass (interior points) */
- nu_last = editnurb->nurbs.last;
- for (nu = editnurb->nurbs.first; (nu != nu_last->next); nu = nu->next) {
- int i, i_end;
-
- if ((nu->flagu & CU_NURB_CYCLIC) && (nu->pntsu > 1)) {
- /* all points are interior */
- i = 0;
- i_end = nu->pntsu;
- }
- else {
- /* skip endpoints */
- i = 1;
- i_end = nu->pntsu - 1;
- }
-
- if (nu->type == CU_BEZIER) {
- BezTriple *bezt;
-
- for (bezt = &nu->bezt[i]; i < i_end; i++, bezt++) {
- if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
- Nurb *nurb_new;
- BezTriple *bezt_new;
- BEZT_DESEL_ALL(bezt);
- nurb_new = BKE_nurb_copy(nu, 1, 1);
- nurb_new->flagu &= ~CU_NURB_CYCLIC;
- BLI_addtail(&editnurb->nurbs, nurb_new);
- bezt_new = nurb_new->bezt;
- ED_curve_beztcpy(editnurb, bezt_new, bezt, 1);
- BEZT_SEL_ALL(bezt_new);
+ if (new_points) {
+ BPoint *bp_src, *bp_dst, *bp_src_iter, *bp_dst_iter;
+ is_prev_selected = false;
+ if (pnt_len == 1) {
+ /* Single point extrusion.
+ * Keep `is_prev_selected` false to force extrude. */
+ BLI_assert(bp_prev == &nu->bp[0]);
+ }
+ else {
+ bp_prev = NULL;
+ }
+ bp_src = nu->bp;
+ bp_dst = MEM_mallocN((pnt_len + new_points) * sizeof(BPoint), __func__);
+ bp_src_iter = &bp_src[0];
+ bp_dst_iter = &bp_dst[0];
+ i = 0;
+ for (bp = &nu->bp[0]; i < pnt_len; i++, bp++) {
+ bool is_selected = (bp->f1 & SELECT) != 0;
+ if (bp_prev && is_prev_selected != is_selected) {
+ int count = i - offset + 1;
+ if (is_prev_selected) {
+ ED_curve_bpcpy(editnurb, bp_dst_iter, bp_src_iter, count - 1);
+ ED_curve_bpcpy(editnurb, &bp_dst_iter[count - 1], bp_prev, 1);
+ }
+ else {
+ ED_curve_bpcpy(editnurb, bp_dst_iter, bp_src_iter, count);
+ }
+ ED_curve_bpcpy(editnurb, &bp_dst_iter[count], bp, 1);
+ bp_dst_iter[count - 1].f1 &= ~SELECT;
- if (cu_actvert.bezt == bezt || cu_actnu == NULL) {
- BKE_curve_nurb_vert_active_set(cu, nurb_new, bezt_new);
+ bp_dst_iter += count + 1;
+ bp_src_iter += count;
+ offset = i + 1;
}
-
- changed = true;
+ bp_prev = bp;
+ is_prev_selected = is_selected;
}
- }
- }
- else {
- BPoint *bp;
- for (bp = &nu->bp[i]; i < i_end; i++, bp++) {
- if (bp->f1 & SELECT) {
- Nurb *nurb_new;
- BPoint *bp_new;
-
- bp->f1 &= ~SELECT;
- nurb_new = BKE_nurb_copy(nu, 1, 1);
- nurb_new->flagu &= ~CU_NURB_CYCLIC;
- BLI_addtail(&editnurb->nurbs, nurb_new);
- bp_new = nurb_new->bp;
- ED_curve_bpcpy(editnurb, bp_new, bp, 1);
- bp_new->f1 |= SELECT;
+ int remain = pnt_len - offset;
+ if (remain) {
+ ED_curve_bpcpy(editnurb, bp_dst_iter, bp_src_iter, pnt_len - offset);
+ }
- if (cu_actvert.bp == bp || cu_actnu == NULL) {
- BKE_curve_nurb_vert_active_set(cu, nurb_new, bp_new);
- }
+ MEM_freeN(nu->bp);
+ nu->bp = bp_dst;
+ nu->pntsu += new_points;
- changed = true;
- }
+ BKE_nurb_knot_calc_u(nu);
+ changed = true;
}
}
}
- if (changed == false) {
- BKE_curve_nurb_vert_active_set(cu, cu_actnu, cu_actvert.p);
- }
+ cu->actvert += act_offset;
return changed;
}
-/***************** add vertex operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Add Vertex Operator
+ * \{ */
static int ed_editcurve_addvert(Curve *cu,
EditNurb *editnurb,
@@ -5659,7 +5558,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
cu = vc.obedit->data;
- findselectedNurbvert(cu, vc.v3d, &nu, &bezt, &bp);
+ ED_curve_nurb_vert_selected_find(cu, vc.v3d, &nu, &bezt, &bp);
if (bezt) {
mul_v3_m4v3(location, vc.obedit->obmat, bezt->vec[1]);
@@ -5760,7 +5659,11 @@ void CURVE_OT_vertex_add(wmOperatorType *ot)
1.0e4f);
}
-/***************** extrude operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Extrude Operator
+ * \{ */
static int curve_extrude_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -5831,7 +5734,11 @@ void CURVE_OT_extrude(wmOperatorType *ot)
RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", "");
}
-/***************** make cyclic operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Make Cyclic Operator
+ * \{ */
static bool curve_toggle_cyclic(View3D *v3d, ListBase *editnurb, int direction)
{
@@ -5997,7 +5904,11 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot)
"Direction to make surface cyclic in");
}
-/********************** add duplicate operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Add Duplicate Operator
+ * \{ */
static int duplicate_exec(bContext *C, wmOperator *op)
{
@@ -6053,7 +5964,11 @@ void CURVE_OT_duplicate(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/********************** delete operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Delete Operator
+ * \{ */
static bool curve_delete_vertices(Object *obedit, View3D *v3d)
{
@@ -6599,6 +6514,12 @@ void CURVE_OT_delete(wmOperatorType *ot)
ot->prop = prop;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Dissolve Vertices
+ * \{ */
+
static bool test_bezt_is_sel_any(const void *bezt_v, void *user_data)
{
View3D *v3d = user_data;
@@ -6628,8 +6549,8 @@ static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op))
for (nu = editnurb->first; nu; nu = nu->next) {
if ((nu->type == CU_BEZIER) && (nu->pntsu > 2)) {
- unsigned int span_step[2] = {nu->pntsu, nu->pntsu};
- unsigned int span_len;
+ uint span_step[2] = {nu->pntsu, nu->pntsu};
+ uint span_len;
while (BLI_array_iter_span(nu->bezt,
nu->pntsu,
@@ -6643,9 +6564,9 @@ static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op))
BezTriple *bezt_next = &nu->bezt[mod_i(span_step[1] + 1, nu->pntsu)];
int i_span_edge_len = span_len + 1;
- const unsigned int dims = 3;
+ const uint dims = 3;
- const unsigned int points_len = ((cu->resolu - 1) * i_span_edge_len) + 1;
+ const uint points_len = ((cu->resolu - 1) * i_span_edge_len) + 1;
float *points = MEM_mallocN(points_len * dims * sizeof(float), __func__);
float *points_stride = points;
const int points_stride_len = (cu->resolu - 1);
@@ -6670,7 +6591,7 @@ static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op))
BLI_assert(points_stride + dims == points + (points_len * dims));
float tan_l[3], tan_r[3], error_sq_dummy;
- unsigned int error_index_dummy;
+ uint error_index_dummy;
sub_v3_v3v3(tan_l, bezt_prev->vec[1], bezt_prev->vec[2]);
normalize_v3(tan_l);
@@ -6731,6 +6652,12 @@ void CURVE_OT_dissolve_verts(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Decimate Operator
+ * \{ */
+
static bool nurb_bezt_flag_any(const Nurb *nu, const char flag_test)
{
BezTriple *bezt = nu->bezt;
@@ -6824,7 +6751,11 @@ void CURVE_OT_decimate(wmOperatorType *ot)
RNA_def_float_factor(ot->srna, "ratio", 1.0f, 0.0f, 1.0f, "Ratio", "", 0.0f, 1.0f);
}
-/********************** shade smooth/flat operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Shade Smooth/Flat Operator
+ * \{ */
static int shade_smooth_exec(bContext *C, wmOperator *op)
{
@@ -6844,7 +6775,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
continue;
}
- for (Nurb *nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (ED_curve_nurb_select_check(v3d, nu)) {
if (!clear) {
nu->flag |= CU_SMOOTH;
@@ -6895,8 +6826,16 @@ void CURVE_OT_shade_flat(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/************** join operator, to be used externally? ****************/
-/* TODO: shape keys - as with meshes */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Join Operator
+ * \{ */
+
+/**
+ * This is used externally, by #OBJECT_OT_join.
+ * TODO: shape keys - as with meshes.
+ */
int join_curve_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@@ -6996,7 +6935,11 @@ int join_curve_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-/***************** clear tilt operator ********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Clear Tilt Operator
+ * \{ */
static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -7077,28 +7020,11 @@ void ED_curve_bpcpy(EditNurb *editnurb, BPoint *dst, BPoint *src, int count)
keyIndex_updateBP(editnurb, src, dst, count);
}
-bool ED_curve_active_center(Curve *cu, float center[3])
-{
- Nurb *nu = NULL;
- void *vert = NULL;
-
- if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert)) {
- return false;
- }
+/** \} */
- if (nu->type == CU_BEZIER) {
- BezTriple *bezt = (BezTriple *)vert;
- copy_v3_v3(center, bezt->vec[1]);
- }
- else {
- BPoint *bp = (BPoint *)vert;
- copy_v3_v3(center, bp->vec);
- }
-
- return true;
-}
-
-/******************** Match texture space operator ***********************/
+/* -------------------------------------------------------------------- */
+/** \name Match Texture Space Operator
+ * \{ */
static bool match_texture_space_poll(bContext *C)
{
@@ -7168,3 +7094,5 @@ void CURVE_OT_match_texture_space(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+
+/** \} */
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index d028a88e322..748bf040fbb 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -205,7 +205,7 @@ static bool stroke_elem_project(const struct CurveDrawData *cdd,
}
else {
const ViewDepths *depths = rv3d->depths;
- if (depths && ((unsigned int)mval_i[0] < depths->w) && ((unsigned int)mval_i[1] < depths->h)) {
+ if (depths && ((uint)mval_i[0] < depths->w) && ((uint)mval_i[1] < depths->h)) {
const double depth = (double)ED_view3d_depth_read_cached(&cdd->vc, mval_i);
if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) {
if (ED_view3d_depth_unproject(region, mval_i, depth, r_location_world)) {
@@ -798,7 +798,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
float *coords = MEM_mallocN(sizeof(*coords) * stroke_len * dims, __func__);
float *cubic_spline = NULL;
- unsigned int cubic_spline_len = 0;
+ uint cubic_spline_len = 0;
/* error in object local space */
const int fit_method = RNA_enum_get(op->ptr, "fit_method");
@@ -827,14 +827,14 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
}
}
- unsigned int *corners = NULL;
- unsigned int corners_len = 0;
+ uint *corners = NULL;
+ uint corners_len = 0;
if ((fit_method == CURVE_PAINT_FIT_METHOD_SPLIT) && (corner_angle < (float)M_PI)) {
/* this could be configurable... */
const float corner_radius_min = error_threshold / 8;
const float corner_radius_max = error_threshold * 2;
- const unsigned int samples_max = 16;
+ const uint samples_max = 16;
curve_fit_corners_detect_fl(coords,
stroke_len,
@@ -847,9 +847,9 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
&corners_len);
}
- unsigned int *corners_index = NULL;
- unsigned int corners_index_len = 0;
- unsigned int calc_flag = CURVE_FIT_CALC_HIGH_QUALIY;
+ uint *corners_index = NULL;
+ uint corners_index_len = 0;
+ uint calc_flag = CURVE_FIT_CALC_HIGH_QUALIY;
if ((stroke_len > 2) && use_cyclic) {
calc_flag |= CURVE_FIT_CALC_CYCLIC;
@@ -919,14 +919,14 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
if (corners_index) {
/* ignore the first and last */
- unsigned int i_start = 0, i_end = corners_index_len;
+ uint i_start = 0, i_end = corners_index_len;
if ((corners_index_len >= 2) && (calc_flag & CURVE_FIT_CALC_CYCLIC) == 0) {
i_start += 1;
i_end -= 1;
}
- for (unsigned int i = i_start; i < i_end; i++) {
+ for (uint i = i_start; i < i_end; i++) {
bezt = &nu->bezt[corners_index[i]];
bezt->h1 = bezt->h2 = HD_FREE;
}
diff --git a/source/blender/editors/curve/editcurve_query.c b/source/blender/editors/curve/editcurve_query.c
new file mode 100644
index 00000000000..0b15d9e55b9
--- /dev/null
+++ b/source/blender/editors/curve/editcurve_query.c
@@ -0,0 +1,244 @@
+/*
+ * 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 edcurve
+ */
+
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+
+#include "BKE_curve.h"
+#include "BKE_fcurve.h"
+#include "BKE_layer.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+
+#include "ED_curve.h"
+#include "ED_view3d.h"
+
+#include "curve_intern.h"
+
+/* -------------------------------------------------------------------- */
+/** \name Cursor Picking API
+ * \{ */
+
+static void ED_curve_pick_vert__do_closest(
+ void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2])
+{
+ struct {
+ BPoint *bp;
+ BezTriple *bezt;
+ Nurb *nurb;
+ float dist;
+ int hpoint, select;
+ float mval_fl[2];
+ bool is_changed;
+ } *data = userData;
+
+ short flag;
+ float dist_test;
+
+ if (bp) {
+ flag = bp->f1;
+ }
+ else {
+ if (beztindex == 0) {
+ flag = bezt->f1;
+ }
+ else if (beztindex == 1) {
+ flag = bezt->f2;
+ }
+ else {
+ flag = bezt->f3;
+ }
+ }
+
+ dist_test = len_manhattan_v2v2(data->mval_fl, screen_co);
+ if ((flag & SELECT) == data->select) {
+ dist_test += 5.0f;
+ }
+ if (bezt && beztindex == 1) {
+ dist_test += 3.0f; /* middle points get a small disadvantage */
+ }
+
+ if (dist_test < data->dist) {
+ data->dist = dist_test;
+
+ data->bp = bp;
+ data->bezt = bezt;
+ data->nurb = nu;
+ data->hpoint = bezt ? beztindex : 0;
+ data->is_changed = true;
+ }
+}
+
+bool ED_curve_pick_vert(ViewContext *vc,
+ short sel,
+ Nurb **r_nurb,
+ BezTriple **r_bezt,
+ BPoint **r_bp,
+ short *r_handle,
+ Base **r_base)
+{
+ /* (sel == 1): selected gets a disadvantage */
+ /* in nurb and bezt or bp the nearest is written */
+ /* return 0 1 2: handlepunt */
+ struct {
+ BPoint *bp;
+ BezTriple *bezt;
+ Nurb *nurb;
+ float dist;
+ int hpoint, select;
+ float mval_fl[2];
+ bool is_changed;
+ } data = {NULL};
+
+ data.dist = ED_view3d_select_dist_px();
+ data.hpoint = 0;
+ data.select = sel;
+ data.mval_fl[0] = vc->mval[0];
+ data.mval_fl[1] = vc->mval[1];
+
+ uint bases_len;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(
+ vc->view_layer, vc->v3d, &bases_len);
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Base *base = bases[base_index];
+ data.is_changed = false;
+
+ ED_view3d_viewcontext_init_object(vc, base->object);
+ ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
+ nurbs_foreachScreenVert(vc, ED_curve_pick_vert__do_closest, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+
+ if (r_base && data.is_changed) {
+ *r_base = base;
+ }
+ }
+ MEM_freeN(bases);
+
+ *r_nurb = data.nurb;
+ *r_bezt = data.bezt;
+ *r_bp = data.bp;
+
+ if (r_handle) {
+ *r_handle = data.hpoint;
+ }
+
+ return (data.bezt || data.bp);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Selection Queries
+ * \{ */
+
+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 */
+ ListBase *editnurb = &cu->editnurb->nurbs;
+ Nurb *nu1;
+ BezTriple *bezt1;
+ BPoint *bp1;
+ int a;
+
+ *r_nu = NULL;
+ *r_bezt = NULL;
+ *r_bp = NULL;
+
+ for (nu1 = editnurb->first; nu1; nu1 = nu1->next) {
+ if (nu1->type == CU_BEZIER) {
+ bezt1 = nu1->bezt;
+ a = nu1->pntsu;
+ while (a--) {
+ if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt1)) {
+ if (*r_nu != NULL && *r_nu != nu1) {
+ *r_nu = NULL;
+ *r_bp = NULL;
+ *r_bezt = NULL;
+ return;
+ }
+ else if (*r_bezt || *r_bp) {
+ *r_bp = NULL;
+ *r_bezt = NULL;
+ }
+ else {
+ *r_bezt = bezt1;
+ *r_nu = nu1;
+ }
+ }
+ bezt1++;
+ }
+ }
+ else {
+ bp1 = nu1->bp;
+ a = nu1->pntsu * nu1->pntsv;
+ while (a--) {
+ if (bp1->f1 & SELECT) {
+ if (*r_nu != NULL && *r_nu != nu1) {
+ *r_bp = NULL;
+ *r_bezt = NULL;
+ *r_nu = NULL;
+ return;
+ }
+ else if (*r_bezt || *r_bp) {
+ *r_bp = NULL;
+ *r_bezt = NULL;
+ }
+ else {
+ *r_bp = bp1;
+ *r_nu = nu1;
+ }
+ }
+ bp1++;
+ }
+ }
+ }
+}
+
+bool ED_curve_active_center(Curve *cu, float center[3])
+{
+ Nurb *nu = NULL;
+ void *vert = NULL;
+
+ if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert)) {
+ return false;
+ }
+
+ if (nu->type == CU_BEZIER) {
+ BezTriple *bezt = (BezTriple *)vert;
+ copy_v3_v3(center, bezt->vec[1]);
+ }
+ else {
+ BPoint *bp = (BPoint *)vert;
+ copy_v3_v3(center, bp->vec);
+ }
+
+ return true;
+}
+
+/** \} */
diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c
index 51bb1eafdb9..9cf61d02677 100644
--- a/source/blender/editors/curve/editcurve_select.c
+++ b/source/blender/editors/curve/editcurve_select.c
@@ -29,6 +29,7 @@
#include "BLI_bitmap.h"
#include "BLI_heap_simple.h"
#include "BLI_kdtree.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_rand.h"
@@ -198,7 +199,7 @@ bool ED_curve_nurb_select_all(const Nurb *nu)
bool ED_curve_select_all(EditNurb *editnurb)
{
bool changed = false;
- for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
changed |= ED_curve_nurb_select_all(nu);
}
return changed;
@@ -257,7 +258,7 @@ bool ED_curve_select_check(View3D *v3d, struct EditNurb *editnurb)
bool ED_curve_deselect_all(EditNurb *editnurb)
{
bool changed = false;
- for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
changed |= ED_curve_nurb_deselect_all(nu);
}
return changed;
@@ -1825,7 +1826,7 @@ static float curve_calc_dist_span(Nurb *nu, int vert_src, int vert_dst)
int i_prev, i;
float dist = 0.0f;
- BLI_assert(nu->pntsv == 1);
+ BLI_assert(nu->pntsv <= 1);
i_prev = vert_src;
i = (i_prev + 1) % u;
diff --git a/source/blender/editors/curve/editcurve_undo.c b/source/blender/editors/curve/editcurve_undo.c
index 94a0ef7a460..af492de638b 100644
--- a/source/blender/editors/curve/editcurve_undo.c
+++ b/source/blender/editors/curve/editcurve_undo.c
@@ -30,7 +30,7 @@
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_fcurve.h"
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index 297af4cb72d..dc5dc71106f 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -76,7 +76,7 @@ static int kill_selection(Object *obedit, int ins);
/** \name Internal Utilities
* \{ */
-static wchar_t findaccent(wchar_t char1, unsigned int code)
+static wchar_t findaccent(wchar_t char1, uint code)
{
wchar_t new = 0;
diff --git a/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c b/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c
index 90196988d94..668b59ac191 100644
--- a/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c
+++ b/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c
@@ -55,7 +55,7 @@ static float normals[][3] = {
{0.000000, 0.000000, 1.000000},
};
-static unsigned short indices[] = {
+static ushort indices[] = {
1, 3, 2, 3, 5, 4, 5, 7, 6, 7, 9, 8, 9, 11, 10, 11, 13, 12, 5, 18, 19, 15, 1,
0, 13, 15, 14, 6, 10, 14, 11, 21, 22, 7, 19, 20, 13, 22, 23, 3, 17, 18, 9, 20, 21, 15,
23, 16, 1, 16, 17, 23, 22, 24, 21, 20, 24, 19, 18, 24, 17, 16, 24, 16, 23, 24, 22, 21, 24,
diff --git a/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c b/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c
index ea1a3147148..51618e353f4 100644
--- a/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c
+++ b/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c
@@ -45,7 +45,7 @@ static const float normals[][3] = {
{-0.577349, 0.577349, 0.577349},
};
-static const unsigned short indices[] = {
+static const ushort indices[] = {
1, 2, 3, 7, 6, 5, 4, 5, 1, 5, 6, 2, 2, 6, 7, 0, 3, 7,
0, 1, 3, 4, 7, 5, 0, 4, 1, 1, 5, 2, 3, 2, 7, 4, 0, 7,
};
diff --git a/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c b/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c
index 273f957e9b6..7e37c233c2a 100644
--- a/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c
+++ b/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c
@@ -221,7 +221,7 @@ static const float normals[][3] = {
{-0.466689, 0.092807, -0.879513}, {0.512650, -0.101962, -0.852504},
};
-static const unsigned short indices[] = {
+static const ushort indices[] = {
6, 7, 1, 7, 8, 2, 8, 9, 3, 9, 10, 4, 10, 11, 5, 5, 11, 6, 12,
13, 7, 13, 14, 8, 14, 15, 9, 15, 16, 10, 16, 17, 11, 11, 17, 12, 18, 19,
13, 13, 19, 20, 20, 21, 15, 15, 21, 22, 22, 23, 17, 17, 23, 18, 24, 25, 19,
diff --git a/source/blender/editors/gizmo_library/gizmo_draw_utils.c b/source/blender/editors/gizmo_library/gizmo_draw_utils.c
index cffafc56693..01e5a7eacfd 100644
--- a/source/blender/editors/gizmo_library/gizmo_draw_utils.c
+++ b/source/blender/editors/gizmo_library/gizmo_draw_utils.c
@@ -66,7 +66,7 @@ void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info,
/* Elements */
GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, info->ntris, info->nverts);
for (int i = 0; i < info->ntris; i++) {
- const unsigned short *idx = &info->indices[i * 3];
+ const ushort *idx = &info->indices[i * 3];
GPU_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]);
}
el = GPU_indexbuf_build(&elb);
diff --git a/source/blender/editors/gizmo_library/gizmo_geometry.h b/source/blender/editors/gizmo_library/gizmo_geometry.h
index ae8ba3c411b..a5f61158f66 100644
--- a/source/blender/editors/gizmo_library/gizmo_geometry.h
+++ b/source/blender/editors/gizmo_library/gizmo_geometry.h
@@ -30,12 +30,14 @@
#ifndef __GIZMO_GEOMETRY_H__
#define __GIZMO_GEOMETRY_H__
+#include "BLI_sys_types.h"
+
typedef struct GizmoGeomInfo {
int nverts;
int ntris;
const float (*verts)[3];
const float (*normals)[3];
- const unsigned short *indices;
+ const ushort *indices;
} GizmoGeomInfo;
/* arrow gizmo */
diff --git a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
index 4049a3b9dcb..39e0712a511 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
@@ -372,9 +372,9 @@ static int gizmo_move_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
WM_gizmo_calc_matrix_final(gz, inter->init.matrix_final);
if (use_snap) {
- ScrArea *sa = CTX_wm_area(C);
- if (sa) {
- switch (sa->spacetype) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area) {
+ switch (area->spacetype) {
case SPACE_VIEW3D: {
inter->snap_context_v3d = ED_transform_snap_object_context_create_view3d(
CTX_data_main(C), CTX_data_scene(C), 0, CTX_wm_region(C), CTX_wm_view3d(C));
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index fc62defd757..26ba2661072 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -353,7 +353,7 @@ static void annotation_draw_stroke_2d(const bGPDspoint *points,
/* Tessellation code - draw stroke as series of connected quads
* (triangle strips in fact) with connection edges rotated to minimize shrinking artifacts,
- * and rounded endcaps.
+ * and rounded end-caps.
*/
{
const bGPDspoint *pt1, *pt2;
@@ -1013,7 +1013,7 @@ static void annotation_draw_data_all(Scene *scene,
void ED_annotation_draw_2dimage(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
@@ -1026,7 +1026,7 @@ void ED_annotation_draw_2dimage(const bContext *C)
}
/* calculate rect */
- switch (sa->spacetype) {
+ switch (area->spacetype) {
case SPACE_IMAGE: /* image */
case SPACE_CLIP: /* clip */
{
@@ -1075,7 +1075,7 @@ void ED_annotation_draw_2dimage(const bContext *C)
}
/* draw it! */
- annotation_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype);
+ annotation_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, area->spacetype);
}
/**
@@ -1088,13 +1088,13 @@ void ED_annotation_draw_2dimage(const bContext *C)
void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
{
wmWindowManager *wm = CTX_wm_manager(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
int dflag = 0;
/* check that we have grease-pencil stuff to draw */
- if (sa == NULL) {
+ if (area == NULL) {
return;
}
bGPdata *gpd = ED_annotation_data_get_active(C);
@@ -1105,7 +1105,7 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
/* special hack for Image Editor */
/* FIXME: the opengl poly-strokes don't draw at right thickness when done this way,
* so disabled. */
- if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) {
+ if (ELEM(area->spacetype, SPACE_IMAGE, SPACE_CLIP)) {
dflag |= GP_DRAWDATA_IEDITHACK;
}
@@ -1118,7 +1118,7 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
}
annotation_draw_data_all(
- scene, gpd, 0, 0, region->winx, region->winy, CFRA, dflag, sa->spacetype);
+ scene, gpd, 0, 0, region->winx, region->winy, CFRA, dflag, area->spacetype);
/* draw status text (if in screen/pixel-space) */
if (!onlyv2d) {
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 53ada341cc9..8d50e24b7f0 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -114,7 +114,7 @@ typedef struct tGPsdata {
/** window where painting originated. */
wmWindow *win;
/** area where painting originated. */
- ScrArea *sa;
+ ScrArea *area;
/** region where painting originated. */
ARegion *region;
/** needed for GP_STROKE_2DSPACE. */
@@ -521,7 +521,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
* so initialize depth buffer before converting coordinates
*/
if (gpencil_project_check(p)) {
- View3D *v3d = p->sa->spacedata.first;
+ View3D *v3d = p->area->spacedata.first;
view3d_region_operator_needs_opengl(p->win, p->region);
ED_view3d_autodist_init(p->depsgraph,
@@ -793,7 +793,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p,
const int x,
const int y)
{
- if ((p->sa->spacetype == SPACE_VIEW3D) && (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH)) {
+ if ((p->area->spacetype == SPACE_VIEW3D) && (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH)) {
RegionView3D *rv3d = p->region->regiondata;
const int mval_i[2] = {x, y};
float mval_3d[3];
@@ -920,9 +920,9 @@ static void gp_stroke_doeraser(tGPsdata *p)
rect.xmax = p->mval[0] + p->radius;
rect.ymax = p->mval[1] + p->radius;
- if (p->sa->spacetype == SPACE_VIEW3D) {
+ if (p->area->spacetype == SPACE_VIEW3D) {
if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) {
- View3D *v3d = p->sa->spacedata.first;
+ View3D *v3d = p->area->spacedata.first;
view3d_region_operator_needs_opengl(p->win, p->region);
ED_view3d_autodist_init(p->depsgraph, p->region, v3d, 0);
}
@@ -936,7 +936,7 @@ static void gp_stroke_doeraser(tGPsdata *p)
/* Not all strokes in the datablock may be valid in the current editor/context
* (e.g. 2D space strokes in the 3D view, if the same datablock is shared)
*/
- if (ED_gpencil_stroke_can_use_direct(p->sa, gps)) {
+ if (ED_gpencil_stroke_can_use_direct(p->area, gps)) {
gp_stroke_eraser_dostroke(p, gpf, gps, p->mval, p->radius, &rect);
}
}
@@ -997,7 +997,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
* - must verify that region data is 3D-view (and not something else)
*/
/* CAUTION: If this is the "toolbar", then this will change on the first stroke */
- p->sa = curarea;
+ p->area = curarea;
p->region = region;
p->align_flag = &ts->annotate_v3d_align;
@@ -1016,7 +1016,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
/* SpaceNode *snode = curarea->spacedata.first; */
/* set current area */
- p->sa = curarea;
+ p->area = curarea;
p->region = region;
p->v2d = &region->v2d;
p->align_flag = &ts->gpencil_v2d_align;
@@ -1026,7 +1026,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
SpaceSeq *sseq = curarea->spacedata.first;
/* set current area */
- p->sa = curarea;
+ p->area = curarea;
p->region = region;
p->v2d = &region->v2d;
p->align_flag = &ts->gpencil_seq_align;
@@ -1045,7 +1045,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
/* SpaceImage *sima = curarea->spacedata.first; */
/* set the current area */
- p->sa = curarea;
+ p->area = curarea;
p->region = region;
p->v2d = &region->v2d;
p->align_flag = &ts->gpencil_ima_align;
@@ -1061,7 +1061,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
}
/* set the current area */
- p->sa = curarea;
+ p->area = curarea;
p->region = region;
p->v2d = &region->v2d;
p->align_flag = &ts->gpencil_v2d_align;
@@ -1279,7 +1279,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
p->gpd->runtime.sbuffer_sflag |= GP_STROKE_ERASER;
/* check if we should respect depth while erasing */
- if (p->sa->spacetype == SPACE_VIEW3D) {
+ if (p->area->spacetype == SPACE_VIEW3D) {
if (p->gpl->flag & GP_LAYER_NO_XRAY) {
p->flags |= GP_PAINTFLAG_V3D_ERASER_DEPTH;
}
@@ -1289,7 +1289,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* disable eraser flags - so that we can switch modes during a session */
p->gpd->runtime.sbuffer_sflag &= ~GP_STROKE_ERASER;
- if (p->sa->spacetype == SPACE_VIEW3D) {
+ if (p->area->spacetype == SPACE_VIEW3D) {
if (p->gpl->flag & GP_LAYER_NO_XRAY) {
p->flags &= ~GP_PAINTFLAG_V3D_ERASER_DEPTH;
}
@@ -1302,8 +1302,8 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* when drawing in the camera view, in 2D space, set the subrect */
p->subrect = NULL;
if ((*p->align_flag & GP_PROJECT_VIEWSPACE) == 0) {
- if (p->sa->spacetype == SPACE_VIEW3D) {
- View3D *v3d = p->sa->spacedata.first;
+ if (p->area->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = p->area->spacedata.first;
RegionView3D *rv3d = p->region->regiondata;
/* for camera view set the subrect */
@@ -1320,7 +1320,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
p->gsc.gpd = p->gpd;
p->gsc.gpl = p->gpl;
- p->gsc.sa = p->sa;
+ p->gsc.area = p->area;
p->gsc.region = p->region;
p->gsc.v2d = p->v2d;
@@ -1331,7 +1331,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* check if points will need to be made in view-aligned space */
if (*p->align_flag & GP_PROJECT_VIEWSPACE) {
- switch (p->sa->spacetype) {
+ switch (p->area->spacetype) {
case SPACE_VIEW3D: {
p->gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE;
break;
@@ -1355,7 +1355,7 @@ static void gp_paint_strokeend(tGPsdata *p)
* the conversions will project the values correctly...
*/
if (gpencil_project_check(p)) {
- View3D *v3d = p->sa->spacedata.first;
+ View3D *v3d = p->area->spacedata.first;
/* need to restore the original projection settings before packing up */
view3d_region_operator_needs_opengl(p->win, p->region);
@@ -1931,10 +1931,10 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
-static bool gpencil_area_exists(bContext *C, ScrArea *sa_test)
+static bool gpencil_area_exists(bContext *C, ScrArea *area_test)
{
- bScreen *sc = CTX_wm_screen(C);
- return (BLI_findindex(&sc->areabase, sa_test) != -1);
+ bScreen *screen = CTX_wm_screen(C);
+ return (BLI_findindex(&screen->areabase, area_test) != -1);
}
static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
@@ -1944,7 +1944,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
/* we must check that we're still within the area that we're set up to work from
* otherwise we could crash (see bug #20586)
*/
- if (CTX_wm_area(C) != p->sa) {
+ if (CTX_wm_area(C) != p->area) {
printf("\t\t\tGP - wrong area execution abort!\n");
p->status = GP_STATUS_ERROR;
}
@@ -2168,18 +2168,19 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
*/
if ((p->region) && (p->region->regiontype == RGN_TYPE_TOOLS)) {
/* Change to whatever region is now under the mouse */
- ARegion *current_region = BKE_area_find_region_xy(p->sa, RGN_TYPE_ANY, event->x, event->y);
+ ARegion *current_region = BKE_area_find_region_xy(
+ p->area, RGN_TYPE_ANY, event->x, event->y);
if (G.debug & G_DEBUG) {
- printf("found alternative region %p (old was %p) - at %d %d (sa: %d %d -> %d %d)\n",
+ printf("found alternative region %p (old was %p) - at %d %d (area: %d %d -> %d %d)\n",
current_region,
p->region,
event->x,
event->y,
- p->sa->totrct.xmin,
- p->sa->totrct.ymin,
- p->sa->totrct.xmax,
- p->sa->totrct.ymax);
+ p->area->totrct.xmin,
+ p->area->totrct.ymin,
+ p->area->totrct.xmax,
+ p->area->totrct.ymax);
}
if (current_region) {
@@ -2314,7 +2315,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
- if (0 == gpencil_area_exists(C, p->sa)) {
+ if (0 == gpencil_area_exists(C, p->area)) {
estate = OPERATOR_CANCELLED;
}
else {
diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index 9566495715a..1528c448c0b 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -543,7 +543,7 @@ static bool gpencil_generate_weights_poll(bContext *C)
}
/* need some armature in the view layer */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object->type == OB_ARMATURE) {
return true;
}
@@ -630,7 +630,7 @@ static const EnumPropertyItem *gpencil_armatures_enum_itemf(bContext *C,
RNA_enum_item_add(&item, &totitem, &item_tmp);
i++;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if (ob->type == OB_ARMATURE) {
item_tmp.identifier = item_tmp.name = ob->id.name + 2;
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 8470fcad9d7..28e632d2b82 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -1465,12 +1465,12 @@ static bool gp_convert_poll(bContext *C)
bGPdata *gpd = (bGPdata *)ob->data;
bGPDlayer *gpl = NULL;
bGPDframe *gpf = NULL;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* only if the current view is 3D View, if there's valid data (i.e. at least one stroke!),
* and if we are not in edit mode!
*/
- return ((sa && sa->spacetype == SPACE_VIEW3D) && (gpl = BKE_gpencil_layer_active_get(gpd)) &&
+ return ((area && area->spacetype == SPACE_VIEW3D) && (gpl = BKE_gpencil_layer_active_get(gpd)) &&
(gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_USE_PREV)) &&
(gpf->strokes.first) && (!GPENCIL_ANY_EDIT_MODE(gpd)));
}
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 898facb86e8..1e49195140c 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -50,6 +50,7 @@
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
+#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_brush.h"
#include "BKE_context.h"
@@ -240,10 +241,10 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op)
if ((ob != NULL) && (ob->type == OB_GPENCIL)) {
gpd = (bGPdata *)ob->data;
bGPDlayer *gpl = BKE_gpencil_layer_addnew(gpd, DATA_("GP_Layer"), true);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* In dopesheet add a new frame. */
- if ((gpl != NULL) && (sa->spacetype == SPACE_ACTION)) {
+ if ((gpl != NULL) && (area->spacetype == SPACE_ACTION)) {
gpl->actframe = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_ADD_NEW);
}
}
@@ -331,6 +332,7 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op)
/* notifiers */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -478,6 +480,7 @@ static int gp_layer_copy_exec(bContext *C, wmOperator *UNUSED(op))
/* notifiers */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -519,7 +522,7 @@ static bool gp_layer_duplicate_object_poll(bContext *C)
}
/* check there are more grease pencil objects */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if ((base->object != ob) && (base->object->type == OB_GPENCIL)) {
return true;
}
@@ -568,7 +571,7 @@ static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op)
gpl_dst->opacity = gpl_src->opacity;
/* Create all frames. */
- for (bGPDframe *gpf_src = gpl_src->frames.first; gpf_src; gpf_src = gpf_src->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf_src, &gpl_src->frames) {
if ((mode == GP_LAYER_COPY_OBJECT_ACT_FRAME) && (gpf_src != gpl_src->actframe)) {
continue;
@@ -578,7 +581,7 @@ static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op)
bGPDframe *gpf_dst = BKE_gpencil_frame_addnew(gpl_dst, gpf_src->framenum);
/* Copy strokes. */
- for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) {
/* Make copy of source stroke. */
bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true);
@@ -1181,12 +1184,12 @@ static int gp_merge_layer_exec(bContext *C, wmOperator *op)
/* Collect frames of gpl_current in hash table to avoid O(n^2) lookups */
GHash *gh_frames_cur = BLI_ghash_int_new_ex(__func__, 64);
- for (bGPDframe *gpf = gpl_current->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_current->frames) {
BLI_ghash_insert(gh_frames_cur, POINTER_FROM_INT(gpf->framenum), gpf);
}
/* read all frames from next layer and add any missing in current layer */
- for (bGPDframe *gpf = gpl_next->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_next->frames) {
/* try to find frame in current layer */
bGPDframe *frame = BLI_ghash_lookup(gh_frames_cur, POINTER_FROM_INT(gpf->framenum));
if (!frame) {
@@ -1228,6 +1231,7 @@ static int gp_merge_layer_exec(bContext *C, wmOperator *op)
/* notifiers */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -1291,6 +1295,7 @@ static int gp_layer_change_exec(bContext *C, wmOperator *op)
/* updates */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -1336,6 +1341,7 @@ static int gp_layer_active_exec(bContext *C, wmOperator *op)
/* updates */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -1433,7 +1439,7 @@ static int gp_stroke_arrange_exec(bContext *C, wmOperator *op)
switch (direction) {
/* Bring to Front */
case GP_STROKE_MOVE_TOP:
- for (LinkData *link = selected.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &selected) {
gps = link->data;
BLI_remlink(&gpf->strokes, gps);
BLI_addtail(&gpf->strokes, gps);
@@ -1448,7 +1454,7 @@ static int gp_stroke_arrange_exec(bContext *C, wmOperator *op)
break;
/* Send Backward */
case GP_STROKE_MOVE_DOWN:
- for (LinkData *link = selected.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &selected) {
gps = link->data;
BLI_listbase_link_move(&gpf->strokes, gps, -1);
}
@@ -2523,7 +2529,7 @@ static void joined_gpencil_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data)
/* Fix driver targets */
if (fcu->driver) {
/* Fix driver references to invalid ID's */
- for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) {
+ LISTBASE_FOREACH (DriverVar *, dvar, &fcu->driver->variables) {
/* Only change the used targets, since the others will need fixing manually anyway. */
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
/* Change the ID's used. */
@@ -2614,7 +2620,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
bGPdata *gpd_src = ob_iter->data;
/* Apply all GP modifiers before */
- for (GpencilModifierData *md = ob_iter->greasepencil_modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (GpencilModifierData *, md, &ob_iter->greasepencil_modifiers) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type);
if (mti->bakeModifier) {
mti->bakeModifier(bmain, depsgraph, md, ob_iter);
@@ -2623,7 +2629,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
/* copy vertex groups to the base one's */
int old_idx = 0;
- for (bDeformGroup *dg = ob_iter->defbase.first; dg; dg = dg->next) {
+ LISTBASE_FOREACH (bDeformGroup *, dg, &ob_iter->defbase) {
bDeformGroup *vgroup = MEM_dupallocN(dg);
int idx = BLI_listbase_count(&ob_active->defbase);
BKE_object_defgroup_unique_name(vgroup, ob_active);
@@ -2675,7 +2681,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
mul_m3_v3(imat, offset_global);
mul_v3_m3v3(offset_local, imat, offset_global);
- for (bGPDlayer *gpl_src = gpd_src->layers.first; gpl_src; gpl_src = gpl_src->next) {
+ LISTBASE_FOREACH (bGPDlayer *, gpl_src, &gpd_src->layers) {
bGPDlayer *gpl_new = BKE_gpencil_layer_duplicate(gpl_src);
float diff_mat[4][4];
float inverse_diff_mat[4][4];
@@ -2685,7 +2691,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
invert_m4_m4(inverse_diff_mat, diff_mat);
Material *ma_src = NULL;
- for (bGPDframe *gpf = gpl_new->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_new->frames) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* Reassign material. Look old material and try to find in destination. */
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index dc7bbfb99fa..947da9e7877 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1333,7 +1333,7 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op)
if (gp_strokes_copypastebuf.first) {
gp_strokes_copypastebuf_colors = BLI_ghash_int_new("GPencil CopyBuf Colors");
GHash *ma_to_name = gp_strokes_copypastebuf_colors_material_to_name_create(bmain);
- for (bGPDstroke *gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gp_strokes_copypastebuf) {
if (ED_gpencil_stroke_can_use(C, gps)) {
Material *ma = BKE_object_material_get(ob, gps->mat_nr + 1);
/* Avoid default material. */
@@ -1379,8 +1379,8 @@ void GPENCIL_OT_copy(wmOperatorType *ot)
static bool gp_strokes_paste_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- if (!((sa != NULL) && (sa->spacetype == SPACE_VIEW3D))) {
+ ScrArea *area = CTX_wm_area(C);
+ if (!((area != NULL) && (area->spacetype == SPACE_VIEW3D))) {
return false;
}
/* 1) Must have GP datablock to paste to
@@ -1569,7 +1569,13 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
}
/* Try to get layer */
- target_layer = BLI_findlink(&gpd->layers, layer_num);
+ if (layer_num > -1) {
+ target_layer = BLI_findlink(&gpd->layers, layer_num);
+ }
+ else {
+ /* Create a new layer. */
+ target_layer = BKE_gpencil_layer_addnew(gpd, "GP_Layer", true);
+ }
if (target_layer == NULL) {
/* back autolock status */
@@ -1655,7 +1661,8 @@ void GPENCIL_OT_move_to_layer(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* GPencil layer to use. */
- ot->prop = RNA_def_int(ot->srna, "layer", 0, 0, INT_MAX, "Grease Pencil Layer", "", 0, INT_MAX);
+ ot->prop = RNA_def_int(
+ ot->srna, "layer", 0, -1, INT_MAX, "Grease Pencil Layer", "", -1, INT_MAX);
RNA_def_property_flag(ot->prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
@@ -2599,11 +2606,11 @@ void GPENCIL_OT_dissolve(wmOperatorType *ot)
*/
static bool gp_snap_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Object *ob = CTX_data_active_object(C);
return (ob != NULL) && (ob->type == OB_GPENCIL) &&
- ((sa != NULL) && (sa->spacetype == SPACE_VIEW3D));
+ ((area != NULL) && (area->spacetype == SPACE_VIEW3D));
}
/* --------------------------------- */
@@ -3233,9 +3240,9 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a,
}
/* define start and end points of each stroke */
- float sa[3], sb[3], ea[3], eb[3];
+ float area[3], sb[3], ea[3], eb[3];
pt = &gps_a->points[0];
- copy_v3_v3(sa, &pt->x);
+ copy_v3_v3(area, &pt->x);
pt = &gps_a->points[gps_a->totpoints - 1];
copy_v3_v3(ea, &pt->x);
@@ -4357,6 +4364,7 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -4617,7 +4625,7 @@ static int gpencil_cutter_lasso_select(bContext *C,
void *user_data)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ToolSettings *ts = CTX_data_tool_settings(C);
const float scale = ts->gp_sculpt.isect_threshold;
@@ -4628,7 +4636,7 @@ static int gpencil_cutter_lasso_select(bContext *C,
bool changed = false;
/* sanity checks */
- if (sa == NULL) {
+ if (area == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
@@ -4724,9 +4732,9 @@ static bool gpencil_cutter_poll(bContext *C)
static int gpencil_cutter_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* sanity checks */
- if (sa == NULL) {
+ if (area == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index e56017d0bed..a3f6e10ccb0 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -92,7 +92,7 @@ typedef struct tGPDfill {
/** current active gp object */
struct Object *ob;
/** area where painting originated */
- struct ScrArea *sa;
+ struct ScrArea *area;
/** region where painting originated */
struct RegionView3D *rv3d;
/** view3 where painting originated */
@@ -1248,8 +1248,8 @@ static bool gpencil_fill_poll(bContext *C)
Object *obact = CTX_data_active_object(C);
if (ED_operator_regionactive(C)) {
- ScrArea *sa = CTX_wm_area(C);
- if (sa->spacetype == SPACE_VIEW3D) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area->spacetype == SPACE_VIEW3D) {
if ((obact == NULL) || (obact->type != OB_GPENCIL) ||
(obact->mode != OB_MODE_PAINT_GPENCIL)) {
return false;
@@ -1283,10 +1283,10 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op))
tgpf->bmain = CTX_data_main(C);
tgpf->scene = CTX_data_scene(C);
tgpf->ob = CTX_data_active_object(C);
- tgpf->sa = CTX_wm_area(C);
+ tgpf->area = CTX_wm_area(C);
tgpf->region = CTX_wm_region(C);
tgpf->rv3d = tgpf->region->regiondata;
- tgpf->v3d = tgpf->sa->spacedata.first;
+ tgpf->v3d = tgpf->area->spacedata.first;
tgpf->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
tgpf->win = CTX_wm_window(C);
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index 61bca235d17..c5e5a0b79ef 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -116,7 +116,7 @@ typedef struct tGPDinterpolate {
/** current scene from context */
struct Scene *scene;
/** area where painting originated */
- struct ScrArea *sa;
+ struct ScrArea *area;
/** region where painting originated */
struct ARegion *region;
/** current GP datablock */
@@ -156,7 +156,7 @@ typedef struct tGPDprimitive {
/** current evaluated gp object */
struct Object *ob_eval;
/** area where painting originated */
- struct ScrArea *sa;
+ struct ScrArea *area;
/** region where painting originated */
struct RegionView3D *rv3d;
/** view3d where painting originated */
@@ -247,7 +247,7 @@ typedef struct GP_SpaceConversion {
struct bGPdata *gpd;
struct bGPDlayer *gpl;
- struct ScrArea *sa;
+ struct ScrArea *area;
struct ARegion *region;
struct View2D *v2d;
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index fef88007542..e6661e886b1 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -86,8 +86,8 @@ static bool gpencil_view3d_poll(bContext *C)
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
/* only 3D view */
- ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype != SPACE_VIEW3D) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area && area->spacetype != SPACE_VIEW3D) {
return 0;
}
@@ -383,7 +383,7 @@ static void gpencil_interpolate_status_indicators(bContext *C, tGPDinterpolate *
(int)((p->init_factor + p->shift) * 100.0f));
}
- ED_area_status_text(p->sa, status_str);
+ ED_area_status_text(p->area, status_str);
ED_workspace_status_text(
C, TIP_("ESC/RMB to cancel, Enter/LMB to confirm, WHEEL/MOVE to adjust factor"));
}
@@ -410,7 +410,7 @@ static void gpencil_interpolate_exit(bContext *C, wmOperator *op)
/* don't assume that operator data exists at all */
if (tgpi) {
/* clear status message area */
- ED_area_status_text(tgpi->sa, NULL);
+ ED_area_status_text(tgpi->area, NULL);
ED_workspace_status_text(C, NULL);
/* Clear any temp stroke. */
@@ -445,7 +445,7 @@ static bool gp_interpolate_set_init_values(bContext *C, wmOperator *op, tGPDinte
/* set current scene and window */
tgpi->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
tgpi->scene = CTX_data_scene(C);
- tgpi->sa = CTX_wm_area(C);
+ tgpi->area = CTX_wm_area(C);
tgpi->region = CTX_wm_region(C);
tgpi->flag = ts->gp_interpolate.flag;
@@ -567,7 +567,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
case EVT_PADENTER:
case EVT_RETKEY: {
/* return to normal cursor and header status */
- ED_area_status_text(tgpi->sa, NULL);
+ ED_area_status_text(tgpi->area, NULL);
ED_workspace_status_text(C, NULL);
WM_cursor_modal_restore(win);
@@ -602,7 +602,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
case EVT_ESCKEY: /* cancel */
case RIGHTMOUSE: {
/* return to normal cursor and header status */
- ED_area_status_text(tgpi->sa, NULL);
+ ED_area_status_text(tgpi->area, NULL);
ED_workspace_status_text(C, NULL);
WM_cursor_modal_restore(win);
diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c
index bd9daa83411..6a5c5f7eb07 100644
--- a/source/blender/editors/gpencil/gpencil_merge.c
+++ b/source/blender/editors/gpencil/gpencil_merge.c
@@ -132,18 +132,8 @@ static bGPDstroke *gpencil_prepare_stroke(bContext *C, wmOperator *op, int totpo
bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, add_frame_mode);
/* stroke */
- bGPDstroke *gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke");
- gps->totpoints = totpoints;
- gps->inittime = 0.0f;
- gps->thickness = brush->size;
- gps->hardeness = brush->gpencil_settings->hardeness;
- copy_v2_v2(gps->aspect_ratio, brush->gpencil_settings->aspect_ratio);
+ bGPDstroke *gps = BKE_gpencil_stroke_new(ob->actcol - 1, totpoints, brush->size);
gps->flag |= GP_STROKE_SELECT;
- gps->flag |= GP_STROKE_3DSPACE;
- gps->mat_nr = ob->actcol - 1;
-
- /* allocate memory for points */
- gps->points = MEM_callocN(sizeof(bGPDspoint) * totpoints, "gp_stroke_points");
if (cyclic) {
gps->flag |= GP_STROKE_CYCLIC;
@@ -529,6 +519,8 @@ static int gp_stroke_merge_exec(bContext *C, wmOperator *op)
gpencil_dissolve_points(C);
}
+ BKE_gpencil_stroke_geometry_update(gps);
+
/* free memory */
MEM_SAFE_FREE(original_array);
MEM_SAFE_FREE(sorted_array);
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index 8b126912efc..0171a81f5eb 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -178,10 +178,10 @@ static bool gp_stroke_sculptmode_poll(bContext *C)
{
bGPdata *gpd = CTX_data_gpencil_data(C);
Object *ob = CTX_data_active_object(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* if not gpencil object and not view3d, need sculpt keys if edit mode */
- if (sa->spacetype != SPACE_VIEW3D) {
+ if (area->spacetype != SPACE_VIEW3D) {
return ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE));
}
else {
diff --git a/source/blender/editors/gpencil/gpencil_ops_versioning.c b/source/blender/editors/gpencil/gpencil_ops_versioning.c
index 96146c60acb..2dd98bb8df1 100644
--- a/source/blender/editors/gpencil/gpencil_ops_versioning.c
+++ b/source/blender/editors/gpencil/gpencil_ops_versioning.c
@@ -117,9 +117,8 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain); /* added object */
/* convert grease pencil palettes (version >= 2.78) to materials and weights */
- for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) {
- for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor;
- palcolor = palcolor->next) {
+ LISTBASE_FOREACH (const bGPDpalette *, palette, &gpd->palettes) {
+ LISTBASE_FOREACH (bGPDpalettecolor *, palcolor, &palette->colors) {
/* create material slot */
Material *ma = BKE_gpencil_object_material_new(bmain, ob, palcolor->info, NULL);
@@ -168,9 +167,8 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *op)
}
if (is_annotation) {
- for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) {
- for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor;
- palcolor = palcolor->next) {
+ LISTBASE_FOREACH (const bGPDpalette *, palette, &gpd->palettes) {
+ LISTBASE_FOREACH (bGPDpalettecolor *, palcolor, &palette->colors) {
/* fix layers */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* unlock/unhide layer */
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 1a169f9ec89..40068b0fb85 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -156,7 +156,7 @@ typedef struct tGPsdata {
/** window where painting originated. */
wmWindow *win;
/** area where painting originated. */
- ScrArea *sa;
+ ScrArea *area;
/** region where painting originated. */
ARegion *region;
/** needed for GP_STROKE_2DSPACE. */
@@ -297,9 +297,9 @@ static void gp_session_validatebuffer(tGPsdata *p);
static bool gpencil_draw_poll(bContext *C)
{
if (ED_operator_regionactive(C)) {
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* 3D Viewport */
- if (sa->spacetype != SPACE_VIEW3D) {
+ if (area->spacetype != SPACE_VIEW3D) {
return false;
}
@@ -812,7 +812,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
pt->time = (float)(curtime - p->inittime);
/* point uv (only 3d view) */
- if ((p->sa->spacetype == SPACE_VIEW3D) && (gpd->runtime.sbuffer_used > 0)) {
+ if ((p->area->spacetype == SPACE_VIEW3D) && (gpd->runtime.sbuffer_used > 0)) {
tGPspoint *ptb = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_used - 1;
bGPDspoint spt, spt2;
@@ -1242,7 +1242,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p,
gp_settings = eraser->gpencil_settings;
}
- if ((gp_settings != NULL) && (p->sa->spacetype == SPACE_VIEW3D) &&
+ if ((gp_settings != NULL) && (p->area->spacetype == SPACE_VIEW3D) &&
(gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) {
RegionView3D *rv3d = p->region->regiondata;
bGPDlayer *gpl = p->gpl;
@@ -1593,9 +1593,9 @@ static void gp_stroke_doeraser(tGPsdata *p)
rect.xmax = p->mval[0] + calc_radius;
rect.ymax = p->mval[1] + calc_radius;
- if (p->sa->spacetype == SPACE_VIEW3D) {
+ if (p->area->spacetype == SPACE_VIEW3D) {
if ((gp_settings != NULL) && (gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) {
- View3D *v3d = p->sa->spacedata.first;
+ View3D *v3d = p->area->spacedata.first;
view3d_region_operator_needs_opengl(p->win, p->region);
ED_view3d_autodist_init(p->depsgraph, p->region, v3d, 0);
}
@@ -1633,7 +1633,7 @@ static void gp_stroke_doeraser(tGPsdata *p)
/* Not all strokes in the datablock may be valid in the current editor/context
* (e.g. 2D space strokes in the 3D view, if the same datablock is shared)
*/
- if (ED_gpencil_stroke_can_use_direct(p->sa, gps)) {
+ if (ED_gpencil_stroke_can_use_direct(p->area, gps)) {
gp_stroke_eraser_dostroke(p, gpf, gps, p->mval, calc_radius, &rect);
}
}
@@ -1816,7 +1816,7 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
* - must verify that region data is 3D-view (and not something else)
*/
/* CAUTION: If this is the "toolbar", then this will change on the first stroke */
- p->sa = curarea;
+ p->area = curarea;
p->region = region;
p->align_flag = &ts->gpencil_v3d_align;
@@ -1831,7 +1831,7 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
}
if ((!obact) || (obact->type != OB_GPENCIL)) {
- View3D *v3d = p->sa->spacedata.first;
+ View3D *v3d = p->area->spacedata.first;
/* if active object doesn't exist or isn't a GP Object, create one */
const float *cur = p->scene->cursor.location;
@@ -2058,8 +2058,8 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* when drawing in the camera view, in 2D space, set the subrect */
p->subrect = NULL;
if ((*p->align_flag & GP_PROJECT_VIEWSPACE) == 0) {
- if (p->sa->spacetype == SPACE_VIEW3D) {
- View3D *v3d = p->sa->spacedata.first;
+ if (p->area->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = p->area->spacedata.first;
RegionView3D *rv3d = p->region->regiondata;
/* for camera view set the subrect */
@@ -2076,7 +2076,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
p->gsc.gpd = p->gpd;
p->gsc.gpl = p->gpl;
- p->gsc.sa = p->sa;
+ p->gsc.area = p->area;
p->gsc.region = p->region;
p->gsc.v2d = p->v2d;
@@ -2087,7 +2087,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* check if points will need to be made in view-aligned space */
if (*p->align_flag & GP_PROJECT_VIEWSPACE) {
- switch (p->sa->spacetype) {
+ switch (p->area->spacetype) {
case SPACE_VIEW3D: {
p->gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE;
break;
@@ -2112,7 +2112,7 @@ static void gp_paint_strokeend(tGPsdata *p)
* the conversions will project the values correctly...
*/
if (gpencil_project_check(p)) {
- View3D *v3d = p->sa->spacedata.first;
+ View3D *v3d = p->area->spacedata.first;
/* need to restore the original projection settings before packing up */
view3d_region_operator_needs_opengl(p->win, p->region);
@@ -2243,7 +2243,7 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op)
}
/* restore cursor to indicate end of drawing */
- if (p->sa->spacetype != SPACE_VIEW3D) {
+ if (p->area->spacetype != SPACE_VIEW3D) {
WM_cursor_modal_restore(CTX_wm_window(C));
}
else {
@@ -3096,10 +3096,10 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
-static bool gpencil_area_exists(bContext *C, ScrArea *sa_test)
+static bool gpencil_area_exists(bContext *C, ScrArea *area_test)
{
- bScreen *sc = CTX_wm_screen(C);
- return (BLI_findindex(&sc->areabase, sa_test) != -1);
+ bScreen *screen = CTX_wm_screen(C);
+ return (BLI_findindex(&screen->areabase, area_test) != -1);
}
static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
@@ -3109,7 +3109,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
/* we must check that we're still within the area that we're set up to work from
* otherwise we could crash (see bug #20586)
*/
- if (CTX_wm_area(C) != p->sa) {
+ if (CTX_wm_area(C) != p->area) {
printf("\t\t\tGP - wrong area execution abort!\n");
p->status = GP_STATUS_ERROR;
}
@@ -3504,18 +3504,19 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
*/
if ((p->region) && (p->region->regiontype == RGN_TYPE_TOOLS)) {
/* Change to whatever region is now under the mouse */
- ARegion *current_region = BKE_area_find_region_xy(p->sa, RGN_TYPE_ANY, event->x, event->y);
+ ARegion *current_region = BKE_area_find_region_xy(
+ p->area, RGN_TYPE_ANY, event->x, event->y);
if (G.debug & G_DEBUG) {
- printf("found alternative region %p (old was %p) - at %d %d (sa: %d %d -> %d %d)\n",
+ printf("found alternative region %p (old was %p) - at %d %d (area: %d %d -> %d %d)\n",
current_region,
p->region,
event->x,
event->y,
- p->sa->totrct.xmin,
- p->sa->totrct.ymin,
- p->sa->totrct.xmax,
- p->sa->totrct.ymax);
+ p->area->totrct.xmin,
+ p->area->totrct.ymin,
+ p->area->totrct.xmax,
+ p->area->totrct.ymax);
}
if (current_region) {
@@ -3660,7 +3661,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
- if (0 == gpencil_area_exists(C, p->sa)) {
+ if (0 == gpencil_area_exists(C, p->area)) {
estate = OPERATOR_CANCELLED;
}
else {
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index dfd11484d22..11aeeba5a24 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -240,8 +240,8 @@ static void gp_primitive_update_cps(tGPDprimitive *tgpi)
static bool gpencil_primitive_add_poll(bContext *C)
{
/* only 3D view */
- ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype != SPACE_VIEW3D) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area && area->spacetype != SPACE_VIEW3D) {
return 0;
}
@@ -1137,10 +1137,10 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
tgpi->scene = scene;
tgpi->ob = CTX_data_active_object(C);
tgpi->ob_eval = (Object *)DEG_get_evaluated_object(tgpi->depsgraph, tgpi->ob);
- tgpi->sa = CTX_wm_area(C);
+ tgpi->area = CTX_wm_area(C);
tgpi->region = CTX_wm_region(C);
tgpi->rv3d = tgpi->region->regiondata;
- tgpi->v3d = tgpi->sa->spacedata.first;
+ tgpi->v3d = tgpi->area->spacedata.first;
tgpi->win = CTX_wm_window(C);
/* save original type */
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index 8f3fc5fa268..7b6054e4156 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -91,7 +91,7 @@ typedef struct tGP_BrushEditData {
Scene *scene;
Object *object;
- ScrArea *sa;
+ ScrArea *area;
ARegion *region;
/* Current GPencil datablock */
@@ -1181,7 +1181,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
gso->is_transformed = false;
}
- gso->sa = CTX_wm_area(C);
+ gso->area = CTX_wm_area(C);
gso->region = CTX_wm_region(C);
Paint *paint = &ts->gp_sculptpaint->paint;
@@ -1307,8 +1307,8 @@ static void gpsculpt_brush_exit(bContext *C, wmOperator *op)
/* poll callback for stroke sculpting operator(s) */
static bool gpsculpt_brush_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype != SPACE_VIEW3D) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area && area->spacetype != SPACE_VIEW3D) {
return false;
}
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 97f0a578d9d..e25576f32aa 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -1015,7 +1015,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
const int mx = RNA_int_get(op->ptr, "x");
const int my = RNA_int_get(op->ptr, "y");
@@ -1028,7 +1028,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
bool changed = false;
/* sanity checks */
- if (sa == NULL) {
+ if (area == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
@@ -1126,7 +1126,7 @@ static int gpencil_generic_select_exec(bContext *C,
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
int selectmode;
if (ob && ob->mode == OB_MODE_SCULPT_GPENCIL) {
@@ -1153,7 +1153,7 @@ static int gpencil_generic_select_exec(bContext *C,
bool changed = false;
/* sanity checks */
- if (sa == NULL) {
+ if (area == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
@@ -1416,7 +1416,7 @@ static void deselect_all_selected(bContext *C)
static int gpencil_select_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
ToolSettings *ts = CTX_data_tool_settings(C);
@@ -1444,7 +1444,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
int hit_distance = radius_squared;
/* sanity checks */
- if (sa == NULL) {
+ if (area == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 312cb1b50c0..3d571773bc8 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -93,13 +93,13 @@
* and an RNA-pointer to trace back to whatever owns it,
* when context info is not available.
*/
-bGPdata **ED_gpencil_data_get_pointers_direct(ScrArea *sa, Object *ob, PointerRNA *r_ptr)
+bGPdata **ED_gpencil_data_get_pointers_direct(ScrArea *area, Object *ob, PointerRNA *r_ptr)
{
/* if there's an active area, check if the particular editor may
* have defined any special Grease Pencil context for editing...
*/
- if (sa) {
- switch (sa->spacetype) {
+ if (area) {
+ switch (area->spacetype) {
case SPACE_PROPERTIES: /* properties */
case SPACE_INFO: /* header info */
case SPACE_TOPBAR: /* Topbar */
@@ -132,16 +132,16 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ScrArea *sa, Object *ob, PointerRN
* when context info is not available.
*/
bGPdata **ED_annotation_data_get_pointers_direct(ID *screen_id,
- ScrArea *sa,
+ ScrArea *area,
Scene *scene,
PointerRNA *r_ptr)
{
/* If there's an active area, check if the particular editor may
* have defined any special Grease Pencil context for editing. */
- if (sa) {
- SpaceLink *sl = sa->spacedata.first;
+ if (area) {
+ SpaceLink *sl = area->spacedata.first;
- switch (sa->spacetype) {
+ switch (area->spacetype) {
case SPACE_PROPERTIES: /* properties */
case SPACE_INFO: /* header info */
{
@@ -236,10 +236,10 @@ bGPdata **ED_annotation_data_get_pointers_direct(ID *screen_id,
* and an RNA-pointer to trace back to whatever owns it. */
bGPdata **ED_gpencil_data_get_pointers(const bContext *C, PointerRNA *r_ptr)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Object *ob = CTX_data_active_object(C);
- return ED_gpencil_data_get_pointers_direct(sa, ob, r_ptr);
+ return ED_gpencil_data_get_pointers_direct(area, ob, r_ptr);
}
/* Get pointer to active Grease Pencil datablock,
@@ -248,23 +248,23 @@ bGPdata **ED_annotation_data_get_pointers(const bContext *C, PointerRNA *r_ptr)
{
ID *screen_id = (ID *)CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
- return ED_annotation_data_get_pointers_direct(screen_id, sa, scene, r_ptr);
+ return ED_annotation_data_get_pointers_direct(screen_id, area, scene, r_ptr);
}
/* -------------------------------------------------------- */
/* Get the active Grease Pencil datablock, when context is not available */
-bGPdata *ED_gpencil_data_get_active_direct(ScrArea *sa, Object *ob)
+bGPdata *ED_gpencil_data_get_active_direct(ScrArea *area, Object *ob)
{
- bGPdata **gpd_ptr = ED_gpencil_data_get_pointers_direct(sa, ob, NULL);
+ bGPdata **gpd_ptr = ED_gpencil_data_get_pointers_direct(area, ob, NULL);
return (gpd_ptr) ? *(gpd_ptr) : NULL;
}
/* Get the active Grease Pencil datablock, when context is not available */
-bGPdata *ED_annotation_data_get_active_direct(ID *screen_id, ScrArea *sa, Scene *scene)
+bGPdata *ED_annotation_data_get_active_direct(ID *screen_id, ScrArea *area, Scene *scene)
{
- bGPdata **gpd_ptr = ED_annotation_data_get_pointers_direct(screen_id, sa, scene, NULL);
+ bGPdata **gpd_ptr = ED_annotation_data_get_pointers_direct(screen_id, area, scene, NULL);
return (gpd_ptr) ? *(gpd_ptr) : NULL;
}
@@ -299,13 +299,13 @@ bGPdata *ED_annotation_data_get_active(const bContext *C)
*/
bGPdata *ED_gpencil_data_get_active_evaluated(const bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob = CTX_data_active_object(C);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- return ED_gpencil_data_get_active_direct(sa, ob_eval);
+ return ED_gpencil_data_get_active_direct(area, ob_eval);
}
/* -------------------------------------------------------- */
@@ -513,25 +513,25 @@ bool gp_stroke_inside_circle(const float mval[2], int rad, int x0, int y0, int x
/* Check whether given stroke can be edited given the supplied context */
/* TODO: do we need additional flags for screenspace vs dataspace? */
-bool ED_gpencil_stroke_can_use_direct(const ScrArea *sa, const bGPDstroke *gps)
+bool ED_gpencil_stroke_can_use_direct(const ScrArea *area, const bGPDstroke *gps)
{
/* sanity check */
- if (ELEM(NULL, sa, gps)) {
+ if (ELEM(NULL, area, gps)) {
return false;
}
/* filter stroke types by flags + spacetype */
if (gps->flag & GP_STROKE_3DSPACE) {
/* 3D strokes - only in 3D view */
- return ((sa->spacetype == SPACE_VIEW3D) || (sa->spacetype == SPACE_PROPERTIES));
+ return ((area->spacetype == SPACE_VIEW3D) || (area->spacetype == SPACE_PROPERTIES));
}
else if (gps->flag & GP_STROKE_2DIMAGE) {
/* Special "image" strokes - only in Image Editor */
- return (sa->spacetype == SPACE_IMAGE);
+ return (area->spacetype == SPACE_IMAGE);
}
else if (gps->flag & GP_STROKE_2DSPACE) {
/* 2D strokes (dataspace) - for any 2D view (i.e. everything other than 3D view) */
- return (sa->spacetype != SPACE_VIEW3D);
+ return (area->spacetype != SPACE_VIEW3D);
}
else {
/* view aligned - anything goes */
@@ -542,8 +542,8 @@ bool ED_gpencil_stroke_can_use_direct(const ScrArea *sa, const bGPDstroke *gps)
/* Check whether given stroke can be edited in the current context */
bool ED_gpencil_stroke_can_use(const bContext *C, const bGPDstroke *gps)
{
- ScrArea *sa = CTX_wm_area(C);
- return ED_gpencil_stroke_can_use_direct(sa, gps);
+ ScrArea *area = CTX_wm_area(C);
+ return ED_gpencil_stroke_can_use_direct(area, gps);
}
/* Check whether given stroke can be edited for the current color */
@@ -574,7 +574,7 @@ bool ED_gpencil_stroke_color_use(Object *ob, const bGPDlayer *gpl, const bGPDstr
*/
void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
/* zero out the storage (just in case) */
@@ -585,12 +585,12 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
r_gsc->scene = CTX_data_scene(C);
r_gsc->ob = CTX_data_active_object(C);
- r_gsc->sa = sa;
+ r_gsc->area = area;
r_gsc->region = region;
r_gsc->v2d = &region->v2d;
/* init region-specific stuff */
- if (sa->spacetype == SPACE_VIEW3D) {
+ if (area->spacetype == SPACE_VIEW3D) {
wmWindow *win = CTX_wm_window(C);
Scene *scene = CTX_data_scene(C);
struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
@@ -685,8 +685,8 @@ void gp_point_to_xy(
int xyval[2];
/* sanity checks */
- BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->sa->spacetype == SPACE_VIEW3D));
- BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->sa->spacetype != SPACE_VIEW3D));
+ BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->area->spacetype == SPACE_VIEW3D));
+ BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->area->spacetype != SPACE_VIEW3D));
if (gps->flag & GP_STROKE_3DSPACE) {
if (ED_view3d_project_int_global(region, &pt->x, xyval, V3D_PROJ_TEST_NOP) ==
@@ -743,8 +743,8 @@ void gp_point_to_xy_fl(const GP_SpaceConversion *gsc,
float xyval[2];
/* sanity checks */
- BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->sa->spacetype == SPACE_VIEW3D));
- BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->sa->spacetype != SPACE_VIEW3D));
+ BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->area->spacetype == SPACE_VIEW3D));
+ BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->area->spacetype != SPACE_VIEW3D));
if (gps->flag & GP_STROKE_3DSPACE) {
if (ED_view3d_project_float_global(region, &pt->x, xyval, V3D_PROJ_TEST_NOP) ==
@@ -802,7 +802,7 @@ void gp_point_3d_to_xy(const GP_SpaceConversion *gsc,
float xyval[2];
/* sanity checks */
- BLI_assert((gsc->sa->spacetype == SPACE_VIEW3D));
+ BLI_assert((gsc->area->spacetype == SPACE_VIEW3D));
if (flag & GP_STROKE_3DSPACE) {
if (ED_view3d_project_float_global(region, pt, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
@@ -1563,7 +1563,7 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob)
static bool gp_check_cursor_region(bContext *C, int mval_i[2])
{
ARegion *region = CTX_wm_region(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Object *ob = CTX_data_active_object(C);
if ((ob == NULL) || (!ELEM(ob->mode,
@@ -1575,7 +1575,7 @@ static bool gp_check_cursor_region(bContext *C, int mval_i[2])
}
/* TODO: add more spacetypes */
- if (!ELEM(sa->spacetype, SPACE_VIEW3D)) {
+ if (!ELEM(area->spacetype, SPACE_VIEW3D)) {
return false;
}
if ((region) && (region->regiontype != RGN_TYPE_WINDOW)) {
@@ -2173,7 +2173,8 @@ int ED_gpencil_select_stroke_segment(bGPDlayer *gpl,
float f = 0.0f;
int i2 = 0;
- bGPDframe *gpf = gpl->actframe;
+ bGPDlayer *gpl_orig = (gpl->runtime.gpl_orig) ? gpl->runtime.gpl_orig : gpl;
+ bGPDframe *gpf = gpl_orig->actframe;
if (gpf == NULL) {
return 0;
}
@@ -2186,7 +2187,7 @@ int ED_gpencil_select_stroke_segment(bGPDlayer *gpl,
/* Save list of strokes to check */
int totstrokes = 0;
- for (bGPDstroke *gps_iter = gpf->strokes.first; gps_iter; gps_iter = gps_iter->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps_iter, &gpf->strokes) {
if (gps_iter->totpoints < 2) {
continue;
}
diff --git a/source/blender/editors/gpencil/gpencil_uv.c b/source/blender/editors/gpencil/gpencil_uv.c
index 5f15a6f5411..114d916d1e2 100644
--- a/source/blender/editors/gpencil/gpencil_uv.c
+++ b/source/blender/editors/gpencil/gpencil_uv.c
@@ -92,9 +92,9 @@ static void gpencil_uv_transform_update_header(wmOperator *op, bContext *C)
const char *str = TIP_("Confirm: Enter/LClick, Cancel: (Esc/RClick) %s");
char msg[UI_MAX_DRAW_STR];
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
- if (sa) {
+ if (area) {
char flts_str[NUM_STR_REP_LEN * 2];
switch (mode) {
case GP_UV_TRANSLATE: {
@@ -120,7 +120,7 @@ static void gpencil_uv_transform_update_header(wmOperator *op, bContext *C)
break;
}
BLI_snprintf(msg, sizeof(msg), str, flts_str, flts_str + NUM_STR_REP_LEN);
- ED_area_status_text(sa, msg);
+ ED_area_status_text(area, msg);
}
}
@@ -214,7 +214,7 @@ static bool gpencil_uv_transform_init(bContext *C, wmOperator *op, const bool is
static void gpencil_uv_transform_exit(bContext *C, wmOperator *op)
{
GpUvData *opdata;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
opdata = op->customdata;
@@ -226,8 +226,8 @@ static void gpencil_uv_transform_exit(bContext *C, wmOperator *op)
WM_cursor_set(CTX_wm_window(C), WM_CURSOR_DEFAULT);
- if (sa) {
- ED_area_status_text(sa, NULL);
+ if (area) {
+ ED_area_status_text(area, NULL);
}
WM_main_add_notifier(NC_GEOM | ND_DATA, NULL);
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 7f4c3470020..a9b34e3c735 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -74,13 +74,13 @@ typedef struct bAnimContext {
/** editor->mode */
short mode;
- /** sa->spacetype */
+ /** area->spacetype */
short spacetype;
/** active region -> type (channels or main) */
short regiontype;
/** editor host */
- struct ScrArea *sa;
+ struct ScrArea *area;
/** editor data */
struct SpaceLink *sl;
/** region within editor */
@@ -337,17 +337,17 @@ typedef enum eAnimFilter_Flags {
/* 'Object' channels */
#define SEL_OBJC(base) (CHECK_TYPE_INLINE(base, Base *), ((base->flag & SELECT)))
#define EXPANDED_OBJC(ob) \
- (CHECK_TYPE_INLINE(ob, Object *), ((ob->nlaflag & OB_ADS_COLLAPSED) == 0))
+ (CHECK_TYPE_INLINE(ob, Object *), (((ob)->nlaflag & OB_ADS_COLLAPSED) == 0))
/* 'Sub-object' channels (flags stored in Data block) */
#define FILTER_SKE_OBJD(key) (CHECK_TYPE_INLINE(key, Key *), ((key->flag & KEY_DS_EXPAND)))
#define FILTER_MAT_OBJD(ma) (CHECK_TYPE_INLINE(ma, Material *), ((ma->flag & MA_DS_EXPAND)))
#define FILTER_LAM_OBJD(la) (CHECK_TYPE_INLINE(la, Light *), ((la->flag & LA_DS_EXPAND)))
#define FILTER_CAM_OBJD(ca) (CHECK_TYPE_INLINE(ca, Camera *), ((ca->flag & CAM_DS_EXPAND)))
#define FILTER_CACHEFILE_OBJD(cf) \
- (CHECK_TYPE_INLINE(cf, CacheFile *), ((cf->flag & CACHEFILE_DS_EXPAND)))
+ (CHECK_TYPE_INLINE(cf, CacheFile *), (((cf)->flag & CACHEFILE_DS_EXPAND)))
#define FILTER_CUR_OBJD(cu) (CHECK_TYPE_INLINE(cu, Curve *), ((cu->flag & CU_DS_EXPAND)))
#define FILTER_PART_OBJD(part) \
- (CHECK_TYPE_INLINE(part, ParticleSettings *), ((part->flag & PART_DS_EXPAND)))
+ (CHECK_TYPE_INLINE(part, ParticleSettings *), (((part)->flag & PART_DS_EXPAND)))
#define FILTER_MBALL_OBJD(mb) (CHECK_TYPE_INLINE(mb, MetaBall *), ((mb->flag2 & MB_DS_EXPAND)))
#define FILTER_ARM_OBJD(arm) (CHECK_TYPE_INLINE(arm, bArmature *), ((arm->flag & ARM_DS_EXPAND)))
#define FILTER_MESH_OBJD(me) (CHECK_TYPE_INLINE(me, Mesh *), ((me->flag & ME_DS_EXPAND)))
@@ -358,7 +358,7 @@ typedef enum eAnimFilter_Flags {
#define FILTER_VOLUME_OBJD(vo) (CHECK_TYPE_INLINE(vo, Volume *), ((vo->flag & VO_DS_EXPAND)))
/* Variable use expanders */
#define FILTER_NTREE_DATA(ntree) \
- (CHECK_TYPE_INLINE(ntree, bNodeTree *), ((ntree->flag & NTREE_DS_EXPAND)))
+ (CHECK_TYPE_INLINE(ntree, bNodeTree *), (((ntree)->flag & NTREE_DS_EXPAND)))
#define FILTER_TEX_DATA(tex) (CHECK_TYPE_INLINE(tex, Tex *), ((tex->flag & TEX_DS_EXPAND)))
/* 'Sub-object/Action' channels (flags stored in Action) */
@@ -369,11 +369,11 @@ typedef enum eAnimFilter_Flags {
/* Actions (also used for Dopesheet) */
/* Action Channel Group */
-#define EDITABLE_AGRP(agrp) ((agrp->flag & AGRP_PROTECTED) == 0)
+#define EDITABLE_AGRP(agrp) (((agrp)->flag & AGRP_PROTECTED) == 0)
#define EXPANDED_AGRP(ac, agrp) \
- (((!(ac) || ((ac)->spacetype != SPACE_GRAPH)) && (agrp->flag & AGRP_EXPANDED)) || \
- (((ac) && ((ac)->spacetype == SPACE_GRAPH)) && (agrp->flag & AGRP_EXPANDED_G)))
-#define SEL_AGRP(agrp) ((agrp->flag & AGRP_SELECTED) || (agrp->flag & AGRP_ACTIVE))
+ (((!(ac) || ((ac)->spacetype != SPACE_GRAPH)) && ((agrp)->flag & AGRP_EXPANDED)) || \
+ (((ac) && ((ac)->spacetype == SPACE_GRAPH)) && ((agrp)->flag & AGRP_EXPANDED_G)))
+#define SEL_AGRP(agrp) (((agrp)->flag & AGRP_SELECTED) || ((agrp)->flag & AGRP_ACTIVE))
/* F-Curve Channels */
#define EDITABLE_FCU(fcu) ((fcu->flag & FCURVE_PROTECTED) == 0)
#define SEL_FCU(fcu) (fcu->flag & FCURVE_SELECTED)
@@ -433,7 +433,8 @@ typedef enum eAnimFilter_Flags {
#define NLACHANNEL_FIRST_TOP(ac) \
(UI_view2d_scale_get_y(&(ac)->region->v2d) * -UI_TIME_SCRUB_MARGIN_Y - NLACHANNEL_SKIP)
#define NLACHANNEL_HEIGHT(snla) \
- ((snla && (snla->flag & SNLA_NOSTRIPCURVES)) ? (0.8f * U.widget_unit) : (1.2f * U.widget_unit))
+ (((snla) && ((snla)->flag & SNLA_NOSTRIPCURVES)) ? (0.8f * U.widget_unit) : \
+ (1.2f * U.widget_unit))
#define NLACHANNEL_SKIP (0.1f * U.widget_unit)
#define NLACHANNEL_STEP(snla) (NLACHANNEL_HEIGHT(snla) + NLACHANNEL_SKIP)
/* Additional offset to give some room at the end. */
@@ -840,7 +841,7 @@ void ED_animedit_unlink_action(struct bContext *C,
bool force_delete);
/* Drivers Editor - Utility to set up UI correctly */
-void ED_drivers_editor_init(struct bContext *C, struct ScrArea *sa);
+void ED_drivers_editor_init(struct bContext *C, struct ScrArea *area);
/* ************************************************ */
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 40f5cade0d5..102c0dc0659 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -134,7 +134,7 @@ typedef struct EditBone {
(((arm)->layer & (ebone)->layer) && !((ebone)->flag & BONE_HIDDEN_A)))
#define EBONE_SELECTABLE(arm, ebone) \
- (EBONE_VISIBLE(arm, ebone) && !(ebone->flag & BONE_UNSELECTABLE))
+ (EBONE_VISIBLE(arm, ebone) && !((ebone)->flag & BONE_UNSELECTABLE))
#define EBONE_EDITABLE(ebone) \
(CHECK_TYPE_INLINE(ebone, EditBone *), \
@@ -187,6 +187,10 @@ struct Object *ED_armature_object_and_ebone_from_select_buffer(struct Object **o
uint objects_len,
int hit,
struct EditBone **r_ebone);
+struct Base *ED_armature_base_and_pchan_from_select_buffer(struct Base **bases,
+ uint bases_len,
+ int hit,
+ struct bPoseChannel **r_pchan);
struct Base *ED_armature_base_and_bone_from_select_buffer(struct Base **bases,
uint bases_len,
int hit,
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 511e892f29a..d63353d3886 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -88,20 +88,20 @@ struct bGPdata *ED_gpencil_data_get_active(const struct bContext *C);
struct bGPdata *ED_gpencil_data_get_active_evaluated(const struct bContext *C);
/* Context independent (i.e. each required part is passed in instead) */
-struct bGPdata **ED_gpencil_data_get_pointers_direct(struct ScrArea *sa,
+struct bGPdata **ED_gpencil_data_get_pointers_direct(struct ScrArea *area,
struct Object *ob,
struct PointerRNA *r_ptr);
-struct bGPdata *ED_gpencil_data_get_active_direct(struct ScrArea *sa, struct Object *ob);
+struct bGPdata *ED_gpencil_data_get_active_direct(struct ScrArea *area, struct Object *ob);
struct bGPdata *ED_annotation_data_get_active(const struct bContext *C);
struct bGPdata **ED_annotation_data_get_pointers(const struct bContext *C,
struct PointerRNA *r_ptr);
struct bGPdata **ED_annotation_data_get_pointers_direct(struct ID *screen_id,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct Scene *scene,
struct PointerRNA *r_ptr);
struct bGPdata *ED_annotation_data_get_active_direct(struct ID *screen_id,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct Scene *scene);
bool ED_gpencil_data_owner_is_annotation(struct PointerRNA *owner_ptr);
@@ -111,7 +111,7 @@ bool ED_gpencil_has_keyframe_v3d(struct Scene *scene, struct Object *ob, int cfr
/* ----------- Stroke Editing Utilities ---------------- */
-bool ED_gpencil_stroke_can_use_direct(const struct ScrArea *sa, const struct bGPDstroke *gps);
+bool ED_gpencil_stroke_can_use_direct(const struct ScrArea *area, const struct bGPDstroke *gps);
bool ED_gpencil_stroke_can_use(const struct bContext *C, const struct bGPDstroke *gps);
bool ED_gpencil_stroke_color_use(struct Object *ob,
const struct bGPDlayer *gpl,
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 6cac3e60531..4225ecc6f3d 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -198,7 +198,7 @@ typedef struct KeyingSetInfo {
cbKeyingSet_Generate generate;
/* RNA integration */
- struct ExtensionRNA ext;
+ struct ExtensionRNA rna_ext;
} KeyingSetInfo;
/* -------- */
@@ -430,14 +430,14 @@ void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const ch
/* Auto-Keying macros for use by various tools */
/* 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))
+ ((scene) ? ((scene)->toolsettings->autokey_mode & AUTOKEY_ON) : (U.autokey_mode & AUTOKEY_ON))
/* check the mode for auto-keyframing (per scene takes precedence) */
#define IS_AUTOKEY_MODE(scene, mode) \
- ((scene) ? (scene->toolsettings->autokey_mode == AUTOKEY_MODE_##mode) : \
+ ((scene) ? ((scene)->toolsettings->autokey_mode == AUTOKEY_MODE_##mode) : \
(U.autokey_mode == AUTOKEY_MODE_##mode))
/* check if a flag is set for auto-keyframing (per scene takes precedence) */
#define IS_AUTOKEY_FLAG(scene, flag) \
- ((scene) ? ((scene->toolsettings->autokey_flag & AUTOKEY_FLAG_##flag) || \
+ ((scene) ? (((scene)->toolsettings->autokey_flag & AUTOKEY_FLAG_##flag) || \
(U.autokey_flag & AUTOKEY_FLAG_##flag)) : \
(U.autokey_flag & AUTOKEY_FLAG_##flag))
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h
index 7d314c0c462..5aafc0702da 100644
--- a/source/blender/editors/include/ED_mask.h
+++ b/source/blender/editors/include/ED_mask.h
@@ -43,22 +43,25 @@ void ED_keymap_mask(struct wmKeyConfig *keyconf);
void ED_operatormacros_mask(void);
/* mask_query.c */
-void ED_mask_get_size(struct ScrArea *sa, int *width, int *height);
-void ED_mask_zoom(struct ScrArea *sa, struct ARegion *region, float *zoomx, float *zoomy);
-void ED_mask_get_aspect(struct ScrArea *sa, struct ARegion *region, float *aspx, float *aspy);
+void ED_mask_get_size(struct ScrArea *area, int *width, int *height);
+void ED_mask_zoom(struct ScrArea *area, struct ARegion *region, float *zoomx, float *zoomy);
+void ED_mask_get_aspect(struct ScrArea *area, struct ARegion *region, float *aspx, float *aspy);
-void ED_mask_pixelspace_factor(struct ScrArea *sa,
+void ED_mask_pixelspace_factor(struct ScrArea *area,
struct ARegion *region,
float *scalex,
float *scaley);
-void ED_mask_mouse_pos(struct ScrArea *sa, struct ARegion *region, const int mval[2], float co[2]);
+void ED_mask_mouse_pos(struct ScrArea *area,
+ struct ARegion *region,
+ const int mval[2],
+ float co[2]);
void ED_mask_point_pos(
- struct ScrArea *sa, struct ARegion *region, float x, float y, float *xr, float *yr);
+ struct ScrArea *area, struct ARegion *region, float x, float y, float *xr, float *yr);
void ED_mask_point_pos__reverse(
- struct ScrArea *sa, struct ARegion *region, float x, float y, float *xr, float *yr);
+ struct ScrArea *area, struct ARegion *region, float x, float y, float *xr, float *yr);
-void ED_mask_cursor_location_get(struct ScrArea *sa, float cursor[2]);
+void ED_mask_cursor_location_get(struct ScrArea *area, float cursor[2]);
bool ED_mask_selected_minmax(const struct bContext *C, float min[2], float max[2]);
/* mask_draw.c */
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 6d3396bb393..7f69bcb25cd 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -450,9 +450,19 @@ int join_mesh_exec(struct bContext *C, struct wmOperator *op);
int join_mesh_shapes_exec(struct bContext *C, struct wmOperator *op);
/* mirror lookup api */
-int ED_mesh_mirror_spatial_table(
- struct Object *ob, struct BMEditMesh *em, struct Mesh *me_eval, const float co[3], char mode);
-int ED_mesh_mirror_topo_table(struct Object *ob, struct Mesh *me_eval, char mode);
+/* Spatial Mirror */
+void ED_mesh_mirror_spatial_table_begin(struct Object *ob,
+ struct BMEditMesh *em,
+ struct Mesh *me_eval);
+void ED_mesh_mirror_spatial_table_end(struct Object *ob);
+int ED_mesh_mirror_spatial_table_lookup(struct Object *ob,
+ struct BMEditMesh *em,
+ struct Mesh *me_eval,
+ const float co[3]);
+
+/* Topology Mirror */
+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
diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h
index ae2b4989069..7a1f64b61d4 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -86,8 +86,8 @@ void ED_node_sort(struct bNodeTree *ntree);
float ED_node_grid_size(void);
/* node_relationships.c */
-void ED_node_link_intersect_test(struct ScrArea *sa, int test);
-void ED_node_link_insert(struct Main *bmain, struct ScrArea *sa);
+void ED_node_link_intersect_test(struct ScrArea *area, int test);
+void ED_node_link_insert(struct Main *bmain, struct ScrArea *area);
/* node_edit.c */
void ED_node_set_tree_type(struct SpaceNode *snode, struct bNodeTreeType *typeinfo);
diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h
index 0645b256a15..f03739c74c4 100644
--- a/source/blender/editors/include/ED_render.h
+++ b/source/blender/editors/include/ED_render.h
@@ -48,8 +48,8 @@ void ED_operatortypes_render(void);
/* render_update.c */
void ED_render_engine_changed(struct Main *bmain);
-void ED_render_engine_area_exit(struct Main *bmain, struct ScrArea *sa);
-void ED_render_view_layer_changed(struct Main *bmain, struct bScreen *sc);
+void ED_render_engine_area_exit(struct Main *bmain, struct ScrArea *area);
+void ED_render_view_layer_changed(struct Main *bmain, struct bScreen *screen);
/* Callbacks handling data update events coming from depsgraph. */
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 0785b0e97f7..43f3a578bfe 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -63,14 +63,14 @@ struct wmWindowManager;
/* regions */
void ED_region_do_listen(struct wmWindow *win,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmNotifier *note,
const Scene *scene);
void ED_region_do_layout(struct bContext *C, struct ARegion *region);
void ED_region_do_draw(struct bContext *C, struct ARegion *region);
void ED_region_exit(struct bContext *C, struct ARegion *region);
-void ED_region_remove(struct bContext *C, struct ScrArea *sa, struct ARegion *region);
+void ED_region_remove(struct bContext *C, struct ScrArea *area, struct ARegion *region);
void ED_region_pixelspace(struct ARegion *region);
void ED_region_update_rect(struct ARegion *region);
void ED_region_floating_initialize(struct ARegion *region);
@@ -104,14 +104,14 @@ void ED_region_header(const struct bContext *C, struct ARegion *region);
void ED_region_header_layout(const struct bContext *C, struct ARegion *region);
void ED_region_header_draw(const struct bContext *C, struct ARegion *region);
-void ED_region_cursor_set(struct wmWindow *win, struct ScrArea *sa, struct ARegion *region);
+void ED_region_cursor_set(struct wmWindow *win, struct ScrArea *area, struct ARegion *region);
void ED_region_toggle_hidden(struct bContext *C, struct ARegion *region);
void ED_region_visibility_change_update(struct bContext *C,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region);
/* screen_ops.c */
void ED_region_visibility_change_update_animated(struct bContext *C,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region);
void ED_region_info_draw(struct ARegion *region,
@@ -146,14 +146,14 @@ void ED_area_do_mgs_subscribe_for_tool_header(const struct bContext *C,
struct WorkSpace *workspace,
struct Scene *scene,
struct bScreen *screen,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus);
void ED_area_do_mgs_subscribe_for_tool_ui(const struct bContext *C,
struct WorkSpace *workspace,
struct Scene *scene,
struct bScreen *screen,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus);
@@ -162,7 +162,7 @@ void ED_region_message_subscribe(struct bContext *C,
struct WorkSpace *workspace,
struct Scene *scene,
struct bScreen *screen,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus);
@@ -171,21 +171,21 @@ void ED_spacetypes_keymap(struct wmKeyConfig *keyconf);
int ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *block, int yco);
/* areas */
-void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa);
-void ED_area_exit(struct bContext *C, struct ScrArea *sa);
+void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *area);
+void ED_area_exit(struct bContext *C, struct ScrArea *area);
int ED_screen_area_active(const struct bContext *C);
void ED_screen_global_areas_refresh(struct wmWindow *win);
void ED_screen_global_areas_sync(struct wmWindow *win);
-void ED_area_do_listen(struct wmWindow *win, ScrArea *sa, struct wmNotifier *note, Scene *scene);
-void ED_area_tag_redraw(ScrArea *sa);
-void ED_area_tag_redraw_no_rebuild(ScrArea *sa);
-void ED_area_tag_redraw_regiontype(ScrArea *sa, int type);
-void ED_area_tag_refresh(ScrArea *sa);
-void ED_area_do_refresh(struct bContext *C, ScrArea *sa);
-struct AZone *ED_area_azones_update(ScrArea *sa, const int mouse_xy[]);
-void ED_area_status_text(ScrArea *sa, const char *str);
-void ED_area_newspace(struct bContext *C, ScrArea *sa, int type, const bool skip_ar_exit);
-void ED_area_prevspace(struct bContext *C, ScrArea *sa);
+void ED_area_do_listen(struct wmWindow *win, ScrArea *area, struct wmNotifier *note, Scene *scene);
+void ED_area_tag_redraw(ScrArea *area);
+void ED_area_tag_redraw_no_rebuild(ScrArea *area);
+void ED_area_tag_redraw_regiontype(ScrArea *area, int type);
+void ED_area_tag_refresh(ScrArea *area);
+void ED_area_do_refresh(struct bContext *C, ScrArea *area);
+struct AZone *ED_area_azones_update(ScrArea *area, const int mouse_xy[]);
+void ED_area_status_text(ScrArea *area, const char *str);
+void ED_area_newspace(struct bContext *C, ScrArea *area, int type, const bool skip_region_exit);
+void ED_area_prevspace(struct bContext *C, ScrArea *area);
void ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2);
int ED_area_headersize(void);
int ED_area_header_alignment_or_fallback(const ScrArea *area, int fallback);
@@ -215,7 +215,7 @@ ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area);
#define ED_screen_verts_iter(win, screen, vert_name) \
for (ScrVert *vert_name = (win)->global_areas.vertbase.first ? \
(win)->global_areas.vertbase.first : \
- screen->vertbase.first; \
+ (screen)->vertbase.first; \
vert_name != NULL; \
vert_name = (vert_name == (win)->global_areas.vertbase.last) ? (screen)->vertbase.first : \
vert_name->next)
@@ -224,25 +224,25 @@ ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area);
void ED_screens_initialize(struct Main *bmain, struct wmWindowManager *wm);
void ED_screen_draw_edges(struct wmWindow *win);
void ED_screen_draw_join_shape(struct ScrArea *sa1, struct ScrArea *sa2);
-void ED_screen_draw_split_preview(struct ScrArea *sa, const int dir, const float fac);
+void ED_screen_draw_split_preview(struct ScrArea *area, const int dir, const float fac);
void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win);
void ED_screen_ensure_updated(struct wmWindowManager *wm,
struct wmWindow *win,
struct bScreen *screen);
void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note);
-bool ED_screen_change(struct bContext *C, struct bScreen *sc);
+bool ED_screen_change(struct bContext *C, struct bScreen *screen);
void ED_screen_scene_change(struct bContext *C, struct wmWindow *win, struct Scene *scene);
void ED_screen_set_active_region(struct bContext *C, struct wmWindow *win, const int xy[2]);
void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen);
void ED_screen_animation_timer(struct bContext *C, int redraws, int sync, int enable);
void ED_screen_animation_timer_update(struct bScreen *screen, int redraws);
-void ED_screen_restore_temp_type(struct bContext *C, ScrArea *sa);
-ScrArea *ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type);
-void ED_screen_full_prevspace(struct bContext *C, ScrArea *sa);
-void ED_screen_full_restore(struct bContext *C, ScrArea *sa);
+void ED_screen_restore_temp_type(struct bContext *C, ScrArea *area);
+ScrArea *ED_screen_full_newspace(struct bContext *C, ScrArea *area, int type);
+void ED_screen_full_prevspace(struct bContext *C, ScrArea *area);
+void ED_screen_full_restore(struct bContext *C, ScrArea *area);
struct ScrArea *ED_screen_state_toggle(struct bContext *C,
struct wmWindow *win,
- struct ScrArea *sa,
+ struct ScrArea *area,
const short state);
ScrArea *ED_screen_temp_space_open(struct bContext *C,
const char *title,
@@ -422,7 +422,7 @@ void ED_region_generic_tools_region_message_subscribe(const struct bContext *C,
struct WorkSpace *workspace,
struct Scene *scene,
struct bScreen *screen,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus);
int ED_region_generic_tools_region_snap_size(const struct ARegion *region, int size, int axis);
@@ -442,15 +442,15 @@ bool ED_region_overlap_isect_xy_with_margin(const ARegion *region,
const int event_xy[2],
const int margin);
-bool ED_region_panel_category_gutter_calc_rect(const ARegion *region, rcti *r_ar_gutter);
+bool ED_region_panel_category_gutter_calc_rect(const ARegion *region, rcti *r_region_gutter);
bool ED_region_panel_category_gutter_isect_xy(const ARegion *region, const int event_xy[2]);
bool ED_region_contains_xy(const struct ARegion *region, const int event_xy[2]);
/* interface_region_hud.c */
struct ARegionType *ED_area_type_hud(int space_type);
-void ED_area_type_hud_clear(struct wmWindowManager *wm, ScrArea *sa_keep);
-void ED_area_type_hud_ensure(struct bContext *C, struct ScrArea *sa);
+void ED_area_type_hud_clear(struct wmWindowManager *wm, ScrArea *area_keep);
+void ED_area_type_hud_ensure(struct bContext *C, struct ScrArea *area);
/* default keymaps, bitflags (matches order of evaluation). */
enum {
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index 8b4829446c3..1f2706957a7 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -48,7 +48,7 @@ bool ED_editors_flush_edits_for_object(struct Main *bmain, struct Object *ob);
bool ED_editors_flush_edits_ex(struct Main *bmain, bool for_render, bool check_needs_flush);
bool ED_editors_flush_edits(struct Main *bmain);
-void ED_spacedata_id_remap(struct ScrArea *sa,
+void ED_spacedata_id_remap(struct ScrArea *area,
struct SpaceLink *sl,
struct ID *old_id,
struct ID *new_id);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index bb065ee0008..668ca3c6437 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -560,10 +560,10 @@ bool edge_inside_circle(const float cent[2],
struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C);
bool ED_view3d_context_user_region(struct bContext *C,
struct View3D **r_v3d,
- struct ARegion **r_ar);
-bool ED_view3d_area_user_region(const struct ScrArea *sa,
+ struct ARegion **r_region);
+bool ED_view3d_area_user_region(const struct ScrArea *area,
const struct View3D *v3d,
- struct ARegion **r_ar);
+ struct ARegion **r_region);
bool ED_operator_rv3d_user_region_poll(struct bContext *C);
void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d);
@@ -600,7 +600,7 @@ void ED_view3d_draw_setup_view(const struct wmWindowManager *wm,
struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]);
struct Object *ED_view3d_give_object_under_cursor(struct bContext *C, const int mval[2]);
bool ED_view3d_is_object_under_cursor(struct bContext *C, const int mval[2]);
-void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *region, bool do_clip);
+void ED_view3d_quadview_update(struct ScrArea *area, struct ARegion *region, bool do_clip);
void ED_view3d_update_viewmat(struct Depsgraph *depsgraph,
const struct Scene *scene,
struct View3D *v3d,
@@ -702,7 +702,7 @@ void ED_view3d_operator_properties_viewmat_get(struct wmOperator *op,
/* render */
void ED_view3d_stop_render_preview(struct wmWindowManager *wm, struct ARegion *region);
-void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa);
+void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *area);
#define XRAY_ALPHA(v3d) \
(((v3d)->shading.type == OB_WIRE) ? (v3d)->shading.xray_alpha_wire : (v3d)->shading.xray_alpha)
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 1fa6e5b12c1..eb134646649 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1650,14 +1650,14 @@ void UI_panels_end(const struct bContext *C, struct ARegion *region, int *r_x, i
void UI_panels_draw(const struct bContext *C, struct ARegion *region);
struct Panel *UI_panel_find_by_type(struct ListBase *lb, struct PanelType *pt);
-struct Panel *UI_panel_begin(struct ScrArea *sa,
+struct Panel *UI_panel_begin(struct ScrArea *area,
struct ARegion *region,
struct ListBase *lb,
uiBlock *block,
struct PanelType *pt,
- struct Panel *pa,
+ struct Panel *panel,
bool *r_open);
-void UI_panel_end(const struct ScrArea *sa,
+void UI_panel_end(const struct ScrArea *area,
const struct ARegion *region,
uiBlock *block,
int width,
@@ -1665,7 +1665,7 @@ void UI_panel_end(const struct ScrArea *sa,
bool open);
void UI_panels_scale(struct ARegion *region, float new_width);
void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y);
-int UI_panel_size_y(const struct Panel *pa);
+int UI_panel_size_y(const struct Panel *panel);
bool UI_panel_category_is_visible(const struct ARegion *region);
void UI_panel_category_add(struct ARegion *region, const char *name);
@@ -2470,7 +2470,7 @@ struct ARegion *UI_tooltip_create_from_button(struct bContext *C,
uiBut *but,
bool is_label);
struct ARegion *UI_tooltip_create_from_gizmo(struct bContext *C, struct wmGizmo *gz);
-void UI_tooltip_free(struct bContext *C, struct bScreen *sc, struct ARegion *region);
+void UI_tooltip_free(struct bContext *C, struct bScreen *screen, struct ARegion *region);
/* How long before a tool-tip shows. */
#define UI_TOOLTIP_DELAY 0.5
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index ff9719d4674..d4db1b14074 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -119,7 +119,7 @@ void UI_view2d_region_reinit(struct View2D *v2d, short type, int winx, int winy)
void UI_view2d_curRect_validate(struct View2D *v2d);
void UI_view2d_curRect_reset(struct View2D *v2d);
-void UI_view2d_sync(struct bScreen *screen, struct ScrArea *sa, struct View2D *v2dcur, int flag);
+void UI_view2d_sync(struct bScreen *screen, struct ScrArea *area, struct View2D *v2dcur, int flag);
void UI_view2d_totRect_set(struct View2D *v2d, int width, int height);
void UI_view2d_totRect_set_resize(struct View2D *v2d, int width, int height, bool resize);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 41b7683dff7..339124db355 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -44,7 +44,6 @@
#include "BLI_utildefines.h"
-#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_main.h"
@@ -262,7 +261,7 @@ void ui_region_to_window(const ARegion *region, int *x, int *y)
static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block)
{
int sepr_flex_len = 0;
- for (uiBut *but = block->buttons.first; but; but = but->next) {
+ LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
if (but->type == UI_BTYPE_SEPR_SPACER) {
sepr_flex_len++;
}
@@ -284,7 +283,7 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block)
/* We could get rid of this loop if we agree on a max number of spacer */
int *spacers_pos = alloca(sizeof(*spacers_pos) * (size_t)sepr_flex_len);
int i = 0;
- for (uiBut *but = block->buttons.first; but; but = but->next) {
+ LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
if (but->type == UI_BTYPE_SEPR_SPACER) {
ui_but_to_pixelrect(&rect, region, block, but);
spacers_pos[i] = rect.xmax + UI_HEADER_OFFSET;
@@ -295,7 +294,7 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block)
const float segment_width = region_width / (float)sepr_flex_len;
float offset = 0, remaining_space = region_width - buttons_width;
i = 0;
- for (uiBut *but = block->buttons.first; but; but = but->next) {
+ LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
BLI_rctf_translate(&but->rect, offset, 0);
if (but->type == UI_BTYPE_SEPR_SPACER) {
/* How much the next block overlap with the current segment */
@@ -899,7 +898,7 @@ bool UI_but_active_only(const bContext *C, ARegion *region, uiBlock *block, uiBu
bool UI_block_active_only_flagged_buttons(const bContext *C, ARegion *region, uiBlock *block)
{
bool done = false;
- for (uiBut *but = block->buttons.first; but; but = but->next) {
+ LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
if (but->flag & UI_BUT_ACTIVATE_ON_INIT) {
but->flag &= ~UI_BUT_ACTIVATE_ON_INIT;
if (ui_but_is_editable(but)) {
@@ -914,7 +913,7 @@ bool UI_block_active_only_flagged_buttons(const bContext *C, ARegion *region, ui
if (done) {
/* Run this in a second pass since it's possible activating the button
* removes the buttons being looped over. */
- for (uiBut *but = block->buttons.first; but; but = but->next) {
+ LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
but->flag &= ~UI_BUT_ACTIVATE_ON_INIT;
}
}
@@ -971,7 +970,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
/* 2 Passes, on for first letter only, second for any letter if first fails
* fun first pass on all buttons so first word chars always get first priority */
- for (uiBut *but = block->buttons.first; but; but = but->next) {
+ LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
if (!ELEM(but->type,
UI_BTYPE_BUT,
UI_BTYPE_BUT_MENU,
@@ -1664,7 +1663,7 @@ static void ui_but_predefined_extra_operator_icons_add(uiBut *but)
}
if (optype) {
- for (uiButExtraOpIcon *op_icon = but->extra_op_icons.first; op_icon; op_icon = op_icon->next) {
+ LISTBASE_FOREACH (uiButExtraOpIcon *, op_icon, &but->extra_op_icons) {
if ((op_icon->optype_params->optype == optype) && (op_icon->icon == icon)) {
/* Don't add the same operator icon twice (happens if button is kept alive while active).
*/
@@ -1935,7 +1934,7 @@ static void ui_block_message_subscribe(ARegion *region, struct wmMsgBus *mbus, u
{
uiBut *but_prev = NULL;
/* possibly we should keep the region this block is contained in? */
- for (uiBut *but = block->buttons.first; but; but = but->next) {
+ LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
if (but->rnapoin.type && but->rnaprop) {
/* quick check to avoid adding buttons representing a vector, multiple times. */
if ((but_prev && (but_prev->rnaprop == but->rnaprop) &&
@@ -1960,7 +1959,7 @@ static void ui_block_message_subscribe(ARegion *region, struct wmMsgBus *mbus, u
void UI_region_message_subscribe(ARegion *region, struct wmMsgBus *mbus)
{
- for (uiBlock *block = region->uiblocks.first; block; block = block->next) {
+ LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
ui_block_message_subscribe(region, mbus, block);
}
}
@@ -3275,7 +3274,7 @@ void UI_blocklist_update_window_matrix(const bContext *C, const ListBase *lb)
ARegion *region = CTX_wm_region(C);
wmWindow *window = CTX_wm_window(C);
- for (uiBlock *block = lb->first; block; block = block->next) {
+ LISTBASE_FOREACH (uiBlock *, block, lb) {
if (block->active) {
ui_update_window_matrix(window, region, block);
}
@@ -3284,7 +3283,7 @@ void UI_blocklist_update_window_matrix(const bContext *C, const ListBase *lb)
void UI_blocklist_draw(const bContext *C, const ListBase *lb)
{
- for (uiBlock *block = lb->first; block; block = block->next) {
+ LISTBASE_FOREACH (uiBlock *, block, lb) {
if (block->active) {
UI_block_draw(C, block);
}
@@ -6608,8 +6607,8 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
}
else {
/* Not all menus are from Python. */
- if (mt->ext.srna) {
- const char *t = RNA_struct_ui_description(mt->ext.srna);
+ if (mt->rna_ext.srna) {
+ const char *t = RNA_struct_ui_description(mt->rna_ext.srna);
if (t && t[0]) {
tmp = BLI_strdup(t);
}
@@ -6626,7 +6625,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
}
else {
/* Not all panels are from Python. */
- if (pt->ext.srna) {
+ if (pt->rna_ext.srna) {
/* Panels don't yet have descriptions, this may be added. */
}
}
@@ -6645,7 +6644,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) {
MenuType *mt = UI_but_menutype_get(but);
if (mt) {
- _tmp = RNA_struct_translation_context(mt->ext.srna);
+ _tmp = RNA_struct_translation_context(mt->rna_ext.srna);
}
}
if (BLT_is_default_context(_tmp)) {
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index 76107d190ba..5245b724da4 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -1231,9 +1231,9 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
/**
* menu to show when right clicking on the panel header
*/
-void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *pa)
+void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *panel)
{
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
const bool has_panel_category = UI_panel_category_is_visible(region);
const bool any_item_visible = has_panel_category;
PointerRNA ptr;
@@ -1243,11 +1243,11 @@ void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *pa)
if (!any_item_visible) {
return;
}
- if (pa->type->parent != NULL) {
+ if (panel->type->parent != NULL) {
return;
}
- RNA_pointer_create(&sc->id, &RNA_Panel, pa, &ptr);
+ RNA_pointer_create(&screen->id, &RNA_Panel, panel, &ptr);
pup = UI_popup_menu_begin(C, IFACE_("Panel"), ICON_NONE);
layout = UI_popup_menu_layout(pup);
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index 5fd1cef6451..817cb44db29 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -139,8 +139,8 @@ void eyedropper_draw_cursor_text(const struct bContext *C, const ARegion *region
uiBut *eyedropper_get_property_button_under_mouse(bContext *C, const wmEvent *event)
{
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->x, event->y);
- ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_ANY, event->x, event->y);
+ ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->x, event->y);
+ ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_ANY, event->x, event->y);
uiBut *but = ui_but_find_mouse_over(region, event);
diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c
index 372fd841bc1..7527a1e0662 100644
--- a/source/blender/editors/interface/interface_eyedropper_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_color.c
@@ -137,15 +137,15 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3])
/* we could use some clever */
Main *bmain = CTX_data_main(C);
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my);
+ ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my);
const char *display_device = CTX_data_scene(C)->display_settings.display_device;
struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
- if (sa) {
- if (sa->spacetype == SPACE_IMAGE) {
- ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my);
+ if (area) {
+ if (area->spacetype == SPACE_IMAGE) {
+ ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my);
if (region) {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
if (ED_space_image_color_sample(sima, region, mval, r_col)) {
@@ -153,10 +153,10 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3])
}
}
}
- else if (sa->spacetype == SPACE_NODE) {
- ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my);
+ else if (area->spacetype == SPACE_NODE) {
+ ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my);
if (region) {
- SpaceNode *snode = sa->spacedata.first;
+ SpaceNode *snode = area->spacedata.first;
int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
if (ED_space_node_color_sample(bmain, snode, region, mval, r_col)) {
@@ -164,10 +164,10 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3])
}
}
}
- else if (sa->spacetype == SPACE_CLIP) {
- ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my);
+ else if (area->spacetype == SPACE_CLIP) {
+ ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my);
if (region) {
- SpaceClip *sc = sa->spacedata.first;
+ SpaceClip *sc = area->spacedata.first;
int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
if (ED_space_clip_color_sample(sc, region, mval, r_col)) {
diff --git a/source/blender/editors/interface/interface_eyedropper_datablock.c b/source/blender/editors/interface/interface_eyedropper_datablock.c
index 93599b8727a..d9c77c26941 100644
--- a/source/blender/editors/interface/interface_eyedropper_datablock.c
+++ b/source/blender/editors/interface/interface_eyedropper_datablock.c
@@ -152,27 +152,27 @@ static void datadropper_id_sample_pt(bContext *C, DataDropper *ddr, int mx, int
{
/* we could use some clever */
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = BKE_screen_find_area_xy(screen, -1, mx, my);
+ ScrArea *area = BKE_screen_find_area_xy(screen, -1, mx, my);
ScrArea *area_prev = CTX_wm_area(C);
- ARegion *ar_prev = CTX_wm_region(C);
+ ARegion *region_prev = CTX_wm_region(C);
ddr->name[0] = '\0';
- if (sa) {
- if (ELEM(sa->spacetype, SPACE_VIEW3D, SPACE_OUTLINER)) {
- ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my);
+ if (area) {
+ if (ELEM(area->spacetype, SPACE_VIEW3D, SPACE_OUTLINER)) {
+ ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my);
if (region) {
const int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
Base *base;
- CTX_wm_area_set(C, sa);
+ CTX_wm_area_set(C, area);
CTX_wm_region_set(C, region);
/* grr, always draw else we leave stale text */
ED_region_tag_redraw(region);
- if (sa->spacetype == SPACE_VIEW3D) {
+ if (area->spacetype == SPACE_VIEW3D) {
base = ED_view3d_give_base_under_cursor(C, mval);
}
else {
@@ -208,7 +208,7 @@ static void datadropper_id_sample_pt(bContext *C, DataDropper *ddr, int mx, int
}
CTX_wm_area_set(C, area_prev);
- CTX_wm_region_set(C, ar_prev);
+ CTX_wm_region_set(C, region_prev);
}
/* sets the ID, returns success */
@@ -250,11 +250,11 @@ static void datadropper_set_draw_callback_region(bContext *C,
const int my)
{
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = BKE_screen_find_area_xy(screen, -1, mx, my);
+ ScrArea *area = BKE_screen_find_area_xy(screen, -1, mx, my);
- if (sa) {
+ if (area) {
/* If spacetype changed */
- if (sa->spacetype != ddr->cursor_area->spacetype) {
+ if (area->spacetype != ddr->cursor_area->spacetype) {
/* Remove old callback */
ED_region_draw_cb_exit(ddr->art, ddr->draw_handle_pixel);
@@ -263,9 +263,9 @@ static void datadropper_set_draw_callback_region(bContext *C,
ED_region_tag_redraw(region);
/* Set draw callback in new region */
- ARegionType *art = BKE_regiontype_from_id(sa->type, RGN_TYPE_WINDOW);
+ ARegionType *art = BKE_regiontype_from_id(area->type, RGN_TYPE_WINDOW);
- ddr->cursor_area = sa;
+ ddr->cursor_area = area;
ddr->art = art;
ddr->draw_handle_pixel = ED_region_draw_cb_activate(
art, datadropper_draw_cb, ddr, REGION_DRAW_POST_PIXEL);
diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c
index a5e60adec55..907da917e75 100644
--- a/source/blender/editors/interface/interface_eyedropper_depth.c
+++ b/source/blender/editors/interface/interface_eyedropper_depth.c
@@ -156,27 +156,27 @@ static void depthdropper_depth_sample_pt(
{
/* we could use some clever */
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my);
+ ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my);
Scene *scene = CTX_data_scene(C);
ScrArea *area_prev = CTX_wm_area(C);
- ARegion *ar_prev = CTX_wm_region(C);
+ ARegion *region_prev = CTX_wm_region(C);
ddr->name[0] = '\0';
- if (sa) {
- if (sa->spacetype == SPACE_VIEW3D) {
- ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my);
+ if (area) {
+ if (area->spacetype == SPACE_VIEW3D) {
+ ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my);
if (region) {
struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- View3D *v3d = sa->spacedata.first;
+ View3D *v3d = area->spacedata.first;
RegionView3D *rv3d = region->regiondata;
/* weak, we could pass in some reference point */
const float *view_co = v3d->camera ? v3d->camera->obmat[3] : rv3d->viewinv[3];
const int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
float co[3];
- CTX_wm_area_set(C, sa);
+ CTX_wm_area_set(C, area);
CTX_wm_region_set(C, region);
/* grr, always draw else we leave stale text */
@@ -209,7 +209,7 @@ static void depthdropper_depth_sample_pt(
}
CTX_wm_area_set(C, area_prev);
- CTX_wm_region_set(C, ar_prev);
+ CTX_wm_region_set(C, region_prev);
}
/* sets the sample depth RGB, maintaining A */
diff --git a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
index 2944186c701..3d32ede60c2 100644
--- a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
@@ -28,6 +28,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLT_translation.h"
@@ -211,7 +212,7 @@ static void eyedropper_add_palette_color(bContext *C, float col_conv[4])
}
/* Check if the color exist already. */
Palette *palette = paint->palette;
- for (PaletteColor *palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
+ LISTBASE_FOREACH (PaletteColor *, palcolor, &palette->colors) {
if (compare_v3v3(palcolor->rgb, col_conv, 0.01f)) {
return;
}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index d378613c035..2b2d91f3a32 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1272,7 +1272,7 @@ static void ui_multibut_states_create(uiBut *but_active, uiHandleButtonData *dat
data->multi_data.bs_mbuts = UI_butstore_create(but_active->block);
- for (uiBut *but = but_active->block->buttons.first; but; but = but->next) {
+ LISTBASE_FOREACH (uiBut *, but, &but_active->block->buttons) {
if (but->flag & UI_BUT_DRAG_MULTI) {
ui_multibut_add(data, but);
}
@@ -1874,7 +1874,7 @@ static bool ui_but_drag_init(bContext *C,
#ifdef USE_DRAG_TOGGLE
if (ui_drag_toggle_but_is_supported(but)) {
uiDragToggleHandle *drag_info = MEM_callocN(sizeof(*drag_info), __func__);
- ARegion *ar_prev;
+ ARegion *region_prev;
/* call here because regular mouse-up event wont run,
* typically 'button_activate_exit()' handles this */
@@ -1887,7 +1887,7 @@ static bool ui_but_drag_init(bContext *C,
copy_v2_v2_int(drag_info->xy_last, &event->x);
/* needed for toggle drag on popups */
- ar_prev = CTX_wm_region(C);
+ region_prev = CTX_wm_region(C);
CTX_wm_region_set(C, data->region);
WM_event_add_ui_handler(C,
@@ -1897,7 +1897,7 @@ static bool ui_but_drag_init(bContext *C,
drag_info,
WM_HANDLER_BLOCKING);
- CTX_wm_region_set(C, ar_prev);
+ CTX_wm_region_set(C, region_prev);
/* Initialize alignment for single row/column regions,
* otherwise we use the relative position of the first other button dragged over. */
@@ -1906,13 +1906,13 @@ static bool ui_but_drag_init(bContext *C,
RGN_TYPE_HEADER,
RGN_TYPE_TOOL_HEADER,
RGN_TYPE_FOOTER)) {
- const int ar_alignment = RGN_ALIGN_ENUM_FROM_MASK(data->region->alignment);
+ const int region_alignment = RGN_ALIGN_ENUM_FROM_MASK(data->region->alignment);
int lock_axis = -1;
- if (ELEM(ar_alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
+ if (ELEM(region_alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
lock_axis = 0;
}
- else if (ELEM(ar_alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
+ else if (ELEM(region_alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
lock_axis = 1;
}
if (lock_axis != -1) {
@@ -7707,8 +7707,8 @@ void UI_but_tooltip_refresh(bContext *C, uiBut *but)
{
uiHandleButtonData *data = but->active;
if (data) {
- bScreen *sc = WM_window_get_active_screen(data->window);
- if (sc->tool_tip && sc->tool_tip->region) {
+ bScreen *screen = WM_window_get_active_screen(data->window);
+ if (screen->tool_tip && screen->tool_tip->region) {
WM_tooltip_refresh(C, data->window);
}
}
@@ -7768,9 +7768,9 @@ static void button_tooltip_timer_reset(bContext *C, uiBut *but)
WM_tooltip_timer_init_ex(
C, data->window, data->area, data->region, ui_but_tooltip_init, delay);
if (is_label) {
- bScreen *sc = WM_window_get_active_screen(data->window);
- if (sc->tool_tip) {
- sc->tool_tip->pass = 1;
+ bScreen *screen = WM_window_get_active_screen(data->window);
+ if (screen->tool_tip) {
+ screen->tool_tip->pass = 1;
}
}
}
@@ -8056,11 +8056,11 @@ static void button_activate_init(bContext *C,
if (UI_but_has_tooltip_label(but)) {
/* Show a label for this button. */
- bScreen *sc = WM_window_get_active_screen(data->window);
+ bScreen *screen = WM_window_get_active_screen(data->window);
if ((PIL_check_seconds_timer() - WM_tooltip_time_closed()) < 0.1) {
WM_tooltip_immediate_init(C, CTX_wm_window(C), data->area, region, ui_but_tooltip_init);
- if (sc->tool_tip) {
- sc->tool_tip->pass = 1;
+ if (screen->tool_tip) {
+ screen->tool_tip->pass = 1;
}
}
}
@@ -8326,16 +8326,16 @@ void UI_context_active_but_prop_handle(bContext *C)
wmOperator *UI_context_active_operator_get(const struct bContext *C)
{
- ARegion *ar_ctx = CTX_wm_region(C);
+ ARegion *region_ctx = CTX_wm_region(C);
uiBlock *block;
/* background mode */
- if (ar_ctx == NULL) {
+ if (region_ctx == NULL) {
return NULL;
}
/* scan active regions ui */
- for (block = ar_ctx->uiblocks.first; block; block = block->next) {
+ for (block = region_ctx->uiblocks.first; block; block = block->next) {
if (block->ui_operator) {
return block->ui_operator;
}
@@ -8343,11 +8343,11 @@ wmOperator *UI_context_active_operator_get(const struct bContext *C)
/* scan popups */
{
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
ARegion *region;
- for (region = sc->regionbase.first; region; region = region->next) {
- if (region == ar_ctx) {
+ for (region = screen->regionbase.first; region; region = region->next) {
+ if (region == region_ctx) {
continue;
}
for (block = region->uiblocks.first; block; block = block->next) {
@@ -8470,10 +8470,10 @@ void ui_but_activate_event(bContext *C, ARegion *region, uiBut *but)
event.customdata = but;
event.customdatafree = false;
- ARegion *ar_ctx = CTX_wm_region(C);
+ ARegion *region_ctx = CTX_wm_region(C);
CTX_wm_region_set(C, region);
ui_do_button(C, but->block, but, &event);
- CTX_wm_region_set(C, ar_ctx);
+ CTX_wm_region_set(C, region_ctx);
}
/**
@@ -9241,7 +9241,7 @@ static void ui_menu_scroll_apply_offset_y(ARegion *region, uiBlock *block, float
if (dy < 0.0f) {
/* Stop at top item, extra 0.5 UI_UNIT_Y makes it snap nicer. */
float ymax = -FLT_MAX;
- for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
+ LISTBASE_FOREACH (uiBut *, bt, &block->buttons) {
ymax = max_ff(ymax, bt->rect.ymax);
}
if (ymax + dy - UI_UNIT_Y * 0.5f < block->rect.ymax - UI_MENU_SCROLL_PAD) {
@@ -9251,7 +9251,7 @@ static void ui_menu_scroll_apply_offset_y(ARegion *region, uiBlock *block, float
else {
/* Stop at bottom item, extra 0.5 UI_UNIT_Y makes it snap nicer. */
float ymin = FLT_MAX;
- for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
+ LISTBASE_FOREACH (uiBut *, bt, &block->buttons) {
ymin = min_ff(ymin, bt->rect.ymin);
}
if (ymin + dy + UI_UNIT_Y * 0.5f > block->rect.ymin + UI_MENU_SCROLL_PAD) {
@@ -9264,7 +9264,7 @@ static void ui_menu_scroll_apply_offset_y(ARegion *region, uiBlock *block, float
block->handle->scrolloffset += dy;
/* apply scroll offset */
- for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
+ LISTBASE_FOREACH (uiBut *, bt, &block->buttons) {
bt->rect.ymin += dy;
bt->rect.ymax += dy;
}
@@ -9345,7 +9345,7 @@ static bool ui_menu_scroll_step(ARegion *region, uiBlock *block, const int scrol
static void ui_region_auto_open_clear(ARegion *region)
{
- for (uiBlock *block = region->uiblocks.first; block; block = block->next) {
+ LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
block->auto_open = false;
}
}
@@ -10640,7 +10640,7 @@ static int ui_region_handler(bContext *C, const wmEvent *event, void *UNUSED(use
static void ui_region_handler_remove(bContext *C, void *UNUSED(userdata))
{
- bScreen *sc;
+ bScreen *screen;
ARegion *region;
region = CTX_wm_region(C);
@@ -10650,15 +10650,15 @@ static void ui_region_handler_remove(bContext *C, void *UNUSED(userdata))
UI_blocklist_free(C, &region->uiblocks);
- sc = CTX_wm_screen(C);
- if (sc == NULL) {
+ screen = CTX_wm_screen(C);
+ if (screen == NULL) {
return;
}
/* delayed apply callbacks, but not for screen level regions, those
* we rather do at the very end after closing them all, which will
* be done in ui_region_handler/window */
- if (BLI_findindex(&sc->regionbase, region) == -1) {
+ if (BLI_findindex(&screen->regionbase, region) == -1) {
ui_apply_but_funcs_after(C);
}
}
@@ -10984,7 +10984,7 @@ void UI_screen_free_active_but(const bContext *C, bScreen *screen)
ED_screen_areas_iter(win, screen, area)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
uiBut *but = ui_region_find_active_but(region);
if (but) {
uiHandleButtonData *data = but->active;
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index edc5087c8dd..084eb943665 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -759,11 +759,11 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf,
// blur alpha channel
const int write_offset = by * (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) + bx;
float alpha_accum = 0.0;
- unsigned int alpha_samples = 0;
+ uint alpha_samples = 0;
for (int ax = asx; ax < aex; ax++) {
for (int ay = asy; ay < aey; ay++) {
const int offset_read = (sy + ay) * buf->x + (sx + ax);
- unsigned int color_read = buf->rect[offset_read];
+ uint color_read = buf->rect[offset_read];
const float alpha_read = ((color_read & 0xff000000) >> 24) / 255.0;
alpha_accum += alpha_read;
alpha_samples += 1;
@@ -782,8 +782,8 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf,
const float border_srgb[4] = {
0, 0, 0, MIN2(1.0, blurred_alpha * border_sharpness) * border_intensity};
- const unsigned int color_read = buf->rect[offset_write];
- const unsigned char *orig_color = (unsigned char *)&color_read;
+ const uint color_read = buf->rect[offset_write];
+ const uchar *orig_color = (uchar *)&color_read;
float border_rgba[4];
float orig_rgba[4];
@@ -795,8 +795,8 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf,
blend_color_interpolate_float(dest_rgba, orig_rgba, border_rgba, 1.0 - orig_rgba[3]);
linearrgb_to_srgb_v4(dest_srgb, dest_rgba);
- unsigned int alpha_mask = ((unsigned int)(dest_srgb[3] * 255)) << 24;
- unsigned int cpack = rgb_to_cpack(dest_srgb[0], dest_srgb[1], dest_srgb[2]) | alpha_mask;
+ uint alpha_mask = ((uint)(dest_srgb[3] * 255)) << 24;
+ uint cpack = rgb_to_cpack(dest_srgb[0], dest_srgb[1], dest_srgb[2]) | alpha_mask;
result->rect[offset_write] = cpack;
}
}
@@ -1892,7 +1892,7 @@ static void icon_draw_size(float x,
mul_v4_fl(color, alpha);
float border_outset = 0.0;
- unsigned int border_texel = 0;
+ uint border_texel = 0;
#ifndef WITH_HEADLESS
if (with_border) {
const float scale = (float)ICON_GRID_W / (float)ICON_DEFAULT_WIDTH;
@@ -2015,8 +2015,8 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
Object *ob = CTX_data_active_object(C);
const EnumPropertyItem *items = NULL;
ePaintMode paint_mode = PAINT_MODE_INVALID;
- ScrArea *sa = CTX_wm_area(C);
- char space_type = sa->spacetype;
+ ScrArea *area = CTX_wm_area(C);
+ char space_type = area->spacetype;
/* Fallback to 3D view. */
if (space_type == SPACE_PROPERTIES) {
space_type = SPACE_VIEW3D;
@@ -2041,8 +2041,8 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
}
}
else if (space_type == SPACE_IMAGE) {
- if (sa->spacetype == space_type) {
- const SpaceImage *sima = sa->spacedata.first;
+ if (area->spacetype == space_type) {
+ const SpaceImage *sima = area->spacedata.first;
if (sima->mode == SI_MODE_PAINT) {
paint_mode = PAINT_MODE_TEXTURE_2D;
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 4a9c8a1ff54..942f19eb4e9 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -975,7 +975,9 @@ ARegion *ui_screen_region_find_mouse_over(bScreen *screen, const struct wmEvent
/* interface_context_menu.c */
bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but);
-void ui_popup_context_menu_for_panel(struct bContext *C, struct ARegion *region, struct Panel *pa);
+void ui_popup_context_menu_for_panel(struct bContext *C,
+ struct ARegion *region,
+ struct Panel *panel);
/* interface_eyedropper.c */
struct wmKeyMap *eyedropper_modal_keymap(struct wmKeyConfig *keyconf);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 6c856a0e8dd..44def6a2c09 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -39,7 +39,7 @@
#include "BLT_translation.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
@@ -945,19 +945,25 @@ static uiBut *ui_item_with_label(uiLayout *layout,
PropertyType type;
PropertySubType subtype;
int prop_but_width = w_hint;
+#ifdef UI_PROP_DECORATE
+ uiLayout *layout_prop_decorate = NULL;
const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
+#endif
/* Always align item with label since text is already given enough space not to overlap. */
sub = uiLayoutRow(layout, true);
UI_block_layout_set_current(block, sub);
+#ifdef UI_PROP_DECORATE
if (name[0]) {
- int w_label;
-
if (use_prop_sep) {
- w_label = (int)((w_hint * 2) * UI_ITEM_PROP_SEP_DIVIDE);
+ layout_prop_decorate = uiItemL_respect_property_split(layout, name, 0);
}
- else {
+ else
+#endif
+ {
+ int w_label;
+
if (ui_layout_variable_size(layout)) {
/* w_hint is width for label in this case.
* Use a default width for property button(s) */
@@ -967,13 +973,7 @@ static uiBut *ui_item_with_label(uiLayout *layout,
else {
w_label = w_hint / 3;
}
- }
-
- uiBut *but_label = uiDefBut(
- block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, "");
- if (use_prop_sep) {
- but_label->drawflag |= UI_BUT_TEXT_RIGHT;
- but_label->drawflag &= ~UI_BUT_TEXT_LEFT;
+ uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, "");
}
}
@@ -1053,7 +1053,7 @@ static uiBut *ui_item_with_label(uiLayout *layout,
if (layout->item.flag & UI_ITEM_PROP_SEP) {
if ((layout->item.flag & UI_ITEM_PROP_DECORATE) &&
(layout->item.flag & UI_ITEM_PROP_DECORATE_NO_PAD) == 0) {
- uiItemL(sub, NULL, ICON_BLANK1);
+ uiItemL(layout_prop_decorate ? layout_prop_decorate : sub, NULL, ICON_BLANK1);
}
}
#endif /* UI_PROP_DECORATE */
@@ -1862,6 +1862,20 @@ static void ui_item_rna_size(uiLayout *layout,
*r_h = h;
}
+/**
+ * Hack to add further items in a row into the second part of the split layout, so the label part
+ * keeps a fixed size.
+ * \return The layout to place further items in for the split layout.
+ */
+static uiLayout *ui_item_prop_split_layout_hack(uiLayout *layout_parent, uiLayout *layout_split)
+{
+ if (layout_parent->item.type == ITEM_LAYOUT_ROW) {
+ layout_parent->child_items_layout = uiLayoutRow(layout_split, true);
+ return layout_parent->child_items_layout;
+ }
+ return layout_split;
+}
+
void uiItemFullR(uiLayout *layout,
PointerRNA *ptr,
PropertyRNA *prop,
@@ -2081,11 +2095,8 @@ void uiItemFullR(uiLayout *layout,
}
}
- /* Hack to add further items in a row into the second part of
- * the split layout, so the label part keeps a fixed size. */
- if (layout_parent && layout_parent->item.type == ITEM_LAYOUT_ROW) {
- layout_split = uiLayoutRow(layout_split, true);
- layout_parent->child_items_layout = layout_split;
+ if (layout_parent) {
+ layout_split = ui_item_prop_split_layout_hack(layout_parent, layout_split);
}
/* Watch out! We can only write into the new layout now. */
@@ -2897,7 +2908,7 @@ void uiItemPopoverPanelFromGroup(uiLayout *layout,
return;
}
- for (PanelType *pt = art->paneltypes.first; pt; pt = pt->next) {
+ LISTBASE_FOREACH (PanelType *, pt, &art->paneltypes) {
/* Causes too many panels, check context. */
if (pt->parent_id[0] == '\0') {
if (/* (*context == '\0') || */ STREQ(pt->context, context)) {
@@ -2989,21 +3000,26 @@ void uiItemL(uiLayout *layout, const char *name, int icon)
* extended to support more cases.
* Ideally, #uiItemFullR() could just call this, but it currently has too many special needs.
*
- * \return the layout to place the item(s) associated to the label in.
+ * \return A layout placed in the row after the split layout. Used to place decorator items.
*/
uiLayout *uiItemL_respect_property_split(uiLayout *layout, const char *text, int icon)
{
if (layout->item.flag & UI_ITEM_PROP_SEP) {
- uiLayout *layout_split = uiLayoutSplit(layout, UI_ITEM_PROP_SEP_DIVIDE, true);
+ uiBlock *block = uiLayoutGetBlock(layout);
+ uiLayout *layout_row = uiLayoutRow(layout, true);
+ uiLayout *layout_split = uiLayoutSplit(layout_row, UI_ITEM_PROP_SEP_DIVIDE, true);
uiLayout *layout_sub = uiLayoutColumn(layout_split, true);
- layout_split->space = layout_sub->space = layout->space = 0;
+ layout_split->space = layout_sub->space = layout_row->space = 0;
layout_sub->alignment = UI_LAYOUT_ALIGN_RIGHT;
uiItemL_(layout_sub, text, icon);
+ layout_split = ui_item_prop_split_layout_hack(layout, layout_split);
+ UI_block_layout_set_current(block, layout_split);
+
/* Give caller a new sub-row to place items in. */
- return uiLayoutRow(layout_split, true);
+ return layout_row;
}
else {
char namestr[UI_MAX_NAME_STR];
@@ -5352,7 +5368,7 @@ static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout,
MEM_freeN(panel);
/* Draw child panels. */
- for (LinkData *link = pt->children.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &pt->children) {
PanelType *child_pt = link->data;
if (child_pt->poll == NULL || child_pt->poll(C, child_pt)) {
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 519ba4cbbdf..53ea51c9e97 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -807,6 +807,9 @@ bool UI_context_copy_to_selected_list(bContext *C,
else if (RNA_struct_is_a(ptr->type, &RNA_FCurve)) {
*r_lb = CTX_data_collection_get(C, "selected_editable_fcurves");
}
+ else if (RNA_struct_is_a(ptr->type, &RNA_NlaStrip)) {
+ *r_lb = CTX_data_collection_get(C, "selected_nla_strips");
+ }
else if (RNA_struct_is_a(ptr->type, &RNA_Constraint) &&
(path_from_bone = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_PoseBone)) !=
NULL) {
@@ -1305,9 +1308,9 @@ static int editsource_text_edit(bContext *C,
else {
/* naughty!, find text area to set, not good behavior
* but since this is a dev tool lets allow it - campbell */
- ScrArea *sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
- if (sa) {
- SpaceText *st = sa->spacedata.first;
+ ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
+ if (area) {
+ SpaceText *st = area->spacedata.first;
st->text = text;
}
else {
@@ -1617,13 +1620,14 @@ static void UI_OT_reloadtranslation(wmOperatorType *ot)
static int ui_button_press_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
const bool skip_depressed = RNA_boolean_get(op->ptr, "skip_depressed");
- ARegion *ar_prev = CTX_wm_region(C);
- ARegion *region = sc ? BKE_screen_find_region_xy(sc, RGN_TYPE_ANY, event->x, event->y) : NULL;
+ ARegion *region_prev = CTX_wm_region(C);
+ ARegion *region = screen ? BKE_screen_find_region_xy(screen, RGN_TYPE_ANY, event->x, event->y) :
+ NULL;
if (region == NULL) {
- region = ar_prev;
+ region = region_prev;
}
if (region == NULL) {
@@ -1632,7 +1636,7 @@ static int ui_button_press_invoke(bContext *C, wmOperator *op, const wmEvent *ev
CTX_wm_region_set(C, region);
uiBut *but = UI_context_active_but_get(C);
- CTX_wm_region_set(C, ar_prev);
+ CTX_wm_region_set(C, region_prev);
if (but == NULL) {
return OPERATOR_PASS_THROUGH;
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index d57b4d444bd..b3854cfc4ae 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -105,8 +105,8 @@ typedef struct uiHandlePanelData {
int startsizex, startsizey;
} uiHandlePanelData;
-static int get_panel_real_size_y(const Panel *pa);
-static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelState state);
+static int get_panel_real_size_y(const Panel *panel);
+static void panel_activate_state(const bContext *C, Panel *panel, uiHandlePanelState state);
static void panel_title_color_get(bool show_background, uchar color[4])
{
@@ -131,18 +131,18 @@ typedef enum eSpaceButtons_Align {
BUT_AUTO = 2,
} eSpaceButtons_Align;
-static int panel_aligned(const ScrArea *sa, const ARegion *region)
+static int panel_aligned(const ScrArea *area, const ARegion *region)
{
- if (sa->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) {
+ if (area->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) {
return BUT_VERTICAL;
}
- else if (sa->spacetype == SPACE_USERPREF && region->regiontype == RGN_TYPE_WINDOW) {
+ else if (area->spacetype == SPACE_USERPREF && region->regiontype == RGN_TYPE_WINDOW) {
return BUT_VERTICAL;
}
- else if (sa->spacetype == SPACE_FILE && region->regiontype == RGN_TYPE_CHANNELS) {
+ else if (area->spacetype == SPACE_FILE && region->regiontype == RGN_TYPE_CHANNELS) {
return BUT_VERTICAL;
}
- else if (sa->spacetype == SPACE_IMAGE && region->regiontype == RGN_TYPE_PREVIEW) {
+ else if (area->spacetype == SPACE_IMAGE && region->regiontype == RGN_TYPE_PREVIEW) {
return BUT_VERTICAL;
}
else if (ELEM(region->regiontype,
@@ -160,71 +160,71 @@ static int panel_aligned(const ScrArea *sa, const ARegion *region)
static bool panel_active_animation_changed(ListBase *lb, Panel **pa_animation, bool *no_animation)
{
- for (Panel *pa = lb->first; pa; pa = pa->next) {
+ LISTBASE_FOREACH (Panel *, panel, lb) {
/* Detect panel active flag changes. */
- if (!(pa->type && pa->type->parent)) {
- if ((pa->runtime_flag & PNL_WAS_ACTIVE) && !(pa->runtime_flag & PNL_ACTIVE)) {
+ if (!(panel->type && panel->type->parent)) {
+ if ((panel->runtime_flag & PNL_WAS_ACTIVE) && !(panel->runtime_flag & PNL_ACTIVE)) {
return true;
}
- if (!(pa->runtime_flag & PNL_WAS_ACTIVE) && (pa->runtime_flag & PNL_ACTIVE)) {
+ if (!(panel->runtime_flag & PNL_WAS_ACTIVE) && (panel->runtime_flag & PNL_ACTIVE)) {
return true;
}
}
- if ((pa->runtime_flag & PNL_ACTIVE) && !(pa->flag & PNL_CLOSED)) {
- if (panel_active_animation_changed(&pa->children, pa_animation, no_animation)) {
+ if ((panel->runtime_flag & PNL_ACTIVE) && !(panel->flag & PNL_CLOSED)) {
+ if (panel_active_animation_changed(&panel->children, pa_animation, no_animation)) {
return true;
}
}
/* Detect animation. */
- if (pa->activedata) {
- uiHandlePanelData *data = pa->activedata;
+ if (panel->activedata) {
+ uiHandlePanelData *data = panel->activedata;
if (data->state == PANEL_STATE_ANIMATION) {
- *pa_animation = pa;
+ *pa_animation = panel;
}
else {
/* Don't animate while handling other interaction. */
*no_animation = true;
}
}
- if ((pa->runtime_flag & PNL_ANIM_ALIGN) && !(*pa_animation)) {
- *pa_animation = pa;
+ if ((panel->runtime_flag & PNL_ANIM_ALIGN) && !(*pa_animation)) {
+ *pa_animation = panel;
}
}
return false;
}
-static bool panels_need_realign(ScrArea *sa, ARegion *region, Panel **r_pa_animate)
+static bool panels_need_realign(ScrArea *area, ARegion *region, Panel **r_panel_animation)
{
- *r_pa_animate = NULL;
+ *r_panel_animation = NULL;
- if (sa->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) {
- SpaceProperties *sbuts = sa->spacedata.first;
+ if (area->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) {
+ SpaceProperties *sbuts = area->spacedata.first;
if (sbuts->mainbo != sbuts->mainb) {
return true;
}
}
- else if (sa->spacetype == SPACE_IMAGE && region->regiontype == RGN_TYPE_PREVIEW) {
+ else if (area->spacetype == SPACE_IMAGE && region->regiontype == RGN_TYPE_PREVIEW) {
return true;
}
- else if (sa->spacetype == SPACE_FILE && region->regiontype == RGN_TYPE_CHANNELS) {
+ else if (area->spacetype == SPACE_FILE && region->regiontype == RGN_TYPE_CHANNELS) {
return true;
}
/* Detect if a panel was added or removed. */
- Panel *pa_animation = NULL;
+ Panel *panel_animation = NULL;
bool no_animation = false;
- if (panel_active_animation_changed(&region->panels, &pa_animation, &no_animation)) {
+ if (panel_active_animation_changed(&region->panels, &panel_animation, &no_animation)) {
return true;
}
/* Detect panel marked for animation, if we're not already animating. */
- if (pa_animation) {
+ if (panel_animation) {
if (!no_animation) {
- *r_pa_animate = pa_animation;
+ *r_panel_animation = panel_animation;
}
return true;
}
@@ -234,24 +234,24 @@ static bool panels_need_realign(ScrArea *sa, ARegion *region, Panel **r_pa_anima
/****************************** panels ******************************/
-static void panels_collapse_all(ScrArea *sa, ARegion *region, const Panel *from_pa)
+static void panels_collapse_all(ScrArea *area, ARegion *region, const Panel *from_panel)
{
const bool has_category_tabs = UI_panel_category_is_visible(region);
const char *category = has_category_tabs ? UI_panel_category_active_get(region, false) : NULL;
- const int flag = ((panel_aligned(sa, region) == BUT_HORIZONTAL) ? PNL_CLOSEDX : PNL_CLOSEDY);
- const PanelType *from_pt = from_pa->type;
- Panel *pa;
+ const int flag = ((panel_aligned(area, region) == BUT_HORIZONTAL) ? PNL_CLOSEDX : PNL_CLOSEDY);
+ const PanelType *from_pt = from_panel->type;
+ Panel *panel;
- for (pa = region->panels.first; pa; pa = pa->next) {
- PanelType *pt = pa->type;
+ for (panel = region->panels.first; panel; panel = panel->next) {
+ PanelType *pt = panel->type;
/* close panels with headers in the same context */
if (pt && from_pt && !(pt->flag & PNL_NO_HEADER)) {
if (!pt->context[0] || !from_pt->context[0] || STREQ(pt->context, from_pt->context)) {
- if ((pa->flag & PNL_PIN) || !category || !pt->category[0] ||
+ if ((panel->flag & PNL_PIN) || !category || !pt->category[0] ||
STREQ(pt->category, category)) {
- pa->flag &= ~PNL_CLOSED;
- pa->flag |= flag;
+ panel->flag &= ~PNL_CLOSED;
+ panel->flag |= flag;
}
}
}
@@ -260,116 +260,116 @@ static void panels_collapse_all(ScrArea *sa, ARegion *region, const Panel *from_
Panel *UI_panel_find_by_type(ListBase *lb, PanelType *pt)
{
- Panel *pa;
+ Panel *panel;
const char *idname = pt->idname;
- for (pa = lb->first; pa; pa = pa->next) {
- if (STREQLEN(pa->panelname, idname, sizeof(pa->panelname))) {
- return pa;
+ for (panel = lb->first; panel; panel = panel->next) {
+ if (STREQLEN(panel->panelname, idname, sizeof(panel->panelname))) {
+ return panel;
}
}
return NULL;
}
/**
- * \note \a pa should be return value from #UI_panel_find_by_type and can be NULL.
+ * \note \a panel should be return value from #UI_panel_find_by_type and can be NULL.
*/
-Panel *UI_panel_begin(ScrArea *sa,
+Panel *UI_panel_begin(ScrArea *area,
ARegion *region,
ListBase *lb,
uiBlock *block,
PanelType *pt,
- Panel *pa,
+ Panel *panel,
bool *r_open)
{
- Panel *palast, *panext;
+ Panel *panel_last, *panel_next;
const char *drawname = CTX_IFACE_(pt->translation_context, pt->label);
const char *idname = pt->idname;
- const bool newpanel = (pa == NULL);
- int align = panel_aligned(sa, region);
+ const bool newpanel = (panel == NULL);
+ int align = panel_aligned(area, region);
if (!newpanel) {
- pa->type = pt;
+ panel->type = pt;
}
else {
/* new panel */
- pa = MEM_callocN(sizeof(Panel), "new panel");
- pa->type = pt;
- BLI_strncpy(pa->panelname, idname, sizeof(pa->panelname));
+ panel = MEM_callocN(sizeof(Panel), "new panel");
+ panel->type = pt;
+ BLI_strncpy(panel->panelname, idname, sizeof(panel->panelname));
if (pt->flag & PNL_DEFAULT_CLOSED) {
if (align == BUT_VERTICAL) {
- pa->flag |= PNL_CLOSEDY;
+ panel->flag |= PNL_CLOSEDY;
}
else {
- pa->flag |= PNL_CLOSEDX;
+ panel->flag |= PNL_CLOSEDX;
}
}
- pa->ofsx = 0;
- pa->ofsy = 0;
- pa->sizex = 0;
- pa->sizey = 0;
- pa->blocksizex = 0;
- pa->blocksizey = 0;
- pa->runtime_flag |= PNL_NEW_ADDED;
+ panel->ofsx = 0;
+ panel->ofsy = 0;
+ panel->sizex = 0;
+ panel->sizey = 0;
+ panel->blocksizex = 0;
+ panel->blocksizey = 0;
+ panel->runtime_flag |= PNL_NEW_ADDED;
- BLI_addtail(lb, pa);
+ BLI_addtail(lb, panel);
}
/* Do not allow closed panels without headers! Else user could get "disappeared" UI! */
- if ((pt->flag & PNL_NO_HEADER) && (pa->flag & PNL_CLOSED)) {
- pa->flag &= ~PNL_CLOSED;
+ if ((pt->flag & PNL_NO_HEADER) && (panel->flag & PNL_CLOSED)) {
+ panel->flag &= ~PNL_CLOSED;
/* Force update of panels' positions! */
- pa->sizex = 0;
- pa->sizey = 0;
- pa->blocksizex = 0;
- pa->blocksizey = 0;
+ panel->sizex = 0;
+ panel->sizey = 0;
+ panel->blocksizex = 0;
+ panel->blocksizey = 0;
}
- BLI_strncpy(pa->drawname, drawname, sizeof(pa->drawname));
+ BLI_strncpy(panel->drawname, drawname, sizeof(panel->drawname));
/* if a new panel is added, we insert it right after the panel
* that was last added. this way new panels are inserted in the
* right place between versions */
- for (palast = lb->first; palast; palast = palast->next) {
- if (palast->runtime_flag & PNL_LAST_ADDED) {
- BLI_remlink(lb, pa);
- BLI_insertlinkafter(lb, palast, pa);
+ for (panel_last = lb->first; panel_last; panel_last = panel_last->next) {
+ if (panel_last->runtime_flag & PNL_LAST_ADDED) {
+ BLI_remlink(lb, panel);
+ BLI_insertlinkafter(lb, panel_last, panel);
break;
}
}
if (newpanel) {
- pa->sortorder = (palast) ? palast->sortorder + 1 : 0;
+ panel->sortorder = (panel_last) ? panel_last->sortorder + 1 : 0;
- for (panext = lb->first; panext; panext = panext->next) {
- if (panext != pa && panext->sortorder >= pa->sortorder) {
- panext->sortorder++;
+ for (panel_next = lb->first; panel_next; panel_next = panel_next->next) {
+ if (panel_next != panel && panel_next->sortorder >= panel->sortorder) {
+ panel_next->sortorder++;
}
}
}
- if (palast) {
- palast->runtime_flag &= ~PNL_LAST_ADDED;
+ if (panel_last) {
+ panel_last->runtime_flag &= ~PNL_LAST_ADDED;
}
/* assign to block */
- block->panel = pa;
- pa->runtime_flag |= PNL_ACTIVE | PNL_LAST_ADDED;
+ block->panel = panel;
+ panel->runtime_flag |= PNL_ACTIVE | PNL_LAST_ADDED;
if (region->alignment == RGN_ALIGN_FLOAT) {
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
}
*r_open = false;
- if (pa->flag & PNL_CLOSED) {
- return pa;
+ if (panel->flag & PNL_CLOSED) {
+ return panel;
}
*r_open = true;
- return pa;
+ return panel;
}
static float panel_region_offset_x_get(const ARegion *region, int align)
@@ -385,16 +385,16 @@ static float panel_region_offset_x_get(const ARegion *region, int align)
}
void UI_panel_end(
- const ScrArea *sa, const ARegion *region, uiBlock *block, int width, int height, bool open)
+ const ScrArea *area, const ARegion *region, uiBlock *block, int width, int height, bool open)
{
- Panel *pa = block->panel;
+ Panel *panel = block->panel;
/* Set panel size excluding children. */
- pa->blocksizex = width;
- pa->blocksizey = height;
+ panel->blocksizex = width;
+ panel->blocksizey = height;
/* Compute total panel size including children. */
- for (Panel *pachild = pa->children.first; pachild; pachild = pachild->next) {
+ LISTBASE_FOREACH (Panel *, pachild, &panel->children) {
if (pachild->runtime_flag & PNL_ACTIVE) {
width = max_ii(width, pachild->sizex);
height += get_panel_real_size_y(pachild);
@@ -402,32 +402,32 @@ void UI_panel_end(
}
/* Update total panel size. */
- if (pa->runtime_flag & PNL_NEW_ADDED) {
- pa->runtime_flag &= ~PNL_NEW_ADDED;
- pa->sizex = width;
- pa->sizey = height;
+ if (panel->runtime_flag & PNL_NEW_ADDED) {
+ panel->runtime_flag &= ~PNL_NEW_ADDED;
+ panel->sizex = width;
+ panel->sizey = height;
}
else {
- int old_sizex = pa->sizex, old_sizey = pa->sizey;
- int old_region_ofsx = pa->runtime.region_ofsx;
+ int old_sizex = panel->sizex, old_sizey = panel->sizey;
+ int old_region_ofsx = panel->runtime.region_ofsx;
/* update width/height if non-zero */
if (width != 0) {
- pa->sizex = width;
+ panel->sizex = width;
}
if (height != 0 || open) {
- pa->sizey = height;
+ panel->sizey = height;
}
/* check if we need to do an animation */
- if (pa->sizex != old_sizex || pa->sizey != old_sizey) {
- pa->runtime_flag |= PNL_ANIM_ALIGN;
- pa->ofsy += old_sizey - pa->sizey;
+ if (panel->sizex != old_sizex || panel->sizey != old_sizey) {
+ panel->runtime_flag |= PNL_ANIM_ALIGN;
+ panel->ofsy += old_sizey - panel->sizey;
}
- int align = panel_aligned(sa, region);
+ int align = panel_aligned(area, region);
if (old_region_ofsx != panel_region_offset_x_get(region, align)) {
- pa->runtime_flag |= PNL_ANIM_ALIGN;
+ panel->runtime_flag |= PNL_ANIM_ALIGN;
}
}
}
@@ -441,7 +441,7 @@ static void ui_offset_panel_block(uiBlock *block)
int ofsy = block->panel->sizey - style->panelspace;
- for (uiBut *but = block->buttons.first; but; but = but->next) {
+ LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
but->rect.ymin += ofsy;
but->rect.ymax += ofsy;
}
@@ -867,64 +867,64 @@ void ui_draw_aligned_panel(uiStyle *style,
/************************** panel alignment *************************/
-static int get_panel_header(const Panel *pa)
+static int get_panel_header(const Panel *panel)
{
- if (pa->type && (pa->type->flag & PNL_NO_HEADER)) {
+ if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
return 0;
}
return PNL_HEADER;
}
-static int get_panel_size_y(const Panel *pa)
+static int get_panel_size_y(const Panel *panel)
{
- if (pa->type && (pa->type->flag & PNL_NO_HEADER)) {
- return pa->sizey;
+ if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
+ return panel->sizey;
}
- return PNL_HEADER + pa->sizey;
+ return PNL_HEADER + panel->sizey;
}
-static int get_panel_real_size_y(const Panel *pa)
+static int get_panel_real_size_y(const Panel *panel)
{
- int sizey = (pa->flag & PNL_CLOSED) ? 0 : pa->sizey;
+ int sizey = (panel->flag & PNL_CLOSED) ? 0 : panel->sizey;
- if (pa->type && (pa->type->flag & PNL_NO_HEADER)) {
+ if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
return sizey;
}
return PNL_HEADER + sizey;
}
-int UI_panel_size_y(const Panel *pa)
+int UI_panel_size_y(const Panel *panel)
{
- return get_panel_real_size_y(pa);
+ return get_panel_real_size_y(panel);
}
/* this function is needed because uiBlock and Panel itself don't
* change sizey or location when closed */
-static int get_panel_real_ofsy(Panel *pa)
+static int get_panel_real_ofsy(Panel *panel)
{
- if (pa->flag & PNL_CLOSEDY) {
- return pa->ofsy + pa->sizey;
+ if (panel->flag & PNL_CLOSEDY) {
+ return panel->ofsy + panel->sizey;
}
else {
- return pa->ofsy;
+ return panel->ofsy;
}
}
-static int get_panel_real_ofsx(Panel *pa)
+static int get_panel_real_ofsx(Panel *panel)
{
- if (pa->flag & PNL_CLOSEDX) {
- return pa->ofsx + get_panel_header(pa);
+ if (panel->flag & PNL_CLOSEDX) {
+ return panel->ofsx + get_panel_header(panel);
}
else {
- return pa->ofsx + pa->sizex;
+ return panel->ofsx + panel->sizex;
}
}
typedef struct PanelSort {
- Panel *pa, *orig;
+ Panel *panel, *orig;
} PanelSort;
/**
@@ -939,16 +939,16 @@ static int find_leftmost_panel(const void *a1, const void *a2)
{
const PanelSort *ps1 = a1, *ps2 = a2;
- if (ps1->pa->ofsx > ps2->pa->ofsx) {
+ if (ps1->panel->ofsx > ps2->panel->ofsx) {
return 1;
}
- else if (ps1->pa->ofsx < ps2->pa->ofsx) {
+ else if (ps1->panel->ofsx < ps2->panel->ofsx) {
return -1;
}
- else if (ps1->pa->sortorder > ps2->pa->sortorder) {
+ else if (ps1->panel->sortorder > ps2->panel->sortorder) {
return 1;
}
- else if (ps1->pa->sortorder < ps2->pa->sortorder) {
+ else if (ps1->panel->sortorder < ps2->panel->sortorder) {
return -1;
}
@@ -961,26 +961,26 @@ static int find_highest_panel(const void *a1, const void *a2)
/* stick uppermost header-less panels to the top of the region -
* prevent them from being sorted (multiple header-less panels have to be sorted though) */
- if (ps1->pa->type->flag & PNL_NO_HEADER && ps2->pa->type->flag & PNL_NO_HEADER) {
+ if (ps1->panel->type->flag & PNL_NO_HEADER && ps2->panel->type->flag & PNL_NO_HEADER) {
/* skip and check for ofs and sortorder below */
}
- else if (ps1->pa->type->flag & PNL_NO_HEADER) {
+ else if (ps1->panel->type->flag & PNL_NO_HEADER) {
return -1;
}
- else if (ps2->pa->type->flag & PNL_NO_HEADER) {
+ else if (ps2->panel->type->flag & PNL_NO_HEADER) {
return 1;
}
- if (ps1->pa->ofsy + ps1->pa->sizey < ps2->pa->ofsy + ps2->pa->sizey) {
+ if (ps1->panel->ofsy + ps1->panel->sizey < ps2->panel->ofsy + ps2->panel->sizey) {
return 1;
}
- else if (ps1->pa->ofsy + ps1->pa->sizey > ps2->pa->ofsy + ps2->pa->sizey) {
+ else if (ps1->panel->ofsy + ps1->panel->sizey > ps2->panel->ofsy + ps2->panel->sizey) {
return -1;
}
- else if (ps1->pa->sortorder > ps2->pa->sortorder) {
+ else if (ps1->panel->sortorder > ps2->panel->sortorder) {
return 1;
}
- else if (ps1->pa->sortorder < ps2->pa->sortorder) {
+ else if (ps1->panel->sortorder < ps2->panel->sortorder) {
return -1;
}
@@ -991,24 +991,24 @@ static int compare_panel(const void *a1, const void *a2)
{
const PanelSort *ps1 = a1, *ps2 = a2;
- if (ps1->pa->sortorder > ps2->pa->sortorder) {
+ if (ps1->panel->sortorder > ps2->panel->sortorder) {
return 1;
}
- else if (ps1->pa->sortorder < ps2->pa->sortorder) {
+ else if (ps1->panel->sortorder < ps2->panel->sortorder) {
return -1;
}
return 0;
}
-static void align_sub_panels(Panel *pa)
+static void align_sub_panels(Panel *panel)
{
/* Position sub panels. */
- int ofsy = pa->ofsy + pa->sizey - pa->blocksizey;
+ int ofsy = panel->ofsy + panel->sizey - panel->blocksizey;
- for (Panel *pachild = pa->children.first; pachild; pachild = pachild->next) {
+ LISTBASE_FOREACH (Panel *, pachild, &panel->children) {
if (pachild->runtime_flag & PNL_ACTIVE) {
- pachild->ofsx = pa->ofsx;
+ pachild->ofsx = panel->ofsx;
pachild->ofsy = ofsy - get_panel_size_y(pachild);
ofsy -= get_panel_real_size_y(pachild);
@@ -1021,17 +1021,17 @@ static void align_sub_panels(Panel *pa)
/* this doesn't draw */
/* returns 1 when it did something */
-static bool uiAlignPanelStep(ScrArea *sa, ARegion *region, const float fac, const bool drag)
+static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, const bool drag)
{
- Panel *pa;
+ Panel *panel;
PanelSort *ps, *panelsort, *psnext;
int a, tot = 0;
bool done;
- int align = panel_aligned(sa, region);
+ int align = panel_aligned(area, region);
/* count active, not tabbed panels */
- for (pa = region->panels.first; pa; pa = pa->next) {
- if (pa->runtime_flag & PNL_ACTIVE) {
+ for (panel = region->panels.first; panel; panel = panel->next) {
+ if (panel->runtime_flag & PNL_ACTIVE) {
tot++;
}
}
@@ -1041,13 +1041,13 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *region, const float fac, cons
}
/* extra; change close direction? */
- for (pa = region->panels.first; pa; pa = pa->next) {
- if (pa->runtime_flag & PNL_ACTIVE) {
- if ((pa->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL)) {
- pa->flag ^= PNL_CLOSED;
+ for (panel = region->panels.first; panel; panel = panel->next) {
+ if (panel->runtime_flag & PNL_ACTIVE) {
+ if ((panel->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL)) {
+ panel->flag ^= PNL_CLOSED;
}
- else if ((pa->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL)) {
- pa->flag ^= PNL_CLOSED;
+ else if ((panel->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL)) {
+ panel->flag ^= PNL_CLOSED;
}
}
}
@@ -1056,10 +1056,10 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *region, const float fac, cons
panelsort = MEM_callocN(tot * sizeof(PanelSort), "panelsort");
ps = panelsort;
- for (pa = region->panels.first; pa; pa = pa->next) {
- if (pa->runtime_flag & PNL_ACTIVE) {
- ps->pa = MEM_dupallocN(pa);
- ps->orig = pa;
+ for (panel = region->panels.first; panel; panel = panel->next) {
+ if (panel->runtime_flag & PNL_ACTIVE) {
+ ps->panel = MEM_dupallocN(panel);
+ ps->orig = panel;
ps++;
}
}
@@ -1084,21 +1084,22 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *region, const float fac, cons
/* no smart other default start loc! this keeps switching f5/f6/etc compatible */
ps = panelsort;
- ps->pa->runtime.region_ofsx = panel_region_offset_x_get(region, align);
- ps->pa->ofsx = 0;
- ps->pa->ofsy = -get_panel_size_y(ps->pa);
- ps->pa->ofsx += ps->pa->runtime.region_ofsx;
+ ps->panel->runtime.region_ofsx = panel_region_offset_x_get(region, align);
+ ps->panel->ofsx = 0;
+ ps->panel->ofsy = -get_panel_size_y(ps->panel);
+ ps->panel->ofsx += ps->panel->runtime.region_ofsx;
for (a = 0; a < tot - 1; a++, ps++) {
psnext = ps + 1;
if (align == BUT_VERTICAL) {
- psnext->pa->ofsx = ps->pa->ofsx;
- psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa);
+ psnext->panel->ofsx = ps->panel->ofsx;
+ psnext->panel->ofsy = get_panel_real_ofsy(ps->panel) - get_panel_size_y(psnext->panel);
}
else {
- psnext->pa->ofsx = get_panel_real_ofsx(ps->pa);
- psnext->pa->ofsy = ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa);
+ psnext->panel->ofsx = get_panel_real_ofsx(ps->panel);
+ psnext->panel->ofsy = ps->panel->ofsy + get_panel_size_y(ps->panel) -
+ get_panel_size_y(psnext->panel);
}
}
@@ -1106,11 +1107,11 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *region, const float fac, cons
done = false;
ps = panelsort;
for (a = 0; a < tot; a++, ps++) {
- if ((ps->pa->flag & PNL_SELECT) == 0) {
- if ((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) {
- ps->orig->ofsx = round_fl_to_int(fac * (float)ps->pa->ofsx +
+ if ((ps->panel->flag & PNL_SELECT) == 0) {
+ if ((ps->orig->ofsx != ps->panel->ofsx) || (ps->orig->ofsy != ps->panel->ofsy)) {
+ ps->orig->ofsx = round_fl_to_int(fac * (float)ps->panel->ofsx +
(1.0f - fac) * (float)ps->orig->ofsx);
- ps->orig->ofsy = round_fl_to_int(fac * (float)ps->pa->ofsy +
+ ps->orig->ofsy = round_fl_to_int(fac * (float)ps->panel->ofsy +
(1.0f - fac) * (float)ps->orig->ofsy);
done = true;
}
@@ -1118,42 +1119,42 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *region, const float fac, cons
}
/* set locations for tabbed and sub panels */
- for (pa = region->panels.first; pa; pa = pa->next) {
- if (pa->runtime_flag & PNL_ACTIVE) {
- if (pa->children.first) {
- align_sub_panels(pa);
+ for (panel = region->panels.first; panel; panel = panel->next) {
+ if (panel->runtime_flag & PNL_ACTIVE) {
+ if (panel->children.first) {
+ align_sub_panels(panel);
}
}
}
/* free panelsort array */
for (ps = panelsort, a = 0; a < tot; a++, ps++) {
- MEM_freeN(ps->pa);
+ MEM_freeN(ps->panel);
}
MEM_freeN(panelsort);
return done;
}
-static void ui_panels_size(ScrArea *sa, ARegion *region, int *r_x, int *r_y)
+static void ui_panels_size(ScrArea *area, ARegion *region, int *r_x, int *r_y)
{
- Panel *pa;
- int align = panel_aligned(sa, region);
+ Panel *panel;
+ int align = panel_aligned(area, region);
int sizex = 0;
int sizey = 0;
/* compute size taken up by panels, for setting in view2d */
- for (pa = region->panels.first; pa; pa = pa->next) {
- if (pa->runtime_flag & PNL_ACTIVE) {
+ for (panel = region->panels.first; panel; panel = panel->next) {
+ if (panel->runtime_flag & PNL_ACTIVE) {
int pa_sizex, pa_sizey;
if (align == BUT_VERTICAL) {
- pa_sizex = pa->ofsx + pa->sizex;
- pa_sizey = get_panel_real_ofsy(pa);
+ pa_sizex = panel->ofsx + panel->sizex;
+ pa_sizey = get_panel_real_ofsy(panel);
}
else {
- pa_sizex = get_panel_real_ofsx(pa) + pa->sizex;
- pa_sizey = pa->ofsy + get_panel_size_y(pa);
+ pa_sizex = get_panel_real_ofsx(panel) + panel->sizex;
+ pa_sizey = panel->ofsy + get_panel_size_y(panel);
}
sizex = max_ii(sizex, pa_sizex);
@@ -1175,7 +1176,7 @@ static void ui_panels_size(ScrArea *sa, ARegion *region, int *r_x, int *r_y)
static void ui_do_animate(const bContext *C, Panel *panel)
{
uiHandlePanelData *data = panel->activedata;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
float fac;
@@ -1183,7 +1184,7 @@ static void ui_do_animate(const bContext *C, Panel *panel)
fac = min_ff(sqrtf(fac), 1.0f);
/* for max 1 second, interpolate positions */
- if (uiAlignPanelStep(sa, region, fac, false)) {
+ if (uiAlignPanelStep(area, region, fac, false)) {
ED_region_tag_redraw(region);
}
else {
@@ -1200,15 +1201,15 @@ static void panel_list_clear_active(ListBase *lb)
{
/* set all panels as inactive, so that at the end we know
* which ones were used */
- for (Panel *pa = lb->first; pa; pa = pa->next) {
- if (pa->runtime_flag & PNL_ACTIVE) {
- pa->runtime_flag = PNL_WAS_ACTIVE;
+ LISTBASE_FOREACH (Panel *, panel, lb) {
+ if (panel->runtime_flag & PNL_ACTIVE) {
+ panel->runtime_flag = PNL_WAS_ACTIVE;
}
else {
- pa->runtime_flag = 0;
+ panel->runtime_flag = 0;
}
- panel_list_clear_active(&pa->children);
+ panel_list_clear_active(&panel->children);
}
}
@@ -1220,9 +1221,9 @@ void UI_panels_begin(const bContext *UNUSED(C), ARegion *region)
/* only draws blocks with panels */
void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
uiBlock *block;
- Panel *pa, *firstpa;
+ Panel *panel, *panel_first;
/* offset contents */
for (block = region->uiblocks.first; block; block = block->next) {
@@ -1232,31 +1233,31 @@ void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y)
}
/* re-align, possibly with animation */
- if (panels_need_realign(sa, region, &pa)) {
- if (pa) {
- panel_activate_state(C, pa, PANEL_STATE_ANIMATION);
+ if (panels_need_realign(area, region, &panel)) {
+ if (panel) {
+ panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
}
else {
- uiAlignPanelStep(sa, region, 1.0, false);
+ uiAlignPanelStep(area, region, 1.0, false);
}
}
/* tag first panel */
- firstpa = NULL;
+ panel_first = NULL;
for (block = region->uiblocks.first; block; block = block->next) {
if (block->active && block->panel) {
- if (!firstpa || block->panel->sortorder < firstpa->sortorder) {
- firstpa = block->panel;
+ if (!panel_first || block->panel->sortorder < panel_first->sortorder) {
+ panel_first = block->panel;
}
}
}
- if (firstpa) {
- firstpa->runtime_flag |= PNL_FIRST;
+ if (panel_first) {
+ panel_first->runtime_flag |= PNL_FIRST;
}
/* compute size taken up by panel */
- ui_panels_size(sa, region, r_x, r_y);
+ ui_panels_size(area, region, r_x, r_y);
}
void UI_panels_draw(const bContext *C, ARegion *region)
@@ -1305,20 +1306,20 @@ void UI_panels_scale(ARegion *region, float new_width)
static void check_panel_overlap(ARegion *region, Panel *panel)
{
- Panel *pa;
+ Panel *panel_list;
/* also called with (panel == NULL) for clear */
- for (pa = region->panels.first; pa; pa = pa->next) {
- pa->flag &= ~PNL_OVERLAP;
- if (panel && (pa != panel)) {
- if (pa->runtime_flag & PNL_ACTIVE) {
+ for (panel_list = region->panels.first; panel_list; panel_list = panel_list->next) {
+ panel_list->flag &= ~PNL_OVERLAP;
+ if (panel && (panel_list != panel)) {
+ if (panel_list->runtime_flag & PNL_ACTIVE) {
float safex = 0.2, safey = 0.2;
- if (pa->flag & PNL_CLOSEDX) {
+ if (panel_list->flag & PNL_CLOSEDX) {
safex = 0.05;
}
- else if (pa->flag & PNL_CLOSEDY) {
+ else if (panel_list->flag & PNL_CLOSEDY) {
safey = 0.05;
}
else if (panel->flag & PNL_CLOSEDX) {
@@ -1328,11 +1329,12 @@ static void check_panel_overlap(ARegion *region, Panel *panel)
safey = 0.05;
}
- if (pa->ofsx > panel->ofsx - safex * panel->sizex) {
- if (pa->ofsx + pa->sizex < panel->ofsx + (1.0f + safex) * panel->sizex) {
- if (pa->ofsy > panel->ofsy - safey * panel->sizey) {
- if (pa->ofsy + pa->sizey < panel->ofsy + (1.0f + safey) * panel->sizey) {
- pa->flag |= PNL_OVERLAP;
+ if (panel_list->ofsx > panel->ofsx - safex * panel->sizex) {
+ if (panel_list->ofsx + panel_list->sizex < panel->ofsx + (1.0f + safex) * panel->sizex) {
+ if (panel_list->ofsy > panel->ofsy - safey * panel->sizey) {
+ if (panel_list->ofsy + panel_list->sizey <
+ panel->ofsy + (1.0f + safey) * panel->sizey) {
+ panel_list->flag |= PNL_OVERLAP;
}
}
}
@@ -1347,9 +1349,9 @@ static void check_panel_overlap(ARegion *region, Panel *panel)
static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
{
uiHandlePanelData *data = panel->activedata;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- short align = panel_aligned(sa, region), dx = 0, dy = 0;
+ short align = panel_aligned(area, region), dx = 0, dy = 0;
/* first clip for window, no dragging outside */
if (!BLI_rcti_isect_pt_v(&region->winrct, &event->x)) {
@@ -1381,7 +1383,7 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
check_panel_overlap(region, panel);
if (align) {
- uiAlignPanelStep(sa, region, 0.2, true);
+ uiAlignPanelStep(area, region, 0.2, true);
}
}
@@ -1391,12 +1393,12 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
/******************* region level panel interaction *****************/
static uiPanelMouseState ui_panel_mouse_state_get(const uiBlock *block,
- const Panel *pa,
+ const Panel *panel,
const int mx,
const int my)
{
/* open panel */
- if (pa->flag & PNL_CLOSEDX) {
+ if (panel->flag & PNL_CLOSEDX) {
if ((block->rect.xmin <= mx) && (block->rect.xmin + PNL_HEADER >= mx)) {
return PANEL_MOUSE_INSIDE_HEADER;
}
@@ -1409,8 +1411,8 @@ static uiPanelMouseState ui_panel_mouse_state_get(const uiBlock *block,
return PANEL_MOUSE_INSIDE_HEADER;
}
/* open panel */
- else if (!(pa->flag & PNL_CLOSEDY)) {
- if (pa->control & UI_PNL_SCALE) {
+ else if (!(panel->flag & PNL_CLOSEDY)) {
+ if (panel->control & UI_PNL_SCALE) {
if (block->rect.xmax - PNL_HEADER <= mx) {
if (block->rect.ymin + PNL_HEADER >= my) {
return PANEL_MOUSE_INSIDE_SCALE;
@@ -1441,22 +1443,22 @@ static void ui_panel_drag_collapse(bContext *C,
uiPanelDragCollapseHandle *dragcol_data,
const int xy_dst[2])
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
uiBlock *block;
- Panel *pa;
+ Panel *panel;
for (block = region->uiblocks.first; block; block = block->next) {
float xy_a_block[2] = {UNPACK2(dragcol_data->xy_init)};
float xy_b_block[2] = {UNPACK2(xy_dst)};
rctf rect = block->rect;
int oldflag;
- const bool is_horizontal = (panel_aligned(sa, region) == BUT_HORIZONTAL);
+ const bool is_horizontal = (panel_aligned(area, region) == BUT_HORIZONTAL);
- if ((pa = block->panel) == 0 || (pa->type && (pa->type->flag & PNL_NO_HEADER))) {
+ if ((panel = block->panel) == 0 || (panel->type && (panel->type->flag & PNL_NO_HEADER))) {
continue;
}
- oldflag = pa->flag;
+ oldflag = panel->flag;
/* lock one axis */
if (is_horizontal) {
@@ -1473,7 +1475,7 @@ static void ui_panel_drag_collapse(bContext *C,
/* set up rect to match header size */
rect.ymin = rect.ymax;
rect.ymax = rect.ymin + PNL_HEADER;
- if (pa->flag & PNL_CLOSEDX) {
+ if (panel->flag & PNL_CLOSEDX) {
rect.xmax = rect.xmin + PNL_HEADER;
}
@@ -1481,16 +1483,16 @@ static void ui_panel_drag_collapse(bContext *C,
if (BLI_rctf_isect_segment(&rect, xy_a_block, xy_b_block)) {
/* force panel to close */
if (dragcol_data->was_first_open == true) {
- pa->flag |= (is_horizontal ? PNL_CLOSEDX : PNL_CLOSEDY);
+ panel->flag |= (is_horizontal ? PNL_CLOSEDX : PNL_CLOSEDY);
}
/* force panel to open */
else {
- pa->flag &= ~PNL_CLOSED;
+ panel->flag &= ~PNL_CLOSED;
}
- /* if pa->flag has changed this means a panel was opened/closed here */
- if (pa->flag != oldflag) {
- panel_activate_state(C, pa, PANEL_STATE_ANIMATION);
+ /* if panel->flag has changed this means a panel was opened/closed here */
+ if (panel->flag != oldflag) {
+ panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
}
}
}
@@ -1553,7 +1555,7 @@ static void ui_panel_drag_collapse_handler_add(const bContext *C, const bool was
static void ui_handle_panel_header(
const bContext *C, uiBlock *block, int mx, int my, int event, short ctrl, short shift)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
#ifdef USE_PIN_HIDDEN
const bool show_pin = UI_panel_category_is_visible(region) &&
@@ -1565,7 +1567,7 @@ static void ui_handle_panel_header(
const bool is_subpanel = (block->panel->type && block->panel->type->parent);
const bool show_drag = !is_subpanel;
- int align = panel_aligned(sa, region), button = 0;
+ int align = panel_aligned(area, region), button = 0;
rctf rect_drag, rect_pin;
float rect_leftmost;
@@ -1620,7 +1622,7 @@ static void ui_handle_panel_header(
}
else { /* collapse */
if (ctrl) {
- panels_collapse_all(sa, region, block->panel);
+ panels_collapse_all(area, region, block->panel);
/* reset the view - we don't want to display a view without content */
UI_view2d_offset(&region->v2d, 0.0f, 1.0f);
@@ -2279,7 +2281,7 @@ int ui_handler_panel_region(bContext *C,
const uiBut *active_but)
{
uiBlock *block;
- Panel *pa;
+ Panel *panel;
int retval, mx, my;
bool has_category_tabs = UI_panel_category_is_visible(region);
@@ -2325,17 +2327,17 @@ int ui_handler_panel_region(bContext *C,
ui_window_to_block(region, block, &mx, &my);
/* checks for mouse position inside */
- pa = block->panel;
+ panel = block->panel;
- if (!pa) {
+ if (!panel) {
continue;
}
/* XXX - accessed freed panels when scripts reload, need to fix. */
- if (pa->type && pa->type->flag & PNL_NO_HEADER) {
+ if (panel->type && panel->type->flag & PNL_NO_HEADER) {
continue;
}
- mouse_state = ui_panel_mouse_state_get(block, pa, mx, my);
+ mouse_state = ui_panel_mouse_state_get(block, panel, mx, my);
/* XXX hardcoded key warning */
if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER) &&
@@ -2343,7 +2345,7 @@ int ui_handler_panel_region(bContext *C,
if (event->type == EVT_AKEY &&
((event->ctrl + event->oskey + event->shift + event->alt) == 0)) {
- if (pa->flag & PNL_CLOSEDY) {
+ if (panel->flag & PNL_CLOSEDY) {
if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) {
ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift);
}
@@ -2383,8 +2385,8 @@ int ui_handler_panel_region(bContext *C,
retval = WM_UI_HANDLER_BREAK;
break;
}
- else if ((mouse_state == PANEL_MOUSE_INSIDE_SCALE) && !(pa->flag & PNL_CLOSED)) {
- panel_activate_state(C, pa, PANEL_STATE_DRAG_SCALE);
+ else if ((mouse_state == PANEL_MOUSE_INSIDE_SCALE) && !(panel->flag & PNL_CLOSED)) {
+ panel_activate_state(C, panel, PANEL_STATE_DRAG_SCALE);
retval = WM_UI_HANDLER_BREAK;
break;
}
@@ -2400,7 +2402,7 @@ int ui_handler_panel_region(bContext *C,
/*XXX 2.50*/
#if 0
if (block->handler) {
- rem_blockhandler(sa, block->handler);
+ rem_blockhandler(area, block->handler);
ED_region_tag_redraw(region);
retval = WM_UI_HANDLER_BREAK;
}
@@ -2411,7 +2413,7 @@ int ui_handler_panel_region(bContext *C,
int zoom = 0;
/* if panel is closed, only zoom if mouse is over the header */
- if (pa->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) {
+ if (panel->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) {
if (inside_header) {
zoom = 1;
}
@@ -2421,11 +2423,11 @@ int ui_handler_panel_region(bContext *C,
}
if (zoom) {
- ScrArea *sa = CTX_wm_area(C);
- SpaceLink *sl = sa->spacedata.first;
+ ScrArea *area = CTX_wm_area(C);
+ SpaceLink *sl = area->spacedata.first;
- if (sa->spacetype != SPACE_PROPERTIES) {
- if (!(pa->control & UI_PNL_SCALE)) {
+ if (area->spacetype != SPACE_PROPERTIES) {
+ if (!(panel->control & UI_PNL_SCALE)) {
if (event->type == PADPLUSKEY) {
sl->blockscale += 0.1;
}
@@ -2458,9 +2460,9 @@ static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata)
/* verify if we can stop */
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- int align = panel_aligned(sa, region);
+ int align = panel_aligned(area, region);
if (align) {
panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
@@ -2495,14 +2497,14 @@ static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata)
static void ui_handler_remove_panel(bContext *C, void *userdata)
{
- Panel *pa = userdata;
+ Panel *panel = userdata;
- panel_activate_state(C, pa, PANEL_STATE_EXIT);
+ panel_activate_state(C, panel, PANEL_STATE_EXIT);
}
-static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelState state)
+static void panel_activate_state(const bContext *C, Panel *panel, uiHandlePanelState state)
{
- uiHandlePanelData *data = pa->activedata;
+ uiHandlePanelData *data = panel->activedata;
wmWindow *win = CTX_wm_window(C);
ARegion *region = CTX_wm_region(C);
@@ -2522,10 +2524,10 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
check_panel_overlap(region, NULL); /* clears */
}
- pa->flag &= ~PNL_SELECT;
+ panel->flag &= ~PNL_SELECT;
}
else {
- pa->flag |= PNL_SELECT;
+ panel->flag |= PNL_SELECT;
}
if (data && data->animtimer) {
@@ -2535,18 +2537,18 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
if (state == PANEL_STATE_EXIT) {
MEM_freeN(data);
- pa->activedata = NULL;
+ panel->activedata = NULL;
WM_event_remove_ui_handler(
- &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, false);
+ &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, panel, false);
}
else {
if (!data) {
data = MEM_callocN(sizeof(uiHandlePanelData), "uiHandlePanelData");
- pa->activedata = data;
+ panel->activedata = data;
WM_event_add_ui_handler(
- C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, 0);
+ C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, panel, 0);
}
if (ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG)) {
@@ -2556,10 +2558,10 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
data->state = state;
data->startx = win->eventstate->x;
data->starty = win->eventstate->y;
- data->startofsx = pa->ofsx;
- data->startofsy = pa->ofsy;
- data->startsizex = pa->sizex;
- data->startsizey = pa->sizey;
+ data->startofsx = panel->ofsx;
+ data->startofsy = panel->ofsy;
+ data->startsizex = panel->sizex;
+ data->startsizey = panel->sizey;
data->starttime = PIL_check_seconds_timer();
}
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index de68b192f67..70b4660e392 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -20,6 +20,7 @@
* Utilities to inspect the interface, extract information.
*/
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
@@ -260,7 +261,7 @@ uiBut *ui_but_find_mouse_over_ex(ARegion *region, const int x, const int y, cons
if (!ui_region_contains_point_px(region, x, y)) {
return NULL;
}
- for (uiBlock *block = region->uiblocks.first; block; block = block->next) {
+ LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
float mx = x, my = y;
ui_window_to_block_fl(region, block, &mx, &my);
@@ -308,7 +309,7 @@ uiBut *ui_but_find_rect_over(const struct ARegion *region, const rcti *rect_px)
BLI_rctf_rcti_copy(&rect_px_fl, rect_px);
uiBut *butover = NULL;
- for (uiBlock *block = region->uiblocks.first; block; block = block->next) {
+ LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
rctf rect_block;
ui_window_to_block_rctf(region, block, &rect_block, &rect_px_fl);
@@ -339,7 +340,7 @@ uiBut *ui_list_find_mouse_over_ex(ARegion *region, int x, int y)
if (!ui_region_contains_point_px(region, x, y)) {
return NULL;
}
- for (uiBlock *block = region->uiblocks.first; block; block = block->next) {
+ LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
float mx = x, my = y;
ui_window_to_block_fl(region, block, &mx, &my);
for (uiBut *but = block->buttons.last; but; but = but->prev) {
@@ -516,7 +517,7 @@ uiBlock *ui_block_find_mouse_over_ex(const ARegion *region,
if (!ui_region_contains_point_px(region, x, y)) {
return NULL;
}
- for (uiBlock *block = region->uiblocks.first; block; block = block->next) {
+ LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
if (only_clip) {
if ((block->flag & UI_BLOCK_CLIP_EVENTS) == 0) {
continue;
@@ -544,8 +545,8 @@ uiBlock *ui_block_find_mouse_over(const ARegion *region, const wmEvent *event, b
uiBut *ui_region_find_active_but(ARegion *region)
{
- for (uiBlock *block = region->uiblocks.first; block; block = block->next) {
- for (uiBut *but = block->buttons.first; but; but = but->next) {
+ LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
+ LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
if (but->active) {
return but;
}
@@ -557,8 +558,8 @@ uiBut *ui_region_find_active_but(ARegion *region)
uiBut *ui_region_find_first_but_test_flag(ARegion *region, int flag_include, int flag_exclude)
{
- for (uiBlock *block = region->uiblocks.first; block; block = block->next) {
- for (uiBut *but = block->buttons.first; but; but = but->next) {
+ LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
+ LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
if (((but->flag & flag_include) == flag_include) && ((but->flag & flag_exclude) == 0)) {
return but;
}
@@ -632,7 +633,7 @@ bool ui_region_contains_rect_px(const ARegion *region, const rcti *rect_px)
/** Check if the cursor is over any popups. */
ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y)
{
- for (ARegion *region = screen->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
rcti winrct;
ui_region_winrct_get_no_margin(region, &winrct);
diff --git a/source/blender/editors/interface/interface_region_color_picker.c b/source/blender/editors/interface/interface_region_color_picker.c
index ecdcd575d5c..f9873f8b96f 100644
--- a/source/blender/editors/interface/interface_region_color_picker.c
+++ b/source/blender/editors/interface/interface_region_color_picker.c
@@ -332,7 +332,7 @@ static void ui_popup_close_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
static void ui_colorpicker_hide_reveal(uiBlock *block, enum ePickerType colormode)
{
/* tag buttons */
- for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
+ LISTBASE_FOREACH (uiBut *, bt, &block->buttons) {
if ((bt->func == ui_colorpicker_rna_cb) && (bt->type == UI_BTYPE_NUM_SLIDER) &&
(bt->rnaindex != 3)) {
/* RGB sliders (color circle and alpha are always shown) */
diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c
index f77739b5114..34ac58c1dca 100644
--- a/source/blender/editors/interface/interface_region_hud.c
+++ b/source/blender/editors/interface/interface_region_hud.c
@@ -74,15 +74,15 @@ static bool last_redo_poll(const bContext *C, short region_type)
* operator call. Otherwise we would be polling the operator with the
* wrong context.
*/
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar_op = (region_type != -1) ? BKE_area_find_region_type(sa, region_type) : NULL;
- ARegion *ar_prev = CTX_wm_region(C);
- CTX_wm_region_set((bContext *)C, ar_op);
+ ScrArea *area = CTX_wm_area(C);
+ ARegion *region_op = (region_type != -1) ? BKE_area_find_region_type(area, region_type) : NULL;
+ ARegion *region_prev = CTX_wm_region(C);
+ CTX_wm_region_set((bContext *)C, region_op);
if (WM_operator_repeat_check(C, op) && WM_operator_check_ui_empty(op->type) == false) {
success = WM_operator_poll((bContext *)C, op->type);
}
- CTX_wm_region_set((bContext *)C, ar_prev);
+ CTX_wm_region_set((bContext *)C, region_prev);
}
return success;
}
@@ -103,8 +103,8 @@ static void hud_region_hide(ARegion *region)
static bool hud_panel_operator_redo_poll(const bContext *C, PanelType *UNUSED(pt))
{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_HUD);
+ ScrArea *area = CTX_wm_area(C);
+ ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_HUD);
if (region != NULL) {
struct HudRegionData *hrd = region->regiondata;
if (hrd != NULL) {
@@ -114,22 +114,22 @@ static bool hud_panel_operator_redo_poll(const bContext *C, PanelType *UNUSED(pt
return false;
}
-static void hud_panel_operator_redo_draw_header(const bContext *C, Panel *pa)
+static void hud_panel_operator_redo_draw_header(const bContext *C, Panel *panel)
{
wmOperator *op = WM_operator_last_redo(C);
- BLI_strncpy(pa->drawname, WM_operatortype_name(op->type, op->ptr), sizeof(pa->drawname));
+ BLI_strncpy(panel->drawname, WM_operatortype_name(op->type, op->ptr), sizeof(panel->drawname));
}
-static void hud_panel_operator_redo_draw(const bContext *C, Panel *pa)
+static void hud_panel_operator_redo_draw(const bContext *C, Panel *panel)
{
wmOperator *op = WM_operator_last_redo(C);
if (op == NULL) {
return;
}
if (!WM_operator_check_ui_enabled(C, op->type->name)) {
- uiLayoutSetEnabled(pa->layout, false);
+ uiLayoutSetEnabled(panel->layout, false);
}
- uiLayout *col = uiLayoutColumn(pa->layout, false);
+ uiLayout *col = uiLayoutColumn(panel->layout, false);
uiTemplateOperatorRedoProperties(col, C);
}
@@ -250,25 +250,25 @@ ARegionType *ED_area_type_hud(int space_type)
return art;
}
-static ARegion *hud_region_add(ScrArea *sa)
+static ARegion *hud_region_add(ScrArea *area)
{
ARegion *region = MEM_callocN(sizeof(ARegion), "area region");
- ARegion *ar_win = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
- if (ar_win) {
- BLI_insertlinkbefore(&sa->regionbase, ar_win, region);
+ ARegion *region_win = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
+ if (region_win) {
+ BLI_insertlinkbefore(&area->regionbase, region_win, region);
}
else {
- BLI_addtail(&sa->regionbase, region);
+ BLI_addtail(&area->regionbase, region);
}
region->regiontype = RGN_TYPE_HUD;
region->alignment = RGN_ALIGN_FLOAT;
region->overlap = true;
region->flag |= RGN_FLAG_DYNAMIC_SIZE;
- if (ar_win) {
+ if (region_win) {
float x, y;
- UI_view2d_scroller_size_get(&ar_win->v2d, &x, &y);
+ UI_view2d_scroller_size_get(&region_win->v2d, &x, &y);
region->runtime.offset_x = x;
region->runtime.offset_y = y;
}
@@ -276,18 +276,18 @@ static ARegion *hud_region_add(ScrArea *sa)
return region;
}
-void ED_area_type_hud_clear(wmWindowManager *wm, ScrArea *sa_keep)
+void ED_area_type_hud_clear(wmWindowManager *wm, ScrArea *area_keep)
{
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
bScreen *screen = WM_window_get_active_screen(win);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa != sa_keep) {
- for (ARegion *region = sa->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ if (area != area_keep) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_HUD) {
if ((region->flag & RGN_FLAG_HIDDEN) == 0) {
hud_region_hide(region);
ED_region_tag_redraw(region);
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
}
}
@@ -296,17 +296,17 @@ void ED_area_type_hud_clear(wmWindowManager *wm, ScrArea *sa_keep)
}
}
-void ED_area_type_hud_ensure(bContext *C, ScrArea *sa)
+void ED_area_type_hud_ensure(bContext *C, ScrArea *area)
{
wmWindowManager *wm = CTX_wm_manager(C);
- ED_area_type_hud_clear(wm, sa);
+ ED_area_type_hud_clear(wm, area);
- ARegionType *art = BKE_regiontype_from_id(sa->type, RGN_TYPE_HUD);
+ ARegionType *art = BKE_regiontype_from_id(area->type, RGN_TYPE_HUD);
if (art == NULL) {
return;
}
- ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_HUD);
+ ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_HUD);
if (region && (region->flag & RGN_FLAG_HIDDEN_BY_USER)) {
/* The region is intentionally hidden by the user, don't show it. */
@@ -316,9 +316,9 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa)
bool init = false;
bool was_hidden = region == NULL || region->visible == false;
- ARegion *ar_op = CTX_wm_region(C);
- BLI_assert((ar_op == NULL) || (ar_op->regiontype != RGN_TYPE_HUD));
- if (!last_redo_poll(C, ar_op ? ar_op->regiontype : -1)) {
+ ARegion *region_op = CTX_wm_region(C);
+ BLI_assert((region_op == NULL) || (region_op->regiontype != RGN_TYPE_HUD));
+ if (!last_redo_poll(C, region_op ? region_op->regiontype : -1)) {
if (region) {
ED_region_tag_redraw(region);
hud_region_hide(region);
@@ -328,18 +328,18 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa)
if (region == NULL) {
init = true;
- region = hud_region_add(sa);
+ region = hud_region_add(area);
region->type = art;
}
/* Let 'ED_area_update_region_sizes' do the work of placing the region.
* Otherwise we could set the 'region->winrct' & 'region->winx/winy' here. */
if (init) {
- sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
+ area->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
}
else {
if (region->flag & RGN_FLAG_HIDDEN) {
- sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
+ area->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
}
region->flag &= ~RGN_FLAG_HIDDEN;
}
@@ -350,8 +350,8 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa)
hrd = MEM_callocN(sizeof(*hrd), __func__);
region->regiondata = hrd;
}
- if (ar_op) {
- hrd->regionid = ar_op->regiontype;
+ if (region_op) {
+ hrd->regionid = region_op->regiontype;
}
else {
hrd->regionid = -1;
@@ -361,7 +361,7 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa)
if (init) {
/* This is needed or 'winrct' will be invalid. */
wmWindow *win = CTX_wm_window(C);
- ED_area_update_region_sizes(wm, win, sa);
+ ED_area_update_region_sizes(wm, win, area);
}
ED_region_floating_initialize(region);
@@ -380,7 +380,7 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa)
/* We shouldn't need to do this every time :S */
/* XXX, this is evil! - it also makes the menu show on first draw. :( */
if (region->visible) {
- ARegion *ar_prev = CTX_wm_region(C);
+ ARegion *region_prev = CTX_wm_region(C);
CTX_wm_region_set((bContext *)C, region);
hud_region_layout(C, region);
if (was_hidden) {
@@ -391,7 +391,7 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa)
.ymax = region->winy,
};
}
- CTX_wm_region_set((bContext *)C, ar_prev);
+ CTX_wm_region_set((bContext *)C, region_prev);
}
region->visible = !((region->flag & RGN_FLAG_HIDDEN) || (region->flag & RGN_FLAG_TOO_SMALL));
diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c
index b3c10e8d6b8..a161a449ba0 100644
--- a/source/blender/editors/interface/interface_region_menu_popup.c
+++ b/source/blender/editors/interface/interface_region_menu_popup.c
@@ -276,17 +276,17 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
else {
/* for a header menu we set the direction automatic */
if (!pup->slideout && flip) {
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- if (sa && region) {
+ if (area && region) {
if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
- if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_header_alignment(sa)) == RGN_ALIGN_BOTTOM) {
+ if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_header_alignment(area)) == RGN_ALIGN_BOTTOM) {
UI_block_direction_set(block, UI_DIR_UP);
UI_block_order_flip(block);
}
}
if (region->regiontype == RGN_TYPE_FOOTER) {
- if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_footer_alignment(sa)) == RGN_ALIGN_BOTTOM) {
+ if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_footer_alignment(area)) == RGN_ALIGN_BOTTOM) {
UI_block_direction_set(block, UI_DIR_UP);
UI_block_order_flip(block);
}
@@ -669,7 +669,7 @@ void UI_popup_block_close(bContext *C, wmWindow *win, uiBlock *block)
/* In the case we have nested popups,
* closing one may need to redraw another, see: T48874 */
- for (ARegion *region = screen->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
ED_region_tag_refresh_ui(region);
}
}
@@ -678,8 +678,8 @@ void UI_popup_block_close(bContext *C, wmWindow *win, uiBlock *block)
bool UI_popup_block_name_exists(const bScreen *screen, const char *name)
{
- for (const ARegion *region = screen->regionbase.first; region; region = region->next) {
- for (const uiBlock *block = region->uiblocks.first; block; block = block->next) {
+ LISTBASE_FOREACH (const ARegion *, region, &screen->regionbase) {
+ LISTBASE_FOREACH (const uiBlock *, block, &region->uiblocks) {
if (STREQ(block->name, name)) {
return true;
}
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index b889f1d6d01..0ad7e570e80 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -171,7 +171,7 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
}
if (!slideout) {
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
if (region && region->panels.first) {
@@ -180,14 +180,14 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
UI_block_direction_set(block, UI_DIR_UP | UI_DIR_CENTER_X);
}
/* Prefer popover from header to be positioned into the editor. */
- else if (sa && region) {
+ else if (area && region) {
if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
- if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_header_alignment(sa)) == RGN_ALIGN_BOTTOM) {
+ if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_header_alignment(area)) == RGN_ALIGN_BOTTOM) {
UI_block_direction_set(block, UI_DIR_UP | UI_DIR_CENTER_X);
}
}
if (region->regiontype == RGN_TYPE_FOOTER) {
- if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_footer_alignment(sa)) == RGN_ALIGN_BOTTOM) {
+ if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_footer_alignment(area)) == RGN_ALIGN_BOTTOM) {
UI_block_direction_set(block, UI_DIR_UP | UI_DIR_CENTER_X);
}
}
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c
index ba9a5026ce3..2ad7e517c60 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.c
@@ -118,7 +118,7 @@ static void ui_popup_block_position(wmWindow *window,
if (block->buttons.first) {
BLI_rctf_init_minmax(&block->rect);
- for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
+ LISTBASE_FOREACH (uiBut *, bt, &block->buttons) {
if (block->content_hints & UI_BLOCK_CONTAINS_SUBMENU_BUT) {
bt->rect.xmax += UI_MENU_SUBMENU_PADDING;
}
@@ -294,7 +294,7 @@ static void ui_popup_block_position(wmWindow *window,
}
/* Apply offset, buttons in window coords. */
- for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
+ LISTBASE_FOREACH (uiBut *, bt, &block->buttons) {
ui_block_to_window_rctf(butregion, but->block, &bt->rect, &bt->rect);
BLI_rctf_translate(&bt->rect, offset_x, offset_y);
@@ -420,7 +420,7 @@ static void ui_block_region_draw(const bContext *C, ARegion *region)
* Use to refresh centered popups on screen resizing (for splash).
*/
static void ui_block_region_popup_window_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -525,36 +525,36 @@ void ui_popup_block_scrolltest(uiBlock *block)
static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle)
{
wmWindow *ctx_win = CTX_wm_window(C);
- ScrArea *ctx_sa = CTX_wm_area(C);
- ARegion *ctx_ar = CTX_wm_region(C);
+ ScrArea *ctx_area = CTX_wm_area(C);
+ ARegion *ctx_region = CTX_wm_region(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = ctx_win;
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
/* There may actually be a different window active than the one showing the popup, so lookup real
* one. */
- if (BLI_findindex(&sc->regionbase, handle->region) == -1) {
+ if (BLI_findindex(&screen->regionbase, handle->region) == -1) {
for (win = wm->windows.first; win; win = win->next) {
- sc = WM_window_get_active_screen(win);
- if (BLI_findindex(&sc->regionbase, handle->region) != -1) {
+ screen = WM_window_get_active_screen(win);
+ if (BLI_findindex(&screen->regionbase, handle->region) != -1) {
break;
}
}
}
- BLI_assert(win && sc);
+ BLI_assert(win && screen);
CTX_wm_window_set(C, win);
- ui_region_temp_remove(C, sc, handle->region);
+ ui_region_temp_remove(C, screen, handle->region);
/* Reset context (area and region were NULL'ed when chaning context window). */
CTX_wm_window_set(C, ctx_win);
- CTX_wm_area_set(C, ctx_sa);
- CTX_wm_region_set(C, ctx_ar);
+ CTX_wm_area_set(C, ctx_area);
+ CTX_wm_region_set(C, ctx_region);
/* reset to region cursor (only if there's not another menu open) */
- if (BLI_listbase_is_empty(&sc->regionbase)) {
+ if (BLI_listbase_is_empty(&screen->regionbase)) {
win->tag_cursor_refresh = true;
}
@@ -698,7 +698,7 @@ uiBlock *ui_popup_block_refresh(bContext *C,
/* lastly set the buttons at the center of the pie menu, ready for animation */
if (U.pie_animation_timeout > 0) {
- for (uiBut *but_iter = block->buttons.first; but_iter; but_iter = but_iter->next) {
+ LISTBASE_FOREACH (uiBut *, but_iter, &block->buttons) {
if (but_iter->pie_dir != UI_RADIAL_NONE) {
BLI_rctf_recenter(&but_iter->rect, UNPACK2(block->pie_data.pie_center_spawned));
}
@@ -742,7 +742,7 @@ uiBlock *ui_popup_block_refresh(bContext *C,
/* apply scroll offset */
if (handle->scrolloffset != 0.0f) {
- for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
+ LISTBASE_FOREACH (uiBut *, bt, &block->buttons) {
bt->rect.ymin += handle->scrolloffset;
bt->rect.ymax += handle->scrolloffset;
}
@@ -846,7 +846,7 @@ void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle)
* then close the popover too. We could extend this to other popup types too. */
ARegion *region = handle->popup_create_vars.butregion;
if (region != NULL) {
- for (uiBlock *block = region->uiblocks.first; block; block = block->next) {
+ LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
if (block->handle && (block->flag & UI_BLOCK_POPOVER) &&
(block->flag & UI_BLOCK_KEEP_OPEN) == 0) {
uiPopupBlockHandle *menu = block->handle;
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index cf8ff51eccf..58a13c6c456 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -42,6 +42,7 @@
#include "DNA_brush_types.h"
#include "DNA_userdef_types.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "BLI_string.h"
@@ -318,7 +319,7 @@ static bool ui_tooltip_data_append_from_keymap(bContext *C, uiTooltipData *data,
const int fields_len_init = data->fields_len;
char buf[512];
- for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) {
wmOperatorType *ot = WM_operatortype_find(kmi->idname, true);
if (ot != NULL) {
/* Tip */
@@ -393,15 +394,15 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
bool has_valid_context = true;
const char *has_valid_context_error = IFACE_("Unsupported context");
{
- ScrArea *sa = CTX_wm_area(C);
- if (sa == NULL) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area == NULL) {
has_valid_context = false;
}
else {
PropertyRNA *prop = RNA_struct_find_property(but->opptr, "space_type");
if (RNA_property_is_set(but->opptr, prop)) {
const int space_type_prop = RNA_property_enum_get(but->opptr, prop);
- if (space_type_prop != sa->spacetype) {
+ if (space_type_prop != area->spacetype) {
has_valid_context = false;
}
}
@@ -596,7 +597,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
else if (BPY_execute_string_as_intptr(C, expr_imports, expr, true, &expr_result)) {
if (expr_result != 0) {
wmKeyMap *keymap = (wmKeyMap *)expr_result;
- for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) {
if (STREQ(kmi->idname, but->optype->idname)) {
char tool_id_test[MAX_NAME];
RNA_string_get(kmi->ptr, "name", tool_id_test);
@@ -1480,9 +1481,9 @@ ARegion *UI_tooltip_create_from_gizmo(bContext *C, wmGizmo *gz)
return ui_tooltip_create_with_data(C, data, init_position, NULL, aspect);
}
-void UI_tooltip_free(bContext *C, bScreen *sc, ARegion *region)
+void UI_tooltip_free(bContext *C, bScreen *screen, ARegion *region)
{
- ui_region_temp_remove(C, sc, region);
+ ui_region_temp_remove(C, screen, region);
}
/** \} */
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 2275f3fecdf..9ff58ddd24f 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -39,12 +39,12 @@
#include "interface_regions_intern.h"
-ARegion *ui_region_temp_add(bScreen *sc)
+ARegion *ui_region_temp_add(bScreen *screen)
{
ARegion *region;
region = MEM_callocN(sizeof(ARegion), "area region");
- BLI_addtail(&sc->regionbase, region);
+ BLI_addtail(&screen->regionbase, region);
region->regiontype = RGN_TYPE_TEMPORARY;
region->alignment = RGN_ALIGN_FLOAT;
@@ -52,17 +52,17 @@ ARegion *ui_region_temp_add(bScreen *sc)
return region;
}
-void ui_region_temp_remove(bContext *C, bScreen *sc, ARegion *region)
+void ui_region_temp_remove(bContext *C, bScreen *screen, ARegion *region)
{
wmWindow *win = CTX_wm_window(C);
BLI_assert(region->regiontype == RGN_TYPE_TEMPORARY);
- BLI_assert(BLI_findindex(&sc->regionbase, region) != -1);
+ BLI_assert(BLI_findindex(&screen->regionbase, region) != -1);
if (win) {
wm_draw_region_clear(win, region);
}
ED_region_exit(C, region);
BKE_area_region_free(NULL, region); /* NULL: no spacetype */
- BLI_freelinkN(&sc->regionbase, region);
+ BLI_freelinkN(&screen->regionbase, region);
}
diff --git a/source/blender/editors/interface/interface_regions_intern.h b/source/blender/editors/interface/interface_regions_intern.h
index 329ee3c08dc..c299562a357 100644
--- a/source/blender/editors/interface/interface_regions_intern.h
+++ b/source/blender/editors/interface/interface_regions_intern.h
@@ -27,7 +27,7 @@
uint ui_popup_menu_hash(const char *str);
/* interface_regions_intern.h */
-ARegion *ui_region_temp_add(bScreen *sc);
-void ui_region_temp_remove(struct bContext *C, bScreen *sc, ARegion *region);
+ARegion *ui_region_temp_add(bScreen *screen);
+void ui_region_temp_remove(struct bContext *C, bScreen *screen, ARegion *region);
#endif /* __INTERFACE_REGIONS_INTERN_H__ */
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index d7377a0e56e..98d5bae0ff1 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -831,7 +831,7 @@ static void template_ID(bContext *C,
if (text) {
/* Add label resepecting the separated layout property split state. */
- layout = uiItemL_respect_property_split(layout, text, ICON_NONE);
+ uiItemL_respect_property_split(layout, text, ICON_NONE);
}
if (flag & UI_ID_BROWSE) {
@@ -1159,7 +1159,7 @@ static void template_ID_tabs(bContext *C,
ListBase ordered;
BKE_id_ordered_list(&ordered, template->idlb);
- for (LinkData *link = ordered.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &ordered) {
ID *id = link->data;
const int name_width = UI_fontstyle_string_width(&style->widgetlabel, id->name + 2);
const int but_width = name_width + UI_UNIT_X;
@@ -2428,7 +2428,7 @@ static void template_operator_redo_property_buts_draw(
const bContext *C, wmOperator *op, uiLayout *layout, int layout_flags, bool *r_has_advanced)
{
if (op->type->flag & OPTYPE_MACRO) {
- for (wmOperator *macro_op = op->macro.first; macro_op; macro_op = macro_op->next) {
+ LISTBASE_FOREACH (wmOperator *, macro_op, &op->macro) {
template_operator_redo_property_buts_draw(C, macro_op, layout, layout_flags, r_has_advanced);
}
}
@@ -6819,7 +6819,7 @@ static bool menu_items_from_ui_create_item_from_button(struct MenuSearch_Data *d
*/
static void menu_types_add_from_keymap_items(bContext *C,
wmWindow *win,
- ScrArea *sa,
+ ScrArea *area,
ARegion *region,
LinkNode **menuid_stack_p,
GHash *menu_to_kmi,
@@ -6827,12 +6827,15 @@ static void menu_types_add_from_keymap_items(bContext *C,
{
wmWindowManager *wm = CTX_wm_manager(C);
ListBase *handlers[] = {
- &region->handlers,
- &sa->handlers,
+ region ? &region->handlers : NULL,
+ area ? &area->handlers : NULL,
&win->handlers,
};
for (int handler_index = 0; handler_index < ARRAY_SIZE(handlers); handler_index++) {
+ if (handlers[handler_index] == NULL) {
+ continue;
+ }
LISTBASE_FOREACH (wmEventHandler *, handler_base, handlers[handler_index]) {
/* During this loop, ui handlers for nested menus can tag multiple handlers free. */
if (handler_base->flag & WM_HANDLER_DO_FREE) {
@@ -6880,7 +6883,7 @@ static void menu_types_add_from_keymap_items(bContext *C,
*/
static struct MenuSearch_Data *menu_items_from_ui_create(bContext *C,
wmWindow *win,
- ScrArea *sa,
+ ScrArea *area,
ARegion *region)
{
MemArena *memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
@@ -6938,8 +6941,8 @@ static struct MenuSearch_Data *menu_items_from_ui_create(bContext *C,
case space_type: \
break
- if (sa != NULL) {
- switch (sa->spacetype) {
+ if (area != NULL) {
+ switch (area->spacetype) {
SPACE_MENU_MAP(SPACE_VIEW3D, "VIEW3D_MT_editor_menus");
SPACE_MENU_MAP(SPACE_GRAPH, "GRAPH_MT_editor_menus");
SPACE_MENU_MAP(SPACE_OUTLINER, "OUTLINER_MT_editor_menus");
@@ -6955,13 +6958,13 @@ static struct MenuSearch_Data *menu_items_from_ui_create(bContext *C,
SPACE_MENU_MAP(SPACE_CONSOLE, "CONSOLE_MT_editor_menus");
SPACE_MENU_MAP(SPACE_USERPREF, "USERPREF_MT_editor_menus");
SPACE_MENU_MAP(SPACE_CLIP,
- (((const SpaceClip *)sa->spacedata.first)->mode == SC_MODE_TRACKING) ?
+ (((const SpaceClip *)area->spacedata.first)->mode == SC_MODE_TRACKING) ?
"CLIP_MT_tracking_editor_menus" :
"CLIP_MT_masking_editor_menus");
SPACE_MENU_NOP(SPACE_TOPBAR);
SPACE_MENU_NOP(SPACE_STATUSBAR);
default:
- printf("Unknown space type '%d'\n", sa->spacetype);
+ printf("Unknown space type '%d'\n", area->spacetype);
}
}
for (int i = 0; i < idname_array_len; i++) {
@@ -7092,18 +7095,23 @@ static struct MenuSearch_Data *menu_items_from_ui_create(bContext *C,
menu_items_from_ui_create_item_from_button(data, memarena, mt, drawstr_submenu, sub_but);
}
- BLI_remlink(&region->uiblocks, sub_block);
+ if (region) {
+ BLI_remlink(&region->uiblocks, sub_block);
+ }
UI_block_free(NULL, sub_block);
}
}
- BLI_remlink(&region->uiblocks, block);
+ if (region) {
+ BLI_remlink(&region->uiblocks, block);
+ }
UI_block_free(NULL, block);
/* Add key-map items as a second pass,
* so all menus are accessed from the header & top-bar before key shortcuts are expanded. */
if ((menu_stack == NULL) && (has_keymap_menu_items == false)) {
has_keymap_menu_items = true;
- menu_types_add_from_keymap_items(C, win, sa, region, &menu_stack, menu_to_kmi, menu_tagged);
+ menu_types_add_from_keymap_items(
+ C, win, area, region, &menu_stack, menu_to_kmi, menu_tagged);
}
}
@@ -7292,9 +7300,9 @@ void UI_but_func_menu_search(uiBut *but)
{
bContext *C = but->block->evil_C;
wmWindow *win = CTX_wm_window(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- struct MenuSearch_Data *data = menu_items_from_ui_create(C, win, sa, region);
+ struct MenuSearch_Data *data = menu_items_from_ui_create(C, win, area, region);
UI_but_func_search_set(but,
ui_searchbox_create_menu,
menu_search_cb,
@@ -7579,7 +7587,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
uiBlock *block;
void *owner = NULL;
int handle_event, icon = 0;
@@ -7653,7 +7661,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
* progress bar which is not being updated (bake jobs only need
* to update NC_IMAGE context.
*/
- if (sa->spacetype != SPACE_NODE) {
+ if (area->spacetype != SPACE_NODE) {
handle_event = B_STOPOTHER;
icon = ICON_IMAGE;
break;
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index e5af8768e6e..01c9716ec86 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1198,7 +1198,7 @@ void UI_GetThemeColor4fv(int colorid, float col[4])
void UI_GetThemeColorType4fv(int colorid, int spacetype, float col[4])
{
- const unsigned char *cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
+ const uchar *cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
col[0] = ((float)cp[0]) / 255.0f;
col[1] = ((float)cp[1]) / 255.0f;
col[2] = ((float)cp[2]) / 255.0f;
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index adf0d6e372c..c07166b9ad2 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -33,6 +33,7 @@
#include "BLI_array.h"
#include "BLI_link_utils.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_rect.h"
@@ -268,7 +269,6 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
*/
v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y);
v2d->keeptot = V2D_KEEPTOT_BOUNDS;
-
if (do_init) {
v2d->tot.xmin = v2d->tot.ymin = 0.0f;
v2d->tot.xmax = (float)(winx - 1);
@@ -865,7 +865,6 @@ void UI_view2d_curRect_validate(View2D *v2d)
* to make sure 'related' views stay in synchrony */
void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
{
- ScrArea *sa;
ARegion *region;
/* don't continue if no view syncing to be done */
@@ -900,8 +899,8 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
/* check if doing whole screen syncing (i.e. time/horizontal) */
if ((v2dcur->flag & V2D_VIEWSYNC_SCREEN_TIME) && (screen)) {
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- for (region = sa->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ScrArea *, area_iter, &screen->areabase) {
+ for (region = area_iter->regionbase.first; region; region = region->next) {
/* don't operate on self */
if (v2dcur != &region->v2d) {
/* only if view has horizontal locks enabled */
@@ -1915,17 +1914,17 @@ View2D *UI_view2d_fromcontext(const bContext *C)
/* same as above, but it returns regionwindow. Utility for pulldowns or buttons */
View2D *UI_view2d_fromcontext_rwin(const bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- if (sa == NULL) {
+ if (area == NULL) {
return NULL;
}
if (region == NULL) {
return NULL;
}
if (region->regiontype != RGN_TYPE_WINDOW) {
- ARegion *region_win = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ ARegion *region_win = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
return region_win ? &(region_win->v2d) : NULL;
}
return &(region->v2d);
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 2adf441514b..5b1e5f746ef 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -79,9 +79,9 @@ static bool view2d_poll(bContext *C)
*/
typedef struct v2dViewPanData {
/** screen where view pan was initiated */
- bScreen *sc;
+ bScreen *screen;
/** area where view pan was initiated */
- ScrArea *sa;
+ ScrArea *area;
/** region where view pan was initiated */
ARegion *region;
/** view2d we're operating in */
@@ -126,8 +126,8 @@ static int view_pan_init(bContext *C, wmOperator *op)
op->customdata = vpd;
/* set pointers to owners */
- vpd->sc = CTX_wm_screen(C);
- vpd->sa = CTX_wm_area(C);
+ vpd->screen = CTX_wm_screen(C);
+ vpd->area = CTX_wm_area(C);
vpd->v2d = v2d;
vpd->region = region;
@@ -190,7 +190,7 @@ static void view_pan_apply_ex(bContext *C, v2dViewPanData *vpd, float dx, float
/* request updates to be done... */
WM_event_add_mousemove(CTX_wm_window(C));
- UI_view2d_sync(vpd->sc, vpd->sa, v2d, V2D_LOCK_COPY);
+ UI_view2d_sync(vpd->screen, vpd->area, v2d, V2D_LOCK_COPY);
}
static void view_pan_apply(bContext *C, wmOperator *op)
@@ -589,13 +589,13 @@ typedef struct v2dViewZoomData {
*/
static void view_zoom_axis_lock_defaults(bContext *C, bool r_do_zoom_xy[2])
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
r_do_zoom_xy[0] = true;
r_do_zoom_xy[1] = true;
/* default not to zoom the sequencer vertically */
- if (sa && sa->spacetype == SPACE_SEQ) {
+ if (area && area->spacetype == SPACE_SEQ) {
ARegion *region = CTX_wm_region(C);
if (region && region->regiontype == RGN_TYPE_WINDOW) {
@@ -758,8 +758,8 @@ static void view_zoomstep_apply_ex(
UI_view2d_curRect_validate(v2d);
if (ED_region_snap_size_apply(region, snap_test)) {
- ScrArea *sa = CTX_wm_area(C);
- ED_area_tag_redraw(sa);
+ ScrArea *area = CTX_wm_area(C);
+ ED_area_tag_redraw(area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
}
@@ -1017,8 +1017,8 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
UI_view2d_curRect_validate(v2d);
if (ED_region_snap_size_apply(vzd->region, snap_test)) {
- ScrArea *sa = CTX_wm_area(C);
- ED_area_tag_redraw(sa);
+ ScrArea *area = CTX_wm_area(C);
+ ED_area_tag_redraw(area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
}
@@ -2211,8 +2211,8 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op))
UI_view2d_curRect_validate(v2d);
if (ED_region_snap_size_apply(region, snap_test)) {
- ScrArea *sa = CTX_wm_area(C);
- ED_area_tag_redraw(sa);
+ ScrArea *area = CTX_wm_area(C);
+ ED_area_tag_redraw(area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
}
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 9945383211a..767976b5ae6 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -444,11 +444,11 @@ static void mask_point_make_pixel_space(bContext *C,
float point_normalized[2],
float point_pixel[2])
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
float scalex, scaley;
- ED_mask_pixelspace_factor(sa, region, &scalex, &scaley);
+ ED_mask_pixelspace_factor(area, region, &scalex, &scaley);
point_pixel[0] = point_normalized[0] * scalex;
point_pixel[1] = point_normalized[1] * scaley;
@@ -556,12 +556,12 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
float co[2];
- ED_mask_mouse_pos(sa, region, event->mval, co);
+ ED_mask_mouse_pos(area, region, event->mval, co);
RNA_float_set_array(op->ptr, "location", co);
@@ -648,12 +648,12 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op)
static int add_feather_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
float co[2];
- ED_mask_mouse_pos(sa, region, event->mval, co);
+ ED_mask_mouse_pos(area, region, event->mval, co);
RNA_float_set_array(op->ptr, "location", co);
@@ -693,7 +693,7 @@ void MASK_OT_add_feather_vertex(wmOperatorType *ot)
static int create_primitive_from_points(
bContext *C, wmOperator *op, const float (*points)[2], int num_points, char handle_type)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Mask *mask;
MaskLayer *mask_layer;
MaskSpline *new_spline;
@@ -701,7 +701,7 @@ static int create_primitive_from_points(
int i, width, height;
int size = RNA_float_get(op->ptr, "size");
- ED_mask_get_size(sa, &width, &height);
+ ED_mask_get_size(area, &width, &height);
scale = (float)size / max_ii(width, height);
/* Get location in mask space. */
@@ -762,12 +762,12 @@ static int create_primitive_from_points(
static int primitive_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
float cursor[2];
int width, height;
- ED_mask_get_size(sa, &width, &height);
- ED_mask_cursor_location_get(sa, cursor);
+ ED_mask_get_size(area, &width, &height);
+ ED_mask_cursor_location_get(area, cursor);
cursor[0] *= width;
cursor[1] *= height;
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 2fda383ebb7..bea44ee89f8 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -57,7 +57,7 @@
static void mask_spline_color_get(MaskLayer *mask_layer,
MaskSpline *spline,
const bool is_sel,
- unsigned char r_rgb[4])
+ uchar r_rgb[4])
{
if (is_sel) {
if (mask_layer->act_spline == spline) {
@@ -79,7 +79,7 @@ static void mask_spline_color_get(MaskLayer *mask_layer,
static void mask_spline_feather_color_get(MaskLayer *UNUSED(mask_layer),
MaskSpline *UNUSED(spline),
const bool is_sel,
- unsigned char r_rgb[4])
+ uchar r_rgb[4])
{
if (is_sel) {
r_rgb[1] = 255;
@@ -124,7 +124,7 @@ static void draw_single_handle(const MaskLayer *mask_layer,
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- const unsigned char rgb_gray[4] = {0x60, 0x60, 0x60, 0xff};
+ const uchar rgb_gray[4] = {0x60, 0x60, 0x60, 0xff};
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ubv(rgb_gray);
@@ -194,7 +194,7 @@ static void draw_spline_points(const bContext *C,
(mask_layer->restrictflag & MASK_RESTRICT_SELECT) == 0;
const bool is_smooth = (draw_flag & MASK_DRAWFLAG_SMOOTH) != 0;
- unsigned char rgb_spline[4];
+ uchar rgb_spline[4];
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
SpaceClip *sc = CTX_wm_space_clip(C);
bool undistort = false;
@@ -368,28 +368,26 @@ static void draw_spline_points(const bContext *C,
}
}
-static void mask_color_active_tint(unsigned char r_rgb[4],
- const unsigned char rgb[4],
- const bool is_active)
+static void mask_color_active_tint(uchar r_rgb[4], const uchar rgb[4], const bool is_active)
{
if (!is_active) {
- r_rgb[0] = (unsigned char)((((int)(rgb[0])) + 128) / 2);
- r_rgb[1] = (unsigned char)((((int)(rgb[1])) + 128) / 2);
- r_rgb[2] = (unsigned char)((((int)(rgb[2])) + 128) / 2);
+ r_rgb[0] = (uchar)((((int)(rgb[0])) + 128) / 2);
+ r_rgb[1] = (uchar)((((int)(rgb[1])) + 128) / 2);
+ r_rgb[2] = (uchar)((((int)(rgb[2])) + 128) / 2);
r_rgb[3] = rgb[3];
}
else {
- *(unsigned int *)r_rgb = *(const unsigned int *)rgb;
+ *(uint *)r_rgb = *(const uint *)rgb;
}
}
-static void mask_draw_array(unsigned int pos,
+static void mask_draw_array(uint pos,
GPUPrimType prim_type,
const float (*points)[2],
- unsigned int vertex_len)
+ uint vertex_len)
{
immBegin(prim_type, vertex_len);
- for (unsigned int i = 0; i < vertex_len; i++) {
+ for (uint i = 0; i < vertex_len; i++) {
immVertex2fv(pos, points[i]);
}
immEnd();
@@ -401,13 +399,13 @@ static void mask_draw_curve_type(const bContext *C,
int tot_point,
const bool is_feather,
const bool is_active,
- const unsigned char rgb_spline[4],
+ const uchar rgb_spline[4],
const char draw_type)
{
const GPUPrimType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GPU_PRIM_LINE_LOOP :
GPU_PRIM_LINE_STRIP;
- const unsigned char rgb_black[4] = {0x00, 0x00, 0x00, 0xff};
- unsigned char rgb_tmp[4];
+ const uchar rgb_black[4] = {0x00, 0x00, 0x00, 0xff};
+ uchar rgb_tmp[4];
SpaceClip *sc = CTX_wm_space_clip(C);
float(*points)[2] = orig_points;
@@ -469,9 +467,9 @@ static void mask_draw_curve_type(const bContext *C,
}
if (is_feather) {
- rgb_tmp[0] = (unsigned char)(((short)rgb_tmp[0] + (short)rgb_spline[0]) / 2);
- rgb_tmp[1] = (unsigned char)(((short)rgb_tmp[1] + (short)rgb_spline[1]) / 2);
- rgb_tmp[2] = (unsigned char)(((short)rgb_tmp[2] + (short)rgb_spline[2]) / 2);
+ rgb_tmp[0] = (uchar)(((short)rgb_tmp[0] + (short)rgb_spline[0]) / 2);
+ rgb_tmp[1] = (uchar)(((short)rgb_tmp[1] + (short)rgb_spline[1]) / 2);
+ rgb_tmp[2] = (uchar)(((short)rgb_tmp[2] + (short)rgb_spline[2]) / 2);
}
mask_color_active_tint(rgb_tmp, rgb_tmp, is_active);
@@ -525,20 +523,20 @@ static void draw_spline_curve(const bContext *C,
const int width,
const int height)
{
- const unsigned int resol = max_ii(BKE_mask_spline_feather_resolution(spline, width, height),
- BKE_mask_spline_resolution(spline, width, height));
+ const uint resol = max_ii(BKE_mask_spline_feather_resolution(spline, width, height),
+ BKE_mask_spline_resolution(spline, width, height));
- unsigned char rgb_tmp[4];
+ uchar rgb_tmp[4];
const bool is_spline_sel = (spline->flag & SELECT) &&
(mask_layer->restrictflag & MASK_RESTRICT_SELECT) == 0;
const bool is_smooth = (draw_flag & MASK_DRAWFLAG_SMOOTH) != 0;
const bool is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0;
- unsigned int tot_diff_point;
+ uint tot_diff_point;
float(*diff_points)[2];
- unsigned int tot_feather_point;
+ uint tot_feather_point;
float(*feather_points)[2];
diff_points = BKE_mask_spline_differentiate_with_resolution(spline, &tot_diff_point, resol);
@@ -612,7 +610,7 @@ static void draw_mask_layers(const bContext *C,
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
/* draw curve itself first... */
draw_spline_curve(C, mask_layer, spline, draw_flag, draw_type, is_active, width, height);
@@ -640,7 +638,7 @@ static void draw_mask_layers(const bContext *C,
void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Mask *mask = CTX_data_edit_mask(C);
int width, height;
@@ -648,7 +646,7 @@ void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type)
return;
}
- ED_mask_get_size(sa, &width, &height);
+ ED_mask_get_size(area, &width, &height);
draw_mask_layers(C, mask, draw_flag, draw_type, width, height);
}
@@ -801,7 +799,7 @@ void ED_mask_draw_frames(
return;
}
- unsigned int num_lines = BLI_listbase_count(&mask_layer->splines_shapes);
+ uint num_lines = BLI_listbase_count(&mask_layer->splines_shapes);
if (num_lines == 0) {
return;
}
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index e696cc37bd3..663ae0097ad 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -44,9 +44,9 @@
bool ED_maskedit_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- if (sa) {
- switch (sa->spacetype) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area) {
+ switch (area->spacetype) {
case SPACE_CLIP:
return ED_space_clip_maskedit_poll(C);
case SPACE_SEQ:
@@ -60,9 +60,9 @@ bool ED_maskedit_poll(bContext *C)
bool ED_maskedit_mask_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- if (sa) {
- switch (sa->spacetype) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area) {
+ switch (area->spacetype) {
case SPACE_CLIP:
return ED_space_clip_maskedit_mask_poll(C);
case SPACE_SEQ:
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index c4e3763dd94..68dfe0d151f 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -55,16 +55,16 @@
Mask *ED_mask_new(bContext *C, const char *name)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Main *bmain = CTX_data_main(C);
Mask *mask;
mask = BKE_mask_new(bmain, name);
- if (sa && sa->spacedata.first) {
- switch (sa->spacetype) {
+ if (area && area->spacedata.first) {
+ switch (area->spacetype) {
case SPACE_CLIP: {
- SpaceClip *sc = sa->spacedata.first;
+ SpaceClip *sc = area->spacedata.first;
ED_space_clip_set_mask(C, sc, mask);
break;
}
@@ -73,7 +73,7 @@ Mask *ED_mask_new(bContext *C, const char *name)
break;
}
case SPACE_IMAGE: {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
ED_space_image_set_mask(C, sima, mask);
break;
}
@@ -260,7 +260,7 @@ static bool spline_under_mouse_get(const bContext *C,
MaskSpline **r_mask_spline)
{
const float threshold = 19.0f;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceClip *sc = CTX_wm_space_clip(C);
int width, height;
float pixel_co[2];
@@ -270,7 +270,7 @@ static bool spline_under_mouse_get(const bContext *C,
bool undistort = false;
*r_mask_layer = NULL;
*r_mask_spline = NULL;
- ED_mask_get_size(sa, &width, &height);
+ ED_mask_get_size(area, &width, &height);
pixel_co[0] = co[0] * width;
pixel_co[1] = co[1] * height;
if (sc != NULL) {
@@ -420,7 +420,7 @@ static void check_sliding_handle_type(MaskSplinePoint *point, eMaskWhichHandle w
static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *event)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
@@ -435,8 +435,8 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
const float threshold = 19;
eMaskWhichHandle which_handle;
- ED_mask_mouse_pos(sa, region, event->mval, co);
- ED_mask_get_size(sa, &width, &height);
+ ED_mask_mouse_pos(area, region, event->mval, co);
+ ED_mask_get_size(area, &width, &height);
cv_point = ED_mask_point_find_nearest(
C, mask, co, threshold, &cv_mask_layer, &cv_spline, &which_handle, &cv_score);
@@ -534,7 +534,7 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
}
customdata->which_handle = which_handle;
- ED_mask_mouse_pos(sa, region, event->mval, customdata->prev_mouse_coord);
+ ED_mask_mouse_pos(area, region, event->mval, customdata->prev_mouse_coord);
}
return customdata;
@@ -658,11 +658,11 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
ATTR_FALLTHROUGH; /* update CV position */
case MOUSEMOVE: {
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
float delta[2];
- ED_mask_mouse_pos(sa, region, event->mval, co);
+ ED_mask_mouse_pos(area, region, event->mval, co);
sub_v2_v2v2(delta, co, data->prev_mouse_coord);
if (data->is_accurate) {
mul_v2_fl(delta, 0.2f);
@@ -1293,12 +1293,12 @@ static int cyclic_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
if (ED_mask_spline_select_check(spline)) {
spline->flag ^= MASK_SPLINE_CYCLIC;
}
@@ -1371,7 +1371,7 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
Mask *mask = CTX_data_edit_mask(C);
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
MaskSpline *spline;
int mask_layer_shape_ofs = 0;
@@ -1493,14 +1493,14 @@ static int mask_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
bool changed = false;
/* do actual selection */
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
bool changed_layer = false;
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
if (ED_mask_spline_select_check(spline)) {
BKE_mask_spline_direction_switch(mask_layer, spline);
changed = true;
@@ -1551,14 +1551,14 @@ static int mask_normals_make_consistent_exec(bContext *C, wmOperator *UNUSED(op)
bool changed = false;
/* do actual selection */
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
bool changed_layer = false;
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -1614,12 +1614,12 @@ static int set_handle_type_exec(bContext *C, wmOperator *op)
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -1695,7 +1695,7 @@ static int mask_hide_view_clear_exec(bContext *C, wmOperator *op)
bool changed = false;
const bool select = RNA_boolean_get(op->ptr, "select");
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & OB_RESTRICT_VIEWPORT) {
ED_mask_layer_select_set(mask_layer, select);
@@ -1739,7 +1739,7 @@ static int mask_hide_view_set_exec(bContext *C, wmOperator *op)
const bool unselected = RNA_boolean_get(op->ptr, "unselected");
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & MASK_RESTRICT_SELECT) {
continue;
@@ -1801,12 +1801,12 @@ static int mask_feather_weight_clear_exec(bContext *C, wmOperator *UNUSED(op))
Mask *mask = CTX_data_edit_mask(C);
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_SELECT | MASK_RESTRICT_VIEW)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -1935,7 +1935,7 @@ static int mask_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
for (MaskSpline *spline = mask_layer->splines.last; spline; spline = spline->prev) {
MaskSplinePoint *point = spline->points;
int i = 0;
diff --git a/source/blender/editors/mask/mask_query.c b/source/blender/editors/mask/mask_query.c
index 8caf5f2ed7b..cf5997d8a18 100644
--- a/source/blender/editors/mask/mask_query.c
+++ b/source/blender/editors/mask/mask_query.c
@@ -61,7 +61,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
float *r_u,
float *r_score)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
MaskLayer *point_mask_layer;
@@ -75,8 +75,8 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id);
- ED_mask_get_size(sa, &width, &height);
- ED_mask_pixelspace_factor(sa, region, &scalex, &scaley);
+ ED_mask_get_size(area, &width, &height);
+ ED_mask_pixelspace_factor(area, region, &scalex, &scaley);
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
@@ -99,13 +99,13 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
for (i = 0, cur_point_eval = use_deform ? spline_eval->points_deform : spline_eval->points;
i < spline_eval->tot_point;
i++, cur_point_eval++) {
- unsigned int tot_diff_point;
+ uint tot_diff_point;
float *diff_points = BKE_mask_point_segment_diff(
spline_eval, cur_point_eval, width, height, &tot_diff_point);
if (diff_points) {
int j, tot_point;
- unsigned int tot_feather_point;
+ uint tot_feather_point;
float *feather_points = NULL, *points;
if (feather) {
@@ -219,7 +219,7 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
eMaskWhichHandle *r_which_handle,
float *r_score)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
MaskLayer *point_mask_layer = NULL;
@@ -234,8 +234,8 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id);
- ED_mask_get_size(sa, &width, &height);
- ED_mask_pixelspace_factor(sa, region, &scalex, &scaley);
+ ED_mask_get_size(area, &width, &height);
+ ED_mask_pixelspace_factor(area, region, &scalex, &scaley);
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
@@ -374,7 +374,7 @@ bool ED_mask_feather_find_nearest(const bContext *C,
MaskSplinePointUW **r_uw,
float *r_score)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
MaskLayer *point_mask_layer = NULL;
@@ -389,8 +389,8 @@ bool ED_mask_feather_find_nearest(const bContext *C,
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id);
- ED_mask_get_size(sa, &width, &height);
- ED_mask_pixelspace_factor(sa, region, &scalex, &scaley);
+ ED_mask_get_size(area, &width, &height);
+ ED_mask_pixelspace_factor(area, region, &scalex, &scaley);
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
@@ -490,12 +490,12 @@ bool ED_mask_feather_find_nearest(const bContext *C,
}
/* takes event->mval */
-void ED_mask_mouse_pos(ScrArea *sa, ARegion *region, const int mval[2], float co[2])
+void ED_mask_mouse_pos(ScrArea *area, ARegion *region, const int mval[2], float co[2])
{
- if (sa) {
- switch (sa->spacetype) {
+ if (area) {
+ switch (area->spacetype) {
case SPACE_CLIP: {
- SpaceClip *sc = sa->spacedata.first;
+ SpaceClip *sc = area->spacedata.first;
ED_clip_mouse_pos(sc, region, mval, co);
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
break;
@@ -505,7 +505,7 @@ void ED_mask_mouse_pos(ScrArea *sa, ARegion *region, const int mval[2], float co
break;
}
case SPACE_IMAGE: {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
ED_image_mouse_pos(sima, region, mval, co);
BKE_mask_coord_from_image(sima->image, &sima->iuser, co, co);
break;
@@ -525,14 +525,14 @@ void ED_mask_mouse_pos(ScrArea *sa, ARegion *region, const int mval[2], float co
/* input: x/y - mval space
* output: xr/yr - mask point space */
-void ED_mask_point_pos(ScrArea *sa, ARegion *region, float x, float y, float *xr, float *yr)
+void ED_mask_point_pos(ScrArea *area, ARegion *region, float x, float y, float *xr, float *yr)
{
float co[2];
- if (sa) {
- switch (sa->spacetype) {
+ if (area) {
+ switch (area->spacetype) {
case SPACE_CLIP: {
- SpaceClip *sc = sa->spacedata.first;
+ SpaceClip *sc = area->spacedata.first;
ED_clip_point_stable_pos(sc, region, x, y, &co[0], &co[1]);
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
break;
@@ -541,7 +541,7 @@ void ED_mask_point_pos(ScrArea *sa, ARegion *region, float x, float y, float *xr
zero_v2(co); /* MASKTODO */
break;
case SPACE_IMAGE: {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
ED_image_point_pos(sima, region, x, y, &co[0], &co[1]);
BKE_mask_coord_from_image(sima->image, &sima->iuser, co, co);
break;
@@ -563,14 +563,14 @@ void ED_mask_point_pos(ScrArea *sa, ARegion *region, float x, float y, float *xr
}
void ED_mask_point_pos__reverse(
- ScrArea *sa, ARegion *region, float x, float y, float *xr, float *yr)
+ ScrArea *area, ARegion *region, float x, float y, float *xr, float *yr)
{
float co[2];
- if (sa) {
- switch (sa->spacetype) {
+ if (area) {
+ switch (area->spacetype) {
case SPACE_CLIP: {
- SpaceClip *sc = sa->spacedata.first;
+ SpaceClip *sc = area->spacedata.first;
co[0] = x;
co[1] = y;
BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co);
@@ -581,7 +581,7 @@ void ED_mask_point_pos__reverse(
zero_v2(co); /* MASKTODO */
break;
case SPACE_IMAGE: {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
co[0] = x;
co[1] = y;
BKE_mask_coord_to_image(sima->image, &sima->iuser, co, co);
@@ -659,12 +659,12 @@ bool ED_mask_selected_minmax(const bContext *C, float min[2], float max[2])
/** \name Generic 2D View Queries
* \{ */
-void ED_mask_get_size(ScrArea *sa, int *width, int *height)
+void ED_mask_get_size(ScrArea *area, int *width, int *height)
{
- if (sa && sa->spacedata.first) {
- switch (sa->spacetype) {
+ if (area && area->spacedata.first) {
+ switch (area->spacetype) {
case SPACE_CLIP: {
- SpaceClip *sc = sa->spacedata.first;
+ SpaceClip *sc = area->spacedata.first;
ED_space_clip_get_size(sc, width, height);
break;
}
@@ -675,7 +675,7 @@ void ED_mask_get_size(ScrArea *sa, int *width, int *height)
break;
}
case SPACE_IMAGE: {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
ED_space_image_get_size(sima, width, height);
break;
}
@@ -694,12 +694,12 @@ void ED_mask_get_size(ScrArea *sa, int *width, int *height)
}
}
-void ED_mask_zoom(ScrArea *sa, ARegion *region, float *zoomx, float *zoomy)
+void ED_mask_zoom(ScrArea *area, ARegion *region, float *zoomx, float *zoomy)
{
- if (sa && sa->spacedata.first) {
- switch (sa->spacetype) {
+ if (area && area->spacedata.first) {
+ switch (area->spacetype) {
case SPACE_CLIP: {
- SpaceClip *sc = sa->spacedata.first;
+ SpaceClip *sc = area->spacedata.first;
ED_space_clip_get_zoom(sc, region, zoomx, zoomy);
break;
}
@@ -708,7 +708,7 @@ void ED_mask_zoom(ScrArea *sa, ARegion *region, float *zoomx, float *zoomy)
break;
}
case SPACE_IMAGE: {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
ED_space_image_get_zoom(sima, region, zoomx, zoomy);
break;
}
@@ -725,12 +725,12 @@ void ED_mask_zoom(ScrArea *sa, ARegion *region, float *zoomx, float *zoomy)
}
}
-void ED_mask_get_aspect(ScrArea *sa, ARegion *UNUSED(region), float *aspx, float *aspy)
+void ED_mask_get_aspect(ScrArea *area, ARegion *UNUSED(region), float *aspx, float *aspy)
{
- if (sa && sa->spacedata.first) {
- switch (sa->spacetype) {
+ if (area && area->spacedata.first) {
+ switch (area->spacetype) {
case SPACE_CLIP: {
- SpaceClip *sc = sa->spacedata.first;
+ SpaceClip *sc = area->spacedata.first;
ED_space_clip_get_aspect(sc, aspx, aspy);
break;
}
@@ -739,7 +739,7 @@ void ED_mask_get_aspect(ScrArea *sa, ARegion *UNUSED(region), float *aspx, float
break;
}
case SPACE_IMAGE: {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
ED_space_image_get_aspect(sima, aspx, aspy);
break;
}
@@ -756,12 +756,12 @@ void ED_mask_get_aspect(ScrArea *sa, ARegion *UNUSED(region), float *aspx, float
}
}
-void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *region, float *scalex, float *scaley)
+void ED_mask_pixelspace_factor(ScrArea *area, ARegion *region, float *scalex, float *scaley)
{
- if (sa && sa->spacedata.first) {
- switch (sa->spacetype) {
+ if (area && area->spacedata.first) {
+ switch (area->spacetype) {
case SPACE_CLIP: {
- SpaceClip *sc = sa->spacedata.first;
+ SpaceClip *sc = area->spacedata.first;
float aspx, aspy;
UI_view2d_scale_get(&region->v2d, scalex, scaley);
@@ -776,7 +776,7 @@ void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *region, float *scalex, floa
break;
}
case SPACE_IMAGE: {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
float aspx, aspy;
UI_view2d_scale_get(&region->v2d, scalex, scaley);
@@ -799,12 +799,12 @@ void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *region, float *scalex, floa
}
}
-void ED_mask_cursor_location_get(ScrArea *sa, float cursor[2])
+void ED_mask_cursor_location_get(ScrArea *area, float cursor[2])
{
- if (sa) {
- switch (sa->spacetype) {
+ if (area) {
+ switch (area->spacetype) {
case SPACE_CLIP: {
- SpaceClip *space_clip = sa->spacedata.first;
+ SpaceClip *space_clip = area->spacedata.first;
copy_v2_v2(cursor, space_clip->cursor);
break;
}
@@ -813,7 +813,7 @@ void ED_mask_cursor_location_get(ScrArea *sa, float cursor[2])
break;
}
case SPACE_IMAGE: {
- SpaceImage *space_image = sa->spacedata.first;
+ SpaceImage *space_image = area->spacedata.first;
copy_v2_v2(cursor, space_image->cursor);
break;
}
diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c
index 49eb4fbd4ca..971e1c948c9 100644
--- a/source/blender/editors/mask/mask_relationships.c
+++ b/source/blender/editors/mask/mask_relationships.c
@@ -21,6 +21,7 @@
* \ingroup edmask
*/
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
@@ -44,12 +45,12 @@ static int mask_parent_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -136,12 +137,12 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index b21d20b360a..a6dece91eb0 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -24,6 +24,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_lasso_2d.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
@@ -73,7 +74,7 @@ bool ED_mask_layer_select_check(const MaskLayer *mask_layer)
return false;
}
- for (const MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (const MaskSpline *, spline, &mask_layer->splines) {
if (ED_mask_spline_select_check(spline)) {
return true;
}
@@ -84,8 +85,7 @@ bool ED_mask_layer_select_check(const MaskLayer *mask_layer)
bool ED_mask_select_check(const Mask *mask)
{
- for (const MaskLayer *mask_layer = mask->masklayers.first; mask_layer;
- mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (const MaskLayer *, mask_layer, &mask->masklayers) {
if (ED_mask_layer_select_check(mask_layer)) {
return true;
}
@@ -121,7 +121,7 @@ void ED_mask_layer_select_set(MaskLayer *mask_layer, const bool do_select)
}
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
ED_mask_spline_select_set(spline, do_select);
}
}
@@ -137,7 +137,7 @@ void ED_mask_select_toggle_all(Mask *mask, int action)
}
}
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & MASK_RESTRICT_VIEW) {
continue;
@@ -150,7 +150,7 @@ void ED_mask_select_toggle_all(Mask *mask, int action)
if (mask_layer->restrictflag & MASK_RESTRICT_SELECT) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
int i;
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -166,8 +166,8 @@ void ED_mask_select_toggle_all(Mask *mask, int action)
void ED_mask_select_flush_all(Mask *mask)
{
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
spline->flag &= ~SELECT;
/* intentionally _dont_ do this in the mask layer loop
@@ -385,12 +385,12 @@ static int select_exec(bContext *C, wmOperator *op)
static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
float co[2];
- ED_mask_mouse_pos(sa, region, event->mval, co);
+ ED_mask_mouse_pos(area, region, event->mval, co);
RNA_float_set_array(op->ptr, "location", co);
@@ -435,7 +435,7 @@ void MASK_OT_select(wmOperatorType *ot)
static int box_select_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
@@ -454,16 +454,16 @@ static int box_select_exec(bContext *C, wmOperator *op)
/* get rectangle from operator */
WM_operator_properties_border_to_rcti(op, &rect);
- ED_mask_point_pos(sa, region, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
- ED_mask_point_pos(sa, region, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
+ ED_mask_point_pos(area, region, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
+ ED_mask_point_pos(area, region, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
/* do actual selection */
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
for (int i = 0; i < spline->tot_point; i++) {
@@ -525,7 +525,7 @@ static bool do_lasso_select_mask(bContext *C,
short moves,
const eSelectOp sel_op)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
@@ -543,12 +543,12 @@ static bool do_lasso_select_mask(bContext *C,
BLI_lasso_boundbox(&rect, mcords, moves);
/* do actual selection */
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
for (int i = 0; i < spline->tot_point; i++) {
@@ -565,7 +565,7 @@ static bool do_lasso_select_mask(bContext *C,
float screen_co[2];
/* point in screen coords */
- ED_mask_point_pos__reverse(sa,
+ ED_mask_point_pos__reverse(area,
region,
point_deform->bezt.vec[1][0],
point_deform->bezt.vec[1][1],
@@ -651,7 +651,7 @@ static int mask_spline_point_inside_ellipse(BezTriple *bezt,
static int circle_select_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
@@ -667,14 +667,14 @@ static int circle_select_exec(bContext *C, wmOperator *op)
const int radius = RNA_int_get(op->ptr, "radius");
/* compute ellipse and position in unified coordinates */
- ED_mask_get_size(sa, &width, &height);
- ED_mask_zoom(sa, region, &zoomx, &zoomy);
+ ED_mask_get_size(area, &width, &height);
+ ED_mask_zoom(area, region, &zoomx, &zoomy);
width = height = max_ii(width, height);
ellipse[0] = width * zoomx / radius;
ellipse[1] = height * zoomy / radius;
- ED_mask_point_pos(sa, region, x, y, &offset[0], &offset[1]);
+ ED_mask_point_pos(area, region, x, y, &offset[0], &offset[1]);
const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"),
WM_gesture_is_modal_first(op->customdata));
@@ -685,12 +685,12 @@ static int circle_select_exec(bContext *C, wmOperator *op)
}
/* do actual selection */
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
for (i = 0; i < spline->tot_point; i++) {
@@ -748,7 +748,7 @@ void MASK_OT_select_circle(wmOperatorType *ot)
static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
@@ -760,7 +760,7 @@ static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
const float threshold = 19;
bool changed = false;
- ED_mask_mouse_pos(sa, region, event->mval, co);
+ ED_mask_mouse_pos(area, region, event->mval, co);
point = ED_mask_point_find_nearest(C, mask, co, threshold, &mask_layer, &spline, NULL, NULL);
@@ -814,12 +814,12 @@ static int mask_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
bool changed = false;
/* do actual selection */
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
if (ED_mask_spline_select_check(spline)) {
ED_mask_spline_select_set(spline, true);
changed = true;
@@ -864,12 +864,12 @@ static int mask_select_more_less(bContext *C, bool more)
{
Mask *mask = CTX_data_edit_mask(C);
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
const bool cyclic = (spline->flag & MASK_SPLINE_CYCLIC) != 0;
bool start_sel, end_sel, prev_sel, cur_sel;
int i;
diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c
index 25b602d63c3..f264e67d35c 100644
--- a/source/blender/editors/mask/mask_shapekey.c
+++ b/source/blender/editors/mask/mask_shapekey.c
@@ -53,7 +53,7 @@ static int mask_shape_key_insert_exec(bContext *C, wmOperator *UNUSED(op))
Mask *mask = CTX_data_edit_mask(C);
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
MaskLayerShape *mask_layer_shape;
if (!ED_mask_layer_select_check(mask_layer)) {
@@ -98,7 +98,7 @@ static int mask_shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
Mask *mask = CTX_data_edit_mask(C);
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
MaskLayerShape *mask_layer_shape;
if (!ED_mask_layer_select_check(mask_layer)) {
@@ -146,7 +146,7 @@ static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op)
Mask *mask = CTX_data_edit_mask(C);
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
@@ -172,7 +172,7 @@ static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op)
shape_ele_src = (MaskLayerShapeElem *)mask_layer_shape_reset->data;
shape_ele_dst = (MaskLayerShapeElem *)mask_layer_shape->data;
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -243,7 +243,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
const bool do_feather = RNA_boolean_get(op->ptr, "feather");
const bool do_location = RNA_boolean_get(op->ptr, "location");
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
@@ -324,7 +324,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
shape_ele_src = (MaskLayerShapeElem *)mask_layer_shape_tmp->data;
shape_ele_dst = (MaskLayerShapeElem *)mask_layer_shape_tmp_rekey->data;
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -404,7 +404,7 @@ bool ED_mask_layer_shape_auto_key_all(Mask *mask, const int frame)
{
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
ED_mask_layer_shape_auto_key(mask_layer, frame);
changed = true;
}
@@ -416,7 +416,7 @@ bool ED_mask_layer_shape_auto_key_select(Mask *mask, const int frame)
{
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (!ED_mask_layer_select_check(mask_layer)) {
continue;
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 3d20b58b905..b303c4c7e4e 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -190,7 +190,7 @@ void paintface_reveal(bContext *C, Object *ob, const bool select)
/* Set tface seams based on edge data, uses hash table to find seam edges. */
-static void select_linked_tfaces_with_seams(Mesh *me, const unsigned int index, const bool select)
+static void select_linked_tfaces_with_seams(Mesh *me, const uint index, const bool select)
{
MPoly *mp;
MLoop *ml;
@@ -201,7 +201,7 @@ static void select_linked_tfaces_with_seams(Mesh *me, const unsigned int index,
BLI_bitmap *edge_tag = BLI_BITMAP_NEW(me->totedge, __func__);
BLI_bitmap *poly_tag = BLI_BITMAP_NEW(me->totpoly, __func__);
- if (index != (unsigned int)-1) {
+ if (index != (uint)-1) {
/* only put face under cursor in array */
mp = &me->mpoly[index];
BKE_mesh_poly_edgebitmap_insert(edge_tag, mp, me->mloop + mp->loopstart);
@@ -267,7 +267,7 @@ static void select_linked_tfaces_with_seams(Mesh *me, const unsigned int index,
void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const bool select)
{
Mesh *me;
- unsigned int index = (unsigned int)-1;
+ uint index = (uint)-1;
me = BKE_mesh_from_object(ob);
if (me == NULL || me->totpoly == 0) {
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index e91aaea91e0..e94412233ff 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -416,10 +416,10 @@ static bool edbm_bevel_calc(wmOperator *op)
static void edbm_bevel_exit(bContext *C, wmOperator *op)
{
BevelData *opdata = op->customdata;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
- if (sa) {
- ED_area_status_text(sa, NULL);
+ if (area) {
+ ED_area_status_text(area, NULL);
}
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
index 75a36b68f8b..feb6b5aaca9 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
@@ -18,6 +18,7 @@
* \ingroup edmesh
*/
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BKE_context.h"
@@ -1030,7 +1031,7 @@ static void gizmo_mesh_spin_redo_draw_prepare(const bContext *UNUSED(C), wmGizmo
* could shift because of float precision.
* Updates in this case are also redundant. */
bool is_modal = false;
- for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) {
if (gz->state & WM_GIZMO_STATE_MODAL) {
is_modal = true;
break;
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c
index f2983f06da6..2eeada95eda 100644
--- a/source/blender/editors/mesh/editmesh_inset.c
+++ b/source/blender/editors/mesh/editmesh_inset.c
@@ -88,10 +88,10 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C)
"(%s)");
char msg[UI_MAX_DRAW_STR];
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Scene *sce = CTX_data_scene(C);
- if (sa) {
+ if (area) {
char flts_str[NUM_STR_REP_LEN * 2];
if (hasNumInput(&opdata->num_input)) {
outputNumInput(&opdata->num_input, flts_str, &sce->unit);
@@ -111,7 +111,7 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C)
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_boundary")),
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_individual")));
- ED_area_status_text(sa, msg);
+ ED_area_status_text(area, msg);
}
}
@@ -189,7 +189,7 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal)
static void edbm_inset_exit(bContext *C, wmOperator *op)
{
InsetData *opdata;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
opdata = op->customdata;
@@ -206,8 +206,8 @@ static void edbm_inset_exit(bContext *C, wmOperator *op)
G.moving = 0;
}
- if (sa) {
- ED_area_status_text(sa, NULL);
+ if (area) {
+ ED_area_status_text(area, NULL);
}
MEM_SAFE_FREE(opdata->ob_store);
diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c
index 7718a07a55e..0c37a2604d9 100644
--- a/source/blender/editors/mesh/editmesh_intersect.c
+++ b/source/blender/editors/mesh/editmesh_intersect.c
@@ -479,7 +479,7 @@ static bool bm_vert_in_faces_radial(BMVert *v, BMEdge *e_radial, BMFace *f_ignor
struct LinkBase {
LinkNode *list;
- unsigned int list_len;
+ uint list_len;
};
static void ghash_insert_face_edge_link(GHash *gh,
@@ -535,7 +535,7 @@ static void bm_face_split_by_edges_island_connect(
}
{
- unsigned int edge_arr_holes_len;
+ uint edge_arr_holes_len;
BMEdge **edge_arr_holes;
if (BM_face_split_edgenet_connect_islands(bm,
f,
@@ -765,7 +765,7 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op))
BMIter liter;
BMLoop *l;
- unsigned int loop_stack_len;
+ uint loop_stack_len;
BMLoop *l_best = NULL;
BLI_assert(BLI_SMALLSTACK_IS_EMPTY(loop_stack));
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 373dfc811ec..fd92d864a28 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -1579,7 +1579,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
float line_tol, line_tol_sq;
float face_tol, face_tol_sq;
int isect_kind;
- unsigned int tot;
+ uint tot;
int i;
const bool use_hit_prev = true;
const bool use_hit_curr = (kcd->is_drag_hold == false);
@@ -2419,7 +2419,7 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe
edge_array_len = i;
#ifdef USE_NET_ISLAND_CONNECT
- unsigned int edge_array_holes_len;
+ uint edge_array_holes_len;
BMEdge **edge_array_holes;
if (BM_face_split_edgenet_connect_islands(bm,
f,
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index a1ea6074044..5d9923c6a7d 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -402,7 +402,7 @@ static UnorderedLoopPair *edbm_tagged_loop_pairs_to_fill(BMesh *bm)
BMIter iter;
BMEdge *e;
- unsigned int total_tag = 0;
+ uint total_tag = 0;
/* count tags, could be pre-calculated */
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
@@ -441,8 +441,8 @@ static UnorderedLoopPair *edbm_tagged_loop_pairs_to_fill(BMesh *bm)
static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *uloop_pairs)
{
UnorderedLoopPair *ulp;
- unsigned int total_tag = MEM_allocN_len(uloop_pairs) / sizeof(UnorderedLoopPair);
- unsigned int i;
+ uint total_tag = MEM_allocN_len(uloop_pairs) / sizeof(UnorderedLoopPair);
+ uint i;
for (i = 0, ulp = uloop_pairs; i < total_tag; i++, ulp++) {
if ((ulp->l_pair[0] && ulp->l_pair[1]) && (ulp->l_pair[0]->e != ulp->l_pair[1]->e)) {
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 1a25e582859..b9ac24e1d03 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -731,8 +731,10 @@ static int edbm_collapse_edge_exec(bContext *C, wmOperator *op)
void MESH_OT_edge_collapse(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Edge Collapse";
- ot->description = "Collapse selected edges";
+ ot->name = "Collapse Edges & Faces";
+ ot->description =
+ "Collapse isolated edges & faces regions, merging data such as UV's and vertex colors. "
+ "This can collapse edge-rings as well as regions of connected faces into vertices";
ot->idname = "MESH_OT_edge_collapse";
/* api callbacks */
@@ -754,7 +756,7 @@ static bool edbm_add_edge_face__smooth_get(BMesh *bm)
BMEdge *e;
BMIter iter;
- unsigned int vote_on_smooth[2] = {0, 0};
+ uint vote_on_smooth[2] = {0, 0};
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(e, BM_ELEM_SELECT) && e->l) {
@@ -6120,7 +6122,7 @@ static void sort_bmelem_flag(bContext *C,
const int flag,
const int action,
const int reverse,
- const unsigned int seed)
+ const uint seed)
{
BMEditMesh *em = BKE_editmesh_from_object(ob);
@@ -6133,7 +6135,7 @@ static void sort_bmelem_flag(bContext *C,
/* Just to mark protected elements. */
char *pblock[3] = {NULL, NULL, NULL}, *pb;
BMElemSort *sblock[3] = {NULL, NULL, NULL}, *sb;
- unsigned int *map[3] = {NULL, NULL, NULL}, *mp;
+ uint *map[3] = {NULL, NULL, NULL}, *mp;
int totelem[3] = {0, 0, 0};
int affected[3] = {0, 0, 0};
int i, j;
@@ -6310,7 +6312,7 @@ static void sort_bmelem_flag(bContext *C,
}
else if (action == SRT_SELECTED) {
- unsigned int *tbuf[3] = {NULL, NULL, NULL}, *tb;
+ uint *tbuf[3] = {NULL, NULL, NULL}, *tb;
if (totelem[0]) {
tb = tbuf[0] = MEM_callocN(sizeof(int) * totelem[0], "sort_bmelem vert tbuf");
@@ -6574,7 +6576,7 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op)
const int action = RNA_enum_get(op->ptr, "type");
PropertyRNA *prop_elem_types = RNA_struct_find_property(op->ptr, "elements");
const bool use_reverse = RNA_boolean_get(op->ptr, "reverse");
- unsigned int seed = RNA_int_get(op->ptr, "seed");
+ uint seed = RNA_int_get(op->ptr, "seed");
int elem_types = 0;
if (ELEM(action, SRT_VIEW_ZAXIS, SRT_VIEW_XAXIS)) {
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index f44a94a63f8..998e0d736e6 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -370,8 +370,7 @@ void EDBM_mesh_load_ex(Main *bmain, Object *ob, bool free_data)
* cycles.
*/
#if 0
- for (Object *other_object = bmain->objects.first; other_object != NULL;
- other_object = other_object->id.next) {
+ for (Object *other_object = bmain->objects.first; other_object != NULL; other_object = other_object->id.next) {
if (other_object->data == ob->data) {
BKE_object_free_derived_caches(other_object);
}
@@ -406,10 +405,10 @@ void EDBM_mesh_load(Main *bmain, Object *ob)
void EDBM_mesh_free(BMEditMesh *em)
{
/* These tables aren't used yet, so it's not strictly necessary
- * to 'end' them (with 'e' param) but if someone tries to start
- * using them, having these in place will save a lot of pain */
- ED_mesh_mirror_spatial_table(NULL, NULL, NULL, NULL, 'e');
- ED_mesh_mirror_topo_table(NULL, NULL, 'e');
+ * to 'end' them but if someone tries to start using them,
+ * having these in place will save a lot of pain. */
+ ED_mesh_mirror_spatial_table_end(NULL);
+ ED_mesh_mirror_topo_table_end(NULL);
BKE_editmesh_free(em);
}
@@ -539,7 +538,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm,
UvVertMap *vmap;
UvMapVert *buf;
MLoopUV *luv;
- unsigned int a;
+ uint a;
int totverts, i, totuv, totfaces;
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
bool *winding = NULL;
@@ -669,7 +668,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm,
return vmap;
}
-UvMapVert *BM_uv_vert_map_at_index(UvVertMap *vmap, unsigned int v)
+UvMapVert *BM_uv_vert_map_at_index(UvVertMap *vmap, uint v)
{
return vmap->vert[v];
}
@@ -832,7 +831,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
}
if (do_islands) {
- unsigned int *map;
+ uint *map;
BMFace **stack;
int stacksize = 0;
UvElement *islandbuf;
@@ -1224,7 +1223,7 @@ BMFace *EDBM_verts_mirror_get_face(BMEditMesh *em, BMFace *f)
BMVert **v_mirr_arr = BLI_array_alloca(v_mirr_arr, f->len);
BMLoop *l_iter, *l_first;
- unsigned int i = 0;
+ uint i = 0;
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c
index 9b599d8df7f..0bbc8b0df76 100644
--- a/source/blender/editors/mesh/mesh_mirror.c
+++ b/source/blender/editors/mesh/mesh_mirror.c
@@ -44,73 +44,71 @@ static struct {
void *tree;
} MirrKdStore = {NULL};
-/* mode is 's' start, or 'e' end, or 'u' use */
-/* if end, ob can be NULL */
-int ED_mesh_mirror_spatial_table(
- Object *ob, BMEditMesh *em, Mesh *me_eval, const float co[3], char mode)
+void ED_mesh_mirror_spatial_table_begin(Object *ob, BMEditMesh *em, Mesh *me_eval)
{
- if (mode == 'u') { /* use table */
- if (MirrKdStore.tree == NULL) {
- ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's');
- }
-
- if (MirrKdStore.tree) {
- KDTreeNearest_3d nearest;
- const int i = BLI_kdtree_3d_find_nearest(MirrKdStore.tree, co, &nearest);
+ Mesh *me = ob->data;
+ const bool use_em = (!me_eval && em && me->edit_mesh == em);
+ const int totvert = use_em ? em->bm->totvert : me_eval ? me_eval->totvert : me->totvert;
- if (i != -1) {
- if (nearest.dist < KD_THRESH) {
- return i;
- }
- }
- }
- return -1;
+ if (MirrKdStore.tree) { /* happens when entering this call without ending it */
+ ED_mesh_mirror_spatial_table_end(ob);
}
- else if (mode == 's') { /* start table */
- Mesh *me = ob->data;
- const bool use_em = (!me_eval && em && me->edit_mesh == em);
- const int totvert = use_em ? em->bm->totvert : me_eval ? me_eval->totvert : me->totvert;
-
- if (MirrKdStore.tree) { /* happens when entering this call without ending it */
- ED_mesh_mirror_spatial_table(ob, em, me_eval, co, 'e');
- }
- MirrKdStore.tree = BLI_kdtree_3d_new(totvert);
+ MirrKdStore.tree = BLI_kdtree_3d_new(totvert);
- if (use_em) {
- BMVert *eve;
- BMIter iter;
- int i;
+ if (use_em) {
+ BMVert *eve;
+ BMIter iter;
+ int i;
- /* this needs to be valid for index lookups later (callers need) */
- BM_mesh_elem_table_ensure(em->bm, BM_VERT);
+ /* this needs to be valid for index lookups later (callers need) */
+ BM_mesh_elem_table_ensure(em->bm, BM_VERT);
- BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) {
- BLI_kdtree_3d_insert(MirrKdStore.tree, i, eve->co);
- }
+ BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) {
+ BLI_kdtree_3d_insert(MirrKdStore.tree, i, eve->co);
}
- else {
- MVert *mvert = me_eval ? me_eval->mvert : me->mvert;
- int i;
+ }
+ else {
+ MVert *mvert = me_eval ? me_eval->mvert : me->mvert;
+ int i;
- for (i = 0; i < totvert; i++, mvert++) {
- BLI_kdtree_3d_insert(MirrKdStore.tree, i, mvert->co);
- }
+ for (i = 0; i < totvert; i++, mvert++) {
+ BLI_kdtree_3d_insert(MirrKdStore.tree, i, mvert->co);
}
+ }
+
+ BLI_kdtree_3d_balance(MirrKdStore.tree);
+}
- BLI_kdtree_3d_balance(MirrKdStore.tree);
+int ED_mesh_mirror_spatial_table_lookup(Object *ob,
+ BMEditMesh *em,
+ Mesh *me_eval,
+ const float co[3])
+{
+ if (MirrKdStore.tree == NULL) {
+ ED_mesh_mirror_spatial_table_begin(ob, em, me_eval);
}
- else if (mode == 'e') { /* end table */
- if (MirrKdStore.tree) {
- BLI_kdtree_3d_free(MirrKdStore.tree);
- MirrKdStore.tree = NULL;
+
+ if (MirrKdStore.tree) {
+ KDTreeNearest_3d nearest;
+ const int i = BLI_kdtree_3d_find_nearest(MirrKdStore.tree, co, &nearest);
+
+ if (i != -1) {
+ if (nearest.dist < KD_THRESH) {
+ return i;
+ }
}
}
- else {
- BLI_assert(0);
- }
+ return -1;
+}
- return 0;
+void ED_mesh_mirror_spatial_table_end(Object *UNUSED(ob))
+{
+ /* TODO: store this in object/object-data (keep unused argument for now). */
+ if (MirrKdStore.tree) {
+ BLI_kdtree_3d_free(MirrKdStore.tree);
+ MirrKdStore.tree = NULL;
+ }
}
/** \} */
@@ -119,7 +117,7 @@ int ED_mesh_mirror_spatial_table(
/** \name Mesh Topology Mirror API
* \{ */
-typedef unsigned int MirrTopoHash_t;
+typedef uint MirrTopoHash_t;
typedef struct MirrTopoVert_t {
MirrTopoHash_t hash;
@@ -231,7 +229,7 @@ void ED_mesh_mirrtopo_init(BMEditMesh *em,
medge = me->medge;
for (a = 0, med = medge; a < totedge; a++, med++) {
- const unsigned int i1 = med->v1, i2 = med->v2;
+ const uint i1 = med->v1, i2 = med->v2;
topo_hash[i1]++;
topo_hash[i2]++;
}
@@ -257,7 +255,7 @@ void ED_mesh_mirrtopo_init(BMEditMesh *em,
}
else {
for (a = 0, med = medge; a < totedge; a++, med++) {
- const unsigned int i1 = med->v1, i2 = med->v2;
+ const uint i1 = med->v1, i2 = med->v2;
topo_hash[i1] += topo_hash_prev[i2] * topo_pass;
topo_hash[i2] += topo_hash_prev[i1] * topo_pass;
tot_unique_edges += (topo_hash[i1] != topo_hash[i2]);
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 6c5106d3eec..8dbd468d04f 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -161,7 +161,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
*/
if (key) {
/* if this mesh has any shapekeys, check first, otherwise just copy coordinates */
- for (KeyBlock *kb = key->block.first; kb; kb = kb->next) {
+ LISTBASE_FOREACH (KeyBlock *, kb, &key->block) {
/* get pointer to where to write data for this mesh in shapekey's data array */
float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs;
@@ -191,7 +191,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
* - otherwise, copy across plain coordinates (no need to transform coordinates)
*/
if (key) {
- for (KeyBlock *kb = key->block.first; kb; kb = kb->next) {
+ LISTBASE_FOREACH (KeyBlock *, kb, &key->block) {
/* get pointer to where to write data for this mesh in shapekey's data array */
float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs;
@@ -440,7 +440,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
/* Join this object's face maps to the base one's. */
- for (bFaceMap *fmap = ob_iter->fmaps.first; fmap; fmap = fmap->next) {
+ LISTBASE_FOREACH (bFaceMap *, fmap, &ob_iter->fmaps) {
/* See if this group exists in the object (if it doesn't, add it to the end) */
if (BKE_object_facemap_find_name(ob, fmap->name) == NULL) {
bFaceMap *fmap_new = MEM_mallocN(sizeof(bFaceMap), "join faceMap");
@@ -786,62 +786,73 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
}
/* -------------------------------------------------------------------- */
-/* Mesh Mirror (Topology) */
-
/** \name Mesh Topology Mirror API
* \{ */
static MirrTopoStore_t mesh_topo_store = {NULL, -1. - 1, -1};
+BLI_INLINE void mesh_mirror_topo_table_get_meshes(Object *ob,
+ Mesh *me_eval,
+ Mesh **r_me_mirror,
+ BMEditMesh **r_em_mirror)
+{
+ Mesh *me_mirror = NULL;
+ BMEditMesh *em_mirror = NULL;
+
+ Mesh *me = ob->data;
+ if (me_eval != NULL) {
+ me_mirror = me_eval;
+ }
+ else if (me->edit_mesh != NULL) {
+ em_mirror = me->edit_mesh;
+ }
+ else {
+ me_mirror = me;
+ }
+
+ *r_me_mirror = me_mirror;
+ *r_em_mirror = em_mirror;
+}
+
/**
* Mode is 's' start, or 'e' end, or 'u' use
* if end, ob can be NULL.
* \note This is supposed return -1 on error,
* which callers are currently checking for, but is not used so far.
*/
-int ED_mesh_mirror_topo_table(Object *ob, Mesh *me_eval, char mode)
+void ED_mesh_mirror_topo_table_begin(Object *ob, Mesh *me_eval)
{
+ Mesh *me_mirror;
+ BMEditMesh *em_mirror;
+ mesh_mirror_topo_table_get_meshes(ob, me_eval, &me_mirror, &em_mirror);
- Mesh *me_mirror = NULL;
- BMEditMesh *em_mirror = NULL;
+ ED_mesh_mirrtopo_init(em_mirror, me_mirror, &mesh_topo_store, false);
+}
- if (mode != 'e') {
- Mesh *me = ob->data;
- if (me_eval != NULL) {
- me_mirror = me_eval;
- }
- else if (me->edit_mesh != NULL) {
- em_mirror = me->edit_mesh;
- }
- else {
- me_mirror = me;
- }
- }
+void ED_mesh_mirror_topo_table_end(Object *UNUSED(ob))
+{
+ /* TODO: store this in object/object-data (keep unused argument for now). */
+ ED_mesh_mirrtopo_free(&mesh_topo_store);
+}
- if (mode == 'u') { /* use table */
- if (ED_mesh_mirrtopo_recalc_check(em_mirror, me_mirror, &mesh_topo_store)) {
- ED_mesh_mirror_topo_table(ob, me_eval, 's');
- }
- }
- else if (mode == 's') { /* start table */
- ED_mesh_mirrtopo_init(em_mirror, me_mirror, &mesh_topo_store, false);
- }
- else if (mode == 'e') { /* end table */
- ED_mesh_mirrtopo_free(&mesh_topo_store);
- }
- else {
- BLI_assert(0);
- }
+static int ed_mesh_mirror_topo_table_update(Object *ob, Mesh *me_eval)
+{
+ Mesh *me_mirror;
+ BMEditMesh *em_mirror;
+ mesh_mirror_topo_table_get_meshes(ob, me_eval, &me_mirror, &em_mirror);
+ if (ED_mesh_mirrtopo_recalc_check(em_mirror, me_mirror, &mesh_topo_store)) {
+ ED_mesh_mirror_topo_table_begin(ob, me_eval);
+ }
return 0;
}
/** \} */
-static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *mesh, int index)
+static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *me_eval, int index)
{
Mesh *me = ob->data;
- MVert *mvert = mesh ? mesh->mvert : me->mvert;
+ MVert *mvert = me_eval ? me_eval->mvert : me->mvert;
float vec[3];
mvert = &mvert[index];
@@ -849,12 +860,12 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *mesh, int index)
vec[1] = mvert->co[1];
vec[2] = mvert->co[2];
- return ED_mesh_mirror_spatial_table(ob, NULL, mesh, vec, 'u');
+ return ED_mesh_mirror_spatial_table_lookup(ob, NULL, me_eval, vec);
}
static int mesh_get_x_mirror_vert_topo(Object *ob, Mesh *mesh, int index)
{
- if (ED_mesh_mirror_topo_table(ob, mesh, 'u') == -1) {
+ if (ed_mesh_mirror_topo_table_update(ob, mesh) == -1) {
return -1;
}
@@ -885,7 +896,7 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c
vec[1] = co[1];
vec[2] = co[2];
- i = ED_mesh_mirror_spatial_table(ob, em, NULL, vec, 'u');
+ i = ED_mesh_mirror_spatial_table_lookup(ob, em, NULL, vec);
if (i != -1) {
return BM_vert_at_index(em->bm, i);
}
@@ -898,7 +909,7 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob,
int index)
{
intptr_t poinval;
- if (ED_mesh_mirror_topo_table(ob, NULL, 'u') == -1) {
+ if (ed_mesh_mirror_topo_table_update(ob, NULL) == -1) {
return NULL;
}
@@ -1023,10 +1034,10 @@ static float *editmesh_get_mirror_uv(
#endif
-static unsigned int mirror_facehash(const void *ptr)
+static uint mirror_facehash(const void *ptr)
{
const MFace *mf = ptr;
- unsigned int v0, v1;
+ uint v0, v1;
if (mf->v4) {
v0 = MIN4(mf->v1, mf->v2, mf->v3, mf->v4);
@@ -1098,13 +1109,13 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
mvert = me_eval ? me_eval->mvert : me->mvert;
mface = me_eval ? me_eval->mface : me->mface;
- ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's');
+ ED_mesh_mirror_spatial_table_begin(ob, em, me_eval);
for (a = 0, mv = mvert; a < totvert; a++, mv++) {
mirrorverts[a] = mesh_get_x_mirror_vert(ob, me_eval, a, use_topology);
}
- ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 'e');
+ ED_mesh_mirror_spatial_table_end(ob);
fhash = BLI_ghash_new_ex(mirror_facehash, mirror_facecmp, "mirror_facehash gh", me->totface);
for (a = 0, mf = mface; a < totface; a++, mf++) {
@@ -1119,8 +1130,8 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
/* make sure v4 is not 0 if a quad */
if (mf->v4 && mirrormf.v4 == 0) {
- SWAP(unsigned int, mirrormf.v1, mirrormf.v3);
- SWAP(unsigned int, mirrormf.v2, mirrormf.v4);
+ SWAP(uint, mirrormf.v1, mirrormf.v3);
+ SWAP(uint, mirrormf.v2, mirrormf.v4);
}
hashmf = BLI_ghash_lookup(fhash, &mirrormf);
@@ -1174,7 +1185,7 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px,
*r_index = DRW_select_buffer_sample_point(vc.depsgraph, vc.region, vc.v3d, mval);
}
- if ((*r_index) == 0 || (*r_index) > (unsigned int)me->totpoly) {
+ if ((*r_index) == 0 || (*r_index) > (uint)me->totpoly) {
return false;
}
@@ -1218,7 +1229,7 @@ bool ED_mesh_pick_face_vert(
bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index)
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- unsigned int poly_index;
+ uint poly_index;
Mesh *me = ob->data;
BLI_assert(me && GS(me->id.name) == ID_ME);
@@ -1241,7 +1252,7 @@ bool ED_mesh_pick_face_vert(
MPoly *me_eval_mpoly;
MLoop *me_eval_mloop;
MVert *me_eval_mvert;
- unsigned int me_eval_mpoly_len;
+ uint me_eval_mpoly_len;
const int *index_mp_to_orig;
me_eval_mpoly = me_eval->mpoly;
@@ -1254,7 +1265,7 @@ bool ED_mesh_pick_face_vert(
/* tag all verts using this face */
if (index_mp_to_orig) {
- unsigned int i;
+ uint i;
for (i = 0; i < me_eval_mpoly_len; i++) {
if (index_mp_to_orig[i] == poly_index) {
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index a64674deda4..9386c466f95 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -456,7 +456,7 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op)
RNG *rng = BLI_rng_new_srandom(seed_iter);
- for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
if (BLI_rng_get_float(rng) < randfac) {
if (select) {
ml->flag |= SELECT;
@@ -656,7 +656,7 @@ static int reveal_metaelems_exec(bContext *C, wmOperator *op)
const bool select = RNA_boolean_get(op->ptr, "select");
bool changed = false;
- for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
if (ml->flag & MB_HIDE) {
SET_FLAG_FROM_TEST(ml->flag, select, SELECT);
ml->flag &= ~MB_HIDE;
@@ -697,7 +697,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
static MetaElem *startelem = NULL;
ViewContext vc;
int a, hits;
- unsigned int buffer[MAXPICKBUF];
+ uint buffer[MAXPICKBUF];
rcti rect;
ED_view3d_viewcontext_init(C, &vc, depsgraph);
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt
index 2328f0196d5..6cd67418571 100644
--- a/source/blender/editors/object/CMakeLists.txt
+++ b/source/blender/editors/object/CMakeLists.txt
@@ -18,6 +18,7 @@
set(INC
../include
../../blenkernel
+ ../../blenfont
../../blenlib
../../blentranslation
../../bmesh
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index ac2958282c1..9119d1cac86 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -53,8 +53,7 @@
#include "BLT_translation.h"
#include "BKE_action.h"
-#include "BKE_anim.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_armature.h"
#include "BKE_camera.h"
#include "BKE_collection.h"
@@ -62,6 +61,7 @@
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_displist.h"
+#include "BKE_duplilist.h"
#include "BKE_effect.h"
#include "BKE_font.h"
#include "BKE_gpencil_geom.h"
@@ -1738,10 +1738,10 @@ static void copy_object_set_idnew(bContext *C)
* In other words, we consider each group of objects from a same item as being
* the 'local group' where to check for parents.
*/
-static unsigned int dupliobject_hash(const void *ptr)
+static uint dupliobject_hash(const void *ptr)
{
const DupliObject *dob = ptr;
- unsigned int hash = BLI_ghashutil_ptrhash(dob->ob);
+ uint hash = BLI_ghashutil_ptrhash(dob->ob);
if (dob->type == OB_DUPLICOLLECTION) {
for (int i = 1; (i < MAX_DUPLI_RECUR) && dob->persistent_id[i] != INT_MAX; i++) {
@@ -1760,10 +1760,10 @@ static unsigned int dupliobject_hash(const void *ptr)
* since its a unique index and we only want to know if the group objects are from the same
* dupli-group instance.
*/
-static unsigned int dupliobject_instancer_hash(const void *ptr)
+static uint dupliobject_instancer_hash(const void *ptr)
{
const DupliObject *dob = ptr;
- unsigned int hash = BLI_ghashutil_inthash(dob->persistent_id[0]);
+ uint hash = BLI_ghashutil_inthash(dob->persistent_id[0]);
for (int i = 1; (i < MAX_DUPLI_RECUR) && dob->persistent_id[i] != INT_MAX; i++) {
hash ^= (dob->persistent_id[i] ^ i);
}
@@ -2255,7 +2255,7 @@ static int convert_exec(bContext *C, wmOperator *op)
* needed since re-evaluating single modifiers causes bugs if they depend
* on other objects data masks too, see: T50950. */
{
- for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) {
+ LISTBASE_FOREACH (CollectionPointerLink *, link, &selected_editable_bases) {
Base *base = link->ptr.data;
Object *ob = base->object;
@@ -2282,7 +2282,7 @@ static int convert_exec(bContext *C, wmOperator *op)
scene->customdata_mask = customdata_mask_prev;
}
- for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) {
+ LISTBASE_FOREACH (CollectionPointerLink *, link, &selected_editable_bases) {
Object *newob = NULL;
Base *base = link->ptr.data;
Object *ob = base->object;
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 7d39d2546b6..d625b770164 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -116,7 +116,7 @@ typedef struct BakeAPIRender {
short *do_update;
/* for redrawing */
- ScrArea *sa;
+ ScrArea *area;
} BakeAPIRender;
/* callbacks */
@@ -161,10 +161,10 @@ static int bake_break(void *UNUSED(rjv))
return 0;
}
-static void bake_update_image(ScrArea *sa, Image *image)
+static void bake_update_image(ScrArea *area, Image *image)
{
- if (sa && sa->spacetype == SPACE_IMAGE) { /* in case the user changed while baking */
- SpaceImage *sima = sa->spacedata.first;
+ if (area && area->spacetype == SPACE_IMAGE) { /* in case the user changed while baking */
+ SpaceImage *sima = area->spacedata.first;
if (sima) {
sima->image = image;
}
@@ -234,7 +234,7 @@ static bool write_internal_bake_pixels(Image *image,
ibuf->x);
}
else {
- IMB_buffer_byte_from_float((unsigned char *)ibuf->rect,
+ IMB_buffer_byte_from_float((uchar *)ibuf->rect,
buffer,
ibuf->channels,
ibuf->dither,
@@ -259,7 +259,7 @@ static bool write_internal_bake_pixels(Image *image,
mask_buffer);
}
else {
- IMB_buffer_byte_from_float_mask((unsigned char *)ibuf->rect,
+ IMB_buffer_byte_from_float_mask((uchar *)ibuf->rect,
buffer,
ibuf->channels,
ibuf->dither,
@@ -359,7 +359,7 @@ static bool write_external_bake_pixels(const char *filepath,
buffer, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, false);
}
- IMB_buffer_byte_from_float((unsigned char *)ibuf->rect,
+ IMB_buffer_byte_from_float((uchar *)ibuf->rect,
buffer,
ibuf->channels,
ibuf->dither,
@@ -743,7 +743,7 @@ static int bake(Render *re,
const int width,
const int height,
const char *identifier,
- ScrArea *sa,
+ ScrArea *area,
const char *uv_layer)
{
/* We build a depsgraph for the baking,
@@ -1146,7 +1146,7 @@ static int bake(Render *re,
is_noncolor);
/* might be read by UI to set active image for display */
- bake_update_image(sa, bk_image->image);
+ bake_update_image(area, bk_image->image);
if (!ok) {
BKE_reportf(reports,
@@ -1283,13 +1283,13 @@ cleanup:
static void bake_init_api_data(wmOperator *op, bContext *C, BakeAPIRender *bkr)
{
bool is_save_internal;
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
bkr->ob = CTX_data_active_object(C);
bkr->main = CTX_data_main(C);
bkr->view_layer = CTX_data_view_layer(C);
bkr->scene = CTX_data_scene(C);
- bkr->sa = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL;
+ bkr->area = screen ? BKE_screen_find_big_area(screen, SPACE_IMAGE, 10) : NULL;
bkr->pass_type = RNA_enum_get(op->ptr, "type");
bkr->pass_filter = RNA_enum_get(op->ptr, "pass_filter");
@@ -1400,7 +1400,7 @@ static int bake_exec(bContext *C, wmOperator *op)
bkr.width,
bkr.height,
bkr.identifier,
- bkr.sa,
+ bkr.area,
bkr.uv_layer);
}
else {
@@ -1432,7 +1432,7 @@ static int bake_exec(bContext *C, wmOperator *op)
bkr.width,
bkr.height,
bkr.identifier,
- bkr.sa,
+ bkr.area,
bkr.uv_layer);
}
}
@@ -1501,7 +1501,7 @@ static void bake_startjob(void *bkv, short *UNUSED(stop), short *do_update, floa
bkr->width,
bkr->height,
bkr->identifier,
- bkr->sa,
+ bkr->area,
bkr->uv_layer);
}
else {
@@ -1533,7 +1533,7 @@ static void bake_startjob(void *bkv, short *UNUSED(stop), short *do_update, floa
bkr->width,
bkr->height,
bkr->identifier,
- bkr->sa,
+ bkr->area,
bkr->uv_layer);
if (bkr->result == OPERATOR_CANCELLED) {
diff --git a/source/blender/editors/object/object_data_transform.c b/source/blender/editors/object/object_data_transform.c
index fc91cbb9666..54fd1fe6671 100644
--- a/source/blender/editors/object/object_data_transform.c
+++ b/source/blender/editors/object/object_data_transform.c
@@ -92,7 +92,7 @@ static struct ElemData_Armature *armature_coords_and_quats_get_recurse(
const ListBase *bone_base, struct ElemData_Armature *elem_array)
{
struct ElemData_Armature *elem = elem_array;
- for (const Bone *bone = bone_base->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (const Bone *, bone, bone_base) {
#define COPY_PTR(member) memcpy(elem->member, bone->member, sizeof(bone->member))
#define COPY_VAL(member) memcpy(&elem->member, &bone->member, sizeof(bone->member))
@@ -125,7 +125,7 @@ static const struct ElemData_Armature *armature_coords_and_quats_apply_with_mat4
ListBase *bone_base, const struct ElemData_Armature *elem_array, const float mat[4][4])
{
const struct ElemData_Armature *elem = elem_array;
- for (Bone *bone = bone_base->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, bone_base) {
#define COPY_PTR(member) memcpy(bone->member, elem->member, sizeof(bone->member))
#define COPY_VAL(member) memcpy(&bone->member, &elem->member, sizeof(bone->member))
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 7faad5cdd0e..5506895613b 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -54,7 +54,7 @@
#include "IMB_imbuf_types.h"
-#include "BKE_anim.h"
+#include "BKE_anim_visualization.h"
#include "BKE_collection.h"
#include "BKE_constraint.h"
#include "BKE_context.h"
@@ -166,7 +166,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op)
const bool select = RNA_boolean_get(op->ptr, "select");
bool changed = false;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->flag & BASE_HIDDEN) {
base->flag &= ~BASE_HIDDEN;
changed = true;
@@ -217,7 +217,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
bool changed = false;
/* Hide selected or unselected objects. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (!(base->flag & BASE_VISIBLE_VIEWLAYER)) {
continue;
}
@@ -321,7 +321,7 @@ void ED_collection_hide_menu_draw(const bContext *C, uiLayout *layout)
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
- for (LayerCollection *lc = lc_scene->layer_collections.first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, &lc_scene->layer_collections) {
int index = BKE_layer_collection_findindex(view_layer, lc);
uiLayout *row = uiLayoutRow(layout, false);
@@ -414,7 +414,7 @@ static bool mesh_needs_keyindex(Main *bmain, const Mesh *me)
return true;
}
if (ob->data == me) {
- for (const ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (const ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Hook) {
return true;
}
@@ -454,8 +454,8 @@ static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool f
}
/* will be recalculated as needed. */
{
- ED_mesh_mirror_spatial_table(NULL, NULL, NULL, NULL, 'e');
- ED_mesh_mirror_topo_table(NULL, NULL, 'e');
+ ED_mesh_mirror_spatial_table_end(obedit);
+ ED_mesh_mirror_topo_table_end(obedit);
}
}
else if (obedit->type == OB_ARMATURE) {
@@ -1593,7 +1593,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- for (LinkData *link = objects.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &objects) {
Object *ob = link->data;
if (!is_link) {
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 6e4b33297b6..f18b223a713 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -292,6 +292,7 @@ void TRANSFORM_OT_vertex_random(struct wmOperatorType *ot);
/* object_remesh.c */
void OBJECT_OT_voxel_remesh(struct wmOperatorType *ot);
+void OBJECT_OT_voxel_size_edit(struct wmOperatorType *ot);
void OBJECT_OT_quadriflow_remesh(struct wmOperatorType *ot);
/* object_transfer_data.c */
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 90794104686..a050b71325b 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2150,7 +2150,7 @@ static int correctivesmooth_bind_exec(bContext *C, wmOperator *op)
/* Signal to modifier to recalculate. */
CorrectiveSmoothModifierData *csmd_eval = (CorrectiveSmoothModifierData *)
modifier_get_evaluated(depsgraph, ob, &csmd->modifier);
- csmd_eval->bind_coords_num = (unsigned int)-1;
+ csmd_eval->bind_coords_num = (uint)-1;
/* Force modifier to run, it will call binding routine
* (this has to happen outside of depsgraph evaluation). */
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index b15e2a851b5..c68aa1bc7d2 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -265,6 +265,8 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_hide_collection);
WM_operatortype_append(OBJECT_OT_voxel_remesh);
+ WM_operatortype_append(OBJECT_OT_voxel_size_edit);
+
WM_operatortype_append(OBJECT_OT_quadriflow_remesh);
WM_operatortype_append(OBJECT_OT_bparticles_clear_cache);
diff --git a/source/blender/editors/object/object_random.c b/source/blender/editors/object/object_random.c
index 43aaecb887b..a6958c798f1 100644
--- a/source/blender/editors/object/object_random.c
+++ b/source/blender/editors/object/object_random.c
@@ -50,7 +50,7 @@ static bool object_rand_transverts(TransVertStore *tvs,
const float offset,
const float uniform,
const float normal_factor,
- const unsigned int seed)
+ const uint seed)
{
bool use_normal = (normal_factor != 0.0f);
struct RNG *rng;
@@ -100,7 +100,7 @@ static int object_rand_verts_exec(bContext *C, wmOperator *op)
const float offset = RNA_float_get(op->ptr, "offset");
const float uniform = RNA_float_get(op->ptr, "uniform");
const float normal_factor = RNA_float_get(op->ptr, "normal");
- const unsigned int seed = RNA_int_get(op->ptr, "seed");
+ const uint seed = RNA_int_get(op->ptr, "seed");
bool changed_multi = false;
uint objects_len = 0;
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 3166c9ddea1..256e32c7bfc 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -55,7 +55,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_action.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_armature.h"
#include "BKE_camera.h"
#include "BKE_collection.h"
@@ -1424,7 +1424,7 @@ void OBJECT_OT_track_set(wmOperatorType *ot)
* \{ */
#if 0
-static void link_to_scene(Main *UNUSED(bmain), unsigned short UNUSED(nr))
+static void link_to_scene(Main *UNUSED(bmain), ushort UNUSED(nr))
{
Scene *sce = (Scene *)BLI_findlink(&bmain->scene, G.curscreen->scenenr - 1);
Base *base, *nbase;
@@ -1753,7 +1753,7 @@ static void libblock_relink_collection(Collection *collection, const bool do_col
BKE_libblock_relink_to_newid(&cob->ob->id);
}
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
libblock_relink_collection(child->collection, true);
}
}
@@ -1772,7 +1772,7 @@ static Collection *single_object_users_collection(Main *bmain,
}
/* We do not remap to new objects here, this is done in separate step. */
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
Object *ob = cob->ob;
/* an object may be in more than one collection */
if ((ob->id.newid == NULL) && ((ob->flag & flag) == flag)) {
@@ -2106,7 +2106,7 @@ void ED_object_single_users(Main *bmain,
if (scene->nodetree) {
IDP_RelinkProperty(scene->nodetree->id.properties);
- for (bNode *node = scene->nodetree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &scene->nodetree->nodes) {
IDP_RelinkProperty(node->prop);
}
}
@@ -2245,7 +2245,7 @@ static void make_local_animdata_tag(AnimData *adt)
/* TODO: need to handle the ID-targets too? */
/* NLA Data */
- for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
+ LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
make_local_animdata_tag_strips(&nlt->strips);
}
}
diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c
index a9f2319d926..b2b372df055 100644
--- a/source/blender/editors/object/object_remesh.c
+++ b/source/blender/editors/object/object_remesh.c
@@ -37,6 +37,9 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_userdef_types.h"
+
+#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
@@ -61,22 +64,38 @@
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_sculpt.h"
+#include "ED_space_api.h"
#include "ED_undo.h"
+#include "ED_view3d.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
+#include "GPU_draw.h"
+#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
+#include "GPU_matrix.h"
+#include "GPU_state.h"
+
#include "WM_api.h"
#include "WM_message.h"
#include "WM_toolsystem.h"
#include "WM_types.h"
+#include "UI_interface.h"
+
+#include "BLF_api.h"
+
#include "object_intern.h" // own include
/* TODO(sebpa): unstable, can lead to unrecoverable errors. */
// #define USE_MESH_CURVATURE
+/* -------------------------------------------------------------------- */
+/** \name Voxel Remesh Operator
+ * \{ */
+
static bool object_remesh_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
@@ -188,16 +207,413 @@ void OBJECT_OT_voxel_remesh(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Voxel Size Operator
+ * \{ */
+
+#define VOXEL_SIZE_EDIT_MAX_GRIDS_LINES 500
+#define VOXEL_SIZE_EDIT_MAX_STR_LEN 20
+
+typedef struct VoxelSizeEditCustomData {
+ void *draw_handle;
+ Object *active_object;
+
+ float init_mval[2];
+ float slow_mval[2];
+
+ bool slow_mode;
+
+ float init_voxel_size;
+ float slow_voxel_size;
+ float voxel_size;
+
+ float preview_plane[4][3];
+
+ float text_mat[4][4];
+} VoxelSizeEditCustomData;
+
+static void voxel_size_parallel_lines_draw(uint pos3d,
+ const float initial_co[3],
+ const float end_co[3],
+ const float length_co[3],
+ const float spacing)
+{
+ const float total_len = len_v3v3(initial_co, end_co);
+ const int tot_lines = (int)(total_len / spacing);
+ const int tot_lines_half = (tot_lines / 2) + 1;
+ float spacing_dir[3], lines_start[3];
+ float line_dir[3];
+ sub_v3_v3v3(spacing_dir, end_co, initial_co);
+ normalize_v3(spacing_dir);
+
+ sub_v3_v3v3(line_dir, length_co, initial_co);
+
+ if (tot_lines > VOXEL_SIZE_EDIT_MAX_GRIDS_LINES || tot_lines <= 1) {
+ return;
+ }
+
+ mid_v3_v3v3(lines_start, initial_co, end_co);
+
+ immBegin(GPU_PRIM_LINES, (uint)tot_lines_half * 2);
+ for (int i = 0; i < tot_lines_half; i++) {
+ float line_start[3];
+ float line_end[3];
+ madd_v3_v3v3fl(line_start, lines_start, spacing_dir, spacing * i);
+ add_v3_v3v3(line_end, line_start, line_dir);
+ immVertex3fv(pos3d, line_start);
+ immVertex3fv(pos3d, line_end);
+ }
+ immEnd();
+
+ mul_v3_fl(spacing_dir, -1.0f);
+
+ immBegin(GPU_PRIM_LINES, (uint)(tot_lines_half - 1) * 2);
+ for (int i = 1; i < tot_lines_half; i++) {
+ float line_start[3];
+ float line_end[3];
+ madd_v3_v3v3fl(line_start, lines_start, spacing_dir, spacing * i);
+ add_v3_v3v3(line_end, line_start, line_dir);
+ immVertex3fv(pos3d, line_start);
+ immVertex3fv(pos3d, line_end);
+ }
+ immEnd();
+}
+
+static void voxel_size_edit_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg)
+{
+ VoxelSizeEditCustomData *cd = arg;
+
+ GPU_blend(true);
+ GPU_line_smooth(true);
+
+ uint pos3d = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+ GPU_matrix_push();
+ GPU_matrix_mul(cd->active_object->obmat);
+
+ /* Draw Rect */
+ immUniformColor4f(0.9f, 0.9f, 0.9f, 0.8f);
+ GPU_line_width(3.0f);
+
+ immBegin(GPU_PRIM_LINES, 8);
+ immVertex3fv(pos3d, cd->preview_plane[0]);
+ immVertex3fv(pos3d, cd->preview_plane[1]);
+
+ immVertex3fv(pos3d, cd->preview_plane[1]);
+ immVertex3fv(pos3d, cd->preview_plane[2]);
+
+ immVertex3fv(pos3d, cd->preview_plane[2]);
+ immVertex3fv(pos3d, cd->preview_plane[3]);
+
+ immVertex3fv(pos3d, cd->preview_plane[3]);
+ immVertex3fv(pos3d, cd->preview_plane[0]);
+ immEnd();
+
+ /* Draw Grid */
+ GPU_line_width(1.0f);
+
+ const float total_len = len_v3v3(cd->preview_plane[0], cd->preview_plane[1]);
+ const int tot_lines = (int)(total_len / cd->voxel_size);
+
+ /* Smoothstep to reduce the alpha of the grid as the line number increases. */
+ const float a = VOXEL_SIZE_EDIT_MAX_GRIDS_LINES * 0.1f;
+ const float b = VOXEL_SIZE_EDIT_MAX_GRIDS_LINES;
+ const float x = clamp_f((tot_lines - a) / (b - a), 0.0f, 1.0);
+ const float alpha_factor = 1.0f - (x * x * (3.0f - 2.0f * x));
+
+ immUniformColor4f(0.9f, 0.9f, 0.9f, 0.75f * alpha_factor);
+ voxel_size_parallel_lines_draw(
+ pos3d, cd->preview_plane[0], cd->preview_plane[1], cd->preview_plane[3], cd->voxel_size);
+ voxel_size_parallel_lines_draw(
+ pos3d, cd->preview_plane[1], cd->preview_plane[2], cd->preview_plane[0], cd->voxel_size);
+
+ /* Draw text */
+ const uiStyle *style = UI_style_get();
+ const uiFontStyle *fstyle = &style->widget;
+ const int fontid = fstyle->uifont_id;
+ float strwidth, strheight;
+ short fstyle_points = fstyle->points;
+ char str[VOXEL_SIZE_EDIT_MAX_STR_LEN];
+ short strdrawlen = 0;
+
+ BLI_snprintf(str, VOXEL_SIZE_EDIT_MAX_STR_LEN, "%3.4f%%", cd->voxel_size);
+ strdrawlen = BLI_strlen_utf8(str);
+
+ immUnbindProgram();
+
+ GPU_matrix_push();
+ GPU_matrix_mul(cd->text_mat);
+ BLF_size(fontid, 10.0f * fstyle_points, U.dpi);
+ BLF_color3f(fontid, 1.0f, 1.0f, 1.0f);
+ BLF_width_and_height(fontid, str, strdrawlen, &strwidth, &strheight);
+ BLF_position(fontid, -0.5f * strwidth, -0.5f * strheight, 0.0f);
+ BLF_draw(fontid, str, strdrawlen);
+ GPU_matrix_pop();
+
+ GPU_matrix_pop();
+
+ GPU_blend(false);
+ GPU_line_smooth(false);
+}
+
+static void voxel_size_edit_cancel(bContext *C, wmOperator *op)
+{
+ ARegion *ar = CTX_wm_region(C);
+ VoxelSizeEditCustomData *cd = op->customdata;
+
+ ED_region_draw_cb_exit(ar->type, cd->draw_handle);
+
+ MEM_freeN(op->customdata);
+
+ ED_workspace_status_text(C, NULL);
+}
+
+static int voxel_size_edit_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ ARegion *ar = CTX_wm_region(C);
+ VoxelSizeEditCustomData *cd = op->customdata;
+ Object *active_object = cd->active_object;
+ Mesh *mesh = (Mesh *)active_object->data;
+
+ /* Cancel modal operator */
+ if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) ||
+ (event->type == RIGHTMOUSE && event->val == KM_PRESS)) {
+ voxel_size_edit_cancel(C, op);
+ ED_region_tag_redraw(ar);
+ return OPERATOR_FINISHED;
+ }
+
+ /* Finish modal operator */
+ if ((event->type == LEFTMOUSE && event->val == KM_RELEASE) ||
+ (event->type == EVT_RETKEY && event->val == KM_PRESS) ||
+ (event->type == EVT_PADENTER && event->val == KM_PRESS)) {
+ ED_region_draw_cb_exit(ar->type, cd->draw_handle);
+ mesh->remesh_voxel_size = cd->voxel_size;
+ MEM_freeN(op->customdata);
+ ED_region_tag_redraw(ar);
+ return OPERATOR_FINISHED;
+ }
+
+ float mval[2] = {event->mval[0], event->mval[1]};
+
+ float d = cd->init_mval[0] - mval[0];
+
+ if (cd->slow_mode) {
+ d = cd->slow_mval[0] - mval[0];
+ }
+
+ if (event->ctrl) {
+ /* Linear mode, enables jumping to any voxel size. */
+ d = d * 0.0005f;
+ }
+ else {
+ /* Multiply d by the initial voxel size to prevent uncontrollable speeds when using low voxel
+ * sizes. */
+ /* When the voxel size is slower, it needs more precision. */
+ d = d * min_ff(pow2f(cd->init_voxel_size), 0.1f) * 0.05f;
+ }
+ if (cd->slow_mode) {
+ cd->voxel_size = cd->slow_voxel_size + d * 0.05f;
+ }
+ else {
+ cd->voxel_size = cd->init_voxel_size + d;
+ }
+
+ if (event->type == EVT_LEFTSHIFTKEY && event->val == KM_PRESS) {
+ cd->slow_mode = true;
+ copy_v2_v2(cd->slow_mval, mval);
+ cd->slow_voxel_size = cd->voxel_size;
+ }
+ if (event->type == EVT_LEFTSHIFTKEY && event->val == KM_RELEASE) {
+ cd->slow_mode = false;
+ cd->slow_voxel_size = 0.0f;
+ }
+
+ cd->voxel_size = clamp_f(cd->voxel_size, 0.0001f, 1.0f);
+
+ ED_region_tag_redraw(ar);
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ ARegion *ar = CTX_wm_region(C);
+ Object *active_object = CTX_data_active_object(C);
+ Mesh *mesh = (Mesh *)active_object->data;
+
+ VoxelSizeEditCustomData *cd = MEM_callocN(sizeof(VoxelSizeEditCustomData),
+ "Voxel Size Edit OP Custom Data");
+
+ /* Initial operator Custom Data setup. */
+ cd->draw_handle = ED_region_draw_cb_activate(
+ ar->type, voxel_size_edit_draw, cd, REGION_DRAW_POST_VIEW);
+ cd->active_object = active_object;
+ cd->init_mval[0] = event->mval[0];
+ cd->init_mval[1] = event->mval[1];
+ cd->init_voxel_size = mesh->remesh_voxel_size;
+ cd->voxel_size = mesh->remesh_voxel_size;
+ op->customdata = cd;
+
+ /* Select the front facing face of the mesh boundig box. */
+ BoundBox *bb = BKE_mesh_boundbox_get(cd->active_object);
+
+ /* Indices of the Bounding Box faces. */
+ int BB_faces[6][4] = {
+ {3, 0, 4, 7},
+ {1, 2, 6, 5},
+ {3, 2, 1, 0},
+ {4, 5, 6, 7},
+ {0, 1, 5, 4},
+ {2, 3, 7, 6},
+ };
+
+ copy_v3_v3(cd->preview_plane[0], bb->vec[BB_faces[0][0]]);
+ copy_v3_v3(cd->preview_plane[1], bb->vec[BB_faces[0][1]]);
+ copy_v3_v3(cd->preview_plane[2], bb->vec[BB_faces[0][2]]);
+ copy_v3_v3(cd->preview_plane[3], bb->vec[BB_faces[0][3]]);
+
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+
+ float mat[3][3];
+ float current_normal[3];
+ float view_normal[3] = {0.0f, 0.0f, 1.0f};
+
+ /* Calculate the view normal. */
+ invert_m4_m4(active_object->imat, active_object->obmat);
+ copy_m3_m4(mat, rv3d->viewinv);
+ mul_m3_v3(mat, view_normal);
+ copy_m3_m4(mat, active_object->imat);
+ mul_m3_v3(mat, view_normal);
+ normalize_v3(view_normal);
+
+ normal_tri_v3(current_normal, cd->preview_plane[0], cd->preview_plane[1], cd->preview_plane[2]);
+
+ float min_dot = dot_v3v3(current_normal, view_normal);
+ float current_dot = 1;
+
+ /* Check if there is a face that is more aligned towards the view. */
+ for (int i = 0; i < 6; i++) {
+ normal_tri_v3(
+ current_normal, bb->vec[BB_faces[i][0]], bb->vec[BB_faces[i][1]], bb->vec[BB_faces[i][2]]);
+ current_dot = dot_v3v3(current_normal, view_normal);
+
+ if (current_dot < min_dot) {
+ min_dot = current_dot;
+ copy_v3_v3(cd->preview_plane[0], bb->vec[BB_faces[i][0]]);
+ copy_v3_v3(cd->preview_plane[1], bb->vec[BB_faces[i][1]]);
+ copy_v3_v3(cd->preview_plane[2], bb->vec[BB_faces[i][2]]);
+ copy_v3_v3(cd->preview_plane[3], bb->vec[BB_faces[i][3]]);
+ }
+ }
+
+ /* Matrix calculation to position the text in 3D space. */
+ float text_pos[3];
+ float scale_mat[4][4];
+
+ float d_a[3], d_b[3];
+ float d_a_proj[2], d_b_proj[2];
+ float preview_plane_proj[4][3];
+ float y_axis_proj[2] = {0.0f, 1.0f};
+
+ mid_v3_v3v3(text_pos, cd->preview_plane[0], cd->preview_plane[2]);
+
+ /* Project the selected face in the previous step of the Bounding Box. */
+ for (int i = 0; i < 4; i++) {
+ ED_view3d_project(ar, cd->preview_plane[i], preview_plane_proj[i]);
+ }
+
+ /* Get the initial X and Y axis of the basis from the edges of the Bounding Box face. */
+ sub_v3_v3v3(d_a, cd->preview_plane[1], cd->preview_plane[0]);
+ sub_v3_v3v3(d_b, cd->preview_plane[3], cd->preview_plane[0]);
+ normalize_v3(d_a);
+ normalize_v3(d_b);
+
+ /* Project the X and Y axis. */
+ sub_v2_v2v2(d_a_proj, preview_plane_proj[1], preview_plane_proj[0]);
+ sub_v2_v2v2(d_b_proj, preview_plane_proj[3], preview_plane_proj[0]);
+ normalize_v2(d_a_proj);
+ normalize_v2(d_b_proj);
+
+ unit_m4(cd->text_mat);
+
+ /* Select the axis that is aligned with the view Y axis to use it as the basis Y. */
+ if (fabsf(dot_v2v2(d_a_proj, y_axis_proj)) > fabsf(dot_v2v2(d_b_proj, y_axis_proj))) {
+ copy_v3_v3(cd->text_mat[0], d_b);
+ copy_v3_v3(cd->text_mat[1], d_a);
+
+ /* Flip the X and Y basis vectors to make sure they always point upwards and to the right. */
+ if (d_b_proj[0] < 0.0f) {
+ mul_v3_fl(cd->text_mat[0], -1.0f);
+ }
+ if (d_a_proj[1] < 0.0f) {
+ mul_v3_fl(cd->text_mat[1], -1.0f);
+ }
+ }
+ else {
+ copy_v3_v3(cd->text_mat[0], d_a);
+ copy_v3_v3(cd->text_mat[1], d_b);
+ if (d_a_proj[0] < 0.0f) {
+ mul_v3_fl(cd->text_mat[0], -1.0f);
+ }
+ if (d_b_proj[1] < 0.0f) {
+ mul_v3_fl(cd->text_mat[1], -1.0f);
+ }
+ }
+
+ /* Use the Bounding Box face normal as the basis Z. */
+ normal_tri_v3(cd->text_mat[2], cd->preview_plane[0], cd->preview_plane[1], cd->preview_plane[2]);
+
+ /* Write the text position into the matrix. */
+ copy_v3_v3(cd->text_mat[3], text_pos);
+
+ /* Scale the text. */
+ unit_m4(scale_mat);
+ scale_m4_fl(scale_mat, 0.0008f);
+ mul_m4_m4_post(cd->text_mat, scale_mat);
+
+ WM_event_add_modal_handler(C, op);
+
+ ED_region_tag_redraw(ar);
+
+ const char *status_str = TIP_(
+ "Move the mouse to change the voxel size. LBM: confirm size, ESC/RMB: cancel");
+ ED_workspace_status_text(C, status_str);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void OBJECT_OT_voxel_size_edit(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Edit Voxel Size";
+ ot->description = "Modify the mesh voxel size interactively used in the voxel remesher";
+ ot->idname = "OBJECT_OT_voxel_size_edit";
+
+ /* api callbacks */
+ ot->poll = object_remesh_poll;
+ ot->invoke = voxel_size_edit_invoke;
+ ot->modal = voxel_size_edit_modal;
+ ot->cancel = voxel_size_edit_cancel;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Quadriflow Remesh Operator
+ * \{ */
+
+#define QUADRIFLOW_MIRROR_BISECT_TOLERANCE 0.005f
+
enum {
QUADRIFLOW_REMESH_RATIO = 1,
QUADRIFLOW_REMESH_EDGE_LENGTH,
QUADRIFLOW_REMESH_FACES,
};
-/****************** quadriflow remesh operator *********************/
-
-#define QUADRIFLOW_MIRROR_BISECT_TOLERANCE 0.005f
-
typedef enum eSymmetryAxes {
SYMMETRY_AXES_X = (1 << 0),
SYMMETRY_AXES_Y = (1 << 1),
@@ -237,13 +653,13 @@ static bool mesh_is_manifold_consistent(Mesh *mesh)
const MLoop *mloop = mesh->mloop;
char *edge_faces = (char *)MEM_callocN(mesh->totedge * sizeof(char), "remesh_manifold_check");
int *edge_vert = (int *)MEM_malloc_arrayN(
- mesh->totedge, sizeof(unsigned int), "remesh_consistent_check");
+ mesh->totedge, sizeof(uint), "remesh_consistent_check");
- for (unsigned int i = 0; i < mesh->totedge; i++) {
+ for (uint i = 0; i < mesh->totedge; i++) {
edge_vert[i] = -1;
}
- for (unsigned int loop_idx = 0; loop_idx < mesh->totloop; loop_idx++) {
+ for (uint loop_idx = 0; loop_idx < mesh->totloop; loop_idx++) {
const MLoop *loop = &mloop[loop_idx];
edge_faces[loop->e] += 1;
if (edge_faces[loop->e] > 2) {
@@ -263,7 +679,7 @@ static bool mesh_is_manifold_consistent(Mesh *mesh)
if (is_manifold_consistent) {
/* check for wire edges */
- for (unsigned int i = 0; i < mesh->totedge; i++) {
+ for (uint i = 0; i < mesh->totedge; i++) {
if (edge_faces[i] == 0) {
is_manifold_consistent = false;
break;
@@ -764,3 +1180,5 @@ void OBJECT_OT_quadriflow_remesh(wmOperatorType *ot)
0,
255);
}
+
+/** \} */
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 8f01adb202e..5f9799710dc 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -246,7 +246,7 @@ Base *ED_object_find_first_by_data_id(ViewLayer *view_layer, ID *id)
Base *base_best = NULL;
int priority_best = 0;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object && base->object->data == id) {
if (base->flag & BASE_SELECTED) {
return base;
@@ -1325,7 +1325,7 @@ static bool object_select_more_less(bContext *C, const bool select)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
ob->flag &= ~OB_DONE;
ob->id.tag &= ~LIB_TAG_DOIT;
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index abce985b65a..26d33bbc375 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -126,7 +126,7 @@ static bool object_shape_key_mirror(
float *fp1, *fp2;
float tvec[3];
- ED_mesh_mirror_spatial_table(ob, NULL, NULL, NULL, 's');
+ ED_mesh_mirror_spatial_table_begin(ob, NULL, NULL);
for (i1 = 0, mv = me->mvert; i1 < me->totvert; i1++, mv++) {
i2 = mesh_get_x_mirror_vert(ob, NULL, i1, use_topology);
@@ -157,7 +157,7 @@ static bool object_shape_key_mirror(
}
}
- ED_mesh_mirror_spatial_table(ob, NULL, NULL, NULL, 'e');
+ ED_mesh_mirror_spatial_table_end(ob);
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = ob->data;
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 28bb28a0298..46245d21d5b 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -1860,8 +1860,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const
if (event->type == MOUSEMOVE || is_translate_init) {
const ViewDepths *depths = xfd->vc.rv3d->depths;
- if (depths && ((unsigned int)event->mval[0] < depths->w) &&
- ((unsigned int)event->mval[1] < depths->h)) {
+ if (depths && ((uint)event->mval[0] < depths->w) && ((uint)event->mval[1] < depths->h)) {
double depth = (double)ED_view3d_depth_read_cached(&xfd->vc, event->mval);
float location_world[3];
if (depth == 1.0f) {
diff --git a/source/blender/editors/object/object_utils.c b/source/blender/editors/object/object_utils.c
index d6056f85932..00aafc2120f 100644
--- a/source/blender/editors/object/object_utils.c
+++ b/source/blender/editors/object/object_utils.c
@@ -28,6 +28,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@@ -193,7 +194,7 @@ void ED_object_xform_skip_child_container_item_ensure_from_array(
BLI_gset_add(objects_in_transdata, ob);
}
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if (ob->parent != NULL) {
if (!BLI_gset_haskey(objects_in_transdata, ob)) {
@@ -223,7 +224,7 @@ void ED_object_xform_skip_child_container_item_ensure_from_array(
}
}
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if (BLI_gset_haskey(objects_in_transdata, ob)) {
diff --git a/source/blender/editors/object/object_volume.c b/source/blender/editors/object/object_volume.c
index 92fb0788f6b..bb619972e80 100644
--- a/source/blender/editors/object/object_volume.c
+++ b/source/blender/editors/object/object_volume.c
@@ -96,7 +96,7 @@ static int volume_import_exec(bContext *C, wmOperator *op)
bool imported = false;
ListBase ranges = ED_image_filesel_detect_sequences(bmain, op, false);
- for (ImageFrameRange *range = ranges.first; range; range = range->next) {
+ LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) {
char filename[FILE_MAX];
BLI_split_file_part(range->filepath, filename, sizeof(filename));
BLI_path_extension_replace(filename, sizeof(filename), "");
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 8a40f65fc8a..75ae0299318 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -135,10 +135,10 @@ bool PE_hair_poll(bContext *C)
bool PE_poll_view3d(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- return (PE_poll(C) && (sa && sa->spacetype == SPACE_VIEW3D) &&
+ return (PE_poll(C) && (area && area->spacetype == SPACE_VIEW3D) &&
(region && region->regiontype == RGN_TYPE_WINDOW));
}
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 8a8fd703845..1237c2c2eda 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -112,7 +112,7 @@ typedef struct RenderJob {
ReportList *reports;
int orig_layer;
int last_layer;
- ScrArea *sa;
+ ScrArea *area;
ColorManagedViewSettings view_settings;
ColorManagedDisplaySettings display_settings;
bool supports_glsl_draw;
@@ -543,24 +543,24 @@ static void render_progress_update(void *rjv, float progress)
static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr, ImageUser *iuser)
{
wmWindowManager *wm;
- ScrArea *first_sa = NULL, *matched_sa = NULL;
+ ScrArea *first_area = NULL, *matched_area = NULL;
/* image window, compo node users */
- for (wm = rj->main->wm.first; wm && matched_sa == NULL; wm = wm->id.next) { /* only 1 wm */
+ for (wm = rj->main->wm.first; wm && matched_area == NULL; wm = wm->id.next) { /* only 1 wm */
wmWindow *win;
- for (win = wm->windows.first; win && matched_sa == NULL; win = win->next) {
+ for (win = wm->windows.first; win && matched_area == NULL; win = win->next) {
const bScreen *screen = WM_window_get_active_screen(win);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = sa->spacedata.first;
- // sa->spacedata might be empty when toggling fullscreen mode.
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ if (area->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = area->spacedata.first;
+ // area->spacedata might be empty when toggling fullscreen mode.
if (sima != NULL && sima->image == rj->image) {
- if (first_sa == NULL) {
- first_sa = sa;
+ if (first_area == NULL) {
+ first_area = area;
}
- if (sa == rj->sa) {
- matched_sa = sa;
+ if (area == rj->area) {
+ matched_area = area;
break;
}
}
@@ -569,12 +569,12 @@ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr,
}
}
- if (matched_sa == NULL) {
- matched_sa = first_sa;
+ if (matched_area == NULL) {
+ matched_area = first_area;
}
- if (matched_sa) {
- SpaceImage *sima = matched_sa->spacedata.first;
+ if (matched_area) {
+ SpaceImage *sima = matched_area->spacedata.first;
RenderResult *main_rr = RE_AcquireResultRead(rj->re);
/* TODO(sergey): is there faster way to get the layer index? */
@@ -689,10 +689,10 @@ static void render_image_restore_layer(RenderJob *rj)
for (win = wm->windows.first; win; win = win->next) {
const bScreen *screen = WM_window_get_active_screen(win);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa == rj->sa) {
- if (sa->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = sa->spacedata.first;
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ if (area == rj->area) {
+ if (area->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = area->spacedata.first;
if (RE_HasSingleLayer(rj->re)) {
/* For single layer renders keep the active layer
@@ -748,7 +748,7 @@ static void render_endjob(void *rjv)
WM_main_add_notifier(NC_NODE | NA_EDITED, rj->scene);
}
- if (rj->sa) {
+ if (rj->area) {
render_image_restore_layer(rj);
}
@@ -887,7 +887,7 @@ static void clean_viewport_memory(Main *bmain, Scene *scene)
/* Go over all the visible objects. */
for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
for (base = view_layer->object_bases.first; base; base = base->next) {
@@ -920,7 +920,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
View3D *v3d = use_viewport ? CTX_wm_view3d(C) : NULL;
struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;
const char *name;
- ScrArea *sa;
+ ScrArea *area;
/* Cannot do render if there is not this function. */
if (re_type->render == NULL) {
@@ -970,7 +970,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
// store spare
/* ensure at least 1 area shows result */
- sa = render_view_open(C, event->x, event->y, op->reports);
+ area = render_view_open(C, event->x, event->y, op->reports);
/* job custom data */
rj = MEM_callocN(sizeof(RenderJob), "render job");
@@ -991,14 +991,14 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
rj->reports = op->reports;
rj->orig_layer = 0;
rj->last_layer = 0;
- rj->sa = sa;
+ rj->area = area;
rj->supports_glsl_draw = IMB_colormanagement_support_glsl_draw(&scene->view_settings);
BKE_color_managed_display_settings_copy(&rj->display_settings, &scene->display_settings);
BKE_color_managed_view_settings_copy(&rj->view_settings, &scene->view_settings);
- if (sa) {
- SpaceImage *sima = sa->spacedata.first;
+ if (area) {
+ SpaceImage *sima = area->spacedata.first;
rj->orig_layer = sima->iuser.layer;
}
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 442f700ad6f..c23ce8a8a9e 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -43,7 +43,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_camera.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
@@ -151,7 +151,7 @@ typedef struct OGLRender {
eImageFormatDepth color_depth;
SpinLock reports_lock;
- unsigned int num_scheduled_frames;
+ uint num_scheduled_frames;
ThreadMutex task_mutex;
ThreadCondition task_condition;
@@ -296,7 +296,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
const short view_context = (v3d != NULL);
bool draw_sky = (scene->r.alphamode == R_ADDSKY);
float *rectf = NULL;
- unsigned char *rect = NULL;
+ uchar *rect = NULL;
const char *viewname = RE_GetActiveRenderView(oglrender->re);
ImBuf *ibuf_result = NULL;
@@ -334,9 +334,8 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
if (gpd) {
int i;
- unsigned char *gp_rect;
- unsigned char *render_rect =
- (unsigned char *)RE_RenderViewGetById(rr, oglrender->view_id)->rect32;
+ uchar *gp_rect;
+ uchar *render_rect = (uchar *)RE_RenderViewGetById(rr, oglrender->view_id)->rect32;
DRW_opengl_context_enable();
GPU_offscreen_bind(oglrender->ofs, true);
@@ -352,7 +351,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
ED_annotation_draw_ex(scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ);
G.f &= ~G_FLAG_RENDER_VIEWPORT;
- gp_rect = MEM_mallocN(sizex * sizey * sizeof(unsigned char) * 4, "offscreen rect");
+ gp_rect = MEM_mallocN(sizex * sizey * sizeof(uchar) * 4, "offscreen rect");
GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, gp_rect);
for (i = 0; i < sizex * sizey * 4; i += 4) {
@@ -414,7 +413,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
rectf = ibuf_view->rect_float;
}
else {
- rect = (unsigned char *)ibuf_view->rect;
+ rect = (uchar *)ibuf_view->rect;
}
}
else {
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 1427c6ed500..0432057bb47 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -167,7 +167,7 @@ typedef struct ShaderPreview {
float color[4];
int sizex, sizey;
- unsigned int *pr_rect;
+ uint *pr_rect;
int pr_method;
bool own_id_copy;
@@ -178,7 +178,7 @@ typedef struct ShaderPreview {
typedef struct IconPreviewSize {
struct IconPreviewSize *next, *prev;
int sizex, sizey;
- unsigned int *rect;
+ uint *rect;
} IconPreviewSize;
typedef struct IconPreview {
@@ -304,7 +304,7 @@ static void set_preview_visibility(Scene *scene,
}
/* Hide floor for icon renders. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (STREQ(base->object->id.name + 2, "Floor")) {
if (pr_method == PR_ICON_RENDER) {
base->object->restrictflag |= OB_RESTRICT_RENDER;
@@ -463,7 +463,7 @@ static Scene *preview_prepare_scene(
sce->display.render_aa = SCE_DISPLAY_AA_OFF;
}
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object->id.name[2] == 'p') {
/* copy over object color, in case material uses it */
copy_v4_v4(base->object->color, sp->color);
@@ -522,7 +522,7 @@ static Scene *preview_prepare_scene(
sce->world->horb = 0.0f;
}
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object->id.name[2] == 'p') {
if (base->object->type == OB_LAMP) {
base->object->data = la;
@@ -566,7 +566,7 @@ static Scene *preview_prepare_scene(
/* new UI convention: draw is in pixel space already. */
/* uses UI_BTYPE_ROUNDBOX button in block to get the rect */
-static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, rcti *newrect)
+static bool ed_preview_draw_rect(ScrArea *area, int split, int first, rcti *rect, rcti *newrect)
{
Render *re;
RenderView *rv;
@@ -578,10 +578,10 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect,
bool ok = false;
if (!split || first) {
- sprintf(name, "Preview %p", (void *)sa);
+ sprintf(name, "Preview %p", (void *)area);
}
else {
- sprintf(name, "SecondPreview %p", (void *)sa);
+ sprintf(name, "SecondPreview %p", (void *)area);
}
if (split) {
@@ -621,14 +621,14 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect,
newrect->ymax = max_ii(newrect->ymax, rect->ymin + rres.recty);
if (rres.rectx && rres.recty) {
- unsigned char *rect_byte = MEM_mallocN(rres.rectx * rres.recty * sizeof(int),
- "ed_preview_draw_rect");
+ uchar *rect_byte = MEM_mallocN(rres.rectx * rres.recty * sizeof(int),
+ "ed_preview_draw_rect");
float fx = rect->xmin + offx;
float fy = rect->ymin;
/* material preview only needs monoscopy (view 0) */
if (re) {
- RE_AcquiredResultGet32(re, &rres, (unsigned int *)rect_byte, 0);
+ RE_AcquiredResultGet32(re, &rres, (uint *)rect_byte, 0);
}
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
@@ -661,12 +661,12 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
{
if (idp) {
wmWindowManager *wm = CTX_wm_manager(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ID *id = (ID *)idp;
ID *parent = (ID *)parentp;
MTex *slot = (MTex *)slotp;
SpaceProperties *sbuts = CTX_wm_space_properties(C);
- ShaderPreview *sp = WM_jobs_customdata(wm, sa);
+ ShaderPreview *sp = WM_jobs_customdata(wm, area);
rcti newrect;
int ok;
int newx = BLI_rcti_size_x(rect);
@@ -678,11 +678,11 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
newrect.ymax = rect->ymin;
if (parent) {
- ok = ed_preview_draw_rect(sa, 1, 1, rect, &newrect);
- ok &= ed_preview_draw_rect(sa, 1, 0, rect, &newrect);
+ ok = ed_preview_draw_rect(area, 1, 1, rect, &newrect);
+ ok &= ed_preview_draw_rect(area, 1, 0, rect, &newrect);
}
else {
- ok = ed_preview_draw_rect(sa, 0, 0, rect, &newrect);
+ ok = ed_preview_draw_rect(area, 0, 0, rect, &newrect);
}
if (ok) {
@@ -693,12 +693,12 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
* if no render result was found and no preview render job is running,
* or if the job is running and the size of preview changed */
if ((sbuts != NULL && sbuts->preview) ||
- (!ok && !WM_jobs_test(wm, sa, WM_JOB_TYPE_RENDER_PREVIEW)) ||
+ (!ok && !WM_jobs_test(wm, area, WM_JOB_TYPE_RENDER_PREVIEW)) ||
(sp && (abs(sp->sizex - newx) >= 2 || abs(sp->sizey - newy) > 2))) {
if (sbuts != NULL) {
sbuts->preview = 0;
}
- ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER);
+ ED_preview_shader_job(C, area, id, parent, slot, newx, newy, PR_BUTS_RENDER);
}
}
}
@@ -1014,10 +1014,10 @@ static void shader_preview_free(void *customdata)
/* ************************* icon preview ********************** */
-static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned int *rect)
+static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect)
{
struct ImBuf *ima;
- unsigned int *drect, *srect;
+ uint *drect, *srect;
float scaledx, scaledy;
short ex, ey, dx, dy;
@@ -1144,7 +1144,7 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
br->icon_imbuf = get_brush_icon(br);
- memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(unsigned int));
+ memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(uint));
if (!(br->icon_imbuf) || !(br->icon_imbuf->rect)) {
return;
@@ -1193,7 +1193,7 @@ static void common_preview_startjob(void *customdata,
/* exported functions */
-static void icon_preview_add_size(IconPreview *ip, unsigned int *rect, int sizex, int sizey)
+static void icon_preview_add_size(IconPreview *ip, uint *rect, int sizex, int sizey)
{
IconPreviewSize *cur_size = ip->sizes.first, *new_size;
@@ -1324,8 +1324,7 @@ static void icon_preview_free(void *customdata)
MEM_freeN(ip);
}
-void ED_preview_icon_render(
- Main *bmain, Scene *scene, ID *id, unsigned int *rect, int sizex, int sizey)
+void ED_preview_icon_render(Main *bmain, Scene *scene, ID *id, uint *rect, int sizex, int sizey)
{
IconPreview ip = {NULL};
short stop = false, update = false;
@@ -1348,13 +1347,8 @@ void ED_preview_icon_render(
BLI_freelistN(&ip.sizes);
}
-void ED_preview_icon_job(const bContext *C,
- void *owner,
- ID *id,
- unsigned int *rect,
- int sizex,
- int sizey,
- const bool delay)
+void ED_preview_icon_job(
+ const bContext *C, void *owner, ID *id, uint *rect, int sizex, int sizey, const bool delay)
{
wmJob *wm_job;
IconPreview *ip, *old_ip;
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index e1fa4caafbd..49ab2c485b1 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -42,6 +42,7 @@
#include "BLT_translation.h"
+#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_brush.h"
#include "BKE_context.h"
@@ -100,15 +101,15 @@
*/
static Object **object_array_for_shading(bContext *C, uint *r_objects_len)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceProperties *sbuts = NULL;
View3D *v3d = NULL;
- if (sa != NULL) {
- if (sa->spacetype == SPACE_PROPERTIES) {
- sbuts = sa->spacedata.first;
+ if (area != NULL) {
+ if (area->spacetype == SPACE_PROPERTIES) {
+ sbuts = area->spacedata.first;
}
- else if (sa->spacetype == SPACE_VIEW3D) {
- v3d = sa->spacedata.first;
+ else if (area->spacetype == SPACE_VIEW3D) {
+ v3d = area->spacedata.first;
}
}
@@ -506,7 +507,7 @@ static int material_slot_move_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
- unsigned int *slot_remap;
+ uint *slot_remap;
int index_pair[2];
int dir = RNA_enum_get(op->ptr, "direction");
@@ -531,7 +532,7 @@ static int material_slot_move_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- slot_remap = MEM_mallocN(sizeof(unsigned int) * ob->totcol, __func__);
+ slot_remap = MEM_mallocN(sizeof(uint) * ob->totcol, __func__);
range_vn_u(slot_remap, ob->totcol, 0);
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index d2bb53de06f..10f69f3fe9d 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -105,18 +105,18 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
wm = bmain->wm.first;
for (win = wm->windows.first; win; win = win->next) {
- bScreen *sc = WM_window_get_active_screen(win);
- ScrArea *sa;
+ bScreen *screen = WM_window_get_active_screen(win);
+ ScrArea *area;
ARegion *region;
CTX_wm_window_set(C, win);
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- if (sa->spacetype != SPACE_VIEW3D) {
+ for (area = screen->areabase.first; area; area = area->next) {
+ if (area->spacetype != SPACE_VIEW3D) {
continue;
}
- View3D *v3d = sa->spacedata.first;
- for (region = sa->regionbase.first; region; region = region->next) {
+ View3D *v3d = area->spacedata.first;
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype != RGN_TYPE_WINDOW) {
continue;
}
@@ -127,8 +127,8 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
* time of the last update) */
if (engine && (updated || (engine->flag & RE_ENGINE_DO_UPDATE))) {
- CTX_wm_screen_set(C, sc);
- CTX_wm_area_set(C, sa);
+ CTX_wm_screen_set(C, screen);
+ CTX_wm_area_set(C, area);
CTX_wm_region_set(C, region);
engine->flag &= ~RE_ENGINE_DO_UPDATE;
@@ -146,7 +146,7 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
.scene = scene,
.view_layer = view_layer,
.region = region,
- .v3d = (View3D *)sa->spacedata.first,
+ .v3d = (View3D *)area->spacedata.first,
.engine_type = engine_type,
}));
}
@@ -160,17 +160,17 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
recursive_check = false;
}
-void ED_render_engine_area_exit(Main *bmain, ScrArea *sa)
+void ED_render_engine_area_exit(Main *bmain, ScrArea *area)
{
/* clear all render engines in this area */
ARegion *region;
wmWindowManager *wm = bmain->wm.first;
- if (sa->spacetype != SPACE_VIEW3D) {
+ if (area->spacetype != SPACE_VIEW3D) {
return;
}
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype != RGN_TYPE_WINDOW || !(region->regiondata)) {
continue;
}
@@ -181,9 +181,9 @@ void ED_render_engine_area_exit(Main *bmain, ScrArea *sa)
void ED_render_engine_changed(Main *bmain)
{
/* on changing the render engine type, clear all running render engines */
- for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) {
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
- ED_render_engine_area_exit(bmain, sa);
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ ED_render_engine_area_exit(bmain, area);
}
}
RE_FreePersistentData();
@@ -204,10 +204,10 @@ void ED_render_engine_changed(Main *bmain)
}
}
-void ED_render_view_layer_changed(Main *bmain, bScreen *sc)
+void ED_render_view_layer_changed(Main *bmain, bScreen *screen)
{
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
- ED_render_engine_area_exit(bmain, sa);
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ ED_render_engine_area_exit(bmain, area);
}
}
diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c
index a93ea343229..a9c855b14b0 100644
--- a/source/blender/editors/render/render_view.c
+++ b/source/blender/editors/render/render_view.c
@@ -56,23 +56,23 @@
/* would use BKE_screen_find_big_area(...) but this is too specific */
static ScrArea *biggest_non_image_area(bContext *C)
{
- bScreen *sc = CTX_wm_screen(C);
- ScrArea *sa, *big = NULL;
+ bScreen *screen = CTX_wm_screen(C);
+ ScrArea *area, *big = NULL;
int size, maxsize = 0, bwmaxsize = 0;
short foundwin = 0;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- if (sa->winx > 30 && sa->winy > 30) {
- size = sa->winx * sa->winy;
- if (!sa->full && sa->spacetype == SPACE_PROPERTIES) {
+ for (area = screen->areabase.first; area; area = area->next) {
+ if (area->winx > 30 && area->winy > 30) {
+ size = area->winx * area->winy;
+ if (!area->full && area->spacetype == SPACE_PROPERTIES) {
if (foundwin == 0 && size > bwmaxsize) {
bwmaxsize = size;
- big = sa;
+ big = area;
}
}
- else if (sa->spacetype != SPACE_IMAGE && size > maxsize) {
+ else if (area->spacetype != SPACE_IMAGE && size > maxsize) {
maxsize = size;
- big = sa;
+ big = area;
foundwin = 1;
}
}
@@ -84,7 +84,7 @@ static ScrArea *biggest_non_image_area(bContext *C)
static ScrArea *find_area_showing_r_result(bContext *C, Scene *scene, wmWindow **win)
{
wmWindowManager *wm = CTX_wm_manager(C);
- ScrArea *sa = NULL;
+ ScrArea *area = NULL;
SpaceImage *sima;
/* find an imagewindow showing render result */
@@ -92,40 +92,40 @@ static ScrArea *find_area_showing_r_result(bContext *C, Scene *scene, wmWindow *
if (WM_window_get_active_scene(*win) == scene) {
const bScreen *screen = WM_window_get_active_screen(*win);
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->spacetype == SPACE_IMAGE) {
- sima = sa->spacedata.first;
+ for (area = screen->areabase.first; area; area = area->next) {
+ if (area->spacetype == SPACE_IMAGE) {
+ sima = area->spacedata.first;
if (sima->image && sima->image->type == IMA_TYPE_R_RESULT) {
break;
}
}
}
- if (sa) {
+ if (area) {
break;
}
}
}
- return sa;
+ return area;
}
static ScrArea *find_area_image_empty(bContext *C)
{
- bScreen *sc = CTX_wm_screen(C);
- ScrArea *sa;
+ bScreen *screen = CTX_wm_screen(C);
+ ScrArea *area;
SpaceImage *sima;
/* find an imagewindow showing render result */
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- if (sa->spacetype == SPACE_IMAGE) {
- sima = sa->spacedata.first;
+ for (area = screen->areabase.first; area; area = area->next) {
+ if (area->spacetype == SPACE_IMAGE) {
+ sima = area->spacedata.first;
if ((sima->mode == SI_MODE_VIEW) && !sima->image) {
break;
}
}
}
- return sa;
+ return area;
}
/********************** open image editor for render *************************/
@@ -136,7 +136,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
wmWindow *win = NULL;
- ScrArea *sa = NULL;
+ ScrArea *area = NULL;
SpaceImage *sima;
bool area_was_image = false;
@@ -163,34 +163,34 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
return NULL;
}
- sa = CTX_wm_area(C);
- if (BLI_listbase_is_single(&sa->spacedata) == false) {
- sima = sa->spacedata.first;
+ area = CTX_wm_area(C);
+ if (BLI_listbase_is_single(&area->spacedata) == false) {
+ sima = area->spacedata.first;
sima->flag |= SI_PREVSPACE;
}
}
else if (U.render_display_type == USER_RENDER_DISPLAY_SCREEN) {
- sa = CTX_wm_area(C);
+ area = CTX_wm_area(C);
/* if the active screen is already in fullscreen mode, skip this and
* unset the area, so that the fullscreen area is just changed later */
- if (sa && sa->full) {
- sa = NULL;
+ if (area && area->full) {
+ area = NULL;
}
else {
- if (sa && sa->spacetype == SPACE_IMAGE) {
+ if (area && area->spacetype == SPACE_IMAGE) {
area_was_image = true;
}
/* this function returns with changed context */
- sa = ED_screen_full_newspace(C, sa, SPACE_IMAGE);
+ area = ED_screen_full_newspace(C, area, SPACE_IMAGE);
}
}
- if (!sa) {
- sa = find_area_showing_r_result(C, scene, &win);
- if (sa == NULL) {
- sa = find_area_image_empty(C);
+ if (!area) {
+ area = find_area_showing_r_result(C, scene, &win);
+ if (area == NULL) {
+ area = find_area_image_empty(C);
}
/* if area found in other window, we make that one show in front */
@@ -198,27 +198,27 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
wm_window_raise(win);
}
- if (sa == NULL) {
+ if (area == NULL) {
/* find largest open non-image area */
- sa = biggest_non_image_area(C);
- if (sa) {
- ED_area_newspace(C, sa, SPACE_IMAGE, true);
- sima = sa->spacedata.first;
+ area = biggest_non_image_area(C);
+ if (area) {
+ ED_area_newspace(C, area, SPACE_IMAGE, true);
+ sima = area->spacedata.first;
/* makes ESC go back to prev space */
sima->flag |= SI_PREVSPACE;
/* we already had a fullscreen here -> mark new space as a stacked fullscreen */
- if (sa->full) {
- sa->flag |= AREA_FLAG_STACKED_FULLSCREEN;
+ if (area->full) {
+ area->flag |= AREA_FLAG_STACKED_FULLSCREEN;
}
}
else {
/* use any area of decent size */
- sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TYPE_ANY, 0);
- if (sa->spacetype != SPACE_IMAGE) {
- // XXX newspace(sa, SPACE_IMAGE);
- sima = sa->spacedata.first;
+ area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TYPE_ANY, 0);
+ if (area->spacetype != SPACE_IMAGE) {
+ // XXX newspace(area, SPACE_IMAGE);
+ sima = area->spacedata.first;
/* makes ESC go back to prev space */
sima->flag |= SI_PREVSPACE;
@@ -226,7 +226,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
}
}
}
- sima = sa->spacedata.first;
+ sima = area->spacedata.first;
sima->link_flag |= SPACE_FLAG_TYPE_TEMPORARY;
/* get the correct image, and scale it */
@@ -234,7 +234,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
/* If we're rendering to full screen, set appropriate hints on image editor
* so it can restore properly on pressing escape. */
- if (sa->full) {
+ if (area->full) {
sima->flag |= SI_FULLWINDOW;
/* Tell the image editor to revert to previous space in space list on close
@@ -253,7 +253,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
old_sl->link_flag |= SPACE_FLAG_TYPE_WAS_ACTIVE;
}
- return sa;
+ return area;
}
/*************************** cancel render viewer **********************/
@@ -261,11 +261,11 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op))
{
wmWindow *win = CTX_wm_window(C);
- ScrArea *sa = CTX_wm_area(C);
- SpaceImage *sima = sa->spacedata.first;
+ ScrArea *area = CTX_wm_area(C);
+ SpaceImage *sima = area->spacedata.first;
/* ensure image editor fullscreen and area fullscreen states are in sync */
- if ((sima->flag & SI_FULLWINDOW) && !sa->full) {
+ if ((sima->flag & SI_FULLWINDOW) && !area->full) {
sima->flag &= ~SI_FULLWINDOW;
}
@@ -275,17 +275,17 @@ static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op))
if (sima->flag & SI_FULLWINDOW) {
sima->flag &= ~SI_FULLWINDOW;
- ED_screen_full_prevspace(C, sa);
+ ED_screen_full_prevspace(C, area);
}
else {
- ED_area_prevspace(C, sa);
+ ED_area_prevspace(C, area);
}
return OPERATOR_FINISHED;
}
else if (sima->flag & SI_FULLWINDOW) {
sima->flag &= ~SI_FULLWINDOW;
- ED_screen_state_toggle(C, win, sa, SCREENMAXIMIZED);
+ ED_screen_state_toggle(C, win, area, SCREENMAXIMIZED);
return OPERATOR_FINISHED;
}
else if (WM_window_is_temp_screen(win)) {
@@ -320,14 +320,14 @@ static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *e
}
else {
wmWindow *win, *winshow;
- ScrArea *sa = find_area_showing_r_result(C, CTX_data_scene(C), &winshow);
+ ScrArea *area = find_area_showing_r_result(C, CTX_data_scene(C), &winshow);
/* is there another window on current scene showing result? */
for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) {
- const bScreen *sc = WM_window_get_active_screen(win);
+ const bScreen *screen = WM_window_get_active_screen(win);
if ((WM_window_is_temp_screen(win) &&
- ((ScrArea *)sc->areabase.first)->spacetype == SPACE_IMAGE) ||
+ ((ScrArea *)screen->areabase.first)->spacetype == SPACE_IMAGE) ||
(win == winshow && winshow != wincur)) {
wm_window_raise(win);
return OPERATOR_FINISHED;
@@ -335,20 +335,20 @@ static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *e
}
/* determine if render already shows */
- if (sa) {
+ if (area) {
/* but don't close it when rendering */
if (G.is_rendering == false) {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
if (sima->flag & SI_PREVSPACE) {
sima->flag &= ~SI_PREVSPACE;
if (sima->flag & SI_FULLWINDOW) {
sima->flag &= ~SI_FULLWINDOW;
- ED_screen_full_prevspace(C, sa);
+ ED_screen_full_prevspace(C, area);
}
else {
- ED_area_prevspace(C, sa);
+ ED_area_prevspace(C, area);
}
}
}
diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c
index 114cb54636a..d78b1532a39 100644
--- a/source/blender/editors/scene/scene_edit.c
+++ b/source/blender/editors/scene/scene_edit.c
@@ -99,7 +99,7 @@ bool ED_scene_delete(bContext *C, Main *bmain, Scene *scene)
return false;
}
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (win->parent != NULL) { /* We only care about main windows here... */
continue;
}
@@ -175,7 +175,7 @@ bool ED_scene_view_layer_delete(Main *bmain, Scene *scene, ViewLayer *layer, Rep
/* Remove from windows. */
wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (win->scene == scene && STREQ(win->view_layer_name, layer->name)) {
ViewLayer *first_layer = BKE_view_layer_default_view(scene);
STRNCPY(win->view_layer_name, first_layer->name);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 56ea59c1d6e..49838b62b71 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -146,7 +146,7 @@ void ED_region_pixelspace(ARegion *region)
/* only exported for WM */
void ED_region_do_listen(
- wmWindow *win, ScrArea *sa, ARegion *region, wmNotifier *note, const Scene *scene)
+ wmWindow *win, ScrArea *area, ARegion *region, wmNotifier *note, const Scene *scene)
{
/* generic notes first */
switch (note->category) {
@@ -161,27 +161,27 @@ void ED_region_do_listen(
}
if (region->type && region->type->listener) {
- region->type->listener(win, sa, region, note, scene);
+ region->type->listener(win, area, region, note, scene);
}
}
/* only exported for WM */
-void ED_area_do_listen(wmWindow *win, ScrArea *sa, wmNotifier *note, Scene *scene)
+void ED_area_do_listen(wmWindow *win, ScrArea *area, wmNotifier *note, Scene *scene)
{
/* no generic notes? */
- if (sa->type && sa->type->listener) {
- sa->type->listener(win, sa, note, scene);
+ if (area->type && area->type->listener) {
+ area->type->listener(win, area, note, scene);
}
}
/* only exported for WM */
-void ED_area_do_refresh(bContext *C, ScrArea *sa)
+void ED_area_do_refresh(bContext *C, ScrArea *area)
{
/* no generic notes? */
- if (sa->type && sa->type->refresh) {
- sa->type->refresh(C, sa);
+ if (area->type && area->type->refresh) {
+ area->type->refresh(C, area);
}
- sa->do_refresh = false;
+ area->do_refresh = false;
}
/**
@@ -294,16 +294,16 @@ static void region_draw_azone_tab_arrow(AZone *az)
draw_azone_arrow((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, az->edge);
}
-static void area_azone_tag_update(ScrArea *sa)
+static void area_azone_tag_update(ScrArea *area)
{
- sa->flag |= AREA_FLAG_ACTIONZONES_UPDATE;
+ area->flag |= AREA_FLAG_ACTIONZONES_UPDATE;
}
-static void region_draw_azones(ScrArea *sa, ARegion *region)
+static void region_draw_azones(ScrArea *area, ARegion *region)
{
AZone *az;
- if (!sa) {
+ if (!area) {
return;
}
@@ -315,7 +315,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *region)
GPU_matrix_push();
GPU_matrix_translate_2f(-region->winrct.xmin, -region->winrct.ymin);
- for (az = sa->actionzones.first; az; az = az->next) {
+ for (az = area->actionzones.first; az; az = az->next) {
/* test if action zone is over this region */
rcti azrct;
BLI_rcti_init(&azrct, az->x1, az->x2, az->y1, az->y2);
@@ -339,7 +339,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *region)
}
}
if (!IS_EQF(az->alpha, 0.0f) && ELEM(az->type, AZONE_FULLSCREEN, AZONE_REGION_SCROLL)) {
- area_azone_tag_update(sa);
+ area_azone_tag_update(area);
}
}
@@ -348,9 +348,9 @@ static void region_draw_azones(ScrArea *sa, ARegion *region)
GPU_blend(false);
}
-static void region_draw_status_text(ScrArea *sa, ARegion *region)
+static void region_draw_status_text(ScrArea *area, ARegion *region)
{
- bool overlap = ED_region_is_overlap(sa->spacetype, region->regiontype);
+ bool overlap = ED_region_is_overlap(area->spacetype, region->regiontype);
if (overlap) {
GPU_clear_color(0.0, 0.0, 0.0, 0.0);
@@ -421,8 +421,8 @@ void ED_area_do_msg_notify_tag_refresh(
wmMsgSubscribeKey *UNUSED(msg_key),
wmMsgSubscribeValue *msg_val)
{
- ScrArea *sa = msg_val->user_data;
- ED_area_tag_refresh(sa);
+ ScrArea *area = msg_val->user_data;
+ ED_area_tag_refresh(area);
}
void ED_area_do_mgs_subscribe_for_tool_header(
@@ -431,7 +431,7 @@ void ED_area_do_mgs_subscribe_for_tool_header(
struct WorkSpace *workspace,
struct Scene *UNUSED(scene),
struct bScreen *UNUSED(screen),
- struct ScrArea *UNUSED(sa),
+ struct ScrArea *UNUSED(area),
struct ARegion *region,
struct wmMsgBus *mbus)
{
@@ -451,7 +451,7 @@ void ED_area_do_mgs_subscribe_for_tool_ui(
struct WorkSpace *workspace,
struct Scene *UNUSED(scene),
struct bScreen *UNUSED(screen),
- struct ScrArea *UNUSED(sa),
+ struct ScrArea *UNUSED(area),
struct ARegion *region,
struct wmMsgBus *mbus)
{
@@ -483,20 +483,20 @@ static bool area_is_pseudo_minimized(const ScrArea *area)
void ED_region_do_layout(bContext *C, ARegion *region)
{
/* This is optional, only needed for dynamically sized regions. */
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegionType *at = region->type;
if (!at->layout) {
return;
}
- if (at->do_lock || (sa && area_is_pseudo_minimized(sa))) {
+ if (at->do_lock || (area && area_is_pseudo_minimized(area))) {
return;
}
region->do_draw |= RGN_DRAWING;
- UI_SetTheme(sa ? sa->spacetype : 0, at->regionid);
+ UI_SetTheme(area ? area->spacetype : 0, at->regionid);
at->layout(C, region);
}
@@ -504,7 +504,7 @@ void ED_region_do_layout(bContext *C, ARegion *region)
void ED_region_do_draw(bContext *C, ARegion *region)
{
wmWindow *win = CTX_wm_window(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegionType *at = region->type;
/* see BKE_spacedata_draw_locks() */
@@ -519,16 +519,16 @@ void ED_region_do_draw(bContext *C, ARegion *region)
wmOrtho2_region_pixelspace(region);
- UI_SetTheme(sa ? sa->spacetype : 0, at->regionid);
+ UI_SetTheme(area ? area->spacetype : 0, at->regionid);
- if (sa && area_is_pseudo_minimized(sa)) {
+ if (area && area_is_pseudo_minimized(area)) {
UI_ThemeClearColor(TH_EDITOR_OUTLINE);
glClear(GL_COLOR_BUFFER_BIT);
return;
}
/* optional header info instead? */
else if (region->headerstr) {
- region_draw_status_text(sa, region);
+ region_draw_status_text(area, region);
}
else if (at->draw) {
at->draw(C, region);
@@ -540,7 +540,7 @@ void ED_region_do_draw(bContext *C, ARegion *region)
ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_PIXEL);
- region_draw_azones(sa, region);
+ region_draw_azones(area, region);
/* for debugging unneeded area redraws and partial redraw */
if (G.debug_value == 888) {
@@ -562,11 +562,11 @@ void ED_region_do_draw(bContext *C, ARegion *region)
UI_blocklist_free_inactive(C, &region->uiblocks);
- if (sa) {
+ if (area) {
const bScreen *screen = WM_window_get_active_screen(win);
/* Only region emboss for top-bar */
- if ((screen->state != SCREENFULL) && ED_area_is_global(sa)) {
+ if ((screen->state != SCREENFULL) && ED_area_is_global(area)) {
region_draw_emboss(region, &region->winrct, (REGION_EMBOSS_LEFT | REGION_EMBOSS_RIGHT));
}
else if ((region->regiontype == RGN_TYPE_WINDOW) && (region->alignment == RGN_ALIGN_QSPLIT)) {
@@ -604,7 +604,7 @@ void ED_region_do_draw(bContext *C, ARegion *region)
*/
if (ELEM(
region->regiontype, RGN_TYPE_WINDOW, RGN_TYPE_CHANNELS, RGN_TYPE_UI, RGN_TYPE_TOOLS)) {
- SpaceLink *sl = sa->spacedata.first;
+ SpaceLink *sl = area->spacedata.first;
PointerRNA ptr;
RNA_pointer_create(&screen->id, &RNA_Space, sl, &ptr);
@@ -618,7 +618,7 @@ void ED_region_do_draw(bContext *C, ARegion *region)
WM_msg_subscribe_rna(mbus, &ptr, NULL, &msg_sub_value_region_tag_redraw, __func__);
}
- ED_region_message_subscribe(C, workspace, scene, screen, sa, region, mbus);
+ ED_region_message_subscribe(C, workspace, scene, screen, area, region, mbus);
}
}
@@ -705,34 +705,34 @@ void ED_region_tag_redraw_partial(ARegion *region, const rcti *rct, bool rebuild
}
}
-void ED_area_tag_redraw(ScrArea *sa)
+void ED_area_tag_redraw(ScrArea *area)
{
ARegion *region;
- if (sa) {
- for (region = sa->regionbase.first; region; region = region->next) {
+ if (area) {
+ for (region = area->regionbase.first; region; region = region->next) {
ED_region_tag_redraw(region);
}
}
}
-void ED_area_tag_redraw_no_rebuild(ScrArea *sa)
+void ED_area_tag_redraw_no_rebuild(ScrArea *area)
{
ARegion *region;
- if (sa) {
- for (region = sa->regionbase.first; region; region = region->next) {
+ if (area) {
+ for (region = area->regionbase.first; region; region = region->next) {
ED_region_tag_redraw_no_rebuild(region);
}
}
}
-void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype)
+void ED_area_tag_redraw_regiontype(ScrArea *area, int regiontype)
{
ARegion *region;
- if (sa) {
- for (region = sa->regionbase.first; region; region = region->next) {
+ if (area) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == regiontype) {
ED_region_tag_redraw(region);
}
@@ -740,26 +740,26 @@ void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype)
}
}
-void ED_area_tag_refresh(ScrArea *sa)
+void ED_area_tag_refresh(ScrArea *area)
{
- if (sa) {
- sa->do_refresh = true;
+ if (area) {
+ area->do_refresh = true;
}
}
/* *************************************************************** */
/* use NULL to disable it */
-void ED_area_status_text(ScrArea *sa, const char *str)
+void ED_area_status_text(ScrArea *area, const char *str)
{
ARegion *region;
/* happens when running transform operators in background mode */
- if (sa == NULL) {
+ if (area == NULL) {
return;
}
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_HEADER) {
if (str) {
if (region->headerstr == NULL) {
@@ -799,9 +799,9 @@ void ED_workspace_status_text(bContext *C, const char *str)
}
/* Redraw status bar. */
- for (ScrArea *sa = win->global_areas.areabase.first; sa; sa = sa->next) {
- if (sa->spacetype == SPACE_STATUSBAR) {
- ED_area_tag_redraw(sa);
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
+ if (area->spacetype == SPACE_STATUSBAR) {
+ ED_area_tag_redraw(area);
break;
}
}
@@ -809,12 +809,12 @@ void ED_workspace_status_text(bContext *C, const char *str)
/* ************************************************************ */
-static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea *sa)
+static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea *area)
{
AZone *az;
/* reinitialize entirely, regions and fullscreen add azones too */
- BLI_freelistN(&sa->actionzones);
+ BLI_freelistN(&area->actionzones);
if (screen->state != SCREENNORMAL) {
return;
@@ -824,7 +824,7 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea
return;
}
- if (ED_area_is_global(sa)) {
+ if (ED_area_is_global(area)) {
return;
}
@@ -834,25 +834,25 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea
const float coords[4][4] = {
/* Bottom-left. */
- {sa->totrct.xmin - U.pixelsize,
- sa->totrct.ymin - U.pixelsize,
- sa->totrct.xmin + AZONESPOTW,
- sa->totrct.ymin + AZONESPOTH},
+ {area->totrct.xmin - U.pixelsize,
+ area->totrct.ymin - U.pixelsize,
+ area->totrct.xmin + AZONESPOTW,
+ area->totrct.ymin + AZONESPOTH},
/* Bottom-right. */
- {sa->totrct.xmax - AZONESPOTW,
- sa->totrct.ymin - U.pixelsize,
- sa->totrct.xmax + U.pixelsize,
- sa->totrct.ymin + AZONESPOTH},
+ {area->totrct.xmax - AZONESPOTW,
+ area->totrct.ymin - U.pixelsize,
+ area->totrct.xmax + U.pixelsize,
+ area->totrct.ymin + AZONESPOTH},
/* Top-left. */
- {sa->totrct.xmin - U.pixelsize,
- sa->totrct.ymax - AZONESPOTH,
- sa->totrct.xmin + AZONESPOTW,
- sa->totrct.ymax + U.pixelsize},
+ {area->totrct.xmin - U.pixelsize,
+ area->totrct.ymax - AZONESPOTH,
+ area->totrct.xmin + AZONESPOTW,
+ area->totrct.ymax + U.pixelsize},
/* Top-right. */
- {sa->totrct.xmax - AZONESPOTW,
- sa->totrct.ymax - AZONESPOTH,
- sa->totrct.xmax + U.pixelsize,
- sa->totrct.ymax + U.pixelsize},
+ {area->totrct.xmax - AZONESPOTW,
+ area->totrct.ymax - AZONESPOTH,
+ area->totrct.xmax + U.pixelsize,
+ area->totrct.ymax + U.pixelsize},
};
for (int i = 0; i < 4; i++) {
@@ -869,7 +869,7 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea
/* set area action zones */
az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
- BLI_addtail(&(sa->actionzones), az);
+ BLI_addtail(&(area->actionzones), az);
az->type = AZONE_AREA;
az->x1 = coords[i][0];
az->y1 = coords[i][1];
@@ -879,16 +879,16 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea
}
}
-static void fullscreen_azone_initialize(ScrArea *sa, ARegion *region)
+static void fullscreen_azone_initialize(ScrArea *area, ARegion *region)
{
AZone *az;
- if (ED_area_is_global(sa) || (region->regiontype != RGN_TYPE_WINDOW)) {
+ if (ED_area_is_global(area) || (region->regiontype != RGN_TYPE_WINDOW)) {
return;
}
az = (AZone *)MEM_callocN(sizeof(AZone), "fullscreen action zone");
- BLI_addtail(&(sa->actionzones), az);
+ BLI_addtail(&(area->actionzones), az);
az->type = AZONE_FULLSCREEN;
az->region = region;
az->alpha = 0.0f;
@@ -942,7 +942,7 @@ static void region_azone_edge(AZone *az, ARegion *region)
}
/* region already made zero sized, in shape of edge */
-static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *region)
+static void region_azone_tab_plus(ScrArea *area, AZone *az, ARegion *region)
{
AZone *azt;
int tot = 0, add;
@@ -952,7 +952,7 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *region)
const float tab_size_x = 0.7f * U.widget_unit;
const float tab_size_y = 0.4f * U.widget_unit;
- for (azt = sa->actionzones.first; azt; azt = azt->next) {
+ for (azt = area->actionzones.first; azt; azt = azt->next) {
if (azt->edge == az->edge) {
tot++;
}
@@ -960,7 +960,7 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *region)
switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
- add = (region->winrct.ymax == sa->totrct.ymin) ? 1 : 0;
+ add = (region->winrct.ymax == area->totrct.ymin) ? 1 : 0;
az->x1 = region->winrct.xmax - ((edge_offset + 1.0f) * tab_size_x);
az->y1 = region->winrct.ymax - add;
az->x2 = region->winrct.xmax - (edge_offset * tab_size_x);
@@ -1003,7 +1003,7 @@ static bool region_azone_edge_poll(const ARegion *region, const bool is_fullscre
return true;
}
-static void region_azone_edge_initialize(ScrArea *sa,
+static void region_azone_edge_initialize(ScrArea *area,
ARegion *region,
AZEdge edge,
const bool is_fullscreen)
@@ -1016,27 +1016,27 @@ static void region_azone_edge_initialize(ScrArea *sa,
}
az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
- BLI_addtail(&(sa->actionzones), az);
+ BLI_addtail(&(area->actionzones), az);
az->type = AZONE_REGION;
az->region = region;
az->edge = edge;
if (is_hidden) {
- region_azone_tab_plus(sa, az, region);
+ region_azone_tab_plus(area, az, region);
}
else {
region_azone_edge(az, region);
}
}
-static void region_azone_scrollbar_initialize(ScrArea *sa,
+static void region_azone_scrollbar_initialize(ScrArea *area,
ARegion *region,
AZScrollDirection direction)
{
rcti scroller_vert = (direction == AZ_SCROLL_VERT) ? region->v2d.vert : region->v2d.hor;
AZone *az = MEM_callocN(sizeof(*az), __func__);
- BLI_addtail(&sa->actionzones, az);
+ BLI_addtail(&area->actionzones, az);
az->type = AZONE_REGION_SCROLL;
az->region = region;
az->direction = direction;
@@ -1057,21 +1057,21 @@ static void region_azone_scrollbar_initialize(ScrArea *sa,
BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
-static void region_azones_scrollbars_initialize(ScrArea *sa, ARegion *region)
+static void region_azones_scrollbars_initialize(ScrArea *area, ARegion *region)
{
const View2D *v2d = &region->v2d;
if ((v2d->scroll & V2D_SCROLL_VERTICAL) && ((v2d->scroll & V2D_SCROLL_VERTICAL_HANDLES) == 0)) {
- region_azone_scrollbar_initialize(sa, region, AZ_SCROLL_VERT);
+ region_azone_scrollbar_initialize(area, region, AZ_SCROLL_VERT);
}
if ((v2d->scroll & V2D_SCROLL_HORIZONTAL) &&
((v2d->scroll & V2D_SCROLL_HORIZONTAL_HANDLES) == 0)) {
- region_azone_scrollbar_initialize(sa, region, AZ_SCROLL_HOR);
+ region_azone_scrollbar_initialize(area, region, AZ_SCROLL_HOR);
}
}
/* *************************************************************** */
-static void region_azones_add_edge(ScrArea *sa,
+static void region_azones_add_edge(ScrArea *area,
ARegion *region,
const int alignment,
const bool is_fullscreen)
@@ -1079,20 +1079,20 @@ static void region_azones_add_edge(ScrArea *sa,
/* edge code (t b l r) is along which area edge azone will be drawn */
if (alignment == RGN_ALIGN_TOP) {
- region_azone_edge_initialize(sa, region, AE_BOTTOM_TO_TOPLEFT, is_fullscreen);
+ region_azone_edge_initialize(area, region, AE_BOTTOM_TO_TOPLEFT, is_fullscreen);
}
else if (alignment == RGN_ALIGN_BOTTOM) {
- region_azone_edge_initialize(sa, region, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen);
+ region_azone_edge_initialize(area, region, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen);
}
else if (alignment == RGN_ALIGN_RIGHT) {
- region_azone_edge_initialize(sa, region, AE_LEFT_TO_TOPRIGHT, is_fullscreen);
+ region_azone_edge_initialize(area, region, AE_LEFT_TO_TOPRIGHT, is_fullscreen);
}
else if (alignment == RGN_ALIGN_LEFT) {
- region_azone_edge_initialize(sa, region, AE_RIGHT_TO_TOPLEFT, is_fullscreen);
+ region_azone_edge_initialize(area, region, AE_RIGHT_TO_TOPLEFT, is_fullscreen);
}
}
-static void region_azones_add(const bScreen *screen, ScrArea *sa, ARegion *region)
+static void region_azones_add(const bScreen *screen, ScrArea *area, ARegion *region)
{
const bool is_fullscreen = screen->state == SCREENFULL;
@@ -1102,20 +1102,20 @@ static void region_azones_add(const bScreen *screen, ScrArea *sa, ARegion *regio
return;
}
- region_azones_add_edge(sa, region, RGN_ALIGN_ENUM_FROM_MASK(region->alignment), is_fullscreen);
+ region_azones_add_edge(area, region, RGN_ALIGN_ENUM_FROM_MASK(region->alignment), is_fullscreen);
/* For a split region also continue the azone edge from the next region if this region is aligned
* with the next */
if ((region->alignment & RGN_SPLIT_PREV) && region->prev) {
region_azones_add_edge(
- sa, region, RGN_ALIGN_ENUM_FROM_MASK(region->prev->alignment), is_fullscreen);
+ area, region, RGN_ALIGN_ENUM_FROM_MASK(region->prev->alignment), is_fullscreen);
}
if (is_fullscreen) {
- fullscreen_azone_initialize(sa, region);
+ fullscreen_azone_initialize(area, region);
}
- region_azones_scrollbars_initialize(sa, region);
+ region_azones_scrollbars_initialize(area, region);
}
/* dir is direction to check, not the splitting edge direction! */
@@ -1133,7 +1133,7 @@ static int rct_fits(const rcti *rect, char dir, int size)
/* region should be overlapping */
/* function checks if some overlapping region was defined before - on same place */
-static void region_overlap_fix(ScrArea *sa, ARegion *region)
+static void region_overlap_fix(ScrArea *area, ARegion *region)
{
ARegion *ar1;
const int align = RGN_ALIGN_ENUM_FROM_MASK(region->alignment);
@@ -1168,7 +1168,7 @@ static void region_overlap_fix(ScrArea *sa, ARegion *region)
/* translate or close */
if (ar1) {
if (align1 == RGN_ALIGN_LEFT) {
- if (region->winrct.xmax + ar1->winx > sa->winx - U.widget_unit) {
+ if (region->winrct.xmax + ar1->winx > area->winx - U.widget_unit) {
region->flag |= RGN_FLAG_TOO_SMALL;
return;
}
@@ -1235,7 +1235,7 @@ bool ED_region_is_overlap(int spacetype, int regiontype)
}
static void region_rect_recursive(
- ScrArea *sa, ARegion *region, rcti *remainder, rcti *overlap_remainder, int quad)
+ ScrArea *area, ARegion *region, rcti *remainder, rcti *overlap_remainder, int quad)
{
rcti *remainder_prev = remainder;
@@ -1259,7 +1259,7 @@ static void region_rect_recursive(
int alignment = RGN_ALIGN_ENUM_FROM_MASK(region->alignment);
/* set here, assuming userpref switching forces to call this again */
- region->overlap = ED_region_is_overlap(sa->spacetype, region->regiontype);
+ region->overlap = ED_region_is_overlap(area->spacetype, region->regiontype);
/* clear state flags first */
region->flag &= ~(RGN_FLAG_TOO_SMALL | RGN_FLAG_SIZE_CLAMP_X | RGN_FLAG_SIZE_CLAMP_Y);
@@ -1300,7 +1300,7 @@ static void region_rect_recursive(
else if (region->regiontype == RGN_TYPE_FOOTER) {
prefsizey = ED_area_footersize();
}
- else if (ED_area_is_global(sa)) {
+ else if (ED_area_is_global(area)) {
prefsizey = ED_region_global_size_y();
}
else {
@@ -1501,7 +1501,7 @@ static void region_rect_recursive(
/* exception for multiple overlapping regions on same spot */
if (region->overlap && (alignment != RGN_ALIGN_FLOAT)) {
- region_overlap_fix(sa, region);
+ region_overlap_fix(area, region);
}
/* set winrect for azones */
@@ -1548,7 +1548,7 @@ static void region_rect_recursive(
BLI_assert(BLI_rcti_is_valid(&region->winrct));
- region_rect_recursive(sa, region->next, remainder, overlap_remainder, quad);
+ region_rect_recursive(area, region->next, remainder, overlap_remainder, quad);
/* Tag for redraw if size changes. */
if (region->winx != prev_winx || region->winy != prev_winy) {
@@ -1559,42 +1559,42 @@ static void region_rect_recursive(
memset(&region->runtime.visible_rect, 0, sizeof(region->runtime.visible_rect));
}
-static void area_calc_totrct(ScrArea *sa, const rcti *window_rect)
+static void area_calc_totrct(ScrArea *area, const rcti *window_rect)
{
short px = (short)U.pixelsize;
- sa->totrct.xmin = sa->v1->vec.x;
- sa->totrct.xmax = sa->v4->vec.x;
- sa->totrct.ymin = sa->v1->vec.y;
- sa->totrct.ymax = sa->v2->vec.y;
+ area->totrct.xmin = area->v1->vec.x;
+ area->totrct.xmax = area->v4->vec.x;
+ area->totrct.ymin = area->v1->vec.y;
+ area->totrct.ymax = area->v2->vec.y;
/* scale down totrct by 1 pixel on all sides not matching window borders */
- if (sa->totrct.xmin > window_rect->xmin) {
- sa->totrct.xmin += px;
+ if (area->totrct.xmin > window_rect->xmin) {
+ area->totrct.xmin += px;
}
- if (sa->totrct.xmax < (window_rect->xmax - 1)) {
- sa->totrct.xmax -= px;
+ if (area->totrct.xmax < (window_rect->xmax - 1)) {
+ area->totrct.xmax -= px;
}
- if (sa->totrct.ymin > window_rect->ymin) {
- sa->totrct.ymin += px;
+ if (area->totrct.ymin > window_rect->ymin) {
+ area->totrct.ymin += px;
}
- if (sa->totrct.ymax < (window_rect->ymax - 1)) {
- sa->totrct.ymax -= px;
+ if (area->totrct.ymax < (window_rect->ymax - 1)) {
+ area->totrct.ymax -= px;
}
/* Although the following asserts are correct they lead to a very unstable Blender.
* And the asserts would fail even in 2.7x
* (they were added in 2.8x as part of the top-bar commit).
* For more details see T54864. */
#if 0
- BLI_assert(sa->totrct.xmin >= 0);
- BLI_assert(sa->totrct.xmax >= 0);
- BLI_assert(sa->totrct.ymin >= 0);
- BLI_assert(sa->totrct.ymax >= 0);
+ BLI_assert(area->totrct.xmin >= 0);
+ BLI_assert(area->totrct.xmax >= 0);
+ BLI_assert(area->totrct.ymin >= 0);
+ BLI_assert(area->totrct.ymax >= 0);
#endif
/* for speedup */
- sa->winx = BLI_rcti_size_x(&sa->totrct) + 1;
- sa->winy = BLI_rcti_size_y(&sa->totrct) + 1;
+ area->winx = BLI_rcti_size_x(&area->totrct) + 1;
+ area->winy = BLI_rcti_size_y(&area->totrct) + 1;
}
/* used for area initialize below */
@@ -1617,12 +1617,12 @@ static bool event_in_markers_region(const ARegion *region, const wmEvent *event)
}
/**
- * \param region: Region, may be NULL when adding handlers for \a sa.
+ * \param region: Region, may be NULL when adding handlers for \a area.
*/
static void ed_default_handlers(
- wmWindowManager *wm, ScrArea *sa, ARegion *region, ListBase *handlers, int flag)
+ wmWindowManager *wm, ScrArea *area, ARegion *region, ListBase *handlers, int flag)
{
- BLI_assert(region ? (&region->handlers == handlers) : (&sa->handlers == handlers));
+ BLI_assert(region ? (&region->handlers == handlers) : (&area->handlers == handlers));
/* note, add-handler checks if it already exists */
@@ -1641,7 +1641,7 @@ static void ed_default_handlers(
BLI_assert(&region->handlers == handlers);
if (region->gizmo_map == NULL) {
region->gizmo_map = WM_gizmomap_new_from_type(
- &(const struct wmGizmoMapType_Params){sa->spacetype, region->type->regionid});
+ &(const struct wmGizmoMapType_Params){area->spacetype, region->type->regionid});
}
WM_gizmomap_add_handlers(region, region->gizmo_map);
}
@@ -1668,9 +1668,9 @@ static void ed_default_handlers(
}
if (flag & ED_KEYMAP_TOOL) {
WM_event_add_keymap_handler_dynamic(
- &region->handlers, WM_event_get_keymap_from_toolsystem_fallback, sa);
+ &region->handlers, WM_event_get_keymap_from_toolsystem_fallback, area);
WM_event_add_keymap_handler_dynamic(
- &region->handlers, WM_event_get_keymap_from_toolsystem, sa);
+ &region->handlers, WM_event_get_keymap_from_toolsystem, area);
}
if (flag & ED_KEYMAP_FRAMES) {
/* frame changing/jumping (for all spaces) */
@@ -1824,7 +1824,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar
/* Dynamically sized regions may have changed region sizes, so we have to force azone update. */
area_azone_initialize(win, screen, area);
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
region_subwindow(region);
/* region size may have changed, init does necessary adjustments */
@@ -1841,7 +1841,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar
}
/* called in screen_refresh, or screens_init, also area size changes */
-void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
+void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *area)
{
WorkSpace *workspace = WM_window_get_active_workspace(win);
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
@@ -1850,49 +1850,49 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
rcti rect, overlap_rect;
rcti window_rect;
- if (ED_area_is_global(sa) && (sa->global->flag & GLOBAL_AREA_IS_HIDDEN)) {
+ if (ED_area_is_global(area) && (area->global->flag & GLOBAL_AREA_IS_HIDDEN)) {
return;
}
WM_window_rect_calc(win, &window_rect);
/* set typedefinitions */
- sa->type = BKE_spacetype_from_id(sa->spacetype);
+ area->type = BKE_spacetype_from_id(area->spacetype);
- if (sa->type == NULL) {
- sa->spacetype = SPACE_VIEW3D;
- sa->type = BKE_spacetype_from_id(sa->spacetype);
+ if (area->type == NULL) {
+ area->spacetype = SPACE_VIEW3D;
+ area->type = BKE_spacetype_from_id(area->spacetype);
}
- for (region = sa->regionbase.first; region; region = region->next) {
- region->type = BKE_regiontype_from_id_or_first(sa->type, region->regiontype);
+ for (region = area->regionbase.first; region; region = region->next) {
+ region->type = BKE_regiontype_from_id_or_first(area->type, region->regiontype);
}
/* area sizes */
- area_calc_totrct(sa, &window_rect);
+ area_calc_totrct(area, &window_rect);
/* region rect sizes */
- rect = sa->totrct;
+ rect = area->totrct;
overlap_rect = rect;
- region_rect_recursive(sa, sa->regionbase.first, &rect, &overlap_rect, 0);
- sa->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
+ region_rect_recursive(area, area->regionbase.first, &rect, &overlap_rect, 0);
+ area->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
/* default area handlers */
- ed_default_handlers(wm, sa, NULL, &sa->handlers, sa->type->keymapflag);
+ ed_default_handlers(wm, area, NULL, &area->handlers, area->type->keymapflag);
/* checks spacedata, adds own handlers */
- if (sa->type->init) {
- sa->type->init(wm, sa);
+ if (area->type->init) {
+ area->type->init(wm, area);
}
/* clear all azones, add the area triangle widgets */
- area_azone_initialize(win, screen, sa);
+ area_azone_initialize(win, screen, area);
/* region windows, default and own handlers */
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
region_subwindow(region);
if (region->visible) {
/* default region handlers */
- ed_default_handlers(wm, sa, region, &region->handlers, region->type->keymapflag);
+ ed_default_handlers(wm, area, region, &region->handlers, region->type->keymapflag);
/* own handlers */
if (region->type->init) {
region->type->init(wm, region);
@@ -1904,18 +1904,18 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
}
/* Some AZones use View2D data which is only updated in region init, so call that first! */
- region_azones_add(screen, sa, region);
+ region_azones_add(screen, area, region);
}
/* Avoid re-initializing tools while resizing the window. */
if ((G.moving & G_TRANSFORM_WM) == 0) {
- if ((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) {
- WM_toolsystem_refresh_screen_area(workspace, view_layer, sa);
- sa->flag |= AREA_FLAG_ACTIVE_TOOL_UPDATE;
+ if ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) {
+ WM_toolsystem_refresh_screen_area(workspace, view_layer, area);
+ area->flag |= AREA_FLAG_ACTIVE_TOOL_UPDATE;
}
else {
- sa->runtime.tool = NULL;
- sa->runtime.is_tool_set = true;
+ area->runtime.tool = NULL;
+ area->runtime.is_tool_set = true;
}
}
}
@@ -1948,19 +1948,19 @@ void ED_region_floating_initialize(ARegion *region)
region_update_rect(region);
}
-void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *region)
+void ED_region_cursor_set(wmWindow *win, ScrArea *area, ARegion *region)
{
if (region != NULL) {
if ((region->gizmo_map != NULL) && WM_gizmomap_cursor_set(region->gizmo_map, win)) {
return;
}
- if (sa && region->type && region->type->cursor) {
- region->type->cursor(win, sa, region);
+ if (area && region->type && region->type->cursor) {
+ region->type->cursor(win, area, region);
return;
}
}
- if (WM_cursor_set_from_tool(win, sa, region)) {
+ if (WM_cursor_set_from_tool(win, area, region)) {
return;
}
@@ -1968,29 +1968,29 @@ void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *region)
}
/* for use after changing visibility of regions */
-void ED_region_visibility_change_update(bContext *C, ScrArea *sa, ARegion *region)
+void ED_region_visibility_change_update(bContext *C, ScrArea *area, ARegion *region)
{
if (region->flag & RGN_FLAG_HIDDEN) {
WM_event_remove_handlers(C, &region->handlers);
}
- ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
- ED_area_tag_redraw(sa);
+ ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), area);
+ ED_area_tag_redraw(area);
}
/* for quick toggle, can skip fades */
void region_toggle_hidden(bContext *C, ARegion *region, const bool do_fade)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
region->flag ^= RGN_FLAG_HIDDEN;
if (do_fade && region->overlap) {
/* starts a timer, and in end calls the stuff below itself (region_sblend_invoke()) */
- ED_region_visibility_change_update_animated(C, sa, region);
+ ED_region_visibility_change_update_animated(C, area, region);
}
else {
- ED_region_visibility_change_update(C, sa, region);
+ ED_region_visibility_change_update(C, area, region);
}
}
@@ -2003,48 +2003,48 @@ void ED_region_toggle_hidden(bContext *C, ARegion *region)
/**
* we swap spaces for fullscreen to keep all allocated data area vertices were set
*/
-void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free)
+void ED_area_data_copy(ScrArea *area_dst, ScrArea *area_src, const bool do_free)
{
SpaceType *st;
ARegion *region;
- const char spacetype = sa_dst->spacetype;
+ const char spacetype = area_dst->spacetype;
const short flag_copy = HEADER_NO_PULLDOWN;
- sa_dst->spacetype = sa_src->spacetype;
- sa_dst->type = sa_src->type;
+ area_dst->spacetype = area_src->spacetype;
+ area_dst->type = area_src->type;
- sa_dst->flag = (sa_dst->flag & ~flag_copy) | (sa_src->flag & flag_copy);
+ area_dst->flag = (area_dst->flag & ~flag_copy) | (area_src->flag & flag_copy);
/* area */
if (do_free) {
- BKE_spacedata_freelist(&sa_dst->spacedata);
+ BKE_spacedata_freelist(&area_dst->spacedata);
}
- BKE_spacedata_copylist(&sa_dst->spacedata, &sa_src->spacedata);
+ BKE_spacedata_copylist(&area_dst->spacedata, &area_src->spacedata);
/* Note; SPACE_EMPTY is possible on new screens */
/* regions */
if (do_free) {
st = BKE_spacetype_from_id(spacetype);
- for (region = sa_dst->regionbase.first; region; region = region->next) {
+ for (region = area_dst->regionbase.first; region; region = region->next) {
BKE_area_region_free(st, region);
}
- BLI_freelistN(&sa_dst->regionbase);
+ BLI_freelistN(&area_dst->regionbase);
}
- st = BKE_spacetype_from_id(sa_src->spacetype);
- for (region = sa_src->regionbase.first; region; region = region->next) {
+ st = BKE_spacetype_from_id(area_src->spacetype);
+ for (region = area_src->regionbase.first; region; region = region->next) {
ARegion *newar = BKE_area_region_copy(st, region);
- BLI_addtail(&sa_dst->regionbase, newar);
+ BLI_addtail(&area_dst->regionbase, newar);
}
}
-void ED_area_data_swap(ScrArea *sa_dst, ScrArea *sa_src)
+void ED_area_data_swap(ScrArea *area_dst, ScrArea *area_src)
{
- SWAP(char, sa_dst->spacetype, sa_src->spacetype);
- SWAP(SpaceType *, sa_dst->type, sa_src->type);
+ SWAP(char, area_dst->spacetype, area_src->spacetype);
+ SWAP(SpaceType *, area_dst->type, area_src->type);
- SWAP(ListBase, sa_dst->spacedata, sa_src->spacedata);
- SWAP(ListBase, sa_dst->regionbase, sa_src->regionbase);
+ SWAP(ListBase, area_dst->spacedata, area_src->spacedata);
+ SWAP(ListBase, area_dst->regionbase, area_src->regionbase);
}
/* *********** Space switching code *********** */
@@ -2076,18 +2076,18 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2)
}
/**
- * \param skip_ar_exit: Skip calling area exit callback. Set for opening temp spaces.
+ * \param skip_region_exit: Skip calling area exit callback. Set for opening temp spaces.
*/
-void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exit)
+void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_region_exit)
{
wmWindow *win = CTX_wm_window(C);
- if (sa->spacetype != type) {
+ if (area->spacetype != type) {
SpaceType *st;
- SpaceLink *slold = sa->spacedata.first;
+ SpaceLink *slold = area->spacedata.first;
SpaceLink *sl;
- /* store sa->type->exit callback */
- void *sa_exit = sa->type ? sa->type->exit : NULL;
+ /* store area->type->exit callback */
+ void *area_exit = area->type ? area->type->exit : NULL;
/* When the user switches between space-types from the type-selector,
* changing the header-type is jarring (especially when using Ctrl-MouseWheel).
*
@@ -2098,34 +2098,34 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
* the space type defaults to in this case instead
* (needed for preferences to have space-type on bottom).
*/
- int header_alignment = ED_area_header_alignment_or_fallback(sa, -1);
+ int header_alignment = ED_area_header_alignment_or_fallback(area, -1);
const bool sync_header_alignment = ((header_alignment != -1) &&
((slold->link_flag & SPACE_FLAG_TYPE_TEMPORARY) == 0));
/* in some cases (opening temp space) we don't want to
* call area exit callback, so we temporarily unset it */
- if (skip_ar_exit && sa->type) {
- sa->type->exit = NULL;
+ if (skip_region_exit && area->type) {
+ area->type->exit = NULL;
}
- ED_area_exit(C, sa);
+ ED_area_exit(C, area);
/* restore old area exit callback */
- if (skip_ar_exit && sa->type) {
- sa->type->exit = sa_exit;
+ if (skip_region_exit && area->type) {
+ area->type->exit = area_exit;
}
st = BKE_spacetype_from_id(type);
- sa->spacetype = type;
- sa->type = st;
+ area->spacetype = type;
+ area->type = st;
/* If st->new may be called, don't use context until then. The
- * sa->type->context() callback has changed but data may be invalid
+ * area->type->context() callback has changed but data may be invalid
* (e.g. with properties editor) until space-data is properly created */
/* check previously stored space */
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ for (sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == type) {
break;
}
@@ -2134,7 +2134,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
/* old spacedata... happened during work on 2.50, remove */
if (sl && BLI_listbase_is_empty(&sl->regionbase)) {
st->free(sl);
- BLI_freelinkN(&sa->spacedata, sl);
+ BLI_freelinkN(&area->spacedata, sl);
if (slold == sl) {
slold = NULL;
}
@@ -2143,8 +2143,8 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
if (sl) {
/* swap regions */
- slold->regionbase = sa->regionbase;
- sa->regionbase = sl->regionbase;
+ slold->regionbase = area->regionbase;
+ area->regionbase = sl->regionbase;
BLI_listbase_clear(&sl->regionbase);
/* SPACE_FLAG_TYPE_WAS_ACTIVE is only used to go back to a previously active space that is
* overlapped by temporary ones. It's now properly activated, so the flag should be cleared
@@ -2152,22 +2152,22 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
sl->link_flag &= ~SPACE_FLAG_TYPE_WAS_ACTIVE;
/* put in front of list */
- BLI_remlink(&sa->spacedata, sl);
- BLI_addhead(&sa->spacedata, sl);
+ BLI_remlink(&area->spacedata, sl);
+ BLI_addhead(&area->spacedata, sl);
}
else {
/* new space */
if (st) {
/* Don't get scene from context here which may depend on space-data. */
Scene *scene = WM_window_get_active_scene(win);
- sl = st->new (sa, scene);
- BLI_addhead(&sa->spacedata, sl);
+ sl = st->new (area, scene);
+ BLI_addhead(&area->spacedata, sl);
/* swap regions */
if (slold) {
- slold->regionbase = sa->regionbase;
+ slold->regionbase = area->regionbase;
}
- sa->regionbase = sl->regionbase;
+ area->regionbase = sl->regionbase;
BLI_listbase_clear(&sl->regionbase);
}
}
@@ -2176,7 +2176,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
if (sync_header_alignment) {
/* Spaces with footer. */
if (st->spaceid == SPACE_TEXT) {
- for (ARegion *region = sa->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
region->alignment = header_alignment;
}
@@ -2189,7 +2189,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
}
}
else {
- for (ARegion *region = sa->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
region->alignment = header_alignment;
break;
@@ -2198,24 +2198,24 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
}
}
- ED_area_initialize(CTX_wm_manager(C), win, sa);
+ ED_area_initialize(CTX_wm_manager(C), win, area);
/* tell WM to refresh, cursor types etc */
WM_event_add_mousemove(win);
/* send space change notifier */
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, area);
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
/* also redraw when re-used */
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
-static SpaceLink *area_get_prevspace(ScrArea *sa)
+static SpaceLink *area_get_prevspace(ScrArea *area)
{
- SpaceLink *sl = sa->spacedata.first;
+ SpaceLink *sl = area->spacedata.first;
/* First toggle to the next temporary space in the list. */
for (SpaceLink *sl_iter = sl->next; sl_iter; sl_iter = sl_iter->next) {
@@ -2235,13 +2235,13 @@ static SpaceLink *area_get_prevspace(ScrArea *sa)
return sl->next;
}
-void ED_area_prevspace(bContext *C, ScrArea *sa)
+void ED_area_prevspace(bContext *C, ScrArea *area)
{
- SpaceLink *sl = sa->spacedata.first;
- SpaceLink *prevspace = sl ? area_get_prevspace(sa) : NULL;
+ SpaceLink *sl = area->spacedata.first;
+ SpaceLink *prevspace = sl ? area_get_prevspace(area) : NULL;
if (prevspace) {
- ED_area_newspace(C, sa, prevspace->spacetype, false);
+ ED_area_newspace(C, area, prevspace->spacetype, false);
/* We've exited the space, so it can't be considered temporary anymore. */
sl->link_flag &= ~SPACE_FLAG_TYPE_TEMPORARY;
}
@@ -2251,23 +2251,23 @@ void ED_area_prevspace(bContext *C, ScrArea *sa)
}
/* If this is a stacked fullscreen, changing to previous area exits it (meaning we're still in a
* fullscreen, but not in a stacked one). */
- sa->flag &= ~AREA_FLAG_STACKED_FULLSCREEN;
+ area->flag &= ~AREA_FLAG_STACKED_FULLSCREEN;
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
/* send space change notifier */
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, area);
}
/* returns offset for next button in header */
int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
{
- ScrArea *sa = CTX_wm_area(C);
- bScreen *scr = CTX_wm_screen(C);
+ ScrArea *area = CTX_wm_area(C);
+ bScreen *screen = CTX_wm_screen(C);
PointerRNA areaptr;
int xco = 0.4 * U.widget_unit;
- RNA_pointer_create(&(scr->id), &RNA_Area, sa, &areaptr);
+ RNA_pointer_create(&(screen->id), &RNA_Area, area, &areaptr);
uiDefButR(block,
UI_BTYPE_MENU,
@@ -2342,7 +2342,7 @@ BLI_INLINE bool streq_array_any(const char *s, const char *arr[])
}
static void ed_panel_draw(const bContext *C,
- ScrArea *sa,
+ ScrArea *area,
ARegion *region,
ListBase *lb,
PanelType *pt,
@@ -2357,7 +2357,7 @@ static void ed_panel_draw(const bContext *C,
uiBlock *block = UI_block_begin(C, region, pt->idname, UI_EMBOSS);
bool open;
- panel = UI_panel_begin(sa, region, lb, block, pt, panel, &open);
+ panel = UI_panel_begin(area, region, lb, block, pt, panel, &open);
/* bad fixed values */
int xco, yco, h = 0;
@@ -2440,17 +2440,17 @@ static void ed_panel_draw(const bContext *C,
/* Draw child panels. */
if (open) {
- for (LinkData *link = pt->children.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &pt->children) {
PanelType *child_pt = link->data;
Panel *child_panel = UI_panel_find_by_type(&panel->children, child_pt);
if (child_pt->draw && (!child_pt->poll || child_pt->poll(C, child_pt))) {
- ed_panel_draw(C, sa, region, &panel->children, child_pt, child_panel, w, em, vertical);
+ ed_panel_draw(C, area, region, &panel->children, child_pt, child_panel, w, em, vertical);
}
}
}
- UI_panel_end(sa, region, block, w, h, open);
+ UI_panel_end(area, region, block, w, h, open);
}
/**
@@ -2499,7 +2499,7 @@ void ED_region_panels_layout_ex(const bContext *C,
region->runtime.category = NULL;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
View2D *v2d = &region->v2d;
int x, y, w, em;
@@ -2508,7 +2508,7 @@ void ED_region_panels_layout_ex(const bContext *C,
bool use_category_tabs = (category_override == NULL) &&
((((1 << region->regiontype) & RGN_TYPE_HAS_CATEGORY_MASK) ||
(region->regiontype == RGN_TYPE_TOOLS &&
- sa->spacetype == SPACE_CLIP)));
+ area->spacetype == SPACE_CLIP)));
/* offset panels for small vertical tab area */
const char *category = NULL;
const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH;
@@ -2584,7 +2584,7 @@ void ED_region_panels_layout_ex(const bContext *C,
}
}
- ed_panel_draw(C, sa, region, &region->panels, pt, panel, w, em, vertical);
+ ed_panel_draw(C, area, region, &region->panels, pt, panel, w, em, vertical);
}
/* align panels and return size */
@@ -2605,7 +2605,7 @@ void ED_region_panels_layout_ex(const bContext *C,
if ((region->sizex != size_dyn[0]) || (region->sizey != size_dyn[1])) {
region->sizex = size_dyn[0];
region->sizey = size_dyn[1];
- sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
+ area->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
}
y = fabsf(region->sizey * UI_DPI_FAC - 1);
}
@@ -2799,10 +2799,10 @@ void ED_region_header_layout(const bContext *C, ARegion *region)
if (region_layout_based && (region->sizex != new_sizex)) {
/* region size is layout based and needs to be updated */
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
region->sizex = new_sizex;
- sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
+ area->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
}
UI_block_end(C, block);
@@ -2856,7 +2856,7 @@ int ED_area_headersize(void)
int ED_area_header_alignment_or_fallback(const ScrArea *area, int fallback)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_HEADER) {
return region->alignment;
}
@@ -2877,7 +2877,7 @@ int ED_area_footersize(void)
int ED_area_footer_alignment_or_fallback(const ScrArea *area, int fallback)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_FOOTER) {
return region->alignment;
}
@@ -3575,7 +3575,7 @@ void ED_region_message_subscribe(bContext *C,
struct WorkSpace *workspace,
struct Scene *scene,
struct bScreen *screen,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus)
{
@@ -3588,7 +3588,7 @@ void ED_region_message_subscribe(bContext *C,
}
if (region->type->message_subscribe != NULL) {
- region->type->message_subscribe(C, workspace, scene, screen, sa, region, mbus);
+ region->type->message_subscribe(C, workspace, scene, screen, area, region, mbus);
}
}
diff --git a/source/blender/editors/screen/area_query.c b/source/blender/editors/screen/area_query.c
index 739f1b93e07..d569e56e11b 100644
--- a/source/blender/editors/screen/area_query.c
+++ b/source/blender/editors/screen/area_query.c
@@ -73,19 +73,19 @@ bool ED_region_overlap_isect_any_xy(const ScrArea *area, const int event_xy[2])
return false;
}
-bool ED_region_panel_category_gutter_calc_rect(const ARegion *region, rcti *r_ar_gutter)
+bool ED_region_panel_category_gutter_calc_rect(const ARegion *region, rcti *r_region_gutter)
{
- *r_ar_gutter = region->winrct;
+ *r_region_gutter = region->winrct;
if (UI_panel_category_is_visible(region)) {
const int category_tabs_width = round_fl_to_int(UI_view2d_scale_get_x(&region->v2d) *
UI_PANEL_CATEGORY_MARGIN_WIDTH);
const int alignment = RGN_ALIGN_ENUM_FROM_MASK(region->alignment);
if (alignment == RGN_ALIGN_LEFT) {
- r_ar_gutter->xmax = r_ar_gutter->xmin + category_tabs_width;
+ r_region_gutter->xmax = r_region_gutter->xmin + category_tabs_width;
}
else if (alignment == RGN_ALIGN_RIGHT) {
- r_ar_gutter->xmin = r_ar_gutter->xmax - category_tabs_width;
+ r_region_gutter->xmin = r_region_gutter->xmax - category_tabs_width;
}
else {
BLI_assert(!"Unsupported alignment");
@@ -97,9 +97,9 @@ bool ED_region_panel_category_gutter_calc_rect(const ARegion *region, rcti *r_ar
bool ED_region_panel_category_gutter_isect_xy(const ARegion *region, const int event_xy[2])
{
- rcti ar_gutter;
- if (ED_region_panel_category_gutter_calc_rect(region, &ar_gutter)) {
- return BLI_rcti_isect_pt_v(&ar_gutter, event_xy);
+ rcti region_gutter;
+ if (ED_region_panel_category_gutter_calc_rect(region, &region_gutter)) {
+ return BLI_rcti_isect_pt_v(&region_gutter, event_xy);
}
return false;
}
diff --git a/source/blender/editors/screen/area_utils.c b/source/blender/editors/screen/area_utils.c
index cacd6b1edd7..075759f1120 100644
--- a/source/blender/editors/screen/area_utils.c
+++ b/source/blender/editors/screen/area_utils.c
@@ -46,7 +46,7 @@ void ED_region_generic_tools_region_message_subscribe(const struct bContext *UNU
struct WorkSpace *UNUSED(workspace),
struct Scene *UNUSED(scene),
struct bScreen *UNUSED(screen),
- struct ScrArea *UNUSED(sa),
+ struct ScrArea *UNUSED(area),
struct ARegion *region,
struct wmMsgBus *mbus)
{
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index f757b856dcf..ddb345ab65e 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -132,7 +132,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
float yzoom,
float color[4])
{
- unsigned char *uc_rect = (unsigned char *)rect;
+ uchar *uc_rect = (uchar *)rect;
const float *f_rect = (float *)rect;
int subpart_x, subpart_y, tex_w, tex_h;
int seamless, offset_x, offset_y, nsubparts_x, nsubparts_y;
@@ -185,7 +185,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex_w, tex_h, 0, format, GL_UNSIGNED_BYTE, NULL);
}
- unsigned int pos = state->pos, texco = state->texco;
+ uint pos = state->pos, texco = state->texco;
/* optional */
/* NOTE: Shader could be null for GLSL OCIO drawing, it is fine, since
@@ -650,7 +650,7 @@ void ED_draw_imbuf_clipping(ImBuf *ibuf,
/* In case GLSL failed or not usable, fallback to glaDrawPixelsAuto */
if (need_fallback) {
- unsigned char *display_buffer;
+ uchar *display_buffer;
void *cache_handle;
display_buffer = IMB_display_buffer_acquire(
@@ -758,7 +758,7 @@ int ED_draw_imbuf_method(ImBuf *ibuf)
/* don't move to GPU_immediate_util.h because this uses user-prefs
* and isn't very low level */
-void immDrawBorderCorners(unsigned int pos, const rcti *border, float zoomx, float zoomy)
+void immDrawBorderCorners(uint pos, const rcti *border, float zoomx, float zoomy)
{
float delta_x = 4.0f * UI_DPI_FAC / zoomx;
float delta_y = 4.0f * UI_DPI_FAC / zoomy;
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 9536772be3d..2ac113d2ba7 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -27,6 +27,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
@@ -36,6 +37,7 @@
#include "DNA_space_types.h"
#include "DNA_windowmanager_types.h"
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_action.h"
@@ -88,6 +90,7 @@ const char *screen_context_dir[] = {
"sequences",
"selected_sequences",
"selected_editable_sequences", /* sequencer */
+ "selected_nla_strips", /* nla editor */
"gpencil_data",
"gpencil_data_owner", /* grease pencil data */
"annotation_data",
@@ -111,8 +114,8 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
{
wmWindow *win = CTX_wm_window(C);
View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
- bScreen *sc = CTX_wm_screen(C);
- ScrArea *sa = CTX_wm_area(C);
+ bScreen *screen = CTX_wm_screen(C);
+ ScrArea *area = CTX_wm_area(C);
Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
Object *obact = (view_layer && view_layer->basact) ? view_layer->basact->object : NULL;
@@ -127,7 +130,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "visible_objects")) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (BASE_VISIBLE(v3d, base)) {
CTX_data_id_list_add(result, &base->object->id);
}
@@ -136,7 +139,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "selectable_objects")) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (BASE_SELECTABLE(v3d, base)) {
CTX_data_id_list_add(result, &base->object->id);
}
@@ -145,7 +148,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "selected_objects")) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (BASE_SELECTED(v3d, base)) {
CTX_data_id_list_add(result, &base->object->id);
}
@@ -154,7 +157,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "selected_editable_objects")) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (BASE_SELECTED_EDITABLE(v3d, base)) {
CTX_data_id_list_add(result, &base->object->id);
}
@@ -164,7 +167,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if (CTX_data_equals(member, "editable_objects")) {
/* Visible + Editable, but not necessarily selected */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (BASE_EDITABLE(v3d, base)) {
CTX_data_id_list_add(result, &base->object->id);
}
@@ -503,13 +506,35 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
}
+ else if (CTX_data_equals(member, "selected_nla_strips")) {
+ bAnimContext ac;
+ if (ANIM_animdata_get_context(C, &ac) != 0) {
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+
+ ANIM_animdata_filter(&ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac.data, ac.datatype);
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ NlaTrack *nlt = (NlaTrack *)ale->data;
+ NlaStrip *strip;
+ for (strip = nlt->strips.first; strip; strip = strip->next) {
+ if (strip->flag & NLASTRIP_FLAG_SELECT) {
+ CTX_data_list_add(result, &scene->id, &RNA_NlaStrip, strip);
+ }
+ }
+ }
+ ANIM_animdata_freelist(&anim_data);
+
+ CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+ return 1;
+ }
+ }
else if (CTX_data_equals(member, "gpencil_data")) {
/* FIXME: for some reason, CTX_data_active_object(C) returns NULL when called from these
* situations (as outlined above - see Campbell's #ifdefs).
* That causes the get_active function to fail when called from context.
* For that reason, we end up using an alternative where we pass everything in!
*/
- bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
+ bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
if (gpd) {
CTX_data_id_pointer_set(result, &gpd->id);
@@ -523,7 +548,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
PointerRNA ptr;
/* get pointer to Grease Pencil Data */
- gpd_ptr = ED_gpencil_data_get_pointers_direct(sa, obact, &ptr);
+ gpd_ptr = ED_gpencil_data_get_pointers_direct(area, obact, &ptr);
if (gpd_ptr) {
CTX_data_pointer_set(result, ptr.owner_id, ptr.type, ptr.data);
@@ -531,7 +556,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "annotation_data")) {
- bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)sc, sa, scene);
+ bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)screen, area, scene);
if (gpd) {
CTX_data_id_pointer_set(result, &gpd->id);
@@ -544,7 +569,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
PointerRNA ptr;
/* Get pointer to Grease Pencil Data. */
- gpd_ptr = ED_annotation_data_get_pointers_direct((ID *)sc, sa, scene, &ptr);
+ gpd_ptr = ED_annotation_data_get_pointers_direct((ID *)screen, area, scene, &ptr);
if (gpd_ptr) {
CTX_data_pointer_set(result, ptr.owner_id, ptr.type, ptr.data);
@@ -552,7 +577,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "active_gpencil_layer")) {
- bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
+ bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
if (gpd) {
bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
@@ -564,7 +589,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "active_annotation_layer")) {
- bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)sc, sa, scene);
+ bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)screen, area, scene);
if (gpd) {
bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
@@ -576,7 +601,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "active_gpencil_frame")) {
- bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
+ bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
if (gpd) {
bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
@@ -588,7 +613,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "visible_gpencil_layers")) {
- bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
+ bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
if (gpd) {
bGPDlayer *gpl;
@@ -603,7 +628,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "editable_gpencil_layers")) {
- bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
+ bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
if (gpd) {
bGPDlayer *gpl;
@@ -618,7 +643,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "editable_gpencil_strokes")) {
- bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
+ bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
if (gpd) {
@@ -636,7 +661,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
for (gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
for (gps = gpf->strokes.first; gps; gps = gps->next) {
- if (ED_gpencil_stroke_can_use_direct(sa, gps)) {
+ if (ED_gpencil_stroke_can_use_direct(area, gps)) {
/* check if the color is editable */
if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {
continue;
@@ -701,7 +726,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
CTX_data_list_add(result, ale->fcurve_owner_id, &RNA_FCurve, ale->data);
}
@@ -724,7 +749,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
CTX_data_pointer_set(result, ale->fcurve_owner_id, &RNA_FCurve, ale->data);
break;
diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c
index 3331f4db11b..2452302561b 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -41,10 +41,10 @@
* Draw horizontal shape visualizing future joining
* (left as well right direction of future joining).
*/
-static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos)
+static void draw_horizontal_join_shape(ScrArea *area, char dir, uint pos)
{
- const float width = screen_geom_area_width(sa) - 1;
- const float height = screen_geom_area_height(sa) - 1;
+ const float width = screen_geom_area_width(area) - 1;
+ const float height = screen_geom_area_height(area) - 1;
vec2f points[10];
short i;
float w, h;
@@ -58,43 +58,43 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos)
w = width / 4;
}
- points[0].x = sa->v1->vec.x;
- points[0].y = sa->v1->vec.y + height / 2;
+ points[0].x = area->v1->vec.x;
+ points[0].y = area->v1->vec.y + height / 2;
- points[1].x = sa->v1->vec.x;
- points[1].y = sa->v1->vec.y;
+ points[1].x = area->v1->vec.x;
+ points[1].y = area->v1->vec.y;
- points[2].x = sa->v4->vec.x - w;
- points[2].y = sa->v4->vec.y;
+ points[2].x = area->v4->vec.x - w;
+ points[2].y = area->v4->vec.y;
- points[3].x = sa->v4->vec.x - w;
- points[3].y = sa->v4->vec.y + height / 2 - 2 * h;
+ points[3].x = area->v4->vec.x - w;
+ points[3].y = area->v4->vec.y + height / 2 - 2 * h;
- points[4].x = sa->v4->vec.x - 2 * w;
- points[4].y = sa->v4->vec.y + height / 2;
+ points[4].x = area->v4->vec.x - 2 * w;
+ points[4].y = area->v4->vec.y + height / 2;
- points[5].x = sa->v4->vec.x - w;
- points[5].y = sa->v4->vec.y + height / 2 + 2 * h;
+ points[5].x = area->v4->vec.x - w;
+ points[5].y = area->v4->vec.y + height / 2 + 2 * h;
- points[6].x = sa->v3->vec.x - w;
- points[6].y = sa->v3->vec.y;
+ points[6].x = area->v3->vec.x - w;
+ points[6].y = area->v3->vec.y;
- points[7].x = sa->v2->vec.x;
- points[7].y = sa->v2->vec.y;
+ points[7].x = area->v2->vec.x;
+ points[7].y = area->v2->vec.y;
- points[8].x = sa->v4->vec.x;
- points[8].y = sa->v4->vec.y + height / 2 - h;
+ points[8].x = area->v4->vec.x;
+ points[8].y = area->v4->vec.y + height / 2 - h;
- points[9].x = sa->v4->vec.x;
- points[9].y = sa->v4->vec.y + height / 2 + h;
+ points[9].x = area->v4->vec.x;
+ points[9].y = area->v4->vec.y + height / 2 + h;
if (dir == 'l') {
/* when direction is left, then we flip direction of arrow */
- float cx = sa->v1->vec.x + width;
+ float cx = area->v1->vec.x + width;
for (i = 0; i < 10; i++) {
points[i].x -= cx;
points[i].x = -points[i].x;
- points[i].x += sa->v1->vec.x;
+ points[i].x += area->v1->vec.x;
}
}
@@ -122,10 +122,10 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos)
/**
* Draw vertical shape visualizing future joining (up/down direction).
*/
-static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos)
+static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos)
{
- const float width = screen_geom_area_width(sa) - 1;
- const float height = screen_geom_area_height(sa) - 1;
+ const float width = screen_geom_area_width(area) - 1;
+ const float height = screen_geom_area_height(area) - 1;
vec2f points[10];
short i;
float w, h;
@@ -139,43 +139,43 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos)
w = width / 8;
}
- points[0].x = sa->v1->vec.x + width / 2;
- points[0].y = sa->v3->vec.y;
+ points[0].x = area->v1->vec.x + width / 2;
+ points[0].y = area->v3->vec.y;
- points[1].x = sa->v2->vec.x;
- points[1].y = sa->v2->vec.y;
+ points[1].x = area->v2->vec.x;
+ points[1].y = area->v2->vec.y;
- points[2].x = sa->v1->vec.x;
- points[2].y = sa->v1->vec.y + h;
+ points[2].x = area->v1->vec.x;
+ points[2].y = area->v1->vec.y + h;
- points[3].x = sa->v1->vec.x + width / 2 - 2 * w;
- points[3].y = sa->v1->vec.y + h;
+ points[3].x = area->v1->vec.x + width / 2 - 2 * w;
+ points[3].y = area->v1->vec.y + h;
- points[4].x = sa->v1->vec.x + width / 2;
- points[4].y = sa->v1->vec.y + 2 * h;
+ points[4].x = area->v1->vec.x + width / 2;
+ points[4].y = area->v1->vec.y + 2 * h;
- points[5].x = sa->v1->vec.x + width / 2 + 2 * w;
- points[5].y = sa->v1->vec.y + h;
+ points[5].x = area->v1->vec.x + width / 2 + 2 * w;
+ points[5].y = area->v1->vec.y + h;
- points[6].x = sa->v4->vec.x;
- points[6].y = sa->v4->vec.y + h;
+ points[6].x = area->v4->vec.x;
+ points[6].y = area->v4->vec.y + h;
- points[7].x = sa->v3->vec.x;
- points[7].y = sa->v3->vec.y;
+ points[7].x = area->v3->vec.x;
+ points[7].y = area->v3->vec.y;
- points[8].x = sa->v1->vec.x + width / 2 - w;
- points[8].y = sa->v1->vec.y;
+ points[8].x = area->v1->vec.x + width / 2 - w;
+ points[8].y = area->v1->vec.y;
- points[9].x = sa->v1->vec.x + width / 2 + w;
- points[9].y = sa->v1->vec.y;
+ points[9].x = area->v1->vec.x + width / 2 + w;
+ points[9].y = area->v1->vec.y;
if (dir == 'u') {
/* when direction is up, then we flip direction of arrow */
- float cy = sa->v1->vec.y + height;
+ float cy = area->v1->vec.y + height;
for (i = 0; i < 10; i++) {
points[i].y -= cy;
points[i].y = -points[i].y;
- points[i].y += sa->v1->vec.y;
+ points[i].y += area->v1->vec.y;
}
}
@@ -203,13 +203,13 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos)
/**
* Draw join shape due to direction of joining.
*/
-static void draw_join_shape(ScrArea *sa, char dir, unsigned int pos)
+static void draw_join_shape(ScrArea *area, char dir, uint pos)
{
if (dir == 'u' || dir == 'd') {
- draw_vertical_join_shape(sa, dir, pos);
+ draw_vertical_join_shape(area, dir, pos);
}
else {
- draw_horizontal_join_shape(sa, dir, pos);
+ draw_horizontal_join_shape(area, dir, pos);
}
}
@@ -294,26 +294,26 @@ static GPUBatch *batch_screen_edges_get(int *corner_len)
/**
* Draw screen area darker with arrow (visualization of future joining).
*/
-static void scrarea_draw_shape_dark(ScrArea *sa, char dir, unsigned int pos)
+static void scrarea_draw_shape_dark(ScrArea *area, char dir, uint pos)
{
GPU_blend_set_func_separate(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
immUniformColor4ub(0, 0, 0, 50);
- draw_join_shape(sa, dir, pos);
+ draw_join_shape(area, dir, pos);
}
/**
* Draw screen area lighter with arrow shape ("eraser" of previous dark shape).
*/
-static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir), unsigned int pos)
+static void scrarea_draw_shape_light(ScrArea *area, char UNUSED(dir), uint pos)
{
GPU_blend_set_func(GPU_DST_COLOR, GPU_SRC_ALPHA);
/* value 181 was hardly computed: 181~105 */
immUniformColor4ub(255, 255, 255, 50);
- /* draw_join_shape(sa, dir); */
+ /* draw_join_shape(area, dir); */
- immRectf(pos, sa->v1->vec.x, sa->v1->vec.y, sa->v3->vec.x, sa->v3->vec.y);
+ immRectf(pos, area->v1->vec.x, area->v1->vec.y, area->v3->vec.x, area->v3->vec.y);
}
static void drawscredge_area_draw(
@@ -350,12 +350,12 @@ static void drawscredge_area_draw(
/**
* \brief Screen edges drawing.
*/
-static void drawscredge_area(ScrArea *sa, int sizex, int sizey, float edge_thickness)
+static void drawscredge_area(ScrArea *area, int sizex, int sizey, float edge_thickness)
{
- short x1 = sa->v1->vec.x;
- short y1 = sa->v1->vec.y;
- short x2 = sa->v3->vec.x;
- short y2 = sa->v3->vec.y;
+ short x1 = area->v1->vec.x;
+ short y1 = area->v1->vec.y;
+ short x2 = area->v3->vec.x;
+ short y2 = area->v3->vec.y;
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, edge_thickness);
}
@@ -381,13 +381,13 @@ void ED_screen_draw_edges(wmWindow *win)
float col[4], corner_scale, edge_thickness;
int verts_per_corner = 0;
- ScrArea *sa;
+ ScrArea *area;
rcti scissor_rect;
BLI_rcti_init_minmax(&scissor_rect);
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){sa->v1->vec.x, sa->v1->vec.y});
- BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){sa->v3->vec.x, sa->v3->vec.y});
+ for (area = screen->areabase.first; area; area = area->next) {
+ BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){area->v1->vec.x, area->v1->vec.y});
+ BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){area->v3->vec.x, area->v3->vec.y});
}
if (GPU_type_matches(GPU_DEVICE_INTEL_UHD, GPU_OS_UNIX, GPU_DRIVER_ANY)) {
@@ -422,8 +422,8 @@ void ED_screen_draw_edges(wmWindow *win)
GPU_batch_uniform_1f(batch, "scale", corner_scale);
GPU_batch_uniform_4fv(batch, "color", col);
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- drawscredge_area(sa, winsize_x, winsize_y, edge_thickness);
+ for (area = screen->areabase.first; area; area = area->next) {
+ drawscredge_area(area, winsize_x, winsize_y, edge_thickness);
}
GPU_blend(false);
@@ -480,7 +480,7 @@ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2)
immUnbindProgram();
}
-void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
+void ED_screen_draw_split_preview(ScrArea *area, const int dir, const float fac)
{
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -495,10 +495,10 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
immBegin(GPU_PRIM_LINES, 2);
if (dir == 'h') {
- const float y = (1 - fac) * sa->totrct.ymin + fac * sa->totrct.ymax;
+ const float y = (1 - fac) * area->totrct.ymin + fac * area->totrct.ymax;
- immVertex2f(pos, sa->totrct.xmin, y);
- immVertex2f(pos, sa->totrct.xmax, y);
+ immVertex2f(pos, area->totrct.xmin, y);
+ immVertex2f(pos, area->totrct.xmax, y);
immEnd();
@@ -506,17 +506,17 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
immBegin(GPU_PRIM_LINES, 2);
- immVertex2f(pos, sa->totrct.xmin, y + 1);
- immVertex2f(pos, sa->totrct.xmax, y + 1);
+ immVertex2f(pos, area->totrct.xmin, y + 1);
+ immVertex2f(pos, area->totrct.xmax, y + 1);
immEnd();
}
else {
BLI_assert(dir == 'v');
- const float x = (1 - fac) * sa->totrct.xmin + fac * sa->totrct.xmax;
+ const float x = (1 - fac) * area->totrct.xmin + fac * area->totrct.xmax;
- immVertex2f(pos, x, sa->totrct.ymin);
- immVertex2f(pos, x, sa->totrct.ymax);
+ immVertex2f(pos, x, area->totrct.ymin);
+ immVertex2f(pos, x, area->totrct.ymax);
immEnd();
@@ -524,8 +524,8 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
immBegin(GPU_PRIM_LINES, 2);
- immVertex2f(pos, x + 1, sa->totrct.ymin);
- immVertex2f(pos, x + 1, sa->totrct.ymax);
+ immVertex2f(pos, x + 1, area->totrct.ymin);
+ immVertex2f(pos, x + 1, area->totrct.ymax);
immEnd();
}
@@ -547,9 +547,9 @@ static void screen_preview_scale_get(
{
float max_x = 0, max_y = 0;
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- max_x = MAX2(max_x, sa->totrct.xmax);
- max_y = MAX2(max_y, sa->totrct.ymax);
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ max_x = MAX2(max_x, area->totrct.xmax);
+ max_y = MAX2(max_y, area->totrct.ymax);
}
r_scale[0] = (size_x * asp[0]) / max_x;
r_scale[1] = (size_y * asp[1]) / max_y;
@@ -566,12 +566,12 @@ static void screen_preview_draw_areas(const bScreen *screen,
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(col);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
rctf rect = {
- .xmin = sa->totrct.xmin * scale[0] + ofs_h,
- .xmax = sa->totrct.xmax * scale[0] - ofs_h,
- .ymin = sa->totrct.ymin * scale[1] + ofs_h,
- .ymax = sa->totrct.ymax * scale[1] - ofs_h,
+ .xmin = area->totrct.xmin * scale[0] + ofs_h,
+ .xmax = area->totrct.xmax * scale[0] - ofs_h,
+ .ymin = area->totrct.ymin * scale[1] + ofs_h,
+ .ymax = area->totrct.ymax * scale[1] - ofs_h,
};
immBegin(GPU_PRIM_TRI_FAN, 4);
@@ -608,7 +608,7 @@ static void screen_preview_draw(const bScreen *screen, int size_x, int size_y)
/**
* Render the preview for a screen layout in \a screen.
*/
-void ED_screen_preview_render(const bScreen *screen, int size_x, int size_y, unsigned int *r_rect)
+void ED_screen_preview_render(const bScreen *screen, int size_x, int size_y, uint *r_rect)
{
char err_out[256] = "unknown";
GPUOffScreen *offscreen = GPU_offscreen_create(size_x, size_y, 0, true, false, err_out);
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 0151a0fcb0d..8608c18c988 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -70,19 +70,19 @@ static ScrArea *screen_addarea_ex(ScrAreaMap *area_map,
ScrVert *bottom_right,
short spacetype)
{
- ScrArea *sa = MEM_callocN(sizeof(ScrArea), "addscrarea");
+ ScrArea *area = MEM_callocN(sizeof(ScrArea), "addscrarea");
- sa->v1 = bottom_left;
- sa->v2 = top_left;
- sa->v3 = top_right;
- sa->v4 = bottom_right;
- sa->spacetype = spacetype;
+ area->v1 = bottom_left;
+ area->v2 = top_left;
+ area->v3 = top_right;
+ area->v4 = bottom_right;
+ area->spacetype = spacetype;
- BLI_addtail(&area_map->areabase, sa);
+ BLI_addtail(&area_map->areabase, area);
- return sa;
+ return area;
}
-static ScrArea *screen_addarea(bScreen *sc,
+static ScrArea *screen_addarea(bScreen *screen,
ScrVert *left_bottom,
ScrVert *left_top,
ScrVert *right_top,
@@ -90,34 +90,35 @@ static ScrArea *screen_addarea(bScreen *sc,
short spacetype)
{
return screen_addarea_ex(
- AREAMAP_FROM_SCREEN(sc), left_bottom, left_top, right_top, right_bottom, spacetype);
+ AREAMAP_FROM_SCREEN(screen), left_bottom, left_top, right_top, right_bottom, spacetype);
}
-static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa)
+static void screen_delarea(bContext *C, bScreen *screen, ScrArea *area)
{
- ED_area_exit(C, sa);
+ ED_area_exit(C, area);
- BKE_screen_area_free(sa);
+ BKE_screen_area_free(area);
- BLI_remlink(&sc->areabase, sa);
- MEM_freeN(sa);
+ BLI_remlink(&screen->areabase, area);
+ MEM_freeN(area);
}
-ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
+ScrArea *area_split(
+ const wmWindow *win, bScreen *screen, ScrArea *area, char dir, float fac, int merge)
{
ScrArea *newa = NULL;
ScrVert *sv1, *sv2;
short split;
rcti window_rect;
- if (sa == NULL) {
+ if (area == NULL) {
return NULL;
}
WM_window_rect_calc(win, &window_rect);
- split = screen_geom_find_area_split_point(sa, &window_rect, dir, fac);
+ split = screen_geom_find_area_split_point(area, &window_rect, dir, fac);
if (split == 0) {
return NULL;
}
@@ -128,73 +129,73 @@ ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, flo
if (dir == 'h') {
/* new vertices */
- sv1 = screen_geom_vertex_add(sc, sa->v1->vec.x, split);
- sv2 = screen_geom_vertex_add(sc, sa->v4->vec.x, split);
+ sv1 = screen_geom_vertex_add(screen, area->v1->vec.x, split);
+ sv2 = screen_geom_vertex_add(screen, area->v4->vec.x, split);
/* new edges */
- screen_geom_edge_add(sc, sa->v1, sv1);
- screen_geom_edge_add(sc, sv1, sa->v2);
- screen_geom_edge_add(sc, sa->v3, sv2);
- screen_geom_edge_add(sc, sv2, sa->v4);
- screen_geom_edge_add(sc, sv1, sv2);
+ screen_geom_edge_add(screen, area->v1, sv1);
+ screen_geom_edge_add(screen, sv1, area->v2);
+ screen_geom_edge_add(screen, area->v3, sv2);
+ screen_geom_edge_add(screen, sv2, area->v4);
+ screen_geom_edge_add(screen, sv1, sv2);
if (fac > 0.5f) {
/* new areas: top */
- newa = screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->spacetype);
+ newa = screen_addarea(screen, sv1, area->v2, area->v3, sv2, area->spacetype);
/* area below */
- sa->v2 = sv1;
- sa->v3 = sv2;
+ area->v2 = sv1;
+ area->v3 = sv2;
}
else {
/* new areas: bottom */
- newa = screen_addarea(sc, sa->v1, sv1, sv2, sa->v4, sa->spacetype);
+ newa = screen_addarea(screen, area->v1, sv1, sv2, area->v4, area->spacetype);
/* area above */
- sa->v1 = sv1;
- sa->v4 = sv2;
+ area->v1 = sv1;
+ area->v4 = sv2;
}
- ED_area_data_copy(newa, sa, true);
+ ED_area_data_copy(newa, area, true);
}
else {
/* new vertices */
- sv1 = screen_geom_vertex_add(sc, split, sa->v1->vec.y);
- sv2 = screen_geom_vertex_add(sc, split, sa->v2->vec.y);
+ sv1 = screen_geom_vertex_add(screen, split, area->v1->vec.y);
+ sv2 = screen_geom_vertex_add(screen, split, area->v2->vec.y);
/* new edges */
- screen_geom_edge_add(sc, sa->v1, sv1);
- screen_geom_edge_add(sc, sv1, sa->v4);
- screen_geom_edge_add(sc, sa->v2, sv2);
- screen_geom_edge_add(sc, sv2, sa->v3);
- screen_geom_edge_add(sc, sv1, sv2);
+ screen_geom_edge_add(screen, area->v1, sv1);
+ screen_geom_edge_add(screen, sv1, area->v4);
+ screen_geom_edge_add(screen, area->v2, sv2);
+ screen_geom_edge_add(screen, sv2, area->v3);
+ screen_geom_edge_add(screen, sv1, sv2);
if (fac > 0.5f) {
/* new areas: right */
- newa = screen_addarea(sc, sv1, sv2, sa->v3, sa->v4, sa->spacetype);
+ newa = screen_addarea(screen, sv1, sv2, area->v3, area->v4, area->spacetype);
/* area left */
- sa->v3 = sv2;
- sa->v4 = sv1;
+ area->v3 = sv2;
+ area->v4 = sv1;
}
else {
/* new areas: left */
- newa = screen_addarea(sc, sa->v1, sa->v2, sv2, sv1, sa->spacetype);
+ newa = screen_addarea(screen, area->v1, area->v2, sv2, sv1, area->spacetype);
/* area right */
- sa->v1 = sv1;
- sa->v2 = sv2;
+ area->v1 = sv1;
+ area->v2 = sv2;
}
- ED_area_data_copy(newa, sa, true);
+ ED_area_data_copy(newa, area, true);
}
/* remove double vertices en edges */
if (merge) {
- BKE_screen_remove_double_scrverts(sc);
+ BKE_screen_remove_double_scrverts(screen);
}
- BKE_screen_remove_double_scredges(sc);
- BKE_screen_remove_unused_scredges(sc);
+ BKE_screen_remove_double_scredges(screen);
+ BKE_screen_remove_unused_scredges(screen);
return newa;
}
@@ -204,34 +205,34 @@ ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, flo
*/
bScreen *screen_add(Main *bmain, const char *name, const rcti *rect)
{
- bScreen *sc;
+ bScreen *screen;
ScrVert *sv1, *sv2, *sv3, *sv4;
- sc = BKE_libblock_alloc(bmain, ID_SCR, name, 0);
- sc->do_refresh = true;
- sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
+ screen = BKE_libblock_alloc(bmain, ID_SCR, name, 0);
+ screen->do_refresh = true;
+ screen->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
- sv1 = screen_geom_vertex_add(sc, rect->xmin, rect->ymin);
- sv2 = screen_geom_vertex_add(sc, rect->xmin, rect->ymax - 1);
- sv3 = screen_geom_vertex_add(sc, rect->xmax - 1, rect->ymax - 1);
- sv4 = screen_geom_vertex_add(sc, rect->xmax - 1, rect->ymin);
+ sv1 = screen_geom_vertex_add(screen, rect->xmin, rect->ymin);
+ sv2 = screen_geom_vertex_add(screen, rect->xmin, rect->ymax - 1);
+ sv3 = screen_geom_vertex_add(screen, rect->xmax - 1, rect->ymax - 1);
+ sv4 = screen_geom_vertex_add(screen, rect->xmax - 1, rect->ymin);
- screen_geom_edge_add(sc, sv1, sv2);
- screen_geom_edge_add(sc, sv2, sv3);
- screen_geom_edge_add(sc, sv3, sv4);
- screen_geom_edge_add(sc, sv4, sv1);
+ screen_geom_edge_add(screen, sv1, sv2);
+ screen_geom_edge_add(screen, sv2, sv3);
+ screen_geom_edge_add(screen, sv3, sv4);
+ screen_geom_edge_add(screen, sv4, sv1);
/* dummy type, no spacedata */
- screen_addarea(sc, sv1, sv2, sv3, sv4, SPACE_EMPTY);
+ screen_addarea(screen, sv1, sv2, sv3, sv4, SPACE_EMPTY);
- return sc;
+ return screen;
}
void screen_data_copy(bScreen *to, bScreen *from)
{
ScrVert *s1, *s2;
ScrEdge *se;
- ScrArea *sa, *saf;
+ ScrArea *area, *saf;
/* free contents of 'to', is from blenkernel screen.c */
BKE_screen_free(to);
@@ -255,18 +256,18 @@ void screen_data_copy(bScreen *to, bScreen *from)
}
saf = from->areabase.first;
- for (sa = to->areabase.first; sa; sa = sa->next, saf = saf->next) {
- sa->v1 = sa->v1->newv;
- sa->v2 = sa->v2->newv;
- sa->v3 = sa->v3->newv;
- sa->v4 = sa->v4->newv;
+ for (area = to->areabase.first; area; area = area->next, saf = saf->next) {
+ area->v1 = area->v1->newv;
+ area->v2 = area->v2->newv;
+ area->v3 = area->v3->newv;
+ area->v4 = area->v4->newv;
- BLI_listbase_clear(&sa->spacedata);
- BLI_listbase_clear(&sa->regionbase);
- BLI_listbase_clear(&sa->actionzones);
- BLI_listbase_clear(&sa->handlers);
+ BLI_listbase_clear(&area->spacedata);
+ BLI_listbase_clear(&area->regionbase);
+ BLI_listbase_clear(&area->actionzones);
+ BLI_listbase_clear(&area->handlers);
- ED_area_data_copy(sa, saf, true);
+ ED_area_data_copy(area, saf, true);
}
/* put at zero (needed?) */
@@ -285,19 +286,19 @@ void screen_new_activate_prepare(const wmWindow *win, bScreen *screen_new)
screen_new->do_draw = true;
}
-/* with sa as center, sb is located at: 0=W, 1=N, 2=E, 3=S */
+/* with area as center, sb is located at: 0=W, 1=N, 2=E, 3=S */
/* -1 = not valid check */
/* used with join operator */
-int area_getorientation(ScrArea *sa, ScrArea *sb)
+int area_getorientation(ScrArea *area, ScrArea *sb)
{
- if (sa == NULL || sb == NULL) {
+ if (area == NULL || sb == NULL) {
return -1;
}
- ScrVert *saBL = sa->v1;
- ScrVert *saTL = sa->v2;
- ScrVert *saTR = sa->v3;
- ScrVert *saBR = sa->v4;
+ ScrVert *saBL = area->v1;
+ ScrVert *saTL = area->v2;
+ ScrVert *saTR = area->v3;
+ ScrVert *saBR = area->v4;
ScrVert *sbBL = sb->v1;
ScrVert *sbTL = sb->v2;
@@ -306,25 +307,26 @@ int area_getorientation(ScrArea *sa, ScrArea *sb)
int tolerance = U.pixelsize * 4;
- if (saBL->vec.x == sbBR->vec.x && saTL->vec.x == sbTR->vec.x) { /* sa to right of sb = W */
+ if (saBL->vec.x == sbBR->vec.x && saTL->vec.x == sbTR->vec.x) { /* area to right of sb = W */
if ((abs(saBL->vec.y - sbBR->vec.y) <= tolerance) &&
(abs(saTL->vec.y - sbTR->vec.y) <= tolerance)) {
return 0;
}
}
- else if (saTL->vec.y == sbBL->vec.y && saTR->vec.y == sbBR->vec.y) { /* sa to bottom of sb = N */
+ else if (saTL->vec.y == sbBL->vec.y &&
+ saTR->vec.y == sbBR->vec.y) { /* area to bottom of sb = N */
if ((abs(saTL->vec.x - sbBL->vec.x) <= tolerance) &&
(abs(saTR->vec.x - sbBR->vec.x) <= tolerance)) {
return 1;
}
}
- else if (saTR->vec.x == sbTL->vec.x && saBR->vec.x == sbBL->vec.x) { /* sa to left of sb = E */
+ else if (saTR->vec.x == sbTL->vec.x && saBR->vec.x == sbBL->vec.x) { /* area to left of sb = E */
if ((abs(saTR->vec.y - sbTL->vec.y) <= tolerance) &&
(abs(saBR->vec.y - sbBL->vec.y) <= tolerance)) {
return 2;
}
}
- else if (saBL->vec.y == sbTL->vec.y && saBR->vec.y == sbTR->vec.y) { /* sa on top of sb = S*/
+ else if (saBL->vec.y == sbTL->vec.y && saBR->vec.y == sbTR->vec.y) { /* area on top of sb = S*/
if ((abs(saBL->vec.x - sbTL->vec.x) <= tolerance) &&
(abs(saBR->vec.x - sbTR->vec.x) <= tolerance)) {
return 3;
@@ -337,7 +339,7 @@ int area_getorientation(ScrArea *sa, ScrArea *sb)
/* Helper function to join 2 areas, it has a return value, 0=failed 1=success
* used by the split, join operators
*/
-int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2)
+int screen_area_join(bContext *C, bScreen *screen, ScrArea *sa1, ScrArea *sa2)
{
int dir = area_getorientation(sa1, sa2);
@@ -365,32 +367,32 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2)
if (dir == 0) { /* sa1 to right of sa2 = W */
sa1->v1 = sa2->v1; /* BL */
sa1->v2 = sa2->v2; /* TL */
- screen_geom_edge_add(scr, sa1->v2, sa1->v3);
- screen_geom_edge_add(scr, sa1->v1, sa1->v4);
+ screen_geom_edge_add(screen, sa1->v2, sa1->v3);
+ screen_geom_edge_add(screen, sa1->v1, sa1->v4);
}
else if (dir == 1) { /* sa1 to bottom of sa2 = N */
sa1->v2 = sa2->v2; /* TL */
sa1->v3 = sa2->v3; /* TR */
- screen_geom_edge_add(scr, sa1->v1, sa1->v2);
- screen_geom_edge_add(scr, sa1->v3, sa1->v4);
+ screen_geom_edge_add(screen, sa1->v1, sa1->v2);
+ screen_geom_edge_add(screen, sa1->v3, sa1->v4);
}
else if (dir == 2) { /* sa1 to left of sa2 = E */
sa1->v3 = sa2->v3; /* TR */
sa1->v4 = sa2->v4; /* BR */
- screen_geom_edge_add(scr, sa1->v2, sa1->v3);
- screen_geom_edge_add(scr, sa1->v1, sa1->v4);
+ screen_geom_edge_add(screen, sa1->v2, sa1->v3);
+ screen_geom_edge_add(screen, sa1->v1, sa1->v4);
}
else if (dir == 3) { /* sa1 on top of sa2 = S */
sa1->v1 = sa2->v1; /* BL */
sa1->v4 = sa2->v4; /* BR */
- screen_geom_edge_add(scr, sa1->v1, sa1->v2);
- screen_geom_edge_add(scr, sa1->v3, sa1->v4);
+ screen_geom_edge_add(screen, sa1->v1, sa1->v2);
+ screen_geom_edge_add(screen, sa1->v3, sa1->v4);
}
- screen_delarea(C, scr, sa2);
- BKE_screen_remove_double_scrverts(scr);
+ screen_delarea(C, screen, sa2);
+ BKE_screen_remove_double_scrverts(screen);
/* Update preview thumbnail */
- BKE_icon_changed(scr->id.icon_id);
+ BKE_icon_changed(screen->id.icon_id);
return 1;
}
@@ -398,12 +400,12 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2)
/* ****************** EXPORTED API TO OTHER MODULES *************************** */
/* screen sets cursor based on active region */
-static void region_cursor_set_ex(wmWindow *win, ScrArea *sa, ARegion *region, bool swin_changed)
+static void region_cursor_set_ex(wmWindow *win, ScrArea *area, ARegion *region, bool swin_changed)
{
BLI_assert(WM_window_get_active_screen(win)->active_region == region);
if (win->tag_cursor_refresh || swin_changed || (region->type && region->type->event_cursor)) {
win->tag_cursor_refresh = false;
- ED_region_cursor_set(win, sa, region);
+ ED_region_cursor_set(win, area, region);
}
}
@@ -411,11 +413,11 @@ static void region_cursor_set(wmWindow *win, bool swin_changed)
{
bScreen *screen = WM_window_get_active_screen(win);
- ED_screen_areas_iter(win, screen, sa)
+ ED_screen_areas_iter(win, screen, area)
{
- for (ARegion *region = sa->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region == screen->active_region) {
- region_cursor_set_ex(win, sa, region, swin_changed);
+ region_cursor_set_ex(win, area, region, swin_changed);
return;
}
}
@@ -522,11 +524,11 @@ void ED_screen_ensure_updated(wmWindowManager *wm, wmWindow *win, bScreen *scree
* Utility to exit and free an area-region. Screen level regions (menus/popups) need to be treated
* slightly differently, see #ui_region_temp_remove().
*/
-void ED_region_remove(bContext *C, ScrArea *sa, ARegion *region)
+void ED_region_remove(bContext *C, ScrArea *area, ARegion *region)
{
ED_region_exit(C, region);
- BKE_area_region_free(sa->type, region);
- BLI_freelinkN(&sa->regionbase, region);
+ BKE_area_region_free(area->type, region);
+ BLI_freelinkN(&area->regionbase, region);
}
/* *********** exit calls are for closing running stuff ******** */
@@ -562,25 +564,25 @@ void ED_region_exit(bContext *C, ARegion *region)
CTX_wm_region_set(C, prevar);
}
-void ED_area_exit(bContext *C, ScrArea *sa)
+void ED_area_exit(bContext *C, ScrArea *area)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
ScrArea *prevsa = CTX_wm_area(C);
ARegion *region;
- if (sa->type && sa->type->exit) {
- sa->type->exit(wm, sa);
+ if (area->type && area->type->exit) {
+ area->type->exit(wm, area);
}
- CTX_wm_area_set(C, sa);
+ CTX_wm_area_set(C, area);
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
ED_region_exit(C, region);
}
- WM_event_remove_handlers(C, &sa->handlers);
- WM_event_modal_handler_area_replace(win, sa, NULL);
+ WM_event_remove_handlers(C, &area->handlers);
+ WM_event_modal_handler_area_replace(win, area, NULL);
CTX_wm_area_set(C, prevsa);
}
@@ -605,15 +607,15 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
screen->active_region = NULL;
- for (ARegion *region = screen->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
ED_region_exit(C, region);
}
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- ED_area_exit(C, sa);
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ ED_area_exit(C, area);
}
/* Don't use ED_screen_areas_iter here, it skips hidden areas. */
- for (ScrArea *sa = window->global_areas.areabase.first; sa; sa = sa->next) {
- ED_area_exit(C, sa);
+ LISTBASE_FOREACH (ScrArea *, area, &window->global_areas.areabase) {
+ ED_area_exit(C, area);
}
/* mark it available for use for other windows */
@@ -636,15 +638,15 @@ static void screen_cursor_set(wmWindow *win, const int xy[2])
{
const bScreen *screen = WM_window_get_active_screen(win);
AZone *az = NULL;
- ScrArea *sa;
+ ScrArea *area;
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- if ((az = ED_area_actionzone_find_xy(sa, xy))) {
+ for (area = screen->areabase.first; area; area = area->next) {
+ if ((az = ED_area_actionzone_find_xy(area, xy))) {
break;
}
}
- if (sa) {
+ if (area) {
if (az->type == AZONE_AREA) {
WM_cursor_set(win, WM_CURSOR_EDIT);
}
@@ -680,63 +682,63 @@ static void screen_cursor_set(wmWindow *win, const int xy[2])
*/
void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
{
- bScreen *scr = WM_window_get_active_screen(win);
- if (scr == NULL) {
+ bScreen *screen = WM_window_get_active_screen(win);
+ if (screen == NULL) {
return;
}
- ScrArea *sa = NULL;
+ ScrArea *area = NULL;
ARegion *region;
- ARegion *ar_prev = scr->active_region;
+ ARegion *region_prev = screen->active_region;
- ED_screen_areas_iter(win, scr, area_iter)
+ ED_screen_areas_iter(win, screen, area_iter)
{
if (xy[0] > area_iter->totrct.xmin && xy[0] < area_iter->totrct.xmax) {
if (xy[1] > area_iter->totrct.ymin && xy[1] < area_iter->totrct.ymax) {
if (ED_area_azones_update(area_iter, xy) == NULL) {
- sa = area_iter;
+ area = area_iter;
break;
}
}
}
}
- if (sa) {
+ if (area) {
/* Make overlap active when mouse over. */
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (ED_region_contains_xy(region, xy)) {
- scr->active_region = region;
+ screen->active_region = region;
break;
}
}
}
else {
- scr->active_region = NULL;
+ screen->active_region = NULL;
}
/* Check for redraw headers. */
- if (ar_prev != scr->active_region) {
+ if (region_prev != screen->active_region) {
- ED_screen_areas_iter(win, scr, area_iter)
+ ED_screen_areas_iter(win, screen, area_iter)
{
bool do_draw = false;
for (region = area_iter->regionbase.first; region; region = region->next) {
/* Call old area's deactivate if assigned. */
- if (region == ar_prev && area_iter->type->deactivate) {
+ if (region == region_prev && area_iter->type->deactivate) {
area_iter->type->deactivate(area_iter);
}
- if (region == ar_prev && region != scr->active_region) {
- wmGizmoMap *gzmap = ar_prev->gizmo_map;
+ if (region == region_prev && region != screen->active_region) {
+ wmGizmoMap *gzmap = region_prev->gizmo_map;
if (gzmap) {
if (WM_gizmo_highlight_set(gzmap, NULL)) {
- ED_region_tag_redraw_no_rebuild(ar_prev);
+ ED_region_tag_redraw_no_rebuild(region_prev);
}
}
}
- if (region == ar_prev || region == scr->active_region) {
+ if (region == region_prev || region == screen->active_region) {
do_draw = true;
}
}
@@ -753,19 +755,19 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
/* Cursors, for time being set always on edges,
* otherwise the active region doesn't switch. */
- if (scr->active_region == NULL) {
+ if (screen->active_region == NULL) {
screen_cursor_set(win, xy);
}
else {
/* Notifier invokes freeing the buttons... causing a bit too much redraws. */
- region_cursor_set_ex(win, sa, scr->active_region, ar_prev != scr->active_region);
+ region_cursor_set_ex(win, area, screen->active_region, region_prev != screen->active_region);
- if (ar_prev != scr->active_region) {
+ if (region_prev != screen->active_region) {
/* This used to be a notifier, but needs to be done immediate
* because it can undo setting the right button as active due
* to delayed notifier handling. */
if (C) {
- UI_screen_free_active_but(C, scr);
+ UI_screen_free_active_but(C, screen);
}
}
}
@@ -774,19 +776,19 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
int ED_screen_area_active(const bContext *C)
{
wmWindow *win = CTX_wm_window(C);
- bScreen *sc = CTX_wm_screen(C);
- ScrArea *sa = CTX_wm_area(C);
+ bScreen *screen = CTX_wm_screen(C);
+ ScrArea *area = CTX_wm_area(C);
- if (win && sc && sa) {
- AZone *az = ED_area_actionzone_find_xy(sa, &win->eventstate->x);
+ if (win && screen && area) {
+ AZone *az = ED_area_actionzone_find_xy(area, &win->eventstate->x);
ARegion *region;
if (az && az->type == AZONE_REGION) {
return 1;
}
- for (region = sa->regionbase.first; region; region = region->next) {
- if (region == sc->active_region) {
+ for (region = area->regionbase.first; region; region = region->next) {
+ if (region == screen->active_region) {
return 1;
}
}
@@ -815,16 +817,16 @@ static ScrArea *screen_area_create_with_geometry(ScrAreaMap *area_map,
return screen_addarea_ex(area_map, bottom_left, top_left, top_right, bottom_right, spacetype);
}
-static void screen_area_set_geometry_rect(ScrArea *sa, const rcti *rect)
+static void screen_area_set_geometry_rect(ScrArea *area, const rcti *rect)
{
- sa->v1->vec.x = rect->xmin;
- sa->v1->vec.y = rect->ymin;
- sa->v2->vec.x = rect->xmin;
- sa->v2->vec.y = rect->ymax;
- sa->v3->vec.x = rect->xmax;
- sa->v3->vec.y = rect->ymax;
- sa->v4->vec.x = rect->xmax;
- sa->v4->vec.y = rect->ymin;
+ area->v1->vec.x = rect->xmin;
+ area->v1->vec.y = rect->ymin;
+ area->v2->vec.x = rect->xmin;
+ area->v2->vec.y = rect->ymax;
+ area->v3->vec.x = rect->xmax;
+ area->v3->vec.y = rect->ymax;
+ area->v4->vec.x = rect->xmax;
+ area->v4->vec.y = rect->ymin;
}
static void screen_global_area_refresh(wmWindow *win,
@@ -910,7 +912,7 @@ void ED_screen_global_areas_sync(wmWindow *win)
screen->flag &= ~SCREEN_COLLAPSE_STATUSBAR;
- for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
if (area->global->cur_fixed_height == area->global->size_min) {
if (area->spacetype == SPACE_STATUSBAR) {
screen->flag |= SCREEN_COLLAPSE_STATUSBAR;
@@ -943,8 +945,8 @@ static bScreen *screen_fullscreen_find_associated_normal_screen(const Main *bmai
for (bScreen *screen_iter = bmain->screens.first; screen_iter;
screen_iter = screen_iter->id.next) {
if ((screen_iter != screen) && ELEM(screen_iter->state, SCREENMAXIMIZED, SCREENFULL)) {
- ScrArea *sa = screen_iter->areabase.first;
- if (sa && sa->full == screen) {
+ ScrArea *area = screen_iter->areabase.first;
+ if (area && area->full == screen) {
return screen_iter;
}
}
@@ -976,8 +978,8 @@ bScreen *screen_change_prepare(
wmTimer *wt = screen_old->animtimer;
/* remove handlers referencing areas in old screen */
- for (ScrArea *sa = screen_old->areabase.first; sa; sa = sa->next) {
- WM_event_remove_area_handler(&win->modalhandlers, sa);
+ LISTBASE_FOREACH (ScrArea *, area, &screen_old->areabase) {
+ WM_event_remove_area_handler(&win->modalhandlers, area);
}
/* we put timer to sleep, so screen_exit has to think there's no timer */
@@ -998,17 +1000,17 @@ bScreen *screen_change_prepare(
return NULL;
}
-void screen_change_update(bContext *C, wmWindow *win, bScreen *sc)
+void screen_change_update(bContext *C, wmWindow *win, bScreen *screen)
{
Scene *scene = WM_window_get_active_scene(win);
WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
- WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, sc);
+ WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, screen);
CTX_wm_window_set(C, win); /* stores C->wm.screen... hrmf */
ED_screen_refresh(CTX_wm_manager(C), win);
- BKE_screen_view3d_scene_sync(sc, scene); /* sync new screen with scene data */
+ BKE_screen_view3d_scene_sync(screen, scene); /* sync new screen with scene data */
WM_event_add_notifier(C, NC_WINDOW, NULL);
WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTSET, layout);
@@ -1024,16 +1026,16 @@ void screen_change_update(bContext *C, wmWindow *win, bScreen *sc)
* \warning Do NOT call in area/region queues!
* \returns if screen changing was successful.
*/
-bool ED_screen_change(bContext *C, bScreen *sc)
+bool ED_screen_change(bContext *C, bScreen *screen)
{
Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
bScreen *screen_old = CTX_wm_screen(C);
- bScreen *screen_new = screen_change_prepare(screen_old, sc, bmain, C, win);
+ bScreen *screen_new = screen_change_prepare(screen_old, screen, bmain, C, win);
if (screen_new) {
WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
- WM_window_set_active_screen(win, workspace, sc);
+ WM_window_set_active_screen(win, workspace, screen);
screen_change_update(C, win, screen_new);
return true;
@@ -1042,21 +1044,24 @@ bool ED_screen_change(bContext *C, bScreen *sc)
return false;
}
-static void screen_set_3dview_camera(Scene *scene, ViewLayer *view_layer, ScrArea *sa, View3D *v3d)
+static void screen_set_3dview_camera(Scene *scene,
+ ViewLayer *view_layer,
+ ScrArea *area,
+ View3D *v3d)
{
/* fix any cameras that are used in the 3d view but not in the scene */
BKE_screen_view3d_sync(v3d, scene);
if (!v3d->camera || !BKE_view_layer_base_find(view_layer, v3d->camera)) {
v3d->camera = BKE_view_layer_camera_find(view_layer);
- // XXX if (sc == curscreen) handle_view3d_lock();
+ // XXX if (screen == curscreen) handle_view3d_lock();
if (!v3d->camera) {
ARegion *region;
ListBase *regionbase;
/* regionbase is in different place depending if space is active */
- if (v3d == sa->spacedata.first) {
- regionbase = &sa->regionbase;
+ if (v3d == area->spacedata.first) {
+ regionbase = &area->regionbase;
}
else {
regionbase = &v3d->regionbase;
@@ -1104,28 +1109,28 @@ void ED_screen_scene_change(bContext *C, wmWindow *win, Scene *scene)
/* Update 3D view cameras. */
const bScreen *screen = WM_window_get_active_screen(win);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
- screen_set_3dview_camera(scene, view_layer, sa, v3d);
+ screen_set_3dview_camera(scene, view_layer, area, v3d);
}
}
}
}
-ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
+ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *area, int type)
{
wmWindow *win = CTX_wm_window(C);
ScrArea *newsa = NULL;
SpaceLink *newsl;
- if (!sa || sa->full == NULL) {
- newsa = ED_screen_state_toggle(C, win, sa, SCREENMAXIMIZED);
+ if (!area || area->full == NULL) {
+ newsa = ED_screen_state_toggle(C, win, area, SCREENMAXIMIZED);
}
if (!newsa) {
- newsa = sa;
+ newsa = area;
}
BLI_assert(newsa);
@@ -1144,40 +1149,40 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
/**
* \a was_prev_temp for the case previous space was a temporary fullscreen as well
*/
-void ED_screen_full_prevspace(bContext *C, ScrArea *sa)
+void ED_screen_full_prevspace(bContext *C, ScrArea *area)
{
- BLI_assert(sa->full);
+ BLI_assert(area->full);
- if (sa->flag & AREA_FLAG_STACKED_FULLSCREEN) {
+ if (area->flag & AREA_FLAG_STACKED_FULLSCREEN) {
/* stacked fullscreen -> only go back to previous area and don't toggle out of fullscreen */
- ED_area_prevspace(C, sa);
+ ED_area_prevspace(C, area);
}
else {
- ED_screen_restore_temp_type(C, sa);
+ ED_screen_restore_temp_type(C, area);
}
}
-void ED_screen_restore_temp_type(bContext *C, ScrArea *sa)
+void ED_screen_restore_temp_type(bContext *C, ScrArea *area)
{
- SpaceLink *sl = sa->spacedata.first;
+ SpaceLink *sl = area->spacedata.first;
/* In case nether functions below run. */
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
if (sl->link_flag & SPACE_FLAG_TYPE_TEMPORARY) {
- ED_area_prevspace(C, sa);
+ ED_area_prevspace(C, area);
}
- if (sa->full) {
- ED_screen_state_toggle(C, CTX_wm_window(C), sa, SCREENMAXIMIZED);
+ if (area->full) {
+ ED_screen_state_toggle(C, CTX_wm_window(C), area, SCREENMAXIMIZED);
}
}
/* restore a screen / area back to default operation, after temp fullscreen modes */
-void ED_screen_full_restore(bContext *C, ScrArea *sa)
+void ED_screen_full_restore(bContext *C, ScrArea *area)
{
wmWindow *win = CTX_wm_window(C);
- SpaceLink *sl = sa->spacedata.first;
+ SpaceLink *sl = area->spacedata.first;
bScreen *screen = CTX_wm_screen(C);
short state = (screen ? screen->state : SCREENMAXIMIZED);
@@ -1186,37 +1191,37 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa)
if (sl->next) {
if (sl->link_flag & SPACE_FLAG_TYPE_TEMPORARY) {
- ED_screen_full_prevspace(C, sa);
+ ED_screen_full_prevspace(C, area);
}
else {
- ED_screen_state_toggle(C, win, sa, state);
+ ED_screen_state_toggle(C, win, area, state);
}
- /* warning: 'sa' may be freed */
+ /* warning: 'area' may be freed */
}
/* otherwise just tile the area again */
else {
- ED_screen_state_toggle(C, win, sa, state);
+ ED_screen_state_toggle(C, win, area, state);
}
}
/**
* this function toggles: if area is maximized/full then the parent will be restored
*
- * \warning \a sa may be freed.
+ * \warning \a area may be freed.
*/
-ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const short state)
+ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const short state)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
WorkSpace *workspace = WM_window_get_active_workspace(win);
- bScreen *sc, *oldscreen;
+ bScreen *screen, *oldscreen;
ARegion *region;
- if (sa) {
+ if (area) {
/* ensure we don't have a button active anymore, can crash when
* switching screens with tooltip open because region and tooltip
* are no longer in the same screen */
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
UI_blocklist_free(C, &region->uiblocks);
if (region->regiontimer) {
@@ -1226,25 +1231,25 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
}
/* prevent hanging status prints */
- ED_area_status_text(sa, NULL);
+ ED_area_status_text(area, NULL);
ED_workspace_status_text(C, NULL);
}
- if (sa && sa->full) {
+ if (area && area->full) {
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
/* restoring back to SCREENNORMAL */
- sc = sa->full; /* the old screen to restore */
+ screen = area->full; /* the old screen to restore */
oldscreen = WM_window_get_active_screen(win); /* the one disappearing */
- BLI_assert(BKE_workspace_layout_screen_get(layout_old) != sc);
+ BLI_assert(BKE_workspace_layout_screen_get(layout_old) != screen);
BLI_assert(BKE_workspace_layout_screen_get(layout_old)->state != SCREENNORMAL);
- sc->state = SCREENNORMAL;
- sc->flag = oldscreen->flag;
+ screen->state = SCREENNORMAL;
+ screen->flag = oldscreen->flag;
/* find old area to restore from */
ScrArea *fullsa = NULL;
- for (ScrArea *old = sc->areabase.first; old; old = old->next) {
+ LISTBASE_FOREACH (ScrArea *, old, &screen->areabase) {
/* area to restore from is always first */
if (old->full && !fullsa) {
fullsa = old;
@@ -1254,7 +1259,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
old->full = NULL;
}
- sa->full = NULL;
+ area->full = NULL;
if (fullsa == NULL) {
if (G.debug & G_DEBUG) {
@@ -1265,23 +1270,22 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
if (state == SCREENFULL) {
/* unhide global areas */
- for (ScrArea *glob_area = win->global_areas.areabase.first; glob_area;
- glob_area = glob_area->next) {
+ LISTBASE_FOREACH (ScrArea *, glob_area, &win->global_areas.areabase) {
glob_area->global->flag &= ~GLOBAL_AREA_IS_HIDDEN;
}
/* restore the old side panels/header visibility */
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
region->flag = region->flagfullscreen;
}
}
- ED_area_data_swap(fullsa, sa);
+ ED_area_data_swap(fullsa, area);
/* animtimer back */
- sc->animtimer = oldscreen->animtimer;
+ screen->animtimer = oldscreen->animtimer;
oldscreen->animtimer = NULL;
- ED_screen_change(C, sc);
+ ED_screen_change(C, screen);
BKE_workspace_layout_remove(CTX_data_main(C), workspace, layout_old);
@@ -1289,7 +1293,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
* screen handling as it uses the area coords which aren't updated yet.
* Without doing so, the screen handling gets wrong area coords,
* which in worst case can lead to crashes (see T43139) */
- sc->skip_handling = true;
+ screen->skip_handling = true;
}
else {
/* change from SCREENNORMAL to new state */
@@ -1306,32 +1310,31 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
layout_new = ED_workspace_layout_add(bmain, workspace, win, newname);
- sc = BKE_workspace_layout_screen_get(layout_new);
- sc->state = state;
- sc->redraws_flag = oldscreen->redraws_flag;
- sc->temp = oldscreen->temp;
- sc->flag = oldscreen->flag;
+ screen = BKE_workspace_layout_screen_get(layout_new);
+ screen->state = state;
+ screen->redraws_flag = oldscreen->redraws_flag;
+ screen->temp = oldscreen->temp;
+ screen->flag = oldscreen->flag;
/* timer */
- sc->animtimer = oldscreen->animtimer;
+ screen->animtimer = oldscreen->animtimer;
oldscreen->animtimer = NULL;
/* use random area when we have no active one, e.g. when the
* mouse is outside of the window and we open a file browser */
- if (!sa || sa->global) {
- sa = oldscreen->areabase.first;
+ if (!area || area->global) {
+ area = oldscreen->areabase.first;
}
- newa = (ScrArea *)sc->areabase.first;
+ newa = (ScrArea *)screen->areabase.first;
/* copy area */
- ED_area_data_swap(newa, sa);
- newa->flag = sa->flag; /* mostly for AREA_FLAG_WASFULLSCREEN */
+ ED_area_data_swap(newa, area);
+ newa->flag = area->flag; /* mostly for AREA_FLAG_WASFULLSCREEN */
if (state == SCREENFULL) {
/* temporarily hide global areas */
- for (ScrArea *glob_area = win->global_areas.areabase.first; glob_area;
- glob_area = glob_area->next) {
+ LISTBASE_FOREACH (ScrArea *, glob_area, &win->global_areas.areabase) {
glob_area->global->flag |= GLOBAL_AREA_IS_HIDDEN;
}
/* temporarily hide the side panels/header */
@@ -1351,16 +1354,16 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
}
}
- sa->full = oldscreen;
+ area->full = oldscreen;
newa->full = oldscreen;
- ED_screen_change(C, sc);
+ ED_screen_change(C, screen);
}
/* XXX bad code: setscreen() ends with first area active. fullscreen render assumes this too */
- CTX_wm_area_set(C, sc->areabase.first);
+ CTX_wm_area_set(C, screen->areabase.first);
- return sc->areabase.first;
+ return screen->areabase.first;
}
/**
@@ -1381,35 +1384,35 @@ ScrArea *ED_screen_temp_space_open(bContext *C,
int display_type,
bool dialog)
{
- ScrArea *sa = NULL;
+ ScrArea *area = NULL;
switch (display_type) {
case USER_TEMP_SPACE_DISPLAY_WINDOW:
if (WM_window_open_temp(C, title, x, y, sizex, sizey, (int)space_type, dialog)) {
- sa = CTX_wm_area(C);
+ area = CTX_wm_area(C);
}
break;
case USER_TEMP_SPACE_DISPLAY_FULLSCREEN: {
- ScrArea *ctx_sa = CTX_wm_area(C);
+ ScrArea *ctx_area = CTX_wm_area(C);
- if (ctx_sa != NULL && ctx_sa->full) {
- sa = ctx_sa;
- ED_area_newspace(C, ctx_sa, space_type, true);
- sa->flag |= AREA_FLAG_STACKED_FULLSCREEN;
- ((SpaceLink *)sa->spacedata.first)->link_flag |= SPACE_FLAG_TYPE_TEMPORARY;
+ if (ctx_area != NULL && ctx_area->full) {
+ area = ctx_area;
+ ED_area_newspace(C, ctx_area, space_type, true);
+ area->flag |= AREA_FLAG_STACKED_FULLSCREEN;
+ ((SpaceLink *)area->spacedata.first)->link_flag |= SPACE_FLAG_TYPE_TEMPORARY;
}
- else if (ctx_sa != NULL && ctx_sa->spacetype == space_type) {
- sa = ED_screen_state_toggle(C, CTX_wm_window(C), ctx_sa, SCREENMAXIMIZED);
+ else if (ctx_area != NULL && ctx_area->spacetype == space_type) {
+ area = ED_screen_state_toggle(C, CTX_wm_window(C), ctx_area, SCREENMAXIMIZED);
}
else {
- sa = ED_screen_full_newspace(C, ctx_sa, (int)space_type);
- ((SpaceLink *)sa->spacedata.first)->link_flag |= SPACE_FLAG_TYPE_TEMPORARY;
+ area = ED_screen_full_newspace(C, ctx_area, (int)space_type);
+ ((SpaceLink *)area->spacedata.first)->link_flag |= SPACE_FLAG_TYPE_TEMPORARY;
}
break;
}
}
- return sa;
+ return area;
}
/* update frame rate info for viewport drawing */
@@ -1487,12 +1490,12 @@ void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable)
sad->flag |= (enable < 0) ? ANIMPLAY_FLAG_REVERSE : 0;
sad->flag |= (sync == 0) ? ANIMPLAY_FLAG_NO_SYNC : (sync == 1) ? ANIMPLAY_FLAG_SYNC : 0;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
char spacetype = -1;
- if (sa) {
- spacetype = sa->spacetype;
+ if (area) {
+ spacetype = area->spacetype;
}
sad->from_anim_edit = (ELEM(spacetype, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA));
@@ -1508,13 +1511,13 @@ void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable)
static ARegion *time_top_left_3dwindow(bScreen *screen)
{
ARegion *aret = NULL;
- ScrArea *sa;
+ ScrArea *area;
int min = 10000;
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->spacetype == SPACE_VIEW3D) {
+ for (area = screen->areabase.first; area; area = area->next) {
+ if (area->spacetype == SPACE_VIEW3D) {
ARegion *region;
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW) {
if (region->winrct.xmin - region->winrct.ymin < min) {
aret = region;
@@ -1552,11 +1555,11 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
#ifdef DURIAN_CAMERA_SWITCH
void *camera = BKE_scene_camera_switch_find(scene);
if (camera && scene->camera != camera) {
- bScreen *sc;
+ bScreen *screen;
scene->camera = camera;
/* are there cameras in the views that are not in the scene? */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- BKE_screen_view3d_scene_sync(sc, scene);
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ BKE_screen_view3d_scene_sync(screen, scene);
}
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
}
@@ -1573,11 +1576,11 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
*/
bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
{
- ScrArea *sa;
+ ScrArea *area;
const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- switch (sa->spacetype) {
+ for (area = screen->areabase.first; area; area = area->next) {
+ switch (area->spacetype) {
case SPACE_VIEW3D: {
View3D *v3d;
@@ -1585,10 +1588,10 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
continue;
}
- v3d = sa->spacedata.first;
+ v3d = area->spacedata.first;
if (v3d->camera && v3d->stereo3d_camera == STEREO_3D_ID) {
ARegion *region;
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiondata && region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
if (rv3d->persp == RV3D_CAMOB) {
@@ -1604,7 +1607,7 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
/* images should always show in stereo, even if
* the file doesn't have views enabled */
- sima = sa->spacedata.first;
+ sima = area->spacedata.first;
if (sima->image && BKE_image_is_stereo(sima->image) &&
(sima->iuser.flag & IMA_SHOW_STEREO)) {
return true;
@@ -1618,7 +1621,7 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
continue;
}
- snode = sa->spacedata.first;
+ snode = area->spacedata.first;
if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) {
return true;
}
@@ -1631,7 +1634,7 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
continue;
}
- sseq = sa->spacedata.first;
+ sseq = area->spacedata.first;
if (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW)) {
return true;
}
@@ -1657,7 +1660,7 @@ Scene *ED_screen_scene_find_with_window(const bScreen *screen,
const wmWindowManager *wm,
struct wmWindow **r_window)
{
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (WM_window_get_active_screen(win) == screen) {
if (r_window) {
*r_window = win;
@@ -1675,16 +1678,16 @@ ScrArea *ED_screen_area_find_with_spacedata(const bScreen *screen,
const bool only_visible)
{
if (only_visible) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->spacedata.first == sl) {
- return sa;
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ if (area->spacedata.first == sl) {
+ return area;
}
}
}
else {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- if (BLI_findindex(&sa->spacedata, sl) != -1) {
- return sa;
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ if (BLI_findindex(&area->spacedata, sl) != -1) {
+ return area;
}
}
}
@@ -1698,7 +1701,7 @@ Scene *ED_screen_scene_find(const bScreen *screen, const wmWindowManager *wm)
wmWindow *ED_screen_window_find(const bScreen *screen, const wmWindowManager *wm)
{
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (WM_window_get_active_screen(win) == screen) {
return win;
}
diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c
index 25855382307..4069795657e 100644
--- a/source/blender/editors/screen/screen_geometry.c
+++ b/source/blender/editors/screen/screen_geometry.c
@@ -57,9 +57,9 @@ ScrVert *screen_geom_vertex_add_ex(ScrAreaMap *area_map, short x, short y)
BLI_addtail(&area_map->vertbase, sv);
return sv;
}
-ScrVert *screen_geom_vertex_add(bScreen *sc, short x, short y)
+ScrVert *screen_geom_vertex_add(bScreen *screen, short x, short y)
{
- return screen_geom_vertex_add_ex(AREAMAP_FROM_SCREEN(sc), x, y);
+ return screen_geom_vertex_add_ex(AREAMAP_FROM_SCREEN(screen), x, y);
}
ScrEdge *screen_geom_edge_add_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2)
@@ -73,9 +73,9 @@ ScrEdge *screen_geom_edge_add_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2)
BLI_addtail(&area_map->edgebase, se);
return se;
}
-ScrEdge *screen_geom_edge_add(bScreen *sc, ScrVert *v1, ScrVert *v2)
+ScrEdge *screen_geom_edge_add(bScreen *screen, ScrVert *v1, ScrVert *v2)
{
- return screen_geom_edge_add_ex(AREAMAP_FROM_SCREEN(sc), v1, v2);
+ return screen_geom_edge_add_ex(AREAMAP_FROM_SCREEN(screen), v1, v2);
}
bool screen_geom_edge_is_horizontal(ScrEdge *se)
@@ -96,7 +96,7 @@ ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map,
CLAMP_MIN(safety, 2);
- for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) {
+ LISTBASE_FOREACH (ScrEdge *, se, &area_map->edgebase) {
if (screen_geom_edge_is_horizontal(se)) {
if ((se->v1->vec.y > bounds_rect->ymin) && (se->v1->vec.y < (bounds_rect->ymax - 1))) {
short min, max;
@@ -153,7 +153,7 @@ ScrEdge *screen_geom_find_active_scredge(const wmWindow *win,
* * Ensure areas have a minimum height.
* * Correctly set global areas to their fixed height.
*/
-void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
+void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen)
{
rcti window_rect, screen_rect;
@@ -163,7 +163,6 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
const int screen_size_x = BLI_rcti_size_x(&screen_rect);
const int screen_size_y = BLI_rcti_size_y(&screen_rect);
ScrVert *sv = NULL;
- ScrArea *sa;
int screen_size_x_prev, screen_size_y_prev;
float min[2], max[2];
@@ -171,7 +170,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
min[0] = min[1] = 20000.0f;
max[0] = max[1] = 0.0f;
- for (sv = sc->vertbase.first; sv; sv = sv->next) {
+ for (sv = screen->vertbase.first; sv; sv = sv->next) {
const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y};
minmax_v2v2_v2(min, max, fv);
}
@@ -184,7 +183,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
const float facy = ((float)screen_size_y - 1) / ((float)screen_size_y_prev - 1);
/* make sure it fits! */
- for (sv = sc->vertbase.first; sv; sv = sv->next) {
+ for (sv = screen->vertbase.first; sv; sv = sv->next) {
sv->vec.x = screen_rect.xmin + round_fl_to_short((sv->vec.x - min[0]) * facx);
CLAMP(sv->vec.x, screen_rect.xmin, screen_rect.xmax - 1);
@@ -199,19 +198,19 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
if (facy > 1) {
/* Keep timeline small in video edit workspace. */
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- if (sa->spacetype == SPACE_ACTION && sa->v1->vec.y == screen_rect.ymin &&
- screen_geom_area_height(sa) <= headery * facy + 1) {
- ScrEdge *se = BKE_screen_find_edge(sc, sa->v2, sa->v3);
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ if (area->spacetype == SPACE_ACTION && area->v1->vec.y == screen_rect.ymin &&
+ screen_geom_area_height(area) <= headery * facy + 1) {
+ ScrEdge *se = BKE_screen_find_edge(screen, area->v2, area->v3);
if (se) {
- const int yval = sa->v1->vec.y + headery - 1;
+ const int yval = area->v1->vec.y + headery - 1;
screen_geom_select_connected_edge(win, se);
/* all selected vertices get the right offset */
- for (sv = sc->vertbase.first; sv; sv = sv->next) {
+ for (sv = screen->vertbase.first; sv; sv = sv->next) {
/* if is a collapsed area */
- if (sv != sa->v1 && sv != sa->v4) {
+ if (sv != area->v1 && sv != area->v4) {
if (sv->flag) {
sv->vec.y = yval;
}
@@ -223,19 +222,19 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
}
if (facy < 1) {
/* make each window at least ED_area_headersize() high */
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- if (screen_geom_area_height(sa) < headery) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ if (screen_geom_area_height(area) < headery) {
/* lower edge */
- ScrEdge *se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
- if (se && sa->v1 != sa->v2) {
- const int yval = sa->v2->vec.y - headery + 1;
+ ScrEdge *se = BKE_screen_find_edge(screen, area->v4, area->v1);
+ if (se && area->v1 != area->v2) {
+ const int yval = area->v2->vec.y - headery + 1;
screen_geom_select_connected_edge(win, se);
/* all selected vertices get the right offset */
- for (sv = sc->vertbase.first; sv; sv = sv->next) {
+ for (sv = screen->vertbase.first; sv; sv = sv->next) {
/* if is not a collapsed area */
- if (sv != sa->v2 && sv != sa->v3) {
+ if (sv != area->v2 && sv != area->v3) {
if (sv->flag) {
sv->vec.y = yval;
}
@@ -249,7 +248,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
/* Global areas have a fixed size that only changes with the DPI.
* Here we ensure that exactly this size is set. */
- for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
if (area->global->flag & GLOBAL_AREA_IS_HIDDEN) {
continue;
}
@@ -284,14 +283,14 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
/**
* \return 0 if no split is possible, otherwise the screen-coordinate at which to split.
*/
-short screen_geom_find_area_split_point(const ScrArea *sa,
+short screen_geom_find_area_split_point(const ScrArea *area,
const rcti *window_rect,
char dir,
float fac)
{
short x, y;
- const int cur_area_width = screen_geom_area_width(sa);
- const int cur_area_height = screen_geom_area_height(sa);
+ const int cur_area_width = screen_geom_area_width(area);
+ const int cur_area_height = screen_geom_area_height(area);
const short area_min_x = AREAMINX;
const short area_min_y = ED_area_headersize();
int area_min;
@@ -308,43 +307,43 @@ short screen_geom_find_area_split_point(const ScrArea *sa,
CLAMP(fac, 0.0f, 1.0f);
if (dir == 'h') {
- y = sa->v1->vec.y + round_fl_to_short(fac * cur_area_height);
+ y = area->v1->vec.y + round_fl_to_short(fac * cur_area_height);
area_min = area_min_y;
- if (sa->v1->vec.y > window_rect->ymin) {
+ if (area->v1->vec.y > window_rect->ymin) {
area_min += U.pixelsize;
}
- if (sa->v2->vec.y < (window_rect->ymax - 1)) {
+ if (area->v2->vec.y < (window_rect->ymax - 1)) {
area_min += U.pixelsize;
}
- if (y - sa->v1->vec.y < area_min) {
- y = sa->v1->vec.y + area_min;
+ if (y - area->v1->vec.y < area_min) {
+ y = area->v1->vec.y + area_min;
}
- else if (sa->v2->vec.y - y < area_min) {
- y = sa->v2->vec.y - area_min;
+ else if (area->v2->vec.y - y < area_min) {
+ y = area->v2->vec.y - area_min;
}
return y;
}
else {
- x = sa->v1->vec.x + round_fl_to_short(fac * cur_area_width);
+ x = area->v1->vec.x + round_fl_to_short(fac * cur_area_width);
area_min = area_min_x;
- if (sa->v1->vec.x > window_rect->xmin) {
+ if (area->v1->vec.x > window_rect->xmin) {
area_min += U.pixelsize;
}
- if (sa->v4->vec.x < (window_rect->xmax - 1)) {
+ if (area->v4->vec.x < (window_rect->xmax - 1)) {
area_min += U.pixelsize;
}
- if (x - sa->v1->vec.x < area_min) {
- x = sa->v1->vec.x + area_min;
+ if (x - area->v1->vec.x < area_min) {
+ x = area->v1->vec.x + area_min;
}
- else if (sa->v4->vec.x - x < area_min) {
- x = sa->v4->vec.x - area_min;
+ else if (area->v4->vec.x - x < area_min) {
+ x = area->v4->vec.x - area_min;
}
return x;
@@ -356,7 +355,7 @@ short screen_geom_find_area_split_point(const ScrArea *sa,
*/
void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge)
{
- bScreen *sc = WM_window_get_active_screen(win);
+ bScreen *screen = WM_window_get_active_screen(win);
bool oneselected = true;
char dir;
@@ -370,7 +369,7 @@ void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge)
dir = 'h';
}
- ED_screen_verts_iter(win, sc, sv)
+ ED_screen_verts_iter(win, screen, sv)
{
sv->flag = 0;
}
@@ -380,7 +379,7 @@ void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge)
while (oneselected) {
oneselected = false;
- for (ScrEdge *se = sc->edgebase.first; se; se = se->next) {
+ LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) {
if (se->v1->flag + se->v2->flag == 1) {
if (dir == 'h') {
if (se->v1->vec.y == se->v2->vec.y) {
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index e1a75e51cf2..3dfc147bc73 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -36,7 +36,7 @@ struct bContextDataResult;
#define AZONEFADEOUT (6.5f * U.widget_unit) /* when we start seeing the azone */
/* area.c */
-void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free);
+void ED_area_data_copy(ScrArea *area_dst, ScrArea *area_src, const bool do_free);
void ED_area_data_swap(ScrArea *sa1, ScrArea *sa2);
void region_toggle_hidden(struct bContext *C, ARegion *region, const bool do_fade);
@@ -44,25 +44,26 @@ void region_toggle_hidden(struct bContext *C, ARegion *region, const bool do_fad
bScreen *screen_add(struct Main *bmain, const char *name, const rcti *rect);
void screen_data_copy(bScreen *to, bScreen *from);
void screen_new_activate_prepare(const wmWindow *win, bScreen *screen_new);
-void screen_change_update(struct bContext *C, wmWindow *win, bScreen *sc);
+void screen_change_update(struct bContext *C, wmWindow *win, bScreen *screen);
bScreen *screen_change_prepare(bScreen *screen_old,
bScreen *screen_new,
struct Main *bmain,
struct bContext *C,
wmWindow *win);
-ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac, int merge);
-int screen_area_join(struct bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2);
-int area_getorientation(ScrArea *sa, ScrArea *sb);
+ScrArea *area_split(
+ const wmWindow *win, bScreen *screen, ScrArea *area, char dir, float fac, int merge);
+int screen_area_join(struct bContext *C, bScreen *screen, ScrArea *sa1, ScrArea *sa2);
+int area_getorientation(ScrArea *area, ScrArea *sb);
-struct AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2]);
+struct AZone *ED_area_actionzone_find_xy(ScrArea *area, const int xy[2]);
/* screen_geometry.c */
int screen_geom_area_height(const ScrArea *area);
int screen_geom_area_width(const ScrArea *area);
ScrVert *screen_geom_vertex_add_ex(ScrAreaMap *area_map, short x, short y);
-ScrVert *screen_geom_vertex_add(bScreen *sc, short x, short y);
+ScrVert *screen_geom_vertex_add(bScreen *screen, short x, short y);
ScrEdge *screen_geom_edge_add_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2);
-ScrEdge *screen_geom_edge_add(bScreen *sc, ScrVert *v1, ScrVert *v2);
+ScrEdge *screen_geom_edge_add(bScreen *screen, ScrVert *v1, ScrVert *v2);
bool screen_geom_edge_is_horizontal(ScrEdge *se);
ScrEdge *screen_geom_area_map_find_active_scredge(const struct ScrAreaMap *area_map,
const rcti *bounds_rect,
@@ -72,8 +73,8 @@ ScrEdge *screen_geom_find_active_scredge(const wmWindow *win,
const bScreen *screen,
const int mx,
const int my);
-void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc);
-short screen_geom_find_area_split_point(const ScrArea *sa,
+void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen);
+short screen_geom_find_area_split_point(const ScrArea *area,
const rcti *window_rect,
char dir,
float fac);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index ae8dd829d8d..452984f2333 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -590,20 +590,20 @@ bool ED_operator_editmball(bContext *C)
bool ED_operator_mask(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacedata.first) {
- switch (sa->spacetype) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area && area->spacedata.first) {
+ switch (area->spacetype) {
case SPACE_CLIP: {
- SpaceClip *sc = sa->spacedata.first;
- return ED_space_clip_check_show_maskedit(sc);
+ SpaceClip *screen = area->spacedata.first;
+ return ED_space_clip_check_show_maskedit(screen);
}
case SPACE_SEQ: {
- SpaceSeq *sseq = sa->spacedata.first;
+ SpaceSeq *sseq = area->spacedata.first;
Scene *scene = CTX_data_scene(C);
return ED_space_sequencer_check_show_maskedit(sseq, scene);
}
case SPACE_IMAGE: {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
ViewLayer *view_layer = CTX_data_view_layer(C);
return ED_space_image_check_show_maskedit(sima, view_layer);
}
@@ -681,8 +681,8 @@ static bool actionzone_area_poll(bContext *C)
const int *xy = &win->eventstate->x;
AZone *az;
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (az = sa->actionzones.first; az; az = az->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ for (az = area->actionzones.first; az; az = az->next) {
if (BLI_rcti_isect_pt_v(&az->rect, xy)) {
return 1;
}
@@ -743,11 +743,11 @@ static bool azone_clipped_rect_calc(const AZone *az, rcti *r_rect_clip)
return false;
}
-static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const bool test_only)
+static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const bool test_only)
{
AZone *az = NULL;
- for (az = sa->actionzones.first; az; az = az->next) {
+ for (az = area->actionzones.first; az; az = az->next) {
rcti az_rect_clip;
if (BLI_rcti_isect_pt_v(&az->rect, xy) &&
/* Check clipping if this is clipped */
@@ -798,7 +798,7 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
}
/* XXX force redraw to show/hide the action zone */
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
}
@@ -868,18 +868,18 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
else if (!test_only && !IS_EQF(az->alpha, 0.0f)) {
if (az->type == AZONE_FULLSCREEN) {
az->alpha = 0.0f;
- sa->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE;
- ED_area_tag_redraw_no_rebuild(sa);
+ area->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE;
+ ED_area_tag_redraw_no_rebuild(area);
}
else if (az->type == AZONE_REGION_SCROLL) {
if (az->direction == AZ_SCROLL_VERT) {
az->alpha = az->region->v2d.alpha_vert = 0;
- sa->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE;
+ area->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE;
ED_region_tag_redraw_no_rebuild(az->region);
}
else if (az->direction == AZ_SCROLL_HOR) {
az->alpha = az->region->v2d.alpha_hor = 0;
- sa->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE;
+ area->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE;
ED_region_tag_redraw_no_rebuild(az->region);
}
else {
@@ -893,10 +893,10 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
}
/* Finds an action-zone by position in entire screen so azones can overlap. */
-static AZone *screen_actionzone_find_xy(bScreen *sc, const int xy[2])
+static AZone *screen_actionzone_find_xy(bScreen *screen, const int xy[2])
{
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
- AZone *az = area_actionzone_refresh_xy(sa, xy, true);
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ AZone *az = area_actionzone_refresh_xy(area, xy, true);
if (az != NULL) {
return az;
}
@@ -905,10 +905,10 @@ static AZone *screen_actionzone_find_xy(bScreen *sc, const int xy[2])
}
/* Returns the area that the azone belongs to */
-static ScrArea *screen_actionzone_area(bScreen *sc, const AZone *az)
+static ScrArea *screen_actionzone_area(bScreen *screen, const AZone *az)
{
- for (ScrArea *area = sc->areabase.first; area; area = area->next) {
- for (AZone *zone = area->actionzones.first; zone; zone = zone->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (AZone *, zone, &area->actionzones) {
if (zone == az) {
return area;
}
@@ -917,14 +917,14 @@ static ScrArea *screen_actionzone_area(bScreen *sc, const AZone *az)
return NULL;
}
-AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2])
+AZone *ED_area_actionzone_find_xy(ScrArea *area, const int xy[2])
{
- return area_actionzone_refresh_xy(sa, xy, true);
+ return area_actionzone_refresh_xy(area, xy, true);
}
-AZone *ED_area_azones_update(ScrArea *sa, const int xy[2])
+AZone *ED_area_azones_update(ScrArea *area, const int xy[2])
{
- return area_actionzone_refresh_xy(sa, xy, false);
+ return area_actionzone_refresh_xy(area, xy, false);
}
static void actionzone_exit(wmOperator *op)
@@ -968,8 +968,8 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type)
static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- bScreen *sc = CTX_wm_screen(C);
- AZone *az = screen_actionzone_find_xy(sc, &event->x);
+ bScreen *screen = CTX_wm_screen(C);
+ AZone *az = screen_actionzone_find_xy(screen, &event->x);
sActionzoneData *sad;
/* Quick escape - Scroll azones only hide/unhide the scroll-bars,
@@ -980,7 +980,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* ok we do the action-zone */
sad = op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData");
- sad->sa1 = screen_actionzone_area(sc, az);
+ sad->sa1 = screen_actionzone_area(screen, az);
sad->az = az;
sad->x = event->x;
sad->y = event->y;
@@ -1003,7 +1003,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
sActionzoneData *sad = op->customdata;
switch (event->type) {
@@ -1044,9 +1044,9 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* Have we dragged off the zone and are not on an edge? */
if ((ED_area_actionzone_find_xy(sad->sa1, &event->x) != sad->az) &&
(screen_geom_area_map_find_active_scredge(
- AREAMAP_FROM_SCREEN(sc), &screen_rect, event->x, event->y) == NULL)) {
+ AREAMAP_FROM_SCREEN(screen), &screen_rect, event->x, event->y) == NULL)) {
/* Are we still in same area? */
- if (BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, event->x, event->y) == sad->sa1) {
+ if (BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->x, event->y) == sad->sa1) {
/* Same area, so possible split. */
WM_cursor_set(
win, (ELEM(sad->gesture_dir, 'n', 's')) ? WM_CURSOR_H_SPLIT : WM_CURSOR_V_SPLIT);
@@ -1081,7 +1081,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* gesture is large enough? */
if (is_gesture) {
/* second area, for join when (sa1 != sa2) */
- sad->sa2 = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, event->x, event->y);
+ sad->sa2 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->x, event->y);
/* apply sends event */
actionzone_apply(C, op, sad->az->type);
actionzone_exit(op);
@@ -1136,12 +1136,12 @@ static ScrEdge *screen_area_edge_from_cursor(const bContext *C,
ScrArea **r_sa2)
{
wmWindow *win = CTX_wm_window(C);
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
ScrEdge *actedge;
rcti window_rect;
WM_window_rect_calc(win, &window_rect);
actedge = screen_geom_area_map_find_active_scredge(
- AREAMAP_FROM_SCREEN(sc), &window_rect, cursor[0], cursor[1]);
+ AREAMAP_FROM_SCREEN(screen), &window_rect, cursor[0], cursor[1]);
*r_sa1 = NULL;
*r_sa2 = NULL;
if (actedge == NULL) {
@@ -1150,12 +1150,12 @@ static ScrEdge *screen_area_edge_from_cursor(const bContext *C,
int borderwidth = (4 * UI_DPI_FAC);
ScrArea *sa1, *sa2;
if (screen_geom_edge_is_horizontal(actedge)) {
- sa1 = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, cursor[0], cursor[1] + borderwidth);
- sa2 = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, cursor[0], cursor[1] - borderwidth);
+ sa1 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, cursor[0], cursor[1] + borderwidth);
+ sa2 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, cursor[0], cursor[1] - borderwidth);
}
else {
- sa1 = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, cursor[0] + borderwidth, cursor[1]);
- sa2 = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, cursor[0] - borderwidth, cursor[1]);
+ sa1 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, cursor[0] + borderwidth, cursor[1]);
+ sa2 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, cursor[0] - borderwidth, cursor[1]);
}
bool isGlobal = ((sa1 && ED_area_is_global(sa1)) || (sa2 && ED_area_is_global(sa2)));
if (!isGlobal) {
@@ -1327,12 +1327,12 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
WorkSpaceLayout *layout_new;
bScreen *newsc;
- ScrArea *sa;
+ ScrArea *area;
rcti rect;
win = CTX_wm_window(C);
scene = CTX_data_scene(C);
- sa = CTX_wm_area(C);
+ area = CTX_wm_area(C);
/* XXX hrmf! */
if (event->type == EVT_ACTIONZONE_AREA) {
@@ -1342,11 +1342,11 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_PASS_THROUGH;
}
- sa = sad->sa1;
+ area = sad->sa1;
}
/* adds window to WM */
- rect = sa->totrct;
+ rect = area->totrct;
BLI_rcti_translate(&rect, win->posx, win->posy);
rect.xmax = rect.xmin + BLI_rcti_size_x(&rect) / U.pixelsize;
rect.ymax = rect.ymin + BLI_rcti_size_y(&rect) / U.pixelsize;
@@ -1371,7 +1371,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
WM_window_set_active_layout(newwin, workspace, layout_new);
/* copy area to new screen */
- ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true);
+ ED_area_data_copy((ScrArea *)newsc->areabase.first, area, true);
ED_area_tag_redraw((ScrArea *)newsc->areabase.first);
@@ -1454,8 +1454,12 @@ typedef struct sAreaMoveData {
/* helper call to move area-edge, sets limits
* need window bounds in order to get correct limits */
-static void area_move_set_limits(
- wmWindow *win, bScreen *sc, int dir, int *bigger, int *smaller, bool *use_bigger_smaller_snap)
+static void area_move_set_limits(wmWindow *win,
+ bScreen *screen,
+ int dir,
+ int *bigger,
+ int *smaller,
+ bool *use_bigger_smaller_snap)
{
rcti window_rect;
int areaminy = ED_area_headersize();
@@ -1466,7 +1470,7 @@ static void area_move_set_limits(
if (use_bigger_smaller_snap != NULL) {
*use_bigger_smaller_snap = false;
- for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
int size_min = ED_area_global_min_size_y(area) - 1;
int size_max = ED_area_global_max_size_y(area) - 1;
@@ -1507,25 +1511,25 @@ static void area_move_set_limits(
WM_window_rect_calc(win, &window_rect);
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (dir == 'h') {
int y1;
areamin = areaminy;
- if (sa->v1->vec.y > window_rect.ymin) {
+ if (area->v1->vec.y > window_rect.ymin) {
areamin += U.pixelsize;
}
- if (sa->v2->vec.y < (window_rect.ymax - 1)) {
+ if (area->v2->vec.y < (window_rect.ymax - 1)) {
areamin += U.pixelsize;
}
- y1 = screen_geom_area_height(sa) - areamin;
+ y1 = screen_geom_area_height(area) - areamin;
/* if top or down edge selected, test height */
- if (sa->v1->editflag && sa->v4->editflag) {
+ if (area->v1->editflag && area->v4->editflag) {
*bigger = min_ii(*bigger, y1);
}
- else if (sa->v2->editflag && sa->v3->editflag) {
+ else if (area->v2->editflag && area->v3->editflag) {
*smaller = min_ii(*smaller, y1);
}
}
@@ -1533,20 +1537,20 @@ static void area_move_set_limits(
int x1;
areamin = AREAMINX;
- if (sa->v1->vec.x > window_rect.xmin) {
+ if (area->v1->vec.x > window_rect.xmin) {
areamin += U.pixelsize;
}
- if (sa->v4->vec.x < (window_rect.xmax - 1)) {
+ if (area->v4->vec.x < (window_rect.xmax - 1)) {
areamin += U.pixelsize;
}
- x1 = screen_geom_area_width(sa) - areamin;
+ x1 = screen_geom_area_width(area) - areamin;
/* if left or right edge selected, test width */
- if (sa->v1->editflag && sa->v2->editflag) {
+ if (area->v1->editflag && area->v2->editflag) {
*bigger = min_ii(*bigger, x1);
}
- else if (sa->v3->editflag && sa->v4->editflag) {
+ else if (area->v3->editflag && area->v4->editflag) {
*smaller = min_ii(*smaller, x1);
}
}
@@ -1557,7 +1561,7 @@ static void area_move_set_limits(
/* return 0: init failed */
static int area_move_init(bContext *C, wmOperator *op)
{
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
wmWindow *win = CTX_wm_window(C);
ScrEdge *actedge;
sAreaMoveData *md;
@@ -1568,7 +1572,7 @@ static int area_move_init(bContext *C, wmOperator *op)
y = RNA_int_get(op->ptr, "y");
/* setup */
- actedge = screen_geom_find_active_scredge(win, sc, x, y);
+ actedge = screen_geom_find_active_scredge(win, screen, x, y);
if (actedge == NULL) {
return 0;
}
@@ -1586,20 +1590,20 @@ static int area_move_init(bContext *C, wmOperator *op)
screen_geom_select_connected_edge(win, actedge);
/* now all vertices with 'flag == 1' are the ones that can be moved. Move this to editflag */
- ED_screen_verts_iter(win, sc, v1)
+ ED_screen_verts_iter(win, screen, v1)
{
v1->editflag = v1->flag;
}
bool use_bigger_smaller_snap = false;
- area_move_set_limits(win, sc, md->dir, &md->bigger, &md->smaller, &use_bigger_smaller_snap);
+ area_move_set_limits(win, screen, md->dir, &md->bigger, &md->smaller, &use_bigger_smaller_snap);
md->snap_type = use_bigger_smaller_snap ? SNAP_BIGGER_SMALLER_ONLY : SNAP_AREAGRID;
return 1;
}
-static int area_snap_calc_location(const bScreen *sc,
+static int area_snap_calc_location(const bScreen *screen,
const enum AreaMoveSnapType snap_type,
const int delta,
const int origval,
@@ -1657,13 +1661,13 @@ static int area_snap_calc_location(const bScreen *sc,
}
}
- for (const ScrVert *v1 = sc->vertbase.first; v1; v1 = v1->next) {
+ LISTBASE_FOREACH (const ScrVert *, v1, &screen->vertbase) {
if (!v1->editflag) {
continue;
}
const int v_loc = (&v1->vec.x)[!axis];
- for (const ScrVert *v2 = sc->vertbase.first; v2; v2 = v2->next) {
+ LISTBASE_FOREACH (const ScrVert *, v2, &screen->vertbase) {
if (v2->editflag) {
continue;
}
@@ -1702,7 +1706,7 @@ static void area_move_apply_do(const bContext *C,
const enum AreaMoveSnapType snap_type)
{
wmWindow *win = CTX_wm_window(C);
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
short final_loc = -1;
bool doredraw = false;
@@ -1714,13 +1718,13 @@ static void area_move_apply_do(const bContext *C,
final_loc = origval + delta;
}
else {
- final_loc = area_snap_calc_location(sc, snap_type, delta, origval, dir, bigger, smaller);
+ final_loc = area_snap_calc_location(screen, snap_type, delta, origval, dir, bigger, smaller);
}
BLI_assert(final_loc != -1);
short axis = (dir == 'v') ? 0 : 1;
- ED_screen_verts_iter(win, sc, v1)
+ ED_screen_verts_iter(win, screen, v1)
{
if (v1->editflag) {
short oldval = (&v1->vec.x)[axis];
@@ -1737,29 +1741,29 @@ static void area_move_apply_do(const bContext *C,
/* only redraw if we actually moved a screen vert, for AREAGRID */
if (doredraw) {
bool redraw_all = false;
- ED_screen_areas_iter(win, sc, sa)
+ ED_screen_areas_iter(win, screen, area)
{
- if (sa->v1->editflag || sa->v2->editflag || sa->v3->editflag || sa->v4->editflag) {
- if (ED_area_is_global(sa)) {
+ if (area->v1->editflag || area->v2->editflag || area->v3->editflag || area->v4->editflag) {
+ if (ED_area_is_global(area)) {
/* Snap to minimum or maximum for global areas. */
- int height = round_fl_to_int(screen_geom_area_height(sa) / UI_DPI_FAC);
- if (abs(height - sa->global->size_min) < abs(height - sa->global->size_max)) {
- sa->global->cur_fixed_height = sa->global->size_min;
+ int height = round_fl_to_int(screen_geom_area_height(area) / UI_DPI_FAC);
+ if (abs(height - area->global->size_min) < abs(height - area->global->size_max)) {
+ area->global->cur_fixed_height = area->global->size_min;
}
else {
- sa->global->cur_fixed_height = sa->global->size_max;
+ area->global->cur_fixed_height = area->global->size_max;
}
- sc->do_refresh = true;
+ screen->do_refresh = true;
redraw_all = true;
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
}
if (redraw_all) {
- ED_screen_areas_iter(win, sc, sa)
+ ED_screen_areas_iter(win, screen, area)
{
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
}
@@ -1767,7 +1771,7 @@ static void area_move_apply_do(const bContext *C,
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* redraw everything */
/* Update preview thumbnail */
- BKE_icon_changed(sc->id.icon_id);
+ BKE_icon_changed(screen->id.icon_id);
}
}
@@ -1984,13 +1988,13 @@ static int area_split_menu_init(bContext *C, wmOperator *op)
/* generic init, no UI stuff here, assumes active area */
static int area_split_init(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
sAreaSplitData *sd;
int areaminy = ED_area_headersize();
int dir;
/* required context */
- if (sa == NULL) {
+ if (area == NULL) {
return 0;
}
@@ -1998,10 +2002,10 @@ static int area_split_init(bContext *C, wmOperator *op)
dir = RNA_enum_get(op->ptr, "direction");
/* minimal size */
- if (dir == 'v' && sa->winx < 2 * AREAMINX) {
+ if (dir == 'v' && area->winx < 2 * AREAMINX) {
return 0;
}
- if (dir == 'h' && sa->winy < 2 * areaminy) {
+ if (dir == 'h' && area->winy < 2 * areaminy) {
return 0;
}
@@ -2009,42 +2013,42 @@ static int area_split_init(bContext *C, wmOperator *op)
sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split");
op->customdata = sd;
- sd->sarea = sa;
+ sd->sarea = area;
if (dir == 'v') {
- sd->origmin = sa->v1->vec.x;
- sd->origsize = sa->v4->vec.x - sd->origmin;
+ sd->origmin = area->v1->vec.x;
+ sd->origsize = area->v4->vec.x - sd->origmin;
}
else {
- sd->origmin = sa->v1->vec.y;
- sd->origsize = sa->v2->vec.y - sd->origmin;
+ sd->origmin = area->v1->vec.y;
+ sd->origsize = area->v2->vec.y - sd->origmin;
}
return 1;
}
-/* with sa as center, sb is located at: 0=W, 1=N, 2=E, 3=S */
+/* with area as center, sb is located at: 0=W, 1=N, 2=E, 3=S */
/* used with split operator */
-static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb)
+static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *area, ScrArea *sb)
{
- ScrVert *sav1 = sa->v1;
- ScrVert *sav2 = sa->v2;
- ScrVert *sav3 = sa->v3;
- ScrVert *sav4 = sa->v4;
+ ScrVert *sav1 = area->v1;
+ ScrVert *sav2 = area->v2;
+ ScrVert *sav3 = area->v3;
+ ScrVert *sav4 = area->v4;
ScrVert *sbv1 = sb->v1;
ScrVert *sbv2 = sb->v2;
ScrVert *sbv3 = sb->v3;
ScrVert *sbv4 = sb->v4;
- if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */
+ if (sav1 == sbv4 && sav2 == sbv3) { /* area to right of sb = W */
return BKE_screen_find_edge(screen, sav1, sav2);
}
- else if (sav2 == sbv1 && sav3 == sbv4) { /* sa to bottom of sb = N */
+ else if (sav2 == sbv1 && sav3 == sbv4) { /* area to bottom of sb = N */
return BKE_screen_find_edge(screen, sav2, sav3);
}
- else if (sav3 == sbv2 && sav4 == sbv1) { /* sa to left of sb = E */
+ else if (sav3 == sbv2 && sav4 == sbv1) { /* area to left of sb = E */
return BKE_screen_find_edge(screen, sav3, sav4);
}
- else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/
+ else if (sav1 == sbv2 && sav4 == sbv3) { /* area on top of sb = S*/
return BKE_screen_find_edge(screen, sav1, sav4);
}
@@ -2055,7 +2059,7 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb)
static int area_split_apply(bContext *C, wmOperator *op)
{
const wmWindow *win = CTX_wm_window(C);
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
float fac;
int dir;
@@ -2063,13 +2067,13 @@ static int area_split_apply(bContext *C, wmOperator *op)
fac = RNA_float_get(op->ptr, "factor");
dir = RNA_enum_get(op->ptr, "direction");
- sd->narea = area_split(win, sc, sd->sarea, dir, fac, 0); /* 0 = no merge */
+ sd->narea = area_split(win, screen, sd->sarea, dir, fac, 0); /* 0 = no merge */
if (sd->narea) {
- sd->nedge = area_findsharededge(sc, sd->sarea, sd->narea);
+ sd->nedge = area_findsharededge(screen, sd->sarea, sd->narea);
/* select newly created edge, prepare for moving edge */
- ED_screen_verts_iter(win, sc, sv)
+ ED_screen_verts_iter(win, screen, sv)
{
sv->editflag = 0;
}
@@ -2089,7 +2093,7 @@ static int area_split_apply(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
/* Update preview thumbnail */
- BKE_icon_changed(sc->id.icon_id);
+ BKE_icon_changed(screen->id.icon_id);
return 1;
}
@@ -2137,12 +2141,12 @@ static void area_split_preview_update_cursor(bContext *C, wmOperator *op)
static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
wmWindow *win = CTX_wm_window(C);
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
sAreaSplitData *sd;
int dir;
/* no full window splitting allowed */
- BLI_assert(sc->state == SCREENNORMAL);
+ BLI_assert(screen->state == SCREENNORMAL);
PropertyRNA *prop_dir = RNA_struct_find_property(op->ptr, "direction");
PropertyRNA *prop_factor = RNA_struct_find_property(op->ptr, "factor");
@@ -2198,18 +2202,18 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
}
else if (RNA_property_is_set(op->ptr, prop_dir)) {
- ScrArea *sa = CTX_wm_area(C);
- if (sa == NULL) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area == NULL) {
return OPERATOR_CANCELLED;
}
dir = RNA_property_enum_get(op->ptr, prop_dir);
if (dir == 'h') {
RNA_property_float_set(
- op->ptr, prop_factor, ((float)(event->x - sa->v1->vec.x)) / (float)sa->winx);
+ op->ptr, prop_factor, ((float)(event->x - area->v1->vec.x)) / (float)area->winx);
}
else {
RNA_property_float_set(
- op->ptr, prop_factor, ((float)(event->y - sa->v1->vec.y)) / (float)sa->winy);
+ op->ptr, prop_factor, ((float)(event->y - area->v1->vec.y)) / (float)area->winy);
}
if (!area_split_init(C, op)) {
@@ -2232,7 +2236,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
WM_window_rect_calc(win, &window_rect);
actedge = screen_geom_area_map_find_active_scredge(
- AREAMAP_FROM_SCREEN(sc), &window_rect, event_co[0], event_co[1]);
+ AREAMAP_FROM_SCREEN(screen), &window_rect, event_co[0], event_co[1]);
if (actedge == NULL) {
return OPERATOR_CANCELLED;
}
@@ -2253,7 +2257,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* do the split */
if (area_split_apply(C, op)) {
- area_move_set_limits(win, sc, dir, &sd->bigger, &sd->smaller, NULL);
+ area_move_set_limits(win, screen, dir, &sd->bigger, &sd->smaller, NULL);
/* add temp handler for edge move or cancel */
G.moving |= G_TRANSFORM_WM;
@@ -2389,18 +2393,18 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
sd->sarea = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, event->x, event->y);
if (sd->sarea) {
- ScrArea *sa = sd->sarea;
+ ScrArea *area = sd->sarea;
if (dir == 'v') {
- sd->origmin = sa->v1->vec.x;
- sd->origsize = sa->v4->vec.x - sd->origmin;
+ sd->origmin = area->v1->vec.x;
+ sd->origsize = area->v4->vec.x - sd->origmin;
}
else {
- sd->origmin = sa->v1->vec.y;
- sd->origsize = sa->v2->vec.y - sd->origmin;
+ sd->origmin = area->v1->vec.y;
+ sd->origsize = area->v2->vec.y - sd->origmin;
}
if (sd->do_snap) {
- sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 1;
+ area->v1->editflag = area->v2->editflag = area->v3->editflag = area->v4->editflag = 1;
const int snap_loc = area_snap_calc_location(CTX_wm_screen(C),
SNAP_FRACTION_AND_ADJACENT,
@@ -2410,7 +2414,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
sd->origmin + sd->origsize,
-sd->origmin);
- sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 0;
+ area->v1->editflag = area->v2->editflag = area->v3->editflag = area->v4->editflag = 0;
sd->delta = snap_loc - sd->origval;
}
@@ -2465,7 +2469,7 @@ static void SCREEN_OT_area_split(wmOperatorType *ot)
typedef struct RegionMoveData {
AZone *az;
ARegion *region;
- ScrArea *sa;
+ ScrArea *area;
int bigger, smaller, origval;
int origx, origy;
int maxsize;
@@ -2473,7 +2477,7 @@ typedef struct RegionMoveData {
} RegionMoveData;
-static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
+static int area_max_regionsize(ScrArea *area, ARegion *scalear, AZEdge edge)
{
int dist;
@@ -2492,15 +2496,15 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
}
else {
if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) {
- dist = BLI_rcti_size_x(&sa->totrct);
+ dist = BLI_rcti_size_x(&area->totrct);
}
else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
- dist = BLI_rcti_size_y(&sa->totrct);
+ dist = BLI_rcti_size_y(&area->totrct);
}
/* subtractwidth of regions on opposite side
* prevents dragging regions into other opposite regions */
- for (ARegion *region = sa->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region == scalear) {
continue;
}
@@ -2574,11 +2578,11 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event
else {
rmd->region = az->region;
}
- rmd->sa = sad->sa1;
+ rmd->area = sad->sa1;
rmd->edge = az->edge;
rmd->origx = event->x;
rmd->origy = event->y;
- rmd->maxsize = area_max_regionsize(rmd->sa, rmd->region, rmd->edge);
+ rmd->maxsize = area_max_regionsize(rmd->area, rmd->region, rmd->edge);
/* if not set we do now, otherwise it uses type */
if (rmd->region->sizex == 0) {
@@ -2641,11 +2645,11 @@ static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd)
if ((rmd->region->flag & RGN_FLAG_HIDDEN) == 0) {
if (rmd->region->regiontype == RGN_TYPE_HEADER) {
- ARegion *ar_tool_header = BKE_area_find_region_type(rmd->sa, RGN_TYPE_TOOL_HEADER);
- if (ar_tool_header != NULL) {
- if ((ar_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER) == 0 &&
- (ar_tool_header->flag & RGN_FLAG_HIDDEN) != 0) {
- region_toggle_hidden(C, ar_tool_header, 0);
+ ARegion *region_tool_header = BKE_area_find_region_type(rmd->area, RGN_TYPE_TOOL_HEADER);
+ if (region_tool_header != NULL) {
+ if ((region_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER) == 0 &&
+ (region_tool_header->flag & RGN_FLAG_HIDDEN) != 0) {
+ region_toggle_hidden(C, region_tool_header, 0);
}
}
}
@@ -2732,7 +2736,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
rmd->region->sizey = rmd->origval;
}
}
- ED_area_tag_redraw(rmd->sa);
+ ED_area_tag_redraw(rmd->area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
break;
@@ -2747,7 +2751,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
region_scale_validate_size(rmd);
}
- ED_area_tag_redraw(rmd->sa);
+ ED_area_tag_redraw(rmd->area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
}
@@ -2794,19 +2798,19 @@ static void SCREEN_OT_region_scale(wmOperatorType *ot)
static void areas_do_frame_follow(bContext *C, bool middle)
{
- bScreen *scr = CTX_wm_screen(C);
+ bScreen *screen_ctx = CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
wmWindowManager *wm = CTX_wm_manager(C);
- for (wmWindow *window = wm->windows.first; window; window = window->next) {
+ LISTBASE_FOREACH (wmWindow *, window, &wm->windows) {
const bScreen *screen = WM_window_get_active_screen(window);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (ARegion *region = sa->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
/* do follow here if editor type supports it */
- if ((scr->redraws_flag & TIME_FOLLOW)) {
+ if ((screen_ctx->redraws_flag & TIME_FOLLOW)) {
if ((region->regiontype == RGN_TYPE_WINDOW &&
- ELEM(sa->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) ||
- (sa->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) {
+ ELEM(area->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) ||
+ (area->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) {
float w = BLI_rctf_size_x(&region->v2d.cur);
if (middle) {
@@ -3155,32 +3159,32 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot)
static int screen_maximize_area_exec(bContext *C, wmOperator *op)
{
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = NULL;
+ ScrArea *area = NULL;
const bool hide_panels = RNA_boolean_get(op->ptr, "use_hide_panels");
/* search current screen for 'fullscreen' areas */
/* prevents restoring info header, when mouse is over it */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->full) {
+ for (area = screen->areabase.first; area; area = area->next) {
+ if (area->full) {
break;
}
}
- if (sa == NULL) {
- sa = CTX_wm_area(C);
+ if (area == NULL) {
+ area = CTX_wm_area(C);
}
if (hide_panels) {
if (!ELEM(screen->state, SCREENNORMAL, SCREENFULL)) {
return OPERATOR_CANCELLED;
}
- ED_screen_state_toggle(C, CTX_wm_window(C), sa, SCREENFULL);
+ ED_screen_state_toggle(C, CTX_wm_window(C), area, SCREENFULL);
}
else {
if (!ELEM(screen->state, SCREENNORMAL, SCREENMAXIMIZED)) {
return OPERATOR_CANCELLED;
}
- ED_screen_state_toggle(C, CTX_wm_window(C), sa, SCREENMAXIMIZED);
+ ED_screen_state_toggle(C, CTX_wm_window(C), area, SCREENMAXIMIZED);
}
return OPERATOR_FINISHED;
@@ -3381,7 +3385,7 @@ static void area_join_cancel(bContext *C, wmOperator *op)
/* modal callback while selecting area (space) that will be removed */
static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
wmWindow *win = CTX_wm_window(C);
sAreaJoinData *jd;
@@ -3396,24 +3400,24 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case MOUSEMOVE: {
- ScrArea *sa = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, event->x, event->y);
+ ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->x, event->y);
int dir = -1;
- if (sa) {
- if (jd->sa1 != sa) {
- dir = area_getorientation(jd->sa1, sa);
+ if (area) {
+ if (jd->sa1 != area) {
+ dir = area_getorientation(jd->sa1, area);
if (dir != -1) {
- jd->sa2 = sa;
+ jd->sa2 = area;
}
else {
/* we are not bordering on the previously selected area
* we check if area has common border with the one marked for removal
* in this case we can swap areas.
*/
- dir = area_getorientation(sa, jd->sa2);
+ dir = area_getorientation(area, jd->sa2);
if (dir != -1) {
jd->sa1 = jd->sa2;
- jd->sa2 = sa;
+ jd->sa2 = area;
}
else {
jd->sa2 = NULL;
@@ -3426,16 +3430,16 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
* we swap the areas if possible to allow user to choose */
if (jd->sa2 != NULL) {
jd->sa1 = jd->sa2;
- jd->sa2 = sa;
+ jd->sa2 = area;
dir = area_getorientation(jd->sa1, jd->sa2);
if (dir == -1) {
printf("oops, didn't expect that!\n");
}
}
else {
- dir = area_getorientation(jd->sa1, sa);
+ dir = area_getorientation(jd->sa1, area);
if (dir != -1) {
- jd->sa2 = sa;
+ jd->sa2 = area;
}
}
WM_event_add_notifier(C, NC_WINDOW, NULL);
@@ -3612,18 +3616,18 @@ static int spacedata_cleanup_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
bScreen *screen;
- ScrArea *sa;
+ ScrArea *area;
int tot = 0;
for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->spacedata.first != sa->spacedata.last) {
- SpaceLink *sl = sa->spacedata.first;
-
- BLI_remlink(&sa->spacedata, sl);
- tot += BLI_listbase_count(&sa->spacedata);
- BKE_spacedata_freelist(&sa->spacedata);
- BLI_addtail(&sa->spacedata, sl);
+ for (area = screen->areabase.first; area; area = area->next) {
+ if (area->spacedata.first != area->spacedata.last) {
+ SpaceLink *sl = area->spacedata.first;
+
+ BLI_remlink(&area->spacedata, sl);
+ tot += BLI_listbase_count(&area->spacedata);
+ BKE_spacedata_freelist(&area->spacedata);
+ BLI_addtail(&area->spacedata, sl);
}
}
}
@@ -3809,7 +3813,7 @@ static void view3d_localview_update_rv3d(struct RegionView3D *rv3d)
}
static void region_quadview_init_rv3d(
- ScrArea *sa, ARegion *region, const char viewlock, const char view, const char persp)
+ ScrArea *area, ARegion *region, const char viewlock, const char view, const char persp)
{
RegionView3D *rv3d = region->regiondata;
@@ -3826,7 +3830,7 @@ static void region_quadview_init_rv3d(
ED_view3d_lock(rv3d);
view3d_localview_update_rv3d(rv3d);
if ((viewlock & RV3D_BOXCLIP) && (persp == RV3D_ORTHO)) {
- ED_view3d_quadview_update(sa, region, true);
+ ED_view3d_quadview_update(area, region, true);
}
}
@@ -3841,24 +3845,24 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
}
else if (region->alignment == RGN_ALIGN_QSPLIT) {
/* Exit quad-view */
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *arn;
/* keep current region */
region->alignment = 0;
- if (sa->spacetype == SPACE_VIEW3D) {
- ARegion *ar_iter;
+ if (area->spacetype == SPACE_VIEW3D) {
+ ARegion *region_iter;
RegionView3D *rv3d = region->regiondata;
/* if this is a locked view, use settings from 'User' view */
if (rv3d->viewlock) {
View3D *v3d_user;
- ARegion *ar_user;
+ ARegion *region_user;
- if (ED_view3d_context_user_region(C, &v3d_user, &ar_user)) {
- if (region != ar_user) {
- SWAP(void *, region->regiondata, ar_user->regiondata);
+ if (ED_view3d_context_user_region(C, &v3d_user, &region_user)) {
+ if (region != region_user) {
+ SWAP(void *, region->regiondata, region_user->regiondata);
rv3d = region->regiondata;
}
}
@@ -3869,21 +3873,21 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
rv3d->rflag &= ~RV3D_CLIPPING;
/* Accumulate locks, in case they're mixed. */
- for (ar_iter = sa->regionbase.first; ar_iter; ar_iter = ar_iter->next) {
- if (ar_iter->regiontype == RGN_TYPE_WINDOW) {
- RegionView3D *rv3d_iter = ar_iter->regiondata;
+ for (region_iter = area->regionbase.first; region_iter; region_iter = region_iter->next) {
+ if (region_iter->regiontype == RGN_TYPE_WINDOW) {
+ RegionView3D *rv3d_iter = region_iter->regiondata;
rv3d->viewlock_quad |= rv3d_iter->viewlock;
}
}
}
- for (region = sa->regionbase.first; region; region = arn) {
+ for (region = area->regionbase.first; region; region = arn) {
arn = region->next;
if (region->alignment == RGN_ALIGN_QSPLIT) {
- ED_region_remove(C, sa, region);
+ ED_region_remove(C, area, region);
}
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
}
else if (region->next) {
@@ -3891,20 +3895,20 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
}
else {
/* Enter quad-view */
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *newar;
int count;
region->alignment = RGN_ALIGN_QSPLIT;
for (count = 0; count < 3; count++) {
- newar = BKE_area_region_copy(sa->type, region);
- BLI_addtail(&sa->regionbase, newar);
+ newar = BKE_area_region_copy(area->type, region);
+ BLI_addtail(&area->regionbase, newar);
}
/* lock views and set them */
- if (sa->spacetype == SPACE_VIEW3D) {
- View3D *v3d = sa->spacedata.first;
+ if (area->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = area->spacedata.first;
int index_qsplit = 0;
/* run ED_view3d_lock() so the correct 'rv3d->viewquat' is set,
@@ -3919,13 +3923,13 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
RV3D_LOCK_ROTATION;
region_quadview_init_rv3d(
- sa, region, viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO);
- region_quadview_init_rv3d(sa,
+ area, region, viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO);
+ region_quadview_init_rv3d(area,
(region = region->next),
viewlock,
ED_view3d_lock_view_from_index(index_qsplit++),
RV3D_ORTHO);
- region_quadview_init_rv3d(sa,
+ region_quadview_init_rv3d(area,
(region = region->next),
viewlock,
ED_view3d_lock_view_from_index(index_qsplit++),
@@ -3933,16 +3937,16 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
/* forcing camera is distracting */
#if 0
if (v3d->camera) {
- region_quadview_init_rv3d(sa, (region = region->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB);
+ region_quadview_init_rv3d(area, (region = region->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB);
}
else {
- region_quadview_init_rv3d(sa, (region = region->next), 0, RV3D_VIEW_USER, RV3D_PERSP);
+ region_quadview_init_rv3d(area, (region = region->next), 0, RV3D_VIEW_USER, RV3D_PERSP);
}
#else
(void)v3d;
#endif
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
}
@@ -4091,11 +4095,11 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot)
/* show/hide header text menus */
static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
- sa->flag = sa->flag ^ HEADER_NO_PULLDOWN;
+ area->flag = area->flag ^ HEADER_NO_PULLDOWN;
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -4122,42 +4126,42 @@ static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot)
static bool screen_region_context_menu_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- return (sa && sa->spacetype != SPACE_STATUSBAR);
+ ScrArea *area = CTX_wm_area(C);
+ return (area && area->spacetype != SPACE_STATUSBAR);
}
void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_TOP) ?
IFACE_("Flip to Bottom") :
IFACE_("Flip to Top");
{
PointerRNA ptr;
- RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, sa->spacedata.first, &ptr);
- if (!ELEM(sa->spacetype, SPACE_TOPBAR)) {
+ RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, area->spacedata.first, &ptr);
+ if (!ELEM(area->spacetype, SPACE_TOPBAR)) {
uiItemR(layout, &ptr, "show_region_header", 0, IFACE_("Show Header"), ICON_NONE);
}
- ARegion *ar_header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+ ARegion *region_header = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
uiLayout *col = uiLayoutColumn(layout, 0);
- uiLayoutSetActive(col, (ar_header->flag & RGN_FLAG_HIDDEN) == 0);
+ uiLayoutSetActive(col, (region_header->flag & RGN_FLAG_HIDDEN) == 0);
- if (BKE_area_find_region_type(sa, RGN_TYPE_TOOL_HEADER)) {
+ if (BKE_area_find_region_type(area, RGN_TYPE_TOOL_HEADER)) {
uiItemR(col, &ptr, "show_region_tool_header", 0, IFACE_("Show Tool Settings"), ICON_NONE);
}
uiItemO(col,
IFACE_("Show Menus"),
- (sa->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_DEHLT : ICON_CHECKBOX_HLT,
+ (area->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_DEHLT : ICON_CHECKBOX_HLT,
"SCREEN_OT_header_toggle_menus");
}
/* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
- if (!ELEM(sa->spacetype, SPACE_TOPBAR)) {
+ if (!ELEM(area->spacetype, SPACE_TOPBAR)) {
uiItemS(layout);
uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip");
@@ -4165,24 +4169,24 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN
/* File browser should be fullscreen all the time, top-bar should
* never be. But other regions can be maximized/restored. */
- if (!ELEM(sa->spacetype, SPACE_FILE, SPACE_TOPBAR)) {
+ if (!ELEM(area->spacetype, SPACE_FILE, SPACE_TOPBAR)) {
uiItemS(layout);
- const char *but_str = sa->full ? IFACE_("Tile Area") : IFACE_("Maximize Area");
+ const char *but_str = area->full ? IFACE_("Tile Area") : IFACE_("Maximize Area");
uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area");
}
}
void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_TOP) ?
IFACE_("Flip to Bottom") :
IFACE_("Flip to Top");
{
PointerRNA ptr;
- RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, sa->spacedata.first, &ptr);
+ RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, area->spacedata.first, &ptr);
uiItemR(layout, &ptr, "show_region_footer", 0, IFACE_("Show Footer"), ICON_NONE);
}
@@ -4193,10 +4197,10 @@ void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *UN
/* File browser should be fullscreen all the time, top-bar should
* never be. But other regions can be maximized/restored... */
- if (!ELEM(sa->spacetype, SPACE_FILE, SPACE_TOPBAR)) {
+ if (!ELEM(area->spacetype, SPACE_FILE, SPACE_TOPBAR)) {
uiItemS(layout);
- const char *but_str = sa->full ? IFACE_("Tile Area") : IFACE_("Maximize Area");
+ const char *but_str = area->full ? IFACE_("Tile Area") : IFACE_("Maximize Area");
uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area");
}
}
@@ -4383,7 +4387,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
ScreenAnimData *sad = wt->customdata;
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *window;
- ScrArea *sa;
+ ScrArea *area;
int sync;
float time;
@@ -4514,15 +4518,15 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
for (window = wm->windows.first; window; window = window->next) {
const bScreen *win_screen = WM_window_get_active_screen(window);
- for (sa = win_screen->areabase.first; sa; sa = sa->next) {
+ for (area = win_screen->areabase.first; area; area = area->next) {
ARegion *region;
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
bool redraw = false;
if (region == sad->region) {
redraw = true;
}
else if (match_region_with_redraws(
- sa->spacetype, region->regiontype, sad->redraws, sad->from_anim_edit)) {
+ area->spacetype, region->regiontype, sad->redraws, sad->from_anim_edit)) {
redraw = true;
}
@@ -4531,8 +4535,8 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
/* do follow here if editor type supports it */
if ((sad->redraws & TIME_FOLLOW)) {
if ((region->regiontype == RGN_TYPE_WINDOW &&
- ELEM(sa->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) ||
- (sa->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) {
+ ELEM(area->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) ||
+ (area->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) {
float w = BLI_rctf_size_x(&region->v2d.cur);
if (scene->r.cfra < region->v2d.cur.xmin) {
region->v2d.cur.xmax = scene->r.cfra;
@@ -4591,7 +4595,7 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot)
/* find window that owns the animation timer */
bScreen *ED_screen_animation_playing(const wmWindowManager *wm)
{
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
bScreen *screen = WM_window_get_active_screen(win);
if (screen->animtimer || screen->scrubbing) {
@@ -4604,7 +4608,7 @@ bScreen *ED_screen_animation_playing(const wmWindowManager *wm)
bScreen *ED_screen_animation_no_scrub(const wmWindowManager *wm)
{
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
bScreen *screen = WM_window_get_active_screen(win);
if (screen->animtimer) {
@@ -4803,20 +4807,20 @@ static void SCREEN_OT_box_select(wmOperatorType *ot)
static int fullscreen_back_exec(bContext *C, wmOperator *op)
{
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = NULL;
+ ScrArea *area = NULL;
/* search current screen for 'fullscreen' areas */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->full) {
+ for (area = screen->areabase.first; area; area = area->next) {
+ if (area->full) {
break;
}
}
- if (!sa) {
+ if (!area) {
BKE_report(op->reports, RPT_ERROR, "No fullscreen areas were found");
return OPERATOR_CANCELLED;
}
- ED_screen_full_prevspace(C, sa);
+ ED_screen_full_prevspace(C, area);
return OPERATOR_FINISHED;
}
@@ -5037,9 +5041,9 @@ static void SCREEN_OT_new(wmOperatorType *ot)
static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
WorkSpace *workspace = CTX_wm_workspace(C);
- WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, sc);
+ WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, screen);
WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTDELETE, layout);
@@ -5069,8 +5073,8 @@ static void SCREEN_OT_delete(wmOperatorType *ot)
* \{ */
typedef struct RegionAlphaInfo {
- ScrArea *sa;
- ARegion *region, *child_ar; /* other region */
+ ScrArea *area;
+ ARegion *region, *child_region; /* other region */
int hidden;
} RegionAlphaInfo;
@@ -5107,8 +5111,8 @@ static void region_blend_end(bContext *C, ARegion *region, const bool is_running
/* always send redraw */
ED_region_tag_redraw(region);
- if (rgi->child_ar) {
- ED_region_tag_redraw(rgi->child_ar);
+ if (rgi->child_region) {
+ ED_region_tag_redraw(rgi->child_region);
}
/* if running timer was hiding, the flag toggle went wrong */
@@ -5120,10 +5124,10 @@ static void region_blend_end(bContext *C, ARegion *region, const bool is_running
else {
if (rgi->hidden) {
rgi->region->flag |= rgi->hidden;
- ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), rgi->sa);
+ ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), rgi->area);
}
/* area decoration needs redraw in end */
- ED_area_tag_redraw(rgi->sa);
+ ED_area_tag_redraw(rgi->area);
}
WM_event_remove_timer(CTX_wm_manager(C), NULL, region->regiontimer); /* frees rgi */
region->regiontimer = NULL;
@@ -5131,7 +5135,7 @@ static void region_blend_end(bContext *C, ARegion *region, const bool is_running
/**
* \note Assumes that \a region itself is not a split version from previous region.
*/
-void ED_region_visibility_change_update_animated(bContext *C, ScrArea *sa, ARegion *region)
+void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARegion *region)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
@@ -5145,13 +5149,13 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *sa, ARegi
rgi = MEM_callocN(sizeof(RegionAlphaInfo), "RegionAlphaInfo");
rgi->hidden = region->flag & RGN_FLAG_HIDDEN;
- rgi->sa = sa;
+ rgi->area = area;
rgi->region = region;
region->flag &= ~RGN_FLAG_HIDDEN;
/* blend in, reinitialize regions because it got unhidden */
if (rgi->hidden == 0) {
- ED_area_initialize(wm, win, sa);
+ ED_area_initialize(wm, win, area);
}
else {
WM_event_remove_handlers(C, &region->handlers);
@@ -5159,7 +5163,7 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *sa, ARegi
if (region->next) {
if (region->next->alignment & RGN_SPLIT_PREV) {
- rgi->child_ar = region->next;
+ rgi->child_region = region->next;
}
}
@@ -5183,8 +5187,8 @@ static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven
/* always send redraws */
ED_region_tag_redraw(rgi->region);
- if (rgi->child_ar) {
- ED_region_tag_redraw(rgi->child_ar);
+ if (rgi->child_region) {
+ ED_region_tag_redraw(rgi->child_region);
}
/* end timer? */
@@ -5220,8 +5224,8 @@ static void SCREEN_OT_region_blend(wmOperatorType *ot)
static bool space_type_set_or_cycle_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- return (sa && !ELEM(sa->spacetype, SPACE_TOPBAR, SPACE_STATUSBAR));
+ ScrArea *area = CTX_wm_area(C);
+ return (area && !ELEM(area->spacetype, SPACE_TOPBAR, SPACE_STATUSBAR));
}
static int space_type_set_or_cycle_exec(bContext *C, wmOperator *op)
@@ -5229,12 +5233,12 @@ static int space_type_set_or_cycle_exec(bContext *C, wmOperator *op)
const int space_type = RNA_enum_get(op->ptr, "space_type");
PointerRNA ptr;
- ScrArea *sa = CTX_wm_area(C);
- RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Area, sa, &ptr);
+ ScrArea *area = CTX_wm_area(C);
+ RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Area, area, &ptr);
PropertyRNA *prop_type = RNA_struct_find_property(&ptr, "type");
PropertyRNA *prop_ui_type = RNA_struct_find_property(&ptr, "ui_type");
- if (sa->spacetype != space_type) {
+ if (area->spacetype != space_type) {
/* Set the type. */
RNA_property_enum_set(&ptr, prop_type, space_type);
RNA_property_update(C, &ptr, prop_type);
@@ -5293,25 +5297,25 @@ static const EnumPropertyItem space_context_cycle_direction[] = {
static bool space_context_cycle_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- /* sa might be NULL if called out of window bounds */
- return (sa && ELEM(sa->spacetype, SPACE_PROPERTIES, SPACE_USERPREF));
+ ScrArea *area = CTX_wm_area(C);
+ /* area might be NULL if called out of window bounds */
+ return (area && ELEM(area->spacetype, SPACE_PROPERTIES, SPACE_USERPREF));
}
/**
* Helper to get the correct RNA pointer/property pair for changing
- * the display context of active space type in \a sa.
+ * the display context of active space type in \a area.
*/
static void context_cycle_prop_get(bScreen *screen,
- const ScrArea *sa,
+ const ScrArea *area,
PointerRNA *r_ptr,
PropertyRNA **r_prop)
{
const char *propname;
- switch (sa->spacetype) {
+ switch (area->spacetype) {
case SPACE_PROPERTIES:
- RNA_pointer_create(&screen->id, &RNA_SpaceProperties, sa->spacedata.first, r_ptr);
+ RNA_pointer_create(&screen->id, &RNA_SpaceProperties, area->spacedata.first, r_ptr);
propname = "context";
break;
case SPACE_USERPREF:
@@ -5384,7 +5388,7 @@ static int space_workspace_cycle_invoke(bContext *C, wmOperator *op, const wmEve
ListBase ordered;
BKE_id_ordered_list(&ordered, &bmain->workspaces);
- for (LinkData *link = ordered.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &ordered) {
if (link->data == workspace_src) {
if (direction == SPACE_CONTEXT_CYCLE_PREV) {
workspace_dst = (link->prev) ? link->prev->data : NULL;
diff --git a/source/blender/editors/screen/screen_user_menu.c b/source/blender/editors/screen/screen_user_menu.c
index 38d83801f2b..733e8b694a6 100644
--- a/source/blender/editors/screen/screen_user_menu.c
+++ b/source/blender/editors/screen/screen_user_menu.c
@@ -113,7 +113,7 @@ bUserMenuItem_Op *ED_screen_user_menu_item_find_operator(ListBase *lb,
IDProperty *prop,
short opcontext)
{
- for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) {
+ LISTBASE_FOREACH (bUserMenuItem *, umi, lb) {
if (umi->type == USER_MENU_TYPE_OPERATOR) {
bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi;
if (STREQ(ot->idname, umi_op->op_idname) && (opcontext == umi_op->opcontext) &&
@@ -128,7 +128,7 @@ bUserMenuItem_Op *ED_screen_user_menu_item_find_operator(ListBase *lb,
struct bUserMenuItem_Menu *ED_screen_user_menu_item_find_menu(struct ListBase *lb,
const struct MenuType *mt)
{
- for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) {
+ LISTBASE_FOREACH (bUserMenuItem *, umi, lb) {
if (umi->type == USER_MENU_TYPE_MENU) {
bUserMenuItem_Menu *umi_mt = (bUserMenuItem_Menu *)umi;
if (STREQ(mt->idname, umi_mt->mt_idname)) {
@@ -144,7 +144,7 @@ struct bUserMenuItem_Prop *ED_screen_user_menu_item_find_prop(struct ListBase *l
const char *prop_id,
int prop_index)
{
- for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) {
+ LISTBASE_FOREACH (bUserMenuItem *, umi, lb) {
if (umi->type == USER_MENU_TYPE_PROP) {
bUserMenuItem_Prop *umi_pr = (bUserMenuItem_Prop *)umi;
if (STREQ(context_data_path, umi_pr->context_data_path) && STREQ(prop_id, umi_pr->prop_id) &&
@@ -222,7 +222,7 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
if (um == NULL) {
continue;
}
- for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) {
+ LISTBASE_FOREACH (bUserMenuItem *, umi, &um->items) {
const char *ui_name = umi->ui_name[0] ? umi->ui_name : NULL;
if (umi->type == USER_MENU_TYPE_OPERATOR) {
bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi;
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index d52dc262c3f..83ded5b3503 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -54,7 +54,7 @@
#include "screen_intern.h"
typedef struct ScreenshotData {
- unsigned int *dumprect;
+ uint *dumprect;
int dumpsx, dumpsy;
rcti crop;
@@ -76,13 +76,13 @@ static int screenshot_data_create(bContext *C, wmOperator *op)
if (dumprect) {
ScreenshotData *scd = MEM_callocN(sizeof(ScreenshotData), "screenshot");
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
scd->dumpsx = dumprect_size[0];
scd->dumpsy = dumprect_size[1];
scd->dumprect = dumprect;
- if (sa) {
- scd->crop = sa->totrct;
+ if (area) {
+ scd->crop = area->totrct;
}
BKE_imformat_defaults(&scd->im_format);
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 784fa60999d..8feef0c675a 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -198,8 +198,7 @@ WorkSpace *ED_workspace_duplicate(WorkSpace *workspace_old, Main *bmain, wmWindo
/* TODO(campbell): tools */
- for (WorkSpaceLayout *layout_old = layouts_old->first; layout_old;
- layout_old = layout_old->next) {
+ LISTBASE_FOREACH (WorkSpaceLayout *, layout_old, layouts_old) {
WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(
bmain, workspace_new, layout_old, win);
@@ -222,7 +221,7 @@ bool ED_workspace_delete(WorkSpace *workspace, Main *bmain, bContext *C, wmWindo
ListBase ordered;
BKE_id_ordered_list(&ordered, &bmain->workspaces);
WorkSpace *prev = NULL, *next = NULL;
- for (LinkData *link = ordered.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &ordered) {
if (link->data == workspace) {
prev = link->prev ? link->prev->data : NULL;
next = link->next ? link->next->data : NULL;
@@ -232,7 +231,7 @@ bool ED_workspace_delete(WorkSpace *workspace, Main *bmain, bContext *C, wmWindo
BLI_freelistN(&ordered);
BLI_assert((prev != NULL) || (next != NULL));
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
WorkSpace *workspace_active = WM_window_get_active_workspace(win);
if (workspace_active == workspace) {
ED_workspace_change((prev != NULL) ? prev : next, C, wm, win);
@@ -481,7 +480,7 @@ static int workspace_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
ListBase templates;
BKE_appdir_app_templates(&templates);
- for (LinkData *link = templates.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &templates) {
char *template = link->data;
char display_name[FILE_MAX];
diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c
index 276e36b97dc..cf9637788a9 100644
--- a/source/blender/editors/screen/workspace_layout_edit.c
+++ b/source/blender/editors/screen/workspace_layout_edit.c
@@ -68,7 +68,7 @@ WorkSpaceLayout *ED_workspace_layout_duplicate(Main *bmain,
screen_new = BKE_workspace_layout_screen_get(layout_new);
if (BKE_screen_is_fullscreen_area(screen_old)) {
- for (ScrArea *area_old = screen_old->areabase.first; area_old; area_old = area_old->next) {
+ LISTBASE_FOREACH (ScrArea *, area_old, &screen_old->areabase) {
if (area_old->full) {
ScrArea *area_new = (ScrArea *)screen_new->areabase.first;
ED_area_data_copy(area_new, area_old, true);
@@ -172,9 +172,9 @@ bool ED_workspace_layout_cycle(WorkSpace *workspace, const short direction, bCon
WorkSpaceLayout *old_layout = BKE_workspace_active_layout_get(win->workspace_hook);
WorkSpaceLayout *new_layout;
const bScreen *old_screen = BKE_workspace_layout_screen_get(old_layout);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
- if (old_screen->temp || (sa && sa->full && sa->full->temp)) {
+ if (old_screen->temp || (area && area->full && area->full->temp)) {
return false;
}
@@ -188,9 +188,9 @@ bool ED_workspace_layout_cycle(WorkSpace *workspace, const short direction, bCon
if (new_layout && (old_layout != new_layout)) {
bScreen *new_screen = BKE_workspace_layout_screen_get(new_layout);
- if (sa && sa->full) {
+ if (area && area->full) {
/* return to previous state before switching screens */
- ED_screen_full_restore(C, sa); /* may free screen of old_layout */
+ ED_screen_full_restore(C, area); /* may free screen of old_layout */
}
ED_screen_change(C, new_screen);
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index de9e70f8e06..b8754953741 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -59,9 +59,18 @@ set(SRC
paint_vertex_weight_ops.c
paint_vertex_weight_utils.c
sculpt.c
+ sculpt_automasking.c
sculpt_cloth.c
+ sculpt_detail.c
+ sculpt_dyntopo.c
+ sculpt_face_set.c
+ sculpt_filter_mask.c
+ sculpt_filter_mesh.c
+ sculpt_mask_expand.c
sculpt_multiplane_scrape.c
sculpt_pose.c
+ sculpt_smooth.c
+ sculpt_transform.c
sculpt_undo.c
sculpt_uv.c
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index c035863203b..04ca5770a97 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -876,12 +876,8 @@ static bool paint_draw_alpha_overlay(UnifiedPaintSettings *ups,
return alpha_overlay_active;
}
-BLI_INLINE void draw_tri_point(unsigned int pos,
- const float sel_col[4],
- float pivot_col[4],
- float *co,
- float width,
- bool selected)
+BLI_INLINE void draw_tri_point(
+ uint pos, const float sel_col[4], float pivot_col[4], float *co, float width, bool selected)
{
immUniformColor4fv(selected ? sel_col : pivot_col);
@@ -910,12 +906,8 @@ BLI_INLINE void draw_tri_point(unsigned int pos,
immEnd();
}
-BLI_INLINE void draw_rect_point(unsigned int pos,
- const float sel_col[4],
- float handle_col[4],
- float *co,
- float width,
- bool selected)
+BLI_INLINE void draw_rect_point(
+ uint pos, const float sel_col[4], float handle_col[4], float *co, float width, bool selected)
{
immUniformColor4fv(selected ? sel_col : handle_col);
@@ -935,7 +927,7 @@ BLI_INLINE void draw_rect_point(unsigned int pos,
imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy);
}
-BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], BezTriple *bez)
+BLI_INLINE void draw_bezier_handle_lines(uint pos, float sel_col[4], BezTriple *bez)
{
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
GPU_line_width(3.0f);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index cbb0ce84156..4d4af028570 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -764,9 +764,9 @@ void PAINT_OT_image_paint(wmOperatorType *ot)
bool get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
{
- ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = sa->spacedata.first;
+ ScrArea *area = CTX_wm_area(C);
+ if (area && area->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = area->spacedata.first;
if (sima->mode == SI_MODE_PAINT) {
ARegion *region = CTX_wm_region(C);
ED_space_image_get_zoom(sima, region, zoomx, zoomy);
@@ -808,12 +808,12 @@ void ED_space_image_paint_update(Main *bmain, wmWindowManager *wm, Scene *scene)
ImagePaintSettings *imapaint = &settings->imapaint;
bool enabled = false;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
bScreen *screen = WM_window_get_active_screen(win);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->spacetype == SPACE_IMAGE) {
- if (((SpaceImage *)sa->spacedata.first)->mode == SI_MODE_PAINT) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ if (area->spacetype == SPACE_IMAGE) {
+ if (((SpaceImage *)area->spacedata.first)->mode == SI_MODE_PAINT) {
enabled = true;
}
}
@@ -949,9 +949,9 @@ typedef struct {
static void sample_color_update_header(SampleColorData *data, bContext *C)
{
char msg[UI_MAX_DRAW_STR];
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
- if (sa) {
+ if (area) {
BLI_snprintf(msg,
sizeof(msg),
TIP_("Sample color for %s"),
@@ -1159,7 +1159,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
toggle_paint_cursor(C, 0);
}
else {
- bScreen *sc;
+ bScreen *screen;
Image *ima = NULL;
ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
@@ -1183,11 +1183,11 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
}
if (ima) {
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ ScrArea *area;
+ for (area = screen->areabase.first; area; area = area->next) {
SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ for (sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 73c099c9407..3485941d3df 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -80,11 +80,11 @@ typedef struct BrushPainterCache {
ImBuf *ibuf;
ImBuf *texibuf;
- unsigned short *curve_mask;
- unsigned short *tex_mask;
- unsigned short *tex_mask_old;
- unsigned int tex_mask_old_w;
- unsigned int tex_mask_old_h;
+ ushort *curve_mask;
+ ushort *tex_mask;
+ ushort *tex_mask_old;
+ uint tex_mask_old_w;
+ uint tex_mask_old_h;
int image_size[2];
} BrushPainterCache;
@@ -228,7 +228,7 @@ static void brush_imbuf_tex_co(rctf *mapping, int x, int y, float texco[3])
}
/* create a mask with the mask texture */
-static unsigned short *brush_painter_mask_ibuf_new(BrushPainter *painter, const int size)
+static ushort *brush_painter_mask_ibuf_new(BrushPainter *painter, const int size)
{
Scene *scene = painter->scene;
Brush *brush = painter->brush;
@@ -236,10 +236,10 @@ static unsigned short *brush_painter_mask_ibuf_new(BrushPainter *painter, const
struct ImagePool *pool = painter->pool;
float texco[3];
- unsigned short *mask, *m;
+ ushort *mask, *m;
int x, y, thread = 0;
- mask = MEM_mallocN(sizeof(unsigned short) * size * size, "brush_painter_mask");
+ mask = MEM_mallocN(sizeof(ushort) * size * size, "brush_painter_mask");
m = mask;
for (y = 0; y < size; y++) {
@@ -247,7 +247,7 @@ static unsigned short *brush_painter_mask_ibuf_new(BrushPainter *painter, const
float res;
brush_imbuf_tex_co(&mask_mapping, x, y, texco);
res = BKE_brush_sample_masktex(scene, brush, texco, thread, pool);
- *m = (unsigned short)(65535.0f * res);
+ *m = (ushort)(65535.0f * res);
}
}
@@ -257,7 +257,7 @@ static unsigned short *brush_painter_mask_ibuf_new(BrushPainter *painter, const
/* update rectangular section of the brush image */
static void brush_painter_mask_imbuf_update(BrushPainter *painter,
ImagePaintTile *tile,
- unsigned short *tex_mask_old,
+ ushort *tex_mask_old,
int origx,
int origy,
int w,
@@ -271,14 +271,14 @@ static void brush_painter_mask_imbuf_update(BrushPainter *painter,
BrushPainterCache *cache = &tile->cache;
rctf tex_mapping = painter->mask_mapping;
struct ImagePool *pool = painter->pool;
- unsigned short res;
+ ushort res;
bool use_texture_old = (tex_mask_old != NULL);
int x, y, thread = 0;
- unsigned short *tex_mask = cache->tex_mask;
- unsigned short *tex_mask_cur = cache->tex_mask_old;
+ ushort *tex_mask = cache->tex_mask;
+ ushort *tex_mask_cur = cache->tex_mask_old;
/* fill pixels */
for (y = origy; y < h; y++) {
@@ -287,13 +287,12 @@ static void brush_painter_mask_imbuf_update(BrushPainter *painter,
float texco[3];
/* handle byte pixel */
- unsigned short *b = tex_mask + (y * diameter + x);
- unsigned short *t = tex_mask_cur + (y * diameter + x);
+ ushort *b = tex_mask + (y * diameter + x);
+ ushort *t = tex_mask_cur + (y * diameter + x);
if (!use_texture_old) {
brush_imbuf_tex_co(&tex_mapping, x, y, texco);
- res = (unsigned short)(65535.0f *
- BKE_brush_sample_masktex(scene, brush, texco, thread, pool));
+ res = (ushort)(65535.0f * BKE_brush_sample_masktex(scene, brush, texco, thread, pool));
}
/* read from old texture buffer */
@@ -320,19 +319,17 @@ static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter,
const int diameter)
{
BrushPainterCache *cache = &tile->cache;
- unsigned short *tex_mask_old;
+ ushort *tex_mask_old;
int destx, desty, srcx, srcy, w, h, x1, y1, x2, y2;
/* create brush image buffer if it didn't exist yet */
if (!cache->tex_mask) {
- cache->tex_mask = MEM_mallocN(sizeof(unsigned short) * diameter * diameter,
- "brush_painter_mask");
+ cache->tex_mask = MEM_mallocN(sizeof(ushort) * diameter * diameter, "brush_painter_mask");
}
/* create new texture image buffer with coordinates relative to old */
tex_mask_old = cache->tex_mask_old;
- cache->tex_mask_old = MEM_mallocN(sizeof(unsigned short) * diameter * diameter,
- "brush_painter_mask");
+ cache->tex_mask_old = MEM_mallocN(sizeof(ushort) * diameter * diameter, "brush_painter_mask");
if (tex_mask_old) {
ImBuf maskibuf;
@@ -393,18 +390,18 @@ static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter,
}
/* create a mask with the falloff strength */
-static unsigned short *brush_painter_curve_mask_new(BrushPainter *painter,
- int diameter,
- float radius,
- const float pos[2])
+static ushort *brush_painter_curve_mask_new(BrushPainter *painter,
+ int diameter,
+ float radius,
+ const float pos[2])
{
Brush *brush = painter->brush;
int offset = (int)floorf(diameter / 2.0f);
- unsigned short *mask, *m;
+ ushort *mask, *m;
- mask = MEM_mallocN(sizeof(unsigned short) * diameter * diameter, "brush_painter_mask");
+ mask = MEM_mallocN(sizeof(ushort) * diameter * diameter, "brush_painter_mask");
m = mask;
int aa_samples = 1.0f / (radius * 0.20f);
@@ -458,7 +455,7 @@ static unsigned short *brush_painter_curve_mask_new(BrushPainter *painter,
total_samples += curve * hardness_factor;
}
}
- *m = (unsigned short)(total_samples * norm_factor);
+ *m = (ushort)(total_samples * norm_factor);
}
}
@@ -528,7 +525,7 @@ static ImBuf *brush_painter_imbuf_new(
}
else {
/* write to byte pixel */
- unsigned char *dst = (unsigned char *)ibuf->rect + (y * size + x) * 4;
+ uchar *dst = (uchar *)ibuf->rect + (y * size + x) * 4;
rgb_float_to_uchar(dst, rgba);
dst[3] = unit_float_to_uchar_clamp(rgba[3]);
@@ -624,16 +621,16 @@ static void brush_painter_imbuf_update(BrushPainter *painter,
bf[3] = rgba[3];
}
else {
- unsigned char crgba[4];
+ uchar crgba[4];
/* handle byte pixel */
- unsigned char *b = (unsigned char *)ibuf->rect + (y * ibuf->x + x) * 4;
- unsigned char *t = (unsigned char *)texibuf->rect + (y * texibuf->x + x) * 4;
+ uchar *b = (uchar *)ibuf->rect + (y * ibuf->x + x) * 4;
+ uchar *t = (uchar *)texibuf->rect + (y * texibuf->x + x) * 4;
/* read from old texture buffer */
if (use_texture_old) {
- unsigned char *ot = (unsigned char *)oldtexibuf->rect +
- ((y - origy + yt) * oldtexibuf->x + (x - origx + xt)) * 4;
+ uchar *ot = (uchar *)oldtexibuf->rect +
+ ((y - origy + yt) * oldtexibuf->x + (x - origx + xt)) * 4;
crgba[0] = ot[0];
crgba[1] = ot[1];
crgba[2] = ot[2];
@@ -975,7 +972,7 @@ static void paint_2d_ibuf_rgb_get(ImBuf *ibuf, int x, int y, float r_rgb[4])
copy_v4_v4(r_rgb, rrgbf);
}
else {
- unsigned char *rrgb = (unsigned char *)ibuf->rect + (ibuf->x * y + x) * 4;
+ uchar *rrgb = (uchar *)ibuf->rect + (ibuf->x * y + x) * 4;
straight_uchar_to_premul_float(r_rgb, rrgb);
}
}
@@ -1001,8 +998,8 @@ static void paint_2d_ibuf_rgb_set(
rrgbf[3] = rgb[3];
}
else {
- unsigned char straight[4];
- unsigned char *rrgb = (unsigned char *)ibuf->rect + (ibuf->x * y + x) * 4;
+ uchar straight[4];
+ uchar *rrgb = (uchar *)ibuf->rect + (ibuf->x * y + x) * 4;
premul_float_to_straight_uchar(straight, rgb);
rrgb[0] = straight[0];
@@ -1329,7 +1326,7 @@ static void paint_2d_do_making_brush(ImagePaintState *s,
for (int ty = tiley; ty <= tileh; ty++) {
for (int tx = tilex; tx <= tilew; tx++) {
/* retrieve original pixels + mask from undo buffer */
- unsigned short *mask;
+ ushort *mask;
int origx = region->destx - tx * ED_IMAGE_UNDO_TILE_SIZE;
int origy = region->desty - ty * ED_IMAGE_UNDO_TILE_SIZE;
@@ -1829,7 +1826,7 @@ static void paint_2d_fill_add_pixel_byte(const int x_px,
if (!BLI_BITMAP_TEST(touched, coordinate)) {
float color_f[4];
- unsigned char *color_b = (unsigned char *)(ibuf->rect + coordinate);
+ uchar *color_b = (uchar *)(ibuf->rect + coordinate);
rgba_uchar_to_float(color_f, color_b);
straight_to_premul_v4(color_f);
@@ -1895,7 +1892,7 @@ void paint_2d_bucket_fill(const bContext *C,
ImBuf *ibuf;
int x_px, y_px;
- unsigned int color_b;
+ uint color_b;
float color_f[4];
float strength = br ? BKE_brush_alpha_get(s->scene, br) : 1.0f;
@@ -1935,7 +1932,7 @@ void paint_2d_bucket_fill(const bContext *C,
* be in gamma space. strictly speaking this is not correct, but blender does not paint
* byte images in linear space */
if (!do_float) {
- linearrgb_to_srgb_uchar3((unsigned char *)&color_b, color);
+ linearrgb_to_srgb_uchar3((uchar *)&color_b, color);
*(((char *)&color_b) + 3) = strength * 255;
}
else {
@@ -1959,9 +1956,9 @@ void paint_2d_bucket_fill(const bContext *C,
else {
for (x_px = 0; x_px < ibuf->x; x_px++) {
for (y_px = 0; y_px < ibuf->y; y_px++) {
- blend_color_mix_byte((unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
- (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
- (unsigned char *)&color_b);
+ blend_color_mix_byte((uchar *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
+ (uchar *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
+ (uchar *)&color_b);
}
}
}
@@ -2000,7 +1997,7 @@ void paint_2d_bucket_fill(const bContext *C,
}
else {
int pixel_color_b = *(ibuf->rect + coordinate);
- rgba_uchar_to_float(pixel_color, (unsigned char *)&pixel_color_b);
+ rgba_uchar_to_float(pixel_color, (uchar *)&pixel_color_b);
straight_to_premul_v4(pixel_color);
}
@@ -2055,9 +2052,9 @@ void paint_2d_bucket_fill(const bContext *C,
while (!BLI_stack_is_empty(stack)) {
BLI_stack_pop(stack, &coordinate);
- IMB_blend_color_byte((unsigned char *)(ibuf->rect + coordinate),
- (unsigned char *)(ibuf->rect + coordinate),
- (unsigned char *)&color_b,
+ IMB_blend_color_byte((uchar *)(ibuf->rect + coordinate),
+ (uchar *)(ibuf->rect + coordinate),
+ (uchar *)&color_b,
br->blend);
/* reconstruct the coordinates here */
@@ -2117,7 +2114,7 @@ void paint_2d_gradient_fill(
ImBuf *ibuf;
int x_px, y_px;
- unsigned int color_b;
+ uint color_b;
float color_f[4];
float image_init[2], image_final[2];
float tangent[2];
@@ -2212,11 +2209,11 @@ void paint_2d_gradient_fill(
BKE_colorband_evaluate(br->gradient, f, color_f);
linearrgb_to_srgb_v3_v3(color_f, color_f);
- rgba_float_to_uchar((unsigned char *)&color_b, color_f);
- ((unsigned char *)&color_b)[3] *= brush_alpha;
- IMB_blend_color_byte((unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
- (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
- (unsigned char *)&color_b,
+ rgba_float_to_uchar((uchar *)&color_b, color_f);
+ ((uchar *)&color_b)[3] *= brush_alpha;
+ IMB_blend_color_byte((uchar *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
+ (uchar *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
+ (uchar *)&color_b,
br->blend);
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index c56ce8fd183..0b99806109a 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -112,7 +112,7 @@ static void partial_redraw_array_init(ImagePaintPartialRedraw *pr);
/* Defines and Structs */
/* unit_float_to_uchar_clamp as inline function */
-BLI_INLINE unsigned char f_to_char(const float val)
+BLI_INLINE uchar f_to_char(const float val)
{
return unit_float_to_uchar_clamp(val);
}
@@ -206,7 +206,7 @@ typedef struct ProjPaintImage {
volatile void **undoRect;
/** The mask accumulation must happen on canvas, not on space screen bucket.
* Here we store the mask rectangle. */
- unsigned short **maskRect;
+ ushort **maskRect;
/** Store flag to enforce validation of undo rectangle. */
bool **valid;
bool touch;
@@ -279,7 +279,7 @@ typedef struct ProjPaintState {
/** bucketRect aligned array linkList of faces overlapping each bucket. */
LinkNode **bucketFaces;
/** store if the bucks have been initialized. */
- unsigned char *bucketFlags;
+ uchar *bucketFlags;
/** store options per vert, now only store if the vert is pointing away from the view. */
char *vertFlags;
@@ -443,13 +443,13 @@ typedef union pixelPointer {
/** float buffer. */
float *f_pt;
/** 2 ways to access a char buffer. */
- unsigned int *uint_pt;
- unsigned char *ch_pt;
+ uint *uint_pt;
+ uchar *ch_pt;
} PixelPointer;
typedef union pixelStore {
- unsigned char ch[4];
- unsigned int uint;
+ uchar ch[4];
+ uint uint;
float f[4];
} PixelStore;
@@ -461,17 +461,17 @@ typedef struct ProjPixel {
short x_px, y_px;
/** if anyone wants to paint onto more than 65535 images they can bite me. */
- unsigned short image_index;
- unsigned char bb_cell_index;
+ ushort image_index;
+ uchar bb_cell_index;
/* for various reasons we may want to mask out painting onto this pixel */
- unsigned short mask;
+ ushort mask;
/* Only used when the airbrush is disabled.
* Store the max mask value to avoid painting over an area with a lower opacity
* with an advantage that we can avoid touching the pixel at all, if the
* new mask value is lower then mask_accum */
- unsigned short *mask_accum;
+ ushort *mask_accum;
/* horrible hack, store tile valid flag pointer here to re-validate tiles
* used for anchored and drag-dot strokes */
@@ -491,7 +491,7 @@ typedef struct ProjPixelClone {
typedef struct {
SpinLock *lock;
bool masked;
- unsigned short tile_width;
+ ushort tile_width;
ImBuf **tmpibuf;
ProjPaintImage *pjima;
} TileInfo;
@@ -717,11 +717,8 @@ static void uvco_to_wrapped_pxco(const float uv[2], int ibuf_x, int ibuf_y, floa
/* Set the top-most face color that the screen space coord 'pt' touches
* (or return 0 if none touch) */
-static bool project_paint_PickColor(const ProjPaintState *ps,
- const float pt[2],
- float *rgba_fp,
- unsigned char *rgba,
- const bool interp)
+static bool project_paint_PickColor(
+ const ProjPaintState *ps, const float pt[2], float *rgba_fp, uchar *rgba, const bool interp)
{
const MLoopTri *lt;
const float *lt_tri_uv[3];
@@ -774,7 +771,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
bilinear_interpolation_color_wrap(ibuf, rgba, NULL, x, y);
}
else {
- unsigned char rgba_tmp[4];
+ uchar rgba_tmp[4];
bilinear_interpolation_color_wrap(ibuf, rgba_tmp, NULL, x, y);
straight_uchar_to_premul_float(rgba_fp, rgba_tmp);
}
@@ -795,8 +792,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
premul_float_to_straight_uchar(rgba, rgba_tmp_fp);
}
else {
- *((unsigned int *)rgba) = *(unsigned int *)(((char *)ibuf->rect) +
- ((xi + yi * ibuf->x) * 4));
+ *((uint *)rgba) = *(uint *)(((char *)ibuf->rect) + ((xi + yi * ibuf->x) * 4));
}
}
@@ -805,7 +801,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
copy_v4_v4(rgba_fp, (ibuf->rect_float + ((xi + yi * ibuf->x) * 4)));
}
else {
- unsigned char *tmp_ch = ((unsigned char *)ibuf->rect) + ((xi + yi * ibuf->x) * 4);
+ uchar *tmp_ch = ((uchar *)ibuf->rect) + ((xi + yi * ibuf->x) * 4);
straight_uchar_to_premul_float(rgba_fp, tmp_ch);
}
}
@@ -1150,8 +1146,8 @@ static bool check_seam(const ProjPaintState *ps,
const MLoopTri *orig_lt = &ps->mlooptri_eval[orig_face];
const float *orig_lt_tri_uv[3] = {PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, orig_lt)};
/* vert indices from face vert order indices */
- const unsigned int i1 = ps->mloop_eval[orig_lt->tri[orig_i1_fidx]].v;
- const unsigned int i2 = ps->mloop_eval[orig_lt->tri[orig_i2_fidx]].v;
+ const uint i1 = ps->mloop_eval[orig_lt->tri[orig_i1_fidx]].v;
+ const uint i2 = ps->mloop_eval[orig_lt->tri[orig_i2_fidx]].v;
LinkNode *node;
/* index in face */
int i1_fidx = -1, i2_fidx = -1;
@@ -1641,7 +1637,7 @@ static float screen_px_line_point_factor_v2_persp(const ProjPaintState *ps,
static void project_face_pixel(const float *lt_tri_uv[3],
ImBuf *ibuf_other,
const float w[3],
- unsigned char rgba_ub[4],
+ uchar rgba_ub[4],
float rgba_f[4])
{
float uv_other[2], x, y;
@@ -1677,7 +1673,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps,
const float *lt_other_tri_uv[3] = {PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, lt_other)};
/* BKE_image_acquire_ibuf - TODO - this may be slow */
- unsigned char rgba_ub[4];
+ uchar rgba_ub[4];
float rgba_f[4];
project_face_pixel(lt_other_tri_uv, ibuf_other, w, rgba_ub, rgba_f);
@@ -1937,8 +1933,8 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
zero_v4(projPixel->newColor.f);
}
else {
- projPixel->pixel.ch_pt = (unsigned char *)(ibuf->rect + (x_px + y_px * ibuf->x));
- projPixel->origColor.uint_pt = (unsigned int *)projima->undoRect[tile_index] + tile_offset;
+ projPixel->pixel.ch_pt = (uchar *)(ibuf->rect + (x_px + y_px * ibuf->x));
+ projPixel->origColor.uint_pt = (uint *)projima->undoRect[tile_index] + tile_offset;
projPixel->newColor.uint = 0;
}
@@ -1952,7 +1948,7 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
projPixel->x_px = x_px;
projPixel->y_px = y_px;
- projPixel->mask = (unsigned short)(mask * 65535);
+ projPixel->mask = (ushort)(mask * 65535);
if (ps->do_masking) {
projPixel->mask_accum = projima->maskRect[tile_index] + tile_offset;
}
@@ -1984,7 +1980,7 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
lt_other_tri_uv, ibuf_other, w, NULL, ((ProjPixelClone *)projPixel)->clonepx.f);
}
else { /* from char to float */
- unsigned char rgba_ub[4];
+ uchar rgba_ub[4];
float rgba[4];
project_face_pixel(lt_other_tri_uv, ibuf_other, w, rgba_ub, NULL);
if (ps->use_colormanagement) {
@@ -4844,15 +4840,15 @@ typedef struct ProjectHandle {
static void do_projectpaint_clone(ProjPaintState *ps, ProjPixel *projPixel, float mask)
{
- const unsigned char *clone_pt = ((ProjPixelClone *)projPixel)->clonepx.ch;
+ const uchar *clone_pt = ((ProjPixelClone *)projPixel)->clonepx.ch;
if (clone_pt[3]) {
- unsigned char clone_rgba[4];
+ uchar clone_rgba[4];
clone_rgba[0] = clone_pt[0];
clone_rgba[1] = clone_pt[1];
clone_rgba[2] = clone_pt[2];
- clone_rgba[3] = (unsigned char)(clone_pt[3] * mask);
+ clone_rgba[3] = (uchar)(clone_pt[3] * mask);
if (ps->do_masking) {
IMB_blend_color_byte(
@@ -4895,7 +4891,7 @@ static void do_projectpaint_smear(ProjPaintState *ps,
LinkNode **smearPixels,
const float co[2])
{
- unsigned char rgba_ub[4];
+ uchar rgba_ub[4];
if (project_paint_PickColor(ps, co, NULL, rgba_ub, 1) == 0) {
return;
@@ -5016,7 +5012,7 @@ static void do_projectpaint_soften(ProjPaintState *ps,
}
if (LIKELY(accum_tot != 0)) {
- unsigned char *rgba_ub = projPixel->newColor.ch;
+ uchar *rgba_ub = projPixel->newColor.ch;
mul_v4_fl(rgba, 1.0f / (float)accum_tot);
@@ -5061,7 +5057,7 @@ static void do_projectpaint_draw(ProjPaintState *ps,
float v)
{
float rgb[3];
- unsigned char rgba_ub[4];
+ uchar rgba_ub[4];
if (ps->is_texbrush) {
mul_v3_v3v3(rgb, texrgb, ps->paint_color_linear);
@@ -5119,7 +5115,7 @@ static void do_projectpaint_draw_f(ProjPaintState *ps,
static void do_projectpaint_mask(ProjPaintState *ps, ProjPixel *projPixel, float mask)
{
- unsigned char rgba_ub[4];
+ uchar rgba_ub[4];
rgba_ub[0] = rgba_ub[1] = rgba_ub[2] = ps->stencil_value * 255.0f;
rgba_ub[3] = f_to_char(mask);
@@ -5204,7 +5200,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool),
/* for smear only */
float pos_ofs[2] = {0};
float co[2];
- unsigned short mask_short;
+ ushort mask_short;
const float brush_alpha = BKE_brush_alpha_get(ps->scene, brush);
const float brush_radius = ps->brush_size;
/* avoid a square root with every dist comparison */
@@ -5468,7 +5464,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool),
}
mask = min_ff(mask, 65535.0f);
- mask_short = (unsigned short)mask;
+ mask_short = (ushort)mask;
if (mask_short > *projPixel->mask_accum) {
*projPixel->mask_accum = mask_short;
@@ -6228,13 +6224,13 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
int maxsize;
char err_out[256] = "unknown";
- ScrArea *sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0);
- if (!sa) {
+ ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0);
+ if (!area) {
BKE_report(op->reports, RPT_ERROR, "No 3D viewport found to create image from");
return OPERATOR_CANCELLED;
}
- ARegion *region = BKE_area_find_region_active_win(sa);
+ ARegion *region = BKE_area_find_region_active_win(area);
if (!region) {
BKE_report(op->reports, RPT_ERROR, "No 3D viewport found to create image from");
return OPERATOR_CANCELLED;
@@ -6254,7 +6250,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
/* Create a copy of the overlays where they are all turned off, except the
* texture paint overlay opacity */
- View3D *v3d = sa->spacedata.first;
+ View3D *v3d = area->spacedata.first;
View3D v3d_copy = *v3d;
v3d_copy.gridflag = 0;
v3d_copy.flag2 = 0;
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index cc848b80bb3..d607b6a9d6f 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -397,7 +397,7 @@ static int palette_sort_exec(bContext *C, wmOperator *op)
color_array = MEM_calloc_arrayN(totcol, sizeof(tPaletteColorHSV), __func__);
/* Put all colors in an array. */
int t = 0;
- for (PaletteColor *color = palette->colors.first; color; color = color->next) {
+ LISTBASE_FOREACH (PaletteColor *, color, &palette->colors) {
float h, s, v;
rgb_to_hsv(color->rgb[0], color->rgb[1], color->rgb[2], &h, &s, &v);
col_elm = &color_array[t];
@@ -543,7 +543,7 @@ static int palette_join_exec(bContext *C, wmOperator *op)
const int totcol = BLI_listbase_count(&palette_join->colors);
if (totcol > 0) {
- for (PaletteColor *color = palette_join->colors.first; color; color = color->next) {
+ LISTBASE_FOREACH (PaletteColor *, color, &palette_join->colors) {
PaletteColor *palcol = BKE_palette_color_add(palette);
if (palcol) {
copy_v3_v3(palcol->rgb, color->rgb);
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 935b9ef9506..e7bc75be45d 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -1597,13 +1597,14 @@ bool paint_poll(bContext *C)
{
Paint *p = BKE_paint_get_active_from_context(C);
Object *ob = CTX_data_active_object(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- if (p && ob && BKE_paint_brush(p) && (sa && ELEM(sa->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) &&
+ if (p && ob && BKE_paint_brush(p) &&
+ (area && ELEM(area->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) &&
(region && region->regiontype == RGN_TYPE_WINDOW)) {
/* Check the current tool is a brush. */
- bToolRef *tref = sa->runtime.tool;
+ bToolRef *tref = area->runtime.tool;
if (tref && tref->runtime && tref->runtime->data_block[0]) {
return true;
}
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index e67d43d4571..60b4a2f8e0c 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -294,12 +294,8 @@ static void imapaint_tri_weights(float matrix[4][4],
}
/* compute uv coordinates of mouse in face */
-static void imapaint_pick_uv(Mesh *me_eval,
- Scene *scene,
- Object *ob_eval,
- unsigned int faceindex,
- const int xy[2],
- float uv[2])
+static void imapaint_pick_uv(
+ Mesh *me_eval, Scene *scene, Object *ob_eval, uint faceindex, const int xy[2], float uv[2])
{
int i, findex;
float p[2], w[3], absw, minabsw;
@@ -376,10 +372,7 @@ static void imapaint_pick_uv(Mesh *me_eval,
}
/* returns 0 if not found, otherwise 1 */
-static int imapaint_pick_face(ViewContext *vc,
- const int mval[2],
- unsigned int *r_index,
- unsigned int totpoly)
+static int imapaint_pick_face(ViewContext *vc, const int mval[2], uint *r_index, uint totpoly)
{
if (totpoly == 0) {
return 0;
@@ -389,7 +382,7 @@ static int imapaint_pick_face(ViewContext *vc,
ED_view3d_select_id_validate(vc);
*r_index = DRW_select_buffer_sample_point(vc->depsgraph, vc->region, vc->v3d, mval);
- if ((*r_index) == 0 || (*r_index) > (unsigned int)totpoly) {
+ if ((*r_index) == 0 || (*r_index) > (uint)totpoly) {
return 0;
}
@@ -464,8 +457,8 @@ void paint_sample_color(
Palette *palette = BKE_paint_palette(paint);
PaletteColor *color = NULL;
Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));
- unsigned int col;
- const unsigned char *cp;
+ uint col;
+ const uchar *cp;
CLAMP(x, 0, region->winx);
CLAMP(y, 0, region->winy);
@@ -497,8 +490,8 @@ void paint_sample_color(
ViewContext vc;
const int mval[2] = {x, y};
- unsigned int faceindex;
- unsigned int totpoly = me->totpoly;
+ uint faceindex;
+ uint totpoly = me->totpoly;
if (CustomData_has_layer(&me_eval->ldata, CD_MLOOPUV)) {
ED_view3d_viewcontext_init(C, &vc, depsgraph);
@@ -563,7 +556,7 @@ void paint_sample_color(
}
}
else {
- unsigned char rgba[4];
+ uchar rgba[4];
bilinear_interpolation_color_wrap(ibuf, rgba, NULL, u, v);
if (use_palette) {
rgb_uchar_to_float(color->rgb, rgba);
@@ -598,7 +591,7 @@ void paint_sample_color(
x + region->winrct.xmin, y + region->winrct.ymin, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
glReadBuffer(GL_BACK);
}
- cp = (unsigned char *)&col;
+ cp = (uchar *)&col;
if (use_palette) {
rgb_uchar_to_float(color->rgb, cp);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 604146e2ca6..d050a39ce68 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -214,8 +214,8 @@ bool vertex_paint_mode_poll(bContext *C)
static bool vertex_paint_poll_ex(bContext *C, bool check_tool)
{
if (vertex_paint_mode_poll(C) && BKE_paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) {
- ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_VIEW3D) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area && area->spacetype == SPACE_VIEW3D) {
ARegion *region = CTX_wm_region(C);
if (region->regiontype == RGN_TYPE_WINDOW) {
if (!check_tool || WM_toolsystem_active_tool_is_brush(C)) {
@@ -247,11 +247,11 @@ bool weight_paint_mode_poll(bContext *C)
static bool weight_paint_poll_ex(bContext *C, bool check_tool)
{
Object *ob = CTX_data_active_object(C);
- ScrArea *sa;
+ ScrArea *area;
if ((ob != NULL) && (ob->mode & OB_MODE_WEIGHT_PAINT) &&
(BKE_paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != NULL) &&
- (sa = CTX_wm_area(C)) && (sa->spacetype == SPACE_VIEW3D)) {
+ (area = CTX_wm_area(C)) && (area->spacetype == SPACE_VIEW3D)) {
ARegion *region = CTX_wm_region(C);
if (ELEM(region->regiontype, RGN_TYPE_WINDOW, RGN_TYPE_HUD)) {
if (!check_tool || WM_toolsystem_active_tool_is_brush(C)) {
@@ -1226,7 +1226,7 @@ static void ed_vwpaintmode_enter_generic(Main *bmain,
BKE_paint_init(bmain, scene, paint_mode, PAINT_CURSOR_WEIGHT_PAINT);
/* weight paint specific */
- ED_mesh_mirror_spatial_table(ob, NULL, NULL, NULL, 's');
+ ED_mesh_mirror_spatial_table_end(ob);
ED_vgroup_sync_from_pose(ob);
}
else {
@@ -1318,8 +1318,8 @@ static void ed_vwpaintmode_exit_generic(Object *ob, const eObjectMode mode_flag)
paint_cursor_delete_textures();
if (mode_flag == OB_MODE_WEIGHT_PAINT) {
- ED_mesh_mirror_spatial_table(NULL, NULL, NULL, NULL, 'e');
- ED_mesh_mirror_topo_table(NULL, NULL, 'e');
+ ED_mesh_mirror_spatial_table_end(ob);
+ ED_mesh_mirror_topo_table_end(ob);
}
/* Never leave derived meshes behind. */
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
index 6e706c907dd..addf7e9f868 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
@@ -109,7 +109,7 @@ static int vertex_color_set_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
- unsigned int paintcol = vpaint_get_current_col(scene, scene->toolsettings->vpaint, false);
+ uint paintcol = vpaint_get_current_col(scene, scene->toolsettings->vpaint, false);
if (vertex_color_set(obact, paintcol)) {
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obact);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 6ccd197c908..b304a476dec 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -153,7 +153,7 @@ const float *SCULPT_vertex_co_get(SculptSession *ss, int index)
return NULL;
}
-static void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3])
+void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3])
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
@@ -209,14 +209,30 @@ const float *SCULPT_active_vertex_co_get(SculptSession *ss)
return SCULPT_vertex_co_get(ss, SCULPT_active_vertex_get(ss));
}
-static void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3])
+void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3])
{
SCULPT_vertex_normal_get(ss, SCULPT_active_vertex_get(ss), normal);
}
/* Sculpt Face Sets and Visibility. */
-static void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible)
+int SCULPT_active_face_set_get(SculptSession *ss)
+{
+ switch (BKE_pbvh_type(ss->pbvh)) {
+ case PBVH_FACES:
+ return ss->face_sets[ss->active_face_index];
+ case PBVH_GRIDS: {
+ const int face_index = BKE_subdiv_cgg_grid_to_face_index(ss->subdiv_ccg,
+ ss->active_grid_index);
+ return ss->face_sets[face_index];
+ }
+ case PBVH_BMESH:
+ return SCULPT_FACE_SET_NONE;
+ }
+ return SCULPT_FACE_SET_NONE;
+}
+
+void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
@@ -231,7 +247,7 @@ static void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible
}
}
-static bool SCULPT_vertex_visible_get(SculptSession *ss, int index)
+bool SCULPT_vertex_visible_get(SculptSession *ss, int index)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
@@ -244,11 +260,12 @@ static bool SCULPT_vertex_visible_get(SculptSession *ss, int index)
return true;
}
-static void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool visible)
+void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool visible)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
- for (int i = 0; i < ss->totpoly; i++) {
+ case PBVH_GRIDS:
+ for (int i = 0; i < ss->totfaces; i++) {
if (abs(ss->face_sets[i]) == face_set) {
if (visible) {
ss->face_sets[i] = abs(ss->face_sets[i]);
@@ -261,31 +278,29 @@ static void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool
break;
case PBVH_BMESH:
break;
- case PBVH_GRIDS:
- break;
}
}
-static void SCULPT_face_sets_visibility_invert(SculptSession *ss)
+void SCULPT_face_sets_visibility_invert(SculptSession *ss)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
- for (int i = 0; i < ss->totpoly; i++) {
+ case PBVH_GRIDS:
+ for (int i = 0; i < ss->totfaces; i++) {
ss->face_sets[i] *= -1;
}
break;
case PBVH_BMESH:
break;
- case PBVH_GRIDS:
- break;
}
}
-static void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible)
+void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
- for (int i = 0; i < ss->totpoly; i++) {
+ case PBVH_GRIDS:
+ for (int i = 0; i < ss->totfaces; i++) {
/* This can run on geometry without a face set assigned, so its ID sign can't be changed to
* modify the visibility. Force that geometry to the ID 1 to enable changing the visibility
@@ -304,12 +319,10 @@ static void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible)
break;
case PBVH_BMESH:
break;
- case PBVH_GRIDS:
- break;
}
}
-static bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, int index)
+bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, int index)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES: {
@@ -329,7 +342,7 @@ static bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, int index)
return true;
}
-static bool SCULPT_vertex_all_face_sets_visible_get(SculptSession *ss, int index)
+bool SCULPT_vertex_all_face_sets_visible_get(SculptSession *ss, int index)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES: {
@@ -343,13 +356,17 @@ static bool SCULPT_vertex_all_face_sets_visible_get(SculptSession *ss, int index
}
case PBVH_BMESH:
return true;
- case PBVH_GRIDS:
- return true;
+ case PBVH_GRIDS: {
+ const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh);
+ const int grid_index = index / key->grid_area;
+ const int face_index = BKE_subdiv_cgg_grid_to_face_index(ss->subdiv_ccg, grid_index);
+ return ss->face_sets[face_index] > 0;
+ }
}
return true;
}
-static void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_set)
+void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_set)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES: {
@@ -362,8 +379,15 @@ static void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_se
} break;
case PBVH_BMESH:
break;
- case PBVH_GRIDS:
- break;
+ case PBVH_GRIDS: {
+ const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh);
+ const int grid_index = index / key->grid_area;
+ const int face_index = BKE_subdiv_cgg_grid_to_face_index(ss->subdiv_ccg, grid_index);
+ if (ss->face_sets[face_index] > 0) {
+ ss->face_sets[face_index] = abs(face_set);
+ }
+
+ } break;
}
}
@@ -382,8 +406,12 @@ int SCULPT_vertex_face_set_get(SculptSession *ss, int index)
}
case PBVH_BMESH:
return 0;
- case PBVH_GRIDS:
- return 0;
+ case PBVH_GRIDS: {
+ const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh);
+ const int grid_index = index / key->grid_area;
+ const int face_index = BKE_subdiv_cgg_grid_to_face_index(ss->subdiv_ccg, grid_index);
+ return ss->face_sets[face_index];
+ }
}
return 0;
}
@@ -402,8 +430,12 @@ bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set)
}
case PBVH_BMESH:
return true;
- case PBVH_GRIDS:
- return true;
+ case PBVH_GRIDS: {
+ const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh);
+ const int grid_index = index / key->grid_area;
+ const int face_index = BKE_subdiv_cgg_grid_to_face_index(ss->subdiv_ccg, grid_index);
+ return ss->face_sets[face_index] == face_set;
+ }
}
return true;
}
@@ -415,8 +447,18 @@ static void sculpt_visibility_sync_face_sets_to_vertex(SculptSession *ss, int in
void SCULPT_visibility_sync_all_face_sets_to_vertices(SculptSession *ss)
{
- for (int i = 0; i < ss->totvert; i++) {
- sculpt_visibility_sync_face_sets_to_vertex(ss, i);
+ switch (BKE_pbvh_type(ss->pbvh)) {
+ case PBVH_FACES: {
+ for (int i = 0; i < ss->totvert; i++) {
+ sculpt_visibility_sync_face_sets_to_vertex(ss, i);
+ }
+ break;
+ }
+ case PBVH_GRIDS: {
+ BKE_pbvh_sync_face_sets_to_grids(ss->pbvh);
+ }
+ case PBVH_BMESH:
+ break;
}
}
@@ -439,7 +481,7 @@ static void UNUSED_FUNCTION(sculpt_visibility_sync_vertex_to_face_sets)(SculptSe
void SCULPT_visibility_sync_all_vertex_to_face_sets(SculptSession *ss)
{
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
- for (int i = 0; i < ss->totpoly; i++) {
+ for (int i = 0; i < ss->totfaces; i++) {
MPoly *poly = &ss->mpoly[i];
bool poly_visible = true;
for (int l = 0; l < poly->totloop; l++) {
@@ -479,17 +521,18 @@ bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index)
case PBVH_BMESH:
return false;
case PBVH_GRIDS:
- return false;
+ return true;
}
return false;
}
-static int SCULPT_face_set_next_available_get(SculptSession *ss)
+int SCULPT_face_set_next_available_get(SculptSession *ss)
{
switch (BKE_pbvh_type(ss->pbvh)) {
- case PBVH_FACES: {
+ case PBVH_FACES:
+ case PBVH_GRIDS: {
int next_face_set = 0;
- for (int i = 0; i < ss->totpoly; i++) {
+ for (int i = 0; i < ss->totfaces; i++) {
if (abs(ss->face_sets[i]) > next_face_set) {
next_face_set = abs(ss->face_sets[i]);
}
@@ -499,8 +542,6 @@ static int SCULPT_face_set_next_available_get(SculptSession *ss)
}
case PBVH_BMESH:
return 0;
- case PBVH_GRIDS:
- return 0;
}
return 0;
}
@@ -633,7 +674,7 @@ void SCULPT_vertex_neighbors_get(SculptSession *ss,
}
}
-static bool sculpt_vertex_is_boundary(SculptSession *ss, const int index)
+bool SCULPT_vertex_is_boundary(SculptSession *ss, const int index)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES: {
@@ -783,10 +824,10 @@ bool SCULPT_is_symmetry_iteration_valid(char i, char symm)
}
/* Checks if a vertex is inside the brush radius from any of its mirrored axis. */
-static bool sculpt_is_vertex_inside_brush_radius_symm(const float vertex[3],
- const float br_co[3],
- float radius,
- char symm)
+bool SCULPT_is_vertex_inside_brush_radius_symm(const float vertex[3],
+ const float br_co[3],
+ float radius,
+ char symm)
{
for (char i = 0; i <= symm; ++i) {
if (SCULPT_is_symmetry_iteration_valid(i, symm)) {
@@ -813,7 +854,7 @@ void SCULPT_floodfill_init(SculptSession *ss, SculptFloodFill *flood)
flood->visited_vertices = MEM_callocN(vertex_count * sizeof(char), "visited vertices");
}
-void sculpt_floodfill_add_initial(SculptFloodFill *flood, int index)
+void SCULPT_floodfill_add_initial(SculptFloodFill *flood, int index)
{
BLI_gsqueue_push(flood->queue, &index);
}
@@ -836,7 +877,7 @@ void SCULPT_floodfill_add_initial_with_symmetry(
v = SCULPT_nearest_vertex_get(sd, ob, location, radius_squared, false);
}
if (v != -1) {
- sculpt_floodfill_add_initial(flood, v);
+ SCULPT_floodfill_add_initial(flood, v);
}
}
}
@@ -860,7 +901,7 @@ void SCULPT_floodfill_add_active(
v = SCULPT_nearest_vertex_get(sd, ob, location, radius_squared, false);
}
if (v != -1) {
- sculpt_floodfill_add_initial(flood, v);
+ SCULPT_floodfill_add_initial(flood, v);
}
}
}
@@ -1155,7 +1196,7 @@ static void sculpt_project_v3(const SculptProjectVector *spvc, const float vec[3
* Factors: some brushes like grab cannot do dynamic topology.
* Others, like smooth, are better without. Same goes for alt-
* key smoothing. */
-static bool sculpt_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *brush)
+bool SCULPT_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *brush)
{
return ((BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) &&
@@ -1544,220 +1585,6 @@ static bool sculpt_brush_test_cyl(SculptBrushTest *test,
#endif
-/* Automasking */
-
-static bool sculpt_automasking_enabled(SculptSession *ss, const Brush *br)
-{
- if (sculpt_stroke_is_dynamic_topology(ss, br)) {
- return false;
- }
- if (br->automasking_flags & BRUSH_AUTOMASKING_TOPOLOGY) {
- return true;
- }
- if (br->automasking_flags & BRUSH_AUTOMASKING_FACE_SETS) {
- return true;
- }
- if (br->automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) {
- return true;
- }
- return false;
-}
-
-float SCULPT_automasking_factor_get(SculptSession *ss, int vert)
-{
- if (ss->cache->automask) {
- return ss->cache->automask[vert];
- }
- else {
- return 1.0f;
- }
-}
-
-static void sculpt_automasking_end(Object *ob)
-{
- SculptSession *ss = ob->sculpt;
- if (ss->cache && ss->cache->automask) {
- MEM_freeN(ss->cache->automask);
- }
-}
-
-static bool sculpt_automasking_is_constrained_by_radius(Brush *br)
-{
- /* 2D falloff is not constrained by radius. */
- if (br->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
- return false;
- }
-
- if (ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE)) {
- return true;
- }
- return false;
-}
-
-typedef struct AutomaskFloodFillData {
- float *automask_factor;
- float radius;
- bool use_radius;
- float location[3];
- char symm;
-} AutomaskFloodFillData;
-
-static bool automask_floodfill_cb(
- SculptSession *ss, int UNUSED(from_v), int to_v, bool UNUSED(is_duplicate), void *userdata)
-{
- AutomaskFloodFillData *data = userdata;
-
- data->automask_factor[to_v] = 1.0f;
- return (!data->use_radius ||
- sculpt_is_vertex_inside_brush_radius_symm(
- SCULPT_vertex_co_get(ss, to_v), data->location, data->radius, data->symm));
-}
-
-static float *sculpt_topology_automasking_init(Sculpt *sd, Object *ob, float *automask_factor)
-{
- SculptSession *ss = ob->sculpt;
- Brush *brush = BKE_paint_brush(&sd->paint);
-
- if (!sculpt_automasking_enabled(ss, brush)) {
- return NULL;
- }
-
- if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) {
- BLI_assert(!"Topology masking: pmap missing");
- return NULL;
- }
-
- const int totvert = SCULPT_vertex_count_get(ss);
- for (int i = 0; i < totvert; i++) {
- ss->cache->automask[i] = 0.0f;
- }
-
- /* Flood fill automask to connected vertices. Limited to vertices inside
- * the brush radius if the tool requires it. */
- SculptFloodFill flood;
- SCULPT_floodfill_init(ss, &flood);
- SCULPT_floodfill_add_active(sd, ob, ss, &flood, ss->cache->radius);
-
- AutomaskFloodFillData fdata = {
- .automask_factor = automask_factor,
- .radius = ss->cache->radius,
- .use_radius = sculpt_automasking_is_constrained_by_radius(brush),
- .symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL,
- };
- copy_v3_v3(fdata.location, SCULPT_active_vertex_co_get(ss));
- SCULPT_floodfill_execute(ss, &flood, automask_floodfill_cb, &fdata);
- SCULPT_floodfill_free(&flood);
-
- return automask_factor;
-}
-
-static float *sculpt_face_sets_automasking_init(Sculpt *sd, Object *ob, float *automask_factor)
-{
- SculptSession *ss = ob->sculpt;
- Brush *brush = BKE_paint_brush(&sd->paint);
-
- if (!sculpt_automasking_enabled(ss, brush)) {
- return NULL;
- }
-
- if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) {
- BLI_assert(!"Face Sets automasking: pmap missing");
- return NULL;
- }
-
- int tot_vert = SCULPT_vertex_count_get(ss);
- int active_face_set = SCULPT_vertex_face_set_get(ss, SCULPT_active_vertex_get(ss));
- for (int i = 0; i < tot_vert; i++) {
- if (!SCULPT_vertex_has_face_set(ss, i, active_face_set)) {
- automask_factor[i] *= 0.0f;
- }
- }
-
- return automask_factor;
-}
-
-#define EDGE_DISTANCE_INF -1
-
-static float *sculpt_boundary_edges_automasking_init(Object *ob,
- int propagation_steps,
- float *automask_factor)
-{
- SculptSession *ss = ob->sculpt;
-
- if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) {
- BLI_assert(!"Boundary Edges masking: pmap missing");
- return NULL;
- }
-
- const int totvert = SCULPT_vertex_count_get(ss);
- int *edge_distance = MEM_callocN(sizeof(int) * totvert, "automask_factor");
-
- for (int i = 0; i < totvert; i++) {
- edge_distance[i] = EDGE_DISTANCE_INF;
- if (!sculpt_vertex_is_boundary(ss, i)) {
- edge_distance[i] = 0;
- }
- }
-
- for (int propagation_it = 0; propagation_it < propagation_steps; propagation_it++) {
- for (int i = 0; i < totvert; i++) {
- if (edge_distance[i] == EDGE_DISTANCE_INF) {
- SculptVertexNeighborIter ni;
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, i, ni) {
- if (edge_distance[ni.index] == propagation_it) {
- edge_distance[i] = propagation_it + 1;
- }
- }
- SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
- }
- }
- }
-
- for (int i = 0; i < totvert; i++) {
- if (edge_distance[i] != EDGE_DISTANCE_INF) {
- const float p = 1.0f - ((float)edge_distance[i] / (float)propagation_steps);
- const float edge_boundary_automask = 3.0f * p * p - 2.0f * p * p * p;
- automask_factor[i] *= (1.0f - edge_boundary_automask);
- }
- }
-
- MEM_SAFE_FREE(edge_distance);
- return automask_factor;
-}
-
-static void sculpt_automasking_init(Sculpt *sd, Object *ob)
-{
- SculptSession *ss = ob->sculpt;
- Brush *brush = BKE_paint_brush(&sd->paint);
- const int totvert = SCULPT_vertex_count_get(ss);
-
- if (!sculpt_automasking_enabled(ss, brush)) {
- return;
- }
-
- ss->cache->automask = MEM_callocN(sizeof(float) * SCULPT_vertex_count_get(ss),
- "automask_factor");
-
- for (int i = 0; i < totvert; i++) {
- ss->cache->automask[i] = 1.0f;
- }
-
- if (brush->automasking_flags & BRUSH_AUTOMASKING_TOPOLOGY) {
- SCULPT_vertex_random_access_init(ss);
- sculpt_topology_automasking_init(sd, ob, ss->cache->automask);
- }
- if (brush->automasking_flags & BRUSH_AUTOMASKING_FACE_SETS) {
- SCULPT_vertex_random_access_init(ss);
- sculpt_face_sets_automasking_init(sd, ob, ss->cache->automask);
- }
-
- if (brush->automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) {
- SCULPT_vertex_random_access_init(ss);
- sculpt_boundary_edges_automasking_init(
- ob, brush->automasking_boundary_edges_propagation_steps, ss->cache->automask);
- }
-}
-
/* ===== Sculpting =====
*/
static void flip_v3(float v[3], const ePaintSymmetryFlags symm)
@@ -2071,7 +1898,7 @@ static void calc_area_center(
{
const Brush *brush = BKE_paint_brush(&sd->paint);
SculptSession *ss = ob->sculpt;
- const bool has_bm_orco = ss->bm && sculpt_stroke_is_dynamic_topology(ss, brush);
+ const bool has_bm_orco = ss->bm && SCULPT_stroke_is_dynamic_topology(ss, brush);
int n;
/* Intentionally set 'sd' to NULL since we share logic with vertex paint. */
@@ -2130,7 +1957,7 @@ bool SCULPT_pbvh_calc_area_normal(const Brush *brush,
float r_area_no[3])
{
SculptSession *ss = ob->sculpt;
- const bool has_bm_orco = ss->bm && sculpt_stroke_is_dynamic_topology(ss, brush);
+ const bool has_bm_orco = ss->bm && SCULPT_stroke_is_dynamic_topology(ss, brush);
/* Intentionally set 'sd' to NULL since this is used for vertex paint too. */
SculptThreadedTaskData data = {
@@ -2170,7 +1997,7 @@ static void calc_area_normal_and_center(
{
const Brush *brush = BKE_paint_brush(&sd->paint);
SculptSession *ss = ob->sculpt;
- const bool has_bm_orco = ss->bm && sculpt_stroke_is_dynamic_topology(ss, brush);
+ const bool has_bm_orco = ss->bm && SCULPT_stroke_is_dynamic_topology(ss, brush);
int n;
/* Intentionally set 'sd' to NULL since this is used for vertex paint too. */
@@ -2532,7 +2359,7 @@ bool SCULPT_search_circle_cb(PBVHNode *node, void *data_v)
}
/* Handles clipping against a mirror modifier and SCULPT_LOCK axis flags. */
-static void sculpt_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3])
+void SCULPT_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3])
{
for (int i = 0; i < 3; i++) {
if (sd->flags & (SCULPT_LOCK_X << i)) {
@@ -2737,225 +2564,6 @@ static void update_brush_local_mat(Sculpt *sd, Object *ob)
}
}
-/* For the smooth brush, uses the neighboring vertices around vert to calculate
- * a smoothed location for vert. Skips corner vertices (used by only one
- * polygon). */
-static void neighbor_average(SculptSession *ss, float avg[3], uint vert)
-{
- const MeshElemMap *vert_map = &ss->pmap[vert];
- const MVert *mvert = ss->mvert;
- float(*deform_co)[3] = ss->deform_cos;
-
- /* Don't modify corner vertices. */
- if (vert_map->count > 1) {
- int total = 0;
-
- zero_v3(avg);
-
- for (int i = 0; i < vert_map->count; i++) {
- const MPoly *p = &ss->mpoly[vert_map->indices[i]];
- uint f_adj_v[2];
-
- if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) {
- for (int j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) {
- if (vert_map->count != 2 || ss->pmap[f_adj_v[j]].count <= 2) {
- add_v3_v3(avg, deform_co ? deform_co[f_adj_v[j]] : mvert[f_adj_v[j]].co);
-
- total++;
- }
- }
- }
- }
-
- if (total > 0) {
- mul_v3_fl(avg, 1.0f / total);
- return;
- }
- }
-
- copy_v3_v3(avg, deform_co ? deform_co[vert] : mvert[vert].co);
-}
-
-/* Similar to neighbor_average(), but returns an averaged mask value
- * instead of coordinate. Also does not restrict based on border or
- * corner vertices. */
-static float neighbor_average_mask(SculptSession *ss, uint vert)
-{
- const float *vmask = ss->vmask;
- float avg = 0.0f;
- int total = 0;
-
- for (int i = 0; i < ss->pmap[vert].count; i++) {
- const MPoly *p = &ss->mpoly[ss->pmap[vert].indices[i]];
- uint f_adj_v[2];
-
- if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) {
- for (int j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) {
- avg += vmask[f_adj_v[j]];
- total++;
- }
- }
- }
-
- if (total > 0) {
- return avg / (float)total;
- }
- else {
- return vmask[vert];
- }
-}
-
-/* Same logic as neighbor_average(), but for bmesh rather than mesh. */
-static void bmesh_neighbor_average(float avg[3], BMVert *v)
-{
- /* logic for 3 or more is identical. */
- const int vfcount = BM_vert_face_count_at_most(v, 3);
-
- /* Don't modify corner vertices. */
- if (vfcount > 1) {
- BMIter liter;
- BMLoop *l;
- int total = 0;
-
- zero_v3(avg);
-
- BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
- const BMVert *adj_v[2] = {l->prev->v, l->next->v};
-
- for (int i = 0; i < ARRAY_SIZE(adj_v); i++) {
- const BMVert *v_other = adj_v[i];
- if (vfcount != 2 || BM_vert_face_count_at_most(v_other, 2) <= 2) {
- add_v3_v3(avg, v_other->co);
- total++;
- }
- }
- }
-
- if (total > 0) {
- mul_v3_fl(avg, 1.0f / total);
- return;
- }
- }
-
- copy_v3_v3(avg, v->co);
-}
-
-/* For bmesh: Average surrounding verts based on an orthogonality measure.
- * Naturally converges to a quad-like structure. */
-static void bmesh_four_neighbor_average(float avg[3], float direction[3], BMVert *v)
-{
-
- float avg_co[3] = {0.0f, 0.0f, 0.0f};
- float tot_co = 0.0f;
-
- BMIter eiter;
- BMEdge *e;
-
- BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
- if (BM_edge_is_boundary(e)) {
- copy_v3_v3(avg, v->co);
- return;
- }
- BMVert *v_other = (e->v1 == v) ? e->v2 : e->v1;
- float vec[3];
- sub_v3_v3v3(vec, v_other->co, v->co);
- madd_v3_v3fl(vec, v->no, -dot_v3v3(vec, v->no));
- normalize_v3(vec);
-
- /* fac is a measure of how orthogonal or parallel the edge is
- * relative to the direction. */
- float fac = dot_v3v3(vec, direction);
- fac = fac * fac - 0.5f;
- fac *= fac;
- madd_v3_v3fl(avg_co, v_other->co, fac);
- tot_co += fac;
- }
-
- /* In case vert has no Edge s. */
- if (tot_co > 0.0f) {
- mul_v3_v3fl(avg, avg_co, 1.0f / tot_co);
-
- /* Preserve volume. */
- float vec[3];
- sub_v3_v3(avg, v->co);
- mul_v3_v3fl(vec, v->no, dot_v3v3(avg, v->no));
- sub_v3_v3(avg, vec);
- add_v3_v3(avg, v->co);
- }
- else {
- zero_v3(avg);
- }
-}
-
-/* Same logic as neighbor_average_mask(), but for bmesh rather than mesh. */
-static float bmesh_neighbor_average_mask(BMVert *v, const int cd_vert_mask_offset)
-{
- BMIter liter;
- BMLoop *l;
- float avg = 0.0f;
- int total = 0;
-
- BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
- /* Skip this vertex. */
- const BMVert *adj_v[2] = {l->prev->v, l->next->v};
-
- for (int i = 0; i < ARRAY_SIZE(adj_v); i++) {
- const BMVert *v_other = adj_v[i];
- const float *vmask = BM_ELEM_CD_GET_VOID_P(v_other, cd_vert_mask_offset);
- avg += (*vmask);
- total++;
- }
- }
-
- if (total > 0) {
- return avg / (float)total;
- }
- else {
- const float *vmask = BM_ELEM_CD_GET_VOID_P(v, cd_vert_mask_offset);
- return (*vmask);
- }
-}
-
-static void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], int index)
-{
- float avg[3] = {0.0f, 0.0f, 0.0f};
- int total = 0;
-
- SculptVertexNeighborIter ni;
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, index, ni) {
- add_v3_v3(avg, SCULPT_vertex_co_get(ss, ni.index));
- total++;
- }
- SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
-
- if (total > 0) {
- mul_v3_v3fl(result, avg, 1.0f / (float)total);
- }
- else {
- copy_v3_v3(result, SCULPT_vertex_co_get(ss, index));
- }
-}
-
-static float grids_neighbor_average_mask(SculptSession *ss, int index)
-{
- float avg = 0.0f;
- int total = 0;
-
- SculptVertexNeighborIter ni;
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, index, ni) {
- avg += SCULPT_vertex_mask_get(ss, ni.index);
- total++;
- }
- SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
-
- if (total > 0) {
- return avg / (float)total;
- }
- else {
- return SCULPT_vertex_mask_get(ss, index);
- }
-}
-
/* Note: uses after-struct allocated mem to store actual cache... */
typedef struct SculptDoBrushSmoothGridDataChunk {
size_t tmpgrid_size;
@@ -2972,17 +2580,10 @@ typedef struct {
int active_vertex_index;
float *face_normal;
- struct IsectRayPrecalc isect_precalc;
-} SculptRaycastData;
-
-typedef struct {
- const float *ray_start;
- bool hit;
- float depth;
- float edge_length;
+ int active_face_grid_index;
struct IsectRayPrecalc isect_precalc;
-} SculptDetailRaycastData;
+} SculptRaycastData;
typedef struct {
SculptSession *ss;
@@ -2993,119 +2594,6 @@ typedef struct {
bool original;
} SculptFindNearestToRayData;
-static void do_smooth_brush_mesh_task_cb_ex(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- Sculpt *sd = data->sd;
- const Brush *brush = data->brush;
- const bool smooth_mask = data->smooth_mask;
- float bstrength = data->strength;
-
- PBVHVertexIter vd;
-
- CLAMP(bstrength, 0.0f, 1.0f);
-
- SculptBrushTest test;
- SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
- ss, &test, data->brush->falloff_shape);
-
- BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
- {
- if (sculpt_brush_test_sq_fn(&test, vd.co)) {
- const float fade = bstrength * SCULPT_brush_strength_factor(
- ss,
- brush,
- vd.co,
- sqrtf(test.dist),
- vd.no,
- vd.fno,
- smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f),
- vd.index,
- tls->thread_id);
- if (smooth_mask) {
- float val = neighbor_average_mask(ss, vd.vert_indices[vd.i]) - *vd.mask;
- val *= fade * bstrength;
- *vd.mask += val;
- CLAMP(*vd.mask, 0.0f, 1.0f);
- }
- else {
- float avg[3], val[3];
-
- neighbor_average(ss, avg, vd.vert_indices[vd.i]);
- sub_v3_v3v3(val, avg, vd.co);
-
- madd_v3_v3v3fl(val, vd.co, val, fade);
-
- sculpt_clip(sd, ss, vd.co, val);
- }
-
- if (vd.mvert) {
- vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
- }
- }
- }
- BKE_pbvh_vertex_iter_end;
-}
-
-static void do_smooth_brush_bmesh_task_cb_ex(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- Sculpt *sd = data->sd;
- const Brush *brush = data->brush;
- const bool smooth_mask = data->smooth_mask;
- float bstrength = data->strength;
-
- PBVHVertexIter vd;
-
- CLAMP(bstrength, 0.0f, 1.0f);
-
- SculptBrushTest test;
- SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
- ss, &test, data->brush->falloff_shape);
-
- BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
- {
- if (sculpt_brush_test_sq_fn(&test, vd.co)) {
- const float fade = bstrength * SCULPT_brush_strength_factor(ss,
- brush,
- vd.co,
- sqrtf(test.dist),
- vd.no,
- vd.fno,
- smooth_mask ? 0.0f : *vd.mask,
- vd.index,
- tls->thread_id);
- if (smooth_mask) {
- float val = bmesh_neighbor_average_mask(vd.bm_vert, vd.cd_vert_mask_offset) - *vd.mask;
- val *= fade * bstrength;
- *vd.mask += val;
- CLAMP(*vd.mask, 0.0f, 1.0f);
- }
- else {
- float avg[3], val[3];
-
- bmesh_neighbor_average(avg, vd.bm_vert);
- sub_v3_v3v3(val, avg, vd.co);
-
- madd_v3_v3v3fl(val, vd.co, val, fade);
-
- sculpt_clip(sd, ss, vd.co, val);
- }
-
- if (vd.mvert) {
- vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
- }
- }
- }
- BKE_pbvh_vertex_iter_end;
-}
-
static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata,
const int n,
const TaskParallelTLS *__restrict tls)
@@ -3154,13 +2642,13 @@ static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata,
float avg[3], val[3];
- bmesh_four_neighbor_average(avg, direction, vd.bm_vert);
+ SCULPT_bmesh_four_neighbor_average(avg, direction, vd.bm_vert);
sub_v3_v3v3(val, avg, vd.co);
madd_v3_v3v3fl(val, vd.co, val, fade);
- sculpt_clip(sd, ss, vd.co, val);
+ SCULPT_clip(sd, ss, vd.co, val);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
@@ -3170,111 +2658,6 @@ static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata,
BKE_pbvh_vertex_iter_end;
}
-static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- Sculpt *sd = data->sd;
- const Brush *brush = data->brush;
- const bool smooth_mask = data->smooth_mask;
- float bstrength = data->strength;
-
- PBVHVertexIter vd;
-
- CLAMP(bstrength, 0.0f, 1.0f);
-
- SculptBrushTest test;
- SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
- ss, &test, data->brush->falloff_shape);
-
- BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
- {
- if (sculpt_brush_test_sq_fn(&test, vd.co)) {
- const float fade = bstrength * SCULPT_brush_strength_factor(
- ss,
- brush,
- vd.co,
- sqrtf(test.dist),
- vd.no,
- vd.fno,
- smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f),
- vd.index,
- tls->thread_id);
- if (smooth_mask) {
- float val = grids_neighbor_average_mask(ss, vd.index) - *vd.mask;
- val *= fade * bstrength;
- *vd.mask += val;
- CLAMP(*vd.mask, 0.0f, 1.0f);
- }
- else {
- float avg[3], val[3];
- SCULPT_neighbor_coords_average(ss, avg, vd.index);
- sub_v3_v3v3(val, avg, vd.co);
- madd_v3_v3v3fl(val, vd.co, val, fade);
- sculpt_clip(sd, ss, vd.co, val);
- }
- }
- }
- BKE_pbvh_vertex_iter_end;
-}
-
-static void smooth(Sculpt *sd,
- Object *ob,
- PBVHNode **nodes,
- const int totnode,
- float bstrength,
- const bool smooth_mask)
-{
- SculptSession *ss = ob->sculpt;
- Brush *brush = BKE_paint_brush(&sd->paint);
-
- const int max_iterations = 4;
- const float fract = 1.0f / max_iterations;
- PBVHType type = BKE_pbvh_type(ss->pbvh);
- int iteration, count;
- float last;
-
- CLAMP(bstrength, 0.0f, 1.0f);
-
- count = (int)(bstrength * max_iterations);
- last = max_iterations * (bstrength - count * fract);
-
- if (type == PBVH_FACES && !ss->pmap) {
- BLI_assert(!"sculpt smooth: pmap missing");
- return;
- }
-
- for (iteration = 0; iteration <= count; iteration++) {
- const float strength = (iteration != count) ? 1.0f : last;
-
- SculptThreadedTaskData data = {
- .sd = sd,
- .ob = ob,
- .brush = brush,
- .nodes = nodes,
- .smooth_mask = smooth_mask,
- .strength = strength,
- };
-
- PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
-
- switch (type) {
- case PBVH_GRIDS:
- BKE_pbvh_parallel_range(0, totnode, &data, do_smooth_brush_multires_task_cb_ex, &settings);
- break;
- case PBVH_FACES:
- BKE_pbvh_parallel_range(0, totnode, &data, do_smooth_brush_mesh_task_cb_ex, &settings);
- break;
- case PBVH_BMESH:
- BKE_pbvh_parallel_range(0, totnode, &data, do_smooth_brush_bmesh_task_cb_ex, &settings);
- break;
- }
- }
-}
-
static void bmesh_topology_rake(
Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, float bstrength)
{
@@ -3304,158 +2687,6 @@ static void bmesh_topology_rake(
}
}
-static void do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
-{
- SculptSession *ss = ob->sculpt;
- smooth(sd, ob, nodes, totnode, ss->cache->bstrength, false);
-}
-/* HC Smooth Algorithm. */
-/* From: Improved Laplacian Smoothing of Noisy Surface Meshes */
-
-static void surface_smooth_laplacian_step(SculptSession *ss,
- float *disp,
- const float co[3],
- float (*laplacian_disp)[3],
- const int v_index,
- const float origco[3],
- const float alpha)
-{
- float laplacian_smooth_co[3];
- float weigthed_o[3], weigthed_q[3], d[3];
- SCULPT_neighbor_coords_average(ss, laplacian_smooth_co, v_index);
-
- mul_v3_v3fl(weigthed_o, origco, alpha);
- mul_v3_v3fl(weigthed_q, co, 1.0f - alpha);
- add_v3_v3v3(d, weigthed_o, weigthed_q);
- sub_v3_v3v3(laplacian_disp[v_index], laplacian_smooth_co, d);
-
- sub_v3_v3v3(disp, laplacian_smooth_co, co);
-}
-
-static void surface_smooth_displace_step(SculptSession *ss,
- float *co,
- float (*laplacian_disp)[3],
- const int v_index,
- const float beta,
- const float fade)
-{
- float b_avg[3] = {0.0f, 0.0f, 0.0f};
- float b_current_vertex[3];
- int total = 0;
- SculptVertexNeighborIter ni;
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, v_index, ni) {
- add_v3_v3(b_avg, laplacian_disp[ni.index]);
- total++;
- }
- SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
- if (total > 0) {
- mul_v3_v3fl(b_current_vertex, b_avg, (1.0f - beta) / (float)total);
- madd_v3_v3fl(b_current_vertex, laplacian_disp[v_index], beta);
- mul_v3_fl(b_current_vertex, clamp_f(fade, 0.0f, 1.0f));
- sub_v3_v3(co, b_current_vertex);
- }
-}
-
-static void do_surface_smooth_brush_laplacian_task_cb_ex(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- const Brush *brush = data->brush;
- const float bstrength = ss->cache->bstrength;
- float alpha = brush->surface_smooth_shape_preservation;
-
- PBVHVertexIter vd;
- SculptOrigVertData orig_data;
-
- SculptBrushTest test;
- SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
- ss, &test, data->brush->falloff_shape);
-
- SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]);
-
- BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
- {
- SCULPT_orig_vert_data_update(&orig_data, &vd);
- if (sculpt_brush_test_sq_fn(&test, vd.co)) {
- const float fade =
- bstrength *
- SCULPT_brush_strength_factor(
- ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, 0.0f, vd.index, tls->thread_id);
-
- float disp[3];
- surface_smooth_laplacian_step(ss,
- disp,
- vd.co,
- ss->cache->surface_smooth_laplacian_disp,
- vd.index,
- orig_data.co,
- alpha);
- madd_v3_v3fl(vd.co, disp, clamp_f(fade, 0.0f, 1.0f));
- }
- BKE_pbvh_vertex_iter_end;
- }
-}
-
-static void do_surface_smooth_brush_displace_task_cb_ex(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- const Brush *brush = data->brush;
- const float bstrength = ss->cache->bstrength;
- const float beta = brush->surface_smooth_current_vertex;
-
- PBVHVertexIter vd;
-
- SculptBrushTest test;
- SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
- ss, &test, data->brush->falloff_shape);
-
- BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
- {
- if (sculpt_brush_test_sq_fn(&test, vd.co)) {
- const float fade =
- bstrength *
- SCULPT_brush_strength_factor(
- ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, 0.0f, vd.index, tls->thread_id);
- surface_smooth_displace_step(
- ss, vd.co, ss->cache->surface_smooth_laplacian_disp, vd.index, beta, fade);
- }
- }
- BKE_pbvh_vertex_iter_end;
-}
-
-static void do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
-{
- Brush *brush = BKE_paint_brush(&sd->paint);
- SculptSession *ss = ob->sculpt;
-
- if (ss->cache->mirror_symmetry_pass == 0 && ss->cache->radial_symmetry_pass == 0) {
- ss->cache->surface_smooth_laplacian_disp = MEM_callocN(
- SCULPT_vertex_count_get(ss) * 3 * sizeof(float), "HC smooth laplacian b");
- }
-
- /* Threaded loop over nodes. */
- SculptThreadedTaskData data = {
- .sd = sd,
- .ob = ob,
- .brush = brush,
- .nodes = nodes,
- };
-
- PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
- for (int i = 0; i < brush->surface_smooth_iterations; i++) {
- BKE_pbvh_parallel_range(
- 0, totnode, &data, do_surface_smooth_brush_laplacian_task_cb_ex, &settings);
- BKE_pbvh_parallel_range(
- 0, totnode, &data, do_surface_smooth_brush_displace_task_cb_ex, &settings);
- }
-}
-
static void do_mask_brush_draw_task_cb_ex(void *__restrict userdata,
const int n,
const TaskParallelTLS *__restrict tls)
@@ -3520,7 +2751,7 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
do_mask_brush_draw(sd, ob, nodes, totnode);
break;
case BRUSH_MASK_SMOOTH:
- smooth(sd, ob, nodes, totnode, ss->cache->bstrength, true);
+ SCULPT_smooth(sd, ob, nodes, totnode, ss->cache->bstrength, true);
break;
}
}
@@ -3597,126 +2828,6 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
BKE_pbvh_parallel_range(0, totnode, &data, do_draw_brush_task_cb_ex, &settings);
}
-static void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- const Brush *brush = data->brush;
- const float bstrength = ss->cache->bstrength;
-
- PBVHVertexIter vd;
-
- SculptBrushTest test;
- SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
- ss, &test, data->brush->falloff_shape);
-
- BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
- {
- if (sculpt_brush_test_sq_fn(&test, vd.co)) {
- const float fade = bstrength * SCULPT_brush_strength_factor(ss,
- brush,
- vd.co,
- sqrtf(test.dist),
- vd.no,
- vd.fno,
- vd.mask ? *vd.mask : 0.0f,
- vd.index,
- tls->thread_id);
-
- if (fade > 0.05f) {
- SCULPT_vertex_face_set_set(ss, vd.index, ss->cache->paint_face_set);
- }
- }
- }
- BKE_pbvh_vertex_iter_end;
-}
-
-static void do_relax_face_sets_brush_task_cb_ex(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- const Brush *brush = data->brush;
- float bstrength = ss->cache->bstrength;
-
- PBVHVertexIter vd;
-
- SculptBrushTest test;
- SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
- ss, &test, data->brush->falloff_shape);
-
- const bool relax_face_sets = !(ss->cache->iteration_count % 3 == 0);
- /* This operations needs a stregth tweak as the relax deformation is too weak by default. */
- if (relax_face_sets) {
- bstrength *= 2.0f;
- }
-
- BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
- {
- if (sculpt_brush_test_sq_fn(&test, vd.co)) {
- if (relax_face_sets != SCULPT_vertex_has_unique_face_set(ss, vd.index)) {
- const float fade = bstrength * SCULPT_brush_strength_factor(ss,
- brush,
- vd.co,
- sqrtf(test.dist),
- vd.no,
- vd.fno,
- vd.mask ? *vd.mask : 0.0f,
- vd.index,
- tls->thread_id);
-
- SCULPT_relax_vertex(ss, &vd, fade * bstrength, relax_face_sets, vd.co);
- if (vd.mvert) {
- vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
- }
- }
- }
- }
- BKE_pbvh_vertex_iter_end;
-}
-
-static void do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
-{
- SculptSession *ss = ob->sculpt;
- Brush *brush = BKE_paint_brush(&sd->paint);
-
- if (ss->cache->first_time && ss->cache->mirror_symmetry_pass == 0 &&
- ss->cache->radial_symmetry_pass == 0) {
- if (ss->cache->invert) {
- /* When inverting the brush, pick the paint face mask ID from the mesh. */
- ss->cache->paint_face_set = SCULPT_vertex_face_set_get(ss, SCULPT_active_vertex_get(ss));
- }
- else {
- /* By default create a new Face Sets. */
- ss->cache->paint_face_set = SCULPT_face_set_next_available_get(ss);
- }
- }
-
- BKE_curvemapping_initialize(brush->curve);
-
- /* Threaded loop over nodes. */
- SculptThreadedTaskData data = {
- .sd = sd,
- .ob = ob,
- .brush = brush,
- .nodes = nodes,
- };
-
- PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
- if (ss->cache->alt_smooth) {
- for (int i = 0; i < 4; i++) {
- BKE_pbvh_parallel_range(0, totnode, &data, do_relax_face_sets_brush_task_cb_ex, &settings);
- }
- }
- else {
- BKE_pbvh_parallel_range(0, totnode, &data, do_draw_face_sets_brush_task_cb_ex, &settings);
- }
-}
-
static void do_draw_sharp_brush_task_cb_ex(void *__restrict userdata,
const int n,
const TaskParallelTLS *__restrict tls)
@@ -5008,7 +4119,7 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(val, offset, *disp);
- if (!ss->multires && !ss->bm && ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
+ if (!ss->multires.active && !ss->bm && ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
int index = vd.vert_indices[vd.i];
/* Persistent base. */
@@ -5018,7 +4129,7 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata,
add_v3_v3(val, orig_data.co);
}
- sculpt_clip(sd, ss, vd.co, val);
+ SCULPT_clip(sd, ss, vd.co, val);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
@@ -6191,8 +5302,8 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
}
if (ss->cache->first_time && ss->cache->mirror_symmetry_pass == 0) {
- if (sculpt_automasking_enabled(ss, brush)) {
- sculpt_automasking_init(sd, ob);
+ if (SCULPT_is_automasking_enabled(sd, ss, brush)) {
+ SCULPT_automasking_init(sd, ob);
}
}
@@ -6210,10 +5321,10 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
break;
case SCULPT_TOOL_SMOOTH:
if (brush->smooth_deform_type == BRUSH_SMOOTH_DEFORM_LAPLACIAN) {
- do_smooth_brush(sd, ob, nodes, totnode);
+ SCULPT_do_smooth_brush(sd, ob, nodes, totnode);
}
else if (brush->smooth_deform_type == BRUSH_SMOOTH_DEFORM_SURFACE) {
- do_surface_smooth_brush(sd, ob, nodes, totnode);
+ SCULPT_do_surface_smooth_brush(sd, ob, nodes, totnode);
}
break;
case SCULPT_TOOL_CREASE:
@@ -6296,22 +5407,22 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
SCULPT_do_cloth_brush(sd, ob, nodes, totnode);
break;
case SCULPT_TOOL_DRAW_FACE_SETS:
- do_draw_face_sets_brush(sd, ob, nodes, totnode);
+ SCULPT_do_draw_face_sets_brush(sd, ob, nodes, totnode);
break;
}
if (!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_MASK) &&
brush->autosmooth_factor > 0) {
if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) {
- smooth(sd,
- ob,
- nodes,
- totnode,
- brush->autosmooth_factor * (1.0f - ss->cache->pressure),
- false);
+ SCULPT_smooth(sd,
+ ob,
+ nodes,
+ totnode,
+ brush->autosmooth_factor * (1.0f - ss->cache->pressure),
+ false);
}
else {
- smooth(sd, ob, nodes, totnode, brush->autosmooth_factor, false);
+ SCULPT_smooth(sd, ob, nodes, totnode, brush->autosmooth_factor, false);
}
}
@@ -6405,7 +5516,7 @@ static void sculpt_combine_proxies_task_cb(void *__restrict userdata,
add_v3_v3(val, proxies[p].co[vd.i]);
}
- sculpt_clip(sd, ss, vd.co, val);
+ SCULPT_clip(sd, ss, vd.co, val);
if (ss->deform_modifiers_active) {
sculpt_flush_pbvhvert_deform(ob, &vd);
@@ -6466,7 +5577,7 @@ static void sculpt_update_keyblock(Object *ob)
}
}
-static void sculpt_flush_stroke_deform_task_cb(void *__restrict userdata,
+static void SCULPT_flush_stroke_deform_task_cb(void *__restrict userdata,
const int n,
const TaskParallelTLS *__restrict UNUSED(tls))
{
@@ -6490,7 +5601,7 @@ static void sculpt_flush_stroke_deform_task_cb(void *__restrict userdata,
}
/* Flush displacement from deformed PBVH to original layer. */
-static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob, bool is_proxy_used)
+void SCULPT_flush_stroke_deform(Sculpt *sd, Object *ob, bool is_proxy_used)
{
SculptSession *ss = ob->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);
@@ -6524,7 +5635,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob, bool is_proxy_use
PBVHParallelSettings settings;
BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
- BKE_pbvh_parallel_range(0, totnode, &data, sculpt_flush_stroke_deform_task_cb, &settings);
+ BKE_pbvh_parallel_range(0, totnode, &data, SCULPT_flush_stroke_deform_task_cb, &settings);
if (vertCos) {
SCULPT_vertcos_to_key(ob, ss->shapekey_active, vertCos);
@@ -6683,7 +5794,7 @@ static void sculpt_fix_noise_tear(Sculpt *sd, Object *ob)
Brush *brush = BKE_paint_brush(&sd->paint);
MTex *mtex = &brush->mtex;
- if (ss->multires && mtex->tex && mtex->tex->type == TEX_NOISE) {
+ if (ss->multires.active && mtex->tex && mtex->tex->type == TEX_NOISE) {
multires_stitch_grids(ob);
}
}
@@ -6835,9 +5946,9 @@ static const char *sculpt_tool_name(Sculpt *sd)
void SCULPT_cache_free(StrokeCache *cache)
{
- if (cache->dial) {
- MEM_freeN(cache->dial);
- }
+ MEM_SAFE_FREE(cache->dial);
+ MEM_SAFE_FREE(cache->surface_smooth_laplacian_disp);
+
if (cache->pose_ik_chain) {
SCULPT_pose_ik_chain_free(cache->pose_ik_chain);
}
@@ -7021,7 +6132,7 @@ static void sculpt_update_cache_invariants(
/* Initialize layer brush displacements and persistent coords. */
if (brush->sculpt_tool == SCULPT_TOOL_LAYER) {
/* Not supported yet for multires or dynamic topology. */
- if (!ss->multires && !ss->bm && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
+ if (!ss->multires.active && !ss->bm && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
if (!ss->layer_co) {
ss->layer_co = MEM_mallocN(sizeof(float) * 3 * ss->totvert, "sculpt mesh vertices copy");
}
@@ -7358,9 +6469,12 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
/* Returns true if any of the smoothing modes are active (currently
* one of smooth brush, autosmooth, mask smooth, or shift-key
* smooth). */
-static bool sculpt_needs_connectivity_info(const Brush *brush, SculptSession *ss, int stroke_mode)
+static bool sculpt_needs_connectivity_info(const Sculpt *sd,
+ const Brush *brush,
+ SculptSession *ss,
+ int stroke_mode)
{
- if (ss && ss->pbvh && sculpt_automasking_enabled(ss, brush)) {
+ if (ss && ss->pbvh && SCULPT_is_automasking_enabled(sd, ss, brush)) {
return true;
}
return ((stroke_mode == BRUSH_STROKE_SMOOTH) || (ss && ss->cache && ss->cache->alt_smooth) ||
@@ -7372,12 +6486,13 @@ static bool sculpt_needs_connectivity_info(const Brush *brush, SculptSession *ss
(brush->sculpt_tool == SCULPT_TOOL_DRAW_FACE_SETS));
}
-static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush)
+void SCULPT_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush)
{
SculptSession *ss = ob->sculpt;
View3D *v3d = CTX_wm_view3d(C);
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- bool need_pmap = sculpt_needs_connectivity_info(brush, ss, 0);
+ bool need_pmap = sculpt_needs_connectivity_info(sd, brush, ss, 0);
if (ss->shapekey_active || ss->deform_modifiers_active ||
(!BKE_sculptsession_use_pbvh_draw(ob, v3d) && need_pmap)) {
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
@@ -7413,6 +6528,7 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin)
&srd->isect_precalc,
&srd->depth,
&srd->active_vertex_index,
+ &srd->active_face_grid_index,
srd->face_normal)) {
srd->hit = true;
*tmin = srd->depth;
@@ -7453,24 +6569,12 @@ static void sculpt_find_nearest_to_ray_cb(PBVHNode *node, void *data_v, float *t
}
}
-static void sculpt_raycast_detail_cb(PBVHNode *node, void *data_v, float *tmin)
-{
- if (BKE_pbvh_node_get_tmin(node) < *tmin) {
- SculptDetailRaycastData *srd = data_v;
- if (BKE_pbvh_bmesh_node_raycast_detail(
- node, srd->ray_start, &srd->isect_precalc, &srd->depth, &srd->edge_length)) {
- srd->hit = true;
- *tmin = srd->depth;
- }
- }
-}
-
-static float sculpt_raycast_init(ViewContext *vc,
- const float mouse[2],
- float ray_start[3],
- float ray_end[3],
- float ray_normal[3],
- bool original)
+float SCULPT_raycast_init(ViewContext *vc,
+ const float mouse[2],
+ float ray_start[3],
+ float ray_end[3],
+ float ray_normal[3],
+ bool original)
{
float obimat[4][4];
float dist;
@@ -7536,8 +6640,8 @@ bool SCULPT_cursor_geometry_info_update(bContext *C,
}
/* PBVH raycast to get active vertex and face normal. */
- depth = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original);
- sculpt_stroke_modifiers_check(C, ob, brush);
+ depth = SCULPT_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original);
+ SCULPT_stroke_modifiers_check(C, ob, brush);
SculptRaycastData srd = {
.original = original,
@@ -7563,6 +6667,21 @@ bool SCULPT_cursor_geometry_info_update(bContext *C,
ss->active_vertex_index = srd.active_vertex_index;
copy_v3_v3(out->active_vertex_co, SCULPT_active_vertex_co_get(ss));
+ switch (BKE_pbvh_type(ss->pbvh)) {
+ case PBVH_FACES:
+ ss->active_face_index = srd.active_face_grid_index;
+ ss->active_grid_index = 0;
+ break;
+ case PBVH_GRIDS:
+ ss->active_face_index = 0;
+ ss->active_grid_index = srd.active_face_grid_index;
+ break;
+ case PBVH_BMESH:
+ ss->active_face_index = 0;
+ ss->active_grid_index = 0;
+ break;
+ }
+
copy_v3_v3(out->location, ray_normal);
mul_v3_fl(out->location, srd.depth);
add_v3_v3(out->location, ray_start);
@@ -7641,9 +6760,9 @@ bool SCULPT_stroke_get_location(bContext *C, float out[3], const float mouse[2])
const Brush *brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
- sculpt_stroke_modifiers_check(C, ob, brush);
+ SCULPT_stroke_modifiers_check(C, ob, brush);
- depth = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original);
+ depth = SCULPT_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original);
if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) {
BM_mesh_elem_table_ensure(ss->bm, BM_VERT);
@@ -7735,7 +6854,7 @@ static void sculpt_brush_stroke_init(bContext *C, wmOperator *op)
view3d_operator_needs_opengl(C);
sculpt_brush_init_tex(scene, sd, ss);
- is_smooth = sculpt_needs_connectivity_info(brush, ss, mode);
+ is_smooth = sculpt_needs_connectivity_info(sd, brush, ss, mode);
BKE_sculpt_update_object_for_edit(depsgraph, ob, is_smooth, need_mask);
}
@@ -7765,13 +6884,13 @@ void SCULPT_update_object_bounding_box(Object *ob)
}
}
-static void sculpt_flush_update_step(bContext *C, SculptUpdateType update_flags)
+void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags)
{
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
ARegion *region = CTX_wm_region(C);
- MultiresModifierData *mmd = ss->multires;
+ MultiresModifierData *mmd = ss->multires.modifier;
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
@@ -7825,7 +6944,7 @@ static void sculpt_flush_update_step(bContext *C, SculptUpdateType update_flags)
}
}
-static void sculpt_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags)
+void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags)
{
/* After we are done drawing the stroke, check if we need to do a more
* expensive depsgraph tag to update geometry. */
@@ -7842,10 +6961,10 @@ static void sculpt_flush_update_done(const bContext *C, Object *ob, SculptUpdate
rv3d->rflag &= ~RV3D_PAINTING;
}
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
bScreen *screen = WM_window_get_active_screen(win);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl = sa->spacedata.first;
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ SpaceLink *sl = area->spacedata.first;
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
if (v3d != current_v3d) {
@@ -7855,7 +6974,7 @@ static void sculpt_flush_update_done(const bContext *C, Object *ob, SculptUpdate
/* Tag all 3D viewports for redraw now that we are done. Others
* viewports did not get a full redraw, and anti-aliasing for the
* current viewport was deactivated. */
- for (ARegion *region = sa->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
ED_region_tag_redraw(region);
}
@@ -7935,7 +7054,7 @@ static void sculpt_stroke_update_step(bContext *C,
SculptSession *ss = ob->sculpt;
const Brush *brush = BKE_paint_brush(&sd->paint);
- sculpt_stroke_modifiers_check(C, ob, brush);
+ SCULPT_stroke_modifiers_check(C, ob, brush);
sculpt_update_cache_variants(C, sd, ob, itemptr);
sculpt_restore_mesh(sd, ob);
@@ -7952,7 +7071,7 @@ static void sculpt_stroke_update_step(bContext *C,
(float)(sd->detail_size * U.pixelsize) / 0.4f);
}
- if (sculpt_stroke_is_dynamic_topology(ss, brush)) {
+ if (SCULPT_stroke_is_dynamic_topology(ss, brush)) {
do_symmetrical_brush_actions(sd, ob, sculpt_topology_update, ups);
}
@@ -7973,7 +7092,7 @@ static void sculpt_stroke_update_step(bContext *C,
* sculpt_flush_update_step().
*/
if (ss->deform_modifiers_active) {
- sculpt_flush_stroke_deform(sd, ob, sculpt_tool_is_proxy_used(brush->sculpt_tool));
+ SCULPT_flush_stroke_deform(sd, ob, sculpt_tool_is_proxy_used(brush->sculpt_tool));
}
else if (ss->shapekey_active) {
sculpt_update_keyblock(ob);
@@ -7984,10 +7103,10 @@ static void sculpt_stroke_update_step(bContext *C,
/* Cleanup. */
if (brush->sculpt_tool == SCULPT_TOOL_MASK) {
- sculpt_flush_update_step(C, SCULPT_UPDATE_MASK);
+ SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK);
}
else {
- sculpt_flush_update_step(C, SCULPT_UPDATE_COORDS);
+ SCULPT_flush_update_step(C, SCULPT_UPDATE_COORDS);
}
}
@@ -8016,7 +7135,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
BLI_assert(brush == ss->cache->brush); /* const, so we shouldn't change. */
ups->draw_inverted = false;
- sculpt_stroke_modifiers_check(C, ob, brush);
+ SCULPT_stroke_modifiers_check(C, ob, brush);
/* Alt-Smooth. */
if (ss->cache->alt_smooth) {
@@ -8035,8 +7154,8 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
}
}
- if (sculpt_automasking_enabled(ss, brush)) {
- sculpt_automasking_end(ob);
+ if (SCULPT_is_automasking_enabled(sd, ss, brush)) {
+ SCULPT_automasking_end(ob);
}
SCULPT_cache_free(ss->cache);
@@ -8045,10 +7164,10 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
SCULPT_undo_push_end();
if (brush->sculpt_tool == SCULPT_TOOL_MASK) {
- sculpt_flush_update_done(C, ob, SCULPT_UPDATE_MASK);
+ SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK);
}
else {
- sculpt_flush_update_done(C, ob, SCULPT_UPDATE_COORDS);
+ SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_COORDS);
}
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -8125,7 +7244,7 @@ static void sculpt_brush_stroke_cancel(bContext *C, wmOperator *op)
/* XXX Canceling strokes that way does not work with dynamic topology,
* user will have to do real undo for now. See T46456. */
- if (ss->cache && !sculpt_stroke_is_dynamic_topology(ss, brush)) {
+ if (ss->cache && !SCULPT_stroke_is_dynamic_topology(ss, brush)) {
paint_mesh_restore_co(sd, ob);
}
@@ -8197,400 +7316,18 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/************************** Dynamic Topology **************************/
-
-static void sculpt_dynamic_topology_triangulate(BMesh *bm)
-{
- if (bm->totloop != bm->totface * 3) {
- BM_mesh_triangulate(
- bm, MOD_TRIANGULATE_QUAD_BEAUTY, MOD_TRIANGULATE_NGON_EARCLIP, 4, false, NULL, NULL, NULL);
- }
-}
-
-void sculpt_pbvh_clear(Object *ob)
-{
- SculptSession *ss = ob->sculpt;
-
- /* Clear out any existing DM and PBVH. */
- if (ss->pbvh) {
- BKE_pbvh_free(ss->pbvh);
- ss->pbvh = NULL;
- }
-
- if (ss->pmap) {
- MEM_freeN(ss->pmap);
- ss->pmap = NULL;
- }
-
- if (ss->pmap_mem) {
- MEM_freeN(ss->pmap_mem);
- ss->pmap_mem = NULL;
- }
-
- BKE_object_free_derived_caches(ob);
-
- /* Tag to rebuild PBVH in depsgraph. */
- DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
-}
-
-void sculpt_dyntopo_node_layers_add(SculptSession *ss)
-{
- int cd_node_layer_index;
-
- char layer_id[] = "_dyntopo_node_id";
-
- cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->vdata, CD_PROP_INT, layer_id);
- if (cd_node_layer_index == -1) {
- BM_data_layer_add_named(ss->bm, &ss->bm->vdata, CD_PROP_INT, layer_id);
- cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->vdata, CD_PROP_INT, layer_id);
- }
-
- ss->cd_vert_node_offset = CustomData_get_n_offset(
- &ss->bm->vdata,
- CD_PROP_INT,
- cd_node_layer_index - CustomData_get_layer_index(&ss->bm->vdata, CD_PROP_INT));
-
- ss->bm->vdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY;
-
- cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->pdata, CD_PROP_INT, layer_id);
- if (cd_node_layer_index == -1) {
- BM_data_layer_add_named(ss->bm, &ss->bm->pdata, CD_PROP_INT, layer_id);
- cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->pdata, CD_PROP_INT, layer_id);
- }
-
- ss->cd_face_node_offset = CustomData_get_n_offset(
- &ss->bm->pdata,
- CD_PROP_INT,
- cd_node_layer_index - CustomData_get_layer_index(&ss->bm->pdata, CD_PROP_INT));
-
- ss->bm->pdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY;
-}
-
-static void sculpt_dynamic_topology_enable_ex(Main *bmain,
- Depsgraph *depsgraph,
- Scene *scene,
- Object *ob)
-{
- SculptSession *ss = ob->sculpt;
- Mesh *me = ob->data;
- const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(me);
-
- sculpt_pbvh_clear(ob);
-
- ss->bm_smooth_shading = (scene->toolsettings->sculpt->flags & SCULPT_DYNTOPO_SMOOTH_SHADING) !=
- 0;
-
- /* Dynamic topology doesn't ensure selection state is valid, so remove [#36280]. */
- BKE_mesh_mselect_clear(me);
-
- /* Create triangles-only BMesh. */
- ss->bm = BM_mesh_create(&allocsize,
- &((struct BMeshCreateParams){
- .use_toolflags = false,
- }));
-
- BM_mesh_bm_from_me(ss->bm,
- me,
- (&(struct BMeshFromMeshParams){
- .calc_face_normal = true,
- .use_shapekey = true,
- .active_shapekey = ob->shapenr,
- }));
- sculpt_dynamic_topology_triangulate(ss->bm);
- BM_data_layer_add(ss->bm, &ss->bm->vdata, CD_PAINT_MASK);
- sculpt_dyntopo_node_layers_add(ss);
- /* Make sure the data for existing faces are initialized. */
- if (me->totpoly != ss->bm->totface) {
- BM_mesh_normals_update(ss->bm);
- }
-
- /* Enable dynamic topology. */
- me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY;
-
- /* Enable logging for undo/redo. */
- ss->bm_log = BM_log_create(ss->bm);
-
- /* Update dependency graph, so modifiers that depend on dyntopo being enabled
- * are re-evaluated and the PBVH is re-created. */
- DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
- BKE_scene_graph_update_tagged(depsgraph, bmain);
-}
-
-/* Free the sculpt BMesh and BMLog
- *
- * If 'unode' is given, the BMesh's data is copied out to the unode
- * before the BMesh is deleted so that it can be restored from. */
-static void sculpt_dynamic_topology_disable_ex(
- Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, SculptUndoNode *unode)
-{
- SculptSession *ss = ob->sculpt;
- Mesh *me = ob->data;
-
- sculpt_pbvh_clear(ob);
-
- if (unode) {
- /* Free all existing custom data. */
- CustomData_free(&me->vdata, me->totvert);
- CustomData_free(&me->edata, me->totedge);
- CustomData_free(&me->fdata, me->totface);
- CustomData_free(&me->ldata, me->totloop);
- CustomData_free(&me->pdata, me->totpoly);
-
- /* Copy over stored custom data. */
- me->totvert = unode->geom_totvert;
- me->totloop = unode->geom_totloop;
- me->totpoly = unode->geom_totpoly;
- me->totedge = unode->geom_totedge;
- me->totface = 0;
- CustomData_copy(
- &unode->geom_vdata, &me->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, unode->geom_totvert);
- CustomData_copy(
- &unode->geom_edata, &me->edata, CD_MASK_MESH.emask, CD_DUPLICATE, unode->geom_totedge);
- CustomData_copy(
- &unode->geom_ldata, &me->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, unode->geom_totloop);
- CustomData_copy(
- &unode->geom_pdata, &me->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, unode->geom_totpoly);
-
- BKE_mesh_update_customdata_pointers(me, false);
- }
- else {
- BKE_sculptsession_bm_to_me(ob, true);
-
- /* Reset Face Sets as they are no longer valid. */
- if (!CustomData_has_layer(&me->pdata, CD_SCULPT_FACE_SETS)) {
- CustomData_add_layer(&me->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, me->totpoly);
- }
- ss->face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS);
- for (int i = 0; i < me->totpoly; i++) {
- ss->face_sets[i] = 1;
- }
- me->face_sets_color_default = 1;
-
- /* Sync the visibility to vertices manually as the pmap is still not initialized. */
- for (int i = 0; i < me->totvert; i++) {
- me->mvert[i].flag &= ~ME_HIDE;
- me->mvert[i].flag |= ME_VERT_PBVH_UPDATE;
- }
- }
-
- /* Clear data. */
- me->flag &= ~ME_SCULPT_DYNAMIC_TOPOLOGY;
-
- /* Typically valid but with global-undo they can be NULL. [#36234] */
- if (ss->bm) {
- BM_mesh_free(ss->bm);
- ss->bm = NULL;
- }
- if (ss->bm_log) {
- BM_log_free(ss->bm_log);
- ss->bm_log = NULL;
- }
-
- BKE_particlesystem_reset_all(ob);
- BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED);
-
- /* Update dependency graph, so modifiers that depend on dyntopo being enabled
- * are re-evaluated and the PBVH is re-created. */
- DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
- BKE_scene_graph_update_tagged(depsgraph, bmain);
-}
-
-void sculpt_dynamic_topology_disable(bContext *C, SculptUndoNode *unode)
-{
- Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- Scene *scene = CTX_data_scene(C);
- Object *ob = CTX_data_active_object(C);
- sculpt_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, unode);
-}
-
-static void sculpt_dynamic_topology_disable_with_undo(Main *bmain,
- Depsgraph *depsgraph,
- Scene *scene,
- Object *ob)
-{
- SculptSession *ss = ob->sculpt;
- if (ss->bm) {
- SCULPT_undo_push_begin("Dynamic topology disable");
- SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END);
- sculpt_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, NULL);
- SCULPT_undo_push_end();
- }
-}
-
-static void sculpt_dynamic_topology_enable_with_undo(Main *bmain,
- Depsgraph *depsgraph,
- Scene *scene,
- Object *ob)
-{
- SculptSession *ss = ob->sculpt;
- if (ss->bm == NULL) {
- SCULPT_undo_push_begin("Dynamic topology enable");
- sculpt_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob);
- SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
- SCULPT_undo_push_end();
- }
-}
-
-static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- Scene *scene = CTX_data_scene(C);
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
-
- WM_cursor_wait(true);
-
- if (ss->bm) {
- sculpt_dynamic_topology_disable_with_undo(bmain, depsgraph, scene, ob);
- }
- else {
- sculpt_dynamic_topology_enable_with_undo(bmain, depsgraph, scene, ob);
- }
-
- WM_cursor_wait(false);
- WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-enum eDynTopoWarnFlag {
- DYNTOPO_WARN_VDATA = (1 << 0),
- DYNTOPO_WARN_EDATA = (1 << 1),
- DYNTOPO_WARN_LDATA = (1 << 2),
- DYNTOPO_WARN_MODIFIER = (1 << 3),
-};
-
-static int dyntopo_warning_popup(bContext *C, wmOperatorType *ot, enum eDynTopoWarnFlag flag)
-{
- uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Warning!"), ICON_ERROR);
- uiLayout *layout = UI_popup_menu_layout(pup);
-
- if (flag & (DYNTOPO_WARN_VDATA | DYNTOPO_WARN_EDATA | DYNTOPO_WARN_LDATA)) {
- const char *msg_error = TIP_("Vertex Data Detected!");
- const char *msg = TIP_("Dyntopo will not preserve vertex colors, UVs, or other customdata");
- uiItemL(layout, msg_error, ICON_INFO);
- uiItemL(layout, msg, ICON_NONE);
- uiItemS(layout);
- }
-
- if (flag & DYNTOPO_WARN_MODIFIER) {
- const char *msg_error = TIP_("Generative Modifiers Detected!");
- const char *msg = TIP_(
- "Keeping the modifiers will increase polycount when returning to object mode");
-
- uiItemL(layout, msg_error, ICON_INFO);
- uiItemL(layout, msg, ICON_NONE);
- uiItemS(layout);
- }
-
- uiItemFullO_ptr(layout, ot, IFACE_("OK"), ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, NULL);
-
- UI_popup_menu_end(C, pup);
-
- return OPERATOR_INTERFACE;
-}
-
-static enum eDynTopoWarnFlag sculpt_dynamic_topology_check(Scene *scene, Object *ob)
-{
- Mesh *me = ob->data;
- SculptSession *ss = ob->sculpt;
-
- enum eDynTopoWarnFlag flag = 0;
-
- BLI_assert(ss->bm == NULL);
- UNUSED_VARS_NDEBUG(ss);
-
- for (int i = 0; i < CD_NUMTYPES; i++) {
- if (!ELEM(i, CD_MVERT, CD_MEDGE, CD_MFACE, CD_MLOOP, CD_MPOLY, CD_PAINT_MASK, CD_ORIGINDEX)) {
- if (CustomData_has_layer(&me->vdata, i)) {
- flag |= DYNTOPO_WARN_VDATA;
- }
- if (CustomData_has_layer(&me->edata, i)) {
- flag |= DYNTOPO_WARN_EDATA;
- }
- if (CustomData_has_layer(&me->ldata, i)) {
- flag |= DYNTOPO_WARN_LDATA;
- }
- }
- }
-
- {
- VirtualModifierData virtualModifierData;
- ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
-
- /* Exception for shape keys because we can edit those. */
- for (; md; md = md->next) {
- const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
- continue;
- }
-
- if (mti->type == eModifierTypeType_Constructive) {
- flag |= DYNTOPO_WARN_MODIFIER;
- break;
- }
- }
- }
-
- return flag;
-}
-
-static int sculpt_dynamic_topology_toggle_invoke(bContext *C,
- wmOperator *op,
- const wmEvent *UNUSED(event))
-{
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
-
- if (!ss->bm) {
- Scene *scene = CTX_data_scene(C);
- enum eDynTopoWarnFlag flag = sculpt_dynamic_topology_check(scene, ob);
-
- if (flag) {
- /* The mesh has customdata that will be lost, let the user confirm this is OK. */
- return dyntopo_warning_popup(C, op->type, flag);
- }
- }
-
- return sculpt_dynamic_topology_toggle_exec(C, op);
-}
-
-static void SCULPT_OT_dynamic_topology_toggle(wmOperatorType *ot)
-{
- /* Identifiers. */
- ot->name = "Dynamic Topology Toggle";
- ot->idname = "SCULPT_OT_dynamic_topology_toggle";
- ot->description = "Dynamic topology alters the mesh topology while sculpting";
-
- /* API callbacks. */
- ot->invoke = sculpt_dynamic_topology_toggle_invoke;
- ot->exec = sculpt_dynamic_topology_toggle_exec;
- ot->poll = SCULPT_mode_poll;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
/************************* SCULPT_OT_optimize *************************/
static int sculpt_optimize_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_active_object(C);
- sculpt_pbvh_clear(ob);
+ SCULPT_pbvh_clear(ob);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return OPERATOR_FINISHED;
}
-static bool sculpt_and_dynamic_topology_poll(bContext *C)
-{
- Object *ob = CTX_data_active_object(C);
-
- return SCULPT_mode_poll(C) && ob->sculpt->bm;
-}
-
/* The BVH gets less optimal more quickly with dynamic topology than
* regular sculpting. There is no doubt more clever stuff we can do to
* optimize it on the fly, but for now this gives the user a nicer way
@@ -8651,7 +7388,7 @@ static int sculpt_symmetrize_exec(bContext *C, wmOperator *UNUSED(op))
"symmetrize input=%avef direction=%i dist=%f",
sd->symmetrize_direction,
0.00001f);
- sculpt_dynamic_topology_triangulate(ss->bm);
+ SCULPT_dynamic_topology_triangulate(ss->bm);
/* Bisect operator flags edges (keep tags clean for edge queue). */
BM_mesh_elem_hflag_disable_all(ss->bm, BM_EDGE, BM_ELEM_TAG, false);
@@ -8712,7 +7449,7 @@ static int sculpt_symmetrize_exec(bContext *C, wmOperator *UNUSED(op))
}
/* Redraw. */
- sculpt_pbvh_clear(ob);
+ SCULPT_pbvh_clear(ob);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return OPERATOR_FINISHED;
@@ -8818,7 +7555,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
message_unsupported = TIP_("multi-res modifier");
}
else {
- enum eDynTopoWarnFlag flag = sculpt_dynamic_topology_check(scene, ob);
+ enum eDynTopoWarnFlag flag = SCULPT_dynamic_topology_check(scene, ob);
if (flag == 0) {
/* pass */
}
@@ -8847,7 +7584,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
if (has_undo) {
SCULPT_undo_push_begin("Dynamic topology enable");
}
- sculpt_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob);
+ SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob);
if (has_undo) {
SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
SCULPT_undo_push_end();
@@ -8990,1759 +7727,6 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static bool sculpt_and_constant_or_manual_detail_poll(bContext *C)
-{
- Object *ob = CTX_data_active_object(C);
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
-
- return SCULPT_mode_poll(C) && ob->sculpt->bm &&
- (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL));
-}
-
-static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- float size;
- float bb_min[3], bb_max[3], center[3], dim[3];
- int totnodes;
- PBVHNode **nodes;
-
- BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnodes);
-
- if (!totnodes) {
- return OPERATOR_CANCELLED;
- }
-
- for (int i = 0; i < totnodes; i++) {
- BKE_pbvh_node_mark_topology_update(nodes[i]);
- }
- /* Get the bounding box, it's center and size. */
- BKE_pbvh_bounding_box(ob->sculpt->pbvh, bb_min, bb_max);
- add_v3_v3v3(center, bb_min, bb_max);
- mul_v3_fl(center, 0.5f);
- sub_v3_v3v3(dim, bb_max, bb_min);
- size = max_fff(dim[0], dim[1], dim[2]);
-
- /* Update topology size. */
- float object_space_constant_detail = 1.0f / (sd->constant_detail * mat4_to_scale(ob->obmat));
- BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail);
-
- SCULPT_undo_push_begin("Dynamic topology flood fill");
- SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_COORDS);
-
- while (BKE_pbvh_bmesh_update_topology(
- ss->pbvh, PBVH_Collapse | PBVH_Subdivide, center, NULL, size, false, false)) {
- for (int i = 0; i < totnodes; i++) {
- BKE_pbvh_node_mark_topology_update(nodes[i]);
- }
- }
-
- MEM_SAFE_FREE(nodes);
- SCULPT_undo_push_end();
-
- /* Force rebuild of pbvh for better BB placement. */
- sculpt_pbvh_clear(ob);
- /* Redraw. */
- WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
-
- return OPERATOR_FINISHED;
-}
-
-static void SCULPT_OT_detail_flood_fill(wmOperatorType *ot)
-{
- /* Identifiers. */
- ot->name = "Detail Flood Fill";
- ot->idname = "SCULPT_OT_detail_flood_fill";
- ot->description = "Flood fill the mesh with the selected detail setting";
-
- /* API callbacks. */
- ot->exec = sculpt_detail_flood_fill_exec;
- ot->poll = sculpt_and_constant_or_manual_detail_poll;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-typedef enum eSculptSampleDetailModeTypes {
- SAMPLE_DETAIL_DYNTOPO = 0,
- SAMPLE_DETAIL_VOXEL = 1,
-} eSculptSampleDetailModeTypes;
-
-static EnumPropertyItem prop_sculpt_sample_detail_mode_types[] = {
- {SAMPLE_DETAIL_DYNTOPO, "DYNTOPO", 0, "Dyntopo", "Sample dyntopo detail"},
- {SAMPLE_DETAIL_VOXEL, "VOXEL", 0, "Voxel", "Sample mesh voxel size"},
- {0, NULL, 0, NULL, NULL},
-};
-
-static void sample_detail_voxel(bContext *C, ViewContext *vc, int mx, int my)
-{
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- Object *ob = vc->obact;
- Mesh *mesh = ob->data;
-
- SculptSession *ss = ob->sculpt;
- SculptCursorGeometryInfo sgi;
- SCULPT_vertex_random_access_init(ss);
-
- /* Update the active vertex. */
- float mouse[2] = {mx, my};
- SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
- BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false);
-
- /* Average the edge length of the connected edges to the active vertex. */
- int active_vertex = SCULPT_active_vertex_get(ss);
- const float *active_vertex_co = SCULPT_active_vertex_co_get(ss);
- float edge_length = 0.0f;
- int tot = 0;
- SculptVertexNeighborIter ni;
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, active_vertex, ni) {
- edge_length += len_v3v3(active_vertex_co, SCULPT_vertex_co_get(ss, ni.index));
- tot += 1;
- }
- SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
- if (tot > 0) {
- mesh->remesh_voxel_size = edge_length / (float)tot;
- }
-}
-
-static void sample_detail_dyntopo(bContext *C, ViewContext *vc, ARegion *region, int mx, int my)
-{
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- Object *ob = vc->obact;
- Brush *brush = BKE_paint_brush(&sd->paint);
-
- sculpt_stroke_modifiers_check(C, ob, brush);
-
- float mouse[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
- float ray_start[3], ray_end[3], ray_normal[3];
- float depth = sculpt_raycast_init(vc, mouse, ray_start, ray_end, ray_normal, false);
-
- SculptDetailRaycastData srd;
- srd.hit = 0;
- srd.ray_start = ray_start;
- srd.depth = depth;
- srd.edge_length = 0.0f;
- isect_ray_tri_watertight_v3_precalc(&srd.isect_precalc, ray_normal);
-
- BKE_pbvh_raycast(ob->sculpt->pbvh, sculpt_raycast_detail_cb, &srd, ray_start, ray_normal, false);
-
- if (srd.hit && srd.edge_length > 0.0f) {
- /* Convert edge length to world space detail resolution. */
- sd->constant_detail = 1 / (srd.edge_length * mat4_to_scale(ob->obmat));
- }
-}
-
-static int sample_detail(bContext *C, int mx, int my, int mode)
-{
- /* Find 3D view to pick from. */
- bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_VIEW3D, mx, my);
- ARegion *region = (sa) ? BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my) : NULL;
- if (region == NULL) {
- return OPERATOR_CANCELLED;
- }
-
- /* Set context to 3D view. */
- ScrArea *prev_sa = CTX_wm_area(C);
- ARegion *prev_ar = CTX_wm_region(C);
- CTX_wm_area_set(C, sa);
- CTX_wm_region_set(C, region);
-
- Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- ViewContext vc;
- ED_view3d_viewcontext_init(C, &vc, depsgraph);
-
- Object *ob = vc.obact;
- SculptSession *ss = ob->sculpt;
-
- if (!ss->pbvh) {
- return OPERATOR_CANCELLED;
- }
-
- /* Pick sample detail. */
- switch (mode) {
- case SAMPLE_DETAIL_DYNTOPO:
- if (BKE_pbvh_type(ss->pbvh) != PBVH_BMESH) {
- CTX_wm_area_set(C, prev_sa);
- CTX_wm_region_set(C, prev_ar);
- return OPERATOR_CANCELLED;
- }
- sample_detail_dyntopo(C, &vc, region, mx, my);
- break;
- case SAMPLE_DETAIL_VOXEL:
- if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) {
- CTX_wm_area_set(C, prev_sa);
- CTX_wm_region_set(C, prev_ar);
- return OPERATOR_CANCELLED;
- }
- sample_detail_voxel(C, &vc, mx, my);
- break;
- }
-
- /* Restore context. */
- CTX_wm_area_set(C, prev_sa);
- CTX_wm_region_set(C, prev_ar);
-
- return OPERATOR_FINISHED;
-}
-
-static int sculpt_sample_detail_size_exec(bContext *C, wmOperator *op)
-{
- int ss_co[2];
- RNA_int_get_array(op->ptr, "location", ss_co);
- int mode = RNA_enum_get(op->ptr, "mode");
- return sample_detail(C, ss_co[0], ss_co[1], mode);
-}
-
-static int sculpt_sample_detail_size_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e))
-{
- ED_workspace_status_text(C, TIP_("Click on the mesh to set the detail"));
- WM_cursor_modal_set(CTX_wm_window(C), WM_CURSOR_EYEDROPPER);
- WM_event_add_modal_handler(C, op);
- return OPERATOR_RUNNING_MODAL;
-}
-
-static int sculpt_sample_detail_size_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
- switch (event->type) {
- case LEFTMOUSE:
- if (event->val == KM_PRESS) {
- int ss_co[2] = {event->x, event->y};
-
- int mode = RNA_enum_get(op->ptr, "mode");
- sample_detail(C, ss_co[0], ss_co[1], mode);
-
- RNA_int_set_array(op->ptr, "location", ss_co);
- WM_cursor_modal_restore(CTX_wm_window(C));
- ED_workspace_status_text(C, NULL);
- WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL);
-
- return OPERATOR_FINISHED;
- }
- break;
-
- case RIGHTMOUSE: {
- WM_cursor_modal_restore(CTX_wm_window(C));
- ED_workspace_status_text(C, NULL);
-
- return OPERATOR_CANCELLED;
- }
- }
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-static void SCULPT_OT_sample_detail_size(wmOperatorType *ot)
-{
- /* Identifiers. */
- ot->name = "Sample Detail Size";
- ot->idname = "SCULPT_OT_sample_detail_size";
- ot->description = "Sample the mesh detail on clicked point";
-
- /* API callbacks. */
- ot->invoke = sculpt_sample_detail_size_invoke;
- ot->exec = sculpt_sample_detail_size_exec;
- ot->modal = sculpt_sample_detail_size_modal;
- ot->poll = SCULPT_mode_poll;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- RNA_def_int_array(ot->srna,
- "location",
- 2,
- NULL,
- 0,
- SHRT_MAX,
- "Location",
- "Screen Coordinates of sampling",
- 0,
- SHRT_MAX);
- RNA_def_enum(ot->srna,
- "mode",
- prop_sculpt_sample_detail_mode_types,
- SAMPLE_DETAIL_DYNTOPO,
- "Detail Mode",
- "Target sculpting workflow that is going to use the sampled size");
-}
-
-/* Dynamic-topology detail size.
- *
- * This should be improved further, perhaps by showing a triangle
- * grid rather than brush alpha. */
-static void set_brush_rc_props(PointerRNA *ptr, const char *prop)
-{
- char *path = BLI_sprintfN("tool_settings.sculpt.brush.%s", prop);
- RNA_string_set(ptr, "data_path_primary", path);
- MEM_freeN(path);
-}
-
-static int sculpt_set_detail_size_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
-
- PointerRNA props_ptr;
- wmOperatorType *ot = WM_operatortype_find("WM_OT_radial_control", true);
-
- WM_operator_properties_create_ptr(&props_ptr, ot);
-
- if (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)) {
- set_brush_rc_props(&props_ptr, "constant_detail_resolution");
- RNA_string_set(
- &props_ptr, "data_path_primary", "tool_settings.sculpt.constant_detail_resolution");
- }
- else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) {
- set_brush_rc_props(&props_ptr, "constant_detail_resolution");
- RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.detail_percent");
- }
- else {
- set_brush_rc_props(&props_ptr, "detail_size");
- RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.detail_size");
- }
-
- WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr);
-
- WM_operator_properties_free(&props_ptr);
-
- return OPERATOR_FINISHED;
-}
-
-static void SCULPT_OT_set_detail_size(wmOperatorType *ot)
-{
- /* Identifiers. */
- ot->name = "Set Detail Size";
- ot->idname = "SCULPT_OT_set_detail_size";
- ot->description =
- "Set the mesh detail (either relative or constant one, depending on current dyntopo mode)";
-
- /* API callbacks. */
- ot->exec = sculpt_set_detail_size_exec;
- ot->poll = sculpt_and_dynamic_topology_poll;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-static void filter_cache_init_task_cb(void *__restrict userdata,
- const int i,
- const TaskParallelTLS *__restrict UNUSED(tls))
-{
- SculptThreadedTaskData *data = userdata;
- PBVHNode *node = data->nodes[i];
-
- SCULPT_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS);
-}
-
-static void sculpt_filter_cache_init(Object *ob, Sculpt *sd)
-{
- SculptSession *ss = ob->sculpt;
- PBVH *pbvh = ob->sculpt->pbvh;
-
- ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache");
-
- ss->filter_cache->random_seed = rand();
-
- float center[3] = {0.0f};
- SculptSearchSphereData search_data = {
- .original = true,
- .center = center,
- .radius_squared = FLT_MAX,
- .ignore_fully_masked = true,
-
- };
- BKE_pbvh_search_gather(pbvh,
- SCULPT_search_sphere_cb,
- &search_data,
- &ss->filter_cache->nodes,
- &ss->filter_cache->totnode);
-
- for (int i = 0; i < ss->filter_cache->totnode; i++) {
- BKE_pbvh_node_mark_normals_update(ss->filter_cache->nodes[i]);
- }
-
- /* mesh->runtime.subdiv_ccg is not available. Updating of the normals is done during drawing.
- * Filters can't use normals in multires. */
- if (BKE_pbvh_type(ss->pbvh) != PBVH_GRIDS) {
- BKE_pbvh_update_normals(ss->pbvh, NULL);
- }
-
- SculptThreadedTaskData data = {
- .sd = sd,
- .ob = ob,
- .nodes = ss->filter_cache->nodes,
- };
-
- PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(
- &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode);
- BKE_pbvh_parallel_range(
- 0, ss->filter_cache->totnode, &data, filter_cache_init_task_cb, &settings);
-}
-
-static void sculpt_filter_cache_free(SculptSession *ss)
-{
- if (ss->filter_cache->nodes) {
- MEM_freeN(ss->filter_cache->nodes);
- }
- if (ss->filter_cache->mask_update_it) {
- MEM_freeN(ss->filter_cache->mask_update_it);
- }
- if (ss->filter_cache->prev_mask) {
- MEM_freeN(ss->filter_cache->prev_mask);
- }
- if (ss->filter_cache->normal_factor) {
- MEM_freeN(ss->filter_cache->normal_factor);
- }
- if (ss->filter_cache->prev_face_set) {
- MEM_freeN(ss->filter_cache->prev_face_set);
- }
- if (ss->filter_cache->automask) {
- MEM_freeN(ss->filter_cache->automask);
- }
- if (ss->filter_cache->surface_smooth_laplacian_disp) {
- MEM_freeN(ss->filter_cache->surface_smooth_laplacian_disp);
- }
- MEM_freeN(ss->filter_cache);
- ss->filter_cache = NULL;
-}
-
-typedef enum eSculptMeshFilterTypes {
- MESH_FILTER_SMOOTH = 0,
- MESH_FILTER_SCALE = 1,
- MESH_FILTER_INFLATE = 2,
- MESH_FILTER_SPHERE = 3,
- MESH_FILTER_RANDOM = 4,
- MESH_FILTER_RELAX = 5,
- MESH_FILTER_RELAX_FACE_SETS = 6,
- MESH_FILTER_SURFACE_SMOOTH = 7,
-} eSculptMeshFilterTypes;
-
-static EnumPropertyItem prop_mesh_filter_types[] = {
- {MESH_FILTER_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth mesh"},
- {MESH_FILTER_SCALE, "SCALE", 0, "Scale", "Scale mesh"},
- {MESH_FILTER_INFLATE, "INFLATE", 0, "Inflate", "Inflate mesh"},
- {MESH_FILTER_SPHERE, "SPHERE", 0, "Sphere", "Morph into sphere"},
- {MESH_FILTER_RANDOM, "RANDOM", 0, "Random", "Randomize vertex positions"},
- {MESH_FILTER_RELAX, "RELAX", 0, "Relax", "Relax mesh"},
- {MESH_FILTER_RELAX_FACE_SETS,
- "RELAX_FACE_SETS",
- 0,
- "Relax Face Sets",
- "Smooth the edges of all the Face Sets"},
- {MESH_FILTER_SURFACE_SMOOTH,
- "SURFACE_SMOOTH",
- 0,
- "Surface Smooth",
- "Smooth the surface of the mesh, preserving the volume"},
- {0, NULL, 0, NULL, NULL},
-};
-
-typedef enum eMeshFilterDeformAxis {
- MESH_FILTER_DEFORM_X = 1 << 0,
- MESH_FILTER_DEFORM_Y = 1 << 1,
- MESH_FILTER_DEFORM_Z = 1 << 2,
-} eMeshFilterDeformAxis;
-
-static EnumPropertyItem prop_mesh_filter_deform_axis_items[] = {
- {MESH_FILTER_DEFORM_X, "X", 0, "X", "Deform in the X axis"},
- {MESH_FILTER_DEFORM_Y, "Y", 0, "Y", "Deform in the Y axis"},
- {MESH_FILTER_DEFORM_Z, "Z", 0, "Z", "Deform in the Z axis"},
- {0, NULL, 0, NULL, NULL},
-};
-
-static bool sculpt_mesh_filter_needs_pmap(int filter_type, bool use_face_sets)
-{
- return use_face_sets || ELEM(filter_type,
- MESH_FILTER_SMOOTH,
- MESH_FILTER_RELAX,
- MESH_FILTER_RELAX_FACE_SETS,
- MESH_FILTER_SURFACE_SMOOTH);
-}
-
-static void mesh_filter_task_cb(void *__restrict userdata,
- const int i,
- const TaskParallelTLS *__restrict UNUSED(tls))
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- PBVHNode *node = data->nodes[i];
-
- const int filter_type = data->filter_type;
-
- SculptOrigVertData orig_data;
- SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[i]);
-
- /* When using the relax face sets mehs filter, each 3 iterations, do a whole mesh relax to smooth
- * the contents of the Face Set. */
- /* This produces better results as the relax operation is no completely focused on the
- * boundaries. */
- const bool relax_face_sets = !(ss->filter_cache->iteration_count % 3 == 0);
-
- PBVHVertexIter vd;
- BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
- {
- SCULPT_orig_vert_data_update(&orig_data, &vd);
- float orig_co[3], val[3], avg[3], normal[3], disp[3], disp2[3], transform[3][3], final_pos[3];
- float fade = vd.mask ? *vd.mask : 0.0f;
- fade = 1.0f - fade;
- fade *= data->filter_strength;
-
- if (fade == 0.0f) {
- continue;
- }
-
- if (ss->filter_cache->active_face_set != SCULPT_FACE_SET_NONE) {
- if (!SCULPT_vertex_has_face_set(ss, vd.index, ss->filter_cache->active_face_set)) {
- continue;
- }
- /* Skip the edges of the face set when relaxing or smoothing. There is a relax face set
- * option to relax the boindaries independently. */
- if (filter_type == MESH_FILTER_RELAX) {
- if (!SCULPT_vertex_has_unique_face_set(ss, vd.index)) {
- continue;
- }
- }
- }
-
- if (ELEM(filter_type, MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS)) {
- copy_v3_v3(orig_co, vd.co);
- }
- else {
- copy_v3_v3(orig_co, orig_data.co);
- }
-
- if (filter_type == MESH_FILTER_RELAX_FACE_SETS) {
- if (relax_face_sets == SCULPT_vertex_has_unique_face_set(ss, vd.index)) {
- continue;
- }
- }
-
- switch (filter_type) {
- case MESH_FILTER_SMOOTH:
- CLAMP(fade, -1.0f, 1.0f);
- switch (BKE_pbvh_type(ss->pbvh)) {
- case PBVH_FACES:
- neighbor_average(ss, avg, vd.index);
- break;
- case PBVH_BMESH:
- bmesh_neighbor_average(avg, vd.bm_vert);
- break;
- case PBVH_GRIDS:
- SCULPT_neighbor_coords_average(ss, avg, vd.index);
- break;
- }
- sub_v3_v3v3(val, avg, orig_co);
- madd_v3_v3v3fl(val, orig_co, val, fade);
- sub_v3_v3v3(disp, val, orig_co);
- break;
- case MESH_FILTER_INFLATE:
- normal_short_to_float_v3(normal, orig_data.no);
- mul_v3_v3fl(disp, normal, fade);
- break;
- case MESH_FILTER_SCALE:
- unit_m3(transform);
- scale_m3_fl(transform, 1.0f + fade);
- copy_v3_v3(val, orig_co);
- mul_m3_v3(transform, val);
- sub_v3_v3v3(disp, val, orig_co);
- break;
- case MESH_FILTER_SPHERE:
- normalize_v3_v3(disp, orig_co);
- if (fade > 0.0f) {
- mul_v3_v3fl(disp, disp, fade);
- }
- else {
- mul_v3_v3fl(disp, disp, -fade);
- }
-
- unit_m3(transform);
- if (fade > 0.0f) {
- scale_m3_fl(transform, 1.0f - fade);
- }
- else {
- scale_m3_fl(transform, 1.0f + fade);
- }
- copy_v3_v3(val, orig_co);
- mul_m3_v3(transform, val);
- sub_v3_v3v3(disp2, val, orig_co);
-
- mid_v3_v3v3(disp, disp, disp2);
- break;
- case MESH_FILTER_RANDOM: {
- normal_short_to_float_v3(normal, orig_data.no);
- /* Index is not unique for multires, so hash by vertex coordinates. */
- const uint *hash_co = (const uint *)orig_co;
- const uint hash = BLI_hash_int_2d(hash_co[0], hash_co[1]) ^
- BLI_hash_int_2d(hash_co[2], ss->filter_cache->random_seed);
- mul_v3_fl(normal, hash * (1.0f / (float)0xFFFFFFFF) - 0.5f);
- mul_v3_v3fl(disp, normal, fade);
- break;
- }
- case MESH_FILTER_RELAX: {
- SCULPT_relax_vertex(
- ss, &vd, clamp_f(fade * ss->filter_cache->automask[vd.index], 0.0f, 1.0f), false, val);
- sub_v3_v3v3(disp, val, vd.co);
- break;
- }
- case MESH_FILTER_RELAX_FACE_SETS: {
- SCULPT_relax_vertex(ss, &vd, clamp_f(fade, 0.0f, 1.0f), relax_face_sets, val);
- sub_v3_v3v3(disp, val, vd.co);
- break;
- }
- case MESH_FILTER_SURFACE_SMOOTH: {
- surface_smooth_laplacian_step(ss,
- disp,
- vd.co,
- ss->filter_cache->surface_smooth_laplacian_disp,
- vd.index,
- orig_data.co,
- ss->filter_cache->surface_smooth_shape_preservation);
- break;
- }
- }
-
- for (int it = 0; it < 3; it++) {
- if (!ss->filter_cache->enabled_axis[it]) {
- disp[it] = 0.0f;
- }
- }
-
- if (filter_type == MESH_FILTER_SURFACE_SMOOTH) {
- madd_v3_v3v3fl(final_pos, vd.co, disp, clamp_f(fade, 0.0f, 1.0f));
- }
- else {
- add_v3_v3v3(final_pos, orig_co, disp);
- }
- copy_v3_v3(vd.co, final_pos);
- if (vd.mvert) {
- vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
- }
- }
- BKE_pbvh_vertex_iter_end;
-
- BKE_pbvh_node_mark_update(node);
-}
-
-static void mesh_filter_surface_smooth_displace_task_cb(
- void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls))
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- PBVHNode *node = data->nodes[i];
- PBVHVertexIter vd;
-
- BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
- {
- float fade = vd.mask ? *vd.mask : 0.0f;
- fade = 1.0f - fade;
- fade *= data->filter_strength;
- if (fade == 0.0f) {
- continue;
- }
- surface_smooth_displace_step(ss,
- vd.co,
- ss->filter_cache->surface_smooth_laplacian_disp,
- vd.index,
- ss->filter_cache->surface_smooth_current_vertex,
- clamp_f(fade, 0.0f, 1.0f));
- }
- BKE_pbvh_vertex_iter_end;
-}
-
-static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
- Object *ob = CTX_data_active_object(C);
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- SculptSession *ss = ob->sculpt;
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- int filter_type = RNA_enum_get(op->ptr, "type");
- float filter_strength = RNA_float_get(op->ptr, "strength");
- const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets");
-
- if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
- sculpt_filter_cache_free(ss);
- SCULPT_undo_push_end();
- sculpt_flush_update_done(C, ob, SCULPT_UPDATE_COORDS);
- return OPERATOR_FINISHED;
- }
-
- if (event->type != MOUSEMOVE) {
- return OPERATOR_RUNNING_MODAL;
- }
-
- float len = event->prevclickx - event->mval[0];
- filter_strength = filter_strength * -len * 0.001f * UI_DPI_FAC;
-
- SCULPT_vertex_random_access_init(ss);
-
- bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets);
- BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false);
-
- SculptThreadedTaskData data = {
- .sd = sd,
- .ob = ob,
- .nodes = ss->filter_cache->nodes,
- .filter_type = filter_type,
- .filter_strength = filter_strength,
- };
-
- PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(
- &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode);
- BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, mesh_filter_task_cb, &settings);
-
- if (filter_type == MESH_FILTER_SURFACE_SMOOTH) {
- BKE_pbvh_parallel_range(0,
- ss->filter_cache->totnode,
- &data,
- mesh_filter_surface_smooth_displace_task_cb,
- &settings);
- }
-
- ss->filter_cache->iteration_count++;
-
- if (ss->deform_modifiers_active || ss->shapekey_active) {
- sculpt_flush_stroke_deform(sd, ob, true);
- }
-
- /* The relax mesh filter needs the updated normals of the modified mesh after each iteration. */
- if (ELEM(MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS)) {
- BKE_pbvh_update_normals(ss->pbvh, ss->subdiv_ccg);
- }
-
- sculpt_flush_update_step(C, SCULPT_UPDATE_COORDS);
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event)
-{
- Object *ob = CTX_data_active_object(C);
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- int filter_type = RNA_enum_get(op->ptr, "type");
- SculptSession *ss = ob->sculpt;
- PBVH *pbvh = ob->sculpt->pbvh;
-
- int deform_axis = RNA_enum_get(op->ptr, "deform_axis");
- if (deform_axis == 0) {
- return OPERATOR_CANCELLED;
- }
-
- if (RNA_boolean_get(op->ptr, "use_face_sets")) {
- /* Update the active vertex */
- float mouse[2];
- SculptCursorGeometryInfo sgi;
- mouse[0] = event->mval[0];
- mouse[1] = event->mval[1];
- SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
- }
-
- const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets");
-
- SCULPT_vertex_random_access_init(ss);
-
- bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets);
- BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false);
-
- if (BKE_pbvh_type(pbvh) == PBVH_FACES && needs_pmap && !ob->sculpt->pmap) {
- return OPERATOR_CANCELLED;
- }
-
- SCULPT_undo_push_begin("Mesh filter");
-
- sculpt_filter_cache_init(ob, sd);
-
- if (use_face_sets) {
- ss->filter_cache->active_face_set = SCULPT_vertex_face_set_get(ss,
- SCULPT_active_vertex_get(ss));
- }
- else {
- ss->filter_cache->active_face_set = SCULPT_FACE_SET_NONE;
- }
-
- if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_SURFACE_SMOOTH) {
- ss->filter_cache->surface_smooth_laplacian_disp = MEM_mallocN(
- 3 * sizeof(float) * SCULPT_vertex_count_get(ss), "surface smooth disp");
- ss->filter_cache->surface_smooth_shape_preservation = RNA_float_get(
- op->ptr, "surface_smooth_shape_preservation");
- ss->filter_cache->surface_smooth_current_vertex = RNA_float_get(
- op->ptr, "surface_smooth_current_vertex");
- }
-
- ss->filter_cache->enabled_axis[0] = deform_axis & MESH_FILTER_DEFORM_X;
- ss->filter_cache->enabled_axis[1] = deform_axis & MESH_FILTER_DEFORM_Y;
- ss->filter_cache->enabled_axis[2] = deform_axis & MESH_FILTER_DEFORM_Z;
-
- if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_RELAX) {
- const int totvert = SCULPT_vertex_count_get(ss);
- ss->filter_cache->automask = MEM_mallocN(totvert * sizeof(float),
- "Relax filter edge automask");
- for (int i = 0; i < totvert; i++) {
- ss->filter_cache->automask[i] = 1.0f;
- }
- sculpt_boundary_edges_automasking_init(ob, 1, ss->filter_cache->automask);
- }
-
- WM_event_add_modal_handler(C, op);
- return OPERATOR_RUNNING_MODAL;
-}
-
-static void SCULPT_OT_mesh_filter(struct wmOperatorType *ot)
-{
- /* Identifiers. */
- ot->name = "Filter mesh";
- ot->idname = "SCULPT_OT_mesh_filter";
- ot->description = "Applies a filter to modify the current mesh";
-
- /* API callbacks. */
- ot->invoke = sculpt_mesh_filter_invoke;
- ot->modal = sculpt_mesh_filter_modal;
- ot->poll = SCULPT_mode_poll;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* RNA. */
- RNA_def_enum(ot->srna,
- "type",
- prop_mesh_filter_types,
- MESH_FILTER_INFLATE,
- "Filter type",
- "Operation that is going to be applied to the mesh");
- RNA_def_float(
- ot->srna, "strength", 1.0f, -10.0f, 10.0f, "Strength", "Filter Strength", -10.0f, 10.0f);
- RNA_def_enum_flag(ot->srna,
- "deform_axis",
- prop_mesh_filter_deform_axis_items,
- MESH_FILTER_DEFORM_X | MESH_FILTER_DEFORM_Y | MESH_FILTER_DEFORM_Z,
- "Deform axis",
- "Apply the deformation in the selected axis");
- ot->prop = RNA_def_boolean(ot->srna,
- "use_face_sets",
- false,
- "Use Face Sets",
- "Apply the filter only to the Face Mask under the cursor");
-
- /* Surface Smooth Mesh Filter properties. */
- RNA_def_float(ot->srna,
- "surface_smooth_shape_preservation",
- 0.5f,
- 0.0f,
- 1.0f,
- "Shape Preservation",
- "How much of the original shape is preserved when smoothing",
- 0.0f,
- 1.0f);
- RNA_def_float(ot->srna,
- "surface_smooth_current_vertex",
- 0.5f,
- 0.0f,
- 1.0f,
- "Per Vertex Displacement",
- "How much the position of each individual vertex influences the final result",
- 0.0f,
- 1.0f);
-}
-
-typedef enum eSculptMaskFilterTypes {
- MASK_FILTER_SMOOTH = 0,
- MASK_FILTER_SHARPEN = 1,
- MASK_FILTER_GROW = 2,
- MASK_FILTER_SHRINK = 3,
- MASK_FILTER_CONTRAST_INCREASE = 5,
- MASK_FILTER_CONTRAST_DECREASE = 6,
-} eSculptMaskFilterTypes;
-
-static EnumPropertyItem prop_mask_filter_types[] = {
- {MASK_FILTER_SMOOTH, "SMOOTH", 0, "Smooth Mask", "Smooth mask"},
- {MASK_FILTER_SHARPEN, "SHARPEN", 0, "Sharpen Mask", "Sharpen mask"},
- {MASK_FILTER_GROW, "GROW", 0, "Grow Mask", "Grow mask"},
- {MASK_FILTER_SHRINK, "SHRINK", 0, "Shrink Mask", "Shrink mask"},
- {MASK_FILTER_CONTRAST_INCREASE,
- "CONTRAST_INCREASE",
- 0,
- "Increase contrast",
- "Increase the contrast of the paint mask"},
- {MASK_FILTER_CONTRAST_DECREASE,
- "CONTRAST_DECREASE",
- 0,
- "Decrease contrast",
- "Decrease the contrast of the paint mask"},
- {0, NULL, 0, NULL, NULL},
-};
-
-static void mask_filter_task_cb(void *__restrict userdata,
- const int i,
- const TaskParallelTLS *__restrict UNUSED(tls))
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- PBVHNode *node = data->nodes[i];
- bool update = false;
-
- const int mode = data->filter_type;
- float contrast = 0.0f;
-
- PBVHVertexIter vd;
-
- if (mode == MASK_FILTER_CONTRAST_INCREASE) {
- contrast = 0.1f;
- }
-
- if (mode == MASK_FILTER_CONTRAST_DECREASE) {
- contrast = -0.1f;
- }
-
- BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
- {
- float delta, gain, offset, max, min;
- float prev_val = *vd.mask;
- SculptVertexNeighborIter ni;
- switch (mode) {
- case MASK_FILTER_SMOOTH:
- case MASK_FILTER_SHARPEN: {
- float val = 0.0f;
-
- switch (BKE_pbvh_type(ss->pbvh)) {
- case PBVH_FACES:
- val = neighbor_average_mask(ss, vd.index);
- break;
- case PBVH_BMESH:
- val = bmesh_neighbor_average_mask(vd.bm_vert, vd.cd_vert_mask_offset);
- break;
- case PBVH_GRIDS:
- val = grids_neighbor_average_mask(ss, vd.index);
- break;
- }
-
- val -= *vd.mask;
-
- if (mode == MASK_FILTER_SMOOTH) {
- *vd.mask += val;
- }
- else if (mode == MASK_FILTER_SHARPEN) {
- if (*vd.mask > 0.5f) {
- *vd.mask += 0.05f;
- }
- else {
- *vd.mask -= 0.05f;
- }
- *vd.mask += val / 2.0f;
- }
- break;
- }
- case MASK_FILTER_GROW:
- max = 0.0f;
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd.index, ni) {
- float vmask_f = data->prev_mask[ni.index];
- if (vmask_f > max) {
- max = vmask_f;
- }
- }
- SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
- *vd.mask = max;
- break;
- case MASK_FILTER_SHRINK:
- min = 1.0f;
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd.index, ni) {
- float vmask_f = data->prev_mask[ni.index];
- if (vmask_f < min) {
- min = vmask_f;
- }
- }
- SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
- *vd.mask = min;
- break;
- case MASK_FILTER_CONTRAST_INCREASE:
- case MASK_FILTER_CONTRAST_DECREASE:
- delta = contrast / 2.0f;
- gain = 1.0f - delta * 2.0f;
- if (contrast > 0) {
- gain = 1.0f / ((gain != 0.0f) ? gain : FLT_EPSILON);
- offset = gain * (-delta);
- }
- else {
- delta *= -1.0f;
- offset = gain * (delta);
- }
- *vd.mask = gain * (*vd.mask) + offset;
- break;
- }
- CLAMP(*vd.mask, 0.0f, 1.0f);
- if (*vd.mask != prev_val) {
- update = true;
- }
- if (vd.mvert) {
- vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
- }
- }
- BKE_pbvh_vertex_iter_end;
-
- if (update) {
- BKE_pbvh_node_mark_update_mask(node);
- }
-}
-
-static int sculpt_mask_filter_exec(bContext *C, wmOperator *op)
-{
- ARegion *region = CTX_wm_region(C);
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- PBVH *pbvh = ob->sculpt->pbvh;
- PBVHNode **nodes;
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- int totnode;
- int filter_type = RNA_enum_get(op->ptr, "filter_type");
-
- BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true);
-
- SCULPT_vertex_random_access_init(ss);
-
- if (!ob->sculpt->pmap) {
- return OPERATOR_CANCELLED;
- }
-
- int num_verts = SCULPT_vertex_count_get(ss);
-
- BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
- SCULPT_undo_push_begin("Mask filter");
-
- for (int i = 0; i < totnode; i++) {
- SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK);
- }
-
- float *prev_mask = NULL;
- int iterations = RNA_int_get(op->ptr, "iterations");
-
- /* Auto iteration count calculates the number of iteration based on the vertices of the mesh to
- * avoid adding an unnecessary amount of undo steps when using the operator from a shortcut.
- * One iteration per 50000 vertices in the mesh should be fine in most cases.
- * Maybe we want this to be configurable. */
- if (RNA_boolean_get(op->ptr, "auto_iteration_count")) {
- iterations = (int)(num_verts / 50000.0f) + 1;
- }
-
- for (int i = 0; i < iterations; i++) {
- if (ELEM(filter_type, MASK_FILTER_GROW, MASK_FILTER_SHRINK)) {
- prev_mask = MEM_mallocN(num_verts * sizeof(float), "prevmask");
- for (int j = 0; j < num_verts; j++) {
- prev_mask[j] = SCULPT_vertex_mask_get(ss, j);
- }
- }
-
- SculptThreadedTaskData data = {
- .sd = sd,
- .ob = ob,
- .nodes = nodes,
- .filter_type = filter_type,
- .prev_mask = prev_mask,
- };
-
- PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
- BKE_pbvh_parallel_range(0, totnode, &data, mask_filter_task_cb, &settings);
-
- if (ELEM(filter_type, MASK_FILTER_GROW, MASK_FILTER_SHRINK)) {
- MEM_freeN(prev_mask);
- }
- }
-
- MEM_SAFE_FREE(nodes);
-
- SCULPT_undo_push_end();
-
- ED_region_tag_redraw(region);
- WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
- return OPERATOR_FINISHED;
-}
-
-static void SCULPT_OT_mask_filter(struct wmOperatorType *ot)
-{
- /* Identifiers. */
- ot->name = "Mask Filter";
- ot->idname = "SCULPT_OT_mask_filter";
- ot->description = "Applies a filter to modify the current mask";
-
- /* API callbacks. */
- ot->exec = sculpt_mask_filter_exec;
- ot->poll = SCULPT_mode_poll;
-
- ot->flag = OPTYPE_REGISTER;
-
- /* RNA. */
- RNA_def_enum(ot->srna,
- "filter_type",
- prop_mask_filter_types,
- MASK_FILTER_SMOOTH,
- "Type",
- "Filter that is going to be applied to the mask");
- RNA_def_int(ot->srna,
- "iterations",
- 1,
- 1,
- 100,
- "Iterations",
- "Number of times that the filter is going to be applied",
- 1,
- 100);
- RNA_def_boolean(
- ot->srna,
- "auto_iteration_count",
- false,
- "Auto Iteration Count",
- "Use a automatic number of iterations based on the number of vertices of the sculpt");
-}
-
-static float neighbor_dirty_mask(SculptSession *ss, PBVHVertexIter *vd)
-{
- int total = 0;
- float avg[3];
- zero_v3(avg);
-
- SculptVertexNeighborIter ni;
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd->index, ni) {
- float normalized[3];
- sub_v3_v3v3(normalized, SCULPT_vertex_co_get(ss, ni.index), vd->co);
- normalize_v3(normalized);
- add_v3_v3(avg, normalized);
- total++;
- }
- SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
-
- if (total > 0) {
- mul_v3_fl(avg, 1.0f / total);
- float normal[3];
- if (vd->no) {
- normal_short_to_float_v3(normal, vd->no);
- }
- else {
- copy_v3_v3(normal, vd->fno);
- }
- float dot = dot_v3v3(avg, normal);
- float angle = max_ff(saacosf(dot), 0.0f);
- return angle;
- }
- return 0.0f;
-}
-
-typedef struct DirtyMaskRangeData {
- float min, max;
-} DirtyMaskRangeData;
-
-static void dirty_mask_compute_range_task_cb(void *__restrict userdata,
- const int i,
- const TaskParallelTLS *__restrict tls)
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- PBVHNode *node = data->nodes[i];
- DirtyMaskRangeData *range = tls->userdata_chunk;
- PBVHVertexIter vd;
-
- BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
- {
- float dirty_mask = neighbor_dirty_mask(ss, &vd);
- range->min = min_ff(dirty_mask, range->min);
- range->max = max_ff(dirty_mask, range->max);
- }
- BKE_pbvh_vertex_iter_end;
-}
-
-static void dirty_mask_compute_range_reduce(const void *__restrict UNUSED(userdata),
- void *__restrict chunk_join,
- void *__restrict chunk)
-{
- DirtyMaskRangeData *join = chunk_join;
- DirtyMaskRangeData *range = chunk;
- join->min = min_ff(range->min, join->min);
- join->max = max_ff(range->max, join->max);
-}
-
-static void dirty_mask_apply_task_cb(void *__restrict userdata,
- const int i,
- const TaskParallelTLS *__restrict UNUSED(tls))
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- PBVHNode *node = data->nodes[i];
- PBVHVertexIter vd;
-
- const bool dirty_only = data->dirty_mask_dirty_only;
- const float min = data->dirty_mask_min;
- const float max = data->dirty_mask_max;
-
- float range = max - min;
- if (range < 0.0001f) {
- range = 0.0f;
- }
- else {
- range = 1.0f / range;
- }
-
- BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
- {
- float dirty_mask = neighbor_dirty_mask(ss, &vd);
- float mask = *vd.mask + (1.0f - ((dirty_mask - min) * range));
- if (dirty_only) {
- mask = fminf(mask, 0.5f) * 2.0f;
- }
- *vd.mask = CLAMPIS(mask, 0.0f, 1.0f);
-
- if (vd.mvert) {
- vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
- }
- }
- BKE_pbvh_vertex_iter_end;
- BKE_pbvh_node_mark_update_mask(node);
-}
-
-static int sculpt_dirty_mask_exec(bContext *C, wmOperator *op)
-{
- ARegion *region = CTX_wm_region(C);
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- PBVH *pbvh = ob->sculpt->pbvh;
- PBVHNode **nodes;
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- int totnode;
-
- BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true);
-
- SCULPT_vertex_random_access_init(ss);
-
- if (!ob->sculpt->pmap) {
- return OPERATOR_CANCELLED;
- }
-
- BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
- SCULPT_undo_push_begin("Dirty Mask");
-
- for (int i = 0; i < totnode; i++) {
- SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK);
- }
-
- SculptThreadedTaskData data = {
- .sd = sd,
- .ob = ob,
- .nodes = nodes,
- .dirty_mask_dirty_only = RNA_boolean_get(op->ptr, "dirty_only"),
- };
- DirtyMaskRangeData range = {
- .min = FLT_MAX,
- .max = -FLT_MAX,
- };
-
- PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
-
- settings.func_reduce = dirty_mask_compute_range_reduce;
- settings.userdata_chunk = &range;
- settings.userdata_chunk_size = sizeof(DirtyMaskRangeData);
-
- BKE_pbvh_parallel_range(0, totnode, &data, dirty_mask_compute_range_task_cb, &settings);
- data.dirty_mask_min = range.min;
- data.dirty_mask_max = range.max;
- BKE_pbvh_parallel_range(0, totnode, &data, dirty_mask_apply_task_cb, &settings);
-
- MEM_SAFE_FREE(nodes);
-
- BKE_pbvh_update_vertex_data(pbvh, PBVH_UpdateMask);
-
- SCULPT_undo_push_end();
-
- ED_region_tag_redraw(region);
-
- WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
-
- return OPERATOR_FINISHED;
-}
-
-static void SCULPT_OT_dirty_mask(struct wmOperatorType *ot)
-{
- /* Identifiers. */
- ot->name = "Dirty Mask";
- ot->idname = "SCULPT_OT_dirty_mask";
- ot->description = "Generates a mask based on the geometry cavity and pointiness";
-
- /* API callbacks. */
- ot->exec = sculpt_dirty_mask_exec;
- ot->poll = SCULPT_mode_poll;
-
- ot->flag = OPTYPE_REGISTER;
-
- /* RNA. */
- RNA_def_boolean(
- ot->srna, "dirty_only", false, "Dirty Only", "Don't calculate cleans for convex areas");
-}
-
-static void sculpt_mask_expand_cancel(bContext *C, wmOperator *op)
-{
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set");
-
- MEM_freeN(op->customdata);
-
- for (int n = 0; n < ss->filter_cache->totnode; n++) {
- PBVHNode *node = ss->filter_cache->nodes[n];
- if (create_face_set) {
- for (int i = 0; i < ss->totpoly; i++) {
- ss->face_sets[i] = ss->filter_cache->prev_face_set[i];
- }
- }
- else {
- PBVHVertexIter vd;
- BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
- {
- *vd.mask = ss->filter_cache->prev_mask[vd.index];
- }
- BKE_pbvh_vertex_iter_end;
- }
-
- BKE_pbvh_node_mark_redraw(node);
- }
-
- if (!create_face_set) {
- sculpt_flush_update_step(C, SCULPT_UPDATE_MASK);
- }
- sculpt_filter_cache_free(ss);
- SCULPT_undo_push_end();
- sculpt_flush_update_done(C, ob, SCULPT_UPDATE_MASK);
- ED_workspace_status_text(C, NULL);
-}
-
-static void sculpt_expand_task_cb(void *__restrict userdata,
- const int i,
- const TaskParallelTLS *__restrict UNUSED(tls))
-{
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- PBVHNode *node = data->nodes[i];
- PBVHVertexIter vd;
- int update_it = data->mask_expand_update_it;
-
- BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_ALL)
- {
- int vi = vd.index;
- float final_mask = *vd.mask;
- if (data->mask_expand_use_normals) {
- if (ss->filter_cache->normal_factor[SCULPT_active_vertex_get(ss)] <
- ss->filter_cache->normal_factor[vd.index]) {
- final_mask = 1.0f;
- }
- else {
- final_mask = 0.0f;
- }
- }
- else {
- if (ss->filter_cache->mask_update_it[vi] <= update_it &&
- ss->filter_cache->mask_update_it[vi] != 0) {
- final_mask = 1.0f;
- }
- else {
- final_mask = 0.0f;
- }
- }
-
- if (data->mask_expand_create_face_set) {
- if (final_mask == 1.0f) {
- SCULPT_vertex_face_set_set(ss, vd.index, ss->filter_cache->new_face_set);
- }
- BKE_pbvh_node_mark_redraw(node);
- }
- else {
-
- if (data->mask_expand_keep_prev_mask) {
- final_mask = MAX2(ss->filter_cache->prev_mask[vd.index], final_mask);
- }
-
- if (data->mask_expand_invert_mask) {
- final_mask = 1.0f - final_mask;
- }
-
- if (*vd.mask != final_mask) {
- if (vd.mvert) {
- vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
- }
- *vd.mask = final_mask;
- BKE_pbvh_node_mark_update_mask(node);
- }
- }
- }
- BKE_pbvh_vertex_iter_end;
-}
-
-static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- ARegion *region = CTX_wm_region(C);
- float prevclick_f[2];
- copy_v2_v2(prevclick_f, op->customdata);
- int prevclick[2] = {(int)prevclick_f[0], (int)prevclick_f[1]};
- int len = (int)len_v2v2_int(prevclick, event->mval);
- len = abs(len);
- int mask_speed = RNA_int_get(op->ptr, "mask_speed");
- int mask_expand_update_it = len / mask_speed;
- mask_expand_update_it = mask_expand_update_it + 1;
-
- const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set");
-
- if (RNA_boolean_get(op->ptr, "use_cursor")) {
- SculptCursorGeometryInfo sgi;
- float mouse[2];
- mouse[0] = event->mval[0];
- mouse[1] = event->mval[1];
- SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
- mask_expand_update_it = ss->filter_cache->mask_update_it[(int)SCULPT_active_vertex_get(ss)];
- }
-
- if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) ||
- (event->type == RIGHTMOUSE && event->val == KM_PRESS)) {
- /* Returning OPERATOR_CANCELLED will leak memory due to not finishing
- * undo. Better solution could be to make paint_mesh_restore_co work
- * for this case. */
- sculpt_mask_expand_cancel(C, op);
- return OPERATOR_FINISHED;
- }
-
- if ((event->type == LEFTMOUSE && event->val == KM_RELEASE) ||
- (event->type == EVT_RETKEY && event->val == KM_PRESS) ||
- (event->type == EVT_PADENTER && event->val == KM_PRESS)) {
-
- /* Smooth iterations. */
- SculptThreadedTaskData data = {
- .sd = sd,
- .ob = ob,
- .nodes = ss->filter_cache->nodes,
- .filter_type = MASK_FILTER_SMOOTH,
- };
-
- int smooth_iterations = RNA_int_get(op->ptr, "smooth_iterations");
- BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false);
- for (int i = 0; i < smooth_iterations; i++) {
- PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(
- &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode);
- BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, mask_filter_task_cb, &settings);
- }
-
- /* Pivot position. */
- if (RNA_boolean_get(op->ptr, "update_pivot")) {
- const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
- const float threshold = 0.2f;
- float avg[3];
- int total = 0;
- zero_v3(avg);
-
- for (int n = 0; n < ss->filter_cache->totnode; n++) {
- PBVHVertexIter vd;
- BKE_pbvh_vertex_iter_begin(ss->pbvh, ss->filter_cache->nodes[n], vd, PBVH_ITER_UNIQUE)
- {
- const float mask = (vd.mask) ? *vd.mask : 0.0f;
- if (mask < (0.5f + threshold) && mask > (0.5f - threshold)) {
- if (SCULPT_check_vertex_pivot_symmetry(
- vd.co, ss->filter_cache->mask_expand_initial_co, symm)) {
- add_v3_v3(avg, vd.co);
- total++;
- }
- }
- }
- BKE_pbvh_vertex_iter_end;
- }
-
- if (total > 0) {
- mul_v3_fl(avg, 1.0f / total);
- copy_v3_v3(ss->pivot_pos, avg);
- }
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
- }
-
- MEM_freeN(op->customdata);
-
- for (int i = 0; i < ss->filter_cache->totnode; i++) {
- BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]);
- }
-
- sculpt_filter_cache_free(ss);
-
- SCULPT_undo_push_end();
- sculpt_flush_update_done(C, ob, SCULPT_UPDATE_MASK);
- ED_workspace_status_text(C, NULL);
- return OPERATOR_FINISHED;
- }
-
- /* When pressing Ctrl, expand directly to the max number of iterations. This allows to flood fill
- * mask and face sets by connectivity directly. */
- if (event->ctrl) {
- mask_expand_update_it = ss->filter_cache->mask_update_last_it - 1;
- }
-
- if (!ELEM(event->type, MOUSEMOVE, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY)) {
- return OPERATOR_RUNNING_MODAL;
- }
-
- if (mask_expand_update_it == ss->filter_cache->mask_update_current_it) {
- ED_region_tag_redraw(region);
- return OPERATOR_RUNNING_MODAL;
- }
-
- if (mask_expand_update_it < ss->filter_cache->mask_update_last_it) {
-
- if (create_face_set) {
- for (int i = 0; i < ss->totpoly; i++) {
- ss->face_sets[i] = ss->filter_cache->prev_face_set[i];
- }
- }
- SculptThreadedTaskData data = {
- .sd = sd,
- .ob = ob,
- .nodes = ss->filter_cache->nodes,
- .mask_expand_update_it = mask_expand_update_it,
- .mask_expand_use_normals = RNA_boolean_get(op->ptr, "use_normals"),
- .mask_expand_invert_mask = RNA_boolean_get(op->ptr, "invert"),
- .mask_expand_keep_prev_mask = RNA_boolean_get(op->ptr, "keep_previous_mask"),
- .mask_expand_create_face_set = RNA_boolean_get(op->ptr, "create_face_set"),
- };
- PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(
- &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode);
- BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, sculpt_expand_task_cb, &settings);
- ss->filter_cache->mask_update_current_it = mask_expand_update_it;
- }
-
- sculpt_flush_update_step(C, SCULPT_UPDATE_MASK);
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-typedef struct MaskExpandFloodFillData {
- float original_normal[3];
- float edge_sensitivity;
- bool use_normals;
-} MaskExpandFloodFillData;
-
-static bool mask_expand_floodfill_cb(
- SculptSession *ss, int from_v, int to_v, bool is_duplicate, void *userdata)
-{
- MaskExpandFloodFillData *data = userdata;
-
- if (!is_duplicate) {
- int to_it = ss->filter_cache->mask_update_it[from_v] + 1;
- ss->filter_cache->mask_update_it[to_v] = to_it;
- if (to_it > ss->filter_cache->mask_update_last_it) {
- ss->filter_cache->mask_update_last_it = to_it;
- }
-
- if (data->use_normals) {
- float current_normal[3], prev_normal[3];
- SCULPT_vertex_normal_get(ss, to_v, current_normal);
- SCULPT_vertex_normal_get(ss, from_v, prev_normal);
- const float from_edge_factor = ss->filter_cache->edge_factor[from_v];
- ss->filter_cache->edge_factor[to_v] = dot_v3v3(current_normal, prev_normal) *
- from_edge_factor;
- ss->filter_cache->normal_factor[to_v] = dot_v3v3(data->original_normal, current_normal) *
- powf(from_edge_factor, data->edge_sensitivity);
- CLAMP(ss->filter_cache->normal_factor[to_v], 0.0f, 1.0f);
- }
- }
- else {
- /* PBVH_GRIDS duplicate handling. */
- ss->filter_cache->mask_update_it[to_v] = ss->filter_cache->mask_update_it[from_v];
- if (data->use_normals) {
- ss->filter_cache->edge_factor[to_v] = ss->filter_cache->edge_factor[from_v];
- ss->filter_cache->normal_factor[to_v] = ss->filter_cache->normal_factor[from_v];
- }
- }
-
- return true;
-}
-
-static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent *event)
-{
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- PBVH *pbvh = ob->sculpt->pbvh;
-
- const bool use_normals = RNA_boolean_get(op->ptr, "use_normals");
- const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set");
-
- SculptCursorGeometryInfo sgi;
- float mouse[2];
- mouse[0] = event->mval[0];
- mouse[1] = event->mval[1];
-
- SCULPT_vertex_random_access_init(ss);
-
- op->customdata = MEM_mallocN(2 * sizeof(float), "initial mouse position");
- copy_v2_v2(op->customdata, mouse);
-
- SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
-
- BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true);
-
- int vertex_count = SCULPT_vertex_count_get(ss);
-
- ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache");
-
- BKE_pbvh_search_gather(pbvh, NULL, NULL, &ss->filter_cache->nodes, &ss->filter_cache->totnode);
-
- SCULPT_undo_push_begin("Mask Expand");
-
- if (create_face_set) {
- SCULPT_undo_push_node(ob, ss->filter_cache->nodes[0], SCULPT_UNDO_FACE_SETS);
- for (int i = 0; i < ss->filter_cache->totnode; i++) {
- BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]);
- }
- }
- else {
- for (int i = 0; i < ss->filter_cache->totnode; i++) {
- SCULPT_undo_push_node(ob, ss->filter_cache->nodes[i], SCULPT_UNDO_MASK);
- BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]);
- }
- }
-
- ss->filter_cache->mask_update_it = MEM_callocN(sizeof(int) * vertex_count,
- "mask update iteration");
- if (use_normals) {
- ss->filter_cache->normal_factor = MEM_callocN(sizeof(float) * vertex_count,
- "mask update normal factor");
- ss->filter_cache->edge_factor = MEM_callocN(sizeof(float) * vertex_count,
- "mask update normal factor");
- for (int i = 0; i < vertex_count; i++) {
- ss->filter_cache->edge_factor[i] = 1.0f;
- }
- }
-
- if (create_face_set) {
- ss->filter_cache->prev_face_set = MEM_callocN(sizeof(float) * ss->totpoly, "prev face mask");
- for (int i = 0; i < ss->totpoly; i++) {
- ss->filter_cache->prev_face_set[i] = ss->face_sets[i];
- }
- ss->filter_cache->new_face_set = SCULPT_face_set_next_available_get(ss);
- }
- else {
- ss->filter_cache->prev_mask = MEM_callocN(sizeof(float) * vertex_count, "prev mask");
- for (int i = 0; i < vertex_count; i++) {
- ss->filter_cache->prev_mask[i] = SCULPT_vertex_mask_get(ss, i);
- }
- }
-
- ss->filter_cache->mask_update_last_it = 1;
- ss->filter_cache->mask_update_current_it = 1;
- ss->filter_cache->mask_update_it[SCULPT_active_vertex_get(ss)] = 0;
-
- copy_v3_v3(ss->filter_cache->mask_expand_initial_co, SCULPT_active_vertex_co_get(ss));
-
- SculptFloodFill flood;
- SCULPT_floodfill_init(ss, &flood);
- SCULPT_floodfill_add_active(sd, ob, ss, &flood, FLT_MAX);
-
- MaskExpandFloodFillData fdata = {
- .use_normals = use_normals,
- .edge_sensitivity = RNA_int_get(op->ptr, "edge_sensitivity"),
- };
- SCULPT_active_vertex_normal_get(ss, fdata.original_normal);
- SCULPT_floodfill_execute(ss, &flood, mask_expand_floodfill_cb, &fdata);
- SCULPT_floodfill_free(&flood);
-
- if (use_normals) {
- for (int repeat = 0; repeat < 2; repeat++) {
- for (int i = 0; i < vertex_count; i++) {
- float avg = 0.0f;
- SculptVertexNeighborIter ni;
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, i, ni) {
- avg += ss->filter_cache->normal_factor[ni.index];
- }
- SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
- ss->filter_cache->normal_factor[i] = avg / ni.size;
- }
- }
-
- MEM_SAFE_FREE(ss->filter_cache->edge_factor);
- }
-
- SculptThreadedTaskData data = {
- .sd = sd,
- .ob = ob,
- .nodes = ss->filter_cache->nodes,
- .mask_expand_update_it = 0,
- .mask_expand_use_normals = RNA_boolean_get(op->ptr, "use_normals"),
- .mask_expand_invert_mask = RNA_boolean_get(op->ptr, "invert"),
- .mask_expand_keep_prev_mask = RNA_boolean_get(op->ptr, "keep_previous_mask"),
- .mask_expand_create_face_set = RNA_boolean_get(op->ptr, "create_face_set"),
- };
- PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(
- &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode);
- BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, sculpt_expand_task_cb, &settings);
-
- const char *status_str = TIP_(
- "Move the mouse to expand the mask from the active vertex. LMB: confirm mask, ESC/RMB: "
- "cancel");
- ED_workspace_status_text(C, status_str);
-
- sculpt_flush_update_step(C, SCULPT_UPDATE_MASK);
- WM_event_add_modal_handler(C, op);
- return OPERATOR_RUNNING_MODAL;
-}
-
-static void SCULPT_OT_mask_expand(wmOperatorType *ot)
-{
- /* Identifiers. */
- ot->name = "Mask Expand";
- ot->idname = "SCULPT_OT_mask_expand";
- ot->description = "Expands a mask from the initial active vertex under the cursor";
-
- /* API callbacks. */
- ot->invoke = sculpt_mask_expand_invoke;
- ot->modal = sculpt_mask_expand_modal;
- ot->cancel = sculpt_mask_expand_cancel;
- ot->poll = SCULPT_mode_poll;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- ot->prop = RNA_def_boolean(ot->srna, "invert", true, "Invert", "Invert the new mask");
- ot->prop = RNA_def_boolean(
- ot->srna, "use_cursor", true, "Use Cursor", "Expand the mask to the cursor position");
- ot->prop = RNA_def_boolean(ot->srna,
- "update_pivot",
- true,
- "Update Pivot Position",
- "Set the pivot position to the mask border after creating the mask");
- ot->prop = RNA_def_int(ot->srna, "smooth_iterations", 2, 0, 10, "Smooth iterations", "", 0, 10);
- ot->prop = RNA_def_int(ot->srna, "mask_speed", 5, 1, 10, "Mask speed", "", 1, 10);
-
- ot->prop = RNA_def_boolean(ot->srna,
- "use_normals",
- true,
- "Use Normals",
- "Generate the mask using the normals and curvature of the model");
- ot->prop = RNA_def_boolean(ot->srna,
- "keep_previous_mask",
- false,
- "Keep Previous Mask",
- "Generate the new mask on top of the current one");
- ot->prop = RNA_def_int(ot->srna,
- "edge_sensitivity",
- 300,
- 0,
- 2000,
- "Edge Detection Sensitivity",
- "Sensitivity for expanding the mask across sculpted sharp edges when "
- "using normals to generate the mask",
- 0,
- 2000);
- ot->prop = RNA_def_boolean(ot->srna,
- "create_face_set",
- false,
- "Expand Face Mask",
- "Expand a new Face Mask instead of the sculpt mask");
-}
-
void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float radius)
{
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
@@ -10808,1069 +7792,6 @@ void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float
ss->preview_vert_index_count = totpoints;
}
-void ED_sculpt_init_transform(struct bContext *C)
-{
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
-
- copy_v3_v3(ss->init_pivot_pos, ss->pivot_pos);
- copy_v4_v4(ss->init_pivot_rot, ss->pivot_rot);
-
- SCULPT_undo_push_begin("Transform");
- BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false);
-
- ss->pivot_rot[3] = 1.0f;
-
- SCULPT_vertex_random_access_init(ss);
- sculpt_filter_cache_init(ob, sd);
-}
-
-static void sculpt_transform_task_cb(void *__restrict userdata,
- const int i,
- const TaskParallelTLS *__restrict UNUSED(tls))
-{
-
- SculptThreadedTaskData *data = userdata;
- SculptSession *ss = data->ob->sculpt;
- PBVHNode *node = data->nodes[i];
-
- SculptOrigVertData orig_data;
- SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[i]);
-
- PBVHVertexIter vd;
-
- SCULPT_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS);
- BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
- {
- SCULPT_orig_vert_data_update(&orig_data, &vd);
- float transformed_co[3], orig_co[3], disp[3];
- float fade = vd.mask ? *vd.mask : 0.0f;
- copy_v3_v3(orig_co, orig_data.co);
- char symm_area = SCULPT_get_vertex_symm_area(orig_co);
-
- copy_v3_v3(transformed_co, orig_co);
- mul_m4_v3(data->transform_mats[(int)symm_area], transformed_co);
- sub_v3_v3v3(disp, transformed_co, orig_co);
- mul_v3_fl(disp, 1.0f - fade);
-
- add_v3_v3v3(vd.co, orig_co, disp);
-
- if (vd.mvert) {
- vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
- }
- }
- BKE_pbvh_vertex_iter_end;
-
- BKE_pbvh_node_mark_update(node);
-}
-
-void ED_sculpt_update_modal_transform(struct bContext *C)
-{
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
-
- SCULPT_vertex_random_access_init(ss);
- BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false);
-
- SculptThreadedTaskData data = {
- .sd = sd,
- .ob = ob,
- .nodes = ss->filter_cache->nodes,
- };
-
- float final_pivot_pos[3], d_t[3], d_r[4];
- float t_mat[4][4], r_mat[4][4], s_mat[4][4], pivot_mat[4][4], pivot_imat[4][4],
- transform_mat[4][4];
-
- copy_v3_v3(final_pivot_pos, ss->pivot_pos);
- for (int i = 0; i < PAINT_SYMM_AREAS; i++) {
- ePaintSymmetryAreas v_symm = i;
-
- copy_v3_v3(final_pivot_pos, ss->pivot_pos);
-
- unit_m4(pivot_mat);
-
- unit_m4(t_mat);
- unit_m4(r_mat);
- unit_m4(s_mat);
-
- /* Translation matrix. */
- sub_v3_v3v3(d_t, ss->pivot_pos, ss->init_pivot_pos);
- SCULPT_flip_v3_by_symm_area(d_t, symm, v_symm, ss->init_pivot_pos);
- translate_m4(t_mat, d_t[0], d_t[1], d_t[2]);
-
- /* Rotation matrix. */
- sub_qt_qtqt(d_r, ss->pivot_rot, ss->init_pivot_rot);
- normalize_qt(d_r);
- SCULPT_flip_quat_by_symm_area(d_r, symm, v_symm, ss->init_pivot_pos);
- quat_to_mat4(r_mat, d_r);
-
- /* Scale matrix. */
- size_to_mat4(s_mat, ss->pivot_scale);
-
- /* Pivot matrix. */
- SCULPT_flip_v3_by_symm_area(final_pivot_pos, symm, v_symm, ss->init_pivot_pos);
- translate_m4(pivot_mat, final_pivot_pos[0], final_pivot_pos[1], final_pivot_pos[2]);
- invert_m4_m4(pivot_imat, pivot_mat);
-
- /* Final transform matrix. */
- mul_m4_m4m4(transform_mat, r_mat, t_mat);
- mul_m4_m4m4(transform_mat, transform_mat, s_mat);
- mul_m4_m4m4(data.transform_mats[i], transform_mat, pivot_imat);
- mul_m4_m4m4(data.transform_mats[i], pivot_mat, data.transform_mats[i]);
- }
-
- PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(
- &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode);
- BKE_pbvh_parallel_range(
- 0, ss->filter_cache->totnode, &data, sculpt_transform_task_cb, &settings);
-
- if (ss->deform_modifiers_active || ss->shapekey_active) {
- sculpt_flush_stroke_deform(sd, ob, true);
- }
-
- sculpt_flush_update_step(C, SCULPT_UPDATE_COORDS);
-}
-
-void ED_sculpt_end_transform(struct bContext *C)
-{
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- if (ss->filter_cache) {
- sculpt_filter_cache_free(ss);
- }
- SCULPT_undo_push_end();
- sculpt_flush_update_done(C, ob, SCULPT_UPDATE_COORDS);
-}
-
-typedef enum eSculptPivotPositionModes {
- SCULPT_PIVOT_POSITION_ORIGIN = 0,
- SCULPT_PIVOT_POSITION_UNMASKED = 1,
- SCULPT_PIVOT_POSITION_MASK_BORDER = 2,
- SCULPT_PIVOT_POSITION_ACTIVE_VERTEX = 3,
- SCULPT_PIVOT_POSITION_CURSOR_SURFACE = 4,
-} eSculptPivotPositionModes;
-
-static EnumPropertyItem prop_sculpt_pivot_position_types[] = {
- {SCULPT_PIVOT_POSITION_ORIGIN,
- "ORIGIN",
- 0,
- "Origin",
- "Sets the pivot to the origin of the sculpt"},
- {SCULPT_PIVOT_POSITION_UNMASKED,
- "UNMASKED",
- 0,
- "Unmasked",
- "Sets the pivot position to the average position of the unmasked vertices"},
- {SCULPT_PIVOT_POSITION_MASK_BORDER,
- "BORDER",
- 0,
- "Mask border",
- "Sets the pivot position to the center of the border of the mask"},
- {SCULPT_PIVOT_POSITION_ACTIVE_VERTEX,
- "ACTIVE",
- 0,
- "Active vertex",
- "Sets the pivot position to the active vertex position"},
- {SCULPT_PIVOT_POSITION_CURSOR_SURFACE,
- "SURFACE",
- 0,
- "Surface",
- "Sets the pivot position to the surface under the cursor"},
- {0, NULL, 0, NULL, NULL},
-};
-
-static int sculpt_set_pivot_position_exec(bContext *C, wmOperator *op)
-{
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- ARegion *region = CTX_wm_region(C);
- Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
-
- int mode = RNA_enum_get(op->ptr, "mode");
-
- BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true);
-
- /* Pivot to center. */
- if (mode == SCULPT_PIVOT_POSITION_ORIGIN) {
- zero_v3(ss->pivot_pos);
- }
- /* Pivot to active vertex. */
- else if (mode == SCULPT_PIVOT_POSITION_ACTIVE_VERTEX) {
- copy_v3_v3(ss->pivot_pos, SCULPT_active_vertex_co_get(ss));
- }
- /* Pivot to raycast surface. */
- else if (mode == SCULPT_PIVOT_POSITION_CURSOR_SURFACE) {
- float stroke_location[3];
- float mouse[2];
- mouse[0] = RNA_float_get(op->ptr, "mouse_x");
- mouse[1] = RNA_float_get(op->ptr, "mouse_y");
- if (SCULPT_stroke_get_location(C, stroke_location, mouse)) {
- copy_v3_v3(ss->pivot_pos, stroke_location);
- }
- }
- else {
- PBVHNode **nodes;
- int totnode;
- BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
-
- float avg[3];
- int total = 0;
- zero_v3(avg);
-
- /* Pivot to unmasked. */
- if (mode == SCULPT_PIVOT_POSITION_UNMASKED) {
- for (int n = 0; n < totnode; n++) {
- PBVHVertexIter vd;
- BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
- {
- const float mask = (vd.mask) ? *vd.mask : 0.0f;
- if (mask < 1.0f) {
- if (SCULPT_check_vertex_pivot_symmetry(vd.co, ss->pivot_pos, symm)) {
- add_v3_v3(avg, vd.co);
- total++;
- }
- }
- }
- BKE_pbvh_vertex_iter_end;
- }
- }
- /* Pivot to mask border. */
- else if (mode == SCULPT_PIVOT_POSITION_MASK_BORDER) {
- const float threshold = 0.2f;
-
- for (int n = 0; n < totnode; n++) {
- PBVHVertexIter vd;
- BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
- {
- const float mask = (vd.mask) ? *vd.mask : 0.0f;
- if (mask < (0.5f + threshold) && mask > (0.5f - threshold)) {
- if (SCULPT_check_vertex_pivot_symmetry(vd.co, ss->pivot_pos, symm)) {
- add_v3_v3(avg, vd.co);
- total++;
- }
- }
- }
- BKE_pbvh_vertex_iter_end;
- }
- }
-
- if (total > 0) {
- mul_v3_fl(avg, 1.0f / total);
- copy_v3_v3(ss->pivot_pos, avg);
- }
-
- MEM_SAFE_FREE(nodes);
- }
-
- ED_region_tag_redraw(region);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
-
- return OPERATOR_FINISHED;
-}
-
-static int sculpt_set_pivot_position_invoke(bContext *C, wmOperator *op, const wmEvent *event)
-{
- RNA_float_set(op->ptr, "mouse_x", event->mval[0]);
- RNA_float_set(op->ptr, "mouse_y", event->mval[1]);
- return sculpt_set_pivot_position_exec(C, op);
-}
-
-static void SCULPT_OT_set_pivot_position(wmOperatorType *ot)
-{
- /* Identifiers. */
- ot->name = "Set Pivot Position";
- ot->idname = "SCULPT_OT_set_pivot_position";
- ot->description = "Sets the sculpt transform pivot position";
-
- /* API callbacks. */
- ot->invoke = sculpt_set_pivot_position_invoke;
- ot->exec = sculpt_set_pivot_position_exec;
- ot->poll = SCULPT_mode_poll;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_enum(ot->srna,
- "mode",
- prop_sculpt_pivot_position_types,
- SCULPT_PIVOT_POSITION_UNMASKED,
- "Mode",
- "");
-
- RNA_def_float(ot->srna,
- "mouse_x",
- 0.0f,
- 0.0f,
- FLT_MAX,
- "Mouse Position X",
- "Position of the mouse used for \"Surface\" mode",
- 0.0f,
- 10000.0f);
- RNA_def_float(ot->srna,
- "mouse_y",
- 0.0f,
- 0.0f,
- FLT_MAX,
- "Mouse Position Y",
- "Position of the mouse used for \"Surface\" mode",
- 0.0f,
- 10000.0f);
-}
-
-typedef enum eSculptFaceGroupsCreateModes {
- SCULPT_FACE_SET_MASKED = 0,
- SCULPT_FACE_SET_VISIBLE = 1,
- SCULPT_FACE_SET_ALL = 2,
- SCULPT_FACE_SET_SELECTION = 3,
-} eSculptFaceGroupsCreateModes;
-
-static EnumPropertyItem prop_sculpt_face_set_create_types[] = {
- {
- SCULPT_FACE_SET_MASKED,
- "MASKED",
- 0,
- "Face Set From Masked",
- "Create a new Face Set from the masked faces",
- },
- {
- SCULPT_FACE_SET_VISIBLE,
- "VISIBLE",
- 0,
- "Face Set From Visible",
- "Create a new Face Set from the visible vertices",
- },
- {
- SCULPT_FACE_SET_ALL,
- "ALL",
- 0,
- "Face Set Full Mesh",
- "Create an unique Face Set with all faces in the sculpt",
- },
- {
- SCULPT_FACE_SET_SELECTION,
- "SELECTION",
- 0,
- "Face Set From Edit Mode Selection",
- "Create an Face Set corresponding to the Edit Mode face selection",
- },
- {0, NULL, 0, NULL, NULL},
-};
-
-static int sculpt_face_set_create_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- ARegion *region = CTX_wm_region(C);
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
-
- const int mode = RNA_enum_get(op->ptr, "mode");
-
- /* Dyntopo and Multires not supported for now. */
- if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) {
- return OPERATOR_CANCELLED;
- }
-
- BKE_sculpt_update_object_for_edit(depsgraph, ob, true, mode == SCULPT_FACE_SET_MASKED);
-
- const int tot_vert = SCULPT_vertex_count_get(ss);
- float threshold = 0.5f;
-
- PBVH *pbvh = ob->sculpt->pbvh;
- PBVHNode **nodes;
- int totnode;
- BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
-
- if (!nodes) {
- return OPERATOR_CANCELLED;
- }
-
- SCULPT_undo_push_begin("face set change");
- SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
-
- const int next_face_set = SCULPT_face_set_next_available_get(ss);
-
- if (mode == SCULPT_FACE_SET_MASKED) {
- for (int i = 0; i < tot_vert; i++) {
- if (SCULPT_vertex_mask_get(ss, i) >= threshold && SCULPT_vertex_visible_get(ss, i)) {
- SCULPT_vertex_face_set_set(ss, i, next_face_set);
- }
- }
- }
-
- if (mode == SCULPT_FACE_SET_VISIBLE) {
- for (int i = 0; i < tot_vert; i++) {
- if (SCULPT_vertex_visible_get(ss, i)) {
- SCULPT_vertex_face_set_set(ss, i, next_face_set);
- }
- }
- }
-
- if (mode == SCULPT_FACE_SET_ALL) {
- for (int i = 0; i < tot_vert; i++) {
- SCULPT_vertex_face_set_set(ss, i, next_face_set);
- }
- }
-
- if (mode == SCULPT_FACE_SET_SELECTION) {
- Mesh *mesh = ob->data;
- BMesh *bm;
- const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh);
- bm = BM_mesh_create(&allocsize,
- &((struct BMeshCreateParams){
- .use_toolflags = true,
- }));
-
- BM_mesh_bm_from_me(bm,
- mesh,
- (&(struct BMeshFromMeshParams){
- .calc_face_normal = true,
- }));
-
- BMIter iter;
- BMFace *f;
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
- ss->face_sets[BM_elem_index_get(f)] = next_face_set;
- }
- }
- BM_mesh_free(bm);
- }
-
- for (int i = 0; i < totnode; i++) {
- BKE_pbvh_node_mark_redraw(nodes[i]);
- }
-
- MEM_SAFE_FREE(nodes);
-
- SCULPT_undo_push_end();
-
- ED_region_tag_redraw(region);
- WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
-
- return OPERATOR_FINISHED;
-}
-
-static void SCULPT_OT_face_sets_create(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Create Face Set";
- ot->idname = "SCULPT_OT_face_sets_create";
- ot->description = "Create a new Face Set";
-
- /* api callbacks */
- ot->invoke = sculpt_face_set_create_invoke;
- ot->poll = SCULPT_mode_poll;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- RNA_def_enum(
- ot->srna, "mode", prop_sculpt_face_set_create_types, SCULPT_FACE_SET_MASKED, "Mode", "");
-}
-
-typedef enum eSculptFaceSetsInitMode {
- SCULPT_FACE_SETS_FROM_LOOSE_PARTS = 0,
- SCULPT_FACE_SETS_FROM_MATERIALS = 1,
- SCULPT_FACE_SETS_FROM_NORMALS = 2,
- SCULPT_FACE_SETS_FROM_UV_SEAMS = 3,
- SCULPT_FACE_SETS_FROM_CREASES = 4,
- SCULPT_FACE_SETS_FROM_SHARP_EDGES = 5,
- SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT = 6,
- SCULPT_FACE_SETS_FROM_FACE_MAPS = 7,
-} eSculptFaceSetsInitMode;
-
-static EnumPropertyItem prop_sculpt_face_sets_init_types[] = {
- {
- SCULPT_FACE_SETS_FROM_LOOSE_PARTS,
- "LOOSE_PARTS",
- 0,
- "Face Sets From Loose Parts",
- "Create a Face Set per loose part in the mesh",
- },
- {
- SCULPT_FACE_SETS_FROM_MATERIALS,
- "MATERIALS",
- 0,
- "Face Sets From Material Slots",
- "Create a Face Set per Material Slot",
- },
- {
- SCULPT_FACE_SETS_FROM_NORMALS,
- "NORMALS",
- 0,
- "Face Sets From Mesh Normals",
- "Create Face Sets for Faces that have similar normal",
- },
- {
- SCULPT_FACE_SETS_FROM_UV_SEAMS,
- "UV_SEAMS",
- 0,
- "Face Sets From UV Seams",
- "Create Face Sets using UV Seams as boundaries",
- },
- {
- SCULPT_FACE_SETS_FROM_CREASES,
- "CREASES",
- 0,
- "Face Sets From Edge Creases",
- "Create Face Sets using Edge Creases as boundaries",
- },
- {
- SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT,
- "BEVEL_WEIGHT",
- 0,
- "Face Sets From Bevel Weight",
- "Create Face Sets using Bevel Weights as boundaries",
- },
- {
- SCULPT_FACE_SETS_FROM_SHARP_EDGES,
- "SHARP_EDGES",
- 0,
- "Face Sets From Sharp Edges",
- "Create Face Sets using Sharp Edges as boundaries",
- },
- {
- SCULPT_FACE_SETS_FROM_FACE_MAPS,
- "FACE_MAPS",
- 0,
- "Face Sets From Face Maps",
- "Create a Face Set per Face Map",
- },
- {0, NULL, 0, NULL, NULL},
-};
-
-typedef bool (*face_sets_flood_fill_test)(
- BMesh *bm, BMFace *from_f, BMEdge *from_e, BMFace *to_f, const float threshold);
-
-static bool sculpt_face_sets_init_loose_parts_test(BMesh *UNUSED(bm),
- BMFace *UNUSED(from_f),
- BMEdge *UNUSED(from_e),
- BMFace *UNUSED(to_f),
- const float UNUSED(threshold))
-{
- return true;
-}
-
-static bool sculpt_face_sets_init_normals_test(
- BMesh *UNUSED(bm), BMFace *from_f, BMEdge *UNUSED(from_e), BMFace *to_f, const float threshold)
-{
- return fabsf(dot_v3v3(from_f->no, to_f->no)) > threshold;
-}
-
-static bool sculpt_face_sets_init_uv_seams_test(BMesh *UNUSED(bm),
- BMFace *UNUSED(from_f),
- BMEdge *from_e,
- BMFace *UNUSED(to_f),
- const float UNUSED(threshold))
-{
- return !BM_elem_flag_test(from_e, BM_ELEM_SEAM);
-}
-
-static bool sculpt_face_sets_init_crease_test(
- BMesh *bm, BMFace *UNUSED(from_f), BMEdge *from_e, BMFace *UNUSED(to_f), const float threshold)
-{
- return BM_elem_float_data_get(&bm->edata, from_e, CD_CREASE) < threshold;
-}
-
-static bool sculpt_face_sets_init_bevel_weight_test(
- BMesh *bm, BMFace *UNUSED(from_f), BMEdge *from_e, BMFace *UNUSED(to_f), const float threshold)
-{
- return BM_elem_float_data_get(&bm->edata, from_e, CD_BWEIGHT) < threshold;
-}
-
-static bool sculpt_face_sets_init_sharp_edges_test(BMesh *UNUSED(bm),
- BMFace *UNUSED(from_f),
- BMEdge *from_e,
- BMFace *UNUSED(to_f),
- const float UNUSED(threshold))
-{
- return BM_elem_flag_test(from_e, BM_ELEM_SMOOTH);
-}
-
-static void sculpt_face_sets_init_flood_fill(Object *ob,
- face_sets_flood_fill_test test,
- const float threshold)
-{
- SculptSession *ss = ob->sculpt;
- Mesh *mesh = ob->data;
- BMesh *bm;
- const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh);
- bm = BM_mesh_create(&allocsize,
- &((struct BMeshCreateParams){
- .use_toolflags = true,
- }));
-
- BM_mesh_bm_from_me(bm,
- mesh,
- (&(struct BMeshFromMeshParams){
- .calc_face_normal = true,
- }));
-
- bool *visited_faces = MEM_callocN(sizeof(bool) * mesh->totpoly, "visited faces");
- const int totfaces = mesh->totpoly;
-
- int *face_sets = ss->face_sets;
-
- BM_mesh_elem_table_init(bm, BM_FACE);
- BM_mesh_elem_table_ensure(bm, BM_FACE);
-
- int next_face_set = 1;
-
- for (int i = 0; i < totfaces; i++) {
- if (!visited_faces[i]) {
- GSQueue *queue;
- queue = BLI_gsqueue_new(sizeof(int));
-
- face_sets[i] = next_face_set;
- visited_faces[i] = true;
- BLI_gsqueue_push(queue, &i);
-
- while (!BLI_gsqueue_is_empty(queue)) {
- int from_f;
- BLI_gsqueue_pop(queue, &from_f);
-
- BMFace *f, *f_neighbor;
- BMEdge *ed;
- BMIter iter_a, iter_b;
-
- f = BM_face_at_index(bm, from_f);
-
- BM_ITER_ELEM (ed, &iter_a, f, BM_EDGES_OF_FACE) {
- BM_ITER_ELEM (f_neighbor, &iter_b, ed, BM_FACES_OF_EDGE) {
- if (f_neighbor != f) {
- int neighbor_face_index = BM_elem_index_get(f_neighbor);
- if (!visited_faces[neighbor_face_index]) {
- if (test(bm, f, ed, f_neighbor, threshold)) {
- face_sets[neighbor_face_index] = next_face_set;
- visited_faces[neighbor_face_index] = true;
- BLI_gsqueue_push(queue, &neighbor_face_index);
- }
- }
- }
- }
- }
- }
-
- next_face_set += 1;
-
- BLI_gsqueue_free(queue);
- }
- }
-
- MEM_SAFE_FREE(visited_faces);
-
- BM_mesh_free(bm);
-}
-
-static void sculpt_face_sets_init_loop(Object *ob, const int mode)
-{
- Mesh *mesh = ob->data;
- SculptSession *ss = ob->sculpt;
- BMesh *bm;
- const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh);
- bm = BM_mesh_create(&allocsize,
- &((struct BMeshCreateParams){
- .use_toolflags = true,
- }));
-
- BM_mesh_bm_from_me(bm,
- mesh,
- (&(struct BMeshFromMeshParams){
- .calc_face_normal = true,
- }));
- BMIter iter;
- BMFace *f;
-
- const int cd_fmaps_offset = CustomData_get_offset(&bm->pdata, CD_FACEMAP);
-
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (mode == SCULPT_FACE_SETS_FROM_MATERIALS) {
- ss->face_sets[BM_elem_index_get(f)] = (int)(f->mat_nr + 1);
- }
- else if (mode == SCULPT_FACE_SETS_FROM_FACE_MAPS) {
- if (cd_fmaps_offset != -1) {
- ss->face_sets[BM_elem_index_get(f)] = BM_ELEM_CD_GET_INT(f, cd_fmaps_offset) + 2;
- }
- else {
- ss->face_sets[BM_elem_index_get(f)] = 1;
- }
- }
- }
- BM_mesh_free(bm);
-}
-
-static int sculpt_face_set_init_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- ARegion *region = CTX_wm_region(C);
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
-
- const int mode = RNA_enum_get(op->ptr, "mode");
-
- /* Dyntopo and Multires not supported for now. */
- if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) {
- return OPERATOR_CANCELLED;
- }
-
- BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false);
-
- PBVH *pbvh = ob->sculpt->pbvh;
- PBVHNode **nodes;
- int totnode;
- BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
-
- if (!nodes) {
- return OPERATOR_CANCELLED;
- }
-
- SCULPT_undo_push_begin("face set change");
- SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
-
- const float threshold = RNA_float_get(op->ptr, "threshold");
-
- switch (mode) {
- case SCULPT_FACE_SETS_FROM_LOOSE_PARTS:
- sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_loose_parts_test, threshold);
- break;
- case SCULPT_FACE_SETS_FROM_MATERIALS:
- sculpt_face_sets_init_loop(ob, SCULPT_FACE_SETS_FROM_MATERIALS);
- break;
- case SCULPT_FACE_SETS_FROM_NORMALS:
- sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_normals_test, threshold);
- break;
- case SCULPT_FACE_SETS_FROM_UV_SEAMS:
- sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_uv_seams_test, threshold);
- break;
- case SCULPT_FACE_SETS_FROM_CREASES:
- sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_crease_test, threshold);
- break;
- case SCULPT_FACE_SETS_FROM_SHARP_EDGES:
- sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_sharp_edges_test, threshold);
- break;
- case SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT:
- sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_bevel_weight_test, threshold);
- break;
- case SCULPT_FACE_SETS_FROM_FACE_MAPS:
- sculpt_face_sets_init_loop(ob, SCULPT_FACE_SETS_FROM_FACE_MAPS);
- break;
- }
-
- SCULPT_undo_push_end();
-
- /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */
- SCULPT_visibility_sync_all_face_sets_to_vertices(ss);
-
- for (int i = 0; i < totnode; i++) {
- BKE_pbvh_node_mark_update_visibility(nodes[i]);
- }
-
- BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility);
-
- MEM_SAFE_FREE(nodes);
-
- if (BKE_pbvh_type(pbvh) == PBVH_FACES) {
- BKE_mesh_flush_hidden_from_verts(ob->data);
- }
-
- ED_region_tag_redraw(region);
- DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
-
- View3D *v3d = CTX_wm_view3d(C);
- if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) {
- DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
- }
-
- return OPERATOR_FINISHED;
-}
-
-static void SCULPT_OT_face_sets_init(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Init Face Sets";
- ot->idname = "SCULPT_OT_face_sets_init";
- ot->description = "Initializes all Face Sets in the mesh";
-
- /* api callbacks */
- ot->invoke = sculpt_face_set_init_invoke;
- ot->poll = SCULPT_mode_poll;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- RNA_def_enum(
- ot->srna, "mode", prop_sculpt_face_sets_init_types, SCULPT_FACE_SET_MASKED, "Mode", "");
- RNA_def_float(
- ot->srna,
- "threshold",
- 0.5f,
- 0.0f,
- 1.0f,
- "Threshold",
- "Minimum value to consider a certain atribute a boundary when creating the Face Sets",
- 0.0f,
- 1.0f);
-}
-
-typedef enum eSculptFaceGroupVisibilityModes {
- SCULPT_FACE_SET_VISIBILITY_TOGGLE = 0,
- SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE = 1,
- SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE = 2,
- SCULPT_FACE_SET_VISIBILITY_INVERT = 3,
- SCULPT_FACE_SET_VISIBILITY_SHOW_ALL = 4,
-} eSculptFaceGroupVisibilityModes;
-
-static EnumPropertyItem prop_sculpt_face_sets_change_visibility_types[] = {
- {
- SCULPT_FACE_SET_VISIBILITY_TOGGLE,
- "TOGGLE",
- 0,
- "Toggle Visibility",
- "Hide all Face Sets except for the active one",
- },
- {
- SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE,
- "SHOW_ACTIVE",
- 0,
- "Show Active Face Set",
- "Show Active Face Set",
- },
- {
- SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE,
- "HIDE_ACTIVE",
- 0,
- "Hide Active Face Sets",
- "Hide Active Face Sets",
- },
- {
- SCULPT_FACE_SET_VISIBILITY_INVERT,
- "INVERT",
- 0,
- "Invert Face Set Visibility",
- "Invert Face Set Visibility",
- },
- {
- SCULPT_FACE_SET_VISIBILITY_SHOW_ALL,
- "SHOW_ALL",
- 0,
- "Show All Face Sets",
- "Show All Face Sets",
- },
- {0, NULL, 0, NULL, NULL},
-};
-
-static int sculpt_face_sets_change_visibility_invoke(bContext *C,
- wmOperator *op,
- const wmEvent *UNUSED(event))
-{
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- ARegion *region = CTX_wm_region(C);
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
-
- /* Dyntopo and Multires not supported for now. */
- if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) {
- return OPERATOR_CANCELLED;
- }
-
- BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true);
-
- const int tot_vert = SCULPT_vertex_count_get(ss);
- const int mode = RNA_enum_get(op->ptr, "mode");
- int active_vertex_index = SCULPT_active_vertex_get(ss);
- int active_face_set = SCULPT_vertex_face_set_get(ss, active_vertex_index);
-
- SCULPT_undo_push_begin("Hide area");
-
- PBVH *pbvh = ob->sculpt->pbvh;
- PBVHNode **nodes;
- int totnode;
-
- BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
-
- if (totnode == 0) {
- MEM_SAFE_FREE(nodes);
- return OPERATOR_CANCELLED;
- }
-
- SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
-
- if (mode == SCULPT_FACE_SET_VISIBILITY_TOGGLE) {
- bool hidden_vertex = false;
-
- /* This can fail with regular meshes with non-manifold geometry as the visibility state can't
- * be synced from face sets to non-manifold vertices. */
- if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
- for (int i = 0; i < tot_vert; i++) {
- if (!SCULPT_vertex_visible_get(ss, i)) {
- hidden_vertex = true;
- break;
- }
- }
- }
-
- for (int i = 0; i < ss->totpoly; i++) {
- if (ss->face_sets[i] <= 0) {
- hidden_vertex = true;
- break;
- }
- }
-
- if (hidden_vertex) {
- SCULPT_face_sets_visibility_all_set(ss, true);
- }
- else {
- SCULPT_face_sets_visibility_all_set(ss, false);
- SCULPT_face_set_visibility_set(ss, active_face_set, true);
- }
- }
-
- if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ALL) {
- SCULPT_face_sets_visibility_all_set(ss, true);
- }
-
- if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE) {
- SCULPT_face_sets_visibility_all_set(ss, false);
- SCULPT_face_set_visibility_set(ss, active_face_set, true);
- for (int i = 0; i < tot_vert; i++) {
- SCULPT_vertex_visible_set(ss,
- i,
- SCULPT_vertex_visible_get(ss, i) &&
- SCULPT_vertex_has_face_set(ss, i, active_face_set));
- }
- }
-
- if (mode == SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE) {
- SCULPT_face_set_visibility_set(ss, active_face_set, false);
- }
-
- if (mode == SCULPT_FACE_SET_VISIBILITY_INVERT) {
- SCULPT_face_sets_visibility_invert(ss);
- }
-
- /* For modes that use the cursor active vertex, update the rotation origin for viewport
- * navigation. */
- if (ELEM(mode, SCULPT_FACE_SET_VISIBILITY_TOGGLE, SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE)) {
- UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
- float location[3];
- copy_v3_v3(location, SCULPT_active_vertex_co_get(ss));
- mul_m4_v3(ob->obmat, location);
- copy_v3_v3(ups->average_stroke_accum, location);
- ups->average_stroke_counter = 1;
- ups->last_stroke_valid = true;
- }
-
- /* Sync face sets visibility and vertex visibility. */
- SCULPT_visibility_sync_all_face_sets_to_vertices(ss);
-
- SCULPT_undo_push_end();
-
- for (int i = 0; i < totnode; i++) {
- BKE_pbvh_node_mark_update_visibility(nodes[i]);
- }
-
- BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility);
-
- MEM_SAFE_FREE(nodes);
-
- if (BKE_pbvh_type(pbvh) == PBVH_FACES) {
- BKE_mesh_flush_hidden_from_verts(ob->data);
- }
-
- ED_region_tag_redraw(region);
- DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
-
- View3D *v3d = CTX_wm_view3d(C);
- if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) {
- DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
- }
- return OPERATOR_FINISHED;
-}
-
-static void SCULPT_OT_face_sets_change_visibility(wmOperatorType *ot)
-{
- /* Identifiers. */
- ot->name = "Face Sets Visibility";
- ot->idname = "SCULPT_OT_face_set_change_visibility";
- ot->description = "Change the visibility of the Face Sets of the sculpt";
-
- /* Api callbacks. */
- ot->invoke = sculpt_face_sets_change_visibility_invoke;
- ot->poll = SCULPT_mode_poll;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- RNA_def_enum(ot->srna,
- "mode",
- prop_sculpt_face_sets_change_visibility_types,
- SCULPT_FACE_SET_VISIBILITY_TOGGLE,
- "Mode",
- "");
-}
-
-static int sculpt_face_sets_randomize_colors_invoke(bContext *C,
- wmOperator *UNUSED(op),
- const wmEvent *UNUSED(event))
-{
-
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- ARegion *region = CTX_wm_region(C);
-
- /* Dyntopo and Multires not supported for now. */
- if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) {
- return OPERATOR_CANCELLED;
- }
-
- PBVH *pbvh = ob->sculpt->pbvh;
- PBVHNode **nodes;
- int totnode;
- Mesh *mesh = ob->data;
-
- mesh->face_sets_color_seed += 1;
- if (ss->face_sets) {
- const int random_index = clamp_i(
- ss->totpoly * BLI_hash_int_01(mesh->face_sets_color_seed), 0, max_ii(0, ss->totpoly - 1));
- mesh->face_sets_color_default = ss->face_sets[random_index];
- }
- BKE_pbvh_face_sets_color_set(pbvh, mesh->face_sets_color_seed, mesh->face_sets_color_default);
-
- BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
- for (int i = 0; i < totnode; i++) {
- BKE_pbvh_node_mark_redraw(nodes[i]);
- }
-
- MEM_SAFE_FREE(nodes);
-
- View3D *v3d = CTX_wm_view3d(C);
- if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) {
- DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
- }
-
- ED_region_tag_redraw(region);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
-
- return OPERATOR_FINISHED;
-}
-
-static void SCULPT_OT_face_sets_randomize_colors(wmOperatorType *ot)
-{
- /* Identifiers. */
- ot->name = "Randomize Face Sets Colors";
- ot->idname = "SCULPT_OT_face_sets_randomize_colors";
- ot->description = "Generates a new set of random colors to render the Face Sets in the viewport";
-
- /* Api callbacks. */
- ot->invoke = sculpt_face_sets_randomize_colors_invoke;
- ot->poll = SCULPT_mode_poll;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
void ED_operatortypes_sculpt(void)
{
diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.c b/source/blender/editors/sculpt_paint/sculpt_automasking.c
new file mode 100644
index 00000000000..68fa7ac01ae
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.c
@@ -0,0 +1,304 @@
+/*
+ * 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) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_hash.h"
+#include "BLI_math.h"
+#include "BLI_task.h"
+
+#include "DNA_brush_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_context.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_object.h"
+#include "BKE_paint.h"
+#include "BKE_pbvh.h"
+#include "BKE_scene.h"
+
+#include "DEG_depsgraph.h"
+
+#include "WM_api.h"
+#include "WM_message.h"
+#include "WM_toolsystem.h"
+#include "WM_types.h"
+
+#include "ED_object.h"
+#include "ED_screen.h"
+#include "ED_sculpt.h"
+#include "paint_intern.h"
+#include "sculpt_intern.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "bmesh.h"
+
+#include <math.h>
+#include <stdlib.h>
+
+bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd,
+ const Brush *br,
+ const eAutomasking_flag mode)
+{
+ return br->automasking_flags & mode || sd->automasking_flags & mode;
+}
+
+bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br)
+{
+ if (SCULPT_stroke_is_dynamic_topology(ss, br)) {
+ return false;
+ }
+ if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_TOPOLOGY)) {
+ return true;
+ }
+ if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_FACE_SETS)) {
+ return true;
+ }
+ if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_BOUNDARY_EDGES)) {
+ return true;
+ }
+ if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS)) {
+ return true;
+ }
+ return false;
+}
+
+float SCULPT_automasking_factor_get(SculptSession *ss, int vert)
+{
+ if (ss->cache->automask) {
+ return ss->cache->automask[vert];
+ }
+ else {
+ return 1.0f;
+ }
+}
+
+void SCULPT_automasking_end(Object *ob)
+{
+ SculptSession *ss = ob->sculpt;
+ if (ss->cache && ss->cache->automask) {
+ MEM_freeN(ss->cache->automask);
+ }
+}
+
+static bool sculpt_automasking_is_constrained_by_radius(Brush *br)
+{
+ /* 2D falloff is not constrained by radius. */
+ if (br->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
+ return false;
+ }
+
+ if (ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE)) {
+ return true;
+ }
+ return false;
+}
+
+typedef struct AutomaskFloodFillData {
+ float *automask_factor;
+ float radius;
+ bool use_radius;
+ float location[3];
+ char symm;
+} AutomaskFloodFillData;
+
+static bool automask_floodfill_cb(
+ SculptSession *ss, int UNUSED(from_v), int to_v, bool UNUSED(is_duplicate), void *userdata)
+{
+ AutomaskFloodFillData *data = userdata;
+
+ data->automask_factor[to_v] = 1.0f;
+ return (!data->use_radius ||
+ SCULPT_is_vertex_inside_brush_radius_symm(
+ SCULPT_vertex_co_get(ss, to_v), data->location, data->radius, data->symm));
+}
+
+static float *SCULPT_topology_automasking_init(Sculpt *sd, Object *ob, float *automask_factor)
+{
+ SculptSession *ss = ob->sculpt;
+ Brush *brush = BKE_paint_brush(&sd->paint);
+
+ if (!SCULPT_is_automasking_enabled(sd, ss, brush)) {
+ return NULL;
+ }
+
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) {
+ BLI_assert(!"Topology masking: pmap missing");
+ return NULL;
+ }
+
+ const int totvert = SCULPT_vertex_count_get(ss);
+ for (int i = 0; i < totvert; i++) {
+ ss->cache->automask[i] = 0.0f;
+ }
+
+ /* Flood fill automask to connected vertices. Limited to vertices inside
+ * the brush radius if the tool requires it. */
+ SculptFloodFill flood;
+ SCULPT_floodfill_init(ss, &flood);
+ SCULPT_floodfill_add_active(sd, ob, ss, &flood, ss->cache->radius);
+
+ AutomaskFloodFillData fdata = {
+ .automask_factor = automask_factor,
+ .radius = ss->cache->radius,
+ .use_radius = sculpt_automasking_is_constrained_by_radius(brush),
+ .symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL,
+ };
+ copy_v3_v3(fdata.location, SCULPT_active_vertex_co_get(ss));
+ SCULPT_floodfill_execute(ss, &flood, automask_floodfill_cb, &fdata);
+ SCULPT_floodfill_free(&flood);
+
+ return automask_factor;
+}
+
+static float *sculpt_face_sets_automasking_init(Sculpt *sd, Object *ob, float *automask_factor)
+{
+ SculptSession *ss = ob->sculpt;
+ Brush *brush = BKE_paint_brush(&sd->paint);
+
+ if (!SCULPT_is_automasking_enabled(sd, ss, brush)) {
+ return NULL;
+ }
+
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) {
+ BLI_assert(!"Face Sets automasking: pmap missing");
+ return NULL;
+ }
+
+ int tot_vert = SCULPT_vertex_count_get(ss);
+ int active_face_set = SCULPT_vertex_face_set_get(ss, SCULPT_active_vertex_get(ss));
+ for (int i = 0; i < tot_vert; i++) {
+ if (!SCULPT_vertex_has_face_set(ss, i, active_face_set)) {
+ automask_factor[i] *= 0.0f;
+ }
+ }
+
+ return automask_factor;
+}
+
+#define EDGE_DISTANCE_INF -1
+
+float *SCULPT_boundary_automasking_init(Object *ob,
+ eBoundaryAutomaskMode mode,
+ int propagation_steps,
+ float *automask_factor)
+{
+ SculptSession *ss = ob->sculpt;
+
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) {
+ BLI_assert(!"Boundary Edges masking: pmap missing");
+ return NULL;
+ }
+
+ const int totvert = SCULPT_vertex_count_get(ss);
+ int *edge_distance = MEM_callocN(sizeof(int) * totvert, "automask_factor");
+
+ for (int i = 0; i < totvert; i++) {
+ edge_distance[i] = EDGE_DISTANCE_INF;
+ switch (mode) {
+ case AUTOMASK_INIT_BOUNDARY_EDGES:
+ if (!SCULPT_vertex_is_boundary(ss, i)) {
+ edge_distance[i] = 0;
+ }
+ break;
+ case AUTOMASK_INIT_BOUNDARY_FACE_SETS:
+ if (!SCULPT_vertex_has_unique_face_set(ss, i)) {
+ edge_distance[i] = 0;
+ }
+ break;
+ }
+ }
+
+ for (int propagation_it = 0; propagation_it < propagation_steps; propagation_it++) {
+ for (int i = 0; i < totvert; i++) {
+ if (edge_distance[i] == EDGE_DISTANCE_INF) {
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, i, ni) {
+ if (edge_distance[ni.index] == propagation_it) {
+ edge_distance[i] = propagation_it + 1;
+ }
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ }
+ }
+ }
+
+ for (int i = 0; i < totvert; i++) {
+ if (edge_distance[i] != EDGE_DISTANCE_INF) {
+ const float p = 1.0f - ((float)edge_distance[i] / (float)propagation_steps);
+ const float edge_boundary_automask = pow2f(p);
+ automask_factor[i] *= (1.0f - edge_boundary_automask);
+ }
+ }
+
+ MEM_SAFE_FREE(edge_distance);
+ return automask_factor;
+}
+
+void SCULPT_automasking_init(Sculpt *sd, Object *ob)
+{
+ SculptSession *ss = ob->sculpt;
+ Brush *brush = BKE_paint_brush(&sd->paint);
+ const int totvert = SCULPT_vertex_count_get(ss);
+
+ if (!SCULPT_is_automasking_enabled(sd, ss, brush)) {
+ return;
+ }
+
+ ss->cache->automask = MEM_callocN(sizeof(float) * SCULPT_vertex_count_get(ss),
+ "automask_factor");
+
+ for (int i = 0; i < totvert; i++) {
+ ss->cache->automask[i] = 1.0f;
+ }
+
+ if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_TOPOLOGY)) {
+ SCULPT_vertex_random_access_init(ss);
+ SCULPT_topology_automasking_init(sd, ob, ss->cache->automask);
+ }
+ if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_FACE_SETS)) {
+ SCULPT_vertex_random_access_init(ss);
+ sculpt_face_sets_automasking_init(sd, ob, ss->cache->automask);
+ }
+
+ if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_BOUNDARY_EDGES)) {
+ SCULPT_vertex_random_access_init(ss);
+ SCULPT_boundary_automasking_init(ob,
+ AUTOMASK_INIT_BOUNDARY_EDGES,
+ brush->automasking_boundary_edges_propagation_steps,
+ ss->cache->automask);
+ }
+ if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS)) {
+ SCULPT_vertex_random_access_init(ss);
+ SCULPT_boundary_automasking_init(ob,
+ AUTOMASK_INIT_BOUNDARY_FACE_SETS,
+ brush->automasking_boundary_edges_propagation_steps,
+ ss->cache->automask);
+ }
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt_detail.c b/source/blender/editors/sculpt_paint/sculpt_detail.c
new file mode 100644
index 00000000000..a99aa3d1bcf
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/sculpt_detail.c
@@ -0,0 +1,428 @@
+/*
+ * 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) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_hash.h"
+#include "BLI_math.h"
+#include "BLI_task.h"
+
+#include "BLT_translation.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_context.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_object.h"
+#include "BKE_paint.h"
+#include "BKE_pbvh.h"
+#include "BKE_scene.h"
+#include "BKE_screen.h"
+
+#include "DEG_depsgraph.h"
+
+#include "WM_api.h"
+#include "WM_message.h"
+#include "WM_toolsystem.h"
+#include "WM_types.h"
+
+#include "ED_object.h"
+#include "ED_screen.h"
+#include "ED_sculpt.h"
+#include "ED_view3d.h"
+#include "paint_intern.h"
+#include "sculpt_intern.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "UI_interface.h"
+
+#include "bmesh.h"
+
+#include <math.h>
+#include <stdlib.h>
+
+typedef struct {
+ const float *ray_start;
+ bool hit;
+ float depth;
+ float edge_length;
+
+ struct IsectRayPrecalc isect_precalc;
+} SculptDetailRaycastData;
+
+static bool sculpt_and_constant_or_manual_detail_poll(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+
+ return SCULPT_mode_poll(C) && ob->sculpt->bm &&
+ (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL));
+}
+
+static bool sculpt_and_dynamic_topology_poll(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+
+ return SCULPT_mode_poll(C) && ob->sculpt->bm;
+}
+
+static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ float size;
+ float bb_min[3], bb_max[3], center[3], dim[3];
+ int totnodes;
+ PBVHNode **nodes;
+
+ BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnodes);
+
+ if (!totnodes) {
+ return OPERATOR_CANCELLED;
+ }
+
+ for (int i = 0; i < totnodes; i++) {
+ BKE_pbvh_node_mark_topology_update(nodes[i]);
+ }
+ /* Get the bounding box, it's center and size. */
+ BKE_pbvh_bounding_box(ob->sculpt->pbvh, bb_min, bb_max);
+ add_v3_v3v3(center, bb_min, bb_max);
+ mul_v3_fl(center, 0.5f);
+ sub_v3_v3v3(dim, bb_max, bb_min);
+ size = max_fff(dim[0], dim[1], dim[2]);
+
+ /* Update topology size. */
+ float object_space_constant_detail = 1.0f / (sd->constant_detail * mat4_to_scale(ob->obmat));
+ BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail);
+
+ SCULPT_undo_push_begin("Dynamic topology flood fill");
+ SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_COORDS);
+
+ while (BKE_pbvh_bmesh_update_topology(
+ ss->pbvh, PBVH_Collapse | PBVH_Subdivide, center, NULL, size, false, false)) {
+ for (int i = 0; i < totnodes; i++) {
+ BKE_pbvh_node_mark_topology_update(nodes[i]);
+ }
+ }
+
+ MEM_SAFE_FREE(nodes);
+ SCULPT_undo_push_end();
+
+ /* Force rebuild of pbvh for better BB placement. */
+ SCULPT_pbvh_clear(ob);
+ /* Redraw. */
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void SCULPT_OT_detail_flood_fill(wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Detail Flood Fill";
+ ot->idname = "SCULPT_OT_detail_flood_fill";
+ ot->description = "Flood fill the mesh with the selected detail setting";
+
+ /* API callbacks. */
+ ot->exec = sculpt_detail_flood_fill_exec;
+ ot->poll = sculpt_and_constant_or_manual_detail_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+typedef enum eSculptSampleDetailModeTypes {
+ SAMPLE_DETAIL_DYNTOPO = 0,
+ SAMPLE_DETAIL_VOXEL = 1,
+} eSculptSampleDetailModeTypes;
+
+static EnumPropertyItem prop_sculpt_sample_detail_mode_types[] = {
+ {SAMPLE_DETAIL_DYNTOPO, "DYNTOPO", 0, "Dyntopo", "Sample dyntopo detail"},
+ {SAMPLE_DETAIL_VOXEL, "VOXEL", 0, "Voxel", "Sample mesh voxel size"},
+ {0, NULL, 0, NULL, NULL},
+};
+
+static void sample_detail_voxel(bContext *C, ViewContext *vc, int mx, int my)
+{
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ Object *ob = vc->obact;
+ Mesh *mesh = ob->data;
+
+ SculptSession *ss = ob->sculpt;
+ SculptCursorGeometryInfo sgi;
+ SCULPT_vertex_random_access_init(ss);
+
+ /* Update the active vertex. */
+ float mouse[2] = {mx, my};
+ SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false);
+
+ /* Average the edge length of the connected edges to the active vertex. */
+ int active_vertex = SCULPT_active_vertex_get(ss);
+ const float *active_vertex_co = SCULPT_active_vertex_co_get(ss);
+ float edge_length = 0.0f;
+ int tot = 0;
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, active_vertex, ni) {
+ edge_length += len_v3v3(active_vertex_co, SCULPT_vertex_co_get(ss, ni.index));
+ tot += 1;
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ if (tot > 0) {
+ mesh->remesh_voxel_size = edge_length / (float)tot;
+ }
+}
+
+static void sculpt_raycast_detail_cb(PBVHNode *node, void *data_v, float *tmin)
+{
+ if (BKE_pbvh_node_get_tmin(node) < *tmin) {
+ SculptDetailRaycastData *srd = data_v;
+ if (BKE_pbvh_bmesh_node_raycast_detail(
+ node, srd->ray_start, &srd->isect_precalc, &srd->depth, &srd->edge_length)) {
+ srd->hit = true;
+ *tmin = srd->depth;
+ }
+ }
+}
+
+static void sample_detail_dyntopo(bContext *C, ViewContext *vc, ARegion *region, int mx, int my)
+{
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Object *ob = vc->obact;
+ Brush *brush = BKE_paint_brush(&sd->paint);
+
+ SCULPT_stroke_modifiers_check(C, ob, brush);
+
+ float mouse[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
+ float ray_start[3], ray_end[3], ray_normal[3];
+ float depth = SCULPT_raycast_init(vc, mouse, ray_start, ray_end, ray_normal, false);
+
+ SculptDetailRaycastData srd;
+ srd.hit = 0;
+ srd.ray_start = ray_start;
+ srd.depth = depth;
+ srd.edge_length = 0.0f;
+ isect_ray_tri_watertight_v3_precalc(&srd.isect_precalc, ray_normal);
+
+ BKE_pbvh_raycast(ob->sculpt->pbvh, sculpt_raycast_detail_cb, &srd, ray_start, ray_normal, false);
+
+ if (srd.hit && srd.edge_length > 0.0f) {
+ /* Convert edge length to world space detail resolution. */
+ sd->constant_detail = 1 / (srd.edge_length * mat4_to_scale(ob->obmat));
+ }
+}
+
+static int sample_detail(bContext *C, int mx, int my, int mode)
+{
+ /* Find 3D view to pick from. */
+ bScreen *screen = CTX_wm_screen(C);
+ ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_VIEW3D, mx, my);
+ ARegion *region = (area) ? BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my) : NULL;
+ if (region == NULL) {
+ return OPERATOR_CANCELLED;
+ }
+
+ /* Set context to 3D view. */
+ ScrArea *prev_area = CTX_wm_area(C);
+ ARegion *prev_region = CTX_wm_region(C);
+ CTX_wm_area_set(C, area);
+ CTX_wm_region_set(C, region);
+
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+ ViewContext vc;
+ ED_view3d_viewcontext_init(C, &vc, depsgraph);
+
+ Object *ob = vc.obact;
+ SculptSession *ss = ob->sculpt;
+
+ if (!ss->pbvh) {
+ return OPERATOR_CANCELLED;
+ }
+
+ /* Pick sample detail. */
+ switch (mode) {
+ case SAMPLE_DETAIL_DYNTOPO:
+ if (BKE_pbvh_type(ss->pbvh) != PBVH_BMESH) {
+ CTX_wm_area_set(C, prev_area);
+ CTX_wm_region_set(C, prev_region);
+ return OPERATOR_CANCELLED;
+ }
+ sample_detail_dyntopo(C, &vc, region, mx, my);
+ break;
+ case SAMPLE_DETAIL_VOXEL:
+ if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) {
+ CTX_wm_area_set(C, prev_area);
+ CTX_wm_region_set(C, prev_region);
+ return OPERATOR_CANCELLED;
+ }
+ sample_detail_voxel(C, &vc, mx, my);
+ break;
+ }
+
+ /* Restore context. */
+ CTX_wm_area_set(C, prev_area);
+ CTX_wm_region_set(C, prev_region);
+
+ return OPERATOR_FINISHED;
+}
+
+static int sculpt_sample_detail_size_exec(bContext *C, wmOperator *op)
+{
+ int ss_co[2];
+ RNA_int_get_array(op->ptr, "location", ss_co);
+ int mode = RNA_enum_get(op->ptr, "mode");
+ return sample_detail(C, ss_co[0], ss_co[1], mode);
+}
+
+static int sculpt_sample_detail_size_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e))
+{
+ ED_workspace_status_text(C, TIP_("Click on the mesh to set the detail"));
+ WM_cursor_modal_set(CTX_wm_window(C), WM_CURSOR_EYEDROPPER);
+ WM_event_add_modal_handler(C, op);
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int sculpt_sample_detail_size_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ switch (event->type) {
+ case LEFTMOUSE:
+ if (event->val == KM_PRESS) {
+ int ss_co[2] = {event->x, event->y};
+
+ int mode = RNA_enum_get(op->ptr, "mode");
+ sample_detail(C, ss_co[0], ss_co[1], mode);
+
+ RNA_int_set_array(op->ptr, "location", ss_co);
+ WM_cursor_modal_restore(CTX_wm_window(C));
+ ED_workspace_status_text(C, NULL);
+ WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL);
+
+ return OPERATOR_FINISHED;
+ }
+ break;
+
+ case RIGHTMOUSE: {
+ WM_cursor_modal_restore(CTX_wm_window(C));
+ ED_workspace_status_text(C, NULL);
+
+ return OPERATOR_CANCELLED;
+ }
+ }
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void SCULPT_OT_sample_detail_size(wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Sample Detail Size";
+ ot->idname = "SCULPT_OT_sample_detail_size";
+ ot->description = "Sample the mesh detail on clicked point";
+
+ /* API callbacks. */
+ ot->invoke = sculpt_sample_detail_size_invoke;
+ ot->exec = sculpt_sample_detail_size_exec;
+ ot->modal = sculpt_sample_detail_size_modal;
+ ot->poll = SCULPT_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_int_array(ot->srna,
+ "location",
+ 2,
+ NULL,
+ 0,
+ SHRT_MAX,
+ "Location",
+ "Screen Coordinates of sampling",
+ 0,
+ SHRT_MAX);
+ RNA_def_enum(ot->srna,
+ "mode",
+ prop_sculpt_sample_detail_mode_types,
+ SAMPLE_DETAIL_DYNTOPO,
+ "Detail Mode",
+ "Target sculpting workflow that is going to use the sampled size");
+}
+
+/* Dynamic-topology detail size.
+ *
+ * This should be improved further, perhaps by showing a triangle
+ * grid rather than brush alpha. */
+static void set_brush_rc_props(PointerRNA *ptr, const char *prop)
+{
+ char *path = BLI_sprintfN("tool_settings.sculpt.brush.%s", prop);
+ RNA_string_set(ptr, "data_path_primary", path);
+ MEM_freeN(path);
+}
+
+static int sculpt_set_detail_size_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+
+ PointerRNA props_ptr;
+ wmOperatorType *ot = WM_operatortype_find("WM_OT_radial_control", true);
+
+ WM_operator_properties_create_ptr(&props_ptr, ot);
+
+ if (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)) {
+ set_brush_rc_props(&props_ptr, "constant_detail_resolution");
+ RNA_string_set(
+ &props_ptr, "data_path_primary", "tool_settings.sculpt.constant_detail_resolution");
+ }
+ else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) {
+ set_brush_rc_props(&props_ptr, "constant_detail_resolution");
+ RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.detail_percent");
+ }
+ else {
+ set_brush_rc_props(&props_ptr, "detail_size");
+ RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.detail_size");
+ }
+
+ WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr);
+
+ WM_operator_properties_free(&props_ptr);
+
+ return OPERATOR_FINISHED;
+}
+
+void SCULPT_OT_set_detail_size(wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Set Detail Size";
+ ot->idname = "SCULPT_OT_set_detail_size";
+ ot->description =
+ "Set the mesh detail (either relative or constant one, depending on current dyntopo mode)";
+
+ /* API callbacks. */
+ ot->exec = sculpt_set_detail_size_exec;
+ ot->poll = sculpt_and_dynamic_topology_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
new file mode 100644
index 00000000000..5f75c1d6813
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
@@ -0,0 +1,443 @@
+/*
+ * 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) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_hash.h"
+#include "BLI_math.h"
+#include "BLI_task.h"
+
+#include "BLT_translation.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_context.h"
+#include "BKE_main.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_modifier.h"
+#include "BKE_object.h"
+#include "BKE_paint.h"
+#include "BKE_pbvh.h"
+#include "BKE_particle.h"
+#include "BKE_pointcache.h"
+#include "BKE_scene.h"
+#include "BKE_screen.h"
+
+#include "DEG_depsgraph.h"
+
+#include "WM_api.h"
+#include "WM_message.h"
+#include "WM_toolsystem.h"
+#include "WM_types.h"
+
+#include "ED_object.h"
+#include "ED_screen.h"
+#include "ED_sculpt.h"
+#include "ED_view3d.h"
+#include "paint_intern.h"
+#include "sculpt_intern.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "bmesh.h"
+#include "bmesh_tools.h"
+
+#include <math.h>
+#include <stdlib.h>
+
+void SCULPT_dynamic_topology_triangulate(BMesh *bm)
+{
+ if (bm->totloop != bm->totface * 3) {
+ BM_mesh_triangulate(
+ bm, MOD_TRIANGULATE_QUAD_BEAUTY, MOD_TRIANGULATE_NGON_EARCLIP, 4, false, NULL, NULL, NULL);
+ }
+}
+
+void SCULPT_pbvh_clear(Object *ob)
+{
+ SculptSession *ss = ob->sculpt;
+
+ /* Clear out any existing DM and PBVH. */
+ if (ss->pbvh) {
+ BKE_pbvh_free(ss->pbvh);
+ ss->pbvh = NULL;
+ }
+
+ if (ss->pmap) {
+ MEM_freeN(ss->pmap);
+ ss->pmap = NULL;
+ }
+
+ if (ss->pmap_mem) {
+ MEM_freeN(ss->pmap_mem);
+ ss->pmap_mem = NULL;
+ }
+
+ BKE_object_free_derived_caches(ob);
+
+ /* Tag to rebuild PBVH in depsgraph. */
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+}
+
+void SCULPT_dyntopo_node_layers_add(SculptSession *ss)
+{
+ int cd_node_layer_index;
+
+ char layer_id[] = "_dyntopo_node_id";
+
+ cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->vdata, CD_PROP_INT, layer_id);
+ if (cd_node_layer_index == -1) {
+ BM_data_layer_add_named(ss->bm, &ss->bm->vdata, CD_PROP_INT, layer_id);
+ cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->vdata, CD_PROP_INT, layer_id);
+ }
+
+ ss->cd_vert_node_offset = CustomData_get_n_offset(
+ &ss->bm->vdata,
+ CD_PROP_INT,
+ cd_node_layer_index - CustomData_get_layer_index(&ss->bm->vdata, CD_PROP_INT));
+
+ ss->bm->vdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY;
+
+ cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->pdata, CD_PROP_INT, layer_id);
+ if (cd_node_layer_index == -1) {
+ BM_data_layer_add_named(ss->bm, &ss->bm->pdata, CD_PROP_INT, layer_id);
+ cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->pdata, CD_PROP_INT, layer_id);
+ }
+
+ ss->cd_face_node_offset = CustomData_get_n_offset(
+ &ss->bm->pdata,
+ CD_PROP_INT,
+ cd_node_layer_index - CustomData_get_layer_index(&ss->bm->pdata, CD_PROP_INT));
+
+ ss->bm->pdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY;
+}
+
+void SCULPT_dynamic_topology_enable_ex(Main *bmain,
+ Depsgraph *depsgraph,
+ Scene *scene,
+ Object *ob)
+{
+ SculptSession *ss = ob->sculpt;
+ Mesh *me = ob->data;
+ const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(me);
+
+ SCULPT_pbvh_clear(ob);
+
+ ss->bm_smooth_shading = (scene->toolsettings->sculpt->flags & SCULPT_DYNTOPO_SMOOTH_SHADING) !=
+ 0;
+
+ /* Dynamic topology doesn't ensure selection state is valid, so remove [#36280]. */
+ BKE_mesh_mselect_clear(me);
+
+ /* Create triangles-only BMesh. */
+ ss->bm = BM_mesh_create(&allocsize,
+ &((struct BMeshCreateParams){
+ .use_toolflags = false,
+ }));
+
+ BM_mesh_bm_from_me(ss->bm,
+ me,
+ (&(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ .use_shapekey = true,
+ .active_shapekey = ob->shapenr,
+ }));
+ SCULPT_dynamic_topology_triangulate(ss->bm);
+ BM_data_layer_add(ss->bm, &ss->bm->vdata, CD_PAINT_MASK);
+ SCULPT_dyntopo_node_layers_add(ss);
+ /* Make sure the data for existing faces are initialized. */
+ if (me->totpoly != ss->bm->totface) {
+ BM_mesh_normals_update(ss->bm);
+ }
+
+ /* Enable dynamic topology. */
+ me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY;
+
+ /* Enable logging for undo/redo. */
+ ss->bm_log = BM_log_create(ss->bm);
+
+ /* Update dependency graph, so modifiers that depend on dyntopo being enabled
+ * are re-evaluated and the PBVH is re-created. */
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ BKE_scene_graph_update_tagged(depsgraph, bmain);
+}
+
+/* Free the sculpt BMesh and BMLog
+ *
+ * If 'unode' is given, the BMesh's data is copied out to the unode
+ * before the BMesh is deleted so that it can be restored from. */
+static void SCULPT_dynamic_topology_disable_ex(
+ Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, SculptUndoNode *unode)
+{
+ SculptSession *ss = ob->sculpt;
+ Mesh *me = ob->data;
+
+ SCULPT_pbvh_clear(ob);
+
+ if (unode) {
+ /* Free all existing custom data. */
+ CustomData_free(&me->vdata, me->totvert);
+ CustomData_free(&me->edata, me->totedge);
+ CustomData_free(&me->fdata, me->totface);
+ CustomData_free(&me->ldata, me->totloop);
+ CustomData_free(&me->pdata, me->totpoly);
+
+ /* Copy over stored custom data. */
+ SculptUndoNodeGeometry *geometry = &unode->geometry_bmesh_enter;
+ me->totvert = geometry->totvert;
+ me->totloop = geometry->totloop;
+ me->totpoly = geometry->totpoly;
+ me->totedge = geometry->totedge;
+ me->totface = 0;
+ CustomData_copy(
+ &geometry->vdata, &me->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, geometry->totvert);
+ CustomData_copy(
+ &geometry->edata, &me->edata, CD_MASK_MESH.emask, CD_DUPLICATE, geometry->totedge);
+ CustomData_copy(
+ &geometry->ldata, &me->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, geometry->totloop);
+ CustomData_copy(
+ &geometry->pdata, &me->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, geometry->totpoly);
+
+ BKE_mesh_update_customdata_pointers(me, false);
+ }
+ else {
+ BKE_sculptsession_bm_to_me(ob, true);
+
+ /* Reset Face Sets as they are no longer valid. */
+ if (!CustomData_has_layer(&me->pdata, CD_SCULPT_FACE_SETS)) {
+ CustomData_add_layer(&me->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, me->totpoly);
+ }
+ ss->face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS);
+ for (int i = 0; i < me->totpoly; i++) {
+ ss->face_sets[i] = 1;
+ }
+ me->face_sets_color_default = 1;
+
+ /* Sync the visibility to vertices manually as the pmap is still not initialized. */
+ for (int i = 0; i < me->totvert; i++) {
+ me->mvert[i].flag &= ~ME_HIDE;
+ me->mvert[i].flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+
+ /* Clear data. */
+ me->flag &= ~ME_SCULPT_DYNAMIC_TOPOLOGY;
+
+ /* Typically valid but with global-undo they can be NULL. [#36234] */
+ if (ss->bm) {
+ BM_mesh_free(ss->bm);
+ ss->bm = NULL;
+ }
+ if (ss->bm_log) {
+ BM_log_free(ss->bm_log);
+ ss->bm_log = NULL;
+ }
+
+ BKE_particlesystem_reset_all(ob);
+ BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED);
+
+ /* Update dependency graph, so modifiers that depend on dyntopo being enabled
+ * are re-evaluated and the PBVH is re-created. */
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ BKE_scene_graph_update_tagged(depsgraph, bmain);
+}
+
+void SCULPT_dynamic_topology_disable(bContext *C, SculptUndoNode *unode)
+{
+ Main *bmain = CTX_data_main(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+ SCULPT_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, unode);
+}
+
+void sculpt_dynamic_topology_disable_with_undo(Main *bmain,
+ Depsgraph *depsgraph,
+ Scene *scene,
+ Object *ob)
+{
+ SculptSession *ss = ob->sculpt;
+ if (ss->bm) {
+ SCULPT_undo_push_begin("Dynamic topology disable");
+ SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END);
+ SCULPT_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, NULL);
+ SCULPT_undo_push_end();
+ }
+}
+
+static void sculpt_dynamic_topology_enable_with_undo(Main *bmain,
+ Depsgraph *depsgraph,
+ Scene *scene,
+ Object *ob)
+{
+ SculptSession *ss = ob->sculpt;
+ if (ss->bm == NULL) {
+ SCULPT_undo_push_begin("Dynamic topology enable");
+ SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob);
+ SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
+ SCULPT_undo_push_end();
+ }
+}
+
+static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Main *bmain = CTX_data_main(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+
+ WM_cursor_wait(true);
+
+ if (ss->bm) {
+ sculpt_dynamic_topology_disable_with_undo(bmain, depsgraph, scene, ob);
+ }
+ else {
+ sculpt_dynamic_topology_enable_with_undo(bmain, depsgraph, scene, ob);
+ }
+
+ WM_cursor_wait(false);
+ WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+
+static int dyntopo_warning_popup(bContext *C, wmOperatorType *ot, enum eDynTopoWarnFlag flag)
+{
+ uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Warning!"), ICON_ERROR);
+ uiLayout *layout = UI_popup_menu_layout(pup);
+
+ if (flag & (DYNTOPO_WARN_VDATA | DYNTOPO_WARN_EDATA | DYNTOPO_WARN_LDATA)) {
+ const char *msg_error = TIP_("Vertex Data Detected!");
+ const char *msg = TIP_("Dyntopo will not preserve vertex colors, UVs, or other customdata");
+ uiItemL(layout, msg_error, ICON_INFO);
+ uiItemL(layout, msg, ICON_NONE);
+ uiItemS(layout);
+ }
+
+ if (flag & DYNTOPO_WARN_MODIFIER) {
+ const char *msg_error = TIP_("Generative Modifiers Detected!");
+ const char *msg = TIP_(
+ "Keeping the modifiers will increase polycount when returning to object mode");
+
+ uiItemL(layout, msg_error, ICON_INFO);
+ uiItemL(layout, msg, ICON_NONE);
+ uiItemS(layout);
+ }
+
+ uiItemFullO_ptr(layout, ot, IFACE_("OK"), ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, NULL);
+
+ UI_popup_menu_end(C, pup);
+
+ return OPERATOR_INTERFACE;
+}
+
+enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene *scene, Object *ob)
+{
+ Mesh *me = ob->data;
+ SculptSession *ss = ob->sculpt;
+
+ enum eDynTopoWarnFlag flag = 0;
+
+ BLI_assert(ss->bm == NULL);
+ UNUSED_VARS_NDEBUG(ss);
+
+ for (int i = 0; i < CD_NUMTYPES; i++) {
+ if (!ELEM(i, CD_MVERT, CD_MEDGE, CD_MFACE, CD_MLOOP, CD_MPOLY, CD_PAINT_MASK, CD_ORIGINDEX)) {
+ if (CustomData_has_layer(&me->vdata, i)) {
+ flag |= DYNTOPO_WARN_VDATA;
+ }
+ if (CustomData_has_layer(&me->edata, i)) {
+ flag |= DYNTOPO_WARN_EDATA;
+ }
+ if (CustomData_has_layer(&me->ldata, i)) {
+ flag |= DYNTOPO_WARN_LDATA;
+ }
+ }
+ }
+
+ {
+ VirtualModifierData virtualModifierData;
+ ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
+
+ /* Exception for shape keys because we can edit those. */
+ for (; md; md = md->next) {
+ const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
+ continue;
+ }
+
+ if (mti->type == eModifierTypeType_Constructive) {
+ flag |= DYNTOPO_WARN_MODIFIER;
+ break;
+ }
+ }
+ }
+
+ return flag;
+}
+
+static int sculpt_dynamic_topology_toggle_invoke(bContext *C,
+ wmOperator *op,
+ const wmEvent *UNUSED(event))
+{
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+
+ if (!ss->bm) {
+ Scene *scene = CTX_data_scene(C);
+ enum eDynTopoWarnFlag flag = SCULPT_dynamic_topology_check(scene, ob);
+
+ if (flag) {
+ /* The mesh has customdata that will be lost, let the user confirm this is OK. */
+ return dyntopo_warning_popup(C, op->type, flag);
+ }
+ }
+
+ return sculpt_dynamic_topology_toggle_exec(C, op);
+}
+
+void SCULPT_OT_dynamic_topology_toggle(wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Dynamic Topology Toggle";
+ ot->idname = "SCULPT_OT_dynamic_topology_toggle";
+ ot->description = "Dynamic topology alters the mesh topology while sculpting";
+
+ /* API callbacks. */
+ ot->invoke = sculpt_dynamic_topology_toggle_invoke;
+ ot->exec = sculpt_dynamic_topology_toggle_exec;
+ ot->poll = SCULPT_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c
new file mode 100644
index 00000000000..1dd1fcf721d
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c
@@ -0,0 +1,974 @@
+/*
+ * 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) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_hash.h"
+#include "BLI_math.h"
+#include "BLI_task.h"
+
+#include "DNA_brush_types.h"
+#include "DNA_customdata_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_ccg.h"
+#include "BKE_colortools.h"
+#include "BKE_context.h"
+#include "BKE_customdata.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_multires.h"
+#include "BKE_node.h"
+#include "BKE_object.h"
+#include "BKE_paint.h"
+#include "BKE_pbvh.h"
+#include "BKE_scene.h"
+
+#include "DEG_depsgraph.h"
+
+#include "WM_api.h"
+#include "WM_message.h"
+#include "WM_toolsystem.h"
+#include "WM_types.h"
+
+#include "ED_object.h"
+#include "ED_screen.h"
+#include "ED_sculpt.h"
+#include "ED_view3d.h"
+#include "paint_intern.h"
+#include "sculpt_intern.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "bmesh.h"
+
+#include <math.h>
+#include <stdlib.h>
+
+/* Draw Face Sets Brush. */
+
+static void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
+ const int n,
+ const TaskParallelTLS *__restrict tls)
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ const Brush *brush = data->brush;
+ const float bstrength = ss->cache->bstrength;
+
+ PBVHVertexIter vd;
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
+ ss, &test, data->brush->falloff_shape);
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
+ MeshElemMap *vert_map = &ss->pmap[vd.index];
+ for (int j = 0; j < ss->pmap[vd.index].count; j++) {
+ const MPoly *p = &ss->mpoly[vert_map->indices[j]];
+
+ float poly_center[3];
+ BKE_mesh_calc_poly_center(p, &ss->mloop[p->loopstart], ss->mvert, poly_center);
+
+ if (sculpt_brush_test_sq_fn(&test, poly_center)) {
+ const float fade = bstrength * SCULPT_brush_strength_factor(ss,
+ brush,
+ vd.co,
+ sqrtf(test.dist),
+ vd.no,
+ vd.fno,
+ vd.mask ? *vd.mask : 0.0f,
+ vd.index,
+ tls->thread_id);
+
+ if (fade > 0.05f && ss->face_sets[vert_map->indices[j]] > 0) {
+ ss->face_sets[vert_map->indices[j]] = abs(ss->cache->paint_face_set);
+ }
+ }
+ }
+ }
+
+ else if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
+ {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ const float fade = bstrength * SCULPT_brush_strength_factor(ss,
+ brush,
+ vd.co,
+ sqrtf(test.dist),
+ vd.no,
+ vd.fno,
+ vd.mask ? *vd.mask : 0.0f,
+ vd.index,
+ tls->thread_id);
+
+ if (fade > 0.05f) {
+ SCULPT_vertex_face_set_set(ss, vd.index, ss->cache->paint_face_set);
+ }
+ }
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void do_relax_face_sets_brush_task_cb_ex(void *__restrict userdata,
+ const int n,
+ const TaskParallelTLS *__restrict tls)
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ const Brush *brush = data->brush;
+ float bstrength = ss->cache->bstrength;
+
+ PBVHVertexIter vd;
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
+ ss, &test, data->brush->falloff_shape);
+
+ const bool relax_face_sets = !(ss->cache->iteration_count % 3 == 0);
+ /* This operations needs a stregth tweak as the relax deformation is too weak by default. */
+ if (relax_face_sets) {
+ bstrength *= 2.0f;
+ }
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ if (relax_face_sets != SCULPT_vertex_has_unique_face_set(ss, vd.index)) {
+ const float fade = bstrength * SCULPT_brush_strength_factor(ss,
+ brush,
+ vd.co,
+ sqrtf(test.dist),
+ vd.no,
+ vd.fno,
+ vd.mask ? *vd.mask : 0.0f,
+ vd.index,
+ tls->thread_id);
+
+ SCULPT_relax_vertex(ss, &vd, fade * bstrength, relax_face_sets, vd.co);
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
+{
+ SculptSession *ss = ob->sculpt;
+ Brush *brush = BKE_paint_brush(&sd->paint);
+
+ if (ss->cache->first_time && ss->cache->mirror_symmetry_pass == 0 &&
+ ss->cache->radial_symmetry_pass == 0) {
+ if (ss->cache->invert) {
+ /* When inverting the brush, pick the paint face mask ID from the mesh. */
+ ss->cache->paint_face_set = SCULPT_active_face_set_get(ss);
+ }
+ else {
+ /* By default create a new Face Sets. */
+ ss->cache->paint_face_set = SCULPT_face_set_next_available_get(ss);
+ }
+ }
+
+ BKE_curvemapping_initialize(brush->curve);
+
+ /* Threaded loop over nodes. */
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .brush = brush,
+ .nodes = nodes,
+ };
+
+ PBVHParallelSettings settings;
+ BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ if (ss->cache->alt_smooth) {
+ for (int i = 0; i < 4; i++) {
+ BKE_pbvh_parallel_range(0, totnode, &data, do_relax_face_sets_brush_task_cb_ex, &settings);
+ }
+ }
+ else {
+ BKE_pbvh_parallel_range(0, totnode, &data, do_draw_face_sets_brush_task_cb_ex, &settings);
+ }
+}
+
+/* Face Sets Operators */
+
+typedef enum eSculptFaceGroupsCreateModes {
+ SCULPT_FACE_SET_MASKED = 0,
+ SCULPT_FACE_SET_VISIBLE = 1,
+ SCULPT_FACE_SET_ALL = 2,
+ SCULPT_FACE_SET_SELECTION = 3,
+} eSculptFaceGroupsCreateModes;
+
+static EnumPropertyItem prop_sculpt_face_set_create_types[] = {
+ {
+ SCULPT_FACE_SET_MASKED,
+ "MASKED",
+ 0,
+ "Face Set From Masked",
+ "Create a new Face Set from the masked faces",
+ },
+ {
+ SCULPT_FACE_SET_VISIBLE,
+ "VISIBLE",
+ 0,
+ "Face Set From Visible",
+ "Create a new Face Set from the visible vertices",
+ },
+ {
+ SCULPT_FACE_SET_ALL,
+ "ALL",
+ 0,
+ "Face Set Full Mesh",
+ "Create an unique Face Set with all faces in the sculpt",
+ },
+ {
+ SCULPT_FACE_SET_SELECTION,
+ "SELECTION",
+ 0,
+ "Face Set From Edit Mode Selection",
+ "Create an Face Set corresponding to the Edit Mode face selection",
+ },
+ {0, NULL, 0, NULL, NULL},
+};
+
+static int sculpt_face_set_create_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ ARegion *region = CTX_wm_region(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+
+ const int mode = RNA_enum_get(op->ptr, "mode");
+
+ /* Dyntopo not suported. */
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) {
+ return OPERATOR_CANCELLED;
+ }
+
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, mode == SCULPT_FACE_SET_MASKED);
+
+ const int tot_vert = SCULPT_vertex_count_get(ss);
+ float threshold = 0.5f;
+
+ PBVH *pbvh = ob->sculpt->pbvh;
+ PBVHNode **nodes;
+ int totnode;
+ BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
+
+ if (!nodes) {
+ return OPERATOR_CANCELLED;
+ }
+
+ SCULPT_undo_push_begin("face set change");
+ SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
+
+ const int next_face_set = SCULPT_face_set_next_available_get(ss);
+
+ if (mode == SCULPT_FACE_SET_MASKED) {
+ for (int i = 0; i < tot_vert; i++) {
+ if (SCULPT_vertex_mask_get(ss, i) >= threshold && SCULPT_vertex_visible_get(ss, i)) {
+ SCULPT_vertex_face_set_set(ss, i, next_face_set);
+ }
+ }
+ }
+
+ if (mode == SCULPT_FACE_SET_VISIBLE) {
+ for (int i = 0; i < tot_vert; i++) {
+ if (SCULPT_vertex_visible_get(ss, i)) {
+ SCULPT_vertex_face_set_set(ss, i, next_face_set);
+ }
+ }
+ }
+
+ if (mode == SCULPT_FACE_SET_ALL) {
+ for (int i = 0; i < tot_vert; i++) {
+ SCULPT_vertex_face_set_set(ss, i, next_face_set);
+ }
+ }
+
+ if (mode == SCULPT_FACE_SET_SELECTION) {
+ Mesh *mesh = ob->data;
+ BMesh *bm;
+ const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh);
+ bm = BM_mesh_create(&allocsize,
+ &((struct BMeshCreateParams){
+ .use_toolflags = true,
+ }));
+
+ BM_mesh_bm_from_me(bm,
+ mesh,
+ (&(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ }));
+
+ BMIter iter;
+ BMFace *f;
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
+ ss->face_sets[BM_elem_index_get(f)] = next_face_set;
+ }
+ }
+ BM_mesh_free(bm);
+ }
+
+ for (int i = 0; i < totnode; i++) {
+ BKE_pbvh_node_mark_redraw(nodes[i]);
+ }
+
+ MEM_SAFE_FREE(nodes);
+
+ SCULPT_undo_push_end();
+
+ ED_region_tag_redraw(region);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void SCULPT_OT_face_sets_create(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Create Face Set";
+ ot->idname = "SCULPT_OT_face_sets_create";
+ ot->description = "Create a new Face Set";
+
+ /* api callbacks */
+ ot->invoke = sculpt_face_set_create_invoke;
+ ot->poll = SCULPT_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_enum(
+ ot->srna, "mode", prop_sculpt_face_set_create_types, SCULPT_FACE_SET_MASKED, "Mode", "");
+}
+
+typedef enum eSculptFaceSetsInitMode {
+ SCULPT_FACE_SETS_FROM_LOOSE_PARTS = 0,
+ SCULPT_FACE_SETS_FROM_MATERIALS = 1,
+ SCULPT_FACE_SETS_FROM_NORMALS = 2,
+ SCULPT_FACE_SETS_FROM_UV_SEAMS = 3,
+ SCULPT_FACE_SETS_FROM_CREASES = 4,
+ SCULPT_FACE_SETS_FROM_SHARP_EDGES = 5,
+ SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT = 6,
+ SCULPT_FACE_SETS_FROM_FACE_MAPS = 7,
+} eSculptFaceSetsInitMode;
+
+static EnumPropertyItem prop_sculpt_face_sets_init_types[] = {
+ {
+ SCULPT_FACE_SETS_FROM_LOOSE_PARTS,
+ "LOOSE_PARTS",
+ 0,
+ "Face Sets From Loose Parts",
+ "Create a Face Set per loose part in the mesh",
+ },
+ {
+ SCULPT_FACE_SETS_FROM_MATERIALS,
+ "MATERIALS",
+ 0,
+ "Face Sets From Material Slots",
+ "Create a Face Set per Material Slot",
+ },
+ {
+ SCULPT_FACE_SETS_FROM_NORMALS,
+ "NORMALS",
+ 0,
+ "Face Sets From Mesh Normals",
+ "Create Face Sets for Faces that have similar normal",
+ },
+ {
+ SCULPT_FACE_SETS_FROM_UV_SEAMS,
+ "UV_SEAMS",
+ 0,
+ "Face Sets From UV Seams",
+ "Create Face Sets using UV Seams as boundaries",
+ },
+ {
+ SCULPT_FACE_SETS_FROM_CREASES,
+ "CREASES",
+ 0,
+ "Face Sets From Edge Creases",
+ "Create Face Sets using Edge Creases as boundaries",
+ },
+ {
+ SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT,
+ "BEVEL_WEIGHT",
+ 0,
+ "Face Sets From Bevel Weight",
+ "Create Face Sets using Bevel Weights as boundaries",
+ },
+ {
+ SCULPT_FACE_SETS_FROM_SHARP_EDGES,
+ "SHARP_EDGES",
+ 0,
+ "Face Sets From Sharp Edges",
+ "Create Face Sets using Sharp Edges as boundaries",
+ },
+ {
+ SCULPT_FACE_SETS_FROM_FACE_MAPS,
+ "FACE_MAPS",
+ 0,
+ "Face Sets From Face Maps",
+ "Create a Face Set per Face Map",
+ },
+ {0, NULL, 0, NULL, NULL},
+};
+
+typedef bool (*face_sets_flood_fill_test)(
+ BMesh *bm, BMFace *from_f, BMEdge *from_e, BMFace *to_f, const float threshold);
+
+static bool sculpt_face_sets_init_loose_parts_test(BMesh *UNUSED(bm),
+ BMFace *UNUSED(from_f),
+ BMEdge *UNUSED(from_e),
+ BMFace *UNUSED(to_f),
+ const float UNUSED(threshold))
+{
+ return true;
+}
+
+static bool sculpt_face_sets_init_normals_test(
+ BMesh *UNUSED(bm), BMFace *from_f, BMEdge *UNUSED(from_e), BMFace *to_f, const float threshold)
+{
+ return fabsf(dot_v3v3(from_f->no, to_f->no)) > threshold;
+}
+
+static bool sculpt_face_sets_init_uv_seams_test(BMesh *UNUSED(bm),
+ BMFace *UNUSED(from_f),
+ BMEdge *from_e,
+ BMFace *UNUSED(to_f),
+ const float UNUSED(threshold))
+{
+ return !BM_elem_flag_test(from_e, BM_ELEM_SEAM);
+}
+
+static bool sculpt_face_sets_init_crease_test(
+ BMesh *bm, BMFace *UNUSED(from_f), BMEdge *from_e, BMFace *UNUSED(to_f), const float threshold)
+{
+ return BM_elem_float_data_get(&bm->edata, from_e, CD_CREASE) < threshold;
+}
+
+static bool sculpt_face_sets_init_bevel_weight_test(
+ BMesh *bm, BMFace *UNUSED(from_f), BMEdge *from_e, BMFace *UNUSED(to_f), const float threshold)
+{
+ return BM_elem_float_data_get(&bm->edata, from_e, CD_BWEIGHT) < threshold;
+}
+
+static bool sculpt_face_sets_init_sharp_edges_test(BMesh *UNUSED(bm),
+ BMFace *UNUSED(from_f),
+ BMEdge *from_e,
+ BMFace *UNUSED(to_f),
+ const float UNUSED(threshold))
+{
+ return BM_elem_flag_test(from_e, BM_ELEM_SMOOTH);
+}
+
+static void sculpt_face_sets_init_flood_fill(Object *ob,
+ face_sets_flood_fill_test test,
+ const float threshold)
+{
+ SculptSession *ss = ob->sculpt;
+ Mesh *mesh = ob->data;
+ BMesh *bm;
+ const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh);
+ bm = BM_mesh_create(&allocsize,
+ &((struct BMeshCreateParams){
+ .use_toolflags = true,
+ }));
+
+ BM_mesh_bm_from_me(bm,
+ mesh,
+ (&(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ }));
+
+ bool *visited_faces = MEM_callocN(sizeof(bool) * mesh->totpoly, "visited faces");
+ const int totfaces = mesh->totpoly;
+
+ int *face_sets = ss->face_sets;
+
+ BM_mesh_elem_table_init(bm, BM_FACE);
+ BM_mesh_elem_table_ensure(bm, BM_FACE);
+
+ int next_face_set = 1;
+
+ for (int i = 0; i < totfaces; i++) {
+ if (!visited_faces[i]) {
+ GSQueue *queue;
+ queue = BLI_gsqueue_new(sizeof(int));
+
+ face_sets[i] = next_face_set;
+ visited_faces[i] = true;
+ BLI_gsqueue_push(queue, &i);
+
+ while (!BLI_gsqueue_is_empty(queue)) {
+ int from_f;
+ BLI_gsqueue_pop(queue, &from_f);
+
+ BMFace *f, *f_neighbor;
+ BMEdge *ed;
+ BMIter iter_a, iter_b;
+
+ f = BM_face_at_index(bm, from_f);
+
+ BM_ITER_ELEM (ed, &iter_a, f, BM_EDGES_OF_FACE) {
+ BM_ITER_ELEM (f_neighbor, &iter_b, ed, BM_FACES_OF_EDGE) {
+ if (f_neighbor != f) {
+ int neighbor_face_index = BM_elem_index_get(f_neighbor);
+ if (!visited_faces[neighbor_face_index]) {
+ if (test(bm, f, ed, f_neighbor, threshold)) {
+ face_sets[neighbor_face_index] = next_face_set;
+ visited_faces[neighbor_face_index] = true;
+ BLI_gsqueue_push(queue, &neighbor_face_index);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ next_face_set += 1;
+
+ BLI_gsqueue_free(queue);
+ }
+ }
+
+ MEM_SAFE_FREE(visited_faces);
+
+ BM_mesh_free(bm);
+}
+
+static void sculpt_face_sets_init_loop(Object *ob, const int mode)
+{
+ Mesh *mesh = ob->data;
+ SculptSession *ss = ob->sculpt;
+ BMesh *bm;
+ const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh);
+ bm = BM_mesh_create(&allocsize,
+ &((struct BMeshCreateParams){
+ .use_toolflags = true,
+ }));
+
+ BM_mesh_bm_from_me(bm,
+ mesh,
+ (&(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ }));
+ BMIter iter;
+ BMFace *f;
+
+ const int cd_fmaps_offset = CustomData_get_offset(&bm->pdata, CD_FACEMAP);
+
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ if (mode == SCULPT_FACE_SETS_FROM_MATERIALS) {
+ ss->face_sets[BM_elem_index_get(f)] = (int)(f->mat_nr + 1);
+ }
+ else if (mode == SCULPT_FACE_SETS_FROM_FACE_MAPS) {
+ if (cd_fmaps_offset != -1) {
+ ss->face_sets[BM_elem_index_get(f)] = BM_ELEM_CD_GET_INT(f, cd_fmaps_offset) + 2;
+ }
+ else {
+ ss->face_sets[BM_elem_index_get(f)] = 1;
+ }
+ }
+ }
+ BM_mesh_free(bm);
+}
+
+static int sculpt_face_set_init_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ ARegion *region = CTX_wm_region(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+
+ const int mode = RNA_enum_get(op->ptr, "mode");
+
+ /* Dyntopo not supported. */
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) {
+ return OPERATOR_CANCELLED;
+ }
+
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false);
+
+ PBVH *pbvh = ob->sculpt->pbvh;
+ PBVHNode **nodes;
+ int totnode;
+ BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
+
+ if (!nodes) {
+ return OPERATOR_CANCELLED;
+ }
+
+ SCULPT_undo_push_begin("face set change");
+ SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
+
+ const float threshold = RNA_float_get(op->ptr, "threshold");
+
+ switch (mode) {
+ case SCULPT_FACE_SETS_FROM_LOOSE_PARTS:
+ sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_loose_parts_test, threshold);
+ break;
+ case SCULPT_FACE_SETS_FROM_MATERIALS:
+ sculpt_face_sets_init_loop(ob, SCULPT_FACE_SETS_FROM_MATERIALS);
+ break;
+ case SCULPT_FACE_SETS_FROM_NORMALS:
+ sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_normals_test, threshold);
+ break;
+ case SCULPT_FACE_SETS_FROM_UV_SEAMS:
+ sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_uv_seams_test, threshold);
+ break;
+ case SCULPT_FACE_SETS_FROM_CREASES:
+ sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_crease_test, threshold);
+ break;
+ case SCULPT_FACE_SETS_FROM_SHARP_EDGES:
+ sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_sharp_edges_test, threshold);
+ break;
+ case SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT:
+ sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_bevel_weight_test, threshold);
+ break;
+ case SCULPT_FACE_SETS_FROM_FACE_MAPS:
+ sculpt_face_sets_init_loop(ob, SCULPT_FACE_SETS_FROM_FACE_MAPS);
+ break;
+ }
+
+ SCULPT_undo_push_end();
+
+ /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */
+ SCULPT_visibility_sync_all_face_sets_to_vertices(ss);
+
+ for (int i = 0; i < totnode; i++) {
+ BKE_pbvh_node_mark_update_visibility(nodes[i]);
+ }
+
+ BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility);
+
+ MEM_SAFE_FREE(nodes);
+
+ if (BKE_pbvh_type(pbvh) == PBVH_FACES) {
+ BKE_mesh_flush_hidden_from_verts(ob->data);
+ }
+
+ ED_region_tag_redraw(region);
+ DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
+
+ View3D *v3d = CTX_wm_view3d(C);
+ if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) {
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void SCULPT_OT_face_sets_init(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Init Face Sets";
+ ot->idname = "SCULPT_OT_face_sets_init";
+ ot->description = "Initializes all Face Sets in the mesh";
+
+ /* api callbacks */
+ ot->invoke = sculpt_face_set_init_invoke;
+ ot->poll = SCULPT_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_enum(
+ ot->srna, "mode", prop_sculpt_face_sets_init_types, SCULPT_FACE_SET_MASKED, "Mode", "");
+ RNA_def_float(
+ ot->srna,
+ "threshold",
+ 0.5f,
+ 0.0f,
+ 1.0f,
+ "Threshold",
+ "Minimum value to consider a certain atribute a boundary when creating the Face Sets",
+ 0.0f,
+ 1.0f);
+}
+
+typedef enum eSculptFaceGroupVisibilityModes {
+ SCULPT_FACE_SET_VISIBILITY_TOGGLE = 0,
+ SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE = 1,
+ SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE = 2,
+ SCULPT_FACE_SET_VISIBILITY_INVERT = 3,
+ SCULPT_FACE_SET_VISIBILITY_SHOW_ALL = 4,
+} eSculptFaceGroupVisibilityModes;
+
+static EnumPropertyItem prop_sculpt_face_sets_change_visibility_types[] = {
+ {
+ SCULPT_FACE_SET_VISIBILITY_TOGGLE,
+ "TOGGLE",
+ 0,
+ "Toggle Visibility",
+ "Hide all Face Sets except for the active one",
+ },
+ {
+ SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE,
+ "SHOW_ACTIVE",
+ 0,
+ "Show Active Face Set",
+ "Show Active Face Set",
+ },
+ {
+ SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE,
+ "HIDE_ACTIVE",
+ 0,
+ "Hide Active Face Sets",
+ "Hide Active Face Sets",
+ },
+ {
+ SCULPT_FACE_SET_VISIBILITY_INVERT,
+ "INVERT",
+ 0,
+ "Invert Face Set Visibility",
+ "Invert Face Set Visibility",
+ },
+ {
+ SCULPT_FACE_SET_VISIBILITY_SHOW_ALL,
+ "SHOW_ALL",
+ 0,
+ "Show All Face Sets",
+ "Show All Face Sets",
+ },
+ {0, NULL, 0, NULL, NULL},
+};
+
+static int sculpt_face_sets_change_visibility_invoke(bContext *C,
+ wmOperator *op,
+ const wmEvent *UNUSED(event))
+{
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ ARegion *region = CTX_wm_region(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+
+ /* Dyntopo not supported. */
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) {
+ return OPERATOR_CANCELLED;
+ }
+
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true);
+
+ const int tot_vert = SCULPT_vertex_count_get(ss);
+ const int mode = RNA_enum_get(op->ptr, "mode");
+ const int active_face_set = SCULPT_active_face_set_get(ss);
+
+ SCULPT_undo_push_begin("Hide area");
+
+ PBVH *pbvh = ob->sculpt->pbvh;
+ PBVHNode **nodes;
+ int totnode;
+
+ BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
+
+ if (totnode == 0) {
+ MEM_SAFE_FREE(nodes);
+ return OPERATOR_CANCELLED;
+ }
+
+ SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
+
+ if (mode == SCULPT_FACE_SET_VISIBILITY_TOGGLE) {
+ bool hidden_vertex = false;
+
+ /* This can fail with regular meshes with non-manifold geometry as the visibility state can't
+ * be synced from face sets to non-manifold vertices. */
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
+ for (int i = 0; i < tot_vert; i++) {
+ if (!SCULPT_vertex_visible_get(ss, i)) {
+ hidden_vertex = true;
+ break;
+ }
+ }
+ }
+
+ for (int i = 0; i < ss->totfaces; i++) {
+ if (ss->face_sets[i] <= 0) {
+ hidden_vertex = true;
+ break;
+ }
+ }
+
+ if (hidden_vertex) {
+ SCULPT_face_sets_visibility_all_set(ss, true);
+ }
+ else {
+ SCULPT_face_sets_visibility_all_set(ss, false);
+ SCULPT_face_set_visibility_set(ss, active_face_set, true);
+ }
+ }
+
+ if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ALL) {
+ SCULPT_face_sets_visibility_all_set(ss, true);
+ }
+
+ if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE) {
+ SCULPT_face_sets_visibility_all_set(ss, false);
+ SCULPT_face_set_visibility_set(ss, active_face_set, true);
+ for (int i = 0; i < tot_vert; i++) {
+ SCULPT_vertex_visible_set(ss,
+ i,
+ SCULPT_vertex_visible_get(ss, i) &&
+ SCULPT_vertex_has_face_set(ss, i, active_face_set));
+ }
+ }
+
+ if (mode == SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE) {
+ SCULPT_face_set_visibility_set(ss, active_face_set, false);
+ }
+
+ if (mode == SCULPT_FACE_SET_VISIBILITY_INVERT) {
+ SCULPT_face_sets_visibility_invert(ss);
+ }
+
+ /* For modes that use the cursor active vertex, update the rotation origin for viewport
+ * navigation. */
+ if (ELEM(mode, SCULPT_FACE_SET_VISIBILITY_TOGGLE, SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE)) {
+ UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
+ float location[3];
+ copy_v3_v3(location, SCULPT_active_vertex_co_get(ss));
+ mul_m4_v3(ob->obmat, location);
+ copy_v3_v3(ups->average_stroke_accum, location);
+ ups->average_stroke_counter = 1;
+ ups->last_stroke_valid = true;
+ }
+
+ /* Sync face sets visibility and vertex visibility. */
+ SCULPT_visibility_sync_all_face_sets_to_vertices(ss);
+
+ SCULPT_undo_push_end();
+
+ for (int i = 0; i < totnode; i++) {
+ BKE_pbvh_node_mark_update_visibility(nodes[i]);
+ }
+
+ BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility);
+
+ MEM_SAFE_FREE(nodes);
+
+ if (BKE_pbvh_type(pbvh) == PBVH_FACES) {
+ BKE_mesh_flush_hidden_from_verts(ob->data);
+ }
+
+ ED_region_tag_redraw(region);
+ DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
+
+ View3D *v3d = CTX_wm_view3d(C);
+ if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) {
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ }
+ return OPERATOR_FINISHED;
+}
+
+void SCULPT_OT_face_sets_change_visibility(wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Face Sets Visibility";
+ ot->idname = "SCULPT_OT_face_set_change_visibility";
+ ot->description = "Change the visibility of the Face Sets of the sculpt";
+
+ /* Api callbacks. */
+ ot->invoke = sculpt_face_sets_change_visibility_invoke;
+ ot->poll = SCULPT_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_enum(ot->srna,
+ "mode",
+ prop_sculpt_face_sets_change_visibility_types,
+ SCULPT_FACE_SET_VISIBILITY_TOGGLE,
+ "Mode",
+ "");
+}
+
+static int sculpt_face_sets_randomize_colors_invoke(bContext *C,
+ wmOperator *UNUSED(op),
+ const wmEvent *UNUSED(event))
+{
+
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ ARegion *region = CTX_wm_region(C);
+
+ /* Dyntopo and Multires not supported for now. */
+ if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) {
+ return OPERATOR_CANCELLED;
+ }
+
+ PBVH *pbvh = ob->sculpt->pbvh;
+ PBVHNode **nodes;
+ int totnode;
+ Mesh *mesh = ob->data;
+
+ mesh->face_sets_color_seed += 1;
+ if (ss->face_sets) {
+ const int random_index = clamp_i(ss->totfaces * BLI_hash_int_01(mesh->face_sets_color_seed),
+ 0,
+ max_ii(0, ss->totfaces - 1));
+ mesh->face_sets_color_default = ss->face_sets[random_index];
+ }
+ BKE_pbvh_face_sets_color_set(pbvh, mesh->face_sets_color_seed, mesh->face_sets_color_default);
+
+ BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
+ for (int i = 0; i < totnode; i++) {
+ BKE_pbvh_node_mark_redraw(nodes[i]);
+ }
+
+ MEM_SAFE_FREE(nodes);
+
+ View3D *v3d = CTX_wm_view3d(C);
+ if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) {
+ DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
+ }
+
+ ED_region_tag_redraw(region);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
+
+ return OPERATOR_FINISHED;
+}
+
+void SCULPT_OT_face_sets_randomize_colors(wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Randomize Face Sets Colors";
+ ot->idname = "SCULPT_OT_face_sets_randomize_colors";
+ ot->description = "Generates a new set of random colors to render the Face Sets in the viewport";
+
+ /* Api callbacks. */
+ ot->invoke = sculpt_face_sets_randomize_colors_invoke;
+ ot->poll = SCULPT_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
new file mode 100644
index 00000000000..38bbd083994
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
@@ -0,0 +1,502 @@
+/*
+ * 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) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_hash.h"
+#include "BLI_math.h"
+#include "BLI_task.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_context.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_object.h"
+#include "BKE_paint.h"
+#include "BKE_pbvh.h"
+#include "BKE_scene.h"
+
+#include "DEG_depsgraph.h"
+
+#include "WM_api.h"
+#include "WM_message.h"
+#include "WM_toolsystem.h"
+#include "WM_types.h"
+
+#include "ED_object.h"
+#include "ED_screen.h"
+#include "ED_sculpt.h"
+#include "paint_intern.h"
+#include "sculpt_intern.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "UI_interface.h"
+
+#include "bmesh.h"
+
+#include <math.h>
+#include <stdlib.h>
+
+typedef enum eSculptMaskFilterTypes {
+ MASK_FILTER_SMOOTH = 0,
+ MASK_FILTER_SHARPEN = 1,
+ MASK_FILTER_GROW = 2,
+ MASK_FILTER_SHRINK = 3,
+ MASK_FILTER_CONTRAST_INCREASE = 5,
+ MASK_FILTER_CONTRAST_DECREASE = 6,
+} eSculptMaskFilterTypes;
+
+static EnumPropertyItem prop_mask_filter_types[] = {
+ {MASK_FILTER_SMOOTH, "SMOOTH", 0, "Smooth Mask", "Smooth mask"},
+ {MASK_FILTER_SHARPEN, "SHARPEN", 0, "Sharpen Mask", "Sharpen mask"},
+ {MASK_FILTER_GROW, "GROW", 0, "Grow Mask", "Grow mask"},
+ {MASK_FILTER_SHRINK, "SHRINK", 0, "Shrink Mask", "Shrink mask"},
+ {MASK_FILTER_CONTRAST_INCREASE,
+ "CONTRAST_INCREASE",
+ 0,
+ "Increase contrast",
+ "Increase the contrast of the paint mask"},
+ {MASK_FILTER_CONTRAST_DECREASE,
+ "CONTRAST_DECREASE",
+ 0,
+ "Decrease contrast",
+ "Decrease the contrast of the paint mask"},
+ {0, NULL, 0, NULL, NULL},
+};
+
+static void mask_filter_task_cb(void *__restrict userdata,
+ const int i,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ PBVHNode *node = data->nodes[i];
+ bool update = false;
+
+ const int mode = data->filter_type;
+ float contrast = 0.0f;
+
+ PBVHVertexIter vd;
+
+ if (mode == MASK_FILTER_CONTRAST_INCREASE) {
+ contrast = 0.1f;
+ }
+
+ if (mode == MASK_FILTER_CONTRAST_DECREASE) {
+ contrast = -0.1f;
+ }
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
+ {
+ float delta, gain, offset, max, min;
+ float prev_val = *vd.mask;
+ SculptVertexNeighborIter ni;
+ switch (mode) {
+ case MASK_FILTER_SMOOTH:
+ case MASK_FILTER_SHARPEN: {
+ float val = SCULPT_neighbor_mask_average(ss, vd.index);
+
+ val -= *vd.mask;
+
+ if (mode == MASK_FILTER_SMOOTH) {
+ *vd.mask += val;
+ }
+ else if (mode == MASK_FILTER_SHARPEN) {
+ if (*vd.mask > 0.5f) {
+ *vd.mask += 0.05f;
+ }
+ else {
+ *vd.mask -= 0.05f;
+ }
+ *vd.mask += val / 2.0f;
+ }
+ break;
+ }
+ case MASK_FILTER_GROW:
+ max = 0.0f;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd.index, ni) {
+ float vmask_f = data->prev_mask[ni.index];
+ if (vmask_f > max) {
+ max = vmask_f;
+ }
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ *vd.mask = max;
+ break;
+ case MASK_FILTER_SHRINK:
+ min = 1.0f;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd.index, ni) {
+ float vmask_f = data->prev_mask[ni.index];
+ if (vmask_f < min) {
+ min = vmask_f;
+ }
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ *vd.mask = min;
+ break;
+ case MASK_FILTER_CONTRAST_INCREASE:
+ case MASK_FILTER_CONTRAST_DECREASE:
+ delta = contrast / 2.0f;
+ gain = 1.0f - delta * 2.0f;
+ if (contrast > 0) {
+ gain = 1.0f / ((gain != 0.0f) ? gain : FLT_EPSILON);
+ offset = gain * (-delta);
+ }
+ else {
+ delta *= -1.0f;
+ offset = gain * (delta);
+ }
+ *vd.mask = gain * (*vd.mask) + offset;
+ break;
+ }
+ CLAMP(*vd.mask, 0.0f, 1.0f);
+ if (*vd.mask != prev_val) {
+ update = true;
+ }
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+
+ if (update) {
+ BKE_pbvh_node_mark_update_mask(node);
+ }
+}
+
+static int sculpt_mask_filter_exec(bContext *C, wmOperator *op)
+{
+ ARegion *region = CTX_wm_region(C);
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ PBVH *pbvh = ob->sculpt->pbvh;
+ PBVHNode **nodes;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ int totnode;
+ int filter_type = RNA_enum_get(op->ptr, "filter_type");
+
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true);
+
+ SCULPT_vertex_random_access_init(ss);
+
+ if (!ob->sculpt->pmap) {
+ return OPERATOR_CANCELLED;
+ }
+
+ int num_verts = SCULPT_vertex_count_get(ss);
+
+ BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
+ SCULPT_undo_push_begin("Mask filter");
+
+ for (int i = 0; i < totnode; i++) {
+ SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK);
+ }
+
+ float *prev_mask = NULL;
+ int iterations = RNA_int_get(op->ptr, "iterations");
+
+ /* Auto iteration count calculates the number of iteration based on the vertices of the mesh to
+ * avoid adding an unnecessary amount of undo steps when using the operator from a shortcut.
+ * One iteration per 50000 vertices in the mesh should be fine in most cases.
+ * Maybe we want this to be configurable. */
+ if (RNA_boolean_get(op->ptr, "auto_iteration_count")) {
+ iterations = (int)(num_verts / 50000.0f) + 1;
+ }
+
+ for (int i = 0; i < iterations; i++) {
+ if (ELEM(filter_type, MASK_FILTER_GROW, MASK_FILTER_SHRINK)) {
+ prev_mask = MEM_mallocN(num_verts * sizeof(float), "prevmask");
+ for (int j = 0; j < num_verts; j++) {
+ prev_mask[j] = SCULPT_vertex_mask_get(ss, j);
+ }
+ }
+
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .nodes = nodes,
+ .filter_type = filter_type,
+ .prev_mask = prev_mask,
+ };
+
+ PBVHParallelSettings settings;
+ BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_parallel_range(0, totnode, &data, mask_filter_task_cb, &settings);
+
+ if (ELEM(filter_type, MASK_FILTER_GROW, MASK_FILTER_SHRINK)) {
+ MEM_freeN(prev_mask);
+ }
+ }
+
+ MEM_SAFE_FREE(nodes);
+
+ SCULPT_undo_push_end();
+
+ ED_region_tag_redraw(region);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+ return OPERATOR_FINISHED;
+}
+
+void SCULPT_mask_filter_smooth_apply(
+ Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, const int smooth_iterations)
+{
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .nodes = nodes,
+ .filter_type = MASK_FILTER_SMOOTH,
+ };
+
+ for (int i = 0; i < smooth_iterations; i++) {
+ PBVHParallelSettings settings;
+ BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_parallel_range(0, totnode, &data, mask_filter_task_cb, &settings);
+ }
+}
+
+void SCULPT_OT_mask_filter(struct wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Mask Filter";
+ ot->idname = "SCULPT_OT_mask_filter";
+ ot->description = "Applies a filter to modify the current mask";
+
+ /* API callbacks. */
+ ot->exec = sculpt_mask_filter_exec;
+ ot->poll = SCULPT_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER;
+
+ /* RNA. */
+ RNA_def_enum(ot->srna,
+ "filter_type",
+ prop_mask_filter_types,
+ MASK_FILTER_SMOOTH,
+ "Type",
+ "Filter that is going to be applied to the mask");
+ RNA_def_int(ot->srna,
+ "iterations",
+ 1,
+ 1,
+ 100,
+ "Iterations",
+ "Number of times that the filter is going to be applied",
+ 1,
+ 100);
+ RNA_def_boolean(
+ ot->srna,
+ "auto_iteration_count",
+ false,
+ "Auto Iteration Count",
+ "Use a automatic number of iterations based on the number of vertices of the sculpt");
+}
+
+static float neighbor_dirty_mask(SculptSession *ss, PBVHVertexIter *vd)
+{
+ int total = 0;
+ float avg[3];
+ zero_v3(avg);
+
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd->index, ni) {
+ float normalized[3];
+ sub_v3_v3v3(normalized, SCULPT_vertex_co_get(ss, ni.index), vd->co);
+ normalize_v3(normalized);
+ add_v3_v3(avg, normalized);
+ total++;
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+
+ if (total > 0) {
+ mul_v3_fl(avg, 1.0f / total);
+ float normal[3];
+ if (vd->no) {
+ normal_short_to_float_v3(normal, vd->no);
+ }
+ else {
+ copy_v3_v3(normal, vd->fno);
+ }
+ float dot = dot_v3v3(avg, normal);
+ float angle = max_ff(saacosf(dot), 0.0f);
+ return angle;
+ }
+ return 0.0f;
+}
+
+typedef struct DirtyMaskRangeData {
+ float min, max;
+} DirtyMaskRangeData;
+
+static void dirty_mask_compute_range_task_cb(void *__restrict userdata,
+ const int i,
+ const TaskParallelTLS *__restrict tls)
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ PBVHNode *node = data->nodes[i];
+ DirtyMaskRangeData *range = tls->userdata_chunk;
+ PBVHVertexIter vd;
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
+ {
+ float dirty_mask = neighbor_dirty_mask(ss, &vd);
+ range->min = min_ff(dirty_mask, range->min);
+ range->max = max_ff(dirty_mask, range->max);
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void dirty_mask_compute_range_reduce(const void *__restrict UNUSED(userdata),
+ void *__restrict chunk_join,
+ void *__restrict chunk)
+{
+ DirtyMaskRangeData *join = chunk_join;
+ DirtyMaskRangeData *range = chunk;
+ join->min = min_ff(range->min, join->min);
+ join->max = max_ff(range->max, join->max);
+}
+
+static void dirty_mask_apply_task_cb(void *__restrict userdata,
+ const int i,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ PBVHNode *node = data->nodes[i];
+ PBVHVertexIter vd;
+
+ const bool dirty_only = data->dirty_mask_dirty_only;
+ const float min = data->dirty_mask_min;
+ const float max = data->dirty_mask_max;
+
+ float range = max - min;
+ if (range < 0.0001f) {
+ range = 0.0f;
+ }
+ else {
+ range = 1.0f / range;
+ }
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
+ {
+ float dirty_mask = neighbor_dirty_mask(ss, &vd);
+ float mask = *vd.mask + (1.0f - ((dirty_mask - min) * range));
+ if (dirty_only) {
+ mask = fminf(mask, 0.5f) * 2.0f;
+ }
+ *vd.mask = CLAMPIS(mask, 0.0f, 1.0f);
+
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+ BKE_pbvh_node_mark_update_mask(node);
+}
+
+static int sculpt_dirty_mask_exec(bContext *C, wmOperator *op)
+{
+ ARegion *region = CTX_wm_region(C);
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ PBVH *pbvh = ob->sculpt->pbvh;
+ PBVHNode **nodes;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ int totnode;
+
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true);
+
+ SCULPT_vertex_random_access_init(ss);
+
+ if (!ob->sculpt->pmap) {
+ return OPERATOR_CANCELLED;
+ }
+
+ BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
+ SCULPT_undo_push_begin("Dirty Mask");
+
+ for (int i = 0; i < totnode; i++) {
+ SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK);
+ }
+
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .nodes = nodes,
+ .dirty_mask_dirty_only = RNA_boolean_get(op->ptr, "dirty_only"),
+ };
+ DirtyMaskRangeData range = {
+ .min = FLT_MAX,
+ .max = -FLT_MAX,
+ };
+
+ PBVHParallelSettings settings;
+ BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+
+ settings.func_reduce = dirty_mask_compute_range_reduce;
+ settings.userdata_chunk = &range;
+ settings.userdata_chunk_size = sizeof(DirtyMaskRangeData);
+
+ BKE_pbvh_parallel_range(0, totnode, &data, dirty_mask_compute_range_task_cb, &settings);
+ data.dirty_mask_min = range.min;
+ data.dirty_mask_max = range.max;
+ BKE_pbvh_parallel_range(0, totnode, &data, dirty_mask_apply_task_cb, &settings);
+
+ MEM_SAFE_FREE(nodes);
+
+ BKE_pbvh_update_vertex_data(pbvh, PBVH_UpdateMask);
+
+ SCULPT_undo_push_end();
+
+ ED_region_tag_redraw(region);
+
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void SCULPT_OT_dirty_mask(struct wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Dirty Mask";
+ ot->idname = "SCULPT_OT_dirty_mask";
+ ot->description = "Generates a mask based on the geometry cavity and pointiness";
+
+ /* API callbacks. */
+ ot->exec = sculpt_dirty_mask_exec;
+ ot->poll = SCULPT_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER;
+
+ /* RNA. */
+ RNA_def_boolean(
+ ot->srna, "dirty_only", false, "Dirty Only", "Don't calculate cleans for convex areas");
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
new file mode 100644
index 00000000000..7116ec77fa4
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -0,0 +1,571 @@
+/*
+ * 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) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_hash.h"
+#include "BLI_math.h"
+#include "BLI_task.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_context.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_object.h"
+#include "BKE_paint.h"
+#include "BKE_pbvh.h"
+#include "BKE_scene.h"
+
+#include "DEG_depsgraph.h"
+
+#include "WM_api.h"
+#include "WM_message.h"
+#include "WM_toolsystem.h"
+#include "WM_types.h"
+
+#include "ED_object.h"
+#include "ED_screen.h"
+#include "ED_sculpt.h"
+#include "paint_intern.h"
+#include "sculpt_intern.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "UI_interface.h"
+
+#include "bmesh.h"
+
+#include <math.h>
+#include <stdlib.h>
+
+static void filter_cache_init_task_cb(void *__restrict userdata,
+ const int i,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ SculptThreadedTaskData *data = userdata;
+ PBVHNode *node = data->nodes[i];
+
+ SCULPT_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS);
+}
+
+void SCULPT_filter_cache_init(Object *ob, Sculpt *sd)
+{
+ SculptSession *ss = ob->sculpt;
+ PBVH *pbvh = ob->sculpt->pbvh;
+
+ ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache");
+
+ ss->filter_cache->random_seed = rand();
+
+ float center[3] = {0.0f};
+ SculptSearchSphereData search_data = {
+ .original = true,
+ .center = center,
+ .radius_squared = FLT_MAX,
+ .ignore_fully_masked = true,
+
+ };
+ BKE_pbvh_search_gather(pbvh,
+ SCULPT_search_sphere_cb,
+ &search_data,
+ &ss->filter_cache->nodes,
+ &ss->filter_cache->totnode);
+
+ for (int i = 0; i < ss->filter_cache->totnode; i++) {
+ BKE_pbvh_node_mark_normals_update(ss->filter_cache->nodes[i]);
+ }
+
+ /* mesh->runtime.subdiv_ccg is not available. Updating of the normals is done during drawing.
+ * Filters can't use normals in multires. */
+ if (BKE_pbvh_type(ss->pbvh) != PBVH_GRIDS) {
+ BKE_pbvh_update_normals(ss->pbvh, NULL);
+ }
+
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .nodes = ss->filter_cache->nodes,
+ };
+
+ PBVHParallelSettings settings;
+ BKE_pbvh_parallel_range_settings(
+ &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode);
+ BKE_pbvh_parallel_range(
+ 0, ss->filter_cache->totnode, &data, filter_cache_init_task_cb, &settings);
+}
+
+void SCULPT_filter_cache_free(SculptSession *ss)
+{
+ MEM_SAFE_FREE(ss->filter_cache->nodes);
+ MEM_SAFE_FREE(ss->filter_cache->mask_update_it);
+ MEM_SAFE_FREE(ss->filter_cache->prev_mask);
+ MEM_SAFE_FREE(ss->filter_cache->normal_factor);
+ MEM_SAFE_FREE(ss->filter_cache->prev_face_set);
+ MEM_SAFE_FREE(ss->filter_cache->automask);
+ MEM_SAFE_FREE(ss->filter_cache->surface_smooth_laplacian_disp);
+ MEM_SAFE_FREE(ss->filter_cache);
+}
+
+typedef enum eSculptMeshFilterTypes {
+ MESH_FILTER_SMOOTH = 0,
+ MESH_FILTER_SCALE = 1,
+ MESH_FILTER_INFLATE = 2,
+ MESH_FILTER_SPHERE = 3,
+ MESH_FILTER_RANDOM = 4,
+ MESH_FILTER_RELAX = 5,
+ MESH_FILTER_RELAX_FACE_SETS = 6,
+ MESH_FILTER_SURFACE_SMOOTH = 7,
+} eSculptMeshFilterTypes;
+
+static EnumPropertyItem prop_mesh_filter_types[] = {
+ {MESH_FILTER_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth mesh"},
+ {MESH_FILTER_SCALE, "SCALE", 0, "Scale", "Scale mesh"},
+ {MESH_FILTER_INFLATE, "INFLATE", 0, "Inflate", "Inflate mesh"},
+ {MESH_FILTER_SPHERE, "SPHERE", 0, "Sphere", "Morph into sphere"},
+ {MESH_FILTER_RANDOM, "RANDOM", 0, "Random", "Randomize vertex positions"},
+ {MESH_FILTER_RELAX, "RELAX", 0, "Relax", "Relax mesh"},
+ {MESH_FILTER_RELAX_FACE_SETS,
+ "RELAX_FACE_SETS",
+ 0,
+ "Relax Face Sets",
+ "Smooth the edges of all the Face Sets"},
+ {MESH_FILTER_SURFACE_SMOOTH,
+ "SURFACE_SMOOTH",
+ 0,
+ "Surface Smooth",
+ "Smooth the surface of the mesh, preserving the volume"},
+ {0, NULL, 0, NULL, NULL},
+};
+
+typedef enum eMeshFilterDeformAxis {
+ MESH_FILTER_DEFORM_X = 1 << 0,
+ MESH_FILTER_DEFORM_Y = 1 << 1,
+ MESH_FILTER_DEFORM_Z = 1 << 2,
+} eMeshFilterDeformAxis;
+
+static EnumPropertyItem prop_mesh_filter_deform_axis_items[] = {
+ {MESH_FILTER_DEFORM_X, "X", 0, "X", "Deform in the X axis"},
+ {MESH_FILTER_DEFORM_Y, "Y", 0, "Y", "Deform in the Y axis"},
+ {MESH_FILTER_DEFORM_Z, "Z", 0, "Z", "Deform in the Z axis"},
+ {0, NULL, 0, NULL, NULL},
+};
+
+static bool sculpt_mesh_filter_needs_pmap(int filter_type, bool use_face_sets)
+{
+ return use_face_sets || ELEM(filter_type,
+ MESH_FILTER_SMOOTH,
+ MESH_FILTER_RELAX,
+ MESH_FILTER_RELAX_FACE_SETS,
+ MESH_FILTER_SURFACE_SMOOTH);
+}
+
+static void mesh_filter_task_cb(void *__restrict userdata,
+ const int i,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ PBVHNode *node = data->nodes[i];
+
+ const int filter_type = data->filter_type;
+
+ SculptOrigVertData orig_data;
+ SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[i]);
+
+ /* When using the relax face sets meshes filter,
+ * each 3 iterations, do a whole mesh relax to smooth the contents of the Face Set. */
+ /* This produces better results as the relax operation is no completely focused on the
+ * boundaries. */
+ const bool relax_face_sets = !(ss->filter_cache->iteration_count % 3 == 0);
+
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
+ {
+ SCULPT_orig_vert_data_update(&orig_data, &vd);
+ float orig_co[3], val[3], avg[3], normal[3], disp[3], disp2[3], transform[3][3], final_pos[3];
+ float fade = vd.mask ? *vd.mask : 0.0f;
+ fade = 1.0f - fade;
+ fade *= data->filter_strength;
+
+ if (fade == 0.0f) {
+ continue;
+ }
+
+ if (ss->filter_cache->active_face_set != SCULPT_FACE_SET_NONE) {
+ if (!SCULPT_vertex_has_face_set(ss, vd.index, ss->filter_cache->active_face_set)) {
+ continue;
+ }
+ /* Skip the edges of the face set when relaxing or smoothing.
+ * There is a relax face set option to relax the boundaries independently. */
+ if (filter_type == MESH_FILTER_RELAX) {
+ if (!SCULPT_vertex_has_unique_face_set(ss, vd.index)) {
+ continue;
+ }
+ }
+ }
+
+ if (ELEM(filter_type, MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS)) {
+ copy_v3_v3(orig_co, vd.co);
+ }
+ else {
+ copy_v3_v3(orig_co, orig_data.co);
+ }
+
+ if (filter_type == MESH_FILTER_RELAX_FACE_SETS) {
+ if (relax_face_sets == SCULPT_vertex_has_unique_face_set(ss, vd.index)) {
+ continue;
+ }
+ }
+
+ switch (filter_type) {
+ case MESH_FILTER_SMOOTH:
+ CLAMP(fade, -1.0f, 1.0f);
+ switch (BKE_pbvh_type(ss->pbvh)) {
+ case PBVH_FACES:
+ SCULPT_neighbor_average(ss, avg, vd.index);
+ break;
+ case PBVH_BMESH:
+ SCULPT_bmesh_neighbor_average(avg, vd.bm_vert);
+ break;
+ case PBVH_GRIDS:
+ SCULPT_neighbor_coords_average(ss, avg, vd.index);
+ break;
+ }
+ sub_v3_v3v3(val, avg, orig_co);
+ madd_v3_v3v3fl(val, orig_co, val, fade);
+ sub_v3_v3v3(disp, val, orig_co);
+ break;
+ case MESH_FILTER_INFLATE:
+ normal_short_to_float_v3(normal, orig_data.no);
+ mul_v3_v3fl(disp, normal, fade);
+ break;
+ case MESH_FILTER_SCALE:
+ unit_m3(transform);
+ scale_m3_fl(transform, 1.0f + fade);
+ copy_v3_v3(val, orig_co);
+ mul_m3_v3(transform, val);
+ sub_v3_v3v3(disp, val, orig_co);
+ break;
+ case MESH_FILTER_SPHERE:
+ normalize_v3_v3(disp, orig_co);
+ if (fade > 0.0f) {
+ mul_v3_v3fl(disp, disp, fade);
+ }
+ else {
+ mul_v3_v3fl(disp, disp, -fade);
+ }
+
+ unit_m3(transform);
+ if (fade > 0.0f) {
+ scale_m3_fl(transform, 1.0f - fade);
+ }
+ else {
+ scale_m3_fl(transform, 1.0f + fade);
+ }
+ copy_v3_v3(val, orig_co);
+ mul_m3_v3(transform, val);
+ sub_v3_v3v3(disp2, val, orig_co);
+
+ mid_v3_v3v3(disp, disp, disp2);
+ break;
+ case MESH_FILTER_RANDOM: {
+ normal_short_to_float_v3(normal, orig_data.no);
+ /* Index is not unique for multires, so hash by vertex coordinates. */
+ const uint *hash_co = (const uint *)orig_co;
+ const uint hash = BLI_hash_int_2d(hash_co[0], hash_co[1]) ^
+ BLI_hash_int_2d(hash_co[2], ss->filter_cache->random_seed);
+ mul_v3_fl(normal, hash * (1.0f / (float)0xFFFFFFFF) - 0.5f);
+ mul_v3_v3fl(disp, normal, fade);
+ break;
+ }
+ case MESH_FILTER_RELAX: {
+ SCULPT_relax_vertex(
+ ss, &vd, clamp_f(fade * ss->filter_cache->automask[vd.index], 0.0f, 1.0f), false, val);
+ sub_v3_v3v3(disp, val, vd.co);
+ break;
+ }
+ case MESH_FILTER_RELAX_FACE_SETS: {
+ SCULPT_relax_vertex(ss, &vd, clamp_f(fade, 0.0f, 1.0f), relax_face_sets, val);
+ sub_v3_v3v3(disp, val, vd.co);
+ break;
+ }
+ case MESH_FILTER_SURFACE_SMOOTH: {
+ SCULPT_surface_smooth_laplacian_step(ss,
+ disp,
+ vd.co,
+ ss->filter_cache->surface_smooth_laplacian_disp,
+ vd.index,
+ orig_data.co,
+ ss->filter_cache->surface_smooth_shape_preservation);
+ break;
+ }
+ }
+
+ for (int it = 0; it < 3; it++) {
+ if (!ss->filter_cache->enabled_axis[it]) {
+ disp[it] = 0.0f;
+ }
+ }
+
+ if (filter_type == MESH_FILTER_SURFACE_SMOOTH) {
+ madd_v3_v3v3fl(final_pos, vd.co, disp, clamp_f(fade, 0.0f, 1.0f));
+ }
+ else {
+ add_v3_v3v3(final_pos, orig_co, disp);
+ }
+ copy_v3_v3(vd.co, final_pos);
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+
+ BKE_pbvh_node_mark_update(node);
+}
+
+static void mesh_filter_surface_smooth_displace_task_cb(
+ void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ PBVHNode *node = data->nodes[i];
+ PBVHVertexIter vd;
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
+ {
+ float fade = vd.mask ? *vd.mask : 0.0f;
+ fade = 1.0f - fade;
+ fade *= data->filter_strength;
+ if (fade == 0.0f) {
+ continue;
+ }
+ SCULPT_surface_smooth_displace_step(ss,
+ vd.co,
+ ss->filter_cache->surface_smooth_laplacian_disp,
+ vd.index,
+ ss->filter_cache->surface_smooth_current_vertex,
+ clamp_f(fade, 0.0f, 1.0f));
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Object *ob = CTX_data_active_object(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ SculptSession *ss = ob->sculpt;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ int filter_type = RNA_enum_get(op->ptr, "type");
+ float filter_strength = RNA_float_get(op->ptr, "strength");
+ const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets");
+
+ if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
+ SCULPT_filter_cache_free(ss);
+ SCULPT_undo_push_end();
+ SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_COORDS);
+ return OPERATOR_FINISHED;
+ }
+
+ if (event->type != MOUSEMOVE) {
+ return OPERATOR_RUNNING_MODAL;
+ }
+
+ float len = event->prevclickx - event->mval[0];
+ filter_strength = filter_strength * -len * 0.001f * UI_DPI_FAC;
+
+ SCULPT_vertex_random_access_init(ss);
+
+ bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false);
+
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .nodes = ss->filter_cache->nodes,
+ .filter_type = filter_type,
+ .filter_strength = filter_strength,
+ };
+
+ PBVHParallelSettings settings;
+ BKE_pbvh_parallel_range_settings(
+ &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode);
+ BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, mesh_filter_task_cb, &settings);
+
+ if (filter_type == MESH_FILTER_SURFACE_SMOOTH) {
+ BKE_pbvh_parallel_range(0,
+ ss->filter_cache->totnode,
+ &data,
+ mesh_filter_surface_smooth_displace_task_cb,
+ &settings);
+ }
+
+ ss->filter_cache->iteration_count++;
+
+ if (ss->deform_modifiers_active || ss->shapekey_active) {
+ SCULPT_flush_stroke_deform(sd, ob, true);
+ }
+
+ /* The relax mesh filter needs the updated normals of the modified mesh after each iteration. */
+ if (ELEM(MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS)) {
+ BKE_pbvh_update_normals(ss->pbvh, ss->subdiv_ccg);
+ }
+
+ SCULPT_flush_update_step(C, SCULPT_UPDATE_COORDS);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Object *ob = CTX_data_active_object(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ int filter_type = RNA_enum_get(op->ptr, "type");
+ SculptSession *ss = ob->sculpt;
+ PBVH *pbvh = ob->sculpt->pbvh;
+
+ int deform_axis = RNA_enum_get(op->ptr, "deform_axis");
+ if (deform_axis == 0) {
+ return OPERATOR_CANCELLED;
+ }
+
+ if (RNA_boolean_get(op->ptr, "use_face_sets")) {
+ /* Update the active vertex */
+ float mouse[2];
+ SculptCursorGeometryInfo sgi;
+ mouse[0] = event->mval[0];
+ mouse[1] = event->mval[1];
+ SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
+ }
+
+ const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets");
+
+ SCULPT_vertex_random_access_init(ss);
+
+ bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false);
+
+ if (BKE_pbvh_type(pbvh) == PBVH_FACES && needs_pmap && !ob->sculpt->pmap) {
+ return OPERATOR_CANCELLED;
+ }
+
+ SCULPT_undo_push_begin("Mesh filter");
+
+ SCULPT_filter_cache_init(ob, sd);
+
+ if (use_face_sets) {
+ ss->filter_cache->active_face_set = SCULPT_vertex_face_set_get(ss,
+ SCULPT_active_vertex_get(ss));
+ }
+ else {
+ ss->filter_cache->active_face_set = SCULPT_FACE_SET_NONE;
+ }
+
+ if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_SURFACE_SMOOTH) {
+ ss->filter_cache->surface_smooth_laplacian_disp = MEM_mallocN(
+ 3 * sizeof(float) * SCULPT_vertex_count_get(ss), "surface smooth disp");
+ ss->filter_cache->surface_smooth_shape_preservation = RNA_float_get(
+ op->ptr, "surface_smooth_shape_preservation");
+ ss->filter_cache->surface_smooth_current_vertex = RNA_float_get(
+ op->ptr, "surface_smooth_current_vertex");
+ }
+
+ ss->filter_cache->enabled_axis[0] = deform_axis & MESH_FILTER_DEFORM_X;
+ ss->filter_cache->enabled_axis[1] = deform_axis & MESH_FILTER_DEFORM_Y;
+ ss->filter_cache->enabled_axis[2] = deform_axis & MESH_FILTER_DEFORM_Z;
+
+ if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_RELAX) {
+ const int totvert = SCULPT_vertex_count_get(ss);
+ ss->filter_cache->automask = MEM_mallocN(totvert * sizeof(float),
+ "Relax filter edge automask");
+ for (int i = 0; i < totvert; i++) {
+ ss->filter_cache->automask[i] = 1.0f;
+ }
+ SCULPT_boundary_automasking_init(
+ ob, AUTOMASK_INIT_BOUNDARY_EDGES, 1, ss->filter_cache->automask);
+ }
+
+ WM_event_add_modal_handler(C, op);
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void SCULPT_OT_mesh_filter(struct wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Filter mesh";
+ ot->idname = "SCULPT_OT_mesh_filter";
+ ot->description = "Applies a filter to modify the current mesh";
+
+ /* API callbacks. */
+ ot->invoke = sculpt_mesh_filter_invoke;
+ ot->modal = sculpt_mesh_filter_modal;
+ ot->poll = SCULPT_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* RNA. */
+ RNA_def_enum(ot->srna,
+ "type",
+ prop_mesh_filter_types,
+ MESH_FILTER_INFLATE,
+ "Filter type",
+ "Operation that is going to be applied to the mesh");
+ RNA_def_float(
+ ot->srna, "strength", 1.0f, -10.0f, 10.0f, "Strength", "Filter Strength", -10.0f, 10.0f);
+ RNA_def_enum_flag(ot->srna,
+ "deform_axis",
+ prop_mesh_filter_deform_axis_items,
+ MESH_FILTER_DEFORM_X | MESH_FILTER_DEFORM_Y | MESH_FILTER_DEFORM_Z,
+ "Deform axis",
+ "Apply the deformation in the selected axis");
+ ot->prop = RNA_def_boolean(ot->srna,
+ "use_face_sets",
+ false,
+ "Use Face Sets",
+ "Apply the filter only to the Face Mask under the cursor");
+
+ /* Surface Smooth Mesh Filter properties. */
+ RNA_def_float(ot->srna,
+ "surface_smooth_shape_preservation",
+ 0.5f,
+ 0.0f,
+ 1.0f,
+ "Shape Preservation",
+ "How much of the original shape is preserved when smoothing",
+ 0.0f,
+ 1.0f);
+ RNA_def_float(ot->srna,
+ "surface_smooth_current_vertex",
+ 0.5f,
+ 0.0f,
+ 1.0f,
+ "Per Vertex Displacement",
+ "How much the position of each individual vertex influences the final result",
+ 0.0f,
+ 1.0f);
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index fe56283dbcb..e2fd54596e7 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -24,6 +24,7 @@
#ifndef __SCULPT_INTERN_H__
#define __SCULPT_INTERN_H__
+#include "DNA_brush_types.h"
#include "DNA_key_types.h"
#include "DNA_listBase.h"
#include "DNA_vec_types.h"
@@ -57,6 +58,10 @@ typedef enum SculptUpdateType {
SCULPT_UPDATE_VISIBILITY = 1 << 2,
} SculptUpdateType;
+void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags);
+void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags);
+void SCULPT_flush_stroke_deform(struct Sculpt *sd, Object *ob, bool is_proxy_used);
+
/* Stroke */
typedef struct SculptCursorGeometryInfo {
@@ -72,11 +77,20 @@ bool SCULPT_cursor_geometry_info_update(bContext *C,
bool use_sampled_normal);
void SCULPT_geometry_preview_lines_update(bContext *C, struct SculptSession *ss, float radius);
+void SCULPT_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush);
+float SCULPT_raycast_init(struct ViewContext *vc,
+ const float mouse[2],
+ float ray_start[3],
+ float ray_end[3],
+ float ray_normal[3],
+ bool original);
+
/* Sculpt PBVH abstraction API */
void SCULPT_vertex_random_access_init(struct SculptSession *ss);
int SCULPT_vertex_count_get(struct SculptSession *ss);
const float *SCULPT_vertex_co_get(struct SculptSession *ss, int index);
+void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3]);
float SCULPT_vertex_mask_get(struct SculptSession *ss, int index);
#define SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY 256
@@ -127,6 +141,35 @@ void SCULPT_vertex_neighbors_get(struct SculptSession *ss,
int SCULPT_active_vertex_get(SculptSession *ss);
const float *SCULPT_active_vertex_co_get(SculptSession *ss);
+void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]);
+
+bool SCULPT_vertex_is_boundary(SculptSession *ss, const int index);
+
+/* Sculpt Visibility API */
+
+void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible);
+bool SCULPT_vertex_visible_get(SculptSession *ss, int index);
+
+void SCULPT_visibility_sync_all_face_sets_to_vertices(struct SculptSession *ss);
+void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss);
+
+/* Face Sets API */
+
+int SCULPT_active_face_set_get(SculptSession *ss);
+int SCULPT_vertex_face_set_get(SculptSession *ss, int index);
+void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_set);
+
+bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set);
+bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index);
+
+int SCULPT_face_set_next_available_get(SculptSession *ss);
+
+void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool visible);
+bool SCULPT_vertex_all_face_sets_visible_get(SculptSession *ss, int index);
+bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, int index);
+
+void SCULPT_face_sets_visibility_invert(SculptSession *ss);
+void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible);
/* Sculpt Original Data */
typedef struct {
@@ -146,16 +189,6 @@ typedef struct {
void SCULPT_orig_vert_data_init(SculptOrigVertData *data, Object *ob, PBVHNode *node);
void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, PBVHVertexIter *iter);
-/* Face Sets */
-int SCULPT_vertex_face_set_get(SculptSession *ss, int index);
-bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set);
-bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index);
-
-/* Dynamic topology */
-void sculpt_pbvh_clear(Object *ob);
-void sculpt_dyntopo_node_layers_add(struct SculptSession *ss);
-void sculpt_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode);
-
/* Utils. */
void SCULPT_calc_brush_plane(struct Sculpt *sd,
struct Object *ob,
@@ -177,11 +210,16 @@ int SCULPT_plane_point_side(const float co[3], const float plane[4]);
int SCULPT_plane_trim(const struct StrokeCache *cache,
const struct Brush *brush,
const float val[3]);
+void SCULPT_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3]);
float SCULPT_brush_plane_offset_get(Sculpt *sd, SculptSession *ss);
ePaintSymmetryAreas SCULPT_get_vertex_symm_area(const float co[3]);
bool SCULPT_check_vertex_pivot_symmetry(const float vco[3], const float pco[3], const char symm);
+bool SCULPT_is_vertex_inside_brush_radius_symm(const float vertex[3],
+ const float br_co[3],
+ float radius,
+ char symm);
bool SCULPT_is_symmetry_iteration_valid(char i, char symm);
void SCULPT_flip_v3_by_symm_area(float v[3],
const ePaintSymmetryFlags symm,
@@ -210,7 +248,7 @@ void SCULPT_floodfill_add_initial_with_symmetry(struct Sculpt *sd,
SculptFloodFill *flood,
int index,
float radius);
-void sculpt_floodfill_add_initial(SculptFloodFill *flood, int index);
+void SCULPT_floodfill_add_initial(SculptFloodFill *flood, int index);
void SCULPT_floodfill_execute(
struct SculptSession *ss,
SculptFloodFill *flood,
@@ -218,9 +256,61 @@ void SCULPT_floodfill_execute(
void *userdata);
void SCULPT_floodfill_free(SculptFloodFill *flood);
+/* Dynamic topology */
+
+enum eDynTopoWarnFlag {
+ DYNTOPO_WARN_VDATA = (1 << 0),
+ DYNTOPO_WARN_EDATA = (1 << 1),
+ DYNTOPO_WARN_LDATA = (1 << 2),
+ DYNTOPO_WARN_MODIFIER = (1 << 3),
+};
+
+void SCULPT_dynamic_topology_enable_ex(struct Main *bmain,
+ struct Depsgraph *depsgraph,
+ Scene *scene,
+ Object *ob);
+void SCULPT_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode);
+void sculpt_dynamic_topology_disable_with_undo(struct Main *bmain,
+ struct Depsgraph *depsgraph,
+ Scene *scene,
+ Object *ob);
+
+bool SCULPT_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *brush);
+
+void SCULPT_dynamic_topology_triangulate(struct BMesh *bm);
+void SCULPT_dyntopo_node_layers_add(struct SculptSession *ss);
+
+enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene *scene, Object *ob);
+
+void SCULPT_pbvh_clear(Object *ob);
+
/* Automasking. */
float SCULPT_automasking_factor_get(SculptSession *ss, int vert);
+void SCULPT_automasking_init(Sculpt *sd, Object *ob);
+void SCULPT_automasking_end(Object *ob);
+
+bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd,
+ const Brush *br,
+ const eAutomasking_flag mode);
+bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br);
+
+typedef enum eBoundaryAutomaskMode {
+ AUTOMASK_INIT_BOUNDARY_EDGES = 1,
+ AUTOMASK_INIT_BOUNDARY_FACE_SETS = 2,
+} eBoundaryAutomaskMode;
+float *SCULPT_boundary_automasking_init(Object *ob,
+ eBoundaryAutomaskMode mode,
+ int propagation_steps,
+ float *automask_factor);
+
+/* Filters. */
+void SCULPT_filter_cache_init(Object *ob, Sculpt *sd);
+void SCULPT_filter_cache_free(SculptSession *ss);
+
+void SCULPT_mask_filter_smooth_apply(
+ Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, const int smooth_iterations);
+
/* Brushes. */
/* Cloth Brush. */
@@ -274,6 +364,43 @@ void SCULPT_multiplane_scrape_preview_draw(const uint gpuattr,
SculptSession *ss,
const float outline_col[3],
const float outline_alpha);
+/* Draw Face Sets Brush. */
+void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
+
+/* Smooth Brush. */
+
+void SCULPT_neighbor_average(SculptSession *ss, float avg[3], uint vert);
+void SCULPT_bmesh_neighbor_average(float avg[3], struct BMVert *v);
+
+void SCULPT_bmesh_four_neighbor_average(float avg[3], float direction[3], struct BMVert *v);
+
+void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], int index);
+float SCULPT_neighbor_mask_average(SculptSession *ss, int index);
+
+void SCULPT_smooth(Sculpt *sd,
+ Object *ob,
+ PBVHNode **nodes,
+ const int totnode,
+ float bstrength,
+ const bool smooth_mask);
+void SCULPT_do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
+
+/* Surface Smooth Brush. */
+
+void SCULPT_surface_smooth_laplacian_step(SculptSession *ss,
+ float *disp,
+ const float co[3],
+ float (*laplacian_disp)[3],
+ const int v_index,
+ const float origco[3],
+ const float alpha);
+void SCULPT_surface_smooth_displace_step(SculptSession *ss,
+ float *co,
+ float (*laplacian_disp)[3],
+ const int v_index,
+ const float beta,
+ const float fade);
+void SCULPT_do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
/* Slide/Relax */
void SCULPT_relax_vertex(struct SculptSession *ss,
@@ -282,10 +409,6 @@ void SCULPT_relax_vertex(struct SculptSession *ss,
bool filter_boundary_face_sets,
float *r_final_pos);
-/* Sculpt Visibility API */
-void SCULPT_visibility_sync_all_face_sets_to_vertices(struct SculptSession *ss);
-void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss);
-
/* Undo */
typedef enum {
@@ -299,6 +422,23 @@ typedef enum {
SCULPT_UNDO_FACE_SETS,
} SculptUndoType;
+/* Storage of geometry for the undo node.
+ * Is used as a storage for either original or modified geometry. */
+typedef struct SculptUndoNodeGeometry {
+ /* Is used for sanity check, helping with ensuring that two and only two
+ * geometry pushes happened in the undo stack. */
+ bool is_initialized;
+
+ CustomData vdata;
+ CustomData edata;
+ CustomData ldata;
+ CustomData pdata;
+ int totvert;
+ int totedge;
+ int totloop;
+ int totpoly;
+} SculptUndoNodeGeometry;
+
typedef struct SculptUndoNode {
struct SculptUndoNode *next, *prev;
@@ -332,15 +472,17 @@ typedef struct SculptUndoNode {
/* shape keys */
char shapeName[sizeof(((KeyBlock *)0))->name];
- /* geometry modification operations and bmesh enter data */
- CustomData geom_vdata;
- CustomData geom_edata;
- CustomData geom_ldata;
- CustomData geom_pdata;
- int geom_totvert;
- int geom_totedge;
- int geom_totloop;
- int geom_totpoly;
+ /* Geometry modification operations.
+ *
+ * Original geometry is stored before some modification is run and is used to restore state of
+ * the object when undoing the operation
+ *
+ * Modified geometry is stored after the modification and is used to redo the modification. */
+ SculptUndoNodeGeometry geometry_original;
+ SculptUndoNodeGeometry geometry_modified;
+
+ /* Geometry at the bmesh enter moment. */
+ SculptUndoNodeGeometry geometry_bmesh_enter;
/* pivot */
float pivot_pos[3];
@@ -707,6 +849,7 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
SculptUndoNode *SCULPT_undo_get_node(PBVHNode *node);
void SCULPT_undo_push_begin(const char *name);
void SCULPT_undo_push_end(void);
+void SCULPT_undo_push_end_ex(const bool use_nested_undo);
void SCULPT_vertcos_to_key(Object *ob, KeyBlock *kb, const float (*vertCos)[3]);
@@ -717,4 +860,33 @@ bool SCULPT_get_redraw_rect(struct ARegion *region,
Object *ob,
rcti *rect);
+/* Operators. */
+
+/* Face Sets. */
+void SCULPT_OT_face_sets_randomize_colors(struct wmOperatorType *ot);
+void SCULPT_OT_face_sets_change_visibility(struct wmOperatorType *ot);
+void SCULPT_OT_face_sets_init(struct wmOperatorType *ot);
+void SCULPT_OT_face_sets_create(struct wmOperatorType *ot);
+
+/* Transform. */
+void SCULPT_OT_set_pivot_position(struct wmOperatorType *ot);
+
+/* Mesh Filter. */
+void SCULPT_OT_mesh_filter(struct wmOperatorType *ot);
+
+/* Mask filter and Dirty Mask. */
+void SCULPT_OT_mask_filter(struct wmOperatorType *ot);
+void SCULPT_OT_dirty_mask(struct wmOperatorType *ot);
+
+/* Mask and Face Sets Expand. */
+void SCULPT_OT_mask_expand(struct wmOperatorType *ot);
+
+/* Detail size. */
+void SCULPT_OT_detail_flood_fill(struct wmOperatorType *ot);
+void SCULPT_OT_sample_detail_size(struct wmOperatorType *ot);
+void SCULPT_OT_set_detail_size(struct wmOperatorType *ot);
+
+/* Dyntopo. */
+void SCULPT_OT_dynamic_topology_toggle(struct wmOperatorType *ot);
+
#endif
diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
new file mode 100644
index 00000000000..34ca92acef9
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
@@ -0,0 +1,526 @@
+/*
+ * 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) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_task.h"
+
+#include "BLT_translation.h"
+
+#include "DNA_brush_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_ccg.h"
+#include "BKE_colortools.h"
+#include "BKE_context.h"
+#include "BKE_mesh.h"
+#include "BKE_multires.h"
+#include "BKE_node.h"
+#include "BKE_object.h"
+#include "BKE_paint.h"
+#include "BKE_pbvh.h"
+#include "BKE_scene.h"
+
+#include "DEG_depsgraph.h"
+
+#include "WM_api.h"
+#include "WM_message.h"
+#include "WM_toolsystem.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "ED_object.h"
+#include "ED_screen.h"
+#include "ED_sculpt.h"
+#include "ED_view3d.h"
+#include "paint_intern.h"
+#include "sculpt_intern.h"
+
+#include "bmesh.h"
+
+#include <math.h>
+#include <stdlib.h>
+
+static void sculpt_mask_expand_cancel(bContext *C, wmOperator *op)
+{
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set");
+
+ MEM_freeN(op->customdata);
+
+ for (int n = 0; n < ss->filter_cache->totnode; n++) {
+ PBVHNode *node = ss->filter_cache->nodes[n];
+ if (create_face_set) {
+ for (int i = 0; i < ss->totfaces; i++) {
+ ss->face_sets[i] = ss->filter_cache->prev_face_set[i];
+ }
+ }
+ else {
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
+ {
+ *vd.mask = ss->filter_cache->prev_mask[vd.index];
+ }
+ BKE_pbvh_vertex_iter_end;
+ }
+
+ BKE_pbvh_node_mark_redraw(node);
+ }
+
+ if (!create_face_set) {
+ SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK);
+ }
+ SCULPT_filter_cache_free(ss);
+ SCULPT_undo_push_end();
+ SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK);
+ ED_workspace_status_text(C, NULL);
+}
+
+static void sculpt_expand_task_cb(void *__restrict userdata,
+ const int i,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ PBVHNode *node = data->nodes[i];
+ PBVHVertexIter vd;
+ int update_it = data->mask_expand_update_it;
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_ALL)
+ {
+ int vi = vd.index;
+ float final_mask = *vd.mask;
+ if (data->mask_expand_use_normals) {
+ if (ss->filter_cache->normal_factor[SCULPT_active_vertex_get(ss)] <
+ ss->filter_cache->normal_factor[vd.index]) {
+ final_mask = 1.0f;
+ }
+ else {
+ final_mask = 0.0f;
+ }
+ }
+ else {
+ if (ss->filter_cache->mask_update_it[vi] <= update_it &&
+ ss->filter_cache->mask_update_it[vi] != 0) {
+ final_mask = 1.0f;
+ }
+ else {
+ final_mask = 0.0f;
+ }
+ }
+
+ if (data->mask_expand_create_face_set) {
+ if (final_mask == 1.0f) {
+ SCULPT_vertex_face_set_set(ss, vd.index, ss->filter_cache->new_face_set);
+ }
+ BKE_pbvh_node_mark_redraw(node);
+ }
+ else {
+
+ if (data->mask_expand_keep_prev_mask) {
+ final_mask = MAX2(ss->filter_cache->prev_mask[vd.index], final_mask);
+ }
+
+ if (data->mask_expand_invert_mask) {
+ final_mask = 1.0f - final_mask;
+ }
+
+ if (*vd.mask != final_mask) {
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ *vd.mask = final_mask;
+ BKE_pbvh_node_mark_update_mask(node);
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ ARegion *region = CTX_wm_region(C);
+ float prevclick_f[2];
+ copy_v2_v2(prevclick_f, op->customdata);
+ int prevclick[2] = {(int)prevclick_f[0], (int)prevclick_f[1]};
+ int len = (int)len_v2v2_int(prevclick, event->mval);
+ len = abs(len);
+ int mask_speed = RNA_int_get(op->ptr, "mask_speed");
+ int mask_expand_update_it = len / mask_speed;
+ mask_expand_update_it = mask_expand_update_it + 1;
+
+ const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set");
+
+ if (RNA_boolean_get(op->ptr, "use_cursor")) {
+ SculptCursorGeometryInfo sgi;
+ float mouse[2];
+ mouse[0] = event->mval[0];
+ mouse[1] = event->mval[1];
+ SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
+ mask_expand_update_it = ss->filter_cache->mask_update_it[(int)SCULPT_active_vertex_get(ss)];
+ }
+
+ if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) ||
+ (event->type == RIGHTMOUSE && event->val == KM_PRESS)) {
+ /* Returning OPERATOR_CANCELLED will leak memory due to not finishing
+ * undo. Better solution could be to make paint_mesh_restore_co work
+ * for this case. */
+ sculpt_mask_expand_cancel(C, op);
+ return OPERATOR_FINISHED;
+ }
+
+ if ((event->type == LEFTMOUSE && event->val == KM_RELEASE) ||
+ (event->type == EVT_RETKEY && event->val == KM_PRESS) ||
+ (event->type == EVT_PADENTER && event->val == KM_PRESS)) {
+
+ /* Smooth iterations. */
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false);
+ const int smooth_iterations = RNA_int_get(op->ptr, "smooth_iterations");
+ SCULPT_mask_filter_smooth_apply(
+ sd, ob, ss->filter_cache->nodes, ss->filter_cache->totnode, smooth_iterations);
+
+ /* Pivot position. */
+ if (RNA_boolean_get(op->ptr, "update_pivot")) {
+ const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const float threshold = 0.2f;
+ float avg[3];
+ int total = 0;
+ zero_v3(avg);
+
+ for (int n = 0; n < ss->filter_cache->totnode; n++) {
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, ss->filter_cache->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ const float mask = (vd.mask) ? *vd.mask : 0.0f;
+ if (mask < (0.5f + threshold) && mask > (0.5f - threshold)) {
+ if (SCULPT_check_vertex_pivot_symmetry(
+ vd.co, ss->filter_cache->mask_expand_initial_co, symm)) {
+ add_v3_v3(avg, vd.co);
+ total++;
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+ }
+
+ if (total > 0) {
+ mul_v3_fl(avg, 1.0f / total);
+ copy_v3_v3(ss->pivot_pos, avg);
+ }
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+ }
+
+ MEM_freeN(op->customdata);
+
+ for (int i = 0; i < ss->filter_cache->totnode; i++) {
+ BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]);
+ }
+
+ SCULPT_filter_cache_free(ss);
+
+ SCULPT_undo_push_end();
+ SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK);
+ ED_workspace_status_text(C, NULL);
+ return OPERATOR_FINISHED;
+ }
+
+ /* When pressing Ctrl, expand directly to the max number of iterations. This allows to flood fill
+ * mask and face sets by connectivity directly. */
+ if (event->ctrl) {
+ mask_expand_update_it = ss->filter_cache->mask_update_last_it - 1;
+ }
+
+ if (!ELEM(event->type, MOUSEMOVE, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY)) {
+ return OPERATOR_RUNNING_MODAL;
+ }
+
+ if (mask_expand_update_it == ss->filter_cache->mask_update_current_it) {
+ ED_region_tag_redraw(region);
+ return OPERATOR_RUNNING_MODAL;
+ }
+
+ if (mask_expand_update_it < ss->filter_cache->mask_update_last_it) {
+
+ if (create_face_set) {
+ for (int i = 0; i < ss->totfaces; i++) {
+ ss->face_sets[i] = ss->filter_cache->prev_face_set[i];
+ }
+ }
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .nodes = ss->filter_cache->nodes,
+ .mask_expand_update_it = mask_expand_update_it,
+ .mask_expand_use_normals = RNA_boolean_get(op->ptr, "use_normals"),
+ .mask_expand_invert_mask = RNA_boolean_get(op->ptr, "invert"),
+ .mask_expand_keep_prev_mask = RNA_boolean_get(op->ptr, "keep_previous_mask"),
+ .mask_expand_create_face_set = RNA_boolean_get(op->ptr, "create_face_set"),
+ };
+ PBVHParallelSettings settings;
+ BKE_pbvh_parallel_range_settings(
+ &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode);
+ BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, sculpt_expand_task_cb, &settings);
+ ss->filter_cache->mask_update_current_it = mask_expand_update_it;
+ }
+
+ SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+typedef struct MaskExpandFloodFillData {
+ float original_normal[3];
+ float edge_sensitivity;
+ bool use_normals;
+} MaskExpandFloodFillData;
+
+static bool mask_expand_floodfill_cb(
+ SculptSession *ss, int from_v, int to_v, bool is_duplicate, void *userdata)
+{
+ MaskExpandFloodFillData *data = userdata;
+
+ if (!is_duplicate) {
+ int to_it = ss->filter_cache->mask_update_it[from_v] + 1;
+ ss->filter_cache->mask_update_it[to_v] = to_it;
+ if (to_it > ss->filter_cache->mask_update_last_it) {
+ ss->filter_cache->mask_update_last_it = to_it;
+ }
+
+ if (data->use_normals) {
+ float current_normal[3], prev_normal[3];
+ SCULPT_vertex_normal_get(ss, to_v, current_normal);
+ SCULPT_vertex_normal_get(ss, from_v, prev_normal);
+ const float from_edge_factor = ss->filter_cache->edge_factor[from_v];
+ ss->filter_cache->edge_factor[to_v] = dot_v3v3(current_normal, prev_normal) *
+ from_edge_factor;
+ ss->filter_cache->normal_factor[to_v] = dot_v3v3(data->original_normal, current_normal) *
+ powf(from_edge_factor, data->edge_sensitivity);
+ CLAMP(ss->filter_cache->normal_factor[to_v], 0.0f, 1.0f);
+ }
+ }
+ else {
+ /* PBVH_GRIDS duplicate handling. */
+ ss->filter_cache->mask_update_it[to_v] = ss->filter_cache->mask_update_it[from_v];
+ if (data->use_normals) {
+ ss->filter_cache->edge_factor[to_v] = ss->filter_cache->edge_factor[from_v];
+ ss->filter_cache->normal_factor[to_v] = ss->filter_cache->normal_factor[from_v];
+ }
+ }
+
+ return true;
+}
+
+static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ PBVH *pbvh = ob->sculpt->pbvh;
+
+ const bool use_normals = RNA_boolean_get(op->ptr, "use_normals");
+ const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set");
+
+ SculptCursorGeometryInfo sgi;
+ float mouse[2];
+ mouse[0] = event->mval[0];
+ mouse[1] = event->mval[1];
+
+ SCULPT_vertex_random_access_init(ss);
+
+ op->customdata = MEM_mallocN(2 * sizeof(float), "initial mouse position");
+ copy_v2_v2(op->customdata, mouse);
+
+ SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
+
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true);
+
+ int vertex_count = SCULPT_vertex_count_get(ss);
+
+ ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache");
+
+ BKE_pbvh_search_gather(pbvh, NULL, NULL, &ss->filter_cache->nodes, &ss->filter_cache->totnode);
+
+ SCULPT_undo_push_begin("Mask Expand");
+
+ if (create_face_set) {
+ SCULPT_undo_push_node(ob, ss->filter_cache->nodes[0], SCULPT_UNDO_FACE_SETS);
+ for (int i = 0; i < ss->filter_cache->totnode; i++) {
+ BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]);
+ }
+ }
+ else {
+ for (int i = 0; i < ss->filter_cache->totnode; i++) {
+ SCULPT_undo_push_node(ob, ss->filter_cache->nodes[i], SCULPT_UNDO_MASK);
+ BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]);
+ }
+ }
+
+ ss->filter_cache->mask_update_it = MEM_callocN(sizeof(int) * vertex_count,
+ "mask update iteration");
+ if (use_normals) {
+ ss->filter_cache->normal_factor = MEM_callocN(sizeof(float) * vertex_count,
+ "mask update normal factor");
+ ss->filter_cache->edge_factor = MEM_callocN(sizeof(float) * vertex_count,
+ "mask update normal factor");
+ for (int i = 0; i < vertex_count; i++) {
+ ss->filter_cache->edge_factor[i] = 1.0f;
+ }
+ }
+
+ if (create_face_set) {
+ ss->filter_cache->prev_face_set = MEM_callocN(sizeof(float) * ss->totfaces, "prev face mask");
+ for (int i = 0; i < ss->totfaces; i++) {
+ ss->filter_cache->prev_face_set[i] = ss->face_sets[i];
+ }
+ ss->filter_cache->new_face_set = SCULPT_face_set_next_available_get(ss);
+ }
+ else {
+ ss->filter_cache->prev_mask = MEM_callocN(sizeof(float) * vertex_count, "prev mask");
+ for (int i = 0; i < vertex_count; i++) {
+ ss->filter_cache->prev_mask[i] = SCULPT_vertex_mask_get(ss, i);
+ }
+ }
+
+ ss->filter_cache->mask_update_last_it = 1;
+ ss->filter_cache->mask_update_current_it = 1;
+ ss->filter_cache->mask_update_it[SCULPT_active_vertex_get(ss)] = 0;
+
+ copy_v3_v3(ss->filter_cache->mask_expand_initial_co, SCULPT_active_vertex_co_get(ss));
+
+ SculptFloodFill flood;
+ SCULPT_floodfill_init(ss, &flood);
+ SCULPT_floodfill_add_active(sd, ob, ss, &flood, FLT_MAX);
+
+ MaskExpandFloodFillData fdata = {
+ .use_normals = use_normals,
+ .edge_sensitivity = RNA_int_get(op->ptr, "edge_sensitivity"),
+ };
+ SCULPT_active_vertex_normal_get(ss, fdata.original_normal);
+ SCULPT_floodfill_execute(ss, &flood, mask_expand_floodfill_cb, &fdata);
+ SCULPT_floodfill_free(&flood);
+
+ if (use_normals) {
+ for (int repeat = 0; repeat < 2; repeat++) {
+ for (int i = 0; i < vertex_count; i++) {
+ float avg = 0.0f;
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, i, ni) {
+ avg += ss->filter_cache->normal_factor[ni.index];
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ ss->filter_cache->normal_factor[i] = avg / ni.size;
+ }
+ }
+
+ MEM_SAFE_FREE(ss->filter_cache->edge_factor);
+ }
+
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .nodes = ss->filter_cache->nodes,
+ .mask_expand_update_it = 0,
+ .mask_expand_use_normals = RNA_boolean_get(op->ptr, "use_normals"),
+ .mask_expand_invert_mask = RNA_boolean_get(op->ptr, "invert"),
+ .mask_expand_keep_prev_mask = RNA_boolean_get(op->ptr, "keep_previous_mask"),
+ .mask_expand_create_face_set = RNA_boolean_get(op->ptr, "create_face_set"),
+ };
+ PBVHParallelSettings settings;
+ BKE_pbvh_parallel_range_settings(
+ &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode);
+ BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, sculpt_expand_task_cb, &settings);
+
+ const char *status_str = TIP_(
+ "Move the mouse to expand the mask from the active vertex. LMB: confirm mask, ESC/RMB: "
+ "cancel");
+ ED_workspace_status_text(C, status_str);
+
+ SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK);
+ WM_event_add_modal_handler(C, op);
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void SCULPT_OT_mask_expand(wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Mask Expand";
+ ot->idname = "SCULPT_OT_mask_expand";
+ ot->description = "Expands a mask from the initial active vertex under the cursor";
+
+ /* API callbacks. */
+ ot->invoke = sculpt_mask_expand_invoke;
+ ot->modal = sculpt_mask_expand_modal;
+ ot->cancel = sculpt_mask_expand_cancel;
+ ot->poll = SCULPT_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ ot->prop = RNA_def_boolean(ot->srna, "invert", true, "Invert", "Invert the new mask");
+ ot->prop = RNA_def_boolean(
+ ot->srna, "use_cursor", true, "Use Cursor", "Expand the mask to the cursor position");
+ ot->prop = RNA_def_boolean(ot->srna,
+ "update_pivot",
+ true,
+ "Update Pivot Position",
+ "Set the pivot position to the mask border after creating the mask");
+ ot->prop = RNA_def_int(ot->srna, "smooth_iterations", 2, 0, 10, "Smooth iterations", "", 0, 10);
+ ot->prop = RNA_def_int(ot->srna, "mask_speed", 5, 1, 10, "Mask speed", "", 1, 10);
+
+ ot->prop = RNA_def_boolean(ot->srna,
+ "use_normals",
+ true,
+ "Use Normals",
+ "Generate the mask using the normals and curvature of the model");
+ ot->prop = RNA_def_boolean(ot->srna,
+ "keep_previous_mask",
+ false,
+ "Keep Previous Mask",
+ "Generate the new mask on top of the current one");
+ ot->prop = RNA_def_int(ot->srna,
+ "edge_sensitivity",
+ 300,
+ 0,
+ 2000,
+ "Edge Detection Sensitivity",
+ "Sensitivity for expanding the mask across sculpted sharp edges when "
+ "using normals to generate the mask",
+ 0,
+ 2000);
+ ot->prop = RNA_def_boolean(ot->srna,
+ "create_face_set",
+ false,
+ "Expand Face Mask",
+ "Expand a new Face Mask instead of the sculpt mask");
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c b/source/blender/editors/sculpt_paint/sculpt_smooth.c
new file mode 100644
index 00000000000..de3211abe08
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c
@@ -0,0 +1,598 @@
+/*
+ * 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) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_hash.h"
+#include "BLI_math.h"
+#include "BLI_task.h"
+
+#include "DNA_brush_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_context.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_object.h"
+#include "BKE_paint.h"
+#include "BKE_pbvh.h"
+#include "BKE_scene.h"
+
+#include "DEG_depsgraph.h"
+
+#include "WM_api.h"
+#include "WM_message.h"
+#include "WM_toolsystem.h"
+#include "WM_types.h"
+
+#include "ED_object.h"
+#include "ED_screen.h"
+#include "ED_sculpt.h"
+#include "paint_intern.h"
+#include "sculpt_intern.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "bmesh.h"
+
+#include <math.h>
+#include <stdlib.h>
+
+/* For the smooth brush, uses the neighboring vertices around vert to calculate
+ * a smoothed location for vert. Skips corner vertices (used by only one
+ * polygon). */
+void SCULPT_neighbor_average(SculptSession *ss, float avg[3], uint vert)
+{
+ const MeshElemMap *vert_map = &ss->pmap[vert];
+ const MVert *mvert = ss->mvert;
+ float(*deform_co)[3] = ss->deform_cos;
+
+ /* Don't modify corner vertices. */
+ if (vert_map->count > 1) {
+ int total = 0;
+
+ zero_v3(avg);
+
+ for (int i = 0; i < vert_map->count; i++) {
+ const MPoly *p = &ss->mpoly[vert_map->indices[i]];
+ uint f_adj_v[2];
+
+ if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) {
+ for (int j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) {
+ if (vert_map->count != 2 || ss->pmap[f_adj_v[j]].count <= 2) {
+ add_v3_v3(avg, deform_co ? deform_co[f_adj_v[j]] : mvert[f_adj_v[j]].co);
+
+ total++;
+ }
+ }
+ }
+ }
+
+ if (total > 0) {
+ mul_v3_fl(avg, 1.0f / total);
+ return;
+ }
+ }
+
+ copy_v3_v3(avg, deform_co ? deform_co[vert] : mvert[vert].co);
+}
+
+/* Same logic as neighbor_average(), but for bmesh rather than mesh. */
+void SCULPT_bmesh_neighbor_average(float avg[3], BMVert *v)
+{
+ /* logic for 3 or more is identical. */
+ const int vfcount = BM_vert_face_count_at_most(v, 3);
+
+ /* Don't modify corner vertices. */
+ if (vfcount > 1) {
+ BMIter liter;
+ BMLoop *l;
+ int total = 0;
+
+ zero_v3(avg);
+
+ BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
+ const BMVert *adj_v[2] = {l->prev->v, l->next->v};
+
+ for (int i = 0; i < ARRAY_SIZE(adj_v); i++) {
+ const BMVert *v_other = adj_v[i];
+ if (vfcount != 2 || BM_vert_face_count_at_most(v_other, 2) <= 2) {
+ add_v3_v3(avg, v_other->co);
+ total++;
+ }
+ }
+ }
+
+ if (total > 0) {
+ mul_v3_fl(avg, 1.0f / total);
+ return;
+ }
+ }
+
+ copy_v3_v3(avg, v->co);
+}
+
+/* For bmesh: Average surrounding verts based on an orthogonality measure.
+ * Naturally converges to a quad-like structure. */
+void SCULPT_bmesh_four_neighbor_average(float avg[3], float direction[3], BMVert *v)
+{
+
+ float avg_co[3] = {0.0f, 0.0f, 0.0f};
+ float tot_co = 0.0f;
+
+ BMIter eiter;
+ BMEdge *e;
+
+ BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
+ if (BM_edge_is_boundary(e)) {
+ copy_v3_v3(avg, v->co);
+ return;
+ }
+ BMVert *v_other = (e->v1 == v) ? e->v2 : e->v1;
+ float vec[3];
+ sub_v3_v3v3(vec, v_other->co, v->co);
+ madd_v3_v3fl(vec, v->no, -dot_v3v3(vec, v->no));
+ normalize_v3(vec);
+
+ /* fac is a measure of how orthogonal or parallel the edge is
+ * relative to the direction. */
+ float fac = dot_v3v3(vec, direction);
+ fac = fac * fac - 0.5f;
+ fac *= fac;
+ madd_v3_v3fl(avg_co, v_other->co, fac);
+ tot_co += fac;
+ }
+
+ /* In case vert has no Edge s. */
+ if (tot_co > 0.0f) {
+ mul_v3_v3fl(avg, avg_co, 1.0f / tot_co);
+
+ /* Preserve volume. */
+ float vec[3];
+ sub_v3_v3(avg, v->co);
+ mul_v3_v3fl(vec, v->no, dot_v3v3(avg, v->no));
+ sub_v3_v3(avg, vec);
+ add_v3_v3(avg, v->co);
+ }
+ else {
+ zero_v3(avg);
+ }
+}
+
+/* Generic functions for laplacian smoothing. These functions do not take boundary vertices into
+ * account. */
+
+void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], int index)
+{
+ float avg[3] = {0.0f, 0.0f, 0.0f};
+ int total = 0;
+
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, index, ni) {
+ add_v3_v3(avg, SCULPT_vertex_co_get(ss, ni.index));
+ total++;
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+
+ if (total > 0) {
+ mul_v3_v3fl(result, avg, 1.0f / (float)total);
+ }
+ else {
+ copy_v3_v3(result, SCULPT_vertex_co_get(ss, index));
+ }
+}
+
+float SCULPT_neighbor_mask_average(SculptSession *ss, int index)
+{
+ float avg = 0.0f;
+ int total = 0;
+
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, index, ni) {
+ avg += SCULPT_vertex_mask_get(ss, ni.index);
+ total++;
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+
+ if (total > 0) {
+ return avg / (float)total;
+ }
+ else {
+ return SCULPT_vertex_mask_get(ss, index);
+ }
+}
+
+static void do_smooth_brush_mesh_task_cb_ex(void *__restrict userdata,
+ const int n,
+ const TaskParallelTLS *__restrict tls)
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ Sculpt *sd = data->sd;
+ const Brush *brush = data->brush;
+ const bool smooth_mask = data->smooth_mask;
+ float bstrength = data->strength;
+
+ PBVHVertexIter vd;
+
+ CLAMP(bstrength, 0.0f, 1.0f);
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
+ ss, &test, data->brush->falloff_shape);
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ const float fade = bstrength * SCULPT_brush_strength_factor(
+ ss,
+ brush,
+ vd.co,
+ sqrtf(test.dist),
+ vd.no,
+ vd.fno,
+ smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f),
+ vd.index,
+ tls->thread_id);
+ if (smooth_mask) {
+ float val = SCULPT_neighbor_mask_average(ss, vd.vert_indices[vd.i]) - *vd.mask;
+ val *= fade * bstrength;
+ *vd.mask += val;
+ CLAMP(*vd.mask, 0.0f, 1.0f);
+ }
+ else {
+ float avg[3], val[3];
+
+ SCULPT_neighbor_average(ss, avg, vd.vert_indices[vd.i]);
+ sub_v3_v3v3(val, avg, vd.co);
+
+ madd_v3_v3v3fl(val, vd.co, val, fade);
+
+ SCULPT_clip(sd, ss, vd.co, val);
+ }
+
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void do_smooth_brush_bmesh_task_cb_ex(void *__restrict userdata,
+ const int n,
+ const TaskParallelTLS *__restrict tls)
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ Sculpt *sd = data->sd;
+ const Brush *brush = data->brush;
+ const bool smooth_mask = data->smooth_mask;
+ float bstrength = data->strength;
+
+ PBVHVertexIter vd;
+
+ CLAMP(bstrength, 0.0f, 1.0f);
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
+ ss, &test, data->brush->falloff_shape);
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ const float fade = bstrength * SCULPT_brush_strength_factor(ss,
+ brush,
+ vd.co,
+ sqrtf(test.dist),
+ vd.no,
+ vd.fno,
+ smooth_mask ? 0.0f : *vd.mask,
+ vd.index,
+ tls->thread_id);
+ if (smooth_mask) {
+ float val = SCULPT_neighbor_mask_average(ss, vd.vert_indices[vd.i]) - *vd.mask;
+ val *= fade * bstrength;
+ *vd.mask += val;
+ CLAMP(*vd.mask, 0.0f, 1.0f);
+ }
+ else {
+ float avg[3], val[3];
+
+ SCULPT_bmesh_neighbor_average(avg, vd.bm_vert);
+ sub_v3_v3v3(val, avg, vd.co);
+
+ madd_v3_v3v3fl(val, vd.co, val, fade);
+
+ SCULPT_clip(sd, ss, vd.co, val);
+ }
+
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata,
+ const int n,
+ const TaskParallelTLS *__restrict tls)
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ Sculpt *sd = data->sd;
+ const Brush *brush = data->brush;
+ const bool smooth_mask = data->smooth_mask;
+ float bstrength = data->strength;
+
+ PBVHVertexIter vd;
+
+ CLAMP(bstrength, 0.0f, 1.0f);
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
+ ss, &test, data->brush->falloff_shape);
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ const float fade = bstrength * SCULPT_brush_strength_factor(
+ ss,
+ brush,
+ vd.co,
+ sqrtf(test.dist),
+ vd.no,
+ vd.fno,
+ smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f),
+ vd.index,
+ tls->thread_id);
+ if (smooth_mask) {
+ float val = SCULPT_neighbor_mask_average(ss, vd.index) - *vd.mask;
+ val *= fade * bstrength;
+ *vd.mask += val;
+ CLAMP(*vd.mask, 0.0f, 1.0f);
+ }
+ else {
+ float avg[3], val[3];
+ SCULPT_neighbor_coords_average(ss, avg, vd.index);
+ sub_v3_v3v3(val, avg, vd.co);
+ madd_v3_v3v3fl(val, vd.co, val, fade);
+ SCULPT_clip(sd, ss, vd.co, val);
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+void SCULPT_smooth(Sculpt *sd,
+ Object *ob,
+ PBVHNode **nodes,
+ const int totnode,
+ float bstrength,
+ const bool smooth_mask)
+{
+ SculptSession *ss = ob->sculpt;
+ Brush *brush = BKE_paint_brush(&sd->paint);
+
+ const int max_iterations = 4;
+ const float fract = 1.0f / max_iterations;
+ PBVHType type = BKE_pbvh_type(ss->pbvh);
+ int iteration, count;
+ float last;
+
+ CLAMP(bstrength, 0.0f, 1.0f);
+
+ count = (int)(bstrength * max_iterations);
+ last = max_iterations * (bstrength - count * fract);
+
+ if (type == PBVH_FACES && !ss->pmap) {
+ BLI_assert(!"sculpt smooth: pmap missing");
+ return;
+ }
+
+ for (iteration = 0; iteration <= count; iteration++) {
+ const float strength = (iteration != count) ? 1.0f : last;
+
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .brush = brush,
+ .nodes = nodes,
+ .smooth_mask = smooth_mask,
+ .strength = strength,
+ };
+
+ PBVHParallelSettings settings;
+ BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+
+ switch (type) {
+ case PBVH_GRIDS:
+ BKE_pbvh_parallel_range(0, totnode, &data, do_smooth_brush_multires_task_cb_ex, &settings);
+ break;
+ case PBVH_FACES:
+ BKE_pbvh_parallel_range(0, totnode, &data, do_smooth_brush_mesh_task_cb_ex, &settings);
+ break;
+ case PBVH_BMESH:
+ BKE_pbvh_parallel_range(0, totnode, &data, do_smooth_brush_bmesh_task_cb_ex, &settings);
+ break;
+ }
+ }
+}
+
+void SCULPT_do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
+{
+ SculptSession *ss = ob->sculpt;
+ SCULPT_smooth(sd, ob, nodes, totnode, ss->cache->bstrength, false);
+}
+
+/* HC Smooth Algorithm. */
+/* From: Improved Laplacian Smoothing of Noisy Surface Meshes */
+
+void SCULPT_surface_smooth_laplacian_step(SculptSession *ss,
+ float *disp,
+ const float co[3],
+ float (*laplacian_disp)[3],
+ const int v_index,
+ const float origco[3],
+ const float alpha)
+{
+ float laplacian_smooth_co[3];
+ float weigthed_o[3], weigthed_q[3], d[3];
+ SCULPT_neighbor_coords_average(ss, laplacian_smooth_co, v_index);
+
+ mul_v3_v3fl(weigthed_o, origco, alpha);
+ mul_v3_v3fl(weigthed_q, co, 1.0f - alpha);
+ add_v3_v3v3(d, weigthed_o, weigthed_q);
+ sub_v3_v3v3(laplacian_disp[v_index], laplacian_smooth_co, d);
+
+ sub_v3_v3v3(disp, laplacian_smooth_co, co);
+}
+
+void SCULPT_surface_smooth_displace_step(SculptSession *ss,
+ float *co,
+ float (*laplacian_disp)[3],
+ const int v_index,
+ const float beta,
+ const float fade)
+{
+ float b_avg[3] = {0.0f, 0.0f, 0.0f};
+ float b_current_vertex[3];
+ int total = 0;
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, v_index, ni) {
+ add_v3_v3(b_avg, laplacian_disp[ni.index]);
+ total++;
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ if (total > 0) {
+ mul_v3_v3fl(b_current_vertex, b_avg, (1.0f - beta) / (float)total);
+ madd_v3_v3fl(b_current_vertex, laplacian_disp[v_index], beta);
+ mul_v3_fl(b_current_vertex, clamp_f(fade, 0.0f, 1.0f));
+ sub_v3_v3(co, b_current_vertex);
+ }
+}
+
+static void SCULPT_do_surface_smooth_brush_laplacian_task_cb_ex(
+ void *__restrict userdata, const int n, const TaskParallelTLS *__restrict tls)
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ const Brush *brush = data->brush;
+ const float bstrength = ss->cache->bstrength;
+ float alpha = brush->surface_smooth_shape_preservation;
+
+ PBVHVertexIter vd;
+ SculptOrigVertData orig_data;
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
+ ss, &test, data->brush->falloff_shape);
+
+ SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]);
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ SCULPT_orig_vert_data_update(&orig_data, &vd);
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ const float fade =
+ bstrength *
+ SCULPT_brush_strength_factor(
+ ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, 0.0f, vd.index, tls->thread_id);
+
+ float disp[3];
+ SCULPT_surface_smooth_laplacian_step(ss,
+ disp,
+ vd.co,
+ ss->cache->surface_smooth_laplacian_disp,
+ vd.index,
+ orig_data.co,
+ alpha);
+ madd_v3_v3fl(vd.co, disp, clamp_f(fade, 0.0f, 1.0f));
+ }
+ BKE_pbvh_vertex_iter_end;
+ }
+}
+
+static void SCULPT_do_surface_smooth_brush_displace_task_cb_ex(
+ void *__restrict userdata, const int n, const TaskParallelTLS *__restrict tls)
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ const Brush *brush = data->brush;
+ const float bstrength = ss->cache->bstrength;
+ const float beta = brush->surface_smooth_current_vertex;
+
+ PBVHVertexIter vd;
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
+ ss, &test, data->brush->falloff_shape);
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ const float fade =
+ bstrength *
+ SCULPT_brush_strength_factor(
+ ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, 0.0f, vd.index, tls->thread_id);
+ SCULPT_surface_smooth_displace_step(
+ ss, vd.co, ss->cache->surface_smooth_laplacian_disp, vd.index, beta, fade);
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+void SCULPT_do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
+{
+ Brush *brush = BKE_paint_brush(&sd->paint);
+ SculptSession *ss = ob->sculpt;
+
+ if (ss->cache->first_time && ss->cache->mirror_symmetry_pass == 0 &&
+ ss->cache->radial_symmetry_pass == 0) {
+ BLI_assert(ss->cache->surface_smooth_laplacian_disp == NULL);
+ ss->cache->surface_smooth_laplacian_disp = MEM_callocN(
+ SCULPT_vertex_count_get(ss) * 3 * sizeof(float), "HC smooth laplacian b");
+ }
+
+ /* Threaded loop over nodes. */
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .brush = brush,
+ .nodes = nodes,
+ };
+
+ PBVHParallelSettings settings;
+ BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ for (int i = 0; i < brush->surface_smooth_iterations; i++) {
+ BKE_pbvh_parallel_range(
+ 0, totnode, &data, SCULPT_do_surface_smooth_brush_laplacian_task_cb_ex, &settings);
+ BKE_pbvh_parallel_range(
+ 0, totnode, &data, SCULPT_do_surface_smooth_brush_displace_task_cb_ex, &settings);
+ }
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.c b/source/blender/editors/sculpt_paint/sculpt_transform.c
new file mode 100644
index 00000000000..c7cbb6672a4
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/sculpt_transform.c
@@ -0,0 +1,381 @@
+/*
+ * 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) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_task.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_context.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_object.h"
+#include "BKE_paint.h"
+#include "BKE_pbvh.h"
+#include "BKE_scene.h"
+
+#include "DEG_depsgraph.h"
+
+#include "WM_api.h"
+#include "WM_message.h"
+#include "WM_toolsystem.h"
+#include "WM_types.h"
+
+#include "ED_object.h"
+#include "ED_screen.h"
+#include "ED_sculpt.h"
+#include "paint_intern.h"
+#include "sculpt_intern.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "bmesh.h"
+
+#include <math.h>
+#include <stdlib.h>
+
+void ED_sculpt_init_transform(struct bContext *C)
+{
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+
+ copy_v3_v3(ss->init_pivot_pos, ss->pivot_pos);
+ copy_v4_v4(ss->init_pivot_rot, ss->pivot_rot);
+
+ SCULPT_undo_push_begin("Transform");
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false);
+
+ ss->pivot_rot[3] = 1.0f;
+
+ SCULPT_vertex_random_access_init(ss);
+ SCULPT_filter_cache_init(ob, sd);
+}
+
+static void sculpt_transform_task_cb(void *__restrict userdata,
+ const int i,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ PBVHNode *node = data->nodes[i];
+
+ SculptOrigVertData orig_data;
+ SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[i]);
+
+ PBVHVertexIter vd;
+
+ SCULPT_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS);
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
+ {
+ SCULPT_orig_vert_data_update(&orig_data, &vd);
+ float transformed_co[3], orig_co[3], disp[3];
+ float fade = vd.mask ? *vd.mask : 0.0f;
+ copy_v3_v3(orig_co, orig_data.co);
+ char symm_area = SCULPT_get_vertex_symm_area(orig_co);
+
+ copy_v3_v3(transformed_co, orig_co);
+ mul_m4_v3(data->transform_mats[(int)symm_area], transformed_co);
+ sub_v3_v3v3(disp, transformed_co, orig_co);
+ mul_v3_fl(disp, 1.0f - fade);
+
+ add_v3_v3v3(vd.co, orig_co, disp);
+
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+
+ BKE_pbvh_node_mark_update(node);
+}
+
+void ED_sculpt_update_modal_transform(struct bContext *C)
+{
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+
+ SCULPT_vertex_random_access_init(ss);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false);
+
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .nodes = ss->filter_cache->nodes,
+ };
+
+ float final_pivot_pos[3], d_t[3], d_r[4];
+ float t_mat[4][4], r_mat[4][4], s_mat[4][4], pivot_mat[4][4], pivot_imat[4][4],
+ transform_mat[4][4];
+
+ copy_v3_v3(final_pivot_pos, ss->pivot_pos);
+ for (int i = 0; i < PAINT_SYMM_AREAS; i++) {
+ ePaintSymmetryAreas v_symm = i;
+
+ copy_v3_v3(final_pivot_pos, ss->pivot_pos);
+
+ unit_m4(pivot_mat);
+
+ unit_m4(t_mat);
+ unit_m4(r_mat);
+ unit_m4(s_mat);
+
+ /* Translation matrix. */
+ sub_v3_v3v3(d_t, ss->pivot_pos, ss->init_pivot_pos);
+ SCULPT_flip_v3_by_symm_area(d_t, symm, v_symm, ss->init_pivot_pos);
+ translate_m4(t_mat, d_t[0], d_t[1], d_t[2]);
+
+ /* Rotation matrix. */
+ sub_qt_qtqt(d_r, ss->pivot_rot, ss->init_pivot_rot);
+ normalize_qt(d_r);
+ SCULPT_flip_quat_by_symm_area(d_r, symm, v_symm, ss->init_pivot_pos);
+ quat_to_mat4(r_mat, d_r);
+
+ /* Scale matrix. */
+ size_to_mat4(s_mat, ss->pivot_scale);
+
+ /* Pivot matrix. */
+ SCULPT_flip_v3_by_symm_area(final_pivot_pos, symm, v_symm, ss->init_pivot_pos);
+ translate_m4(pivot_mat, final_pivot_pos[0], final_pivot_pos[1], final_pivot_pos[2]);
+ invert_m4_m4(pivot_imat, pivot_mat);
+
+ /* Final transform matrix. */
+ mul_m4_m4m4(transform_mat, r_mat, t_mat);
+ mul_m4_m4m4(transform_mat, transform_mat, s_mat);
+ mul_m4_m4m4(data.transform_mats[i], transform_mat, pivot_imat);
+ mul_m4_m4m4(data.transform_mats[i], pivot_mat, data.transform_mats[i]);
+ }
+
+ PBVHParallelSettings settings;
+ BKE_pbvh_parallel_range_settings(
+ &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode);
+ BKE_pbvh_parallel_range(
+ 0, ss->filter_cache->totnode, &data, sculpt_transform_task_cb, &settings);
+
+ if (ss->deform_modifiers_active || ss->shapekey_active) {
+ SCULPT_flush_stroke_deform(sd, ob, true);
+ }
+
+ SCULPT_flush_update_step(C, SCULPT_UPDATE_COORDS);
+}
+
+void ED_sculpt_end_transform(struct bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ if (ss->filter_cache) {
+ SCULPT_filter_cache_free(ss);
+ }
+ /* Force undo push to happen even inside transform operator, since the sculpt
+ * undo system works separate from regular undo and this is require to properly
+ * finish an undo step also when cancelling. */
+ const bool use_nested_undo = true;
+ SCULPT_undo_push_end_ex(use_nested_undo);
+ SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_COORDS);
+}
+
+typedef enum eSculptPivotPositionModes {
+ SCULPT_PIVOT_POSITION_ORIGIN = 0,
+ SCULPT_PIVOT_POSITION_UNMASKED = 1,
+ SCULPT_PIVOT_POSITION_MASK_BORDER = 2,
+ SCULPT_PIVOT_POSITION_ACTIVE_VERTEX = 3,
+ SCULPT_PIVOT_POSITION_CURSOR_SURFACE = 4,
+} eSculptPivotPositionModes;
+
+static EnumPropertyItem prop_sculpt_pivot_position_types[] = {
+ {SCULPT_PIVOT_POSITION_ORIGIN,
+ "ORIGIN",
+ 0,
+ "Origin",
+ "Sets the pivot to the origin of the sculpt"},
+ {SCULPT_PIVOT_POSITION_UNMASKED,
+ "UNMASKED",
+ 0,
+ "Unmasked",
+ "Sets the pivot position to the average position of the unmasked vertices"},
+ {SCULPT_PIVOT_POSITION_MASK_BORDER,
+ "BORDER",
+ 0,
+ "Mask border",
+ "Sets the pivot position to the center of the border of the mask"},
+ {SCULPT_PIVOT_POSITION_ACTIVE_VERTEX,
+ "ACTIVE",
+ 0,
+ "Active vertex",
+ "Sets the pivot position to the active vertex position"},
+ {SCULPT_PIVOT_POSITION_CURSOR_SURFACE,
+ "SURFACE",
+ 0,
+ "Surface",
+ "Sets the pivot position to the surface under the cursor"},
+ {0, NULL, 0, NULL, NULL},
+};
+
+static int sculpt_set_pivot_position_exec(bContext *C, wmOperator *op)
+{
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ ARegion *region = CTX_wm_region(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+ const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+
+ int mode = RNA_enum_get(op->ptr, "mode");
+
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true);
+
+ /* Pivot to center. */
+ if (mode == SCULPT_PIVOT_POSITION_ORIGIN) {
+ zero_v3(ss->pivot_pos);
+ }
+ /* Pivot to active vertex. */
+ else if (mode == SCULPT_PIVOT_POSITION_ACTIVE_VERTEX) {
+ copy_v3_v3(ss->pivot_pos, SCULPT_active_vertex_co_get(ss));
+ }
+ /* Pivot to raycast surface. */
+ else if (mode == SCULPT_PIVOT_POSITION_CURSOR_SURFACE) {
+ float stroke_location[3];
+ float mouse[2];
+ mouse[0] = RNA_float_get(op->ptr, "mouse_x");
+ mouse[1] = RNA_float_get(op->ptr, "mouse_y");
+ if (SCULPT_stroke_get_location(C, stroke_location, mouse)) {
+ copy_v3_v3(ss->pivot_pos, stroke_location);
+ }
+ }
+ else {
+ PBVHNode **nodes;
+ int totnode;
+ BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
+
+ float avg[3];
+ int total = 0;
+ zero_v3(avg);
+
+ /* Pivot to unmasked. */
+ if (mode == SCULPT_PIVOT_POSITION_UNMASKED) {
+ for (int n = 0; n < totnode; n++) {
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ const float mask = (vd.mask) ? *vd.mask : 0.0f;
+ if (mask < 1.0f) {
+ if (SCULPT_check_vertex_pivot_symmetry(vd.co, ss->pivot_pos, symm)) {
+ add_v3_v3(avg, vd.co);
+ total++;
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+ }
+ }
+ /* Pivot to mask border. */
+ else if (mode == SCULPT_PIVOT_POSITION_MASK_BORDER) {
+ const float threshold = 0.2f;
+
+ for (int n = 0; n < totnode; n++) {
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ const float mask = (vd.mask) ? *vd.mask : 0.0f;
+ if (mask < (0.5f + threshold) && mask > (0.5f - threshold)) {
+ if (SCULPT_check_vertex_pivot_symmetry(vd.co, ss->pivot_pos, symm)) {
+ add_v3_v3(avg, vd.co);
+ total++;
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+ }
+ }
+
+ if (total > 0) {
+ mul_v3_fl(avg, 1.0f / total);
+ copy_v3_v3(ss->pivot_pos, avg);
+ }
+
+ MEM_SAFE_FREE(nodes);
+ }
+
+ ED_region_tag_redraw(region);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+
+ return OPERATOR_FINISHED;
+}
+
+static int sculpt_set_pivot_position_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ RNA_float_set(op->ptr, "mouse_x", event->mval[0]);
+ RNA_float_set(op->ptr, "mouse_y", event->mval[1]);
+ return sculpt_set_pivot_position_exec(C, op);
+}
+
+void SCULPT_OT_set_pivot_position(wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Set Pivot Position";
+ ot->idname = "SCULPT_OT_set_pivot_position";
+ ot->description = "Sets the sculpt transform pivot position";
+
+ /* API callbacks. */
+ ot->invoke = sculpt_set_pivot_position_invoke;
+ ot->exec = sculpt_set_pivot_position_exec;
+ ot->poll = SCULPT_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ RNA_def_enum(ot->srna,
+ "mode",
+ prop_sculpt_pivot_position_types,
+ SCULPT_PIVOT_POSITION_UNMASKED,
+ "Mode",
+ "");
+
+ RNA_def_float(ot->srna,
+ "mouse_x",
+ 0.0f,
+ 0.0f,
+ FLT_MAX,
+ "Mouse Position X",
+ "Position of the mouse used for \"Surface\" mode",
+ 0.0f,
+ 10000.0f);
+ RNA_def_float(ot->srna,
+ "mouse_y",
+ 0.0f,
+ 0.0f,
+ FLT_MAX,
+ "Mouse Position Y",
+ "Position of the mouse used for \"Surface\" mode",
+ 0.0f,
+ 10000.0f);
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index af404c64fb0..340f7191b95 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -48,6 +48,7 @@
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_multires.h"
+#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_scene.h"
#include "BKE_subdiv_ccg.h"
@@ -66,6 +67,45 @@
#include "bmesh.h"
#include "sculpt_intern.h"
+/* Implementation of undo system for objects in sculpt mode.
+ *
+ * Each undo step in sculpt mode consists of list of nodes, each node contains:
+ * - Node type
+ * - Data for this type.
+ *
+ * Node type used for undo depends on specific operation and active sculpt mode
+ * ("regular" or dynamic topology).
+ *
+ * Regular sculpt brushes will use COORDS, HIDDEN or MASK nodes. These nodes are
+ * created for every BVH node which is affected by the brush. The undo push for
+ * the node happens BEFORE modifications. This makes the operation undo to work
+ * in the following way: for every node in the undo step swap happens between
+ * node in the undo stack and the corresponding value in the BVH. This is how
+ * redo is possible after undo.
+ *
+ * The COORDS, HIDDEN or MASK type of nodes contains arrays of the corresponding
+ * values.
+ *
+ * Operations like Symmetrize are using GEOMETRY type of nodes which pushes the
+ * entire state of the mesh to the undo stack. This node contains all CustomData
+ * layers.
+ *
+ * The tricky aspect of this undo node type is that it stores mesh before and
+ * after modification. This allows the undo system to both undo and redo the
+ * symmetrize operation within the pre-modified-push of other node type
+ * behavior, but it uses more memory that it seems it should be.
+ *
+ * The dynamic topology undo nodes are handled somewhat separately from all
+ * other ones and the idea there is to store log of operations: which vertices
+ * and faces have been added or removed.
+ *
+ * Begin of dynamic topology sculpting mode have own node type. It contains an
+ * entire copy of mesh since just enabling the dynamic topology mode already
+ * does modifications on it.
+ *
+ * End of dynamic topology and symmetrize in this mode are handled in a special
+ * manner as well. */
+
typedef struct UndoSculpt {
ListBase nodes;
@@ -335,8 +375,11 @@ static bool sculpt_undo_restore_face_sets(bContext *C, SculptUndoNode *unode)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
- SculptSession *ss = ob->sculpt;
- memcpy(ss->face_sets, unode->face_sets, ss->totpoly * sizeof(int));
+ Mesh *me = BKE_object_get_original_mesh(ob);
+ int *face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS);
+ for (int i = 0; i < me->totpoly; i++) {
+ face_sets[i] = unode->face_sets[i];
+ }
return false;
}
@@ -379,7 +422,7 @@ static void sculpt_undo_bmesh_restore_generic(bContext *C,
}
}
else {
- sculpt_pbvh_clear(ob);
+ SCULPT_pbvh_clear(ob);
}
}
@@ -389,7 +432,7 @@ static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode)
SculptSession *ss = ob->sculpt;
Mesh *me = ob->data;
- sculpt_pbvh_clear(ob);
+ SCULPT_pbvh_clear(ob);
/* Create empty BMesh and enable logging. */
ss->bm = BM_mesh_create(&bm_mesh_allocsize_default,
@@ -397,7 +440,7 @@ static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode)
.use_toolflags = false,
}));
BM_data_layer_add(ss->bm, &ss->bm->vdata, CD_PAINT_MASK);
- sculpt_dyntopo_node_layers_add(ss);
+ SCULPT_dyntopo_node_layers_add(ss);
me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY;
/* Restore the BMLog using saved entries. */
@@ -410,7 +453,7 @@ static void sculpt_undo_bmesh_restore_begin(bContext *C,
SculptSession *ss)
{
if (unode->applied) {
- sculpt_dynamic_topology_disable(C, unode);
+ SCULPT_dynamic_topology_disable(C, unode);
unode->applied = false;
}
else {
@@ -438,35 +481,87 @@ static void sculpt_undo_bmesh_restore_end(bContext *C,
}
else {
/* Disable dynamic topology sculpting. */
- sculpt_dynamic_topology_disable(C, NULL);
+ SCULPT_dynamic_topology_disable(C, NULL);
unode->applied = true;
}
}
-static void sculpt_undo_geometry_restore(SculptUndoNode *unode, Object *ob)
+static void sculpt_undo_geometry_store_data(SculptUndoNodeGeometry *geometry, Object *object)
{
- Mesh *me;
- sculpt_pbvh_clear(ob);
- me = ob->data;
- CustomData_free(&me->vdata, me->totvert);
- CustomData_free(&me->edata, me->totedge);
- CustomData_free(&me->fdata, me->totface);
- CustomData_free(&me->ldata, me->totloop);
- CustomData_free(&me->pdata, me->totpoly);
- me->totvert = unode->geom_totvert;
- me->totedge = unode->geom_totedge;
- me->totloop = unode->geom_totloop;
- me->totpoly = unode->geom_totpoly;
- me->totface = 0;
+ Mesh *mesh = object->data;
+
+ BLI_assert(!geometry->is_initialized);
+ geometry->is_initialized = true;
+
+ CustomData_copy(&mesh->vdata, &geometry->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, mesh->totvert);
+ CustomData_copy(&mesh->edata, &geometry->edata, CD_MASK_MESH.emask, CD_DUPLICATE, mesh->totedge);
+ CustomData_copy(&mesh->ldata, &geometry->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, mesh->totloop);
+ CustomData_copy(&mesh->pdata, &geometry->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, mesh->totpoly);
+
+ geometry->totvert = mesh->totvert;
+ geometry->totedge = mesh->totedge;
+ geometry->totloop = mesh->totloop;
+ geometry->totpoly = mesh->totpoly;
+}
+
+static void sculpt_undo_geometry_restore_data(SculptUndoNodeGeometry *geometry, Object *object)
+{
+ Mesh *mesh = object->data;
+
+ BLI_assert(geometry->is_initialized);
+
+ CustomData_free(&mesh->vdata, mesh->totvert);
+ CustomData_free(&mesh->edata, mesh->totedge);
+ CustomData_free(&mesh->fdata, mesh->totface);
+ CustomData_free(&mesh->ldata, mesh->totloop);
+ CustomData_free(&mesh->pdata, mesh->totpoly);
+
+ mesh->totvert = geometry->totvert;
+ mesh->totedge = geometry->totedge;
+ mesh->totloop = geometry->totloop;
+ mesh->totpoly = geometry->totpoly;
+ mesh->totface = 0;
+
CustomData_copy(
- &unode->geom_vdata, &me->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, unode->geom_totvert);
+ &geometry->vdata, &mesh->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, geometry->totvert);
CustomData_copy(
- &unode->geom_edata, &me->edata, CD_MASK_MESH.emask, CD_DUPLICATE, unode->geom_totedge);
+ &geometry->edata, &mesh->edata, CD_MASK_MESH.emask, CD_DUPLICATE, geometry->totedge);
CustomData_copy(
- &unode->geom_ldata, &me->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, unode->geom_totloop);
+ &geometry->ldata, &mesh->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, geometry->totloop);
CustomData_copy(
- &unode->geom_pdata, &me->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, unode->geom_totpoly);
- BKE_mesh_update_customdata_pointers(me, false);
+ &geometry->pdata, &mesh->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, geometry->totpoly);
+
+ BKE_mesh_update_customdata_pointers(mesh, false);
+}
+
+static void sculpt_undo_geometry_free_data(SculptUndoNodeGeometry *geometry)
+{
+ if (geometry->totvert) {
+ CustomData_free(&geometry->vdata, geometry->totvert);
+ }
+ if (geometry->totedge) {
+ CustomData_free(&geometry->edata, geometry->totedge);
+ }
+ if (geometry->totloop) {
+ CustomData_free(&geometry->ldata, geometry->totloop);
+ }
+ if (geometry->totpoly) {
+ CustomData_free(&geometry->pdata, geometry->totpoly);
+ }
+}
+
+static void sculpt_undo_geometry_restore(SculptUndoNode *unode, Object *object)
+{
+ SCULPT_pbvh_clear(object);
+
+ if (unode->applied) {
+ sculpt_undo_geometry_restore_data(&unode->geometry_modified, object);
+ unode->applied = false;
+ }
+ else {
+ sculpt_undo_geometry_restore_data(&unode->geometry_original, object);
+ unode->applied = true;
+ }
}
/* Handle all dynamic-topology updates
@@ -527,22 +622,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
if (lb->first) {
unode = lb->first;
- if (unode->type == SCULPT_UNDO_GEOMETRY) {
- if (unode->applied) {
- sculpt_undo_geometry_restore(unode->next, ob);
- unode->next->applied = true;
- unode->applied = false;
- }
- else {
- sculpt_undo_geometry_restore(unode, ob);
- unode->next->applied = false;
- unode->applied = true;
- }
- BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask);
- return;
- }
- else if (unode->type == SCULPT_UNDO_FACE_SETS) {
-
+ if (unode->type == SCULPT_UNDO_FACE_SETS) {
sculpt_undo_restore_face_sets(C, unode);
rebuild = true;
@@ -551,14 +631,15 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, need_mask);
SCULPT_visibility_sync_all_face_sets_to_vertices(ss);
+
BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility);
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
BKE_mesh_flush_hidden_from_verts(ob->data);
}
+ DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) {
- DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
@@ -567,10 +648,18 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
}
}
- BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask);
+ if (lb->first != NULL) {
+ /* Only do early object update for edits if first node needs this.
+ * Undo steps like geometry does not need object to be updated before they run and will
+ * ensure object is updated after the node is handled. */
+ const SculptUndoNode *first_unode = (const SculptUndoNode *)lb->first;
+ if (first_unode->type != SCULPT_UNDO_GEOMETRY) {
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask);
+ }
- if (lb->first && sculpt_undo_bmesh_restore(C, lb->first, ob, ss)) {
- return;
+ if (sculpt_undo_bmesh_restore(C, lb->first, ob, ss)) {
+ return;
+ }
}
char *undo_modified_grids = NULL;
@@ -619,22 +708,32 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
case SCULPT_UNDO_FACE_SETS:
break;
+ case SCULPT_UNDO_GEOMETRY:
+ sculpt_undo_geometry_restore(unode, ob);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask);
+ break;
+
case SCULPT_UNDO_DYNTOPO_BEGIN:
case SCULPT_UNDO_DYNTOPO_END:
case SCULPT_UNDO_DYNTOPO_SYMMETRIZE:
BLI_assert(!"Dynamic topology should've already been handled");
break;
- case SCULPT_UNDO_GEOMETRY:
- break;
}
}
if (use_multires_undo) {
- int max_grid;
- unode = lb->first;
- max_grid = unode->maxgrid;
- undo_modified_grids = MEM_callocN(sizeof(char) * max_grid, "undo_grids");
for (unode = lb->first; unode; unode = unode->next) {
+ if (!STREQ(unode->idname, ob->id.name)) {
+ continue;
+ }
+ if (unode->maxgrid == 0) {
+ continue;
+ }
+
+ if (undo_modified_grids == NULL) {
+ undo_modified_grids = MEM_callocN(sizeof(char) * unode->maxgrid, "undo_grids");
+ }
+
for (int i = 0; i < unode->totgrid; i++) {
undo_modified_grids[unode->grids[i]] = 1;
}
@@ -737,18 +836,8 @@ static void sculpt_undo_free_list(ListBase *lb)
BM_log_entry_drop(unode->bm_entry);
}
- if (unode->geom_totvert) {
- CustomData_free(&unode->geom_vdata, unode->geom_totvert);
- }
- if (unode->geom_totedge) {
- CustomData_free(&unode->geom_edata, unode->geom_totedge);
- }
- if (unode->geom_totloop) {
- CustomData_free(&unode->geom_ldata, unode->geom_totloop);
- }
- if (unode->geom_totpoly) {
- CustomData_free(&unode->geom_pdata, unode->geom_totpoly);
- }
+ sculpt_undo_geometry_free_data(&unode->geometry_original);
+ sculpt_undo_geometry_free_data(&unode->geometry_modified);
if (unode->face_sets) {
MEM_freeN(unode->face_sets);
@@ -816,16 +905,43 @@ static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, SculptUndoNode *unode
}
}
+/* Allocate node and initialize its default fields specific for the given undo type.
+ * Will also add the node to the list in the undo step. */
+static SculptUndoNode *sculpt_undo_alloc_node_type(Object *object, SculptUndoType type)
+{
+ SculptUndoNode *unode = MEM_callocN(sizeof(SculptUndoNode), "SculptUndoNode");
+ BLI_strncpy(unode->idname, object->id.name, sizeof(unode->idname));
+ unode->type = type;
+
+ UndoSculpt *usculpt = sculpt_undo_get_nodes();
+ BLI_addtail(&usculpt->nodes, unode);
+
+ return unode;
+}
+
+/* Will return first existing undo node of the given type.
+ * If such node does not exist will allocate node of this type, register it in the undo step and
+ * return it. */
+static SculptUndoNode *sculpt_undo_find_or_alloc_node_type(Object *object, SculptUndoType type)
+{
+ UndoSculpt *usculpt = sculpt_undo_get_nodes();
+
+ LISTBASE_FOREACH (SculptUndoNode *, unode, &usculpt->nodes) {
+ if (unode->type == type) {
+ return unode;
+ }
+ }
+
+ return sculpt_undo_alloc_node_type(object, type);
+}
+
static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, SculptUndoType type)
{
UndoSculpt *usculpt = sculpt_undo_get_nodes();
- SculptUndoNode *unode;
SculptSession *ss = ob->sculpt;
int totvert, allvert, totgrid, maxgrid, gridsize, *grids;
- unode = MEM_callocN(sizeof(SculptUndoNode), "SculptUndoNode");
- BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname));
- unode->type = type;
+ SculptUndoNode *unode = sculpt_undo_alloc_node_type(ob, type);
unode->node = node;
if (node) {
@@ -872,8 +988,6 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
break;
}
- BLI_addtail(&usculpt->nodes, unode);
-
if (maxgrid) {
/* Multires. */
unode->maxgrid = maxgrid;
@@ -950,32 +1064,24 @@ static void sculpt_undo_store_mask(Object *ob, SculptUndoNode *unode)
BKE_pbvh_vertex_iter_end;
}
-static SculptUndoNode *sculpt_undo_geometry_push(Object *ob, SculptUndoType type)
+static SculptUndoNodeGeometry *sculpt_undo_geometry_get(SculptUndoNode *unode)
{
- UndoSculpt *usculpt = sculpt_undo_get_nodes();
- Mesh *me = ob->data;
- bool applied;
-
- SculptUndoNode *unode = usculpt->nodes.first;
- /* Store the original mesh in the first node, modifications in the second. */
- applied = unode != NULL;
+ if (!unode->geometry_original.is_initialized) {
+ return &unode->geometry_original;
+ }
- unode = MEM_callocN(sizeof(*unode), __func__);
+ BLI_assert(!unode->geometry_modified.is_initialized);
- BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname));
- unode->type = type;
- unode->applied = applied;
+ return &unode->geometry_modified;
+}
- CustomData_copy(&me->vdata, &unode->geom_vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, me->totvert);
- CustomData_copy(&me->edata, &unode->geom_edata, CD_MASK_MESH.emask, CD_DUPLICATE, me->totedge);
- CustomData_copy(&me->ldata, &unode->geom_ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, me->totloop);
- CustomData_copy(&me->pdata, &unode->geom_pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, me->totpoly);
- unode->geom_totvert = me->totvert;
- unode->geom_totedge = me->totedge;
- unode->geom_totloop = me->totloop;
- unode->geom_totpoly = me->totpoly;
+static SculptUndoNode *sculpt_undo_geometry_push(Object *object, SculptUndoType type)
+{
+ SculptUndoNode *unode = sculpt_undo_find_or_alloc_node_type(object, type);
+ unode->applied = false;
- BLI_addtail(&usculpt->nodes, unode);
+ SculptUndoNodeGeometry *geometry = sculpt_undo_geometry_get(unode);
+ sculpt_undo_geometry_store_data(geometry, object);
return unode;
}
@@ -983,8 +1089,6 @@ static SculptUndoNode *sculpt_undo_geometry_push(Object *ob, SculptUndoType type
static SculptUndoNode *sculpt_undo_face_sets_push(Object *ob, SculptUndoType type)
{
UndoSculpt *usculpt = sculpt_undo_get_nodes();
- SculptSession *ss = ob->sculpt;
-
SculptUndoNode *unode = usculpt->nodes.first;
unode = MEM_callocN(sizeof(*unode), __func__);
@@ -993,8 +1097,14 @@ static SculptUndoNode *sculpt_undo_face_sets_push(Object *ob, SculptUndoType typ
unode->type = type;
unode->applied = true;
- unode->face_sets = MEM_callocN(ss->totpoly * sizeof(int), "sculpt face sets");
- memcpy(unode->face_sets, ss->face_sets, ss->totpoly * sizeof(int));
+ Mesh *me = BKE_object_get_original_mesh(ob);
+
+ unode->face_sets = MEM_callocN(me->totpoly * sizeof(int), "sculpt face sets");
+
+ int *face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS);
+ for (int i = 0; i < me->totpoly; i++) {
+ unode->face_sets[i] = face_sets[i];
+ }
BLI_addtail(&usculpt->nodes, unode);
@@ -1021,25 +1131,13 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob, PBVHNode *node, Sculpt
BM_log_before_all_removed(ss->bm, ss->bm_log);
}
else if (type == SCULPT_UNDO_DYNTOPO_BEGIN) {
- Mesh *me = ob->data;
-
/* Store a copy of the mesh's current vertices, loops, and
* polys. A full copy like this is needed because entering
* dynamic-topology immediately does topological edits
* (converting polys to triangles) that the BMLog can't
* fully restore from. */
- CustomData_copy(
- &me->vdata, &unode->geom_vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, me->totvert);
- CustomData_copy(
- &me->edata, &unode->geom_edata, CD_MASK_MESH.emask, CD_DUPLICATE, me->totedge);
- CustomData_copy(
- &me->ldata, &unode->geom_ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, me->totloop);
- CustomData_copy(
- &me->pdata, &unode->geom_pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, me->totpoly);
- unode->geom_totvert = me->totvert;
- unode->geom_totedge = me->totedge;
- unode->geom_totloop = me->totloop;
- unode->geom_totpoly = me->totpoly;
+ SculptUndoNodeGeometry *geometry = &unode->geometry_bmesh_enter;
+ sculpt_undo_geometry_store_data(geometry, ob);
unode->bm_entry = BM_log_entry_add(ss->bm_log);
BM_log_all_added(ss->bm, ss->bm_log);
@@ -1192,6 +1290,11 @@ void SCULPT_undo_push_begin(const char *name)
void SCULPT_undo_push_end(void)
{
+ SCULPT_undo_push_end_ex(false);
+}
+
+void SCULPT_undo_push_end_ex(const bool use_nested_undo)
+{
UndoSculpt *usculpt = sculpt_undo_get_nodes();
SculptUndoNode *unode;
@@ -1209,7 +1312,7 @@ void SCULPT_undo_push_end(void)
/* We could remove this and enforce all callers run in an operator using 'OPTYPE_UNDO'. */
wmWindowManager *wm = G_MAIN->wm.first;
- if (wm->op_undo_depth == 0) {
+ if (wm->op_undo_depth == 0 || use_nested_undo) {
UndoStack *ustack = ED_undo_stack_get();
BKE_undosys_step_push(ustack, NULL, NULL);
WM_file_tag_modified();
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index f364c174f0f..0a5814be626 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -70,8 +70,8 @@ typedef struct UvAdjacencyElement {
} UvAdjacencyElement;
typedef struct UvEdge {
- unsigned int uv1;
- unsigned int uv2;
+ uint uv1;
+ uint uv2;
/* general use flag
* (Used to check if edge is boundary here, and propagates to adjacency elements) */
char flag;
@@ -315,7 +315,7 @@ static void uv_sculpt_stroke_apply(bContext *C,
Scene *scene = CTX_data_scene(C);
ARegion *region = CTX_wm_region(C);
BMEditMesh *em = BKE_editmesh_from_object(obedit);
- unsigned int tool;
+ uint tool;
UvSculptData *sculptdata = (UvSculptData *)op->customdata;
SpaceImage *sima;
int invert;
@@ -386,7 +386,7 @@ static void uv_sculpt_stroke_apply(bContext *C,
* Smooth Tool
*/
else if (tool == UV_SCULPT_TOOL_RELAX) {
- unsigned int method = toolsettings->uv_relax_method;
+ uint method = toolsettings->uv_relax_method;
if (method == UV_SCULPT_TOOL_RELAX_HC) {
HC_relaxation_iteration_uv(em, sculptdata, co, alpha, radius, aspectRatio);
}
@@ -464,7 +464,7 @@ static int uv_element_offset_from_face_get(
return element - map->buf;
}
-static unsigned int uv_edge_hash(const void *key)
+static uint uv_edge_hash(const void *key)
{
const UvEdge *edge = key;
return (BLI_ghashutil_uinthash(edge->uv2) + BLI_ghashutil_uinthash(edge->uv1));
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index e6e36309fec..81ac8a16d8a 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -206,7 +206,7 @@ static void SOUND_OT_open_mono(wmOperatorType *ot)
static void sound_update_animation_flags(Scene *scene);
-static int sound_update_animation_flags_cb(Sequence *seq, void *user_data)
+static int sound_update_animation_flags_fn(Sequence *seq, void *user_data)
{
struct FCurve *fcu;
Scene *scene = (Scene *)user_data;
@@ -258,7 +258,7 @@ static void sound_update_animation_flags(Scene *scene)
scene->id.tag |= LIB_TAG_DOIT;
SEQ_BEGIN (scene->ed, seq) {
- BKE_sequencer_recursive_apply(seq, sound_update_animation_flags_cb, scene);
+ BKE_sequencer_recursive_apply(seq, sound_update_animation_flags_fn, scene);
}
SEQ_END;
diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c
index 6c2cee4042b..a356962946e 100644
--- a/source/blender/editors/space_action/action_data.c
+++ b/source/blender/editors/space_action/action_data.c
@@ -42,7 +42,6 @@
#include "RNA_enum_types.h"
#include "BKE_action.h"
-#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_fcurve.h"
#include "BKE_key.h"
@@ -100,7 +99,7 @@ AnimData *ED_actedit_animdata_from_context(bContext *C)
/* Create new action */
static bAction *action_create_new(bContext *C, bAction *oldact)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
bAction *action;
/* create action - the way to do this depends on whether we've got an
@@ -124,8 +123,8 @@ static bAction *action_create_new(bContext *C, bAction *oldact)
id_us_min(&action->id);
/* set ID-Root type */
- if (sa->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
+ if (area->spacetype == SPACE_ACTION) {
+ SpaceAction *saction = (SpaceAction *)area->spacedata.first;
if (saction->mode == SACTCONT_SHAPEKEY) {
action->idroot = ID_KE;
@@ -550,7 +549,7 @@ void ACTION_OT_stash_and_create(wmOperatorType *ot)
void ED_animedit_unlink_action(
bContext *C, ID *id, AnimData *adt, bAction *act, ReportList *reports, bool force_delete)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* If the old action only has a single user (that it's about to lose),
* warn user about it
@@ -609,13 +608,13 @@ void ED_animedit_unlink_action(
BKE_nla_tweakmode_exit(adt);
/* Flush this to the Action Editor (if that's where this change was initiated) */
- if (sa->spacetype == SPACE_ACTION) {
+ if (area->spacetype == SPACE_ACTION) {
actedit_change_action(C, NULL);
}
}
else {
/* Unlink normally - Setting it to NULL should be enough to get the old one unlinked */
- if (sa->spacetype == SPACE_ACTION) {
+ if (area->spacetype == SPACE_ACTION) {
/* clear action editor -> action */
actedit_change_action(C, NULL);
}
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 75eeb125609..52287b07b28 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -81,7 +81,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
v2d->tot.ymin = -height;
/* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */
- UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY);
+ UI_view2d_sync(NULL, ac->area, v2d, V2D_LOCK_COPY);
/* loop through channels, and set up drawing depending on their type */
{ /* first pass: just the standard GL-drawing for backdrop + text */
@@ -141,9 +141,9 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
bDopeSheet *ads = &saction->ads;
AnimData *adt = NULL;
- unsigned char col1[4], col2[4];
- unsigned char col1a[4], col2a[4];
- unsigned char col1b[4], col2b[4];
+ uchar col1[4], col2[4];
+ uchar col1a[4], col2a[4];
+ uchar col1b[4], col2b[4];
const bool show_group_colors = !(saction->flag & SACTION_NODRAWGCOLORS);
@@ -212,10 +212,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
bActionGroup *agrp = ale->data;
if (show_group_colors && agrp->customCol) {
if (sel) {
- immUniformColor3ubvAlpha((unsigned char *)agrp->cs.select, col1a[3]);
+ immUniformColor3ubvAlpha((uchar *)agrp->cs.select, col1a[3]);
}
else {
- immUniformColor3ubvAlpha((unsigned char *)agrp->cs.solid, col2a[3]);
+ immUniformColor3ubvAlpha((uchar *)agrp->cs.solid, col2a[3]);
}
}
else {
@@ -226,8 +226,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
case ANIMTYPE_FCURVE: {
FCurve *fcu = ale->data;
if (show_group_colors && fcu->grp && fcu->grp->customCol) {
- immUniformColor3ubvAlpha((unsigned char *)fcu->grp->cs.active,
- sel ? col1[3] : col2[3]);
+ immUniformColor3ubvAlpha((uchar *)fcu->grp->cs.active, sel ? col1[3] : col2[3]);
}
else {
immUniformColor4ubv(sel ? col1 : col2);
@@ -243,8 +242,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
immRectf(pos, v2d->cur.xmin, ymin, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymax);
}
else if (ac->datatype == ANIMCONT_GPENCIL) {
- unsigned char *color;
- unsigned char gpl_col[4];
+ uchar *color;
+ uchar gpl_col[4];
if ((show_group_colors) && (ale->type == ANIMTYPE_GPLAYER)) {
bGPDlayer *gpl = (bGPDlayer *)ale->data;
rgb_float_to_uchar(gpl_col, gpl->color);
@@ -266,7 +265,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
else if (ac->datatype == ANIMCONT_MASK) {
/* TODO --- this is a copy of gpencil */
/* frames less than one get less saturated background */
- unsigned char *color = sel ? col1 : col2;
+ uchar *color = sel ? col1 : col2;
immUniformColor4ubv(color);
immRectf(pos, 0.0f, ymin, v2d->cur.xmin, ymax);
@@ -562,7 +561,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
/* Iterate over pointcaches on the active object, and draw each one's range. */
float y_offset = 0.0f;
const float cache_draw_height = 4.0f * UI_DPI_FAC * U.pixelsize;
- for (PTCacheID *pid = pidlist.first; pid; pid = pid->next) {
+ LISTBASE_FOREACH (PTCacheID *, pid, &pidlist) {
if (timeline_cache_is_hidden_by_setting(saction, pid)) {
continue;
}
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 173c2f1b5dc..26c29d6cbe7 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -437,7 +437,7 @@ static void box_select_elem(
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, ac->datatype);
- for (bAnimListElem *ale2 = anim_data.first; ale2; ale2 = ale2->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale2, &anim_data) {
box_select_elem(sel_data, ale2, xmin, xmax, true);
}
@@ -675,7 +675,7 @@ static void region_select_elem(RegionSelectData *sel_data, bAnimListElem *ale, b
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, ac->datatype);
- for (bAnimListElem *ale2 = anim_data.first; ale2; ale2 = ale2->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale2, &anim_data) {
region_select_elem(sel_data, ale2, true);
}
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 64c81797bb4..e92ea906237 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -60,7 +60,7 @@
/* ******************** default callbacks for action space ***************** */
-static SpaceLink *action_new(const ScrArea *sa, const Scene *scene)
+static SpaceLink *action_new(const ScrArea *area, const Scene *scene)
{
SpaceAction *saction;
ARegion *region;
@@ -113,7 +113,7 @@ static SpaceLink *action_new(const ScrArea *sa, const Scene *scene)
region->regiontype = RGN_TYPE_WINDOW;
region->v2d.tot.xmin = (float)(SFRA - 10);
- region->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
+ region->v2d.tot.ymin = (float)(-area->winy) / 3.0f;
region->v2d.tot.xmax = (float)(EFRA + 10);
region->v2d.tot.ymax = 0.0f;
@@ -144,9 +144,9 @@ static void action_free(SpaceLink *UNUSED(sl))
}
/* spacetype; init callback */
-static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
+static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *area)
{
- SpaceAction *saction = sa->spacedata.first;
+ SpaceAction *saction = area->spacedata.first;
saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
}
@@ -301,7 +301,7 @@ static void action_header_region_draw(const bContext *C, ARegion *region)
}
static void action_channel_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -355,12 +355,12 @@ static void saction_channel_region_message_subscribe(const struct bContext *UNUS
struct WorkSpace *UNUSED(workspace),
struct Scene *UNUSED(scene),
struct bScreen *screen,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus)
{
PointerRNA ptr;
- RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, sa->spacedata.first, &ptr);
+ RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, area->spacedata.first, &ptr);
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
@@ -397,7 +397,7 @@ static void saction_channel_region_message_subscribe(const struct bContext *UNUS
}
static void action_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -459,12 +459,12 @@ static void saction_main_region_message_subscribe(const struct bContext *C,
struct WorkSpace *workspace,
struct Scene *scene,
struct bScreen *screen,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus)
{
PointerRNA ptr;
- RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, sa->spacedata.first, &ptr);
+ RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, area->spacedata.first, &ptr);
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
@@ -497,16 +497,16 @@ static void saction_main_region_message_subscribe(const struct bContext *C,
}
/* Now run the general "channels region" one - since channels and main should be in sync */
- saction_channel_region_message_subscribe(C, workspace, scene, screen, sa, region, mbus);
+ saction_channel_region_message_subscribe(C, workspace, scene, screen, area, region, mbus);
}
/* editor level listener */
static void action_listener(wmWindow *UNUSED(win),
- ScrArea *sa,
+ ScrArea *area,
wmNotifier *wmn,
Scene *UNUSED(scene))
{
- SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)area->spacedata.first;
/* context changes */
switch (wmn->category) {
@@ -514,11 +514,11 @@ static void action_listener(wmWindow *UNUSED(win),
/* only handle these events in GPencil mode for performance considerations */
if (saction->mode == SACTCONT_GPENCIL) {
if (wmn->action == NA_EDITED) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
else if (wmn->action == NA_SELECTED) {
saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
}
break;
@@ -526,7 +526,7 @@ static void action_listener(wmWindow *UNUSED(win),
/* for NLA tweakmode enter/exit, need complete refresh */
if (wmn->data == ND_NLA_ACTCHANGE) {
saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
/* autocolor only really needs to change when channels are added/removed,
* or previously hidden stuff appears
@@ -534,14 +534,14 @@ static void action_listener(wmWindow *UNUSED(win),
*/
else if (((wmn->data == ND_KEYFRAME) && ELEM(wmn->action, NA_ADDED, NA_REMOVED)) ||
((wmn->data == ND_ANIMCHAN) && (wmn->action != NA_SELECTED))) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
/* for simple edits to the curve data though (or just plain selections),
* a simple redraw should work
* (see T39851 for an example of how this can go wrong)
*/
else {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
case NC_SCENE:
@@ -549,7 +549,7 @@ static void action_listener(wmWindow *UNUSED(win),
case ND_SEQUENCER:
if (wmn->action == NA_SELECTED) {
saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
break;
case ND_OB_ACTIVE:
@@ -557,13 +557,13 @@ static void action_listener(wmWindow *UNUSED(win),
/* Selection changed, so force refresh to flush
* (needs flag set to do syncing). */
saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
case ND_RENDER_RESULT:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
case ND_FRAME_RANGE:
- for (ARegion *region = sa->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
Scene *scene = wmn->reference;
region->v2d.tot.xmin = (float)(SFRA - 4);
@@ -575,7 +575,7 @@ static void action_listener(wmWindow *UNUSED(win),
default:
if (saction->mode != SACTCONT_TIMELINE) {
/* Just redrawing the view will do. */
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
}
@@ -586,7 +586,7 @@ static void action_listener(wmWindow *UNUSED(win),
* (needs flag set to do syncing). */
case ND_BONE_ACTIVE:
saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
case ND_TRANSFORM:
/* moving object shouldn't need to redraw action */
@@ -596,12 +596,12 @@ static void action_listener(wmWindow *UNUSED(win),
case ND_PARTICLE:
/* only needed in timeline mode */
if (saction->mode == SACTCONT_TIMELINE) {
- ED_area_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ ED_area_tag_refresh(area);
+ ED_area_tag_redraw(area);
}
break;
default: /* just redrawing the view will do */
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
break;
@@ -609,11 +609,11 @@ static void action_listener(wmWindow *UNUSED(win),
if (saction->mode == SACTCONT_MASK) {
switch (wmn->data) {
case ND_DATA:
- ED_area_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ ED_area_tag_refresh(area);
+ ED_area_tag_redraw(area);
break;
default: /* just redrawing the view will do */
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
}
@@ -622,33 +622,33 @@ static void action_listener(wmWindow *UNUSED(win),
if (wmn->action == NA_SELECTED) {
/* selection changed, so force refresh to flush (needs flag set to do syncing) */
saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
break;
case NC_SPACE:
switch (wmn->data) {
case ND_SPACE_DOPESHEET:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
case ND_SPACE_TIME:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
case ND_SPACE_CHANGED:
saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
}
break;
case NC_WINDOW:
if (saction->runtime.flag & SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC) {
/* force redraw/refresh after undo/redo - [#28962] */
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
break;
case NC_WM:
switch (wmn->data) {
case ND_FILEREAD:
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
}
break;
@@ -656,12 +656,12 @@ static void action_listener(wmWindow *UNUSED(win),
}
static void action_header_region_listener(wmWindow *UNUSED(win),
- ScrArea *sa,
+ ScrArea *area,
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
{
- SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)area->spacedata.first;
/* context changes */
switch (wmn->category) {
@@ -733,7 +733,7 @@ static void action_buttons_area_draw(const bContext *C, ARegion *region)
}
static void action_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -769,9 +769,9 @@ static void action_region_listener(wmWindow *UNUSED(win),
}
}
-static void action_refresh(const bContext *C, ScrArea *sa)
+static void action_refresh(const bContext *C, ScrArea *area)
{
- SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)area->spacedata.first;
/* Update the state of the animchannels in response to changes from the data they represent
* NOTE: the temp flag is used to indicate when this needs to be done,
@@ -789,8 +789,8 @@ static void action_refresh(const bContext *C, ScrArea *sa)
* - Regions (such as header) need to be manually tagged for redraw too
* or else they don't update [#28962]
*/
- ED_area_tag_redraw(sa);
- for (region = sa->regionbase.first; region; region = region->next) {
+ ED_area_tag_redraw(area);
+ for (region = area->regionbase.first; region; region = region->next) {
ED_region_tag_redraw(region);
}
}
@@ -799,7 +799,7 @@ static void action_refresh(const bContext *C, ScrArea *sa)
// XXX re-sizing y-extents of tot should go here?
}
-static void action_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
+static void action_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
{
SpaceAction *sact = (SpaceAction *)slink;
@@ -820,15 +820,15 @@ static void action_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, I
* The previous non-timeline mode is stored so switching back to the
* dope-sheet doesn't always reset the sub-mode.
*/
-static int action_space_subtype_get(ScrArea *sa)
+static int action_space_subtype_get(ScrArea *area)
{
- SpaceAction *sact = sa->spacedata.first;
+ SpaceAction *sact = area->spacedata.first;
return sact->mode == SACTCONT_TIMELINE ? SACTCONT_TIMELINE : SACTCONT_DOPESHEET;
}
-static void action_space_subtype_set(ScrArea *sa, int value)
+static void action_space_subtype_set(ScrArea *area, int value)
{
- SpaceAction *sact = sa->spacedata.first;
+ SpaceAction *sact = area->spacedata.first;
if (value == SACTCONT_TIMELINE) {
if (sact->mode != SACTCONT_TIMELINE) {
sact->mode_prev = sact->mode;
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 44d64bd750a..f81aaeb0ee4 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -279,7 +279,7 @@ void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
void ED_spacetype_xxx(void);
/* allocate and init some vars */
-static SpaceLink *xxx_new(const ScrArea *UNUSED(sa), const Scene *UNUSED(scene))
+static SpaceLink *xxx_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
return NULL;
}
@@ -290,7 +290,7 @@ static void xxx_free(SpaceLink *UNUSED(sl))
}
/* spacetype; init callback for usage, should be redoable */
-static void xxx_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void xxx_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
/* link area to SpaceXXX struct */
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 2fd54db667b..c06c107d4a3 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -110,7 +110,7 @@ static void buttons_free(SpaceLink *sl)
}
/* spacetype; init callback */
-static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
@@ -219,7 +219,7 @@ static void buttons_main_region_layout(const bContext *C, ARegion *region)
}
static void buttons_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -274,11 +274,11 @@ static void buttons_header_region_message_subscribe(const bContext *UNUSED(C),
WorkSpace *UNUSED(workspace),
Scene *UNUSED(scene),
bScreen *UNUSED(screen),
- ScrArea *sa,
+ ScrArea *area,
ARegion *region,
struct wmMsgBus *mbus)
{
- SpaceProperties *sbuts = sa->spacedata.first;
+ SpaceProperties *sbuts = area->spacedata.first;
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
.user_data = region,
@@ -312,7 +312,7 @@ static void buttons_navigation_bar_region_init(wmWindowManager *wm, ARegion *reg
static void buttons_navigation_bar_region_draw(const bContext *C, ARegion *region)
{
- for (PanelType *pt = region->type->paneltypes.first; pt; pt = pt->next) {
+ LISTBASE_FOREACH (PanelType *, pt, &region->type->paneltypes) {
pt->flag |= PNL_LAYOUT_VERT_BAR;
}
@@ -326,7 +326,7 @@ static void buttons_navigation_bar_region_message_subscribe(const bContext *UNUS
WorkSpace *UNUSED(workspace),
Scene *UNUSED(scene),
bScreen *UNUSED(screen),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
struct wmMsgBus *mbus)
{
@@ -341,96 +341,96 @@ static void buttons_navigation_bar_region_message_subscribe(const bContext *UNUS
/* draw a certain button set only if properties area is currently
* showing that button set, to reduce unnecessary drawing. */
-static void buttons_area_redraw(ScrArea *sa, short buttons)
+static void buttons_area_redraw(ScrArea *area, short buttons)
{
- SpaceProperties *sbuts = sa->spacedata.first;
+ SpaceProperties *sbuts = area->spacedata.first;
/* if the area's current button set is equal to the one to redraw */
if (sbuts->mainb == buttons) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
}
/* reused! */
static void buttons_area_listener(wmWindow *UNUSED(win),
- ScrArea *sa,
+ ScrArea *area,
wmNotifier *wmn,
Scene *UNUSED(scene))
{
- SpaceProperties *sbuts = sa->spacedata.first;
+ SpaceProperties *sbuts = area->spacedata.first;
/* context changes */
switch (wmn->category) {
case NC_SCENE:
switch (wmn->data) {
case ND_RENDER_OPTIONS:
- buttons_area_redraw(sa, BCONTEXT_RENDER);
- buttons_area_redraw(sa, BCONTEXT_OUTPUT);
- buttons_area_redraw(sa, BCONTEXT_VIEW_LAYER);
+ buttons_area_redraw(area, BCONTEXT_RENDER);
+ buttons_area_redraw(area, BCONTEXT_OUTPUT);
+ buttons_area_redraw(area, BCONTEXT_VIEW_LAYER);
break;
case ND_WORLD:
- buttons_area_redraw(sa, BCONTEXT_WORLD);
+ buttons_area_redraw(area, BCONTEXT_WORLD);
sbuts->preview = 1;
break;
case ND_FRAME:
/* any buttons area can have animated properties so redraw all */
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
sbuts->preview = 1;
break;
case ND_OB_ACTIVE:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
sbuts->preview = 1;
break;
case ND_KEYINGSET:
- buttons_area_redraw(sa, BCONTEXT_SCENE);
+ buttons_area_redraw(area, BCONTEXT_SCENE);
break;
case ND_RENDER_RESULT:
break;
case ND_MODE:
case ND_LAYER:
default:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
break;
case NC_OBJECT:
switch (wmn->data) {
case ND_TRANSFORM:
- buttons_area_redraw(sa, BCONTEXT_OBJECT);
- buttons_area_redraw(sa, BCONTEXT_DATA); /* autotexpace flag */
+ buttons_area_redraw(area, BCONTEXT_OBJECT);
+ buttons_area_redraw(area, BCONTEXT_DATA); /* autotexpace flag */
break;
case ND_POSE:
case ND_BONE_ACTIVE:
case ND_BONE_SELECT:
- buttons_area_redraw(sa, BCONTEXT_BONE);
- buttons_area_redraw(sa, BCONTEXT_BONE_CONSTRAINT);
- buttons_area_redraw(sa, BCONTEXT_DATA);
+ buttons_area_redraw(area, BCONTEXT_BONE);
+ buttons_area_redraw(area, BCONTEXT_BONE_CONSTRAINT);
+ buttons_area_redraw(area, BCONTEXT_DATA);
break;
case ND_MODIFIER:
if (wmn->action == NA_RENAME) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
else {
- buttons_area_redraw(sa, BCONTEXT_MODIFIER);
+ buttons_area_redraw(area, BCONTEXT_MODIFIER);
}
- buttons_area_redraw(sa, BCONTEXT_PHYSICS);
+ buttons_area_redraw(area, BCONTEXT_PHYSICS);
break;
case ND_CONSTRAINT:
- buttons_area_redraw(sa, BCONTEXT_CONSTRAINT);
- buttons_area_redraw(sa, BCONTEXT_BONE_CONSTRAINT);
+ buttons_area_redraw(area, BCONTEXT_CONSTRAINT);
+ buttons_area_redraw(area, BCONTEXT_BONE_CONSTRAINT);
break;
case ND_PARTICLE:
if (wmn->action == NA_EDITED) {
- buttons_area_redraw(sa, BCONTEXT_PARTICLE);
+ buttons_area_redraw(area, BCONTEXT_PARTICLE);
}
sbuts->preview = 1;
break;
case ND_DRAW:
- buttons_area_redraw(sa, BCONTEXT_OBJECT);
- buttons_area_redraw(sa, BCONTEXT_DATA);
- buttons_area_redraw(sa, BCONTEXT_PHYSICS);
+ buttons_area_redraw(area, BCONTEXT_OBJECT);
+ buttons_area_redraw(area, BCONTEXT_DATA);
+ buttons_area_redraw(area, BCONTEXT_PHYSICS);
/* Needed to refresh context path when changing active particle system index. */
- buttons_area_redraw(sa, BCONTEXT_PARTICLE);
+ buttons_area_redraw(area, BCONTEXT_PARTICLE);
break;
case ND_SHADING:
case ND_SHADING_DRAW:
@@ -441,7 +441,7 @@ static void buttons_area_listener(wmWindow *UNUSED(win),
break;
default:
/* Not all object RNA props have a ND_ notifier (yet) */
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
break;
@@ -450,12 +450,12 @@ static void buttons_area_listener(wmWindow *UNUSED(win),
case ND_SELECT:
case ND_DATA:
case ND_VERTEX_GROUP:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
break;
case NC_MATERIAL:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
switch (wmn->data) {
case ND_SHADING:
case ND_SHADING_DRAW:
@@ -468,43 +468,43 @@ static void buttons_area_listener(wmWindow *UNUSED(win),
}
break;
case NC_WORLD:
- buttons_area_redraw(sa, BCONTEXT_WORLD);
+ buttons_area_redraw(area, BCONTEXT_WORLD);
sbuts->preview = 1;
break;
case NC_LAMP:
- buttons_area_redraw(sa, BCONTEXT_DATA);
+ buttons_area_redraw(area, BCONTEXT_DATA);
sbuts->preview = 1;
break;
case NC_GROUP:
- buttons_area_redraw(sa, BCONTEXT_OBJECT);
+ buttons_area_redraw(area, BCONTEXT_OBJECT);
break;
case NC_BRUSH:
- buttons_area_redraw(sa, BCONTEXT_TEXTURE);
- buttons_area_redraw(sa, BCONTEXT_TOOL);
+ buttons_area_redraw(area, BCONTEXT_TEXTURE);
+ buttons_area_redraw(area, BCONTEXT_TOOL);
sbuts->preview = 1;
break;
case NC_TEXTURE:
case NC_IMAGE:
if (wmn->action != NA_PAINTING) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
sbuts->preview = 1;
}
break;
case NC_SPACE:
if (wmn->data == ND_SPACE_PROPERTIES) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
case NC_ID:
if (wmn->action == NA_RENAME) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
case NC_ANIMATION:
switch (wmn->data) {
case ND_KEYFRAME:
if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
}
@@ -513,14 +513,14 @@ static void buttons_area_listener(wmWindow *UNUSED(win),
switch (wmn->data) {
case ND_DATA:
if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED, NA_SELECTED)) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
}
break;
case NC_NODE:
if (wmn->action == NA_SELECTED) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
/* new active node, update texture preview */
if (sbuts->mainb == BCONTEXT_TEXTURE) {
sbuts->preview = 1;
@@ -530,24 +530,24 @@ static void buttons_area_listener(wmWindow *UNUSED(win),
/* Listener for preview render, when doing an global undo. */
case NC_WM:
if (wmn->data == ND_UNDO) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
sbuts->preview = 1;
}
break;
#ifdef WITH_FREESTYLE
case NC_LINESTYLE:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
sbuts->preview = 1;
break;
#endif
}
if (wmn->data == ND_KEYS) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
}
-static void buttons_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
+static void buttons_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
{
SpaceProperties *sbuts = (SpaceProperties *)slink;
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index eba0f33d6cc..84ab5e6524b 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -68,7 +68,7 @@ static void track_channel_color(MovieTrackingTrack *track, float default_color[3
}
static void draw_keyframe_shape(
- float x, float y, bool sel, float alpha, unsigned int pos_id, unsigned int color_id)
+ float x, float y, bool sel, float alpha, uint pos_id, uint color_id)
{
float color[4] = {0.91f, 0.91f, 0.91f, alpha};
if (sel) {
@@ -79,7 +79,7 @@ static void draw_keyframe_shape(
immVertex2f(pos_id, x, y);
}
-static void clip_draw_dopesheet_background(ARegion *region, MovieClip *clip, unsigned int pos_id)
+static void clip_draw_dopesheet_background(ARegion *region, MovieClip *clip, uint pos_id)
{
View2D *v2d = &region->v2d;
MovieTracking *tracking = &clip->tracking;
@@ -292,7 +292,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *region, Scene *scene)
void clip_draw_dopesheet_channels(const bContext *C, ARegion *region)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceClip *sc = CTX_wm_space_clip(C);
View2D *v2d = &region->v2d;
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -316,7 +316,7 @@ void clip_draw_dopesheet_channels(const bContext *C, 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, sa, v2d, V2D_LOCK_COPY);
+ UI_view2d_sync(NULL, area, v2d, V2D_LOCK_COPY);
/* loop through channels, and set up drawing depending on their type
* first pass: just the standard GL-drawing for backdrop + text
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 2a6cf4d5a55..a1652ca0e88 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -66,8 +66,7 @@
/*********************** main area drawing *************************/
-static void draw_keyframe(
- int frame, int cfra, int sfra, float framelen, int width, unsigned int pos)
+static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int width, uint pos)
{
int height = (frame == cfra) ? 22 : 10;
int x = (frame - sfra) * framelen;
@@ -592,7 +591,7 @@ static void draw_marker_outline(SpaceClip *sc,
const float marker_pos[2],
int width,
int height,
- unsigned int position)
+ uint position)
{
int tiny = sc->flag & SC_SHOW_TINY_MARKER;
bool show_search = false;
@@ -895,7 +894,7 @@ static float get_shortest_pattern_side(MovieTrackingMarker *marker)
}
static void draw_marker_slide_square(
- float x, float y, float dx, float dy, int outline, const float px[2], unsigned int pos)
+ float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
{
float tdx, tdy;
@@ -911,7 +910,7 @@ static void draw_marker_slide_square(
}
static void draw_marker_slide_triangle(
- float x, float y, float dx, float dy, int outline, const float px[2], unsigned int pos)
+ float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
{
float tdx, tdy;
@@ -939,7 +938,7 @@ static void draw_marker_slide_zones(SpaceClip *sc,
int act,
int width,
int height,
- unsigned int pos)
+ uint pos)
{
float dx, dy, patdx, patdy, searchdx, searchdy;
int tiny = sc->flag & SC_SHOW_TINY_MARKER;
@@ -1056,7 +1055,7 @@ static void draw_marker_texts(SpaceClip *sc,
UI_FontThemeColor(fontid, TH_ACT_MARKER);
}
else {
- unsigned char color[4];
+ uchar color[4];
UI_GetThemeColorShade4ubv(TH_DIS_MARKER, 128, color);
BLF_color4ubv(fontid, color);
}
@@ -1191,7 +1190,7 @@ static void draw_plane_marker_image(Scene *scene,
ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
if (ibuf) {
- unsigned char *display_buffer;
+ uchar *display_buffer;
void *cache_handle;
if (image->flag & IMA_VIEW_AS_RENDER) {
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 6336f1bff3a..ffc50407917 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -37,6 +37,7 @@
#include "DNA_mask_types.h"
#include "BLI_fileops.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "BLI_task.h"
@@ -282,7 +283,7 @@ bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *region, int mval[2], flo
if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
const float *fp;
- unsigned char *cp;
+ uchar *cp;
int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
CLAMP(x, 0, ibuf->x - 1);
@@ -294,7 +295,7 @@ bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *region, int mval[2], flo
ret = true;
}
else if (ibuf->rect) {
- cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
+ cp = (uchar *)(ibuf->rect + y * ibuf->x + x);
rgb_uchar_to_float(r_col, cp);
IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace);
ret = true;
@@ -310,12 +311,12 @@ void ED_clip_update_frame(const Main *mainp, int cfra)
{
/* image window, compo node users */
for (wmWindowManager *wm = mainp->wm.first; wm; wm = wm->id.next) { /* only 1 wm */
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
bScreen *screen = WM_window_get_active_screen(win);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->spacetype == SPACE_CLIP) {
- SpaceClip *sc = sa->spacedata.first;
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ if (area->spacetype == SPACE_CLIP) {
+ SpaceClip *sc = area->spacedata.first;
sc->scopes.ok = false;
@@ -744,7 +745,7 @@ static bool check_prefetch_break(void)
}
/* read file for specified frame number to the memory */
-static unsigned char *prefetch_read_file_to_memory(
+static uchar *prefetch_read_file_to_memory(
MovieClip *clip, int current_frame, short render_size, short render_flag, size_t *r_size)
{
MovieClipUser user = {0};
@@ -766,7 +767,7 @@ static unsigned char *prefetch_read_file_to_memory(
return NULL;
}
- unsigned char *mem = MEM_mallocN(size, "movieclip prefetch memory file");
+ uchar *mem = MEM_mallocN(size, "movieclip prefetch memory file");
if (mem == NULL) {
close(file);
return NULL;
@@ -822,12 +823,12 @@ static int prefetch_find_uncached_frame(MovieClip *clip,
}
/* get memory buffer for first uncached frame within prefetch frame range */
-static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue,
- MovieClip *clip,
- size_t *r_size,
- int *r_current_frame)
+static uchar *prefetch_thread_next_frame(PrefetchQueue *queue,
+ MovieClip *clip,
+ size_t *r_size,
+ int *r_current_frame)
{
- unsigned char *mem = NULL;
+ uchar *mem = NULL;
BLI_spin_lock(&queue->spin);
if (!*queue->stop && !check_prefetch_break() &&
@@ -888,7 +889,7 @@ static void prefetch_task_func(TaskPool *__restrict pool, void *task_data, int U
{
PrefetchQueue *queue = (PrefetchQueue *)BLI_task_pool_userdata(pool);
MovieClip *clip = (MovieClip *)task_data;
- unsigned char *mem;
+ uchar *mem;
size_t size;
int current_frame;
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index 7f3d3f3d651..dc212741e6b 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -52,7 +52,7 @@ typedef struct TrackMotionCurveUserData {
MovieTrackingTrack *act_track;
bool sel;
float xscale, yscale, hsize;
- unsigned int pos;
+ uint pos;
} TrackMotionCurveUserData;
static void tracking_segment_point_cb(void *userdata,
@@ -159,7 +159,7 @@ static void tracking_segment_knot_cb(void *userdata,
}
}
-static void draw_tracks_motion_and_error_curves(View2D *v2d, SpaceClip *sc, unsigned int pos)
+static void draw_tracks_motion_and_error_curves(View2D *v2d, SpaceClip *sc, uint pos)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
@@ -215,7 +215,7 @@ static void draw_tracks_motion_and_error_curves(View2D *v2d, SpaceClip *sc, unsi
}
}
-static void draw_frame_curves(SpaceClip *sc, unsigned int pos)
+static void draw_frame_curves(SpaceClip *sc, uint pos)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h
index 4dc8d367f2b..27493bb5ccd 100644
--- a/source/blender/editors/space_clip/clip_intern.h
+++ b/source/blender/editors/space_clip/clip_intern.h
@@ -112,7 +112,7 @@ void CLIP_OT_cursor_set(struct wmOperatorType *ot);
void CLIP_OT_lock_selection_toggle(struct wmOperatorType *ot);
/* clip_toolbar.c */
-struct ARegion *ED_clip_has_properties_region(struct ScrArea *sa);
+struct ARegion *ED_clip_has_properties_region(struct ScrArea *area);
/* clip_utils.c */
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 4e5c6513695..48bc885405d 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -1313,12 +1313,12 @@ typedef struct ProxyThread {
int *build_undistort_sizes, build_undistort_count;
} ProxyThread;
-static unsigned char *proxy_thread_next_frame(ProxyQueue *queue,
- MovieClip *clip,
- size_t *r_size,
- int *r_cfra)
+static uchar *proxy_thread_next_frame(ProxyQueue *queue,
+ MovieClip *clip,
+ size_t *r_size,
+ int *r_cfra)
{
- unsigned char *mem = NULL;
+ uchar *mem = NULL;
BLI_spin_lock(&queue->spin);
if (!*queue->stop && queue->cfra <= queue->efra) {
@@ -1371,7 +1371,7 @@ static void proxy_task_func(TaskPool *__restrict pool, void *task_data, int UNUS
{
ProxyThread *data = (ProxyThread *)task_data;
ProxyQueue *queue = (ProxyQueue *)BLI_task_pool_userdata(pool);
- unsigned char *mem;
+ uchar *mem;
size_t size;
int cfra;
@@ -1533,7 +1533,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
wmJob *wm_job;
ProxyJob *pj;
Scene *scene = CTX_data_scene(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -1570,7 +1570,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
G.is_break = false;
WM_jobs_start(CTX_wm_manager(C), wm_job);
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c
index 1e3911863fc..b02f3fe16f6 100644
--- a/source/blender/editors/space_clip/clip_toolbar.c
+++ b/source/blender/editors/space_clip/clip_toolbar.c
@@ -53,17 +53,17 @@
/************************** properties ******************************/
-ARegion *ED_clip_has_properties_region(ScrArea *sa)
+ARegion *ED_clip_has_properties_region(ScrArea *area)
{
ARegion *region, *arnew;
- region = BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ region = BKE_area_find_region_type(area, RGN_TYPE_UI);
if (region) {
return region;
}
/* add subdiv level; after header */
- region = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+ region = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
/* is error! */
if (region == NULL) {
@@ -72,7 +72,7 @@ ARegion *ED_clip_has_properties_region(ScrArea *sa)
arnew = MEM_callocN(sizeof(ARegion), "clip properties region");
- BLI_insertlinkafter(&sa->regionbase, region, arnew);
+ BLI_insertlinkafter(&area->regionbase, region, arnew);
arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_RIGHT;
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 4b9c872ffce..a68e06951f7 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -71,7 +71,7 @@
#include "clip_intern.h" /* own include */
static void init_preview_region(const Scene *scene,
- const ScrArea *sa,
+ const ScrArea *area,
const SpaceClip *sc,
ARegion *region)
{
@@ -81,8 +81,8 @@ static void init_preview_region(const Scene *scene,
if (sc->view == SC_VIEW_DOPESHEET) {
region->v2d.tot.xmin = -10.0f;
- region->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
- region->v2d.tot.xmax = (float)(sa->winx);
+ region->v2d.tot.ymin = (float)(-area->winy) / 3.0f;
+ region->v2d.tot.xmax = (float)(area->winx);
region->v2d.tot.ymax = 0.0f;
region->v2d.cur = region->v2d.tot;
@@ -133,32 +133,32 @@ static void init_preview_region(const Scene *scene,
static void reinit_preview_region(const bContext *C, ARegion *region)
{
Scene *scene = CTX_data_scene(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceClip *sc = CTX_wm_space_clip(C);
if (sc->view == SC_VIEW_DOPESHEET) {
if ((region->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) == 0) {
- init_preview_region(scene, sa, sc, region);
+ init_preview_region(scene, area, sc, region);
}
}
else {
if (region->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) {
- init_preview_region(scene, sa, sc, region);
+ init_preview_region(scene, area, sc, region);
}
}
}
-static ARegion *ED_clip_has_preview_region(const bContext *C, ScrArea *sa)
+static ARegion *ED_clip_has_preview_region(const bContext *C, ScrArea *area)
{
ARegion *region, *arnew;
- region = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
+ region = BKE_area_find_region_type(area, RGN_TYPE_PREVIEW);
if (region) {
return region;
}
/* add subdiv level; after header */
- region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
/* is error! */
if (region == NULL) {
@@ -167,23 +167,23 @@ static ARegion *ED_clip_has_preview_region(const bContext *C, ScrArea *sa)
arnew = MEM_callocN(sizeof(ARegion), "clip preview region");
- BLI_insertlinkbefore(&sa->regionbase, region, arnew);
- init_preview_region(CTX_data_scene(C), sa, CTX_wm_space_clip(C), arnew);
+ BLI_insertlinkbefore(&area->regionbase, region, arnew);
+ init_preview_region(CTX_data_scene(C), area, CTX_wm_space_clip(C), arnew);
return arnew;
}
-static ARegion *ED_clip_has_channels_region(ScrArea *sa)
+static ARegion *ED_clip_has_channels_region(ScrArea *area)
{
ARegion *region, *arnew;
- region = BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS);
+ region = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS);
if (region) {
return region;
}
/* add subdiv level; after header */
- region = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
+ region = BKE_area_find_region_type(area, RGN_TYPE_PREVIEW);
/* is error! */
if (region == NULL) {
@@ -192,7 +192,7 @@ static ARegion *ED_clip_has_channels_region(ScrArea *sa)
arnew = MEM_callocN(sizeof(ARegion), "clip channels region");
- BLI_insertlinkbefore(&sa->regionbase, region, arnew);
+ BLI_insertlinkbefore(&area->regionbase, region, arnew);
arnew->regiontype = RGN_TYPE_CHANNELS;
arnew->alignment = RGN_ALIGN_LEFT;
@@ -202,9 +202,9 @@ static ARegion *ED_clip_has_channels_region(ScrArea *sa)
return arnew;
}
-static void clip_scopes_tag_refresh(ScrArea *sa)
+static void clip_scopes_tag_refresh(ScrArea *area)
{
- SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
+ SpaceClip *sc = (SpaceClip *)area->spacedata.first;
ARegion *region;
if (sc->mode != SC_MODE_TRACKING) {
@@ -212,7 +212,7 @@ static void clip_scopes_tag_refresh(ScrArea *sa)
}
/* only while properties are visible */
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_UI && region->flag & RGN_FLAG_HIDDEN) {
return;
}
@@ -221,24 +221,24 @@ static void clip_scopes_tag_refresh(ScrArea *sa)
sc->scopes.ok = false;
}
-static void clip_scopes_check_gpencil_change(ScrArea *sa)
+static void clip_scopes_check_gpencil_change(ScrArea *area)
{
- SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
+ SpaceClip *sc = (SpaceClip *)area->spacedata.first;
if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
- clip_scopes_tag_refresh(sa);
+ clip_scopes_tag_refresh(area);
}
}
-static void clip_area_sync_frame_from_scene(ScrArea *sa, Scene *scene)
+static void clip_area_sync_frame_from_scene(ScrArea *area, Scene *scene)
{
- SpaceClip *space_clip = (SpaceClip *)sa->spacedata.first;
+ SpaceClip *space_clip = (SpaceClip *)area->spacedata.first;
BKE_movieclip_user_set_frame(&space_clip->user, scene->r.cfra);
}
/* ******************** default callbacks for clip space ***************** */
-static SpaceLink *clip_new(const ScrArea *sa, const Scene *scene)
+static SpaceLink *clip_new(const ScrArea *area, const Scene *scene)
{
ARegion *region;
SpaceClip *sc;
@@ -287,7 +287,7 @@ static SpaceLink *clip_new(const ScrArea *sa, const Scene *scene)
region = MEM_callocN(sizeof(ARegion), "preview for clip");
BLI_addtail(&sc->regionbase, region);
- init_preview_region(scene, sa, sc, region);
+ init_preview_region(scene, area, sc, region);
/* main region */
region = MEM_callocN(sizeof(ARegion), "main region for clip");
@@ -315,12 +315,12 @@ static void clip_free(SpaceLink *sl)
}
/* spacetype; init callback */
-static void clip_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
+static void clip_init(struct wmWindowManager *UNUSED(wm), ScrArea *area)
{
ListBase *lb = WM_dropboxmap_find("Clip", SPACE_CLIP, 0);
/* add drop boxes */
- WM_event_add_dropbox_handler(&sa->handlers, lb);
+ WM_event_add_dropbox_handler(&area->handlers, lb);
}
static SpaceLink *clip_duplicate(SpaceLink *sl)
@@ -335,18 +335,18 @@ static SpaceLink *clip_duplicate(SpaceLink *sl)
return (SpaceLink *)scn;
}
-static void clip_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *scene)
+static void clip_listener(wmWindow *UNUSED(win), ScrArea *area, wmNotifier *wmn, Scene *scene)
{
/* context changes */
switch (wmn->category) {
case NC_SCENE:
switch (wmn->data) {
case ND_FRAME:
- clip_scopes_tag_refresh(sa);
+ clip_scopes_tag_refresh(area);
ATTR_FALLTHROUGH;
case ND_FRAME_RANGE:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
break;
@@ -354,8 +354,8 @@ static void clip_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, S
switch (wmn->data) {
case ND_DISPLAY:
case ND_SELECT:
- clip_scopes_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ clip_scopes_tag_refresh(area);
+ ED_area_tag_redraw(area);
break;
}
switch (wmn->action) {
@@ -365,8 +365,8 @@ static void clip_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, S
/* fall-through */
case NA_SELECTED:
- clip_scopes_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ clip_scopes_tag_refresh(area);
+ ED_area_tag_redraw(area);
break;
}
break;
@@ -375,56 +375,56 @@ static void clip_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, S
case ND_SELECT:
case ND_DATA:
case ND_DRAW:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
switch (wmn->action) {
case NA_SELECTED:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
case NA_EDITED:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
break;
case NC_GEOM:
switch (wmn->data) {
case ND_SELECT:
- clip_scopes_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ clip_scopes_tag_refresh(area);
+ ED_area_tag_redraw(area);
break;
}
break;
case NC_SCREEN:
switch (wmn->data) {
case ND_ANIMPLAY:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
case ND_LAYOUTSET:
- clip_area_sync_frame_from_scene(sa, scene);
+ clip_area_sync_frame_from_scene(area, scene);
break;
}
break;
case NC_SPACE:
if (wmn->data == ND_SPACE_CLIP) {
- clip_scopes_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ clip_scopes_tag_refresh(area);
+ ED_area_tag_redraw(area);
}
break;
case NC_GPENCIL:
if (wmn->action == NA_EDITED) {
- clip_scopes_check_gpencil_change(sa);
- ED_area_tag_redraw(sa);
+ clip_scopes_check_gpencil_change(area);
+ ED_area_tag_redraw(area);
}
else if (wmn->data & ND_GPENCIL_EDITMODE) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
case NC_WM:
switch (wmn->data) {
case ND_FILEREAD:
case ND_UNDO:
- clip_area_sync_frame_from_scene(sa, scene);
+ clip_area_sync_frame_from_scene(area, scene);
break;
}
break;
@@ -639,17 +639,17 @@ static void clip_dropboxes(void)
WM_dropbox_add(lb, "CLIP_OT_open", clip_drop_poll, clip_drop_copy);
}
-static void clip_refresh(const bContext *C, ScrArea *sa)
+static void clip_refresh(const bContext *C, ScrArea *area)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *window = CTX_wm_window(C);
Scene *scene = CTX_data_scene(C);
- SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
- ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
- ARegion *ar_tools = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
- ARegion *ar_preview = ED_clip_has_preview_region(C, sa);
- ARegion *ar_properties = ED_clip_has_properties_region(sa);
- ARegion *ar_channels = ED_clip_has_channels_region(sa);
+ SpaceClip *sc = (SpaceClip *)area->spacedata.first;
+ ARegion *region_main = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
+ ARegion *region_tools = BKE_area_find_region_type(area, RGN_TYPE_TOOLS);
+ ARegion *region_preview = ED_clip_has_preview_region(C, area);
+ ARegion *region_properties = ED_clip_has_properties_region(area);
+ ARegion *region_channels = ED_clip_has_channels_region(area);
bool main_visible = false, preview_visible = false, tools_visible = false;
bool properties_visible = false, channels_visible = false;
bool view_changed = false;
@@ -669,7 +669,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
properties_visible = false;
channels_visible = false;
- reinit_preview_region(C, ar_preview);
+ reinit_preview_region(C, region_preview);
break;
case SC_VIEW_DOPESHEET:
main_visible = false;
@@ -678,135 +678,135 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
properties_visible = false;
channels_visible = true;
- reinit_preview_region(C, ar_preview);
+ reinit_preview_region(C, region_preview);
break;
}
if (main_visible) {
- if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) {
- ar_main->flag &= ~RGN_FLAG_HIDDEN;
- ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ if (region_main && (region_main->flag & RGN_FLAG_HIDDEN)) {
+ region_main->flag &= ~RGN_FLAG_HIDDEN;
+ region_main->v2d.flag &= ~V2D_IS_INITIALISED;
view_changed = true;
}
- if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
- ar_main->alignment = RGN_ALIGN_NONE;
+ if (region_main && region_main->alignment != RGN_ALIGN_NONE) {
+ region_main->alignment = RGN_ALIGN_NONE;
view_changed = true;
}
}
else {
- if (ar_main && !(ar_main->flag & RGN_FLAG_HIDDEN)) {
- ar_main->flag |= RGN_FLAG_HIDDEN;
- ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
- WM_event_remove_handlers((bContext *)C, &ar_main->handlers);
+ if (region_main && !(region_main->flag & RGN_FLAG_HIDDEN)) {
+ region_main->flag |= RGN_FLAG_HIDDEN;
+ region_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &region_main->handlers);
view_changed = true;
}
- if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
- ar_main->alignment = RGN_ALIGN_NONE;
+ if (region_main && region_main->alignment != RGN_ALIGN_NONE) {
+ region_main->alignment = RGN_ALIGN_NONE;
view_changed = true;
}
}
if (properties_visible) {
- if (ar_properties && (ar_properties->flag & RGN_FLAG_HIDDEN)) {
- ar_properties->flag &= ~RGN_FLAG_HIDDEN;
- ar_properties->v2d.flag &= ~V2D_IS_INITIALISED;
+ if (region_properties && (region_properties->flag & RGN_FLAG_HIDDEN)) {
+ region_properties->flag &= ~RGN_FLAG_HIDDEN;
+ region_properties->v2d.flag &= ~V2D_IS_INITIALISED;
view_changed = true;
}
- if (ar_properties && ar_properties->alignment != RGN_ALIGN_RIGHT) {
- ar_properties->alignment = RGN_ALIGN_RIGHT;
+ if (region_properties && region_properties->alignment != RGN_ALIGN_RIGHT) {
+ region_properties->alignment = RGN_ALIGN_RIGHT;
view_changed = true;
}
}
else {
- if (ar_properties && !(ar_properties->flag & RGN_FLAG_HIDDEN)) {
- ar_properties->flag |= RGN_FLAG_HIDDEN;
- ar_properties->v2d.flag &= ~V2D_IS_INITIALISED;
- WM_event_remove_handlers((bContext *)C, &ar_properties->handlers);
+ if (region_properties && !(region_properties->flag & RGN_FLAG_HIDDEN)) {
+ region_properties->flag |= RGN_FLAG_HIDDEN;
+ region_properties->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &region_properties->handlers);
view_changed = true;
}
- if (ar_properties && ar_properties->alignment != RGN_ALIGN_NONE) {
- ar_properties->alignment = RGN_ALIGN_NONE;
+ if (region_properties && region_properties->alignment != RGN_ALIGN_NONE) {
+ region_properties->alignment = RGN_ALIGN_NONE;
view_changed = true;
}
}
if (tools_visible) {
- if (ar_tools && (ar_tools->flag & RGN_FLAG_HIDDEN)) {
- ar_tools->flag &= ~RGN_FLAG_HIDDEN;
- ar_tools->v2d.flag &= ~V2D_IS_INITIALISED;
+ if (region_tools && (region_tools->flag & RGN_FLAG_HIDDEN)) {
+ region_tools->flag &= ~RGN_FLAG_HIDDEN;
+ region_tools->v2d.flag &= ~V2D_IS_INITIALISED;
view_changed = true;
}
- if (ar_tools && ar_tools->alignment != RGN_ALIGN_LEFT) {
- ar_tools->alignment = RGN_ALIGN_LEFT;
+ if (region_tools && region_tools->alignment != RGN_ALIGN_LEFT) {
+ region_tools->alignment = RGN_ALIGN_LEFT;
view_changed = true;
}
}
else {
- if (ar_tools && !(ar_tools->flag & RGN_FLAG_HIDDEN)) {
- ar_tools->flag |= RGN_FLAG_HIDDEN;
- ar_tools->v2d.flag &= ~V2D_IS_INITIALISED;
- WM_event_remove_handlers((bContext *)C, &ar_tools->handlers);
+ if (region_tools && !(region_tools->flag & RGN_FLAG_HIDDEN)) {
+ region_tools->flag |= RGN_FLAG_HIDDEN;
+ region_tools->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &region_tools->handlers);
view_changed = true;
}
- if (ar_tools && ar_tools->alignment != RGN_ALIGN_NONE) {
- ar_tools->alignment = RGN_ALIGN_NONE;
+ if (region_tools && region_tools->alignment != RGN_ALIGN_NONE) {
+ region_tools->alignment = RGN_ALIGN_NONE;
view_changed = true;
}
}
if (preview_visible) {
- if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) {
- ar_preview->flag &= ~RGN_FLAG_HIDDEN;
- ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
- ar_preview->v2d.cur = ar_preview->v2d.tot;
+ if (region_preview && (region_preview->flag & RGN_FLAG_HIDDEN)) {
+ region_preview->flag &= ~RGN_FLAG_HIDDEN;
+ region_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_preview->v2d.cur = region_preview->v2d.tot;
view_changed = true;
}
- if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
- ar_preview->alignment = RGN_ALIGN_NONE;
+ if (region_preview && region_preview->alignment != RGN_ALIGN_NONE) {
+ region_preview->alignment = RGN_ALIGN_NONE;
view_changed = true;
}
}
else {
- if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) {
- ar_preview->flag |= RGN_FLAG_HIDDEN;
- ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
- WM_event_remove_handlers((bContext *)C, &ar_preview->handlers);
+ if (region_preview && !(region_preview->flag & RGN_FLAG_HIDDEN)) {
+ region_preview->flag |= RGN_FLAG_HIDDEN;
+ region_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &region_preview->handlers);
view_changed = true;
}
- if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
- ar_preview->alignment = RGN_ALIGN_NONE;
+ if (region_preview && region_preview->alignment != RGN_ALIGN_NONE) {
+ region_preview->alignment = RGN_ALIGN_NONE;
view_changed = true;
}
}
if (channels_visible) {
- if (ar_channels && (ar_channels->flag & RGN_FLAG_HIDDEN)) {
- ar_channels->flag &= ~RGN_FLAG_HIDDEN;
- ar_channels->v2d.flag &= ~V2D_IS_INITIALISED;
+ if (region_channels && (region_channels->flag & RGN_FLAG_HIDDEN)) {
+ region_channels->flag &= ~RGN_FLAG_HIDDEN;
+ region_channels->v2d.flag &= ~V2D_IS_INITIALISED;
view_changed = true;
}
- if (ar_channels && ar_channels->alignment != RGN_ALIGN_LEFT) {
- ar_channels->alignment = RGN_ALIGN_LEFT;
+ if (region_channels && region_channels->alignment != RGN_ALIGN_LEFT) {
+ region_channels->alignment = RGN_ALIGN_LEFT;
view_changed = true;
}
}
else {
- if (ar_channels && !(ar_channels->flag & RGN_FLAG_HIDDEN)) {
- ar_channels->flag |= RGN_FLAG_HIDDEN;
- ar_channels->v2d.flag &= ~V2D_IS_INITIALISED;
- WM_event_remove_handlers((bContext *)C, &ar_channels->handlers);
+ if (region_channels && !(region_channels->flag & RGN_FLAG_HIDDEN)) {
+ region_channels->flag |= RGN_FLAG_HIDDEN;
+ region_channels->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &region_channels->handlers);
view_changed = true;
}
- if (ar_channels && ar_channels->alignment != RGN_ALIGN_NONE) {
- ar_channels->alignment = RGN_ALIGN_NONE;
+ if (region_channels && region_channels->alignment != RGN_ALIGN_NONE) {
+ region_channels->alignment = RGN_ALIGN_NONE;
view_changed = true;
}
}
if (view_changed) {
- ED_area_initialize(wm, window, sa);
- ED_area_tag_redraw(sa);
+ ED_area_initialize(wm, window, area);
+ ED_area_tag_redraw(area);
}
BKE_movieclip_user_set_frame(&sc->user, scene->r.cfra);
@@ -946,9 +946,9 @@ static void clip_main_region_draw(const bContext *C, ARegion *region)
if (sc->mode == SC_MODE_MASKEDIT) {
Mask *mask = CTX_data_edit_mask(C);
if (mask && clip) {
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
int mask_width, mask_height;
- ED_mask_get_size(sa, &mask_width, &mask_height);
+ ED_mask_get_size(area, &mask_width, &mask_height);
ED_mask_draw_region(CTX_data_expect_evaluated_depsgraph(C),
mask,
region,
@@ -1001,7 +1001,7 @@ static void clip_main_region_draw(const bContext *C, ARegion *region)
}
static void clip_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -1145,7 +1145,7 @@ static void clip_preview_region_draw(const bContext *C, ARegion *region)
}
static void clip_preview_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *UNUSED(region),
wmNotifier *UNUSED(wmn),
const Scene *UNUSED(scene))
@@ -1191,7 +1191,7 @@ static void clip_channels_region_draw(const bContext *C, ARegion *region)
}
static void clip_channels_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *UNUSED(region),
wmNotifier *UNUSED(wmn),
const Scene *UNUSED(scene))
@@ -1212,7 +1212,7 @@ static void clip_header_region_draw(const bContext *C, ARegion *region)
}
static void clip_header_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -1255,7 +1255,7 @@ static void clip_tools_region_draw(const bContext *C, ARegion *region)
/****************** tool properties region ******************/
static void clip_props_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -1308,7 +1308,7 @@ static void clip_properties_region_draw(const bContext *C, ARegion *region)
}
static void clip_properties_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -1330,7 +1330,7 @@ static void clip_properties_region_listener(wmWindow *UNUSED(win),
/********************* registration ********************/
-static void clip_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
+static void clip_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
{
SpaceClip *sclip = (SpaceClip *)slink;
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index 58d6fb425b0..981e056fa63 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -353,10 +353,10 @@ static int console_move_exec(bContext *C, wmOperator *op)
}
if (done) {
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
console_scroll_bottom(region);
}
@@ -860,7 +860,7 @@ static int console_history_append_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc = CTX_wm_space_console(C);
ARegion *region = CTX_wm_region(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ConsoleLine *ci = console_history_verify(C);
/* own this text in the new line, don't free */
char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0);
@@ -885,7 +885,7 @@ static int console_history_append_exec(bContext *C, wmOperator *op)
console_select_offset(sc, ci->len - prev_len);
console_line_cursor_set(ci, cursor);
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
/* when calling render modally this can be NULL when calling:
* bpy.ops.render.render('INVOKE_DEFAULT') */
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 66aa92275b4..d8c097cad37 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -98,7 +98,7 @@ static void console_free(SpaceLink *sl)
}
/* spacetype; init callback */
-static void console_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void console_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
@@ -146,7 +146,7 @@ static void console_main_region_init(wmWindowManager *wm, ARegion *region)
}
/* same as 'text_cursor' */
-static void console_cursor(wmWindow *win, ScrArea *UNUSED(sa), ARegion *region)
+static void console_cursor(wmWindow *win, ScrArea *UNUSED(area), ARegion *region)
{
int wmcursor = WM_CURSOR_TEXT_EDIT;
const wmEvent *event = win->eventstate;
@@ -278,19 +278,19 @@ static void console_header_region_draw(const bContext *C, ARegion *region)
}
static void console_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *sa,
+ ScrArea *area,
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
{
- // SpaceInfo *sinfo = sa->spacedata.first;
+ // SpaceInfo *sinfo = area->spacedata.first;
/* context changes */
switch (wmn->category) {
case NC_SPACE: {
if (wmn->data == ND_SPACE_CONSOLE) {
if (wmn->action == NA_EDITED) {
- if ((wmn->reference && sa) && (wmn->reference == sa->spacedata.first)) {
+ if ((wmn->reference && area) && (wmn->reference == area->spacedata.first)) {
/* we've modified the geometry (font size), re-calculate rect */
console_textview_update_rect(wmn->reference, region);
ED_region_tag_redraw(region);
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 5f5aced292d..226e7ae6b22 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -448,7 +448,7 @@ static void draw_dividers(FileLayout *layout, View2D *v2d)
const int step = (layout->tile_w + 2 * layout->tile_border_x);
- unsigned int vertex_len = 0;
+ uint vertex_len = 0;
int sx = (int)v2d->tot.xmin;
while (sx < v2d->cur.xmax) {
sx += step;
@@ -457,7 +457,7 @@ static void draw_dividers(FileLayout *layout, View2D *v2d)
if (vertex_len > 0) {
int v1[2], v2[2];
- unsigned char col_hi[3], col_lo[3];
+ uchar col_hi[3], col_lo[3];
UI_GetThemeColorShade3ubv(TH_BACK, 30, col_hi);
UI_GetThemeColorShade3ubv(TH_BACK, -30, col_lo);
@@ -685,7 +685,7 @@ void file_draw_list(const bContext *C, ARegion *region)
bool is_icon;
eFontStyle_Align align;
bool do_drag;
- unsigned char text_col[4];
+ uchar text_col[4];
const bool draw_columnheader = (params->display == FILE_VERTICALDISPLAY);
const float thumb_icon_aspect = MIN2(64.0f / (float)(params->thumbnail_size), 1.0f);
@@ -753,7 +753,7 @@ void file_draw_list(const bContext *C, ARegion *region)
UI_GetThemeColor4ubv(TH_TEXT, text_col);
for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) {
- unsigned int file_selflag;
+ uint file_selflag;
char path[FILE_MAX_LIBEXTRA];
int padx = 0.1f * UI_UNIT_X;
int icon_ofs = 0;
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 5258892d55d..7cce243696d 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -103,7 +103,7 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile,
return sel;
}
-static void file_deselect_all(SpaceFile *sfile, unsigned int flag)
+static void file_deselect_all(SpaceFile *sfile, uint flag)
{
FileSelection sel;
sel.first = 0;
@@ -851,7 +851,7 @@ void FILE_OT_select_walk(wmOperatorType *ot)
static int file_select_all_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceFile *sfile = CTX_wm_space_file(C);
FileSelection sel;
const int numfiles = filelist_files_ensure(sfile->files);
@@ -900,7 +900,7 @@ static int file_select_all_exec(bContext *C, wmOperator *op)
file_draw_check(C);
WM_event_add_mousemove(CTX_wm_window(C));
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
return OPERATOR_FINISHED;
}
@@ -975,7 +975,7 @@ void FILE_OT_select_bookmark(wmOperatorType *ot)
static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceFile *sfile = CTX_wm_space_file(C);
struct FSMenu *fsmenu = ED_fsmenu_get();
struct FileSelectParams *params = ED_fileselect_get_params(sfile);
@@ -992,8 +992,8 @@ static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op))
fsmenu_write_file(fsmenu, name);
}
- ED_area_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ ED_area_tag_refresh(area);
+ ED_area_tag_redraw(area);
return OPERATOR_FINISHED;
}
@@ -1017,7 +1017,7 @@ void FILE_OT_bookmark_add(wmOperatorType *ot)
static int bookmark_delete_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceFile *sfile = CTX_wm_space_file(C);
struct FSMenu *fsmenu = ED_fsmenu_get();
int nentries = ED_fsmenu_get_nentries(fsmenu, FS_CATEGORY_BOOKMARKS);
@@ -1041,8 +1041,8 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op)
BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL),
BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, name);
- ED_area_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ ED_area_tag_refresh(area);
+ ED_area_tag_redraw(area);
}
}
@@ -1075,7 +1075,7 @@ void FILE_OT_bookmark_delete(wmOperatorType *ot)
static int bookmark_cleanup_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
struct FSMenu *fsmenu = ED_fsmenu_get();
struct FSMenuEntry *fsme_next, *fsme = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS);
int index;
@@ -1102,8 +1102,8 @@ static int bookmark_cleanup_exec(bContext *C, wmOperator *UNUSED(op))
BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, name);
fsmenu_refresh_bookmarks_status(CTX_wm_manager(C), fsmenu);
- ED_area_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ ED_area_tag_refresh(area);
+ ED_area_tag_redraw(area);
}
return OPERATOR_FINISHED;
@@ -1138,7 +1138,7 @@ enum {
static int bookmark_move_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceFile *sfile = CTX_wm_space_file(C);
struct FSMenu *fsmenu = ED_fsmenu_get();
struct FSMenuEntry *fsmentry = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS);
@@ -1187,7 +1187,7 @@ static int bookmark_move_exec(bContext *C, wmOperator *op)
BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, fname);
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
return OPERATOR_FINISHED;
}
@@ -1228,7 +1228,7 @@ void FILE_OT_bookmark_move(wmOperatorType *ot)
static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
char name[FILE_MAX];
struct FSMenu *fsmenu = ED_fsmenu_get();
@@ -1240,7 +1240,7 @@ static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op))
BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL),
BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, name);
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
return OPERATOR_FINISHED;
}
@@ -1867,9 +1867,9 @@ void FILE_OT_next(struct wmOperatorType *ot)
/* only meant for timer usage */
static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceFile *sfile = CTX_wm_space_file(C);
- ARegion *region, *ar_ctx = CTX_wm_region(C);
+ ARegion *region, *region_ctx = CTX_wm_region(C);
const bool is_horizontal = (sfile->layout->flag & FILE_LAYOUT_HOR) != 0;
int i;
@@ -1911,7 +1911,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
}
/* we need the correct area for scrolling */
- region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
if (!region || region->regiontype != RGN_TYPE_WINDOW) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer);
sfile->smoothscroll_timer = NULL;
@@ -2033,7 +2033,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
ED_region_tag_redraw(region);
/* and restore context */
- CTX_wm_region_set(C, ar_ctx);
+ CTX_wm_region_set(C, region_ctx);
return OPERATOR_FINISHED;
}
@@ -2494,7 +2494,7 @@ static void filenum_newname(char *name, size_t name_size, int add)
char head[FILE_MAXFILE], tail[FILE_MAXFILE];
char name_temp[FILE_MAXFILE];
int pic;
- unsigned short digits;
+ ushort digits;
pic = BLI_stringdec(name, head, tail, &digits);
@@ -2521,12 +2521,12 @@ static void filenum_newname(char *name, size_t name_size, int add)
static int file_filenum_exec(bContext *C, wmOperator *op)
{
SpaceFile *sfile = CTX_wm_space_file(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
int inc = RNA_int_get(op->ptr, "increment");
if (sfile->params && (inc != 0)) {
filenum_newname(sfile->params->file, sizeof(sfile->params->file), inc);
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
file_draw_check(C);
// WM_event_add_notifier(C, NC_WINDOW, NULL);
}
@@ -2576,12 +2576,12 @@ static void file_rename_state_activate(SpaceFile *sfile, int file_idx, bool requ
static int file_rename_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C);
if (sfile->params) {
file_rename_state_activate(sfile, sfile->params->active_file, true);
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
return OPERATOR_FINISHED;
@@ -2589,12 +2589,12 @@ static int file_rename_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
static int file_rename_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C);
if (sfile->params) {
file_rename_state_activate(sfile, sfile->params->highlight_file, false);
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
return OPERATOR_FINISHED;
@@ -2708,8 +2708,8 @@ void FILE_OT_delete(struct wmOperatorType *ot)
static int file_start_filter_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ ScrArea *area = CTX_wm_area(C);
+ ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_UI);
SpaceFile *sf = CTX_wm_space_file(C);
UI_textbutton_activate_rna(C, region, sf->params, "filter_search");
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index 9ba098fcf45..ff9454cd922 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -57,20 +57,20 @@ static bool file_panel_operator_poll(const bContext *C, PanelType *UNUSED(pt))
return (sfile && sfile->op);
}
-static void file_panel_operator_header(const bContext *C, Panel *pa)
+static void file_panel_operator_header(const bContext *C, Panel *panel)
{
SpaceFile *sfile = CTX_wm_space_file(C);
wmOperator *op = sfile->op;
- BLI_strncpy(pa->drawname, WM_operatortype_name(op->type, op->ptr), sizeof(pa->drawname));
+ BLI_strncpy(panel->drawname, WM_operatortype_name(op->type, op->ptr), sizeof(panel->drawname));
}
-static void file_panel_operator(const bContext *C, Panel *pa)
+static void file_panel_operator(const bContext *C, Panel *panel)
{
SpaceFile *sfile = CTX_wm_space_file(C);
wmOperator *op = sfile->op;
- UI_block_func_set(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL);
+ UI_block_func_set(uiLayoutGetBlock(panel->layout), file_draw_check_cb, NULL, NULL);
/* Hack: temporary hide.*/
const char *hide[] = {"filepath", "files", "directory", "filename"};
@@ -82,7 +82,7 @@ static void file_panel_operator(const bContext *C, Panel *pa)
}
uiTemplateOperatorPropertyButs(
- C, pa->layout, op, UI_BUT_LABEL_ALIGN_NONE, UI_TEMPLATE_OP_PROPS_SHOW_EMPTY);
+ C, panel->layout, op, UI_BUT_LABEL_ALIGN_NONE, UI_TEMPLATE_OP_PROPS_SHOW_EMPTY);
/* Hack: temporary hide.*/
for (int i = 0; i < ARRAY_SIZE(hide); i++) {
@@ -92,7 +92,7 @@ static void file_panel_operator(const bContext *C, Panel *pa)
}
}
- UI_block_func_set(uiLayoutGetBlock(pa->layout), NULL, NULL, NULL);
+ UI_block_func_set(uiLayoutGetBlock(panel->layout), NULL, NULL, NULL);
}
void file_tool_props_region_panels_register(ARegionType *art)
@@ -128,12 +128,12 @@ static void file_panel_execution_execute_button(uiLayout *layout, const char *ti
uiItemO(row, title, ICON_NONE, "FILE_OT_execute");
}
-static void file_panel_execution_buttons_draw(const bContext *C, Panel *pa)
+static void file_panel_execution_buttons_draw(const bContext *C, Panel *panel)
{
bScreen *screen = CTX_wm_screen(C);
SpaceFile *sfile = CTX_wm_space_file(C);
FileSelectParams *params = ED_fileselect_get_params(sfile);
- uiBlock *block = uiLayoutGetBlock(pa->layout);
+ uiBlock *block = uiLayoutGetBlock(panel->layout);
uiBut *but;
uiLayout *row;
PointerRNA params_rna_ptr, *but_extra_rna_ptr;
@@ -148,7 +148,7 @@ static void file_panel_execution_buttons_draw(const bContext *C, Panel *pa)
RNA_pointer_create(&screen->id, &RNA_FileSelectParams, params, &params_rna_ptr);
- row = uiLayoutRow(pa->layout, false);
+ row = uiLayoutRow(panel->layout, false);
uiLayoutSetScaleY(row, 1.3f);
/* callbacks for operator check functions */
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index dec38501d38..126430986a5 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -264,7 +264,7 @@ enum {
typedef struct FileListEntryPreview {
char path[FILE_MAX];
- unsigned int flags;
+ uint flags;
int index;
ImBuf *img;
} FileListEntryPreview;
@@ -2325,16 +2325,16 @@ int filelist_empty(struct FileList *filelist)
return (filelist->filelist.nbr_entries == 0);
}
-unsigned int filelist_entry_select_set(const FileList *filelist,
- const FileDirEntry *entry,
- FileSelType select,
- unsigned int flag,
- FileCheckType check)
+uint filelist_entry_select_set(const FileList *filelist,
+ const FileDirEntry *entry,
+ FileSelType select,
+ uint flag,
+ FileCheckType check)
{
/* Default NULL pointer if not found is fine here! */
void **es_p = BLI_ghash_lookup_p(filelist->selection_state, entry->uuid);
- unsigned int entry_flag = es_p ? POINTER_AS_UINT(*es_p) : 0;
- const unsigned int org_entry_flag = entry_flag;
+ uint entry_flag = es_p ? POINTER_AS_UINT(*es_p) : 0;
+ const uint org_entry_flag = entry_flag;
BLI_assert(entry);
BLI_assert(ELEM(check, CHECK_DIRS, CHECK_FILES, CHECK_ALL));
@@ -2373,11 +2373,8 @@ unsigned int filelist_entry_select_set(const FileList *filelist,
return entry_flag;
}
-void filelist_entry_select_index_set(FileList *filelist,
- const int index,
- FileSelType select,
- unsigned int flag,
- FileCheckType check)
+void filelist_entry_select_index_set(
+ FileList *filelist, const int index, FileSelType select, uint flag, FileCheckType check)
{
FileDirEntry *entry = filelist_file(filelist, index);
@@ -2386,11 +2383,8 @@ void filelist_entry_select_index_set(FileList *filelist,
}
}
-void filelist_entries_select_index_range_set(FileList *filelist,
- FileSelection *sel,
- FileSelType select,
- unsigned int flag,
- FileCheckType check)
+void filelist_entries_select_index_range_set(
+ FileList *filelist, FileSelection *sel, FileSelType select, uint flag, FileCheckType check)
{
/* select all valid files between first and last indicated */
if ((sel->first >= 0) && (sel->first < filelist->filelist.nbr_entries_filtered) &&
@@ -2402,9 +2396,7 @@ void filelist_entries_select_index_range_set(FileList *filelist,
}
}
-unsigned int filelist_entry_select_get(FileList *filelist,
- FileDirEntry *entry,
- FileCheckType check)
+uint filelist_entry_select_get(FileList *filelist, FileDirEntry *entry, FileCheckType check)
{
BLI_assert(entry);
BLI_assert(ELEM(check, CHECK_DIRS, CHECK_FILES, CHECK_ALL));
@@ -2418,9 +2410,7 @@ unsigned int filelist_entry_select_get(FileList *filelist,
return 0;
}
-unsigned int filelist_entry_select_index_get(FileList *filelist,
- const int index,
- FileCheckType check)
+uint filelist_entry_select_index_get(FileList *filelist, const int index, FileCheckType check)
{
FileDirEntry *entry = filelist_file(filelist, index);
@@ -2436,7 +2426,7 @@ unsigned int filelist_entry_select_index_get(FileList *filelist,
*/
void filelist_entry_parent_select_set(FileList *filelist,
FileSelType select,
- unsigned int flag,
+ uint flag,
FileCheckType check)
{
if ((filelist->filter_data.flags & FLF_HIDE_PARENT) == 0) {
@@ -2627,7 +2617,7 @@ static int filelist_readjob_list_lib(const char *root, ListBase *entries, const
/* Kept for reference here, in case we want to add back that feature later.
* We do not need it currently. */
/* Code ***NOT*** updated for job stuff! */
-static void filelist_readjob_main_rec(Main *bmain, FileList *filelist)
+static void filelist_readjob_main_recursive(Main *bmain, FileList *filelist)
{
ID *id;
FileDirEntry *files, *firstlib = NULL;
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 1574dbbeb76..21b705cbb44 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -55,16 +55,16 @@
#include "filelist.h"
#include "fsmenu.h"
-static ARegion *file_execute_region_ensure(ScrArea *sa, ARegion *ar_prev)
+static ARegion *file_execute_region_ensure(ScrArea *area, ARegion *region_prev)
{
ARegion *region;
- if ((region = BKE_area_find_region_type(sa, RGN_TYPE_EXECUTE)) != NULL) {
+ if ((region = BKE_area_find_region_type(area, RGN_TYPE_EXECUTE)) != NULL) {
return region;
}
region = MEM_callocN(sizeof(ARegion), "execute region for file");
- BLI_insertlinkafter(&sa->regionbase, ar_prev, region);
+ BLI_insertlinkafter(&area->regionbase, region_prev, region);
region->regiontype = RGN_TYPE_EXECUTE;
region->alignment = RGN_ALIGN_BOTTOM;
region->flag = RGN_FLAG_DYNAMIC_SIZE;
@@ -72,17 +72,17 @@ static ARegion *file_execute_region_ensure(ScrArea *sa, ARegion *ar_prev)
return region;
}
-static ARegion *file_tool_props_region_ensure(ScrArea *sa, ARegion *ar_prev)
+static ARegion *file_tool_props_region_ensure(ScrArea *area, ARegion *region_prev)
{
ARegion *region;
- if ((region = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS)) != NULL) {
+ if ((region = BKE_area_find_region_type(area, RGN_TYPE_TOOL_PROPS)) != NULL) {
return region;
}
/* add subdiv level; after execute region */
region = MEM_callocN(sizeof(ARegion), "tool props for file");
- BLI_insertlinkafter(&sa->regionbase, ar_prev, region);
+ BLI_insertlinkafter(&area->regionbase, region_prev, region);
region->regiontype = RGN_TYPE_TOOL_PROPS;
region->alignment = RGN_ALIGN_RIGHT;
@@ -173,18 +173,18 @@ static void file_free(SpaceLink *sl)
}
/* spacetype; init callback, area size changes, screen set, etc */
-static void file_init(wmWindowManager *UNUSED(wm), ScrArea *sa)
+static void file_init(wmWindowManager *UNUSED(wm), ScrArea *area)
{
- SpaceFile *sfile = (SpaceFile *)sa->spacedata.first;
+ SpaceFile *sfile = (SpaceFile *)area->spacedata.first;
if (sfile->layout) {
sfile->layout->dirty = true;
}
}
-static void file_exit(wmWindowManager *wm, ScrArea *sa)
+static void file_exit(wmWindowManager *wm, ScrArea *area)
{
- SpaceFile *sfile = (SpaceFile *)sa->spacedata.first;
+ SpaceFile *sfile = (SpaceFile *)area->spacedata.first;
if (sfile->previews_timer) {
WM_event_remove_timer_notifier(wm, NULL, sfile->previews_timer);
@@ -228,44 +228,44 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
static void file_ensure_valid_region_state(bContext *C,
wmWindowManager *wm,
wmWindow *win,
- ScrArea *sa,
+ ScrArea *area,
SpaceFile *sfile,
FileSelectParams *params)
{
- ARegion *ar_ui = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS);
- ARegion *ar_execute = BKE_area_find_region_type(sa, RGN_TYPE_EXECUTE);
+ ARegion *region_ui = BKE_area_find_region_type(area, RGN_TYPE_UI);
+ ARegion *region_props = BKE_area_find_region_type(area, RGN_TYPE_TOOL_PROPS);
+ ARegion *region_execute = BKE_area_find_region_type(area, RGN_TYPE_EXECUTE);
bool needs_init = false; /* To avoid multiple ED_area_initialize() calls. */
/* If there's an file-operation, ensure we have the option and execute region */
- if (sfile->op && (ar_props == NULL)) {
- ar_execute = file_execute_region_ensure(sa, ar_ui);
- ar_props = file_tool_props_region_ensure(sa, ar_execute);
+ if (sfile->op && (region_props == NULL)) {
+ region_execute = file_execute_region_ensure(area, region_ui);
+ region_props = file_tool_props_region_ensure(area, region_execute);
if (params->flag & FILE_HIDE_TOOL_PROPS) {
- ar_props->flag |= RGN_FLAG_HIDDEN;
+ region_props->flag |= RGN_FLAG_HIDDEN;
}
else {
- ar_props->flag &= ~RGN_FLAG_HIDDEN;
+ region_props->flag &= ~RGN_FLAG_HIDDEN;
}
needs_init = true;
}
/* If there's _no_ file-operation, ensure we _don't_ have the option and execute region */
- else if ((sfile->op == NULL) && (ar_props != NULL)) {
- BLI_assert(ar_execute != NULL);
+ else if ((sfile->op == NULL) && (region_props != NULL)) {
+ BLI_assert(region_execute != NULL);
- ED_region_remove(C, sa, ar_props);
- ED_region_remove(C, sa, ar_execute);
+ ED_region_remove(C, area, region_props);
+ ED_region_remove(C, area, region_execute);
needs_init = true;
}
if (needs_init) {
- ED_area_initialize(wm, win, sa);
+ ED_area_initialize(wm, win, area);
}
}
-static void file_refresh(const bContext *C, ScrArea *sa)
+static void file_refresh(const bContext *C, ScrArea *area)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
@@ -333,34 +333,34 @@ static void file_refresh(const bContext *C, ScrArea *sa)
sfile->layout->dirty = true;
}
- /* Might be called with NULL sa, see file_main_region_draw() below. */
- if (sa) {
- file_ensure_valid_region_state((bContext *)C, wm, win, sa, sfile, params);
+ /* Might be called with NULL area, see file_main_region_draw() below. */
+ if (area) {
+ file_ensure_valid_region_state((bContext *)C, wm, win, area, sfile, params);
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
static void file_listener(wmWindow *UNUSED(win),
- ScrArea *sa,
+ ScrArea *area,
wmNotifier *wmn,
Scene *UNUSED(scene))
{
- SpaceFile *sfile = (SpaceFile *)sa->spacedata.first;
+ SpaceFile *sfile = (SpaceFile *)area->spacedata.first;
/* context changes */
switch (wmn->category) {
case NC_SPACE:
switch (wmn->data) {
case ND_SPACE_FILE_LIST:
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
case ND_SPACE_FILE_PARAMS:
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
case ND_SPACE_FILE_PREVIEW:
if (sfile->files && filelist_cache_previews_update(sfile->files)) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
break;
}
@@ -384,7 +384,7 @@ static void file_main_region_init(wmWindowManager *wm, ARegion *region)
}
static void file_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -408,18 +408,18 @@ static void file_main_region_message_subscribe(const struct bContext *UNUSED(C),
struct WorkSpace *UNUSED(workspace),
struct Scene *UNUSED(scene),
struct bScreen *screen,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus)
{
- SpaceFile *sfile = sa->spacedata.first;
+ SpaceFile *sfile = area->spacedata.first;
FileSelectParams *params = ED_fileselect_get_params(sfile);
/* This is a bit odd that a region owns the subscriber for an area,
* keep for now since all subscribers for WM are regions.
* May be worth re-visiting later. */
wmMsgSubscribeValue msg_sub_value_area_tag_refresh = {
.owner = region,
- .user_data = sa,
+ .user_data = area,
.notify = ED_area_do_msg_notify_tag_refresh,
};
@@ -575,7 +575,7 @@ static void file_tools_region_draw(const bContext *C, ARegion *region)
}
static void file_tools_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *UNUSED(region),
wmNotifier *UNUSED(wmn),
const Scene *UNUSED(scene))
@@ -643,7 +643,7 @@ static void file_execution_region_draw(const bContext *C, ARegion *region)
}
static void file_ui_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index ba16d08f0d3..9a3a942a9eb 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -38,7 +38,7 @@
#include "BLT_translation.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_fcurve.h"
@@ -111,9 +111,9 @@ static bool graph_panel_poll(const bContext *C, PanelType *UNUSED(pt))
/* -------------- */
-static void graph_panel_cursor_header(const bContext *C, Panel *pa)
+static void graph_panel_cursor_header(const bContext *C, Panel *panel)
{
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
SpaceGraph *sipo = CTX_wm_space_graph(C);
Scene *scene = CTX_data_scene(C);
PointerRNA spaceptr, sceneptr;
@@ -121,25 +121,25 @@ static void graph_panel_cursor_header(const bContext *C, Panel *pa)
/* get RNA pointers for use when creating the UI elements */
RNA_id_pointer_create(&scene->id, &sceneptr);
- RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr);
+ RNA_pointer_create(&screen->id, &RNA_SpaceGraphEditor, sipo, &spaceptr);
/* 2D-Cursor */
- col = uiLayoutColumn(pa->layout, false);
+ col = uiLayoutColumn(panel->layout, false);
uiItemR(col, &spaceptr, "show_cursor", 0, "", ICON_NONE);
}
-static void graph_panel_cursor(const bContext *C, Panel *pa)
+static void graph_panel_cursor(const bContext *C, Panel *panel)
{
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
SpaceGraph *sipo = CTX_wm_space_graph(C);
Scene *scene = CTX_data_scene(C);
PointerRNA spaceptr, sceneptr;
- uiLayout *layout = pa->layout;
+ uiLayout *layout = panel->layout;
uiLayout *col, *sub;
/* get RNA pointers for use when creating the UI elements */
RNA_id_pointer_create(&scene->id, &sceneptr);
- RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr);
+ RNA_pointer_create(&screen->id, &RNA_SpaceGraphEditor, sipo, &spaceptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
@@ -164,12 +164,12 @@ static void graph_panel_cursor(const bContext *C, Panel *pa)
/* ******************* active F-Curve ************** */
-static void graph_panel_properties(const bContext *C, Panel *pa)
+static void graph_panel_properties(const bContext *C, Panel *panel)
{
bAnimListElem *ale;
FCurve *fcu;
PointerRNA fcu_ptr;
- uiLayout *layout = pa->layout;
+ uiLayout *layout = panel->layout;
uiLayout *col;
char name[256];
int icon = 0;
@@ -345,13 +345,13 @@ static void graphedit_activekey_right_handle_coord_cb(bContext *C, void *fcu_ptr
bezt->f3 = f3;
}
-static void graph_panel_key_properties(const bContext *C, Panel *pa)
+static void graph_panel_key_properties(const bContext *C, Panel *panel)
{
bAnimListElem *ale;
FCurve *fcu;
BezTriple *bezt, *prevbezt;
- uiLayout *layout = pa->layout;
+ uiLayout *layout = panel->layout;
const ARegion *region = CTX_wm_region(C);
/* Just a width big enough so buttons use entire layout width (will be clamped by it then). */
const int but_max_width = region->winx;
@@ -1240,7 +1240,7 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
/* Panel to show property driven by the driver (in Drivers Editor) - duplicates Active FCurve,
* but useful for clarity. */
-static void graph_panel_driven_property(const bContext *C, Panel *pa)
+static void graph_panel_driven_property(const bContext *C, Panel *panel)
{
bAnimListElem *ale;
FCurve *fcu;
@@ -1249,14 +1249,14 @@ static void graph_panel_driven_property(const bContext *C, Panel *pa)
return;
}
- graph_draw_driven_property_panel(pa->layout, ale->id, fcu);
+ graph_draw_driven_property_panel(panel->layout, ale->id, fcu);
MEM_freeN(ale);
}
/* driver settings for active F-Curve
* (only for 'Drivers' mode in Graph Editor, i.e. the full "Drivers Editor") */
-static void graph_panel_drivers(const bContext *C, Panel *pa)
+static void graph_panel_drivers(const bContext *C, Panel *panel)
{
bAnimListElem *ale;
FCurve *fcu;
@@ -1266,7 +1266,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
return;
}
- graph_draw_driver_settings_panel(pa->layout, ale->id, fcu, false);
+ graph_draw_driver_settings_panel(panel->layout, ale->id, fcu, false);
/* cleanup */
MEM_freeN(ale);
@@ -1282,9 +1282,9 @@ static bool graph_panel_drivers_popover_poll(const bContext *C, PanelType *UNUSE
}
/* popover panel for driver editing anywhere in ui */
-static void graph_panel_drivers_popover(const bContext *C, Panel *pa)
+static void graph_panel_drivers_popover(const bContext *C, Panel *panel)
{
- uiLayout *layout = pa->layout;
+ uiLayout *layout = panel->layout;
PointerRNA ptr = {NULL};
PropertyRNA *prop = NULL;
@@ -1316,7 +1316,7 @@ static void graph_panel_drivers_popover(const bContext *C, Panel *pa)
/* Driven Property Settings */
uiItemL(layout, IFACE_("Driven Property:"), ICON_NONE);
- graph_draw_driven_property_panel(pa->layout, id, fcu);
+ graph_draw_driven_property_panel(panel->layout, id, fcu);
/* TODO: All vs Single */
uiItemS(layout);
@@ -1324,7 +1324,7 @@ static void graph_panel_drivers_popover(const bContext *C, Panel *pa)
/* Drivers Settings */
uiItemL(layout, IFACE_("Driver Settings:"), ICON_NONE);
- graph_draw_driver_settings_panel(pa->layout, id, fcu, true);
+ graph_draw_driver_settings_panel(panel->layout, id, fcu, true);
}
}
@@ -1347,7 +1347,7 @@ static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int
}
}
-static void graph_panel_modifiers(const bContext *C, Panel *pa)
+static void graph_panel_modifiers(const bContext *C, Panel *panel)
{
bAnimListElem *ale;
FCurve *fcu;
@@ -1360,12 +1360,12 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa)
return;
}
- block = uiLayoutGetBlock(pa->layout);
+ block = uiLayoutGetBlock(panel->layout);
UI_block_func_handle_set(block, do_graph_region_modifier_buttons, NULL);
/* 'add modifier' button at top of panel */
{
- row = uiLayoutRow(pa->layout, false);
+ row = uiLayoutRow(panel->layout, false);
/* this is an operator button which calls a 'add modifier' operator...
* a menu might be nicer but would be tricky as we need some custom filtering
@@ -1382,7 +1382,7 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa)
active = !(fcu->flag & FCURVE_MOD_OFF);
/* draw each modifier */
for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) {
- col = uiLayoutColumn(pa->layout, true);
+ col = uiLayoutColumn(panel->layout, true);
uiLayoutSetActive(col, active);
ANIM_uiTemplate_fmodifier_draw(col, ale->fcurve_owner_id, &fcu->modifiers, fcm);
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 8c64fb5bb40..08053dba4d9 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -1336,7 +1336,7 @@ static void decimate_graph_keys(bAnimContext *ac, float remove_ratio, float erro
typedef struct tDecimateGraphOp {
bAnimContext ac;
Scene *scene;
- ScrArea *sa;
+ ScrArea *area;
ARegion *region;
/** A 0-1 value for determining how much we should decimate. */
@@ -1409,7 +1409,7 @@ static void decimate_exit(bContext *C, wmOperator *op)
return;
}
- ScrArea *sa = dgo->sa;
+ ScrArea *area = dgo->area;
LinkData *link;
for (link = dgo->bezt_arr_list.first; link != NULL; link = link->next) {
@@ -1423,7 +1423,7 @@ static void decimate_exit(bContext *C, wmOperator *op)
/* Return to normal cursor and header status. */
WM_cursor_modal_restore(win);
- ED_area_status_text(sa, NULL);
+ ED_area_status_text(area, NULL);
/* cleanup */
op->customdata = NULL;
@@ -1450,7 +1450,7 @@ static void decimate_draw_status_header(wmOperator *op, tDecimateGraphOp *dgo)
status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(percentage * 100.0f));
}
- ED_area_status_text(dgo->sa, status_str);
+ ED_area_status_text(dgo->area, status_str);
}
/* Calculate percentage based on position of mouse (we only use x-axis for now.
@@ -1482,7 +1482,7 @@ static int graphkeys_decimate_invoke(bContext *C, wmOperator *op, const wmEvent
dgo->percentage_prop = RNA_struct_find_property(op->ptr, "remove_ratio");
dgo->scene = CTX_data_scene(C);
- dgo->sa = CTX_wm_area(C);
+ dgo->area = CTX_wm_area(C);
dgo->region = CTX_wm_region(C);
/* initialise percentage so that it will have the correct value before the first mouse move. */
@@ -2647,7 +2647,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
for (f = 0; f < 3; f++) {
FCurve *fcu = euf->fcurves[f];
BezTriple *bezt, *prev;
- unsigned int i;
+ uint i;
/* skip if not enough vets to do a decent analysis of... */
if (fcu->totvert <= 2) {
@@ -3569,7 +3569,7 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op)
bAnimListElem *ale;
int filter;
bool ok = false;
- unsigned int deleted = 0;
+ uint deleted = 0;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -3623,10 +3623,10 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op)
static bool graph_driver_delete_invalid_poll(bContext *C)
{
bAnimContext ac;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* firstly, check if in Graph Editor */
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
+ if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
return 0;
}
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c
index 0af94904ba6..575cba07f04 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -54,40 +54,40 @@
/* Set up UI configuration for Drivers Editor */
/* NOTE: Currently called from windowmanager
* (new drivers editor window) and RNA (mode switching) */
-void ED_drivers_editor_init(bContext *C, ScrArea *sa)
+void ED_drivers_editor_init(bContext *C, ScrArea *area)
{
- SpaceGraph *sipo = (SpaceGraph *)sa->spacedata.first;
+ SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first;
/* Set mode */
sipo->mode = SIPO_MODE_DRIVERS;
/* Show Properties Region (or else the settings can't be edited) */
- ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar_props) {
- UI_panel_category_active_set(ar_props, "Drivers");
+ ARegion *region_props = BKE_area_find_region_type(area, RGN_TYPE_UI);
+ if (region_props) {
+ UI_panel_category_active_set(region_props, "Drivers");
- ar_props->flag &= ~RGN_FLAG_HIDDEN;
+ region_props->flag &= ~RGN_FLAG_HIDDEN;
/* XXX: Adjust width of this too? */
- ED_region_visibility_change_update(C, sa, ar_props);
+ ED_region_visibility_change_update(C, area, region_props);
}
else {
- printf("%s: Couldn't find properties region for Drivers Editor - %p\n", __func__, sa);
+ printf("%s: Couldn't find properties region for Drivers Editor - %p\n", __func__, area);
}
/* Adjust framing in graph region */
/* TODO: Have a way of not resetting this every time?
* (e.g. So that switching back and forth between editors doesn't keep jumping?)
*/
- ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
- if (ar_main) {
+ ARegion *region_main = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
+ if (region_main) {
/* XXX: Ideally we recenter based on the range instead... */
- ar_main->v2d.tot.xmin = -2.0f;
- ar_main->v2d.tot.ymin = -2.0f;
- ar_main->v2d.tot.xmax = 2.0f;
- ar_main->v2d.tot.ymax = 2.0f;
+ region_main->v2d.tot.xmin = -2.0f;
+ region_main->v2d.tot.ymin = -2.0f;
+ region_main->v2d.tot.xmax = 2.0f;
+ region_main->v2d.tot.ymax = 2.0f;
- ar_main->v2d.cur = ar_main->v2d.tot;
+ region_main->v2d.cur = region_main->v2d.tot;
}
}
@@ -135,14 +135,14 @@ bool graphop_visible_keyframes_poll(bContext *C)
bAnimContext ac;
bAnimListElem *ale;
ListBase anim_data = {NULL, NULL};
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
size_t items;
int filter;
short found = 0;
/* firstly, check if in Graph Editor */
// TODO: also check for region?
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
+ if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
return 0;
}
@@ -188,14 +188,14 @@ bool graphop_editable_keyframes_poll(bContext *C)
bAnimContext ac;
bAnimListElem *ale;
ListBase anim_data = {NULL, NULL};
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
size_t items;
int filter;
short found = 0;
/* firstly, check if in Graph Editor */
// TODO: also check for region?
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
+ if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
return 0;
}
@@ -241,12 +241,12 @@ bool graphop_active_fcurve_poll(bContext *C)
{
bAnimContext ac;
bAnimListElem *ale;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
bool has_fcurve = 0;
/* firstly, check if in Graph Editor */
// TODO: also check for region?
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
+ if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
return 0;
}
@@ -293,13 +293,13 @@ bool graphop_selected_fcurve_poll(bContext *C)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
size_t items;
int filter;
/* firstly, check if in Graph Editor */
// TODO: also check for region?
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
+ if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
return 0;
}
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 05edfccd6a8..bd82b8ecf2e 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -64,7 +64,7 @@
/* ******************** default callbacks for ipo space ***************** */
-static SpaceLink *graph_new(const ScrArea *UNUSED(sa), const Scene *scene)
+static SpaceLink *graph_new(const ScrArea *UNUSED(area), const Scene *scene)
{
ARegion *region;
SpaceGraph *sipo;
@@ -150,9 +150,9 @@ static void graph_free(SpaceLink *sl)
}
/* spacetype; init callback */
-static void graph_init(struct wmWindowManager *wm, ScrArea *sa)
+static void graph_init(struct wmWindowManager *wm, ScrArea *area)
{
- SpaceGraph *sipo = (SpaceGraph *)sa->spacedata.first;
+ SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first;
/* init dopesheet data if non-existent (i.e. for old files) */
if (sipo->ads == NULL) {
@@ -165,7 +165,7 @@ static void graph_init(struct wmWindowManager *wm, ScrArea *sa)
* as this is run on each region resize; setting this here will cause selection
* state to be lost on area/region resizing. [#35744]
*/
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
static SpaceLink *graph_duplicate(SpaceLink *sl)
@@ -413,7 +413,7 @@ static void graph_buttons_region_draw(const bContext *C, ARegion *region)
}
static void graph_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -483,12 +483,12 @@ static void graph_region_message_subscribe(const struct bContext *UNUSED(C),
struct WorkSpace *UNUSED(workspace),
struct Scene *scene,
struct bScreen *screen,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus)
{
PointerRNA ptr;
- RNA_pointer_create(&screen->id, &RNA_SpaceGraphEditor, sa->spacedata.first, &ptr);
+ RNA_pointer_create(&screen->id, &RNA_SpaceGraphEditor, area->spacedata.first, &ptr);
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
@@ -556,11 +556,11 @@ static void graph_region_message_subscribe(const struct bContext *UNUSED(C),
/* editor level listener */
static void graph_listener(wmWindow *UNUSED(win),
- ScrArea *sa,
+ ScrArea *area,
wmNotifier *wmn,
Scene *UNUSED(scene))
{
- SpaceGraph *sipo = (SpaceGraph *)sa->spacedata.first;
+ SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first;
/* context changes */
switch (wmn->category) {
@@ -568,10 +568,10 @@ static void graph_listener(wmWindow *UNUSED(win),
/* for selection changes of animation data, we can just redraw...
* otherwise autocolor might need to be done again */
if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED)) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
else {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
break;
case NC_SCENE:
@@ -580,11 +580,11 @@ static void graph_listener(wmWindow *UNUSED(win),
* (needs flag set to do syncing). */
case ND_OB_SELECT:
sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC;
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
default: /* just redrawing the view will do */
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
break;
@@ -594,13 +594,13 @@ static void graph_listener(wmWindow *UNUSED(win),
* (needs flag set to do syncing). */
case ND_BONE_ACTIVE:
sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC;
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
case ND_TRANSFORM:
break; /*do nothing*/
default: /* just redrawing the view will do */
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
break;
@@ -608,26 +608,26 @@ static void graph_listener(wmWindow *UNUSED(win),
if (wmn->action == NA_SELECTED) {
/* selection changed, so force refresh to flush (needs flag set to do syncing) */
sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC;
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
break;
case NC_SPACE:
if (wmn->data == ND_SPACE_GRAPH) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
case NC_WINDOW:
if (sipo->runtime.flag &
(SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC | SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR)) {
/* force redraw/refresh after undo/redo - prevents "black curve" problem */
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
break;
// XXX: restore the case below if not enough updates occur...
// default:
// if (wmn->data == ND_KEYS)
- // ED_area_tag_redraw(sa);
+ // ED_area_tag_redraw(area);
}
}
@@ -754,9 +754,9 @@ static void graph_refresh_fcurve_colors(const bContext *C)
ANIM_animdata_freelist(&anim_data);
}
-static void graph_refresh(const bContext *C, ScrArea *sa)
+static void graph_refresh(const bContext *C, ScrArea *area)
{
- SpaceGraph *sipo = (SpaceGraph *)sa->spacedata.first;
+ SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first;
/* updates to data needed depends on Graph Editor mode... */
switch (sipo->mode) {
@@ -780,7 +780,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
if (sipo->runtime.flag & SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC) {
ANIM_sync_animchannels_to_data(C);
sipo->runtime.flag &= ~SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC;
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
/* We could check 'SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR', but color is recalculated anyway. */
@@ -789,7 +789,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
#if 0 /* Done below. */
graph_refresh_fcurve_colors(C);
#endif
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
sipo->runtime.flag &= ~(SIPO_RUNTIME_FLAG_TWEAK_HANDLES_LEFT |
@@ -799,7 +799,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
graph_refresh_fcurve_colors(C);
}
-static void graph_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
+static void graph_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
{
SpaceGraph *sgraph = (SpaceGraph *)slink;
@@ -813,15 +813,15 @@ static void graph_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID
}
}
-static int graph_space_subtype_get(ScrArea *sa)
+static int graph_space_subtype_get(ScrArea *area)
{
- SpaceGraph *sgraph = sa->spacedata.first;
+ SpaceGraph *sgraph = area->spacedata.first;
return sgraph->mode;
}
-static void graph_space_subtype_set(ScrArea *sa, int value)
+static void graph_space_subtype_set(ScrArea *area, int value)
{
- SpaceGraph *sgraph = sa->spacedata.first;
+ SpaceGraph *sgraph = area->spacedata.first;
sgraph->mode = value;
}
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 7bd1b8e8291..67e64c52051 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1275,7 +1275,7 @@ static Image *image_open_single(Main *bmain,
if ((range->length > 1) && (ima->source == IMA_SRC_FILE)) {
if (range->udim_tiles.first && range->offset == 1001) {
ima->source = IMA_SRC_TILED;
- for (LinkData *node = range->udim_tiles.first; node; node = node->next) {
+ LISTBASE_FOREACH (LinkData *, node, &range->udim_tiles) {
BKE_image_add_tile(ima, POINTER_AS_INT(node->data), NULL);
}
}
@@ -1291,7 +1291,7 @@ static Image *image_open_single(Main *bmain,
static int image_open_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
ImageUser *iuser = NULL;
@@ -1309,7 +1309,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
}
ListBase ranges = ED_image_filesel_detect_sequences(bmain, op, use_udim);
- for (ImageFrameRange *range = ranges.first; range; range = range->next) {
+ LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) {
Image *ima_range = image_open_single(
bmain, op, range, BKE_main_blendfile_path(bmain), is_relative_path, use_multiview);
@@ -1345,8 +1345,8 @@ static int image_open_exec(bContext *C, wmOperator *op)
if (iod->iuser) {
iuser = iod->iuser;
}
- else if (sa && sa->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = sa->spacedata.first;
+ else if (area && area->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = area->spacedata.first;
ED_space_image_set(bmain, sima, obedit, ima, false);
iuser = &sima->iuser;
}
@@ -1359,7 +1359,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
if (iuser == NULL) {
Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data;
if (cam) {
- for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) {
+ LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
if (bgpic->ima == ima) {
iuser = &bgpic->iuser;
break;
@@ -3107,13 +3107,13 @@ typedef struct ImageSampleInfo {
int width, height;
int sample_size;
- unsigned char col[4];
+ uchar col[4];
float colf[4];
float linearcol[4];
int z;
float zf;
- unsigned char *colp;
+ uchar *colp;
const float *colfp;
int *zp;
float *zfp;
@@ -3198,7 +3198,7 @@ bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, int mval[2],
if (uv[0] >= 0.0f && uv[1] >= 0.0f && uv[0] < 1.0f && uv[1] < 1.0f) {
const float *fp;
- unsigned char *cp;
+ uchar *cp;
int x = (int)(uv[0] * ibuf->x), y = (int)(uv[1] * ibuf->y);
CLAMP(x, 0, ibuf->x - 1);
@@ -3210,7 +3210,7 @@ bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, int mval[2],
ret = true;
}
else if (ibuf->rect) {
- cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
+ cp = (uchar *)(ibuf->rect + y * ibuf->x + x);
rgb_uchar_to_float(r_col, cp);
IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace);
ret = true;
@@ -3230,7 +3230,7 @@ static void image_sample_pixel_color_ubyte(const ImBuf *ibuf,
uchar r_col[4],
float r_col_linear[4])
{
- const uchar *cp = (unsigned char *)(ibuf->rect + coord[1] * ibuf->x + coord[0]);
+ const uchar *cp = (uchar *)(ibuf->rect + coord[1] * ibuf->x + coord[0]);
copy_v4_v4_uchar(r_col, cp);
rgba_uchar_to_float(r_col_linear, r_col);
IMB_colormanagement_colorspace_to_scene_linear_v4(r_col_linear, false, ibuf->rect_colorspace);
@@ -3409,13 +3409,13 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
// XXX node curve integration ..
#if 0
{
- ScrArea *sa, *cur = curarea;
+ ScrArea *area, *cur = curarea;
node_curvemap_sample(fp); /* sends global to node editor */
- for (sa = G.curscreen->areabase.first; sa; sa = sa->next) {
- if (sa->spacetype == SPACE_NODE) {
- areawinset(sa->win);
- scrarea_do_windraw(sa);
+ for (area = G.curscreen->areabase.first; area; area = area->next) {
+ if (area->spacetype == SPACE_NODE) {
+ areawinset(area->win);
+ scrarea_do_windraw(area);
}
}
node_curvemap_sample(NULL); /* clears global in node editor */
diff --git a/source/blender/editors/space_image/image_sequence.c b/source/blender/editors/space_image/image_sequence.c
index cc6fe38866d..8b298045597 100644
--- a/source/blender/editors/space_image/image_sequence.c
+++ b/source/blender/editors/space_image/image_sequence.c
@@ -69,7 +69,7 @@ static void image_sequence_get_frame_ranges(wmOperator *op, ListBase *ranges)
RNA_BEGIN (op->ptr, itemptr, "files") {
char base_head[FILE_MAX], base_tail[FILE_MAX];
char head[FILE_MAX], tail[FILE_MAX];
- unsigned short digits;
+ ushort digits;
char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
ImageFrame *frame = MEM_callocN(sizeof(ImageFrame), "image_frame");
@@ -125,7 +125,7 @@ static int image_get_udim(char *filepath, ListBase *udim_tiles)
char filename[FILE_MAX], dirname[FILE_MAXDIR];
BLI_split_dirfile(filepath, dirname, filename, sizeof(dirname), sizeof(filename));
- unsigned short digits;
+ ushort digits;
char base_head[FILE_MAX], base_tail[FILE_MAX];
int id = BLI_stringdec(filename, base_head, base_tail, &digits);
@@ -226,7 +226,7 @@ ListBase ED_image_filesel_detect_sequences(Main *bmain, wmOperator *op, const bo
const bool was_relative = BLI_path_is_rel(filepath);
image_sequence_get_frame_ranges(op, &ranges);
- for (ImageFrameRange *range = ranges.first; range; range = range->next) {
+ LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) {
image_detect_frame_range(range, detect_udim);
BLI_freelistN(&range->frames);
diff --git a/source/blender/editors/space_image/image_undo.c b/source/blender/editors/space_image/image_undo.c
index 8f9f4189c8a..056dd826238 100644
--- a/source/blender/editors/space_image/image_undo.c
+++ b/source/blender/editors/space_image/image_undo.c
@@ -145,7 +145,7 @@ static void ptile_free_list(ListBase *paint_tiles)
static void ptile_invalidate_list(ListBase *paint_tiles)
{
- for (PaintTile *ptile = paint_tiles->first; ptile; ptile = ptile->next) {
+ LISTBASE_FOREACH (PaintTile *, ptile, paint_tiles) {
ptile->valid = false;
}
}
@@ -159,7 +159,7 @@ void *ED_image_paint_tile_find(ListBase *paint_tiles,
ushort **r_mask,
bool validate)
{
- for (PaintTile *ptile = paint_tiles->first; ptile; ptile = ptile->next) {
+ LISTBASE_FOREACH (PaintTile *, ptile, paint_tiles) {
if (ptile->x_tile == x_tile && ptile->y_tile == y_tile) {
if (ptile->image == image && ptile->ibuf == ibuf && ptile->iuser.tile == iuser->tile) {
if (r_mask) {
@@ -267,7 +267,7 @@ static void ptile_restore_runtime_list(ListBase *paint_tiles)
{
ImBuf *tmpibuf = imbuf_alloc_temp_tile();
- for (PaintTile *ptile = paint_tiles->first; ptile; ptile = ptile->next) {
+ LISTBASE_FOREACH (PaintTile *, ptile, paint_tiles) {
Image *image = ptile->image;
ImBuf *ibuf = BKE_image_acquire_ibuf(image, &ptile->iuser, NULL);
const bool has_float = (ibuf->rect_float != NULL);
@@ -542,7 +542,7 @@ static void uhandle_restore_list(ListBase *undo_handles, bool use_init)
{
ImBuf *tmpibuf = imbuf_alloc_temp_tile();
- for (UndoImageHandle *uh = undo_handles->first; uh; uh = uh->next) {
+ LISTBASE_FOREACH (UndoImageHandle *, uh, undo_handles) {
/* Tiles only added to second set of tiles. */
Image *image = uh->image_ref.ptr;
@@ -552,7 +552,7 @@ static void uhandle_restore_list(ListBase *undo_handles, bool use_init)
continue;
}
bool changed = false;
- for (UndoImageBuf *ubuf_iter = uh->buffers.first; ubuf_iter; ubuf_iter = ubuf_iter->next) {
+ LISTBASE_FOREACH (UndoImageBuf *, ubuf_iter, &uh->buffers) {
UndoImageBuf *ubuf = use_init ? ubuf_iter : ubuf_iter->post;
ubuf_ensure_compat_ibuf(ubuf, ibuf);
@@ -611,7 +611,7 @@ static UndoImageBuf *uhandle_lookup_ubuf(UndoImageHandle *uh,
const Image *UNUSED(image),
const char *ibuf_name)
{
- for (UndoImageBuf *ubuf = uh->buffers.first; ubuf; ubuf = ubuf->next) {
+ LISTBASE_FOREACH (UndoImageBuf *, ubuf, &uh->buffers) {
if (STREQ(ubuf->ibuf_name, ibuf_name)) {
return ubuf;
}
@@ -643,7 +643,7 @@ static UndoImageHandle *uhandle_lookup_by_name(ListBase *undo_handles,
const Image *image,
int tile_number)
{
- for (UndoImageHandle *uh = undo_handles->first; uh; uh = uh->next) {
+ LISTBASE_FOREACH (UndoImageHandle *, uh, undo_handles) {
if (STREQ(image->id.name + 2, uh->image_ref.name + 2) && uh->iuser.tile == tile_number) {
return uh;
}
@@ -653,7 +653,7 @@ static UndoImageHandle *uhandle_lookup_by_name(ListBase *undo_handles,
static UndoImageHandle *uhandle_lookup(ListBase *undo_handles, const Image *image, int tile_number)
{
- for (UndoImageHandle *uh = undo_handles->first; uh; uh = uh->next) {
+ LISTBASE_FOREACH (UndoImageHandle *, uh, undo_handles) {
if (image == uh->image_ref.ptr && uh->iuser.tile == tile_number) {
return uh;
}
@@ -733,9 +733,9 @@ static bool image_undosys_poll(bContext *C)
{
Object *obact = CTX_data_active_object(C);
- ScrArea *sa = CTX_wm_area(C);
- if (sa && (sa->spacetype == SPACE_IMAGE)) {
- SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
+ ScrArea *area = CTX_wm_area(C);
+ if (area && (area->spacetype == SPACE_IMAGE)) {
+ SpaceImage *sima = (SpaceImage *)area->spacedata.first;
if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
return true;
}
@@ -799,8 +799,8 @@ static bool image_undosys_step_encode(struct bContext *C,
}
BLI_listbase_clear(&us->paint_tiles);
- for (UndoImageHandle *uh = us->handles.first; uh; uh = uh->next) {
- for (UndoImageBuf *ubuf_pre = uh->buffers.first; ubuf_pre; ubuf_pre = ubuf_pre->next) {
+ LISTBASE_FOREACH (UndoImageHandle *, uh, &us->handles) {
+ LISTBASE_FOREACH (UndoImageBuf *, ubuf_pre, &uh->buffers) {
ImBuf *ibuf = BKE_image_acquire_ibuf(uh->image_ref.ptr, &uh->iuser, NULL);
@@ -979,7 +979,7 @@ static void image_undosys_foreach_ID_ref(UndoStep *us_p,
void *user_data)
{
ImageUndoStep *us = (ImageUndoStep *)us_p;
- for (UndoImageHandle *uh = us->handles.first; uh; uh = uh->next) {
+ LISTBASE_FOREACH (UndoImageHandle *, uh, &us->handles) {
foreach_ID_ref_fn(user_data, ((UndoRefID *)&uh->image_ref));
}
}
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 12a1dce3a5f..af94b5b6e21 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -83,13 +83,13 @@
/**************************** common state *****************************/
-static void image_scopes_tag_refresh(ScrArea *sa)
+static void image_scopes_tag_refresh(ScrArea *area)
{
- SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
+ SpaceImage *sima = (SpaceImage *)area->spacedata.first;
ARegion *region;
/* only while histogram is visible */
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_TOOL_PROPS && region->flag & RGN_FLAG_HIDDEN) {
return;
}
@@ -186,12 +186,12 @@ static void image_free(SpaceLink *sl)
}
/* spacetype; init callback, add handlers */
-static void image_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
+static void image_init(struct wmWindowManager *UNUSED(wm), ScrArea *area)
{
ListBase *lb = WM_dropboxmap_find("Image", SPACE_IMAGE, 0);
/* add drop boxes */
- WM_event_add_dropbox_handler(&sa->handlers, lb);
+ WM_event_add_dropbox_handler(&area->handlers, lb);
}
static SpaceLink *image_duplicate(SpaceLink *sl)
@@ -298,10 +298,10 @@ static void image_dropboxes(void)
* \note take care not to get into feedback loop here,
* calling composite job causes viewer to refresh.
*/
-static void image_refresh(const bContext *C, ScrArea *sa)
+static void image_refresh(const bContext *C, ScrArea *area)
{
Scene *scene = CTX_data_scene(C);
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
Image *ima;
ima = ED_space_image(sima);
@@ -318,53 +318,53 @@ static void image_refresh(const bContext *C, ScrArea *sa)
}
}
-static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
+static void image_listener(wmWindow *win, ScrArea *area, wmNotifier *wmn, Scene *UNUSED(scene))
{
- SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
+ SpaceImage *sima = (SpaceImage *)area->spacedata.first;
/* context changes */
switch (wmn->category) {
case NC_WINDOW:
/* notifier comes from editing color space */
- image_scopes_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ image_scopes_tag_refresh(area);
+ ED_area_tag_redraw(area);
break;
case NC_SCENE:
switch (wmn->data) {
case ND_FRAME:
- image_scopes_tag_refresh(sa);
- ED_area_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ image_scopes_tag_refresh(area);
+ ED_area_tag_refresh(area);
+ ED_area_tag_redraw(area);
break;
case ND_MODE:
if (wmn->subtype == NS_EDITMODE_MESH) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
case ND_RENDER_RESULT:
case ND_RENDER_OPTIONS:
case ND_COMPO_RESULT:
if (ED_space_image_show_render(sima)) {
- image_scopes_tag_refresh(sa);
+ image_scopes_tag_refresh(area);
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
break;
case NC_IMAGE:
if (wmn->reference == sima->image || !wmn->reference) {
if (wmn->action != NA_PAINTING) {
- image_scopes_tag_refresh(sa);
- ED_area_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ image_scopes_tag_refresh(area);
+ ED_area_tag_refresh(area);
+ ED_area_tag_redraw(area);
}
}
break;
case NC_SPACE:
if (wmn->data == ND_SPACE_IMAGE) {
- image_scopes_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ image_scopes_tag_refresh(area);
+ ED_area_tag_redraw(area);
}
break;
case NC_MASK: {
@@ -374,23 +374,23 @@ static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *U
if (sima->mode == SI_MODE_MASK) {
switch (wmn->data) {
case ND_SELECT:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
case ND_DATA:
case ND_DRAW:
/* causes node-recalc */
- ED_area_tag_redraw(sa);
- ED_area_tag_refresh(sa);
+ ED_area_tag_redraw(area);
+ ED_area_tag_refresh(area);
break;
}
switch (wmn->action) {
case NA_SELECTED:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
case NA_EDITED:
/* causes node-recalc */
- ED_area_tag_redraw(sa);
- ED_area_tag_refresh(sa);
+ ED_area_tag_redraw(area);
+ ED_area_tag_refresh(area);
break;
}
}
@@ -400,9 +400,9 @@ static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *U
switch (wmn->data) {
case ND_DATA:
case ND_SELECT:
- image_scopes_tag_refresh(sa);
- ED_area_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ image_scopes_tag_refresh(area);
+ ED_area_tag_refresh(area);
+ ED_area_tag_redraw(area);
break;
}
break;
@@ -415,8 +415,8 @@ static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *U
Object *ob = OBACT(view_layer);
if (ob && (ob == wmn->reference) && (ob->mode & OB_MODE_EDIT)) {
if (sima->lock && (sima->flag & SI_DRAWSHADOW)) {
- ED_area_tag_refresh(sa);
- ED_area_tag_redraw(sa);
+ ED_area_tag_refresh(area);
+ ED_area_tag_redraw(area);
}
}
break;
@@ -427,14 +427,14 @@ static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *U
}
case NC_ID: {
if (wmn->action == NA_RENAME) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
}
case NC_WM:
if (wmn->data == ND_UNDO) {
- ED_area_tag_redraw(sa);
- ED_area_tag_refresh(sa);
+ ED_area_tag_redraw(area);
+ ED_area_tag_refresh(area);
}
break;
}
@@ -756,7 +756,7 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
}
static void image_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *sa,
+ ScrArea *area,
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -784,7 +784,7 @@ static void image_main_region_listener(wmWindow *UNUSED(win),
break;
case NC_MATERIAL:
if (wmn->data == ND_SHADING_LINKS) {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
if (sima->iuser.scene && (sima->iuser.scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE)) {
ED_region_tag_redraw(region);
@@ -873,7 +873,7 @@ static void image_buttons_region_draw(const bContext *C, ARegion *region)
}
static void image_buttons_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -936,7 +936,7 @@ static void image_tools_region_draw(const bContext *C, ARegion *region)
}
static void image_tools_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -984,8 +984,8 @@ static void image_header_region_init(wmWindowManager *UNUSED(wm), ARegion *regio
static void image_header_region_draw(const bContext *C, ARegion *region)
{
- ScrArea *sa = CTX_wm_area(C);
- SpaceImage *sima = sa->spacedata.first;
+ ScrArea *area = CTX_wm_area(C);
+ SpaceImage *sima = area->spacedata.first;
image_user_refresh_scene(C, sima);
@@ -993,7 +993,7 @@ static void image_header_region_draw(const bContext *C, ARegion *region)
}
static void image_header_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -1024,7 +1024,7 @@ static void image_header_region_listener(wmWindow *UNUSED(win),
}
}
-static void image_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
+static void image_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
{
SpaceImage *simg = (SpaceImage *)slink;
@@ -1054,15 +1054,15 @@ static void image_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID
* The previous non-uv-edit mode is stored so switching back to the
* image doesn't always reset the sub-mode.
*/
-static int image_space_subtype_get(ScrArea *sa)
+static int image_space_subtype_get(ScrArea *area)
{
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
return sima->mode == SI_MODE_UV ? SI_MODE_UV : SI_MODE_VIEW;
}
-static void image_space_subtype_set(ScrArea *sa, int value)
+static void image_space_subtype_set(ScrArea *area, int value)
{
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
if (value == SI_MODE_UV) {
if (sima->mode != SI_MODE_UV) {
sima->mode_prev = sima->mode;
diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c
index 7499c057950..adc6391a0f6 100644
--- a/source/blender/editors/space_info/info_report.c
+++ b/source/blender/editors/space_info/info_report.c
@@ -250,7 +250,7 @@ static int box_select_exec(bContext *C, wmOperator *op)
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const int select = (sel_op != SEL_OP_SUB);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- for (Report *report = reports->list.first; report; report = report->next) {
+ LISTBASE_FOREACH (Report *, report, &reports->list) {
if ((report->type & report_mask) == 0) {
continue;
}
@@ -264,7 +264,7 @@ static int box_select_exec(bContext *C, wmOperator *op)
/* get the first report if none found */
if (report_min == NULL) {
// printf("find_min\n");
- for (Report *report = reports->list.first; report; report = report->next) {
+ LISTBASE_FOREACH (Report *, report, &reports->list) {
if (report->type & report_mask) {
report_min = report;
break;
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index 78bc0961cb3..a91a11b2465 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -40,7 +40,6 @@
#include "BLT_translation.h"
-#include "BKE_anim.h"
#include "BKE_blender_version.h"
#include "BKE_curve.h"
#include "BKE_displist.h"
@@ -582,8 +581,8 @@ void ED_info_stats_clear(ViewLayer *view_layer)
const char *ED_info_stats_string(Main *bmain, Scene *scene, ViewLayer *view_layer)
{
- /* Looping through dependency graph when interface is locked in not safe.
- * Thew interface is marked as locked when jobs wants to modify the
+ /* Looping through dependency graph when interface is locked is not safe.
+ * The interface is marked as locked when jobs wants to modify the
* dependency graph. */
wmWindowManager *wm = bmain->wm.first;
if (wm->is_interface_locked) {
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 58ce3316c4b..04df0f0d4f0 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -97,7 +97,7 @@ static void info_free(SpaceLink *UNUSED(sl))
}
/* spacetype; init callback */
-static void info_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void info_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
@@ -209,12 +209,12 @@ static void info_header_region_draw(const bContext *C, ARegion *region)
}
static void info_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
{
- // SpaceInfo *sinfo = sa->spacedata.first;
+ // SpaceInfo *sinfo = area->spacedata.first;
/* context changes */
switch (wmn->category) {
@@ -228,7 +228,7 @@ static void info_main_region_listener(wmWindow *UNUSED(win),
}
static void info_header_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -267,7 +267,7 @@ static void info_header_region_message_subscribe(const bContext *UNUSED(C),
WorkSpace *UNUSED(workspace),
Scene *UNUSED(scene),
bScreen *UNUSED(screen),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
struct wmMsgBus *mbus)
{
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index ca7f8791f75..218e2be0362 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -242,11 +242,11 @@ static bool nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt))
/* -------------- */
/* active AnimData */
-static void nla_panel_animdata(const bContext *C, Panel *pa)
+static void nla_panel_animdata(const bContext *C, Panel *panel)
{
PointerRNA adt_ptr;
/* AnimData *adt; */
- uiLayout *layout = pa->layout;
+ uiLayout *layout = panel->layout;
uiLayout *row;
uiBlock *block;
@@ -312,10 +312,10 @@ static void nla_panel_animdata(const bContext *C, Panel *pa)
}
/* generic settings for active NLA-Strip */
-static void nla_panel_stripname(const bContext *C, Panel *pa)
+static void nla_panel_stripname(const bContext *C, Panel *panel)
{
PointerRNA strip_ptr;
- uiLayout *layout = pa->layout;
+ uiLayout *layout = panel->layout;
uiLayout *row;
uiBlock *block;
@@ -350,10 +350,10 @@ static void nla_panel_stripname(const bContext *C, Panel *pa)
}
/* generic settings for active NLA-Strip */
-static void nla_panel_properties(const bContext *C, Panel *pa)
+static void nla_panel_properties(const bContext *C, Panel *panel)
{
PointerRNA strip_ptr;
- uiLayout *layout = pa->layout;
+ uiLayout *layout = panel->layout;
uiLayout *column;
uiBlock *block;
short showEvalProps = 1;
@@ -419,10 +419,10 @@ static void nla_panel_properties(const bContext *C, Panel *pa)
}
/* action-clip only settings for active NLA-Strip */
-static void nla_panel_actclip(const bContext *C, Panel *pa)
+static void nla_panel_actclip(const bContext *C, Panel *panel)
{
PointerRNA strip_ptr;
- uiLayout *layout = pa->layout;
+ uiLayout *layout = panel->layout;
uiLayout *column, *row;
uiBlock *block;
@@ -461,10 +461,10 @@ static void nla_panel_actclip(const bContext *C, Panel *pa)
}
/* evaluation settings for active NLA-Strip */
-static void nla_panel_animated_influence_header(const bContext *C, Panel *pa)
+static void nla_panel_animated_influence_header(const bContext *C, Panel *panel)
{
PointerRNA strip_ptr;
- uiLayout *layout = pa->layout;
+ uiLayout *layout = panel->layout;
uiLayout *col;
uiBlock *block;
@@ -481,10 +481,10 @@ static void nla_panel_animated_influence_header(const bContext *C, Panel *pa)
}
/* evaluation settings for active NLA-Strip */
-static void nla_panel_evaluation(const bContext *C, Panel *pa)
+static void nla_panel_evaluation(const bContext *C, Panel *panel)
{
PointerRNA strip_ptr;
- uiLayout *layout = pa->layout;
+ uiLayout *layout = panel->layout;
uiBlock *block;
/* check context and also validity of pointer */
@@ -500,10 +500,10 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa)
uiItemR(layout, &strip_ptr, "influence", 0, NULL, ICON_NONE);
}
-static void nla_panel_animated_strip_time_header(const bContext *C, Panel *pa)
+static void nla_panel_animated_strip_time_header(const bContext *C, Panel *panel)
{
PointerRNA strip_ptr;
- uiLayout *layout = pa->layout;
+ uiLayout *layout = panel->layout;
uiLayout *col;
uiBlock *block;
@@ -519,10 +519,10 @@ static void nla_panel_animated_strip_time_header(const bContext *C, Panel *pa)
uiItemR(col, &strip_ptr, "use_animated_time", 0, "", ICON_NONE);
}
-static void nla_panel_animated_strip_time(const bContext *C, Panel *pa)
+static void nla_panel_animated_strip_time(const bContext *C, Panel *panel)
{
PointerRNA strip_ptr;
- uiLayout *layout = pa->layout;
+ uiLayout *layout = panel->layout;
uiBlock *block;
/* check context and also validity of pointer */
@@ -539,7 +539,7 @@ static void nla_panel_animated_strip_time(const bContext *C, Panel *pa)
}
/* F-Modifiers for active NLA-Strip */
-static void nla_panel_modifiers(const bContext *C, Panel *pa)
+static void nla_panel_modifiers(const bContext *C, Panel *panel)
{
PointerRNA strip_ptr;
NlaStrip *strip;
@@ -553,12 +553,12 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa)
}
strip = strip_ptr.data;
- block = uiLayoutGetBlock(pa->layout);
+ block = uiLayoutGetBlock(panel->layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
/* 'add modifier' button at top of panel */
{
- row = uiLayoutRow(pa->layout, false);
+ row = uiLayoutRow(panel->layout, false);
block = uiLayoutGetBlock(row);
// FIXME: we need to set the only-active property so that this
@@ -574,7 +574,7 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa)
/* draw each modifier */
for (fcm = strip->modifiers.first; fcm; fcm = fcm->next) {
- col = uiLayoutColumn(pa->layout, true);
+ col = uiLayoutColumn(panel->layout, true);
ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.owner_id, &strip->modifiers, fcm);
}
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index a69aed38cab..5adcec8a5d7 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -33,7 +33,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_nla.h"
@@ -146,7 +146,7 @@ static int mouse_nla_channels(
else {
/* deselect all */
/* TODO: should this deselect all other types of channels too? */
- for (Base *b = view_layer->object_bases.first; b; b = b->next) {
+ LISTBASE_FOREACH (Base *, b, &view_layer->object_bases) {
ED_object_base_select(b, BA_DESELECT);
if (b->object->adt) {
b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 4ccf752a916..5c4ccd96534 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -150,7 +150,7 @@ static void nla_action_draw_keyframes(
/* - disregard the selection status of keyframes so they draw a certain way
* - size is 6.0f which is smaller than the editable keyframes, so that there is a distinction
*/
- for (ActKeyColumn *ak = keys.first; ak; ak = ak->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, ak, &keys) {
draw_keyframe_shape(ak->cfra,
y,
6.0f,
@@ -207,7 +207,7 @@ static void nla_actionclip_draw_markers(
immUniformThemeColorShade(TH_STRIP_SELECT, shade);
immBeginAtMost(GPU_PRIM_LINES, BLI_listbase_count(&act->markers) * 2);
- for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) {
float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP);
@@ -238,7 +238,7 @@ static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc)
/* just a solid color, so that it is very easy to spot */
int shade = 20;
/* draw the markers in the first level of strips only (if they are actions) */
- for (NlaStrip *nls = strip->strips.first; nls; nls = nls->next) {
+ LISTBASE_FOREACH (NlaStrip *, nls, &strip->strips) {
if (nls->type == NLASTRIP_TYPE_CLIP) {
nla_actionclip_draw_markers(nls, yminc, ymaxc, shade, false);
}
@@ -313,7 +313,7 @@ static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float col
}
/* helper call for drawing influence/time control curves for a given NLA-strip */
-static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, unsigned int pos)
+static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uint pos)
{
const float yheight = ymaxc - yminc;
@@ -565,7 +565,7 @@ static void nla_draw_strip(SpaceNla *snla,
immBeginAtMost(GPU_PRIM_LINES, 4 * BLI_listbase_count(&strip->strips));
/* only draw first-level of child-strips, but don't draw any lines on the endpoints */
- for (NlaStrip *cs = strip->strips.first; cs; cs = cs->next) {
+ LISTBASE_FOREACH (NlaStrip *, cs, &strip->strips) {
/* draw start-line if not same as end of previous (and only if not the first strip)
* - on upper half of strip
*/
@@ -828,7 +828,7 @@ void draw_nla_channel_list(const 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->sa, v2d, V2D_LOCK_COPY);
+ UI_view2d_sync(NULL, ac->area, v2d, V2D_LOCK_COPY);
/* draw channels */
{ /* first pass: just the standard GL-drawing for backdrop + text */
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 2427001657a..5b949911158 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -1506,7 +1506,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip, *stripN = NULL;
- NlaStrip *sa = NULL, *sb = NULL;
+ NlaStrip *area = NULL, *sb = NULL;
/* make temporary metastrips so that entire islands of selections can be moved around */
BKE_nlastrips_make_metas(&nlt->strips, 1);
@@ -1533,9 +1533,9 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* first or second strip? */
- if (sa == NULL) {
+ if (area == NULL) {
/* store as first */
- sa = strip;
+ area = strip;
}
else if (sb == NULL) {
/* store as second */
@@ -1556,7 +1556,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
"Too many clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected",
nlt->name);
}
- else if (sa == NULL) {
+ else if (area == NULL) {
/* no warning as this is just a common case,
* and it may get annoying when doing multiple tracks */
}
@@ -1573,24 +1573,24 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
/* remove these strips from the track,
* so that we can test if they can fit in the proposed places */
- BLI_remlink(&nlt->strips, sa);
+ BLI_remlink(&nlt->strips, area);
BLI_remlink(&nlt->strips, sb);
/* calculate new extents for strips */
/* a --> b */
nsa[0] = sb->start;
- nsa[1] = sb->start + (sa->end - sa->start);
+ nsa[1] = sb->start + (area->end - area->start);
/* b --> a */
- nsb[0] = sa->start;
- nsb[1] = sa->start + (sb->end - sb->start);
+ nsb[0] = area->start;
+ nsb[1] = area->start + (sb->end - sb->start);
/* check if the track has room for the strips to be swapped */
if (BKE_nlastrips_has_space(&nlt->strips, nsa[0], nsa[1]) &&
BKE_nlastrips_has_space(&nlt->strips, nsb[0], nsb[1])) {
/* set new extents for strips then */
- sa->start = nsa[0];
- sa->end = nsa[1];
- BKE_nlameta_flush_transforms(sa);
+ area->start = nsa[0];
+ area->end = nsa[1];
+ BKE_nlameta_flush_transforms(area);
sb->start = nsb[0];
sb->end = nsb[1];
@@ -1598,7 +1598,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
}
else {
/* not enough room to swap, so show message */
- if ((sa->flag & NLASTRIP_FLAG_TEMP_META) || (sb->flag & NLASTRIP_FLAG_TEMP_META)) {
+ if ((area->flag & NLASTRIP_FLAG_TEMP_META) || (sb->flag & NLASTRIP_FLAG_TEMP_META)) {
BKE_report(
op->reports,
RPT_WARNING,
@@ -1609,13 +1609,13 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
RPT_WARNING,
"Cannot swap '%s' and '%s' as one or both will not be able to fit in their "
"new places",
- sa->name,
+ area->name,
sb->name);
}
}
/* add strips back to track now */
- BKE_nlatrack_add_strip(nlt, sa);
+ BKE_nlatrack_add_strip(nlt, area);
BKE_nlatrack_add_strip(nlt, sb);
}
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index 09abfc300c7..ec41368b9f0 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -308,7 +308,7 @@ static void nlaedit_strip_at_region_position(
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
- for (NlaStrip *strip = nlt->strips.first; strip; strip = strip->next) {
+ LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) {
*r_ale = ale;
*r_strip = strip;
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index c4e1431ee26..f060693d9f4 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -57,7 +57,7 @@
/* ******************** default callbacks for nla space ***************** */
-static SpaceLink *nla_new(const ScrArea *sa, const Scene *scene)
+static SpaceLink *nla_new(const ScrArea *area, const Scene *scene)
{
ARegion *region;
SpaceNla *snla;
@@ -105,7 +105,7 @@ static SpaceLink *nla_new(const ScrArea *sa, const Scene *scene)
region->regiontype = RGN_TYPE_WINDOW;
region->v2d.tot.xmin = (float)(SFRA - 10);
- region->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
+ region->v2d.tot.ymin = (float)(-area->winy) / 3.0f;
region->v2d.tot.xmax = (float)(EFRA + 10);
region->v2d.tot.ymax = 0.0f;
@@ -141,9 +141,9 @@ static void nla_free(SpaceLink *sl)
}
/* spacetype; init callback */
-static void nla_init(struct wmWindowManager *wm, ScrArea *sa)
+static void nla_init(struct wmWindowManager *wm, ScrArea *area)
{
- SpaceNla *snla = (SpaceNla *)sa->spacedata.first;
+ SpaceNla *snla = (SpaceNla *)area->spacedata.first;
/* init dopesheet data if non-existent (i.e. for old files) */
if (snla->ads == NULL) {
@@ -151,7 +151,7 @@ static void nla_init(struct wmWindowManager *wm, ScrArea *sa)
snla->ads->source = (ID *)WM_window_get_active_scene(wm->winactive);
}
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
static SpaceLink *nla_duplicate(SpaceLink *sl)
@@ -325,7 +325,7 @@ static void nla_buttons_region_draw(const bContext *C, ARegion *region)
}
static void nla_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -365,7 +365,7 @@ static void nla_region_listener(wmWindow *UNUSED(win),
}
static void nla_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -427,12 +427,12 @@ static void nla_main_region_message_subscribe(const struct bContext *UNUSED(C),
struct WorkSpace *UNUSED(workspace),
struct Scene *scene,
struct bScreen *screen,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus)
{
PointerRNA ptr;
- RNA_pointer_create(&screen->id, &RNA_SpaceNLA, sa->spacedata.first, &ptr);
+ RNA_pointer_create(&screen->id, &RNA_SpaceNLA, area->spacedata.first, &ptr);
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
@@ -466,7 +466,7 @@ static void nla_main_region_message_subscribe(const struct bContext *UNUSED(C),
}
static void nla_channel_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -512,12 +512,12 @@ static void nla_channel_region_message_subscribe(const struct bContext *UNUSED(C
struct WorkSpace *UNUSED(workspace),
struct Scene *UNUSED(scene),
struct bScreen *screen,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus)
{
PointerRNA ptr;
- RNA_pointer_create(&screen->id, &RNA_SpaceNLA, sa->spacedata.first, &ptr);
+ RNA_pointer_create(&screen->id, &RNA_SpaceNLA, area->spacedata.first, &ptr);
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
@@ -543,24 +543,27 @@ static void nla_channel_region_message_subscribe(const struct bContext *UNUSED(C
}
/* editor level listener */
-static void nla_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
+static void nla_listener(wmWindow *UNUSED(win),
+ ScrArea *area,
+ wmNotifier *wmn,
+ Scene *UNUSED(scene))
{
/* context changes */
switch (wmn->category) {
case NC_ANIMATION:
// TODO: filter specific types of changes?
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
case NC_SCENE:
#if 0
switch (wmn->data) {
case ND_OB_ACTIVE:
case ND_OB_SELECT:
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
}
#endif
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
case NC_OBJECT:
switch (wmn->data) {
@@ -568,19 +571,19 @@ static void nla_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Sc
/* do nothing */
break;
default:
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
}
break;
case NC_SPACE:
if (wmn->data == ND_SPACE_NLA) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
}
}
-static void nla_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
+static void nla_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
{
SpaceNla *snla = (SpaceNla *)slink;
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 55a5a043014..e5ca2efb26f 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3133,7 +3133,7 @@ static void node_property_update_default(Main *bmain, Scene *UNUSED(scene), Poin
static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocketTemplate *stemp)
{
- StructRNA *srna = ntype->ext.srna;
+ StructRNA *srna = ntype->rna_ext.srna;
PropertyRNA *prop = RNA_struct_type_find_property(srna, stemp->identifier);
if (prop) {
diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c
index ee1d2b43c5f..4cf67dddb57 100644
--- a/source/blender/editors/space_node/node_buttons.c
+++ b/source/blender/editors/space_node/node_buttons.c
@@ -66,13 +66,13 @@ static bool node_sockets_poll(const bContext *C, PanelType *UNUSED(pt))
return (snode && snode->nodetree && G.debug_value == 777);
}
-static void node_sockets_panel(const bContext *C, Panel *pa)
+static void node_sockets_panel(const bContext *C, Panel *panel)
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = (snode) ? snode->edittree : NULL;
bNode *node = (ntree) ? nodeGetActive(ntree) : NULL;
bNodeSocket *sock;
- uiLayout *layout = pa->layout, *split;
+ uiLayout *layout = panel->layout, *split;
char name[UI_MAX_NAME_STR];
if (ELEM(NULL, ntree, node)) {
@@ -119,13 +119,13 @@ static bool node_tree_find_active_socket(bNodeTree *ntree, bNodeSocket **r_sock,
return false;
}
-static void node_tree_interface_panel(const bContext *C, Panel *pa)
+static void node_tree_interface_panel(const bContext *C, Panel *panel)
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = (snode) ? snode->edittree : NULL;
bNodeSocket *sock;
int in_out;
- uiLayout *layout = pa->layout, *row, *split, *col;
+ uiLayout *layout = panel->layout, *row, *split, *col;
PointerRNA ptr, sockptr, opptr;
wmOperatorType *ot;
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index e50f5a818aa..a82acfc4dbe 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -127,12 +127,12 @@ static int compo_get_recalc_flags(const bContext *C)
int recalc_flags = 0;
for (win = wm->windows.first; win; win = win->next) {
- const bScreen *sc = WM_window_get_active_screen(win);
- ScrArea *sa;
+ const bScreen *screen = WM_window_get_active_screen(win);
+ ScrArea *area;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- if (sa->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = sa->spacedata.first;
+ for (area = screen->areabase.first; area; area = area->next) {
+ if (area->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = area->spacedata.first;
if (sima->image) {
if (sima->image->type == IMA_TYPE_R_RESULT) {
recalc_flags |= COM_RECALC_COMPOSITE;
@@ -142,8 +142,8 @@ static int compo_get_recalc_flags(const bContext *C)
}
}
}
- else if (sa->spacetype == SPACE_NODE) {
- SpaceNode *snode = sa->spacedata.first;
+ else if (area->spacetype == SPACE_NODE) {
+ SpaceNode *snode = area->spacedata.first;
if (snode->flag & SNODE_BACKDRAW) {
recalc_flags |= COM_RECALC_VIEWER;
}
@@ -1326,7 +1326,7 @@ void NODE_OT_duplicate(wmOperatorType *ot)
bool ED_node_select_check(ListBase *lb)
{
- for (bNode *node = lb->first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, lb) {
if (node->flag & NODE_SELECT) {
return true;
}
@@ -1346,7 +1346,7 @@ void ED_node_select_all(ListBase *lb, int action)
}
}
- for (bNode *node = lb->first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, lb) {
switch (action) {
case SEL_SELECT:
nodeSetSelected(node, true);
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 5dc98a3905a..8f8f945a600 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -30,7 +30,7 @@
#include "BLI_easing.h"
#include "BLI_math.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_context.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
@@ -466,7 +466,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
if (tonode) {
/* Find a selected socket that overrides the socket to connect to */
- for (bNodeSocket *sock2 = tonode->outputs.first; sock2; sock2 = sock2->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock2, &tonode->outputs) {
if (!nodeSocketIsHidden(sock2) && sock2->flag & SELECT) {
sock = sock2;
break;
@@ -1446,9 +1446,12 @@ void NODE_OT_detach(wmOperatorType *ot)
/* ********************* automatic node insert on dragging ******************* */
/* prevent duplicate testing code below */
-static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode, bNode **r_select)
+static bool ed_node_link_conditions(ScrArea *area,
+ bool test,
+ SpaceNode **r_snode,
+ bNode **r_select)
{
- SpaceNode *snode = sa ? sa->spacedata.first : NULL;
+ SpaceNode *snode = area ? area->spacedata.first : NULL;
bNode *node, *select = NULL;
bNodeLink *link;
@@ -1456,7 +1459,7 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode,
*r_select = NULL;
/* no unlucky accidents */
- if (sa == NULL || sa->spacetype != SPACE_NODE) {
+ if (area == NULL || area->spacetype != SPACE_NODE) {
return false;
}
@@ -1501,14 +1504,14 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode,
}
/* test == 0, clear all intersect flags */
-void ED_node_link_intersect_test(ScrArea *sa, int test)
+void ED_node_link_intersect_test(ScrArea *area, int test)
{
bNode *select;
SpaceNode *snode;
bNodeLink *link, *selink = NULL;
float dist_best = FLT_MAX;
- if (!ed_node_link_conditions(sa, test, &snode, &select)) {
+ if (!ed_node_link_conditions(area, test, &snode, &select)) {
return;
}
@@ -1919,14 +1922,14 @@ void NODE_OT_insert_offset(wmOperatorType *ot)
}
/* assumes link with NODE_LINKFLAG_HILITE set */
-void ED_node_link_insert(Main *bmain, ScrArea *sa)
+void ED_node_link_insert(Main *bmain, ScrArea *area)
{
bNode *node, *select;
SpaceNode *snode;
bNodeLink *link;
bNodeSocket *sockto;
- if (!ed_node_link_conditions(sa, true, &snode, &select)) {
+ if (!ed_node_link_conditions(area, true, &snode, &select)) {
return;
}
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 98fcf862290..38ec855e845 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -26,6 +26,7 @@
#include "DNA_node_types.h"
#include "BLI_lasso_2d.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "BLI_string.h"
@@ -284,7 +285,7 @@ static bool node_select_grouped_name(SpaceNode *snode, bNode *node_act, const bo
{
bNode *node;
bool changed = false;
- const unsigned int delims[] = {'.', '-', '_', '\0'};
+ const uint delims[] = {'.', '-', '_', '\0'};
size_t pref_len_act, pref_len_curr;
const char *sep, *suf_act, *suf_curr;
@@ -622,7 +623,7 @@ static int node_box_select_exec(bContext *C, wmOperator *op)
ED_node_select_all(&snode->edittree->nodes, SEL_DESELECT);
}
- for (bNode *node = snode->edittree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
bool is_inside;
if (node->type == NODE_FRAME) {
is_inside = BLI_rctf_inside_rctf(&rectf, &node->totr);
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index 9283b073e86..5bdca04856b 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -382,7 +382,7 @@ typedef struct ImageSampleInfo {
int x, y;
int channels;
- unsigned char col[4];
+ uchar col[4];
float colf[4];
float linearcol[4];
@@ -450,7 +450,7 @@ bool ED_space_node_color_sample(
if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
const float *fp;
- unsigned char *cp;
+ uchar *cp;
int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
CLAMP(x, 0, ibuf->x - 1);
@@ -463,7 +463,7 @@ bool ED_space_node_color_sample(
ret = true;
}
else if (ibuf->rect) {
- cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
+ cp = (uchar *)(ibuf->rect + y * ibuf->x + x);
rgb_uchar_to_float(r_col, cp);
IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace);
ret = true;
@@ -507,7 +507,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
const float *fp;
- unsigned char *cp;
+ uchar *cp;
int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
CLAMP(x, 0, ibuf->x - 1);
@@ -522,7 +522,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
info->zfp = NULL;
if (ibuf->rect) {
- cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
+ cp = (uchar *)(ibuf->rect + y * ibuf->x + x);
info->col[0] = cp[0];
info->col[1] = cp[1];
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 32007d5b971..d682cab7293 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -328,17 +328,17 @@ static void node_free(SpaceLink *sl)
}
/* spacetype; init callback */
-static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
static void node_area_listener(wmWindow *UNUSED(win),
- ScrArea *sa,
+ ScrArea *area,
wmNotifier *wmn,
Scene *UNUSED(scene))
{
/* note, ED_area_tag_refresh will re-execute compositor */
- SpaceNode *snode = sa->spacedata.first;
+ SpaceNode *snode = area->spacedata.first;
/* shaderfrom is only used for new shading nodes, otherwise all shaders are from objects */
short shader_type = snode->shaderfrom;
@@ -347,32 +347,32 @@ static void node_area_listener(wmWindow *UNUSED(win),
case NC_SCENE:
switch (wmn->data) {
case ND_NODES: {
- ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
bNodeTreePath *path = snode->treepath.last;
/* shift view to node tree center */
if (region && path) {
UI_view2d_center_set(&region->v2d, path->view_center[0], path->view_center[1]);
}
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
}
case ND_FRAME:
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
case ND_COMPO_RESULT:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
case ND_TRANSFORM_DONE:
if (ED_node_is_compositor(snode)) {
if (snode->flag & SNODE_AUTO_RENDER) {
snode->recalc = 1;
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
}
break;
case ND_LAYER_CONTENT:
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
}
break;
@@ -381,13 +381,13 @@ static void node_area_listener(wmWindow *UNUSED(win),
case NC_MATERIAL:
if (ED_node_is_shader(snode)) {
if (wmn->data == ND_SHADING) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
else if (wmn->data == ND_SHADING_DRAW) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
else if (wmn->data == ND_SHADING_LINKS) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
else if (wmn->action == NA_ADDED && snode->edittree) {
nodeSetActiveID(snode->edittree, ID_MA, wmn->reference);
@@ -397,49 +397,49 @@ static void node_area_listener(wmWindow *UNUSED(win),
case NC_TEXTURE:
if (ED_node_is_shader(snode) || ED_node_is_texture(snode)) {
if (wmn->data == ND_NODES) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
}
break;
case NC_WORLD:
if (ED_node_is_shader(snode) && shader_type == SNODE_SHADER_WORLD) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
break;
case NC_OBJECT:
if (ED_node_is_shader(snode)) {
if (wmn->data == ND_OB_SHADING) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
}
break;
case NC_SPACE:
if (wmn->data == ND_SPACE_NODE) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
else if (wmn->data == ND_SPACE_NODE_VIEW) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
case NC_NODE:
if (wmn->action == NA_EDITED) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
else if (wmn->action == NA_SELECTED) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
case NC_SCREEN:
switch (wmn->data) {
case ND_ANIMPLAY:
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
}
break;
case NC_MASK:
if (wmn->action == NA_EDITED) {
if (snode->nodetree && snode->nodetree->type == NTREE_COMPOSIT) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
}
break;
@@ -451,7 +451,7 @@ static void node_area_listener(wmWindow *UNUSED(win),
* scenes so really this is just to know if the images is used in the compo else
* painting on images could become very slow when the compositor is open. */
if (nodeUpdateID(snode->nodetree, wmn->reference)) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
}
}
@@ -461,7 +461,7 @@ static void node_area_listener(wmWindow *UNUSED(win),
if (wmn->action == NA_EDITED) {
if (ED_node_is_compositor(snode)) {
if (nodeUpdateID(snode->nodetree, wmn->reference)) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
}
}
@@ -469,26 +469,26 @@ static void node_area_listener(wmWindow *UNUSED(win),
case NC_LINESTYLE:
if (ED_node_is_shader(snode) && shader_type == SNODE_SHADER_LINESTYLE) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
break;
case NC_WM:
if (wmn->data == ND_UNDO) {
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
}
break;
case NC_GPENCIL:
if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
}
}
-static void node_area_refresh(const struct bContext *C, ScrArea *sa)
+static void node_area_refresh(const struct bContext *C, ScrArea *area)
{
/* default now: refresh node is starting preview */
- SpaceNode *snode = sa->spacedata.first;
+ SpaceNode *snode = area->spacedata.first;
snode_set_context(C);
@@ -497,19 +497,19 @@ static void node_area_refresh(const struct bContext *C, ScrArea *sa)
if (GS(snode->id->name) == ID_MA) {
Material *ma = (Material *)snode->id;
if (ma->use_nodes) {
- ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
+ ED_preview_shader_job(C, area, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
}
}
else if (GS(snode->id->name) == ID_LA) {
Light *la = (Light *)snode->id;
if (la->use_nodes) {
- ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
+ ED_preview_shader_job(C, area, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
}
}
else if (GS(snode->id->name) == ID_WO) {
World *wo = (World *)snode->id;
if (wo->use_nodes) {
- ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
+ ED_preview_shader_job(C, area, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
}
}
}
@@ -529,7 +529,7 @@ static void node_area_refresh(const struct bContext *C, ScrArea *sa)
else if (snode->nodetree->type == NTREE_TEXTURE) {
Tex *tex = (Tex *)snode->id;
if (tex->use_nodes) {
- ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
+ ED_preview_shader_job(C, area, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
}
}
}
@@ -585,9 +585,9 @@ static void node_toolbar_region_draw(const bContext *C, ARegion *region)
ED_region_panels(C, region);
}
-static void node_cursor(wmWindow *win, ScrArea *sa, ARegion *region)
+static void node_cursor(wmWindow *win, ScrArea *area, ARegion *region)
{
- SpaceNode *snode = sa->spacedata.first;
+ SpaceNode *snode = area->spacedata.first;
/* convert mouse coordinates to v2d space */
UI_view2d_region_to_view(&region->v2d,
@@ -702,7 +702,7 @@ static void node_header_region_draw(const bContext *C, ARegion *region)
/* used for header + main region */
static void node_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -851,7 +851,7 @@ static void node_widgets(void)
WM_gizmogrouptype_append_and_link(gzmap_type, NODE_GGT_backdrop_corner_pin);
}
-static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
+static void node_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
{
SpaceNode *snode = (SpaceNode *)slink;
@@ -922,15 +922,15 @@ static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID
}
}
-static int node_space_subtype_get(ScrArea *sa)
+static int node_space_subtype_get(ScrArea *area)
{
- SpaceNode *snode = sa->spacedata.first;
+ SpaceNode *snode = area->spacedata.first;
return rna_node_tree_idname_to_enum(snode->tree_idname);
}
-static void node_space_subtype_set(ScrArea *sa, int value)
+static void node_space_subtype_set(ScrArea *area, int value)
{
- SpaceNode *snode = sa->spacedata.first;
+ SpaceNode *snode = area->spacedata.first;
ED_node_set_tree_type(snode, rna_node_tree_type_from_enum(value));
}
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 8563b7d8c24..5a0ed954909 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -336,8 +336,7 @@ static int collection_delete_exec(bContext *C, wmOperator *op)
skip = true;
}
else {
- for (CollectionParent *cparent = collection->parents.first; cparent;
- cparent = cparent->next) {
+ LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) {
Collection *parent = cparent->collection;
if (ID_IS_LINKED(parent)) {
skip = true;
@@ -848,7 +847,7 @@ static bool collections_indirect_only_clear_poll(bContext *C)
static void layer_collection_flag_recursive_set(LayerCollection *lc, int flag)
{
- for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
+ LISTBASE_FOREACH (LayerCollection *, nlc, &lc->layer_collections) {
if (lc->flag & flag) {
nlc->flag |= flag;
}
@@ -1468,14 +1467,13 @@ static int outliner_unhide_all_exec(bContext *C, wmOperator *UNUSED(op))
/* Unhide all the collections. */
LayerCollection *lc_master = view_layer->layer_collections.first;
- for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) {
lc_iter->flag &= ~LAYER_COLLECTION_HIDE;
layer_collection_flag_recursive_set(lc_iter, LAYER_COLLECTION_HIDE);
}
/* Unhide all objects. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
base->flag &= ~BASE_HIDDEN;
}
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index 6f071ca128e..b6f5ac25c3c 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -263,8 +263,7 @@ static bool parent_drop_allowed(TreeElement *te, Object *potential_child)
* element for object it means that all displayed objects belong to
* active scene and parenting them is allowed (sergey) */
if (scene) {
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
if (BKE_view_layer_base_find(view_layer, potential_child)) {
return true;
}
@@ -481,7 +480,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven
ListBase *lb = event->customdata;
wmDrag *drag = lb->first;
- for (wmDragID *drag_id = drag->ids.first; drag_id; drag_id = drag_id->next) {
+ LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) {
if (GS(drag_id->id->name) == ID_OB) {
Object *object = (Object *)drag_id->id;
@@ -548,8 +547,7 @@ static int scene_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
BKE_collection_object_add(bmain, collection, ob);
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (base) {
ED_object_base_select(base, BA_SELECT);
@@ -817,7 +815,7 @@ static int collection_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmE
TREESTORE(data.te)->flag &= ~TSE_CLOSED;
}
- for (wmDragID *drag_id = drag->ids.first; drag_id; drag_id = drag_id->next) {
+ LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) {
/* Ctrl enables linking, so we don't need a from collection then. */
Collection *from = (event->ctrl) ? NULL : collection_parent_from_ID(drag_id->from_parent);
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 838b86149dc..9030bdb1d58 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -91,7 +91,7 @@ static void outliner_tree_dimensions_impl(SpaceOutliner *soops,
int *width,
int *height)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
*width = MAX2(*width, te->xend);
if (height != NULL) {
*height += UI_UNIT_Y;
@@ -387,8 +387,7 @@ static void outliner_collection_set_flag_recursive(Scene *scene,
if (base_or_object_prop) {
/* Note: We can't use BKE_collection_object_cache_get()
* otherwise we would not take collection exclusion into account. */
- for (CollectionObject *cob = layer_collection->collection->gobject.first; cob;
- cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &layer_collection->collection->gobject) {
outliner_base_or_object_pointer_create(view_layer, collection, cob->ob, &ptr);
RNA_property_boolean_set(&ptr, base_or_object_prop, value);
@@ -401,7 +400,7 @@ static void outliner_collection_set_flag_recursive(Scene *scene,
/* Keep going recursively. */
ListBase *lb = (layer_collection ? &layer_collection->layer_collections : &collection->children);
- for (Link *link = lb->first; link; link = link->next) {
+ LISTBASE_FOREACH (Link *, link, lb) {
LayerCollection *layer_collection_iter = layer_collection ? (LayerCollection *)link : NULL;
Collection *collection_iter = layer_collection ?
(collection ? layer_collection_iter->collection : NULL) :
@@ -467,7 +466,7 @@ static bool outliner_collection_is_isolated(Scene *scene,
/* Keep going recursively. */
ListBase *lb = (layer_collection ? &layer_collection->layer_collections : &collection->children);
- for (Link *link = lb->first; link; link = link->next) {
+ LISTBASE_FOREACH (Link *, link, lb) {
LayerCollection *layer_collection_iter = layer_collection ? (LayerCollection *)link : NULL;
Collection *collection_iter = layer_collection ?
(collection ? layer_collection_iter->collection : NULL) :
@@ -542,8 +541,7 @@ void outliner_collection_isolate_flag(Scene *scene,
/* Make this collection direct parents also "visible". */
if (layer_collection) {
LayerCollection *lc_parent = layer_collection;
- for (LayerCollection *lc_iter = top_layer_collection->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &top_layer_collection->layer_collections) {
if (BKE_layer_collection_has_layer_collection(lc_iter, layer_collection)) {
lc_parent = lc_iter;
break;
@@ -555,8 +553,7 @@ void outliner_collection_isolate_flag(Scene *scene,
scene, lc_parent, collection ? lc_parent->collection : NULL, &ptr);
RNA_property_boolean_set(&ptr, layer_or_collection_prop, !is_hide);
- for (LayerCollection *lc_iter = lc_parent->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_parent->layer_collections) {
if (BKE_layer_collection_has_layer_collection(lc_iter, layer_collection)) {
lc_parent = lc_iter;
break;
@@ -1054,7 +1051,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
/* Create buttons. */
uiBut *bt;
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
RestrictPropertiesActive props_active = props_active_parent;
@@ -1651,7 +1648,7 @@ static void outliner_draw_userbuts(uiBlock *block,
ListBase *lb)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) {
if (tselem->type == 0) {
@@ -1770,7 +1767,7 @@ static void outliner_draw_rnabuts(
PointerRNA *ptr;
PropertyRNA *prop;
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) {
if (tselem->type == TSE_RNA_PROPERTY) {
@@ -2865,7 +2862,7 @@ static void outliner_draw_iconrow(bContext *C,
{
eOLDrawState active = OL_DRAWSEL_NONE;
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
/* object hierarchy always, further constrained on level */
@@ -3208,7 +3205,7 @@ static void outliner_draw_tree_element(bContext *C,
if (TSELEM_OPEN(tselem, soops)) {
*starty -= UI_UNIT_Y;
- for (TreeElement *ten = te->subtree.first; ten; ten = ten->next) {
+ LISTBASE_FOREACH (TreeElement *, ten, &te->subtree) {
/* check if element needs to be drawn grayed out, but also gray out
* childs of a grayed out parent (pass on draw_grayed_out to childs) */
bool draw_childs_grayed_out = draw_grayed_out || (ten->flag & TE_DRAGGING);
@@ -3227,7 +3224,7 @@ static void outliner_draw_tree_element(bContext *C,
}
}
else {
- for (TreeElement *ten = te->subtree.first; ten; ten = ten->next) {
+ LISTBASE_FOREACH (TreeElement *, ten, &te->subtree) {
outliner_set_coord_tree_element(ten, startx, *starty);
}
@@ -3361,7 +3358,7 @@ static void outliner_draw_struct_marks(ARegion *region,
ListBase *lb,
int *starty)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
/* selection status */
@@ -3410,7 +3407,7 @@ static void outliner_draw_highlights_recursive(uint pos,
const bool is_searching = (SEARCHING_OUTLINER(soops) ||
(soops->outlinevis == SO_DATA_API && soops->search_string[0] != 0));
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
const TreeStoreElem *tselem = TREESTORE(te);
const int start_y = *io_start_y;
@@ -3559,7 +3556,7 @@ static void outliner_draw_tree(bContext *C,
// items themselves
starty = (int)region->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET;
startx = 0;
- for (TreeElement *te = soops->tree.first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, &soops->tree) {
outliner_draw_tree_element(C,
block,
fstyle,
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 57bf34f1e18..60e6b423720 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -1292,7 +1292,7 @@ static void outliner_show_active(SpaceOutliner *so, ARegion *region, TreeElement
return;
}
- for (TreeElement *ten = te->subtree.first; ten; ten = ten->next) {
+ LISTBASE_FOREACH (TreeElement *, ten, &te->subtree) {
outliner_show_active(so, region, ten, id);
}
}
@@ -1310,7 +1310,7 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
ID *id = TREESTORE(active_element)->id;
/* Expand all elements in the outliner with matching ID */
- for (TreeElement *te = so->tree.first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, &so->tree) {
outliner_show_active(so, region, te, id);
}
@@ -1675,8 +1675,8 @@ void OUTLINER_OT_show_hierarchy(wmOperatorType *ot)
/* specialized poll callback for these operators to work in Datablocks view only */
static bool ed_operator_outliner_datablocks_active(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- if ((sa) && (sa->spacetype == SPACE_OUTLINER)) {
+ ScrArea *area = CTX_wm_area(C);
+ if ((area) && (area->spacetype == SPACE_OUTLINER)) {
SpaceOutliner *so = CTX_wm_space_outliner(C);
return (so->outlinevis == SO_DATA_API);
}
@@ -2179,8 +2179,8 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot)
static bool ed_operator_outliner_id_orphans_active(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- if (sa != NULL && sa->spacetype == SPACE_OUTLINER) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area != NULL && area->spacetype == SPACE_OUTLINER) {
SpaceOutliner *so = CTX_wm_space_outliner(C);
return (so->outlinevis == SO_ID_ORPHANS);
}
@@ -2249,7 +2249,7 @@ static int outliner_orphans_purge_invoke(bContext *C, wmOperator *op, const wmEv
static int outliner_orphans_purge_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceOutliner *soops = CTX_wm_space_outliner(C);
int num_tagged[INDEX_ID_MAX] = {0};
@@ -2276,7 +2276,7 @@ static int outliner_orphans_purge_exec(bContext *C, wmOperator *op)
* outliner several mouse events can be handled in one cycle without
* handling notifiers/redraw which leads to deleting the same object twice.
* cleanup tree here to prevent such cases. */
- if ((sa != NULL) && (sa->spacetype == SPACE_OUTLINER)) {
+ if ((area != NULL) && (area->spacetype == SPACE_OUTLINER)) {
outliner_cleanup_tree(soops);
}
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index fb40ae195ef..90092817acc 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -193,7 +193,8 @@ typedef enum {
/* is the current element open? if so we also show children */
#define TSELEM_OPEN(telm, sv) \
- ((telm->flag & TSE_CLOSED) == 0 || (SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH)))
+ (((telm)->flag & TSE_CLOSED) == 0 || \
+ (SEARCHING_OUTLINER(sv) && ((telm)->flag & TSE_CHILDSEARCH)))
/**
* Container to avoid passing around these variables to many functions.
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index d50a097e6f6..ec1595eb930 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1252,7 +1252,7 @@ static bool do_outliner_range_select_recursive(ListBase *lb,
TreeElement *cursor,
bool selecting)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
if (selecting) {
@@ -1496,7 +1496,7 @@ static int outliner_box_select_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rctf(op, &rectf);
UI_view2d_region_to_view_rctf(&region->v2d, &rectf, &rectf);
- for (TreeElement *te = soops->tree.first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, &soops->tree) {
outliner_item_box_select(soops, scene, &rectf, te, select);
}
diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c
index 745a527cc15..35dd91ff061 100644
--- a/source/blender/editors/space_outliner/outliner_sync.c
+++ b/source/blender/editors/space_outliner/outliner_sync.c
@@ -32,6 +32,7 @@
#include "BLI_compiler_compat.h"
#include "BLI_ghash.h"
+#include "BLI_listbase.h"
#include "BKE_armature.h"
#include "BKE_context.h"
@@ -95,8 +96,8 @@ void ED_outliner_select_sync_flag_outliners(const bContext *C)
wmWindowManager *wm = CTX_wm_manager(C);
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_OUTLINER) {
SpaceOutliner *soutliner = (SpaceOutliner *)sl;
@@ -318,7 +319,7 @@ static void outliner_sync_selection_from_outliner(Scene *scene,
SelectedItems *selected_items)
{
- for (TreeElement *te = tree->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, tree) {
TreeStoreElem *tselem = TREESTORE(te);
if (tselem->type == 0 && te->idcode == ID_OB) {
@@ -499,7 +500,7 @@ static void outliner_sync_selection_to_outliner(ViewLayer *view_layer,
SyncSelectActiveData *active_data,
const SyncSelectTypes *sync_types)
{
- for (TreeElement *te = tree->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, tree) {
TreeStoreElem *tselem = TREESTORE(te);
if (tselem->type == 0 && te->idcode == ID_OB) {
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 12be08550af..34ca2267b7a 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -45,6 +45,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_collection.h"
#include "BKE_constraint.h"
@@ -517,7 +518,7 @@ static void merged_element_search_cb_recursive(
char name[64];
int iconid;
- for (TreeElement *te = tree->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, tree) {
TreeStoreElem *tselem = TREESTORE(te);
if (tree_element_id_type_to_index(te) == type && tselem_type == tselem->type) {
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index d89a755f1c6..b226d291188 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1254,7 +1254,7 @@ static bool outliner_library_id_show(Library *lib, ID *id, short filter_id_type)
Collection *collection = (Collection *)id;
bool has_non_scene_parent = false;
- for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) {
+ LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) {
if (!(cparent->collection->flag & COLLECTION_IS_MASTER)) {
has_non_scene_parent = true;
}
@@ -1387,7 +1387,7 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops
static void outliner_add_layer_collection_objects(
SpaceOutliner *soops, ListBase *tree, ViewLayer *layer, LayerCollection *lc, TreeElement *ten)
{
- for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) {
Base *base = BKE_view_layer_base_find(layer, cob->ob);
TreeElement *te_object = outliner_add_element(soops, tree, base->object, ten, 0, 0);
te_object->directdata = base;
@@ -1405,7 +1405,7 @@ static void outliner_add_layer_collections_recursive(SpaceOutliner *soops,
TreeElement *parent_ten,
const bool show_objects)
{
- for (LayerCollection *lc = layer_collections->first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, layer_collections) {
const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0;
TreeElement *ten;
@@ -1468,7 +1468,7 @@ BLI_INLINE void outliner_add_collection_objects(SpaceOutliner *soops,
Collection *collection,
TreeElement *parent)
{
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
outliner_add_element(soops, tree, cob->ob, parent, 0, 0);
}
}
@@ -1479,7 +1479,7 @@ static TreeElement *outliner_add_collection_recursive(SpaceOutliner *soops,
{
outliner_add_collection_init(ten, collection);
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
outliner_add_element(soops, &ten->subtree, &child->collection->id, ten, 0, 0);
}
@@ -1542,7 +1542,7 @@ static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soo
continue;
}
- for (LinkData *link = parent_ob_tree_elements->first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, parent_ob_tree_elements) {
TreeElement *parent_ob_tree_element = link->data;
TreeElement *parent_ob_collection_tree_element = NULL;
bool found = false;
@@ -1556,8 +1556,7 @@ static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soo
parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent;
}
- for (LinkData *link_iter = child_ob_tree_elements->first; link_iter;
- link_iter = link_iter->next) {
+ LISTBASE_FOREACH (LinkData *, link_iter, child_ob_tree_elements) {
TreeElement *child_ob_tree_element = link_iter->data;
if (child_ob_tree_element->parent == parent_ob_collection_tree_element) {
@@ -1589,7 +1588,7 @@ static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soo
static void outliner_object_tree_elements_lookup_create_recursive(GHash *object_tree_elements_hash,
TreeElement *te_parent)
{
- for (TreeElement *te = te_parent->subtree.first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, &te_parent->subtree) {
TreeStoreElem *tselem = TREESTORE(te);
if (tselem->type == TSE_LAYER_COLLECTION) {
@@ -2427,7 +2426,7 @@ void outliner_build_tree(
else if (soops->outlinevis == SO_VIEW_LAYER) {
if (soops->filter & SO_FILTER_NO_COLLECTION) {
/* Show objects in the view layer. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
TreeElement *te_object = outliner_add_element(
soops, &soops->tree, base->object, NULL, 0, 0);
te_object->directdata = base;
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index 45b46788c8f..a058c30cef2 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -23,6 +23,7 @@
#include <string.h>
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "DNA_action_types.h"
@@ -77,7 +78,7 @@ TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops,
const ListBase *tree,
float view_co_y)
{
- for (TreeElement *te_iter = tree->first; te_iter; te_iter = te_iter->next) {
+ LISTBASE_FOREACH (TreeElement *, te_iter, tree) {
if (view_co_y < (te_iter->ys + UI_UNIT_Y)) {
if (view_co_y >= te_iter->ys) {
/* co_y is inside this element */
@@ -203,7 +204,7 @@ TreeElement *outliner_find_tse(SpaceOutliner *soops, const TreeStoreElem *tse)
/* Find treestore that refers to given ID */
TreeElement *outliner_find_id(SpaceOutliner *soops, ListBase *lb, const ID *id)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
if (tselem->type == 0) {
if (tselem->id == id) {
@@ -221,7 +222,7 @@ TreeElement *outliner_find_id(SpaceOutliner *soops, ListBase *lb, const ID *id)
TreeElement *outliner_find_posechannel(ListBase *lb, const bPoseChannel *pchan)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
if (te->directdata == pchan) {
return te;
}
@@ -239,7 +240,7 @@ TreeElement *outliner_find_posechannel(ListBase *lb, const bPoseChannel *pchan)
TreeElement *outliner_find_editbone(ListBase *lb, const EditBone *ebone)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
if (te->directdata == ebone) {
return te;
}
@@ -360,7 +361,7 @@ float outliner_restrict_columns_width(const SpaceOutliner *soops)
/* Find first tree element in tree with matching treestore flag */
TreeElement *outliner_find_element_with_flag(const ListBase *lb, short flag)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
if ((TREESTORE(te)->flag & flag) == flag) {
return te;
}
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index cfeaf8aa897..9450136b6a6 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -106,7 +106,7 @@ static void outliner_main_region_free(ARegion *UNUSED(region))
}
static void outliner_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -241,11 +241,11 @@ static void outliner_main_region_message_subscribe(const struct bContext *UNUSED
struct WorkSpace *UNUSED(workspace),
struct Scene *UNUSED(scene),
struct bScreen *UNUSED(screen),
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus)
{
- SpaceOutliner *soops = sa->spacedata.first;
+ SpaceOutliner *soops = area->spacedata.first;
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
.user_data = region,
@@ -275,7 +275,7 @@ static void outliner_header_region_free(ARegion *UNUSED(region))
}
static void outliner_header_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -341,7 +341,7 @@ static void outliner_free(SpaceLink *sl)
}
/* spacetype; init callback */
-static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
@@ -360,7 +360,7 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl)
return (SpaceLink *)soutlinern;
}
-static void outliner_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
+static void outliner_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
{
SpaceOutliner *so = (SpaceOutliner *)slink;
@@ -393,12 +393,12 @@ static void outliner_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id,
}
}
-static void outliner_deactivate(struct ScrArea *sa)
+static void outliner_deactivate(struct ScrArea *area)
{
/* Remove hover highlights */
- SpaceOutliner *soops = sa->spacedata.first;
+ SpaceOutliner *soops = area->spacedata.first;
outliner_flag_set(&soops->tree, TSE_HIGHLIGHTED, false);
- ED_region_tag_redraw(BKE_area_find_region_type(sa, RGN_TYPE_WINDOW));
+ ED_region_tag_redraw(BKE_area_find_region_type(area, RGN_TYPE_WINDOW));
}
/* only called once, from space_api/spacetypes.c */
diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c
index 79311cac6b5..e9ed1cec228 100644
--- a/source/blender/editors/space_script/script_edit.c
+++ b/source/blender/editors/space_script/script_edit.c
@@ -92,7 +92,7 @@ static bool script_test_modal_operators(bContext *C)
wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
if (handler->op != NULL) {
wmOperatorType *ot = handler->op->type;
- if (ot->ext.srna) {
+ if (ot->rna_ext.srna) {
return true;
}
}
diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c
index d872facd488..343f35421a4 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -94,7 +94,7 @@ static void script_free(SpaceLink *sl)
}
/* spacetype; init callback */
-static void script_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void script_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
@@ -160,7 +160,7 @@ static void script_header_region_draw(const bContext *C, ARegion *region)
}
static void script_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *UNUSED(region),
wmNotifier *UNUSED(wmn),
const Scene *UNUSED(scene))
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index ac9b605b193..80172c5462f 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -51,8 +51,7 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
-/* for menu/popup icons etc etc*/
-
+/* For menu, popup, icons, etc. */
#include "ED_screen.h"
#include "ED_sequencer.h"
@@ -67,16 +66,16 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
-/* own include */
+/* Own include. */
#include "sequencer_intern.h"
typedef struct SequencerAddData {
ImageFormatData im_format;
} SequencerAddData;
-/* Generic functions, reused by add strip operators */
+/* Generic functions, reused by add strip operators. */
-/* avoid passing multiple args and be more verbose */
+/* Avoid passing multiple args and be more verbose. */
#define SEQPROP_STARTFRAME (1 << 0)
#define SEQPROP_ENDFRAME (1 << 1)
#define SEQPROP_NOPATHS (1 << 2)
@@ -101,7 +100,7 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag)
}
if (flag & SEQPROP_ENDFRAME) {
- /* not usual since most strips have a fixed length */
+ /* Not usual since most strips have a fixed length. */
RNA_def_int(ot->srna,
"frame_end",
0,
@@ -119,7 +118,7 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag)
RNA_def_boolean(
ot->srna, "replace_sel", 1, "Replace Selection", "Replace the current selection");
- /* only for python scripts which import strips and place them after */
+ /* Only for python scripts which import strips and place them after. */
prop = RNA_def_boolean(
ot->srna, "overlap", 0, "Allow Overlap", "Don't correct overlap on new sequence strips");
RNA_def_property_flag(prop, PROP_HIDDEN);
@@ -175,7 +174,7 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, i
int cfra = (int)CFRA;
- /* effect strips don't need a channel initialized from the mouse */
+ /* Effect strips don't need a channel initialized from the mouse. */
if (!(flag & SEQPROP_NOCHAN) && RNA_struct_property_is_set(op->ptr, "channel") == 0) {
RNA_int_set(op->ptr, "channel", sequencer_generic_invoke_xy_guess_channel(C, type));
}
@@ -203,18 +202,17 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato
memset(seq_load, 0, sizeof(SeqLoadInfo));
seq_load->start_frame = RNA_int_get(op->ptr, "frame_start");
- seq_load->end_frame = seq_load->start_frame; /* un-set */
-
+ seq_load->end_frame = seq_load->start_frame;
seq_load->channel = RNA_int_get(op->ptr, "channel");
- seq_load->len = 1; // images only, if endframe isn't set!
+ seq_load->len = 1;
if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) {
- /* full path, file is set by the caller */
+ /* Full path, file is set by the caller. */
RNA_property_string_get(op->ptr, prop, seq_load->path);
is_file = 1;
}
else if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
- /* full path, file is set by the caller */
+ /* Full path, file is set by the caller. */
RNA_property_string_get(op->ptr, prop, seq_load->path);
is_file = 0;
}
@@ -252,15 +250,13 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato
seq_load->flag |= SEQ_LOAD_SYNC_FPS;
}
- /* always use this for ops */
+ /* Create consecutive array of strips. */
seq_load->flag |= SEQ_LOAD_FRAME_ADVANCE;
if (is_file == 1) {
BLI_strncpy(seq_load->name, BLI_path_basename(seq_load->path), sizeof(seq_load->name));
}
else if ((prop = RNA_struct_find_property(op->ptr, "files"))) {
- /* used for image strip */
- /* best guess, first images name */
RNA_PROP_BEGIN (op->ptr, itemptr, prop) {
char *name = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
BLI_strncpy(seq_load->name, name, sizeof(seq_load->name));
@@ -278,9 +274,6 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato
seq_load->views_format = imf->views_format;
seq_load->flag |= SEQ_USE_VIEWS;
-
- /* operator custom data is always released after the SeqLoadInfo,
- * no need to handle the memory here */
seq_load->stereo3d_format = &imf->stereo3d_format;
}
}
@@ -332,22 +325,17 @@ static bool seq_effect_add_properties_poll(const bContext *UNUSED(C),
return true;
}
-/* add scene operator */
static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, true);
-
Scene *sce_seq;
+ Sequence *seq;
- Sequence *seq; /* generic strip vars */
-
- int start_frame, channel; /* operator props */
-
+ int start_frame, channel;
start_frame = RNA_int_get(op->ptr, "frame_start");
channel = RNA_int_get(op->ptr, "channel");
-
sce_seq = BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene"));
if (sce_seq == NULL) {
@@ -356,11 +344,8 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
}
seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, SEQ_TYPE_SCENE);
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
-
+ seq->blend_mode = SEQ_TYPE_CROSS;
seq->scene = sce_seq;
-
- /* basic defaults */
seq->len = sce_seq->r.efra - sce_seq->r.sfra + 1;
BLI_strncpy(seq->name + 2, sce_seq->id.name + 2, sizeof(seq->name) - 2);
@@ -388,26 +373,23 @@ static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, const w
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SCENE);
return sequencer_add_scene_strip_exec(C, op);
- // needs a menu
- // return WM_menu_invoke(C, op, event);
}
void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot)
{
PropertyRNA *prop;
- /* identifiers */
+ /* Identifiers. */
ot->name = "Add Scene Strip";
ot->idname = "SEQUENCER_OT_scene_strip_add";
ot->description = "Add a strip to the sequencer using a blender scene as a source";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_add_scene_strip_invoke;
ot->exec = sequencer_add_scene_strip_exec;
-
ot->poll = ED_operator_sequencer_active_editable;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
@@ -417,22 +399,17 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot)
ot->prop = prop;
}
-/* add movieclip operator */
static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, true);
-
MovieClip *clip;
+ Sequence *seq;
- Sequence *seq; /* generic strip vars */
-
- int start_frame, channel; /* operator props */
-
+ int start_frame, channel;
start_frame = RNA_int_get(op->ptr, "frame_start");
channel = RNA_int_get(op->ptr, "channel");
-
clip = BLI_findlink(&bmain->movieclips, RNA_enum_get(op->ptr, "clip"));
if (clip == NULL) {
@@ -443,12 +420,10 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, SEQ_TYPE_MOVIECLIP);
seq->blend_mode = SEQ_TYPE_CROSS;
seq->clip = clip;
+ seq->len = BKE_movieclip_get_duration(clip);
id_us_ensure_real(&seq->clip->id);
- /* basic defaults */
- seq->len = BKE_movieclip_get_duration(clip);
-
BLI_strncpy(seq->name + 2, clip->id.name + 2, sizeof(seq->name) - 2);
BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
@@ -473,26 +448,23 @@ static int sequencer_add_movieclip_strip_invoke(bContext *C, wmOperator *op, con
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIECLIP);
return sequencer_add_movieclip_strip_exec(C, op);
- // needs a menu
- // return WM_menu_invoke(C, op, event);
}
void SEQUENCER_OT_movieclip_strip_add(struct wmOperatorType *ot)
{
PropertyRNA *prop;
- /* identifiers */
+ /* Identifiers. */
ot->name = "Add MovieClip Strip";
ot->idname = "SEQUENCER_OT_movieclip_strip_add";
ot->description = "Add a movieclip strip to the sequencer";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_add_movieclip_strip_invoke;
ot->exec = sequencer_add_movieclip_strip_exec;
-
ot->poll = ED_operator_sequencer_active_editable;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
@@ -508,16 +480,12 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, true);
-
Mask *mask;
+ Sequence *seq;
- Sequence *seq; /* generic strip vars */
-
- int start_frame, channel; /* operator props */
-
+ int start_frame, channel;
start_frame = RNA_int_get(op->ptr, "frame_start");
channel = RNA_int_get(op->ptr, "channel");
-
mask = BLI_findlink(&bmain->masks, RNA_enum_get(op->ptr, "mask"));
if (mask == NULL) {
@@ -528,12 +496,10 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, SEQ_TYPE_MASK);
seq->blend_mode = SEQ_TYPE_CROSS;
seq->mask = mask;
+ seq->len = BKE_mask_get_duration(mask);
id_us_ensure_real(&seq->mask->id);
- /* basic defaults */
- seq->len = BKE_mask_get_duration(mask);
-
BLI_strncpy(seq->name + 2, mask->id.name + 2, sizeof(seq->name) - 2);
BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
@@ -558,26 +524,23 @@ static int sequencer_add_mask_strip_invoke(bContext *C, wmOperator *op, const wm
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MASK);
return sequencer_add_mask_strip_exec(C, op);
- // needs a menu
- // return WM_menu_invoke(C, op, event);
}
void SEQUENCER_OT_mask_strip_add(struct wmOperatorType *ot)
{
PropertyRNA *prop;
- /* identifiers */
+ /* Identifiers. */
ot->name = "Add Mask Strip";
ot->idname = "SEQUENCER_OT_mask_strip_add";
ot->description = "Add a mask strip to the sequencer";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_add_mask_strip_invoke;
ot->exec = sequencer_add_mask_strip_exec;
-
ot->poll = ED_operator_sequencer_active_editable;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
@@ -587,9 +550,9 @@ void SEQUENCER_OT_mask_strip_add(struct wmOperatorType *ot)
ot->prop = prop;
}
-static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFunc seq_load_func)
+static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFn seq_load_fn)
{
- Scene *scene = CTX_data_scene(C); /* only for sound */
+ Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, true);
SeqLoadInfo seq_load;
int tot_files;
@@ -603,7 +566,6 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
tot_files = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
if (tot_files > 1) {
- /* multiple files */
char dir_only[FILE_MAX];
char file_only[FILE_MAX];
@@ -614,10 +576,10 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
RNA_string_get(&itemptr, "name", file_only);
BLI_join_dirfile(seq_load.path, sizeof(seq_load.path), dir_only, file_only);
- /* Set seq_load.name, else all video/audio files get the same name! ugly! */
+ /* Set seq_load.name, otherwise all video/audio files get the same name. */
BLI_strncpy(seq_load.name, file_only, sizeof(seq_load.name));
- seq = seq_load_func(C, ed->seqbasep, &seq_load);
+ seq = seq_load_fn(C, ed->seqbasep, &seq_load);
if (seq) {
sequencer_add_apply_overlap(C, op, seq);
if (seq_load.seq_sound) {
@@ -627,11 +589,10 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
}
RNA_END;
}
- else {
+ else { /* Single file./ */
Sequence *seq;
+ seq = seq_load_fn(C, ed->seqbasep, &seq_load);
- /* single file */
- seq = seq_load_func(C, ed->seqbasep, &seq_load);
if (seq) {
sequencer_add_apply_overlap(C, op, seq);
if (seq_load.seq_sound) {
@@ -658,7 +619,6 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
return OPERATOR_FINISHED;
}
-/* add sequencer operators */
static void sequencer_add_init(bContext *UNUSED(C), wmOperator *op)
{
op->customdata = MEM_callocN(sizeof(SequencerAddData), __func__);
@@ -672,9 +632,9 @@ static void sequencer_add_cancel(bContext *UNUSED(C), wmOperator *op)
op->customdata = NULL;
}
-static bool sequencer_add_draw_check_prop(PointerRNA *UNUSED(ptr),
- PropertyRNA *prop,
- void *UNUSED(user_data))
+static bool sequencer_add_draw_check_fn(PointerRNA *UNUSED(ptr),
+ PropertyRNA *prop,
+ void *UNUSED(user_data))
{
const char *prop_id = RNA_property_identifier(prop);
@@ -682,7 +642,6 @@ static bool sequencer_add_draw_check_prop(PointerRNA *UNUSED(ptr),
STREQ(prop_id, "filename"));
}
-/* add movie operator */
static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op)
{
return sequencer_add_generic_strip_exec(C, op, BKE_sequencer_add_movie_strip);
@@ -696,20 +655,12 @@ static int sequencer_add_movie_strip_invoke(bContext *C,
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
- /* only enable "use_framerate" if there aren't any existing strips
- * - When there are no strips yet, there is no harm in enabling this,
- * and it makes the single-strip case really nice for casual users
- * - When there are strips, it's best we don't touch the framerate,
- * as all hell may break loose (e.g. audio strips start overlapping
- * and can't be restored)
- * - These initial guesses can still be manually overridden by users
- * from the modal options panel
- */
+ /* Only enable "use_framerate" if there aren't any existing strips, unless overriden by user. */
if (ed && ed->seqbasep && ed->seqbasep->first) {
RNA_boolean_set(op->ptr, "use_framerate", false);
}
- /* This is for drag and drop */
+ /* This is for drag and drop. */
if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) ||
RNA_struct_property_is_set(op->ptr, "filepath")) {
sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE);
@@ -717,17 +668,14 @@ static int sequencer_add_movie_strip_invoke(bContext *C,
}
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIE);
-
sequencer_add_init(C, op);
- /* show multiview save options only if scene has multiviews */
+ /* Show multiview save options only if scene use multiview. */
prop = RNA_struct_find_property(op->ptr, "show_multiview");
RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0);
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
-
- // return sequencer_add_movie_strip_exec(C, op);
}
static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
@@ -737,15 +685,15 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
ImageFormatData *imf = &sad->im_format;
PointerRNA imf_ptr, ptr;
- /* main draw call */
+ /* Main draw call. */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
uiDefAutoButsRNA(
- layout, &ptr, sequencer_add_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
+ layout, &ptr, sequencer_add_draw_check_fn, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
- /* image template */
+ /* Image template. */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
- /* multiview template */
+ /* Multiview template. */
if (RNA_boolean_get(op->ptr, "show_multiview")) {
uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
}
@@ -754,20 +702,19 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Add Movie Strip";
ot->idname = "SEQUENCER_OT_movie_strip_add";
ot->description = "Add a movie strip to the sequencer";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_add_movie_strip_invoke;
ot->exec = sequencer_add_movie_strip_exec;
ot->cancel = sequencer_add_cancel;
ot->ui = sequencer_add_draw;
-
ot->poll = ED_operator_sequencer_active_editable;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_filesel(ot,
@@ -787,8 +734,6 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
"Use framerate from the movie to keep sound and video in sync");
}
-/* add sound operator */
-
static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op)
{
return sequencer_add_generic_strip_exec(C, op, BKE_sequencer_add_sound_strip);
@@ -798,7 +743,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- /* This is for drag and drop */
+ /* This is for drag and drop. */
if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) ||
RNA_struct_property_is_set(op->ptr, "filepath")) {
sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_SOUND_RAM);
@@ -809,25 +754,22 @@ static int sequencer_add_sound_strip_invoke(bContext *C,
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
-
- // return sequencer_add_sound_strip_exec(C, op);
}
void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Add Sound Strip";
ot->idname = "SEQUENCER_OT_sound_strip_add";
ot->description = "Add a sound strip to the sequencer";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_add_sound_strip_invoke;
ot->exec = sequencer_add_sound_strip_exec;
-
ot->poll = ED_operator_sequencer_active_editable;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_filesel(ot,
@@ -854,7 +796,6 @@ int sequencer_image_seq_get_minmax_frame(wmOperator *op,
RNA_BEGIN (op->ptr, itemptr, "files") {
char *filename;
int frame;
- /* just get the first filename */
filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
if (filename) {
@@ -885,7 +826,6 @@ void sequencer_image_seq_reserve_frames(
int i;
char *filename = NULL;
RNA_BEGIN (op->ptr, itemptr, "files") {
- /* just get the first filename */
filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
break;
}
@@ -894,7 +834,7 @@ void sequencer_image_seq_reserve_frames(
if (filename) {
char ext[PATH_MAX];
char filename_stripped[PATH_MAX];
- /* strip the frame from filename and substitute with # */
+ /* Strip the frame from filename and substitute with `#`. */
BLI_path_frame_strip(filename, ext);
for (i = 0; i < len; i++, se++) {
@@ -907,23 +847,20 @@ void sequencer_image_seq_reserve_frames(
}
}
-/* add image operator */
static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
{
int minframe, numdigits;
- /* cant use the generic function for this */
- Scene *scene = CTX_data_scene(C); /* only for sound */
+ Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, true);
SeqLoadInfo seq_load;
Sequence *seq;
-
Strip *strip;
StripElem *se;
const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
seq_load_operator_info(&seq_load, C, op);
- /* images are unique in how they handle this - 1 per strip elem */
+ /* Images are unique in how they handle this - 1 per strip elem. */
if (use_placeholders) {
seq_load.len = sequencer_image_seq_get_minmax_frame(
op, seq_load.start_frame, &minframe, &numdigits);
@@ -941,11 +878,10 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
ED_sequencer_deselect_all(scene);
}
- /* main adding function */
+ /* Main adding function. */
seq = BKE_sequencer_add_image_strip(C, ed->seqbasep, &seq_load);
strip = seq->strip;
se = strip->stripdata;
-
seq->blend_mode = SEQ_TYPE_ALPHAOVER;
if (use_placeholders) {
@@ -968,21 +904,18 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
}
BKE_sequence_init_colorspace(seq);
-
BKE_sequence_calc_disp(scene, seq);
-
BKE_sequencer_sort(scene);
- /* last active name */
+ /* Last active name. */
BLI_strncpy(ed->act_imagedir, strip->dir, sizeof(ed->act_imagedir));
-
sequencer_add_apply_overlap(C, op, seq);
if (op->customdata) {
MEM_freeN(op->customdata);
}
- BKE_sequence_invalidate_cache_composite(scene, seq);
+ BKE_sequence_invalidate_cache_composite(scene, seq);
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
@@ -996,7 +929,7 @@ static int sequencer_add_image_strip_invoke(bContext *C,
PropertyRNA *prop;
Scene *scene = CTX_data_scene(C);
- /* drag drop has set the names */
+ /* Name set already by drag and drop. */
if (RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) {
sequencer_generic_invoke_xy__internal(
C, op, SEQPROP_ENDFRAME | SEQPROP_NOPATHS, SEQ_TYPE_IMAGE);
@@ -1004,10 +937,9 @@ static int sequencer_add_image_strip_invoke(bContext *C,
}
sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME, SEQ_TYPE_IMAGE);
-
sequencer_add_init(C, op);
- /* show multiview save options only if scene has multiviews */
+ /* Show multiview save options only if scene use multiview. */
prop = RNA_struct_find_property(op->ptr, "show_multiview");
RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0);
@@ -1018,20 +950,19 @@ static int sequencer_add_image_strip_invoke(bContext *C,
void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Add Image Strip";
ot->idname = "SEQUENCER_OT_image_strip_add";
ot->description = "Add an image or image sequence to the sequencer";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_add_image_strip_invoke;
ot->exec = sequencer_add_image_strip_exec;
ot->cancel = sequencer_add_cancel;
ot->ui = sequencer_add_draw;
-
ot->poll = ED_operator_sequencer_active_editable;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_filesel(ot,
@@ -1051,65 +982,54 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot)
"Use placeholders for missing frames of the strip");
}
-/* add_effect_strip operator */
static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, true);
-
- Sequence *seq; /* generic strip vars */
+ Sequence *seq;
struct SeqEffectHandle sh;
-
- int start_frame, end_frame, channel, type; /* operator props */
-
Sequence *seq1, *seq2, *seq3;
const char *error_msg;
+ int start_frame, end_frame, channel, type;
start_frame = RNA_int_get(op->ptr, "frame_start");
end_frame = RNA_int_get(op->ptr, "frame_end");
channel = RNA_int_get(op->ptr, "channel");
-
type = RNA_enum_get(op->ptr, "type");
- // XXX move to invoke
if (!seq_effect_find_selected(scene, NULL, type, &seq1, &seq2, &seq3, &error_msg)) {
BKE_report(op->reports, RPT_ERROR, error_msg);
return OPERATOR_CANCELLED;
}
- /* If seq1 is NULL and no error was raised it means the seq is standalone
- * (like color strips) and we need to check its start and end frames are valid */
+ /* Check its start and end frames are valid. */
if (seq1 == NULL && end_frame <= start_frame) {
end_frame = start_frame + 1;
RNA_int_set(op->ptr, "frame_end", end_frame);
}
seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, type);
-
BLI_strncpy(seq->name + 2, BKE_sequence_give_name(seq), sizeof(seq->name) - 2);
BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
sh = BKE_sequence_get_effect(seq);
-
+ sh.init(seq);
seq->seq1 = seq1;
seq->seq2 = seq2;
seq->seq3 = seq3;
- sh.init(seq);
-
- if (!seq1) { /* effect has no deps */
- seq->len = 1;
+ if (!seq1) {
+ seq->len = 1; /* Effect is generator, set non zero length. */
BKE_sequence_tx_set_final_right(seq, end_frame);
}
seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE;
-
BKE_sequence_calc(scene, seq);
if (seq->type == SEQ_TYPE_COLOR) {
SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
RNA_float_get_array(op->ptr, "color", colvars->col);
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
+ seq->blend_mode = SEQ_TYPE_CROSS;
}
else if (seq->type == SEQ_TYPE_ADJUSTMENT) {
seq->blend_mode = SEQ_TYPE_CROSS;
@@ -1118,8 +1038,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
seq->blend_mode = SEQ_TYPE_ALPHAOVER;
}
- /* an unset channel is a special case where we automatically go above
- * the other strips. */
+ /* Set channel. If unset, use lowest free one above strips. */
if (!RNA_struct_property_is_set(op->ptr, "channel")) {
if (seq->seq1) {
int chan = max_iii(seq->seq1 ? seq->seq1->machine : 0,
@@ -1134,20 +1053,16 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
sequencer_add_apply_replace_sel(C, op, seq);
sequencer_add_apply_overlap(C, op, seq);
- BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1); /* runs BKE_sequence_calc */
-
- /* not sure if this is needed with update_changed_seq_and_deps.
- * it was NOT called in blender 2.4x, but wont hurt */
+ BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1); /* Runs BKE_sequence_calc. */
BKE_sequencer_sort(scene);
- BKE_sequence_invalidate_cache_composite(scene, seq);
+ BKE_sequence_invalidate_cache_composite(scene, seq);
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
-/* add color */
static int sequencer_add_effect_strip_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
@@ -1159,10 +1074,8 @@ static int sequencer_add_effect_strip_invoke(bContext *C,
if (is_type_set) {
type = RNA_enum_get(op->ptr, "type");
- /* when invoking an effect strip which uses inputs,
- * skip initializing the channel from the mouse.
- * Instead leave the property unset so exec() initializes it to be
- * above the strips its applied to. */
+ /* When invoking an effect strip which uses inputs, skip initializing the channel from the
+ * mouse. */
if (BKE_sequence_effect_get_num_inputs(type) != 0) {
prop_flag |= SEQPROP_NOCHAN;
}
@@ -1177,19 +1090,18 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot)
{
PropertyRNA *prop;
- /* identifiers */
+ /* Identifiers. */
ot->name = "Add Effect Strip";
ot->idname = "SEQUENCER_OT_effect_strip_add";
ot->description = "Add an effect to the sequencer, most are applied on top of existing strips";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_add_effect_strip_invoke;
ot->exec = sequencer_add_effect_strip_exec;
-
ot->poll = ED_operator_sequencer_active_editable;
ot->poll_property = seq_effect_add_properties_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_enum(ot->srna,
diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c
index a2568e2e827..dce8aa16985 100644
--- a/source/blender/editors/space_sequencer/sequencer_buttons.c
+++ b/source/blender/editors/space_sequencer/sequencer_buttons.c
@@ -54,7 +54,7 @@ static bool sequencer_grease_pencil_panel_poll(const bContext *C, PanelType *UNU
{
SpaceSeq *sseq = CTX_wm_space_seq(C);
- /* don't show the gpencil if we are not showing the image */
+ /* Don't show the gpencil if we are not showing the image. */
return ED_space_sequencer_check_show_imbuf(sseq);
}
#endif
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 0766996c00b..93ff5263148 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -79,29 +79,26 @@
#include "MEM_guardedalloc.h"
-/* own include */
+/* Own include. */
#include "sequencer_intern.h"
#define SEQ_LEFTHANDLE 1
#define SEQ_RIGHTHANDLE 2
-
#define SEQ_HANDLE_SIZE 8.0f
-
#define SEQ_SCROLLER_TEXT_OFFSET 8
-
#define MUTE_ALPHA 120
/* Note, Don't use SEQ_BEGIN/SEQ_END while drawing!
- * it messes up transform, - Campbell */
+ * it messes up transform. */
#undef SEQ_BEGIN
#undef SEQP_BEGIN
#undef SEQ_END
static Sequence *special_seq_update = NULL;
-void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3])
+void color3ubv_from_seq(Scene *curscene, Sequence *seq, uchar col[3])
{
- unsigned char blendcol[3];
+ uchar blendcol[3];
switch (seq->type) {
case SEQ_TYPE_IMAGE:
@@ -141,7 +138,7 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3])
col[2] = 130;
break;
- /* effects */
+ /* Effects. */
case SEQ_TYPE_TRANSFORM:
case SEQ_TYPE_SPEED:
case SEQ_TYPE_ADD:
@@ -234,13 +231,10 @@ static void draw_seq_waveform(View2D *v2d,
float y2,
float stepsize)
{
- /*
- * x1 is the starting x value to draw the wave,
- * x2 the end x value, same for y1 and y2
- * stepsize is width of a pixel.
- */
+ /* X1, x2 is the starting and end X value to draw the wave, same for y1 and y2.
+ * Stepsize is width of a pixel. */
- /* offset x1 and x2 values, to match view min/max, if strip is out of bounds */
+ /* Offset x1 and x2 values, to match view min/max, if strip is out of bounds. */
int x1_offset = max_ff(v2d->cur.xmin, x1);
int x2_offset = min_ff(v2d->cur.xmax + 1.0f, x2);
@@ -254,8 +248,6 @@ static void draw_seq_waveform(View2D *v2d,
float volume = seq->volume;
float value1, value2;
bSound *sound = seq->sound;
- FCurve *fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, NULL);
-
SoundWaveform *waveform;
if (length < 2) {
@@ -265,7 +257,7 @@ static void draw_seq_waveform(View2D *v2d,
BLI_spin_lock(sound->spinlock);
if (!sound->waveform) {
if (!(sound->tags & SOUND_TAGS_WAVEFORM_LOADING)) {
- /* prevent sounds from reloading */
+ /* Prevent sounds from reloading. */
sound->tags |= SOUND_TAGS_WAVEFORM_LOADING;
BLI_spin_unlock(sound->spinlock);
sequencer_preview_add_sound(C, seq);
@@ -273,15 +265,14 @@ static void draw_seq_waveform(View2D *v2d,
else {
BLI_spin_unlock(sound->spinlock);
}
- return; /* nothing to draw */
+ return; /* Nothing to draw. */
}
BLI_spin_unlock(sound->spinlock);
waveform = sound->waveform;
+ /* Waveform could not be built. */
if (waveform->length == 0) {
- /* BKE_sound_read_waveform() set an empty SoundWaveform data in case it cannot generate a
- * valid one. See T45726. */
return;
}
@@ -299,6 +290,9 @@ static void draw_seq_waveform(View2D *v2d,
return;
}
+ /* Fcurve lookup is quite expensive, so do this after precondition. */
+ FCurve *fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, NULL);
+
GPU_blend(true);
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -325,7 +319,7 @@ static void draw_seq_waveform(View2D *v2d,
}
}
else if (p + 1 < waveform->length) {
- /* use simple linear interpolation */
+ /* Use simple linear interpolation. */
float f = sampleoffset - p;
value1 = (1.0f - f) * value1 + f * waveform->data[p * 3 + 3];
value2 = (1.0f - f) * value2 + f * waveform->data[p * 3 + 4];
@@ -359,14 +353,12 @@ static void draw_seq_waveform(View2D *v2d,
}
}
+/* Don't use SEQ_BEGIN/SEQ_END here, because it changes seq->depth,
+ * which is needed for tranform. */
static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2)
{
- /* note: this used to use SEQ_BEGIN/SEQ_END, but it messes up the
- * seq->depth value, (needed by transform when doing overlap checks)
- * so for now, just use the meta's immediate children, could be fixed but
- * its only drawing - campbell */
Sequence *seq;
- unsigned char col[4];
+ uchar col[4];
int chan_min = MAXSEQ;
int chan_max = 0;
@@ -400,12 +392,12 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
chan_range = (chan_max - chan_min) + 1;
draw_height = draw_range / chan_range;
- col[3] = 196; /* alpha, used for all meta children */
+ col[3] = 196; /* Alpha, used for all meta children. */
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ /* Draw only immediate children (1 level depth). */
for (seq = seqbase->first; seq; seq = seq->next) {
const int startdisp = seq->startdisp + offset;
const int enddisp = seq->enddisp + offset;
@@ -433,7 +425,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
immUniformColor4ubv(col);
- /* clamp within parent sequence strip bounds */
+ /* Clamp within parent sequence strip bounds. */
if (x1_chan < x1) {
x1_chan = x1;
}
@@ -453,29 +445,29 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
GPU_blend(false);
}
-/* clamp handles to defined size in pixel space */
+/* Get handle width in pixels. */
float sequence_handle_size_get_clamped(Sequence *seq, const float pixelx)
{
const float maxhandle = (pixelx * SEQ_HANDLE_SIZE) * U.pixelsize;
- /* ensure we're not greater than half width */
+ /* Ensure that handle is not wider, than half of strip. */
return min_ff(maxhandle, ((float)(seq->enddisp - seq->startdisp) / 2.0f) / pixelx);
}
-/* draw a handle, for each end of a sequence strip */
+/* Draw a handle, on left or right side of strip. */
static void draw_seq_handle(View2D *v2d,
Sequence *seq,
const float handsize_clamped,
const short direction,
- unsigned int pos,
+ uint pos,
bool seq_active,
float pixelx,
bool y_threshold)
{
float rx1 = 0, rx2 = 0;
float x1, x2, y1, y2;
- unsigned int whichsel = 0;
- unsigned char col[4];
+ uint whichsel = 0;
+ uchar col[4];
x1 = seq->startdisp;
x2 = seq->enddisp;
@@ -483,7 +475,7 @@ static void draw_seq_handle(View2D *v2d,
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
- /* set up co-ordinates/dimensions for either left or right handle */
+ /* Set up co-ordinates and dimensions for either left or right handle. */
if (direction == SEQ_LEFTHANDLE) {
rx1 = x1;
rx2 = x1 + handsize_clamped;
@@ -495,7 +487,6 @@ static void draw_seq_handle(View2D *v2d,
whichsel = SEQ_RIGHTSEL;
}
- /* draw! */
if (!(seq->type & SEQ_TYPE_EFFECT) || BKE_sequence_effect_get_num_inputs(seq->type) == 0) {
GPU_blend(true);
@@ -522,9 +513,7 @@ static void draw_seq_handle(View2D *v2d,
GPU_blend(false);
}
- /* Draw numbers for start and end of the strip next to its handles.
- * - Draw only when handles are selected or while translating the strip.
- */
+ /* Draw numbers for start and end of the strip next to its handles. */
if (y_threshold &&
(((seq->flag & SELECT) && (G.moving & G_TRANSFORM_SEQ)) || (seq->flag & whichsel))) {
@@ -557,7 +546,7 @@ static void draw_seq_handle(View2D *v2d,
}
static void draw_seq_outline(Sequence *seq,
- unsigned int pos,
+ uint pos,
float x1,
float x2,
float y1,
@@ -566,7 +555,7 @@ static void draw_seq_outline(Sequence *seq,
float pixely,
bool seq_active)
{
- unsigned char col[3];
+ uchar col[3];
/* Get the color for the outline. */
if (seq_active && (seq->flag & SELECT)) {
@@ -575,8 +564,8 @@ static void draw_seq_outline(Sequence *seq,
else if (seq->flag & SELECT) {
UI_GetThemeColor3ubv(TH_SEQ_SELECTED, col);
}
- /* Regular color for unselected strips: a bit darker than the background. */
else {
+ /* Color for unselected strips is a bit darker than the background. */
UI_GetThemeColor3ubv(TH_BACK, col);
UI_GetColorPtrShade3ubv(col, col, -40);
}
@@ -610,13 +599,13 @@ static void draw_seq_outline(Sequence *seq,
/* Top */
immRectf(pos, x1 - pixelx, y2 - 2 * pixely, x2 + pixelx, y2);
}
- /* 1px wide outline for unselected strips. */
else {
+ /* 1px wide outline for unselected strips. */
imm_draw_box_wire_2d(pos, x1, y1, x2, y2);
}
}
-/* draw info text on a sequence strip */
+/* Draw info text on a sequence strip. */
static void draw_seq_text(View2D *v2d,
Sequence *seq,
SpaceSeq *sseq,
@@ -633,7 +622,7 @@ static void draw_seq_text(View2D *v2d,
const char *name = seq->name + 2;
uchar col[4];
- /* note, all strings should include 'name' */
+ /* All strings should include name. */
if (name[0] == '\0') {
name = BKE_sequence_give_name(seq);
}
@@ -723,7 +712,7 @@ static void draw_seq_text(View2D *v2d,
seq->len);
}
else {
- /* should never get here!, but might with files from future */
+ /* Should never get here!, but might with files from future. */
BLI_assert(0);
str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
@@ -751,10 +740,10 @@ static void draw_seq_text(View2D *v2d,
UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col);
}
-static void draw_sequence_extensions(Scene *scene, Sequence *seq, unsigned int pos, float pixely)
+static void draw_sequence_extensions(Scene *scene, Sequence *seq, uint pos, float pixely)
{
float x1, x2, y1, y2;
- unsigned char col[4], blend_col[3];
+ uchar col[4], blend_col[3];
x1 = seq->startdisp;
x2 = seq->enddisp;
@@ -793,9 +782,9 @@ static void draw_sequence_extensions(Scene *scene, Sequence *seq, unsigned int p
GPU_blend(false);
}
-static void draw_color_strip_band(Sequence *seq, unsigned int pos, float text_margin_y, float y1)
+static void draw_color_strip_band(Sequence *seq, uint pos, float text_margin_y, float y1)
{
- unsigned char col[4];
+ uchar col[4];
SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
rgb_float_to_uchar(col, colvars->col);
@@ -827,14 +816,14 @@ static void draw_color_strip_band(Sequence *seq, unsigned int pos, float text_ma
static void draw_seq_background(Scene *scene,
Sequence *seq,
- unsigned int pos,
+ uint pos,
float x1,
float x2,
float y1,
float y2,
bool is_single_image)
{
- unsigned char col[4];
+ uchar col[4];
/* Get the correct color per strip type, transitions use their inputs ones. */
if (ELEM(seq->type, SEQ_TYPE_CROSS, SEQ_TYPE_GAMCROSS, SEQ_TYPE_WIPE)) {
@@ -888,7 +877,7 @@ static void draw_seq_background(Scene *scene,
}
}
- /* Transition strips.. Draw right half. */
+ /* Draw right half of transition strips. */
if (ELEM(seq->type, SEQ_TYPE_CROSS, SEQ_TYPE_GAMCROSS, SEQ_TYPE_WIPE)) {
float vert_pos[3][2];
Sequence *seq1 = seq->seq1;
@@ -966,7 +955,7 @@ static void calculate_seq_text_offsets(
float scroller_vert_xoffs = (V2D_SCROLL_HANDLE_WIDTH + SEQ_SCROLLER_TEXT_OFFSET) * pixelx;
- /* info text on the strip */
+ /* Info text on the strip. */
if (*x1 < v2d->cur.xmin + scroller_vert_xoffs) {
*x1 = v2d->cur.xmin + scroller_vert_xoffs;
}
@@ -981,11 +970,100 @@ static void calculate_seq_text_offsets(
}
}
-/*
- * Draw a sequence strip, bounds check already made
- * ARegion is currently only used to get the windows width in pixels
- * so wave file sample drawing precision is zoom adjusted
- */
+static void fcurve_batch_add_verts(GPUVertBuf *vbo,
+ float y1,
+ float y2,
+ float y_height,
+ int cfra,
+ float curve_val,
+ unsigned int *vert_count)
+{
+ float vert_pos[2][2];
+
+ copy_v2_fl2(vert_pos[0], cfra, (curve_val * y_height) + y1);
+ copy_v2_fl2(vert_pos[1], cfra, y2);
+
+ GPU_vertbuf_vert_set(vbo, *vert_count, vert_pos[0]);
+ GPU_vertbuf_vert_set(vbo, *vert_count + 1, vert_pos[1]);
+ *vert_count += 2;
+}
+
+/* Draw f-curves as darkened regions of the strip.
+ * - Volume for sound strips.
+ * - Opacity for the other types. */
+static void draw_seq_fcurve(
+ Scene *scene, View2D *v2d, Sequence *seq, float x1, float y1, float x2, float y2, float pixelx)
+{
+ FCurve *fcu;
+
+ if (seq->type == SEQ_TYPE_SOUND_RAM) {
+ fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, NULL);
+ }
+ else {
+ fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "blend_alpha", 0, NULL);
+ }
+
+ if (fcu && !BKE_fcurve_is_empty(fcu)) {
+
+ /* Clamp curve evaluation to the editor's borders. */
+ int eval_start = max_ff(x1, v2d->cur.xmin);
+ int eval_end = min_ff(x2, v2d->cur.xmax + 1);
+
+ int eval_step = max_ii(1, floor(pixelx));
+
+ if (eval_start >= eval_end) {
+ return;
+ }
+
+ GPUVertFormat format = {0};
+ GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+
+ uint max_verts = 2 * ((eval_end - eval_start) / eval_step + 1);
+ GPU_vertbuf_data_alloc(vbo, max_verts);
+ uint vert_count = 0;
+
+ const float y_height = y2 - y1;
+ float curve_val;
+ float prev_val = INT_MIN;
+ bool skip = false;
+
+ for (int cfra = eval_start; cfra <= eval_end; cfra += eval_step) {
+ curve_val = evaluate_fcurve(fcu, cfra);
+ CLAMP(curve_val, 0.0f, 1.0f);
+
+ /* Avoid adding adjacent verts that have the same value. */
+ if (curve_val == prev_val && cfra < eval_end - eval_step) {
+ skip = true;
+ continue;
+ }
+
+ /* If some frames were skipped above, we need to close the shape. */
+ if (skip) {
+ fcurve_batch_add_verts(vbo, y1, y2, y_height, cfra - eval_step, prev_val, &vert_count);
+ skip = false;
+ }
+
+ fcurve_batch_add_verts(vbo, y1, y2, y_height, cfra, curve_val, &vert_count);
+ prev_val = curve_val;
+ }
+
+ GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
+ GPU_vertbuf_data_len_set(vbo, vert_count);
+ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR);
+ GPU_batch_uniform_4f(batch, "color", 0.0f, 0.0f, 0.0f, 0.15f);
+ GPU_blend(true);
+
+ if (vert_count > 0) {
+ GPU_batch_draw(batch);
+ }
+
+ GPU_blend(false);
+ GPU_batch_discard(batch);
+ }
+}
+
+/* Draw visible strips. Bounds check are already made. */
static void draw_seq_strip(const bContext *C,
SpaceSeq *sseq,
Scene *scene,
@@ -999,20 +1077,19 @@ static void draw_seq_strip(const bContext *C,
const float handsize_clamped = sequence_handle_size_get_clamped(seq, pixelx);
float pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
- /* We need to know if this is a single image/color or not for drawing. */
+ /* Check if we are doing "solo preview". */
bool is_single_image = (char)BKE_sequence_single_check(seq);
- /* body */
+ /* Draw strip body. */
x1 = (seq->startstill) ? seq->start : seq->startdisp;
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
- /* Position of the text,
- * make sure that the strip content is visible also when the strip height gets lower. */
+ /* Calculate height needed for drawing text on strip. */
float text_margin_y = y2 - min_ff(0.40f, 20 * U.dpi_fac * pixely);
- /* Show some content only when the strip is high enough. */
+ /* Is there enough space for drawing something else than text? */
bool y_threshold = ((y2 - y1) / pixely) > 20 * U.dpi_fac;
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -1020,12 +1097,12 @@ static void draw_seq_strip(const bContext *C,
draw_seq_background(scene, seq, pos, x1, x2, y1, y2, is_single_image);
- /* Color strips.. Draw a band with the strip's color on its lower part. */
+ /* Draw a color band inside color strip. */
if (seq->type == SEQ_TYPE_COLOR && y_threshold) {
draw_color_strip_band(seq, pos, text_margin_y, y1);
}
- /* Draw strip's offsets when flag is enabled or during "solo preview". */
+ /* Draw strip offsets when flag is enabled or during "solo preview". */
if (!is_single_image && (seq->startofs || seq->endofs) && pixely > 0) {
if ((sseq->draw_flag & SEQ_DRAW_OFFSET_EXT) || (seq == special_seq_update)) {
draw_sequence_extensions(scene, seq, pos, pixely);
@@ -1042,7 +1119,11 @@ static void draw_seq_strip(const bContext *C,
drawmeta_contents(scene, seq, x1, y1, x2, y2);
}
- /* Sound strips.. Draw waveforms. */
+ if (sseq->flag & SEQ_SHOW_FCURVES) {
+ draw_seq_fcurve(scene, v2d, seq, x1, y1, x2, y2, pixelx);
+ }
+
+ /* Draw sound strip waveform. */
if ((seq->type == SEQ_TYPE_SOUND_RAM) && (sseq->flag & SEQ_NO_WAVEFORMS) == 0) {
draw_seq_waveform(v2d,
C,
@@ -1061,7 +1142,7 @@ static void draw_seq_strip(const bContext *C,
draw_seq_locked(x1, y1, x2, y2);
}
- /* Missing media indication.. Draw a red line on the top of the strip. */
+ /* Draw Red line on the top of invalid strip (Missing media). */
if (!BKE_sequence_is_valid_check(seq)) {
draw_seq_invalid(x1, x2, y2, text_margin_y);
}
@@ -1082,11 +1163,9 @@ static void draw_seq_strip(const bContext *C,
calculate_seq_text_offsets(v2d, seq, &x1, &x2, pixelx);
- /* Draw the text on the top section of the strip,
- * - depending on the vertical space, move it to the center or don't draw it.
- * - don't draw it when there is not enough horizontal space.
- */
+ /* Don't draw strip if there is not enough vertical or horizontal space. */
if (((x2 - x1) > 32 * pixelx * U.dpi_fac) && ((y2 - y1) > 8 * pixely * U.dpi_fac)) {
+ /* Depending on the vertical space, draw text on top or in the center of strip. */
draw_seq_text(
v2d, seq, sseq, x1, x2, y_threshold ? text_margin_y : y1, y2, seq_active, y_threshold);
}
@@ -1203,7 +1282,7 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain,
GPU_framebuffer_bind(fb);
}
- /* restore state so real rendering would be canceled (if needed) */
+ /* Restore state so real rendering would be canceled if needed. */
G.is_break = is_break;
return ibuf;
@@ -1239,7 +1318,7 @@ static void sequencer_check_scopes(SequencerScopes *scopes, ImBuf *ibuf)
}
}
-static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_cb)(ImBuf *ibuf))
+static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_fn)(ImBuf *ibuf))
{
ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
ImBuf *scope;
@@ -1247,7 +1326,7 @@ static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scop
IMB_colormanagement_imbuf_make_display_space(
display_ibuf, &scene->view_settings, &scene->display_settings);
- scope = make_scope_cb(display_ibuf);
+ scope = make_scope_fn(display_ibuf);
IMB_freeImBuf(display_ibuf);
@@ -1264,17 +1343,17 @@ static void sequencer_display_size(Scene *scene, float r_viewrect[2])
static void sequencer_draw_gpencil(const bContext *C)
{
- /* draw grease-pencil (image aligned) */
+ /* Draw grease-pencil (image aligned). */
ED_annotation_draw_2dimage(C);
- /* ortho at pixel level */
+ /* Ortho at pixel level. */
UI_view2d_view_restore(C);
- /* draw grease-pencil (screen aligned) */
+ /* Draw grease-pencil (screen aligned). */
ED_annotation_draw_view2d(C, 0);
}
-/* draws content borders plus safety borders if needed */
+/* Draw content and safety borders borders. */
static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, const Scene *scene)
{
float x1 = v2d->tot.xmin;
@@ -1284,7 +1363,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
GPU_line_width(1.0f);
- /* border */
+ /* Draw border. */
const uint shdr_pos = GPU_vertformat_attr_add(
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -1301,7 +1380,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
imm_draw_box_wire_2d(shdr_pos, x1 - 0.5f, y1 - 0.5f, x2 + 0.5f, y2 + 0.5f);
- /* safety border */
+ /* Draw safety border. */
if (sseq->flag & SEQ_SHOW_SAFE_MARGINS) {
immUniformThemeColorBlend(TH_VIEW_OVERLAY, TH_BACK, 0.25f);
@@ -1325,8 +1404,8 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
#if 0
void sequencer_draw_maskedit(const bContext *C, Scene *scene, ARegion *region, SpaceSeq *sseq)
{
- /* NOTE: sequencer mask editing isnt finished, the draw code is working but editing not,
- * for now just disable drawing since the strip frame will likely be offset */
+ /* NOTE: sequencer mask editing isnt finished, the draw code is working but editing not.
+ * For now just disable drawing since the strip frame will likely be offset. */
// if (sc->mode == SC_MODE_MASKEDIT)
if (0 && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
@@ -1377,8 +1456,8 @@ static void *sequencer_OCIO_transform_ibuf(
force_fallback |= (ED_draw_imbuf_method(ibuf) != IMAGE_DRAW_METHOD_GLSL);
force_fallback |= (ibuf->dither != 0.0f);
+ /* Fallback to CPU based color space conversion. */
if (force_fallback) {
- /* Fallback to CPU based color space conversion */
*r_glsl_used = false;
*r_format = GL_RGBA;
*r_type = GL_UNSIGNED_BYTE;
@@ -1423,9 +1502,8 @@ static void *sequencer_OCIO_transform_ibuf(
display_buffer = NULL;
}
- /* there's a data to be displayed, but GLSL is not initialized
- * properly, in this case we fallback to CPU-based display transform
- */
+ /* There is data to be displayed, but GLSL is not initialized
+ * properly, in this case we fallback to CPU-based display transform. */
if ((ibuf->rect || ibuf->rect_float) && !*r_glsl_used) {
display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
*r_format = GL_RGBA;
@@ -1441,14 +1519,12 @@ static void *sequencer_OCIO_transform_ibuf(
static void sequencer_stop_running_jobs(const bContext *C, Scene *scene)
{
if (G.is_rendering == false && (scene->r.seq_prev_type) == OB_RENDER) {
- /* stop all running jobs, except screen one. currently previews frustrate Render
- * needed to make so sequencer's rendering doesn't conflict with compositor
- */
+ /* Stop all running jobs, except screen one. Currently previews frustrate Render.
+ * Need to make so sequencer's rendering doesn't conflict with compositor. */
WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_COMPOSITE);
- /* in case of final rendering used for preview, kill all previews,
- * otherwise threading conflict will happen in rendering module
- */
+ /* In case of final rendering used for preview, kill all previews,
+ * otherwise threading conflict will happen in rendering module. */
WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_RENDER_PREVIEW);
}
}
@@ -1521,8 +1597,7 @@ static void sequencer_draw_display_buffer(const bContext *C,
}
/* Format needs to be created prior to any immBindProgram call.
- * Do it here because OCIO binds it's own shader.
- */
+ * Do it here because OCIO binds it's own shader. */
int format, type;
bool glsl_used = false;
GLuint texid;
@@ -1538,7 +1613,7 @@ static void sequencer_draw_display_buffer(const bContext *C,
IMB_rect_from_float(ibuf);
}
- display_buffer = (unsigned char *)ibuf->rect;
+ display_buffer = (uchar *)ibuf->rect;
format = GL_RGBA;
type = GL_UNSIGNED_BYTE;
}
@@ -1671,7 +1746,7 @@ static ImBuf *sequencer_get_scope(Scene *scene, SpaceSeq *sseq, ImBuf *ibuf, boo
break;
}
- /* future files may have new scopes we don't catch above */
+ /* Future files may have new scopes we don't catch above. */
if (scope) {
scopes->reference_ibuf = ibuf;
}
@@ -1708,13 +1783,13 @@ void sequencer_draw_preview(const bContext *C,
return;
}
- /* Setup view */
+ /* Setup view. */
sequencer_display_size(scene, viewrect);
UI_view2d_totRect_set(v2d, viewrect[0] + 0.5f, viewrect[1] + 0.5f);
UI_view2d_curRect_validate(v2d);
UI_view2d_view_ortho(v2d);
- /* Draw background */
+ /* Draw background. */
if (!draw_backdrop && (!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE)) {
sequencer_preview_clear();
@@ -1722,18 +1797,18 @@ void sequencer_draw_preview(const bContext *C,
imm_draw_box_checker_2d(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax);
}
}
- /* Get image */
+ /* Get image. */
ibuf = sequencer_ibuf_get(
bmain, depsgraph, scene, sseq, cfra, frame_ofs, names[sseq->multiview_eye]);
if (ibuf) {
scope = sequencer_get_scope(scene, sseq, ibuf, draw_backdrop);
- /* Draw image */
+ /* Draw image. */
sequencer_draw_display_buffer(
C, scene, region, sseq, ibuf, scope, draw_overlay, draw_backdrop);
- /* Draw over image */
+ /* Draw over image. */
if (sseq->flag & SEQ_SHOW_METADATA) {
ED_region_image_metadata_draw(0.0, 0.0, ibuf, &v2d->tot, 1.0, 1.0);
}
@@ -1746,12 +1821,11 @@ void sequencer_draw_preview(const bContext *C,
if (draw_gpencil && show_imbuf) {
sequencer_draw_gpencil(C);
}
+#if 0
+ sequencer_draw_maskedit(C, scene, region, sseq);
+#endif
- /* TODO */
- /* sequencer_draw_maskedit(C, scene, region, sseq); */
-
- /* Scope is freed in sequencer_check_scopes when ibuf changes and
- * scope image is to be replaced. */
+ /* Scope is freed in sequencer_check_scopes when ibuf changes and redraw is needed. */
if (ibuf) {
IMB_freeImBuf(ibuf);
}
@@ -1760,7 +1834,7 @@ void sequencer_draw_preview(const bContext *C,
seq_prefetch_wm_notify(C, scene);
}
-/* draw backdrop of the sequencer strips view */
+/* Draw backdrop in sequencer timeline. */
static void draw_seq_backdrop(View2D *v2d)
{
int i;
@@ -1768,11 +1842,11 @@ static void draw_seq_backdrop(View2D *v2d)
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- /* darker gray overlay over the view backdrop */
+ /* Darker gray overlay over the view backdrop. */
immUniformThemeColorShade(TH_BACK, -20);
immRectf(pos, v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0);
- /* Alternating horizontal stripes */
+ /* Alternating horizontal stripes. */
i = max_ii(1, ((int)v2d->cur.ymin) - 1);
while (i < v2d->cur.ymax) {
@@ -1788,7 +1862,7 @@ static void draw_seq_backdrop(View2D *v2d)
i++;
}
- /* Darker lines separating the horizontal bands */
+ /* Darker lines separating the horizontal bands. */
i = max_ii(1, ((int)v2d->cur.ymin) - 1);
int line_len = (int)v2d->cur.ymax - i + 1;
immUniformThemeColor(TH_GRID);
@@ -1802,7 +1876,6 @@ static void draw_seq_backdrop(View2D *v2d)
immUnbindProgram();
}
-/* draw the contents of the sequencer strips view */
static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region)
{
Scene *scene = CTX_data_scene(C);
@@ -1812,12 +1885,12 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region)
int sel = 0, j;
float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
- /* loop through twice, first unselected, then selected */
+ /* Loop through twice, first unselected, then selected. */
for (j = 0; j < 2; j++) {
Sequence *seq;
- /* loop through strips, checking for those that are visible */
+ /* Loop through strips, checking for those that are visible. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- /* boundbox and selection tests for NOT drawing the strip... */
+ /* Boundbox and selection tests for NOT drawing the strip. */
if ((seq->flag & SELECT) != sel) {
continue;
}
@@ -1837,11 +1910,11 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region)
continue;
}
- /* strip passed all tests unscathed... so draw it now */
+ /* Strip passed all tests, draw it now. */
draw_seq_strip(C, sseq, scene, region, seq, pixelx, seq == last_seq ? true : false);
}
- /* draw selected next time round */
+ /* Draw selected next time round. */
sel = SELECT;
}
@@ -1872,7 +1945,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region)
}
}
- /* draw highlight when previewing a single strip */
+ /* Draw highlight if "solo preview" is used. */
if (special_seq_update) {
const Sequence *seq = special_seq_update;
GPU_blend(true);
@@ -1904,8 +1977,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- /* draw darkened area outside of active timeline
- * frame range used is preview range or scene range */
+ /* Draw overlay outside of frame range. */
immUniformThemeColorShadeAlpha(TH_BACK, -25, -100);
if (frame_sta < frame_end) {
@@ -1918,7 +1990,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
immUniformThemeColorShade(TH_BACK, -60);
- /* thin lines where the actual frames are */
+ /* Draw frame range boundary. */
immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, frame_sta, v2d->cur.ymin);
@@ -1929,7 +2001,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
immEnd();
- /* While inside a meta strip, draw a checkerboard pattern outside of its range. */
+ /* While in meta strip, draw a checkerboard overlay outside of frame range. */
if (ed && !BLI_listbase_is_empty(&ed->metastack)) {
MetaStack *ms = ed->metastack.last;
immUnbindProgram();
@@ -1979,8 +2051,8 @@ typedef struct CacheDrawData {
size_t final_out_vert_count;
} CacheDrawData;
-/* Called as a callback */
-static bool draw_cache_view_init_cb(void *userdata, size_t item_count)
+/* Called as a callback. */
+static bool draw_cache_view_init_fn(void *userdata, size_t item_count)
{
if (item_count == 0) {
return true;
@@ -1998,7 +2070,7 @@ static bool draw_cache_view_init_cb(void *userdata, size_t item_count)
}
/* Called as a callback */
-static bool draw_cache_view_iter_cb(
+static bool draw_cache_view_iter_fn(
void *userdata, struct Sequence *seq, int nfra, int cache_type, float UNUSED(cost))
{
CacheDrawData *drawdata = userdata;
@@ -2162,7 +2234,7 @@ static void draw_cache_view(const bContext *C)
userdata.composite_vbo = GPU_vertbuf_create_with_format(&format);
userdata.final_out_vbo = GPU_vertbuf_create_with_format(&format);
- BKE_sequencer_cache_iterate(scene, &userdata, draw_cache_view_init_cb, draw_cache_view_iter_cb);
+ BKE_sequencer_cache_iterate(scene, &userdata, draw_cache_view_init_fn, draw_cache_view_iter_fn);
draw_cache_view_batch(userdata.raw_vbo, userdata.raw_vert_count, 1.0f, 0.1f, 0.02f, 0.4f);
draw_cache_view_batch(
@@ -2175,7 +2247,7 @@ static void draw_cache_view(const bContext *C)
GPU_blend(false);
}
-/* Draw Timeline/Strip Editor Mode for Sequencer */
+/* Draw sequencer timeline. */
void draw_timeline_seq(const bContext *C, ARegion *region)
{
Scene *scene = CTX_data_scene(C);
@@ -2188,7 +2260,6 @@ void draw_timeline_seq(const bContext *C, ARegion *region)
seq_prefetch_wm_notify(C, scene);
- /* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
if (ed && ed->metastack.first) {
GPU_clear_color(col[0], col[1], col[2] - 0.1f, 0.0f);
@@ -2199,44 +2270,36 @@ void draw_timeline_seq(const bContext *C, ARegion *region)
GPU_clear(GPU_COLOR_BIT);
UI_view2d_view_ortho(v2d);
-
- /* calculate extents of sequencer strips/data
- * NOTE: needed for the scrollers later
- */
+ /* Get timeline boundbox, needed for the scrollers. */
boundbox_seq(scene, &v2d->tot);
-
- /* draw backdrop */
draw_seq_backdrop(v2d);
-
- /* regular grid-pattern over the rest of the view (i.e. 1-second grid lines) */
UI_view2d_constant_grid_draw(v2d, FPS);
- /* Only draw backdrop in pure sequence view. */
+ /* Only draw backdrop in timeline view. */
if (sseq->view == SEQ_VIEW_SEQUENCE && sseq->draw_flag & SEQ_DRAW_BACKDROP) {
sequencer_draw_preview(C, scene, region, sseq, scene->r.cfra, 0, false, true);
UI_view2d_view_ortho(v2d);
}
+ /* Draw attached callbacks. */
ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW);
-
seq_draw_sfra_efra(scene, v2d);
- /* sequence strips (if there is data available to be drawn) */
if (ed) {
- /* draw the data */
draw_seq_strips(C, ed, region);
- /* text draw cached (for sequence names), in pixelspace now */
+ /* Draw text added in previous function. */
UI_view2d_text_cache_draw(region);
}
- /* current frame */
UI_view2d_view_ortho(v2d);
if ((sseq->flag & SEQ_DRAWFRAMES) == 0) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
}
+
+ /* Draw playhead. */
ANIM_draw_cfra(C, v2d, cfra_flag);
- /* overlap playhead */
+ /* Draw overlap playhead. */
if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) {
int cfra_over = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ?
scene->ed->over_cfra :
@@ -2247,7 +2310,8 @@ void draw_timeline_seq(const bContext *C, ARegion *region)
float viewport_size[4];
GPU_viewport_size_get_f(viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
- immUniform1i("colors_len", 0); /* "simple" mode */
+ /* Shader may have color set from past usage - reset it. */
+ immUniform1i("colors_len", 0);
immUniform1f("dash_width", 20.0f * U.pixelsize);
immUniform1f("dash_factor", 0.5f);
immUniformThemeColor(TH_CFRAME);
@@ -2260,7 +2324,6 @@ void draw_timeline_seq(const bContext *C, ARegion *region)
immUnbindProgram();
}
- /* markers */
UI_view2d_view_orthoSpecial(region, v2d, 1);
int marker_draw_flag = DRAW_MARKERS_MARGIN;
if (sseq->flag & SEQ_SHOW_MARKERS) {
@@ -2268,28 +2331,22 @@ void draw_timeline_seq(const bContext *C, ARegion *region)
}
UI_view2d_view_ortho(v2d);
- /* draw cache on top of markers area */
+
if (ed) {
draw_cache_view(C);
}
- /* preview range */
+
ANIM_draw_previewrange(C, v2d, 1);
- /* callback */
+ /* Draw registered callbacks. */
ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW);
-
- /* reset view matrix */
UI_view2d_view_restore(C);
-
- /* scrubbing region */
ED_time_scrub_draw(region, scene, !(sseq->flag & SEQ_DRAWFRAMES), true);
-
- /* scrollers */
scrollers = UI_view2d_scrollers_calc(v2d, NULL);
UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
- /* channel numbers */
+ /* Draw channel numbers. */
{
rcti rect;
BLI_rcti_init(
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 71e63547eae..d34eed622d4 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -52,7 +52,7 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
-/* for menu/popup icons etc etc*/
+/* For menu, popup, icons, etc. */
#include "ED_anim_api.h"
#include "ED_numinput.h"
@@ -67,11 +67,11 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
-/* own include */
+/* Own include. */
#include "sequencer_intern.h"
/* XXX */
-/* RNA Enums, used in multiple files */
+/* RNA Enums, used in multiple files. */
EnumPropertyItem sequencer_prop_effect_types[] = {
{SEQ_TYPE_CROSS, "CROSS", 0, "Crossfade", "Crossfade effect strip type"},
{SEQ_TYPE_ADD, "ADD", 0, "Add", "Add effect strip type"},
@@ -94,8 +94,6 @@ EnumPropertyItem sequencer_prop_effect_types[] = {
{0, NULL, 0, NULL, NULL},
};
-/* mute operator */
-
#define SEQ_SIDE_MOUSE -1
EnumPropertyItem prop_side_types[] = {
@@ -144,7 +142,7 @@ static void proxy_freejob(void *pjv)
MEM_freeN(pj);
}
-/* only this runs inside thread */
+/* Only this runs inside thread. */
static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress)
{
ProxyJob *pj = pjv;
@@ -185,7 +183,7 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports)
struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Sequence *seq;
GSet *file_list;
@@ -233,7 +231,7 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports)
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
/* ********************************************************************** */
@@ -291,7 +289,7 @@ static int mouse_frame_side(View2D *v2d, short mouse_x, int frame)
mval[0] = mouse_x;
mval[1] = 0;
- /* choose the side based on which side of the playhead the mouse is on */
+ /* Choose the side based on which side of the playhead the mouse is on. */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &mouseloc[0], &mouseloc[1]);
return mouseloc[0] > frame ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT;
@@ -299,7 +297,7 @@ static int mouse_frame_side(View2D *v2d, short mouse_x, int frame)
Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int sel)
{
- /* sel - 0==unselected, 1==selected, -1==done care*/
+ /* sel: 0==unselected, 1==selected, -1==don't care. */
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
@@ -334,7 +332,7 @@ Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int se
static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, int sel)
{
- /* sel - 0==unselected, 1==selected, -1==done care*/
+ /* sel: 0==unselected, 1==selected, -1==don't care. */
Sequence *seq, *best_seq = NULL;
Editing *ed = BKE_sequencer_editing_get(scene, false);
@@ -375,7 +373,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i
}
seq = seq->next;
}
- return best_seq; /* can be null */
+ return best_seq; /* Can be null. */
}
Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[2])
@@ -400,22 +398,21 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[
while (seq) {
if (seq->machine == (int)y) {
- /* check for both normal strips, and strips that have been flipped horizontally */
+ /* Check for both normal strips, and strips that have been flipped horizontally. */
if (((seq->startdisp < seq->enddisp) && (seq->startdisp <= x && seq->enddisp >= x)) ||
((seq->startdisp > seq->enddisp) && (seq->startdisp >= x && seq->enddisp <= x))) {
if (BKE_sequence_tx_test(seq)) {
- /* clamp handles to defined size in pixel space */
-
+ /* Clamp handles to defined size in pixel space. */
handsize = 2.0f * sequence_handle_size_get_clamped(seq, pixelx);
displen = (float)abs(seq->startdisp - seq->enddisp);
- /* don't even try to grab the handles of small strips */
+ /* Don't even try to grab the handles of small strips. */
if (displen / pixelx > 16) {
+
/* Set the max value to handle to 1/3 of the total len when its
* less than 28. This is important because otherwise selecting
* handles happens even when you click in the middle. */
-
if ((displen / 3) < 30 * pixelx) {
handsize = displen / 3;
}
@@ -510,7 +507,6 @@ void recurs_sel_seq(Sequence *seqm)
bool ED_space_sequencer_maskedit_mask_poll(bContext *C)
{
- /* in this case both funcs are the same, for clip editor not */
return ED_space_sequencer_maskedit_poll(C);
}
@@ -535,7 +531,7 @@ bool ED_space_sequencer_maskedit_poll(bContext *C)
return false;
}
-/* are we displaying the seq output (not channels or histogram)*/
+/* Are we displaying the seq output (not channels or histogram). */
bool ED_space_sequencer_check_show_imbuf(SpaceSeq *sseq)
{
return (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW) &&
@@ -589,8 +585,8 @@ int seq_effect_find_selected(Scene *scene,
}
}
- /* make sequence selection a little bit more intuitive
- * for 3 strips: the last-strip should be sequence3 */
+ /* Make sequence selection a little bit more intuitive
+ * for 3 strips: the last-strip should be seq3. */
if (seq3 != NULL && seq2 != NULL) {
Sequence *tmp = seq2;
seq2 = seq3;
@@ -600,7 +596,7 @@ int seq_effect_find_selected(Scene *scene,
switch (BKE_sequence_effect_get_num_inputs(type)) {
case 0:
*r_selseq1 = *r_selseq2 = *r_selseq3 = NULL;
- return 1; /* success */
+ return 1; /* Success. */
case 1:
if (seq2 == NULL) {
*r_error_str = N_("At least one selected sequence strip is needed");
@@ -640,8 +636,8 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq)
{
Sequence *seq1, *seq2, *seq3;
- /* try to find a replacement input sequence, and flag for later deletion if
- * no replacement can be found */
+ /* Try to find a replacement input sequence, and flag for later deletion if
+ * no replacement can be found. */
if (!seq) {
return NULL;
@@ -650,13 +646,13 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq)
return ((seq->flag & SELECT) ? NULL : seq);
}
else if (!(seq->flag & SELECT)) {
- /* try to find replacement for effect inputs */
+ /* Try to find replacement for effect inputs. */
seq1 = del_seq_find_replace_recurs(scene, seq->seq1);
seq2 = del_seq_find_replace_recurs(scene, seq->seq2);
seq3 = del_seq_find_replace_recurs(scene, seq->seq3);
if (seq1 == seq->seq1 && seq2 == seq->seq2 && seq3 == seq->seq3) {
- /* pass */
+ /* Pass. */
}
else if (seq1 || seq2 || seq3) {
seq->seq1 = (seq1) ? seq1 : (seq2) ? seq2 : seq3;
@@ -666,7 +662,7 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq)
BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1);
}
else {
- seq->flag |= SELECT; /* mark for delete */
+ seq->flag |= SELECT; /* Mark for delete. */
}
}
@@ -740,7 +736,7 @@ static Sequence *split_seq_hard(
/* Unlike soft-split, it's important to use the same value for both strips. */
const bool is_end_exact = ((seq->start + seq->len) == split_frame);
- /* backup values */
+ /* Backup values. */
ts.start = seq->start;
ts.machine = seq->machine;
ts.startstill = seq->startstill;
@@ -753,21 +749,19 @@ static Sequence *split_seq_hard(
ts.anim_endofs = seq->anim_endofs;
ts.len = seq->len;
- /* First Strip! */
- /* strips with extended stillfames before */
-
- /* Precaution, needed because the length saved on-disk may not match the length saved in the
- * blend file, or our code may have minor differences reading file length between versions.
- * This causes hard-split to fail, see: T47862 */
if (seq->type != SEQ_TYPE_META) {
+ /* Precaution, needed because the length saved on-disk may not match the length saved in the
+ * blend file, or our code may have minor differences reading file length between versions.
+ * This causes hard-split to fail, see: T47862. */
BKE_sequence_reload_new_file(bmain, scene, seq, true);
BKE_sequence_calc(scene, seq);
}
+ /* First Strip. */
/* Important to offset the start when 'split_frame == seq->start'
* because we need at least one frame of content after start/end still have clipped it. */
if ((seq->startstill) && (split_frame <= seq->start)) {
- /* don't do funny things with METAs ... */
+ /* Don't do funny things with METAs. */
if (seq->type == SEQ_TYPE_META) {
skip_dup = true;
seq->startstill = seq->start - split_frame;
@@ -779,18 +773,18 @@ static Sequence *split_seq_hard(
seq->endstill = 0;
}
}
- /* normal strip */
+ /* Normal strip. */
else if ((is_end_exact == false) &&
((split_frame >= seq->start) && (split_frame <= (seq->start + seq->len)))) {
seq->endofs = 0;
seq->endstill = 0;
seq->anim_endofs += (seq->start + seq->len) - split_frame;
}
- /* strips with extended stillframes after */
+ /* Strips with extended stillframes. */
else if ((is_end_exact == true) ||
(((seq->start + seq->len) < split_frame) && (seq->endstill))) {
seq->endstill -= seq->enddisp - split_frame;
- /* don't do funny things with METAs ... */
+ /* Don't do funny things with METAs. */
if (seq->type == SEQ_TYPE_META) {
skip_dup = true;
}
@@ -800,7 +794,7 @@ static Sequence *split_seq_hard(
BKE_sequence_calc(scene, seq);
if (!skip_dup) {
- /* Duplicate AFTER the first change */
+ /* Duplicate AFTER the first change. */
seqn = BKE_sequence_dupli_recursive(
scene, scene, new_seq_list, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
}
@@ -808,12 +802,11 @@ static Sequence *split_seq_hard(
if (seqn) {
seqn->flag |= SELECT;
- /* Important not to re-assign this (unlike soft-split) */
#if 0
is_end_exact = ((seqn->start + seqn->len) == split_frame);
#endif
- /* Second Strip! */
- /* strips with extended stillframes before */
+ /* Second Strip. */
+ /* strips with extended stillframes. */
if ((seqn->startstill) && (split_frame == seqn->start + 1)) {
seqn->start = ts.start;
seqn->startstill = ts.start - split_frame;
@@ -821,7 +814,7 @@ static Sequence *split_seq_hard(
seqn->endstill = ts.endstill;
}
- /* normal strip */
+ /* Normal strip. */
else if ((is_end_exact == false) &&
((split_frame >= seqn->start) && (split_frame <= (seqn->start + seqn->len)))) {
seqn->start = split_frame;
@@ -833,7 +826,7 @@ static Sequence *split_seq_hard(
seqn->endstill = ts.endstill;
}
- /* strips with extended stillframes after */
+ /* Strips with extended stillframes after. */
else if ((is_end_exact == true) ||
(((seqn->start + seqn->len) < split_frame) && (seqn->endstill))) {
seqn->start = split_frame;
@@ -858,7 +851,7 @@ static Sequence *split_seq_soft(
bool is_end_exact = ((seq->start + seq->len) == split_frame);
- /* backup values */
+ /* Backup values. */
ts.start = seq->start;
ts.machine = seq->machine;
ts.startstill = seq->startstill;
@@ -871,9 +864,8 @@ static Sequence *split_seq_soft(
ts.anim_endofs = seq->anim_endofs;
ts.len = seq->len;
- /* First Strip! */
- /* strips with extended stillfames before */
-
+ /* First Strip. */
+ /* Strips with extended stillfames. */
/* Important to offset the start when 'split_frame == seq->start'
* because we need at least one frame of content after start/end still have clipped it. */
if ((seq->startstill) && (split_frame <= seq->start)) {
@@ -889,16 +881,16 @@ static Sequence *split_seq_soft(
seq->endstill = 0;
}
}
- /* normal strip */
+ /* Normal strip. */
else if ((is_end_exact == false) && (split_frame >= seq->start) &&
(split_frame <= (seq->start + seq->len))) {
seq->endofs = (seq->start + seq->len) - split_frame;
}
- /* strips with extended stillframes after */
+ /* Strips with extended stillframes. */
else if ((is_end_exact == true) ||
(((seq->start + seq->len) < split_frame) && (seq->endstill))) {
seq->endstill -= seq->enddisp - split_frame;
- /* don't do funny things with METAs ... */
+ /* Don't do funny things with METAs. */
if (seq->type == SEQ_TYPE_META) {
skip_dup = true;
}
@@ -907,7 +899,7 @@ static Sequence *split_seq_soft(
BKE_sequence_calc(scene, seq);
if (!skip_dup) {
- /* Duplicate AFTER the first change */
+ /* Duplicate AFTER the first change. */
seqn = BKE_sequence_dupli_recursive(
scene, scene, new_seq_list, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
}
@@ -917,8 +909,8 @@ static Sequence *split_seq_soft(
is_end_exact = ((seqn->start + seqn->len) == split_frame);
- /* Second Strip! */
- /* strips with extended stillframes before */
+ /* Second Strip. */
+ /* Strips with extended stillframes. */
if ((seqn->startstill) && (split_frame == seqn->start + 1)) {
seqn->start = ts.start;
seqn->startstill = ts.start - split_frame;
@@ -926,7 +918,7 @@ static Sequence *split_seq_soft(
seqn->endstill = ts.endstill;
}
- /* normal strip */
+ /* Normal strip. */
else if ((is_end_exact == false) && (split_frame >= seqn->start) &&
(split_frame <= (seqn->start + seqn->len))) {
seqn->startstill = 0;
@@ -935,7 +927,7 @@ static Sequence *split_seq_soft(
seqn->endstill = ts.endstill;
}
- /* strips with extended stillframes after */
+ /* Strips with extended stillframes. */
else if ((is_end_exact == true) ||
(((seqn->start + seqn->len) < split_frame) && (seqn->endstill))) {
seqn->start = split_frame - ts.len + 1;
@@ -949,12 +941,12 @@ static Sequence *split_seq_soft(
return seqn;
}
-/* like duplicate, but only duplicate and split overlapping strips,
+/* Like duplicate, but only duplicate and split overlapping strips,
* strips to the left of the split_frame are ignored and strips to the right
- * are moved to the end of slist
- * we have to work on the same slist (not using a separate list), since
+ * are moved to the end of slist.
+ * We have to work on the same slist (not using a separate list), since
* otherwise dupli_seq can't check for duplicate names properly and
- * may generate strips with the same name (which will mess up animdata)
+ * may generate strips with the same name which will mess up animdata.
*/
static bool split_seq_list(
@@ -973,7 +965,7 @@ static bool split_seq_list(
seq = slist->first;
while (seq && seq != seq_first_new) {
- seq_next_iter = seq->next; /* we need this because we may remove seq */
+ seq_next_iter = seq->next; /* We need this because we may remove seq. */
seq->tmp = NULL;
if (use_cursor_position) {
if (seq->machine == channel && seq->startdisp < split_frame && seq->enddisp > split_frame) {
@@ -996,10 +988,10 @@ static bool split_seq_list(
}
}
else if (seq->enddisp <= split_frame) {
- /* do nothing */
+ /* Pass. */
}
else if (seq->startdisp >= split_frame) {
- /* move to tail */
+ /* Move to tail. */
BLI_remlink(slist, seq);
BLI_addtail(slist, seq);
@@ -1022,7 +1014,7 @@ static bool sequence_offset_after_frame(Scene *scene, const int delta, const int
bool done = false;
TimeMarker *marker;
- /* all strips >= cfra are shifted */
+ /* All strips >= cfra are shifted. */
if (ed == NULL) {
return 0;
@@ -1085,12 +1077,12 @@ static void UNUSED_FUNCTION(seq_remap_paths)(Scene *scene)
}
BLI_strncpy(from, last_seq->strip->dir, sizeof(from));
- // XXX if (0 == sbutton(from, 0, sizeof(from) - 1, "From: "))
- // return;
+ /* XXX if (0 == sbutton(from, 0, sizeof(from) - 1, "From: "))
+ * return; */
BLI_strncpy(to, from, sizeof(to));
- // XXX if (0 == sbutton(to, 0, sizeof(to) - 1, "To: "))
- // return;
+ /* XXX if (0 == sbutton(to, 0, sizeof(to) - 1, "To: "))
+ * return; */
if (STREQ(to, from)) {
return;
@@ -1101,11 +1093,11 @@ static void UNUSED_FUNCTION(seq_remap_paths)(Scene *scene)
if (STREQLEN(seq->strip->dir, from, strlen(from))) {
printf("found %s\n", seq->strip->dir);
- /* strip off the beginning */
+ /* Strip off the beginning. */
stripped[0] = 0;
BLI_strncpy(stripped, seq->strip->dir + strlen(from), FILE_MAX);
- /* new path */
+ /* New path. */
BLI_snprintf(seq->strip->dir, sizeof(seq->strip->dir), "%s%s", to, stripped);
printf("new %s\n", seq->strip->dir);
}
@@ -1122,12 +1114,12 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
bool first = false, done;
bool do_all = RNA_boolean_get(op->ptr, "all");
- /* get first and last frame */
+ /* Get first and last frame. */
boundbox_seq(scene, &rectf);
sfra = (int)rectf.xmin;
efra = (int)rectf.xmax;
- /* first check if the current frame has a gap already */
+ /* Check if the current frame has a gap already. */
for (cfra = CFRA; cfra >= sfra; cfra--) {
if (BKE_sequencer_evaluate_frame(scene, cfra)) {
first = true;
@@ -1136,7 +1128,7 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
}
for (; cfra < efra; cfra++) {
- /* first == 0 means there's still no strip to remove a gap for */
+ /* There's still no strip to remove a gap for. */
if (first == false) {
if (BKE_sequencer_evaluate_frame(scene, cfra)) {
first = true;
@@ -1164,19 +1156,19 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_gap_remove(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Remove Gaps";
ot->idname = "SEQUENCER_OT_gap_remove";
ot->description =
"Remove gap at current frame to first strip at the right, independent of selection or "
"locked state of strips";
- /* api callbacks */
+ /* Api callbacks. */
// ot->invoke = sequencer_snap_invoke;
ot->exec = sequencer_gap_remove_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "all", 0, "All Gaps", "Do all gaps to right of current frame");
@@ -1196,19 +1188,19 @@ static int sequencer_gap_insert_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_gap_insert(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Insert Gaps";
ot->idname = "SEQUENCER_OT_gap_insert";
ot->description =
"Insert gap at current frame to first strips at the right, independent of selection or "
"locked state of strips";
- /* api callbacks */
+ /* Api callbacks. */
// ot->invoke = sequencer_snap_invoke;
ot->exec = sequencer_gap_insert_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_int(ot->srna,
@@ -1238,7 +1230,7 @@ static int seq_get_snaplimit(View2D *v2d)
}
#endif
-/* Operator functions */
+/* Operator functions. */
bool sequencer_edit_poll(bContext *C)
{
return (BKE_sequencer_editing_get(CTX_data_scene(C), false) != NULL);
@@ -1282,7 +1274,7 @@ bool sequencer_view_strips_poll(bContext *C)
return 0;
}
-/* snap operator*/
+/* Snap operator. */
static int sequencer_snap_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -1293,14 +1285,11 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op)
snap_frame = RNA_int_get(op->ptr, "frame");
- /* also check metas */
+ /* Check metas. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK) &&
BKE_sequence_tx_test(seq)) {
if ((seq->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) == 0) {
- /* simple but no anim update */
- /* seq->start = snap_frame-seq->startofs+seq->startstill; */
-
BKE_sequence_translate(
scene, seq, (snap_frame - seq->startofs + seq->startstill) - seq->start);
}
@@ -1318,8 +1307,8 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op)
}
}
- /* test for effects and overlap
- * don't use SEQP_BEGIN since that would be recursive */
+ /* Test for effects and overlap.
+ * Don't use SEQP_BEGIN since that would be recursive. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK)) {
seq->flag &= ~SEQ_OVERLAP;
@@ -1340,7 +1329,6 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op)
}
}
- /* as last: */
BKE_sequencer_sort(scene);
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
@@ -1363,17 +1351,17 @@ static int sequencer_snap_invoke(bContext *C, wmOperator *op, const wmEvent *UNU
void SEQUENCER_OT_snap(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Snap Strips to Playhead";
ot->idname = "SEQUENCER_OT_snap";
ot->description = "Frame where selected strips will be snapped";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_snap_invoke;
ot->exec = sequencer_snap_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_int(ot->srna,
@@ -1395,7 +1383,7 @@ typedef struct SlipData {
bool *trim;
int num_seq;
bool slow;
- int slow_offset; /* offset at the point where offset was turned on */
+ int slow_offset; /* Offset at the point where offset was turned on. */
NumInput num_input;
} SlipData;
@@ -1429,7 +1417,7 @@ static void transseq_restore(TransSeq *ts, Sequence *seq)
seq->len = ts->len;
}
-static int slip_add_sequences_rec(
+static int slip_add_sequences_recursive(
ListBase *seqbasep, Sequence **seq_array, bool *trim, int offset, bool do_trim)
{
Sequence *seq;
@@ -1442,8 +1430,8 @@ static int slip_add_sequences_rec(
num_items++;
if (seq->type == SEQ_TYPE_META) {
- /* trim the sub-sequences */
- num_items += slip_add_sequences_rec(
+ /* Trim the sub-sequences. */
+ num_items += slip_add_sequences_recursive(
&seq->seqbase, seq_array, trim, num_items + offset, false);
}
else if (seq->type & SEQ_TYPE_EFFECT) {
@@ -1455,7 +1443,7 @@ static int slip_add_sequences_rec(
return num_items;
}
-static int slip_count_sequences_rec(ListBase *seqbasep, bool first_level)
+static int slip_count_sequences_recursive(ListBase *seqbasep, bool first_level)
{
Sequence *seq;
int trimmed_sequences = 0;
@@ -1465,8 +1453,8 @@ static int slip_count_sequences_rec(ListBase *seqbasep, bool first_level)
trimmed_sequences++;
if (seq->type == SEQ_TYPE_META) {
- /* trim the sub-sequences */
- trimmed_sequences += slip_count_sequences_rec(&seq->seqbase, false);
+ /* Trim the sub-sequences. */
+ trimmed_sequences += slip_count_sequences_recursive(&seq->seqbase, false);
}
}
}
@@ -1483,8 +1471,8 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve
int num_seq, i;
View2D *v2d = UI_view2d_fromcontext(C);
- /* first recursively count the trimmed elements */
- num_seq = slip_count_sequences_rec(ed->seqbasep, true);
+ /* Recursively count the trimmed elements. */
+ num_seq = slip_count_sequences_recursive(ed->seqbasep, true);
if (num_seq == 0) {
return OPERATOR_CANCELLED;
@@ -1502,7 +1490,7 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve
data->num_input.unit_sys = USER_UNIT_NONE;
data->num_input.unit_type[0] = 0;
- slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true);
+ slip_add_sequences_recursive(ed->seqbasep, data->seq_array, data->trim, 0, true);
for (i = 0; i < num_seq; i++) {
transseq_backup(data->ts + i, data->seq_array[i]);
@@ -1517,7 +1505,7 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve
WM_event_add_modal_handler(C, op);
- /* notify so we draw extensions immediately */
+ /* Notify so we draw extensions immediately. */
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_RUNNING_MODAL;
@@ -1529,20 +1517,19 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset)
Editing *ed = BKE_sequencer_editing_get(scene, false);
bool changed = false;
- /* We iterate in reverse so meta-strips are iterated after their children. */
+ /* Iterate in reverse so meta-strips are iterated after their children. */
for (int i = data->num_seq - 1; i >= 0; i--) {
Sequence *seq = data->seq_array[i];
int endframe;
- /* We have the offset, apply the values to the sequence strips. */
- /* first, do the offset */
+ /* Offset seq start. */
seq->start = data->ts[i].start + offset;
if (data->trim[i]) {
/* Find the end-frame. */
endframe = seq->start + seq->len;
- /* Now compute the sequence offsets. */
+ /* Compute the sequence offsets. */
if (endframe > seq->enddisp) {
seq->endstill = 0;
seq->endofs = endframe - seq->enddisp;
@@ -1566,7 +1553,7 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset)
}
}
else {
- /* If no real trim, don't change the data, rather transform the strips themselves. */
+ /* No transform data (likely effect strip). Only move start and end. */
seq->startdisp = data->ts[i].startdisp + offset;
seq->enddisp = data->ts[i].enddisp + offset;
changed = true;
@@ -1575,7 +1562,7 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset)
/* Effects are only added if we they are in a meta-strip.
* In this case, dependent strips will just be transformed and
* we can skip calculating for effects.
- * This way we can avoid an extra loop just for effects*/
+ * This way we can avoid an extra loop just for effects. */
if (!(seq->type & SEQ_TYPE_EFFECT)) {
BKE_sequence_calc(scene, seq);
}
@@ -1586,6 +1573,28 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset)
return changed;
}
+/* Make sure, that each strip contains at least 1 frame of content. */
+static void sequencer_slip_apply_limits(SlipData *data, int *offset)
+{
+ for (int i = 0; i < data->num_seq; i++) {
+ if (data->trim[i]) {
+ Sequence *seq = data->seq_array[i];
+ int seq_content_start = data->ts[i].start + *offset;
+ int seq_content_end = seq_content_start + seq->len + seq->anim_startofs + seq->anim_endofs;
+ int diff = 0;
+
+ if (seq_content_start >= seq->enddisp) {
+ diff = seq->enddisp - seq_content_start - 1;
+ }
+
+ if (seq_content_end <= seq->startdisp) {
+ diff = seq->startdisp - seq_content_end + 1;
+ }
+ *offset += diff;
+ }
+ }
+}
+
static int sequencer_slip_exec(bContext *C, wmOperator *op)
{
SlipData *data;
@@ -1595,8 +1604,8 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op)
int offset = RNA_int_get(op->ptr, "offset");
bool success = false;
- /* first recursively count the trimmed elements */
- num_seq = slip_count_sequences_rec(ed->seqbasep, true);
+ /* Recursively count the trimmed elements. */
+ num_seq = slip_count_sequences_recursive(ed->seqbasep, true);
if (num_seq == 0) {
return OPERATOR_CANCELLED;
@@ -1608,12 +1617,13 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op)
data->trim = MEM_mallocN(num_seq * sizeof(bool), "trimdata_trim");
data->num_seq = num_seq;
- slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true);
+ slip_add_sequences_recursive(ed->seqbasep, data->seq_array, data->trim, 0, true);
for (i = 0; i < num_seq; i++) {
transseq_backup(data->ts + i, data->seq_array[i]);
}
+ sequencer_slip_apply_limits(data, &offset);
success = sequencer_slip_recursively(scene, data, offset);
MEM_freeN(data->seq_array);
@@ -1631,11 +1641,11 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op)
}
}
-static void sequencer_slip_update_header(Scene *scene, ScrArea *sa, SlipData *data, int offset)
+static void sequencer_slip_update_header(Scene *scene, ScrArea *area, SlipData *data, int offset)
{
char msg[UI_MAX_DRAW_STR];
- if (sa) {
+ if (area) {
if (hasNumInput(&data->num_input)) {
char num_str[NUM_STR_REP_LEN];
outputNumInput(&data->num_input, num_str, &scene->unit);
@@ -1646,7 +1656,7 @@ static void sequencer_slip_update_header(Scene *scene, ScrArea *sa, SlipData *da
}
}
- ED_area_status_text(sa, msg);
+ ED_area_status_text(area, msg);
}
static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *event)
@@ -1654,16 +1664,18 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
SlipData *data = (SlipData *)op->customdata;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
const bool has_numInput = hasNumInput(&data->num_input);
bool handled = true;
- /* Modal numinput active, try to handle numeric inputs first... */
+ /* Modal numinput active, try to handle numeric inputs. */
if (event->val == KM_PRESS && has_numInput && handleNumInput(C, &data->num_input, event)) {
- float offset;
- applyNumInput(&data->num_input, &offset);
+ float offset_fl;
+ applyNumInput(&data->num_input, &offset_fl);
+ int offset = round_fl_to_int(offset_fl);
- sequencer_slip_update_header(scene, sa, data, (int)offset);
+ sequencer_slip_apply_limits(data, &offset);
+ sequencer_slip_update_header(scene, area, data, offset);
RNA_int_set(op->ptr, "offset", offset);
@@ -1691,11 +1703,12 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even
mouse_x = event->mval[0];
}
- /* choose the side based on which side of the playhead the mouse is on */
+ /* Choose the side based on which side of the playhead the mouse is. */
UI_view2d_region_to_view(v2d, mouse_x, 0, &mouseloc[0], &mouseloc[1]);
offset = mouseloc[0] - data->init_mouseloc[0];
- sequencer_slip_update_header(scene, sa, data, offset);
+ sequencer_slip_apply_limits(data, &offset);
+ sequencer_slip_update_header(scene, area, data, offset);
RNA_int_set(op->ptr, "offset", offset);
@@ -1714,8 +1727,8 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even
MEM_freeN(data->ts);
MEM_freeN(data);
op->customdata = NULL;
- if (sa) {
- ED_area_status_text(sa, NULL);
+ if (area) {
+ ED_area_status_text(area, NULL);
}
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
@@ -1747,8 +1760,8 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even
BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
- if (sa) {
- ED_area_status_text(sa, NULL);
+ if (area) {
+ ED_area_status_text(area, NULL);
}
return OPERATOR_CANCELLED;
@@ -1772,12 +1785,14 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even
break;
}
- /* Modal numinput inactive, try to handle numeric inputs last... */
+ /* Modal numinput inactive, try to handle numeric inputs. */
if (!handled && event->val == KM_PRESS && handleNumInput(C, &data->num_input, event)) {
- float offset;
- applyNumInput(&data->num_input, &offset);
+ float offset_fl;
+ applyNumInput(&data->num_input, &offset_fl);
+ int offset = round_fl_to_int(offset_fl);
- sequencer_slip_update_header(scene, sa, data, (int)offset);
+ sequencer_slip_apply_limits(data, &offset);
+ sequencer_slip_update_header(scene, area, data, offset);
RNA_int_set(op->ptr, "offset", offset);
@@ -1791,18 +1806,18 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even
void SEQUENCER_OT_slip(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Trim Strips";
ot->idname = "SEQUENCER_OT_slip";
ot->description = "Trim the contents of the active strip";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_slip_invoke;
ot->modal = sequencer_slip_modal;
ot->exec = sequencer_slip_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_int(ot->srna,
@@ -1816,7 +1831,7 @@ void SEQUENCER_OT_slip(struct wmOperatorType *ot)
INT32_MAX);
}
-/* mute operator */
+/* Mute operator. */
static int sequencer_mute_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -1828,7 +1843,7 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op)
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq->flag & SEQ_LOCK) == 0) {
- if (selected) { /* mute unselected */
+ if (selected) {
if (seq->flag & SELECT) {
seq->flag |= SEQ_MUTE;
BKE_sequence_invalidate_dependent(scene, seq);
@@ -1851,23 +1866,23 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_mute(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Mute Strips";
ot->idname = "SEQUENCER_OT_mute";
ot->description = "Mute (un)selected strips";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_mute_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(
ot->srna, "unselected", 0, "Unselected", "Mute unselected rather than selected strips");
}
-/* unmute operator */
+/* Unmute operator. */
static int sequencer_unmute_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -1879,7 +1894,7 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op)
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq->flag & SEQ_LOCK) == 0) {
- if (selected) { /* unmute unselected */
+ if (selected) {
if (seq->flag & SELECT) {
seq->flag &= ~SEQ_MUTE;
BKE_sequence_invalidate_dependent(scene, seq);
@@ -1902,23 +1917,23 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_unmute(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Unmute Strips";
ot->idname = "SEQUENCER_OT_unmute";
ot->description = "Unmute (un)selected strips";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_unmute_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(
ot->srna, "unselected", 0, "Unselected", "Unmute unselected rather than selected strips");
}
-/* lock operator */
+/* Lock operator. */
static int sequencer_lock_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
@@ -1938,20 +1953,20 @@ static int sequencer_lock_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_lock(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Lock Strips";
ot->idname = "SEQUENCER_OT_lock";
ot->description = "Lock strips so they can't be transformed";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_lock_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* unlock operator */
+/* Unlock operator. */
static int sequencer_unlock_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
@@ -1971,20 +1986,20 @@ static int sequencer_unlock_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_unlock(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Unlock Strips";
ot->idname = "SEQUENCER_OT_unlock";
ot->description = "Unlock strips so they can be transformed";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_unlock_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* reload operator */
+/* Reload operator. */
static int sequencer_reload_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@@ -2015,17 +2030,17 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot)
{
PropertyRNA *prop;
- /* identifiers */
+ /* Identifiers. */
ot->name = "Reload Strips";
ot->idname = "SEQUENCER_OT_reload";
ot->description = "Reload strips in the sequencer";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_reload_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER; /* no undo, the data changed is stored outside 'main' */
+ /* Flags. */
+ ot->flag = OPTYPE_REGISTER; /* No undo, the data changed is stored outside 'main'. */
prop = RNA_def_boolean(ot->srna,
"adjust_length",
@@ -2035,7 +2050,7 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
-/* reload operator */
+/* Reload operator. */
static bool sequencer_refresh_all_poll(bContext *C)
{
if (G.is_rendering) {
@@ -2058,12 +2073,12 @@ static int sequencer_refresh_all_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Refresh Sequencer";
ot->idname = "SEQUENCER_OT_refresh_all";
ot->description = "Refresh the sequencer editor";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_refresh_all_exec;
ot->poll = sequencer_refresh_all_poll;
}
@@ -2079,7 +2094,7 @@ static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, error_msg);
return OPERATOR_CANCELLED;
}
- /* see reassigning would create a cycle */
+ /* Check if reassigning would create recursivity. */
if (seq_is_predecessor(seq1, last_seq) || seq_is_predecessor(seq2, last_seq) ||
seq_is_predecessor(seq3, last_seq)) {
BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: no cycles allowed");
@@ -2114,16 +2129,16 @@ static bool sequencer_effect_poll(bContext *C)
void SEQUENCER_OT_reassign_inputs(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Reassign Inputs";
ot->idname = "SEQUENCER_OT_reassign_inputs";
ot->description = "Reassign the inputs for the effect strip";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_reassign_inputs_exec;
ot->poll = sequencer_effect_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2149,20 +2164,20 @@ static int sequencer_swap_inputs_exec(bContext *C, wmOperator *op)
}
void SEQUENCER_OT_swap_inputs(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Swap Inputs";
ot->idname = "SEQUENCER_OT_swap_inputs";
ot->description = "Swap the first two inputs for the effect strip";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_swap_inputs_exec;
ot->poll = sequencer_effect_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* split operator */
+/* Split operator. */
static const EnumPropertyItem prop_split_types[] = {
{SEQ_SPLIT_SOFT, "SOFT", 0, "Soft", ""},
{SEQ_SPLIT_HARD, "HARD", 0, "Hard", ""},
@@ -2203,7 +2218,7 @@ static int sequencer_split_exec(bContext *C, wmOperator *op)
use_cursor_position,
split_seq_soft);
}
- if (changed) { /* got new strips ? */
+ if (changed) { /* Got new strips? */
Sequence *seq;
if (ignore_selection) {
if (use_cursor_position) {
@@ -2246,7 +2261,7 @@ static int sequencer_split_exec(bContext *C, wmOperator *op)
}
}
SEQ_END;
- /* as last: */
+
BKE_sequencer_sort(scene);
}
if (changed) {
@@ -2285,24 +2300,24 @@ static int sequencer_split_invoke(bContext *C, wmOperator *op, const wmEvent *ev
}
RNA_int_set(op->ptr, "channel", mouseloc[1]);
RNA_enum_set(op->ptr, "side", split_side);
- /*RNA_enum_set(op->ptr, "type", split_hard); */ /*This type is set from the key
- shortsplit */
+ /*RNA_enum_set(op->ptr, "type", split_hard); */
+
return sequencer_split_exec(C, op);
}
void SEQUENCER_OT_split(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Split Strips";
ot->idname = "SEQUENCER_OT_split";
ot->description = "Split the selected strips in two";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_split_invoke;
ot->exec = sequencer_split_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
PropertyRNA *prop;
@@ -2358,8 +2373,8 @@ void SEQUENCER_OT_split(struct wmOperatorType *ot)
#undef SEQ_SIDE_MOUSE
-/* duplicate operator */
-static int apply_unique_name_cb(Sequence *seq, void *arg_pt)
+/* Duplicate operator. */
+static int apply_unique_name_fn(Sequence *seq, void *arg_pt)
{
Scene *scene = (Scene *)arg_pt;
char name[sizeof(seq->name) - 2];
@@ -2385,11 +2400,11 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
if (nseqbase.first) {
Sequence *seq = nseqbase.first;
- /* rely on the nseqbase list being added at the end */
+ /* Rely on the nseqbase list being added at the end. */
BLI_movelisttolist(ed->seqbasep, &nseqbase);
for (; seq; seq = seq->next) {
- BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene);
+ BKE_sequencer_recursive_apply(seq, apply_unique_name_fn, scene);
}
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
@@ -2401,20 +2416,20 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_duplicate(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Duplicate Strips";
ot->idname = "SEQUENCER_OT_duplicate";
ot->description = "Duplicate the selected strips";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_add_duplicate_exec;
ot->poll = ED_operator_sequencer_active;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* delete operator */
+/* Delete operator. */
static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
@@ -2425,7 +2440,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
bool nothing_selected = true;
seq = BKE_sequencer_active_get(scene);
- if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */
+ if (seq && seq->flag & SELECT) { /* Avoid a loop since this is likely to be selected. */
nothing_selected = false;
}
else {
@@ -2441,7 +2456,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
- /* for effects and modifiers, try to find a replacement input */
+ /* For effects and modifiers, try to find a replacement input. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (!(seq->flag & SELECT)) {
if ((seq->type & SEQ_TYPE_EFFECT)) {
@@ -2453,17 +2468,17 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- /* delete all selected strips */
+ /* Delete all selected strips. */
recurs_del_seq_flag(scene, ed->seqbasep, SELECT, 0);
- /* updates lengths etc */
+ /* Update lengths, etc. */
seq = ed->seqbasep->first;
while (seq) {
BKE_sequence_calc(scene, seq);
seq = seq->next;
}
- /* free parent metas */
+ /* Free parent metas. */
ms = ed->metastack.last;
while (ms) {
BKE_sequence_calc(scene, ms->parseq);
@@ -2482,8 +2497,8 @@ static int sequencer_delete_invoke(bContext *C, wmOperator *op, const wmEvent *e
ARegion *region = CTX_wm_region(C);
if (region->regiontype == RGN_TYPE_WINDOW) {
- /* bounding box of 30 pixels is used for markers shortcuts,
- * prevent conflict with markers shortcuts here
+ /* Bounding box of 30 pixels is used for markers shortcuts,
+ * prevent conflict with markers shortcuts here.
*/
if (event->mval[1] <= 30) {
return OPERATOR_PASS_THROUGH;
@@ -2496,35 +2511,35 @@ static int sequencer_delete_invoke(bContext *C, wmOperator *op, const wmEvent *e
void SEQUENCER_OT_delete(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Erase Strips";
ot->idname = "SEQUENCER_OT_delete";
ot->description = "Erase selected strips from the sequencer";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_delete_invoke;
ot->exec = sequencer_delete_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* offset clear operator */
+/* Offset clear operator. */
static int sequencer_offset_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
- /* for effects, try to find a replacement input */
+ /* For effects, try to find a replacement input. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq->type & SEQ_TYPE_EFFECT) == 0 && (seq->flag & SELECT)) {
seq->startofs = seq->endofs = seq->startstill = seq->endstill = 0;
}
}
- /* updates lengths etc */
+ /* Update lengths, etc. */
seq = ed->seqbasep->first;
while (seq) {
BKE_sequence_calc(scene, seq);
@@ -2547,20 +2562,20 @@ static int sequencer_offset_clear_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_offset_clear(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Clear Strip Offset";
ot->idname = "SEQUENCER_OT_offset_clear";
ot->description = "Clear strip offsets from the start and end frames";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_offset_clear_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* separate_images operator */
+/* Separate_images operator. */
static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -2572,13 +2587,13 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
int start_ofs, cfra, frame_end;
int step = RNA_int_get(op->ptr, "length");
- seq = ed->seqbasep->first; /* poll checks this is valid */
+ seq = ed->seqbasep->first; /* Poll checks this is valid. */
while (seq) {
if ((seq->flag & SELECT) && (seq->type == SEQ_TYPE_IMAGE) && (seq->len > 1)) {
Sequence *seq_next;
- /* remove seq so overlap tests don't conflict,
+ /* 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); */
@@ -2588,7 +2603,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
frame_end = BKE_sequence_tx_get_final_right(seq, false);
while (cfra < frame_end) {
- /* new seq */
+ /* New seq. */
se = BKE_sequencer_give_stripelem(seq, cfra);
seq_new = BKE_sequence_dupli_recursive(
@@ -2599,11 +2614,11 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
seq_new->len = 1;
seq_new->endstill = step - 1;
- /* new strip */
+ /* New strip. */
strip_new = seq_new->strip;
strip_new->us = 1;
- /* new stripdata (only one element now!) */
+ /* New stripdata, only one element now. */
/* Note this assume all elements (images) have the same dimension,
* since we only copy the name here. */
se_new = MEM_reallocN(strip_new->stripdata, sizeof(*se_new));
@@ -2634,7 +2649,6 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
}
}
- /* as last: */
BKE_sequencer_sort(scene);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
@@ -2644,25 +2658,25 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_images_separate(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Separate Images";
ot->idname = "SEQUENCER_OT_images_separate";
ot->description = "On image sequence strips, it returns a strip for each image";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_separate_images_exec;
ot->invoke = WM_operator_props_popup_confirm;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_int(ot->srna, "length", 1, 1, INT_MAX, "Length", "Length of each frame", 1, 1000);
}
-/* META Operators */
+/* META Operators. */
-/* separate_meta_toggle operator */
+/* Separate_meta_toggle operator. */
static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
@@ -2671,7 +2685,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
MetaStack *ms;
if (last_seq && last_seq->type == SEQ_TYPE_META && last_seq->flag & SELECT) {
- /* Enter Metastrip */
+ /* Enter metastrip. */
ms = MEM_mallocN(sizeof(MetaStack), "metastack");
BLI_addtail(&ed->metastack, ms);
ms->parseq = last_seq;
@@ -2683,7 +2697,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
BKE_sequencer_active_set(scene, NULL);
}
else {
- /* Exit Metastrip (if possible) */
+ /* Exit metastrip if possible. */
Sequence *seq;
@@ -2696,18 +2710,18 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
ed->seqbasep = ms->oldbasep;
- /* for old files, update from meta */
+ /* For old files, update from meta. */
if (ms->disp_range[0] == ms->disp_range[1]) {
copy_v2_v2_int(ms->disp_range, &ms->parseq->startdisp);
}
- /* recalc all: the meta can have effects connected to it */
+ /* Recalc all: the meta can have effects connected to it. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
BKE_sequence_calc(scene, seq);
}
/* 2.73+, keeping endpoints is important!
- * moving them around means you can't usefully use metas in a complex edit. */
+ * Moving them around means you can't usefully use metas in a complex edit. */
#if 1
BKE_sequence_tx_set_final_left(ms->parseq, ms->disp_range[0]);
BKE_sequence_tx_set_final_right(ms->parseq, ms->disp_range[1]);
@@ -2735,20 +2749,20 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_meta_toggle(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Toggle Meta Strip";
ot->idname = "SEQUENCER_OT_meta_toggle";
ot->description = "Toggle a metastrip (to edit enclosed strips)";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_meta_toggle_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* separate_meta_make operator */
+/* Separate_meta_make operator. */
static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -2762,9 +2776,9 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* remove all selected from main list, and put in meta */
+ /* Remove all selected from main list, and put in meta. */
- seqm = BKE_sequence_alloc(ed->seqbasep, 1, 1, SEQ_TYPE_META); /* channel number set later */
+ seqm = BKE_sequence_alloc(ed->seqbasep, 1, 1, SEQ_TYPE_META); /* Channel number set later. */
strcpy(seqm->name + 2, "MetaStrip");
seqm->flag = SELECT;
@@ -2799,16 +2813,16 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_meta_make(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Make Meta Strip";
ot->idname = "SEQUENCER_OT_meta_make";
ot->description = "Group selected strips into a metastrip";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_meta_make_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2831,7 +2845,7 @@ static int seq_depends_on_meta(Sequence *seq, Sequence *seqm)
}
}
-/* separate_meta_make operator */
+/* Separate_meta_make operator. */
static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
@@ -2854,7 +2868,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
BLI_remlink(ed->seqbasep, last_seq);
BKE_sequence_free(scene, last_seq);
- /* empty meta strip, delete all effects depending on it */
+ /* Empty meta strip, delete all effects depending on it. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq->type & SEQ_TYPE_EFFECT) && seq_depends_on_meta(seq, last_seq)) {
seq->flag |= SEQ_FLAG_DELETE;
@@ -2863,8 +2877,8 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
recurs_del_seq_flag(scene, ed->seqbasep, SEQ_FLAG_DELETE, 0);
- /* test for effects and overlap
- * don't use SEQP_BEGIN since that would be recursive */
+ /* Test for effects and overlap
+ * don't use SEQP_BEGIN since that would be recursive. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT) {
seq->flag &= ~SEQ_OVERLAP;
@@ -2884,20 +2898,20 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_meta_separate(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "UnMeta Strip";
ot->idname = "SEQUENCER_OT_meta_separate";
ot->description = "Put the contents of a metastrip back in the sequencer";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_meta_separate_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* view_all operator */
+/* View_all operator. */
static int sequencer_view_all_exec(bContext *C, wmOperator *op)
{
ARegion *region = CTX_wm_region(C);
@@ -2912,16 +2926,16 @@ static int sequencer_view_all_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_view_all(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "View All";
ot->idname = "SEQUENCER_OT_view_all";
ot->description = "View all the strips in the sequencer";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_view_all_exec;
ot->poll = ED_operator_sequencer_active;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER;
}
@@ -2935,23 +2949,23 @@ static int sequencer_view_frame_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_view_frame(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Go to Current Frame";
ot->idname = "SEQUENCER_OT_view_frame";
ot->description = "Move the view to the playhead";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_view_frame_exec;
ot->poll = ED_operator_sequencer_active;
- /* flags */
+ /* Flags. */
ot->flag = 0;
}
-/* view_all operator */
+/* View_all operator. */
static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op))
{
- bScreen *sc = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
ScrArea *area = CTX_wm_area(C);
#if 0
ARegion *region = CTX_wm_region(C);
@@ -2962,10 +2976,10 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op))
v2d->cur = v2d->tot;
UI_view2d_curRect_validate(v2d);
- UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY);
+ UI_view2d_sync(screen, area, v2d, V2D_LOCK_COPY);
#if 0
- /* Like zooming on an image view */
+ /* Like zooming on an image view. */
float zoomX, zoomY;
int width, height, imgwidth, imgheight;
@@ -2977,11 +2991,11 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op))
imgwidth = (scene->r.size * scene->r.xsch) / 100;
imgheight = (scene->r.size * scene->r.ysch) / 100;
- /* Apply aspect, doesn't need to be that accurate */
+ /* Apply aspect, doesn't need to be that accurate. */
imgwidth = (int)(imgwidth * (scene->r.xasp / scene->r.yasp));
if (((imgwidth >= width) || (imgheight >= height)) && ((width > 0) && (height > 0))) {
- /* Find the zoom value that will fit the image in the image space */
+ /* Find the zoom value that will fit the image in the image space. */
zoomX = ((float)width) / ((float)imgwidth);
zoomY = ((float)height) / ((float)imgheight);
sseq->zoom = (zoomX < zoomY) ? zoomX : zoomY;
@@ -2999,16 +3013,16 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_view_all_preview(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "View All";
ot->idname = "SEQUENCER_OT_view_all_preview";
ot->description = "Zoom preview to fit in the area";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_view_all_preview_exec;
ot->poll = ED_operator_sequencer_active;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER;
}
@@ -3034,16 +3048,16 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_view_zoom_ratio(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Sequencer View Zoom Ratio";
ot->idname = "SEQUENCER_OT_view_zoom_ratio";
ot->description = "Change zoom ratio of sequencer preview";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_view_zoom_ratio_exec;
ot->poll = ED_operator_sequencer_active;
- /* properties */
+ /* Properties. */
RNA_def_float(ot->srna,
"ratio",
1.0f,
@@ -3068,7 +3082,7 @@ static const EnumPropertyItem view_type_items[] = {
};
#endif
-/* view_all operator */
+/* View_all operator. */
static int sequencer_view_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C);
@@ -3085,20 +3099,20 @@ static int sequencer_view_toggle_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_view_toggle(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "View Toggle";
ot->idname = "SEQUENCER_OT_view_toggle";
ot->description = "Toggle between sequencer views (sequence, preview, both)";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_view_toggle_exec;
ot->poll = ED_operator_sequencer_active;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER;
}
-/* view_selected operator */
+/* View_selected operator. */
static int sequencer_view_selected_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -3148,7 +3162,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *op)
cur_new.ymin = ymin;
cur_new.ymax = ymax;
- /* only zoom out vertically */
+ /* Only zoom out vertically. */
if (orig_height > BLI_rctf_size_y(&cur_new)) {
ymid = BLI_rctf_cent_y(&cur_new);
@@ -3167,16 +3181,16 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_view_selected(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Frame Selected";
ot->idname = "SEQUENCER_OT_view_selected";
ot->description = "Zoom the sequencer on the selected strips";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_view_selected_exec;
ot->poll = ED_operator_sequencer_active;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER;
}
@@ -3199,7 +3213,7 @@ static bool strip_jump_internal(Scene *scene,
static bool sequencer_strip_jump_poll(bContext *C)
{
- /* prevent changes during render */
+ /* Prevent changes during render. */
if (G.is_rendering) {
return 0;
}
@@ -3207,14 +3221,14 @@ static bool sequencer_strip_jump_poll(bContext *C)
return sequencer_edit_poll(C);
}
-/* jump frame to edit point operator */
+/* Jump frame to edit point operator. */
static int sequencer_strip_jump_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
const bool next = RNA_boolean_get(op->ptr, "next");
const bool center = RNA_boolean_get(op->ptr, "center");
- /* currently do_skip_mute is always true */
+ /* Currently do_skip_mute is always true. */
if (!strip_jump_internal(scene, next ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT, true, center)) {
return OPERATOR_CANCELLED;
}
@@ -3226,19 +3240,19 @@ static int sequencer_strip_jump_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_strip_jump(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Jump to Strip";
ot->idname = "SEQUENCER_OT_strip_jump";
ot->description = "Move frame to previous edit point";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_strip_jump_exec;
ot->poll = sequencer_strip_jump_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_UNDO;
- /* properties */
+ /* Properties. */
RNA_def_boolean(ot->srna, "next", true, "Next Strip", "");
RNA_def_boolean(ot->srna, "center", true, "Use strip center", "");
}
@@ -3296,7 +3310,7 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op)
if (seq) {
- /* disallow effect strips */
+ /* Disallow effect strips. */
if (BKE_sequence_effect_get_num_inputs(seq->type) >= 1 &&
(seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3)) {
return OPERATOR_CANCELLED;
@@ -3315,7 +3329,7 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op)
break;
}
- // XXX - should be a generic function
+ /* XXX - Should be a generic function. */
for (iseq = scene->ed->seqbasep->first; iseq; iseq = iseq->next) {
if ((iseq->type & SEQ_TYPE_EFFECT) &&
(seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) {
@@ -3323,11 +3337,11 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op)
}
}
- /* do this in a new loop since both effects need to be calculated first */
+ /* Do this in a new loop since both effects need to be calculated first. */
for (iseq = scene->ed->seqbasep->first; iseq; iseq = iseq->next) {
if ((iseq->type & SEQ_TYPE_EFFECT) &&
(seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) {
- /* this may now overlap */
+ /* This may now overlap. */
if (BKE_sequence_test_overlap(ed->seqbasep, iseq)) {
BKE_sequence_base_shuffle(ed->seqbasep, iseq, scene);
}
@@ -3346,19 +3360,19 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_swap(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Swap Strip";
ot->idname = "SEQUENCER_OT_swap";
ot->description = "Swap active strip with strip to the right or left";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_swap_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
+ /* Properties. */
RNA_def_enum(
ot->srna, "side", prop_side_lr_types, SEQ_SIDE_RIGHT, "Side", "Side of the strip to swap");
}
@@ -3392,7 +3406,7 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op))
}
if (se) {
- // prevent setting the render size if sequence values aren't initialized
+ /* Prevent setting the render size if sequence values aren't initialized. */
if ((se->orig_width > 0) && (se->orig_height > 0)) {
scene->r.xsch = se->orig_width;
scene->r.ysch = se->orig_height;
@@ -3406,19 +3420,17 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_rendersize(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Set Render Size";
ot->idname = "SEQUENCER_OT_rendersize";
ot->description = "Set render size and aspect from active sequence";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_rendersize_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
}
static void seq_copy_del_sound(Scene *scene, Sequence *seq)
@@ -3453,15 +3465,14 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
BKE_sequence_base_dupli_recursive(
scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME, LIB_ID_CREATE_NO_USER_REFCOUNT);
- /* To make sure the copied strips have unique names between each other add
- * them temporarily to the end of the original seqbase. (bug 25932)
- */
+ /* Make sure that copied strips have unique names.
+ * Add them temporarily to the end of the original seqbase (bug 25932). */
if (nseqbase.first) {
Sequence *seq, *first_seq = nseqbase.first;
BLI_movelisttolist(ed->seqbasep, &nseqbase);
for (seq = first_seq; seq; seq = seq->next) {
- BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene);
+ BKE_sequencer_recursive_apply(seq, apply_unique_name_fn, scene);
}
seqbase_clipboard.first = first_seq;
@@ -3476,8 +3487,8 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
seqbase_clipboard_frame = scene->r.cfra;
- /* Need to remove anything that references the current scene */
- for (Sequence *seq = seqbase_clipboard.first; seq; seq = seq->next) {
+ /* Remove anything that references the current scene. */
+ LISTBASE_FOREACH (Sequence *, seq, &seqbase_clipboard) {
seq_copy_del_sound(scene, seq);
}
@@ -3490,26 +3501,24 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_copy(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Copy";
ot->idname = "SEQUENCER_OT_copy";
ot->description = "Copy selected strips to clipboard";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_copy_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER;
-
- /* properties */
}
static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, true); /* create if needed */
+ Editing *ed = BKE_sequencer_editing_get(scene, true); /* Create if needed. */
ListBase nseqbase = {NULL, NULL};
int ofs;
Sequence *iseq, *iseq_first;
@@ -3525,7 +3534,7 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op))
scene, scene, &nseqbase, &seqbase_clipboard, SEQ_DUPE_UNIQUE_NAME, 0);
BKE_sequencer_base_clipboard_pointers_store(bmain, &seqbase_clipboard);
- /* transform pasted strips before adding */
+ /* Transform pasted strips before adding. */
if (ofs) {
for (iseq = nseqbase.first; iseq; iseq = iseq->next) {
BKE_sequence_translate(scene, iseq, ofs);
@@ -3536,12 +3545,12 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op))
BLI_movelisttolist(ed->seqbasep, &nseqbase);
- /* make sure the pasted strips have unique names between them */
+ /* Make sure, that pasted strips have unique names. */
for (iseq = iseq_first; iseq; iseq = iseq->next) {
- BKE_sequencer_recursive_apply(iseq, apply_unique_name_cb, scene);
+ BKE_sequencer_recursive_apply(iseq, apply_unique_name_fn, scene);
}
- /* ensure pasted strips don't overlap */
+ /* Ensure, that pasted strips don't overlap. */
for (iseq = iseq_first; iseq; iseq = iseq->next) {
if (BKE_sequence_test_overlap(ed->seqbasep, iseq)) {
BKE_sequence_base_shuffle(ed->seqbasep, iseq, scene);
@@ -3556,19 +3565,17 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_paste(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Paste";
ot->idname = "SEQUENCER_OT_paste";
ot->description = "Paste strips from clipboard";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_paste_exec;
ot->poll = ED_operator_sequencer_active;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
}
static int sequencer_swap_data_exec(bContext *C, wmOperator *op)
@@ -3619,22 +3626,20 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_swap_data(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Sequencer Swap Data";
ot->idname = "SEQUENCER_OT_swap_data";
ot->description = "Swap 2 sequencer strips";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_swap_data_exec;
ot->poll = ED_operator_sequencer_active;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
}
-/* box select operator */
+/* Box select operator. */
static int view_ghost_border_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -3642,7 +3647,7 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op)
rctf rect;
- /* convert coordinates of rect to 'tot' rect coordinates */
+ /* Convert coordinates of rect to 'tot' rect coordinates. */
WM_operator_properties_border_to_rctf(op, &rect);
UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
@@ -3669,30 +3674,28 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-/* ****** Box Select ****** */
void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Border Offset View";
ot->idname = "SEQUENCER_OT_view_ghost_border";
ot->description = "Set the boundaries of the border used for offset-view";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = WM_gesture_box_invoke;
ot->exec = view_ghost_border_exec;
ot->modal = WM_gesture_box_modal;
ot->poll = sequencer_view_preview_poll;
ot->cancel = WM_gesture_box_cancel;
- /* flags */
+ /* Flags. */
ot->flag = 0;
- /* rna */
+ /* Properties. */
WM_operator_properties_gesture_box(ot);
}
-/* rebuild_proxy operator */
-
+/* Rebuild_proxy operator. */
static int sequencer_rebuild_proxy_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
@@ -3743,16 +3746,16 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Rebuild Proxy and Timecode Indices";
ot->idname = "SEQUENCER_OT_rebuild_proxy";
ot->description = "Rebuild all selected proxies and timecode indices using the job system";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_rebuild_proxy_invoke;
ot->exec = sequencer_rebuild_proxy_exec;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER;
}
@@ -3838,16 +3841,16 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_enable_proxies(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Set Selected Strip Proxies";
ot->idname = "SEQUENCER_OT_enable_proxies";
ot->description = "Enable selected proxies on all selected Movie, Image and Meta strips";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_enable_proxies_invoke;
ot->exec = sequencer_enable_proxies_exec;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER;
RNA_def_boolean(ot->srna, "proxy_25", false, "25%", "");
@@ -3857,8 +3860,7 @@ void SEQUENCER_OT_enable_proxies(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "overwrite", false, "Overwrite", "");
}
-/* change ops */
-
+/* Change effect inputs operator. */
static const EnumPropertyItem prop_change_effect_input_types[] = {
{0, "A_B", 0, "A -> B", ""},
{1, "B_C", 0, "B -> C", ""},
@@ -3899,9 +3901,8 @@ static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op)
BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
- /* important else we don't get the imbuf cache flushed */
+ /* Invalidate cache. */
BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
-
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
@@ -3909,21 +3910,22 @@ static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Change Effect Input";
ot->idname = "SEQUENCER_OT_change_effect_input";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_change_effect_input_exec;
ot->poll = sequencer_effect_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
ot->prop = RNA_def_enum(
ot->srna, "swap", prop_change_effect_input_types, 0, "Swap", "The effect inputs to swap");
}
+/* Change effect type operator. */
static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -3931,14 +3933,14 @@ static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op)
Sequence *seq = BKE_sequencer_active_get(scene);
const int new_type = RNA_enum_get(op->ptr, "type");
- /* free previous effect and init new effect */
+ /* Free previous effect and init new effect. */
struct SeqEffectHandle sh;
if ((seq->type & SEQ_TYPE_EFFECT) == 0) {
return OPERATOR_CANCELLED;
}
- /* can someone explain the logic behind only allowing to increase this,
+ /* Can someone explain the logic behind only allowing to increase this,
* copied from 2.4x - campbell */
if (BKE_sequence_effect_get_num_inputs(seq->type) <
BKE_sequence_effect_get_num_inputs(new_type)) {
@@ -3955,10 +3957,8 @@ static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op)
sh.init(seq);
}
- /* update */
BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
-
- /* important else we don't get the imbuf cache flushed */
+ /* Invalidate cache. */
BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
@@ -3968,15 +3968,15 @@ static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Change Effect Type";
ot->idname = "SEQUENCER_OT_change_effect_type";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_change_effect_type_exec;
ot->poll = sequencer_effect_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
ot->prop = RNA_def_enum(ot->srna,
@@ -3987,6 +3987,7 @@ void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot)
"Sequencer effect type");
}
+/* Change path operator. */
static int sequencer_change_path_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@@ -4002,7 +4003,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
int len;
StripElem *se;
- /* need to find min/max frame for placeholders */
+ /* Need to find min/max frame for placeholders. */
if (use_placeholders) {
len = sequencer_image_seq_get_minmax_frame(op, seq->sfra, &minframe, &numdigits);
}
@@ -4040,16 +4041,16 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
RNA_END;
}
- /* reset these else we wont see all the images */
+ /* Reset these else we wont see all the images. */
seq->anim_startofs = seq->anim_endofs = 0;
- /* correct start/end frames so we don't move
- * important not to set seq->len = len; allow the function to handle it */
+ /* Correct start/end frames so we don't move.
+ * Important not to set seq->len = len; allow the function to handle it. */
BKE_sequence_reload_new_file(bmain, scene, seq, true);
BKE_sequence_calc(scene, seq);
- /* important else we don't get the imbuf cache flushed */
+ /* Invalidate cache. */
BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
}
else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
@@ -4063,7 +4064,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
BKE_sound_load(bmain, sound);
}
else {
- /* lame, set rna filepath */
+ /* Lame, set rna filepath. */
PointerRNA seq_ptr;
PropertyRNA *prop;
char filepath[FILE_MAX];
@@ -4092,7 +4093,7 @@ static int sequencer_change_path_invoke(bContext *C, wmOperator *op, const wmEve
RNA_string_set(op->ptr, "directory", seq->strip->dir);
RNA_string_set(op->ptr, "filepath", filepath);
- /* set default display depending on seq type */
+ /* Set default display depending on seq type. */
if (seq->type == SEQ_TYPE_IMAGE) {
RNA_boolean_set(op->ptr, "filter_movie", false);
}
@@ -4107,16 +4108,16 @@ static int sequencer_change_path_invoke(bContext *C, wmOperator *op, const wmEve
void SEQUENCER_OT_change_path(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Change Data/Files";
ot->idname = "SEQUENCER_OT_change_path";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_change_path_exec;
ot->invoke = sequencer_change_path_invoke;
ot->poll = sequencer_strip_has_path_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_filesel(ot,
@@ -4134,6 +4135,7 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot)
"Use placeholders for missing frames of the strip");
}
+/* Export subtitles operator. */
static int sequencer_export_subtitles_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
@@ -4176,7 +4178,7 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", filepath);
BLI_path_extension_ensure(filepath, sizeof(filepath), ".srt");
- /* Avoid File write exceptions */
+ /* Avoid File write exceptions. */
if (!BLI_exists(filepath)) {
BLI_make_existing_file(filepath);
if (!BLI_file_touch(filepath)) {
@@ -4203,7 +4205,7 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
BLI_listbase_sort(&text_seq, BKE_sequencer_cmp_time_startdisp);
- /* time to open and write! */
+ /* Open and write file. */
file = BLI_fopen(filepath, "w");
for (seq = text_seq.first; seq; seq = seq_next) {
@@ -4246,17 +4248,17 @@ static bool sequencer_strip_is_text_poll(bContext *C)
void SEQUENCER_OT_export_subtitles(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Export Subtitles";
ot->idname = "SEQUENCER_OT_export_subtitles";
ot->description = "Export .srt file containing text strips";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_export_subtitles_exec;
ot->invoke = sequencer_export_subtitles_invoke;
ot->poll = sequencer_strip_is_text_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_filesel(ot,
@@ -4268,6 +4270,7 @@ void SEQUENCER_OT_export_subtitles(struct wmOperatorType *ot)
FILE_SORT_ALPHA);
}
+/* Set range to strips operator. */
static int sequencer_set_range_to_strips_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -4316,16 +4319,16 @@ void SEQUENCER_OT_set_range_to_strips(struct wmOperatorType *ot)
{
PropertyRNA *prop;
- /* identifiers */
+ /* Identifiers. */
ot->name = "Set Range to Strips";
ot->idname = "SEQUENCER_OT_set_range_to_strips";
ot->description = "Set the frame range to the selected strips start and end";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_set_range_to_strips_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
prop = RNA_def_boolean(ot->srna, "preview", false, "Preview", "Set the preview range instead");
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index f70bc06caf7..708682cd04f 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -27,7 +27,7 @@
#include "DNA_sequence_types.h"
#include "RNA_access.h"
-/* internal exports only */
+/* Internal exports only. */
struct ARegion;
struct ARegionType;
@@ -57,7 +57,7 @@ void sequencer_special_update_set(Sequence *seq);
float sequence_handle_size_get_clamped(struct Sequence *seq, const float pixelx);
/* UNUSED */
-// void seq_reset_imageofs(struct SpaceSeq *sseq);
+/* void seq_reset_imageofs(struct SpaceSeq *sseq); */
struct ImBuf *sequencer_ibuf_get(struct Main *bmain,
struct Depsgraph *depsgraph,
@@ -88,19 +88,19 @@ int seq_effect_find_selected(struct Scene *scene,
struct Sequence **r_selseq3,
const char **r_error_str);
-/* operator helpers */
+/* Operator helpers. */
bool sequencer_edit_poll(struct bContext *C);
/* UNUSED */
-// bool sequencer_strip_poll(struct bContext *C);
+/* bool sequencer_strip_poll(struct bContext *C); */
bool sequencer_strip_has_path_poll(struct bContext *C);
bool sequencer_view_preview_poll(struct bContext *C);
bool sequencer_view_strips_poll(struct bContext *C);
-/* externs */
+/* Externs. */
extern EnumPropertyItem sequencer_prop_effect_types[];
extern EnumPropertyItem prop_side_types[];
-/* operators */
+/* Operators. */
struct wmKeyConfig;
struct wmOperatorType;
@@ -152,7 +152,7 @@ void SEQUENCER_OT_export_subtitles(struct wmOperatorType *ot);
void SEQUENCER_OT_set_range_to_strips(struct wmOperatorType *ot);
-/* preview specific operators */
+/* Preview specific operators. */
void SEQUENCER_OT_view_all_preview(struct wmOperatorType *ot);
/* sequencer_select.c */
@@ -193,8 +193,8 @@ enum {
SEQ_SELECT_LR_RIGHT,
};
-/* defines used internally */
-#define SCE_MARKERS 0 // XXX - dummy
+/* Defines used internally. */
+#define SCE_MARKERS 0 /* XXX - dummy */
/* sequencer_ops.c */
void sequencer_operatortypes(void);
@@ -222,7 +222,7 @@ void SEQUENCER_OT_sample(struct wmOperatorType *ot);
/* sequencer_preview.c */
void sequencer_preview_add_sound(const struct bContext *C, struct Sequence *seq);
-/* sequencer_add */
+/* sequencer_add.c */
int sequencer_image_seq_get_minmax_frame(struct wmOperator *op,
int sfra,
int *r_minframe,
diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c
index b90dc5e10ff..e0f7179c3f9 100644
--- a/source/blender/editors/space_sequencer/sequencer_modifier.c
+++ b/source/blender/editors/space_sequencer/sequencer_modifier.c
@@ -35,7 +35,7 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
-/* own include */
+/* Own include. */
#include "sequencer_intern.h"
/*********************** Add modifier operator *************************/
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index 4296701366a..ac00838a079 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -32,7 +32,7 @@
#include "ED_markers.h"
#include "ED_select_utils.h"
#include "ED_sequencer.h"
-#include "ED_transform.h" /* transform keymap */
+#include "ED_transform.h" /* Transform keymap. */
#include "BKE_sequencer.h"
diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c
index 7c8a5ff5981..7d416884721 100644
--- a/source/blender/editors/space_sequencer/sequencer_preview.c
+++ b/source/blender/editors/space_sequencer/sequencer_preview.c
@@ -52,9 +52,9 @@ typedef struct PreviewJobAudio {
struct PreviewJobAudio *next, *prev;
struct Main *bmain;
bSound *sound;
- int lr; /* sample left or right */
+ int lr; /* Sample left or right. */
int startframe;
- bool waveform; /* reload sound or waveform */
+ bool waveform; /* Reload sound or waveform. */
} PreviewJobAudio;
static void free_preview_job(void *data)
@@ -66,7 +66,7 @@ static void free_preview_job(void *data)
MEM_freeN(pj);
}
-/* only this runs inside thread */
+/* Only this runs inside thread. */
static void preview_startjob(void *data, short *stop, short *do_update, float *progress)
{
PreviewJob *pj = data;
@@ -89,7 +89,7 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p
while (previewjb) {
sound = previewjb->sound;
- /* make sure we cleanup the loading flag! */
+ /* Make sure we cleanup the loading flag! */
BLI_spin_lock(sound->spinlock);
sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING;
BLI_spin_unlock(sound->spinlock);
@@ -127,10 +127,9 @@ static void preview_endjob(void *data)
void sequencer_preview_add_sound(const bContext *C, Sequence *seq)
{
- /* first, get the preview job, if it exists */
wmJob *wm_job;
PreviewJob *pj;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
PreviewJobAudio *audiojob = MEM_callocN(sizeof(PreviewJobAudio), "preview_audio");
wm_job = WM_jobs_get(CTX_wm_manager(C),
CTX_wm_window(C),
@@ -139,6 +138,7 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq)
WM_JOB_PROGRESS,
WM_JOB_TYPE_SEQ_BUILD_PREVIEW);
+ /* Get the preview job if it exists. */
pj = WM_jobs_customdata_get(wm_job);
if (!pj) {
@@ -152,8 +152,6 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq)
WM_jobs_callbacks(wm_job, preview_startjob, NULL, NULL, preview_endjob);
}
- /* attempt to lock mutex of job here */
-
audiojob->bmain = CTX_data_main(C);
audiojob->sound = seq->sound;
@@ -167,5 +165,5 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq)
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c
index 309840ea9e3..b08c35623af 100644
--- a/source/blender/editors/space_sequencer/sequencer_scopes.c
+++ b/source/blender/editors/space_sequencer/sequencer_scopes.c
@@ -42,7 +42,7 @@ static void rgb_to_yuv_normalized(const float rgb[3], float yuv[3])
yuv[1] = 0.492f * (rgb[2] - yuv[0]);
yuv[2] = 0.877f * (rgb[0] - yuv[0]);
- /* Normalize */
+ /* Normalize. */
yuv[1] *= 255.0f / (122 * 2.0f);
yuv[1] += 0.5f;
@@ -50,24 +50,24 @@ static void rgb_to_yuv_normalized(const float rgb[3], float yuv[3])
yuv[2] += 0.5f;
}
-static void scope_put_pixel(unsigned char *table, unsigned char *pos)
+static void scope_put_pixel(uchar *table, uchar *pos)
{
- unsigned char newval = table[*pos];
+ uchar newval = table[*pos];
pos[0] = pos[1] = pos[2] = newval;
pos[3] = 255;
}
-static void scope_put_pixel_single(unsigned char *table, unsigned char *pos, int col)
+static void scope_put_pixel_single(uchar *table, uchar *pos, int col)
{
char newval = table[pos[col]];
pos[col] = newval;
pos[3] = 255;
}
-static void wform_put_line(int w, unsigned char *last_pos, unsigned char *new_pos)
+static void wform_put_line(int w, uchar *last_pos, uchar *new_pos)
{
if (last_pos > new_pos) {
- unsigned char *temp = new_pos;
+ uchar *temp = new_pos;
new_pos = last_pos;
last_pos = temp;
}
@@ -81,10 +81,10 @@ static void wform_put_line(int w, unsigned char *last_pos, unsigned char *new_po
}
}
-static void wform_put_line_single(int w, unsigned char *last_pos, unsigned char *new_pos, int col)
+static void wform_put_line_single(int w, uchar *last_pos, uchar *new_pos, int col)
{
if (last_pos > new_pos) {
- unsigned char *temp = new_pos;
+ uchar *temp = new_pos;
new_pos = last_pos;
last_pos = temp;
}
@@ -98,12 +98,12 @@ static void wform_put_line_single(int w, unsigned char *last_pos, unsigned char
}
}
-static void wform_put_border(unsigned char *tgt, int w, int h)
+static void wform_put_border(uchar *tgt, int w, int h)
{
int x, y;
for (x = 0; x < w; x++) {
- unsigned char *p = tgt + 4 * x;
+ uchar *p = tgt + 4 * x;
p[1] = p[3] = 155;
p[4 * w + 1] = p[4 * w + 3] = 155;
p = tgt + 4 * (w * (h - 1) + x);
@@ -112,7 +112,7 @@ static void wform_put_border(unsigned char *tgt, int w, int h)
}
for (y = 0; y < h; y++) {
- unsigned char *p = tgt + 4 * w * y;
+ uchar *p = tgt + 4 * w * y;
p[1] = p[3] = 155;
p[4 + 1] = p[4 + 3] = 155;
p = tgt + 4 * (w * y + w - 1);
@@ -121,7 +121,7 @@ static void wform_put_border(unsigned char *tgt, int w, int h)
}
}
-static void wform_put_gridrow(unsigned char *tgt, float perc, int w, int h)
+static void wform_put_gridrow(uchar *tgt, float perc, int w, int h)
{
int i;
@@ -134,7 +134,7 @@ static void wform_put_gridrow(unsigned char *tgt, float perc, int w, int h)
}
}
-static void wform_put_grid(unsigned char *tgt, int w, int h)
+static void wform_put_grid(uchar *tgt, int w, int h)
{
wform_put_gridrow(tgt, 90.0, w, h);
wform_put_gridrow(tgt, 70.0, w, h);
@@ -145,27 +145,27 @@ static ImBuf *make_waveform_view_from_ibuf_byte(ImBuf *ibuf)
{
ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect);
int x, y;
- const unsigned char *src = (unsigned char *)ibuf->rect;
- unsigned char *tgt = (unsigned char *)rval->rect;
+ const uchar *src = (uchar *)ibuf->rect;
+ uchar *tgt = (uchar *)rval->rect;
int w = ibuf->x + 3;
int h = 515;
float waveform_gamma = 0.2;
- unsigned char wtable[256];
+ uchar wtable[256];
wform_put_grid(tgt, w, h);
wform_put_border(tgt, w, h);
for (x = 0; x < 256; x++) {
- wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, waveform_gamma) * 255);
+ wtable[x] = (uchar)(pow(((float)x + 1) / 256, waveform_gamma) * 255);
}
for (y = 0; y < ibuf->y; y++) {
- unsigned char *last_p = NULL;
+ uchar *last_p = NULL;
for (x = 0; x < ibuf->x; x++) {
- const unsigned char *rgb = src + 4 * (ibuf->x * y + x);
+ const uchar *rgb = src + 4 * (ibuf->x * y + x);
float v = (float)IMB_colormanagement_get_luminance_byte(rgb) / 255.0f;
- unsigned char *p = tgt;
+ uchar *p = tgt;
p += 4 * (w * ((int)(v * (h - 3)) + 1) + x + 1);
scope_put_pixel(wtable, p);
@@ -187,25 +187,25 @@ static ImBuf *make_waveform_view_from_ibuf_float(ImBuf *ibuf)
ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect);
int x, y;
const float *src = ibuf->rect_float;
- unsigned char *tgt = (unsigned char *)rval->rect;
+ uchar *tgt = (uchar *)rval->rect;
int w = ibuf->x + 3;
int h = 515;
float waveform_gamma = 0.2;
- unsigned char wtable[256];
+ uchar wtable[256];
wform_put_grid(tgt, w, h);
for (x = 0; x < 256; x++) {
- wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, waveform_gamma) * 255);
+ wtable[x] = (uchar)(pow(((float)x + 1) / 256, waveform_gamma) * 255);
}
for (y = 0; y < ibuf->y; y++) {
- unsigned char *last_p = NULL;
+ uchar *last_p = NULL;
for (x = 0; x < ibuf->x; x++) {
const float *rgb = src + 4 * (ibuf->x * y + x);
float v = IMB_colormanagement_get_luminance(rgb);
- unsigned char *p = tgt;
+ uchar *p = tgt;
CLAMP(v, 0.0f, 1.0f);
@@ -241,28 +241,28 @@ static ImBuf *make_sep_waveform_view_from_ibuf_byte(ImBuf *ibuf)
{
ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect);
int x, y;
- const unsigned char *src = (const unsigned char *)ibuf->rect;
- unsigned char *tgt = (unsigned char *)rval->rect;
+ const uchar *src = (const uchar *)ibuf->rect;
+ uchar *tgt = (uchar *)rval->rect;
int w = ibuf->x + 3;
int sw = ibuf->x / 3;
int h = 515;
float waveform_gamma = 0.2;
- unsigned char wtable[256];
+ uchar wtable[256];
wform_put_grid(tgt, w, h);
for (x = 0; x < 256; x++) {
- wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, waveform_gamma) * 255);
+ wtable[x] = (uchar)(pow(((float)x + 1) / 256, waveform_gamma) * 255);
}
for (y = 0; y < ibuf->y; y++) {
- unsigned char *last_p[3] = {NULL, NULL, NULL};
+ uchar *last_p[3] = {NULL, NULL, NULL};
for (x = 0; x < ibuf->x; x++) {
int c;
- const unsigned char *rgb = src + 4 * (ibuf->x * y + x);
+ const uchar *rgb = src + 4 * (ibuf->x * y + x);
for (c = 0; c < 3; c++) {
- unsigned char *p = tgt;
+ uchar *p = tgt;
p += 4 * (w * ((rgb[c] * (h - 3)) / 255 + 1) + c * sw + x / 3 + 1);
scope_put_pixel_single(wtable, p, c);
@@ -287,27 +287,27 @@ static ImBuf *make_sep_waveform_view_from_ibuf_float(ImBuf *ibuf)
ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect);
int x, y;
const float *src = ibuf->rect_float;
- unsigned char *tgt = (unsigned char *)rval->rect;
+ uchar *tgt = (uchar *)rval->rect;
int w = ibuf->x + 3;
int sw = ibuf->x / 3;
int h = 515;
float waveform_gamma = 0.2;
- unsigned char wtable[256];
+ uchar wtable[256];
wform_put_grid(tgt, w, h);
for (x = 0; x < 256; x++) {
- wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, waveform_gamma) * 255);
+ wtable[x] = (uchar)(pow(((float)x + 1) / 256, waveform_gamma) * 255);
}
for (y = 0; y < ibuf->y; y++) {
- unsigned char *last_p[3] = {NULL, NULL, NULL};
+ uchar *last_p[3] = {NULL, NULL, NULL};
for (x = 0; x < ibuf->x; x++) {
int c;
const float *rgb = src + 4 * (ibuf->x * y + x);
for (c = 0; c < 3; c++) {
- unsigned char *p = tgt;
+ uchar *p = tgt;
float v = rgb[c];
CLAMP(v, 0.0f, 1.0f);
@@ -343,18 +343,18 @@ ImBuf *make_sep_waveform_view_from_ibuf(ImBuf *ibuf)
static void draw_zebra_byte(ImBuf *src, ImBuf *ibuf, float perc)
{
- unsigned int limit = 255.0f * perc / 100.0f;
- unsigned char *p = (unsigned char *)src->rect;
- unsigned char *o = (unsigned char *)ibuf->rect;
+ uint limit = 255.0f * perc / 100.0f;
+ uchar *p = (uchar *)src->rect;
+ uchar *o = (uchar *)ibuf->rect;
int x;
int y;
for (y = 0; y < ibuf->y; y++) {
for (x = 0; x < ibuf->x; x++) {
- unsigned char r = *p++;
- unsigned char g = *p++;
- unsigned char b = *p++;
- unsigned char a = *p++;
+ uchar r = *p++;
+ uchar g = *p++;
+ uchar b = *p++;
+ uchar a = *p++;
if (r >= limit || g >= limit || b >= limit) {
if (((x + y) & 0x08) != 0) {
@@ -375,7 +375,7 @@ static void draw_zebra_float(ImBuf *src, ImBuf *ibuf, float perc)
{
float limit = perc / 100.0f;
const float *p = src->rect_float;
- unsigned char *o = (unsigned char *)ibuf->rect;
+ uchar *o = (uchar *)ibuf->rect;
int x;
int y;
@@ -417,7 +417,7 @@ ImBuf *make_zebra_view_from_ibuf(ImBuf *src, float perc)
static void draw_histogram_marker(ImBuf *ibuf, int x)
{
- unsigned char *p = (unsigned char *)ibuf->rect;
+ uchar *p = (uchar *)ibuf->rect;
int barh = ibuf->y * 0.1;
int i;
@@ -431,7 +431,7 @@ static void draw_histogram_marker(ImBuf *ibuf, int x)
static void draw_histogram_bar(ImBuf *ibuf, int x, float val, int col)
{
- unsigned char *p = (unsigned char *)ibuf->rect;
+ uchar *p = (uchar *)ibuf->rect;
int barh = ibuf->y * val * 0.9f;
int i;
@@ -450,18 +450,18 @@ typedef struct MakeHistogramViewData {
uint32_t (*bins)[HIS_STEPS];
} MakeHistogramViewData;
-static void make_histogram_view_from_ibuf_byte_cb_ex(void *__restrict userdata,
+static void make_histogram_view_from_ibuf_byte_fn(void *__restrict userdata,
const int y,
const TaskParallelTLS *__restrict tls)
{
MakeHistogramViewData *data = userdata;
const ImBuf *ibuf = data->ibuf;
- const unsigned char *src = (unsigned char *)ibuf->rect;
+ const uchar *src = (uchar *)ibuf->rect;
uint32_t(*cur_bins)[HIS_STEPS] = tls->userdata_chunk;
for (int x = 0; x < ibuf->x; x++) {
- const unsigned char *pixel = src + (y * ibuf->x + x) * 4;
+ const uchar *pixel = src + (y * ibuf->x + x) * 4;
for (int j = 3; j--;) {
cur_bins[j][pixel[j]]++;
@@ -488,9 +488,9 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
{
ImBuf *rval = IMB_allocImBuf(515, 128, 32, IB_rect);
int x;
- unsigned int nr, ng, nb;
+ uint nr, ng, nb;
- unsigned int bins[3][HIS_STEPS];
+ uint bins[3][HIS_STEPS];
memset(bins, 0, sizeof(bins));
@@ -504,7 +504,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
settings.userdata_chunk = bins;
settings.userdata_chunk_size = sizeof(bins);
settings.func_finalize = make_histogram_view_from_ibuf_finalize;
- BLI_task_parallel_range(0, ibuf->y, &data, make_histogram_view_from_ibuf_byte_cb_ex, &settings);
+ BLI_task_parallel_range(0, ibuf->y, &data, make_histogram_view_from_ibuf_byte_fn, &settings);
nr = nb = ng = 0;
for (x = 0; x < HIS_STEPS; x++) {
@@ -534,7 +534,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
}
}
- wform_put_border((unsigned char *)rval->rect, rval->x, rval->y);
+ wform_put_border((uchar *)rval->rect, rval->x, rval->y);
return rval;
}
@@ -551,7 +551,7 @@ BLI_INLINE int get_bin_float(float f)
return (int)(((f + 0.25f) / 1.5f) * 512);
}
-static void make_histogram_view_from_ibuf_float_cb_ex(void *__restrict userdata,
+static void make_histogram_view_from_ibuf_float_fn(void *__restrict userdata,
const int y,
const TaskParallelTLS *__restrict tls)
{
@@ -576,7 +576,7 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
int nr, ng, nb;
int x;
- unsigned int bins[3][HIS_STEPS];
+ uint bins[3][HIS_STEPS];
memset(bins, 0, sizeof(bins));
@@ -590,7 +590,7 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
settings.userdata_chunk = bins;
settings.userdata_chunk_size = sizeof(bins);
settings.func_finalize = make_histogram_view_from_ibuf_finalize;
- BLI_task_parallel_range(0, ibuf->y, &data, make_histogram_view_from_ibuf_float_cb_ex, &settings);
+ BLI_task_parallel_range(0, ibuf->y, &data, make_histogram_view_from_ibuf_float_fn, &settings);
nr = nb = ng = 0;
for (x = 0; x < HIS_STEPS; x++) {
@@ -619,7 +619,7 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
draw_histogram_marker(rval, get_bin_float(0.0));
draw_histogram_marker(rval, get_bin_float(1.0));
- wform_put_border((unsigned char *)rval->rect, rval->x, rval->y);
+ wform_put_border((uchar *)rval->rect, rval->x, rval->y);
return rval;
}
@@ -636,8 +636,7 @@ ImBuf *make_histogram_view_from_ibuf(ImBuf *ibuf)
}
}
-static void vectorscope_put_cross(
- unsigned char r, unsigned char g, unsigned char b, char *tgt, int w, int h, int size)
+static void vectorscope_put_cross(uchar r, uchar g, uchar b, char *tgt, int w, int h, int size)
{
float rgb[3], yuv[3];
char *p;
@@ -676,10 +675,10 @@ static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf)
int w = 515;
int h = 515;
float scope_gamma = 0.2;
- unsigned char wtable[256];
+ uchar wtable[256];
for (x = 0; x < 256; x++) {
- wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, scope_gamma) * 255);
+ wtable[x] = (uchar)(pow(((float)x + 1) / 256, scope_gamma) * 255);
}
for (x = 0; x < 256; x++) {
@@ -702,7 +701,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf)
rgb_to_yuv_normalized(rgb, yuv);
p = tgt + 4 * (w * (int)((yuv[2] * (h - 3) + 1)) + (int)((yuv[1] * (w - 3) + 1)));
- scope_put_pixel(wtable, (unsigned char *)p);
+ scope_put_pixel(wtable, (uchar *)p);
}
}
@@ -721,10 +720,10 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf)
int w = 515;
int h = 515;
float scope_gamma = 0.2;
- unsigned char wtable[256];
+ uchar wtable[256];
for (x = 0; x < 256; x++) {
- wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, scope_gamma) * 255);
+ wtable[x] = (uchar)(pow(((float)x + 1) / 256, scope_gamma) * 255);
}
for (x = 0; x <= 255; x++) {
@@ -748,7 +747,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf)
rgb_to_yuv_normalized(rgb, yuv);
p = tgt + 4 * (w * (int)((yuv[2] * (h - 3) + 1)) + (int)((yuv[1] * (w - 3) + 1)));
- scope_put_pixel(wtable, (unsigned char *)p);
+ scope_put_pixel(wtable, (uchar *)p);
}
}
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index ccb18331c55..c5472ed88e5 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -40,7 +40,7 @@
#include "RNA_define.h"
-/* for menu/popup icons etc etc*/
+/* For menu, popup, icons, etc. */
#include "ED_outliner.h"
#include "ED_screen.h"
@@ -49,7 +49,7 @@
#include "UI_view2d.h"
-/* own include */
+/* Own include. */
#include "sequencer_intern.h"
static void *find_nearest_marker(int UNUSED(d1), int UNUSED(d2))
@@ -147,7 +147,7 @@ static void select_active_side_range(ListBase *seqbase,
}
}
-/* used for mouse selection in SEQUENCER_OT_select */
+/* Used for mouse selection in SEQUENCER_OT_select */
static void select_linked_time(ListBase *seqbase, Sequence *seq_link)
{
Sequence *seq;
@@ -158,7 +158,7 @@ static void select_linked_time(ListBase *seqbase, Sequence *seq_link)
int right_match = (seq->enddisp == seq_link->enddisp) ? 1 : 0;
if (left_match && right_match) {
- /* a direct match, copy the selection settinhs */
+ /* Direct match, copy the selection settings. */
seq->flag &= ~(SELECT | SEQ_LEFTSEL | SEQ_RIGHTSEL);
seq->flag |= seq_link->flag & (SELECT | SEQ_LEFTSEL | SEQ_RIGHTSEL);
@@ -166,7 +166,7 @@ static void select_linked_time(ListBase *seqbase, Sequence *seq_link)
}
else if (seq_link->flag & SELECT && (left_match || right_match)) {
- /* clear for reselection */
+ /* Clear for reselection. */
seq->flag &= ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
if (left_match && seq_link->flag & SEQ_LEFTSEL) {
@@ -248,12 +248,11 @@ static void select_neighbor_from_last(Scene *scene, int lr)
}
}
if (changed) {
- /* pass */
+ /* Pass. */
}
}
#endif
-/* (de)select operator */
static int sequencer_de_select_all_exec(bContext *C, wmOperator *op)
{
int action = RNA_enum_get(op->ptr, "action");
@@ -302,22 +301,21 @@ static int sequencer_de_select_all_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_select_all(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "(De)select All";
ot->idname = "SEQUENCER_OT_select_all";
ot->description = "Select or deselect all strips";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_de_select_all_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_UNDO;
WM_operator_properties_select_all(ot);
}
-/* (de)select operator */
static int sequencer_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
@@ -343,16 +341,16 @@ static int sequencer_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_select_inverse(struct wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Select Inverse";
ot->idname = "SEQUENCER_OT_select_inverse";
ot->description = "Select unselected strips";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_select_inverse_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_UNDO;
}
@@ -385,18 +383,18 @@ static int sequencer_select_exec(bContext *C, wmOperator *op)
wait_to_deselect_others = false;
}
- marker = find_nearest_marker(SCE_MARKERS, 1); // XXX - dummy function for now
+ marker = find_nearest_marker(SCE_MARKERS, 1); /* XXX - dummy function for now */
seq = find_nearest_seq(scene, v2d, &hand, mval);
- // XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip
+ /* XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip */
if (seq && linked_time && (left_right == SEQ_SELECT_LR_MOUSE)) {
left_right = SEQ_SELECT_LR_NONE;
}
if (marker) {
int oldflag;
- /* select timeline marker */
+ /* Select timeline marker. */
if (extend) {
oldflag = marker->flag;
if (oldflag & SELECT) {
@@ -415,7 +413,7 @@ static int sequencer_select_exec(bContext *C, wmOperator *op)
ret_value = OPERATOR_FINISHED;
}
else if (left_right != SEQ_SELECT_LR_NONE) {
- /* use different logic for this */
+ /* Use different logic for this. */
float x;
if (extend == false) {
ED_sequencer_deselect_all(scene);
@@ -494,7 +492,7 @@ static int sequencer_select_exec(bContext *C, wmOperator *op)
}
}
- /* On Alt selection, select the strip and bordering handles */
+ /* On Alt selection, select the strip and bordering handles. */
if (linked_handle) {
if (!ELEM(hand, SEQ_SIDE_LEFT, SEQ_SIDE_RIGHT)) {
/* First click selects the strip and its adjacent handles (if valid).
@@ -510,7 +508,7 @@ static int sequencer_select_exec(bContext *C, wmOperator *op)
select_surrounding_handles(scene, seq);
}
else {
- /* always select the strip under the cursor */
+ /* Always select the strip under the cursor. */
seq->flag |= SELECT;
/* First click selects adjacent handles on that side.
@@ -635,21 +633,21 @@ void SEQUENCER_OT_select(wmOperatorType *ot)
};
PropertyRNA *prop;
- /* identifiers */
+ /* Identifiers. */
ot->name = "Select";
ot->idname = "SEQUENCER_OT_select";
ot->description = "Select a strip (last selected becomes the \"active strip\")";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_select_exec;
ot->invoke = WM_generic_select_invoke;
ot->modal = WM_generic_select_modal;
ot->poll = ED_operator_sequencer_active;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_UNDO;
- /* properties */
+ /* Properties. */
WM_operator_properties_generic_select(ot);
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
prop = RNA_def_boolean(ot->srna,
@@ -660,7 +658,7 @@ void SEQUENCER_OT_select(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
RNA_def_boolean(
ot->srna, "linked_handle", 0, "Linked Handle", "Select handles next to the active strip");
- /* for animation this is an enum but atm having an enum isn't useful for us */
+ /* For animation this is enum but atm having an enum isn't useful for us. */
RNA_def_enum(ot->srna,
"left_right",
sequencer_select_left_right_types,
@@ -671,7 +669,7 @@ void SEQUENCER_OT_select(wmOperatorType *ot)
ot->srna, "linked_time", 0, "Linked Time", "Select other strips at the same time");
}
-/* run recursively to select linked */
+/* Run recursively to select linked. */
static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool linked)
{
Editing *ed = BKE_sequencer_editing_get(scene, false);
@@ -693,7 +691,7 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li
}
if (!linked) {
- /* if not linked we only want to touch each seq once, newseq */
+ /* If not linked we only want to touch each seq once, newseq. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
seq->tmp = NULL;
}
@@ -702,7 +700,7 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq->flag & SELECT) == sel) {
if (linked || (seq->tmp == NULL)) {
- /* only get unselected neighbors */
+ /* Only get unselected neighbors. */
neighbor = find_neighboring_sequence(scene, seq, SEQ_SIDE_LEFT, isel);
if (neighbor) {
if (sel) {
@@ -738,7 +736,6 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li
return changed;
}
-/* select more operator */
static int sequencer_select_more_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
@@ -756,22 +753,19 @@ static int sequencer_select_more_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_select_more(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Select More";
ot->idname = "SEQUENCER_OT_select_more";
ot->description = "Select more strips adjacent to the current selection";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_select_more_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
}
-/* select less operator */
static int sequencer_select_less_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
@@ -789,22 +783,19 @@ static int sequencer_select_less_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_select_less(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Select Less";
ot->idname = "SEQUENCER_OT_select_less";
ot->description = "Shrink the current selection of adjacent selected strips";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_select_less_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
}
-/* select pick linked operator (uses the mouse) */
static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Scene *scene = CTX_data_scene(C);
@@ -815,10 +806,10 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, cons
Sequence *mouse_seq;
int selected, hand;
- /* this works like UV, not mesh */
+ /* This works like UV, not mesh. */
mouse_seq = find_nearest_seq(scene, v2d, &hand, event->mval);
if (!mouse_seq) {
- return OPERATOR_FINISHED; /* user error as with mesh?? */
+ return OPERATOR_FINISHED; /* User error as with mesh?? */
}
if (extend == 0) {
@@ -842,23 +833,22 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, cons
void SEQUENCER_OT_select_linked_pick(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Select Pick Linked";
ot->idname = "SEQUENCER_OT_select_linked_pick";
ot->description = "Select a chain of linked strips nearest to the mouse pointer";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_select_linked_pick_invoke;
ot->poll = ED_operator_sequencer_active;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
+ /* Properties. */
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
}
-/* select linked operator */
static int sequencer_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
@@ -878,22 +868,19 @@ static int sequencer_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_select_linked(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Select Linked";
ot->idname = "SEQUENCER_OT_select_linked";
ot->description = "Select all strips adjacent to the current selection";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_select_linked_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
}
-/* select handles operator */
static int sequencer_select_handles_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -928,19 +915,19 @@ static int sequencer_select_handles_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_select_handles(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Select Handles";
ot->idname = "SEQUENCER_OT_select_handles";
ot->description = "Select gizmo handles on the sides of the selected strip";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_select_handles_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
+ /* Properties. */
RNA_def_enum(ot->srna,
"side",
prop_side_types,
@@ -949,7 +936,6 @@ void SEQUENCER_OT_select_handles(wmOperatorType *ot)
"The side of the handle that is selected");
}
-/* select side operator */
static int sequencer_select_side_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -962,7 +948,7 @@ static int sequencer_select_side_exec(bContext *C, wmOperator *op)
copy_vn_i(frame_ranges, ARRAY_SIZE(frame_ranges), frame_init);
- for (Sequence *seq = ed->seqbasep->first; seq; seq = seq->next) {
+ LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
if (UNLIKELY(seq->machine >= MAXSEQ)) {
continue;
}
@@ -993,19 +979,19 @@ static int sequencer_select_side_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_select_side(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Select Side";
ot->idname = "SEQUENCER_OT_select_side";
ot->description = "Select strips on the nominated side of the selected strips";
- /* api callbacks */
+ /* Api callbacks. */
ot->exec = sequencer_select_side_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
+ /* Properties. */
RNA_def_enum(ot->srna,
"side",
prop_side_types,
@@ -1014,7 +1000,6 @@ void SEQUENCER_OT_select_side(wmOperatorType *ot)
"The side to which the selection is applied");
}
-/* box_select operator */
static int sequencer_box_select_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -1037,7 +1022,7 @@ static int sequencer_box_select_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rctf(op, &rectf);
UI_view2d_region_to_view_rctf(v2d, &rectf, &rectf);
- for (Sequence *seq = ed->seqbasep->first; seq; seq = seq->next) {
+ LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
rctf rq;
seq_rectf(seq, &rq);
if (BLI_rctf_isect(&rq, &rectf, NULL)) {
@@ -1089,7 +1074,6 @@ static int sequencer_box_select_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-/* ****** Box Select ****** */
static int sequencer_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Scene *scene = CTX_data_scene(C);
@@ -1112,12 +1096,12 @@ void SEQUENCER_OT_select_box(wmOperatorType *ot)
{
PropertyRNA *prop;
- /* identifiers */
+ /* Identifiers. */
ot->name = "Box Select";
ot->idname = "SEQUENCER_OT_select_box";
ot->description = "Select strips using box selection";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sequencer_box_select_invoke;
ot->exec = sequencer_box_select_exec;
ot->modal = WM_gesture_box_modal;
@@ -1125,10 +1109,10 @@ void SEQUENCER_OT_select_box(wmOperatorType *ot)
ot->poll = ED_operator_sequencer_active;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_UNDO;
- /* properties */
+ /* Properties. */
WM_operator_properties_gesture_box(ot);
WM_operator_properties_select_operation_simple(ot);
@@ -1140,8 +1124,6 @@ void SEQUENCER_OT_select_box(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
-/* ****** Selected Grouped ****** */
-
enum {
SEQ_SELECT_GROUP_TYPE,
SEQ_SELECT_GROUP_TYPE_BASIC,
@@ -1366,7 +1348,7 @@ static bool select_grouped_effect_link(Editing *ed, Sequence *actseq, const int
BKE_sequence_iterator_next(&iter)) {
seq = iter.seq;
- /* Ignore all seqs already selected! */
+ /* Ignore all seqs already selected. */
/* Ignore all seqs not sharing some time with active one. */
/* Ignore all seqs of incompatible types (audio vs video). */
if (!SEQ_CHANNEL_CHECK(seq, channel) || (seq->flag & SELECT) || (seq->startdisp >= enddisp) ||
@@ -1375,7 +1357,7 @@ static bool select_grouped_effect_link(Editing *ed, Sequence *actseq, const int
continue;
}
- /* If the seq is an effect one, we need extra checking! */
+ /* If the seq is an effect one, we need extra checking. */
if (SEQ_IS_EFFECT(seq) && ((seq->seq1 && seq->seq1->tmp) || (seq->seq2 && seq->seq2->tmp) ||
(seq->seq3 && seq->seq3->tmp))) {
if (startdisp > seq->startdisp) {
@@ -1398,7 +1380,7 @@ static bool select_grouped_effect_link(Editing *ed, Sequence *actseq, const int
BKE_sequence_iterator_begin(ed, &iter, true);
}
- /* Video strips below active one, or any strip for audio (order do no matters here!). */
+ /* Video strips below active one, or any strip for audio (order doesn't matter here). */
else if (seq->machine < machine || is_audio) {
seq->flag |= SELECT;
changed = true;
@@ -1476,20 +1458,20 @@ static int sequencer_select_grouped_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_select_grouped(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Select Grouped";
ot->description = "Select all strips grouped by various properties";
ot->idname = "SEQUENCER_OT_select_grouped";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = WM_menu_invoke;
ot->exec = sequencer_select_grouped_exec;
ot->poll = sequencer_edit_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
+ /* Properties. */
ot->prop = RNA_def_enum(ot->srna, "type", sequencer_prop_select_grouped_types, 0, "Type", "");
RNA_def_boolean(ot->srna,
"extend",
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index 714a634766c..a890b770c83 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -46,7 +46,7 @@
#include "UI_view2d.h"
-/* own include */
+/* Own include. */
#include "sequencer_intern.h"
/******************** sample backdrop operator ********************/
@@ -57,11 +57,11 @@ typedef struct ImageSampleInfo {
int x, y;
int channels;
- unsigned char col[4];
+ uchar col[4];
float colf[4];
float linearcol[4];
- unsigned char *colp;
+ uchar *colp;
const float *colfp;
int draw;
@@ -117,7 +117,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) {
const float *fp;
- unsigned char *cp;
+ uchar *cp;
int x = (int)fx, y = (int)fy;
info->x = x;
@@ -129,7 +129,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
info->colfp = NULL;
if (ibuf->rect) {
- cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
+ cp = (uchar *)(ibuf->rect + y * ibuf->x + x);
info->col[0] = cp[0];
info->col[1] = cp[1];
@@ -158,7 +158,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
info->colf[3] = fp[3];
info->colfp = info->colf;
- /* sequencer's image buffers are in non-linear space, need to make them linear */
+ /* Sequencer's image buffers are in non-linear space, need to make them linear. */
copy_v4_v4(info->linearcol, info->colf);
BKE_sequencer_pixel_from_sequencer_space_v4(scene, info->linearcol);
@@ -236,17 +236,17 @@ static bool sample_poll(bContext *C)
void SEQUENCER_OT_sample(wmOperatorType *ot)
{
- /* identifiers */
+ /* Identifiers. */
ot->name = "Sample Color";
ot->idname = "SEQUENCER_OT_sample";
ot->description = "Use mouse to sample color in current frame";
- /* api callbacks */
+ /* Api callbacks. */
ot->invoke = sample_invoke;
ot->modal = sample_modal;
ot->cancel = sample_cancel;
ot->poll = sample_poll;
- /* flags */
+ /* Flags. */
ot->flag = OPTYPE_BLOCKING;
}
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 447bf27099d..f52cfdd34c0 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -43,7 +43,7 @@
#include "ED_screen.h"
#include "ED_space_api.h"
#include "ED_view3d.h"
-#include "ED_view3d_offscreen.h" /* only for sequencer view3d drawing callback */
+#include "ED_view3d_offscreen.h" /* Only for sequencer view3d drawing callback. */
#include "WM_api.h"
#include "WM_message.h"
@@ -57,24 +57,25 @@
#include "IMB_imbuf.h"
-#include "sequencer_intern.h" // own include
+/* Own include. */
+#include "sequencer_intern.h"
/**************************** common state *****************************/
-static void sequencer_scopes_tag_refresh(ScrArea *sa)
+static void sequencer_scopes_tag_refresh(ScrArea *area)
{
- SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first;
+ SpaceSeq *sseq = (SpaceSeq *)area->spacedata.first;
sseq->scopes.reference_ibuf = NULL;
}
/* ******************** manage regions ********************* */
-static ARegion *sequencer_find_region(ScrArea *sa, short type)
+static ARegion *sequencer_find_region(ScrArea *area, short type)
{
ARegion *region = NULL;
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == type) {
return region;
}
@@ -85,7 +86,7 @@ static ARegion *sequencer_find_region(ScrArea *sa, short type)
/* ******************** default callbacks for sequencer space ***************** */
-static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
+static SpaceLink *sequencer_new(const ScrArea *UNUSED(area), const Scene *scene)
{
ARegion *region;
SpaceSeq *sseq;
@@ -95,9 +96,9 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
sseq->chanshown = 0;
sseq->view = SEQ_VIEW_SEQUENCE;
sseq->mainb = SEQ_DRAW_IMG_IMBUF;
- sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA | SEQ_SHOW_MARKERS;
+ sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA | SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES;
- /* tool header */
+ /* Tool header. */
region = MEM_callocN(sizeof(ARegion), "tool header for sequencer");
BLI_addtail(&sseq->regionbase, region);
@@ -105,14 +106,14 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
region->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
- /* header */
+ /* Header. */
region = MEM_callocN(sizeof(ARegion), "header for sequencer");
BLI_addtail(&sseq->regionbase, region);
region->regiontype = RGN_TYPE_HEADER;
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
- /* buttons/list view */
+ /* Buttons/list view. */
region = MEM_callocN(sizeof(ARegion), "buttons for sequencer");
BLI_addtail(&sseq->regionbase, region);
@@ -120,7 +121,7 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
region->alignment = RGN_ALIGN_RIGHT;
region->flag = RGN_FLAG_HIDDEN;
- /* toolbar */
+ /* Toolbar. */
region = MEM_callocN(sizeof(ARegion), "tools for sequencer");
BLI_addtail(&sseq->regionbase, region);
@@ -128,19 +129,19 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
region->alignment = RGN_ALIGN_LEFT;
region->flag = RGN_FLAG_HIDDEN;
- /* preview region */
- /* NOTE: if you change values here, also change them in sequencer_init_preview_region */
+ /* Preview region. */
+ /* NOTE: if you change values here, also change them in sequencer_init_preview_region. */
region = MEM_callocN(sizeof(ARegion), "preview region for sequencer");
BLI_addtail(&sseq->regionbase, region);
region->regiontype = RGN_TYPE_PREVIEW;
region->alignment = RGN_ALIGN_TOP;
region->flag |= RGN_FLAG_HIDDEN;
- /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
+ /* For now, aspect ratio should be maintained, and zoom is clamped within sane default limits. */
region->v2d.keepzoom = V2D_KEEPASPECT | V2D_KEEPZOOM | V2D_LIMITZOOM;
region->v2d.minzoom = 0.001f;
region->v2d.maxzoom = 1000.0f;
- region->v2d.tot.xmin = -960.0f; /* 1920 width centered */
- region->v2d.tot.ymin = -540.0f; /* 1080 height centered */
+ region->v2d.tot.xmin = -960.0f; /* 1920 width centered. */
+ region->v2d.tot.ymin = -540.0f; /* 1080 height centered. */
region->v2d.tot.xmax = 960.0f;
region->v2d.tot.ymax = 540.0f;
region->v2d.min[0] = 0.0f;
@@ -151,14 +152,13 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
region->v2d.align = V2D_ALIGN_FREE;
region->v2d.keeptot = V2D_KEEPTOT_FREE;
- /* main region */
+ /* Main region. */
region = MEM_callocN(sizeof(ARegion), "main region for sequencer");
BLI_addtail(&sseq->regionbase, region);
region->regiontype = RGN_TYPE_WINDOW;
- /* seq space goes from (0,8) to (0, efra) */
-
+ /* Seq space goes from (0,8) to (0, efra). */
region->v2d.tot.xmin = 0.0f;
region->v2d.tot.ymin = 0.0f;
region->v2d.tot.xmax = scene->r.efra;
@@ -184,13 +184,13 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
return (SpaceLink *)sseq;
}
-/* not spacelink itself */
+/* Not spacelink itself. */
static void sequencer_free(SpaceLink *sl)
{
SpaceSeq *sseq = (SpaceSeq *)sl;
SequencerScopes *scopes = &sseq->scopes;
- // XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd);
+ /* XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd); */
if (scopes->zebra_ibuf) {
IMB_freeImBuf(scopes->zebra_ibuf);
@@ -213,98 +213,98 @@ static void sequencer_free(SpaceLink *sl)
}
}
-/* spacetype; init callback */
-static void sequencer_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+/* Spacetype init callback. */
+static void sequencer_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
-static void sequencer_refresh(const bContext *C, ScrArea *sa)
+static void sequencer_refresh(const bContext *C, ScrArea *area)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *window = CTX_wm_window(C);
- SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first;
- ARegion *ar_main = sequencer_find_region(sa, RGN_TYPE_WINDOW);
- ARegion *ar_preview = sequencer_find_region(sa, RGN_TYPE_PREVIEW);
+ SpaceSeq *sseq = (SpaceSeq *)area->spacedata.first;
+ ARegion *region_main = sequencer_find_region(area, RGN_TYPE_WINDOW);
+ ARegion *region_preview = sequencer_find_region(area, RGN_TYPE_PREVIEW);
bool view_changed = false;
switch (sseq->view) {
case SEQ_VIEW_SEQUENCE:
- if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) {
- ar_main->flag &= ~RGN_FLAG_HIDDEN;
- ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ if (region_main && (region_main->flag & RGN_FLAG_HIDDEN)) {
+ region_main->flag &= ~RGN_FLAG_HIDDEN;
+ region_main->v2d.flag &= ~V2D_IS_INITIALISED;
view_changed = true;
}
- if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) {
- ar_preview->flag |= RGN_FLAG_HIDDEN;
- ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
- WM_event_remove_handlers((bContext *)C, &ar_preview->handlers);
+ if (region_preview && !(region_preview->flag & RGN_FLAG_HIDDEN)) {
+ region_preview->flag |= RGN_FLAG_HIDDEN;
+ region_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &region_preview->handlers);
view_changed = true;
}
- if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
- ar_main->alignment = RGN_ALIGN_NONE;
+ if (region_main && region_main->alignment != RGN_ALIGN_NONE) {
+ region_main->alignment = RGN_ALIGN_NONE;
view_changed = true;
}
- if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
- ar_preview->alignment = RGN_ALIGN_NONE;
+ if (region_preview && region_preview->alignment != RGN_ALIGN_NONE) {
+ region_preview->alignment = RGN_ALIGN_NONE;
view_changed = true;
}
break;
case SEQ_VIEW_PREVIEW:
- if (ar_main && !(ar_main->flag & RGN_FLAG_HIDDEN)) {
- ar_main->flag |= RGN_FLAG_HIDDEN;
- ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
- WM_event_remove_handlers((bContext *)C, &ar_main->handlers);
+ if (region_main && !(region_main->flag & RGN_FLAG_HIDDEN)) {
+ region_main->flag |= RGN_FLAG_HIDDEN;
+ region_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &region_main->handlers);
view_changed = true;
}
- if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) {
- ar_preview->flag &= ~RGN_FLAG_HIDDEN;
- ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
- ar_preview->v2d.cur = ar_preview->v2d.tot;
+ if (region_preview && (region_preview->flag & RGN_FLAG_HIDDEN)) {
+ region_preview->flag &= ~RGN_FLAG_HIDDEN;
+ region_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_preview->v2d.cur = region_preview->v2d.tot;
view_changed = true;
}
- if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
- ar_main->alignment = RGN_ALIGN_NONE;
+ if (region_main && region_main->alignment != RGN_ALIGN_NONE) {
+ region_main->alignment = RGN_ALIGN_NONE;
view_changed = true;
}
- if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
- ar_preview->alignment = RGN_ALIGN_NONE;
+ if (region_preview && region_preview->alignment != RGN_ALIGN_NONE) {
+ region_preview->alignment = RGN_ALIGN_NONE;
view_changed = true;
}
break;
case SEQ_VIEW_SEQUENCE_PREVIEW:
- if (ar_main && ar_preview) {
+ if (region_main && region_preview) {
/* Get available height (without DPI correction). */
- const float height = (sa->winy - ED_area_headersize()) / UI_DPI_FAC;
+ const float height = (area->winy - ED_area_headersize()) / UI_DPI_FAC;
/* We reuse hidden region's size, allows to find same layout as before if we just switch
* between one 'full window' view and the combined one. This gets lost if we switch to both
* 'full window' views before, though... Better than nothing. */
- if (ar_main->flag & RGN_FLAG_HIDDEN) {
- ar_main->flag &= ~RGN_FLAG_HIDDEN;
- ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
- ar_preview->sizey = (int)(height - ar_main->sizey);
+ if (region_main->flag & RGN_FLAG_HIDDEN) {
+ region_main->flag &= ~RGN_FLAG_HIDDEN;
+ region_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_preview->sizey = (int)(height - region_main->sizey);
view_changed = true;
}
- if (ar_preview->flag & RGN_FLAG_HIDDEN) {
- ar_preview->flag &= ~RGN_FLAG_HIDDEN;
- ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
- ar_preview->v2d.cur = ar_preview->v2d.tot;
- ar_main->sizey = (int)(height - ar_preview->sizey);
+ if (region_preview->flag & RGN_FLAG_HIDDEN) {
+ region_preview->flag &= ~RGN_FLAG_HIDDEN;
+ region_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_preview->v2d.cur = region_preview->v2d.tot;
+ region_main->sizey = (int)(height - region_preview->sizey);
view_changed = true;
}
- if (ar_main->alignment != RGN_ALIGN_NONE) {
- ar_main->alignment = RGN_ALIGN_NONE;
+ if (region_main->alignment != RGN_ALIGN_NONE) {
+ region_main->alignment = RGN_ALIGN_NONE;
view_changed = true;
}
- if (ar_preview->alignment != RGN_ALIGN_TOP) {
- ar_preview->alignment = RGN_ALIGN_TOP;
+ if (region_preview->alignment != RGN_ALIGN_TOP) {
+ region_preview->alignment = RGN_ALIGN_TOP;
view_changed = true;
}
- /* Final check that both preview and main height are reasonable! */
- if (ar_preview->sizey < 10 || ar_main->sizey < 10 ||
- ar_preview->sizey + ar_main->sizey > height) {
- ar_preview->sizey = (int)(height * 0.4f + 0.5f);
- ar_main->sizey = (int)(height - ar_preview->sizey);
+ /* Final check that both preview and main height are reasonable. */
+ if (region_preview->sizey < 10 || region_main->sizey < 10 ||
+ region_preview->sizey + region_main->sizey > height) {
+ region_preview->sizey = (int)(height * 0.4f + 0.5f);
+ region_main->sizey = (int)(height - region_preview->sizey);
view_changed = true;
}
}
@@ -312,8 +312,8 @@ static void sequencer_refresh(const bContext *C, ScrArea *sa)
}
if (view_changed) {
- ED_area_initialize(wm, window, sa);
- ED_area_tag_redraw(sa);
+ ED_area_initialize(wm, window, area);
+ ED_area_tag_redraw(area);
}
}
@@ -321,8 +321,8 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl)
{
SpaceSeq *sseqn = MEM_dupallocN(sl);
- /* clear or remove stuff from old */
- // XXX sseq->gpd = gpencil_data_duplicate(sseq->gpd, false);
+ /* Clear or remove stuff from old. */
+ /* XXX sseq->gpd = gpencil_data_duplicate(sseq->gpd, false); */
memset(&sseqn->scopes, 0, sizeof(sseqn->scopes));
@@ -330,29 +330,29 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl)
}
static void sequencer_listener(wmWindow *UNUSED(win),
- ScrArea *sa,
+ ScrArea *area,
wmNotifier *wmn,
Scene *UNUSED(scene))
{
- /* context changes */
+ /* Context changes. */
switch (wmn->category) {
case NC_SCENE:
switch (wmn->data) {
case ND_FRAME:
case ND_SEQUENCER:
- sequencer_scopes_tag_refresh(sa);
+ sequencer_scopes_tag_refresh(area);
break;
}
break;
case NC_WINDOW:
case NC_SPACE:
if (wmn->data == ND_SPACE_SEQUENCER) {
- sequencer_scopes_tag_refresh(sa);
+ sequencer_scopes_tag_refresh(area);
}
break;
case NC_GPENCIL:
if (wmn->data & ND_GPENCIL_EDITMODE) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
}
@@ -370,7 +370,7 @@ static bool image_drop_poll(bContext *C,
int hand;
if (drag->type == WM_DRAG_PATH) {
- if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) { /* rule might not work? */
+ if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) { /* Rule might not work? */
if (find_nearest_seq(scene, &region->v2d, &hand, event->mval) == NULL) {
return 1;
}
@@ -390,7 +390,7 @@ static bool movie_drop_poll(bContext *C,
int hand;
if (drag->type == WM_DRAG_PATH) {
- if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* rule might not work? */
+ if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* Rule might not work? */
if (find_nearest_seq(scene, &region->v2d, &hand, event->mval) == NULL) {
return 1;
}
@@ -409,7 +409,7 @@ static bool sound_drop_poll(bContext *C,
int hand;
if (drag->type == WM_DRAG_PATH) {
- if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* rule might not work? */
+ if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* Rule might not work? */
if (find_nearest_seq(scene, &region->v2d, &hand, event->mval) == NULL) {
return 1;
}
@@ -420,7 +420,7 @@ static bool sound_drop_poll(bContext *C,
static void sequencer_drop_copy(wmDrag *drag, wmDropBox *drop)
{
- /* copy drag path to properties */
+ /* Copy drag path to properties. */
if (RNA_struct_find_property(drop->ptr, "filepath")) {
RNA_string_set(drop->ptr, "filepath", drag->path);
}
@@ -439,7 +439,7 @@ static void sequencer_drop_copy(wmDrag *drag, wmDropBox *drop)
}
}
-/* this region dropbox definition */
+/* This region dropbox definition. */
static void sequencer_dropboxes(void)
{
ListBase *lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW);
@@ -452,7 +452,7 @@ static void sequencer_dropboxes(void)
/* ************* end drop *********** */
/* DO NOT make this static, this hides the symbol and breaks API generation script. */
-extern const char *sequencer_context_dir[]; /* quiet warning. */
+extern const char *sequencer_context_dir[]; /* Quiet warning. */
const char *sequencer_context_dir[] = {"edit_mask", NULL};
static int sequencer_context(const bContext *C, const char *member, bContextDataResult *result)
@@ -489,7 +489,7 @@ static void sequencer_gizmos(void)
}
/* *********************** sequencer (main) region ************************ */
-/* add handlers, stuff you only do once or on area/region changes */
+/* Add handlers, stuff you only do once or on area/region changes. */
static void sequencer_main_region_init(wmWindowManager *wm, ARegion *region)
{
wmKeyMap *keymap;
@@ -505,36 +505,36 @@ static void sequencer_main_region_init(wmWindowManager *wm, ARegion *region)
keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
WM_event_add_keymap_handler_v2d_mask(&region->handlers, keymap);
- /* own keymap */
+ /* Own keymap. */
keymap = WM_keymap_ensure(wm->defaultconf, "Sequencer", SPACE_SEQ, 0);
WM_event_add_keymap_handler_v2d_mask(&region->handlers, keymap);
- /* add drop boxes */
+ /* Add drop boxes. */
lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW);
WM_event_add_dropbox_handler(&region->handlers, lb);
}
+/* Strip editing timeline. */
static void sequencer_main_region_draw(const bContext *C, ARegion *region)
{
- /* NLE - strip editing timeline interface */
draw_timeline_seq(C, region);
}
static void sequencer_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
{
- /* context changes */
+ /* Context changes. */
switch (wmn->category) {
case NC_SCENE:
switch (wmn->data) {
case ND_FRAME:
case ND_FRAME_RANGE:
case ND_MARKERS:
- case ND_RENDER_OPTIONS: /* for FPS and FPS Base */
+ case ND_RENDER_OPTIONS: /* For FPS and FPS Base. */
case ND_SEQUENCER:
case ND_RENDER_RESULT:
ED_region_tag_redraw(region);
@@ -570,7 +570,7 @@ static void sequencer_main_region_message_subscribe(const struct bContext *UNUSE
struct WorkSpace *UNUSED(workspace),
struct Scene *scene,
struct bScreen *UNUSED(screen),
- struct ScrArea *UNUSED(sa),
+ struct ScrArea *UNUSED(area),
struct ARegion *region,
struct wmMsgBus *mbus)
{
@@ -625,7 +625,7 @@ static void sequencer_main_region_message_subscribe(const struct bContext *UNUSE
}
/* *********************** header region ************************ */
-/* add handlers, stuff you only do once or on area/region changes */
+/* Add handlers, stuff you only do once or on area/region changes. */
static void sequencer_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
{
ED_region_header_init(region);
@@ -637,7 +637,7 @@ static void sequencer_header_region_draw(const bContext *C, ARegion *region)
}
/* *********************** toolbar region ************************ */
-/* add handlers, stuff you only do once or on area/region changes */
+/* Add handlers, stuff you only do once or on area/region changes. */
static void sequencer_tools_region_init(wmWindowManager *wm, ARegion *region)
{
wmKeyMap *keymap;
@@ -668,15 +668,15 @@ static void sequencer_preview_region_init(wmWindowManager *wm, ARegion *region)
keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
WM_event_add_keymap_handler_v2d_mask(&region->handlers, keymap);
- /* own keymap */
+ /* Own keymap. */
keymap = WM_keymap_ensure(wm->defaultconf, "SequencerPreview", SPACE_SEQ, 0);
WM_event_add_keymap_handler_v2d_mask(&region->handlers, keymap);
}
static void sequencer_preview_region_draw(const bContext *C, ARegion *region)
{
- ScrArea *sa = CTX_wm_area(C);
- SpaceSeq *sseq = sa->spacedata.first;
+ ScrArea *area = CTX_wm_area(C);
+ SpaceSeq *sseq = area->spacedata.first;
Scene *scene = CTX_data_scene(C);
wmWindowManager *wm = CTX_wm_manager(C);
const bool draw_overlay = (scene->ed && (scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW));
@@ -717,12 +717,12 @@ static void sequencer_preview_region_draw(const bContext *C, ARegion *region)
}
static void sequencer_preview_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
{
- /* context changes */
+ /* Context changes. */
switch (wmn->category) {
case NC_GPENCIL:
if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
@@ -769,7 +769,7 @@ static void sequencer_preview_region_listener(wmWindow *UNUSED(win),
/* *********************** buttons region ************************ */
-/* add handlers, stuff you only do once or on area/region changes */
+/* Add handlers, stuff you only do once or on area/region changes. */
static void sequencer_buttons_region_init(wmWindowManager *wm, ARegion *region)
{
wmKeyMap *keymap;
@@ -787,12 +787,12 @@ static void sequencer_buttons_region_draw(const bContext *C, ARegion *region)
}
static void sequencer_buttons_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
{
- /* context changes */
+ /* Context changes. */
switch (wmn->category) {
case NC_GPENCIL:
if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
@@ -820,7 +820,7 @@ static void sequencer_buttons_region_listener(wmWindow *UNUSED(win),
}
}
-static void sequencer_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
+static void sequencer_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
{
SpaceSeq *sseq = (SpaceSeq *)slink;
@@ -837,7 +837,7 @@ static void sequencer_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id
/* ************************************* */
-/* only called once, from space/spacetypes.c */
+/* Only called once, from space/spacetypes.c. */
void ED_spacetype_sequencer(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype sequencer");
@@ -859,7 +859,8 @@ void ED_spacetype_sequencer(void)
st->listener = sequencer_listener;
st->id_remap = sequencer_id_remap;
- /* regions: main window */
+ /* Create regions: */
+ /* Main window. */
art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
art->regionid = RGN_TYPE_WINDOW;
art->init = sequencer_main_region_init;
@@ -867,10 +868,9 @@ void ED_spacetype_sequencer(void)
art->listener = sequencer_main_region_listener;
art->message_subscribe = sequencer_main_region_message_subscribe;
art->keymapflag = ED_KEYMAP_TOOL | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_ANIMATION;
-
BLI_addhead(&st->regiontypes, art);
- /* preview */
+ /* Preview. */
art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
art->regionid = RGN_TYPE_PREVIEW;
art->init = sequencer_preview_region_init;
@@ -880,7 +880,7 @@ void ED_spacetype_sequencer(void)
ED_KEYMAP_GPENCIL;
BLI_addhead(&st->regiontypes, art);
- /* regions: listview/buttons */
+ /* Listview/buttons. */
art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
art->regionid = RGN_TYPE_UI;
art->prefsizex = UI_SIDEBAR_PANEL_WIDTH * 1.3f;
@@ -892,7 +892,7 @@ void ED_spacetype_sequencer(void)
BLI_addhead(&st->regiontypes, art);
sequencer_buttons_register(art);
- /* regions: tool(bar) */
+ /* Toolbar. */
art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer tools region");
art->regionid = RGN_TYPE_TOOLS;
art->prefsizex = 58; /* XXX */
@@ -904,7 +904,7 @@ void ED_spacetype_sequencer(void)
art->draw = sequencer_tools_region_draw;
BLI_addhead(&st->regiontypes, art);
- /* regions: tool header */
+ /* Tool header. */
art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer tool header region");
art->regionid = RGN_TYPE_TOOL_HEADER;
art->prefsizey = HEADERY;
@@ -915,7 +915,7 @@ void ED_spacetype_sequencer(void)
art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_header;
BLI_addhead(&st->regiontypes, art);
- /* regions: header */
+ /* Header. */
art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
@@ -924,17 +924,16 @@ void ED_spacetype_sequencer(void)
art->init = sequencer_header_region_init;
art->draw = sequencer_header_region_draw;
art->listener = sequencer_main_region_listener;
-
BLI_addhead(&st->regiontypes, art);
- /* regions: hud */
+ /* Hud. */
art = ED_area_type_hud(st->spaceid);
BLI_addhead(&st->regiontypes, art);
BKE_spacetype_register(st);
- /* set the sequencer callback when not in background mode */
+ /* Set the sequencer callback when not in background mode. */
if (G.background == 0) {
- sequencer_view3d_cb = ED_view3d_draw_offscreen_imbuf_simple;
+ sequencer_view3d_fn = ED_view3d_draw_offscreen_imbuf_simple;
}
}
diff --git a/source/blender/editors/space_statusbar/space_statusbar.c b/source/blender/editors/space_statusbar/space_statusbar.c
index 1efb18403de..34d7f8b0216 100644
--- a/source/blender/editors/space_statusbar/space_statusbar.c
+++ b/source/blender/editors/space_statusbar/space_statusbar.c
@@ -65,7 +65,7 @@ static void statusbar_free(SpaceLink *UNUSED(sl))
}
/* spacetype; init callback */
-static void statusbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void statusbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
@@ -96,7 +96,7 @@ static void statusbar_keymap(struct wmKeyConfig *UNUSED(keyconf))
}
static void statusbar_header_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -135,7 +135,7 @@ static void statusbar_header_region_message_subscribe(const bContext *UNUSED(C),
WorkSpace *UNUSED(workspace),
Scene *UNUSED(scene),
bScreen *UNUSED(screen),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
struct wmMsgBus *mbus)
{
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index d5379a4e76d..76d61193ce0 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -107,7 +107,7 @@ static void text_free(SpaceLink *sl)
}
/* spacetype; init callback */
-static void text_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void text_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
@@ -123,11 +123,11 @@ static SpaceLink *text_duplicate(SpaceLink *sl)
}
static void text_listener(wmWindow *UNUSED(win),
- ScrArea *sa,
+ ScrArea *area,
wmNotifier *wmn,
Scene *UNUSED(scene))
{
- SpaceText *st = sa->spacedata.first;
+ SpaceText *st = area->spacedata.first;
/* context changes */
switch (wmn->category) {
@@ -141,14 +141,14 @@ static void text_listener(wmWindow *UNUSED(win),
switch (wmn->data) {
case ND_DISPLAY:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
case ND_CURSOR:
if (st->text && st->text == wmn->reference) {
- text_scroll_to_cursor__area(st, sa, true);
+ text_scroll_to_cursor__area(st, area, true);
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
}
@@ -159,15 +159,15 @@ static void text_listener(wmWindow *UNUSED(win),
text_update_edited(st->text);
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
ATTR_FALLTHROUGH; /* fall down to tag redraw */
case NA_ADDED:
case NA_REMOVED:
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
break;
case NA_SELECTED:
if (st->text && st->text == wmn->reference) {
- text_scroll_to_cursor__area(st, sa, true);
+ text_scroll_to_cursor__area(st, area, true);
}
break;
@@ -176,7 +176,7 @@ static void text_listener(wmWindow *UNUSED(win),
break;
case NC_SPACE:
if (wmn->data == ND_SPACE_TEXT) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
break;
}
@@ -309,9 +309,9 @@ static void text_main_region_draw(const bContext *C, ARegion *region)
/* scrollers? */
}
-static void text_cursor(wmWindow *win, ScrArea *sa, ARegion *region)
+static void text_cursor(wmWindow *win, ScrArea *area, ARegion *region)
{
- SpaceText *st = sa->spacedata.first;
+ SpaceText *st = area->spacedata.first;
int wmcursor = WM_CURSOR_TEXT_EDIT;
if (st->text && BLI_rcti_isect_pt(&st->runtime.scroll_region_handle,
@@ -413,14 +413,14 @@ static void text_properties_region_draw(const bContext *C, ARegion *region)
if (st->flags & ST_FIND_ACTIVATE) {
if (UI_textbutton_activate_rna(C, region, st, "find_text")) {
/* if the panel was already open we need to do another redraw */
- ScrArea *sa = CTX_wm_area(C);
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_TEXT, sa);
+ ScrArea *area = CTX_wm_area(C);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_TEXT, area);
}
st->flags &= ~ST_FIND_ACTIVATE;
}
}
-static void text_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
+static void text_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
{
SpaceText *stext = (SpaceText *)slink;
diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c
index cb1861d8726..1f034bdbd09 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -335,8 +335,8 @@ static int doc_scroll = 0;
static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
SpaceText *st = CTX_wm_space_text(C);
- ScrArea *sa = CTX_wm_area(C);
- ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ ScrArea *area = CTX_wm_area(C);
+ ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
int draw = 0, tools = 0, swallow = 0, scroll = 1;
Text *text = CTX_data_edit_text(C);
@@ -577,7 +577,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
}
if (draw) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
// if (swallow) {
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 777b6b1ef1d..a0339b35c57 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -1812,7 +1812,7 @@ void text_scroll_to_cursor(SpaceText *st, ARegion *region, const bool center)
}
/* takes an area instead of a region, use for listeners */
-void text_scroll_to_cursor__area(SpaceText *st, ScrArea *sa, const bool center)
+void text_scroll_to_cursor__area(SpaceText *st, ScrArea *area, const bool center)
{
ARegion *region;
@@ -1820,7 +1820,7 @@ void text_scroll_to_cursor__area(SpaceText *st, ScrArea *sa, const bool center)
return;
}
- region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
if (region) {
text_scroll_to_cursor(st, region, center);
@@ -1829,10 +1829,10 @@ void text_scroll_to_cursor__area(SpaceText *st, ScrArea *sa, const bool center)
void text_update_cursor_moved(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
SpaceText *st = CTX_wm_space_text(C);
- text_scroll_to_cursor__area(st, sa, true);
+ text_scroll_to_cursor__area(st, area, true);
}
/**
diff --git a/source/blender/editors/space_text/text_format.c b/source/blender/editors/space_text/text_format.c
index 2eeb46049d2..bdbf55d9198 100644
--- a/source/blender/editors/space_text/text_format.c
+++ b/source/blender/editors/space_text/text_format.c
@@ -121,7 +121,7 @@ int flatten_string_strlen(FlattenString *fs, const char *str)
/* Ensures the format string for the given line is long enough, reallocating
* as needed. Allocation is done here, alone, to ensure consistency. */
-int text_check_format_len(TextLine *line, unsigned int len)
+int text_check_format_len(TextLine *line, uint len)
{
if (line->format) {
if (strlen(line->format) < len) {
diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c
index da39ba3c5ad..c4052fcef84 100644
--- a/source/blender/editors/space_text/text_header.c
+++ b/source/blender/editors/space_text/text_header.c
@@ -42,17 +42,17 @@
/************************** properties ******************************/
-static ARegion *text_has_properties_region(ScrArea *sa)
+static ARegion *text_has_properties_region(ScrArea *area)
{
ARegion *region, *arnew;
- region = BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ region = BKE_area_find_region_type(area, RGN_TYPE_UI);
if (region) {
return region;
}
/* add subdiv level; after header */
- region = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+ region = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
/* is error! */
if (region == NULL) {
@@ -61,7 +61,7 @@ static ARegion *text_has_properties_region(ScrArea *sa)
arnew = MEM_callocN(sizeof(ARegion), "properties region");
- BLI_insertlinkafter(&sa->regionbase, region, arnew);
+ BLI_insertlinkafter(&area->regionbase, region, arnew);
arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_LEFT;
@@ -77,8 +77,8 @@ static bool text_properties_poll(bContext *C)
static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *region = text_has_properties_region(sa);
+ ScrArea *area = CTX_wm_area(C);
+ ARegion *region = text_has_properties_region(area);
SpaceText *st = CTX_wm_space_text(C);
if (region) {
diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h
index 5ad6a554188..d6588dda797 100644
--- a/source/blender/editors/space_text/text_intern.h
+++ b/source/blender/editors/space_text/text_intern.h
@@ -41,20 +41,20 @@ void text_update_line_edited(struct TextLine *line);
void text_update_edited(struct Text *text);
void text_update_character_width(struct SpaceText *st);
void text_scroll_to_cursor(struct SpaceText *st, struct ARegion *region, const bool center);
-void text_scroll_to_cursor__area(struct SpaceText *st, struct ScrArea *sa, const bool center);
+void text_scroll_to_cursor__area(struct SpaceText *st, struct ScrArea *area, const bool center);
void text_update_cursor_moved(struct bContext *C);
/* Padding around line numbers in character widths. */
#define TXT_NUMCOL_PAD 1.0f
/* Total width of the optional line numbers column. */
#define TXT_NUMCOL_WIDTH(st) \
- (st->runtime.cwidth_px * (st->runtime.line_number_display_digits + (2 * TXT_NUMCOL_PAD)))
+ ((st)->runtime.cwidth_px * ((st)->runtime.line_number_display_digits + (2 * TXT_NUMCOL_PAD)))
/* Padding on left of body text in character units. */
#define TXT_BODY_LPAD 1.0f
/* Left position of body text. */
#define TXT_BODY_LEFT(st) \
- (st->showlinenrs ? TXT_NUMCOL_WIDTH(st) : 0) + (TXT_BODY_LPAD * st->runtime.cwidth_px)
+ ((st)->showlinenrs ? TXT_NUMCOL_WIDTH(st) : 0) + (TXT_BODY_LPAD * (st)->runtime.cwidth_px)
#define TXT_SCROLL_WIDTH U.widget_unit
#define TXT_SCROLL_SPACE ((int)(0.1f * U.widget_unit))
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index e0b15d0a9d5..26600bd7dbc 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -3420,7 +3420,7 @@ static int text_insert_exec(bContext *C, wmOperator *op)
char *str;
bool done = false;
size_t i = 0;
- unsigned int code;
+ uint code;
text_drawcache_tag_update(st, 0);
diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c
index cacf956aa84..d06c567988d 100644
--- a/source/blender/editors/space_topbar/space_topbar.c
+++ b/source/blender/editors/space_topbar/space_topbar.c
@@ -84,7 +84,7 @@ static void topbar_free(SpaceLink *UNUSED(sl))
}
/* spacetype; init callback */
-static void topbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void topbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
@@ -130,7 +130,7 @@ static void topbar_header_region_init(wmWindowManager *UNUSED(wm), ARegion *regi
}
static void topbar_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -161,7 +161,7 @@ static void topbar_main_region_listener(wmWindow *UNUSED(win),
}
static void topbar_header_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -195,7 +195,7 @@ static void topbar_header_region_message_subscribe(const struct bContext *UNUSED
struct WorkSpace *workspace,
struct Scene *UNUSED(scene),
struct bScreen *UNUSED(screen),
- struct ScrArea *UNUSED(sa),
+ struct ScrArea *UNUSED(area),
struct ARegion *region,
struct wmMsgBus *mbus)
{
diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c
index d3bea4598ff..9eae722d5c8 100644
--- a/source/blender/editors/space_userpref/space_userpref.c
+++ b/source/blender/editors/space_userpref/space_userpref.c
@@ -97,7 +97,7 @@ static void userpref_free(SpaceLink *UNUSED(sl))
}
/* spacetype; init callback */
-static void userpref_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void userpref_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
@@ -185,7 +185,7 @@ static void userpref_execute_region_init(wmWindowManager *wm, ARegion *region)
}
static void userpref_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *UNUSED(region),
wmNotifier *UNUSED(wmn),
const Scene *UNUSED(scene))
@@ -194,7 +194,7 @@ static void userpref_main_region_listener(wmWindow *UNUSED(win),
}
static void userpref_header_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *UNUSED(region),
wmNotifier *UNUSED(wmn),
const Scene *UNUSED(scene))
@@ -209,7 +209,7 @@ static void userpref_header_listener(wmWindow *UNUSED(win),
}
static void userpref_navigation_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *UNUSED(region),
wmNotifier *UNUSED(wmn),
const Scene *UNUSED(scene))
@@ -218,7 +218,7 @@ static void userpref_navigation_region_listener(wmWindow *UNUSED(win),
}
static void userpref_execute_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *UNUSED(region),
wmNotifier *UNUSED(wmn),
const Scene *UNUSED(scene))
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 13c5bddd3bf..226e6617a71 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -88,9 +88,9 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C)
RegionView3D *rv3d = CTX_wm_region_view3d(C);
if (rv3d == NULL) {
- ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_VIEW3D) {
- ARegion *region = BKE_area_find_region_active_win(sa);
+ ScrArea *area = CTX_wm_area(C);
+ if (area && area->spacetype == SPACE_VIEW3D) {
+ ARegion *region = BKE_area_find_region_active_win(area);
if (region) {
rv3d = region->regiondata;
}
@@ -101,27 +101,27 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C)
/* ideally would return an rv3d but in some cases the region is needed too
* so return that, the caller can then access the region->regiondata */
-bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar)
+bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_region)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
*r_v3d = NULL;
- *r_ar = NULL;
+ *r_region = NULL;
- if (sa && sa->spacetype == SPACE_VIEW3D) {
+ if (area && area->spacetype == SPACE_VIEW3D) {
ARegion *region = CTX_wm_region(C);
- View3D *v3d = (View3D *)sa->spacedata.first;
+ View3D *v3d = (View3D *)area->spacedata.first;
if (region) {
RegionView3D *rv3d;
if ((region->regiontype == RGN_TYPE_WINDOW) && (rv3d = region->regiondata) &&
(rv3d->viewlock & RV3D_LOCK_ROTATION) == 0) {
*r_v3d = v3d;
- *r_ar = region;
+ *r_region = region;
return true;
}
else {
- if (ED_view3d_area_user_region(sa, v3d, r_ar)) {
+ if (ED_view3d_area_user_region(area, v3d, r_region)) {
*r_v3d = v3d;
return true;
}
@@ -136,23 +136,24 @@ bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar)
* Similar to #ED_view3d_context_user_region() but does not use context. Always performs a lookup.
* Also works if \a v3d is not the active space.
*/
-bool ED_view3d_area_user_region(const ScrArea *sa, const View3D *v3d, ARegion **r_ar)
+bool ED_view3d_area_user_region(const ScrArea *area, const View3D *v3d, ARegion **r_region)
{
RegionView3D *rv3d = NULL;
- ARegion *ar_unlock_user = NULL;
- ARegion *ar_unlock = NULL;
- const ListBase *region_list = (v3d == sa->spacedata.first) ? &sa->regionbase : &v3d->regionbase;
+ ARegion *region_unlock_user = NULL;
+ ARegion *region_unlock = NULL;
+ const ListBase *region_list = (v3d == area->spacedata.first) ? &area->regionbase :
+ &v3d->regionbase;
BLI_assert(v3d->spacetype == SPACE_VIEW3D);
- for (ARegion *region = region_list->first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, region_list) {
/* find the first unlocked rv3d */
if (region->regiondata && region->regiontype == RGN_TYPE_WINDOW) {
rv3d = region->regiondata;
if ((rv3d->viewlock & RV3D_LOCK_ROTATION) == 0) {
- ar_unlock = region;
+ region_unlock = region;
if (rv3d->persp == RV3D_PERSP || rv3d->persp == RV3D_CAMOB) {
- ar_unlock_user = region;
+ region_unlock_user = region;
break;
}
}
@@ -160,13 +161,13 @@ bool ED_view3d_area_user_region(const ScrArea *sa, const View3D *v3d, ARegion **
}
/* camera/perspective view get priority when the active region is locked */
- if (ar_unlock_user) {
- *r_ar = ar_unlock_user;
+ if (region_unlock_user) {
+ *r_region = region_unlock_user;
return true;
}
- if (ar_unlock) {
- *r_ar = ar_unlock;
+ if (region_unlock) {
+ *r_region = region_unlock;
return true;
}
@@ -239,14 +240,14 @@ void ED_view3d_stop_render_preview(wmWindowManager *wm, ARegion *region)
}
}
-void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa)
+void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *area)
{
wmWindowManager *wm = bmain->wm.first;
if (v3d->shading.type != OB_RENDER) {
ARegion *region;
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if ((region->regiontype == RGN_TYPE_WINDOW) && region->regiondata) {
ED_view3d_stop_render_preview(wm, region);
break;
@@ -257,7 +258,7 @@ void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa)
/* ******************** default callbacks for view3d space ***************** */
-static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
+static SpaceLink *view3d_new(const ScrArea *UNUSED(area), const Scene *scene)
{
ARegion *region;
View3D *v3d;
@@ -336,7 +337,7 @@ static void view3d_free(SpaceLink *sl)
}
/* spacetype; init callback */
-static void view3d_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void view3d_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
@@ -732,9 +733,9 @@ static void *view3d_main_region_duplicate(void *poin)
}
static void view3d_main_region_listener(
- wmWindow *UNUSED(win), ScrArea *sa, ARegion *region, wmNotifier *wmn, const Scene *scene)
+ wmWindow *UNUSED(win), ScrArea *area, ARegion *region, wmNotifier *wmn, const Scene *scene)
{
- View3D *v3d = sa->spacedata.first;
+ View3D *v3d = area->spacedata.first;
RegionView3D *rv3d = region->regiondata;
wmGizmoMap *gzmap = region->gizmo_map;
@@ -927,7 +928,7 @@ static void view3d_main_region_listener(
}
break;
case NC_LIGHTPROBE:
- ED_area_tag_refresh(sa);
+ ED_area_tag_refresh(area);
break;
case NC_IMAGE:
/* this could be more fine grained checks if we had
@@ -992,7 +993,7 @@ static void view3d_main_region_message_subscribe(const struct bContext *C,
struct WorkSpace *UNUSED(workspace),
struct Scene *UNUSED(scene),
struct bScreen *UNUSED(screen),
- struct ScrArea *sa,
+ struct ScrArea *area,
struct ARegion *region,
struct wmMsgBus *mbus)
{
@@ -1070,7 +1071,7 @@ static void view3d_main_region_message_subscribe(const struct bContext *C,
{
wmMsgSubscribeValue msg_sub_value_region_tag_refresh = {
.owner = region,
- .user_data = sa,
+ .user_data = area,
.notify = WM_toolsystem_do_msg_notify_tag_refresh,
};
WM_msg_subscribe_rna_anon_prop(mbus, Object, mode, &msg_sub_value_region_tag_refresh);
@@ -1078,9 +1079,9 @@ static void view3d_main_region_message_subscribe(const struct bContext *C,
}
}
-static void view3d_main_region_cursor(wmWindow *win, ScrArea *sa, ARegion *region)
+static void view3d_main_region_cursor(wmWindow *win, ScrArea *area, ARegion *region)
{
- if (!WM_cursor_set_from_tool(win, sa, region)) {
+ if (!WM_cursor_set_from_tool(win, area, region)) {
WM_cursor_set(win, WM_CURSOR_DEFAULT);
}
}
@@ -1101,7 +1102,7 @@ static void view3d_header_region_draw(const bContext *C, ARegion *region)
}
static void view3d_header_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -1174,7 +1175,7 @@ static void view3d_header_region_message_subscribe(const struct bContext *UNUSED
struct WorkSpace *UNUSED(workspace),
struct Scene *UNUSED(scene),
struct bScreen *UNUSED(screen),
- struct ScrArea *UNUSED(sa),
+ struct ScrArea *UNUSED(area),
struct ARegion *region,
struct wmMsgBus *mbus)
{
@@ -1318,7 +1319,7 @@ static void view3d_buttons_region_layout(const bContext *C, ARegion *region)
}
static void view3d_buttons_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(sa),
+ ScrArea *UNUSED(area),
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
@@ -1441,11 +1442,11 @@ static void view3d_tools_region_draw(const bContext *C, ARegion *region)
/* area (not region) level listener */
static void space_view3d_listener(wmWindow *UNUSED(win),
- ScrArea *sa,
+ ScrArea *area,
struct wmNotifier *wmn,
Scene *UNUSED(scene))
{
- View3D *v3d = sa->spacedata.first;
+ View3D *v3d = area->spacedata.first;
/* context changes */
switch (wmn->category) {
@@ -1453,7 +1454,7 @@ static void space_view3d_listener(wmWindow *UNUSED(win),
switch (wmn->data) {
case ND_WORLD:
if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
- ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW);
+ ED_area_tag_redraw_regiontype(area, RGN_TYPE_WINDOW);
}
break;
}
@@ -1463,7 +1464,7 @@ static void space_view3d_listener(wmWindow *UNUSED(win),
case ND_WORLD_DRAW:
case ND_WORLD:
if (v3d->shading.background_type == V3D_SHADING_BACKGROUND_WORLD) {
- ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW);
+ ED_area_tag_redraw_regiontype(area, RGN_TYPE_WINDOW);
}
break;
}
@@ -1472,7 +1473,7 @@ static void space_view3d_listener(wmWindow *UNUSED(win),
switch (wmn->data) {
case ND_NODES:
if (v3d->shading.type == OB_TEXTURE) {
- ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW);
+ ED_area_tag_redraw_regiontype(area, RGN_TYPE_WINDOW);
}
break;
}
@@ -1480,7 +1481,7 @@ static void space_view3d_listener(wmWindow *UNUSED(win),
}
}
-static void space_view3d_refresh(const bContext *C, ScrArea *UNUSED(sa))
+static void space_view3d_refresh(const bContext *C, ScrArea *UNUSED(area))
{
Scene *scene = CTX_data_scene(C);
LightCache *lcache = scene->eevee.light_cache_data;
@@ -1538,7 +1539,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
return -1; /* found but not available */
}
-static void view3d_id_remap(ScrArea *sa, SpaceLink *slink, ID *old_id, ID *new_id)
+static void view3d_id_remap(ScrArea *area, SpaceLink *slink, ID *old_id, ID *new_id)
{
View3D *v3d;
ARegion *region;
@@ -1553,8 +1554,8 @@ static void view3d_id_remap(ScrArea *sa, SpaceLink *slink, ID *old_id, ID *new_i
v3d->camera = (Object *)new_id;
if (!new_id) {
/* 3D view might be inactive, in that case needs to use slink->regionbase */
- ListBase *regionbase = (slink == sa->spacedata.first) ? &sa->regionbase :
- &slink->regionbase;
+ ListBase *regionbase = (slink == area->spacedata.first) ? &area->regionbase :
+ &slink->regionbase;
for (region = regionbase->first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = is_local ? ((RegionView3D *)region->regiondata)->localvd :
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index 80ab18cd3db..7965422c117 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -1140,9 +1140,9 @@ static bool view3d_panel_vgroup_poll(const bContext *C, PanelType *UNUSED(pt))
return false;
}
-static void view3d_panel_vgroup(const bContext *C, Panel *pa)
+static void view3d_panel_vgroup(const bContext *C, Panel *panel)
{
- uiBlock *block = uiLayoutAbsoluteBlock(pa->layout);
+ uiBlock *block = uiLayoutAbsoluteBlock(panel->layout);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = view_layer->basact->object;
@@ -1171,7 +1171,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
UI_block_func_handle_set(block, do_view3d_vgroup_buttons, NULL);
- bcol = uiLayoutColumn(pa->layout, true);
+ bcol = uiLayoutColumn(panel->layout, true);
row = uiLayoutRow(bcol, true); /* The filter button row */
RNA_pointer_create(NULL, &RNA_ToolSettings, ts, &tools_ptr);
@@ -1269,7 +1269,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
yco -= 2;
- col = uiLayoutColumn(pa->layout, true);
+ col = uiLayoutColumn(panel->layout, true);
row = uiLayoutRow(col, true);
ot = WM_operatortype_find("OBJECT_OT_vertex_weight_normalize_active_vertex", 1);
@@ -1555,7 +1555,7 @@ static bool view3d_panel_transform_poll(const bContext *C, PanelType *UNUSED(pt)
return (view_layer->basact != NULL);
}
-static void view3d_panel_transform(const bContext *C, Panel *pa)
+static void view3d_panel_transform(const bContext *C, Panel *panel)
{
uiBlock *block;
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -1563,10 +1563,10 @@ static void view3d_panel_transform(const bContext *C, Panel *pa)
Object *obedit = OBEDIT_FROM_OBACT(ob);
uiLayout *col;
- block = uiLayoutGetBlock(pa->layout);
+ block = uiLayoutGetBlock(panel->layout);
UI_block_func_handle_set(block, do_view3d_region_buttons, NULL);
- col = uiLayoutColumn(pa->layout, false);
+ col = uiLayoutColumn(panel->layout, false);
if (ob == obedit) {
if (ob->type == OB_ARMATURE) {
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 694cb7ee7d4..c1995249c26 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2396,9 +2396,9 @@ void ED_view3d_screen_datamask(const bContext *C,
CustomData_MeshMasks_update(r_cddata_masks, &CD_MASK_BAREMESH);
/* Check if we need tfaces & mcols due to view mode. */
- for (const ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->spacetype == SPACE_VIEW3D) {
- ED_view3d_datamask(C, scene, sa->spacedata.first, r_cddata_masks);
+ LISTBASE_FOREACH (const ScrArea *, area, &screen->areabase) {
+ if (area->spacetype == SPACE_VIEW3D) {
+ ED_view3d_datamask(C, scene, area->spacedata.first, r_cddata_masks);
}
}
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index e650f5581ff..0a30336aed8 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -175,7 +175,7 @@ typedef struct ViewOpsData {
/** Context pointers (assigned by #viewops_data_alloc). */
Main *bmain;
Scene *scene;
- ScrArea *sa;
+ ScrArea *area;
ARegion *region;
View3D *v3d;
RegionView3D *rv3d;
@@ -277,9 +277,9 @@ static void viewops_data_alloc(bContext *C, wmOperator *op)
vod->bmain = CTX_data_main(C);
vod->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
vod->scene = CTX_data_scene(C);
- vod->sa = CTX_wm_area(C);
+ vod->area = CTX_wm_area(C);
vod->region = CTX_wm_region(C);
- vod->v3d = vod->sa->spacedata.first;
+ vod->v3d = vod->area->spacedata.first;
vod->rv3d = vod->region->regiondata;
}
@@ -529,10 +529,10 @@ static void viewops_data_create(bContext *C,
negate_v3_v3(rv3d->ofs, dvec);
}
else {
- const float mval_ar_mid[2] = {(float)vod->region->winx / 2.0f,
- (float)vod->region->winy / 2.0f};
+ const float mval_region_mid[2] = {(float)vod->region->winx / 2.0f,
+ (float)vod->region->winy / 2.0f};
- ED_view3d_win_to_3d(vod->v3d, vod->region, vod->dyn_ofs, mval_ar_mid, rv3d->ofs);
+ ED_view3d_win_to_3d(vod->v3d, vod->region, vod->dyn_ofs, mval_region_mid, rv3d->ofs);
negate_v3(rv3d->ofs);
}
negate_v3(vod->dyn_ofs);
@@ -1120,7 +1120,7 @@ static float view3d_ndof_pan_speed_calc(RegionView3D *rv3d)
* often `!rv3d->is_persp` since it doesn't make sense to dolly in ortho.
*/
static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof,
- ScrArea *sa,
+ ScrArea *area,
ARegion *region,
const bool has_translate,
const bool has_zoom)
@@ -1161,7 +1161,7 @@ static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof,
/* all callers must check */
if (has_translate) {
- BLI_assert(ED_view3d_offset_lock_check((View3D *)sa->spacedata.first, rv3d) == false);
+ BLI_assert(ED_view3d_offset_lock_check((View3D *)area->spacedata.first, rv3d) == false);
}
}
@@ -1178,18 +1178,18 @@ static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof,
sub_v3_v3(rv3d->ofs, pan_vec);
if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
- view3d_boxview_sync(sa, region);
+ view3d_boxview_sync(area, region);
}
}
}
static void view3d_ndof_orbit(const struct wmNDOFMotionData *ndof,
- ScrArea *sa,
+ ScrArea *area,
ARegion *region,
ViewOpsData *vod,
const bool apply_dyn_ofs)
{
- View3D *v3d = sa->spacedata.first;
+ View3D *v3d = area->spacedata.first;
RegionView3D *rv3d = region->regiondata;
float view_inv[4];
@@ -1422,12 +1422,12 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp;
if (has_translate || has_zoom) {
- view3d_ndof_pan_zoom(ndof, vod->sa, vod->region, has_translate, has_zoom);
+ view3d_ndof_pan_zoom(ndof, vod->area, vod->region, has_translate, has_zoom);
xform_flag |= HAS_TRANSLATE;
}
if (has_rotation) {
- view3d_ndof_orbit(ndof, vod->sa, vod->region, vod, true);
+ view3d_ndof_orbit(ndof, vod->area, vod->region, vod, true);
xform_flag |= HAS_ROTATE;
}
}
@@ -1505,7 +1505,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
const bool has_zoom = (ndof->tvec[2] != 0.0f) && ED_view3d_offset_lock_check(v3d, rv3d);
if (has_translate || has_zoom) {
- view3d_ndof_pan_zoom(ndof, vod->sa, vod->region, has_translate, true);
+ view3d_ndof_pan_zoom(ndof, vod->area, vod->region, has_translate, true);
xform_flag |= HAS_TRANSLATE;
}
}
@@ -1535,7 +1535,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
if (!is_orbit_around_pivot) {
ED_view3d_distance_set(rv3d, 0.0f);
}
- view3d_ndof_orbit(ndof, vod->sa, vod->region, vod, is_orbit_around_pivot);
+ view3d_ndof_orbit(ndof, vod->area, vod->region, vod, is_orbit_around_pivot);
xform_flag |= HAS_ROTATE;
if (!is_orbit_around_pivot) {
ED_view3d_distance_set(rv3d, dist_backup);
@@ -1543,7 +1543,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
}
if (has_translate || has_zoom) {
- view3d_ndof_pan_zoom(ndof, vod->sa, vod->region, has_translate, has_zoom);
+ view3d_ndof_pan_zoom(ndof, vod->area, vod->region, has_translate, has_zoom);
xform_flag |= HAS_TRANSLATE;
}
}
@@ -1607,11 +1607,11 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e
ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false);
if (ndof->progress != P_FINISHING) {
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
if (has_translate || has_zoom) {
- view3d_ndof_pan_zoom(ndof, sa, region, has_translate, has_zoom);
+ view3d_ndof_pan_zoom(ndof, area, region, has_translate, has_zoom);
xform_flag |= HAS_TRANSLATE;
}
}
@@ -1751,7 +1751,7 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y)
add_v3_v3(vod->rv3d->ofs, dvec);
if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) {
- view3d_boxview_sync(vod->sa, vod->region);
+ view3d_boxview_sync(vod->area, vod->region);
}
}
@@ -2189,7 +2189,7 @@ static void viewzoom_apply_3d(ViewOpsData *vod,
CLAMP(vod->rv3d->dist, dist_range[0], dist_range[1]);
if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) {
- view3d_boxview_sync(vod->sa, vod->region);
+ view3d_boxview_sync(vod->area, vod->region);
}
ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d);
@@ -2280,7 +2280,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
View3D *v3d;
RegionView3D *rv3d;
- ScrArea *sa;
+ ScrArea *area;
ARegion *region;
bool use_cam_zoom;
float dist_range[2];
@@ -2291,15 +2291,15 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
if (op->customdata) {
ViewOpsData *vod = op->customdata;
- sa = vod->sa;
+ area = vod->area;
region = vod->region;
}
else {
- sa = CTX_wm_area(C);
+ area = CTX_wm_area(C);
region = CTX_wm_region(C);
}
- v3d = sa->spacedata.first;
+ v3d = area->spacedata.first;
rv3d = region->regiondata;
use_cam_zoom = (rv3d->persp == RV3D_CAMOB) &&
@@ -2342,7 +2342,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
}
if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
- view3d_boxview_sync(sa, region);
+ view3d_boxview_sync(area, region);
}
ED_view3d_depth_tag_update(rv3d);
@@ -2538,7 +2538,7 @@ static void viewdolly_apply(ViewOpsData *vod, const int xy[2], const short zoom_
}
if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) {
- view3d_boxview_sync(vod->sa, vod->region);
+ view3d_boxview_sync(vod->area, vod->region);
}
ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d);
@@ -2603,7 +2603,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
{
View3D *v3d;
RegionView3D *rv3d;
- ScrArea *sa;
+ ScrArea *area;
ARegion *region;
float mousevec[3];
@@ -2612,18 +2612,18 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
if (op->customdata) {
ViewOpsData *vod = op->customdata;
- sa = vod->sa;
+ area = vod->area;
region = vod->region;
copy_v3_v3(mousevec, vod->init.mousevec);
}
else {
- sa = CTX_wm_area(C);
+ area = CTX_wm_area(C);
region = CTX_wm_region(C);
negate_v3_v3(mousevec, ((RegionView3D *)region->regiondata)->viewinv[2]);
normalize_v3(mousevec);
}
- v3d = sa->spacedata.first;
+ v3d = area->spacedata.first;
rv3d = region->regiondata;
const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init");
@@ -2636,7 +2636,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
view_dolly_to_vector_3d(region, rv3d->ofs, mousevec, delta < 0 ? 0.2f : 1.8f);
if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
- view3d_boxview_sync(sa, region);
+ view3d_boxview_sync(area, region);
}
ED_view3d_depth_tag_update(rv3d);
@@ -2886,9 +2886,9 @@ static void view3d_from_minmax_multi(bContext *C,
const bool ok_dist,
const int smooth_viewtx)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region;
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
/* when using all regions, don't jump out of camera view,
@@ -4376,7 +4376,7 @@ static void viewroll_apply(ViewOpsData *vod, int x, int UNUSED(y))
}
if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) {
- view3d_boxview_sync(vod->sa, vod->region);
+ view3d_boxview_sync(vod->area, vod->region);
}
ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d);
@@ -5279,7 +5279,7 @@ static int toggle_shading_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
View3D *v3d = CTX_wm_view3d(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
int type = RNA_enum_get(op->ptr, "type");
if (type == OB_SOLID) {
@@ -5307,7 +5307,7 @@ static int toggle_shading_exec(bContext *C, wmOperator *op)
}
}
- ED_view3d_shade_update(bmain, v3d, sa);
+ ED_view3d_shade_update(bmain, v3d, area);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
return OPERATOR_FINISHED;
@@ -5340,7 +5340,7 @@ void VIEW3D_OT_toggle_shading(wmOperatorType *ot)
static int toggle_xray_exec(bContext *C, wmOperator *op)
{
View3D *v3d = CTX_wm_view3d(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Object *obact = CTX_data_active_object(C);
if (obact && ((obact->mode & OB_MODE_POSE) ||
@@ -5362,7 +5362,7 @@ static int toggle_xray_exec(bContext *C, wmOperator *op)
}
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
index cc00037b1fb..533fba3795b 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
@@ -321,14 +321,14 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g
if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0) {
gz = navgroup->gz_array[GZ_INDEX_CAMERA];
- gz->matrix_basis[3][0] = co[0];
- gz->matrix_basis[3][1] = co[1] - (icon_offset_mini * icon_mini_slot++);
+ gz->matrix_basis[3][0] = roundf(co[0]);
+ gz->matrix_basis[3][1] = roundf(co[1] - (icon_offset_mini * icon_mini_slot++));
WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
if (navgroup->state.rv3d.is_camera == false) {
gz = navgroup->gz_array[rv3d->is_persp ? GZ_INDEX_PERSP : GZ_INDEX_ORTHO];
- gz->matrix_basis[3][0] = co[0];
- gz->matrix_basis[3][1] = co[1] - (icon_offset_mini * icon_mini_slot++);
+ gz->matrix_basis[3][0] = roundf(co[0]);
+ gz->matrix_basis[3][1] = roundf(co[1] - (icon_offset_mini * icon_mini_slot++));
WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
index 4b194d6687d..e4863c0cdeb 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
@@ -110,7 +110,7 @@ typedef struct RulerInfo {
/* wm state */
wmWindow *win;
- ScrArea *sa;
+ ScrArea *area;
ARegion *region; /* re-assigned every modal update */
/* Track changes in state. */
@@ -299,7 +299,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
static void view3d_ruler_item_project(RulerInfo *ruler_info, float r_co[3], const int xy[2])
{
- ED_view3d_win_to_3d_int(ruler_info->sa->spacedata.first, ruler_info->region, r_co, xy, r_co);
+ ED_view3d_win_to_3d_int(ruler_info->area->spacedata.first, ruler_info->region, r_co, xy, r_co);
}
/* use for mousemove events */
@@ -323,7 +323,7 @@ static bool view3d_ruler_item_mousemove(struct Depsgraph *depsgraph,
view3d_ruler_item_project(ruler_info, co, mval);
if (do_thickness && inter->co_index != 1) {
// Scene *scene = CTX_data_scene(C);
- // View3D *v3d = ruler_info->sa->spacedata.first;
+ // View3D *v3d = ruler_info->area->spacedata.first;
const float mval_fl[2] = {UNPACK2(mval)};
float ray_normal[3];
float ray_start[3];
@@ -1064,10 +1064,10 @@ static void WIDGETGROUP_ruler_setup(const bContext *C, wmGizmoGroup *gzgroup)
}
wmWindow *win = CTX_wm_window(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
ruler_info->win = win;
- ruler_info->sa = sa;
+ ruler_info->area = area;
ruler_info->region = region;
gzgroup->customdata = ruler_info;
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 57989680705..be0084d8869 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -105,7 +105,7 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
wmWindow *win = CTX_wm_window(C);
const int ctrl = win->eventstate->ctrl, shift = win->eventstate->shift;
- /* watch it: if sa->win does not exist, check that when calling direct drawing routines */
+ /* watch it: if area->win does not exist, check that when calling direct drawing routines */
switch (event) {
case B_SEL_VERT:
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 610c40c37eb..c16131c8317 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -91,8 +91,8 @@ void VIEW3D_OT_zoom_border(struct wmOperatorType *ot);
void VIEW3D_OT_toggle_shading(struct wmOperatorType *ot);
void VIEW3D_OT_toggle_xray(struct wmOperatorType *ot);
-void view3d_boxview_copy(struct ScrArea *sa, struct ARegion *region);
-void view3d_boxview_sync(struct ScrArea *sa, struct ARegion *region);
+void view3d_boxview_copy(struct ScrArea *area, struct ARegion *region);
+void view3d_boxview_sync(struct ScrArea *area, struct ARegion *region);
void view3d_orbit_apply_dyn_ofs(float r_ofs[3],
const float ofs_old[3],
@@ -181,7 +181,7 @@ typedef struct V3D_SmoothParams {
void ED_view3d_smooth_view_ex(const struct Depsgraph *depsgraph,
struct wmWindowManager *wm,
struct wmWindow *win,
- struct ScrArea *sa,
+ struct ScrArea *area,
struct View3D *v3d,
struct ARegion *region,
const int smooth_viewtx,
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 8fdef585fa2..0a272db1344 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -157,7 +157,7 @@ void ED_view3d_viewcontext_init_object(ViewContext *vc, Object *obact)
static bool object_deselect_all_visible(ViewLayer *view_layer, View3D *v3d)
{
bool changed = false;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->flag & BASE_SELECTED) {
if (BASE_SELECTABLE(v3d, base)) {
ED_object_base_select(base, BA_DESELECT);
@@ -172,7 +172,7 @@ static bool object_deselect_all_visible(ViewLayer *view_layer, View3D *v3d)
static bool object_deselect_all_except(ViewLayer *view_layer, Base *b)
{
bool changed = false;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->flag & BASE_SELECTED) {
if (b != base) {
ED_object_base_select(base, BA_DESELECT);
@@ -617,7 +617,7 @@ static Base **do_pose_tag_select_op_prepare(ViewContext *vc, uint *r_bases_len)
FOREACH_BASE_IN_MODE_BEGIN (vc->view_layer, vc->v3d, OB_ARMATURE, OB_MODE_POSE, base_iter) {
Object *ob_iter = base_iter->object;
bArmature *arm = ob_iter->data;
- for (bPoseChannel *pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob_iter->pose->chanbase) {
Bone *bone = pchan->bone;
bone->flag &= ~BONE_DONE;
}
@@ -659,7 +659,7 @@ static bool do_pose_tag_select_op_exec(Base **bases, const uint bases_len, const
}
bool changed = true;
- for (bPoseChannel *pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob_iter->pose->chanbase) {
Bone *bone = pchan->bone;
if ((bone->flag & BONE_UNSELECTABLE) == 0) {
const bool is_select = bone->flag & BONE_SELECTED;
@@ -1226,7 +1226,7 @@ static bool do_lasso_select_paintface(ViewContext *vc,
#if 0
static void do_lasso_select_node(int mcords[][2], short moves, const eSelectOp sel_op)
{
- SpaceNode *snode = sa->spacedata.first;
+ SpaceNode *snode = area->spacedata.first;
bNode *node;
rcti rect;
@@ -3076,7 +3076,7 @@ static bool do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const
const int hits = view3d_opengl_select(
vc, vbuffer, 4 * (totobj + MAXPICKELEMS), rect, VIEW3D_SELECT_ALL, select_filter);
- for (Base *base = vc->view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &vc->view_layer->object_bases) {
base->object->id.tag &= ~LIB_TAG_DOIT;
}
@@ -3092,7 +3092,7 @@ static bool do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const
goto finally;
}
- for (Base *base = vc->view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &vc->view_layer->object_bases) {
if (BASE_SELECTABLE(v3d, base)) {
if ((base->object->runtime.select_id & 0x0000FFFF) != 0) {
BLI_array_append(bases, base);
@@ -3104,9 +3104,9 @@ static bool do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const
qsort(vbuffer, hits, sizeof(uint[4]), opengl_bone_select_buffer_cmp);
for (const uint *col = vbuffer + 3, *col_end = col + (hits * 4); col < col_end; col += 4) {
- Bone *bone;
- Base *base = ED_armature_base_and_bone_from_select_buffer(
- bases, BLI_array_len(bases), *col, &bone);
+ bPoseChannel *pchan_dummy;
+ Base *base = ED_armature_base_and_pchan_from_select_buffer(
+ bases, BLI_array_len(bases), *col, &pchan_dummy);
if (base != NULL) {
base->object->id.tag |= LIB_TAG_DOIT;
}
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index 2637fb6d1db..09e1dca3152 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -228,26 +228,26 @@ void ED_view3d_polygon_offset(const RegionView3D *rv3d, const float dist)
bool ED_view3d_context_activate(bContext *C)
{
- bScreen *sc = CTX_wm_screen(C);
- ScrArea *sa = CTX_wm_area(C);
+ bScreen *screen = CTX_wm_screen(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region;
- /* sa can be NULL when called from python */
- if (sa == NULL || sa->spacetype != SPACE_VIEW3D) {
- sa = BKE_screen_find_big_area(sc, SPACE_VIEW3D, 0);
+ /* area can be NULL when called from python */
+ if (area == NULL || area->spacetype != SPACE_VIEW3D) {
+ area = BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0);
}
- if (sa == NULL) {
+ if (area == NULL) {
return false;
}
- region = BKE_area_find_region_active_win(sa);
+ region = BKE_area_find_region_active_win(area);
if (region == NULL) {
return false;
}
/* bad context switch .. */
- CTX_wm_area_set(C, sa);
+ CTX_wm_area_set(C, area);
CTX_wm_region_set(C, region);
return true;
@@ -666,7 +666,7 @@ bool ED_view3d_camera_lock_autokey(View3D *v3d,
* Use with quad-split so each view is clipped by the bounds of each view axis.
* \{ */
-static void view3d_boxview_clip(ScrArea *sa)
+static void view3d_boxview_clip(ScrArea *area)
{
ARegion *region;
BoundBox *bb = MEM_callocN(sizeof(BoundBox), "clipbb");
@@ -675,7 +675,7 @@ static void view3d_boxview_clip(ScrArea *sa)
int val;
/* create bounding box */
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
@@ -747,7 +747,7 @@ static void view3d_boxview_clip(ScrArea *sa)
}
/* create bounding box */
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
@@ -812,13 +812,13 @@ static void view3d_boxview_sync_axis(RegionView3D *rv3d_dst, RegionView3D *rv3d_
}
/* sync center/zoom view of region to others, for view transforms */
-void view3d_boxview_sync(ScrArea *sa, ARegion *region)
+void view3d_boxview_sync(ScrArea *area, ARegion *region)
{
ARegion *artest;
RegionView3D *rv3d = region->regiondata;
short clip = 0;
- for (artest = sa->regionbase.first; artest; artest = artest->next) {
+ for (artest = area->regionbase.first; artest; artest = artest->next) {
if (artest != region && artest->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3dtest = artest->regiondata;
@@ -833,18 +833,18 @@ void view3d_boxview_sync(ScrArea *sa, ARegion *region)
}
if (clip) {
- view3d_boxview_clip(sa);
+ view3d_boxview_clip(area);
}
}
/* for home, center etc */
-void view3d_boxview_copy(ScrArea *sa, ARegion *region)
+void view3d_boxview_copy(ScrArea *area, ARegion *region)
{
ARegion *artest;
RegionView3D *rv3d = region->regiondata;
bool clip = false;
- for (artest = sa->regionbase.first; artest; artest = artest->next) {
+ for (artest = area->regionbase.first; artest; artest = artest->next) {
if (artest != region && artest->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3dtest = artest->regiondata;
@@ -859,14 +859,14 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *region)
}
if (clip) {
- view3d_boxview_clip(sa);
+ view3d_boxview_clip(area);
}
}
/* 'clip' is used to know if our clip setting has changed */
-void ED_view3d_quadview_update(ScrArea *sa, ARegion *region, bool do_clip)
+void ED_view3d_quadview_update(ScrArea *area, ARegion *region, bool do_clip)
{
- ARegion *ar_sync = NULL;
+ ARegion *region_sync = NULL;
RegionView3D *rv3d = region->regiondata;
short viewlock;
/* this function copies flags from the first of the 3 other quadview
@@ -892,21 +892,21 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *region, bool do_clip)
rv3d->rflag &= ~RV3D_BOXCLIP;
}
- /* use ar_sync so we sync with one of the aligned views below
+ /* use region_sync so we sync with one of the aligned views below
* else the view jumps on changing view settings like 'clip'
* since it copies from the perspective view */
- ar_sync = region;
+ region_sync = region;
}
}
if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
- view3d_boxview_sync(sa, ar_sync ? ar_sync : sa->regionbase.last);
+ view3d_boxview_sync(area, region_sync ? region_sync : area->regionbase.last);
}
/* ensure locked regions have an axis, locked user views don't make much sense */
if (viewlock & RV3D_LOCK_ROTATION) {
int index_qsplit = 0;
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->alignment == RGN_ALIGN_QSPLIT) {
rv3d = region->regiondata;
if (rv3d->viewlock) {
@@ -922,7 +922,7 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *region, bool do_clip)
}
}
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
}
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 30587e6084d..b90f7aa870e 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -128,7 +128,7 @@ void ED_view3d_smooth_view_ex(
const Depsgraph *depsgraph,
wmWindowManager *wm,
wmWindow *win,
- ScrArea *sa,
+ ScrArea *area,
View3D *v3d,
ARegion *region,
const int smooth_viewtx,
@@ -293,7 +293,7 @@ void ED_view3d_smooth_view_ex(
}
if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
- view3d_boxview_copy(sa, region);
+ view3d_boxview_copy(area, region);
}
ED_region_tag_redraw(region);
@@ -309,9 +309,9 @@ void ED_view3d_smooth_view(bContext *C,
const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
- ED_view3d_smooth_view_ex(depsgraph, wm, win, sa, v3d, region, smooth_viewtx, sview);
+ ED_view3d_smooth_view_ex(depsgraph, wm, win, area, v3d, region, smooth_viewtx, sview);
}
/* only meant for timer usage */
@@ -615,17 +615,18 @@ static void sync_viewport_camera_smoothview(bContext *C,
if (v3d->scenelock) {
ListBase *lb = (space_link == area->spacedata.first) ? &area->regionbase :
&space_link->regionbase;
- for (ARegion *other_ar = lb->first; other_ar != NULL; other_ar = other_ar->next) {
- if (other_ar->regiontype == RGN_TYPE_WINDOW) {
- if (other_ar->regiondata) {
- RegionView3D *other_rv3d = other_ar->regiondata;
+ for (ARegion *other_region = lb->first; other_region != NULL;
+ other_region = other_region->next) {
+ if (other_region->regiontype == RGN_TYPE_WINDOW) {
+ if (other_region->regiondata) {
+ RegionView3D *other_rv3d = other_region->regiondata;
if (other_rv3d->persp == RV3D_CAMOB) {
Object *other_camera_old = other_v3d->camera;
other_v3d->camera = ob;
ED_view3d_lastview_store(other_rv3d);
ED_view3d_smooth_view(C,
other_v3d,
- other_ar,
+ other_region,
smooth_viewtx,
&(const V3D_SmoothParams){
.camera_old = other_camera_old,
@@ -704,9 +705,9 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
bool ED_operator_rv3d_user_region_poll(bContext *C)
{
View3D *v3d_dummy;
- ARegion *ar_dummy;
+ ARegion *region_dummy;
- return ED_view3d_context_user_region(C, &v3d_dummy, &ar_dummy);
+ return ED_view3d_context_user_region(C, &v3d_dummy, &region_dummy);
}
void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
@@ -1199,16 +1200,16 @@ finally:
static uint free_localview_bit(Main *bmain)
{
- ScrArea *sa;
- bScreen *sc;
+ ScrArea *area;
+ bScreen *screen;
ushort local_view_bits = 0;
/* sometimes we loose a localview: when an area is closed */
/* check all areas: which localviews are in use? */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl = sa->spacedata.first;
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (area = screen->areabase.first; area; area = area->next) {
+ SpaceLink *sl = area->spacedata.first;
for (; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
@@ -1234,12 +1235,12 @@ static bool view3d_localview_init(const Depsgraph *depsgraph,
wmWindow *win,
Main *bmain,
ViewLayer *view_layer,
- ScrArea *sa,
+ ScrArea *area,
const bool frame_selected,
const int smooth_viewtx,
ReportList *reports)
{
- View3D *v3d = sa->spacedata.first;
+ View3D *v3d = area->spacedata.first;
Base *base;
float min[3], max[3], box[3];
float size = 0.0f;
@@ -1301,7 +1302,7 @@ static bool view3d_localview_init(const Depsgraph *depsgraph,
memcpy(v3d->localvd, v3d, sizeof(View3D));
v3d->local_view_uuid = local_view_bit;
- for (region = sa->regionbase.first; region; region = region->next) {
+ for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
bool ok_dist = true;
@@ -1342,7 +1343,7 @@ static bool view3d_localview_init(const Depsgraph *depsgraph,
ED_view3d_smooth_view_ex(depsgraph,
wm,
win,
- sa,
+ area,
v3d,
region,
smooth_viewtx,
@@ -1364,11 +1365,11 @@ static void view3d_localview_exit(const Depsgraph *depsgraph,
wmWindowManager *wm,
wmWindow *win,
ViewLayer *view_layer,
- ScrArea *sa,
+ ScrArea *area,
const bool frame_selected,
const int smooth_viewtx)
{
- View3D *v3d = sa->spacedata.first;
+ View3D *v3d = area->spacedata.first;
if (v3d->localvd == NULL) {
return;
@@ -1389,7 +1390,7 @@ static void view3d_localview_exit(const Depsgraph *depsgraph,
MEM_freeN(v3d->localvd);
v3d->localvd = NULL;
- for (ARegion *region = sa->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
@@ -1410,7 +1411,7 @@ static void view3d_localview_exit(const Depsgraph *depsgraph,
ED_view3d_smooth_view_ex(depsgraph,
wm,
win,
- sa,
+ area,
v3d,
region,
smooth_viewtx,
@@ -1438,23 +1439,23 @@ static int localview_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
View3D *v3d = CTX_wm_view3d(C);
bool frame_selected = RNA_boolean_get(op->ptr, "frame_selected");
bool changed;
if (v3d->localvd) {
- view3d_localview_exit(depsgraph, wm, win, view_layer, sa, frame_selected, smooth_viewtx);
+ view3d_localview_exit(depsgraph, wm, win, view_layer, area, frame_selected, smooth_viewtx);
changed = true;
}
else {
changed = view3d_localview_init(
- depsgraph, wm, win, bmain, view_layer, sa, frame_selected, smooth_viewtx, op->reports);
+ depsgraph, wm, win, bmain, view_layer, area, frame_selected, smooth_viewtx, op->reports);
}
if (changed) {
DEG_id_type_tag(bmain, ID_OB);
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(area);
/* Unselected objects become selected when exiting. */
if (v3d->localvd == NULL) {
@@ -1555,19 +1556,17 @@ void VIEW3D_OT_localview_remove_from(wmOperatorType *ot)
/** \name Local Collections
* \{ */
-static uint free_localcollection_bit(Main *bmain,
- unsigned short local_collections_uuid,
- bool *r_reset)
+static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid, bool *r_reset)
{
- ScrArea *sa;
- bScreen *sc;
+ ScrArea *area;
+ bScreen *screen;
ushort local_view_bits = 0;
/* Check all areas: which localviews are in use? */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl = sa->spacedata.first;
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (area = screen->areabase.first; area; area = area->next) {
+ SpaceLink *sl = area->spacedata.first;
for (; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
@@ -1596,7 +1595,7 @@ static uint free_localcollection_bit(Main *bmain,
}
static void local_collections_reset_uuid(LayerCollection *layer_collection,
- const unsigned short local_view_bit)
+ const ushort local_view_bit)
{
if (layer_collection->flag & LAYER_COLLECTION_HIDE) {
layer_collection->local_collections_bits &= ~local_view_bit;
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index a9eaad6868e..c48c86bd423 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -110,7 +110,7 @@ void setTransformViewAspect(TransInfo *t, float r_aspect[3])
copy_v3_fl(r_aspect, 1.0f);
if (t->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = t->sa->spacedata.first;
+ SpaceImage *sima = t->area->spacedata.first;
if (t->options & CTX_MASK) {
ED_space_image_get_aspect(sima, &r_aspect[0], &r_aspect[1]);
@@ -123,7 +123,7 @@ void setTransformViewAspect(TransInfo *t, float r_aspect[3])
}
}
else if (t->spacetype == SPACE_CLIP) {
- SpaceClip *sclip = t->sa->spacedata.first;
+ SpaceClip *sclip = t->area->spacedata.first;
if (t->options & CTX_MOVIECLIP) {
ED_space_clip_get_aspect_dimension_aware(sclip, &r_aspect[0], &r_aspect[1]);
@@ -234,7 +234,7 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
}
}
else if (t->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = t->sa->spacedata.first;
+ SpaceImage *sima = t->area->spacedata.first;
if (t->options & CTX_MASK) {
float v[2];
@@ -265,7 +265,7 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
else if (t->spacetype == SPACE_ACTION) {
int out[2] = {0, 0};
#if 0
- SpaceAction *sact = t->sa->spacedata.first;
+ SpaceAction *sact = t->area->spacedata.first;
if (sact->flag & SACTION_DRAWTIME) {
//vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base));
@@ -296,7 +296,7 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
adr[1] = out[1];
}
else if (t->spacetype == SPACE_CLIP) {
- SpaceClip *sc = t->sa->spacedata.first;
+ SpaceClip *sc = t->area->spacedata.first;
if (t->options & CTX_MASK) {
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -377,7 +377,7 @@ void applyAspectRatio(TransInfo *t, float vec[2])
{
if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION) &&
!(t->options & CTX_PAINT_CURVE)) {
- SpaceImage *sima = t->sa->spacedata.first;
+ SpaceImage *sima = t->area->spacedata.first;
if ((sima->flag & SI_COORDFLOATS) == 0) {
int width, height;
@@ -401,7 +401,7 @@ void applyAspectRatio(TransInfo *t, float vec[2])
void removeAspectRatio(TransInfo *t, float vec[2])
{
if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
- SpaceImage *sima = t->sa->spacedata.first;
+ SpaceImage *sima = t->area->spacedata.first;
if ((sima->flag & SI_COORDFLOATS) == 0) {
int width, height;
@@ -453,18 +453,18 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
}
}
else if (t->spacetype == SPACE_ACTION) {
- // SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
+ // SpaceAction *saction = (SpaceAction *)t->area->spacedata.first;
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_GRAPH) {
- // SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
+ // SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_NLA) {
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_NODE) {
- // ED_area_tag_redraw(t->sa);
+ // ED_area_tag_redraw(t->area);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
}
else if (t->spacetype == SPACE_SEQ) {
@@ -483,21 +483,21 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
WM_paint_cursor_tag_redraw(window, t->region);
}
else if (t->flag & T_CURSOR) {
- ED_area_tag_redraw(t->sa);
+ ED_area_tag_redraw(t->area);
}
else {
// XXX how to deal with lock?
- SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
+ SpaceImage *sima = (SpaceImage *)t->area->spacedata.first;
if (sima->lock) {
WM_event_add_notifier(C, NC_GEOM | ND_DATA, OBEDIT_FROM_VIEW_LAYER(t->view_layer)->data);
}
else {
- ED_area_tag_redraw(t->sa);
+ ED_area_tag_redraw(t->area);
}
}
}
else if (t->spacetype == SPACE_CLIP) {
- SpaceClip *sc = (SpaceClip *)t->sa->spacedata.first;
+ SpaceClip *sc = (SpaceClip *)t->area->spacedata.first;
if (ED_space_clip_check_show_trackedit(sc)) {
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -517,7 +517,7 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
static void viewRedrawPost(bContext *C, TransInfo *t)
{
- ED_area_status_text(t->sa, NULL);
+ ED_area_status_text(t->area, NULL);
if (t->spacetype == SPACE_VIEW3D) {
/* if autokeying is enabled, send notifiers that keyframes were added */
@@ -559,7 +559,7 @@ static void viewRedrawPost(bContext *C, TransInfo *t)
/* ************************** TRANSFORMATIONS **************************** */
-static void view_editmove(unsigned short UNUSED(event))
+static void view_editmove(ushort UNUSED(event))
{
#if 0 // TRANSFORM_FIX_ME
int refresh = 0;
@@ -1160,9 +1160,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
break;
case TFM_MODAL_INSERTOFS_TOGGLE_DIR:
if (t->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first;
+ SpaceNode *snode = (SpaceNode *)t->area->spacedata.first;
- BLI_assert(t->sa->spacetype == t->spacetype);
+ BLI_assert(t->area->spacetype == t->spacetype);
if (snode->insert_ofs_dir == SNODE_INSERTOFS_DIR_RIGHT) {
snode->insert_ofs_dir = SNODE_INSERTOFS_DIR_LEFT;
@@ -1521,9 +1521,9 @@ static bool transinfo_show_overlay(const struct bContext *C, TransInfo *t, ARegi
ok = true;
}
else {
- ScrArea *sa = CTX_wm_area(C);
- if (sa->spacetype == SPACE_VIEW3D) {
- View3D *v3d = sa->spacedata.first;
+ ScrArea *area = CTX_wm_area(C);
+ if (area->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = area->spacedata.first;
if ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) {
ok = true;
}
@@ -1576,7 +1576,7 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *region)
/* warning text (to clarify meaning of overlays)
* - original color was red to match the icon, but that clashes badly with a less nasty border
*/
- unsigned char color[3];
+ uchar color[3];
UI_GetThemeColorShade3ubv(TH_TEXT_HI, -50, color);
BLF_color3ubv(font_id, color);
#ifdef WITH_INTERNATIONAL
@@ -1870,7 +1870,7 @@ static void initSnapSpatial(TransInfo *t, float r_snap[3])
RegionView3D *rv3d = t->region->regiondata;
if (rv3d) {
- View3D *v3d = t->sa->spacedata.first;
+ View3D *v3d = t->area->spacedata.first;
r_snap[0] = 0.0f;
r_snap[1] = ED_view3d_grid_view_scale(t->scene, v3d, rv3d, NULL) * 1.0f;
r_snap[2] = r_snap[1] * 0.1f;
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index a2c8caba0f5..701e068d3fa 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -581,7 +581,7 @@ typedef struct TransInfo {
void *view;
/** Only valid (non null) during an operator called function. */
struct bContext *context;
- struct ScrArea *sa;
+ struct ScrArea *area;
struct ARegion *region;
struct Depsgraph *depsgraph;
struct Scene *scene;
@@ -967,14 +967,14 @@ bool checkUseAxisMatrix(TransInfo *t);
(BLI_assert((t)->data_container_len == 1), (&(t)->data_container[0]))
#define FOREACH_TRANS_DATA_CONTAINER(t, th) \
- for (TransDataContainer *tc = t->data_container, \
- *tc_end = t->data_container + t->data_container_len; \
+ for (TransDataContainer *tc = (t)->data_container, \
+ *tc_end = (t)->data_container + (t)->data_container_len; \
th != tc_end; \
th++)
#define FOREACH_TRANS_DATA_CONTAINER_INDEX(t, th, i) \
- for (TransDataContainer *tc = ((i = 0), t->data_container), \
- *tc_end = t->data_container + t->data_container_len; \
+ for (TransDataContainer *tc = ((i = 0), (t)->data_container), \
+ *tc_end = (t)->data_container + (t)->data_container_len; \
th != tc_end; \
th++, i++)
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 4b6932d977d..cdff9fdf750 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -171,7 +171,7 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3])
static void viewAxisCorrectCenter(const TransInfo *t, float t_con_center[3])
{
if (t->spacetype == SPACE_VIEW3D) {
- // View3D *v3d = t->sa->spacedata.first;
+ // View3D *v3d = t->area->spacedata.first;
const float min_dist = 1.0f; /* v3d->clip_start; */
float dir[3];
float l;
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index 1049db74a75..1e751f67c9d 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -1026,7 +1026,7 @@ static void posttrans_fcurve_clean(FCurve *fcu,
}
else {
/* Compute the average values for each retained keyframe */
- for (tRetainedKeyframe *rk = retained_keys.first; rk; rk = rk->next) {
+ LISTBASE_FOREACH (tRetainedKeyframe *, rk, &retained_keys) {
rk->val = rk->val / (float)rk->tot_count;
}
}
@@ -1128,10 +1128,10 @@ static void posttrans_action_clean(bAnimContext *ac, bAction *act)
/* struct for use in re-sorting BezTriples during Graph Editor transform */
typedef struct BeztMap {
BezTriple *bezt;
- unsigned int oldIndex; /* index of bezt in fcu->bezt array before sorting */
- unsigned int newIndex; /* index of bezt in fcu->bezt array after sorting */
- short swapHs; /* swap order of handles (-1=clear; 0=not checked, 1=swap) */
- char pipo, cipo; /* interpolation of current and next segments */
+ uint oldIndex; /* index of bezt in fcu->bezt array before sorting */
+ uint newIndex; /* index of bezt in fcu->bezt array after sorting */
+ short swapHs; /* swap order of handles (-1=clear; 0=not checked, 1=swap) */
+ char pipo, cipo; /* interpolation of current and next segments */
} BeztMap;
/* This function converts an FCurve's BezTriple array to a BeztMap array
@@ -1309,7 +1309,7 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve
*/
void remake_graph_transdata(TransInfo *t, ListBase *anim_data)
{
- SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
+ SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
bAnimListElem *ale;
const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0;
@@ -1749,13 +1749,12 @@ bool motionpath_need_update_pose(Scene *scene, Object *ob)
static void special_aftertrans_update__movieclip(bContext *C, TransInfo *t)
{
- SpaceClip *sc = t->sa->spacedata.first;
+ SpaceClip *sc = t->area->spacedata.first;
MovieClip *clip = ED_space_clip_get_clip(sc);
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(&clip->tracking);
const int framenr = ED_space_clip_get_clip_frame_number(sc);
/* Update coordinates of modified plane tracks. */
- for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track;
- plane_track = plane_track->next) {
+ LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, plane_tracks_base) {
bool do_update = false;
if (plane_track->flag & PLANE_TRACK_HIDDEN) {
continue;
@@ -1791,11 +1790,11 @@ static void special_aftertrans_update__mask(bContext *C, TransInfo *t)
Mask *mask = NULL;
if (t->spacetype == SPACE_CLIP) {
- SpaceClip *sc = t->sa->spacedata.first;
+ SpaceClip *sc = t->area->spacedata.first;
mask = ED_space_clip_get_mask(sc);
}
else if (t->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = t->sa->spacedata.first;
+ SpaceImage *sima = t->area->spacedata.first;
mask = ED_space_image_get_mask(sima);
}
else {
@@ -1826,7 +1825,7 @@ static void special_aftertrans_update__node(bContext *C, TransInfo *t)
if (canceled && t->remove_on_cancel) {
/* remove selected nodes on cancel */
- SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first;
+ SpaceNode *snode = (SpaceNode *)t->area->spacedata.first;
bNodeTree *ntree = snode->edittree;
if (ntree) {
bNode *node, *node_next;
@@ -1949,7 +1948,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* freeSeqData in transform_conversions.c does this
* keep here so the else at the end wont run... */
- SpaceSeq *sseq = (SpaceSeq *)t->sa->spacedata.first;
+ SpaceSeq *sseq = (SpaceSeq *)t->area->spacedata.first;
/* Marker transform, not especially nice but we may want to move markers
* at the same time as strips in the Video Sequencer. */
@@ -1975,16 +1974,16 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
}
else if (t->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first;
+ SpaceNode *snode = (SpaceNode *)t->area->spacedata.first;
special_aftertrans_update__node(C, t);
if (canceled == 0) {
ED_node_post_apply_transform(C, snode->edittree);
- ED_node_link_insert(bmain, t->sa);
+ ED_node_link_insert(bmain, t->area);
}
/* clear link line */
- ED_node_link_intersect_test(t->sa, 0);
+ ED_node_link_intersect_test(t->area, 0);
}
else if (t->spacetype == SPACE_CLIP) {
if (t->options & CTX_MOVIECLIP) {
@@ -1995,7 +1994,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
}
else if (t->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)t->area->spacedata.first;
bAnimContext ac;
/* initialize relevant anim-context 'context' data */
@@ -2078,12 +2077,12 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
const int filter = ANIMFILTER_DATA_VISIBLE;
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ale->datatype == ALE_GPFRAME) {
ale->id->tag |= LIB_TAG_DOIT;
}
}
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ale->datatype == ALE_GPFRAME) {
if (ale->id->tag & LIB_TAG_DOIT) {
ale->id->tag &= ~LIB_TAG_DOIT;
@@ -2109,12 +2108,12 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
const int filter = ANIMFILTER_DATA_VISIBLE;
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ale->datatype == ALE_MASKLAY) {
ale->id->tag |= LIB_TAG_DOIT;
}
}
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ale->datatype == ALE_MASKLAY) {
if (ale->id->tag & LIB_TAG_DOIT) {
ale->id->tag &= ~LIB_TAG_DOIT;
@@ -2159,7 +2158,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
saction->flag &= ~SACTION_MOVING;
}
else if (t->spacetype == SPACE_GRAPH) {
- SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
+ SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
bAnimContext ac;
const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0;
@@ -2248,9 +2247,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
else if (t->flag & T_EDIT) {
if (t->obedit_type == OB_MESH) {
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
/* table needs to be created for each edit command, since vertices can move etc */
- ED_mesh_mirror_spatial_table(tc->obedit, em, NULL, NULL, 'e');
+ ED_mesh_mirror_spatial_table_end(tc->obedit);
/* TODO(campbell): xform: We need support for many mirror objects at once! */
break;
}
diff --git a/source/blender/editors/transform/transform_convert_armature.c b/source/blender/editors/transform/transform_convert_armature.c
index 53dd54d4b53..e52bd15b0d5 100644
--- a/source/blender/editors/transform/transform_convert_armature.c
+++ b/source/blender/editors/transform/transform_convert_armature.c
@@ -26,6 +26,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BKE_action.h"
@@ -530,8 +531,7 @@ void pose_transform_mirror_update(TransInfo *t, TransDataContainer *tc, Object *
unit_m4(flip_mtx);
flip_mtx[0][0] = -1;
- for (bPoseChannel *pchan_orig = ob->pose->chanbase.first; pchan_orig;
- pchan_orig = pchan_orig->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan_orig, &ob->pose->chanbase) {
/* Clear the MIRROR flag from previous runs. */
pchan_orig->bone->flag &= ~BONE_TRANSFORM_MIRROR;
}
@@ -654,7 +654,7 @@ void createTransPose(TransInfo *t)
if (mirror) {
int total_mirrored = 0;
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if ((pchan->bone->flag & BONE_TRANSFORM) &&
BKE_pose_channel_get_mirrored(ob->pose, pchan->name)) {
total_mirrored++;
@@ -704,7 +704,7 @@ void createTransPose(TransInfo *t)
}
if (mirror) {
- for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
if (pchan->bone->flag & BONE_TRANSFORM) {
bPoseChannel *pchan_mirror = BKE_pose_channel_get_mirrored(ob->pose, pchan->name);
if (pchan_mirror) {
@@ -726,7 +726,7 @@ void createTransPose(TransInfo *t)
/* use pose channels to fill trans data */
td = tc->data;
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (pchan->bone->flag & BONE_TRANSFORM) {
add_pose_transdata(t, pchan, ob, tc, td);
td++;
diff --git a/source/blender/editors/transform/transform_convert_cursor.c b/source/blender/editors/transform/transform_convert_cursor.c
index 621f9dd63e2..e6a972bfc7c 100644
--- a/source/blender/editors/transform/transform_convert_cursor.c
+++ b/source/blender/editors/transform/transform_convert_cursor.c
@@ -44,7 +44,7 @@
void createTransCursor_image(TransInfo *t)
{
TransData *td;
- SpaceImage *sima = t->sa->spacedata.first;
+ SpaceImage *sima = t->area->spacedata.first;
float *cursor_location = sima->cursor;
{
diff --git a/source/blender/editors/transform/transform_convert_curve.c b/source/blender/editors/transform/transform_convert_curve.c
index 24f0491c86c..908cf7707f2 100644
--- a/source/blender/editors/transform/transform_convert_curve.c
+++ b/source/blender/editors/transform/transform_convert_curve.c
@@ -25,6 +25,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BKE_context.h"
@@ -98,7 +99,7 @@ void createTransCurveVerts(TransInfo *t)
/* count total of vertices, check identical as in 2nd loop for making transdata! */
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- for (Nurb *nu = nurbs->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, nurbs) {
if (nu->type == CU_BEZIER) {
for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
if (bezt->hide == 0) {
@@ -173,7 +174,7 @@ void createTransCurveVerts(TransInfo *t)
TransData *td = tc->data;
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- for (Nurb *nu = nurbs->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, nurbs) {
if (nu->type == CU_BEZIER) {
TransData *head, *tail;
head = tail = td;
diff --git a/source/blender/editors/transform/transform_convert_graph.c b/source/blender/editors/transform/transform_convert_graph.c
index 95a385a5a50..5c2391d8dd0 100644
--- a/source/blender/editors/transform/transform_convert_graph.c
+++ b/source/blender/editors/transform/transform_convert_graph.c
@@ -167,7 +167,7 @@ static void graph_bezt_get_transform_selection(const TransInfo *t,
bool *r_key,
bool *r_right_handle)
{
- SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
+ SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
bool key = (bezt->f2 & SELECT) != 0;
bool left = use_handle ? ((bezt->f1 & SELECT) != 0) : key;
bool right = use_handle ? ((bezt->f3 & SELECT) != 0) : key;
@@ -224,7 +224,7 @@ static void graph_key_shortest_dist(
*/
void createTransGraphEditData(bContext *C, TransInfo *t)
{
- SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
+ SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
Scene *scene = t->scene;
ARegion *region = t->region;
View2D *v2d = &region->v2d;
@@ -642,7 +642,7 @@ void createTransGraphEditData(bContext *C, TransInfo *t)
*/
void flushTransGraphData(TransInfo *t)
{
- SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
+ SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
TransData *td;
TransData2D *td2d;
TransDataGraph *tdg;
diff --git a/source/blender/editors/transform/transform_convert_mask.c b/source/blender/editors/transform/transform_convert_mask.c
index 65244a09b73..6c743da3e65 100644
--- a/source/blender/editors/transform/transform_convert_mask.c
+++ b/source/blender/editors/transform/transform_convert_mask.c
@@ -280,7 +280,7 @@ void createTransMaskingData(bContext *C, TransInfo *t)
}
if (t->spacetype == SPACE_CLIP) {
- SpaceClip *sc = t->sa->spacedata.first;
+ SpaceClip *sc = t->area->spacedata.first;
MovieClip *clip = ED_space_clip_get_clip(sc);
if (!clip) {
return;
@@ -333,7 +333,7 @@ void createTransMaskingData(bContext *C, TransInfo *t)
return;
}
- ED_mask_get_aspect(t->sa, t->region, &asp[0], &asp[1]);
+ ED_mask_get_aspect(t->area, t->region, &asp[0], &asp[1]);
tc->data_len = (is_prop_edit) ? count : countsel;
td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Mask Editing)");
@@ -409,7 +409,7 @@ void flushTransMasking(TransInfo *t)
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
- ED_mask_get_aspect(t->sa, t->region, &asp[0], &asp[1]);
+ ED_mask_get_aspect(t->area, t->region, &asp[0], &asp[1]);
inv[0] = 1.0f / asp[0];
inv[1] = 1.0f / asp[1];
diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c
index 29a74be8e2b..7528f791130 100644
--- a/source/blender/editors/transform/transform_convert_mesh.c
+++ b/source/blender/editors/transform/transform_convert_mesh.c
@@ -61,8 +61,10 @@
/* when transforming islands */
struct TransIslandData {
- float co[3];
- float axismtx[3][3];
+ float (*center)[3];
+ float (*axismtx)[3][3];
+ int island_tot;
+ int *island_vert_map;
};
/* -------------------------------------------------------------------- */
@@ -247,18 +249,19 @@ static void editmesh_set_connectivity_distance(BMesh *bm,
}
}
-static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em,
- int *r_island_tot,
- int **r_island_vert_map,
- bool calc_single_islands)
+static void editmesh_islands_info_calc(BMEditMesh *em,
+ const bool calc_single_islands,
+ const bool calc_island_axismtx,
+ struct TransIslandData *r_island_data)
{
BMesh *bm = em->bm;
- struct TransIslandData *trans_islands;
char htype;
char itype;
int i;
/* group vars */
+ float(*center)[3];
+ float(*axismtx)[3][3] = NULL;
int *groups_array;
int(*group_index)[2];
int group_tot;
@@ -283,7 +286,11 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em,
itype = BM_VERTS_OF_FACE;
}
- trans_islands = MEM_mallocN(sizeof(*trans_islands) * group_tot, __func__);
+ center = MEM_mallocN(sizeof(*center) * group_tot, __func__);
+
+ if (calc_island_axismtx) {
+ axismtx = MEM_mallocN(sizeof(*axismtx) * group_tot, __func__);
+ }
vert_map = MEM_mallocN(sizeof(*vert_map) * bm->totvert, __func__);
/* we shouldn't need this, but with incorrect selection flushing
@@ -311,7 +318,7 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em,
ese.htype = htype;
- /* loop on each face in this group:
+ /* loop on each face or edge in this group:
* - assign r_vert_map
* - calculate (co, no)
*/
@@ -321,12 +328,14 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em,
ese.ele = ele_array[groups_array[fg_sta + j]];
BM_editselection_center(&ese, tmp_co);
- BM_editselection_normal(&ese, tmp_no);
- BM_editselection_plane(&ese, tmp_tangent);
-
add_v3_v3(co, tmp_co);
- add_v3_v3(no, tmp_no);
- add_v3_v3(tangent, tmp_tangent);
+
+ if (axismtx) {
+ BM_editselection_normal(&ese, tmp_no);
+ BM_editselection_plane(&ese, tmp_tangent);
+ add_v3_v3(no, tmp_no);
+ add_v3_v3(tangent, tmp_tangent);
+ }
{
/* setup vertex map */
@@ -340,18 +349,20 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em,
}
}
- mul_v3_v3fl(trans_islands[i].co, co, 1.0f / (float)fg_len);
+ mul_v3_v3fl(center[i], co, 1.0f / (float)fg_len);
- if (createSpaceNormalTangent(trans_islands[i].axismtx, no, tangent)) {
- /* pass */
- }
- else {
- if (normalize_v3(no) != 0.0f) {
- axis_dominant_v3_to_m3(trans_islands[i].axismtx, no);
- invert_m3(trans_islands[i].axismtx);
+ if (axismtx) {
+ if (createSpaceNormalTangent(axismtx[i], no, tangent)) {
+ /* pass */
}
else {
- unit_m3(trans_islands[i].axismtx);
+ if (normalize_v3(no) != 0.0f) {
+ axis_dominant_v3_to_m3(axismtx[i], no);
+ invert_m3(axismtx[i]);
+ }
+ else {
+ unit_m3(axismtx[i]);
+ }
}
}
}
@@ -372,22 +383,24 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em,
}
if (group_tot_single != 0) {
- trans_islands = MEM_reallocN(trans_islands,
- sizeof(*trans_islands) * (group_tot + group_tot_single));
+ center = MEM_reallocN(center, sizeof(*center) * (group_tot + group_tot_single));
+ if (axismtx) {
+ axismtx = MEM_reallocN(axismtx, sizeof(*axismtx) * (group_tot + group_tot_single));
+ }
BM_ITER_MESH_INDEX (v, &viter, bm, BM_VERTS_OF_MESH, i) {
if (BM_elem_flag_test(v, BM_ELEM_SELECT) && (vert_map[i] == -1)) {
- struct TransIslandData *v_island = &trans_islands[group_tot];
vert_map[i] = group_tot;
+ copy_v3_v3(center[group_tot], v->co);
- copy_v3_v3(v_island->co, v->co);
-
- if (is_zero_v3(v->no) != 0.0f) {
- axis_dominant_v3_to_m3(v_island->axismtx, v->no);
- invert_m3(v_island->axismtx);
- }
- else {
- unit_m3(v_island->axismtx);
+ if (axismtx) {
+ if (is_zero_v3(v->no) != 0.0f) {
+ axis_dominant_v3_to_m3(axismtx[group_tot], v->no);
+ invert_m3(axismtx[group_tot]);
+ }
+ else {
+ unit_m3(axismtx[group_tot]);
+ }
}
group_tot += 1;
@@ -396,10 +409,10 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em,
}
}
- *r_island_tot = group_tot;
- *r_island_vert_map = vert_map;
-
- return trans_islands;
+ r_island_data->axismtx = axismtx;
+ r_island_data->center = center;
+ r_island_data->island_tot = group_tot;
+ r_island_data->island_vert_map = vert_map;
}
static bool is_in_quadrant_v3(const float co[3], const int quadrant[3], const float epsilon)
@@ -567,7 +580,8 @@ static void VertsToTransData(TransInfo *t,
BMEditMesh *em,
BMVert *eve,
float *bweight,
- struct TransIslandData *v_island,
+ const struct TransIslandData *island_data,
+ const int island_index,
const bool no_island_center)
{
float *no, _no[3];
@@ -589,14 +603,17 @@ static void VertsToTransData(TransInfo *t,
no = eve->no;
}
- if (v_island) {
+ if (island_index != -1) {
if (no_island_center) {
copy_v3_v3(td->center, td->loc);
}
else {
- copy_v3_v3(td->center, v_island->co);
+ copy_v3_v3(td->center, island_data->center[island_index]);
}
- copy_m3_m3(td->axismtx, v_island->axismtx);
+ }
+
+ if ((island_index != -1) && island_data->axismtx) {
+ copy_m3_m3(td->axismtx, island_data->axismtx[island_index]);
}
else if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
copy_v3_v3(td->center, td->loc);
@@ -654,9 +671,7 @@ void createTransEditVerts(TransInfo *t)
const int prop_mode = (t->flag & T_PROP_EDIT) ? (t->flag & T_PROP_EDIT_ALL) : 0;
int cd_vert_bweight_offset = -1;
- struct TransIslandData *island_info = NULL;
- int island_info_tot;
- int *island_vert_map = NULL;
+ struct TransIslandData island_data = {NULL};
/* Snap rotation along normal needs a common axis for whole islands,
* otherwise one get random crazy results, see T59104.
@@ -758,8 +773,11 @@ void createTransEditVerts(TransInfo *t)
(t->around == V3D_AROUND_LOCAL_ORIGINS) &&
(em->selectmode & SCE_SELECT_VERTEX));
- island_info = editmesh_islands_info_calc(
- em, &island_info_tot, &island_vert_map, calc_single_islands);
+ /* The island axismtx is only necessary in some modes.
+ * TODO(Germano): Extend the list to exclude other modes. */
+ const bool calc_island_axismtx = !ELEM(t->mode, TFM_SHRINKFATTEN);
+
+ editmesh_islands_info_calc(em, calc_single_islands, calc_island_axismtx, &island_data);
}
/* detect CrazySpace [tm] */
@@ -809,21 +827,19 @@ void createTransEditVerts(TransInfo *t)
continue;
}
if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- struct TransIslandData *v_island = NULL;
float *bweight = (cd_vert_bweight_offset != -1) ?
BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset) :
NULL;
- if (island_info) {
+ int island_index = -1;
+ if (island_data.island_vert_map) {
const int connected_index = (dists_index && dists_index[a] != -1) ? dists_index[a] : a;
- v_island = (island_vert_map[connected_index] != -1) ?
- &island_info[island_vert_map[connected_index]] :
- NULL;
+ island_index = island_data.island_vert_map[connected_index];
}
/* Do not use the island center in case we are using islands
* only to get axis for snap/rotate to normal... */
- VertsToTransData(t, tob, tx, em, eve, bweight, v_island, is_snap_rotate);
+ VertsToTransData(t, tob, tx, em, eve, bweight, &island_data, island_index, is_snap_rotate);
if (tx) {
tx++;
}
@@ -889,9 +905,16 @@ void createTransEditVerts(TransInfo *t)
}
}
- if (island_info) {
- MEM_freeN(island_info);
- MEM_freeN(island_vert_map);
+ if (island_data.center) {
+ MEM_freeN(island_data.center);
+ }
+
+ if (island_data.axismtx) {
+ MEM_freeN(island_data.axismtx);
+ }
+
+ if (island_data.island_vert_map) {
+ MEM_freeN(island_data.island_vert_map);
}
cleanup:
@@ -1608,7 +1631,7 @@ void createTransUVs(bContext *C, TransInfo *t)
void flushTransUVs(TransInfo *t)
{
- SpaceImage *sima = t->sa->spacedata.first;
+ SpaceImage *sima = t->area->spacedata.first;
const bool use_pixel_snap = ((sima->pixel_snap_mode != SI_PIXEL_SNAP_DISABLED) &&
(t->state != TRANS_CANCEL));
diff --git a/source/blender/editors/transform/transform_convert_node.c b/source/blender/editors/transform/transform_convert_node.c
index ee4aa053444..d783bfdf40e 100644
--- a/source/blender/editors/transform/transform_convert_node.c
+++ b/source/blender/editors/transform/transform_convert_node.c
@@ -109,7 +109,7 @@ void createTransNodeData(bContext *UNUSED(C), TransInfo *t)
const float dpi_fac = UI_DPI_FAC;
TransData *td;
TransData2D *td2d;
- SpaceNode *snode = t->sa->spacedata.first;
+ SpaceNode *snode = t->area->spacedata.first;
bNode *node;
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
@@ -188,7 +188,7 @@ void flushTransNodes(TransInfo *t)
/* handle intersection with noodles */
if (tc->data_len == 1) {
- ED_node_link_intersect_test(t->sa, 1);
+ ED_node_link_intersect_test(t->area, 1);
}
}
}
diff --git a/source/blender/editors/transform/transform_convert_object.c b/source/blender/editors/transform/transform_convert_object.c
index 4973b1cb268..9b76db7f265 100644
--- a/source/blender/editors/transform/transform_convert_object.c
+++ b/source/blender/editors/transform/transform_convert_object.c
@@ -290,7 +290,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
static void trans_object_base_deps_flag_prepare(ViewLayer *view_layer)
{
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
base->object->id.tag &= ~LIB_TAG_DOIT;
}
}
@@ -324,7 +324,7 @@ static void trans_object_base_deps_flag_finish(const TransInfo *t, ViewLayer *vi
{
if ((t->options & CTX_OBMODE_XFORM_OBDATA) == 0) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object->id.tag & LIB_TAG_DOIT) {
base->flag_legacy |= BA_SNAP_FIX_DEPS_FIASCO;
}
@@ -355,7 +355,7 @@ static void set_trans_object_base_flags(TransInfo *t)
/* Clear all flags we need. It will be used to detect dependencies. */
trans_object_base_deps_flag_prepare(view_layer);
/* Traverse all bases and set all possible flags. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
base->flag_legacy &= ~(BA_WAS_SEL | BA_TRANSFORM_LOCKED_IN_PLACE);
if (BASE_SELECTED_EDITABLE(v3d, base)) {
Object *ob = base->object;
@@ -422,7 +422,7 @@ static int count_proportional_objects(TransInfo *t)
if (!((t->around == V3D_AROUND_LOCAL_ORIGINS) &&
(t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL))) {
/* Mark all parents. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (BASE_SELECTED_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base)) {
Object *parent = base->object->parent;
/* flag all parents */
@@ -433,7 +433,7 @@ static int count_proportional_objects(TransInfo *t)
}
}
/* Mark all children. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
/* all base not already selected or marked that is editable */
if ((base->object->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
(base->flag & BASE_SELECTED) == 0 &&
@@ -443,7 +443,7 @@ static int count_proportional_objects(TransInfo *t)
}
}
/* Flush changed flags to all dependencies. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
/* If base is not selected, not a parent of selection or not a child of
* selection and it is editable and selectable.
@@ -592,7 +592,7 @@ void createTransObject(bContext *C, TransInfo *t)
ViewLayer *view_layer = t->view_layer;
View3D *v3d = t->view;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
/* if base is not selected, not a parent of selection
@@ -639,7 +639,7 @@ void createTransObject(bContext *C, TransInfo *t)
ViewLayer *view_layer = t->view_layer;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if (ob->parent != NULL) {
if (ob->parent && !BLI_gset_haskey(objects_in_transdata, ob->parent) &&
@@ -669,7 +669,7 @@ void createTransObject(bContext *C, TransInfo *t)
}
}
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if (BASE_XFORM_INDIRECT(base) || BLI_gset_haskey(objects_in_transdata, ob)) {
diff --git a/source/blender/editors/transform/transform_convert_sequencer.c b/source/blender/editors/transform/transform_convert_sequencer.c
index f2d0f4dfc43..a722f17db22 100644
--- a/source/blender/editors/transform/transform_convert_sequencer.c
+++ b/source/blender/editors/transform/transform_convert_sequencer.c
@@ -379,7 +379,7 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
}
if (overlap) {
- const bool use_sync_markers = (((SpaceSeq *)t->sa->spacedata.first)->flag &
+ const bool use_sync_markers = (((SpaceSeq *)t->area->spacedata.first)->flag &
SEQ_MARKER_TRANS) != 0;
ListBase *markers = &t->scene->markers;
diff --git a/source/blender/editors/transform/transform_convert_tracking.c b/source/blender/editors/transform/transform_convert_tracking.c
index a8bde661342..6704567a76b 100644
--- a/source/blender/editors/transform/transform_convert_tracking.c
+++ b/source/blender/editors/transform/transform_convert_tracking.c
@@ -549,7 +549,7 @@ void createTransTrackingData(bContext *C, TransInfo *t)
void cancelTransTracking(TransInfo *t)
{
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
- SpaceClip *sc = t->sa->spacedata.first;
+ SpaceClip *sc = t->area->spacedata.first;
int i, framenr = ED_space_clip_get_clip_frame_number(sc);
TransDataTracking *tdt_array = tc->custom.type.data;
diff --git a/source/blender/editors/transform/transform_draw_cursors.c b/source/blender/editors/transform/transform_draw_cursors.c
index f3105c8eb36..95ca5ae0c30 100644
--- a/source/blender/editors/transform/transform_draw_cursors.c
+++ b/source/blender/editors/transform/transform_draw_cursors.c
@@ -313,7 +313,7 @@ void transform_draw_cursor_draw(bContext *UNUSED(C), int x, int y, void *customd
break;
}
case HLP_TRACKBALL: {
- unsigned char col[3], col2[3];
+ uchar col[3], col2[3];
UI_GetThemeColor3ubv(TH_GRID, col);
GPU_matrix_translate_3fv(mval);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 7a787b77a62..05318a5c1d3 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -64,7 +64,7 @@
#include "BIK_api.h"
#include "BKE_action.h"
-#include "BKE_animsys.h"
+#include "BKE_anim_data.h"
#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_curve.h"
@@ -337,7 +337,7 @@ static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer)
static bool fcu_test_selected(FCurve *fcu)
{
BezTriple *bezt = fcu->bezt;
- unsigned int i;
+ uint i;
if (bezt == NULL) { /* ignore baked */
return 0;
@@ -356,7 +356,7 @@ static bool fcu_test_selected(FCurve *fcu)
static void recalcData_actedit(TransInfo *t)
{
ViewLayer *view_layer = t->view_layer;
- SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)t->area->spacedata.first;
bAnimContext ac = {NULL};
ListBase anim_data = {NULL, NULL};
@@ -369,10 +369,10 @@ static void recalcData_actedit(TransInfo *t)
ac.scene = t->scene;
ac.view_layer = t->view_layer;
ac.obact = OBACT(view_layer);
- ac.sa = t->sa;
+ ac.area = t->area;
ac.region = t->region;
- ac.sl = (t->sa) ? t->sa->spacedata.first : NULL;
- ac.spacetype = (t->sa) ? t->sa->spacetype : 0;
+ ac.sl = (t->area) ? t->area->spacedata.first : NULL;
+ ac.spacetype = (t->area) ? t->area->spacetype : 0;
ac.regiontype = (t->region) ? t->region->regiontype : 0;
ANIM_animdata_context_getdata(&ac);
@@ -406,7 +406,7 @@ static void recalcData_actedit(TransInfo *t)
/* helper for recalcData() - for Graph Editor transforms */
static void recalcData_graphedit(TransInfo *t)
{
- SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
+ SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
ViewLayer *view_layer = t->view_layer;
ListBase anim_data = {NULL, NULL};
@@ -422,10 +422,10 @@ static void recalcData_graphedit(TransInfo *t)
ac.scene = t->scene;
ac.view_layer = t->view_layer;
ac.obact = OBACT(view_layer);
- ac.sa = t->sa;
+ ac.area = t->area;
ac.region = t->region;
- ac.sl = (t->sa) ? t->sa->spacedata.first : NULL;
- ac.spacetype = (t->sa) ? t->sa->spacetype : 0;
+ ac.sl = (t->area) ? t->area->spacedata.first : NULL;
+ ac.spacetype = (t->area) ? t->area->spacetype : 0;
ac.regiontype = (t->region) ? t->region->regiontype : 0;
ANIM_animdata_context_getdata(&ac);
@@ -474,7 +474,7 @@ static void recalcData_graphedit(TransInfo *t)
/* helper for recalcData() - for NLA Editor transforms */
static void recalcData_nla(TransInfo *t)
{
- SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first;
+ SpaceNla *snla = (SpaceNla *)t->area->spacedata.first;
Scene *scene = t->scene;
double secf = FPS;
int i;
@@ -718,7 +718,7 @@ static void recalcData_image(TransInfo *t)
flushTransPaintCurve(t);
}
else if ((t->flag & T_EDIT) && t->obedit_type == OB_MESH) {
- SpaceImage *sima = t->sa->spacedata.first;
+ SpaceImage *sima = t->area->spacedata.first;
flushTransUVs(t);
if (sima->flag & SI_LIVE_UNWRAP) {
@@ -736,7 +736,7 @@ static void recalcData_image(TransInfo *t)
/* helper for recalcData() - for Movie Clip transforms */
static void recalcData_spaceclip(TransInfo *t)
{
- SpaceClip *sc = t->sa->spacedata.first;
+ SpaceClip *sc = t->area->spacedata.first;
if (ED_space_clip_check_show_trackedit(sc)) {
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -1222,7 +1222,7 @@ void recalcData(TransInfo *t)
void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options)
{
float v1[3], v2[3], v3[3];
- unsigned char col[3], col2[3];
+ uchar col[3], col2[3];
if (t->spacetype == SPACE_VIEW3D) {
View3D *v3d = t->view;
@@ -1375,7 +1375,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT;
ToolSettings *ts = CTX_data_tool_settings(C);
ARegion *region = CTX_wm_region(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
bGPdata *gpd = CTX_data_gpencil_data(C);
PropertyRNA *prop;
@@ -1383,7 +1383,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->depsgraph = CTX_data_depsgraph_pointer(C);
t->scene = sce;
t->view_layer = view_layer;
- t->sa = sa;
+ t->area = area;
t->region = region;
t->settings = ts;
t->reports = op ? op->reports : NULL;
@@ -1465,17 +1465,17 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
/* Assign the space type, some exceptions for running in different mode */
- if (sa == NULL) {
+ if (area == NULL) {
/* background mode */
t->spacetype = SPACE_EMPTY;
}
- else if ((region == NULL) && (sa->spacetype == SPACE_VIEW3D)) {
+ else if ((region == NULL) && (area->spacetype == SPACE_VIEW3D)) {
/* running in the text editor */
t->spacetype = SPACE_EMPTY;
}
else {
/* normal operation */
- t->spacetype = sa->spacetype;
+ t->spacetype = area->spacetype;
}
/* handle T_ALT_TRANSFORM initialization, we may use for different operators */
@@ -1491,7 +1491,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
if (t->spacetype == SPACE_VIEW3D) {
- View3D *v3d = sa->spacedata.first;
+ View3D *v3d = area->spacedata.first;
bScreen *animscreen = ED_screen_animation_playing(CTX_wm_manager(C));
t->view = v3d;
@@ -1564,7 +1564,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
else if (t->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
// XXX for now, get View2D from the active region
t->view = &region->v2d;
t->around = sima->around;
@@ -1589,12 +1589,12 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->around = V3D_AROUND_CENTER_BOUNDS;
}
else if (t->spacetype == SPACE_GRAPH) {
- SpaceGraph *sipo = sa->spacedata.first;
+ SpaceGraph *sipo = area->spacedata.first;
t->view = &region->v2d;
t->around = sipo->around;
}
else if (t->spacetype == SPACE_CLIP) {
- SpaceClip *sclip = sa->spacedata.first;
+ SpaceClip *sclip = area->spacedata.first;
t->view = &region->v2d;
t->around = sclip->around;
@@ -1876,14 +1876,14 @@ void postTrans(bContext *C, TransInfo *t)
/* pass */
}
else {
- SpaceImage *sima = t->sa->spacedata.first;
+ SpaceImage *sima = t->area->spacedata.first;
if (sima->flag & SI_LIVE_UNWRAP) {
ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL);
}
}
}
else if (t->spacetype == SPACE_VIEW3D) {
- View3D *v3d = t->sa->spacedata.first;
+ View3D *v3d = t->area->spacedata.first;
/* restore gizmo */
if (t->flag & T_MODAL) {
v3d->gizmo_flag = t->gizmo_flag;
@@ -2023,11 +2023,11 @@ void calculateCenterCursor2D(TransInfo *t, float r_center[2])
const float *cursor = NULL;
if (t->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
+ SpaceImage *sima = (SpaceImage *)t->area->spacedata.first;
cursor = sima->cursor;
}
else if (t->spacetype == SPACE_CLIP) {
- SpaceClip *space_clip = (SpaceClip *)t->sa->spacedata.first;
+ SpaceClip *space_clip = (SpaceClip *)t->area->spacedata.first;
cursor = space_clip->cursor;
}
@@ -2036,11 +2036,11 @@ void calculateCenterCursor2D(TransInfo *t, float r_center[2])
float co[2];
if (t->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
+ SpaceImage *sima = (SpaceImage *)t->area->spacedata.first;
BKE_mask_coord_from_image(sima->image, &sima->iuser, co, cursor);
}
else if (t->spacetype == SPACE_CLIP) {
- SpaceClip *space_clip = (SpaceClip *)t->sa->spacedata.first;
+ SpaceClip *space_clip = (SpaceClip *)t->area->spacedata.first;
BKE_mask_coord_from_movieclip(space_clip->clip, &space_clip->user, co, cursor);
}
else {
@@ -2065,7 +2065,7 @@ void calculateCenterCursor2D(TransInfo *t, float r_center[2])
void calculateCenterCursorGraph2D(TransInfo *t, float r_center[2])
{
- SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
+ SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
Scene *scene = t->scene;
/* cursor is combination of current frame, and graph-editor cursor value */
diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c
index e85b9f0bee1..50317d8b395 100644
--- a/source/blender/editors/transform/transform_gizmo_2d.c
+++ b/source/blender/editors/transform/transform_gizmo_2d.c
@@ -68,10 +68,10 @@ static bool gizmo2d_generic_poll(const bContext *C, wmGizmoGroupType *gzgt)
return false;
}
- ScrArea *sa = CTX_wm_area(C);
- switch (sa->spacetype) {
+ ScrArea *area = CTX_wm_area(C);
+ switch (area->spacetype) {
case SPACE_IMAGE: {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
Object *obedit = CTX_data_edit_object(C);
if (!ED_space_image_show_uvedit(sima, obedit)) {
return false;
@@ -86,7 +86,7 @@ static void gizmo2d_pivot_point_message_subscribe(struct wmGizmoGroup *gzgroup,
struct wmMsgBus *mbus,
/* Additional args. */
bScreen *screen,
- ScrArea *sa,
+ ScrArea *area,
ARegion *region)
{
wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = {
@@ -95,9 +95,9 @@ static void gizmo2d_pivot_point_message_subscribe(struct wmGizmoGroup *gzgroup,
.notify = WM_gizmo_do_msg_notify_tag_refresh,
};
- switch (sa->spacetype) {
+ switch (area->spacetype) {
case SPACE_IMAGE: {
- SpaceImage *sima = sa->spacedata.first;
+ SpaceImage *sima = area->spacedata.first;
PointerRNA ptr;
RNA_pointer_create(&screen->id, &RNA_SpaceImageEditor, sima, &ptr);
{
@@ -214,10 +214,10 @@ static bool gizmo2d_calc_bounds(const bContext *C, float *r_center, float *r_min
r_max = max_buf;
}
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
bool changed = false;
- if (sa->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = sa->spacedata.first;
+ if (area->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = area->spacedata.first;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Image *ima = ED_space_image(sima);
@@ -241,11 +241,11 @@ static bool gizmo2d_calc_bounds(const bContext *C, float *r_center, float *r_min
static bool gizmo2d_calc_center(const bContext *C, float r_center[2])
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
bool has_select = false;
zero_v2(r_center);
- if (sa->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = sa->spacedata.first;
+ if (area->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = area->spacedata.first;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ED_uvedit_center_from_pivot_ex(sima, scene, view_layer, r_center, sima->around, &has_select);
@@ -509,9 +509,9 @@ static void gizmo2d_xform_no_cage_message_subscribe(const struct bContext *C,
struct wmMsgBus *mbus)
{
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- gizmo2d_pivot_point_message_subscribe(gzgroup, mbus, screen, sa, region);
+ gizmo2d_pivot_point_message_subscribe(gzgroup, mbus, screen, area, region);
}
void ED_widgetgroup_gizmo2d_xform_callbacks_set(wmGizmoGroupType *gzgt)
@@ -671,9 +671,9 @@ static void gizmo2d_resize_message_subscribe(const struct bContext *C,
struct wmMsgBus *mbus)
{
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- gizmo2d_pivot_point_message_subscribe(gzgroup, mbus, screen, sa, region);
+ gizmo2d_pivot_point_message_subscribe(gzgroup, mbus, screen, area, region);
}
void ED_widgetgroup_gizmo2d_resize_callbacks_set(wmGizmoGroupType *gzgt)
@@ -791,9 +791,9 @@ static void gizmo2d_rotate_message_subscribe(const struct bContext *C,
struct wmMsgBus *mbus)
{
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- gizmo2d_pivot_point_message_subscribe(gzgroup, mbus, screen, sa, region);
+ gizmo2d_pivot_point_message_subscribe(gzgroup, mbus, screen, area, region);
}
void ED_widgetgroup_gizmo2d_rotate_callbacks_set(wmGizmoGroupType *gzgt)
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index de7b2ec02de..aa298b04d1a 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -734,14 +734,14 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
const struct TransformCalcParams *params,
struct TransformBounds *tbounds)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
/* TODO(sergey): This function is used from operator's modal() and from gizmo's refresh().
* Is it fine to possibly evaluate dependency graph here? */
Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- View3D *v3d = sa->spacedata.first;
+ View3D *v3d = area->spacedata.first;
Object *obedit = CTX_data_edit_object(C);
RegionView3D *rv3d = region->regiondata;
Base *base;
@@ -800,7 +800,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
/* calculate difference matrix */
BKE_gpencil_parent_matrix_get(depsgraph, ob, gpl, diff_mat);
- for (bGPDstroke *gps = gpl->actframe->strokes.first; gps; gps = gps->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpl->actframe->strokes) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
@@ -883,7 +883,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
if (use_mat_local) {
mul_m4_m4m4(mat_local, obedit->imat, ob_iter->obmat);
}
- for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) {
+ LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) {
if (EBONE_VISIBLE(arm, ebo)) {
if (ebo->flag & BONE_TIPSEL) {
calc_tw_center_with_matrix(tbounds, ebo->tail, use_mat_local, mat_local);
@@ -977,7 +977,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
mul_m4_m4m4(mat_local, obedit->imat, ob_iter->obmat);
}
- for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
if (ml->flag & SELECT) {
calc_tw_center_with_matrix(tbounds, &ml->x, use_mat_local, mat_local);
totsel++;
@@ -1244,7 +1244,7 @@ static void gizmo_xform_message_subscribe(wmGizmoGroup *gzgroup,
struct wmMsgBus *mbus,
Scene *scene,
bScreen *screen,
- ScrArea *sa,
+ ScrArea *area,
ARegion *region,
const void *type_fn)
{
@@ -1334,7 +1334,7 @@ static void gizmo_xform_message_subscribe(wmGizmoGroup *gzgroup,
}
PointerRNA view3d_ptr;
- RNA_pointer_create(&screen->id, &RNA_SpaceView3D, sa->spacedata.first, &view3d_ptr);
+ RNA_pointer_create(&screen->id, &RNA_SpaceView3D, area->spacedata.first, &view3d_ptr);
if (type_fn == VIEW3D_GGT_xform_gizmo) {
GizmoGroup *ggd = gzgroup->customdata;
@@ -1701,8 +1701,8 @@ static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *gzgroup)
gzgroup->customdata = ggd;
{
- ScrArea *sa = CTX_wm_area(C);
- const bToolRef *tref = sa->runtime.tool;
+ ScrArea *area = CTX_wm_area(C);
+ const bToolRef *tref = area->runtime.tool;
ggd->twtype = 0;
if (tref && STREQ(tref->idname, "builtin.move")) {
@@ -1737,8 +1737,8 @@ static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
GizmoGroup *ggd = gzgroup->customdata;
Scene *scene = CTX_data_scene(C);
- ScrArea *sa = CTX_wm_area(C);
- View3D *v3d = sa->spacedata.first;
+ ScrArea *area = CTX_wm_area(C);
+ View3D *v3d = area->spacedata.first;
ARegion *region = CTX_wm_region(C);
RegionView3D *rv3d = region->regiondata;
struct TransformBounds tbounds;
@@ -1844,17 +1844,18 @@ static void WIDGETGROUP_gizmo_message_subscribe(const bContext *C,
{
Scene *scene = CTX_data_scene(C);
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, region, VIEW3D_GGT_xform_gizmo);
+ gizmo_xform_message_subscribe(
+ gzgroup, mbus, scene, screen, area, region, VIEW3D_GGT_xform_gizmo);
}
static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
{
GizmoGroup *ggd = gzgroup->customdata;
- // ScrArea *sa = CTX_wm_area(C);
+ // ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- // View3D *v3d = sa->spacedata.first;
+ // View3D *v3d = area->spacedata.first;
RegionView3D *rv3d = region->regiondata;
float viewinv_m3[3][3];
copy_m3_m4(viewinv_m3, rv3d->viewinv);
@@ -1997,13 +1998,13 @@ static bool WIDGETGROUP_gizmo_poll_generic(View3D *v3d)
static bool WIDGETGROUP_gizmo_poll_context(const struct bContext *C,
struct wmGizmoGroupType *UNUSED(gzgt))
{
- ScrArea *sa = CTX_wm_area(C);
- View3D *v3d = sa->spacedata.first;
+ ScrArea *area = CTX_wm_area(C);
+ View3D *v3d = area->spacedata.first;
if (!WIDGETGROUP_gizmo_poll_generic(v3d)) {
return false;
}
- const bToolRef *tref = sa->runtime.tool;
+ const bToolRef *tref = area->runtime.tool;
if (v3d->gizmo_flag & V3D_GIZMO_HIDE_CONTEXT) {
return false;
}
@@ -2025,8 +2026,8 @@ static bool WIDGETGROUP_gizmo_poll_tool(const struct bContext *C, struct wmGizmo
return false;
}
- ScrArea *sa = CTX_wm_area(C);
- View3D *v3d = sa->spacedata.first;
+ ScrArea *area = CTX_wm_area(C);
+ View3D *v3d = area->spacedata.first;
if (!WIDGETGROUP_gizmo_poll_generic(v3d)) {
return false;
}
@@ -2247,9 +2248,9 @@ static void WIDGETGROUP_xform_cage_message_subscribe(const bContext *C,
{
Scene *scene = CTX_data_scene(C);
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, region, VIEW3D_GGT_xform_cage);
+ gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, area, region, VIEW3D_GGT_xform_cage);
}
static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
@@ -2460,9 +2461,10 @@ static void WIDGETGROUP_xform_shear_message_subscribe(const bContext *C,
{
Scene *scene = CTX_data_scene(C);
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, region, VIEW3D_GGT_xform_shear);
+ gizmo_xform_message_subscribe(
+ gzgroup, mbus, scene, screen, area, region, VIEW3D_GGT_xform_shear);
}
static void WIDGETGROUP_xform_shear_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
diff --git a/source/blender/editors/transform/transform_mode.c b/source/blender/editors/transform/transform_mode.c
index 31aae4f5b05..a2b3a891031 100644
--- a/source/blender/editors/transform/transform_mode.c
+++ b/source/blender/editors/transform/transform_mode.c
@@ -1028,21 +1028,21 @@ short getAnimEdit_SnapMode(TransInfo *t)
short autosnap = SACTSNAP_OFF;
if (t->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)t->area->spacedata.first;
if (saction) {
autosnap = saction->autosnap;
}
}
else if (t->spacetype == SPACE_GRAPH) {
- SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
+ SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
if (sipo) {
autosnap = sipo->autosnap;
}
}
else if (t->spacetype == SPACE_NLA) {
- SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first;
+ SpaceNla *snla = (SpaceNla *)t->area->spacedata.first;
if (snla) {
autosnap = snla->autosnap;
diff --git a/source/blender/editors/transform/transform_mode_align.c b/source/blender/editors/transform/transform_mode_align.c
index fbd5e87f034..9bce793809b 100644
--- a/source/blender/editors/transform/transform_mode_align.c
+++ b/source/blender/editors/transform/transform_mode_align.c
@@ -82,7 +82,7 @@ static void applyAlign(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, TIP_("Align"));
+ ED_area_status_text(t->area, TIP_("Align"));
}
void initAlign(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_baketime.c b/source/blender/editors/transform/transform_mode_baketime.c
index 0feaa27d4ce..bb8fd0df13d 100644
--- a/source/blender/editors/transform/transform_mode_baketime.c
+++ b/source/blender/editors/transform/transform_mode_baketime.c
@@ -119,7 +119,7 @@ static void applyBakeTime(TransInfo *t, const int mval[2])
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initBakeTime(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_bbone_resize.c b/source/blender/editors/transform/transform_mode_bbone_resize.c
index 1a32a550cb0..c81049ac379 100644
--- a/source/blender/editors/transform/transform_mode_bbone_resize.c
+++ b/source/blender/editors/transform/transform_mode_bbone_resize.c
@@ -155,7 +155,7 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initBoneSize(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_bend.c b/source/blender/editors/transform/transform_mode_bend.c
index bf80673fbb4..721d226050a 100644
--- a/source/blender/editors/transform/transform_mode_bend.c
+++ b/source/blender/editors/transform/transform_mode_bend.c
@@ -246,7 +246,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initBend(TransInfo *t)
@@ -289,7 +289,8 @@ void initBend(TransInfo *t)
curs = t->scene->cursor.location;
copy_v3_v3(data->warp_sta, curs);
- ED_view3d_win_to_3d((View3D *)t->sa->spacedata.first, t->region, curs, mval_fl, data->warp_end);
+ ED_view3d_win_to_3d(
+ (View3D *)t->area->spacedata.first, t->region, curs, mval_fl, data->warp_end);
copy_v3_v3(data->warp_nor, t->viewinv[2]);
normalize_v3(data->warp_nor);
diff --git a/source/blender/editors/transform/transform_mode_boneenvelope.c b/source/blender/editors/transform/transform_mode_boneenvelope.c
index 0886d4e01ef..aa20a5ade95 100644
--- a/source/blender/editors/transform/transform_mode_boneenvelope.c
+++ b/source/blender/editors/transform/transform_mode_boneenvelope.c
@@ -95,7 +95,7 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initBoneEnvelope(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_boneroll.c b/source/blender/editors/transform/transform_mode_boneroll.c
index 8e9d680f269..0564a946148 100644
--- a/source/blender/editors/transform/transform_mode_boneroll.c
+++ b/source/blender/editors/transform/transform_mode_boneroll.c
@@ -89,7 +89,7 @@ static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initBoneRoll(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
index 6ccb0e757c3..057f13ac068 100644
--- a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
+++ b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
@@ -94,7 +94,7 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initCurveShrinkFatten(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_edge_bevelweight.c b/source/blender/editors/transform/transform_mode_edge_bevelweight.c
index 15a9e7384b1..5db7895232c 100644
--- a/source/blender/editors/transform/transform_mode_edge_bevelweight.c
+++ b/source/blender/editors/transform/transform_mode_edge_bevelweight.c
@@ -105,7 +105,7 @@ static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initBevelWeight(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_edge_crease.c b/source/blender/editors/transform/transform_mode_edge_crease.c
index 8865721bc7e..4a92a57fef6 100644
--- a/source/blender/editors/transform/transform_mode_edge_crease.c
+++ b/source/blender/editors/transform/transform_mode_edge_crease.c
@@ -109,7 +109,7 @@ static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initCrease(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_edge_rotate_normal.c b/source/blender/editors/transform/transform_mode_edge_rotate_normal.c
index 69cd909cff9..18149a09f20 100644
--- a/source/blender/editors/transform/transform_mode_edge_rotate_normal.c
+++ b/source/blender/editors/transform/transform_mode_edge_rotate_normal.c
@@ -121,7 +121,7 @@ static void applyNormalRotation(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initNormalRotation(TransInfo *t)
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 e23e5c188c8..ee91459dcdd 100644
--- a/source/blender/editors/transform/transform_mode_edge_seq_slide.c
+++ b/source/blender/editors/transform/transform_mode_edge_seq_slide.c
@@ -120,7 +120,7 @@ static void applySeqSlide(TransInfo *t, const int mval[2])
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initSeqSlide(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c b/source/blender/editors/transform/transform_mode_edge_slide.c
index b54e6afc9a1..5613a782529 100644
--- a/source/blender/editors/transform/transform_mode_edge_slide.c
+++ b/source/blender/editors/transform/transform_mode_edge_slide.c
@@ -334,7 +334,7 @@ static void calcEdgeSlide_mval_range(TransInfo *t,
if (t->spacetype == SPACE_VIEW3D) {
/* background mode support */
- v3d = t->sa ? t->sa->spacedata.first : NULL;
+ v3d = t->area ? t->area->spacedata.first : NULL;
rv3d = t->region ? t->region->regiondata : NULL;
}
@@ -858,7 +858,7 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t
/* use for visibility checks */
if (t->spacetype == SPACE_VIEW3D) {
- v3d = t->sa ? t->sa->spacedata.first : NULL;
+ v3d = t->area ? t->area->spacedata.first : NULL;
rv3d = t->region ? t->region->regiondata : NULL;
use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE &&
!XRAY_ENABLED(v3d));
@@ -899,7 +899,7 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *t
if (t->spacetype == SPACE_VIEW3D) {
/* background mode support */
- v3d = t->sa ? t->sa->spacedata.first : NULL;
+ v3d = t->area ? t->area->spacedata.first : NULL;
rv3d = t->region ? t->region->regiondata : NULL;
}
@@ -1043,7 +1043,7 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *t
/* use for visibility checks */
if (t->spacetype == SPACE_VIEW3D) {
- v3d = t->sa ? t->sa->spacedata.first : NULL;
+ v3d = t->area ? t->area->spacedata.first : NULL;
rv3d = t->region ? t->region->regiondata : NULL;
use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE &&
!XRAY_ENABLED(v3d));
@@ -1417,7 +1417,7 @@ static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initEdgeSlide_ex(
diff --git a/source/blender/editors/transform/transform_mode_gpopacity.c b/source/blender/editors/transform/transform_mode_gpopacity.c
index 460e2b41da8..267d297a31c 100644
--- a/source/blender/editors/transform/transform_mode_gpopacity.c
+++ b/source/blender/editors/transform/transform_mode_gpopacity.c
@@ -90,7 +90,7 @@ static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2]))
}
}
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initGPOpacity(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_gpshrinkfatten.c b/source/blender/editors/transform/transform_mode_gpshrinkfatten.c
index edb353b343d..7c49d107703 100644
--- a/source/blender/editors/transform/transform_mode_gpshrinkfatten.c
+++ b/source/blender/editors/transform/transform_mode_gpshrinkfatten.c
@@ -92,7 +92,7 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
}
}
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initGPShrinkFatten(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_maskshrinkfatten.c b/source/blender/editors/transform/transform_mode_maskshrinkfatten.c
index b6719067f5b..e42439920db 100644
--- a/source/blender/editors/transform/transform_mode_maskshrinkfatten.c
+++ b/source/blender/editors/transform/transform_mode_maskshrinkfatten.c
@@ -124,7 +124,7 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initMaskShrinkFatten(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_mirror.c b/source/blender/editors/transform/transform_mode_mirror.c
index 2f305989f82..dae17374481 100644
--- a/source/blender/editors/transform/transform_mode_mirror.c
+++ b/source/blender/editors/transform/transform_mode_mirror.c
@@ -83,7 +83,7 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
else {
size[0] = size[1] = size[2] = 1;
@@ -108,10 +108,10 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
if (t->flag & T_2D_EDIT) {
- ED_area_status_text(t->sa, TIP_("Select a mirror axis (X, Y)"));
+ ED_area_status_text(t->area, TIP_("Select a mirror axis (X, Y)"));
}
else {
- ED_area_status_text(t->sa, TIP_("Select a mirror axis (X, Y, Z)"));
+ ED_area_status_text(t->area, TIP_("Select a mirror axis (X, Y, Z)"));
}
}
}
diff --git a/source/blender/editors/transform/transform_mode_push_pull.c b/source/blender/editors/transform/transform_mode_push_pull.c
index 890fc820cd5..6eb038ea9b0 100644
--- a/source/blender/editors/transform/transform_mode_push_pull.c
+++ b/source/blender/editors/transform/transform_mode_push_pull.c
@@ -114,7 +114,7 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initPushPull(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_resize.c b/source/blender/editors/transform/transform_mode_resize.c
index 59f2ab5c294..00644b9bfdc 100644
--- a/source/blender/editors/transform/transform_mode_resize.c
+++ b/source/blender/editors/transform/transform_mode_resize.c
@@ -131,7 +131,7 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initResize(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_rotate.c b/source/blender/editors/transform/transform_mode_rotate.c
index bea039194d0..6c2b3dc77d2 100644
--- a/source/blender/editors/transform/transform_mode_rotate.c
+++ b/source/blender/editors/transform/transform_mode_rotate.c
@@ -169,7 +169,7 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initRotation(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_shear.c b/source/blender/editors/transform/transform_mode_shear.c
index 8b7dc12f41b..ba79f5f3c7b 100644
--- a/source/blender/editors/transform/transform_mode_shear.c
+++ b/source/blender/editors/transform/transform_mode_shear.c
@@ -217,7 +217,7 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initShear(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_shrink_fatten.c b/source/blender/editors/transform/transform_mode_shrink_fatten.c
index e24e63f445c..ed082e86b6d 100644
--- a/source/blender/editors/transform/transform_mode_shrink_fatten.c
+++ b/source/blender/editors/transform/transform_mode_shrink_fatten.c
@@ -115,7 +115,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initShrinkFatten(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_skin_resize.c b/source/blender/editors/transform/transform_mode_skin_resize.c
index 23ba9a07f3e..b53dbb55c62 100644
--- a/source/blender/editors/transform/transform_mode_skin_resize.c
+++ b/source/blender/editors/transform/transform_mode_skin_resize.c
@@ -102,7 +102,7 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initSkinResize(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_tilt.c b/source/blender/editors/transform/transform_mode_tilt.c
index 9ae0cfdf805..2f56f4bd162 100644
--- a/source/blender/editors/transform/transform_mode_tilt.c
+++ b/source/blender/editors/transform/transform_mode_tilt.c
@@ -93,7 +93,7 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initTilt(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_timescale.c b/source/blender/editors/transform/transform_mode_timescale.c
index b75ef4da0f2..ce46cc36276 100644
--- a/source/blender/editors/transform/transform_mode_timescale.c
+++ b/source/blender/editors/transform/transform_mode_timescale.c
@@ -109,7 +109,7 @@ static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initTimeScale(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_timeslide.c b/source/blender/editors/transform/transform_mode_timeslide.c
index fce526873f1..43e14a26930 100644
--- a/source/blender/editors/transform/transform_mode_timeslide.c
+++ b/source/blender/editors/transform/transform_mode_timeslide.c
@@ -82,7 +82,7 @@ static void applyTimeSlideValue(TransInfo *t, float sval, float cval)
/* set value for drawing black line */
if (t->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)t->area->spacedata.first;
saction->timeslide = cval;
}
@@ -160,14 +160,14 @@ static void applyTimeSlide(TransInfo *t, const int mval[2])
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initTimeSlide(TransInfo *t)
{
/* this tool is only really available in the Action Editor... */
if (t->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)t->area->spacedata.first;
/* set flag for drawing stuff */
saction->flag |= SACTION_MOVING;
diff --git a/source/blender/editors/transform/transform_mode_timetranslate.c b/source/blender/editors/transform/transform_mode_timetranslate.c
index 494609cafb0..c514df497bc 100644
--- a/source/blender/editors/transform/transform_mode_timetranslate.c
+++ b/source/blender/editors/transform/transform_mode_timetranslate.c
@@ -136,7 +136,7 @@ static void applyTimeTranslate(TransInfo *t, const int mval[2])
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initTimeTranslate(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_tosphere.c b/source/blender/editors/transform/transform_mode_tosphere.c
index 5a3b138823c..841ccf41365 100644
--- a/source/blender/editors/transform/transform_mode_tosphere.c
+++ b/source/blender/editors/transform/transform_mode_tosphere.c
@@ -101,7 +101,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initToSphere(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_trackball.c b/source/blender/editors/transform/transform_mode_trackball.c
index 758ee3b9cae..c6e0b205204 100644
--- a/source/blender/editors/transform/transform_mode_trackball.c
+++ b/source/blender/editors/transform/transform_mode_trackball.c
@@ -143,7 +143,7 @@ static void applyTrackball(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initTrackball(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c
index aef5a999d18..0a7d8bd90d3 100644
--- a/source/blender/editors/transform/transform_mode_translate.c
+++ b/source/blender/editors/transform/transform_mode_translate.c
@@ -191,7 +191,7 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_
}
if (t->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first;
+ SpaceNode *snode = (SpaceNode *)t->area->spacedata.first;
if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) {
const char *str_old = BLI_strdup(str);
@@ -370,7 +370,7 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initTranslation(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_vert_slide.c b/source/blender/editors/transform/transform_mode_vert_slide.c
index 2325c4d1d26..7bee48337f9 100644
--- a/source/blender/editors/transform/transform_mode_vert_slide.c
+++ b/source/blender/editors/transform/transform_mode_vert_slide.c
@@ -602,7 +602,7 @@ static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- ED_area_status_text(t->sa, str);
+ ED_area_status_text(t->area, str);
}
void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp)
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 7e56b34af2f..31b85cdf3a8 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -893,8 +893,8 @@ static bool transform_shear_poll(bContext *C)
return false;
}
- ScrArea *sa = CTX_wm_area(C);
- return sa && !ELEM(sa->spacetype, SPACE_ACTION);
+ ScrArea *area = CTX_wm_area(C);
+ return area && !ELEM(area->spacetype, SPACE_ACTION);
}
static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 5cc1feddf7a..423990b3713 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -523,12 +523,12 @@ void initTransformOrientation(bContext *C, TransInfo *t)
/**
* utility function - get first n, selected vert/edge/faces
*/
-static unsigned int bm_mesh_elems_select_get_n__internal(
- BMesh *bm, BMElem **elems, const unsigned int n, const BMIterType itype, const char htype)
+static uint bm_mesh_elems_select_get_n__internal(
+ BMesh *bm, BMElem **elems, const uint n, const BMIterType itype, const char htype)
{
BMIter iter;
BMElem *ele;
- unsigned int i;
+ uint i;
BLI_assert(ELEM(htype, BM_VERT, BM_EDGE, BM_FACE));
BLI_assert(ELEM(itype, BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, BM_FACES_OF_MESH));
@@ -579,18 +579,18 @@ static unsigned int bm_mesh_elems_select_get_n__internal(
return i;
}
-static unsigned int bm_mesh_verts_select_get_n(BMesh *bm, BMVert **elems, const unsigned int n)
+static uint bm_mesh_verts_select_get_n(BMesh *bm, BMVert **elems, const uint n)
{
return bm_mesh_elems_select_get_n__internal(
bm, (BMElem **)elems, min_ii(n, bm->totvertsel), BM_VERTS_OF_MESH, BM_VERT);
}
-static unsigned int bm_mesh_edges_select_get_n(BMesh *bm, BMEdge **elems, const unsigned int n)
+static uint bm_mesh_edges_select_get_n(BMesh *bm, BMEdge **elems, const uint n)
{
return bm_mesh_elems_select_get_n__internal(
bm, (BMElem **)elems, min_ii(n, bm->totedgesel), BM_EDGES_OF_MESH, BM_EDGE);
}
#if 0
-static unsigned int bm_mesh_faces_select_get_n(BMesh *bm, BMVert **elems, const unsigned int n)
+static uint bm_mesh_faces_select_get_n(BMesh *bm, BMVert **elems, const uint n)
{
return bm_mesh_elems_select_get_n__internal(
bm, (BMElem **)elems, min_ii(n, bm->totfacesel), BM_FACES_OF_MESH, BM_FACE);
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 86e99c986f8..cb4446deb99 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -44,8 +44,8 @@
#include "GPU_immediate.h"
#include "GPU_state.h"
-#include "BKE_anim.h" /* for duplis */
#include "BKE_context.h"
+#include "BKE_duplilist.h"
#include "BKE_editmesh.h"
#include "BKE_layer.h"
#include "BKE_main.h"
@@ -158,7 +158,7 @@ static bool doForceIncrementSnap(const TransInfo *t)
void drawSnapping(const struct bContext *C, TransInfo *t)
{
- unsigned char col[4], selectedCol[4], activeCol[4];
+ uchar col[4], selectedCol[4], activeCol[4];
if (!activeSnap(t)) {
return;
@@ -1106,7 +1106,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
}
else if (t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH) {
if (t->tsnap.mode & SCE_SNAP_MODE_VERTEX) {
- Image *ima = ED_space_image(t->sa->spacedata.first);
+ Image *ima = ED_space_image(t->area->spacedata.first);
float co[2];
UI_view2d_region_to_view(&t->region->v2d, t->mval[0], t->mval[1], &co[0], &co[1]);
@@ -1581,7 +1581,7 @@ bool snapNodesTransform(
TransInfo *t, const int mval[2], float r_loc[2], float *r_dist_px, char *r_node_border)
{
return snapNodes(t->settings,
- t->sa->spacedata.first,
+ t->area->spacedata.first,
t->region,
mval,
t->tsnap.modeSelect,
@@ -1716,7 +1716,7 @@ static void applyGridIncrement(
if (t->spacetype == SPACE_GRAPH) {
View2D *v2d = &t->region->v2d;
Scene *scene = t->scene;
- SpaceGraph *sipo = t->sa->spacedata.first;
+ SpaceGraph *sipo = t->area->spacedata.first;
asp_local[0] = UI_view2d_grid_resolution_x__frames_or_seconds(
v2d, scene, sipo->flag & SIPO_DRAWTIME);
asp_local[1] = UI_view2d_grid_resolution_y__values(v2d);
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index f55c73fd15e..2cfeedbb346 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -38,10 +38,10 @@
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
-#include "BKE_anim.h" /* for duplis */
#include "BKE_armature.h"
#include "BKE_bvhutils.h"
#include "BKE_curve.h"
+#include "BKE_duplilist.h"
#include "BKE_editmesh.h"
#include "BKE_layer.h"
#include "BKE_main.h"
@@ -447,7 +447,7 @@ struct RayCastAll_Data {
float local_scale;
Object *ob;
- unsigned int ob_uuid;
+ uint ob_uuid;
/* output data */
ListBase *hit_list;
@@ -460,7 +460,7 @@ static struct SnapObjectHitDepth *hit_depth_create(const float depth,
int index,
Object *ob,
const float obmat[4][4],
- unsigned int ob_uuid)
+ uint ob_uuid)
{
struct SnapObjectHitDepth *hit = MEM_mallocN(sizeof(*hit), __func__);
@@ -586,7 +586,7 @@ static bool raycastMesh(SnapObjectContext *sctx,
Object *ob,
Mesh *me,
const float obmat[4][4],
- const unsigned int ob_index,
+ const uint ob_index,
bool use_hide,
bool use_backface_culling,
/* read/write args */
@@ -761,7 +761,7 @@ static bool raycastEditMesh(SnapObjectContext *sctx,
Object *ob,
BMEditMesh *em,
const float obmat[4][4],
- const unsigned int ob_index,
+ const uint ob_index,
bool use_backface_culling,
/* read/write args */
float *ray_depth,
@@ -931,7 +931,7 @@ static bool raycastObj(SnapObjectContext *sctx,
const float ray_dir[3],
Object *ob,
const float obmat[4][4],
- const unsigned int ob_index,
+ const uint ob_index,
bool use_obedit,
bool use_occlusion_test,
bool use_backface_culling,
@@ -1046,7 +1046,7 @@ static bool raycastObj(SnapObjectContext *sctx,
struct RaycastObjUserData {
const float *ray_start;
const float *ray_dir;
- unsigned int ob_index;
+ uint ob_index;
/* read/write args */
float *ray_depth;
/* return args */
@@ -1227,7 +1227,7 @@ static void cb_mlooptri_edges_get(const int index, int v_index[3], const BVHTree
const MLoopTri *lt = &data->looptri[index];
for (int j = 2, j_next = 0; j_next < 3; j = j_next++) {
const MEdge *ed = &medge[mloop[lt->tri[j]].e];
- unsigned int tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v};
+ uint tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v};
if (ELEM(ed->v1, tri_edge[0], tri_edge[1]) && ELEM(ed->v2, tri_edge[0], tri_edge[1])) {
// printf("real edge found\n");
v_index[j] = mloop[lt->tri[j]].e;
@@ -1838,7 +1838,7 @@ static short snapArmature(SnapData *snapdata,
bArmature *arm = ob->data;
if (arm->edbo) {
- for (EditBone *eBone = arm->edbo->first; eBone; eBone = eBone->next) {
+ LISTBASE_FOREACH (EditBone *, eBone, arm->edbo) {
if (eBone->layer & arm->layer) {
/* skip hidden or moving (selected) bones */
if ((eBone->flag & (BONE_HIDDEN_A | BONE_ROOTSEL | BONE_TIPSEL)) == 0) {
@@ -1881,7 +1881,7 @@ static short snapArmature(SnapData *snapdata,
}
}
else if (ob->pose && ob->pose->chanbase.first) {
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
Bone *bone = pchan->bone;
/* skip hidden bones */
if (bone && !(bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) {
@@ -3049,7 +3049,7 @@ bool ED_transform_snap_object_project_ray(SnapObjectContext *sctx,
static short transform_snap_context_project_view3d_mixed_impl(
SnapObjectContext *sctx,
Depsgraph *depsgraph,
- const unsigned short snap_to_flag,
+ const ushort snap_to_flag,
const struct SnapObjectParams *params,
const float mval[2],
const float prev_co[3],
@@ -3225,7 +3225,7 @@ static short transform_snap_context_project_view3d_mixed_impl(
short ED_transform_snap_object_project_view3d_ex(SnapObjectContext *sctx,
Depsgraph *depsgraph,
- const unsigned short snap_to,
+ const ushort snap_to,
const struct SnapObjectParams *params,
const float mval[2],
const float prev_co[3],
@@ -3265,7 +3265,7 @@ short ED_transform_snap_object_project_view3d_ex(SnapObjectContext *sctx,
*/
bool ED_transform_snap_object_project_view3d(SnapObjectContext *sctx,
Depsgraph *depsgraph,
- const unsigned short snap_to,
+ const ushort snap_to,
const struct SnapObjectParams *params,
const float mval[2],
const float prev_co[3],
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index 123fd5f35da..69e7c04b5e5 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -119,7 +119,7 @@ static int ed_undo_step_impl(
CLOG_INFO(&LOG, 1, "name='%s', step=%d", undoname, step);
wmWindowManager *wm = CTX_wm_manager(C);
Scene *scene = CTX_data_scene(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* undo during jobs are running can easily lead to freeing data using by jobs,
* or they can just lead to freezing job in some other cases */
@@ -138,7 +138,7 @@ static int ed_undo_step_impl(
if (ED_gpencil_session_active()) {
return ED_undo_gpencil_step(C, step, undoname);
}
- if (sa && (sa->spacetype == SPACE_VIEW3D)) {
+ if (area && (area->spacetype == SPACE_VIEW3D)) {
Object *obact = CTX_data_active_object(C);
if (obact && (obact->type == OB_GPENCIL)) {
ED_gpencil_toggle_brush_cursor(C, false, NULL);
@@ -195,7 +195,7 @@ static int ed_undo_step_impl(
}
/* Set special modes for grease pencil */
- if (sa && (sa->spacetype == SPACE_VIEW3D)) {
+ if (area && (area->spacetype == SPACE_VIEW3D)) {
Object *obact = CTX_data_active_object(C);
if (obact && (obact->type == OB_GPENCIL)) {
/* set cursor */
@@ -558,11 +558,11 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op)
struct Scene *scene = CTX_data_scene(C);
/* keep in sync with logic in view3d_panel_operator_redo() */
- ARegion *ar_orig = CTX_wm_region(C);
- ARegion *ar_win = BKE_area_find_region_active_win(CTX_wm_area(C));
+ ARegion *region_orig = CTX_wm_region(C);
+ ARegion *region_win = BKE_area_find_region_active_win(CTX_wm_area(C));
- if (ar_win) {
- CTX_wm_region_set(C, ar_win);
+ if (region_win) {
+ CTX_wm_region_set(C, region_win);
}
if ((WM_operator_repeat_check(C, op)) && (WM_operator_poll(C, op->type)) &&
@@ -585,9 +585,9 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op)
if (op->type->check) {
if (op->type->check(C, op)) {
/* check for popup and re-layout buttons */
- ARegion *ar_menu = CTX_wm_menu(C);
- if (ar_menu) {
- ED_region_tag_refresh_ui(ar_menu);
+ ARegion *region_menu = CTX_wm_menu(C);
+ if (region_menu) {
+ ED_region_tag_refresh_ui(region_menu);
}
}
}
@@ -610,7 +610,7 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op)
}
/* set region back */
- CTX_wm_region_set(C, ar_orig);
+ CTX_wm_region_set(C, region_orig);
}
else {
CLOG_WARN(&LOG, "called with NULL 'op'");
@@ -816,7 +816,7 @@ static int undo_editmode_objects_from_view_layer_prepare(ViewLayer *view_layer,
{
const short object_type = obact->type;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
ID *id = ob->data;
@@ -825,7 +825,7 @@ static int undo_editmode_objects_from_view_layer_prepare(ViewLayer *view_layer,
}
int len = 0;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
if (ob == obact) {
@@ -852,7 +852,7 @@ Object **ED_undo_editmode_objects_from_view_layer(ViewLayer *view_layer, uint *r
const short object_type = obact->type;
int i = 0;
Object **objects = MEM_malloc_arrayN(len, sizeof(*objects), __func__);
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
ID *id = ob->data;
@@ -881,7 +881,7 @@ Base **ED_undo_editmode_bases_from_view_layer(ViewLayer *view_layer, uint *r_len
const short object_type = obact->type;
int i = 0;
Base **base_array = MEM_malloc_arrayN(len, sizeof(*base_array), __func__);
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
ID *id = ob->data;
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index fa28d9c2d6d..f8e19b742e4 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -35,6 +35,7 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
+#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
@@ -82,7 +83,7 @@
void ED_editors_init_for_undo(Main *bmain)
{
wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
Base *base = BASACT(view_layer);
if (base != NULL) {
@@ -224,8 +225,8 @@ void ED_editors_exit(Main *bmain, bool do_undo_system)
}
/* global in meshtools... */
- ED_mesh_mirror_spatial_table(NULL, NULL, NULL, NULL, 'e');
- ED_mesh_mirror_topo_table(NULL, NULL, 'e');
+ ED_mesh_mirror_spatial_table_end(NULL);
+ ED_mesh_mirror_topo_table_end(NULL);
}
bool ED_editors_flush_edits_for_object_ex(Main *bmain,
@@ -472,12 +473,12 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *region, void *arg_
*
* \param new_id: may be NULL to unlink \a old_id.
*/
-void ED_spacedata_id_remap(struct ScrArea *sa, struct SpaceLink *sl, ID *old_id, ID *new_id)
+void ED_spacedata_id_remap(struct ScrArea *area, struct SpaceLink *sl, ID *old_id, ID *new_id)
{
SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
if (st && st->id_remap) {
- st->id_remap(sa, sl, old_id, new_id);
+ st->id_remap(area, sl, old_id, new_id);
}
}
diff --git a/source/blender/editors/util/gizmo_utils.c b/source/blender/editors/util/gizmo_utils.c
index 85a7cc94ae3..08e7b3a9a0a 100644
--- a/source/blender/editors/util/gizmo_utils.c
+++ b/source/blender/editors/util/gizmo_utils.c
@@ -59,9 +59,9 @@ bool ED_gizmo_poll_or_unlink_delayed_from_tool_ex(const bContext *C,
{
bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C);
if ((tref_rt == NULL) || !STREQ(gzgt_idname, tref_rt->gizmo_group)) {
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params);
- WM_gizmo_group_unlink_delayed_ptr_from_space(gzgt, gzmap_type, sa);
+ WM_gizmo_group_unlink_delayed_ptr_from_space(gzgt, gzmap_type, area);
if (gzgt->users == 0) {
WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
}
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c
index 887ce274680..c072220842e 100644
--- a/source/blender/editors/uvedit/uvedit_buttons.c
+++ b/source/blender/editors/uvedit/uvedit_buttons.c
@@ -259,11 +259,11 @@ static bool image_panel_uv_poll(const bContext *C, PanelType *UNUSED(pt))
return ED_uvedit_test(obedit);
}
-static void image_panel_uv(const bContext *C, Panel *pa)
+static void image_panel_uv(const bContext *C, Panel *panel)
{
uiBlock *block;
- block = uiLayoutAbsoluteBlock(pa->layout);
+ block = uiLayoutAbsoluteBlock(panel->layout);
UI_block_func_handle_set(block, do_uvedit_vertex, NULL);
uvedit_vertex_buttons(C, block);
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index b805681cfd3..33601de50da 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -695,7 +695,7 @@ void ED_uvedit_select_all(BMesh *bm)
static bool ED_uvedit_median_multi(
const Scene *scene, Image *ima, Object **objects_edit, uint objects_len, float co[2])
{
- unsigned int sel = 0;
+ uint sel = 0;
zero_v2(co);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -1319,7 +1319,7 @@ static void uv_select_linked_multi(Scene *scene,
UvVertMap *vmap;
UvMapVert *vlist, *iterv, *startv;
int i, stacksize = 0, *stack;
- unsigned int a;
+ uint a;
char *flag;
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -3261,7 +3261,7 @@ static void uv_select_tag_update_for_object(Depsgraph *depsgraph,
static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene,
BMEditMesh *em,
UvVertMap *vmap,
- const unsigned int efa_index,
+ const uint efa_index,
BMLoop *l,
const bool select,
const int cd_loop_uv_offset)
@@ -3361,7 +3361,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima,
else if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_LOC) {
struct UvVertMap *vmap;
float limit[2];
- unsigned int efa_index;
+ uint efa_index;
uvedit_pixel_to_float(sima, limit, 0.05);
@@ -3448,7 +3448,7 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima,
else if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_LOC) {
struct UvVertMap *vmap;
float limit[2];
- unsigned int efa_index;
+ uint efa_index;
uvedit_pixel_to_float(sima, limit, 0.05);
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 936ba750266..da8e0efa522 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -107,7 +107,7 @@ typedef struct PVert {
struct PEdge *edge;
float co[3];
float uv[2];
- unsigned char flag;
+ uchar flag;
} PVert;
@@ -126,7 +126,7 @@ typedef struct PEdge {
struct PEdge *next;
struct PFace *face;
float *orig_uv, old_uv[2];
- unsigned short flag;
+ ushort flag;
} PEdge;
@@ -141,7 +141,7 @@ typedef struct PFace {
} u;
struct PEdge *edge;
- unsigned char flag;
+ uchar flag;
} PFace;
enum PVertFlag {
@@ -197,7 +197,7 @@ typedef struct PChart {
} pack;
} u;
- unsigned char flag;
+ uchar flag;
struct PHandle *handle;
} PChart;
@@ -245,7 +245,7 @@ static int PHashSizes[] = {
1048583, 2097169, 4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 268435459,
};
-#define PHASH_hash(ph, item) (((uintptr_t)(item)) % ((unsigned int)(ph)->cursize))
+#define PHASH_hash(ph, item) (((uintptr_t)(item)) % ((uint)(ph)->cursize))
#define PHASH_edge(v1, v2) (((v1) < (v2)) ? ((v1)*39) ^ ((v2)*31) : ((v1)*31) ^ ((v2)*39))
static PHash *phash_new(PHashLink **list, int sizehint)
@@ -511,7 +511,7 @@ static void p_chart_uv_transform(PChart *chart, float mat[2][2])
static void p_chart_uv_to_array(PChart *chart, float (*points)[2])
{
PVert *v;
- unsigned int i = 0;
+ uint i = 0;
for (v = chart->verts; v; v = v->nextlink) {
copy_v2_v2(points[i++], v->uv);
@@ -521,7 +521,7 @@ static void p_chart_uv_to_array(PChart *chart, float (*points)[2])
static void UNUSED_FUNCTION(p_chart_uv_from_array)(PChart *chart, float (*points)[2])
{
PVert *v;
- unsigned int i = 0;
+ uint i = 0;
for (v = chart->verts; v; v = v->nextlink) {
copy_v2_v2(v->uv, points[i++]);
@@ -4409,8 +4409,8 @@ static void p_add_ngon(ParamHandle *handle,
PHandle *phandle = (PHandle *)handle;
MemArena *arena = phandle->polyfill_arena;
Heap *heap = phandle->polyfill_heap;
- unsigned int nfilltri = nverts - 2;
- unsigned int(*tris)[3] = BLI_memarena_alloc(arena, sizeof(*tris) * (size_t)nfilltri);
+ uint nfilltri = nverts - 2;
+ uint(*tris)[3] = BLI_memarena_alloc(arena, sizeof(*tris) * (size_t)nfilltri);
float(*projverts)[2] = BLI_memarena_alloc(arena, sizeof(*projverts) * (size_t)nverts);
/* Calc normal, flipped: to get a positive 2d cross product. */
@@ -4441,10 +4441,10 @@ static void p_add_ngon(ParamHandle *handle,
/* Add triangles. */
for (int j = 0; j < nfilltri; j++) {
- unsigned int *tri = tris[j];
- unsigned int v0 = tri[0];
- unsigned int v1 = tri[1];
- unsigned int v2 = tri[2];
+ uint *tri = tris[j];
+ uint v0 = tri[0];
+ uint v1 = tri[1];
+ uint v2 = tri[2];
ParamKey tri_vkeys[3] = {vkeys[v0], vkeys[v1], vkeys[v2]};
float *tri_co[3] = {co[v0], co[v1], co[v2]};
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index cf23cac38a7..3a4f12acf9c 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -75,20 +75,20 @@ typedef struct StitchPreviewer {
/* here we'll store the preview triangle indices of the mesh */
float *preview_polys;
/* uvs per polygon. */
- unsigned int *uvs_per_polygon;
+ uint *uvs_per_polygon;
/*number of preview polygons */
- unsigned int num_polys;
+ uint num_polys;
/* preview data. These will be either the previewed vertices or edges
* depending on stitch mode settings */
float *preview_stitchable;
float *preview_unstitchable;
/* here we'll store the number of elements to be drawn */
- unsigned int num_stitchable;
- unsigned int num_unstitchable;
- unsigned int preview_uvs;
+ uint num_stitchable;
+ uint num_unstitchable;
+ uint preview_uvs;
/* ...and here we'll store the static island triangles */
float *static_tris;
- unsigned int num_static_tris;
+ uint num_static_tris;
} StitchPreviewer;
struct IslandStitchData;
@@ -119,16 +119,16 @@ typedef struct IslandStitchData {
/* just for averaging UVs */
typedef struct UVVertAverage {
float uv[2];
- unsigned short count;
+ ushort count;
} UVVertAverage;
typedef struct UvEdge {
/** index to uv buffer */
- unsigned int uv1;
- unsigned int uv2;
+ uint uv1;
+ uint uv2;
/** general use flag
* (Used to check if edge is boundary here, and propagates to adjacency elements) */
- unsigned char flag;
+ uchar flag;
/** element that guarantees element->face
* has the edge on element->tfindex and element->tfindex+1 is the second uv */
UvElement *element;
@@ -172,7 +172,7 @@ typedef struct StitchState {
int selection_size;
/* store number of primitives per face so that we can allocate the active island buffer later */
- unsigned int *tris_per_island;
+ uint *tris_per_island;
/* preview data */
StitchPreviewer *stitch_preview;
} StitchState;
@@ -299,9 +299,9 @@ static void stitch_update_header(StitchStateContainer *ssc, bContext *C)
"shift select vertices");
char msg[UI_MAX_DRAW_STR];
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
- if (sa) {
+ if (area) {
BLI_snprintf(msg,
sizeof(msg),
str,
@@ -544,7 +544,7 @@ static void stitch_island_calculate_edge_rotation(UvEdge *edge,
StitchStateContainer *ssc,
StitchState *state,
UVVertAverage *uv_average,
- unsigned int *uvfinal_map,
+ uint *uvfinal_map,
IslandStitchData *island_stitch_data)
{
BMesh *bm = state->em->bm;
@@ -1032,7 +1032,7 @@ static int stitch_process_data(StitchStateContainer *ssc,
char stitch_midpoints = ssc->midpoints;
/* used to map uv indices to uvaverage indices for selection */
- unsigned int *uvfinal_map = NULL;
+ uint *uvfinal_map = NULL;
/* per face preview position in preview buffer */
PreviewPosition *preview_position = NULL;
@@ -1229,7 +1229,7 @@ static int stitch_process_data(StitchStateContainer *ssc,
BMIter liter;
BMLoop *l;
MLoopUV *luv;
- unsigned int buffer_index = 0;
+ uint buffer_index = 0;
/* initialize the preview buffers */
preview->preview_polys = MEM_mallocN(preview->preview_uvs * sizeof(float) * 2,
@@ -1575,7 +1575,7 @@ static int stitch_process_data_all(StitchStateContainer *ssc, Scene *scene, int
}
/* Stitch hash initialization functions */
-static unsigned int uv_edge_hash(const void *key)
+static uint uv_edge_hash(const void *key)
{
const UvEdge *edge = key;
return (BLI_ghashutil_uinthash(edge->uv2) + BLI_ghashutil_uinthash(edge->uv1));
@@ -1760,14 +1760,14 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), void
for (uint ob_index = 0; ob_index < ssc->objects_len; ob_index++) {
int j, index = 0;
- unsigned int num_line = 0, num_tri, tri_idx = 0, line_idx = 0;
+ uint num_line = 0, num_tri, tri_idx = 0, line_idx = 0;
StitchState *state = ssc->states[ob_index];
StitchPreviewer *stitch_preview = state->stitch_preview;
GPUVertBuf *vbo, *vbo_line;
float col[4];
static GPUVertFormat format = {0};
- static unsigned int pos_id;
+ static uint pos_id;
if (format.attr_len == 0) {
pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
@@ -2438,7 +2438,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished)
{
Scene *scene = CTX_data_scene(C);
SpaceImage *sima = CTX_wm_space_image(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
StitchStateContainer *ssc = (StitchStateContainer *)op->customdata;
@@ -2492,7 +2492,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished)
MEM_freeN(objs_selection_count);
}
- if (sa) {
+ if (area) {
ED_workspace_status_text(C, NULL);
}
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 8ded2c16be8..c4dcaaaa8b2 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -708,7 +708,7 @@ static bool minimize_stretch_init(bContext *C, wmOperator *op)
static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interactive)
{
MinStretch *ms = op->customdata;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
const Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
const bool synced_selection = (ts->uv_flag & UV_SYNC_SELECTION) != 0;
@@ -724,9 +724,9 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interac
param_flush(ms->handle);
- if (sa) {
+ if (area) {
BLI_snprintf(str, sizeof(str), TIP_("Minimize Stretch. Blend %.2f"), ms->blend);
- ED_area_status_text(sa, str);
+ ED_area_status_text(area, str);
ED_workspace_status_text(C, TIP_("Press + and -, or scroll wheel to set blending"));
}
@@ -749,12 +749,12 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interac
static void minimize_stretch_exit(bContext *C, wmOperator *op, bool cancel)
{
MinStretch *ms = op->customdata;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
const Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
const bool synced_selection = (ts->uv_flag & UV_SYNC_SELECTION) != 0;
- ED_area_status_text(sa, NULL);
+ ED_area_status_text(area, NULL);
ED_workspace_status_text(C, NULL);
if (ms->timer) {