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
path: root/source
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-10-19 03:54:09 +0300
committerHans Goudey <h.goudey@me.com>2020-10-19 03:54:09 +0300
commita5ad2d7f75d1a59abe6a002860f4103252f64525 (patch)
tree6f783be12ef379c1b5a93960f768236b4c88e96e /source
parent7c977ae4c91250a2577b1413c38b869df73529ec (diff)
parent48c484a22e0d105ed21a4f18b0cb455af6aac661 (diff)
Merge branch 'master' into fcurve-modifier-panels
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenfont/BLF_api.h5
-rw-r--r--source/blender/blenfont/intern/blf.c27
-rw-r--r--source/blender/blenkernel/BKE_addon.h2
-rw-r--r--source/blender/blenkernel/BKE_animsys.h10
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/BKE_collision.h18
-rw-r--r--source/blender/blenkernel/BKE_curve.h8
-rw-r--r--source/blender/blenkernel/BKE_editmesh.h7
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h25
-rw-r--r--source/blender/blenkernel/BKE_hair.h6
-rw-r--r--source/blender/blenkernel/BKE_key.h1
-rw-r--r--source/blender/blenkernel/BKE_lattice.h5
-rw-r--r--source/blender/blenkernel/BKE_mask.h3
-rw-r--r--source/blender/blenkernel/BKE_mball.h6
-rw-r--r--source/blender/blenkernel/BKE_mesh.h2
-rw-r--r--source/blender/blenkernel/BKE_paint.h27
-rw-r--r--source/blender/blenkernel/BKE_particle.h6
-rw-r--r--source/blender/blenkernel/BKE_pointcloud.h8
-rw-r--r--source/blender/blenkernel/BKE_scene.h2
-rw-r--r--source/blender/blenkernel/BKE_softbody.h2
-rw-r--r--source/blender/blenkernel/BKE_volume.h7
-rw-r--r--source/blender/blenkernel/CMakeLists.txt13
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c2
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_legacy.c2
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_util.c2
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c4
-rw-r--r--source/blender/blenkernel/intern/action.c18
-rw-r--r--source/blender/blenkernel/intern/anim_data.c46
-rw-r--r--source/blender/blenkernel/intern/armature.c17
-rw-r--r--source/blender/blenkernel/intern/armature_test.cc6
-rw-r--r--source/blender/blenkernel/intern/blender_undo.c4
-rw-r--r--source/blender/blenkernel/intern/blendfile.c4
-rw-r--r--source/blender/blenkernel/intern/brush.c4
-rw-r--r--source/blender/blenkernel/intern/cachefile.c4
-rw-r--r--source/blender/blenkernel/intern/camera.c4
-rw-r--r--source/blender/blenkernel/intern/cloth.c44
-rw-r--r--source/blender/blenkernel/intern/collection.c164
-rw-r--r--source/blender/blenkernel/intern/colortools.c3
-rw-r--r--source/blender/blenkernel/intern/constraint.c8
-rw-r--r--source/blender/blenkernel/intern/context.c58
-rw-r--r--source/blender/blenkernel/intern/curve.c54
-rw-r--r--source/blender/blenkernel/intern/customdata.c281
-rw-r--r--source/blender/blenkernel/intern/editmesh.c28
-rw-r--r--source/blender/blenkernel/intern/fcurve.c54
-rw-r--r--source/blender/blenkernel/intern/fcurve_test.cc89
-rw-r--r--source/blender/blenkernel/intern/fluid.c278
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c107
-rw-r--r--source/blender/blenkernel/intern/hair.c8
-rw-r--r--source/blender/blenkernel/intern/icons.c2
-rw-r--r--source/blender/blenkernel/intern/idprop.c2
-rw-r--r--source/blender/blenkernel/intern/image.c6
-rw-r--r--source/blender/blenkernel/intern/ipo.c47
-rw-r--r--source/blender/blenkernel/intern/key.c38
-rw-r--r--source/blender/blenkernel/intern/lattice.c8
-rw-r--r--source/blender/blenkernel/intern/layer.c7
-rw-r--r--source/blender/blenkernel/intern/lib_override.c14
-rw-r--r--source/blender/blenkernel/intern/light.c4
-rw-r--r--source/blender/blenkernel/intern/lightprobe.c4
-rw-r--r--source/blender/blenkernel/intern/linestyle.c12
-rw-r--r--source/blender/blenkernel/intern/mask.c27
-rw-r--r--source/blender/blenkernel/intern/material.c8
-rw-r--r--source/blender/blenkernel/intern/mball.c8
-rw-r--r--source/blender/blenkernel/intern/mesh.c4
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c2
-rw-r--r--source/blender/blenkernel/intern/mesh_merge.c2
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c7
-rw-r--r--source/blender/blenkernel/intern/mesh_tangent.c8
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c107
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.cc268
-rw-r--r--source/blender/blenkernel/intern/modifier.c28
-rw-r--r--source/blender/blenkernel/intern/movieclip.c30
-rw-r--r--source/blender/blenkernel/intern/object.c3
-rw-r--r--source/blender/blenkernel/intern/object_update.c2
-rw-r--r--source/blender/blenkernel/intern/outliner_treehash.c2
-rw-r--r--source/blender/blenkernel/intern/paint.c64
-rw-r--r--source/blender/blenkernel/intern/particle.c109
-rw-r--r--source/blender/blenkernel/intern/particle_system.c8
-rw-r--r--source/blender/blenkernel/intern/pointcache.c22
-rw-r--r--source/blender/blenkernel/intern/pointcloud.c11
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c12
-rw-r--r--source/blender/blenkernel/intern/scene.c12
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c34
-rw-r--r--source/blender/blenkernel/intern/simulation.cc4
-rw-r--r--source/blender/blenkernel/intern/softbody.c23
-rw-r--r--source/blender/blenkernel/intern/sound.c10
-rw-r--r--source/blender/blenkernel/intern/speaker.c4
-rw-r--r--source/blender/blenkernel/intern/subdiv_ccg.c6
-rw-r--r--source/blender/blenkernel/intern/subdiv_mesh.c3
-rw-r--r--source/blender/blenkernel/intern/text.c6
-rw-r--r--source/blender/blenkernel/intern/texture.c8
-rw-r--r--source/blender/blenkernel/intern/volume.cc17
-rw-r--r--source/blender/blenkernel/intern/workspace.c2
-rw-r--r--source/blender/blenkernel/intern/world.c8
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c16
-rw-r--r--source/blender/blenlib/BLI_fileops.h2
-rw-r--r--source/blender/blenlib/BLI_set.hh33
-rw-r--r--source/blender/blenlib/BLI_task.hh74
-rw-r--r--source/blender/blenlib/BLI_utildefines.h7
-rw-r--r--source/blender/blenlib/BLI_vector.hh2
-rw-r--r--source/blender/blenlib/intern/BLI_filelist.c4
-rw-r--r--source/blender/blenlib/intern/fileops.c2
-rw-r--r--source/blender/blenlib/intern/math_boolean.cc2
-rw-r--r--source/blender/blenlib/intern/math_color.c2
-rw-r--r--source/blender/blenlib/intern/math_rotation.c1
-rw-r--r--source/blender/blenlib/intern/mesh_boolean.cc12
-rw-r--r--source/blender/blenlib/intern/path_util.c2
-rw-r--r--source/blender/blenlib/intern/storage.c16
-rw-r--r--source/blender/blenlib/intern/storage_apple.mm36
-rw-r--r--source/blender/blenlib/intern/system_win32.c2
-rw-r--r--source/blender/blenlib/tests/BLI_path_util_test.cc4
-rw-r--r--source/blender/blenlib/tests/BLI_set_test.cc14
-rw-r--r--source/blender/blenlib/tests/BLI_string_test.cc2
-rw-r--r--source/blender/blenlib/tests/BLI_string_utf8_test.cc146
-rw-r--r--source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc2
-rw-r--r--source/blender/blenloader/intern/blend_validate.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c137
-rw-r--r--source/blender/blenloader/intern/versioning_250.c66
-rw-r--r--source/blender/blenloader/intern/versioning_260.c106
-rw-r--r--source/blender/blenloader/intern/versioning_280.c12
-rw-r--r--source/blender/blenloader/intern/versioning_290.c108
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c40
-rw-r--r--source/blender/blenloader/intern/writefile.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c41
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.h4
-rw-r--r--source/blender/bmesh/operators/bmo_edgenet.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c194
-rw-r--r--source/blender/bmesh/tools/bmesh_intersect.c2
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp2
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h8
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.cpp9
-rw-r--r--source/blender/datatoc/CMakeLists.txt5
-rw-r--r--source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc20
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query.cc4
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type.cc2
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.h4
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c30
-rw-r--r--source/blender/draw/engines/eevee/eevee_occlusion.c4
-rw-r--r--source/blender/draw/engines/eevee/eevee_renderpasses.c4
-rw-r--r--source/blender/draw/engines/eevee/eevee_shadows.c3
-rw-r--r--source/blender/draw/engines/eevee/eevee_volumes.c3
-rw-r--r--source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl2
-rw-r--r--source/blender/draw/engines/overlay/overlay_edit_uv.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_engine.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_volume.c11
-rw-r--r--source/blender/draw/engines/overlay/shaders/edit_uv_verts_frag.glsl22
-rw-r--r--source/blender/draw/engines/overlay/shaders/edit_uv_verts_vert.glsl6
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl8
-rw-r--r--source/blender/draw/engines/workbench/workbench_data.c22
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h14
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_hair.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_lattice.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_metaball.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_pointcloud.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_volume.c2
-rw-r--r--source/blender/draw/intern/shaders/common_fxaa_lib.glsl194
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c113
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c878
-rw-r--r--source/blender/editors/animation/anim_deps.c126
-rw-r--r--source/blender/editors/animation/anim_draw.c18
-rw-r--r--source/blender/editors/animation/anim_filter.c73
-rw-r--r--source/blender/editors/animation/anim_markers.c4
-rw-r--r--source/blender/editors/animation/drivers.c27
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c6
-rw-r--r--source/blender/editors/animation/keyframes_draw.c6
-rw-r--r--source/blender/editors/animation/keyframes_edit.c25
-rw-r--r--source/blender/editors/animation/keyframes_general.c4
-rw-r--r--source/blender/editors/animation/keyframing.c33
-rw-r--r--source/blender/editors/animation/keyingsets.c9
-rw-r--r--source/blender/editors/animation/time_scrub_ui.c37
-rw-r--r--source/blender/editors/armature/armature_add.c16
-rw-r--r--source/blender/editors/armature/armature_relations.c2
-rw-r--r--source/blender/editors/armature/meshlaplacian.c2
-rw-r--r--source/blender/editors/armature/pose_edit.c2
-rw-r--r--source/blender/editors/armature/pose_lib.c4
-rw-r--r--source/blender/editors/armature/pose_select.c4
-rw-r--r--source/blender/editors/armature/pose_slide.c10
-rw-r--r--source/blender/editors/armature/pose_transform.c8
-rw-r--r--source/blender/editors/armature/pose_utils.c2
-rw-r--r--source/blender/editors/curve/editcurve.c4
-rw-r--r--source/blender/editors/curve/editcurve_add.c2
-rw-r--r--source/blender/editors/datafiles/CMakeLists.txt5
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c2
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c2
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c2
-rw-r--r--source/blender/editors/gpencil/annotate_draw.c4
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c6
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c3
-rw-r--r--source/blender/editors/gpencil/gpencil_sculpt_paint.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c12
-rw-r--r--source/blender/editors/include/ED_anim_api.h14
-rw-r--r--source/blender/editors/include/ED_buttons.h5
-rw-r--r--source/blender/editors/include/ED_screen.h5
-rw-r--r--source/blender/editors/include/UI_icons.h6
-rw-r--r--source/blender/editors/include/UI_interface.h10
-rw-r--r--source/blender/editors/include/UI_resources.h46
-rw-r--r--source/blender/editors/interface/interface.c43
-rw-r--r--source/blender/editors/interface/interface_draw.c2
-rw-r--r--source/blender/editors/interface/interface_eyedropper_driver.c4
-rw-r--r--source/blender/editors/interface/interface_handlers.c25
-rw-r--r--source/blender/editors/interface/interface_icons.c6
-rw-r--r--source/blender/editors/interface/interface_intern.h2
-rw-r--r--source/blender/editors/interface/interface_layout.c42
-rw-r--r--source/blender/editors/interface/interface_ops.c10
-rw-r--r--source/blender/editors/interface/interface_panel.c145
-rw-r--r--source/blender/editors/interface/interface_region_popover.c10
-rw-r--r--source/blender/editors/interface/interface_style.c8
-rw-r--r--source/blender/editors/interface/interface_templates.c5
-rw-r--r--source/blender/editors/interface/interface_widgets.c4
-rw-r--r--source/blender/editors/interface/view2d.c4
-rw-r--r--source/blender/editors/interface/view2d_ops.c4
-rw-r--r--source/blender/editors/io/io_collada.c4
-rw-r--r--source/blender/editors/mesh/editface.c2
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c4
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c37
-rw-r--r--source/blender/editors/mesh/editmesh_select.c40
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c9
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c43
-rw-r--r--source/blender/editors/mesh/mesh_intern.h9
-rw-r--r--source/blender/editors/object/object_add.c127
-rw-r--r--source/blender/editors/object/object_constraint.c14
-rw-r--r--source/blender/editors/object/object_edit.c6
-rw-r--r--source/blender/editors/object/object_modifier.c230
-rw-r--r--source/blender/editors/object/object_relations.c11
-rw-r--r--source/blender/editors/object/object_remesh.c2
-rw-r--r--source/blender/editors/object/object_select.c2
-rw-r--r--source/blender/editors/object/object_shapekey.c2
-rw-r--r--source/blender/editors/object/object_transform.c2
-rw-r--r--source/blender/editors/physics/particle_edit.c19
-rw-r--r--source/blender/editors/physics/physics_fluid.c2
-rw-r--r--source/blender/editors/physics/physics_ops.c2
-rw-r--r--source/blender/editors/physics/rigidbody_object.c2
-rw-r--r--source/blender/editors/physics/rigidbody_world.c2
-rw-r--r--source/blender/editors/render/render_internal.c12
-rw-r--r--source/blender/editors/render/render_opengl.c7
-rw-r--r--source/blender/editors/render/render_ops.c2
-rw-r--r--source/blender/editors/render/render_preview.c24
-rw-r--r--source/blender/editors/render/render_shading.c4
-rw-r--r--source/blender/editors/render/render_update.c2
-rw-r--r--source/blender/editors/screen/area.c292
-rw-r--r--source/blender/editors/screen/screen_context.c108
-rw-r--r--source/blender/editors/screen/screen_draw.c25
-rw-r--r--source/blender/editors/screen/screen_edit.c49
-rw-r--r--source/blender/editors/screen/screen_geometry.c37
-rw-r--r--source/blender/editors/screen/screen_ops.c264
-rw-r--r--source/blender/editors/screen/screendump.c2
-rw-r--r--source/blender/editors/screen/workspace_edit.c3
-rw-r--r--source/blender/editors/screen/workspace_layout_edit.c18
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c17
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c145
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c9
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c19
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c80
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_automasking.c118
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_cloth.c95
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_face_set.c16
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_filter_color.c26
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_filter_mesh.c74
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h68
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_mask_expand.c10
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_paint_color.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c4
-rw-r--r--source/blender/editors/sound/sound_ops.c14
-rw-r--r--source/blender/editors/space_action/action_buttons.c4
-rw-r--r--source/blender/editors/space_action/action_data.c4
-rw-r--r--source/blender/editors/space_action/action_edit.c4
-rw-r--r--source/blender/editors/space_action/action_select.c18
-rw-r--r--source/blender/editors/space_action/space_action.c2
-rw-r--r--source/blender/editors/space_api/spacetypes.c2
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c16
-rw-r--r--source/blender/editors/space_buttons/buttons_intern.h11
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c2
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c232
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_ops.c2
-rw-r--r--source/blender/editors/space_clip/clip_draw.c2
-rw-r--r--source/blender/editors/space_clip/clip_editor.c2
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c2
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c2
-rw-r--r--source/blender/editors/space_clip/clip_ops.c2
-rw-r--r--source/blender/editors/space_clip/clip_utils.c2
-rw-r--r--source/blender/editors/space_clip/tracking_ops_track.c4
-rw-r--r--source/blender/editors/space_clip/tracking_ops_utils.c2
-rw-r--r--source/blender/editors/space_console/console_ops.c7
-rw-r--r--source/blender/editors/space_console/space_console.c2
-rw-r--r--source/blender/editors/space_file/file_draw.c2
-rw-r--r--source/blender/editors/space_file/file_ops.c2
-rw-r--r--source/blender/editors/space_file/filelist.c10
-rw-r--r--source/blender/editors/space_file/space_file.c4
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c11
-rw-r--r--source/blender/editors/space_graph/graph_draw.c2
-rw-r--r--source/blender/editors/space_graph/graph_edit.c135
-rw-r--r--source/blender/editors/space_graph/graph_intern.h1
-rw-r--r--source/blender/editors/space_graph/graph_ops.c3
-rw-r--r--source/blender/editors/space_graph/graph_select.c26
-rw-r--r--source/blender/editors/space_graph/graph_utils.c10
-rw-r--r--source/blender/editors/space_graph/space_graph.c17
-rw-r--r--source/blender/editors/space_image/image_buttons.c3
-rw-r--r--source/blender/editors/space_image/space_image.c2
-rw-r--r--source/blender/editors/space_info/info_ops.c2
-rw-r--r--source/blender/editors/space_info/info_report.c12
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c10
-rw-r--r--source/blender/editors/space_nla/nla_channels.c12
-rw-r--r--source/blender/editors/space_nla/nla_draw.c2
-rw-r--r--source/blender/editors/space_nla/nla_edit.c26
-rw-r--r--source/blender/editors/space_nla/nla_select.c8
-rw-r--r--source/blender/editors/space_nla/space_nla.c2
-rw-r--r--source/blender/editors/space_node/drawnode.c2
-rw-r--r--source/blender/editors/space_node/node_draw.c4
-rw-r--r--source/blender/editors/space_node/node_edit.c12
-rw-r--r--source/blender/editors/space_node/node_group.c194
-rw-r--r--source/blender/editors/space_node/node_intern.h6
-rw-r--r--source/blender/editors/space_node/node_relationships.c265
-rw-r--r--source/blender/editors/space_node/node_view.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_dragdrop.c22
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c6
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c63
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h5
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c13
-rw-r--r--source/blender/editors/space_outliner/outliner_utils.c8
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c11
-rw-r--r--source/blender/editors/space_script/script_edit.c2
-rw-r--r--source/blender/editors/space_script/space_script.c12
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c6
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c2
-rw-r--r--source/blender/editors/space_text/text_draw.c4
-rw-r--r--source/blender/editors/space_text/text_header.c8
-rw-r--r--source/blender/editors/space_text/text_ops.c9
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c21
-rw-r--r--source/blender/editors/space_view3d/view3d_project.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c2
-rw-r--r--source/blender/editors/transform/CMakeLists.txt1
-rw-r--r--source/blender/editors/transform/transform.c69
-rw-r--r--source/blender/editors/transform/transform.h42
-rw-r--r--source/blender/editors/transform/transform_constraints.c4
-rw-r--r--source/blender/editors/transform/transform_convert_action.c4
-rw-r--r--source/blender/editors/transform/transform_convert_armature.c24
-rw-r--r--source/blender/editors/transform/transform_convert_curve.c1
-rw-r--r--source/blender/editors/transform/transform_convert_graph.c2
-rw-r--r--source/blender/editors/transform/transform_convert_mesh.c11
-rw-r--r--source/blender/editors/transform/transform_convert_mesh_edge.c2
-rw-r--r--source/blender/editors/transform/transform_convert_nla.c4
-rw-r--r--source/blender/editors/transform/transform_convert_object.c15
-rw-r--r--source/blender/editors/transform/transform_convert_sequencer.c4
-rw-r--r--source/blender/editors/transform/transform_data.h10
-rw-r--r--source/blender/editors/transform/transform_generics.c21
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c15
-rw-r--r--source/blender/editors/transform/transform_mode.c36
-rw-r--r--source/blender/editors/transform/transform_mode_baketime.c7
-rw-r--r--source/blender/editors/transform/transform_mode_bbone_resize.c9
-rw-r--r--source/blender/editors/transform/transform_mode_bend.c9
-rw-r--r--source/blender/editors/transform/transform_mode_boneenvelope.c7
-rw-r--r--source/blender/editors/transform/transform_mode_boneroll.c7
-rw-r--r--source/blender/editors/transform/transform_mode_curveshrinkfatten.c7
-rw-r--r--source/blender/editors/transform/transform_mode_edge_bevelweight.c7
-rw-r--r--source/blender/editors/transform/transform_mode_edge_crease.c7
-rw-r--r--source/blender/editors/transform/transform_mode_edge_rotate_normal.c7
-rw-r--r--source/blender/editors/transform/transform_mode_edge_seq_slide.c7
-rw-r--r--source/blender/editors/transform/transform_mode_edge_slide.c7
-rw-r--r--source/blender/editors/transform/transform_mode_gpopacity.c7
-rw-r--r--source/blender/editors/transform/transform_mode_gpshrinkfatten.c7
-rw-r--r--source/blender/editors/transform/transform_mode_maskshrinkfatten.c7
-rw-r--r--source/blender/editors/transform/transform_mode_push_pull.c7
-rw-r--r--source/blender/editors/transform/transform_mode_resize.c9
-rw-r--r--source/blender/editors/transform/transform_mode_rotate.c9
-rw-r--r--source/blender/editors/transform/transform_mode_shear.c7
-rw-r--r--source/blender/editors/transform/transform_mode_shrink_fatten.c9
-rw-r--r--source/blender/editors/transform/transform_mode_skin_resize.c7
-rw-r--r--source/blender/editors/transform/transform_mode_tilt.c7
-rw-r--r--source/blender/editors/transform/transform_mode_timescale.c5
-rw-r--r--source/blender/editors/transform/transform_mode_timeslide.c7
-rw-r--r--source/blender/editors/transform/transform_mode_timetranslate.c5
-rw-r--r--source/blender/editors/transform/transform_mode_tosphere.c9
-rw-r--r--source/blender/editors/transform/transform_mode_trackball.c11
-rw-r--r--source/blender/editors/transform/transform_mode_translate.c4
-rw-r--r--source/blender/editors/transform/transform_mode_vert_slide.c7
-rw-r--r--source/blender/editors/transform/transform_ops.c10
-rw-r--r--source/blender/editors/transform/transform_orientations.c131
-rw-r--r--source/blender/editors/transform/transform_orientations.h67
-rw-r--r--source/blender/editors/transform/transform_snap.c31
-rw-r--r--source/blender/editors/util/ed_util_imbuf.c4
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.h2
-rw-r--r--source/blender/gpencil_modifiers/CMakeLists.txt5
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c7
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c15
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c11
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c14
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c15
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c11
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c9
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c14
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c21
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c10
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c16
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c12
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c16
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c9
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c14
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c14
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c12
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c17
-rw-r--r--source/blender/gpu/GPU_batch.h2
-rw-r--r--source/blender/gpu/GPU_framebuffer.h2
-rw-r--r--source/blender/gpu/GPU_platform.h2
-rw-r--r--source/blender/gpu/GPU_state.h9
-rw-r--r--source/blender/gpu/GPU_texture.h8
-rw-r--r--source/blender/gpu/GPU_vertex_buffer.h2
-rw-r--r--source/blender/gpu/intern/gpu_state.cc46
-rw-r--r--source/blender/gpu/intern/gpu_state_private.hh1
-rw-r--r--source/blender/gpu/intern/gpu_texture_private.hh4
-rw-r--r--source/blender/gpu/opengl/gl_debug.cc2
-rw-r--r--source/blender/gpu/opengl/gl_framebuffer.cc14
-rw-r--r--source/blender/gpu/opengl/gl_framebuffer.hh2
-rw-r--r--source/blender/gpu/opengl/gl_state.cc12
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_edituvs_points_vert.glsl6
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_aa_vert.glsl6
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl6
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_varying_color_outline_aa_vert.glsl6
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_point_uniform_size_outline_aa_vert.glsl6
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_polyline_geom.glsl37
-rw-r--r--source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl12
-rw-r--r--source/blender/gpu/shaders/gpu_shader_point_uniform_color_aa_frag.glsl14
-rw-r--r--source/blender/gpu/shaders/gpu_shader_point_uniform_color_outline_aa_frag.glsl22
-rw-r--r--source/blender/gpu/shaders/gpu_shader_point_varying_color_outline_aa_frag.glsl22
-rw-r--r--source/blender/gpu/shaders/gpu_shader_point_varying_color_varying_outline_aa_frag.glsl22
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl2
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c14
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp490
-rw-r--r--source/blender/imbuf/intern/IMB_anim.h8
-rw-r--r--source/blender/imbuf/intern/anim_movie.c4
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.c2
-rw-r--r--source/blender/imbuf/intern/dds/BlockDXT.cpp172
-rw-r--r--source/blender/imbuf/intern/dds/BlockDXT.h82
-rw-r--r--source/blender/imbuf/intern/dds/Color.h2
-rw-r--r--source/blender/imbuf/intern/dds/ColorBlock.cpp30
-rw-r--r--source/blender/imbuf/intern/dds/ColorBlock.h4
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp160
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.h48
-rw-r--r--source/blender/imbuf/intern/dds/FlipDXT.cpp114
-rw-r--r--source/blender/imbuf/intern/dds/Image.cpp4
-rw-r--r--source/blender/imbuf/intern/dds/Image.h2
-rw-r--r--source/blender/imbuf/intern/dds/PixelFormat.h66
-rw-r--r--source/blender/imbuf/intern/dds/Stream.cpp10
-rw-r--r--source/blender/imbuf/intern/dds/Stream.h8
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.cpp6
-rw-r--r--source/blender/imbuf/intern/oiio/openimageio_api.cpp2
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp29
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_multi.h2
-rw-r--r--source/blender/imbuf/intern/scaling.c2
-rw-r--r--source/blender/io/alembic/exporter/abc_archive.cc8
-rw-r--r--source/blender/io/alembic/exporter/abc_export_capi.cc20
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_transform.cc4
-rw-r--r--source/blender/io/alembic/intern/abc_reader_mesh.cc6
-rw-r--r--source/blender/io/alembic/tests/abc_export_test.cc20
-rw-r--r--source/blender/io/alembic/tests/abc_matrix_test.cc44
-rw-r--r--source/blender/io/collada/AnimationExporter.h10
-rw-r--r--source/blender/io/collada/AnimationImporter.h28
-rw-r--r--source/blender/io/collada/ArmatureExporter.cpp36
-rw-r--r--source/blender/io/collada/ArmatureExporter.h18
-rw-r--r--source/blender/io/collada/ArmatureImporter.cpp8
-rw-r--r--source/blender/io/collada/ArmatureImporter.h25
-rw-r--r--source/blender/io/collada/BCAnimationCurve.cpp6
-rw-r--r--source/blender/io/collada/BCAnimationCurve.h2
-rw-r--r--source/blender/io/collada/BCAnimationSampler.cpp16
-rw-r--r--source/blender/io/collada/BCAnimationSampler.h2
-rw-r--r--source/blender/io/collada/BCMath.cpp3
-rw-r--r--source/blender/io/collada/BCSampleData.h2
-rw-r--r--source/blender/io/collada/BlenderContext.cpp4
-rw-r--r--source/blender/io/collada/ControllerExporter.cpp8
-rw-r--r--source/blender/io/collada/ControllerExporter.h10
-rw-r--r--source/blender/io/collada/DocumentExporter.cpp40
-rw-r--r--source/blender/io/collada/DocumentImporter.cpp16
-rw-r--r--source/blender/io/collada/DocumentImporter.h8
-rw-r--r--source/blender/io/collada/EffectExporter.cpp20
-rw-r--r--source/blender/io/collada/ErrorHandler.h2
-rw-r--r--source/blender/io/collada/ExtraHandler.h2
-rw-r--r--source/blender/io/collada/GeometryExporter.cpp6
-rw-r--r--source/blender/io/collada/LightExporter.cpp12
-rw-r--r--source/blender/io/collada/MaterialExporter.cpp2
-rw-r--r--source/blender/io/collada/MaterialExporter.h6
-rw-r--r--source/blender/io/collada/Materials.cpp50
-rw-r--r--source/blender/io/collada/MeshImporter.cpp186
-rw-r--r--source/blender/io/collada/SkinInfo.h42
-rw-r--r--source/blender/io/collada/TransformReader.cpp10
-rw-r--r--source/blender/io/collada/TransformReader.h2
-rw-r--r--source/blender/io/collada/collada_internal.cpp16
-rw-r--r--source/blender/io/collada/collada_internal.h4
-rw-r--r--source/blender/io/common/IO_abstract_hierarchy_iterator.h12
-rw-r--r--source/blender/io/common/intern/abstract_hierarchy_iterator.cc71
-rw-r--r--source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc34
-rw-r--r--source/blender/io/common/intern/object_identifier_test.cc4
-rw-r--r--source/blender/io/usd/intern/usd_capi.cc14
-rw-r--r--source/blender/io/usd/intern/usd_writer_abstract.cc12
-rw-r--r--source/blender/io/usd/intern/usd_writer_camera.cc2
-rw-r--r--source/blender/io/usd/intern/usd_writer_hair.cc2
-rw-r--r--source/blender/io/usd/intern/usd_writer_mesh.cc8
-rw-r--r--source/blender/io/usd/intern/usd_writer_transform.cc4
-rw-r--r--source/blender/makesdna/DNA_action_types.h6
-rw-r--r--source/blender/makesdna/DNA_anim_types.h13
-rw-r--r--source/blender/makesdna/DNA_armature_defaults.h40
-rw-r--r--source/blender/makesdna/DNA_brush_types.h8
-rw-r--r--source/blender/makesdna/DNA_cloth_types.h4
-rw-r--r--source/blender/makesdna/DNA_collection_defaults.h37
-rw-r--r--source/blender/makesdna/DNA_fluid_defaults.h266
-rw-r--r--source/blender/makesdna/DNA_fluid_types.h1
-rw-r--r--source/blender/makesdna/DNA_genfile.h2
-rw-r--r--source/blender/makesdna/DNA_gpencil_modifier_defaults.h286
-rw-r--r--source/blender/makesdna/DNA_gpencil_modifier_types.h2
-rw-r--r--source/blender/makesdna/DNA_layer_types.h2
-rw-r--r--source/blender/makesdna/DNA_modifier_defaults.h2
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h2
-rw-r--r--source/blender/makesdna/DNA_movieclip_defaults.h50
-rw-r--r--source/blender/makesdna/DNA_node_types.h2
-rw-r--r--source/blender/makesdna/DNA_object_types.h14
-rw-r--r--source/blender/makesdna/DNA_particle_defaults.h113
-rw-r--r--source/blender/makesdna/DNA_particle_types.h2
-rw-r--r--source/blender/makesdna/DNA_scene_types.h21
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h24
-rw-r--r--source/blender/makesdna/DNA_shader_fx_types.h2
-rw-r--r--source/blender/makesdna/DNA_sound_types.h6
-rw-r--r--source/blender/makesdna/DNA_space_types.h12
-rw-r--r--source/blender/makesdna/DNA_texture_types.h5
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h12
-rw-r--r--source/blender/makesdna/intern/CMakeLists.txt3
-rw-r--r--source/blender/makesdna/intern/dna_defaults.c87
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c194
-rw-r--r--source/blender/makesrna/RNA_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_access_compare_override.c8
-rw-r--r--source/blender/makesrna/intern/rna_action.c6
-rw-r--r--source/blender/makesrna/intern/rna_attribute.c8
-rw-r--r--source/blender/makesrna/intern/rna_brush.c42
-rw-r--r--source/blender/makesrna/intern/rna_fluid.c25
-rw-r--r--source/blender/makesrna/intern/rna_gpencil_modifier.c16
-rw-r--r--source/blender/makesrna/intern/rna_layer.c2
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c4
-rw-r--r--source/blender/makesrna/intern/rna_particle.c1
-rw-r--r--source/blender/makesrna/intern/rna_render.c4
-rw-r--r--source/blender/makesrna/intern/rna_rigidbody.c10
-rw-r--r--source/blender/makesrna/intern/rna_scene.c22
-rw-r--r--source/blender/makesrna/intern/rna_sequencer_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_space.c64
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c40
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c11
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c34
-rw-r--r--source/blender/modifiers/intern/MOD_decimate.c9
-rw-r--r--source/blender/modifiers/intern/MOD_mesh_to_volume.cc21
-rw-r--r--source/blender/modifiers/intern/MOD_volume_displace.cc29
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weld.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_tonemap.c6
-rw-r--r--source/blender/python/BPY_extern.h3
-rw-r--r--source/blender/python/BPY_extern_python.h2
-rw-r--r--source/blender/python/bmesh/bmesh_py_api.c3
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops.c113
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_meshdata.c6
-rw-r--r--source/blender/python/generic/bgl.c3
-rw-r--r--source/blender/python/generic/bpy_threads.c11
-rw-r--r--source/blender/python/generic/py_capi_utils.c8
-rw-r--r--source/blender/python/gpu/gpu_py_api.c15
-rw-r--r--source/blender/python/gpu/gpu_py_batch.c4
-rw-r--r--source/blender/python/gpu/gpu_py_offscreen.c4
-rw-r--r--source/blender/python/gpu/gpu_py_shader.c95
-rw-r--r--source/blender/python/gpu/gpu_py_vertex_format.c11
-rw-r--r--source/blender/python/intern/bpy.c12
-rw-r--r--source/blender/python/intern/bpy.h4
-rw-r--r--source/blender/python/intern/bpy_app.c12
-rw-r--r--source/blender/python/intern/bpy_app_ffmpeg.c2
-rw-r--r--source/blender/python/intern/bpy_app_sdl.c4
-rw-r--r--source/blender/python/intern/bpy_capi_utils.c10
-rw-r--r--source/blender/python/intern/bpy_capi_utils.h4
-rw-r--r--source/blender/python/intern/bpy_driver.c4
-rw-r--r--source/blender/python/intern/bpy_interface.c27
-rw-r--r--source/blender/python/intern/bpy_interface_atexit.c2
-rw-r--r--source/blender/python/intern/bpy_library_load.c4
-rw-r--r--source/blender/python/intern/bpy_msgbus.c6
-rw-r--r--source/blender/python/intern/bpy_operator.c8
-rw-r--r--source/blender/python/intern/bpy_rna.c188
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c12
-rw-r--r--source/blender/python/intern/bpy_rna_gizmo.c4
-rw-r--r--source/blender/python/mathutils/mathutils.c15
-rw-r--r--source/blender/render/extern/include/RE_engine.h2
-rw-r--r--source/blender/sequencer/intern/sequencer.c10
-rw-r--r--source/blender/simulation/intern/ConstrainedConjugateGradient.h22
-rw-r--r--source/blender/simulation/intern/SIM_mass_spring.cpp14
-rw-r--r--source/blender/simulation/intern/implicit_blender.c110
-rw-r--r--source/blender/simulation/intern/implicit_eigen.cpp30
-rw-r--r--source/blender/windowmanager/WM_types.h1
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo.c2
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c2
-rw-r--r--source/blender/windowmanager/intern/wm.c67
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c5
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c26
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c66
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c631
-rw-r--r--source/blender/windowmanager/intern/wm_files.c58
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c12
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c20
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c24
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c11
-rw-r--r--source/blender/windowmanager/intern/wm_menu_type.c10
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c203
-rw-r--r--source/blender/windowmanager/intern/wm_panel_type.c10
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c32
-rw-r--r--source/blender/windowmanager/intern/wm_splash_screen.c20
-rw-r--r--source/blender/windowmanager/intern/wm_stereo.c9
-rw-r--r--source/blender/windowmanager/intern/wm_uilist_type.c10
-rw-r--r--source/blender/windowmanager/intern/wm_window.c253
-rw-r--r--source/creator/CMakeLists.txt5
-rw-r--r--source/creator/creator.c12
m---------source/tools0
625 files changed, 9367 insertions, 7165 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index bf84f5c57b3..17a650e28f5 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -163,8 +163,13 @@ float BLF_height_ex(int fontid, const char *str, size_t len, struct ResultBLF *r
float BLF_height(int fontid, const char *str, size_t len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
/* Return dimensions of the font without any sample text. */
+
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT;
+int BLF_default_height_max(void) ATTR_WARN_UNUSED_RESULT;
+
float BLF_width_max(int fontid) ATTR_WARN_UNUSED_RESULT;
+float BLF_default_width_max(void) ATTR_WARN_UNUSED_RESULT;
+
float BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT;
float BLF_ascender(int fontid) ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 547112ecf66..76ff498f5c2 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -38,6 +38,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_listBase.h"
+#include "DNA_userdef_types.h"
#include "DNA_vec_types.h"
#include "BLI_math.h"
@@ -47,6 +48,8 @@
#include "IMB_colormanagement.h"
+#include "UI_interface.h"
+
#include "GPU_immediate.h"
#include "GPU_matrix.h"
#include "GPU_shader.h"
@@ -75,7 +78,6 @@ static FontBLF *global_font[BLF_MAX_FONT] = {NULL};
/* Default size and dpi, for BLF_draw_default. */
static int global_font_default = -1;
-static int global_font_points = 11;
static int global_font_dpi = 72;
/* XXX, should these be made into global_font_'s too? */
@@ -96,7 +98,6 @@ int BLF_init(void)
global_font[i] = NULL;
}
- global_font_points = 11;
global_font_dpi = 72;
return blf_font_init();
@@ -518,7 +519,8 @@ void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
{
ASSERT_DEFAULT_SET;
- BLF_size(global_font_default, global_font_points, global_font_dpi);
+ const uiStyle *style = UI_style_get();
+ BLF_size(global_font_default, style->widgetlabel.points, global_font_dpi);
BLF_position(global_font_default, x, y, z);
BLF_draw(global_font_default, str, len);
}
@@ -528,7 +530,8 @@ void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t l
{
ASSERT_DEFAULT_SET;
- BLF_size(global_font_default, global_font_points, global_font_dpi);
+ const uiStyle *style = UI_style_get();
+ BLF_size(global_font_default, style->widgetlabel.points, global_font_dpi);
BLF_position(global_font_default, x, y, z);
BLF_draw_ascii(global_font_default, str, len); /* XXX, use real length */
}
@@ -537,7 +540,8 @@ int BLF_set_default(void)
{
ASSERT_DEFAULT_SET;
- BLF_size(global_font_default, global_font_points, global_font_dpi);
+ const uiStyle *style = UI_style_get();
+ BLF_size(global_font_default, style->widgetlabel.points, global_font_dpi);
return global_font_default;
}
@@ -600,6 +604,9 @@ void BLF_draw(int fontid, const char *str, size_t len)
return;
}
+ /* Avoid bgl usage to corrupt BLF drawing. */
+ GPU_bgl_end();
+
BLF_draw_ex(fontid, str, len, NULL);
}
@@ -817,6 +824,11 @@ int BLF_height_max(int fontid)
return 0;
}
+int BLF_default_height_max(void)
+{
+ return BLF_height_max(global_font_default);
+}
+
float BLF_width_max(int fontid)
{
FontBLF *font = blf_get(fontid);
@@ -828,6 +840,11 @@ float BLF_width_max(int fontid)
return 0.0f;
}
+float BLF_default_width_max(void)
+{
+ return BLF_width_max(global_font_default);
+}
+
float BLF_descender(int fontid)
{
FontBLF *font = blf_get(fontid);
diff --git a/source/blender/blenkernel/BKE_addon.h b/source/blender/blenkernel/BKE_addon.h
index 73e3f6e41dc..03d29d47a83 100644
--- a/source/blender/blenkernel/BKE_addon.h
+++ b/source/blender/blenkernel/BKE_addon.h
@@ -29,7 +29,7 @@ struct bAddon;
#ifdef __RNA_TYPES_H__
typedef struct bAddonPrefType {
/* type info */
- char idname[64]; // best keep the same size as BKE_ST_MAXNAME
+ char idname[64]; /* best keep the same size as #BKE_ST_MAXNAME */
/* RNA integration */
ExtensionRNA rna_ext;
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index e9819e6ea87..2007d150c6a 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -152,6 +152,16 @@ void BKE_animdata_fix_paths_rename_all(struct ID *ref_id,
const char *oldName,
const char *newName);
+/* Fix all the paths for the entire bmain with extra parameters. */
+void BKE_animdata_fix_paths_rename_all_ex(struct Main *bmain,
+ struct ID *ref_id,
+ const char *prefix,
+ const char *oldName,
+ const char *newName,
+ const int oldSubscript,
+ const int newSubscript,
+ const bool verify_paths);
+
/* Fix the path after removing elements that are not ID (e.g., node).
* Return true if any animation data was affected. */
bool BKE_animdata_fix_paths_remove(struct ID *id, const char *path);
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index bd10deb216b..aed4dad05ad 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 7
+#define BLENDER_FILE_SUBVERSION 8
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h
index 965bb7b737e..3a5328a33e2 100644
--- a/source/blender/blenkernel/BKE_collision.h
+++ b/source/blender/blenkernel/BKE_collision.h
@@ -63,14 +63,14 @@ typedef enum {
////////////////////////////////////////
/* used for collisions in collision.c */
typedef struct CollPair {
- unsigned int face1; // cloth face
- unsigned int face2; // object face
+ unsigned int face1; /* cloth face */
+ unsigned int face2; /* object face */
float distance;
float normal[3];
- float vector[3]; // unnormalized collision vector: p2-p1
- float pa[3], pb[3]; // collision point p1 on face1, p2 on face2
+ float vector[3]; /* unnormalized collision vector: p2-p1 */
+ float pa[3], pb[3]; /* collision point p1 on face1, p2 on face2 */
int flag;
- float time; // collision time, from 0 up to 1
+ float time; /* collision time, from 0 up to 1 */
/* mesh-mesh collision */
#ifdef WITH_ELTOPO /*either ap* or bp* can be set, but not both*/
@@ -90,7 +90,7 @@ typedef struct EdgeCollPair {
float vector[3];
float time;
int lastsign;
- float pa[3], pb[3]; // collision point p1 on face1, p2 on face2
+ float pa[3], pb[3]; /* collision point p1 on face1, p2 on face2 */
} EdgeCollPair;
/* used for collisions in collision.c */
@@ -100,7 +100,7 @@ typedef struct FaceCollPair {
float vector[3];
float time;
int lastsign;
- float pa[3], pb[3]; // collision point p1 on face1, p2 on face2
+ float pa[3], pb[3]; /* collision point p1 on face1, p2 on face2 */
} FaceCollPair;
////////////////////////////////////////
@@ -126,8 +126,8 @@ void bvhtree_update_from_mvert(BVHTree *bvhtree,
/////////////////////////////////////////////////
-// move Collision modifier object inter-frame with step = [0,1]
-// defined in collisions.c
+/* move Collision modifier object inter-frame with step = [0,1]
+ * defined in collisions.c */
void collision_move_object(struct CollisionModifierData *collmd,
const float step,
const float prevstep,
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 2b238ef18f5..dcb4a993da1 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -22,8 +22,6 @@
* \ingroup bke
*/
-#include "BKE_mesh_types.h"
-
#include "DNA_scene_types.h"
#ifdef __cplusplus
@@ -160,6 +158,8 @@ void BKE_curve_rect_from_textbox(const struct Curve *cu,
const struct TextBox *tb,
struct rctf *r_rect);
+void BKE_curve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2]);
+
/* ** Nurbs ** */
bool BKE_nurbList_index_get_co(struct ListBase *editnurb, const int index, float r_co[3]);
@@ -277,10 +277,10 @@ enum {
BKE_CURVE_BATCH_DIRTY_ALL = 0,
BKE_CURVE_BATCH_DIRTY_SELECT,
};
-void BKE_curve_batch_cache_dirty_tag(struct Curve *cu, eMeshBatchDirtyMode mode);
+void BKE_curve_batch_cache_dirty_tag(struct Curve *cu, int mode);
void BKE_curve_batch_cache_free(struct Curve *cu);
-extern void (*BKE_curve_batch_cache_dirty_tag_cb)(struct Curve *cu, eMeshBatchDirtyMode mode);
+extern void (*BKE_curve_batch_cache_dirty_tag_cb)(struct Curve *cu, int mode);
extern void (*BKE_curve_batch_cache_free_cb)(struct Curve *cu);
/* -------------------------------------------------------------------- */
diff --git a/source/blender/blenkernel/BKE_editmesh.h b/source/blender/blenkernel/BKE_editmesh.h
index 819e91b438e..6febbb4e136 100644
--- a/source/blender/blenkernel/BKE_editmesh.h
+++ b/source/blender/blenkernel/BKE_editmesh.h
@@ -99,6 +99,13 @@ float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph *depsgraph,
struct Object *ob,
int *r_vert_len))[3];
float (*BKE_editmesh_vert_coords_alloc_orco(BMEditMesh *em, int *r_vert_len))[3];
+const float (*BKE_editmesh_vert_coords_when_deformed(struct Depsgraph *depsgraph,
+ struct BMEditMesh *em,
+ struct Scene *scene,
+ struct Object *obedit,
+ int *r_vert_len,
+ bool *r_is_alloc))[3];
+
void BKE_editmesh_lnorspace_update(BMEditMesh *em, struct Mesh *me);
void BKE_editmesh_ensure_autosmooth(BMEditMesh *em, struct Mesh *me);
struct BoundBox *BKE_editmesh_cage_boundbox_get(BMEditMesh *em);
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index e42d1cbbc78..c9bc5e83a1f 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -57,8 +57,6 @@ typedef struct CfraElem {
int sel;
} CfraElem;
-void bezt_add_to_cfra_elem(ListBase *lb, struct BezTriple *bezt);
-
/* ************** F-Curve Modifiers *************** */
/* F-Curve Modifier Type-Info (fmi):
@@ -229,7 +227,10 @@ struct FCurve *BKE_fcurve_find_by_rna_context_ui(struct bContext *C,
/* Binary search algorithm for finding where to 'insert' BezTriple with given frame number.
* Returns the index to insert at (data already at that index will be offset if replace is 0)
*/
-int binarysearch_bezt_index(struct BezTriple array[], float frame, int arraylen, bool *r_replace);
+int BKE_fcurve_bezt_binarysearch_index(struct BezTriple array[],
+ float frame,
+ int arraylen,
+ bool *r_replace);
/* get the time extents for F-Curve */
bool BKE_fcurve_calc_range(
@@ -270,17 +271,11 @@ typedef enum eFCU_Cycle_Type {
eFCU_Cycle_Type BKE_fcurve_get_cycle_type(struct FCurve *fcu);
-/** Adjust Bezier handles of all three given BezTriples, so that `bezt` can be inserted between
- * `prev` and `next` without changing the resulting curve shape.
- *
- * \param r_pdelta: return Y difference between `bezt` and the original curve value at its X
- * position.
- * \return Whether the split was succesful.
- */
-bool BKE_bezt_subdivide_handles(struct BezTriple *bezt,
- struct BezTriple *prev,
- struct BezTriple *next,
- float *r_pdelta);
+/* Recompute handles to neatly subdivide the prev-next range at bezt. */
+bool BKE_fcurve_bezt_subdivide_handles(struct BezTriple *bezt,
+ struct BezTriple *prev,
+ struct BezTriple *next,
+ float *r_pdelta);
/* -------- Curve Sanity -------- */
@@ -290,7 +285,7 @@ void testhandles_fcurve(struct FCurve *fcu, eBezTriple_Flag sel_flag, const bool
void sort_time_fcurve(struct FCurve *fcu);
bool test_time_fcurve(struct FCurve *fcu);
-void correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2]);
+void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2]);
/* -------- Evaluation -------- */
diff --git a/source/blender/blenkernel/BKE_hair.h b/source/blender/blenkernel/BKE_hair.h
index 1d7985e5c98..403e461a9dc 100644
--- a/source/blender/blenkernel/BKE_hair.h
+++ b/source/blender/blenkernel/BKE_hair.h
@@ -16,8 +16,6 @@
#pragma once
-#include "BKE_mesh_types.h"
-
/** \file
* \ingroup bke
* \brief General operations for hairs.
@@ -54,10 +52,10 @@ enum {
BKE_HAIR_BATCH_DIRTY_ALL = 0,
};
-void BKE_hair_batch_cache_dirty_tag(struct Hair *hair, eMeshBatchDirtyMode mode);
+void BKE_hair_batch_cache_dirty_tag(struct Hair *hair, int mode);
void BKE_hair_batch_cache_free(struct Hair *hair);
-extern void (*BKE_hair_batch_cache_dirty_tag_cb)(struct Hair *hair, eMeshBatchDirtyMode mode);
+extern void (*BKE_hair_batch_cache_dirty_tag_cb)(struct Hair *hair, int mode);
extern void (*BKE_hair_batch_cache_free_cb)(struct Hair *hair);
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index e3d69166b62..c969ce07d74 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -39,7 +39,6 @@ extern "C" {
void BKE_key_free(struct Key *key);
void BKE_key_free_nolib(struct Key *key);
struct Key *BKE_key_add(struct Main *bmain, struct ID *id);
-struct Key *BKE_key_copy_nolib(struct Key *key);
void BKE_key_sort(struct Key *key);
void key_curve_position_weights(float t, float data[4], int type);
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index 0396d050b35..f4c1a6fdcb4 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -22,7 +22,6 @@
/** \file
* \ingroup bke
*/
-#include "BKE_mesh_types.h"
#include "BLI_compiler_attrs.h"
@@ -92,10 +91,10 @@ enum {
BKE_LATTICE_BATCH_DIRTY_ALL = 0,
BKE_LATTICE_BATCH_DIRTY_SELECT,
};
-void BKE_lattice_batch_cache_dirty_tag(struct Lattice *lt, eMeshBatchDirtyMode mode);
+void BKE_lattice_batch_cache_dirty_tag(struct Lattice *lt, int mode);
void BKE_lattice_batch_cache_free(struct Lattice *lt);
-extern void (*BKE_lattice_batch_cache_dirty_tag_cb)(struct Lattice *lt, eMeshBatchDirtyMode mode);
+extern void (*BKE_lattice_batch_cache_dirty_tag_cb)(struct Lattice *lt, int mode);
extern void (*BKE_lattice_batch_cache_free_cb)(struct Lattice *lt);
/* -------------------------------------------------------------------- */
diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h
index 80092c1d61a..29072742f81 100644
--- a/source/blender/blenkernel/BKE_mask.h
+++ b/source/blender/blenkernel/BKE_mask.h
@@ -141,9 +141,6 @@ void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point,
/* general */
struct Mask *BKE_mask_new(struct Main *bmain, const char *name);
-struct Mask *BKE_mask_copy_nolib(struct Mask *mask);
-
-void BKE_mask_free(struct Mask *mask);
void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2]);
void BKE_mask_coord_from_movieclip(struct MovieClip *clip,
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h
index 8a294c96e26..db4dca14535 100644
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@ -22,8 +22,6 @@
* \ingroup bke
*/
-#include "BKE_mesh_types.h"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -83,10 +81,10 @@ struct Depsgraph;
enum {
BKE_MBALL_BATCH_DIRTY_ALL = 0,
};
-void BKE_mball_batch_cache_dirty_tag(struct MetaBall *mb, eMeshBatchDirtyMode mode);
+void BKE_mball_batch_cache_dirty_tag(struct MetaBall *mb, int mode);
void BKE_mball_batch_cache_free(struct MetaBall *mb);
-extern void (*BKE_mball_batch_cache_dirty_tag_cb)(struct MetaBall *mb, eMeshBatchDirtyMode mode);
+extern void (*BKE_mball_batch_cache_dirty_tag_cb)(struct MetaBall *mb, int mode);
extern void (*BKE_mball_batch_cache_free_cb)(struct MetaBall *mb);
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index a61e453ec52..fdea26ce730 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -673,7 +673,7 @@ void BKE_mesh_strip_loose_edges(struct Mesh *me);
void BKE_mesh_calc_edges_legacy(struct Mesh *me, const bool use_old);
void BKE_mesh_calc_edges_loose(struct Mesh *mesh);
-void BKE_mesh_calc_edges(struct Mesh *mesh, bool update, const bool select);
+void BKE_mesh_calc_edges(struct Mesh *mesh, bool keep_existing_edges, const bool select_new_edges);
void BKE_mesh_calc_edges_tessface(struct Mesh *mesh);
/* In DerivedMesh.c */
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index a7a837406ac..150d0d9b011 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -270,10 +270,13 @@ typedef enum eSculptClothConstraintType {
/* Constraint that creates the structure of the cloth. */
SCULPT_CLOTH_CONSTRAINT_STRUCTURAL = 0,
/* Constraint that references the position of a vertex and a position in deformation_pos which
- can be deformed by the tools. */
+ * can be deformed by the tools. */
SCULPT_CLOTH_CONSTRAINT_DEFORMATION = 1,
- /* Constarint that references the vertex position and its initial position. */
+ /* Constraint that references the vertex position and a editable soft-body position for
+ * plasticity. */
SCULPT_CLOTH_CONSTRAINT_SOFTBODY = 2,
+ /* Constraint that references the vertex position and its initial position. */
+ SCULPT_CLOTH_CONSTRAINT_PIN = 3,
} eSculptClothConstraintType;
typedef struct SculptClothLengthConstraint {
@@ -292,7 +295,7 @@ typedef struct SculptClothLengthConstraint {
float length;
float strength;
- /* Index in SculptClothSimulation.node_state of the node from where this constraint was created.
+ /* Index in #SculptClothSimulation.node_state of the node from where this constraint was created.
* This constraints will only be used by the solver if the state is active. */
int node;
@@ -314,17 +317,19 @@ typedef struct SculptClothSimulation {
float mass;
float damping;
+ float softbody_strength;
float (*acceleration)[3];
float (*pos)[3];
float (*init_pos)[3];
+ float (*softbody_pos)[3];
float (*prev_pos)[3];
float (*last_iteration_pos)[3];
struct ListBase *collider_list;
int totnode;
- /* PBVHNode pointer as a key, index in SculptClothSimulation.node_state as value. */
+ /** #PBVHNode pointer as a key, index in #SculptClothSimulation.node_state as value. */
struct GHash *node_state_index;
eSculptClothNodeSimState *node_state;
} SculptClothSimulation;
@@ -336,7 +341,7 @@ typedef struct SculptPersistentBase {
} SculptPersistentBase;
typedef struct SculptVertexInfo {
- /* Idexed by vertex, stores and ID of its topologycally connected component. */
+ /* Indexed by vertex, stores and ID of its topologically connected component. */
int *connected_component;
/* Indexed by base mesh vertex index, stores if that vertex is a boundary. */
@@ -424,7 +429,7 @@ typedef struct SculptFakeNeighbors {
/* Max distance used to calculate neighborhood information. */
float current_max_distance;
- /* Idexed by vertex, stores the vertex index of its fake neighbor if available. */
+ /* Indexed by vertex, stores the vertex index of its fake neighbor if available. */
int *fake_neighbor_index;
} SculptFakeNeighbors;
@@ -506,6 +511,11 @@ typedef struct SculptSession {
float cursor_sampled_normal[3];
float cursor_view_normal[3];
+ /* For Sculpt trimming gesture tools, initial raycast data from the position of the mouse when
+ * the gesture starts (intersection with the surface and if they ray hit the surface or not). */
+ float gesture_initial_location[3];
+ bool gesture_initial_hit;
+
/* TODO(jbakker): Replace rv3d adn v3d with ViewContext */
struct RegionView3D *rv3d;
struct View3D *v3d;
@@ -602,6 +612,11 @@ void BKE_sculpt_bvh_update_from_ccg(struct PBVH *pbvh, struct SubdivCCG *subdiv_
* updated according to the face sets. */
void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG *subdiv_ccg);
+/* Individual function to sync the Face Set visibility to mesh and grids. */
+void BKE_sculpt_sync_face_sets_visibility_to_base_mesh(struct Mesh *mesh);
+void BKE_sculpt_sync_face_sets_visibility_to_grids(struct Mesh *mesh,
+ struct SubdivCCG *subdiv_ccg);
+
/* Ensures that a Face Set data-layers exists. If it does not, it creates one respecting the
* visibility stored in the vertices of the mesh. If it does, it copies the visibility from the
* mesh to the Face Sets. */
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index f726b48ebeb..6ed3b94b8e5 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -33,7 +33,6 @@
#include "DNA_particle_types.h"
#include "BKE_customdata.h"
-#include "BKE_mesh_types.h"
#ifdef __cplusplus
extern "C" {
@@ -620,11 +619,10 @@ void BKE_particle_system_eval_init(struct Depsgraph *depsgraph, struct Object *o
enum {
BKE_PARTICLE_BATCH_DIRTY_ALL = 0,
};
-void BKE_particle_batch_cache_dirty_tag(struct ParticleSystem *psys, eMeshBatchDirtyMode mode);
+void BKE_particle_batch_cache_dirty_tag(struct ParticleSystem *psys, int mode);
void BKE_particle_batch_cache_free(struct ParticleSystem *psys);
-extern void (*BKE_particle_batch_cache_dirty_tag_cb)(struct ParticleSystem *psys,
- eMeshBatchDirtyMode mode);
+extern void (*BKE_particle_batch_cache_dirty_tag_cb)(struct ParticleSystem *psys, int mode);
extern void (*BKE_particle_batch_cache_free_cb)(struct ParticleSystem *psys);
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/BKE_pointcloud.h b/source/blender/blenkernel/BKE_pointcloud.h
index 682797991bd..985a8cc3ca7 100644
--- a/source/blender/blenkernel/BKE_pointcloud.h
+++ b/source/blender/blenkernel/BKE_pointcloud.h
@@ -20,9 +20,6 @@
* \ingroup bke
* \brief General operations for point-clouds.
*/
-
-#include "BKE_mesh_types.h"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -64,11 +61,10 @@ enum {
BKE_POINTCLOUD_BATCH_DIRTY_ALL = 0,
};
-void BKE_pointcloud_batch_cache_dirty_tag(struct PointCloud *pointcloud, eMeshBatchDirtyMode mode);
+void BKE_pointcloud_batch_cache_dirty_tag(struct PointCloud *pointcloud, int mode);
void BKE_pointcloud_batch_cache_free(struct PointCloud *pointcloud);
-extern void (*BKE_pointcloud_batch_cache_dirty_tag_cb)(struct PointCloud *pointcloud,
- eMeshBatchDirtyMode mode);
+extern void (*BKE_pointcloud_batch_cache_dirty_tag_cb)(struct PointCloud *pointcloud, int mode);
extern void (*BKE_pointcloud_batch_cache_free_cb)(struct PointCloud *pointcloud);
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 20190817a8e..7ac980e9d94 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -115,7 +115,7 @@ struct Scene *BKE_scene_find_from_collection(const struct Main *bmain,
const struct Collection *collection);
#ifdef DURIAN_CAMERA_SWITCH
-struct Object *BKE_scene_camera_switch_find(struct Scene *scene); // DURIAN_CAMERA_SWITCH
+struct Object *BKE_scene_camera_switch_find(struct Scene *scene); /* DURIAN_CAMERA_SWITCH */
#endif
bool BKE_scene_camera_switch_update(struct Scene *scene);
diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h
index b0923be8434..d1cffd26432 100644
--- a/source/blender/blenkernel/BKE_softbody.h
+++ b/source/blender/blenkernel/BKE_softbody.h
@@ -40,7 +40,7 @@ typedef struct BodyPoint {
int *springs;
float choke, choke2, frozen;
float colball;
- short loc_flag; // reserved by locale module specific states
+ short loc_flag; /* reserved by locale module specific states */
// char octantflag;
float mass;
float springweight;
diff --git a/source/blender/blenkernel/BKE_volume.h b/source/blender/blenkernel/BKE_volume.h
index f48f417ab6d..2a272d06986 100644
--- a/source/blender/blenkernel/BKE_volume.h
+++ b/source/blender/blenkernel/BKE_volume.h
@@ -16,8 +16,6 @@
#pragma once
-#include "BKE_mesh_types.h"
-
/** \file
* \ingroup bke
* \brief Volume datablock.
@@ -66,11 +64,10 @@ enum {
BKE_VOLUME_BATCH_DIRTY_ALL = 0,
};
-void BKE_volume_batch_cache_dirty_tag(struct Volume *volume, eMeshBatchDirtyMode mode);
+void BKE_volume_batch_cache_dirty_tag(struct Volume *volume, int mode);
void BKE_volume_batch_cache_free(struct Volume *volume);
-extern void (*BKE_volume_batch_cache_dirty_tag_cb)(struct Volume *volume,
- eMeshBatchDirtyMode mode);
+extern void (*BKE_volume_batch_cache_dirty_tag_cb)(struct Volume *volume, int mode);
extern void (*BKE_volume_batch_cache_free_cb)(struct Volume *volume);
/* Grids
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 63e98b94852..0fbc8c4c229 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -175,6 +175,7 @@ set(SRC
intern/mesh_runtime.c
intern/mesh_tangent.c
intern/mesh_validate.c
+ intern/mesh_validate.cc
intern/mesh_wrapper.c
intern/modifier.c
intern/movieclip.c
@@ -690,6 +691,18 @@ if(WITH_XR_OPENXR)
add_definitions(-DWITH_XR_OPENXR)
endif()
+if(WITH_TBB)
+ add_definitions(-DWITH_TBB)
+
+ list(APPEND INC_SYS
+ ${TBB_INCLUDE_DIRS}
+ )
+
+ list(APPEND LIB
+ ${TBB_LIBRARIES}
+ )
+endif()
+
# # Warnings as errors, this is too strict!
# if(MSVC)
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index ec2fb5f5bdb..d63c5fe12ab 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <string.h>
-#include "BLI_sys_types.h" // for intptr_t support
+#include "BLI_sys_types.h" /* for intptr_t support */
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h" /* for BLI_assert */
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c
index 22a4bf18f7f..99ea1fb9607 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c
@@ -18,7 +18,7 @@
* \ingroup bke
*/
-#include "BLI_sys_types.h" // for intptr_t support
+#include "BLI_sys_types.h" /* for intptr_t support */
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_util.c b/source/blender/blenkernel/intern/CCGSubSurf_util.c
index bc63d8b97f7..3941b42d4b3 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_util.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf_util.c
@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <string.h>
-#include "BLI_sys_types.h" // for intptr_t support
+#include "BLI_sys_types.h" /* for intptr_t support */
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h" /* for BLI_assert */
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 88d8073b989..d551eaf04e4 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1488,8 +1488,10 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
/* Modifier evaluation modes. */
const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
+ const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
/* Modifier evaluation contexts for different types of modifiers. */
- const ModifierEvalContext mectx = {depsgraph, ob, MOD_APPLY_USECACHE};
+ ModifierApplyFlag apply_render = use_render ? MOD_APPLY_RENDER : 0;
+ const ModifierEvalContext mectx = {depsgraph, ob, MOD_APPLY_USECACHE | apply_render};
const ModifierEvalContext mectx_orco = {depsgraph, ob, MOD_APPLY_ORCO};
/* Get effective list of modifiers to execute. Some effects like shape keys
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 1f8c1cca113..8f47739151e 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -199,17 +199,17 @@ static void action_blend_read_data(BlendDataReader *reader, ID *id)
bAction *act = (bAction *)id;
BLO_read_list(reader, &act->curves);
- BLO_read_list(reader, &act->chanbase); // XXX deprecated - old animation system
+ BLO_read_list(reader, &act->chanbase); /* XXX deprecated - old animation system */
BLO_read_list(reader, &act->groups);
BLO_read_list(reader, &act->markers);
- // XXX deprecated - old animation system <<<
+ /* XXX deprecated - old animation system <<< */
LISTBASE_FOREACH (bActionChannel *, achan, &act->chanbase) {
BLO_read_data_address(reader, &achan->grp);
BLO_read_list(reader, &achan->constraintChannels);
}
- // >>> XXX deprecated - old animation system
+ /* >>> XXX deprecated - old animation system */
BKE_fcurve_blend_read_data(reader, &act->curves);
@@ -230,12 +230,12 @@ static void action_blend_read_lib(BlendLibReader *reader, ID *id)
{
bAction *act = (bAction *)id;
- // XXX deprecated - old animation system <<<
+ /* XXX deprecated - old animation system <<< */
LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
BLO_read_id_address(reader, act->id.lib, &chan->ipo);
blend_read_lib_constraint_channels(reader, &act->id, &chan->constraintChannels);
}
- // >>> XXX deprecated - old animation system
+ /* >>> XXX deprecated - old animation system */
BKE_fcurve_blend_read_lib(reader, &act->id, &act->curves);
@@ -257,12 +257,12 @@ static void action_blend_read_expand(BlendExpander *expander, ID *id)
{
bAction *act = (bAction *)id;
- // XXX deprecated - old animation system --------------
+ /* XXX deprecated - old animation system -------------- */
LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
BLO_expand(expander, chan->ipo);
blend_read_expand_constraint_channels(expander, &chan->constraintChannels);
}
- // ---------------------------------------------------
+ /* --------------------------------------------------- */
/* F-Curves in Action */
BKE_fcurve_blend_read_expand(expander, &act->curves);
@@ -303,7 +303,7 @@ bAction *BKE_action_add(Main *bmain, const char name[])
{
bAction *act;
- act = BKE_libblock_alloc(bmain, ID_AC, name, 0);
+ act = BKE_id_new(bmain, ID_AC, name);
return act;
}
@@ -827,7 +827,7 @@ void BKE_pose_copy_data_ex(bPose **dst,
if (copy_constraints) {
BKE_constraints_copy_ex(
- &listb, &pchan->constraints, flag, true); // BKE_constraints_copy NULLs listb
+ &listb, &pchan->constraints, flag, true); /* BKE_constraints_copy NULLs listb */
pchan->constraints = listb;
/* XXX: This is needed for motionpath drawing to work.
diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c
index 6ff705a0379..a85509b11db 100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -1406,13 +1406,30 @@ void BKE_animdata_main_cb(Main *bmain, ID_AnimData_Edit_Callback func, void *use
* NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]>
* i.e. pose.bones["Bone"]
*/
-/* TODO: use BKE_animdata_main_cb for looping over all data */
void BKE_animdata_fix_paths_rename_all(ID *ref_id,
const char *prefix,
const char *oldName,
const char *newName)
{
Main *bmain = G.main; /* XXX UGLY! */
+ BKE_animdata_fix_paths_rename_all_ex(bmain, ref_id, prefix, oldName, newName, 0, 0, 1);
+}
+
+/* Fix all RNA-Paths throughout the database
+ * NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]>
+ * i.e. pose.bones["Bone"]
+ */
+/* TODO: use BKE_animdata_main_cb for looping over all data */
+void BKE_animdata_fix_paths_rename_all_ex(Main *bmain,
+ ID *ref_id,
+ const char *prefix,
+ const char *oldName,
+ const char *newName,
+ const int oldSubscript,
+ const int newSubscript,
+ const bool verify_paths)
+{
+
ID *id;
/* macro for less typing
@@ -1422,7 +1439,8 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id,
#define RENAMEFIX_ANIM_IDS(first) \
for (id = first; id; id = id->next) { \
AnimData *adt = BKE_animdata_from_id(id); \
- BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 0, 0, 1); \
+ BKE_animdata_fix_paths_rename( \
+ id, adt, ref_id, prefix, oldName, newName, oldSubscript, newSubscript, verify_paths); \
} \
(void)0
@@ -1433,10 +1451,18 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id,
NtId_Type *ntp = (NtId_Type *)id; \
if (ntp->nodetree) { \
AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \
- BKE_animdata_fix_paths_rename( \
- (ID *)ntp->nodetree, adt2, ref_id, prefix, oldName, newName, 0, 0, 1); \
+ BKE_animdata_fix_paths_rename((ID *)ntp->nodetree, \
+ adt2, \
+ ref_id, \
+ prefix, \
+ oldName, \
+ newName, \
+ oldSubscript, \
+ newSubscript, \
+ verify_paths); \
} \
- BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 0, 0, 1); \
+ BKE_animdata_fix_paths_rename( \
+ id, adt, ref_id, prefix, oldName, newName, oldSubscript, newSubscript, verify_paths); \
} \
(void)0
@@ -1527,14 +1553,14 @@ void BKE_animdata_blend_write(BlendWriter *writer, struct AnimData *adt)
BKE_fcurve_blend_write(writer, &adt->drivers);
/* write overrides */
- // FIXME: are these needed?
+ /* FIXME: are these needed? */
LISTBASE_FOREACH (AnimOverride *, aor, &adt->overrides) {
/* overrides consist of base data + rna_path */
BLO_write_struct(writer, AnimOverride, aor);
BLO_write_string(writer, aor->rna_path);
}
- // TODO write the remaps (if they are needed)
+ /* TODO write the remaps (if they are needed) */
/* write NLA data */
BKE_nla_blend_write(writer, &adt->nla_tracks);
@@ -1553,7 +1579,7 @@ void BKE_animdata_blend_read_data(BlendDataReader *reader, AnimData *adt)
adt->driver_array = NULL;
/* link overrides */
- // TODO...
+ /* TODO... */
/* link NLA-data */
BLO_read_list(reader, &adt->nla_tracks);
@@ -1563,8 +1589,8 @@ void BKE_animdata_blend_read_data(BlendDataReader *reader, AnimData *adt)
* if we're in 'tweaking mode', we need to be able to have this loaded back for
* undo, but also since users may not exit tweakmode before saving (T24535)
*/
- // TODO: it's not really nice that anyone should be able to save the file in this
- // state, but it's going to be too hard to enforce this single case...
+ /* TODO: it's not really nice that anyone should be able to save the file in this
+ * state, but it's going to be too hard to enforce this single case... */
BLO_read_data_address(reader, &adt->act_track);
BLO_read_data_address(reader, &adt->actstrip);
}
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index ed8c811c116..1406ee02afd 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -38,6 +38,8 @@
#include "BLI_utildefines.h"
#include "BLT_translation.h"
+#include "DNA_defaults.h"
+
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_listBase.h"
@@ -87,6 +89,14 @@ static void copy_bonechildren_custom_handles(Bone *bone_dst, bArmature *arm_dst)
/** \name Armature Data-block
* \{ */
+static void armature_init_data(ID *id)
+{
+ bArmature *armature = (bArmature *)id;
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(armature, id));
+
+ MEMCPY_STRUCT_AFTER(armature, DNA_struct_default_get(bArmature), id);
+}
+
/**
* Only copy internal data of Armature ID from source
* to already allocated/initialized destination.
@@ -308,7 +318,7 @@ IDTypeInfo IDType_ID_AR = {
.translation_context = BLT_I18NCONTEXT_ID_ARMATURE,
.flags = 0,
- .init_data = NULL,
+ .init_data = armature_init_data,
.copy_data = armature_copy_data,
.free_data = armature_free_data,
.make_local = NULL,
@@ -331,10 +341,7 @@ bArmature *BKE_armature_add(Main *bmain, const char *name)
{
bArmature *arm;
- arm = BKE_libblock_alloc(bmain, ID_AR, name, 0);
- arm->deformflag = ARM_DEF_VGROUP | ARM_DEF_ENVELOPE;
- arm->flag = ARM_COL_CUSTOM; /* custom bone-group colors */
- arm->layer = 1;
+ arm = BKE_id_new(bmain, ID_AR, name);
return arm;
}
diff --git a/source/blender/blenkernel/intern/armature_test.cc b/source/blender/blenkernel/intern/armature_test.cc
index cf17c37bc69..f3c0d2f407a 100644
--- a/source/blender/blenkernel/intern/armature_test.cc
+++ b/source/blender/blenkernel/intern/armature_test.cc
@@ -34,7 +34,7 @@ TEST(mat3_vec_to_roll, UnitMatrix)
unit_m3(unit_matrix);
- // Any vector with a unit matrix should return zero roll.
+ /* Any vector with a unit matrix should return zero roll. */
mat3_vec_to_roll(unit_matrix, unit_matrix[0], &roll);
EXPECT_FLOAT_EQ(0.0f, roll);
@@ -45,12 +45,12 @@ TEST(mat3_vec_to_roll, UnitMatrix)
EXPECT_FLOAT_EQ(0.0f, roll);
{
- // Non-unit vector.
+ /* Non-unit vector. */
float vector[3] = {1.0f, 1.0f, 1.0f};
mat3_vec_to_roll(unit_matrix, vector, &roll);
EXPECT_NEAR(0.0f, roll, FLOAT_EPSILON);
- // Normalized version of the above vector.
+ /* Normalized version of the above vector. */
normalize_v3(vector);
mat3_vec_to_roll(unit_matrix, vector, &roll);
EXPECT_NEAR(0.0f, roll, FLOAT_EPSILON);
diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c
index a6f84f3c3a4..9e061b1ac69 100644
--- a/source/blender/blenkernel/intern/blender_undo.c
+++ b/source/blender/blenkernel/intern/blender_undo.c
@@ -22,9 +22,9 @@
*/
#ifndef _WIN32
-# include <unistd.h> // for read close
+# include <unistd.h> /* for read close */
#else
-# include <io.h> // for open close read
+# include <io.h> /* for open close read */
#endif
#include <errno.h>
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 9dabbb021b6..567773507cf 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -330,7 +330,9 @@ static void setup_app_data(bContext *C,
#ifdef WITH_PYTHON
/* let python know about new main */
- BPY_context_update(C);
+ if (CTX_py_init_get(C)) {
+ BPY_context_update(C);
+ }
#endif
/* FIXME: this version patching should really be part of the file-reading code,
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 3dfddbeed24..da4d9ea485c 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -455,9 +455,7 @@ Brush *BKE_brush_add(Main *bmain, const char *name, const eObjectMode ob_mode)
{
Brush *brush;
- brush = BKE_libblock_alloc(bmain, ID_BR, name, 0);
-
- brush_init_data(&brush->id);
+ brush = BKE_id_new(bmain, ID_BR, name);
brush->ob_mode = ob_mode;
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index 8abf5515645..0ee0242866f 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -247,9 +247,7 @@ static void cachefile_handle_free(CacheFile *cache_file)
void *BKE_cachefile_add(Main *bmain, const char *name)
{
- CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, name, 0);
-
- cache_file_init_data(&cache_file->id);
+ CacheFile *cache_file = BKE_id_new(bmain, ID_CF, name);
return cache_file;
}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index d54bebeafb9..3980a552855 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -213,9 +213,7 @@ void *BKE_camera_add(Main *bmain, const char *name)
{
Camera *cam;
- cam = BKE_libblock_alloc(bmain, ID_CA, name, 0);
-
- camera_init_data(&cam->id);
+ cam = BKE_id_new(bmain, ID_CA, name);
return cam;
}
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 3d5451125d9..403722b80cf 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -216,7 +216,7 @@ void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
BKE_ptcache_id_from_cloth(&pid, ob, clmd);
- // don't do anything as long as we're in editmode!
+ /* don't do anything as long as we're in editmode! */
if (pid.cache->edit && ob->mode & OB_MODE_PARTICLE_EDIT) {
return;
}
@@ -439,7 +439,7 @@ void cloth_free_modifier(ClothModifierData *clmd)
if (cloth) {
SIM_cloth_solver_free(clmd);
- // Free the verts.
+ /* Free the verts. */
if (cloth->verts != NULL) {
MEM_freeN(cloth->verts);
}
@@ -447,7 +447,7 @@ void cloth_free_modifier(ClothModifierData *clmd)
cloth->verts = NULL;
cloth->mvert_num = 0;
- // Free the springs.
+ /* Free the springs. */
if (cloth->springs != NULL) {
LinkNode *search = cloth->springs;
while (search) {
@@ -467,7 +467,7 @@ void cloth_free_modifier(ClothModifierData *clmd)
cloth->springs = NULL;
cloth->numsprings = 0;
- // free BVH collision tree
+ /* free BVH collision tree */
if (cloth->bvhtree) {
BLI_bvhtree_free(cloth->bvhtree);
}
@@ -476,7 +476,7 @@ void cloth_free_modifier(ClothModifierData *clmd)
BLI_bvhtree_free(cloth->bvhselftree);
}
- // we save our faces for collision objects
+ /* we save our faces for collision objects */
if (cloth->tri) {
MEM_freeN(cloth->tri);
}
@@ -521,7 +521,7 @@ void cloth_free_modifier_extern(ClothModifierData *clmd)
SIM_cloth_solver_free(clmd);
- // Free the verts.
+ /* Free the verts. */
if (cloth->verts != NULL) {
MEM_freeN(cloth->verts);
}
@@ -529,7 +529,7 @@ void cloth_free_modifier_extern(ClothModifierData *clmd)
cloth->verts = NULL;
cloth->mvert_num = 0;
- // Free the springs.
+ /* Free the springs. */
if (cloth->springs != NULL) {
LinkNode *search = cloth->springs;
while (search) {
@@ -549,7 +549,7 @@ void cloth_free_modifier_extern(ClothModifierData *clmd)
cloth->springs = NULL;
cloth->numsprings = 0;
- // free BVH collision tree
+ /* free BVH collision tree */
if (cloth->bvhtree) {
BLI_bvhtree_free(cloth->bvhtree);
}
@@ -558,7 +558,7 @@ void cloth_free_modifier_extern(ClothModifierData *clmd)
BLI_bvhtree_free(cloth->bvhselftree);
}
- // we save our faces for collision objects
+ /* we save our faces for collision objects */
if (cloth->tri) {
MEM_freeN(cloth->tri);
}
@@ -655,8 +655,8 @@ static void cloth_apply_vgroup(ClothModifierData *clmd, Mesh *mesh)
/* goalfac= 1.0f; */ /* UNUSED */
- // Kicking goal factor to simplify things...who uses that anyway?
- // ABS ( clmd->sim_parms->maxgoal - clmd->sim_parms->mingoal );
+ /* Kicking goal factor to simplify things...who uses that anyway? */
+ // ABS (clmd->sim_parms->maxgoal - clmd->sim_parms->mingoal);
verts->goal = pow4f(verts->goal);
if (verts->goal >= SOFTGOALSNAP) {
@@ -727,7 +727,7 @@ static bool cloth_from_object(
float(*shapekey_rest)[3] = NULL;
const float tnull[3] = {0, 0, 0};
- // If we have a clothObject, free it.
+ /* If we have a clothObject, free it. */
if (clmd->clothObject != NULL) {
cloth_free_modifier(clmd);
if (G.debug & G_DEBUG_SIMDATA) {
@@ -735,7 +735,7 @@ static bool cloth_from_object(
}
}
- // Allocate a new cloth object.
+ /* Allocate a new cloth object. */
clmd->clothObject = MEM_callocN(sizeof(Cloth), "cloth");
if (clmd->clothObject) {
clmd->clothObject->old_solver_type = 255;
@@ -746,14 +746,14 @@ static bool cloth_from_object(
return false;
}
- // mesh input objects need Mesh
+ /* mesh input objects need Mesh */
if (!mesh) {
return false;
}
cloth_from_mesh(clmd, mesh);
- // create springs
+ /* create springs */
clmd->clothObject->springs = NULL;
clmd->clothObject->numsprings = -1;
@@ -768,7 +768,7 @@ static bool cloth_from_object(
verts = clmd->clothObject->verts;
- // set initial values
+ /* set initial values */
for (i = 0; i < mesh->totvert; i++, verts++) {
if (first) {
copy_v3_v3(verts->x, mvert[i].co);
@@ -808,8 +808,8 @@ static bool cloth_from_object(
copy_v3_v3(verts->impulse, tnull);
}
- // apply / set vertex groups
- // has to be happen before springs are build!
+ /* apply / set vertex groups */
+ /* has to be happen before springs are build! */
cloth_apply_vgroup(clmd, mesh);
if (!cloth_build_springs(clmd, mesh)) {
@@ -818,7 +818,7 @@ static bool cloth_from_object(
return false;
}
- // init our solver
+ /* init our solver */
SIM_cloth_solver_init(ob, clmd);
if (!first) {
@@ -1471,13 +1471,13 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh)
const MEdge *medge = mesh->medge;
const MPoly *mpoly = mesh->mpoly;
const MLoop *mloop = mesh->mloop;
- int index2 = 0; // our second vertex index
+ int index2 = 0; /* our second vertex index */
LinkNodePair *edgelist = NULL;
EdgeSet *edgeset = NULL;
LinkNode *search = NULL, *search2 = NULL;
BendSpringRef *spring_ref = NULL;
- // error handling
+ /* error handling */
if (numedges == 0) {
return false;
}
@@ -1599,7 +1599,7 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh)
if (spring) {
spring_verts_ordered_set(spring, medge[i].v1, medge[i].v2);
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW && medge[i].flag & ME_LOOSEEDGE) {
- // handle sewing (loose edges will be pulled together)
+ /* handle sewing (loose edges will be pulled together) */
spring->restlen = 0.0f;
spring->lin_stiffness = 1.0f;
spring->type = CLOTH_SPRING_TYPE_SEWING;
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index e49c0c63c84..0ed6f94ce79 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -21,7 +21,6 @@
#include <string.h>
#include "BLI_blenlib.h"
-#include "BLI_ghash.h"
#include "BLI_iterator.h"
#include "BLI_listbase.h"
#include "BLI_math_base.h"
@@ -42,6 +41,8 @@
#include "BKE_rigidbody.h"
#include "BKE_scene.h"
+#include "DNA_defaults.h"
+
#include "DNA_ID.h"
#include "DNA_collection_types.h"
#include "DNA_layer_types.h"
@@ -81,6 +82,14 @@ static bool collection_find_child_recursive(Collection *parent, Collection *coll
/** \name Collection Data-Block
* \{ */
+static void collection_init_data(ID *id)
+{
+ Collection *collection = (Collection *)id;
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(collection, id));
+
+ MEMCPY_STRUCT_AFTER(collection, DNA_struct_default_get(Collection), id);
+}
+
/**
* Only copy internal data of Collection ID from source
* to already allocated/initialized destination.
@@ -168,7 +177,7 @@ IDTypeInfo IDType_ID_GR = {
.translation_context = BLT_I18NCONTEXT_ID_COLLECTION,
.flags = IDTYPE_FLAGS_NO_ANIMDATA,
- .init_data = NULL,
+ .init_data = collection_init_data,
.copy_data = collection_copy_data,
.free_data = collection_free_data,
.make_local = NULL,
@@ -203,8 +212,7 @@ static Collection *collection_add(Main *bmain,
}
/* Create new collection. */
- Collection *collection = BKE_libblock_alloc(bmain, ID_GR, name, 0);
- collection->color_tag = COLLECTION_COLOR_NONE;
+ Collection *collection = BKE_id_new(bmain, ID_GR, name);
/* We increase collection user count when linking to Collections. */
id_us_min(&collection->id);
@@ -1534,6 +1542,112 @@ bool BKE_collection_objects_select(ViewLayer *view_layer, Collection *collection
/** \name Collection move (outliner drag & drop)
* \{ */
+/* Local temporary storage for layer collection flags. */
+typedef struct LayerCollectionFlag {
+ struct LayerCollectionFlag *next, *prev;
+ /** The view layer for the collections being moved, NULL for their children. */
+ ViewLayer *view_layer;
+ /** The original #LayerCollection's collection field. */
+ Collection *collection;
+ /** The original #LayerCollection's flag. */
+ int flag;
+ /** Corresponds to #LayerCollection->layer_collections. */
+ ListBase children;
+} LayerCollectionFlag;
+
+static void layer_collection_flags_store_recursive(const LayerCollection *layer_collection,
+ LayerCollectionFlag *flag)
+{
+ flag->collection = layer_collection->collection;
+ flag->flag = layer_collection->flag;
+
+ LISTBASE_FOREACH (const LayerCollection *, child, &layer_collection->layer_collections) {
+ LayerCollectionFlag *child_flag = MEM_callocN(sizeof(LayerCollectionFlag), __func__);
+ BLI_addtail(&flag->children, child_flag);
+ layer_collection_flags_store_recursive(child, child_flag);
+ }
+}
+
+/**
+ * For every view layer, find the \a collection and save flags
+ * for it and its children in a temporary tree structure.
+ */
+static void layer_collection_flags_store(Main *bmain,
+ const Collection *collection,
+ ListBase *r_layer_level_list)
+{
+ BLI_listbase_clear(r_layer_level_list);
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
+ LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection(
+ view_layer, collection);
+ /* Skip this view layer if the collection isn't found for some reason. */
+ if (layer_collection == NULL) {
+ continue;
+ }
+
+ /* Store the flags for the collection and all of its children. */
+ LayerCollectionFlag *flag = MEM_callocN(sizeof(LayerCollectionFlag), __func__);
+ flag->view_layer = view_layer;
+
+ /* Recursively save flags from collection children. */
+ layer_collection_flags_store_recursive(layer_collection, flag);
+
+ BLI_addtail(r_layer_level_list, flag);
+ }
+ }
+}
+
+static void layer_collection_flags_restore_recursive(LayerCollection *layer_collection,
+ LayerCollectionFlag *flag)
+{
+ /* There should be a flag struct for every layer collection. */
+ BLI_assert(BLI_listbase_count(&layer_collection->layer_collections) ==
+ BLI_listbase_count(&flag->children));
+ /* The flag and the the layer collection should actually correspond. */
+ BLI_assert(flag->collection == layer_collection->collection);
+
+ LayerCollectionFlag *child_flag = flag->children.first;
+ LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) {
+ layer_collection_flags_restore_recursive(child, child_flag);
+
+ child_flag = child_flag->next;
+ }
+ BLI_freelistN(&flag->children);
+
+ /* We treat exclude as a special case.
+ *
+ * If in a different view layer the parent collection was disabled (e.g., background)
+ * and now we moved a new collection to be part of the background this collection should
+ * probably be disabled.
+ *
+ * Note: If we were to also keep the exclude flag we would need to re-sync the collections.
+ */
+ layer_collection->flag = flag->flag | (layer_collection->flag & LAYER_COLLECTION_EXCLUDE);
+}
+
+/**
+ * Restore a collection's (and its children's) flags for each view layer
+ * from the structure built in #layer_collection_flags_store.
+ */
+static void layer_collection_flags_restore(ListBase *flags, const Collection *collection)
+{
+ LISTBASE_FOREACH (LayerCollectionFlag *, flag, flags) {
+ ViewLayer *view_layer = flag->view_layer;
+ /* The top level of flag structs must have this set. */
+ BLI_assert(view_layer != NULL);
+
+ LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection(
+ view_layer, collection);
+ /* The flags should only be added if the collection is in the view layer. */
+ BLI_assert(layer_collection != NULL);
+
+ layer_collection_flags_restore_recursive(layer_collection, flag);
+ }
+
+ BLI_freelistN(flags);
+}
+
bool BKE_collection_move(Main *bmain,
Collection *to_parent,
Collection *from_parent,
@@ -1576,48 +1690,14 @@ bool BKE_collection_move(Main *bmain,
/* Make sure we store the flag of the layer collections before we remove and re-create them.
* Otherwise they will get lost and everything will be copied from the new parent collection. */
- GHash *view_layer_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
-
- LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection(
- view_layer, collection);
-
- if (layer_collection == NULL) {
- continue;
- }
-
- BLI_ghash_insert(view_layer_hash, view_layer, POINTER_FROM_INT(layer_collection->flag));
- }
- }
+ ListBase layer_flags;
+ layer_collection_flags_store(bmain, collection, &layer_flags);
/* Create and remove layer collections. */
BKE_main_collection_sync(bmain);
- /* Restore back the original layer collection flags. */
- GHashIterator gh_iter;
- GHASH_ITER (gh_iter, view_layer_hash) {
- ViewLayer *view_layer = BLI_ghashIterator_getKey(&gh_iter);
-
- LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection(
- view_layer, collection);
-
- if (layer_collection) {
- /* We treat exclude as a special case.
- *
- * If in a different view layer the parent collection was disabled (e.g., background)
- * and now we moved a new collection to be part of the background this collection should
- * probably be disabled.
- *
- * Note: If we were to also keep the exclude flag we would need to re-sync the collections.
- */
- layer_collection->flag = POINTER_AS_INT(BLI_ghashIterator_getValue(&gh_iter)) |
- (layer_collection->flag & LAYER_COLLECTION_EXCLUDE);
- }
- }
-
- BLI_ghash_free(view_layer_hash, NULL, NULL);
+ /* Restore the original layer collection flags. */
+ layer_collection_flags_restore(&layer_flags, collection);
/* We need to sync it again to pass the correct flags to the collections objects. */
BKE_main_collection_sync(bmain);
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 77a29bf41b8..34e8e8bc6fb 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -715,7 +715,8 @@ static void curvemap_make_table(const CurveMapping *cumap, CurveMap *cuma)
float *point = allpoints;
for (int a = 0; a < cuma->totpoint - 1; a++, point += 2 * CM_RESOL) {
- correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a + 1].vec[0], bezt[a + 1].vec[1]);
+ BKE_curve_correct_bezpart(
+ bezt[a].vec[1], bezt[a].vec[2], bezt[a + 1].vec[0], bezt[a + 1].vec[1]);
BKE_curve_forward_diff_bezier(bezt[a].vec[1][0],
bezt[a].vec[2][0],
bezt[a + 1].vec[0][0],
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 30e8a7948ba..274546132fb 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -744,7 +744,7 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph),
* (Hopefully all compilers will be happy with the lines with just a space on them.
* Those are really just to help this code easier to read).
*/
-// TODO: cope with getting rotation order...
+/* TODO: cope with getting rotation order... */
#define SINGLETARGET_GET_TARS(con, datatar, datasubtarget, ct, list) \
{ \
ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
@@ -779,7 +779,7 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph),
* (Hopefully all compilers will be happy with the lines with just a space on them. Those are
* really just to help this code easier to read)
*/
-// TODO: cope with getting rotation order...
+/* TODO: cope with getting rotation order... */
#define SINGLETARGETNS_GET_TARS(con, datatar, ct, list) \
{ \
ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
@@ -4340,7 +4340,7 @@ static void damptrack_do_transform(float matrix[4][4], const float tarvec_in[3],
* we may have destroyed that in the process of multiplying the matrix
*/
unit_m4(tmat);
- mul_m4_m3m4(tmat, rmat, matrix); // m1, m3, m2
+ mul_m4_m3m4(tmat, rmat, matrix); /* m1, m3, m2 */
copy_m4_m4(matrix, tmat);
copy_v3_v3(matrix[3], obloc);
@@ -4577,7 +4577,7 @@ static bConstraintTypeInfo CTI_PIVOT = {
pivotcon_id_looper, /* id looper */
NULL, /* copy data */
NULL,
- /* new data */ // XXX: might be needed to get 'normal' pivot behavior...
+ /* new data */ /* XXX: might be needed to get 'normal' pivot behavior... */
pivotcon_get_tars, /* get constraint targets */
pivotcon_flush_tars, /* flush constraint targets */
default_get_tarmat, /* get target matrix */
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 2002a49293f..a1edfd1c56d 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -104,9 +104,7 @@ struct bContext {
bContext *CTX_create(void)
{
- bContext *C;
-
- C = MEM_callocN(sizeof(bContext), "bContext");
+ bContext *C = MEM_callocN(sizeof(bContext), "bContext");
return C;
}
@@ -127,16 +125,13 @@ void CTX_free(bContext *C)
bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *ptr)
{
- bContextStoreEntry *entry;
- bContextStore *ctx, *lastctx;
-
/* ensure we have a context to put the entry in, if it was already used
* we have to copy the context to ensure */
- ctx = contexts->last;
+ bContextStore *ctx = contexts->last;
if (!ctx || ctx->used) {
if (ctx) {
- lastctx = ctx;
+ bContextStore *lastctx = ctx;
ctx = MEM_dupallocN(lastctx);
BLI_duplicatelist(&ctx->entries, &lastctx->entries);
}
@@ -147,7 +142,7 @@ bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *p
BLI_addtail(contexts, ctx);
}
- entry = MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry");
+ bContextStoreEntry *entry = MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry");
BLI_strncpy(entry->name, name, sizeof(entry->name));
entry->ptr = *ptr;
@@ -158,16 +153,13 @@ bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *p
bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context)
{
- bContextStoreEntry *entry, *tentry;
- bContextStore *ctx, *lastctx;
-
/* ensure we have a context to put the entries in, if it was already used
* we have to copy the context to ensure */
- ctx = contexts->last;
+ bContextStore *ctx = contexts->last;
if (!ctx || ctx->used) {
if (ctx) {
- lastctx = ctx;
+ bContextStore *lastctx = ctx;
ctx = MEM_dupallocN(lastctx);
BLI_duplicatelist(&ctx->entries, &lastctx->entries);
}
@@ -178,8 +170,8 @@ bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context)
BLI_addtail(contexts, ctx);
}
- for (tentry = context->entries.first; tentry; tentry = tentry->next) {
- entry = MEM_dupallocN(tentry);
+ LISTBASE_FOREACH (bContextStoreEntry *, tentry, &context->entries) {
+ bContextStoreEntry *entry = MEM_dupallocN(tentry);
BLI_addtail(&ctx->entries, entry);
}
@@ -193,9 +185,7 @@ void CTX_store_set(bContext *C, bContextStore *store)
bContextStore *CTX_store_copy(bContextStore *store)
{
- bContextStore *ctx;
-
- ctx = MEM_dupallocN(store);
+ bContextStore *ctx = MEM_dupallocN(store);
BLI_duplicatelist(&ctx->entries, &store->entries);
return ctx;
@@ -210,7 +200,6 @@ void CTX_store_free(bContextStore *store)
void CTX_store_free_list(ListBase *contexts)
{
bContextStore *ctx;
-
while ((ctx = BLI_pophead(contexts))) {
CTX_store_free(ctx);
}
@@ -326,11 +315,11 @@ static eContextResult ctx_data_get(bContext *C, const char *member, bContextData
* (0, -1, 1) - Where 1 is highest priority
* */
if (done != 1 && recursion < 1 && C->wm.store) {
- bContextStoreEntry *entry;
-
C->data.recursion = 1;
- entry = BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name));
+ bContextStoreEntry *entry = BLI_rfindstring(
+ &C->wm.store->entries, member, offsetof(bContextStoreEntry, name));
+
if (entry) {
result->ptr = entry->ptr;
done = 1;
@@ -354,6 +343,7 @@ static eContextResult ctx_data_get(bContext *C, const char *member, bContextData
}
}
}
+
if (done != 1 && recursion < 4 && (screen = CTX_wm_screen(C))) {
bContextDataCallback cb = screen->context;
C->data.recursion = 4;
@@ -373,7 +363,6 @@ static eContextResult ctx_data_get(bContext *C, const char *member, bContextData
static void *ctx_data_pointer_get(const bContext *C, const char *member)
{
bContextDataResult result;
-
if (C && ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
BLI_assert(result.type == CTX_DATA_TYPE_POINTER);
return result.ptr.data;
@@ -384,13 +373,13 @@ static void *ctx_data_pointer_get(const bContext *C, const char *member)
static int ctx_data_pointer_verify(const bContext *C, const char *member, void **pointer)
{
- bContextDataResult result;
-
/* if context is NULL, pointer must be NULL too and that is a valid return */
if (C == NULL) {
*pointer = NULL;
return 1;
}
+
+ bContextDataResult result;
if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
BLI_assert(result.type == CTX_DATA_TYPE_POINTER);
*pointer = result.ptr.data;
@@ -404,7 +393,6 @@ static int ctx_data_pointer_verify(const bContext *C, const char *member, void *
static int ctx_data_collection_get(const bContext *C, const char *member, ListBase *list)
{
bContextDataResult result;
-
if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
BLI_assert(result.type == CTX_DATA_TYPE_COLLECTION);
*list = result.list;
@@ -419,8 +407,6 @@ static int ctx_data_collection_get(const bContext *C, const char *member, ListBa
static int ctx_data_base_collection_get(const bContext *C, const char *member, ListBase *list)
{
ListBase ctx_object_list;
- bool ok = false;
-
if ((ctx_data_collection_get(C, member, &ctx_object_list) == false) ||
BLI_listbase_is_empty(&ctx_object_list)) {
BLI_listbase_clear(list);
@@ -433,6 +419,8 @@ static int ctx_data_base_collection_get(const bContext *C, const char *member, L
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
+ bool ok = false;
+
CollectionPointerLink *ctx_object;
for (ctx_object = ctx_object_list.first; ctx_object; ctx_object = ctx_object->next) {
Object *ob = ctx_object->ptr.data;
@@ -452,7 +440,6 @@ static int ctx_data_base_collection_get(const bContext *C, const char *member, L
PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
{
bContextDataResult result;
-
if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
BLI_assert(result.type == CTX_DATA_TYPE_POINTER);
return result.ptr;
@@ -494,7 +481,6 @@ PointerRNA CTX_data_pointer_get_type_silent(const bContext *C, const char *membe
ListBase CTX_data_collection_get(const bContext *C, const char *member)
{
bContextDataResult result;
-
if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
BLI_assert(result.type == CTX_DATA_TYPE_COLLECTION);
return result.list;
@@ -651,9 +637,7 @@ void CTX_data_pointer_set(bContextDataResult *result, ID *id, StructRNA *type, v
void CTX_data_id_list_add(bContextDataResult *result, ID *id)
{
- CollectionPointerLink *link;
-
- link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add");
+ CollectionPointerLink *link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add");
RNA_id_pointer_create(id, &link->ptr);
BLI_addtail(&result->list, link);
@@ -661,9 +645,7 @@ void CTX_data_id_list_add(bContextDataResult *result, ID *id)
void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void *data)
{
- CollectionPointerLink *link;
-
- link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add");
+ CollectionPointerLink *link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add");
RNA_pointer_create(id, type, data, &link->ptr);
BLI_addtail(&result->list, link);
@@ -1022,7 +1004,6 @@ const char *CTX_wm_operator_poll_msg_get(bContext *C)
Main *CTX_data_main(const bContext *C)
{
Main *bmain;
-
if (ctx_data_pointer_verify(C, "blend_data", (void *)&bmain)) {
return bmain;
}
@@ -1039,7 +1020,6 @@ void CTX_data_main_set(bContext *C, Main *bmain)
Scene *CTX_data_scene(const bContext *C)
{
Scene *scene;
-
if (ctx_data_pointer_verify(C, "scene", (void *)&scene)) {
return scene;
}
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index be82252159c..01636c7eb2b 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -21,7 +21,7 @@
* \ingroup bke
*/
-#include <math.h> // floor
+#include <math.h> /* floor */
#include <stdlib.h>
#include <string.h>
@@ -282,7 +282,7 @@ static void curve_blend_read_lib(BlendLibReader *reader, ID *id)
BLO_read_id_address(reader, cu->id.lib, &cu->vfonti);
BLO_read_id_address(reader, cu->id.lib, &cu->vfontbi);
- BLO_read_id_address(reader, cu->id.lib, &cu->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, cu->id.lib, &cu->ipo); /* XXX deprecated - old animation system */
BLO_read_id_address(reader, cu->id.lib, &cu->key);
}
@@ -298,7 +298,7 @@ static void curve_blend_read_expand(BlendExpander *expander, ID *id)
BLO_expand(expander, cu->vfonti);
BLO_expand(expander, cu->vfontbi);
BLO_expand(expander, cu->key);
- BLO_expand(expander, cu->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, cu->ipo); /* XXX deprecated - old animation system */
BLO_expand(expander, cu->bevobj);
BLO_expand(expander, cu->taperobj);
BLO_expand(expander, cu->textoncurve);
@@ -418,6 +418,7 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
{
Curve *cu;
+ /* We cannot use #BKE_id_new here as we need some custom initialization code. */
cu = BKE_libblock_alloc(bmain, ID_CU, name, 0);
BKE_curve_init(cu, type);
@@ -3638,7 +3639,7 @@ static bool tridiagonal_solve_with_limits(float *a,
* see if it may be a good idea to unlock some handles. */
if (!locked) {
for (int i = 0; i < solve_count; i++) {
- // to definitely avoid infinite loops limit this to 2 times
+ /* to definitely avoid infinite loops limit this to 2 times */
if (!is_locked[i] || num_unlocks[i] >= 2) {
continue;
}
@@ -5565,6 +5566,47 @@ void BKE_curve_rect_from_textbox(const struct Curve *cu,
r_rect->ymin = r_rect->ymax - tb->h;
}
+/* This function is almost the same as BKE_fcurve_correct_bezpart(), but doesn't allow as large a
+ * tangent. */
+void BKE_curve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2])
+{
+ float h1[2], h2[2], len1, len2, len, fac;
+
+ /* Calculate handle deltas. */
+ h1[0] = v1[0] - v2[0];
+ h1[1] = v1[1] - v2[1];
+
+ h2[0] = v4[0] - v3[0];
+ h2[1] = v4[1] - v3[1];
+
+ /* Calculate distances:
+ * - len = span of time between keyframes
+ * - len1 = length of handle of start key
+ * - len2 = length of handle of end key
+ */
+ len = v4[0] - v1[0];
+ len1 = fabsf(h1[0]);
+ len2 = fabsf(h2[0]);
+
+ /* If the handles have no length, no need to do any corrections. */
+ if ((len1 + len2) == 0.0f) {
+ return;
+ }
+
+ /* the two handles cross over each other, so force them
+ * apart using the proportion they overlap
+ */
+ if ((len1 + len2) > len) {
+ fac = len / (len1 + len2);
+
+ v2[0] = (v1[0] - fac * h1[0]);
+ v2[1] = (v1[1] - fac * h1[1]);
+
+ v3[0] = (v4[0] - fac * h2[0]);
+ v3[1] = (v4[1] - fac * h2[1]);
+ }
+}
+
/* **** Depsgraph evaluation **** */
void BKE_curve_eval_geometry(Depsgraph *depsgraph, Curve *curve)
@@ -5582,10 +5624,10 @@ void BKE_curve_eval_geometry(Depsgraph *depsgraph, Curve *curve)
}
/* Draw Engine */
-void (*BKE_curve_batch_cache_dirty_tag_cb)(Curve *cu, eMeshBatchDirtyMode mode) = NULL;
+void (*BKE_curve_batch_cache_dirty_tag_cb)(Curve *cu, int mode) = NULL;
void (*BKE_curve_batch_cache_free_cb)(Curve *cu) = NULL;
-void BKE_curve_batch_cache_dirty_tag(Curve *cu, eMeshBatchDirtyMode mode)
+void BKE_curve_batch_cache_dirty_tag(Curve *cu, int mode)
{
if (cu->batch_cache) {
BKE_curve_batch_cache_dirty_tag_cb(cu, mode);
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 2a4aeb81b0c..2b2b1fb70ce 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -255,15 +255,11 @@ static void layerInterp_mdeformvert(const void **sources,
struct MDeformWeight_Link *node;
int i, j, totweight;
- if (count <= 0) {
- return;
- }
-
/* build a list of unique def_nrs for dest */
totweight = 0;
for (i = 0; i < count; i++) {
const MDeformVert *source = sources[i];
- float interp_weight = weights ? weights[i] : 1.0f;
+ float interp_weight = weights[i];
for (j = 0; j < source->totweight; j++) {
MDeformWeight *dw = &source->dw[j];
@@ -424,23 +420,19 @@ static void layerInterp_tface(
float uv[4][2] = {{0.0f}};
const float *sub_weight;
- if (count <= 0) {
- return;
- }
-
sub_weight = sub_weights;
for (i = 0; i < count; i++) {
- float weight = weights ? weights[i] : 1;
+ const float interp_weight = weights[i];
const MTFace *src = sources[i];
for (j = 0; j < 4; j++) {
if (sub_weights) {
for (k = 0; k < 4; k++, sub_weight++) {
- madd_v2_v2fl(uv[j], src->uv[k], (*sub_weight) * weight);
+ madd_v2_v2fl(uv[j], src->uv[k], (*sub_weight) * interp_weight);
}
}
else {
- madd_v2_v2fl(uv[j], src->uv[j], weight);
+ madd_v2_v2fl(uv[j], src->uv[j], interp_weight);
}
}
}
@@ -529,23 +521,19 @@ static void layerInterp_origspace_face(
float uv[4][2] = {{0.0f}};
const float *sub_weight;
- if (count <= 0) {
- return;
- }
-
sub_weight = sub_weights;
for (i = 0; i < count; i++) {
- float weight = weights ? weights[i] : 1;
+ const float interp_weight = weights[i];
const OrigSpaceFace *src = sources[i];
for (j = 0; j < 4; j++) {
if (sub_weights) {
for (k = 0; k < 4; k++, sub_weight++) {
- madd_v2_v2fl(uv[j], src->uv[k], (*sub_weight) * weight);
+ madd_v2_v2fl(uv[j], src->uv[k], (*sub_weight) * interp_weight);
}
}
else {
- madd_v2_v2fl(uv[j], src->uv[j], weight);
+ madd_v2_v2fl(uv[j], src->uv[j], interp_weight);
}
}
}
@@ -690,21 +678,17 @@ static size_t layerFilesize_mdisps(CDataFile *UNUSED(cdf), const void *data, int
return size;
}
-static void layerInterp_paint_mask(
- const void **sources, const float *weights, const float *sub_weights, int count, void *dest)
+static void layerInterp_paint_mask(const void **sources,
+ const float *weights,
+ const float *UNUSED(sub_weights),
+ int count,
+ void *dest)
{
float mask = 0.0f;
- const float *sub_weight = sub_weights;
for (int i = 0; i < count; i++) {
- float weight = weights ? weights[i] : 1.0f;
+ const float interp_weight = weights[i];
const float *src = sources[i];
- if (sub_weights) {
- mask += (*src) * (*sub_weight) * weight;
- sub_weight++;
- }
- else {
- mask += (*src) * weight;
- }
+ mask += (*src) * interp_weight;
}
*(float *)dest = mask;
}
@@ -885,8 +869,11 @@ static void layerDefault_mloopcol(void *data, int count)
}
}
-static void layerInterp_mloopcol(
- const void **sources, const float *weights, const float *sub_weights, int count, void *dest)
+static void layerInterp_mloopcol(const void **sources,
+ const float *weights,
+ const float *UNUSED(sub_weights),
+ int count,
+ void *dest)
{
MLoopCol *mc = dest;
struct {
@@ -896,23 +883,13 @@ static void layerInterp_mloopcol(
float b;
} col = {0};
- const float *sub_weight = sub_weights;
for (int i = 0; i < count; i++) {
- float weight = weights ? weights[i] : 1;
+ const float interp_weight = weights[i];
const MLoopCol *src = sources[i];
- if (sub_weights) {
- col.r += src->r * (*sub_weight) * weight;
- col.g += src->g * (*sub_weight) * weight;
- col.b += src->b * (*sub_weight) * weight;
- col.a += src->a * (*sub_weight) * weight;
- sub_weight++;
- }
- else {
- col.r += src->r * weight;
- col.g += src->g * weight;
- col.b += src->b * weight;
- col.a += src->a * weight;
- }
+ col.r += src->r * interp_weight;
+ col.g += src->g * interp_weight;
+ col.b += src->b * interp_weight;
+ col.a += src->a * interp_weight;
}
/* Subdivide smooth or fractal can cause problems without clamping
@@ -986,34 +963,23 @@ static void layerAdd_mloopuv(void *data1, const void *data2)
add_v2_v2(l1->uv, l2->uv);
}
-static void layerInterp_mloopuv(
- const void **sources, const float *weights, const float *sub_weights, int count, void *dest)
+static void layerInterp_mloopuv(const void **sources,
+ const float *weights,
+ const float *UNUSED(sub_weights),
+ int count,
+ void *dest)
{
float uv[2];
int flag = 0;
zero_v2(uv);
- if (sub_weights) {
- const float *sub_weight = sub_weights;
- for (int i = 0; i < count; i++) {
- float weight = (weights ? weights[i] : 1.0f) * (*sub_weight);
- const MLoopUV *src = sources[i];
- madd_v2_v2fl(uv, src->uv, weight);
- if (weight > 0.0f) {
- flag |= src->flag;
- }
- sub_weight++;
- }
- }
- else {
- for (int i = 0; i < count; i++) {
- float weight = weights ? weights[i] : 1;
- const MLoopUV *src = sources[i];
- madd_v2_v2fl(uv, src->uv, weight);
- if (weight > 0.0f) {
- flag |= src->flag;
- }
+ for (int i = 0; i < count; i++) {
+ const float interp_weight = weights[i];
+ const MLoopUV *src = sources[i];
+ madd_v2_v2fl(uv, src->uv, interp_weight);
+ if (interp_weight > 0.0f) {
+ flag |= src->flag;
}
}
@@ -1088,27 +1054,19 @@ static void layerAdd_mloop_origspace(void *data1, const void *data2)
add_v2_v2(l1->uv, l2->uv);
}
-static void layerInterp_mloop_origspace(
- const void **sources, const float *weights, const float *sub_weights, int count, void *dest)
+static void layerInterp_mloop_origspace(const void **sources,
+ const float *weights,
+ const float *UNUSED(sub_weights),
+ int count,
+ void *dest)
{
float uv[2];
zero_v2(uv);
- if (sub_weights) {
- const float *sub_weight = sub_weights;
- for (int i = 0; i < count; i++) {
- float weight = weights ? weights[i] : 1.0f;
- const OrigSpaceLoop *src = sources[i];
- madd_v2_v2fl(uv, src->uv, (*sub_weight) * weight);
- sub_weight++;
- }
- }
- else {
- for (int i = 0; i < count; i++) {
- float weight = weights ? weights[i] : 1.0f;
- const OrigSpaceLoop *src = sources[i];
- madd_v2_v2fl(uv, src->uv, weight);
- }
+ for (int i = 0; i < count; i++) {
+ const float interp_weight = weights[i];
+ const OrigSpaceLoop *src = sources[i];
+ madd_v2_v2fl(uv, src->uv, interp_weight);
}
/* Delay writing to the destination in case dest is in sources. */
@@ -1127,19 +1085,15 @@ static void layerInterp_mcol(
float b;
} col[4] = {{0.0f}};
- if (count <= 0) {
- return;
- }
-
const float *sub_weight = sub_weights;
for (int i = 0; i < count; i++) {
- float weight = weights ? weights[i] : 1;
+ const float interp_weight = weights[i];
for (int j = 0; j < 4; j++) {
if (sub_weights) {
const MCol *src = sources[i];
for (int k = 0; k < 4; k++, sub_weight++, src++) {
- const float w = (*sub_weight) * weight;
+ const float w = (*sub_weight) * interp_weight;
col[j].a += src->a * w;
col[j].r += src->r * w;
col[j].g += src->g * w;
@@ -1148,10 +1102,10 @@ static void layerInterp_mcol(
}
else {
const MCol *src = sources[i];
- col[j].a += src[j].a * weight;
- col[j].r += src[j].r * weight;
- col[j].g += src[j].g * weight;
- col[j].b += src[j].b * weight;
+ col[j].a += src[j].a * interp_weight;
+ col[j].r += src[j].r * interp_weight;
+ col[j].g += src[j].g * interp_weight;
+ col[j].b += src[j].b * interp_weight;
}
}
}
@@ -1210,15 +1164,9 @@ static void layerInterp_bweight(const void **sources,
float f = 0.0f;
- if (weights) {
- for (int i = 0; i < count; i++) {
- f += *in[i] * weights[i];
- }
- }
- else {
- for (int i = 0; i < count; i++) {
- f += *in[i];
- }
+ for (int i = 0; i < count; i++) {
+ const float interp_weight = weights[i];
+ f += *in[i] * interp_weight;
}
/* Delay writing to the destination in case dest is in sources. */
@@ -1240,15 +1188,9 @@ static void layerInterp_shapekey(const void **sources,
float co[3];
zero_v3(co);
- if (weights) {
- for (int i = 0; i < count; i++) {
- madd_v3_v3fl(co, in[i], weights[i]);
- }
- }
- else {
- for (int i = 0; i < count; i++) {
- add_v3_v3(co, in[i]);
- }
+ for (int i = 0; i < count; i++) {
+ const float interp_weight = weights[i];
+ madd_v3_v3fl(co, in[i], interp_weight);
}
/* Delay writing to the destination in case dest is in sources. */
@@ -1282,10 +1224,10 @@ static void layerInterp_mvert_skin(const void **sources,
zero_v3(radius);
for (int i = 0; i < count; i++) {
+ const float interp_weight = weights[i];
const MVertSkin *vs_src = sources[i];
- float w = weights ? weights[i] : 1.0f;
- madd_v3_v3fl(radius, vs_src->radius, w);
+ madd_v3_v3fl(radius, vs_src->radius, interp_weight);
}
/* Delay writing to the destination in case dest is in sources. */
@@ -1415,22 +1357,18 @@ static void layerDefault_propcol(void *data, int count)
}
}
-static void layerInterp_propcol(
- const void **sources, const float *weights, const float *sub_weights, int count, void *dest)
+static void layerInterp_propcol(const void **sources,
+ const float *weights,
+ const float *UNUSED(sub_weights),
+ int count,
+ void *dest)
{
MPropCol *mc = dest;
float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- const float *sub_weight = sub_weights;
for (int i = 0; i < count; i++) {
- float weight = weights ? weights[i] : 1.0f;
+ const float interp_weight = weights[i];
const MPropCol *src = sources[i];
- if (sub_weights) {
- madd_v4_v4fl(col, src->color, (*sub_weight) * weight);
- sub_weight++;
- }
- else {
- madd_v4_v4fl(col, src->color, weight);
- }
+ madd_v4_v4fl(col, src->color, interp_weight);
}
copy_v4_v4(mc->color, col);
}
@@ -1440,19 +1378,17 @@ static int layerMaxNum_propcol(void)
return MAX_MCOL;
}
-static void layerInterp_propfloat3(
- const void **sources, const float *weights, const float *sub_weights, int count, void *dest)
+static void layerInterp_propfloat3(const void **sources,
+ const float *weights,
+ const float *UNUSED(sub_weights),
+ int count,
+ void *dest)
{
vec3f result = {0.0f, 0.0f, 0.0f};
for (int i = 0; i < count; i++) {
- float weight = weights ? weights[i] : 1.0f;
+ const float interp_weight = weights[i];
const vec3f *src = sources[i];
- if (sub_weights) {
- madd_v3_v3fl(&result.x, &src->x, sub_weights[i] * weight);
- }
- else {
- madd_v3_v3fl(&result.x, &src->x, weight);
- }
+ madd_v3_v3fl(&result.x, &src->x, interp_weight);
}
copy_v3_v3((float *)dest, &result.x);
}
@@ -1489,19 +1425,17 @@ static bool layerValidate_propfloat3(void *data, const uint totitems, const bool
return has_errors;
}
-static void layerInterp_propfloat2(
- const void **sources, const float *weights, const float *sub_weights, int count, void *dest)
+static void layerInterp_propfloat2(const void **sources,
+ const float *weights,
+ const float *UNUSED(sub_weights),
+ int count,
+ void *dest)
{
vec2f result = {0.0f, 0.0f};
for (int i = 0; i < count; i++) {
- float weight = weights ? weights[i] : 1.0f;
+ const float interp_weight = weights[i];
const vec2f *src = sources[i];
- if (sub_weights) {
- madd_v2_v2fl(&result.x, &src->x, sub_weights[i] * weight);
- }
- else {
- madd_v2_v2fl(&result.x, &src->x, weight);
- }
+ madd_v2_v2fl(&result.x, &src->x, interp_weight);
}
copy_v2_v2((float *)dest, &result.x);
}
@@ -3059,6 +2993,18 @@ void CustomData_free_elem(CustomData *data, int index, int count)
#define SOURCE_BUF_SIZE 100
+/**
+ * Interpolate given custom data source items into a single destination one.
+ *
+ * \param src_indices Indices of every source items to interpolate into the destination one.
+ * \param weights: The weight to apply to each source value individually. If NULL, they will be
+ * averaged.
+ * \param sub_weights: The weights of sub-items, only used to affect each corners of a
+ * tessellated face data (should always be and array of four values).
+ * \param count: The number of source items to interpolate.
+ * \param dest_index: Index of the destination item, in which to put the result of the
+ * interpolation.
+ */
void CustomData_interp(const CustomData *source,
CustomData *dest,
const int *src_indices,
@@ -3067,6 +3013,10 @@ void CustomData_interp(const CustomData *source,
int count,
int dest_index)
{
+ if (count <= 0) {
+ return;
+ }
+
const void *source_buf[SOURCE_BUF_SIZE];
const void **sources = source_buf;
@@ -3075,6 +3025,17 @@ void CustomData_interp(const CustomData *source,
sources = MEM_malloc_arrayN(count, sizeof(*sources), __func__);
}
+ /* If no weights are given, generate default ones to produce an average result. */
+ float default_weights_buf[SOURCE_BUF_SIZE];
+ float *default_weights = NULL;
+ if (weights == NULL) {
+ default_weights = (count > SOURCE_BUF_SIZE) ?
+ MEM_mallocN(sizeof(*weights) * (size_t)count, __func__) :
+ default_weights_buf;
+ copy_vn_fl(default_weights, count, 1.0f / count);
+ weights = default_weights;
+ }
+
/* interpolates a layer at a time */
int dest_i = 0;
for (int src_i = 0; src_i < source->totlayer; src_i++) {
@@ -3121,6 +3082,9 @@ void CustomData_interp(const CustomData *source,
if (count > SOURCE_BUF_SIZE) {
MEM_freeN((void *)sources);
}
+ if (!ELEM(default_weights, NULL, default_weights_buf)) {
+ MEM_freeN(default_weights);
+ }
}
/**
@@ -4049,6 +4013,9 @@ void CustomData_bmesh_interp_n(CustomData *data,
void *dst_block_ofs,
int n)
{
+ BLI_assert(weights != NULL);
+ BLI_assert(count > 0);
+
CustomDataLayer *layer = &data->layers[n];
const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
@@ -4062,6 +4029,10 @@ void CustomData_bmesh_interp(CustomData *data,
int count,
void *dst_block)
{
+ if (count <= 0) {
+ return;
+ }
+
int i, j;
void *source_buf[SOURCE_BUF_SIZE];
const void **sources = (const void **)source_buf;
@@ -4071,6 +4042,17 @@ void CustomData_bmesh_interp(CustomData *data,
sources = MEM_malloc_arrayN(count, sizeof(*sources), __func__);
}
+ /* If no weights are given, generate default ones to produce an average result. */
+ float default_weights_buf[SOURCE_BUF_SIZE];
+ float *default_weights = NULL;
+ if (weights == NULL) {
+ default_weights = (count > SOURCE_BUF_SIZE) ?
+ MEM_mallocN(sizeof(*weights) * (size_t)count, __func__) :
+ default_weights_buf;
+ copy_vn_fl(default_weights, count, 1.0f / count);
+ weights = default_weights;
+ }
+
/* interpolates a layer at a time */
for (i = 0; i < data->totlayer; i++) {
CustomDataLayer *layer = &data->layers[i];
@@ -4087,6 +4069,9 @@ void CustomData_bmesh_interp(CustomData *data,
if (count > SOURCE_BUF_SIZE) {
MEM_freeN((void *)sources);
}
+ if (!ELEM(default_weights, NULL, default_weights_buf)) {
+ MEM_freeN(default_weights);
+ }
}
/**
@@ -4803,6 +4788,9 @@ static void customdata_data_transfer_interp_generic(const CustomDataTransferLaye
const int count,
const float mix_factor)
{
+ BLI_assert(weights != NULL);
+ BLI_assert(count > 0);
+
/* Fake interpolation, we actually copy highest weighted source to dest.
* Note we also handle bitflags here,
* in which case we rather choose to transfer value of elements totaling
@@ -4918,6 +4906,9 @@ void customdata_data_transfer_interp_normal_normals(const CustomDataTransferLaye
const int count,
const float mix_factor)
{
+ BLI_assert(weights != NULL);
+ BLI_assert(count > 0);
+
const int data_type = laymap->data_type;
const int mix_mode = laymap->mix_mode;
diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c
index 1a5b7685c0e..0fa3bb29ccd 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -228,6 +228,34 @@ float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph *depsgraph,
return cos_cage;
}
+const float (*BKE_editmesh_vert_coords_when_deformed(struct Depsgraph *depsgraph,
+ BMEditMesh *em,
+ struct Scene *scene,
+ Object *ob,
+ int *r_vert_len,
+ bool *r_is_alloc))[3]
+{
+ const float(*coords)[3] = NULL;
+ *r_is_alloc = false;
+
+ Mesh *me = ob->data;
+
+ if ((me->runtime.edit_data != NULL) && (me->runtime.edit_data->vertexCos != NULL)) {
+ /* Deformed, and we have deformed coords already. */
+ coords = me->runtime.edit_data->vertexCos;
+ }
+ else if ((em->mesh_eval_final != NULL) &&
+ (em->mesh_eval_final->runtime.wrapper_type == ME_WRAPPER_TYPE_BMESH)) {
+ /* If this is an edit-mesh type, leave NULL as we can use the vertex coords. . */
+ }
+ else {
+ /* Constructive modifiers have been used, we need to allocate coordinates. */
+ *r_is_alloc = true;
+ coords = BKE_editmesh_vert_coords_alloc(depsgraph, em, scene, ob, r_vert_len);
+ }
+ return coords;
+}
+
float (*BKE_editmesh_vert_coords_alloc_orco(BMEditMesh *em, int *r_vert_len))[3]
{
return BM_mesh_vert_coords_alloc(em->bm, r_vert_len);
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 856e0e872b3..2287170c29d 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -444,8 +444,8 @@ FCurve *BKE_fcurve_find_by_rna_context_ui(bContext *C,
continue;
}
- // XXX: the logic here is duplicated with a function up above
- /* animation takes priority over drivers */
+ /* XXX: the logic here is duplicated with a function up above
+ * animation takes priority over drivers. */
if (adt->action && adt->action->curves.first) {
fcu = BKE_fcurve_find(&adt->action->curves, path, rnaindex);
@@ -502,7 +502,7 @@ FCurve *BKE_fcurve_find_by_rna_context_ui(bContext *C,
* with optional argument for precision required.
* Returns the index to insert at (data already at that index will be offset if replace is 0)
*/
-static int binarysearch_bezt_index_ex(
+static int BKE_fcurve_bezt_binarysearch_index_ex(
BezTriple array[], float frame, int arraylen, float threshold, bool *r_replace)
{
int start = 0, end = arraylen;
@@ -589,10 +589,14 @@ static int binarysearch_bezt_index_ex(
/* Binary search algorithm for finding where to insert BezTriple. (for use by insert_bezt_fcurve)
* Returns the index to insert at (data already at that index will be offset if replace is 0)
*/
-int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, bool *r_replace)
+int BKE_fcurve_bezt_binarysearch_index(BezTriple array[],
+ float frame,
+ int arraylen,
+ bool *r_replace)
{
/* this is just a wrapper which uses the default threshold */
- return binarysearch_bezt_index_ex(array, frame, arraylen, BEZT_BINARYSEARCH_THRESH, r_replace);
+ return BKE_fcurve_bezt_binarysearch_index_ex(
+ array, frame, arraylen, BEZT_BINARYSEARCH_THRESH, r_replace);
}
/* ...................................... */
@@ -839,6 +843,8 @@ bool BKE_fcurve_calc_range(
*/
void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
{
+ /* The active keyframe should always be selected. */
+ BLI_assert(active_bezt == NULL || (active_bezt->f2 & SELECT));
fcu->active_keyframe_index = (active_bezt == NULL) ? FCURVE_ACTIVE_KEYFRAME_NONE :
active_bezt - fcu->bezt;
}
@@ -850,12 +856,18 @@ int BKE_fcurve_active_keyframe_index(const FCurve *fcu)
{
const int active_keyframe_index = fcu->active_keyframe_index;
- /* Sanity checks. */
+ /* Array access boundary checks. */
if ((fcu->bezt == NULL) || (active_keyframe_index >= fcu->totvert) ||
(active_keyframe_index < 0)) {
return FCURVE_ACTIVE_KEYFRAME_NONE;
}
+ const BezTriple *active_bezt = &fcu->bezt[active_keyframe_index];
+ if ((active_bezt->f2 & SELECT) == 0) {
+ /* The active keyframe should always be selected. If it's not selected, it can't be active. */
+ return FCURVE_ACTIVE_KEYFRAME_NONE;
+ }
+
return active_keyframe_index;
}
@@ -960,7 +972,7 @@ bool BKE_fcurve_is_keyframable(FCurve *fcu)
* \{ */
/* add a BezTriple to a column */
-void bezt_add_to_cfra_elem(ListBase *lb, BezTriple *bezt)
+static void UNUSED_FUNCTION(bezt_add_to_cfra_elem)(ListBase *lb, BezTriple *bezt)
{
CfraElem *ce, *cen;
@@ -1343,8 +1355,11 @@ bool test_time_fcurve(FCurve *fcu)
/* The length of each handle is not allowed to be more
* than the horizontal distance between (v1-v4).
* This is to prevent curve loops.
+ *
+ * This function is very similar to BKE_curve_correct_bezpart(), but allows a steeper tangent for
+ * more snappy animations. This is not desired for other areas in which curves are used, though.
*/
-void correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2])
+void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2])
{
float h1[2], h2[2], len1, len2, len, fac;
@@ -1525,11 +1540,18 @@ static void berekeny(float f1, float f2, float f3, float f4, float *o, int b)
}
}
-/* Recompute handles to neatly subdivide the prev-next range at bezt. */
-bool BKE_bezt_subdivide_handles(struct BezTriple *bezt,
- struct BezTriple *prev,
- struct BezTriple *next,
- float *r_pdelta)
+/**
+ * Adjust Bezier handles of all three given BezTriples, so that `bezt` can be inserted between
+ * `prev` and `next` without changing the resulting curve shape.
+ *
+ * \param r_pdelta: return Y difference between `bezt` and the original curve value at its X
+ * position.
+ * \return Whether the split was successful.
+ */
+bool BKE_fcurve_bezt_subdivide_handles(struct BezTriple *bezt,
+ struct BezTriple *prev,
+ struct BezTriple *next,
+ float *r_pdelta)
{
/* The four points that make up this section of the Bezier curve. */
const float *prev_coords = prev->vec[1];
@@ -1547,7 +1569,7 @@ bool BKE_bezt_subdivide_handles(struct BezTriple *bezt,
}
/* Apply evaluation-time limits and compute the effective curve. */
- correct_bezpart(prev_coords, prev_handle_right, next_handle_left, next_coords);
+ BKE_fcurve_correct_bezpart(prev_coords, prev_handle_right, next_handle_left, next_coords);
float roots[4];
if (!findzero(new_coords[0],
prev_coords[0],
@@ -1659,7 +1681,7 @@ static float fcurve_eval_keyframes_interpolate(FCurve *fcu, BezTriple *bezts, fl
* Weird errors, like selecting the wrong keyframe range (see T39207), occur.
* This lower bound was established in b888a32eee8147b028464336ad2404d8155c64dd.
*/
- a = binarysearch_bezt_index_ex(bezts, evaltime, fcu->totvert, 0.0001, &exact);
+ a = BKE_fcurve_bezt_binarysearch_index_ex(bezts, evaltime, fcu->totvert, 0.0001, &exact);
bezt = bezts + a;
if (exact) {
@@ -1731,7 +1753,7 @@ static float fcurve_eval_keyframes_interpolate(FCurve *fcu, BezTriple *bezts, fl
return v1[1];
}
/* adjust handles so that they don't overlap (forming a loop) */
- correct_bezpart(v1, v2, v3, v4);
+ BKE_fcurve_correct_bezpart(v1, v2, v3, v4);
/* try to get a value for this position - if failure, try another set of points */
if (!findzero(evaltime, v1[0], v2[0], v3[0], v4[0], opl)) {
diff --git a/source/blender/blenkernel/intern/fcurve_test.cc b/source/blender/blenkernel/intern/fcurve_test.cc
index a58f519adfb..a230c8f2e96 100644
--- a/source/blender/blenkernel/intern/fcurve_test.cc
+++ b/source/blender/blenkernel/intern/fcurve_test.cc
@@ -27,7 +27,7 @@
namespace blender::bke::tests {
-// Epsilon for floating point comparisons.
+/* Epsilon for floating point comparisons. */
static const float EPSILON = 1e-7f;
TEST(evaluate_fcurve, EmptyFCurve)
@@ -45,13 +45,14 @@ TEST(evaluate_fcurve, OnKeys)
insert_vert_fcurve(fcu, 2.0f, 13.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_NO_USERPREF);
insert_vert_fcurve(fcu, 3.0f, 19.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_NO_USERPREF);
- EXPECT_NEAR(evaluate_fcurve(fcu, 1.0f), 7.0f, EPSILON); // hits 'on or before first' function
- EXPECT_NEAR(evaluate_fcurve(fcu, 2.0f), 13.0f, EPSILON); // hits 'between' function
- EXPECT_NEAR(evaluate_fcurve(fcu, 3.0f), 19.0f, EPSILON); // hits 'on or after last' function
+ EXPECT_NEAR(evaluate_fcurve(fcu, 1.0f), 7.0f, EPSILON); /* hits 'on or before first' function */
+ EXPECT_NEAR(evaluate_fcurve(fcu, 2.0f), 13.0f, EPSILON); /* hits 'between' function */
+ EXPECT_NEAR(evaluate_fcurve(fcu, 3.0f), 19.0f, EPSILON); /* hits 'on or after last' function */
/* Also test within a specific time epsilon of the keys, as this was an issue in T39207.
- * This epsilon is just slightly smaller than the epsilon given to binarysearch_bezt_index_ex()
- * in fcurve_eval_between_keyframes(), so it should hit the "exact" code path. */
+ * This epsilon is just slightly smaller than the epsilon given to
+ * BKE_fcurve_bezt_binarysearch_index_ex() in fcurve_eval_between_keyframes(), so it should hit
+ * the "exact" code path. */
float time_epsilon = 0.00008f;
EXPECT_NEAR(evaluate_fcurve(fcu, 2.0f - time_epsilon), 13.0f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, 2.0f + time_epsilon), 13.0f, EPSILON);
@@ -102,21 +103,21 @@ TEST(evaluate_fcurve, InterpolationBezier)
EXPECT_EQ(fcu->bezt[0].ipo, BEZT_IPO_BEZ);
EXPECT_EQ(fcu->bezt[1].ipo, BEZT_IPO_BEZ);
- // Test with default handles.
+ /* Test with default handles. */
EXPECT_NEAR(evaluate_fcurve(fcu, 1.25f), 7.8297067f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, 1.50f), 10.0f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, 1.75f), 12.170294f, EPSILON);
- // Test with modified handles.
- fcu->bezt[0].vec[0][0] = 0.71855f; // left handle X
- fcu->bezt[0].vec[0][1] = 6.22482f; // left handle Y
- fcu->bezt[0].vec[2][0] = 1.35148f; // right handle X
- fcu->bezt[0].vec[2][1] = 7.96806f; // right handle Y
+ /* Test with modified handles. */
+ fcu->bezt[0].vec[0][0] = 0.71855f; /* left handle X */
+ fcu->bezt[0].vec[0][1] = 6.22482f; /* left handle Y */
+ fcu->bezt[0].vec[2][0] = 1.35148f; /* right handle X */
+ fcu->bezt[0].vec[2][1] = 7.96806f; /* right handle Y */
- fcu->bezt[1].vec[0][0] = 1.66667f; // left handle X
- fcu->bezt[1].vec[0][1] = 10.4136f; // left handle Y
- fcu->bezt[1].vec[2][0] = 2.33333f; // right handle X
- fcu->bezt[1].vec[2][1] = 15.5864f; // right handle Y
+ fcu->bezt[1].vec[0][0] = 1.66667f; /* left handle X */
+ fcu->bezt[1].vec[0][1] = 10.4136f; /* left handle Y */
+ fcu->bezt[1].vec[2][0] = 2.33333f; /* right handle X */
+ fcu->bezt[1].vec[2][1] = 15.5864f; /* right handle Y */
EXPECT_NEAR(evaluate_fcurve(fcu, 1.25f), 7.945497f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, 1.50f), 9.3495407f, EPSILON);
@@ -155,19 +156,19 @@ TEST(evaluate_fcurve, ExtrapolationLinearKeys)
fcu->bezt[1].ipo = BEZT_IPO_LIN;
fcu->extend = FCURVE_EXTRAPOLATE_LINEAR;
- // Before first keyframe.
+ /* Before first keyframe. */
EXPECT_NEAR(evaluate_fcurve(fcu, 0.75f), 5.5f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, 0.50f), 4.0f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, -1.50f), -8.0f, EPSILON);
- // After last keyframe.
+ /* After last keyframe. */
EXPECT_NEAR(evaluate_fcurve(fcu, 2.75f), 17.5f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, 3.50f), 22.0f, EPSILON);
fcu->extend = FCURVE_EXTRAPOLATE_CONSTANT;
- // Before first keyframe.
+ /* Before first keyframe. */
EXPECT_NEAR(evaluate_fcurve(fcu, 0.75f), 7.0f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, -1.50f), 7.0f, EPSILON);
- // After last keyframe.
+ /* After last keyframe. */
EXPECT_NEAR(evaluate_fcurve(fcu, 2.75f), 13.0f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, 3.50f), 13.0f, EPSILON);
@@ -181,36 +182,36 @@ TEST(evaluate_fcurve, ExtrapolationBezierKeys)
EXPECT_EQ(insert_vert_fcurve(fcu, 1.0f, 7.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_NO_USERPREF), 0);
EXPECT_EQ(insert_vert_fcurve(fcu, 2.0f, 13.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_NO_USERPREF), 1);
- fcu->bezt[0].vec[0][0] = 0.71855f; // left handle X
- fcu->bezt[0].vec[0][1] = 6.22482f; // left handle Y
- fcu->bezt[0].vec[2][0] = 1.35148f; // right handle X
- fcu->bezt[0].vec[2][1] = 7.96806f; // right handle Y
+ fcu->bezt[0].vec[0][0] = 0.71855f; /* left handle X */
+ fcu->bezt[0].vec[0][1] = 6.22482f; /* left handle Y */
+ fcu->bezt[0].vec[2][0] = 1.35148f; /* right handle X */
+ fcu->bezt[0].vec[2][1] = 7.96806f; /* right handle Y */
- fcu->bezt[1].vec[0][0] = 1.66667f; // left handle X
- fcu->bezt[1].vec[0][1] = 10.4136f; // left handle Y
- fcu->bezt[1].vec[2][0] = 2.33333f; // right handle X
- fcu->bezt[1].vec[2][1] = 15.5864f; // right handle Y
+ fcu->bezt[1].vec[0][0] = 1.66667f; /* left handle X */
+ fcu->bezt[1].vec[0][1] = 10.4136f; /* left handle Y */
+ fcu->bezt[1].vec[2][0] = 2.33333f; /* right handle X */
+ fcu->bezt[1].vec[2][1] = 15.5864f; /* right handle Y */
fcu->extend = FCURVE_EXTRAPOLATE_LINEAR;
- // Before first keyframe.
+ /* Before first keyframe. */
EXPECT_NEAR(evaluate_fcurve(fcu, 0.75f), 6.3114409f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, -0.50f), 2.8686447f, EPSILON);
- // After last keyframe.
+ /* After last keyframe. */
EXPECT_NEAR(evaluate_fcurve(fcu, 2.75f), 18.81946f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, 3.50f), 24.63892f, EPSILON);
fcu->extend = FCURVE_EXTRAPOLATE_CONSTANT;
- // Before first keyframe.
+ /* Before first keyframe. */
EXPECT_NEAR(evaluate_fcurve(fcu, 0.75f), 7.0f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, -1.50f), 7.0f, EPSILON);
- // After last keyframe.
+ /* After last keyframe. */
EXPECT_NEAR(evaluate_fcurve(fcu, 2.75f), 13.0f, EPSILON);
EXPECT_NEAR(evaluate_fcurve(fcu, 3.50f), 13.0f, EPSILON);
BKE_fcurve_free(fcu);
}
-TEST(fcurve_subdivide, BKE_bezt_subdivide_handles)
+TEST(fcurve_subdivide, BKE_fcurve_bezt_subdivide_handles)
{
FCurve *fcu = BKE_fcurve_create();
@@ -232,7 +233,7 @@ TEST(fcurve_subdivide, BKE_bezt_subdivide_handles)
/* Create new keyframe point with defaults from insert_vert_fcurve(). */
BezTriple beztr;
- const float x = 7.375f; // at this X-coord, the FCurve should evaluate to 1.000f.
+ const float x = 7.375f; /* at this X-coord, the FCurve should evaluate to 1.000f. */
const float y = 1.000f;
beztr.vec[0][0] = x - 1.0f;
beztr.vec[0][1] = y;
@@ -245,29 +246,29 @@ TEST(fcurve_subdivide, BKE_bezt_subdivide_handles)
/* This should update the existing handles as well as the new BezTriple. */
float y_delta;
- BKE_bezt_subdivide_handles(&beztr, &fcu->bezt[0], &fcu->bezt[1], &y_delta);
+ BKE_fcurve_bezt_subdivide_handles(&beztr, &fcu->bezt[0], &fcu->bezt[1], &y_delta);
EXPECT_FLOAT_EQ(y_delta, 0.0f);
- EXPECT_FLOAT_EQ(fcu->bezt[0].vec[0][0], -5.0f); // Left handle should not be touched.
+ EXPECT_FLOAT_EQ(fcu->bezt[0].vec[0][0], -5.0f); /* Left handle should not be touched. */
EXPECT_FLOAT_EQ(fcu->bezt[0].vec[0][1], 0.0f);
- EXPECT_FLOAT_EQ(fcu->bezt[0].vec[1][0], 1.0f); // Coordinates should not be touched.
+ EXPECT_FLOAT_EQ(fcu->bezt[0].vec[1][0], 1.0f); /* Coordinates should not be touched. */
EXPECT_FLOAT_EQ(fcu->bezt[0].vec[1][1], 0.0f);
- EXPECT_FLOAT_EQ(fcu->bezt[0].vec[2][0], 1.5f); // Right handle should be updated.
+ EXPECT_FLOAT_EQ(fcu->bezt[0].vec[2][0], 1.5f); /* Right handle should be updated. */
EXPECT_FLOAT_EQ(fcu->bezt[0].vec[2][1], 2.0f);
- EXPECT_FLOAT_EQ(fcu->bezt[1].vec[0][0], 13.0f); // Left handle should be updated.
+ EXPECT_FLOAT_EQ(fcu->bezt[1].vec[0][0], 13.0f); /* Left handle should be updated. */
EXPECT_FLOAT_EQ(fcu->bezt[1].vec[0][1], 0.0f);
- EXPECT_FLOAT_EQ(fcu->bezt[1].vec[1][0], 13.0f); // Coordinates should not be touched.
+ EXPECT_FLOAT_EQ(fcu->bezt[1].vec[1][0], 13.0f); /* Coordinates should not be touched. */
EXPECT_FLOAT_EQ(fcu->bezt[1].vec[1][1], 2.0f);
- EXPECT_FLOAT_EQ(fcu->bezt[1].vec[2][0], 16.0f); // Right handle should not be touched
+ EXPECT_FLOAT_EQ(fcu->bezt[1].vec[2][0], 16.0f); /* Right handle should not be touched */
EXPECT_FLOAT_EQ(fcu->bezt[1].vec[2][1], -3.0f);
- EXPECT_FLOAT_EQ(beztr.vec[0][0], 4.5f); // Left handle should be updated.
+ EXPECT_FLOAT_EQ(beztr.vec[0][0], 4.5f); /* Left handle should be updated. */
EXPECT_FLOAT_EQ(beztr.vec[0][1], 1.5f);
- EXPECT_FLOAT_EQ(beztr.vec[1][0], 7.375f); // Coordinates should not be touched.
+ EXPECT_FLOAT_EQ(beztr.vec[1][0], 7.375f); /* Coordinates should not be touched. */
EXPECT_FLOAT_EQ(beztr.vec[1][1], 1.0f);
- EXPECT_FLOAT_EQ(beztr.vec[2][0], 10.250); // Right handle should be updated.
+ EXPECT_FLOAT_EQ(beztr.vec[2][0], 10.250); /* Right handle should be updated. */
EXPECT_FLOAT_EQ(beztr.vec[2][1], 0.5);
BKE_fcurve_free(fcu);
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 92decf000ca..7392c9161b8 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -33,6 +33,7 @@
#include "BLI_task.h"
#include "BLI_utildefines.h"
+#include "DNA_defaults.h"
#include "DNA_fluid_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
@@ -924,7 +925,7 @@ static void update_velocities(FluidEffectorSettings *fes,
velocity_map[index * 3 + 2] = hit_vel[2];
# ifdef DEBUG_PRINT
/* Debugging: Print object velocities. */
- printf("adding effector object vel: [%f, %f, %f]\n", hit_vel[0], hit_vel[1], hit_vel[2]);
+ printf("setting effector object vel: [%f, %f, %f]\n", hit_vel[0], hit_vel[1], hit_vel[2]);
# endif
}
else {
@@ -1064,7 +1065,7 @@ static void obstacles_from_mesh(Object *coll_ob,
add_v3fl_v3fl_v3i(co, mvert[i].co, fds->shift);
if (has_velocity) {
sub_v3_v3v3(&vert_vel[i * 3], co, &fes->verts_old[i * 3]);
- mul_v3_fl(&vert_vel[i * 3], fds->dx / dt);
+ mul_v3_fl(&vert_vel[i * 3], 1.0f / dt);
}
copy_v3_v3(&fes->verts_old[i * 3], co);
@@ -1823,6 +1824,7 @@ static void sample_mesh(FluidFlowSettings *ffs,
float *velocity_map,
int index,
const int base_res[3],
+ const float global_size[3],
const float flow_center[3],
BVHTreeFromMesh *tree_data,
const float ray_start[3],
@@ -1982,9 +1984,23 @@ static void sample_mesh(FluidFlowSettings *ffs,
printf("adding flow object vel: [%f, %f, %f]\n", hit_vel[0], hit_vel[1], hit_vel[2]);
# endif
}
- velocity_map[index * 3] += ffs->vel_coord[0];
- velocity_map[index * 3 + 1] += ffs->vel_coord[1];
- velocity_map[index * 3 + 2] += ffs->vel_coord[2];
+ /* Convert xyz velocities flow settings from world to grid space. */
+ float convert_vel[3];
+ copy_v3_v3(convert_vel, ffs->vel_coord);
+ float time_mult = 1.0 / (25.f * DT_DEFAULT);
+ float size_mult = MAX3(base_res[0], base_res[1], base_res[2]) /
+ MAX3(global_size[0], global_size[1], global_size[2]);
+ mul_v3_v3fl(convert_vel, ffs->vel_coord, size_mult * time_mult);
+
+ velocity_map[index * 3] += convert_vel[0];
+ velocity_map[index * 3 + 1] += convert_vel[1];
+ velocity_map[index * 3 + 2] += convert_vel[2];
+# ifdef DEBUG_PRINT
+ printf("initial vel: [%f, %f, %f]\n",
+ velocity_map[index * 3],
+ velocity_map[index * 3 + 1],
+ velocity_map[index * 3 + 2]);
+# endif
}
}
@@ -2038,6 +2054,7 @@ static void emit_from_mesh_task_cb(void *__restrict userdata,
bb->velocity,
index,
data->fds->base_res,
+ data->fds->global_size,
data->flow_center,
data->tree,
ray_start,
@@ -2135,7 +2152,7 @@ static void emit_from_mesh(
add_v3fl_v3fl_v3i(co, mvert[i].co, fds->shift);
if (has_velocity) {
sub_v3_v3v3(&vert_vel[i * 3], co, &ffs->verts_old[i * 3]);
- mul_v3_fl(&vert_vel[i * 3], fds->dx / dt);
+ mul_v3_fl(&vert_vel[i * 3], 1.0 / dt);
}
copy_v3_v3(&ffs->verts_old[i * 3], co);
}
@@ -2433,19 +2450,6 @@ static void adaptive_domain_adjust(
/* Redo adapt time step in manta to refresh solver state (ie time variables) */
manta_adapt_timestep(fds->fluid);
}
-
- /* update global size field with new bbox size */
- /* volume bounds */
- float minf[3], maxf[3], size[3];
- madd_v3fl_v3fl_v3fl_v3i(minf, fds->p0, fds->cell_size, fds->res_min);
- madd_v3fl_v3fl_v3fl_v3i(maxf, fds->p0, fds->cell_size, fds->res_max);
- /* calculate domain dimensions */
- sub_v3_v3v3(size, maxf, minf);
- /* apply object scale */
- for (int i = 0; i < 3; i++) {
- size[i] = fabsf(size[i] * ob->scale[i]);
- }
- copy_v3_v3(fds->global_size, size);
}
BLI_INLINE void apply_outflow_fields(int index,
@@ -3208,7 +3212,7 @@ static void update_effectors(
effectors = BKE_effectors_create(depsgraph, ob, NULL, fds->effector_weights);
if (effectors) {
- // precalculate wind forces
+ /* Precalculate wind forces. */
UpdateEffectorsData data;
data.scene = scene;
data.fds = fds;
@@ -4422,7 +4426,7 @@ float BKE_fluid_get_velocity_at(struct Object *ob, float position[3], float velo
FluidDomainSettings *fds = fmd->domain;
float time_mult = 25.f * DT_DEFAULT;
float size_mult = MAX3(fds->global_size[0], fds->global_size[1], fds->global_size[2]) /
- fds->maxres;
+ MAX3(fds->base_res[0], fds->base_res[1], fds->base_res[2]);
float vel_mag;
float density = 0.0f, fuel = 0.0f;
float pos[3];
@@ -4515,6 +4519,7 @@ void BKE_fluid_particle_system_create(struct Main *bmain,
part->totpart = 0;
part->draw_size = 0.01f; /* Make fluid particles more subtle in viewport. */
part->draw_col = PART_DRAW_COL_VEL;
+ part->phystype = PART_PHYS_NO; /* No physics needed, part system only used to display data. */
psys->part = part;
psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
BLI_strncpy(psys->name, parts_name, sizeof(psys->name));
@@ -4858,255 +4863,48 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *fmd)
BKE_fluid_modifier_freeDomain(fmd);
}
- /* domain object data */
- fmd->domain = MEM_callocN(sizeof(FluidDomainSettings), "FluidDomain");
+ fmd->domain = DNA_struct_default_alloc(FluidDomainSettings);
fmd->domain->fmd = fmd;
- fmd->domain->effector_weights = BKE_effector_add_weights(NULL);
- fmd->domain->fluid = NULL;
- fmd->domain->fluid_mutex = BLI_rw_mutex_alloc();
- fmd->domain->force_group = NULL;
- fmd->domain->fluid_group = NULL;
- fmd->domain->effector_group = NULL;
-
- /* adaptive domain options */
- fmd->domain->adapt_margin = 4;
- fmd->domain->adapt_res = 0;
- fmd->domain->adapt_threshold = 0.02f;
-
- /* fluid domain options */
- fmd->domain->maxres = 32;
- fmd->domain->solver_res = 3;
- fmd->domain->border_collisions = 0; // open domain
- fmd->domain->flags = FLUID_DOMAIN_USE_DISSOLVE_LOG | FLUID_DOMAIN_USE_ADAPTIVE_TIME;
- fmd->domain->gravity[0] = 0.0f;
- fmd->domain->gravity[1] = 0.0f;
- fmd->domain->gravity[2] = -9.81f;
- fmd->domain->active_fields = 0;
- fmd->domain->type = FLUID_DOMAIN_TYPE_GAS;
- fmd->domain->boundary_width = 1;
-
- /* smoke domain options */
- fmd->domain->alpha = 1.0f;
- fmd->domain->beta = 1.0f;
- fmd->domain->diss_speed = 5;
- fmd->domain->vorticity = 0;
- fmd->domain->active_color[0] = 0.0f;
- fmd->domain->active_color[1] = 0.0f;
- fmd->domain->active_color[2] = 0.0f;
- fmd->domain->highres_sampling = SM_HRES_FULLSAMPLE;
-
- /* flame options */
- fmd->domain->burning_rate = 0.75f;
- fmd->domain->flame_smoke = 1.0f;
- fmd->domain->flame_vorticity = 0.5f;
- fmd->domain->flame_ignition = 1.5f;
- fmd->domain->flame_max_temp = 3.0f;
- fmd->domain->flame_smoke_color[0] = 0.7f;
- fmd->domain->flame_smoke_color[1] = 0.7f;
- fmd->domain->flame_smoke_color[2] = 0.7f;
-
- /* noise options */
- fmd->domain->noise_strength = 1.0;
- fmd->domain->noise_pos_scale = 2.0f;
- fmd->domain->noise_time_anim = 0.1f;
- fmd->domain->noise_scale = 2;
- fmd->domain->noise_type = FLUID_NOISE_TYPE_WAVELET;
-
- /* liquid domain options */
- fmd->domain->simulation_method = FLUID_DOMAIN_METHOD_FLIP;
- fmd->domain->flip_ratio = 0.97f;
- fmd->domain->particle_randomness = 0.1f;
- fmd->domain->particle_number = 2;
- fmd->domain->particle_minimum = 8;
- fmd->domain->particle_maximum = 16;
- fmd->domain->particle_radius = 1.0f;
- fmd->domain->particle_band_width = 3.0f;
- fmd->domain->fractions_threshold = 0.05f;
- fmd->domain->sys_particle_maximum = 0;
-
- /* diffusion options*/
- fmd->domain->surface_tension = 0.0f;
- fmd->domain->viscosity_base = 1.0f;
- fmd->domain->viscosity_exponent = 6.0f;
-
- /* mesh options */
- fmd->domain->mesh_velocities = NULL;
- fmd->domain->mesh_concave_upper = 3.5f;
- fmd->domain->mesh_concave_lower = 0.4f;
- fmd->domain->mesh_particle_radius = 2.0;
- fmd->domain->mesh_smoothen_pos = 1;
- fmd->domain->mesh_smoothen_neg = 1;
- fmd->domain->mesh_scale = 2;
- fmd->domain->totvert = 0;
- fmd->domain->mesh_generator = FLUID_DOMAIN_MESH_IMPROVED;
-
- /* secondary particle options */
- fmd->domain->sndparticle_tau_min_wc = 2.0;
- fmd->domain->sndparticle_tau_max_wc = 8.0;
- fmd->domain->sndparticle_tau_min_ta = 5.0;
- fmd->domain->sndparticle_tau_max_ta = 20.0;
- fmd->domain->sndparticle_tau_min_k = 1.0;
- fmd->domain->sndparticle_tau_max_k = 5.0;
- fmd->domain->sndparticle_k_wc = 200;
- fmd->domain->sndparticle_k_ta = 40;
- fmd->domain->sndparticle_k_b = 0.5;
- fmd->domain->sndparticle_k_d = 0.6;
- fmd->domain->sndparticle_l_min = 10.0;
- fmd->domain->sndparticle_l_max = 25.0;
- fmd->domain->sndparticle_boundary = SNDPARTICLE_BOUNDARY_DELETE;
- fmd->domain->sndparticle_combined_export = SNDPARTICLE_COMBINED_EXPORT_OFF;
- fmd->domain->sndparticle_potential_radius = 2;
- fmd->domain->sndparticle_update_radius = 2;
- fmd->domain->particle_type = 0;
- fmd->domain->particle_scale = 1;
-
- /* fluid guide options */
- fmd->domain->guide_parent = NULL;
- fmd->domain->guide_alpha = 2.0f;
- fmd->domain->guide_beta = 5;
- fmd->domain->guide_vel_factor = 2.0f;
- fmd->domain->guide_source = FLUID_DOMAIN_GUIDE_SRC_DOMAIN;
- /* cache options */
- fmd->domain->cache_frame_start = 1;
- fmd->domain->cache_frame_end = 250;
- fmd->domain->cache_frame_pause_data = 0;
- fmd->domain->cache_frame_pause_noise = 0;
- fmd->domain->cache_frame_pause_mesh = 0;
- fmd->domain->cache_frame_pause_particles = 0;
- fmd->domain->cache_frame_pause_guide = 0;
- fmd->domain->cache_frame_offset = 0;
- fmd->domain->cache_flag = 0;
- fmd->domain->cache_type = FLUID_DOMAIN_CACHE_REPLAY;
- fmd->domain->cache_mesh_format = FLUID_DOMAIN_FILE_BIN_OBJECT;
-#ifdef WITH_OPENVDB
- fmd->domain->cache_data_format = FLUID_DOMAIN_FILE_OPENVDB;
- fmd->domain->cache_particle_format = FLUID_DOMAIN_FILE_OPENVDB;
- fmd->domain->cache_noise_format = FLUID_DOMAIN_FILE_OPENVDB;
-#else
+ /* Turn off incompatible options. */
+#ifndef WITH_OPENVDB
fmd->domain->cache_data_format = FLUID_DOMAIN_FILE_UNI;
fmd->domain->cache_particle_format = FLUID_DOMAIN_FILE_UNI;
fmd->domain->cache_noise_format = FLUID_DOMAIN_FILE_UNI;
#endif
+#ifndef WITH_OPENVDB_BLOSC
+ fmd->domain->openvdb_compression = VDB_COMPRESSION_ZIP;
+#endif
+
+ fmd->domain->effector_weights = BKE_effector_add_weights(NULL);
+ fmd->domain->fluid_mutex = BLI_rw_mutex_alloc();
+
char cache_name[64];
BKE_fluid_cache_new_name_for_current_session(sizeof(cache_name), cache_name);
BKE_modifier_path_init(
fmd->domain->cache_directory, sizeof(fmd->domain->cache_directory), cache_name);
- /* time options */
- fmd->domain->time_scale = 1.0;
- fmd->domain->cfl_condition = 4.0;
- fmd->domain->timesteps_minimum = 1;
- fmd->domain->timesteps_maximum = 4;
-
- /* display options */
- fmd->domain->axis_slice_method = AXIS_SLICE_FULL;
- fmd->domain->slice_axis = 0;
- fmd->domain->interp_method = FLUID_DISPLAY_INTERP_LINEAR;
- fmd->domain->draw_velocity = false;
- fmd->domain->slice_per_voxel = 5.0f;
- fmd->domain->slice_depth = 0.5f;
- fmd->domain->display_thickness = 1.0f;
- fmd->domain->show_gridlines = false;
- fmd->domain->coba = NULL;
- fmd->domain->grid_scale = 1.0f;
- fmd->domain->vector_scale = 1.0f;
- fmd->domain->vector_draw_type = VECTOR_DRAW_NEEDLE;
- fmd->domain->vector_field = FLUID_DOMAIN_VECTOR_FIELD_VELOCITY;
- fmd->domain->vector_scale_with_magnitude = true;
- fmd->domain->vector_draw_mac_components = VECTOR_DRAW_MAC_X | VECTOR_DRAW_MAC_Y |
- VECTOR_DRAW_MAC_Z;
- fmd->domain->use_coba = false;
- fmd->domain->coba_field = FLUID_DOMAIN_FIELD_DENSITY;
- fmd->domain->gridlines_color_field = 0;
- fmd->domain->gridlines_lower_bound = 0.0f;
- fmd->domain->gridlines_upper_bound = 1.0f;
- fmd->domain->gridlines_range_color[0] = 1.0f;
- fmd->domain->gridlines_range_color[1] = 0.0f;
- fmd->domain->gridlines_range_color[2] = 0.0f;
- fmd->domain->gridlines_range_color[3] = 1.0f;
- fmd->domain->gridlines_cell_filter = FLUID_CELL_TYPE_NONE;
-
- /* -- Deprecated / unsed options (below)-- */
-
/* pointcache options */
- BLI_listbase_clear(&fmd->domain->ptcaches[1]);
fmd->domain->point_cache[0] = BKE_ptcache_add(&(fmd->domain->ptcaches[0]));
fmd->domain->point_cache[0]->flag |= PTCACHE_DISK_CACHE;
fmd->domain->point_cache[0]->step = 1;
fmd->domain->point_cache[1] = NULL; /* Deprecated */
- fmd->domain->cache_comp = SM_CACHE_LIGHT;
- fmd->domain->cache_high_comp = SM_CACHE_LIGHT;
-
- /* OpenVDB cache options */
-#ifdef WITH_OPENVDB_BLOSC
- fmd->domain->openvdb_compression = VDB_COMPRESSION_BLOSC;
-#else
- fmd->domain->openvdb_compression = VDB_COMPRESSION_ZIP;
-#endif
- fmd->domain->clipping = 1e-6f;
- fmd->domain->openvdb_data_depth = 0;
}
else if (fmd->type & MOD_FLUID_TYPE_FLOW) {
if (fmd->flow) {
BKE_fluid_modifier_freeFlow(fmd);
}
- /* flow object data */
- fmd->flow = MEM_callocN(sizeof(FluidFlowSettings), "MantaFlow");
+ fmd->flow = DNA_struct_default_alloc(FluidFlowSettings);
fmd->flow->fmd = fmd;
- fmd->flow->mesh = NULL;
- fmd->flow->psys = NULL;
- fmd->flow->noise_texture = NULL;
-
- /* initial velocity */
- fmd->flow->verts_old = NULL;
- fmd->flow->numverts = 0;
- fmd->flow->vel_multi = 1.0f;
- fmd->flow->vel_normal = 0.0f;
- fmd->flow->vel_random = 0.0f;
- fmd->flow->vel_coord[0] = 0.0f;
- fmd->flow->vel_coord[1] = 0.0f;
- fmd->flow->vel_coord[2] = 0.0f;
-
- /* emission */
- fmd->flow->density = 1.0f;
- fmd->flow->color[0] = 0.7f;
- fmd->flow->color[1] = 0.7f;
- fmd->flow->color[2] = 0.7f;
- fmd->flow->fuel_amount = 1.0f;
- fmd->flow->temperature = 1.0f;
- fmd->flow->volume_density = 0.0f;
- fmd->flow->surface_distance = 1.5f;
- fmd->flow->particle_size = 1.0f;
- fmd->flow->subframes = 0;
-
- /* texture control */
- fmd->flow->source = FLUID_FLOW_SOURCE_MESH;
- fmd->flow->texture_size = 1.0f;
-
- fmd->flow->type = FLUID_FLOW_TYPE_SMOKE;
- fmd->flow->behavior = FLUID_FLOW_BEHAVIOR_GEOMETRY;
- fmd->flow->flags = FLUID_FLOW_ABSOLUTE | FLUID_FLOW_USE_PART_SIZE | FLUID_FLOW_USE_INFLOW;
}
else if (fmd->type & MOD_FLUID_TYPE_EFFEC) {
if (fmd->effector) {
BKE_fluid_modifier_freeEffector(fmd);
}
- /* effector object data */
- fmd->effector = MEM_callocN(sizeof(FluidEffectorSettings), "MantaEffector");
+ fmd->effector = DNA_struct_default_alloc(FluidEffectorSettings);
fmd->effector->fmd = fmd;
- fmd->effector->mesh = NULL;
- fmd->effector->verts_old = NULL;
- fmd->effector->numverts = 0;
- fmd->effector->surface_distance = 0.0f;
- fmd->effector->type = FLUID_EFFECTOR_TYPE_COLLISION;
- fmd->effector->flags = FLUID_EFFECTOR_USE_EFFEC;
-
- /* guide options */
- fmd->effector->guide_mode = FLUID_EFFECTOR_GUIDE_OVERRIDE;
- fmd->effector->vel_multi = 1.0f;
}
}
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 621e3087d09..3267952f092 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -46,7 +46,9 @@
static CLG_LogRef LOG = {"bke.fmodifier"};
-/* ******************************** F-Modifiers ********************************* */
+/* -------------------------------------------------------------------- */
+/** \name F-Curve Modifier Types
+ * \{ */
/* Info ------------------------------- */
@@ -131,8 +133,8 @@ static void fcm_generator_new_data(void *mdata)
data->poly_order = 1;
data->arraysize = 2;
cp = data->coefficients = MEM_callocN(sizeof(float) * 2, "FMod_Generator_Coefs");
- cp[0] = 0; // y-offset
- cp[1] = 1; // gradient
+ cp[0] = 0; /* y-offset */
+ cp[1] = 1; /* gradient */
}
static void fcm_generator_verify(FModifier *fcm)
@@ -1033,16 +1035,20 @@ static FModifierTypeInfo FMI_STEPPED = {
NULL, /* evaluate */
};
-/* F-Curve Modifier API --------------------------- */
-/* All of the F-Curve Modifier api functions use FModifierTypeInfo structs to carry out
- * and operations that involve F-Curve modifier specific code.
- */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name F-Curve Modifier Type API
+ *
+ * all of the f-curve modifier api functions use #fmodifiertypeinfo structs to carry out
+ * and operations that involve f-curve modifier specific code.
+ * \{ */
/* These globals only ever get directly accessed in this file */
static FModifierTypeInfo *fmodifiersTypeInfo[FMODIFIER_NUM_TYPES];
static short FMI_INIT = 1; /* when non-zero, the list needs to be updated */
-/* This function only gets called when FMI_INIT is non-zero */
+/** This function only gets called when #FMI_INIT is non-zero. */
static void fmods_init_typeinfo(void)
{
fmodifiersTypeInfo[0] = NULL; /* 'Null' F-Curve Modifier */
@@ -1051,14 +1057,16 @@ static void fmods_init_typeinfo(void)
fmodifiersTypeInfo[3] = &FMI_ENVELOPE; /* Envelope F-Curve Modifier */
fmodifiersTypeInfo[4] = &FMI_CYCLES; /* Cycles F-Curve Modifier */
fmodifiersTypeInfo[5] = &FMI_NOISE; /* Apply-Noise F-Curve Modifier */
- fmodifiersTypeInfo[6] = NULL /*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented
+ fmodifiersTypeInfo[6] = NULL /*&FMI_FILTER*/;
+ /* Filter F-Curve Modifier */ /* XXX unimplemented. */
fmodifiersTypeInfo[7] = &FMI_PYTHON; /* Custom Python F-Curve Modifier */
fmodifiersTypeInfo[8] = &FMI_LIMITS; /* Limits F-Curve Modifier */
fmodifiersTypeInfo[9] = &FMI_STEPPED; /* Stepped F-Curve Modifier */
}
-/* This function should be used for getting the appropriate type-info when only
- * a F-Curve modifier type is known
+/**
+ * This function should be used for getting the appropriate type-info when only
+ * a F-Curve modifier type is known.
*/
const FModifierTypeInfo *get_fmodifier_typeinfo(const int type)
{
@@ -1079,8 +1087,9 @@ const FModifierTypeInfo *get_fmodifier_typeinfo(const int type)
return NULL;
}
-/* This function should always be used to get the appropriate type-info, as it
- * has checks which prevent segfaults in some weird cases.
+/**
+ * This function should always be used to get the appropriate type-info,
+ * as it has checks which prevent segfaults in some weird cases.
*/
const FModifierTypeInfo *fmodifier_get_typeinfo(const FModifier *fcm)
{
@@ -1092,9 +1101,15 @@ const FModifierTypeInfo *fmodifier_get_typeinfo(const FModifier *fcm)
return NULL;
}
-/* API --------------------------- */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name F-Curve Modifier Public API
+ * \{ */
-/* Add a new F-Curve Modifier to the given F-Curve of a certain type */
+/**
+ * Add a new F-Curve Modifier to the given F-Curve of a certain type.
+ */
FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
{
const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type);
@@ -1145,7 +1160,9 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
return fcm;
}
-/* Make a copy of the specified F-Modifier */
+/**
+ * Make a copy of the specified F-Modifier.
+ */
FModifier *copy_fmodifier(const FModifier *src)
{
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(src);
@@ -1173,7 +1190,9 @@ FModifier *copy_fmodifier(const FModifier *src)
return dst;
}
-/* Duplicate all of the F-Modifiers in the Modifier stacks */
+/**
+ * Duplicate all of the F-Modifiers in the Modifier stacks.
+ */
void copy_fmodifiers(ListBase *dst, const ListBase *src)
{
FModifier *fcm, *srcfcm;
@@ -1200,7 +1219,9 @@ void copy_fmodifiers(ListBase *dst, const ListBase *src)
}
}
-/* Remove and free the given F-Modifier from the given stack */
+/**
+ * Remove and free the given F-Modifier from the given stack.
+ */
bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
{
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
@@ -1241,7 +1262,9 @@ bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
return false;
}
-/* Remove all of a given F-Curve's modifiers */
+/**
+ * Remove all of a given F-Curve's modifiers.
+ */
void free_fmodifiers(ListBase *modifiers)
{
FModifier *fcm, *fmn;
@@ -1258,7 +1281,9 @@ void free_fmodifiers(ListBase *modifiers)
}
}
-/* Find the active F-Modifier */
+/**
+ * Find the active F-Modifier.
+ */
FModifier *find_active_fmodifier(ListBase *modifiers)
{
FModifier *fcm;
@@ -1279,7 +1304,9 @@ FModifier *find_active_fmodifier(ListBase *modifiers)
return NULL;
}
-/* Set the active F-Modifier */
+/**
+ * Set the active F-Modifier.
+ */
void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
{
FModifier *fm;
@@ -1300,9 +1327,11 @@ void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
}
}
-/* Do we have any modifiers which match certain criteria
- * - mtype - type of modifier (if 0, doesn't matter)
- * - acttype - type of action to perform (if -1, doesn't matter)
+/**
+ * Do we have any modifiers which match certain criteria.
+ *
+ * \param mtype: Type of modifier (if 0, doesn't matter).
+ * \param acttype: Type of action to perform (if -1, doesn't matter).
*/
bool list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
{
@@ -1318,7 +1347,7 @@ bool list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
return false;
}
- /* find the first mdifier fitting these criteria */
+ /* Find the first modifier fitting these criteria. */
for (fcm = modifiers->first; fcm; fcm = fcm->next) {
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
short mOk = 1, aOk = 1; /* by default 1, so that when only one test, won't fail */
@@ -1365,7 +1394,9 @@ uint evaluate_fmodifiers_storage_size_per_modifier(ListBase *modifiers)
return max_size;
}
-/* helper function - calculate influence of FModifier */
+/**
+ * Helper function - calculate influence of #FModifier.
+ */
static float eval_fmodifier_influence(FModifier *fcm, float evaltime)
{
float influence;
@@ -1409,16 +1440,18 @@ static float eval_fmodifier_influence(FModifier *fcm, float evaltime)
return influence;
}
-/* evaluate time modifications imposed by some F-Curve Modifiers
- * - this step acts as an optimization to prevent the F-Curve stack being evaluated
+/**
+ * Evaluate time modifications imposed by some F-Curve Modifiers.
+ *
+ * - This step acts as an optimization to prevent the F-Curve stack being evaluated
* several times by modifiers requesting the time be modified, as the final result
* would have required using the modified time
- * - modifiers only ever receive the unmodified time, as subsequent modifiers should be
+ * - Modifiers only ever receive the unmodified time, as subsequent modifiers should be
* working on the 'global' result of the modified curve, not some localized segment,
- * so nevaltime gets set to whatever the last time-modifying modifier likes...
- * - we start from the end of the stack, as only the last one matters for now
+ * so \a evaltime gets set to whatever the last time-modifying modifier likes.
+ * - We start from the end of the stack, as only the last one matters for now.
*
- * Note: *fcu might be NULL
+ * \param fcu: Can be NULL.
*/
float evaluate_time_fmodifiers(FModifiersStackStorage *storage,
ListBase *modifiers,
@@ -1477,8 +1510,9 @@ float evaluate_time_fmodifiers(FModifiersStackStorage *storage,
return evaltime;
}
-/* Evaluates the given set of F-Curve Modifiers using the given data
- * Should only be called after evaluate_time_fmodifiers() has been called...
+/**
+ * Evaluates the given set of F-Curve Modifiers using the given data
+ * Should only be called after evaluate_time_fmodifiers() has been called.
*/
void evaluate_value_fmodifiers(FModifiersStackStorage *storage,
ListBase *modifiers,
@@ -1528,7 +1562,8 @@ void evaluate_value_fmodifiers(FModifiersStackStorage *storage,
/* ---------- */
-/* Bake modifiers for given F-Curve to curve sample data, in the frame range defined
+/**
+ * Bake modifiers for given F-Curve to curve sample data, in the frame range defined
* by start and end (inclusive).
*/
void fcurve_bake_modifiers(FCurve *fcu, int start, int end)
@@ -1555,3 +1590,5 @@ void fcurve_bake_modifiers(FCurve *fcu, int start, int end)
/* restore driver */
fcu->driver = driver;
}
+
+/** \} */
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index 3a35836d4d5..313b0d192dc 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -244,9 +244,7 @@ static void hair_random(Hair *hair)
void *BKE_hair_add(Main *bmain, const char *name)
{
- Hair *hair = BKE_libblock_alloc(bmain, ID_HA, name, 0);
-
- hair_init_data(&hair->id);
+ Hair *hair = BKE_id_new(bmain, ID_HA, name);
return hair;
}
@@ -404,10 +402,10 @@ void BKE_hair_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Obje
}
/* Draw Cache */
-void (*BKE_hair_batch_cache_dirty_tag_cb)(Hair *hair, eMeshBatchDirtyMode mode) = NULL;
+void (*BKE_hair_batch_cache_dirty_tag_cb)(Hair *hair, int mode) = NULL;
void (*BKE_hair_batch_cache_free_cb)(Hair *hair) = NULL;
-void BKE_hair_batch_cache_dirty_tag(Hair *hair, eMeshBatchDirtyMode mode)
+void BKE_hair_batch_cache_dirty_tag(Hair *hair, int mode)
{
if (hair->batch_cache) {
BKE_hair_batch_cache_dirty_tag_cb(hair, mode);
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index 01e3eef4e19..bcec90cf0cf 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -51,7 +51,7 @@
#include "BKE_icons.h"
#include "BKE_studiolight.h"
-#include "BLI_sys_types.h" // for intptr_t support
+#include "BLI_sys_types.h" /* for intptr_t support */
#include "GPU_texture.h"
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index af15b9143e7..9ad71918242 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -967,7 +967,7 @@ bool IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
* \code{.c}
* IDPropertyTemplate val;
* IDProperty *group, *idgroup, *color;
- * group = IDP_New(IDP_GROUP, val, "group1"); //groups don't need a template.
+ * group = IDP_New(IDP_GROUP, val, "group1"); // groups don't need a template.
*
* val.array.len = 4
* val.array.type = IDP_FLOAT;
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 29cf3cc0a8d..07e31abab48 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -95,7 +95,7 @@
#include "GPU_texture.h"
-#include "BLI_sys_types.h" // for intptr_t support
+#include "BLI_sys_types.h" /* for intptr_t support */
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@@ -1812,7 +1812,7 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i
im_format->depth = R_IMF_CHAN_DEPTH_16;
}
if (custom_flags & OPENEXR_COMPRESS) {
- im_format->exr_codec = R_IMF_EXR_CODEC_ZIP; // Can't determine compression
+ im_format->exr_codec = R_IMF_EXR_CODEC_ZIP; /* Can't determine compression */
}
if (imbuf->zbuf_float) {
im_format->flag |= R_IMF_FLAG_ZBUF;
@@ -2200,7 +2200,7 @@ void BKE_image_stamp_buf(Scene *scene,
float w, h, pad;
int x, y, y_ofs;
float h_fixed;
- const int mono = blf_mono_font_render; // XXX
+ const int mono = blf_mono_font_render; /* XXX */
struct ColorManagedDisplay *display;
const char *display_device;
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 17060750ed9..1a87b931689 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -177,7 +177,7 @@ static AdrBit2Path *adrcode_bitmaps_to_paths(int blocktype, int adrcode, int *to
if ((blocktype == ID_OB) && (adrcode == OB_LAY)) {
RET_ABP(ob_layer_bits);
}
- // XXX TODO: add other types...
+ /* XXX TODO: add other types... */
/* Normal curve */
return NULL;
@@ -473,7 +473,7 @@ static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index))
/* property identifier for path */
adrcode = (adrcode & (MA_MAP1 - 1));
switch (adrcode) {
-#if 0 // XXX these are not wrapped in RNA yet!
+#if 0 /* XXX these are not wrapped in RNA yet! */
case MAP_OFS_X:
poin = &(mtex->ofs[0]);
break;
@@ -541,17 +541,17 @@ static const char *texture_adrcodes_to_paths(int adrcode, int *array_index)
case TE_TURB:
return "turbulence";
- case TE_NDEPTH: // XXX texture RNA undefined
+ case TE_NDEPTH: /* XXX texture RNA undefined */
// poin= &(tex->noisedepth); *type= IPO_SHORT; break;
break;
- case TE_NTYPE: // XXX texture RNA undefined
+ case TE_NTYPE: /* XXX texture RNA undefined */
// poin= &(tex->noisetype); *type= IPO_SHORT; break;
break;
case TE_N_BAS1:
return "noise_basis";
case TE_N_BAS2:
- return "noise_basis"; // XXX this is not yet defined in RNA...
+ return "noise_basis"; /* XXX this is not yet defined in RNA... */
/* voronoi */
case TE_VNW1:
@@ -582,7 +582,7 @@ static const char *texture_adrcodes_to_paths(int adrcode, int *array_index)
return "distortion_amount";
/* musgrave */
- case TE_MG_TYP: // XXX texture RNA undefined
+ case TE_MG_TYP: /* XXX texture RNA undefined */
// poin= &(tex->stype); *type= IPO_SHORT; break;
break;
case TE_MGH:
@@ -717,31 +717,31 @@ static const char *camera_adrcodes_to_paths(int adrcode, int *array_index)
/* result depends on adrcode */
switch (adrcode) {
case CAM_LENS:
-#if 0 /* XXX this cannot be resolved easily... \
- * perhaps we assume camera is perspective (works for most cases... */
+#if 0 /* XXX this cannot be resolved easily... \
+ * perhaps we assume camera is perspective (works for most cases... */
if (ca->type == CAM_ORTHO) {
return "ortho_scale";
}
else {
return "lens";
}
-#else // XXX lazy hack for now...
+#else /* XXX lazy hack for now... */
return "lens";
-#endif // XXX this cannot be resolved easily
+#endif /* XXX this cannot be resolved easily */
case CAM_STA:
return "clip_start";
case CAM_END:
return "clip_end";
-#if 0 // XXX these are not defined in RNA
+#if 0 /* XXX these are not defined in RNA */
case CAM_YF_APERT:
poin = &(ca->YF_aperture);
break;
case CAM_YF_FDIST:
poin = &(ca->dof_distance);
break;
-#endif // XXX these are not defined in RNA
+#endif /* XXX these are not defined in RNA */
case CAM_SHIFT_X:
return "shift_x";
@@ -1040,7 +1040,7 @@ static char *get_rna_access(ID *id,
/* XXX problematic blocktypes */
case ID_SEQ: /* sequencer strip */
- // SEQ_FAC1:
+ /* SEQ_FAC1: */
switch (adrcode) {
case SEQ_FAC1:
propname = "effect_fader";
@@ -1052,7 +1052,8 @@ static char *get_rna_access(ID *id,
propname = "blend_opacity";
break;
}
- // poin= &(seq->facf0); // XXX this doesn't seem to be included anywhere in sequencer RNA...
+ /* XXX this doesn't seem to be included anywhere in sequencer RNA... */
+ // poin= &(seq->facf0);
break;
/* special hacks */
@@ -1187,7 +1188,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
/* if 'pydriver', just copy data across */
if (idriver->type == IPO_DRIVER_TYPE_PYTHON) {
/* PyDriver only requires the expression to be copied */
- // FIXME: expression will be useless due to API changes, but at least not totally lost
+ /* FIXME: expression will be useless due to API changes, but at least not totally lost */
cdriver->type = DRIVER_TYPE_PYTHON;
if (idriver->name[0]) {
BLI_strncpy(cdriver->expression, idriver->name, sizeof(cdriver->expression));
@@ -1219,7 +1220,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
dtar = &dvar->targets[1];
dtar->id = (ID *)idriver->ob;
dtar->idtype = ID_OB;
- if (idriver->name[0]) { // xxx... for safety
+ if (idriver->name[0]) { /* xxx... for safety */
BLI_strncpy(
dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS, sizeof(dtar->pchan_name));
}
@@ -1272,7 +1273,7 @@ static void fcurve_add_to_list(
bActionGroup *agrp = NULL;
/* init the temp action */
- memset(&tmp_act, 0, sizeof(bAction)); // XXX only enable this line if we get errors
+ memset(&tmp_act, 0, sizeof(bAction)); /* XXX only enable this line if we get errors */
tmp_act.groups.first = groups->first;
tmp_act.groups.last = groups->last;
tmp_act.curves.first = list->first;
@@ -1544,7 +1545,7 @@ static void icu_to_fcurves(ID *id,
*/
if (((icu->blocktype == ID_OB) && ELEM(icu->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) ||
((icu->blocktype == ID_PO) && ELEM(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z))) {
- const float fac = (float)M_PI / 18.0f; // 10.0f * M_PI/180.0f;
+ const float fac = (float)M_PI / 18.0f; /* 10.0f * M_PI/180.0f; */
dst->vec[0][1] *= fac;
dst->vec[1][1] *= fac;
@@ -1719,7 +1720,7 @@ static void action_to_animato(
}
/* get rid of all Action Groups */
- // XXX this is risky if there's some old + some new data in the Action...
+ /* XXX this is risky if there's some old + some new data in the Action... */
if (act->groups.first) {
BLI_freelistN(&act->groups);
}
@@ -1793,7 +1794,7 @@ static void ipo_to_animdata(
/* Convert curves to animato system
* (separated into separate lists of F-Curves for animation and drivers),
* and the try to put these lists in the right places, but do not free the lists here. */
- // XXX there shouldn't be any need for the groups, so don't supply pointer for that now...
+ /* XXX there shouldn't be any need for the groups, so don't supply pointer for that now... */
ipo_to_animato(id, ipo, actname, constname, seq, NULL, &anim, &drivers);
/* deal with animation first */
@@ -1942,7 +1943,7 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips)
}
/* modifiers */
- // FIXME: for now, we just free them...
+ /* FIXME: for now, we just free them... */
if (as->modifiers.first) {
BLI_freelistN(&as->modifiers);
}
@@ -1965,7 +1966,7 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips)
* Data that has been converted should be freed immediately, which means that it is immediately
* clear which data-blocks have yet to be converted, and also prevent freeing errors when we exit.
*/
-// XXX currently done after all file reading...
+/* XXX currently done after all file reading... */
void do_versions_ipos_to_animato(Main *bmain)
{
ListBase drivers = {NULL, NULL};
@@ -2084,7 +2085,7 @@ void do_versions_ipos_to_animato(Main *bmain)
}
/* check for Action Constraint */
- // XXX do we really want to do this here?
+ /* XXX do we really want to do this here? */
}
/* check constraint channels - we need to remove them anyway... */
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index b93adf43751..95a8419b95d 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -183,14 +183,14 @@ static void shapekey_blend_read_lib(BlendLibReader *reader, ID *id)
Key *key = (Key *)id;
BLI_assert((key->id.tag & LIB_TAG_EXTERN) == 0);
- BLO_read_id_address(reader, key->id.lib, &key->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, key->id.lib, &key->ipo); /* XXX deprecated - old animation system */
BLO_read_id_address(reader, key->id.lib, &key->from);
}
static void shapekey_blend_read_expand(BlendExpander *expander, ID *id)
{
Key *key = (Key *)id;
- BLO_expand(expander, key->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, key->ipo); /* XXX deprecated - old animation system */
}
IDTypeInfo IDType_ID_KE = {
@@ -249,7 +249,7 @@ Key *BKE_key_add(Main *bmain, ID *id) /* common function */
Key *key;
char *el;
- key = BKE_libblock_alloc(bmain, ID_KE, "Key", 0);
+ key = BKE_id_new(bmain, ID_KE, "Key");
key->type = KEY_NORMAL;
key->from = id;
@@ -296,36 +296,6 @@ Key *BKE_key_add(Main *bmain, ID *id) /* common function */
return key;
}
-/* XXX TODO get rid of this! */
-Key *BKE_key_copy_nolib(Key *key)
-{
- Key *keyn;
- KeyBlock *kbn, *kb;
-
- keyn = MEM_dupallocN(key);
-
- keyn->adt = NULL;
-
- BLI_duplicatelist(&keyn->block, &key->block);
-
- kb = key->block.first;
- kbn = keyn->block.first;
- while (kbn) {
-
- if (kbn->data) {
- kbn->data = MEM_dupallocN(kbn->data);
- }
- if (kb == key->refkey) {
- keyn->refkey = kbn;
- }
-
- kbn = kbn->next;
- kb = kb->next;
- }
-
- return keyn;
-}
-
/* Sort shape keys and Ipo curves after a change. This assumes that at most
* one key was moved, which is a valid assumption for the places it's
* currently being called.
@@ -952,7 +922,7 @@ static void key_evaluate_relative(const int start,
reffrom = refb->data;
poin += start * poinsize;
- reffrom += key->elemsize * start; // key elemsize yes!
+ reffrom += key->elemsize * start; /* key elemsize yes! */
from += key->elemsize * start;
for (b = start; b < end; b += step) {
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index bb62e4c2495..fc0e337ec30 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -394,9 +394,7 @@ Lattice *BKE_lattice_add(Main *bmain, const char *name)
{
Lattice *lt;
- lt = BKE_libblock_alloc(bmain, ID_LT, name, 0);
-
- lattice_init_data(&lt->id);
+ lt = BKE_id_new(bmain, ID_LT, name);
return lt;
}
@@ -801,10 +799,10 @@ void BKE_lattice_eval_geometry(struct Depsgraph *UNUSED(depsgraph), Lattice *UNU
}
/* Draw Engine */
-void (*BKE_lattice_batch_cache_dirty_tag_cb)(Lattice *lt, eMeshBatchDirtyMode mode) = NULL;
+void (*BKE_lattice_batch_cache_dirty_tag_cb)(Lattice *lt, int mode) = NULL;
void (*BKE_lattice_batch_cache_free_cb)(Lattice *lt) = NULL;
-void BKE_lattice_batch_cache_dirty_tag(Lattice *lt, eMeshBatchDirtyMode mode)
+void BKE_lattice_batch_cache_dirty_tag(Lattice *lt, int mode)
{
if (lt->batch_cache) {
BKE_lattice_batch_cache_dirty_tag_cb(lt, mode);
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 4ed8a796d5d..6efc9d0753e 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -1631,18 +1631,19 @@ void BKE_view_layer_selected_editable_objects_iterator_begin(BLI_Iterator *iter,
objects_iterator_begin(iter, data_in, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED);
if (iter->valid) {
if (BKE_object_is_libdata((Object *)iter->current) == false) {
- // First object is valid (selectable and not libdata) -> all good.
+ /* First object is valid (selectable and not libdata) -> all good. */
return;
}
- // Object is selectable but not editable -> search for another one.
+ /* Object is selectable but not editable -> search for another one. */
BKE_view_layer_selected_editable_objects_iterator_next(iter);
}
}
void BKE_view_layer_selected_editable_objects_iterator_next(BLI_Iterator *iter)
{
- // Search while there are objects and the one we have is not editable (editable = not libdata).
+ /* Search while there are objects and the one we have is not editable (editable = not libdata).
+ */
do {
objects_iterator_next(iter, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED);
} while (iter->valid && BKE_object_is_libdata((Object *)iter->current) != false);
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index a989a865994..e008058ae39 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -597,32 +597,30 @@ static void lib_override_library_create_post_process(
case ID_GR: {
default_instantiating_collection = BKE_collection_add(
bmain, (Collection *)id_root, "OVERRIDE_HIDDEN");
+ /* Hide the collection from viewport and render. */
+ default_instantiating_collection->flag |= COLLECTION_RESTRICT_VIEWPORT |
+ COLLECTION_RESTRICT_RENDER;
break;
}
case ID_OB: {
- /* Add the new container collection to one of the collections instantiating the
+ /* Add the other objects to one of the collections instantiating the
* root object, or scene's master collection if none found. */
Object *ob_root = (Object *)id_root;
LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
if (BKE_collection_has_object(collection, ob_root) &&
BKE_view_layer_has_collection(view_layer, collection) &&
!ID_IS_LINKED(collection) && !ID_IS_OVERRIDE_LIBRARY(collection)) {
- default_instantiating_collection = BKE_collection_add(
- bmain, collection, "OVERRIDE_HIDDEN");
+ default_instantiating_collection = collection;
}
}
if (default_instantiating_collection == NULL) {
- default_instantiating_collection = BKE_collection_add(
- bmain, scene->master_collection, "OVERRIDE_HIDDEN");
+ default_instantiating_collection = scene->master_collection;
}
break;
}
default:
BLI_assert(0);
}
- /* Hide the collection from viewport and render. */
- default_instantiating_collection->flag |= COLLECTION_RESTRICT_VIEWPORT |
- COLLECTION_RESTRICT_RENDER;
}
BKE_collection_object_add(bmain, default_instantiating_collection, ob_new);
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index c8abe296f59..4780f0cf208 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -213,9 +213,7 @@ Light *BKE_light_add(Main *bmain, const char *name)
{
Light *la;
- la = BKE_libblock_alloc(bmain, ID_LA, name, 0);
-
- light_init_data(&la->id);
+ la = BKE_id_new(bmain, ID_LA, name);
return la;
}
diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c
index debd9706b5e..31653a9a0ac 100644
--- a/source/blender/blenkernel/intern/lightprobe.c
+++ b/source/blender/blenkernel/intern/lightprobe.c
@@ -135,9 +135,7 @@ void *BKE_lightprobe_add(Main *bmain, const char *name)
{
LightProbe *probe;
- probe = BKE_libblock_alloc(bmain, ID_LP, name, 0);
-
- lightprobe_init_data(&probe->id);
+ probe = BKE_id_new(bmain, ID_LP, name);
return probe;
}
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index f32a62376ac..733a2bcd1e1 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -2059,7 +2059,7 @@ void BKE_linestyle_default_shader(const bContext *C, FreestyleLineStyle *linesty
uv_along_stroke = nodeAddStaticNode(C, ntree, SH_NODE_UVALONGSTROKE);
uv_along_stroke->locx = 0.0f;
uv_along_stroke->locy = 300.0f;
- uv_along_stroke->custom1 = 0; // use_tips
+ uv_along_stroke->custom1 = 0; /* use_tips */
input_texure = nodeAddStaticNode(C, ntree, SH_NODE_TEX_IMAGE);
input_texure->locx = 200.0f;
@@ -2069,16 +2069,16 @@ void BKE_linestyle_default_shader(const bContext *C, FreestyleLineStyle *linesty
output_linestyle->locx = 400.0f;
output_linestyle->locy = 300.0f;
output_linestyle->custom1 = MA_RAMP_BLEND;
- output_linestyle->custom2 = 0; // use_clamp
+ output_linestyle->custom2 = 0; /* use_clamp */
nodeSetActive(ntree, input_texure);
- fromsock = BLI_findlink(&uv_along_stroke->outputs, 0); // UV
- tosock = BLI_findlink(&input_texure->inputs, 0); // UV
+ fromsock = BLI_findlink(&uv_along_stroke->outputs, 0); /* UV */
+ tosock = BLI_findlink(&input_texure->inputs, 0); /* UV */
nodeAddLink(ntree, uv_along_stroke, fromsock, input_texure, tosock);
- fromsock = BLI_findlink(&input_texure->outputs, 0); // Color
- tosock = BLI_findlink(&output_linestyle->inputs, 0); // Color
+ fromsock = BLI_findlink(&input_texure->outputs, 0); /* Color */
+ tosock = BLI_findlink(&output_linestyle->inputs, 0); /* Color */
nodeAddLink(ntree, input_texure, fromsock, output_linestyle, tosock);
ntreeUpdateTree(CTX_data_main(C), ntree);
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index 2f71d1ad99f..1f9f155ee55 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -1053,27 +1053,6 @@ Mask *BKE_mask_new(Main *bmain, const char *name)
return mask;
}
-/* TODO(sergey): Use generic BKE_libblock_copy_nolib() instead. */
-/* TODO(bastien): Use new super cool & generic BKE_id_copy_ex() instead! */
-Mask *BKE_mask_copy_nolib(Mask *mask)
-{
- Mask *mask_new;
-
- mask_new = MEM_dupallocN(mask);
-
- /*take care here! - we may want to copy anim data */
- mask_new->adt = NULL;
-
- BLI_listbase_clear(&mask_new->masklayers);
-
- BKE_mask_layer_copy_list(&mask_new->masklayers, &mask->masklayers);
-
- /* enable fake user by default */
- id_fake_user_set(&mask->id);
-
- return mask_new;
-}
-
void BKE_mask_point_free(MaskSplinePoint *point)
{
if (point->uw) {
@@ -1216,12 +1195,6 @@ void BKE_mask_layer_free_list(ListBase *masklayers)
}
}
-/** Free (or release) any data used by this mask (does not free the mask itself). */
-void BKE_mask_free(Mask *mask)
-{
- mask_free_data(&mask->id);
-}
-
void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2])
{
if (frame_size[0] == frame_size[1]) {
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 70cb06185c9..4a85fab4e18 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -225,7 +225,7 @@ static void material_blend_read_data(BlendDataReader *reader, ID *id)
static void material_blend_read_lib(BlendLibReader *reader, ID *id)
{
Material *ma = (Material *)id;
- BLO_read_id_address(reader, ma->id.lib, &ma->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, ma->id.lib, &ma->ipo); /* XXX deprecated - old animation system */
/* relink grease pencil settings */
if (ma->gp_style != NULL) {
@@ -242,7 +242,7 @@ static void material_blend_read_lib(BlendLibReader *reader, ID *id)
static void material_blend_read_expand(BlendExpander *expander, ID *id)
{
Material *ma = (Material *)id;
- BLO_expand(expander, ma->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, ma->ipo); /* XXX deprecated - old animation system */
if (ma->gp_style) {
MaterialGPencilStyle *gp_style = ma->gp_style;
@@ -297,9 +297,7 @@ Material *BKE_material_add(Main *bmain, const char *name)
{
Material *ma;
- ma = BKE_libblock_alloc(bmain, ID_MA, name, 0);
-
- material_init_data(&ma->id);
+ ma = BKE_id_new(bmain, ID_MA, name);
return ma;
}
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 84f07b7bc60..e60a5f7b616 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -210,9 +210,7 @@ MetaBall *BKE_mball_add(Main *bmain, const char *name)
{
MetaBall *mb;
- mb = BKE_libblock_alloc(bmain, ID_MB, name, 0);
-
- metaball_init_data(&mb->id);
+ mb = BKE_id_new(bmain, ID_MB, name);
return mb;
}
@@ -739,10 +737,10 @@ bool BKE_mball_select_swap_multi_ex(Base **bases, int bases_len)
/* Draw Engine */
-void (*BKE_mball_batch_cache_dirty_tag_cb)(MetaBall *mb, eMeshBatchDirtyMode mode) = NULL;
+void (*BKE_mball_batch_cache_dirty_tag_cb)(MetaBall *mb, int mode) = NULL;
void (*BKE_mball_batch_cache_free_cb)(MetaBall *mb) = NULL;
-void BKE_mball_batch_cache_dirty_tag(MetaBall *mb, eMeshBatchDirtyMode mode)
+void BKE_mball_batch_cache_dirty_tag(MetaBall *mb, int mode)
{
if (mb->batch_cache) {
BKE_mball_batch_cache_dirty_tag_cb(mb, mode);
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 4486c9eb926..9765cd7fa1e 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -860,9 +860,7 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name)
{
Mesh *me;
- me = BKE_libblock_alloc(bmain, ID_ME, name, 0);
-
- mesh_init_data(&me->id);
+ me = BKE_id_new(bmain, ID_ME, name);
return me;
}
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index c11f9961f67..247ea2975fd 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -317,7 +317,7 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
*r_allvert = mvert = MEM_calloc_arrayN(totvert, sizeof(MVert), "nurbs_init mvert");
*r_alledge = medge = MEM_calloc_arrayN(totedge, sizeof(MEdge), "nurbs_init medge");
*r_allloop = mloop = MEM_calloc_arrayN(
- totpoly, sizeof(MLoop[4]), "nurbs_init mloop"); // totloop
+ totpoly, sizeof(MLoop[4]), "nurbs_init mloop"); /* totloop */
*r_allpoly = mpoly = MEM_calloc_arrayN(totpoly, sizeof(MPoly), "nurbs_init mloop");
if (r_alluv) {
diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c
index ef28e9958fc..868694931cb 100644
--- a/source/blender/blenkernel/intern/mesh_merge.c
+++ b/source/blender/blenkernel/intern/mesh_merge.c
@@ -20,7 +20,7 @@
/** \file
* \ingroup bke
*/
-#include <string.h> // for memcpy
+#include <string.h> /* for memcpy */
#include "MEM_guardedalloc.h"
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index a8937f74dee..1c48cf6f3cb 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -61,7 +61,12 @@ static bool mesh_remap_bvhtree_query_nearest(BVHTreeFromMesh *treedata,
{
/* Use local proximity heuristics (to reduce the nearest search). */
if (nearest->index != -1) {
- nearest->dist_sq = min_ff(len_squared_v3v3(co, nearest->co), max_dist_sq);
+ nearest->dist_sq = len_squared_v3v3(co, nearest->co);
+ if (nearest->dist_sq > max_dist_sq) {
+ /* The previous valid index is too far away and not valid for this check. */
+ nearest->dist_sq = max_dist_sq;
+ nearest->index = -1;
+ }
}
else {
nearest->dist_sq = max_dist_sq;
diff --git a/source/blender/blenkernel/intern/mesh_tangent.c b/source/blender/blenkernel/intern/mesh_tangent.c
index d6f945cf34f..c8f15fef71a 100644
--- a/source/blender/blenkernel/intern/mesh_tangent.c
+++ b/source/blender/blenkernel/intern/mesh_tangent.c
@@ -724,7 +724,9 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
*tangent_mask_curr_p = tangent_mask_curr;
/* Update active layer index */
- int act_uv_index = CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, act_uv_n);
+ int act_uv_index = (act_uv_n != -1) ?
+ CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, act_uv_n) :
+ -1;
if (act_uv_index != -1) {
int tan_index = CustomData_get_named_layer_index(
loopdata, CD_TANGENT, loopdata->layers[act_uv_index].name);
@@ -732,7 +734,9 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
} /* else tangent has been built from orco */
/* Update render layer index */
- int ren_uv_index = CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, ren_uv_n);
+ int ren_uv_index = (ren_uv_n != -1) ?
+ CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, ren_uv_n) :
+ -1;
if (ren_uv_index != -1) {
int tan_index = CustomData_get_named_layer_index(
loopdata, CD_TANGENT, loopdata->layers[ren_uv_index].name);
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index af09ef6dae0..6fea2cc8bf5 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -701,7 +701,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
/* Test same polys. */
if ((p1_nv == p2_nv) && (memcmp(p1_v, p2_v, p1_nv * sizeof(*p1_v)) == 0)) {
if (do_verbose) {
- // TODO: convert list to string
+ /* TODO: convert list to string */
PRINT_ERR("\tPolys %u and %u use same vertices (%d", prev_sp->index, sp->index, *p1_v);
for (j = 1; j < p1_nv; j++) {
PRINT_ERR(", %d", p1_v[j]);
@@ -1526,111 +1526,6 @@ void BKE_mesh_calc_edges_legacy(Mesh *me, const bool use_old)
BKE_mesh_strip_loose_faces(me);
}
-/**
- * Calculate edges from polygons
- *
- * \param mesh: The mesh to add edges into
- * \param update: When true create new edges co-exist
- */
-void BKE_mesh_calc_edges(Mesh *mesh, bool update, const bool select)
-{
- MEdge *med;
- int i, totpoly = mesh->totpoly;
- /* Select for newly created meshes which are selected T25595. */
- const short ed_flag = (ME_EDGEDRAW | ME_EDGERENDER) | (select ? SELECT : 0);
-
- if (mesh->totedge == 0) {
- update = false;
- }
-
- const unsigned int eh_reserve = max_ii(update ? mesh->totedge : 0,
- BLI_EDGEHASH_SIZE_GUESS_FROM_POLYS(totpoly));
- EdgeHash *eh = BLI_edgehash_new_ex(__func__, eh_reserve);
-
- if (update) {
- /* assume existing edges are valid
- * useful when adding more faces and generating edges from them */
- med = mesh->medge;
- for (i = 0; i < mesh->totedge; i++, med++) {
- BLI_edgehash_insert(eh, med->v1, med->v2, med);
- }
- }
-
- /* mesh loops (bmesh only) */
- MPoly *mp;
- for (mp = mesh->mpoly, i = 0; i < totpoly; mp++, i++) {
- MLoop *l = &mesh->mloop[mp->loopstart];
- int j, v_prev = (l + (mp->totloop - 1))->v;
- for (j = 0; j < mp->totloop; j++, l++) {
- if (v_prev != l->v) {
- void **val_p;
- if (!BLI_edgehash_ensure_p(eh, v_prev, l->v, &val_p)) {
- *val_p = NULL;
- }
- }
- v_prev = l->v;
- }
- }
-
- const int totedge = BLI_edgehash_len(eh);
-
- /* write new edges into a temporary CustomData */
- CustomData edata;
- CustomData_reset(&edata);
- CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
-
- med = CustomData_get_layer(&edata, CD_MEDGE);
- EdgeHashIterator *ehi;
- for (ehi = BLI_edgehashIterator_new(eh), i = 0; BLI_edgehashIterator_isDone(ehi) == false;
- BLI_edgehashIterator_step(ehi), ++i, ++med) {
- MEdge *med_orig;
- if (update && (med_orig = BLI_edgehashIterator_getValue(ehi))) {
- *med = *med_orig; /* copy from the original */
- }
- else {
- BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2);
- med->flag = ed_flag;
- }
-
- /* store the new edge index in the hash value */
- BLI_edgehashIterator_setValue(ehi, POINTER_FROM_INT(i));
- }
- BLI_edgehashIterator_free(ehi);
-
- if (mesh->totpoly) {
- /* second pass, iterate through all loops again and assign
- * the newly created edges to them. */
- for (mp = mesh->mpoly, i = 0; i < mesh->totpoly; mp++, i++) {
- MLoop *l = &mesh->mloop[mp->loopstart];
- MLoop *l_prev = (l + (mp->totloop - 1));
- int j;
- for (j = 0; j < mp->totloop; j++, l++) {
- /* Lookup hashed edge index, if it's valid. */
- int med_index;
- if (l_prev->v != l->v) {
- med_index = POINTER_AS_INT(BLI_edgehash_lookup(eh, l_prev->v, l->v));
- }
- else {
- /* This is an invalid edge; normally this does not happen in Blender, but it can be part
- * of an imported mesh with invalid geometry. See T76514. */
- med_index = 0;
- }
- l_prev->e = med_index;
- l_prev = l;
- }
- }
- }
-
- /* free old CustomData and assign new one */
- CustomData_free(&mesh->edata, mesh->totedge);
- mesh->edata = edata;
- mesh->totedge = totedge;
-
- mesh->medge = CustomData_get_layer(&mesh->edata, CD_MEDGE);
-
- BLI_edgehash_free(eh, NULL);
-}
-
void BKE_mesh_calc_edges_loose(Mesh *mesh)
{
MEdge *med = mesh->medge;
diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc
new file mode 100644
index 00000000000..16733729be0
--- /dev/null
+++ b/source/blender/blenkernel/intern/mesh_validate.cc
@@ -0,0 +1,268 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_edgehash.h"
+#include "BLI_map.hh"
+#include "BLI_math_base.h"
+#include "BLI_task.hh"
+#include "BLI_threads.h"
+#include "BLI_timeit.hh"
+
+#include "BKE_customdata.h"
+#include "BKE_mesh.h"
+
+namespace blender::bke::calc_edges {
+
+/** This is used to uniquely identify edges in a hash map. */
+struct OrderedEdge {
+ int v_low, v_high;
+
+ OrderedEdge(const int v1, const int v2)
+ {
+ if (v1 < v2) {
+ v_low = v1;
+ v_high = v2;
+ }
+ else {
+ v_low = v2;
+ v_high = v1;
+ }
+ }
+
+ OrderedEdge(const uint v1, const uint v2)
+ : OrderedEdge(static_cast<int>(v1), static_cast<int>(v2))
+ {
+ }
+
+ uint64_t hash() const
+ {
+ return (this->v_low << 8) ^ this->v_high;
+ }
+
+ /** Return a hash value that is likely to be different in the low bits from the normal `hash()`
+ * function. This is necessary to avoid collisions in #BKE_mesh_calc_edges. */
+ uint64_t hash2() const
+ {
+ return this->v_low;
+ }
+
+ friend bool operator==(const OrderedEdge &e1, const OrderedEdge &e2)
+ {
+ BLI_assert(e1.v_low < e1.v_high);
+ BLI_assert(e2.v_low < e2.v_high);
+ return e1.v_low == e2.v_low && e1.v_high == e2.v_high;
+ }
+};
+
+/* The map first contains an edge pointer and later an index. */
+typedef union OrigEdgeOrIndex {
+ const MEdge *original_edge;
+ int index;
+} OrigEdgeOrIndex;
+using EdgeMap = Map<OrderedEdge, OrigEdgeOrIndex>;
+
+static void reserve_hash_maps(const Mesh *mesh,
+ const bool keep_existing_edges,
+ MutableSpan<EdgeMap> edge_maps)
+{
+ const int totedge_guess = std::max(keep_existing_edges ? mesh->totedge : 0, mesh->totpoly * 2);
+ parallel_for_each(
+ edge_maps, [&](EdgeMap &edge_map) { edge_map.reserve(totedge_guess / edge_maps.size()); });
+}
+
+static void add_existing_edges_to_hash_maps(Mesh *mesh,
+ MutableSpan<EdgeMap> edge_maps,
+ uint32_t parallel_mask)
+{
+ /* Assume existing edges are valid. */
+ parallel_for_each(edge_maps, [&](EdgeMap &edge_map) {
+ const int task_index = &edge_map - &edge_maps[0];
+ for (const MEdge &edge : Span(mesh->medge, mesh->totedge)) {
+ OrderedEdge ordered_edge{edge.v1, edge.v2};
+ /* Only add the edge when it belongs into this map. */
+ if (task_index == (parallel_mask & ordered_edge.hash2())) {
+ edge_map.add_new(ordered_edge, {&edge});
+ }
+ }
+ });
+}
+
+static void add_polygon_edges_to_hash_maps(Mesh *mesh,
+ MutableSpan<EdgeMap> edge_maps,
+ uint32_t parallel_mask)
+{
+ const Span<MLoop> loops{mesh->mloop, mesh->totloop};
+ parallel_for_each(edge_maps, [&](EdgeMap &edge_map) {
+ const int task_index = &edge_map - &edge_maps[0];
+ for (const MPoly &poly : Span(mesh->mpoly, mesh->totpoly)) {
+ Span<MLoop> poly_loops = loops.slice(poly.loopstart, poly.totloop);
+ const MLoop *prev_loop = &poly_loops.last();
+ for (const MLoop &next_loop : poly_loops) {
+ /* Can only be the same when the mesh data is invalid. */
+ if (prev_loop->v != next_loop.v) {
+ OrderedEdge ordered_edge{prev_loop->v, next_loop.v};
+ /* Only add the edge when it belongs into this map. */
+ if (task_index == (parallel_mask & ordered_edge.hash2())) {
+ edge_map.lookup_or_add(ordered_edge, {nullptr});
+ }
+ }
+ prev_loop = &next_loop;
+ }
+ }
+ });
+}
+
+static void serialize_and_initialize_deduplicated_edges(MutableSpan<EdgeMap> edge_maps,
+ MutableSpan<MEdge> new_edges,
+ short new_edge_flag)
+{
+ /* All edges are distributed in the hash tables now. They have to be serialized into a single
+ * array below. To be able to parallelize this, we have to compute edge index offsets for each
+ * map. */
+ Array<int> edge_index_offsets(edge_maps.size());
+ edge_index_offsets[0] = 0;
+ for (const int i : IndexRange(edge_maps.size() - 1)) {
+ edge_index_offsets[i + 1] = edge_index_offsets[i] + edge_maps[i].size();
+ }
+
+ parallel_for_each(edge_maps, [&](EdgeMap &edge_map) {
+ const int task_index = &edge_map - &edge_maps[0];
+
+ int new_edge_index = edge_index_offsets[task_index];
+ for (EdgeMap::MutableItem item : edge_map.items()) {
+ MEdge &new_edge = new_edges[new_edge_index];
+ const MEdge *orig_edge = item.value.original_edge;
+ if (orig_edge != nullptr) {
+ /* Copy values from original edge. */
+ new_edge = *orig_edge;
+ }
+ else {
+ /* Initialize new edge. */
+ new_edge.v1 = item.key.v_low;
+ new_edge.v2 = item.key.v_high;
+ new_edge.flag = new_edge_flag;
+ }
+ item.value.index = new_edge_index;
+ new_edge_index++;
+ }
+ });
+}
+
+static void update_edge_indices_in_poly_loops(Mesh *mesh,
+ Span<EdgeMap> edge_maps,
+ uint32_t parallel_mask)
+{
+ const MutableSpan<MLoop> loops{mesh->mloop, mesh->totloop};
+ parallel_for(IndexRange(mesh->totpoly), 100, [&](IndexRange range) {
+ for (const int poly_index : range) {
+ MPoly &poly = mesh->mpoly[poly_index];
+ MutableSpan<MLoop> poly_loops = loops.slice(poly.loopstart, poly.totloop);
+
+ MLoop *prev_loop = &poly_loops.last();
+ for (MLoop &next_loop : poly_loops) {
+ int edge_index;
+ if (prev_loop->v != next_loop.v) {
+ OrderedEdge ordered_edge{prev_loop->v, next_loop.v};
+ /* Double lookup: First find the map that contains the edge, then lookup the edge. */
+ const EdgeMap &edge_map = edge_maps[parallel_mask & ordered_edge.hash2()];
+ edge_index = edge_map.lookup(ordered_edge).index;
+ }
+ else {
+ /* This is an invalid edge; normally this does not happen in Blender,
+ * but it can be part of an imported mesh with invalid geometry. See
+ * T76514. */
+ edge_index = 0;
+ }
+ prev_loop->e = edge_index;
+ prev_loop = &next_loop;
+ }
+ }
+ });
+}
+
+static int get_parallel_maps_count(const Mesh *mesh)
+{
+ /* Don't use parallelization when the mesh is small. */
+ if (mesh->totpoly < 1000) {
+ return 1;
+ }
+ /* Use at most 8 separate hash tables. Using more threads has diminishing returns. These threads
+ * can better do something more useful instead. */
+ const int system_thread_count = BLI_system_thread_count();
+ return power_of_2_min_i(std::min(8, system_thread_count));
+}
+
+static void clear_hash_tables(MutableSpan<EdgeMap> edge_maps)
+{
+ parallel_for_each(edge_maps, [](EdgeMap &edge_map) { edge_map.clear(); });
+}
+
+} // namespace blender::bke::calc_edges
+
+/**
+ * Calculate edges from polygons.
+ */
+void BKE_mesh_calc_edges(Mesh *mesh, bool keep_existing_edges, const bool select_new_edges)
+{
+ using namespace blender;
+ using namespace blender::bke;
+ using namespace blender::bke::calc_edges;
+
+ /* Parallelization is achieved by having multiple hash tables for different subsets of edges.
+ * Each edge is assigned to one of the hash maps based on the lower bits of a hash value. */
+ const int parallel_maps = get_parallel_maps_count(mesh);
+ BLI_assert(is_power_of_2_i(parallel_maps));
+ const uint32_t parallel_mask = static_cast<uint32_t>(parallel_maps) - 1;
+ Array<EdgeMap> edge_maps(parallel_maps);
+ reserve_hash_maps(mesh, keep_existing_edges, edge_maps);
+
+ /* Add all edges. */
+ if (keep_existing_edges) {
+ calc_edges::add_existing_edges_to_hash_maps(mesh, edge_maps, parallel_mask);
+ }
+ calc_edges::add_polygon_edges_to_hash_maps(mesh, edge_maps, parallel_mask);
+
+ /* Compute total number of edges. */
+ int new_totedge = 0;
+ for (EdgeMap &edge_map : edge_maps) {
+ new_totedge += edge_map.size();
+ }
+
+ /* Create new edges. */
+ MutableSpan<MEdge> new_edges{
+ static_cast<MEdge *>(MEM_calloc_arrayN(new_totedge, sizeof(MEdge), __func__)), new_totedge};
+ const short new_edge_flag = (ME_EDGEDRAW | ME_EDGERENDER) | (select_new_edges ? SELECT : 0);
+ calc_edges::serialize_and_initialize_deduplicated_edges(edge_maps, new_edges, new_edge_flag);
+ calc_edges::update_edge_indices_in_poly_loops(mesh, edge_maps, parallel_mask);
+
+ /* Free old CustomData and assign new one. */
+ CustomData_free(&mesh->edata, mesh->totedge);
+ CustomData_reset(&mesh->edata);
+ CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_ASSIGN, new_edges.data(), new_totedge);
+ mesh->totedge = new_totedge;
+ mesh->medge = new_edges.data();
+
+ /* Explicitely clear edge maps, because that way it can be parallelized. */
+ clear_hash_tables(edge_maps);
+}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index abf4fc82300..6ace8f87994 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -244,15 +244,12 @@ bool BKE_modifier_is_preview(ModifierData *md)
ModifierData *BKE_modifiers_findby_type(Object *ob, ModifierType type)
{
- ModifierData *md = ob->modifiers.first;
-
- for (; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == type) {
- break;
+ return md;
}
}
-
- return md;
+ return NULL;
}
ModifierData *BKE_modifiers_findby_name(Object *ob, const char *name)
@@ -262,24 +259,17 @@ ModifierData *BKE_modifiers_findby_name(Object *ob, const char *name)
void BKE_modifiers_clear_errors(Object *ob)
{
- ModifierData *md = ob->modifiers.first;
- /* int qRedraw = 0; */
-
- for (; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->error) {
MEM_freeN(md->error);
md->error = NULL;
-
- /* qRedraw = 1; */
}
}
}
void BKE_modifiers_foreach_ID_link(Object *ob, IDWalkFunc walk, void *userData)
{
- ModifierData *md = ob->modifiers.first;
-
- for (; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
if (mti->foreachIDLink) {
@@ -290,9 +280,7 @@ void BKE_modifiers_foreach_ID_link(Object *ob, IDWalkFunc walk, void *userData)
void BKE_modifiers_foreach_tex_link(Object *ob, TexWalkFunc walk, void *userData)
{
- ModifierData *md = ob->modifiers.first;
-
- for (; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
if (mti->foreachTexLink) {
@@ -437,7 +425,6 @@ int BKE_modifiers_get_cage_index(struct Scene *scene,
ModifierData *md = (is_virtual) ?
BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData) :
ob->modifiers.first;
- int i, cageIndex = -1;
if (r_lastPossibleCageIndex) {
/* ensure the value is initialized */
@@ -445,7 +432,8 @@ int BKE_modifiers_get_cage_index(struct Scene *scene,
}
/* Find the last modifier acting on the cage. */
- for (i = 0; md; i++, md = md->next) {
+ int cageIndex = -1;
+ for (int i = 0; md; i++, md = md->next) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
bool supports_mapping;
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 36f9e47421b..40b12d8a777 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -38,6 +38,8 @@
/* Allow using deprecated functionality for .blend file I/O. */
#define DNA_DEPRECATED_ALLOW
+#include "DNA_defaults.h"
+
#include "DNA_constraint_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_movieclip_types.h"
@@ -86,6 +88,17 @@
static void free_buffers(MovieClip *clip);
+static void movie_clip_init_data(ID *id)
+{
+ MovieClip *movie_clip = (MovieClip *)id;
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(movie_clip, id));
+
+ MEMCPY_STRUCT_AFTER(movie_clip, DNA_struct_default_get(MovieClip), id);
+
+ BKE_tracking_settings_init(&movie_clip->tracking);
+ BKE_color_managed_colorspace_settings_init(&movie_clip->colorspace_settings);
+}
+
static void movie_clip_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag)
{
MovieClip *movie_clip_dst = (MovieClip *)id_dst;
@@ -335,7 +348,7 @@ IDTypeInfo IDType_ID_MC = {
.translation_context = BLT_I18NCONTEXT_ID_MOVIECLIP,
.flags = 0,
- .init_data = NULL,
+ .init_data = movie_clip_init_data,
.copy_data = movie_clip_copy_data,
.free_data = movie_clip_free_data,
.make_local = NULL,
@@ -921,20 +934,7 @@ static MovieClip *movieclip_alloc(Main *bmain, const char *name)
{
MovieClip *clip;
- clip = BKE_libblock_alloc(bmain, ID_MC, name, 0);
-
- clip->aspx = clip->aspy = 1.0f;
-
- BKE_tracking_settings_init(&clip->tracking);
- BKE_color_managed_colorspace_settings_init(&clip->colorspace_settings);
-
- clip->proxy.build_size_flag = IMB_PROXY_25;
- clip->proxy.build_tc_flag = IMB_TC_RECORD_RUN | IMB_TC_FREE_RUN |
- IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN | IMB_TC_RECORD_RUN_NO_GAPS;
- clip->proxy.quality = 90;
-
- clip->start_frame = 1;
- clip->frame_offset = 0;
+ clip = BKE_id_new(bmain, ID_MC, name);
return clip;
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 6ab47f1b1f8..a8017569ba9 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1346,6 +1346,7 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name)
name = get_obdata_defname(type);
}
+ /* We cannot use #BKE_id_new here as we need some custom initialization code. */
ob = BKE_libblock_alloc(bmain, ID_OB, name, 0);
/* We increase object user count when linking to Collections. */
@@ -2059,8 +2060,8 @@ void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob)
}
ob->proxy = target;
+ id_us_plus(&target->id);
ob->proxy_group = cob;
- id_lib_extern(&target->id);
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
DEG_id_tag_update(&target->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 7f378e6e80b..915ee56e2f7 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -100,7 +100,7 @@ void BKE_object_eval_parent(Depsgraph *depsgraph, Object *ob)
DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob);
/* get local matrix (but don't calculate it, as that was done already!) */
- // XXX: redundant?
+ /* XXX: redundant? */
copy_m4_m4(locmat, ob->obmat);
/* get parent effect matrix */
diff --git a/source/blender/blenkernel/intern/outliner_treehash.c b/source/blender/blenkernel/intern/outliner_treehash.c
index 39618c95a68..05873d20f7f 100644
--- a/source/blender/blenkernel/intern/outliner_treehash.c
+++ b/source/blender/blenkernel/intern/outliner_treehash.c
@@ -193,7 +193,7 @@ static TseGroup *BKE_outliner_treehash_lookup_group(GHash *th, short type, short
{
TreeStoreElem tse_template;
tse_template.type = type;
- tse_template.nr = type ? nr : 0; // we're picky! :)
+ tse_template.nr = type ? nr : 0; /* we're picky! :) */
tse_template.id = id;
BLI_assert(th);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index fd37ceed568..88415140a5b 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -672,7 +672,7 @@ PaintCurve *BKE_paint_curve_add(Main *bmain, const char *name)
{
PaintCurve *pc;
- pc = BKE_libblock_alloc(bmain, ID_PC, name, 0);
+ pc = BKE_id_new(bmain, ID_PC, name);
return pc;
}
@@ -1894,63 +1894,41 @@ void BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(Mesh *mesh)
int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
- /* Show the only the face sets that have all visible vertices. */
for (int i = 0; i < mesh->totpoly; i++) {
- for (int l = 0; l < mesh->mpoly[i].totloop; l++) {
- MLoop *loop = &mesh->mloop[mesh->mpoly[i].loopstart + l];
- if (mesh->mvert[loop->v].flag & ME_HIDE) {
- if (initialize_new_face_sets) {
- /* When initializing a new Face Set data-layer, assign a new hidden Face Set ID to hidden
- * vertices. This way, we get at initial split in two Face Sets between hidden and
- * visible vertices based on the previous mesh visibly from other mode that can be
- * useful in some cases. */
- face_sets[i] = face_sets_default_hidden_id;
- }
- else {
- /* Otherwise, set the already existing Face Set ID to hidden. */
- face_sets[i] = -abs(face_sets[i]);
- }
- break;
- }
+ if (!(mesh->mpoly[i].flag & ME_HIDE)) {
+ continue;
+ }
+
+ if (initialize_new_face_sets) {
+ /* When initializing a new Face Set data-layer, assign a new hidden Face Set ID to hidden
+ * vertices. This way, we get at initial split in two Face Sets between hidden and
+ * visible vertices based on the previous mesh visibly from other mode that can be
+ * useful in some cases. */
+ face_sets[i] = face_sets_default_hidden_id;
+ }
+ else {
+ /* Otherwise, set the already existing Face Set ID to hidden. */
+ face_sets[i] = -abs(face_sets[i]);
}
}
}
-static void sculpt_sync_face_sets_visibility_to_base_mesh(Mesh *mesh)
+void BKE_sculpt_sync_face_sets_visibility_to_base_mesh(Mesh *mesh)
{
int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
if (!face_sets) {
return;
}
- /* Enabled if the vertex should be visible according to the Face Sets. */
- BLI_bitmap *visible_vertex = BLI_BITMAP_NEW(mesh->totvert, "visible vertices");
- /* Enabled if the visibility of this vertex can be affected by the Face Sets to avoid modifying
- * disconnected geometry. */
- BLI_bitmap *modified_vertex = BLI_BITMAP_NEW(mesh->totvert, "modified vertices");
-
for (int i = 0; i < mesh->totpoly; i++) {
const bool is_face_set_visible = face_sets[i] >= 0;
- for (int l = 0; l < mesh->mpoly[i].totloop; l++) {
- MLoop *loop = &mesh->mloop[mesh->mpoly[i].loopstart + l];
- if (is_face_set_visible) {
- BLI_BITMAP_ENABLE(visible_vertex, loop->v);
- }
- BLI_BITMAP_ENABLE(modified_vertex, loop->v);
- }
- }
-
- for (int i = 0; i < mesh->totvert; i++) {
- if (BLI_BITMAP_TEST(modified_vertex, i) && !BLI_BITMAP_TEST(visible_vertex, i)) {
- mesh->mvert[i].flag |= ME_HIDE;
- }
+ SET_FLAG_FROM_TEST(mesh->mpoly[i].flag, !is_face_set_visible, ME_HIDE);
}
- MEM_SAFE_FREE(visible_vertex);
- MEM_SAFE_FREE(modified_vertex);
+ BKE_mesh_flush_hidden_from_polys(mesh);
}
-static void sculpt_sync_face_sets_visibility_to_grids(Mesh *mesh, SubdivCCG *subdiv_ccg)
+void BKE_sculpt_sync_face_sets_visibility_to_grids(Mesh *mesh, SubdivCCG *subdiv_ccg)
{
int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
if (!face_sets) {
@@ -1984,8 +1962,8 @@ static void sculpt_sync_face_sets_visibility_to_grids(Mesh *mesh, SubdivCCG *sub
void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG *subdiv_ccg)
{
BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(mesh);
- sculpt_sync_face_sets_visibility_to_base_mesh(mesh);
- sculpt_sync_face_sets_visibility_to_grids(mesh, subdiv_ccg);
+ BKE_sculpt_sync_face_sets_visibility_to_base_mesh(mesh);
+ BKE_sculpt_sync_face_sets_visibility_to_grids(mesh, subdiv_ccg);
}
static PBVH *build_pbvh_for_dynamic_topology(Object *ob)
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 8d091767709..b978236da06 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -27,6 +27,8 @@
#include "MEM_guardedalloc.h"
+#include "DNA_defaults.h"
+
#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
#include "DNA_dynamicpaint_types.h"
@@ -82,6 +84,16 @@
static void fluid_free_settings(SPHFluidSettings *fluid);
+static void particle_settings_init(ID *id)
+{
+ ParticleSettings *particle_settings = (ParticleSettings *)id;
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(particle_settings, id));
+
+ MEMCPY_STRUCT_AFTER(particle_settings, DNA_struct_default_get(ParticleSettings), id);
+
+ particle_settings->effector_weights = BKE_effector_add_weights(NULL);
+}
+
static void particle_settings_copy_data(Main *UNUSED(bmain),
ID *id_dst,
const ID *id_src,
@@ -204,7 +216,7 @@ IDTypeInfo IDType_ID_PA = {
.translation_context = BLT_I18NCONTEXT_ID_PARTICLESETTINGS,
.flags = 0,
- .init_data = NULL,
+ .init_data = particle_settings_init,
.copy_data = particle_settings_copy_data,
.free_data = particle_settings_free_data,
.make_local = NULL,
@@ -3769,98 +3781,11 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
-static void default_particle_settings(ParticleSettings *part)
-{
- part->type = PART_EMITTER;
- part->distr = PART_DISTR_JIT;
- part->draw_as = PART_DRAW_REND;
- part->ren_as = PART_DRAW_HALO;
- part->bb_uv_split = 1;
- part->flag = PART_EDISTR | PART_TRAND | PART_HIDE_ADVANCED_HAIR;
-
- part->sta = 1.0;
- part->end = 200.0;
- part->lifetime = 50.0;
- part->jitfac = 1.0;
- part->totpart = 1000;
- part->grid_res = 10;
- part->timetweak = 1.0;
- part->courant_target = 0.2;
-
- part->integrator = PART_INT_MIDPOINT;
- part->phystype = PART_PHYS_NEWTON;
- part->hair_step = 5;
- part->keys_step = 5;
- part->draw_step = 2;
- part->ren_step = 3;
- part->adapt_angle = 5;
- part->adapt_pix = 3;
- part->kink_axis = 2;
- part->kink_amp_clump = 1.f;
- part->kink_extra_steps = 4;
- part->clump_noise_size = 1.0f;
- part->reactevent = PART_EVENT_DEATH;
- part->disp = 100;
- part->from = PART_FROM_FACE;
-
- part->normfac = 1.0f;
-
- part->mass = 1.0;
- part->size = 0.05;
- part->childsize = 1.0;
-
- part->rotmode = PART_ROT_VEL;
- part->avemode = PART_AVE_VELOCITY;
-
- part->child_nbr = 10;
- part->ren_child_nbr = 100;
- part->childrad = 0.2f;
- part->childflat = 0.0f;
- part->clumppow = 0.0f;
- part->kink_amp = 0.2f;
- part->kink_freq = 2.0;
-
- part->rough1_size = 1.0;
- part->rough2_size = 1.0;
- part->rough_end_shape = 1.0;
-
- part->clength = 1.0f;
- part->clength_thres = 0.0f;
-
- part->draw = 0;
- part->draw_line[0] = 0.5;
- part->path_start = 0.0f;
- part->path_end = 1.0f;
-
- part->bb_size[0] = part->bb_size[1] = 1.0f;
-
- part->keyed_loops = 1;
-
- part->color_vec_max = 1.f;
- part->draw_col = PART_DRAW_COL_MAT;
-
- if (!part->effector_weights) {
- part->effector_weights = BKE_effector_add_weights(NULL);
- }
-
- part->omat = 1;
- part->use_modifier_stack = false;
- part->draw_size = 0.1f;
-
- part->shape_flag = PART_SHAPE_CLOSE_TIP;
- part->shape = 0.0f;
- part->rad_root = 1.0f;
- part->rad_tip = 0.0f;
- part->rad_scale = 0.01f;
-}
-
ParticleSettings *BKE_particlesettings_add(Main *bmain, const char *name)
{
ParticleSettings *part;
- part = BKE_libblock_alloc(bmain, ID_PA, name, 0);
-
- default_particle_settings(part);
+ part = BKE_id_new(bmain, ID_PA, name);
return part;
}
@@ -4270,7 +4195,7 @@ float psys_get_child_size(ParticleSystem *psys,
float *UNUSED(pa_time))
{
ParticleSettings *part = psys->part;
- float size; // time XXX
+ float size; /* time XXX */
if (part->childtype == PART_CHILD_FACES) {
int w = 0;
@@ -5009,10 +4934,10 @@ void psys_apply_hair_lattice(Depsgraph *depsgraph, Scene *scene, Object *ob, Par
}
/* Draw Engine */
-void (*BKE_particle_batch_cache_dirty_tag_cb)(ParticleSystem *psys, eMeshBatchDirtyMode mode) = NULL;
+void (*BKE_particle_batch_cache_dirty_tag_cb)(ParticleSystem *psys, int mode) = NULL;
void (*BKE_particle_batch_cache_free_cb)(ParticleSystem *psys) = NULL;
-void BKE_particle_batch_cache_dirty_tag(ParticleSystem *psys, eMeshBatchDirtyMode mode)
+void BKE_particle_batch_cache_dirty_tag(ParticleSystem *psys, int mode)
{
if (psys->batch_cache) {
BKE_particle_batch_cache_dirty_tag_cb(psys, mode);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 862ebf43913..060a9b4d794 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -2001,7 +2001,7 @@ static void sphclassical_force_cb(void *sphdata_v,
/* 4.77 is an experimentally determined density factor */
float rest_density = fluid->rest_density * (fluid->flag & SPH_FAC_DENSITY ? 4.77f : 1.0f);
- // Use speed of sound squared
+ /* Use speed of sound squared */
float stiffness = pow2f(fluid->stiffness_k);
ParticleData *npa;
@@ -2118,7 +2118,7 @@ void psys_sph_init(ParticleSimulationData *sim, SPHData *sphdata)
BLI_buffer_field_init(&sphdata->new_springs, ParticleSpring);
- // Add other coupled particle systems.
+ /* Add other coupled particle systems. */
sphdata->psys[0] = sim->psys;
for (i = 1, pt = sim->psys->targets.first; i < 10; i++, pt = (pt ? pt->next : NULL)) {
sphdata->psys[i] = pt ? psys_get_target_system(sim->ob, pt) : NULL;
@@ -2132,8 +2132,8 @@ void psys_sph_init(ParticleSimulationData *sim, SPHData *sphdata)
}
sphdata->eh = sph_springhash_build(sim->psys);
- // These per-particle values should be overridden later, but just for
- // completeness we give them default values now.
+ /* These per-particle values should be overridden later, but just for
+ * completeness we give them default values now. */
sphdata->pa = NULL;
sphdata->mass = 1.0f;
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 9018131af86..9d9e0a9c9cb 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -116,14 +116,14 @@
static CLG_LogRef LOG = {"bke.pointcache"};
static int ptcache_data_size[] = {
- sizeof(unsigned int), // BPHYS_DATA_INDEX
- sizeof(float[3]), // BPHYS_DATA_LOCATION
- sizeof(float[3]), // BPHYS_DATA_VELOCITY
- sizeof(float[4]), // BPHYS_DATA_ROTATION
- sizeof(float[3]), // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST
- sizeof(float), // BPHYS_DATA_SIZE
- sizeof(float[3]), // BPHYS_DATA_TIMES
- sizeof(BoidData), // case BPHYS_DATA_BOIDS
+ sizeof(unsigned int), /* BPHYS_DATA_INDEX */
+ sizeof(float[3]), /* BPHYS_DATA_LOCATION */
+ sizeof(float[3]), /* BPHYS_DATA_VELOCITY */
+ sizeof(float[4]), /* BPHYS_DATA_ROTATION */
+ sizeof(float[3]), /* BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
+ sizeof(float), /* BPHYS_DATA_SIZE */
+ sizeof(float[3]), /* BPHYS_DATA_TIMES */
+ sizeof(BoidData), /* case BPHYS_DATA_BOIDS */
};
static int ptcache_extra_datasize[] = {
@@ -1550,7 +1550,7 @@ static int ptcache_file_compressed_write(
r = LzmaCompress(out,
&out_len,
in,
- in_len, // assume sizeof(char)==1....
+ in_len, /* assume sizeof(char)==1.... */
props,
&sizeOfIt,
5,
@@ -2117,7 +2117,7 @@ static int ptcache_read_stream(PTCacheID *pid, int cfra)
if (!error) {
ptcache_file_pointers_init(pf);
- // we have stream reading here
+ /* We have stream reading here. */
if (!pid->read_stream(pf, pid->calldata)) {
pid->error(pid->calldata, "Failed to read point cache file data");
error = 1;
@@ -3245,7 +3245,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
scene, pid->calldata, &cache->startframe, &cache->endframe);
}
- // XXX workaround for regression inroduced in ee3fadd, needs looking into
+ /* XXX workaround for regression inroduced in ee3fadd, needs looking into */
if (pid->type == PTCACHE_TYPE_RIGIDBODY) {
if ((cache->flag & PTCACHE_REDO_NEEDED ||
(cache->flag & PTCACHE_SIMULATION_VALID) == 0) &&
diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.c
index a130117ded5..78acf7251fa 100644
--- a/source/blender/blenkernel/intern/pointcloud.c
+++ b/source/blender/blenkernel/intern/pointcloud.c
@@ -39,10 +39,10 @@
#include "BKE_lib_query.h"
#include "BKE_lib_remap.h"
#include "BKE_main.h"
-#include "BKE_mesh_types.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_pointcloud.h"
+
#include "BLT_translation.h"
#include "DEG_depsgraph_query.h"
@@ -206,9 +206,7 @@ static void pointcloud_random(PointCloud *pointcloud)
void *BKE_pointcloud_add(Main *bmain, const char *name)
{
- PointCloud *pointcloud = BKE_libblock_alloc(bmain, ID_PT, name, 0);
-
- pointcloud_init_data(&pointcloud->id);
+ PointCloud *pointcloud = BKE_id_new(bmain, ID_PT, name);
return pointcloud;
}
@@ -384,11 +382,10 @@ void BKE_pointcloud_data_update(struct Depsgraph *depsgraph, struct Scene *scene
}
/* Draw Cache */
-void (*BKE_pointcloud_batch_cache_dirty_tag_cb)(PointCloud *pointcloud,
- eMeshBatchDirtyMode mode) = NULL;
+void (*BKE_pointcloud_batch_cache_dirty_tag_cb)(PointCloud *pointcloud, int mode) = NULL;
void (*BKE_pointcloud_batch_cache_free_cb)(PointCloud *pointcloud) = NULL;
-void BKE_pointcloud_batch_cache_dirty_tag(PointCloud *pointcloud, eMeshBatchDirtyMode mode)
+void BKE_pointcloud_batch_cache_dirty_tag(PointCloud *pointcloud, int mode)
{
if (pointcloud->batch_cache) {
BKE_pointcloud_batch_cache_dirty_tag_cb(pointcloud, mode);
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 6b2b7271c76..586aeb274a5 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -509,7 +509,7 @@ static rbCollisionShape *rigidbody_validate_sim_shape_helper(RigidBodyWorld *rbw
* - assume even distribution of mass around the Object's pivot
* (i.e. Object pivot is centralized in boundbox)
*/
- // XXX: all dimensions are auto-determined now... later can add stored settings for this
+ /* XXX: all dimensions are auto-determined now... later can add stored settings for this */
/* get object dimensions without scaling */
bb = BKE_object_boundbox_get(ob);
if (bb) {
@@ -636,7 +636,7 @@ static void rigidbody_validate_sim_shape(RigidBodyWorld *rbw, Object *ob, bool r
/* --------------------- */
/* helper function to calculate volume of rigidbody object */
-// TODO: allow a parameter to specify method used to calculate this?
+/* TODO: allow a parameter to specify method used to calculate this? */
void BKE_rigidbody_calc_volume(Object *ob, float *r_vol)
{
RigidBodyOb *rbo = ob->rigidbody_object;
@@ -653,7 +653,7 @@ void BKE_rigidbody_calc_volume(Object *ob, float *r_vol)
* (i.e. Object pivot is centralized in boundbox)
* - boundbox gives full width
*/
- // XXX: all dimensions are auto-determined now... later can add stored settings for this
+ /* XXX: all dimensions are auto-determined now... later can add stored settings for this */
BKE_object_dimensions_get(ob, size);
if (ELEM(rbo->shape, RB_SHAPE_CAPSULE, RB_SHAPE_CYLINDER, RB_SHAPE_CONE)) {
@@ -742,7 +742,7 @@ void BKE_rigidbody_calc_center_of_mass(Object *ob, float r_center[3])
* (i.e. Object pivot is centralized in boundbox)
* - boundbox gives full width
*/
- // XXX: all dimensions are auto-determined now... later can add stored settings for this
+ /* XXX: all dimensions are auto-determined now... later can add stored settings for this */
BKE_object_dimensions_get(ob, size);
/* calculate volume as appropriate */
@@ -2034,7 +2034,7 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime)
!(ob->base_flag & BASE_SELECTED && G.moving & G_TRANSFORM_OBJ)) {
float mat[4][4], size_mat[4][4], size[3];
- normalize_qt(rbo->orn); // RB_TODO investigate why quaternion isn't normalized at this point
+ normalize_qt(rbo->orn); /* RB_TODO investigate why quaternion isn't normalized at this point */
quat_to_mat4(mat, rbo->orn);
copy_v3_v3(mat[3], rbo->pos);
@@ -2200,7 +2200,7 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
}
/* try to read from cache */
- // RB_TODO deal with interpolated, old and baked results
+ /* RB_TODO deal with interpolated, old and baked results */
bool can_simulate = (ctime == rbw->ltime + 1) && !(cache->flag & PTCACHE_BAKED);
if (BKE_ptcache_read(&pid, ctime, can_simulate) == PTCACHE_READ_EXACT) {
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index e0cc2905074..5e5f325d7d8 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -421,10 +421,10 @@ static void scene_free_data(ID *id)
}
/* Master Collection */
- // TODO: what to do with do_id_user? it's also true when just
- // closing the file which seems wrong? should decrement users
- // for objects directly in the master collection? then other
- // collections in the scene need to do it too?
+ /* TODO: what to do with do_id_user? it's also true when just
+ * closing the file which seems wrong? should decrement users
+ * for objects directly in the master collection? then other
+ * collections in the scene need to do it too? */
if (scene->master_collection) {
BKE_collection_free(scene->master_collection);
MEM_freeN(scene->master_collection);
@@ -955,12 +955,10 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
{
Scene *sce;
- sce = BKE_libblock_alloc(bmain, ID_SCE, name, 0);
+ sce = BKE_id_new(bmain, ID_SCE, name);
id_us_min(&sce->id);
id_us_ensure_real(&sce->id);
- scene_init_data(&sce->id);
-
return sce;
}
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 9240851c07a..0c9ee61ca19 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -70,25 +70,25 @@
#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n"))
typedef struct ShrinkwrapCalcData {
- ShrinkwrapModifierData *smd; // shrinkwrap modifier data
+ ShrinkwrapModifierData *smd; /* shrinkwrap modifier data */
- struct Object *ob; // object we are applying shrinkwrap to
+ struct Object *ob; /* object we are applying shrinkwrap to */
- struct MVert *vert; // Array of verts being projected (to fetch normals or other data)
- float (*vertexCos)[3]; // vertexs being shrinkwraped
+ struct MVert *vert; /* Array of verts being projected (to fetch normals or other data) */
+ float (*vertexCos)[3]; /* vertexs being shrinkwraped */
int numVerts;
- struct MDeformVert *dvert; // Pointer to mdeform array
- int vgroup; // Vertex group num
- bool invert_vgroup; /* invert vertex group influence */
+ struct MDeformVert *dvert; /* Pointer to mdeform array */
+ int vgroup; /* Vertex group num */
+ bool invert_vgroup; /* invert vertex group influence */
- struct Mesh *target; // mesh we are shrinking to
- struct SpaceTransform local2target; // transform to move between local and target space
- struct ShrinkwrapTreeData *tree; // mesh BVH tree data
+ struct Mesh *target; /* mesh we are shrinking to */
+ struct SpaceTransform local2target; /* transform to move between local and target space */
+ struct ShrinkwrapTreeData *tree; /* mesh BVH tree data */
struct Object *aux_target;
- float keepDist; // Distance to keep above target surface (units are in local space)
+ float keepDist; /* Distance to keep above target surface (units are in local space) */
} ShrinkwrapCalcData;
typedef struct ShrinkwrapCalcCBData {
@@ -345,10 +345,10 @@ void BKE_shrinkwrap_compute_boundary_data(struct Mesh *mesh)
mesh->runtime.shrinkwrap_data = shrinkwrap_build_boundary_data(mesh);
}
-/*
- * Shrinkwrap to the nearest vertex
+/**
+ * Shrink-wrap to the nearest vertex
*
- * it builds a kdtree of vertexs we can attach to and then
+ * it builds a #BVHTree of vertices we can attach to and then
* for each vertex performs a nearest vertex search on the tree
*/
static void shrinkwrap_calc_nearest_vertex_cb_ex(void *__restrict userdata,
@@ -1548,7 +1548,11 @@ void BKE_shrinkwrap_remesh_target_project(Mesh *src_me, Mesh *target_me, Object
ssmd.shrinkMode = MOD_SHRINKWRAP_ON_SURFACE;
ssmd.shrinkOpts = MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR;
ssmd.keepDist = 0.0f;
- ssmd.projLimit = target_me->remesh_voxel_size;
+
+ /* Tolerance value to prevent artifacts on sharp edges of a mesh.
+ * This constant and based on experimenting with different values. */
+ const float projLimitTolerance = 5.0f;
+ ssmd.projLimit = target_me->remesh_voxel_size * projLimitTolerance;
float(*vertexCos)[3] = BKE_mesh_vert_coords_alloc(src_me, &totvert);
diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc
index eacb854950d..d7314831b18 100644
--- a/source/blender/blenkernel/intern/simulation.cc
+++ b/source/blender/blenkernel/intern/simulation.cc
@@ -261,9 +261,7 @@ IDTypeInfo IDType_ID_SIM = {
void *BKE_simulation_add(Main *bmain, const char *name)
{
- Simulation *simulation = (Simulation *)BKE_libblock_alloc(bmain, ID_SIM, name, 0);
-
- simulation_init_data(&simulation->id);
+ Simulation *simulation = (Simulation *)BKE_id_new(bmain, ID_SIM, name);
return simulation;
}
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 9cf5ef85850..bf61c27ee2f 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -1506,7 +1506,7 @@ static void _scan_for_ext_spring_forces(
madd_v3_v3fl(bs->ext_force, vel, f * (1.0f - fabsf(dot_v3v3(vel, sp))));
}
else {
- madd_v3_v3fl(bs->ext_force, vel, f); // to keep compatible with 2.45 release files
+ madd_v3_v3fl(bs->ext_force, vel, f); /* to keep compatible with 2.45 release files */
}
}
/* --- springs seeing wind */
@@ -1554,7 +1554,7 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph,
for (i = 0; i < totthread; i++) {
sb_threads[i].scene = scene;
sb_threads[i].ob = ob;
- sb_threads[i].forcetime = 0.0; // not used here
+ sb_threads[i].forcetime = 0.0; /* not used here */
sb_threads[i].timenow = timenow;
sb_threads[i].ilast = left;
left = left - dec;
@@ -1565,9 +1565,9 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph,
sb_threads[i].ifirst = 0;
}
sb_threads[i].effectors = effectors;
- sb_threads[i].do_deflector = false; // not used here
- sb_threads[i].fieldfactor = 0.0f; // not used here
- sb_threads[i].windfactor = 0.0f; // not used here
+ sb_threads[i].do_deflector = false; /* not used here */
+ sb_threads[i].fieldfactor = 0.0f; /* not used here */
+ sb_threads[i].windfactor = 0.0f; /* not used here */
sb_threads[i].nr = i;
sb_threads[i].tot = totthread;
}
@@ -1741,8 +1741,7 @@ static int sb_detect_vertex_collisionCached(float opco[3],
cross_v3_v3v3(d_nvect, edge2, edge1);
/* n_mag = */ /* UNUSED */ normalize_v3(d_nvect);
facedist = dot_v3v3(dv1, d_nvect);
- // so rules are
- //
+ /* so rules are */
if ((facedist > innerfacethickness) && (facedist < outerfacethickness)) {
if (isect_point_tri_prism_v3(opco, nv1, nv2, nv3)) {
@@ -1781,7 +1780,7 @@ static int sb_detect_vertex_collisionCached(float opco[3],
}
} /* while () */
- if (deflected == 1) { // no face but 'outer' edge cylinder sees vert
+ if (deflected == 1) { /* no face but 'outer' edge cylinder sees vert */
force_mag_norm = (float)exp(-ee * mindistedge);
if (mindistedge > outerfacethickness * ff) {
force_mag_norm = (float)force_mag_norm * fa * (mindistedge - outerfacethickness) *
@@ -1793,10 +1792,10 @@ static int sb_detect_vertex_collisionCached(float opco[3],
*damp *= (1.0f - mindistedge / outerfacethickness);
}
}
- if (deflected == 2) { // face inner detected
+ if (deflected == 2) { /* face inner detected */
add_v3_v3(force, innerforceaccu);
}
- if (deflected == 3) { // face outer detected
+ if (deflected == 3) { /* face outer detected */
add_v3_v3(force, outerforceaccu);
}
@@ -3496,14 +3495,14 @@ static void softbody_step(
}
else if (sb->solver_ID == 2) {
/* do semi "fake" implicit euler */
- // removed
+ /* removed */
} /*SOLVER SELECT*/
else if (sb->solver_ID == 4) {
/* do semi "fake" implicit euler */
} /*SOLVER SELECT*/
else if (sb->solver_ID == 3) {
/* do "stupid" semi "fake" implicit euler */
- // removed
+ /* removed */
} /*SOLVER SELECT*/
else {
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index dbcc2482f5a..0f1b341a606 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -180,13 +180,13 @@ static void sound_blend_read_lib(BlendLibReader *reader, ID *id)
{
bSound *sound = (bSound *)id;
BLO_read_id_address(
- reader, sound->id.lib, &sound->ipo); // XXX deprecated - old animation system
+ reader, sound->id.lib, &sound->ipo); /* XXX deprecated - old animation system */
}
static void sound_blend_read_expand(BlendExpander *expander, ID *id)
{
bSound *snd = (bSound *)id;
- BLO_expand(expander, snd->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, snd->ipo); /* XXX deprecated - old animation system */
}
IDTypeInfo IDType_ID_SO = {
@@ -957,7 +957,7 @@ double BKE_sound_sync_scene(Scene *scene)
{
sound_verify_evaluated_id(&scene->id);
- // Ugly: Blender doesn't like it when the animation is played back during rendering
+ /* Ugly: Blender doesn't like it when the animation is played back during rendering */
if (G.is_rendering) {
return NAN_FLT;
}
@@ -976,12 +976,12 @@ int BKE_sound_scene_playing(Scene *scene)
{
sound_verify_evaluated_id(&scene->id);
- // Ugly: Blender doesn't like it when the animation is played back during rendering
+ /* Ugly: Blender doesn't like it when the animation is played back during rendering */
if (G.is_rendering) {
return -1;
}
- // in case of a "Null" audio device, we have no playback information
+ /* In case of a "Null" audio device, we have no playback information. */
if (AUD_Device_getRate(sound_device) == AUD_RATE_INVALID) {
return -1;
}
diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c
index 2f65442fd48..a98093d1893 100644
--- a/source/blender/blenkernel/intern/speaker.c
+++ b/source/blender/blenkernel/intern/speaker.c
@@ -118,9 +118,7 @@ void *BKE_speaker_add(Main *bmain, const char *name)
{
Speaker *spk;
- spk = BKE_libblock_alloc(bmain, ID_SPK, name, 0);
-
- speaker_init_data(&spk->id);
+ spk = BKE_id_new(bmain, ID_SPK, name);
return spk;
}
diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c
index 0997b42a19f..a59f9e0c633 100644
--- a/source/blender/blenkernel/intern/subdiv_ccg.c
+++ b/source/blender/blenkernel/intern/subdiv_ccg.c
@@ -1878,12 +1878,14 @@ static void adjacet_vertices_index_from_adjacent_edge(const SubdivCCG *subdiv_cc
const int poly_index = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, coord->grid_index);
const MPoly *p = &mpoly[poly_index];
*r_v1 = mloop[coord->grid_index].v;
+
+ const int corner = poly_find_loop_from_vert(p, &mloop[p->loopstart], *r_v1);
if (coord->x == grid_size_1) {
- const MLoop *next = ME_POLY_LOOP_NEXT(mloop, p, coord->grid_index);
+ const MLoop *next = ME_POLY_LOOP_NEXT(mloop, p, corner);
*r_v2 = next->v;
}
if (coord->y == grid_size_1) {
- const MLoop *prev = ME_POLY_LOOP_PREV(mloop, p, coord->grid_index);
+ const MLoop *prev = ME_POLY_LOOP_PREV(mloop, p, corner);
*r_v2 = prev->v;
}
}
diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c
index b0adec4e194..da6ee8d8779 100644
--- a/source/blender/blenkernel/intern/subdiv_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_mesh.c
@@ -1216,7 +1216,8 @@ Mesh *BKE_subdiv_to_mesh(Subdiv *subdiv,
subdiv_context.coarse_mesh = coarse_mesh;
subdiv_context.subdiv = subdiv;
subdiv_context.have_displacement = (subdiv->displacement_evaluator != NULL);
- subdiv_context.can_evaluate_normals = !subdiv_context.have_displacement && subdiv_context.subdiv->settings.is_adaptive;
+ subdiv_context.can_evaluate_normals = !subdiv_context.have_displacement &&
+ subdiv_context.subdiv->settings.is_adaptive;
/* Multi-threaded traversal/evaluation. */
BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_MESH_GEOMETRY);
SubdivForeachContext foreach_context;
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 84b5b526eff..93306703686 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -287,12 +287,10 @@ Text *BKE_text_add(Main *bmain, const char *name)
{
Text *ta;
- ta = BKE_libblock_alloc(bmain, ID_TXT, name, 0);
+ ta = BKE_id_new(bmain, ID_TXT, name);
/* Texts always have 'real' user (see also read code). */
id_us_ensure_real(&ta->id);
- text_init_data(&ta->id);
-
return ta;
}
@@ -908,7 +906,7 @@ void txt_move_left(Text *text, const bool sel)
}
else {
/* do nice left only if there are only spaces */
- // TXT_TABSIZE hardcoded in DNA_text_types.h
+ /* #TXT_TABSIZE hard-coded in DNA_text_types.h */
if (text->flags & TXT_TABSTOSPACES) {
tabsize = txt_calc_tab_left(*linep, *charp);
}
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index c2325eeeab0..90c4f71ce7a 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -193,14 +193,14 @@ static void texture_blend_read_lib(BlendLibReader *reader, ID *id)
{
Tex *tex = (Tex *)id;
BLO_read_id_address(reader, tex->id.lib, &tex->ima);
- BLO_read_id_address(reader, tex->id.lib, &tex->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, tex->id.lib, &tex->ipo); /* XXX deprecated - old animation system */
}
static void texture_blend_read_expand(BlendExpander *expander, ID *id)
{
Tex *tex = (Tex *)id;
BLO_expand(expander, tex->ima);
- BLO_expand(expander, tex->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, tex->ipo); /* XXX deprecated - old animation system */
}
IDTypeInfo IDType_ID_TE = {
@@ -383,9 +383,7 @@ Tex *BKE_texture_add(Main *bmain, const char *name)
{
Tex *tex;
- tex = BKE_libblock_alloc(bmain, ID_TE, name, 0);
-
- texture_init_data(&tex->id);
+ tex = BKE_id_new(bmain, ID_TE, name);
return tex;
}
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index 382787fd0f9..32f6a94aa7f 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -603,9 +603,7 @@ void BKE_volume_init_grids(Volume *volume)
void *BKE_volume_add(Main *bmain, const char *name)
{
- Volume *volume = (Volume *)BKE_libblock_alloc(bmain, ID_VO, name, 0);
-
- volume_init_data(&volume->id);
+ Volume *volume = (Volume *)BKE_id_new(bmain, ID_VO, name);
return volume;
}
@@ -744,15 +742,6 @@ bool BKE_volume_load(Volume *volume, Main *bmain)
return false;
}
- /* Test if file exists. */
- if (!BLI_exists(grids.filepath)) {
- char filename[FILE_MAX];
- BLI_split_file_part(grids.filepath, filename, sizeof(filename));
- grids.error_msg = filename + std::string(" not found");
- CLOG_INFO(&LOG, 1, "Volume %s: %s", volume_name, grids.error_msg.c_str());
- return false;
- }
-
/* Open OpenVDB file. */
openvdb::io::File file(grids.filepath);
openvdb::GridPtrVec vdb_grids;
@@ -1027,10 +1016,10 @@ void BKE_volume_grids_backup_restore(Volume *volume, VolumeGridVector *grids, co
/* Draw Cache */
-void (*BKE_volume_batch_cache_dirty_tag_cb)(Volume *volume, eMeshBatchDirtyMode mode) = NULL;
+void (*BKE_volume_batch_cache_dirty_tag_cb)(Volume *volume, int mode) = NULL;
void (*BKE_volume_batch_cache_free_cb)(Volume *volume) = NULL;
-void BKE_volume_batch_cache_dirty_tag(Volume *volume, eMeshBatchDirtyMode mode)
+void BKE_volume_batch_cache_dirty_tag(Volume *volume, int mode)
{
if (volume->batch_cache) {
BKE_volume_batch_cache_dirty_tag_cb(volume, mode);
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 5db534b76b4..cd163b7c8bf 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -205,7 +205,7 @@ static bool UNUSED_FUNCTION(workspaces_is_screen_used)
WorkSpace *BKE_workspace_add(Main *bmain, const char *name)
{
- WorkSpace *new_workspace = BKE_libblock_alloc(bmain, ID_WS, name, 0);
+ WorkSpace *new_workspace = BKE_id_new(bmain, ID_WS, name);
id_us_ensure_real(&new_workspace->id);
return new_workspace;
}
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 7590afeaaff..094557502a3 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -174,13 +174,13 @@ static void world_blend_read_data(BlendDataReader *reader, ID *id)
static void world_blend_read_lib(BlendLibReader *reader, ID *id)
{
World *wrld = (World *)id;
- BLO_read_id_address(reader, wrld->id.lib, &wrld->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, wrld->id.lib, &wrld->ipo); /* XXX deprecated, old animation system */
}
static void world_blend_read_expand(BlendExpander *expander, ID *id)
{
World *wrld = (World *)id;
- BLO_expand(expander, wrld->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, wrld->ipo); /* XXX deprecated, old animation system */
}
IDTypeInfo IDType_ID_WO = {
@@ -210,9 +210,7 @@ World *BKE_world_add(Main *bmain, const char *name)
{
World *wrld;
- wrld = BKE_libblock_alloc(bmain, ID_WO, name, 0);
-
- world_init_data(&wrld->id);
+ wrld = BKE_id_new(bmain, ID_WO, name);
return wrld;
}
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 0073a3692ee..7a8fd2dc43b 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -249,7 +249,7 @@ static int write_audio_frame(FFMpegContext *context)
return 0;
}
-# endif // #ifdef WITH_AUDASPACE
+# endif /* #ifdef WITH_AUDASPACE */
/* Allocate a temporary frame */
static AVFrame *alloc_picture(int pix_fmt, int width, int height)
@@ -878,9 +878,9 @@ static AVStream *alloc_audio_stream(FFMpegContext *context,
# endif
if (c->frame_size == 0) {
- // used to be if ((c->codec_id >= CODEC_ID_PCM_S16LE) && (c->codec_id <= CODEC_ID_PCM_DVD))
- // not sure if that is needed anymore, so let's try out if there are any
- // complaints regarding some ffmpeg versions users might have
+ /* Used to be if ((c->codec_id >= CODEC_ID_PCM_S16LE) && (c->codec_id <= CODEC_ID_PCM_DVD))
+ * not sure if that is needed anymore, so let's try out if there are any
+ * complaints regarding some FFmpeg versions users might have. */
context->audio_input_samples = FF_MIN_BUFFER_SIZE * 8 / c->bits_per_coded_sample / c->channels;
}
else {
@@ -1675,9 +1675,9 @@ static void ffmpeg_set_expert_options(RenderData *rd)
/* This breaks compatibility for QT. */
// BKE_ffmpeg_property_add_string(rd, "video", "flags:loop");
BKE_ffmpeg_property_add_string(rd, "video", "cmp:chroma");
- BKE_ffmpeg_property_add_string(rd, "video", "partitions:parti4x4"); // Deprecated.
- BKE_ffmpeg_property_add_string(rd, "video", "partitions:partp8x8"); // Deprecated.
- BKE_ffmpeg_property_add_string(rd, "video", "partitions:partb8x8"); // Deprecated.
+ BKE_ffmpeg_property_add_string(rd, "video", "partitions:parti4x4"); /* Deprecated. */
+ BKE_ffmpeg_property_add_string(rd, "video", "partitions:partp8x8"); /* Deprecated. */
+ BKE_ffmpeg_property_add_string(rd, "video", "partitions:partb8x8"); /* Deprecated. */
BKE_ffmpeg_property_add_string(rd, "video", "me:hex");
BKE_ffmpeg_property_add_string(rd, "video", "subq:6");
BKE_ffmpeg_property_add_string(rd, "video", "me_range:16");
@@ -1787,7 +1787,7 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset)
rd->ffcodecdata.codec = AV_CODEC_ID_MPEG4;
}
else if (preset == FFMPEG_PRESET_THEORA) {
- rd->ffcodecdata.type = FFMPEG_OGG; // XXX broken
+ rd->ffcodecdata.type = FFMPEG_OGG; /* XXX broken */
rd->ffcodecdata.codec = AV_CODEC_ID_THEORA;
}
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h
index 922039e8862..74a491898b6 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -146,7 +146,7 @@ int BLI_access(const char *filename, int mode) ATTR_WARN_UNUSED_RESULT ATTR_NONN
bool BLI_file_is_writable(const char *file) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BLI_file_touch(const char *file) ATTR_NONNULL();
-bool BLI_file_alias_target(char *target, const char *filepath);
+bool BLI_file_alias_target(const char *filepath, char *r_targetpath) ATTR_WARN_UNUSED_RESULT;
#if 0 /* UNUSED */
int BLI_file_gzip(const char *from, const char *to) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh
index 9684f372db7..f1cf44018c9 100644
--- a/source/blender/blenlib/BLI_set.hh
+++ b/source/blender/blenlib/BLI_set.hh
@@ -351,6 +351,23 @@ class Set {
}
/**
+ * Returns the key in the set that compares equal to the given key. If it does not exist, the key
+ * is newly added.
+ */
+ const Key &lookup_key_or_add(const Key &key)
+ {
+ return this->lookup_key_or_add_as(key);
+ }
+ const Key &lookup_key_or_add(Key &&key)
+ {
+ return this->lookup_key_or_add_as(std::move(key));
+ }
+ template<typename ForwardKey> const Key &lookup_key_or_add_as(ForwardKey &&key)
+ {
+ return this->lookup_key_or_add__impl(std::forward<ForwardKey>(key), hash_(key));
+ }
+
+ /**
* Deletes the key from the set. Returns true when the key did exist beforehand, otherwise false.
*
* This is similar to std::unordered_set::erase.
@@ -735,6 +752,22 @@ class Set {
}
template<typename ForwardKey>
+ const Key &lookup_key_or_add__impl(ForwardKey &&key, const uint64_t hash)
+ {
+ SET_SLOT_PROBING_BEGIN (hash, slot) {
+ if (slot.contains(key, is_equal_, hash)) {
+ return *slot.key();
+ }
+ if (slot.is_empty()) {
+ slot.occupy(std::forward<ForwardKey>(key), hash);
+ occupied_and_removed_slots_++;
+ return *slot.key();
+ }
+ }
+ SET_SLOT_PROBING_END();
+ }
+
+ template<typename ForwardKey>
int64_t count_collisions__impl(const ForwardKey &key, const uint64_t hash) const
{
int64_t collisions = 0;
diff --git a/source/blender/blenlib/BLI_task.hh b/source/blender/blenlib/BLI_task.hh
new file mode 100644
index 00000000000..8a0d77745c8
--- /dev/null
+++ b/source/blender/blenlib/BLI_task.hh
@@ -0,0 +1,74 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup bli
+ */
+
+#ifdef WITH_TBB
+/* Quiet top level deprecation message, unrelated to API usage here. */
+# define TBB_SUPPRESS_DEPRECATED_MESSAGES 1
+
+# ifdef WIN32
+/* TBB includes Windows.h which will define min/max macros causing issues
+ * when we try to use std::min and std::max later on. */
+# define NOMINMAX
+# endif
+# include <tbb/tbb.h>
+# ifdef WIN32
+/* We cannot keep this defined, since other parts of the code deal with this on their own leading
+ * to multiple define warnings unless we un-define this. */
+# undef NOMINMAX
+# endif
+#endif
+
+#include "BLI_index_range.hh"
+#include "BLI_utildefines.h"
+
+namespace blender {
+
+template<typename Range, typename Function>
+void parallel_for_each(Range &range, const Function &function)
+{
+#ifdef WITH_TBB
+ tbb::parallel_for_each(range, function);
+#else
+ for (auto &value : range) {
+ function(value);
+ }
+#endif
+}
+
+template<typename Function>
+void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
+{
+ if (range.size() == 0) {
+ return;
+ }
+#ifdef WITH_TBB
+ tbb::parallel_for(tbb::blocked_range<int64_t>(range.first(), range.one_after_last(), grain_size),
+ [&](const tbb::blocked_range<int64_t> &subrange) {
+ function(IndexRange(subrange.begin(), subrange.size()));
+ });
+#else
+ UNUSED_VARS(grain_size);
+ function(range);
+#endif
+}
+
+} // namespace blender
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 326015e8d80..40d24f07c25 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -782,7 +782,8 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
/* Useful to port C code using enums to C++ where enums are strongly typed.
* To use after the enum declaration. */
-# define ENUM_OPERATORS(_enum_type) \
+/* If any enumerator `C` is set to say `A|B`, then `C` would be the max enum value. */
+# define ENUM_OPERATORS(_enum_type, _max_enum_value) \
inline constexpr _enum_type operator|(_enum_type a, _enum_type b) \
{ \
return static_cast<_enum_type>(static_cast<int>(a) | b); \
@@ -793,7 +794,7 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
} \
inline constexpr _enum_type operator~(_enum_type a) \
{ \
- return static_cast<_enum_type>(~static_cast<int>(a)); \
+ return static_cast<_enum_type>(~static_cast<int>(a) & (2 * _max_enum_value - 1)); \
} \
inline _enum_type &operator|=(_enum_type &a, _enum_type b) \
{ \
@@ -806,7 +807,7 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
#else
/* Output nothing. */
-# define ENUM_OPERATORS(_type)
+# define ENUM_OPERATORS(_type, _max)
#endif
/** \} */
diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh
index 3c90e1ab755..053dcb6faea 100644
--- a/source/blender/blenlib/BLI_vector.hh
+++ b/source/blender/blenlib/BLI_vector.hh
@@ -186,7 +186,7 @@ class Vector {
template<typename InputIt,
/* This constructor should not be called with e.g. Vector(3, 10), because that is
- expected to produce the vector (10, 10, 10). */
+ * expected to produce the vector (10, 10, 10). */
typename std::enable_if_t<!std::is_convertible_v<InputIt, int>> * = nullptr>
Vector(InputIt first, InputIt last, Allocator allocator = {})
: Vector(NoExceptConstructor(), allocator)
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index 26f1de33aa9..fe3ec368379 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -248,8 +248,8 @@ unsigned int BLI_filelist_dir_contents(const char *dirname, struct direntry **r_
*r_filelist = dir_ctx.files;
}
else {
- // keep blender happy. Blender stores this in a variable
- // where 0 has special meaning.....
+ /* Keep Blender happy. Blender stores this in a variable
+ * where 0 has special meaning..... */
*r_filelist = MEM_mallocN(sizeof(**r_filelist), __func__);
}
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index 014c5217896..413c2007b1b 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -58,7 +58,7 @@
#include "BLI_fileops.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
-#include "BLI_sys_types.h" // for intptr_t support
+#include "BLI_sys_types.h" /* for intptr_t support */
#include "BLI_utildefines.h"
#if 0 /* UNUSED */
diff --git a/source/blender/blenlib/intern/math_boolean.cc b/source/blender/blenlib/intern/math_boolean.cc
index f7454a713a1..f8bf8676f50 100644
--- a/source/blender/blenlib/intern/math_boolean.cc
+++ b/source/blender/blenlib/intern/math_boolean.cc
@@ -123,7 +123,7 @@ namespace robust_pred {
* Since this is C++, an instantiated singleton class is used to make
* sure that #exactinit() is called once.
* (Because it's undefined when this is called in initialization of all modules,
- other modules shouldn't use these functions in initialization.)
+ * other modules shouldn't use these functions in initialization.)
*/
void exactinit();
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 132aeb3ace2..31ee81de40e 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -264,7 +264,7 @@ void rgb_to_hsl(float r, float g, float b, float *r_h, float *r_s, float *r_l)
float h, s, l = min_ff(1.0, (cmax + cmin) / 2.0f);
if (cmax == cmin) {
- h = s = 0.0f; // achromatic
+ h = s = 0.0f; /* achromatic */
}
else {
float d = cmax - cmin;
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index c7cd1901164..c8e84cee0a0 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -2344,7 +2344,6 @@ BLI_INLINE int _axis_signed(const int axis)
bool mat3_from_axis_conversion(
int src_forward, int src_up, int dst_forward, int dst_up, float r_mat[3][3])
{
- // from functools import reduce
int value;
if (src_forward == dst_forward && src_up == dst_up) {
diff --git a/source/blender/blenlib/intern/mesh_boolean.cc b/source/blender/blenlib/intern/mesh_boolean.cc
index a6ab30a3b26..169687cf9d1 100644
--- a/source/blender/blenlib/intern/mesh_boolean.cc
+++ b/source/blender/blenlib/intern/mesh_boolean.cc
@@ -3113,16 +3113,8 @@ static Array<bool> find_dissolve_verts(IMesh &imesh_out, int *r_count_dissolve)
const std::pair<const Vert *, const Vert *> &nbrs = neighbors[v_out];
if (nbrs.first != nullptr) {
BLI_assert(nbrs.second != nullptr);
- const mpq3 &co1 = nbrs.first->co_exact;
- const mpq3 &co2 = nbrs.second->co_exact;
- const mpq3 &co = imesh_out.vert(v_out)->co_exact;
- mpq3 dir1 = co - co1;
- mpq3 dir2 = co2 - co;
- mpq3 cross = mpq3::cross(dir1, dir2);
- if (cross[0] == 0 && cross[1] == 0 && cross[2] == 0) {
- dissolve[v_out] = true;
- ++count;
- }
+ dissolve[v_out] = true;
+ ++count;
}
}
}
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index d4f0467b31b..f3afef80c3e 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -1026,7 +1026,7 @@ bool BLI_path_abs(char *path, const char *basepath)
if (!wasrelative && !BLI_path_is_abs(path)) {
char *p = path;
BLI_windows_get_default_root_dir(tmp);
- // get rid of the slashes at the beginning of the path
+ /* Get rid of the slashes at the beginning of the path. */
while (ELEM(*p, '\\', '/')) {
p++;
}
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index a841068bfdb..628bdc1a31f 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -288,11 +288,11 @@ eFileAttributes BLI_file_attributes(const char *path)
/* Return alias/shortcut file target. Apple version is defined in storage_apple.mm */
#ifndef __APPLE__
-bool BLI_file_alias_target(
- /* This parameter can only be const on non-windows platforms.
- * NOLINTNEXTLINE: readability-non-const-parameter. */
- char target[FILE_MAXDIR],
- const char *filepath)
+bool BLI_file_alias_target(const char *filepath,
+ /* This parameter can only be `const` on Linux since
+ * redirections are not supported there.
+ * NOLINTNEXTLINE: readability-non-const-parameter. */
+ char r_targetpath[FILE_MAXDIR])
{
# ifdef WIN32
if (!BLI_path_extension_check(filepath, ".lnk")) {
@@ -318,7 +318,7 @@ bool BLI_file_alias_target(
wchar_t target_utf16[FILE_MAXDIR] = {0};
hr = Shortcut->lpVtbl->GetPath(Shortcut, target_utf16, FILE_MAXDIR, NULL, 0);
if (SUCCEEDED(hr)) {
- success = (conv_utf_16_to_8(target_utf16, target, FILE_MAXDIR) == 0);
+ success = (conv_utf_16_to_8(target_utf16, r_targetpath, FILE_MAXDIR) == 0);
}
}
PersistFile->lpVtbl->Release(PersistFile);
@@ -328,9 +328,9 @@ bool BLI_file_alias_target(
Shortcut->lpVtbl->Release(Shortcut);
}
- return (success && target[0]);
+ return (success && r_targetpath[0]);
# else
- UNUSED_VARS(target, filepath);
+ UNUSED_VARS(r_targetpath, filepath);
/* File-based redirection not supported. */
return false;
# endif
diff --git a/source/blender/blenlib/intern/storage_apple.mm b/source/blender/blenlib/intern/storage_apple.mm
index 08d2cfdf4a4..16a2fd338fa 100644
--- a/source/blender/blenlib/intern/storage_apple.mm
+++ b/source/blender/blenlib/intern/storage_apple.mm
@@ -28,7 +28,11 @@
#include "BLI_fileops.h"
#include "BLI_path_util.h"
-bool BLI_file_alias_target(char targetpath[FILE_MAXDIR], const char *filepath)
+/**
+ * \param r_targetpath Buffer for the target path an alias points to.
+ * \return Whether the file at the input path is an alias.
+ */
+bool BLI_file_alias_target(const char *filepath, char r_targetpath[FILE_MAXDIR])
{
/* clang-format off */
@autoreleasepool {
@@ -37,26 +41,24 @@ bool BLI_file_alias_target(char targetpath[FILE_MAXDIR], const char *filepath)
NSURL *shortcutURL = [[NSURL alloc] initFileURLWithFileSystemRepresentation:filepath
isDirectory:NO
relativeToURL:nil];
- NSURL *targetURL = [NSURL URLByResolvingAliasFileAtURL:shortcutURL
- options:NSURLBookmarkResolutionWithoutUI
- error:&error];
- BOOL isSame = [shortcutURL isEqual:targetURL] and
- ([[[shortcutURL path] stringByStandardizingPath]
- isEqualToString:[[targetURL path] stringByStandardizingPath]]);
+ const NSURL *targetURL = [NSURL URLByResolvingAliasFileAtURL:shortcutURL
+ options:NSURLBookmarkResolutionWithoutUI
+ error:&error];
+ const BOOL isSame = [shortcutURL isEqual:targetURL] and
+ ([[[shortcutURL path] stringByStandardizingPath]
+ isEqualToString:[[targetURL path] stringByStandardizingPath]]);
if (targetURL == nil) {
return false;
}
- else if (isSame) {
- [targetURL getFileSystemRepresentation:targetpath maxLength:FILE_MAXDIR];
+ if (isSame) {
+ [targetURL getFileSystemRepresentation:r_targetpath maxLength:FILE_MAXDIR];
return false;
}
- else if (![targetURL getFileSystemRepresentation:targetpath maxLength:FILE_MAXDIR]) {
+ /* Note that the if-condition may also change the value of `r_targetpath`. */
+ if (![targetURL getFileSystemRepresentation:r_targetpath maxLength:FILE_MAXDIR]) {
return false;
}
-
- NSNumber *targetIsDirectory = 0;
- [targetURL getResourceValue:&targetIsDirectory forKey:NSURLIsDirectoryKey error:nil];
}
return true;
@@ -69,13 +71,13 @@ eFileAttributes BLI_file_attributes(const char *path)
/* clang-format off */
@autoreleasepool {
/* clang-format on */
- NSURL *fileURL = [[NSURL alloc] initFileURLWithFileSystemRepresentation:path
- isDirectory:NO
- relativeToURL:nil];
+ const NSURL *fileURL = [[NSURL alloc] initFileURLWithFileSystemRepresentation:path
+ isDirectory:NO
+ relativeToURL:nil];
NSArray *resourceKeys =
@[ NSURLIsAliasFileKey, NSURLIsHiddenKey, NSURLIsReadableKey, NSURLIsWritableKey ];
- NSDictionary *resourceKeyValues = [fileURL resourceValuesForKeys:resourceKeys error:nil];
+ const NSDictionary *resourceKeyValues = [fileURL resourceValuesForKeys:resourceKeys error:nil];
const bool is_alias = [resourceKeyValues[(void)(@"@%"), NSURLIsAliasFileKey] boolValue];
const bool is_hidden = [resourceKeyValues[(void)(@"@%"), NSURLIsHiddenKey] boolValue];
diff --git a/source/blender/blenlib/intern/system_win32.c b/source/blender/blenlib/intern/system_win32.c
index d60f54ebe67..be2195d679d 100644
--- a/source/blender/blenlib/intern/system_win32.c
+++ b/source/blender/blenlib/intern/system_win32.c
@@ -244,7 +244,7 @@ static void bli_windows_system_backtrace_modules(FILE *fp)
me32.dwSize = sizeof(MODULEENTRY32);
if (!Module32First(hModuleSnap, &me32)) {
- CloseHandle(hModuleSnap); // Must clean up the snapshot object!
+ CloseHandle(hModuleSnap); /* Must clean up the snapshot object! */
fprintf(fp, " Error getting module list.\n");
return;
}
diff --git a/source/blender/blenlib/tests/BLI_path_util_test.cc b/source/blender/blenlib/tests/BLI_path_util_test.cc
index 6cfebd0ea05..5556062233e 100644
--- a/source/blender/blenlib/tests/BLI_path_util_test.cc
+++ b/source/blender/blenlib/tests/BLI_path_util_test.cc
@@ -284,9 +284,9 @@ TEST(path_util, JoinTruncateLong)
JOIN("//longer/p", 11, "//", "//longer", "path");
JOIN("//longer/pa", 12, "//", "//longer", "path");
JOIN("//longer/pat", 13, "//", "//longer", "path");
- JOIN("//longer/path", 14, "//", "//longer", "path"); // not truncated
+ JOIN("//longer/path", 14, "//", "//longer", "path"); /* not truncated. */
JOIN("//longer/path", 14, "//", "//longer", "path/");
- JOIN("//longer/path/", 15, "//", "//longer", "path/"); // not truncated
+ JOIN("//longer/path/", 15, "//", "//longer", "path/"); /* not truncated. */
JOIN("//longer/path/", 15, "//", "//longer", "path/", "trunc");
JOIN("//longer/path/t", 16, "//", "//longer", "path/", "trunc");
}
diff --git a/source/blender/blenlib/tests/BLI_set_test.cc b/source/blender/blenlib/tests/BLI_set_test.cc
index bf49bfb611b..dbe820c9d15 100644
--- a/source/blender/blenlib/tests/BLI_set_test.cc
+++ b/source/blender/blenlib/tests/BLI_set_test.cc
@@ -453,6 +453,20 @@ TEST(set, LookupKeyPtr)
EXPECT_EQ(set.lookup_key_ptr({3, 50}), nullptr);
}
+TEST(set, LookupKeyOrAdd)
+{
+ Set<MyKeyType> set;
+ set.add({1, 10});
+ set.add({2, 20});
+ EXPECT_EQ(set.size(), 2);
+ EXPECT_EQ(set.lookup_key_or_add({2, 40}).attached_data, 20);
+ EXPECT_EQ(set.size(), 2);
+ EXPECT_EQ(set.lookup_key_or_add({3, 40}).attached_data, 40);
+ EXPECT_EQ(set.size(), 3);
+ EXPECT_EQ(set.lookup_key_or_add({3, 60}).attached_data, 40);
+ EXPECT_EQ(set.size(), 3);
+}
+
TEST(set, StringViewKeys)
{
Set<std::string_view> set;
diff --git a/source/blender/blenlib/tests/BLI_string_test.cc b/source/blender/blenlib/tests/BLI_string_test.cc
index 12f0fd5ac62..e8fe505a6c9 100644
--- a/source/blender/blenlib/tests/BLI_string_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_test.cc
@@ -4,7 +4,7 @@
#include <array>
#include <initializer_list>
-#include <ostream> // NOLINT
+#include <ostream> /* NOLINT */
#include <string>
#include <utility>
#include <vector>
diff --git a/source/blender/blenlib/tests/BLI_string_utf8_test.cc b/source/blender/blenlib/tests/BLI_string_utf8_test.cc
index 96df4d2b71a..9743c1387a0 100644
--- a/source/blender/blenlib/tests/BLI_string_utf8_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_utf8_test.cc
@@ -23,14 +23,14 @@
* by Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> - 2015-08-28 - CC BY 4.0
*/
const char *utf8_invalid_tests[][3] = {
-// 1 Some correct UTF-8 text
+/* 1 Some correct UTF-8 text. */
{"You should see the Greek word 'kosme': \"\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce\xb5\" |",
"You should see the Greek word 'kosme': \"\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce\xb5\" |", "\x00"},
-// 2 Boundary condition test cases
-// Note that those will pass for us, those are not erronéous unicode code points
-// (asside from \x00, which is only valid as string terminator).
-// 2.1 First possible sequence of a certain length
+/* 2 Boundary condition test cases
+ * Note that those will pass for us, those are not erronéous unicode code points
+ * (aside from \x00, which is only valid as string terminator).
+ * 2.1 First possible sequence of a certain length */
{"2.1.1 1 byte (U-00000000): \"\x00\" |",
"2.1.1 1 byte (U-00000000): \"\" |", "\x01"},
{"2.1.2 2 bytes (U-00000080): \"\xc2\x80\" |",
@@ -43,7 +43,7 @@ const char *utf8_invalid_tests[][3] = {
"2.1.5 5 bytes (U-00200000): \"\xf8\x88\x80\x80\x80\" |", "\x00"},
{"2.1.6 6 bytes (U-04000000): \"\xfc\x84\x80\x80\x80\x80\" |",
"2.1.6 6 bytes (U-04000000): \"\xfc\x84\x80\x80\x80\x80\" |", "\x00"},
-// 2.2 Last possible sequence of a certain length
+/* 2.2 Last possible sequence of a certain length */
{"2.2.1 1 byte (U-0000007F): \"\x7f\" |",
"2.2.1 1 byte (U-0000007F): \"\x7f\" |", "\x00"},
{"2.2.2 2 bytes (U-000007FF): \"\xdf\xbf\" |",
@@ -56,7 +56,7 @@ const char *utf8_invalid_tests[][3] = {
"2.2.5 5 bytes (U-03FFFFFF): \"\xfb\xbf\xbf\xbf\xbf\" |", "\x00"},
{"2.2.6 6 bytes (U-7FFFFFFF): \"\xfd\xbf\xbf\xbf\xbf\xbf\" |",
"2.2.6 6 bytes (U-7FFFFFFF): \"\xfd\xbf\xbf\xbf\xbf\xbf\" |", "\x00"},
-// 2.3 Other boundary conditions
+/* 2.3 Other boundary conditions */
{"2.3.1 U-0000D7FF = ed 9f bf = \"\xed\x9f\xbf\" |",
"2.3.1 U-0000D7FF = ed 9f bf = \"\xed\x9f\xbf\" |", "\x00"},
{"2.3.2 U-0000E000 = ee 80 80 = \"\xee\x80\x80\" |",
@@ -68,9 +68,9 @@ const char *utf8_invalid_tests[][3] = {
{"2.3.5 U-00110000 = f4 90 80 80 = \"\xf4\x90\x80\x80\" |",
"2.3.5 U-00110000 = f4 90 80 80 = \"\xf4\x90\x80\x80\" |", "\x00"},
-// 3 Malformed sequences
-// 3.1 Unexpected continuation bytes
-// Each unexpected continuation byte should be separately signaled as a malformed sequence of its own.
+/* 3 Malformed sequences
+ * 3.1 Unexpected continuation bytes
+ * Each unexpected continuation byte should be separately signaled as a malformed sequence of its own. */
{"3.1.1 First continuation byte 0x80: \"\x80\" |",
"3.1.1 First continuation byte 0x80: \"\" |", "\x01"},
{"3.1.2 Last continuation byte 0xbf: \"\xbf\" |",
@@ -87,33 +87,33 @@ const char *utf8_invalid_tests[][3] = {
"3.1.7 6 continuation bytes: \"\" |", "\x06"},
{"3.1.8 7 continuation bytes: \"\x80\xbf\x80\xbf\x80\xbf\x80\" |",
"3.1.8 7 continuation bytes: \"\" |", "\x07"},
-// 3.1.9 Sequence of all 64 possible continuation bytes (0x80-0xbf): |
+/* 3.1.9 Sequence of all 64 possible continuation bytes (0x80-0xbf): | */
{"3.1.9 \"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\" |",
"3.1.9 \"\" |", "\x40"},
-// 3.2 Lonely start characters
-// 3.2.1 All 32 first bytes of 2-byte sequences (0xc0-0xdf), each followed by a space character:
+/* 3.2 Lonely start characters
+ * 3.2.1 All 32 first bytes of 2-byte sequences (0xc0-0xdf), each followed by a space character: */
{"3.2.1 \"\xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce \xcf "
"\xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd7 \xd8 \xd9 \xda \xdb \xdc \xdd \xde \xdf \" |",
"3.2.1 \" \" |", "\x20"},
-// 3.2.2 All 16 first bytes of 3-byte sequences (0xe0-0xef), each followed by a space character:
+/* 3.2.2 All 16 first bytes of 3-byte sequences (0xe0-0xef), each followed by a space character: */
{"3.2.2 \"\xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee \xef \" |",
"3.2.2 \" \" |", "\x10"},
-// 3.2.3 All 8 first bytes of 4-byte sequences (0xf0-0xf7), each followed by a space character:
+/* 3.2.3 All 8 first bytes of 4-byte sequences (0xf0-0xf7), each followed by a space character: */
{"3.2.3 \"\xf0 \xf1 \xf2 \xf3 \xf4 \xf5 \xf6 \xf7 \" |",
"3.2.3 \" \" |", "\x08"},
-// 3.2.4 All 4 first bytes of 5-byte sequences (0xf8-0xfb), each followed by a space character:
+/* 3.2.4 All 4 first bytes of 5-byte sequences (0xf8-0xfb), each followed by a space character: */
{"3.2.4 \"\xf8 \xf9 \xfa \xfb \" |",
"3.2.4 \" \" |", "\x04"},
-// 3.2.5 All 2 first bytes of 6-byte sequences (0xfc-0xfd), each followed by a space character:
+/* 3.2.5 All 2 first bytes of 6-byte sequences (0xfc-0xfd), each followed by a space character: */
{"3.2.4 \"\xfc \xfd \" |",
"3.2.4 \" \" |", "\x02"},
-// 3.3 Sequences with last continuation byte missing
-// All bytes of an incomplete sequence should be signaled as a single malformed sequence,
-// i.e., you should see only a single replacement character in each of the next 10 tests.
-// (Characters as in section 2)
+/* 3.3 Sequences with last continuation byte missing
+ * All bytes of an incomplete sequence should be signaled as a single malformed sequence,
+ * i.e., you should see only a single replacement character in each of the next 10 tests.
+ * (Characters as in section 2) */
{"3.3.1 2-byte sequence with last byte missing (U+0000): \"\xc0\" |",
"3.3.1 2-byte sequence with last byte missing (U+0000): \"\" |", "\x01"},
{"3.3.2 3-byte sequence with last byte missing (U+0000): \"\xe0\x80\" |",
@@ -134,14 +134,14 @@ const char *utf8_invalid_tests[][3] = {
"3.3.9 5-byte sequence with last byte missing (U-03FFFFFF): \"\" |", "\x04"},
{"3.3.10 6-byte sequence with last byte missing (U-7FFFFFFF): \"\xfd\xbf\xbf\xbf\xbf\" |",
"3.3.10 6-byte sequence with last byte missing (U-7FFFFFFF): \"\" |", "\x05"},
-// 3.4 Concatenation of incomplete sequences
-// All the 10 sequences of 3.3 concatenated, you should see 10 malformed sequences being signaled:
+/* 3.4 Concatenation of incomplete sequences
+ * All the 10 sequences of 3.3 concatenated, you should see 10 malformed sequences being signaled: */
{"3.4 \"\xc0\xe0\x80\xf0\x80\x80\xf8\x80\x80\x80\xfc\x80\x80\x80\x80"
"\xdf\xef\xbf\xf7\xbf\xbf\xfb\xbf\xbf\xbf\xfd\xbf\xbf\xbf\xbf\""
" |",
"3.4 \"\" |", "\x1e"},
-// 3.5 Impossible bytes
-// The following two bytes cannot appear in a correct UTF-8 string
+/* 3.5 Impossible bytes
+ * The following two bytes cannot appear in a correct UTF-8 string */
{"3.5.1 fe = \"\xfe\" |",
"3.5.1 fe = \"\" |", "\x01"},
{"3.5.2 ff = \"\xff\" |",
@@ -149,24 +149,24 @@ const char *utf8_invalid_tests[][3] = {
{"3.5.3 fe fe ff ff = \"\xfe\xfe\xff\xff\" |",
"3.5.3 fe fe ff ff = \"\" |", "\x04"},
-// 4 Overlong sequences
-// The following sequences are not malformed according to the letter of the Unicode 2.0 standard.
-// However, they are longer then necessary and a correct UTF-8 encoder is not allowed to produce them.
-// A "safe UTF-8 decoder" should reject them just like malformed sequences for two reasons:
-// (1) It helps to debug applications if overlong sequences are not treated as valid representations
-// of characters, because this helps to spot problems more quickly. (2) Overlong sequences provide
-// alternative representations of characters, that could maliciously be used to bypass filters that check
-// only for ASCII characters. For instance, a 2-byte encoded line feed (LF) would not be caught by a
-// line counter that counts only 0x0a bytes, but it would still be processed as a line feed by an unsafe
-// UTF-8 decoder later in the pipeline. From a security point of view, ASCII compatibility of UTF-8
-// sequences means also, that ASCII characters are *only* allowed to be represented by ASCII bytes
-// in the range 0x00-0x7f. To ensure this aspect of ASCII compatibility, use only "safe UTF-8 decoders"
-// that reject overlong UTF-8 sequences for which a shorter encoding exists.
-//
-// 4.1 Examples of an overlong ASCII character
-// With a safe UTF-8 decoder, all of the following five overlong representations of the ASCII character
-// slash ("/") should be rejected like a malformed UTF-8 sequence, for instance by substituting it with
-// a replacement character. If you see a slash below, you do not have a safe UTF-8 decoder!
+/* 4 Overlong sequences
+ * The following sequences are not malformed according to the letter of the Unicode 2.0 standard.
+ * However, they are longer then necessary and a correct UTF-8 encoder is not allowed to produce them.
+ * A "safe UTF-8 decoder" should reject them just like malformed sequences for two reasons:
+ * (1) It helps to debug applications if overlong sequences are not treated as valid representations
+ * of characters, because this helps to spot problems more quickly. (2) Overlong sequences provide
+ * alternative representations of characters, that could maliciously be used to bypass filters that check
+ * only for ASCII characters. For instance, a 2-byte encoded line feed (LF) would not be caught by a
+ * line counter that counts only 0x0a bytes, but it would still be processed as a line feed by an unsafe
+ * UTF-8 decoder later in the pipeline. From a security point of view, ASCII compatibility of UTF-8
+ * sequences means also, that ASCII characters are *only* allowed to be represented by ASCII bytes
+ * in the range 0x00-0x7f. To ensure this aspect of ASCII compatibility, use only "safe UTF-8 decoders"
+ * that reject overlong UTF-8 sequences for which a shorter encoding exists.
+ *
+ * 4.1 Examples of an overlong ASCII character
+ * With a safe UTF-8 decoder, all of the following five overlong representations of the ASCII character
+ * slash ("/") should be rejected like a malformed UTF-8 sequence, for instance by substituting it with
+ * a replacement character. If you see a slash below, you do not have a safe UTF-8 decoder! */
{"4.1.1 U+002F = c0 af = \"\xc0\xaf\" |",
"4.1.1 U+002F = c0 af = \"\" |", "\x02"},
{"4.1.2 U+002F = e0 80 af = \"\xe0\x80\xaf\" |",
@@ -177,10 +177,10 @@ const char *utf8_invalid_tests[][3] = {
"4.1.4 U+002F = f8 80 80 80 af = \"\" |", "\x05"},
{"4.1.5 U+002F = fc 80 80 80 80 af = \"\xfc\x80\x80\x80\x80\xaf\" |",
"4.1.5 U+002F = fc 80 80 80 80 af = \"\" |", "\x06"},
-// 4.2 Maximum overlong sequences
-// Below you see the highest Unicode value that is still resulting in an overlong sequence if represented
-// with the given number of bytes. This is a boundary test for safe UTF-8 decoders. All five characters
-// should be rejected like malformed UTF-8 sequences.
+/* 4.2 Maximum overlong sequences
+ * Below you see the highest Unicode value that is still resulting in an overlong sequence if represented
+ * with the given number of bytes. This is a boundary test for safe UTF-8 decoders. All five characters
+ * should be rejected like malformed UTF-8 sequences. */
{"4.2.1 U-0000007F = c1 bf = \"\xc1\xbf\" |",
"4.2.1 U-0000007F = c1 bf = \"\" |", "\x02"},
{"4.2.2 U-000007FF = e0 9f bf = \"\xe0\x9f\xbf\" |",
@@ -191,9 +191,9 @@ const char *utf8_invalid_tests[][3] = {
"4.2.4 U-001FFFFF = f8 87 bf bf bf = \"\" |", "\x05"},
{"4.2.5 U+0000 = fc 83 bf bf bf bf = \"\xfc\x83\xbf\xbf\xbf\xbf\" |",
"4.2.5 U+0000 = fc 83 bf bf bf bf = \"\" |", "\x06"},
-// 4.3 Overlong representation of the NUL character
-// The following five sequences should also be rejected like malformed UTF-8 sequences and should not be
-// treated like the ASCII NUL character.
+/* 4.3 Overlong representation of the NUL character
+ * The following five sequences should also be rejected like malformed UTF-8 sequences and should not be
+ * treated like the ASCII NUL character. */
{"4.3.1 U+0000 = c0 80 = \"\xc0\x80\" |",
"4.3.1 U+0000 = c0 80 = \"\" |", "\x02"},
{"4.3.2 U+0000 = e0 80 80 = \"\xe0\x80\x80\" |",
@@ -205,11 +205,11 @@ const char *utf8_invalid_tests[][3] = {
{"4.3.5 U+0000 = fc 80 80 80 80 80 = \"\xfc\x80\x80\x80\x80\x80\" |",
"4.3.5 U+0000 = fc 80 80 80 80 80 = \"\" |", "\x06"},
-// 5 Illegal code positions
-// The following UTF-8 sequences should be rejected like malformed sequences, because they never represent
-// valid ISO 10646 characters and a UTF-8 decoder that accepts them might introduce security problems
-// comparable to overlong UTF-8 sequences.
-// 5.1 Single UTF-16 surrogates
+/* 5 Illegal code positions
+ * The following UTF-8 sequences should be rejected like malformed sequences, because they never represent
+ * valid ISO 10646 characters and a UTF-8 decoder that accepts them might introduce security problems
+ * comparable to overlong UTF-8 sequences.
+ * 5.1 Single UTF-16 surrogates */
{"5.1.1 U+D800 = ed a0 80 = \"\xed\xa0\x80\" |",
"5.1.1 U+D800 = ed a0 80 = \"\" |", "\x03"},
{"5.1.2 U+DB7F = ed ad bf = \"\xed\xad\xbf\" |",
@@ -224,7 +224,7 @@ const char *utf8_invalid_tests[][3] = {
"5.1.6 U+DF80 = ed be 80 = \"\" |", "\x03"},
{"5.1.7 U+DFFF = ed bf bf = \"\xed\xbf\xbf\" |",
"5.1.7 U+DFFF = ed bf bf = \"\" |", "\x03"},
-// 5.2 Paired UTF-16 surrogates
+/* 5.2 Paired UTF-16 surrogates */
{"5.2.1 U+D800 U+DC00 = ed a0 80 ed b0 80 = \"\xed\xa0\x80\xed\xb0\x80\" |",
"5.2.1 U+D800 U+DC00 = ed a0 80 ed b0 80 = \"\" |", "\x06"},
{"5.2.2 U+D800 U+DFFF = ed a0 80 ed bf bf = \"\xed\xa0\x80\xed\xbf\xbf\" |",
@@ -241,27 +241,27 @@ const char *utf8_invalid_tests[][3] = {
"5.2.7 U+DBFF U+DC00 = ed af bf ed b0 80 = \"\" |", "\x06"},
{"5.2.8 U+DBFF U+DFFF = ed af bf ed bf bf = \"\xed\xaf\xbf\xed\xbf\xbf\" |",
"5.2.8 U+DBFF U+DFFF = ed af bf ed bf bf = \"\" |", "\x06"},
-// 5.3 Noncharacter code positions
-// The following "noncharacters" are "reserved for internal use" by applications, and according to older versions
-// of the Unicode Standard "should never be interchanged". Unicode Corrigendum #9 dropped the latter restriction.
-// Nevertheless, their presence in incoming UTF-8 data can remain a potential security risk, depending
-// on what use is made of these codes subsequently. Examples of such internal use:
-// - Some file APIs with 16-bit characters may use the integer value -1 = U+FFFF to signal
-// an end-of-file (EOF) or error condition.
-// - In some UTF-16 receivers, code point U+FFFE might trigger a byte-swap operation
-// (to convert between UTF-16LE and UTF-16BE).
-// With such internal use of noncharacters, it may be desirable and safer to block those code points in
-// UTF-8 decoders, as they should never occur legitimately in incoming UTF-8 data, and could trigger
-// unsafe behavior in subsequent processing.
-//
-// Particularly problematic noncharacters in 16-bit applications:
+/* 5.3 Non-character code positions
+ * The following "non-characters" are "reserved for internal use" by applications, and according to older versions
+ * of the Unicode Standard "should never be interchanged". Unicode Corrigendum #9 dropped the latter restriction.
+ * Nevertheless, their presence in incoming UTF-8 data can remain a potential security risk, depending
+ * on what use is made of these codes subsequently. Examples of such internal use:
+ * - Some file APIs with 16-bit characters may use the integer value -1 = U+FFFF to signal
+ * an end-of-file (EOF) or error condition.
+ * - In some UTF-16 receivers, code point U+FFFE might trigger a byte-swap operation
+ * (to convert between UTF-16LE and UTF-16BE).
+ * With such internal use of non-characters, it may be desirable and safer to block those code points in
+ * UTF-8 decoders, as they should never occur legitimately in incoming UTF-8 data, and could trigger
+ * unsafe behavior in subsequent processing.
+ *
+ * Particularly problematic non-characters in 16-bit applications: */
{"5.3.1 U+FFFE = ef bf be = \"\xef\xbf\xbe\" |",
"5.3.1 U+FFFE = ef bf be = \"\" |", "\x03"},
{"5.3.2 U+FFFF = ef bf bf = \"\xef\xbf\xbf\" |",
"5.3.2 U+FFFF = ef bf bf = \"\" |", "\x03"},
- /* Fo now, we ignore those, they do not seem to be crucial anyway... */
-// 5.3.3 U+FDD0 .. U+FDEF
-// 5.3.4 U+nFFFE U+nFFFF (for n = 1..10)
+ /* For now, we ignore those, they do not seem to be crucial anyway... */
+/* 5.3.3 U+FDD0 .. U+FDEF
+ * 5.3.4 U+nFFFE U+nFFFF (for n = 1..10) */
{NULL, NULL, NULL},
};
/* clang-format on */
diff --git a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
index f93c40f05fb..6400bec93f9 100644
--- a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
+++ b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
@@ -310,6 +310,7 @@ static void randint_ghash_tests(GHash *ghash, const char *id, const unsigned int
}
BLI_ghash_free(ghash, NULL, NULL);
+ MEM_freeN(data);
printf("========== ENDED %s ==========\n\n", id);
}
@@ -506,6 +507,7 @@ static void multi_small_ghash_tests_one(GHash *ghash, RNG *rng, const unsigned i
}
BLI_ghash_clear(ghash, NULL, NULL);
+ MEM_freeN(data);
}
static void multi_small_ghash_tests(GHash *ghash, const char *id, const unsigned int nbr)
diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c
index 0a5d8d332aa..2848aac2c77 100644
--- a/source/blender/blenloader/intern/blend_validate.c
+++ b/source/blender/blenloader/intern/blend_validate.c
@@ -23,7 +23,7 @@
* \note Does not *fix* anything, only reports found errors.
*/
-#include <string.h> // for strrchr strncmp strstr
+#include <string.h> /* for strrchr strncmp strstr */
#include "BLI_utildefines.h"
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index cf2181c8a27..17d9a6d89f0 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -33,11 +33,11 @@
#include "BLI_utildefines.h"
#ifndef WIN32
-# include <unistd.h> // for read close
+# include <unistd.h> /* for read close */
#else
# include "BLI_winstuff.h"
# include "winsock2.h"
-# include <io.h> // for open close read
+# include <io.h> /* for open close read */
#endif
/* allow readfile to use deprecated functionality */
@@ -126,7 +126,7 @@
#include "BKE_fcurve.h"
#include "BKE_fcurve_driver.h"
#include "BKE_fluid.h"
-#include "BKE_global.h" // for G
+#include "BKE_global.h" /* for G */
#include "BKE_gpencil.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_hair.h"
@@ -138,15 +138,15 @@
#include "BKE_lib_id.h"
#include "BKE_lib_override.h"
#include "BKE_lib_query.h"
-#include "BKE_main.h" // for Main
+#include "BKE_main.h" /* for Main */
#include "BKE_main_idmap.h"
#include "BKE_material.h"
-#include "BKE_mesh.h" // for ME_ defines (patching)
+#include "BKE_mesh.h" /* for ME_ defines (patching) */
#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_nla.h"
-#include "BKE_node.h" // for tree type defines
+#include "BKE_node.h" /* for tree type defines */
#include "BKE_object.h"
#include "BKE_packedFile.h"
#include "BKE_paint.h"
@@ -766,7 +766,7 @@ static void switch_endian_bh8(BHead8 *bhead)
}
}
-static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap)
+static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, bool do_endian_swap)
{
BHead4 *bhead4 = (BHead4 *)bhead;
int64_t old;
@@ -859,7 +859,7 @@ static BHeadN *get_bhead(FileData *fd)
}
if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) {
- bh4_from_bh8(&bhead, &bhead8, (fd->flags & FD_FLAGS_SWITCH_ENDIAN));
+ bh4_from_bh8(&bhead, &bhead8, (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0);
}
else {
/* MIN2 is only to quiet '-Warray-bounds' compiler warning. */
@@ -1490,7 +1490,7 @@ static ssize_t fd_read_gzip_from_memory(FileData *filedata,
filedata->strm.next_out = (Bytef *)buffer;
filedata->strm.avail_out = (uint)size;
- // Inflate another chunk.
+ /* Inflate another chunk. */
err = inflate(&filedata->strm, Z_SYNC_FLUSH);
if (err == Z_STREAM_END) {
@@ -2490,7 +2490,7 @@ static void direct_link_id_common(
/** \name Read Animation (legacy for version patching)
* \{ */
-// XXX deprecated - old animation system
+/* XXX deprecated - old animation system */
static void lib_link_ipo(BlendLibReader *reader, Ipo *ipo)
{
LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
@@ -2500,7 +2500,7 @@ static void lib_link_ipo(BlendLibReader *reader, Ipo *ipo)
}
}
-// XXX deprecated - old animation system
+/* XXX deprecated - old animation system */
static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo)
{
BLO_read_list(reader, &(ipo->curve));
@@ -2509,10 +2509,36 @@ static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo)
BLO_read_data_address(reader, &icu->bezt);
BLO_read_data_address(reader, &icu->bp);
BLO_read_data_address(reader, &icu->driver);
+
+ /* Undo generic endian switching. */
+ if (BLO_read_requires_endian_switch(reader)) {
+ BLI_endian_switch_int16(&icu->blocktype);
+ if (icu->driver != NULL) {
+
+ /* Undo generic endian switching. */
+ if (BLO_read_requires_endian_switch(reader)) {
+ BLI_endian_switch_int16(&icu->blocktype);
+ if (icu->driver != NULL) {
+ BLI_endian_switch_int16(&icu->driver->blocktype);
+ }
+ }
+ }
+
+ /* Undo generic endian switching. */
+ if (BLO_read_requires_endian_switch(reader)) {
+ BLI_endian_switch_int16(&ipo->blocktype);
+ BLI_endian_switch_int16(&icu->driver->blocktype);
+ }
+ }
+ }
+
+ /* Undo generic endian switching. */
+ if (BLO_read_requires_endian_switch(reader)) {
+ BLI_endian_switch_int16(&ipo->blocktype);
}
}
-// XXX deprecated - old animation system
+/* XXX deprecated - old animation system */
static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *striplist)
{
LISTBASE_FOREACH (bActionStrip *, strip, striplist) {
@@ -2525,7 +2551,7 @@ static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *stripli
}
}
-// XXX deprecated - old animation system
+/* XXX deprecated - old animation system */
static void direct_link_nlastrips(BlendDataReader *reader, ListBase *strips)
{
BLO_read_list(reader, strips);
@@ -2535,7 +2561,7 @@ static void direct_link_nlastrips(BlendDataReader *reader, ListBase *strips)
}
}
-// XXX deprecated - old animation system
+/* XXX deprecated - old animation system */
static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase)
{
LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
@@ -2654,7 +2680,7 @@ static void lib_link_constraints(BlendLibReader *reader, ID *id, ListBase *conli
con->type = CONSTRAINT_TYPE_NULL;
}
/* own ipo, all constraints have it */
- BLO_read_id_address(reader, id->lib, &con->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, id->lib, &con->ipo); /* XXX deprecated - old animation system */
/* If linking from a library, clear 'local' library override flag. */
if (id->lib != NULL) {
@@ -2803,14 +2829,14 @@ void blo_do_versions_key_uidgen(Key *key)
/* update this also to writefile.c */
static const char *ptcache_data_struct[] = {
- "", // BPHYS_DATA_INDEX
- "", // BPHYS_DATA_LOCATION
- "", // BPHYS_DATA_VELOCITY
- "", // BPHYS_DATA_ROTATION
- "", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
- "", // BPHYS_DATA_SIZE:
- "", // BPHYS_DATA_TIMES:
- "BoidData", // case BPHYS_DATA_BOIDS:
+ "", /* BPHYS_DATA_INDEX */
+ "", /* BPHYS_DATA_LOCATION */
+ "", /* BPHYS_DATA_VELOCITY */
+ "", /* BPHYS_DATA_ROTATION */
+ "", /* BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
+ "", /* BPHYS_DATA_SIZE: */
+ "", /* BPHYS_DATA_TIMES: */
+ "BoidData", /* case BPHYS_DATA_BOIDS: */
};
static void direct_link_pointcache_cb(BlendDataReader *reader, void *data)
@@ -2897,7 +2923,8 @@ static void lib_link_partdeflect(BlendLibReader *reader, ID *id, PartDeflect *pd
static void lib_link_particlesettings(BlendLibReader *reader, ParticleSettings *part)
{
- BLO_read_id_address(reader, part->id.lib, &part->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(
+ reader, part->id.lib, &part->ipo); /* XXX deprecated - old animation system */
BLO_read_id_address(reader, part->id.lib, &part->instance_object);
BLO_read_id_address(reader, part->id.lib, &part->instance_collection);
@@ -3196,10 +3223,10 @@ static void lib_link_object(BlendLibReader *reader, Object *ob)
{
bool warn = false;
- // XXX deprecated - old animation system <<<
+ /* XXX deprecated - old animation system <<< */
BLO_read_id_address(reader, ob->id.lib, &ob->ipo);
BLO_read_id_address(reader, ob->id.lib, &ob->action);
- // >>> XXX deprecated - old animation system
+ /* >>> XXX deprecated - old animation system */
BLO_read_id_address(reader, ob->id.lib, &ob->parent);
BLO_read_id_address(reader, ob->id.lib, &ob->track);
@@ -3296,10 +3323,10 @@ static void lib_link_object(BlendLibReader *reader, Object *ob)
lib_link_pose(reader, ob, ob->pose);
lib_link_constraints(reader, &ob->id, &ob->constraints);
- // XXX deprecated - old animation system <<<
+ /* XXX deprecated - old animation system <<< */
lib_link_constraint_channels(reader, &ob->id, &ob->constraintChannels);
lib_link_nlastrips(reader, &ob->id, &ob->nlastrips);
- // >>> XXX deprecated - old animation system
+ /* >>> XXX deprecated - old animation system */
LISTBASE_FOREACH (PartEff *, paf, &ob->effect) {
if (paf->type == EFF_PARTICLE) {
@@ -3313,7 +3340,7 @@ static void lib_link_object(BlendLibReader *reader, Object *ob)
if (fluidmd && fluidmd->fss) {
BLO_read_id_address(
- reader, ob->id.lib, &fluidmd->fss->ipo); // XXX deprecated - old animation system
+ reader, ob->id.lib, &fluidmd->fss->ipo); /* XXX deprecated - old animation system */
}
}
@@ -3828,18 +3855,17 @@ static void direct_link_object(BlendDataReader *reader, Object *ob)
* so for now play safe. */
ob->proxy_from = NULL;
- /* loading saved files with editmode enabled works, but for undo we like
- * to stay in object mode during undo presses so keep editmode disabled.
- *
- * Also when linking in a file don't allow edit and pose modes.
- * See [T34776, T42780] for more information.
- */
const bool is_undo = BLO_read_data_is_undo(reader);
- if (is_undo || (ob->id.tag & (LIB_TAG_EXTERN | LIB_TAG_INDIRECT))) {
+ if (ob->id.tag & (LIB_TAG_EXTERN | LIB_TAG_INDIRECT)) {
+ /* Do not allow any non-object mode for linked data.
+ * See T34776, T42780, T81027 for more information. */
+ ob->mode &= ~OB_MODE_ALL_MODE_DATA;
+ }
+ else if (is_undo) {
+ /* For undo we want to stay in object mode during undo presses, so keep some edit modes
+ * disabled.
+ * TODO: Check if we should not disable more edit modes here? */
ob->mode &= ~(OB_MODE_EDIT | OB_MODE_PARTICLE_EDIT);
- if (!is_undo) {
- ob->mode &= ~OB_MODE_POSE;
- }
}
BLO_read_data_address(reader, &ob->adt);
@@ -3855,10 +3881,10 @@ static void direct_link_object(BlendDataReader *reader, Object *ob)
BLO_read_list(reader, &ob->defbase);
BLO_read_list(reader, &ob->fmaps);
- // XXX deprecated - old animation system <<<
+ /* XXX deprecated - old animation system <<< */
direct_link_nlastrips(reader, &ob->nlastrips);
BLO_read_list(reader, &ob->constraintChannels);
- // >>> XXX deprecated - old animation system
+ /* >>> XXX deprecated - old animation system */
BLO_read_pointer_array(reader, (void **)&ob->mat);
BLO_read_data_address(reader, &ob->matbits);
@@ -3925,7 +3951,7 @@ static void direct_link_object(BlendDataReader *reader, Object *ob)
if (ob->soft) {
SoftBody *sb = ob->soft;
- sb->bpoint = NULL; // init pointers so it gets rebuilt nicely
+ sb->bpoint = NULL; /* init pointers so it gets rebuilt nicely */
sb->bspring = NULL;
sb->scratch = NULL;
/* although not used anymore */
@@ -4422,7 +4448,7 @@ static void lib_link_scene(BlendLibReader *reader, Scene *sce)
if (seq->ipo) {
BLO_read_id_address(
- reader, sce->id.lib, &seq->ipo); // XXX deprecated - old animation system
+ reader, sce->id.lib, &seq->ipo); /* XXX deprecated - old animation system */
}
seq->scene_sound = NULL;
if (seq->scene) {
@@ -5113,7 +5139,7 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
}
}
/* we only saved what was used */
- space_outliner->storeflag |= SO_TREESTORE_CLEANUP; // at first draw
+ space_outliner->storeflag |= SO_TREESTORE_CLEANUP; /* at first draw */
}
space_outliner->treehash = NULL;
space_outliner->tree.first = space_outliner->tree.last = NULL;
@@ -5194,9 +5220,6 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
BLO_read_list(reader, &sconsole->scrollback);
BLO_read_list(reader, &sconsole->history);
- // for (cl= sconsole->scrollback.first; cl; cl= cl->next)
- // cl->line= newdataadr(fd, cl->line);
-
/* comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
* from left to right. the right-most expression sets the result of the comma
* expression as a whole*/
@@ -6869,7 +6892,7 @@ static void link_global(FileData *fd, BlendFileData *bfd)
bfd->cur_view_layer = blo_read_get_new_globaldata_address(fd, bfd->cur_view_layer);
bfd->curscreen = newlibadr(fd, NULL, bfd->curscreen);
bfd->curscene = newlibadr(fd, NULL, bfd->curscene);
- // this happens in files older than 2.35
+ /* this happens in files older than 2.35 */
if (bfd->curscene == NULL) {
if (bfd->curscreen) {
bfd->curscene = bfd->curscreen->scene;
@@ -7171,7 +7194,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
IDP_BlendDataRead(reader, &addon->prop);
}
- // XXX
+ /* XXX */
user->uifonts.first = user->uifonts.last = NULL;
BLO_read_list(reader, &user->uistyles);
@@ -7549,7 +7572,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
/* ID has not been read yet, add placeholder to the main of the
* library it belongs to, so that it will be read later. */
read_libblock(fd, libmain, bhead, LIB_TAG_INDIRECT, false, NULL);
- // commented because this can print way too much
+ /* commented because this can print way too much */
// if (G.debug & G_DEBUG) printf("expand_doit: other lib %s\n", lib->filepath);
/* for outliner dependency only */
@@ -7616,7 +7639,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
* and another append happens which invokes same ID...
* in that case the lookup table needs this entry */
oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
- // commented because this can print way too much
+ /* commented because this can print way too much */
// if (G.debug & G_DEBUG) printf("expand: already read %s\n", id->name);
}
}
@@ -7634,7 +7657,7 @@ static void expand_ipo(BlendExpander *expander, Ipo *ipo)
}
}
-// XXX deprecated - old animation system
+/* XXX deprecated - old animation system */
static void expand_constraint_channels(BlendExpander *expander, ListBase *chanbase)
{
LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
@@ -7762,7 +7785,7 @@ static void expand_constraints(BlendExpander *expander, ListBase *lb)
/* deprecated manual expansion stuff */
LISTBASE_FOREACH (bConstraint *, curcon, lb) {
if (curcon->ipo) {
- BLO_expand(expander, curcon->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, curcon->ipo); /* XXX deprecated - old animation system */
}
}
}
@@ -7814,7 +7837,7 @@ static void expand_object(BlendExpander *expander, Object *ob)
BLO_expand(expander, ob->gpd);
- // XXX deprecated - old animation system (for version patching only)
+ /* XXX deprecated - old animation system (for version patching only) */
BLO_expand(expander, ob->ipo);
BLO_expand(expander, ob->action);
@@ -7825,7 +7848,7 @@ static void expand_object(BlendExpander *expander, Object *ob)
BLO_expand(expander, strip->act);
BLO_expand(expander, strip->ipo);
}
- // XXX deprecated - old animation system (for version patching only)
+ /* XXX deprecated - old animation system (for version patching only) */
for (int a = 0; a < ob->totcol; a++) {
BLO_expand(expander, ob->mat[a]);
@@ -8049,7 +8072,7 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
expand_collection(&expander, (Collection *)id);
break;
case ID_IP:
- expand_ipo(&expander, (Ipo *)id); // XXX deprecated - old animation system
+ expand_ipo(&expander, (Ipo *)id); /* XXX deprecated - old animation system */
break;
case ID_PA:
expand_particlesettings(&expander, (ParticleSettings *)id);
@@ -8120,7 +8143,7 @@ static void add_loose_objects_to_scene(Main *mainvar,
if (ob->id.us == 0) {
do_it = true;
}
- else if ((ob->id.lib == lib) && (object_in_any_collection(bmain, ob) == 0)) {
+ else if ((ob->id.lib == lib) && !object_in_any_collection(bmain, ob)) {
/* When appending, make sure any indirectly loaded object gets a base,
* when they are not part of any collection yet. */
do_it = true;
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index dad86f80813..5046ee6aab1 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -23,7 +23,7 @@
#else
# include "BLI_winstuff.h"
# include "winsock2.h"
-# include <io.h> // for open close read
+# include <io.h> /* for open close read */
# include <zlib.h> /* odd include order-issue */
#endif
@@ -65,7 +65,7 @@
#include "BKE_anim_visualization.h"
#include "BKE_armature.h"
#include "BKE_colortools.h"
-#include "BKE_global.h" // for G
+#include "BKE_global.h" /* for G */
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_modifier.h"
@@ -113,7 +113,7 @@ static void area_add_header_region(ScrArea *area, ListBase *lb)
static void sequencer_init_preview_region(ARegion *region)
{
- // XXX a bit ugly still, copied from space_sequencer
+ /* XXX a bit ugly still, copied from space_sequencer */
/* NOTE: if you change values here, also change them in space_sequencer.c, sequencer_new */
region->regiontype = RGN_TYPE_PREVIEW;
region->alignment = RGN_ALIGN_TOP;
@@ -781,7 +781,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 1)) {
Object *ob;
Tex *tex;
Scene *sce;
@@ -849,7 +849,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 2)) {
Object *ob;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
@@ -859,7 +859,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 4)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 4)) {
Scene *sce;
Object *ob;
ParticleSettings *part;
@@ -951,7 +951,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 6)) {
Object *ob;
/* New variables for axis-angle rotations and/or quaternion rotations were added,
@@ -973,7 +973,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 7)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 7)) {
Mesh *me;
Nurb *nu;
Lattice *lt;
@@ -1041,7 +1041,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 8)) {
{
Scene *sce = bmain->scenes.first;
while (sce) {
@@ -1139,7 +1139,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 9)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 9)) {
Scene *sce;
Mesh *me;
Object *ob;
@@ -1169,7 +1169,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 10)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 10)) {
Object *ob;
/* properly initialize hair clothsim data on old files */
@@ -1225,7 +1225,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 11)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 11)) {
{
/* fix for new view type in sequencer */
bScreen *screen;
@@ -1271,7 +1271,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 12)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 12)) {
Object *ob;
Brush *brush;
@@ -1333,7 +1333,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 13)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 13)) {
/* NOTE: if you do more conversion, be sure to do it outside of this and
* increase subversion again, otherwise it will not be correct */
Object *ob;
@@ -1359,7 +1359,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 14)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 14)) {
/* fix for bad View2D extents for Animation Editors */
bScreen *screen;
ScrArea *area;
@@ -1391,7 +1391,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 17)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 250, 17)) {
Scene *sce;
Sequence *seq;
@@ -1482,7 +1482,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 252, 1)) {
Brush *brush;
Object *ob;
Scene *scene;
@@ -1540,7 +1540,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
/* old-track -> constraints (this time we're really doing it!) */
- if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 252, 2)) {
Object *ob;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
@@ -1548,7 +1548,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 252, 5)) {
bScreen *screen;
/* Image editor scopes */
@@ -1745,7 +1745,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
/* New Settings */
- if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 252, 5)) {
brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space
/* spacing was originally in pixels, convert it to percentage for new version
@@ -1786,7 +1786,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 253 || (bmain->versionfile == 253 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 253, 1)) {
Object *ob;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
@@ -1832,7 +1832,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 255, 1)) {
Brush *br;
ParticleSettings *part;
bScreen *screen;
@@ -1881,7 +1881,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 255, 3)) {
Object *ob;
/* ocean res is now squared, reset old ones - will be massive */
@@ -1934,7 +1934,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 256, 1)) {
/* fix for bones that didn't have arm_roll before */
bArmature *arm;
Bone *bone;
@@ -1958,7 +1958,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 256, 2)) {
bNodeTree *ntree;
bNode *node;
bNodeSocket *sock, *gsock;
@@ -2041,7 +2041,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 256, 3)) {
bScreen *screen;
Brush *brush;
Object *ob;
@@ -2086,7 +2086,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
if (0) {
- if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 256, 6)) {
for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
/* Vertex normal calculation from legacy 'MFace' has been removed.
* update after calculating polygons in file reading code instead. */
@@ -2094,7 +2094,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 256, 2)) {
/* update blur area sizes from 0..1 range to 0..100 percentage */
Scene *scene;
bNode *node;
@@ -2111,7 +2111,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 258, 1)) {
/* screen view2d settings were not properly initialized T27164.
* v2d->scroll caused the bug but best reset other values too
* which are in old blend files only.
@@ -2158,7 +2158,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 259, 1)) {
{
Scene *scene;
Sequence *seq;
@@ -2247,7 +2247,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 259, 2)) {
{
/* Convert default socket values from bNodeStack */
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
@@ -2288,7 +2288,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 4)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 259, 4)) {
{
/* Adaptive time step for particle systems */
ParticleSettings *part;
@@ -2339,7 +2339,7 @@ static void lib_node_do_versions_group_indices(bNode *gnode)
void do_versions_after_linking_250(Main *bmain)
{
- if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 256, 2)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
/* updates external links for all group nodes in a tree */
bNode *node;
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 3abac65a4df..a7c5d7b933c 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -54,15 +54,15 @@
#include "BKE_anim_visualization.h"
#include "BKE_image.h"
-#include "BKE_main.h" // for Main
-#include "BKE_mesh.h" // for ME_ defines (patching)
+#include "BKE_main.h" /* for Main */
+#include "BKE_mesh.h" /* for ME_ defines (patching) */
#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_sequencer.h"
-#include "BKE_text.h" // for txt_extended_ascii_as_utf8
+#include "BKE_text.h" /* for txt_extended_ascii_as_utf8 */
#include "BKE_texture.h"
#include "BKE_tracking.h"
@@ -70,7 +70,7 @@
# include "BKE_writeffmpeg.h"
#endif
-#include "IMB_imbuf.h" // for proxy / timecode versioning stuff
+#include "IMB_imbuf.h" /* for proxy / timecode versioning stuff */
#include "NOD_common.h"
#include "NOD_texture.h"
@@ -700,7 +700,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 260, 1)) {
Object *ob;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
@@ -721,7 +721,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 260, 2)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
bNode *node;
@@ -740,7 +740,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_END;
}
- if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 4)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 260, 4)) {
{
/* Convert node angles to radians! */
Scene *sce;
@@ -830,7 +830,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 260, 6)) {
Scene *sce;
MovieClip *clip;
@@ -880,7 +880,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 8)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 260, 8)) {
Brush *brush;
for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
@@ -890,7 +890,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 261, 1)) {
{
/* update use flags for node sockets (was only temporary before) */
Scene *sce;
@@ -975,7 +975,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 261, 2)) {
{
/* convert deprecated sculpt_paint_unified_* fields to
* UnifiedPaintSettings */
@@ -991,7 +991,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 261, 3)) {
{
/* convert extended ascii to utf-8 for text editor */
Text *text;
@@ -1068,7 +1068,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 262, 1)) {
/* update use flags for node sockets (was only temporary before) */
Scene *sce;
bNodeTree *ntree;
@@ -1095,7 +1095,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 262, 2)) {
/* Set new idname of keyingsets from their now "label-only" name. */
Scene *scene;
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
@@ -1108,7 +1108,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 262, 3)) {
Object *ob;
ModifierData *md;
@@ -1122,7 +1122,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 4)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 262, 4)) {
/* Read Viscosity presets from older files */
Object *ob;
@@ -1152,7 +1152,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 1)) {
/* file output node paths are now stored in the file info struct instead socket name */
Scene *sce;
bNodeTree *ntree;
@@ -1167,7 +1167,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 3)) {
Scene *scene;
Brush *brush;
@@ -1188,7 +1188,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 2)) {
bScreen *screen;
for (screen = bmain->screens.first; screen; screen = screen->id.next) {
@@ -1223,7 +1223,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 4)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 4)) {
Camera *cam;
Curve *cu;
@@ -1242,7 +1242,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 5)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 5)) {
{
/* file output node paths are now stored in the file info struct instead socket name */
Scene *sce;
@@ -1261,7 +1261,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 6)) {
/* update use flags for node sockets (was only temporary before) */
Scene *sce;
Material *mat;
@@ -1304,7 +1304,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 7)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 7)) {
Object *ob;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
@@ -1322,7 +1322,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 9)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 9)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
bNode *node;
@@ -1340,10 +1340,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_END;
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 10)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 10)) {
{
Scene *scene;
- // composite redesign
+ /* composite redesign */
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
if (scene->nodetree) {
if (scene->nodetree->chunksize == 0) {
@@ -1399,7 +1399,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 11)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 11)) {
MovieClip *clip;
for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
@@ -1414,7 +1414,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 13)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 13)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
@@ -1432,7 +1432,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_END;
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 14)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 14)) {
ParticleSettings *part;
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
@@ -1461,7 +1461,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 17)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 17)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
@@ -1482,7 +1482,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_END;
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 18)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 18)) {
Scene *scene;
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
@@ -1518,7 +1518,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
/* color management pipeline changes compatibility code */
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 19)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 19)) {
Scene *scene;
Image *ima;
bool colormanagement_disabled = false;
@@ -1556,14 +1556,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 20)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 20)) {
Key *key;
for (key = bmain->shapekeys.first; key; key = key->id.next) {
blo_do_versions_key_uidgen(key);
}
}
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 21)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 263, 21)) {
{
Mesh *me;
for (me = bmain->meshes.first; me; me = me->id.next) {
@@ -1589,7 +1589,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 264, 1)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
bNode *node;
@@ -1603,7 +1603,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_END;
}
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 264, 2)) {
MovieClip *clip;
for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
@@ -1620,7 +1620,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 264, 3)) {
/* smoke branch */
{
Object *ob;
@@ -1683,7 +1683,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 5)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 264, 5)) {
/* set a unwrapping margin and ABF by default */
Scene *scene;
@@ -1695,7 +1695,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 264, 6)) {
/* Fix for bug T32982, internal_links list could get corrupted from r51630 onward.
* Simply remove bad internal_links lists to avoid NULL pointers.
*/
@@ -1715,7 +1715,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_END;
}
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 264, 7)) {
/* convert tiles size from resolution and number of tiles */
{
Scene *scene;
@@ -1739,7 +1739,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 264, 7)) {
MovieClip *clip;
for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
@@ -1758,7 +1758,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 265, 3)) {
bScreen *screen;
for (screen = bmain->screens.first; screen; screen = screen->id.next) {
ScrArea *area;
@@ -1797,7 +1797,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 5)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 265, 5)) {
Scene *scene;
Tex *tex;
@@ -1858,7 +1858,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
FOREACH_NODETREE_END;
}
- else if (bmain->versionfile < 266 || (bmain->versionfile == 266 && bmain->subversionfile < 1)) {
+ else if (!MAIN_VERSION_ATLEAST(bmain, 266, 1)) {
/* texture use alpha was removed for 2.66 but added back again for 2.66a,
* for compatibility all textures assumed it to be enabled */
Tex *tex;
@@ -1870,7 +1870,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 7)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 265, 7)) {
Curve *cu;
for (cu = bmain->curves.first; cu; cu = cu->id.next) {
@@ -1905,14 +1905,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (MAIN_VERSION_OLDER(bmain, 265, 9)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 265, 9)) {
Mesh *me;
for (me = bmain->meshes.first; me; me = me->id.next) {
BKE_mesh_do_versions_cd_flag_init(me);
}
}
- if (MAIN_VERSION_OLDER(bmain, 265, 10)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 265, 10)) {
Brush *br;
for (br = bmain->brushes.first; br; br = br->id.next) {
if (br->ob_mode & OB_MODE_TEXTURE_PAINT) {
@@ -1921,8 +1921,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- // add storage for compositor translate nodes when not existing
- if (MAIN_VERSION_OLDER(bmain, 265, 11)) {
+ /* add storage for compositor translate nodes when not existing */
+ if (!MAIN_VERSION_ATLEAST(bmain, 265, 11)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
@@ -1936,14 +1936,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_END;
}
- if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 266, 2)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
do_versions_nodetree_customnodes(ntree, ((ID *)ntree == id));
}
FOREACH_NODETREE_END;
}
- if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 266, 2)) {
bScreen *screen;
for (screen = bmain->screens.first; screen; screen = screen->id.next) {
ScrArea *area;
@@ -1977,7 +1977,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (MAIN_VERSION_OLDER(bmain, 266, 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 266, 3)) {
{
/* Fix for a very old issue:
* Node names were nominally made unique in r24478 (2.50.8), but the do_versions check
@@ -2152,7 +2152,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (MAIN_VERSION_OLDER(bmain, 267, 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 267, 1)) {
Object *ob;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index ad6066647d6..c44e9b5efff 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -978,7 +978,7 @@ static void do_version_curvemapping_walker(Main *bmain, void (*callback)(CurveMa
}
}
- // toolsettings
+ /* toolsettings */
ToolSettings *ts = scene->toolsettings;
if (ts->vpaint) {
callback(ts->vpaint->paint.cavity_curve);
@@ -1201,7 +1201,7 @@ static void do_version_fcurve_hide_viewport_fix(struct ID *UNUSED(id),
struct FCurve *fcu,
void *UNUSED(user_data))
{
- if (!STREQ(fcu->rna_path, "hide")) {
+ if (fcu->rna_path == NULL || !STREQ(fcu->rna_path, "hide")) {
return;
}
@@ -1665,7 +1665,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
BKE_mesh_tessface_clear(me);
/* Moved from do_versions because we need updated polygons for calculating normals. */
- if (MAIN_VERSION_OLDER(bmain, 256, 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 256, 6)) {
BKE_mesh_calc_normals(me);
}
}
@@ -2988,9 +2988,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* gpencil grid settings */
for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- ARRAY_SET_ITEMS(gpd->grid.color, 0.5f, 0.5f, 0.5f); // Color
- ARRAY_SET_ITEMS(gpd->grid.scale, 1.0f, 1.0f); // Scale
- gpd->grid.lines = GP_DEFAULT_GRID_LINES; // Number of lines
+ ARRAY_SET_ITEMS(gpd->grid.color, 0.5f, 0.5f, 0.5f); /* Color */
+ ARRAY_SET_ITEMS(gpd->grid.scale, 1.0f, 1.0f); /* Scale */
+ gpd->grid.lines = GP_DEFAULT_GRID_LINES; /* Number of lines */
}
}
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 862cfbf6c45..0d8b097b32a 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -20,6 +20,7 @@
/* allow readfile to use deprecated functionality */
#define DNA_DEPRECATED_ALLOW
+#include "BLI_alloca.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
@@ -37,12 +38,14 @@
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
+#include "DNA_particle_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_screen_types.h"
#include "DNA_shader_fx_types.h"
#include "DNA_workspace_types.h"
+#include "BKE_animsys.h"
#include "BKE_collection.h"
#include "BKE_colortools.h"
#include "BKE_gpencil.h"
@@ -229,6 +232,48 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 291, 8)) {
+ /**
+ * Make sure Emission Alpha fcurve and drivers is properly mapped after the Emission Strength
+ * got introduced.
+ * */
+
+ /**
+ * Effectively we are replacing the (animation of) node socket input 18 with 19.
+ * Emission Strength is the new socket input 18, pushing Emission Alpha to input 19.
+ *
+ * To play safe we move all the inputs beyond 18 to their rightful new place.
+ * In case users are doing unexpected things with not-really supported keyframeable channels.
+ *
+ * The for loop for the input ids is at the top level otherwise we loose the animation
+ * keyframe data.
+ * */
+ for (int input_id = 21; input_id >= 18; input_id--) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_SHADER) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
+ if (node->type != SH_NODE_BSDF_PRINCIPLED) {
+ continue;
+ }
+
+ const size_t node_name_length = strlen(node->name);
+ const size_t node_name_escaped_max_length = (node_name_length * 2);
+ char *node_name_escaped = MEM_mallocN(node_name_escaped_max_length + 1,
+ "escaped name");
+ BLI_strescape(node_name_escaped, node->name, node_name_escaped_max_length);
+ char *rna_path_prefix = BLI_sprintfN("nodes[\"%s\"].inputs", node_name_escaped);
+
+ BKE_animdata_fix_paths_rename_all_ex(
+ bmain, id, rna_path_prefix, NULL, NULL, input_id, input_id + 1, false);
+ MEM_freeN(rna_path_prefix);
+ MEM_freeN(node_name_escaped);
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
@@ -769,32 +814,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- /**
- * Versioning code until next subversion bump goes here.
- *
- * \note Be sure to check when bumping the version:
- * - "versioning_userdef.c", #blo_do_versions_userdef
- * - "versioning_userdef.c", #do_versions_theme
- *
- * \note Keep this message at the bottom of the function.
- */
- {
- /* Keep this block, even when empty. */
-
- /* Move to storing expansion for all panels of FModifiers. */
- LISTBASE_FOREACH (bAction *, act, &bmain->actions) {
- LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {
- LISTBASE_FOREACH (FModifier *, fcm, &fcu->modifiers) {
- if (fcm->flag & FMODIFIER_FLAG_EXPANDED_DEPRECATED) {
- fcm->ui_expand_flag = 1;
- }
- else {
- fcm->ui_expand_flag = 0;
- }
- }
- }
- }
-
+ if (!MAIN_VERSION_ATLEAST(bmain, 291, 8)) {
if (!DNA_struct_elem_find(fd->filesdna, "WorkSpaceDataRelation", "int", "parentid")) {
LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) {
LISTBASE_FOREACH_MUTABLE (
@@ -835,5 +855,39 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+ /* Ensure that particle systems generated by fluid modifier have correct phystype. */
+ LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) {
+ if ELEM (part->type, PART_FLUID_FLIP, PART_FLUID_SPRAY, PART_FLUID_BUBBLE, PART_FLUID_FOAM) {
+ part->phystype = PART_PHYS_NO;
+ }
+ }
}
-}
+
+ /**
+ * Versioning code until next subversion bump goes here.
+ *
+ * \note Be sure to check when bumping the version:
+ * - "versioning_userdef.c", #blo_do_versions_userdef
+ * - "versioning_userdef.c", #do_versions_theme
+ *
+ * \note Keep this message at the bottom of the function.
+ */
+ {
+ /* Keep this block, even when empty. */
+
+ /* Move to storing expansion for all panels of FModifiers. */
+ LISTBASE_FOREACH (bAction *, act, &bmain->actions) {
+ LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {
+ LISTBASE_FOREACH (FModifier *, fcm, &fcu->modifiers) {
+ if (fcm->flag & FMODIFIER_FLAG_EXPANDED_DEPRECATED) {
+ fcm->ui_expand_flag = 1;
+ }
+ else {
+ fcm->ui_expand_flag = 0;
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 58d57f12b8f..666806479b2 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -24,11 +24,11 @@
#include <limits.h>
#ifndef WIN32
-# include <unistd.h> // for read close
+# include <unistd.h> /* for read close */
#else
# include "BLI_winstuff.h"
# include "winsock2.h"
-# include <io.h> // for open close read
+# include <io.h> /* for open close read */
# include <zlib.h> /* odd include order-issue */
#endif
@@ -72,8 +72,8 @@
#include "BKE_deform.h"
#include "BKE_fcurve.h"
#include "BKE_lattice.h"
-#include "BKE_main.h" // for Main
-#include "BKE_mesh.h" // for ME_ defines (patching)
+#include "BKE_main.h" /* for Main */
+#include "BKE_mesh.h" /* for ME_ defines (patching) */
#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
@@ -886,7 +886,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- sce->r.stereomode = 1; // no stereo
+ sce->r.stereomode = 1; /* no stereo */
}
/* some oldfile patch, moved from set_func_space */
@@ -2150,7 +2150,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 245, 2)) {
Image *ima;
/* initialize 1:1 Aspect */
@@ -2159,7 +2159,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 4)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 245, 4)) {
bArmature *arm;
ModifierData *md;
Object *ob;
@@ -2177,7 +2177,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 5)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 245, 5)) {
/* foreground color needs to be something other then black */
Scene *sce;
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
@@ -2187,7 +2187,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 245, 6)) {
Scene *sce;
/* fix frs_sec_base */
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
@@ -2197,7 +2197,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 7)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 245, 7)) {
Object *ob;
bPoseChannel *pchan;
@@ -2227,7 +2227,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 8)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 245, 8)) {
Scene *sce;
Object *ob;
PartEff *paf = NULL;
@@ -2394,7 +2394,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 10)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 245, 10)) {
Object *ob;
/* dupliface scale */
@@ -2403,7 +2403,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 245, 11)) {
Object *ob;
bActionStrip *strip;
@@ -2437,7 +2437,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 14)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 245, 14)) {
Scene *sce;
Sequence *seq;
@@ -2452,7 +2452,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
/* fix broken group lengths in id properties */
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 15)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 245, 15)) {
idproperties_fix_group_lengths(bmain->scenes);
idproperties_fix_group_lengths(bmain->libraries);
idproperties_fix_group_lengths(bmain->objects);
@@ -2481,7 +2481,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
/* convert fluids to modifier */
- if (bmain->versionfile < 246 || (bmain->versionfile == 246 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 246, 1)) {
Object *ob;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
@@ -2502,7 +2502,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 246 || (bmain->versionfile == 246 && bmain->subversionfile < 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 246, 1)) {
Object *ob;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->pd && (ob->pd->forcefield == PFIELD_WIND)) {
@@ -2512,7 +2512,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
/* set the curve radius interpolation to 2.47 default - easy */
- if (bmain->versionfile < 247 || (bmain->versionfile == 247 && bmain->subversionfile < 6)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 247, 6)) {
Curve *cu;
Nurb *nu;
@@ -2532,7 +2532,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 2)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 248, 2)) {
Scene *sce;
/* Note, these will need to be added for painting */
@@ -2542,7 +2542,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 3)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 248, 3)) {
bScreen *screen;
/* adjust default settings for Animation Editors */
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 74a4ddfd8f3..a37ec2d9f0a 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -125,7 +125,7 @@
#include "BLI_bitmap.h"
#include "BLI_blenlib.h"
#include "BLI_mempool.h"
-#include "MEM_guardedalloc.h" // MEM_freeN
+#include "MEM_guardedalloc.h" /* MEM_freeN */
#include "BKE_action.h"
#include "BKE_anim_data.h"
@@ -140,7 +140,7 @@
#include "BKE_deform.h"
#include "BKE_fcurve.h"
#include "BKE_fcurve_driver.h"
-#include "BKE_global.h" // for G
+#include "BKE_global.h" /* for G */
#include "BKE_gpencil_modifier.h"
#include "BKE_icons.h"
#include "BKE_idprop.h"
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index 81494b03558..4c70be65bef 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -606,6 +606,47 @@ void BM_mesh_copy_init_customdata(BMesh *bm_dst, BMesh *bm_src, const BMAllocTem
CustomData_bmesh_init_pool(&bm_dst->pdata, allocsize->totface, BM_FACE);
}
+/**
+ * Similar to #BM_mesh_copy_init_customdata but copies all layers ignoring
+ * flags like #CD_FLAG_NOCOPY.
+ *
+ * \param bm_dst: BMesh whose custom-data layers will be added.
+ * \param bm_src: BMesh whose custom-data layers will be copied.
+ * \param htype: Specifies which custom-data layers will be initiated.
+ * \param allocsize: Initialize the the memory-pool before use (may be an estimate).
+ */
+void BM_mesh_copy_init_customdata_all_layers(BMesh *bm_dst,
+ BMesh *bm_src,
+ const char htype,
+ const BMAllocTemplate *allocsize)
+{
+ if (allocsize == NULL) {
+ allocsize = &bm_mesh_allocsize_default;
+ }
+
+ const char htypes[4] = {BM_VERT, BM_EDGE, BM_LOOP, BM_FACE};
+ BLI_assert(((&bm_dst->vdata + 1) == &bm_dst->edata) &&
+ ((&bm_dst->vdata + 2) == &bm_dst->ldata) && ((&bm_dst->vdata + 3) == &bm_dst->pdata));
+
+ BLI_assert(((&allocsize->totvert + 1) == &allocsize->totedge) &&
+ ((&allocsize->totvert + 2) == &allocsize->totloop) &&
+ ((&allocsize->totvert + 3) == &allocsize->totface));
+
+ for (int i = 0; i < 4; i++) {
+ if (!(htypes[i] & htype)) {
+ continue;
+ }
+ CustomData *dst = &bm_dst->vdata + i;
+ CustomData *src = &bm_src->vdata + i;
+ const int size = *(&allocsize->totvert + i);
+
+ for (int l = 0; l < src->totlayer; l++) {
+ CustomData_add_layer(dst, src->layers[l].type, CD_CALLOC, NULL, 0);
+ }
+ CustomData_bmesh_init_pool(dst, size, htypes[i]);
+ }
+}
+
BMesh *BM_mesh_copy(BMesh *bm_old)
{
BMesh *bm_new;
diff --git a/source/blender/bmesh/intern/bmesh_construct.h b/source/blender/bmesh/intern/bmesh_construct.h
index 3523c4aec1a..f5102283ede 100644
--- a/source/blender/bmesh/intern/bmesh_construct.h
+++ b/source/blender/bmesh/intern/bmesh_construct.h
@@ -69,6 +69,10 @@ void BM_elem_select_copy(BMesh *bm_dst, void *ele_dst_v, const void *ele_src_v);
void BM_mesh_copy_init_customdata(BMesh *bm_dst,
BMesh *bm_src,
const struct BMAllocTemplate *allocsize);
+void BM_mesh_copy_init_customdata_all_layers(BMesh *bm_dst,
+ BMesh *bm_src,
+ const char htype,
+ const struct BMAllocTemplate *allocsize);
BMesh *BM_mesh_copy(BMesh *bm_old);
char BM_face_flag_from_mflag(const char mflag);
diff --git a/source/blender/bmesh/operators/bmo_edgenet.c b/source/blender/bmesh/operators/bmo_edgenet.c
index 3ce84dff921..0f6ef1cb019 100644
--- a/source/blender/bmesh/operators/bmo_edgenet.c
+++ b/source/blender/bmesh/operators/bmo_edgenet.c
@@ -52,7 +52,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
BMO_slot_buffer_hflag_enable(bm, op->slots_in, "edges", BM_EDGE, BM_ELEM_TAG, false);
BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, false);
- BM_mesh_edgenet(bm, true, true); // TODO, sides
+ BM_mesh_edgenet(bm, true, true); /* TODO, sides */
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index b9c9aa3aec8..f45457085dc 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -1149,6 +1149,112 @@ static bool point_between_edges(
return (ang11 - ang1co > -BEVEL_EPSILON_ANG);
}
+/* Is the angle swept from e1 to e2, CCW when viewed from the normal side of f,
+ * not a reflex angle or a straight angle? Assume e1 and e2 share a vert. */
+static bool edge_edge_angle_less_than_180(const BMEdge *e1, const BMEdge *e2, const BMFace *f)
+{
+ float dir1[3], dir2[3], cross[3];
+ BLI_assert(f != NULL);
+ BMVert *v, *v1, *v2;
+ if (e1->v1 == e2->v1) {
+ v = e1->v1;
+ v1 = e1->v2;
+ v2 = e2->v2;
+ }
+ else if (e1->v1 == e2->v2) {
+ v = e1->v1;
+ v1 = e1->v2;
+ v2 = e2->v1;
+ }
+ else if (e1->v2 == e2->v1) {
+ v = e1->v2;
+ v1 = e1->v1;
+ v2 = e2->v2;
+ }
+ else if (e1->v2 == e2->v2) {
+ v = e1->v2;
+ v1 = e1->v1;
+ v2 = e2->v1;
+ }
+ else {
+ BLI_assert(false);
+ }
+ sub_v3_v3v3(dir1, v1->co, v->co);
+ sub_v3_v3v3(dir2, v2->co, v->co);
+ cross_v3_v3v3(cross, dir1, dir2);
+ return dot_v3v3(cross, f->no) > 0.0f;
+}
+
+/* When the offset_type is BEVEL_AMT_PERCENT or BEVEL_AMT_ABSOLUTE, fill in the coordinates
+ * of the lines whose intersection defines the boundary point between e1 and e2 with common
+ * vert v, as defined in the parameters of offset_meet.
+ */
+static void offset_meet_lines_percent_or_absolute(BevelParams *bp,
+ EdgeHalf *e1,
+ EdgeHalf *e2,
+ BMVert *v,
+ float r_l1a[3],
+ float r_l1b[3],
+ float r_l2a[3],
+ float r_l2b[3])
+{
+ /* Get points the specified distance along each leg.
+ * Note: not all BevVerts and EdgeHalfs have been made yet, so we have
+ * to find required edges by moving around faces and use fake EdgeHalfs for
+ * some of the edges. If there aren't faces to move around, we have to give up.
+ * The legs we need are:
+ * e0 : the next edge around e1->fnext (==f1) after e1.
+ * e3 : the prev edge around e2->fprev (==f2) before e2.
+ * e4 : the previous edge around f1 before e1 (may be e2).
+ * e5 : the next edge around f2 after e2 (may be e1).
+ */
+ BMVert *v1, *v2;
+ EdgeHalf e0, e3, e4, e5;
+ BMFace *f1, *f2;
+ float d0, d3, d4, d5;
+ v1 = BM_edge_other_vert(e1->e, v);
+ v2 = BM_edge_other_vert(e2->e, v);
+ f1 = e1->fnext;
+ f2 = e2->fprev;
+ bool no_offsets = f1 == NULL || f2 == NULL;
+ if (!no_offsets) {
+ BMLoop *l = BM_face_vert_share_loop(f1, v1);
+ e0.e = l->e;
+ l = BM_face_vert_share_loop(f2, v2);
+ e3.e = l->prev->e;
+ l = BM_face_vert_share_loop(f1, v);
+ e4.e = l->prev->e;
+ l = BM_face_vert_share_loop(f2, v);
+ e5.e = l->e;
+ /* All the legs must be visible from their opposite legs. */
+ no_offsets = !edge_edge_angle_less_than_180(e0.e, e1->e, f1) ||
+ !edge_edge_angle_less_than_180(e1->e, e4.e, f1) ||
+ !edge_edge_angle_less_than_180(e2->e, e3.e, f2) ||
+ !edge_edge_angle_less_than_180(e5.e, e2->e, f1);
+ if (!no_offsets) {
+ if (bp->offset_type == BEVEL_AMT_ABSOLUTE) {
+ d0 = d3 = d4 = d5 = bp->offset;
+ }
+ else {
+ d0 = bp->offset * BM_edge_calc_length(e0.e) / 100.0f;
+ d3 = bp->offset * BM_edge_calc_length(e3.e) / 100.0f;
+ d4 = bp->offset * BM_edge_calc_length(e4.e) / 100.0f;
+ d5 = bp->offset * BM_edge_calc_length(e5.e) / 100.0f;
+ }
+ slide_dist(&e4, v, d4, r_l1a);
+ slide_dist(&e0, v1, d0, r_l1b);
+ slide_dist(&e5, v, d5, r_l2a);
+ slide_dist(&e3, v2, d3, r_l2b);
+ }
+ }
+ if (no_offsets) {
+ copy_v3_v3(r_l1a, v->co);
+ copy_v3_v3(r_l1b, v1->co);
+ copy_v3_v3(r_l2a, v->co);
+ copy_v3_v3(r_l2b, v2->co);
+ }
+}
+
/**
* Calculate the meeting point between the offset edges for e1 and e2, putting answer in meetco.
* e1 and e2 share vertex v and face f (may be NULL) and viewed from the normal side of
@@ -1167,7 +1273,8 @@ static bool point_between_edges(
* \param e_in_plane: If we need to drop from the calculated offset lines to one of the faces,
* we don't want to drop onto the 'in plane' face, so if this is not null skip this edge's faces.
*/
-static void offset_meet(EdgeHalf *e1,
+static void offset_meet(BevelParams *bp,
+ EdgeHalf *e1,
EdgeHalf *e2,
BMVert *v,
BMFace *f,
@@ -1273,14 +1380,19 @@ static void offset_meet(EdgeHalf *e1,
normalize_v3(norm_perp1);
normalize_v3(norm_perp2);
- /* Get points that are offset distances from each line, then another point on each line. */
float off1a[3], off1b[3], off2a[3], off2b[3];
- copy_v3_v3(off1a, v->co);
- madd_v3_v3fl(off1a, norm_perp1, e1->offset_r);
- add_v3_v3v3(off1b, off1a, dir1);
- copy_v3_v3(off2a, v->co);
- madd_v3_v3fl(off2a, norm_perp2, e2->offset_l);
- add_v3_v3v3(off2b, off2a, dir2);
+ if (bp->offset_type == BEVEL_AMT_PERCENT || bp->offset_type == BEVEL_AMT_ABSOLUTE) {
+ offset_meet_lines_percent_or_absolute(bp, e1, e2, v, off1a, off1b, off2a, off2b);
+ }
+ else {
+ /* Get points that are offset distances from each line, then another point on each line. */
+ copy_v3_v3(off1a, v->co);
+ madd_v3_v3fl(off1a, norm_perp1, e1->offset_r);
+ add_v3_v3v3(off1b, off1a, dir1);
+ copy_v3_v3(off2a, v->co);
+ madd_v3_v3fl(off2a, norm_perp2, e2->offset_l);
+ add_v3_v3v3(off2b, off2a, dir2);
+ }
/* Intersect the offset lines. */
float isect2[3];
@@ -2554,7 +2666,9 @@ static void build_boundary_terminal_edge(BevelParams *bp,
EdgeHalf *e = efirst;
float co[3];
if (bv->edgecount == 2) {
- /* Only 2 edges in, so terminate the edge with an artificial vertex on the unbeveled edge. */
+ /* Only 2 edges in, so terminate the edge with an artificial vertex on the unbeveled edge.
+ * If the offset type is BEVEL_AMT_PERCENT or BEVEL_AMT_ABSOLUTE, what to do is a bit
+ * undefined (there aren't two "legs"), so just let the code do what it does. */
const float *no = e->fprev ? e->fprev->no : (e->fnext ? e->fnext->no : NULL);
offset_in_plane(e, no, true, co);
if (construct) {
@@ -2592,7 +2706,13 @@ static void build_boundary_terminal_edge(BevelParams *bp,
* edge to make a poly or adj mesh, because e->prev has offset 0, offset_meet will put co on
* that edge. */
/* TODO: should do something else if angle between e and e->prev > 180 */
- offset_meet(e->prev, e, bv->v, e->fprev, false, co, NULL);
+ bool leg_slide = bp->offset_type == BEVEL_AMT_PERCENT || bp->offset_type == BEVEL_AMT_ABSOLUTE;
+ if (leg_slide) {
+ slide_dist(e->prev, bv->v, e->offset_l, co);
+ }
+ else {
+ offset_meet(bp, e->prev, e, bv->v, e->fprev, false, co, NULL);
+ }
if (construct) {
BoundVert *bndv = add_new_bound_vert(mem_arena, vm, co);
bndv->efirst = e->prev;
@@ -2604,7 +2724,12 @@ static void build_boundary_terminal_edge(BevelParams *bp,
adjust_bound_vert(e->leftv, co);
}
e = e->next;
- offset_meet(e->prev, e, bv->v, e->fprev, false, co, NULL);
+ if (leg_slide) {
+ slide_dist(e, bv->v, e->prev->offset_r, co);
+ }
+ else {
+ offset_meet(bp, e->prev, e, bv->v, e->fprev, false, co, NULL);
+ }
if (construct) {
BoundVert *bndv = add_new_bound_vert(mem_arena, vm, co);
bndv->efirst = e->prev;
@@ -2823,7 +2948,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
float r, co[3];
if (in_plane == 0 && not_in_plane == 0) {
- offset_meet(e, e2, bv->v, e->fnext, false, co, NULL);
+ offset_meet(bp, e, e2, bv->v, e->fnext, false, co, NULL);
}
else if (not_in_plane > 0) {
if (bp->loop_slide && not_in_plane == 1 && good_offset_on_edge_between(e, e2, enip, bv->v)) {
@@ -2832,7 +2957,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
}
}
else {
- offset_meet(e, e2, bv->v, NULL, true, co, eip);
+ offset_meet(bp, e, e2, bv->v, NULL, true, co, eip);
}
}
else {
@@ -2843,7 +2968,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
}
}
else {
- offset_meet(e, e2, bv->v, e->fnext, true, co, eip);
+ offset_meet(bp, e, e2, bv->v, e->fnext, true, co, eip);
}
}
@@ -6040,27 +6165,21 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
break;
}
case BEVEL_AMT_PERCENT: {
- /* Offset needs to meet adjacent edges at percentage of their lengths. */
- BMVert *v1 = BM_edge_other_vert(e->prev->e, v);
- BMVert *v2 = BM_edge_other_vert(e->e, v);
- float z = sinf(angle_v3v3v3(v1->co, v->co, v2->co));
- e->offset_l_spec = BM_edge_calc_length(e->prev->e) * bp->offset * z / 100.0f;
- v1 = BM_edge_other_vert(e->e, v);
- v2 = BM_edge_other_vert(e->next->e, v);
- z = sinf(angle_v3v3v3(v1->co, v->co, v2->co));
- e->offset_r_spec = BM_edge_calc_length(e->next->e) * bp->offset * z / 100.0f;
+ /* Offset needs to meet adjacent edges at percentage of their lengths.
+ * Since the width isn't constant, we don't store a width at all, but
+ * rather the distance along the adjacent edge that we need to go
+ * at this end of the edge.
+ */
+
+ e->offset_l_spec = BM_edge_calc_length(e->prev->e) * bp->offset / 100.0f;
+ e->offset_r_spec = BM_edge_calc_length(e->next->e) * bp->offset / 100.0f;
+
break;
}
case BEVEL_AMT_ABSOLUTE: {
/* Like Percent, but the amount gives the absolute distance along adjacent edges. */
- BMVert *v1 = BM_edge_other_vert(e->prev->e, v);
- BMVert *v2 = BM_edge_other_vert(e->e, v);
- float z = sinf(angle_v3v3v3(v1->co, v->co, v2->co));
- e->offset_l_spec = bp->offset * z;
- v1 = BM_edge_other_vert(e->e, v);
- v2 = BM_edge_other_vert(e->next->e, v);
- z = sinf(angle_v3v3v3(v1->co, v->co, v2->co));
- e->offset_r_spec = bp->offset * z;
+ e->offset_l_spec = bp->offset;
+ e->offset_r_spec = bp->offset;
break;
}
default: {
@@ -7072,6 +7191,19 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
EdgeHalf *ec;
BMVert *vd;
float kc;
+ if (bp->offset_type == BEVEL_AMT_PERCENT || bp->offset_type == BEVEL_AMT_ABSOLUTE) {
+ if (ea->is_bev && ebother != NULL && ebother->prev->is_bev) {
+ if (bp->offset_type == BEVEL_AMT_PERCENT) {
+ return bp->offset > 50.0f ? 50.0f : 100.f;
+ }
+ else {
+ /* This is only right sometimes. The exact answer is very hard to calculate. */
+ float blen = BM_edge_calc_length(eb->e);
+ return bp->offset > blen / 2.0f ? blen / 2.0f : blen;
+ }
+ }
+ return no_collide_offset;
+ }
if (ebother != NULL) {
ec = ebother->prev; /* Note: this is in direction c --> d. */
vc = bvc->v;
diff --git a/source/blender/bmesh/tools/bmesh_intersect.c b/source/blender/bmesh/tools/bmesh_intersect.c
index 371d8d59d6c..a47de4390a7 100644
--- a/source/blender/bmesh/tools/bmesh_intersect.c
+++ b/source/blender/bmesh/tools/bmesh_intersect.c
@@ -681,7 +681,7 @@ static void bm_isect_tri_tri(
copy_v3_v3(t_scale[2], fv_b[2]->co);
tri_v3_scale(UNPACK3(t_scale), 1.0f - s->epsilon.eps2x);
- // second check for verts intersecting the triangle
+ /* second check for verts intersecting the triangle */
for (i_a = 0; i_a < 3; i_a++) {
if (BM_ELEM_API_FLAG_TEST(fv_a[i_a], VERT_VISIT_A)) {
continue;
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
index 08f794d7eba..ad980177ae5 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -116,7 +116,7 @@ bool ExecutionGroup::addOperation(NodeOperation *operation)
NodeOperation *ExecutionGroup::getOutputOperation() const
{
return this
- ->m_operations[0]; // the first operation of the group is always the output operation.
+ ->m_operations[0]; /* the first operation of the group is always the output operation. */
}
void ExecutionGroup::initExecution()
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index d9324729560..0ce7c1389bd 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -51,20 +51,20 @@ class NodeOperationOutput;
*/
typedef enum InputResizeMode {
/** \brief Center the input image to the center of the working area of the node, no resizing
- occurs */
+ * occurs */
COM_SC_CENTER = NS_CR_CENTER,
/** \brief The bottom left of the input image is the bottom left of the working area of the node,
- no resizing occurs */
+ * no resizing occurs */
COM_SC_NO_RESIZE = NS_CR_NONE,
/** \brief Fit the width of the input image to the width of the working area of the node */
COM_SC_FIT_WIDTH = NS_CR_FIT_WIDTH,
/** \brief Fit the height of the input image to the height of the working area of the node */
COM_SC_FIT_HEIGHT = NS_CR_FIT_HEIGHT,
/** \brief Fit the width or the height of the input image to the width or height of the working
- area of the node, image will be larger than the working area */
+ * area of the node, image will be larger than the working area */
COM_SC_FIT = NS_CR_FIT,
/** \brief Fit the width and the height of the input image to the width and height of the working
- area of the node, image will be equally larger than the working area */
+ * area of the node, image will be equally larger than the working area */
COM_SC_STRETCH = NS_CR_STRETCH,
} InputResizeMode;
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
index e5764c5bb73..640fbf49808 100644
--- a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
@@ -24,7 +24,7 @@
#include "COM_MixOperation.h"
#include "COM_SetValueOperation.h"
-#include "DNA_material_types.h" // the ramp types
+#include "DNA_material_types.h" /* the ramp types */
void AlphaOverNode::convertToOperations(NodeConverter &converter,
const CompositorContext & /*context*/) const
diff --git a/source/blender/compositor/nodes/COM_MixNode.cpp b/source/blender/compositor/nodes/COM_MixNode.cpp
index b3bcefaccb5..d082590d21b 100644
--- a/source/blender/compositor/nodes/COM_MixNode.cpp
+++ b/source/blender/compositor/nodes/COM_MixNode.cpp
@@ -22,7 +22,7 @@
#include "COM_ExecutionSystem.h"
#include "COM_SetValueOperation.h"
-#include "DNA_material_types.h" // the ramp types
+#include "DNA_material_types.h" /* the ramp types */
MixNode::MixNode(bNode *editorNode) : Node(editorNode)
{
diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.cpp b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
index b30a603bcee..df201289ca4 100644
--- a/source/blender/compositor/nodes/COM_ZCombineNode.cpp
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
@@ -26,7 +26,7 @@
#include "COM_MixOperation.h"
#include "COM_SetValueOperation.h"
-#include "DNA_material_types.h" // the ramp types
+#include "DNA_material_types.h" /* the ramp types */
void ZCombineNode::convertToOperations(NodeConverter &converter,
const CompositorContext &context) const
diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp
index bdc954ac081..9fc7448ce42 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_MaskOperation.cpp
@@ -23,6 +23,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
+#include "BKE_lib_id.h"
#include "BKE_mask.h"
MaskOperation::MaskOperation() : NodeOperation()
@@ -59,9 +60,8 @@ void MaskOperation::initExecution()
const float frame_step = (this->m_frame_shutter * 2.0f) / this->m_rasterMaskHandleTot;
float frame_iter = frame;
- Mask *mask_temp;
-
- mask_temp = BKE_mask_copy_nolib(this->m_mask);
+ Mask *mask_temp = (Mask *)BKE_id_copy_ex(
+ NULL, &this->m_mask->id, NULL, LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA);
/* trick so we can get unkeyed edits to display */
{
@@ -92,8 +92,7 @@ void MaskOperation::initExecution()
frame_iter += frame_step;
}
- BKE_mask_free(mask_temp);
- MEM_freeN(mask_temp);
+ BKE_id_free(NULL, &mask_temp->id);
}
}
}
diff --git a/source/blender/datatoc/CMakeLists.txt b/source/blender/datatoc/CMakeLists.txt
index 3dc4a1add76..27dc01f1750 100644
--- a/source/blender/datatoc/CMakeLists.txt
+++ b/source/blender/datatoc/CMakeLists.txt
@@ -52,7 +52,10 @@ if(NOT WITH_HEADLESS)
endif()
include_directories(${PNG_INCLUDE_DIRS})
- link_directories(${PNG_LIBPATH} ${ZLIB_LIBPATH})
+ if(NOT APPLE)
+ # APPLE plaform uses full paths for linking libraries.
+ link_directories(${PNG_LIBPATH} ${ZLIB_LIBPATH})
+ endif()
add_executable(datatoc_icon ${SRC})
setup_platform_linker_flags(datatoc_icon)
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc b/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc
index 98a2d09c352..42c1fcba1bb 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc
@@ -66,8 +66,8 @@ void deg_debug_fprintf(const DebugContext &ctx, const char *fmt, ...)
inline double get_node_time(const DebugContext & /*ctx*/, const Node *node)
{
- // TODO(sergey): Figure out a nice way to define which exact time
- // we want to show.
+ /* TODO(sergey): Figure out a nice way to define which exact time
+ * we want to show. */
return node->stats.current_time;
}
@@ -97,7 +97,7 @@ string gnuplotify_name(const string &name)
void write_stats_data(const DebugContext &ctx)
{
- // Fill in array of all stats which are to be displayed.
+ /* Fill in array of all stats which are to be displayed. */
Vector<StatsEntry> stats;
stats.reserve(ctx.graph->id_nodes.size());
for (const IDNode *id_node : ctx.graph->id_nodes) {
@@ -110,12 +110,12 @@ void write_stats_data(const DebugContext &ctx)
entry.time = time;
stats.append(entry);
}
- // Sort the data.
+ /* Sort the data. */
std::sort(stats.begin(), stats.end(), stat_entry_comparator);
- // We limit number of entries, otherwise things become unreadable.
+ /* We limit number of entries, otherwise things become unreadable. */
stats.resize(min_ii(stats.size(), 32));
std::reverse(stats.begin(), stats.end());
- // Print data to the file stream.
+ /* Print data to the file stream. */
deg_debug_fprintf(ctx, "$data << EOD" NL);
for (const StatsEntry &entry : stats) {
deg_debug_fprintf(ctx,
@@ -129,14 +129,14 @@ void write_stats_data(const DebugContext &ctx)
void deg_debug_stats_gnuplot(const DebugContext &ctx)
{
- // Data itself.
+ /* Data itself. */
write_stats_data(ctx);
- // Optional label.
+ /* Optional label. */
if (ctx.label && ctx.label[0]) {
deg_debug_fprintf(ctx, "set title \"%s\"" NL, ctx.label);
}
- // Rest of the commands.
- // TODO(sergey): Need to decide on the resolution somehow.
+ /* Rest of the commands.
+ * TODO(sergey): Need to decide on the resolution somehow. */
deg_debug_fprintf(ctx, "set terminal pngcairo size 1920,1080" NL);
deg_debug_fprintf(ctx, "set output \"%s\"" NL, ctx.output_filename);
deg_debug_fprintf(ctx, "set grid" NL);
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index fc9ed9a6ab9..d0eedd6d811 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -25,12 +25,12 @@
#include "MEM_guardedalloc.h"
-#include <string.h> // XXX: memcpy
+#include <string.h> /* XXX: memcpy */
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
-#include "BKE_action.h" // XXX: BKE_pose_channel_find_name
+#include "BKE_action.h" /* XXX: BKE_pose_channel_find_name */
#include "BKE_customdata.h"
#include "BKE_idtype.h"
#include "BKE_main.h"
diff --git a/source/blender/depsgraph/intern/depsgraph_type.cc b/source/blender/depsgraph/intern/depsgraph_type.cc
index 25e9a4643b3..07664cb4f0b 100644
--- a/source/blender/depsgraph/intern/depsgraph_type.cc
+++ b/source/blender/depsgraph/intern/depsgraph_type.cc
@@ -23,7 +23,7 @@
* Defines and code for core node types.
*/
-#include <cstdlib> // for BLI_assert()
+#include <cstdlib> /* for BLI_assert() */
#include "BLI_utildefines.h"
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.h b/source/blender/depsgraph/intern/node/deg_node_operation.h
index 52b6c9a753b..40369de08f5 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.h
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.h
@@ -35,7 +35,7 @@ namespace deg {
struct ComponentNode;
/* Evaluation Operation for atomic operation */
-// XXX: move this to another header that can be exposed?
+/* XXX: move this to another header that can be exposed? */
typedef function<void(struct ::Depsgraph *)> DepsEvalOperationCb;
/* Identifiers for common operations (as an enum). */
@@ -143,7 +143,7 @@ enum class OperationCode {
*
* - "DONE" This noop is used to signal that the bone's final pose
* transform can be read by others. */
- // TODO: deform mats could get calculated in the final_transform ops...
+ /* TODO: deform mats could get calculated in the final_transform ops... */
BONE_READY,
BONE_DONE,
/* B-Bone segment shape computation (after DONE) */
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index 5d5bd7ea9ba..355d156a083 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -459,12 +459,28 @@ static void eevee_render_to_image(void *vedata,
EEVEE_render_modules_init(vedata, engine, depsgraph);
int initial_frame = CFRA;
- int steps = max_ii(1, scene->eevee.motion_blur_steps);
- int time_steps_tot = (do_motion_blur) ? steps : 1;
+ float initial_subframe = SUBFRA;
+ float shuttertime = (do_motion_blur) ? scene->eevee.motion_blur_shutter : 0.0f;
+ int time_steps_tot = (do_motion_blur) ? max_ii(1, scene->eevee.motion_blur_steps) : 1;
g_data->render_tot_samples = divide_ceil_u(scene->eevee.taa_render_samples, time_steps_tot);
- /* Centered on frame for now. */
- float time = CFRA - scene->eevee.motion_blur_shutter / 2.0f;
- float time_step = scene->eevee.motion_blur_shutter / time_steps_tot;
+ /* Compute start time. The motion blur will cover `[time ...time + shuttertime]`. */
+ float time = initial_frame + initial_subframe;
+ switch (scene->eevee.motion_blur_position) {
+ case SCE_EEVEE_MB_START:
+ /* No offset. */
+ break;
+ case SCE_EEVEE_MB_CENTER:
+ time -= shuttertime * 0.5f;
+ break;
+ case SCE_EEVEE_MB_END:
+ time -= shuttertime;
+ break;
+ default:
+ BLI_assert(!"Invalid motion blur position enum!");
+ break;
+ }
+
+ float time_step = shuttertime / time_steps_tot;
for (int i = 0; i < time_steps_tot && !RE_engine_test_break(engine); i++) {
float time_prev = time;
float time_curr = time + time_step * 0.5f;
@@ -562,9 +578,9 @@ static void eevee_render_to_image(void *vedata,
/* Restore original viewport size. */
DRW_render_viewport_size_set((int[2]){g_data->size_orig[0], g_data->size_orig[1]});
- if (CFRA != initial_frame) {
+ if (CFRA != initial_frame || SUBFRA != initial_subframe) {
/* Restore original frame number. This is because the render pipeline expects it. */
- RE_engine_frame_set(engine, initial_frame, 0.0f);
+ RE_engine_frame_set(engine, initial_frame, initial_subframe);
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_occlusion.c b/source/blender/draw/engines/eevee/eevee_occlusion.c
index 46f9c775335..fd96a076c68 100644
--- a/source/blender/draw/engines/eevee/eevee_occlusion.c
+++ b/source/blender/draw/engines/eevee/eevee_occlusion.c
@@ -64,7 +64,9 @@ int EEVEE_occlusion_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
common_data->ao_factor = scene_eval->eevee.gtao_factor;
common_data->ao_quality = 1.0f - scene_eval->eevee.gtao_quality;
- common_data->ao_settings = 1.0f; /* USE_AO */
+ if (scene_eval->eevee.flag & SCE_EEVEE_GTAO_ENABLED) {
+ common_data->ao_settings = 1.0f; /* USE_AO */
+ }
if (scene_eval->eevee.flag & SCE_EEVEE_GTAO_BENT_NORMALS) {
common_data->ao_settings += 2.0f; /* USE_BENT_NORMAL */
}
diff --git a/source/blender/draw/engines/eevee/eevee_renderpasses.c b/source/blender/draw/engines/eevee/eevee_renderpasses.c
index 8ec823879ad..be73225b348 100644
--- a/source/blender/draw/engines/eevee/eevee_renderpasses.c
+++ b/source/blender/draw/engines/eevee/eevee_renderpasses.c
@@ -367,8 +367,8 @@ void EEVEE_renderpasses_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
EEVEE_EffectsInfo *effects = stl->effects;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
- /* We can only draw a single renderpass. Lightpasses also select their color pass (a second
- pass). We mask the light pass when a light pass is selected. */
+ /* We can only draw a single renderpass. Lightpasses also select their color pass
+ * (a second pass). We mask the light pass when a light pass is selected. */
const eViewLayerEEVEEPassType render_pass =
((stl->g_data->render_passes & EEVEE_RENDERPASSES_LIGHT_PASS) != 0) ?
(stl->g_data->render_passes & EEVEE_RENDERPASSES_LIGHT_PASS) :
diff --git a/source/blender/draw/engines/eevee/eevee_shadows.c b/source/blender/draw/engines/eevee/eevee_shadows.c
index 618096fc992..2f8eb482882 100644
--- a/source/blender/draw/engines/eevee/eevee_shadows.c
+++ b/source/blender/draw/engines/eevee/eevee_shadows.c
@@ -23,9 +23,6 @@
#include "BLI_string_utils.h"
#include "BLI_sys_types.h" /* bool */
-// #include "BLI_dynstr.h"
-// #include "BLI_rand.h"
-
#include "BKE_object.h"
#include "DEG_depsgraph_query.h"
diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c
index c6e6530830d..9527c0f47b0 100644
--- a/source/blender/draw/engines/eevee/eevee_volumes.c
+++ b/source/blender/draw/engines/eevee/eevee_volumes.c
@@ -610,7 +610,8 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
grp, NULL, USE_VOLUME_OPTI ? 1 : common_data->vol_tex_size[2]);
DRW_PASS_CREATE(psl->volumetric_resolve_ps, DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_CUSTOM);
- grp = DRW_shgroup_create(EEVEE_shaders_volumes_resolve_sh_get(false), psl->volumetric_resolve_ps);
+ grp = DRW_shgroup_create(EEVEE_shaders_volumes_resolve_sh_get(false),
+ psl->volumetric_resolve_ps);
DRW_shgroup_uniform_texture_ref(grp, "inScattering", &txl->volume_scatter);
DRW_shgroup_uniform_texture_ref(grp, "inTransmittance", &txl->volume_transmit);
DRW_shgroup_uniform_texture_ref(grp, "inSceneDepth", &e_data.depth_src);
diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
index 39db39f8756..06a7def532f 100644
--- a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
@@ -258,7 +258,7 @@ float screen_border_mask(vec2 hit_co)
{
const float margin = 0.003;
float atten = ssrBorderFac + margin; /* Screen percentage */
- hit_co = smoothstep(margin, atten, hit_co) * (1 - smoothstep(1.0 - atten, 1.0 - margin, hit_co));
+ hit_co = smoothstep(0.0, atten, hit_co) * (1.0 - smoothstep(1.0 - atten, 1.0, hit_co));
float screenfade = hit_co.x * hit_co.y;
diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.c b/source/blender/draw/engines/overlay/overlay_edit_uv.c
index af20e85a89b..18400799d3c 100644
--- a/source/blender/draw/engines/overlay/overlay_edit_uv.c
+++ b/source/blender/draw/engines/overlay/overlay_edit_uv.c
@@ -174,7 +174,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata)
GPUShader *sh = OVERLAY_shader_edit_uv_verts_get();
pd->edit_uv_verts_grp = DRW_shgroup_create(sh, psl->edit_uv_verts_ps);
- const float point_size = UI_GetThemeValuef(TH_FACEDOT_SIZE);
+ const float point_size = UI_GetThemeValuef(TH_VERTEX_SIZE);
DRW_shgroup_uniform_block(pd->edit_uv_verts_grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_float_copy(
diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c
index 76697b42a52..30b39e5d5e1 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.c
+++ b/source/blender/draw/engines/overlay/overlay_engine.c
@@ -547,6 +547,7 @@ static void OVERLAY_draw_scene(void *vedata)
OVERLAY_fade_draw(vedata);
OVERLAY_facing_draw(vedata);
OVERLAY_extra_blend_draw(vedata);
+ OVERLAY_volume_draw(vedata);
if (DRW_state_is_fbo()) {
GPU_framebuffer_bind(fbl->overlay_line_fb);
@@ -557,7 +558,6 @@ static void OVERLAY_draw_scene(void *vedata)
OVERLAY_particle_draw(vedata);
OVERLAY_metaball_draw(vedata);
OVERLAY_gpencil_draw(vedata);
- OVERLAY_volume_draw(vedata);
OVERLAY_extra_draw(vedata);
if (DRW_state_is_fbo()) {
diff --git a/source/blender/draw/engines/overlay/overlay_volume.c b/source/blender/draw/engines/overlay/overlay_volume.c
index ffa664c90d5..ad0ccf1c7c4 100644
--- a/source/blender/draw/engines/overlay/overlay_volume.c
+++ b/source/blender/draw/engines/overlay/overlay_volume.c
@@ -39,6 +39,10 @@ void OVERLAY_volume_cache_init(OVERLAY_Data *vedata)
pd->volume_selection_surface_grp = grp;
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
}
+ else {
+ psl->volume_ps = NULL;
+ pd->volume_selection_surface_grp = NULL;
+ }
}
void OVERLAY_volume_cache_populate(OVERLAY_Data *vedata, Object *ob)
@@ -57,11 +61,8 @@ void OVERLAY_volume_cache_populate(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_volume_draw(OVERLAY_Data *vedata)
{
OVERLAY_PassList *psl = vedata->psl;
- OVERLAY_FramebufferList *fbl = vedata->fbl;
- if (DRW_state_is_fbo()) {
- GPU_framebuffer_bind(fbl->overlay_default_fb);
+ if (psl->volume_ps) {
+ DRW_draw_pass(psl->volume_ps);
}
-
- DRW_draw_pass(psl->volume_ps);
}
diff --git a/source/blender/draw/engines/overlay/shaders/edit_uv_verts_frag.glsl b/source/blender/draw/engines/overlay/shaders/edit_uv_verts_frag.glsl
index 11694de38ca..1d936e4e072 100644
--- a/source/blender/draw/engines/overlay/shaders/edit_uv_verts_frag.glsl
+++ b/source/blender/draw/engines/overlay/shaders/edit_uv_verts_frag.glsl
@@ -9,17 +9,17 @@ void main()
{
float dist = length(gl_PointCoord - vec2(0.5));
- // transparent outside of point
- // --- 0 ---
- // smooth transition
- // --- 1 ---
- // pure outline color
- // --- 2 ---
- // smooth transition
- // --- 3 ---
- // pure fill color
- // ...
- // dist = 0 at center of point
+ /* transparent outside of point
+ * --- 0 ---
+ * smooth transition
+ * --- 1 ---
+ * pure outline color
+ * --- 2 ---
+ * smooth transition
+ * --- 3 ---
+ * pure fill color
+ * ...
+ * dist = 0 at center of point */
float midStroke = 0.5 * (radii[1] + radii[2]);
diff --git a/source/blender/draw/engines/overlay/shaders/edit_uv_verts_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_uv_verts_vert.glsl
index eb8f380072f..9e9df82a77d 100644
--- a/source/blender/draw/engines/overlay/shaders/edit_uv_verts_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/edit_uv_verts_vert.glsl
@@ -30,15 +30,15 @@ void main()
gl_Position = vec4(point_world_to_ndc(world_pos).xy, depth, 1.0);
gl_PointSize = pointSize;
- // calculate concentric radii in pixels
+ /* calculate concentric radii in pixels */
float radius = 0.5 * pointSize;
- // start at the outside and progress toward the center
+ /* start at the outside and progress toward the center */
radii[0] = radius;
radii[1] = radius - 1.0;
radii[2] = radius - outlineWidth;
radii[3] = radius - outlineWidth - 1.0;
- // convert to PointCoord units
+ /* convert to PointCoord units */
radii /= pointSize;
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
index 0d67ba2b9e4..102a8ddca7b 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
@@ -342,23 +342,23 @@ void main()
# define mnmx3(a, b, c) \
mx3(a, b, c); \
- s2(a, b); // 3 exchanges
+ s2(a, b); /* 3 exchanges */
# define mnmx4(a, b, c, d) \
s2(a, b); \
s2(c, d); \
s2(a, c); \
- s2(b, d); // 4 exchanges
+ s2(b, d); /* 4 exchanges */
# define mnmx5(a, b, c, d, e) \
s2(a, b); \
s2(c, d); \
mn3(a, c, e); \
- mx3(b, d, e); // 6 exchanges
+ mx3(b, d, e); /* 6 exchanges */
# define mnmx6(a, b, c, d, e, f) \
s2(a, d); \
s2(b, e); \
s2(c, f); \
mn3(a, b, c); \
- mx3(d, e, f); // 7 exchanges
+ mx3(d, e, f); /* 7 exchanges */
vec v[9];
diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c
index 310a8b861aa..c566b35cd34 100644
--- a/source/blender/draw/engines/workbench/workbench_data.c
+++ b/source/blender/draw/engines/workbench/workbench_data.c
@@ -179,14 +179,21 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
}
if (!v3d || (v3d->shading.type == OB_RENDER && BKE_scene_uses_blender_workbench(scene))) {
+ short shading_flag = scene->display.shading.flag;
+ if (XRAY_FLAG_ENABLED((&scene->display))) {
+ /* Disable shading options that aren't supported in transparency mode. */
+ shading_flag &= ~(V3D_SHADING_SHADOW | V3D_SHADING_CAVITY | V3D_SHADING_DEPTH_OF_FIELD);
+ }
+
/* FIXME: This reproduce old behavior when workbench was separated in 2 engines.
* But this is a workaround for a missing update tagging from operators. */
- if ((v3d && (XRAY_ENABLED(v3d) != XRAY_ENABLED(&scene->display))) ||
- (scene->display.shading.flag != wpd->shading.flag)) {
+ if ((XRAY_ENABLED(wpd) != XRAY_ENABLED(&scene->display)) ||
+ (shading_flag != wpd->shading.flag)) {
wpd->view_updated = true;
}
wpd->shading = scene->display.shading;
+ wpd->shading.flag = shading_flag;
if (XRAY_FLAG_ENABLED((&scene->display))) {
wpd->shading.xray_alpha = XRAY_ALPHA((&scene->display));
}
@@ -206,13 +213,20 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
}
}
else {
+ short shading_flag = v3d->shading.flag;
+ if (XRAY_ENABLED(v3d)) {
+ /* Disable shading options that aren't supported in transparency mode. */
+ shading_flag &= ~(V3D_SHADING_SHADOW | V3D_SHADING_CAVITY | V3D_SHADING_DEPTH_OF_FIELD);
+ }
+
/* FIXME: This reproduce old behavior when workbench was separated in 2 engines.
* But this is a workaround for a missing update tagging from operators. */
- if (XRAY_ENABLED(v3d) != XRAY_ENABLED(wpd) || v3d->shading.flag != wpd->shading.flag) {
+ if (XRAY_ENABLED(v3d) != XRAY_ENABLED(wpd) || shading_flag != wpd->shading.flag) {
wpd->view_updated = true;
}
wpd->shading = v3d->shading;
+ wpd->shading.flag = shading_flag;
if (wpd->shading.type < OB_SOLID) {
wpd->shading.light = V3D_LIGHTING_FLAT;
wpd->shading.color_type = V3D_SHADING_OBJECT_COLOR;
@@ -220,8 +234,6 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
}
else if (XRAY_ENABLED(v3d)) {
wpd->shading.xray_alpha = XRAY_ALPHA(v3d);
- /* Disable shading options that aren't supported in transparency mode. */
- wpd->shading.flag &= ~(V3D_SHADING_SHADOW | V3D_SHADING_CAVITY | V3D_SHADING_DEPTH_OF_FIELD);
}
else {
wpd->shading.xray_alpha = 1.0f;
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 95cdb849e63..438acdca171 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -44,11 +44,11 @@ struct bGPdata;
#include "BKE_mesh_types.h"
/* Expose via BKE callbacks */
-void DRW_mball_batch_cache_dirty_tag(struct MetaBall *mb, eMeshBatchDirtyMode mode);
+void DRW_mball_batch_cache_dirty_tag(struct MetaBall *mb, int mode);
void DRW_mball_batch_cache_validate(struct MetaBall *mb);
void DRW_mball_batch_cache_free(struct MetaBall *mb);
-void DRW_curve_batch_cache_dirty_tag(struct Curve *cu, eMeshBatchDirtyMode mode);
+void DRW_curve_batch_cache_dirty_tag(struct Curve *cu, int mode);
void DRW_curve_batch_cache_validate(struct Curve *cu);
void DRW_curve_batch_cache_free(struct Curve *cu);
@@ -56,25 +56,25 @@ void DRW_mesh_batch_cache_dirty_tag(struct Mesh *me, eMeshBatchDirtyMode mode);
void DRW_mesh_batch_cache_validate(struct Mesh *me);
void DRW_mesh_batch_cache_free(struct Mesh *me);
-void DRW_lattice_batch_cache_dirty_tag(struct Lattice *lt, eMeshBatchDirtyMode mode);
+void DRW_lattice_batch_cache_dirty_tag(struct Lattice *lt, int mode);
void DRW_lattice_batch_cache_validate(struct Lattice *lt);
void DRW_lattice_batch_cache_free(struct Lattice *lt);
-void DRW_particle_batch_cache_dirty_tag(struct ParticleSystem *psys, eMeshBatchDirtyMode mode);
+void DRW_particle_batch_cache_dirty_tag(struct ParticleSystem *psys, int mode);
void DRW_particle_batch_cache_free(struct ParticleSystem *psys);
void DRW_gpencil_batch_cache_dirty_tag(struct bGPdata *gpd);
void DRW_gpencil_batch_cache_free(struct bGPdata *gpd);
-void DRW_hair_batch_cache_dirty_tag(struct Hair *hair, eMeshBatchDirtyMode mode);
+void DRW_hair_batch_cache_dirty_tag(struct Hair *hair, int mode);
void DRW_hair_batch_cache_validate(struct Hair *hair);
void DRW_hair_batch_cache_free(struct Hair *hair);
-void DRW_pointcloud_batch_cache_dirty_tag(struct PointCloud *pointcloud, eMeshBatchDirtyMode mode);
+void DRW_pointcloud_batch_cache_dirty_tag(struct PointCloud *pointcloud, int mode);
void DRW_pointcloud_batch_cache_validate(struct PointCloud *pointcloud);
void DRW_pointcloud_batch_cache_free(struct PointCloud *pointcloud);
-void DRW_volume_batch_cache_dirty_tag(struct Volume *volume, eMeshBatchDirtyMode mode);
+void DRW_volume_batch_cache_dirty_tag(struct Volume *volume, int mode);
void DRW_volume_batch_cache_validate(struct Volume *volume);
void DRW_volume_batch_cache_free(struct Volume *volume);
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index 01fe43e081f..938c26a9cdf 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -484,7 +484,7 @@ static CurveBatchCache *curve_batch_cache_get(Curve *cu)
return cu->batch_cache;
}
-void DRW_curve_batch_cache_dirty_tag(Curve *cu, eMeshBatchDirtyMode mode)
+void DRW_curve_batch_cache_dirty_tag(Curve *cu, int mode)
{
CurveBatchCache *cache = cu->batch_cache;
if (cache == NULL) {
diff --git a/source/blender/draw/intern/draw_cache_impl_hair.c b/source/blender/draw/intern/draw_cache_impl_hair.c
index aeb53418392..327a92a997e 100644
--- a/source/blender/draw/intern/draw_cache_impl_hair.c
+++ b/source/blender/draw/intern/draw_cache_impl_hair.c
@@ -90,7 +90,7 @@ static HairBatchCache *hair_batch_cache_get(Hair *hair)
return hair->batch_cache;
}
-void DRW_hair_batch_cache_dirty_tag(Hair *hair, eMeshBatchDirtyMode mode)
+void DRW_hair_batch_cache_dirty_tag(Hair *hair, int mode)
{
HairBatchCache *cache = hair->batch_cache;
if (cache == NULL) {
diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c
index 0c5bbbb89f5..0f80b5159a7 100644
--- a/source/blender/draw/intern/draw_cache_impl_lattice.c
+++ b/source/blender/draw/intern/draw_cache_impl_lattice.c
@@ -294,7 +294,7 @@ static LatticeBatchCache *lattice_batch_cache_get(Lattice *lt)
return lt->batch_cache;
}
-void DRW_lattice_batch_cache_dirty_tag(Lattice *lt, eMeshBatchDirtyMode mode)
+void DRW_lattice_batch_cache_dirty_tag(Lattice *lt, int mode)
{
LatticeBatchCache *cache = lt->batch_cache;
if (cache == NULL) {
diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c
index 91d9f134da2..53c31ac3de8 100644
--- a/source/blender/draw/intern/draw_cache_impl_metaball.c
+++ b/source/blender/draw/intern/draw_cache_impl_metaball.c
@@ -112,7 +112,7 @@ static MetaBallBatchCache *metaball_batch_cache_get(MetaBall *mb)
return mb->batch_cache;
}
-void DRW_mball_batch_cache_dirty_tag(MetaBall *mb, eMeshBatchDirtyMode mode)
+void DRW_mball_batch_cache_dirty_tag(MetaBall *mb, int mode)
{
MetaBallBatchCache *cache = mb->batch_cache;
if (cache == NULL) {
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index e04da8e2686..52d1fcfdb80 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -157,7 +157,7 @@ static ParticleBatchCache *particle_batch_cache_get(ParticleSystem *psys)
return psys->batch_cache;
}
-void DRW_particle_batch_cache_dirty_tag(ParticleSystem *psys, eMeshBatchDirtyMode mode)
+void DRW_particle_batch_cache_dirty_tag(ParticleSystem *psys, int mode)
{
ParticleBatchCache *cache = psys->batch_cache;
if (cache == NULL) {
diff --git a/source/blender/draw/intern/draw_cache_impl_pointcloud.c b/source/blender/draw/intern/draw_cache_impl_pointcloud.c
index bd34760ca4e..74020a228e7 100644
--- a/source/blender/draw/intern/draw_cache_impl_pointcloud.c
+++ b/source/blender/draw/intern/draw_cache_impl_pointcloud.c
@@ -106,7 +106,7 @@ static PointCloudBatchCache *pointcloud_batch_cache_get(PointCloud *pointcloud)
return pointcloud->batch_cache;
}
-void DRW_pointcloud_batch_cache_dirty_tag(PointCloud *pointcloud, eMeshBatchDirtyMode mode)
+void DRW_pointcloud_batch_cache_dirty_tag(PointCloud *pointcloud, int mode)
{
PointCloudBatchCache *cache = pointcloud->batch_cache;
if (cache == NULL) {
diff --git a/source/blender/draw/intern/draw_cache_impl_volume.c b/source/blender/draw/intern/draw_cache_impl_volume.c
index b9eef066533..10bacadb199 100644
--- a/source/blender/draw/intern/draw_cache_impl_volume.c
+++ b/source/blender/draw/intern/draw_cache_impl_volume.c
@@ -107,7 +107,7 @@ static VolumeBatchCache *volume_batch_cache_get(Volume *volume)
return volume->batch_cache;
}
-void DRW_volume_batch_cache_dirty_tag(Volume *volume, eMeshBatchDirtyMode mode)
+void DRW_volume_batch_cache_dirty_tag(Volume *volume, int mode)
{
VolumeBatchCache *cache = volume->batch_cache;
if (cache == NULL) {
diff --git a/source/blender/draw/intern/shaders/common_fxaa_lib.glsl b/source/blender/draw/intern/shaders/common_fxaa_lib.glsl
index 9eaba00988d..69af2d09af4 100644
--- a/source/blender/draw/intern/shaders/common_fxaa_lib.glsl
+++ b/source/blender/draw/intern/shaders/common_fxaa_lib.glsl
@@ -1,36 +1,36 @@
-//----------------------------------------------------------------------------------
-// File: es3-kepler\FXAA/FXAA3_11.h
-// SDK Version: v3.00
-// Email: gameworks@nvidia.com
-// Site: http://developer.nvidia.com/
-//
-// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-// * Neither the name of NVIDIA CORPORATION nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
-// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-//----------------------------------------------------------------------------------
+/* ---------------------------------------------------------------------------------
+ * File: es3-kepler\FXAA/FXAA3_11.h
+ * SDK Version: v3.00
+ * Email: gameworks@nvidia.com
+ * Site: http://developer.nvidia.com/
+ *
+ * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of NVIDIA CORPORATION nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * --------------------------------------------------------------------------------- */
/* BLENDER MODIFICATIONS:
*
@@ -54,26 +54,26 @@
NOTE the other tuning knobs are now in the shader function inputs!
============================================================================*/
#ifndef FXAA_QUALITY__PRESET
-//
-// Choose the quality preset.
-// This needs to be compiled into the shader as it effects code.
-// Best option to include multiple presets is to
-// in each shader define the preset, then include this file.
-//
-// OPTIONS
-// -----------------------------------------------------------------------
-// 10 to 15 - default medium dither (10=fastest, 15=highest quality)
-// 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)
-// 39 - no dither, very expensive
-//
-// NOTES
-// -----------------------------------------------------------------------
-// 12 = slightly faster then FXAA 3.9 and higher edge quality (default)
-// 13 = about same speed as FXAA 3.9 and better than 12
-// 23 = closest to FXAA 3.9 visually and performance wise
-// _ = the lowest digit is directly related to performance
-// _ = the highest digit is directly related to style
-//
+/*
+ * Choose the quality preset.
+ * This needs to be compiled into the shader as it effects code.
+ * Best option to include multiple presets is to
+ * in each shader define the preset, then include this file.
+ *
+ * OPTIONS
+ * -----------------------------------------------------------------------
+ * 10 to 15 - default medium dither (10=fastest, 15=highest quality)
+ * 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)
+ * 39 - no dither, very expensive
+ *
+ * NOTES
+ * -----------------------------------------------------------------------
+ * 12 = slightly faster then FXAA 3.9 and higher edge quality (default)
+ * 13 = about same speed as FXAA 3.9 and better than 12
+ * 23 = closest to FXAA 3.9 visually and performance wise
+ * _ = the lowest digit is directly related to performance
+ * _ = the highest digit is directly related to style
+ */
# define FXAA_QUALITY__PRESET 12
#endif
@@ -296,9 +296,9 @@ NOTE the other tuning knobs are now in the shader function inputs!
/* (#B1#) */
float FxaaLuma(vec4 rgba)
{
- // note: sqrt because the sampled colors are in a linear colorspace!
- // this approximates a perceptual conversion, which is good enough for the
- // algorithm
+ /* note: sqrt because the sampled colors are in a linear colorspace!
+ * this approximates a perceptual conversion, which is good enough for the
+ * algorithm */
return sqrt(dot(rgba.rgb, vec3(0.2126, 0.7152, 0.0722)));
}
@@ -311,51 +311,51 @@ float FxaaLuma(vec4 rgba)
============================================================================*/
/*--------------------------------------------------------------------------*/
vec4 FxaaPixelShader(
- //
- // Use noperspective interpolation here (turn off perspective interpolation).
- // {xy} = center of pixel
+ /*
+ * Use noperspective interpolation here (turn off perspective interpolation).
+ * {xy} = center of pixel */
vec2 pos,
- //
- // Input color texture.
- // {rgb_} = color in linear or perceptual color space
+ /*
+ * Input color texture.
+ * {rgb_} = color in linear or perceptual color space */
sampler2D tex,
- //
- // Only used on FXAA Quality.
- // This must be from a constant/uniform.
- // {x_} = 1.0/screenWidthInPixels
- // {_y} = 1.0/screenHeightInPixels
+ /*
+ * Only used on FXAA Quality.
+ * This must be from a constant/uniform.
+ * {x_} = 1.0/screenWidthInPixels
+ * {_y} = 1.0/screenHeightInPixels */
vec2 fxaaQualityRcpFrame,
- //
- // Only used on FXAA Quality.
- // This used to be the FXAA_QUALITY__SUBPIX define.
- // It is here now to allow easier tuning.
- // Choose the amount of sub-pixel aliasing removal.
- // This can effect sharpness.
- // 1.00 - upper limit (softer)
- // 0.75 - default amount of filtering
- // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
- // 0.25 - almost off
- // 0.00 - completely off
+ /*
+ * Only used on FXAA Quality.
+ * This used to be the FXAA_QUALITY__SUBPIX define.
+ * It is here now to allow easier tuning.
+ * Choose the amount of sub-pixel aliasing removal.
+ * This can effect sharpness.
+ * 1.00 - upper limit (softer)
+ * 0.75 - default amount of filtering
+ * 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
+ * 0.25 - almost off
+ * 0.00 - completely off */
float fxaaQualitySubpix,
- //
- // Only used on FXAA Quality.
- // This used to be the FXAA_QUALITY__EDGE_THRESHOLD define.
- // It is here now to allow easier tuning.
- // The minimum amount of local contrast required to apply algorithm.
- // 0.333 - too little (faster)
- // 0.250 - low quality
- // 0.166 - default
- // 0.125 - high quality
- // 0.063 - overkill (slower)
+ /*
+ * Only used on FXAA Quality.
+ * This used to be the FXAA_QUALITY__EDGE_THRESHOLD define.
+ * It is here now to allow easier tuning.
+ * The minimum amount of local contrast required to apply algorithm.
+ * 0.333 - too little (faster)
+ * 0.250 - low quality
+ * 0.166 - default
+ * 0.125 - high quality
+ * 0.063 - overkill (slower) */
float fxaaQualityEdgeThreshold,
- //
- // Only used on FXAA Quality.
- // This used to be the FXAA_QUALITY__EDGE_THRESHOLD_MIN define.
- // It is here now to allow easier tuning.
- // Trims the algorithm from processing darks.
- // 0.0833 - upper limit (default, the start of visible unfiltered edges)
- // 0.0625 - high quality (faster)
- // 0.0312 - visible limit (slower)
+ /*
+ * Only used on FXAA Quality.
+ * This used to be the FXAA_QUALITY__EDGE_THRESHOLD_MIN define.
+ * It is here now to allow easier tuning.
+ * Trims the algorithm from processing darks.
+ * 0.0833 - upper limit (default, the start of visible unfiltered edges)
+ * 0.0625 - high quality (faster)
+ * 0.0312 - visible limit (slower) */
float fxaaQualityEdgeThresholdMin)
{
/*--------------------------------------------------------------------------*/
@@ -363,7 +363,7 @@ vec4 FxaaPixelShader(
posM.x = pos.x;
posM.y = pos.y;
vec4 rgbyM = FxaaTexTop(tex, posM);
- float lumaM = FxaaLuma(rgbyM); // (#B4#)
+ float lumaM = FxaaLuma(rgbyM); /* (#B4#) */
float lumaS = FxaaLuma(FxaaTexOff(tex, posM, ivec2(0, 1), fxaaQualityRcpFrame.xy));
float lumaE = FxaaLuma(FxaaTexOff(tex, posM, ivec2(1, 0), fxaaQualityRcpFrame.xy));
float lumaN = FxaaLuma(FxaaTexOff(tex, posM, ivec2(0, -1), fxaaQualityRcpFrame.xy));
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 9f56bfd8d40..338cbf2cded 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -85,7 +85,7 @@
#include "WM_types.h"
/* *********************************************** */
-// XXX constant defines to be moved elsewhere?
+/* XXX constant defines to be moved elsewhere? */
/* extra padding for lengths (to go under scrollers) */
#define EXTRA_SCROLL_PAD 100.0f
@@ -288,7 +288,7 @@ static short acf_generic_indention_1(bAnimContext *UNUSED(ac), bAnimListElem *UN
{
return 1;
}
-#if 0 // XXX not used
+#if 0 /* XXX not used */
static short acf_generic_indention_2(bAnimContext *ac, bAnimListElem *ale)
{
return 2;
@@ -304,7 +304,7 @@ static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListE
if (ale->type == ANIMTYPE_FCURVE) {
FCurve *fcu = (FCurve *)ale->data;
- // TODO: we need some way of specifying that the indention color should be one less...
+ /* TODO: we need some way of specifying that the indention color should be one less. */
if (fcu->grp) {
indent++;
}
@@ -562,7 +562,7 @@ static bAnimChannelType ACF_SUMMARY = {
/* Scene ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_scene_icon(bAnimListElem *UNUSED(ale))
{
return ICON_SCENE_DATA;
@@ -810,8 +810,8 @@ static void *acf_object_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_SELECT: /* selected */
return GET_ACF_FLAG_PTR(base->flag, type);
- case ACHANNEL_SETTING_EXPAND: /* expanded */
- return GET_ACF_FLAG_PTR(ob->nlaflag, type); // xxx
+ case ACHANNEL_SETTING_EXPAND: /* expanded */
+ return GET_ACF_FLAG_PTR(ob->nlaflag, type); /* XXX */
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
@@ -1062,7 +1062,7 @@ static bool acf_fcurve_setting_valid(bAnimContext *ac,
return true;
}
else {
- return false; // NOTE: in this special case, we need to draw ICON_ZOOMOUT
+ return false; /* NOTE: in this special case, we need to draw ICON_ZOOMOUT */
}
case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
@@ -1126,7 +1126,7 @@ static bAnimChannelType ACF_FCURVE = {
acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_flexible,
- /* indent level */ // xxx rename this to f-curves only?
+ /* indent level */ /* XXX rename this to f-curves only? */
acf_generic_group_offset, /* offset */
acf_fcurve_name, /* name */
@@ -1145,7 +1145,7 @@ static void acf_nla_controls_color(bAnimContext *UNUSED(ac),
bAnimListElem *UNUSED(ale),
float r_color[3])
{
- // TODO: give this its own theme setting?
+ /* TODO: give this its own theme setting? */
UI_GetThemeColorShade3fv(TH_GROUP, 55, r_color);
}
@@ -1187,7 +1187,7 @@ static bool acf_nla_controls_setting_valid(bAnimContext *UNUSED(ac),
case ACHANNEL_SETTING_EXPAND:
return true;
- // TODO: selected?
+ /* TODO: selected? */
default: /* unsupported */
return false;
@@ -1290,7 +1290,7 @@ static bAnimChannelType ACF_NLACURVE = {
/* Object Action Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_fillactd_icon(bAnimListElem *UNUSED(ale))
{
return ICON_ACTION;
@@ -1380,7 +1380,7 @@ static bAnimChannelType ACF_FILLACTD = {
/* Drivers Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_filldrivers_icon(bAnimListElem *UNUSED(ale))
{
return ICON_DRIVER;
@@ -1392,7 +1392,7 @@ static void acf_filldrivers_name(bAnimListElem *UNUSED(ale), char *name)
}
/* check if some setting exists for this channel */
-// TODO: this could be made more generic
+/* TODO: this could be made more generic */
static bool acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac),
bAnimListElem *UNUSED(ale),
eAnimChannel_Settings setting)
@@ -1465,7 +1465,7 @@ static bAnimChannelType ACF_FILLDRIVERS = {
/* Material Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dsmat_icon(bAnimListElem *UNUSED(ale))
{
return ICON_MATERIAL_DATA;
@@ -1544,7 +1544,7 @@ static bAnimChannelType ACF_DSMAT = {
/* Light Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dslight_icon(bAnimListElem *UNUSED(ale))
{
return ICON_LIGHT_DATA;
@@ -1625,17 +1625,17 @@ static bAnimChannelType ACF_DSLIGHT = {
/* Texture Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dstex_icon(bAnimListElem *UNUSED(ale))
{
return ICON_TEXTURE_DATA;
}
/* offset for texture expanders */
-// FIXME: soon to be obsolete?
+/* FIXME: soon to be obsolete? */
static short acf_dstex_offset(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale))
{
- return 14; // XXX: simply include this in indention instead?
+ return 14; /* XXX: simply include this in indention instead? */
}
/* get the appropriate flag(s) for the setting when it is valid */
@@ -1711,7 +1711,7 @@ static bAnimChannelType ACF_DSTEX = {
/* Camera Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dscachefile_icon(bAnimListElem *ale)
{
UNUSED_VARS(ale);
@@ -1794,7 +1794,7 @@ static bAnimChannelType ACF_DSCACHEFILE = {
/* Camera Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dscam_icon(bAnimListElem *UNUSED(ale))
{
return ICON_CAMERA_DATA;
@@ -1877,7 +1877,7 @@ static bAnimChannelType ACF_DSCAM = {
/* Curve Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dscur_icon(bAnimListElem *ale)
{
Curve *cu = (Curve *)ale->data;
@@ -1966,7 +1966,7 @@ static bAnimChannelType ACF_DSCUR = {
/* Shape Key Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dsskey_icon(bAnimListElem *UNUSED(ale))
{
return ICON_SHAPEKEY_DATA;
@@ -2064,7 +2064,7 @@ static bAnimChannelType ACF_DSSKEY = {
/* World Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dswor_icon(bAnimListElem *UNUSED(ale))
{
return ICON_WORLD_DATA;
@@ -2143,7 +2143,7 @@ static bAnimChannelType ACF_DSWOR = {
/* Particle Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dspart_icon(bAnimListElem *UNUSED(ale))
{
return ICON_PARTICLE_DATA;
@@ -2222,7 +2222,7 @@ static bAnimChannelType ACF_DSPART = {
/* MetaBall Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dsmball_icon(bAnimListElem *UNUSED(ale))
{
return ICON_META_DATA;
@@ -2303,7 +2303,7 @@ static bAnimChannelType ACF_DSMBALL = {
/* Armature Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dsarm_icon(bAnimListElem *UNUSED(ale))
{
return ICON_ARMATURE_DATA;
@@ -2382,7 +2382,7 @@ static bAnimChannelType ACF_DSARM = {
/* NodeTree Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dsntree_icon(bAnimListElem *UNUSED(ale))
{
return ICON_NODETREE;
@@ -2555,7 +2555,7 @@ static bAnimChannelType ACF_DSLINESTYLE = {
/* Mesh Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dsmesh_icon(bAnimListElem *UNUSED(ale))
{
return ICON_MESH_DATA;
@@ -2621,7 +2621,7 @@ static bAnimChannelType ACF_DSMESH = {
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1,
- /* indent level */ // XXX this only works for compositing
+ /* indent level */ /* XXX this only works for compositing */
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
@@ -2635,7 +2635,7 @@ static bAnimChannelType ACF_DSMESH = {
/* Lattice Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dslat_icon(bAnimListElem *UNUSED(ale))
{
return ICON_LATTICE_DATA;
@@ -2701,7 +2701,7 @@ static bAnimChannelType ACF_DSLAT = {
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1,
- /* indent level */ // XXX this only works for compositing
+ /* indent level */ /* XXX this only works for compositing */
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
@@ -2715,7 +2715,7 @@ static bAnimChannelType ACF_DSLAT = {
/* Speaker Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dsspk_icon(bAnimListElem *UNUSED(ale))
{
return ICON_SPEAKER;
@@ -2794,7 +2794,7 @@ static bAnimChannelType ACF_DSSPK = {
/* Hair Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dshair_icon(bAnimListElem *UNUSED(ale))
{
return ICON_HAIR_DATA;
@@ -2873,7 +2873,7 @@ static bAnimChannelType ACF_DSHAIR = {
/* PointCloud Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dspointcloud_icon(bAnimListElem *UNUSED(ale))
{
return ICON_POINTCLOUD_DATA;
@@ -2954,7 +2954,7 @@ static bAnimChannelType ACF_DSPOINTCLOUD = {
/* Volume Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dsvolume_icon(bAnimListElem *UNUSED(ale))
{
return ICON_VOLUME_DATA;
@@ -3113,7 +3113,7 @@ static bAnimChannelType ACF_DSSIMULATION = {
/* GPencil Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dsgpencil_icon(bAnimListElem *UNUSED(ale))
{
return ICON_GREASEPENCIL;
@@ -3194,7 +3194,7 @@ static bAnimChannelType ACF_DSGPENCIL = {
/* World Expander ------------------------------------------- */
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_dsmclip_icon(bAnimListElem *UNUSED(ale))
{
return ICON_SEQUENCE;
@@ -3397,7 +3397,7 @@ static void acf_gpd_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale),
UI_GetThemeColorShade3fv(TH_DOPESHEET_CHANNELSUBOB, 20, r_color);
}
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_gpd_icon(bAnimListElem *UNUSED(ale))
{
return ICON_GREASEPENCIL;
@@ -3576,7 +3576,7 @@ static void acf_mask_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale),
UI_GetThemeColorShade3fv(TH_DOPESHEET_CHANNELSUBOB, 20, r_color);
}
-// TODO: just get this from RNA?
+/* TODO: just get this from RNA? */
static int acf_mask_icon(bAnimListElem *UNUSED(ale))
{
return ICON_MOD_MASK;
@@ -3875,7 +3875,7 @@ static bAnimChannelType ACF_NLATRACK = {
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_flexible, /* indent level */
acf_generic_group_offset,
- /* offset */ // XXX?
+ /* offset */ /* XXX? */
acf_nlatrack_name, /* name */
acf_nlatrack_name_prop, /* name prop */
@@ -3970,7 +3970,7 @@ static void acf_nlaaction_name(bAnimListElem *ale, char *name)
if (name) {
if (act) {
- // TODO: add special decoration when doing this in tweaking mode?
+ /* TODO: add special decoration when doing this in tweaking mode? */
BLI_strncpy(name, act->id.name + 2, ANIM_CHAN_NAME_SIZE);
}
else {
@@ -4027,7 +4027,7 @@ static int acf_nlaaction_setting_flag(bAnimContext *UNUSED(ac),
switch (setting) {
case ACHANNEL_SETTING_PINNED: /* pinned - map/unmap */
- *neg = true; // XXX
+ *neg = true; /* XXX */
return ADT_NLA_EDIT_NOMAP;
default: /* unsupported */
@@ -4054,7 +4054,7 @@ static bAnimChannelType ACF_NLAACTION = {
acf_nlaaction_backdrop, /* backdrop */
acf_generic_indention_flexible, /* indent level */
acf_generic_group_offset,
- /* offset */ // XXX?
+ /* offset */ /* XXX? */
acf_nlaaction_name, /* name */
acf_nlaaction_name_prop, /* name prop */
@@ -4328,15 +4328,15 @@ void ANIM_channel_setting_set(bAnimContext *ac,
/* --------------------------- */
-// size of icons
+/* size of icons */
#define ICON_WIDTH (0.85f * U.widget_unit)
-// width of sliders
+/* width of sliders */
#define SLIDER_WIDTH (4 * U.widget_unit)
-// min-width of rename textboxes
+/* min-width of rename textboxes */
#define RENAME_TEXT_MIN_WIDTH (U.widget_unit)
-// width of graph editor color bands
+/* width of graph editor color bands */
#define GRAPH_COLOR_BAND_WIDTH (0.3f * U.widget_unit)
-// extra offset for the visibility icons in the graph editor
+/* extra offset for the visibility icons in the graph editor */
#define GRAPH_ICON_VISIBILITY_OFFSET (GRAPH_COLOR_BAND_WIDTH * 1.5f)
/* Helper - Check if a channel needs renaming */
@@ -4796,7 +4796,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
/* try to resolve the path stored in the F-Curve */
if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop)) {
/* find or create new F-Curve */
- // XXX is the group name for this ok?
+ /* XXX is the group name for this ok? */
bAction *act = ED_id_action_ensure(bmain, (ID *)key);
FCurve *fcu = ED_action_fcurve_ensure(bmain, act, NULL, &ptr, rna_path, 0);
@@ -4945,7 +4945,7 @@ static void draw_setting_widget(bAnimContext *ac,
/* --- */
case ACHANNEL_SETTING_PROTECT: /* protected lock */
- // TODO: what about when there's no protect needed?
+ /* TODO: what about when there's no protect needed? */
// icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED);
icon = ICON_UNLOCKED;
@@ -5241,7 +5241,7 @@ void ANIM_channel_draw_widgets(const bContext *C,
/* reset offset - now goes from RHS of panel */
offset = (int)rect->xmax;
- // TODO: when drawing sliders, make those draw instead of these toggles if not enough space
+ /* TODO: when drawing sliders, make those draw instead of these toggles if not enough space. */
if (v2d && !is_being_renamed) {
short draw_sliders = 0;
@@ -5333,9 +5333,12 @@ void ANIM_channel_draw_widgets(const bContext *C,
* - Sliders are always drawn in Shapekey mode now. Prior to this
* the SACTION_SLIDERS flag would be set when changing into Shapekey mode.
*/
- if (((draw_sliders)
- && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY, ANIMTYPE_GPLAYER))
- || ale->type == ANIMTYPE_SHAPEKEY) {
+ if (((draw_sliders) && ELEM(ale->type,
+ ANIMTYPE_FCURVE,
+ ANIMTYPE_NLACURVE,
+ ANIMTYPE_SHAPEKEY,
+ ANIMTYPE_GPLAYER)) ||
+ ale->type == ANIMTYPE_SHAPEKEY) {
/* adjust offset */
/* TODO: make slider width dynamic,
* so that they can be easier to use when the view is wide enough. */
@@ -5518,7 +5521,7 @@ void ANIM_channel_draw_widgets(const bContext *C,
}
}
else { /* Special Slider for stuff without RNA Access ---------- */
- // TODO: only implement this case when we really need it...
+ /* TODO: only implement this case when we really need it... */
}
}
}
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 6aa8f8d0b27..77ebc1606fa 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -59,7 +59,7 @@
#include "ED_anim_api.h"
#include "ED_armature.h"
-#include "ED_keyframes_edit.h" // XXX move the select modes out of there!
+#include "ED_keyframes_edit.h" /* XXX move the select modes out of there! */
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
@@ -73,7 +73,7 @@
/* -------------------------- Selection ------------------------------------- */
/* Set the given animation-channel as the active one for the active context */
-// TODO: extend for animdata types...
+/* TODO: extend for animdata types... */
void ANIM_set_active_channel(bAnimContext *ac,
void *data,
eAnimCont_Types datatype,
@@ -253,109 +253,107 @@ static void select_pchan_for_action_group(bAnimContext *ac, bActionGroup *agrp,
}
}
-/* Deselect all animation channels
- * - data: pointer to datatype, as contained in bAnimContext
- * - datatype: the type of data that 'data' represents (eAnimCont_Types)
- * - test: check if deselecting instead of selecting
- * - sel: eAnimChannels_SetFlag;
- */
-void ANIM_deselect_anim_channels(
- bAnimContext *ac, void *data, eAnimCont_Types datatype, bool test, eAnimChannels_SetFlag sel)
+static ListBase /* bAnimListElem */ anim_channels_for_selection(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
- bAnimListElem *ale;
- int filter;
/* filter data */
/* NOTE: no list visible, otherwise, we get dangling */
- filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS;
- ANIM_animdata_filter(ac, &anim_data, filter, data, datatype);
+ const int filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS;
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- /* See if we should be selecting or deselecting */
- if (test) {
- for (ale = anim_data.first; ale; ale = ale->next) {
- if (sel == 0) {
- break;
- }
+ return anim_data;
+}
- switch (ale->type) {
- case ANIMTYPE_SCENE:
- if (ale->flag & SCE_DS_SELECTED) {
- sel = ACHANNEL_SETFLAG_CLEAR;
- }
- break;
- case ANIMTYPE_OBJECT:
+static eAnimChannels_SetFlag anim_channels_selection_flag_for_toggle(const ListBase anim_data)
+{
+ /* See if we should be selecting or deselecting. */
+ for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ switch (ale->type) {
+ case ANIMTYPE_SCENE:
+ if (ale->flag & SCE_DS_SELECTED) {
+ return ACHANNEL_SETFLAG_CLEAR;
+ }
+ break;
+ case ANIMTYPE_OBJECT:
#if 0 /* for now, do not take object selection into account, since it gets too annoying */
if (ale->flag & SELECT) {
- sel = ACHANNEL_SETFLAG_CLEAR;
+ return ACHANNEL_SETFLAG_CLEAR;
}
#endif
- break;
- case ANIMTYPE_GROUP:
- if (ale->flag & AGRP_SELECTED) {
- sel = ACHANNEL_SETFLAG_CLEAR;
- }
- break;
- case ANIMTYPE_FCURVE:
- case ANIMTYPE_NLACURVE:
- if (ale->flag & FCURVE_SELECTED) {
- sel = ACHANNEL_SETFLAG_CLEAR;
- }
- break;
- case ANIMTYPE_SHAPEKEY:
- if (ale->flag & KEYBLOCK_SEL) {
- sel = ACHANNEL_SETFLAG_CLEAR;
- }
- break;
- case ANIMTYPE_NLATRACK:
- if (ale->flag & NLATRACK_SELECTED) {
- sel = ACHANNEL_SETFLAG_CLEAR;
- }
- break;
+ break;
+ case ANIMTYPE_GROUP:
+ if (ale->flag & AGRP_SELECTED) {
+ return ACHANNEL_SETFLAG_CLEAR;
+ }
+ break;
+ case ANIMTYPE_FCURVE:
+ case ANIMTYPE_NLACURVE:
+ if (ale->flag & FCURVE_SELECTED) {
+ return ACHANNEL_SETFLAG_CLEAR;
+ }
+ break;
+ case ANIMTYPE_SHAPEKEY:
+ if (ale->flag & KEYBLOCK_SEL) {
+ return ACHANNEL_SETFLAG_CLEAR;
+ }
+ break;
+ case ANIMTYPE_NLATRACK:
+ if (ale->flag & NLATRACK_SELECTED) {
+ return ACHANNEL_SETFLAG_CLEAR;
+ }
+ break;
- case ANIMTYPE_FILLACTD: /* Action Expander */
- case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */
- case ANIMTYPE_DSLAM:
- case ANIMTYPE_DSCAM:
- case ANIMTYPE_DSCACHEFILE:
- case ANIMTYPE_DSCUR:
- case ANIMTYPE_DSSKEY:
- case ANIMTYPE_DSWOR:
- case ANIMTYPE_DSPART:
- case ANIMTYPE_DSMBALL:
- case ANIMTYPE_DSARM:
- case ANIMTYPE_DSMESH:
- case ANIMTYPE_DSNTREE:
- case ANIMTYPE_DSTEX:
- case ANIMTYPE_DSLAT:
- case ANIMTYPE_DSLINESTYLE:
- case ANIMTYPE_DSSPK:
- case ANIMTYPE_DSGPENCIL:
- case ANIMTYPE_DSMCLIP:
- case ANIMTYPE_DSHAIR:
- case ANIMTYPE_DSPOINTCLOUD:
- case ANIMTYPE_DSVOLUME:
- case ANIMTYPE_DSSIMULATION: {
- if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
- sel = ACHANNEL_SETFLAG_CLEAR;
- }
- break;
+ case ANIMTYPE_FILLACTD: /* Action Expander */
+ case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */
+ case ANIMTYPE_DSLAM:
+ case ANIMTYPE_DSCAM:
+ case ANIMTYPE_DSCACHEFILE:
+ case ANIMTYPE_DSCUR:
+ case ANIMTYPE_DSSKEY:
+ case ANIMTYPE_DSWOR:
+ case ANIMTYPE_DSPART:
+ case ANIMTYPE_DSMBALL:
+ case ANIMTYPE_DSARM:
+ case ANIMTYPE_DSMESH:
+ case ANIMTYPE_DSNTREE:
+ case ANIMTYPE_DSTEX:
+ case ANIMTYPE_DSLAT:
+ case ANIMTYPE_DSLINESTYLE:
+ case ANIMTYPE_DSSPK:
+ case ANIMTYPE_DSGPENCIL:
+ case ANIMTYPE_DSMCLIP:
+ case ANIMTYPE_DSHAIR:
+ case ANIMTYPE_DSPOINTCLOUD:
+ case ANIMTYPE_DSVOLUME:
+ case ANIMTYPE_DSSIMULATION: {
+ if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
+ return ACHANNEL_SETFLAG_CLEAR;
}
- case ANIMTYPE_GPLAYER:
- if (ale->flag & GP_LAYER_SELECT) {
- sel = ACHANNEL_SETFLAG_CLEAR;
- }
- break;
- case ANIMTYPE_MASKLAYER:
- if (ale->flag & MASK_LAYERFLAG_SELECT) {
- sel = ACHANNEL_SETFLAG_CLEAR;
- }
- break;
+ break;
}
+ case ANIMTYPE_GPLAYER:
+ if (ale->flag & GP_LAYER_SELECT) {
+ return ACHANNEL_SETFLAG_CLEAR;
+ }
+ break;
+ case ANIMTYPE_MASKLAYER:
+ if (ale->flag & MASK_LAYERFLAG_SELECT) {
+ return ACHANNEL_SETFLAG_CLEAR;
+ }
+ break;
}
}
- /* Now set the flags */
+ return ACHANNEL_SETFLAG_ADD;
+}
+
+static void anim_channels_select_set(bAnimContext *ac,
+ const ListBase anim_data,
+ eAnimChannels_SetFlag sel)
+{
+ bAnimListElem *ale;
+
for (ale = anim_data.first; ale; ale = ale->next) {
switch (ale->type) {
case ANIMTYPE_SCENE: {
@@ -454,8 +452,22 @@ void ANIM_deselect_anim_channels(
}
}
}
+}
+
+/* Set selection state of all animation channels in the context. */
+void ANIM_anim_channels_select_set(bAnimContext *ac, eAnimChannels_SetFlag sel)
+{
+ ListBase anim_data = anim_channels_for_selection(ac);
+ anim_channels_select_set(ac, anim_data, sel);
+ ANIM_animdata_freelist(&anim_data);
+}
- /* Cleanup */
+/* Toggle selection state of all animation channels in the context. */
+void ANIM_anim_channels_select_toggle(bAnimContext *ac)
+{
+ ListBase anim_data = anim_channels_for_selection(ac);
+ const eAnimChannels_SetFlag sel = anim_channels_selection_flag_for_toggle(anim_data);
+ anim_channels_select_set(ac, anim_data, sel);
ANIM_animdata_freelist(&anim_data);
}
@@ -1470,8 +1482,8 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
rearrange_driver_channels(&ac, adt, mode);
break;
- case ANIMCONT_ACTION: /* Single Action only... */
- case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME...
+ case ANIMCONT_ACTION: /* Single Action only... */
+ case ANIMCONT_SHAPEKEY: /* DOUBLE CHECK ME... */
{
if (adt->action) {
rearrange_action_channels(&ac, adt->action, mode);
@@ -1939,7 +1951,7 @@ static const EnumPropertyItem prop_animchannel_setflag_types[] = {
};
/* defines for set animation-channel settings */
-// TODO: could add some more types, but those are really quite dependent on the mode...
+/* TODO: could add some more types, but those are really quite dependent on the mode... */
static const EnumPropertyItem prop_animchannel_settings_types[] = {
{ACHANNEL_SETTING_PROTECT, "PROTECT", 0, "Protect", ""},
{ACHANNEL_SETTING_MUTE, "MUTE", 0, "Mute", ""},
@@ -1948,12 +1960,14 @@ static const EnumPropertyItem prop_animchannel_settings_types[] = {
/* ------------------- */
-/* Set/clear a particular flag (setting) for all selected + visible channels
- * setting: the setting to modify
- * mode: eAnimChannels_SetFlag
- * onlysel: only selected channels get the flag set
+/**
+ * Set/clear a particular flag (setting) for all selected + visible channels
+ * \param setting: the setting to modify.
+ * \param mode: eAnimChannels_SetFlag.
+ * \param onlysel: only selected channels get the flag set.
+ *
+ * TODO: enable a setting which turns flushing on/off?.
*/
-// TODO: enable a setting which turns flushing on/off?
static void setflag_anim_channels(bAnimContext *ac,
eAnimChannel_Settings setting,
eAnimChannels_SetFlag mode,
@@ -2524,7 +2538,7 @@ static void ANIM_OT_channels_find(wmOperatorType *ot)
/* ********************** Select All Operator *********************** */
-static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
+static int animchannels_selectall_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
@@ -2537,16 +2551,16 @@ static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
const int action = RNA_enum_get(op->ptr, "action");
switch (action) {
case SEL_TOGGLE:
- ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_ADD);
+ ANIM_anim_channels_select_toggle(&ac);
break;
case SEL_SELECT:
- ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_ADD);
+ ANIM_anim_channels_select_set(&ac, ACHANNEL_SETFLAG_ADD);
break;
case SEL_DESELECT:
- ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_CLEAR);
+ ANIM_anim_channels_select_set(&ac, ACHANNEL_SETFLAG_CLEAR);
break;
case SEL_INVERT:
- ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_INVERT);
+ ANIM_anim_channels_select_set(&ac, ACHANNEL_SETFLAG_INVERT);
break;
default:
BLI_assert(0);
@@ -2567,7 +2581,7 @@ static void ANIM_OT_channels_select_all(wmOperatorType *ot)
ot->description = "Toggle selection of all animation channels";
/* api callbacks */
- ot->exec = animchannels_deselectall_exec;
+ ot->exec = animchannels_selectall_exec;
ot->poll = animedit_poll_channels_nla_tweakmode_off;
/* flags */
@@ -2668,7 +2682,11 @@ static int animchannels_box_select_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rcti(op, &rect);
if (!extend) {
- ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_CLEAR);
+ printf("\n\n\n\033[92mBox-selecting channels without extend!\033[0m\n");
+ ANIM_anim_channels_select_set(&ac, ACHANNEL_SETFLAG_CLEAR);
+ }
+ else {
+ printf("\n\n\n\033[91mBox-selecting channels WITH extend!\033[0m\n");
}
if (select) {
@@ -2846,7 +2864,338 @@ static void ANIM_OT_channels_rename(wmOperatorType *ot)
/* ******************** Mouse-Click Operator *********************** */
/* Handle selection changes due to clicking on channels. Settings will get caught by UI code... */
-static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, short selectmode)
+static int click_select_channel_scene(bAnimListElem *ale,
+ const short /* eEditKeyframes_Select or -1 */ selectmode)
+{
+ Scene *sce = (Scene *)ale->data;
+ AnimData *adt = sce->adt;
+
+ /* set selection status */
+ if (selectmode == SELECT_INVERT) {
+ /* swap select */
+ sce->flag ^= SCE_DS_SELECTED;
+ if (adt) {
+ adt->flag ^= ADT_UI_SELECTED;
+ }
+ }
+ else {
+ sce->flag |= SCE_DS_SELECTED;
+ if (adt) {
+ adt->flag |= ADT_UI_SELECTED;
+ }
+ }
+ return (ND_ANIMCHAN | NA_SELECTED);
+}
+
+static int click_select_channel_object(bContext *C,
+ bAnimContext *ac,
+ bAnimListElem *ale,
+ const short /* eEditKeyframes_Select or -1 */ selectmode)
+{
+ ViewLayer *view_layer = ac->view_layer;
+ Base *base = (Base *)ale->data;
+ Object *ob = base->object;
+ AnimData *adt = ob->adt;
+
+ if ((base->flag & BASE_SELECTABLE) == 0) {
+ return 0;
+ }
+
+ if (selectmode == SELECT_INVERT) {
+ /* swap select */
+ ED_object_base_select(base, BA_INVERT);
+
+ if (adt) {
+ adt->flag ^= ADT_UI_SELECTED;
+ }
+ }
+ else {
+ Base *b;
+
+ /* deselect all */
+ /* TODO: should this deselect all other types of channels too? */
+ for (b = view_layer->object_bases.first; b; b = b->next) {
+ ED_object_base_select(b, BA_DESELECT);
+ if (b->object->adt) {
+ b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
+ }
+ }
+
+ /* select object now */
+ ED_object_base_select(base, BA_SELECT);
+ if (adt) {
+ adt->flag |= ADT_UI_SELECTED;
+ }
+ }
+
+ /* change active object - regardless of whether it is now selected [T37883] */
+ ED_object_base_activate(C, base); /* adds notifier */
+
+ if ((adt) && (adt->flag & ADT_UI_SELECTED)) {
+ adt->flag |= ADT_UI_ACTIVE;
+ }
+
+ /* Ensure we exit editmode on whatever object was active before
+ * to avoid getting stuck there - T48747. */
+ if (ob != CTX_data_edit_object(C)) {
+ ED_object_editmode_exit(C, EM_FREEDATA);
+ }
+ return (ND_ANIMCHAN | NA_SELECTED);
+}
+
+static int click_select_channel_dummy(bAnimContext *ac,
+ bAnimListElem *ale,
+ const short /* eEditKeyframes_Select or -1 */ selectmode)
+{
+ if (ale->adt == NULL) {
+ return 0;
+ }
+
+ /* select/deselect */
+ if (selectmode == SELECT_INVERT) {
+ /* inverse selection status of this AnimData block only */
+ ale->adt->flag ^= ADT_UI_SELECTED;
+ }
+ else {
+ /* select AnimData block by itself */
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
+ ale->adt->flag |= ADT_UI_SELECTED;
+ }
+
+ /* set active? */
+ if (ale->adt->flag & ADT_UI_SELECTED) {
+ ale->adt->flag |= ADT_UI_ACTIVE;
+ }
+
+ return (ND_ANIMCHAN | NA_SELECTED);
+}
+
+static int click_select_channel_group(bAnimContext *ac,
+ bAnimListElem *ale,
+ const short /* eEditKeyframes_Select or -1 */ selectmode,
+ const int filter)
+{
+ bActionGroup *agrp = (bActionGroup *)ale->data;
+ Object *ob = NULL;
+ bPoseChannel *pchan = NULL;
+
+ /* Armatures-Specific Feature:
+ * Since groups are used to collect F-Curves of the same Bone by default
+ * (via Keying Sets) so that they can be managed better, we try to make
+ * things here easier for animators by mapping group selection to bone
+ * selection.
+ *
+ * Only do this if "Only Selected" dopesheet filter is not active, or else it
+ * becomes too unpredictable/tricky to manage
+ */
+ if ((ac->ads->filterflag & ADS_FILTER_ONLYSEL) == 0) {
+ if ((ale->id) && (GS(ale->id->name) == ID_OB)) {
+ ob = (Object *)ale->id;
+
+ if (ob->type == OB_ARMATURE) {
+ /* Assume for now that any group with corresponding name is what we want
+ * (i.e. for an armature whose location is animated, things would break
+ * if the user were to add a bone named "Location").
+ *
+ * TODO: check the first F-Curve or so to be sure...
+ */
+ pchan = BKE_pose_channel_find_name(ob->pose, agrp->name);
+ }
+ }
+ }
+
+ /* select/deselect group */
+ if (selectmode == SELECT_INVERT) {
+ /* inverse selection status of this group only */
+ agrp->flag ^= AGRP_SELECTED;
+ }
+ else if (selectmode == -1) {
+ /* select all in group (and deselect everything else) */
+ FCurve *fcu;
+
+ /* deselect all other channels */
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
+ if (pchan) {
+ ED_pose_deselect_all(ob, SEL_DESELECT, false);
+ }
+
+ /* only select channels in group and group itself */
+ for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) {
+ fcu->flag |= FCURVE_SELECTED;
+ }
+ agrp->flag |= AGRP_SELECTED;
+ }
+ else {
+ /* select group by itself */
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
+ if (pchan) {
+ ED_pose_deselect_all(ob, SEL_DESELECT, false);
+ }
+
+ agrp->flag |= AGRP_SELECTED;
+ }
+
+ /* if group is selected now, make group the 'active' one in the visible list */
+ if (agrp->flag & AGRP_SELECTED) {
+ ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
+ if (pchan) {
+ ED_pose_bone_select(ob, pchan, true);
+ }
+ }
+ else {
+ ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, NULL, ANIMTYPE_GROUP);
+ if (pchan) {
+ ED_pose_bone_select(ob, pchan, false);
+ }
+ }
+
+ return (ND_ANIMCHAN | NA_SELECTED);
+}
+
+static int click_select_channel_fcurve(bAnimContext *ac,
+ bAnimListElem *ale,
+ const short /* eEditKeyframes_Select or -1 */ selectmode,
+ const int filter)
+{
+ FCurve *fcu = (FCurve *)ale->data;
+
+ /* select/deselect */
+ if (selectmode == SELECT_INVERT) {
+ /* inverse selection status of this F-Curve only */
+ fcu->flag ^= FCURVE_SELECTED;
+ }
+ else {
+ /* select F-Curve by itself */
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
+ fcu->flag |= FCURVE_SELECTED;
+ }
+
+ /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */
+ if (fcu->flag & FCURVE_SELECTED) {
+ ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type);
+ }
+
+ return (ND_ANIMCHAN | NA_SELECTED);
+}
+
+static int click_select_channel_shapekey(bAnimContext *ac,
+ bAnimListElem *ale,
+ const short /* eEditKeyframes_Select or -1 */ selectmode)
+{
+ KeyBlock *kb = (KeyBlock *)ale->data;
+
+ /* select/deselect */
+ if (selectmode == SELECT_INVERT) {
+ /* inverse selection status of this ShapeKey only */
+ kb->flag ^= KEYBLOCK_SEL;
+ }
+ else {
+ /* select ShapeKey by itself */
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
+ kb->flag |= KEYBLOCK_SEL;
+ }
+
+ return (ND_ANIMCHAN | NA_SELECTED);
+}
+
+static int click_select_channel_nlacontrols(bAnimListElem *ale)
+{
+ AnimData *adt = (AnimData *)ale->data;
+
+ /* Toggle expand:
+ * - Although the triangle widget already allows this,
+ * since there's nothing else that can be done here now,
+ * let's just use it for easier expand/collapse for now.
+ */
+ adt->flag ^= ADT_NLA_SKEYS_COLLAPSED;
+
+ return (ND_ANIMCHAN | NA_EDITED);
+}
+
+static int click_select_channel_gpdatablock(bAnimListElem *ale)
+{
+ bGPdata *gpd = (bGPdata *)ale->data;
+
+ /* Toggle expand:
+ * - Although the triangle widget already allows this,
+ * the whole channel can also be used for this purpose.
+ */
+ gpd->flag ^= GP_DATA_EXPAND;
+
+ return (ND_ANIMCHAN | NA_EDITED);
+}
+
+static int click_select_channel_gplayer(bContext *C,
+ bAnimContext *ac,
+ bAnimListElem *ale,
+ const short /* eEditKeyframes_Select or -1 */ selectmode,
+ const int filter)
+{
+ bGPdata *gpd = (bGPdata *)ale->id;
+ bGPDlayer *gpl = (bGPDlayer *)ale->data;
+
+ /* select/deselect */
+ if (selectmode == SELECT_INVERT) {
+ /* invert selection status of this layer only */
+ gpl->flag ^= GP_LAYER_SELECT;
+ }
+ else {
+ /* select layer by itself */
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
+ gpl->flag |= GP_LAYER_SELECT;
+ }
+
+ /* change active layer, if this is selected (since we must always have an active layer) */
+ if (gpl->flag & GP_LAYER_SELECT) {
+ ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, gpl, ANIMTYPE_GPLAYER);
+ /* update other layer status */
+ BKE_gpencil_layer_active_set(gpd, gpl);
+ BKE_gpencil_layer_autolock_set(gpd, false);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
+ }
+
+ /* Grease Pencil updates */
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
+ return (ND_ANIMCHAN | NA_EDITED); /* Animation Editors updates */
+}
+
+static int click_select_channel_maskdatablock(bAnimListElem *ale)
+{
+ Mask *mask = (Mask *)ale->data;
+
+ /* Toggle expand
+ * - Although the triangle widget already allows this,
+ * the whole channel can also be used for this purpose.
+ */
+ mask->flag ^= MASK_ANIMF_EXPAND;
+
+ return (ND_ANIMCHAN | NA_EDITED);
+}
+
+static int click_select_channel_masklayer(bAnimContext *ac,
+ bAnimListElem *ale,
+ const short /* eEditKeyframes_Select or -1 */ selectmode)
+{
+ MaskLayer *masklay = (MaskLayer *)ale->data;
+
+ /* select/deselect */
+ if (selectmode == SELECT_INVERT) {
+ /* invert selection status of this layer only */
+ masklay->flag ^= MASK_LAYERFLAG_SELECT;
+ }
+ else {
+ /* select layer by itself */
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
+ masklay->flag |= MASK_LAYERFLAG_SELECT;
+ }
+
+ return (ND_ANIMCHAN | NA_EDITED);
+}
+
+static int mouse_anim_channels(bContext *C,
+ bAnimContext *ac,
+ const int channel_index,
+ const short /* eEditKeyframes_Select or -1 */ selectmode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
@@ -2883,84 +3232,12 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
/* action to take depends on what channel we've got */
/* WARNING: must keep this in sync with the equivalent function in nla_channels.c */
switch (ale->type) {
- case ANIMTYPE_SCENE: {
- Scene *sce = (Scene *)ale->data;
- AnimData *adt = sce->adt;
-
- /* set selection status */
- if (selectmode == SELECT_INVERT) {
- /* swap select */
- sce->flag ^= SCE_DS_SELECTED;
- if (adt) {
- adt->flag ^= ADT_UI_SELECTED;
- }
- }
- else {
- sce->flag |= SCE_DS_SELECTED;
- if (adt) {
- adt->flag |= ADT_UI_SELECTED;
- }
- }
-
- notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
+ case ANIMTYPE_SCENE:
+ notifierFlags |= click_select_channel_scene(ale, selectmode);
break;
- }
- case ANIMTYPE_OBJECT: {
-#if 0
- bDopeSheet *ads = (bDopeSheet *)ac->data;
- Scene *sce = (Scene *)ads->source;
-#endif
- ViewLayer *view_layer = ac->view_layer;
- Base *base = (Base *)ale->data;
- Object *ob = base->object;
- AnimData *adt = ob->adt;
-
- /* set selection status */
- if (base->flag & BASE_SELECTABLE) {
- if (selectmode == SELECT_INVERT) {
- /* swap select */
- ED_object_base_select(base, BA_INVERT);
-
- if (adt) {
- adt->flag ^= ADT_UI_SELECTED;
- }
- }
- else {
- Base *b;
-
- /* deselect all */
- /* TODO: should this deselect all other types of channels too? */
- for (b = view_layer->object_bases.first; b; b = b->next) {
- ED_object_base_select(b, BA_DESELECT);
- if (b->object->adt) {
- b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
- }
- }
-
- /* select object now */
- ED_object_base_select(base, BA_SELECT);
- if (adt) {
- adt->flag |= ADT_UI_SELECTED;
- }
- }
-
- /* change active object - regardless of whether it is now selected [T37883] */
- ED_object_base_activate(C, base); /* adds notifier */
-
- if ((adt) && (adt->flag & ADT_UI_SELECTED)) {
- adt->flag |= ADT_UI_ACTIVE;
- }
-
- /* Ensure we exit editmode on whatever object was active before
- * to avoid getting stuck there - T48747. */
- if (ob != CTX_data_edit_object(C)) {
- ED_object_editmode_exit(C, EM_FREEDATA);
- }
-
- notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
- }
+ case ANIMTYPE_OBJECT:
+ notifierFlags |= click_select_channel_object(C, ac, ale, selectmode);
break;
- }
case ANIMTYPE_FILLACTD: /* Action Expander */
case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */
case ANIMTYPE_DSLAM:
@@ -2983,231 +3260,34 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
case ANIMTYPE_DSHAIR:
case ANIMTYPE_DSPOINTCLOUD:
case ANIMTYPE_DSVOLUME:
- case ANIMTYPE_DSSIMULATION: {
- /* sanity checking... */
- if (ale->adt) {
- /* select/deselect */
- if (selectmode == SELECT_INVERT) {
- /* inverse selection status of this AnimData block only */
- ale->adt->flag ^= ADT_UI_SELECTED;
- }
- else {
- /* select AnimData block by itself */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- ale->adt->flag |= ADT_UI_SELECTED;
- }
-
- /* set active? */
- if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
- ale->adt->flag |= ADT_UI_ACTIVE;
- }
- }
-
- notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
+ case ANIMTYPE_DSSIMULATION:
+ notifierFlags |= click_select_channel_dummy(ac, ale, selectmode);
break;
- }
- case ANIMTYPE_GROUP: {
- bActionGroup *agrp = (bActionGroup *)ale->data;
-
- Object *ob = NULL;
- bPoseChannel *pchan = NULL;
-
- /* Armatures-Specific Feature:
- * Since groups are used to collect F-Curves of the same Bone by default
- * (via Keying Sets) so that they can be managed better, we try to make
- * things here easier for animators by mapping group selection to bone
- * selection.
- *
- * Only do this if "Only Selected" dopesheet filter is not active, or else it
- * becomes too unpredictable/tricky to manage
- */
- if ((ac->ads->filterflag & ADS_FILTER_ONLYSEL) == 0) {
- if ((ale->id) && (GS(ale->id->name) == ID_OB)) {
- ob = (Object *)ale->id;
-
- if (ob->type == OB_ARMATURE) {
- /* Assume for now that any group with corresponding name is what we want
- * (i.e. for an armature whose location is animated, things would break
- * if the user were to add a bone named "Location").
- *
- * TODO: check the first F-Curve or so to be sure...
- */
- pchan = BKE_pose_channel_find_name(ob->pose, agrp->name);
- }
- }
- }
-
- /* select/deselect group */
- if (selectmode == SELECT_INVERT) {
- /* inverse selection status of this group only */
- agrp->flag ^= AGRP_SELECTED;
- }
- else if (selectmode == -1) {
- /* select all in group (and deselect everything else) */
- FCurve *fcu;
-
- /* deselect all other channels */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- if (pchan) {
- ED_pose_deselect_all(ob, SEL_DESELECT, false);
- }
-
- /* only select channels in group and group itself */
- for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) {
- fcu->flag |= FCURVE_SELECTED;
- }
- agrp->flag |= AGRP_SELECTED;
- }
- else {
- /* select group by itself */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- if (pchan) {
- ED_pose_deselect_all(ob, SEL_DESELECT, false);
- }
-
- agrp->flag |= AGRP_SELECTED;
- }
-
- /* if group is selected now, make group the 'active' one in the visible list */
- if (agrp->flag & AGRP_SELECTED) {
- ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
- if (pchan) {
- ED_pose_bone_select(ob, pchan, true);
- }
- }
- else {
- ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, NULL, ANIMTYPE_GROUP);
- if (pchan) {
- ED_pose_bone_select(ob, pchan, false);
- }
- }
-
- notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
+ case ANIMTYPE_GROUP:
+ notifierFlags |= click_select_channel_group(ac, ale, selectmode, filter);
break;
- }
case ANIMTYPE_FCURVE:
- case ANIMTYPE_NLACURVE: {
- FCurve *fcu = (FCurve *)ale->data;
-
- /* select/deselect */
- if (selectmode == SELECT_INVERT) {
- /* inverse selection status of this F-Curve only */
- fcu->flag ^= FCURVE_SELECTED;
- }
- else {
- /* select F-Curve by itself */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- fcu->flag |= FCURVE_SELECTED;
- }
-
- /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */
- if (fcu->flag & FCURVE_SELECTED) {
- ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type);
- }
-
- notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
+ case ANIMTYPE_NLACURVE:
+ notifierFlags |= click_select_channel_fcurve(ac, ale, selectmode, filter);
break;
- }
- case ANIMTYPE_SHAPEKEY: {
- KeyBlock *kb = (KeyBlock *)ale->data;
-
- /* select/deselect */
- if (selectmode == SELECT_INVERT) {
- /* inverse selection status of this ShapeKey only */
- kb->flag ^= KEYBLOCK_SEL;
- }
- else {
- /* select ShapeKey by itself */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- kb->flag |= KEYBLOCK_SEL;
- }
-
- notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
+ case ANIMTYPE_SHAPEKEY:
+ notifierFlags |= click_select_channel_shapekey(ac, ale, selectmode);
break;
- }
- case ANIMTYPE_NLACONTROLS: {
- AnimData *adt = (AnimData *)ale->data;
-
- /* Toggle expand:
- * - Although the triangle widget already allows this,
- * since there's nothing else that can be done here now,
- * let's just use it for easier expand/collapse for now.
- */
- adt->flag ^= ADT_NLA_SKEYS_COLLAPSED;
-
- notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
+ case ANIMTYPE_NLACONTROLS:
+ notifierFlags |= click_select_channel_nlacontrols(ale);
break;
- }
- case ANIMTYPE_GPDATABLOCK: {
- bGPdata *gpd = (bGPdata *)ale->data;
-
- /* Toggle expand:
- * - Although the triangle widget already allows this,
- * the whole channel can also be used for this purpose.
- */
- gpd->flag ^= GP_DATA_EXPAND;
-
- notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
+ case ANIMTYPE_GPDATABLOCK:
+ notifierFlags |= click_select_channel_gpdatablock(ale);
break;
- }
- case ANIMTYPE_GPLAYER: {
- bGPdata *gpd = (bGPdata *)ale->id;
- bGPDlayer *gpl = (bGPDlayer *)ale->data;
-
- /* select/deselect */
- if (selectmode == SELECT_INVERT) {
- /* invert selection status of this layer only */
- gpl->flag ^= GP_LAYER_SELECT;
- }
- else {
- /* select layer by itself */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- gpl->flag |= GP_LAYER_SELECT;
- }
-
- /* change active layer, if this is selected (since we must always have an active layer) */
- if (gpl->flag & GP_LAYER_SELECT) {
- ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, gpl, ANIMTYPE_GPLAYER);
- /* update other layer status */
- BKE_gpencil_layer_active_set(gpd, gpl);
- BKE_gpencil_layer_autolock_set(gpd, false);
- DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
- }
-
- /* Grease Pencil updates */
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
- notifierFlags |= (ND_ANIMCHAN | NA_EDITED); /* Animation Editors updates */
+ case ANIMTYPE_GPLAYER:
+ notifierFlags |= click_select_channel_gplayer(C, ac, ale, selectmode, filter);
break;
- }
- case ANIMTYPE_MASKDATABLOCK: {
- Mask *mask = (Mask *)ale->data;
-
- /* Toggle expand
- * - Although the triangle widget already allows this,
- * the whole channel can also be used for this purpose.
- */
- mask->flag ^= MASK_ANIMF_EXPAND;
-
- notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
+ case ANIMTYPE_MASKDATABLOCK:
+ notifierFlags |= click_select_channel_maskdatablock(ale);
break;
- }
- case ANIMTYPE_MASKLAYER: {
- MaskLayer *masklay = (MaskLayer *)ale->data;
-
- /* select/deselect */
- if (selectmode == SELECT_INVERT) {
- /* invert selection status of this layer only */
- masklay->flag ^= MASK_LAYERFLAG_SELECT;
- }
- else {
- /* select layer by itself */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- masklay->flag |= MASK_LAYERFLAG_SELECT;
- }
-
- notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
+ case ANIMTYPE_MASKLAYER:
+ notifierFlags |= click_select_channel_masklayer(ac, ale, selectmode);
break;
- }
default:
if (G.debug & G_DEBUG) {
printf("Error: Invalid channel type in mouse_anim_channels()\n");
@@ -3295,11 +3375,11 @@ static void ANIM_OT_channels_click(wmOperatorType *ot)
/* properties */
/* NOTE: don't save settings, otherwise, can end up with some weird behavior (sticky extend) */
- prop = RNA_def_boolean(ot->srna, "extend", false, "Extend Select", ""); // SHIFTKEY
+ prop = RNA_def_boolean(ot->srna, "extend", false, "Extend Select", ""); /* SHIFTKEY */
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(
- ot->srna, "children_only", false, "Select Children Only", ""); // CTRLKEY|SHIFTKEY
+ ot->srna, "children_only", false, "Select Children Only", ""); /* CTRLKEY|SHIFTKEY */
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
@@ -3443,7 +3523,7 @@ void ED_operatortypes_animchannels(void)
WM_operatortype_append(ANIM_OT_channels_ungroup);
}
-// TODO: check on a poll callback for this, to get hotkeys into menus
+/* TODO: check on a poll callback for this, to get hotkeys into menus */
void ED_keymap_animchannels(wmKeyConfig *keyconf)
{
WM_keymap_ensure(keyconf, "Animation Channels", 0, 0);
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 4fb68b614ff..b2225ec138f 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -108,7 +108,7 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
* we'd be calling property update functions here too ... */
DEG_id_tag_update(id,
ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY |
- ID_RECALC_ANIMATION); // XXX or do we want something more restrictive?
+ ID_RECALC_ANIMATION); /* XXX or do we want something more restrictive? */
}
}
@@ -121,7 +121,7 @@ void ANIM_id_update(Main *bmain, ID *id)
bmain,
id,
ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY |
- ID_RECALC_ANIMATION); // XXX or do we want something more restrictive?
+ ID_RECALC_ANIMATION); /* XXX or do we want something more restrictive? */
}
}
@@ -199,97 +199,64 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
}
}
-/* perform syncing updates for F-Curves */
-static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
- bAnimListElem *ale,
- FCurve **active_fcurve)
+static void animchan_sync_fcurve_scene(bAnimListElem *ale)
{
- FCurve *fcu = (FCurve *)ale->data;
ID *owner_id = ale->id;
+ BLI_assert(GS(owner_id->name) == ID_SCE);
+ Scene *scene = (Scene *)owner_id;
+ FCurve *fcu = (FCurve *)ale->data;
- /* major priority is selection status, so refer to the checks done in anim_filter.c
- * skip_fcurve_selected_data() for reference about what's going on here...
- */
- if (ELEM(NULL, fcu, fcu->rna_path, owner_id)) {
+ /* only affect if F-Curve involves sequence_editor.sequences */
+ if (!strstr(fcu->rna_path, "sequences_all")) {
return;
}
- if (GS(owner_id->name) == ID_SCE) {
- Scene *scene = (Scene *)owner_id;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
- /* only affect if F-Curve involves sequence_editor.sequences */
- if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
- char *seq_name;
+ /* get strip name, and check if this strip is selected */
+ char *seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
+ Sequence *seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
+ if (seq_name) {
+ MEM_freeN(seq_name);
+ }
- /* get strip name, and check if this strip is selected */
- seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
- seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
- if (seq_name) {
- MEM_freeN(seq_name);
- }
+ if (seq == NULL) {
+ return;
+ }
- /* update selection status */
- if (seq) {
- if (seq->flag & SELECT) {
- fcu->flag |= FCURVE_SELECTED;
- }
- else {
- fcu->flag &= ~FCURVE_SELECTED;
- }
- }
- }
+ /* update selection status */
+ if (seq->flag & SELECT) {
+ fcu->flag |= FCURVE_SELECTED;
}
- else if (GS(owner_id->name) == ID_NT) {
- bNodeTree *ntree = (bNodeTree *)owner_id;
-
- /* check for selected nodes */
- if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) {
- bNode *node;
- char *node_name;
-
- /* get strip name, and check if this strip is selected */
- node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
- node = nodeFindNodebyName(ntree, node_name);
- if (node_name) {
- MEM_freeN(node_name);
- }
+ else {
+ fcu->flag &= ~FCURVE_SELECTED;
+ }
+}
- /* update selection/active status */
- if (node) {
- /* update selection status */
- if (node->flag & NODE_SELECT) {
- fcu->flag |= FCURVE_SELECTED;
- }
- else {
- fcu->flag &= ~FCURVE_SELECTED;
- }
+/* perform syncing updates for F-Curves */
+static void animchan_sync_fcurve(bAnimListElem *ale)
+{
+ FCurve *fcu = (FCurve *)ale->data;
+ ID *owner_id = ale->id;
- /* update active status */
- /* XXX: this may interfere with setting bones as active if both exist at once;
- * then again, if that's the case, production setups aren't likely to be animating
- * nodes while working with bones?
- */
- if (node->flag & NODE_ACTIVE) {
- if (*active_fcurve == NULL) {
- fcu->flag |= FCURVE_ACTIVE;
- *active_fcurve = fcu;
- }
- else {
- fcu->flag &= ~FCURVE_ACTIVE;
- }
- }
- else {
- fcu->flag &= ~FCURVE_ACTIVE;
- }
- }
- }
+ /* major priority is selection status, so refer to the checks done in anim_filter.c
+ * skip_fcurve_selected_data() for reference about what's going on here...
+ */
+ if (ELEM(NULL, fcu, fcu->rna_path, owner_id)) {
+ return;
+ }
+
+ switch (GS(owner_id->name)) {
+ case ID_SCE:
+ animchan_sync_fcurve_scene(ale);
+ break;
+ default:
+ break;
}
}
/* perform syncing updates for GPencil Layers */
-static void animchan_sync_gplayer(bAnimContext *UNUSED(ac), bAnimListElem *ale)
+static void animchan_sync_gplayer(bAnimListElem *ale)
{
bGPDlayer *gpl = (bGPDlayer *)ale->data;
@@ -321,7 +288,6 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
int filter;
bActionGroup *active_agrp = NULL;
- FCurve *active_fcurve = NULL;
/* get animation context info for filtering the channels */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -345,11 +311,11 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
break;
case ANIMTYPE_FCURVE:
- animchan_sync_fcurve(&ac, ale, &active_fcurve);
+ animchan_sync_fcurve(ale);
break;
case ANIMTYPE_GPLAYER:
- animchan_sync_gplayer(&ac, ale);
+ animchan_sync_gplayer(ale);
break;
}
}
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 73df0518f06..aca332ff0fe 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -126,8 +126,11 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
/* *************************************************** */
/* SCENE FRAME RANGE */
-/* Draw frame range guides (for scene frame range) in background */
-// TODO: Should we still show these when preview range is enabled?
+/**
+ * Draw frame range guides (for scene frame range) in background.
+ *
+ * TODO: Should we still show these when preview range is enabled?
+ */
void ANIM_draw_framerange(Scene *scene, View2D *v2d)
{
/* draw darkened area outside of active timeline frame range */
@@ -167,8 +170,11 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d)
/* *************************************************** */
/* NLA-MAPPING UTILITIES (required for drawing and also editing keyframes) */
-/* Obtain the AnimData block providing NLA-mapping for the given channel (if applicable) */
-// TODO: do not supply return this if the animdata tells us that there is no mapping to perform
+/**
+ * Obtain the AnimData block providing NLA-mapping for the given channel (if applicable).
+ *
+ * TODO: do not supply return this if the animdata tells us that there is no mapping to perform.
+ */
AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
{
/* sanity checks */
@@ -182,7 +188,7 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
}
/* apart from strictly keyframe-related contexts, this shouldn't even happen */
- // XXX: nla and channel here may not be necessary...
+ /* XXX: nla and channel here may not be necessary... */
if (ELEM(ac->datatype,
ANIMCONT_ACTION,
ANIMCONT_SHAPEKEY,
@@ -391,7 +397,7 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo
v4[0] = bezt->vec[1][0];
v4[1] = bezt->vec[1][1];
- correct_bezpart(v1, v2, v3, v4);
+ BKE_fcurve_correct_bezpart(v1, v2, v3, v4);
BKE_curve_forward_diff_bezier(
v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float[3]));
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index ed119a111be..7cf4cb87fc8 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -142,7 +142,7 @@ static Key *actedit_get_shapekeys(bAnimContext *ac)
}
/* XXX pinning is not available in 'ShapeKey' mode... */
- // if (saction->pin) return NULL;
+ // if (saction->pin) { return NULL; }
/* shapekey data is stored with geometry data */
key = BKE_key_from_object(ob);
@@ -223,9 +223,11 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
case SACTCONT_MASK: /* Mask */ /* XXX review how this mode is handled... */
{
/* TODO, other methods to get the mask */
- // Sequence *seq = BKE_sequencer_active_get(ac->scene);
- // MovieClip *clip = ac->scene->clip;
- // struct Mask *mask = seq ? seq->mask : NULL;
+#if 0
+ Sequence *seq = BKE_sequencer_active_get(ac->scene);
+ MovieClip *clip = ac->scene->clip;
+ struct Mask *mask = seq ? seq->mask : NULL;
+#endif
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
saction->ads.source = (ID *)ac->scene;
@@ -562,12 +564,14 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
/* ............................... */
-/* Add a new animation channel, taking into account the "peek" flag, which is used to just check
+/**
+ * Add a new animation channel, taking into account the "peek" flag, which is used to just check
* whether any channels will be added (but without needing them to actually get created).
*
- * ! This causes the calling function to return early if we're only "peeking" for channels
+ * \warning This causes the calling function to return early if we're only "peeking" for channels.
+ *
+ * XXX: ale_statement stuff is really a hack for one special case. It shouldn't really be needed.
*/
-// XXX: ale_statement stuff is really a hack for one special case. It shouldn't really be needed...
#define ANIMCHANNEL_NEW_CHANNEL_FULL( \
channel_data, channel_type, owner_id, fcurve_owner_id, ale_statement) \
if (filter_mode & ANIMFILTER_TMP_PEEK) { \
@@ -681,7 +685,7 @@ static bAnimListElem *make_new_animlistelem(void *data,
ale->flag = adt->flag;
- // XXX... drivers don't show summary for now
+ /* XXX drivers don't show summary for now. */
ale->key_data = NULL;
ale->datatype = ALE_NONE;
break;
@@ -921,7 +925,7 @@ static bAnimListElem *make_new_animlistelem(void *data,
/* NOTE: we just reuse the same expand filter for this case */
ale->flag = EXPANDED_GPD(gpd);
- // XXX: currently, this is only used for access to its animation data
+ /* XXX: currently, this is only used for access to its animation data */
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
@@ -1169,10 +1173,11 @@ static bool name_matches_dopesheet_filter(bDopeSheet *ads, char *name)
}
/* if we have a match somewhere, this returns true */
- return found;
+ return ((ads->flag & ADS_FLAG_INVERT_FILTER) == 0) ? found : !found;
}
/* fallback/default - just case insensitive, but starts from start of word */
- return BLI_strcasestr(name, ads->searchstr) != NULL;
+ bool found = BLI_strcasestr(name, ads->searchstr) != NULL;
+ return ((ads->flag & ADS_FLAG_INVERT_FILTER) == 0) ? found : !found;
}
/* (Display-)Name-based F-Curve filtering
@@ -1234,7 +1239,7 @@ static bool fcurve_has_errors(FCurve *fcu)
}
/* check variables for other things that need linting... */
- // TODO: maybe it would be more efficient just to have a quick flag for this?
+ /* TODO: maybe it would be more efficient just to have a quick flag for this? */
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
if (dtar->flag & DTAR_FLAG_INVALID) {
@@ -1476,7 +1481,7 @@ static size_t animfilter_action(bAnimContext *ac,
}
/* do groups */
- // TODO: do nested groups?
+ /* TODO: do nested groups? */
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
/* store reference to last channel of group */
if (agrp->channels.last) {
@@ -1725,7 +1730,7 @@ static size_t animdata_filter_shapekey(bAnimContext *ac,
/* Only include this track if selected in a way consistent
* with the filtering requirements. */
if (ANIMCHANNEL_SELOK(SEL_SHAPEKEY(kb))) {
- // TODO: consider 'active' too?
+ /* TODO: consider 'active' too? */
/* owner-id here must be key so that the F-Curve can be resolved... */
ANIMCHANNEL_NEW_CHANNEL(kb, ANIMTYPE_SHAPEKEY, key, NULL);
@@ -1735,7 +1740,7 @@ static size_t animdata_filter_shapekey(bAnimContext *ac,
}
else {
/* just use the action associated with the shapekey */
- // TODO: somehow manage to pass dopesheet info down here too?
+ /* TODO: somehow manage to pass dopesheet info down here too? */
if (key->adt) {
if (filter_mode & ANIMFILTER_ANIMDATA) {
if (ANIMCHANNEL_SELOK(SEL_ANIMDATA(key->adt))) {
@@ -1840,8 +1845,11 @@ static size_t animdata_filter_gpencil_data(ListBase *anim_data,
return items;
}
-/* Grab all Grease Pencil data-blocks in file. */
-// TODO: should this be amalgamated with the dopesheet filtering code?
+/**
+ * Grab all Grease Pencil data-blocks in file.
+ *
+ * TODO: should this be amalgamated with the dope-sheet filtering code?
+ */
static size_t animdata_filter_gpencil(bAnimContext *ac,
ListBase *anim_data,
void *UNUSED(data),
@@ -1930,8 +1938,9 @@ static size_t animdata_filter_ds_gpencil(
tmp_items += animfilter_block_data(ac, &tmp_data, ads, &gpd->id, filter_mode);
/* add Grease Pencil layers */
- // TODO: do these need a separate expander?
- // XXX: what order should these go in?
+
+ /* TODO: do these need a separate expander?
+ * XXX: what order should these go in? */
}
END_ANIMFILTER_SUBCHANNELS;
@@ -1940,7 +1949,7 @@ static size_t animdata_filter_ds_gpencil(
/* include data-expand widget first */
if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
/* check if filtering by active status */
- // XXX: active check here needs checking
+ /* XXX: active check here needs checking */
if (ANIMCHANNEL_ACTIVEOK(gpd)) {
ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_DSGPENCIL, gpd, NULL);
}
@@ -1976,7 +1985,7 @@ static size_t animdata_filter_ds_cachefile(
/* include data-expand widget first */
if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
/* check if filtering by active status */
- // XXX: active check here needs checking
+ /* XXX: active check here needs checking */
if (ANIMCHANNEL_ACTIVEOK(cache_file)) {
ANIMCHANNEL_NEW_CHANNEL(cache_file, ANIMTYPE_DSCACHEFILE, cache_file, NULL);
}
@@ -2027,7 +2036,7 @@ static size_t animdata_filter_mask(Main *bmain,
size_t items = 0;
/* For now, grab mask data-blocks directly from main. */
- // XXX: this is not good...
+ /* XXX: this is not good... */
for (mask = bmain->masks.first; mask; mask = mask->id.next) {
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
@@ -2215,8 +2224,10 @@ static size_t animdata_filter_ds_texture(bAnimContext *ac,
if ((tex->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
/* owner_id as id instead of texture,
* since it'll otherwise be impossible to track the depth. */
- // FIXME: perhaps as a result, textures should NOT be included under materials,
- // but under their own section instead so that free-floating textures can also be animated.
+
+ /* FIXME: perhaps as a result, textures should NOT be included under materials,
+ * but under their own section instead so that free-floating textures can also be animated.
+ */
tmp_items += animdata_filter_ds_nodetree(
ac, &tmp_data, ads, (ID *)tex, tex->nodetree, filter_mode);
}
@@ -2406,7 +2417,7 @@ static void animfilter_modifier_idpoin_cb(void *afm_ptr,
* which would be nice to animate (i.e. texture parameters) but which are not actually
* attached to any other objects/materials/etc. in the scene
*/
-// TODO: do we want an expander for this?
+/* TODO: do we want an expander for this? */
static size_t animdata_filter_ds_modifiers(
bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode)
{
@@ -2900,7 +2911,7 @@ static size_t animdata_filter_ds_scene(
void *cdata = NULL;
/* determine the type of expander channels to use */
- // this is the best way to do this for now...
+ /* this is the best way to do this for now... */
ANIMDATA_FILTER_CASES(
sce, /* Some useless long comment to prevent wrapping by old clang-format versions... */
{/* AnimData - no channel, but consider data */},
@@ -3168,9 +3179,9 @@ static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads,
return sorted_bases;
}
-// TODO: implement pinning...
-// (if and when pinning is done, what we need to do is to provide freeing mechanisms -
-// to protect against data that was deleted).
+/* TODO: implement pinning...
+ * (if and when pinning is done, what we need to do is to provide freeing mechanisms -
+ * to protect against data that was deleted). */
static size_t animdata_filter_dopesheet(bAnimContext *ac,
ListBase *anim_data,
bDopeSheet *ads,
@@ -3227,7 +3238,7 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac,
if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && !(ads->flag & ADS_FLAG_NO_DB_SORT) &&
(view_layer->object_bases.first != view_layer->object_bases.last)) {
/* Filter list of bases (i.e. objects), sort them, then add their contents normally... */
- // TODO: Cache the old sorted order - if the set of bases hasn't changed, don't re-sort...
+ /* TODO: Cache the old sorted order - if the set of bases hasn't changed, don't re-sort... */
Base **sorted_bases;
size_t num_bases;
@@ -3238,7 +3249,7 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac,
items += animdata_filter_dopesheet_ob(ac, anim_data, ads, sorted_bases[i], filter_mode);
}
- // TODO: store something to validate whether any changes are needed?
+ /* TODO: store something to validate whether any changes are needed? */
/* free temporary data */
MEM_freeN(sorted_bases);
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 38e5723f7db..8e1f03295f4 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -687,7 +687,7 @@ static int ed_marker_add_exec(bContext *C, wmOperator *UNUSED(op))
marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
marker->flag = SELECT;
marker->frame = frame;
- BLI_snprintf(marker->name, sizeof(marker->name), "F_%02d", frame); // XXX - temp code only
+ BLI_snprintf(marker->name, sizeof(marker->name), "F_%02d", frame); /* XXX - temp code only */
BLI_addtail(markers, marker);
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
@@ -1110,7 +1110,7 @@ static void ed_marker_duplicate_apply(bContext *C)
}
/* new marker is added to the beginning of list */
- // FIXME: bad ordering!
+ /* FIXME: bad ordering! */
BLI_addhead(markers, newmarker);
}
}
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 4d5ff33d5cf..b2a9d6ac9b7 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -883,9 +883,12 @@ void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const ch
/* Add Driver - Enum Defines ------------------------- */
-/* Mapping Types enum for operators */
-/* NOTE: Used by ANIM_OT_driver_button_add and UI_OT_eyedropper_driver */
-// XXX: These names need reviewing
+/**
+ * Mapping Types enum for operators.
+ * \note Used by #ANIM_OT_driver_button_add and #UI_OT_eyedropper_driver.
+ *
+ * XXX: These names need reviewing.
+ */
EnumPropertyItem prop_driver_create_mapping_types[] = {
{CREATEDRIVER_MAPPING_1_N,
"SINGLE_MANY",
@@ -1014,7 +1017,7 @@ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_typ
/* send updates */
UI_context_update_anim_flag(C);
DEG_relations_tag_update(CTX_data_main(C));
- WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX
+ WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); /* XXX */
return OPERATOR_FINISHED;
}
@@ -1051,8 +1054,8 @@ static int add_driver_button_menu_invoke(bContext *C, wmOperator *op, const wmEv
}
/* Show menu */
- // TODO: This should get filtered by the enum filter
- /* important to execute in the region we're currently in */
+ /* TODO: This should get filtered by the enum filter. */
+ /* important to execute in the region we're currently in. */
return WM_menu_invoke_ex(C, op, WM_OP_INVOKE_DEFAULT);
}
@@ -1167,7 +1170,7 @@ static int remove_driver_button_exec(bContext *C, wmOperator *op)
/* send updates */
UI_context_update_anim_flag(C);
DEG_relations_tag_update(CTX_data_main(C));
- WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX
+ WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); /* XXX */
}
return (changed) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
@@ -1183,7 +1186,7 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot)
/* callbacks */
ot->exec = remove_driver_button_exec;
- // op->poll = ??? // TODO: need to have some driver to be able to do this...
+ /* TODO: `op->poll` need to have some driver to be able to do this. */
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -1220,7 +1223,7 @@ void ANIM_OT_driver_button_edit(wmOperatorType *ot)
/* callbacks */
ot->exec = edit_driver_button_exec;
- // op->poll = ??? // TODO: need to have some driver to be able to do this...
+ /* TODO: `op->poll` need to have some driver to be able to do this. */
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -1264,7 +1267,7 @@ void ANIM_OT_copy_driver_button(wmOperatorType *ot)
/* callbacks */
ot->exec = copy_driver_button_exec;
- // op->poll = ??? // TODO: need to have some driver to be able to do this...
+ /* TODO: `op->poll` need to have some driver to be able to do this. */
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -1295,7 +1298,7 @@ static int paste_driver_button_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(ptr.owner_id, ID_RECALC_ANIMATION);
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); // XXX
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); /* XXX */
MEM_freeN(path);
}
@@ -1314,7 +1317,7 @@ void ANIM_OT_paste_driver_button(wmOperatorType *ot)
/* callbacks */
ot->exec = paste_driver_button_exec;
- // op->poll = ??? // TODO: need to have some driver to be able to do this...
+ /* TODO: `op->poll` need to have some driver to be able to do this. */
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 5cef02e8921..cae249ea925 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -222,7 +222,7 @@ static PanelType *fmodifier_subpanel_register(ARegionType *region_type,
/** \name General UI Callbacks and Drawing
* \{ */
-// XXX! --------------------------------
+/* XXX! -------------------------------- */
/* Temporary definition for limits of float number buttons
* (FLT_MAX tends to infinity with old system). */
#define UI_FLT_MAX 10000.0f
@@ -716,7 +716,7 @@ static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(ar
/* init template data */
fed.min = -1.0f;
fed.max = 1.0f;
- fed.time = (float)scene->r.cfra; // XXX make this int for ease of use?
+ fed.time = (float)scene->r.cfra; /* XXX make this int for ease of use? */
fed.f1 = fed.f2 = 0;
/* check that no data exists for the current frame... */
@@ -761,7 +761,7 @@ static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(ar
}
/* callback to remove envelope data point */
-// TODO: should we have a separate file for things like this?
+/* TODO: should we have a separate file for things like this? */
static void fmod_envelope_deletepoint_cb(bContext *UNUSED(C), void *fcm_dv, void *ind_v)
{
FMod_Envelope *env = (FMod_Envelope *)fcm_dv;
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 4d6d7fa3ad5..542a6d45db7 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -1071,7 +1071,7 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, int saction
ac.datatype = ANIMCONT_CHANNEL;
/* get F-Curves to take keyframes from */
- filter = ANIMFILTER_DATA_VISIBLE; // curves only
+ filter = ANIMFILTER_DATA_VISIBLE; /* curves only */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* loop through each F-Curve, grabbing the keyframes */
@@ -1109,7 +1109,7 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, int saction_fl
ac.datatype = ANIMCONT_CHANNEL;
/* get F-Curves to take keyframes from */
- filter = ANIMFILTER_DATA_VISIBLE; // curves only
+ filter = ANIMFILTER_DATA_VISIBLE; /* curves only */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* loop through each F-Curve, grabbing the keyframes */
@@ -1143,7 +1143,7 @@ void cachefile_to_keylist(bDopeSheet *ads,
/* get F-Curves to take keyframes from */
ListBase anim_data = {NULL, NULL};
- int filter = ANIMFILTER_DATA_VISIBLE; // curves only
+ int filter = ANIMFILTER_DATA_VISIBLE; /* curves only */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* loop through each F-Curve, grabbing the keyframes */
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index 299aa1db4f5..d5260cac0c9 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -70,7 +70,7 @@
/* This function is used to loop over BezTriples in the given F-Curve, applying a given
* operation on them, and optionally applies an F-Curve validation function afterwards.
*/
-// TODO: make this function work on samples too...
+/* TODO: make this function work on samples too. */
short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
FCurve *fcu,
KeyframeEditFunc key_ok,
@@ -237,7 +237,7 @@ static short ob_keyframes_loop(KeyframeEditData *ked,
ac.datatype = ANIMCONT_CHANNEL;
/* get F-Curves to take keyframes from */
- filter = ANIMFILTER_DATA_VISIBLE; // curves only
+ filter = ANIMFILTER_DATA_VISIBLE; /* curves only */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* Loop through each F-Curve, applying the operation as required,
@@ -286,7 +286,7 @@ static short scene_keyframes_loop(KeyframeEditData *ked,
ac.datatype = ANIMCONT_CHANNEL;
/* get F-Curves to take keyframes from */
- filter = ANIMFILTER_DATA_VISIBLE; // curves only
+ filter = ANIMFILTER_DATA_VISIBLE; /* curves only */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* Loop through each F-Curve, applying the operation as required,
@@ -478,7 +478,7 @@ void ANIM_animdata_keyframe_callback(bAnimContext *ac,
/* Keyframe Integrity Tools */
/* Rearrange keyframes if some are out of order */
-// used to be recalc_*_ipos() where * was object or action
+/* used to be recalc_*_ipos() where * was object or action */
void ANIM_editkeyframes_refresh(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
@@ -834,7 +834,7 @@ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt)
const float scale = (rmap->newMax - rmap->newMin) / (rmap->oldMax - rmap->oldMin);
/* perform transform on all three handles unless indicated otherwise */
- // TODO: need to include some checks for that
+ /* TODO: need to include some checks for that */
bezt->vec[0][0] = scale * (bezt->vec[0][0] - rmap->oldMin) + rmap->newMin;
bezt->vec[1][0] = scale * (bezt->vec[1][0] - rmap->oldMin) + rmap->newMin;
@@ -1025,7 +1025,7 @@ static short mirror_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
}
/* Note: for markers and 'value', the values to use must be supplied as the first float value */
-// calchandles_fcurve
+/* calchandles_fcurve */
KeyframeEditFunc ANIM_editkeyframes_mirror(short mode)
{
switch (mode) {
@@ -1128,9 +1128,12 @@ static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
return 0;
}
-/* Queries if the handle should be set to 'free' or 'align' */
-// NOTE: this was used for the 'toggle free/align' option
-// currently this isn't used, but may be restored later
+/**
+ * Queries if the handle should be set to 'free' or 'align'.
+ *
+ * \note This was used for the 'toggle free/align' option
+ * currently this isn't used, but may be restored later.
+ */
static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
if ((bezt->f1 & SELECT) && (bezt->h1)) {
@@ -1181,7 +1184,7 @@ static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
}
/* Set all selected Bezier Handles to a single type */
-// calchandles_fcurve
+/* calchandles_fcurve */
KeyframeEditFunc ANIM_editkeyframes_handles(short mode)
{
switch (mode) {
@@ -1309,7 +1312,7 @@ static short set_bezt_sine(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
}
/* Set the interpolation type of the selected BezTriples in each F-Curve to the specified one */
-// ANIM_editkeyframes_ipocurve_ipotype() !
+/* ANIM_editkeyframes_ipocurve_ipotype() ! */
KeyframeEditFunc ANIM_editkeyframes_ipo(short mode)
{
switch (mode) {
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 0bec20c739e..08b02020f76 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -390,7 +390,7 @@ static void decimate_fcurve_segment(FCurve *fcu,
BKE_curve_decimate_bezt_array(&fcu->bezt[bezt_segment_start_idx],
bezt_segment_len,
12, /* The actual resolution displayed in the viewport is dynamic
- so we just pick a value that preserves the curve shape. */
+ * so we just pick a value that preserves the curve shape. */
false,
SELECT,
BEZT_FLAG_TEMP_TAG,
@@ -485,7 +485,7 @@ typedef struct tSmooth_Bezt {
} tSmooth_Bezt;
/* Use a weighted moving-means method to reduce intensity of fluctuations */
-// TODO: introduce scaling factor for weighting falloff
+/* TODO: introduce scaling factor for weighting falloff */
void smooth_fcurve(FCurve *fcu)
{
int totSel = 0;
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index e4b73ea65a0..3fb707078b8 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -407,7 +407,7 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
/* are there already keyframes? */
if (fcu->bezt) {
bool replace;
- i = binarysearch_bezt_index(fcu->bezt, bezt->vec[1][0], fcu->totvert, &replace);
+ i = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, bezt->vec[1][0], fcu->totvert, &replace);
/* replace an existing keyframe? */
if (replace) {
@@ -462,8 +462,8 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
/* no keyframes already, but can only add if...
* 1) keyframing modes say that keyframes can only be replaced, so adding new ones won't know
* 2) there are no samples on the curve
- * // NOTE: maybe we may want to allow this later when doing samples -> bezt conversions,
- * // but for now, having both is asking for trouble
+ * NOTE: maybe we may want to allow this later when doing samples -> bezt conversions,
+ * but for now, having both is asking for trouble
*/
else if ((flag & INSERTKEY_REPLACE) == 0 && (fcu->fpt == NULL)) {
/* create new keyframes array */
@@ -511,12 +511,12 @@ static void subdivide_nonauto_handles(const FCurve *fcu,
/* Subdivide the curve. */
float delta;
- if (!BKE_bezt_subdivide_handles(bezt, prev, next, &delta)) {
+ if (!BKE_fcurve_bezt_subdivide_handles(bezt, prev, next, &delta)) {
return;
}
/* Decide when to force auto to manual. */
- if (!BEZT_IS_AUTOH(bezt) || fabsf(delta) >= 0.001f) {
+ if (!BEZT_IS_AUTOH(bezt)) {
return;
}
if ((prev_auto || next_auto) && fcu->auto_smoothing == FCURVE_SMOOTH_CONT_ACCEL) {
@@ -605,8 +605,7 @@ int insert_vert_fcurve(
/* add temp beztriple to keyframes */
a = insert_bezt_fcurve(fcu, &beztr, flag);
-
- fcu->active_keyframe_index = a;
+ BKE_fcurve_active_keyframe_set(fcu, &fcu->bezt[a]);
/* what if 'a' is a negative index?
* for now, just exit to prevent any segfaults
@@ -1606,7 +1605,7 @@ static bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra)
int i;
/* try to find index of beztriple to get rid of */
- i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found);
+ i = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, cfra, fcu->totvert, &found);
if (found) {
/* delete the key at the index (will sanity check + do recalc afterwards) */
delete_fcurve_key(fcu, i, 1);
@@ -1875,7 +1874,7 @@ static int insert_key_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
bool ob_edit_mode = false;
- float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
+ float cfra = (float)CFRA; /* XXX for now, don't bother about all the yucky offset crap */
int num_channels;
KeyingSet *ks = keyingset_get_from_op_with_error(op, op->type->prop, scene);
@@ -2058,7 +2057,7 @@ void ANIM_OT_keyframe_insert_menu(wmOperatorType *ot)
/* confirm whether a keyframe was added by showing a popup
* - by default, this is disabled so that if a menu is shown, this doesn't come up too
*/
- // XXX should this just be always on?
+ /* XXX should this just be always on? */
prop = RNA_def_boolean(ot->srna,
"confirm_success",
0,
@@ -2079,7 +2078,7 @@ void ANIM_OT_keyframe_insert_menu(wmOperatorType *ot)
static int delete_key_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
+ float cfra = (float)CFRA; /* XXX for now, don't bother about all the yucky offset crap */
int num_channels;
KeyingSet *ks = keyingset_get_from_op_with_error(op, op->type->prop, scene);
@@ -2609,7 +2608,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
PropertyRNA *prop = NULL;
Main *bmain = CTX_data_main(C);
char *path;
- float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
+ float cfra = (float)CFRA; /* XXX for now, don't bother about all the yucky offset crap */
bool changed = false;
int index;
const bool all = RNA_boolean_get(op->ptr, "all");
@@ -2649,7 +2648,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
int i;
/* try to find index of beztriple to get rid of */
- i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found);
+ i = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, cfra, fcu->totvert, &found);
if (found) {
/* delete the key at the index (will sanity check + do recalc afterwards) */
delete_fcurve_key(fcu, i, 1);
@@ -2781,7 +2780,7 @@ void ANIM_OT_keyframe_clear_button(wmOperatorType *ot)
bool autokeyframe_cfra_can_key(const Scene *scene, ID *id)
{
- float cfra = (float)CFRA; // XXX for now, this will do
+ float cfra = (float)CFRA; /* XXX for now, this will do */
/* only filter if auto-key mode requires this */
if (IS_AUTOKEY_ON(scene) == 0) {
@@ -2823,9 +2822,9 @@ bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
/* we either include all regardless of muting, or only non-muted */
if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED) == 0) {
bool replace;
- int i = binarysearch_bezt_index(fcu->bezt, frame, fcu->totvert, &replace);
+ int i = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, frame, fcu->totvert, &replace);
- /* binarysearch_bezt_index will set replace to be 0 or 1
+ /* BKE_fcurve_bezt_binarysearch_index will set replace to be 0 or 1
* - obviously, 1 represents a match
*/
if (replace) {
@@ -2981,7 +2980,7 @@ bool id_frame_has_keyframe(ID *id, float frame, short filter)
case ID_OB: /* object */
return object_frame_has_keyframe((Object *)id, frame, filter);
#if 0
- // XXX TODO... for now, just use 'normal' behavior
+ /* XXX TODO... for now, just use 'normal' behavior */
case ID_SCE: /* scene */
break;
#endif
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 876740b889a..fda7b600c1c 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -214,7 +214,7 @@ static int add_empty_ks_path_exec(bContext *C, wmOperator *op)
BLI_addtail(&ks->paths, ksp);
ks->active_path = BLI_listbase_count(&ks->paths);
- ksp->groupmode = KSP_GROUP_KSNAME; // XXX?
+ ksp->groupmode = KSP_GROUP_KSNAME; /* XXX? */
ksp->idtype = ID_OB;
ksp->flag = KSP_FLAG_WHOLE_ARRAY;
@@ -968,14 +968,15 @@ eModifyKey_Returns ANIM_validate_keyingset(bContext *C, ListBase *dsources, Keyi
}
/* if we don't have any paths now, then this still qualifies as invalid context */
- // FIXME: we need some error conditions (to be retrieved from the iterator why this failed!)
+ /* FIXME: we need some error conditions (to be retrieved from the iterator why this failed!)
+ */
if (BLI_listbase_is_empty(&ks->paths)) {
return MODIFYKEY_INVALID_CONTEXT;
}
}
else {
/* poll callback tells us that KeyingSet is useless in current context */
- // FIXME: the poll callback needs to give us more info why
+ /* FIXME: the poll callback needs to give us more info why */
return MODIFYKEY_INVALID_CONTEXT;
}
}
@@ -1149,7 +1150,7 @@ int ANIM_apply_keyingset(
{
Object *ob = (Object *)ksp->id;
- // XXX: only object transforms?
+ /* XXX: only object transforms? */
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
break;
}
diff --git a/source/blender/editors/animation/time_scrub_ui.c b/source/blender/editors/animation/time_scrub_ui.c
index 0615e21c4a5..acbac93b654 100644
--- a/source/blender/editors/animation/time_scrub_ui.c
+++ b/source/blender/editors/animation/time_scrub_ui.c
@@ -226,23 +226,30 @@ void ED_time_scrub_channel_search_draw(const bContext *C, ARegion *region, bDope
immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
immUnbindProgram();
- uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
-
PointerRNA ptr;
RNA_pointer_create(&CTX_wm_screen(C)->id, &RNA_DopeSheet, dopesheet, &ptr);
- PropertyRNA *prop = RNA_struct_find_property(&ptr, "filter_text");
-
- int padding = 2 * UI_DPI_FAC;
- uiDefAutoButR(block,
- &ptr,
- prop,
- -1,
- "",
- ICON_NONE,
- rect.xmin + padding,
- rect.ymin + padding,
- BLI_rcti_size_x(&rect) - 2 * padding,
- BLI_rcti_size_y(&rect) - 2 * padding);
+
+ const uiStyle *style = UI_style_get_dpi();
+ const float padding_x = 2 * UI_DPI_FAC;
+ const float padding_y = UI_DPI_FAC;
+
+ uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
+ uiLayout *layout = UI_block_layout(block,
+ UI_LAYOUT_VERTICAL,
+ UI_LAYOUT_HEADER,
+ rect.xmin + padding_x,
+ rect.ymin + UI_UNIT_Y + padding_y,
+ BLI_rcti_size_x(&rect) - 2 * padding_x,
+ 1,
+ 0,
+ style);
+ uiLayoutSetScaleY(layout, (UI_UNIT_Y - padding_y) / UI_UNIT_Y);
+ UI_block_layout_set_current(block, layout);
+ UI_block_align_begin(block);
+ uiItemR(layout, &ptr, "filter_text", 0, "", ICON_NONE);
+ uiItemR(layout, &ptr, "use_filter_invert", 0, "", ICON_ARROW_LEFTRIGHT);
+ UI_block_align_end(block);
+ UI_block_layout_resolve(block, NULL, NULL);
UI_block_end(C, block);
UI_block_draw(C, block);
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index 5f01c4ed038..4d31a5e786b 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -942,7 +942,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
- ED_armature_edit_sync_selection(arm->edbo); // XXX why is this needed?
+ ED_armature_edit_sync_selection(arm->edbo); /* XXX why is this needed? */
preEditBoneDuplicate(arm->edbo);
@@ -1117,7 +1117,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op)
/* The beginning of the duplicated mirrored bones in the edbo list */
EditBone *ebone_first_dupe = NULL;
- ED_armature_edit_sync_selection(arm->edbo); // XXX why is this needed?
+ ED_armature_edit_sync_selection(arm->edbo); /* XXX why is this needed? */
preEditBoneDuplicate(arm->edbo);
@@ -1399,7 +1399,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
if (arm->flag & ARM_MIRROR_EDIT) {
flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
if (flipbone) {
- forked_iter = 0; // we extrude 2 different bones
+ forked_iter = 0; /* we extrude 2 different bones */
if (flipbone->flag & (BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED)) {
/* don't want this bone to be selected... */
flipbone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
@@ -1449,7 +1449,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
newbone->dist = ebone->dist;
newbone->xwidth = ebone->xwidth;
newbone->zwidth = ebone->zwidth;
- newbone->rad_head = ebone->rad_tail; // don't copy entire bone...
+ newbone->rad_head = ebone->rad_tail; /* don't copy entire bone. */
newbone->rad_tail = ebone->rad_tail;
newbone->segments = 1;
newbone->layer = ebone->layer;
@@ -1470,7 +1470,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name));
- if (flipbone && forked_iter) { // only set if mirror edit
+ if (flipbone && forked_iter) { /* only set if mirror edit */
if (strlen(newbone->name) < (MAXBONENAME - 2)) {
if (a == 0) {
strcat(newbone->name, "_L");
@@ -1587,10 +1587,10 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
copy_v3_v3(bone->head, curs);
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) {
- add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
+ add_v3_v3v3(bone->tail, bone->head, imat[1]); /* bone with unit length 1 */
}
else {
- add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
+ add_v3_v3v3(bone->tail, bone->head, imat[2]); /* bone with unit length 1, pointing up Z */
}
ED_armature_edit_refresh_layer_used(obedit->data);
@@ -1638,7 +1638,7 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
cuts = RNA_int_get(op->ptr, "number_cuts");
/* loop over all editable bones */
- // XXX the old code did this in reverse order though!
+ /* XXX the old code did this in reverse order though! */
CTX_DATA_BEGIN_WITH_ID (C, EditBone *, ebone, selected_editable_bones, bArmature *, arm) {
for (i = cuts + 1; i > 1; i--) {
/* compute cut ratio first */
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 2efb7315b89..14d64d2d808 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -685,7 +685,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
separate_armature_bones(bmain, ob_old, true);
separate_armature_bones(bmain, ob_new, false);
- /* 4) fix links before depsgraph flushes */ // err... or after?
+ /* 4) fix links before depsgraph flushes, err... or after? */
separated_armature_fix_links(bmain, ob_old, ob_new);
DEG_id_tag_update(&ob_old->id, ID_RECALC_GEOMETRY); /* this is the original one */
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index cf64cfc849d..e51e5ec5cef 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -451,7 +451,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys)
BLI_bvhtree_insert(sys->heat.bvhtree, a, bb, 2);
- // Setup inverse pointers to use on isect.orig
+ /* Setup inverse pointers to use on isect.orig */
sys->heat.vltree[vtri[0]] = lt;
sys->heat.vltree[vtri[1]] = lt;
sys->heat.vltree[vtri[2]] = lt;
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 85948f3abc3..e8c35958115 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -279,7 +279,7 @@ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEven
}
/* show popup dialog to allow editing of range... */
- // FIXME: hardcoded dimensions here are just arbitrary
+ /* FIXME: hard-coded dimensions here are just arbitrary. */
return WM_operator_props_dialog_popup(C, op, 200);
}
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 33c1a8a8b4f..947e2dbf5aa 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -1856,7 +1856,7 @@ void POSELIB_OT_browse_interactive(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* properties */
- // TODO: make the pose_index into a proper enum instead of a cryptic int...
+ /* TODO: make the pose_index into a proper enum instead of a cryptic int. */
ot->prop = RNA_def_int(
ot->srna,
"pose_index",
@@ -1868,7 +1868,7 @@ void POSELIB_OT_browse_interactive(wmOperatorType *ot)
0,
INT_MAX);
- // XXX: percentage vs factor?
+ /* XXX: percentage vs factor? */
/* not used yet */
#if 0
RNA_def_float_factor(ot->srna,
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index c63f2ff12c5..731d0d10e0b 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -114,7 +114,7 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
bArmature *arm;
/* sanity checks */
- // XXX: actually, we can probably still get away with no object - at most we have no updates
+ /* XXX: actually, we can probably still get away with no object - at most we have no updates */
if (ELEM(NULL, ob, ob->pose, pchan, pchan->bone)) {
return;
}
@@ -133,7 +133,7 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
arm->act_bone = NULL;
}
- // TODO: select and activate corresponding vgroup?
+ /* TODO: select and activate corresponding vgroup? */
ED_pose_bone_select_tag_update(ob);
}
}
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index e60270bc3f0..eb2a0d7a073 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -480,7 +480,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
float tval = (float)RNA_property_boolean_get(&ptr, prop);
pose_slide_apply_val(pso, fcu, pfl->ob, &tval);
RNA_property_boolean_set(
- &ptr, prop, (int)tval); // XXX: do we need threshold clamping here?
+ &ptr, prop, (int)tval); /* XXX: do we need threshold clamping here? */
break;
}
case PROP_ENUM: {
@@ -681,14 +681,14 @@ static void pose_slide_rest_pose_apply(bContext *C, tPoseSlideOp *pso)
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_BBONE_SHAPE) && (pchan->flag & POSE_BBONE_SHAPE)) {
/* bbone properties - they all start a "bbone_" prefix */
- // TODO Not implemented
+ /* TODO Not implemented */
// pose_slide_apply_props(pso, pfl, "bbone_");
}
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_PROPS) && (pfl->oldprops)) {
/* Not strictly a transform, but custom properties contribute
* to the pose produced in many rigs (e.g. the facial rigs used in Sintel). */
- // TODO Not implemented
+ /* TODO Not implemented */
// pose_slide_apply_props(pso, pfl, "[\""); /* dummy " for texteditor bugs */
}
}
@@ -790,7 +790,7 @@ static void pose_slide_reset(tPoseSlideOp *pso)
/* ------------------------------------ */
/* draw percentage indicator in header */
-// TODO: Include hints about locks here...
+/* TODO: Include hints about locks here... */
static void pose_slide_draw_status(tPoseSlideOp *pso)
{
char status_str[UI_MAX_DRAW_STR];
@@ -1802,7 +1802,7 @@ static void pose_propagate_fcurve(
* - if only doing selected keyframes, start from the first one
*/
if (mode != POSE_PROPAGATE_SELECTED_KEYS) {
- match = binarysearch_bezt_index(fcu->bezt, startFrame, fcu->totvert, &keyExists);
+ match = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, startFrame, fcu->totvert, &keyExists);
if (fcu->bezt[match].vec[1][0] < startFrame) {
i = match + 1;
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index b09015096a6..d3f11c5a16f 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -385,7 +385,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
- // must be active object, not edit-object
+ /* must be active object, not edit-object */
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bArmature *arm = BKE_armature_from_object(ob);
@@ -688,8 +688,8 @@ static bPoseChannel *pose_bone_do_paste(Object *ob,
pchan->curve_in_x *= -1;
pchan->curve_out_x *= -1;
- pchan->roll1 *= -1; // XXX?
- pchan->roll2 *= -1; // XXX?
+ pchan->roll1 *= -1; /* XXX? */
+ pchan->roll2 *= -1; /* XXX? */
/* has to be done as eulers... */
if (pchan->rotmode > 0) {
@@ -1108,7 +1108,7 @@ static int pose_clear_transform_generic_exec(bContext *C,
ViewLayer *view_layer = CTX_data_view_layer(C);
View3D *v3d = CTX_wm_view3d(C);
FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) {
- // XXX: UGLY HACK (for autokey + clear transforms)
+ /* XXX: UGLY HACK (for autokey + clear transforms) */
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter);
ListBase dsources = {NULL, NULL};
bool changed = false;
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index e2038bdd2a3..2a6dc9f406b 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -332,7 +332,7 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks,
FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) {
if (ob->id.tag & LIB_TAG_DOIT) {
if (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) {
- // ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
+ // ED_pose_clear_paths(C, ob); /* XXX for now, don't need to clear. */
/* TODO(sergey): Should ensure we can use more narrow update range here. */
ED_pose_recalculate_paths(C, scene, ob, POSE_PATH_CALC_RANGE_FULL);
}
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 15a147b6b86..85d86849140 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1349,7 +1349,7 @@ void ED_curve_editnurb_make(Object *obedit)
nu = cu->nurb.first;
while (nu) {
newnu = BKE_nurb_duplicate(nu);
- BKE_nurb_test_2d(newnu); // after join, or any other creation of curve
+ BKE_nurb_test_2d(newnu); /* after join, or any other creation of curve */
BLI_addtail(&editnurb->nurbs, newnu);
nu = nu->next;
}
@@ -7001,7 +7001,7 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op)
BKE_curve_curve_dimension_update(cu);
}
- DEG_relations_tag_update(bmain); // because we removed object(s), call before editmode!
+ DEG_relations_tag_update(bmain); /* because we removed object(s), call before editmode! */
DEG_id_tag_update(&ob_active->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c
index 4d72e90b89b..684666aba13 100644
--- a/source/blender/editors/curve/editcurve_add.c
+++ b/source/blender/editors/curve/editcurve_add.c
@@ -127,7 +127,7 @@ Nurb *ED_curve_add_nurbs_primitive(
float fac;
int a, b;
const float grid = 1.0f;
- const int cutype = (type & CU_TYPE); // poly, bezier, nurbs, etc
+ const int cutype = (type & CU_TYPE); /* poly, bezier, nurbs, etc */
const int stype = (type & CU_PRIMITIVE);
unit_m4(umat);
diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt
index b8cc704eb23..fff8949cf7a 100644
--- a/source/blender/editors/datafiles/CMakeLists.txt
+++ b/source/blender/editors/datafiles/CMakeLists.txt
@@ -742,10 +742,15 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
ops.pose.breakdowner
ops.pose.push
ops.pose.relax
+ ops.sculpt.border_face_set
ops.sculpt.border_hide
ops.sculpt.border_mask
+ ops.sculpt.box_trim
ops.sculpt.cloth_filter
+ ops.sculpt.face_set_edit
+ ops.sculpt.lasso_face_set
ops.sculpt.lasso_mask
+ ops.sculpt.lasso_trim
ops.sculpt.mesh_filter
ops.sequencer.blade
ops.transform.bone_envelope
diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
index 13f3903f0b2..eb40500d011 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
@@ -386,4 +386,4 @@ void ED_gizmotypes_button_2d(void)
WM_gizmotype_append(GIZMO_GT_button_2d);
}
-/** \} */ // Button Gizmo API
+/** \} */ /* Button Gizmo API */
diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
index 2cd73f613c1..f7ab1732457 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
@@ -92,7 +92,7 @@ static void gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[3], f
static void gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[3], float margin[3])
{
const float handle_size = 0.15f;
- // XXX, the scale isn't taking offset into account, we need to calculate scale per handle!
+ /* XXX, the scale isn't taking offset into account, we need to calculate scale per handle! */
// handle_size *= gz->scale_final;
float scale_xyz[3];
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 ad7036f4460..011563eece5 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
@@ -481,4 +481,4 @@ void ED_gizmotypes_move_3d(void)
WM_gizmotype_append(GIZMO_GT_move_3d);
}
-/** \} */ // Move Gizmo API
+/** \} */ /* Move Gizmo API */
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index b6cbbe7712b..fe1c5efc747 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -744,8 +744,8 @@ static void annotation_draw_data(
annotation_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag);
/* turn off alpha blending, then smooth lines */
- GPU_blend(GPU_BLEND_NONE); // alpha blending
- GPU_line_smooth(false); // smooth lines
+ GPU_blend(GPU_BLEND_NONE); /* alpha blending */
+ GPU_line_smooth(false); /* smooth lines */
GPU_depth_mask(prev_depth_mask);
}
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 7cea221568e..c06a2f06a98 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -2090,7 +2090,7 @@ static void annotation_draw_apply_event(
else {
p->straight[0] = 0;
/* We were using shift while having permanent stabilization active,
- so activate the temp flag back again. */
+ * so activate the temp flag back again. */
if (p->flags & GP_PAINTFLAG_USE_STABILIZER) {
if ((p->flags & GP_PAINTFLAG_USE_STABILIZER_TEMP) == 0) {
annotation_draw_toggle_stabilizer_cursor(p, true);
@@ -2098,8 +2098,8 @@ static void annotation_draw_apply_event(
}
}
/* We are using the temporal stabilizer flag atm,
- but shift is not pressed as well as the permanent flag is not used,
- so we don't need the cursor anymore. */
+ * but shift is not pressed as well as the permanent flag is not used,
+ * so we don't need the cursor anymore. */
else if (p->flags & GP_PAINTFLAG_USE_STABILIZER_TEMP) {
/* Reset temporal stabilizer flag and remove cursor. */
p->flags &= ~GP_PAINTFLAG_USE_STABILIZER_TEMP;
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index 897a6e9653d..d4f3c4d7f5e 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -443,7 +443,7 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
}
/* filter data */
- // TODO: try doing it with selection, then without selection imits
+ /* TODO: try doing it with selection, then without selection limits. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
@@ -649,7 +649,7 @@ static bool gpencil_frame_mirror_marker(bGPDframe *gpf, Scene *scene)
}
/* mirror selected gp-frames on... */
-// TODO: mirror over a specific time
+/* TODO: mirror over a specific time */
void ED_gpencil_layer_mirror_frames(bGPDlayer *gpl, Scene *scene, short mode)
{
switch (mode) {
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index b7bf1861ff3..fa7fe27635a 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1441,7 +1441,7 @@ static int gpencil_strokes_copy_exec(bContext *C, wmOperator *op)
}
/* updates (to ensure operator buttons are refreshed, when used via hotkeys) */
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL); // XXX?
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL); /* XXX? */
/* done */
return OPERATOR_FINISHED;
@@ -1749,11 +1749,11 @@ void GPENCIL_OT_move_to_layer(wmOperatorType *ot)
ot->name = "Move Strokes to Layer";
ot->idname = "GPENCIL_OT_move_to_layer";
ot->description =
- "Move selected strokes to another layer"; // XXX: allow moving individual points too?
+ "Move selected strokes to another layer"; /* XXX: allow moving individual points too? */
/* callbacks */
ot->exec = gpencil_move_to_layer_exec;
- ot->poll = gpencil_stroke_edit_poll; // XXX?
+ ot->poll = gpencil_stroke_edit_poll; /* XXX? */
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -2766,7 +2766,7 @@ static int gpencil_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
continue;
}
- // TODO: if entire stroke is selected, offset entire stroke by same amount?
+ /* TODO: if entire stroke is selected, offset entire stroke by same amount? */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
/* only if point is selected */
if (pt->flag & GP_SPOINT_SELECT) {
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 247cc218c2f..a11397bd0bb 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -1269,7 +1269,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
for (int i = 0; i < gps->totpoints; i++) {
BKE_gpencil_stroke_smooth(gps, i, smoothfac - reduce);
}
- reduce += 0.25f; // reduce the factor
+ reduce += 0.25f; /* reduce the factor */
}
/* if axis locked, reproject to plane locked */
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index fb24c64f2bd..543ff8e7e9a 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -3471,8 +3471,7 @@ static void gpencil_add_fake_points(const wmEvent *event, tGPsdata *p)
(p->brush && (p->brush->gpencil_tool == GPAINT_TOOL_DRAW)));
/* TODO: ensure sampling enough points when using circular guide,
- but the arc must be around the center. (see if above to check other guides only)
- */
+ * but the arc must be around the center. (see if above to check other guides only). */
if (is_speed_guide && (guide->type == GP_GUIDE_CIRCULAR)) {
input_samples = GP_MAX_INPUT_SAMPLES;
}
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index d37e393ac77..1d500223ab8 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -760,7 +760,7 @@ static bool gpencil_brush_twist_apply(tGP_BrushEditData *gso,
float rmat[3][3];
/* Express position of point relative to cursor, ready to rotate */
- // XXX: There is still some offset here, but it's close to working as expected...
+ /* XXX: There is still some offset here, but it's close to working as expected. */
vec[0] = (float)(co[0] - gso->mval[0]);
vec[1] = (float)(co[1] - gso->mval[1]);
@@ -778,7 +778,7 @@ static bool gpencil_brush_twist_apply(tGP_BrushEditData *gso,
UI_view2d_region_to_view(v2d, vec[0], vec[1], &pt->x, &pt->y);
}
else {
- // XXX
+ /* XXX */
copy_v2_v2(&pt->x, vec);
}
}
@@ -2125,7 +2125,7 @@ void GPENCIL_OT_sculpt_paint(wmOperatorType *ot)
/* identifiers */
ot->name = "Stroke Sculpt";
ot->idname = "GPENCIL_OT_sculpt_paint";
- ot->description = "Apply tweaks to strokes by painting over the strokes"; // XXX
+ ot->description = "Apply tweaks to strokes by painting over the strokes"; /* XXX */
/* api callbacks */
ot->exec = gpencil_sculpt_brush_exec;
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 8b77709bacb..5a45afe9c5a 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -335,7 +335,7 @@ bool ED_gpencil_has_keyframe_v3d(Scene *UNUSED(scene), Object *ob, int cfra)
bGPDlayer *gpl = BKE_gpencil_layer_active_get(ob->data);
if (gpl) {
if (gpl->actframe) {
- // XXX: assumes that frame has been fetched already
+ /* XXX: assumes that frame has been fetched already */
return (gpl->actframe->framenum == cfra);
}
/* XXX: disabled as could be too much of a penalty */
@@ -2531,7 +2531,7 @@ void ED_gpencil_select_toggle_all(bContext *C, int action)
CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
if (gps->flag & GP_STROKE_SELECT) {
action = SEL_DESELECT;
- break; // XXX: this only gets out of the inner loop...
+ break; /* XXX: this only gets out of the inner loop. */
}
}
CTX_DATA_END;
@@ -2584,9 +2584,11 @@ void ED_gpencil_select_toggle_all(bContext *C, int action)
case SEL_SELECT:
pt->flag |= GP_SPOINT_SELECT;
break;
- // case SEL_DESELECT:
- // pt->flag &= ~GP_SPOINT_SELECT;
- // break;
+#if 0
+ case SEL_DESELECT:
+ pt->flag &= ~GP_SPOINT_SELECT;
+ break;
+#endif
case SEL_INVERT:
pt->flag ^= GP_SPOINT_SELECT;
break;
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 2642f3e62c9..3395385071e 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -334,7 +334,7 @@ typedef enum eAnimFilter_Flags {
} eAnimFilter_Flags;
/* ---------- Flag Checking Macros ------------ */
-// xxx check on all of these flags again...
+/* XXX check on all of these flags again. */
/* Dopesheet only */
/* 'Scene' channels */
@@ -509,7 +509,7 @@ typedef enum eAnimChannels_SetFlag {
ACHANNEL_SETFLAG_ADD = 1,
/** on->off, off->on */
ACHANNEL_SETFLAG_INVERT = 2,
- /** some on -> all off // all on */
+ /** some on -> all off / all on */
ACHANNEL_SETFLAG_TOGGLE = 3,
} eAnimChannels_SetFlag;
@@ -622,9 +622,11 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
eAnimChannel_Settings setting,
eAnimChannels_SetFlag mode);
-/* Deselect all animation channels */
-void ANIM_deselect_anim_channels(
- bAnimContext *ac, void *data, eAnimCont_Types datatype, bool test, eAnimChannels_SetFlag sel);
+/* Select or deselect animation channels */
+void ANIM_anim_channels_select_set(bAnimContext *ac, eAnimChannels_SetFlag sel);
+
+/* Toggle selection of animation channels */
+void ANIM_anim_channels_select_toggle(bAnimContext *ac);
/* Set the 'active' channel of type channel_type, in the given action */
void ANIM_set_active_channel(bAnimContext *ac,
@@ -759,7 +761,7 @@ void ANIM_nla_mapping_apply_fcurve(struct AnimData *adt,
/* ..... */
/* Perform auto-blending/extend refreshes after some operations */
-// NOTE: defined in space_nla/nla_edit.c, not in animation/
+/* NOTE: defined in space_nla/nla_edit.c, not in animation/ */
void ED_nla_postop_refresh(bAnimContext *ac);
/* ------------- Unit Conversion Mappings ------------- */
diff --git a/source/blender/editors/include/ED_buttons.h b/source/blender/editors/include/ED_buttons.h
index a4cd2525af3..5d153757900 100644
--- a/source/blender/editors/include/ED_buttons.h
+++ b/source/blender/editors/include/ED_buttons.h
@@ -29,6 +29,11 @@ extern "C" {
struct SpaceProperties;
int ED_buttons_tabs_list(struct SpaceProperties *sbuts, short *context_tabs_array);
+bool ED_buttons_tab_has_search_result(struct SpaceProperties *sbuts, const int index);
+
+void ED_buttons_search_string_set(struct SpaceProperties *sbuts, const char *value);
+int ED_buttons_search_string_length(struct SpaceProperties *sbuts);
+const char *ED_buttons_search_string_get(struct SpaceProperties *sbuts);
#ifdef __cplusplus
}
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 53554e3f34c..b8500ba0c37 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -92,6 +92,11 @@ void ED_region_panels_layout_ex(const struct bContext *C,
struct ListBase *paneltypes,
const char *contexts[],
const char *category_override);
+bool ED_region_property_search(const struct bContext *C,
+ struct ARegion *region,
+ struct ListBase *paneltypes,
+ const char *contexts[],
+ const char *category_override);
void ED_region_panels_layout(const struct bContext *C, struct ARegion *region);
void ED_region_panels_draw(const struct bContext *C, struct ARegion *region);
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index 09ab72efaaf..d99ecf2fd56 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -160,7 +160,7 @@ DEF_ICON_BLANK(157)
DEF_ICON_BLANK(158)
DEF_ICON_BLANK(159)
DEF_ICON_BLANK(160)
-DEF_ICON(BLANK1) // Not actually blank - this is used all over the place
+DEF_ICON(BLANK1) /* Not actually blank - this is used all over the place */
DEF_ICON(FAKE_USER_OFF)
DEF_ICON(FAKE_USER_ON)
/* EDITORS */
@@ -192,7 +192,7 @@ DEF_ICON(UV)
DEF_ICON_BLANK(190)
/* MODES */
-DEF_ICON(OBJECT_DATAMODE) // XXX fix this up
+DEF_ICON(OBJECT_DATAMODE) /* XXX fix this up */
DEF_ICON(EDITMODE_HLT)
DEF_ICON(UV_DATA)
DEF_ICON(VPAINT_HLT)
@@ -873,7 +873,7 @@ DEF_ICON(SEQ_SPLITVIEW)
DEF_ICON(SEQ_STRIP_META)
DEF_ICON(SEQ_STRIP_DUPLICATE)
DEF_ICON_BLANK(872)
-DEF_ICON(IMAGE_RGB) // XXX CHANGE TO STRAIGHT ALPHA, Z ETC
+DEF_ICON(IMAGE_RGB) /* XXX CHANGE TO STRAIGHT ALPHA, Z ETC */
DEF_ICON(IMAGE_RGB_ALPHA)
DEF_ICON(IMAGE_ALPHA)
DEF_ICON(IMAGE_ZDEPTH)
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index cac18d81f56..c987a8ac13b 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -226,6 +226,12 @@ enum {
UI_BUT_OVERRIDEN = 1u << 31u,
};
+/* Default font size for normal text. */
+#define UI_DEFAULT_TEXT_POINTS 11
+
+/* Larger size used for title text. */
+#define UI_DEFAULT_TITLE_POINTS 12
+
#define UI_PANEL_WIDTH 340
#define UI_COMPACT_PANEL_WIDTH 160
#define UI_SIDEBAR_PANEL_WIDTH 220
@@ -1687,6 +1693,7 @@ void UI_panel_header_buttons_begin(struct Panel *panel);
void UI_panel_header_buttons_end(struct Panel *panel);
void UI_panel_end(struct Panel *panel, int width, int height);
+bool UI_panel_is_closed(const struct Panel *panel);
bool UI_panel_is_active(const struct Panel *panel);
void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y);
int UI_panel_size_y(const struct Panel *panel);
@@ -1868,6 +1875,7 @@ uiLayout *UI_block_layout(uiBlock *block,
const struct uiStyle *style);
void UI_block_layout_set_current(uiBlock *block, uiLayout *layout);
void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y);
+void UI_block_layout_free(uiBlock *block);
bool UI_block_apply_search_filter(uiBlock *block, const char *search_filter);
@@ -2423,6 +2431,8 @@ void uiItemTabsEnumR_prop(uiLayout *layout,
struct bContext *C,
struct PointerRNA *ptr,
PropertyRNA *prop,
+ struct PointerRNA *ptr_highlight,
+ PropertyRNA *prop_highlight,
bool icon_only);
/* Only for testing, inspecting layouts. */
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index a7b87d38472..f597bb307db 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -50,7 +50,7 @@ typedef enum ThemeColorID {
TH_REDALERT,
TH_THEMEUI,
- // common colors among spaces
+ /* Common colors among spaces. */
TH_BACK,
/** Use when 'TH_SHOW_BACK_GRAD' is set (the lower, darker color). */
@@ -358,92 +358,92 @@ struct bThemeState {
int spacetype, regionid;
};
-// THE CODERS API FOR THEMES:
+/* THE CODERS API FOR THEMES: */
-// returns one value, not scaled
+/* returns one value, not scaled */
float UI_GetThemeValuef(int colorid);
int UI_GetThemeValue(int colorid);
float UI_GetThemeValueTypef(int colorid, int spacetype);
int UI_GetThemeValueType(int colorid, int spacetype);
-// get three color values, scaled to 0.0-1.0 range
+/* get three color values, scaled to 0.0-1.0 range */
void UI_GetThemeColor3fv(int colorid, float col[3]);
void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned char col[3]);
void UI_GetThemeColorBlend3f(int colorid1, int colorid2, float fac, float r_col[3]);
void UI_GetThemeColorBlend4f(int colorid1, int colorid2, float fac, float r_col[4]);
-// get the color, range 0.0-1.0, complete with shading offset
+/* get the color, range 0.0-1.0, complete with shading offset */
void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3]);
void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3]);
void UI_GetThemeColorShade4ubv(int colorid, int offset, unsigned char col[4]);
-// get three color values, range 0-255,
-// complete with shading offset for the RGB components and blending.
+/* get three color values, range 0-255,
+ * complete with shading offset for the RGB components and blending. */
void UI_GetThemeColorBlendShade3ubv(
int colorid1, int colorid2, float fac, int offset, unsigned char col[3]);
-// get four color values, scaled to 0.0-1.0 range
+/* get four color values, scaled to 0.0-1.0 range */
void UI_GetThemeColor4fv(int colorid, float col[4]);
/* get four color values from specified space type, scaled to 0.0-1.0 range */
void UI_GetThemeColorType4fv(int colorid, int spacetype, float col[4]);
-// get four color values, range 0.0-1.0, complete with shading offset for the RGB components
+/* get four color values, range 0.0-1.0, complete with shading offset for the RGB components */
void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4]);
void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]);
-// get four color values ranged between 0 and 255; includes the alpha channel
+/* get four color values ranged between 0 and 255; includes the alpha channel */
void UI_GetThemeColorShadeAlpha4ubv(int colorid,
int coloffset,
int alphaoffset,
unsigned char col[4]);
-// get four color values, range 0.0-1.0,
-// complete with shading offset for the RGB components and blending.
+/* get four color values, range 0.0-1.0,
+ * complete with shading offset for the RGB components and blending. */
void UI_GetThemeColorBlendShade3fv(
int colorid1, int colorid2, float fac, int offset, float col[3]);
void UI_GetThemeColorBlendShade4fv(
int colorid1, int colorid2, float fac, int offset, float col[4]);
-// get the 3 or 4 byte values
+/* get the 3 or 4 byte values */
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3]);
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4]);
-// get a theme color from specified space type
+/* get a theme color from specified space type */
void UI_GetThemeColorType3fv(int colorid, int spacetype, float col[3]);
void UI_GetThemeColorType3ubv(int colorid, int spacetype, unsigned char col[3]);
void UI_GetThemeColorType4ubv(int colorid, int spacetype, unsigned char col[4]);
-// get theme color for coloring monochrome icons
+/* get theme color for coloring monochrome icons */
bool UI_GetIconThemeColor4ubv(int colorid, unsigned char col[4]);
-// shade a 3 byte color (same as UI_GetColorPtrBlendShade3ubv with 0.0 factor)
+/* shade a 3 byte color (same as UI_GetColorPtrBlendShade3ubv with 0.0 factor) */
void UI_GetColorPtrShade3ubv(const unsigned char cp1[3], unsigned char col[3], int offset);
-// get a 3 byte color, blended and shaded between two other char color pointers
+/* get a 3 byte color, blended and shaded between two other char color pointers */
void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3],
const unsigned char cp2[3],
unsigned char col[3],
float fac,
int offset);
-// sets the font color
-// (for anything fancy use UI_GetThemeColor[Fancy] then BLF_color)
+/* sets the font color
+ * (for anything fancy use UI_GetThemeColor[Fancy] then BLF_color) */
void UI_FontThemeColor(int fontid, int colorid);
-// clear the framebuffer using the input colorid
+/* clear the framebuffer using the input colorid */
void UI_ThemeClearColor(int colorid);
-// internal (blender) usage only, for init and set active
+/* internal (blender) usage only, for init and set active */
void UI_SetTheme(int spacetype, int regionid);
-// get current theme
+/* get current theme */
struct bTheme *UI_GetTheme(void);
void UI_Theme_Store(struct bThemeState *theme_state);
void UI_Theme_Restore(struct bThemeState *theme_state);
-// return shadow width outside menus and popups */
+/* return shadow width outside menus and popups */
int UI_ThemeMenuShadowWidth(void);
/* only for buttons in theme editor! */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 98e76114956..c2a4465af07 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2628,7 +2628,7 @@ static void ui_get_but_string_unit(
int precision;
if (unit->scale_length < 0.0001f) {
- unit->scale_length = 1.0f; // XXX do_versions
+ unit->scale_length = 1.0f; /* XXX do_versions */
}
/* Use precision override? */
@@ -3123,23 +3123,6 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
return false;
}
-void ui_but_default_set(bContext *C, const bool all, const bool use_afterfunc)
-{
- wmOperatorType *ot = WM_operatortype_find("UI_OT_reset_default_button", true);
-
- if (use_afterfunc) {
- PointerRNA *ptr = ui_handle_afterfunc_add_operator(ot, WM_OP_EXEC_DEFAULT, true);
- RNA_boolean_set(ptr, "all", all);
- }
- else {
- PointerRNA ptr;
- WM_operator_properties_create_ptr(&ptr, ot);
- RNA_boolean_set(&ptr, "all", all);
- WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &ptr);
- WM_operator_properties_free(&ptr);
- }
-}
-
static double soft_range_round_up(double value, double max)
{
/* round up to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, ..
@@ -3663,7 +3646,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
}
/* safety is 4 to enable small number buttons (like 'users') */
- // okwidth = -4 + (BLI_rcti_size_x(&but->rect)); // UNUSED
+ // okwidth = -4 + (BLI_rcti_size_x(&but->rect)); /* UNUSED */
/* name: */
switch (but->type) {
@@ -3805,7 +3788,7 @@ void UI_block_align_begin(uiBlock *block)
block->flag |= UI_BUT_ALIGN_DOWN;
block->alignnr++;
- /* buttons declared after this call will get this align nr */ // XXX flag?
+ /* buttons declared after this call will get this align nr */ /* XXX flag? */
}
void UI_block_align_end(uiBlock *block)
@@ -4706,24 +4689,8 @@ uiBut *uiDefButImage(
uiBut *uiDefButAlert(uiBlock *block, int icon, int x, int y, short width, short height)
{
struct ImBuf *ibuf = UI_icon_alert_imbuf_get(icon);
-
- if (icon == ALERT_ICON_BLENDER) {
- return uiDefButImage(block, ibuf, x, y, width, height, NULL);
- }
-
- uchar icon_color[4];
- ThemeColorID color_id = TH_INFO_WARNING;
- if (icon == ALERT_ICON_ERROR) {
- color_id = TH_INFO_ERROR;
- }
- else if (icon == ALERT_ICON_INFO) {
- color_id = TH_INFO_INFO;
- }
- else if (icon == ALERT_ICON_QUESTION) {
- color_id = TH_INFO_PROPERTY;
- }
- UI_GetThemeColorType4ubv(color_id, SPACE_INFO, icon_color);
- return uiDefButImage(block, ibuf, x, y, width, height, icon_color);
+ bTheme *btheme = UI_GetTheme();
+ return uiDefButImage(block, ibuf, x, y, width, height, btheme->tui.wcol_menu_back.text);
}
/**
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index bcb8a10be02..dec1710ac69 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -783,7 +783,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(region),
GPU_blend(GPU_BLEND_NONE);
# if 0
- // restore scissortest
+ /* restore scissortest */
GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]);
# endif
diff --git a/source/blender/editors/interface/interface_eyedropper_driver.c b/source/blender/editors/interface/interface_eyedropper_driver.c
index 29c0368219b..8762a4819d4 100644
--- a/source/blender/editors/interface/interface_eyedropper_driver.c
+++ b/source/blender/editors/interface/interface_eyedropper_driver.c
@@ -58,7 +58,7 @@ typedef struct DriverDropper {
int index;
bool is_undo;
- // TODO: new target?
+ /* TODO: new target? */
} DriverDropper;
static bool driverdropper_init(bContext *C, wmOperator *op)
@@ -130,7 +130,7 @@ static void driverdropper_sample(bContext *C, wmOperator *op, const wmEvent *eve
UI_context_update_anim_flag(C);
DEG_relations_tag_update(CTX_data_main(C));
DEG_id_tag_update(ddr->ptr.owner_id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX
+ WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); /* XXX */
}
}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index def6e0d480d..0cc1932d88c 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2385,7 +2385,7 @@ static void ui_but_paste_numeric_array(bContext *C,
{
const int array_length = get_but_property_array_length(but);
if (array_length > 4) {
- // not supported for now
+ /* not supported for now */
return;
}
@@ -4998,7 +4998,7 @@ static int ui_do_but_NUM(
}
/* XXX hardcoded keymap check.... */
- if (type == MOUSEPAN && event->alt) {
+ if (type == MOUSEPAN && event->ctrl) {
/* allow accumulating values, otherwise scrolling gets preference */
retval = WM_UI_HANDLER_BREAK;
}
@@ -5310,7 +5310,7 @@ static int ui_do_but_SLI(
}
/* XXX hardcoded keymap check.... */
- if (type == MOUSEPAN && event->alt) {
+ if (type == MOUSEPAN && event->ctrl) {
/* allow accumulating values, otherwise scrolling gets preference */
retval = WM_UI_HANDLER_BREAK;
}
@@ -5747,7 +5747,7 @@ static bool ui_numedit_but_UNITVEC(
}
else { /* outer circle */
- mrad = rad / sqrtf(mrad); // veclen
+ mrad = rad / sqrtf(mrad); /* veclen */
dx *= (2.0f * mrad - 1.0f);
dy *= (2.0f * mrad - 1.0f);
@@ -6371,7 +6371,7 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but,
/* exception, when using color wheel in 'locked' value state:
* allow choosing a hue for black values, by giving a tiny increment */
if (cpicker->use_color_lock) {
- if (U.color_picker_type == USER_CP_CIRCLE_HSV) { // lock
+ if (U.color_picker_type == USER_CP_CIRCLE_HSV) { /* lock */
if (hsv[2] == 0.f) {
hsv[2] = 0.0001f;
}
@@ -6474,7 +6474,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but,
/* exception, when using color wheel in 'locked' value state:
* allow choosing a hue for black values, by giving a tiny increment */
if (cpicker->use_color_lock) {
- if (U.color_picker_type == USER_CP_CIRCLE_HSV) { // lock
+ if (U.color_picker_type == USER_CP_CIRCLE_HSV) { /* lock */
if (hsv[2] == 0.f) {
hsv[2] = 0.0001f;
}
@@ -7692,19 +7692,6 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
break;
}
- /* reset to default (generic function, only use if not handled by switch above) */
- /* XXX hardcoded keymap check.... */
- data = but->active;
- if (data && data->state == BUTTON_STATE_HIGHLIGHT) {
- if ((retval == WM_UI_HANDLER_CONTINUE) &&
- (event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS)) {
- /* ctrl+backspace = reset active button; backspace = reset a whole array*/
- ui_but_default_set(C, !event->ctrl, true);
- ED_region_tag_redraw(data->region);
- retval = WM_UI_HANDLER_BREAK;
- }
- }
-
#ifdef USE_DRAG_MULTINUM
if (data) {
if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) ||
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index b89f7a60ae1..fbe61a23d11 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -771,7 +771,7 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf,
const int asy = MAX2(by - blur_size, 0);
const int aey = MIN2(by + blur_size + 1, icon_height);
- // blur alpha channel
+ /* blur alpha channel */
const int write_offset = by * (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) + bx;
float alpha_accum = 0.0;
uint alpha_samples = 0;
@@ -908,7 +908,7 @@ void UI_icons_reload_internal_textures(void)
static void init_internal_icons(void)
{
-# if 0 // temp disabled
+# if 0 /* temp disabled */
if ((btheme != NULL) && btheme->tui.iconfile[0]) {
char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
char iconfilestr[FILE_MAX];
@@ -1299,7 +1299,7 @@ static void ui_studiolight_free_function(StudioLight *sl, void *data)
return;
}
- // get icons_id, get icons and kill wm jobs
+ /* get icons_id, get icons and kill wm jobs */
if (sl->icon_id_radiance) {
ui_studiolight_kill_icon_preview_job(wm, sl->icon_id_radiance);
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index dc1f6cfce50..5da3d9528f8 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -619,8 +619,6 @@ extern uiBut *ui_but_drag_multi_edit_get(uiBut *but);
void ui_def_but_icon(uiBut *but, const int icon, const int flag);
void ui_def_but_icon_clear(uiBut *but);
-extern void ui_but_default_set(struct bContext *C, const bool all, const bool use_afterfunc);
-
void ui_but_extra_operator_icons_free(uiBut *but);
extern void ui_but_rna_menu_convert_to_panel_type(struct uiBut *but, const char *panel_type);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b13dd24ea4b..3e276a69277 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -886,6 +886,8 @@ static void ui_item_enum_expand_tabs(uiLayout *layout,
uiBlock *block,
PointerRNA *ptr,
PropertyRNA *prop,
+ PointerRNA *ptr_highlight,
+ PropertyRNA *prop_highlight,
const char *uiname,
const int h,
const bool icon_only)
@@ -894,9 +896,24 @@ static void ui_item_enum_expand_tabs(uiLayout *layout,
ui_item_enum_expand_exec(layout, block, ptr, prop, uiname, h, UI_BTYPE_TAB, icon_only);
BLI_assert(last != block->buttons.last);
+
for (uiBut *tab = last ? last->next : block->buttons.first; tab; tab = tab->next) {
UI_but_drawflag_enable(tab, ui_but_align_opposite_to_area_align_get(CTX_wm_region(C)));
}
+
+ const bool use_custom_highlight = (prop_highlight != NULL);
+
+ if (use_custom_highlight) {
+ const int highlight_array_len = RNA_property_array_length(ptr_highlight, prop_highlight);
+ bool *highlight_array = alloca(sizeof(bool) * highlight_array_len);
+ RNA_property_boolean_get_array(ptr_highlight, prop_highlight, highlight_array);
+ int i = 0;
+ for (uiBut *tab_but = last ? last->next : block->buttons.first;
+ (tab_but != NULL) && (i < highlight_array_len);
+ tab_but = tab_but->next, i++) {
+ SET_FLAG_FROM_TEST(tab_but->flag, !highlight_array[i], UI_BUT_INACTIVE);
+ }
+ }
}
/* callback for keymap item change button */
@@ -3474,13 +3491,19 @@ void uiItemMenuEnumR(
uiItemMenuEnumR_prop(layout, ptr, prop, name, icon);
}
-void uiItemTabsEnumR_prop(
- uiLayout *layout, bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool icon_only)
+void uiItemTabsEnumR_prop(uiLayout *layout,
+ bContext *C,
+ PointerRNA *ptr,
+ PropertyRNA *prop,
+ PointerRNA *ptr_highlight,
+ PropertyRNA *prop_highlight,
+ bool icon_only)
{
uiBlock *block = layout->root->block;
UI_block_layout_set_current(block, layout);
- ui_item_enum_expand_tabs(layout, C, block, ptr, prop, NULL, UI_UNIT_Y, icon_only);
+ ui_item_enum_expand_tabs(
+ layout, C, block, ptr, prop, ptr_highlight, prop_highlight, NULL, UI_UNIT_Y, icon_only);
}
/** \} */
@@ -5577,6 +5600,19 @@ void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv)
layout->root->argv = argv;
}
+/**
+ * Used for property search when the layout process needs to be cancelled in order to avoid
+ * computing the locations for buttons, but the layout items created while adding the buttons
+ * must still be freed.
+ */
+void UI_block_layout_free(uiBlock *block)
+{
+ LISTBASE_FOREACH_MUTABLE (uiLayoutRoot *, root, &block->layouts) {
+ ui_layout_free(root->layout);
+ MEM_freeN(root);
+ }
+}
+
void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y)
{
BLI_assert(block->active);
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index c9f21c7fc2e..2b91d1b273d 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -558,6 +558,13 @@ static int override_type_set_button_exec(bContext *C, wmOperator *op)
IDOverrideLibraryPropertyOperation *opop = RNA_property_override_property_operation_get(
CTX_data_main(C), &ptr, prop, operation, index, true, NULL, &created);
+
+ if (opop == NULL) {
+ /* Sometimes e.g. RNA cannot generate a path to the given property. */
+ BKE_reportf(op->reports, RPT_WARNING, "Failed to create the override operation");
+ return OPERATOR_CANCELLED;
+ }
+
if (!created) {
opop->operation = operation;
}
@@ -809,6 +816,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_Keyframe)) {
+ *r_lb = CTX_data_collection_get(C, "selected_editable_keyframes");
+ }
else if (RNA_struct_is_a(ptr->type, &RNA_NlaStrip)) {
*r_lb = CTX_data_collection_get(C, "selected_nla_strips");
}
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 7e2ca776f5b..48abc1f4d82 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -78,6 +78,13 @@ typedef enum uiPanelRuntimeFlag {
PANEL_ANIM_ALIGN = (1 << 4),
PANEL_NEW_ADDED = (1 << 5),
PANEL_SEARCH_FILTER_MATCH = (1 << 7),
+ /**
+ * Use the status set by property search (#PANEL_SEARCH_FILTER_MATCH)
+ * instead of #PNL_CLOSED. Set to true on every property search update.
+ */
+ PANEL_USE_CLOSED_FROM_SEARCH = (1 << 8),
+ /** The Panel was before the start of the current / latest layout pass. */
+ PANEL_WAS_CLOSED = (1 << 9),
} uiPanelRuntimeFlag;
/* The state of the mouse position relative to the panel. */
@@ -168,7 +175,13 @@ static bool panel_active_animation_changed(ListBase *lb,
}
}
- if ((panel->runtime_flag & PANEL_ACTIVE) && !(panel->flag & PNL_CLOSED)) {
+ /* Detect changes in panel expansions. */
+ if ((bool)(panel->runtime_flag & PANEL_WAS_CLOSED) != UI_panel_is_closed(panel)) {
+ *r_panel_animation = panel;
+ return false;
+ }
+
+ if ((panel->runtime_flag & PANEL_ACTIVE) && !UI_panel_is_closed(panel)) {
if (panel_active_animation_changed(&panel->children, r_panel_animation, r_no_animation)) {
return true;
}
@@ -492,7 +505,8 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr
static bool panel_set_expand_from_list_data_recursive(Panel *panel, short flag, short *flag_index)
{
const bool open = (flag & (1 << *flag_index));
- bool changed = (open == (bool)(panel->flag & PNL_CLOSED));
+ bool changed = (open == UI_panel_is_closed(panel));
+
SET_FLAG_FROM_TEST(panel->flag, !open, PNL_CLOSED);
LISTBASE_FOREACH (Panel *, child, &panel->children) {
@@ -673,6 +687,7 @@ Panel *UI_panel_begin(
if (pt->flag & PNL_DEFAULT_CLOSED) {
panel->flag |= PNL_CLOSED;
+ panel->runtime_flag |= PANEL_WAS_CLOSED;
}
panel->ofsx = 0;
@@ -692,16 +707,6 @@ Panel *UI_panel_begin(
panel->runtime.block = block;
- /* Do not allow closed panels without headers! Else user could get "disappeared" UI! */
- if ((pt->flag & PNL_NO_HEADER) && (panel->flag & PNL_CLOSED)) {
- panel->flag &= ~PNL_CLOSED;
- /* Force update of panels' positions. */
- panel->sizex = 0;
- panel->sizey = 0;
- panel->blocksizex = 0;
- panel->blocksizey = 0;
- }
-
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.
@@ -737,7 +742,7 @@ Panel *UI_panel_begin(
*r_open = false;
- if (panel->flag & PNL_CLOSED) {
+ if (UI_panel_is_closed(panel)) {
return panel;
}
@@ -829,7 +834,7 @@ static void panel_calculate_size_recursive(ARegion *region, Panel *panel)
if (width != 0) {
panel->sizex = width;
}
- if (height != 0 || !(panel->flag & PNL_CLOSED)) {
+ if (height != 0 || !UI_panel_is_closed(panel)) {
panel->sizey = height;
}
@@ -902,39 +907,41 @@ bool UI_panel_matches_search_filter(const Panel *panel)
}
/**
- * Expands a panel if it was tagged as having a result by property search, otherwise collapses it.
+ * Set the flag telling the panel to use its search result status for
+ * its expansion. Also activate animation if that changes the expansion.
*/
static void panel_set_expansion_from_seach_filter_recursive(const bContext *C,
Panel *panel,
+ const bool use_search_closed,
const bool use_animation)
{
- if (!(panel->type->flag & PNL_NO_HEADER)) {
- short start_flag = panel->flag;
- SET_FLAG_FROM_TEST(panel->flag, !UI_panel_matches_search_filter(panel), PNL_CLOSED);
- if (use_animation && start_flag != panel->flag) {
- panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
- }
+ /* This has to run on inactive panels that may not have a type,
+ * but we can prevent running on headerless panels in some cases. */
+ if (panel->type == NULL || !(panel->type->flag & PNL_NO_HEADER)) {
+ SET_FLAG_FROM_TEST(panel->runtime_flag, use_search_closed, PANEL_USE_CLOSED_FROM_SEARCH);
}
- /* If the panel is filtered (removed) we need to check that its children are too. */
LISTBASE_FOREACH (Panel *, child_panel, &panel->children) {
- if (child_panel->runtime_flag & PANEL_ACTIVE) {
- panel_set_expansion_from_seach_filter_recursive(C, child_panel, use_animation);
- }
+ /* Don't check if the subpanel is active, otherwise the
+ * expansion won't be reset when the parent is closed. */
+ panel_set_expansion_from_seach_filter_recursive(
+ C, child_panel, use_search_closed, use_animation);
}
}
/**
- * Uses the panel's search filter flag to set its expansion, activating animation if it was closed
- * or opened. Note that this can't be set too often, or manual interaction becomes impossible.
+ * Set the flag telling every panel to override its expansion with its search result status.
*/
static void region_panels_set_expansion_from_seach_filter(const bContext *C,
ARegion *region,
+ const bool use_search_closed,
const bool use_animation)
{
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
+ /* Checking if the panel is active is only an optimization, it would be fine to run this on
+ * inactive panels. */
if (panel->runtime_flag & PANEL_ACTIVE) {
- panel_set_expansion_from_seach_filter_recursive(C, panel, use_animation);
+ panel_set_expansion_from_seach_filter_recursive(C, panel, use_search_closed, use_animation);
}
}
set_panels_list_data_expand_flag(C, region);
@@ -949,14 +956,14 @@ static void panel_remove_invisible_layouts_recursive(Panel *panel, const Panel *
uiBlock *block = panel->runtime.block;
BLI_assert(block != NULL);
BLI_assert(block->active);
- if (parent_panel != NULL && parent_panel->flag & PNL_CLOSED) {
+ if (parent_panel != NULL && UI_panel_is_closed(parent_panel)) {
/* The parent panel is closed, so this panel can be completely removed. */
UI_block_set_search_only(block, true);
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
but->flag |= UI_HIDDEN;
}
}
- else if (panel->flag & PNL_CLOSED) {
+ else if (UI_panel_is_closed(panel)) {
/* If subpanels have no search results but the parent panel does, then the parent panel open
* and the subpanels will close. In that case there must be a way to hide the buttons in the
* panel but keep the header buttons. */
@@ -989,6 +996,24 @@ static void region_panels_remove_invisible_layouts(ARegion *region)
}
}
+/**
+ * Get the panel's expansion state, taking into account
+ * expansion set from property search if it applies.
+ */
+bool UI_panel_is_closed(const Panel *panel)
+{
+ /* Header-less panels can never be closed, otherwise they could disappear. */
+ if (panel->type && panel->type->flag & PNL_NO_HEADER) {
+ return false;
+ }
+
+ if (panel->runtime_flag & PANEL_USE_CLOSED_FROM_SEARCH) {
+ return !UI_panel_matches_search_filter(panel);
+ }
+
+ return panel->flag & PNL_CLOSED;
+}
+
bool UI_panel_is_active(const Panel *panel)
{
return panel->runtime_flag & PANEL_ACTIVE;
@@ -1135,12 +1160,12 @@ void ui_draw_aligned_panel(const uiStyle *style,
/* Expand the top a tiny bit to give header buttons equal size above and below. */
rcti box_rect = {rect->xmin,
rect->xmax,
- (panel->flag & PNL_CLOSED) ? headrect.ymin : rect->ymin,
+ UI_panel_is_closed(panel) ? headrect.ymin : rect->ymin,
headrect.ymax + U.pixelsize};
ui_draw_box_opaque(&box_rect, UI_CNR_ALL);
/* Mimic the border between aligned box widgets for the bottom of the header. */
- if (!(panel->flag & PNL_CLOSED)) {
+ if (!UI_panel_is_closed(panel)) {
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
GPU_blend(GPU_BLEND_ALPHA);
@@ -1237,7 +1262,7 @@ void ui_draw_aligned_panel(const uiStyle *style,
}
/* Draw panel backdrop. */
- if (!(panel->flag & PNL_CLOSED)) {
+ if (!UI_panel_is_closed(panel)) {
/* in some occasions, draw a border */
if (panel->flag & PNL_SELECT && !is_subpanel) {
float radius;
@@ -1309,7 +1334,7 @@ void ui_draw_aligned_panel(const uiStyle *style,
rgb_uchar_to_float(tria_color, col_title);
tria_color[3] = 1.0f;
- if (panel->flag & PNL_CLOSED) {
+ if (UI_panel_is_closed(panel)) {
ui_draw_anti_tria_rect(&itemrect, 'h', tria_color);
}
else {
@@ -1581,7 +1606,7 @@ static int get_panel_size_y(const Panel *panel)
static int get_panel_real_size_y(const Panel *panel)
{
- const int sizey = (panel->flag & PNL_CLOSED) ? 0 : panel->sizey;
+ const int sizey = UI_panel_is_closed(panel) ? 0 : panel->sizey;
if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
return sizey;
@@ -1601,7 +1626,7 @@ int UI_panel_size_y(const Panel *panel)
*/
static int get_panel_real_ofsy(Panel *panel)
{
- if (panel->flag & PNL_CLOSED) {
+ if (UI_panel_is_closed(panel)) {
return panel->ofsy + panel->sizey;
}
return panel->ofsy;
@@ -1753,7 +1778,7 @@ static bool uiAlignPanelStep(ARegion *region, const float factor, const bool dra
}
ps->new_offset_y = y;
/* The header still draws offset by the size of closed panels, so apply the offset here. */
- if (ps->panel->flag & PNL_CLOSED) {
+ if (UI_panel_is_closed(ps->panel)) {
panel_sort[i].new_offset_y -= ps->panel->sizey;
}
}
@@ -1853,13 +1878,13 @@ static void panels_layout_begin_clear_flags(ListBase *lb)
{
LISTBASE_FOREACH (Panel *, panel, lb) {
/* Flags to copy over to the next layout pass. */
- const short flag_copy = 0;
+ const short flag_copy = PANEL_USE_CLOSED_FROM_SEARCH;
const bool was_active = panel->runtime_flag & PANEL_ACTIVE;
+ const bool was_closed = UI_panel_is_closed(panel);
panel->runtime_flag &= flag_copy;
- if (was_active) {
- panel->runtime_flag |= PANEL_WAS_ACTIVE;
- }
+ SET_FLAG_FROM_TEST(panel->runtime_flag, was_active, PANEL_WAS_ACTIVE);
+ SET_FLAG_FROM_TEST(panel->runtime_flag, was_closed, PANEL_WAS_CLOSED);
panels_layout_begin_clear_flags(&panel->children);
}
@@ -1878,16 +1903,16 @@ void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y)
region_panels_set_expansion_from_list_data(C, region);
- if (region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE) {
- /* Update panel expansion based on property search results. Keep this inside the check
- * for an active search filter, or all panels will be left closed when a search ends. */
- if (region->flag & RGN_FLAG_SEARCH_FILTER_UPDATE) {
- region_panels_set_expansion_from_seach_filter(C, region, true);
- }
- else if (properties_space_needs_realign(area, region)) {
- region_panels_set_expansion_from_seach_filter(C, region, false);
- }
+ const bool region_search_filter_active = region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE;
+
+ if (properties_space_needs_realign(area, region)) {
+ region_panels_set_expansion_from_seach_filter(C, region, region_search_filter_active, false);
+ }
+ else if (region->flag & RGN_FLAG_SEARCH_FILTER_UPDATE) {
+ region_panels_set_expansion_from_seach_filter(C, region, region_search_filter_active, true);
+ }
+ if (region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE) {
/* Clean up the extra panels and buttons created for searching. */
region_panels_remove_invisible_layouts(region);
}
@@ -1990,7 +2015,7 @@ static uiPanelMouseState ui_panel_mouse_state_get(const uiBlock *block,
return PANEL_MOUSE_INSIDE_HEADER;
}
- if (!(panel->flag & PNL_CLOSED)) {
+ if (!UI_panel_is_closed(panel)) {
if (IN_RANGE((float)my, block->rect.ymin, block->rect.ymax + PNL_HEADER)) {
return PANEL_MOUSE_INSIDE_CONTENT;
}
@@ -2041,6 +2066,7 @@ static void ui_panel_drag_collapse(const bContext *C,
/* Touch all panels between last mouse coordinate and the current one. */
if (BLI_rctf_isect_segment(&rect, xy_a_block, xy_b_block)) {
/* Force panel to open or close. */
+ panel->runtime_flag &= ~PANEL_USE_CLOSED_FROM_SEARCH;
SET_FLAG_FROM_TEST(panel->flag, dragcol_data->was_first_open, PNL_CLOSED);
/* If panel->flag has changed this means a panel was opened/closed here. */
@@ -2149,7 +2175,7 @@ static void ui_handle_panel_header(const bContext *C,
if (ELEM(event_type, EVT_RETKEY, EVT_PADENTER, EVT_AKEY) || mx < expansion_area_xmax) {
if (ctrl && !is_subpanel) {
/* For parent panels, collapse all other panels or toggle children. */
- if (panel->flag & PNL_CLOSED || BLI_listbase_is_empty(&panel->children)) {
+ if (UI_panel_is_closed(panel) || BLI_listbase_is_empty(&panel->children)) {
panels_collapse_all(region, panel);
/* Reset the view - we don't want to display a view without content. */
@@ -2160,12 +2186,12 @@ static void ui_handle_panel_header(const bContext *C,
* of the sub-panels (based on the expansion of the first sub-panel). */
Panel *first_child = panel->children.first;
BLI_assert(first_child != NULL);
- panel_set_flag_recursive(panel, PNL_CLOSED, !(first_child->flag & PNL_CLOSED));
+ panel_set_flag_recursive(panel, PNL_CLOSED, !UI_panel_is_closed(first_child));
panel->flag |= PNL_CLOSED;
}
}
- if (panel->flag & PNL_CLOSED) {
+ if (UI_panel_is_closed(panel)) {
panel->flag &= ~PNL_CLOSED;
/* Snap back up so full panel aligns with screen edge. */
if (panel->snap & PNL_SNAP_BOTTOM) {
@@ -2454,9 +2480,14 @@ int ui_handler_panel_region(bContext *C,
const uiPanelMouseState mouse_state = ui_panel_mouse_state_get(block, panel, mx, my);
- /* The panel collapse / expand key "A" is special as it takes priority over
- * active button handling. */
- if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER)) {
+ if (mouse_state != PANEL_MOUSE_OUTSIDE) {
+ /* Mark panels that have been interacted with so their expansion
+ * doesn't reset when property search finishes. */
+ SET_FLAG_FROM_TEST(panel->flag, UI_panel_is_closed(panel), PNL_CLOSED);
+ panel->runtime_flag &= ~PANEL_USE_CLOSED_FROM_SEARCH;
+
+ /* The panel collapse / expand key "A" is special as it takes priority over
+ * active button handling. */
if (event->type == EVT_AKEY && !IS_EVENT_MOD(event, shift, ctrl, alt, oskey)) {
retval = WM_UI_HANDLER_BREAK;
ui_handle_panel_header(C, block, mx, event->type, event->ctrl, event->shift);
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index 80776c8d26e..1a9a663f94e 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -247,6 +247,8 @@ uiPopupBlockHandle *ui_popover_panel_create(
bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg)
{
wmWindow *window = CTX_wm_window(C);
+ const uiStyle *style = UI_style_get_dpi();
+ const PanelType *panel_type = (PanelType *)arg;
/* Create popover, buttons are created from callback. */
uiPopover *pup = MEM_callocN(sizeof(uiPopover), __func__);
@@ -254,8 +256,12 @@ uiPopupBlockHandle *ui_popover_panel_create(
/* FIXME: maybe one day we want non panel popovers? */
{
- const int ui_units_x = ((PanelType *)arg)->ui_units_x;
- pup->ui_size_x = U.widget_unit * (ui_units_x ? ui_units_x : UI_POPOVER_WIDTH_UNITS);
+ const int ui_units_x = (panel_type->ui_units_x == 0) ? UI_POPOVER_WIDTH_UNITS :
+ panel_type->ui_units_x;
+ /* Scale width by changes to Text Style point size. */
+ const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points);
+ pup->ui_size_x = ui_units_x * U.widget_unit *
+ (text_points_max / (float)UI_DEFAULT_TEXT_POINTS);
}
pup->menu_func = menu_func;
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index b38ad9f6adb..c3d528ad5c5 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -81,7 +81,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
style->panelzoom = 1.0; /* unused */
style->paneltitle.uifont_id = uifont_id;
- style->paneltitle.points = 12;
+ style->paneltitle.points = UI_DEFAULT_TITLE_POINTS;
style->paneltitle.kerning = 1;
style->paneltitle.shadow = 3;
style->paneltitle.shadx = 0;
@@ -90,7 +90,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
style->paneltitle.shadowcolor = 0.0f;
style->grouplabel.uifont_id = uifont_id;
- style->grouplabel.points = 12;
+ style->grouplabel.points = UI_DEFAULT_TITLE_POINTS;
style->grouplabel.kerning = 1;
style->grouplabel.shadow = 3;
style->grouplabel.shadx = 0;
@@ -99,7 +99,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
style->grouplabel.shadowcolor = 0.0f;
style->widgetlabel.uifont_id = uifont_id;
- style->widgetlabel.points = 11;
+ style->widgetlabel.points = UI_DEFAULT_TEXT_POINTS;
style->widgetlabel.kerning = 1;
style->widgetlabel.shadow = 3;
style->widgetlabel.shadx = 0;
@@ -108,7 +108,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
style->widgetlabel.shadowcolor = 0.0f;
style->widget.uifont_id = uifont_id;
- style->widget.points = 11;
+ style->widget.points = UI_DEFAULT_TEXT_POINTS;
style->widget.kerning = 1;
style->widget.shadow = 1;
style->widget.shady = -1;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 6b11e727b66..592738bdb3b 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -98,7 +98,8 @@
#include "PIL_time.h"
-// #define USE_OP_RESET_BUT // we may want to make this optional, disable for now.
+/* we may want to make this optional, disable for now. */
+// #define USE_OP_RESET_BUT
/* defines for templateID/TemplateSearch */
#define TEMPLATE_SEARCH_TEXTBUT_WIDTH (UI_UNIT_X * 6)
@@ -5641,7 +5642,7 @@ static void uilist_draw_filter_default(struct uiList *ui_list,
"use_filter_invert",
UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY,
"",
- (ui_list->filter_flag & UILST_FLT_EXCLUDE) ? ICON_ZOOM_OUT : ICON_ZOOM_IN);
+ ICON_ARROW_LEFTRIGHT);
if ((ui_list->filter_sort_flag & UILST_FLT_SORT_LOCK) == 0) {
subrow = uiLayoutRow(row, true);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index becfab3cb07..68b804f5b28 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -4199,7 +4199,7 @@ static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundbox
/* Draw shaded outline - Disabled for now,
* seems incorrect and also looks nicer without it imho ;) */
- //#define USE_TAB_SHADED_HIGHLIGHT
+ // #define USE_TAB_SHADED_HIGHLIGHT
uiWidgetBase wtb;
uchar theme_col_tab_highlight[3];
@@ -4956,7 +4956,7 @@ static void ui_draw_popover_back_impl(const uiWidgetColors *wcol,
GPU_blend(GPU_BLEND_ALPHA);
immBegin(GPU_PRIM_TRIS, 3);
- immUniformColor4ub(UNPACK3(wcol->outline), 166);
+ immUniformColor4ubv(wcol->outline);
immVertex2f(pos, cent_x - unit_half, y);
immVertex2f(pos, cent_x + unit_half, y);
immVertex2f(pos, cent_x, y + sign * unit_half);
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index dddd6446c0e..f115618c13b 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -402,7 +402,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
* Ensure View2D rects remain in a viable configuration
* 'cur' is not allowed to be: larger than max, smaller than min, or outside of 'tot'
*/
-// XXX pre2.5 -> this used to be called test_view2d()
+/* XXX pre2.5 -> this used to be called test_view2d() */
static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize)
{
float totwidth, totheight, curwidth, curheight, width, height;
@@ -994,7 +994,7 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz
printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n",
(void *)v2d,
width,
- height); // XXX temp debug info
+ height); /* XXX temp debug info */
}
return;
}
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 38530fc4b5c..e4a7ad0d635 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1122,7 +1122,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
/* continuous zoom shouldn't move that fast... */
- if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
+ if (U.viewzoom == USER_ZOOM_CONT) { /* XXX store this setting as RNA prop? */
const double time = PIL_check_seconds_timer();
const float time_step = (float)(time - vzd->timer_lastdraw);
@@ -1406,7 +1406,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
* - Continuous zoom only depends on distance of mouse
* to starting point to determine rate of change.
*/
- if (U.viewzoom != USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
+ if (U.viewzoom != USER_ZOOM_CONT) { /* XXX store this setting as RNA prop? */
vzd->lastx = event->x;
vzd->lasty = event->y;
}
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index b91b3b92947..54ef5e6b8c5 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -222,12 +222,12 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
export_settings.keep_smooth_curves = keep_smooth_curves != 0;
if (export_animation_type != BC_ANIMATION_EXPORT_SAMPLES) {
- // When curves are exported then we can not export as matrix
+ /* When curves are exported then we can not export as matrix. */
export_settings.animation_transformation_type = BC_TRANSFORMATION_TYPE_DECOMPOSED;
}
if (export_settings.animation_transformation_type != BC_TRANSFORMATION_TYPE_DECOMPOSED) {
- // Can not export smooth curves when Matrix export is enabled.
+ /* Can not export smooth curves when Matrix export is enabled. */
export_settings.keep_smooth_curves = false;
}
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index b349def4637..b7ee50a9461 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -433,7 +433,7 @@ bool paintface_mouse_select(
/* image window redraw */
paintface_flush_flags(C, ob, SELECT);
- ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views
+ ED_region_tag_redraw(CTX_wm_region(C)); /* XXX - should redraw all 3D views */
return true;
}
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index 5ad1b5d67da..d5ddb7fc2c4 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -814,7 +814,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
mul_m4_v3(vc.obedit->obmat, ofs); /* view space */
ED_view3d_win_to_3d_int(vc.v3d, vc.region, ofs, event->mval, ofs);
- mul_m4_v3(vc.obedit->imat, ofs); // back in object space
+ mul_m4_v3(vc.obedit->imat, ofs); /* back in object space */
sub_v3_v3(ofs, local_center);
@@ -865,7 +865,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
copy_v3_v3(local_center, cursor);
ED_view3d_win_to_3d_int(vc.v3d, vc.region, local_center, event->mval, local_center);
- mul_m4_v3(vc.obedit->imat, local_center); // back in object space
+ mul_m4_v3(vc.obedit->imat, local_center); /* back in object space */
EDBM_op_init(vc.em, &bmop, op, "create_vert co=%v", local_center);
BMO_op_exec(vc.em->bm, &bmop);
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 02bcf97c87f..69d27cd5ffa 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -64,6 +64,11 @@
/* ringsel operator */
+struct MeshCoordsCache {
+ bool is_init, is_alloc;
+ const float (*coords)[3];
+};
+
/* struct for properties used while drawing */
typedef struct RingSelOpData {
ARegion *region; /* region that ringsel was activated in */
@@ -78,6 +83,8 @@ typedef struct RingSelOpData {
Base **bases;
uint bases_len;
+ struct MeshCoordsCache *geom_cache;
+
/* These values switch objects based on the object under the cursor. */
uint base_index;
Object *ob;
@@ -138,15 +145,18 @@ static void edgering_select(RingSelOpData *lcd)
static void ringsel_find_edge(RingSelOpData *lcd, const int previewlines)
{
if (lcd->eed) {
- const float(*coords)[3] = NULL;
- {
- Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(lcd->depsgraph, lcd->ob->data);
- if (me_eval->runtime.edit_data) {
- coords = me_eval->runtime.edit_data->vertexCos;
- }
+ struct MeshCoordsCache *gcache = &lcd->geom_cache[lcd->base_index];
+ if (gcache->is_init == false) {
+ Scene *scene_eval = (Scene *)DEG_get_evaluated_id(lcd->vc.depsgraph, &lcd->vc.scene->id);
+ Object *ob_eval = DEG_get_evaluated_object(lcd->vc.depsgraph, lcd->ob);
+ BMEditMesh *em_eval = BKE_editmesh_from_object(ob_eval);
+ gcache->coords = BKE_editmesh_vert_coords_when_deformed(
+ lcd->vc.depsgraph, em_eval, scene_eval, ob_eval, NULL, &gcache->is_alloc);
+ gcache->is_init = true;
}
+
EDBM_preselect_edgering_update_from_edge(
- lcd->presel_edgering, lcd->em->bm, lcd->eed, previewlines, coords);
+ lcd->presel_edgering, lcd->em->bm, lcd->eed, previewlines, gcache->coords);
}
else {
EDBM_preselect_edgering_clear(lcd->presel_edgering);
@@ -250,6 +260,14 @@ static void ringsel_exit(bContext *UNUSED(C), wmOperator *op)
EDBM_preselect_edgering_destroy(lcd->presel_edgering);
+ for (uint i = 0; i < lcd->bases_len; i++) {
+ struct MeshCoordsCache *gcache = &lcd->geom_cache[i];
+ if (gcache->is_alloc) {
+ MEM_freeN((void *)gcache->coords);
+ }
+ }
+ MEM_freeN(lcd->geom_cache);
+
MEM_freeN(lcd->bases);
ED_region_tag_redraw(lcd->region);
@@ -415,6 +433,7 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
lcd->bases = bases;
lcd->bases_len = bases_len;
+ lcd->geom_cache = MEM_callocN(sizeof(*lcd->geom_cache) * bases_len, __func__);
if (is_interactive) {
copy_v2_v2_int(lcd->vc.mval, event->mval);
@@ -544,7 +563,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case EVT_RETKEY:
case EVT_PADENTER:
- case LEFTMOUSE: /* confirm */ // XXX hardcoded
+ case LEFTMOUSE: /* confirm */ /* XXX hardcoded */
if (event->val == KM_PRESS) {
return loopcut_finish(lcd, C, op);
}
@@ -552,7 +571,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
ED_region_tag_redraw(lcd->region);
handled = true;
break;
- case RIGHTMOUSE: /* abort */ // XXX hardcoded
+ case RIGHTMOUSE: /* abort */ /* XXX hardcoded */
ED_region_tag_redraw(lcd->region);
ringsel_exit(C, op);
ED_workspace_status_text(C, NULL);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 52c109b3854..48405c7f534 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -3572,13 +3572,17 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
edbm_select_linked_pick_ex(em, ele, sel, delimit);
- /* to support redo */
- BM_mesh_elem_index_ensure(bm, ele->head.htype);
- index = EDBM_elem_to_index_any(em, ele);
-
- /* TODO(MULTI_EDIT), index doesn't know which object,
- * index selections isn't very common. */
- RNA_int_set(op->ptr, "index", index);
+ /* To support redo. */
+ {
+ /* Note that the `base_index` can't be used as the index depends on the view-port
+ * which might not be available on redo. */
+ BM_mesh_elem_index_ensure(bm, ele->head.htype);
+ int object_index;
+ index = EDBM_elem_to_index_any_multi(vc.view_layer, em, ele, &object_index);
+ BLI_assert(object_index >= 0);
+ RNA_int_set(op->ptr, "object_index", object_index);
+ RNA_int_set(op->ptr, "index", index);
+ }
DEG_id_tag_update(basact->object->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, basact->object->data);
@@ -3589,18 +3593,22 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
static int edbm_select_linked_pick_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMesh *bm = em->bm;
- int index;
- const bool sel = !RNA_boolean_get(op->ptr, "deselect");
+ Object *obedit = NULL;
+ BMElem *ele;
+
+ {
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ const int object_index = RNA_int_get(op->ptr, "object_index");
+ const int index = RNA_int_get(op->ptr, "index");
+ ele = EDBM_elem_from_index_any_multi(view_layer, object_index, index, &obedit);
+ }
- index = RNA_int_get(op->ptr, "index");
- if (index < 0 || index >= (bm->totvert + bm->totedge + bm->totface)) {
+ if (ele == NULL) {
return OPERATOR_CANCELLED;
}
- BMElem *ele = EDBM_elem_from_index_any(em, index);
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ const bool sel = !RNA_boolean_get(op->ptr, "deselect");
#ifdef USE_LINKED_SELECT_DEFAULT_HACK
int delimit = select_linked_delimit_default_from_op(op, em->selectmode);
@@ -3645,6 +3653,8 @@ void MESH_OT_select_linked_pick(wmOperatorType *ot)
#endif
/* use for redo */
+ prop = RNA_def_int(ot->srna, "object_index", -1, -1, INT_MAX, "", "", 0, INT_MAX);
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
prop = RNA_def_int(ot->srna, "index", -1, -1, INT_MAX, "", "", 0, INT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index 9f625fd0515..41d840c4a2d 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -35,6 +35,7 @@
#include "BKE_editmesh.h"
#include "BKE_key.h"
#include "BKE_layer.h"
+#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_undo_system.h"
@@ -508,7 +509,13 @@ static void *undomesh_from_editmesh(UndoMesh *um, BMEditMesh *em, Key *key)
}
#endif
/* make sure shape keys work */
- um->me.key = key ? BKE_key_copy_nolib(key) : NULL;
+ if (key != NULL) {
+ um->me.key = (Key *)BKE_id_copy_ex(
+ NULL, &key->id, NULL, LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA);
+ }
+ else {
+ um->me.key = NULL;
+ }
/* BM_mesh_validate(em->bm); */ /* for troubleshooting */
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 1182187b3ff..d7ed3dca1b1 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -38,6 +38,7 @@
#include "BKE_editmesh.h"
#include "BKE_editmesh_bvh.h"
#include "BKE_global.h"
+#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
@@ -1557,6 +1558,48 @@ BMElem *EDBM_elem_from_index_any(BMEditMesh *em, int index)
return NULL;
}
+int EDBM_elem_to_index_any_multi(ViewLayer *view_layer,
+ BMEditMesh *em,
+ BMElem *ele,
+ int *r_object_index)
+{
+ uint bases_len;
+ int elem_index = -1;
+ *r_object_index = -1;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(view_layer, NULL, &bases_len);
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Base *base_iter = bases[base_index];
+ if (BKE_editmesh_from_object(base_iter->object) == em) {
+ *r_object_index = base_index;
+ elem_index = EDBM_elem_to_index_any(em, ele);
+ break;
+ }
+ }
+ MEM_freeN(bases);
+ return elem_index;
+}
+
+BMElem *EDBM_elem_from_index_any_multi(ViewLayer *view_layer,
+ int object_index,
+ int elem_index,
+ Object **r_obedit)
+{
+ uint bases_len;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(view_layer, NULL, &bases_len);
+ *r_obedit = NULL;
+ Object *obedit = ((uint)object_index < bases_len) ? bases[object_index]->object : NULL;
+ MEM_freeN(bases);
+ if (obedit != NULL) {
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMElem *ele = EDBM_elem_from_index_any(em, elem_index);
+ if (ele != NULL) {
+ *r_obedit = obedit;
+ return ele;
+ }
+ }
+ return NULL;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index a1172d17fb0..21feddfb886 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -79,6 +79,15 @@ struct BMElem *EDBM_elem_from_selectmode(struct BMEditMesh *em,
int EDBM_elem_to_index_any(struct BMEditMesh *em, struct BMElem *ele);
struct BMElem *EDBM_elem_from_index_any(struct BMEditMesh *em, int index);
+int EDBM_elem_to_index_any_multi(struct ViewLayer *view_layer,
+ struct BMEditMesh *em,
+ struct BMElem *ele,
+ int *r_object_index);
+struct BMElem *EDBM_elem_from_index_any_multi(struct ViewLayer *view_layer,
+ int object_index,
+ int elem_index,
+ struct Object **r_obedit);
+
bool edbm_extrude_edges_indiv(struct BMEditMesh *em,
struct wmOperator *op,
const char hflag,
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 96f13578513..0ec7ca52263 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -285,7 +285,7 @@ float ED_object_new_primitive_matrix(
return dia;
}
- // return 1.0f;
+ /* return 1.0f; */
}
/** \} */
@@ -528,7 +528,6 @@ Object *ED_object_add_type_with_obdata(bContext *C,
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *ob;
/* For as long scene has editmode... */
{
@@ -539,6 +538,7 @@ Object *ED_object_add_type_with_obdata(bContext *C,
}
/* deselects all, sets active object */
+ Object *ob;
if (obdata != NULL) {
BLI_assert(type == BKE_object_obdata_to_type(obdata));
ob = BKE_object_add_for_data(bmain, view_layer, type, name, obdata, true);
@@ -595,18 +595,16 @@ Object *ED_object_add_type(bContext *C,
/* for object add operator */
static int object_add_exec(bContext *C, wmOperator *op)
{
- Object *ob;
- bool enter_editmode;
ushort local_view_bits;
+ bool enter_editmode;
float loc[3], rot[3], radius;
-
WM_operator_view3d_unit_defaults(C, op);
if (!ED_object_add_generic_get_opts(
C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
radius = RNA_float_get(op->ptr, "radius");
- ob = ED_object_add_type(
+ Object *ob = ED_object_add_type(
C, RNA_enum_get(op->ptr, "type"), NULL, loc, rot, enter_editmode, local_view_bits);
if (ob->type == OB_LATTICE) {
@@ -666,27 +664,22 @@ static const char *get_lightprobe_defname(int type)
static int lightprobe_add_exec(bContext *C, wmOperator *op)
{
- Object *ob;
- LightProbe *probe;
- int type;
bool enter_editmode;
ushort local_view_bits;
float loc[3], rot[3];
- float radius;
-
WM_operator_view3d_unit_defaults(C, op);
if (!ED_object_add_generic_get_opts(
C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
- type = RNA_enum_get(op->ptr, "type");
- radius = RNA_float_get(op->ptr, "radius");
+ int type = RNA_enum_get(op->ptr, "type");
+ float radius = RNA_float_get(op->ptr, "radius");
- ob = ED_object_add_type(
+ Object *ob = ED_object_add_type(
C, OB_LIGHTPROBE, get_lightprobe_defname(type), loc, rot, false, local_view_bits);
copy_v3_fl(ob->scale, radius);
- probe = (LightProbe *)ob->data;
+ LightProbe *probe = (LightProbe *)ob->data;
BKE_lightprobe_type_set(probe, type);
@@ -765,22 +758,18 @@ static const char *get_effector_defname(ePFieldType type)
static int effector_add_exec(bContext *C, wmOperator *op)
{
- Object *ob;
- int type;
bool enter_editmode;
ushort local_view_bits;
float loc[3], rot[3];
- float mat[4][4];
- float dia;
-
WM_operator_view3d_unit_defaults(C, op);
if (!ED_object_add_generic_get_opts(
C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
- type = RNA_enum_get(op->ptr, "type");
- dia = RNA_float_get(op->ptr, "radius");
+ int type = RNA_enum_get(op->ptr, "type");
+ float dia = RNA_float_get(op->ptr, "radius");
+ Object *ob;
if (type == PFIELD_GUIDE) {
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -791,6 +780,8 @@ static int effector_add_exec(bContext *C, wmOperator *op)
cu = ob->data;
cu->flag |= CU_PATH | CU_3D;
ED_object_editmode_enter_ex(bmain, scene, ob, 0);
+
+ float mat[4][4];
ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
BLI_addtail(&cu->editnurb->nurbs,
ED_curve_add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, dia));
@@ -845,20 +836,18 @@ static int object_camera_add_exec(bContext *C, wmOperator *op)
{
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
- Object *ob;
- Camera *cam;
- bool enter_editmode;
- ushort local_view_bits;
- float loc[3], rot[3];
/* force view align for cameras */
RNA_enum_set(op->ptr, "align", ALIGN_VIEW);
+ ushort local_view_bits;
+ bool enter_editmode;
+ float loc[3], rot[3];
if (!ED_object_add_generic_get_opts(
C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
- ob = ED_object_add_type(C, OB_CAMERA, NULL, loc, rot, false, local_view_bits);
+ Object *ob = ED_object_add_type(C, OB_CAMERA, NULL, loc, rot, false, local_view_bits);
if (v3d) {
if (v3d->camera == NULL) {
@@ -869,7 +858,7 @@ static int object_camera_add_exec(bContext *C, wmOperator *op)
}
}
- cam = ob->data;
+ Camera *cam = ob->data;
cam->drawsize = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) : ED_scene_grid_scale(scene, NULL);
return OPERATOR_FINISHED;
@@ -909,19 +898,18 @@ static int object_metaball_add_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);
- Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
- bool newob = false;
- bool enter_editmode;
+
ushort local_view_bits;
+ bool enter_editmode;
float loc[3], rot[3];
- float mat[4][4];
- float dia;
-
WM_operator_view3d_unit_defaults(C, op);
if (!ED_object_add_generic_get_opts(
C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
+
+ bool newob = false;
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
if (obedit == NULL || obedit->type != OB_MBALL) {
obedit = ED_object_add_type(C, OB_MBALL, NULL, loc, rot, true, local_view_bits);
newob = true;
@@ -930,11 +918,12 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
+ float mat[4][4];
ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
/* Halving here is done to account for constant values from #BKE_mball_element_add.
* While the default radius of the resulting meta element is 2,
* we want to pass in 1 so other values such as resolution are scaled by 1.0. */
- dia = RNA_float_get(op->ptr, "radius") / 2;
+ float dia = RNA_float_get(op->ptr, "radius") / 2;
ED_mball_add_primitive(C, obedit, newob, mat, dia, RNA_enum_get(op->ptr, "type"));
@@ -1621,15 +1610,14 @@ void OBJECT_OT_data_instance_add(wmOperatorType *ot)
static int object_speaker_add_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- Object *ob;
- ushort local_view_bits;
- float loc[3], rot[3];
Scene *scene = CTX_data_scene(C);
+ ushort local_view_bits;
+ float loc[3], rot[3];
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
- ob = ED_object_add_type(C, OB_SPEAKER, NULL, loc, rot, false, local_view_bits);
+ Object *ob = ED_object_add_type(C, OB_SPEAKER, NULL, loc, rot, false, local_view_bits);
/* to make it easier to start using this immediately in NLA, a default sound clip is created
* ready to be moved around to retime the sound and/or make new sound clips
@@ -1690,10 +1678,10 @@ static int object_hair_add_exec(bContext *C, wmOperator *op)
{
ushort local_view_bits;
float loc[3], rot[3];
-
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
+
Object *object = ED_object_add_type(C, OB_HAIR, NULL, loc, rot, false, local_view_bits);
object->dtx |= OB_DRAWBOUNDOX; /* TODO: remove once there is actual drawing. */
@@ -1735,10 +1723,10 @@ static int object_pointcloud_add_exec(bContext *C, wmOperator *op)
{
ushort local_view_bits;
float loc[3], rot[3];
-
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
+
Object *object = ED_object_add_type(C, OB_POINTCLOUD, NULL, loc, rot, false, local_view_bits);
object->dtx |= OB_DRAWBOUNDOX; /* TODO: remove once there is actual drawing. */
@@ -1791,7 +1779,6 @@ static int object_delete_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win;
const bool use_global = RNA_boolean_get(op->ptr, "use_global");
uint changed_count = 0;
@@ -1884,7 +1871,7 @@ static int object_delete_exec(bContext *C, wmOperator *op)
/* delete has to handle all open scenes */
BKE_main_id_tag_listbase(&bmain->scenes, LIB_TAG_DOIT, true);
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
scene = WM_window_get_active_scene(win);
if (scene->id.tag & LIB_TAG_DOIT) {
@@ -2076,18 +2063,16 @@ static void make_object_duplilist_real(bContext *C,
{
Main *bmain = CTX_data_main(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- ListBase *lb_duplis;
- DupliObject *dob;
- GHash *dupli_gh, *parent_gh = NULL, *instancer_gh = NULL;
+ GHash *parent_gh = NULL, *instancer_gh = NULL;
if (!(base->object->transflag & OB_DUPLI)) {
return;
}
Object *object_eval = DEG_get_evaluated_object(depsgraph, base->object);
- lb_duplis = object_duplilist(depsgraph, scene, object_eval);
+ ListBase *lb_duplis = object_duplilist(depsgraph, scene, object_eval);
- dupli_gh = BLI_ghash_ptr_new(__func__);
+ GHash *dupli_gh = BLI_ghash_ptr_new(__func__);
if (use_hierarchy) {
parent_gh = BLI_ghash_new(dupliobject_hash, dupliobject_cmp, __func__);
@@ -2097,11 +2082,10 @@ static void make_object_duplilist_real(bContext *C,
}
}
- for (dob = lb_duplis->first; dob; dob = dob->next) {
+ LISTBASE_FOREACH (DupliObject *, dob, lb_duplis) {
Object *ob_src = DEG_get_original_object(dob->ob);
Object *ob_dst = ID_NEW_SET(ob_src, BKE_id_copy(bmain, &ob_src->id));
id_us_min(&ob_dst->id);
- Base *base_dst;
/* font duplis can have a totcol without material, we get them from parent
* should be implemented better...
@@ -2111,7 +2095,7 @@ static void make_object_duplilist_real(bContext *C,
}
BKE_collection_object_add_from(bmain, scene, base->object, ob_dst);
- base_dst = BKE_view_layer_base_find(view_layer, ob_dst);
+ Base *base_dst = BKE_view_layer_base_find(view_layer, ob_dst);
BLI_assert(base_dst != NULL);
ED_object_base_select(base_dst, BA_SELECT);
@@ -2160,7 +2144,7 @@ static void make_object_duplilist_real(bContext *C,
}
}
- for (dob = lb_duplis->first; dob; dob = dob->next) {
+ LISTBASE_FOREACH (DupliObject *, dob, lb_duplis) {
Object *ob_src = dob->ob;
Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob);
@@ -2242,7 +2226,7 @@ static void make_object_duplilist_real(bContext *C,
}
if (base->object->transflag & OB_DUPLICOLLECTION && base->object->instance_collection) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
if (ob->proxy_group == base->object) {
ob->proxy = NULL;
ob->proxy_from = NULL;
@@ -2425,19 +2409,16 @@ static bool object_convert_poll(bContext *C)
static Base *duplibase_for_convert(
Main *bmain, Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer, Base *base, Object *ob)
{
- Object *obn;
- Base *basen;
-
if (ob == NULL) {
ob = base->object;
}
- obn = (Object *)BKE_id_copy(bmain, &ob->id);
+ Object *obn = (Object *)BKE_id_copy(bmain, &ob->id);
id_us_min(&obn->id);
DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
BKE_collection_object_add_from(bmain, scene, ob, obn);
- basen = BKE_view_layer_base_find(view_layer, obn);
+ Base *basen = BKE_view_layer_base_find(view_layer, obn);
ED_object_base_select(basen, BA_SELECT);
ED_object_base_select(base, BA_DESELECT);
@@ -2484,12 +2465,6 @@ static int object_convert_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
Base *basen = NULL, *basact = NULL;
Object *ob1, *obact = CTX_data_active_object(C);
- Curve *cu;
- Nurb *nu;
- MetaBall *mb;
- Mesh *me;
- Object *ob_gpencil = NULL;
- PointCloud *pointcloud;
const short target = RNA_enum_get(op->ptr, "target");
bool keep_original = RNA_boolean_get(op->ptr, "keep_original");
@@ -2593,7 +2568,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
newob = basen->object;
/* decrement original mesh's usage count */
- me = newob->data;
+ Mesh *me = newob->data;
id_us_min(&me->id);
/* make a new copy of the mesh */
@@ -2622,7 +2597,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
mat4_to_loc_rot_size(loc, rot, size, ob->obmat);
mat3_to_eul(eul, rot);
- ob_gpencil = ED_gpencil_add_object(C, loc, local_view_bits);
+ Object *ob_gpencil = ED_gpencil_add_object(C, loc, local_view_bits);
copy_v3_v3(ob_gpencil->loc, loc);
copy_v3_v3(ob_gpencil->rot, eul);
copy_v3_v3(ob_gpencil->scale, size);
@@ -2667,7 +2642,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
newob = basen->object;
/* decrement original mesh's usage count */
- me = newob->data;
+ Mesh *me = newob->data;
id_us_min(&me->id);
/* make a new copy of the mesh */
@@ -2692,7 +2667,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
newob = basen->object;
/* decrement original mesh's usage count */
- me = newob->data;
+ Mesh *me = newob->data;
id_us_min(&me->id);
/* make a new copy of the mesh */
@@ -2731,7 +2706,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
newob = ob;
}
- cu = newob->data;
+ Curve *cu = newob->data;
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
BKE_vfont_to_curve_ex(ob_eval, ob_eval->data, FO_EDIT, &cu->nurb, NULL, NULL, NULL, NULL);
@@ -2769,7 +2744,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
}
}
- for (nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
nu->charidx = 0;
}
@@ -2818,7 +2793,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
* Nurbs Surface are not supported.
*/
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
- ob_gpencil = ED_gpencil_add_object(C, ob->loc, local_view_bits);
+ Object *ob_gpencil = ED_gpencil_add_object(C, ob->loc, local_view_bits);
copy_v3_v3(ob_gpencil->rot, ob->rot);
copy_v3_v3(ob_gpencil->scale, ob->scale);
BKE_gpencil_convert_curve(bmain, scene, ob_gpencil, ob, false, 1.0f, 0.0f);
@@ -2843,13 +2818,13 @@ static int object_convert_exec(bContext *C, wmOperator *op)
basen = duplibase_for_convert(bmain, depsgraph, scene, view_layer, base, baseob);
newob = basen->object;
- mb = newob->data;
+ MetaBall *mb = newob->data;
id_us_min(&mb->id);
newob->data = BKE_mesh_add(bmain, "Mesh");
newob->type = OB_MESH;
- me = newob->data;
+ Mesh *me = newob->data;
me->totcol = mb->totcol;
if (newob->totcol) {
me->mat = MEM_dupallocN(mb->mat);
@@ -2877,7 +2852,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
newob = basen->object;
/* decrement original pointclouds's usage count */
- pointcloud = newob->data;
+ PointCloud *pointcloud = newob->data;
id_us_min(&pointcloud->id);
/* make a new copy of the pointcloud */
@@ -3110,7 +3085,7 @@ static Base *object_add_duplicate_internal(Main *bmain,
/* 1) duplis should end up in same collection as the original
* 2) Rigid Body sim participants MUST always be part of a collection...
*/
- // XXX: is 2) really a good measure here?
+ /* XXX: is 2) really a good measure here? */
if (ob->rigidbody_object || ob->rigidbody_constraint) {
Collection *collection;
for (collection = bmain->collections.first; collection; collection = collection->id.next) {
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 9b8a50cfe89..0073aa830de 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -111,9 +111,9 @@ ListBase *ED_object_constraint_active_list(Object *ob)
*/
ListBase *ED_object_pose_constraint_list(const bContext *C)
{
- bPoseChannel *pose_bone = CTX_data_pointer_get(C, "active_pose_bone").data;
+ bPoseChannel *pose_bone = CTX_data_pointer_get(C, "pose_bone").data;
if (pose_bone == NULL) {
- pose_bone = CTX_data_pointer_get(C, "pose_bone").data;
+ pose_bone = CTX_data_pointer_get(C, "active_pose_bone").data;
if (pose_bone == NULL) {
return NULL;
}
@@ -242,7 +242,7 @@ static char *buildmenu_pyconstraints(Main *bmain, Text *con_text, int *pyconinde
}
#endif /* WITH_PYTHON */
-#if 0 // UNUSED, until pyconstraints are added back.
+#if 0 /* UNUSED, until pyconstraints are added back. */
/* this callback gets called when the 'refresh' button of a pyconstraint gets pressed */
static void update_pyconstraint_cb(void *arg1, void *arg2)
{
@@ -257,7 +257,7 @@ static void update_pyconstraint_cb(void *arg1, void *arg2)
}
# endif
}
-#endif // UNUSED
+#endif /* UNUSED */
/** \} */
@@ -1747,8 +1747,8 @@ void POSE_OT_constraints_clear(wmOperatorType *ot)
/* callbacks */
ot->exec = pose_constraints_clear_exec;
- ot->poll = ED_operator_posemode_exclusive; // XXX - do we want to ensure there are selected
- // bones too?
+ ot->poll = ED_operator_posemode_exclusive; /* XXX - do we want to ensure there are selected
+ * bones too? */
}
static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
@@ -2333,7 +2333,7 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot)
* \note Only for pose-channels.
* \{ */
-// TODO: should these be here, or back in editors/armature/poseobject.c again?
+/* TODO: should these be here, or back in editors/armature/poseobject.c again? */
/* present menu with options + validation for targets to use */
static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 69e734de8ee..3e7f028bd95 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -24,7 +24,7 @@
#include <ctype.h>
#include <float.h>
#include <math.h>
-#include <stddef.h> //for offsetof
+#include <stddef.h> /* for offsetof */
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -114,7 +114,7 @@
#include "WM_toolsystem.h"
#include "WM_types.h"
-#include "object_intern.h" // own include
+#include "object_intern.h" /* own include */
static CLG_LogRef LOG = {"ed.object.edit"};
@@ -257,6 +257,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op)
BKE_layer_collection_sync(scene, view_layer);
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene);
return OPERATOR_FINISHED;
}
@@ -314,6 +315,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
BKE_layer_collection_sync(scene, view_layer);
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 567e97a71ee..4eed9187d66 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -243,9 +243,7 @@ ModifierData *ED_object_modifier_add(
* the modifier pointed to be 'exclude', otherwise returns false. */
static bool object_has_modifier(const Object *ob, const ModifierData *exclude, ModifierType type)
{
- ModifierData *md;
-
- for (md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if ((md != exclude) && (md->type == type)) {
return true;
}
@@ -309,10 +307,9 @@ static bool object_has_modifier_cb(Object *ob, void *data)
* callback_data. */
bool ED_object_multires_update_totlevels_cb(Object *ob, void *totlevel_v)
{
- ModifierData *md;
int totlevel = *((char *)totlevel_v);
- for (md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Multires) {
multires_set_tot_level(ob, (MultiresModifierData *)md, totlevel);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@@ -392,9 +389,8 @@ bool ED_object_modifier_remove(
ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md)
{
bool sort_depsgraph = false;
- bool ok;
- ok = object_modifier_remove(bmain, scene, ob, md, &sort_depsgraph);
+ bool ok = object_modifier_remove(bmain, scene, ob, md, &sort_depsgraph);
if (!ok) {
BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", md->name, ob->id.name);
@@ -417,9 +413,7 @@ void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob)
}
while (md) {
- ModifierData *next_md;
-
- next_md = md->next;
+ ModifierData *next_md = md->next;
object_modifier_remove(bmain, scene, ob, md, &sort_depsgraph);
@@ -547,16 +541,7 @@ bool ED_object_modifier_convert(ReportList *UNUSED(reports),
Object *ob,
ModifierData *md)
{
- Object *obn;
- ParticleSystem *psys_orig, *psys_eval;
- ParticleCacheKey *key, **cache;
- ParticleSettings *part;
- Mesh *me;
- MVert *mvert;
- MEdge *medge;
- int a, k, kmax;
- int totvert = 0, totedge = 0, cvert = 0;
- int totpart = 0, totchild = 0;
+ int cvert = 0;
if (md->type != eModifierType_ParticleSystem) {
return false;
@@ -565,28 +550,29 @@ bool ED_object_modifier_convert(ReportList *UNUSED(reports),
return false;
}
- psys_orig = ((ParticleSystemModifierData *)md)->psys;
- part = psys_orig->part;
+ ParticleSystem *psys_orig = ((ParticleSystemModifierData *)md)->psys;
+ ParticleSettings *part = psys_orig->part;
if (part->ren_as != PART_DRAW_PATH) {
return false;
}
- psys_eval = psys_eval_get(depsgraph, ob, psys_orig);
+ ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys_orig);
if (psys_eval->pathcache == NULL) {
return false;
}
- totpart = psys_eval->totcached;
- totchild = psys_eval->totchildcache;
+ int totpart = psys_eval->totcached;
+ int totchild = psys_eval->totchildcache;
if (totchild && (part->draw & PART_DRAW_PARENT) == 0) {
totpart = 0;
}
/* count */
- cache = psys_eval->pathcache;
- for (a = 0; a < totpart; a++) {
- key = cache[a];
+ int totvert = 0, totedge = 0;
+ ParticleCacheKey **cache = psys_eval->pathcache;
+ for (int a = 0; a < totpart; a++) {
+ ParticleCacheKey *key = cache[a];
if (key->segments > 0) {
totvert += key->segments + 1;
@@ -595,8 +581,8 @@ bool ED_object_modifier_convert(ReportList *UNUSED(reports),
}
cache = psys_eval->childcache;
- for (a = 0; a < totchild; a++) {
- key = cache[a];
+ for (int a = 0; a < totchild; a++) {
+ ParticleCacheKey *key = cache[a];
if (key->segments > 0) {
totvert += key->segments + 1;
@@ -609,8 +595,8 @@ bool ED_object_modifier_convert(ReportList *UNUSED(reports),
}
/* add new mesh */
- obn = BKE_object_add(bmain, view_layer, OB_MESH, NULL);
- me = obn->data;
+ Object *obn = BKE_object_add(bmain, view_layer, OB_MESH, NULL);
+ Mesh *me = obn->data;
me->totvert = totvert;
me->totedge = totedge;
@@ -619,15 +605,15 @@ bool ED_object_modifier_convert(ReportList *UNUSED(reports),
me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0);
- mvert = me->mvert;
- medge = me->medge;
+ MVert *mvert = me->mvert;
+ MEdge *medge = me->medge;
/* copy coordinates */
cache = psys_eval->pathcache;
- for (a = 0; a < totpart; a++) {
- key = cache[a];
- kmax = key->segments;
- for (k = 0; k <= kmax; k++, key++, cvert++, mvert++) {
+ for (int a = 0; a < totpart; a++) {
+ ParticleCacheKey *key = cache[a];
+ int kmax = key->segments;
+ for (int k = 0; k <= kmax; k++, key++, cvert++, mvert++) {
copy_v3_v3(mvert->co, key->co);
if (k) {
medge->v1 = cvert - 1;
@@ -643,10 +629,10 @@ bool ED_object_modifier_convert(ReportList *UNUSED(reports),
}
cache = psys_eval->childcache;
- for (a = 0; a < totchild; a++) {
- key = cache[a];
- kmax = key->segments;
- for (k = 0; k <= kmax; k++, key++, cvert++, mvert++) {
+ for (int a = 0; a < totchild; a++) {
+ ParticleCacheKey *key = cache[a];
+ int kmax = key->segments;
+ for (int k = 0; k <= kmax; k++, key++, cvert++, mvert++) {
copy_v3_v3(mvert->co, key->co);
if (k) {
medge->v1 = cvert - 1;
@@ -708,7 +694,6 @@ static int modifier_apply_shape(Main *bmain,
Mesh *mesh_applied;
Mesh *me = ob->data;
Key *key = me->key;
- KeyBlock *kb;
if (!BKE_modifier_is_same_topology(md_eval) || mti->type == eModifierTypeType_NonGeometrical) {
BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to shapes");
@@ -726,11 +711,11 @@ static int modifier_apply_shape(Main *bmain,
key->type = KEY_RELATIVE;
/* if that was the first key block added, then it was the basis.
* Initialize it with the mesh, and add another for the modifier */
- kb = BKE_keyblock_add(key, NULL);
+ KeyBlock *kb = BKE_keyblock_add(key, NULL);
BKE_keyblock_convert_from_mesh(me, key, kb);
}
- kb = BKE_keyblock_add(key, md_eval->name);
+ KeyBlock *kb = BKE_keyblock_add(key, md_eval->name);
BKE_mesh_nomain_to_meshkey(mesh_applied, me, kb);
BKE_id_free(NULL, mesh_applied);
@@ -792,8 +777,6 @@ static int modifier_apply_obdata(
Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
Curve *curve = ob->data;
Curve *curve_eval = (Curve *)object_eval->data;
- int numVerts;
- float(*vertexCos)[3];
ModifierEvalContext mectx = {depsgraph, object_eval, 0};
if (ELEM(mti->type, eModifierTypeType_Constructive, eModifierTypeType_Nonconstructive)) {
@@ -806,7 +789,8 @@ static int modifier_apply_obdata(
RPT_INFO,
"Applied modifier only changed CV points, not tessellated/bevel vertices");
- vertexCos = BKE_curve_nurbs_vert_coords_alloc(&curve_eval->nurb, &numVerts);
+ int numVerts;
+ float(*vertexCos)[3] = BKE_curve_nurbs_vert_coords_alloc(&curve_eval->nurb, &numVerts);
mti->deformVerts(md_eval, &mectx, NULL, vertexCos, numVerts);
BKE_curve_nurbs_vert_coords_apply(&curve->nurb, vertexCos, false);
@@ -822,11 +806,7 @@ static int modifier_apply_obdata(
/* lattice modifier can be applied to particle system too */
if (ob->particlesystem.first) {
-
- ParticleSystem *psys = ob->particlesystem.first;
-
- for (; psys; psys = psys->next) {
-
+ LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
if (psys->part->type != PART_HAIR) {
continue;
}
@@ -847,8 +827,6 @@ bool ED_object_modifier_apply(Main *bmain,
int mode,
bool keep_modifier)
{
- int prev_mode;
-
if (BKE_object_is_in_editmode(ob)) {
BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in edit mode");
return false;
@@ -875,7 +853,7 @@ bool ED_object_modifier_apply(Main *bmain,
ModifierData *md_eval = (ob_eval) ? BKE_modifiers_findby_name(ob_eval, md->name) : md;
/* allow apply of a not-realtime modifier, by first re-enabling realtime. */
- prev_mode = md_eval->mode;
+ int prev_mode = md_eval->mode;
md_eval->mode |= eModifierMode_Realtime;
if (mode == MODIFIER_APPLY_SHAPE) {
@@ -953,20 +931,20 @@ static const EnumPropertyItem *modifier_add_itemf(bContext *C,
bool *r_free)
{
Object *ob = ED_object_active_context(C);
- EnumPropertyItem *item = NULL;
- const EnumPropertyItem *md_item, *group_item = NULL;
- const ModifierTypeInfo *mti;
- int totitem = 0, a;
if (!ob) {
return rna_enum_object_modifier_type_items;
}
- for (a = 0; rna_enum_object_modifier_type_items[a].identifier; a++) {
- md_item = &rna_enum_object_modifier_type_items[a];
+ EnumPropertyItem *items = NULL;
+ int totitem = 0;
+
+ const EnumPropertyItem *group_item = NULL;
+ for (int a = 0; rna_enum_object_modifier_type_items[a].identifier; a++) {
+ const EnumPropertyItem *md_item = &rna_enum_object_modifier_type_items[a];
if (md_item->identifier[0]) {
- mti = BKE_modifier_get_info(md_item->value);
+ const ModifierTypeInfo *mti = BKE_modifier_get_info(md_item->value);
if (mti->flags & eModifierTypeFlag_NoUserAdd) {
continue;
@@ -978,23 +956,21 @@ static const EnumPropertyItem *modifier_add_itemf(bContext *C,
}
else {
group_item = md_item;
- md_item = NULL;
-
continue;
}
if (group_item) {
- RNA_enum_item_add(&item, &totitem, group_item);
+ RNA_enum_item_add(&items, &totitem, group_item);
group_item = NULL;
}
- RNA_enum_item_add(&item, &totitem, md_item);
+ RNA_enum_item_add(&items, &totitem, md_item);
}
- RNA_enum_item_end(&item, &totitem);
+ RNA_enum_item_end(&items, &totitem);
*r_free = true;
- return item;
+ return items;
}
void OBJECT_OT_modifier_add(wmOperatorType *ot)
@@ -1139,10 +1115,9 @@ bool edit_modifier_invoke_properties(bContext *C,
ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type)
{
char modifier_name[MAX_NAME];
- ModifierData *md;
RNA_string_get(op->ptr, "modifier", modifier_name);
- md = BKE_modifiers_findby_name(ob, modifier_name);
+ ModifierData *md = BKE_modifiers_findby_name(ob, modifier_name);
if (md && type != 0 && md->type != type) {
md = NULL;
@@ -1860,7 +1835,6 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Object *ob = ED_object_active_context(C);
- MultiresModifierData *mmd;
Mesh *me = ob->data;
char path[FILE_MAX];
@@ -1868,7 +1842,8 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEv
return OPERATOR_CANCELLED;
}
- mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires);
+ MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(
+ op, ob, eModifierType_Multires);
if (!mmd) {
return OPERATOR_CANCELLED;
@@ -2167,16 +2142,15 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_edit_object(C);
BMEditMesh *em = BKE_editmesh_from_object(ob);
BMesh *bm = em->bm;
- BMVert *bm_vert;
- BMIter bm_iter;
- GSet *visited;
- visited = BLI_gset_ptr_new(__func__);
+ GSet *visited = BLI_gset_ptr_new(__func__);
BKE_mesh_ensure_skin_customdata(ob->data);
const int cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN);
+ BMVert *bm_vert;
+ BMIter bm_iter;
BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(bm_vert, BM_ELEM_SELECT) && BLI_gset_add(visited, bm_vert)) {
MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(bm_vert, cd_vert_skin_offset);
@@ -2220,14 +2194,14 @@ static int skin_loose_mark_clear_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_edit_object(C);
BMEditMesh *em = BKE_editmesh_from_object(ob);
BMesh *bm = em->bm;
- BMVert *bm_vert;
- BMIter bm_iter;
SkinLooseAction action = RNA_enum_get(op->ptr, "action");
if (!CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN)) {
return OPERATOR_CANCELLED;
}
+ BMVert *bm_vert;
+ BMIter bm_iter;
BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(bm_vert, BM_ELEM_SELECT)) {
MVertSkin *vs = CustomData_bmesh_get(&bm->vdata, bm_vert->head.data, CD_MVERT_SKIN);
@@ -2275,13 +2249,13 @@ static int skin_radii_equalize_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_edit_object(C);
BMEditMesh *em = BKE_editmesh_from_object(ob);
BMesh *bm = em->bm;
- BMVert *bm_vert;
- BMIter bm_iter;
if (!CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN)) {
return OPERATOR_CANCELLED;
}
+ BMVert *bm_vert;
+ BMIter bm_iter;
BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(bm_vert, BM_ELEM_SELECT)) {
MVertSkin *vs = CustomData_bmesh_get(&bm->vdata, bm_vert->head.data, CD_MVERT_SKIN);
@@ -2319,14 +2293,9 @@ static void skin_armature_bone_create(Object *skin_ob,
EditBone *parent_bone,
int parent_v)
{
- int i;
-
- for (i = 0; i < emap[parent_v].count; i++) {
+ for (int i = 0; i < emap[parent_v].count; i++) {
int endx = emap[parent_v].indices[i];
const MEdge *e = &medge[endx];
- EditBone *bone;
- bDeformGroup *dg;
- int v;
/* ignore edge if already visited */
if (BLI_BITMAP_TEST(edges_visited, endx)) {
@@ -2334,9 +2303,9 @@ static void skin_armature_bone_create(Object *skin_ob,
}
BLI_BITMAP_ENABLE(edges_visited, endx);
- v = (e->v1 == parent_v ? e->v2 : e->v1);
+ int v = (e->v1 == parent_v ? e->v2 : e->v1);
- bone = ED_armature_ebone_add(arm, "Bone");
+ EditBone *bone = ED_armature_ebone_add(arm, "Bone");
bone->parent = parent_bone;
bone->flag |= BONE_CONNECTED;
@@ -2347,7 +2316,8 @@ static void skin_armature_bone_create(Object *skin_ob,
BLI_snprintf(bone->name, sizeof(bone->name), "Bone.%.2d", endx);
/* add bDeformGroup */
- if ((dg = BKE_object_defgroup_add_name(skin_ob, bone->name))) {
+ bDeformGroup *dg = BKE_object_defgroup_add_name(skin_ob, bone->name);
+ if (dg != NULL) {
ED_vgroup_vert_add(skin_ob, dg, parent_v, 1, WEIGHT_REPLACE);
ED_vgroup_vert_add(skin_ob, dg, v, 1, WEIGHT_REPLACE);
}
@@ -2358,43 +2328,36 @@ static void skin_armature_bone_create(Object *skin_ob,
static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain, Object *skin_ob)
{
- BLI_bitmap *edges_visited;
- Mesh *me_eval_deform;
- MVert *mvert;
Mesh *me = skin_ob->data;
- Object *arm_ob;
- bArmature *arm;
- MVertSkin *mvert_skin;
- MeshElemMap *emap;
- int *emap_mem;
- int v;
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, skin_ob);
- me_eval_deform = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
- mvert = me_eval_deform->mvert;
+ Mesh *me_eval_deform = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
+ MVert *mvert = me_eval_deform->mvert;
/* add vertex weights to original mesh */
CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, me->totvert);
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
- arm_ob = BKE_object_add(bmain, view_layer, OB_ARMATURE, NULL);
+ Object *arm_ob = BKE_object_add(bmain, view_layer, OB_ARMATURE, NULL);
BKE_object_transform_copy(arm_ob, skin_ob);
- arm = arm_ob->data;
+ bArmature *arm = arm_ob->data;
arm->layer = 1;
arm_ob->dtx |= OB_DRAW_IN_FRONT;
arm->drawtype = ARM_LINE;
arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature");
- mvert_skin = CustomData_get_layer(&me->vdata, CD_MVERT_SKIN);
+ MVertSkin *mvert_skin = CustomData_get_layer(&me->vdata, CD_MVERT_SKIN);
+ int *emap_mem;
+ MeshElemMap *emap;
BKE_mesh_vert_edge_map_create(&emap, &emap_mem, me->medge, me->totvert, me->totedge);
- edges_visited = BLI_BITMAP_NEW(me->totedge, "edge_visited");
+ BLI_bitmap *edges_visited = BLI_BITMAP_NEW(me->totedge, "edge_visited");
/* note: we use EditBones here, easier to set them up and use
* edit-armature functions to convert back to regular bones */
- for (v = 0; v < me->totvert; v++) {
+ for (int v = 0; v < me->totvert; v++) {
if (mvert_skin[v].flag & MVERT_SKIN_ROOT) {
EditBone *bone = NULL;
@@ -2431,10 +2394,9 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- Object *ob = CTX_data_active_object(C), *arm_ob;
+ Object *ob = CTX_data_active_object(C);
Mesh *me = ob->data;
ModifierData *skin_md;
- ArmatureModifierData *arm_md;
if (!CustomData_has_layer(&me->vdata, CD_MVERT_SKIN)) {
BKE_reportf(op->reports, RPT_WARNING, "Mesh '%s' has no skin vertex data", me->id.name + 2);
@@ -2442,10 +2404,10 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op)
}
/* create new armature */
- arm_ob = modifier_skin_armature_create(depsgraph, bmain, ob);
+ Object *arm_ob = modifier_skin_armature_create(depsgraph, bmain, ob);
/* add a modifier to connect the new armature to the mesh */
- arm_md = (ArmatureModifierData *)BKE_modifier_new(eModifierType_Armature);
+ ArmatureModifierData *arm_md = (ArmatureModifierData *)BKE_modifier_new(eModifierType_Armature);
if (arm_md) {
skin_md = edit_modifier_property_get(op, ob, eModifierType_Skin);
BLI_insertlinkafter(&ob->modifiers, skin_md, arm_md);
@@ -2501,7 +2463,6 @@ static int correctivesmooth_bind_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)edit_modifier_property_get(
op, ob, eModifierType_CorrectiveSmooth);
- bool is_bind;
if (!csmd) {
return OPERATOR_CANCELLED;
@@ -2512,7 +2473,7 @@ static int correctivesmooth_bind_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- is_bind = (csmd->bind_coords != NULL);
+ const bool is_bind = (csmd->bind_coords != NULL);
MEM_SAFE_FREE(csmd->bind_coords);
MEM_SAFE_FREE(csmd->delta_cache.deltas);
@@ -2782,14 +2743,8 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
OceanModifierData *omd = (OceanModifierData *)edit_modifier_property_get(
op, ob, eModifierType_Ocean);
Scene *scene = CTX_data_scene(C);
- OceanCache *och;
- struct Ocean *ocean;
- int f, cfra, i = 0;
const bool free = RNA_boolean_get(op->ptr, "free");
- wmJob *wm_job;
- OceanBakeJob *oj;
-
if (!omd) {
return OPERATOR_CANCELLED;
}
@@ -2801,23 +2756,24 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- och = BKE_ocean_init_cache(omd->cachepath,
- BKE_modifier_path_relbase(bmain, ob),
- omd->bakestart,
- omd->bakeend,
- omd->wave_scale,
- omd->chop_amount,
- omd->foam_coverage,
- omd->foam_fade,
- omd->resolution);
+ OceanCache *och = BKE_ocean_init_cache(omd->cachepath,
+ BKE_modifier_path_relbase(bmain, ob),
+ omd->bakestart,
+ omd->bakeend,
+ omd->wave_scale,
+ omd->chop_amount,
+ omd->foam_coverage,
+ omd->foam_fade,
+ omd->resolution);
och->time = MEM_mallocN(och->duration * sizeof(float), "foam bake time");
- cfra = scene->r.cfra;
+ int cfra = scene->r.cfra;
/* precalculate time variable before baking */
+ int i = 0;
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- for (f = omd->bakestart; f <= omd->bakeend; f++) {
+ for (int f = omd->bakestart; f <= omd->bakeend; f++) {
/* For now only simple animation of time value is supported, nothing else.
* No drivers or other modifier parameters. */
/* TODO(sergey): This operates on an original data, so no flush is needed. However, baking
@@ -2832,7 +2788,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
}
/* make a copy of ocean to use for baking - threadsafety */
- ocean = BKE_ocean_add();
+ struct Ocean *ocean = BKE_ocean_add();
BKE_ocean_init_from_modifier(ocean, omd, omd->resolution);
#if 0
@@ -2852,13 +2808,13 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
scene->r.cfra = cfra;
/* setup job */
- wm_job = WM_jobs_get(CTX_wm_manager(C),
- CTX_wm_window(C),
- scene,
- "Ocean Simulation",
- WM_JOB_PROGRESS,
- WM_JOB_TYPE_OBJECT_SIM_OCEAN);
- oj = MEM_callocN(sizeof(OceanBakeJob), "ocean bake job");
+ wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
+ CTX_wm_window(C),
+ scene,
+ "Ocean Simulation",
+ WM_JOB_PROGRESS,
+ WM_JOB_TYPE_OBJECT_SIM_OCEAN);
+ OceanBakeJob *oj = MEM_callocN(sizeof(OceanBakeJob), "ocean bake job");
oj->owner = ob;
oj->ocean = ocean;
oj->och = och;
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 80b521b2af3..780ce487550 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2297,7 +2297,7 @@ void OBJECT_OT_make_local(wmOperatorType *ot)
/** \name Make Library Override Operator
* \{ */
-static bool make_override_library_ovject_overridable_check(Main *bmain, Object *object)
+static bool make_override_library_object_overridable_check(Main *bmain, Object *object)
{
/* An object is actually overrideable only if it is in at least one local collections.
* Unfortunately 'direct link' flag is not enough here. */
@@ -2306,6 +2306,11 @@ static bool make_override_library_ovject_overridable_check(Main *bmain, Object *
return true;
}
}
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ if (!ID_IS_LINKED(scene) && BKE_collection_has_object(scene->master_collection, object)) {
+ return true;
+ }
+ }
return false;
}
@@ -2323,7 +2328,7 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve
if ((!ID_IS_LINKED(obact) && obact->instance_collection != NULL &&
ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection)) ||
- make_override_library_ovject_overridable_check(bmain, obact)) {
+ make_override_library_object_overridable_check(bmain, obact)) {
uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("OK?"), ICON_QUESTION);
uiLayout *layout = UI_popup_menu_layout(pup);
@@ -2374,7 +2379,7 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
id_root = &obact->instance_collection->id;
is_override_instancing_object = true;
}
- else if (!make_override_library_ovject_overridable_check(bmain, obact)) {
+ else if (!make_override_library_object_overridable_check(bmain, obact)) {
const int i = RNA_property_enum_get(op->ptr, op->type->prop);
const uint collection_session_uuid = *((uint *)&i);
if (collection_session_uuid == MAIN_ID_SESSION_UUID_UNSET) {
diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c
index a0cfdac1ac6..cc3230dff7b 100644
--- a/source/blender/editors/object/object_remesh.c
+++ b/source/blender/editors/object/object_remesh.c
@@ -86,7 +86,7 @@
#include "BLF_api.h"
-#include "object_intern.h" // own include
+#include "object_intern.h" /* own include */
/* TODO(sebpa): unstable, can lead to unrecoverable errors. */
// #define USE_MESH_CURVATURE
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 5dfbaf583f6..d3b9c64913d 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -661,7 +661,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
}
if (nr == OBJECT_SELECT_LINKED_IPO) {
- // XXX old animation system
+ /* XXX old animation system */
// if (ob->ipo == 0) return OPERATOR_CANCELLED;
// object_select_all_by_ipo(C, ob->ipo)
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index 19fac707575..1bb0246deb5 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -53,7 +53,7 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
-#include "BLI_sys_types.h" // for intptr_t support
+#include "BLI_sys_types.h" /* for intptr_t support */
#include "ED_mesh.h"
#include "ED_object.h"
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index e2d043c3206..7d853745ad6 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -242,7 +242,7 @@ static void object_clear_rot(Object *ob, const bool clear_delta)
copy_v3_v3(ob->rot, eul);
}
}
- } // Duplicated in source/blender/editors/armature/editarmature.c
+ } /* Duplicated in source/blender/editors/armature/editarmature.c */
else {
if (ob->rotmode == ROT_MODE_QUAT) {
unit_qt(ob->quat);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 1d1859d8170..0cf9fd7768d 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -202,9 +202,10 @@ ParticleEditSettings *PE_settings(Scene *scene)
static float pe_brush_size_get(const Scene *UNUSED(scene), ParticleBrushData *brush)
{
- // here we can enable unified brush size, needs more work...
- // UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
- // float size = (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size;
+#if 0 /* TODO: Here we can enable unified brush size, needs more work. */
+ UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+ float size = (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size;
+#endif
return brush->size;
}
@@ -4560,7 +4561,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
(dx != 0 || dy != 0)) ||
bedit->first) {
PEData data = bedit->data;
- data.context = C; // TODO(mai): why isnt this set in bedit->data?
+ data.context = C; /* TODO(mai): why isnt this set in bedit->data? */
view3d_operator_needs_opengl(C);
selected = (short)count_selected_keys(scene, edit);
@@ -4783,7 +4784,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, const wmEvent *e
RNA_collection_add(op->ptr, "stroke", &itemptr);
RNA_float_set_array(&itemptr, "mouse", mouse);
- RNA_boolean_set(&itemptr, "pen_flip", event->shift != false); // XXX hardcoded
+ RNA_boolean_set(&itemptr, "pen_flip", event->shift != false); /* XXX hardcoded */
/* apply */
brush_edit_apply(C, op, &itemptr);
@@ -4807,7 +4808,7 @@ static int brush_edit_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case LEFTMOUSE:
case MIDDLEMOUSE:
- case RIGHTMOUSE: // XXX hardcoded
+ case RIGHTMOUSE: /* XXX hardcoded */
if (event->val == KM_RELEASE) {
brush_edit_exit(op);
return OPERATOR_FINISHED;
@@ -5390,11 +5391,6 @@ static int clear_edited_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
-static int clear_edited_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- return WM_operator_confirm_message(C, op, "Lose changes done in particle mode? (no undo)");
-}
-
void PARTICLE_OT_edited_clear(wmOperatorType *ot)
{
/* identifiers */
@@ -5405,7 +5401,6 @@ void PARTICLE_OT_edited_clear(wmOperatorType *ot)
/* api callbacks */
ot->exec = clear_edited_exec;
ot->poll = particle_edit_toggle_poll;
- ot->invoke = clear_edited_invoke;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 26b5f7fb2af..32d2e39d6f6 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -60,7 +60,7 @@
#include "WM_types.h"
#include "manta_fluid_API.h"
-#include "physics_intern.h" // own include
+#include "physics_intern.h" /* own include */
#include "DNA_fluid_types.h"
#include "DNA_mesh_types.h"
diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c
index f6943c25063..eb154b97eb0 100644
--- a/source/blender/editors/physics/physics_ops.c
+++ b/source/blender/editors/physics/physics_ops.c
@@ -32,7 +32,7 @@
#include "ED_physics.h"
#include "ED_select_utils.h"
-#include "physics_intern.h" // own include
+#include "physics_intern.h" /* own include */
/***************************** particles ***********************************/
diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c
index b91385c502c..cb25363d2b2 100644
--- a/source/blender/editors/physics/rigidbody_object.c
+++ b/source/blender/editors/physics/rigidbody_object.c
@@ -531,7 +531,7 @@ void RIGIDBODY_OT_mass_calculate(wmOperatorType *ot)
ot->description = "Automatically calculate mass values for Rigid Body Objects based on volume";
/* callbacks */
- ot->invoke = WM_menu_invoke; // XXX
+ ot->invoke = WM_menu_invoke; /* XXX */
ot->exec = rigidbody_objects_calc_mass_exec;
ot->poll = ED_operator_rigidbody_active_poll;
diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c
index 558a293ccbf..42f270874e3 100644
--- a/source/blender/editors/physics/rigidbody_world.c
+++ b/source/blender/editors/physics/rigidbody_world.c
@@ -180,7 +180,7 @@ static int rigidbody_world_export_invoke(bContext *C, wmOperator *op, const wmEv
return rigidbody_world_export_exec(C, op);
}
- // TODO: use the actual rigidbody world's name + .bullet instead of this temp crap
+ /* TODO: use the actual rigidbody world's name + .bullet instead of this temp crap */
RNA_string_set(op->ptr, "filepath", "rigidbodyworld_export.bullet");
WM_event_add_fileselect(C, op);
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 32bc1cff4a0..7ca711cd2b8 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -363,7 +363,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
RE_SetReports(re, NULL);
- // no redraw needed, we leave state as we entered it
+ /* No redraw needed, we leave state as we entered it. */
ED_update_for_newframe(mainp, CTX_data_depsgraph_pointer(C));
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene);
@@ -386,7 +386,7 @@ static void make_renderinfo_string(const RenderStats *rs,
const char *error,
char *str)
{
- char info_time_str[32]; // used to be extern to header_info.c
+ char info_time_str[32]; /* used to be extern to header_info.c */
uintptr_t mem_in_use, peak_memory;
float megs_used_memory, megs_peak_memory;
char *spos = str;
@@ -526,7 +526,7 @@ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr,
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.
+ /* area->spacedata might be empty when toggling full-screen mode. */
if (sima != NULL && sima->image == rj->image) {
if (first_area == NULL) {
first_area = area;
@@ -944,9 +944,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
* since sequence rendering can call that recursively... (peter) */
BKE_sequencer_cache_cleanup(scene);
- // store spare
- // get view3d layer, local layer, make this nice api call to render
- // store spare
+ /* store spare
+ * get view3d layer, local layer, make this nice api call to render
+ * store spare */
/* ensure at least 1 area shows result */
area = render_view_open(C, event->x, event->y, op->reports);
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 80fa8082592..8d410e36ca6 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -90,8 +90,8 @@
# include "PIL_time.h"
#endif
-// TODO(sergey): Find better approximation of the scheduled frames.
-// For really highres renders it might fail still.
+/* TODO(sergey): Find better approximation of the scheduled frames.
+ * For really highres renders it might fail still. */
#define MAX_SCHEDULED_FRAMES 8
typedef struct OGLRender {
@@ -546,7 +546,8 @@ static void gather_frames_to_render_for_adt(const OGLRender *oglrender, const An
}
bool found = false; /* Not interesting, we just want a starting point for the for-loop.*/
- int key_index = binarysearch_bezt_index(fcu->bezt, frame_start, fcu->totvert, &found);
+ int key_index = BKE_fcurve_bezt_binarysearch_index(
+ fcu->bezt, frame_start, fcu->totvert, &found);
for (; key_index < fcu->totvert; key_index++) {
BezTriple *bezt = &fcu->bezt[key_index];
/* The frame range to render uses integer frame numbers, and the frame
diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c
index 8156f48343f..706249a3f8b 100644
--- a/source/blender/editors/render/render_ops.c
+++ b/source/blender/editors/render/render_ops.c
@@ -29,7 +29,7 @@
#include "WM_api.h"
-#include "render_intern.h" // own include
+#include "render_intern.h" /* own include */
/***************************** render ***********************************/
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 6369b7bad43..4afa45893f9 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -111,7 +111,7 @@ ImBuf *get_brush_icon(Brush *brush)
if (brush->flag & BRUSH_CUSTOM_ICON) {
if (brush->icon_filepath[0]) {
- // first use the path directly to try and load the file
+ /* First use the path directly to try and load the file. */
BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath));
BLI_path_abs(path, ID_BLEND_PATH_FROM_GLOBAL(&brush->id));
@@ -119,7 +119,7 @@ ImBuf *get_brush_icon(Brush *brush)
/* use default colorspaces for brushes */
brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
- // otherwise lets try to find it in other directories
+ /* otherwise lets try to find it in other directories */
if (!(brush->icon_imbuf)) {
folder = BKE_appdir_folder_id(BLENDER_DATAFILES, "brushicons");
@@ -881,7 +881,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
sce->display.render_aa = SCE_DISPLAY_AA_SAMPLES_8;
}
- /* callbacs are cleared on GetRender() */
+ /* Callbacks are cleared on GetRender(). */
if (ELEM(sp->pr_method, PR_BUTS_RENDER, PR_NODE_RENDER)) {
RE_display_update_cb(re, sp, shader_preview_update);
}
@@ -907,7 +907,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
/* handle results */
if (sp->pr_method == PR_ICON_RENDER) {
- // char *rct= (char *)(sp->pr_rect + 32*16 + 16);
+ // char *rct = (char *)(sp->pr_rect + 32 * 16 + 16);
if (sp->pr_rect) {
RE_ResultGet32(re, sp->pr_rect);
@@ -917,12 +917,14 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
/* unassign the pointers, reset vars */
preview_prepare_scene(sp->bmain, sp->scene, NULL, GS(id->name), sp);
- /* XXX bad exception, end-exec is not being called in render, because it uses local main */
- // if (idtype == ID_TE) {
- // Tex *tex= (Tex *)id;
- // if (tex->use_nodes && tex->nodetree)
- // ntreeEndExecTree(tex->nodetree);
- // }
+ /* XXX bad exception, end-exec is not being called in render, because it uses local main. */
+#if 0
+ if (idtype == ID_TE) {
+ Tex *tex = (Tex *)id;
+ if (tex->use_nodes && tex->nodetree)
+ ntreeEndExecTree(tex->nodetree);
+ }
+#endif
}
/* runs inside thread for material and icons */
@@ -1083,7 +1085,7 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
int source = deferred_data[0];
char *path = &deferred_data[1];
- // printf("generating deferred %d×%d preview for %s\n", sp->sizex, sp->sizey, path);
+ // printf("generating deferred %d×%d preview for %s\n", sp->sizex, sp->sizey, path);
thumb = IMB_thumb_manage(path, THB_LARGE, source);
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 6fed806c8af..60e5c2081fd 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -94,7 +94,7 @@
#include "engines/eevee/eevee_lightcache.h"
-#include "render_intern.h" // own include
+#include "render_intern.h" /* own include */
static bool object_materials_supported_poll_ex(bContext *C, const Object *ob);
@@ -1092,7 +1092,7 @@ static int light_cache_bake_exec(bContext *C, wmOperator *op)
EEVEE_lightbake_job(rj, &stop, &do_update, &progress);
EEVEE_lightbake_job_data_free(rj);
- // no redraw needed, we leave state as we entered it
+ /* No redraw needed, we leave state as we entered it. */
ED_update_for_newframe(bmain, CTX_data_depsgraph_pointer(C));
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 1ba32d3386d..ffb2d3991b7 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -64,7 +64,7 @@
#include "WM_api.h"
-#include "render_intern.h" // own include
+#include "render_intern.h" /* own include */
/***************************** Render Engines ********************************/
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 6fa9d203bba..10d269151ce 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -48,6 +48,7 @@
#include "WM_toolsystem.h"
#include "WM_types.h"
+#include "ED_buttons.h"
#include "ED_screen.h"
#include "ED_screen_types.h"
#include "ED_space_api.h"
@@ -84,13 +85,11 @@ enum RegionEmbossSide {
static void region_draw_emboss(const ARegion *region, const rcti *scirct, int sides)
{
- rcti rect;
-
/* translate scissor rect to region space */
- rect.xmin = scirct->xmin - region->winrct.xmin;
- rect.ymin = scirct->ymin - region->winrct.ymin;
- rect.xmax = scirct->xmax - region->winrct.xmin;
- rect.ymax = scirct->ymax - region->winrct.ymin;
+ const rcti rect = {.xmin = scirct->xmin - region->winrct.xmin,
+ .xmax = scirct->xmax - region->winrct.xmin,
+ .ymin = scirct->ymin - region->winrct.ymin,
+ .ymax = scirct->ymax - region->winrct.ymin};
/* set transp line */
GPU_blend(GPU_BLEND_ALPHA);
@@ -551,7 +550,10 @@ void ED_region_do_draw(bContext *C, ARegion *region)
* for drawing of borders/gestures etc */
ED_region_pixelspace(region);
+ GPUFrameBuffer *fb = GPU_framebuffer_active_get();
+ GPU_framebuffer_bind(fb);
ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_PIXEL);
+ GPU_framebuffer_bind_no_srgb(fb);
region_draw_azones(area, region);
@@ -765,7 +767,7 @@ const char *ED_area_region_search_filter_get(const ScrArea *area, const ARegion
if (area->spacetype == SPACE_PROPERTIES) {
SpaceProperties *sbuts = area->spacedata.first;
if (region->regiontype == RGN_TYPE_WINDOW) {
- return sbuts->runtime->search_string;
+ return ED_buttons_search_string_get(sbuts);
}
}
@@ -847,8 +849,6 @@ void ED_workspace_status_text(bContext *C, const char *str)
static void area_azone_init(wmWindow *win, const bScreen *screen, ScrArea *area)
{
- AZone *az;
-
/* reinitialize entirely, regions and fullscreen add azones too */
BLI_freelistN(&area->actionzones);
@@ -904,7 +904,7 @@ static void area_azone_init(wmWindow *win, const bScreen *screen, ScrArea *area)
#endif
/* set area action zones */
- az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+ AZone *az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
BLI_addtail(&(area->actionzones), az);
az->type = AZONE_AREA;
az->x1 = coords[i][0];
@@ -917,13 +917,11 @@ static void area_azone_init(wmWindow *win, const bScreen *screen, ScrArea *area)
static void fullscreen_azone_init(ScrArea *area, ARegion *region)
{
- AZone *az;
-
if (ED_area_is_global(area) || (region->regiontype != RGN_TYPE_WINDOW)) {
return;
}
- az = (AZone *)MEM_callocN(sizeof(AZone), "fullscreen action zone");
+ AZone *az = (AZone *)MEM_callocN(sizeof(AZone), "fullscreen action zone");
BLI_addtail(&(area->actionzones), az);
az->type = AZONE_FULLSCREEN;
az->region = region;
@@ -980,13 +978,11 @@ 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 *area, AZone *az, ARegion *region)
{
- int tot = 0, add;
- /* Edge offset multiplied by the */
-
float edge_offset = 1.0f;
const float tab_size_x = 0.7f * U.widget_unit;
const float tab_size_y = 0.4f * U.widget_unit;
+ int tot = 0;
LISTBASE_FOREACH (AZone *, azt, &area->actionzones) {
if (azt->edge == az->edge) {
tot++;
@@ -994,13 +990,14 @@ static void region_azone_tab_plus(ScrArea *area, AZone *az, ARegion *region)
}
switch (az->edge) {
- case AE_TOP_TO_BOTTOMRIGHT:
- add = (region->winrct.ymax == area->totrct.ymin) ? 1 : 0;
+ case AE_TOP_TO_BOTTOMRIGHT: {
+ int 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);
az->y2 = region->winrct.ymax - add + tab_size_y;
break;
+ }
case AE_BOTTOM_TO_TOPLEFT:
az->x1 = region->winrct.xmax - ((edge_offset + 1.0f) * tab_size_x);
az->y1 = region->winrct.ymin - tab_size_y;
@@ -1043,14 +1040,13 @@ static void region_azone_edge_init(ScrArea *area,
AZEdge edge,
const bool is_fullscreen)
{
- AZone *az = NULL;
const bool is_hidden = (region->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL));
if (!region_azone_edge_poll(region, is_fullscreen)) {
return;
}
- az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+ AZone *az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
BLI_addtail(&(area->actionzones), az);
az->type = AZONE_REGION;
az->region = region;
@@ -1169,11 +1165,10 @@ static int rct_fits(const rcti *rect, char dir, int size)
/* function checks if some overlapping region was defined before - on same place */
static void region_overlap_fix(ScrArea *area, ARegion *region)
{
+ /* find overlapping previous region on same place */
ARegion *ar1;
- const int align = RGN_ALIGN_ENUM_FROM_MASK(region->alignment);
int align1 = 0;
-
- /* find overlapping previous region on same place */
+ const int align = RGN_ALIGN_ENUM_FROM_MASK(region->alignment);
for (ar1 = region->prev; ar1; ar1 = ar1->prev) {
if (ar1->flag & RGN_FLAG_HIDDEN) {
continue;
@@ -1842,20 +1837,18 @@ static void ed_default_handlers(
void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area)
{
- rcti rect, overlap_rect;
- rcti window_rect;
-
if (!(area->flag & AREA_FLAG_REGION_SIZE_UPDATE)) {
return;
}
const bScreen *screen = WM_window_get_active_screen(win);
+ rcti window_rect;
WM_window_rect_calc(win, &window_rect);
area_calc_totrct(area, &window_rect);
/* region rect sizes */
- rect = area->totrct;
- overlap_rect = rect;
+ rcti rect = area->totrct;
+ rcti overlap_rect = rect;
region_rect_recursive(area, area->regionbase.first, &rect, &overlap_rect, 0);
/* Dynamically sized regions may have changed region sizes, so we have to force azone update. */
@@ -1883,12 +1876,12 @@ void ED_area_init(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);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- rcti rect, overlap_rect;
- rcti window_rect;
if (ED_area_is_global(area) && (area->global->flag & GLOBAL_AREA_IS_HIDDEN)) {
return;
}
+
+ rcti window_rect;
WM_window_rect_calc(win, &window_rect);
/* set typedefinitions */
@@ -1907,8 +1900,8 @@ void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area)
area_calc_totrct(area, &window_rect);
/* region rect sizes */
- rect = area->totrct;
- overlap_rect = rect;
+ rcti rect = area->totrct;
+ rcti overlap_rect = rect;
region_rect_recursive(area, area->regionbase.first, &rect, &overlap_rect, 0);
area->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
@@ -2041,7 +2034,6 @@ void ED_region_toggle_hidden(bContext *C, ARegion *region)
*/
void ED_area_data_copy(ScrArea *area_dst, ScrArea *area_src, const bool do_free)
{
- SpaceType *st;
const char spacetype = area_dst->spacetype;
const short flag_copy = HEADER_NO_PULLDOWN;
@@ -2060,13 +2052,13 @@ void ED_area_data_copy(ScrArea *area_dst, ScrArea *area_src, const bool do_free)
/* regions */
if (do_free) {
- st = BKE_spacetype_from_id(spacetype);
+ SpaceType *st = BKE_spacetype_from_id(spacetype);
LISTBASE_FOREACH (ARegion *, region, &area_dst->regionbase) {
BKE_area_region_free(st, region);
}
BLI_freelistN(&area_dst->regionbase);
}
- st = BKE_spacetype_from_id(area_src->spacetype);
+ SpaceType *st = BKE_spacetype_from_id(area_src->spacetype);
LISTBASE_FOREACH (ARegion *, region, &area_src->regionbase) {
ARegion *newar = BKE_area_region_copy(st, region);
BLI_addtail(&area_dst->regionbase, newar);
@@ -2353,7 +2345,6 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
wmWindow *win = CTX_wm_window(C);
if (area->spacetype != type) {
- SpaceType *st;
SpaceLink *slold = area->spacedata.first;
/* store area->type->exit callback */
void *area_exit = area->type ? area->type->exit : NULL;
@@ -2388,7 +2379,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
area->type->exit = area_exit;
}
- st = BKE_spacetype_from_id(type);
+ SpaceType *st = BKE_spacetype_from_id(type);
area->spacetype = type;
area->type = st;
@@ -2849,7 +2840,6 @@ void ED_region_panels_layout_ex(const bContext *C,
ScrArea *area = CTX_wm_area(C);
View2D *v2d = &region->v2d;
- int x, y, w, em;
bool use_category_tabs = (category_override == NULL) && region_uses_category_tabs(area, region);
/* offset panels for small vertical tab area */
@@ -2873,11 +2863,11 @@ void ED_region_panels_layout_ex(const bContext *C,
margin_x = category_tabs_width;
}
- w = BLI_rctf_size_x(&v2d->cur);
- em = (region->type->prefsizex) ? 10 : 20; /* works out to 10*UI_UNIT_X or 20*UI_UNIT_X */
+ const int w = BLI_rctf_size_x(&v2d->cur) - margin_x;
+ /* Works out to 10 * UI_UNIT_X or 20 * UI_UNIT_X. */
+ const int em = (region->type->prefsizex) ? 10 : 20;
- w -= margin_x;
- int w_box_panel = w - UI_PANEL_BOX_STYLE_MARGIN * 2.0f;
+ const int w_box_panel = w - UI_PANEL_BOX_STYLE_MARGIN * 2.0f;
/* create panels */
UI_panels_begin(C, region);
@@ -2956,6 +2946,7 @@ void ED_region_panels_layout_ex(const bContext *C,
}
/* align panels and return size */
+ int x, y;
UI_panels_end(C, region, &x, &y);
/* before setting the view */
@@ -2966,7 +2957,7 @@ void ED_region_panels_layout_ex(const bContext *C,
Panel *panel = region->panels.last;
if (panel != NULL) {
const int size_dyn[2] = {
- UI_UNIT_X * ((panel->flag & PNL_CLOSED) ? 8 : 14) / UI_DPI_FAC,
+ UI_UNIT_X * (UI_panel_is_closed(panel) ? 8 : 14) / UI_DPI_FAC,
UI_panel_size_y(panel) / UI_DPI_FAC,
};
/* region size is layout based and needs to be updated */
@@ -3040,9 +3031,9 @@ void ED_region_panels_draw(const bContext *C, ARegion *region)
/* scrollers */
const rcti *mask = NULL;
- rcti mask_buf;
if (region->runtime.category &&
(RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_RIGHT)) {
+ rcti mask_buf;
UI_view2d_mask_from_win(v2d, &mask_buf);
mask_buf.xmax -= UI_PANEL_CATEGORY_MARGIN_WIDTH;
mask = &mask_buf;
@@ -3066,20 +3057,158 @@ void ED_region_panels(const bContext *C, ARegion *region)
void ED_region_panels_init(wmWindowManager *wm, ARegion *region)
{
- wmKeyMap *keymap;
-
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_PANELS_UI, region->winx, region->winy);
- keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", 0, 0);
+ wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", 0, 0);
WM_event_add_keymap_handler(&region->handlers, keymap);
}
+/**
+ * Check whether any of the buttons generated by the \a panel_type's
+ * layout callbacks match the \a search_filter.
+ *
+ * \param panel: If non-NULL, use this instead of adding a new panel for the \a panel_type.
+ */
+static bool panel_property_search(const bContext *C,
+ ARegion *region,
+ const uiStyle *style,
+ Panel *panel,
+ PanelType *panel_type,
+ const char *search_filter)
+{
+ uiBlock *block = UI_block_begin(C, region, panel_type->idname, UI_EMBOSS);
+ UI_block_set_search_only(block, true);
+
+ if (panel == NULL) {
+ bool open; /* Dummy variable. */
+ panel = UI_panel_begin(region, &region->panels, block, panel_type, panel, &open);
+ }
+
+ /* Build the layouts. Because they are only used for search,
+ * they don't need any of the proper style or layout information. */
+ if (panel->type->draw_header_preset != NULL) {
+ panel->layout = UI_block_layout(
+ block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, 0, 0, 0, 0, 0, style);
+ panel_type->draw_header_preset(C, panel);
+ }
+ if (panel->type->draw_header != NULL) {
+ panel->layout = UI_block_layout(
+ block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, 0, 0, 0, 0, 0, style);
+ panel_type->draw_header(C, panel);
+ }
+ if (LIKELY(panel->type->draw != NULL)) {
+ panel->layout = UI_block_layout(
+ block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 0, 0, 0, style);
+ panel_type->draw(C, panel);
+ }
+
+ UI_block_layout_free(block);
+
+ /* We could check after each layout to increase the likelihood of returning early,
+ * but that probably wouldn't make much of a difference anyway. */
+ if (UI_block_apply_search_filter(block, search_filter)) {
+ return true;
+ }
+
+ LISTBASE_FOREACH (LinkData *, link, &panel_type->children) {
+ PanelType *panel_type_child = link->data;
+ if (!panel_type_child->poll || panel_type_child->poll(C, panel_type_child)) {
+ /* Search for the existing child panel here because it might be an instanced
+ * child panel with a custom data field that will be needed to build the layout. */
+ Panel *child_panel = UI_panel_find_by_type(&panel->children, panel_type_child);
+ if (panel_property_search(C, region, style, child_panel, panel_type_child, search_filter)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Build the same panel list as #ED_region_panels_layout_ex and checks whether any
+ * of the panels contain a search result based on the area / region's search filter.
+ */
+bool ED_region_property_search(const bContext *C,
+ ARegion *region,
+ ListBase *paneltypes,
+ const char *contexts[],
+ const char *category_override)
+{
+ ScrArea *area = CTX_wm_area(C);
+ WorkSpace *workspace = CTX_wm_workspace(C);
+ const uiStyle *style = UI_style_get_dpi();
+ const char *search_filter = ED_area_region_search_filter_get(area, region);
+
+ LinkNode *panel_types_stack = NULL;
+ LISTBASE_FOREACH_BACKWARD (PanelType *, pt, paneltypes) {
+ if (panel_add_check(C, workspace, contexts, category_override, pt)) {
+ BLI_linklist_prepend_alloca(&panel_types_stack, pt);
+ }
+ }
+
+ const char *category = NULL;
+ bool use_category_tabs = (category_override == NULL) && region_uses_category_tabs(area, region);
+ if (use_category_tabs) {
+ category = region_panels_collect_categories(region, panel_types_stack, &use_category_tabs);
+ }
+
+ /* Run property search for each panel, stopping if a result is found. */
+ bool has_result = true;
+ bool has_instanced_panel = false;
+ for (LinkNode *pt_link = panel_types_stack; pt_link; pt_link = pt_link->next) {
+ PanelType *panel_type = pt_link->link;
+ /* Note that these checks are duplicated from #ED_region_panels_layout_ex. */
+ if (panel_type->flag & PNL_INSTANCED) {
+ has_instanced_panel = true;
+ continue;
+ }
+
+ if (use_category_tabs) {
+ if (panel_type->category[0] && !STREQ(category, panel_type->category)) {
+ continue;
+ }
+ }
+
+ /* We start property search with an empty panel list, so there's
+ * no point in trying to find an existing panel with this type. */
+ has_result = panel_property_search(C, region, style, NULL, panel_type, search_filter);
+ if (has_result) {
+ break;
+ }
+ }
+
+ /* Run property search for instanced panels (created in the layout calls of previous panels). */
+ if (!has_result && has_instanced_panel) {
+ LISTBASE_FOREACH (Panel *, panel, &region->panels) {
+ /* Note that these checks are duplicated from #ED_region_panels_layout_ex. */
+ if (panel->type == NULL || !(panel->type->flag & PNL_INSTANCED)) {
+ continue;
+ }
+ if (use_category_tabs) {
+ if (panel->type->category[0] && !STREQ(category, panel->type->category)) {
+ continue;
+ }
+ }
+
+ has_result = panel_property_search(C, region, style, panel, panel->type, search_filter);
+ if (has_result) {
+ break;
+ }
+ }
+ }
+
+ /* Free the panels and blocks, as they are only used for search. */
+ UI_blocklist_free(C, &region->uiblocks);
+ UI_panels_free_instanced(C, region);
+ BKE_area_region_panels_free(&region->panels);
+
+ return has_result;
+}
+
void ED_region_header_layout(const bContext *C, ARegion *region)
{
const uiStyle *style = UI_style_get_dpi();
- uiBlock *block;
- uiLayout *layout;
- Header header = {NULL};
bool region_layout_based = region->flag & RGN_FLAG_DYNAMIC_SIZE;
/* Height of buttons and scaling needed to achieve it. */
@@ -3106,14 +3235,15 @@ void ED_region_header_layout(const bContext *C, ARegion *region)
continue;
}
- block = UI_block_begin(C, region, ht->idname, UI_EMBOSS);
- layout = UI_block_layout(
+ uiBlock *block = UI_block_begin(C, region, ht->idname, UI_EMBOSS);
+ uiLayout *layout = UI_block_layout(
block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, buttony, 1, 0, style);
if (buttony_scale != 1.0f) {
uiLayoutSetScaleY(layout, buttony_scale);
}
+ Header header = {NULL};
if (ht->draw) {
header.type = ht;
header.layout = layout;
@@ -3243,17 +3373,17 @@ ScrArea *ED_screen_areas_iter_first(const wmWindow *win, const bScreen *screen)
}
ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area)
{
- if (area->global) {
- for (ScrArea *area_iter = area->next; area_iter; area_iter = area_iter->next) {
- if ((area_iter->global->flag & GLOBAL_AREA_IS_HIDDEN) == 0) {
- return area_iter;
- }
- }
- /* No visible next global area found, start iterating over layout areas. */
- return screen->areabase.first;
+ if (area->global == NULL) {
+ return area->next;
}
- return area->next;
+ for (ScrArea *area_iter = area->next; area_iter; area_iter = area_iter->next) {
+ if ((area_iter->global->flag & GLOBAL_AREA_IS_HIDDEN) == 0) {
+ return area_iter;
+ }
+ }
+ /* No visible next global area found, start iterating over layout areas. */
+ return screen->areabase.first;
}
/**
@@ -3410,9 +3540,7 @@ static void metadata_custom_draw_fields(const char *field, const char *value, vo
static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const bool is_top)
{
char temp_str[MAX_METADATA_STR];
- int line_width;
int ofs_y = 0;
- int len;
const float height = BLF_height_max(fontid);
const float margin = height / 8;
const float vertical_offset = (height + margin);
@@ -3429,7 +3557,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
/* first line */
if (i == 0) {
bool do_newline = false;
- len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[0]);
+ int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[0]);
if (metadata_is_valid(ibuf, temp_str, 0, len)) {
BLF_position(fontid, xmin, ymax - vertical_offset, 0.0f);
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
@@ -3438,7 +3566,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[1]);
if (metadata_is_valid(ibuf, temp_str, 1, len)) {
- line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
+ int line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
BLF_position(fontid, xmax - line_width, ymax - vertical_offset, 0.0f);
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
do_newline = true;
@@ -3449,7 +3577,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
}
} /* Strip */
else if (i == 1 || i == 2) {
- len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
+ int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
@@ -3457,7 +3585,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
}
} /* Note (wrapped) */
else if (i == 3) {
- len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
+ int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
struct ResultBLF info;
BLF_enable(fontid, BLF_WORD_WRAP);
@@ -3470,9 +3598,9 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
}
}
else {
- len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
+ int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
- line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
+ int line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
BLF_position(fontid, xmax - line_width, ymax - vertical_offset - ofs_y, 0.0f);
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
ofs_y += vertical_offset;
@@ -3491,7 +3619,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
int ofs_x = 0;
ofs_y = ctx.current_y;
for (int i = 5; i < 10; i++) {
- len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i]);
+ int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i]);
if (metadata_is_valid(ibuf, temp_str, i, len)) {
BLF_position(fontid, xmin + ofs_x, ymin + ofs_y, 0.0f);
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
@@ -3520,13 +3648,13 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
const float height = BLF_height_max(fontid);
const float margin = (height / 8);
char str[MAX_METADATA_STR] = "";
- short i, count = 0;
+ short count = 0;
if (is_top) {
if (metadata_is_valid(ibuf, str, 0, 0) || metadata_is_valid(ibuf, str, 1, 0)) {
count++;
}
- for (i = 2; i < 5; i++) {
+ for (int i = 2; i < 5; i++) {
if (metadata_is_valid(ibuf, str, i, 0)) {
if (i == 4) {
struct {
@@ -3549,7 +3677,7 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
}
}
else {
- for (i = 5; i < 10; i++) {
+ for (int i = 5; i < 10; i++) {
if (metadata_is_valid(ibuf, str, i, 0)) {
count = 1;
break;
@@ -3573,8 +3701,6 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
void ED_region_image_metadata_draw(
int x, int y, ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy)
{
- float box_y;
- rctf rect;
const uiStyle *style = UI_style_get_dpi();
if (!ibuf->metadata) {
@@ -3593,10 +3719,11 @@ void ED_region_image_metadata_draw(
/* *** upper box*** */
/* get needed box height */
- box_y = metadata_box_height_get(ibuf, blf_mono_font, true);
+ float box_y = metadata_box_height_get(ibuf, blf_mono_font, true);
if (box_y) {
/* set up rect */
+ rctf rect;
BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymax, frame->ymax + box_y);
/* draw top box */
GPUVertFormat *format = immVertexFormat();
@@ -3621,6 +3748,7 @@ void ED_region_image_metadata_draw(
if (box_y) {
/* set up box rect */
+ rctf rect;
BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymin - box_y, frame->ymin);
/* draw top box */
GPUVertFormat *format = immVertexFormat();
@@ -3663,11 +3791,8 @@ void ED_region_image_metadata_panel_draw(ImBuf *ibuf, uiLayout *layout)
void ED_region_grid_draw(ARegion *region, float zoomx, float zoomy, float x0, float y0)
{
- float gridsize, gridstep = 1.0f / 32.0f;
- float fac, blendfac;
- int x1, y1, x2, y2;
-
/* the image is located inside (x0, y0), (x0+1, y0+1) as set by view2d */
+ int x1, y1, x2, y2;
UI_view2d_view_to_region(&region->v2d, x0, y0, &x1, &y1);
UI_view2d_view_to_region(&region->v2d, x0 + 1.0f, y0 + 1.0f, &x2, &y2);
@@ -3684,7 +3809,8 @@ void ED_region_grid_draw(ARegion *region, float zoomx, float zoomy, float x0, fl
immUnbindProgram();
/* gridsize adapted to zoom level */
- gridsize = 0.5f * (zoomx + zoomy);
+ float gridsize = 0.5f * (zoomx + zoomy);
+ float gridstep = 1.0f / 32.0f;
if (gridsize <= 0.0f) {
return;
}
@@ -3702,7 +3828,7 @@ void ED_region_grid_draw(ARegion *region, float zoomx, float zoomy, float x0, fl
}
}
- blendfac = 0.25f * gridsize - floorf(0.25f * gridsize);
+ float blendfac = 0.25f * gridsize - floorf(0.25f * gridsize);
CLAMP(blendfac, 0.0f, 1.0f);
int count_fine = 1.0f / gridstep;
@@ -3718,7 +3844,7 @@ void ED_region_grid_draw(ARegion *region, float zoomx, float zoomy, float x0, fl
float theme_color[3];
UI_GetThemeColorShade3fv(TH_GRID, (int)(20.0f * (1.0f - blendfac)), theme_color);
- fac = 0.0f;
+ float fac = 0.0f;
/* the fine resolution level */
for (int i = 0; i < count_fine; i++) {
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 74621b917c6..3924c334541 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -109,6 +109,7 @@ const char *screen_context_dir[] = {
"selected_visible_fcurves",
"selected_editable_fcurves",
"active_editable_fcurve",
+ "selected_editable_keyframes",
NULL,
};
@@ -485,10 +486,9 @@ static eContextResult screen_ctx_active_pose_bone(const bContext *C, bContextDat
wmWindow *win = CTX_wm_window(C);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
Object *obact = view_layer->basact ? view_layer->basact->object : NULL;
- bPoseChannel *pchan;
Object *obpose = BKE_object_pose_armature_get(obact);
- pchan = BKE_pose_channel_active(obpose);
+ bPoseChannel *pchan = BKE_pose_channel_active(obpose);
if (pchan) {
CTX_data_pointer_set(result, &obpose->id, &RNA_PoseBone, pchan);
return CTX_RESULT_OK;
@@ -698,13 +698,11 @@ static eContextResult screen_ctx_gpencil_data_owner(const bContext *C, bContextD
ScrArea *area = CTX_wm_area(C);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
Object *obact = view_layer->basact ? view_layer->basact->object : NULL;
+
/* Pointer to which data/datablock owns the reference to the Grease Pencil data being used
* (as gpencil_data). */
- bGPdata **gpd_ptr = NULL;
PointerRNA ptr;
-
- /* get pointer to Grease Pencil Data */
- gpd_ptr = ED_gpencil_data_get_pointers_direct(area, obact, &ptr);
+ bGPdata **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);
@@ -733,12 +731,10 @@ static eContextResult screen_ctx_annotation_data_owner(const bContext *C,
bScreen *screen = CTX_wm_screen(C);
ScrArea *area = CTX_wm_area(C);
Scene *scene = WM_window_get_active_scene(win);
+
/* Pointer to which data/datablock owns the reference to the Grease Pencil data being used. */
- bGPdata **gpd_ptr = NULL;
PointerRNA ptr;
-
- /* Get pointer to Grease Pencil Data. */
- gpd_ptr = ED_annotation_data_get_pointers_direct((ID *)screen, area, scene, &ptr);
+ bGPdata **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);
@@ -854,39 +850,40 @@ static eContextResult screen_ctx_editable_gpencil_strokes(const bContext *C,
bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
- if (gpd) {
- LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
- if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe)) {
- bGPDframe *gpf;
- bGPDframe *init_gpf = gpl->actframe;
- if (is_multiedit) {
- init_gpf = gpl->frames.first;
- }
+ if (gpd == NULL) {
+ return CTX_RESULT_NO_DATA;
+ }
- for (gpf = init_gpf; gpf; gpf = gpf->next) {
- if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- 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;
- }
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe)) {
+ bGPDframe *gpf;
+ bGPDframe *init_gpf = gpl->actframe;
+ if (is_multiedit) {
+ init_gpf = gpl->frames.first;
+ }
- CTX_data_list_add(result, &gpd->id, &RNA_GPencilStroke, gps);
+ for (gpf = init_gpf; gpf; gpf = gpf->next) {
+ if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ 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;
}
+
+ CTX_data_list_add(result, &gpd->id, &RNA_GPencilStroke, gps);
}
}
- /* if not multiedit out of loop */
- if (!is_multiedit) {
- break;
- }
+ }
+ /* if not multiedit out of loop */
+ if (!is_multiedit) {
+ break;
}
}
}
- CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
- return CTX_RESULT_OK;
}
- return CTX_RESULT_NO_DATA;
+ CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+ return CTX_RESULT_OK;
}
static eContextResult screen_ctx_active_operator(const bContext *C, bContextDataResult *result)
{
@@ -917,7 +914,6 @@ static eContextResult screen_ctx_sel_edit_fcurves_(const bContext *C,
const int extra_filter)
{
bAnimContext ac;
-
if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) {
ListBase anim_data = {NULL, NULL};
@@ -963,7 +959,6 @@ static eContextResult screen_ctx_active_editable_fcurve(const bContext *C,
bContextDataResult *result)
{
bAnimContext ac;
-
if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_GRAPH)) {
ListBase anim_data = {NULL, NULL};
@@ -984,6 +979,46 @@ static eContextResult screen_ctx_active_editable_fcurve(const bContext *C,
}
return CTX_RESULT_NO_DATA;
}
+static eContextResult screen_ctx_selected_editable_keyframes(const bContext *C,
+ bContextDataResult *result)
+{
+ bAnimContext ac;
+ if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) {
+ ListBase anim_data = {NULL, NULL};
+
+ /* Use keyframes from editable selected FCurves. */
+ int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS | ANIMFILTER_FOREDIT |
+ ANIMFILTER_SEL) |
+ (ac.spacetype == SPACE_GRAPH ? ANIMFILTER_CURVE_VISIBLE :
+ ANIMFILTER_LIST_VISIBLE);
+
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ int i;
+ FCurve *fcurve;
+ BezTriple *bezt;
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
+ if (!ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
+ continue;
+ }
+
+ fcurve = (FCurve *)ale->data;
+ for (i = 0, bezt = fcurve->bezt; i < fcurve->totvert; i++, bezt++) {
+ if ((bezt->f2 & SELECT) == 0) {
+ continue;
+ }
+
+ CTX_data_list_add(result, ale->fcurve_owner_id, &RNA_Keyframe, bezt);
+ }
+ }
+
+ ANIM_animdata_freelist(&anim_data);
+
+ CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+ return CTX_RESULT_OK;
+ }
+ return CTX_RESULT_NO_DATA;
+}
/* Registry of context callback functions. */
@@ -1058,6 +1093,7 @@ static void ensure_ed_screen_context_functions(void)
register_context_function("selected_editable_fcurves", screen_ctx_selected_editable_fcurves);
register_context_function("selected_visible_fcurves", screen_ctx_selected_visible_fcurves);
register_context_function("active_editable_fcurve", screen_ctx_active_editable_fcurve);
+ register_context_function("selected_editable_keyframes", screen_ctx_selected_editable_keyframes);
}
/* Entry point for the screen context. */
diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c
index 8ded845b008..ddb1f5c87ba 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -45,10 +45,8 @@ static void draw_horizontal_join_shape(ScrArea *area, char dir, uint pos)
{
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;
+ float w, h;
if (height < width) {
h = height / 8;
w = height / 4;
@@ -58,6 +56,7 @@ static void draw_horizontal_join_shape(ScrArea *area, char dir, uint pos)
w = width / 4;
}
+ vec2f points[10];
points[0].x = area->v1->vec.x;
points[0].y = area->v1->vec.y + height / 2;
@@ -91,7 +90,7 @@ static void draw_horizontal_join_shape(ScrArea *area, char dir, uint pos)
if (dir == 'l') {
/* when direction is left, then we flip direction of arrow */
float cx = area->v1->vec.x + width;
- for (i = 0; i < 10; i++) {
+ for (int i = 0; i < 10; i++) {
points[i].x -= cx;
points[i].x = -points[i].x;
points[i].x += area->v1->vec.x;
@@ -100,7 +99,7 @@ static void draw_horizontal_join_shape(ScrArea *area, char dir, uint pos)
immBegin(GPU_PRIM_TRI_FAN, 5);
- for (i = 0; i < 5; i++) {
+ for (int i = 0; i < 5; i++) {
immVertex2f(pos, points[i].x, points[i].y);
}
@@ -108,7 +107,7 @@ static void draw_horizontal_join_shape(ScrArea *area, char dir, uint pos)
immBegin(GPU_PRIM_TRI_FAN, 5);
- for (i = 4; i < 8; i++) {
+ for (int i = 4; i < 8; i++) {
immVertex2f(pos, points[i].x, points[i].y);
}
@@ -126,10 +125,8 @@ static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos)
{
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;
+ float w, h;
if (height < width) {
h = height / 4;
w = height / 8;
@@ -139,6 +136,7 @@ static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos)
w = width / 8;
}
+ vec2f points[10];
points[0].x = area->v1->vec.x + width / 2;
points[0].y = area->v3->vec.y;
@@ -172,7 +170,7 @@ static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos)
if (dir == 'u') {
/* when direction is up, then we flip direction of arrow */
float cy = area->v1->vec.y + height;
- for (i = 0; i < 10; i++) {
+ for (int i = 0; i < 10; i++) {
points[i].y -= cy;
points[i].y = -points[i].y;
points[i].y += area->v1->vec.y;
@@ -181,7 +179,7 @@ static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos)
immBegin(GPU_PRIM_TRI_FAN, 5);
- for (i = 0; i < 5; i++) {
+ for (int i = 0; i < 5; i++) {
immVertex2f(pos, points[i].x, points[i].y);
}
@@ -189,7 +187,7 @@ static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos)
immBegin(GPU_PRIM_TRI_FAN, 5);
- for (i = 4; i < 8; i++) {
+ for (int i = 4; i < 8; i++) {
immVertex2f(pos, points[i].x, points[i].y);
}
@@ -217,12 +215,13 @@ static void draw_join_shape(ScrArea *area, char dir, uint pos)
static void do_vert_pair(GPUVertBuf *vbo, uint pos, uint *vidx, int corner, int i)
{
- float inter[2], exter[2];
+ float inter[2];
inter[0] = cosf(corner * M_PI_2 + (i * M_PI_2 / (CORNER_RESOLUTION - 1.0f)));
inter[1] = sinf(corner * M_PI_2 + (i * M_PI_2 / (CORNER_RESOLUTION - 1.0f)));
/* Snap point to edge */
float div = 1.0f / max_ff(fabsf(inter[0]), fabsf(inter[1]));
+ float exter[2];
mul_v2_v2fl(exter, inter, div);
exter[0] = roundf(exter[0]);
exter[1] = roundf(exter[1]);
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index ee8dacd28fc..5f56bbaef9d 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -108,17 +108,15 @@ 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 (area == NULL) {
return NULL;
}
+ rcti window_rect;
WM_window_rect_calc(win, &window_rect);
- split = screen_geom_find_area_split_point(area, &window_rect, dir, fac);
+ short split = screen_geom_find_area_split_point(area, &window_rect, dir, fac);
if (split == 0) {
return NULL;
}
@@ -129,8 +127,8 @@ ScrArea *area_split(
if (dir == 'h') {
/* new vertices */
- sv1 = screen_geom_vertex_add(screen, area->v1->vec.x, split);
- sv2 = screen_geom_vertex_add(screen, area->v4->vec.x, split);
+ ScrVert *sv1 = screen_geom_vertex_add(screen, area->v1->vec.x, split);
+ ScrVert *sv2 = screen_geom_vertex_add(screen, area->v4->vec.x, split);
/* new edges */
screen_geom_edge_add(screen, area->v1, sv1);
@@ -160,8 +158,8 @@ ScrArea *area_split(
}
else {
/* new vertices */
- sv1 = screen_geom_vertex_add(screen, split, area->v1->vec.y);
- sv2 = screen_geom_vertex_add(screen, split, area->v2->vec.y);
+ ScrVert *sv1 = screen_geom_vertex_add(screen, split, area->v1->vec.y);
+ ScrVert *sv2 = screen_geom_vertex_add(screen, split, area->v2->vec.y);
/* new edges */
screen_geom_edge_add(screen, area->v1, sv1);
@@ -205,17 +203,14 @@ ScrArea *area_split(
*/
bScreen *screen_add(Main *bmain, const char *name, const rcti *rect)
{
- bScreen *screen;
- ScrVert *sv1, *sv2, *sv3, *sv4;
-
- screen = BKE_libblock_alloc(bmain, ID_SCR, name, 0);
+ bScreen *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(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);
+ ScrVert *sv1 = screen_geom_vertex_add(screen, rect->xmin, rect->ymin);
+ ScrVert *sv2 = screen_geom_vertex_add(screen, rect->xmin, rect->ymax - 1);
+ ScrVert *sv3 = screen_geom_vertex_add(screen, rect->xmax - 1, rect->ymax - 1);
+ ScrVert *sv4 = screen_geom_vertex_add(screen, rect->xmax - 1, rect->ymin);
screen_geom_edge_add(screen, sv1, sv2);
screen_geom_edge_add(screen, sv2, sv3);
@@ -230,9 +225,6 @@ bScreen *screen_add(Main *bmain, const char *name, const rcti *rect)
void screen_data_copy(bScreen *to, bScreen *from)
{
- ScrVert *s2;
- ScrArea *area, *saf;
-
/* free contents of 'to', is from blenkernel screen.c */
BKE_screen_free(to);
@@ -243,7 +235,7 @@ void screen_data_copy(bScreen *to, bScreen *from)
BLI_duplicatelist(&to->areabase, &from->areabase);
BLI_listbase_clear(&to->regionbase);
- s2 = to->vertbase.first;
+ ScrVert *s2 = to->vertbase.first;
for (ScrVert *s1 = from->vertbase.first; s1; s1 = s1->next, s2 = s2->next) {
s1->newv = s2;
}
@@ -254,8 +246,8 @@ void screen_data_copy(bScreen *to, bScreen *from)
BKE_screen_sort_scrvert(&(se->v1), &(se->v2));
}
- saf = from->areabase.first;
- for (area = to->areabase.first; area; area = area->next, saf = saf->next) {
+ ScrArea *from_area = from->areabase.first;
+ LISTBASE_FOREACH (ScrArea *, area, &to->areabase) {
area->v1 = area->v1->newv;
area->v2 = area->v2->newv;
area->v3 = area->v3->newv;
@@ -266,7 +258,9 @@ void screen_data_copy(bScreen *to, bScreen *from)
BLI_listbase_clear(&area->actionzones);
BLI_listbase_clear(&area->handlers);
- ED_area_data_copy(area, saf, true);
+ ED_area_data_copy(area, from_area, true);
+
+ from_area = from_area->next;
}
/* put at zero (needed?) */
@@ -1232,7 +1226,6 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
WorkSpace *workspace = WM_window_get_active_workspace(win);
- bScreen *screen, *oldscreen;
if (area) {
/* ensure we don't have a button active anymore, can crash when
@@ -1251,12 +1244,12 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
ED_area_status_text(area, NULL);
ED_workspace_status_text(C, NULL);
}
-
+ bScreen *screen;
if (area && area->full) {
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
/* restoring back to SCREENNORMAL */
- screen = area->full; /* the old screen to restore */
- oldscreen = WM_window_get_active_screen(win); /* the one disappearing */
+ screen = area->full; /* the old screen to restore */
+ bScreen *oldscreen = WM_window_get_active_screen(win); /* the one disappearing */
BLI_assert(BKE_workspace_layout_screen_get(layout_old) != screen);
BLI_assert(BKE_workspace_layout_screen_get(layout_old)->state != SCREENNORMAL);
@@ -1321,7 +1314,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
BLI_assert(ELEM(state, SCREENMAXIMIZED, SCREENFULL));
- oldscreen = WM_window_get_active_screen(win);
+ bScreen *oldscreen = WM_window_get_active_screen(win);
oldscreen->state = state;
BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name + 2, "nonnormal");
diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c
index 29e5f398ec3..4acf3dd7ba5 100644
--- a/source/blender/editors/screen/screen_geometry.c
+++ b/source/blender/editors/screen/screen_geometry.c
@@ -132,10 +132,9 @@ ScrEdge *screen_geom_find_active_scredge(const wmWindow *win,
{
/* Use layout size (screen excluding global areas) for screen-layout area edges */
rcti screen_rect;
- ScrEdge *se;
-
WM_window_screen_rect_calc(win, &screen_rect);
- se = screen_geom_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(screen), &screen_rect, mx, my);
+ ScrEdge *se = screen_geom_area_map_find_active_scredge(
+ AREAMAP_FROM_SCREEN(screen), &screen_rect, mx, my);
if (!se) {
/* Use entire window size (screen including global areas) for global area edges */
@@ -157,21 +156,19 @@ static bool screen_geom_vertices_scale_pass(const wmWindow *win,
const int screen_size_x = BLI_rcti_size_x(screen_rect);
const int screen_size_y = BLI_rcti_size_y(screen_rect);
- int screen_size_x_prev, screen_size_y_prev;
- float min[2], max[2];
bool needs_another_pass = false;
/* calculate size */
- min[0] = min[1] = 20000.0f;
- max[0] = max[1] = 0.0f;
+ float min[2] = {20000.0f, 20000.0f};
+ float max[2] = {0.0f, 0.0f};
LISTBASE_FOREACH (ScrVert *, sv, &screen->vertbase) {
const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y};
minmax_v2v2_v2(min, max, fv);
}
- screen_size_x_prev = (max[0] - min[0]) + 1;
- screen_size_y_prev = (max[1] - min[1]) + 1;
+ int screen_size_x_prev = (max[0] - min[0]) + 1;
+ int screen_size_y_prev = (max[1] - min[1]) + 1;
if (screen_size_x_prev != screen_size_x || screen_size_y_prev != screen_size_y) {
const float facx = ((float)screen_size_x - 1) / ((float)screen_size_x_prev - 1);
@@ -258,7 +255,6 @@ static bool screen_geom_vertices_scale_pass(const wmWindow *win,
void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen)
{
rcti window_rect, screen_rect;
-
WM_window_rect_calc(win, &window_rect);
WM_window_screen_rect_calc(win, &screen_rect);
@@ -311,14 +307,12 @@ short screen_geom_find_area_split_point(const ScrArea *area,
char dir,
float fac)
{
- short x, y;
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;
- // area big enough?
+ /* area big enough? */
if ((dir == 'v') && (cur_area_width <= 2 * area_min_x)) {
return 0;
}
@@ -326,13 +320,13 @@ short screen_geom_find_area_split_point(const ScrArea *area,
return 0;
}
- // to be sure
+ /* to be sure */
CLAMP(fac, 0.0f, 1.0f);
if (dir == 'h') {
- y = area->v1->vec.y + round_fl_to_short(fac * cur_area_height);
+ short y = area->v1->vec.y + round_fl_to_short(fac * cur_area_height);
- area_min = area_min_y;
+ int area_min = area_min_y;
if (area->v1->vec.y > window_rect->ymin) {
area_min += U.pixelsize;
@@ -351,9 +345,9 @@ short screen_geom_find_area_split_point(const ScrArea *area,
return y;
}
- x = area->v1->vec.x + round_fl_to_short(fac * cur_area_width);
+ short x = area->v1->vec.x + round_fl_to_short(fac * cur_area_width);
- area_min = area_min_x;
+ int area_min = area_min_x;
if (area->v1->vec.x > window_rect->xmin) {
area_min += U.pixelsize;
@@ -378,12 +372,9 @@ short screen_geom_find_area_split_point(const ScrArea *area,
void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge)
{
bScreen *screen = WM_window_get_active_screen(win);
- bool oneselected = true;
- char dir;
- /* select connected, only in the right direction */
/* 'dir' is the direction of EDGE */
-
+ char dir;
if (edge->v1->vec.x == edge->v2->vec.x) {
dir = 'v';
}
@@ -399,6 +390,8 @@ void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge)
edge->v1->flag = 1;
edge->v2->flag = 1;
+ /* select connected, only in the right direction */
+ bool oneselected = true;
while (oneselected) {
oneselected = false;
LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) {
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 16d7c641c50..8fc2bf96639 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -159,11 +159,10 @@ static bool ED_operator_screenactive_norender(bContext *C)
/* when mouse is over area-edge */
bool ED_operator_screen_mainwinactive(bContext *C)
{
- bScreen *screen;
if (CTX_wm_window(C) == NULL) {
return false;
}
- screen = CTX_wm_screen(C);
+ bScreen *screen = CTX_wm_screen(C);
if (screen == NULL) {
return false;
}
@@ -448,8 +447,8 @@ bool ED_operator_posemode_exclusive(bContext *C)
Object *obact = CTX_data_active_object(C);
if (obact && !(obact->mode & OB_MODE_EDIT)) {
- Object *obpose;
- if ((obpose = BKE_object_pose_armature_get(obact))) {
+ Object *obpose = BKE_object_pose_armature_get(obact);
+ if (obpose != NULL) {
if (obact == obpose) {
return true;
}
@@ -479,8 +478,8 @@ bool ED_operator_posemode(bContext *C)
Object *obact = CTX_data_active_object(C);
if (obact && !(obact->mode & OB_MODE_EDIT)) {
- Object *obpose;
- if ((obpose = BKE_object_pose_armature_get(obact))) {
+ Object *obpose = BKE_object_pose_armature_get(obact);
+ if (obpose != NULL) {
if ((obact == obpose) || (obact->mode & OB_MODE_ALL_WEIGHT_PAINT)) {
return true;
}
@@ -958,12 +957,12 @@ static void actionzone_exit(wmOperator *op)
/* send EVT_ACTIONZONE event */
static void actionzone_apply(bContext *C, wmOperator *op, int type)
{
- wmEvent event;
wmWindow *win = CTX_wm_window(C);
sActionzoneData *sad = op->customdata;
sad->modifier = RNA_int_get(op->ptr, "modifier");
+ wmEvent event;
wm_event_init_from_window(win, &event);
if (type == AZONE_AREA) {
@@ -988,7 +987,6 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
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,
* they have their own handling. */
@@ -997,7 +995,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");
+ sActionzoneData *sad = op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData");
sad->sa1 = screen_actionzone_area(screen, az);
sad->az = az;
sad->x = event->x;
@@ -1025,8 +1023,6 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case MOUSEMOVE: {
- bool is_gesture;
-
const int delta_x = (event->x - sad->x);
const int delta_y = (event->y - sad->y);
@@ -1052,10 +1048,11 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
sad->gesture_dir = 'w';
}
+ bool is_gesture;
if (sad->az->type == AZONE_AREA) {
wmWindow *win = CTX_wm_window(C);
- rcti screen_rect;
+ rcti screen_rect;
WM_window_screen_rect_calc(win, &screen_rect);
/* Have we dragged off the zone and are not on an edge? */
@@ -1154,10 +1151,9 @@ static ScrEdge *screen_area_edge_from_cursor(const bContext *C,
{
wmWindow *win = CTX_wm_window(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(
+ ScrEdge *actedge = screen_geom_area_map_find_active_scredge(
AREAMAP_FROM_SCREEN(screen), &window_rect, cursor[0], cursor[1]);
*r_sa1 = NULL;
*r_sa2 = NULL;
@@ -1215,14 +1211,13 @@ typedef struct sAreaSwapData {
static bool area_swap_init(wmOperator *op, const wmEvent *event)
{
- sAreaSwapData *sd = NULL;
sActionzoneData *sad = event->customdata;
if (sad == NULL || sad->sa1 == NULL) {
return false;
}
- sd = MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData");
+ sAreaSwapData *sd = MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData");
sd->sa1 = sad->sa1;
sd->sa2 = sad->sa2;
op->customdata = sd;
@@ -1337,18 +1332,12 @@ static void SCREEN_OT_area_swap(wmOperatorType *ot)
static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Main *bmain = CTX_data_main(C);
- wmWindow *newwin, *win = CTX_wm_window(C);
- Scene *scene;
+ wmWindow *win = CTX_wm_window(C);
WorkSpace *workspace = WM_window_get_active_workspace(win);
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
- WorkSpaceLayout *layout_new;
- bScreen *newsc;
- ScrArea *area;
- rcti rect;
- win = CTX_wm_window(C);
- scene = CTX_data_scene(C);
- area = CTX_wm_area(C);
+ Scene *scene = CTX_data_scene(C);
+ ScrArea *area = CTX_wm_area(C);
/* XXX hrmf! */
if (event->type == EVT_ACTIONZONE_AREA) {
@@ -1362,12 +1351,12 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
/* adds window to WM */
- rect = area->totrct;
+ rcti 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;
- newwin = WM_window_open(C, &rect);
+ wmWindow *newwin = WM_window_open(C, &rect);
if (newwin == NULL) {
BKE_report(op->reports, RPT_ERROR, "Failed to open window!");
goto finally;
@@ -1381,9 +1370,9 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
BKE_workspace_active_set(newwin->workspace_hook, workspace);
/* allocs new screen and adds to newly created window, using window size */
- layout_new = ED_workspace_layout_add(
+ WorkSpaceLayout *layout_new = ED_workspace_layout_add(
bmain, workspace, newwin, BKE_workspace_layout_name_get(layout_old));
- newsc = BKE_workspace_layout_screen_get(layout_new);
+ bScreen *newsc = BKE_workspace_layout_screen_get(layout_new);
WM_window_set_active_layout(newwin, workspace, layout_new);
/* copy area to new screen */
@@ -1475,10 +1464,6 @@ static void area_move_set_limits(wmWindow *win,
int *smaller,
bool *use_bigger_smaller_snap)
{
- rcti window_rect;
- int areaminy = ED_area_headersize();
- int areamin;
-
/* we check all areas and test for free space with MINSIZE */
*bigger = *smaller = 100000;
@@ -1523,12 +1508,12 @@ static void area_move_set_limits(wmWindow *win,
}
}
+ rcti window_rect;
WM_window_rect_calc(win, &window_rect);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (dir == 'h') {
- int y1;
- areamin = areaminy;
+ int areamin = ED_area_headersize();
if (area->v1->vec.y > window_rect.ymin) {
areamin += U.pixelsize;
@@ -1537,7 +1522,7 @@ static void area_move_set_limits(wmWindow *win,
areamin += U.pixelsize;
}
- y1 = screen_geom_area_height(area) - areamin;
+ int y1 = screen_geom_area_height(area) - areamin;
/* if top or down edge selected, test height */
if (area->v1->editflag && area->v4->editflag) {
@@ -1548,8 +1533,7 @@ static void area_move_set_limits(wmWindow *win,
}
}
else {
- int x1;
- areamin = AREAMINX;
+ int areamin = AREAMINX;
if (area->v1->vec.x > window_rect.xmin) {
areamin += U.pixelsize;
@@ -1558,7 +1542,7 @@ static void area_move_set_limits(wmWindow *win,
areamin += U.pixelsize;
}
- x1 = screen_geom_area_width(area) - areamin;
+ int x1 = screen_geom_area_width(area) - areamin;
/* if left or right edge selected, test width */
if (area->v1->editflag && area->v2->editflag) {
@@ -1577,21 +1561,18 @@ static bool area_move_init(bContext *C, wmOperator *op)
{
bScreen *screen = CTX_wm_screen(C);
wmWindow *win = CTX_wm_window(C);
- ScrEdge *actedge;
- sAreaMoveData *md;
- int x, y;
/* required properties */
- x = RNA_int_get(op->ptr, "x");
- y = RNA_int_get(op->ptr, "y");
+ int x = RNA_int_get(op->ptr, "x");
+ int y = RNA_int_get(op->ptr, "y");
/* setup */
- actedge = screen_geom_find_active_scredge(win, screen, x, y);
+ ScrEdge *actedge = screen_geom_find_active_scredge(win, screen, x, y);
if (actedge == NULL) {
return false;
}
- md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
+ sAreaMoveData *md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
op->customdata = md;
md->dir = screen_geom_edge_is_horizontal(actedge) ? 'h' : 'v';
@@ -1850,15 +1831,14 @@ static void area_move_cancel(bContext *C, wmOperator *op)
static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
sAreaMoveData *md = op->customdata;
- int delta, x, y;
/* execute the events */
switch (event->type) {
case MOUSEMOVE: {
- x = RNA_int_get(op->ptr, "x");
- y = RNA_int_get(op->ptr, "y");
+ int x = RNA_int_get(op->ptr, "x");
+ int y = RNA_int_get(op->ptr, "y");
- delta = (md->dir == 'v') ? event->x - x : event->y - y;
+ int delta = (md->dir == 'v') ? event->x - x : event->y - y;
RNA_int_set(op->ptr, "delta", delta);
area_move_apply(C, op);
@@ -1986,10 +1966,8 @@ static void area_split_draw_cb(const struct wmWindow *UNUSED(win), void *userdat
/* generic init, menu case, doesn't need active area */
static bool area_split_menu_init(bContext *C, wmOperator *op)
{
- sAreaSplitData *sd;
-
/* custom data */
- sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split");
+ sAreaSplitData *sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split");
op->customdata = sd;
sd->sarea = CTX_wm_area(C);
@@ -2001,9 +1979,6 @@ static bool area_split_menu_init(bContext *C, wmOperator *op)
static bool area_split_init(bContext *C, wmOperator *op)
{
ScrArea *area = CTX_wm_area(C);
- sAreaSplitData *sd;
- int areaminy = ED_area_headersize();
- int dir;
/* required context */
if (area == NULL) {
@@ -2011,18 +1986,18 @@ static bool area_split_init(bContext *C, wmOperator *op)
}
/* required properties */
- dir = RNA_enum_get(op->ptr, "direction");
+ int dir = RNA_enum_get(op->ptr, "direction");
/* minimal size */
if (dir == 'v' && area->winx < 2 * AREAMINX) {
return false;
}
- if (dir == 'h' && area->winy < 2 * areaminy) {
+ if (dir == 'h' && area->winy < 2 * ED_area_headersize()) {
return false;
}
/* custom data */
- sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split");
+ sAreaSplitData *sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split");
op->customdata = sd;
sd->sarea = area;
@@ -2073,44 +2048,42 @@ static bool area_split_apply(bContext *C, wmOperator *op)
const wmWindow *win = CTX_wm_window(C);
bScreen *screen = CTX_wm_screen(C);
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
- float fac;
- int dir;
- fac = RNA_float_get(op->ptr, "factor");
- dir = RNA_enum_get(op->ptr, "direction");
+ float fac = RNA_float_get(op->ptr, "factor");
+ int dir = RNA_enum_get(op->ptr, "direction");
sd->narea = area_split(win, screen, sd->sarea, dir, fac, 0); /* 0 = no merge */
- if (sd->narea) {
- sd->nedge = area_findsharededge(screen, sd->sarea, sd->narea);
+ if (sd->narea == NULL) {
+ return false;
+ }
- /* select newly created edge, prepare for moving edge */
- ED_screen_verts_iter(win, screen, sv)
- {
- sv->editflag = 0;
- }
+ sd->nedge = area_findsharededge(screen, sd->sarea, sd->narea);
- sd->nedge->v1->editflag = 1;
- sd->nedge->v2->editflag = 1;
+ /* select newly created edge, prepare for moving edge */
+ ED_screen_verts_iter(win, screen, sv)
+ {
+ sv->editflag = 0;
+ }
- if (dir == 'h') {
- sd->origval = sd->nedge->v1->vec.y;
- }
- else {
- sd->origval = sd->nedge->v1->vec.x;
- }
+ sd->nedge->v1->editflag = 1;
+ sd->nedge->v2->editflag = 1;
- ED_area_tag_redraw(sd->sarea);
- ED_area_tag_redraw(sd->narea);
+ if (dir == 'h') {
+ sd->origval = sd->nedge->v1->vec.y;
+ }
+ else {
+ sd->origval = sd->nedge->v1->vec.x;
+ }
- WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
- /* Update preview thumbnail */
- BKE_icon_changed(screen->id.icon_id);
+ ED_area_tag_redraw(sd->sarea);
+ ED_area_tag_redraw(sd->narea);
- return true;
- }
+ WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
+ /* Update preview thumbnail */
+ BKE_icon_changed(screen->id.icon_id);
- return false;
+ return true;
}
static void area_split_exit(bContext *C, wmOperator *op)
@@ -2154,8 +2127,6 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
wmWindow *win = CTX_wm_window(C);
bScreen *screen = CTX_wm_screen(C);
- sAreaSplitData *sd;
- int dir;
/* no full window splitting allowed */
BLI_assert(screen->state == SCREENNORMAL);
@@ -2164,6 +2135,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
PropertyRNA *prop_factor = RNA_struct_find_property(op->ptr, "factor");
PropertyRNA *prop_cursor = RNA_struct_find_property(op->ptr, "cursor");
+ int dir;
if (event->type == EVT_ACTIONZONE_AREA) {
sActionzoneData *sad = event->customdata;
@@ -2233,8 +2205,6 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
}
else {
- ScrEdge *actedge;
- rcti window_rect;
int event_co[2];
/* retrieve initial mouse coord, so we can find the active edge */
@@ -2245,9 +2215,10 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
copy_v2_v2_int(event_co, &event->x);
}
+ rcti window_rect;
WM_window_rect_calc(win, &window_rect);
- actedge = screen_geom_area_map_find_active_scredge(
+ ScrEdge *actedge = screen_geom_area_map_find_active_scredge(
AREAMAP_FROM_SCREEN(screen), &window_rect, event_co[0], event_co[1]);
if (actedge == NULL) {
return OPERATOR_CANCELLED;
@@ -2263,10 +2234,9 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- sd = (sAreaSplitData *)op->customdata;
+ sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
if (event->type == EVT_ACTIONZONE_AREA) {
-
/* do the split */
if (area_split_apply(C, op)) {
area_move_set_limits(win, screen, dir, &sd->bigger, &sd->smaller, NULL);
@@ -2294,7 +2264,6 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* function to be called outside UI context, or for redo */
static int area_split_exec(bContext *C, wmOperator *op)
{
-
if (!area_split_init(C, op)) {
return OPERATOR_CANCELLED;
}
@@ -2565,14 +2534,13 @@ static void region_scale_exit(wmOperator *op)
static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
sActionzoneData *sad = event->customdata;
- AZone *az;
if (event->type != EVT_ACTIONZONE_REGION) {
BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone");
return OPERATOR_CANCELLED;
}
- az = sad->az;
+ AZone *az = sad->az;
if (az->region) {
RegionMoveData *rmd = MEM_callocN(sizeof(RegionMoveData), "RegionMoveData");
@@ -2853,9 +2821,8 @@ static void areas_do_frame_follow(bContext *C, bool middle)
static int frame_offset_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- int delta;
- delta = RNA_int_get(op->ptr, "delta");
+ int delta = RNA_int_get(op->ptr, "delta");
CFRA += delta;
FRAMENUMBER_MIN_CLAMP(CFRA);
@@ -2960,9 +2927,6 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
bDopeSheet ads = {NULL};
- DLRBT_Tree keys;
- ActKeyColumn *ak;
- float cfra;
const bool next = RNA_boolean_get(op->ptr, "next");
bool done = false;
@@ -2971,9 +2935,10 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- cfra = (float)(CFRA);
+ float cfra = (float)(CFRA);
/* init binarytree-list for getting keyframes */
+ DLRBT_Tree keys;
BLI_dlrbTree_init(&keys);
/* seed up dummy dopesheet context with flags to perform necessary filtering */
@@ -3003,6 +2968,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
}
/* find matching keyframe in the right direction */
+ ActKeyColumn *ak;
if (next) {
ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
}
@@ -3355,7 +3321,6 @@ static int area_join_exec(bContext *C, wmOperator *op)
/* interaction callback */
static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
-
if (event->type == EVT_ACTIONZONE_AREA) {
sActionzoneData *sad = event->customdata;
@@ -3395,14 +3360,13 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
bScreen *screen = CTX_wm_screen(C);
wmWindow *win = CTX_wm_window(C);
- sAreaJoinData *jd;
if (op->customdata == NULL) {
if (!area_join_init(C, op, NULL, NULL)) {
return OPERATOR_CANCELLED;
}
}
- jd = (sAreaJoinData *)op->customdata;
+ sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
/* execute the events */
switch (event->type) {
@@ -3524,20 +3488,16 @@ static void SCREEN_OT_area_join(wmOperatorType *ot)
static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- uiPopupMenu *pup;
- uiLayout *layout;
- PointerRNA ptr;
-
ScrArea *sa1, *sa2;
-
if (screen_area_edge_from_cursor(C, &event->x, &sa1, &sa2) == NULL) {
return OPERATOR_CANCELLED;
}
- pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE);
- layout = UI_popup_menu_layout(pup);
+ uiPopupMenu *pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE);
+ uiLayout *layout = UI_popup_menu_layout(pup);
/* Vertical Split */
+ PointerRNA ptr;
uiItemFullO(layout,
"SCREEN_OT_area_split",
IFACE_("Vertical Split"),
@@ -3712,19 +3672,17 @@ static void SCREEN_OT_repeat_last(wmOperatorType *ot)
static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
wmWindowManager *wm = CTX_wm_manager(C);
- wmOperator *lastop;
- uiPopupMenu *pup;
- uiLayout *layout;
- int items, i;
- items = BLI_listbase_count(&wm->operators);
+ int items = BLI_listbase_count(&wm->operators);
if (items == 0) {
return OPERATOR_CANCELLED;
}
- pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE);
- layout = UI_popup_menu_layout(pup);
+ uiPopupMenu *pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE);
+ uiLayout *layout = UI_popup_menu_layout(pup);
+ wmOperator *lastop;
+ int i;
for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--) {
if ((lastop->type->flag & OPTYPE_REGISTER) && WM_operator_repeat_check(C, lastop)) {
uiItemIntO(layout,
@@ -3850,7 +3808,6 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
else if (region->alignment == RGN_ALIGN_QSPLIT) {
/* Exit quad-view */
ScrArea *area = CTX_wm_area(C);
- ARegion *arn;
/* keep current region */
region->alignment = 0;
@@ -3887,10 +3844,9 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
}
}
- for (region = area->regionbase.first; region; region = arn) {
- arn = region->next;
- if (region->alignment == RGN_ALIGN_QSPLIT) {
- ED_region_remove(C, area, region);
+ LISTBASE_FOREACH_MUTABLE (ARegion *, region_iter, &area->regionbase) {
+ if (region_iter->alignment == RGN_ALIGN_QSPLIT) {
+ ED_region_remove(C, area, region_iter);
}
}
ED_area_tag_redraw(area);
@@ -3902,14 +3858,12 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
else {
/* Enter quad-view */
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(area->type, region);
- BLI_addtail(&area->regionbase, newar);
+ for (int count = 0; count < 3; count++) {
+ ARegion *new_region = BKE_area_region_copy(area->type, region);
+ BLI_addtail(&area->regionbase, new_region);
}
/* lock views and set them */
@@ -3981,8 +3935,8 @@ static void SCREEN_OT_region_quadview(wmOperatorType *ot)
static int region_toggle_exec(bContext *C, wmOperator *op)
{
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "region_type");
- ARegion *region;
+ ARegion *region;
if (RNA_property_is_set(op->ptr, prop)) {
region = BKE_area_find_region_type(CTX_wm_area(C), RNA_property_enum_get(op->ptr, prop));
}
@@ -4235,32 +4189,30 @@ static int screen_context_menu_invoke(bContext *C,
wmOperator *UNUSED(op),
const wmEvent *UNUSED(event))
{
- uiPopupMenu *pup;
- uiLayout *layout;
const ScrArea *area = CTX_wm_area(C);
const ARegion *region = CTX_wm_region(C);
if (area && area->spacetype == SPACE_STATUSBAR) {
- pup = UI_popup_menu_begin(C, IFACE_("Status Bar"), ICON_NONE);
- layout = UI_popup_menu_layout(pup);
+ uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Status Bar"), ICON_NONE);
+ uiLayout *layout = UI_popup_menu_layout(pup);
ed_screens_statusbar_menu_create(layout, NULL);
UI_popup_menu_end(C, pup);
}
else if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
- pup = UI_popup_menu_begin(C, IFACE_("Header"), ICON_NONE);
- layout = UI_popup_menu_layout(pup);
+ uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Header"), ICON_NONE);
+ uiLayout *layout = UI_popup_menu_layout(pup);
ED_screens_header_tools_menu_create(C, layout, NULL);
UI_popup_menu_end(C, pup);
}
else if (region->regiontype == RGN_TYPE_FOOTER) {
- pup = UI_popup_menu_begin(C, IFACE_("Footer"), ICON_NONE);
- layout = UI_popup_menu_layout(pup);
+ uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Footer"), ICON_NONE);
+ uiLayout *layout = UI_popup_menu_layout(pup);
ED_screens_footer_tools_menu_create(C, layout, NULL);
UI_popup_menu_end(C, pup);
}
else if (region->regiontype == RGN_TYPE_NAV_BAR) {
- pup = UI_popup_menu_begin(C, IFACE_("Navigation Bar"), ICON_NONE);
- layout = UI_popup_menu_layout(pup);
+ uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Navigation Bar"), ICON_NONE);
+ uiLayout *layout = UI_popup_menu_layout(pup);
ED_screens_navigation_bar_tools_menu_create(C, layout, NULL);
UI_popup_menu_end(C, pup);
}
@@ -4953,10 +4905,6 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op)
wmWindow *win_cur = CTX_wm_window(C);
/* Use eventstate, not event from _invoke, so this can be called through exec(). */
const wmEvent *event = win_cur->eventstate;
- PointerRNA ptr = {NULL};
- PropertyRNA *prop = NULL;
- int index = -1;
- uiBut *but = NULL;
int sizex = 900 * UI_DPI_FAC;
int sizey = 580 * UI_DPI_FAC;
@@ -4965,7 +4913,10 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op)
* - Need to grab it first, or else this info disappears
* after we've created the window
*/
- but = UI_context_active_but_prop_get(C, &ptr, &prop, &index);
+ int index;
+ PointerRNA ptr;
+ PropertyRNA *prop;
+ uiBut *but = UI_context_active_but_prop_get(C, &ptr, &prop, &index);
/* changes context! */
if (WM_window_open_temp(C,
@@ -4980,16 +4931,16 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op)
/* activate driver F-Curve for the property under the cursor */
if (but) {
- FCurve *fcu;
bool driven, special;
+ FCurve *fcu = BKE_fcurve_find_by_rna_context_ui(
+ C, &ptr, prop, index, NULL, NULL, &driven, &special);
- fcu = BKE_fcurve_find_by_rna_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special);
if (fcu) {
/* Isolate this F-Curve... */
bAnimContext ac;
if (ANIM_animdata_get_context(C, &ac)) {
int filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS;
- ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ ANIM_anim_channels_select_set(&ac, ACHANNEL_SETFLAG_CLEAR);
ANIM_set_active_channel(&ac, ac.data, ac.datatype, filter, fcu, ANIMTYPE_FCURVE);
}
else {
@@ -5072,9 +5023,9 @@ static int screen_new_exec(bContext *C, wmOperator *UNUSED(op))
wmWindow *win = CTX_wm_window(C);
WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
WorkSpaceLayout *layout_old = BKE_workspace_active_layout_get(win->workspace_hook);
- WorkSpaceLayout *layout_new;
- layout_new = ED_workspace_layout_duplicate(bmain, workspace, layout_old, win);
+ WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(bmain, workspace, layout_old, win);
+
WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTBROWSE, layout_new);
return OPERATOR_FINISHED;
@@ -5198,14 +5149,13 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARe
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
- RegionAlphaInfo *rgi;
/* end running timer */
if (region->regiontimer) {
region_blend_end(C, region, true);
}
- rgi = MEM_callocN(sizeof(RegionAlphaInfo), "RegionAlphaInfo");
+ RegionAlphaInfo *rgi = MEM_callocN(sizeof(RegionAlphaInfo), "RegionAlphaInfo");
rgi->hidden = region->flag & RGN_FLAG_HIDDEN;
rgi->area = area;
@@ -5234,7 +5184,6 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARe
/* timer runs in win->handlers, so it cannot use context to find area/region */
static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
- RegionAlphaInfo *rgi;
wmTimer *timer = event->customdata;
/* event type is TIMERREGION, but we better check */
@@ -5242,7 +5191,7 @@ static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven
return OPERATOR_PASS_THROUGH;
}
- rgi = timer->customdata;
+ RegionAlphaInfo *rgi = timer->customdata;
/* always send redraws */
ED_region_tag_redraw(rgi->region);
@@ -5577,10 +5526,9 @@ static void keymap_modal_set(wmKeyConfig *keyconf)
{KM_MODAL_SNAP_OFF, "SNAP_OFF", 0, "Snap off", ""},
{0, NULL, 0, NULL, NULL},
};
- wmKeyMap *keymap;
/* Standard Modal keymap ------------------------------------------------ */
- keymap = WM_modalkeymap_ensure(keyconf, "Standard Modal Map", modal_items);
+ wmKeyMap *keymap = WM_modalkeymap_ensure(keyconf, "Standard Modal Map", modal_items);
WM_modalkeymap_assign(keymap, "SCREEN_OT_area_move");
}
@@ -5607,8 +5555,6 @@ static void blend_file_drop_copy(wmDrag *drag, wmDropBox *drop)
/* called in spacetypes.c */
void ED_keymap_screen(wmKeyConfig *keyconf)
{
- ListBase *lb;
-
/* Screen Editing ------------------------------------------------ */
WM_keymap_ensure(keyconf, "Screen Editing", 0, 0);
@@ -5623,7 +5569,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
WM_keymap_ensure(keyconf, "Frames", 0, 0);
/* dropbox for entire window */
- lb = WM_dropboxmap_find("Window", 0, 0);
+ ListBase *lb = WM_dropboxmap_find("Window", 0, 0);
WM_dropbox_add(lb, "WM_OT_drop_blend_file", blend_file_drop_poll, blend_file_drop_copy);
WM_dropbox_add(lb, "UI_OT_drop_color", UI_drop_color_poll, UI_drop_color_copy);
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 9fb11899d78..5d0ae292ffa 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -203,12 +203,12 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
{
uiLayout *layout = op->layout;
ScreenshotData *scd = op->customdata;
- PointerRNA ptr;
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
/* image template */
+ PointerRNA ptr;
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &scd->im_format, &ptr);
uiTemplateImageSettings(layout, &ptr, false);
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index aca2b48a937..cab2d32bdcf 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -385,7 +385,6 @@ static void workspace_append_button(uiLayout *layout,
const Main *from_main)
{
const ID *id = (ID *)workspace;
- PointerRNA opptr;
const char *filepath = from_main->name;
if (strlen(filepath) == 0) {
@@ -393,6 +392,8 @@ static void workspace_append_button(uiLayout *layout,
}
BLI_assert(STREQ(ot_append->idname, "WORKSPACE_OT_append_activate"));
+
+ PointerRNA opptr;
uiItemFullO_ptr(
layout, ot_append, workspace->id.name + 2, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr);
RNA_string_set(&opptr, "idname", id->name + 2);
diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c
index f4b076aca00..31ca11bb847 100644
--- a/source/blender/editors/screen/workspace_layout_edit.c
+++ b/source/blender/editors/screen/workspace_layout_edit.c
@@ -61,11 +61,9 @@ WorkSpaceLayout *ED_workspace_layout_duplicate(Main *bmain,
{
bScreen *screen_old = BKE_workspace_layout_screen_get(layout_old);
const char *name = BKE_workspace_layout_name_get(layout_old);
- bScreen *screen_new;
- WorkSpaceLayout *layout_new;
- layout_new = ED_workspace_layout_add(bmain, workspace, win, name);
- screen_new = BKE_workspace_layout_screen_get(layout_new);
+ WorkSpaceLayout *layout_new = ED_workspace_layout_add(bmain, workspace, win, name);
+ bScreen *screen_new = BKE_workspace_layout_screen_get(layout_new);
if (BKE_screen_is_fullscreen_area(screen_old)) {
LISTBASE_FOREACH (ScrArea *, area_old, &screen_old->areabase) {
@@ -229,7 +227,6 @@ bool ED_workspace_layout_cycle(WorkSpace *workspace, const short direction, bCon
{
wmWindow *win = CTX_wm_window(C);
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 *area = CTX_wm_area(C);
@@ -238,11 +235,12 @@ bool ED_workspace_layout_cycle(WorkSpace *workspace, const short direction, bCon
}
BLI_assert(ELEM(direction, 1, -1));
- new_layout = BKE_workspace_layout_iter_circular(workspace,
- old_layout,
- workspace_layout_cycle_iter_cb,
- NULL,
- (direction == -1) ? true : false);
+ WorkSpaceLayout *new_layout = BKE_workspace_layout_iter_circular(workspace,
+ old_layout,
+ workspace_layout_cycle_iter_cb,
+ NULL,
+ (direction == -1) ? true :
+ false);
if (new_layout && (old_layout != new_layout)) {
bScreen *new_screen = BKE_workspace_layout_screen_get(new_layout);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 3ac2b65f97a..fe16611a6eb 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -882,7 +882,7 @@ static int grab_clone_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case LEFTMOUSE:
case MIDDLEMOUSE:
- case RIGHTMOUSE: // XXX hardcoded
+ case RIGHTMOUSE: /* XXX hardcoded */
MEM_freeN(op->customdata);
return OPERATOR_FINISHED;
case MOUSEMOVE:
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 15ecaec5657..75f1e63ebb3 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -3054,9 +3054,9 @@ static void project_paint_face_init(const ProjPaintState *ps,
lt_uv_pxoffset[2][1] = lt_tri_uv[2][1] - yhalfpx;
{
- uv1co = lt_uv_pxoffset[0]; // was lt_tri_uv[i1];
- uv2co = lt_uv_pxoffset[1]; // was lt_tri_uv[i2];
- uv3co = lt_uv_pxoffset[2]; // was lt_tri_uv[i3];
+ uv1co = lt_uv_pxoffset[0]; /* was lt_tri_uv[i1]; */
+ uv2co = lt_uv_pxoffset[1]; /* was lt_tri_uv[i2]; */
+ uv3co = lt_uv_pxoffset[2]; /* was lt_tri_uv[i3]; */
v1coSS = ps->screenCoords[lt_vtri[0]];
v2coSS = ps->screenCoords[lt_vtri[1]];
@@ -3414,7 +3414,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
}
#else
UNUSED_VARS(vCo, threaded);
-#endif // PROJ_DEBUG_NOSEAMBLEED
+#endif /* PROJ_DEBUG_NOSEAMBLEED */
}
/**
@@ -4221,7 +4221,7 @@ static bool project_paint_winclip(const ProjPaintState *ps, const ProjPaintFaceC
(coSS->v1[1] > ps->screenMax[1] && coSS->v2[1] > ps->screenMax[1] &&
coSS->v3[1] > ps->screenMax[1])));
}
-#endif // PROJ_DEBUG_WINCLIP
+#endif /* PROJ_DEBUG_WINCLIP */
typedef struct PrepareImageEntry {
struct PrepareImageEntry *next, *prev;
@@ -4719,7 +4719,12 @@ static bool project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
const float radius = ps->brush_size;
/* so we don't have a bucket bounds that is way too small to paint into */
- // if (radius < 1.0f) radius = 1.0f; // this doesn't work yet :/
+#if 0
+ /* This doesn't work yet. */
+ if (radius < 1.0f) {
+ radius = 1.0f;
+ }
+#endif
min_brush[0] = mval_f[0] - radius;
min_brush[1] = mval_f[1] - radius;
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 622ea82bf25..8c912290997 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -39,6 +39,7 @@
#include "BLI_task.h"
#include "BLI_utildefines.h"
+#include "BKE_brush.h"
#include "BKE_ccg.h"
#include "BKE_context.h"
#include "BKE_mesh.h"
@@ -283,6 +284,14 @@ typedef struct SculptGestureContext {
float true_clip_planes[4][4];
float clip_planes[4][4];
+ /* These store the view origin and normal in world space, which is used in some gestures to
+ * generate geometry aligned from the view directly in world space. */
+ /* World space view origin and normal are not affected by object symmetry when doing symmetry
+ * passes, so there is no separate variables with the true_ prefix to store their original values
+ * without symmetry modifications. */
+ float world_space_view_origin[3];
+ float world_space_view_normal[3];
+
/* Lasso Gesture. */
LassoGestureData lasso;
@@ -337,11 +346,13 @@ static void sculpt_gesture_context_init_common(bContext *C,
float view_dir[3] = {0.0f, 0.0f, 1.0f};
copy_m3_m4(mat, sgcontext->vc.rv3d->viewinv);
mul_m3_v3(mat, view_dir);
+ normalize_v3_v3(sgcontext->world_space_view_normal, view_dir);
copy_m3_m4(mat, ob->imat);
mul_m3_v3(mat, view_dir);
normalize_v3_v3(sgcontext->true_view_normal, view_dir);
/* View Origin. */
+ copy_v3_v3(sgcontext->world_space_view_origin, sgcontext->vc.rv3d->viewinv[3]);
copy_v3_v3(sgcontext->true_view_origin, sgcontext->vc.rv3d->viewinv[3]);
}
@@ -851,6 +862,8 @@ typedef struct SculptGestureTrimOperation {
float depth_front;
float depth_back;
+ bool use_cursor_depth;
+
eSculptTrimOperationType mode;
} SculptGestureTrimOperation;
@@ -888,25 +901,54 @@ static void sculpt_gesture_trim_normals_update(SculptGestureContext *sgcontext)
trim_operation->mesh = result;
}
-static void sculpt_gesture_trim_calculate_depth(SculptGestureContext *sgcontext)
+static void sculpt_gesture_trim_calculate_depth(bContext *C, SculptGestureContext *sgcontext)
{
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)sgcontext->operation;
SculptSession *ss = sgcontext->ss;
+ ViewContext *vc = &sgcontext->vc;
+
const int totvert = SCULPT_vertex_count_get(ss);
float view_plane[4];
- plane_from_point_normal_v3(view_plane, sgcontext->true_view_origin, sgcontext->true_view_normal);
+ const float *view_origin = sgcontext->world_space_view_origin;
+ const float *view_normal = sgcontext->world_space_view_normal;
+
+ plane_from_point_normal_v3(view_plane, view_origin, view_normal);
trim_operation->depth_front = FLT_MAX;
trim_operation->depth_back = -FLT_MAX;
for (int i = 0; i < totvert; i++) {
const float *vco = SCULPT_vertex_co_get(ss, i);
- const float dist = dist_signed_to_plane_v3(vco, view_plane);
+ /* Convert the coordinates to world space to calculate the depth. When generating the trimming
+ * mesh, coordinates are first calculated in world space, then converted to object space to
+ * store them. */
+ float world_space_vco[3];
+ mul_v3_m4v3(world_space_vco, vc->obact->obmat, vco);
+ const float dist = dist_signed_to_plane_v3(world_space_vco, view_plane);
trim_operation->depth_front = min_ff(dist, trim_operation->depth_front);
trim_operation->depth_back = max_ff(dist, trim_operation->depth_back);
}
+
+ if (trim_operation->use_cursor_depth) {
+ float world_space_gesture_initial_location[3];
+ mul_v3_m4v3(
+ world_space_gesture_initial_location, vc->obact->obmat, ss->gesture_initial_location);
+ const float mid_point_depth = ss->gesture_initial_hit ?
+ dist_signed_to_plane_v3(world_space_gesture_initial_location,
+ view_plane) :
+ (trim_operation->depth_back + trim_operation->depth_front) *
+ 0.5f;
+
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Brush *brush = BKE_paint_brush(&sd->paint);
+ Scene *scene = CTX_data_scene(C);
+ const float depth_radius = BKE_brush_unprojected_radius_get(scene, brush);
+
+ trim_operation->depth_front = mid_point_depth - depth_radius;
+ trim_operation->depth_back = mid_point_depth + depth_radius;
+ }
}
static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontext)
@@ -924,21 +966,34 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
trim_totverts, 0, 0, trim_totpolys * 3, trim_totpolys);
trim_operation->true_mesh_co = MEM_malloc_arrayN(trim_totverts, 3 * sizeof(float), "mesh orco");
- const float depth_front = trim_operation->depth_front - 0.1f;
- const float depth_back = trim_operation->depth_back + 0.1f;
+ float depth_front = trim_operation->depth_front;
+ float depth_back = trim_operation->depth_back;
- float *view_origin = sgcontext->true_view_origin;
- float *view_normal = sgcontext->true_view_normal;
+ if (!trim_operation->use_cursor_depth) {
+ /* When using cursor depth, don't modify the depth set by the cursor radius. If full depth is
+ * used, adding a little padding to the trimming shape can help avoiding booleans with coplanar
+ * faces. */
+ depth_front -= 0.1f;
+ depth_back += 0.1f;
+ }
- /* Write vertices coordinates for the front face. */
+ /* Use the view origin and normal in world space. The trimming mesh coordinates are calculated in
+ * world space, aligned to the view, and then converted to object space to store them in the
+ * final trimming mesh which is going to be used in the boolean operation.
+ */
+ const float *view_origin = sgcontext->world_space_view_origin;
+ const float *view_normal = sgcontext->world_space_view_normal;
+ const float(*ob_imat)[4] = vc->obact->imat;
+
+ /* Write vertices coordinates for the front face. */
float depth_point[3];
madd_v3_v3v3fl(depth_point, view_origin, view_normal, depth_front);
for (int i = 0; i < tot_screen_points; i++) {
float new_point[3];
ED_view3d_win_to_3d(vc->v3d, region, depth_point, screen_points[i], new_point);
- copy_v3_v3(trim_operation->mesh->mvert[i].co, new_point);
- copy_v3_v3(trim_operation->true_mesh_co[i], new_point);
+ mul_v3_m4v3(trim_operation->mesh->mvert[i].co, ob_imat, new_point);
+ mul_v3_m4v3(trim_operation->true_mesh_co[i], ob_imat, new_point);
}
/* Write vertices coordinates for the back face. */
@@ -946,8 +1001,8 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
for (int i = 0; i < tot_screen_points; i++) {
float new_point[3];
ED_view3d_win_to_3d(vc->v3d, region, depth_point, screen_points[i], new_point);
- copy_v3_v3(trim_operation->mesh->mvert[i + tot_screen_points].co, new_point);
- copy_v3_v3(trim_operation->true_mesh_co[i + tot_screen_points], new_point);
+ mul_v3_m4v3(trim_operation->mesh->mvert[i + tot_screen_points].co, ob_imat, new_point);
+ mul_v3_m4v3(trim_operation->true_mesh_co[i + tot_screen_points], ob_imat, new_point);
}
/* Get the triangulation for the front/back poly. */
@@ -1024,7 +1079,6 @@ static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
{
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)sgcontext->operation;
- Object *object = sgcontext->vc.obact;
Mesh *sculpt_mesh = BKE_mesh_from_object(sgcontext->vc.obact);
Mesh *trim_mesh = trim_operation->mesh;
@@ -1055,29 +1109,10 @@ static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
BMIter iter;
int i;
- const int i_verts_end = trim_mesh->totvert;
const int i_faces_end = trim_mesh->totpoly;
- float imat[4][4];
- float omat[4][4];
-
- invert_m4_m4(imat, object->obmat);
- mul_m4_m4m4(omat, imat, object->obmat);
-
- BMVert *eve;
- i = 0;
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- mul_m4_v3(omat, eve->co);
- if (++i == i_verts_end) {
- break;
- }
- }
-
/* We need face normals because of 'BM_face_split_edgenet'
* we could calculate on the fly too (before calling split). */
- float nmat[3][3];
- copy_m3_m4(nmat, omat);
- invert_m3(nmat);
const short ob_src_totcol = trim_mesh->totcol;
short *material_remap = BLI_array_alloca(material_remap, ob_src_totcol ? ob_src_totcol : 1);
@@ -1085,7 +1120,6 @@ static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
BMFace *efa;
i = 0;
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- mul_transposed_m3_v3(nmat, efa->no);
normalize_v3(efa->no);
/* Temp tag to test which side split faces are from. */
@@ -1132,7 +1166,7 @@ static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
static void sculpt_gesture_trim_begin(bContext *C, SculptGestureContext *sgcontext)
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- sculpt_gesture_trim_calculate_depth(sgcontext);
+ sculpt_gesture_trim_calculate_depth(C, sgcontext);
sculpt_gesture_trim_geometry_generate(sgcontext);
BKE_sculpt_update_object_for_edit(depsgraph, sgcontext->vc.obact, true, false, false);
SCULPT_undo_push_node(sgcontext->vc.obact, NULL, SCULPT_UNDO_GEOMETRY);
@@ -1180,6 +1214,7 @@ static void sculpt_gesture_init_trim_properties(SculptGestureContext *sgcontext,
trim_operation->op.sculpt_gesture_end = sculpt_gesture_trim_end;
trim_operation->mode = RNA_enum_get(op->ptr, "trim_mode");
+ trim_operation->use_cursor_depth = RNA_boolean_get(op->ptr, "use_cursor_depth");
}
static void sculpt_trim_gesture_operator_properties(wmOperatorType *ot)
@@ -1190,6 +1225,12 @@ static void sculpt_trim_gesture_operator_properties(wmOperatorType *ot)
SCULPT_GESTURE_TRIM_DIFFERENCE,
"Trim Mode",
NULL);
+ RNA_def_boolean(
+ ot->srna,
+ "use_cursor_depth",
+ false,
+ "Use Cursor for Depth",
+ "Use cursor location and radius for the dimensions and position of the trimming shape");
}
/* Project Gesture Operation. */
@@ -1364,6 +1405,22 @@ static int sculpt_trim_gesture_box_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static int sculpt_trim_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+
+ SculptCursorGeometryInfo sgi;
+ float mouse[2] = {event->mval[0], event->mval[1]};
+ SCULPT_vertex_random_access_ensure(ss);
+ ss->gesture_initial_hit = SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
+ if (ss->gesture_initial_hit) {
+ copy_v3_v3(ss->gesture_initial_location, sgi.location);
+ }
+
+ return WM_gesture_box_invoke(C, op, event);
+}
+
static int sculpt_trim_gesture_lasso_exec(bContext *C, wmOperator *op)
{
Object *object = CTX_data_active_object(C);
@@ -1383,6 +1440,22 @@ static int sculpt_trim_gesture_lasso_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static int sculpt_trim_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+
+ SculptCursorGeometryInfo sgi;
+ float mouse[2] = {event->mval[0], event->mval[1]};
+ SCULPT_vertex_random_access_ensure(ss);
+ ss->gesture_initial_hit = SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
+ if (ss->gesture_initial_hit) {
+ copy_v3_v3(ss->gesture_initial_location, sgi.location);
+ }
+
+ return WM_gesture_lasso_invoke(C, op, event);
+}
+
static int project_gesture_line_exec(bContext *C, wmOperator *op)
{
SculptGestureContext *sgcontext = sculpt_gesture_init_from_line(C, op);
@@ -1498,7 +1571,7 @@ void SCULPT_OT_trim_lasso_gesture(wmOperatorType *ot)
ot->idname = "SCULPT_OT_trim_lasso_gesture";
ot->description = "Trims the mesh within the lasso as you move the brush";
- ot->invoke = WM_gesture_lasso_invoke;
+ ot->invoke = sculpt_trim_gesture_lasso_invoke;
ot->modal = WM_gesture_lasso_modal;
ot->exec = sculpt_trim_gesture_lasso_exec;
@@ -1519,7 +1592,7 @@ void SCULPT_OT_trim_box_gesture(wmOperatorType *ot)
ot->idname = "SCULPT_OT_trim_box_gesture";
ot->description = "Trims the mesh within the box as you move the brush";
- ot->invoke = WM_gesture_box_invoke;
+ ot->invoke = sculpt_trim_gesture_box_invoke;
ot->modal = WM_gesture_box_modal;
ot->exec = sculpt_trim_gesture_box_exec;
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 9bf1911aee8..f4586fa130d 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -56,9 +56,8 @@
#include "paint_intern.h"
#include "sculpt_intern.h"
-#include <string.h>
-//#include <stdio.h>
#include <stddef.h>
+#include <string.h>
/* Brush operators */
static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
@@ -144,7 +143,7 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
float scalar = RNA_float_get(op->ptr, "scalar");
if (brush) {
- // pixel radius
+ /* pixel radius */
{
const int old_size = BKE_brush_size_get(scene, brush);
int size = (int)(scalar * old_size);
@@ -161,11 +160,11 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
BKE_brush_size_set(scene, brush, size);
}
- // unprojected radius
+ /* unprojected radius */
{
float unprojected_radius = scalar * BKE_brush_unprojected_radius_get(scene, brush);
- if (unprojected_radius < 0.001f) { // XXX magic number
+ if (unprojected_radius < 0.001f) { /* XXX magic number */
unprojected_radius = 0.001f;
}
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index ac1e5564f20..0da0b191537 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -123,6 +123,10 @@ typedef struct PaintStroke {
float zoom_2d;
int pen_flip;
+ /* Tilt, as read from the event. */
+ float x_tilt;
+ float y_tilt;
+
/* line constraint */
bool constrain_line;
float constrained_pos[2];
@@ -617,9 +621,14 @@ static void paint_brush_stroke_add_step(bContext *C,
RNA_collection_add(op->ptr, "stroke", &itemptr);
RNA_float_set(&itemptr, "size", ups->pixel_radius);
RNA_float_set_array(&itemptr, "location", location);
+ /* Mouse coordinates modified by the stroke type options. */
RNA_float_set_array(&itemptr, "mouse", mouse_out);
+ /* Original mouse coordinates. */
+ RNA_float_set_array(&itemptr, "mouse_event", mouse_in);
RNA_boolean_set(&itemptr, "pen_flip", stroke->pen_flip);
RNA_float_set(&itemptr, "pressure", pressure);
+ RNA_float_set(&itemptr, "x_tilt", stroke->x_tilt);
+ RNA_float_set(&itemptr, "y_tilt", stroke->y_tilt);
stroke->update_step(C, stroke, &itemptr);
@@ -698,8 +707,8 @@ static float paint_space_stroke_spacing(bContext *C,
if (SCULPT_is_cloth_deform_brush(brush)) {
/* The spacing in tools that use the cloth solver should not be affected by the brush radius to
* avoid affecting the simulation update rate when changing the radius of the brush.
- With a value of 100 and the brush default of 10 for spacing, a simulation step runs every 2
- pixels movement of the cursor. */
+ * With a value of 100 and the brush default of 10 for spacing, a simulation step runs every 2
+ * pixels movement of the cursor. */
size_clamp = 100.0f;
}
@@ -1383,6 +1392,12 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
paint_stroke_add_sample(p, stroke, event->mval[0], event->mval[1], pressure);
paint_stroke_sample_average(stroke, &sample_average);
+ /* Tilt. */
+ if (WM_event_is_tablet(event)) {
+ stroke->x_tilt = event->tablet.x_tilt;
+ stroke->y_tilt = event->tablet.y_tilt;
+ }
+
#ifdef WITH_INPUT_NDOF
/* let NDOF motion pass through to the 3D view so we can paint and rotate simultaneously!
* this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke discards it
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 2bc19b625cd..16b5d770fa2 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -544,22 +544,19 @@ bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set)
return true;
}
-static void sculpt_visibility_sync_face_sets_to_vertex(SculptSession *ss, int index)
-{
- SCULPT_vertex_visible_set(ss, index, SCULPT_vertex_any_face_set_visible_get(ss, index));
-}
-
-void SCULPT_visibility_sync_all_face_sets_to_vertices(SculptSession *ss)
+void SCULPT_visibility_sync_all_face_sets_to_vertices(Object *ob)
{
+ SculptSession *ss = ob->sculpt;
+ Mesh *mesh = BKE_object_get_original_mesh(ob);
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);
- }
+ BKE_sculpt_sync_face_sets_visibility_to_base_mesh(mesh);
break;
}
case PBVH_GRIDS: {
- BKE_pbvh_sync_face_sets_to_grids(ss->pbvh);
+ BKE_sculpt_sync_face_sets_visibility_to_base_mesh(mesh);
+ BKE_sculpt_sync_face_sets_visibility_to_grids(mesh, ss->subdiv_ccg);
+ break;
}
case PBVH_BMESH:
break;
@@ -1591,10 +1588,14 @@ void SCULPT_brush_test_init(SculptSession *ss, SculptBrushTest *test)
if (ss->cache) {
copy_v3_v3(test->location, ss->cache->location);
test->mirror_symmetry_pass = ss->cache->mirror_symmetry_pass;
+ test->radial_symmetry_pass = ss->cache->radial_symmetry_pass;
+ copy_m4_m4(test->symm_rot_mat_inv, ss->cache->symm_rot_mat_inv);
}
else {
copy_v3_v3(test->location, ss->cursor_location);
test->mirror_symmetry_pass = 0;
+ test->radial_symmetry_pass = 0;
+ unit_m4(test->symm_rot_mat_inv);
}
/* Just for initialize. */
@@ -1604,8 +1605,6 @@ void SCULPT_brush_test_init(SculptSession *ss, SculptBrushTest *test)
zero_v4(test->plane_view);
zero_v4(test->plane_tool);
- test->mirror_symmetry_pass = ss->cache ? ss->cache->mirror_symmetry_pass : 0;
-
if (RV3D_CLIPPING_ENABLED(v3d, rv3d)) {
test->clip_rv3d = rv3d;
}
@@ -1622,6 +1621,9 @@ BLI_INLINE bool sculpt_brush_test_clipping(const SculptBrushTest *test, const fl
}
float symm_co[3];
flip_v3_v3(symm_co, co, test->mirror_symmetry_pass);
+ if (test->radial_symmetry_pass) {
+ mul_m4_v3(test->symm_rot_mat_inv, symm_co);
+ }
return ED_view3d_clipping_test(rv3d, symm_co, true);
}
@@ -2501,7 +2503,7 @@ float SCULPT_brush_strength_factor(SculptSession *ss,
avg *= 1.0f - mask;
/* Auto-masking. */
- avg *= SCULPT_automasking_factor_get(ss, vertex_index);
+ avg *= SCULPT_automasking_factor_get(cache->automasking, ss, vertex_index);
return avg;
}
@@ -2779,6 +2781,20 @@ static void calc_brush_local_mat(const Brush *brush, Object *ob, float local_mat
invert_m4_m4(local_mat, tmat);
}
+#define SCULPT_TILT_SENSITIVITY 0.7f
+void SCULPT_tilt_apply_to_normal(float r_normal[3], StrokeCache *cache, const float tilt_strength)
+{
+ if (!U.experimental.use_sculpt_tools_tilt) {
+ return;
+ }
+ const float rot_max = M_PI_2 * tilt_strength * SCULPT_TILT_SENSITIVITY;
+ mul_v3_mat3_m4v3(r_normal, cache->vc->obact->obmat, r_normal);
+ rotate_v3_v3v3fl(r_normal, r_normal, cache->vc->rv3d->viewinv[0], cache->y_tilt * rot_max);
+ rotate_v3_v3v3fl(r_normal, r_normal, cache->vc->rv3d->viewinv[1], cache->x_tilt * rot_max);
+ mul_v3_mat3_m4v3(r_normal, cache->vc->obact->imat, r_normal);
+ normalize_v3(r_normal);
+}
+
static void update_brush_local_mat(Sculpt *sd, Object *ob)
{
StrokeCache *cache = ob->sculpt->cache;
@@ -3089,6 +3105,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
/* Offset with as much as possible factored in already. */
mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius);
+ SCULPT_tilt_apply_to_normal(offset, ss->cache, brush->tilt_strength_factor);
mul_v3_v3(offset, ss->cache->scale);
mul_v3_fl(offset, bstrength);
@@ -3166,6 +3183,7 @@ static void do_draw_sharp_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
/* Offset with as much as possible factored in already. */
mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius);
+ SCULPT_tilt_apply_to_normal(offset, ss->cache, brush->tilt_strength_factor);
mul_v3_v3(offset, ss->cache->scale);
mul_v3_fl(offset, bstrength);
@@ -3887,7 +3905,7 @@ static void do_elastic_deform_brush_task_cb_ex(void *__restrict userdata,
mul_v3_fl(final_disp, 1.0f - *vd.mask);
}
- mul_v3_fl(final_disp, SCULPT_automasking_factor_get(ss, vd.index));
+ mul_v3_fl(final_disp, SCULPT_automasking_factor_get(ss->cache->automasking, ss, vd.index));
copy_v3_v3(proxy[vd.i], final_disp);
@@ -4688,6 +4706,8 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
SCULPT_calc_brush_plane(sd, ob, nodes, totnode, area_no, area_co);
+ SCULPT_tilt_apply_to_normal(area_no, ss->cache, brush->tilt_strength_factor);
+
displace = radius * offset;
mul_v3_v3v3(temp, area_no, ss->cache->scale);
@@ -4972,6 +4992,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
float tmat[4][4];
SCULPT_calc_brush_plane(sd, ob, nodes, totnode, area_no_sp, area_co);
+ SCULPT_tilt_apply_to_normal(area_no_sp, ss->cache, brush->tilt_strength_factor);
if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA || (brush->flag & BRUSH_ORIGINAL_NORMAL)) {
SCULPT_calc_area_normal(sd, ob, nodes, totnode, area_no);
@@ -5115,6 +5136,8 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
SCULPT_calc_brush_plane(sd, ob, nodes, totnode, area_no, area_co);
+ SCULPT_tilt_apply_to_normal(area_no, ss->cache, brush->tilt_strength_factor);
+
displace = radius * offset;
mul_v3_v3v3(temp, area_no, ss->cache->scale);
@@ -5208,6 +5231,8 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
SCULPT_calc_brush_plane(sd, ob, nodes, totnode, area_no, area_co);
+ SCULPT_tilt_apply_to_normal(area_no, ss->cache, brush->tilt_strength_factor);
+
displace = -radius * offset;
mul_v3_v3v3(temp, area_no, ss->cache->scale);
@@ -5659,7 +5684,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
SculptSearchSphereData data = {
.ss = ss,
.sd = sd,
- .radius_squared = square_f(ss->cache->initial_radius * (1.0 + brush->cloth_sim_limit)),
+ .radius_squared = square_f(ss->cache->radius * (1.0 + brush->cloth_sim_limit)),
.original = false,
.ignore_fully_ineffective = false,
.center = ss->cache->location,
@@ -5732,7 +5757,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
if (SCULPT_stroke_is_first_brush_step(ss->cache)) {
if (SCULPT_is_automasking_enabled(sd, ss, brush)) {
- SCULPT_automasking_init(sd, ob);
+ ss->cache->automasking = SCULPT_automasking_cache_init(sd, brush, ob);
}
}
@@ -5742,7 +5767,8 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
if (brush->deform_target == BRUSH_DEFORM_TARGET_CLOTH_SIM) {
if (!ss->cache->cloth_sim) {
- ss->cache->cloth_sim = SCULPT_cloth_brush_simulation_create(ss, 1.0f, 0.0f, false, true);
+ ss->cache->cloth_sim = SCULPT_cloth_brush_simulation_create(
+ ss, 1.0f, 0.0f, 0.0f, false, true);
SCULPT_cloth_brush_simulation_init(ss, ss->cache->cloth_sim);
}
SCULPT_cloth_brush_store_simulation_state(ss, ss->cache->cloth_sim);
@@ -6581,6 +6607,7 @@ static void sculpt_update_cache_invariants(
}
copy_v2_v2(cache->mouse, cache->initial_mouse);
+ copy_v2_v2(cache->mouse_event, cache->initial_mouse);
copy_v2_v2(ups->tex_mouse, cache->initial_mouse);
/* Truly temporary data that isn't stored in properties. */
@@ -6708,8 +6735,8 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
const float mouse[2] = {
- cache->mouse[0],
- cache->mouse[1],
+ cache->mouse_event[0],
+ cache->mouse_event[1],
};
int tool = brush->sculpt_tool;
@@ -6920,6 +6947,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
cache->pen_flip = RNA_boolean_get(ptr, "pen_flip");
RNA_float_get_array(ptr, "mouse", cache->mouse);
+ RNA_float_get_array(ptr, "mouse_event", cache->mouse_event);
/* XXX: Use pressure value from first brush step for brushes which don't support strokes (grab,
* thumb). They depends on initial state and brush coord/pressure/etc.
@@ -6929,6 +6957,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
cache->pressure = RNA_float_get(ptr, "pressure");
}
+ cache->x_tilt = RNA_float_get(ptr, "x_tilt");
+ cache->y_tilt = RNA_float_get(ptr, "y_tilt");
+
/* Truly temporary data that isn't stored in properties. */
if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache)) {
if (!BKE_brush_use_locked_size(scene, brush)) {
@@ -7162,7 +7193,7 @@ bool SCULPT_cursor_geometry_info_update(bContext *C,
mat[3][3];
float viewDir[3] = {0.0f, 0.0f, 1.0f};
int totnode;
- bool original = false, hit = false;
+ bool original = false;
ED_view3d_viewcontext_init(C, &vc, depsgraph);
@@ -7227,7 +7258,7 @@ bool SCULPT_cursor_geometry_info_update(bContext *C,
/* Option to return the face normal directly for performance o accuracy reasons. */
if (!use_sampled_normal) {
copy_v3_v3(out->normal, srd.face_normal);
- return hit;
+ return srd.hit;
}
/* Sampled normal calculation. */
@@ -7732,7 +7763,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
}
if (SCULPT_is_automasking_enabled(sd, ss, brush)) {
- SCULPT_automasking_end(ob);
+ SCULPT_automasking_cache_free(ss->cache->automasking);
}
BKE_pbvh_node_color_buffer_free(ss->pbvh);
@@ -8144,6 +8175,9 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
* freed memory. */
BKE_object_free_derived_caches(ob);
+ /* Copy the current mesh visibility to the Face Sets. */
+ BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(me);
+
sculpt_init_session(depsgraph, scene, ob);
/* Mask layer is required. */
@@ -8165,7 +8199,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_SCULPT);
BKE_paint_init(bmain, scene, PAINT_MODE_SCULPT, PAINT_CURSOR_SCULPT);
- paint_cursor_start(paint, SCULPT_poll_view3d);
+ paint_cursor_start(paint, SCULPT_mode_poll_view3d);
/* Check dynamic-topology flag; re-enter dynamic-topology mode when changing modes,
* As long as no data was added that is not supported. */
diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.c b/source/blender/editors/sculpt_paint/sculpt_automasking.c
index 241f1167316..bb68ec56b25 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.c
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.c
@@ -62,16 +62,30 @@
#include <math.h>
#include <stdlib.h>
+AutomaskingCache *SCULPT_automasking_active_cache_get(SculptSession *ss)
+{
+ if (ss->cache) {
+ return ss->cache->automasking;
+ }
+ if (ss->filter_cache) {
+ return ss->filter_cache->automasking;
+ }
+ return NULL;
+}
+
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;
+ if (br) {
+ return br->automasking_flags & mode || sd->automasking_flags & mode;
+ }
+ return 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)) {
+ if (br && SCULPT_stroke_is_dynamic_topology(ss, br)) {
return false;
}
if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_TOPOLOGY)) {
@@ -91,10 +105,13 @@ bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, co
static int sculpt_automasking_mode_effective_bits(const Sculpt *sculpt, const Brush *brush)
{
- return sculpt->automasking_flags | brush->automasking_flags;
+ if (brush) {
+ return sculpt->automasking_flags | brush->automasking_flags;
+ }
+ return sculpt->automasking_flags;
}
-static bool SCULPT_automasking_needs_cache(const Sculpt *sd, const Brush *brush)
+static bool SCULPT_automasking_needs_factors_cache(const Sculpt *sd, const Brush *brush)
{
const int automasking_flags = sculpt_automasking_mode_effective_bits(sd, brush);
@@ -102,39 +119,39 @@ static bool SCULPT_automasking_needs_cache(const Sculpt *sd, const Brush *brush)
return true;
}
if (automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) {
- return brush->automasking_boundary_edges_propagation_steps != 1;
+ return brush && brush->automasking_boundary_edges_propagation_steps != 1;
}
if (automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS) {
- return brush->automasking_boundary_edges_propagation_steps != 1;
+ return brush && brush->automasking_boundary_edges_propagation_steps != 1;
}
return false;
}
-float SCULPT_automasking_factor_get(SculptSession *ss, int vert)
+float SCULPT_automasking_factor_get(AutomaskingCache *automasking, SculptSession *ss, int vert)
{
- if (!ss->cache) {
+ if (!automasking) {
return 1.0f;
}
/* If the cache is initialized with valid info, use the cache. This is used when the
* automasking information can't be computed in real time per vertex and needs to be
* initialized for the whole mesh when the stroke starts. */
- if (ss->cache->automask_factor) {
- return ss->cache->automask_factor[vert];
+ if (automasking->factor) {
+ return automasking->factor[vert];
}
- if (ss->cache->automask_settings.flags & BRUSH_AUTOMASKING_FACE_SETS) {
- if (!SCULPT_vertex_has_face_set(ss, vert, ss->cache->automask_settings.initial_face_set)) {
+ if (automasking->settings.flags & BRUSH_AUTOMASKING_FACE_SETS) {
+ if (!SCULPT_vertex_has_face_set(ss, vert, automasking->settings.initial_face_set)) {
return 0.0f;
}
}
- if (ss->cache->automask_settings.flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) {
+ if (automasking->settings.flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) {
if (SCULPT_vertex_is_boundary(ss, vert)) {
return 0.0f;
}
}
- if (ss->cache->automask_settings.flags & BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS) {
+ if (automasking->settings.flags & BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS) {
if (!SCULPT_vertex_has_unique_face_set(ss, vert)) {
return 0.0f;
}
@@ -143,12 +160,14 @@ float SCULPT_automasking_factor_get(SculptSession *ss, int vert)
return 1.0f;
}
-void SCULPT_automasking_end(Object *ob)
+void SCULPT_automasking_cache_free(AutomaskingCache *automasking)
{
- SculptSession *ss = ob->sculpt;
- if (ss->cache && ss->cache->automask_factor) {
- MEM_freeN(ss->cache->automask_factor);
+ if (!automasking) {
+ return;
}
+
+ MEM_SAFE_FREE(automasking->factor);
+ MEM_SAFE_FREE(automasking);
}
static bool sculpt_automasking_is_constrained_by_radius(Brush *br)
@@ -189,10 +208,6 @@ static float *SCULPT_topology_automasking_init(Sculpt *sd, Object *ob, float *au
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;
@@ -200,19 +215,20 @@ static float *SCULPT_topology_automasking_init(Sculpt *sd, Object *ob, float *au
const int totvert = SCULPT_vertex_count_get(ss);
for (int i = 0; i < totvert; i++) {
- ss->cache->automask_factor[i] = 0.0f;
+ automask_factor[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);
+ const float radius = ss->cache ? ss->cache->radius : FLT_MAX;
+ SCULPT_floodfill_add_active(sd, ob, ss, &flood, radius);
AutomaskFloodFillData fdata = {
.automask_factor = automask_factor,
- .radius = ss->cache->radius,
- .use_radius = sculpt_automasking_is_constrained_by_radius(brush),
+ .radius = radius,
+ .use_radius = ss->cache && sculpt_automasking_is_constrained_by_radius(brush),
.symm = SCULPT_mesh_symmetry_xyz_get(ob),
};
copy_v3_v3(fdata.location, SCULPT_active_vertex_co_get(ss));
@@ -306,58 +322,60 @@ float *SCULPT_boundary_automasking_init(Object *ob,
return automask_factor;
}
-static void SCULPT_stroke_automasking_settings_update(SculptSession *ss, Sculpt *sd, Brush *brush)
+static void SCULPT_automasking_cache_settings_update(AutomaskingCache *automasking,
+ SculptSession *ss,
+ Sculpt *sd,
+ Brush *brush)
{
- BLI_assert(ss->cache);
-
- ss->cache->automask_settings.flags = sculpt_automasking_mode_effective_bits(sd, brush);
- ss->cache->automask_settings.initial_face_set = SCULPT_active_face_set_get(ss);
+ automasking->settings.flags = sculpt_automasking_mode_effective_bits(sd, brush);
+ automasking->settings.initial_face_set = SCULPT_active_face_set_get(ss);
}
-void SCULPT_automasking_init(Sculpt *sd, Object *ob)
+AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, 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;
+ return NULL;
}
- SCULPT_stroke_automasking_settings_update(ss, sd, brush);
+ AutomaskingCache *automasking = MEM_callocN(sizeof(AutomaskingCache), "automasking cache");
+ SCULPT_automasking_cache_settings_update(automasking, ss, sd, brush);
SCULPT_boundary_info_ensure(ob);
- if (!SCULPT_automasking_needs_cache(sd, brush)) {
- return;
+ if (!SCULPT_automasking_needs_factors_cache(sd, brush)) {
+ return automasking;
}
- ss->cache->automask_factor = MEM_malloc_arrayN(totvert, sizeof(float), "automask_factor");
-
+ automasking->factor = MEM_malloc_arrayN(totvert, sizeof(float), "automask_factor");
for (int i = 0; i < totvert; i++) {
- ss->cache->automask_factor[i] = 1.0f;
+ automasking->factor[i] = 1.0f;
}
+ const int boundary_propagation_steps = brush ?
+ brush->automasking_boundary_edges_propagation_steps :
+ 1;
+
if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_TOPOLOGY)) {
SCULPT_vertex_random_access_ensure(ss);
- SCULPT_topology_automasking_init(sd, ob, ss->cache->automask_factor);
+ SCULPT_topology_automasking_init(sd, ob, automasking->factor);
}
if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_FACE_SETS)) {
SCULPT_vertex_random_access_ensure(ss);
- sculpt_face_sets_automasking_init(sd, ob, ss->cache->automask_factor);
+ sculpt_face_sets_automasking_init(sd, ob, automasking->factor);
}
if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_BOUNDARY_EDGES)) {
SCULPT_vertex_random_access_ensure(ss);
- SCULPT_boundary_automasking_init(ob,
- AUTOMASK_INIT_BOUNDARY_EDGES,
- brush->automasking_boundary_edges_propagation_steps,
- ss->cache->automask_factor);
+ SCULPT_boundary_automasking_init(
+ ob, AUTOMASK_INIT_BOUNDARY_EDGES, boundary_propagation_steps, automasking->factor);
}
if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS)) {
SCULPT_vertex_random_access_ensure(ss);
- SCULPT_boundary_automasking_init(ob,
- AUTOMASK_INIT_BOUNDARY_FACE_SETS,
- brush->automasking_boundary_edges_propagation_steps,
- ss->cache->automask_factor);
+ SCULPT_boundary_automasking_init(
+ ob, AUTOMASK_INIT_BOUNDARY_FACE_SETS, boundary_propagation_steps, automasking->factor);
}
+
+ return automasking;
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index 2bca5e2e1f0..591168fd3a2 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -157,6 +157,7 @@ static float cloth_brush_simulation_falloff_get(const Brush *brush,
#define CLOTH_SIMULATION_TIME_STEP 0.01f
#define CLOTH_DEFORMATION_SNAKEHOOK_STRENGTH 0.35f
#define CLOTH_DEFORMATION_TARGET_STRENGTH 0.01f
+#define CLOTH_DEFORMATION_GRAB_STRENGTH 0.1f
static bool cloth_brush_sim_has_length_constraint(SculptClothSimulation *cloth_sim,
const int v1,
@@ -229,7 +230,7 @@ static void cloth_brush_add_softbody_constraint(SculptClothSimulation *cloth_sim
length_constraint->node = node_index;
length_constraint->elem_position_a = cloth_sim->pos[v];
- length_constraint->elem_position_b = cloth_sim->init_pos[v];
+ length_constraint->elem_position_b = cloth_sim->softbody_pos[v];
length_constraint->type = SCULPT_CLOTH_CONSTRAINT_SOFTBODY;
@@ -242,6 +243,33 @@ static void cloth_brush_add_softbody_constraint(SculptClothSimulation *cloth_sim
cloth_brush_reallocate_constraints(cloth_sim);
}
+static void cloth_brush_add_pin_constraint(SculptClothSimulation *cloth_sim,
+ const int node_index,
+ const int v,
+ const float strength)
+{
+ SculptClothLengthConstraint *length_constraint =
+ &cloth_sim->length_constraints[cloth_sim->tot_length_constraints];
+
+ length_constraint->elem_index_a = v;
+ length_constraint->elem_index_b = v;
+
+ length_constraint->node = node_index;
+
+ length_constraint->elem_position_a = cloth_sim->pos[v];
+ length_constraint->elem_position_b = cloth_sim->init_pos[v];
+
+ length_constraint->type = SCULPT_CLOTH_CONSTRAINT_PIN;
+
+ length_constraint->length = 0.0f;
+ length_constraint->strength = strength;
+
+ cloth_sim->tot_length_constraints++;
+
+ /* Reallocation if the array capacity is exceeded. */
+ cloth_brush_reallocate_constraints(cloth_sim);
+}
+
static void cloth_brush_add_deformation_constraint(SculptClothSimulation *cloth_sim,
const int node_index,
const int v,
@@ -323,9 +351,8 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
}
SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
- if (brush->cloth_constraint_softbody_strength > 0.0f) {
- cloth_brush_add_softbody_constraint(
- data->cloth_sim, node_index, vd.index, brush->cloth_constraint_softbody_strength);
+ if (data->cloth_sim->softbody_strength > 0.0f) {
+ cloth_brush_add_softbody_constraint(data->cloth_sim, node_index, vd.index, 1.0f);
}
/* As we don't know the order of the neighbor vertices, we create all possible combinations
@@ -355,7 +382,8 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
/* When the grab brush brush is used as part of the cloth brush, deformation constraints
* are created with different strengths and only inside the radius of the brush. */
const float fade = BKE_brush_curve_strength(brush, sqrtf(len_squared), ss->cache->radius);
- cloth_brush_add_deformation_constraint(data->cloth_sim, node_index, vd.index, fade);
+ cloth_brush_add_deformation_constraint(
+ data->cloth_sim, node_index, vd.index, fade * CLOTH_DEFORMATION_GRAB_STRENGTH);
}
else if (brush->cloth_deform_type == BRUSH_CLOTH_DEFORM_SNAKE_HOOK) {
/* Cloth Snake Hook creates deformation constraint with fixed strength because the strength
@@ -379,8 +407,7 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
if (sim_falloff < 1.0f) {
/* Create constraints with more strength the closer the vertex is to the simulation
* boundary. */
- cloth_brush_add_softbody_constraint(
- data->cloth_sim, node_index, vd.index, 1.0f - sim_falloff);
+ cloth_brush_add_pin_constraint(data->cloth_sim, node_index, vd.index, 1.0f - sim_falloff);
}
}
}
@@ -698,6 +725,8 @@ static void do_cloth_brush_solve_simulation_task_cb_ex(
return;
}
+ AutomaskingCache *automasking = SCULPT_automasking_active_cache_get(ss);
+
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
float sim_location[3];
@@ -718,7 +747,7 @@ static void do_cloth_brush_solve_simulation_task_cb_ex(
mul_v3_fl(pos_diff, (1.0f - cloth_sim->damping) * sim_factor);
const float mask_v = (1.0f - (vd.mask ? *vd.mask : 0.0f)) *
- SCULPT_automasking_factor_get(ss, vd.index);
+ SCULPT_automasking_factor_get(automasking, ss, vd.index);
madd_v3_v3fl(cloth_sim->pos[i], pos_diff, mask_v);
madd_v3_v3fl(cloth_sim->pos[i], cloth_sim->acceleration[i], mask_v);
@@ -750,6 +779,9 @@ static void cloth_brush_satisfy_constraints(SculptSession *ss,
Brush *brush,
SculptClothSimulation *cloth_sim)
{
+
+ AutomaskingCache *automasking = SCULPT_automasking_active_cache_get(ss);
+
for (int constraint_it = 0; constraint_it < CLOTH_SIMULATION_ITERATIONS; constraint_it++) {
for (int i = 0; i < cloth_sim->tot_length_constraints; i++) {
const SculptClothLengthConstraint *constraint = &cloth_sim->length_constraints[i];
@@ -782,9 +814,9 @@ static void cloth_brush_satisfy_constraints(SculptSession *ss,
mul_v3_v3fl(correction_vector_half, correction_vector, 0.5f);
const float mask_v1 = (1.0f - SCULPT_vertex_mask_get(ss, v1)) *
- SCULPT_automasking_factor_get(ss, v1);
+ SCULPT_automasking_factor_get(automasking, ss, v1);
const float mask_v2 = (1.0f - SCULPT_vertex_mask_get(ss, v2)) *
- SCULPT_automasking_factor_get(ss, v2);
+ SCULPT_automasking_factor_get(automasking, ss, v2);
float sim_location[3];
cloth_brush_simulation_location_get(ss, brush, sim_location);
@@ -809,14 +841,26 @@ static void cloth_brush_satisfy_constraints(SculptSession *ss,
0.5f;
}
- madd_v3_v3fl(cloth_sim->pos[v1],
- correction_vector_half,
- 1.0f * mask_v1 * sim_factor_v1 * constraint->strength * deformation_strength);
- if (v1 != v2) {
- madd_v3_v3fl(cloth_sim->pos[v2],
+ if (constraint->type == SCULPT_CLOTH_CONSTRAINT_SOFTBODY) {
+ const float softbody_plasticity = brush ? brush->cloth_constraint_softbody_strength : 0.0f;
+ madd_v3_v3fl(cloth_sim->pos[v1],
correction_vector_half,
- -1.0f * mask_v2 * sim_factor_v2 * constraint->strength *
- deformation_strength);
+ 1.0f * mask_v1 * sim_factor_v1 * constraint->strength * softbody_plasticity);
+ madd_v3_v3fl(cloth_sim->softbody_pos[v1],
+ correction_vector_half,
+ -1.0f * mask_v1 * sim_factor_v1 * constraint->strength *
+ (1.0f - softbody_plasticity));
+ }
+ else {
+ madd_v3_v3fl(cloth_sim->pos[v1],
+ correction_vector_half,
+ 1.0f * mask_v1 * sim_factor_v1 * constraint->strength * deformation_strength);
+ if (v1 != v2) {
+ madd_v3_v3fl(cloth_sim->pos[v2],
+ correction_vector_half,
+ -1.0f * mask_v2 * sim_factor_v2 * constraint->strength *
+ deformation_strength);
+ }
}
}
}
@@ -954,6 +998,7 @@ static void cloth_sim_initialize_default_node_state(SculptSession *ss,
SculptClothSimulation *SCULPT_cloth_brush_simulation_create(SculptSession *ss,
const float cloth_mass,
const float cloth_damping,
+ const float cloth_softbody_strength,
const bool use_collisions,
const bool needs_deform_coords)
{
@@ -984,8 +1029,14 @@ SculptClothSimulation *SCULPT_cloth_brush_simulation_create(SculptSession *ss,
totverts, sizeof(float), "cloth sim deformation strength");
}
+ if (cloth_softbody_strength > 0.0f) {
+ cloth_sim->softbody_pos = MEM_calloc_arrayN(
+ totverts, sizeof(float[3]), "cloth sim softbody pos");
+ }
+
cloth_sim->mass = cloth_mass;
cloth_sim->damping = cloth_damping;
+ cloth_sim->softbody_strength = cloth_softbody_strength;
if (use_collisions) {
cloth_sim->collider_list = cloth_brush_collider_cache_create(ss->depsgraph);
@@ -1037,6 +1088,7 @@ void SCULPT_cloth_brush_simulation_init(SculptSession *ss, SculptClothSimulation
{
const int totverts = SCULPT_vertex_count_get(ss);
const bool has_deformation_pos = cloth_sim->deformation_pos != NULL;
+ const bool has_softbody_pos = cloth_sim->softbody_pos != NULL;
for (int i = 0; i < totverts; i++) {
copy_v3_v3(cloth_sim->last_iteration_pos[i], SCULPT_vertex_co_get(ss, i));
copy_v3_v3(cloth_sim->init_pos[i], SCULPT_vertex_co_get(ss, i));
@@ -1045,6 +1097,9 @@ void SCULPT_cloth_brush_simulation_init(SculptSession *ss, SculptClothSimulation
copy_v3_v3(cloth_sim->deformation_pos[i], SCULPT_vertex_co_get(ss, i));
cloth_sim->deformation_strength[i] = 1.0f;
}
+ if (has_softbody_pos) {
+ copy_v3_v3(cloth_sim->softbody_pos[i], SCULPT_vertex_co_get(ss, i));
+ }
}
}
@@ -1086,6 +1141,7 @@ void SCULPT_do_cloth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
ss,
brush->cloth_mass,
brush->cloth_damping,
+ brush->cloth_constraint_softbody_strength,
(brush->flag2 & BRUSH_CLOTH_USE_COLLISION),
SCULPT_is_cloth_deform_brush(brush));
SCULPT_cloth_brush_simulation_init(ss, ss->cache->cloth_sim);
@@ -1121,6 +1177,7 @@ void SCULPT_cloth_simulation_free(struct SculptClothSimulation *cloth_sim)
MEM_SAFE_FREE(cloth_sim->length_constraints);
MEM_SAFE_FREE(cloth_sim->length_constraint_tweak);
MEM_SAFE_FREE(cloth_sim->deformation_pos);
+ MEM_SAFE_FREE(cloth_sim->softbody_pos);
MEM_SAFE_FREE(cloth_sim->init_pos);
MEM_SAFE_FREE(cloth_sim->deformation_strength);
MEM_SAFE_FREE(cloth_sim->node_state);
@@ -1304,6 +1361,7 @@ static void cloth_filter_apply_forces_task_cb(void *__restrict userdata,
BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
{
float fade = vd.mask ? *vd.mask : 0.0f;
+ fade *= SCULPT_automasking_factor_get(ss->filter_cache->automasking, ss, vd.index);
fade = 1.0f - fade;
float force[3] = {0.0f, 0.0f, 0.0f};
float disp[3], temp[3], transform[3][3];
@@ -1448,6 +1506,8 @@ static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent
SCULPT_undo_push_begin("Cloth filter");
SCULPT_filter_cache_init(C, ob, sd, SCULPT_UNDO_COORDS);
+ ss->filter_cache->automasking = SCULPT_automasking_cache_init(sd, NULL, ob);
+
const float cloth_mass = RNA_float_get(op->ptr, "cloth_mass");
const float cloth_damping = RNA_float_get(op->ptr, "cloth_damping");
const bool use_collisions = RNA_boolean_get(op->ptr, "use_collisions");
@@ -1455,6 +1515,7 @@ static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent
ss,
cloth_mass,
cloth_damping,
+ 0.0f,
use_collisions,
cloth_filter_is_deformation_filter(filter_type));
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c
index dae4b068e93..152d23dfa5b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c
@@ -720,7 +720,7 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op)
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);
+ SCULPT_visibility_sync_all_face_sets_to_vertices(ob);
for (int i = 0; i < totnode; i++) {
BKE_pbvh_node_mark_update_visibility(nodes[i]);
@@ -889,12 +889,6 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op)
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) {
@@ -918,7 +912,7 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op)
}
/* Sync face sets visibility and vertex visibility. */
- SCULPT_visibility_sync_all_face_sets_to_vertices(ss);
+ SCULPT_visibility_sync_all_face_sets_to_vertices(ob);
SCULPT_undo_push_end();
@@ -930,10 +924,6 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op)
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);
@@ -1194,7 +1184,7 @@ static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEven
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);
+ SCULPT_visibility_sync_all_face_sets_to_vertices(ob);
for (int i = 0; i < totnode; i++) {
BKE_pbvh_node_mark_update_visibility(nodes[i]);
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.c b/source/blender/editors/sculpt_paint/sculpt_filter_color.c
index 89af836d095..07986bbb032 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_color.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.c
@@ -119,6 +119,10 @@ static void color_filter_task_cb(void *__restrict userdata,
float fade = vd.mask ? *vd.mask : 0.0f;
fade = 1.0f - fade;
fade *= data->filter_strength;
+ fade *= SCULPT_automasking_factor_get(ss->filter_cache->automasking, ss, vd.index);
+ if (fade == 0.0f) {
+ continue;
+ }
copy_v3_v3(orig_color, orig_data.col);
@@ -255,7 +259,7 @@ static int sculpt_color_filter_modal(bContext *C, wmOperator *op, const wmEvent
return OPERATOR_RUNNING_MODAL;
}
-static int sculpt_color_filter_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+static int sculpt_color_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Object *ob = CTX_data_active_object(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
@@ -263,6 +267,17 @@ static int sculpt_color_filter_invoke(bContext *C, wmOperator *op, const wmEvent
int mode = RNA_enum_get(op->ptr, "type");
PBVH *pbvh = ob->sculpt->pbvh;
+ const bool use_automasking = SCULPT_is_automasking_enabled(sd, ss, NULL);
+ if (use_automasking) {
+ /* Update the active face set manually as the paint cursor is not enabled when using the Mesh
+ * Filter Tool. */
+ float mouse[2];
+ SculptCursorGeometryInfo sgi;
+ mouse[0] = event->mval[0];
+ mouse[1] = event->mval[1];
+ SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
+ }
+
/* Disable for multires and dyntopo for now */
if (!ss->pbvh) {
return OPERATOR_CANCELLED;
@@ -282,14 +297,17 @@ static int sculpt_color_filter_invoke(bContext *C, wmOperator *op, const wmEvent
/* CTX_data_ensure_evaluated_depsgraph should be used at the end to include the updates of
* earlier steps modifying the data. */
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- bool needs_pmap = mode == COLOR_FILTER_SMOOTH;
- BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false, true);
+ const bool needs_topology_info = mode == COLOR_FILTER_SMOOTH || use_automasking;
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_topology_info, false, true);
- if (BKE_pbvh_type(pbvh) == PBVH_FACES && needs_pmap && !ob->sculpt->pmap) {
+ if (BKE_pbvh_type(pbvh) == PBVH_FACES && needs_topology_info && !ob->sculpt->pmap) {
return OPERATOR_CANCELLED;
}
SCULPT_filter_cache_init(C, ob, sd, SCULPT_UNDO_COLOR);
+ FilterCache *filter_cache = ss->filter_cache;
+ filter_cache->active_face_set = SCULPT_FACE_SET_NONE;
+ filter_cache->automasking = SCULPT_automasking_cache_init(sd, NULL, ob);
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index c2e90638994..349e492a496 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -179,12 +179,14 @@ void SCULPT_filter_cache_free(SculptSession *ss)
if (ss->filter_cache->cloth_sim) {
SCULPT_cloth_simulation_free(ss->filter_cache->cloth_sim);
}
+ if (ss->filter_cache->automasking) {
+ SCULPT_automasking_cache_free(ss->filter_cache->automasking);
+ }
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->sharpen_factor);
MEM_SAFE_FREE(ss->filter_cache->detail_directions);
@@ -269,15 +271,15 @@ static EnumPropertyItem prop_mesh_filter_orientation_items[] = {
{0, NULL, 0, NULL, NULL},
};
-static bool sculpt_mesh_filter_needs_pmap(eSculptMeshFilterType filter_type, bool use_face_sets)
+static bool sculpt_mesh_filter_needs_pmap(eSculptMeshFilterType filter_type)
{
- return use_face_sets || ELEM(filter_type,
- MESH_FILTER_SMOOTH,
- MESH_FILTER_RELAX,
- MESH_FILTER_RELAX_FACE_SETS,
- MESH_FILTER_SURFACE_SMOOTH,
- MESH_FILTER_ENHANCE_DETAILS,
- MESH_FILTER_SHARPEN);
+ return ELEM(filter_type,
+ MESH_FILTER_SMOOTH,
+ MESH_FILTER_RELAX,
+ MESH_FILTER_RELAX_FACE_SETS,
+ MESH_FILTER_SURFACE_SMOOTH,
+ MESH_FILTER_ENHANCE_DETAILS,
+ MESH_FILTER_SHARPEN);
}
static void mesh_filter_task_cb(void *__restrict userdata,
@@ -307,33 +309,16 @@ static void mesh_filter_task_cb(void *__restrict userdata,
float fade = vd.mask ? *vd.mask : 0.0f;
fade = 1.0f - fade;
fade *= data->filter_strength;
+ fade *= SCULPT_automasking_factor_get(ss->filter_cache->automasking, ss, vd.index);
- if (fade == 0.0f) {
+ if (fade == 0.0f && filter_type != MESH_FILTER_SURFACE_SMOOTH) {
+ /* Surface Smooth can't skip the loop for this vertex as it needs to calculate its
+ * laplacian_disp. This value is accessed from the vertex neighbors when deforming the
+ * vertices, so it is needed for all vertices even if they are not going to be displaced.
+ */
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)) {
- /* Surface Smooth can't skip the loop for this vertex as it needs to calculate its
- * laplacian_disp. This value is accessed from the vertex neighbors when deforming the
- * vertices, so it is needed for all vertices even if they are not going to be displaced.
- */
- if (filter_type == MESH_FILTER_SURFACE_SMOOTH) {
- fade = 0.0f;
- }
- else {
- 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);
}
@@ -606,16 +591,11 @@ static void mesh_filter_surface_smooth_displace_task_cb(
float fade = vd.mask ? *vd.mask : 0.0f;
fade = 1.0f - fade;
fade *= data->filter_strength;
+ fade *= SCULPT_automasking_factor_get(ss->filter_cache->automasking, ss, vd.index);
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;
- }
- }
-
SCULPT_surface_smooth_displace_step(ss,
vd.co,
ss->filter_cache->surface_smooth_laplacian_disp,
@@ -634,7 +614,6 @@ static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
eSculptMeshFilterType 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);
@@ -652,7 +631,7 @@ static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *
SCULPT_vertex_random_access_ensure(ss);
- bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets);
+ bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type);
BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false, false);
SculptThreadedTaskData data = {
@@ -700,15 +679,15 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent
const eMeshFilterDeformAxis deform_axis = RNA_enum_get(op->ptr, "deform_axis");
const eSculptMeshFilterType filter_type = RNA_enum_get(op->ptr, "type");
- const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets");
- const bool needs_topology_info = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets);
+ const bool use_automasking = SCULPT_is_automasking_enabled(sd, ss, NULL);
+ const bool needs_topology_info = sculpt_mesh_filter_needs_pmap(filter_type) || use_automasking;
if (deform_axis == 0) {
/* All axis are disabled, so the filter is not going to produce any deformation. */
return OPERATOR_CANCELLED;
}
- if (use_face_sets) {
+ if (use_automasking) {
/* Update the active face set manually as the paint cursor is not enabled when using the Mesh
* Filter Tool. */
float mouse[2];
@@ -729,8 +708,8 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent
SCULPT_filter_cache_init(C, ob, sd, SCULPT_UNDO_COORDS);
FilterCache *filter_cache = ss->filter_cache;
- filter_cache->active_face_set = use_face_sets ? SCULPT_active_face_set_get(ss) :
- SCULPT_FACE_SET_NONE;
+ filter_cache->active_face_set = SCULPT_FACE_SET_NONE;
+ filter_cache->automasking = SCULPT_automasking_cache_init(sd, NULL, ob);
switch (filter_type) {
case MESH_FILTER_SURFACE_SMOOTH: {
@@ -808,11 +787,6 @@ void SCULPT_OT_mesh_filter(struct wmOperatorType *ot)
SCULPT_FILTER_ORIENTATION_LOCAL,
"Orientation",
"Orientation of the axis to limit the filter displacement");
- 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,
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index e6710e27115..6055f4e4c8b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -36,6 +36,7 @@
#include "BKE_paint.h"
#include "BKE_pbvh.h"
+struct AutomaskingCache;
struct KeyBlock;
struct Object;
struct SculptPoseIKChainSegment;
@@ -185,7 +186,7 @@ bool SCULPT_vertex_is_boundary(const SculptSession *ss, const int index);
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_face_sets_to_vertices(struct Object *ob);
void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss);
/* Face Sets API */
@@ -328,11 +329,17 @@ 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);
+/* Auto-masking. */
+float SCULPT_automasking_factor_get(struct AutomaskingCache *automasking,
+ SculptSession *ss,
+ int vert);
-void SCULPT_automasking_init(Sculpt *sd, Object *ob);
-void SCULPT_automasking_end(Object *ob);
+/* Returns the automasking cache depending on the active tool. Used for code that can run both for
+ * brushes and filter. */
+struct AutomaskingCache *SCULPT_automasking_active_cache_get(SculptSession *ss);
+
+struct AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, Object *ob);
+void SCULPT_automasking_cache_free(struct AutomaskingCache *automasking);
bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd,
const Brush *br,
@@ -365,11 +372,13 @@ void SCULPT_do_cloth_brush(struct Sculpt *sd,
void SCULPT_cloth_simulation_free(struct SculptClothSimulation *cloth_sim);
-struct SculptClothSimulation *SCULPT_cloth_brush_simulation_create(struct SculptSession *ss,
- const float cloth_mass,
- const float cloth_damping,
- const bool use_collisions,
- const bool needs_deform_coords);
+struct SculptClothSimulation *SCULPT_cloth_brush_simulation_create(
+ struct SculptSession *ss,
+ const float cloth_mass,
+ const float cloth_damping,
+ const float cloth_softbody_strength,
+ const bool use_collisions,
+ const bool needs_deform_coords);
void SCULPT_cloth_brush_simulation_init(struct SculptSession *ss,
struct SculptClothSimulation *cloth_sim);
@@ -413,7 +422,7 @@ BLI_INLINE bool SCULPT_is_cloth_deform_brush(const Brush *brush)
BRUSH_CLOTH_DEFORM_GRAB,
BRUSH_CLOTH_DEFORM_SNAKE_HOOK)) ||
/* All brushes that are not the cloth brush deform the simulation using softbody
- constriants instead of applying forces. */
+ * constraints instead of applying forces. */
(brush->sculpt_tool != SCULPT_TOOL_CLOTH &&
brush->deform_target == BRUSH_DEFORM_TARGET_CLOTH_SIM);
}
@@ -735,6 +744,9 @@ typedef struct SculptBrushTest {
float dist;
int mirror_symmetry_pass;
+ int radial_symmetry_pass;
+ float symm_rot_mat_inv[4][4];
+
/* For circle (not sphere) projection. */
float plane_view[4];
@@ -794,6 +806,11 @@ float SCULPT_brush_strength_factor(struct SculptSession *ss,
const int vertex_index,
const int thread_id);
+/* Tilts a normal by the x and y tilt values using the view axis. */
+void SCULPT_tilt_apply_to_normal(float r_normal[3],
+ struct StrokeCache *cache,
+ const float tilt_strength);
+
/* just for vertex paint. */
bool SCULPT_pbvh_calc_area_normal(const struct Brush *brush,
Object *ob,
@@ -816,6 +833,13 @@ typedef struct AutomaskingSettings {
int initial_face_set;
} AutomaskingSettings;
+typedef struct AutomaskingCache {
+ AutomaskingSettings settings;
+ /* Precomputed auto-mask factor indexed by vertex, owned by the auto-masking system and
+ * initialized in #SCULPT_automasking_cache_init when needed. */
+ float *factor;
+} AutomaskingCache;
+
typedef struct StrokeCache {
/* Invariants */
float initial_radius;
@@ -844,9 +868,16 @@ typedef struct StrokeCache {
bool pen_flip;
bool invert;
float pressure;
- float mouse[2];
float bstrength;
float normal_weight; /* from brush (with optional override) */
+ float x_tilt;
+ float y_tilt;
+
+ /* Position of the mouse corresponding to the stroke location, modified by the paint_stroke
+ * operator according to the stroke type. */
+ float mouse[2];
+ /* Position of the mouse event in screen space, not modified by the stroke type. */
+ float mouse_event[2];
float (*prev_colors)[4];
@@ -953,11 +984,8 @@ typedef struct StrokeCache {
float true_gravity_direction[3];
float gravity_direction[3];
- /* Automasking. */
- AutomaskingSettings automask_settings;
- /* Precomputed automask factor indexed by vertex, owned by the automasking system and initialized
- * in SCULPT_automasking_init when needed. */
- float *automask_factor;
+ /* Auto-masking. */
+ AutomaskingCache *automasking;
float stroke_local_mat[4][4];
float multiplane_scrape_angle;
@@ -1029,13 +1057,13 @@ typedef struct FilterCache {
float *prev_mask;
float mask_expand_initial_co[3];
- /* Used to prevent undesired results on certain mesh filters. */
- float *automask;
-
int new_face_set;
int *prev_face_set;
int active_face_set;
+
+ /* Auto-masking. */
+ AutomaskingCache *automasking;
} FilterCache;
void SCULPT_cache_calc_brushdata_symm(StrokeCache *cache,
diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
index e403bada316..5a921383ac3 100644
--- a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
@@ -188,8 +188,14 @@ static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent *
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 (SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false)) {
+ /* The cursor is over the mesh, get the update iteration from the updated active vertex. */
+ mask_expand_update_it = ss->filter_cache->mask_update_it[(int)SCULPT_active_vertex_get(ss)];
+ }
+ else {
+ /* When the cursor is outside the mesh, affect the entire connected component. */
+ mask_expand_update_it = ss->filter_cache->mask_update_last_it - 1;
+ }
}
if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) ||
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c
index 000b7afdf55..f0047448a8d 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c
@@ -133,7 +133,9 @@ static void do_paint_brush_task_cb_ex(void *__restrict userdata,
const int thread_id = BLI_task_parallel_thread_id(tls);
float brush_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
- copy_v3_v3(brush_color, BKE_brush_color_get(ss->scene, brush));
+ copy_v3_v3(brush_color,
+ ss->cache->invert ? BKE_brush_secondary_color_get(ss->scene, brush) :
+ BKE_brush_color_get(ss->scene, brush));
IMB_colormanagement_srgb_to_scene_linear_v3(brush_color);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 287e1eb03d1..fa9eb43891c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -55,7 +55,7 @@
#include "BKE_subsurf.h"
#include "BKE_undo_system.h"
-// XXX: Ideally should be no direct call to such low level things.
+/* XXX: Ideally should be no direct call to such low level things. */
#include "BKE_subdiv_eval.h"
#include "DEG_depsgraph.h"
@@ -647,7 +647,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, need_mask, false);
- SCULPT_visibility_sync_all_face_sets_to_vertices(ss);
+ SCULPT_visibility_sync_all_face_sets_to_vertices(ob);
BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility);
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index 9d9918a6daf..e5f6b61a2ae 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -126,7 +126,7 @@ static int sound_open_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-#else // WITH_AUDASPACE
+#else /* WITH_AUDASPACE */
static int sound_open_exec(bContext *UNUSED(C), wmOperator *op)
{
@@ -410,10 +410,10 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, result);
return OPERATOR_CANCELLED;
}
-#else // WITH_AUDASPACE
+#else /* WITH_AUDASPACE */
(void)C;
(void)op;
-#endif // WITH_AUDASPACE
+#endif /* WITH_AUDASPACE */
return OPERATOR_FINISHED;
}
@@ -493,7 +493,7 @@ static bool sound_mixdown_check(bContext *UNUSED(C), wmOperator *op)
return false;
}
-#endif // WITH_AUDASPACE
+#endif /* WITH_AUDASPACE */
static int sound_mixdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
@@ -666,7 +666,7 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
uiDefAutoButsRNA(
layout, &ptr, sound_mixdown_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
}
-#endif // WITH_AUDASPACE
+#endif /* WITH_AUDASPACE */
static void SOUND_OT_mixdown(wmOperatorType *ot)
{
@@ -696,7 +696,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
{0, NULL, 0, NULL, NULL},
};
-#endif // WITH_AUDASPACE
+#endif /* WITH_AUDASPACE */
/* identifiers */
ot->name = "Mixdown";
@@ -743,7 +743,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
0,
"Split channels",
"Each channel will be rendered into a mono file");
-#endif // WITH_AUDASPACE
+#endif /* WITH_AUDASPACE */
}
/* ******************************************************* */
diff --git a/source/blender/editors/space_action/action_buttons.c b/source/blender/editors/space_action/action_buttons.c
index ed49a1ed6d6..5e1c205f1d4 100644
--- a/source/blender/editors/space_action/action_buttons.c
+++ b/source/blender/editors/space_action/action_buttons.c
@@ -54,7 +54,7 @@
#include "UI_interface.h"
#include "UI_resources.h"
-#include "action_intern.h" // own include
+#include "action_intern.h" /* own include */
/* ******************* action editor space & buttons ************** */
@@ -65,7 +65,7 @@ void action_buttons_register(ARegionType *UNUSED(art))
#if 0
PanelType *pt;
- // TODO: AnimData / Actions List
+ /* TODO: AnimData / Actions List */
pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties");
strcpy(pt->idname, "ACTION_PT_properties");
diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c
index d5b185302c1..e20be9c8328 100644
--- a/source/blender/editors/space_action/action_data.c
+++ b/source/blender/editors/space_action/action_data.c
@@ -757,7 +757,7 @@ static void action_layer_switch_strip(
adt->flag |= ADT_NLA_SOLO_TRACK;
nlt->flag |= NLATRACK_SOLO;
- // TODO: Needs rest-pose flushing (when we get reference track)
+ /* TODO: Needs rest-pose flushing (when we get reference track) */
}
}
@@ -851,7 +851,7 @@ static int action_layer_next_exec(bContext *C, wmOperator *op)
/* turn on NLA muting (to keep same effect) */
adt->flag |= ADT_NLA_EVAL_OFF;
- // TODO: Needs rest-pose flushing (when we get reference track)
+ /* TODO: Needs rest-pose flushing (when we get reference track) */
}
}
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 73d272cff4f..e14e78912d7 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -286,7 +286,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
}
/* set notifier that things have changed */
- // XXX err... there's nothing for frame ranges yet, but this should do fine too
+ /* XXX err... there's nothing for frame ranges yet, but this should do fine too */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
return OPERATOR_FINISHED;
@@ -1107,7 +1107,7 @@ void ACTION_OT_clean(wmOperatorType *ot)
ot->description = "Simplify F-Curves by removing closely spaced keyframes";
/* api callbacks */
- // ot->invoke = // XXX we need that number popup for this!
+ // ot->invoke = /* XXX we need that number popup for this! */
ot->exec = actkeys_clean_exec;
ot->poll = ED_operator_action_active;
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index f40b792269b..ab5f1e0ab22 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -132,17 +132,17 @@ static void actkeys_list_element_to_keylist(bAnimContext *ac,
summary_to_keylist(ac, anim_keys, 0);
}
else if (ale->type == ANIMTYPE_GROUP) {
- // TODO: why don't we just give groups key_data too?
+ /* TODO: why don't we just give groups key_data too? */
bActionGroup *agrp = (bActionGroup *)ale->data;
agroup_to_keylist(adt, agrp, anim_keys, 0);
}
else if (ale->type == ANIMTYPE_GPLAYER) {
- // TODO: why don't we just give gplayers key_data too?
+ /* TODO: why don't we just give gplayers key_data too? */
bGPDlayer *gpl = (bGPDlayer *)ale->data;
gpl_to_keylist(ads, gpl, anim_keys);
}
else if (ale->type == ANIMTYPE_MASKLAYER) {
- // TODO: why don't we just give masklayers key_data too?
+ /* TODO: why don't we just give masklayers key_data too? */
MaskLayer *masklay = (MaskLayer *)ale->data;
mask_to_keylist(ads, masklay, anim_keys);
}
@@ -1730,7 +1730,7 @@ static int mouse_action_keys(bAnimContext *ac,
/* highlight channel clicked on */
if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE)) {
/* deselect all other channels first */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
/* Highlight Action-Group or F-Curve? */
if (ale != NULL && ale->data) {
@@ -1750,7 +1750,7 @@ static int mouse_action_keys(bAnimContext *ac,
}
else if (ac->datatype == ANIMCONT_GPENCIL) {
/* deselect all other channels first */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
/* Highlight GPencil Layer */
if (ale != NULL && ale->data != NULL && ale->type == ANIMTYPE_GPLAYER) {
@@ -1768,7 +1768,7 @@ static int mouse_action_keys(bAnimContext *ac,
}
else if (ac->datatype == ANIMCONT_MASK) {
/* deselect all other channels first */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
if (ale != NULL && ale->data != NULL && ale->type == ANIMTYPE_MASKLAYER) {
MaskLayer *masklay = ale->data;
@@ -1877,7 +1877,7 @@ void ACTION_OT_clickselect(wmOperatorType *ot)
"extend",
0,
"Extend Select",
- "Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY
+ "Toggle keyframe selection instead of leaving newly selected keyframes only"); /* SHIFTKEY */
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna,
@@ -1892,7 +1892,7 @@ void ACTION_OT_clickselect(wmOperatorType *ot)
"column",
0,
"Column Select",
- "Select all keyframes that occur on the same frame as the one under the mouse"); // ALTKEY
+ "Select all keyframes that occur on the same frame as the one under the mouse"); /* ALTKEY */
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(
@@ -1900,7 +1900,7 @@ void ACTION_OT_clickselect(wmOperatorType *ot)
"channel",
0,
"Only Channel",
- "Select all the keyframes in the channel under the mouse"); // CTRLKEY + ALTKEY
+ "Select all the keyframes in the channel under the mouse"); /* CTRLKEY + ALTKEY */
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 8f049816941..ff0201f9702 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -801,7 +801,7 @@ static void action_refresh(const bContext *C, ScrArea *area)
}
/* region updates? */
- // XXX re-sizing y-extents of tot should go here?
+ /* XXX re-sizing y-extents of tot should go here? */
}
static void action_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 2a18ffafc6c..b89c8cb2193 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -281,7 +281,7 @@ void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
}
if (has_drawn_something) {
/* This is needed until we get rid of BGL which can change the states we are tracking. */
- GPU_force_state();
+ GPU_bgl_end();
}
}
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index fabccecd533..dcf2e6e74fa 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -64,7 +64,7 @@
#include "WM_api.h"
-#include "buttons_intern.h" // own include
+#include "buttons_intern.h" /* own include */
static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type)
{
@@ -73,11 +73,11 @@ static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, S
if (RNA_struct_is_a(ptr->type, type)) {
CTX_data_pointer_set(result, ptr->owner_id, ptr->type, ptr->data);
- return 1;
+ return CTX_RESULT_OK;
}
}
- return 0;
+ return CTX_RESULT_MEMBER_NOT_FOUND;
}
static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type)
@@ -880,6 +880,10 @@ int /*eContextResult*/ buttons_context(const bContext *C,
ButsContextTexture *ct = sbuts->texuser;
if (ct) {
+ if (ct->texture == NULL) {
+ return CTX_RESULT_NO_DATA;
+ }
+
CTX_data_pointer_set(result, &ct->texture->id, &RNA_Texture, ct->texture);
}
@@ -907,7 +911,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
ButsContextTexture *ct = sbuts->texuser;
if (!ct) {
- return -1;
+ return CTX_RESULT_NO_DATA;
}
if (ct->user && ct->user->ptr.data) {
@@ -921,7 +925,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
ButsContextTexture *ct = sbuts->texuser;
if (!ct) {
- return -1;
+ return CTX_RESULT_NO_DATA;
}
if (ct->user && ct->user->ptr.data) {
@@ -958,7 +962,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
}
}
else if (ct) {
- return 0; /* new shading system */
+ return CTX_RESULT_MEMBER_NOT_FOUND; /* new shading system */
}
else if ((ptr = get_pointer_type(path, &RNA_FreestyleLineStyle))) {
FreestyleLineStyle *ls = ptr->data;
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index a5419fea5ca..0a0846cf216 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -23,6 +23,7 @@
#pragma once
+#include "BLI_bitmap.h"
#include "DNA_listBase.h"
#include "RNA_types.h"
@@ -37,6 +38,16 @@ struct bNodeTree;
struct uiLayout;
struct wmOperatorType;
+struct SpaceProperties_Runtime {
+ /** For filtering properties displayed in the space. */
+ char search_string[UI_MAX_NAME_STR];
+ /**
+ * Bitfield (in the same order as the tabs) for whether each tab has properties
+ * that match the search filter. Only valid when #search_string is set.
+ */
+ BLI_bitmap *tab_search_results;
+};
+
/* context data */
typedef struct ButsContextPath {
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index dc35a0f3658..6f743eb1a6b 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -70,7 +70,7 @@
#include "../interface/interface_intern.h"
-#include "buttons_intern.h" // own include
+#include "buttons_intern.h" /* own include */
/************************* Texture User **************************/
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 8c1030f6fc4..3d470b19c1c 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -26,6 +26,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_bitmap.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
@@ -48,11 +49,14 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
+#include "UI_interface.h"
#include "UI_resources.h"
#include "buttons_intern.h" /* own include */
-/* ******************** default callbacks for buttons space ***************** */
+/* -------------------------------------------------------------------- */
+/** \name Default Callbacks for Properties Space
+ * \{ */
static SpaceLink *buttons_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
@@ -110,7 +114,10 @@ static void buttons_free(SpaceLink *sl)
MEM_freeN(ct);
}
- MEM_SAFE_FREE(sbuts->runtime);
+ if (sbuts->runtime != NULL) {
+ MEM_SAFE_FREE(sbuts->runtime->tab_search_results);
+ MEM_freeN(sbuts->runtime);
+ }
}
/* spacetype; init callback */
@@ -121,6 +128,7 @@ static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *area)
if (sbuts->runtime == NULL) {
sbuts->runtime = MEM_mallocN(sizeof(SpaceProperties_Runtime), __func__);
sbuts->runtime->search_string[0] = '\0';
+ sbuts->runtime->tab_search_results = BLI_BITMAP_NEW(BCONTEXT_TOT * 2, __func__);
}
}
@@ -135,6 +143,7 @@ static SpaceLink *buttons_duplicate(SpaceLink *sl)
if (sfile_old->runtime != NULL) {
sbutsn->runtime = MEM_dupallocN(sfile_old->runtime);
sbutsn->runtime->search_string[0] = '\0';
+ sbutsn->runtime->tab_search_results = BLI_BITMAP_NEW(BCONTEXT_TOT, __func__);
}
return (SpaceLink *)sbutsn;
@@ -151,6 +160,12 @@ static void buttons_main_region_init(wmWindowManager *wm, ARegion *region)
WM_event_add_keymap_handler(&region->handlers, keymap);
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Property Editor Layout
+ * \{ */
+
/**
* Fills an array with the tab context values for the properties editor. -1 signals a separator.
*
@@ -298,6 +313,185 @@ static void buttons_main_region_layout_properties(const bContext *C,
ED_region_panels_layout_ex(C, region, &region->type->paneltypes, contexts, NULL);
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Property Search Access API
+ * \{ */
+
+const char *ED_buttons_search_string_get(SpaceProperties *sbuts)
+{
+ return sbuts->runtime->search_string;
+}
+
+int ED_buttons_search_string_length(struct SpaceProperties *sbuts)
+{
+ return BLI_strnlen(sbuts->runtime->search_string, sizeof(sbuts->runtime->search_string));
+}
+
+void ED_buttons_search_string_set(SpaceProperties *sbuts, const char *value)
+{
+ BLI_strncpy(sbuts->runtime->search_string, value, sizeof(sbuts->runtime->search_string));
+}
+
+bool ED_buttons_tab_has_search_result(SpaceProperties *sbuts, const int index)
+{
+ return BLI_BITMAP_TEST(sbuts->runtime->tab_search_results, index);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name "Off Screen" Layout Generation for Property Search
+ * \{ */
+
+static bool property_search_for_context(const bContext *C, ARegion *region, SpaceProperties *sbuts)
+{
+ const char *contexts[2] = {buttons_main_region_context_string(sbuts->mainb), NULL};
+
+ if (sbuts->mainb == BCONTEXT_TOOL) {
+ return false;
+ }
+
+ buttons_context_compute(C, sbuts);
+ return ED_region_property_search(C, region, &region->type->paneltypes, contexts, NULL);
+}
+
+static void property_search_move_to_next_tab_with_results(SpaceProperties *sbuts,
+ const short *context_tabs_array,
+ const int tabs_len)
+{
+ /* As long as all-tab search in the tool is disabled in the tool context, don't move from it. */
+ if (sbuts->mainb == BCONTEXT_TOOL) {
+ return;
+ }
+
+ int current_tab_index = 0;
+ for (int i = 0; i < tabs_len; i++) {
+ if (sbuts->mainb == context_tabs_array[i]) {
+ current_tab_index = i;
+ break;
+ }
+ }
+
+ /* Try the tabs after the current tab. */
+ for (int i = current_tab_index; i < tabs_len; i++) {
+ if (BLI_BITMAP_TEST(sbuts->runtime->tab_search_results, i)) {
+ sbuts->mainbuser = context_tabs_array[i];
+ return;
+ }
+ }
+
+ /* Try the tabs before the current tab. */
+ for (int i = 0; i < current_tab_index; i++) {
+ if (BLI_BITMAP_TEST(sbuts->runtime->tab_search_results, i)) {
+ sbuts->mainbuser = context_tabs_array[i];
+ return;
+ }
+ }
+}
+
+static void property_search_all_tabs(const bContext *C,
+ SpaceProperties *sbuts,
+ ARegion *region_original,
+ const short *context_tabs_array,
+ const int tabs_len)
+{
+ /* Use local copies of the area and duplicate the region as a mainly-paranoid protection
+ * against changing any of the space / region data while running the search. */
+ ScrArea *area_original = CTX_wm_area(C);
+ ScrArea area_copy = *area_original;
+ ARegion *region_copy = BKE_area_region_copy(area_copy.type, region_original);
+ CTX_wm_area_set((bContext *)C, &area_copy);
+ CTX_wm_region_set((bContext *)C, region_copy);
+
+ SpaceProperties sbuts_copy = *sbuts;
+ sbuts_copy.path = NULL;
+ sbuts_copy.texuser = NULL;
+ sbuts_copy.runtime = MEM_dupallocN(sbuts->runtime);
+ sbuts_copy.runtime->tab_search_results = NULL;
+ BLI_listbase_clear(&area_copy.spacedata);
+ BLI_addtail(&area_copy.spacedata, &sbuts_copy);
+
+ /* Loop through the tabs added to the properties editor. */
+ for (int i = 0; i < tabs_len; i++) {
+ /* -1 corresponds to a spacer. */
+ if (context_tabs_array[i] == -1) {
+ continue;
+ }
+
+ /* Handle search for the current tab in the normal layout pass. */
+ if (context_tabs_array[i] == sbuts->mainb) {
+ continue;
+ }
+
+ sbuts_copy.mainb = sbuts_copy.mainbo = sbuts_copy.mainbuser = context_tabs_array[i];
+
+ /* Actually do the search and store the result in the bitmap. */
+ BLI_BITMAP_SET(sbuts->runtime->tab_search_results,
+ i,
+ property_search_for_context(C, region_copy, &sbuts_copy));
+
+ UI_blocklist_free(C, &region_copy->uiblocks);
+ }
+
+ BKE_area_region_free(area_copy.type, region_copy);
+ MEM_freeN(region_copy);
+ buttons_free((SpaceLink *)&sbuts_copy);
+
+ CTX_wm_area_set((bContext *)C, area_original);
+ CTX_wm_region_set((bContext *)C, region_original);
+}
+
+/**
+ * Handle property search for the layout pass, including finding which tabs have
+ * search results and switching if the current tab doesn't have a result.
+ */
+static void buttons_main_region_property_search(const bContext *C,
+ SpaceProperties *sbuts,
+ ARegion *region)
+{
+ /* Theoretical maximum of every context shown with a spacer between every tab. */
+ short context_tabs_array[BCONTEXT_TOT * 2];
+ int tabs_len = ED_buttons_tabs_list(sbuts, context_tabs_array);
+
+ property_search_all_tabs(C, sbuts, region, context_tabs_array, tabs_len);
+
+ /* Check whether the current tab has a search match. */
+ bool current_tab_has_search_match = false;
+ LISTBASE_FOREACH (Panel *, panel, &region->panels) {
+ if (UI_panel_is_active(panel) && UI_panel_matches_search_filter(panel)) {
+ current_tab_has_search_match = true;
+ }
+ }
+
+ /* Find which index in the list the current tab corresponds to. */
+ int current_tab_index = -1;
+ for (int i = 0; i < tabs_len; i++) {
+ if (context_tabs_array[i] == sbuts->mainb) {
+ current_tab_index = i;
+ }
+ }
+ BLI_assert(current_tab_index != -1);
+
+ /* Update the tab search match flag for the current tab. */
+ BLI_BITMAP_SET(
+ sbuts->runtime->tab_search_results, current_tab_index, current_tab_has_search_match);
+
+ /* Move to the next tab with a result */
+ if (!current_tab_has_search_match) {
+ if (region->flag & RGN_FLAG_SEARCH_FILTER_UPDATE) {
+ property_search_move_to_next_tab_with_results(sbuts, context_tabs_array, tabs_len);
+ }
+ }
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Main Region Layout and Listener
+ * \{ */
+
static void buttons_main_region_layout(const bContext *C, ARegion *region)
{
/* draw entirely, view changes should be handled here */
@@ -310,6 +504,10 @@ static void buttons_main_region_layout(const bContext *C, ARegion *region)
buttons_main_region_layout_properties(C, sbuts, region);
}
+ if (region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE) {
+ buttons_main_region_property_search(C, sbuts, region);
+ }
+
sbuts->mainbo = sbuts->mainb;
}
@@ -344,6 +542,12 @@ static void buttons_keymap(struct wmKeyConfig *keyconf)
WM_keymap_ensure(keyconf, "Property Editor", SPACE_PROPERTIES, 0);
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Header Region Callbacks
+ * \{ */
+
/* add handlers, stuff you only do once or on area/region changes */
static void buttons_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
{
@@ -388,6 +592,12 @@ static void buttons_header_region_message_subscribe(const bContext *UNUSED(C),
}
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Navigation Region Callbacks
+ * \{ */
+
static void buttons_navigation_bar_region_init(wmWindowManager *wm, ARegion *region)
{
region->flag |= RGN_FLAG_PREFSIZE_OR_HIDDEN;
@@ -437,6 +647,12 @@ static void buttons_area_redraw(ScrArea *area, short buttons)
}
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Area-Level Code
+ * \{ */
+
/* reused! */
static void buttons_area_listener(wmWindow *UNUSED(win),
ScrArea *area,
@@ -692,6 +908,12 @@ static void buttons_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id
}
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Space Type Initialization
+ * \{ */
+
/* only called once, from space/spacetypes.c */
void ED_spacetype_buttons(void)
{
@@ -722,8 +944,8 @@ void ED_spacetype_buttons(void)
buttons_context_register(art);
BLI_addhead(&st->regiontypes, art);
- /* Register the panel types from modifiers. The actual panels are built per modifier rather than
- * per modifier type. */
+ /* Register the panel types from modifiers. The actual panels are built per modifier rather
+ * than per modifier type. */
for (ModifierType i = 0; i < NUM_MODIFIER_TYPES; i++) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(i);
if (mti != NULL && mti->panelRegister != NULL) {
@@ -770,3 +992,5 @@ void ED_spacetype_buttons(void)
BKE_spacetype_register(st);
}
+
+/** \} */
diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c
index c3323491085..135b7d1cb6c 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_ops.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c
@@ -43,7 +43,7 @@
#include "UI_view2d.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" /* own include */
static bool space_clip_dopesheet_poll(bContext *C)
{
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 4759075555b..93c30c9a4ba 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -62,7 +62,7 @@
#include "BLF_api.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" /* own include */
/*********************** main area drawing *************************/
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index b2c80faec0b..69b89d25a1a 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -65,7 +65,7 @@
#include "UI_view2d.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" /* own include */
/* ******** operactor poll functions ******** */
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index 4cf3e3e0798..e6fb6d75051 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -45,7 +45,7 @@
#include "UI_resources.h"
#include "UI_view2d.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" /* own include */
typedef struct TrackMotionCurveUserData {
SpaceClip *sc;
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index ffd3241a30f..590f8efe105 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -44,7 +44,7 @@
#include "UI_view2d.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" /* own include */
/******************** common graph-editing utilities ********************/
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 013731a50d6..26fa5b8a06c 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -76,7 +76,7 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" /* own include */
/* -------------------------------------------------------------------- */
/** \name View Navigation Utilities
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index cbf43bb7ff0..c7f2a027ba8 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -50,7 +50,7 @@
#include "UI_resources.h"
#include "UI_view2d.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" /* own include */
bool clip_graph_value_visible(SpaceClip *sc, eClipCurveValueSource value_source)
{
diff --git a/source/blender/editors/space_clip/tracking_ops_track.c b/source/blender/editors/space_clip/tracking_ops_track.c
index afbca48bd45..66669527929 100644
--- a/source/blender/editors/space_clip/tracking_ops_track.c
+++ b/source/blender/editors/space_clip/tracking_ops_track.c
@@ -46,7 +46,7 @@
#include "DEG_depsgraph.h"
-#include "clip_intern.h" // own include
+#include "clip_intern.h" /* own include */
#include "tracking_ops_intern.h"
/********************** Track operator *********************/
@@ -281,7 +281,7 @@ static void track_markers_endjob(void *tmv)
tmj->clip->tracking_context = NULL;
tmj->scene->r.cfra = BKE_movieclip_remap_clip_to_scene_frame(tmj->clip, tmj->lastfra);
if (wm != NULL) {
- // XXX: ...
+ /* XXX */
// ED_update_for_newframe(tmj->main, tmj->scene);
}
diff --git a/source/blender/editors/space_clip/tracking_ops_utils.c b/source/blender/editors/space_clip/tracking_ops_utils.c
index 7579c9a49c6..1f959e94309 100644
--- a/source/blender/editors/space_clip/tracking_ops_utils.c
+++ b/source/blender/editors/space_clip/tracking_ops_utils.c
@@ -33,7 +33,7 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "tracking_ops_intern.h" // own include
+#include "tracking_ops_intern.h" /* own include */
void clip_tracking_clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip)
{
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index f0d4a45a3dd..77f1111624d 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -131,7 +131,7 @@ static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
return true;
}
-#if 0 // XXX unused
+#if 0 /* XXX unused */
static void console_lb_debug__internal(ListBase *lb)
{
ConsoleLine *cl;
@@ -415,7 +415,8 @@ static int console_insert_exec(bContext *C, wmOperator *op)
static int console_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- // if (!RNA_struct_property_is_set(op->ptr, "text")) { /* always set from keymap XXX */
+ /* Note, the "text" property is always set from key-map,
+ * so we can't use #RNA_struct_property_is_set, check the length instead. */
if (!RNA_string_length(op->ptr, "text")) {
/* if alt/ctrl/super are pressed pass through except for utf8 character event
* (when input method are used for utf8 inputs, the user may assign key event
@@ -1108,7 +1109,7 @@ typedef struct SetConsoleCursor {
int sel_init;
} SetConsoleCursor;
-// TODO, cursor placement without selection
+/* TODO, cursor placement without selection */
static void console_cursor_set_to_pos(
SpaceConsole *sc, ARegion *region, SetConsoleCursor *scu, const int mval[2], int UNUSED(sel))
{
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 4b554e0c5c0..a54faa41122 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -42,7 +42,7 @@
#include "UI_view2d.h"
#include "GPU_framebuffer.h"
-#include "console_intern.h" // own include
+#include "console_intern.h" /* own include */
/* ******************** default callbacks for console space ***************** */
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 7039eba7db1..4b277435f63 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -69,7 +69,7 @@
#include "filelist.h"
-#include "file_intern.h" // own include
+#include "file_intern.h" /* own include */
void ED_file_path_button(bScreen *screen,
const SpaceFile *sfile,
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 7ac3c209f2d..7bbf27c1f1e 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1877,7 +1877,7 @@ static int file_next_exec(bContext *C, wmOperator *UNUSED(unused))
folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
folderlist_popdir(sfile->folders_next, sfile->params->dir);
- // update folders_prev so we can check for it in folderlist_clear_next()
+ /* update folders_prev so we can check for it in #folderlist_clear_next() */
folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
ED_file_change_dir(C);
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 48ee87662ea..3004aadb5dd 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -2504,14 +2504,18 @@ static int filelist_readjob_list_dir(const char *root,
/* Set initial file type and attributes. */
entry->attributes = BLI_file_attributes(full_path);
- if (S_ISDIR(files[i].s.st_mode)) {
+ if (S_ISDIR(files[i].s.st_mode)
+#ifdef __APPLE__
+ && !(ED_path_extension_type(full_path) & FILE_TYPE_APPLICATIONBUNDLE)
+#endif
+ ) {
entry->typeflag = FILE_TYPE_DIR;
}
/* Is this a file that points to another file? */
if (entry->attributes & FILE_ATTR_ALIAS) {
entry->redirection_path = MEM_callocN(FILE_MAXDIR, __func__);
- if (BLI_file_alias_target(entry->redirection_path, full_path)) {
+ if (BLI_file_alias_target(full_path, entry->redirection_path)) {
if (BLI_is_dir(entry->redirection_path)) {
entry->typeflag = FILE_TYPE_DIR;
BLI_path_slash_ensure(entry->redirection_path);
@@ -2640,7 +2644,7 @@ static void filelist_readjob_main_recursive(Main *bmain, FileList *filelist)
ListBase *lb;
int a, fake, idcode, ok, totlib, totbl;
- // filelist->type = FILE_MAIN; // XXX TODO: add modes to filebrowser
+ // filelist->type = FILE_MAIN; /* XXX TODO: add modes to filebrowser */
BLI_assert(filelist->filelist.entries == NULL);
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index edc1e83e882..6ffe553e076 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -51,7 +51,7 @@
#include "UI_view2d.h"
#include "GPU_framebuffer.h"
-#include "file_intern.h" // own include
+#include "file_intern.h" /* own include */
#include "filelist.h"
#include "fsmenu.h"
@@ -142,7 +142,7 @@ static void file_free(SpaceLink *sl)
BLI_assert(sfile->previews_timer == NULL);
if (sfile->files) {
- // XXXXX would need to do thumbnails_stop here, but no context available
+ /* XXX would need to do thumbnails_stop here, but no context available */
filelist_freelib(sfile->files);
filelist_free(sfile->files);
MEM_freeN(sfile->files);
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index dde8c23b326..09fe0b0fd16 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -64,7 +64,7 @@
#include "UI_interface.h"
#include "UI_resources.h"
-#include "graph_intern.h" // own include
+#include "graph_intern.h" /* own include */
/* ******************* graph editor space & buttons ************** */
@@ -171,6 +171,7 @@ static void graph_panel_cursor(const bContext *C, Panel *panel)
sub = uiLayoutColumn(col, true);
uiItemO(sub, IFACE_("Cursor to Selection"), ICON_NONE, "GRAPH_OT_frame_jump");
+ uiItemO(sub, IFACE_("Cursor Value to Selection"), ICON_NONE, "GRAPH_OT_snap_cursor_value");
}
/* ******************* active F-Curve ************** */
@@ -654,7 +655,7 @@ static void do_graph_region_driver_buttons(bContext *C, void *id_v, int event)
}
/* default for now */
- WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); // XXX could use better notifier
+ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); /* XXX could use better notifier */
}
/* callback to add a target variable to the active driver */
@@ -1130,7 +1131,7 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
0.0,
0.0,
TIP_("Invalid variable name, click here for details"));
- UI_but_func_set(but, driver_dvar_invalid_name_query_cb, dvar, NULL); // XXX: reports?
+ UI_but_func_set(but, driver_dvar_invalid_name_query_cb, dvar, NULL); /* XXX: reports? */
}
/* 1.3) remove button */
@@ -1336,9 +1337,9 @@ static void graph_fmodifier_panel_id(void *fcm_link, char *r_name)
static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int event)
{
switch (event) {
- case B_FMODIFIER_REDRAW: // XXX this should send depsgraph updates too
+ case B_FMODIFIER_REDRAW: /* XXX this should send depsgraph updates too */
WM_event_add_notifier(
- C, NC_ANIMATION, NULL); // XXX need a notifier specially for F-Modifiers
+ C, NC_ANIMATION, NULL); /* XXX need a notifier specially for F-Modifiers */
break;
}
}
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index c6acc8260b7..d430e331b6c 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -880,7 +880,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
v4[0] = bezt->vec[1][0];
v4[1] = bezt->vec[1][1];
- correct_bezpart(v1, v2, v3, v4);
+ BKE_fcurve_correct_bezpart(v1, v2, v3, v4);
BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float[3]));
BKE_curve_forward_diff_bezier(
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index e99aeb82456..c9b26674351 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -243,7 +243,7 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
scene->r.pefra = round_fl_to_int(max);
/* set notifier that things have changed */
- // XXX err... there's nothing for frame ranges yet, but this should do fine too
+ /* XXX err... there's nothing for frame ranges yet, but this should do fine too */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
return OPERATOR_FINISHED;
@@ -258,7 +258,7 @@ void GRAPH_OT_previewrange_set(wmOperatorType *ot)
/* api callbacks */
ot->exec = graphkeys_previewrange_exec;
- // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier...
+ /* XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier. */
ot->poll = ED_operator_graphedit_active;
/* flags */
@@ -514,7 +514,7 @@ void GRAPH_OT_ghost_curves_create(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- // todo: add props for start/end frames
+ /* TODO: add props for start/end frames */
}
/* ******************** Clear Ghost-Curves Operator *********************** */
@@ -1069,7 +1069,8 @@ void GRAPH_OT_paste(wmOperatorType *ot)
"frame";
/* api callbacks */
- // ot->invoke = WM_operator_props_popup; // better wait for graph redo panel
+
+ // ot->invoke = WM_operator_props_popup; /* better wait for graph redo panel */
ot->exec = graphkeys_paste_exec;
ot->poll = graphop_editable_keyframes_poll;
@@ -1292,7 +1293,7 @@ void GRAPH_OT_clean(wmOperatorType *ot)
ot->description = "Simplify F-Curves by removing closely spaced keyframes";
/* api callbacks */
- // ot->invoke = // XXX we need that number popup for this!
+ // ot->invoke = ???; /* XXX we need that number popup for this! */
ot->exec = graphkeys_clean_exec;
ot->poll = graphop_editable_keyframes_poll;
@@ -1828,7 +1829,7 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op))
}
/* for now, init start/end from preview-range extents */
- // TODO: add properties for this
+ /* TODO: add properties for this */
scene = ac.scene;
start = PSFRA;
end = PEFRA;
@@ -1837,7 +1838,7 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op))
bake_graph_curves(&ac, start, end);
/* set notifier that keyframes have changed */
- // NOTE: some distinction between order/number of keyframes and type should be made?
+ /* NOTE: some distinction between order/number of keyframes and type should be made? */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1851,14 +1852,14 @@ void GRAPH_OT_bake(wmOperatorType *ot)
ot->description = "Bake selected F-Curves to a set of sampled points defining a similar curve";
/* api callbacks */
- ot->invoke = WM_operator_confirm; // FIXME...
+ ot->invoke = WM_operator_confirm; /* FIXME */
ot->exec = graphkeys_bake_exec;
ot->poll = graphop_selected_fcurve_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- // todo: add props for start/end frames
+ /* TODO: add props for start/end frames */
}
#ifdef WITH_AUDASPACE
@@ -1974,7 +1975,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-#else // WITH_AUDASPACE
+#else /* WITH_AUDASPACE */
static int graphkeys_sound_bake_exec(bContext *UNUSED(C), wmOperator *op)
{
@@ -1983,7 +1984,7 @@ static int graphkeys_sound_bake_exec(bContext *UNUSED(C), wmOperator *op)
return OPERATOR_CANCELLED;
}
-#endif // WITH_AUDASPACE
+#endif /* WITH_AUDASPACE */
static int graphkeys_sound_bake_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
@@ -2224,7 +2225,7 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode)
if (mode == MAKE_CYCLIC_EXPO) {
/* only add if one doesn't exist */
if (list_has_suitable_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, -1) == 0) {
- // TODO: add some more preset versions which set different extrapolation options?
+ /* TODO: add some more preset versions which set different extrapolation options? */
add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, fcu);
}
}
@@ -2737,34 +2738,27 @@ static bool graphkeys_framejump_poll(bContext *C)
return graphop_visible_keyframes_poll(C);
}
-/* snap current-frame indicator to 'average time' of selected keyframe */
-static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
+static KeyframeEditData sum_selected_keyframes(bAnimContext *ac)
{
- bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
KeyframeEditData ked;
- /* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0) {
- return OPERATOR_CANCELLED;
- }
-
/* init edit data */
memset(&ked, 0, sizeof(KeyframeEditData));
/* loop over action data, averaging values */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
- ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale = anim_data.first; ale; ale = ale->next) {
- AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
- short mapping_flag = ANIM_get_normalization_flags(&ac);
+ AnimData *adt = ANIM_nla_mapping_get(ac, ale);
+ short mapping_flag = ANIM_get_normalization_flags(ac);
KeyframeEditData current_ked;
float offset;
float unit_scale = ANIM_unit_mapping_get_factor(
- ac.scene, ale->id, ale->key_data, mapping_flag | ANIM_UNITCONV_ONLYKEYS, &offset);
+ ac->scene, ale->id, ale->key_data, mapping_flag | ANIM_UNITCONV_ONLYKEYS, &offset);
memset(&current_ked, 0, sizeof(current_ked));
@@ -2785,24 +2779,43 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_animdata_freelist(&anim_data);
+ return ked;
+}
+
+/* snap current-frame indicator to 'average time' of selected keyframe */
+static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ bAnimContext ac;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
+ return OPERATOR_CANCELLED;
+ }
+
+ const KeyframeEditData keyframe_sum = sum_selected_keyframes(&ac);
+ const float sum_time = keyframe_sum.f1;
+ const float sum_value = keyframe_sum.f2;
+ const int num_keyframes = keyframe_sum.i1;
+
+ if (num_keyframes == 0) {
+ return OPERATOR_FINISHED;
+ }
+
/* set the new current frame and cursor values, based on the average time and value */
- if (ked.i1) {
- SpaceGraph *sipo = (SpaceGraph *)ac.sl;
- Scene *scene = ac.scene;
+ SpaceGraph *sipo = (SpaceGraph *)ac.sl;
+ Scene *scene = ac.scene;
- /* take the average values, rounding to the nearest int as necessary for int results */
- if (sipo->mode == SIPO_MODE_DRIVERS) {
- /* Drivers Mode - Affects cursor (float) */
- sipo->cursorTime = ked.f1 / (float)ked.i1;
- sipo->cursorVal = ked.f2 / (float)ked.i1;
- }
- else {
- /* Animation Mode - Affects current frame (int) */
- CFRA = round_fl_to_int(ked.f1 / ked.i1);
- SUBFRA = 0.f;
- sipo->cursorVal = ked.f2 / (float)ked.i1;
- }
+ /* take the average values, rounding to the nearest int as necessary for int results */
+ if (sipo->mode == SIPO_MODE_DRIVERS) {
+ /* Drivers Mode - Affects cursor (float) */
+ sipo->cursorTime = sum_time / (float)num_keyframes;
}
+ else {
+ /* Animation Mode - Affects current frame (int) */
+ CFRA = round_fl_to_int(sum_time / num_keyframes);
+ SUBFRA = 0.f;
+ }
+ sipo->cursorVal = sum_value / (float)num_keyframes;
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
@@ -2825,6 +2838,46 @@ void GRAPH_OT_frame_jump(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+/* snap 2D cursor value to the average value of selected keyframe */
+static int graphkeys_snap_cursor_value_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ bAnimContext ac;
+
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
+ return OPERATOR_CANCELLED;
+ }
+
+ const KeyframeEditData keyframe_sum = sum_selected_keyframes(&ac);
+ const float sum_value = keyframe_sum.f2;
+ const int num_keyframes = keyframe_sum.i1;
+
+ if (num_keyframes == 0) {
+ return OPERATOR_FINISHED;
+ }
+
+ SpaceGraph *sipo = (SpaceGraph *)ac.sl;
+ sipo->cursorVal = sum_value / (float)num_keyframes;
+ // WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
+ ED_region_tag_redraw(CTX_wm_region(C));
+
+ return OPERATOR_FINISHED;
+}
+
+void GRAPH_OT_snap_cursor_value(wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Snap Cursor Value to Selected";
+ ot->idname = "GRAPH_OT_snap_cursor_value";
+ ot->description = "Place the cursor value on the average value of selected keyframes";
+
+ /* API callbacks. */
+ ot->exec = graphkeys_snap_cursor_value_exec;
+ ot->poll = graphkeys_framejump_poll;
+
+ /* Flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
/* ******************** Snap Keyframes Operator *********************** */
/* defines for snap keyframes tool */
@@ -3249,8 +3302,8 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
if (RNA_boolean_get(op->ptr, "only_active")) {
- filter |=
- ANIMFILTER_ACTIVE; // FIXME: enforce in this case only a single channel to get handled?
+ /* FIXME: enforce in this case only a single channel to get handled? */
+ filter |= ANIMFILTER_ACTIVE;
}
else {
filter |= (ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE);
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index c39ffdf42ed..eaa14fedb93 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -113,6 +113,7 @@ void GRAPH_OT_extrapolation_type(struct wmOperatorType *ot);
void GRAPH_OT_easing_type(struct wmOperatorType *ot);
void GRAPH_OT_frame_jump(struct wmOperatorType *ot);
+void GRAPH_OT_snap_cursor_value(struct wmOperatorType *ot);
void GRAPH_OT_snap(struct wmOperatorType *ot);
void GRAPH_OT_mirror(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 22c185e36e5..fd68303e759 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -54,7 +54,7 @@
#include "WM_types.h"
/* ************************** view-based operators **********************************/
-// XXX should these really be here?
+/* XXX should these really be here? */
/* Set Cursor --------------------------------------------------------------------- */
/* The 'cursor' in the Graph Editor consists of two parts:
@@ -452,6 +452,7 @@ void graphedit_operatortypes(void)
WM_operatortype_append(GRAPH_OT_snap);
WM_operatortype_append(GRAPH_OT_mirror);
WM_operatortype_append(GRAPH_OT_frame_jump);
+ WM_operatortype_append(GRAPH_OT_snap_cursor_value);
WM_operatortype_append(GRAPH_OT_handle_type);
WM_operatortype_append(GRAPH_OT_interpolation_type);
WM_operatortype_append(GRAPH_OT_extrapolation_type);
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 433d7d6774b..df89a4ff725 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -85,13 +85,13 @@ typedef enum eGraphVertIndex {
} eGraphVertIndex;
/* Tolerance for absolute radius (in pixels) of the vert from the cursor to use */
-// TODO: perhaps this should depend a bit on the size that the user set the vertices to be?
+/* TODO: perhaps this should depend a bit on the size that the user set the vertices to be? */
#define GVERTSEL_TOL (10 * U.pixelsize)
/* ....... */
/* check if its ok to select a handle */
-// XXX also need to check for int-values only?
+/* XXX also need to check for int-values only? */
static bool fcurve_handle_sel_check(SpaceGraph *sipo, BezTriple *bezt)
{
if (sipo->flag & SIPO_NOHANDLES) {
@@ -104,7 +104,7 @@ static bool fcurve_handle_sel_check(SpaceGraph *sipo, BezTriple *bezt)
}
/* check if the given vertex is within bounds or not */
-// TODO: should we return if we hit something?
+/* TODO: should we return if we hit something? */
static void nearest_fcurve_vert_store(ListBase *matches,
View2D *v2d,
FCurve *fcu,
@@ -158,7 +158,7 @@ static void nearest_fcurve_vert_store(ListBase *matches,
nvi->frame = bezt->vec[1][0]; /* currently in global time... */
- nvi->sel = BEZT_ISSEL_ANY(bezt); // XXX... should this use the individual verts instead?
+ nvi->sel = BEZT_ISSEL_ANY(bezt); /* XXX... should this use the individual verts instead? */
/* add to list of matches if appropriate... */
if (replace == 0) {
@@ -188,7 +188,7 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
if (sipo->flag &
- SIPO_SELCUVERTSONLY) { // FIXME: this should really be check for by the filtering code...
+ SIPO_SELCUVERTSONLY) { /* FIXME: this should really be check for by the filtering code... */
filter |= ANIMFILTER_SEL;
}
mapping_flag |= ANIM_get_normalization_flags(ac);
@@ -257,7 +257,7 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
}
}
else if (fcu->fpt) {
- // TODO; do this for samples too
+ /* TODO; do this for samples too */
}
/* un-apply NLA mapping from all the keyframes */
@@ -1471,7 +1471,7 @@ static int mouse_graph_keys(bAnimContext *ac,
* doesn't depend on this
*/
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
}
}
@@ -1480,7 +1480,7 @@ static int mouse_graph_keys(bAnimContext *ac,
}
/* if points can be selected on this F-Curve */
- // TODO: what about those with no keyframes?
+ /* TODO: what about those with no keyframes? */
if (!curves_only && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) {
/* only if there's keyframe */
if (nvi->bezt) {
@@ -1515,7 +1515,7 @@ static int mouse_graph_keys(bAnimContext *ac,
}
}
else if (nvi->fpt) {
- // TODO: need to handle sample points
+ /* TODO: need to handle sample points */
}
}
else {
@@ -1609,7 +1609,7 @@ static int graphkeys_mselect_column(bAnimContext *ac,
}
/* get frame number on which elements should be selected */
- // TODO: should we restrict to integer frames only?
+ /* TODO: should we restrict to integer frames only? */
selx = nvi->frame;
if (select_mode != SELECT_REPLACE) {
@@ -1739,7 +1739,7 @@ void GRAPH_OT_clickselect(wmOperatorType *ot)
0,
"Extend Select",
"Toggle keyframe selection instead of leaving newly selected "
- "keyframes only"); // SHIFTKEY
+ "keyframes only"); /* SHIFTKEY */
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna,
@@ -1754,14 +1754,14 @@ void GRAPH_OT_clickselect(wmOperatorType *ot)
0,
"Column Select",
"Select all keyframes that occur on the same frame as the one under "
- "the mouse"); // ALTKEY
+ "the mouse"); /* ALTKEY */
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna,
"curves",
0,
"Only Curves",
- "Select all the keyframes in the curve"); // CTRLKEY + ALTKEY
+ "Select all the keyframes in the curve"); /* CTRLKEY + ALTKEY */
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c
index ffac9f1c722..8463c21b1ad 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -46,7 +46,7 @@
#include "RNA_access.h"
-#include "graph_intern.h" // own include
+#include "graph_intern.h" /* own include */
/* ************************************************************** */
/* Set Up Drivers Editor */
@@ -141,7 +141,7 @@ bool graphop_visible_keyframes_poll(bContext *C)
bool found = false;
/* firstly, check if in Graph Editor */
- // TODO: also check for region?
+ /* TODO: also check for region? */
if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
return found;
}
@@ -194,7 +194,7 @@ bool graphop_editable_keyframes_poll(bContext *C)
bool found = false;
/* firstly, check if in Graph Editor */
- // TODO: also check for region?
+ /* TODO: also check for region? */
if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
return found;
}
@@ -246,7 +246,7 @@ bool graphop_active_fcurve_poll(bContext *C)
bool has_fcurve = false;
/* firstly, check if in Graph Editor */
- // TODO: also check for region?
+ /* TODO: also check for region? */
if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
return has_fcurve;
}
@@ -299,7 +299,7 @@ bool graphop_selected_fcurve_poll(bContext *C)
int filter;
/* firstly, check if in Graph Editor */
- // TODO: also check for region?
+ /* TODO: also check for region? */
if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
return false;
}
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 97db9b756ad..791039498e8 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -60,7 +60,7 @@
#include "UI_resources.h"
#include "UI_view2d.h"
-#include "graph_intern.h" // own include
+#include "graph_intern.h" /* own include */
/* ******************** default callbacks for ipo space ***************** */
@@ -317,7 +317,7 @@ static void graph_main_region_draw_overlay(const bContext *C, ARegion *region)
ED_time_scrub_draw_current_frame(region, scene, sipo->flag & SIPO_DRAWTIME, draw_vert_line);
/* scrollers */
- // FIXME: args for scrollers depend on the type of data being shown...
+ /* FIXME: args for scrollers depend on the type of data being shown. */
UI_view2d_scrollers_draw(v2d, NULL);
/* scale numbers */
@@ -615,10 +615,13 @@ static void graph_listener(wmWindow *UNUSED(win),
}
break;
- // XXX: restore the case below if not enough updates occur...
- // default:
- // if (wmn->data == ND_KEYS)
- // ED_area_tag_redraw(area);
+#if 0 /* XXX: restore the case below if not enough updates occur... */
+ default: {
+ if (wmn->data == ND_KEYS) {
+ ED_area_tag_redraw(area);
+ }
+ }
+#endif
}
}
@@ -763,7 +766,7 @@ static void graph_refresh(const bContext *C, ScrArea *area)
}
/* region updates? */
- // XXX re-sizing y-extents of tot should go here?
+ /* XXX re-sizing y-extents of tot should go here? */
/* 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,
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 1f8dd7cfe44..0dcc090fa0e 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -725,9 +725,6 @@ static void uiblock_layer_pass_buttons(uiLayout *layout,
}
}
-// XXX HACK!
-// static int packdummy=0;
-
typedef struct RNAUpdateCb {
PointerRNA ptr;
PropertyRNA *prop;
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 7a53e9b75b6..7a066adae77 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -603,7 +603,7 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *region)
{
wmKeyMap *keymap;
- // image space manages own v2d
+ /* Image space manages own v2d. */
// UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_STANDARD, region->winx, region->winy);
/* mask polls mode */
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index 30f36509b41..0544a2cbefa 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -161,7 +161,7 @@ static int pack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
Main *bmain = CTX_data_main(C);
Image *ima;
- // first check for dirty images
+ /* First check for dirty images. */
for (ima = bmain->images.first; ima; ima = ima->id.next) {
if (BKE_image_is_dirty(ima)) {
break;
diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c
index adc6391a0f6..3ba088018c3 100644
--- a/source/blender/editors/space_info/info_report.c
+++ b/source/blender/editors/space_info/info_report.c
@@ -100,15 +100,15 @@ int info_report_mask(const SpaceInfo *UNUSED(sinfo))
RPT_ERROR_ALL;
}
-// TODO, get this working again!
static int report_replay_exec(bContext *C, wmOperator *UNUSED(op))
{
- // SpaceInfo *sc = CTX_wm_space_info(C);
- // ReportList *reports = CTX_wm_reports(C);
- // int report_mask = info_report_mask(sc);
- // Report *report;
-
+ /* TODO, get this working again! */
#if 0
+ SpaceInfo *sc = CTX_wm_space_info(C);
+ ReportList *reports = CTX_wm_reports(C);
+ int report_mask = info_report_mask(sc);
+ Report *report;
+
sc->type = CONSOLE_TYPE_PYTHON;
for (report = reports->list.last; report; report = report->prev) {
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index edf4cebf7d7..9e58fcd471b 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -52,7 +52,7 @@
#include "UI_interface.h"
#include "UI_resources.h"
-#include "nla_intern.h" // own include
+#include "nla_intern.h" /* own include */
/* ******************* nla editor space & buttons ************** */
@@ -92,7 +92,7 @@ bool nla_panel_context(const bContext *C,
/* extract list of active channel(s), of which we should only take the first one
* - we need the channels flag to get the active AnimData block when there are no NLA Tracks
*/
- // XXX: double-check active!
+ /* XXX: double-check active! */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ACTIVE |
ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
@@ -416,7 +416,7 @@ static void nla_panel_properties(const bContext *C, Panel *panel)
row = uiLayoutRow(column, true);
uiLayoutSetActive(row, RNA_boolean_get(&strip_ptr, "use_animated_influence") == false);
- uiItemR(row, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle?
+ uiItemR(row, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); /* XXX as toggle? */
/* settings */
column = uiLayoutColumnWithHeading(layout, true, IFACE_("Playback"));
@@ -580,8 +580,8 @@ static void nla_panel_modifiers(const bContext *C, Panel *panel)
row = uiLayoutRow(panel->layout, false);
block = uiLayoutGetBlock(row);
- // FIXME: we need to set the only-active property so that this
- // will only add modifiers for the active strip (not all selected).
+ /* FIXME: we need to set the only-active property so that this
+ * will only add modifiers for the active strip (not all selected). */
uiItemMenuEnumO(
row, (bContext *)C, "NLA_OT_fmodifier_add", "type", IFACE_("Add Modifier"), ICON_NONE);
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index f6f3571018a..561de5e82a6 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -59,7 +59,7 @@
#include "UI_view2d.h"
-#include "nla_intern.h" // own include
+#include "nla_intern.h" /* own include */
/* *********************************************** */
/* Operators for NLA channels-list which need to be different
@@ -103,7 +103,7 @@ static int mouse_nla_channels(
}
/* action to take depends on what channel we've got */
- // WARNING: must keep this in sync with the equivalent function in anim_channels_edit.c
+ /* WARNING: must keep this in sync with the equivalent function in anim_channels_edit.c */
switch (ale->type) {
case ANIMTYPE_SCENE: {
Scene *sce = (Scene *)ale->data;
@@ -204,7 +204,7 @@ static int mouse_nla_channels(
}
else {
/* select AnimData block by itself */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
ale->adt->flag |= ADT_UI_SELECTED;
}
@@ -267,7 +267,7 @@ static int mouse_nla_channels(
}
else {
/* select F-Curve by itself */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
nlt->flag |= NLATRACK_SELECTED;
}
@@ -329,7 +329,7 @@ static int mouse_nla_channels(
}
else {
/* select AnimData block by itself */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
adt->flag |= ADT_UI_SELECTED;
}
@@ -427,7 +427,7 @@ void NLA_OT_channels_click(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* props */
- prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY
+ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); /* SHIFTKEY */
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 9e43a8ce109..6fe980cf657 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -266,7 +266,7 @@ static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float col
}
else if (strip->type == NLASTRIP_TYPE_META) {
/* Meta Clip */
- // TODO: should temporary metas get different colors too?
+ /* TODO: should temporary metas get different colors too? */
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* selected - use a bold purple color */
UI_GetThemeColor3fv(TH_NLA_META_SEL, color);
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index d82a39786d9..fa27a6941ec 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -65,8 +65,8 @@
#include "UI_resources.h"
#include "UI_view2d.h"
-#include "nla_intern.h" // own include
-#include "nla_private.h" // FIXME... maybe this shouldn't be included?
+#include "nla_intern.h" /* own include */
+#include "nla_private.h" /* FIXME... maybe this shouldn't be included? */
/* *********************************************** */
/* Utilities exported to other places... */
@@ -381,7 +381,7 @@ static int nlaedit_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
scene->r.pefra = round_fl_to_int(max);
/* set notifier that things have changed */
- // XXX err... there's nothing for frame ranges yet, but this should do fine too
+ /* XXX err... there's nothing for frame ranges yet, but this should do fine too */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
return OPERATOR_FINISHED;
@@ -717,7 +717,7 @@ void NLA_OT_actionclip_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
- // TODO: this would be nicer as an ID-pointer...
+ /* TODO: this would be nicer as an ID-pointer. */
prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", "");
RNA_def_enum_funcs(prop, RNA_action_itemf);
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
@@ -878,7 +878,8 @@ static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* for each track, add sound clips if it belongs to a speaker */
- // TODO: what happens if there aren't any tracks... well that's a more general problem for later
+ /* TODO: what happens if there aren't any tracks,
+ * well that's a more general problem for later. */
for (ale = anim_data.first; ale; ale = ale->next) {
Object *ob = (Object *)ale->id; /* may not be object until we actually check! */
@@ -1260,9 +1261,9 @@ void NLA_OT_delete(wmOperatorType *ot)
/* ******************** Split Strips Operator ***************************** */
/* Splits the selected NLA-Strips into two strips at the midpoint of the strip */
-// TODO's?
-// - multiple splits
-// - variable-length splits?
+/* TODO's?
+ * - multiple splits
+ * - variable-length splits? */
/* split a given Action-Clip strip */
static void nlaedit_split_strip_actclip(
@@ -1440,7 +1441,7 @@ static int nlaedit_toggle_mute_exec(bContext *C, wmOperator *UNUSED(op))
for (strip = nlt->strips.first; strip; strip = strip->next) {
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* just flip the mute flag for now */
- // TODO: have a pre-pass to check if mute all or unmute all?
+ /* TODO: have a pre-pass to check if mute all or unmute all? */
strip->flag ^= NLASTRIP_FLAG_MUTED;
/* tag AnimData to get recalculated */
@@ -2158,8 +2159,9 @@ void NLA_OT_clear_scale(wmOperatorType *ot)
/* defines for snap keyframes tool */
static const EnumPropertyItem prop_nlaedit_snap_types[] = {
{NLAEDIT_SNAP_CFRA, "CFRA", 0, "Current Frame", ""},
- {NLAEDIT_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, // XXX as single entry?
- // XXX as single entry?
+ /* XXX as single entry? */
+ {NLAEDIT_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""},
+ /* XXX as single entry? */
{NLAEDIT_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""},
{NLAEDIT_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", ""},
{0, NULL, 0, NULL, NULL},
@@ -2481,7 +2483,7 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op)
continue;
}
- // TODO: when 'active' vs 'all' boolean is added, change last param!
+ /* TODO: when 'active' vs 'all' boolean is added, change last param! */
ok |= ANIM_fmodifiers_copy_to_buf(&strip->modifiers, 0);
}
}
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index ec41368b9f0..751a05b605e 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -49,7 +49,7 @@
#include "UI_interface.h"
#include "UI_view2d.h"
-#include "nla_intern.h" // own include
+#include "nla_intern.h" /* own include */
/* ******************** Utilities ***************************************** */
@@ -100,7 +100,7 @@ static void deselect_nla_strips(bAnimContext *ac, short test, short sel)
short smode;
/* determine type-based settings */
- // FIXME: double check whether ANIMFILTER_LIST_VISIBLE is needed!
+ /* FIXME: double check whether ANIMFILTER_LIST_VISIBLE is needed! */
filter = (ANIMFILTER_DATA_VISIBLE);
/* filter data */
@@ -638,7 +638,7 @@ static int mouse_nla_strips(bContext *C,
deselect_nla_strips(ac, 0, SELECT_SUBTRACT);
/* deselect all other channels first */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
}
}
@@ -728,7 +728,7 @@ void NLA_OT_click_select(wmOperatorType *ot)
/* properties */
WM_operator_properties_generic_select(ot);
- prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY
+ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); /* SHIFTKEY */
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna,
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 7a0cd35ece1..7e3f90b01ba 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -551,7 +551,7 @@ static void nla_listener(wmWindow *UNUSED(win),
/* context changes */
switch (wmn->category) {
case NC_ANIMATION:
- // TODO: filter specific types of changes?
+ /* TODO: filter specific types of changes? */
ED_area_tag_refresh(area);
break;
case NC_SCENE:
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 9373c434b9b..10aa53abb01 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -2369,7 +2369,7 @@ static void node_composit_buts_bokehimage(uiLayout *layout, bContext *UNUSED(C),
static void node_composit_buts_bokehblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "use_variable_size", DEFAULT_FLAGS, NULL, ICON_NONE);
- // uiItemR(layout, ptr, "f_stop", DEFAULT_FLAGS, NULL, ICON_NONE); // UNUSED
+ // uiItemR(layout, ptr, "f_stop", DEFAULT_FLAGS, NULL, ICON_NONE); /* UNUSED */
uiItemR(layout, ptr, "blur_max", DEFAULT_FLAGS, NULL, ICON_NONE);
uiItemR(layout, ptr, "use_extended_bounds", DEFAULT_FLAGS, NULL, ICON_NONE);
}
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index ac2b8bac70d..bafd1b9a388 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -1275,7 +1275,7 @@ static void node_draw_basis(const bContext *C,
showname,
(int)(rct->xmin + NODE_MARGIN_X),
(int)(rct->ymax - NODE_DY),
- (short)(iconofs - rct->xmin - 18.0f),
+ (short)(iconofs - rct->xmin - (18.0f * U.dpi_fac)),
(short)NODE_DY,
NULL,
0,
@@ -1456,7 +1456,7 @@ static void node_draw_hidden(const bContext *C,
showname,
round_fl_to_int(rct->xmin + NODE_MARGIN_X),
round_fl_to_int(centy - NODE_DY * 0.5f),
- (short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f),
+ (short)(BLI_rctf_size_x(rct) - ((18.0f + 12.0f) * U.dpi_fac)),
(short)NODE_DY,
NULL,
0,
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 8c9d477e864..b1659bcd023 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -773,12 +773,12 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node, bool *r_acti
}
}
else if (ntree->type == NTREE_TEXTURE) {
- // XXX
+ /* XXX */
#if 0
if (node->id) {
- // XXX BIF_preview_changed(-1);
- // allqueue(REDRAWBUTSSHADING, 1);
- // allqueue(REDRAWIPO, 0);
+ BIF_preview_changed(-1);
+ allqueue(REDRAWBUTSSHADING, 1);
+ allqueue(REDRAWIPO, 0);
}
#endif
}
@@ -1378,7 +1378,7 @@ void ED_node_select_all(ListBase *lb, int action)
}
/* ******************************** */
-// XXX some code needing updating to operators...
+/* XXX some code needing updating to operators. */
/* goes over all scenes, reads render layers */
static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
@@ -2724,7 +2724,7 @@ void NODE_OT_viewer_border(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- WM_operator_properties_gesture_box_select(ot);
+ WM_operator_properties_gesture_box(ot);
}
static int clear_viewer_border_exec(bContext *C, wmOperator *UNUSED(op))
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index 742d577ccf8..c74593f73bf 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -138,12 +138,11 @@ static int node_group_edit_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
const char *node_idname = group_node_idname(C);
- bNode *gnode;
const bool exit = RNA_boolean_get(op->ptr, "exit");
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
- gnode = node_group_get_active(C, node_idname);
+ bNode *gnode = node_group_get_active(C, node_idname);
if (gnode && !exit) {
bNodeTree *ngroup = (bNodeTree *)gnode->id;
@@ -203,30 +202,24 @@ static void animation_basepath_change_free(AnimationBasePathChange *basepath_cha
/* returns 1 if its OK */
static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
{
- bNodeLink *link, *linkn, *tlink;
- bNode *node, *nextnode;
- bNodeTree *ngroup, *wgroup;
- ListBase anim_basepaths = {NULL, NULL};
- LinkNode *nodes_delayed_free = NULL;
-
- ngroup = (bNodeTree *)gnode->id;
-
/* clear new pointers, set in copytree */
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
node->new_node = NULL;
}
+ ListBase anim_basepaths = {NULL, NULL};
+ LinkNode *nodes_delayed_free = NULL;
+ bNodeTree *ngroup = (bNodeTree *)gnode->id;
+
/* wgroup is a temporary copy of the NodeTree we're merging in
* - all of wgroup's nodes are copied across to their new home
* - ngroup (i.e. the source NodeTree) is left unscathed
* - temp copy. do change ID usercount for the copies
*/
- wgroup = ntreeCopyTree_ex_new_pointers(ngroup, bmain, true);
+ bNodeTree *wgroup = ntreeCopyTree_ex_new_pointers(ngroup, bmain, true);
/* Add the nodes into the ntree */
- for (node = wgroup->nodes.first; node; node = nextnode) {
- nextnode = node->next;
-
+ LISTBASE_FOREACH_MUTABLE (bNode *, node, &wgroup->nodes) {
/* Remove interface nodes.
* This also removes remaining links to and from interface nodes.
*/
@@ -271,8 +264,7 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
bNodeLink *glinks_first = ntree->links.last;
/* Add internal links to the ntree */
- for (link = wgroup->links.first; link; link = linkn) {
- linkn = link->next;
+ LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &wgroup->links) {
BLI_remlink(&wgroup->links, link);
BLI_addtail(&ntree->links, link);
}
@@ -310,13 +302,14 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
/* input links */
if (glinks_first != NULL) {
- for (link = glinks_first->next; link != glinks_last->next; link = link->next) {
+ for (bNodeLink *link = glinks_first->next; link != glinks_last->next; link = link->next) {
if (link->fromnode->type == NODE_GROUP_INPUT) {
const char *identifier = link->fromsock->identifier;
int num_external_links = 0;
/* find external links to this input */
- for (tlink = ntree->links.first; tlink != glinks_first->next; tlink = tlink->next) {
+ for (bNodeLink *tlink = ntree->links.first; tlink != glinks_first->next;
+ tlink = tlink->next) {
if (tlink->tonode == gnode && STREQ(tlink->tosock->identifier, identifier)) {
nodeAddLink(ntree, tlink->fromnode, tlink->fromsock, link->tonode, link->tosock);
num_external_links++;
@@ -326,12 +319,14 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
/* if group output is not externally linked,
* convert the constant input value to ensure somewhat consistent behavior */
if (num_external_links == 0) {
- /* XXX TODO bNodeSocket *sock = node_group_find_input_socket(gnode, identifier);
- BLI_assert(sock);*/
-
- /* XXX TODO
- * nodeSocketCopy(ntree, link->tosock->new_sock, link->tonode->new_node,
- * ntree, sock, gnode);*/
+ /* TODO */
+#if 0
+ bNodeSocket *sock = node_group_find_input_socket(gnode, identifier);
+ BLI_assert(sock);
+
+ nodeSocketCopy(
+ ntree, link->tosock->new_sock, link->tonode->new_node, ntree, sock, gnode);
+#endif
}
}
}
@@ -340,13 +335,14 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
glinks_last = ntree->links.last;
/* output links */
- for (link = ntree->links.first; link != glinks_first->next; link = link->next) {
+ for (bNodeLink *link = ntree->links.first; link != glinks_first->next; link = link->next) {
if (link->fromnode == gnode) {
const char *identifier = link->fromsock->identifier;
int num_internal_links = 0;
/* find internal links to this output */
- for (tlink = glinks_first->next; tlink != glinks_last->next; tlink = tlink->next) {
+ for (bNodeLink *tlink = glinks_first->next; tlink != glinks_last->next;
+ tlink = tlink->next) {
/* only use active output node */
if (tlink->tonode->type == NODE_GROUP_OUTPUT && (tlink->tonode->flag & NODE_DO_OUTPUT)) {
if (STREQ(tlink->tosock->identifier, identifier)) {
@@ -359,18 +355,20 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
/* if group output is not internally linked,
* convert the constant output value to ensure somewhat consistent behavior */
if (num_internal_links == 0) {
- /* XXX TODO bNodeSocket *sock = node_group_find_output_socket(gnode, identifier);
- BLI_assert(sock);*/
+ /* TODO */
+#if 0
+ bNodeSocket *sock = node_group_find_output_socket(gnode, identifier);
+ BLI_assert(sock);
- /* XXX TODO
- * nodeSocketCopy(ntree, link->tosock, link->tonode, ntree, sock, gnode); */
+ nodeSocketCopy(ntree, link->tosock, link->tonode, ntree, sock, gnode);
+#endif
}
}
}
}
while (nodes_delayed_free) {
- node = BLI_linklist_pop(&nodes_delayed_free);
+ bNode *node = BLI_linklist_pop(&nodes_delayed_free);
nodeRemoveNode(bmain, ntree, node, false);
}
@@ -387,11 +385,10 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
const char *node_idname = group_node_idname(C);
- bNode *gnode;
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
- gnode = node_group_get_active(C, node_idname);
+ bNode *gnode = node_group_get_active(C, node_idname);
if (!gnode) {
return OPERATOR_CANCELLED;
}
@@ -431,23 +428,20 @@ void NODE_OT_group_ungroup(wmOperatorType *ot)
static int node_group_separate_selected(
Main *bmain, bNodeTree *ntree, bNodeTree *ngroup, float offx, float offy, int make_copy)
{
- bNodeLink *link, *link_next;
- bNode *node, *node_next, *newnode;
- ListBase anim_basepaths = {NULL, NULL};
-
/* deselect all nodes in the target tree */
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
nodeSetSelected(node, false);
}
/* clear new pointers, set in BKE_node_copy_ex(). */
- for (node = ngroup->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ngroup->nodes) {
node->new_node = NULL;
}
+ ListBase anim_basepaths = {NULL, NULL};
+
/* add selected nodes into the ntree */
- for (node = ngroup->nodes.first; node; node = node_next) {
- node_next = node->next;
+ LISTBASE_FOREACH_MUTABLE (bNode *, node, &ngroup->nodes) {
if (!(node->flag & NODE_SELECT)) {
continue;
}
@@ -458,6 +452,7 @@ static int node_group_separate_selected(
continue;
}
+ bNode *newnode;
if (make_copy) {
/* make a copy */
newnode = BKE_node_copy_store_new_pointers(ngroup, node, LIB_ID_COPY_DEFAULT);
@@ -501,10 +496,9 @@ static int node_group_separate_selected(
}
/* add internal links to the ntree */
- for (link = ngroup->links.first; link; link = link_next) {
+ LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ngroup->links) {
const bool fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT));
const bool toselect = (link->tonode && (link->tonode->flag & NODE_SELECT));
- link_next = link->next;
if (make_copy) {
/* make a copy of internal links */
@@ -564,20 +558,19 @@ static int node_group_separate_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
- bNodeTree *ngroup, *nparent;
int type = RNA_enum_get(op->ptr, "type");
- float offx, offy;
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
/* are we inside of a group? */
- ngroup = snode->edittree;
- nparent = ED_node_tree_get(snode, 1);
+ bNodeTree *ngroup = snode->edittree;
+ bNodeTree *nparent = ED_node_tree_get(snode, 1);
if (!nparent) {
BKE_report(op->reports, RPT_WARNING, "Not inside node group");
return OPERATOR_CANCELLED;
}
/* get node tree offset */
+ float offx, offy;
space_node_group_offset(snode, &offx, &offy);
switch (type) {
@@ -654,16 +647,13 @@ static bool node_group_make_test_selected(bNodeTree *ntree,
const char *ntree_idname,
struct ReportList *reports)
{
- bNodeTree *ngroup;
- bNode *node;
- bNodeLink *link;
int ok = true;
/* make a local pseudo node tree to pass to the node poll functions */
- ngroup = ntreeAddTree(NULL, "Pseudo Node Group", ntree_idname);
+ bNodeTree *ngroup = ntreeAddTree(NULL, "Pseudo Node Group", ntree_idname);
/* check poll functions for selected nodes */
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node_group_make_use_node(node, gnode)) {
if (node->typeinfo->poll_instance && !node->typeinfo->poll_instance(node, ngroup)) {
BKE_reportf(reports, RPT_WARNING, "Can not add node '%s' in a group", node->name);
@@ -684,7 +674,7 @@ static bool node_group_make_test_selected(bNodeTree *ntree,
/* check if all connections are OK, no unselected node has both
* inputs and outputs to a selection */
- for (link = ntree->links.first; link; link = link->next) {
+ LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
if (node_group_make_use_node(link->fromnode, gnode)) {
link->tonode->done |= 1;
}
@@ -692,7 +682,7 @@ static bool node_group_make_test_selected(bNodeTree *ntree,
link->fromnode->done |= 2;
}
}
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (!(node->flag & NODE_SELECT) && node != gnode && node->done == 3) {
return false;
}
@@ -703,13 +693,12 @@ static bool node_group_make_test_selected(bNodeTree *ntree,
static int node_get_selected_minmax(
bNodeTree *ntree, bNode *gnode, float *min, float *max, bool use_size)
{
- bNode *node;
- float loc[2];
int totselect = 0;
INIT_MINMAX2(min, max);
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node_group_make_use_node(node, gnode)) {
+ float loc[2];
nodeToView(node, 0.0f, 0.0f, &loc[0], &loc[1]);
minmax_v2v2_v2(min, max, loc);
if (use_size) {
@@ -733,28 +722,23 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
{
Main *bmain = CTX_data_main(C);
bNodeTree *ngroup = (bNodeTree *)gnode->id;
- bNodeLink *link, *linkn;
- bNode *node, *nextn, *link_node;
- bNodeSocket *sock, *link_sock;
- ListBase anim_basepaths = {NULL, NULL};
- float min[2], max[2], real_min[2], real_max[2], center[2];
- int totselect;
bool expose_visible = false;
- bNode *input_node, *output_node;
/* XXX rough guess, not nice but we don't have access to UI constants here ... */
static const float offsetx = 200;
static const float offsety = 0.0f;
/* deselect all nodes in the target tree */
- for (node = ngroup->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ngroup->nodes) {
nodeSetSelected(node, false);
}
- totselect = node_get_selected_minmax(ntree, gnode, min, max, false);
+ float center[2], min[2], max[2];
+ const int totselect = node_get_selected_minmax(ntree, gnode, min, max, false);
add_v2_v2v2(center, min, max);
mul_v2_fl(center, 0.5f);
+ float real_min[2], real_max[2];
node_get_selected_minmax(ntree, gnode, real_min, real_max, true);
/* auto-add interface for "solo" nodes */
@@ -762,9 +746,10 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
expose_visible = true;
}
+ ListBase anim_basepaths = {NULL, NULL};
+
/* move nodes over */
- for (node = ntree->nodes.first; node; node = nextn) {
- nextn = node->next;
+ LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) {
if (node_group_make_use_node(node, gnode)) {
/* keep track of this node's RNA "base" path (the part of the pat identifying the node)
* if the old nodetree has animation data which potentially covers this node
@@ -809,22 +794,20 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
ntreeFreeCache(ngroup);
/* create input node */
- input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT);
+ bNode *input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT);
input_node->locx = real_min[0] - center[0] - offsetx;
input_node->locy = -offsety;
/* create output node */
- output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT);
+ bNode *output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT);
output_node->locx = real_max[0] - center[0] + offsetx * 0.25f;
output_node->locy = -offsety;
/* relink external sockets */
- for (link = ntree->links.first; link; link = linkn) {
+ LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) {
int fromselect = node_group_make_use_node(link->fromnode, gnode);
int toselect = node_group_make_use_node(link->tonode, gnode);
- linkn = link->next;
-
if ((fromselect && link->tonode == gnode) || (toselect && link->fromnode == gnode)) {
/* remove all links to/from the gnode.
* this can remove link information, but there's no general way to preserve it.
@@ -832,9 +815,10 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
nodeRemLink(ntree, link);
}
else if (toselect && !fromselect) {
+ bNodeSocket *link_sock;
+ bNode *link_node;
node_socket_skip_reroutes(&ntree->links, link->tonode, link->tosock, &link_node, &link_sock);
bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link_node, link_sock);
- bNodeSocket *input_sock;
/* update the group node and interface node sockets,
* so the new interface socket can be linked.
@@ -843,7 +827,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
node_group_input_update(ngroup, input_node);
/* create new internal link */
- input_sock = node_group_input_find_socket(input_node, iosock->identifier);
+ bNodeSocket *input_sock = node_group_input_find_socket(input_node, iosock->identifier);
nodeAddLink(ngroup, input_node, input_sock, link->tonode, link->tosock);
/* redirect external link */
@@ -854,8 +838,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
/* First check whether the source of this link is already connected to an output.
* If yes, reuse that output instead of duplicating it. */
bool connected = false;
- bNodeLink *olink;
- for (olink = ngroup->links.first; olink; olink = olink->next) {
+ LISTBASE_FOREACH (bNodeLink *, olink, &ngroup->links) {
if (olink->fromsock == link->fromsock && olink->tonode == output_node) {
bNodeSocket *output_sock = node_group_find_output_socket(gnode,
olink->tosock->identifier);
@@ -866,10 +849,11 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
}
if (!connected) {
+ bNodeSocket *link_sock;
+ bNode *link_node;
node_socket_skip_reroutes(
&ntree->links, link->fromnode, link->fromsock, &link_node, &link_sock);
bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link_node, link_sock);
- bNodeSocket *output_sock;
/* update the group node and interface node sockets,
* so the new interface socket can be linked.
@@ -878,7 +862,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
node_group_output_update(ngroup, output_node);
/* create new internal link */
- output_sock = node_group_output_find_socket(output_node, iosock->identifier);
+ bNodeSocket *output_sock = node_group_output_find_socket(output_node, iosock->identifier);
nodeAddLink(ngroup, link->fromnode, link->fromsock, output_node, output_sock);
/* redirect external link */
@@ -889,12 +873,10 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
}
/* move internal links */
- for (link = ntree->links.first; link; link = linkn) {
+ LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) {
int fromselect = node_group_make_use_node(link->fromnode, gnode);
int toselect = node_group_make_use_node(link->tonode, gnode);
- linkn = link->next;
-
if (fromselect && toselect) {
BLI_remlink(&ntree->links, link);
BLI_addtail(&ngroup->links, link);
@@ -902,7 +884,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
}
/* move nodes in the group to the center */
- for (node = ngroup->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ngroup->nodes) {
if (node_group_make_use_node(node, gnode) && !node->parent) {
node->locx -= center[0];
node->locy -= center[1];
@@ -911,12 +893,11 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
/* expose all unlinked sockets too but only the visible ones*/
if (expose_visible) {
- for (node = ngroup->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ngroup->nodes) {
if (node_group_make_use_node(node, gnode)) {
- for (sock = node->inputs.first; sock; sock = sock->next) {
- bNodeSocket *iosock, *input_sock;
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
bool skip = false;
- for (link = ngroup->links.first; link; link = link->next) {
+ LISTBASE_FOREACH (bNodeLink *, link, &ngroup->links) {
if (link->tosock == sock) {
skip = true;
break;
@@ -929,19 +910,18 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
continue;
}
- iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
+ bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
node_group_input_update(ngroup, input_node);
/* create new internal link */
- input_sock = node_group_input_find_socket(input_node, iosock->identifier);
+ bNodeSocket *input_sock = node_group_input_find_socket(input_node, iosock->identifier);
nodeAddLink(ngroup, input_node, input_sock, node, sock);
}
- for (sock = node->outputs.first; sock; sock = sock->next) {
- bNodeSocket *iosock, *output_sock;
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
bool skip = false;
- for (link = ngroup->links.first; link; link = link->next) {
+ LISTBASE_FOREACH (bNodeLink *, link, &ngroup->links) {
if (link->fromsock == sock) {
skip = true;
}
@@ -953,12 +933,13 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
continue;
}
- iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
+ bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
node_group_output_update(ngroup, output_node);
/* create new internal link */
- output_sock = node_group_output_find_socket(output_node, iosock->identifier);
+ bNodeSocket *output_sock = node_group_output_find_socket(output_node,
+ iosock->identifier);
nodeAddLink(ngroup, node, sock, output_node, output_sock);
}
}
@@ -977,22 +958,19 @@ static bNode *node_group_make_from_selected(const bContext *C,
const char *ntreetype)
{
Main *bmain = CTX_data_main(C);
- bNode *gnode;
- bNodeTree *ngroup;
- float min[2], max[2];
- int totselect;
- totselect = node_get_selected_minmax(ntree, NULL, min, max, false);
+ float min[2], max[2];
+ const int totselect = node_get_selected_minmax(ntree, NULL, min, max, false);
/* don't make empty group */
if (totselect == 0) {
return NULL;
}
/* new nodetree */
- ngroup = ntreeAddTree(bmain, "NodeGroup", ntreetype);
+ bNodeTree *ngroup = ntreeAddTree(bmain, "NodeGroup", ntreetype);
/* make group node */
- gnode = nodeAddNode(C, ntree, ntype);
+ bNode *gnode = nodeAddNode(C, ntree, ntype);
gnode->id = (ID *)ngroup;
gnode->locx = 0.5f * (min[0] + max[0]);
@@ -1012,8 +990,6 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
bNodeTree *ntree = snode->edittree;
const char *ntree_idname = group_ntree_idname(C);
const char *node_idname = group_node_idname(C);
- bNodeTree *ngroup;
- bNode *gnode;
Main *bmain = CTX_data_main(C);
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
@@ -1022,10 +998,10 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- gnode = node_group_make_from_selected(C, ntree, node_idname, ntree_idname);
+ bNode *gnode = node_group_make_from_selected(C, ntree, node_idname, ntree_idname);
if (gnode) {
- ngroup = (bNodeTree *)gnode->id;
+ bNodeTree *ngroup = (bNodeTree *)gnode->id;
nodeSetActive(ntree, gnode);
if (ngroup) {
@@ -1066,20 +1042,18 @@ static int node_group_insert_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
- bNodeTree *ngroup;
const char *node_idname = group_node_idname(C);
- bNode *gnode;
Main *bmain = CTX_data_main(C);
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
- gnode = node_group_get_active(C, node_idname);
+ bNode *gnode = node_group_get_active(C, node_idname);
if (!gnode || !gnode->id) {
return OPERATOR_CANCELLED;
}
- ngroup = (bNodeTree *)gnode->id;
+ bNodeTree *ngroup = (bNodeTree *)gnode->id;
if (!node_group_make_test_selected(ntree, gnode, ngroup->idname, op->reports)) {
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 1a0b5dc9ee8..04e452d5270 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -256,9 +256,9 @@ void NODE_OT_cryptomatte_layer_remove(struct wmOperatorType *ot);
extern const char *node_context_dir[];
-// XXXXXX
+/* XXXXXX */
-// nodes draw without dpi - the view zoom is flexible
+/* Nodes draw without dpi - the view zoom is flexible. */
#define HIDDEN_RAD (0.75f * U.widget_unit)
#define BASIS_RAD (0.2f * U.widget_unit)
#define NODE_DYS (U.widget_unit / 2)
@@ -271,7 +271,7 @@ extern const char *node_context_dir[];
#define NODE_RESIZE_MARGIN (0.20f * U.widget_unit)
#define NODE_LINK_RESOL 12
-// XXX button events (butspace)
+/* Button events (butspace) */
enum eNodeSpace_ButEvents {
B_NOP = 0,
B_REDR = 1,
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 57fd84a4521..b6d9cdc729d 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -71,7 +71,7 @@ static bool ntree_check_nodes_connected_dfs(bNodeTree *ntree, bNode *from, bNode
return false;
}
from->flag |= NODE_TEST;
- for (bNodeLink *link = ntree->links.first; link != NULL; link = link->next) {
+ LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
if (link->fromnode == from) {
if (link->tonode == to) {
return true;
@@ -136,8 +136,7 @@ bool node_connected_to_output(Main *bmain, bNodeTree *ntree, bNode *node)
if (ntree_has_drivers(ntree)) {
return true;
}
- for (bNode *current_node = ntree->nodes.first; current_node != NULL;
- current_node = current_node->next) {
+ LISTBASE_FOREACH (bNode *, current_node, &ntree->nodes) {
/* Special case for group nodes -- if modified node connected to a group
* with active output inside we consider refresh is needed.
*
@@ -211,10 +210,8 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree,
bNodeSocket *sock_target,
const bool allow_multiple)
{
- bNodeSocket *sock;
-
/* first look for selected output */
- for (sock = node->outputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
if (!socket_is_available(ntree, sock, allow_multiple)) {
continue;
}
@@ -225,7 +222,7 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree,
}
/* try to find a socket with a matching name */
- for (sock = node->outputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
if (!socket_is_available(ntree, sock, allow_multiple)) {
continue;
}
@@ -239,8 +236,7 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree,
}
/* otherwise settle for the first available socket of the right type */
- for (sock = node->outputs.first; sock; sock = sock->next) {
-
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
if (!socket_is_available(ntree, sock, allow_multiple)) {
continue;
}
@@ -264,18 +260,15 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree,
* sockets of higher types, such as image, first */
static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, int replace)
{
- bNodeSocket *sock;
- int socktype, maxtype = 0;
- int a = 0;
-
- for (sock = node->inputs.first; sock; sock = sock->next) {
+ int maxtype = 0;
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
maxtype = max_ii(sock->type, maxtype);
}
/* find sockets of higher 'types' first (i.e. image) */
- for (socktype = maxtype; socktype >= 0; socktype--) {
- for (sock = node->inputs.first; sock; sock = sock->next) {
-
+ int a = 0;
+ for (int socktype = maxtype; socktype >= 0; socktype--) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if (!socket_is_available(ntree, sock, replace)) {
a++;
continue;
@@ -320,13 +313,10 @@ static void snode_autoconnect(Main *bmain,
{
bNodeTree *ntree = snode->edittree;
ListBase *nodelist = MEM_callocN(sizeof(ListBase), "items_list");
- bNodeListItem *nli;
- bNode *node;
- int numlinks = 0;
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->flag & NODE_SELECT) {
- nli = MEM_mallocN(sizeof(bNodeListItem), "temporary node list item");
+ bNodeListItem *nli = MEM_mallocN(sizeof(bNodeListItem), "temporary node list item");
nli->node = node;
BLI_addtail(nodelist, nli);
}
@@ -335,24 +325,23 @@ static void snode_autoconnect(Main *bmain,
/* sort nodes left to right */
BLI_listbase_sort(nodelist, sort_nodes_locx);
- for (nli = nodelist->first; nli; nli = nli->next) {
- bNode *node_fr, *node_to;
- bNodeSocket *sock_fr, *sock_to;
+ int numlinks = 0;
+ LISTBASE_FOREACH (bNodeListItem *, nli, nodelist) {
bool has_selected_inputs = false;
if (nli->next == NULL) {
break;
}
- node_fr = nli->node;
- node_to = nli->next->node;
+ bNode *node_fr = nli->node;
+ bNode *node_to = nli->next->node;
/* corner case: input/output node aligned the wrong way around (T47729) */
if (BLI_listbase_is_empty(&node_to->inputs) || BLI_listbase_is_empty(&node_fr->outputs)) {
SWAP(bNode *, node_fr, node_to);
}
/* if there are selected sockets, connect those */
- for (sock_to = node_to->inputs.first; sock_to; sock_to = sock_to->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock_to, &node_to->inputs) {
if (sock_to->flag & SELECT) {
has_selected_inputs = 1;
@@ -361,7 +350,7 @@ static void snode_autoconnect(Main *bmain,
}
/* check for an appropriate output socket to connect from */
- sock_fr = best_socket_output(ntree, node_fr, sock_to, allow_multiple);
+ bNodeSocket *sock_fr = best_socket_output(ntree, node_fr, sock_to, allow_multiple);
if (!sock_fr) {
continue;
}
@@ -379,13 +368,13 @@ static void snode_autoconnect(Main *bmain,
for (int i = 0; i < num_inputs; i++) {
/* find the best guess input socket */
- sock_to = best_socket_input(ntree, node_to, i, replace);
+ bNodeSocket *sock_to = best_socket_input(ntree, node_to, i, replace);
if (!sock_to) {
continue;
}
/* check for an appropriate output socket to connect from */
- sock_fr = best_socket_output(ntree, node_fr, sock_to, allow_multiple);
+ bNodeSocket *sock_fr = best_socket_output(ntree, node_fr, sock_to, allow_multiple);
if (!sock_fr) {
continue;
}
@@ -411,9 +400,6 @@ static void snode_autoconnect(Main *bmain,
static int node_link_viewer(const bContext *C, bNode *tonode)
{
SpaceNode *snode = CTX_wm_space_node(C);
- bNode *node;
- bNodeLink *link;
- bNodeSocket *sock;
/* context check */
if (tonode == NULL || BLI_listbase_is_empty(&tonode->outputs)) {
@@ -424,31 +410,36 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
}
/* get viewer */
- for (node = snode->edittree->nodes.first; node; node = node->next) {
+ bNode *viewer_node = NULL;
+ LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
if (node->flag & NODE_DO_OUTPUT) {
+ viewer_node = node;
break;
}
}
}
/* no viewer, we make one active */
- if (node == NULL) {
- for (node = snode->edittree->nodes.first; node; node = node->next) {
+ if (viewer_node == NULL) {
+ LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
node->flag |= NODE_DO_OUTPUT;
+ viewer_node = node;
break;
}
}
}
- sock = NULL;
+ bNodeSocket *sock = NULL;
+ bNodeLink *link = NULL;
/* try to find an already connected socket to cycle to the next */
- if (node) {
+ if (viewer_node) {
link = NULL;
+
for (link = snode->edittree->links.first; link; link = link->next) {
- if (link->tonode == node && link->fromnode == tonode) {
- if (link->tosock == node->inputs.first) {
+ if (link->tonode == viewer_node && link->fromnode == tonode) {
+ if (link->tosock == viewer_node->inputs.first) {
break;
}
}
@@ -488,10 +479,10 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
if (sock) {
/* add a new viewer if none exists yet */
- if (!node) {
+ if (!viewer_node) {
/* XXX location is a quick hack, just place it next to the linked socket */
- node = node_add_node(C, NULL, CMP_NODE_VIEWER, sock->locx + 100, sock->locy);
- if (!node) {
+ viewer_node = node_add_node(C, NULL, CMP_NODE_VIEWER, sock->locx + 100, sock->locy);
+ if (!viewer_node) {
return OPERATOR_CANCELLED;
}
@@ -500,14 +491,14 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
else {
/* get link to viewer */
for (link = snode->edittree->links.first; link; link = link->next) {
- if (link->tonode == node && link->tosock == node->inputs.first) {
+ if (link->tonode == viewer_node && link->tosock == viewer_node->inputs.first) {
break;
}
}
}
if (link == NULL) {
- nodeAddLink(snode->edittree, tonode, sock, node, node->inputs.first);
+ nodeAddLink(snode->edittree, tonode, sock, viewer_node, viewer_node->inputs.first);
}
else {
link->fromnode = tonode;
@@ -516,7 +507,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
snode->edittree->update |= NTREE_UPDATE_LINKS;
}
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
- snode_update(snode, node);
+ snode_update(snode, viewer_node);
}
return OPERATOR_FINISHED;
@@ -525,9 +516,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
static int node_active_link_viewer_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceNode *snode = CTX_wm_space_node(C);
- bNode *node;
-
- node = nodeGetActive(snode->edittree);
+ bNode *node = nodeGetActive(snode->edittree);
if (!node) {
return OPERATOR_CANCELLED;
@@ -571,9 +560,8 @@ static void node_link_update_header(bContext *C, bNodeLinkDrag *UNUSED(nldrag))
static int node_count_links(bNodeTree *ntree, bNodeSocket *sock)
{
- bNodeLink *link;
int count = 0;
- for (link = ntree->links.first; link; link = link->next) {
+ LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
if (link->fromsock == sock) {
count++;
}
@@ -588,14 +576,12 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
{
bNodeTree *ntree = snode->edittree;
bNodeSocket *from = link->fromsock, *to = link->tosock;
- bNodeLink *tlink, *tlink_next;
int to_count = node_count_links(ntree, to);
int from_count = node_count_links(ntree, from);
int to_link_limit = nodeSocketLinkLimit(to);
int from_link_limit = nodeSocketLinkLimit(from);
- for (tlink = ntree->links.first; tlink; tlink = tlink_next) {
- tlink_next = tlink->next;
+ LISTBASE_FOREACH_MUTABLE (bNodeLink *, tlink, &ntree->links) {
if (tlink == link) {
continue;
}
@@ -624,12 +610,11 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
bNodeLinkDrag *nldrag = op->customdata;
- LinkData *linkdata;
bool do_tag_update = false;
/* avoid updates while applying links */
ntree->is_updating = true;
- for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
+ LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
bNodeLink *link = linkdata->data;
/* See note below, but basically TEST flag means that the link
@@ -688,13 +673,12 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeLinkDrag *nldrag = op->customdata;
- bNode *tnode;
- bNodeSocket *tsock = NULL;
- LinkData *linkdata;
if (nldrag->in_out == SOCK_OUT) {
+ bNode *tnode;
+ bNodeSocket *tsock = NULL;
if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_IN)) {
- for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
+ LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
bNodeLink *link = linkdata->data;
/* skip if this is already the target socket */
@@ -712,7 +696,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
}
}
else {
- for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
+ LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
bNodeLink *link = linkdata->data;
link->tonode = NULL;
@@ -721,8 +705,10 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
}
}
else {
+ bNode *tnode;
+ bNodeSocket *tsock = NULL;
if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_OUT)) {
- for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
+ LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
bNodeLink *link = linkdata->data;
/* skip if this is already the target socket */
@@ -740,7 +726,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
}
}
else {
- for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
+ LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
bNodeLink *link = linkdata->data;
link->fromnode = NULL;
@@ -788,28 +774,25 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* return 1 when socket clicked */
static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor[2], bool detach)
{
- bNode *node;
- bNodeSocket *sock;
- bNodeLink *link, *link_next, *oplink;
bNodeLinkDrag *nldrag = NULL;
- LinkData *linkdata;
- int num_links;
/* output indicated? */
+ bNode *node;
+ bNodeSocket *sock;
if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_OUT)) {
nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
- num_links = nodeCountSocketLinks(snode->edittree, sock);
+ const int num_links = nodeCountSocketLinks(snode->edittree, sock);
int link_limit = nodeSocketLinkLimit(sock);
if (num_links > 0 && (num_links >= link_limit || detach)) {
/* dragged links are fixed on input side */
nldrag->in_out = SOCK_IN;
/* detach current links and store them in the operator data */
- for (link = snode->edittree->links.first; link; link = link_next) {
- link_next = link->next;
+ LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &snode->edittree->links) {
if (link->fromsock == sock) {
- linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
- linkdata->data = oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
+ LinkData *linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
+ bNodeLink *oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
+ linkdata->data = oplink;
*oplink = *link;
oplink->next = oplink->prev = NULL;
oplink->flag |= NODE_LINK_VALID;
@@ -834,8 +817,9 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
/* dragged links are fixed on output side */
nldrag->in_out = SOCK_OUT;
/* create a new link */
- linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
- linkdata->data = oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
+ LinkData *linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
+ bNodeLink *oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
+ linkdata->data = oplink;
oplink->fromnode = node;
oplink->fromsock = sock;
oplink->flag |= NODE_LINK_VALID;
@@ -851,17 +835,17 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
else if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN)) {
nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
- num_links = nodeCountSocketLinks(snode->edittree, sock);
+ const int num_links = nodeCountSocketLinks(snode->edittree, sock);
int link_limit = nodeSocketLinkLimit(sock);
if (num_links > 0 && (num_links >= link_limit || detach)) {
/* dragged links are fixed on output side */
nldrag->in_out = SOCK_OUT;
/* detach current links and store them in the operator data */
- for (link = snode->edittree->links.first; link; link = link_next) {
- link_next = link->next;
+ LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &snode->edittree->links) {
if (link->tosock == sock) {
- linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
- linkdata->data = oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
+ LinkData *linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
+ bNodeLink *oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
+ linkdata->data = oplink;
*oplink = *link;
oplink->next = oplink->prev = NULL;
oplink->flag |= NODE_LINK_VALID;
@@ -884,8 +868,9 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
/* dragged links are fixed on input side */
nldrag->in_out = SOCK_IN;
/* create a new link */
- linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
- linkdata->data = oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
+ LinkData *linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
+ bNodeLink *oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
+ linkdata->data = oplink;
oplink->tonode = node;
oplink->tosock = sock;
oplink->flag |= NODE_LINK_VALID;
@@ -906,16 +891,15 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *region = CTX_wm_region(C);
- bNodeLinkDrag *nldrag;
- float cursor[2];
bool detach = RNA_boolean_get(op->ptr, "detach");
+ float cursor[2];
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &cursor[0], &cursor[1]);
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
- nldrag = node_link_init(bmain, snode, cursor, detach);
+ bNodeLinkDrag *nldrag = node_link_init(bmain, snode, cursor, detach);
if (nldrag) {
op->customdata = nldrag;
@@ -993,7 +977,7 @@ void NODE_OT_link_make(wmOperatorType *ot)
/* callbacks */
ot->exec = node_make_link_exec;
- // XXX we need a special poll which checks that there are selected input/output sockets
+ /* XXX we need a special poll which checks that there are selected input/output sockets. */
ot->poll = ED_operator_node_editable;
/* flags */
@@ -1025,10 +1009,10 @@ static int cut_links_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *region = CTX_wm_region(C);
- float mcoords[256][2];
- int i = 0;
bool do_tag_update = false;
+ int i = 0;
+ float mcoords[256][2];
RNA_BEGIN (op->ptr, itemptr, "path") {
float loc[2];
@@ -1044,12 +1028,10 @@ static int cut_links_exec(bContext *C, wmOperator *op)
if (i > 1) {
bool found = false;
- bNodeLink *link, *next;
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
- for (link = snode->edittree->links.first; link; link = next) {
- next = link->next;
+ LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &snode->edittree->links) {
if (nodeLinkIsHidden(link)) {
continue;
}
@@ -1119,11 +1101,10 @@ static int detach_links_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
- bNode *node;
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->flag & SELECT) {
nodeInternalRelink(ntree, node);
}
@@ -1157,12 +1138,12 @@ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
- bNode *frame = nodeGetActive(ntree), *node;
+ bNode *frame = nodeGetActive(ntree);
if (!frame || frame->type != NODE_FRAME) {
return OPERATOR_CANCELLED;
}
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node == frame) {
continue;
}
@@ -1233,11 +1214,10 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
- bNode *node, *frame;
/* XXX save selection: node_add_node call below sets the new frame as single
* active+selected node */
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->flag & NODE_SELECT) {
node->flag |= NODE_TEST;
}
@@ -1246,21 +1226,21 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- frame = node_add_node(C, NULL, NODE_FRAME, 0.0f, 0.0f);
+ bNode *frame = node_add_node(C, NULL, NODE_FRAME, 0.0f, 0.0f);
/* reset tags */
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
node->done = 0;
}
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (!(node->done & NODE_JOIN_DONE)) {
node_join_attach_recursive(node, frame);
}
}
/* restore selection */
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->flag & NODE_TEST) {
node->flag |= NODE_SELECT;
}
@@ -1293,14 +1273,11 @@ static bNode *node_find_frame_to_attach(ARegion *region,
const bNodeTree *ntree,
const int mouse_xy[2])
{
- bNode *frame;
- float cursor[2];
-
/* convert mouse coordinates to v2d space */
+ float cursor[2];
UI_view2d_region_to_view(&region->v2d, UNPACK2(mouse_xy), &cursor[0], &cursor[1]);
- /* check nodes front to back */
- for (frame = ntree->nodes.last; frame; frame = frame->prev) {
+ LISTBASE_FOREACH_BACKWARD (bNode *, frame, &ntree->nodes) {
/* skip selected, those are the nodes we want to attach */
if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) {
continue;
@@ -1321,8 +1298,7 @@ static int node_attach_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
bNode *frame = node_find_frame_to_attach(region, ntree, event->mval);
if (frame) {
- bNode *node, *parent;
- for (node = ntree->nodes.last; node; node = node->prev) {
+ LISTBASE_FOREACH_BACKWARD (bNode *, node, &ntree->nodes) {
if (node->flag & NODE_SELECT) {
if (node->parent == NULL) {
/* disallow moving a parent into its child */
@@ -1333,6 +1309,7 @@ static int node_attach_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
}
else {
/* attach nodes which share parent with the frame */
+ bNode *parent;
for (parent = frame->parent; parent; parent = parent->parent) {
if (parent == node->parent) {
break;
@@ -1409,16 +1386,15 @@ static int node_detach_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
- bNode *node;
/* reset tags */
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
node->done = 0;
}
/* detach nodes recursively
* relative order is preserved here!
*/
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (!(node->done & NODE_DETACH_DONE)) {
node_detach_recursive(node);
}
@@ -1454,8 +1430,6 @@ static bool ed_node_link_conditions(ScrArea *area,
bNode **r_select)
{
SpaceNode *snode = area ? area->spacedata.first : NULL;
- bNode *node, *select = NULL;
- bNodeLink *link;
*r_snode = snode;
*r_select = NULL;
@@ -1470,6 +1444,8 @@ static bool ed_node_link_conditions(ScrArea *area,
return true;
}
+ bNode *node;
+ bNode *select = NULL;
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
if (select) {
@@ -1489,7 +1465,7 @@ static bool ed_node_link_conditions(ScrArea *area,
}
/* test node for links */
- for (link = snode->edittree->links.first; link; link = link->next) {
+ LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
if (nodeLinkIsHidden(link)) {
continue;
}
@@ -1508,15 +1484,12 @@ 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(area, test, &snode, &select)) {
return;
}
/* clear flags */
- for (link = snode->edittree->links.first; link; link = link->next) {
+ LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
link->flag &= ~NODE_LINKFLAG_HILITE;
}
@@ -1525,7 +1498,9 @@ void ED_node_link_intersect_test(ScrArea *area, int test)
}
/* find link to select/highlight */
- for (link = snode->edittree->links.first; link; link = link->next) {
+ bNodeLink *selink = NULL;
+ float dist_best = FLT_MAX;
+ LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
float coord_array[NODE_LINK_RESOL + 1][2];
if (nodeLinkIsHidden(link)) {
@@ -1567,17 +1542,15 @@ void ED_node_link_intersect_test(ScrArea *area, int test)
/* assumes sockets in list */
static bNodeSocket *socket_best_match(ListBase *sockets)
{
- bNodeSocket *sock;
- int type, maxtype = 0;
-
/* find type range */
- for (sock = sockets->first; sock; sock = sock->next) {
+ int maxtype = 0;
+ LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
maxtype = max_ii(sock->type, maxtype);
}
/* try all types, starting from 'highest' (i.e. colors, vectors, values) */
- for (type = maxtype; type >= 0; type--) {
- for (sock = sockets->first; sock; sock = sock->next) {
+ for (int type = maxtype; type >= 0; type--) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
if (!nodeSocketIsHidden(sock) && type == sock->type) {
return sock;
}
@@ -1585,8 +1558,8 @@ static bNodeSocket *socket_best_match(ListBase *sockets)
}
/* no visible sockets, unhide first of highest type */
- for (type = maxtype; type >= 0; type--) {
- for (sock = sockets->first; sock; sock = sock->next) {
+ for (int type = maxtype; type >= 0; type--) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
if (type == sock->type) {
sock->flag &= ~SOCK_HIDDEN;
return sock;
@@ -1617,13 +1590,11 @@ static void node_offset_apply(bNode *node, const float offset_x)
static void node_parent_offset_apply(NodeInsertOfsData *data, bNode *parent, const float offset_x)
{
- bNode *node;
-
node_offset_apply(parent, offset_x);
/* Flag all children as offset to prevent them from being offset
* separately (they've already moved with the parent). */
- for (node = data->ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &data->ntree->nodes) {
if (nodeIsChildOf(parent, node)) {
/* NODE_TEST is used to flag nodes that shouldn't be offset (again) */
node->flag |= NODE_TEST;
@@ -1663,9 +1634,7 @@ static void node_link_insert_offset_frame_chains(const bNodeTree *ntree,
NodeInsertOfsData *data,
const bool reversed)
{
- bNode *node;
-
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (nodeIsChildOf(parent, node)) {
nodeChainIter(ntree, node, node_link_insert_offset_frame_chain_cb, data, reversed);
}
@@ -1717,20 +1686,19 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd,
bNode *insert = iofsd->insert;
bNode *prev = iofsd->prev, *next = iofsd->next;
bNode *init_parent = insert->parent; /* store old insert->parent for restoring later */
- rctf totr_insert;
const float min_margin = U.node_margin * UI_DPI_FAC;
const float width = NODE_WIDTH(insert);
const bool needs_alignment = (next->totr.xmin - prev->totr.xmax) < (width + (min_margin * 2.0f));
float margin = width;
- float dist, addval;
/* NODE_TEST will be used later, so disable for all nodes */
ntreeNodeFlagSet(ntree, NODE_TEST, false);
/* insert->totr isn't updated yet,
* so totr_insert is used to get the correct worldspace coords */
+ rctf totr_insert;
node_to_updated_rect(insert, &totr_insert);
/* frame attachment wasn't handled yet
@@ -1770,10 +1738,11 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd,
/* *** ensure offset at the left (or right for right_alignment case) of insert_node *** */
- dist = right_alignment ? totr_insert.xmin - prev->totr.xmax : next->totr.xmin - totr_insert.xmax;
+ float dist = right_alignment ? totr_insert.xmin - prev->totr.xmax :
+ next->totr.xmin - totr_insert.xmax;
/* distance between insert_node and prev is smaller than min margin */
if (dist < min_margin) {
- addval = (min_margin - dist) * (right_alignment ? 1.0f : -1.0f);
+ const float addval = (min_margin - dist) * (right_alignment ? 1.0f : -1.0f);
node_offset_apply(insert, addval);
@@ -1787,7 +1756,7 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd,
dist = right_alignment ? next->totr.xmin - totr_insert.xmax : totr_insert.xmin - prev->totr.xmax;
/* distance between insert_node and next is smaller than min margin */
if (dist < min_margin) {
- addval = (min_margin - dist) * (right_alignment ? 1.0f : -1.0f);
+ const float addval = (min_margin - dist) * (right_alignment ? 1.0f : -1.0f);
if (needs_alignment) {
bNode *offs_node = right_alignment ? next : prev;
if (!offs_node->parent || offs_node->parent == insert->parent ||
@@ -1830,19 +1799,17 @@ static int node_insert_offset_modal(bContext *C, wmOperator *UNUSED(op), const w
{
SpaceNode *snode = CTX_wm_space_node(C);
NodeInsertOfsData *iofsd = snode->iofsd;
- bNode *node;
- float duration;
bool redraw = false;
if (!snode || event->type != TIMER || iofsd == NULL || iofsd->anim_timer != event->customdata) {
return OPERATOR_PASS_THROUGH;
}
- duration = (float)iofsd->anim_timer->duration;
+ const float duration = (float)iofsd->anim_timer->duration;
/* handle animation - do this before possibly aborting due to duration, since
* main thread might be so busy that node hasn't reached final position yet */
- for (node = snode->edittree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
if (UNLIKELY(node->anim_ofsx)) {
const float endval = node->anim_init_locx + node->anim_ofsx;
if (IS_EQF(node->locx, endval) == false) {
@@ -1866,7 +1833,7 @@ static int node_insert_offset_modal(bContext *C, wmOperator *UNUSED(op), const w
if (duration > NODE_INSOFS_ANIM_DURATION) {
WM_event_remove_timer(CTX_wm_manager(C), NULL, iofsd->anim_timer);
- for (node = snode->edittree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
node->anim_init_locx = node->anim_ofsx = 0.0f;
}
@@ -1923,16 +1890,14 @@ void NODE_OT_insert_offset(wmOperatorType *ot)
/* assumes link with NODE_LINKFLAG_HILITE set */
void ED_node_link_insert(Main *bmain, ScrArea *area)
{
- bNode *node, *select;
+ bNode *select;
SpaceNode *snode;
- bNodeLink *link;
- bNodeSocket *sockto;
-
if (!ed_node_link_conditions(area, true, &snode, &select)) {
return;
}
/* get the link */
+ bNodeLink *link;
for (link = snode->edittree->links.first; link; link = link->next) {
if (link->flag & NODE_LINKFLAG_HILITE) {
break;
@@ -1944,8 +1909,8 @@ void ED_node_link_insert(Main *bmain, ScrArea *area)
bNodeSocket *best_output = socket_best_match(&select->outputs);
if (best_input && best_output) {
- node = link->tonode;
- sockto = link->tosock;
+ bNode *node = link->tonode;
+ bNodeSocket *sockto = link->tosock;
link->tonode = select;
link->tosock = best_input;
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index ce66740dc60..fca8086d36f 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -607,7 +607,7 @@ static int sample_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
switch (event->type) {
case LEFTMOUSE:
- case RIGHTMOUSE: // XXX hardcoded
+ case RIGHTMOUSE: /* XXX hardcoded */
if (event->val == KM_RELEASE) {
sample_exit(C, op);
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index cbe6887f66e..6c0975498e0 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -847,6 +847,10 @@ static bool datastack_drop_poll(bContext *C,
const wmEvent *event,
const char **r_tooltip)
{
+ if (drag->type != WM_DRAG_DATASTACK) {
+ return false;
+ }
+
SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ARegion *region = CTX_wm_region(C);
bool changed = outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED | TSE_DRAG_ANY, false);
@@ -1363,16 +1367,18 @@ static int outliner_item_drag_drop_invoke(bContext *C,
WM_operator_properties_free(&op_ptr);
}
- wmDrag *drag = WM_event_start_drag(C, data.icon, WM_DRAG_ID, NULL, 0.0, WM_DRAG_NOP);
+ const bool use_datastack_drag = ELEM(tselem->type,
+ TSE_MODIFIER,
+ TSE_MODIFIER_BASE,
+ TSE_CONSTRAINT,
+ TSE_CONSTRAINT_BASE,
+ TSE_GPENCIL_EFFECT,
+ TSE_GPENCIL_EFFECT_BASE);
- if (ELEM(tselem->type,
- TSE_MODIFIER,
- TSE_MODIFIER_BASE,
- TSE_CONSTRAINT,
- TSE_CONSTRAINT_BASE,
- TSE_GPENCIL_EFFECT,
- TSE_GPENCIL_EFFECT_BASE)) {
+ const int wm_drag_type = use_datastack_drag ? WM_DRAG_DATASTACK : WM_DRAG_ID;
+ wmDrag *drag = WM_event_start_drag(C, data.icon, wm_drag_type, NULL, 0.0, WM_DRAG_NOP);
+ if (use_datastack_drag) {
TreeElement *te_bone = NULL;
bPoseChannel *pchan = outliner_find_parent_bone(te, &te_bone);
datastack_drop_data_init(drag, (Object *)tselem->id, pchan, te, tselem, te->directdata);
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 22bc0119652..09ccb950c18 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2915,9 +2915,9 @@ static void outliner_set_coord_tree_element(TreeElement *te, int startx, int sta
/* closed items may be displayed in row of parent, don't change their coordinate! */
if ((te->flag & TE_ICONROW) == 0 && (te->flag & TE_ICONROW_MERGED) == 0) {
- /* store coord and continue, we need coordinates for elements outside view too */
- te->xs = startx;
- te->ys = starty;
+ te->xs = 0;
+ te->ys = 0;
+ te->xend = 0;
}
for (ten = te->subtree.first; ten; ten = ten->next) {
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index abfec4fc2aa..779efc3cacb 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -363,50 +363,47 @@ void item_rename_fn(bContext *C,
do_item_rename(region, te, tselem, reports);
}
-static void do_outliner_item_rename(ReportList *reports,
- ARegion *region,
- TreeElement *te,
- const float mval[2])
+static TreeElement *outliner_item_rename_find_active(const SpaceOutliner *space_outliner,
+ ReportList *reports)
{
- if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
- TreeStoreElem *tselem = TREESTORE(te);
+ TreeElement *active_element = outliner_find_element_with_flag(&space_outliner->tree, TSE_ACTIVE);
- /* click on name */
- if (mval[0] > te->xs + UI_UNIT_X * 2 && mval[0] < te->xend) {
- do_item_rename(region, te, tselem, reports);
- }
+ if (!active_element) {
+ BKE_report(reports, RPT_WARNING, "No active item to rename");
+ return NULL;
}
- LISTBASE_FOREACH (TreeElement *, te_child, &te->subtree) {
- do_outliner_item_rename(reports, region, te_child, mval);
+ return active_element;
+}
+
+static TreeElement *outliner_item_rename_find_hovered(const SpaceOutliner *space_outliner,
+ ARegion *region,
+ const wmEvent *event)
+{
+ float fmval[2];
+ UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
+
+ TreeElement *hovered = outliner_find_item_at_y(space_outliner, &space_outliner->tree, fmval[1]);
+ if (hovered && outliner_item_is_co_over_name(hovered, fmval[0])) {
+ return hovered;
}
+
+ return NULL;
}
static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
- float fmval[2];
-
- /* Rename active element if key pressed, otherwise rename element at cursor coordinates */
- if (event->val == KM_PRESS) {
- TreeElement *active_element = outliner_find_element_with_flag(&space_outliner->tree,
- TSE_ACTIVE);
+ const bool use_active = RNA_boolean_get(op->ptr, "use_active");
- if (active_element) {
- do_item_rename(region, active_element, TREESTORE(active_element), op->reports);
- }
- else {
- BKE_report(op->reports, RPT_WARNING, "No active item to rename");
- }
+ TreeElement *te = use_active ? outliner_item_rename_find_active(space_outliner, op->reports) :
+ outliner_item_rename_find_hovered(space_outliner, region, event);
+ if (!te) {
+ return OPERATOR_CANCELLED;
}
- else {
- UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
- LISTBASE_FOREACH (TreeElement *, te, &space_outliner->tree) {
- do_outliner_item_rename(op->reports, region, te, fmval);
- }
- }
+ do_item_rename(region, te, TREESTORE(te), op->reports);
return OPERATOR_FINISHED;
}
@@ -423,6 +420,12 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot)
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna,
+ "use_active",
+ false,
+ "Use Active",
+ "Rename the active item, rather than the one the mouse is over");
}
/** \} */
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 9ef3d8eed7a..382078f006b 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -236,7 +236,9 @@ void outliner_build_tree(struct Main *mainvar,
struct SpaceOutliner *space_outliner,
struct ARegion *region);
-bool outliner_mode_requires_always_rebuild(const struct SpaceOutliner *space_outliner);
+bool outliner_requires_rebuild_on_select_or_active_change(
+ const struct SpaceOutliner *space_outliner);
+bool outliner_requires_rebuild_on_open_change(const struct SpaceOutliner *space_outliner);
typedef struct IDsSelectedData {
struct ListBase selected_array;
@@ -284,6 +286,7 @@ void outliner_item_select(struct bContext *C,
const short select_flag);
bool outliner_item_is_co_over_name_icons(const TreeElement *te, float view_co_x);
+bool outliner_item_is_co_over_name(const TreeElement *te, float view_co_x);
bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_co_x);
bool outliner_is_co_within_mode_column(SpaceOutliner *space_outliner, const float view_mval[2]);
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 7e450af4802..3357b0b7346 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -1791,7 +1791,7 @@ static bool outliner_id_operation_item_poll(bContext *C,
return true;
}
/* TODO(dalai): enable in the few cases where this can be supported
- (i.e., when we have a valid parent for the tselem). */
+ * (i.e., when we have a valid parent for the tselem). */
return false;
}
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 632f7d63ad4..c44a1554478 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -94,6 +94,7 @@ static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outli
Collection *collection,
TreeElement *ten);
static void outliner_make_object_parent_hierarchy(ListBase *lb);
+static int outliner_exclude_filter_get(const SpaceOutliner *space_outliner);
/* ********************************************************* */
/* Persistent Data */
@@ -245,11 +246,19 @@ static TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
/* -------------------------------------------------------- */
+bool outliner_requires_rebuild_on_select_or_active_change(const SpaceOutliner *space_outliner)
+{
+ int exclude_flags = outliner_exclude_filter_get(space_outliner);
+ /* Need to rebuild tree to re-apply filter if select/active changed while filtering based on
+ * select/active. */
+ return exclude_flags & (SO_FILTER_OB_STATE_SELECTED | SO_FILTER_OB_STATE_ACTIVE);
+}
+
/**
* Check if a display mode needs a full rebuild if the open/collapsed state changes.
* Element types in these modes don't actually add children if collapsed, so the rebuild is needed.
*/
-bool outliner_mode_requires_always_rebuild(const SpaceOutliner *space_outliner)
+bool outliner_requires_rebuild_on_open_change(const SpaceOutliner *space_outliner)
{
return ELEM(space_outliner->outlinevis, SO_DATA_API);
}
@@ -2164,7 +2173,7 @@ static void outliner_store_scrolling_position(SpaceOutliner *space_outliner,
}
}
-static int outliner_exclude_filter_get(SpaceOutliner *space_outliner)
+static int outliner_exclude_filter_get(const SpaceOutliner *space_outliner)
{
int exclude_filter = space_outliner->filter & ~SO_FILTER_OB_STATE;
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index 4db465111b2..c1551b5c584 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -429,6 +429,12 @@ bool outliner_item_is_co_over_name_icons(const TreeElement *te, float view_co_x)
return outside_left && (view_co_x < te->xend);
}
+/* Find if x coordinate is over element name. */
+bool outliner_item_is_co_over_name(const TreeElement *te, float view_co_x)
+{
+ return (view_co_x > (te->xs + UI_UNIT_X * 2)) && (view_co_x < te->xend);
+}
+
/* Find if x coordinate is over element disclosure toggle */
bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_co_x)
{
@@ -466,7 +472,7 @@ void outliner_tag_redraw_avoid_rebuild_on_open_change(const SpaceOutliner *space
ARegion *region)
{
/* Avoid rebuild if possible. */
- if (outliner_mode_requires_always_rebuild(space_outliner)) {
+ if (outliner_requires_rebuild_on_open_change(space_outliner)) {
ED_region_tag_redraw(region);
}
else {
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 2ed834a15dd..8be7f4d1bad 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -102,18 +102,25 @@ static void outliner_main_region_free(ARegion *UNUSED(region))
}
static void outliner_main_region_listener(wmWindow *UNUSED(win),
- ScrArea *UNUSED(area),
+ ScrArea *area,
ARegion *region,
wmNotifier *wmn,
const Scene *UNUSED(scene))
{
+ SpaceOutliner *space_outliner = area->spacedata.first;
+
/* context changes */
switch (wmn->category) {
case NC_SCENE:
switch (wmn->data) {
case ND_OB_ACTIVE:
case ND_OB_SELECT:
- ED_region_tag_redraw_no_rebuild(region);
+ if (outliner_requires_rebuild_on_select_or_active_change(space_outliner)) {
+ ED_region_tag_redraw(region);
+ }
+ else {
+ ED_region_tag_redraw_no_rebuild(region);
+ }
break;
case ND_OB_VISIBLE:
case ND_OB_RENDER:
diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c
index 56f99d31cf1..bde7bdb77f1 100644
--- a/source/blender/editors/space_script/script_edit.c
+++ b/source/blender/editors/space_script/script_edit.c
@@ -39,7 +39,7 @@
#include "ED_screen.h"
-#include "script_intern.h" // own include
+#include "script_intern.h" /* own include */
#ifdef WITH_PYTHON
# include "BPY_extern_run.h"
diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c
index 3c3f7dc1e8e..3330ba14530 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -45,7 +45,7 @@
#endif
#include "GPU_framebuffer.h"
-#include "script_intern.h" // own include
+#include "script_intern.h" /* own include */
// static script_run_python(char *funcname, )
@@ -85,8 +85,6 @@ static void script_free(SpaceLink *sl)
#ifdef WITH_PYTHON
/*free buttons references*/
if (sscript->but_refs) {
- // XXX BPy_Set_DrawButtonsList(sscript->but_refs);
- // BPy_Free_DrawButtonsList();
sscript->but_refs = NULL;
}
#endif
@@ -164,9 +162,11 @@ static void script_main_region_listener(wmWindow *UNUSED(win),
wmNotifier *UNUSED(wmn),
const Scene *UNUSED(scene))
{
- /* context changes */
- // XXX - Todo, need the ScriptSpace accessible to get the python script to run.
- // BPY_run_script_space_listener()
+/* context changes */
+/* XXX - Todo, need the ScriptSpace accessible to get the python script to run. */
+#if 0
+ BPY_run_script_space_listener()
+#endif
}
/* only called once, from space/spacetypes.c */
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 962c4e4c59d..0725109944a 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -182,7 +182,7 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, i
RNA_int_set(op->ptr, "frame_start", cfra);
if ((flag & SEQPROP_ENDFRAME) && RNA_struct_property_is_set(op->ptr, "frame_end") == 0) {
- RNA_int_set(op->ptr, "frame_end", cfra + 25); // XXX arbitrary but ok for now.
+ RNA_int_set(op->ptr, "frame_end", cfra + 25); /* XXX arbitrary but ok for now. */
}
if (!(flag & SEQPROP_NOPATHS)) {
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 38b5ebaf78c..89d6d647ada 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -2299,7 +2299,10 @@ void draw_timeline_seq(const bContext *C, ARegion *region)
}
/* Draw attached callbacks. */
+ GPU_framebuffer_bind(framebuffer_overlay);
ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW);
+ GPU_framebuffer_bind_no_srgb(framebuffer_overlay);
+
seq_draw_sfra_efra(scene, v2d);
if (ed) {
@@ -2353,7 +2356,10 @@ void draw_timeline_seq(const bContext *C, ARegion *region)
ANIM_draw_previewrange(C, v2d, 1);
/* Draw registered callbacks. */
+ GPU_framebuffer_bind(framebuffer_overlay);
ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW);
+ GPU_framebuffer_bind_no_srgb(framebuffer_overlay);
+
UI_view2d_view_restore(C);
ED_time_scrub_draw(region, scene, !(sseq->flag & SEQ_DRAWFRAMES), true);
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index e446a1a5ed7..8a705ef49dd 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -2134,7 +2134,7 @@ static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op)
Sequence *seq1, *seq2, *seq3, *last_seq = BKE_sequencer_active_get(scene);
const char *error_msg;
- if (BKE_sequence_effect_get_num_inputs(last_seq->type) != 0) {
+ if (BKE_sequence_effect_get_num_inputs(last_seq->type) == 0) {
BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: strip has no inputs");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index e041ce3184e..0a4a1ae92d9 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -182,7 +182,7 @@ static void select_linked_time(ListBase *seqbase, Sequence *seq_link)
}
}
-#if 0 // BRING BACK
+#if 0 /* BRING BACK */
void select_surround_from_last(Scene *scene)
{
Sequence *seq = get_last_seq(scene);
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index ec5175eae51..d3e6fd8f79c 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -1094,7 +1094,7 @@ static void draw_documentation(const SpaceText *st, ARegion *region)
i = 0;
br = DOC_WIDTH;
- lines = 0; // XXX -doc_scroll;
+ lines = 0; /* XXX -doc_scroll; */
for (p = docs; *p; p++) {
if (*p == '\r' && *(++p) != '\n') {
*(--p) = '\n'; /* Fix line endings */
@@ -1400,7 +1400,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
char ch;
- // syntax_highlight must be on or else the format string will be null
+ /* syntax_highlight must be on or else the format string will be null */
if (!text->curl || !tdc->syntax_highlight) {
return;
}
diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c
index c4052fcef84..c583634f440 100644
--- a/source/blender/editors/space_text/text_header.c
+++ b/source/blender/editors/space_text/text_header.c
@@ -113,7 +113,7 @@ void TEXT_OT_start_find(wmOperatorType *ot)
#if 0
{
- // RMB
+ /* RMB */
uiPopupMenu *pup;
@@ -140,7 +140,7 @@ void TEXT_OT_start_find(wmOperatorType *ot)
}
{
- // Alt+Shift+E
+ /* Alt+Shift+E */
uiPopupMenu *pup;
@@ -152,7 +152,7 @@ void TEXT_OT_start_find(wmOperatorType *ot)
}
{
- // Alt+Shift+F
+ /* Alt+Shift+F */
uiPopupMenu *pup;
@@ -174,7 +174,7 @@ void TEXT_OT_start_find(wmOperatorType *ot)
}
{
- // Alt+Shift+V
+ /* Alt+Shift+V */
uiPopupMenu *pup;
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 2ae8d4cde7a..5c7f84ea386 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -407,7 +407,7 @@ void TEXT_OT_open(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA); // XXX TODO, relative_path
+ FILE_SORT_ALPHA); /* TODO: relative_path. */
RNA_def_boolean(
ot->srna, "internal", 0, "Make internal", "Make text file internal after loading");
}
@@ -733,7 +733,7 @@ void TEXT_OT_save_as(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA); // XXX TODO, relative_path
+ FILE_SORT_ALPHA); /* XXX TODO, relative_path. */
}
/** \} */
@@ -1208,7 +1208,7 @@ static int text_line_break_exec(bContext *C, wmOperator *UNUSED(op))
text_drawcache_tag_update(st, 0);
- // double check tabs/spaces before splitting the line
+ /* Double check tabs/spaces before splitting the line. */
curts = txt_setcurr_tab_spaces(text, space);
ED_text_undo_push_init(C);
txt_split_curline(text);
@@ -3463,7 +3463,8 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
int ret;
- // if (!RNA_struct_property_is_set(op->ptr, "text")) { /* always set from keymap XXX */
+ /* Note, the "text" property is always set from key-map,
+ * so we can't use #RNA_struct_property_is_set, check the length instead. */
if (!RNA_string_length(op->ptr, "text")) {
/* if alt/ctrl/super are pressed pass through except for utf8 character event
* (when input method are used for utf8 inputs, the user may assign key event
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 66ce06bb340..1f4c0dd9eb1 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -102,7 +102,7 @@
#define M_GOLDEN_RATIO_CONJUGATE 0.618033988749895f
-#define VIEW3D_OVERLAY_LINEHEIGHT (0.9f * U.widget_unit)
+#define VIEW3D_OVERLAY_LINEHEIGHT (int)(1.1f * BLF_default_height_max())
/* -------------------------------------------------------------------- */
/** \name General Functions
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
index e17993445df..aa8905721b4 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
@@ -364,16 +364,19 @@ static int gizmo_preselect_edgering_test_select(bContext *C, wmGizmo *gz, const
}
else {
if (best.eed) {
- const float(*coords)[3] = NULL;
- {
- Object *ob = gz_ring->bases[gz_ring->base_index]->object;
- Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(depsgraph, ob->data);
- if (me_eval->runtime.edit_data) {
- coords = me_eval->runtime.edit_data->vertexCos;
- }
- }
+ Object *ob = gz_ring->bases[gz_ring->base_index]->object;
+ Scene *scene_eval = (Scene *)DEG_get_evaluated_id(vc.depsgraph, &vc.scene->id);
+ Object *ob_eval = DEG_get_evaluated_object(vc.depsgraph, ob);
+ BMEditMesh *em_eval = BKE_editmesh_from_object(ob_eval);
+ /* Re-allocate coords each update isn't ideal, however we can't be sure
+ * the mesh hasn't been edited since last update. */
+ bool is_alloc = false;
+ const float(*coords)[3] = BKE_editmesh_vert_coords_when_deformed(
+ vc.depsgraph, em_eval, scene_eval, ob_eval, NULL, &is_alloc);
EDBM_preselect_edgering_update_from_edge(gz_ring->psel, bm, best.eed, 1, coords);
+ if (is_alloc) {
+ MEM_freeN((void *)coords);
+ }
}
else {
EDBM_preselect_edgering_clear(gz_ring->psel);
diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c
index e073cb43962..0afa44b6f4f 100644
--- a/source/blender/editors/space_view3d/view3d_project.c
+++ b/source/blender/editors/space_view3d/view3d_project.c
@@ -776,7 +776,7 @@ void ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d,
* a point in world space. */
void ED_view3d_project(const struct ARegion *region, const float world[3], float r_region_co[3])
{
- // viewport is set up to make coordinates relative to the region, not window
+ /* Viewport is set up to make coordinates relative to the region, not window. */
RegionView3D *rv3d = region->regiondata;
const int viewport[4] = {0, 0, region->winx, region->winy};
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index fc71648acfb..3f758c0fda3 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -2299,7 +2299,7 @@ static bool ed_object_select_pick(bContext *C,
/* Set special modes for grease pencil
* The grease pencil modes are not real modes, but a hack to make the interface
* consistent, so need some tricks to keep UI synchronized */
- // XXX: This stuff needs reviewing (Aligorith)
+ /* XXX: This stuff needs reviewing (Aligorith) */
if (false && (((oldbasact) && oldbasact->object->type == OB_GPENCIL) ||
(basact->object->type == OB_GPENCIL))) {
/* set cursor */
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index 92d86f6bebb..dcb3179a46d 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -213,7 +213,7 @@ void view3d_region_operator_needs_opengl(wmWindow *UNUSED(win), ARegion *region)
else {
RegionView3D *rv3d = region->regiondata;
- wmViewport(&region->winrct); // TODO: bad
+ wmViewport(&region->winrct); /* TODO: bad */
GPU_matrix_projection_set(rv3d->winmat);
GPU_matrix_set(rv3d->viewmat);
}
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 0d350d0e7d4..b05ff207e82 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1782,8 +1782,8 @@ bool ED_view3d_is_region_xr_mirror_active(const wmWindowManager *wm,
const ARegion *region)
{
return (v3d->flag & V3D_XR_SESSION_MIRROR) &&
- /* The free region (e.g. the camera region in quad-view) is always the last in the list
- base. We don't want any other to be affected. */
+ /* The free region (e.g. the camera region in quad-view) is always
+ * the last in the list base. We don't want any other to be affected. */
!region->next && //
WM_xr_session_is_ready(&wm->xr);
}
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index ef389918eb4..1d89b040b85 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -1450,7 +1450,7 @@ static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event)
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, walk_object);
}
- // too frequent, commented with NDOF_WALK_DRAW_TOOMUCH for now
+ /* too frequent, commented with NDOF_WALK_DRAW_TOOMUCH for now */
// puts("redraw!");
ED_region_tag_redraw(CTX_wm_region(C));
}
diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt
index 59fdf1450b3..5bf8450246b 100644
--- a/source/blender/editors/transform/CMakeLists.txt
+++ b/source/blender/editors/transform/CMakeLists.txt
@@ -107,6 +107,7 @@ set(SRC
transform_data.h
transform_draw_cursors.h
transform_mode.h
+ transform_orientations.h
transform_snap.h
)
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index a0374d733ea..4e08b6b1c5d 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -65,11 +65,12 @@
#include "transform_convert.h"
#include "transform_draw_cursors.h"
#include "transform_mode.h"
+#include "transform_orientations.h"
#include "transform_snap.h"
/* Disabling, since when you type you know what you are doing,
* and being able to set it to zero is handy. */
-// #define USE_NUM_NO_ZERO
+/* #define USE_NUM_NO_ZERO */
static void drawTransformApply(const struct bContext *C, ARegion *region, void *arg);
@@ -268,7 +269,7 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
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));
+ // vec[0] = vec[0] / ((t->scene->r.frs_sec / t->scene->r.frs_sec_base));
/* same as below */
UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]);
}
@@ -446,7 +447,7 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
}
/* For real-time animation record - send notifiers recognized by animation editors */
- // XXX: is this notifier a lame duck?
+ /* XXX: is this notifier a lame duck? */
if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
}
@@ -486,7 +487,7 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
ED_area_tag_redraw(t->area);
}
else {
- // XXX how to deal with lock?
+ /* XXX how to deal with lock? */
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);
@@ -538,7 +539,7 @@ static void viewRedrawPost(bContext *C, TransInfo *t)
WM_event_add_notifier(C, NC_SCENE | ND_TRANSFORM_DONE, CTX_data_scene(C));
}
-#if 0 // TRANSFORM_FIX_ME
+#if 0 /* TRANSFORM_FIX_ME */
if (t->spacetype == SPACE_VIEW3D) {
allqueue(REDRAWBUTSOBJECT, 0);
allqueue(REDRAWVIEW3D, 0);
@@ -813,7 +814,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
applyMouseInput(t, &t->mouse, t->mval, t->values);
- // Snapping mouse move events
+ /* Snapping mouse move events. */
t->redraw |= handleSnapping(t, event);
handled = true;
}
@@ -853,7 +854,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
resetTransRestrictions(t);
transform_mode_init(t, NULL, TFM_TRANSLATION);
}
- initSnapping(t, NULL); // need to reinit after mode change
+ initSnapping(t, NULL); /* need to reinit after mode change */
t->redraw |= TREDRAW_HARD;
handled = true;
}
@@ -875,7 +876,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
resetTransModal(t);
resetTransRestrictions(t);
transform_mode_init(t, NULL, TFM_TRANSLATION);
- initSnapping(t, NULL); // need to reinit after mode change
+ initSnapping(t, NULL); /* need to reinit after mode change */
t->redraw |= TREDRAW_HARD;
handled = true;
}
@@ -894,7 +895,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
else {
transform_mode_init(t, NULL, TFM_ROTATION);
}
- initSnapping(t, NULL); // need to reinit after mode change
+ initSnapping(t, NULL); /* need to reinit after mode change */
t->redraw |= TREDRAW_HARD;
handled = true;
}
@@ -926,7 +927,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
resetTransModal(t);
resetTransRestrictions(t);
transform_mode_init(t, NULL, TFM_RESIZE);
- initSnapping(t, NULL); // need to reinit after mode change
+ initSnapping(t, NULL); /* need to reinit after mode change */
t->redraw |= TREDRAW_HARD;
handled = true;
}
@@ -1274,9 +1275,9 @@ bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], floa
/* avoid doing connectivity lookups (when V3D_AROUND_LOCAL_ORIGINS is set) */
t->around = V3D_AROUND_CENTER_BOUNDS;
- createTransData(C, t); // make TransData structs from selection
+ createTransData(C, t); /* make TransData structs from selection */
- t->around = centerMode; // override userdefined mode
+ t->around = centerMode; /* override userdefined mode */
if (t->data_len_all == 0) {
success = false;
@@ -1291,7 +1292,7 @@ bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], floa
}
if (cent3d) {
- // Copy center from constraint center. Transform center can be local
+ /* Copy center from constraint center. Transform center can be local */
copy_v3_v3(cent3d, t->center_global);
}
}
@@ -1446,7 +1447,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
t->orient[0].type = V3D_ORIENT_GLOBAL;
}
- // Save back mode in case we're in the generic operator
+ /* Save back mode in case we're in the generic operator */
if ((prop = RNA_struct_find_property(op->ptr, "mode"))) {
RNA_property_enum_set(op->ptr, prop, t->mode);
}
@@ -1474,7 +1475,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
}
- // If modal, save settings back in scene if not set as operator argument
+ /* If modal, save settings back in scene if not set as operator argument */
if ((t->flag & T_MODAL) || (op->flag & OP_IS_REPEAT)) {
/* save settings if not set in operator */
@@ -1622,40 +1623,34 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
}
-static void initSnapSpatial(TransInfo *t, float r_snap[3])
+static void initSnapSpatial(TransInfo *t, float r_snap[2])
{
if (t->spacetype == SPACE_VIEW3D) {
RegionView3D *rv3d = t->region->regiondata;
if (rv3d) {
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;
+ r_snap[0] = ED_view3d_grid_view_scale(t->scene, v3d, rv3d, NULL) * 1.0f;
+ r_snap[1] = r_snap[0] * 0.1f;
}
}
else if (t->spacetype == SPACE_IMAGE) {
- r_snap[0] = 0.0f;
- r_snap[1] = 0.0625f;
- r_snap[2] = 0.03125f;
+ r_snap[0] = 0.0625f;
+ r_snap[1] = 0.03125f;
}
else if (t->spacetype == SPACE_CLIP) {
- r_snap[0] = 0.0f;
- r_snap[1] = 0.125f;
- r_snap[2] = 0.0625f;
+ r_snap[0] = 0.125f;
+ r_snap[1] = 0.0625f;
}
else if (t->spacetype == SPACE_NODE) {
- r_snap[0] = 0.0f;
- r_snap[1] = r_snap[2] = ED_node_grid_size();
+ r_snap[0] = r_snap[1] = ED_node_grid_size();
}
else if (t->spacetype == SPACE_GRAPH) {
- r_snap[0] = 0.0f;
- r_snap[1] = 1.0;
- r_snap[2] = 0.1f;
+ r_snap[0] = 1.0;
+ r_snap[1] = 0.1f;
}
else {
- r_snap[0] = 0.0f;
- r_snap[1] = r_snap[2] = 1.0f;
+ r_snap[0] = r_snap[1] = 1.0f;
}
}
@@ -1758,7 +1753,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
SPACE_TYPE_ANY, RGN_TYPE_ANY, transform_draw_cursor_poll, transform_draw_cursor_draw, t);
}
- createTransData(C, t); // make TransData structs from selection
+ createTransData(C, t); /* Make #TransData structs from selection. */
if (t->data_len_all == 0) {
postTrans(C, t);
@@ -1817,7 +1812,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
- initSnapping(t, op); // Initialize snapping data AFTER mode flags
+ initSnapping(t, op); /* Initialize snapping data AFTER mode flags */
initSnapSpatial(t, t->snap_spatial);
@@ -1879,7 +1874,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if ((((Mesh *)(tc->obedit->data))->flag & ME_AUTOSMOOTH)) {
- BMEditMesh *em = NULL; // BKE_editmesh_from_object(t->obedit);
+ BMEditMesh *em = NULL; /* BKE_editmesh_from_object(t->obedit); */
bool do_skip = false;
/* Currently only used for two of three most frequent transform ops,
@@ -1921,7 +1916,7 @@ void transformApply(bContext *C, TransInfo *t)
if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) {
selectConstraint(t);
if (t->transform) {
- t->transform(t, t->mval); // calls recalcData()
+ t->transform(t, t->mval); /* calls recalcData() */
viewRedrawForce(C, t);
}
t->redraw = TREDRAW_NOTHING;
@@ -1958,7 +1953,7 @@ int transformEnd(bContext *C, TransInfo *t)
/* handle restoring objects */
if (t->state == TRANS_CANCEL) {
exit_code = OPERATOR_CANCELLED;
- restoreTransObjects(t); // calls recalcData()
+ restoreTransObjects(t); /* calls recalcData() */
}
else {
if (t->flag & T_CLNOR_REBUILD) {
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 0c4aae9e2d1..17ef9a3034f 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -316,9 +316,9 @@ typedef struct TransInfo {
/** maximum index on the input vector. */
short idx_max;
/** Snapping Gears. */
- float snap[3];
+ float snap[2];
/** Spatial snapping gears(even when rotating, scaling... etc). */
- float snap_spatial[3];
+ float snap_spatial[2];
/** Mouse side of the current frame, 'L', 'R' or 'B' */
char frame_side;
@@ -692,44 +692,6 @@ void getViewVector(const TransInfo *t, const float coord[3], float vec[3]);
void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot);
-/*********************** Transform Orientations ******************************/
-short transform_orientation_matrix_get(struct bContext *C,
- TransInfo *t,
- short orientation,
- const float custom[3][3],
- float r_spacemtx[3][3]);
-const char *transform_orientations_spacename_get(TransInfo *t, const short orient_type);
-void transform_orientations_current_set(struct TransInfo *t, const short orient_index);
-
-/* Those two fill in mat and return non-zero on success */
-bool createSpaceNormal(float mat[3][3], const float normal[3]);
-bool createSpaceNormalTangent(float mat[3][3], const float normal[3], const float tangent[3]);
-
-struct TransformOrientation *addMatrixSpace(struct bContext *C,
- float mat[3][3],
- const char *name,
- const bool overwrite);
-void applyTransformOrientation(const struct TransformOrientation *ts,
- float r_mat[3][3],
- char r_name[64]);
-
-enum {
- ORIENTATION_NONE = 0,
- ORIENTATION_NORMAL = 1,
- ORIENTATION_VERT = 2,
- ORIENTATION_EDGE = 3,
- ORIENTATION_FACE = 4,
-};
-#define ORIENTATION_USE_PLANE(ty) ELEM(ty, ORIENTATION_NORMAL, ORIENTATION_EDGE, ORIENTATION_FACE)
-
-int getTransformOrientation_ex(const struct bContext *C,
- struct Object *ob,
- struct Object *obedit,
- float normal[3],
- float plane[3],
- const short around);
-int getTransformOrientation(const struct bContext *C, float normal[3], float plane[3]);
-
void freeCustomNormalArray(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data);
/* TODO. transform_query.c */
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index ac27f2cd7aa..de1c875a7b0 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -50,6 +50,7 @@
#include "UI_resources.h"
#include "transform.h"
+#include "transform_orientations.h"
#include "transform_snap.h"
/* Own include. */
@@ -424,7 +425,8 @@ static void applyAxisConstraintVec(
else if (t->con.mode & CON_AXIS1) {
copy_v3_v3(c, t->spacemtx[1]);
}
- else if (t->con.mode & CON_AXIS2) {
+ else {
+ BLI_assert(t->con.mode & CON_AXIS2);
copy_v3_v3(c, t->spacemtx[2]);
}
diff --git a/source/blender/editors/transform/transform_convert_action.c b/source/blender/editors/transform/transform_convert_action.c
index 40e60544642..da68f9c13de 100644
--- a/source/blender/editors/transform/transform_convert_action.c
+++ b/source/blender/editors/transform/transform_convert_action.c
@@ -796,9 +796,9 @@ void special_aftertrans_update__actedit(bContext *C, TransInfo *t)
/* free temp memory */
ANIM_animdata_freelist(&anim_data);
}
- else if (ac.datatype == ANIMCONT_ACTION) { // TODO: just integrate into the above...
+ else if (ac.datatype == ANIMCONT_ACTION) { /* TODO: just integrate into the above. */
/* Depending on the lock status, draw necessary views */
- // fixme... some of this stuff is not good
+ /* FIXME: some of this stuff is not good. */
if (ob) {
if (ob->pose || BKE_key_from_object(ob)) {
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
diff --git a/source/blender/editors/transform/transform_convert_armature.c b/source/blender/editors/transform/transform_convert_armature.c
index dd35ed3cbf5..a14ff6c500d 100644
--- a/source/blender/editors/transform/transform_convert_armature.c
+++ b/source/blender/editors/transform/transform_convert_armature.c
@@ -99,7 +99,7 @@ static void autokeyframe_pose(
bPoseChannel *pchan;
FCurve *fcu;
- // TODO: this should probably be done per channel instead...
+ /* TODO: this should probably be done per channel instead. */
if (!autokeyframe_cfra_can_key(scene, id)) {
/* tag channels that should have unkeyed data */
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -337,7 +337,7 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
if (data->rootbone == 0) {
for (bPoseChannel *pchan_iter = pchan; pchan_iter; pchan_iter = pchan_iter->parent) {
/* here, we set ik-settings for bone from pchan->protectflag */
- // XXX: careful with quats/axis-angle rotations where we're locking 4d components
+ /* XXX: careful with quats/axis-angle rotations where we're locking 4d components. */
if (pchan_iter->protectflag & OB_LOCK_ROTX) {
pchan_iter->ikflag |= BONE_IK_NO_XDOF_TEMP;
}
@@ -373,7 +373,7 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
/* we only include bones that are part of a continual connected chain */
do {
/* here, we set ik-settings for bone from pchan->protectflag */
- // XXX: careful with quats/axis-angle rotations where we're locking 4d components
+ /* XXX: careful with quats/axis-angle rotations where we're locking 4d components. */
if (pchan->protectflag & OB_LOCK_ROTX) {
pchan->ikflag |= BONE_IK_NO_XDOF_TEMP;
}
@@ -683,7 +683,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
td->ival = bone->dist;
}
else if (t->mode == TFM_BONESIZE) {
- // abusive storage of scale in the loc pointer :)
+ /* Abusive storage of scale in the loc pointer :) */
td->loc = &bone->xwidth;
copy_v3_v3(td->iloc, td->loc);
td->val = NULL;
@@ -957,8 +957,9 @@ void createTransArmatureVerts(TransInfo *t)
for (ebo = edbo->first; ebo; ebo = ebo->next) {
td_old = td;
- ebo->oldlength =
- ebo->length; // length==0.0 on extrude, used for scaling radius of bone points
+
+ /* (length == 0.0) on extrude, used for scaling radius of bone points. */
+ ebo->oldlength = ebo->length;
if (EBONE_VISIBLE(arm, ebo) && !(ebo->flag & BONE_EDITMODE_LOCKED)) {
if (t->mode == TFM_BONE_ENVELOPE) {
@@ -1002,7 +1003,7 @@ void createTransArmatureVerts(TransInfo *t)
td->ival = ebo->dist;
}
else {
- // abusive storage of scale in the loc pointer :)
+ /* Abusive storage of scale in the loc pointer :). */
td->loc = &ebo->xwidth;
copy_v3_v3(td->iloc, td->loc);
td->val = NULL;
@@ -1330,8 +1331,8 @@ static void pose_transform_mirror_update(TransInfo *t, TransDataContainer *tc, O
/* We assume X-axis flipping for now. */
pchan->curve_in_x = pchan_orig->curve_in_x * -1;
pchan->curve_out_x = pchan_orig->curve_out_x * -1;
- pchan->roll1 = pchan_orig->roll1 * -1; // XXX?
- pchan->roll2 = pchan_orig->roll2 * -1; // XXX?
+ pchan->roll1 = pchan_orig->roll1 * -1; /* XXX? */
+ pchan->roll2 = pchan_orig->roll2 * -1; /* XXX? */
float pchan_mtx_final[4][4];
BKE_pchan_to_mat4(pchan_orig, pchan_mtx_final);
@@ -1465,7 +1466,8 @@ void recalcData_pose(TransInfo *t)
* (FPoints) instead of keyframes? */
if ((t->animtimer) && (t->context) && IS_AUTOKEY_ON(t->scene)) {
int targetless_ik =
- (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet!
+ (t->flag &
+ T_AUTOIK); /* XXX this currently doesn't work, since flags aren't set yet! */
animrecord_check_state(t, ob);
autokeyframe_pose(t->context, t->scene, ob, t->mode, targetless_ik);
@@ -1617,7 +1619,7 @@ static short apply_targetless_ik(Object *ob)
segcount++;
if (segcount == data->rootbone || segcount > 255) {
- break; // 255 is weak
+ break; /* 255 is weak */
}
}
for (; segcount; segcount--) {
diff --git a/source/blender/editors/transform/transform_convert_curve.c b/source/blender/editors/transform/transform_convert_curve.c
index 65b2c9f9382..90257b28f55 100644
--- a/source/blender/editors/transform/transform_convert_curve.c
+++ b/source/blender/editors/transform/transform_convert_curve.c
@@ -36,6 +36,7 @@
/* Own include. */
#include "transform_convert.h"
+#include "transform_orientations.h"
/* -------------------------------------------------------------------- */
/** \name Curve/Surfaces Transform Creation
diff --git a/source/blender/editors/transform/transform_convert_graph.c b/source/blender/editors/transform/transform_convert_graph.c
index 8886be9ac85..7daa6498334 100644
--- a/source/blender/editors/transform/transform_convert_graph.c
+++ b/source/blender/editors/transform/transform_convert_graph.c
@@ -260,7 +260,7 @@ void createTransGraphEditData(bContext *C, TransInfo *t)
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* which side of the current frame should be allowed */
- // XXX we still want this mode, but how to get this using standard transform too?
+ /* XXX we still want this mode, but how to get this using standard transform too? */
if (t->mode == TFM_TIME_EXTEND) {
t->frame_side = transform_convert_frame_side_dir_get(t, (float)CFRA);
}
diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c
index 835781d458f..f154c8d338e 100644
--- a/source/blender/editors/transform/transform_convert_mesh.c
+++ b/source/blender/editors/transform/transform_convert_mesh.c
@@ -50,6 +50,7 @@
/* Own include. */
#include "transform_convert.h"
+#include "transform_orientations.h"
#define USE_FACE_SUBSTITUTE
@@ -1175,8 +1176,9 @@ static void mesh_customdatacorrect_init_container_generic(TransDataContainer *UN
.use_toolflags = false,
}));
- /* We need to have matching custom-data. */
- BM_mesh_copy_init_customdata(bm_origfaces, bm, NULL);
+ /* We need to have matching loop custom-data. */
+ BM_mesh_copy_init_customdata_all_layers(bm_origfaces, bm, BM_LOOP, NULL);
+
tcld->origfaces = origfaces;
tcld->bm_origfaces = bm_origfaces;
@@ -1358,9 +1360,6 @@ static void mesh_customdatacorrect_apply_vert(struct TransCustomDataLayer *tcld,
* and we do not want to mess up other shape keys */
BM_loop_interp_from_face(bm, l, f_copy, false, false);
- /* make sure face-attributes are correct (e.g. #MLoopUV, #MLoopCol) */
- BM_elem_attrs_copy_ex(tcld->bm_origfaces, bm, f_copy, l->f, BM_ELEM_SELECT, CD_MASK_NORMAL);
-
/* weight the loop */
if (do_loop_weight) {
const float eps = 1.0e-8f;
@@ -1513,8 +1512,6 @@ static void mesh_customdatacorrect_restore(struct TransInfo *t)
BM_elem_attrs_copy(bm_copy, bm, l_copy, l_iter);
l_copy = l_copy->next;
} while ((l_iter = l_iter->next) != l_first);
-
- BM_elem_attrs_copy_ex(bm_copy, bm, f_copy, f, BM_ELEM_SELECT, CD_MASK_NORMAL);
}
}
}
diff --git a/source/blender/editors/transform/transform_convert_mesh_edge.c b/source/blender/editors/transform/transform_convert_mesh_edge.c
index febfa4cd367..7bdd33192da 100644
--- a/source/blender/editors/transform/transform_convert_mesh_edge.c
+++ b/source/blender/editors/transform/transform_convert_mesh_edge.c
@@ -86,7 +86,7 @@ void createTransEdge(TransInfo *t)
BM_mesh_cd_flag_ensure(em->bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_EDGE_BWEIGHT);
cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_BWEIGHT);
}
- else { // if (t->mode == TFM_CREASE) {
+ else { /* if (t->mode == TFM_CREASE) { */
BLI_assert(t->mode == TFM_CREASE);
BM_mesh_cd_flag_ensure(em->bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_EDGE_CREASE);
cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_CREASE);
diff --git a/source/blender/editors/transform/transform_convert_nla.c b/source/blender/editors/transform/transform_convert_nla.c
index afebf1c46a4..8f18f6a8c96 100644
--- a/source/blender/editors/transform/transform_convert_nla.c
+++ b/source/blender/editors/transform/transform_convert_nla.c
@@ -117,7 +117,7 @@ void createTransNlaData(bContext *C, TransInfo *t)
/* only consider selected strips */
for (strip = nlt->strips.first; strip; strip = strip->next) {
- // TODO: we can make strips have handles later on...
+ /* TODO: we can make strips have handles later on. */
/* transition strips can't get directly transformed */
if (strip->type != NLASTRIP_TYPE_TRANSITION) {
if (strip->flag & NLASTRIP_FLAG_SELECT) {
@@ -166,7 +166,7 @@ void createTransNlaData(bContext *C, TransInfo *t)
/* only consider selected strips */
for (strip = nlt->strips.first; strip; strip = strip->next) {
- // TODO: we can make strips have handles later on...
+ /* TODO: we can make strips have handles later on. */
/* transition strips can't get directly transformed */
if (strip->type != NLASTRIP_TYPE_TRANSITION) {
if (strip->flag & NLASTRIP_FLAG_SELECT) {
diff --git a/source/blender/editors/transform/transform_convert_object.c b/source/blender/editors/transform/transform_convert_object.c
index 4bf0f842f2f..6664c41b0b6 100644
--- a/source/blender/editors/transform/transform_convert_object.c
+++ b/source/blender/editors/transform/transform_convert_object.c
@@ -50,6 +50,7 @@
/* Own include. */
#include "transform_convert.h"
+#include "transform_orientations.h"
/* -------------------------------------------------------------------- */
/** \name Object Mode Custom Data
@@ -183,8 +184,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
}
/* axismtx has the real orientation */
- copy_m3_m4(td->axismtx, ob->obmat);
- normalize_m3(td->axismtx);
+ transform_orientations_create_from_axis(td->axismtx, UNPACK3(ob->obmat));
td->con = ob->constraints.first;
@@ -251,8 +251,11 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
td->ext->irotAngle = ob->rotAngle;
copy_v3_v3(td->ext->irotAxis, ob->rotAxis);
- // td->ext->drotAngle = ob->drotAngle; // XXX, not implemented
- // copy_v3_v3(td->ext->drotAxis, ob->drotAxis); // XXX, not implemented
+ /* XXX, not implemented. */
+#if 0
+ td->ext->drotAngle = ob->drotAngle;
+ copy_v3_v3(td->ext->drotAxis, ob->drotAxis);
+#endif
}
else {
td->ext->rot = NULL;
@@ -726,7 +729,7 @@ void createTransTexspace(TransInfo *t)
ob = OBACT(view_layer);
- if (ob == NULL) { // Shouldn't logically happen, but still...
+ if (ob == NULL) { /* Shouldn't logically happen, but still. */
return;
}
@@ -788,7 +791,7 @@ static void autokeyframe_object(
ID *id = &ob->id;
FCurve *fcu;
- // TODO: this should probably be done per channel instead...
+ /* TODO: this should probably be done per channel instead. */
if (autokeyframe_cfra_can_key(scene, id)) {
ReportList *reports = CTX_wm_reports(C);
ToolSettings *ts = scene->toolsettings;
diff --git a/source/blender/editors/transform/transform_convert_sequencer.c b/source/blender/editors/transform/transform_convert_sequencer.c
index 80ce4770984..307fbbdf80b 100644
--- a/source/blender/editors/transform/transform_convert_sequencer.c
+++ b/source/blender/editors/transform/transform_convert_sequencer.c
@@ -381,7 +381,7 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
if (!(t->state == TRANS_CANCEL)) {
-#if 0 // default 2.4 behavior
+#if 0 /* Default 2.4 behavior. */
/* flush to 2d vector from internally used 3d vector */
for (a = 0; a < t->total; a++, td++) {
@@ -393,7 +393,7 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
seq_prev = seq;
}
-#else // durian hack
+#else /* durian hack */
{
int overlap = 0;
diff --git a/source/blender/editors/transform/transform_data.h b/source/blender/editors/transform/transform_data.h
index 726e70c5e4d..b59197fcd39 100644
--- a/source/blender/editors/transform/transform_data.h
+++ b/source/blender/editors/transform/transform_data.h
@@ -53,10 +53,12 @@ typedef struct TransDataMirror {
typedef struct TransDataExtension {
/** Initial object drot. */
float drot[3];
- // /* Initial object drotAngle, TODO: not yet implemented */
- // float drotAngle;
- // /* Initial object drotAxis, TODO: not yet implemented */
- // float drotAxis[3];
+#if 0 /* TODO: not yet implemented */
+ /* Initial object drotAngle */
+ float drotAngle;
+ /* Initial object drotAxis */
+ float drotAxis[3];
+#endif
/** Initial object delta quat. */
float dquat[4];
/** Initial object delta scale. */
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index ba87f0bcc38..1b8c9b47c04 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -61,6 +61,7 @@
#include "transform.h"
#include "transform_mode.h"
+#include "transform_orientations.h"
#include "transform_snap.h"
/* ************************** Functions *************************** */
@@ -389,7 +390,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
else if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = area->spacedata.first;
- // XXX for now, get View2D from the active region
+ /* XXX for now, get View2D from the active region. */
t->view = &region->v2d;
t->around = sima->around;
@@ -408,7 +409,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
/* image not in uv edit, nor in mask mode, can happen for some tools */
}
else if (t->spacetype == SPACE_NODE) {
- // XXX for now, get View2D from the active region
+ /* XXX for now, get View2D from the active region. */
t->view = &region->v2d;
t->around = V3D_AROUND_CENTER_BOUNDS;
}
@@ -431,9 +432,9 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
else {
if (region) {
- // XXX for now, get View2D from the active region
+ /* XXX for now, get View2D from the active region */
t->view = &region->v2d;
- // XXX for now, the center point is the midpoint of the data
+ /* XXX for now, the center point is the midpoint of the data */
}
else {
t->view = NULL;
@@ -479,9 +480,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
if (t_values_set_is_array) {
/* For operators whose `t->values` is array, set constraint so that the
* orientation is more intuitive in the Redo Panel. */
- for (int i = 3; i--;) {
- constraint_axis[i] |= t->values[i] != 0.0f;
- }
+ constraint_axis[0] = constraint_axis[1] = constraint_axis[2] = true;
}
else if (use_orient_axis) {
constraint_axis[t->orient_axis] = true;
@@ -531,10 +530,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_type")) &&
RNA_property_is_set(op->ptr, prop))) {
orient_type_set = RNA_property_enum_get(op->ptr, prop);
- if (orient_type_set >= V3D_ORIENT_CUSTOM) {
- if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) {
- orient_type_set = V3D_ORIENT_GLOBAL;
- }
+ if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) {
+ orient_type_set = V3D_ORIENT_GLOBAL;
}
/* Change the default orientation to be used when redoing. */
@@ -718,7 +715,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
- // Mirror is not supported with PET, turn it off.
+ /* Mirror is not supported with PET, turn it off. */
#if 0
if (t->flag & T_PROP_EDIT) {
t->flag &= ~T_MIRROR;
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index b8aa16c0a59..a22f6c35139 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -915,7 +915,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
/* selection center */
if (totsel) {
- mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
+ mul_v3_fl(tbounds->center, 1.0f / (float)totsel); /* centroid! */
mul_m4_v3(obedit->obmat, tbounds->center);
mul_m4_v3(obedit->obmat, tbounds->min);
mul_m4_v3(obedit->obmat, tbounds->max);
@@ -958,7 +958,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
MEM_freeN(objects);
if (totsel) {
- mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
+ mul_v3_fl(tbounds->center, 1.0f / (float)totsel); /* centroid! */
mul_m4_v3(ob->obmat, tbounds->center);
mul_m4_v3(ob->obmat, tbounds->min);
mul_m4_v3(ob->obmat, tbounds->max);
@@ -996,7 +996,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
/* selection center */
if (totsel) {
- mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
+ mul_v3_fl(tbounds->center, 1.0f / (float)totsel); /* centroid! */
}
}
}
@@ -1044,7 +1044,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
/* selection center */
if (totsel) {
- mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
+ mul_v3_fl(tbounds->center, 1.0f / (float)totsel); /* centroid! */
}
}
@@ -1280,7 +1280,7 @@ void drawDial3d(const TransInfo *t)
float mat_basis[4][4];
float mat_final[4][4];
float color[4];
- float increment;
+ float increment = 0.0f;
float line_with = GIZMO_AXIS_LINE_WIDTH + 1.0f;
float scale = UI_DPI_FAC * U.gizmo_size;
@@ -1335,10 +1335,7 @@ void drawDial3d(const TransInfo *t)
if (activeSnap(t) && (!transformModeUseSnap(t) ||
(t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) {
- increment = (t->modifiers & MOD_PRECISION) ? t->snap[2] : t->snap[1];
- }
- else {
- increment = t->snap[0];
+ increment = (t->modifiers & MOD_PRECISION) ? t->snap[1] : t->snap[0];
}
BLI_assert(axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END);
diff --git a/source/blender/editors/transform/transform_mode.c b/source/blender/editors/transform/transform_mode.c
index edc0781e18e..c525bc0e6ea 100644
--- a/source/blender/editors/transform/transform_mode.c
+++ b/source/blender/editors/transform/transform_mode.c
@@ -446,7 +446,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
*/
if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
- return; // TODO: fix this case
+ return; /* TODO: fix this case */
}
/* Reset val if SINGLESIZE but using a constraint */
@@ -505,7 +505,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* copy results from cob->matrix */
if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
- return; // TODO: fix this case
+ return; /* TODO: fix this case. */
}
/* Reset val if SINGLESIZE but using a constraint */
@@ -605,7 +605,7 @@ void ElementRotation_ex(TransInfo *t,
if (td->flag & TD_USEQUAT) {
mul_m3_series(fmat, td->smtx, mat, td->mtx);
- mat3_to_quat(quat, fmat); // Actual transform
+ mat3_to_quat(quat, fmat); /* Actual transform */
if (td->ext->quat) {
mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat);
@@ -628,31 +628,31 @@ void ElementRotation_ex(TransInfo *t,
* has been computed, it has to be converted back into the bone's space.
*/
else if (t->flag & T_POSE) {
- // Extract and invert armature object matrix
+ /* Extract and invert armature object matrix */
if ((td->flag & TD_NO_LOC) == 0) {
sub_v3_v3v3(vec, td->center, center);
- mul_m3_v3(tc->mat3, vec); // To Global space
- mul_m3_v3(mat, vec); // Applying rotation
- mul_m3_v3(tc->imat3, vec); // To Local space
+ mul_m3_v3(tc->mat3, vec); /* To Global space. */
+ mul_m3_v3(mat, vec); /* Applying rotation. */
+ mul_m3_v3(tc->imat3, vec); /* To Local space. */
add_v3_v3(vec, center);
/* vec now is the location where the object has to be */
- sub_v3_v3v3(vec, vec, td->center); // Translation needed from the initial location
+ sub_v3_v3v3(vec, vec, td->center); /* Translation needed from the initial location */
/* special exception, see TD_PBONE_LOCAL_MTX definition comments */
if (td->flag & TD_PBONE_LOCAL_MTX_P) {
/* do nothing */
}
else if (td->flag & TD_PBONE_LOCAL_MTX_C) {
- mul_m3_v3(tc->mat3, vec); // To Global space
- mul_m3_v3(td->ext->l_smtx, vec); // To Pose space (Local Location)
+ mul_m3_v3(tc->mat3, vec); /* To Global space. */
+ mul_m3_v3(td->ext->l_smtx, vec); /* To Pose space (Local Location). */
}
else {
- mul_m3_v3(tc->mat3, vec); // To Global space
- mul_m3_v3(td->smtx, vec); // To Pose space
+ mul_m3_v3(tc->mat3, vec); /* To Global space. */
+ mul_m3_v3(td->smtx, vec); /* To Pose space. */
}
protectedTransBits(td->protectflag, vec);
@@ -738,13 +738,13 @@ void ElementRotation_ex(TransInfo *t,
constraintTransLim(t, td);
/* rotation */
- if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't rotate objects itself
+ if ((t->flag & T_V3D_ALIGN) == 0) { /* Align mode doesn't rotate objects itself. */
/* euler or quaternion? */
if ((td->ext->rotOrder == ROT_MODE_QUAT) || (td->flag & TD_USEQUAT)) {
/* can be called for texture space translate for example, then opt out */
if (td->ext->quat) {
mul_m3_series(fmat, td->smtx, mat, td->mtx);
- mat3_to_quat(quat, fmat); // Actual transform
+ mat3_to_quat(quat, fmat); /* Actual transform */
mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat);
/* this function works on end result */
@@ -758,7 +758,7 @@ void ElementRotation_ex(TransInfo *t,
axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle);
mul_m3_series(fmat, td->smtx, mat, td->mtx);
- mat3_to_quat(quat, fmat); // Actual transform
+ mat3_to_quat(quat, fmat); /* Actual transform */
mul_qt_qtqt(tquat, quat, iquat);
quat_to_axis_angle(td->ext->rotAxis, td->ext->rotAngle, tquat);
@@ -1045,10 +1045,12 @@ void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float ma
/** \name Transform Frame Utils
* \{ */
-/* This function returns the snapping 'mode' for Animation Editors only
+/**
+ * This function returns the snapping 'mode' for Animation Editors only.
* We cannot use the standard snapping due to NLA-strip scaling complexities.
+ *
+ * TODO: these modifier checks should be key-mappable.
*/
-// XXX these modifier checks should be keymappable
short getAnimEdit_SnapMode(TransInfo *t)
{
short autosnap = SACTSNAP_OFF;
diff --git a/source/blender/editors/transform/transform_mode_baketime.c b/source/blender/editors/transform/transform_mode_baketime.c
index 235b04b1858..6470776e1a2 100644
--- a/source/blender/editors/transform/transform_mode_baketime.c
+++ b/source/blender/editors/transform/transform_mode_baketime.c
@@ -125,11 +125,10 @@ void initBakeTime(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 1.0f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 1.0f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE; /* Don't think this uses units? */
}
diff --git a/source/blender/editors/transform/transform_mode_bbone_resize.c b/source/blender/editors/transform/transform_mode_bbone_resize.c
index d067c9df418..57e809a566a 100644
--- a/source/blender/editors/transform/transform_mode_bbone_resize.c
+++ b/source/blender/editors/transform/transform_mode_bbone_resize.c
@@ -142,7 +142,7 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2]))
}
}
- copy_m3_m3(t->mat, mat); // used in gizmo
+ copy_m3_m3(t->mat, mat); /* used in gizmo */
headerBoneSize(t, t->values_final, str);
@@ -175,11 +175,10 @@ void initBoneSize(TransInfo *t)
t->num.val_flag[1] |= NUM_NULL_ONE;
t->num.val_flag[2] |= NUM_NULL_ONE;
t->num.flag |= NUM_AFFECT_ALL;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
t->num.unit_type[1] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_mode_bend.c b/source/blender/editors/transform/transform_mode_bend.c
index 86de40448b7..ca22263712c 100644
--- a/source/blender/editors/transform/transform_mode_bend.c
+++ b/source/blender/editors/transform/transform_mode_bend.c
@@ -102,7 +102,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
* this isnt essential but nicer to give reasonable snapping values for radius */
if (t->tsnap.mode & SCE_SNAP_MODE_INCREMENT) {
const float radius_snap = 0.1f;
- const float snap_hack = (t->snap[1] * data->warp_init_dist) / radius_snap;
+ const float snap_hack = (t->snap[0] * data->warp_init_dist) / radius_snap;
values.scale *= snap_hack;
transform_snap_increment(t, values.vector);
values.scale /= snap_hack;
@@ -261,11 +261,10 @@ void initBend(TransInfo *t)
t->idx_max = 1;
t->num.idx_max = 1;
- t->snap[0] = 0.0f;
- t->snap[1] = SNAP_INCREMENTAL_ANGLE;
- t->snap[2] = t->snap[1] * 0.2;
+ t->snap[0] = SNAP_INCREMENTAL_ANGLE;
+ t->snap[1] = t->snap[0] * 0.2;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
t->num.unit_type[0] = B_UNIT_ROTATION;
diff --git a/source/blender/editors/transform/transform_mode_boneenvelope.c b/source/blender/editors/transform/transform_mode_boneenvelope.c
index 7f5a8fedeef..1a25ee50543 100644
--- a/source/blender/editors/transform/transform_mode_boneenvelope.c
+++ b/source/blender/editors/transform/transform_mode_boneenvelope.c
@@ -102,11 +102,10 @@ void initBoneEnvelope(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_mode_boneroll.c b/source/blender/editors/transform/transform_mode_boneroll.c
index 8805d54e1f8..cd277517d6b 100644
--- a/source/blender/editors/transform/transform_mode_boneroll.c
+++ b/source/blender/editors/transform/transform_mode_boneroll.c
@@ -97,11 +97,10 @@ void initBoneRoll(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = DEG2RAD(5.0);
- t->snap[2] = DEG2RAD(1.0);
+ t->snap[0] = DEG2RAD(5.0);
+ t->snap[1] = DEG2RAD(1.0);
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
t->num.unit_type[0] = B_UNIT_ROTATION;
diff --git a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
index fd65b019fe0..1935264d6d0 100644
--- a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
+++ b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
@@ -102,11 +102,10 @@ void initCurveShrinkFatten(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_mode_edge_bevelweight.c b/source/blender/editors/transform/transform_mode_edge_bevelweight.c
index 4d6e25dbe34..2f7707cdee4 100644
--- a/source/blender/editors/transform/transform_mode_edge_bevelweight.c
+++ b/source/blender/editors/transform/transform_mode_edge_bevelweight.c
@@ -113,11 +113,10 @@ void initBevelWeight(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_mode_edge_crease.c b/source/blender/editors/transform/transform_mode_edge_crease.c
index a1822d99ff9..e2e0afc0a8f 100644
--- a/source/blender/editors/transform/transform_mode_edge_crease.c
+++ b/source/blender/editors/transform/transform_mode_edge_crease.c
@@ -117,11 +117,10 @@ void initCrease(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
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 5b929c39915..4b083a0529f 100644
--- a/source/blender/editors/transform/transform_mode_edge_rotate_normal.c
+++ b/source/blender/editors/transform/transform_mode_edge_rotate_normal.c
@@ -134,11 +134,10 @@ void initNormalRotation(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = DEG2RAD(5.0);
- t->snap[2] = DEG2RAD(1.0);
+ t->snap[0] = DEG2RAD(5.0);
+ t->snap[1] = DEG2RAD(1.0);
- copy_v3_fl(t->num.val_inc, t->snap[2]);
+ copy_v3_fl(t->num.val_inc, t->snap[1]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
t->num.unit_type[0] = B_UNIT_ROTATION;
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 befd54c3636..5222d4d4e5a 100644
--- a/source/blender/editors/transform/transform_mode_edge_seq_slide.c
+++ b/source/blender/editors/transform/transform_mode_edge_seq_slide.c
@@ -135,11 +135,10 @@ void initSeqSlide(TransInfo *t)
t->num.flag = 0;
t->num.idx_max = t->idx_max;
- t->snap[0] = 0.0f;
- t->snap[1] = floorf(t->scene->r.frs_sec / t->scene->r.frs_sec_base);
- t->snap[2] = 10.0f;
+ t->snap[0] = floorf(t->scene->r.frs_sec / t->scene->r.frs_sec_base);
+ t->snap[1] = 10.0f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
/* Would be nice to have a time handling in units as well
* (supporting frames in addition to "natural" time...). */
diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c b/source/blender/editors/transform/transform_mode_edge_slide.c
index 0c38ba588c1..c887b69c792 100644
--- a/source/blender/editors/transform/transform_mode_edge_slide.c
+++ b/source/blender/editors/transform/transform_mode_edge_slide.c
@@ -1555,11 +1555,10 @@ void initEdgeSlide_ex(
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_mode_gpopacity.c b/source/blender/editors/transform/transform_mode_gpopacity.c
index 11c63be156c..5eb390d7cbd 100644
--- a/source/blender/editors/transform/transform_mode_gpopacity.c
+++ b/source/blender/editors/transform/transform_mode_gpopacity.c
@@ -98,11 +98,10 @@ void initGPOpacity(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_mode_gpshrinkfatten.c b/source/blender/editors/transform/transform_mode_gpshrinkfatten.c
index c025dbcaccb..2d886b55a04 100644
--- a/source/blender/editors/transform/transform_mode_gpshrinkfatten.c
+++ b/source/blender/editors/transform/transform_mode_gpshrinkfatten.c
@@ -100,11 +100,10 @@ void initGPShrinkFatten(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_mode_maskshrinkfatten.c b/source/blender/editors/transform/transform_mode_maskshrinkfatten.c
index 3ac35ae7780..1c5b5000f5c 100644
--- a/source/blender/editors/transform/transform_mode_maskshrinkfatten.c
+++ b/source/blender/editors/transform/transform_mode_maskshrinkfatten.c
@@ -128,11 +128,10 @@ void initMaskShrinkFatten(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_mode_push_pull.c b/source/blender/editors/transform/transform_mode_push_pull.c
index 2b17f208e79..860dd51da94 100644
--- a/source/blender/editors/transform/transform_mode_push_pull.c
+++ b/source/blender/editors/transform/transform_mode_push_pull.c
@@ -122,11 +122,10 @@ void initPushPull(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 1.0f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 1.0f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_LENGTH;
}
diff --git a/source/blender/editors/transform/transform_mode_resize.c b/source/blender/editors/transform/transform_mode_resize.c
index b4245abcc12..33303b82567 100644
--- a/source/blender/editors/transform/transform_mode_resize.c
+++ b/source/blender/editors/transform/transform_mode_resize.c
@@ -121,7 +121,7 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
headerResize(t, t->values_final, str);
}
- copy_m3_m3(t->mat, mat); // used in gizmo
+ copy_m3_m3(t->mat, mat); /* used in gizmo */
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
@@ -188,11 +188,10 @@ void initResize(TransInfo *t)
t->idx_max = 2;
t->num.idx_max = 2;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
t->num.unit_type[1] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_mode_rotate.c b/source/blender/editors/transform/transform_mode_rotate.c
index 37b68877b08..d8857dbc31e 100644
--- a/source/blender/editors/transform/transform_mode_rotate.c
+++ b/source/blender/editors/transform/transform_mode_rotate.c
@@ -49,7 +49,7 @@ static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3])
sub_v3_v3v3(start, p1, t->center_global);
sub_v3_v3v3(end, p2, t->center_global);
- // Angle around a constraint axis (error prone, will need debug)
+ /* Angle around a constraint axis (error prone, will need debug). */
if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) {
float axis[3], tmp[3];
@@ -244,11 +244,10 @@ void initRotation(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = DEG2RAD(5.0);
- t->snap[2] = DEG2RAD(1.0);
+ t->snap[0] = DEG2RAD(5.0);
+ t->snap[1] = DEG2RAD(1.0);
- copy_v3_fl(t->num.val_inc, t->snap[2]);
+ copy_v3_fl(t->num.val_inc, t->snap[1]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
t->num.unit_type[0] = B_UNIT_ROTATION;
diff --git a/source/blender/editors/transform/transform_mode_shear.c b/source/blender/editors/transform/transform_mode_shear.c
index 18968494395..dfc6f69b341 100644
--- a/source/blender/editors/transform/transform_mode_shear.c
+++ b/source/blender/editors/transform/transform_mode_shear.c
@@ -226,11 +226,10 @@ void initShear(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE; /* Don't think we have any unit here? */
diff --git a/source/blender/editors/transform/transform_mode_shrink_fatten.c b/source/blender/editors/transform/transform_mode_shrink_fatten.c
index 2f221181d12..af33c2bb090 100644
--- a/source/blender/editors/transform/transform_mode_shrink_fatten.c
+++ b/source/blender/editors/transform/transform_mode_shrink_fatten.c
@@ -116,7 +116,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
void initShrinkFatten(TransInfo *t)
{
- // If not in mesh edit mode, fallback to Resize
+ /* If not in mesh edit mode, fallback to Resize. */
if ((t->flag & T_EDIT) == 0 || (t->obedit_type != OB_MESH)) {
initResize(t);
}
@@ -128,11 +128,10 @@ void initShrinkFatten(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 1.0f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 1.0f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_LENGTH;
diff --git a/source/blender/editors/transform/transform_mode_skin_resize.c b/source/blender/editors/transform/transform_mode_skin_resize.c
index 665c616bc2b..a1a6f0ce8f8 100644
--- a/source/blender/editors/transform/transform_mode_skin_resize.c
+++ b/source/blender/editors/transform/transform_mode_skin_resize.c
@@ -123,11 +123,10 @@ void initSkinResize(TransInfo *t)
t->idx_max = 2;
t->num.idx_max = 2;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
t->num.unit_type[1] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_mode_tilt.c b/source/blender/editors/transform/transform_mode_tilt.c
index 5ab23000039..07e0e156803 100644
--- a/source/blender/editors/transform/transform_mode_tilt.c
+++ b/source/blender/editors/transform/transform_mode_tilt.c
@@ -101,11 +101,10 @@ void initTilt(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = DEG2RAD(5.0);
- t->snap[2] = DEG2RAD(1.0);
+ t->snap[0] = DEG2RAD(5.0);
+ t->snap[1] = DEG2RAD(1.0);
- copy_v3_fl(t->num.val_inc, t->snap[2]);
+ copy_v3_fl(t->num.val_inc, t->snap[1]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
t->num.unit_type[0] = B_UNIT_ROTATION;
diff --git a/source/blender/editors/transform/transform_mode_timescale.c b/source/blender/editors/transform/transform_mode_timescale.c
index ce46cc36276..dbe06a6f1f6 100644
--- a/source/blender/editors/transform/transform_mode_timescale.c
+++ b/source/blender/editors/transform/transform_mode_timescale.c
@@ -148,10 +148,9 @@ void initTimeScale(TransInfo *t)
t->num.idx_max = t->idx_max;
/* initialize snap like for everything else */
- t->snap[0] = 0.0f;
- t->snap[1] = t->snap[2] = 1.0f;
+ t->snap[0] = t->snap[1] = 1.0f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
}
diff --git a/source/blender/editors/transform/transform_mode_timeslide.c b/source/blender/editors/transform/transform_mode_timeslide.c
index 43e14a26930..9636b4f6e42 100644
--- a/source/blender/editors/transform/transform_mode_timeslide.c
+++ b/source/blender/editors/transform/transform_mode_timeslide.c
@@ -147,7 +147,7 @@ static void applyTimeSlide(TransInfo *t, const int mval[2])
UI_view2d_region_to_view(v2d, t->mouse.imval[0], t->mouse.imval[1], &sval[0], &sval[1]);
/* t->values_final[0] stores cval[0], which is the current mouse-pointer location (in frames) */
- // XXX Need to be able to repeat this
+ /* XXX Need to be able to repeat this. */
/* t->values_final[0] = cval[0]; */ /* UNUSED (reset again later). */
/* handle numeric-input stuff */
@@ -225,10 +225,9 @@ void initTimeSlide(TransInfo *t)
t->num.idx_max = t->idx_max;
/* initialize snap like for everything else */
- t->snap[0] = 0.0f;
- t->snap[1] = t->snap[2] = 1.0f;
+ t->snap[0] = t->snap[1] = 1.0f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
/* No time unit supporting frames currently... */
t->num.unit_type[0] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_mode_timetranslate.c b/source/blender/editors/transform/transform_mode_timetranslate.c
index 28eaff8c136..226e8a377ea 100644
--- a/source/blender/editors/transform/transform_mode_timetranslate.c
+++ b/source/blender/editors/transform/transform_mode_timetranslate.c
@@ -155,10 +155,9 @@ void initTimeTranslate(TransInfo *t)
t->num.idx_max = t->idx_max;
/* initialize snap like for everything else */
- t->snap[0] = 0.0f;
- t->snap[1] = t->snap[2] = 1.0f;
+ t->snap[0] = t->snap[1] = 1.0f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
/* No time unit supporting frames currently... */
t->num.unit_type[0] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_mode_tosphere.c b/source/blender/editors/transform/transform_mode_tosphere.c
index e747f0e75d0..f49462ccc65 100644
--- a/source/blender/editors/transform/transform_mode_tosphere.c
+++ b/source/blender/editors/transform/transform_mode_tosphere.c
@@ -111,18 +111,17 @@ void initToSphere(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
t->num.val_flag[0] |= NUM_NULL_ONE | NUM_NO_NEGATIVE;
t->flag |= T_NO_CONSTRAINT;
- // Calculate average radius
+ /* Calculate average radius */
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
diff --git a/source/blender/editors/transform/transform_mode_trackball.c b/source/blender/editors/transform/transform_mode_trackball.c
index 2656411e8ab..32019e151a1 100644
--- a/source/blender/editors/transform/transform_mode_trackball.c
+++ b/source/blender/editors/transform/transform_mode_trackball.c
@@ -131,8 +131,8 @@ static void applyTrackball(TransInfo *t, const int UNUSED(mval[2]))
mul_m3_m3m3(mat, smat, totmat);
- // TRANSFORM_FIX_ME
- //copy_m3_m3(t->mat, mat); // used in gizmo
+ /* TRANSFORM_FIX_ME */
+ // copy_m3_m3(t->mat, mat); /* used in gizmo. */
#endif
applyTrackballValue(t, axis1, axis2, phi);
@@ -151,11 +151,10 @@ void initTrackball(TransInfo *t)
t->idx_max = 1;
t->num.idx_max = 1;
- t->snap[0] = 0.0f;
- t->snap[1] = DEG2RAD(5.0);
- t->snap[2] = DEG2RAD(1.0);
+ t->snap[0] = DEG2RAD(5.0);
+ t->snap[1] = DEG2RAD(1.0);
- copy_v3_fl(t->num.val_inc, t->snap[2]);
+ copy_v3_fl(t->num.val_inc, t->snap[1]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
t->num.unit_type[0] = B_UNIT_ROTATION;
diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c
index c17e6e596e0..d4748e7933b 100644
--- a/source/blender/editors/transform/transform_mode_translate.c
+++ b/source/blender/editors/transform/transform_mode_translate.c
@@ -449,9 +449,9 @@ void initTranslation(TransInfo *t)
t->num.flag = 0;
t->num.idx_max = t->idx_max;
- copy_v3_v3(t->snap, t->snap_spatial);
+ copy_v2_v2(t->snap, t->snap_spatial);
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
if (t->spacetype == SPACE_VIEW3D) {
/* Handling units makes only sense in 3Dview... See T38877. */
diff --git a/source/blender/editors/transform/transform_mode_vert_slide.c b/source/blender/editors/transform/transform_mode_vert_slide.c
index 75b973b6b14..289ed76c731 100644
--- a/source/blender/editors/transform/transform_mode_vert_slide.c
+++ b/source/blender/editors/transform/transform_mode_vert_slide.c
@@ -675,11 +675,10 @@ void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp)
t->idx_max = 0;
t->num.idx_max = 0;
- t->snap[0] = 0.0f;
- t->snap[1] = 0.1f;
- t->snap[2] = t->snap[1] * 0.1f;
+ t->snap[0] = 0.1f;
+ t->snap[1] = t->snap[0] * 0.1f;
- copy_v3_fl(t->num.val_inc, t->snap[1]);
+ copy_v3_fl(t->num.val_inc, t->snap[0]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_type[0] = B_UNIT_NONE;
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 6b6cab5c2a4..b164d0d443f 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -414,9 +414,9 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
const enum TfmMode mode_prev = t->mode;
#if defined(WITH_INPUT_NDOF) && 0
- // stable 2D mouse coords map to different 3D coords while the 3D mouse is active
- // in other words, 2D deltas are no longer good enough!
- // disable until individual 'transformers' behave better
+ /* Stable 2D mouse coords map to different 3D coords while the 3D mouse is active
+ * in other words, 2D deltas are no longer good enough!
+ * disable until individual 'transformers' behave better. */
if (event->type == NDOF_MOTION) {
return OPERATOR_PASS_THROUGH;
@@ -520,7 +520,7 @@ static int transform_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* add temp handler */
WM_event_add_modal_handler(C, op);
- op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the gizmo only?
+ op->flag |= OP_IS_MODAL_GRAB_CURSOR; /* XXX maybe we want this with the gizmo only? */
/* Use when modal input has some transformation to begin with. */
TransInfo *t = op->customdata;
@@ -888,7 +888,7 @@ static void TRANSFORM_OT_bend(struct wmOperatorType *ot)
/* api callbacks */
ot->invoke = transform_invoke;
- // ot->exec = transform_exec; // unsupported
+ // ot->exec = transform_exec; /* unsupported */
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_region_view3d_active;
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 548c1042682..8ad61288461 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -53,6 +53,7 @@
#include "ED_armature.h"
#include "transform.h"
+#include "transform_orientations.h"
/* *********************** TransSpace ************************** */
@@ -240,6 +241,54 @@ static TransformOrientation *createMeshSpace(bContext *C,
return addMatrixSpace(C, mat, name, overwrite);
}
+bool transform_orientations_create_from_axis(float mat[3][3],
+ const float x[3],
+ const float y[3],
+ const float z[3])
+{
+ bool is_zero[3] = {true, true, true};
+ zero_m3(mat);
+ if (x) {
+ is_zero[0] = normalize_v3_v3(mat[0], x) == 0.0f;
+ }
+ if (y) {
+ is_zero[1] = normalize_v3_v3(mat[1], y) == 0.0f;
+ }
+ if (z) {
+ is_zero[2] = normalize_v3_v3(mat[2], z) == 0.0f;
+ }
+
+ int zero_axis = is_zero[0] + is_zero[1] + is_zero[2];
+ if (zero_axis == 0) {
+ return true;
+ }
+
+ if (zero_axis == 1) {
+ int axis = is_zero[0] ? 0 : is_zero[1] ? 1 : 2;
+ cross_v3_v3v3(mat[axis], mat[(axis + 1) % 3], mat[(axis + 2) % 3]);
+ if (normalize_v3(mat[axis]) != 0.0f) {
+ return true;
+ }
+ }
+ else if (zero_axis == 2) {
+ int axis, a, b;
+ axis = !is_zero[0] ? 0 : !is_zero[1] ? 1 : 2;
+ a = (axis + 1) % 3;
+ b = (axis + 2) % 3;
+
+ mat[a][a] = 1.0f;
+ mat[b][b] = 1.0f;
+ project_plane_v3_v3v3(mat[a], mat[a], mat[axis]);
+ project_plane_v3_v3v3(mat[b], mat[b], mat[axis]);
+ if ((normalize_v3(mat[a]) != 0.0f) && (normalize_v3(mat[b]) != 0.0f)) {
+ return true;
+ }
+ }
+
+ unit_m3(mat);
+ return false;
+}
+
bool createSpaceNormal(float mat[3][3], const float normal[3])
{
float tangent[3] = {0.0f, 0.0f, 1.0f};
@@ -492,8 +541,7 @@ short ED_transform_calc_orientation_from_type_ex(const bContext *C,
ED_getTransformOrientationMatrix(C, ob, obedit, pivot_point, r_mat);
}
else {
- copy_m3_m4(r_mat, ob->obmat);
- normalize_m3(r_mat);
+ transform_orientations_create_from_axis(r_mat, UNPACK3(ob->obmat));
}
return V3D_ORIENT_LOCAL;
}
@@ -537,41 +585,24 @@ short ED_transform_calc_orientation_from_type_ex(const bContext *C,
short transform_orientation_matrix_get(
bContext *C, TransInfo *t, short orientation, const float custom[3][3], float r_spacemtx[3][3])
{
- Object *ob = NULL;
- Object *obedit = NULL;
- Scene *scene = NULL;
- RegionView3D *rv3d = NULL;
- int orientation_index_custom = 0;
-
if (orientation == V3D_ORIENT_CUSTOM_MATRIX) {
copy_m3_m3(r_spacemtx, custom);
return V3D_ORIENT_CUSTOM_MATRIX;
}
+ Object *ob = CTX_data_active_object(C);
+ Object *obedit = CTX_data_edit_object(C);
+ Scene *scene = t->scene;
+ RegionView3D *rv3d = NULL;
+ int orientation_index_custom = 0;
+
if (orientation >= V3D_ORIENT_CUSTOM) {
orientation_index_custom = orientation - V3D_ORIENT_CUSTOM;
orientation = V3D_ORIENT_CUSTOM;
}
- switch (orientation) {
- case V3D_ORIENT_GIMBAL:
- case V3D_ORIENT_LOCAL:
- case V3D_ORIENT_NORMAL:
- ob = CTX_data_active_object(C);
- obedit = CTX_data_edit_object(C);
- break;
- case V3D_ORIENT_VIEW:
- if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
- rv3d = t->region->regiondata;
- }
- break;
- case V3D_ORIENT_CURSOR:
- case V3D_ORIENT_CUSTOM:
- scene = t->scene;
- break;
- case V3D_ORIENT_GLOBAL:
- case V3D_ORIENT_CUSTOM_MATRIX:
- default:
- break;
+
+ if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
+ rv3d = t->region->regiondata;
}
return ED_transform_calc_orientation_from_type_ex(C,
@@ -584,9 +615,6 @@ short transform_orientation_matrix_get(
orientation,
orientation_index_custom,
t->around);
-
- unit_m3(r_spacemtx);
- return V3D_ORIENT_GLOBAL;
}
const char *transform_orientations_spacename_get(TransInfo *t, const short orient_type)
@@ -626,7 +654,7 @@ void transform_orientations_current_set(TransInfo *t, const short orient_index)
BLI_strncpy(t->spacename, spacename, sizeof(t->spacename));
copy_m3_m3(t->spacemtx, t->orient[orient_index].matrix);
- invert_m3_m3(t->spacemtx_inv, t->spacemtx);
+ invert_m3_m3_safe_ortho(t->spacemtx_inv, t->spacemtx);
t->orient_curr = orient_index;
}
@@ -716,7 +744,6 @@ int getTransformOrientation_ex(const bContext *C,
{
ViewLayer *view_layer = CTX_data_view_layer(C);
View3D *v3d = CTX_wm_view3d(C);
- Base *base;
int result = ORIENTATION_NONE;
const bool activeOnly = (around == V3D_AROUND_ACTIVE);
@@ -1208,30 +1235,30 @@ int getTransformOrientation_ex(const bContext *C,
result = ORIENTATION_EDGE;
}
}
- else if (ob && (ob->mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) {
- /* pass */
- }
else {
/* we need the one selected object, if its not active */
- base = BASACT(view_layer);
- ob = OBACT(view_layer);
- if (base && ((base->flag & BASE_SELECTED) != 0)) {
- /* pass */
- }
- else {
- /* first selected */
- ob = NULL;
- for (base = view_layer->object_bases.first; base; base = base->next) {
- if (BASE_SELECTED_EDITABLE(v3d, base)) {
- ob = base->object;
- break;
+ if (ob != NULL) {
+ bool ok = false;
+ if (activeOnly || (ob->mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) {
+ /* Ignore selection state. */
+ ok = true;
+ }
+ else {
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+ if (UNLIKELY(base == NULL)) {
+ /* This is very unlikely, if it happens allow the value to be set since the caller
+ * may have taken the object from outside this view-layer. */
+ ok = true;
+ }
+ else if (BASE_SELECTED(v3d, base)) {
+ ok = true;
}
}
- }
- if (ob) {
- copy_v3_v3(normal, ob->obmat[2]);
- copy_v3_v3(plane, ob->obmat[1]);
+ if (ok) {
+ copy_v3_v3(normal, ob->obmat[2]);
+ copy_v3_v3(plane, ob->obmat[1]);
+ }
}
result = ORIENTATION_NORMAL;
}
diff --git a/source/blender/editors/transform/transform_orientations.h b/source/blender/editors/transform/transform_orientations.h
new file mode 100644
index 00000000000..e9c146a6853
--- /dev/null
+++ b/source/blender/editors/transform/transform_orientations.h
@@ -0,0 +1,67 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edtransform
+ */
+
+#pragma once
+
+struct TransInfo;
+
+short transform_orientation_matrix_get(struct bContext *C,
+ struct TransInfo *t,
+ short orientation,
+ const float custom[3][3],
+ float r_spacemtx[3][3]);
+const char *transform_orientations_spacename_get(struct TransInfo *t, const short orient_type);
+void transform_orientations_current_set(struct TransInfo *t, const short orient_index);
+
+/* Those two fill in mat and return non-zero on success */
+bool transform_orientations_create_from_axis(float mat[3][3],
+ const float x[3],
+ const float y[3],
+ const float z[3]);
+bool createSpaceNormal(float mat[3][3], const float normal[3]);
+bool createSpaceNormalTangent(float mat[3][3], const float normal[3], const float tangent[3]);
+
+struct TransformOrientation *addMatrixSpace(struct bContext *C,
+ float mat[3][3],
+ const char *name,
+ const bool overwrite);
+void applyTransformOrientation(const struct TransformOrientation *ts,
+ float r_mat[3][3],
+ char r_name[64]);
+
+enum {
+ ORIENTATION_NONE = 0,
+ ORIENTATION_NORMAL = 1,
+ ORIENTATION_VERT = 2,
+ ORIENTATION_EDGE = 3,
+ ORIENTATION_FACE = 4,
+};
+#define ORIENTATION_USE_PLANE(ty) ELEM(ty, ORIENTATION_NORMAL, ORIENTATION_EDGE, ORIENTATION_FACE)
+
+int getTransformOrientation_ex(const struct bContext *C,
+ struct Object *ob,
+ struct Object *obedit,
+ float normal[3],
+ float plane[3],
+ const short around);
+int getTransformOrientation(const struct bContext *C, float normal[3], float plane[3]);
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index a546aabd095..e461bcb88e9 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -280,7 +280,7 @@ eRedrawFlag handleSnapping(TransInfo *t, const wmEvent *event)
{
eRedrawFlag status = TREDRAW_NOTHING;
-#if 0 // XXX need a proper selector for all snap mode
+#if 0 /* XXX need a proper selector for all snap mode */
if (BIF_snappingSupported(t->obedit) && event->type == TABKEY && event->shift) {
/* toggle snap and reinit */
t->settings->snap_flag ^= SCE_SNAP;
@@ -370,7 +370,9 @@ void applyProject(TransInfo *t)
}
}
- // XXX constraintTransLim(t, td);
+#if 0 /* TODO: sipport this? */
+ constraintTransLim(t, td);
+#endif
}
}
}
@@ -384,7 +386,7 @@ void applyGridAbsolute(TransInfo *t)
return;
}
- float grid_size = (t->modifiers & MOD_PRECISION) ? t->snap_spatial[2] : t->snap_spatial[1];
+ float grid_size = (t->modifiers & MOD_PRECISION) ? t->snap_spatial[1] : t->snap_spatial[0];
/* early exit on unusable grid size */
if (grid_size == 0.0f) {
@@ -447,8 +449,8 @@ void applySnapping(TransInfo *t, float *vec)
activeSnap(t)) {
double current = PIL_check_seconds_timer();
- // Time base quirky code to go around findnearest slowness
- /* !TODO! add exception for object mode, no need to slow it down then */
+ /* Time base quirky code to go around findnearest slowness */
+ /* TODO: add exception for object mode, no need to slow it down then. */
if (current - t->tsnap.last >= 0.01) {
t->tsnap.calcSnap(t, vec);
t->tsnap.targetSnap(t);
@@ -831,7 +833,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
float mval[2];
bool found = false;
short snap_elem = 0;
- float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here
+ float dist_px = SNAP_MIN_DISTANCE; /* Use a user defined value here. */
mval[0] = t->mval[0];
mval[1] = t->mval[1];
@@ -890,7 +892,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
else if (t->spacetype == SPACE_NODE) {
if (t->tsnap.mode & (SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y)) {
float loc[2];
- float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here
+ float dist_px = SNAP_MIN_DISTANCE; /* Use a user defined value here. */
char node_border;
if (snapNodesTransform(t, t->mval, loc, &dist_px, &node_border)) {
@@ -981,7 +983,7 @@ static void TargetSnapActive(TransInfo *t)
static void TargetSnapMedian(TransInfo *t)
{
- // Only need to calculate once
+ /* Only need to calculate once. */
if ((t->tsnap.status & TARGET_INIT) == 0) {
int i_accum = 0;
@@ -1024,7 +1026,7 @@ static void TargetSnapMedian(TransInfo *t)
static void TargetSnapClosest(TransInfo *t)
{
- // Only valid if a snap point has been selected
+ /* Only valid if a snap point has been selected. */
if (t->tsnap.status & POINT_INIT) {
float dist_closest = 0.0f;
TransData *closest = NULL;
@@ -1370,7 +1372,7 @@ void snapFrameTransform(TransInfo *t,
break;
case SACTSNAP_MARKER:
/* snap to nearest marker */
- // TODO: need some more careful checks for where data comes from
+ /* TODO: need some more careful checks for where data comes from. */
val = ED_markers_find_nearest_marker_time(&t->scene->markers, (float)val);
break;
case SACTSNAP_SECOND:
@@ -1462,7 +1464,7 @@ bool transform_snap_grid(TransInfo *t, float *val)
return false;
}
- float grid_dist = (t->modifiers & MOD_PRECISION) ? t->snap[2] : t->snap[1];
+ float grid_dist = (t->modifiers & MOD_PRECISION) ? t->snap[1] : t->snap[0];
/* Early bailing out if no need to snap */
if (grid_dist == 0.0f) {
@@ -1523,6 +1525,10 @@ static void snap_increment_apply(TransInfo *t,
bool transform_snap_increment(TransInfo *t, float *val)
{
+ if (!activeSnap(t)) {
+ return false;
+ }
+
if (!(t->tsnap.mode & SCE_SNAP_MODE_INCREMENT) && !doForceIncrementSnap(t)) {
return false;
}
@@ -1533,8 +1539,7 @@ bool transform_snap_increment(TransInfo *t, float *val)
return false;
}
- float increment_dist = activeSnap(t) ? (t->modifiers & MOD_PRECISION) ? t->snap[2] : t->snap[1] :
- t->snap[0];
+ float increment_dist = (t->modifiers & MOD_PRECISION) ? t->snap[1] : t->snap[0];
snap_increment_apply(t, t->idx_max, increment_dist, val);
return true;
diff --git a/source/blender/editors/util/ed_util_imbuf.c b/source/blender/editors/util/ed_util_imbuf.c
index a6eed5d54d1..9a2b346132e 100644
--- a/source/blender/editors/util/ed_util_imbuf.c
+++ b/source/blender/editors/util/ed_util_imbuf.c
@@ -273,7 +273,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
}
}
- // XXX node curve integration ..
+ /* XXX node curve integration. */
#if 0
{
ScrArea *sa, *cur = curarea;
@@ -512,7 +512,7 @@ int ED_imbuf_sample_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
switch (event->type) {
case LEFTMOUSE:
- case RIGHTMOUSE: // XXX hardcoded
+ case RIGHTMOUSE: /* XXX hardcoded */
if (event->val == KM_RELEASE) {
ED_imbuf_sample_exit(C, op);
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h
index de021adb4f0..0de792cb915 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.h
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.h
@@ -20,7 +20,7 @@
* \ingroup eduv
*/
-#include "BLI_sys_types.h" // for intptr_t support
+#include "BLI_sys_types.h" /* for intptr_t support */
#ifdef __cplusplus
extern "C" {
diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt
index 22f8f01be4b..cb4d74559a4 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -35,6 +35,9 @@ set(INC
../windowmanager
../../../intern/eigen
../../../intern/guardedalloc
+
+ # dna_type_offsets.h in BLO_read_write.h
+ ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
)
set(INC_SYS
@@ -78,3 +81,5 @@ endif()
blender_add_lib(bf_gpencil_modifiers "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
+
+add_dependencies(bf_gpencil_modifiers bf_dna)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
index 7035908605a..aee345757c6 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
@@ -31,6 +31,7 @@
#include "BLT_translation.h"
#include "DNA_armature_types.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -68,8 +69,10 @@
static void initData(GpencilModifierData *md)
{
ArmatureGpencilModifierData *gpmd = (ArmatureGpencilModifierData *)md;
- gpmd->object = NULL;
- gpmd->deformflag = ARM_DEF_VGROUP;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(ArmatureGpencilModifierData), modifier);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
index 2f6faf5ee6a..dec6ef63ffb 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
@@ -37,6 +37,7 @@
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
@@ -79,16 +80,10 @@ typedef struct tmpStrokes {
static void initData(GpencilModifierData *md)
{
ArrayGpencilModifierData *gpmd = (ArrayGpencilModifierData *)md;
- gpmd->count = 2;
- gpmd->shift[0] = 1.0f;
- gpmd->shift[1] = 0.0f;
- gpmd->shift[2] = 0.0f;
- zero_v3(gpmd->offset);
- zero_v3(gpmd->rnd_scale);
- gpmd->object = NULL;
- gpmd->flag |= GP_ARRAY_USE_RELATIVE;
- gpmd->seed = 1;
- gpmd->material = NULL;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(ArrayGpencilModifierData), modifier);
/* Open the first subpanel too, because it's activated by default. */
md->ui_expand_flag = (1 << 0) | (1 << 1);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
index 7995381ac71..5b5cc61bedc 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
@@ -32,6 +32,7 @@
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -61,15 +62,9 @@ static void initData(GpencilModifierData *md)
{
BuildGpencilModifierData *gpmd = (BuildGpencilModifierData *)md;
- /* We deliberately set this range to the half the default
- * frame-range to have an immediate effect to suggest use-cases
- */
- gpmd->start_frame = 1;
- gpmd->end_frame = 125;
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
- /* Init default length of each build effect - Nothing special */
- gpmd->start_delay = 0.0f;
- gpmd->length = 100.0f;
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(BuildGpencilModifierData), modifier);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
index 71354ddb18e..4e569099461 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
@@ -31,6 +31,7 @@
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
@@ -61,16 +62,13 @@
static void initData(GpencilModifierData *md)
{
ColorGpencilModifierData *gpmd = (ColorGpencilModifierData *)md;
- gpmd->pass_index = 0;
- ARRAY_SET_ITEMS(gpmd->hsv, 0.5f, 1.0f, 1.0f);
- gpmd->material = NULL;
- gpmd->modify_color = GP_MODIFY_COLOR_BOTH;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(ColorGpencilModifierData), modifier);
gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- if (gpmd->curve_intensity) {
- CurveMapping *curve = gpmd->curve_intensity;
- BKE_curvemapping_init(curve);
- }
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
index 450c23c7144..f0838e4522d 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
@@ -30,6 +30,7 @@
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -87,15 +88,13 @@ struct GPHookData_cb {
static void initData(GpencilModifierData *md)
{
HookGpencilModifierData *gpmd = (HookGpencilModifierData *)md;
- gpmd->pass_index = 0;
- gpmd->material = NULL;
- gpmd->object = NULL;
- gpmd->force = 0.5f;
- gpmd->falloff_type = eGPHook_Falloff_Smooth;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(HookGpencilModifierData), modifier);
+
gpmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- if (gpmd->curfalloff) {
- BKE_curvemapping_init(gpmd->curfalloff);
- }
+ BKE_curvemapping_init(gpmd->curfalloff);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
index 6aa64a97112..098a2edf04a 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
@@ -22,12 +22,14 @@
*/
#include <stdio.h>
+#include <string.h> /* For #MEMCPY_STRUCT_AFTER. */
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -65,11 +67,10 @@
static void initData(GpencilModifierData *md)
{
LatticeGpencilModifierData *gpmd = (LatticeGpencilModifierData *)md;
- gpmd->pass_index = 0;
- gpmd->material = NULL;
- gpmd->object = NULL;
- gpmd->cache_data = NULL;
- gpmd->strength = 1.0f;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(LatticeGpencilModifierData), modifier);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
index 4de85c52d33..a5457c86ec0 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
@@ -30,6 +30,7 @@
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -67,10 +68,10 @@
static void initData(GpencilModifierData *md)
{
MirrorGpencilModifierData *gpmd = (MirrorGpencilModifierData *)md;
- gpmd->pass_index = 0;
- gpmd->material = NULL;
- gpmd->object = NULL;
- gpmd->flag |= GP_MIRROR_AXIS_X;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(MirrorGpencilModifierData), modifier);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
index 1ae258032eb..7d0e3ce53fe 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
@@ -25,6 +25,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
@@ -74,14 +75,11 @@
static void initData(GpencilModifierData *md)
{
- MultiplyGpencilModifierData *mmd = (MultiplyGpencilModifierData *)md;
- mmd->duplications = 3;
- mmd->distance = 0.1f;
- mmd->split_angle = DEG2RADF(1.0f);
- mmd->fading_center = 0.5f;
- mmd->fading_thickness = 0.5f;
- mmd->fading_opacity = 0.5f;
- mmd->material = NULL;
+ MultiplyGpencilModifierData *gpmd = (MultiplyGpencilModifierData *)md;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(MultiplyGpencilModifierData), modifier);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
index 93e7eb43c86..e2f4d34ff40 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
@@ -35,6 +35,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -68,19 +69,15 @@
static void initData(GpencilModifierData *md)
{
NoiseGpencilModifierData *gpmd = (NoiseGpencilModifierData *)md;
- gpmd->pass_index = 0;
- gpmd->flag |= GP_NOISE_FULL_STROKE;
- gpmd->flag |= GP_NOISE_USE_RANDOM;
- gpmd->factor = 0.5f;
- gpmd->material = NULL;
- gpmd->step = 4;
- gpmd->seed = 1;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(NoiseGpencilModifierData), modifier);
+
gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- if (gpmd->curve_intensity) {
- CurveMapping *curve = gpmd->curve_intensity;
- BKE_curvemap_reset(curve->cm, &curve->clipr, CURVE_PRESET_BELL, CURVEMAP_SLOPE_POSITIVE);
- BKE_curvemapping_init(curve);
- }
+ CurveMapping *curve = gpmd->curve_intensity;
+ BKE_curvemap_reset(curve->cm, &curve->clipr, CURVE_PRESET_BELL, CURVEMAP_SLOPE_POSITIVE);
+ BKE_curvemapping_init(curve);
}
static void freeData(GpencilModifierData *md)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
index 03616ca2548..634aac00777 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
@@ -30,6 +30,7 @@
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -60,11 +61,10 @@
static void initData(GpencilModifierData *md)
{
OffsetGpencilModifierData *gpmd = (OffsetGpencilModifierData *)md;
- gpmd->pass_index = 0;
- gpmd->material = NULL;
- ARRAY_SET_ITEMS(gpmd->loc, 0.0f, 0.0f, 0.0f);
- ARRAY_SET_ITEMS(gpmd->rot, 0.0f, 0.0f, 0.0f);
- ARRAY_SET_ITEMS(gpmd->scale, 0.0f, 0.0f, 0.0f);
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(OffsetGpencilModifierData), modifier);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
index 9268b7ac8d5..e62bfef21ee 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
@@ -30,6 +30,7 @@
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -62,16 +63,13 @@
static void initData(GpencilModifierData *md)
{
OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md;
- gpmd->pass_index = 0;
- gpmd->factor = 1.0f;
- gpmd->hardeness = 1.0f;
- gpmd->material = NULL;
- gpmd->modify_color = GP_MODIFY_COLOR_BOTH;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(OpacityGpencilModifierData), modifier);
+
gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- if (gpmd->curve_intensity) {
- CurveMapping *curve = gpmd->curve_intensity;
- BKE_curvemapping_init(curve);
- }
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
index c8a90ea58ec..7052c59ae40 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
@@ -22,12 +22,14 @@
*/
#include <stdio.h>
+#include <string.h> /* For #MEMCPY_STRUCT_AFTER. */
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
@@ -56,12 +58,10 @@
static void initData(GpencilModifierData *md)
{
SimplifyGpencilModifierData *gpmd = (SimplifyGpencilModifierData *)md;
- gpmd->pass_index = 0;
- gpmd->step = 1;
- gpmd->factor = 0.0f;
- gpmd->length = 0.1f;
- gpmd->distance = 0.1f;
- gpmd->material = NULL;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(SimplifyGpencilModifierData), modifier);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
index 166811d847f..df2c838140e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
@@ -22,12 +22,14 @@
*/
#include <stdio.h>
+#include <string.h> /* For #MEMCPY_STRUCT_AFTER. */
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -57,17 +59,13 @@
static void initData(GpencilModifierData *md)
{
SmoothGpencilModifierData *gpmd = (SmoothGpencilModifierData *)md;
- gpmd->pass_index = 0;
- gpmd->flag |= GP_SMOOTH_MOD_LOCATION;
- gpmd->factor = 0.5f;
- gpmd->material = NULL;
- gpmd->step = 1;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(SmoothGpencilModifierData), modifier);
gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- if (gpmd->curve_intensity) {
- CurveMapping *curve = gpmd->curve_intensity;
- BKE_curvemapping_init(curve);
- }
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
index e8a7d83d7a9..6eb12974408 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
@@ -22,6 +22,7 @@
*/
#include <stdio.h>
+#include <string.h> /* For #MEMCPY_STRUCT_AFTER. */
#include "MEM_guardedalloc.h"
@@ -30,6 +31,7 @@
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -58,9 +60,10 @@
static void initData(GpencilModifierData *md)
{
SubdivGpencilModifierData *gpmd = (SubdivGpencilModifierData *)md;
- gpmd->pass_index = 0;
- gpmd->level = 1;
- gpmd->material = NULL;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(SubdivGpencilModifierData), modifier);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c
index 08542cacfcd..d29351646b9 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c
@@ -29,6 +29,7 @@
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -60,15 +61,10 @@
static void initData(GpencilModifierData *md)
{
TextureGpencilModifierData *gpmd = (TextureGpencilModifierData *)md;
- gpmd->fit_method = GP_TEX_CONSTANT_LENGTH;
- gpmd->fill_rotation = 0.0f;
- gpmd->fill_scale = 1.0f;
- gpmd->fill_offset[0] = 0.0f;
- gpmd->fill_offset[1] = 0.0f;
- gpmd->uv_offset = 0.0f;
- gpmd->uv_scale = 1.0f;
- gpmd->pass_index = 0;
- gpmd->material = NULL;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(TextureGpencilModifierData), modifier);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
index bf23dd0d78a..5cfd805b1de 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
@@ -29,6 +29,7 @@
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -59,14 +60,13 @@
static void initData(GpencilModifierData *md)
{
ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
- gpmd->pass_index = 0;
- gpmd->thickness_fac = 1.0f;
- gpmd->thickness = 30;
- gpmd->material = NULL;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(ThickGpencilModifierData), modifier);
+
gpmd->curve_thickness = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- if (gpmd->curve_thickness) {
- BKE_curvemapping_init(gpmd->curve_thickness);
- }
+ BKE_curvemapping_init(gpmd->curve_thickness);
}
static void freeData(GpencilModifierData *md)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
index 7587d6a53e6..9e8d4687979 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
@@ -29,6 +29,7 @@
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -57,11 +58,10 @@
static void initData(GpencilModifierData *md)
{
TimeGpencilModifierData *gpmd = (TimeGpencilModifierData *)md;
- gpmd->offset = 1;
- gpmd->frame_scale = 1.0f;
- gpmd->flag |= GP_TIME_KEEP_LOOP;
- gpmd->sfra = 1;
- gpmd->efra = 250;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(TimeGpencilModifierData), modifier);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
@@ -233,7 +233,7 @@ static void custom_range_panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayoutSetActive(
layout, (mode != GP_TIME_MODE_FIX) && (RNA_boolean_get(ptr, "use_custom_frame_range")));
- col = uiLayoutColumn(layout, false);
+ col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "frame_start", 0, IFACE_("Frame Start"), ICON_NONE);
uiItemR(col, ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
index a5a77095114..2ee148837cd 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
@@ -30,6 +30,7 @@
#include "BLT_translation.h"
+#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -71,13 +72,10 @@
static void initData(GpencilModifierData *md)
{
TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
- gpmd->pass_index = 0;
- gpmd->material = NULL;
- gpmd->object = NULL;
- gpmd->radius = 1.0f;
- gpmd->factor = 0.5f;
- ARRAY_SET_ITEMS(gpmd->rgb, 1.0f, 1.0f, 1.0f);
- gpmd->mode = GPPAINT_MODE_BOTH;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(TintGpencilModifierData), modifier);
/* Add default color ramp. */
gpmd->colorband = BKE_colorband_add(false);
@@ -94,10 +92,7 @@ static void initData(GpencilModifierData *md)
}
gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- if (gpmd->curve_intensity) {
- CurveMapping *curve = gpmd->curve_intensity;
- BKE_curvemapping_init(curve);
- }
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index 6fc2f646831..e5f36c1ae46 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -66,7 +66,7 @@ typedef enum eGPUBatchFlag {
BLI_STATIC_ASSERT(GPU_BATCH_OWNS_INDEX < GPU_BATCH_INIT,
"eGPUBatchFlag: Error: status flags are shadowed by the ownership bits!")
-ENUM_OPERATORS(eGPUBatchFlag)
+ENUM_OPERATORS(eGPUBatchFlag, GPU_BATCH_DIRTY)
#ifdef __cplusplus
extern "C" {
diff --git a/source/blender/gpu/GPU_framebuffer.h b/source/blender/gpu/GPU_framebuffer.h
index be55cd7af2d..c0f91756bf6 100644
--- a/source/blender/gpu/GPU_framebuffer.h
+++ b/source/blender/gpu/GPU_framebuffer.h
@@ -38,7 +38,7 @@ typedef enum eGPUFrameBufferBits {
GPU_STENCIL_BIT = (1 << 2),
} eGPUFrameBufferBits;
-ENUM_OPERATORS(eGPUFrameBufferBits)
+ENUM_OPERATORS(eGPUFrameBufferBits, GPU_STENCIL_BIT)
#ifdef __cplusplus
extern "C" {
diff --git a/source/blender/gpu/GPU_platform.h b/source/blender/gpu/GPU_platform.h
index a89298c0d01..bb7e1d58041 100644
--- a/source/blender/gpu/GPU_platform.h
+++ b/source/blender/gpu/GPU_platform.h
@@ -39,7 +39,7 @@ typedef enum eGPUDeviceType {
GPU_DEVICE_ANY = (0xff),
} eGPUDeviceType;
-ENUM_OPERATORS(eGPUDeviceType)
+ENUM_OPERATORS(eGPUDeviceType, GPU_DEVICE_ANY)
typedef enum eGPUOSType {
GPU_OS_WIN = (1 << 8),
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h
index 04cf7bc54ba..b7bea4b0a08 100644
--- a/source/blender/gpu/GPU_state.h
+++ b/source/blender/gpu/GPU_state.h
@@ -33,7 +33,7 @@ typedef enum eGPUWriteMask {
GPU_WRITE_COLOR = (GPU_WRITE_RED | GPU_WRITE_GREEN | GPU_WRITE_BLUE | GPU_WRITE_ALPHA),
} eGPUWriteMask;
-ENUM_OPERATORS(eGPUWriteMask)
+ENUM_OPERATORS(eGPUWriteMask, GPU_WRITE_COLOR)
typedef enum eGPUBarrier {
GPU_BARRIER_NONE = 0,
@@ -41,7 +41,7 @@ typedef enum eGPUBarrier {
GPU_BARRIER_TEXTURE_FETCH = (1 << 1),
} eGPUBarrier;
-ENUM_OPERATORS(eGPUBarrier)
+ENUM_OPERATORS(eGPUBarrier, GPU_BARRIER_TEXTURE_FETCH)
/**
* Defines the fixed pipeline blending equation.
@@ -161,7 +161,10 @@ float GPU_line_width_get(void);
void GPU_flush(void);
void GPU_finish(void);
void GPU_apply_state(void);
-void GPU_force_state(void);
+
+void GPU_bgl_start(void);
+void GPU_bgl_end(void);
+bool GPU_bgl_get(void);
void GPU_memory_barrier(eGPUBarrier barrier);
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 862da60c845..e9c081abd22 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -58,11 +58,13 @@ typedef enum eGPUSamplerState {
GPU_SAMPLER_ICON = (1 << 8),
GPU_SAMPLER_REPEAT = (GPU_SAMPLER_REPEAT_S | GPU_SAMPLER_REPEAT_T | GPU_SAMPLER_REPEAT_R),
- /* Don't use that. */
- GPU_SAMPLER_MAX = (GPU_SAMPLER_ICON + 1),
} eGPUSamplerState;
-ENUM_OPERATORS(eGPUSamplerState)
+/* `GPU_SAMPLER_MAX` is not a valid enum value, but only a limit.
+ * It also creates a bad mask for the `NOT` operator in `ENUM_OPERATORS`.
+ */
+static const int GPU_SAMPLER_MAX = (GPU_SAMPLER_ICON + 1);
+ENUM_OPERATORS(eGPUSamplerState, GPU_SAMPLER_ICON)
#ifdef __cplusplus
extern "C" {
diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h
index 36caee10072..eeaebd3fae5 100644
--- a/source/blender/gpu/GPU_vertex_buffer.h
+++ b/source/blender/gpu/GPU_vertex_buffer.h
@@ -40,7 +40,7 @@ typedef enum {
GPU_VERTBUF_DATA_UPLOADED = (1 << 2),
} GPUVertBufStatus;
-ENUM_OPERATORS(GPUVertBufStatus)
+ENUM_OPERATORS(GPUVertBufStatus, GPU_VERTBUF_DATA_UPLOADED)
#ifdef __cplusplus
extern "C" {
diff --git a/source/blender/gpu/intern/gpu_state.cc b/source/blender/gpu/intern/gpu_state.cc
index 44ad9cc9a84..d0048ab9b87 100644
--- a/source/blender/gpu/intern/gpu_state.cc
+++ b/source/blender/gpu/intern/gpu_state.cc
@@ -317,10 +317,50 @@ void GPU_apply_state(void)
Context::get()->state_manager->apply_state();
}
-/* Will set all the states regardless of the current ones. */
-void GPU_force_state(void)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name BGL workaround
+ *
+ * bgl makes direct GL calls that makes our state tracking out of date.
+ * This flag make it so that the pyGPU calls will not override the state set by
+ * bgl functions.
+ * \{ */
+
+void GPU_bgl_start(void)
+{
+ Context *ctx = Context::get();
+ if (!(ctx && ctx->state_manager)) {
+ return;
+ }
+ StateManager &state_manager = *(Context::get()->state_manager);
+ if (state_manager.use_bgl == false) {
+ /* Expected by many addons (see T80169, T81289).
+ * This will reset the blend function. */
+ GPU_blend(GPU_BLEND_NONE);
+ state_manager.apply_state();
+ state_manager.use_bgl = true;
+ }
+}
+
+/* Just turn off the bgl safeguard system. Can be called even without GPU_bgl_start. */
+void GPU_bgl_end(void)
+{
+ Context *ctx = Context::get();
+ if (!(ctx && ctx->state_manager)) {
+ return;
+ }
+ StateManager &state_manager = *ctx->state_manager;
+ if (state_manager.use_bgl == true) {
+ state_manager.use_bgl = false;
+ /* Resync state tracking. */
+ state_manager.force_state();
+ }
+}
+
+bool GPU_bgl_get(void)
{
- Context::get()->state_manager->force_state();
+ return Context::get()->state_manager->use_bgl;
}
/** \} */
diff --git a/source/blender/gpu/intern/gpu_state_private.hh b/source/blender/gpu/intern/gpu_state_private.hh
index d93556a1058..db1747127d4 100644
--- a/source/blender/gpu/intern/gpu_state_private.hh
+++ b/source/blender/gpu/intern/gpu_state_private.hh
@@ -153,6 +153,7 @@ class StateManager {
public:
GPUState state;
GPUStateMutable mutable_state;
+ bool use_bgl = false;
public:
StateManager();
diff --git a/source/blender/gpu/intern/gpu_texture_private.hh b/source/blender/gpu/intern/gpu_texture_private.hh
index b489493c5c1..250dee62f96 100644
--- a/source/blender/gpu/intern/gpu_texture_private.hh
+++ b/source/blender/gpu/intern/gpu_texture_private.hh
@@ -42,7 +42,7 @@ typedef enum eGPUTextureFormatFlag {
GPU_FORMAT_DEPTH_STENCIL = (GPU_FORMAT_DEPTH | GPU_FORMAT_STENCIL),
} eGPUTextureFormatFlag;
-ENUM_OPERATORS(eGPUTextureFormatFlag)
+ENUM_OPERATORS(eGPUTextureFormatFlag, GPU_FORMAT_DEPTH_STENCIL)
typedef enum eGPUTextureType {
GPU_TEXTURE_1D = (1 << 0),
@@ -57,7 +57,7 @@ typedef enum eGPUTextureType {
GPU_TEXTURE_CUBE_ARRAY = (GPU_TEXTURE_CUBE | GPU_TEXTURE_ARRAY),
} eGPUTextureType;
-ENUM_OPERATORS(eGPUTextureType)
+ENUM_OPERATORS(eGPUTextureType, GPU_TEXTURE_CUBE_ARRAY)
#ifdef DEBUG
# define DEBUG_NAME_LEN 64
diff --git a/source/blender/gpu/opengl/gl_debug.cc b/source/blender/gpu/opengl/gl_debug.cc
index 797f9ff404c..b2b05124463 100644
--- a/source/blender/gpu/opengl/gl_debug.cc
+++ b/source/blender/gpu/opengl/gl_debug.cc
@@ -200,7 +200,7 @@ void check_gl_error(const char *info)
void check_gl_resources(const char *info)
{
- if (!(G.debug & G_DEBUG_GPU)) {
+ if (!(G.debug & G_DEBUG_GPU) || GPU_bgl_get()) {
return;
}
diff --git a/source/blender/gpu/opengl/gl_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc
index 4270ba544b5..cd87fc88144 100644
--- a/source/blender/gpu/opengl/gl_framebuffer.cc
+++ b/source/blender/gpu/opengl/gl_framebuffer.cc
@@ -286,20 +286,22 @@ void GLFrameBuffer::bind(bool enabled_srgb)
this->scissor_reset();
}
- if (context_->active_fb != this) {
- context_->active_fb = this;
- state_manager_->active_fb = this;
- dirty_state_ = true;
-
+ if (context_->active_fb != this || enabled_srgb_ != enabled_srgb) {
+ enabled_srgb_ = enabled_srgb;
if (enabled_srgb) {
glEnable(GL_FRAMEBUFFER_SRGB);
}
else {
glDisable(GL_FRAMEBUFFER_SRGB);
}
-
GPU_shader_set_framebuffer_srgb_target(enabled_srgb && srgb_);
}
+
+ if (context_->active_fb != this) {
+ context_->active_fb = this;
+ state_manager_->active_fb = this;
+ dirty_state_ = true;
+ }
}
/** \} */
diff --git a/source/blender/gpu/opengl/gl_framebuffer.hh b/source/blender/gpu/opengl/gl_framebuffer.hh
index 755f3f97567..33c1cd0befa 100644
--- a/source/blender/gpu/opengl/gl_framebuffer.hh
+++ b/source/blender/gpu/opengl/gl_framebuffer.hh
@@ -55,6 +55,8 @@ class GLFrameBuffer : public FrameBuffer {
bool immutable_;
/** True is the framebuffer has it's first color target using the GPU_SRGB8_A8 format. */
bool srgb_;
+ /** True is the framebuffer has been bound using the GL_FRAMEBUFFER_SRGB feature. */
+ bool enabled_srgb_ = false;
public:
/**
diff --git a/source/blender/gpu/opengl/gl_state.cc b/source/blender/gpu/opengl/gl_state.cc
index cd24fa0e0e4..27c9b501add 100644
--- a/source/blender/gpu/opengl/gl_state.cc
+++ b/source/blender/gpu/opengl/gl_state.cc
@@ -73,13 +73,17 @@ GLStateManager::GLStateManager(void) : StateManager()
void GLStateManager::apply_state(void)
{
- this->set_state(this->state);
- this->set_mutable_state(this->mutable_state);
- this->texture_bind_apply();
- this->image_bind_apply();
+ if (!this->use_bgl) {
+ this->set_state(this->state);
+ this->set_mutable_state(this->mutable_state);
+ this->texture_bind_apply();
+ this->image_bind_apply();
+ }
+ /* This is needed by gpu_py_offscreen. */
active_fb->apply_state();
};
+/* Will set all the states regardless of the current ones. */
void GLStateManager::force_state(void)
{
/* Little exception for clip distances since they need to keep the old count correct. */
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_edituvs_points_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_edituvs_points_vert.glsl
index 3f3bfa5410c..bec565be1df 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_edituvs_points_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_edituvs_points_vert.glsl
@@ -30,15 +30,15 @@ void main()
fillColor = (is_selected) ? selectColor : deselect_col;
outlineColor = (is_pinned) ? pinnedColor : vec4(fillColor.rgb, 0.0);
- // calculate concentric radii in pixels
+ /* Calculate concentric radii in pixels. */
float radius = 0.5 * pointSize;
- // start at the outside and progress toward the center
+ /* Start at the outside and progress toward the center. */
radii[0] = radius;
radii[1] = radius - 1.0;
radii[2] = radius - outlineWidth;
radii[3] = radius - outlineWidth - 1.0;
- // convert to PointCoord units
+ /* Convert to PointCoord units. */
radii /= pointSize;
}
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_aa_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_aa_vert.glsl
index a7681353d49..1453393aa9f 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_aa_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_aa_vert.glsl
@@ -10,13 +10,13 @@ void main()
gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
gl_PointSize = size;
- // calculate concentric radii in pixels
+ /* calculate concentric radii in pixels */
float radius = 0.5 * size;
- // start at the outside and progress toward the center
+ /* start at the outside and progress toward the center */
radii[0] = radius;
radii[1] = radius - 1.0;
- // convert to PointCoord units
+ /* convert to PointCoord units */
radii /= size;
}
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl
index a3439ebe3c4..5c555b2d3e7 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl
@@ -11,15 +11,15 @@ void main()
gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
gl_PointSize = size;
- // calculate concentric radii in pixels
+ /* calculate concentric radii in pixels */
float radius = 0.5 * size;
- // start at the outside and progress toward the center
+ /* start at the outside and progress toward the center */
radii[0] = radius;
radii[1] = radius - 1.0;
radii[2] = radius - outlineWidth;
radii[3] = radius - outlineWidth - 1.0;
- // convert to PointCoord units
+ /* convert to PointCoord units */
radii /= size;
}
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_varying_color_outline_aa_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_varying_color_outline_aa_vert.glsl
index 287bd351534..3eec271913a 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_varying_color_outline_aa_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_varying_color_outline_aa_vert.glsl
@@ -14,15 +14,15 @@ void main()
gl_PointSize = size;
fillColor = color;
- // calculate concentric radii in pixels
+ /* Calculate concentric radii in pixels. */
float radius = 0.5 * size;
- // start at the outside and progress toward the center
+ /* Start at the outside and progress toward the center. */
radii[0] = radius;
radii[1] = radius - 1.0;
radii[2] = radius - outlineWidth;
radii[3] = radius - outlineWidth - 1.0;
- // convert to PointCoord units
+ /* Convert to PointCoord units. */
radii /= size;
}
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_point_uniform_size_outline_aa_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_point_uniform_size_outline_aa_vert.glsl
index 8bd344ed0e7..fb5506a778d 100644
--- a/source/blender/gpu/shaders/gpu_shader_3D_point_uniform_size_outline_aa_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_3D_point_uniform_size_outline_aa_vert.glsl
@@ -15,16 +15,16 @@ void main()
gl_Position = ModelViewProjectionMatrix * pos_4d;
gl_PointSize = size;
- // calculate concentric radii in pixels
+ /* calculate concentric radii in pixels */
float radius = 0.5 * size;
- // start at the outside and progress toward the center
+ /* start at the outside and progress toward the center */
radii[0] = radius;
radii[1] = radius - 1.0;
radii[2] = radius - outlineWidth;
radii[3] = radius - outlineWidth - 1.0;
- // convert to PointCoord units
+ /* convert to PointCoord units */
radii /= size;
#ifdef USE_WORLD_CLIP_PLANES
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_polyline_geom.glsl b/source/blender/gpu/shaders/gpu_shader_3D_polyline_geom.glsl
index cca94680284..fd9b7e221e6 100644
--- a/source/blender/gpu/shaders/gpu_shader_3D_polyline_geom.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_3D_polyline_geom.glsl
@@ -20,7 +20,23 @@ noperspective out float smoothline;
#define SMOOTH_WIDTH 1.0
-void do_vertex(const int i, vec2 ofs)
+/* Clips point to near clip plane before perspective divide. */
+vec4 clip_line_point_homogeneous_space(vec4 p, vec4 q)
+{
+ if (p.z < -p.w) {
+ /* Just solves p + (q - p) * A; for A when p.z / p.w = -1.0. */
+ float denom = q.z - p.z + q.w - p.w;
+ if (denom == 0.0) {
+ /* No solution. */
+ return p;
+ }
+ float A = (-p.z - p.w) / denom;
+ p = p + (q - p) * A;
+ }
+ return p;
+}
+
+void do_vertex(const int i, vec4 pos, vec2 ofs)
{
#if defined(UNIFORM)
finalColor = color;
@@ -38,21 +54,22 @@ void do_vertex(const int i, vec2 ofs)
#endif
smoothline = (lineWidth + SMOOTH_WIDTH) * 0.5;
- gl_Position = gl_in[i].gl_Position;
- gl_Position.xy += ofs * gl_Position.w;
+ gl_Position = pos;
+ gl_Position.xy += ofs * pos.w;
EmitVertex();
smoothline = -(lineWidth + SMOOTH_WIDTH) * 0.5;
- gl_Position = gl_in[i].gl_Position;
- gl_Position.xy -= ofs * gl_Position.w;
+ gl_Position = pos;
+ gl_Position.xy -= ofs * pos.w;
EmitVertex();
}
void main(void)
{
- vec2 p0 = gl_in[0].gl_Position.xy / gl_in[0].gl_Position.w;
- vec2 p1 = gl_in[1].gl_Position.xy / gl_in[1].gl_Position.w;
- vec2 e = normalize((p1 - p0) * viewportSize.xy);
+ vec4 p0 = clip_line_point_homogeneous_space(gl_in[0].gl_Position, gl_in[1].gl_Position);
+ vec4 p1 = clip_line_point_homogeneous_space(gl_in[1].gl_Position, gl_in[0].gl_Position);
+ vec2 e = normalize(((p1.xy / p1.w) - (p0.xy / p0.w)) * viewportSize.xy);
+
#if 0 /* Hard turn when line direction changes quadrant. */
e = abs(e);
vec2 ofs = (e.x > e.y) ? vec2(0.0, 1.0 / e.x) : vec2(1.0 / e.y, 0.0);
@@ -62,8 +79,8 @@ void main(void)
ofs /= viewportSize.xy;
ofs *= lineWidth + SMOOTH_WIDTH;
- do_vertex(0, ofs);
- do_vertex(1, ofs);
+ do_vertex(0, p0, ofs);
+ do_vertex(1, p1, ofs);
EndPrimitive();
}
diff --git a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
index 21c925560b9..da6e6502e62 100644
--- a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
@@ -69,10 +69,10 @@ void main(void)
vec4 P3 = gl_in[3].gl_Position;
/* get the four vertices passed to the shader */
- vec2 sp0 = toScreenSpace(P0); // start of previous segment
- vec2 sp1 = toScreenSpace(P1); // end of previous segment, start of current segment
- vec2 sp2 = toScreenSpace(P2); // end of current segment, start of next segment
- vec2 sp3 = toScreenSpace(P3); // end of next segment
+ vec2 sp0 = toScreenSpace(P0); /* start of previous segment */
+ vec2 sp1 = toScreenSpace(P1); /* end of previous segment, start of current segment */
+ vec2 sp2 = toScreenSpace(P2); /* end of current segment, start of next segment */
+ vec2 sp3 = toScreenSpace(P3); /* end of next segment */
/* culling outside viewport */
vec2 area = Viewport * 4.0;
@@ -100,8 +100,8 @@ void main(void)
vec2 n2 = vec2(-v2.y, v2.x);
/* determine miter lines by averaging the normals of the 2 segments */
- vec2 miter_a = normalize(n0 + n1); // miter at start of current segment
- vec2 miter_b = normalize(n1 + n2); // miter at end of current segment
+ vec2 miter_a = normalize(n0 + n1); /* miter at start of current segment */
+ vec2 miter_b = normalize(n1 + n2); /* miter at end of current segment */
/* determine the length of the miter by projecting it onto normal and then inverse it */
float an1 = dot(miter_a, n1);
diff --git a/source/blender/gpu/shaders/gpu_shader_point_uniform_color_aa_frag.glsl b/source/blender/gpu/shaders/gpu_shader_point_uniform_color_aa_frag.glsl
index a8e9c620535..52d59d2030f 100644
--- a/source/blender/gpu/shaders/gpu_shader_point_uniform_color_aa_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_point_uniform_color_aa_frag.glsl
@@ -8,13 +8,13 @@ void main()
{
float dist = length(gl_PointCoord - vec2(0.5));
- // transparent outside of point
- // --- 0 ---
- // smooth transition
- // --- 1 ---
- // pure point color
- // ...
- // dist = 0 at center of point
+ /* transparent outside of point
+ * --- 0 ---
+ * smooth transition
+ * --- 1 ---
+ * pure point color
+ * ...
+ * dist = 0 at center of point */
fragColor.rgb = color.rgb;
fragColor.a = mix(color.a, 0.0, smoothstep(radii[1], radii[0], dist));
diff --git a/source/blender/gpu/shaders/gpu_shader_point_uniform_color_outline_aa_frag.glsl b/source/blender/gpu/shaders/gpu_shader_point_uniform_color_outline_aa_frag.glsl
index 1c1301dd818..2ece73b3845 100644
--- a/source/blender/gpu/shaders/gpu_shader_point_uniform_color_outline_aa_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_point_uniform_color_outline_aa_frag.glsl
@@ -9,17 +9,17 @@ void main()
{
float dist = length(gl_PointCoord - vec2(0.5));
- // transparent outside of point
- // --- 0 ---
- // smooth transition
- // --- 1 ---
- // pure outline color
- // --- 2 ---
- // smooth transition
- // --- 3 ---
- // pure point color
- // ...
- // dist = 0 at center of point
+ /* transparent outside of point
+ * --- 0 ---
+ * smooth transition
+ * --- 1 ---
+ * pure outline color
+ * --- 2 ---
+ * smooth transition
+ * --- 3 ---
+ * pure point color
+ * ...
+ * dist = 0 at center of point */
float midStroke = 0.5 * (radii[1] + radii[2]);
diff --git a/source/blender/gpu/shaders/gpu_shader_point_varying_color_outline_aa_frag.glsl b/source/blender/gpu/shaders/gpu_shader_point_varying_color_outline_aa_frag.glsl
index 11694de38ca..1d936e4e072 100644
--- a/source/blender/gpu/shaders/gpu_shader_point_varying_color_outline_aa_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_point_varying_color_outline_aa_frag.glsl
@@ -9,17 +9,17 @@ void main()
{
float dist = length(gl_PointCoord - vec2(0.5));
- // transparent outside of point
- // --- 0 ---
- // smooth transition
- // --- 1 ---
- // pure outline color
- // --- 2 ---
- // smooth transition
- // --- 3 ---
- // pure fill color
- // ...
- // dist = 0 at center of point
+ /* transparent outside of point
+ * --- 0 ---
+ * smooth transition
+ * --- 1 ---
+ * pure outline color
+ * --- 2 ---
+ * smooth transition
+ * --- 3 ---
+ * pure fill color
+ * ...
+ * dist = 0 at center of point */
float midStroke = 0.5 * (radii[1] + radii[2]);
diff --git a/source/blender/gpu/shaders/gpu_shader_point_varying_color_varying_outline_aa_frag.glsl b/source/blender/gpu/shaders/gpu_shader_point_varying_color_varying_outline_aa_frag.glsl
index 6d997ec14cc..c9bd9e881bf 100644
--- a/source/blender/gpu/shaders/gpu_shader_point_varying_color_varying_outline_aa_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_point_varying_color_varying_outline_aa_frag.glsl
@@ -8,17 +8,17 @@ void main()
{
float dist = length(gl_PointCoord - vec2(0.5));
- // transparent outside of point
- // --- 0 ---
- // smooth transition
- // --- 1 ---
- // pure outline color
- // --- 2 ---
- // smooth transition
- // --- 3 ---
- // pure fill color
- // ...
- // dist = 0 at center of point
+ /* transparent outside of point
+ * --- 0 ---
+ * smooth transition
+ * --- 1 ---
+ * pure outline color
+ * --- 2 ---
+ * smooth transition
+ * --- 3 ---
+ * pure fill color
+ * ...
+ * dist = 0 at center of point */
float midStroke = 0.5 * (radii[1] + radii[2]);
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
index 3fc40fd88e5..3708b8b0531 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
@@ -387,7 +387,7 @@ void node_bsdf_principled_subsurface(vec4 base_color,
mixed_ss_base_color,
f0,
/* HACK: Pass the multiscatter flag as the sign to not add closure variations
- or increase register usage. */
+ * or increase register usage. */
(use_multiscatter != 0.0) ? f90 : -f90,
int(ssr_id),
roughness,
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index a4381f0ca8f..f569634defc 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -89,12 +89,12 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
for (curchan = pchan_tip; curchan; curchan = curchan->parent) {
pchan_root = curchan;
- curchan->flag |= POSE_CHAIN; // don't forget to clear this
+ curchan->flag |= POSE_CHAIN; /* don't forget to clear this */
chanlist[segcount] = curchan;
segcount++;
if (segcount == data->rootbone || segcount > 255) {
- break; // 255 is weak
+ break; /* 255 is weak */
}
}
if (!segcount) {
@@ -220,7 +220,7 @@ static void make_dmats(bPoseChannel *pchan)
if (pchan->parent) {
float iR_parmat[4][4];
invert_m4_m4(iR_parmat, pchan->parent->pose_mat);
- mul_m4_m4m4(pchan->chan_mat, iR_parmat, pchan->pose_mat); // delta mat
+ mul_m4_m4m4(pchan->chan_mat, iR_parmat, pchan->pose_mat); /* delta mat */
}
else {
copy_m4_m4(pchan->chan_mat, pchan->pose_mat);
@@ -231,7 +231,7 @@ static void make_dmats(bPoseChannel *pchan)
/* formula: pose_mat(b) = pose_mat(b-1) * diffmat(b-1, b) * ik_mat(b) */
/* to make this work, the diffmats have to be precalculated! Stored in chan_mat */
static void where_is_ik_bone(bPoseChannel *pchan,
- float ik_mat[3][3]) // nr = to detect if this is first bone
+ float ik_mat[3][3]) /* nr = to detect if this is first bone */
{
float vec[3], ikmat[4][4];
@@ -594,8 +594,8 @@ void iksolver_initialize_tree(struct Depsgraph *UNUSED(depsgraph),
bPoseChannel *pchan;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- if (pchan->constflag & PCHAN_HAS_IK) { // flag is set on editing constraints
- initialize_posetree(ob, pchan); // will attach it to root!
+ if (pchan->constflag & PCHAN_HAS_IK) { /* flag is set on editing constraints */
+ initialize_posetree(ob, pchan); /* will attach it to root! */
}
}
ob->pose->flag &= ~POSE_WAS_REBUILT;
@@ -618,7 +618,7 @@ void iksolver_execute_tree(struct Depsgraph *depsgraph,
/* 4. walk over the tree for regular solving */
for (a = 0; a < tree->totchannel; a++) {
- if (!(tree->pchan[a]->flag & POSE_DONE)) { // successive trees can set the flag
+ if (!(tree->pchan[a]->flag & POSE_DONE)) { /* successive trees can set the flag */
BKE_pose_where_is_bone(depsgraph, scene, ob, tree->pchan[a], ctime, 1);
}
/* Tell blender that this channel was controlled by IK,
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index 0bc73d4812b..e127e377858 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -27,7 +27,7 @@
#include <string.h>
#include <vector>
-// iTaSC headers
+/* iTaSC headers */
#ifdef WITH_IK_ITASC
# include "Armature.hpp"
# include "Cache.hpp"
@@ -58,17 +58,17 @@
#include "itasc_plugin.h"
-// default parameters
+/* default parameters */
static bItasc DefIKParam;
-// in case of animation mode, feedback and timestep is fixed
+/* in case of animation mode, feedback and timestep is fixed */
// #define ANIM_TIMESTEP 1.0
#define ANIM_FEEDBACK 0.8
// #define ANIM_QMAX 0.52
-// Structure pointed by bPose.ikdata
-// It contains everything needed to simulate the armatures
-// There can be several simulation islands independent to each other
+/* Structure pointed by bPose.ikdata
+ * It contains everything needed to simulate the armatures
+ * There can be several simulation islands independent to each other */
struct IK_Data {
struct IK_Scene *first;
};
@@ -80,7 +80,7 @@ typedef void (*ErrorCallback)(const iTaSC::ConstraintValues *values,
unsigned int nvalues,
IK_Target *iktarget);
-// one structure for each target in the scene
+/* one structure for each target in the scene */
struct IK_Target {
struct Depsgraph *bldepsgraph;
struct Scene *blscene;
@@ -88,16 +88,16 @@ struct IK_Target {
iTaSC::ConstraintSet *constraint;
struct bConstraint *blenderConstraint;
struct bPoseChannel *rootChannel;
- Object *owner; // for auto IK
+ Object *owner; /* for auto IK */
ErrorCallback errorCallback;
std::string targetName;
std::string constraintName;
unsigned short controlType;
- short channel; // index in IK channel array of channel on which this target is defined
- short ee; // end effector number
- bool simulation; // true when simulation mode is used (update feedback)
- bool eeBlend; // end effector affected by enforce blending
- float eeRest[4][4]; // end effector initial pose relative to armature
+ short channel; /* index in IK channel array of channel on which this target is defined */
+ short ee; /* end effector number */
+ bool simulation; /* true when simulation mode is used (update feedback) */
+ bool eeBlend; /* end effector affected by enforce blending */
+ float eeRest[4][4]; /* end effector initial pose relative to armature */
IK_Target()
{
@@ -124,17 +124,17 @@ struct IK_Target {
};
struct IK_Channel {
- bPoseChannel *pchan; // channel where we must copy matrix back
- KDL::Frame frame; // frame of the bone relative to object base, not armature base
- std::string tail; // segment name of the joint from which we get the bone tail
- std::string head; // segment name of the joint from which we get the bone head
- int parent; // index in this array of the parent channel
- short jointType; // type of joint, combination of IK_SegmentFlag
- char ndof; // number of joint angles for this channel
- char jointValid; // set to 1 when jointValue has been computed
- // for joint constraint
- Object *owner; // for pose and IK param
- double jointValue[4]; // computed joint value
+ bPoseChannel *pchan; /* channel where we must copy matrix back */
+ KDL::Frame frame; /* frame of the bone relative to object base, not armature base */
+ std::string tail; /* segment name of the joint from which we get the bone tail */
+ std::string head; /* segment name of the joint from which we get the bone head */
+ int parent; /* index in this array of the parent channel */
+ short jointType; /* type of joint, combination of IK_SegmentFlag */
+ char ndof; /* number of joint angles for this channel */
+ char jointValid; /* set to 1 when jointValue has been computed */
+ /* for joint constraint */
+ Object *owner; /* for pose and IK param */
+ double jointValue[4]; /* computed joint value */
IK_Channel()
{
@@ -155,20 +155,20 @@ struct IK_Scene {
struct Depsgraph *bldepsgraph;
struct Scene *blscene;
IK_Scene *next;
- int numchan; // number of channel in pchan
- int numjoint; // number of joint in jointArray
- // array of bone information, one per channel in the tree
+ int numchan; /* number of channel in pchan */
+ int numjoint; /* number of joint in jointArray */
+ /* array of bone information, one per channel in the tree */
IK_Channel *channels;
iTaSC::Armature *armature;
iTaSC::Cache *cache;
iTaSC::Scene *scene;
- iTaSC::MovingFrame *base; // armature base object
- KDL::Frame baseFrame; // frame of armature base relative to blArmature
- KDL::JntArray jointArray; // buffer for storing temporary joint array
+ iTaSC::MovingFrame *base; /* armature base object */
+ KDL::Frame baseFrame; /* frame of armature base relative to blArmature */
+ KDL::JntArray jointArray; /* buffer for storing temporary joint array */
iTaSC::Solver *solver;
Object *blArmature;
- float blScale; // scale of the Armature object (assume uniform scaling)
- float blInvScale; // inverse of Armature object scale
+ float blScale; /* scale of the Armature object (assume uniform scaling) */
+ float blInvScale; /* inverse of Armature object scale */
struct bConstraint *polarConstraint;
std::vector<IK_Target *> targets;
@@ -192,7 +192,7 @@ struct IK_Scene {
~IK_Scene()
{
- // delete scene first
+ /* delete scene first */
delete scene;
for (std::vector<IK_Target *>::iterator it = targets.begin(); it != targets.end(); ++it) {
delete (*it);
@@ -202,12 +202,12 @@ struct IK_Scene {
delete solver;
delete armature;
delete base;
- // delete cache last
+ /* delete cache last */
delete cache;
}
};
-// type of IK joint, can be combined to list the joints corresponding to a bone
+/* type of IK joint, can be combined to list the joints corresponding to a bone */
enum IK_SegmentFlag {
IK_XDOF = 1,
IK_YDOF = 2,
@@ -246,13 +246,13 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
for (curchan = pchan_tip; curchan; curchan = curchan->parent) {
pchan_root = curchan;
- if (++segcount > 255) { // 255 is weak
+ if (++segcount > 255) { /* 255 is weak */
break;
}
if (segcount == rootbone) {
- // reached this end of the chain but if the chain is overlapping with a
- // previous one, we must go back up to the root of the other chain
+ /* reached this end of the chain but if the chain is overlapping with a
+ * previous one, we must go back up to the root of the other chain */
if ((curchan->flag & POSE_CHAIN) && BLI_listbase_is_empty(&curchan->iktree)) {
rootbone++;
continue;
@@ -261,21 +261,21 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
}
if (BLI_listbase_is_empty(&curchan->iktree) == false) {
- // Oh oh, there is already a chain starting from this channel and our chain is longer...
- // Should handle this by moving the previous chain up to the beginning of our chain
- // For now we just stop here
+ /* Oh oh, there is already a chain starting from this channel and our chain is longer...
+ * Should handle this by moving the previous chain up to the beginning of our chain
+ * For now we just stop here */
break;
}
}
if (!segcount) {
return 0;
}
- // we reached a limit and still not the end of a previous chain, quit
+ /* we reached a limit and still not the end of a previous chain, quit */
if ((pchan_root->flag & POSE_CHAIN) && BLI_listbase_is_empty(&pchan_root->iktree)) {
return 0;
}
- // now that we know how many segment we have, set the flag
+ /* now that we know how many segment we have, set the flag */
for (rootbone = segcount, segcount = 0, curchan = pchan_tip; segcount < rootbone;
segcount++, curchan = curchan->parent) {
chanlist[segcount] = curchan;
@@ -286,8 +286,8 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
/* create a target */
target = (PoseTarget *)MEM_callocN(sizeof(PoseTarget), "posetarget");
target->con = con;
- // by construction there can be only one tree per channel
- // and each channel can be part of at most one tree.
+ /* by construction there can be only one tree per channel
+ * and each channel can be part of at most one tree. */
tree = (PoseTree *)pchan_root->iktree.first;
if (tree == NULL) {
@@ -308,7 +308,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
/* AND! link the tree to the root */
BLI_addtail(&pchan_root->iktree, tree);
- // new tree
+ /* new tree */
treecount = 1;
}
else {
@@ -319,7 +319,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
size = MIN2(segcount, tree->totchannel);
a = t = 0;
while (a < size && t < tree->totchannel) {
- // locate first matching channel
+ /* locate first matching channel */
for (; t < tree->totchannel && tree->pchan[t] != chanlist[segcount - a - 1]; t++) {
/* pass */
}
@@ -368,7 +368,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
tree->totchannel = newsize;
}
- // reusing tree
+ /* reusing tree */
treecount = 0;
}
@@ -431,8 +431,8 @@ static IK_Data *get_ikdata(bPose *pose)
return (IK_Data *)pose->ikdata;
}
pose->ikdata = MEM_callocN(sizeof(IK_Data), "iTaSC ikdata");
- // here init ikdata if needed
- // now that we have scene, make sure the default param are initialized
+ /* here init ikdata if needed
+ * now that we have scene, make sure the default param are initialized */
if (!DefIKParam.iksolver) {
BKE_pose_itasc_init(&DefIKParam);
}
@@ -466,7 +466,7 @@ static double EulerAngleFromMatrix(const KDL::Rotation &R, int axis)
static double ComputeTwist(const KDL::Rotation &R)
{
- // qy and qw are the y and w components of the quaternion from R
+ /* qy and qw are the y and w components of the quaternion from R */
double qy = R(0, 2) - R(2, 0);
double qw = R(0, 0) + R(1, 1) + R(2, 2) + 1;
@@ -477,7 +477,7 @@ static double ComputeTwist(const KDL::Rotation &R)
static void RemoveEulerAngleFromMatrix(KDL::Rotation &R, double angle, int axis)
{
- // compute twist parameter
+ /* compute twist parameter */
KDL::Rotation T;
switch (axis) {
case 0:
@@ -492,7 +492,7 @@ static void RemoveEulerAngleFromMatrix(KDL::Rotation &R, double angle, int axis)
default:
return;
}
- // remove angle
+ /* remove angle */
R = R * T;
}
@@ -530,18 +530,18 @@ static void GetJointRotation(KDL::Rotation &boneRot, int type, double *rot)
{
switch (type & ~IK_TRANSY) {
default:
- // fixed bone, no joint
+ /* fixed bone, no joint */
break;
case IK_XDOF:
- // RX only, get the X rotation
+ /* RX only, get the X rotation */
rot[0] = EulerAngleFromMatrix(boneRot, 0);
break;
case IK_YDOF:
- // RY only, get the Y rotation
+ /* RY only, get the Y rotation */
rot[0] = ComputeTwist(boneRot);
break;
case IK_ZDOF:
- // RZ only, get the Z rotation
+ /* RZ only, get the Z rotation */
rot[0] = EulerAngleFromMatrix(boneRot, 2);
break;
case IK_XDOF | IK_YDOF:
@@ -550,11 +550,11 @@ static void GetJointRotation(KDL::Rotation &boneRot, int type, double *rot)
rot[0] = EulerAngleFromMatrix(boneRot, 0);
break;
case IK_SWING:
- // RX+RZ
+ /* RX+RZ */
boneRot.GetXZRot().GetValue(rot);
break;
case IK_YDOF | IK_ZDOF:
- // RZ+RY
+ /* RZ+RY */
rot[1] = ComputeTwist(boneRot);
RemoveEulerAngleFromMatrix(boneRot, rot[1], 1);
rot[0] = EulerAngleFromMatrix(boneRot, 2);
@@ -576,8 +576,8 @@ static bool target_callback(const iTaSC::Timestamp &timestamp,
void *param)
{
IK_Target *target = (IK_Target *)param;
- // compute next target position
- // get target matrix from constraint.
+ /* compute next target position
+ * get target matrix from constraint. */
bConstraint *constraint = (bConstraint *)target->blenderConstraint;
float tarmat[4][4];
@@ -590,12 +590,12 @@ static bool target_callback(const iTaSC::Timestamp &timestamp,
tarmat,
1.0);
- // rootmat contains the target pose in world coordinate
- // if enforce is != 1.0, blend the target position with the end effector position
- // if the armature was in rest position. This information is available in eeRest
+ /* rootmat contains the target pose in world coordinate
+ * if enforce is != 1.0, blend the target position with the end effector position
+ * if the armature was in rest position. This information is available in eeRest */
if (constraint->enforce != 1.0f && target->eeBlend) {
- // eeRest is relative to the reference frame of the IK root
- // get this frame in world reference
+ /* eeRest is relative to the reference frame of the IK root
+ * get this frame in world reference */
float restmat[4][4];
bPoseChannel *pchan = target->rootChannel;
if (pchan->parent) {
@@ -608,7 +608,7 @@ static bool target_callback(const iTaSC::Timestamp &timestamp,
else {
mul_m4_m4m4(restmat, target->owner->obmat, target->eeRest);
}
- // blend the target
+ /* blend the target */
blend_m4_m4m4(tarmat, restmat, tarmat, constraint->enforce);
}
next.setValue(&tarmat[0][0]);
@@ -621,11 +621,11 @@ static bool base_callback(const iTaSC::Timestamp &timestamp,
void *param)
{
IK_Scene *ikscene = (IK_Scene *)param;
- // compute next armature base pose
- // algorithm:
- // ikscene->pchan[0] is the root channel of the tree
- // if it has a parent, get the pose matrix from it and replace [3] by parent pchan->tail
- // then multiply by the armature matrix to get ikscene->armature base position
+ /* compute next armature base pose
+ * algorithm:
+ * ikscene->pchan[0] is the root channel of the tree
+ * if it has a parent, get the pose matrix from it and replace [3] by parent pchan->tail
+ * then multiply by the armature matrix to get ikscene->armature base position */
bPoseChannel *pchan = ikscene->channels[0].pchan;
float rootmat[4][4];
if (pchan->parent) {
@@ -633,9 +633,9 @@ static bool base_callback(const iTaSC::Timestamp &timestamp,
float chanmat[4][4];
copy_m4_m4(chanmat, pchan->pose_mat);
copy_v3_v3(chanmat[3], pchan->pose_tail);
- // save the base as a frame too so that we can compute deformation after simulation
+ /* save the base as a frame too so that we can compute deformation after simulation */
ikscene->baseFrame.setValue(&chanmat[0][0]);
- // iTaSC armature is scaled to object scale, scale the base frame too
+ /* iTaSC armature is scaled to object scale, scale the base frame too */
ikscene->baseFrame.p *= ikscene->blScale;
mul_m4_m4m4(rootmat, ikscene->blArmature->obmat, chanmat);
}
@@ -644,22 +644,22 @@ static bool base_callback(const iTaSC::Timestamp &timestamp,
ikscene->baseFrame = iTaSC::F_identity;
}
next.setValue(&rootmat[0][0]);
- // if there is a polar target (only during solving otherwise we don't have end efffector)
+ /* if there is a polar target (only during solving otherwise we don't have end efffector) */
if (ikscene->polarConstraint && timestamp.update) {
- // compute additional rotation of base frame so that armature follows the polar target
- float imat[4][4]; // IK tree base inverse matrix
- float polemat[4][4]; // polar target in IK tree base frame
- float goalmat[4][4]; // target in IK tree base frame
- float mat[4][4]; // temp matrix
+ /* compute additional rotation of base frame so that armature follows the polar target */
+ float imat[4][4]; /* IK tree base inverse matrix */
+ float polemat[4][4]; /* polar target in IK tree base frame */
+ float goalmat[4][4]; /* target in IK tree base frame */
+ float mat[4][4]; /* temp matrix */
bKinematicConstraint *poledata = (bKinematicConstraint *)ikscene->polarConstraint->data;
invert_m4_m4(imat, rootmat);
- // polar constraint imply only one target
+ /* polar constraint imply only one target */
IK_Target *iktarget = ikscene->targets[0];
- // root channel from which we take the bone initial orientation
+ /* root channel from which we take the bone initial orientation */
IK_Channel &rootchan = ikscene->channels[0];
- // get polar target matrix in world space
+ /* get polar target matrix in world space */
BKE_constraint_target_matrix_get(ikscene->bldepsgraph,
ikscene->blscene,
ikscene->polarConstraint,
@@ -668,23 +668,23 @@ static bool base_callback(const iTaSC::Timestamp &timestamp,
ikscene->blArmature,
mat,
1.0);
- // convert to armature space
+ /* convert to armature space */
mul_m4_m4m4(polemat, imat, mat);
- // get the target in world space
- // (was computed before as target object are defined before base object).
+ /* get the target in world space
+ * (was computed before as target object are defined before base object). */
iktarget->target->getPose().getValue(mat[0]);
- // convert to armature space
+ /* convert to armature space */
mul_m4_m4m4(goalmat, imat, mat);
- // take position of target, polar target, end effector, in armature space
+ /* take position of target, polar target, end effector, in armature space */
KDL::Vector goalpos(goalmat[3]);
KDL::Vector polepos(polemat[3]);
KDL::Vector endpos = ikscene->armature->getPose(iktarget->ee).p;
- // get root bone orientation
+ /* get root bone orientation */
KDL::Frame rootframe;
ikscene->armature->getRelativeFrame(rootframe, rootchan.tail);
KDL::Vector rootx = rootframe.M.UnitX();
KDL::Vector rootz = rootframe.M.UnitZ();
- // and compute root bone head
+ /* and compute root bone head */
double q_rest[3], q[3], length;
const KDL::Joint *joint;
const KDL::Frame *tip;
@@ -692,27 +692,27 @@ static bool base_callback(const iTaSC::Timestamp &timestamp,
length = (joint->getType() == KDL::Joint::TransY) ? q[0] : tip->p(1);
KDL::Vector rootpos = rootframe.p - length * rootframe.M.UnitY();
- // compute main directions
+ /* compute main directions */
KDL::Vector dir = KDL::Normalize(endpos - rootpos);
KDL::Vector poledir = KDL::Normalize(goalpos - rootpos);
- // compute up directions
+ /* compute up directions */
KDL::Vector poleup = KDL::Normalize(polepos - rootpos);
KDL::Vector up = rootx * KDL::cos(poledata->poleangle) + rootz * KDL::sin(poledata->poleangle);
- // from which we build rotation matrix
+ /* from which we build rotation matrix */
KDL::Rotation endrot, polerot;
- // for the armature, using the root bone orientation
+ /* for the armature, using the root bone orientation */
KDL::Vector x = KDL::Normalize(dir * up);
endrot.UnitX(x);
endrot.UnitY(KDL::Normalize(x * dir));
endrot.UnitZ(-dir);
- // for the polar target
+ /* for the polar target */
x = KDL::Normalize(poledir * poleup);
polerot.UnitX(x);
polerot.UnitY(KDL::Normalize(x * poledir));
polerot.UnitZ(-poledir);
- // the difference between the two is the rotation we want to apply
+ /* the difference between the two is the rotation we want to apply */
KDL::Rotation result(polerot * endrot.Inverse());
- // apply on base frame as this is an artificial additional rotation
+ /* apply on base frame as this is an artificial additional rotation */
next.M = next.M * result;
ikscene->baseFrame.M = ikscene->baseFrame.M * result;
}
@@ -729,7 +729,7 @@ static bool copypose_callback(const iTaSC::Timestamp &timestamp,
iTaSC::ConstraintValues *values = _values;
bItasc *ikparam = (bItasc *)iktarget->owner->pose->ikparam;
- // we need default parameters
+ /* we need default parameters */
if (!ikparam) {
ikparam = &DefIKParam;
}
@@ -748,14 +748,14 @@ static bool copypose_callback(const iTaSC::Timestamp &timestamp,
}
else {
if (iktarget->controlType & iTaSC::CopyPose::CTL_POSITION) {
- // update error
+ /* update error */
values->alpha = condata->weight;
values->action = iTaSC::ACT_ALPHA | iTaSC::ACT_FEEDBACK;
values->feedback = (iktarget->simulation) ? ikparam->feedback : ANIM_FEEDBACK;
values++;
}
if (iktarget->controlType & iTaSC::CopyPose::CTL_ROTATION) {
- // update error
+ /* update error */
values->alpha = condata->orientweight;
values->action = iTaSC::ACT_ALPHA | iTaSC::ACT_FEEDBACK;
values->feedback = (iktarget->simulation) ? ikparam->feedback : ANIM_FEEDBACK;
@@ -774,7 +774,7 @@ static void copypose_error(const iTaSC::ConstraintValues *values,
int i;
if (iktarget->controlType & iTaSC::CopyPose::CTL_POSITION) {
- // update error
+ /* update error */
for (i = 0, error = 0.0, value = values->values; i < values->number; i++, value++) {
error += KDL::sqr(value->y - value->yd);
}
@@ -782,7 +782,7 @@ static void copypose_error(const iTaSC::ConstraintValues *values,
values++;
}
if (iktarget->controlType & iTaSC::CopyPose::CTL_ROTATION) {
- // update error
+ /* update error */
for (i = 0, error = 0.0, value = values->values; i < values->number; i++, value++) {
error += KDL::sqr(value->y - value->yd);
}
@@ -800,12 +800,12 @@ static bool distance_callback(const iTaSC::Timestamp &timestamp,
bKinematicConstraint *condata = (bKinematicConstraint *)iktarget->blenderConstraint->data;
iTaSC::ConstraintValues *values = _values;
bItasc *ikparam = (bItasc *)iktarget->owner->pose->ikparam;
- // we need default parameters
+ /* we need default parameters */
if (!ikparam) {
ikparam = &DefIKParam;
}
- // update weight according to mode
+ /* update weight according to mode */
if (iktarget->blenderConstraint->flag & CONSTRAINT_OFF) {
values->alpha = 0.0;
}
@@ -822,7 +822,7 @@ static bool distance_callback(const iTaSC::Timestamp &timestamp,
break;
}
if (!timestamp.substep) {
- // only update value on first timestep
+ /* only update value on first timestep */
switch (condata->mode) {
case LIMITDIST_INSIDE:
values->values[0].yd = condata->dist * 0.95;
@@ -859,11 +859,11 @@ static bool joint_callback(const iTaSC::Timestamp &timestamp,
bPoseChannel *chan = ikchan->pchan;
int dof;
- // a channel can be split into multiple joints, so we get called multiple
- // times for one channel (this callback is only for 1 joint in the armature)
- // the IK_JointTarget structure is shared between multiple joint constraint
- // and the target joint values is computed only once, remember this in jointValid
- // Don't forget to reset it before each frame
+ /* a channel can be split into multiple joints, so we get called multiple
+ * times for one channel (this callback is only for 1 joint in the armature)
+ * the IK_JointTarget structure is shared between multiple joint constraint
+ * and the target joint values is computed only once, remember this in jointValid
+ * Don't forget to reset it before each frame */
if (!ikchan->jointValid) {
float rmat[3][3];
@@ -894,8 +894,8 @@ static bool joint_callback(const iTaSC::Timestamp &timestamp,
GetJointRotation(jointRot, ikchan->jointType, ikchan->jointValue);
ikchan->jointValid = 1;
}
- // determine which part of jointValue is used for this joint
- // closely related to the way the joints are defined
+ /* determine which part of jointValue is used for this joint
+ * closely related to the way the joints are defined */
switch (ikchan->jointType & ~IK_TRANSY) {
case IK_XDOF:
case IK_YDOF:
@@ -903,19 +903,19 @@ static bool joint_callback(const iTaSC::Timestamp &timestamp,
dof = 0;
break;
case IK_XDOF | IK_YDOF:
- // X + Y
+ /* X + Y */
dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RX) ? 0 : 1;
break;
case IK_SWING:
- // XZ
+ /* XZ */
dof = 0;
break;
case IK_YDOF | IK_ZDOF:
- // Z + Y
+ /* Z + Y */
dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RZ) ? 0 : 1;
break;
case IK_SWING | IK_YDOF:
- // XZ + Y
+ /* XZ + Y */
dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RY) ? 2 : 0;
break;
case IK_REVOLUTE:
@@ -935,7 +935,7 @@ static bool joint_callback(const iTaSC::Timestamp &timestamp,
return true;
}
-// build array of joint corresponding to IK chain
+/* build array of joint corresponding to IK chain */
static int convert_channels(struct Depsgraph *depsgraph,
IK_Scene *ikscene,
PoseTree *tree,
@@ -952,14 +952,14 @@ static int convert_channels(struct Depsgraph *depsgraph,
ikchan->parent = (a > 0) ? tree->parent[a] : -1;
ikchan->owner = ikscene->blArmature;
- // the constraint and channels must be applied before we build the iTaSC scene,
- // this is because some of the pose data (e.g. pose head) don't have corresponding
- // joint angles and can't be applied to the iTaSC armature dynamically
+ /* the constraint and channels must be applied before we build the iTaSC scene,
+ * this is because some of the pose data (e.g. pose head) don't have corresponding
+ * joint angles and can't be applied to the iTaSC armature dynamically */
if (!(pchan->flag & POSE_DONE)) {
BKE_pose_where_is_bone(depsgraph, ikscene->blscene, ikscene->blArmature, pchan, ctime, 1);
}
- // tell blender that this channel was controlled by IK,
- // it's cleared on each BKE_pose_where_is()
+ /* tell blender that this channel was controlled by IK,
+ * it's cleared on each BKE_pose_where_is() */
pchan->flag |= (POSE_DONE | POSE_CHAIN);
/* set DoF flag */
@@ -1016,17 +1016,17 @@ static int convert_channels(struct Depsgraph *depsgraph,
ikchan->ndof = 0;
break;
case IK_XDOF:
- // RX only, get the X rotation
+ /* RX only, get the X rotation */
ikchan->jointType = IK_XDOF;
ikchan->ndof = 1;
break;
case IK_YDOF:
- // RY only, get the Y rotation
+ /* RY only, get the Y rotation */
ikchan->jointType = IK_YDOF;
ikchan->ndof = 1;
break;
case IK_ZDOF:
- // RZ only, get the Zz rotation
+ /* RZ only, get the Zz rotation */
ikchan->jointType = IK_ZDOF;
ikchan->ndof = 1;
break;
@@ -1035,19 +1035,19 @@ static int convert_channels(struct Depsgraph *depsgraph,
ikchan->ndof = 2;
break;
case IK_XDOF | IK_ZDOF:
- // RX+RZ
+ /* RX+RZ */
ikchan->jointType = IK_SWING;
ikchan->ndof = 2;
break;
case IK_YDOF | IK_ZDOF:
- // RZ+RY
+ /* RZ+RY */
ikchan->jointType = IK_ZDOF | IK_YDOF;
ikchan->ndof = 2;
break;
case IK_XDOF | IK_YDOF | IK_ZDOF:
- // spherical joint
+ /* spherical joint */
if (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_YLIMIT | BONE_IK_ZLIMIT)) {
- // decompose in a Swing+RotY joint
+ /* decompose in a Swing+RotY joint */
ikchan->jointType = IK_SWING | IK_YDOF;
}
else {
@@ -1062,26 +1062,26 @@ static int convert_channels(struct Depsgraph *depsgraph,
}
njoint += ikchan->ndof;
}
- // njoint is the joint coordinate, create the Joint Array
+ /* njoint is the joint coordinate, create the Joint Array */
ikscene->jointArray.resize(njoint);
ikscene->numjoint = njoint;
return njoint;
}
-// compute array of joint value corresponding to current pose
+/* compute array of joint value corresponding to current pose */
static void convert_pose(IK_Scene *ikscene)
{
KDL::Rotation boneRot;
bPoseChannel *pchan;
IK_Channel *ikchan;
Bone *bone;
- float rmat[4][4]; // rest pose of bone with parent taken into account
- float bmat[4][4]; // difference
+ float rmat[4][4]; /* rest pose of bone with parent taken into account */
+ float bmat[4][4]; /* difference */
float scale;
double *rot;
int a, joint;
- // assume uniform scaling and take Y scale as general scale for the armature
+ /* assume uniform scaling and take Y scale as general scale for the armature */
scale = len_v3(ikscene->blArmature->obmat[1]);
rot = ikscene->jointArray(0);
for (joint = a = 0, ikchan = ikscene->channels;
@@ -1103,7 +1103,7 @@ static void convert_pose(IK_Scene *ikscene)
boneRot.setValue(bmat[0]);
GetJointRotation(boneRot, ikchan->jointType, rot);
if (ikchan->jointType & IK_TRANSY) {
- // compute actual length
+ /* compute actual length */
rot[ikchan->ndof - 1] = len_v3v3(pchan->pose_tail, pchan->pose_head) * scale;
}
rot += ikchan->ndof;
@@ -1111,7 +1111,7 @@ static void convert_pose(IK_Scene *ikscene)
}
}
-// compute array of joint value corresponding to current pose
+/* compute array of joint value corresponding to current pose */
static void BKE_pose_rest(IK_Scene *ikscene)
{
bPoseChannel *pchan;
@@ -1121,11 +1121,11 @@ static void BKE_pose_rest(IK_Scene *ikscene)
double *rot;
int a, joint;
- // assume uniform scaling and take Y scale as general scale for the armature
+ /* assume uniform scaling and take Y scale as general scale for the armature */
scale = len_v3(ikscene->blArmature->obmat[1]);
- // rest pose is 0
+ /* rest pose is 0 */
SetToZero(ikscene->jointArray);
- // except for transY joints
+ /* except for transY joints */
rot = ikscene->jointArray(0);
for (joint = a = 0, ikchan = ikscene->channels;
a < ikscene->numchan && joint < ikscene->numjoint;
@@ -1178,12 +1178,12 @@ static IK_Scene *convert_tree(
ikparam = (bItasc *)ob->pose->ikparam;
if (!ikparam) {
- // you must have our own copy
+ /* you must have our own copy */
ikparam = &DefIKParam;
}
if (ikparam->flag & ITASC_SIMULATION) {
- // no cache in animation mode
+ /* no cache in animation mode */
ikscene->cache = new iTaSC::Cache();
}
@@ -1199,7 +1199,7 @@ static IK_Scene *convert_tree(
return NULL;
}
ikscene->blArmature = ob;
- // assume uniform scaling and take Y scale as general scale for the armature
+ /* assume uniform scaling and take Y scale as general scale for the armature */
ikscene->blScale = len_v3(ob->obmat[1]);
ikscene->blInvScale = (ikscene->blScale < KDL::epsilon) ? 0.0f : 1.0f / ikscene->blScale;
@@ -1208,9 +1208,9 @@ static IK_Scene *convert_tree(
std::string parent;
std::vector<double> weights;
double weight[3];
- // build the array of joints corresponding to the IK chain
+ /* build the array of joints corresponding to the IK chain */
convert_channels(depsgraph, ikscene, tree, ctime);
- // in Blender, the rest pose is always 0 for joints
+ /* in Blender, the rest pose is always 0 for joints */
BKE_pose_rest(ikscene);
rot = ikscene->jointArray(0);
@@ -1219,13 +1219,13 @@ static IK_Scene *convert_tree(
bone = pchan->bone;
KDL::Frame tip(iTaSC::F_identity);
- // compute the position and rotation of the head from previous segment
+ /* compute the position and rotation of the head from previous segment */
Vector3 *fl = bone->bone_mat;
KDL::Rotation brot(
fl[0][0], fl[1][0], fl[2][0], fl[0][1], fl[1][1], fl[2][1], fl[0][2], fl[1][2], fl[2][2]);
- // if the bone is disconnected, the head is movable in pose mode
- // take that into account by using pose matrix instead of bone
- // Note that pose is expressed in armature space, convert to previous bone space
+ /* if the bone is disconnected, the head is movable in pose mode
+ * take that into account by using pose matrix instead of bone
+ * Note that pose is expressed in armature space, convert to previous bone space */
{
float R_parmat[3][3];
float iR_parmat[3][3];
@@ -1249,10 +1249,10 @@ static IK_Scene *convert_tree(
bpos *= ikscene->blScale;
KDL::Frame head(brot, bpos);
- // rest pose length of the bone taking scaling into account
+ /* rest pose length of the bone taking scaling into account */
length = bone->length * ikscene->blScale;
parent = (a > 0) ? ikscene->channels[tree->parent[a]].tail : root;
- // first the fixed segment to the bone head
+ /* first the fixed segment to the bone head */
if (!(ikchan->pchan->bone->flag & BONE_CONNECTED) || head.M.GetRot().Norm() > KDL::epsilon) {
joint = bone->name;
joint += ":H";
@@ -1260,7 +1260,7 @@ static IK_Scene *convert_tree(
parent = joint;
}
if (!(ikchan->jointType & IK_TRANSY)) {
- // fixed length, put it in tip
+ /* fixed length, put it in tip */
tip.p[1] = length;
}
joint = bone->name;
@@ -1269,24 +1269,24 @@ static IK_Scene *convert_tree(
weight[2] = (1.0 - pchan->stiffness[2]);
switch (ikchan->jointType & ~IK_TRANSY) {
case 0:
- // fixed bone
+ /* fixed bone */
joint += ":F";
ret = arm->addSegment(joint, parent, KDL::Joint::None, 0.0, tip);
break;
case IK_XDOF:
- // RX only, get the X rotation
+ /* RX only, get the X rotation */
joint += ":RX";
ret = arm->addSegment(joint, parent, KDL::Joint::RotX, rot[0], tip);
weights.push_back(weight[0]);
break;
case IK_YDOF:
- // RY only, get the Y rotation
+ /* RY only, get the Y rotation */
joint += ":RY";
ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[0], tip);
weights.push_back(weight[1]);
break;
case IK_ZDOF:
- // RZ only, get the Zz rotation
+ /* RZ only, get the Zz rotation */
joint += ":RZ";
ret = arm->addSegment(joint, parent, KDL::Joint::RotZ, rot[0], tip);
weights.push_back(weight[2]);
@@ -1310,7 +1310,7 @@ static IK_Scene *convert_tree(
weights.push_back(weight[2]);
break;
case IK_YDOF | IK_ZDOF:
- // RZ+RY
+ /* RZ+RY */
joint += ":RZ";
ret = arm->addSegment(joint, parent, KDL::Joint::RotZ, rot[0]);
weights.push_back(weight[2]);
@@ -1323,7 +1323,7 @@ static IK_Scene *convert_tree(
}
break;
case IK_SWING | IK_YDOF:
- // decompose in a Swing+RotY joint
+ /* decompose in a Swing+RotY joint */
joint += ":SW";
ret = arm->addSegment(joint, parent, KDL::Joint::Swing, rot[0]);
weights.push_back(weight[0]);
@@ -1355,13 +1355,13 @@ static IK_Scene *convert_tree(
weights.push_back(weight[1]);
}
if (!ret) {
- // error making the armature??
+ /* error making the armature?? */
break;
}
- // joint points to the segment that correspond to the bone per say
+ /* joint points to the segment that correspond to the bone per say */
ikchan->tail = joint;
ikchan->head = parent;
- // in case of error
+ /* in case of error */
ret = false;
if ((ikchan->jointType & IK_XDOF) && (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_ROTCTL))) {
joint = bone->name;
@@ -1432,7 +1432,7 @@ static IK_Scene *convert_tree(
break;
}
}
- // no error, so restore
+ /* no error, so restore */
ret = true;
rot += ikchan->ndof;
}
@@ -1440,7 +1440,7 @@ static IK_Scene *convert_tree(
delete ikscene;
return NULL;
}
- // for each target, we need to add an end effector in the armature
+ /* for each target, we need to add an end effector in the armature */
for (numtarget = 0, polarcon = NULL, ret = true, target = (PoseTarget *)tree->targets.first;
target;
target = (PoseTarget *)target->next) {
@@ -1448,7 +1448,7 @@ static IK_Scene *convert_tree(
pchan = tree->pchan[target->tip];
if (is_cartesian_constraint(target->con)) {
- // add the end effector
+ /* add the end effector */
IK_Target *iktarget = new IK_Target();
ikscene->targets.push_back(iktarget);
iktarget->ee = arm->addEndEffector(ikscene->channels[target->tip].tail);
@@ -1456,7 +1456,7 @@ static IK_Scene *convert_tree(
ret = false;
break;
}
- // initialize all the fields that we can set at this time
+ /* initialize all the fields that we can set at this time */
iktarget->blenderConstraint = target->con;
iktarget->channel = target->tip;
iktarget->simulation = (ikparam->flag & ITASC_SIMULATION);
@@ -1470,18 +1470,18 @@ static IK_Scene *convert_tree(
iktarget->constraintName += target->con->name;
numtarget++;
if (condata->poletar) {
- // this constraint has a polar target
+ /* this constraint has a polar target */
polarcon = target->con;
}
}
}
- // deal with polar target if any
+ /* deal with polar target if any */
if (numtarget == 1 && polarcon) {
ikscene->polarConstraint = polarcon;
}
- // we can now add the armature
- // the armature is based on a moving frame.
- // initialize with the correct position in case there is no cache
+ /* we can now add the armature
+ * the armature is based on a moving frame.
+ * initialize with the correct position in case there is no cache */
base_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, ikscene);
ikscene->base = new iTaSC::MovingFrame(initPose);
ikscene->base->setCallback(base_callback, ikscene);
@@ -1498,31 +1498,31 @@ static IK_Scene *convert_tree(
delete ikscene;
return NULL;
}
- // set the weight
+ /* set the weight */
e_matrix &Wq = arm->getWq();
assert(Wq.cols() == (int)weights.size());
for (int q = 0; q < Wq.cols(); q++) {
Wq(q, q) = weights[q];
}
- // get the inverse rest pose frame of the base to compute relative rest pose of end effectors
- // this is needed to handle the enforce parameter
- // ikscene->pchan[0] is the root channel of the tree
- // if it has no parent, then it's just the identify Frame
+ /* get the inverse rest pose frame of the base to compute relative rest pose of end effectors
+ * this is needed to handle the enforce parameter
+ * ikscene->pchan[0] is the root channel of the tree
+ * if it has no parent, then it's just the identify Frame */
float invBaseFrame[4][4];
pchan = ikscene->channels[0].pchan;
if (pchan->parent) {
- // it has a parent, get the pose matrix from it
+ /* it has a parent, get the pose matrix from it */
float baseFrame[4][4];
pchan = pchan->parent;
copy_m4_m4(baseFrame, pchan->bone->arm_mat);
- // move to the tail and scale to get rest pose of armature base
+ /* move to the tail and scale to get rest pose of armature base */
copy_v3_v3(baseFrame[3], pchan->bone->arm_tail);
invert_m4_m4(invBaseFrame, baseFrame);
}
else {
unit_m4(invBaseFrame);
}
- // finally add the constraint
+ /* finally add the constraint */
for (t = 0; t < ikscene->targets.size(); t++) {
IK_Target *iktarget = ikscene->targets[t];
iktarget->blscene = blscene;
@@ -1533,23 +1533,23 @@ static IK_Scene *convert_tree(
double bonelen;
float mat[4][4];
- // add the end effector
- // estimate the average bone length, used to clamp feedback error
+ /* add the end effector
+ * estimate the average bone length, used to clamp feedback error */
for (bonecnt = 0, bonelen = 0.f, a = iktarget->channel; a >= 0;
a = tree->parent[a], bonecnt++) {
bonelen += ikscene->blScale * tree->pchan[a]->bone->length;
}
bonelen /= bonecnt;
- // store the rest pose of the end effector to compute enforce target
+ /* store the rest pose of the end effector to compute enforce target */
copy_m4_m4(mat, pchan->bone->arm_mat);
copy_v3_v3(mat[3], pchan->bone->arm_tail);
- // get the rest pose relative to the armature base
+ /* get the rest pose relative to the armature base */
mul_m4_m4m4(iktarget->eeRest, invBaseFrame, mat);
iktarget->eeBlend = (!ikscene->polarConstraint && condata->type == CONSTRAINT_IK_COPYPOSE) ?
true :
false;
- // use target_callback to make sure the initPose includes enforce coefficient
+ /* use target_callback to make sure the initPose includes enforce coefficient */
target_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, iktarget);
iktarget->target = new iTaSC::MovingFrame(initPose);
iktarget->target->setCallback(target_callback, iktarget);
@@ -1585,7 +1585,7 @@ static IK_Scene *convert_tree(
}
if (controltype) {
iktarget->constraint = new iTaSC::CopyPose(controltype, controltype, bonelen);
- // set the gain
+ /* set the gain */
if (controltype & iTaSC::CopyPose::CTL_POSITION) {
iktarget->constraint->setControlParameter(
iTaSC::CopyPose::ID_POSITION, iTaSC::ACT_ALPHA, condata->weight);
@@ -1597,7 +1597,7 @@ static IK_Scene *convert_tree(
iktarget->constraint->registerCallback(copypose_callback, iktarget);
iktarget->errorCallback = copypose_error;
iktarget->controlType = controltype;
- // add the constraint
+ /* add the constraint */
if (condata->flag & CONSTRAINT_IK_TARGETAXIS) {
ret = scene->addConstraintSet(iktarget->constraintName,
iktarget->constraint,
@@ -1621,9 +1621,9 @@ static IK_Scene *convert_tree(
iTaSC::Distance::ID_DISTANCE, iTaSC::ACT_VALUE, condata->dist);
iktarget->constraint->registerCallback(distance_callback, iktarget);
iktarget->errorCallback = distance_error;
- // we can update the weight on each substep
+ /* we can update the weight on each substep */
iktarget->constraint->substep(true);
- // add the constraint
+ /* add the constraint */
ret = scene->addConstraintSet(iktarget->constraintName,
iktarget->constraint,
armname,
@@ -1647,20 +1647,20 @@ static void create_scene(struct Depsgraph *depsgraph, Scene *scene, Object *ob,
{
bPoseChannel *pchan;
- // create the IK scene
+ /* create the IK scene */
for (pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan;
pchan = (bPoseChannel *)pchan->next) {
- // by construction there is only one tree
+ /* by construction there is only one tree */
PoseTree *tree = (PoseTree *)pchan->iktree.first;
if (tree) {
IK_Data *ikdata = get_ikdata(ob->pose);
- // convert tree in iTaSC::Scene
+ /* convert tree in iTaSC::Scene */
IK_Scene *ikscene = convert_tree(depsgraph, scene, ob, pchan, ctime);
if (ikscene) {
ikscene->next = ikdata->first;
ikdata->first = ikscene;
}
- // delete the trees once we are done
+ /* delete the trees once we are done */
while (tree) {
BLI_remlink(&pchan->iktree, tree);
BLI_freelistN(&tree->targets);
@@ -1683,7 +1683,7 @@ static void create_scene(struct Depsgraph *depsgraph, Scene *scene, Object *ob,
/* returns 1 if scaling has changed and tree must be reinitialized */
static int init_scene(Object *ob)
{
- // check also if scaling has changed
+ /* check also if scaling has changed */
float scale = len_v3(ob->obmat[1]);
IK_Scene *scene;
@@ -1709,26 +1709,26 @@ static void execute_scene(struct Depsgraph *depsgraph,
IK_Channel *ikchan;
if (ikparam->flag & ITASC_SIMULATION) {
for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ikchan++) {
- // In simulation mode we don't allow external constraint to change our bones,
- // mark the channel done also tell Blender that this channel is part of IK tree.
- // Cleared on each BKE_pose_where_is()
+ /* In simulation mode we don't allow external constraint to change our bones,
+ * mark the channel done also tell Blender that this channel is part of IK tree.
+ * Cleared on each BKE_pose_where_is() */
ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN);
ikchan->jointValid = 0;
}
}
else {
- // in animation mode, we must get the bone position from action and constraints
+ /* in animation mode, we must get the bone position from action and constraints */
for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ikchan++) {
if (!(ikchan->pchan->flag & POSE_DONE)) {
BKE_pose_where_is_bone(depsgraph, blscene, ikscene->blArmature, ikchan->pchan, ctime, 1);
}
- // tell blender that this channel was controlled by IK,
- // it's cleared on each BKE_pose_where_is()
+ /* tell blender that this channel was controlled by IK,
+ * it's cleared on each BKE_pose_where_is() */
ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN);
ikchan->jointValid = 0;
}
}
- // only run execute the scene if at least one of our target is enabled
+ /* only run execute the scene if at least one of our target is enabled */
for (i = ikscene->targets.size(); i > 0; i--) {
IK_Target *iktarget = ikscene->targets[i - 1];
if (!(iktarget->blenderConstraint->flag & CONSTRAINT_OFF)) {
@@ -1736,11 +1736,11 @@ static void execute_scene(struct Depsgraph *depsgraph,
}
}
if (i == 0 && ikscene->armature->getNrOfConstraints() == 0) {
- // all constraint disabled
+ /* all constraint disabled */
return;
}
- // compute timestep
+ /* compute timestep */
double timestamp = ctime * frtime + 2147483.648;
double timestep = frtime;
bool reiterate = (ikparam->flag & ITASC_REITERATION) ? true : false;
@@ -1751,16 +1751,16 @@ static void execute_scene(struct Depsgraph *depsgraph,
ikscene->solver->setParam(iTaSC::Solver::DLS_QMAX, ikparam->maxvel);
}
else {
- // in animation mode we start from the pose after action and constraint
+ /* in animation mode we start from the pose after action and constraint */
convert_pose(ikscene);
ikscene->armature->setJointArray(ikscene->jointArray);
- // and we don't handle velocity
+ /* and we don't handle velocity */
reiterate = true;
simulation = false;
- // time is virtual, so take fixed value for velocity parameters (see itasc_update_param)
- // and choose 1s timestep to allow having velocity parameters in radiant
+ /* time is virtual, so take fixed value for velocity parameters (see itasc_update_param)
+ * and choose 1s timestep to allow having velocity parameters in radiant */
timestep = 1.0;
- // use auto setup to let the solver test the variation of the joints
+ /* use auto setup to let the solver test the variation of the joints */
numstep = 0;
}
@@ -1768,21 +1768,21 @@ static void execute_scene(struct Depsgraph *depsgraph,
iTaSC::CacheTS sts, cts;
sts = cts = (iTaSC::CacheTS)std::round(timestamp * 1000.0);
if (ikscene->cache->getPreviousCacheItem(ikscene->armature, 0, &cts) == NULL || cts == 0) {
- // the cache is empty before this time, reiterate
+ /* the cache is empty before this time, reiterate */
if (ikparam->flag & ITASC_INITIAL_REITERATION) {
reiterate = true;
}
}
else {
- // can take the cache as a start point.
+ /* can take the cache as a start point. */
sts -= cts;
timestep = sts / 1000.0;
}
}
- // don't cache if we are reiterating because we don't want to destroy the cache unnecessarily
+ /* don't cache if we are reiterating because we don't want to destroy the cache unnecessarily */
ikscene->scene->update(timestamp, timestep, numstep, false, !reiterate, simulation);
if (reiterate) {
- // how many times do we reiterate?
+ /* how many times do we reiterate? */
for (i = 0; i < ikparam->numiter; i++) {
if (ikscene->armature->getMaxJointChange() < ikparam->precision ||
ikscene->armature->getMaxEndEffectorChange() < ikparam->precision) {
@@ -1791,11 +1791,11 @@ static void execute_scene(struct Depsgraph *depsgraph,
ikscene->scene->update(timestamp, timestep, numstep, true, false, simulation);
}
if (simulation) {
- // one more fake iteration to cache
+ /* one more fake iteration to cache */
ikscene->scene->update(timestamp, 0.0, 1, true, true, true);
}
}
- // compute constraint error
+ /* compute constraint error */
for (i = ikscene->targets.size(); i > 0; i--) {
IK_Target *iktarget = ikscene->targets[i - 1];
if (!(iktarget->blenderConstraint->flag & CONSTRAINT_OFF) && iktarget->constraint) {
@@ -1805,12 +1805,12 @@ static void execute_scene(struct Depsgraph *depsgraph,
iktarget->errorCallback(values, nvalues, iktarget);
}
}
- // Apply result to bone:
- // walk the ikscene->channels
- // for each, get the Frame of the joint corresponding to the bone relative to its parent
- // combine the parent and the joint frame to get the frame relative to armature
- // a backward translation of the bone length gives the head
- // if TY, compute the scale as the ratio of the joint length with rest pose length
+ /* Apply result to bone:
+ * walk the ikscene->channels
+ * for each, get the Frame of the joint corresponding to the bone relative to its parent
+ * combine the parent and the joint frame to get the frame relative to armature
+ * a backward translation of the bone length gives the head
+ * if TY, compute the scale as the ratio of the joint length with rest pose length */
iTaSC::Armature *arm = ikscene->armature;
KDL::Frame frame;
double q_rest[3], q[3];
@@ -1825,59 +1825,59 @@ static void execute_scene(struct Depsgraph *depsgraph,
if (!arm->getRelativeFrame(frame, ikchan->tail)) {
break;
}
- // this frame is relative to base, make it relative to object
+ /* this frame is relative to base, make it relative to object */
ikchan->frame = ikscene->baseFrame * frame;
}
else {
if (!arm->getRelativeFrame(frame, ikchan->tail, ikscene->channels[ikchan->parent].tail)) {
break;
}
- // combine with parent frame to get frame relative to object
+ /* combine with parent frame to get frame relative to object */
ikchan->frame = ikscene->channels[ikchan->parent].frame * frame;
}
- // ikchan->frame is the tail frame relative to object
- // get bone length
+ /* ikchan->frame is the tail frame relative to object
+ * get bone length */
if (!arm->getSegment(ikchan->tail, 3, joint, q_rest[0], q[0], tip)) {
break;
}
if (joint->getType() == KDL::Joint::TransY) {
- // stretch bones have a TY joint, compute the scale
+ /* stretch bones have a TY joint, compute the scale */
scale = (float)(q[0] / q_rest[0]);
- // the length is the joint itself
+ /* the length is the joint itself */
length = (float)q[0];
}
else {
scale = 1.0f;
- // for fixed bone, the length is in the tip (always along Y axis)
+ /* for fixed bone, the length is in the tip (always along Y axis) */
length = tip->p(1);
}
- // ready to compute the pose mat
+ /* ready to compute the pose mat */
pchan = ikchan->pchan;
- // tail mat
+ /* tail mat */
ikchan->frame.getValue(&pchan->pose_mat[0][0]);
- // the scale of the object was included in the ik scene, take it out now
- // because the pose channels are relative to the object
+ /* the scale of the object was included in the ik scene, take it out now
+ * because the pose channels are relative to the object */
mul_v3_fl(pchan->pose_mat[3], ikscene->blInvScale);
length *= ikscene->blInvScale;
copy_v3_v3(pchan->pose_tail, pchan->pose_mat[3]);
- // shift to head
+ /* shift to head */
copy_v3_v3(yaxis, pchan->pose_mat[1]);
mul_v3_fl(yaxis, length);
sub_v3_v3v3(pchan->pose_mat[3], pchan->pose_mat[3], yaxis);
copy_v3_v3(pchan->pose_head, pchan->pose_mat[3]);
- // add scale
+ /* add scale */
mul_v3_fl(pchan->pose_mat[0], scale);
mul_v3_fl(pchan->pose_mat[1], scale);
mul_v3_fl(pchan->pose_mat[2], scale);
}
if (i < ikscene->numchan) {
- // big problem
+ /* big problem */
}
}
-//---------------------------------------------------
-// plugin interface
-//
+/*---------------------------------------------------
+ * plugin interface
+ * */
void itasc_initialize_tree(struct Depsgraph *depsgraph,
struct Scene *scene,
Object *ob,
@@ -1891,23 +1891,23 @@ void itasc_initialize_tree(struct Depsgraph *depsgraph,
return;
}
}
- // first remove old scene
+ /* first remove old scene */
itasc_clear_data(ob->pose);
- // we should handle all the constraint and mark them all disabled
- // for blender but we'll start with the IK constraint alone
+ /* we should handle all the constraint and mark them all disabled
+ * for blender but we'll start with the IK constraint alone */
for (pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan;
pchan = (bPoseChannel *)pchan->next) {
if (pchan->constflag & PCHAN_HAS_IK) {
count += initialize_scene(ob, pchan);
}
}
- // if at least one tree, create the scenes from the PoseTree stored in the channels
- // postpone until execute_tree: this way the pose constraint are included
+ /* if at least one tree, create the scenes from the PoseTree stored in the channels
+ * postpone until execute_tree: this way the pose constraint are included */
if (count) {
create_scene(depsgraph, scene, ob, ctime);
}
itasc_update_param(ob->pose);
- // make sure we don't rebuilt until the user changes something important
+ /* make sure we don't rebuilt until the user changes something important */
ob->pose->flag &= ~POSE_WAS_REBUILT;
}
@@ -1920,7 +1920,7 @@ void itasc_execute_tree(struct Depsgraph *depsgraph,
if (ob->pose->ikdata) {
IK_Data *ikdata = (IK_Data *)ob->pose->ikdata;
bItasc *ikparam = (bItasc *)ob->pose->ikparam;
- // we need default parameters
+ /* we need default parameters */
if (!ikparam) {
ikparam = &DefIKParam;
}
@@ -1937,7 +1937,7 @@ void itasc_execute_tree(struct Depsgraph *depsgraph,
void itasc_release_tree(struct Scene *scene, struct Object *ob, float ctime)
{
- // not used for iTaSC
+ /* not used for iTaSC */
}
void itasc_clear_data(struct bPose *pose)
@@ -1959,7 +1959,7 @@ void itasc_clear_cache(struct bPose *pose)
IK_Data *ikdata = (IK_Data *)pose->ikdata;
for (IK_Scene *scene = ikdata->first; scene; scene = scene->next) {
if (scene->cache) {
- // clear all cache but leaving the timestamp 0 (=rest pose)
+ /* clear all cache but leaving the timestamp 0 (=rest pose) */
scene->cache->clearCacheFrom(NULL, 1);
}
}
@@ -1983,8 +1983,8 @@ void itasc_update_param(struct bPose *pose)
CONSTRAINT_ID_ALL, iTaSC::Armature::ID_JOINT, iTaSC::ACT_FEEDBACK, ikparam->feedback);
}
else {
- // in animation mode timestep is 1s by convention => qmax becomes radiant and feedback
- // becomes fraction of error gap corrected in one iteration.
+ /* in animation mode timestep is 1s by convention => qmax becomes radiant and feedback
+ * becomes fraction of error gap corrected in one iteration. */
ikscene->scene->setParam(iTaSC::Scene::MIN_TIMESTEP, 1.0);
ikscene->scene->setParam(iTaSC::Scene::MAX_TIMESTEP, 1.0);
ikscene->solver->setParam(iTaSC::Solver::DLS_QMAX, 0.52);
diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h
index babff5c34cd..1239d3881de 100644
--- a/source/blender/imbuf/intern/IMB_anim.h
+++ b/source/blender/imbuf/intern/IMB_anim.h
@@ -32,9 +32,9 @@
# include <windows.h>
# include <windowsx.h>
-# undef AVIIF_KEYFRAME // redefined in AVI_avi.h
-# undef AVIIF_LIST // redefined in AVI_avi.h
-#endif /* _WIN32 */
+# undef AVIIF_KEYFRAME /* redefined in AVI_avi.h */
+# undef AVIIF_LIST /* redefined in AVI_avi.h */
+#endif /* _WIN32 */
#include <ctype.h>
#include <stdio.h>
@@ -117,7 +117,7 @@ struct anim {
int firstvideo;
int pfileopen;
PAVIFILE pfile;
- PAVISTREAM pavi[MAXNUMSTREAMS]; // the current streams
+ PAVISTREAM pavi[MAXNUMSTREAMS]; /* the current streams */
PGETFRAME pgf;
#endif
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index f5ae602946e..d825b20f5f2 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -82,7 +82,7 @@
# include <libswscale/swscale.h>
# include "ffmpeg_compat.h"
-#endif // WITH_FFMPEG
+#endif /* WITH_FFMPEG */
int ismovie(const char *UNUSED(filepath))
{
@@ -467,7 +467,7 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position)
if (lpbi) {
ibuf = IMB_ibImageFromMemory(
(const unsigned char *)lpbi, 100, IB_rect, anim->colorspace, "<avi_fetchibuf>");
- // Oh brother...
+ /* Oh brother... */
}
}
}
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c
index 74a0684c35c..446f360a3e7 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.c
+++ b/source/blender/imbuf/intern/cineon/logImageCore.c
@@ -1689,7 +1689,7 @@ static int convertLogElementToRGBA(
if (dstIsLinearRGB) {
/* convert data from sRGB to Linear RGB via lut */
float *lut = getSrgbToLinLut(logElement);
- src_ptr = dst; // no error here
+ src_ptr = dst; /* no error here */
dst_ptr = dst;
for (i = 0; i < logImage->width * logImage->height; i++) {
*(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
diff --git a/source/blender/imbuf/intern/dds/BlockDXT.cpp b/source/blender/imbuf/intern/dds/BlockDXT.cpp
index 8978b823e2a..2d9c300a147 100644
--- a/source/blender/imbuf/intern/dds/BlockDXT.cpp
+++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp
@@ -25,28 +25,28 @@
* Original license from NVIDIA follows.
*/
-// Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
+/* Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE. */
#include <BlockDXT.h>
#include <ColorBlock.h>
@@ -59,32 +59,32 @@
uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
{
- // Does bit expansion before interpolation.
+ /* Does bit expansion before interpolation. */
color_array[0].b = (col0.b << 3) | (col0.b >> 2);
color_array[0].g = (col0.g << 2) | (col0.g >> 4);
color_array[0].r = (col0.r << 3) | (col0.r >> 2);
color_array[0].a = 0xFF;
- // @@ Same as above, but faster?
- // Color32 c;
- // c.u = ((col0.u << 3) & 0xf8) | ((col0.u << 5) & 0xfc00) | ((col0.u << 8) & 0xf80000);
- // c.u |= (c.u >> 5) & 0x070007;
- // c.u |= (c.u >> 6) & 0x000300;
- // color_array[0].u = c.u;
+ /* @@ Same as above, but faster?
+ * Color32 c;
+ * c.u = ((col0.u << 3) & 0xf8) | ((col0.u << 5) & 0xfc00) | ((col0.u << 8) & 0xf80000);
+ * c.u |= (c.u >> 5) & 0x070007;
+ * c.u |= (c.u >> 6) & 0x000300;
+ * color_array[0].u = c.u; */
color_array[1].r = (col1.r << 3) | (col1.r >> 2);
color_array[1].g = (col1.g << 2) | (col1.g >> 4);
color_array[1].b = (col1.b << 3) | (col1.b >> 2);
color_array[1].a = 0xFF;
- // @@ Same as above, but faster?
- // c.u = ((col1.u << 3) & 0xf8) | ((col1.u << 5) & 0xfc00) | ((col1.u << 8) & 0xf80000);
- // c.u |= (c.u >> 5) & 0x070007;
- // c.u |= (c.u >> 6) & 0x000300;
- // color_array[1].u = c.u;
+ /* @@ Same as above, but faster?
+ * c.u = ((col1.u << 3) & 0xf8) | ((col1.u << 5) & 0xfc00) | ((col1.u << 8) & 0xf80000);
+ * c.u |= (c.u >> 5) & 0x070007;
+ * c.u |= (c.u >> 6) & 0x000300;
+ * color_array[1].u = c.u; */
if (col0.u > col1.u) {
- // Four-color block: derive the other two colors.
+ /* Four-color block: derive the other two colors. */
color_array[2].r = (2 * color_array[0].r + color_array[1].r) / 3;
color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3;
color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3;
@@ -98,16 +98,16 @@ uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
return 4;
}
- // Three-color block: derive the other color.
+ /* Three-color block: derive the other color. */
color_array[2].r = (color_array[0].r + color_array[1].r) / 2;
color_array[2].g = (color_array[0].g + color_array[1].g) / 2;
color_array[2].b = (color_array[0].b + color_array[1].b) / 2;
color_array[2].a = 0xFF;
- // Set all components to 0 to match DXT specs.
- color_array[3].r = 0x00; // color_array[2].r;
- color_array[3].g = 0x00; // color_array[2].g;
- color_array[3].b = 0x00; // color_array[2].b;
+ /* Set all components to 0 to match DXT specs. */
+ color_array[3].r = 0x00; /* color_array[2].r; */
+ color_array[3].g = 0x00; /* color_array[2].g; */
+ color_array[3].b = 0x00; /* color_array[2].b; */
color_array[3].a = 0x00;
return 3;
@@ -115,7 +115,7 @@ uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
{
- // Does bit expansion before interpolation.
+ /* Does bit expansion before interpolation. */
color_array[0].b = (3 * col0.b * 22) / 8;
color_array[0].g = (col0.g << 2) | (col0.g >> 4);
color_array[0].r = (3 * col0.r * 22) / 8;
@@ -129,7 +129,7 @@ uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
int gdiff = color_array[1].g - color_array[0].g;
if (col0.u > col1.u) {
- // Four-color block: derive the other two colors.
+ /* Four-color block: derive the other two colors. */
color_array[2].r = ((2 * col0.r + col1.r) * 22) / 8;
color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 80) / 256;
color_array[2].b = ((2 * col0.b + col1.b) * 22) / 8;
@@ -143,22 +143,22 @@ uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
return 4;
}
- // Three-color block: derive the other color.
+ /* Three-color block: derive the other color. */
color_array[2].r = ((col0.r + col1.r) * 33) / 8;
color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 128) / 256;
color_array[2].b = ((col0.b + col1.b) * 33) / 8;
color_array[2].a = 0xFF;
- // Set all components to 0 to match DXT specs.
- color_array[3].r = 0x00; // color_array[2].r;
- color_array[3].g = 0x00; // color_array[2].g;
- color_array[3].b = 0x00; // color_array[2].b;
+ /* Set all components to 0 to match DXT specs. */
+ color_array[3].r = 0x00; /* color_array[2].r; */
+ color_array[3].g = 0x00; /* color_array[2].g; */
+ color_array[3].b = 0x00; /* color_array[2].b; */
color_array[3].a = 0x00;
return 3;
}
-// Evaluate palette assuming 3 color block.
+/* Evaluate palette assuming 3 color block. */
void BlockDXT1::evaluatePalette3(Color32 color_array[4]) const
{
color_array[0].b = (col0.b << 3) | (col0.b >> 2);
@@ -171,20 +171,20 @@ void BlockDXT1::evaluatePalette3(Color32 color_array[4]) const
color_array[1].b = (col1.b << 3) | (col1.b >> 2);
color_array[1].a = 0xFF;
- // Three-color block: derive the other color.
+ /* Three-color block: derive the other color. */
color_array[2].r = (color_array[0].r + color_array[1].r) / 2;
color_array[2].g = (color_array[0].g + color_array[1].g) / 2;
color_array[2].b = (color_array[0].b + color_array[1].b) / 2;
color_array[2].a = 0xFF;
- // Set all components to 0 to match DXT specs.
- color_array[3].r = 0x00; // color_array[2].r;
- color_array[3].g = 0x00; // color_array[2].g;
- color_array[3].b = 0x00; // color_array[2].b;
+ /* Set all components to 0 to match DXT specs. */
+ color_array[3].r = 0x00; /* color_array[2].r; */
+ color_array[3].g = 0x00; /* color_array[2].g; */
+ color_array[3].b = 0x00; /* color_array[2].b; */
color_array[3].a = 0x00;
}
-// Evaluate palette assuming 4 color block.
+/* Evaluate palette assuming 4 color block. */
void BlockDXT1::evaluatePalette4(Color32 color_array[4]) const
{
color_array[0].b = (col0.b << 3) | (col0.b >> 2);
@@ -197,7 +197,7 @@ void BlockDXT1::evaluatePalette4(Color32 color_array[4]) const
color_array[1].b = (col1.b << 3) | (col1.b >> 2);
color_array[1].a = 0xFF;
- // Four-color block: derive the other two colors.
+ /* Four-color block: derive the other two colors. */
color_array[2].r = (2 * color_array[0].r + color_array[1].r) / 3;
color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3;
color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3;
@@ -211,11 +211,11 @@ void BlockDXT1::evaluatePalette4(Color32 color_array[4]) const
void BlockDXT1::decodeBlock(ColorBlock *block) const
{
- // Decode color block.
+ /* Decode color block. */
Color32 color_array[4];
evaluatePalette(color_array);
- // Write color block.
+ /* Write color block. */
for (uint j = 0; j < 4; j++) {
for (uint i = 0; i < 4; i++) {
uint idx = (row[j] >> (2 * i)) & 3;
@@ -226,11 +226,11 @@ void BlockDXT1::decodeBlock(ColorBlock *block) const
void BlockDXT1::decodeBlockNV5x(ColorBlock *block) const
{
- // Decode color block.
+ /* Decode color block. */
Color32 color_array[4];
evaluatePaletteNV5x(color_array);
- // Write color block.
+ /* Write color block. */
for (uint j = 0; j < 4; j++) {
for (uint i = 0; i < 4; i++) {
uint idx = (row[j] >> (2 * i)) & 3;
@@ -266,10 +266,10 @@ inline void BlockDXT1::flip2()
void BlockDXT3::decodeBlock(ColorBlock *block) const
{
- // Decode color.
+ /* Decode color. */
color.decodeBlock(block);
- // Decode alpha.
+ /* Decode alpha. */
alpha.decodeBlock(block);
}
@@ -342,30 +342,30 @@ void AlphaBlockDXT5::evaluatePalette(uint8 alpha[8]) const
void AlphaBlockDXT5::evaluatePalette8(uint8 alpha[8]) const
{
- // 8-alpha block: derive the other six alphas.
- // Bit code 000 = alpha0, 001 = alpha1, others are interpolated.
+ /* 8-alpha block: derive the other six alphas.
+ * Bit code 000 = alpha0, 001 = alpha1, others are interpolated. */
alpha[0] = alpha0();
alpha[1] = alpha1();
- alpha[2] = (6 * alpha[0] + 1 * alpha[1]) / 7; // bit code 010
- alpha[3] = (5 * alpha[0] + 2 * alpha[1]) / 7; // bit code 011
- alpha[4] = (4 * alpha[0] + 3 * alpha[1]) / 7; // bit code 100
- alpha[5] = (3 * alpha[0] + 4 * alpha[1]) / 7; // bit code 101
- alpha[6] = (2 * alpha[0] + 5 * alpha[1]) / 7; // bit code 110
- alpha[7] = (1 * alpha[0] + 6 * alpha[1]) / 7; // bit code 111
+ alpha[2] = (6 * alpha[0] + 1 * alpha[1]) / 7; /* bit code 010 */
+ alpha[3] = (5 * alpha[0] + 2 * alpha[1]) / 7; /* bit code 011 */
+ alpha[4] = (4 * alpha[0] + 3 * alpha[1]) / 7; /* bit code 100 */
+ alpha[5] = (3 * alpha[0] + 4 * alpha[1]) / 7; /* bit code 101 */
+ alpha[6] = (2 * alpha[0] + 5 * alpha[1]) / 7; /* bit code 110 */
+ alpha[7] = (1 * alpha[0] + 6 * alpha[1]) / 7; /* bit code 111 */
}
void AlphaBlockDXT5::evaluatePalette6(uint8 alpha[8]) const
{
- // 6-alpha block.
- // Bit code 000 = alpha0, 001 = alpha1, others are interpolated.
+ /* 6-alpha block.
+ * Bit code 000 = alpha0, 001 = alpha1, others are interpolated. */
alpha[0] = alpha0();
alpha[1] = alpha1();
- alpha[2] = (4 * alpha[0] + 1 * alpha[1]) / 5; // Bit code 010
- alpha[3] = (3 * alpha[0] + 2 * alpha[1]) / 5; // Bit code 011
- alpha[4] = (2 * alpha[0] + 3 * alpha[1]) / 5; // Bit code 100
- alpha[5] = (1 * alpha[0] + 4 * alpha[1]) / 5; // Bit code 101
- alpha[6] = 0x00; // Bit code 110
- alpha[7] = 0xFF; // Bit code 111
+ alpha[2] = (4 * alpha[0] + 1 * alpha[1]) / 5; /* Bit code 010 */
+ alpha[3] = (3 * alpha[0] + 2 * alpha[1]) / 5; /* Bit code 011 */
+ alpha[4] = (2 * alpha[0] + 3 * alpha[1]) / 5; /* Bit code 100 */
+ alpha[5] = (1 * alpha[0] + 4 * alpha[1]) / 5; /* Bit code 101 */
+ alpha[6] = 0x00; /* Bit code 110 */
+ alpha[7] = 0xFF; /* Bit code 111 */
}
void AlphaBlockDXT5::indices(uint8 index_array[16]) const
@@ -418,7 +418,7 @@ void AlphaBlockDXT5::flip4()
{
uint64 *b = (uint64 *)this;
- // @@ The masks might have to be byte swapped.
+ /* @@ The masks might have to be byte swapped. */
uint64 tmp = (*b & (uint64)(0x000000000000FFFFLL));
tmp |= (*b & (uint64)(0x000000000FFF0000LL)) << 36;
tmp |= (*b & (uint64)(0x000000FFF0000000LL)) << 12;
@@ -432,7 +432,7 @@ void AlphaBlockDXT5::flip2()
{
uint *b = (uint *)this;
- // @@ The masks might have to be byte swapped.
+ /* @@ The masks might have to be byte swapped. */
uint tmp = (*b & 0xFF000000);
tmp |= (*b & 0x00000FFF) << 12;
tmp |= (*b & 0x00FFF000) >> 12;
@@ -442,19 +442,19 @@ void AlphaBlockDXT5::flip2()
void BlockDXT5::decodeBlock(ColorBlock *block) const
{
- // Decode color.
+ /* Decode color. */
color.decodeBlock(block);
- // Decode alpha.
+ /* Decode alpha. */
alpha.decodeBlock(block);
}
void BlockDXT5::decodeBlockNV5x(ColorBlock *block) const
{
- // Decode color.
+ /* Decode color. */
color.decodeBlockNV5x(block);
- // Decode alpha.
+ /* Decode alpha. */
alpha.decodeBlock(block);
}
@@ -541,7 +541,7 @@ void BlockATI2::flip2()
void BlockCTX1::evaluatePalette(Color32 color_array[4]) const
{
- // Does bit expansion before interpolation.
+ /* Does bit expansion before interpolation. */
color_array[0].b = 0x00;
color_array[0].g = col0[1];
color_array[0].r = col0[0];
@@ -565,11 +565,11 @@ void BlockCTX1::evaluatePalette(Color32 color_array[4]) const
void BlockCTX1::decodeBlock(ColorBlock *block) const
{
- // Decode color block.
+ /* Decode color block. */
Color32 color_array[4];
evaluatePalette(color_array);
- // Write color block.
+ /* Write color block. */
for (uint j = 0; j < 4; j++) {
for (uint i = 0; i < 4; i++) {
uint idx = (row[j] >> (2 * i)) & 3;
diff --git a/source/blender/imbuf/intern/dds/BlockDXT.h b/source/blender/imbuf/intern/dds/BlockDXT.h
index 83cc147c76c..1fefa7c739d 100644
--- a/source/blender/imbuf/intern/dds/BlockDXT.h
+++ b/source/blender/imbuf/intern/dds/BlockDXT.h
@@ -25,28 +25,28 @@
* Original license from NVIDIA follows.
*/
-// Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
+/* Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE. */
#pragma once
@@ -131,28 +131,28 @@ struct BlockDXT3 {
/** DXT5 alpha block. */
struct AlphaBlockDXT5 {
- // uint64 unions do not compile on all platforms
+ /* uint64 unions do not compile on all platforms */
#if 0
union {
struct {
- uint64 alpha0 : 8; // 8
- uint64 alpha1 : 8; // 16
- uint64 bits0 : 3; // 3 - 19
- uint64 bits1 : 3; // 6 - 22
- uint64 bits2 : 3; // 9 - 25
- uint64 bits3 : 3; // 12 - 28
- uint64 bits4 : 3; // 15 - 31
- uint64 bits5 : 3; // 18 - 34
- uint64 bits6 : 3; // 21 - 37
- uint64 bits7 : 3; // 24 - 40
- uint64 bits8 : 3; // 27 - 43
- uint64 bits9 : 3; // 30 - 46
- uint64 bitsA : 3; // 33 - 49
- uint64 bitsB : 3; // 36 - 52
- uint64 bitsC : 3; // 39 - 55
- uint64 bitsD : 3; // 42 - 58
- uint64 bitsE : 3; // 45 - 61
- uint64 bitsF : 3; // 48 - 64
+ uint64 alpha0 : 8; /* 8 */
+ uint64 alpha1 : 8; /* 16 */
+ uint64 bits0 : 3; /* 3 - 19 */
+ uint64 bits1 : 3; /* 6 - 22 */
+ uint64 bits2 : 3; /* 9 - 25 */
+ uint64 bits3 : 3; /* 12 - 28 */
+ uint64 bits4 : 3; /* 15 - 31 */
+ uint64 bits5 : 3; /* 18 - 34 */
+ uint64 bits6 : 3; /* 21 - 37 */
+ uint64 bits7 : 3; /* 24 - 40 */
+ uint64 bits8 : 3; /* 27 - 43 */
+ uint64 bits9 : 3; /* 30 - 46 */
+ uint64 bitsA : 3; /* 33 - 49 */
+ uint64 bitsB : 3; /* 36 - 52 */
+ uint64 bitsC : 3; /* 39 - 55 */
+ uint64 bitsD : 3; /* 42 - 58 */
+ uint64 bitsE : 3; /* 45 - 61 */
+ uint64 bitsF : 3; /* 48 - 64 */
};
uint64 u;
};
diff --git a/source/blender/imbuf/intern/dds/Color.h b/source/blender/imbuf/intern/dds/Color.h
index 4a9202617f5..03d49391e59 100644
--- a/source/blender/imbuf/intern/dds/Color.h
+++ b/source/blender/imbuf/intern/dds/Color.h
@@ -25,7 +25,7 @@
* Original license from NVIDIA follows.
*/
-// This code is in the public domain -- castanyo@yahoo.es
+/* This code is in the public domain -- <castanyo@yahoo.es> */
#pragma once
diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp
index f2e8e0b0313..7c8b7c1d345 100644
--- a/source/blender/imbuf/intern/dds/ColorBlock.cpp
+++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp
@@ -25,20 +25,20 @@
* Original license from NVIDIA follows.
*/
-// This code is in the public domain -- castanyo@yahoo.es
+/* This code is in the public domain - <castanyo@yahoo.es> */
#include <ColorBlock.h>
#include <Common.h>
#include <Image.h>
#if 0
-// Get approximate luminance.
+/* Get approximate luminance. */
inline static uint colorLuminance(Color32 c)
{
return c.r + c.g + c.b;
}
-// Get the euclidean distance between the given colors.
+/* Get the euclidean distance between the given colors. */
inline static uint colorDistance(Color32 c0, Color32 c1)
{
return (c0.r - c1.r) * (c0.r - c1.r) + (c0.g - c1.g) * (c0.g - c1.g) +
@@ -83,9 +83,9 @@ void ColorBlock::init(uint w, uint h, const uint *data, uint x, uint y)
const uint bw = MIN(w - x, 4U);
const uint bh = MIN(h - y, 4U);
- // Blocks that are smaller than 4x4 are handled by repeating the pixels.
- // @@ That's only correct when block size is 1, 2 or 4, but not with 3. :(
- // @@ Ideally we should zero the weights of the pixels out of range.
+ /* Blocks that are smaller than 4x4 are handled by repeating the pixels.
+ * @@ That's only correct when block size is 1, 2 or 4, but not with 3. :(
+ * @@ Ideally we should zero the weights of the pixels out of range. */
for (uint i = 0; i < 4; i++) {
const int by = i % bh;
@@ -104,9 +104,9 @@ void ColorBlock::init(uint w, uint h, const float *data, uint x, uint y)
const uint bw = MIN(w - x, 4U);
const uint bh = MIN(h - y, 4U);
- // Blocks that are smaller than 4x4 are handled by repeating the pixels.
- // @@ That's only correct when block size is 1, 2 or 4, but not with 3. :(
- // @@ Ideally we should zero the weights of the pixels out of range.
+ /* Blocks that are smaller than 4x4 are handled by repeating the pixels.
+ * @@ That's only correct when block size is 1, 2 or 4, but not with 3. :(
+ * @@ Ideally we should zero the weights of the pixels out of range. */
uint srcPlane = w * h;
@@ -120,7 +120,7 @@ void ColorBlock::init(uint w, uint h, const float *data, uint x, uint y)
Color32 &c = color(e, i);
c.r = uint8(255 * CLAMP(data[idx + 0 * srcPlane],
0.0f,
- 1.0f)); // @@ Is this the right way to quantize floats to bytes?
+ 1.0f)); /* @@ Is this the right way to quantize floats to bytes? */
c.g = uint8(255 * CLAMP(data[idx + 1 * srcPlane], 0.0f, 1.0f));
c.b = uint8(255 * CLAMP(data[idx + 2 * srcPlane], 0.0f, 1.0f));
c.a = uint8(255 * CLAMP(data[idx + 3 * srcPlane], 0.0f, 1.0f));
@@ -204,7 +204,7 @@ uint ColorBlock::countUniqueColors() const
{
uint count = 0;
- // @@ This does not have to be o(n^2)
+ /* @@ This does not have to be o(n^2) */
for (int i = 0; i < 16; i++) {
bool unique = true;
for (int j = 0; j < i; j++) {
@@ -326,7 +326,7 @@ void ColorBlock::boundsRange(Color32 *start, Color32 *end) const
}
}
- // Offset range by 1/16 of the extents
+ /* Offset range by 1/16 of the extents */
Color32 inset;
inset.r = (maxColor.r - minColor.r) >> 4;
inset.g = (maxColor.g - minColor.g) >> 4;
@@ -377,7 +377,7 @@ void ColorBlock::boundsRangeAlpha(Color32 *start, Color32 *end) const
}
}
- // Offset range by 1/16 of the extents
+ /* Offset range by 1/16 of the extents */
Color32 inset;
inset.r = (maxColor.r - minColor.r) >> 4;
inset.g = (maxColor.g - minColor.g) >> 4;
@@ -403,7 +403,7 @@ void ColorBlock::boundsRangeAlpha(Color32 *start, Color32 *end) const
/** Sort colors by abosolute value in their 16 bit representation. */
void ColorBlock::sortColorsByAbsoluteValue()
{
- // Dummy selection sort.
+ /* Dummy selection sort. */
for (uint a = 0; a < 16; a++) {
uint max = a;
Color16 cmax(m_color[a]);
@@ -462,7 +462,7 @@ void ColorBlock::sortColors(const Vector3 &axis)
luma_array[i] = dot(vec, axis);
}
- // Dummy selection sort.
+ /* Dummy selection sort. */
for (uint a = 0; a < 16; a++) {
uint min = a;
for (uint b = a + 1; b < 16; b++) {
diff --git a/source/blender/imbuf/intern/dds/ColorBlock.h b/source/blender/imbuf/intern/dds/ColorBlock.h
index 98b4c9cb40a..0271c7964b8 100644
--- a/source/blender/imbuf/intern/dds/ColorBlock.h
+++ b/source/blender/imbuf/intern/dds/ColorBlock.h
@@ -43,12 +43,12 @@ struct ColorBlock {
void init(uint w, uint h, const uint *data, uint x, uint y);
void init(uint w, uint h, const float *data, uint x, uint y);
- void swizzle(uint x, uint y, uint z, uint w); // 0=r, 1=g, 2=b, 3=a, 4=0xFF, 5=0
+ void swizzle(uint x, uint y, uint z, uint w); /* 0=r, 1=g, 2=b, 3=a, 4=0xFF, 5=0 */
bool isSingleColor(Color32 mask = Color32(0xFF, 0xFF, 0xFF, 0x00)) const;
bool hasAlpha() const;
- // Accessors
+ /* Accessors */
const Color32 *colors() const;
Color32 color(uint i) const;
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index 7ec059607c5..3e459934db7 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -25,36 +25,36 @@
* Original license from NVIDIA follows.
*/
-// Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
+/* Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE. */
#include <BlockDXT.h>
#include <DirectDrawSurface.h>
#include <PixelFormat.h>
-#include <math.h> // sqrt
-#include <stdio.h> // printf
-#include <stdlib.h> // malloc
+#include <math.h> /* sqrt */
+#include <stdio.h> /* printf */
+#include <stdlib.h> /* malloc */
#include <sys/types.h>
/*** declarations ***/
@@ -76,13 +76,15 @@ static const uint FOURCC_RXGB = DDS_MAKEFOURCC('R', 'X', 'G', 'B');
static const uint FOURCC_ATI1 = DDS_MAKEFOURCC('A', 'T', 'I', '1');
static const uint FOURCC_ATI2 = DDS_MAKEFOURCC('A', 'T', 'I', '2');
-// static const uint FOURCC_A2XY = DDS_MAKEFOURCC('A', '2', 'X', 'Y');
+#if 0 /* Valid but currently unused. */
+static const uint FOURCC_A2XY = DDS_MAKEFOURCC('A', '2', 'X', 'Y');
+#endif
static const uint FOURCC_DX10 = DDS_MAKEFOURCC('D', 'X', '1', '0');
static const uint FOURCC_UVER = DDS_MAKEFOURCC('U', 'V', 'E', 'R');
-// 32 bit RGB formats.
+/* 32 bit RGB formats. */
static const uint D3DFMT_R8G8B8 = 20;
static const uint D3DFMT_A8R8G8B8 = 21;
static const uint D3DFMT_X8R8G8B8 = 22;
@@ -100,25 +102,33 @@ static const uint D3DFMT_X8B8G8R8 = 33;
static const uint D3DFMT_G16R16 = 34;
static const uint D3DFMT_A2R10G10B10 = 35;
-// static const uint D3DFMT_A16B16G16R16 = 36;
+#if 0 /* Valid but currently unused. */
+static const uint D3DFMT_A16B16G16R16 = 36;
+#endif
-// Palette formats.
-// static const uint D3DFMT_A8P8 = 40;
-// static const uint D3DFMT_P8 = 41;
+/* Palette formats. */
+#if 0 /* Valid but currently unused. */
+static const uint D3DFMT_A8P8 = 40;
+static const uint D3DFMT_P8 = 41;
+#endif
-// Luminance formats.
+/* Luminance formats. */
static const uint D3DFMT_L8 = 50;
-// static const uint D3DFMT_A8L8 = 51;
-// static const uint D3DFMT_A4L4 = 52;
+#if 0 /* Valid but currently unused. */
+static const uint D3DFMT_A8L8 = 51;
+static const uint D3DFMT_A4L4 = 52;
+#endif
static const uint D3DFMT_L16 = 81;
-// Floating point formats
-// static const uint D3DFMT_R16F = 111;
-// static const uint D3DFMT_G16R16F = 112;
-// static const uint D3DFMT_A16B16G16R16F = 113;
-// static const uint D3DFMT_R32F = 114;
-// static const uint D3DFMT_G32R32F = 115;
-// static const uint D3DFMT_A32B32G32R32F = 116;
+/* Floating point formats */
+#if 0 /* Valid but currently unused. */
+static const uint D3DFMT_R16F = 111;
+static const uint D3DFMT_G16R16F = 112;
+static const uint D3DFMT_A16B16G16R16F = 113;
+static const uint D3DFMT_R32F = 114;
+static const uint D3DFMT_G32R32F = 115;
+static const uint D3DFMT_A32B32G32R32F = 116;
+#endif
static const uint DDSD_CAPS = 0x00000001U;
static const uint DDSD_PIXELFORMAT = 0x00001000U;
@@ -154,11 +164,11 @@ static const uint DDPF_PALETTEINDEXED8 = 0x00000020U;
static const uint DDPF_LUMINANCE = 0x00020000U;
static const uint DDPF_ALPHAPREMULT = 0x00008000U;
-// Custom NVTT flags.
+/* Custom NVTT flags. */
static const uint DDPF_NORMAL = 0x80000000U;
static const uint DDPF_SRGB = 0x40000000U;
-// DX10 formats.
+/* DX10 formats. */
enum DXGI_FORMAT {
DXGI_FORMAT_UNKNOWN = 0,
@@ -526,7 +536,7 @@ const FormatDescriptor s_d3dFormats[] = {
const uint s_d3dFormatCount = sizeof(s_d3dFormats) / sizeof(s_d3dFormats[0]);
-} // namespace
+} /* namespace */
static uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
{
@@ -555,9 +565,9 @@ DDSHeader::DDSHeader()
this->reserved[i] = 0;
}
- // Store version information on the reserved header attributes.
+ /* Store version information on the reserved header attributes. */
this->reserved[9] = FOURCC_NVTT;
- this->reserved[10] = (2 << 16) | (1 << 8) | (0); // major.minor.revision
+ this->reserved[10] = (2 << 16) | (1 << 8) | (0); /* major.minor.revision */
this->pf.size = 32;
this->pf.flags = 0;
@@ -658,7 +668,7 @@ void DDSHeader::setPitch(uint pitch)
void DDSHeader::setFourCC(uint8 c0, uint8 c1, uint8 c2, uint8 c3)
{
- // set fourcc pixel format.
+ /* set fourcc pixel format. */
this->pf.flags = DDPF_FOURCC;
this->pf.fourcc = DDS_MAKEFOURCC(c0, c1, c2, c3);
@@ -671,7 +681,7 @@ void DDSHeader::setFourCC(uint8 c0, uint8 c1, uint8 c2, uint8 c3)
void DDSHeader::setFormatCode(uint32 code)
{
- // set fourcc pixel format.
+ /* set fourcc pixel format. */
this->pf.flags = DDPF_FOURCC;
this->pf.fourcc = code;
@@ -689,7 +699,7 @@ void DDSHeader::setSwizzleCode(uint8 c0, uint8 c1, uint8 c2, uint8 c3)
void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
{
- // Make sure the masks are correct.
+ /* Make sure the masks are correct. */
if ((rmask & gmask) || (rmask & bmask) || (rmask & amask) || (gmask & bmask) ||
(gmask & amask) || (bmask & amask)) {
printf("DDS: bad RGBA masks, pixel format not set\n");
@@ -713,7 +723,7 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask
}
if (bitcount == 0) {
- // Compute bit count from the masks.
+ /* Compute bit count from the masks. */
uint total = rmask | gmask | bmask | amask;
while (total != 0) {
bitcount++;
@@ -721,7 +731,7 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask
}
}
- // D3DX functions do not like this:
+ /* D3DX functions do not like this: */
this->pf.fourcc = 0; // findD3D9Format(bitcount, rmask, gmask, bmask, amask);
#if 0
if (this->pf.fourcc) {
@@ -872,9 +882,9 @@ DirectDrawSurface::DirectDrawSurface(unsigned char *mem, uint size) : stream(mem
{
mem_read(stream, header);
- // some ATI2 compressed normal maps do not have their
- // normal flag set, so force it here (the original nvtt don't do
- // this, but the decompressor has a -forcenormal flag)
+ /* Some ATI2 compressed normal maps do not have their
+ * normal flag set, so force it here (the original nvtt don't do
+ * this, but the decompressor has a -forcenormal flag). */
if (header.pf.fourcc == FOURCC_ATI2) {
header.setNormalFlag(true);
}
@@ -928,12 +938,12 @@ bool DirectDrawSurface::isSupported() const
header.pf.fourcc != FOURCC_DXT3 && header.pf.fourcc != FOURCC_DXT4 &&
header.pf.fourcc != FOURCC_DXT5 && header.pf.fourcc != FOURCC_RXGB &&
header.pf.fourcc != FOURCC_ATI1 && header.pf.fourcc != FOURCC_ATI2) {
- // Unknown fourcc code.
+ /* Unknown fourcc code. */
return false;
}
}
else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE)) {
- // All RGB and luminance formats are supported now.
+ /* All RGB and luminance formats are supported now. */
}
else {
return false;
@@ -941,12 +951,12 @@ bool DirectDrawSurface::isSupported() const
if (isTextureCube() &&
(header.caps.caps2 & DDSCAPS2_CUBEMAP_ALL_FACES) != DDSCAPS2_CUBEMAP_ALL_FACES) {
- // Cubemaps must contain all faces.
+ /* Cubemaps must contain all faces. */
return false;
}
if (isTexture3D()) {
- // @@ 3D textures not supported yet.
+ /* @@ 3D textures not supported yet. */
return false;
}
@@ -971,7 +981,7 @@ bool DirectDrawSurface::hasAlpha() const
return false;
}
- // @@ Here we could check the ALPHA_PIXELS flag, but nobody sets it. (except us?)
+ /* @@ Here we could check the ALPHA_PIXELS flag, but nobody sets it. (except us?) */
return true;
}
@@ -1072,7 +1082,7 @@ void DirectDrawSurface::mipmap(Image *img, uint face, uint mipmap)
uint w = width();
uint h = height();
- // Compute width and height.
+ /* Compute width and height. */
for (uint m = 0; m < mipmap; m++) {
w = MAX(1U, w / 2);
h = MAX(1U, h / 2);
@@ -1088,7 +1098,7 @@ void DirectDrawSurface::mipmap(Image *img, uint face, uint mipmap)
}
if (header.hasDX10Header()) {
- // So far only block formats supported.
+ /* So far only block formats supported. */
readBlockImage(img);
}
else {
@@ -1101,8 +1111,8 @@ void DirectDrawSurface::mipmap(Image *img, uint face, uint mipmap)
}
}
-// It was easier to copy this function from upstream than to resync.
-// This should be removed if a resync ever occurs.
+/* It was easier to copy this function from upstream than to resync.
+ * This should be removed if a resync ever occurs. */
void *DirectDrawSurface::readData(uint &rsize)
{
uint header_size = 128; // sizeof(DDSHeader);
@@ -1124,7 +1134,7 @@ void *DirectDrawSurface::readData(uint &rsize)
rsize = 0;
}
- // Maybe check if size == rsize? assert() isn't in this scope...
+ /* Maybe check if size == rsize? assert() isn't in this scope. */
return data;
}
@@ -1155,7 +1165,7 @@ void DirectDrawSurface::readLinearImage(Image *img)
return;
}
- // Read linear RGB images.
+ /* Read linear RGB images. */
for (uint y = 0; y < h; y++) {
for (uint x = 0; x < w; x++) {
uint c = 0;
@@ -1185,10 +1195,10 @@ void DirectDrawSurface::readBlockImage(Image *img)
for (uint bx = 0; bx < bw; bx++) {
ColorBlock block;
- // Read color block.
+ /* Read color block. */
readBlock(&block);
- // Write color block.
+ /* Write color block. */
for (uint y = 0; y < MIN(4U, h - 4 * by); y++) {
for (uint x = 0; x < MIN(4U, w - 4 * bx); x++) {
img->pixel(4 * bx + x, 4 * by + y) = block.color(x, y);
@@ -1215,7 +1225,7 @@ void DirectDrawSurface::readBlock(ColorBlock *rgba)
{
uint fourcc = header.pf.fourcc;
- // Map DX10 block formats to fourcc codes.
+ /* Map DX10 block formats to fourcc codes. */
if (header.hasDX10Header()) {
if (header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM) {
fourcc = FOURCC_DXT1;
@@ -1251,7 +1261,7 @@ void DirectDrawSurface::readBlock(ColorBlock *rgba)
block.decodeBlock(rgba);
if (fourcc == FOURCC_RXGB) {
- // Swap R & A.
+ /* Swap R & A. */
for (int i = 0; i < 16; i++) {
Color32 &c = rgba->color(i);
uint tmp = c.r;
@@ -1271,7 +1281,7 @@ void DirectDrawSurface::readBlock(ColorBlock *rgba)
block.decodeBlock(rgba);
}
- // If normal flag set, convert to normal.
+ /* If normal flag set, convert to normal. */
if (header.pf.flags & DDPF_NORMAL) {
if (fourcc == FOURCC_ATI2) {
for (int i = 0; i < 16; i++) {
@@ -1323,7 +1333,7 @@ uint DirectDrawSurface::blockSize() const
}
}
- // Not a block image.
+ /* Not a block image. */
return 0;
}
@@ -1340,14 +1350,14 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const
}
if (header.pf.flags & DDPF_FOURCC) {
- // @@ How are 3D textures aligned?
+ /* @@ How are 3D textures aligned? */
w = (w + 3) / 4;
h = (h + 3) / 4;
return blockSize() * w * h;
}
if (header.pf.flags & DDPF_RGB || (header.pf.flags & DDPF_LUMINANCE)) {
- uint pitch = computePitch(
- w, header.pf.bitcount, 8); // Assuming 8 bit alignment, which is the same D3DX expects.
+ /* Assuming 8 bit alignment, which is the same D3DX expects. */
+ uint pitch = computePitch(w, header.pf.bitcount, 8);
return pitch * h * d;
}
@@ -1463,7 +1473,7 @@ void DirectDrawSurface::printInfo() const
}
if (header.pf.fourcc != 0) {
- // Display fourcc code even when DDPF_FOURCC flag not set.
+ /* Display fourcc code even when DDPF_FOURCC flag not set. */
printf("\tFourCC: '%c%c%c%c' (0x%.8X)\n",
(int)((header.pf.fourcc >> 0) & 0xFF),
(int)((header.pf.fourcc >> 8) & 0xFF),
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.h b/source/blender/imbuf/intern/dds/DirectDrawSurface.h
index 373d5974a5e..b6c2d1962e2 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.h
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.h
@@ -25,28 +25,28 @@
* Original license from NVIDIA follows.
*/
-// Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
+/* Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE. */
#pragma once
@@ -98,7 +98,7 @@ struct DDSHeader {
uint notused;
DDSHeader10 header10;
- // Helper methods.
+ /* Helper methods. */
DDSHeader();
void setWidth(uint w);
@@ -175,7 +175,7 @@ class DirectDrawSurface {
void readBlock(ColorBlock *rgba);
private:
- Stream stream; // memory where DDS file resides
+ Stream stream; /* Memory where DDS file resides. */
DDSHeader header;
};
diff --git a/source/blender/imbuf/intern/dds/FlipDXT.cpp b/source/blender/imbuf/intern/dds/FlipDXT.cpp
index f46f50eb2b9..9b07084bf81 100644
--- a/source/blender/imbuf/intern/dds/FlipDXT.cpp
+++ b/source/blender/imbuf/intern/dds/FlipDXT.cpp
@@ -31,8 +31,8 @@
* All rights reserved.
*/
-// This file comes from the chromium project, adapted to Blender to add DDS
-// flipping to OpenGL convention for Blender
+/* This file comes from the chromium project, adapted to Blender to add DDS
+ * flipping to OpenGL convention for Blender */
#include "IMB_imbuf_types.h"
@@ -44,18 +44,18 @@
#include <FlipDXT.h>
#include <Stream.h>
-// A function that flips a DXTC block.
+/* A function that flips a DXTC block. */
typedef void (*FlipBlockFunction)(uint8_t *block);
-// Flips a full DXT1 block in the y direction.
+/* Flips a full DXT1 block in the y direction. */
static void FlipDXT1BlockFull(uint8_t *block)
{
- // A DXT1 block layout is:
- // [0-1] color0.
- // [2-3] color1.
- // [4-7] color bitmap, 2 bits per pixel.
- // So each of the 4-7 bytes represents one line, flipping a block is just
- // flipping those bytes.
+ /* A DXT1 block layout is:
+ * [0-1] color0.
+ * [2-3] color1.
+ * [4-7] color bitmap, 2 bits per pixel.
+ * So each of the 4-7 bytes represents one line, flipping a block is just
+ * flipping those bytes. */
uint8_t tmp = block[4];
block[4] = block[7];
block[7] = tmp;
@@ -64,23 +64,23 @@ static void FlipDXT1BlockFull(uint8_t *block)
block[6] = tmp;
}
-// Flips the first 2 lines of a DXT1 block in the y direction.
+/* Flips the first 2 lines of a DXT1 block in the y direction. */
static void FlipDXT1BlockHalf(uint8_t *block)
{
- // See layout above.
+ /* See layout above. */
uint8_t tmp = block[4];
block[4] = block[5];
block[5] = tmp;
}
-// Flips a full DXT3 block in the y direction.
+/* Flips a full DXT3 block in the y direction. */
static void FlipDXT3BlockFull(uint8_t *block)
{
- // A DXT3 block layout is:
- // [0-7] alpha bitmap, 4 bits per pixel.
- // [8-15] a DXT1 block.
+ /* A DXT3 block layout is:
+ * [0-7] alpha bitmap, 4 bits per pixel.
+ * [8-15] a DXT1 block. */
- // We can flip the alpha bits at the byte level (2 bytes per line).
+ /* We can flip the alpha bits at the byte level (2 bytes per line). */
uint8_t tmp = block[0];
block[0] = block[6];
@@ -95,14 +95,14 @@ static void FlipDXT3BlockFull(uint8_t *block)
block[3] = block[5];
block[5] = tmp;
- // And flip the DXT1 block using the above function.
+ /* And flip the DXT1 block using the above function. */
FlipDXT1BlockFull(block + 8);
}
-// Flips the first 2 lines of a DXT3 block in the y direction.
+/* Flips the first 2 lines of a DXT3 block in the y direction. */
static void FlipDXT3BlockHalf(uint8_t *block)
{
- // See layout above.
+ /* See layout above. */
uint8_t tmp = block[0];
block[0] = block[2];
@@ -113,36 +113,36 @@ static void FlipDXT3BlockHalf(uint8_t *block)
FlipDXT1BlockHalf(block + 8);
}
-// Flips a full DXT5 block in the y direction.
+/* Flips a full DXT5 block in the y direction. */
static void FlipDXT5BlockFull(uint8_t *block)
{
- // A DXT5 block layout is:
- // [0] alpha0.
- // [1] alpha1.
- // [2-7] alpha bitmap, 3 bits per pixel.
- // [8-15] a DXT1 block.
+ /* A DXT5 block layout is:
+ * [0] alpha0.
+ * [1] alpha1.
+ * [2-7] alpha bitmap, 3 bits per pixel.
+ * [8-15] a DXT1 block. */
- // The alpha bitmap doesn't easily map lines to bytes, so we have to
- // interpret it correctly. Extracted from
- // http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt :
- //
- // The 6 "bits" bytes of the block are decoded into one 48-bit integer:
- //
- // bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * (bits_3 +
- // 256 * (bits_4 + 256 * bits_5))))
- //
- // bits is a 48-bit unsigned integer, from which a three-bit control code
- // is extracted for a texel at location (x,y) in the block using:
- //
- // code(x,y) = bits[3*(4*y+x)+1..3*(4*y+x)+0]
- //
- // where bit 47 is the most significant and bit 0 is the least
- // significant bit.
+ /* The alpha bitmap doesn't easily map lines to bytes, so we have to
+ * interpret it correctly. Extracted from
+ * http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt :
+ *
+ * The 6 "bits" bytes of the block are decoded into one 48-bit integer:
+ *
+ * bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * (bits_3 +
+ * 256 * (bits_4 + 256 * bits_5))))
+ *
+ * bits is a 48-bit unsigned integer, from which a three-bit control code
+ * is extracted for a texel at location (x,y) in the block using:
+ *
+ * code(x,y) = bits[3*(4*y+x)+1..3*(4*y+x)+0]
+ *
+ * where bit 47 is the most significant and bit 0 is the least
+ * significant bit. */
unsigned int line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
unsigned int line_2_3 = block[5] + 256 * (block[6] + 256 * block[7]);
- // swap lines 0 and 1 in line_0_1.
+ /* swap lines 0 and 1 in line_0_1. */
unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
- // swap lines 2 and 3 in line_2_3.
+ /* swap lines 2 and 3 in line_2_3. */
unsigned int line_3_2 = ((line_2_3 & 0x000fff) << 12) | ((line_2_3 & 0xfff000) >> 12);
block[2] = line_3_2 & 0xff;
@@ -152,14 +152,14 @@ static void FlipDXT5BlockFull(uint8_t *block)
block[6] = (line_1_0 & 0xff00) >> 8;
block[7] = (line_1_0 & 0xff0000) >> 16;
- // And flip the DXT1 block using the above function.
+ /* And flip the DXT1 block using the above function. */
FlipDXT1BlockFull(block + 8);
}
-// Flips the first 2 lines of a DXT5 block in the y direction.
+/* Flips the first 2 lines of a DXT5 block in the y direction. */
static void FlipDXT5BlockHalf(uint8_t *block)
{
- // See layout above.
+ /* See layout above. */
unsigned int line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
block[2] = line_1_0 & 0xff;
@@ -168,15 +168,15 @@ static void FlipDXT5BlockHalf(uint8_t *block)
FlipDXT1BlockHalf(block + 8);
}
-// Flips a DXTC image, by flipping and swapping DXTC blocks as appropriate.
+/* Flips a DXTC image, by flipping and swapping DXTC blocks as appropriate. */
int FlipDXTCImage(
unsigned int width, unsigned int height, unsigned int levels, int fourcc, uint8_t *data)
{
- // must have valid dimensions
+ /* Must have valid dimensions. */
if (width == 0 || height == 0) {
return 0;
}
- // height must be a power-of-two
+ /* Height must be a power-of-two. */
if ((height & (height - 1)) != 0) {
return 0;
}
@@ -214,24 +214,24 @@ int FlipDXTCImage(
unsigned int blocks = blocks_per_row * blocks_per_col;
if (mip_height == 1) {
- // no flip to do, and we're done.
+ /* no flip to do, and we're done. */
break;
}
if (mip_height == 2) {
- // flip the first 2 lines in each block.
+ /* flip the first 2 lines in each block. */
for (unsigned int i = 0; i < blocks_per_row; i++) {
half_block_function(data + i * block_bytes);
}
}
else {
- // flip each block.
+ /* flip each block. */
for (unsigned int i = 0; i < blocks; i++) {
full_block_function(data + i * block_bytes);
}
- // swap each block line in the first half of the image with the
- // corresponding one in the second half.
- // note that this is a no-op if mip_height is 4.
+ /* Swap each block line in the first half of the image with the
+ * corresponding one in the second half.
+ * note that this is a no-op if mip_height is 4. */
unsigned int row_bytes = block_bytes * blocks_per_row;
uint8_t *temp_line = new uint8_t[row_bytes];
@@ -247,7 +247,7 @@ int FlipDXTCImage(
delete[] temp_line;
}
- // mip levels are contiguous.
+ /* mip levels are contiguous. */
data += block_bytes * blocks;
mip_width = MAX(1U, mip_width >> 1);
mip_height = MAX(1U, mip_height >> 1);
diff --git a/source/blender/imbuf/intern/dds/Image.cpp b/source/blender/imbuf/intern/dds/Image.cpp
index 31a9927557b..4cfd7178f29 100644
--- a/source/blender/imbuf/intern/dds/Image.cpp
+++ b/source/blender/imbuf/intern/dds/Image.cpp
@@ -25,12 +25,12 @@
* Original license from NVIDIA follows.
*/
-// This code is in the public domain -- castanyo@yahoo.es
+/* This code is in the public domain -- <castanyo@yahoo.es>. */
#include <Color.h>
#include <Image.h>
-#include <stdio.h> // printf
+#include <stdio.h> /* printf */
Image::Image() : m_width(0), m_height(0), m_format(Format_RGB), m_data(NULL)
{
diff --git a/source/blender/imbuf/intern/dds/Image.h b/source/blender/imbuf/intern/dds/Image.h
index 0f977641d89..bc46b839952 100644
--- a/source/blender/imbuf/intern/dds/Image.h
+++ b/source/blender/imbuf/intern/dds/Image.h
@@ -25,7 +25,7 @@
* Original license from NVIDIA follows.
*/
-// This code is in the public domain -- castanyo@yahoo.es
+/* This code is in the public domain -- <castanyo@yahoo.es> */
#pragma once
diff --git a/source/blender/imbuf/intern/dds/PixelFormat.h b/source/blender/imbuf/intern/dds/PixelFormat.h
index a9125c64121..5c1d8e981a6 100644
--- a/source/blender/imbuf/intern/dds/PixelFormat.h
+++ b/source/blender/imbuf/intern/dds/PixelFormat.h
@@ -25,28 +25,29 @@
* Original license from NVIDIA follows.
*/
-// Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
+/* Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
#pragma once
@@ -54,23 +55,23 @@
namespace PixelFormat {
-// Convert component \a c having \a inbits to the returned value having \a outbits.
+/** Convert component \a c having \a inbits to the returned value having \a outbits. */
inline uint convert(uint c, uint inbits, uint outbits)
{
if (inbits == 0) {
return 0;
}
else if (inbits >= outbits) {
- // truncate
+ /* truncate */
return c >> (inbits - outbits);
}
else {
- // bitexpand
+ /* bitexpand */
return (c << (outbits - inbits)) | convert(c, inbits, outbits - inbits);
}
}
-// Get pixel component shift and size given its mask.
+/* Get pixel component shift and size given its mask. */
inline void maskShiftAndSize(uint mask, uint *shift, uint *size)
{
if (!mask) {
@@ -94,11 +95,14 @@ inline void maskShiftAndSize(uint mask, uint *shift, uint *size)
inline float quantizeCeil(float f, int inbits, int outbits)
{
- // uint i = f * (float(1 << inbits) - 1);
- // i = convert(i, inbits, outbits);
- // float result = float(i) / (float(1 << outbits) - 1);
- // nvCheck(result >= f);
+#if 0
+ uint i = f * (float(1 << inbits) - 1);
+ i = convert(i, inbits, outbits);
+ float result = float(i) / (float(1 << outbits) - 1);
+ nvCheck(result >= f);
+#endif
float result;
+
int offset = 0;
do {
uint i = offset + uint(f * (float(1 << inbits) - 1));
@@ -124,4 +128,4 @@ inline float quantizeFloor(float f, int bits)
}
#endif
-} // namespace PixelFormat
+} /* namespace PixelFormat */
diff --git a/source/blender/imbuf/intern/dds/Stream.cpp b/source/blender/imbuf/intern/dds/Stream.cpp
index e1c5eb1d505..59892a0a228 100644
--- a/source/blender/imbuf/intern/dds/Stream.cpp
+++ b/source/blender/imbuf/intern/dds/Stream.cpp
@@ -20,8 +20,8 @@
#include <Stream.h>
-#include <stdio.h> // printf
-#include <string.h> // memcpy
+#include <stdio.h> /* printf */
+#include <string.h> /* memcpy */
static const char *msg_error_seek = "DDS: trying to seek beyond end of stream (corrupt file?)";
static const char *msg_error_read = "DDS: trying to read beyond end of stream (corrupt file?)";
@@ -44,7 +44,7 @@ unsigned int mem_read(Stream &mem, unsigned long long &i)
mem.set_failed(msg_error_seek);
return 0;
}
- memcpy(&i, mem.mem + mem.pos, 8); // @@ todo: make sure little endian
+ memcpy(&i, mem.mem + mem.pos, 8); /* @@ todo: make sure little endian */
mem.pos += 8;
return 8;
}
@@ -55,7 +55,7 @@ unsigned int mem_read(Stream &mem, unsigned int &i)
mem.set_failed(msg_error_read);
return 0;
}
- memcpy(&i, mem.mem + mem.pos, 4); // @@ todo: make sure little endian
+ memcpy(&i, mem.mem + mem.pos, 4); /* @@ todo: make sure little endian */
mem.pos += 4;
return 4;
}
@@ -66,7 +66,7 @@ unsigned int mem_read(Stream &mem, unsigned short &i)
mem.set_failed(msg_error_read);
return 0;
}
- memcpy(&i, mem.mem + mem.pos, 2); // @@ todo: make sure little endian
+ memcpy(&i, mem.mem + mem.pos, 2); /* @@ todo: make sure little endian */
mem.pos += 2;
return 2;
}
diff --git a/source/blender/imbuf/intern/dds/Stream.h b/source/blender/imbuf/intern/dds/Stream.h
index ad6b9165801..acf0345b3a6 100644
--- a/source/blender/imbuf/intern/dds/Stream.h
+++ b/source/blender/imbuf/intern/dds/Stream.h
@@ -23,10 +23,10 @@
#pragma once
struct Stream {
- unsigned char *mem; // location in memory
- unsigned int size; // size
- unsigned int pos; // current position
- bool failed; // error occurred when seeking
+ unsigned char *mem; /* location in memory */
+ unsigned int size; /* size */
+ unsigned int pos; /* current position */
+ bool failed; /* error occurred when seeking */
Stream(unsigned char *m, unsigned int s) : mem(m), size(s), pos(0), failed(false)
{
}
diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp
index 309b5d6410f..1d29dd4a26b 100644
--- a/source/blender/imbuf/intern/dds/dds_api.cpp
+++ b/source/blender/imbuf/intern/dds/dds_api.cpp
@@ -26,7 +26,7 @@
#include <dds_api.h>
#include <fstream>
#include <stddef.h>
-#include <stdio.h> // printf
+#include <stdio.h> /* printf */
#if defined(WIN32)
# include "utfconv.h"
@@ -72,7 +72,7 @@ int imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
return 1;
}
-int imb_is_a_dds(const unsigned char *mem) // note: use at most first 32 bytes
+int imb_is_a_dds(const unsigned char *mem) /* note: use at most first 32 bytes */
{
/* heuristic check to see if mem contains a DDS file */
/* header.fourcc == FOURCC_DDS */
@@ -199,4 +199,4 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
return ibuf;
}
-} // extern "C"
+} /* extern "C" */
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
index 86bb5934db6..71774b335d7 100644
--- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp
+++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
@@ -290,4 +290,4 @@ int OIIO_getVersionHex(void)
return openimageio_version();
}
-} // export "C"
+} /* export "C" */
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 480bb15aa87..ca70ec633c1 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -699,7 +699,7 @@ void *IMB_exr_get_handle_name(const char *name)
}
/* multiview functions */
-} // extern "C"
+} /* extern "C" */
extern "C" {
@@ -1918,7 +1918,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
// printf("OpenEXR-load: image data window %d %d %d %d\n",
// dw.min.x, dw.min.y, dw.max.x, dw.max.y);
- if (0) { // debug
+ if (0) { /* debug */
exr_print_filecontents(*file);
}
@@ -2022,17 +2022,18 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
in.setFrameBuffer(frameBuffer);
in.readPixels(dw.min.y, dw.max.y);
- // XXX, ImBuf has no nice way to deal with this.
- // ideally IM_rect would be used when the caller wants a rect BUT
- // at the moment all functions use IM_rect.
- // Disabling this is ok because all functions should check
- // if a rect exists and create one on demand.
- //
- // Disabling this because the sequencer frees immediate.
- //
- // if (flag & IM_rect) {
- // IMB_rect_from_float(ibuf);
- // }
+ /* XXX, ImBuf has no nice way to deal with this.
+ * ideally IM_rect would be used when the caller wants a rect BUT
+ * at the moment all functions use IM_rect.
+ * Disabling this is ok because all functions should check
+ * if a rect exists and create one on demand.
+ *
+ * Disabling this because the sequencer frees immediate. */
+#if 0
+ if (flag & IM_rect) {
+ IMB_rect_from_float(ibuf);
+ }
+#endif
if (num_rgb_channels == 0 && has_luma && exr_has_chroma(*file)) {
for (size_t a = 0; a < (size_t)ibuf->x * ibuf->y; a++) {
@@ -2102,4 +2103,4 @@ void imb_exitopenexr(void)
setGlobalThreadCount(0);
}
-} // export "C"
+} /* export "C" */
diff --git a/source/blender/imbuf/intern/openexr/openexr_multi.h b/source/blender/imbuf/intern/openexr/openexr_multi.h
index 7008447313d..556717ad618 100644
--- a/source/blender/imbuf/intern/openexr/openexr_multi.h
+++ b/source/blender/imbuf/intern/openexr/openexr_multi.h
@@ -96,5 +96,5 @@ void IMB_exr_add_view(void *handle, const char *name);
bool IMB_exr_has_multilayer(void *handle);
#ifdef __cplusplus
-} // extern "C"
+} /* extern "C" */
#endif
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index 10d35b24cab..4a964c64917 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -35,7 +35,7 @@
#include "IMB_filter.h"
-#include "BLI_sys_types.h" // for intptr_t support
+#include "BLI_sys_types.h" /* for intptr_t support */
static void imb_half_x_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
{
diff --git a/source/blender/io/alembic/exporter/abc_archive.cc b/source/blender/io/alembic/exporter/abc_archive.cc
index a181a721de9..68ad2089a3e 100644
--- a/source/blender/io/alembic/exporter/abc_archive.cc
+++ b/source/blender/io/alembic/exporter/abc_archive.cc
@@ -177,10 +177,10 @@ ABCArchive::ABCArchive(const Main *bmain,
double scene_fps = FPS;
MetaData abc_metadata = create_abc_metadata(bmain, scene_fps);
- // Create the Archive.
+ /* Create the Archive. */
archive = create_archive(&abc_ostream_, filename, abc_metadata);
- // Create time samples for transforms and shapes.
+ /* Create time samples for transforms and shapes. */
TimeSamplingPtr ts_xform;
TimeSamplingPtr ts_shapes;
@@ -197,11 +197,11 @@ ABCArchive::ABCArchive(const Main *bmain,
time_sampling_index_shapes_ = archive->addTimeSampling(*ts_shapes);
}
- // Construct the frames to export.
+ /* Construct the frames to export. */
get_frames(scene_fps, params, params.frame_samples_xform, xform_frames_);
get_frames(scene_fps, params, params.frame_samples_shape, shape_frames_);
- // Merge all frames to get the final set of frames to export.
+ /* Merge all frames to get the final set of frames to export. */
export_frames_.insert(xform_frames_.begin(), xform_frames_.end());
export_frames_.insert(shape_frames_.begin(), shape_frames_.end());
diff --git a/source/blender/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc
index c22864a5433..892109dc578 100644
--- a/source/blender/io/alembic/exporter/abc_export_capi.cc
+++ b/source/blender/io/alembic/exporter/abc_export_capi.cc
@@ -64,7 +64,7 @@ struct ExportJobData {
namespace blender::io::alembic {
-// Construct the depsgraph for exporting.
+/* Construct the depsgraph for exporting. */
static void build_depsgraph(Depsgraph *depsgraph, const bool visible_objects_only)
{
if (visible_objects_only) {
@@ -99,12 +99,12 @@ static void export_startjob(void *customdata,
}
BKE_scene_graph_update_tagged(data->depsgraph, data->bmain);
- // For restoring the current frame after exporting animation is done.
+ /* For restoring the current frame after exporting animation is done. */
Scene *scene = DEG_get_input_scene(data->depsgraph);
const int orig_frame = CFRA;
const bool export_animation = (data->params.frame_start != data->params.frame_end);
- // Create the Alembic archive.
+ /* Create the Alembic archive. */
std::unique_ptr<ABCArchive> abc_archive;
try {
abc_archive = std::make_unique<ABCArchive>(
@@ -115,15 +115,15 @@ static void export_startjob(void *customdata,
error_message_stream << "Error writing to " << data->filename;
const std::string &error_message = error_message_stream.str();
- // The exception message can be very cryptic (just "iostream error" on Linux, for example), so
- // better not to include it in the report.
+ /* The exception message can be very cryptic (just "iostream error" on Linux, for example),
+ * so better not to include it in the report. */
CLOG_ERROR(&LOG, "%s: %s", error_message.c_str(), ex.what());
WM_report(RPT_ERROR, error_message.c_str());
data->export_ok = false;
return;
}
catch (...) {
- // Unknown exception class, so we cannot include its message.
+ /* Unknown exception class, so we cannot include its message. */
std::stringstream error_message_stream;
error_message_stream << "Unknown error writing to " << data->filename;
WM_report(RPT_ERROR, error_message_stream.str().c_str());
@@ -136,7 +136,7 @@ static void export_startjob(void *customdata,
if (export_animation) {
CLOG_INFO(&LOG, 2, "Exporting animation");
- // Writing the animated frames is not 100% of the work, but it's our best guess.
+ /* Writing the animated frames is not 100% of the work, but it's our best guess. */
const float progress_per_frame = 1.0f / std::max(size_t(1), abc_archive->total_frame_count());
ABCArchive::Frames::const_iterator frame_it = abc_archive->frames_begin();
const ABCArchive::Frames::const_iterator frames_end = abc_archive->frames_end();
@@ -148,7 +148,7 @@ static void export_startjob(void *customdata,
break;
}
- // Update the scene for the next frame to render.
+ /* Update the scene for the next frame to render. */
scene->r.cfra = static_cast<int>(frame);
scene->r.subframe = frame - scene->r.cfra;
BKE_scene_graph_update_for_newframe(data->depsgraph);
@@ -163,13 +163,13 @@ static void export_startjob(void *customdata,
}
}
else {
- // If we're not animating, a single iteration over all objects is enough.
+ /* If we're not animating, a single iteration over all objects is enough. */
iter.iterate_and_write();
}
iter.release_writers();
- // Finish up by going back to the keyframe that was current before we started.
+ /* Finish up by going back to the keyframe that was current before we started. */
if (CFRA != orig_frame) {
CFRA = orig_frame;
BKE_scene_graph_update_for_newframe(data->depsgraph);
diff --git a/source/blender/io/alembic/exporter/abc_writer_transform.cc b/source/blender/io/alembic/exporter/abc_writer_transform.cc
index 79e460e56e9..7b1fa87de64 100644
--- a/source/blender/io/alembic/exporter/abc_writer_transform.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_transform.cc
@@ -66,10 +66,10 @@ const IDProperty *ABCTransformWriter::get_id_properties(const HierarchyContext &
void ABCTransformWriter::do_write(HierarchyContext &context)
{
- float parent_relative_matrix[4][4]; // The object matrix relative to the parent.
+ float parent_relative_matrix[4][4]; /* The object matrix relative to the parent. */
mul_m4_m4m4(parent_relative_matrix, context.parent_matrix_inv_world, context.matrix_world);
- // After this, parent_relative_matrix uses Y=up.
+ /* After this, parent_relative_matrix uses Y=up. */
copy_m44_axis_swap(parent_relative_matrix, parent_relative_matrix, ABC_YUP_FROM_ZUP);
/* If the parent is a camera, undo its to-Maya rotation (see below). */
diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc
index b7fcdbc2087..31a8cf46fa7 100644
--- a/source/blender/io/alembic/intern/abc_reader_mesh.cc
+++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc
@@ -339,11 +339,11 @@ static void process_normals(CDStreamConfig &config,
Alembic::AbcGeom::GeometryScope scope = normals.getScope();
switch (scope) {
- case Alembic::AbcGeom::kFacevaryingScope: // 'Vertex Normals' in Houdini.
+ case Alembic::AbcGeom::kFacevaryingScope: /* 'Vertex Normals' in Houdini. */
process_loop_normals(config, normsamp.getVals());
break;
case Alembic::AbcGeom::kVertexScope:
- case Alembic::AbcGeom::kVaryingScope: // 'Point Normals' in Houdini.
+ case Alembic::AbcGeom::kVaryingScope: /* 'Point Normals' in Houdini. */
process_vertex_normals(config, normsamp.getVals());
break;
case Alembic::AbcGeom::kConstantScope:
@@ -614,7 +614,7 @@ bool AbcMeshReader::topology_changed(Mesh *existing_mesh, const ISampleSelector
m_schema.getName().c_str(),
sample_sel.getRequestedTime(),
ex.what());
- // A similar error in read_mesh() would just return existing_mesh.
+ /* A similar error in read_mesh() would just return existing_mesh. */
return false;
}
diff --git a/source/blender/io/alembic/tests/abc_export_test.cc b/source/blender/io/alembic/tests/abc_export_test.cc
index 625dbfd176f..e1a9bd34f6b 100644
--- a/source/blender/io/alembic/tests/abc_export_test.cc
+++ b/source/blender/io/alembic/tests/abc_export_test.cc
@@ -1,6 +1,6 @@
#include "testing/testing.h"
-// Keep first since utildefines defines AT which conflicts with STL
+/* Keep first since utildefines defines AT which conflicts with STL */
#include "exporter/abc_archive.h"
#include "intern/abc_util.h"
@@ -49,7 +49,7 @@ class AlembicExportTest : public testing::Test {
deleteArchive();
}
- // Call after setting up the parameters.
+ /* Call after setting up the parameters. */
void createArchive()
{
if (abc_archive != nullptr) {
@@ -108,28 +108,28 @@ TEST_F(AlembicExportTest, TimeSamplesFullShutterDifferent)
createArchive();
std::vector<double> frames(abc_archive->frames_begin(), abc_archive->frames_end());
EXPECT_EQ(8, frames.size());
- EXPECT_NEAR(31.0, frames[0], 1e-5); // transform + shape
+ EXPECT_NEAR(31.0, frames[0], 1e-5); /* transform + shape */
EXPECT_TRUE(abc_archive->is_xform_frame(frames[0]));
EXPECT_TRUE(abc_archive->is_shape_frame(frames[0]));
- EXPECT_NEAR(31.33333, frames[1], 1e-5); // transform
+ EXPECT_NEAR(31.33333, frames[1], 1e-5); /* transform */
EXPECT_TRUE(abc_archive->is_xform_frame(frames[1]));
EXPECT_FALSE(abc_archive->is_shape_frame(frames[1]));
- EXPECT_NEAR(31.5, frames[2], 1e-5); // shape
+ EXPECT_NEAR(31.5, frames[2], 1e-5); /* shape */
EXPECT_FALSE(abc_archive->is_xform_frame(frames[2]));
EXPECT_TRUE(abc_archive->is_shape_frame(frames[2]));
- EXPECT_NEAR(31.66666, frames[3], 1e-5); // transform
+ EXPECT_NEAR(31.66666, frames[3], 1e-5); /* transform */
EXPECT_TRUE(abc_archive->is_xform_frame(frames[3]));
EXPECT_FALSE(abc_archive->is_shape_frame(frames[3]));
- EXPECT_NEAR(32.0, frames[4], 1e-5); // transform + shape
+ EXPECT_NEAR(32.0, frames[4], 1e-5); /* transform + shape */
EXPECT_TRUE(abc_archive->is_xform_frame(frames[4]));
EXPECT_TRUE(abc_archive->is_shape_frame(frames[4]));
- EXPECT_NEAR(32.33333, frames[5], 1e-5); // transform
+ EXPECT_NEAR(32.33333, frames[5], 1e-5); /* transform */
EXPECT_TRUE(abc_archive->is_xform_frame(frames[5]));
EXPECT_FALSE(abc_archive->is_shape_frame(frames[5]));
- EXPECT_NEAR(32.5, frames[6], 1e-5); // shape
+ EXPECT_NEAR(32.5, frames[6], 1e-5); /* shape */
EXPECT_FALSE(abc_archive->is_xform_frame(frames[6]));
EXPECT_TRUE(abc_archive->is_shape_frame(frames[6]));
- EXPECT_NEAR(32.66666, frames[7], 1e-5); // transform
+ EXPECT_NEAR(32.66666, frames[7], 1e-5); /* transform */
EXPECT_TRUE(abc_archive->is_xform_frame(frames[7]));
EXPECT_FALSE(abc_archive->is_shape_frame(frames[7]));
}
diff --git a/source/blender/io/alembic/tests/abc_matrix_test.cc b/source/blender/io/alembic/tests/abc_matrix_test.cc
index 02ef1a99348..fc5b645987e 100644
--- a/source/blender/io/alembic/tests/abc_matrix_test.cc
+++ b/source/blender/io/alembic/tests/abc_matrix_test.cc
@@ -10,15 +10,15 @@ namespace blender::io::alembic {
TEST(abc_matrix, CreateRotationMatrixY_YfromZ)
{
- // Input variables
+ /* Input variables */
float rot_x_mat[3][3];
float rot_y_mat[3][3];
float rot_z_mat[3][3];
float euler[3] = {0.f, M_PI_4, 0.f};
- // Construct expected matrices
+ /* Construct expected matrices */
float unit[3][3];
- float rot_z_min_quart_pi[3][3]; // rotation of -pi/4 radians over z-axis
+ float rot_z_min_quart_pi[3][3]; /* rotation of -pi/4 radians over z-axis */
unit_m3(unit);
unit_m3(rot_z_min_quart_pi);
@@ -27,7 +27,7 @@ TEST(abc_matrix, CreateRotationMatrixY_YfromZ)
rot_z_min_quart_pi[1][0] = M_SQRT1_2;
rot_z_min_quart_pi[1][1] = M_SQRT1_2;
- // Run tests
+ /* Run tests */
create_swapped_rotation_matrix(rot_x_mat, rot_y_mat, rot_z_mat, euler, ABC_YUP_FROM_ZUP);
EXPECT_M3_NEAR(rot_x_mat, unit, 1e-5f);
@@ -37,15 +37,15 @@ TEST(abc_matrix, CreateRotationMatrixY_YfromZ)
TEST(abc_matrix, CreateRotationMatrixZ_YfromZ)
{
- // Input variables
+ /* Input variables */
float rot_x_mat[3][3];
float rot_y_mat[3][3];
float rot_z_mat[3][3];
float euler[3] = {0.f, 0.f, M_PI_4};
- // Construct expected matrices
+ /* Construct expected matrices */
float unit[3][3];
- float rot_y_quart_pi[3][3]; // rotation of pi/4 radians over y-axis
+ float rot_y_quart_pi[3][3]; /* rotation of pi/4 radians over y-axis */
unit_m3(unit);
unit_m3(rot_y_quart_pi);
@@ -54,7 +54,7 @@ TEST(abc_matrix, CreateRotationMatrixZ_YfromZ)
rot_y_quart_pi[2][0] = M_SQRT1_2;
rot_y_quart_pi[2][2] = M_SQRT1_2;
- // Run tests
+ /* Run tests */
create_swapped_rotation_matrix(rot_x_mat, rot_y_mat, rot_z_mat, euler, ABC_YUP_FROM_ZUP);
EXPECT_M3_NEAR(rot_x_mat, unit, 1e-5f);
@@ -64,17 +64,17 @@ TEST(abc_matrix, CreateRotationMatrixZ_YfromZ)
TEST(abc_matrix, CreateRotationMatrixXYZ_YfromZ)
{
- // Input variables
+ /* Input variables */
float rot_x_mat[3][3];
float rot_y_mat[3][3];
float rot_z_mat[3][3];
- // in degrees: X=10, Y=20, Z=30
+ /* in degrees: X=10, Y=20, Z=30 */
float euler[3] = {0.17453292012214f, 0.34906581044197f, 0.52359879016876f};
- // Construct expected matrices
- float rot_x_p10[3][3]; // rotation of +10 degrees over x-axis
- float rot_y_p30[3][3]; // rotation of +30 degrees over y-axis
- float rot_z_m20[3][3]; // rotation of -20 degrees over z-axis
+ /* Construct expected matrices */
+ float rot_x_p10[3][3]; /* rotation of +10 degrees over x-axis */
+ float rot_y_p30[3][3]; /* rotation of +30 degrees over y-axis */
+ float rot_z_m20[3][3]; /* rotation of -20 degrees over z-axis */
unit_m3(rot_x_p10);
rot_x_p10[1][1] = 0.9848077297210693f;
@@ -94,7 +94,7 @@ TEST(abc_matrix, CreateRotationMatrixXYZ_YfromZ)
rot_z_m20[1][0] = 0.3420201241970062f;
rot_z_m20[1][1] = 0.9396926164627075f;
- // Run tests
+ /* Run tests */
create_swapped_rotation_matrix(rot_x_mat, rot_y_mat, rot_z_mat, euler, ABC_YUP_FROM_ZUP);
EXPECT_M3_NEAR(rot_x_mat, rot_x_p10, 1e-5f);
@@ -104,17 +104,17 @@ TEST(abc_matrix, CreateRotationMatrixXYZ_YfromZ)
TEST(abc_matrix, CreateRotationMatrixXYZ_ZfromY)
{
- // Input variables
+ /* Input variables */
float rot_x_mat[3][3];
float rot_y_mat[3][3];
float rot_z_mat[3][3];
- // in degrees: X=10, Y=20, Z=30
+ /* in degrees: X=10, Y=20, Z=30 */
float euler[3] = {0.1745329201221466f, 0.3490658104419708f, 0.5235987901687622f};
- // Construct expected matrices
- float rot_x_p10[3][3]; // rotation of +10 degrees over x-axis
- float rot_y_m30[3][3]; // rotation of -30 degrees over y-axis
- float rot_z_p20[3][3]; // rotation of +20 degrees over z-axis
+ /* Construct expected matrices */
+ float rot_x_p10[3][3]; /* rotation of +10 degrees over x-axis */
+ float rot_y_m30[3][3]; /* rotation of -30 degrees over y-axis */
+ float rot_z_p20[3][3]; /* rotation of +20 degrees over z-axis */
unit_m3(rot_x_p10);
rot_x_p10[1][1] = 0.9848077297210693f;
@@ -134,7 +134,7 @@ TEST(abc_matrix, CreateRotationMatrixXYZ_ZfromY)
rot_z_p20[1][0] = -0.3420201241970062f;
rot_z_p20[1][1] = 0.9396926164627075f;
- // Run tests
+ /* Run tests */
create_swapped_rotation_matrix(rot_x_mat, rot_y_mat, rot_z_mat, euler, ABC_ZUP_FROM_YUP);
EXPECT_M3_NEAR(rot_x_mat, rot_x_p10, 1e-5f);
diff --git a/source/blender/io/collada/AnimationExporter.h b/source/blender/io/collada/AnimationExporter.h
index 2d38a541347..fd691184e8b 100644
--- a/source/blender/io/collada/AnimationExporter.h
+++ b/source/blender/io/collada/AnimationExporter.h
@@ -39,7 +39,7 @@
#include "BLI_utildefines.h"
#include "BIK_api.h"
-#include "BKE_action.h" // pose functions
+#include "BKE_action.h" /* pose functions */
#include "BKE_armature.h"
#include "BKE_constraint.h"
#include "BKE_fcurve.h"
@@ -69,7 +69,7 @@
#include "IK_solver.h"
-#include <algorithm> // std::find
+#include <algorithm> /* std::find */
#include <map>
#include <vector>
@@ -100,7 +100,7 @@ class AnimationExporter : COLLADASW::LibraryAnimations {
bool exportAnimations();
- // called for each exported object
+ /* called for each exported object */
void operator()(Object *ob);
protected:
@@ -129,8 +129,8 @@ class AnimationExporter : COLLADASW::LibraryAnimations {
Object *ob_arm,
bPoseChannel *pChan);
- // dae_bone_animation -> add_bone_animation
- // (blend this into dae_bone_animation)
+ /* dae_bone_animation -> add_bone_animation
+ * (blend this into dae_bone_animation) */
void dae_bone_animation(std::vector<float> &fra,
float *v,
int tm_type,
diff --git a/source/blender/io/collada/AnimationImporter.h b/source/blender/io/collada/AnimationImporter.h
index 5c6f9400286..44001366adc 100644
--- a/source/blender/io/collada/AnimationImporter.h
+++ b/source/blender/io/collada/AnimationImporter.h
@@ -52,7 +52,7 @@ class ArmatureImporter;
class AnimationImporterBase {
public:
- // virtual void change_eul_to_quat(Object *ob, bAction *act) = 0;
+ /* virtual void change_eul_to_quat(Object *ob, bAction *act) = 0; */
};
class AnimationImporter : private TransformReader, public AnimationImporterBase {
@@ -75,7 +75,7 @@ class AnimationImporter : private TransformReader, public AnimationImporterBase
float value,
eBezTriple_Interpolation ipo = BEZT_IPO_LIN);
- // create one or several fcurves depending on the number of parameters being animated
+ /* create one or several fcurves depending on the number of parameters being animated */
void animation_to_fcurves(COLLADAFW::AnimationCurve *curve);
void fcurve_deg_to_rad(FCurve *cu);
@@ -143,7 +143,7 @@ class AnimationImporter : private TransformReader, public AnimationImporterBase
void set_import_from_version(std::string import_from_version);
bool write_animation(const COLLADAFW::Animation *anim);
- // called on post-process stage after writeVisualScenes
+ /* called on post-process stage after writeVisualScenes */
bool write_animation_list(const COLLADAFW::AnimationList *animlist);
void read_node_transform(COLLADAFW::Node *node, Object *ob);
@@ -199,9 +199,9 @@ class AnimationImporter : private TransformReader, public AnimationImporterBase
int array_index,
int scale = 1);
void unused_fcurve(std::vector<FCurve *> *curves);
- // prerequisites:
- // animlist_map - map animlist id -> animlist
- // curve_map - map anim id -> curve(s)
+ /* prerequisites:
+ * animlist_map - map animlist id -> animlist
+ * curve_map - map anim id -> curve(s) */
Object *translate_animation_OLD(COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, Object *> &object_map,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &root_map,
@@ -212,21 +212,21 @@ class AnimationImporter : private TransformReader, public AnimationImporterBase
void find_frames_old(std::vector<float> *frames,
COLLADAFW::Node *node,
COLLADAFW::Transformation::TransformationType tm_type);
- // internal, better make it private
- // warning: evaluates only rotation
- // prerequisites: animlist_map, curve_map
+ /* internal, better make it private
+ * warning: evaluates only rotation
+ * prerequisites: animlist_map, curve_map */
void evaluate_transform_at_frame(float mat[4][4], COLLADAFW::Node *node, float fra);
- // return true to indicate that mat contains a sane value
+ /* return true to indicate that mat contains a sane value */
bool evaluate_animation(COLLADAFW::Transformation *tm,
float mat[4][4],
float fra,
const char *node_id);
- // gives a world-space mat of joint at rest position
+ /* gives a world-space mat of joint at rest position */
void get_joint_rest_mat(float mat[4][4], COLLADAFW::Node *root, COLLADAFW::Node *node);
- // gives a world-space mat, end's mat not included
+ /* gives a world-space mat, end's mat not included */
bool calc_joint_parent_mat_rest(float mat[4][4],
float par[4][4],
COLLADAFW::Node *node,
@@ -239,8 +239,8 @@ class AnimationImporter : private TransformReader, public AnimationImporterBase
#endif
#if 0
- // recursively evaluates joint tree until end is found, mat then is world-space matrix of end
- // mat must be identity on enter, node must be root
+ /* recursively evaluates joint tree until end is found, mat then is world-space matrix of end
+ * mat must be identity on enter, node must be root */
bool evaluate_joint_world_transform_at_frame(
float mat[4][4], float par[4][4], COLLADAFW::Node *node, COLLADAFW::Node *end, float fra);
#endif
diff --git a/source/blender/io/collada/ArmatureExporter.cpp b/source/blender/io/collada/ArmatureExporter.cpp
index fc697e1617b..ed043096c7e 100644
--- a/source/blender/io/collada/ArmatureExporter.cpp
+++ b/source/blender/io/collada/ArmatureExporter.cpp
@@ -40,14 +40,14 @@
#include "GeometryExporter.h"
#include "SceneExporter.h"
-// write bone nodes
+/* write bone nodes */
void ArmatureExporter::add_armature_bones(Object *ob_arm,
ViewLayer *view_layer,
SceneExporter *se,
std::vector<Object *> &child_objects)
{
- // write bone nodes
+ /* write bone nodes */
bArmature *armature = (bArmature *)ob_arm->data;
bool is_edited = armature->edbo != NULL;
@@ -95,7 +95,7 @@ bool ArmatureExporter::add_instance_controller(Object *ob)
return false;
}
- // write root bone URLs
+ /* write root bone URLs */
Bone *bone;
for (bone = (Bone *)arm->bonebase.first; bone; bone = bone->next) {
write_bone_URLs(ins, ob_arm, bone);
@@ -144,7 +144,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm,
}
#endif
-// parent_mat is armature-space
+/* parent_mat is armature-space */
void ArmatureExporter::add_bone_node(Bone *bone,
Object *ob_arm,
SceneExporter *se,
@@ -197,7 +197,7 @@ void ArmatureExporter::add_bone_node(Bone *bone,
add_bone_transform(ob_arm, bone, node);
- // Write nodes of childobjects, remove written objects from list
+ /* Write nodes of childobjects, remove written objects from list */
std::vector<Object *>::iterator iter = child_objects.begin();
while (iter != child_objects.end()) {
@@ -206,20 +206,20 @@ void ArmatureExporter::add_bone_node(Bone *bone,
float backup_parinv[4][4];
copy_m4_m4(backup_parinv, ob->parentinv);
- // crude, temporary change to parentinv
- // so transform gets exported correctly.
+ /* Crude, temporary change to parentinv
+ * so transform gets exported correctly. */
- // Add bone tail- translation... don't know why
- // bone parenting is against the tail of a bone
- // and not it's head, seems arbitrary.
+ /* Add bone tail- translation... don't know why
+ * bone parenting is against the tail of a bone
+ * and not it's head, seems arbitrary. */
ob->parentinv[3][1] += bone->length;
- // OPEN_SIM_COMPATIBILITY
- // TODO: when such objects are animated as
- // single matrix the tweak must be applied
- // to the result.
+ /* OPEN_SIM_COMPATIBILITY
+ * TODO: when such objects are animated as
+ * single matrix the tweak must be applied
+ * to the result. */
if (export_settings.get_open_sim()) {
- // tweak objects parentinverse to match compatibility
+ /* Tweak objects parentinverse to match compatibility. */
float temp[4][4];
copy_m4_m4(temp, bone->arm_mat);
@@ -289,11 +289,11 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW:
mul_m4_m4m4(mat, parent_inverse, bone_rest_mat);
}
- // OPEN_SIM_COMPATIBILITY
+ /* OPEN_SIM_COMPATIBILITY */
if (export_settings.get_open_sim()) {
- // Remove rotations vs armature from transform
- // parent_rest_rot * mat * irest_rot
+ /* Remove rotations vs armature from transform
+ * parent_rest_rot * mat * irest_rot */
Matrix workmat;
copy_m4_m4(workmat, bone_rest_mat);
diff --git a/source/blender/io/collada/ArmatureExporter.h b/source/blender/io/collada/ArmatureExporter.h
index 193dc9cde3a..b994741f342 100644
--- a/source/blender/io/collada/ArmatureExporter.h
+++ b/source/blender/io/collada/ArmatureExporter.h
@@ -22,7 +22,7 @@
#include <list>
#include <string>
-//#include <vector>
+// #include <vector>
#include "COLLADASWInputList.h"
#include "COLLADASWLibraryControllers.h"
@@ -43,16 +43,16 @@
class SceneExporter;
-// XXX exporter writes wrong data for shared armatures. A separate
-// controller should be written for each armature-mesh binding how do
-// we make controller ids then?
+/* XXX exporter writes wrong data for shared armatures. A separate
+ * controller should be written for each armature-mesh binding how do
+ * we make controller ids then? */
class ArmatureExporter : public COLLADASW::LibraryControllers,
protected TransformWriter,
protected InstanceWriter {
public:
- // XXX exporter writes wrong data for shared armatures. A separate
- // controller should be written for each armature-mesh binding how do
- // we make controller ids then?
+ /* XXX exporter writes wrong data for shared armatures. A separate
+ * controller should be written for each armature-mesh binding how do
+ * we make controller ids then? */
ArmatureExporter(BlenderContext &blender_context,
COLLADASW::StreamWriter *sw,
BCExportSettings &export_settings)
@@ -83,8 +83,8 @@ class ArmatureExporter : public COLLADASW::LibraryControllers,
void find_objects_using_armature(Object *ob_arm, std::vector<Object *> &objects, Scene *sce);
#endif
- // Scene, SceneExporter and the list of child_objects
- // are required for writing bone parented objects
+ /* Scene, SceneExporter and the list of child_objects
+ * are required for writing bone parented objects */
void add_bone_node(Bone *bone,
Object *ob_arm,
SceneExporter *se,
diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp
index dbb0ad328f5..af6558da3b4 100644
--- a/source/blender/io/collada/ArmatureImporter.cpp
+++ b/source/blender/io/collada/ArmatureImporter.cpp
@@ -153,7 +153,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
if (layer) {
bone->layer = layer;
}
- arm->layer |= layer; // ensure that all populated bone layers are visible after import
+ arm->layer |= layer; /* ensure that all populated bone layers are visible after import */
float *tail = be.get_tail();
int use_connect = be.get_use_connect();
@@ -504,7 +504,7 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *>
}
ED_armature_to_edit(armature);
- armature->layer = 0; // layer is set according to imported bone set in create_bone()
+ armature->layer = 0; /* layer is set according to imported bone set in create_bone() */
create_bone(NULL, node, NULL, node->getChildNodes().getCount(), NULL, armature, layer_labels);
if (this->import_settings->find_chains) {
@@ -623,7 +623,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
ob_arm = skin.set_armature(shared);
}
else {
- ob_arm = skin.create_armature(m_bmain, scene, view_layer); // once for every armature
+ ob_arm = skin.create_armature(m_bmain, scene, view_layer); /* once for every armature */
}
/* enter armature edit mode */
@@ -631,7 +631,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
ED_armature_to_edit(armature);
totbone = 0;
- // bone_direction_row = 1; // TODO: don't default to Y but use asset and based on it decide on
+ // bone_direction_row = 1; /* TODO: don't default to Y but use asset and based on it decide on */
/* default row */
/* create bones */
diff --git a/source/blender/io/collada/ArmatureImporter.h b/source/blender/io/collada/ArmatureImporter.h
index a1c4a25b80f..16265e66a8e 100644
--- a/source/blender/io/collada/ArmatureImporter.h
+++ b/source/blender/io/collada/ArmatureImporter.h
@@ -61,11 +61,11 @@ class ArmatureImporter : private TransformReader {
// std::map<int, JointData> joint_index_to_joint_info_map;
// std::map<COLLADAFW::UniqueId, int> joint_id_to_joint_index_map;
BoneExtensionManager bone_extension_manager;
- // int bone_direction_row; // XXX not used
+ // int bone_direction_row; /* XXX not used */
float leaf_bone_length;
int totbone;
- // XXX not used
- // float min_angle; // minimum angle between bone head-tail and a row of bone matrix
+ /* XXX not used */
+ // float min_angle; /* minimum angle between bone head-tail and a row of bone matrix */
#if 0
struct ArmatureJoints {
@@ -75,10 +75,10 @@ class ArmatureImporter : private TransformReader {
std::vector<ArmatureJoints> armature_joints;
#endif
- Object *empty; // empty for leaf bones
+ Object *empty; /* empty for leaf bones */
std::map<COLLADAFW::UniqueId, COLLADAFW::UniqueId> geom_uid_by_controller_uid;
- std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> joint_by_uid; // contains all joints
+ std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> joint_by_uid; /* contains all joints */
std::vector<COLLADAFW::Node *> root_joints;
std::vector<COLLADAFW::Node *> finished_joints;
std::vector<COLLADAFW::MorphController *> morph_controllers;
@@ -87,11 +87,12 @@ class ArmatureImporter : private TransformReader {
MeshImporterBase *mesh_importer;
- // This is used to store data passed in write_controller_data.
- // Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members
- // so that arrays don't get freed until we free them explicitly.
+ /* This is used to store data passed in write_controller_data.
+ * Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members
+ * so that arrays don't get freed until we free them explicitly. */
- std::map<COLLADAFW::UniqueId, SkinInfo> skin_by_data_uid; // data UID = skin controller data UID
+ std::map<COLLADAFW::UniqueId, SkinInfo>
+ skin_by_data_uid; /* data UID = skin controller data UID */
#if 0
JointData *get_joint_data(COLLADAFW::Node *node);
#endif
@@ -153,13 +154,13 @@ class ArmatureImporter : private TransformReader {
void add_root_joint(COLLADAFW::Node *node, Object *parent);
- // here we add bones to armatures, having armatures previously created in write_controller
+ /* here we add bones to armatures, having armatures previously created in write_controller */
void make_armatures(bContext *C, std::vector<Object *> &objects_to_scale);
void make_shape_keys(bContext *C);
#if 0
- // link with meshes, create vertex groups, assign weights
+ /* link with meshes, create vertex groups, assign weights */
void link_armature(Object *ob_arm,
const COLLADAFW::UniqueId &geom_id,
const COLLADAFW::UniqueId &controller_data_id);
@@ -175,7 +176,7 @@ class ArmatureImporter : private TransformReader {
void get_rna_path_for_joint(COLLADAFW::Node *node, char *joint_path, size_t count);
- // gives a world-space mat
+ /* gives a world-space mat */
bool get_joint_bind_mat(float m[4][4], COLLADAFW::Node *joint);
void set_tags_map(TagsMap &tags_map);
diff --git a/source/blender/io/collada/BCAnimationCurve.cpp b/source/blender/io/collada/BCAnimationCurve.cpp
index 559a17eda9f..46439bb3556 100644
--- a/source/blender/io/collada/BCAnimationCurve.cpp
+++ b/source/blender/io/collada/BCAnimationCurve.cpp
@@ -230,7 +230,7 @@ int BCAnimationCurve::closest_index_above(const float sample_frame, const int st
return -1;
}
- const int cframe = fcurve->bezt[start_at].vec[1][0]; // inaccurate!
+ const int cframe = fcurve->bezt[start_at].vec[1][0]; /* inaccurate! */
if (fabs(cframe - sample_frame) < 0.00001) {
return start_at;
@@ -252,7 +252,7 @@ int BCAnimationCurve::closest_index_below(const float sample_frame) const
for (int fcu_index = 0; fcu_index < fcurve->totvert; fcu_index++) {
upper_index = fcu_index;
- const int cframe = fcurve->bezt[fcu_index].vec[1][0]; // inaccurate!
+ const int cframe = fcurve->bezt[fcu_index].vec[1][0]; /* inaccurate! */
if (cframe <= sample_frame) {
lower_frame = cframe;
lower_index = fcu_index;
@@ -347,7 +347,7 @@ float BCAnimationCurve::get_value(const float frame)
if (fcurve) {
return evaluate_fcurve(fcurve, frame);
}
- return 0; // TODO: handle case where neither sample nor fcu exist
+ return 0; /* TODO: handle case where neither sample nor fcu exist */
}
void BCAnimationCurve::update_range(float val)
diff --git a/source/blender/io/collada/BCAnimationCurve.h b/source/blender/io/collada/BCAnimationCurve.h
index 3f7bcf9a13f..27856dd55f4 100644
--- a/source/blender/io/collada/BCAnimationCurve.h
+++ b/source/blender/io/collada/BCAnimationCurve.h
@@ -119,7 +119,7 @@ class BCAnimationCurve {
std::string get_animation_name(Object *ob) const; /* xxx: this is collada specific */
std::string get_channel_target() const;
std::string get_channel_type() const;
- std::string get_channel_posebone() const; // returns "" if channel is not a bone channel
+ std::string get_channel_posebone() const; /* returns "" if channel is not a bone channel */
int get_channel_index() const;
int get_subindex() const;
diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp
index b8df98e8acb..6bada9950b9 100644
--- a/source/blender/io/collada/BCAnimationSampler.cpp
+++ b/source/blender/io/collada/BCAnimationSampler.cpp
@@ -17,7 +17,7 @@
* All rights reserved.
*/
-#include <algorithm> // std::find
+#include <algorithm> /* std::find */
#include <map>
#include <vector>
@@ -92,7 +92,7 @@ static void get_sample_frames(BCFrameSet &sample_frames,
sample_frames.clear();
if (sampling_rate < 1) {
- return; // no sample frames in this case
+ return; /* no sample frames in this case */
}
float sfra = scene->r.sfra;
@@ -584,7 +584,7 @@ BCSampleFrame *BCSampleFrameContainer::get_frame(int frame_index)
/* Return a list of all frames that need to be sampled */
int BCSampleFrameContainer::get_frames(std::vector<int> &frames) const
{
- frames.clear(); // safety;
+ frames.clear(); /* safety; */
BCSampleFrameMap::const_iterator it;
for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
frames.push_back(it->first);
@@ -594,7 +594,7 @@ int BCSampleFrameContainer::get_frames(std::vector<int> &frames) const
int BCSampleFrameContainer::get_frames(Object *ob, BCFrames &frames) const
{
- frames.clear(); // safety;
+ frames.clear(); /* safety; */
BCSampleFrameMap::const_iterator it;
for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
const BCSampleFrame &frame = it->second;
@@ -607,7 +607,7 @@ int BCSampleFrameContainer::get_frames(Object *ob, BCFrames &frames) const
int BCSampleFrameContainer::get_frames(Object *ob, Bone *bone, BCFrames &frames) const
{
- frames.clear(); // safety;
+ frames.clear(); /* safety; */
BCSampleFrameMap::const_iterator it;
for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
const BCSampleFrame &frame = it->second;
@@ -620,7 +620,7 @@ int BCSampleFrameContainer::get_frames(Object *ob, Bone *bone, BCFrames &frames)
int BCSampleFrameContainer::get_samples(Object *ob, BCFrameSampleMap &samples) const
{
- samples.clear(); // safety;
+ samples.clear(); /* safety; */
BCSampleFrameMap::const_iterator it;
for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
const BCSampleFrame &frame = it->second;
@@ -634,7 +634,7 @@ int BCSampleFrameContainer::get_samples(Object *ob, BCFrameSampleMap &samples) c
int BCSampleFrameContainer::get_matrices(Object *ob, BCMatrixSampleMap &samples) const
{
- samples.clear(); // safety;
+ samples.clear(); /* safety; */
BCSampleFrameMap::const_iterator it;
for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
const BCSampleFrame &frame = it->second;
@@ -648,7 +648,7 @@ int BCSampleFrameContainer::get_matrices(Object *ob, BCMatrixSampleMap &samples)
int BCSampleFrameContainer::get_matrices(Object *ob, Bone *bone, BCMatrixSampleMap &samples) const
{
- samples.clear(); // safety;
+ samples.clear(); /* safety; */
BCSampleFrameMap::const_iterator it;
for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
const BCSampleFrame &frame = it->second;
diff --git a/source/blender/io/collada/BCAnimationSampler.h b/source/blender/io/collada/BCAnimationSampler.h
index f7f2464a637..52c0c8aa29e 100644
--- a/source/blender/io/collada/BCAnimationSampler.h
+++ b/source/blender/io/collada/BCAnimationSampler.h
@@ -134,7 +134,7 @@ class BCSampleFrameContainer {
}
BCSample &add(Object *ob, int frame_index);
- BCSampleFrame *get_frame(int frame_index); // returns NULL if frame does not exist
+ BCSampleFrame *get_frame(int frame_index); /* returns NULL if frame does not exist */
int get_frames(std::vector<int> &frames) const;
int get_frames(Object *ob, BCFrames &frames) const;
diff --git a/source/blender/io/collada/BCMath.cpp b/source/blender/io/collada/BCMath.cpp
index 85d4c212141..8a3fbf3c92c 100644
--- a/source/blender/io/collada/BCMath.cpp
+++ b/source/blender/io/collada/BCMath.cpp
@@ -67,7 +67,8 @@ BCMatrix::BCMatrix(BC_global_forward_axis global_forward_axis, BC_global_up_axis
mat3_from_axis_conversion(
BC_DEFAULT_FORWARD, BC_DEFAULT_UP, global_forward_axis, global_up_axis, mrot);
- transpose_m3(mrot); // TODO: Verify that mat3_from_axis_conversion() returns a transposed matrix
+ transpose_m3(
+ mrot); /* TODO: Verify that mat3_from_axis_conversion() returns a transposed matrix */
copy_m4_m3(mat, mrot);
set_transform(mat);
}
diff --git a/source/blender/io/collada/BCSampleData.h b/source/blender/io/collada/BCSampleData.h
index 463c90ec00b..06d234e2c3e 100644
--- a/source/blender/io/collada/BCSampleData.h
+++ b/source/blender/io/collada/BCSampleData.h
@@ -55,7 +55,7 @@ class BCSample {
bool get_value(std::string channel_target, const int array_index, float *val) const;
const BCMatrix &get_matrix() const;
- const BCMatrix *get_matrix(Bone *bone) const; // returns NULL if bone is not animated
+ const BCMatrix *get_matrix(Bone *bone) const; /* returns NULL if bone is not animated */
};
typedef std::map<Object *, BCSample *> BCSampleMap;
diff --git a/source/blender/io/collada/BlenderContext.cpp b/source/blender/io/collada/BlenderContext.cpp
index 1d3bffacb79..8009f10aa03 100644
--- a/source/blender/io/collada/BlenderContext.cpp
+++ b/source/blender/io/collada/BlenderContext.cpp
@@ -77,7 +77,7 @@ bool bc_is_in_Export_set(LinkNode *export_set, Object *ob, ViewLayer *view_layer
if (!to_export) {
/* Mark this object as to_export even if it is not in the
- export list, but it contains children to export */
+ * export list, but it contains children to export. */
std::vector<Object *> children;
bc_get_children(children, ob, view_layer);
@@ -112,7 +112,7 @@ BlenderContext::BlenderContext(bContext *C)
main = CTX_data_main(C);
scene = CTX_data_scene(C);
view_layer = CTX_data_view_layer(C);
- depsgraph = nullptr; // create only when needed
+ depsgraph = nullptr; /* create only when needed */
}
bContext *BlenderContext::get_context()
diff --git a/source/blender/io/collada/ControllerExporter.cpp b/source/blender/io/collada/ControllerExporter.cpp
index 1b8c859f443..1d8d0f2b389 100644
--- a/source/blender/io/collada/ControllerExporter.cpp
+++ b/source/blender/io/collada/ControllerExporter.cpp
@@ -305,7 +305,7 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key)
COLLADASW::InputList &input = targets.getInputList();
input.push_back(COLLADASW::Input(
- COLLADASW::InputSemantic::MORPH_TARGET, // constant declared in COLLADASWInputList.h
+ COLLADASW::InputSemantic::MORPH_TARGET, /* constant declared in COLLADASWInputList.h */
COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, targets_id)));
input.push_back(
COLLADASW::Input(COLLADASW::InputSemantic::MORPH_WEIGHT,
@@ -400,7 +400,7 @@ void ControllerExporter::add_joints_element(ListBase *defbase,
COLLADASW::InputList &input = joints.getInputList();
input.push_back(COLLADASW::Input(
- COLLADASW::InputSemantic::JOINT, // constant declared in COLLADASWInputList.h
+ COLLADASW::InputSemantic::JOINT, /* constant declared in COLLADASWInputList.h */
COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, joints_source_id)));
input.push_back(
COLLADASW::Input(COLLADASW::InputSemantic::BINDMATRIX,
@@ -415,7 +415,7 @@ void ControllerExporter::add_bind_shape_mat(Object *ob)
BKE_object_matrix_local_get(ob, f_obmat);
if (export_settings.get_apply_global_orientation()) {
- // do nothing, rotation is going to be applied to the Data
+ /* do nothing, rotation is going to be applied to the Data */
}
else {
bc_add_global_transform(f_obmat, export_settings.get_global_transform());
@@ -615,7 +615,7 @@ void ControllerExporter::add_vertex_weights_element(const std::string &weights_s
int offset = 0;
input.push_back(COLLADASW::Input(
- COLLADASW::InputSemantic::JOINT, // constant declared in COLLADASWInputList.h
+ COLLADASW::InputSemantic::JOINT, /* constant declared in COLLADASWInputList.h */
COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, joints_source_id),
offset++));
input.push_back(
diff --git a/source/blender/io/collada/ControllerExporter.h b/source/blender/io/collada/ControllerExporter.h
index 753538d8e98..6a377a4119e 100644
--- a/source/blender/io/collada/ControllerExporter.h
+++ b/source/blender/io/collada/ControllerExporter.h
@@ -56,9 +56,9 @@ class ControllerExporter : public COLLADASW::LibraryControllers,
BCExportSettings export_settings;
public:
- // XXX exporter writes wrong data for shared armatures. A separate
- // controller should be written for each armature-mesh binding how do
- // we make controller ids then?
+ /* XXX exporter writes wrong data for shared armatures. A separate
+ * controller should be written for each armature-mesh binding how do
+ * we make controller ids then? */
ControllerExporter(BlenderContext &blender_context,
COLLADASW::StreamWriter *sw,
BCExportSettings &export_settings)
@@ -91,8 +91,8 @@ class ControllerExporter : public COLLADASW::LibraryControllers,
std::string get_controller_id(Key *key, Object *ob);
- // ob should be of type OB_MESH
- // both args are required
+ /* ob should be of type OB_MESH
+ * both args are required */
void export_skin_controller(Object *ob, Object *ob_arm);
void export_morph_controller(Object *ob, Key *key);
diff --git a/source/blender/io/collada/DocumentExporter.cpp b/source/blender/io/collada/DocumentExporter.cpp
index 6be441a9e27..65c71b0edef 100644
--- a/source/blender/io/collada/DocumentExporter.cpp
+++ b/source/blender/io/collada/DocumentExporter.cpp
@@ -18,7 +18,7 @@
* \ingroup collada
*/
-#include <algorithm> // std::find
+#include <algorithm> /* std::find */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@@ -79,7 +79,7 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
-#include "BKE_action.h" // pose functions
+#include "BKE_action.h" /* pose functions */
#include "BKE_animsys.h"
#include "BKE_appdir.h"
#include "BKE_armature.h"
@@ -106,7 +106,7 @@ extern "C" char build_hash[];
#include "collada_internal.h"
#include "collada_utils.h"
-// can probably go after refactor is complete
+/* can probably go after refactor is complete */
#include "InstanceWriter.h"
#include "TransformWriter.h"
@@ -170,9 +170,9 @@ static COLLADABU::NativeString make_temp_filepath(const char *name, const char *
return native_filename;
}
-// TODO: it would be better to instantiate animations rather than create a new one per object
-// COLLADA allows this through multiple <channel>s in <animation>.
-// For this to work, we need to know objects that use a certain action.
+/* TODO: it would be better to instantiate animations rather than create a new one per object
+ * COLLADA allows this through multiple <channel>s in <animation>.
+ * For this to work, we need to know objects that use a certain action. */
int DocumentExporter::exportCurrentScene()
{
@@ -187,10 +187,10 @@ int DocumentExporter::exportCurrentScene()
COLLADABU::NativeString native_filename = make_temp_filepath(NULL, ".dae");
COLLADASW::StreamWriter *writer = new COLLADASW::StreamWriter(native_filename);
- // open <collada>
+ /* open <collada> */
writer->startDocument();
- // <asset>
+ /* <asset> */
COLLADASW::Asset asset(writer);
RNA_id_pointer_create(&(sce->id), &sceneptr);
@@ -254,37 +254,37 @@ int DocumentExporter::exportCurrentScene()
asset.add();
LinkNode *export_set = this->export_settings.get_export_set();
- // <library_cameras>
+ /* <library_cameras> */
if (bc_has_object_type(export_set, OB_CAMERA)) {
CamerasExporter ce(writer, this->export_settings);
ce.exportCameras(sce);
}
- // <library_lights>
+ /* <library_lights> */
if (bc_has_object_type(export_set, OB_LAMP)) {
LightsExporter le(writer, this->export_settings);
le.exportLights(sce);
}
- // <library_effects>
+ /* <library_effects> */
EffectsExporter ee(writer, this->export_settings, key_image_map);
ee.exportEffects(C, sce);
- // <library_images>
+ /* <library_images> */
ImagesExporter ie(writer, this->export_settings, key_image_map);
ie.exportImages(sce);
- // <library_materials>
+ /* <library_materials> */
MaterialsExporter me(writer, this->export_settings);
me.exportMaterials(sce);
- // <library_geometries>
+ /* <library_geometries> */
if (bc_has_object_type(export_set, OB_MESH)) {
GeometryExporter ge(blender_context, writer, this->export_settings);
ge.exportGeom();
}
- // <library_controllers>
+ /* <library_controllers> */
ArmatureExporter arm_exporter(blender_context, writer, this->export_settings);
ControllerExporter controller_exporter(blender_context, writer, this->export_settings);
if (bc_has_object_type(export_set, OB_ARMATURE) ||
@@ -292,28 +292,28 @@ int DocumentExporter::exportCurrentScene()
controller_exporter.export_controllers();
}
- // <library_visual_scenes>
+ /* <library_visual_scenes> */
SceneExporter se(blender_context, writer, &arm_exporter, this->export_settings);
if (this->export_settings.get_include_animations()) {
- // <library_animations>
+ /* <library_animations> */
AnimationExporter ae(writer, this->export_settings);
ae.exportAnimations();
}
se.exportScene();
- // <scene>
+ /* <scene> */
std::string scene_name(translate_id(id_name(sce)));
COLLADASW::Scene scene(writer, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, scene_name));
scene.add();
- // close <Collada>
+ /* close <Collada> */
writer->endDocument();
delete writer;
- // Finally move the created document into place
+ /* Finally move the created document into place */
fprintf(stdout, "Collada export to: %s\n", this->export_settings.get_filepath());
int status = BLI_rename(native_filename.c_str(), this->export_settings.get_filepath());
if (status != 0) {
diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp
index 083d7258d0a..b9f132d04dd 100644
--- a/source/blender/io/collada/DocumentImporter.cpp
+++ b/source/blender/io/collada/DocumentImporter.cpp
@@ -22,7 +22,7 @@
* * name imported objects
* * import object rotation as euler */
-#include <algorithm> // sort()
+#include <algorithm> /* sort() */
#include <map>
#include <string>
@@ -90,7 +90,7 @@
*/
// #define COLLADA_DEBUG
-// creates empties for each imported bone on layer 2, for debugging
+/* creates empties for each imported bone on layer 2, for debugging */
// #define ARMATURE_TEST
DocumentImporter::DocumentImporter(bContext *C, const ImportSettings *import_settings)
@@ -429,7 +429,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
if (source_node) {
COLLADABU::Math::Matrix4 mat4 = source_node->getTransformationMatrix();
COLLADABU::Math::Matrix4 bmat4 =
- mat4.transpose(); // transpose to get blender row-major order
+ mat4.transpose(); /* transpose to get blender row-major order */
float mat[4][4];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
@@ -457,7 +457,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
}
COLLADAFW::InstanceNodePointerArray &inodes = child_node->getInstanceNodes();
Object *new_child = NULL;
- if (inodes.getCount()) { // \todo loop through instance nodes
+ if (inodes.getCount()) { /* \todo loop through instance nodes */
const COLLADAFW::UniqueId &id = inodes[0]->getInstanciatedObjectId();
fprintf(stderr, "Doing %d child nodes\n", (int)node_map.count(id));
new_child = create_instance_node(
@@ -678,7 +678,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
}
- // create_constraints(et,ob);
+ /* create_constraints(et,ob); */
}
for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end();
@@ -686,7 +686,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
ob = *it;
if (read_transform) {
- anim_importer.read_node_transform(node, ob); // overwrites location set earlier
+ anim_importer.read_node_transform(node, ob); /* overwrites location set earlier */
}
if (!is_joint) {
@@ -815,7 +815,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
/* following mapping still needs to be verified */
#if 0
- // needs rework to be done for 2.81
+ /* needs rework to be done for 2.81 */
matNode.set_shininess(ef->getShininess());
#endif
matNode.set_reflectivity(ef->getReflectivity());
@@ -1127,7 +1127,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
switch (light->getLightType()) {
case COLLADAFW::Light::AMBIENT_LIGHT: {
- lamp->type = LA_SUN; // TODO needs more thoughts
+ lamp->type = LA_SUN; /* TODO needs more thoughts */
} break;
case COLLADAFW::Light::SPOT_LIGHT: {
lamp->type = LA_SPOT;
diff --git a/source/blender/io/collada/DocumentImporter.h b/source/blender/io/collada/DocumentImporter.h
index e382a44c3c2..a23e983940e 100644
--- a/source/blender/io/collada/DocumentImporter.h
+++ b/source/blender/io/collada/DocumentImporter.h
@@ -46,7 +46,7 @@ struct bContext;
/** Importer class. */
class DocumentImporter : COLLADAFW::IWriter {
public:
- //! Enumeration to denote the stage of import
+ /** Enumeration to denote the stage of import */
enum ImportStage {
Fetching_Scene_data, /* First pass to collect all data except controller */
Fetching_Controller_data, /* Second pass to collect controller data */
@@ -98,7 +98,8 @@ class DocumentImporter : COLLADAFW::IWriter {
bool writeAnimationList(const COLLADAFW::AnimationList *);
#if WITH_OPENCOLLADA_ANIMATION_CLIP
- // Please enable this when building with Collada 1.6.65 or newer (also in DocumentImporter.cpp)
+ /* Please enable this when building with Collada 1.6.65 or newer (also in DocumentImporter.cpp)
+ */
bool writeAnimationClip(const COLLADAFW::AnimationClip *animationClip);
#endif
@@ -160,7 +161,8 @@ class DocumentImporter : COLLADAFW::IWriter {
std::vector<Object *> libnode_ob;
std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>
- root_map; // find root joint by child joint uid, for bone tree evaluation during resampling
+ root_map; /* find root joint by child joint uid, for bone tree evaluation during resampling
+ */
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map;
std::string import_from_version;
diff --git a/source/blender/io/collada/EffectExporter.cpp b/source/blender/io/collada/EffectExporter.cpp
index 7f6d3cbdc6f..4108472d1df 100644
--- a/source/blender/io/collada/EffectExporter.cpp
+++ b/source/blender/io/collada/EffectExporter.cpp
@@ -65,7 +65,7 @@ bool EffectsExporter::hasEffects(Scene *sce)
for (a = 0; a < ob->totcol; a++) {
Material *ma = BKE_object_material_get(ob, a + 1);
- // no material, but check all of the slots
+ /* no material, but check all of the slots */
if (!ma) {
continue;
}
@@ -101,7 +101,7 @@ void EffectsExporter::set_transparency(COLLADASW::EffectProfile &ep, Material *m
{
double alpha = bc_get_alpha(ma);
if (alpha < 1) {
- // workaround use <transparent> to avoid wrong handling of <transparency> by other tools
+ /* workaround use <transparent> to avoid wrong handling of <transparency> by other tools */
COLLADASW::ColorOrTexture cot = bc_get_cot(0, 0, 0, alpha);
ep.setTransparent(cot, false, "alpha");
ep.setOpaque(COLLADASW::EffectProfile::A_ONE);
@@ -209,7 +209,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
COLLADASW::EffectProfile ep(mSW);
ep.setProfileType(COLLADASW::EffectProfile::COMMON);
ep.openProfile();
- set_shader_type(ep, ma); // creates a Lambert Shader for now
+ set_shader_type(ep, ma); /* creates a Lambert Shader for now */
COLLADASW::ColorOrTexture cot;
@@ -234,7 +234,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
MTex *t = ma->mtex[tex_indices[a]];
Image *ima = t->tex->ima;
- // Image not set for texture
+ /* Image not set for texture */
if (!ima) {
continue;
}
@@ -242,17 +242,17 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
std::string key(id_name(ima));
key = translate_id(key);
- // create only one <sampler>/<surface> pair for each unique image
+ /* create only one <sampler>/<surface> pair for each unique image */
if (im_samp_map.find(key) == im_samp_map.end()) {
- //<newparam> <sampler> <source>
+ /* <newparam> <sampler> <source> */
COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D,
key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
sampler.setImageId(key);
- // copy values to arrays since they will live longer
+ /* copy values to arrays since they will live longer */
samplers[a] = sampler;
- // store pointers so they can be used later when we create <texture>s
+ /* store pointers so they can be used later when we create <texture>s */
samp_surf[b] = &samplers[a];
//samp_surf[b][1] = &surfaces[a];
@@ -274,12 +274,12 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
int i = im_samp_map[key];
std::string uvname = strlen(t->uvname) ? t->uvname : active_uv;
COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)
- samp_surf[i]; // possibly uninitialized memory ...
+ samp_surf[i]; /* possibly uninitialized memory ... */
writeTextures(ep, key, sampler, t, ima, uvname);
}
#endif
- // performs the actual writing
+ /* performs the actual writing */
ep.addProfileElements();
ep.addExtraTechniques(mSW);
diff --git a/source/blender/io/collada/ErrorHandler.h b/source/blender/io/collada/ErrorHandler.h
index 60253a08cda..1da17dbed42 100644
--- a/source/blender/io/collada/ErrorHandler.h
+++ b/source/blender/io/collada/ErrorHandler.h
@@ -20,7 +20,7 @@
#pragma once
-#include <algorithm> // sort()
+#include <algorithm> /* sort() */
#include <map>
#include <string>
#include <vector>
diff --git a/source/blender/io/collada/ExtraHandler.h b/source/blender/io/collada/ExtraHandler.h
index 8f98e1dec1b..4b13aaca2aa 100644
--- a/source/blender/io/collada/ExtraHandler.h
+++ b/source/blender/io/collada/ExtraHandler.h
@@ -20,7 +20,7 @@
#pragma once
-#include <algorithm> // sort()
+#include <algorithm> /* sort() */
#include <map>
#include <string>
#include <vector>
diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp
index c7fcc51d42f..332390845c7 100644
--- a/source/blender/io/collada/GeometryExporter.cpp
+++ b/source/blender/io/collada/GeometryExporter.cpp
@@ -386,7 +386,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
COLLADASW::Input texcoord_input(
COLLADASW::InputSemantic::TEXCOORD,
makeUrl(makeTexcoordSourceId(geom_id, i, this->export_settings.get_active_uv_only())),
- 2, // this is only until we have optimized UV sets
+ 2, /* this is only until we have optimized UV sets */
(this->export_settings.get_active_uv_only()) ? 0 : layer_index - 1 /* set (0,1,2,...) */
);
til.push_back(texcoord_input);
@@ -401,8 +401,8 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
char *layer_name = bc_CustomData_get_layer_name(&me->ldata, CD_MLOOPCOL, a);
COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR,
makeUrl(makeVertexColorSourceId(geom_id, layer_name)),
- (has_uvs) ? 3 : 2, // all color layers have same index order
- map_index // set number equals color map index
+ (has_uvs) ? 3 : 2, /* all color layers have same index order */
+ map_index /* set number equals color map index */
);
til.push_back(input4);
map_index++;
diff --git a/source/blender/io/collada/LightExporter.cpp b/source/blender/io/collada/LightExporter.cpp
index 463981ceefa..2f50a603ca3 100644
--- a/source/blender/io/collada/LightExporter.cpp
+++ b/source/blender/io/collada/LightExporter.cpp
@@ -76,7 +76,7 @@ void LightsExporter::operator()(Object *ob)
quadatt = 1.0f / (d * d);
}
- // sun
+ /* sun */
if (la->type == LA_SUN) {
COLLADASW::DirectionalLight cla(mSW, la_id, la_name);
cla.setColor(col, false, "color");
@@ -85,7 +85,7 @@ void LightsExporter::operator()(Object *ob)
addLight(cla);
}
- // spot
+ /* spot */
else if (la->type == LA_SPOT) {
COLLADASW::SpotLight cla(mSW, la_id, la_name);
cla.setColor(col, false, "color");
@@ -97,7 +97,7 @@ void LightsExporter::operator()(Object *ob)
exportBlenderProfile(cla, la);
addLight(cla);
}
- // lamp
+ /* lamp */
else if (la->type == LA_LOCAL) {
COLLADASW::PointLight cla(mSW, la_id, la_name);
cla.setColor(col, false, "color");
@@ -107,8 +107,8 @@ void LightsExporter::operator()(Object *ob)
exportBlenderProfile(cla, la);
addLight(cla);
}
- // area light is not supported
- // it will be exported as a local lamp
+ /* area light is not supported
+ * it will be exported as a local lamp */
else {
COLLADASW::PointLight cla(mSW, la_id, la_name);
cla.setColor(col, false, "color");
@@ -138,7 +138,7 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Light *la)
cla.addExtraTechniqueParameter("blender", "spotblend", la->spotblend);
cla.addExtraTechniqueParameter("blender", "att1", la->att1);
cla.addExtraTechniqueParameter("blender", "att2", la->att2);
- // \todo figure out how we can have falloff curve supported here
+ /* \todo figure out how we can have falloff curve supported here */
cla.addExtraTechniqueParameter("blender", "falloff_type", la->falloff_type);
cla.addExtraTechniqueParameter("blender", "clipsta", la->clipsta);
cla.addExtraTechniqueParameter("blender", "clipend", la->clipend);
diff --git a/source/blender/io/collada/MaterialExporter.cpp b/source/blender/io/collada/MaterialExporter.cpp
index 488d1833e48..72669e9d8d2 100644
--- a/source/blender/io/collada/MaterialExporter.cpp
+++ b/source/blender/io/collada/MaterialExporter.cpp
@@ -51,7 +51,7 @@ bool MaterialsExporter::hasMaterials(Scene *sce)
for (a = 0; a < ob->totcol; a++) {
Material *ma = BKE_object_material_get(ob, a + 1);
- // no material, but check all of the slots
+ /* no material, but check all of the slots */
if (!ma) {
continue;
}
diff --git a/source/blender/io/collada/MaterialExporter.h b/source/blender/io/collada/MaterialExporter.h
index 7d40347097c..c684e96be19 100644
--- a/source/blender/io/collada/MaterialExporter.h
+++ b/source/blender/io/collada/MaterialExporter.h
@@ -51,7 +51,7 @@ class MaterialsExporter : COLLADASW::LibraryMaterials {
// used in forEachMaterialInScene
template<class Functor> class ForEachMaterialFunctor {
std::vector<std::string>
- mMat; // contains list of material names, to avoid duplicate calling of f
+ mMat; /* contains list of material names, to avoid duplicate calling of f */
Functor *f;
public:
@@ -81,8 +81,8 @@ template<class Functor> class ForEachMaterialFunctor {
};
struct MaterialFunctor {
- // calls f for each unique material linked to each object in sce
- // f should have
+ /* calls f for each unique material linked to each object in sce
+ * f should have */
// void operator()(Material *ma)
template<class Functor>
void forEachMaterialInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
diff --git a/source/blender/io/collada/Materials.cpp b/source/blender/io/collada/Materials.cpp
index 1e02e151d97..a97b7dfcfd6 100644
--- a/source/blender/io/collada/Materials.cpp
+++ b/source/blender/io/collada/Materials.cpp
@@ -53,7 +53,7 @@ MaterialNode::MaterialNode(bContext *C,
add_link(ntree, nmap["transparent"], 0, nmap["mix"], 2);
add_link(ntree, nmap["mix"], 0, nmap["out"], 0);
- // experimental, probably not used.
+ /* experimental, probably not used. */
make_group(C, ntree, nmap);
#else
shader_node = add_node(SH_NODE_BSDF_PRINCIPLED, 0, 300, "");
@@ -66,24 +66,24 @@ void MaterialNode::setShaderType()
{
#if 0
COLLADAFW::EffectCommon::ShaderType shader = ef->getShaderType();
- // Currently we only support PBR based shaders
- // TODO: simulate the effects with PBR
+ /* Currently we only support PBR based shaders */
+ /* TODO: simulate the effects with PBR */
- // blinn
+ /* blinn */
if (shader == COLLADAFW::EffectCommon::SHADER_BLINN) {
ma->spec_shader = MA_SPEC_BLINN;
ma->spec = ef->getShininess().getFloatValue();
}
- // phong
+ /* phong */
else if (shader == COLLADAFW::EffectCommon::SHADER_PHONG) {
ma->spec_shader = MA_SPEC_PHONG;
ma->har = ef->getShininess().getFloatValue();
}
- // lambert
+ /* lambert */
else if (shader == COLLADAFW::EffectCommon::SHADER_LAMBERT) {
ma->diff_shader = MA_DIFF_LAMBERT;
}
- // default - lambert
+ /* default - lambert */
else {
ma->diff_shader = MA_DIFF_LAMBERT;
fprintf(stderr, "Current shader type is not supported, default to lambert.\n");
@@ -91,7 +91,7 @@ void MaterialNode::setShaderType()
#endif
}
-// returns null if material already has a node tree
+/* returns null if material already has a node tree */
bNodeTree *MaterialNode::prepare_material_nodetree()
{
if (material->nodetree) {
@@ -139,7 +139,7 @@ void MaterialNode::set_reflectivity(COLLADAFW::FloatOrParam &val)
}
#if 0
-// needs rework to be done for 2.81
+/* needs rework to be done for 2.81 */
void MaterialNode::set_shininess(COLLADAFW::FloatOrParam &val)
{
float roughness = val.getFloatValue();
@@ -177,7 +177,7 @@ void MaterialNode::set_alpha(COLLADAFW::EffectCommon::OpaqueMode mode,
}
if (cot.isColor() || !cot.isValid()) {
- // transparent_cot is either a color or not defined
+ /* transparent_cot is either a color or not defined */
float transparent_alpha;
if (cot.isValid()) {
@@ -185,14 +185,14 @@ void MaterialNode::set_alpha(COLLADAFW::EffectCommon::OpaqueMode mode,
transparent_alpha = col.getAlpha();
}
else {
- // no transparent color defined
+ /* no transparent color defined */
transparent_alpha = 1;
}
float transparency_alpha = val.getFloatValue();
if (transparency_alpha < 0) {
- // transparency is not defined
- transparency_alpha = 1; // set to opaque
+ /* transparency is not defined */
+ transparency_alpha = 1; /* set to opaque */
}
float alpha = transparent_alpha * transparency_alpha;
@@ -279,12 +279,12 @@ void MaterialNode::set_ambient(COLLADAFW::ColorOrTexture &cot)
COLLADAFW::Color col = cot.getColor();
bNode *node = add_node(SH_NODE_RGB, -300, locy, "Ambient");
set_color(node, col);
- // TODO: Connect node
+ /* TODO: Connect node */
}
- // texture
+ /* texture */
else if (cot.isTexture()) {
add_texture_node(cot, -300, locy, "Ambient");
- // TODO: Connect node
+ /* TODO: Connect node */
}
}
@@ -295,12 +295,12 @@ void MaterialNode::set_reflective(COLLADAFW::ColorOrTexture &cot)
COLLADAFW::Color col = cot.getColor();
bNode *node = add_node(SH_NODE_RGB, -300, locy, "Reflective");
set_color(node, col);
- // TODO: Connect node
+ /* TODO: Connect node */
}
- // texture
+ /* texture */
else if (cot.isTexture()) {
add_texture_node(cot, -300, locy, "Reflective");
- // TODO: Connect node
+ /* TODO: Connect node */
}
}
@@ -343,16 +343,16 @@ void MaterialNode::set_opacity(COLLADAFW::ColorOrTexture &cot)
float alpha = effect->getTransparency().getFloatValue();
if (col.isValid()) {
- alpha *= col.getAlpha(); // Assuming A_ONE opaque mode
+ alpha *= col.getAlpha(); /* Assuming A_ONE opaque mode */
}
bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Alpha");
((bNodeSocketValueFloat *)socket->default_value)->value = alpha;
}
- // texture
+ /* texture */
else if (cot.isTexture()) {
add_texture_node(cot, -300, locy, "Alpha");
- // TODO: Connect node
+ /* TODO: Connect node */
}
}
@@ -363,12 +363,12 @@ void MaterialNode::set_specular(COLLADAFW::ColorOrTexture &cot)
COLLADAFW::Color col = cot.getColor();
bNode *node = add_node(SH_NODE_RGB, -300, locy, "Specular");
set_color(node, col);
- // TODO: Connect node
+ /* TODO: Connect node */
}
- // texture
+ /* texture */
else if (cot.isTexture()) {
add_texture_node(cot, -300, locy, "Specular");
- // TODO: Connect node
+ /* TODO: Connect node */
}
}
diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp
index 3d9c4d3ad6f..7d5cd671b73 100644
--- a/source/blender/io/collada/MeshImporter.cpp
+++ b/source/blender/io/collada/MeshImporter.cpp
@@ -47,7 +47,7 @@
#include "MeshImporter.h"
#include "collada_utils.h"
-// get node name, or fall back to original id if not present (name is optional)
+/* get node name, or fall back to original id if not present (name is optional) */
template<class T> static std::string bc_get_dae_name(T *node)
{
return node->getName().empty() ? node->getOriginalId() : node->getName();
@@ -170,7 +170,7 @@ void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol)
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: {
COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
if (values->empty() || values->getCount() <= (v_index * stride + 2)) {
- return; // xxx need to create an error instead
+ return; /* xxx need to create an error instead */
}
mloopcol->r = unit_float_to_uchar_clamp((*values)[v_index * stride]);
@@ -181,7 +181,7 @@ void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol)
case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: {
COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
if (values->empty() || values->getCount() <= (v_index * stride + 2)) {
- return; // xxx need to create an error instead
+ return; /* xxx need to create an error instead */
}
mloopcol->r = unit_float_to_uchar_clamp((*values)[v_index * stride]);
@@ -216,7 +216,7 @@ bool MeshImporter::set_poly_indices(
if (!broken_loop) {
for (int i = 0; i < index; i++) {
if (indices[i] == indices[index]) {
- // duplicate index -> not good
+ /* duplicate index -> not good */
broken_loop = true;
}
}
@@ -247,7 +247,7 @@ void MeshImporter::set_face_uv(MLoopUV *mloopuv,
COLLADAFW::IndexList &index_list,
int count)
{
- // per face vertex indices, this means for quad we have 4 indices, not 8
+ /* per face vertex indices, this means for quad we have 4 indices, not 8 */
COLLADAFW::UIntValuesArray &indices = index_list.getIndices();
for (int index = 0; index < count; index++) {
@@ -281,7 +281,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh)
const char *type_str = bc_primTypeToStr(type);
- // OpenCollada passes POLYGONS type for <polylist>
+ /* OpenCollada passes POLYGONS type for <polylist> */
if (type == COLLADAFW::MeshPrimitive::POLYLIST || type == COLLADAFW::MeshPrimitive::POLYGONS) {
COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
@@ -319,7 +319,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh)
}
else if (type == COLLADAFW::MeshPrimitive::LINES) {
- // TODO: Add Checker for line syntax here
+ /* TODO: Add Checker for line syntax here */
}
else if (type != COLLADAFW::MeshPrimitive::TRIANGLES &&
@@ -334,7 +334,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh)
void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
{
- // vertices
+ /* vertices */
COLLADAFW::MeshVertexData &pos = mesh->getPositions();
if (pos.empty()) {
return;
@@ -356,12 +356,12 @@ void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
}
}
-// =====================================================================
-// condition 1: The Primitive has normals
-// condition 2: The number of normals equals the number of faces.
-// return true if both conditions apply.
-// return false otherwise.
-// =====================================================================
+/* =====================================================================
+ * condition 1: The Primitive has normals
+ * condition 2: The number of normals equals the number of faces.
+ * return true if both conditions apply.
+ * return false otherwise.
+ * ===================================================================== */
bool MeshImporter::primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp)
{
@@ -385,10 +385,10 @@ bool MeshImporter::primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp)
return has_useable_normals;
}
-// =====================================================================
-// Assume that only TRIANGLES, TRIANGLE_FANS, POLYLIST and POLYGONS
-// have faces. (to be verified)
-// =====================================================================
+/* =====================================================================
+ * Assume that only TRIANGLES, TRIANGLE_FANS, POLYLIST and POLYGONS
+ * have faces. (to be verified)
+ * ===================================================================== */
bool MeshImporter::primitive_has_faces(COLLADAFW::MeshPrimitive *mp)
{
@@ -420,19 +420,19 @@ static std::string extract_vcolname(const COLLADAFW::String &collada_id)
return colname;
}
-// =================================================================
-// Return the number of faces by summing up
-// the facecounts of the parts.
-// hint: This is done because mesh->getFacesCount() does
-// count loose edges as extra faces, which is not what we want here.
-// =================================================================
+/* =================================================================
+ * Return the number of faces by summing up
+ * the face-counts of the parts.
+ * hint: This is done because `mesh->getFacesCount()` does
+ * count loose edges as extra faces, which is not what we want here.
+ * ================================================================= */
void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
{
COLLADAFW::MeshPrimitiveArray &prim_arr = collada_mesh->getMeshPrimitives();
int total_poly_count = 0;
int total_loop_count = 0;
- // collect edge_count and face_count from all parts
+ /* collect edge_count and face_count from all parts */
for (int i = 0; i < prim_arr.getCount(); i++) {
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
int type = mp->getPrimitiveType();
@@ -452,7 +452,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
total_poly_count++;
}
else {
- // TODO: this is a hole and not another polygon!
+ /* TODO: this is a hole and not another polygon! */
}
}
@@ -465,7 +465,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
}
}
- // Add the data containers
+ /* Add the data containers */
if (total_poly_count > 0) {
me->totpoly = total_poly_count;
me->totloop = total_loop_count;
@@ -485,11 +485,11 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
COLLADAFW::MeshVertexData::InputInfos *info =
collada_mesh->getUVCoords().getInputInfosArray()[i];
COLLADAFW::String &uvname = info->mName;
- // Allocate space for UV_data
+ /* Allocate space for UV_data */
CustomData_add_layer_named(
&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, uvname.c_str());
}
- // activate the first uv map
+ /* activate the first uv map */
me->mloopuv = (MLoopUV *)CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, 0);
}
@@ -535,7 +535,7 @@ unsigned int MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh)
COLLADAFW::MeshPrimitiveArray &prim_arr = mesh->getMeshPrimitives();
int loose_edge_count = 0;
- // collect edge_count and face_count from all parts
+ /* collect edge_count and face_count from all parts */
for (int i = 0; i < prim_arr.getCount(); i++) {
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
int type = mp->getPrimitiveType();
@@ -552,13 +552,13 @@ unsigned int MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh)
return loose_edge_count;
}
-// =================================================================
-// This function is copied from source/blender/editors/mesh/mesh_data.c
-//
-// TODO: (As discussed with sergey-) :
-// Maybe move this function to blenderkernel/intern/mesh.c
-// and add definition to BKE_mesh.c
-// =================================================================
+/* =================================================================
+ * This function is copied from source/blender/editors/mesh/mesh_data.c
+ *
+ * TODO: (As discussed with sergey-) :
+ * Maybe move this function to blenderkernel/intern/mesh.c
+ * and add definition to BKE_mesh.c
+ * ================================================================= */
void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
{
CustomData edata;
@@ -592,12 +592,12 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
mesh->totedge = totedge;
}
-// =================================================================
-// Read all loose edges.
-// Important: This function assumes that all edges from existing
-// faces have already been generated and added to me->medge
-// So this function MUST be called after read_faces() (see below)
-// =================================================================
+/* =================================================================
+ * Read all loose edges.
+ * Important: This function assumes that all edges from existing
+ * faces have already been generated and added to me->medge
+ * So this function MUST be called after read_faces() (see below)
+ * ================================================================= */
void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
{
unsigned int loose_edge_count = get_loose_edge_count(mesh);
@@ -631,13 +631,13 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
}
}
-// =======================================================================
-// Read all faces from TRIANGLES, TRIANGLE_FANS, POLYLIST, POLYGON
-// Important: This function MUST be called before read_lines()
-// Otherwise we will loose all edges from faces (see read_lines() above)
-//
-// TODO: import uv set names
-// ========================================================================
+/* =======================================================================
+ * Read all faces from TRIANGLES, TRIANGLE_FANS, POLYLIST, POLYGON
+ * Important: This function MUST be called before read_lines()
+ * Otherwise we will loose all edges from faces (see read_lines() above)
+ *
+ * TODO: import uv set names
+ * ======================================================================== */
void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
{
unsigned int i;
@@ -660,7 +660,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
- // faces
+ /* faces */
size_t prim_totpoly = mp->getFaceCount();
unsigned int *position_indices = mp->getPositionIndices().getData();
unsigned int *normal_indices = mp->getNormalIndices().getData();
@@ -670,28 +670,28 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
int collada_meshtype = mp->getPrimitiveType();
- // since we cannot set mpoly->mat_nr here, we store a portion of me->mpoly in Primitive
+ /* since we cannot set mpoly->mat_nr here, we store a portion of me->mpoly in Primitive */
Primitive prim = {mpoly, 0};
- // If MeshPrimitive is TRIANGLE_FANS we split it into triangles
- // The first trifan vertex will be the first vertex in every triangle
- // XXX The proper function of TRIANGLE_FANS is not tested!!!
- // XXX In particular the handling of the normal_indices looks very wrong to me
+ /* If MeshPrimitive is TRIANGLE_FANS we split it into triangles
+ * The first triangle-fan vertex will be the first vertex in every triangle
+ * XXX The proper function of TRIANGLE_FANS is not tested!!!
+ * XXX In particular the handling of the normal_indices looks very wrong to me */
if (collada_meshtype == COLLADAFW::MeshPrimitive::TRIANGLE_FANS) {
unsigned int grouped_vertex_count = mp->getGroupedVertexElementsCount();
for (unsigned int group_index = 0; group_index < grouped_vertex_count; group_index++) {
- unsigned int first_vertex = position_indices[0]; // Store first trifan vertex
- unsigned int first_normal = normal_indices[0]; // Store first trifan vertex normal
+ unsigned int first_vertex = position_indices[0]; /* Store first trifan vertex */
+ unsigned int first_normal = normal_indices[0]; /* Store first trifan vertex normal */
unsigned int vertex_count = mp->getGroupedVerticesVertexCount(group_index);
for (unsigned int vertex_index = 0; vertex_index < vertex_count - 2; vertex_index++) {
- // For each triangle store indices of its 3 vertices
+ /* For each triangle store indices of its 3 vertices */
unsigned int triangle_vertex_indices[3] = {
first_vertex, position_indices[1], position_indices[2]};
set_poly_indices(mpoly, mloop, loop_index, triangle_vertex_indices, 3);
- if (mp_has_normals) { // vertex normals, same implementation as for the triangles
- // the same for vertces normals
+ if (mp_has_normals) { /* vertex normals, same implementation as for the triangles */
+ /* the same for vertces normals */
unsigned int vertex_normal_indices[3] = {
first_normal, normal_indices[1], normal_indices[2]};
if (!is_flat_face(vertex_normal_indices, nor, 3)) {
@@ -706,7 +706,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
prim.totpoly++;
}
- // Moving cursor to the next triangle fan.
+ /* Moving cursor to the next triangle fan. */
if (mp_has_normals) {
normal_indices += 2;
}
@@ -727,10 +727,10 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
int invalid_loop_holes = 0;
for (unsigned int j = 0; j < prim_totpoly; j++) {
- // Vertices in polygon:
+ /* Vertices in polygon: */
int vcount = get_vertex_count(mpvc, j);
if (vcount < 0) {
- continue; // TODO: add support for holes
+ continue; /* TODO: add support for holes */
}
bool broken_loop = set_poly_indices(mpoly, mloop, loop_index, position_indices, vcount);
@@ -740,7 +740,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
for (unsigned int uvset_index = 0; uvset_index < index_list_array_uvcoord.getCount();
uvset_index++) {
- // get mtface by face index and uv set index
+ /* get mtface by face index and uv set index */
COLLADAFW::IndexList &index_list = *index_list_array_uvcoord[uvset_index];
MLoopUV *mloopuv = (MLoopUV *)CustomData_get_layer_named(
&me->ldata, CD_MLOOPUV, index_list.getName().c_str());
@@ -808,7 +808,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
}
else if (collada_meshtype == COLLADAFW::MeshPrimitive::LINES) {
- continue; // read the lines later after all the rest is done
+ continue; /* read the lines later after all the rest is done */
}
if (mp_has_faces) {
@@ -915,21 +915,21 @@ std::string *MeshImporter::get_geometry_name(const std::string &mesh_name)
static bool bc_has_same_material_configuration(Object *ob1, Object *ob2)
{
if (ob1->totcol != ob2->totcol) {
- return false; // not same number of materials
+ return false; /* not same number of materials */
}
if (ob1->totcol == 0) {
- return false; // no material at all
+ return false; /* no material at all */
}
for (int index = 0; index < ob1->totcol; index++) {
if (ob1->matbits[index] != ob2->matbits[index]) {
- return false; // shouldn't happen
+ return false; /* shouldn't happen */
}
if (ob1->matbits[index] == 0) {
- return false; // shouldn't happen
+ return false; /* shouldn't happen */
}
if (ob1->mat[index] != ob2->mat[index]) {
- return false; // different material assignment
+ return false; /* different material assignment */
}
}
return true;
@@ -1055,28 +1055,28 @@ void MeshImporter::assign_material_to_geom(
{
const COLLADAFW::UniqueId &ma_uid = cmaterial.getReferencedMaterial();
- // do we know this material?
+ /* do we know this material? */
if (uid_material_map.find(ma_uid) == uid_material_map.end()) {
fprintf(stderr, "Cannot find material by UID.\n");
return;
}
- // first time we get geom_uid, ma_uid pair. Save for later check.
+ /* first time we get geom_uid, ma_uid pair. Save for later check. */
materials_mapped_to_geom.insert(
std::pair<COLLADAFW::UniqueId, COLLADAFW::UniqueId>(*geom_uid, ma_uid));
Material *ma = uid_material_map[ma_uid];
- // Attention! This temporarily assigns material to object on purpose!
- // See note above.
+ /* Attention! This temporarily assigns material to object on purpose!
+ * See note above. */
ob->actcol = 0;
BKE_object_material_assign(m_bmain, ob, ma, mat_index + 1, BKE_MAT_ASSIGN_OBJECT);
MaterialIdPrimitiveArrayMap &mat_prim_map = geom_uid_mat_mapping_map[*geom_uid];
COLLADAFW::MaterialId mat_id = cmaterial.getMaterialId();
- // assign material indices to mesh faces
+ /* assign material indices to mesh faces */
if (mat_prim_map.find(mat_id) != mat_prim_map.end()) {
std::vector<Primitive> &prims = mat_prim_map[mat_id];
@@ -1102,7 +1102,7 @@ Object *MeshImporter::create_mesh_object(
{
const COLLADAFW::UniqueId *geom_uid = &geom->getInstanciatedObjectId();
- // check if node instantiates controller or geometry
+ /* check if node instantiates controller or geometry */
if (isController) {
geom_uid = armature_importer->get_geometry_uid(*geom_uid);
@@ -1115,8 +1115,8 @@ Object *MeshImporter::create_mesh_object(
else {
if (uid_mesh_map.find(*geom_uid) == uid_mesh_map.end()) {
- // this could happen if a mesh was not created
- // (e.g. if it contains unsupported geometry)
+ /* this could happen if a mesh was not created
+ * (e.g. if it contains unsupported geometry) */
fprintf(stderr, "Couldn't find a mesh by UID.\n");
return NULL;
}
@@ -1125,19 +1125,19 @@ Object *MeshImporter::create_mesh_object(
return NULL;
}
- // name Object
+ /* name Object */
const std::string &id = node->getName().empty() ? node->getOriginalId() : node->getName();
const char *name = (id.length()) ? id.c_str() : NULL;
- // add object
+ /* add object */
Object *ob = bc_add_object(m_bmain, scene, view_layer, OB_MESH, name);
- bc_set_mark(ob); // used later for material assignment optimization
+ bc_set_mark(ob); /* used later for material assignment optimization */
- // store object pointer for ArmatureImporter
+ /* store object pointer for ArmatureImporter */
uid_object_map[*geom_uid] = ob;
imported_objects.push_back(ob);
- // replace ob->data freeing the old one
+ /* replace ob->data freeing the old one */
Mesh *old_mesh = (Mesh *)ob->data;
Mesh *new_mesh = uid_mesh_map[*geom_uid];
@@ -1151,7 +1151,7 @@ Object *MeshImporter::create_mesh_object(
COLLADAFW::MaterialBindingArray &mat_array = geom->getMaterialBindings();
- // loop through geom's materials
+ /* loop through geom's materials */
for (unsigned int i = 0; i < mat_array.getCount(); i++) {
if (mat_array[i].getReferencedMaterial().isValid()) {
@@ -1162,18 +1162,18 @@ Object *MeshImporter::create_mesh_object(
}
}
- // clean up the mesh
+ /* clean up the mesh */
BKE_mesh_validate((Mesh *)ob->data, false, false);
return ob;
}
-// create a mesh storing a pointer in a map so it can be retrieved later by geometry UID
+/* create a mesh storing a pointer in a map so it can be retrieved later by geometry UID */
bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
{
if (geom->getType() != COLLADAFW::Geometry::GEO_TYPE_MESH) {
- // TODO: report warning
+ /* TODO: report warning */
fprintf(stderr, "Mesh type %s is not supported\n", bc_geomTypeToStr(geom->getType()));
return true;
}
@@ -1188,18 +1188,18 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
const std::string &str_geom_id = mesh->getName().empty() ? mesh->getOriginalId() :
mesh->getName();
Mesh *me = BKE_mesh_add(m_bmain, (char *)str_geom_id.c_str());
- id_us_min(&me->id); // is already 1 here, but will be set later in BKE_mesh_assign_object
+ id_us_min(&me->id); /* is already 1 here, but will be set later in BKE_mesh_assign_object */
- // store the Mesh pointer to link it later with an Object
- // mesh_geom_map needed to map mesh to its geometry name (for shape key naming)
+ /* store the Mesh pointer to link it later with an Object
+ * mesh_geom_map needed to map mesh to its geometry name (for shape key naming) */
this->uid_mesh_map[mesh->getUniqueId()] = me;
this->mesh_geom_map[std::string(me->id.name)] = str_geom_id;
read_vertices(mesh, me);
read_polys(mesh, me);
BKE_mesh_calc_edges(me, false, false);
- // read_lines() must be called after the face edges have been generated.
- // Otherwise the loose edges will be silently deleted again.
+ /* read_lines() must be called after the face edges have been generated.
+ * Otherwise the loose edges will be silently deleted again. */
read_lines(mesh, me);
return true;
diff --git a/source/blender/io/collada/SkinInfo.h b/source/blender/io/collada/SkinInfo.h
index 3b94e403b6d..7ce66b22a5f 100644
--- a/source/blender/io/collada/SkinInfo.h
+++ b/source/blender/io/collada/SkinInfo.h
@@ -35,28 +35,28 @@
#include "TransformReader.h"
#include "collada_internal.h"
-// This is used to store data passed in write_controller_data.
-// Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members
-// so that arrays don't get freed until we free them explicitly.
+/* This is used to store data passed in write_controller_data.
+ * Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members
+ * so that arrays don't get freed until we free them explicitly. */
class SkinInfo {
private:
- // to build armature bones from inverse bind matrices
+ /* to build armature bones from inverse bind matrices */
struct JointData {
- float inv_bind_mat[4][4]; // joint inverse bind matrix
- COLLADAFW::UniqueId joint_uid; // joint node UID
- // Object *ob_arm; // armature object
+ float inv_bind_mat[4][4]; /* joint inverse bind matrix */
+ COLLADAFW::UniqueId joint_uid; /* joint node UID */
+ // Object *ob_arm; /* armature object */
};
float bind_shape_matrix[4][4];
- // data from COLLADAFW::SkinControllerData, each array should be freed
+ /* data from COLLADAFW::SkinControllerData, each array should be freed */
COLLADAFW::UIntValuesArray joints_per_vertex;
COLLADAFW::UIntValuesArray weight_indices;
COLLADAFW::IntValuesArray joint_indices;
- // COLLADAFW::FloatOrDoubleArray weights;
+ /* COLLADAFW::FloatOrDoubleArray weights; */
std::vector<float> weights;
- std::vector<JointData> joint_data; // index to this vector is joint index
+ std::vector<JointData> joint_data; /* index to this vector is joint index */
UnitConverter *unit_converter;
@@ -69,10 +69,10 @@ class SkinInfo {
SkinInfo(const SkinInfo &skin);
SkinInfo(UnitConverter *conv);
- // nobody owns the data after this, so it should be freed manually with releaseMemory
+ /* nobody owns the data after this, so it should be freed manually with releaseMemory */
template<typename T> void transfer_array_data(T &src, T &dest);
- // when src is const we cannot src.yieldOwnerShip, this is used by copy constructor
+ /* when src is const we cannot src.yieldOwnerShip, this is used by copy constructor */
void transfer_int_array_data_const(const COLLADAFW::IntValuesArray &src,
COLLADAFW::IntValuesArray &dest);
@@ -83,14 +83,14 @@ class SkinInfo {
void free();
- // using inverse bind matrices to construct armature
- // it is safe to invert them to get the original matrices
- // because if they are inverse matrices, they can be inverted
+ /* using inverse bind matrices to construct armature
+ * it is safe to invert them to get the original matrices
+ * because if they are inverse matrices, they can be inverted */
void add_joint(const COLLADABU::Math::Matrix4 &matrix);
void set_controller(const COLLADAFW::SkinController *co);
- // called from write_controller
+ /* called from write_controller */
Object *create_armature(Main *bmain, Scene *scene, ViewLayer *view_layer);
Object *set_armature(Object *ob_arm);
@@ -101,11 +101,11 @@ class SkinInfo {
const COLLADAFW::UniqueId &get_controller_uid();
- // check if this skin controller references a joint or any descendant of it
- //
- // some nodes may not be referenced by SkinController,
- // in this case to determine if the node belongs to this armature,
- // we need to search down the tree
+ /* check if this skin controller references a joint or any descendant of it
+ *
+ * some nodes may not be referenced by SkinController,
+ * in this case to determine if the node belongs to this armature,
+ * we need to search down the tree */
bool uses_joint_or_descendant(COLLADAFW::Node *node);
void link_armature(bContext *C,
diff --git a/source/blender/io/collada/TransformReader.cpp b/source/blender/io/collada/TransformReader.cpp
index 87b8763fb6a..393393be65b 100644
--- a/source/blender/io/collada/TransformReader.cpp
+++ b/source/blender/io/collada/TransformReader.cpp
@@ -54,9 +54,9 @@ void TransformReader::get_node_mat(float mat[4][4],
switch (type) {
case COLLADAFW::Transformation::MATRIX:
- // When matrix AND Trans/Rot/Scale are defined for a node,
- // then this is considered as redundant information.
- // So if we find a Matrix we use that and return.
+ /* When matrix AND Trans/Rot/Scale are defined for a node,
+ * then this is considered as redundant information.
+ * So if we find a Matrix we use that and return. */
dae_matrix_to_mat4(tm, mat);
if (parent_mat) {
mul_m4_m4m4(mat, parent_mat, mat);
@@ -83,10 +83,10 @@ void TransformReader::get_node_mat(float mat[4][4],
mul_m4_m4m4(mat, copy, cur);
if (animation_map) {
- // AnimationList that drives this Transformation
+ /* AnimationList that drives this Transformation */
const COLLADAFW::UniqueId &anim_list_id = tm->getAnimationList();
- // store this so later we can link animation data with ob
+ /* store this so later we can link animation data with ob */
Animation anim = {ob, node, tm};
(*animation_map)[anim_list_id] = anim;
}
diff --git a/source/blender/io/collada/TransformReader.h b/source/blender/io/collada/TransformReader.h
index f8a73ce3912..9b87f56699e 100644
--- a/source/blender/io/collada/TransformReader.h
+++ b/source/blender/io/collada/TransformReader.h
@@ -44,7 +44,7 @@ class TransformReader {
struct Animation {
Object *ob;
COLLADAFW::Node *node;
- COLLADAFW::Transformation *tm; // which transform is animated by an AnimationList->id
+ COLLADAFW::Transformation *tm; /* which transform is animated by an AnimationList->id */
};
TransformReader(UnitConverter *conv);
diff --git a/source/blender/io/collada/collada_internal.cpp b/source/blender/io/collada/collada_internal.cpp
index 66810685979..091bd2cd7c2 100644
--- a/source/blender/io/collada/collada_internal.cpp
+++ b/source/blender/io/collada/collada_internal.cpp
@@ -71,12 +71,12 @@ void UnitConverter::convertVector3(COLLADABU::Math::Vector3 &vec, float *v)
v[2] = vec.z;
}
-// TODO need also for angle conversion, time conversion...
+/* TODO need also for angle conversion, time conversion... */
void UnitConverter::dae_matrix_to_mat4_(float out[4][4], const COLLADABU::Math::Matrix4 &in)
{
- // in DAE, matrices use columns vectors, (see comments in COLLADABUMathMatrix4.h)
- // so here, to make a blender matrix, we swap columns and rows
+ /* in DAE, matrices use columns vectors, (see comments in COLLADABUMathMatrix4.h)
+ * so here, to make a blender matrix, we swap columns and rows. */
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
out[i][j] = in[j][i];
@@ -138,7 +138,7 @@ void UnitConverter::calculate_scale(Scene &sce)
switch (type) {
case USER_UNIT_NONE:
- bl_scale = 1.0; // map 1 Blender unit to 1 Meter
+ bl_scale = 1.0; /* map 1 Blender unit to 1 Meter. */
break;
case USER_UNIT_METRIC:
@@ -147,8 +147,8 @@ void UnitConverter::calculate_scale(Scene &sce)
default:
bl_scale = RNA_property_float_get(&unit_settings, scale_ptr);
- // it looks like the conversion to Imperial is done implicitly.
- // So nothing to do here.
+ /* It looks like the conversion to Imperial is done implicitly.
+ * So nothing to do here. */
break;
}
@@ -231,9 +231,9 @@ std::string translate_id(const std::string &id)
for (unsigned int i = 1; i < id_translated.size(); i++) {
id_translated[i] = translate_name_map[(unsigned int)id_translated[i]];
}
- // It's so much workload now, the if () should speed up things.
+ /* It's so much workload now, the if () should speed up things. */
if (id_translated != id) {
- // Search duplicates
+ /* Search duplicates. */
map_string_list::iterator iter = global_id_map.find(id_translated);
if (iter != global_id_map.end()) {
unsigned int i = 0;
diff --git a/source/blender/io/collada/collada_internal.h b/source/blender/io/collada/collada_internal.h
index de4e1d7e0d4..1d2ed11bfe6 100644
--- a/source/blender/io/collada/collada_internal.h
+++ b/source/blender/io/collada/collada_internal.h
@@ -51,7 +51,7 @@ class UnitConverter {
Imperial,
};
- // Initialize with Z_UP, since Blender uses right-handed, z-up
+ /* Initialize with Z_UP, since Blender uses right-handed, z-up */
UnitConverter();
void read_asset(const COLLADAFW::FileInfo *asset);
@@ -62,7 +62,7 @@ class UnitConverter {
float getLinearMeter(void);
- // TODO need also for angle conversion, time conversion...
+ /* TODO need also for angle conversion, time conversion... */
static void dae_matrix_to_mat4_(float out[4][4], const COLLADABU::Math::Matrix4 &in);
static void mat4_to_dae(float out[4][4], float in[4][4]);
diff --git a/source/blender/io/common/IO_abstract_hierarchy_iterator.h b/source/blender/io/common/IO_abstract_hierarchy_iterator.h
index e3ed3dd70a2..e066ca8ba8f 100644
--- a/source/blender/io/common/IO_abstract_hierarchy_iterator.h
+++ b/source/blender/io/common/IO_abstract_hierarchy_iterator.h
@@ -86,9 +86,9 @@ struct HierarchyContext {
bool animation_check_include_parent;
/*********** Determined during writer creation: ***************/
- float parent_matrix_inv_world[4][4]; // Inverse of the parent's world matrix.
- std::string export_path; // Hierarchical path, such as "/grandparent/parent/objectname".
- ParticleSystem *particle_system; // Only set for particle/hair writers.
+ float parent_matrix_inv_world[4][4]; /* Inverse of the parent's world matrix. */
+ std::string export_path; /* Hierarchical path, such as "/grandparent/parent/objectname". */
+ ParticleSystem *particle_system; /* Only set for particle/hair writers. */
/* Hierarchical path of the object this object is duplicating; only set when this object should
* be stored as a reference to its original. It can happen that the original is not part of the
@@ -127,9 +127,9 @@ class AbstractHierarchyWriter {
public:
virtual ~AbstractHierarchyWriter();
virtual void write(HierarchyContext &context) = 0;
- // TODO(Sybren): add function like absent() that's called when a writer was previously created,
- // but wasn't used while exporting the current frame (for example, a particle-instanced mesh of
- // which the particle is no longer alive).
+ /* TODO(Sybren): add function like absent() that's called when a writer was previously created,
+ * but wasn't used while exporting the current frame (for example, a particle-instanced mesh of
+ * which the particle is no longer alive). */
protected:
/* Return true if the data written by this writer changes over time.
* Note that this function assumes this is an object data writer. Transform writers should not
diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
index 6e763c29631..6077fc89b91 100644
--- a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
@@ -57,7 +57,7 @@ bool HierarchyContext::operator<(const HierarchyContext &other) const
return object < other.object;
}
if (duplicator != nullptr && duplicator == other.duplicator) {
- // Only resort to string comparisons when both objects are created by the same duplicator.
+ /* Only resort to string comparisons when both objects are created by the same duplicator. */
return export_name < other.export_name;
}
@@ -291,16 +291,16 @@ void AbstractHierarchyIterator::export_graph_construct()
object,
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET) {
- // Non-instanced objects always have their object-parent as export-parent.
+ /* Non-instanced objects always have their object-parent as export-parent. */
const bool weak_export = mark_as_weak_export(object);
visit_object(object, object->parent, weak_export);
if (weak_export) {
- // If a duplicator shouldn't be exported, its duplilist also shouldn't be.
+ /* If a duplicator shouldn't be exported, its duplilist also shouldn't be. */
continue;
}
- // Export the duplicated objects instanced by this object.
+ /* Export the duplicated objects instanced by this object. */
ListBase *lb = object_duplilist(depsgraph_, scene, object);
if (lb) {
DupliParentFinder dupli_parent_finder;
@@ -328,29 +328,29 @@ void AbstractHierarchyIterator::export_graph_construct()
void AbstractHierarchyIterator::connect_loose_objects()
{
- // Find those objects whose parent is not part of the export graph; these
- // objects would be skipped when traversing the graph as a hierarchy.
- // These objects will have to be re-attached to some parent object in order to
- // fit into the hierarchy.
+ /* Find those objects whose parent is not part of the export graph; these
+ * objects would be skipped when traversing the graph as a hierarchy.
+ * These objects will have to be re-attached to some parent object in order to
+ * fit into the hierarchy. */
ExportGraph loose_objects_graph = export_graph_;
for (const ExportGraph::value_type &map_iter : export_graph_) {
for (const HierarchyContext *child : map_iter.second) {
- // An object that is marked as a child of another object is not considered 'loose'.
+ /* An object that is marked as a child of another object is not considered 'loose'. */
ObjectIdentifier child_oid = ObjectIdentifier::for_hierarchy_context(child);
loose_objects_graph.erase(child_oid);
}
}
- // The root of the hierarchy is always found, so it's never considered 'loose'.
+ /* The root of the hierarchy is always found, so it's never considered 'loose'. */
loose_objects_graph.erase(ObjectIdentifier::for_graph_root());
- // Iterate over the loose objects and connect them to their export parent.
+ /* Iterate over the loose objects and connect them to their export parent. */
for (const ExportGraph::value_type &map_iter : loose_objects_graph) {
const ObjectIdentifier &graph_key = map_iter.first;
Object *object = graph_key.object;
while (true) {
- // Loose objects will all be real objects, as duplicated objects always have
- // their duplicator or other exported duplicated object as ancestor.
+ /* Loose objects will all be real objects, as duplicated objects always have
+ * their duplicator or other exported duplicated object as ancestor. */
ExportGraph::iterator found_parent_iter = export_graph_.find(
ObjectIdentifier::for_real_object(object->parent));
@@ -358,8 +358,8 @@ void AbstractHierarchyIterator::connect_loose_objects()
if (found_parent_iter != export_graph_.end()) {
break;
}
- // 'object->parent' will never be nullptr here, as the export graph contains the
- // root as nullptr and thus will cause a break above.
+ /* 'object->parent' will never be nullptr here, as the export graph contains the
+ * root as nullptr and thus will cause a break above. */
BLI_assert(object->parent != nullptr);
object = object->parent;
@@ -383,7 +383,7 @@ static bool remove_weak_subtrees(const HierarchyContext *context,
all_is_weak &= child_tree_is_weak;
if (child_tree_is_weak) {
- // This subtree is all weak, so we can remove it from the current object's children.
+ /* This subtree is all weak, so we can remove it from the current object's children. */
clean_graph[map_key].erase(child_context);
delete child_context;
}
@@ -391,7 +391,7 @@ static bool remove_weak_subtrees(const HierarchyContext *context,
}
if (all_is_weak) {
- // This node and all its children are weak, so it can be removed from the export graph.
+ /* This node and all its children are weak, so it can be removed from the export graph. */
clean_graph.erase(map_key);
}
@@ -400,7 +400,7 @@ static bool remove_weak_subtrees(const HierarchyContext *context,
void AbstractHierarchyIterator::export_graph_prune()
{
- // Take a copy of the map so that we can modify while recursing.
+ /* Take a copy of the map so that we can modify while recursing. */
ExportGraph unpruned_export_graph = export_graph_;
remove_weak_subtrees(HierarchyContext::root(), export_graph_, unpruned_export_graph);
}
@@ -435,14 +435,14 @@ void AbstractHierarchyIterator::visit_object(Object *object,
ExportGraph::key_type graph_index = determine_graph_index_object(context);
context_update_for_graph_index(context, graph_index);
- // Store this HierarchyContext as child of the export parent.
+ /* Store this HierarchyContext as child of the export parent. */
export_graph_[graph_index].insert(context);
- // Create an empty entry for this object to indicate it is part of the export. This will be used
- // by connect_loose_objects(). Having such an "indicator" will make it possible to do an O(log n)
- // check on whether an object is part of the export, rather than having to check all objects in
- // the map. Note that it's not possible to simply search for (object->parent, nullptr), as the
- // object's parent in Blender may not be the same as its export-parent.
+ /* Create an empty entry for this object to indicate it is part of the export. This will be used
+ * by connect_loose_objects(). Having such an "indicator" will make it possible to do an O(log n)
+ * check on whether an object is part of the export, rather than having to check all objects in
+ * the map. Note that it's not possible to simply search for (object->parent, nullptr), as the
+ * object's parent in Blender may not be the same as its export-parent. */
ExportGraph::key_type object_key = ObjectIdentifier::for_real_object(object);
if (export_graph_.find(object_key) == export_graph_.end()) {
export_graph_[object_key] = ExportChildren();
@@ -471,7 +471,7 @@ void AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object,
copy_m4_m4(context->matrix_world, dupli_object->mat);
- // Construct export name for the dupli-instance.
+ /* Construct export name for the dupli-instance. */
std::stringstream export_name_stream;
export_name_stream << get_object_name(context->object) << "-"
<< context->persistent_id.as_object_name_suffix();
@@ -500,7 +500,7 @@ AbstractHierarchyIterator::ExportGraph::key_type AbstractHierarchyIterator::
void AbstractHierarchyIterator::context_update_for_graph_index(
HierarchyContext *context, const ExportGraph::key_type &graph_index) const
{
- // Update the HierarchyContext so that it is consistent with the graph index.
+ /* Update the HierarchyContext so that it is consistent with the graph index. */
context->export_parent = graph_index.object;
if (context->export_parent != context->object->parent) {
/* The parent object in Blender is NOT used as the export parent. This means
@@ -550,7 +550,7 @@ void AbstractHierarchyIterator::determine_duplication_references(
const ExportPathMap::const_iterator &it = duplisource_export_path_.find(source_id);
if (it == duplisource_export_path_.end()) {
- // The original was not found, so mark this instance as "the original".
+ /* The original was not found, so mark this instance as "the original". */
context->mark_as_not_instanced();
duplisource_export_path_[source_id] = context->export_path;
}
@@ -563,7 +563,7 @@ void AbstractHierarchyIterator::determine_duplication_references(
const ExportPathMap::const_iterator &it = duplisource_export_path_.find(source_data_id);
if (it == duplisource_export_path_.end()) {
- // The original was not found, so mark this instance as "original".
+ /* The original was not found, so mark this instance as "original". */
std::string data_path = get_object_data_path(context);
context->mark_as_not_instanced();
duplisource_export_path_[source_id] = context->export_path;
@@ -588,19 +588,19 @@ void AbstractHierarchyIterator::make_writers(const HierarchyContext *parent_cont
}
for (HierarchyContext *context : graph_children(parent_context)) {
- // Update the context so that it is correct for this parent-child relation.
+ /* Update the context so that it is correct for this parent-child relation. */
copy_m4_m4(context->parent_matrix_inv_world, parent_matrix_inv_world);
if (parent_context != nullptr) {
context->higher_up_export_path = parent_context->export_path;
}
- // Get or create the transform writer.
+ /* Get or create the transform writer. */
EnsuredWriter transform_writer = ensure_writer(
context, &AbstractHierarchyIterator::create_transform_writer);
if (!transform_writer) {
- // Unable to export, so there is nothing to attach any children to; just abort this entire
- // branch of the export hierarchy.
+ /* Unable to export, so there is nothing to attach any children to; just abort this entire
+ * branch of the export hierarchy. */
return;
}
@@ -617,11 +617,12 @@ void AbstractHierarchyIterator::make_writers(const HierarchyContext *parent_cont
make_writer_object_data(context);
}
- // Recurse into this object's children.
+ /* Recurse into this object's children. */
make_writers(context);
}
- // TODO(Sybren): iterate over all unused writers and call unused_during_iteration() or something.
+ /* TODO(Sybren): iterate over all unused writers and call unused_during_iteration() or something.
+ */
}
HierarchyContext AbstractHierarchyIterator::context_for_object_data(
@@ -750,7 +751,7 @@ bool AbstractHierarchyIterator::mark_as_weak_export(const Object * /*object*/) c
}
bool AbstractHierarchyIterator::should_visit_dupli_object(const DupliObject *dupli_object) const
{
- // Removing dupli_object->no_draw hides things like custom bone shapes.
+ /* Removing dupli_object->no_draw hides things like custom bone shapes. */
return !dupli_object->no_draw;
}
diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
index 27196994a3c..6e4509afd30 100644
--- a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
+++ b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
@@ -145,7 +145,7 @@ TEST_F(AbstractHierarchyIteratorTest, ExportHierarchyTest)
iterator->iterate_and_write();
- // Mapping from object name to set of export paths.
+ /* Mapping from object name to set of export paths. */
used_writers expected_transforms = {
{"OBCamera", {"/Camera"}},
{"OBDupli1", {"/Dupli1"}},
@@ -196,12 +196,12 @@ TEST_F(AbstractHierarchyIteratorTest, ExportHierarchyTest)
EXPECT_EQ(expected_data, iterator->data_writers);
- // The scene has no hair or particle systems.
+ /* The scene has no hair or particle systems. */
EXPECT_EQ(0, iterator->hair_writers.size());
EXPECT_EQ(0, iterator->particle_writers.size());
- // On the second iteration, everything should be written as well.
- // This tests the default value of iterator->export_subset_.
+ /* On the second iteration, everything should be written as well.
+ * This tests the default value of iterator->export_subset_. */
iterator->transform_writers.clear();
iterator->data_writers.clear();
iterator->iterate_and_write();
@@ -211,8 +211,8 @@ TEST_F(AbstractHierarchyIteratorTest, ExportHierarchyTest)
TEST_F(AbstractHierarchyIteratorTest, ExportSubsetTest)
{
- // The scene has no hair or particle systems, and this is already covered by ExportHierarchyTest,
- // so not included here. Update this test when hair & particle systems are included.
+ /* The scene has no hair or particle systems, and this is already covered by ExportHierarchyTest,
+ * so not included here. Update this test when hair & particle systems are included. */
/* Load the test blend file. */
if (!blendfile_load("usd/usd_hierarchy_export_test.blend")) {
@@ -221,7 +221,7 @@ TEST_F(AbstractHierarchyIteratorTest, ExportSubsetTest)
depsgraph_create(DAG_EVAL_RENDER);
iterator_create();
- // Mapping from object name to set of export paths.
+ /* Mapping from object name to set of export paths. */
used_writers expected_transforms = {
{"OBCamera", {"/Camera"}},
{"OBDupli1", {"/Dupli1"}},
@@ -269,8 +269,8 @@ TEST_F(AbstractHierarchyIteratorTest, ExportSubsetTest)
{"OBParentOfDupli2", {"/ParentOfDupli2/Icosphere"}},
};
- // Even when only asking an export of transforms, on the first frame everything should be
- // exported.
+ /* Even when only asking an export of transforms, on the first frame everything should be
+ * exported. */
{
ExportSubset export_subset = {0};
export_subset.transforms = true;
@@ -281,20 +281,20 @@ TEST_F(AbstractHierarchyIteratorTest, ExportSubsetTest)
EXPECT_EQ(expected_transforms, iterator->transform_writers);
EXPECT_EQ(expected_data, iterator->data_writers);
- // Clear data to prepare for the next iteration.
+ /* Clear data to prepare for the next iteration. */
iterator->transform_writers.clear();
iterator->data_writers.clear();
- // Second iteration, should only write transforms now.
+ /* Second iteration, should only write transforms now. */
iterator->iterate_and_write();
EXPECT_EQ(expected_transforms, iterator->transform_writers);
EXPECT_EQ(0, iterator->data_writers.size());
- // Clear data to prepare for the next iteration.
+ /* Clear data to prepare for the next iteration. */
iterator->transform_writers.clear();
iterator->data_writers.clear();
- // Third iteration, should only write data now.
+ /* Third iteration, should only write data now. */
{
ExportSubset export_subset = {0};
export_subset.transforms = false;
@@ -305,11 +305,11 @@ TEST_F(AbstractHierarchyIteratorTest, ExportSubsetTest)
EXPECT_EQ(0, iterator->transform_writers.size());
EXPECT_EQ(expected_data, iterator->data_writers);
- // Clear data to prepare for the next iteration.
+ /* Clear data to prepare for the next iteration. */
iterator->transform_writers.clear();
iterator->data_writers.clear();
- // Fourth iteration, should export everything now.
+ /* Fourth iteration, should export everything now. */
{
ExportSubset export_subset = {0};
export_subset.transforms = true;
@@ -343,7 +343,7 @@ TEST_F(AbstractHierarchyIteratorInvisibleTest, ExportInvisibleTest)
iterator->iterate_and_write();
- // Mapping from object name to set of export paths.
+ /* Mapping from object name to set of export paths. */
used_writers expected_transforms = {{"OBInvisibleAnimatedCube", {"/InvisibleAnimatedCube"}},
{"OBInvisibleCube", {"/InvisibleCube"}},
{"OBVisibleCube", {"/VisibleCube"}}};
@@ -355,7 +355,7 @@ TEST_F(AbstractHierarchyIteratorInvisibleTest, ExportInvisibleTest)
EXPECT_EQ(expected_data, iterator->data_writers);
- // The scene has no hair or particle systems.
+ /* The scene has no hair or particle systems. */
EXPECT_EQ(0, iterator->hair_writers.size());
EXPECT_EQ(0, iterator->particle_writers.size());
}
diff --git a/source/blender/io/common/intern/object_identifier_test.cc b/source/blender/io/common/intern/object_identifier_test.cc
index 2b565876f22..30e1e43d076 100644
--- a/source/blender/io/common/intern/object_identifier_test.cc
+++ b/source/blender/io/common/intern/object_identifier_test.cc
@@ -175,7 +175,7 @@ TEST_F(ObjectIdentifierOrderTest, map_copy_and_update)
AbstractHierarchyIterator::ExportGraph graph_copy = graph;
EXPECT_EQ(5, graph_copy.size());
- // Updating a value in a copy should not update the original.
+ /* Updating a value in a copy should not update the original. */
HierarchyContext ctx1;
HierarchyContext ctx2;
ctx1.object = fake_pointer(1);
@@ -184,7 +184,7 @@ TEST_F(ObjectIdentifierOrderTest, map_copy_and_update)
graph_copy[id_root].insert(&ctx1);
EXPECT_EQ(0, graph[id_root].size());
- // Deleting a key in the copy should not update the original.
+ /* Deleting a key in the copy should not update the original. */
graph_copy.erase(id_dupli_c);
EXPECT_EQ(4, graph_copy.size());
EXPECT_EQ(5, graph.size());
diff --git a/source/blender/io/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc
index 4717f27dbd9..7b375689543 100644
--- a/source/blender/io/usd/intern/usd_capi.cc
+++ b/source/blender/io/usd/intern/usd_capi.cc
@@ -88,7 +88,7 @@ static void export_startjob(void *customdata,
WM_set_locked_interface(data->wm, true);
G.is_break = false;
- // Construct the depsgraph for exporting.
+ /* Construct the depsgraph for exporting. */
Scene *scene = DEG_get_input_scene(data->depsgraph);
if (data->params.visible_objects_only) {
DEG_graph_build_from_view_layer(data->depsgraph);
@@ -101,7 +101,7 @@ static void export_startjob(void *customdata,
*progress = 0.0f;
*do_update = true;
- // For restoring the current frame after exporting animation is done.
+ /* For restoring the current frame after exporting animation is done. */
const int orig_frame = CFRA;
pxr::UsdStageRefPtr usd_stage = pxr::UsdStage::CreateNew(data->filename);
@@ -120,7 +120,7 @@ static void export_startjob(void *customdata,
usd_stage->GetRootLayer()->SetDocumentation(std::string("Blender v") +
BKE_blender_version_string());
- // Set up the stage for animated data.
+ /* Set up the stage for animated data. */
if (data->params.export_animation) {
usd_stage->SetTimeCodesPerSecond(FPS);
usd_stage->SetStartTimeCode(scene->r.sfra);
@@ -130,7 +130,7 @@ static void export_startjob(void *customdata,
USDHierarchyIterator iter(data->depsgraph, usd_stage, data->params);
if (data->params.export_animation) {
- // Writing the animated frames is not 100% of the work, but it's our best guess.
+ /* Writing the animated frames is not 100% of the work, but it's our best guess. */
float progress_per_frame = 1.0f / std::max(1, (scene->r.efra - scene->r.sfra + 1));
for (float frame = scene->r.sfra; frame <= scene->r.efra; frame++) {
@@ -138,7 +138,7 @@ static void export_startjob(void *customdata,
break;
}
- // Update the scene for the next frame to render.
+ /* Update the scene for the next frame to render. */
scene->r.cfra = static_cast<int>(frame);
scene->r.subframe = frame - scene->r.cfra;
BKE_scene_graph_update_for_newframe(data->depsgraph);
@@ -151,14 +151,14 @@ static void export_startjob(void *customdata,
}
}
else {
- // If we're not animating, a single iteration over all objects is enough.
+ /* If we're not animating, a single iteration over all objects is enough. */
iter.iterate_and_write();
}
iter.release_writers();
usd_stage->GetRootLayer()->Save();
- // Finish up by going back to the keyframe that was current before we started.
+ /* Finish up by going back to the keyframe that was current before we started. */
if (CFRA != orig_frame) {
CFRA = orig_frame;
BKE_scene_graph_update_for_newframe(data->depsgraph);
diff --git a/source/blender/io/usd/intern/usd_writer_abstract.cc b/source/blender/io/usd/intern/usd_writer_abstract.cc
index 3f5babdee56..17d51c9b7cc 100644
--- a/source/blender/io/usd/intern/usd_writer_abstract.cc
+++ b/source/blender/io/usd/intern/usd_writer_abstract.cc
@@ -25,7 +25,7 @@
/* TfToken objects are not cheap to construct, so we do it once. */
namespace usdtokens {
-// Materials
+/* Materials */
static const pxr::TfToken diffuse_color("diffuseColor", pxr::TfToken::Immortal);
static const pxr::TfToken metallic("metallic", pxr::TfToken::Immortal);
static const pxr::TfToken preview_shader("previewShader", pxr::TfToken::Immortal);
@@ -58,8 +58,8 @@ pxr::UsdTimeCode USDAbstractWriter::get_export_time_code() const
if (is_animated_) {
return usd_export_context_.hierarchy_iterator->get_export_time_code();
}
- // By using the default timecode USD won't even write a single `timeSample` for non-animated
- // data. Instead, it writes it as non-timesampled.
+ /* By using the default timecode USD won't even write a single `timeSample` for non-animated
+ * data. Instead, it writes it as non-timesampled. */
static pxr::UsdTimeCode default_timecode = pxr::UsdTimeCode::Default();
return default_timecode;
}
@@ -90,7 +90,7 @@ pxr::UsdShadeMaterial USDAbstractWriter::ensure_usd_material(Material *material)
static pxr::SdfPath material_library_path("/_materials");
pxr::UsdStageRefPtr stage = usd_export_context_.stage;
- // Construct the material.
+ /* Construct the material. */
pxr::TfToken material_name(usd_export_context_.hierarchy_iterator->get_id_name(&material->id));
pxr::SdfPath usd_path = material_library_path.AppendChild(material_name);
pxr::UsdShadeMaterial usd_material = pxr::UsdShadeMaterial::Get(stage, usd_path);
@@ -99,7 +99,7 @@ pxr::UsdShadeMaterial USDAbstractWriter::ensure_usd_material(Material *material)
}
usd_material = pxr::UsdShadeMaterial::Define(stage, usd_path);
- // Construct the shader.
+ /* Construct the shader. */
pxr::SdfPath shader_path = usd_path.AppendChild(usdtokens::preview_shader);
pxr::UsdShadeShader shader = pxr::UsdShadeShader::Define(stage, shader_path);
shader.CreateIdAttr(pxr::VtValue(usdtokens::preview_surface));
@@ -108,7 +108,7 @@ pxr::UsdShadeMaterial USDAbstractWriter::ensure_usd_material(Material *material)
shader.CreateInput(usdtokens::roughness, pxr::SdfValueTypeNames->Float).Set(material->roughness);
shader.CreateInput(usdtokens::metallic, pxr::SdfValueTypeNames->Float).Set(material->metallic);
- // Connect the shader and the material together.
+ /* Connect the shader and the material together. */
usd_material.CreateSurfaceOutput().ConnectToSource(shader, usdtokens::surface);
return usd_material;
diff --git a/source/blender/io/usd/intern/usd_writer_camera.cc b/source/blender/io/usd/intern/usd_writer_camera.cc
index f21a0444888..677be9a7fc4 100644
--- a/source/blender/io/usd/intern/usd_writer_camera.cc
+++ b/source/blender/io/usd/intern/usd_writer_camera.cc
@@ -96,7 +96,7 @@ void USDCameraWriter::do_write(HierarchyContext &context)
usd_camera.CreateClippingRangeAttr().Set(
pxr::VtValue(pxr::GfVec2f(camera->clip_start, camera->clip_end)), timecode);
- // Write DoF-related attributes.
+ /* Write DoF-related attributes. */
if (camera->dof.flag & CAM_DOF_ENABLED) {
usd_camera.CreateFStopAttr().Set(camera->dof.aperture_fstop, timecode);
diff --git a/source/blender/io/usd/intern/usd_writer_hair.cc b/source/blender/io/usd/intern/usd_writer_hair.cc
index df09aa2f187..5de8f3cefef 100644
--- a/source/blender/io/usd/intern/usd_writer_hair.cc
+++ b/source/blender/io/usd/intern/usd_writer_hair.cc
@@ -44,7 +44,7 @@ void USDHairWriter::do_write(HierarchyContext &context)
pxr::UsdGeomBasisCurves curves = pxr::UsdGeomBasisCurves::Define(usd_export_context_.stage,
usd_export_context_.usd_path);
- // TODO(Sybren): deal with (psys->part->flag & PART_HAIR_BSPLINE)
+ /* TODO(Sybren): deal with (psys->part->flag & PART_HAIR_BSPLINE) */
curves.CreateBasisAttr(pxr::VtValue(pxr::UsdGeomTokens->bspline));
curves.CreateTypeAttr(pxr::VtValue(pxr::UsdGeomTokens->cubic));
diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc
index 3f9cb78ea3b..17c41e0edc1 100644
--- a/source/blender/io/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/io/usd/intern/usd_writer_mesh.cc
@@ -180,8 +180,8 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext &context, Mesh *mesh)
true);
if (!attr_points.HasValue()) {
- // Provide the initial value as default. This makes USD write the value as constant if they
- // don't change over time.
+ /* Provide the initial value as default. This makes USD write the value as constant if they
+ * don't change over time. */
attr_points.Set(usd_mesh_data.points, defaultTime);
attr_face_vertex_counts.Set(usd_mesh_data.face_vertex_counts, defaultTime);
attr_face_vertex_indices.Set(usd_mesh_data.face_indices, defaultTime);
@@ -221,7 +221,7 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext &context, Mesh *mesh)
}
write_surface_velocity(context.object, mesh, usd_mesh);
- // TODO(Sybren): figure out what happens when the face groups change.
+ /* TODO(Sybren): figure out what happens when the face groups change. */
if (frame_has_been_written_) {
return;
}
@@ -342,7 +342,7 @@ void USDGenericMeshWriter::assign_materials(const HierarchyContext &context,
return;
}
- // Define a geometry subset per material.
+ /* Define a geometry subset per material. */
for (const MaterialFaceGroups::value_type &face_group : usd_face_groups) {
short material_number = face_group.first;
const pxr::VtIntArray &face_indices = face_group.second;
diff --git a/source/blender/io/usd/intern/usd_writer_transform.cc b/source/blender/io/usd/intern/usd_writer_transform.cc
index 632a6dd0f3f..136b5c477a2 100644
--- a/source/blender/io/usd/intern/usd_writer_transform.cc
+++ b/source/blender/io/usd/intern/usd_writer_transform.cc
@@ -36,10 +36,10 @@ USDTransformWriter::USDTransformWriter(const USDExporterContext &ctx) : USDAbstr
void USDTransformWriter::do_write(HierarchyContext &context)
{
- float parent_relative_matrix[4][4]; // The object matrix relative to the parent.
+ float parent_relative_matrix[4][4]; /* The object matrix relative to the parent. */
mul_m4_m4m4(parent_relative_matrix, context.parent_matrix_inv_world, context.matrix_world);
- // Write the transform relative to the parent.
+ /* Write the transform relative to the parent. */
pxr::UsdGeomXform xform = pxr::UsdGeomXform::Define(usd_export_context_.stage,
usd_export_context_.usd_path);
if (!xformOp_) {
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 6e590001aff..ac6160b28e4 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -697,7 +697,7 @@ typedef enum eAction_Flags {
typedef struct bDopeSheet {
/** Currently ID_SCE (for Dopesheet), and ID_SC (for Grease Pencil). */
ID *source;
- /** Cache for channels (only initialized when pinned). */ // XXX not used!
+ /** Cache for channels (only initialized when pinned). */ /* XXX not used! */
ListBase chanbase;
/** Object group for option to only include objects that belong to this Collection. */
@@ -796,6 +796,8 @@ typedef enum eDopeSheet_Flag {
ADS_FLAG_FUZZY_NAMES = (1 << 2),
/** do not sort datablocks (mostly objects) by name (NOTE: potentially expensive operation) */
ADS_FLAG_NO_DB_SORT = (1 << 3),
+ /** Invert the search filter */
+ ADS_FLAG_INVERT_FILTER = (1 << 4),
} eDopeSheet_Flag;
typedef struct SpaceAction_Runtime {
@@ -847,7 +849,7 @@ typedef enum eSAction_Flag {
/* draw time in seconds instead of time in frames */
SACTION_DRAWTIME = (1 << 2),
/* don't filter action channels according to visibility */
- // SACTION_NOHIDE = (1 << 3), // XXX deprecated... old animation system
+ // SACTION_NOHIDE = (1 << 3), /* XXX deprecated... old animation systems. */
/* don't kill overlapping keyframes after transform */
SACTION_NOTRANSKEYCULL = (1 << 4),
/* don't include keyframes that are out of view */
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 0d9158c4377..0c58e0674d2 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -510,7 +510,7 @@ typedef struct ChannelDriver {
/** Result of previous evaluation. */
float curval;
- // XXX to be implemented... this is like the constraint influence setting
+ /* XXX to be implemented... this is like the constraint influence setting. */
/** Influence of driver on result. */
float influence;
@@ -541,7 +541,7 @@ typedef enum eDriver_Flags {
DRIVER_FLAG_INVALID = (1 << 0),
DRIVER_FLAG_DEPRECATED = (1 << 1),
/** Driver does replace value, but overrides (for layering of animation over driver) */
- // TODO: this needs to be implemented at some stage or left out...
+ /* TODO: this needs to be implemented at some stage or left out... */
// DRIVER_FLAG_LAYERING = (1 << 2),
/** Use when the expression needs to be recompiled. */
DRIVER_FLAG_RECOMPILE = (1 << 3),
@@ -597,6 +597,9 @@ typedef struct FCurve {
/**
* Index of active keyframe in #bezt for numerical editing in the interface. A value of
* #FCURVE_ACTIVE_KEYFRAME_NONE indicates that the FCurve has no active keyframe.
+ *
+ * Do not access directly, use #BKE_fcurve_active_keyframe_index() and
+ * #BKE_fcurve_active_keyframe_set() instead.
*/
int active_keyframe_index;
@@ -711,7 +714,7 @@ typedef struct NlaStrip {
/** Action that is referenced by this strip (strip is 'user' of the action). */
bAction *act;
- /** F-Curves for controlling this strip's influence and timing */ // TODO: move o.ut?
+ /** F-Curves for controlling this strip's influence and timing */ /* TODO: move out? */
ListBase fcurves;
/** F-Curve modifiers to be applied to the entire strip's referenced F-Curves. */
ListBase modifiers;
@@ -786,8 +789,8 @@ typedef enum eNlaStrip_Flag {
NLASTRIP_FLAG_ACTIVE = (1 << 0),
/* NLA strip is selected for editing */
NLASTRIP_FLAG_SELECT = (1 << 1),
- // NLASTRIP_FLAG_SELECT_L = (1 << 2), // left handle selected
- // NLASTRIP_FLAG_SELECT_R = (1 << 3), // right handle selected
+ // NLASTRIP_FLAG_SELECT_L = (1 << 2), /* left handle selected. */
+ // NLASTRIP_FLAG_SELECT_R = (1 << 3), /* right handle selected. */
/** NLA strip uses the same action that the action being tweaked uses
* (not set for the tweaking one though). */
diff --git a/source/blender/makesdna/DNA_armature_defaults.h b/source/blender/makesdna/DNA_armature_defaults.h
new file mode 100644
index 00000000000..c8a54aaee3c
--- /dev/null
+++ b/source/blender/makesdna/DNA_armature_defaults.h
@@ -0,0 +1,40 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#pragma once
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name bArmature Struct
+ * \{ */
+
+#define _DNA_DEFAULT_bArmature \
+ { \
+ .deformflag = ARM_DEF_VGROUP | ARM_DEF_ENVELOPE, \
+ .flag = ARM_COL_CUSTOM, /* custom bone-group colors */ \
+ .layer = 1, \
+ .drawtype = ARM_OCTA, \
+ }
+
+/** \} */
+
+/* clang-format on */
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 07186425c3f..8437d782e98 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -27,10 +27,6 @@
#include "DNA_curve_types.h"
#include "DNA_texture_types.h" /* for MTex */
-//#ifndef MAX_MTEX // XXX Not used?
-//#define MAX_MTEX 18
-//#endif
-
struct CurveMapping;
struct Image;
struct MTex;
@@ -572,10 +568,12 @@ typedef struct Brush {
char gpencil_sculpt_tool;
/** Active grease pencil weight tool. */
char gpencil_weight_tool;
- char _pad1[2];
+ char _pad1[6];
float autosmooth_factor;
+ float tilt_strength_factor;
+
float topology_rake_factor;
float crease_pinch_factor;
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index a4c0d9a4c40..3d11b3cd7a3 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -105,8 +105,8 @@ typedef struct ClothSimSettings {
/* User set volume. This is the volume the mesh wants to expand to (the equilibrium volume). */
float target_volume;
/* The scaling factor to apply to the actual pressure.
- pressure=( (current_volume/target_volume) - 1 + uniform_pressure_force) *
- pressure_factor */
+ * pressure=( (current_volume/target_volume) - 1 + uniform_pressure_force) *
+ * pressure_factor */
float pressure_factor;
/* Density of the fluid inside or outside the object for use in the hydrostatic pressure
* gradient. */
diff --git a/source/blender/makesdna/DNA_collection_defaults.h b/source/blender/makesdna/DNA_collection_defaults.h
new file mode 100644
index 00000000000..079c24b04db
--- /dev/null
+++ b/source/blender/makesdna/DNA_collection_defaults.h
@@ -0,0 +1,37 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#pragma once
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name Collection Struct
+ * \{ */
+
+#define _DNA_DEFAULT_Collection \
+ { \
+ .color_tag = COLLECTION_COLOR_NONE, \
+ }
+
+/** \} */
+
+/* clang-format on */
diff --git a/source/blender/makesdna/DNA_fluid_defaults.h b/source/blender/makesdna/DNA_fluid_defaults.h
new file mode 100644
index 00000000000..14ea874a674
--- /dev/null
+++ b/source/blender/makesdna/DNA_fluid_defaults.h
@@ -0,0 +1,266 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#pragma once
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name Fluid Domain Settings Struct
+ * \{ */
+
+#define _DNA_DEFAULT_FluidDomainSettings \
+ { \
+ .fmd = NULL, \
+ .fluid = NULL, \
+ .fluid_old = NULL, \
+ .fluid_mutex = NULL, \
+ .fluid_group = NULL, \
+ .force_group = NULL, \
+ .effector_group = NULL, \
+ .tex_density = NULL, \
+ .tex_color = NULL, \
+ .tex_wt = NULL, \
+ .tex_shadow = NULL, \
+ .tex_flame = NULL, \
+ .tex_flame_coba = NULL, \
+ .tex_coba = NULL, \
+ .tex_field = NULL, \
+ .tex_velocity_x = NULL, \
+ .tex_velocity_y = NULL, \
+ .tex_velocity_z = NULL, \
+ .tex_flags = NULL, \
+ .tex_range_field = NULL, \
+ .guide_parent = NULL, \
+ .mesh_velocities = NULL, \
+ .effector_weights = NULL, /* #BKE_effector_add_weights. */ \
+ .p0 = {0.0f, 0.0f, 0.0f}, \
+ .p1 = {0.0f, 0.0f, 0.0f}, \
+ .dp0 = {0.0f, 0.0f, 0.0f}, \
+ .cell_size = {0.0f, 0.0f, 0.0f}, \
+ .global_size = {0.0f, 0.0f, 0.0f}, \
+ .prev_loc = {0.0f, 0.0f, 0.0f}, \
+ .shift = {0, 0, 0}, \
+ .shift_f = {0.0f, 0.0f, 0.0f}, \
+ .obj_shift_f = {0.0f, 0.0f, 0.0f}, \
+ .imat = _DNA_DEFAULT_UNIT_M4, \
+ .obmat = _DNA_DEFAULT_UNIT_M4, \
+ .fluidmat = _DNA_DEFAULT_UNIT_M4, \
+ .fluidmat_wt = _DNA_DEFAULT_UNIT_M4, \
+ .base_res = {0, 0, 0}, \
+ .res_min = {0, 0, 0}, \
+ .res_max = {0, 0, 0}, \
+ .res = {0, 0, 0}, \
+ .total_cells = 0, \
+ .dx = 0, \
+ .scale = 0.0f, \
+ .boundary_width = 1, \
+ .gravity_final = {0.0f, 0.0f, 0.0f}, \
+ .adapt_margin = 4, \
+ .adapt_res = 0, \
+ .adapt_threshold = 0.02f, \
+ .maxres = 32, \
+ .solver_res = 3, \
+ .border_collisions = 0, \
+ .flags = FLUID_DOMAIN_USE_DISSOLVE_LOG | FLUID_DOMAIN_USE_ADAPTIVE_TIME, \
+ .gravity = {0.0f, 0.0f, -9.81f}, \
+ .active_fields = 0, \
+ .type = FLUID_DOMAIN_TYPE_GAS, \
+ .alpha = 1.0f, \
+ .beta = 1.0f, \
+ .diss_speed = 5, \
+ .vorticity = 0.0f, \
+ .active_color = {0.0f, 0.0f, 0.0f}, \
+ .highres_sampling = SM_HRES_FULLSAMPLE, \
+ .burning_rate = 0.75f, \
+ .flame_smoke = 1.0f, \
+ .flame_vorticity = 0.5f, \
+ .flame_ignition = 1.5f, \
+ .flame_max_temp = 3.0f, \
+ .flame_smoke_color = {0.7f, 0.7f, 0.7f}, \
+ .noise_strength = 1.0f, \
+ .noise_pos_scale = 2.0f, \
+ .noise_time_anim = 0.1f, \
+ .res_noise = {0, 0, 0}, \
+ .noise_scale = 2, \
+ .noise_type = FLUID_NOISE_TYPE_WAVELET, \
+ .particle_randomness = 0.1f, \
+ .particle_number = 2, \
+ .particle_minimum = 8, \
+ .particle_maximum = 16, \
+ .particle_radius = 1.0f, \
+ .particle_band_width = 3.0f, \
+ .fractions_threshold = 0.05f, \
+ .flip_ratio = 0.97f, \
+ .sys_particle_maximum = 0, \
+ .simulation_method = FLUID_DOMAIN_METHOD_FLIP, \
+ .surface_tension = 0.0f, \
+ .viscosity_base = 1.0f, \
+ .viscosity_exponent = 6.0f, \
+ .mesh_concave_upper = 3.5f, \
+ .mesh_concave_lower = 0.4f, \
+ .mesh_particle_radius = 2.0f, \
+ .mesh_smoothen_pos = 1, \
+ .mesh_smoothen_neg = 1, \
+ .mesh_scale = 2, \
+ .totvert = 0, \
+ .mesh_generator = FLUID_DOMAIN_MESH_IMPROVED, \
+ .particle_type = 0, \
+ .particle_scale = 1, \
+ .sndparticle_tau_min_wc = 2.0f, \
+ .sndparticle_tau_max_wc = 8.0f, \
+ .sndparticle_tau_min_ta = 5.0f, \
+ .sndparticle_tau_max_ta = 20.0f, \
+ .sndparticle_tau_min_k = 1.0f, \
+ .sndparticle_tau_max_k = 5.0f, \
+ .sndparticle_k_wc = 200, \
+ .sndparticle_k_ta = 40, \
+ .sndparticle_k_b = 0.5f, \
+ .sndparticle_k_d = 0.6f, \
+ .sndparticle_l_min = 10.0f, \
+ .sndparticle_l_max = 25.0f, \
+ .sndparticle_potential_radius = 2, \
+ .sndparticle_update_radius = 2, \
+ .sndparticle_boundary = SNDPARTICLE_BOUNDARY_DELETE, \
+ .sndparticle_combined_export = SNDPARTICLE_COMBINED_EXPORT_OFF, \
+ .guide_alpha = 2.0f, \
+ .guide_beta = 5, \
+ .guide_vel_factor = 2.0f, \
+ .guide_res = {0, 0, 0}, \
+ .guide_source = FLUID_DOMAIN_GUIDE_SRC_DOMAIN, \
+ .cache_frame_start = 1, \
+ .cache_frame_end = 250, \
+ .cache_frame_pause_data = 0, \
+ .cache_frame_pause_noise = 0, \
+ .cache_frame_pause_mesh = 0, \
+ .cache_frame_pause_particles = 0, \
+ .cache_frame_pause_guide = 0, \
+ .cache_frame_offset = 0, \
+ .cache_flag = 0, \
+ .cache_mesh_format = FLUID_DOMAIN_FILE_BIN_OBJECT, \
+ .cache_data_format = FLUID_DOMAIN_FILE_OPENVDB, \
+ .cache_particle_format = FLUID_DOMAIN_FILE_OPENVDB, \
+ .cache_noise_format = FLUID_DOMAIN_FILE_OPENVDB, \
+ .cache_directory = "", \
+ .error = "", \
+ .cache_type = FLUID_DOMAIN_CACHE_REPLAY, \
+ .cache_id = "", \
+ .dt = 0.0f, \
+ .time_total = 0.0f, \
+ .time_per_frame = 0.0f, \
+ .frame_length = 0.0f, \
+ .time_scale = 1.0f, \
+ .cfl_condition = 4.0f, \
+ .timesteps_minimum = 1, \
+ .timesteps_maximum = 4, \
+ .slice_per_voxel = 5.0f, \
+ .slice_depth = 0.5f, \
+ .display_thickness = 1.0f, \
+ .grid_scale = 1.0f, \
+ .coba = NULL, \
+ .vector_scale = 1.0f, \
+ .gridlines_lower_bound = 0.0f, \
+ .gridlines_upper_bound = 1.0f, \
+ .gridlines_range_color = {1.0f, 0.0f, 0.0f, 1.0f}, \
+ .axis_slice_method = AXIS_SLICE_FULL, \
+ .slice_axis = 0, \
+ .show_gridlines = false, \
+ .draw_velocity = false, \
+ .vector_draw_type = VECTOR_DRAW_NEEDLE, \
+ .vector_field = FLUID_DOMAIN_VECTOR_FIELD_VELOCITY, \
+ .vector_scale_with_magnitude = true, \
+ .vector_draw_mac_components = VECTOR_DRAW_MAC_X | VECTOR_DRAW_MAC_Y | VECTOR_DRAW_MAC_Z, \
+ .use_coba = false, \
+ .coba_field = FLUID_DOMAIN_FIELD_DENSITY, \
+ .interp_method = FLUID_DISPLAY_INTERP_LINEAR, \
+ .gridlines_color_field = 0, \
+ .gridlines_cell_filter = FLUID_CELL_TYPE_NONE, \
+ .openvdb_compression = VDB_COMPRESSION_BLOSC, \
+ .clipping = 1e-6f, \
+ .openvdb_data_depth = 0, \
+ .viewsettings = 0, \
+ .point_cache = {NULL, NULL}, /* Use #BKE_ptcache_add. */ \
+ .ptcaches = {{NULL}}, \
+ .cache_comp = SM_CACHE_LIGHT, \
+ .cache_high_comp = SM_CACHE_LIGHT, \
+ .cache_file_format = 0, \
+ }
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Fluid Flow Settings Struct
+ * \{ */
+
+#define _DNA_DEFAULT_FluidFlowSettings \
+ { \
+ .fmd = NULL, \
+ .mesh = NULL, \
+ .psys = NULL, \
+ .noise_texture = NULL, \
+ .verts_old = NULL, \
+ .numverts = 0, \
+ .vel_multi = 1.0f, \
+ .vel_normal = 0.0f, \
+ .vel_random = 0.0f, \
+ .vel_coord = {0.0f, 0.0f, 0.0f}, \
+ .density = 1.0f, \
+ .color = {0.7f, 0.7f, 0.7f}, \
+ .fuel_amount = 1.0f, \
+ .temperature = 1.0f, \
+ .volume_density = 0.0f, \
+ .surface_distance = 1.5f, \
+ .particle_size = 1.0f, \
+ .subframes = 0, \
+ .texture_size = 1.0f, \
+ .texture_offset = 0.0f, \
+ .uvlayer_name = "", \
+ .vgroup_density = 0, \
+ .type = FLUID_FLOW_TYPE_SMOKE, \
+ .behavior = FLUID_FLOW_BEHAVIOR_GEOMETRY, \
+ .source = FLUID_FLOW_SOURCE_MESH, \
+ .texture_type = 0, \
+ .flags = FLUID_FLOW_ABSOLUTE | FLUID_FLOW_USE_PART_SIZE | FLUID_FLOW_USE_INFLOW, \
+ }
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Fluid Effector Settings Struct
+ * \{ */
+
+#define _DNA_DEFAULT_FluidEffectorSettings \
+ { \
+ .fmd = NULL, \
+ .mesh = NULL, \
+ .verts_old = NULL, \
+ .numverts = 0, \
+ .surface_distance = 0.0f, \
+ .flags = FLUID_EFFECTOR_USE_EFFEC, \
+ .subframes = 0, \
+ .type = FLUID_EFFECTOR_TYPE_COLLISION, \
+ .vel_multi = 1.0f, \
+ .guide_mode = FLUID_EFFECTOR_GUIDE_OVERRIDE, \
+ }
+
+/** \} */
+
+/* clang-format on */
diff --git a/source/blender/makesdna/DNA_fluid_types.h b/source/blender/makesdna/DNA_fluid_types.h
index 8f67cd060e9..afb2a294605 100644
--- a/source/blender/makesdna/DNA_fluid_types.h
+++ b/source/blender/makesdna/DNA_fluid_types.h
@@ -463,6 +463,7 @@ enum {
enum {
VDB_PRECISION_HALF_FLOAT = 0,
VDB_PRECISION_FULL_FLOAT = 1,
+ VDB_PRECISION_MINI_FLOAT = 2,
};
/* Deprecated values (i.e. all defines and enums below this line up until typedefs). */
diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h
index 96766bf16b8..6fcbc53d47b 100644
--- a/source/blender/makesdna/DNA_genfile.h
+++ b/source/blender/makesdna/DNA_genfile.h
@@ -103,7 +103,7 @@ void DNA_reconstruct_info_free(struct DNA_ReconstructInfo *reconstruct_info);
int DNA_struct_find_nr_ex(const struct SDNA *sdna, const char *str, unsigned int *index_last);
int DNA_struct_find_nr(const struct SDNA *sdna, const char *str);
-void DNA_struct_switch_endian(const struct SDNA *oldsdna, int oldSDNAnr, char *data);
+void DNA_struct_switch_endian(const struct SDNA *sdna, int struct_nr, char *data);
const char *DNA_struct_get_compareflags(const struct SDNA *sdna, const struct SDNA *newsdna);
void *DNA_struct_reconstruct(const struct DNA_ReconstructInfo *reconstruct_info,
int old_struct_nr,
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
new file mode 100644
index 00000000000..44239221df4
--- /dev/null
+++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
@@ -0,0 +1,286 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#pragma once
+
+/* Note that some struct members for colormapping and colorbands are not initialized here. */
+
+/* Struct members on own line. */
+/* clang-format off */
+
+#define _DNA_DEFAULT_ArmatureGpencilModifierData \
+ { \
+ .deformflag = ARM_DEF_VGROUP, \
+ .multi = 0, \
+ .object = NULL, \
+ .vert_coords_prev = NULL, \
+ .vgname = "", \
+ }
+
+#define _DNA_DEFAULT_ArrayGpencilModifierData \
+ { \
+ .object = NULL, \
+ .material = NULL, \
+ .count = 2, \
+ .flag = GP_ARRAY_USE_RELATIVE, \
+ .offset = {0.0f, 0.0f, 0.0f}, \
+ .shift = {1.0f, 0.0f, 0.0f}, \
+ .rnd_offset = {0.0f, 0.0f, 0.0f}, \
+ .rnd_rot = {0.0f, 0.0f, 0.0f}, \
+ .rnd_scale = {0.0f, 0.0f, 0.0f}, \
+ .seed = 1, \
+ .pass_index = 0, \
+ .layername = "", \
+ .mat_rpl = 0, \
+ .layer_pass = 0, \
+ }
+
+/* Deliberately set this range to the half the default frame-range
+ * to have an immediate effect to suggest use-cases. */
+#define _DNA_DEFAULT_BuildGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .pass_index = 0, \
+ .layer_pass = 0, \
+ .start_frame = 1, \
+ .end_frame = 125, \
+ .start_delay = 0.0f, \
+ .length = 100.0f, \
+ .flag = 0, \
+ .mode = 0, \
+ .transition = 0, \
+ .time_alignment = 0, \
+ .percentage_fac = 0.0f, \
+ }
+
+#define _DNA_DEFAULT_ColorGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .hsv = {0.5f, 1.0f, 1.0f}, \
+ .modify_color = GP_MODIFY_COLOR_BOTH, \
+ .layer_pass = 0, \
+ .curve_intensity = NULL, \
+ }
+
+#define _DNA_DEFAULT_HookGpencilModifierData \
+ { \
+ .object = NULL, \
+ .material = NULL, \
+ .subtarget = "", \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .layer_pass = 0, \
+ .flag = 0, \
+ .falloff_type = eGPHook_Falloff_Smooth, \
+ .parentinv = _DNA_DEFAULT_UNIT_M4, \
+ .cent = {0.0f, 0.0f, 0.0f}, \
+ .falloff = 0.0f, \
+ .force = 0.5f, \
+ .curfalloff = NULL, \
+ }
+
+#define _DNA_DEFAULT_LatticeGpencilModifierData \
+ { \
+ .object = NULL, \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .strength = 1.0f, \
+ .layer_pass = 0, \
+ .cache_data = NULL, \
+ }
+
+#define _DNA_DEFAULT_MirrorGpencilModifierData \
+ { \
+ .object = NULL, \
+ .material = NULL, \
+ .layername = "", \
+ .pass_index = 0, \
+ .flag = GP_MIRROR_AXIS_X, \
+ .layer_pass = 0, \
+ }
+
+#define _DNA_DEFAULT_MultiplyGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .layer_pass = 0, \
+ .flags = 0, \
+ .duplications = 3, \
+ .distance = 0.1f, \
+ .offset = 0.0f, \
+ .fading_center = 0.5f, \
+ .fading_thickness = 0.5f, \
+ .fading_opacity = 0.5f, \
+ .split_angle = DEG2RADF(1.0f), \
+ }
+
+#define _DNA_DEFAULT_NoiseGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = GP_NOISE_FULL_STROKE | GP_NOISE_USE_RANDOM, \
+ .factor = 0.5f, \
+ .factor_strength = 0.0f, \
+ .factor_thickness = 0.0f, \
+ .factor_uvs = 0.0f, \
+ .noise_scale = 0.0f, \
+ .step = 4, \
+ .layer_pass = 0, \
+ .seed = 1, \
+ .curve_intensity = NULL, \
+ }
+
+#define _DNA_DEFAULT_OffsetGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .loc = {0.0f, 0.0f, 0.0f}, \
+ .rot = {0.0f, 0.0f, 0.0f}, \
+ .scale = {0.0f, 0.0f, 0.0f}, \
+ .layer_pass = 0, \
+ }
+
+#define _DNA_DEFAULT_OpacityGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .factor = 1.0f, \
+ .modify_color = GP_MODIFY_COLOR_BOTH, \
+ .layer_pass = 0, \
+ .hardeness = 1.0f, \
+ .curve_intensity = NULL, \
+ }
+
+#define _DNA_DEFAULT_SimplifyGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .factor = 0.0f, \
+ .mode = 0, \
+ .step = 1, \
+ .layer_pass = 0, \
+ .length = 0.1f, \
+ .distance = 0.1f, \
+ }
+
+#define _DNA_DEFAULT_SmoothGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = GP_SMOOTH_MOD_LOCATION, \
+ .factor = 0.5f, \
+ .step = 1, \
+ .layer_pass = 0, \
+ .curve_intensity = NULL, \
+ }
+
+#define _DNA_DEFAULT_SubdivGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .level = 1, \
+ .layer_pass = 0, \
+ .type = 0, \
+ }
+
+#define _DNA_DEFAULT_TextureGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .uv_offset = 0.0f, \
+ .uv_scale = 1.0f, \
+ .fill_rotation = 0.0f, \
+ .fill_offset = {0.0f, 0.0f}, \
+ .fill_scale = 1.0f, \
+ .layer_pass = 0, \
+ .fit_method = GP_TEX_CONSTANT_LENGTH, \
+ .mode = 0, \
+ }
+
+#define _DNA_DEFAULT_ThickGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .thickness_fac = 1.0f, \
+ .thickness = 30, \
+ .layer_pass = 0, \
+ }
+
+#define _DNA_DEFAULT_TimeGpencilModifierData \
+ { \
+ .layername = "", \
+ .layer_pass = 0, \
+ .flag = GP_TIME_KEEP_LOOP, \
+ .offset = 1, \
+ .frame_scale = 1.0f, \
+ .mode = 0, \
+ .sfra = 1, \
+ .efra = 250, \
+ }
+
+#define _DNA_DEFAULT_TintGpencilModifierData \
+ { \
+ .object = NULL, \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .layer_pass = 0, \
+ .flag = 0, \
+ .mode = GPPAINT_MODE_BOTH, \
+ .factor = 0.5f, \
+ .radius = 1.0f, \
+ .rgb = {1.0f, 1.0f, 1.0f}, \
+ .type = 0, \
+ .curve_intensity = NULL, \
+ .colorband = NULL, \
+ }
+
+/* clang-format off */
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index bf268ae7c2d..7e2ec8b6c65 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -70,7 +70,7 @@ typedef struct GpencilModifierData {
struct GpencilModifierData *next, *prev;
int type, mode;
- int stackindex;
+ char _pad0[4];
short flag;
short ui_expand_flag;
/** MAX_NAME. */
diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h
index 3c2d479bea4..85065ba35d4 100644
--- a/source/blender/makesdna/DNA_layer_types.h
+++ b/source/blender/makesdna/DNA_layer_types.h
@@ -176,7 +176,7 @@ enum {
};
/* Layer Collection->runtime_flag
- Keep it synced with base->flag based on g_base_collection_flags. */
+ * Keep it synced with base->flag based on g_base_collection_flags. */
enum {
LAYER_COLLECTION_HAS_OBJECTS = (1 << 0),
/* LAYER_COLLECTION_VISIBLE_DEPSGRAPH = (1 << 1), */ /* UNUSED */
diff --git a/source/blender/makesdna/DNA_modifier_defaults.h b/source/blender/makesdna/DNA_modifier_defaults.h
index 41db7c914aa..3aca558cdbe 100644
--- a/source/blender/makesdna/DNA_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_modifier_defaults.h
@@ -41,7 +41,7 @@
.offset = {1.0f, 0.0f, 0.0f}, \
.scale = {1.0f, 0.0f, 0.0f}, \
.length = 0.0f, \
- .merge_dist = 0.1f, \
+ .merge_dist = 0.01f, \
.fit_type = MOD_ARR_FIXEDCOUNT, \
.offset_type = MOD_ARR_OFF_RELATIVE, \
.flags = 0, \
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 3a3aa106dc0..7a13b9f4852 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -116,7 +116,7 @@ typedef struct ModifierData {
struct ModifierData *next, *prev;
int type, mode;
- int stackindex;
+ char _pad0[4];
short flag;
/* An "expand" bit for each of the modifier's (sub)panels. */
short ui_expand_flag;
diff --git a/source/blender/makesdna/DNA_movieclip_defaults.h b/source/blender/makesdna/DNA_movieclip_defaults.h
new file mode 100644
index 00000000000..4aa1bd779c2
--- /dev/null
+++ b/source/blender/makesdna/DNA_movieclip_defaults.h
@@ -0,0 +1,50 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#pragma once
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name MovieClip Struct
+ * \{ */
+
+#define _DNA_DEFAULT_MovieClipProxy \
+ { \
+ .build_size_flag = IMB_PROXY_25, \
+ .build_tc_flag = IMB_TC_RECORD_RUN | IMB_TC_FREE_RUN | \
+ IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN | IMB_TC_RECORD_RUN_NO_GAPS, \
+ .quality = 90, \
+ }
+
+
+#define _DNA_DEFAULT_MovieClip \
+ { \
+ .aspx = 1.0f, \
+ .aspy = 1.0f, \
+ .proxy = _DNA_DEFAULT_MovieClipProxy, \
+ .start_frame = 1, \
+ .frame_offset = 0, \
+ }
+
+/** \} */
+
+/* clang-format on */
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 1d76ebdff2c..33856dc2622 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1356,7 +1356,7 @@ enum {
/* subsurface */
enum {
#ifdef DNA_DEPRECATED_ALLOW
- SHD_SUBSURFACE_COMPATIBLE = 0, // Deprecated
+ SHD_SUBSURFACE_COMPATIBLE = 0, /* Deprecated */
#endif
SHD_SUBSURFACE_CUBIC = 1,
SHD_SUBSURFACE_GAUSSIAN = 2,
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 586c704e0f1..112c8210460 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -202,7 +202,7 @@ typedef struct Object {
/** Old animation system, deprecated for 2.5. */
struct Ipo *ipo DNA_DEPRECATED;
/* struct Path *path; */
- struct bAction *action DNA_DEPRECATED; // XXX deprecated... old animation system
+ struct bAction *action DNA_DEPRECATED; /* XXX deprecated... old animation system */
struct bAction *poselib;
/** Pose data, armature objects only. */
struct bPose *pose;
@@ -211,7 +211,7 @@ typedef struct Object {
/** Grease Pencil data. */
struct bGPdata *gpd
- DNA_DEPRECATED; // XXX deprecated... replaced by gpencil object, keep for readfile
+ DNA_DEPRECATED; /* XXX deprecated... replaced by gpencil object, keep for readfile */
/** Settings for visualization of object-transform animation. */
bAnimVizSettings avs;
@@ -219,8 +219,8 @@ typedef struct Object {
bMotionPath *mpath;
void *_pad0;
- ListBase constraintChannels DNA_DEPRECATED; // XXX deprecated... old animation system
- ListBase effect DNA_DEPRECATED; // XXX deprecated... keep for readfile
+ ListBase constraintChannels DNA_DEPRECATED; /* XXX deprecated... old animation system */
+ ListBase effect DNA_DEPRECATED; /* XXX deprecated... keep for readfile */
/** List of bDeformGroup (vertex groups) names and flag only. */
ListBase defbase;
/** List of ModifierData structures. */
@@ -352,8 +352,8 @@ typedef struct Object {
/** Object constraints. */
ListBase constraints;
- ListBase nlastrips DNA_DEPRECATED; // XXX deprecated... old animation system
- ListBase hooks DNA_DEPRECATED; // XXX deprecated... old animation system
+ ListBase nlastrips DNA_DEPRECATED; /* XXX deprecated... old animation system */
+ ListBase hooks DNA_DEPRECATED; /* XXX deprecated... old animation system */
/** Particle systems. */
ListBase particlesystem;
@@ -366,7 +366,7 @@ typedef struct Object {
/** If fluidsim enabled, store additional settings. */
struct FluidsimSettings *fluidsimSettings
- DNA_DEPRECATED; // XXX deprecated... replaced by mantaflow, keep for readfile
+ DNA_DEPRECATED; /* XXX deprecated... replaced by mantaflow, keep for readfile */
ListBase pc_ids;
diff --git a/source/blender/makesdna/DNA_particle_defaults.h b/source/blender/makesdna/DNA_particle_defaults.h
new file mode 100644
index 00000000000..85971b8e9b7
--- /dev/null
+++ b/source/blender/makesdna/DNA_particle_defaults.h
@@ -0,0 +1,113 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#pragma once
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name ParticleSettings Struct
+ * \{ */
+
+#define _DNA_DEFAULT_ParticleSettings \
+ { \
+ .type = PART_EMITTER, \
+ .distr = PART_DISTR_JIT, \
+ .draw_as = PART_DRAW_REND, \
+ .ren_as = PART_DRAW_HALO, \
+ .bb_uv_split = 1, \
+ .flag = PART_EDISTR | PART_TRAND | PART_HIDE_ADVANCED_HAIR, \
+ \
+ .sta = 1.0f, \
+ .end = 200.0f, \
+ .lifetime = 50.0f, \
+ .jitfac = 1.0f, \
+ .totpart = 1000, \
+ .grid_res = 10, \
+ .timetweak = 1.0f, \
+ .courant_target = 0.2f, \
+ \
+ .integrator = PART_INT_MIDPOINT, \
+ .phystype = PART_PHYS_NEWTON, \
+ .hair_step = 5, \
+ .keys_step = 5, \
+ .draw_step = 2, \
+ .ren_step = 3, \
+ .adapt_angle = 5, \
+ .adapt_pix = 3, \
+ .kink_axis = 2, \
+ .kink_amp_clump = 1.0f, \
+ .kink_extra_steps = 4, \
+ .clump_noise_size = 1.0f, \
+ .reactevent = PART_EVENT_DEATH, \
+ .disp = 100, \
+ .from = PART_FROM_FACE, \
+ \
+ .normfac = 1.0f, \
+ \
+ .mass = 1.0f, \
+ .size = 0.05f, \
+ .childsize = 1.0f, \
+ \
+ .rotmode = PART_ROT_VEL, \
+ .avemode = PART_AVE_VELOCITY, \
+ \
+ .child_nbr = 10, \
+ .ren_child_nbr = 100, \
+ .childrad = 0.2f, \
+ .childflat = 0.0f, \
+ .clumppow = 0.0f, \
+ .kink_amp = 0.2f, \
+ .kink_freq = 2.0f, \
+ \
+ .rough1_size = 1.0f, \
+ .rough2_size = 1.0f, \
+ .rough_end_shape = 1.0f, \
+ \
+ .clength = 1.0f, \
+ .clength_thres = 0.0f, \
+ \
+ .draw = 0, \
+ .draw_line = {0.5f,}, \
+ .path_start = 0.0f, \
+ .path_end = 1.0f, \
+ \
+ .bb_size = {1.0f, 1.0f}, \
+ \
+ .keyed_loops = 1, \
+ \
+ .color_vec_max = 1.0f, \
+ .draw_col = PART_DRAW_COL_MAT, \
+ \
+ .omat = 1, \
+ .use_modifier_stack = false, \
+ .draw_size = 0.1f, \
+ \
+ .shape_flag = PART_SHAPE_CLOSE_TIP, \
+ .shape = 0.0f, \
+ .rad_root = 1.0f, \
+ .rad_tip = 0.0f, \
+ .rad_scale = 0.01f, \
+ }
+
+/** \} */
+
+/* clang-format on */
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index b50c2268b3c..bd19498eba7 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -272,7 +272,7 @@ typedef struct ParticleSettings {
struct Collection *instance_collection;
struct ListBase instance_weights;
- struct Collection *force_group DNA_DEPRECATED; // deprecated
+ struct Collection *force_group DNA_DEPRECATED; /* deprecated */
struct Object *instance_object;
struct Object *bb_ob;
/** Old animation system, deprecated for 2.5. */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index df9ad358540..0b63a085ee6 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -182,8 +182,8 @@ typedef struct FFMpegCodecData {
/* Audio */
typedef struct AudioData {
- int mixrate; // 2.5: now in FFMpegCodecData: audio_mixrate
- float main; // 2.5: now in FFMpegCodecData: audio_volume
+ int mixrate; /* 2.5: now in FFMpegCodecData: audio_mixrate */
+ float main; /* 2.5: now in FFMpegCodecData: audio_volume */
float speed_of_sound;
float doppler_factor;
int distance_model;
@@ -622,7 +622,7 @@ typedef struct RenderData {
/** Frames to jump during render/playback. */
int frame_step;
- /** Standalone player stereo settings */ // XXX deprecated since .2.5
+ /** Standalone player stereo settings */ /* XXX deprecated since .2.5 */
short stereomode DNA_DEPRECATED;
/** For the dimensions presets menu. */
@@ -1635,8 +1635,10 @@ typedef struct SceneEEVEE {
int motion_blur_samples DNA_DEPRECATED;
int motion_blur_max;
int motion_blur_steps;
+ int motion_blur_position;
float motion_blur_shutter;
float motion_blur_depth_scale;
+ char _pad0[4];
int shadow_method DNA_DEPRECATED;
int shadow_cube_size;
@@ -2181,7 +2183,7 @@ typedef enum eSculptFlags {
SCULPT_FLAG_UNUSED_7 = (1 << 7), /* cleared */
SCULPT_ONLY_DEFORM = (1 << 8),
- // SCULPT_SHOW_DIFFUSE = (1 << 9), // deprecated
+ // SCULPT_SHOW_DIFFUSE = (1 << 9), /* deprecated */
/* If set, the mesh will be drawn with smooth-shading in
* dynamic-topology mode */
@@ -2218,8 +2220,8 @@ enum {
/* ImagePaintSettings.flag */
#define IMAGEPAINT_DRAWING (1 << 0)
-// #define IMAGEPAINT_DRAW_TOOL (1 << 1) // deprecated
-// #define IMAGEPAINT_DRAW_TOOL_DRAWING (1 << 2) // deprecated
+// #define IMAGEPAINT_DRAW_TOOL (1 << 1) /* deprecated */
+// #define IMAGEPAINT_DRAW_TOOL_DRAWING (1 << 2) /* deprecated */
/* projection painting only */
/* ImagePaintSettings.flag */
@@ -2405,6 +2407,13 @@ enum {
/* SHADOW_METHOD_MAX = 3, */ /* UNUSED */
};
+/* SceneEEVEE->motion_blur_position */
+enum {
+ SCE_EEVEE_MB_CENTER = 0,
+ SCE_EEVEE_MB_START = 1,
+ SCE_EEVEE_MB_END = 2,
+};
+
/* SceneDisplay->render_aa, SceneDisplay->viewport_aa */
enum {
SCE_DISPLAY_AA_OFF = 0,
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 850b906af39..1d89657faf6 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -76,24 +76,24 @@ typedef struct StripColorBalance {
float gain[3];
int flag;
char _pad[4];
- // float exposure;
- // float saturation;
+ /* float exposure; */
+ /* float saturation; */
} StripColorBalance;
typedef struct StripProxy {
- char dir[768]; // custom directory for index and proxy files
- // (defaults to BL_proxy)
+ char dir[768]; /* custom directory for index and proxy files */
+ /* (defaults to BL_proxy) */
- char file[256]; // custom file
- struct anim *anim; // custom proxy anim file
+ char file[256]; /* custom file */
+ struct anim *anim; /* custom proxy anim file */
- short tc; // time code in use
+ short tc; /* time code in use */
- short quality; // proxy build quality
- short build_size_flags; // size flags (see below) of all proxies
- // to build
- short build_tc_flags; // time code flags (see below) of all tc indices
- // to build
+ short quality; /* proxy build quality */
+ short build_size_flags; /* size flags (see below) of all proxies */
+ /* to build */
+ short build_tc_flags; /* time code flags (see below) of all tc indices */
+ /* to build */
short build_flags;
char storage;
char _pad[5];
diff --git a/source/blender/makesdna/DNA_shader_fx_types.h b/source/blender/makesdna/DNA_shader_fx_types.h
index 56caac51b94..5bb78edb280 100644
--- a/source/blender/makesdna/DNA_shader_fx_types.h
+++ b/source/blender/makesdna/DNA_shader_fx_types.h
@@ -61,7 +61,7 @@ typedef struct ShaderFxData {
struct ShaderFxData *next, *prev;
int type, mode;
- int stackindex;
+ char _pad0[4];
short flag;
/* Expansion for shader effect panels and sub-panels. */
short ui_expand_flag;
diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h
index 1d24e655f45..5adadd8f8d1 100644
--- a/source/blender/makesdna/DNA_sound_types.h
+++ b/source/blender/makesdna/DNA_sound_types.h
@@ -64,9 +64,9 @@ typedef struct bSound {
short tags;
char _pad[4];
- /* unused currently
- int type;
- struct bSound *child_sound; */
+ /* Unused currently. */
+ // int type;
+ // struct bSound *child_sound;
/**
* The audaspace handle for cache.
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 9d9b41a1f81..be02e450412 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -56,6 +56,9 @@ struct bNodeTree;
struct wmOperator;
struct wmTimer;
+/* Defined in `buttons_intern.h`. */
+typedef struct SpaceProperties_Runtime SpaceProperties_Runtime;
+
/* TODO 2.8: We don't write the global areas to files currently. Uncomment
* define to enable writing (should become the default in a bit). */
//#define WITH_GLOBAL_AREA_WRITING
@@ -129,13 +132,6 @@ typedef enum eSpaceInfo_RptMask {
/** \name Properties Editor
* \{ */
-#
-#
-typedef struct SpaceProperties_Runtime {
- /** For filtering properties displayed in the space. Length defined as UI_MAX_NAME_STR. */
- char search_string[128];
-} SpaceProperties_Runtime;
-
/* Properties Editor */
typedef struct SpaceProperties {
SpaceLink *next, *prev;
@@ -168,7 +164,7 @@ typedef struct SpaceProperties {
void *texuser;
/* Doesn't necessarily need to be a pointer, but runtime structs are still written to files. */
- SpaceProperties_Runtime *runtime;
+ struct SpaceProperties_Runtime *runtime;
} SpaceProperties;
/* button defines (deprecated) */
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index 63e5f134c19..5381c524e4d 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -192,7 +192,7 @@ typedef struct Tex {
float cropxmin, cropymin, cropxmax, cropymax;
int texfilter;
- int afmax; // anisotropic filter maximum value, ewa -> max eccentricity, feline -> max probes
+ int afmax; /* anisotropic filter maximum value, ewa -> max eccentricity, feline -> max probes */
short xrepeat, yrepeat;
short extend;
@@ -318,8 +318,7 @@ typedef struct ColorMapping {
#define TEX_DERIVATIVEMAP (1 << 14)
/* texfilter */
-// TXF_BOX -> blender's old texture filtering method
-#define TXF_BOX 0
+#define TXF_BOX 0 /* Blender's old texture filtering method. */
#define TXF_EWA 1
#define TXF_FELINE 2
#define TXF_AREA 3
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index c41a8bb9bc1..954da51e3bf 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -322,10 +322,10 @@ typedef struct ThemeSpace {
unsigned char grid_levels;
/* syntax for textwindow and nodes */
- unsigned char syntaxl[4], syntaxs[4]; // in nodespace used for backdrop matte
- unsigned char syntaxb[4], syntaxn[4]; // in nodespace used for color input
- unsigned char syntaxv[4], syntaxc[4]; // in nodespace used for converter group
- unsigned char syntaxd[4], syntaxr[4]; // in nodespace used for distort
+ unsigned char syntaxl[4], syntaxs[4]; /* in nodespace used for backdrop matte */
+ unsigned char syntaxb[4], syntaxn[4]; /* in nodespace used for color input */
+ unsigned char syntaxv[4], syntaxc[4]; /* in nodespace used for converter group */
+ unsigned char syntaxd[4], syntaxr[4]; /* in nodespace used for distort */
unsigned char line_numbers[4];
char _pad6[3];
@@ -635,7 +635,9 @@ typedef struct UserDef_Experimental {
char use_sculpt_vertex_colors;
char use_tools_missing_icons;
char use_switch_object_operator;
- char _pad[7];
+ char use_sculpt_tools_tilt;
+ char _pad[6];
+ /** `makesdna` does not allow empty structs. */
} UserDef_Experimental;
#define USER_EXPERIMENTAL_TEST(userdef, member) \
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt
index 57a68720160..2051335dd7e 100644
--- a/source/blender/makesdna/intern/CMakeLists.txt
+++ b/source/blender/makesdna/intern/CMakeLists.txt
@@ -26,6 +26,7 @@ blender_include_dirs(
../../../../intern/atomic
../../../../intern/guardedalloc
../../blenlib
+ ../../imbuf
..
)
@@ -142,6 +143,8 @@ set(SRC
../DNA_camera_defaults.h
../DNA_curve_defaults.h
../DNA_defaults.h
+ ../DNA_fluid_defaults.h
+ ../DNA_gpencil_modifier_defaults.h
../DNA_hair_defaults.h
../DNA_image_defaults.h
../DNA_lattice_defaults.h
diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c
index 273f52a1d74..8c95a6d2a31 100644
--- a/source/blender/makesdna/intern/dna_defaults.c
+++ b/source/blender/makesdna/intern/dna_defaults.c
@@ -80,6 +80,8 @@
#include "BLI_memarena.h"
#include "BLI_utildefines.h"
+#include "IMB_imbuf.h"
+
#include "DNA_defaults.h"
#include "DNA_armature_types.h"
@@ -87,7 +89,10 @@
#include "DNA_cachefile_types.h"
#include "DNA_camera_types.h"
#include "DNA_cloth_types.h"
+#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
+#include "DNA_fluid_types.h"
+#include "DNA_gpencil_modifier_types.h"
#include "DNA_hair_types.h"
#include "DNA_image_types.h"
#include "DNA_key_types.h"
@@ -99,7 +104,9 @@
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_modifier_types.h"
+#include "DNA_movieclip_types.h"
#include "DNA_object_types.h"
+#include "DNA_particle_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_simulation_types.h"
@@ -109,10 +116,14 @@
#include "DNA_volume_types.h"
#include "DNA_world_types.h"
+#include "DNA_armature_defaults.h"
#include "DNA_brush_defaults.h"
#include "DNA_cachefile_defaults.h"
#include "DNA_camera_defaults.h"
+#include "DNA_collection_defaults.h"
#include "DNA_curve_defaults.h"
+#include "DNA_fluid_defaults.h"
+#include "DNA_gpencil_modifier_defaults.h"
#include "DNA_hair_defaults.h"
#include "DNA_image_defaults.h"
#include "DNA_lattice_defaults.h"
@@ -123,7 +134,9 @@
#include "DNA_mesh_defaults.h"
#include "DNA_meta_defaults.h"
#include "DNA_modifier_defaults.h"
+#include "DNA_movieclip_defaults.h"
#include "DNA_object_defaults.h"
+#include "DNA_particle_defaults.h"
#include "DNA_pointcloud_defaults.h"
#include "DNA_scene_defaults.h"
#include "DNA_simulation_defaults.h"
@@ -135,6 +148,9 @@
#define SDNA_DEFAULT_DECL_STRUCT(struct_name) \
static const struct_name DNA_DEFAULT_##struct_name = _DNA_DEFAULT_##struct_name
+/* DNA_armature_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(bArmature);
+
/* DNA_brush_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Brush);
@@ -144,9 +160,17 @@ SDNA_DEFAULT_DECL_STRUCT(CacheFile);
/* DNA_camera_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Camera);
+/* DNA_collection_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(Collection);
+
/* DNA_curve_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Curve);
+/* DNA_fluid_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(FluidDomainSettings);
+SDNA_DEFAULT_DECL_STRUCT(FluidFlowSettings);
+SDNA_DEFAULT_DECL_STRUCT(FluidEffectorSettings);
+
/* DNA_image_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Image);
@@ -174,9 +198,15 @@ SDNA_DEFAULT_DECL_STRUCT(Mesh);
/* DNA_meta_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(MetaBall);
+/* DNA_movieclip_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(MovieClip);
+
/* DNA_object_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Object);
+/* DNA_particle_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(ParticleSettings);
+
/* DNA_pointcloud_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(PointCloud);
@@ -261,6 +291,26 @@ SDNA_DEFAULT_DECL_STRUCT(WeightVGProximityModifierData);
SDNA_DEFAULT_DECL_STRUCT(WeldModifierData);
SDNA_DEFAULT_DECL_STRUCT(WireframeModifierData);
+/* DNA_gpencil_modifier_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(ArmatureGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(ArrayGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(BuildGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(ColorGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(HookGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(LatticeGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(MirrorGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(MultiplyGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(NoiseGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(OffsetGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(OpacityGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(SimplifyGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(SmoothGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(SubdivGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(TextureGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(ThickGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(TimeGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(TintGpencilModifierData);
+
#undef SDNA_DEFAULT_DECL_STRUCT
/* Reuse existing definitions. */
@@ -288,6 +338,9 @@ extern const bTheme U_theme_default;
/** Keep headers sorted. */
const void *DNA_default_table[SDNA_TYPE_MAX] = {
+ /* DNA_arnature_defaults.h */
+ SDNA_DEFAULT_DECL(bArmature),
+
/* DNA_brush_defaults.h */
SDNA_DEFAULT_DECL(Brush),
@@ -299,9 +352,17 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
SDNA_DEFAULT_DECL_EX(CameraDOFSettings, Camera.dof),
SDNA_DEFAULT_DECL_EX(CameraStereoSettings, Camera.stereo),
+ /* DNA_collection_defaults.h */
+ SDNA_DEFAULT_DECL(Collection),
+
/* DNA_curve_defaults.h */
SDNA_DEFAULT_DECL(Curve),
+ /* DNA_fluid_defaults.h */
+ SDNA_DEFAULT_DECL(FluidDomainSettings),
+ SDNA_DEFAULT_DECL(FluidFlowSettings),
+ SDNA_DEFAULT_DECL(FluidEffectorSettings),
+
/* DNA_image_defaults.h */
SDNA_DEFAULT_DECL(Image),
@@ -329,9 +390,15 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
/* DNA_meta_defaults.h */
SDNA_DEFAULT_DECL(MetaBall),
+ /* DNA_movieclip_defaults.h */
+ SDNA_DEFAULT_DECL(MovieClip),
+
/* DNA_object_defaults.h */
SDNA_DEFAULT_DECL(Object),
+ /* DNA_particle_defaults.h */
+ SDNA_DEFAULT_DECL(ParticleSettings),
+
/* DNA_pointcloud_defaults.h */
SDNA_DEFAULT_DECL(PointCloud),
@@ -443,6 +510,26 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
SDNA_DEFAULT_DECL(WeightVGProximityModifierData),
SDNA_DEFAULT_DECL(WeldModifierData),
SDNA_DEFAULT_DECL(WireframeModifierData),
+
+ /* DNA_gpencil_modifier_defaults.h */
+ SDNA_DEFAULT_DECL(ArmatureGpencilModifierData),
+ SDNA_DEFAULT_DECL(ArrayGpencilModifierData),
+ SDNA_DEFAULT_DECL(BuildGpencilModifierData),
+ SDNA_DEFAULT_DECL(ColorGpencilModifierData),
+ SDNA_DEFAULT_DECL(HookGpencilModifierData),
+ SDNA_DEFAULT_DECL(LatticeGpencilModifierData),
+ SDNA_DEFAULT_DECL(MirrorGpencilModifierData),
+ SDNA_DEFAULT_DECL(MultiplyGpencilModifierData),
+ SDNA_DEFAULT_DECL(NoiseGpencilModifierData),
+ SDNA_DEFAULT_DECL(OffsetGpencilModifierData),
+ SDNA_DEFAULT_DECL(OpacityGpencilModifierData),
+ SDNA_DEFAULT_DECL(SimplifyGpencilModifierData),
+ SDNA_DEFAULT_DECL(SmoothGpencilModifierData),
+ SDNA_DEFAULT_DECL(SubdivGpencilModifierData),
+ SDNA_DEFAULT_DECL(TextureGpencilModifierData),
+ SDNA_DEFAULT_DECL(ThickGpencilModifierData),
+ SDNA_DEFAULT_DECL(TimeGpencilModifierData),
+ SDNA_DEFAULT_DECL(TintGpencilModifierData),
};
#undef SDNA_DEFAULT_DECL
#undef SDNA_DEFAULT_DECL_EX
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index d7360c67210..ac747ab3037 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -32,7 +32,7 @@
#include <stdlib.h>
#include <string.h>
-#include "MEM_guardedalloc.h" // for MEM_freeN MEM_mallocN MEM_callocN
+#include "MEM_guardedalloc.h" /* for MEM_freeN MEM_mallocN MEM_callocN */
#include "BLI_endian_switch.h"
#include "BLI_memarena.h"
@@ -42,7 +42,7 @@
#include "BLI_ghash.h"
#include "DNA_genfile.h"
-#include "DNA_sdna_types.h" // for SDNA ;-)
+#include "DNA_sdna_types.h" /* for SDNA ;-) */
/**
* \section dna_genfile Overview
@@ -980,92 +980,110 @@ static int elem_offset(const SDNA *sdna,
return -1;
}
+/* Each struct member belongs to one of the categories below. */
+typedef enum eStructMemberCategory {
+ STRUCT_MEMBER_CATEGORY_STRUCT,
+ STRUCT_MEMBER_CATEGORY_PRIMITIVE,
+ STRUCT_MEMBER_CATEGORY_POINTER,
+} eStructMemberCategory;
+
+static eStructMemberCategory get_struct_member_category(const SDNA *sdna,
+ const SDNA_StructMember *member)
+{
+ const char *member_name = sdna->names[member->name];
+ if (ispointer(member_name)) {
+ return STRUCT_MEMBER_CATEGORY_POINTER;
+ }
+ const char *member_type_name = sdna->types[member->type];
+ if (DNA_struct_find(sdna, member_type_name)) {
+ return STRUCT_MEMBER_CATEGORY_STRUCT;
+ }
+ return STRUCT_MEMBER_CATEGORY_PRIMITIVE;
+}
+
+static int get_member_size_in_bytes(const SDNA *sdna, const SDNA_StructMember *member)
+{
+ const char *name = sdna->names[member->name];
+ const int array_length = sdna->names_array_len[member->name];
+ if (ispointer(name)) {
+ return sdna->pointer_size * array_length;
+ }
+ const int type_size = sdna->types_size[member->type];
+ return type_size * array_length;
+}
+
/**
* Does endian swapping on the fields of a struct value.
*
- * \param oldsdna: SDNA of Blender that saved file
- * \param oldSDNAnr: Index of struct info within oldsdna
- * \param data: Struct data
+ * \param sdna: SDNA of the struct_nr belongs to
+ * \param struct_nr: Index of struct info within sdna
+ * \param data: Struct data that is to be converted
*/
-void DNA_struct_switch_endian(const SDNA *oldsdna, int oldSDNAnr, char *data)
+void DNA_struct_switch_endian(const SDNA *sdna, int struct_nr, char *data)
{
- /* Recursive!
- * If element is a struct, call recursive.
- */
- if (oldSDNAnr == -1) {
+ if (struct_nr == -1) {
return;
}
- const int firststructtypenr = oldsdna->structs[0]->type;
- const SDNA_Struct *struct_info = oldsdna->structs[oldSDNAnr];
- char *cur = data;
- for (int a = 0; a < struct_info->members_len; a++) {
- const SDNA_StructMember *member = &struct_info->members[a];
- const char *type = oldsdna->types[member->type];
- const char *name = oldsdna->names[member->name];
- const int old_name_array_len = oldsdna->names_array_len[member->name];
-
- /* DNA_elem_size_nr = including arraysize */
- const int elen = DNA_elem_size_nr(oldsdna, member->type, member->name);
-
- /* test: is type a struct? */
- if (member->type >= firststructtypenr && !ispointer(name)) {
- /* struct field type */
- /* where does the old data start (is there one?) */
-
- const int data_offset = elem_offset(oldsdna, type, name, struct_info);
- if (data_offset != -1) {
- char *cpo = data + data_offset;
- unsigned int oldsdna_index_last = UINT_MAX;
- oldSDNAnr = DNA_struct_find_nr_ex(oldsdna, type, &oldsdna_index_last);
-
- int mul = old_name_array_len;
- const int elena = elen / mul;
-
- while (mul--) {
- DNA_struct_switch_endian(oldsdna, oldSDNAnr, cpo);
- cpo += elena;
+
+ const SDNA_Struct *struct_info = sdna->structs[struct_nr];
+
+ int offset_in_bytes = 0;
+ for (int member_index = 0; member_index < struct_info->members_len; member_index++) {
+ const SDNA_StructMember *member = &struct_info->members[member_index];
+ const eStructMemberCategory member_category = get_struct_member_category(sdna, member);
+ char *member_data = data + offset_in_bytes;
+ const char *member_type_name = sdna->types[member->type];
+ const int member_array_length = sdna->names_array_len[member->name];
+
+ switch (member_category) {
+ case STRUCT_MEMBER_CATEGORY_STRUCT: {
+ const int substruct_size = sdna->types_size[member->type];
+ const int substruct_nr = DNA_struct_find_nr(sdna, member_type_name);
+ BLI_assert(substruct_nr != -1);
+ for (int a = 0; a < member_array_length; a++) {
+ DNA_struct_switch_endian(sdna, substruct_nr, member_data + a * substruct_size);
}
+ break;
}
- }
- else {
- /* non-struct field type */
- if (ispointer(name)) {
- /* See readfile.c (#bh4_from_bh8 swap endian argument),
- * this is only done when reducing the size of a pointer from 4 to 8. */
- if (sizeof(void *) < 8) {
- if (oldsdna->pointer_size == 8) {
- BLI_endian_switch_int64_array((int64_t *)cur, old_name_array_len);
+ case STRUCT_MEMBER_CATEGORY_PRIMITIVE: {
+ switch (member->type) {
+ case SDNA_TYPE_SHORT:
+ case SDNA_TYPE_USHORT: {
+ BLI_endian_switch_int16_array((int16_t *)member_data, member_array_length);
+ break;
}
- }
- }
- else {
- if (ELEM(member->type, SDNA_TYPE_SHORT, SDNA_TYPE_USHORT)) {
-
- /* exception: variable called blocktype: derived from ID_ */
- bool skip = false;
- if (name[0] == 'b' && name[1] == 'l') {
- if (STREQ(name, "blocktype")) {
- skip = true;
- }
+ case SDNA_TYPE_INT:
+ case SDNA_TYPE_FLOAT: {
+ /* Note, intentionally ignore long/ulong, because these could be 4 or 8 bytes.
+ * Fortunately, we only use these types for runtime variables and only once for a
+ * struct type that is no longer used. */
+ BLI_endian_switch_int32_array((int32_t *)member_data, member_array_length);
+ break;
}
-
- if (skip == false) {
- BLI_endian_switch_int16_array((int16_t *)cur, old_name_array_len);
+ case SDNA_TYPE_INT64:
+ case SDNA_TYPE_UINT64:
+ case SDNA_TYPE_DOUBLE: {
+ BLI_endian_switch_int64_array((int64_t *)member_data, member_array_length);
+ break;
+ }
+ default: {
+ break;
}
}
- else if (ELEM(member->type, SDNA_TYPE_INT, SDNA_TYPE_FLOAT)) {
- /* note, intentionally ignore long/ulong here these could be 4 or 8 bits,
- * but turns out we only used for runtime vars and
- * only once for a struct type that's no longer used. */
-
- BLI_endian_switch_int32_array((int32_t *)cur, old_name_array_len);
- }
- else if (ELEM(member->type, SDNA_TYPE_INT64, SDNA_TYPE_UINT64, SDNA_TYPE_DOUBLE)) {
- BLI_endian_switch_int64_array((int64_t *)cur, old_name_array_len);
+ break;
+ }
+ case STRUCT_MEMBER_CATEGORY_POINTER: {
+ /* See readfile.c (#bh4_from_bh8 swap endian argument),
+ * this is only done when reducing the size of a pointer from 4 to 8. */
+ if (sizeof(void *) < 8) {
+ if (sdna->pointer_size == 8) {
+ BLI_endian_switch_uint64_array((uint64_t *)member_data, member_array_length);
+ }
}
+ break;
}
}
- cur += elen;
+ offset_in_bytes += get_member_size_in_bytes(sdna, member);
}
}
@@ -1235,38 +1253,6 @@ void *DNA_struct_reconstruct(const DNA_ReconstructInfo *reconstruct_info,
return new_blocks;
}
-/* Each struct member belongs to one of the categories below. */
-typedef enum eStructMemberCategory {
- STRUCT_MEMBER_CATEGORY_STRUCT,
- STRUCT_MEMBER_CATEGORY_PRIMITIVE,
- STRUCT_MEMBER_CATEGORY_POINTER,
-} eStructMemberCategory;
-
-static eStructMemberCategory get_struct_member_category(const SDNA *sdna,
- const SDNA_StructMember *member)
-{
- const char *member_name = sdna->names[member->name];
- if (ispointer(member_name)) {
- return STRUCT_MEMBER_CATEGORY_POINTER;
- }
- const char *member_type_name = sdna->types[member->type];
- if (DNA_struct_find(sdna, member_type_name)) {
- return STRUCT_MEMBER_CATEGORY_STRUCT;
- }
- return STRUCT_MEMBER_CATEGORY_PRIMITIVE;
-}
-
-static int get_member_size_in_bytes(const SDNA *sdna, const SDNA_StructMember *member)
-{
- const char *name = sdna->names[member->name];
- const int array_length = sdna->names_array_len[member->name];
- if (ispointer(name)) {
- return sdna->pointer_size * array_length;
- }
- const int type_size = sdna->types_size[member->type];
- return type_size * array_length;
-}
-
/** Finds a member in the given struct with the given name. */
static const SDNA_StructMember *find_member_with_matching_name(const SDNA *sdna,
const SDNA_Struct *struct_info,
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 1c488b2cac1..d63a2e06764 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -414,7 +414,7 @@ typedef struct CollectionListBase {
typedef enum RawPropertyType {
PROP_RAW_UNSET = -1,
- PROP_RAW_INT, // XXX - abused for types that are not set, eg. MFace.verts, needs fixing.
+ PROP_RAW_INT, /* XXX - abused for types that are not set, eg. MFace.verts, needs fixing. */
PROP_RAW_SHORT,
PROP_RAW_CHAR,
PROP_RAW_BOOLEAN,
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index 098854513a4..202864a7d82 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -1160,6 +1160,10 @@ IDOverrideLibraryProperty *RNA_property_override_property_get(Main *bmain,
ID *id;
char *rna_path;
+ if (r_created != NULL) {
+ *r_created = false;
+ }
+
if ((rna_path = rna_property_override_property_real_id_owner(bmain, ptr, prop, &id)) != NULL) {
IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
id->override_library, rna_path, r_created);
@@ -1198,6 +1202,10 @@ IDOverrideLibraryPropertyOperation *RNA_property_override_property_operation_get
bool *r_strict,
bool *r_created)
{
+ if (r_created != NULL) {
+ *r_created = false;
+ }
+
IDOverrideLibraryProperty *op = RNA_property_override_property_get(bmain, ptr, prop, NULL);
if (!op) {
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index cec32877c0b..89687c1234c 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -365,6 +365,12 @@ static void rna_def_dopesheet(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_SORTALPHA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+ prop = RNA_def_property(srna, "use_filter_invert", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", ADS_FLAG_INVERT_FILTER);
+ RNA_def_property_ui_text(prop, "Invert", "Invert filter search");
+ RNA_def_property_ui_icon(prop, ICON_ZOOM_IN, 0);
+ RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+
/* Debug Filtering Settings */
prop = RNA_def_property(srna, "show_only_errors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLY_ERRORS);
diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c
index 9e9575344c5..7f0ab2df70d 100644
--- a/source/blender/makesrna/intern/rna_attribute.c
+++ b/source/blender/makesrna/intern/rna_attribute.c
@@ -48,14 +48,14 @@ const EnumPropertyItem rna_enum_attribute_type_items[] = {
};
const EnumPropertyItem rna_enum_attribute_domain_items[] = {
- /* Not implement yet
- {ATTR_DOMAIN_GEOMETRY, "GEOMETRY", 0, "Geometry", "Attribute on (whole) geometry"}, */
+ /* Not implement yet */
+ // {ATTR_DOMAIN_GEOMETRY, "GEOMETRY", 0, "Geometry", "Attribute on (whole) geometry"},
{ATTR_DOMAIN_VERTEX, "VERTEX", 0, "Vertex", "Attribute on mesh vertex"},
{ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"},
{ATTR_DOMAIN_CORNER, "CORNER", 0, "Corner", "Attribute on mesh polygon corner"},
{ATTR_DOMAIN_POLYGON, "POLYGON", 0, "Polygon", "Attribute on mesh polygons"},
- /* Not implement yet
- {ATTR_DOMAIN_GRIDS, "GRIDS", 0, "Grids", "Attribute on mesh multires grids"}, */
+ /* Not implement yet */
+ // {ATTR_DOMAIN_GRIDS, "GRIDS", 0, "Grids", "Attribute on mesh multires grids"},
{ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"},
{ATTR_DOMAIN_CURVE, "CURVE", 0, "Curve", "Attribute on hair curve"},
{0, NULL, 0, NULL, NULL},
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 35f5c4c37bc..ac876eac7db 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -557,6 +557,19 @@ static bool rna_BrushCapabilitiesSculpt_has_gravity_get(PointerRNA *ptr)
return !ELEM(br->sculpt_tool, SCULPT_TOOL_MASK, SCULPT_TOOL_SMOOTH);
}
+static bool rna_BrushCapabilitiesSculpt_has_tilt_get(PointerRNA *ptr)
+{
+ Brush *br = (Brush *)ptr->data;
+ return ELEM(br->sculpt_tool,
+ SCULPT_TOOL_DRAW,
+ SCULPT_TOOL_DRAW_SHARP,
+ SCULPT_TOOL_FLATTEN,
+ SCULPT_TOOL_FILL,
+ SCULPT_TOOL_SCRAPE,
+ SCULPT_TOOL_CLAY_STRIPS,
+ SCULPT_TOOL_CLAY_THUMB);
+}
+
static bool rna_TextureCapabilities_has_texture_angle_source_get(PointerRNA *ptr)
{
MTex *mtex = (MTex *)ptr->data;
@@ -1137,6 +1150,7 @@ static void rna_def_sculpt_capabilities(BlenderRNA *brna)
SCULPT_TOOL_CAPABILITY(has_strength_pressure, "Has Strength Pressure");
SCULPT_TOOL_CAPABILITY(has_direction, "Has Direction");
SCULPT_TOOL_CAPABILITY(has_gravity, "Has Gravity");
+ SCULPT_TOOL_CAPABILITY(has_tilt, "Has Tilt");
# undef SCULPT_CAPABILITY
}
@@ -2753,8 +2767,8 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(
prop,
- "Soft Body Influence",
- "How much the simulation preserves the original shape, acting as a soft body");
+ "Soft Body Plasticity",
+ "How much the cloth preserves the original shape, acting as a soft body");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "hardness", PROP_FLOAT, PROP_FACTOR);
@@ -2796,6 +2810,15 @@ static void rna_def_brush(BlenderRNA *brna)
"Best used on low-poly meshes as it has a performance impact");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "tilt_strength_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "tilt_strength_factor");
+ RNA_def_property_float_default(prop, 0);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
+ RNA_def_property_ui_text(
+ prop, "Tilt Strength", "How much the tilt of the pen will affect the brush");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "normal_radius_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "normal_radius_factor");
RNA_def_property_range(prop, 0.0f, 2.0f);
@@ -3403,6 +3426,11 @@ static void rna_def_operator_stroke_element(BlenderRNA *brna)
RNA_def_property_array(prop, 2);
RNA_def_property_ui_text(prop, "Mouse", "");
+ prop = RNA_def_property(srna, "mouse_event", PROP_FLOAT, PROP_XYZ);
+ RNA_def_property_flag(prop, PROP_IDPROPERTY);
+ RNA_def_property_array(prop, 2);
+ RNA_def_property_ui_text(prop, "Mouse Event", "");
+
prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_flag(prop, PROP_IDPROPERTY);
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -3417,6 +3445,16 @@ static void rna_def_operator_stroke_element(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_IDPROPERTY);
RNA_def_property_ui_text(prop, "Flip", "");
+ prop = RNA_def_property(srna, "x_tilt", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_flag(prop, PROP_IDPROPERTY);
+ RNA_def_property_range(prop, -1.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Tilt X", "");
+
+ prop = RNA_def_property(srna, "y_tilt", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_flag(prop, PROP_IDPROPERTY);
+ RNA_def_property_range(prop, -1.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Tilt Y", "");
+
/* used in uv painting */
prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_flag(prop, PROP_IDPROPERTY);
diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c
index cb64d81533f..ad117933764 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -62,7 +62,7 @@ static void rna_Fluid_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
{
DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
- // Needed for liquid domain objects
+ /* Needed for liquid domain objects */
Object *ob = (Object *)ptr->owner_id;
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
@@ -490,7 +490,7 @@ static void rna_Fluid_combined_export_update(Main *bmain, Scene *scene, PointerR
}
}
else {
- // sanity check, should not occur
+ /* sanity check, should not occur */
printf("ERROR: Unexpected combined export setting encountered!");
}
}
@@ -1264,8 +1264,13 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}};
static const EnumPropertyItem fluid_data_depth_items[] = {
- {VDB_PRECISION_HALF_FLOAT, "16", 0, "Half", "Half float (16 bit data)"},
- {VDB_PRECISION_FULL_FLOAT, "32", 0, "Full", "Full float (32 bit data)"},
+ {VDB_PRECISION_MINI_FLOAT,
+ "8",
+ 0,
+ "Mini",
+ "Mini float (Use 8 bit where possible, otherwise 16 bit)"},
+ {VDB_PRECISION_HALF_FLOAT, "16", 0, "Half", "Half float (Use 16 bit for all data)"},
+ {VDB_PRECISION_FULL_FLOAT, "32", 0, "Full", "Full float (Use 32 bit for all data)"},
{0, NULL, 0, NULL, NULL},
};
@@ -2628,10 +2633,10 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "openvdb_data_depth", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "openvdb_data_depth");
RNA_def_property_enum_items(prop, fluid_data_depth_items);
- RNA_def_property_ui_text(prop,
- "Data Depth",
- "Bit depth for writing all scalar (including vector) "
- "lower values reduce file size");
+ RNA_def_property_ui_text(
+ prop,
+ "Data Depth",
+ "Bit depth for fluid particles and grids (lower bit values reduce file size)");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
}
@@ -2776,7 +2781,9 @@ static void rna_def_fluid_flow_settings(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, -1000.1, 1000.1);
RNA_def_property_ui_text(
- prop, "Initial", "Initial velocity in X, Y and Z direction in world space");
+ prop,
+ "Initial",
+ "Additional initial velocity in X, Y and Z direction (added to source velocity)");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
prop = RNA_def_property(srna, "volume_density", PROP_FLOAT, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 9e3f8bb8183..5592474a348 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -459,7 +459,6 @@ static void rna_def_modifier_gpencilnoise(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "factor");
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 2);
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "Offset Factor", "Amount of noise to apply");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -467,7 +466,6 @@ static void rna_def_modifier_gpencilnoise(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "factor_strength");
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 2);
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "Strength Factor", "Amount of noise to apply to opacity");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -475,7 +473,6 @@ static void rna_def_modifier_gpencilnoise(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "factor_thickness");
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 2);
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "Thickness Factor", "Amount of noise to apply to thickness");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -483,7 +480,6 @@ static void rna_def_modifier_gpencilnoise(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "factor_uvs");
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 2);
- RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "UV Factor", "Amount of noise to apply uv rotation");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -887,7 +883,6 @@ static void rna_def_modifier_gpencilthick(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "thickness_fac");
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0, 10.0, 0.1, 3);
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Thickness Factor", "Factor to multiply the thickness with");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -1218,7 +1213,6 @@ static void rna_def_modifier_gpenciltime(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "sfra");
RNA_def_property_int_funcs(prop, NULL, "rna_TimeModifier_start_frame_set", NULL);
RNA_def_property_range(prop, MINFRAME, MAXFRAME);
- RNA_def_property_int_default(prop, 1);
RNA_def_property_ui_text(prop, "Start Frame", "First frame of the range");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -1227,7 +1221,6 @@ static void rna_def_modifier_gpenciltime(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "efra");
RNA_def_property_int_funcs(prop, NULL, "rna_TimeModifier_end_frame_set", NULL);
RNA_def_property_range(prop, MINFRAME, MAXFRAME);
- RNA_def_property_int_default(prop, 250);
RNA_def_property_ui_text(prop, "End Frame", "Final frame of the range");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -1273,7 +1266,6 @@ static void rna_def_modifier_gpencilcolor(BlenderRNA *brna)
prop = RNA_def_property(srna, "hue", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
- RNA_def_property_float_default(prop, 0.5);
RNA_def_property_float_sdna(prop, NULL, "hsv[0]");
RNA_def_property_ui_text(prop, "Hue", "Color Hue");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -1281,7 +1273,6 @@ static void rna_def_modifier_gpencilcolor(BlenderRNA *brna)
prop = RNA_def_property(srna, "saturation", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0, 2.0, 0.1, 3);
- RNA_def_property_float_default(prop, 1.0);
RNA_def_property_float_sdna(prop, NULL, "hsv[1]");
RNA_def_property_ui_text(prop, "Saturation", "Color Saturation");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -1289,7 +1280,6 @@ static void rna_def_modifier_gpencilcolor(BlenderRNA *brna)
prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0, 2.0, 0.1, 3);
- RNA_def_property_float_default(prop, 1.0);
RNA_def_property_float_sdna(prop, NULL, "hsv[2]");
RNA_def_property_ui_text(prop, "Value", "Color Value");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -1382,7 +1372,6 @@ static void rna_def_modifier_gpencilopacity(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "hardeness");
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0, FLT_MAX, 0.1, 2);
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Hardness", "Factor of stroke hardness");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -2156,19 +2145,16 @@ static void rna_def_modifier_gpencilmultiply(BlenderRNA *brna)
prop = RNA_def_property(srna, "fading_thickness", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0, 1);
- RNA_def_property_float_default(prop, 0.5);
RNA_def_property_ui_text(prop, "Thickness", "Fade influence of stroke's thickness");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "fading_opacity", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0, 1);
- RNA_def_property_float_default(prop, 0.5);
RNA_def_property_ui_text(prop, "Opacity", "Fade influence of stroke's opacity");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "fading_center", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0, 1);
- RNA_def_property_float_default(prop, 0.5);
RNA_def_property_ui_text(prop, "Center", "Fade center");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
}
@@ -2267,7 +2253,6 @@ static void rna_def_modifier_gpenciltexture(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "uv_offset");
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
RNA_def_property_ui_range(prop, -100.0, 100.0, 0.1, 3);
- RNA_def_property_float_default(prop, 0.0f);
RNA_def_property_ui_text(prop, "UV Offset", "Offset value to add to stroke UVs");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -2275,7 +2260,6 @@ static void rna_def_modifier_gpenciltexture(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "uv_scale");
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0, 100.0, 0.1, 3);
- RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "UV Scale", "Factor to scale the UVs");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index fc5e957bba6..d3e2445366e 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -29,8 +29,6 @@
#include "RE_engine.h"
-#include "DRW_engine.h"
-
#include "WM_api.h"
#include "WM_types.h"
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 766497d53c1..0010e473924 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -7030,7 +7030,8 @@ static void rna_def_modifier_mesh_to_volume(BlenderRNA *brna)
prop = RNA_def_property(srna, "voxel_size", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(
prop, "Voxel Size", "Smaller values result in a higher resolution output");
- RNA_def_property_range(prop, 0.1, FLT_MAX);
+ RNA_def_property_range(prop, 0.0, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0, FLT_MAX, 0.01, 4);
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "voxel_amount", PROP_INT, PROP_NONE);
@@ -7095,6 +7096,7 @@ static void rna_def_modifier_volume_displace(BlenderRNA *brna)
prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "Strength", "Strength of the displacement");
+ RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 4);
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 13b068c2be5..615faf6e2f3 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -2944,7 +2944,6 @@ static void rna_def_particle_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "courant_target", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0001, 10);
- RNA_def_property_float_default(prop, 0.1);
RNA_def_property_ui_text(
prop,
"Adaptive Subframe Threshold",
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index 35563ad143e..05b3b0b0c70 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -27,7 +27,9 @@
#include "BLI_path_util.h"
#include "BLI_utildefines.h"
-#include "BPY_extern.h"
+#ifdef WITH_PYTHON
+# include "BPY_extern.h"
+#endif
#include "DEG_depsgraph.h"
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index d4d30d0c09a..0b56a73efa2 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -1077,14 +1077,14 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
/* Physics Parameters */
prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS);
RNA_def_property_float_sdna(prop, NULL, "mass");
- RNA_def_property_range(prop, 0.001f, FLT_MAX); // range must always be positive (and non-zero)
+ RNA_def_property_range(prop, 0.001f, FLT_MAX); /* range must always be positive (and non-zero) */
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_mass_set", NULL);
RNA_def_property_ui_text(prop, "Mass", "How much the object 'weighs' irrespective of gravity");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
/* Dynamics Parameters - Activation */
- // TODO: define and figure out how to implement these
+ /* TODO: define and figure out how to implement these. */
/* Dynamics Parameters - Deactivation */
prop = RNA_def_property(srna, "use_deactivation", PROP_BOOLEAN, PROP_NONE);
@@ -1107,7 +1107,8 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
prop = RNA_def_property(srna, "deactivate_linear_velocity", PROP_FLOAT, PROP_UNIT_VELOCITY);
RNA_def_property_float_sdna(prop, NULL, "lin_sleep_thresh");
- RNA_def_property_range(prop, FLT_MIN, FLT_MAX); // range must always be positive (and non-zero)
+ RNA_def_property_range(
+ prop, FLT_MIN, FLT_MAX); /* range must always be positive (and non-zero) */
RNA_def_property_float_default(prop, 0.4f);
RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_linear_sleepThresh_set", NULL);
RNA_def_property_ui_text(prop,
@@ -1117,7 +1118,8 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
prop = RNA_def_property(srna, "deactivate_angular_velocity", PROP_FLOAT, PROP_UNIT_VELOCITY);
RNA_def_property_float_sdna(prop, NULL, "ang_sleep_thresh");
- RNA_def_property_range(prop, FLT_MIN, FLT_MAX); // range must always be positive (and non-zero)
+ RNA_def_property_range(
+ prop, FLT_MIN, FLT_MAX); /* range must always be positive (and non-zero) */
RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_angular_sleepThresh_set", NULL);
RNA_def_property_ui_text(prop,
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 8e09de86529..24cff501b59 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -49,8 +49,6 @@
#include "ED_gpencil.h"
#include "ED_object.h"
-#include "DRW_engine.h"
-
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -6853,6 +6851,17 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
+ static const EnumPropertyItem eevee_motion_blur_position_items[] = {
+ {SCE_EEVEE_MB_START, "START", 0, "Start on Frame", "The shutter opens at the current frame"},
+ {SCE_EEVEE_MB_CENTER,
+ "CENTER",
+ 0,
+ "Center on Frame",
+ "The shutter is open during the current frame"},
+ {SCE_EEVEE_MB_END, "END", 0, "End on Frame", "The shutter closes at the current frame"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
srna = RNA_def_struct(brna, "SceneEEVEE", NULL);
RNA_def_struct_path_func(srna, "rna_SceneEEVEE_path");
RNA_def_struct_ui_text(srna, "Scene Display", "Scene display settings for 3d viewport");
@@ -7242,6 +7251,15 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+ prop = RNA_def_property(srna, "motion_blur_position", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, eevee_motion_blur_position_items);
+ RNA_def_property_ui_text(prop,
+ "Motion Blur Position",
+ "Offset for the shutter's time interval, "
+ "allows to change the motion blur trails");
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
/* Shadows */
prop = RNA_def_property(srna, "shadow_cube_size", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, eevee_shadow_size_items);
diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c
index 59cedf8fcb8..e93ca7bc019 100644
--- a/source/blender/makesrna/intern/rna_sequencer_api.c
+++ b/source/blender/makesrna/intern/rna_sequencer_api.c
@@ -58,7 +58,7 @@ static void rna_Sequence_update_rnafunc(ID *id, Sequence *self, bool do_data)
{
if (do_data) {
BKE_sequencer_update_changed_seq_and_deps((Scene *)id, self, true, true);
- // new_tstripdata(self); // need 2.6x version of this.
+ // new_tstripdata(self); /* need 2.6x version of this. */
}
BKE_sequence_calc((Scene *)id, self);
BKE_sequence_calc_disp((Scene *)id, self);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 2a4bc6bae06..5b34281ffa0 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1825,6 +1825,53 @@ static void rna_SpaceProperties_context_update(Main *UNUSED(bmain),
}
}
+static int rna_SpaceProperties_tab_search_results_getlength(PointerRNA *ptr,
+ int length[RNA_MAX_ARRAY_DIMENSION])
+{
+ SpaceProperties *sbuts = ptr->data;
+
+ short context_tabs_array[BCONTEXT_TOT * 2]; /* Dummy variable. */
+ const int tabs_len = ED_buttons_tabs_list(sbuts, context_tabs_array);
+
+ length[0] = tabs_len;
+
+ return length[0];
+}
+
+static void rna_SpaceProperties_tab_search_results_get(PointerRNA *ptr, bool *values)
+{
+ SpaceProperties *sbuts = ptr->data;
+
+ short context_tabs_array[BCONTEXT_TOT * 2]; /* Dummy variable. */
+ const int tabs_len = ED_buttons_tabs_list(sbuts, context_tabs_array);
+
+ for (int i = 0; i < tabs_len; i++) {
+ values[i] = ED_buttons_tab_has_search_result(sbuts, i);
+ }
+}
+
+static void rna_SpaceProperties_search_filter_get(PointerRNA *ptr, char *value)
+{
+ SpaceProperties *sbuts = ptr->data;
+ const char *search_filter = ED_buttons_search_string_get(sbuts);
+
+ strcpy(value, search_filter);
+}
+
+static int rna_SpaceProperties_search_filter_length(PointerRNA *ptr)
+{
+ SpaceProperties *sbuts = ptr->data;
+
+ return ED_buttons_search_string_length(sbuts);
+}
+
+static void rna_SpaceProperties_search_filter_set(struct PointerRNA *ptr, const char *value)
+{
+ SpaceProperties *sbuts = ptr->data;
+
+ ED_buttons_search_string_set(sbuts, value);
+}
+
static void rna_SpaceProperties_search_filter_update(Main *UNUSED(bmain),
Scene *UNUSED(scene),
PointerRNA *ptr)
@@ -4514,8 +4561,23 @@ static void rna_def_space_properties(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Pin ID", "Use the pinned context");
/* Property search. */
+
+ prop = RNA_def_property(srna, "tab_search_results", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_array(prop, 0); /* Dynamic length, see next line. */
+ RNA_def_property_flag(prop, PROP_DYNAMIC);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_boolean_funcs(prop, "rna_SpaceProperties_tab_search_results_get", NULL);
+ RNA_def_property_dynamic_array_funcs(prop, "rna_SpaceProperties_tab_search_results_getlength");
+ RNA_def_property_ui_text(
+ prop, "Tab Search Results", "Whether or not each visible tab has a search result");
+
prop = RNA_def_property(srna, "search_filter", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "runtime->search_string");
+ /* The search filter is stored in the property editor's runtime struct which
+ * is only defined in an internal header, so use the getter / setter here. */
+ RNA_def_property_string_funcs(prop,
+ "rna_SpaceProperties_search_filter_get",
+ "rna_SpaceProperties_search_filter_length",
+ "rna_SpaceProperties_search_filter_set");
RNA_def_property_ui_text(prop, "Display Filter", "Live search filtering string");
RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE);
RNA_def_property_update(
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 47d9e3e146a..447f5b4210b 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -216,8 +216,13 @@ static void rna_uiItemMenuEnumR(uiLayout *layout,
uiItemMenuEnumR_prop(layout, ptr, prop, name, icon);
}
-static void rna_uiItemTabsEnumR(
- uiLayout *layout, bContext *C, struct PointerRNA *ptr, const char *propname, bool icon_only)
+static void rna_uiItemTabsEnumR(uiLayout *layout,
+ bContext *C,
+ struct PointerRNA *ptr,
+ const char *propname,
+ struct PointerRNA *ptr_highlight,
+ const char *propname_highlight,
+ bool icon_only)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
@@ -230,7 +235,31 @@ static void rna_uiItemTabsEnumR(
return;
}
- uiItemTabsEnumR_prop(layout, C, ptr, prop, icon_only);
+ /* Get the highlight property used to gray out some of the tabs. */
+ PropertyRNA *prop_highlight = NULL;
+ if (!RNA_pointer_is_null(ptr_highlight)) {
+ prop_highlight = RNA_struct_find_property(ptr_highlight, propname_highlight);
+ if (!prop_highlight) {
+ RNA_warning("property not found: %s.%s",
+ RNA_struct_identifier(ptr_highlight->type),
+ propname_highlight);
+ return;
+ }
+ if (RNA_property_type(prop_highlight) != PROP_BOOLEAN) {
+ RNA_warning("property is not a boolean: %s.%s",
+ RNA_struct_identifier(ptr_highlight->type),
+ propname_highlight);
+ return;
+ }
+ if (!RNA_property_array_check(prop_highlight)) {
+ RNA_warning("property is not an array: %s.%s",
+ RNA_struct_identifier(ptr_highlight->type),
+ propname_highlight);
+ return;
+ }
+ }
+
+ uiItemTabsEnumR_prop(layout, C, ptr, prop, ptr_highlight, prop_highlight, icon_only);
}
static void rna_uiItemEnumR_string(uiLayout *layout,
@@ -929,6 +958,11 @@ void RNA_api_ui_layout(StructRNA *srna)
func = RNA_def_function(srna, "prop_tabs_enum", "rna_uiItemTabsEnumR");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
api_ui_item_rna_common(func);
+ parm = RNA_def_pointer(
+ func, "data_highlight", "AnyType", "", "Data from which to take highlight property");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
+ parm = RNA_def_string(
+ func, "property_highlight", NULL, 0, "", "Identifier of highlight property in data");
RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text");
func = RNA_def_function(srna, "prop_enum", "rna_uiItemEnumR_string");
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 8d36b7dc08f..2b04a2328ad 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -78,7 +78,7 @@ const EnumPropertyItem rna_enum_preference_section_items[] = {
{USER_SECTION_ANIMATION, "ANIMATION", 0, "Animation", ""},
{0, "", 0, NULL, NULL},
{USER_SECTION_ADDONS, "ADDONS", 0, "Add-ons", ""},
-#if 0 // def WITH_USERDEF_WORKSPACES
+#if 0 /* def WITH_USERDEF_WORKSPACES */
{0, "", 0, NULL, NULL},
{USER_SECTION_WORKSPACE_CONFIG, "WORKSPACE_CONFIG", 0, "Configuration File", ""},
{USER_SECTION_WORKSPACE_ADDONS, "WORKSPACE_ADDONS", 0, "Add-on Overrides", ""},
@@ -2893,7 +2893,7 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "noodle_curving");
RNA_def_property_int_default(prop, 5);
RNA_def_property_range(prop, 0, 10);
- RNA_def_property_ui_text(prop, "Noodle curving", "Curving of the noodle");
+ RNA_def_property_ui_text(prop, "Noodle Curving", "Curving of the noodle");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "grid_levels", PROP_INT, PROP_NONE);
@@ -2901,7 +2901,7 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna)
RNA_def_property_int_default(prop, 2);
RNA_def_property_range(prop, 0, 2);
RNA_def_property_ui_text(
- prop, "Grid levels", "Amount of grid lines displayed in the background");
+ prop, "Grid Levels", "Amount of grid lines displayed in the background");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "input_node", PROP_FLOAT, PROP_COLOR_GAMMA);
@@ -6178,6 +6178,11 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_tools_missing_icons", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_tools_missing_icons", 1);
RNA_def_property_ui_text(prop, "Tools with Missing Icons", "Show tools with missing icons");
+
+ prop = RNA_def_property(srna, "use_sculpt_tools_tilt", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "use_sculpt_tools_tilt", 1);
+ RNA_def_property_ui_text(
+ prop, "Sculpt Mode Tilt Support", "Support for pen tablet tilt events in Sculpt Mode");
}
static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop)
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 943e628c09e..7700c8bbff9 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -96,7 +96,8 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
return !bmd->object || bmd->object->type != OB_MESH;
}
if (bmd->flag & eBooleanModifierFlag_Collection) {
- return !col;
+ /* The Exact solver tolerates an empty collection. */
+ return !col && bmd->solver != eBooleanModifierSolver_Exact;
}
return false;
}
@@ -426,22 +427,25 @@ static Mesh *collection_boolean_exact(BooleanModifierData *bmd,
BLI_array_append(meshes, mesh);
BLI_array_append(objects, ctx->object);
Mesh *col_mesh;
- FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (col, ob) {
- if (ob->type == OB_MESH && ob != ctx->object) {
- col_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob, false);
- /* XXX This is utterly non-optimal, we may go from a bmesh to a mesh back to a bmesh!
- * But for 2.90 better not try to be smart here. */
- BKE_mesh_wrapper_ensure_mdata(col_mesh);
- BLI_array_append(meshes, col_mesh);
- BLI_array_append(objects, ob);
- bat.totvert += col_mesh->totvert;
- bat.totedge += col_mesh->totedge;
- bat.totloop += col_mesh->totloop;
- bat.totface += col_mesh->totpoly;
- ++num_shapes;
+ /* Allow col to be empty: then target mesh will just remove self-intersections. */
+ if (col) {
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (col, ob) {
+ if (ob->type == OB_MESH && ob != ctx->object) {
+ col_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob, false);
+ /* XXX This is utterly non-optimal, we may go from a bmesh to a mesh back to a bmesh!
+ * But for 2.90 better not try to be smart here. */
+ BKE_mesh_wrapper_ensure_mdata(col_mesh);
+ BLI_array_append(meshes, col_mesh);
+ BLI_array_append(objects, ob);
+ bat.totvert += col_mesh->totvert;
+ bat.totedge += col_mesh->totedge;
+ bat.totloop += col_mesh->totloop;
+ bat.totface += col_mesh->totpoly;
+ ++num_shapes;
+ }
}
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
- FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
int *shape_face_end = MEM_mallocN(num_shapes * sizeof(int), __func__);
int *shape_vert_end = MEM_mallocN(num_shapes * sizeof(int), __func__);
bool is_neg_mat0 = is_negative_m4(ctx->object->obmat);
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index bf7b6493a36..2532afc933e 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -235,13 +235,13 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
PointerRNA ob_ptr;
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
- uiLayoutSetPropSep(layout, true);
-
int decimate_type = RNA_enum_get(ptr, "decimate_type");
char count_info[32];
snprintf(count_info, 32, "%s: %d", IFACE_("Face Count"), RNA_int_get(ptr, "face_count"));
- uiItemR(layout, ptr, "decimate_type", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "decimate_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+
+ uiLayoutSetPropSep(layout, true);
if (decimate_type == MOD_DECIM_MODE_COLLAPSE) {
uiItemR(layout, ptr, "ratio", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
@@ -268,7 +268,8 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
}
else { /* decimate_type == MOD_DECIM_MODE_DISSOLVE. */
uiItemR(layout, ptr, "angle_limit", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "delimit", 0, NULL, ICON_NONE);
+ uiLayout *col = uiLayoutColumn(layout, false);
+ uiItemR(col, ptr, "delimit", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "use_dissolve_boundaries", 0, NULL, ICON_NONE);
}
uiItemL(layout, count_info, ICON_NONE);
diff --git a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
index 6fdc78c6ce9..508c84c3e8f 100644
--- a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
+++ b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
@@ -181,20 +181,18 @@ static float compute_voxel_size(const MeshToVolumeModifierData *mvmd,
{
using namespace blender;
if (mvmd->resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_SIZE) {
- return MAX2(0.0001, mvmd->voxel_size);
+ return mvmd->voxel_size;
+ }
+ if (mvmd->voxel_amount <= 0) {
+ return 0;
}
-
/* Compute the voxel size based on the desired number of voxels and the approximated bounding box
* of the volume. */
const BoundBox *bb = BKE_object_boundbox_get(mvmd->object);
- const float3 x_axis = float3(bb->vec[4]) - float3(bb->vec[0]);
- const float3 y_axis = float3(bb->vec[3]) - float3(bb->vec[0]);
- const float3 z_axis = float3(bb->vec[1]) - float3(bb->vec[0]);
- const float max_dimension = std::max({(transform.ref_3x3() * x_axis).length(),
- (transform.ref_3x3() * y_axis).length(),
- (transform.ref_3x3() * z_axis).length()});
- const float approximate_volume_side_length = max_dimension + mvmd->exterior_band_width * 2.0f;
- const float voxel_size = approximate_volume_side_length / MAX2(1, mvmd->voxel_amount);
+ const float diagonal = float3::distance(transform * float3(bb->vec[6]),
+ transform * float3(bb->vec[0]));
+ const float approximate_volume_side_length = diagonal + mvmd->exterior_band_width * 2.0f;
+ const float voxel_size = approximate_volume_side_length / mvmd->voxel_amount;
return voxel_size;
}
@@ -218,6 +216,9 @@ static Volume *modifyVolume(ModifierData *md, const ModifierEvalContext *ctx, Vo
const float4x4 mesh_to_own_object_space_transform = float4x4(ctx->object->imat) *
float4x4(object_to_convert->obmat);
const float voxel_size = compute_voxel_size(mvmd, mesh_to_own_object_space_transform);
+ if (voxel_size == 0.0f) {
+ return input_volume;
+ }
float4x4 mesh_to_index_space_transform;
scale_m4_fl(mesh_to_index_space_transform.values, 1.0f / voxel_size);
diff --git a/source/blender/modifiers/intern/MOD_volume_displace.cc b/source/blender/modifiers/intern/MOD_volume_displace.cc
index 89b5a604d58..18ecefda881 100644
--- a/source/blender/modifiers/intern/MOD_volume_displace.cc
+++ b/source/blender/modifiers/intern/MOD_volume_displace.cc
@@ -62,7 +62,7 @@ static void initData(ModifierData *md)
{
VolumeDisplaceModifierData *vdmd = reinterpret_cast<VolumeDisplaceModifierData *>(md);
vdmd->texture = NULL;
- vdmd->strength = 1.0f;
+ vdmd->strength = 0.5f;
copy_v3_fl(vdmd->texture_mid_level, 0.5f);
vdmd->texture_sample_radius = 1.0f;
}
@@ -136,18 +136,17 @@ static void panelRegister(ARegionType *region_type)
static openvdb::Mat4s matrix_to_openvdb(const float m[4][4])
{
- /* This constructor expects floats in row-major form. Therefore the matrix is transposed
- * afterwards. */
+ /* OpenVDB matrices are transposed Blender matrices, i.e. the translation is in the last row
+ * instead of in the last column. However, the layout in memory is the same, because OpenVDB
+ * matrices are row major (compared to Blender's column major matrices). */
openvdb::Mat4s new_matrix{reinterpret_cast<const float *>(m)};
- new_matrix = new_matrix.transpose();
return new_matrix;
}
template<typename GridType> struct DisplaceOp {
/* Has to be copied for each thread. */
typename GridType::ConstAccessor accessor;
- /* This is the transform of the grid that is being displaced. */
- openvdb::Mat4s index_to_texture;
+ const openvdb::Mat4s index_to_texture;
Tex *texture;
const double strength;
@@ -167,9 +166,11 @@ template<typename GridType> struct DisplaceOp {
openvdb::Vec3d compute_displace_vector(const openvdb::Coord &coord) const
{
if (this->texture != NULL) {
- const openvdb::Vec3f texture_pos = this->index_to_texture * coord.asVec3s();
- openvdb::Vec3d displace_vector = this->evaluate_texture(texture_pos);
- return (displace_vector - this->texture_mid_level) * this->strength;
+ const openvdb::Vec3f texture_pos = coord.asVec3s() * this->index_to_texture;
+ const openvdb::Vec3d texture_value = this->evaluate_texture(texture_pos);
+ const openvdb::Vec3d displacement = (texture_value - this->texture_mid_level) *
+ this->strength;
+ return displacement;
}
return openvdb::Vec3d{0, 0, 0};
}
@@ -185,9 +186,8 @@ template<typename GridType> struct DisplaceOp {
static float get_max_voxel_side_length(const openvdb::GridBase &grid)
{
- const openvdb::Mat3d matrix = grid.transform().baseMap()->getAffineMap()->getMat4().getMat3();
- const float max_voxel_side_length = std::max(
- {matrix.col(0).length(), matrix.col(1).length(), matrix.col(2).length()});
+ const openvdb::Vec3d voxel_size = grid.voxelSize();
+ const float max_voxel_side_length = std::max({voxel_size[0], voxel_size[1], voxel_size[2]});
return max_voxel_side_length;
}
@@ -266,7 +266,7 @@ struct DisplaceGridOp {
}
case MOD_VOLUME_DISPLACE_MAP_GLOBAL: {
const openvdb::Mat4s object_to_world = matrix_to_openvdb(ctx.object->obmat);
- return object_to_world * index_to_object;
+ return index_to_object * object_to_world;
}
case MOD_VOLUME_DISPLACE_MAP_OBJECT: {
if (vdmd.texture_map_object == NULL) {
@@ -274,9 +274,10 @@ struct DisplaceGridOp {
}
const openvdb::Mat4s object_to_world = matrix_to_openvdb(ctx.object->obmat);
const openvdb::Mat4s world_to_texture = matrix_to_openvdb(vdmd.texture_map_object->imat);
- return world_to_texture * object_to_world * index_to_object;
+ return index_to_object * object_to_world * world_to_texture;
}
}
+ BLI_assert(false);
return {};
}
};
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 6a963b4c043..4c8b511f19a 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -62,7 +62,7 @@
static void initData(ModifierData *md)
{
- WaveModifierData *wmd = (WaveModifierData *)md; // whadya know, moved here from Iraq
+ WaveModifierData *wmd = (WaveModifierData *)md;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(wmd, modifier));
diff --git a/source/blender/modifiers/intern/MOD_weld.c b/source/blender/modifiers/intern/MOD_weld.c
index 306e093919a..1a25c24fedc 100644
--- a/source/blender/modifiers/intern/MOD_weld.c
+++ b/source/blender/modifiers/intern/MOD_weld.c
@@ -1687,9 +1687,9 @@ static Mesh *weldModifier_doWeld(WeldModifierData *wmd, const ModifierEvalContex
}
#else
{
- KDTree_3d *tree = BLI_kdtree_3d_new(totvert);
+ KDTree_3d *tree = BLI_kdtree_3d_new(v_mask ? v_mask_act : totvert);
for (uint i = 0; i < totvert; i++) {
- if (!(v_mask && !BLI_BITMAP_TEST(v_mask, i))) {
+ if (!v_mask || BLI_BITMAP_TEST(v_mask, i)) {
BLI_kdtree_3d_insert(tree, i, mvert[i].co);
}
vert_dest_map[i] = OUT_OF_CONTEXT;
@@ -1697,7 +1697,7 @@ static Mesh *weldModifier_doWeld(WeldModifierData *wmd, const ModifierEvalContex
BLI_kdtree_3d_balance(tree);
vert_kill_len = BLI_kdtree_3d_calc_duplicates_fast(
- tree, wmd->merge_dist, true, (int *)vert_dest_map);
+ tree, wmd->merge_dist, false, (int *)vert_dest_map);
BLI_kdtree_3d_free(tree);
}
#endif
diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.c b/source/blender/nodes/composite/nodes/node_composite_tonemap.c
index 1048ac1b167..5fc86c997f5 100644
--- a/source/blender/nodes/composite/nodes/node_composite_tonemap.c
+++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.c
@@ -40,9 +40,9 @@ static void node_composit_init_tonemap(bNodeTree *UNUSED(ntree), bNode *node)
ntm->offset = 1;
ntm->gamma = 1;
ntm->f = 0;
- ntm->m = 0; // actual value is set according to input
- // default a of 1 works well with natural HDR images, but not always so for cgi.
- // Maybe should use 0 or at least lower initial value instead
+ ntm->m = 0; /* Actual value is set according to input. */
+ /* Default a of 1 works well with natural HDR images, but not always so for CGI.
+ * Maybe should use 0 or at least lower initial value instead. */
ntm->a = 1;
ntm->c = 0;
node->storage = ntm;
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
index 6632f9ae3cd..46b4dbc96d7 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -68,8 +68,7 @@ void BPY_thread_restore(BPy_ThreadStatePtr tstate);
(void)0
void BPY_text_free_code(struct Text *text);
-void BPY_modules_update(
- struct bContext *C); // XXX - annoying, need this for pointers that get out of date
+void BPY_modules_update(void);
void BPY_modules_load_user(struct bContext *C);
void BPY_app_handlers_reset(const short do_all);
diff --git a/source/blender/python/BPY_extern_python.h b/source/blender/python/BPY_extern_python.h
index 70b5cd679b9..c321fd93379 100644
--- a/source/blender/python/BPY_extern_python.h
+++ b/source/blender/python/BPY_extern_python.h
@@ -32,7 +32,7 @@ extern "C" {
#include <stdio.h>
/* bpy_interface.c */
-void BPY_python_start(int argc, const char **argv);
+void BPY_python_start(struct bContext *C, int argc, const char **argv);
void BPY_python_end(void);
void BPY_python_reset(struct bContext *C);
void BPY_python_use_system_env(void);
diff --git a/source/blender/python/bmesh/bmesh_py_api.c b/source/blender/python/bmesh/bmesh_py_api.c
index c6fd4bf0644..6dcf8bc5f1c 100644
--- a/source/blender/python/bmesh/bmesh_py_api.c
+++ b/source/blender/python/bmesh/bmesh_py_api.c
@@ -201,8 +201,7 @@ PyObject *BPyInit_bmesh(void)
/* bmesh.ops (not a real module, exposes module like access). */
PyModule_AddObject(mod, "ops", (submodule = BPyInit_bmesh_ops()));
- /* PyDict_SetItemString(sys_modules, PyModule_GetNameObject(submodule), submodule); */
- PyDict_SetItemString(sys_modules, "bmesh.ops", submodule); /* fake module */
+ PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
PyModule_AddObject(mod, "utils", (submodule = BPyInit_bmesh_utils()));
PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c
index cdbd4832159..2168e0d1730 100644
--- a/source/blender/python/bmesh/bmesh_py_ops.c
+++ b/source/blender/python/bmesh/bmesh_py_ops.c
@@ -240,10 +240,10 @@ static PyTypeObject bmesh_op_Type = {
NULL,
};
-/* bmesh fake module 'bmesh.ops'
- * ***************************** */
+/* bmesh module 'bmesh.ops'
+ * ************************ */
-static PyObject *bpy_bmesh_ops_fakemod_getattro(PyObject *UNUSED(self), PyObject *pyname)
+static PyObject *bpy_bmesh_ops_module_getattro(PyObject *UNUSED(self), PyObject *pyname)
{
const char *opname = _PyUnicode_AsString(pyname);
@@ -255,7 +255,7 @@ static PyObject *bpy_bmesh_ops_fakemod_getattro(PyObject *UNUSED(self), PyObject
return NULL;
}
-static PyObject *bpy_bmesh_ops_fakemod_dir(PyObject *UNUSED(self))
+static PyObject *bpy_bmesh_ops_module_dir(PyObject *UNUSED(self))
{
const uint tot = bmo_opdefines_total;
uint i;
@@ -270,107 +270,32 @@ static PyObject *bpy_bmesh_ops_fakemod_dir(PyObject *UNUSED(self))
return ret;
}
-static struct PyMethodDef bpy_bmesh_ops_fakemod_methods[] = {
- {"__dir__", (PyCFunction)bpy_bmesh_ops_fakemod_dir, METH_NOARGS, NULL},
+static struct PyMethodDef BPy_BM_ops_methods[] = {
+ {"__getattr__", (PyCFunction)bpy_bmesh_ops_module_getattro, METH_O, NULL},
+ {"__dir__", (PyCFunction)bpy_bmesh_ops_module_dir, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL},
};
-static PyTypeObject bmesh_ops_fakemod_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "BMeshOpsModule", /* tp_name */
- 0, /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- NULL, /* tp_dealloc */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- NULL,
- /* tp_compare */ /* DEPRECATED in python 3.0! */
- NULL, /* tp_repr */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- NULL, /* PySequenceMethods *tp_as_sequence; */
- NULL, /* PyMappingMethods *tp_as_mapping; */
-
- /* More standard operations (here for binary compatibility) */
-
- NULL, /* hashfunc tp_hash; */
- NULL, /* ternaryfunc tp_call; */
- NULL, /* reprfunc tp_str; */
-
- /* will only use these if this is a subtype of a py class */
- bpy_bmesh_ops_fakemod_getattro, /* getattrofunc tp_getattro; */
- NULL, /* setattrofunc tp_setattro; */
-
- /* Functions to access object as input/output buffer */
- NULL, /* PyBufferProcs *tp_as_buffer; */
-
- /*** Flags to define presence of optional/expanded features ***/
- Py_TPFLAGS_DEFAULT, /* long tp_flags; */
-
- NULL, /* char *tp_doc; Documentation string */
- /*** Assigned meaning in release 2.0 ***/
- /* call function for all accessible objects */
- NULL, /* traverseproc tp_traverse; */
-
- /* delete references to contained objects */
- NULL, /* inquiry tp_clear; */
-
- /*** Assigned meaning in release 2.1 ***/
- /*** rich comparisons (subclassed) ***/
- NULL, /* richcmpfunc tp_richcompare; */
-
- /*** weak reference enabler ***/
- 0,
- /*** Added in release 2.2 ***/
- /* Iterators */
- NULL, /* getiterfunc tp_iter; */
- NULL, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- bpy_bmesh_ops_fakemod_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- NULL, /* struct PyGetSetDef *tp_getset; */
- NULL, /* struct _typeobject *tp_base; */
- NULL, /* PyObject *tp_dict; */
- NULL, /* descrgetfunc tp_descr_get; */
- NULL, /* descrsetfunc tp_descr_set; */
- 0, /* long tp_dictoffset; */
- NULL, /* initproc tp_init; */
- NULL, /* allocfunc tp_alloc; */
- NULL, /* newfunc tp_new; */
- /* Low-level free-memory routine */
- NULL, /* freefunc tp_free; */
- /* For PyObject_IS_GC */
- NULL, /* inquiry tp_is_gc; */
- NULL, /* PyObject *tp_bases; */
- /* method resolution order */
- NULL, /* PyObject *tp_mro; */
- NULL, /* PyObject *tp_cache; */
- NULL, /* PyObject *tp_subclasses; */
- NULL, /* PyObject *tp_weaklist; */
- NULL,
+PyDoc_STRVAR(BPy_BM_ops_doc, "Access to BMesh operators");
+static struct PyModuleDef BPy_BM_ops_module_def = {
+ PyModuleDef_HEAD_INIT,
+ "bmesh.ops", /* m_name */
+ BPy_BM_ops_doc, /* m_doc */
+ 0, /* m_size */
+ BPy_BM_ops_methods, /* m_methods */
+ NULL, /* m_reload */
+ NULL, /* m_traverse */
+ NULL, /* m_clear */
+ NULL, /* m_free */
};
PyObject *BPyInit_bmesh_ops(void)
{
- PyObject *submodule;
-
- if (PyType_Ready(&bmesh_ops_fakemod_Type) < 0) {
- return NULL;
- }
+ PyObject *submodule = PyModule_Create(&BPy_BM_ops_module_def);
if (PyType_Ready(&bmesh_op_Type) < 0) {
return NULL;
}
- submodule = PyObject_New(PyObject, &bmesh_ops_fakemod_Type);
-
- /* prevent further creation of instances */
- bmesh_ops_fakemod_Type.tp_init = NULL;
- bmesh_ops_fakemod_Type.tp_new = NULL;
-
return submodule;
}
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index a74be2b580e..96c36f2d788 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -98,7 +98,7 @@ PyDoc_STRVAR(bpy_bmlayeraccess_collection__string_doc,
":class:`BMLayerCollection`");
PyDoc_STRVAR(bpy_bmlayeraccess_collection__deform_doc,
"Vertex deform weight :class:`BMDeformVert` (TODO).\n\ntype: "
- ":class:`BMLayerCollection`" // TYPE DOESN'T EXIST YET
+ ":class:`BMLayerCollection`" /* TYPE DOESN'T EXIST YET */
);
PyDoc_STRVAR(
bpy_bmlayeraccess_collection__shape_doc,
diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
index 8214be3bd73..c43e5bb4d97 100644
--- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
@@ -120,7 +120,7 @@ static void bm_init_types_bmloopuv(void)
BPy_BMLoopUV_Type.tp_name = "BMLoopUV";
- BPy_BMLoopUV_Type.tp_doc = NULL; // todo
+ BPy_BMLoopUV_Type.tp_doc = NULL; /* todo */
BPy_BMLoopUV_Type.tp_getset = bpy_bmloopuv_getseters;
@@ -233,7 +233,7 @@ static void bm_init_types_bmvertskin(void)
BPy_BMVertSkin_Type.tp_name = "BMVertSkin";
- BPy_BMVertSkin_Type.tp_doc = NULL; // todo
+ BPy_BMVertSkin_Type.tp_doc = NULL; /* todo */
BPy_BMVertSkin_Type.tp_getset = bpy_bmvertskin_getseters;
@@ -645,7 +645,7 @@ static void bm_init_types_bmdvert(void)
BPy_BMDeformVert_Type.tp_name = "BMDeformVert";
- BPy_BMDeformVert_Type.tp_doc = NULL; // todo
+ BPy_BMDeformVert_Type.tp_doc = NULL; /* todo */
BPy_BMDeformVert_Type.tp_as_sequence = &bpy_bmdeformvert_as_sequence;
BPy_BMDeformVert_Type.tp_as_mapping = &bpy_bmdeformvert_as_mapping;
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 8a5c4f4a11b..e9a58288c5e 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -29,6 +29,8 @@
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"
+#include "GPU_state.h"
+
#include "../generic/py_capi_utils.h"
#include "glew-mx.h"
@@ -1109,6 +1111,7 @@ static PyObject *Buffer_repr(Buffer *self)
if (!PyArg_ParseTuple(args, arg_str arg_list, arg_ref arg_list)) { \
return NULL; \
} \
+ GPU_bgl_start(); \
ret_set_##ret gl##funcname(arg_var arg_list); \
ret_ret_##ret; \
}
diff --git a/source/blender/python/generic/bpy_threads.c b/source/blender/python/generic/bpy_threads.c
index 1aa36a0e685..bd707f728a1 100644
--- a/source/blender/python/generic/bpy_threads.c
+++ b/source/blender/python/generic/bpy_threads.c
@@ -29,14 +29,11 @@
/* analogue of PyEval_SaveThread() */
BPy_ThreadStatePtr BPY_thread_save(void)
{
- PyThreadState *tstate = PyThreadState_Swap(NULL);
- /* note: tstate can be NULL when quitting Blender */
-
- if (tstate && PyEval_ThreadsInitialized()) {
- PyEval_ReleaseLock();
+ /* The thread-state can be NULL when quitting Blender. */
+ if (_PyThreadState_UncheckedGet()) {
+ return (BPy_ThreadStatePtr)PyEval_SaveThread();
}
-
- return (BPy_ThreadStatePtr)tstate;
+ return NULL;
}
/* analogue of PyEval_RestoreThread() */
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 1531b2e0a11..6c02e293789 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -646,10 +646,12 @@ PyObject *PyC_ExceptionBuffer(void)
goto error_cleanup;
}
- Py_INCREF(stdout_backup); // since these were borrowed we don't want them freed when replaced.
+ /* Since these were borrowed we don't want them freed when replaced. */
+ Py_INCREF(stdout_backup);
Py_INCREF(stderr_backup);
- PySys_SetObject("stdout", string_io); // both of these are freed when restoring
+ /* Both of these are freed when restoring. */
+ PySys_SetObject("stdout", string_io);
PySys_SetObject("stderr", string_io);
PyErr_Restore(error_type, error_value, error_traceback);
@@ -887,7 +889,7 @@ void PyC_MainModule_Restore(PyObject *main_mod)
* - Must be called before #Py_Initialize.
* - Expects output of `BKE_appdir_folder_id(BLENDER_PYTHON, NULL)`.
* - Note that the `PYTHONPATH` environment variable isn't reliable, see T31506.
- Use #Py_SetPythonHome instead.
+ * Use #Py_SetPythonHome instead.
*/
void PyC_SetHomePath(const char *py_path_bundle)
{
diff --git a/source/blender/python/gpu/gpu_py_api.c b/source/blender/python/gpu/gpu_py_api.c
index da7674eb7f9..33130291162 100644
--- a/source/blender/python/gpu/gpu_py_api.c
+++ b/source/blender/python/gpu/gpu_py_api.c
@@ -106,19 +106,8 @@ success:
* \{ */
PyDoc_STRVAR(GPU_doc,
- "This module provides Python wrappers for the GPU implementation in Blender. "
- "Some higher level functions can be found in the `gpu_extras` module. "
- "\n\n"
- "Submodules:\n"
- "\n"
- ".. toctree::\n"
- " :maxdepth: 1\n"
- "\n"
- " gpu.types.rst\n"
- " gpu.shader.rst\n"
- " gpu.matrix.rst\n"
- " gpu.select.rst\n"
- "\n");
+ "This module provides Python wrappers for the GPU implementation in Blender.\n"
+ "Some higher level functions can be found in the `gpu_extras` module.");
static struct PyModuleDef GPU_module_def = {
PyModuleDef_HEAD_INIT,
.m_name = "gpu",
diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c
index 60b78b51890..81d1cb7055d 100644
--- a/source/blender/python/gpu/gpu_py_batch.c
+++ b/source/blender/python/gpu/gpu_py_batch.c
@@ -172,8 +172,8 @@ PyDoc_STRVAR(
"\n"
" Assign a shader to this batch that will be used for drawing when not overwritten later.\n"
" Note: This method has to be called in the draw context that the batch will be drawn in.\n"
- " This function does not need to be called when you always set the shader when calling "
- "`batch.draw`.\n"
+ " This function does not need to be called when you always\n"
+ " set the shader when calling :meth:`gpu.types.GPUBatch.draw`.\n"
"\n"
" :param program: The program/shader the batch will use in future draw calls.\n"
" :type program: :class:`gpu.types.GPUShader`\n");
diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c
index 31440dadd03..d6548834f2d 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.c
+++ b/source/blender/python/gpu/gpu_py_offscreen.c
@@ -140,8 +140,8 @@ PyDoc_STRVAR(
".. method:: bind(save=True)\n"
"\n"
" Bind the offscreen object.\n"
- " To make sure that the offscreen gets unbind whether an exception occurs or not, pack it "
- "into a `with` statement.\n"
+ " To make sure that the offscreen gets unbind whether an exception occurs or not,\n"
+ " pack it into a `with` statement.\n"
"\n"
" :arg save: Save the current OpenGL state, so that it can be restored when unbinding.\n"
" :type save: `bool`\n");
diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c
index 55753e91f14..3748691c434 100644
--- a/source/blender/python/gpu/gpu_py_shader.c
+++ b/source/blender/python/gpu/gpu_py_shader.c
@@ -231,15 +231,13 @@ PyDoc_STRVAR(bpygpu_shader_uniform_vector_float_doc,
" :type location: int\n"
" :param buffer: The data that should be set. Can support the buffer protocol.\n"
" :type buffer: sequence of floats\n"
- " :param length: Size of the uniform data type:\n"
- "\n"
+ " :param length: Size of the uniform data type:\n\n"
" - 1: float\n"
" - 2: vec2 or float[2]\n"
" - 3: vec3 or float[3]\n"
" - 4: vec4 or float[4]\n"
" - 9: mat3\n"
" - 16: mat4\n"
- "\n"
" :type length: int\n"
" :param count: Specifies the number of elements, vector or matrices that are to "
"be modified.\n"
@@ -597,22 +595,20 @@ PyDoc_STRVAR(
" GPUShader combines multiple GLSL shaders into a program used for drawing.\n"
" It must contain a vertex and fragment shaders, with an optional geometry shader.\n"
"\n"
- " The GLSL #version directive is automatically included at the top of shaders, and set to "
- "330.\n"
- " Some preprocessor directives are automatically added according to the Operating System or "
- "availability:\n"
- " ``GPU_ATI``, ``GPU_NVIDIA`` and ``GPU_INTEL``.\n"
+ " The GLSL ``#version`` directive is automatically included at the top of shaders,\n"
+ " and set to 330. Some preprocessor directives are automatically added according to\n"
+ " the Operating System or availability: ``GPU_ATI``, ``GPU_NVIDIA`` and ``GPU_INTEL``.\n"
"\n"
" The following extensions are enabled by default if supported by the GPU:\n"
- " ``GL_ARB_texture_gather``, ``GL_ARB_texture_cube_map_array`` and "
- "``GL_ARB_shader_draw_parameters``.\n"
+ " ``GL_ARB_texture_gather``, ``GL_ARB_texture_cube_map_array``\n"
+ " and ``GL_ARB_shader_draw_parameters``.\n"
"\n"
- " To debug shaders, use the ``--debug-gpu-shaders`` command line option "
- "to see full GLSL shader compilation and linking errors.\n"
+ " To debug shaders, use the ``--debug-gpu-shaders`` command line option\n"
+ " to see full GLSL shader compilation and linking errors.\n"
"\n"
- " For drawing user interface elements and gizmos, use "
- "``fragOutput = blender_srgb_to_framebuffer_space(fragOutput)`` "
- "to transform the output sRGB colors to the frame-buffer color-space."
+ " For drawing user interface elements and gizmos, use\n"
+ " ``fragOutput = blender_srgb_to_framebuffer_space(fragOutput)``\n"
+ " to transform the output sRGB colors to the frame-buffer color-space.\n"
"\n"
" :param vertexcode: Vertex shader code.\n"
" :type vertexcode: str\n"
@@ -655,19 +651,19 @@ PyDoc_STRVAR(bpygpu_shader_from_builtin_doc,
".. function:: from_builtin(shader_name)\n"
"\n"
" Shaders that are embedded in the blender internal code.\n"
- " They all read the uniform 'mat4 ModelViewProjectionMatrix', which can be edited "
- "by the 'gpu.matrix' module.\n"
- " For more details, you can check the shader code with the function "
- "'gpu.shader.code_from_builtin';\n"
+ " They all read the uniform ``mat4 ModelViewProjectionMatrix``,\n"
+ " which can be edited by the :mod:`gpu.matrix` module.\n"
+ " For more details, you can check the shader code with the\n"
+ " :func:`gpu.shader.code_from_builtin` function.\n"
"\n"
- " :param shader_name: One of these builtin shader names: {\n"
- " '2D_UNIFORM_COLOR',\n"
- " '2D_FLAT_COLOR',\n"
- " '2D_SMOOTH_COLOR',\n"
- " '2D_IMAGE',\n"
- " '3D_UNIFORM_COLOR',\n"
- " '3D_FLAT_COLOR',\n"
- " '3D_SMOOTH_COLOR'}\n"
+ " :param shader_name: One of these builtin shader names:\n\n"
+ " - ``2D_UNIFORM_COLOR``\n"
+ " - ``2D_FLAT_COLOR``\n"
+ " - ``2D_SMOOTH_COLOR``\n"
+ " - ``2D_IMAGE``\n"
+ " - ``3D_UNIFORM_COLOR``\n"
+ " - ``3D_FLAT_COLOR``\n"
+ " - ``3D_SMOOTH_COLOR``\n"
" :type shader_name: str\n"
" :return: Shader object corresponding to the given name.\n"
" :rtype: :class:`bpy.types.GPUShader`\n");
@@ -691,14 +687,14 @@ PyDoc_STRVAR(bpygpu_shader_code_from_builtin_doc,
"\n"
" Exposes the internal shader code for query.\n"
"\n"
- " :param shader_name: One of these builtin shader names: {\n"
- " '2D_UNIFORM_COLOR',\n"
- " '2D_FLAT_COLOR',\n"
- " '2D_SMOOTH_COLOR',\n"
- " '2D_IMAGE',\n"
- " '3D_UNIFORM_COLOR',\n"
- " '3D_FLAT_COLOR',\n"
- " '3D_SMOOTH_COLOR'}\n"
+ " :param shader_name: One of these builtin shader names:\n\n"
+ " - ``2D_UNIFORM_COLOR``\n"
+ " - ``2D_FLAT_COLOR``\n"
+ " - ``2D_SMOOTH_COLOR``\n"
+ " - ``2D_IMAGE``\n"
+ " - ``3D_UNIFORM_COLOR``\n"
+ " - ``3D_FLAT_COLOR``\n"
+ " - ``3D_SMOOTH_COLOR``\n"
" :type shader_name: str\n"
" :return: Vertex, fragment and geometry shader codes.\n"
" :rtype: dict\n");
@@ -752,7 +748,34 @@ static struct PyMethodDef bpygpu_shader_module_methods[] = {
};
PyDoc_STRVAR(bpygpu_shader_module_doc,
- "This module provides access to GPUShader internal functions.");
+ "This module provides access to GPUShader internal functions.\n"
+ "\n"
+ ".. rubric:: Built-in shaders\n"
+ "\n"
+ "All built-in shaders have the ``mat4 ModelViewProjectionMatrix`` uniform.\n"
+ "The value of it can only be modified using the :class:`gpu.matrix` module.\n"
+ "\n"
+ "2D_UNIFORM_COLOR\n"
+ " :Attributes: vec3 pos\n"
+ " :Uniforms: vec4 color\n"
+ "2D_FLAT_COLOR\n"
+ " :Attributes: vec3 pos, vec4 color\n"
+ " :Uniforms: none\n"
+ "2D_SMOOTH_COLOR\n"
+ " :Attributes: vec3 pos, vec4 color\n"
+ " :Uniforms: none\n"
+ "2D_IMAGE\n"
+ " :Attributes: vec3 pos, vec2 texCoord\n"
+ " :Uniforms: sampler2D image\n"
+ "3D_UNIFORM_COLOR\n"
+ " :Attributes: vec3 pos\n"
+ " :Uniforms: vec4 color\n"
+ "3D_FLAT_COLOR\n"
+ " :Attributes: vec3 pos, vec4 color\n"
+ " :Uniforms: none\n"
+ "3D_SMOOTH_COLOR\n"
+ " :Attributes: vec3 pos, vec4 color\n"
+ " :Uniforms: none\n");
static PyModuleDef BPyGPU_shader_module_def = {
PyModuleDef_HEAD_INIT,
.m_name = "gpu.shader",
diff --git a/source/blender/python/gpu/gpu_py_vertex_format.c b/source/blender/python/gpu/gpu_py_vertex_format.c
index 1cbcaba6bfb..2d45eadcfe3 100644
--- a/source/blender/python/gpu/gpu_py_vertex_format.c
+++ b/source/blender/python/gpu/gpu_py_vertex_format.c
@@ -168,14 +168,13 @@ PyDoc_STRVAR(
" :param comp_type: The data type that will be used store the value in memory.\n"
" Possible values are `I8`, `U8`, `I16`, `U16`, `I32`, `U32`, `F32` and `I10`.\n"
" :type comp_type: `str`\n"
- " :param len: How many individual values the attribute consists of (e.g. 2 for uv "
- "coordinates).\n"
+ " :param len: How many individual values the attribute consists of\n"
+ " (e.g. 2 for uv coordinates).\n"
" :type len: int\n"
" :param fetch_mode: How values from memory will be converted when used in the shader.\n"
- " This is mainly useful for memory optimizations when you want to store values with "
- "reduced precision.\n"
- " E.g. you can store a float in only 1 byte but it will be converted to a normal 4 byte "
- "float when used.\n"
+ " This is mainly useful for memory optimizations when you want to store values with\n"
+ " reduced precision. E.g. you can store a float in only 1 byte but it will be\n"
+ " converted to a normal 4 byte float when used.\n"
" Possible values are `FLOAT`, `INT`, `INT_TO_FLOAT_UNIT` and `INT_TO_FLOAT`.\n"
" :type fetch_mode: `str`\n");
static PyObject *bpygpu_VertFormat_attr_add(BPyGPUVertFormat *self, PyObject *args, PyObject *kwds)
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index de8fd87db58..804a28d0ebc 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -35,6 +35,8 @@
#include "RNA_access.h"
#include "RNA_types.h"
+#include "GPU_state.h"
+
#include "bpy.h"
#include "bpy_app.h"
#include "bpy_capi_utils.h"
@@ -145,7 +147,7 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
return list;
}
-// PyDoc_STRVAR(bpy_user_resource_doc[] = // now in bpy/utils.py
+// PyDoc_STRVAR(bpy_user_resource_doc[] = /* now in bpy/utils.py */
static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
const struct PyC_StringEnumItems type_items[] = {
@@ -330,6 +332,9 @@ static PyMethodDef meth_bpy_escape_identifier = {
static PyObject *bpy_import_test(const char *modname)
{
PyObject *mod = PyImport_ImportModuleLevel(modname, NULL, NULL, NULL, 0);
+
+ GPU_bgl_end();
+
if (mod) {
Py_DECREF(mod);
}
@@ -344,7 +349,7 @@ static PyObject *bpy_import_test(const char *modname)
/******************************************************************************
* Description: Creates the bpy module and adds it to sys.modules for importing
******************************************************************************/
-void BPy_init_modules(void)
+void BPy_init_modules(struct bContext *C)
{
PointerRNA ctx_ptr;
PyObject *mod;
@@ -395,8 +400,7 @@ void BPy_init_modules(void)
PyModule_AddObject(mod, "_utils_previews", BPY_utils_previews_module());
PyModule_AddObject(mod, "msgbus", BPY_msgbus_module());
- /* bpy context */
- RNA_pointer_create(NULL, &RNA_Context, (void *)BPy_GetContext(), &ctx_ptr);
+ RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr);
bpy_context_module = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ctx_ptr);
/* odd that this is needed, 1 ref on creation and another for the module
* but without we get a crash on exit */
diff --git a/source/blender/python/intern/bpy.h b/source/blender/python/intern/bpy.h
index 744bf903443..e2fe84f71c7 100644
--- a/source/blender/python/intern/bpy.h
+++ b/source/blender/python/intern/bpy.h
@@ -24,7 +24,9 @@
extern "C" {
#endif
-void BPy_init_modules(void);
+struct bContext;
+
+void BPy_init_modules(struct bContext *C);
extern PyObject *bpy_package_py;
/* bpy_interface_atexit.c */
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index 88ae0e92647..554ab2645a7 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -126,17 +126,7 @@ static PyStructSequence_Field app_info_fields[] = {
};
PyDoc_STRVAR(bpy_app_doc,
- "This module contains application values that remain unchanged during runtime.\n"
- "\n"
- "Submodules:\n"
- "\n"
- ".. toctree::\n"
- " :maxdepth: 1\n"
- "\n"
- " bpy.app.handlers.rst\n"
- " bpy.app.icons.rst\n"
- " bpy.app.timers.rst\n"
- " bpy.app.translations.rst\n");
+ "This module contains application values that remain unchanged during runtime.");
static PyStructSequence_Desc app_info_desc = {
"bpy.app", /* name */
diff --git a/source/blender/python/intern/bpy_app_ffmpeg.c b/source/blender/python/intern/bpy_app_ffmpeg.c
index fdd09be508a..4e396668450 100644
--- a/source/blender/python/intern/bpy_app_ffmpeg.c
+++ b/source/blender/python/intern/bpy_app_ffmpeg.c
@@ -75,7 +75,7 @@ static PyObject *make_ffmpeg_info(void)
return NULL;
}
-#if 0 // UNUSED
+#if 0 /* UNUSED */
# define SetIntItem(flag) PyStructSequence_SET_ITEM(ffmpeg_info, pos++, PyLong_FromLong(flag))
#endif
#ifndef WITH_FFMPEG
diff --git a/source/blender/python/intern/bpy_app_sdl.c b/source/blender/python/intern/bpy_app_sdl.c
index c8be2c521d3..645119c1c5d 100644
--- a/source/blender/python/intern/bpy_app_sdl.c
+++ b/source/blender/python/intern/bpy_app_sdl.c
@@ -89,7 +89,7 @@ static PyObject *make_sdl_info(void)
SDL_GetVersion(&version);
sdl_available = true;
}
-# else // WITH_SDL_DYNLOAD=OFF
+# else /* WITH_SDL_DYNLOAD=OFF */
sdl_available = true;
# if SDL_MAJOR_VERSION >= 2
SDL_GetVersion(&version);
@@ -107,7 +107,7 @@ static PyObject *make_sdl_info(void)
}
SetObjItem(PyBool_FromLong(sdl_available));
-#else // WITH_SDL=OFF
+#else /* WITH_SDL=OFF */
SetObjItem(PyBool_FromLong(0));
SetObjItem(PyC_Tuple_Pack_I32(0, 0, 0));
SetStrItem("Unknown");
diff --git a/source/blender/python/intern/bpy_capi_utils.c b/source/blender/python/intern/bpy_capi_utils.c
index 8eb44e918d7..57dc4c0a679 100644
--- a/source/blender/python/intern/bpy_capi_utils.c
+++ b/source/blender/python/intern/bpy_capi_utils.c
@@ -38,16 +38,6 @@
#include "../generic/py_capi_utils.h"
-static bContext *__py_context = NULL;
-bContext *BPy_GetContext(void)
-{
- return __py_context;
-}
-void BPy_SetContext(bContext *C)
-{
- __py_context = C;
-}
-
char *BPy_enum_as_string(const EnumPropertyItem *item)
{
DynStr *dynstr = BLI_dynstr_new();
diff --git a/source/blender/python/intern/bpy_capi_utils.h b/source/blender/python/intern/bpy_capi_utils.h
index 861b23190a2..55f8a291410 100644
--- a/source/blender/python/intern/bpy_capi_utils.h
+++ b/source/blender/python/intern/bpy_capi_utils.h
@@ -48,9 +48,7 @@ bool BPy_errors_to_report_ex(struct ReportList *reports,
bool BPy_errors_to_report_brief_with_prefix(struct ReportList *reports, const char *error_prefix);
bool BPy_errors_to_report(struct ReportList *reports);
-/* TODO - find a better solution! */
-struct bContext *BPy_GetContext(void);
-void BPy_SetContext(struct bContext *C);
+struct bContext *BPY_context_get(void);
extern void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate);
extern void bpy_context_clear(struct bContext *C, const PyGILState_STATE *gilstate);
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index 8ba468f91e8..c0536693f38 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -266,7 +266,7 @@ static void pydriver_error(ChannelDriver *driver)
"\nError in Driver: The following Python expression failed:\n\t'%s'\n\n",
driver->expression);
- // BPy_errors_to_report(NULL); // TODO - reports
+ // BPy_errors_to_report(NULL); /* TODO - reports */
PyErr_Print();
PyErr_Clear();
}
@@ -613,7 +613,7 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
fprintf(
stderr, "\tBPY_driver_eval() - couldn't add variable '%s' to namespace\n", dvar->name);
- // BPy_errors_to_report(NULL); // TODO - reports
+ // BPy_errors_to_report(NULL); /* TODO - reports */
PyErr_Print();
PyErr_Clear();
}
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 0c45a9222ee..49a17bbf1bf 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -91,7 +91,7 @@ static int py_call_level = 0;
/* Set by command line arguments before Python starts. */
static bool py_use_system_env = false;
-// #define TIME_PY_RUN // simple python tests. prints on exit.
+// #define TIME_PY_RUN /* simple python tests. prints on exit. */
#ifdef TIME_PY_RUN
# include "PIL_time.h"
@@ -111,8 +111,8 @@ void BPY_context_update(bContext *C)
return;
}
- BPy_SetContext(C);
- BPY_modules_update(C); /* can give really bad results if this isn't here */
+ BPY_context_set(C);
+ BPY_modules_update(); /* can give really bad results if this isn't here */
}
void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
@@ -155,7 +155,7 @@ void bpy_context_clear(bContext *UNUSED(C), const PyGILState_STATE *gilstate)
/* XXX - Calling classes currently wont store the context :\,
* cant set NULL because of this. but this is very flakey still. */
#if 0
- BPy_SetContext(NULL);
+ BPY_context_set(NULL);
#endif
#ifdef TIME_PY_RUN
@@ -224,7 +224,10 @@ void BPY_text_free_code(Text *text)
}
}
-void BPY_modules_update(bContext *C)
+/**
+ * Needed so the #Main pointer in `bpy.data` doesn't become out of date.
+ */
+void BPY_modules_update(void)
{
#if 0 /* slow, this runs all the time poll, draw etc 100's of time a sec. */
PyObject *mod = PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0);
@@ -234,14 +237,16 @@ void BPY_modules_update(bContext *C)
/* refreshes the main struct */
BPY_update_rna_module();
- if (bpy_context_module) {
- bpy_context_module->ptr.data = (void *)C;
- }
+}
+
+bContext *BPY_context_get(void)
+{
+ return bpy_context_module->ptr.data;
}
void BPY_context_set(bContext *C)
{
- BPy_SetContext(C);
+ bpy_context_module->ptr.data = (void *)C;
}
#ifdef WITH_FLUID
@@ -295,7 +300,7 @@ static struct _inittab bpy_internal_modules[] = {
};
/* call BPY_context_set first */
-void BPY_python_start(int argc, const char **argv)
+void BPY_python_start(bContext *C, int argc, const char **argv)
{
#ifndef WITH_PYTHON_MODULE
PyThreadState *py_tstate = NULL;
@@ -387,7 +392,7 @@ void BPY_python_start(int argc, const char **argv)
#endif
/* bpy.* and lets us import it */
- BPy_init_modules();
+ BPy_init_modules(C);
pyrna_alloc_types();
diff --git a/source/blender/python/intern/bpy_interface_atexit.c b/source/blender/python/intern/bpy_interface_atexit.c
index e69914671dd..8e5a6dc530b 100644
--- a/source/blender/python/intern/bpy_interface_atexit.c
+++ b/source/blender/python/intern/bpy_interface_atexit.c
@@ -34,7 +34,7 @@
static PyObject *bpy_atexit(PyObject *UNUSED(self), PyObject *UNUSED(args), PyObject *UNUSED(kw))
{
/* close down enough of blender at least not to crash */
- struct bContext *C = BPy_GetContext();
+ struct bContext *C = BPY_context_get();
WM_exit_ex(C, false);
diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c
index a3750d348f5..061595a6c5d 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -180,7 +180,7 @@ PyDoc_STRVAR(
" :type relative: bool\n");
static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
- Main *bmain = CTX_data_main(BPy_GetContext());
+ Main *bmain = CTX_data_main(BPY_context_get());
BPy_Library *ret;
const char *filename = NULL;
bool is_rel = false, is_link = false;
@@ -319,7 +319,7 @@ static void bpy_lib_exit_warn_type(BPy_Library *self, PyObject *item)
static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
{
- Main *bmain = CTX_data_main(BPy_GetContext());
+ Main *bmain = CTX_data_main(BPY_context_get());
Main *mainl = NULL;
const int err = 0;
const bool do_append = ((self->flag & FILE_LINK) == 0);
diff --git a/source/blender/python/intern/bpy_msgbus.c b/source/blender/python/intern/bpy_msgbus.c
index 3739f56dc79..df45007b68f 100644
--- a/source/blender/python/intern/bpy_msgbus.c
+++ b/source/blender/python/intern/bpy_msgbus.c
@@ -265,7 +265,7 @@ static PyObject *bpy_msgbus_subscribe_rna(PyObject *UNUSED(self), PyObject *args
}
/* Note: we may want to have a way to pass this in. */
- bContext *C = (bContext *)BPy_GetContext();
+ bContext *C = BPY_context_get();
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
wmMsgParams_RNA msg_key_params = {{0}};
@@ -340,7 +340,7 @@ static PyObject *bpy_msgbus_publish_rna(PyObject *UNUSED(self), PyObject *args,
}
/* Note: we may want to have a way to pass this in. */
- bContext *C = (bContext *)BPy_GetContext();
+ bContext *C = BPY_context_get();
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
wmMsgParams_RNA msg_key_params = {{0}};
@@ -359,7 +359,7 @@ PyDoc_STRVAR(bpy_msgbus_clear_by_owner_doc,
" Clear all subscribers using this owner.\n");
static PyObject *bpy_msgbus_clear_by_owner(PyObject *UNUSED(self), PyObject *py_owner)
{
- bContext *C = (bContext *)BPy_GetContext();
+ bContext *C = BPY_context_get();
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
WM_msgbus_clear_by_owner(mbus, py_owner);
Py_RETURN_NONE;
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 727654e1ac5..8b65bb22889 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -84,7 +84,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
/* XXX Todo, work out a better solution for passing on context,
* could make a tuple from self and pack the name and Context into it... */
- bContext *C = (bContext *)BPy_GetContext();
+ bContext *C = BPY_context_get();
if (C == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
@@ -171,7 +171,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
/* XXX Todo, work out a better solution for passing on context,
* could make a tuple from self and pack the name and Context into it... */
- bContext *C = (bContext *)BPy_GetContext();
+ bContext *C = BPY_context_get();
if (C == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
@@ -339,7 +339,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
* is freed by clear_globals(), further access will crash blender.
* Setting context is not needed in this case, only calling because this
* function corrects bpy.data (internal Main pointer) */
- BPY_modules_update(C);
+ BPY_modules_update();
/* return operator_ret as a bpy enum */
return pyrna_enum_bitfield_to_py(rna_enum_operator_return_items, operator_ret);
@@ -359,7 +359,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
char *buf = NULL;
PyObject *pybuf;
- bContext *C = (bContext *)BPy_GetContext();
+ bContext *C = BPY_context_get();
if (C == NULL) {
PyErr_SetString(PyExc_RuntimeError,
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 1aad07af591..8ad7d84ca2d 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -80,6 +80,11 @@
#define USE_MATHUTILS
#define USE_STRING_COERCE
+/* Unfortunately Python needs to hold a global reference to the context.
+ * If we remove this is means `bpy.context` won't be usable from some parts of the code:
+ * `bpy.app.handler` callbacks for example.
+ * Even though this is arguably "correct", it's going to cause problems for existing scripts,
+ * so accept having this for the time being. */
BPy_StructRNA *bpy_context_module = NULL; /* for fast access */
static PyObject *pyrna_struct_Subtype(PointerRNA *ptr);
@@ -457,7 +462,7 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
RNA_property_float_set_array(&self->ptr, self->prop, bmo->data);
if (RNA_property_update_check(self->prop)) {
- RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
+ RNA_property_update(BPY_context_get(), &self->ptr, self->prop);
}
/* Euler order exception. */
@@ -468,7 +473,7 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
if (order != eul->order) {
RNA_property_enum_set(&self->ptr, prop_eul_order, eul->order);
if (RNA_property_update_check(prop_eul_order)) {
- RNA_property_update(BPy_GetContext(), &self->ptr, prop_eul_order);
+ RNA_property_update(BPY_context_get(), &self->ptr, prop_eul_order);
}
}
}
@@ -517,7 +522,7 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp
RNA_property_float_set_index(&self->ptr, self->prop, index, bmo->data[index]);
if (RNA_property_update_check(self->prop)) {
- RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
+ RNA_property_update(BPY_context_get(), &self->ptr, self->prop);
}
return 0;
@@ -576,7 +581,7 @@ static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype))
RNA_property_float_set_array(&self->ptr, self->prop, bmo->data);
if (RNA_property_update_check(self->prop)) {
- RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
+ RNA_property_update(BPY_context_get(), &self->ptr, self->prop);
}
return 0;
}
@@ -722,7 +727,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
}
else {
/* Order will be updated from callback on use. */
- // TODO, get order from RNA
+ /* TODO, get order from RNA. */
PyObject *eul_cb = Euler_CreatePyObject_cb(
ret, EULER_ORDER_XYZ, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_EUL);
Py_DECREF(ret); /* The euler owns 'ret' now. */
@@ -1229,7 +1234,7 @@ static const char *pyrna_enum_as_string(PointerRNA *ptr, PropertyRNA *prop)
const char *result;
bool free = false;
- RNA_property_enum_items(BPy_GetContext(), ptr, prop, &item, NULL, &free);
+ RNA_property_enum_items(BPY_context_get(), ptr, prop, &item, NULL, &free);
if (item) {
result = BPy_enum_as_string(item);
}
@@ -1257,7 +1262,7 @@ static int pyrna_string_to_enum(
return -1;
}
- if (!RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, r_value)) {
+ if (!RNA_property_enum_value(BPY_context_get(), ptr, prop, param, r_value)) {
const char *enum_str = pyrna_enum_as_string(ptr, prop);
PyErr_Format(PyExc_TypeError,
"%.200s enum \"%.200s\" not found in (%s)",
@@ -1399,7 +1404,7 @@ static int pyrna_prop_to_enum_bitfield(
return -1;
}
- RNA_property_enum_items(BPy_GetContext(), ptr, prop, &item, NULL, &free);
+ RNA_property_enum_items(BPY_context_get(), ptr, prop, &item, NULL, &free);
if (item) {
ret = pyrna_set_to_enum_bitfield(item, value, r_value, error_prefix);
@@ -1451,7 +1456,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
ret = PySet_New(NULL);
- if (RNA_property_enum_bitflag_identifiers(BPy_GetContext(), ptr, prop, val, identifier)) {
+ if (RNA_property_enum_bitflag_identifiers(BPY_context_get(), ptr, prop, val, identifier)) {
int index;
for (index = 0; identifier[index]; index++) {
@@ -1463,7 +1468,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
}
else {
const char *identifier;
- if (RNA_property_enum_identifier(BPy_GetContext(), ptr, prop, val, &identifier)) {
+ if (RNA_property_enum_identifier(BPY_context_get(), ptr, prop, val, &identifier)) {
ret = PyUnicode_FromString(identifier);
}
else {
@@ -2212,7 +2217,7 @@ static int pyrna_py_to_prop(
/* Run RNA property functions. */
if (RNA_property_update_check(prop)) {
- RNA_property_update(BPy_GetContext(), ptr, prop);
+ RNA_property_update(BPY_context_get(), ptr, prop);
}
return 0;
@@ -2288,7 +2293,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
/* Run RNA property functions. */
if (RNA_property_update_check(prop)) {
- RNA_property_update(BPy_GetContext(), ptr, prop);
+ RNA_property_update(BPY_context_get(), ptr, prop);
}
return ret;
@@ -3292,7 +3297,7 @@ static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self,
if (ret != -1) {
if (RNA_property_update_check(self->prop)) {
- RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
+ RNA_property_update(BPY_context_get(), &self->ptr, self->prop);
}
}
@@ -3962,7 +3967,7 @@ PyDoc_STRVAR(pyrna_prop_update_doc,
" however in rare cases it's useful to call explicitly.\n");
static PyObject *pyrna_prop_update(BPy_PropertyRNA *self)
{
- RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
+ RNA_property_update(BPY_context_get(), &self->ptr, self->prop);
Py_RETURN_NONE;
}
@@ -6048,7 +6053,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
/* enable this so all strings are copied and freed after calling.
* this exposes bugs where the pointer to the string is held and re-used */
- // #define DEBUG_STRING_FREE
+ /* #define DEBUG_STRING_FREE */
#ifdef DEBUG_STRING_FREE
PyObject *string_free_ls = PyList_New(0);
@@ -6294,7 +6299,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
if (err == 0) {
/* Call function. */
ReportList reports;
- bContext *C = BPy_GetContext();
+ bContext *C = BPY_context_get();
BKE_reports_init(&reports, RPT_STORE);
RNA_function_call(C, &reports, self_ptr, self_func, &parms);
@@ -8103,18 +8108,11 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
for (link = lb->first; link; link = link->next) {
FunctionRNA *func = (FunctionRNA *)link;
const int flag = RNA_function_flag(func);
- /* TODO(campbell): this is used for classmethod's too,
- * even though class methods should have 'FUNC_USE_SELF_TYPE' set, see Operator.poll for eg.
- * Keep this as-is since it's working, but we should be using
- * 'FUNC_USE_SELF_TYPE' for many functions. */
- const bool is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE);
-
if (!(flag & FUNC_REGISTER)) {
continue;
}
item = PyObject_GetAttrString(py_class, RNA_function_identifier(func));
-
have_function[i] = (item != NULL);
i++;
@@ -8127,80 +8125,89 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
RNA_function_identifier(func));
return -1;
}
-
PyErr_Clear();
+
+ continue;
}
- else {
- /* No need to keep a ref, the class owns it
- * (technically we should keep a reference, but...). */
- Py_DECREF(item);
- if (is_staticmethod) {
- if (PyMethod_Check(item) == 0) {
- PyErr_Format(PyExc_TypeError,
- "expected %.200s, %.200s class \"%.200s\" "
- "attribute to be a static/class method, not a %.200s",
- class_type,
- py_class_name,
- RNA_function_identifier(func),
- Py_TYPE(item)->tp_name);
- return -1;
- }
- item = ((PyMethodObject *)item)->im_func;
+ /* TODO(campbell): this is used for classmethod's too,
+ * even though class methods should have 'FUNC_USE_SELF_TYPE' set, see Operator.poll for eg.
+ * Keep this as-is since it's working, but we should be using
+ * 'FUNC_USE_SELF_TYPE' for many functions. */
+ const bool is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE);
+
+ /* Store original so we can decrement it's reference before returning. */
+ PyObject *item_orig = item;
+
+ if (is_staticmethod) {
+ if (PyMethod_Check(item) == 0) {
+ PyErr_Format(PyExc_TypeError,
+ "expected %.200s, %.200s class \"%.200s\" "
+ "attribute to be a static/class method, not a %.200s",
+ class_type,
+ py_class_name,
+ RNA_function_identifier(func),
+ Py_TYPE(item)->tp_name);
+ Py_DECREF(item_orig);
+ return -1;
}
- else {
- if (PyFunction_Check(item) == 0) {
- PyErr_Format(PyExc_TypeError,
- "expected %.200s, %.200s class \"%.200s\" "
- "attribute to be a function, not a %.200s",
- class_type,
- py_class_name,
- RNA_function_identifier(func),
- Py_TYPE(item)->tp_name);
- return -1;
- }
+ item = ((PyMethodObject *)item)->im_func;
+ }
+ else {
+ if (PyFunction_Check(item) == 0) {
+ PyErr_Format(PyExc_TypeError,
+ "expected %.200s, %.200s class \"%.200s\" "
+ "attribute to be a function, not a %.200s",
+ class_type,
+ py_class_name,
+ RNA_function_identifier(func),
+ Py_TYPE(item)->tp_name);
+ Py_DECREF(item_orig);
+ return -1;
}
+ }
- func_arg_count = rna_function_arg_count(func, &func_arg_min_count);
+ func_arg_count = rna_function_arg_count(func, &func_arg_min_count);
- if (func_arg_count >= 0) { /* -1 if we don't care. */
- arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
+ if (func_arg_count >= 0) { /* -1 if we don't care. */
+ arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
- /* note, the number of args we check for and the number of args we give to
- * '@staticmethods' are different (quirk of Python),
- * this is why rna_function_arg_count() doesn't return the value -1*/
- if (is_staticmethod) {
- func_arg_count++;
- func_arg_min_count++;
- }
+ /* note, the number of args we check for and the number of args we give to
+ * '@staticmethods' are different (quirk of Python),
+ * this is why rna_function_arg_count() doesn't return the value -1*/
+ if (is_staticmethod) {
+ func_arg_count++;
+ func_arg_min_count++;
+ }
- if (arg_count < func_arg_min_count || arg_count > func_arg_count) {
- if (func_arg_min_count != func_arg_count) {
- PyErr_Format(
- PyExc_ValueError,
- "expected %.200s, %.200s class \"%.200s\" function to have between %d and %d "
- "args, found %d",
- class_type,
- py_class_name,
- RNA_function_identifier(func),
- func_arg_count,
- func_arg_min_count,
- arg_count);
- }
- else {
- PyErr_Format(
- PyExc_ValueError,
- "expected %.200s, %.200s class \"%.200s\" function to have %d args, found %d",
- class_type,
- py_class_name,
- RNA_function_identifier(func),
- func_arg_count,
- arg_count);
- }
- return -1;
+ if (arg_count < func_arg_min_count || arg_count > func_arg_count) {
+ if (func_arg_min_count != func_arg_count) {
+ PyErr_Format(
+ PyExc_ValueError,
+ "expected %.200s, %.200s class \"%.200s\" function to have between %d and %d "
+ "args, found %d",
+ class_type,
+ py_class_name,
+ RNA_function_identifier(func),
+ func_arg_count,
+ func_arg_min_count,
+ arg_count);
+ }
+ else {
+ PyErr_Format(
+ PyExc_ValueError,
+ "expected %.200s, %.200s class \"%.200s\" function to have %d args, found %d",
+ class_type,
+ py_class_name,
+ RNA_function_identifier(func),
+ func_arg_count,
+ arg_count);
}
+ Py_DECREF(item_orig);
+ return -1;
}
}
+ Py_DECREF(item_orig);
}
/* Verify properties. */
@@ -8313,7 +8320,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
/* XXX, this is needed because render engine calls without a context
* this should be supported at some point, but at the moment it's not! */
if (C == NULL) {
- C = BPy_GetContext();
+ C = BPY_context_get();
}
/* Annoying! We need to check if the screen gets set to NULL which is a
@@ -8782,7 +8789,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
}
/* Get the context, so register callback can do necessary refreshes. */
- C = BPy_GetContext();
+ C = BPY_context_get();
/* Call the register callback with reports & identifier. */
BKE_reports_init(&reports, RPT_STORE);
@@ -8820,7 +8827,10 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
/* Old srna still references us, keep the check in case registering somehow can free it. */
if (RNA_struct_py_type_get(srna)) {
RNA_struct_py_type_set(srna, NULL);
- // Py_DECREF(py_class); /* Should be able to do this XXX since the old RNA adds a new ref. */
+#if 0
+ /* Should be able to do this XXX since the old RNA adds a new ref. */
+ Py_DECREF(py_class);
+#endif
}
/* Can't use this because it returns a dict proxy
@@ -8990,7 +9000,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
}
/* Get the context, so register callback can do necessary refreshes. */
- C = BPy_GetContext();
+ C = BPY_context_get();
/* Call unregister. */
unreg(CTX_data_main(C), srna); /* Calls bpy_class_free, this decref's py_class. */
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index 1d52706c5f9..b7648ee830f 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -259,7 +259,7 @@ static int pyrna_struct_keyframe_parse(PointerRNA *ptr,
}
if (*r_cfra == FLT_MAX) {
- *r_cfra = CTX_data_scene(BPy_GetContext())->r.cfra;
+ *r_cfra = CTX_data_scene(BPY_context_get())->r.cfra;
}
/* flag may be null (no option currently for remove keyframes e.g.). */
@@ -341,7 +341,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
* It is unlikely that driver code (which is the reason this depsgraph pointer is obtained) will
* be executed from this function call, as this only happens when `options` has
* `INSERTKEY_DRIVER`, which is not exposed to Python. */
- bContext *C = BPy_GetContext();
+ bContext *C = BPY_context_get();
struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(depsgraph,
cfra);
@@ -498,7 +498,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
int i;
/* try to find index of beztriple to get rid of */
- i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found);
+ i = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, cfra, fcu->totvert, &found);
if (found) {
/* delete the key at the index (will sanity check + do recalc afterwards) */
delete_fcurve_key(fcu, i, 1);
@@ -600,8 +600,8 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
ret = pyrna_struct_CreatePyObject(&tptr);
}
- bContext *context = BPy_GetContext();
- WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
+ bContext *context = BPY_context_get();
+ WM_event_add_notifier(BPY_context_get(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
DEG_relations_tag_update(CTX_data_main(context));
}
else {
@@ -659,7 +659,7 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
return NULL;
}
- bContext *context = BPy_GetContext();
+ bContext *context = BPY_context_get();
WM_event_add_notifier(context, NC_ANIMATION | ND_FCURVES_ORDER, NULL);
DEG_relations_tag_update(CTX_data_main(context));
diff --git a/source/blender/python/intern/bpy_rna_gizmo.c b/source/blender/python/intern/bpy_rna_gizmo.c
index 542d014f8b2..1f27e4bcca8 100644
--- a/source/blender/python/intern/bpy_rna_gizmo.c
+++ b/source/blender/python/intern/bpy_rna_gizmo.c
@@ -433,14 +433,14 @@ static PyObject *bpy_gizmo_target_set_value(PyObject *UNUSED(self), PyObject *ar
"Gizmo target property array") == -1) {
goto fail;
}
- WM_gizmo_target_property_float_set_array(BPy_GetContext(), gz, gz_prop, value);
+ WM_gizmo_target_property_float_set_array(BPY_context_get(), gz, gz_prop, value);
}
else {
float value;
if ((value = PyFloat_AsDouble(params.value)) == -1.0f && PyErr_Occurred()) {
goto fail;
}
- WM_gizmo_target_property_float_set(BPy_GetContext(), gz, gz_prop, value);
+ WM_gizmo_target_property_float_set(BPY_context_get(), gz, gz_prop, value);
}
Py_RETURN_NONE;
}
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index afdf890943e..1616bbeeea9 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -39,18 +39,7 @@ PyDoc_STRVAR(
".. note::\n"
"\n"
" Classes, methods and attributes that accept vectors also accept other numeric sequences,\n"
- " such as tuples, lists."
- "\n\n"
- "Submodules:\n"
- "\n"
- ".. toctree::\n"
- " :maxdepth: 1\n"
- "\n"
- " mathutils.geometry.rst\n"
- " mathutils.bvhtree.rst\n"
- " mathutils.kdtree.rst\n"
- " mathutils.interpolate.rst\n"
- " mathutils.noise.rst\n"
+ " such as tuples, lists.\n"
"\n"
"The :mod:`mathutils` module provides the following classes:\n"
"\n"
@@ -738,7 +727,7 @@ void BaseMathObject_dealloc(BaseMathObject *self)
BaseMathObject_clear(self);
}
- Py_TYPE(self)->tp_free(self); // PyObject_DEL(self); // breaks subtypes
+ Py_TYPE(self)->tp_free(self); // PyObject_DEL(self); /* breaks subtypes. */
}
/*----------------------------MODULE INIT-------------------------*/
diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h
index 41f65fbda5c..e53f33eacff 100644
--- a/source/blender/render/extern/include/RE_engine.h
+++ b/source/blender/render/extern/include/RE_engine.h
@@ -79,7 +79,7 @@ typedef struct RenderEngineType {
struct RenderEngineType *next, *prev;
/* type info */
- char idname[64]; // best keep the same size as BKE_ST_MAXNAME
+ char idname[64]; /* best keep the same size as BKE_ST_MAXNAME. */
char name[64];
int flag;
diff --git a/source/blender/sequencer/intern/sequencer.c b/source/blender/sequencer/intern/sequencer.c
index b8ccdec0902..2e38c478905 100644
--- a/source/blender/sequencer/intern/sequencer.c
+++ b/source/blender/sequencer/intern/sequencer.c
@@ -3387,7 +3387,8 @@ static ImBuf *seq_render_mask(const SeqRenderData *context, Mask *mask, float nr
Mask *mask_temp;
MaskRasterHandle *mr_handle;
- mask_temp = BKE_mask_copy_nolib(mask);
+ mask_temp = (Mask *)BKE_id_copy_ex(
+ NULL, &mask->id, NULL, LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA);
BKE_mask_evaluate(mask_temp, mask->sfra + nr, true);
@@ -3404,8 +3405,7 @@ static ImBuf *seq_render_mask(const SeqRenderData *context, Mask *mask, float nr
BKE_maskrasterize_handle_init(
mr_handle, mask_temp, context->rectx, context->recty, true, true, true);
- BKE_mask_free(mask_temp);
- MEM_freeN(mask_temp);
+ BKE_id_free(NULL, &mask_temp->id);
BKE_maskrasterize_buffer(mr_handle, context->rectx, context->recty, maskbuf);
@@ -6085,6 +6085,10 @@ bool BKE_sequencer_check_scene_recursion(Scene *scene, ReportList *reports)
/* Check if "seq_main" (indirectly) uses strip "seq". */
bool BKE_sequencer_render_loop_check(Sequence *seq_main, Sequence *seq)
{
+ if (seq_main == NULL || seq == NULL) {
+ return false;
+ }
+
if (seq_main == seq) {
return true;
}
diff --git a/source/blender/simulation/intern/ConstrainedConjugateGradient.h b/source/blender/simulation/intern/ConstrainedConjugateGradient.h
index b0f2bb037d2..0dc80c03bb5 100644
--- a/source/blender/simulation/intern/ConstrainedConjugateGradient.h
+++ b/source/blender/simulation/intern/ConstrainedConjugateGradient.h
@@ -60,7 +60,7 @@ EIGEN_DONT_INLINE void constrained_conjugate_gradient(const MatrixType &mat,
int n = mat.cols();
- VectorType residual = filter * (rhs - mat * x); // initial residual
+ VectorType residual = filter * (rhs - mat * x); /* initial residual */
RealScalar rhsNorm2 = (filter * rhs).squaredNorm();
if (rhsNorm2 == 0) {
@@ -79,32 +79,32 @@ EIGEN_DONT_INLINE void constrained_conjugate_gradient(const MatrixType &mat,
}
VectorType p(n);
- p = filter * precond.solve(residual); // initial search direction
+ p = filter * precond.solve(residual); /* initial search direction */
VectorType z(n), tmp(n);
RealScalar absNew = numext::real(
- residual.dot(p)); // the square of the absolute value of r scaled by invM
+ residual.dot(p)); /* the square of the absolute value of r scaled by invM */
int i = 0;
while (i < maxIters) {
- tmp.noalias() = filter * (mat * p); // the bottleneck of the algorithm
+ tmp.noalias() = filter * (mat * p); /* the bottleneck of the algorithm */
- Scalar alpha = absNew / p.dot(tmp); // the amount we travel on dir
- x += alpha * p; // update solution
- residual -= alpha * tmp; // update residue
+ Scalar alpha = absNew / p.dot(tmp); /* the amount we travel on dir */
+ x += alpha * p; /* update solution */
+ residual -= alpha * tmp; /* update residue */
residualNorm2 = residual.squaredNorm();
if (residualNorm2 < threshold) {
break;
}
- z = precond.solve(residual); // approximately solve for "A z = residual"
+ z = precond.solve(residual); /* approximately solve for "A z = residual" */
RealScalar absOld = absNew;
- absNew = numext::real(residual.dot(z)); // update the absolute value of r
+ absNew = numext::real(residual.dot(z)); /* update the absolute value of r */
RealScalar beta =
absNew /
- absOld; // calculate the Gram-Schmidt value used to create the new search direction
- p = filter * (z + beta * p); // update search direction
+ absOld; /* calculate the Gram-Schmidt value used to create the new search direction */
+ p = filter * (z + beta * p); /* update search direction */
i++;
}
tol_error = sqrt(residualNorm2 / rhsNorm2);
diff --git a/source/blender/simulation/intern/SIM_mass_spring.cpp b/source/blender/simulation/intern/SIM_mass_spring.cpp
index c09a58dcb56..42cfb11a15a 100644
--- a/source/blender/simulation/intern/SIM_mass_spring.cpp
+++ b/source/blender/simulation/intern/SIM_mass_spring.cpp
@@ -510,7 +510,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
scaling = parms->bending + s->lin_stiffness * fabsf(parms->max_bend - parms->bending);
kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
- // Fix for T45084 for cloth stiffness must have cb proportional to kb
+ /* Fix for T45084 for cloth stiffness must have cb proportional to kb */
cb = kb * parms->bending_damping;
SIM_mass_spring_force_spring_bending(data, s->ij, s->kl, s->restlen, kb, cb);
@@ -529,7 +529,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
scaling = s->lin_stiffness * parms->bending;
kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
- // Fix for T45084 for cloth stiffness must have cb proportional to kb
+ /* Fix for T45084 for cloth stiffness must have cb proportional to kb */
cb = kb * parms->bending_damping;
/* XXX assuming same restlen for ij and jk segments here,
@@ -788,10 +788,10 @@ static void cloth_calc_force(
MEM_freeN(winvec);
}
- // calculate spring forces
+ /* calculate spring forces */
for (LinkNode *link = cloth->springs; link; link = link->next) {
ClothSpring *spring = (ClothSpring *)link->link;
- // only handle active springs
+ /* only handle active springs */
if (!(spring->flags & CLOTH_SPRING_FLAG_DEACTIVATE)) {
cloth_calc_spring_force(clmd, spring);
}
@@ -1280,7 +1280,7 @@ int SIM_cloth_solve(
if (clmd->sim_parms->vgroup_mass > 0) { /* Do goal stuff. */
for (i = 0; i < mvert_num; i++) {
- // update velocities with constrained velocities from pinned verts
+ /* update velocities with constrained velocities from pinned verts */
if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) {
float v[3];
sub_v3_v3v3(v, verts[i].xconst, verts[i].xold);
@@ -1305,10 +1305,10 @@ int SIM_cloth_solve(
/* initialize forces to zero */
SIM_mass_spring_clear_forces(id);
- // calculate forces
+ /* calculate forces */
cloth_calc_force(scene, clmd, frame, effectors, step);
- // calculate new velocity and position
+ /* calculate new velocity and position */
SIM_mass_spring_solve_velocities(id, dt, &result);
cloth_record_result(clmd, &result, dt);
diff --git a/source/blender/simulation/intern/implicit_blender.c b/source/blender/simulation/intern/implicit_blender.c
index b4912492678..df8c4782acd 100644
--- a/source/blender/simulation/intern/implicit_blender.c
+++ b/source/blender/simulation/intern/implicit_blender.c
@@ -79,14 +79,14 @@ typedef float lfVector[3];
typedef struct fmatrix3x3 {
float m[3][3]; /* 3x3 matrix */
unsigned int c, r; /* column and row number */
- /* int pinned; // is this vertex allowed to move? */
+ // int pinned; /* is this vertex allowed to move? */
float n1, n2, n3; /* three normal vectors for collision constrains */
unsigned int vcount; /* vertex count */
unsigned int scount; /* spring count */
} fmatrix3x3;
///////////////////////////
-// float[3] vector
+/* float[3] vector */
///////////////////////////
/* simple vector code */
/* STATUS: verified */
@@ -123,7 +123,7 @@ static void print_fvector(float m3[3])
}
///////////////////////////
-// long float vector float (*)[3]
+/* long float vector float (*)[3] */
///////////////////////////
/* print long vector on console: for debug output */
DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts)
@@ -199,10 +199,10 @@ DO_INLINE float dot_lfvector(float (*fLongVectorA)[3],
{
long i = 0;
float temp = 0.0;
- // XXX brecht, disabled this for now (first schedule line was already disabled),
- // due to non-commutative nature of floating point ops this makes the sim give
- // different results each time you run it!
- // schedule(guided, 2)
+ /* XXX brecht, disabled this for now (first schedule line was already disabled),
+ * due to non-commutative nature of floating point ops this makes the sim give
+ * different results each time you run it!
+ * schedule(guided, 2) */
//#pragma omp parallel for reduction(+: temp) if (verts > CLOTH_OPENMP_LIMIT)
for (i = 0; i < (long)verts; i++) {
temp += dot_v3v3(fLongVectorA[i], fLongVectorB[i]);
@@ -326,9 +326,11 @@ static void print_bfmatrix(fmatrix3x3 *m)
for (j = 0; j < 3; j++) {
for (i = 0; i < 3; i++) {
- // if (t[k + i + (l + j) * size] != 0.0f) {
- // printf("warning: overwriting value at %d, %d\n", m[q].r, m[q].c);
- // }
+# if 0
+ if (t[k + i + (l + j) * size] != 0.0f) {
+ printf("warning: overwriting value at %d, %d\n", m[q].r, m[q].c);
+ }
+# endif
if (k == l) {
t[k + i + (k + j) * size] += m[q].m[i][j];
}
@@ -471,7 +473,7 @@ DO_INLINE void sub_fmatrix_fmatrix(float to[3][3],
sub_v3_v3v3(to[2], matrixA[2], matrixB[2]);
}
/////////////////////////////////////////////////////////////////
-// special functions
+/* special functions */
/////////////////////////////////////////////////////////////////
/* 3x3 matrix multiplied+added by a vector */
/* STATUS: verified */
@@ -532,7 +534,7 @@ BLI_INLINE void madd_m3_m3fl(float r[3][3], const float m[3][3], float f)
/////////////////////////////////////////////////////////////////
///////////////////////////
-// SPARSE SYMMETRIC big matrix with 3x3 matrix entries
+/* SPARSE SYMMETRIC big matrix with 3x3 matrix entries */
///////////////////////////
/* printf a big matrix on console: for debug output */
# if 0
@@ -555,7 +557,7 @@ BLI_INLINE void init_fmatrix(fmatrix3x3 *matrix, int r, int c)
/* create big matrix */
DO_INLINE fmatrix3x3 *create_bfmatrix(unsigned int verts, unsigned int springs)
{
- // TODO: check if memory allocation was successful */
+ /* TODO: check if memory allocation was successful */
fmatrix3x3 *temp = (fmatrix3x3 *)MEM_callocN(sizeof(fmatrix3x3) * (verts + springs),
"cloth_implicit_alloc_matrix");
int i;
@@ -581,12 +583,12 @@ DO_INLINE void del_bfmatrix(fmatrix3x3 *matrix)
/* copy big matrix */
DO_INLINE void cp_bfmatrix(fmatrix3x3 *to, fmatrix3x3 *from)
{
- // TODO bounds checking
+ /* TODO bounds checking */
memcpy(to, from, sizeof(fmatrix3x3) * (from[0].vcount + from[0].scount));
}
/* init big matrix */
-// slow in parallel
+/* slow in parallel */
DO_INLINE void init_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
{
unsigned int i;
@@ -597,7 +599,7 @@ DO_INLINE void init_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
}
/* init the diagonal of big matrix */
-// slow in parallel
+/* slow in parallel */
DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
{
unsigned int i, j;
@@ -657,7 +659,7 @@ DO_INLINE void subadd_bfmatrixS_bfmatrixS(
}
///////////////////////////////////////////////////////////////////
-// simulator start
+/* simulator start */
///////////////////////////////////////////////////////////////////
typedef struct Implicit_Data {
@@ -695,7 +697,7 @@ Implicit_Data *SIM_mass_spring_solver_create(int numverts, int numsprings)
id->S = create_bfmatrix(numverts, 0);
id->Pinv = create_bfmatrix(numverts, numsprings);
id->P = create_bfmatrix(numverts, numsprings);
- id->bigI = create_bfmatrix(numverts, numsprings); // TODO 0 springs
+ id->bigI = create_bfmatrix(numverts, numsprings); /* TODO 0 springs */
id->M = create_bfmatrix(numverts, numsprings);
id->X = create_lfvector(numverts);
id->Xnew = create_lfvector(numverts);
@@ -783,7 +785,7 @@ DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
# if 0
static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S)
{
- // Solves for unknown X in equation AX=B
+ /* Solves for unknown X in equation AX=B */
unsigned int conjgrad_loopcount = 0, conjgrad_looplimit = 100;
float conjgrad_epsilon = 0.0001f /* , conjgrad_lasterror=0 */ /* UNUSED */;
lfVector *q, *d, *tmp, *r;
@@ -799,7 +801,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z,
add_lfvector_lfvector(ldV, ldV, z, numverts);
- // r = B - Mul(tmp, A, X); // just use B if X known to be zero
+ // r = B - Mul(tmp, A, X); /* just use B if X known to be zero. */
cp_lfvector(r, lB, numverts);
mul_bfmatrix_lfvector(tmp, lA, ldV);
sub_lfvector_lfvector(r, r, tmp, numverts);
@@ -812,23 +814,23 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z,
starget = s * sqrtf(conjgrad_epsilon);
while (s > starget && conjgrad_loopcount < conjgrad_looplimit) {
- // Mul(q, A, d); // q = A*d;
+ // Mul(q, A, d); /* q = A*d; */
mul_bfmatrix_lfvector(q, lA, d);
filter(q, S);
a = s / dot_lfvector(d, q, numverts);
- // X = X + d*a;
+ /* X = X + d*a; */
add_lfvector_lfvectorS(ldV, ldV, d, a, numverts);
- // r = r - q*a;
+ /* r = r - q*a; */
sub_lfvector_lfvectorS(r, r, q, a, numverts);
s_prev = s;
s = dot_lfvector(r, r, numverts);
- //d = r+d*(s/s_prev);
+ /* d = r+d*(s/s_prev); */
add_lfvector_lfvectorS(d, r, d, (s / s_prev), numverts);
filter(d, S);
@@ -844,7 +846,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z,
// printf("W/O conjgrad_loopcount: %d\n", conjgrad_loopcount);
return conjgrad_loopcount <
- conjgrad_looplimit; // true means we reached desired accuracy in given time - ie stable
+ conjgrad_looplimit; /* true means we reached desired accuracy in given time - ie stable */
}
# endif
@@ -855,7 +857,7 @@ static int cg_filtered(lfVector *ldV,
fmatrix3x3 *S,
ImplicitSolverResult *result)
{
- // Solves for unknown X in equation AX=B
+ /* Solves for unknown X in equation AX=B */
unsigned int conjgrad_loopcount = 0, conjgrad_looplimit = 100;
float conjgrad_epsilon = 0.01f;
@@ -940,26 +942,26 @@ static int cg_filtered(lfVector *ldV,
result->error = bnorm2 > 0.0f ? sqrtf(delta_new / bnorm2) : 0.0f;
return conjgrad_loopcount <
- conjgrad_looplimit; // true means we reached desired accuracy in given time - ie stable
+ conjgrad_looplimit; /* true means we reached desired accuracy in given time - ie stable */
}
# if 0
-// block diagonalizer
+/* block diagonalizer */
DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
{
unsigned int i = 0;
- // Take only the diagonal blocks of A
+ /* Take only the diagonal blocks of A */
// #pragma omp parallel for private(i) if (lA[0].vcount > CLOTH_OPENMP_LIMIT)
for (i = 0; i < lA[0].vcount; i++) {
- // block diagonalizer
+ /* block diagonalizer */
cp_fmatrix(P[i].m, lA[i].m);
inverse_fmatrix(Pinv[i].m, P[i].m);
}
}
# if 0
-// version 1.3
+/* version 1.3 */
static int cg_filtered_pre(lfVector *dv,
fmatrix3x3 *lA,
lfVector *lB,
@@ -970,7 +972,7 @@ static int cg_filtered_pre(lfVector *dv,
{
unsigned int numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit = 100;
float delta0 = 0, deltaNew = 0, deltaOld = 0, alpha = 0;
- float conjgrad_epsilon = 0.0001; // 0.2 is dt for steps=5
+ float conjgrad_epsilon = 0.0001; /* 0.2 is dt for steps=5 */
lfVector *r = create_lfvector(numverts);
lfVector *p = create_lfvector(numverts);
lfVector *s = create_lfvector(numverts);
@@ -1036,7 +1038,7 @@ static int cg_filtered_pre(lfVector *dv,
}
# endif
-// version 1.4
+/* version 1.4 */
static int cg_filtered_pre(lfVector *dv,
fmatrix3x3 *lA,
lfVector *lB,
@@ -1060,29 +1062,29 @@ static int cg_filtered_pre(lfVector *dv,
initdiag_bfmatrix(bigI, I);
sub_bfmatrix_Smatrix(bigI, bigI, S);
- // x = Sx_0+(I-S)z
+ /* x = Sx_0+(I-S)z */
filter(dv, S);
add_lfvector_lfvector(dv, dv, z, numverts);
- // b_hat = S(b-A(I-S)z)
+ /* b_hat = S(b-A(I-S)z) */
mul_bfmatrix_lfvector(r, lA, z);
mul_bfmatrix_lfvector(bhat, bigI, r);
sub_lfvector_lfvector(bhat, lB, bhat, numverts);
- // r = S(b-Ax)
+ /* r = S(b-Ax) */
mul_bfmatrix_lfvector(r, lA, dv);
sub_lfvector_lfvector(r, lB, r, numverts);
filter(r, S);
- // p = SP^-1r
+ /* p = SP^-1r */
mul_prevfmatrix_lfvector(p, Pinv, r);
filter(p, S);
- // delta0 = bhat^TP^-1bhat
+ /* delta0 = bhat^TP^-1bhat */
mul_prevfmatrix_lfvector(btemp, Pinv, bhat);
delta0 = dot_lfvector(bhat, btemp, numverts);
- // deltaNew = r^TP
+ /* deltaNew = r^TP */
deltaNew = dot_lfvector(r, p, numverts);
# if 0
@@ -1178,7 +1180,7 @@ bool SIM_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
printf("cg_filtered calc time: %f\n", (float)(end - start));
# endif
- // advance velocities
+ /* advance velocities */
add_lfvector_lfvector(data->Vnew, data->V, data->dV, numverts);
del_lfvector(dFdXmV);
@@ -1190,7 +1192,7 @@ bool SIM_mass_spring_solve_positions(Implicit_Data *data, float dt)
{
int numverts = data->M[0].vcount;
- // advance positions
+ /* advance positions */
add_lfvector_lfvectorS(data->Xnew, data->X, data->Vnew, dt, numverts);
return true;
@@ -1662,7 +1664,7 @@ void SIM_mass_spring_force_vertex_wind(Implicit_Data *data,
BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, float L, float k)
{
- // dir is unit length direction, rest is spring's restlength, k is spring constant.
+ /* dir is unit length direction, rest is spring's restlength, k is spring constant. */
// return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k;
outerproduct(to, dir, dir);
sub_m3_m3m3(to, I, to);
@@ -1681,7 +1683,7 @@ BLI_INLINE void dfdx_damp(float to[3][3],
float rest,
float damping)
{
- // inner spring damping vel is the relative velocity of the endpoints.
+ /* inner spring damping vel is the relative velocity of the endpoints. */
// return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
mul_fvectorT_fvector(to, dir, dir);
sub_fmatrix_fmatrix(to, I, to);
@@ -1691,7 +1693,7 @@ BLI_INLINE void dfdx_damp(float to[3][3],
BLI_INLINE void dfdv_damp(float to[3][3], const float dir[3], float damping)
{
- // derivative of force wrt velocity
+ /* derivative of force wrt velocity */
outerproduct(to, dir, dir);
mul_m3_fl(to, -damping);
}
@@ -1725,7 +1727,7 @@ BLI_INLINE float fbstar(float length, float L, float kb, float cb)
return tempfb_fl;
}
-// function to calculae bending spring force (taken from Choi & Co)
+/* function to calculae bending spring force (taken from Choi & Co) */
BLI_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
{
float tempfb_fl = kb * fb(length, L);
@@ -1738,7 +1740,7 @@ BLI_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
return -kb * fbderiv(length, L);
}
-/* calculate elonglation */
+/* calculate elongation */
BLI_INLINE bool spring_length(Implicit_Data *data,
int i,
int j,
@@ -1756,7 +1758,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data,
if (length > L) {
if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
(((length - L) * 100.0f / L) > clmd->sim_parms->maxspringlen)) {
- // cut spring!
+ /* cut spring! */
s->flags |= CSPRING_FLAG_DEACTIVATE;
return false;
}
@@ -1808,7 +1810,7 @@ bool SIM_mass_spring_force_spring_linear(Implicit_Data *data,
float f[3], dfdx[3][3], dfdv[3][3];
float damping = 0;
- // calculate elonglation
+ /* calculate elongation */
spring_length(data, i, j, extent, dir, &length, vel);
/* This code computes not only the force, but also its derivative.
@@ -1858,7 +1860,7 @@ bool SIM_mass_spring_force_spring_bending(
{
float extent[3], length, dir[3], vel[3];
- // calculate elonglation
+ /* calculate elongation */
spring_length(data, i, j, extent, dir, &length, vel);
if (length < restlen) {
@@ -2110,7 +2112,7 @@ BLI_INLINE void spring_hairbend_estimate_dfdx(Implicit_Data *data,
int q,
float dfdx[3][3])
{
- const float delta = 0.00001f; // TODO find a good heuristic for this
+ const float delta = 0.00001f; /* TODO find a good heuristic for this */
float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
float f[3];
int a, b;
@@ -2149,7 +2151,7 @@ BLI_INLINE void spring_hairbend_estimate_dfdv(Implicit_Data *data,
int q,
float dfdv[3][3])
{
- const float delta = 0.00001f; // TODO find a good heuristic for this
+ const float delta = 0.00001f; /* TODO find a good heuristic for this */
float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
float f[3];
int a, b;
@@ -2253,7 +2255,7 @@ bool SIM_mass_spring_force_spring_bending_hair(Implicit_Data *data,
float dfi_dxi[3][3], dfj_dxi[3][3], dfj_dxj[3][3], dfk_dxi[3][3], dfk_dxj[3][3], dfk_dxk[3][3];
float dfdvi[3][3];
- // TESTING
+ /* TESTING */
damping = 0.0f;
zero_v3(fi);
@@ -2350,8 +2352,8 @@ bool SIM_mass_spring_force_spring_goal(Implicit_Data *data,
if (length > ALMOST_ZERO) {
mul_v3_v3fl(f, dir, stiffness * length);
- // Ascher & Boxman, p.21: Damping only during elonglation
- // something wrong with it...
+ /* Ascher & Boxman, p.21: Damping only during elongation
+ * something wrong with it. */
madd_v3_v3fl(f, dir, damping * dot_v3v3(vel, dir));
dfdx_spring(dfdx, dir, length, 0.0f, stiffness);
diff --git a/source/blender/simulation/intern/implicit_eigen.cpp b/source/blender/simulation/intern/implicit_eigen.cpp
index 15b9e30e32a..b30a46909b9 100644
--- a/source/blender/simulation/intern/implicit_eigen.cpp
+++ b/source/blender/simulation/intern/implicit_eigen.cpp
@@ -842,7 +842,7 @@ void SIM_mass_spring_force_face_wind(
float win[3], nor[3], area;
float factor;
- // calculate face normal and area
+ /* calculate face normal and area */
area = calc_nor_area_tri(nor, data->X.v3(v1), data->X.v3(v2), data->X.v3(v3));
factor = effector_scale * area / 3.0f;
@@ -894,7 +894,7 @@ BLI_INLINE void dfdx_damp(float to[3][3],
float rest,
float damping)
{
- // inner spring damping vel is the relative velocity of the endpoints.
+ /* inner spring damping vel is the relative velocity of the endpoints. */
// return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
mul_fvectorT_fvector(to, dir, dir);
sub_fmatrix_fmatrix(to, I, to);
@@ -904,7 +904,7 @@ BLI_INLINE void dfdx_damp(float to[3][3],
BLI_INLINE void dfdv_damp(float to[3][3], const float dir[3], float damping)
{
- // derivative of force wrt velocity
+ /* derivative of force wrt velocity */
outerproduct(to, dir, dir);
mul_m3_fl(to, -damping);
}
@@ -936,7 +936,7 @@ BLI_INLINE float fbstar(float length, float L, float kb, float cb)
}
}
-// function to calculae bending spring force (taken from Choi & Co)
+/* function to calculae bending spring force (taken from Choi & Co) */
BLI_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
{
float tempfb_fl = kb * fb(length, L);
@@ -950,7 +950,7 @@ BLI_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
}
}
-/* calculate elonglation */
+/* calculate elongation */
BLI_INLINE bool spring_length(Implicit_Data *data,
int i,
int j,
@@ -968,7 +968,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data,
if (length > L) {
if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
(((length - L) * 100.0f / L) > clmd->sim_parms->maxspringlen)) {
- // cut spring!
+ /* cut spring! */
s->flags |= CSPRING_FLAG_DEACTIVATE;
return false;
}
@@ -1014,7 +1014,7 @@ bool SIM_mass_spring_force_spring_linear(Implicit_Data *data,
{
float extent[3], length, dir[3], vel[3];
- // calculate elonglation
+ /* calculate elongation */
spring_length(data, i, j, extent, dir, &length, vel);
if (length > restlen || no_compress) {
@@ -1026,8 +1026,8 @@ bool SIM_mass_spring_force_spring_linear(Implicit_Data *data,
}
mul_v3_v3fl(f, dir, stretch_force);
- // Ascher & Boxman, p.21: Damping only during elonglation
- // something wrong with it...
+ /* Ascher & Boxman, p.21: Damping only during elongation
+ * something wrong with it... */
madd_v3_v3fl(f, dir, damping * dot_v3v3(vel, dir));
dfdx_spring(dfdx, dir, length, restlen, stiffness);
@@ -1075,7 +1075,7 @@ bool SIM_mass_spring_force_spring_bending(Implicit_Data *data,
{
float extent[3], length, dir[3], vel[3];
- // calculate elonglation
+ /* calculate elongation */
spring_length(data, i, j, extent, dir, &length, vel);
if (length < restlen) {
@@ -1223,7 +1223,7 @@ BLI_INLINE void spring_angbend_estimate_dfdx(Implicit_Data *data,
int q,
float dfdx[3][3])
{
- const float delta = 0.00001f; // TODO find a good heuristic for this
+ const float delta = 0.00001f; /* TODO find a good heuristic for this */
float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
float f[3];
int a, b;
@@ -1262,7 +1262,7 @@ BLI_INLINE void spring_angbend_estimate_dfdv(Implicit_Data *data,
int q,
float dfdv[3][3])
{
- const float delta = 0.00001f; // TODO find a good heuristic for this
+ const float delta = 0.00001f; /* TODO find a good heuristic for this */
float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
float f[3];
int a, b;
@@ -1368,7 +1368,7 @@ bool SIM_mass_spring_force_spring_bending_angular(Implicit_Data *data,
float dfi_dxi[3][3], dfj_dxi[3][3], dfj_dxj[3][3], dfk_dxi[3][3], dfk_dxj[3][3], dfk_dxk[3][3];
float dfdvi[3][3];
- // TESTING
+ /* TESTING */
damping = 0.0f;
zero_v3(fi);
@@ -1468,8 +1468,8 @@ bool SIM_mass_spring_force_spring_goal(Implicit_Data *data,
if (length > ALMOST_ZERO) {
mul_v3_v3fl(f, dir, stiffness * length);
- // Ascher & Boxman, p.21: Damping only during elonglation
- // something wrong with it...
+ /* Ascher & Boxman, p.21: Damping only during elongation
+ * something wrong with it... */
madd_v3_v3fl(f, dir, damping * dot_v3v3(vel, dir));
dfdx_spring(dfdx, dir, length, 0.0f, stiffness);
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 82d6e93dd87..acd72a4b1fd 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -822,6 +822,7 @@ typedef void (*wmPaintCursorDraw)(struct bContext *C, int, int, void *customdata
#define WM_DRAG_NAME 3
#define WM_DRAG_VALUE 4
#define WM_DRAG_COLOR 5
+#define WM_DRAG_DATASTACK 6
typedef enum wmDragFlags {
WM_DRAG_NOP = 0,
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
index 87cb4d5f584..b81b12a1b06 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
@@ -374,7 +374,7 @@ void WM_gizmo_set_color_highlight(wmGizmo *gz, const float color_hi[4])
copy_v4_v4(gz->color_hi, color_hi);
}
-/** \} */ // Gizmo Creation API
+/** \} */ /* Gizmo Creation API. */
/* -------------------------------------------------------------------- */
/** \name Gizmo Callback Assignment
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c
index b056ed40943..7cb1a0bdf4b 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c
@@ -314,7 +314,7 @@ void WM_gizmo_do_msg_notify_tag_refresh(bContext *UNUSED(C),
ED_region_tag_redraw(
region); /* Could possibly avoid a full redraw and only tag for editor overlays
- redraw in some cases, see ED_region_tag_redraw_editor_overlays(). */
+ * redraw in some cases, see #ED_region_tag_redraw_editor_overlays(). */
WM_gizmomap_tag_refresh(gzmap);
}
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 12ccd2134cf..e7010461c68 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -20,9 +20,9 @@
/** \file
* \ingroup wm
*
- * Internal functions for managing UI registrable types (operator, UI and menu types)
+ * Internal functions for managing UI registrable types (operator, UI and menu types).
*
- * Also Blenders main event loop (WM_main)
+ * Also Blender's main event loop (WM_main).
*/
#include <stddef.h>
@@ -87,7 +87,7 @@ static void window_manager_foreach_id(ID *id, LibraryForeachIDData *data)
if (win->workspace_hook != NULL) {
ID *workspace = (ID *)BKE_workspace_active_get(win->workspace_hook);
BKE_LIB_FOREACHID_PROCESS_ID(data, workspace, IDWALK_CB_NOP);
- /* allow callback to set a different workspace */
+ /* Allow callback to set a different workspace. */
BKE_workspace_active_set(win->workspace_hook, (WorkSpace *)workspace);
}
if (BKE_lib_query_foreachid_process_flags_get(data) & IDWALK_INCLUDE_UI) {
@@ -129,8 +129,7 @@ void WM_operator_free(wmOperator *op)
#ifdef WITH_PYTHON
if (op->py_instance) {
- /* do this first in case there are any __del__ functions or
- * similar that use properties */
+ /* Do this first in case there are any __del__ functions or similar that use properties. */
BPY_DECREF_RNA_INVALIDATE(op->py_instance);
}
#endif
@@ -180,16 +179,15 @@ void WM_operator_free_all_after(wmWindowManager *wm, struct wmOperator *op)
*/
void WM_operator_type_set(wmOperator *op, wmOperatorType *ot)
{
- /* not supported for Python */
+ /* Not supported for Python. */
BLI_assert(op->py_instance == NULL);
op->type = ot;
op->ptr->type = ot->srna;
- /* ensure compatible properties */
+ /* Ensure compatible properties. */
if (op->properties) {
PointerRNA ptr;
-
WM_operator_properties_create_ptr(&ptr, ot);
WM_operator_properties_default(&ptr, false);
@@ -208,8 +206,8 @@ static void wm_reports_free(wmWindowManager *wm)
WM_event_remove_timer(wm, NULL, wm->reports.reporttimer);
}
-/* all operations get registered in the windowmanager here */
-/* called on event handling by event_system.c */
+/* All operations get registered in the windowmanager here. */
+/* Called on event handling by event_system.c. */
void wm_operator_register(bContext *C, wmOperator *op)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@ -217,7 +215,7 @@ void wm_operator_register(bContext *C, wmOperator *op)
BLI_addtail(&wm->operators, op);
- /* only count registered operators */
+ /* Only count registered operators. */
while (op) {
wmOperator *op_prev = op->prev;
if (op->type->flag & OPTYPE_REGISTER) {
@@ -230,7 +228,7 @@ void wm_operator_register(bContext *C, wmOperator *op)
op = op_prev;
}
- /* so the console is redrawn */
+ /* So the console is redrawn. */
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO_REPORT, NULL);
WM_event_add_notifier(C, NC_WM | ND_HISTORY, NULL);
}
@@ -252,8 +250,7 @@ void WM_operator_stack_clear(wmWindowManager *wm)
*/
void WM_operator_handlers_clear(wmWindowManager *wm, wmOperatorType *ot)
{
- wmWindow *win;
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
ListBase *lb[2] = {&win->handlers, &win->modalhandlers};
for (int i = 0; i < ARRAY_SIZE(lb); i++) {
LISTBASE_FOREACH (wmEventHandler *, handler_base, lb[i]) {
@@ -287,7 +284,7 @@ void WM_keyconfig_init(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
- /* create standard key configs */
+ /* Create standard key configs. */
if (wm->defaultconf == NULL) {
/* Keep lowercase to match the preset filename. */
wm->defaultconf = WM_keyconfig_new(wm, WM_KEYCONFIG_STR_DEFAULT, false);
@@ -299,8 +296,7 @@ void WM_keyconfig_init(bContext *C)
wm->userconf = WM_keyconfig_new(wm, WM_KEYCONFIG_STR_DEFAULT " user", false);
}
- /* initialize only after python init is done, for keymaps that
- * use python operators */
+ /* Initialize only after python init is done, for keymaps that use python operators. */
if (CTX_py_init_get(C) && (wm->initialized & WM_KEYCONFIG_IS_INIT) == 0) {
/* create default key config, only initialize once,
* it's persistent across sessions */
@@ -325,7 +321,7 @@ void WM_check(bContext *C)
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
- /* wm context */
+ /* WM context. */
if (wm == NULL) {
wm = bmain->wm.first;
CTX_wm_manager_set(C, wm);
@@ -341,18 +337,18 @@ void WM_check(bContext *C)
}
if (!G.background) {
- /* case: fileread */
+ /* Case: fileread. */
if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) {
WM_keyconfig_init(C);
WM_autosave_init(wm);
}
- /* case: no open windows at all, for old file reads */
+ /* Case: no open windows at all, for old file reads. */
wm_window_ghostwindows_ensure(wm);
}
- /* case: fileread */
- /* note: this runs in bg mode to set the screen context cb */
+ /* Case: fileread. */
+ /* Note: this runs in background mode to set the screen context cb. */
if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) {
ED_screens_init(bmain, wm);
wm->initialized |= WM_WINDOW_IS_INIT;
@@ -362,9 +358,8 @@ void WM_check(bContext *C)
void wm_clear_default_size(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win;
- /* wm context */
+ /* WM context. */
if (wm == NULL) {
wm = CTX_data_main(C)->wm.first;
CTX_wm_manager_set(C, wm);
@@ -374,7 +369,7 @@ void wm_clear_default_size(bContext *C)
return;
}
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
win->sizex = 0;
win->sizey = 0;
win->posx = 0;
@@ -382,7 +377,7 @@ void wm_clear_default_size(bContext *C)
}
}
-/* on startup, it adds all data, for matching */
+/* On startup, it adds all data, for matching. */
void wm_add_default(Main *bmain, bContext *C)
{
wmWindowManager *wm = BKE_libblock_alloc(bmain, ID_WM, "WinMan", 0);
@@ -404,13 +399,9 @@ void wm_add_default(Main *bmain, bContext *C)
wm_window_make_drawable(wm, win);
}
-/* context is allowed to be NULL, do not free wm itself (lib_id.c) */
+/* Context is allowed to be NULL, do not free wm itself (lib_id.c). */
void wm_close_and_free(bContext *C, wmWindowManager *wm)
{
- wmWindow *win;
- wmOperator *op;
- wmKeyConfig *keyconf;
-
if (wm->autosavetimer) {
wm_autosave_timer_ended(wm);
}
@@ -420,16 +411,19 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
wm_xr_exit(wm);
#endif
+ wmWindow *win;
while ((win = BLI_pophead(&wm->windows))) {
- /* prevent draw clear to use screen */
+ /* Prevent draw clear to use screen. */
BKE_workspace_active_set(win->workspace_hook, NULL);
wm_window_free(C, wm, win);
}
+ wmOperator *op;
while ((op = BLI_pophead(&wm->operators))) {
WM_operator_free(op);
}
+ wmKeyConfig *keyconf;
while ((keyconf = BLI_pophead(&wm->keyconfigs))) {
WM_keyconfig_free(keyconf);
}
@@ -459,7 +453,6 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
void wm_close_and_free_all(bContext *C, ListBase *wmlist)
{
wmWindowManager *wm;
-
while ((wm = wmlist->first)) {
wm_close_and_free(C, wm);
BLI_remlink(wmlist, wm);
@@ -476,16 +469,16 @@ void WM_main(bContext *C)
while (1) {
- /* get events from ghost, handle window events, add to window queues */
+ /* Get events from ghost, handle window events, add to window queues. */
wm_window_process_events(C);
- /* per window, all events to the window, screen, area and region handlers */
+ /* Per window, all events to the window, screen, area and region handlers. */
wm_event_do_handlers(C);
- /* events have left notes about changes, we handle and cache it */
+ /* Wvents have left notes about changes, we handle and cache it. */
wm_event_do_notifiers(C);
- /* execute cached changes draw */
+ /* Wxecute cached changes draw. */
wm_draw_update(C);
}
}
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index b3185f57577..0f39e6ccf80 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -353,7 +353,6 @@ void WM_cursor_time(wmWindow *win, int nr)
};
uchar mask[16][2];
uchar bitmap[16][2] = {{0}};
- int i, idx;
if (win->lastcursor == 0) {
win->lastcursor = win->cursor;
@@ -362,12 +361,12 @@ void WM_cursor_time(wmWindow *win, int nr)
memset(&mask, 0xFF, sizeof(mask));
/* print number bottom right justified */
- for (idx = 3; nr && idx >= 0; idx--) {
+ for (int idx = 3; nr && idx >= 0; idx--) {
const char *digit = number_bitmaps[nr % 10];
int x = idx % 2;
int y = idx / 2;
- for (i = 0; i < 8; i++) {
+ for (int i = 0; i < 8; i++) {
bitmap[i + y * 8][x] = digit[i];
}
nr /= 10;
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index b1a469d1365..373360c7b92 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -74,9 +74,7 @@ typedef struct wmDropBoxMap {
/* spaceid/regionid is zero for window drop maps */
ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
{
- wmDropBoxMap *dm;
-
- for (dm = dropboxes.first; dm; dm = dm->next) {
+ LISTBASE_FOREACH (wmDropBoxMap *, dm, &dropboxes) {
if (dm->spaceid == spaceid && dm->regionid == regionid) {
if (STREQLEN(idname, dm->idname, KMAP_MAX_NAME)) {
return &dm->dropboxes;
@@ -84,7 +82,7 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
}
}
- dm = MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list");
+ wmDropBoxMap *dm = MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list");
BLI_strncpy(dm->idname, idname, KMAP_MAX_NAME);
dm->spaceid = spaceid;
dm->regionid = regionid;
@@ -99,7 +97,6 @@ wmDropBox *WM_dropbox_add(ListBase *lb,
void (*copy)(wmDrag *, wmDropBox *))
{
wmDropBox *drop = MEM_callocN(sizeof(wmDropBox), "wmDropBox");
-
drop->poll = poll;
drop->copy = copy;
drop->ot = WM_operatortype_find(idname, 0);
@@ -119,12 +116,9 @@ wmDropBox *WM_dropbox_add(ListBase *lb,
void wm_dropbox_free(void)
{
- wmDropBoxMap *dm;
-
- for (dm = dropboxes.first; dm; dm = dm->next) {
- wmDropBox *drop;
- for (drop = dm->dropboxes.first; drop; drop = drop->next) {
+ LISTBASE_FOREACH (wmDropBoxMap *, dm, &dropboxes) {
+ LISTBASE_FOREACH (wmDropBox *, drop, &dm->dropboxes) {
if (drop->ptr) {
WM_operator_properties_free(drop->ptr);
MEM_freeN(drop->ptr);
@@ -277,9 +271,8 @@ static void wm_drop_operator_options(bContext *C, wmDrag *drag, const wmEvent *e
void wm_drags_check_ops(bContext *C, const wmEvent *event)
{
wmWindowManager *wm = CTX_wm_manager(C);
- wmDrag *drag;
- for (drag = wm->drags.first; drag; drag = drag->next) {
+ LISTBASE_FOREACH (wmDrag *, drag, &wm->drags) {
wm_drop_operator_options(C, drag, event);
}
}
@@ -389,12 +382,10 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
{
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
wmWindowManager *wm = CTX_wm_manager(C);
- wmDrag *drag;
const int winsize_y = WM_window_pixels_y(win);
- int cursorx, cursory, x, y;
- cursorx = win->eventstate->x;
- cursory = win->eventstate->y;
+ int cursorx = win->eventstate->x;
+ int cursory = win->eventstate->y;
if (rect) {
rect->xmin = rect->xmax = cursorx;
rect->ymin = rect->ymax = cursory;
@@ -402,12 +393,13 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
/* Should we support multi-line drag draws? Maybe not, more types mixed wont work well. */
GPU_blend(GPU_BLEND_ALPHA);
- for (drag = wm->drags.first; drag; drag = drag->next) {
+ LISTBASE_FOREACH (wmDrag *, drag, &wm->drags) {
const uchar text_col[] = {255, 255, 255, 255};
int iconsize = UI_DPI_ICON_SIZE;
int padding = 4 * UI_DPI_FAC;
/* image or icon */
+ int x, y;
if (drag->imb) {
x = cursorx - drag->sx / 2;
y = cursory - drag->sy / 2;
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 2853481381d..3449c6974f5 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -86,7 +86,6 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region)
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
bScreen *screen = WM_window_get_active_screen(win);
- wmPaintCursor *pc;
/* Don't draw paint cursors with locked interface. Painting is not possible
* then, and cursor drawing can use scene data that another thread may be
@@ -95,36 +94,37 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region)
return;
}
- if (region->visible && region == screen->active_region) {
- for (pc = wm->paintcursors.first; pc; pc = pc->next) {
-
- if ((pc->space_type != SPACE_TYPE_ANY) && (area->spacetype != pc->space_type)) {
- continue;
- }
+ if (!region->visible || region != screen->active_region) {
+ return;
+ }
- if ((pc->region_type != RGN_TYPE_ANY) && (region->regiontype != pc->region_type)) {
- continue;
- }
+ LISTBASE_FOREACH (wmPaintCursor *, pc, &wm->paintcursors) {
+ if ((pc->space_type != SPACE_TYPE_ANY) && (area->spacetype != pc->space_type)) {
+ continue;
+ }
- if (pc->poll == NULL || pc->poll(C)) {
- /* Prevent drawing outside region. */
- GPU_scissor_test(true);
- GPU_scissor(region->winrct.xmin,
- region->winrct.ymin,
- BLI_rcti_size_x(&region->winrct) + 1,
- BLI_rcti_size_y(&region->winrct) + 1);
-
- if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) {
- int x = 0, y = 0;
- wm_get_cursor_position(win, &x, &y);
- pc->draw(C, x, y, pc->customdata);
- }
- else {
- pc->draw(C, win->eventstate->x, win->eventstate->y, pc->customdata);
- }
+ if ((pc->region_type != RGN_TYPE_ANY) && (region->regiontype != pc->region_type)) {
+ continue;
+ }
- GPU_scissor_test(false);
+ if (pc->poll == NULL || pc->poll(C)) {
+ /* Prevent drawing outside region. */
+ GPU_scissor_test(true);
+ GPU_scissor(region->winrct.xmin,
+ region->winrct.ymin,
+ BLI_rcti_size_x(&region->winrct) + 1,
+ BLI_rcti_size_y(&region->winrct) + 1);
+
+ if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) {
+ int x = 0, y = 0;
+ wm_get_cursor_position(win, &x, &y);
+ pc->draw(C, x, y, pc->customdata);
}
+ else {
+ pc->draw(C, win->eventstate->x, win->eventstate->y, pc->customdata);
+ }
+
+ GPU_scissor_test(false);
}
}
}
@@ -863,6 +863,10 @@ static void wm_draw_window(bContext *C, wmWindow *win)
{
bScreen *screen = WM_window_get_active_screen(win);
bool stereo = WM_stereo3d_enabled(win, false);
+
+ /* Avoid any BGL call issued before this to alter the window drawin. */
+ GPU_bgl_end();
+
/* Draw area regions into their own framebuffer. This way we can redraw
* the areas that need it, and blit the rest from existing framebuffers. */
wm_draw_window_offscreen(C, win, stereo);
@@ -956,10 +960,9 @@ static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win)
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
struct Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer);
bScreen *screen = WM_window_get_active_screen(win);
- ARegion *region;
bool do_draw = false;
- for (region = screen->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
if (region->do_draw_paintcursor) {
screen->do_draw_paintcursor = true;
region->do_draw_paintcursor = false;
@@ -970,7 +973,7 @@ static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win)
}
ED_screen_areas_iter (win, screen, area) {
- for (region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
wm_region_test_gizmo_do_draw(C, area, region, true);
wm_region_test_render_do_draw(scene, depsgraph, area, region);
#ifdef WITH_XR_OPENXR
@@ -1039,12 +1042,11 @@ void wm_draw_update(bContext *C)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win;
GPU_context_main_lock();
BKE_image_free_unused_gpu_textures();
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
#ifdef WIN32
GHOST_TWindowState state = GHOST_GetWindowState(win->ghostwin);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 76ec3bba368..07d5ffa1b82 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -157,7 +157,7 @@ void wm_event_free(wmEvent *event)
{
if (event->customdata) {
if (event->customdatafree) {
- /* note: pointer to listbase struct elsewhere */
+ /* Note: pointer to listbase struct elsewhere. */
if (event->custom == EVT_DATA_DRAGDROP) {
ListBase *lb = event->customdata;
WM_drag_free_list(lb);
@@ -174,7 +174,6 @@ void wm_event_free(wmEvent *event)
void wm_event_free_all(wmWindow *win)
{
wmEvent *event;
-
while ((event = BLI_pophead(&win->queue))) {
wm_event_free(event);
}
@@ -205,13 +204,11 @@ static bool wm_test_duplicate_notifier(const wmWindowManager *wm, uint type, voi
void WM_event_add_notifier_ex(wmWindowManager *wm, const wmWindow *win, uint type, void *reference)
{
- wmNotifier *note;
-
if (wm_test_duplicate_notifier(wm, type, reference)) {
return;
}
- note = MEM_callocN(sizeof(wmNotifier), "notifier");
+ wmNotifier *note = MEM_callocN(sizeof(wmNotifier), "notifier");
BLI_addtail(&wm->queue, note);
@@ -235,13 +232,12 @@ void WM_main_add_notifier(unsigned int type, void *reference)
{
Main *bmain = G_MAIN;
wmWindowManager *wm = bmain->wm.first;
- wmNotifier *note;
if (!wm || wm_test_duplicate_notifier(wm, type, reference)) {
return;
}
- note = MEM_callocN(sizeof(wmNotifier), "notifier");
+ wmNotifier *note = MEM_callocN(sizeof(wmNotifier), "notifier");
BLI_addtail(&wm->queue, note);
@@ -262,14 +258,10 @@ void WM_main_remove_notifier_reference(const void *reference)
wmWindowManager *wm = bmain->wm.first;
if (wm) {
- wmNotifier *note, *note_next;
-
- for (note = wm->queue.first; note; note = note_next) {
- note_next = note->next;
-
+ LISTBASE_FOREACH_MUTABLE (wmNotifier *, note, &wm->queue) {
if (note->reference == reference) {
- /* don't remove because this causes problems for #wm_event_do_notifiers
- * which may be looping on the data (deleting screens) */
+ /* Don't remove because this causes problems for #wm_event_do_notifiers
+ * which may be looping on the data (deleting screens). */
wm_notifier_clear(note);
}
}
@@ -286,15 +278,10 @@ void WM_main_remove_notifier_reference(const void *reference)
void WM_main_remap_editor_id_reference(ID *old_id, ID *new_id)
{
Main *bmain = G_MAIN;
- bScreen *screen;
-
- 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 = area->spacedata.first; sl; sl = sl->next) {
+ LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
ED_spacedata_id_remap(area, sl, old_id, new_id);
}
}
@@ -314,7 +301,7 @@ void WM_main_remap_editor_id_reference(ID *old_id, ID *new_id)
static void wm_notifier_clear(wmNotifier *note)
{
- /* NULL the entire notifier, only leaving (next, prev) members intact */
+ /* NULL the entire notifier, only leaving (next, prev) members intact. */
memset(((char *)note) + sizeof(Link), 0, sizeof(*note) - sizeof(Link));
}
@@ -322,13 +309,13 @@ void wm_event_do_depsgraph(bContext *C, bool is_after_open_file)
{
wmWindowManager *wm = CTX_wm_manager(C);
/* The whole idea of locked interface is to prevent viewport and whatever
- * thread to modify the same data. Because of this, we can not perform
+ * thread from modifying the same data. Because of this, we can not perform
* dependency graph update.
*/
if (wm->is_interface_locked) {
return;
}
- /* Combine datamasks so 1 win doesn't disable UV's in another T26448. */
+ /* Combine datamasks so one window doesn't disable UV's in another T26448. */
CustomData_MeshMasks win_combine_v3d_datamask = {0};
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
const Scene *scene = WM_window_get_active_scene(win);
@@ -369,7 +356,7 @@ void wm_event_do_depsgraph(bContext *C, bool is_after_open_file)
void wm_event_do_refresh_wm_and_depsgraph(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
- /* cached: editor refresh callbacks now, they get context */
+ /* Cached: editor refresh callbacks now, they get context. */
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
const bScreen *screen = WM_window_get_active_screen(win);
ScrArea *area;
@@ -403,12 +390,9 @@ static void wm_event_execute_timers(bContext *C)
CTX_wm_window_set(C, NULL);
}
-/* called in mainloop */
+/* Called in mainloop. */
void wm_event_do_notifiers(bContext *C)
{
- wmNotifier *note, *next;
- wmWindow *win;
-
/* Run the timer before assigning 'wm' in the unlikely case a timer loads a file, see T80028. */
wm_event_execute_timers(C);
@@ -417,18 +401,16 @@ void wm_event_do_notifiers(bContext *C)
return;
}
- /* disable? - keep for now since its used for window level notifiers. */
+ /* Disable? - Keep for now since its used for window level notifiers. */
#if 1
- /* cache & catch WM level notifiers, such as frame change, scene/screen set */
- for (win = wm->windows.first; win; win = win->next) {
+ /* Cache & catch WM level notifiers, such as frame change, scene/screen set. */
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
Scene *scene = WM_window_get_active_scene(win);
bool do_anim = false;
CTX_wm_window_set(C, win);
- for (note = wm->queue.first; note; note = next) {
- next = note->next;
-
+ LISTBASE_FOREACH_MUTABLE (wmNotifier *, note, &wm->queue) {
if (note->category == NC_WM) {
if (ELEM(note->data, ND_FILEREAD, ND_FILESAVE)) {
wm->file_saved = 1;
@@ -453,7 +435,8 @@ void wm_event_do_notifiers(bContext *C)
else if (note->data == ND_WORKSPACE_DELETE) {
WorkSpace *workspace = note->reference;
- ED_workspace_delete(workspace, CTX_data_main(C), C, wm); // XXX hrms, think this over!
+ ED_workspace_delete(
+ workspace, CTX_data_main(C), C, wm); /* XXX hrms, think this over! */
if (G.debug & G_DEBUG_EVENTS) {
printf("%s: Workspace delete %p\n", __func__, workspace);
}
@@ -473,7 +456,7 @@ void wm_event_do_notifiers(bContext *C)
WorkSpace *workspace = WM_window_get_active_workspace(win);
WorkSpaceLayout *layout = note->reference;
- ED_workspace_layout_delete(workspace, layout, C); // XXX hrms, think this over!
+ ED_workspace_layout_delete(workspace, layout, C); /* XXX hrms, think this over! */
if (G.debug & G_DEBUG_EVENTS) {
printf("%s: screen delete %p\n", __func__, note->reference);
}
@@ -501,27 +484,28 @@ void wm_event_do_notifiers(bContext *C)
* collide (happens on slow scenes), BKE_scene_graph_update_for_newframe can be called
* twice which can depgraph update the same object at once */
if (G.is_rendering == false) {
- /* depsgraph gets called, might send more notifiers */
+ /* Depsgraph gets called, might send more notifiers. */
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
ED_update_for_newframe(CTX_data_main(C), depsgraph);
}
}
}
- /* the notifiers are sent without context, to keep it clean */
+ /* The notifiers are sent without context, to keep it clean. */
+ wmNotifier *note;
while ((note = BLI_pophead(&wm->queue))) {
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
Scene *scene = WM_window_get_active_scene(win);
bScreen *screen = WM_window_get_active_screen(win);
WorkSpace *workspace = WM_window_get_active_workspace(win);
- /* filter out notifiers */
+ /* Dilter out notifiers. */
if (note->category == NC_SCREEN && note->reference && note->reference != screen &&
note->reference != workspace && note->reference != WM_window_get_active_layout(win)) {
- /* pass */
+ /* Pass. */
}
else if (note->category == NC_SCENE && note->reference && note->reference != scene) {
- /* pass */
+ /* Pass. */
}
else {
ARegion *region;
@@ -556,7 +540,7 @@ void wm_event_do_notifiers(bContext *C)
/* Handle message bus. */
{
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
CTX_wm_window_set(C, win);
WM_msgbus_handle(wm->message_bus, C);
}
@@ -567,7 +551,7 @@ void wm_event_do_notifiers(bContext *C)
/* Status bar */
if (wm->winactive) {
- win = wm->winactive;
+ wmWindow *win = wm->winactive;
CTX_wm_window_set(C, win);
WM_window_cursor_keymap_status_refresh(C, win);
CTX_wm_window_set(C, NULL);
@@ -579,7 +563,7 @@ void wm_event_do_notifiers(bContext *C)
static int wm_event_always_pass(const wmEvent *event)
{
- /* some events we always pass on, to ensure proper communication */
+ /* Some events we always pass on, to ensure proper communication. */
return ISTIMER(event->type) || (event->type == WINDEACTIVATE);
}
@@ -599,17 +583,16 @@ static int wm_handler_ui_call(bContext *C,
ARegion *menu = CTX_wm_menu(C);
static bool do_wheel_ui = true;
const bool is_wheel = ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE, MOUSEPAN);
- int retval;
/* UI code doesn't handle return values - it just always returns break.
- * to make the DBL_CLICK conversion work, we just don't send this to UI, except mouse clicks */
+ * to make the DBL_CLICK conversion work, we just don't send this to UI, except mouse clicks. */
if (((handler->head.flag & WM_HANDLER_ACCEPT_DBL_CLICK) == 0) && !ISMOUSE_BUTTON(event->type) &&
(event->val == KM_DBL_CLICK)) {
return WM_HANDLER_CONTINUE;
}
/* UI is quite aggressive with swallowing events, like scroll-wheel. */
- /* I realize this is not extremely nice code... when UI gets keymaps it can be maybe smarter */
+ /* I realize this is not extremely nice code... when UI gets keymaps it can be maybe smarter. */
if (do_wheel_ui == false) {
if (is_wheel) {
return WM_HANDLER_CONTINUE;
@@ -636,7 +619,7 @@ static int wm_handler_ui_call(bContext *C,
CTX_wm_menu_set(C, handler->context.menu);
}
- retval = handler->handle_fn(C, event, handler->user_data);
+ int retval = handler->handle_fn(C, event, handler->user_data);
/* putting back screen context */
if ((retval != WM_UI_HANDLER_BREAK) || always_pass) {
@@ -645,7 +628,7 @@ static int wm_handler_ui_call(bContext *C,
CTX_wm_menu_set(C, menu);
}
else {
- /* this special cases is for areas and regions that get removed */
+ /* This special cases is for areas and regions that get removed. */
CTX_wm_area_set(C, NULL);
CTX_wm_region_set(C, NULL);
CTX_wm_menu_set(C, NULL);
@@ -707,7 +690,6 @@ void WM_report_banner_show(void)
{
wmWindowManager *wm = G_MAIN->wm.first;
ReportList *wm_reports = &wm->reports;
- ReportTimerInfo *rti;
/* After adding reports to the global list, reset the report timer. */
WM_event_remove_timer(wm, NULL, wm_reports->reporttimer);
@@ -715,7 +697,7 @@ void WM_report_banner_show(void)
/* Records time since last report was added */
wm_reports->reporttimer = WM_event_add_timer(wm, wm->winactive, TIMERREPORT, 0.05);
- rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
+ ReportTimerInfo *rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
wm_reports->reporttimer->customdata = rti;
}
@@ -738,7 +720,7 @@ void WM_ndof_deadzone_set(float deadzone)
static void wm_add_reports(ReportList *reports)
{
- /* if the caller owns them, handle this */
+ /* If the caller owns them, handle this. */
if (reports->list.first && (reports->flag & RPT_OP_HOLD) == 0) {
wmWindowManager *wm = G_MAIN->wm.first;
@@ -752,7 +734,6 @@ static void wm_add_reports(ReportList *reports)
void WM_report(ReportType type, const char *message)
{
ReportList reports;
-
BKE_reports_init(&reports, RPT_STORE);
BKE_report(&reports, type, message);
@@ -763,10 +744,9 @@ void WM_report(ReportType type, const char *message)
void WM_reportf(ReportType type, const char *format, ...)
{
- DynStr *ds;
va_list args;
- ds = BLI_dynstr_new();
+ DynStr *ds = BLI_dynstr_new();
va_start(args, format);
BLI_dynstr_vappendf(ds, format, args);
va_end(args);
@@ -786,17 +766,16 @@ void WM_reportf(ReportType type, const char *format, ...)
bool WM_operator_poll(bContext *C, wmOperatorType *ot)
{
- wmOperatorTypeMacro *otmacro;
- for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) {
- wmOperatorType *ot_macro = WM_operatortype_find(otmacro->idname, 0);
+ LISTBASE_FOREACH (wmOperatorTypeMacro *, macro, &ot->macro) {
+ wmOperatorType *ot_macro = WM_operatortype_find(macro->idname, 0);
if (0 == WM_operator_poll(C, ot_macro)) {
return 0;
}
}
- /* python needs operator type, so we added exception for it */
+ /* Python needs operator type, so we added exception for it. */
if (ot->pyop_poll) {
return ot->pyop_poll(C, ot);
}
@@ -816,10 +795,9 @@ bool WM_operator_poll_context(bContext *C, wmOperatorType *ot, short context)
bool WM_operator_check_ui_empty(wmOperatorType *ot)
{
if (ot->macro.first != NULL) {
- /* for macros, check all have exec() we can call */
- wmOperatorTypeMacro *otmacro;
- for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) {
- wmOperatorType *otm = WM_operatortype_find(otmacro->idname, 0);
+ /* For macros, check all have exec() we can call. */
+ LISTBASE_FOREACH (wmOperatorTypeMacro *, macro, &ot->macro) {
+ wmOperatorType *otm = WM_operatortype_find(macro->idname, 0);
if (otm && !WM_operator_check_ui_empty(otm)) {
return false;
}
@@ -861,12 +839,12 @@ void WM_operator_region_active_win_set(bContext *C)
}
}
-/* (caller_owns_reports == true) when called from python */
+/* (caller_owns_reports == true) when called from python. */
static void wm_operator_reports(bContext *C, wmOperator *op, int retval, bool caller_owns_reports)
{
if (G.background == 0 && caller_owns_reports == false) { /* popup */
if (op->reports->list.first) {
- /* FIXME, temp setting window, see other call to UI_popup_menu_reports for why */
+ /* FIXME, temp setting window, see other call to UI_popup_menu_reports for why. */
wmWindow *win_prev = CTX_wm_window(C);
ScrArea *area_prev = CTX_wm_area(C);
ARegion *region_prev = CTX_wm_region(C);
@@ -887,12 +865,12 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, bool ca
CLOG_STR_INFO_N(WM_LOG_OPERATORS, 1, WM_operator_pystring(C, op, false, true));
if (caller_owns_reports == false) {
- BKE_reports_print(op->reports, RPT_DEBUG); /* print out reports to console. */
+ BKE_reports_print(op->reports, RPT_DEBUG); /* Print out reports to console. */
}
if (op->type->flag & OPTYPE_REGISTER) {
- if (G.background == 0) { /* ends up printing these in the terminal, gets annoying */
- /* Report the python string representation of the operator */
+ if (G.background == 0) { /* Ends up printing these in the terminal, gets annoying. */
+ /* Report the python string representation of the operator. */
char *buf = WM_operator_pystring(C, op, false, true);
BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf);
MEM_freeN(buf);
@@ -904,7 +882,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, bool ca
if ((retval & OPERATOR_CANCELLED) && !BLI_listbase_is_empty(&op->reports->list)) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO_REPORT, NULL);
}
- /* if the caller owns them, handle this */
+ /* If the caller owns them, handle this. */
wm_add_reports(op->reports);
}
@@ -934,9 +912,9 @@ static void wm_operator_finished(bContext *C, wmOperator *op, const bool repeat,
WM_operator_last_properties_store(op);
}
- /* we don't want to do undo pushes for operators that are being
- * called from operators that already do an undo push. usually
- * this will happen for python operators that call C operators */
+ /* We don't want to do undo pushes for operators that are being
+ * called from operators that already do an undo push. Usually
+ * this will happen for python operators that call C operators. */
if (wm->op_undo_depth == 0) {
if (op->type->flag & OPTYPE_UNDO) {
ED_undo_push_op(C, op);
@@ -992,7 +970,7 @@ static void wm_operator_finished(bContext *C, wmOperator *op, const bool repeat,
}
}
-/* if repeat is true, it doesn't register again, nor does it free */
+/* If repeat is true, it doesn't register again, nor does it free. */
static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, const bool store)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@ -1041,7 +1019,7 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons
return retval | OPERATOR_HANDLED;
}
-/* simply calls exec with basic checks */
+/* Simply calls exec with basic checks. */
static int wm_operator_exec_notest(bContext *C, wmOperator *op)
{
int retval = OPERATOR_CANCELLED;
@@ -1057,7 +1035,7 @@ static int wm_operator_exec_notest(bContext *C, wmOperator *op)
}
/**
- * for running operators with frozen context (modal handlers, menus)
+ * For running operators with frozen context (modal handlers, menus).
*
* \param store: Store settings for re-use.
*
@@ -1103,8 +1081,8 @@ int WM_operator_repeat_last(bContext *C, wmOperator *op)
return ret;
}
/**
- * \return true if #WM_operator_repeat can run
- * simple check for now but may become more involved.
+ * \return true if #WM_operator_repeat can run.
+ * Simple check for now but may become more involved.
* To be sure the operator can run call `WM_operator_poll(C, op->type)` also, since this call
* checks if #WM_operator_repeat() can run at all, not that it WILL run at any time.
*/
@@ -1115,9 +1093,8 @@ bool WM_operator_repeat_check(const bContext *UNUSED(C), wmOperator *op)
}
if (op->opm) {
/* for macros, check all have exec() we can call */
- wmOperatorTypeMacro *otmacro;
- for (otmacro = op->opm->type->macro.first; otmacro; otmacro = otmacro->next) {
- wmOperatorType *otm = WM_operatortype_find(otmacro->idname, 0);
+ LISTBASE_FOREACH (wmOperatorTypeMacro *, macro, &op->opm->type->macro) {
+ wmOperatorType *otm = WM_operatortype_find(macro->idname, 0);
if (otm && otm->exec == NULL) {
return false;
}
@@ -1130,7 +1107,7 @@ bool WM_operator_repeat_check(const bContext *UNUSED(C), wmOperator *op)
bool WM_operator_is_repeat(const bContext *C, const wmOperator *op)
{
- /* may be in the operators list or not */
+ /* May be in the operators list or not. */
wmOperator *op_prev;
if (op->prev == NULL && op->next == NULL) {
wmWindowManager *wm = CTX_wm_manager(C);
@@ -1154,7 +1131,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm,
op->type = ot;
BLI_strncpy(op->idname, ot->idname, OP_MAX_TYPENAME);
- /* initialize properties, either copy or create */
+ /* Initialize properties, either copy or create. */
op->ptr = MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA");
if (properties && properties->data) {
op->properties = IDP_CopyProperty(properties->data);
@@ -1165,30 +1142,29 @@ static wmOperator *wm_operator_create(wmWindowManager *wm,
}
RNA_pointer_create(&wm->id, ot->srna, op->properties, op->ptr);
- /* initialize error reports */
+ /* Initialize error reports. */
if (reports) {
- op->reports = reports; /* must be initialized already */
+ op->reports = reports; /* Must be initialized already. */
}
else {
op->reports = MEM_mallocN(sizeof(ReportList), "wmOperatorReportList");
BKE_reports_init(op->reports, RPT_STORE | RPT_FREE);
}
- /* recursive filling of operator macro list */
+ /* Recursive filling of operator macro list. */
if (ot->macro.first) {
static wmOperator *motherop = NULL;
- wmOperatorTypeMacro *otmacro;
int root = 0;
- /* ensure all ops are in execution order in 1 list */
+ /* Ensure all ops are in execution order in 1 list. */
if (motherop == NULL) {
motherop = op;
root = 1;
}
- /* if properties exist, it will contain everything needed */
+ /* If properties exist, it will contain everything needed. */
if (properties) {
- otmacro = ot->macro.first;
+ wmOperatorTypeMacro *otmacro = ot->macro.first;
RNA_STRUCT_BEGIN (properties, prop) {
@@ -1196,7 +1172,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm,
break;
}
- /* skip invalid properties */
+ /* Skip invalid properties. */
if (STREQ(RNA_property_identifier(prop), otmacro->idname)) {
wmOperatorType *otm = WM_operatortype_find(otmacro->idname, 0);
PointerRNA someptr = RNA_property_pointer_get(properties, prop);
@@ -1205,7 +1181,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm,
IDP_ReplaceGroupInGroup(opm->properties, otmacro->properties);
BLI_addtail(&motherop->macro, opm);
- opm->opm = motherop; /* pointer to mom, for modal() */
+ opm->opm = motherop; /* Pointer to mom, for modal(). */
otmacro = otmacro->next;
}
@@ -1213,12 +1189,12 @@ static wmOperator *wm_operator_create(wmWindowManager *wm,
RNA_STRUCT_END;
}
else {
- for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) {
- wmOperatorType *otm = WM_operatortype_find(otmacro->idname, 0);
- wmOperator *opm = wm_operator_create(wm, otm, otmacro->ptr, NULL);
+ LISTBASE_FOREACH (wmOperatorTypeMacro *, macro, &op->opm->type->macro) {
+ wmOperatorType *otm = WM_operatortype_find(macro->idname, 0);
+ wmOperator *opm = wm_operator_create(wm, otm, macro->ptr, NULL);
BLI_addtail(&motherop->macro, opm);
- opm->opm = motherop; /* pointer to mom, for modal() */
+ opm->opm = motherop; /* Pointer to mom, for modal(). */
}
}
@@ -1236,12 +1212,12 @@ static void wm_region_mouse_co(bContext *C, wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
if (region) {
- /* compatibility convention */
+ /* Compatibility convention. */
event->mval[0] = event->x - region->winrct.xmin;
event->mval[1] = event->y - region->winrct.ymin;
}
else {
- /* these values are invalid (avoid odd behavior by relying on old mval values) */
+ /* These values are invalid (avoid odd behavior by relying on old mval values). */
event->mval[0] = -1;
event->mval[1] = -1;
}
@@ -1269,7 +1245,7 @@ static int wm_operator_invoke(bContext *C,
if (WM_operator_poll(C, ot)) {
wmWindowManager *wm = CTX_wm_manager(C);
- /* if reports == NULL, they'll be initialized */
+ /* If reports == NULL, they'll be initialized. */
wmOperator *op = wm_operator_create(wm, ot, properties, reports);
const bool is_nested_call = (wm->op_undo_depth != 0);
@@ -1278,8 +1254,8 @@ static int wm_operator_invoke(bContext *C,
op->flag |= OP_IS_INVOKE;
}
- /* initialize setting from previous run */
- if (!is_nested_call && use_last_properties) { /* not called by py script */
+ /* /initialize setting from previous run. */
+ if (!is_nested_call && use_last_properties) { /* Not called by py script. */
WM_operator_last_properties_init(op);
}
@@ -1319,30 +1295,30 @@ static int wm_operator_invoke(bContext *C,
}
}
else {
- /* debug, important to leave a while, should never happen */
+ /* Debug, important to leave a while, should never happen. */
CLOG_ERROR(WM_LOG_OPERATORS, "invalid operator call '%s'", op->idname);
}
/* Note, if the report is given as an argument then assume the caller will deal with displaying
* them currently Python only uses this. */
if (!(retval & OPERATOR_HANDLED) && (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED))) {
- /* only show the report if the report list was not given in the function */
+ /* Only show the report if the report list was not given in the function. */
wm_operator_reports(C, op, retval, (reports != NULL));
}
if (retval & OPERATOR_HANDLED) {
- /* do nothing, wm_operator_exec() has been called somewhere */
+ /* Do nothing, wm_operator_exec() has been called somewhere. */
}
else if (retval & OPERATOR_FINISHED) {
const bool store = !is_nested_call && use_last_properties;
wm_operator_finished(C, op, false, store);
}
else if (retval & OPERATOR_RUNNING_MODAL) {
- /* take ownership of reports (in case python provided own) */
+ /* Take ownership of reports (in case python provided own). */
op->reports->flag |= RPT_FREE;
- /* grab cursor during blocking modal ops (X11)
- * Also check for macro
+ /* Grab cursor during blocking modal ops (X11)
+ * Also check for macro.
*/
if (ot->flag & OPTYPE_BLOCKING || (op->opm && op->opm->type->flag & OPTYPE_BLOCKING)) {
int bounds[4] = {-1, -1, -1, -1};
@@ -1392,10 +1368,10 @@ static int wm_operator_invoke(bContext *C,
WM_cursor_grab_enable(CTX_wm_window(C), wrap, false, bounds);
}
- /* cancel UI handlers, typically tooltips that can hang around
+ /* Cancel UI handlers, typically tooltips that can hang around
* while dragging the view or worse, that stay there permanently
* after the modal operator has swallowed all events and passed
- * none to the UI handler */
+ * none to the UI handler. */
wm_event_handler_ui_cancel(C);
}
else {
@@ -1408,9 +1384,8 @@ static int wm_operator_invoke(bContext *C,
/**
* #WM_operator_name_call is the main accessor function
- * this is for python to access since its done the operator lookup
- *
- * invokes operator in context
+ * This is for python to access since its done the operator lookup
+ * invokes operator in context.
*/
static int wm_operator_call_internal(bContext *C,
wmOperatorType *ot,
@@ -1424,7 +1399,7 @@ static int wm_operator_call_internal(bContext *C,
CTX_wm_operator_poll_msg_set(C, NULL);
- /* dummie test */
+ /* Dummy test. */
if (ot) {
wmWindow *window = CTX_wm_window(C);
@@ -1436,7 +1411,7 @@ static int wm_operator_call_internal(bContext *C,
case WM_OP_INVOKE_REGION_CHANNELS:
case WM_OP_INVOKE_AREA:
case WM_OP_INVOKE_SCREEN:
- /* window is needed for invoke, cancel operator */
+ /* Window is needed for invoke and cancel operators. */
if (window == NULL) {
if (poll_only) {
CTX_wm_operator_poll_msg_set(C, "Missing 'window' in context");
@@ -1473,8 +1448,8 @@ static int wm_operator_call_internal(bContext *C,
case WM_OP_INVOKE_REGION_CHANNELS:
case WM_OP_EXEC_REGION_PREVIEW:
case WM_OP_INVOKE_REGION_PREVIEW: {
- /* forces operator to go to the region window/channels/preview, for header menus
- * but we stay in the same region if we are already in one
+ /* Forces operator to go to the region window/channels/preview, for header menus,
+ * but we stay in the same region if we are already in one.
*/
ARegion *region = CTX_wm_region(C);
ScrArea *area = CTX_wm_area(C);
@@ -1514,14 +1489,14 @@ static int wm_operator_call_internal(bContext *C,
retval = wm_operator_invoke(C, ot, event, properties, reports, poll_only, true);
- /* set region back */
+ /* Set region back. */
CTX_wm_region_set(C, region);
return retval;
}
case WM_OP_EXEC_AREA:
case WM_OP_INVOKE_AREA: {
- /* remove region from context */
+ /* Remove region from context. */
ARegion *region = CTX_wm_region(C);
CTX_wm_region_set(C, NULL);
@@ -1532,7 +1507,7 @@ static int wm_operator_call_internal(bContext *C,
}
case WM_OP_EXEC_SCREEN:
case WM_OP_INVOKE_SCREEN: {
- /* remove region + area from context */
+ /* Remove region + area from context. */
ARegion *region = CTX_wm_region(C);
ScrArea *area = CTX_wm_area(C);
@@ -1553,7 +1528,7 @@ static int wm_operator_call_internal(bContext *C,
return 0;
}
-/* invokes operator in context */
+/* Invokes operator in context. */
int WM_operator_name_call_ptr(bContext *C,
wmOperatorType *ot,
short context,
@@ -1636,10 +1611,10 @@ int WM_operator_call_py(bContext *C,
#endif
- /* not especially nice using undo depth here, its used so py never
- * triggers undo or stores operators last used state.
+ /* Not especially nice using undo depth here. It's used so Python never
+ * triggers undo or stores an operator's last used state.
*
- * we could have some more obvious way of doing this like passing a flag.
+ * We could have some more obvious way of doing this like passing a flag.
*/
wmWindowManager *wm = CTX_wm_manager(C);
if (!is_undo && wm) {
@@ -1663,13 +1638,13 @@ int WM_operator_call_py(bContext *C,
* General API for different handler types.
* \{ */
-/* future extra customadata free? */
+/* Future extra customadata free? */
void wm_event_free_handler(wmEventHandler *handler)
{
MEM_freeN(handler);
}
-/* only set context when area/region is part of screen */
+/* Only set context when area/region is part of screen. */
static void wm_handler_op_context(bContext *C, wmEventHandler_Op *handler, const wmEvent *event)
{
wmWindow *win = handler->context.win ? handler->context.win : CTX_wm_window(C);
@@ -1678,68 +1653,70 @@ static void wm_handler_op_context(bContext *C, wmEventHandler_Op *handler, const
* possible. */
bScreen *screen = handler->context.win ? WM_window_get_active_screen(win) : CTX_wm_screen(C);
- if (screen && handler->op) {
- if (handler->context.area == NULL) {
- CTX_wm_area_set(C, NULL);
+ if (screen == NULL || handler->op == NULL) {
+ return;
+ }
+
+ if (handler->context.area == NULL) {
+ CTX_wm_area_set(C, NULL);
+ }
+ else {
+ ScrArea *area = NULL;
+
+ ED_screen_areas_iter (win, screen, area_iter) {
+ if (area_iter == handler->context.area) {
+ area = area_iter;
+ break;
+ }
}
- else {
- ScrArea *area = NULL;
- ED_screen_areas_iter (win, screen, area_iter) {
- if (area_iter == handler->context.area) {
- area = area_iter;
- break;
- }
+ if (area == NULL) {
+ /* When changing screen layouts with running modal handlers (like render display), this
+ * is not an error to print. */
+ if (handler->op == NULL) {
+ CLOG_ERROR(WM_LOG_HANDLERS,
+ "internal error: handler (%s) has invalid area",
+ handler->op->type->idname);
}
+ }
+ else {
+ ARegion *region;
+ wmOperator *op = handler->op ? (handler->op->opm ? handler->op->opm : handler->op) : NULL;
+ CTX_wm_area_set(C, area);
- if (area == NULL) {
- /* when changing screen layouts with running modal handlers (like render display), this
- * is not an error to print */
- if (handler->op == NULL) {
- CLOG_ERROR(WM_LOG_HANDLERS,
- "internal error: handler (%s) has invalid area",
- handler->op->type->idname);
+ if (op && (op->flag & OP_IS_MODAL_CURSOR_REGION)) {
+ region = BKE_area_find_region_xy(area, handler->context.region_type, event->x, event->y);
+ if (region) {
+ handler->context.region = region;
}
}
else {
- ARegion *region;
- wmOperator *op = handler->op ? (handler->op->opm ? handler->op->opm : handler->op) : NULL;
- CTX_wm_area_set(C, area);
-
- if (op && (op->flag & OP_IS_MODAL_CURSOR_REGION)) {
- region = BKE_area_find_region_xy(area, handler->context.region_type, event->x, event->y);
- if (region) {
- handler->context.region = region;
- }
- }
- else {
- region = NULL;
- }
+ region = NULL;
+ }
- if (region == NULL) {
- for (region = area->regionbase.first; region; region = region->next) {
- if (region == handler->context.region) {
- break;
- }
+ if (region == NULL) {
+ for (region = area->regionbase.first; region; region = region->next) {
+ if (region == handler->context.region) {
+ break;
}
}
+ }
- /* XXX no warning print here, after full-area and back regions are remade */
- if (region) {
- CTX_wm_region_set(C, region);
- }
+ /* XXX no warning print here, after full-area and back regions are remade. */
+ if (region) {
+ CTX_wm_region_set(C, region);
}
}
}
}
-/* called on exit or remove area, only here call cancel callback */
+/* Called on exit or remove area, only here call cancel callback. */
void WM_event_remove_handlers(bContext *C, ListBase *handlers)
{
- wmEventHandler *handler_base;
wmWindowManager *wm = CTX_wm_manager(C);
/* C is zero on freeing database, modal handlers then already were freed */
+ wmEventHandler *handler_base;
while ((handler_base = BLI_pophead(handlers))) {
BLI_assert(handler_base->type != 0);
if (handler_base->type == WM_HANDLER_TYPE_OP) {
@@ -1814,9 +1791,9 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi)
const int kmitype = WM_userdef_event_map(kmi->type);
- /* the matching rules */
+ /* The matching rules. */
if (kmitype == KM_TEXTINPUT) {
- if (winevent->val == KM_PRESS) { /* prevent double clicks */
+ if (winevent->val == KM_PRESS) { /* Prevent double clicks. */
/* NOT using ISTEXTINPUT anymore because (at least on Windows) some key codes above 255
* could have printable ascii keys - BUG T30479. */
if (ISKEYBOARD(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) {
@@ -1830,7 +1807,7 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi)
const wmTabletData *wmtab = &winevent->tablet;
if (winevent->type != LEFTMOUSE) {
- /* tablet events can occur on hover + keypress */
+ /* Tablet events can occur on hover + keypress. */
return false;
}
if ((kmitype == TABLET_STYLUS) && (wmtab->active != EVT_TABLET_STYLUS)) {
@@ -1925,7 +1902,7 @@ static void wm_event_modalkeymap_begin(const bContext *C,
{
BLI_assert(event->type != EVT_MODAL_MAP);
- /* support for modal keymap in macros */
+ /* Support for modal keymap in macros. */
if (op->opm) {
op = op->opm;
}
@@ -2004,7 +1981,7 @@ static int wm_handler_operator_call(bContext *C,
{
int retval = OPERATOR_PASS_THROUGH;
- /* derived, modal or blocking operator */
+ /* Derived, modal or blocking operator. */
if ((handler_base->type == WM_HANDLER_TYPE_OP) &&
(((wmEventHandler_Op *)handler_base)->op != NULL)) {
wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
@@ -2017,7 +1994,7 @@ static int wm_handler_operator_call(bContext *C,
*/
}
else if (ot->modal) {
- /* we set context to where modal handler came from */
+ /* We set context to where modal handler came from. */
wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
@@ -2031,11 +2008,11 @@ static int wm_handler_operator_call(bContext *C,
wm->op_undo_depth++;
}
- /* warning, after this call all context data and 'event' may be freed. see check below */
+ /* Warning, after this call all context data and 'event' may be freed. see check below. */
retval = ot->modal(C, op, event);
OPERATOR_RETVAL_CHECK(retval);
- /* when this is _not_ the case the modal modifier may have loaded
+ /* When this is _not_ the case the modal modifier may have loaded
* a new blend file (demo mode does this), so we have to assume
* the event, operator etc have all been freed. - campbell */
if (CTX_wm_manager(C) == wm) {
@@ -2055,13 +2032,13 @@ static int wm_handler_operator_call(bContext *C,
}
}
else {
- /* not very common, but modal operators may report before finishing */
+ /* Not very common, but modal operators may report before finishing. */
if (!BLI_listbase_is_empty(&op->reports->list)) {
wm_add_reports(op->reports);
}
}
- /* important to run 'wm_operator_finished' before NULLing the context members */
+ /* Important to run 'wm_operator_finished' before NULLing the context members. */
if (retval & OPERATOR_FINISHED) {
wm_operator_finished(C, op, false, true);
handler->op = NULL;
@@ -2071,21 +2048,21 @@ static int wm_handler_operator_call(bContext *C,
handler->op = NULL;
}
- /* putting back screen context, reval can pass trough after modal failures! */
+ /* Putting back screen context, reval can pass trough after modal failures! */
if ((retval & OPERATOR_PASS_THROUGH) || wm_event_always_pass(event)) {
CTX_wm_area_set(C, area);
CTX_wm_region_set(C, region);
}
else {
- /* this special cases is for areas and regions that get removed */
+ /* This special cases is for areas and regions that get removed. */
CTX_wm_area_set(C, NULL);
CTX_wm_region_set(C, NULL);
}
- /* update gizmos during modal handlers */
+ /* /update gizmos during modal handlers. */
wm_gizmomaps_handled_modal_update(C, event, handler);
- /* remove modal handler, operator itself should have been canceled and freed */
+ /* Remove modal handler, operator itself should have been canceled and freed. */
if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) {
WM_cursor_grab_disable(CTX_wm_window(C), NULL);
@@ -2163,14 +2140,14 @@ static int wm_handler_operator_call(bContext *C,
/* Done linking gizmo. */
}
}
- /* Finished and pass through flag as handled */
+ /* Finished and pass through flag as handled. */
- /* Finished and pass through flag as handled */
+ /* Finished and pass through flag as handled. */
if (retval == (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH)) {
return WM_HANDLER_HANDLED;
}
- /* Modal unhandled, break */
+ /* Modal unhandled, break. */
if (retval == (OPERATOR_PASS_THROUGH | OPERATOR_RUNNING_MODAL)) {
return (WM_HANDLER_BREAK | WM_HANDLER_MODAL);
}
@@ -2211,10 +2188,10 @@ static int wm_handler_fileselect_do(bContext *C,
BLI_assert(area->spacetype == SPACE_FILE);
region_header->flag |= RGN_FLAG_HIDDEN;
- /* Header on bottom, AZone triangle to toggle header looks misplaced at the top */
+ /* Header on bottom, AZone triangle to toggle header looks misplaced at the top. */
region_header->alignment = RGN_ALIGN_BOTTOM;
- /* settings for filebrowser, sfile is not operator owner but sends events */
+ /* Settings for filebrowser, #sfile is not operator owner but sends events. */
SpaceFile *sfile = (SpaceFile *)area->spacedata.first;
sfile->op = handler->op;
@@ -2234,7 +2211,7 @@ static int wm_handler_fileselect_do(bContext *C,
case EVT_FILESELECT_EXTERNAL_CANCEL: {
wmWindow *ctx_win = CTX_wm_window(C);
- /* remlink now, for load file case before removing*/
+ /* Remove link now, for load file case before removing. */
BLI_remlink(handlers, handler);
if (val == EVT_FILESELECT_EXTERNAL_CANCEL) {
@@ -2262,11 +2239,11 @@ static int wm_handler_fileselect_do(bContext *C,
wm_window_close(C, wm, temp_win);
- CTX_wm_window_set(C, ctx_win); // wm_window_close() NULLs.
- /* Some operators expect a drawable context (for EVT_FILESELECT_EXEC) */
+ CTX_wm_window_set(C, ctx_win); /* #wm_window_close() NULLs. */
+ /* Some operators expect a drawable context (for EVT_FILESELECT_EXEC). */
wm_window_make_drawable(wm, ctx_win);
/* Ensure correct cursor position, otherwise, popups may close immediately after
- * opening (UI_BLOCK_MOVEMOUSE_QUIT) */
+ * opening (UI_BLOCK_MOVEMOUSE_QUIT). */
wm_get_cursor_position(ctx_win, &ctx_win->eventstate->x, &ctx_win->eventstate->y);
wm->winactive = ctx_win; /* Reports use this... */
if (handler->context.win == temp_win) {
@@ -2292,7 +2269,7 @@ static int wm_handler_fileselect_do(bContext *C,
wm_handler_op_context(C, handler, ctx_win->eventstate);
- /* needed for UI_popup_menu_reports */
+ /* Needed for #UI_popup_menu_reports. */
if (val == EVT_FILESELECT_EXEC) {
int retval;
@@ -2338,7 +2315,7 @@ static int wm_handler_fileselect_do(bContext *C,
/* add reports to the global list, otherwise they are not seen */
BLI_movelisttolist(&CTX_wm_reports(C)->list, &handler->op->reports->list);
- /* more hacks, since we meddle with reports, banner display doesn't happen automatic */
+ /* More hacks, since we meddle with reports, banner display doesn't happen automaticM */
WM_report_banner_show();
CTX_wm_window_set(C, win_prev);
@@ -2346,7 +2323,7 @@ static int wm_handler_fileselect_do(bContext *C,
CTX_wm_region_set(C, region_prev);
}
- /* for WM_operator_pystring only, custom report handling is done above */
+ /* For WM_operator_pystring only, custom report handling is done above. */
wm_operator_reports(C, handler->op, retval, true);
if (retval & OPERATOR_FINISHED) {
@@ -2412,7 +2389,7 @@ static int wm_action_not_handled(int action)
printf
static int wm_handlers_do_keymap_with_keymap_handler(
- /* From 'wm_handlers_do_intern' */
+ /* From 'wm_handlers_do_intern'. */
bContext *C,
wmEvent *event,
ListBase *handlers,
@@ -2444,7 +2421,7 @@ static int wm_handlers_do_keymap_with_keymap_handler(
C, handlers, &handler->head, event, kmi->ptr, kmi->idname);
if (action & WM_HANDLER_BREAK) {
- /* not always_pass here, it denotes removed handler_base */
+ /* Not always_pass here, it denotes removed handler_base. */
CLOG_INFO(WM_LOG_HANDLERS, 2, "handled! '%s'", kmi->idname);
if (keymap_post.post_fn != NULL) {
keymap_post.post_fn(keymap, kmi, keymap_post.user_data);
@@ -2495,7 +2472,7 @@ static int wm_handlers_do_keymap_with_gizmo_handler(
CTX_wm_gizmo_group_set(C, gzgroup);
- /* handler->op is called later, we want keymap op to be triggered here */
+ /* handler->op is called later, we want keymap op to be triggered here. */
action |= wm_handler_operator_call(
C, handlers, &handler->head, event, kmi->ptr, kmi->idname);
@@ -2545,7 +2522,7 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
/* Needed so UI blocks over gizmos don't let events fall through to the gizmos,
* noticeable for the node editor - where dragging on a node should move it, see: T73212.
- * note we still allow for starting the gizmo drag outside, then travel 'inside' the node */
+ * note we still allow for starting the gizmo drag outside, then travel 'inside' the node. */
if (region->type->clip_gizmo_events_by_ui) {
if (UI_region_block_find_mouse_over(region, &event->x, true)) {
if (gz != NULL && event->type != EVT_GIZMO_UPDATE) {
@@ -2571,7 +2548,7 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
bool handle_highlight = false;
bool handle_keymap = false;
- /* handle gizmo highlighting */
+ /* Handle gizmo highlighting. */
if (!wm_gizmomap_modal_get(gzmap) &&
((event->type == MOUSEMOVE) || is_event_modifier || is_event_drag)) {
handle_highlight = true;
@@ -2698,7 +2675,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
{
const bool do_debug_handler =
(G.debug & G_DEBUG_HANDLERS) &&
- /* comment this out to flood the console! (if you really want to test) */
+ /* Comment this out to flood the console! (if you really want to test). */
!ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE);
wmWindowManager *wm = CTX_wm_manager(C);
@@ -2709,9 +2686,9 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
return action;
}
- /* modal handlers can get removed in this loop, we keep the loop this way
+ /* Modal handlers can get removed in this loop, we keep the loop this way.
*
- * note: check 'handlers->first' because in rare cases the handlers can be cleared
+ * Note: check 'handlers->first' because in rare cases the handlers can be cleared
* by the event that's called, for eg:
*
* Calling a python script which changes the area.type, see T32232. */
@@ -2722,13 +2699,13 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
/* During this loop, UI handlers for nested menus can tag multiple handlers free. */
if (handler_base->flag & WM_HANDLER_DO_FREE) {
- /* pass */
+ /* Pass. */
}
else if (handler_base->poll == NULL || handler_base->poll(CTX_wm_region(C), event)) {
- /* in advance to avoid access to freed event on window close */
+ /* In advance to avoid access to freed event on window close. */
always_pass = wm_event_always_pass(event);
- /* modal+blocking handler_base */
+ /* Modal+blocking handler_base. */
if (handler_base->flag & WM_HANDLER_BLOCKING) {
action |= WM_HANDLER_BREAK;
}
@@ -2759,14 +2736,11 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
else if (handler_base->type == WM_HANDLER_TYPE_DROPBOX) {
wmEventHandler_Dropbox *handler = (wmEventHandler_Dropbox *)handler_base;
if (!wm->is_interface_locked && event->type == EVT_DROP) {
- wmDropBox *drop = handler->dropboxes->first;
- for (; drop; drop = drop->next) {
- /* other drop custom types allowed */
+ LISTBASE_FOREACH (wmDropBox *, drop, handler->dropboxes) {
+ /* Other drop custom types allowed. */
if (event->custom == EVT_DATA_DRAGDROP) {
ListBase *lb = (ListBase *)event->customdata;
- wmDrag *drag;
-
- for (drag = lb->first; drag; drag = drag->next) {
+ LISTBASE_FOREACH (wmDrag *, drag, lb) {
const char *tooltip = NULL;
if (drop->poll(C, drag, event, &tooltip)) {
/* Optionally copy drag information to operator properties. */
@@ -2783,19 +2757,19 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
C, drop->ot, drop->ptr, NULL, drop->opcontext, false, event);
action |= WM_HANDLER_BREAK;
- /* free the drags */
+ /* Free the drags. */
WM_drag_free_list(lb);
WM_drag_free_list(&single_lb);
event->customdata = NULL;
event->custom = 0;
- /* XXX fileread case */
+ /* XXX fileread case. */
if (CTX_wm_window(C) == NULL) {
return action;
}
- /* escape from drag loop, got freed */
+ /* Escape from drag loop, got freed. */
break;
}
}
@@ -2811,7 +2785,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
if (handler->is_fileselect) {
if (!wm->is_interface_locked) {
- /* screen context changes here */
+ /* Screen context changes here. */
action |= wm_handler_fileselect_call(C, handlers, handler, event);
}
}
@@ -2840,11 +2814,11 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
return action;
}
- /* XXX code this for all modal ops, and ensure free only happens here */
+ /* XXX code this for all modal ops, and ensure free only happens here. */
/* Modal UI handler can be tagged to be freed. */
if (BLI_findindex(handlers, handler_base) !=
- -1) { /* could be freed already by regular modal ops */
+ -1) { /* Could be freed already by regular modal ops. */
if (handler_base->flag & WM_HANDLER_DO_FREE) {
BLI_remlink(handlers, handler_base);
wm_event_free_handler(handler_base);
@@ -2861,12 +2835,12 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
#undef PRINT
-/* this calls handlers twice - to solve (double-)click events */
+/* This calls handlers twice - to solve (double-)click events. */
static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
{
int action = wm_handlers_do_intern(C, event, handlers);
- /* fileread case */
+ /* Fileread case. */
if (CTX_wm_window(C) == NULL) {
return action;
}
@@ -3041,10 +3015,9 @@ static ARegion *region_event_inside(bContext *C, const int xy[2])
{
bScreen *screen = CTX_wm_screen(C);
ScrArea *area = CTX_wm_area(C);
- ARegion *region;
if (screen && area) {
- for (region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (BLI_rcti_isect_pt_v(&region->winrct, xy)) {
return region;
}
@@ -3065,8 +3038,8 @@ static void wm_paintcursor_tag(bContext *C, wmPaintCursor *pc, ARegion *region)
}
}
-/* called on mousemove, check updates for paintcursors */
-/* context was set on active area and region */
+/* Called on mousemove, check updates for paintcursors. */
+/* Context was set on active area and region. */
static void wm_paintcursor_test(bContext *C, const wmEvent *event)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@ -3078,7 +3051,7 @@ static void wm_paintcursor_test(bContext *C, const wmEvent *event)
wm_paintcursor_tag(C, wm->paintcursors.first, region);
}
- /* if previous position was not in current region, we have to set a temp new context */
+ /* If previous position was not in current region, we have to set a temp new context. */
if (region == NULL || !BLI_rcti_isect_pt_v(&region->winrct, &event->prevx)) {
ScrArea *area = CTX_wm_area(C);
@@ -3112,7 +3085,7 @@ static void wm_event_drag_and_drop_test(wmWindowManager *wm, wmWindow *win, wmEv
else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
event->type = EVT_DROP;
- /* create customdata, first free existing */
+ /* Vreate customdata, first free existing. */
if (event->customdata) {
if (event->customdatafree) {
MEM_freeN(event->customdata);
@@ -3123,7 +3096,7 @@ static void wm_event_drag_and_drop_test(wmWindowManager *wm, wmWindow *win, wmEv
event->customdata = &wm->drags;
event->customdatafree = 1;
- /* clear drop icon */
+ /* Vlear drop icon. */
screen->do_draw_drag = true;
/* restore cursor (disabled, see wm_dragdrop.c) */
@@ -3131,7 +3104,7 @@ static void wm_event_drag_and_drop_test(wmWindowManager *wm, wmWindow *win, wmEv
}
}
-/* filter out all events of the pie that spawned the last pie unless it's a release event */
+/* Filter out all events of the pie that spawned the last pie unless it's a release event. */
static bool wm_event_pie_filter(wmWindow *win, const wmEvent *event)
{
if (win->lock_pie_event && win->lock_pie_event == event->type) {
@@ -3171,22 +3144,20 @@ static void wm_event_free_and_remove_from_queue_if_valid(wmEvent *event)
* Handle events for all windows, run from the #WM_main event loop.
* \{ */
-/* called in main loop */
-/* goes over entire hierarchy: events -> window -> screen -> area -> region */
+/* Called in main loop. */
+/* Goes over entire hierarchy: events -> window -> screen -> area -> region. */
void wm_event_do_handlers(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win;
- /* update key configuration before handling events */
+ /* Update key configuration before handling events. */
WM_keyconfig_update(wm);
WM_gizmoconfig_update(CTX_data_main(C));
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
bScreen *screen = WM_window_get_active_screen(win);
- wmEvent *event;
- /* some safety checks - these should always be set! */
+ /* Some safety checks - these should always be set! */
BLI_assert(WM_window_get_active_scene(win));
BLI_assert(WM_window_get_active_screen(win));
BLI_assert(WM_window_get_active_workspace(win));
@@ -3244,10 +3215,11 @@ void wm_event_do_handlers(bContext *C)
}
}
+ wmEvent *event;
while ((event = win->queue.first)) {
int action = WM_HANDLER_CONTINUE;
- /* active screen might change during handlers, update pointer */
+ /* Active screen might change during handlers, update pointer. */
screen = WM_window_get_active_screen(win);
if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) &&
@@ -3256,7 +3228,7 @@ void wm_event_do_handlers(bContext *C)
WM_event_print(event);
}
- /* take care of pie event filter */
+ /* Take care of pie event filter. */
if (wm_event_pie_filter(win, event)) {
if (!ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
CLOG_INFO(WM_LOG_HANDLERS, 1, "event filtered due to pie button pressed");
@@ -3277,7 +3249,7 @@ void wm_event_do_handlers(bContext *C)
}
}
- /* we let modal handlers get active area/region, also wm_paintcursor_test needs it */
+ /* We let modal handlers get active area/region, also wm_paintcursor_test needs it. */
CTX_wm_area_set(C, area_event_inside(C, &event->x));
CTX_wm_region_set(C, region_event_inside(C, &event->x));
@@ -3287,16 +3259,16 @@ void wm_event_do_handlers(bContext *C)
wm_region_mouse_co(C, event);
- /* first we do priority handlers, modal + some limited keymaps */
+ /* First we do priority handlers, modal + some limited keymaps. */
action |= wm_handlers_do(C, event, &win->modalhandlers);
- /* fileread case */
+ /* Fileread case. */
if (CTX_wm_window(C) == NULL) {
wm_event_free_and_remove_from_queue_if_valid(event);
return;
}
- /* check for a tooltip */
+ /* Check for a tooltip. */
if (screen == WM_window_get_active_screen(win)) {
if (screen->tool_tip && screen->tool_tip->timer) {
if ((event->type == TIMER) && (event->customdata == screen->tool_tip->timer)) {
@@ -3305,21 +3277,19 @@ void wm_event_do_handlers(bContext *C)
}
}
- /* check dragging, creates new event or frees, adds draw tag */
+ /* Check dragging, creates new event or frees, adds draw tag. */
wm_event_drag_and_drop_test(wm, win, event);
- /* builtin tweak, if action is break it removes tweak */
+ /* Builtin tweak, if action is break it removes tweak. */
wm_tweakevent_test(C, event, action);
if ((action & WM_HANDLER_BREAK) == 0) {
- ARegion *region;
-
/* Note: setting subwin active should be done here, after modal handlers have been done */
if (event->type == MOUSEMOVE) {
/* State variables in screen, cursors.
* Also used in wm_draw.c, fails for modal handlers though. */
ED_screen_set_active_region(C, win, &event->x);
- /* for regions having custom cursors */
+ /* For regions having custom cursors. */
wm_paintcursor_test(C, event);
}
#ifdef WITH_INPUT_NDOF
@@ -3329,15 +3299,16 @@ void wm_event_do_handlers(bContext *C)
#endif
ED_screen_areas_iter (win, screen, area) {
- /* after restoring a screen from SCREENMAXIMIZED we have to wait
- * with the screen handling till the region coordinates are updated */
+ /* After restoring a screen from SCREENMAXIMIZED we have to wait
+ * with the screen handling till the region coordinates are updated. */
if (screen->skip_handling == true) {
- /* restore for the next iteration of wm_event_do_handlers */
+ /* Restore for the next iteration of wm_event_do_handlers. */
screen->skip_handling = false;
break;
}
- /* update azones if needed - done here because it needs to be independent from redraws */
+ /* Update azones if needed - done here because it needs to be independent from redraws.
+ */
if (area->flag & AREA_FLAG_ACTIONZONES_UPDATE) {
ED_area_azones_update(area, &event->x);
}
@@ -3346,17 +3317,17 @@ void wm_event_do_handlers(bContext *C)
CTX_wm_area_set(C, area);
if ((action & WM_HANDLER_BREAK) == 0) {
- for (region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (wm_event_inside_region(event, region)) {
CTX_wm_region_set(C, region);
- /* call even on non mouse events, since the */
+ /* Call even on non mouse events, since the */
wm_region_mouse_co(C, event);
if (!BLI_listbase_is_empty(&wm->drags)) {
- /* does polls for drop regions and checks uibuts */
- /* need to be here to make sure region context is true */
+ /* Does polls for drop regions and checks #uiButs. */
+ /* Need to be here to make sure region context is true. */
if (ELEM(event->type, MOUSEMOVE, EVT_DROP) || ISKEYMODIFIER(event->type)) {
wm_drags_check_ops(C, event);
}
@@ -3364,7 +3335,7 @@ void wm_event_do_handlers(bContext *C)
action |= wm_handlers_do(C, event, &region->handlers);
- /* fileread case (python), T29489. */
+ /* Fileread case (python), T29489. */
if (CTX_wm_window(C) == NULL) {
wm_event_free_and_remove_from_queue_if_valid(event);
return;
@@ -3380,7 +3351,7 @@ void wm_event_do_handlers(bContext *C)
CTX_wm_region_set(C, NULL);
if ((action & WM_HANDLER_BREAK) == 0) {
- wm_region_mouse_co(C, event); /* only invalidates event->mval in this case */
+ wm_region_mouse_co(C, event); /* Only invalidates event->mval in this case. */
action |= wm_handlers_do(C, event, &area->handlers);
}
CTX_wm_area_set(C, NULL);
@@ -3391,7 +3362,7 @@ void wm_event_do_handlers(bContext *C)
}
if ((action & WM_HANDLER_BREAK) == 0) {
- /* also some non-modal handlers need active area/region */
+ /* Also some non-modal handlers need active area/region. */
CTX_wm_area_set(C, area_event_inside(C, &event->x));
CTX_wm_region_set(C, region_event_inside(C, &event->x));
@@ -3399,7 +3370,7 @@ void wm_event_do_handlers(bContext *C)
action |= wm_handlers_do(C, event, &win->handlers);
- /* fileread case */
+ /* Fileread case. */
if (CTX_wm_window(C) == NULL) {
wm_event_free_and_remove_from_queue_if_valid(event);
return;
@@ -3414,16 +3385,16 @@ void wm_event_do_handlers(bContext *C)
win->eventstate->check_click = false;
}
- /* update previous mouse position for following events to use */
+ /* Update previous mouse position for following events to use. */
win->eventstate->prevx = event->x;
win->eventstate->prevy = event->y;
- /* unlink and free here, blender-quit then frees all */
+ /* Unlink and free here, blender-quit then frees all. */
BLI_remlink(&win->queue, event);
wm_event_free(event);
}
- /* only add mousemove when queue was read entirely */
+ /* Only add mousemove when queue was read entirely. */
if (win->addmousemove && win->eventstate) {
wmEvent tevent = *(win->eventstate);
// printf("adding MOUSEMOVE %d %d\n", tevent.x, tevent.y);
@@ -3437,7 +3408,7 @@ void wm_event_do_handlers(bContext *C)
CTX_wm_window_set(C, NULL);
}
- /* update key configuration after handling events */
+ /* Update key configuration after handling events. */
WM_keyconfig_update(wm);
WM_gizmoconfig_update(CTX_data_main(C));
}
@@ -3450,28 +3421,26 @@ void wm_event_do_handlers(bContext *C)
void WM_event_fileselect_event(wmWindowManager *wm, void *ophandle, int eventval)
{
- /* add to all windows! */
- wmWindow *win;
-
- for (win = wm->windows.first; win; win = win->next) {
+ /* Add to all windows! */
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
wmEvent event = *win->eventstate;
event.type = EVT_FILESELECT;
event.val = eventval;
- event.customdata = ophandle; // only as void pointer type check
+ event.customdata = ophandle; /* Only as void pointer type check. */
wm_event_add(win, &event);
}
}
-/* operator is supposed to have a filled "path" property */
-/* optional property: filetype (XXX enum?) */
+/* Operator is supposed to have a filled "path" property. */
+/* Optional property: filetype (XXX enum?) */
/**
* The idea here is to keep a handler alive on window queue, owning the operator.
* The file window can send event to make it execute, thus ensuring
* executing happens outside of lower level queues, with UI refreshed.
- * Should also allow multiwin solutions
+ * Should also allow multiwin solutions.
*/
void WM_event_add_fileselect(bContext *C, wmOperator *op)
{
@@ -3483,7 +3452,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
UI_popup_handlers_remove_all(C, &win->modalhandlers);
if (!is_temp_screen) {
- /* only allow 1 file selector open per window */
+ /* Only allow 1 file selector open per window. */
LISTBASE_FOREACH_MUTABLE (wmEventHandler *, handler_base, &win->modalhandlers) {
if (handler_base->type == WM_HANDLER_TYPE_OP) {
wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
@@ -3493,7 +3462,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
bScreen *screen = CTX_wm_screen(C);
bool cancel_handler = true;
- /* find the area with the file selector for this handler */
+ /* Find the area with the file selector for this handler. */
ED_screen_areas_iter (win, screen, area) {
if (area->spacetype == SPACE_FILE) {
SpaceFile *sfile = area->spacedata.first;
@@ -3507,7 +3476,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
}
}
- /* if not found we stop the handler without changing the screen */
+ /* If not found we stop the handler without changing the screen. */
if (cancel_handler) {
wm_handler_fileselect_do(
C, &win->modalhandlers, handler, EVT_FILESELECT_EXTERNAL_CANCEL);
@@ -3527,10 +3496,10 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
BLI_addhead(&win->modalhandlers, handler);
- /* check props once before invoking if check is available
- * ensures initial properties are valid */
+ /* Check props once before invoking if check is available
+ * ensures initial properties are valid. */
if (op->type->check) {
- op->type->check(C, op); /* ignore return value */
+ op->type->check(C, op); /* Ignore return value. */
}
WM_event_fileselect_event(wm, op, EVT_FILESELECT_FULL_OPEN);
@@ -3556,18 +3525,18 @@ wmEventHandler_Op *WM_event_add_modal_handler(bContext *C, wmOperator *op)
handler->head.type = WM_HANDLER_TYPE_OP;
wmWindow *win = CTX_wm_window(C);
- /* operator was part of macro */
+ /* Operator was part of macro. */
if (op->opm) {
- /* give the mother macro to the handler */
+ /* Give the mother macro to the handler. */
handler->op = op->opm;
- /* mother macro opm becomes the macro element */
+ /* Mother macro opm becomes the macro element. */
handler->op->opm = op;
}
else {
handler->op = op;
}
- handler->context.area = CTX_wm_area(C); /* means frozen screen context for modal handlers! */
+ handler->context.area = CTX_wm_area(C); /* Means frozen screen context for modal handlers! */
handler->context.region = CTX_wm_region(C);
handler->context.region_type = handler->context.region ? handler->context.region->regiontype :
-1;
@@ -3627,7 +3596,7 @@ wmEventHandler_Keymap *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap
return NULL;
}
- /* only allow same keymap once */
+ /* Only allow same keymap once. */
LISTBASE_FOREACH (wmEventHandler *, handler_base, handlers) {
if (handler_base->type == WM_HANDLER_TYPE_KEYMAP) {
wmEventHandler_Keymap *handler = (wmEventHandler_Keymap *)handler_base;
@@ -3737,7 +3706,7 @@ struct wmEventHandler_Keymap *WM_event_add_keymap_handler_dynamic(
return NULL;
}
- /* only allow same keymap once */
+ /* Only allow same keymap once. */
LISTBASE_FOREACH (wmEventHandler *, handler_base, handlers) {
if (handler_base->type == WM_HANDLER_TYPE_KEYMAP) {
wmEventHandler_Keymap *handler = (wmEventHandler_Keymap *)handler_base;
@@ -3758,7 +3727,7 @@ struct wmEventHandler_Keymap *WM_event_add_keymap_handler_dynamic(
return handler;
}
-/* priorities not implemented yet, for time being just insert in begin of list */
+/* Priorities not implemented yet, for time being just insert in begin of list. */
wmEventHandler_Keymap *WM_event_add_keymap_handler_priority(ListBase *handlers,
wmKeyMap *keymap,
int UNUSED(priority))
@@ -3865,7 +3834,7 @@ wmEventHandler_UI *WM_event_add_ui_handler(const bContext *C,
return handler;
}
-/* set "postpone" for win->modalhandlers, this is in a running for () loop in wm_handlers_do() */
+/* Set "postpone" for win->modalhandlers, this is in a running for () loop in wm_handlers_do(). */
void WM_event_remove_ui_handler(ListBase *handlers,
wmUIHandlerFunc handle_fn,
wmUIHandlerRemoveFunc remove_fn,
@@ -3877,7 +3846,7 @@ void WM_event_remove_ui_handler(ListBase *handlers,
wmEventHandler_UI *handler = (wmEventHandler_UI *)handler_base;
if ((handler->handle_fn == handle_fn) && (handler->remove_fn == remove_fn) &&
(handler->user_data == user_data)) {
- /* handlers will be freed in wm_handlers_do() */
+ /* Handlers will be freed in wm_handlers_do(). */
if (postpone) {
handler->head.flag |= WM_HANDLER_DO_FREE;
}
@@ -3910,7 +3879,7 @@ void WM_event_free_ui_handler_all(bContext *C,
wmEventHandler_Dropbox *WM_event_add_dropbox_handler(ListBase *handlers, ListBase *dropboxes)
{
- /* only allow same dropbox once */
+ /* Only allow same dropbox once. */
LISTBASE_FOREACH (wmEventHandler *, handler_base, handlers) {
if (handler_base->type == WM_HANDLER_TYPE_DROPBOX) {
wmEventHandler_Dropbox *handler = (wmEventHandler_Dropbox *)handler_base;
@@ -3923,7 +3892,7 @@ wmEventHandler_Dropbox *WM_event_add_dropbox_handler(ListBase *handlers, ListBas
wmEventHandler_Dropbox *handler = MEM_callocN(sizeof(*handler), __func__);
handler->head.type = WM_HANDLER_TYPE_DROPBOX;
- /* dropbox stored static, no free or copy */
+ /* Dropbox stored static, no free or copy. */
handler->dropboxes = dropboxes;
BLI_addhead(handlers, handler);
@@ -4134,7 +4103,7 @@ static void wm_eventemulation(wmEvent *event, bool test_only)
}
}
else if (event->val == KM_RELEASE) {
- /* only send middle-mouse release if emulated */
+ /* Only send middle-mouse release if emulated. */
if (emulating_event == MIDDLEMOUSE) {
event->type = MIDDLEMOUSE;
*mod = 0;
@@ -4147,7 +4116,7 @@ static void wm_eventemulation(wmEvent *event, bool test_only)
}
}
- /* numpad emulation */
+ /* Numpad emulation. */
if (U.flag & USER_NONUMPAD) {
switch (event->type) {
case EVT_ZEROKEY:
@@ -4224,7 +4193,7 @@ void wm_tablet_data_from_ghost(const GHOST_TabletData *tablet_data, wmTabletData
}
#ifdef WITH_INPUT_NDOF
-/* adds customdata to event */
+/* Adds customdata to event. */
static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *ghost)
{
wmNDOFMotionData *data = MEM_mallocN(sizeof(wmNDOFMotionData), "customdata NDOF");
@@ -4252,7 +4221,7 @@ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *g
}
#endif /* WITH_INPUT_NDOF */
-/* imperfect but probably usable... draw/enable drags to other windows */
+/* Imperfect but probably usable... draw/enable drags to other windows. */
static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *event)
{
int mval[2] = {event->x, event->y};
@@ -4261,23 +4230,21 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi
return NULL;
}
- /* in order to use window size and mouse position (pixels), we have to use a WM function */
+ /* In order to use window size and mouse position (pixels), we have to use a WM function. */
/* check if outside, include top window bar... */
if (mval[0] < 0 || mval[1] < 0 || mval[0] > WM_window_pixels_x(win) ||
mval[1] > WM_window_pixels_y(win) + 30) {
- wmWindow *owin;
- wmEventHandler *handler;
-
/* Let's skip windows having modal handlers now */
/* potential XXX ugly... I wouldn't have added a modalhandlers list
* (introduced in rev 23331, ton). */
- for (handler = win->modalhandlers.first; handler; handler = handler->next) {
+ LISTBASE_FOREACH (wmEventHandler *, handler, &win->modalhandlers) {
if (ELEM(handler->type, WM_HANDLER_TYPE_UI, WM_HANDLER_TYPE_OP)) {
return NULL;
}
}
+ wmWindow *owin;
if (WM_window_find_under_cursor(wm, win, win, mval, &owin, mval)) {
event->x = mval[0];
event->y = mval[1];
@@ -4292,7 +4259,7 @@ static bool wm_event_is_double_click(const wmEvent *event, const wmEvent *event_
if ((event->type == event_state->prevtype) && (event_state->prevval == KM_RELEASE) &&
(event->val == KM_PRESS)) {
if (ISMOUSE(event->type) && WM_event_drag_test(event, &event_state->prevclickx)) {
- /* pass */
+ /* Pass. */
}
else {
if ((PIL_check_seconds_timer() - event_state->prevclicktime) * 1000 < U.dbl_click_time) {
@@ -4308,9 +4275,9 @@ static wmEvent *wm_event_add_mousemove(wmWindow *win, const wmEvent *event)
{
wmEvent *event_last = win->queue.last;
- /* some painting operators want accurate mouse events, they can
+ /* Some painting operators want accurate mouse events, they can
* handle in between mouse move moves, others can happily ignore
- * them for better performance */
+ * them for better performance. */
if (event_last && event_last->type == MOUSEMOVE) {
event_last->type = INBETWEEN_MOUSEMOVE;
}
@@ -4324,12 +4291,10 @@ static wmEvent *wm_event_add_mousemove(wmWindow *win, const wmEvent *event)
return event_new;
}
-/* windows store own event queues, no bContext here */
-/* time is in 1000s of seconds, from ghost */
+/* Windows store own event queues, no bContext here. */
+/* Time is in 1000s of seconds, from Ghost. */
void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void *customdata)
{
- wmWindow *owin;
-
if (UNLIKELY(G.f & G_FLAG_EVENT_SIMULATE)) {
return;
}
@@ -4346,12 +4311,12 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
*/
wmEvent event, *evt = win->eventstate;
- /* initialize and copy state (only mouse x y and modifiers) */
+ /* Initialize and copy state (only mouse x y and modifiers). */
event = *evt;
event.is_repeat = false;
switch (type) {
- /* mouse move, also to inactive window (X11 does this) */
+ /* Mouse move, also to inactive window (X11 does this). */
case GHOST_kEventCursorMove: {
GHOST_TEventCursorData *cd = customdata;
@@ -4368,9 +4333,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
evt->tablet.is_motion_absolute = event_new->tablet.is_motion_absolute;
}
- /* also add to other window if event is there, this makes overdraws disappear nicely */
- /* it remaps mousecoord to other window in event */
- owin = wm_event_cursor_other_windows(wm, win, &event);
+ /* Also add to other window if event is there, this makes overdraws disappear nicely. */
+ /* It remaps mousecoord to other window in event. */
+ wmWindow *owin = wm_event_cursor_other_windows(wm, win, &event);
if (owin) {
wmEvent oevent, *oevt = owin->eventstate;
@@ -4413,19 +4378,19 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
event.y = evt->y = pd->y;
event.val = KM_NOTHING;
- /* Use prevx/prevy so we can calculate the delta later */
+ /* Use prevx/prevy so we can calculate the delta later. */
event.prevx = event.x - pd->deltaX;
event.prevy = event.y - (-pd->deltaY);
wm_event_add(win, &event);
break;
}
- /* mouse button */
+ /* ,ouse button, */
case GHOST_kEventButtonDown:
case GHOST_kEventButtonUp: {
GHOST_TEventButtonData *bd = customdata;
- /* get value and type from ghost */
+ /* Get value and type from Ghost. */
event.val = (type == GHOST_kEventButtonDown) ? KM_PRESS : KM_RELEASE;
if (bd->button == GHOST_kButtonMaskLeft) {
@@ -4455,15 +4420,15 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
wm_eventemulation(&event, false);
- /* copy previous state to prev event state (two old!) */
+ /* Copy previous state to prev event state (two old!). */
evt->prevval = evt->val;
evt->prevtype = evt->type;
- /* copy to event state */
+ /* Copy to event state. */
evt->val = event.val;
evt->type = event.type;
- /* double click test */
+ /* Double click test. */
if (wm_event_is_double_click(&event, evt)) {
CLOG_INFO(WM_LOG_HANDLERS, 1, "Send double click");
event.val = KM_DBL_CLICK;
@@ -4474,8 +4439,8 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
evt->prevclicky = event.y;
}
- /* add to other window if event is there (not to both!) */
- owin = wm_event_cursor_other_windows(wm, win, &event);
+ /* Add to other window if event is there (not to both!). */
+ wmWindow *owin = wm_event_cursor_other_windows(wm, win, &event);
if (owin) {
wmEvent oevent = *(owin->eventstate);
@@ -4493,34 +4458,34 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
break;
}
- /* keyboard */
+ /* Keyboard. */
case GHOST_kEventKeyDown:
case GHOST_kEventKeyUp: {
GHOST_TEventKeyData *kd = customdata;
short keymodifier = KM_NOTHING;
event.type = convert_key(kd->key);
event.ascii = kd->ascii;
- memcpy(
- event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf)); /* might be not null terminated*/
+ /* Might be not NULL terminated. */
+ memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf));
event.is_repeat = kd->is_repeat;
event.val = (type == GHOST_kEventKeyDown) ? KM_PRESS : KM_RELEASE;
wm_eventemulation(&event, false);
- /* copy previous state to prev event state (two old!) */
+ /* Copy previous state to prev event state (two old!). */
evt->prevval = evt->val;
evt->prevtype = evt->type;
- /* copy to event state */
+ /* Copy to event state. */
evt->val = event.val;
evt->type = event.type;
evt->is_repeat = event.is_repeat;
- /* exclude arrow keys, esc, etc from text input */
+ /* Exclude arrow keys, esc, etc from text input. */
if (type == GHOST_kEventKeyUp) {
event.ascii = '\0';
- /* ghost should do this already for key up */
+ /* Ghost should do this already for key up. */
if (event.utf8_buf[0]) {
CLOG_ERROR(WM_LOG_EVENTS,
"ghost on your platform is misbehaving, utf8 events on key up!");
@@ -4545,7 +4510,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
}
}
- /* assigning both first and second is strange - campbell */
+ /* Assigning both first and second is strange. - campbell */
switch (event.type) {
case EVT_LEFTSHIFTKEY:
case EVT_RIGHTSHIFTKEY:
@@ -4605,20 +4570,20 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
break;
}
- /* double click test */
- /* if previous event was same type, and previous was release, and now it presses... */
+ /* Double click test. */
+ /* If previous event was same type, and previous was release, and now it presses... */
if (wm_event_is_double_click(&event, evt)) {
CLOG_INFO(WM_LOG_HANDLERS, 1, "Send double click");
event.val = KM_DBL_CLICK;
}
- /* this case happens on holding a key pressed, it should not generate
- * press events events with the same key as modifier */
+ /* This case happens on holding a key pressed, it should not generate
+ * press events events with the same key as modifier. */
if (event.keymodifier == event.type) {
event.keymodifier = 0;
}
- /* this case happens with an external numpad, and also when using 'dead keys'
+ /* This case happens with an external numpad, and also when using 'dead keys'
* (to compose complex latin characters e.g.), it's not really clear why.
* Since it's impossible to map a key modifier to an unknown key,
* it shouldn't harm to clear it. */
@@ -4626,15 +4591,15 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
evt->keymodifier = event.keymodifier = 0;
}
- /* if test_break set, it catches this. Do not set with modifier presses.
+ /* If test_break set, it catches this. Do not set with modifier presses.
* XXX Keep global for now? */
if ((event.type == EVT_ESCKEY && event.val == KM_PRESS) &&
- /* check other modifiers because ms-windows uses these to bring up the task manager */
+ /* Check other modifiers because ms-windows uses these to bring up the task manager. */
(event.shift == 0 && event.ctrl == 0 && event.alt == 0)) {
G.is_break = true;
}
- /* double click test - only for press */
+ /* Double click test - only for press. */
if (event.val == KM_PRESS) {
/* Don't reset timer & location when holding the key generates repeat events. */
if ((evt->prevtype != event.type) || (evt->prevval != KM_PRESS)) {
@@ -4837,7 +4802,7 @@ wmKeyMapItem *WM_event_match_keymap_item_from_handlers(bContext *C,
LISTBASE_FOREACH (wmEventHandler *, handler_base, handlers) {
/* During this loop, UI handlers for nested menus can tag multiple handlers free. */
if (handler_base->flag & WM_HANDLER_DO_FREE) {
- /* pass */
+ /* Pass. */
}
else if (handler_base->poll == NULL || handler_base->poll(CTX_wm_region(C), event)) {
if (handler_base->type == WM_HANDLER_TYPE_KEYMAP) {
@@ -5132,7 +5097,7 @@ bool WM_window_modal_keymap_status_draw(bContext *C, wmWindow *win, uiLayout *la
bool show_text = true;
{
- /* warning: O(n^2) */
+ /* Warning: O(n^2). */
wmKeyMapItem *kmi = NULL;
for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (kmi->propvalue == items[i].value) {
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 23571395e24..a862d221815 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -50,6 +50,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "BLI_fileops_types.h"
#include "BLI_linklist.h"
#include "BLI_system.h"
#include "BLI_threads.h"
@@ -2368,10 +2369,47 @@ static int wm_open_mainfile_exec(bContext *C, wmOperator *op)
return wm_open_mainfile__open(C, op);
}
+static char *wm_open_mainfile_description(struct bContext *UNUSED(C),
+ struct wmOperatorType *UNUSED(op),
+ struct PointerRNA *params)
+{
+ if (!RNA_struct_property_is_set(params, "filepath")) {
+ return NULL;
+ }
+
+ /* Filepath. */
+ char path[FILE_MAX];
+ RNA_string_get(params, "filepath", path);
+
+ BLI_stat_t stats;
+ if (BLI_stat(path, &stats) == -1) {
+ return BLI_sprintfN("%s\n\n%s", path, N_("File Not Found"));
+ }
+
+ /* Date. */
+ char date_st[FILELIST_DIRENTRY_DATE_LEN];
+ char time_st[FILELIST_DIRENTRY_TIME_LEN];
+ bool is_today, is_yesterday;
+ BLI_filelist_entry_datetime_to_string(
+ NULL, (int64_t)stats.st_mtime, false, time_st, date_st, &is_today, &is_yesterday);
+ if (is_today || is_yesterday) {
+ BLI_strncpy(date_st, is_today ? N_("Today") : N_("Yesterday"), sizeof(date_st));
+ }
+
+ /* Size. */
+ char size_str[FILELIST_DIRENTRY_SIZE_LEN];
+ BLI_filelist_entry_size_to_string(NULL, (uint64_t)stats.st_size, false, size_str);
+
+ return BLI_sprintfN(
+ "%s\n\n%s: %s %s\n%s: %s", path, N_("Modified"), date_st, time_st, N_("Size"), size_str);
+}
+
/* currently fits in a pointer */
struct FileRuntime {
bool is_untrusted;
};
+BLI_STATIC_ASSERT(sizeof(struct FileRuntime) <= sizeof(void *),
+ "Struct must not exceed pointer size");
static bool wm_open_mainfile_check(bContext *UNUSED(C), wmOperator *op)
{
@@ -2430,6 +2468,7 @@ void WM_OT_open_mainfile(wmOperatorType *ot)
ot->name = "Open";
ot->idname = "WM_OT_open_mainfile";
ot->description = "Open a Blender file";
+ ot->get_description = wm_open_mainfile_description;
ot->invoke = wm_open_mainfile_invoke;
ot->exec = wm_open_mainfile_exec;
@@ -2910,6 +2949,9 @@ static uiBlock *block_create_autorun_warning(struct bContext *C,
{
wmWindowManager *wm = CTX_wm_manager(C);
const uiStyle *style = UI_style_get_dpi();
+ const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points);
+ const int dialog_width = text_points_max * 44 * U.dpi_fac;
+
uiBlock *block = UI_block_begin(C, region, "autorun_warning_popup", UI_EMBOSS);
UI_block_flag_enable(
@@ -2917,15 +2959,8 @@ static uiBlock *block_create_autorun_warning(struct bContext *C,
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
UI_block_emboss_set(block, UI_EMBOSS);
- uiLayout *layout = UI_block_layout(block,
- UI_LAYOUT_VERTICAL,
- UI_LAYOUT_PANEL,
- 10,
- 2,
- U.widget_unit * 24,
- U.widget_unit * 6,
- 0,
- style);
+ uiLayout *layout = UI_block_layout(
+ block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, dialog_width, 0, 0, style);
/* Text and some vertical space */
uiLayout *col = uiLayoutColumn(layout, true);
@@ -3151,8 +3186,9 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
wmGenericCallback *post_action = (wmGenericCallback *)arg1;
Main *bmain = CTX_data_main(C);
const uiStyle *style = UI_style_get_dpi();
- const int dialog_width = U.widget_unit * 22;
const short icon_size = 64 * U.dpi_fac;
+ const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points);
+ const int dialog_width = icon_size + (text_points_max * 34 * U.dpi_fac);
/* Calculate icon column factor. */
const float split_factor = (float)icon_size / (float)(dialog_width - style->columnspace);
@@ -3172,7 +3208,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
/* Alert Icon. */
uiLayout *layout = uiLayoutColumn(split_block, false);
- uiDefButAlert(block, ALERT_ICON_WARNING, 0, 0, 0, icon_size);
+ uiDefButAlert(block, ALERT_ICON_QUESTION, 0, 0, 0, icon_size);
/* The rest of the content on the right. */
layout = uiLayoutColumn(split_block, false);
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 860c1d40dd9..cfbc037d19c 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -890,6 +890,9 @@ static void lib_relocate_do(Main *bmain,
ID *new_id = item->new_id;
lib_relocate_do_remap(bmain, old_id, new_id, reports, do_reload, remap_flags);
+ if (new_id == NULL) {
+ continue;
+ }
/* Usual special code for ShapeKeys snowflakes... */
Key **old_key_p = BKE_key_from_id_p(old_id);
if (old_key_p == NULL) {
@@ -1057,6 +1060,15 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
return OPERATOR_CANCELLED;
}
+ if (BLI_path_cmp(BKE_main_blendfile_path(bmain), path) == 0) {
+ BKE_reportf(op->reports,
+ RPT_ERROR_INVALID_INPUT,
+ "Cannot relocate library '%s' to current blend file '%s'",
+ lib->id.name,
+ path);
+ return OPERATOR_CANCELLED;
+ }
+
if (BLI_path_cmp(lib->filepath_abs, path) == 0) {
#ifdef PRINT_DEBUG
printf("We are supposed to reload '%s' lib (%d)...\n", lib->filepath, lib->id.us);
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 5a22e990218..ac9d3848f3a 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -86,6 +86,7 @@
#ifdef WITH_PYTHON
# include "BPY_extern.h"
# include "BPY_extern_python.h"
+# include "BPY_extern_run.h"
#endif
#include "GHOST_C-api.h"
@@ -202,7 +203,7 @@ static void sound_jack_sync_callback(Main *bmain, int mode, double time)
wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *window = wm->windows.first; window != NULL; window = window->next) {
+ LISTBASE_FOREACH (wmWindow *, window, &wm->windows) {
Scene *scene = WM_window_get_active_scene(window);
if ((scene->audio.flag & AUDIO_SYNC) == 0) {
continue;
@@ -334,9 +335,7 @@ void WM_init(bContext *C, int argc, const char **argv)
* Will try fix when the crash can be repeated. - campbell. */
#ifdef WITH_PYTHON
- BPY_context_set(C); /* necessary evil */
- BPY_python_start(argc, argv);
-
+ BPY_python_start(C, argc, argv);
BPY_python_reset(C);
#else
(void)argc; /* unused */
@@ -480,8 +479,6 @@ void WM_exit_ex(bContext *C, const bool do_python)
/* modal handlers are on window level freed, others too? */
/* note; same code copied in wm_files.c */
if (C && wm) {
- wmWindow *win;
-
if (!G.background) {
struct MemFile *undo_memfile = wm->undo_stack ?
ED_undosys_stack_memfile_get_active(wm->undo_stack) :
@@ -508,8 +505,7 @@ void WM_exit_ex(bContext *C, const bool do_python)
WM_jobs_kill_all(wm);
- for (win = wm->windows.first; win; win = win->next) {
-
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
CTX_wm_window_set(C, win); /* needed by operator close callbacks */
WM_event_remove_handlers(C, &win->handlers);
WM_event_remove_handlers(C, &win->modalhandlers);
@@ -525,6 +521,14 @@ void WM_exit_ex(bContext *C, const bool do_python)
}
}
+#ifdef WITH_PYTHON
+ /* Without this, we there isn't a good way to manage false-positive resource leaks
+ * where a #PyObject references memory allocated with guarded-alloc, T71362.
+ *
+ * This allows add-ons to free resources when unregistered (which is good practice anyway). */
+ BPY_run_string_eval(C, (const char *[]){"addon_utils", NULL}, "addon_utils.disable_all()");
+#endif
+
BLI_timer_free();
WM_paneltype_clear();
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index c9b125901e7..361b3ed3d7f 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -159,24 +159,22 @@ static void wm_job_main_thread_yield(wmJob *wm_job)
*/
static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
{
- wmJob *wm_job;
-
if (owner && job_type) {
- for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
+ LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
if (wm_job->owner == owner && wm_job->job_type == job_type) {
return wm_job;
}
}
}
else if (owner) {
- for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
+ LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
if (wm_job->owner == owner) {
return wm_job;
}
}
}
else if (job_type) {
- for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
+ LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
if (wm_job->job_type == job_type) {
return wm_job;
}
@@ -443,7 +441,11 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test)
/* Possible suspend ourselves, waiting for other jobs, or de-suspend. */
test->suspended = suspend;
- // if (suspend) printf("job suspended: %s\n", test->name);
+#if 0
+ if (suspend) {
+ printf("job suspended: %s\n", test->name);
+ }
+#endif
}
/**
@@ -679,8 +681,14 @@ void wm_jobs_timer(wmWindowManager *wm, wmTimer *wt)
wm_job->run_customdata = NULL;
wm_job->run_free = NULL;
- // if (wm_job->stop) printf("job ready but stopped %s\n", wm_job->name);
- // else printf("job finished %s\n", wm_job->name);
+#if 0
+ if (wm_job->stop) {
+ printf("job ready but stopped %s\n", wm_job->name);
+ }
+ else {
+ printf("job finished %s\n", wm_job->name);
+ }
+#endif
if (G.debug & G_DEBUG_JOBS) {
printf("Job '%s' finished in %f seconds\n",
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 3d9ca281897..3b792744d40 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -147,17 +147,12 @@ static void wm_keymap_item_properties_update_ot(wmKeyMapItem *kmi)
static void wm_keymap_item_properties_update_ot_from_list(ListBase *km_lb)
{
- wmKeyMap *km;
- wmKeyMapItem *kmi;
-
- for (km = km_lb->first; km; km = km->next) {
- wmKeyMapDiffItem *kmdi;
-
- for (kmi = km->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMap *, km, km_lb) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &km->items) {
wm_keymap_item_properties_update_ot(kmi);
}
- for (kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) {
+ LISTBASE_FOREACH (wmKeyMapDiffItem *, kmdi, &km->diff_items) {
if (kmdi->add_item) {
wm_keymap_item_properties_update_ot(kmdi->add_item);
}
diff --git a/source/blender/windowmanager/intern/wm_menu_type.c b/source/blender/windowmanager/intern/wm_menu_type.c
index dc4efe79433..0c52e636e4d 100644
--- a/source/blender/windowmanager/intern/wm_menu_type.c
+++ b/source/blender/windowmanager/intern/wm_menu_type.c
@@ -41,10 +41,8 @@ static GHash *menutypes_hash = NULL;
MenuType *WM_menutype_find(const char *idname, bool quiet)
{
- MenuType *mt;
-
if (idname[0]) {
- mt = BLI_ghash_lookup(menutypes_hash, idname);
+ MenuType *mt = BLI_ghash_lookup(menutypes_hash, idname);
if (mt) {
return mt;
}
@@ -71,12 +69,10 @@ bool WM_menutype_add(MenuType *mt)
void WM_menutype_freelink(MenuType *mt)
{
- bool ok;
-
- ok = BLI_ghash_remove(menutypes_hash, mt->idname, NULL, MEM_freeN);
+ bool ok = BLI_ghash_remove(menutypes_hash, mt->idname, NULL, MEM_freeN);
BLI_assert(ok);
- (void)ok;
+ UNUSED_VARS_NDEBUG(ok);
}
/* called on initialize WM_init() */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 9d99e671369..c51086c5f0a 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -235,8 +235,6 @@ char *WM_operator_pystring_ex(bContext *C,
/* for building the string */
DynStr *dynstr = BLI_dynstr_new();
- char *cstring;
- char *cstring_args;
/* arbitrary, but can get huge string with stroke painting otherwise */
int max_prop_length = 10;
@@ -259,7 +257,7 @@ char *WM_operator_pystring_ex(bContext *C,
opmptr = &opmptr_default;
}
- cstring_args = RNA_pointer_as_string_id(C, opmptr);
+ char *cstring_args = RNA_pointer_as_string_id(C, opmptr);
if (first_op) {
BLI_dynstr_appendf(dynstr, "%s=%s", opm->type->idname, cstring_args);
first_op = false;
@@ -284,7 +282,7 @@ char *WM_operator_pystring_ex(bContext *C,
opptr = &opptr_default;
}
- cstring_args = RNA_pointer_as_string_keywords(
+ char *cstring_args = RNA_pointer_as_string_keywords(
C, opptr, false, all_args, macro_args_test, max_prop_length);
BLI_dynstr_append(dynstr, cstring_args);
MEM_freeN(cstring_args);
@@ -296,7 +294,7 @@ char *WM_operator_pystring_ex(bContext *C,
BLI_dynstr_append(dynstr, ")");
- cstring = BLI_dynstr_get_cstring(dynstr);
+ char *cstring = BLI_dynstr_get_cstring(dynstr);
BLI_dynstr_free(dynstr);
return cstring;
}
@@ -367,7 +365,7 @@ static const char *wm_context_member_from_ptr(bContext *C, const PointerRNA *ptr
for (link = lb.first; link; link = link->next) {
const char *identifier = link->data;
PointerRNA ctx_item_ptr = {
- {0}}; // CTX_data_pointer_get(C, identifier); // XXX, this isnt working
+ {0}}; /* CTX_data_pointer_get(C, identifier); */ /* XXX, this isn't working. */
if (ctx_item_ptr.type == NULL) {
continue;
@@ -559,9 +557,7 @@ const char *WM_context_member_from_ptr(bContext *C, const PointerRNA *ptr)
char *WM_prop_pystring_assign(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index)
{
- char *lhs, *rhs, *ret;
-
- lhs = C ? wm_prop_pystring_from_context(C, ptr, prop, index) : NULL;
+ char *lhs = C ? wm_prop_pystring_from_context(C, ptr, prop, index) : NULL;
if (lhs == NULL) {
/* fallback to bpy.data.foo[id] if we dont find in the context */
@@ -572,13 +568,13 @@ char *WM_prop_pystring_assign(bContext *C, PointerRNA *ptr, PropertyRNA *prop, i
return NULL;
}
- rhs = RNA_property_as_string(C, ptr, prop, index, INT_MAX);
+ char *rhs = RNA_property_as_string(C, ptr, prop, index, INT_MAX);
if (!rhs) {
MEM_freeN(lhs);
return NULL;
}
- ret = BLI_sprintfN("%s = %s", lhs, rhs);
+ char *ret = BLI_sprintfN("%s = %s", lhs, rhs);
MEM_freeN(lhs);
MEM_freeN(rhs);
return ret;
@@ -686,8 +682,7 @@ bool WM_operator_properties_default(PointerRNA *ptr, const bool do_update)
void WM_operator_properties_reset(wmOperator *op)
{
if (op->ptr->data) {
- PropertyRNA *iterprop;
- iterprop = RNA_struct_iterator_property(op->type->srna);
+ PropertyRNA *iterprop = RNA_struct_iterator_property(op->type->srna);
RNA_PROP_BEGIN (op->ptr, itemptr, iterprop) {
PropertyRNA *prop = itemptr.data;
@@ -733,11 +728,10 @@ static bool operator_last_properties_init_impl(wmOperator *op, IDProperty *last_
bool changed = false;
IDPropertyTemplate val = {0};
IDProperty *replaceprops = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
- PropertyRNA *iterprop;
CLOG_INFO(WM_LOG_OPERATORS, 1, "loading previous properties for '%s'", op->type->idname);
- iterprop = RNA_struct_iterator_property(op->type->srna);
+ PropertyRNA *iterprop = RNA_struct_iterator_property(op->type->srna);
RNA_PROP_BEGIN (op->ptr, itemptr, iterprop) {
PropertyRNA *prop = itemptr.data;
@@ -846,9 +840,7 @@ int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
int ret_value = 0;
/* get settings from RNA properties for operator */
- int mval[2];
- mval[0] = RNA_int_get(op->ptr, "mouse_x");
- mval[1] = RNA_int_get(op->ptr, "mouse_y");
+ const int mval[2] = {RNA_int_get(op->ptr, "mouse_x"), RNA_int_get(op->ptr, "mouse_y")};
if (init_event_type == 0) {
if (event->val == KM_PRESS) {
@@ -955,8 +947,6 @@ int WM_operator_smooth_viewtx_get(const wmOperator *op)
int WM_menu_invoke_ex(bContext *C, wmOperator *op, int opcontext)
{
PropertyRNA *prop = op->type->prop;
- uiPopupMenu *pup;
- uiLayout *layout;
if (prop == NULL) {
CLOG_ERROR(WM_LOG_OPERATORS, "'%s' has no enum property set", op->type->idname);
@@ -973,8 +963,8 @@ int WM_menu_invoke_ex(bContext *C, wmOperator *op, int opcontext)
return retval;
}
else {
- pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE);
- layout = UI_popup_menu_layout(pup);
+ uiPopupMenu *pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE);
+ uiLayout *layout = UI_popup_menu_layout(pup);
/* set this so the default execution context is the same as submenus */
uiLayoutSetOperatorContext(layout, opcontext);
uiItemsFullEnumO(
@@ -1011,10 +1001,8 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *region, void *arg)
const int height = search_menu->use_previews ? 5 * U.widget_unit * search_menu->prv_rows :
UI_searchbox_size_y();
static char search[256] = "";
- uiBlock *block;
- uiBut *but;
- block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
+ uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
@@ -1037,20 +1025,20 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *region, void *arg)
0,
"");
#endif
- but = uiDefSearchButO_ptr(block,
- op->type,
- op->ptr->data,
- search,
- 0,
- ICON_VIEWZOOM,
- sizeof(search),
- 10,
- 10,
- width,
- UI_UNIT_Y,
- search_menu->prv_rows,
- search_menu->prv_cols,
- "");
+ uiBut *but = uiDefSearchButO_ptr(block,
+ op->type,
+ op->ptr->data,
+ search,
+ 0,
+ ICON_VIEWZOOM,
+ sizeof(search),
+ 10,
+ 10,
+ width,
+ UI_UNIT_Y,
+ search_menu->prv_rows,
+ search_menu->prv_cols,
+ "");
/* fake button, it holds space for search items */
uiDefBut(block,
@@ -1110,8 +1098,6 @@ int WM_operator_confirm_message_ex(bContext *C,
const char *message,
const short opcontext)
{
- uiPopupMenu *pup;
- uiLayout *layout;
IDProperty *properties = op->ptr->data;
if (properties && properties->len) {
@@ -1121,8 +1107,8 @@ int WM_operator_confirm_message_ex(bContext *C,
properties = NULL;
}
- pup = UI_popup_menu_begin(C, title, icon);
- layout = UI_popup_menu_layout(pup);
+ uiPopupMenu *pup = UI_popup_menu_begin(C, title, icon);
+ uiLayout *layout = UI_popup_menu_layout(pup);
uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, opcontext, 0, NULL);
UI_popup_menu_end(C, pup);
@@ -1161,10 +1147,9 @@ int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *UNUSED(event
bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct ImageFormatData *im_format)
{
- PropertyRNA *prop;
char filepath[FILE_MAX];
/* dont NULL check prop, this can only run on ops with a 'filepath' */
- prop = RNA_struct_find_property(op->ptr, "filepath");
+ PropertyRNA *prop = RNA_struct_find_property(op->ptr, "filepath");
RNA_property_string_get(op->ptr, prop, filepath);
if (BKE_image_path_ensure_ext_from_imformat(filepath, im_format)) {
RNA_property_string_set(op->ptr, prop, filepath);
@@ -1196,16 +1181,15 @@ bool WM_operator_check_ui_enabled(const bContext *C, const char *idname)
wmOperator *WM_operator_last_redo(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
- wmOperator *op;
/* only for operators that are registered and did an undo push */
- for (op = wm->operators.last; op; op = op->prev) {
+ LISTBASE_FOREACH_BACKWARD (wmOperator *, op, &wm->operators) {
if ((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO)) {
- break;
+ return op;
}
}
- return op;
+ return NULL;
}
IDProperty *WM_operator_last_properties_ensure_idprops(wmOperatorType *ot)
@@ -1313,12 +1297,10 @@ static void wm_block_redo_cancel_cb(bContext *C, void *arg_op)
static uiBlock *wm_block_create_redo(bContext *C, ARegion *region, void *arg_op)
{
wmOperator *op = arg_op;
- uiBlock *block;
- uiLayout *layout;
const uiStyle *style = UI_style_get_dpi();
int width = 15 * UI_UNIT_X;
- block = UI_block_begin(C, region, __func__, UI_EMBOSS);
+ uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
UI_block_flag_disable(block, UI_BLOCK_LOOP);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_REGULAR);
@@ -1330,7 +1312,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *region, void *arg_op)
BLI_assert(op->type->flag & OPTYPE_REGISTER);
UI_block_func_handle_set(block, wm_block_redo_cb, arg_op);
- layout = UI_block_layout(
+ uiLayout *layout = UI_block_layout(
block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, UI_UNIT_Y, 0, style);
if (op == WM_operator_last_redo(C)) {
@@ -1386,11 +1368,9 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *userD
{
wmOpPopUp *data = userData;
wmOperator *op = data->op;
- uiBlock *block;
- uiLayout *layout;
const uiStyle *style = UI_style_get_dpi();
- block = UI_block_begin(C, region, __func__, UI_EMBOSS);
+ uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
UI_block_flag_disable(block, UI_BLOCK_LOOP);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_REGULAR);
@@ -1398,7 +1378,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *userD
* where quitting by accident is very annoying */
UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_NUMSELECT);
- layout = UI_block_layout(
+ uiLayout *layout = UI_block_layout(
block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style);
uiTemplateOperatorPropertyButs(
@@ -1409,17 +1389,13 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *userD
/* new column so as not to interfere with custom layouts T26436. */
{
- uiBlock *col_block;
- uiLayout *col;
- uiBut *btn;
-
- col = uiLayoutColumn(layout, false);
- col_block = uiLayoutGetBlock(col);
+ uiLayout *col = uiLayoutColumn(layout, false);
+ uiBlock *col_block = uiLayoutGetBlock(col);
/* Create OK button, the callback of which will execute op */
- btn = uiDefBut(
+ uiBut *but = uiDefBut(
col_block, UI_BTYPE_BUT, 0, IFACE_("OK"), 0, -30, 0, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
- UI_but_flag_enable(btn, UI_BUT_ACTIVE_DEFAULT);
- UI_but_func_set(btn, dialog_exec_cb, data, col_block);
+ UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT);
+ UI_but_func_set(but, dialog_exec_cb, data, col_block);
}
/* center around the mouse */
@@ -1435,16 +1411,14 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *region, void *userDa
{
wmOpPopUp *data = userData;
wmOperator *op = data->op;
- uiBlock *block;
- uiLayout *layout;
const uiStyle *style = UI_style_get_dpi();
- block = UI_block_begin(C, region, __func__, UI_EMBOSS);
+ uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
UI_block_flag_disable(block, UI_BLOCK_LOOP);
UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_REGULAR);
- layout = UI_block_layout(
+ uiLayout *layout = UI_block_layout(
block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style);
/* since ui is defined the auto-layout args are not used */
@@ -1689,25 +1663,23 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *region, void *userdat
{
const struct SearchPopupInit_Data *init_data = userdata;
static char search[256] = "";
- uiBlock *block;
- uiBut *but;
- block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
+ uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
- but = uiDefSearchBut(block,
- search,
- 0,
- ICON_VIEWZOOM,
- sizeof(search),
- 10,
- 10,
- init_data->size[0],
- UI_UNIT_Y,
- 0,
- 0,
- "");
+ uiBut *but = uiDefSearchBut(block,
+ search,
+ 0,
+ ICON_VIEWZOOM,
+ sizeof(search),
+ 10,
+ 10,
+ init_data->size[0],
+ UI_UNIT_Y,
+ 0,
+ 0,
+ "");
if (init_data->search_type == SEARCH_TYPE_OPERATOR) {
UI_but_func_operator_search(but);
@@ -2233,10 +2205,9 @@ static void radial_control_set_tex(RadialControl *rc)
static void radial_control_paint_tex(RadialControl *rc, float radius, float alpha)
{
- float col[3] = {0, 0, 0};
- float rot;
/* set fill color */
+ float col[3] = {0, 0, 0};
if (rc->fill_col_prop) {
PointerRNA *fill_ptr;
PropertyRNA *fill_prop;
@@ -2262,7 +2233,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
/* set up rotation if available */
if (rc->rot_prop) {
- rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop);
+ float rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop);
GPU_matrix_push();
GPU_matrix_rotate_2d(RAD2DEGF(rot));
}
@@ -2493,8 +2464,6 @@ static int radial_control_get_path(PointerRNA *ctx_ptr,
RCPropFlags flags)
{
PropertyRNA *unused_prop;
- int len;
- char *str;
/* check flags */
if ((flags & RC_PROP_REQUIRE_BOOL) && (flags & RC_PROP_REQUIRE_FLOAT)) {
@@ -2503,6 +2472,7 @@ static int radial_control_get_path(PointerRNA *ctx_ptr,
}
/* get an rna string path from the operator's properties */
+ char *str;
if (!(str = RNA_string_get_alloc(op->ptr, name, NULL, 0))) {
return 1;
}
@@ -2542,6 +2512,7 @@ static int radial_control_get_path(PointerRNA *ctx_ptr,
}
/* check property's array length */
+ int len;
if (*r_prop && (len = RNA_property_array_length(r_ptr, *r_prop)) != req_length) {
MEM_freeN(str);
BKE_reportf(op->reports,
@@ -2562,13 +2533,13 @@ static int radial_control_get_path(PointerRNA *ctx_ptr,
static int radial_control_get_properties(bContext *C, wmOperator *op)
{
RadialControl *rc = op->customdata;
- PointerRNA ctx_ptr, use_secondary_ptr;
- PropertyRNA *use_secondary_prop = NULL;
- const char *data_path;
+ PointerRNA ctx_ptr;
RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr);
/* check if we use primary or secondary path */
+ PointerRNA use_secondary_ptr;
+ PropertyRNA *use_secondary_prop = NULL;
if (!radial_control_get_path(&ctx_ptr,
op,
"use_secondary",
@@ -2579,6 +2550,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
return 0;
}
+ const char *data_path;
if (use_secondary_prop && RNA_property_boolean_get(&use_secondary_ptr, use_secondary_prop)) {
data_path = "data_path_secondary";
}
@@ -2798,14 +2770,13 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even
float new_value, dist = 0.0f, zoom[2];
float delta[2];
int ret = OPERATOR_RUNNING_MODAL;
- bool snap;
float angle_precision = 0.0f;
const bool has_numInput = hasNumInput(&rc->num_input);
bool handled = false;
float numValue;
/* TODO: fix hardcoded events */
- snap = event->ctrl != 0;
+ bool snap = event->ctrl != 0;
/* Modal numinput active, try to handle numeric inputs first... */
if (event->val == KM_PRESS && has_numInput && handleNumInput(C, &rc->num_input, event)) {
@@ -3115,10 +3086,11 @@ static void WM_OT_radial_control(wmOperatorType *ot)
static void redraw_timer_window_swap(bContext *C)
{
wmWindow *win = CTX_wm_window(C);
- ScrArea *area;
+ bScreen *screen = CTX_wm_screen(C);
+
CTX_wm_menu_set(C, NULL);
- for (area = CTX_wm_screen(C)->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
ED_area_tag_redraw(area);
}
wm_draw_update(C);
@@ -3171,16 +3143,12 @@ static void redraw_timer_step(bContext *C,
}
else if (type == eRTDrawWindow) {
bScreen *screen = WM_window_get_active_screen(win);
- ScrArea *area_iter;
CTX_wm_menu_set(C, NULL);
- for (area_iter = screen->areabase.first; area_iter; area_iter = area_iter->next) {
- ARegion *region_iter;
+ LISTBASE_FOREACH (ScrArea *, area_iter, &screen->areabase) {
CTX_wm_area_set(C, area_iter);
-
- for (region_iter = area_iter->regionbase.first; region_iter;
- region_iter = region_iter->next) {
+ LISTBASE_FOREACH (ARegion *, region_iter, &area_iter->regionbase) {
if (region_iter->visible) {
CTX_wm_region_set(C, region_iter);
wm_draw_region_test(C, area_iter, region_iter);
@@ -3232,12 +3200,10 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
wmWindowManager *wm = CTX_wm_manager(C);
- double time_start, time_delta;
const int type = RNA_enum_get(op->ptr, "type");
const int iter = RNA_int_get(op->ptr, "iterations");
const double time_limit = (double)RNA_float_get(op->ptr, "time_limit");
const int cfra = scene->r.cfra;
- int a, iter_steps = 0;
const char *infostr = "";
/* NOTE: Depsgraph is used to update scene for a new state, so no need to ensure evaluation here.
@@ -3246,11 +3212,12 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
WM_cursor_wait(1);
- time_start = PIL_check_seconds_timer();
+ double time_start = PIL_check_seconds_timer();
wm_window_make_drawable(wm, win);
- for (a = 0; a < iter; a++) {
+ int iter_steps = 0;
+ for (int a = 0; a < iter; a++) {
redraw_timer_step(C, scene, depsgraph, win, area, region, type, cfra);
iter_steps += 1;
@@ -3262,7 +3229,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
}
}
- time_delta = (PIL_check_seconds_timer() - time_start) * 1000;
+ double time_delta = (PIL_check_seconds_timer() - time_start) * 1000;
RNA_enum_description(redraw_timer_type_items, type, &infostr);
@@ -3377,20 +3344,17 @@ static int previews_ensure_exec(bContext *C, wmOperator *UNUSED(op))
ListBase *lb[] = {
&bmain->materials, &bmain->textures, &bmain->images, &bmain->worlds, &bmain->lights, NULL};
PreviewsIDEnsureData preview_id_data;
- Scene *scene;
- ID *id;
- int i;
/* We use LIB_TAG_DOIT to check whether we have already handled a given ID or not. */
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
- for (i = 0; lb[i]; i++) {
+ for (int i = 0; lb[i]; i++) {
BKE_main_id_tag_listbase(lb[i], LIB_TAG_DOIT, true);
}
preview_id_data.C = C;
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
preview_id_data.scene = scene;
- id = (ID *)scene;
+ ID *id = (ID *)scene;
BKE_library_foreach_ID_link(
NULL, id, previews_id_ensure_callback, &preview_id_data, IDWALK_RECURSE);
@@ -3398,8 +3362,8 @@ static int previews_ensure_exec(bContext *C, wmOperator *UNUSED(op))
/* Check a last time for ID not used (fake users only, in theory), and
* do our best for those, using current scene... */
- for (i = 0; lb[i]; i++) {
- for (id = lb[i]->first; id; id = id->next) {
+ for (int i = 0; lb[i]; i++) {
+ LISTBASE_FOREACH (ID *, id, lb[i]) {
if (id->tag & LIB_TAG_DOIT) {
previews_id_ensure(C, NULL, id);
id->tag &= ~LIB_TAG_DOIT;
@@ -3512,11 +3476,10 @@ static int previews_clear_exec(bContext *C, wmOperator *op)
&bmain->images,
NULL,
};
- int i;
const int id_filters = preview_filter_to_idfilter(RNA_enum_get(op->ptr, "id_type"));
- for (i = 0; lb[i]; i++) {
+ for (int i = 0; lb[i]; i++) {
ID *id = lb[i]->first;
if (!id) {
continue;
@@ -3893,7 +3856,9 @@ static void gesture_box_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "NODE_OT_viewer_border");
WM_modalkeymap_assign(keymap, "PAINT_OT_hide_show");
WM_modalkeymap_assign(keymap, "OUTLINER_OT_select_box");
- // WM_modalkeymap_assign(keymap, "SCREEN_OT_box_select"); // template
+#if 0 /* Template. */
+ WM_modalkeymap_assign(keymap, "SCREEN_OT_box_select");
+#endif
WM_modalkeymap_assign(keymap, "SEQUENCER_OT_select_box");
WM_modalkeymap_assign(keymap, "SEQUENCER_OT_view_ghost_border");
WM_modalkeymap_assign(keymap, "UV_OT_select_box");
diff --git a/source/blender/windowmanager/intern/wm_panel_type.c b/source/blender/windowmanager/intern/wm_panel_type.c
index 1d2fecd0de6..24508c377a6 100644
--- a/source/blender/windowmanager/intern/wm_panel_type.c
+++ b/source/blender/windowmanager/intern/wm_panel_type.c
@@ -41,10 +41,8 @@ static GHash *g_paneltypes_hash = NULL;
PanelType *WM_paneltype_find(const char *idname, bool quiet)
{
- PanelType *pt;
-
if (idname[0]) {
- pt = BLI_ghash_lookup(g_paneltypes_hash, idname);
+ PanelType *pt = BLI_ghash_lookup(g_paneltypes_hash, idname);
if (pt) {
return pt;
}
@@ -65,12 +63,10 @@ bool WM_paneltype_add(PanelType *pt)
void WM_paneltype_remove(PanelType *pt)
{
- bool ok;
-
- ok = BLI_ghash_remove(g_paneltypes_hash, pt->idname, NULL, NULL);
+ const bool ok = BLI_ghash_remove(g_paneltypes_hash, pt->idname, NULL, NULL);
BLI_assert(ok);
- (void)ok;
+ UNUSED_VARS_NDEBUG(ok);
}
/* called on initialize WM_init() */
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index e3c763930c0..5d1607fe506 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -270,9 +270,8 @@ static PlayAnimPict *playanim_step(PlayAnimPict *playanim, int step)
static int pupdate_time(void)
{
static double ltime;
- double time;
- time = PIL_check_seconds_timer();
+ double time = PIL_check_seconds_timer();
ptottime += (time - ltime);
ltime = time;
@@ -282,9 +281,6 @@ static int pupdate_time(void)
static void playanim_toscreen(
PlayState *ps, PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep)
{
- float offs_x, offs_y;
- float span_x, span_y;
-
if (ibuf == NULL) {
printf("%s: no ibuf for picture '%s'\n", __func__, picture ? picture->name : "<NIL>");
return;
@@ -300,12 +296,12 @@ static void playanim_toscreen(
GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
/* size within window */
- span_x = (ps->zoom * ibuf->x) / (float)ps->win_x;
- span_y = (ps->zoom * ibuf->y) / (float)ps->win_y;
+ float span_x = (ps->zoom * ibuf->x) / (float)ps->win_x;
+ float span_y = (ps->zoom * ibuf->y) / (float)ps->win_y;
/* offset within window */
- offs_x = 0.5f * (1.0f - span_x);
- offs_y = 0.5f * (1.0f - span_y);
+ float offs_x = 0.5f * (1.0f - span_x);
+ float offs_y = 0.5f * (1.0f - span_y);
CLAMP(offs_x, 0.0f, 1.0f);
CLAMP(offs_y, 0.0f, 1.0f);
@@ -392,26 +388,19 @@ static void playanim_toscreen(
static void build_pict_list_ex(
PlayState *ps, const char *first, int totframes, int fstep, int fontid)
{
- char filepath[FILE_MAX];
- uchar *mem;
- // short val;
- PlayAnimPict *picture = NULL;
- struct ImBuf *ibuf = NULL;
- struct anim *anim;
-
if (IMB_isanim(first)) {
/* OCIO_TODO: support different input color space */
- anim = IMB_open_anim(first, IB_rect, 0, NULL);
+ struct anim *anim = IMB_open_anim(first, IB_rect, 0, NULL);
if (anim) {
int pic;
- ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
+ struct ImBuf *ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
if (ibuf) {
playanim_toscreen(ps, NULL, ibuf, fontid, fstep);
IMB_freeImBuf(ibuf);
}
for (pic = 0; pic < IMB_anim_get_duration(anim, IMB_TC_NONE); pic++) {
- picture = (PlayAnimPict *)MEM_callocN(sizeof(PlayAnimPict), "Pict");
+ PlayAnimPict *picture = (PlayAnimPict *)MEM_callocN(sizeof(PlayAnimPict), "Pict");
picture->anim = anim;
picture->frame = pic;
picture->IB_flags = IB_rect;
@@ -432,6 +421,7 @@ static void build_pict_list_ex(
unsigned short digits;
} fp_decoded;
+ char filepath[FILE_MAX];
BLI_strncpy(filepath, first, sizeof(filepath));
fp_framenr = BLI_path_sequence_decode(
filepath, fp_decoded.head, fp_decoded.tail, &fp_decoded.digits);
@@ -461,7 +451,7 @@ static void build_pict_list_ex(
return;
}
- picture = (PlayAnimPict *)MEM_callocN(sizeof(PlayAnimPict), "picture");
+ PlayAnimPict *picture = (PlayAnimPict *)MEM_callocN(sizeof(PlayAnimPict), "picture");
if (picture == NULL) {
printf("Not enough memory for pict struct '%s'\n", filepath);
close(file);
@@ -478,6 +468,7 @@ static void build_pict_list_ex(
picture->size = size;
picture->IB_flags = IB_rect;
+ uchar *mem;
if (fromdisk == false) {
mem = MEM_mallocN(size, "build pic list");
if (mem == NULL) {
@@ -510,6 +501,7 @@ static void build_pict_list_ex(
if (ptottime > 1.0) {
/* OCIO_TODO: support different input color space */
+ struct ImBuf *ibuf;
if (picture->mem) {
ibuf = IMB_ibImageFromMemory(
picture->mem, picture->size, picture->IB_flags, NULL, picture->name);
diff --git a/source/blender/windowmanager/intern/wm_splash_screen.c b/source/blender/windowmanager/intern/wm_splash_screen.c
index e9be0c33735..ec1c4440474 100644
--- a/source/blender/windowmanager/intern/wm_splash_screen.c
+++ b/source/blender/windowmanager/intern/wm_splash_screen.c
@@ -156,8 +156,6 @@ static ImBuf *wm_block_splash_image(int width, int *r_height)
extern int datatoc_splash_png_size;
ImBuf *ibuf = NULL;
- int height = 0;
-
if (U.app_template[0] != '\0') {
char splash_filepath[FILE_MAX];
char template_directory[FILE_MAX];
@@ -174,6 +172,7 @@ static ImBuf *wm_block_splash_image(int width, int *r_height)
ibuf = IMB_ibImageFromMemory(splash_data, splash_data_size, IB_rect, NULL, "<splash screen>");
}
+ int height = 0;
if (ibuf) {
height = (width * ibuf->y) / ibuf->x;
if (width != ibuf->x || height != ibuf->y) {
@@ -195,11 +194,9 @@ static ImBuf *wm_block_splash_image(int width, int *r_height)
static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSED(arg))
{
- uiBlock *block;
- uiBut *but;
const uiStyle *style = UI_style_get_dpi();
- block = UI_block_begin(C, region, "splash", UI_EMBOSS);
+ uiBlock *block = UI_block_begin(C, region, "splash", UI_EMBOSS);
/* note on UI_BLOCK_NO_WIN_CLIP, the window size is not always synchronized
* with the OS when the splash shows, window clipping in this case gives
@@ -207,14 +204,17 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSE
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
- int splash_width = 500.0f * U.dpi_fac;
+ const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points);
+ int splash_width = text_points_max * 45 * U.dpi_fac;
+ CLAMP_MAX(splash_width, CTX_wm_window(C)->sizex * 0.7f);
int splash_height;
/* Would be nice to support caching this, so it only has to be re-read (and likely resized) on
* first draw or if the image changed. */
ImBuf *ibuf = wm_block_splash_image(splash_width, &splash_height);
- but = uiDefButImage(block, ibuf, 0, 0.5f * U.widget_unit, splash_width, splash_height, NULL);
+ uiBut *but = uiDefButImage(
+ block, ibuf, 0, 0.5f * U.widget_unit, splash_width, splash_height, NULL);
UI_but_func_set(but, wm_block_close, block, NULL);
UI_block_func_set(block, wm_block_splash_refreshmenu, block, NULL);
@@ -262,15 +262,15 @@ void WM_OT_splash(wmOperatorType *ot)
static uiBlock *wm_block_create_about(bContext *C, ARegion *region, void *UNUSED(arg))
{
- uiBlock *block;
const uiStyle *style = UI_style_get_dpi();
- const int dialog_width = U.widget_unit * 24;
const short logo_size = 128 * U.dpi_fac;
+ const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points);
+ const int dialog_width = logo_size + (text_points_max * 32 * U.dpi_fac);
/* Calculate icon column factor. */
const float split_factor = (float)logo_size / (float)(dialog_width - style->columnspace);
- block = UI_block_begin(C, region, "about", UI_EMBOSS);
+ uiBlock *block = UI_block_begin(C, region, "about", UI_EMBOSS);
UI_block_flag_enable(
block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_LOOP | UI_BLOCK_NO_WIN_CLIP | UI_BLOCK_NUMSELECT);
diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c
index 948b6854b02..fb9c71163c8 100644
--- a/source/blender/windowmanager/intern/wm_stereo.c
+++ b/source/blender/windowmanager/intern/wm_stereo.c
@@ -70,7 +70,7 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view)
soffx = 0;
}
}
- else { // RIGHT_LEFT_ID
+ else { /* #RIGHT_LEFT_ID */
if (cross_eyed) {
soffx = 0;
}
@@ -262,10 +262,10 @@ static bool wm_stereo3d_set_properties(bContext *UNUSED(C), wmOperator *op)
static void wm_stereo3d_set_init(bContext *C, wmOperator *op)
{
- Stereo3dData *s3dd;
wmWindow *win = CTX_wm_window(C);
- op->customdata = s3dd = MEM_callocN(sizeof(Stereo3dData), __func__);
+ Stereo3dData *s3dd = MEM_callocN(sizeof(Stereo3dData), __func__);
+ op->customdata = s3dd;
/* store the original win stereo 3d settings in case of cancel */
s3dd->stereo3d_format = *win->stereo3d_format;
@@ -278,7 +278,6 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
wmWindow *win_dst = NULL;
const bool is_fullscreen = WM_window_is_fullscreen(win_src);
char prev_display_mode = win_src->stereo3d_format->display_mode;
- Stereo3dData *s3dd;
bool ok = true;
if (G.background) {
@@ -291,7 +290,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
wm_stereo3d_set_properties(C, op);
}
- s3dd = op->customdata;
+ Stereo3dData *s3dd = op->customdata;
*win_src->stereo3d_format = s3dd->stereo3d_format;
if (prev_display_mode == S3D_DISPLAY_PAGEFLIP &&
diff --git a/source/blender/windowmanager/intern/wm_uilist_type.c b/source/blender/windowmanager/intern/wm_uilist_type.c
index 801043a56d1..ef6d855cb36 100644
--- a/source/blender/windowmanager/intern/wm_uilist_type.c
+++ b/source/blender/windowmanager/intern/wm_uilist_type.c
@@ -38,10 +38,8 @@ static GHash *uilisttypes_hash = NULL;
uiListType *WM_uilisttype_find(const char *idname, bool quiet)
{
- uiListType *ult;
-
if (idname[0]) {
- ult = BLI_ghash_lookup(uilisttypes_hash, idname);
+ uiListType *ult = BLI_ghash_lookup(uilisttypes_hash, idname);
if (ult) {
return ult;
}
@@ -62,12 +60,11 @@ bool WM_uilisttype_add(uiListType *ult)
void WM_uilisttype_freelink(uiListType *ult)
{
- bool ok;
- ok = BLI_ghash_remove(uilisttypes_hash, ult->idname, NULL, MEM_freeN);
+ bool ok = BLI_ghash_remove(uilisttypes_hash, ult->idname, NULL, MEM_freeN);
BLI_assert(ok);
- (void)ok;
+ UNUSED_VARS_NDEBUG(ok);
}
/* called on initialize WM_init() */
@@ -79,7 +76,6 @@ void WM_uilisttype_init(void)
void WM_uilisttype_free(void)
{
GHashIterator gh_iter;
-
GHASH_ITER (gh_iter, uilisttypes_hash) {
uiListType *ult = BLI_ghashIterator_getValue(&gh_iter);
if (ult->rna_ext.free) {
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index e8575374022..6782d8ea484 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -162,8 +162,7 @@ void wm_get_desktopsize(int *r_width, int *r_height)
/* XXX solve dual screen... */
static void wm_window_check_position(rcti *rect)
{
- int width, height, d;
-
+ int width, height;
wm_get_screensize(&width, &height);
if (rect->xmin < 0) {
@@ -175,12 +174,12 @@ static void wm_window_check_position(rcti *rect)
rect->ymin = 0;
}
if (rect->xmax > width) {
- d = rect->xmax - width;
+ int d = rect->xmax - width;
rect->xmax -= d;
rect->xmin -= d;
}
if (rect->ymax > height) {
- d = rect->ymax - height;
+ int d = rect->ymax - height;
rect->ymax -= d;
rect->ymin -= d;
}
@@ -223,8 +222,6 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
* ED_screen_exit should have been called */
void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
{
- wmTimer *wt, *wtnext;
-
/* update context */
if (C) {
WM_event_remove_handlers(C, &win->handlers);
@@ -238,16 +235,14 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
BKE_screen_area_map_free(&win->global_areas);
/* end running jobs, a job end also removes its timer */
- for (wt = wm->timers.first; wt; wt = wtnext) {
- wtnext = wt->next;
+ LISTBASE_FOREACH_MUTABLE (wmTimer *, wt, &wm->timers) {
if (wt->win == win && wt->event_type == TIMERJOBS) {
wm_jobs_timer_ended(wm, wt);
}
}
/* timer removing, need to call this api function */
- for (wt = wm->timers.first; wt; wt = wtnext) {
- wtnext = wt->next;
+ LISTBASE_FOREACH_MUTABLE (wmTimer *, wt, &wm->timers) {
if (wt->win == win) {
WM_event_remove_timer(wm, win, wt);
}
@@ -275,10 +270,9 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
static int find_free_winid(wmWindowManager *wm)
{
- wmWindow *win;
int id = 1;
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (id <= win->winid) {
id = win->winid + 1;
}
@@ -314,7 +308,6 @@ wmWindow *wm_window_copy(Main *bmain,
wmWindow *win_dst = wm_window_new(bmain, wm, win_parent, is_dialog);
WorkSpace *workspace = WM_window_get_active_workspace(win_src);
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win_src);
- WorkSpaceLayout *layout_new;
win_dst->posx = win_src->posx + 10;
win_dst->posy = win_src->posy;
@@ -324,9 +317,9 @@ wmWindow *wm_window_copy(Main *bmain,
win_dst->scene = win_src->scene;
STRNCPY(win_dst->view_layer_name, win_src->view_layer_name);
BKE_workspace_active_set(win_dst->workspace_hook, workspace);
- layout_new = duplicate_layout ?
- ED_workspace_layout_duplicate(bmain, workspace, layout_old, win_dst) :
- layout_old;
+ WorkSpaceLayout *layout_new = duplicate_layout ? ED_workspace_layout_duplicate(
+ bmain, workspace, layout_old, win_dst) :
+ layout_old;
BKE_workspace_active_layout_set(win_dst->workspace_hook, win_dst->winid, workspace, layout_new);
*win_dst->stereo3d_format = *win_src->stereo3d_format;
@@ -345,9 +338,8 @@ wmWindow *wm_window_copy_test(bContext *C,
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win_dst;
- win_dst = wm_window_copy(bmain, wm, win_src, duplicate_layout, child);
+ wmWindow *win_dst = wm_window_copy(bmain, wm, win_src, duplicate_layout, child);
WM_check(C);
@@ -568,11 +560,9 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
wmWindow *win,
bool is_dialog)
{
- GHOST_WindowHandle ghostwin;
- GHOST_GLSettings glSettings = {0};
- int scr_w, scr_h, posy;
/* a new window is created when pageflip mode is required for a window */
+ GHOST_GLSettings glSettings = {0};
if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) {
glSettings.flags |= GHOST_glStereoVisual;
}
@@ -581,13 +571,15 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
glSettings.flags |= GHOST_glDebugContext;
}
+ int scr_w, scr_h;
wm_get_screensize(&scr_w, &scr_h);
- posy = (scr_h - win->posy - win->sizey);
+ int posy = (scr_h - win->posy - win->sizey);
/* Clear drawable so we can set the new window. */
wmWindow *prev_windrawable = wm->windrawable;
wm_window_clear_drawable(wm);
+ GHOST_WindowHandle ghostwin;
if (is_dialog && win->parent) {
ghostwin = GHOST_CreateDialogWindow(g_system,
win->parent->ghostwin,
@@ -613,8 +605,6 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
}
if (ghostwin) {
- GHOST_RectangleHandle bounds;
-
win->gpuctx = GPU_context_create(ghostwin);
/* needed so we can detect the graphics card below */
@@ -630,7 +620,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
wm_window_ensure_eventstate(win);
/* store actual window size in blender window */
- bounds = GHOST_GetClientBounds(win->ghostwin);
+ GHOST_RectangleHandle bounds = GHOST_GetClientBounds(win->ghostwin);
/* win32: gives undefined window size when minimized */
if (GHOST_GetWindowState(win->ghostwin) != GHOST_kWindowStateMinimized) {
@@ -662,8 +652,6 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
static void wm_window_ghostwindow_ensure(wmWindowManager *wm, wmWindow *win, bool is_dialog)
{
- wmKeyMap *keymap;
-
if (win->ghostwin == NULL) {
if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) {
win->posx = wm_init_state.start_x;
@@ -704,7 +692,7 @@ static void wm_window_ghostwindow_ensure(wmWindowManager *wm, wmWindow *win, boo
}
/* add keymap handlers (1 handler for all keys in map!) */
- keymap = WM_keymap_ensure(wm->defaultconf, "Window", 0, 0);
+ wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Window", 0, 0);
WM_event_add_keymap_handler(&win->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Screen", 0, 0);
@@ -766,12 +754,9 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm)
*/
void wm_window_ghostwindows_remove_invalid(bContext *C, wmWindowManager *wm)
{
- wmWindow *win, *win_next;
-
BLI_assert(G.background == false);
- for (win = wm->windows.first; win; win = win_next) {
- win_next = win->next;
+ LISTBASE_FOREACH_MUTABLE (wmWindow *, win, &wm->windows) {
if (win->ghostwin == NULL) {
wm_window_close(C, wm, win);
}
@@ -781,20 +766,18 @@ void wm_window_ghostwindows_remove_invalid(bContext *C, wmWindowManager *wm)
/* Update window size and position based on data from GHOST window. */
static bool wm_window_update_size_position(wmWindow *win)
{
- GHOST_RectangleHandle client_rect;
- int l, t, r, b, scr_w, scr_h;
- int sizex, sizey, posx, posy;
-
- client_rect = GHOST_GetClientBounds(win->ghostwin);
+ GHOST_RectangleHandle client_rect = GHOST_GetClientBounds(win->ghostwin);
+ int l, t, r, b;
GHOST_GetRectangle(client_rect, &l, &t, &r, &b);
GHOST_DisposeRectangle(client_rect);
+ int scr_w, scr_h;
wm_get_desktopsize(&scr_w, &scr_h);
- sizex = r - l;
- sizey = b - t;
- posx = l;
- posy = scr_h - t - win->sizey;
+ int sizex = r - l;
+ int sizey = b - t;
+ int posx = l;
+ int posy = scr_h - t - win->sizey;
if (win->sizex != sizex || win->sizey != sizey || win->posx != posx || win->posy != posy) {
win->sizex = sizex;
@@ -853,9 +836,6 @@ wmWindow *WM_window_open_temp(bContext *C,
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win_prev = CTX_wm_window(C);
- wmWindow *win;
- bScreen *screen;
- ScrArea *area;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -878,9 +858,11 @@ wmWindow *WM_window_open_temp(bContext *C,
/* Reuse temporary or dialog window if one is open (but don't use a dialog for a regular
* temporary window, or vice versa). */
- for (win = wm->windows.first; win; win = win->next) {
- if (WM_window_is_temp_screen(win) && (dialog == GHOST_IsDialogWindow(win->ghostwin))) {
- break;
+ wmWindow *win = NULL;
+ LISTBASE_FOREACH (wmWindow *, win_iter, &wm->windows) {
+ if (WM_window_is_temp_screen(win_iter) &&
+ (dialog == GHOST_IsDialogWindow(win_iter->ghostwin))) {
+ win = win_iter;
}
}
@@ -892,7 +874,7 @@ wmWindow *WM_window_open_temp(bContext *C,
win->posy = rect.ymin;
}
- screen = WM_window_get_active_screen(win);
+ bScreen *screen = WM_window_get_active_screen(win);
win->sizex = BLI_rcti_size_x(&rect);
win->sizey = BLI_rcti_size_y(&rect);
@@ -934,7 +916,7 @@ wmWindow *WM_window_open_temp(bContext *C,
*/
/* ensure it shows the right spacetype editor */
- area = screen->areabase.first;
+ ScrArea *area = screen->areabase.first;
CTX_wm_area_set(C, area);
ED_area_newspace(C, area, space_type, false);
@@ -977,9 +959,8 @@ int wm_window_close_exec(bContext *C, wmOperator *UNUSED(op))
int wm_window_new_exec(bContext *C, wmOperator *UNUSED(op))
{
wmWindow *win_src = CTX_wm_window(C);
- bool ok;
- ok = (wm_window_copy_test(C, win_src, true, true) != NULL);
+ bool ok = (wm_window_copy_test(C, win_src, true, true) != NULL);
return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -987,9 +968,8 @@ int wm_window_new_exec(bContext *C, wmOperator *UNUSED(op))
int wm_window_new_main_exec(bContext *C, wmOperator *UNUSED(op))
{
wmWindow *win_src = CTX_wm_window(C);
- bool ok;
- ok = (wm_window_copy_test(C, win_src, true, false) != NULL);
+ bool ok = (wm_window_copy_test(C, win_src, true, false) != NULL);
return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -998,13 +978,12 @@ int wm_window_new_main_exec(bContext *C, wmOperator *UNUSED(op))
int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
wmWindow *window = CTX_wm_window(C);
- GHOST_TWindowState state;
if (G.background) {
return OPERATOR_CANCELLED;
}
- state = GHOST_GetWindowState(window->ghostwin);
+ GHOST_TWindowState state = GHOST_GetWindowState(window->ghostwin);
if (state != GHOST_kWindowStateFullScreen) {
GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateFullScreen);
}
@@ -1061,8 +1040,6 @@ typedef enum {
static int query_qual(modifierKeyType qual)
{
GHOST_TModifierKeyMask left, right;
- int val = 0;
-
switch (qual) {
case SHIFT:
left = GHOST_kModifierKeyLeftShift;
@@ -1082,6 +1059,7 @@ static int query_qual(modifierKeyType qual)
break;
}
+ int val = 0;
GHOST_GetModifierKeyState(g_system, left, &val);
if (!val) {
GHOST_GetModifierKeyState(g_system, right, &val);
@@ -1163,8 +1141,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
if (type == GHOST_kEventQuitRequest) {
/* Find an active window to display quit dialog in. */
GHOST_WindowHandle ghostwin = GHOST_GetEventWindow(evt);
- wmWindow *win;
+ wmWindow *win;
if (ghostwin && GHOST_ValidWindow(g_system, ghostwin)) {
win = GHOST_GetWindowUserData(ghostwin);
}
@@ -1183,7 +1161,6 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
else {
GHOST_WindowHandle ghostwin = GHOST_GetEventWindow(evt);
GHOST_TEventDataPtr data = GHOST_GetEventData(evt);
- wmWindow *win;
/* Ghost now can call this function for life resizes,
* but it should return if WM didn't initialize yet.
@@ -1203,7 +1180,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
puts("<!> event has invalid window");
return 1;
}
- win = GHOST_GetWindowUserData(ghostwin);
+ wmWindow *win = GHOST_GetWindowUserData(ghostwin);
switch (type) {
case GHOST_kEventWindowDeactivate:
@@ -1220,7 +1197,6 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
break;
case GHOST_kEventWindowActivate: {
GHOST_TEventKeyData kdata;
- wmEvent event;
const int keymodifier = ((query_qual(SHIFT) ? KM_SHIFT : 0) |
(query_qual(CONTROL) ? KM_CTRL : 0) |
(query_qual(ALT) ? KM_ALT : 0) | (query_qual(OS) ? KM_OSKEY : 0));
@@ -1320,6 +1296,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
* currently it seems to be common practice to generate new event for, but probably
* we'll need utility function for this? (sergey)
*/
+ wmEvent event;
wm_event_init_from_window(win, &event);
event.type = MOUSEMOVE;
event.prevx = event.x;
@@ -1345,8 +1322,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
}
case GHOST_kEventWindowSize:
case GHOST_kEventWindowMove: {
- GHOST_TWindowState state;
- state = GHOST_GetWindowState(win->ghostwin);
+ GHOST_TWindowState state = GHOST_GetWindowState(win->ghostwin);
win->windowstate = state;
WM_window_set_dpi(win);
@@ -1424,7 +1400,6 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
}
case GHOST_kEventOpenMainFile: {
- PointerRNA props_ptr;
const char *path = GHOST_GetEventData(evt);
if (path) {
@@ -1433,6 +1408,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
* it is correctly set */
CTX_wm_window_set(C, win);
+ PointerRNA props_ptr;
WM_operator_properties_create_ptr(&props_ptr, ot);
RNA_string_set(&props_ptr, "filepath", path);
RNA_boolean_set(&props_ptr, "display_file_selector", false);
@@ -1444,12 +1420,12 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
break;
}
case GHOST_kEventDraggingDropDone: {
- wmEvent event;
GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt);
/* entering window, update mouse pos */
wm_window_update_eventstate(win);
+ wmEvent event;
wm_event_init_from_window(win, &event); /* copy last state, like mouse coords */
/* activate region */
@@ -1479,12 +1455,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
if (ddd->dataType == GHOST_kDragnDropTypeFilenames) {
GHOST_TStringArray *stra = ddd->data;
- int a, icon;
- for (a = 0; a < stra->count; a++) {
+ for (int a = 0; a < stra->count; a++) {
printf("drop file %s\n", stra->strings[a]);
/* try to get icon type from extension */
- icon = ED_file_extension_icon((char *)stra->strings[a]);
+ int icon = ED_file_extension_icon((char *)stra->strings[a]);
WM_event_start_drag(C, icon, WM_DRAG_PATH, stra->strings[a], 0.0, WM_DRAG_NOP);
/* void poin should point to string, it makes a copy */
@@ -1495,15 +1470,15 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
break;
}
case GHOST_kEventNativeResolutionChange: {
- // only update if the actual pixel size changes
+ /* Only update if the actual pixel size changes. */
float prev_pixelsize = U.pixelsize;
WM_window_set_dpi(win);
if (U.pixelsize != prev_pixelsize) {
BKE_icon_changed(WM_window_get_active_screen(win)->id.icon_id);
- // close all popups since they are positioned with the pixel
- // size baked in and it's difficult to correct them
+ /* Close all popups since they are positioned with the pixel
+ * size baked in and it's difficult to correct them. */
CTX_wm_window_set(C, win);
UI_popup_handlers_remove_all(C, &win->modalhandlers);
CTX_wm_window_set(C, NULL);
@@ -1560,44 +1535,44 @@ static int wm_window_timer(const bContext *C)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
- wmTimer *wt, *wtnext;
- wmWindow *win;
double time = PIL_check_seconds_timer();
int retval = 0;
- for (wt = wm->timers.first; wt; wt = wtnext) {
- wtnext = wt->next; /* in case timer gets removed */
- win = wt->win;
+ /* Mutable in case the timer gets removed. */
+ LISTBASE_FOREACH_MUTABLE (wmTimer *, wt, &wm->timers) {
+ wmWindow *win = wt->win;
- if (wt->sleep == 0) {
- if (time > wt->ntime) {
- wt->delta = time - wt->ltime;
- wt->duration += wt->delta;
- wt->ltime = time;
- wt->ntime = wt->stime + wt->timestep * ceil(wt->duration / wt->timestep);
+ if (wt->sleep != 0) {
+ continue;
+ }
- if (wt->event_type == TIMERJOBS) {
- wm_jobs_timer(wm, wt);
- }
- else if (wt->event_type == TIMERAUTOSAVE) {
- wm_autosave_timer(bmain, wm, wt);
- }
- else if (wt->event_type == TIMERNOTIFIER) {
- WM_main_add_notifier(POINTER_AS_UINT(wt->customdata), NULL);
- }
- else if (win) {
- wmEvent event;
- wm_event_init_from_window(win, &event);
-
- event.type = wt->event_type;
- event.val = KM_NOTHING;
- event.keymodifier = 0;
- event.custom = EVT_DATA_TIMER;
- event.customdata = wt;
- wm_event_add(win, &event);
-
- retval = 1;
- }
+ if (time > wt->ntime) {
+ wt->delta = time - wt->ltime;
+ wt->duration += wt->delta;
+ wt->ltime = time;
+ wt->ntime = wt->stime + wt->timestep * ceil(wt->duration / wt->timestep);
+
+ if (wt->event_type == TIMERJOBS) {
+ wm_jobs_timer(wm, wt);
+ }
+ else if (wt->event_type == TIMERAUTOSAVE) {
+ wm_autosave_timer(bmain, wm, wt);
+ }
+ else if (wt->event_type == TIMERNOTIFIER) {
+ WM_main_add_notifier(POINTER_AS_UINT(wt->customdata), NULL);
+ }
+ else if (win) {
+ wmEvent event;
+ wm_event_init_from_window(win, &event);
+
+ event.type = wt->event_type;
+ event.val = KM_NOTHING;
+ event.keymodifier = 0;
+ event.custom = EVT_DATA_TIMER;
+ event.customdata = wt;
+ wm_event_add(win, &event);
+
+ retval = 1;
}
}
}
@@ -1606,11 +1581,9 @@ static int wm_window_timer(const bContext *C)
void wm_window_process_events(const bContext *C)
{
- int hasevent;
-
BLI_assert(BLI_thread_is_main());
- hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
+ int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
if (hasevent) {
GHOST_DispatchEvents(g_system);
@@ -1680,17 +1653,12 @@ void WM_event_timer_sleep(wmWindowManager *wm,
wmTimer *timer,
bool do_sleep)
{
- wmTimer *wt;
-
- for (wt = wm->timers.first; wt; wt = wt->next) {
+ LISTBASE_FOREACH (wmTimer *, wt, &wm->timers) {
if (wt == timer) {
+ wt->sleep = do_sleep;
break;
}
}
-
- if (wt) {
- wt->sleep = do_sleep;
- }
}
wmTimer *WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)
@@ -1732,35 +1700,33 @@ wmTimer *WM_event_add_timer_notifier(wmWindowManager *wm,
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
{
- wmTimer *wt;
-
/* extra security check */
- for (wt = wm->timers.first; wt; wt = wt->next) {
- if (wt == timer) {
- break;
+ wmTimer *wt = NULL;
+ LISTBASE_FOREACH (wmTimer *, timer_iter, &wm->timers) {
+ if (timer_iter == timer) {
+ wt = timer_iter;
}
}
- if (wt) {
- wmWindow *win;
+ if (wt == NULL) {
+ return;
+ }
- if (wm->reports.reporttimer == wt) {
- wm->reports.reporttimer = NULL;
- }
+ if (wm->reports.reporttimer == wt) {
+ wm->reports.reporttimer = NULL;
+ }
- BLI_remlink(&wm->timers, wt);
- if (wt->customdata != NULL && (wt->flags & WM_TIMER_NO_FREE_CUSTOM_DATA) == 0) {
- MEM_freeN(wt->customdata);
- }
- MEM_freeN(wt);
-
- /* there might be events in queue with this timer as customdata */
- for (win = wm->windows.first; win; win = win->next) {
- wmEvent *event;
- for (event = win->queue.first; event; event = event->next) {
- if (event->customdata == wt) {
- event->customdata = NULL;
- event->type = EVENT_NONE; /* timer users customdata, dont want NULL == NULL */
- }
+ BLI_remlink(&wm->timers, wt);
+ if (wt->customdata != NULL && (wt->flags & WM_TIMER_NO_FREE_CUSTOM_DATA) == 0) {
+ MEM_freeN(wt->customdata);
+ }
+ MEM_freeN(wt);
+
+ /* there might be events in queue with this timer as customdata */
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
+ LISTBASE_FOREACH (wmEvent *, event, &win->queue) {
+ if (event->customdata == wt) {
+ event->customdata = NULL;
+ event->type = EVENT_NONE; /* timer users customdata, dont want NULL == NULL */
}
}
}
@@ -1780,25 +1746,24 @@ void WM_event_remove_timer_notifier(wmWindowManager *wm, wmWindow *win, wmTimer
static char *wm_clipboard_text_get_ex(bool selection, int *r_len, bool firstline)
{
- char *p, *p2, *buf, *newbuf;
-
if (G.background) {
*r_len = 0;
return NULL;
}
- buf = (char *)GHOST_getClipboard(selection);
+ char *buf = (char *)GHOST_getClipboard(selection);
if (!buf) {
*r_len = 0;
return NULL;
}
/* always convert from \r\n to \n */
- p2 = newbuf = MEM_mallocN(strlen(buf) + 1, __func__);
+ char *newbuf = MEM_mallocN(strlen(buf) + 1, __func__);
+ char *p2 = newbuf;
if (firstline) {
/* will return an over-alloc'ed value in the case there are newlines */
- for (p = buf; *p; p++) {
+ for (char *p = buf; *p; p++) {
if ((*p != '\n') && (*p != '\r')) {
*(p2++) = *p;
}
@@ -1808,7 +1773,7 @@ static char *wm_clipboard_text_get_ex(bool selection, int *r_len, bool firstline
}
}
else {
- for (p = buf; *p; p++) {
+ for (char *p = buf; *p; p++) {
if (*p != '\r') {
*(p2++) = *p;
}
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index b85586691f8..74c2797856d 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -73,7 +73,10 @@ endif()
if(WITH_TBB)
blender_include_dirs(${TBB_INCLUDE_DIRS})
- link_directories(${LIBDIR}/tbb/lib)
+ if(NOT APPLE)
+ # APPLE plaform uses full paths for linking libraries.
+ link_directories(${LIBDIR}/tbb/lib)
+ endif()
endif()
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 80cae248c67..65610ea9b70 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -47,7 +47,7 @@
#include "BLI_threads.h"
#include "BLI_utildefines.h"
-/* mostly init functions */
+/* Mostly init functions. */
#include "BKE_appdir.h"
#include "BKE_blender.h"
#include "BKE_brush.h"
@@ -69,7 +69,7 @@
#include "DEG_depsgraph.h"
-#include "IMB_imbuf.h" /* for IMB_init */
+#include "IMB_imbuf.h" /* For #IMB_init. */
#include "RE_engine.h"
#include "RE_render_ext.h"
@@ -107,7 +107,7 @@
# include "sdlew.h"
#endif
-#include "creator_intern.h" /* own include */
+#include "creator_intern.h" /* Own include. */
/* Local Function prototypes. */
@@ -244,7 +244,7 @@ int main(int argc,
/* --- end declarations --- */
- /* ensure we free data on early-exit */
+ /* Ensure we free data on early-exit. */
struct CreatorAtExitData app_init_data = {NULL};
BKE_blender_atexit_register(callback_main_atexit, &app_init_data);
@@ -320,7 +320,7 @@ int main(int argc,
sdlewInit();
#endif
- /* Initialize logging */
+ /* Initialize logging. */
CLG_init();
CLG_fatal_fn_set(callback_clg_fatal);
@@ -366,7 +366,7 @@ int main(int argc,
fpsetmask(0);
#endif
- /* initialize path to executable */
+ /* Initialize path to executable. */
BKE_appdir_program_path_init(argv[0]);
BLI_threadapi_init();
diff --git a/source/tools b/source/tools
-Subproject 2afbb8ec472cac5102eb239f57b006f8c938768
+Subproject 7011d02c292ac1c91a5c9cc1a075ea2727982ce